From 0af415e175729e0794bcf7527e0ccef1fdbcc6c5 Mon Sep 17 00:00:00 2001 From: Lorenzooone Date: Sun, 14 Jul 2019 22:52:28 +0200 Subject: [PATCH] Fix https://github.com/jeffman/Mother2GbaTranslation/issues/34 (#44) --- notes/m2-notes.txt | 1 + src/m2-hack.asm | 15 +++++++++++ src/m2-vwf-entries.asm | 58 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 74 insertions(+) diff --git a/notes/m2-notes.txt b/notes/m2-notes.txt index 6a90f41..9a80e32 100644 --- a/notes/m2-notes.txt +++ b/notes/m2-notes.txt @@ -74,6 +74,7 @@ English names: 0x30023D4: current ATM balance 0x3002500: buttons being pressed 0x3002504: shadow of 0x3002500? delayed by one frame maybe? +0x3004F08: printing flag 0x30051EC: tile offset (usually 0x100) 0x30051F0: flag? gets set to 1 when you change rooms, goes back to 0 the first time you open a text window 0x3005224: menu sub-state diff --git a/src/m2-hack.asm b/src/m2-hack.asm index a7c5335..fece9a9 100644 --- a/src/m2-hack.asm +++ b/src/m2-hack.asm @@ -726,6 +726,19 @@ b 0x080C959A bl eeb1a_player_name //Call the new routine b 0x80EEB7A //Do the rest of the original routine +//--------------------------------------------------------- +// End of battle hacks +//--------------------------------------------------------- + +.org 0x80cb936 +bl cb936_battle_won //Removes the game's ability to read the script instantly out of a won battle + +.org 0x80a1f8c +bl a1f8c_set_script_reading //Change the game's ability to read the script instantly a bit + +.org 0x80b7702 +bl b7702_check_script_reading //Change the newly set value slowly and make it 0 when it's safe + //--------------------------------------------------------- // Teleport window hacks //--------------------------------------------------------- @@ -855,8 +868,10 @@ m2_enemy_attributes: .definelabel m2_food ,0x3001F30 .definelabel m2_rockin ,0x3001F3A .definelabel m2_player1 ,0x3001F50 +.definelabel m2_script_readability ,0x3004F08 .definelabel m2_active_window_pc ,0x3005264 .definelabel m2_soundeffect ,0x8001720 +.definelabel m2_enable_script ,0x80A1F6C .definelabel m2_sub_a334c ,0x80A334C .definelabel m2_sub_a3384 ,0x80A3384 .definelabel m2_psitargetwindow ,0x80B8AE0 diff --git a/src/m2-vwf-entries.asm b/src/m2-vwf-entries.asm index 9e2d449..26bbee5 100644 --- a/src/m2-vwf-entries.asm +++ b/src/m2-vwf-entries.asm @@ -995,4 +995,62 @@ mov r0,#0 @@next: //Do the rest of the routine pop {pc} +.pool + +//============================================================================== +//These three hacks remove the game's ability to read the script instantly out of a won battle + +cb936_battle_won: //Called at the end of a battle if it is won +push {lr} +ldr r0,=m2_script_readability //Remove the ability to instantly read the script +mov r1,#8 +strb r1,[r0,#0] + +ldr r0,=#0x3000A6C //Clobbered code +mov r1,#0 +pop {pc} + +.pool + +//============================================================================== + +b7702_check_script_reading: //Makes the game wait six extra frames before being able to read the script out of battle +push {lr} +ldr r0,=m2_script_readability +ldrb r1,[r0,#0] +cmp r1,#2 //If the value is > 2, then lower it +ble @@next +sub r1,r1,#1 +strb r1,[r0,#0] +b @@end + +@@next: +cmp r1,#2 //If the value is 2, change it to 0 and allow reading the script +bne @@end +mov r1,#0 +strb r1,[r0,#0] + +@@end: +mov r7,r10 //Clobbered code +mov r6,r9 +pop {pc} +.pool + +//============================================================================== + +a1f8c_set_script_reading: //Changes the way the game sets the ability to read the script +push {lr} +ldrb r1,[r0,#0] +cmp r1,#8 //If this particular flag is set, then don't do a thing. Allows to make it so the game waits before reading the script. +beq @@next +mov r1,#0 +strb r1,[r0,#0] +b @@end + +@@next: +mov r1,#0 + +@@end: +pop {pc} + .pool \ No newline at end of file