From 229e0c8629b5a3c984a8a2c5ed5aba2aa59d32d7 Mon Sep 17 00:00:00 2001 From: Roman971 <32455037+Roman971@users.noreply.github.com> Date: Mon, 15 Jun 2020 01:24:09 +0200 Subject: [PATCH] Update asm processor and migrate/improve rodata for a few files (#209) * Update asm processor * Migrate or improve rodata for a few files --- asm/code_800E11F0.s | 1 - .../UCodeDisas_Disassemble.rodata.s | 9 +- .../UCodeDisas_Disassemble.rodata2.s | 5 +- .../code/ucode_disas/UCodeDisas_Disassemble.s | 22 +- .../code/z_kankyo/func_8006F140.s | 15 + .../code/z_kankyo/func_8006F9BC.s | 11 + .../code/z_kankyo/func_8006FC88.s | 31 ++ .../code/z_kankyo/func_80070600.s | 7 + .../code/z_kankyo/func_80070718.s | 90 ++++ .../code/z_kankyo/func_80070C24.s | 41 ++ .../code/z_kankyo/func_800730DC.s | 28 ++ .../code/z_kankyo/func_80073A5C.s | 37 ++ .../code/z_kankyo/func_80074704.s | 37 ++ .../code/z_kankyo/func_80074D6C.s | 22 + .../code/z_kankyo/func_80074FF4.s | 10 + .../code/z_kankyo/func_800750C0.s | 8 + .../code/z_kankyo/func_8007542C.s | 24 ++ .../code/z_kankyo/func_800758AC.s | 30 ++ .../code/z_kankyo/func_80075B44.s | 18 + .../code/z_kankyo/func_8007672C.s | 10 + .../code/z_kankyo/func_80076934.s | 17 + asm/non_matchings/code/z_sram/func_800A8484.s | 98 +++++ asm/non_matchings/code/z_sram/func_800A8A20.s | 96 +++++ asm/non_matchings/code/z_sram/func_800A9258.s | 61 +++ asm/non_matchings/code/z_sram/func_800A96D0.s | 7 + asm/non_matchings/code/z_sram/func_800A97F0.s | 20 + asm/non_matchings/code/z_sram/func_800A9AD0.s | 41 ++ asm/non_matchings/code/z_sram/func_800A9CD4.s | 14 + asm/osSetIntMask.s | 70 +++ data/db_camera.data.s | 2 +- data/db_camera.rodata.s | 10 +- data/osSetIntMask.rodata.s | 74 ---- data/z_kankyo.rodata.s | 403 ------------------ data/z_message_PAL.rodata.s | 29 +- data/z_sram.rodata.s | 332 --------------- spec | 3 - tools/asm_processor/asm_processor.py | 101 ++++- 37 files changed, 964 insertions(+), 870 deletions(-) delete mode 100644 data/osSetIntMask.rodata.s delete mode 100644 data/z_kankyo.rodata.s delete mode 100644 data/z_sram.rodata.s diff --git a/asm/code_800E11F0.s b/asm/code_800E11F0.s index 98295a83d1..d1250ada3a 100644 --- a/asm/code_800E11F0.s +++ b/asm/code_800E11F0.s @@ -4956,7 +4956,6 @@ glabel L800E569C /* B5C83C 800E569C 8E090004 */ lw $t1, 4($s0) /* B5C840 800E56A0 3C078017 */ lui $a3, %hi(gAudioContext) # $a3, 0x8017 /* B5C844 800E56A4 24E7F180 */ addiu $a3, %lo(gAudioContext) # addiu $a3, $a3, -0xe80 -glabel L00E5944 /* B5C848 800E56A8 100000A6 */ b .L800E5944 /* B5C84C 800E56AC A0E9289A */ sb $t1, 0x289a($a3) glabel L800E56B0 diff --git a/asm/non_matchings/code/ucode_disas/UCodeDisas_Disassemble.rodata.s b/asm/non_matchings/code/ucode_disas/UCodeDisas_Disassemble.rodata.s index 32af0b27b4..0f69571fcd 100644 --- a/asm/non_matchings/code/ucode_disas/UCodeDisas_Disassemble.rodata.s +++ b/asm/non_matchings/code/ucode_disas/UCodeDisas_Disassemble.rodata.s @@ -1,4 +1,3 @@ - .rdata glabel D_80147E58 .asciz "%08x:" @@ -49,7 +48,7 @@ glabel D_80147F5C .balign 4 glabel D_80147F90 - .asciz "\x23\x23\x23 TileSyncが必要です。\n" + .asciz "### TileSyncが必要です。\n" # EUC-JP: が必要です。| Is required. .balign 4 @@ -62,7 +61,7 @@ glabel D_80147FCC .balign 4 glabel D_80147FEC - .asciz "\x23\x23\x23 LoadSyncが必要です。\n" + .asciz "### LoadSyncが必要です。\n" # EUC-JP: が必要です。| Is required. .balign 4 @@ -79,6 +78,6 @@ glabel D_80148044 .balign 4 glabel D_8014808C - .asciz "\x23\x23\x23 PipeSyncが必要です。\n" + .asciz "### PipeSyncが必要です。\n" # EUC-JP: が必要です。| Is required. - .balign 4 \ No newline at end of file + .balign 4 diff --git a/asm/non_matchings/code/ucode_disas/UCodeDisas_Disassemble.rodata2.s b/asm/non_matchings/code/ucode_disas/UCodeDisas_Disassemble.rodata2.s index cea44e3ae6..a716a55563 100644 --- a/asm/non_matchings/code/ucode_disas/UCodeDisas_Disassemble.rodata2.s +++ b/asm/non_matchings/code/ucode_disas/UCodeDisas_Disassemble.rodata2.s @@ -1,4 +1,3 @@ - .rdata glabel D_80148374 .asciz "gsDP%s(%s)," @@ -9,6 +8,6 @@ glabel D_80148380 .balign 4 glabel D_801483A4 - .asciz "\x23\x23\x23 PipeSyncが必要です。\n" + .asciz "### PipeSyncが必要です。\n" # EUC-JP: が必要です。| Is required. - .balign 4 \ No newline at end of file + .balign 4 diff --git a/asm/non_matchings/code/ucode_disas/UCodeDisas_Disassemble.s b/asm/non_matchings/code/ucode_disas/UCodeDisas_Disassemble.s index 51be390b19..93e6872145 100644 --- a/asm/non_matchings/code/ucode_disas/UCodeDisas_Disassemble.s +++ b/asm/non_matchings/code/ucode_disas/UCodeDisas_Disassemble.s @@ -18,7 +18,7 @@ glabel D_8014845C .balign 4 glabel D_80148480 - .asciz "\x23\x23\x23 PipeSyncが必要です。\n" + .asciz "### PipeSyncが必要です。\n" # EUC-JP: が必要です。 | Is required. .balign 4 @@ -27,7 +27,7 @@ glabel D_8014849C .balign 4 glabel D_801484C0 - .asciz "\x23\x23\x23 PipeSyncが必要です。\n" + .asciz "### PipeSyncが必要です。\n" # EUC-JP: が必要です。 | Is required. .balign 4 @@ -99,7 +99,7 @@ glabel D_801485F4 .balign 4 glabel D_801485F8 - .asciz "\x23\x23\x23 PipeSyncが必要です。\n" + .asciz "### PipeSyncが必要です。\n" # EUC-JP: が必要です。 | Is required. .balign 4 @@ -108,7 +108,7 @@ glabel D_80148614 .balign 4 glabel D_80148638 - .asciz "\x23\x23\x23 PipeSyncが必要です。\n" + .asciz "### PipeSyncが必要です。\n" # EUC-JP: が必要です。 | Is required. .balign 4 @@ -157,7 +157,7 @@ glabel D_801486C0 .balign 4 glabel D_801486E4 - .asciz "\x23\x23\x23 PipeSyncが必要です。\n" + .asciz "### PipeSyncが必要です。\n" # EUC-JP: が必要です。 | Is required. .balign 4 @@ -166,7 +166,7 @@ glabel D_80148700 .balign 4 glabel D_80148724 - .asciz "\x23\x23\x23 PipeSyncが必要です。\n" + .asciz "### PipeSyncが必要です。\n" # EUC-JP: が必要です。 | Is required. .balign 4 @@ -175,7 +175,7 @@ glabel D_80148740 .balign 4 glabel D_80148764 - .asciz "\x23\x23\x23 PipeSyncが必要です。\n" + .asciz "### PipeSyncが必要です。\n" # EUC-JP: が必要です。 | Is required. .balign 4 @@ -184,7 +184,7 @@ glabel D_80148780 .balign 4 glabel D_8014879C - .asciz "\x23\x23\x23 PipeSyncが必要です。\n" + .asciz "### PipeSyncが必要です。\n" # EUC-JP: が必要です。 | Is required. .balign 4 @@ -193,7 +193,7 @@ glabel D_801487B8 .balign 4 glabel D_801487D4 - .asciz "\x23\x23\x23 PipeSyncが必要です。\n" + .asciz "### PipeSyncが必要です。\n" # EUC-JP: が必要です。 | Is required. .balign 4 @@ -206,7 +206,7 @@ glabel D_8014881C .balign 4 glabel D_8014882C - .asciz "\x23\x23\x23 PipeSyncが必要です。\n" + .asciz "### PipeSyncが必要です。\n" # EUC-JP: が必要です。 | Is required. .balign 4 @@ -450,7 +450,7 @@ glabel D_80148EA8 .balign 4 glabel D_80148EC8 - .asciz " \x23 vscale=[%d %d %d %d], " + .asciz " # vscale=[%d %d %d %d], " .balign 4 glabel D_80148EE4 diff --git a/asm/non_matchings/code/z_kankyo/func_8006F140.s b/asm/non_matchings/code/z_kankyo/func_8006F140.s index 9dda194f6c..854e83c28e 100644 --- a/asm/non_matchings/code/z_kankyo/func_8006F140.s +++ b/asm/non_matchings/code/z_kankyo/func_8006F140.s @@ -1,3 +1,18 @@ +.rdata +glabel D_8013C240 + .asciz "\x1b[43;30m\n\nフィールド常駐以外、太陽設定!よって強制解除!\n\x1b[m" + # EUC-JP: フィールド常駐以外、太陽設定!よって強制解除! | "Sun setting except field resident! So forced release!"? + .balign 4 + +.late_rodata +glabel jtbl_8013C790 + .word L8006F4A8 + .word L8006F4CC + .word L8006F4CC + .word L8006F4CC + .word L8006F4F0 + +.text glabel func_8006F140 /* AE62E0 8006F140 3C088016 */ lui $t0, %hi(gSaveContext) # $t0, 0x8016 /* AE62E4 8006F144 2508E660 */ addiu $t0, %lo(gSaveContext) # addiu $t0, $t0, -0x19a0 diff --git a/asm/non_matchings/code/z_kankyo/func_8006F9BC.s b/asm/non_matchings/code/z_kankyo/func_8006F9BC.s index 45335c23a5..a74e6f7f92 100644 --- a/asm/non_matchings/code/z_kankyo/func_8006F9BC.s +++ b/asm/non_matchings/code/z_kankyo/func_8006F9BC.s @@ -1,3 +1,14 @@ +.rdata +glabel D_8013C280 + .asciz "\x1b[41;37m\nend_frameとstart_frameのフレーム関係がおかしい!!!\x1b[m" + # EUC-JP: とstart_frameのフレーム関係がおかしい!!! | The frame relation between end_frame and start_frame is wrong + .balign 4 + +glabel D_8013C2C0 + .asciz "\x1b[41;37m\nby get_parcent_forAccelBrake!!!!!!!!!\x1b[m" + .balign 4 + +.text glabel func_8006F9BC /* AE6B5C 8006F9BC 27BDFFC0 */ addiu $sp, $sp, -0x40 /* AE6B60 8006F9C0 30A3FFFF */ andi $v1, $a1, 0xffff diff --git a/asm/non_matchings/code/z_kankyo/func_8006FC88.s b/asm/non_matchings/code/z_kankyo/func_8006FC88.s index 978c6aa8b5..834392d26f 100644 --- a/asm/non_matchings/code/z_kankyo/func_8006FC88.s +++ b/asm/non_matchings/code/z_kankyo/func_8006FC88.s @@ -1,3 +1,34 @@ +.rdata +glabel D_8013C2F4 + .asciz "\x1b[41;37m\n環境VRデータ取得失敗! ささきまでご報告を!\x1b[m" + # EUC-JP: 環境VRデータ取得失敗! ささきまでご報告を! | Environment VR data acquisition failed! Report to Sasaki! + .balign 4 + +glabel D_8013C330 + .asciz "../z_kankyo.c" + .balign 4 + +glabel D_8013C340 + .asciz "../z_kankyo.c" + .balign 4 + +glabel D_8013C350 + .asciz "../z_kankyo.c" + .balign 4 + +glabel D_8013C360 + .asciz "../z_kankyo.c" + .balign 4 + +glabel D_8013C370 + .asciz "../z_kankyo.c" + .balign 4 + +glabel D_8013C380 + .asciz "../z_kankyo.c" + .balign 4 + +.text glabel func_8006FC88 /* AE6E28 8006FC88 27BDFFA0 */ addiu $sp, $sp, -0x60 /* AE6E2C 8006FC8C AFB00030 */ sw $s0, 0x30($sp) diff --git a/asm/non_matchings/code/z_kankyo/func_80070600.s b/asm/non_matchings/code/z_kankyo/func_80070600.s index 7b1b7e3314..5a28337980 100644 --- a/asm/non_matchings/code/z_kankyo/func_80070600.s +++ b/asm/non_matchings/code/z_kankyo/func_80070600.s @@ -1,3 +1,10 @@ +.rdata +glabel D_8013C390 + .asciz "\x1b[43;30m\n水ポリゴンデータに水中カラーが設定されておりません!\x1b[m" + # EUC-JP: 水ポリゴンデータに水中カラーが設定されておりません | Underwater color is not set in the water poly data + .balign 4 + +.text glabel func_80070600 /* AE77A0 80070600 27BDFFE8 */ addiu $sp, $sp, -0x18 /* AE77A4 80070604 2401001F */ li $at, 31 diff --git a/asm/non_matchings/code/z_kankyo/func_80070718.s b/asm/non_matchings/code/z_kankyo/func_80070718.s index 80334ec3f5..b40164a2ea 100644 --- a/asm/non_matchings/code/z_kankyo/func_80070718.s +++ b/asm/non_matchings/code/z_kankyo/func_80070718.s @@ -1,3 +1,93 @@ +.rdata +glabel D_8013C3D0 + .asciz "T%03d " + .balign 4 + +glabel D_8013C3D8 + .asciz "E%03d" + .balign 4 + +glabel D_8013C3E0 + .asciz "%s" + .balign 4 + +glabel D_8013C3E4 + .asciz "ZELDATIME " + .balign 4 + +glabel D_8013C3F0 + .asciz "%02d" + .balign 4 + +glabel D_8013C3F8 + .asciz "%s" + .balign 4 + +glabel D_8013C3FC + .asciz ":" + .balign 4 + +glabel D_8013C400 + .asciz "%s" + .balign 4 + +glabel D_8013C404 + .asciz " " + .balign 4 + +glabel D_8013C408 + .asciz "%02d" + .balign 4 + +glabel D_8013C410 + .asciz "%s" + .balign 4 + +glabel D_8013C414 + .asciz "VRBOXTIME " + .balign 4 + +glabel D_8013C420 + .asciz "%02d" + .balign 4 + +glabel D_8013C428 + .asciz "%s" + .balign 4 + +glabel D_8013C42C + .asciz ":" + .balign 4 + +glabel D_8013C430 + .asciz "%s" + .balign 4 + +glabel D_8013C434 + .asciz " " + .balign 4 + +glabel D_8013C438 + .asciz "%02d" + .balign 4 + +glabel D_8013C440 + .asciz "%s" + .balign 4 + +glabel D_8013C444 + .asciz "YORU" + .balign 4 + +glabel D_8013C44C + .asciz "%s" + .balign 4 + +glabel D_8013C450 + .asciz "HIRU" + .balign 4 + +.text glabel func_80070718 /* AE78B8 80070718 27BDFF98 */ addiu $sp, $sp, -0x68 /* AE78BC 8007071C AFB00020 */ sw $s0, 0x20($sp) diff --git a/asm/non_matchings/code/z_kankyo/func_80070C24.s b/asm/non_matchings/code/z_kankyo/func_80070C24.s index f99ae72e8a..1e839f2176 100644 --- a/asm/non_matchings/code/z_kankyo/func_80070C24.s +++ b/asm/non_matchings/code/z_kankyo/func_80070C24.s @@ -1,3 +1,44 @@ +.rdata +glabel D_8013C458 + .asciz "\nnext_zelda_time=[%x]" + .balign 4 + +glabel D_8013C470 + .asciz "../z_kankyo.c" + .balign 4 + +glabel D_8013C480 + .asciz "../z_kankyo.c" + .balign 4 + +glabel D_8013C490 + .asciz "\x1b[41;37m\nカラーパレットの設定がおかしいようです!\x1b[m" + # EUC-JP: カラーパレットの設定がおかしいようです! | The color palette settings seem to be wrong! + .balign 4 + +glabel D_8013C4C8 + .asciz "\x1b[41;37m\n設定パレット=[%d] 最後パレット番号=[%d]\n\x1b[m" + # EUC-JP: 設定パレット=[%d] 最後パレット番号= | Set pallet = [% d] Last pallet number = + .balign 4 + +glabel D_8013C500 + .asciz "\n\x1b[31mカラーパレットがおかしいようです!" + # EUC-JP: カラーパレットがおかしいようです! | The color palette seems strange! + .balign 4 + +glabel D_8013C52C + .asciz "\n\x1b[33m設定パレット=[%d] パレット数=[%d]\n\x1b[m" + # EUC-JP: 設定パレット=[%d] パレット数=[%d] | Set pallet = [% d] Number of pallets = [% d] + .balign 4 + +.late_rodata +glabel D_8013C7A4 + .float 0.001 + +glabel D_8013C7A8 + .float 0.005 + +.text glabel func_80070C24 /* AE7DC4 80070C24 27BDFF70 */ addiu $sp, $sp, -0x90 /* AE7DC8 80070C28 3C0D8016 */ lui $t5, %hi(gSaveContext) # $t5, 0x8016 diff --git a/asm/non_matchings/code/z_kankyo/func_800730DC.s b/asm/non_matchings/code/z_kankyo/func_800730DC.s index 9f955639d7..9950378b18 100644 --- a/asm/non_matchings/code/z_kankyo/func_800730DC.s +++ b/asm/non_matchings/code/z_kankyo/func_800730DC.s @@ -1,3 +1,31 @@ +.rdata +glabel D_8013C55C + .asciz "../z_kankyo.c" + .balign 4 + +glabel D_8013C56C + .asciz "../z_kankyo.c" + .balign 4 + +glabel D_8013C57C + .asciz "../z_kankyo.c" + .balign 4 + +glabel D_8013C58C + .asciz "../z_kankyo.c" + .balign 4 + +.late_rodata +glabel D_8013C7AC + .float 0.8 + +glabel D_8013C7B0 + .float 0.8 + +glabel D_8013C7B4 + .float 0.8 + +.text glabel func_800730DC /* AEA27C 800730DC 27BDFF78 */ addiu $sp, $sp, -0x88 /* AEA280 800730E0 AFBF0024 */ sw $ra, 0x24($sp) diff --git a/asm/non_matchings/code/z_kankyo/func_80073A5C.s b/asm/non_matchings/code/z_kankyo/func_80073A5C.s index ad7e35fcb1..9273c49887 100644 --- a/asm/non_matchings/code/z_kankyo/func_80073A5C.s +++ b/asm/non_matchings/code/z_kankyo/func_80073A5C.s @@ -1,3 +1,40 @@ +.rdata +glabel D_8013C59C + .asciz "../z_kankyo.c" + .balign 4 + +glabel D_8013C5AC + .asciz "../z_kankyo.c" + .balign 4 + +glabel D_8013C5BC + .asciz "../z_kankyo.c" + .balign 4 + +.late_rodata +glabel D_8013C7B8 + .float 630 + + .word 0 # forced padding +glabel D_8013C7C0 + .double 0.001 + +glabel D_8013C7C8 + .float 1.0E-4 + +glabel D_8013C7CC + .float 0.001 + +glabel D_8013C7D0 + .float 0.001 + +glabel D_8013C7D4 + .float 0.1 + +glabel D_8013C7D8 + .float 0.1 + +.text glabel func_80073A5C /* AEABFC 80073A5C 27BDFE50 */ addiu $sp, $sp, -0x1b0 /* AEAC00 80073A60 3C0B8012 */ lui $t3, %hi(D_8011FE00) # $t3, 0x8012 diff --git a/asm/non_matchings/code/z_kankyo/func_80074704.s b/asm/non_matchings/code/z_kankyo/func_80074704.s index 4175edb51c..4368b159ed 100644 --- a/asm/non_matchings/code/z_kankyo/func_80074704.s +++ b/asm/non_matchings/code/z_kankyo/func_80074704.s @@ -1,3 +1,40 @@ +.rdata +glabel D_8013C5CC + .asciz "../z_kankyo.c" + .balign 4 + +glabel D_8013C5DC + .asciz "../z_kankyo.c" + .balign 4 + +glabel D_8013C5EC + .asciz "../z_kankyo.c" + .balign 4 + +glabel D_8013C5FC + .asciz "../z_kankyo.c" + .balign 4 + +.late_rodata +glabel D_8013C7DC + .float 0.4 + +glabel D_8013C7E0 + .float 0.7 + +glabel D_8013C7E4 + .float 1.5707964 # M_PI / 2 + +glabel D_8013C7E8 + .float 1.2 + +glabel D_8013C7EC + .float 0.1 + +glabel D_8013C7F0 + .float 0.02 + +.text glabel func_80074704 /* AEB8A4 80074704 27BDFED8 */ addiu $sp, $sp, -0x128 /* AEB8A8 80074708 3C0F8012 */ lui $t7, %hi(D_8011FE70) # $t7, 0x8012 diff --git a/asm/non_matchings/code/z_kankyo/func_80074D6C.s b/asm/non_matchings/code/z_kankyo/func_80074D6C.s index 97e8f62036..3d554658e2 100644 --- a/asm/non_matchings/code/z_kankyo/func_80074D6C.s +++ b/asm/non_matchings/code/z_kankyo/func_80074D6C.s @@ -1,3 +1,25 @@ +.rdata +glabel D_8013C60C + .asciz "../z_kankyo.c" + .balign 4 + +glabel D_8013C61C + .asciz "../z_kankyo.c" + .balign 4 + +glabel D_8013C62C + .asciz "../z_kankyo.c" + .balign 4 + +glabel D_8013C63C + .asciz "../z_kankyo.c" + .balign 4 + +.late_rodata +glabel D_8013C7F4 + .float 0.02 + +.text glabel func_80074D6C /* AEBF0C 80074D6C 27BDFF98 */ addiu $sp, $sp, -0x68 /* AEBF10 80074D70 3C010001 */ lui $at, 1 diff --git a/asm/non_matchings/code/z_kankyo/func_80074FF4.s b/asm/non_matchings/code/z_kankyo/func_80074FF4.s index f9afc06f76..475c93f93c 100644 --- a/asm/non_matchings/code/z_kankyo/func_80074FF4.s +++ b/asm/non_matchings/code/z_kankyo/func_80074FF4.s @@ -1,3 +1,13 @@ +.rdata +glabel D_8013C64C + .asciz "../z_kankyo.c" + .balign 4 + +glabel D_8013C65C + .asciz "../z_kankyo.c" + .balign 4 + +.text glabel func_80074FF4 /* AEC194 80074FF4 27BDFFC8 */ addiu $sp, $sp, -0x38 /* AEC198 80074FF8 AFBF0014 */ sw $ra, 0x14($sp) diff --git a/asm/non_matchings/code/z_kankyo/func_800750C0.s b/asm/non_matchings/code/z_kankyo/func_800750C0.s index 2d6bfd4a2d..cdd559f180 100644 --- a/asm/non_matchings/code/z_kankyo/func_800750C0.s +++ b/asm/non_matchings/code/z_kankyo/func_800750C0.s @@ -1,3 +1,11 @@ +.late_rodata +glabel D_8013C7F8 + .float 0.1 + +glabel D_8013C7FC + .float 2.9 + +.text glabel func_800750C0 /* AEC260 800750C0 27BDFFE0 */ addiu $sp, $sp, -0x20 /* AEC264 800750C4 3C010001 */ lui $at, 1 diff --git a/asm/non_matchings/code/z_kankyo/func_8007542C.s b/asm/non_matchings/code/z_kankyo/func_8007542C.s index cfcabfb81a..2a25eb5718 100644 --- a/asm/non_matchings/code/z_kankyo/func_8007542C.s +++ b/asm/non_matchings/code/z_kankyo/func_8007542C.s @@ -1,3 +1,27 @@ +.rdata +glabel D_8013C66C + .asciz "../z_kankyo.c" + .balign 4 + +glabel D_8013C67C + .asciz "../z_kankyo.c" + .balign 4 + +glabel D_8013C68C + .asciz "../z_kankyo.c" + .balign 4 + +.late_rodata +glabel D_8013C800 + .float 5000 + +glabel D_8013C804 + .float 9500 + +glabel D_8013C808 + .float 0.017453292 + +.text glabel func_8007542C /* AEC5CC 8007542C 27BDFF20 */ addiu $sp, $sp, -0xe0 /* AEC5D0 80075430 3C0F8012 */ lui $t7, %hi(D_8011FE88) # $t7, 0x8012 diff --git a/asm/non_matchings/code/z_kankyo/func_800758AC.s b/asm/non_matchings/code/z_kankyo/func_800758AC.s index 78723c9da9..6fba91f987 100644 --- a/asm/non_matchings/code/z_kankyo/func_800758AC.s +++ b/asm/non_matchings/code/z_kankyo/func_800758AC.s @@ -1,3 +1,33 @@ +.rdata +glabel D_8013C69C + .asciz "\n\n\nBGM設定game_play->sound_info.BGM=[%d] old_bgm=[%d]\n\n" + # EUC-JP: 設定 | Configuration + .balign 4 + +glabel D_8013C6D4 + .asciz "\n-----------------\n" + .balign 4 + +glabel D_8013C6E8 + .asciz "\n 強制BGM=[%d]" + # EUC-JP: 強制BGM | Forced BGM + .balign 4 + +glabel D_8013C6FC + .asciz "\n BGM=[%d]" + # EUC-JP: BGM + .balign 4 + +glabel D_8013C710 + .asciz "\n エンブ=[%d]" + # EUC-JP: エンブ | Emblem? + .balign 4 + +glabel D_8013C724 + .asciz "\n status=[%d]" + .balign 4 + +.text glabel func_800758AC /* AECA4C 800758AC 27BDFFE0 */ addiu $sp, $sp, -0x20 /* AECA50 800758B0 3C010001 */ lui $at, 1 diff --git a/asm/non_matchings/code/z_kankyo/func_80075B44.s b/asm/non_matchings/code/z_kankyo/func_80075B44.s index 70fa7b79de..b866fd6cbb 100644 --- a/asm/non_matchings/code/z_kankyo/func_80075B44.s +++ b/asm/non_matchings/code/z_kankyo/func_80075B44.s @@ -1,3 +1,21 @@ +.rdata +glabel D_8013C738 + .asciz "\n\n\nNa_StartMorinigBgm\n\n" + .balign 4 + +.late_rodata +glabel jtbl_8013C80C + .word L80075B84 + .word L80075BD8 + .word L80075C30 + .word L80075C6C + .word L80075CB4 + .word L80075CE0 + .word L80075D30 + .word L80075DE4 + .word L80075E34 + +.text glabel func_80075B44 /* AECCE4 80075B44 27BDFFE0 */ addiu $sp, $sp, -0x20 /* AECCE8 80075B48 AFB00014 */ sw $s0, 0x14($sp) diff --git a/asm/non_matchings/code/z_kankyo/func_8007672C.s b/asm/non_matchings/code/z_kankyo/func_8007672C.s index ebbfc930ca..29fa3e46c5 100644 --- a/asm/non_matchings/code/z_kankyo/func_8007672C.s +++ b/asm/non_matchings/code/z_kankyo/func_8007672C.s @@ -1,3 +1,13 @@ +.rdata +glabel D_8013C750 + .asciz "../z_kankyo.c" + .balign 4 + +glabel D_8013C760 + .asciz "../z_kankyo.c" + .balign 4 + +.text glabel func_8007672C /* AED8CC 8007672C 27BDFFA0 */ addiu $sp, $sp, -0x60 /* AED8D0 80076730 93AE0073 */ lbu $t6, 0x73($sp) diff --git a/asm/non_matchings/code/z_kankyo/func_80076934.s b/asm/non_matchings/code/z_kankyo/func_80076934.s index fda95ecc31..79dbe67f43 100644 --- a/asm/non_matchings/code/z_kankyo/func_80076934.s +++ b/asm/non_matchings/code/z_kankyo/func_80076934.s @@ -1,3 +1,20 @@ +.rdata +glabel D_8013C770 + .asciz "../z_kankyo.c" + .balign 4 + +glabel D_8013C780 + .asciz "../z_kankyo.c" + .balign 4 + +.late_rodata +glabel D_8013C830 + .float 0.16666667 + +glabel D_8013C834 + .float 1.8333334 + +.text glabel func_80076934 /* AEDAD4 80076934 27BDFF48 */ addiu $sp, $sp, -0xb8 /* AEDAD8 80076938 3C010001 */ lui $at, 1 diff --git a/asm/non_matchings/code/z_sram/func_800A8484.s b/asm/non_matchings/code/z_sram/func_800A8484.s index acd17519a4..2b333da9c2 100644 --- a/asm/non_matchings/code/z_sram/func_800A8484.s +++ b/asm/non_matchings/code/z_sram/func_800A8484.s @@ -1,3 +1,101 @@ +.rdata +glabel D_80140850 + .asciz "個人File作成\n" + # EUC-JP: 個人File作成 | Create personal file + .balign 4 + +glabel D_80140864 + .asciz "ぽいんと=%x(%d)\n" + # EUC-JP: ぽいんと= | Point= + .balign 4 + +glabel D_80140878 + .asciz "\x1b[33m" + .balign 4 + +glabel D_80140880 + .asciz "SCENE_DATA_ID = %d SceneNo = %d\n" + .balign 4 + +glabel D_801408A4 + .asciz "scene_no = %d\n" + .balign 4 + +glabel D_801408B4 + .asciz "\x1b[m" + .balign 4 + +glabel D_801408B8 + .asciz "\x1b[34m" + .balign 4 + +glabel D_801408C0 + .asciz "\n====================================================================\n" + .balign 4 + +glabel D_80140908 + .asciz "%d, " + .balign 4 + +glabel D_80140910 + .asciz "\n====================================================================\n" + .balign 4 + +glabel D_80140958 + .asciz "\x1b[m" + .balign 4 + +glabel D_8014095C + .asciz "\x1b[32m" + .balign 4 + +glabel D_80140964 + .asciz "\n====================================================================\n" + .balign 4 + +glabel D_801409AC + .asciz "%d, " + .balign 4 + +glabel D_801409B4 + .asciz "\n====================================================================\n" + .balign 4 + +glabel D_801409FC + .asciz "\x1b[m" + .balign 4 + +.late_rodata +glabel jtbl_80140FB8 + .word L800A854C + .word L800A854C + .word L800A854C + .word L800A854C + .word L800A854C + .word L800A854C + .word L800A854C + .word L800A854C + .word L800A854C + .word L800A854C + .word L800A854C + .word L800A854C + .word L800A854C + .word L800A854C + .word L800A85C0 + .word L800A85C0 + .word L800A85CC + .word L800A8564 + .word L800A856C + .word L800A8578 + .word L800A8584 + .word L800A8590 + .word L800A859C + .word L800A85A8 + .word L800A85B4 + .word L800A85C0 + .word L800A85C0 + +.text glabel func_800A8484 /* B1F624 800A8484 27BDFFD8 */ addiu $sp, $sp, -0x28 /* B1F628 800A8488 AFB00014 */ sw $s0, 0x14($sp) diff --git a/asm/non_matchings/code/z_sram/func_800A8A20.s b/asm/non_matchings/code/z_sram/func_800A8A20.s index 241d6a4fa1..ee08fad088 100644 --- a/asm/non_matchings/code/z_sram/func_800A8A20.s +++ b/asm/non_matchings/code/z_sram/func_800A8A20.s @@ -1,3 +1,99 @@ +.rdata +glabel D_80140A00 + .asciz "SRAM START─LOAD\n" + # EUC-JP: SRAM START─LOAD + .balign 4 + +glabel D_80140A20 + .asciz "ぽいんと=%x(%d) SAVE_MAX=%d\n" + # EUC-JP: ぽいんと= | Point= + .balign 4 + +glabel D_80140A44 + .asciz "\n============= S(%d) =============\n" + # EUC-JP: ============= S(%d) ============= + .balign 4 + +glabel D_80140A88 + .asciz "\nSAVEチェックサム計算 j=%x mmm=%x " + # EUC-JP: SAVEチェックサム計算 | SAVE checksum calculation + .balign 4 + +glabel D_80140AB4 + .asciz "ERROR!!! = %x(%d)\n" + # EUC-JP: ERROR!!! = + .balign 4 + +glabel D_80140AD0 + .asciz "================= BACK─UP ========================\n" + # EUC-JP: BACK─UP + .balign 4 + +glabel D_80140B0C + .asciz "\n(B)SAVEチェックサム計算 j=%x mmm=%x " + # EUC-JP: (B)SAVEチェックサム計算 | (B) SAVE checksum calculation + .balign 4 + +glabel D_80140B3C + .asciz "ERROR!!! = %x(%d+3)\n" + #EUR-JP: ERROR!!! = + .balign 4 + +glabel D_80140B5C + .asciz "newf=%x,%x,%x,%x,%x,%x\n" + .balign 4 + +glabel D_80140B74 + .asciz "\n--------------------------------------------------------------\n" + .balign 4 + +glabel D_80140BB8 + .asciz "%x " + .balign 4 + +glabel D_80140BBC + .asciz "\n" + .balign 4 + +glabel D_80140BC0 + .asciz "\nCheck_Sum=%x(%x)\n" + .balign 4 + +glabel D_80140BD4 + .asciz "????#%x,%x,%x,%x,%x,%x\n" + .balign 4 + +glabel D_80140BEC + .asciz "\nぽいんと=%x(%d+3) check_sum=%x(%x)\n" + # EUC-JP: ぽいんと= | Point = + .balign 4 + +glabel D_80140C14 + .asciz "ぽいんと=%x(%d) check_sum=%x(%x)\n" + .balign 4 + +glabel D_80140C38 + .asciz "\nSAVEデータ OK!!!!\n" + # EUC-JP: SAVEデータ OK!!!! | SAVE data OK! ! ! ! + .balign 4 + +glabel D_80140C58 + .asciz "SAVECT=%x, NAME=%x, LIFE=%x, ITEM=%x, 64DD=%x, HEART=%x\n" + .balign 4 + +glabel D_80140C94 + .asciz "f_64dd=%d, %d, %d\n" + .balign 4 + +glabel D_80140CA8 + .asciz "heart_status=%d, %d, %d\n" + .balign 4 + +glabel D_80140CC4 + .asciz "now_life=%d, %d, %d\n" + .balign 4 + +.text glabel func_800A8A20 /* B1FBC0 800A8A20 27BDFF88 */ addiu $sp, $sp, -0x78 /* B1FBC4 800A8A24 AFA40078 */ sw $a0, 0x78($sp) diff --git a/asm/non_matchings/code/z_sram/func_800A9258.s b/asm/non_matchings/code/z_sram/func_800A9258.s index a1e6e5e381..36c8fa3723 100644 --- a/asm/non_matchings/code/z_sram/func_800A9258.s +++ b/asm/non_matchings/code/z_sram/func_800A9258.s @@ -1,3 +1,64 @@ +.rdata +glabel D_80140CDC + .asciz "64DDフラグ=%d\n" + # EUC-JP: 64DDフラグ | 64DD flag + .balign 4 + +glabel D_80140CF0 + .asciz "newf=%x,%x,%x,%x,%x,%x\n" + .balign 4 + +glabel D_80140D08 + .asciz "\n$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$\n" + .balign 4 + +glabel D_80140D58 + .asciz "%x " + .balign 4 + +glabel D_80140D5C + .asciz "\n" + .balign 4 + +glabel D_80140D60 + .asciz "\nチェックサム=%x\n" + # EUC-JP: チェックサム=%x | Checksum + .balign 4 + +glabel D_80140D74 + .asciz "I=%x no=%d\n" + .balign 4 + +glabel D_80140D80 + .asciz "I=%x no=%d\n" + .balign 4 + +glabel D_80140D8C + .asciz "SAVE終了\n" + # EUC-JP: SAVE終了 | SAVE end + .balign 4 + +glabel D_80140D9C + .asciz "z_common_data.file_no = %d\n" + .balign 4 + +glabel D_80140DB8 + .asciz "SAVECT=%x, NAME=%x, LIFE=%x, ITEM=%x, SAVE_64DD=%x\n" + .balign 4 + +glabel D_80140DF0 + .asciz "f_64dd[%d]=%d\n" + .balign 4 + +glabel D_80140E00 + .asciz "heart_status[%d]=%d\n" + .balign 4 + +glabel D_80140E18 + .asciz "now_life[%d]=%d\n" + .balign 4 + +.text glabel func_800A9258 /* B203F8 800A9258 27BDFFB8 */ addiu $sp, $sp, -0x48 /* B203FC 800A925C AFB60040 */ sw $s6, 0x40($sp) diff --git a/asm/non_matchings/code/z_sram/func_800A96D0.s b/asm/non_matchings/code/z_sram/func_800A96D0.s index 8b5aea8c5e..2a1eb49a27 100644 --- a/asm/non_matchings/code/z_sram/func_800A96D0.s +++ b/asm/non_matchings/code/z_sram/func_800A96D0.s @@ -1,3 +1,10 @@ +.rdata +glabel D_80140E2C + .asciz "CLEAR終了\n" + # EUC-JP: CLEAR終了 | Clear End + .balign 4 + +.text glabel func_800A96D0 /* B20870 800A96D0 27BDFFD8 */ addiu $sp, $sp, -0x28 /* B20874 800A96D4 AFBF001C */ sw $ra, 0x1c($sp) diff --git a/asm/non_matchings/code/z_sram/func_800A97F0.s b/asm/non_matchings/code/z_sram/func_800A97F0.s index bd26cdbb0d..0f759c92c0 100644 --- a/asm/non_matchings/code/z_sram/func_800A97F0.s +++ b/asm/non_matchings/code/z_sram/func_800A97F0.s @@ -1,3 +1,23 @@ +.rdata +glabel D_80140E3C + .asciz "READ=%d(%x) COPY=%d(%x)\n" + # EUC-JP: READ=%d(%x) COPY=%d + .balign 4 + +glabel D_80140E60 + .asciz "f_64dd[%d]=%d\n" + .balign 4 + +glabel D_80140E70 + .asciz "heart_status[%d]=%d\n" + .balign 4 + +glabel D_80140E88 + .asciz "COPY終了\n" + # EUC-JP: COPY終了 | Copy end + .balign 4 + +.text glabel func_800A97F0 /* B20990 800A97F0 27BDFFC8 */ addiu $sp, $sp, -0x38 /* B20994 800A97F4 AFB3002C */ sw $s3, 0x2c($sp) diff --git a/asm/non_matchings/code/z_sram/func_800A9AD0.s b/asm/non_matchings/code/z_sram/func_800A9AD0.s index e4bb125632..376a42dc78 100644 --- a/asm/non_matchings/code/z_sram/func_800A9AD0.s +++ b/asm/non_matchings/code/z_sram/func_800A9AD0.s @@ -1,3 +1,44 @@ +.rdata +glabel D_80140E98 + .asciz "sram_initialize( Game *game, Sram *sram )\n" + .balign 4 + +glabel D_80140EC4 + .asciz "SRAM破壊!!!!!!\n" + # EUC-JP: SRAM破壊!!!!!! | SRAM destruction! ! ! ! ! ! + .balign 4 + +glabel D_80140EE0 + .asciz "SRAM破壊!!!!!!\n" + # EUC-JP: SRAM破壊!!!!!! | SRAM destruction! ! ! ! ! ! + .balign 4 + +glabel D_80140EFC + .asciz "GOOD!GOOD! サイズ=%d + %d = %d\n" + # EUC-JP: GOOD!GOOD! サイズ=%d + %d = %d | GOOD! GOOD! Size =% d +% d =% d + .balign 4 + +glabel D_80140F28 + .asciz "\x1b[34m" + .balign 4 + +glabel D_80140F30 + .asciz "Na_SetSoundOutputMode = %d\n" + .balign 4 + +glabel D_80140F4C + .asciz "Na_SetSoundOutputMode = %d\n" + .balign 4 + +glabel D_80140F68 + .asciz "Na_SetSoundOutputMode = %d\n" + .balign 4 + +glabel D_80140F84 + .asciz "\x1b[m" + .balign 4 + +.text glabel func_800A9AD0 /* B20C70 800A9AD0 27BDFFD0 */ addiu $sp, $sp, -0x30 /* B20C74 800A9AD4 AFA40030 */ sw $a0, 0x30($sp) diff --git a/asm/non_matchings/code/z_sram/func_800A9CD4.s b/asm/non_matchings/code/z_sram/func_800A9CD4.s index 9fc81085db..62a8d501d0 100644 --- a/asm/non_matchings/code/z_sram/func_800A9CD4.s +++ b/asm/non_matchings/code/z_sram/func_800A9CD4.s @@ -1,3 +1,17 @@ +.rdata +glabel D_80140F88 + .asciz "../z_sram.c" + .balign 4 + +glabel D_80140F94 + .asciz "sram->read_buff != NULL" + .balign 4 + +glabel D_80140FAC + .asciz "../z_sram.c" + .balign 4 + +.text glabel func_800A9CD4 /* B20E74 800A9CD4 27BDFFE8 */ addiu $sp, $sp, -0x18 /* B20E78 800A9CD8 AFBF0014 */ sw $ra, 0x14($sp) diff --git a/asm/osSetIntMask.s b/asm/osSetIntMask.s index 232549d61f..05a57b4186 100644 --- a/asm/osSetIntMask.s +++ b/asm/osSetIntMask.s @@ -51,3 +51,73 @@ glabel osSetIntMask /* 005BD4 80004FD4 00000000 */ nop /* 005BD8 80004FD8 03E00008 */ jr $ra /* 005BDC 80004FDC 00000000 */ nop + +.section .rodata + +.balign 16 + +glabel __osRcpImTable + .half 0x0555 + .half 0x0556 + .half 0x0559 + .half 0x055A + .half 0x0565 + .half 0x0566 + .half 0x0569 + .half 0x056A + .half 0x0595 + .half 0x0596 + .half 0x0599 + .half 0x059A + .half 0x05A5 + .half 0x05A6 + .half 0x05A9 + .half 0x05AA + .half 0x0655 + .half 0x0656 + .half 0x0659 + .half 0x065A + .half 0x0665 + .half 0x0666 + .half 0x0669 + .half 0x066A + .half 0x0695 + .half 0x0696 + .half 0x0699 + .half 0x069A + .half 0x06A5 + .half 0x06A6 + .half 0x06A9 + .half 0x06AA + .half 0x0955 + .half 0x0956 + .half 0x0959 + .half 0x095A + .half 0x0965 + .half 0x0966 + .half 0x0969 + .half 0x096A + .half 0x0995 + .half 0x0996 + .half 0x0999 + .half 0x099A + .half 0x09A5 + .half 0x09A6 + .half 0x09A9 + .half 0x09AA + .half 0x0A55 + .half 0x0A56 + .half 0x0A59 + .half 0x0A5A + .half 0x0A65 + .half 0x0A66 + .half 0x0A69 + .half 0x0A6A + .half 0x0A95 + .half 0x0A96 + .half 0x0A99 + .half 0x0A9A + .half 0x0AA5 + .half 0x0AA6 + .half 0x0AA9 + .half 0x0AAA diff --git a/data/db_camera.data.s b/data/db_camera.data.s index af2ce7e4ad..29d94c4898 100644 --- a/data/db_camera.data.s +++ b/data/db_camera.data.s @@ -8,6 +8,7 @@ .section .data .balign 16 + glabel D_8012CED0 .incbin "baserom.z64", 0xBA4070, 0x4 @@ -23,7 +24,6 @@ glabel D_8012CEE0 glabel D_8012CEE4 .word D_80143184 - glabel D_8012CEE8 .word D_80143194 diff --git a/data/db_camera.rodata.s b/data/db_camera.rodata.s index 14a76c569a..865076091c 100644 --- a/data/db_camera.rodata.s +++ b/data/db_camera.rodata.s @@ -78,13 +78,11 @@ glabel D_80143254 .balign 4 glabel D_80143264 - .byte 0x8C - .asciz "Eモ-ド\x8D ソウタイ" + .asciz "\x8C\Eモ-ド\x8D ソウタイ" .balign 4 glabel D_80143278 - .byte 0x8C - .asciz "Eモ-ド\x8Dゼッタイ" + .asciz "\x8C\Eモ-ド\x8Dゼッタイ" .balign 4 glabel D_80143290 @@ -239,8 +237,7 @@ glabel D_801434B4 .balign 4 glabel D_801434C4 - .byte 0x8C - .asciz "Eモ-ド\x8D コテイ" + .asciz "\x8C\Eモ-ド\x8D コテイ" .balign 4 glabel D_801434D8 @@ -549,7 +546,6 @@ glabel D_80143C40 glabel D_80143C54 .float 0.15 - .balign 4 glabel D_80143C58 .float 0.2 diff --git a/data/osSetIntMask.rodata.s b/data/osSetIntMask.rodata.s deleted file mode 100644 index 38b73ebfa7..0000000000 --- a/data/osSetIntMask.rodata.s +++ /dev/null @@ -1,74 +0,0 @@ -.include "macro.inc" - -# assembler directives -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches -.set gp=64 # allow use of 64-bit general purpose registers - -.section .rodata - -glabel __osRcpImTable - .hword 0x0555 - .hword 0x0556 - .hword 0x0559 - .hword 0x055A - .hword 0x0565 - .hword 0x0566 - .hword 0x0569 - .hword 0x056A - .hword 0x0595 - .hword 0x0596 - .hword 0x0599 - .hword 0x059A - .hword 0x05A5 - .hword 0x05A6 - .hword 0x05A9 - .hword 0x05AA - .hword 0x0655 - .hword 0x0656 - .hword 0x0659 - .hword 0x065A - .hword 0x0665 - .hword 0x0666 - .hword 0x0669 - .hword 0x066A - .hword 0x0695 - .hword 0x0696 - .hword 0x0699 - .hword 0x069A - .hword 0x06A5 - .hword 0x06A6 - .hword 0x06A9 - .hword 0x06AA - .hword 0x0955 - .hword 0x0956 - .hword 0x0959 - .hword 0x095A - .hword 0x0965 - .hword 0x0966 - .hword 0x0969 - .hword 0x096A - .hword 0x0995 - .hword 0x0996 - .hword 0x0999 - .hword 0x099A - .hword 0x09A5 - .hword 0x09A6 - .hword 0x09A9 - .hword 0x09AA - .hword 0x0A55 - .hword 0x0A56 - .hword 0x0A59 - .hword 0x0A5A - .hword 0x0A65 - .hword 0x0A66 - .hword 0x0A69 - .hword 0x0A6A - .hword 0x0A95 - .hword 0x0A96 - .hword 0x0A99 - .hword 0x0A9A - .hword 0x0AA5 - .hword 0x0AA6 - .hword 0x0AA9 - .hword 0x0AAA diff --git a/data/z_kankyo.rodata.s b/data/z_kankyo.rodata.s deleted file mode 100644 index 4abbf38de0..0000000000 --- a/data/z_kankyo.rodata.s +++ /dev/null @@ -1,403 +0,0 @@ -.include "macro.inc" - -# assembler directives -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches -.set gp=64 # allow use of 64-bit general purpose registers - -.section .rodata - -.balign 16 - -glabel D_8013C240 - .asciz "\x1b[43;30m\n\nフィールド常駐以外、太陽設定!よって強制解除!\n\x1b[m" - # EUC-JP: フィールド常駐以外、太陽設定!よって強制解除! | "Sun setting except field resident! So forced release!"? - .balign 4 - -glabel D_8013C280 - .asciz "\x1b[41;37m\nend_frameとstart_frameのフレーム関係がおかしい!!!\x1b[m" - # EUC-JP: とstart_frameのフレーム関係がおかしい!!! | The frame relation between end_frame and start_frame is wrong - .balign 4 - -glabel D_8013C2C0 - .asciz "\x1b[41;37m\nby get_parcent_forAccelBrake!!!!!!!!!\x1b[m" - .balign 4 - -glabel D_8013C2F4 - .asciz "\x1b[41;37m\n環境VRデータ取得失敗! ささきまでご報告を!\x1b[m" - # EUC-JP: 環境VRデータ取得失敗! ささきまでご報告を! | Environment VR data acquisition failed! Report to Sasaki! - .balign 4 - -glabel D_8013C330 - .asciz "../z_kankyo.c" - .balign 4 - -glabel D_8013C340 - .asciz "../z_kankyo.c" - .balign 4 - -glabel D_8013C350 - .asciz "../z_kankyo.c" - .balign 4 - -glabel D_8013C360 - .asciz "../z_kankyo.c" - .balign 4 - -glabel D_8013C370 - .asciz "../z_kankyo.c" - .balign 4 - -glabel D_8013C380 - .asciz "../z_kankyo.c" - .balign 4 - -glabel D_8013C390 - .asciz "\x1b[43;30m\n水ポリゴンデータに水中カラーが設定されておりません!\x1b[m" - # EUC-JP: 水ポリゴンデータに水中カラーが設定されておりません | Underwater color is not set in the water poly data - .balign 4 - -glabel D_8013C3D0 - .asciz "T%03d " - .balign 4 - -glabel D_8013C3D8 - .asciz "E%03d" - .balign 4 - -glabel D_8013C3E0 - .asciz "%s" - .balign 4 - -glabel D_8013C3E4 - .asciz "ZELDATIME " - .balign 4 - -glabel D_8013C3F0 - .asciz "%02d" - .balign 4 - -glabel D_8013C3F8 - .asciz "%s" - .balign 4 - -glabel D_8013C3FC - .asciz ":" - .balign 4 - -glabel D_8013C400 - .asciz "%s" - .balign 4 - -glabel D_8013C404 - .asciz " " - .balign 4 - -glabel D_8013C408 - .asciz "%02d" - .balign 4 - -glabel D_8013C410 - .asciz "%s" - .balign 4 - -glabel D_8013C414 - .asciz "VRBOXTIME " - .balign 4 - -glabel D_8013C420 - .asciz "%02d" - .balign 4 - -glabel D_8013C428 - .asciz "%s" - .balign 4 - -glabel D_8013C42C - .asciz ":" - .balign 4 - -glabel D_8013C430 - .asciz "%s" - .balign 4 - -glabel D_8013C434 - .asciz " " - .balign 4 - -glabel D_8013C438 - .asciz "%02d" - .balign 4 - -glabel D_8013C440 - .asciz "%s" - .balign 4 - -glabel D_8013C444 - .asciz "YORU" - .balign 4 - -glabel D_8013C44C - .asciz "%s" - .balign 4 - -glabel D_8013C450 - .asciz "HIRU" - .balign 4 - -glabel D_8013C458 - .asciz "\nnext_zelda_time=[%x]" - .balign 4 - -glabel D_8013C470 - .asciz "../z_kankyo.c" - .balign 4 - -glabel D_8013C480 - .asciz "../z_kankyo.c" - .balign 4 - -glabel D_8013C490 - .asciz "\x1b[41;37m\nカラーパレットの設定がおかしいようです!\x1b[m" - # EUC-JP: カラーパレットの設定がおかしいようです! | The color palette settings seem to be wrong! - .balign 4 - -glabel D_8013C4C8 - .asciz "\x1b[41;37m\n設定パレット=[%d] 最後パレット番号=[%d]\n\x1b[m" - # EUC-JP: 設定パレット=[%d] 最後パレット番号= | Set pallet = [% d] Last pallet number = - .balign 4 - -glabel D_8013C500 - .asciz "\n\x1b[31mカラーパレットがおかしいようです!" - # EUC-JP: カラーパレットがおかしいようです! | The color palette seems strange! - .balign 4 - -glabel D_8013C52C - .asciz "\n\x1b[33m設定パレット=[%d] パレット数=[%d]\n\x1b[m" - # EUC-JP: 設定パレット=[%d] パレット数=[%d] | Set pallet = [% d] Number of pallets = [% d] - .balign 4 - -glabel D_8013C55C - .asciz "../z_kankyo.c" - .balign 4 - -glabel D_8013C56C - .asciz "../z_kankyo.c" - .balign 4 - -glabel D_8013C57C - .asciz "../z_kankyo.c" - .balign 4 - -glabel D_8013C58C - .asciz "../z_kankyo.c" - .balign 4 - -glabel D_8013C59C - .asciz "../z_kankyo.c" - .balign 4 - -glabel D_8013C5AC - .asciz "../z_kankyo.c" - .balign 4 - -glabel D_8013C5BC - .asciz "../z_kankyo.c" - .balign 4 - -glabel D_8013C5CC - .asciz "../z_kankyo.c" - .balign 4 - -glabel D_8013C5DC - .asciz "../z_kankyo.c" - .balign 4 - -glabel D_8013C5EC - .asciz "../z_kankyo.c" - .balign 4 - -glabel D_8013C5FC - .asciz "../z_kankyo.c" - .balign 4 - -glabel D_8013C60C - .asciz "../z_kankyo.c" - .balign 4 - -glabel D_8013C61C - .asciz "../z_kankyo.c" - .balign 4 - -glabel D_8013C62C - .asciz "../z_kankyo.c" - .balign 4 - -glabel D_8013C63C - .asciz "../z_kankyo.c" - .balign 4 - -glabel D_8013C64C - .asciz "../z_kankyo.c" - .balign 4 - -glabel D_8013C65C - .asciz "../z_kankyo.c" - .balign 4 - -glabel D_8013C66C - .asciz "../z_kankyo.c" - .balign 4 - -glabel D_8013C67C - .asciz "../z_kankyo.c" - .balign 4 - -glabel D_8013C68C - .asciz "../z_kankyo.c" - .balign 4 - -glabel D_8013C69C - .asciz "\n\n\nBGM設定game_play->sound_info.BGM=[%d] old_bgm=[%d]\n\n" - # EUC-JP: 設定 | Configuration - .balign 4 - -glabel D_8013C6D4 - .asciz "\n-----------------\n" - .balign 4 - -glabel D_8013C6E8 - .asciz "\n 強制BGM=[%d]" - # EUC-JP: 強制BGM | Forced BGM - .balign 4 - -glabel D_8013C6FC - .asciz "\n BGM=[%d]" - # EUC-JP: BGM - .balign 4 - -glabel D_8013C710 - .asciz "\n エンブ=[%d]" - # EUC-JP: エンブ | Emblem? - .balign 4 - -glabel D_8013C724 - .asciz "\n status=[%d]" - .balign 4 - -glabel D_8013C738 - .asciz "\n\n\nNa_StartMorinigBgm\n\n" - .balign 4 - -glabel D_8013C750 - .asciz "../z_kankyo.c" - .balign 4 - -glabel D_8013C760 - .asciz "../z_kankyo.c" - .balign 4 - -glabel D_8013C770 - .asciz "../z_kankyo.c" - .balign 4 - -glabel D_8013C780 - .asciz "../z_kankyo.c" - .balign 4 - -glabel jtbl_8013C790 - .word L8006F4A8 - .word L8006F4CC - .word L8006F4CC - .word L8006F4CC - .word L8006F4F0 - -glabel D_8013C7A4 - .float 0.001 - -glabel D_8013C7A8 - .float 0.005 - -glabel D_8013C7AC - .float 0.8 - -glabel D_8013C7B0 - .float 0.8 - -glabel D_8013C7B4 - .float 0.8 - -glabel D_8013C7B8 - .float 630 - - .balign 8 -glabel D_8013C7C0 - .double 0.001 - -glabel D_8013C7C8 - .float 1.0E-4 - -glabel D_8013C7CC - .float 0.001 - -glabel D_8013C7D0 - .float 0.001 - -glabel D_8013C7D4 - .float 0.1 - -glabel D_8013C7D8 - .float 0.1 - -glabel D_8013C7DC - .float 0.4 - -glabel D_8013C7E0 - .float 0.7 - -glabel D_8013C7E4 - .float 1.5707964 # M_PI / 2 - -glabel D_8013C7E8 - .float 1.2 - -glabel D_8013C7EC - .float 0.1 - -glabel D_8013C7F0 - .float 0.02 - -glabel D_8013C7F4 - .float 0.02 - -glabel D_8013C7F8 - .float 0.1 - -glabel D_8013C7FC - .float 2.9 - -glabel D_8013C800 - .float 5000 - -glabel D_8013C804 - .float 9500 - -glabel D_8013C808 - .float 0.017453292 - -glabel jtbl_8013C80C - .word L80075B84 - .word L80075BD8 - .word L80075C30 - .word L80075C6C - .word L80075CB4 - .word L80075CE0 - .word L80075D30 - .word L80075DE4 - .word L80075E34 - -glabel D_8013C830 - .float 0.16666667 - -glabel D_8013C834 - .float 1.8333334 diff --git a/data/z_message_PAL.rodata.s b/data/z_message_PAL.rodata.s index e03e561999..5f65435cf5 100644 --- a/data/z_message_PAL.rodata.s +++ b/data/z_message_PAL.rodata.s @@ -86,28 +86,28 @@ glabel D_8015394C .word 0x00000000, 0x00000000, 0x00000000 glabel D_80153958 - .hword 0x0000 + .half 0x0000 glabel D_8015395A - .hword 0x0000 + .half 0x0000 glabel D_8015395C - .hword 0x0000 + .half 0x0000 glabel D_8015395E - .hword 0x0000 + .half 0x0000 glabel D_80153960 - .hword 0x0000 + .half 0x0000 glabel D_80153962 - .hword 0x0000 + .half 0x0000 glabel D_80153964 - .hword 0x0000 + .half 0x0000 glabel D_80153966 - .hword 0x0000 + .half 0x0000 glabel D_80153968 .word 0x00000000 @@ -164,16 +164,16 @@ glabel D_80153C48 .word 0x00480048, 0x00480000 glabel D_80153C50 - .hword 0x0000 + .half 0x0000 glabel D_80153C52 - .hword 0x0001 + .half 0x0001 glabel D_80153C54 - .hword 0x0003 + .half 0x0003 glabel D_80153C56 - .hword 0x0002 + .half 0x0002 glabel D_80153C58 .word 0x00010002, 0x00040008, 0x00100020, 0x01000080 @@ -234,8 +234,9 @@ glabel D_80153D74 glabel D_80153D78 .word 0x00000000 - .balign 16 + +glabel D_80153D7C + .word 0x00000000 glabel D_80153D80 .word 0x00000000 - .balign 16 diff --git a/data/z_sram.rodata.s b/data/z_sram.rodata.s deleted file mode 100644 index 0abc912efc..0000000000 --- a/data/z_sram.rodata.s +++ /dev/null @@ -1,332 +0,0 @@ -.include "macro.inc" - -# assembler directives -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches -.set gp=64 # allow use of 64-bit general purpose registers - -.section .rodata - -.balign 16 - -glabel D_80140850 - .asciz "個人File作成\n" - # EUC-JP: 個人File作成 | Create personal file - .balign 4 - -glabel D_80140864 - .asciz "ぽいんと=%x(%d)\n" - # EUC-JP: ぽいんと= | Point= - .balign 4 - -glabel D_80140878 - .asciz "\x1b[33m" - .balign 4 - -glabel D_80140880 - .asciz "SCENE_DATA_ID = %d SceneNo = %d\n" - .balign 4 - -glabel D_801408A4 - .asciz "scene_no = %d\n" - .balign 4 - -glabel D_801408B4 - .asciz "\x1b[m" - .balign 4 - -glabel D_801408B8 - .asciz "\x1b[34m" - .balign 4 - -glabel D_801408C0 - .asciz "\n====================================================================\n" - .balign 4 - -glabel D_80140908 - .asciz "%d, " - .balign 4 - -glabel D_80140910 - .asciz "\n====================================================================\n" - .balign 4 - -glabel D_80140958 - .asciz "\x1b[m" - .balign 4 - -glabel D_8014095C - .asciz "\x1b[32m" - .balign 4 - -glabel D_80140964 - .asciz "\n====================================================================\n" - .balign 4 - -glabel D_801409AC - .asciz "%d, " - .balign 4 - -glabel D_801409B4 - .asciz "\n====================================================================\n" - .balign 4 - -glabel D_801409FC - .asciz "\x1b[m" - .balign 4 - -glabel D_80140A00 - .asciz "SRAM START─LOAD\n" - # EUC-JP: SRAM START─LOAD - .balign 4 - -glabel D_80140A20 - .asciz "ぽいんと=%x(%d) SAVE_MAX=%d\n" - # EUC-JP: ぽいんと= | Point= - .balign 4 - -glabel D_80140A44 - .asciz "\n============= S(%d) =============\n" - # EUC-JP: ============= S(%d) ============= - .balign 4 - -glabel D_80140A88 - .asciz "\nSAVEチェックサム計算 j=%x mmm=%x " - # EUC-JP: SAVEチェックサム計算 | SAVE checksum calculation - .balign 4 - -glabel D_80140AB4 - .asciz "ERROR!!! = %x(%d)\n" - # EUC-JP: ERROR!!! = - .balign 4 - -glabel D_80140AD0 - .asciz "================= BACK─UP ========================\n" - # EUC-JP: BACK─UP - .balign 4 - -glabel D_80140B0C - .asciz "\n(B)SAVEチェックサム計算 j=%x mmm=%x " - # EUC-JP: (B)SAVEチェックサム計算 | (B) SAVE checksum calculation - .balign 4 - -glabel D_80140B3C - .asciz "ERROR!!! = %x(%d+3)\n" - #EUR-JP: ERROR!!! = - .balign 4 - -glabel D_80140B5C - .asciz "newf=%x,%x,%x,%x,%x,%x\n" - .balign 4 - -glabel D_80140B74 - .asciz "\n--------------------------------------------------------------\n" - .balign 4 - -glabel D_80140BB8 - .asciz "%x " - .balign 4 - -glabel D_80140BBC - .asciz "\n" - .balign 4 - -glabel D_80140BC0 - .asciz "\nCheck_Sum=%x(%x)\n" - .balign 4 - -glabel D_80140BD4 - .asciz "????#%x,%x,%x,%x,%x,%x\n" - .balign 4 - -glabel D_80140BEC - .asciz "\nぽいんと=%x(%d+3) check_sum=%x(%x)\n" - # EUC-JP: ぽいんと= | Point = - .balign 4 - -glabel D_80140C14 - .asciz "ぽいんと=%x(%d) check_sum=%x(%x)\n" - .balign 4 - -glabel D_80140C38 - .asciz "\nSAVEデータ OK!!!!\n" - # EUC-JP: SAVEデータ OK!!!! | SAVE data OK! ! ! ! - .balign 4 - -glabel D_80140C58 - .asciz "SAVECT=%x, NAME=%x, LIFE=%x, ITEM=%x, 64DD=%x, HEART=%x\n" - .balign 4 - -glabel D_80140C94 - .asciz "f_64dd=%d, %d, %d\n" - .balign 4 - -glabel D_80140CA8 - .asciz "heart_status=%d, %d, %d\n" - .balign 4 - -glabel D_80140CC4 - .asciz "now_life=%d, %d, %d\n" - .balign 4 - -glabel D_80140CDC - .asciz "64DDフラグ=%d\n" - # EUC-JP: 64DDフラグ | 64DD flag - .balign 4 - -glabel D_80140CF0 - .asciz "newf=%x,%x,%x,%x,%x,%x\n" - .balign 4 - -glabel D_80140D08 - .asciz "\n$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$\n" - .balign 4 - -glabel D_80140D58 - .asciz "%x " - .balign 4 - -glabel D_80140D5C - .asciz "\n" - .balign 4 - -glabel D_80140D60 - .asciz "\nチェックサム=%x\n" - # EUC-JP: チェックサム=%x | Checksum - .balign 4 - -glabel D_80140D74 - .asciz "I=%x no=%d\n" - .balign 4 - -glabel D_80140D80 - .asciz "I=%x no=%d\n" - .balign 4 - -glabel D_80140D8C - .asciz "SAVE終了\n" - # EUC-JP: SAVE終了 | SAVE end - .balign 4 - -glabel D_80140D9C - .asciz "z_common_data.file_no = %d\n" - .balign - -glabel D_80140DB8 - .asciz "SAVECT=%x, NAME=%x, LIFE=%x, ITEM=%x, SAVE_64DD=%x\n" - .balign 4 - -glabel D_80140DF0 - .asciz "f_64dd[%d]=%d\n" - .balign 4 - -glabel D_80140E00 - .asciz "heart_status[%d]=%d\n" - .balign 4 - -glabel D_80140E18 - .asciz "now_life[%d]=%d\n" - .balign 4 - -glabel D_80140E2C - .asciz "CLEAR終了\n" - # EUC-JP: CLEAR終了 | Clear End - .balign 4 - -glabel D_80140E3C - .asciz "READ=%d(%x) COPY=%d(%x)\n" - # EUC-JP: READ=%d(%x) COPY=%d - .balign 4 - -glabel D_80140E60 - .asciz "f_64dd[%d]=%d\n" - .balign 4 - -glabel D_80140E70 - .asciz "heart_status[%d]=%d\n" - .balign 4 - -glabel D_80140E88 - .asciz "COPY終了\n" - # EUC-JP: COPY終了 | Copy end - .balign 4 - -glabel D_80140E98 - .asciz "sram_initialize( Game *game, Sram *sram )\n" - .balign 4 - -glabel D_80140EC4 - .asciz "SRAM破壊!!!!!!\n" - # EUC-JP: SRAM破壊!!!!!! | SRAM destruction! ! ! ! ! ! - .balign 4 - -glabel D_80140EE0 - .asciz "SRAM破壊!!!!!!\n" - # EUC-JP: SRAM破壊!!!!!! | SRAM destruction! ! ! ! ! ! - .balign 4 - -glabel D_80140EFC - .asciz "GOOD!GOOD! サイズ=%d + %d = %d\n" - # EUC-JP: GOOD!GOOD! サイズ=%d + %d = %d | GOOD! GOOD! Size =% d +% d =% d - .balign 4 - -glabel D_80140F28 - .asciz "\x1b[34m" - .balign 4 - -glabel D_80140F30 - .asciz "Na_SetSoundOutputMode = %d\n" - .balign 4 - -glabel D_80140F4C - .asciz "Na_SetSoundOutputMode = %d\n" - .balign 4 - -glabel D_80140F68 - .asciz "Na_SetSoundOutputMode = %d\n" - .balign 4 - -glabel D_80140F84 - .asciz "\x1b[m" - .balign 4 - -glabel D_80140F88 - .asciz "../z_sram.c" - .balign 4 - -glabel D_80140F94 - .asciz "sram->read_buff != NULL" - .balign 4 - -glabel D_80140FAC - .asciz "../z_sram.c" - .balign 4 - -glabel jtbl_80140FB8 - .word L800A854C - .word L800A854C - .word L800A854C - .word L800A854C - .word L800A854C - .word L800A854C - .word L800A854C - .word L800A854C - .word L800A854C - .word L800A854C - .word L800A854C - .word L800A854C - .word L800A854C - .word L800A854C - .word L800A85C0 - .word L800A85C0 - .word L800A85CC - .word L800A8564 - .word L800A856C - .word L800A8578 - .word L800A8584 - .word L800A8590 - .word L800A859C - .word L800A85A8 - .word L800A85B4 - .word L800A85C0 - .word L800A85C0 diff --git a/spec b/spec index 9452fb9ebe..e4d7f8ac03 100644 --- a/spec +++ b/spec @@ -53,7 +53,6 @@ beginseg include "build/src/libultra_boot_O2/__osSiRawReadIo.o" include "build/src/libultra_boot_O1/osGetThreadId.o" include "build/asm/osSetIntMask.o" - include "build/data/osSetIntMask.rodata.o" include "build/src/libultra_boot_O2/osViSetMode.o" include "build/asm/__osProbeTLB.o" include "build/src/libultra_boot_O1/osGetMemSize.o" @@ -318,7 +317,6 @@ beginseg include "build/src/code/z_kanfont.o" include "build/src/code/z_kankyo.o" include "build/data/z_kankyo.data.o" - include "build/data/z_kankyo.rodata.o" include "build/data/z_kankyo.bss.o" include "build/src/code/z_lib.o" include "build/src/code/z_lifemeter.o" @@ -358,7 +356,6 @@ beginseg include "build/data/z_skin_matrix.data.o" include "build/src/code/z_sram.o" include "build/data/z_sram.data.o" - include "build/data/z_sram.rodata.o" include "build/src/code/code_800A9D40.o" include "build/src/code/code_800A9F30.o" include "build/data/z_text.data.o" diff --git a/tools/asm_processor/asm_processor.py b/tools/asm_processor/asm_processor.py index 50d2a91d59..04b94316b6 100644 --- a/tools/asm_processor/asm_processor.py +++ b/tools/asm_processor/asm_processor.py @@ -10,6 +10,7 @@ from collections import namedtuple from io import StringIO MAX_FN_SIZE = 100 +SLOW_CHECKS = False EI_NIDENT = 16 EI_CLASS = 4 @@ -348,6 +349,20 @@ def is_temp_name(name): return name.startswith('_asmpp_') +# https://stackoverflow.com/a/241506 +def re_comment_replacer(match): + s = match.group(0) + if s[0] in "/#": + return " " + else: + return s + + +re_comment_or_string = re.compile( + r'#.*|/\*.*?\*/|"(?:\\.|[^\\"])*"' +) + + class Failure(Exception): def __init__(self, message): self.message = message @@ -357,13 +372,14 @@ class Failure(Exception): class GlobalState: - def __init__(self, min_instr_count, skip_instr_count): + def __init__(self, min_instr_count, skip_instr_count, use_jtbl_for_rodata): # A value that hopefully never appears as a 32-bit rodata constant (or we # miscompile late rodata). Increases by 1 in each step. self.late_rodata_hex = 0xE0123456 self.namectr = 0 self.min_instr_count = min_instr_count self.skip_instr_count = skip_instr_count + self.use_jtbl_for_rodata = use_jtbl_for_rodata def next_late_rodata_hex(self): dummy_bytes = struct.pack('>I', self.late_rodata_hex) @@ -378,7 +394,7 @@ class GlobalState: return '_asmpp_{}{}'.format(cat, self.namectr) -Function = namedtuple('Function', ['text_glabels', 'asm_conts', 'late_rodata_dummy_bytes', 'late_rodata_asm_conts', 'fn_desc', 'data']) +Function = namedtuple('Function', ['text_glabels', 'asm_conts', 'late_rodata_dummy_bytes', 'jtbl_rodata_size', 'late_rodata_asm_conts', 'fn_desc', 'data']) class GlobalAsmBlock: @@ -476,8 +492,7 @@ class GlobalAsmBlock: self.glued_line = '' real_line = line - line = re.sub(r'/\*.*?\*/', '', line) - line = re.sub(r'#.*', '', line) + line = re.sub(re_comment_or_string, re_comment_replacer, line) line = line.strip() line = re.sub(r'^[a-zA-Z0-9_]+:\s*', '', line) changed_section = False @@ -536,6 +551,8 @@ class GlobalAsmBlock: elif line.startswith('.asci'): z = (line.startswith('.asciz') or line.startswith('.asciiz')) self.add_sized(self.count_quoted_size(line, z, real_line, output_enc), real_line) + elif line.startswith('.byte'): + self.add_sized(len(line.split(',')), real_line) elif line.startswith('.'): # .macro, ... self.fail("asm directive not supported", real_line) @@ -564,8 +581,11 @@ class GlobalAsmBlock: def finish(self, state): src = [''] * (self.num_lines + 1) late_rodata_dummy_bytes = [] + jtbl_rodata_size = 0 late_rodata_fn_output = [] + num_instr = self.fn_section_sizes['.text'] // 4 + if self.fn_section_sizes['.late_rodata'] > 0: # Generate late rodata by emitting unique float constants. # This requires 3 instructions for each 4 bytes of rodata. @@ -573,10 +593,29 @@ class GlobalAsmBlock: # instructions for 8 bytes of rodata. size = self.fn_section_sizes['.late_rodata'] // 4 skip_next = False + needs_double = (self.late_rodata_alignment != 0) for i in range(size): if skip_next: skip_next = False continue + # Jump tables give 9 instructions for >= 5 words of rodata, and should be + # emitted when: + # - -O2 or -O2 -g3 are used, which give the right codegen + # - we have emitted our first .float/.double (to ensure that we find the + # created rodata in the binary) + # - we have emitted our first .double, if any (to ensure alignment of doubles + # in shifted rodata sections) + # - we have at least 5 words of rodata left to emit (otherwise IDO does not + # generate a jump table) + # - we have at least 10 more instructions to go in this function (otherwise our + # function size computation will be wrong since the delay slot goes unused) + if (not needs_double and state.use_jtbl_for_rodata and i >= 1 and + size - i >= 5 and num_instr - len(late_rodata_fn_output) >= 10): + cases = " ".join("case {}:".format(case) for case in range(size - i)) + late_rodata_fn_output.append("switch (*(volatile int*)0) { " + cases + " ; }") + late_rodata_fn_output.extend([""] * 8) + jtbl_rodata_size = (size - i) * 4 + break dummy_bytes = state.next_late_rodata_hex() late_rodata_dummy_bytes.append(dummy_bytes) if self.late_rodata_alignment == 4 * ((i + 1) % 2 + 1) and i + 1 < size: @@ -585,6 +624,7 @@ class GlobalAsmBlock: fval, = struct.unpack('>d', dummy_bytes + dummy_bytes2) late_rodata_fn_output.append('*(volatile double*)0 = {};'.format(fval)) skip_next = True + needs_double = True else: fval, = struct.unpack('>f', dummy_bytes) late_rodata_fn_output.append('*(volatile float*)0 = {}f;'.format(fval)) @@ -651,6 +691,7 @@ class GlobalAsmBlock: text_glabels=self.text_glabels, asm_conts=self.asm_conts, late_rodata_dummy_bytes=late_rodata_dummy_bytes, + jtbl_rodata_size=jtbl_rodata_size, late_rodata_asm_conts=self.late_rodata_asm_conts, fn_desc=self.fn_desc, data={ @@ -661,6 +702,9 @@ class GlobalAsmBlock: }) return src, fn +cutscene_data_regexpr = re.compile(r"CutsceneData (.|\n)*\[\] = {") +float_regexpr = re.compile(r"[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?f") + def repl_float_hex(m): return str(struct.unpack(">I", struct.pack(">f", float(m.group(0).strip().rstrip("f"))))[0]) @@ -689,13 +733,18 @@ def parse_source(f, opt, framepointer, input_enc, output_enc, print_source=None) min_instr_count = 2 skip_instr_count = 2 - state = GlobalState(min_instr_count, skip_instr_count) + use_jtbl_for_rodata = False + if opt in ['O2', 'g3'] and not framepointer: + use_jtbl_for_rodata = True + + state = GlobalState(min_instr_count, skip_instr_count, use_jtbl_for_rodata) global_asm = None - is_cutscene_data = False asm_functions = [] output_lines = [] + is_cutscene_data = False + for line_no, raw_line in enumerate(f, 1): raw_line = raw_line.rstrip() line = raw_line.lstrip() @@ -730,6 +779,8 @@ def parse_source(f, opt, framepointer, input_enc, output_enc, print_source=None) asm_functions.append(fn) global_asm = None elif ((line.startswith('#include "')) and line.endswith('" EARLY')): + # C includes qualified with EARLY (i.e. #include "file.c" EARLY) will be + # processed recursively when encountered fpath = os.path.dirname(f.name) fname = line[line.index(' ') + 2 : -7] include_src = StringIO() @@ -739,12 +790,14 @@ def parse_source(f, opt, framepointer, input_enc, output_enc, print_source=None) include_src.write('#line ' + str(line_no) + '\n') include_src.close() else: - if re.compile(r"(CutsceneData (.|\n)*\[\] = {)").search(line) is not None: + # This is a hack to replace all floating-point numbers in an array of a particular type + # (in this case CutsceneData) with their corresponding IEEE-754 hexadecimal representation + if cutscene_data_regexpr.search(line) is not None: is_cutscene_data = True elif line.endswith("};"): is_cutscene_data = False if is_cutscene_data: - raw_line = re.sub(re.compile(r"[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?f"), repl_float_hex, raw_line) + raw_line = re.sub(float_regexpr, repl_float_hex, raw_line) output_lines[-1] = raw_line if print_source: @@ -779,7 +832,8 @@ def fixup_objfile(objfile_name, functions, asm_prelude, assembler, output_enc): '.bss': [], } asm = [] - late_rodata_dummy_bytes = [] + all_late_rodata_dummy_bytes = [] + all_jtbl_rodata_size = [] late_rodata_asm = [] late_rodata_source_name_start = None late_rodata_source_name_end = None @@ -800,7 +854,8 @@ def fixup_objfile(objfile_name, functions, asm_prelude, assembler, output_enc): break loc = loc[1] prev_loc = prev_locs[sectype] - assert loc >= prev_loc, sectype + if loc < prev_loc: + raise Failure("Wrongly computed size for section {} (diff {}). This is an asm-processor bug!".format(sectype, prev_loc- loc)) if loc != prev_loc: asm.append('.section ' + sectype) if sectype == '.text': @@ -812,7 +867,8 @@ def fixup_objfile(objfile_name, functions, asm_prelude, assembler, output_enc): prev_locs[sectype] = loc + size if not ifdefed: all_text_glabels.update(function.text_glabels) - late_rodata_dummy_bytes.append(function.late_rodata_dummy_bytes) + all_late_rodata_dummy_bytes.append(function.late_rodata_dummy_bytes) + all_jtbl_rodata_size.append(function.jtbl_rodata_size) late_rodata_asm.append(function.late_rodata_asm_conts) for sectype, (temp_name, size) in function.data.items(): if temp_name is not None: @@ -863,6 +919,7 @@ def fixup_objfile(objfile_name, functions, asm_prelude, assembler, output_enc): # Move over section contents modified_text_positions = set() + jtbl_rodata_positions = set() last_rodata_pos = 0 for sectype in SECTIONS: if not to_copy[sectype]: @@ -894,18 +951,19 @@ def fixup_objfile(objfile_name, functions, asm_prelude, assembler, output_enc): # Move over late rodata. This is heuristic, sadly, since I can't think # of another way of doing it. moved_late_rodata = {} - if any(late_rodata_dummy_bytes): + if any(all_late_rodata_dummy_bytes) or any(all_jtbl_rodata_size): source = asm_objfile.find_section('.rodata') target = objfile.find_section('.rodata') source_pos = asm_objfile.symtab.find_symbol_in_section(late_rodata_source_name_start, source) source_end = asm_objfile.symtab.find_symbol_in_section(late_rodata_source_name_end, source) - if source_end - source_pos != sum(map(len, late_rodata_dummy_bytes)) * 4: + if source_end - source_pos != sum(map(len, all_late_rodata_dummy_bytes)) * 4 + sum(all_jtbl_rodata_size): raise Failure("computed wrong size of .late_rodata") new_data = list(target.data) - for dummy_bytes_list in late_rodata_dummy_bytes: + for dummy_bytes_list, jtbl_rodata_size in zip(all_late_rodata_dummy_bytes, all_jtbl_rodata_size): for index, dummy_bytes in enumerate(dummy_bytes_list): pos = target.data.index(dummy_bytes, last_rodata_pos) - if target.data.find(dummy_bytes, pos + 4) != -1: + # This check is nice, but makes time complexity worse for large files: + if SLOW_CHECKS and target.data.find(dummy_bytes, pos + 4) != -1: raise Failure("multiple occurrences of late_rodata hex magic. Change asm-processor to use something better than 0xE0123456!") if index == 0 and len(dummy_bytes_list) > 1 and target.data[pos+4:pos+8] == b'\0\0\0\0': # Ugly hack to handle double alignment for non-matching builds. @@ -920,6 +978,16 @@ def fixup_objfile(objfile_name, functions, asm_prelude, assembler, output_enc): moved_late_rodata[source_pos] = pos last_rodata_pos = pos + 4 source_pos += 4 + if jtbl_rodata_size > 0: + assert dummy_bytes_list, "should always have dummy bytes before jtbl data" + pos = last_rodata_pos + new_data[pos : pos + jtbl_rodata_size] = \ + source.data[source_pos : source_pos + jtbl_rodata_size] + for i in range(0, jtbl_rodata_size, 4): + moved_late_rodata[source_pos + i] = pos + i + jtbl_rodata_positions.add(pos + i) + last_rodata_pos += jtbl_rodata_size + source_pos += jtbl_rodata_size target.data = bytes(new_data) # Merge strtab data. @@ -981,7 +1049,8 @@ def fixup_objfile(objfile_name, functions, asm_prelude, assembler, output_enc): for reltab in target.relocated_by: nrels = [] for rel in reltab.relocations: - if sectype == '.text' and rel.r_offset in modified_text_positions: + if (sectype == '.text' and rel.r_offset in modified_text_positions or + sectype == '.rodata' and rel.r_offset in jtbl_rodata_positions): # don't include relocations for late_rodata dummy code continue # hopefully we don't have relocations for local or