From fe1d17d42bec615fbc06b628de7609d99b0f8fec Mon Sep 17 00:00:00 2001 From: Lorenzooone Date: Sun, 14 Jul 2019 02:29:23 +0200 Subject: [PATCH] Miscellanous fixes (#43) * Fix https://github.com/jeffman/Mother2GbaTranslation/issues/36 Wrong order of the operations caused unexpected behaviour due to unpredictable number in r3. This is the reason why scrolling down was fine, but scrolling up was not. * Put proper indentation. * Fix https://github.com/jeffman/Mother2GbaTranslation/issues/29 --- notes/m2-notes.txt | 2 ++ src/m2-hack.asm | 8 ++++++++ src/m2-vwf-entries.asm | 45 +++++++++++++++++++++++++++++++++++++++++- 3 files changed, 54 insertions(+), 1 deletion(-) diff --git a/notes/m2-notes.txt b/notes/m2-notes.txt index a851374..6a90f41 100644 --- a/notes/m2-notes.txt +++ b/notes/m2-notes.txt @@ -132,6 +132,7 @@ Subroutines 80A2E00: door-related? r0 = source, r1 = dest 80A334C: store r0 to window memory 80B8AE0: draw PSI target/PP cost window with PSI index r0 +80BB268: Weapons window 80BC670: check if currently selected character has item equipped r0: item index + 1 returns: 1 if equipped, 0 otherwise or if index==0 @@ -167,6 +168,7 @@ Subroutines 80C1FBC: draw PSI window for character r0 80C239C: print PSI name with Greek letter 80C438C: check for cursor movements in PSI window +80C5B10: If everything works properly, changes cursor position in Weapons/Body/Head/Other submenu 80C87D0: draw blank window and border (r0: window pointer) 80C8BE4: render main menu string to window r0 80C8FFC: render string to window r0 diff --git a/src/m2-hack.asm b/src/m2-hack.asm index 0d89e1f..a7c5335 100644 --- a/src/m2-hack.asm +++ b/src/m2-hack.asm @@ -718,6 +718,14 @@ ldrh r3,[r3] b 0x080C959A .pool +//--------------------------------------------------------- +// EEB1A (load player name) +//--------------------------------------------------------- + +.org 0x80EEB1A +bl eeb1a_player_name //Call the new routine +b 0x80EEB7A //Do the rest of the original routine + //--------------------------------------------------------- // Teleport window hacks //--------------------------------------------------------- diff --git a/src/m2-vwf-entries.asm b/src/m2-vwf-entries.asm index 9c31754..9e2d449 100644 --- a/src/m2-vwf-entries.asm +++ b/src/m2-vwf-entries.asm @@ -453,9 +453,10 @@ mov r2,0x3 bl print_blankstr // Clobbered code +pop {r1-r3} //r3 would otherwise be a 0x3000xxx number sub r0,r3,1 strh r0,[r7,0x36] -pop {r1-r3,pc} +pop {pc} c5500_clear_down: push {r0-r3,lr} @@ -953,3 +954,45 @@ add r2,r0,1 mov r0,r5 pop {pc} +.pool + +//============================================================================== +//Loads the player's name properly +eeb1a_player_name: +push {lr} +mov r2,#0x18 //Maximum amount of characters in the name +ldr r1,=m2_player1 //Player's name new location +mov r3,#0 +@@continue_cycle: //Count the amount of characters +cmp r3,r2 +bge @@exit_cycle +add r0,r1,r3 +ldrb r0,[r0,#0] +cmp r0,#0xFF +beq @@exit_cycle +add r3,#1 +b @@continue_cycle +@@exit_cycle: +mov r4,r3 //Store the amount of characters in r4 + +bl 0x80A322C //Clobbered code: load at which letter the routine is +lsl r1,r4,#0x10 +lsl r0,r0,#0x10 +cmp r1,r0 +blt @@ended +bl 0x80A322C + +mov r3,#1 +ldr r1,=m2_player1 //Player's name new location. The routine starts from 1 because the original routine had a flag before the name, so we subtract 1 to the address we look at in order to avoid skipping a character +sub r1,r1,r3 +lsl r0,r0,#0x10 +asr r0,r0,#0x10 +add r1,r1,r0 +ldrb r0,[r1,#0] +b @@next +@@ended: +mov r0,#0 + +@@next: //Do the rest of the routine +pop {pc} +.pool \ No newline at end of file