Mother2GbaTranslation/m2-vwf-entries.asm

960 lines
18 KiB
NASM
Raw Normal View History

2017-03-09 18:16:37 +00:00
//==============================================================================
2017-03-29 05:19:51 +01:00
c980c_custom_codes:
2017-03-09 18:16:37 +00:00
push {r1-r2,lr}
mov r1,r7
mov r2,r5
2017-03-29 05:19:51 +01:00
bl customcodes_parse
2017-04-03 03:12:18 +01:00
ldr r1,[r6]
2017-03-09 18:16:37 +00:00
// If 0, return [r6]+2; otherwise, return [r6]+r0
2017-03-29 05:19:51 +01:00
beq @@next
2017-03-09 18:16:37 +00:00
add r0,r0,r1
pop {r1-r2,pc}
2017-03-29 05:19:51 +01:00
@@next:
add r0,r1,2
2017-03-09 18:16:37 +00:00
pop {r1-r2,pc}
//==============================================================================
2017-03-29 05:19:51 +01:00
c980c_weld_entry:
2017-04-11 06:16:14 +01:00
push {r0-r3,lr}
2017-03-09 18:16:37 +00:00
mov r0,r5
mov r1,r7
2017-03-29 05:19:51 +01:00
bl weld_entry
2017-04-11 06:16:14 +01:00
pop {r0-r3,pc}
2017-03-09 18:16:37 +00:00
2017-03-14 04:05:02 +00:00
//==============================================================================
2017-03-29 05:19:51 +01:00
c8ffc_custom_codes:
2017-03-14 04:05:02 +00:00
push {r2,r5,lr}
2017-04-03 03:12:18 +01:00
ldrb r0,[r2]
2017-03-14 04:05:02 +00:00
mov r5,r0
mov r1,r2
mov r2,r4
2017-03-29 05:19:51 +01:00
bl customcodes_parse
cmp r0,0
beq @@next
2017-03-14 04:05:02 +00:00
mov r2,r12
add r0,r0,r2
2017-03-29 05:19:51 +01:00
strh r0,[r4,0x14]
2017-03-14 04:05:02 +00:00
pop {r2,r5}
2017-03-29 05:19:51 +01:00
add sp,4
ldr r1,=0x80C904D
2017-03-14 04:05:02 +00:00
bx r1
2017-03-29 05:19:51 +01:00
@@next:
2017-03-14 04:05:02 +00:00
mov r0,r5
2017-03-29 05:19:51 +01:00
cmp r0,1
2017-03-14 04:05:02 +00:00
pop {r2,r5,pc}
2017-03-29 05:19:51 +01:00
.pool
2017-03-14 04:05:02 +00:00
//==============================================================================
2017-03-29 05:19:51 +01:00
c8ffc_weld_entry:
2017-03-14 04:05:02 +00:00
push {r0-r1,lr}
mov r0,r4
mov r1,r2
2017-03-29 05:19:51 +01:00
bl weld_entry
2017-03-14 04:05:02 +00:00
pop {r0-r1,pc}
2017-03-09 18:16:37 +00:00
//==============================================================================
2017-03-29 05:19:51 +01:00
c980c_resetx:
2017-03-09 18:16:37 +00:00
push {r1,lr}
2017-03-29 05:19:51 +01:00
mov r1,0
strh r1,[r0,2]
2017-03-09 18:16:37 +00:00
pop {r1}
2017-03-29 05:19:51 +01:00
bl 0x80C87D0
2017-03-10 23:40:47 +00:00
pop {pc}
2017-03-13 17:53:55 +00:00
//==============================================================================
2017-03-29 05:19:51 +01:00
c980c_resetx_newline:
2017-03-13 17:53:55 +00:00
push {lr}
2017-03-29 05:19:51 +01:00
strh r0,[r5,0x2C]
strh r4,[r5,0x2A]
strh r4,[r5,2]
2017-03-13 17:53:55 +00:00
pop {pc}
2017-03-18 21:10:45 +00:00
//==============================================================================
2017-03-29 05:19:51 +01:00
c980c_resetx_scroll:
2017-03-18 21:10:45 +00:00
push {lr}
2017-03-29 05:19:51 +01:00
strh r0,[r5,0x2C]
strh r1,[r5,0x2A]
strh r1,[r5,2]
2017-03-18 21:10:45 +00:00
pop {pc}
//==============================================================================
2017-03-29 05:19:51 +01:00
c980c_resetx_other:
2017-03-18 21:10:45 +00:00
push {lr}
2017-03-29 05:19:51 +01:00
strh r0,[r5,0x2C]
strh r2,[r5,0x2A]
strh r2,[r5,2]
2017-03-18 21:10:45 +00:00
pop {pc}
//==============================================================================
2017-03-29 05:19:51 +01:00
c980c_resetx_other2:
2017-03-18 21:10:45 +00:00
push {lr}
2017-03-29 05:19:51 +01:00
mov r2,0
strh r2,[r5,0x2A]
strh r2,[r5,2]
2017-03-18 21:10:45 +00:00
pop {pc}
//==============================================================================
2017-03-29 05:19:51 +01:00
c980c_resetx_other3:
2017-03-18 21:10:45 +00:00
push {lr}
2017-03-29 05:19:51 +01:00
mov r1,0
strh r1,[r5,0x2A]
strh r1,[r5,2]
2017-03-18 21:10:45 +00:00
pop {pc}
//==============================================================================
2017-03-29 05:19:51 +01:00
c980c_resetx_other4:
2017-03-18 21:10:45 +00:00
push {lr}
2017-03-29 05:19:51 +01:00
strh r0,[r5,0x2C]
strh r6,[r5,0x2A]
strh r6,[r5,2]
2017-03-18 21:10:45 +00:00
pop {pc}
2017-03-13 17:53:55 +00:00
2017-03-10 23:40:47 +00:00
//==============================================================================
2017-03-29 05:19:51 +01:00
c87d0_clear_entry:
2017-03-10 23:40:47 +00:00
push {lr}
// Reset X
2017-03-29 05:19:51 +01:00
mov r1,0
strh r1,[r0,2]
2017-03-10 23:40:47 +00:00
// Clear window
2017-03-29 05:19:51 +01:00
bl clear_window
2017-03-10 23:40:47 +00:00
// Clobbered code
2017-03-29 05:19:51 +01:00
ldr r4,=0x3005270
mov r1,0x24
2017-03-11 04:41:45 +00:00
pop {pc}
2017-03-29 05:19:51 +01:00
.pool
2017-03-11 04:41:45 +00:00
//==============================================================================
2017-03-29 05:19:51 +01:00
c9634_resetx:
2017-03-11 04:41:45 +00:00
push {lr}
2017-03-29 05:19:51 +01:00
mov r4,0
strh r4,[r6,2]
2017-03-11 04:41:45 +00:00
// Clobbered code
2017-04-03 03:12:18 +01:00
strh r5,[r1]
2017-03-11 04:41:45 +00:00
pop {pc}
//==============================================================================
2017-03-12 21:33:47 +00:00
// Only render the (None) strings in the equip window if there's nothing equipped
2017-03-29 05:19:51 +01:00
c4b2c_skip_nones:
push {r7,lr}
2017-03-29 05:19:51 +01:00
add sp,-4
mov r7,0
// Get the (none) pointer
mov r0,r4
mov r1,r10
2017-03-29 05:19:51 +01:00
mov r2,0x2A
bl 0x80BE260
mov r5,r0
// Check each equip slot
2017-03-29 05:19:51 +01:00
ldr r6,=0x3001D40
ldr r3,=0x3005264
2017-04-03 03:12:18 +01:00
ldrh r0,[r3] // active party character
2017-03-29 05:19:51 +01:00
mov r1,0x6C
mul r0,r1
add r6,r0,r6
2017-03-29 05:19:51 +01:00
add r6,0x75
2017-04-03 03:12:18 +01:00
ldrb r0,[r6]
2017-03-29 05:19:51 +01:00
cmp r0,0
bne @@next
// Weapon
mov r0,r8
mov r1,r5
2017-03-29 05:19:51 +01:00
mov r2,0x6
mov r3,0
2017-04-03 03:12:18 +01:00
str r7,[sp]
2017-03-29 05:19:51 +01:00
bl 0x80C9634
2017-03-29 05:19:51 +01:00
@@next:
ldrb r0,[r6,1]
cmp r0,0
bne @@next2
// Body
mov r0,r8
mov r1,r5
2017-03-29 05:19:51 +01:00
mov r2,0x6
mov r3,1
2017-04-03 03:12:18 +01:00
str r7,[sp]
2017-03-29 05:19:51 +01:00
bl 0x80C9634
2017-03-29 05:19:51 +01:00
@@next2:
ldrb r0,[r6,2]
cmp r0,0
bne @@next3
// Arms
mov r0,r8
mov r1,r5
2017-03-29 05:19:51 +01:00
mov r2,0x6
mov r3,2
2017-04-03 03:12:18 +01:00
str r7,[sp]
2017-03-29 05:19:51 +01:00
bl 0x80C9634
2017-03-29 05:19:51 +01:00
@@next3:
ldrb r0,[r6,3]
cmp r0,0
bne @@next4
// Other
mov r0,r8
mov r1,r5
2017-03-29 05:19:51 +01:00
mov r2,0x6
mov r3,3
2017-04-03 03:12:18 +01:00
str r7,[sp]
2017-03-29 05:19:51 +01:00
bl 0x80C9634
2017-03-29 05:19:51 +01:00
@@next4:
mov r0,0
mov r10,r0
2017-03-29 05:19:51 +01:00
add sp,4
2017-03-11 18:30:08 +00:00
pop {r7,pc}
2017-03-29 05:19:51 +01:00
.pool
2017-03-11 18:30:08 +00:00
//==============================================================================
2017-03-12 21:33:47 +00:00
// Clears the equipment portion of the equip window
2017-03-11 18:30:08 +00:00
// r0 = window pointer
2017-03-29 05:19:51 +01:00
clear_equipment:
push {r0-r4,lr}
add sp,-4
mov r3,r0
ldr r0,=0x44444444
str r0,[sp]
ldrh r0,[r3,0x22]
add r0,6
ldrh r1,[r3,0x24]
ldrh r2,[r3,0x26]
2017-03-29 05:19:51 +01:00
sub r2,6
ldrh r3,[r3,0x28]
2017-03-29 05:19:51 +01:00
bl clear_rect
add sp,4
pop {r0-r4,pc}
2017-03-29 05:19:51 +01:00
.pool
2017-03-11 18:30:08 +00:00
//==============================================================================
// Clear equipment and offense/defense when moving left/right on equip screen
2017-03-11 18:30:08 +00:00
// r6 = window pointer
2017-03-29 05:19:51 +01:00
c4b2c_clear_left:
2017-03-11 18:30:08 +00:00
mov r0,r6
2017-03-29 05:19:51 +01:00
bl clear_equipment
2017-03-11 18:30:08 +00:00
// Clear offense/defense
push {r0-r2}
2017-03-29 05:19:51 +01:00
mov r0,8
mov r2,r0
2017-03-29 05:19:51 +01:00
mov r1,0xB
bl print_blankstr
add r1,2
bl print_blankstr
pop {r0-r2}
2017-03-11 18:30:08 +00:00
// Clobbered code
2017-04-03 03:12:18 +01:00
strh r1,[r3]
2017-03-29 05:19:51 +01:00
ldr r0,=0x80C4F3B
2017-03-11 18:30:08 +00:00
bx r0
2017-03-29 05:19:51 +01:00
c4b2c_clear_right:
2017-03-11 18:30:08 +00:00
mov r0,r6
2017-03-29 05:19:51 +01:00
bl clear_equipment
2017-03-11 18:30:08 +00:00
// Clear offense/defense
push {r0-r2}
2017-03-29 05:19:51 +01:00
mov r0,8
mov r2,r0
2017-03-29 05:19:51 +01:00
mov r1,0xB
bl print_blankstr
add r1,2
bl print_blankstr
pop {r0-r2}
2017-03-11 18:30:08 +00:00
// Clobbered code
2017-04-03 03:12:18 +01:00
strh r1,[r3]
2017-03-29 05:19:51 +01:00
ldr r0,=0x80C4EFF
2017-03-12 21:33:47 +00:00
bx r0
2017-03-29 05:19:51 +01:00
.pool
2017-03-13 17:53:12 +00:00
//==============================================================================
// Clear PSI target window when moving left/right on PSI screen
2017-03-29 05:19:51 +01:00
c438c_moveright:
2017-03-13 17:53:12 +00:00
push {r0-r1,lr}
2017-03-29 05:19:51 +01:00
ldr r1,=0x3005230
ldr r0,[r1,0x24] // PSI target window pointer
bl clear_window
2017-03-13 17:53:12 +00:00
pop {r0-r1}
// Clobbered code
2017-03-29 05:19:51 +01:00
add r0,1
strh r0,[r5,0x34]
2017-03-13 17:53:12 +00:00
pop {pc}
2017-03-29 05:19:51 +01:00
c438c_moveleft:
2017-03-13 17:53:12 +00:00
push {r0-r1,lr}
2017-03-29 05:19:51 +01:00
ldr r1,=0x3005230
ldr r0,[r1,0x24] // PSI target window pointer
bl clear_window
2017-03-13 17:53:12 +00:00
pop {r0-r1}
// Clobbered code
2017-03-29 05:19:51 +01:00
sub r0,1
strh r0,[r5,0x34]
2017-03-13 17:53:12 +00:00
pop {pc}
2017-03-29 05:19:51 +01:00
c438c_moveup:
2017-03-13 17:53:12 +00:00
push {r0-r1,lr}
2017-03-29 05:19:51 +01:00
ldr r1,=0x3005230
ldr r0,[r1,0x24] // PSI target window pointer
bl clear_window
2017-03-13 17:53:12 +00:00
pop {r0-r1}
// Clobbered code
2017-03-29 05:19:51 +01:00
sub r0,1
strh r0,[r5,0x36]
2017-03-13 17:53:12 +00:00
pop {pc}
2017-03-29 05:19:51 +01:00
c438c_movedown:
2017-03-13 17:53:12 +00:00
push {r0-r1,lr}
2017-03-29 05:19:51 +01:00
ldr r1,=0x3005230
ldr r0,[r1,0x24] // PSI target window pointer
bl clear_window
2017-03-13 17:53:12 +00:00
pop {r0-r1}
// Clobbered code
2017-03-29 05:19:51 +01:00
add r0,1
strh r0,[r5,0x36]
2017-03-13 17:53:12 +00:00
pop {pc}
2017-03-29 05:19:51 +01:00
.pool
2017-03-14 04:06:36 +00:00
//==============================================================================
// Prints a string in the status window
2017-03-29 05:19:51 +01:00
c0a5c_printstr:
2017-03-14 04:06:36 +00:00
push {r0-r2,lr}
mov r0,r1
mov r1,r2
mov r2,r3
2017-03-29 05:19:51 +01:00
bl print_string
2017-03-14 04:06:36 +00:00
pop {r0-r2,pc}
//==============================================================================
// Prints an empty space instead of the "Press A for PSI info" string
2017-03-29 05:19:51 +01:00
c0a5c_psi_info_blank:
2017-03-14 04:06:36 +00:00
push {lr}
2017-03-29 05:19:51 +01:00
mov r0,5
mov r1,0xF
mov r2,0x14
bl print_blankstr
2017-03-14 04:06:36 +00:00
pop {pc}
2017-03-17 00:32:11 +00:00
//==============================================================================
// Redraws the status window (when exiting the PSI submenu, etc.)
2017-03-29 05:19:51 +01:00
bac18_redraw_status:
2017-03-17 00:32:11 +00:00
push {r4,lr}
2017-03-29 05:19:51 +01:00
ldr r4,=0x3005230
ldr r4,[r4,0x18]
2017-03-17 00:32:11 +00:00
// Get the address of the status text
2017-03-29 05:19:51 +01:00
ldr r0,=0x8B17EE4
ldr r1,=0x8B17424
mov r2,0x11
bl 0x80BE260
2017-03-17 00:32:11 +00:00
// Prepare the window for parsing
mov r1,r0
mov r0,r4
2017-03-29 05:19:51 +01:00
mov r2,0
bl 0x80BE458
2017-03-17 00:32:11 +00:00
// Render text
mov r0,r4
2017-03-29 05:19:51 +01:00
bl 0x80C8FFC
2017-03-17 00:32:11 +00:00
// Render numbers
mov r0,r4
2017-03-29 05:19:51 +01:00
mov r1,0
bl 0x80C0A5C
2017-03-17 00:32:11 +00:00
pop {r4,pc}
2017-03-29 05:19:51 +01:00
.pool
//==============================================================================
// Clears the PSI window when switching classes
// r5 = 0x3005230
2017-03-29 05:19:51 +01:00
bac18_clear_psi:
push {r0,lr}
2017-03-29 05:19:51 +01:00
ldr r0,[r5,0x20] // PSI class window pointer
2017-04-03 03:12:18 +01:00
ldrb r0,[r0]
2017-03-29 05:19:51 +01:00
mov r1,0x10
and r0,r1
2017-03-29 05:19:51 +01:00
cmp r0,0
beq @@next
// If flag 0x10 is set, clear the PSI window
2017-03-29 05:19:51 +01:00
ldr r0,[r5,0x1C] // PSI window
bl clear_window
2017-03-29 05:19:51 +01:00
@@next:
// Clobbered code
pop {r0}
2017-03-29 05:19:51 +01:00
lsl r0,r0,0x10
asr r4,r0,0x10
pop {pc}
//==============================================================================
// Only clear+redraw the PSI help if a button has been pressed
2017-03-29 05:19:51 +01:00
bac18_check_button:
push {lr}
2017-03-29 05:19:51 +01:00
ldr r0,=0x3002500
2017-04-03 03:12:18 +01:00
ldrh r0,[r0]
2017-03-29 05:19:51 +01:00
cmp r0,0
beq @@next
// Clear window
2017-03-29 05:19:51 +01:00
ldr r0,[r5,0x28]
mov r1,r2
2017-03-29 05:19:51 +01:00
mov r2,0
bl 0x80BE458
// Render window
2017-03-29 05:19:51 +01:00
ldr r0,[r5,0x28]
bl 0x80C8BE4
2017-03-29 05:19:51 +01:00
@@next:
pop {pc}
2017-03-29 05:19:51 +01:00
.pool
2017-03-18 01:22:35 +00:00
//==============================================================================
// Clear offense/defense changes when switching in equip select window
2017-03-29 05:19:51 +01:00
c5500_clear_up:
2017-03-18 01:22:35 +00:00
push {r1-r2,lr}
2017-03-29 05:19:51 +01:00
mov r0,0xD
mov r1,0xB
mov r2,0x3
bl print_blankstr
add r1,2
bl print_blankstr
2017-03-18 01:22:35 +00:00
// Clobbered code
2017-03-29 05:19:51 +01:00
sub r0,r3,1
strh r0,[r7,0x36]
2017-03-18 01:22:35 +00:00
pop {r1-r2,pc}
2017-03-29 05:19:51 +01:00
c5500_clear_down:
2017-03-18 01:22:35 +00:00
push {r0-r2,lr}
2017-03-29 05:19:51 +01:00
mov r0,0xD
mov r1,0xB
mov r2,0x3
bl print_blankstr
add r1,2
bl print_blankstr
2017-03-18 01:22:35 +00:00
// Clobbered code
pop {r0-r2}
2017-03-29 05:19:51 +01:00
add r0,1
strh r0,[r7,0x36]
2017-03-18 01:22:35 +00:00
pop {pc}
//==============================================================================
// Clear offense/defense when re-equipping (or un-equipping) something
2017-03-29 05:19:51 +01:00
baef8_reequip_erase:
2017-03-18 01:22:35 +00:00
push {r1,lr}
2017-03-29 05:19:51 +01:00
mov r0,8
mov r1,0xB
mov r2,4
bl print_blankstr
add r1,2
bl print_blankstr
2017-03-18 01:22:35 +00:00
// Clobbered code
pop {r1}
2017-03-29 05:19:51 +01:00
mov r0,2
2017-04-03 03:12:18 +01:00
strh r0,[r1]
2017-03-18 01:22:35 +00:00
pop {pc}
//==============================================================================
// Redraw main menu when exiting PSI target window
2017-03-29 05:19:51 +01:00
b8bbc_redraw_menu_2to1:
push {r1-r4,lr}
2017-03-29 05:19:51 +01:00
add sp,-4
// Copied from 80B7A74
2017-03-29 05:19:51 +01:00
mov r0,0
2017-04-03 03:12:18 +01:00
str r0,[sp]
2017-03-29 05:19:51 +01:00
ldr r0,=0x3005230
2017-04-03 03:12:18 +01:00
ldr r0,[r0] // main menu window pointer
2017-03-29 05:19:51 +01:00
ldr r1,[r0,4] // text pointer
mov r2,5
mov r3,2
mov r4,r0
2017-03-29 05:19:51 +01:00
bl 0x80BE4C8
mov r0,r4
2017-03-29 05:19:51 +01:00
bl 0x80C8BE4
// Clobbered code (restore the window borders, etc.)
2017-03-29 05:19:51 +01:00
mov r0,1
bl 0x80BD7AC
2017-03-29 05:19:51 +01:00
add sp,4
pop {r1-r4,pc}
2017-03-29 05:19:51 +01:00
.pool
2017-03-18 17:38:32 +00:00
//==============================================================================
// Redraw main menu when entering PSI target window
2017-03-29 05:19:51 +01:00
b8bbc_redraw_menu_13to2:
2017-03-18 17:38:32 +00:00
push {r1-r4,lr}
2017-03-29 05:19:51 +01:00
add sp,-4
2017-03-18 17:38:32 +00:00
// Copied from 80B7A74
2017-03-29 05:19:51 +01:00
mov r0,0
2017-04-03 03:12:18 +01:00
str r0,[sp]
2017-03-29 05:19:51 +01:00
ldr r0,=0x3005230
2017-04-03 03:12:18 +01:00
ldr r0,[r0] // main menu window pointer
2017-03-29 05:19:51 +01:00
ldr r1,[r0,4] // text pointer
mov r2,5
mov r3,2
2017-03-18 17:38:32 +00:00
mov r4,r0
2017-03-29 05:19:51 +01:00
bl 0x80BE4C8
2017-03-18 17:38:32 +00:00
mov r0,r4
2017-03-29 05:19:51 +01:00
bl 0x80C8BE4
2017-03-18 17:38:32 +00:00
// Clobbered code (restore the window borders, etc.)
2017-03-29 05:19:51 +01:00
mov r0,1
bl 0x80BD7F8
2017-03-18 17:38:32 +00:00
2017-03-29 05:19:51 +01:00
add sp,4
2017-03-18 17:38:32 +00:00
pop {r1-r4,pc}
2017-03-29 05:19:51 +01:00
.pool
2017-03-18 18:43:57 +00:00
//==============================================================================
// Print a space before the Greek letter
2017-03-29 05:19:51 +01:00
d3934_print_space:
2017-04-11 22:39:56 +01:00
push {r2-r3,lr}
2017-03-18 18:43:57 +00:00
mov r0,r4
2017-03-29 05:19:51 +01:00
bl print_space
2017-04-11 22:39:56 +01:00
pop {r2-r3}
2017-03-18 18:43:57 +00:00
// Clobbered code
2017-03-29 05:19:51 +01:00
ldrb r1,[r3,1]
lsl r0,r1,1
2017-03-18 18:43:57 +00:00
pop {pc}
2017-03-18 21:11:19 +00:00
//==============================================================================
// Copy a tile up one line
// r4: (x << 16) (relative)
// r5: dest tilemap
// r6: window
// r7: source tilemap
// r8: y (dest, relative)
// r10: 3005270
2017-03-29 05:19:51 +01:00
ca4bc_copy_tile_up:
2017-03-18 21:11:19 +00:00
push {r4-r7,lr}
// Four cases:
// 1) copy blank to blank
// 2) copy blank to non-blank
// 3) copy non-blank to blank
// 4) copy non-blank to non-blank
// 1) we don't have to do anything: pixels are blank for source and dest,
// and the tilemap won't change either
// 2) we have to erase dest pixels and set dest tilemap to 0xE2FF
// 3) we have to copy source pixels to dest pixels and set dest tilemap
// to the proper tile index
// 4) we only have to copy the source pixels to dest pixels
// Check blank by comparing tilemap with 0xE2FF
// 0xE2FF is already stored to [sp+(# of regs pushed * 4)]
2017-03-29 05:19:51 +01:00
ldr r0,[sp,20]
2017-04-03 03:12:18 +01:00
ldrh r1,[r7]
ldrh r2,[r5]
2017-03-18 21:11:19 +00:00
cmp r1,r0
2017-03-29 05:19:51 +01:00
bne @@next
2017-03-18 21:11:19 +00:00
cmp r2,r0
2017-03-29 05:19:51 +01:00
bne @@blank_to_nonblank
2017-03-18 21:11:19 +00:00
// Case 1: blank to blank
2017-03-29 05:19:51 +01:00
b @@end
2017-03-18 21:11:19 +00:00
2017-03-29 05:19:51 +01:00
@@next:
2017-03-18 21:11:19 +00:00
cmp r2,r0
2017-03-29 05:19:51 +01:00
bne @@nonblank_to_nonblank
2017-03-18 21:11:19 +00:00
// Case 3: non-blank to blank
2017-03-29 05:19:51 +01:00
@@nonblank_to_blank:
2017-03-18 21:11:19 +00:00
// Copy pixels up
2017-03-29 05:19:51 +01:00
ldrh r0,[r6,0x22]
lsl r0,r0,16
2017-03-18 21:11:19 +00:00
add r0,r0,r4
2017-03-29 05:19:51 +01:00
lsr r0,r0,16 // x
ldrh r1,[r6,0x24]
2017-03-18 21:11:19 +00:00
add r1,r8 // dest y
mov r4,r1
2017-03-29 05:19:51 +01:00
add r1,2 // source y
mov r6,r0
2017-03-29 05:19:51 +01:00
bl copy_tile_up
2017-03-18 21:11:19 +00:00
// Set proper tilemap
mov r0,r6 // dest x
2017-03-18 21:11:19 +00:00
mov r1,r4 // dest y
2017-03-29 05:19:51 +01:00
bl get_tile_number
ldr r1,=0x30051EC
2017-04-03 03:12:18 +01:00
ldrh r2,[r1]
2017-03-18 21:11:19 +00:00
add r0,r0,r2 // dest tile number
2017-03-29 05:19:51 +01:00
ldrh r1,[r1,0x3C] // 0xE000
2017-03-18 21:11:19 +00:00
orr r0,r1
2017-04-03 03:12:18 +01:00
strh r0,[r5]
2017-03-29 05:19:51 +01:00
b @@end
2017-03-18 21:11:19 +00:00
// Case 2: blank to non-blank
2017-03-29 05:19:51 +01:00
@@blank_to_nonblank:
2017-03-18 21:11:19 +00:00
// Set dest tilemap to 0xE2FF
2017-04-03 03:12:18 +01:00
strh r0,[r5]
2017-03-18 21:11:19 +00:00
// Case 4: non-blank to non-blank
2017-03-29 05:19:51 +01:00
@@nonblank_to_nonblank:
2017-03-18 21:11:19 +00:00
// Copy pixels up
2017-03-29 05:19:51 +01:00
ldrh r0,[r6,0x22]
lsl r0,r0,16
2017-03-18 21:11:19 +00:00
add r0,r0,r4
2017-03-29 05:19:51 +01:00
lsr r0,r0,16 // x
ldrh r1,[r6,0x24]
2017-03-18 21:11:19 +00:00
add r1,r8 // dest y
2017-03-29 05:19:51 +01:00
add r1,2 // source y
bl copy_tile_up
2017-03-18 21:11:19 +00:00
2017-03-29 05:19:51 +01:00
@@end:
2017-03-18 21:11:19 +00:00
pop {r4-r7,pc}
2017-03-29 05:19:51 +01:00
.pool
2017-03-18 21:39:56 +00:00
//==============================================================================
// Erase tile (for short windows)
// r2: 100
// r4: (x << 16) (relative)
// r5: dest tilemap
// r6: window
// r8: y (dest, relative)
2017-03-29 05:19:51 +01:00
ca4bc_erase_tile_short:
push {r0-r1,lr}
2017-03-18 21:39:56 +00:00
// Clobbered code
orr r0,r1 // 0xE2FF
2017-04-03 03:12:18 +01:00
strh r0,[r5] // dest tilemap
2017-03-18 21:39:56 +00:00
// We need to erase the pixels
2017-03-29 05:19:51 +01:00
ca4bc_erase_tile_common:
ldrh r2,[r6,0x22]
lsl r2,r2,16
2017-03-18 21:39:56 +00:00
add r2,r2,r4
lsr r0,r2,16 // x
2017-03-29 05:19:51 +01:00
ldrh r1,[r6,0x24]
2017-03-18 21:39:56 +00:00
add r1,r8 // y
ldr r2,=0x44444444
bl clear_tile
2017-03-18 21:39:56 +00:00
pop {r0-r1,pc}
2017-03-29 05:19:51 +01:00
.pool
2017-03-18 21:39:56 +00:00
//==============================================================================
// Erase tile
2017-03-29 05:19:51 +01:00
ca4bc_erase_tile:
push {r0-r1,lr}
2017-03-18 21:39:56 +00:00
// Clobbered code
2017-04-03 03:12:18 +01:00
ldrh r1,[r1]
strh r1,[r5]
2017-03-18 21:39:56 +00:00
// We need to erase the pixels
2017-03-29 05:19:51 +01:00
b ca4bc_erase_tile_common
.pool
2017-03-25 21:08:00 +00:00
//==============================================================================
// Clear PSI window when scrolling through classes
2017-03-29 05:19:51 +01:00
e06ec_clear_window:
2017-03-25 21:08:00 +00:00
push {r0-r1,lr}
2017-03-29 05:19:51 +01:00
ldr r0,=0x3002500
2017-04-03 03:12:18 +01:00
ldrh r0,[r0]
2017-03-29 05:19:51 +01:00
cmp r0,0
beq @@next
ldr r0,=0x3005230
ldr r0,[r0,0x1C]
bl clear_window
@@next:
2017-03-25 21:08:00 +00:00
pop {r0-r1}
// Clobbered code
2017-03-29 05:19:51 +01:00
lsl r0,r0,0x10
asr r4,r0,0x10
2017-03-25 21:08:00 +00:00
pop {pc}
2017-03-29 05:19:51 +01:00
.pool
2017-03-25 22:29:13 +00:00
//==============================================================================
// Redraw PSI command when exiting PSI subwindow
2017-03-29 05:19:51 +01:00
e06ec_redraw_psi:
2017-03-25 22:29:13 +00:00
push {r0-r3,lr}
// Clear old tiles
2017-03-29 05:19:51 +01:00
mov r0,2
mov r1,3
mov r2,1
bl print_blankstr
2017-03-25 22:29:13 +00:00
// Render PSI string
2017-03-29 05:19:51 +01:00
add sp,-4
ldr r0,=0x80DC1EC // address of PSI string pointer
2017-04-03 03:12:18 +01:00
ldr r1,[r0] // PSI string pointer
2017-03-29 05:19:51 +01:00
ldr r0,=0x3005230
2017-04-03 03:12:18 +01:00
ldr r0,[r0] // window pointer
2017-03-29 05:19:51 +01:00
mov r2,1 // highlight
2017-04-03 03:12:18 +01:00
str r2,[sp]
2017-03-29 05:19:51 +01:00
mov r2,1
mov r3,1
bl 0x80C96F0 // render string
add sp,4
2017-03-25 22:29:13 +00:00
// Clobbered code
pop {r0-r3}
2017-03-29 05:19:51 +01:00
bl 0x80BD7F8 // restore tilemaps
2017-03-25 22:29:13 +00:00
pop {pc}
2017-03-29 05:19:51 +01:00
.pool
2017-03-25 22:29:13 +00:00
//==============================================================================
// Redraw Bash/Do Nothing and PSI commands when exiting PSI ally target subwindow
2017-03-29 05:19:51 +01:00
e06ec_redraw_bash_psi:
2017-03-25 22:29:13 +00:00
push {r0-r3,lr}
2017-03-29 05:19:51 +01:00
add sp,-4
2017-03-25 22:29:13 +00:00
// Clear old tiles
2017-03-29 05:19:51 +01:00
mov r0,2
mov r1,1
mov r2,1
bl print_blankstr
mov r0,2
mov r1,3
mov r2,1
2017-03-29 05:19:51 +01:00
bl print_blankstr
2017-03-25 22:29:13 +00:00
// We need to figure out whether to draw Bash or Do Nothing
// If [0x2025122] == 2, draw Do Nothing; else, draw Bash
// We'll never draw Shoot because Jeff doesn't use PSI
2017-03-29 05:19:51 +01:00
ldr r0,=0x2025122
2017-04-03 03:12:18 +01:00
ldrh r0,[r0]
2017-03-29 05:19:51 +01:00
cmp r0,2
beq @@donothing
ldr r0,=0x80DBFB0
b @@next
@@donothing:
ldr r0,=0x80DC108
@@next:
2017-04-03 03:12:18 +01:00
ldr r1,[r0]
2017-03-29 05:19:51 +01:00
ldr r0,=0x3005230
2017-04-03 03:12:18 +01:00
ldr r0,[r0] // window pointer
2017-03-29 05:19:51 +01:00
mov r2,0 // no highlight
2017-04-03 03:12:18 +01:00
str r2,[sp]
2017-03-29 05:19:51 +01:00
mov r2,1
mov r3,0
bl 0x80C96F0 // render string
2017-03-25 22:29:13 +00:00
// Render PSI string
2017-03-29 05:19:51 +01:00
ldr r0,=0x80DC1EC // address of PSI string pointer
2017-04-03 03:12:18 +01:00
ldr r1,[r0] // PSI string pointer
2017-03-29 05:19:51 +01:00
ldr r0,=0x3005230
2017-04-03 03:12:18 +01:00
ldr r0,[r0] // window pointer
2017-03-29 05:19:51 +01:00
mov r2,1 // highlight
2017-04-03 03:12:18 +01:00
str r2,[sp]
2017-03-29 05:19:51 +01:00
mov r2,1
mov r3,1
bl 0x80C96F0 // render string
add sp,4
2017-03-25 22:29:13 +00:00
// Clobbered code
pop {r0-r3}
2017-03-29 05:19:51 +01:00
bl 0x80BD7F8 // restore tilemaps
2017-03-25 22:29:13 +00:00
pop {pc}
2017-03-29 05:19:51 +01:00
.pool
2017-03-26 00:15:00 +00:00
//==============================================================================
// Print "PSI "
2017-03-29 05:19:51 +01:00
c239c_print_psi:
2017-03-26 00:15:00 +00:00
push {lr}
2017-03-29 05:19:51 +01:00
add sp,-4
mov r2,0
2017-04-03 03:12:18 +01:00
str r2,[sp]
2017-03-26 00:15:00 +00:00
mov r2,r4
2017-03-29 05:19:51 +01:00
lsl r3,r3,3 // tiles-to-pixels
bl print_string_hlight_pixels
add sp,4
2017-03-26 00:15:00 +00:00
pop {pc}
2017-03-26 20:16:09 +01:00
//==============================================================================
// Use new pointer for user/target strings
2017-03-29 05:19:51 +01:00
ebfd4_user_pointer:
2017-03-26 20:16:09 +01:00
push {lr}
2017-03-29 05:19:51 +01:00
mov r4,0x4C
lsl r4,r4,4
2017-03-26 20:16:09 +01:00
add r0,r0,r4
mov r5,r0
2017-03-29 05:19:51 +01:00
lsl r4,r1,0x10
asr r4,r4,0x10
2017-03-26 20:16:09 +01:00
mov r1,r2
mov r2,r4
2017-03-29 05:19:51 +01:00
bl 0x80F4C78
2017-03-26 20:16:09 +01:00
add r0,r4,r5
2017-03-29 05:19:51 +01:00
mov r1,0
2017-04-03 03:12:18 +01:00
strb r1,[r0]
2017-03-29 05:19:51 +01:00
mov r1,0xFF
strb r1,[r0,1]
2017-03-26 20:16:09 +01:00
pop {pc}
2017-03-29 05:19:51 +01:00
ec004_user_pointer:
2017-03-26 20:16:09 +01:00
push {r1}
2017-03-29 05:19:51 +01:00
ldr r1,[sp,4]
2017-03-26 20:16:09 +01:00
mov lr,r1
pop {r1}
2017-03-29 05:19:51 +01:00
add sp,4
ldr r0,=0x3005220
2017-04-03 03:12:18 +01:00
ldr r0,[r0]
2017-03-29 05:19:51 +01:00
mov r1,0x4C
lsl r1,r1,4
2017-03-26 20:16:09 +01:00
add r0,r0,r1
bx lr
2017-03-29 05:19:51 +01:00
ec010_target_pointer:
2017-03-26 20:16:09 +01:00
push {lr}
2017-03-29 05:19:51 +01:00
mov r4,0x50
lsl r4,r4,4
2017-03-26 20:16:09 +01:00
add r0,r0,r4
mov r5,r0
2017-03-29 05:19:51 +01:00
lsl r4,r1,0x10
asr r4,r4,0x10
2017-03-26 20:16:09 +01:00
mov r1,r2
mov r2,r4
2017-03-29 05:19:51 +01:00
bl 0x80F4C78
2017-03-26 20:16:09 +01:00
add r0,r4,r5
2017-03-29 05:19:51 +01:00
mov r1,0
2017-04-03 03:12:18 +01:00
strb r1,[r0]
2017-03-29 05:19:51 +01:00
mov r1,0xFF
strb r1,[r0,1]
2017-03-26 20:16:09 +01:00
pop {pc}
2017-03-29 05:19:51 +01:00
ec046_target_pointer:
2017-03-26 20:16:09 +01:00
push {r1}
2017-03-29 05:19:51 +01:00
ldr r1,[sp,4]
2017-03-26 20:16:09 +01:00
mov lr,r1
pop {r1}
2017-03-29 05:19:51 +01:00
add sp,4
2017-04-03 03:12:18 +01:00
ldr r0,[r0]
2017-03-29 05:19:51 +01:00
mov r1,0x50
lsl r1,r1,4
2017-03-26 20:16:09 +01:00
add r0,r0,r1
bx lr
2017-03-29 05:19:51 +01:00
c980c_user_pointer:
2017-04-03 03:12:18 +01:00
ldr r1,[r0]
2017-03-29 05:19:51 +01:00
mov r0,0x4C
lsl r0,r0,4
2017-03-26 20:16:09 +01:00
add r1,r0,r1
2017-03-29 05:19:51 +01:00
ldr r0,[r5,0x1C]
2017-03-26 20:16:09 +01:00
bx lr
2017-03-29 05:19:51 +01:00
c980c_target_pointer:
2017-04-03 03:12:18 +01:00
ldr r0,[r0]
2017-03-29 05:19:51 +01:00
mov r7,0x50
lsl r7,r7,4
2017-03-26 20:16:09 +01:00
add r0,r0,r7
bx lr
2017-03-29 05:19:51 +01:00
.pool
//==============================================================================
// Add a space between enemy name and letter in multi-enemy fights
2017-03-29 05:19:51 +01:00
dcd00_enemy_letter:
sub r0,0x90
strb r0,[r5,1]
mov r0,0x50
2017-04-03 03:12:18 +01:00
strb r0,[r5]
bx lr
2017-03-27 05:19:17 +01:00
2017-03-29 05:19:51 +01:00
dae00_enemy_letter:
sub r0,0x90
strb r0,[r4,1]
mov r0,0x50
2017-04-03 03:12:18 +01:00
strb r0,[r4]
2017-03-27 05:48:23 +01:00
bx lr
2017-03-27 05:19:17 +01:00
//==============================================================================
// "The" flag checks
2017-03-29 05:19:51 +01:00
db04c_theflag:
2017-03-27 05:19:17 +01:00
push {r4,lr}
// Clobbered code: get enemy string pointer
2017-03-29 05:19:51 +01:00
lsl r4,r2,1
bl 0x80BE260
2017-03-27 05:19:17 +01:00
mov r1,r0
mov r0,sp
2017-03-29 05:19:51 +01:00
add r0,8
2017-03-27 05:19:17 +01:00
// Check for "The" flag
2017-03-29 05:19:51 +01:00
ldr r3,=m2_enemy_attributes
2017-03-27 05:19:17 +01:00
ldrb r3,[r3,r4] // "The" flag
2017-03-29 05:19:51 +01:00
cmp r3,0
beq @@next
2017-03-27 05:19:17 +01:00
// Write "The " before the enemy name
2017-03-29 05:19:51 +01:00
ldr r2,=0x50959884
2017-04-03 03:12:18 +01:00
str r2,[r0]
2017-03-29 05:19:51 +01:00
add r0,4
2017-03-27 05:19:17 +01:00
2017-03-29 05:19:51 +01:00
@@next:
2017-03-27 05:19:17 +01:00
pop {r4,pc}
2017-03-29 05:19:51 +01:00
.pool
2017-04-15 17:50:32 +01:00
//==============================================================================
bf858_name_header:
push {lr}
mov r2,0
ldr r0,=m2_widths_tiny
sub r4,r1,1
@@bf858_name_header_loop:
ldrb r1,[r4,1]
cmp r1,0xFF
beq @@bf858_name_header_next
ldrb r1,[r4]
lsl r1,r1,2
ldrb r1,[r0]
add r2,r1,r2
add r4,1
b @@bf858_name_header_loop
@@bf858_name_header_next:
add r2,7
lsr r2,r2,3 // total number of tiles to use
@@bf858_name_header_print_loop:
cmp r2,0
beq @@bf858_name_header_end
strh r5,[r6]
add r5,1
add r6,2
sub r2,1
b @@bf858_name_header_print_loop
@@bf858_name_header_end:
pop {pc}