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
This commit is contained in:
Lorenzooone 2019-07-14 02:29:23 +02:00 committed by jeffman
parent 87380c26a9
commit fe1d17d42b
3 changed files with 54 additions and 1 deletions

View File

@ -132,6 +132,7 @@ Subroutines
80A2E00: door-related? r0 = source, r1 = dest 80A2E00: door-related? r0 = source, r1 = dest
80A334C: store r0 to window memory 80A334C: store r0 to window memory
80B8AE0: draw PSI target/PP cost window with PSI index r0 80B8AE0: draw PSI target/PP cost window with PSI index r0
80BB268: Weapons window
80BC670: check if currently selected character has item equipped 80BC670: check if currently selected character has item equipped
r0: item index + 1 r0: item index + 1
returns: 1 if equipped, 0 otherwise or if index==0 returns: 1 if equipped, 0 otherwise or if index==0
@ -167,6 +168,7 @@ Subroutines
80C1FBC: draw PSI window for character r0 80C1FBC: draw PSI window for character r0
80C239C: print PSI name with Greek letter 80C239C: print PSI name with Greek letter
80C438C: check for cursor movements in PSI window 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) 80C87D0: draw blank window and border (r0: window pointer)
80C8BE4: render main menu string to window r0 80C8BE4: render main menu string to window r0
80C8FFC: render string to window r0 80C8FFC: render string to window r0

View File

@ -718,6 +718,14 @@ ldrh r3,[r3]
b 0x080C959A b 0x080C959A
.pool .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 // Teleport window hacks
//--------------------------------------------------------- //---------------------------------------------------------

View File

@ -453,9 +453,10 @@ mov r2,0x3
bl print_blankstr bl print_blankstr
// Clobbered code // Clobbered code
pop {r1-r3} //r3 would otherwise be a 0x3000xxx number
sub r0,r3,1 sub r0,r3,1
strh r0,[r7,0x36] strh r0,[r7,0x36]
pop {r1-r3,pc} pop {pc}
c5500_clear_down: c5500_clear_down:
push {r0-r3,lr} push {r0-r3,lr}
@ -953,3 +954,45 @@ add r2,r0,1
mov r0,r5 mov r0,r5
pop {pc} 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