remove asm, hsfman start, add vars to interpretasm

This commit is contained in:
CreateSource 2023-12-02 19:47:57 -05:00
parent b60e0eccf6
commit 5a7d9615d3
8 changed files with 6683 additions and 21725 deletions

1
.gitignore vendored
View file

@ -10,3 +10,4 @@ orig/*/*
!orig/*/.gitkeep
/*.txt
ctx.c
tools/output/*

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,391 +0,0 @@
.include "macros.inc"
.file "auto_04_00000000_data"
# 0x00000000 - 0x00000498
.data
.balign 8
.obj lbl_2_data_0, global
.float -7.1875
.endobj lbl_2_data_0
.obj lbl_2_data_4, global
.4byte 0x00000001
.4byte 0x00020003
.4byte 0x00040005
.4byte 0x00060007
.endobj lbl_2_data_4
.obj lbl_2_data_14, global
.4byte 0x44BB8000
.4byte 0x451C4000
.4byte 0x44BB8000
.endobj lbl_2_data_14
.obj lbl_2_data_20, global
.4byte 0x00000000
.4byte 0xBF800000
.4byte 0x00000000
.endobj lbl_2_data_20
.obj lbl_2_data_2C, global
.4byte 0xFFFFFFFF
.endobj lbl_2_data_2C
.obj lbl_2_data_30, global
.float 0
.float 2500
.float 0
.endobj lbl_2_data_30
.obj lbl_2_data_3C, global
.4byte 0x00000000
.4byte 0x3F800000
.4byte 0xBF800000
.endobj lbl_2_data_3C
.obj lbl_2_data_48, global
.float 0
.float 0
.float 0
.endobj lbl_2_data_48
.obj lbl_2_data_54, global
.string "**** M401ObjectSetup ****\n"
.endobj lbl_2_data_54
.obj lbl_2_data_6F, global
.4byte 0x77696E6E
.4byte 0x6572636E
.4byte 0x743A2564
.4byte 0x0A000000
.byte 0x00
.endobj lbl_2_data_6F
.obj lbl_2_data_80, global
.4byte 0x00610000
.4byte 0x00610001
.4byte 0x00610002
.4byte 0x00610003
.4byte 0x00610004
.4byte 0x00610005
.4byte 0x00610006
.4byte 0x00610007
.endobj lbl_2_data_80
.obj lbl_2_data_A0, global
.4byte 0xC3FA0000
.4byte 0xC604D000
.4byte 0xC688B800
.4byte 0xC6CF0800
.4byte 0xC7C15C00
.endobj lbl_2_data_A0
.obj lbl_2_data_B4, global
.4byte 0xC60E3000
.4byte 0xC68D6800
.4byte 0xC6D3B800
.4byte 0xC70D0400
.4byte 0xC7302C00
.4byte 0xC7C35000
.endobj lbl_2_data_B4
.obj lbl_2_data_CC, global
.4byte fn_2_1A38
.4byte fn_2_2CBC
.4byte fn_2_1B80
.4byte fn_2_2D64
.4byte fn_2_1CF0
.4byte fn_2_2DCC
.4byte fn_2_1DE8
.4byte fn_2_2E20
.4byte fn_2_20B0
.4byte fn_2_2ED0
.endobj lbl_2_data_CC
.obj lbl_2_data_F4, global
.string "kaitei01"
.endobj lbl_2_data_F4
.obj lbl_2_data_FD, global
.string "kaitei02"
.endobj lbl_2_data_FD
.obj lbl_2_data_106, global
.string "kaitei03"
.endobj lbl_2_data_106
.obj lbl_2_data_10F, global
.string "kaitei04"
.endobj lbl_2_data_10F
.obj lbl_2_data_118, global
.4byte 0x6B616974
.4byte 0x65693035
.4byte 0x00000000
.endobj lbl_2_data_118
.obj lbl_2_data_124, global
.4byte lbl_2_data_F4
.4byte lbl_2_data_FD
.4byte lbl_2_data_106
.4byte lbl_2_data_10F
.4byte lbl_2_data_118
.4byte 0x005C0002
.4byte 0x005C0002
.4byte 0x005C0002
.4byte 0x005C0002
.4byte 0x005C0002
.4byte 0x005C0002
.4byte 0x005C0002
.4byte 0x005C0002
.endobj lbl_2_data_124
.obj lbl_2_data_158, global
.4byte 0x005F002A
.4byte 0x00200031
.4byte 0x005F0000
.4byte 0x005F002B
.4byte 0x005F0005
.4byte 0x005F0017
.4byte 0x00200039
.4byte 0x00200041
.4byte 0x005F0022
.4byte 0x00200049
.4byte 0x001A002A
.4byte 0x00200032
.4byte 0x001A0000
.4byte 0x001A002B
.4byte 0x001A0005
.4byte 0x001A0017
.4byte 0x0020003A
.4byte 0x00200042
.4byte 0x001A0022
.4byte 0x0020004A
.4byte 0x006D002A
.4byte 0x00200033
.4byte 0x006D0000
.4byte 0x006D002B
.4byte 0x006D0005
.4byte 0x006D0017
.4byte 0x0020003B
.4byte 0x00200043
.4byte 0x006D0022
.4byte 0x0020004B
.4byte 0x008A002A
.4byte 0x00200034
.4byte 0x008A0000
.4byte 0x008A002B
.4byte 0x008A0005
.4byte 0x008A0017
.4byte 0x0020003C
.4byte 0x00200044
.4byte 0x008A0022
.4byte 0x0020004C
.4byte 0x0085002A
.4byte 0x00200035
.4byte 0x00850000
.4byte 0x0085002B
.4byte 0x00850005
.4byte 0x00850017
.4byte 0x0020003D
.4byte 0x00200045
.4byte 0x00850022
.4byte 0x0020004D
.4byte 0x0011002A
.4byte 0x00200036
.4byte 0x00110000
.4byte 0x0011002B
.4byte 0x00110005
.4byte 0x00110017
.4byte 0x0020003E
.4byte 0x00200046
.4byte 0x00110022
.4byte 0x0020004E
.4byte 0x000D002A
.4byte 0x00200037
.4byte 0x000D0000
.4byte 0x000D002B
.4byte 0x000D0005
.4byte 0x000D0017
.4byte 0x0020003F
.4byte 0x00200047
.4byte 0x000D0022
.4byte 0x0020004F
.4byte 0x0081002A
.4byte 0x00200038
.4byte 0x00810000
.4byte 0x0081002B
.4byte 0x00810005
.4byte 0x00810017
.4byte 0x00200040
.4byte 0x00200048
.4byte 0x00810022
.4byte 0x00200050
.endobj lbl_2_data_158
.obj lbl_2_data_298, global
.4byte 0xC3160000
.4byte 0x449C4000
.4byte 0xC4AF0000
.4byte 0xC2480000
.4byte 0x449C4000
.4byte 0xC4AF0000
.4byte 0x42480000
.4byte 0x449C4000
.4byte 0xC4AF0000
.4byte 0x43160000
.4byte 0x449C4000
.4byte 0xC4AF0000
.endobj lbl_2_data_298
.obj lbl_2_data_2C8, global
.4byte 0xC3960000
.4byte 0x00000000
.4byte 0xC4BB8000
.4byte 0xC2C80000
.4byte 0x00000000
.4byte 0xC4BB8000
.4byte 0x42C80000
.4byte 0x00000000
.4byte 0xC4BB8000
.4byte 0x43960000
.4byte 0x00000000
.4byte 0xC4BB8000
.endobj lbl_2_data_2C8
.obj jumptable_2_data_2F8, global
.4byte fn_2_48A0+0xE0
.4byte fn_2_48A0+0x174
.4byte fn_2_48A0+0x330
.4byte fn_2_48A0+0x4A8
.4byte fn_2_48A0+0x13CC
.4byte fn_2_48A0+0x838
.4byte fn_2_48A0+0xBF0
.4byte fn_2_48A0+0xCEC
.4byte fn_2_48A0+0xFC0
.4byte fn_2_48A0+0x1100
.4byte fn_2_48A0+0x1278
.4byte fn_2_48A0+0x68C
.endobj jumptable_2_data_2F8
.obj gap_04_00000328_data, global
.hidden gap_04_00000328_data
.4byte 0x0020000C
.endobj gap_04_00000328_data
.obj lbl_2_data_32C, global
.4byte 0x00000004
.4byte 0x00000006
.endobj lbl_2_data_32C
.obj lbl_2_data_334, global
.4byte 0x44AF0000
.4byte 0xC4160000
.4byte 0xC6A7F800
.4byte 0xC2C80000
.4byte 0x42C80000
.4byte 0xC6ABE000
.4byte 0xC47A0000
.4byte 0xC3480000
.4byte 0xC6B3B000
.4byte 0xC4FA0000
.4byte 0xC3480000
.4byte 0xC6B79800
.4byte 0xC5098000
.4byte 0xC3480000
.4byte 0xC6B79800
.4byte 0xC50FC000
.4byte 0xC3480000
.4byte 0xC6B79800
.4byte 0x00000000
.4byte 0x00000000
.4byte 0x00000000
.4byte 0x00000000
.4byte 0x00000000
.4byte 0x00000000
.4byte 0x00000000
.4byte 0x00000000
.4byte 0x00000000
.4byte 0x00000000
.4byte 0x00000000
.4byte 0x00000000
.4byte 0xC47A0000
.4byte 0x43FA0000
.4byte 0xC6E67800
.4byte 0xC3960000
.4byte 0x43960000
.4byte 0xC6F61800
.4byte 0x43960000
.4byte 0xC3160000
.4byte 0xC6FDE800
.4byte 0xC3480000
.4byte 0x437A0000
.4byte 0xC704D000
.4byte 0xC3960000
.4byte 0x43960000
.4byte 0xC708B800
.4byte 0xC4160000
.4byte 0x43960000
.4byte 0xC70CA000
.4byte 0x447A0000
.4byte 0xC3340000
.4byte 0xC71C4000
.4byte 0x447A0000
.4byte 0xC3340000
.4byte 0xC71C4000
.4byte 0x00000000
.4byte 0x00000000
.4byte 0x00000000
.4byte 0x00000000
.4byte 0x00000000
.4byte 0x00000000
.endobj lbl_2_data_334
.obj lbl_2_data_424, global
.4byte 0x00000032
.4byte 0x0000005F
.endobj lbl_2_data_424
.obj lbl_2_data_42C, global
.4byte 0x0020001C
.4byte 0x0020001D
.4byte 0x0000012D
.4byte 0x0000016D
.4byte 0x000001AD
.4byte 0x000001ED
.4byte 0x0000022D
.4byte 0x0000026D
.4byte 0x000002AD
.4byte 0x000002ED
.endobj lbl_2_data_42C
.obj lbl_2_data_454, global
.string "GetCoin:%d\n"
.endobj lbl_2_data_454
.obj lbl_2_data_460, global
.4byte 0x00200004
.4byte 0x00200005
.4byte 0x00200006
.endobj lbl_2_data_460
.obj lbl_2_data_46C, global
.string "____"
.endobj lbl_2_data_46C
.obj lbl_2_data_471, global
.4byte 0x252E3266
.byte 0x00, 0x00, 0x00
.endobj lbl_2_data_471
.obj jumptable_2_data_478, global
.4byte fn_2_10A88+0x30C
.4byte fn_2_10A88+0x2E4
.4byte fn_2_10A88+0x444
.4byte fn_2_10A88+0x51C
.4byte fn_2_10A88+0x5E0
.4byte fn_2_10A88+0x6B8
.4byte fn_2_10A88+0x790
.4byte fn_2_10A88+0x84C
.endobj jumptable_2_data_478

View file

@ -1,273 +0,0 @@
.include "macros.inc"
.file "auto_05_00000000_bss"
# 0x00000000 - 0x00000254
.section .bss, "wa", @nobits
.balign 8
.obj pad_05_00000000_bss, local
.skip 0x4
.endobj pad_05_00000000_bss
.obj lbl_2_bss_4, global
.skip 0x4
.endobj lbl_2_bss_4
.obj lbl_2_bss_8, global
.skip 0x4
.endobj lbl_2_bss_8
.obj lbl_2_bss_C, global
.skip 0x2
.endobj lbl_2_bss_C
.obj lbl_2_bss_E, global
.skip 0x2
.endobj lbl_2_bss_E
.obj lbl_2_bss_10, global
.skip 0x4
.endobj lbl_2_bss_10
.obj lbl_2_bss_14, global
.skip 0x4
.endobj lbl_2_bss_14
.obj lbl_2_bss_18, global
.skip 0x2
.endobj lbl_2_bss_18
.obj lbl_2_bss_1A, global
.skip 0x2
.endobj lbl_2_bss_1A
.obj lbl_2_bss_1C, global
.skip 0x10
.endobj lbl_2_bss_1C
.obj lbl_2_bss_2C, global
.skip 0xC
.endobj lbl_2_bss_2C
.obj lbl_2_bss_38, global
.skip 0xC
.endobj lbl_2_bss_38
.obj lbl_2_bss_44, global
.skip 0xC
.endobj lbl_2_bss_44
.obj lbl_2_bss_50, global
.skip 0x4
.endobj lbl_2_bss_50
.obj lbl_2_bss_54, global
.skip 0xC
.endobj lbl_2_bss_54
.obj lbl_2_bss_60, global
.skip 0xC
.endobj lbl_2_bss_60
.obj lbl_2_bss_6C, global
.skip 0xC
.endobj lbl_2_bss_6C
.obj lbl_2_bss_78, global
.skip 0xC
.endobj lbl_2_bss_78
.obj lbl_2_bss_84, global
.skip 0x4
.endobj lbl_2_bss_84
.obj lbl_2_bss_88, global
.skip 0x4
.endobj lbl_2_bss_88
.obj lbl_2_bss_8C, global
.skip 0x4
.endobj lbl_2_bss_8C
.obj lbl_2_bss_90, global
.skip 0x14
.endobj lbl_2_bss_90
.obj lbl_2_bss_A4, global
.skip 0x4
.endobj lbl_2_bss_A4
.obj lbl_2_bss_A8, global
.skip 0x2
.endobj lbl_2_bss_A8
.obj lbl_2_bss_AA, global
.skip 0x8
.endobj lbl_2_bss_AA
.obj lbl_2_bss_B2, global
.skip 0x8
.endobj lbl_2_bss_B2
.obj lbl_2_bss_BA, global
.skip 0x2
.endobj lbl_2_bss_BA
.obj gap_05_000000BC_bss, global
.hidden gap_05_000000BC_bss
.skip 0x2
.endobj gap_05_000000BC_bss
.obj lbl_2_bss_BE, global
.skip 0x2
.endobj lbl_2_bss_BE
.obj lbl_2_bss_C0, global
.skip 0x2
.endobj lbl_2_bss_C0
.obj gap_05_000000C2_bss, global
.hidden gap_05_000000C2_bss
.skip 0x2
.endobj gap_05_000000C2_bss
.obj lbl_2_bss_C4, global
.skip 0x4
.endobj lbl_2_bss_C4
.obj lbl_2_bss_C8, global
.skip 0x4
.endobj lbl_2_bss_C8
.obj lbl_2_bss_CC, global
.skip 0x4
.endobj lbl_2_bss_CC
.obj lbl_2_bss_D0, global
.skip 0x4
.endobj lbl_2_bss_D0
.obj lbl_2_bss_D4, global
.skip 0x4
.endobj lbl_2_bss_D4
.obj lbl_2_bss_D8, global
.skip 0x4
.endobj lbl_2_bss_D8
.obj lbl_2_bss_DC, global
.skip 0x4
.endobj lbl_2_bss_DC
.obj lbl_2_bss_E0, global
.skip 0x4
.endobj lbl_2_bss_E0
.obj lbl_2_bss_E4, global
.skip 0x10
.endobj lbl_2_bss_E4
.obj lbl_2_bss_F4, global
.skip 0x4
.endobj lbl_2_bss_F4
.obj lbl_2_bss_F8, global
.skip 0x4
.endobj lbl_2_bss_F8
.obj lbl_2_bss_FC, global
.skip 0x4
.endobj lbl_2_bss_FC
.obj lbl_2_bss_100, global
.skip 0x8
.endobj lbl_2_bss_100
.obj lbl_2_bss_108, global
.skip 0x4
.endobj lbl_2_bss_108
.obj lbl_2_bss_10C, global
.skip 0x4
.endobj lbl_2_bss_10C
.obj lbl_2_bss_110, global
.skip 0x4
.endobj lbl_2_bss_110
.obj lbl_2_bss_114, global
.skip 0x4
.endobj lbl_2_bss_114
.obj lbl_2_bss_118, global
.skip 0x4
.endobj lbl_2_bss_118
.obj lbl_2_bss_11C, global
.skip 0x4
.endobj lbl_2_bss_11C
.obj lbl_2_bss_120, global
.skip 0x2
.endobj lbl_2_bss_120
.obj gap_05_00000122_bss, global
.hidden gap_05_00000122_bss
.skip 0x2
.endobj gap_05_00000122_bss
.obj lbl_2_bss_124, global
.skip 0x4
.endobj lbl_2_bss_124
.obj lbl_2_bss_128, global
.skip 0x4
.endobj lbl_2_bss_128
.obj lbl_2_bss_12C, global
.skip 0x8
.endobj lbl_2_bss_12C
.obj lbl_2_bss_134, global
.skip 0x2
.endobj lbl_2_bss_134
.obj lbl_2_bss_136, global
.skip 0x8
.endobj lbl_2_bss_136
.obj lbl_2_bss_13E, global
.skip 0xE2
.endobj lbl_2_bss_13E
.obj lbl_2_bss_220, global
.skip 0x18
.endobj lbl_2_bss_220
.obj lbl_2_bss_238, global
.skip 0x4
.endobj lbl_2_bss_238
.obj lbl_2_bss_23C, global
.skip 0x4
.endobj lbl_2_bss_23C
.obj lbl_2_bss_240, global
.skip 0x4
.endobj lbl_2_bss_240
.obj lbl_2_bss_244, global
.skip 0x4
.endobj lbl_2_bss_244
.obj lbl_2_bss_248, global
.skip 0x4
.endobj lbl_2_bss_248
.obj lbl_2_bss_24C, global
.skip 0x4
.endobj lbl_2_bss_24C
.obj lbl_2_bss_250, global
.skip 0x4
.endobj lbl_2_bss_250

106
src/game/hsfman.c Normal file
View file

@ -0,0 +1,106 @@
#include "common.h"
typedef struct ThreeDDataStruct {
char unk_00[0xC4];
s32 unk_C4;
char unk_C8[0x5C];
} ThreeDDataStruct;
typedef struct ThreeDCameraStruct {
f32 unk_00;
char unk_04[0x54];
} ThreeDCameraStruct;
typedef struct ThreeDProjectionStruct {
char unk_00[0x4];
s32 unk_04;
char unk_08[0x90];
} ThreeDProjectionStruct;
typedef struct ThreeDShadowStruct {
char unk_00[0x4];
s32 unk_04;
char unk_08[0x90];
} ThreeDShadowStruct;
void Hu3DAnimInit(void);
void Hu3DFogClear(void);
void Hu3DLighInit(void);
void Hu3DMotionInit(void);
void Hu3DParManInit(void);
char *HuSprAnimRead(char*);
s16 Hu3DCameraExistF;
ThreeDDataStruct Hu3DData[0x200];
ThreeDCameraStruct Hu3DCamera[0x10];
s16 Hu3DPauseF;
s16 Hu3DProjectionNum;
s16 Hu3DShadowCamBit;
s32 Hu3DShadowF;
s16 NoSyncF;
f32 lbl_801D4AB0;
s32 modelKillAllF;
char refMapData0[0x1240] = {};
char refMapData1[0x1100] = {};
char refMapData2[0x2080] = {};
char refMapData3[0x2080] = {};
char refMapData4[0x2080] = {};
char toonMapData[0x880] = {};
char toonMapData2[0x1080] = {};
char hiliteData[0x480] = {};
char hiliteData2[0x480] = {};
char hiliteData3[0x480] = {};
char hiliteData4[0x480] = {};
s16 reflectMapNo;
char *toonAnim;
s16 layerNum[8];
s32 layerHook[8];
char *reflectAnim[5];
char *hiliteAnim[4];
ThreeDProjectionStruct Hu3DProjection[4];
ThreeDShadowStruct Hu3DShadowData;
GXColor BGColor;
void Hu3DInit(void) {
ThreeDDataStruct* data;
ThreeDCameraStruct* camera;
s16 i;
data = Hu3DData;
for (i = 0; i < 0x200; i++, data++) {
data->unk_C4 = 0;
}
camera = Hu3DCamera;
for (i = 0; i < 0x10; i++, camera++) {
camera->unk_00 = lbl_801D4AB0;
}
Hu3DMotionInit();
Hu3DLighInit();
BGColor.r = BGColor.g = BGColor.b = 0;
BGColor.a = 0xFF;
for (i = 0; i < 8; i++) {
layerNum[i] = 0;
layerHook[i] = 0;
}
reflectAnim[0] = HuSprAnimRead(refMapData0);
reflectAnim[1] = HuSprAnimRead(refMapData1);
reflectAnim[2] = HuSprAnimRead(refMapData2);
reflectAnim[3] = HuSprAnimRead(refMapData3);
reflectAnim[4] = HuSprAnimRead(refMapData4);
reflectMapNo = 0;
toonAnim = HuSprAnimRead(toonMapData);
hiliteAnim[0] = HuSprAnimRead(hiliteData);
hiliteAnim[1] = HuSprAnimRead(hiliteData2);
hiliteAnim[2] = HuSprAnimRead(hiliteData3);
hiliteAnim[3] = HuSprAnimRead(hiliteData4);
Hu3DFogClear();
Hu3DAnimInit();
Hu3DParManInit();
for (i = 0; i < 4; i++) {
Hu3DProjection[i].unk_04 = 0;
}
Hu3DShadowCamBit = 0;
Hu3DShadowData.unk_04 = 0;
Hu3DShadowF = 0;
Hu3DProjectionNum = 0;
Hu3DCameraExistF = 0;
modelKillAllF = 0;
Hu3DPauseF = 0;
NoSyncF = 0;
}

6525
tools/hsfman-output.txt Normal file

File diff suppressed because it is too large Load diff

View file

@ -1,4 +1,5 @@
import sys
import os
def rc(s:str)->str: return s.replace(',','')
@ -6,6 +7,7 @@ def join(*args)->str: return " ".join(args)
addrstore = {}
cmpstore = []
isObj = ""
def interpret_cmd(line: list, addr: int)->str:
global addrstore, cmpstore
ret = ""
@ -27,9 +29,9 @@ def interpret_cmd(line: list, addr: int)->str:
elif "w" in line[0]: ret += join("", "(s32/u32)")
elif "fs" in line[0]: ret += join("", "(f32)")
elif "fd" in line[0]: ret += join("", "(f64)")
elif line[0] == "stbx" or line[0] == "sthx" or line[0] == "stfsx":
elif line[0] == "stbx" or line[0] == "sthx" or line[0] == "stwx" or line[0] == "stfsx":
if "r1" in line[2]: ret = "Stack"
else: ret += rc(line[2])
else: ret = rc(line[2])
ret += join(f"[{line[3]}]",
"=",
@ -61,7 +63,7 @@ def interpret_cmd(line: list, addr: int)->str:
ret = join(rc(line[1]), "=", line[2])
## Loading
elif line[0] == "lbz" or line[0] == "lha" or line[0] == "lhz" or line[0] == "lwz" or line[0] == "lfs" or line[0] == "lfd":
elif line[0] == "lbz" or line[0] == "lha" or line[0] == "lhz" or line[0] == "lwz" or line[0] == "lwzu" or line[0] == "lfs" or line[0] == "lfd":
ret = join(rc(line[1]), "=")
if "r1" in line[2]: ret += join("", "Stack")
else: ret += join("", line[2][(line[2].index("(")+1):-1])
@ -73,7 +75,7 @@ def interpret_cmd(line: list, addr: int)->str:
elif "w" in line[0]: ret += join("", "(s32/u32)")
elif "fs" in line[0]: ret += join("", "(f32)")
elif "fd" in line[0]: ret += join("", "(f64)")
elif line[0] == "lbzx" or line[0] == "lhax" or line[0] == "lwzx" or line[0] == "lfsx":
elif line[0] == "lbzx" or line[0] == "lhax" or line[0] == "lhzx" or line[0] == "lwzx" or line[0] == "lfsx":
ret = join(rc(line[1]), "=")
if "r1" in line[2]: ret += join("", "Stack")
else: ret += join("", rc(line[2]))
@ -126,7 +128,7 @@ def interpret_cmd(line: list, addr: int)->str:
ret += join("", line[3])
elif "neg" in line[0]:
ret = join(rc(line[1]), "=", "-"+line[2])
elif line[0] == "slwi" or line[0] == "slawi":
elif line[0] == "slw" or line[0] == "slwi" or line[0] == "slawi":
ret = join(rc(line[1]), "=", rc(line[2]), "<<", line[3], "(s32/u32)", "(signed)" if line[0] == "slawi" else "")
elif line[0] == "srwi" or line[0] == "srawi":
ret = join(rc(line[1]), "=", rc(line[2]), ">>", line[3], "(s32/u32)", "(signed)" if line[0] == "srawi" else "")
@ -255,9 +257,9 @@ def interpret_cmd(line: list, addr: int)->str:
elif line[0] == "crset":
ret = f"set({line[1]})"
elif line[0] == "extsh":
ret = join("s32", rc(line[1]), "= s16", line[2])
ret = join("(s32)", rc(line[1]), "= (s16)", line[2])
elif line[0] == "extsb":
ret = join("s32", rc(line[1]), "= s8", line[2])
ret = join("(s32)", rc(line[1]), "= (s8)", line[2])
elif line[0] == "clrlwi":
ret = join(rc(line[1]), "=", f"remove({line[2]} {line[3]})")
elif line[0] == "rlwinm":
@ -273,8 +275,27 @@ def interpret_cmd(line: list, addr: int)->str:
return "unable to interpret: "+str(line)
return ret
def interpret_obj(line: list)->str:
global isObj
ret = ""
if line[0] == "\t.4byte":
if isObj == True:
ret = "{\n"
ret += join("\t(s32)", line[1])
elif line[0] == "\t.string":
ret = join("\t(char[])", " ".join(line[1:]))
elif line[0] == "\t.skip":
ret = join("\tsizeof =", line[1])
elif line[0] == "\t.double":
ret = join("\t(f64)", line[1])
elif line[0] == "\t.float":
ret = join("\t(f32)", line[1])
return ret
def interpret_line(line: list)->str:
global addrstore
global addrstore, isObj
line = line.split(" ")
line[-1] = line[-1].replace("\n","")
ret = ""
@ -283,6 +304,12 @@ def interpret_line(line: list)->str:
ret = join(line[2], "function", rc(line[1])+":")
elif line[0] == ".endfn":
ret = join(line[1], "end\n")
elif line[0] == ".obj":
ret = rc(line[1])+":"
isObj = True
elif line[0] == ".endobj" and isObj == True:
ret = "}"
isObj = False
elif ".L" in line[0]:
try:
ret = join("\n\tfrom", addrstore[hex(int(line[0][3:-1], 16))]+":")
@ -294,27 +321,35 @@ def interpret_line(line: list)->str:
ret = join("\t", hex(address), "|",
interpret_cmd(line[8:], address)
)
elif "\t" in line[0]:
ret = interpret_obj(line)
isObj = line[0]
print(line, "\n", ret, "\n")
return ret
tempcounter = 150
def interpret_file(file)->None:
global tempcounter
curdir = os.path.dirname(os.path.abspath(__file__))
fs = file.split("/")[-1]
os.system(f"mkdir {curdir}/output")
f = open(file)
g = open("output.txt", "w")
g = open(f"{curdir}/output/{fs[:(fs.index('.'))]}-output.txt", "w")
line = f.readline()
while line:
ret = interpret_line(line)
g.write(ret+"\n" if ret != "" else "")
line = f.readline()
tempcounter -= 1
g.close()
f.close()
try:
interpret_file(sys.argv[1])
except:
print("interpretasm.py")
print("Usage: python3 interpretasm.py [file]")
print("Accepts all files that use the generated asm from ninja")
except Exception:
if len(sys.argv) == 1:
print("interpretasm.py")
print("Usage: python3 interpretasm.py [file]")
print("Accepts all files that use the generated asm from ninja")
else:
raise Exception