Cleaning things out

This commit is contained in:
jeffman 2017-03-07 17:12:52 -05:00
parent 7f9ff41c77
commit 742f053a3f
8 changed files with 61 additions and 3233 deletions

View File

@ -21,7 +21,7 @@ mov r4,r0
// Get the window number // Get the window number
mov r0,r2 mov r0,r2
bl m2_vwf.get_window_number //bl m2_vwf.get_window_number
//-------------------------------- //--------------------------------
// 60 FF XX: Add XX pixels to the renderer // 60 FF XX: Add XX pixels to the renderer
@ -74,107 +74,3 @@ b .store_x
.parse_end: .parse_end:
mov r0,r6 mov r0,r6
pop {r1-r6,pc} pop {r1-r6,pc}
//==============================================================================
// void check_main(byte code, char* parserAddress, WINDOW* window)
// In:
// r0: code
// r7: parser address
// r5: window
//==============================================================================
.check_main:
push {r1-r3,lr}
//--------------------------------
mov r1,r7
mov r2,r5
bl .parse
cmp r0,#0
bne +
mov r0,#2
+
//--------------------------------
// Clobbered code
ldr r3,[r6,#0]
add r3,r3,r0
mov r0,r3
//--------------------------------
pop {r1-r3,pc}
//==============================================================================
// void check_status(char* parserAddress, WINDOW* window)
// In:
// r2: parser address
// r4: window
//==============================================================================
.check_status:
push {lr}
ldrb r0,[r2,#0]
cmp r0,#1
bne +
pop {r0}
mov lr,r0
ldr r0,=#0x80C90A9
bx r0
+
//--------------------------------
push {r0-r2}
mov r1,r2
mov r2,r4
bl .parse
mov r7,r0
cmp r0,#0
pop {r0-r2}
bne +
// It wasn't one of our codes, so let the game continue checking
pop {r7}
mov lr,r7
ldr r7,=#0x80C90CD
bx r7
+
//--------------------------------
mov r0,r12
add r0,r0,r7
str r0,[r4,#0x14]
pop {r7}
mov lr,r7
ldr r7,=#0x80C904D
bx r7
//==============================================================================
// void check_selection_menu(char* parserAddress, WINDOW* window)
// In:
// r3: parser address
// r4: window
//==============================================================================
.check_selection_menu:
push {r0-r2,lr}
//--------------------------------
ldrb r0,[r3,#0]
mov r1,r3
mov r2,r4
bl .parse
cmp r0,#0
bne +
mov r0,#2
+
add r3,r3,r0
//--------------------------------
pop {r0-r2,pc}

View File

@ -273,126 +273,3 @@ strb r1,[r4,#2]
sub r5,r6,r7 sub r5,r6,r7
sub r0,r5,#1 sub r0,r5,#1
pop {r1-r7,pc} pop {r1-r7,pc}
//==============================================================================
// void status1(int x, int y, char* str)
// In:
// r2: x (pixel)
// r3: y (pixel)
// r1: str
//==============================================================================
.status1:
print "m2formatting.status1: $",pc
push {r0-r2,lr}
mov r0,r2
mov r2,r1
mov r1,r3
bl m2_vwf.print_string
pop {r0-r2,pc}
//==============================================================================
// void status_clear(WINDOW* window)
// In:
// r10: window address
//==============================================================================
.status_clear:
print "m2formatting.status_clear: $",pc
push {r0-r4,lr}
ldr r4,=#.status_clear_areas
//--------------------------------
.status_clear_loop:
ldrb r0,[r4,#0] // Top-left X
cmp r0,#0xFF
beq +
ldrb r1,[r4,#1] // Top-left Y
ldrb r2,[r4,#2] // Bottom-right X
ldrb r3,[r4,#3] // Bottom-right Y
//--------------------------------
-
bl m2_vwf.erase_tile
add r0,r0,#1
cmp r0,r2
bls -
ldrb r0,[r4,#0]
add r1,r1,#1
cmp r1,r3
bls -
add r4,r4,#4
b .status_clear_loop
//--------------------------------
+
pop {r0-r4,pc}
//--------------------------------
.status_clear_areas:
db $05,$01,$06,$02 // Level
db $0C,$07,$0E,$0A // Current HP and PP
db $10,$07,$12,$0A // Max HP and PP
db $0C,$0B,$12,$0C // Exp
db $01,$0D,$07,$0E // Exp to next level
db $01,$0F,$1C,$10 // PSI info
db $19,$01,$1C,$0E // Stats
db $FF,$FF
//==============================================================================
// void status_redraw()
// In:
// r5: #0x3005230
//==============================================================================
.status_redraw:
push {r0-r7,lr}
//--------------------------------
// Call the clobbered code to redraw the old (broken) window,
// since we still need the borders
bl $80BD7AC
//--------------------------------
// Clear the text area
ldr r0,[r5,#0x18] // Get the status window address
mov r4,r0
bl m2_vwf.clear_window
// Clear the map
bl m2_vwf.clear_tilemap
//--------------------------------
// (Copying the code at $80B8308)
// Get the address of the status text
ldr r0,=#0x8B17EE4
ldr r1,=#0x8B17424
mov r2,#0x11
bl $80BE260
// Prepare the window for parsing
mov r1,r0
mov r0,r4
mov r2,#0
bl $80BE458
// I think this renders it
mov r0,r4
bl $80C8FFC
//--------------------------------
// Draw the numbers
mov r0,r4
mov r1,#0
bl $80C0A5C
//--------------------------------
// Set all dirty flags
bl m2_vwf.set_all_dirty_flags
pop {r0-r7,pc}

View File

@ -1,524 +0,0 @@
m2_goods:
//==============================================================================
// void entry(char* chr, TILEDATA* tileData)
// In:
// r3: chr
// r6: tileData
//==============================================================================
.entry:
print "m2goods.entry: $",pc
push {lr}
//--------------------------------
// Check if the item is equipped
push {r1-r3}
mov r0,r8
add r0,r0,#1
bl $80BC670
pop {r1-r3}
cmp r0,#0
beq +
// Write the equip symbol
push {r2}
mov r0,r10
ldrh r0,[r0,#0] // tile offset (0x100)
ldr r1,=#0x8B1B6AC // equip tile number (0x1DE)
ldrh r1,[r1,#0]
add r0,r0,r1
mov r1,r9
ldrh r2,[r1,#0] // mask (0xE000)
mov r1,r2
orr r1,r0
strh r1,[r6,#0]
mov r1,r6
add r1,#0x40
add r0,#0x20
orr r0,r2
strh r0,[r1,#0]
add r6,r6,#2
lsl r0,r4,#0x10
ldr r4,=#0xFFFF0000
add r0,r0,r4
lsr r4,r0,#0x10
pop {r2}
+
//--------------------------------
// Check if the dirty flag is set
mov r0,r7
bl m2_vwf.get_dirty_flag
cmp r0,#1
bne +
// Just get the string width instead (don't need to render)
mov r0,r3
mov r1,#0
bl m2_vwf.string_width
add r3,r3,r1
b .entry_skip
+
//--------------------------------
// Get x and y from tilebase
mov r0,r6
bl m2_vwf.get_coords
//--------------------------------
// Print string
push {r6,r7}
mov r6,#0
mov r5,r3
mov r3,#0
-
ldrb r2,[r5,#1]
cmp r2,#0xFF
beq +
ldrb r2,[r5,#0]
sub r2,#0x50
mov r7,r0
bl m2_vwf.print_character
add r6,r0,r6
add r0,r0,r7
add r5,r5,#1
b -
+
mov r3,r5
mov r0,r6
pop {r6,r7}
//--------------------------------
.entry_skip:
// Advance r4 and r6
sub r1,r0,#1
asr r0,r0,#3
add r1,r0,#1
ldr r2,=#0xFFFF0000
-
cmp r1,#0
beq +
lsl r0,r4,#0x10
add r0,r0,r2
lsr r4,r0,#0x10
add r6,r6,#2
sub r1,r1,#1
b -
+
pop {pc}
//==============================================================================
// void entry2(char* chr, TILEDATA* tileData)
// In:
// r3: chr
// r6: tileData
//==============================================================================
.entry2:
print "m2goods.entry2: $",pc
push {r5,lr}
//--------------------------------
// Check if the item is equipped
push {r1-r3}
mov r0,r8
add r0,r0,#1
bl $80BC670
pop {r1-r3}
cmp r0,#0
beq +
// Write the equip symbol
push {r2}
ldr r0,=#0x30051EC
ldrh r0,[r0,#0] // tile offset (0x100)
ldr r1,=#0x8B1B6AC // equip tile number (0x1DE)
ldrh r1,[r1,#0]
add r0,r0,r1
mov r1,r9
ldrh r2,[r1,#0] // mask (0xE000)
mov r1,r2
orr r1,r0
strh r1,[r6,#0]
mov r1,r6
add r1,#0x40
add r0,#0x20
orr r0,r2
strh r0,[r1,#0]
add r6,r6,#2
pop {r2}
+
//--------------------------------
// Check if the dirty flag is set
mov r0,r7
bl m2_vwf.get_dirty_flag
cmp r0,#1
bne +
// Just get the string width instead (don't need to render)
mov r0,r3
mov r1,#0
bl m2_vwf.string_width
add r3,r3,r1
b .entry2_skip
+
//--------------------------------
// Get x and y from tilebase
mov r0,r6
bl m2_vwf.get_coords
//--------------------------------
// Print string
push {r6,r7}
mov r6,#0
mov r5,r3
mov r3,#0
-
ldrb r2,[r5,#1]
cmp r2,#0xFF
beq +
ldrb r2,[r5,#0]
sub r2,#0x50
mov r7,r0
bl m2_vwf.print_character
add r6,r0,r6
add r0,r0,r7
add r5,r5,#1
b -
+
mov r3,r5
mov r0,r6
pop {r6,r7}
//--------------------------------
.entry2_skip:
// Advance r6
sub r1,r0,#1
asr r0,r0,#3
add r1,r0,#1
-
cmp r1,#0
beq +
add r6,r6,#2
sub r1,r1,#1
b -
+
pop {r5,pc}
//==============================================================================
// void highlight(WINDOW* window, char* chr, int itemIndex)
// In:
// r0: window
// r1: chr
// r9: itemIndex (based at 0)
// Out:
// r2: new tile X
//==============================================================================
.highlight:
print "m2goods.highlight: $",pc
// Clobbered code
str r1,[sp,#0]
//--------------------------------
push {r0,r4,lr}
mov r4,r0
mov r0,r9
add r0,#1
push {r1-r3}
bl $80BC670
pop {r1-r3}
cmp r0,#0
beq +
// Advance the X coord by 1 tile
add r2,#1
+
mov r0,r4
//--------------------------------
// Clobbered code
mov r1,r6
pop {r0,r4,pc}
//==============================================================================
// void clean()
//==============================================================================
.clean:
print "m2goods.clean: $",pc
push {lr}
mov r0,r7
mov r1,#1
bl m2_vwf.set_dirty_flag
ldr r0,=#0x3002504 // Clobbered code
ldrh r1,[r0,#0]
pop {pc}
//==============================================================================
// void dirty1()
//==============================================================================
.dirty1:
print "m2goods.dirty1: $",pc
push {r1,lr}
// Set the dirty flag
mov r0,r7
mov r1,#0
bl m2_vwf.set_dirty_flag
// Clear the window
mov r0,r7
bl m2_vwf.clear_window
// Clobbered code
ldrh r0,[r4,#0]
sub r0,#0x1
pop {r1,pc}
//==============================================================================
// void dirty2()
//==============================================================================
.dirty2:
print "m2goods.dirty2: $",pc
push {r0,lr}
// Set the dirty flag
mov r0,r7
mov r1,#0
bl m2_vwf.set_dirty_flag
// Clear the window
mov r0,r7
bl m2_vwf.clear_window
// Clobbered code
pop {r0}
add r0,#0x1
mov r1,r9
pop {pc}
//==============================================================================
// void dirty3()
//==============================================================================
.dirty3:
print "m2goods.dirty3: $",pc
push {r2-r3,lr}
mov r2,r0
mov r3,r1
// Set the dirty flag
ldr r0,=#0x3005240
ldr r0,[r0,#0]
mov r2,r1
mov r1,#0
bl m2_vwf.set_dirty_flag
mov r0,r2
mov r1,r3
// Clobbered code
ldrb r0,[r0,#0]
strh r0,[r1,#0]
pop {r2-r3,pc}
//==============================================================================
// void dirty4()
//==============================================================================
.dirty4:
print "m2goods.dirty4: $",pc
push {r1,lr}
// Set the dirty flag
mov r0,r7
mov r1,#0
bl m2_vwf.set_dirty_flag
// Clobbered code
mov r6,#0
mov r8,r6
pop {r1,pc}
//==============================================================================
// void dirty5()
//==============================================================================
.dirty5:
print "m2goods.dirty5: $",pc
push {r0,lr}
// Check the dirty flag
bl m2_vwf.get_dirty_flag
cmp r0,#0
bne +
// It's dirty, so erase the window
pop {r0}
bl $80CA834
pop {pc}
+
pop {r0,pc}
//==============================================================================
// void dirty6()
//==============================================================================
.dirty6:
print "m2goods.dirty6: $",pc
push {r1,lr}
// Set the dirty flag
mov r0,r7
mov r1,#0
bl m2_vwf.set_dirty_flag
// Clobbered code
mov r0,#0
strh r0,[r7,#0x32]
pop {r1,pc}
//==============================================================================
// void redraw()
//==============================================================================
.redraw:
print "m2goods.redraw: $",pc
push {r0-r7,lr}
//--------------------------------
// Set the dirty flag
ldr r0,=#0x3005240
ldr r0,[r0,#0]
ldr r2,=#m2_custom_wram
add r2,#0x14
mov r4,#0
strb r4,[r2,r0]
//--------------------------------
// Clear window
ldr r0,=#0x3005240
ldr r0,[r0,#0]
mov r5,r0
bl m2_vwf.clear_window
//--------------------------------
// Redraw the goods window
ldr r0,=#0x3005264
ldrb r1,[r0,#0] // get character number
mov r0,#0x6C
mul r1,r0
ldr r0,=#0x3001D54
add r1,r0,r1 // inventory pointer
mov r0,r5
mov r5,r1
mov r4,r0
mov r2,#8
strb r2,[r0,#1] // need to set this flag for some reason
bl $80BEB6C
//--------------------------------
// Redraw the highlighted item
// Get the item index from the cursor coords
add r4,#0x34
ldrh r1,[r4,#0] // X
add r6,r1,#0
cmp r1,#0xB
bne +
mov r1,#1
+
ldrh r0,[r4,#2] // Y
mov r7,r0
lsl r0,r0,#1
add r0,r0,r1 // item index
// Check if the item is equipped
push {r0-r3}
add r0,#1
bl $80BC670
cmp r0,#0
pop {r0-r3}
beq +
add r6,#1
+
// Get the item number
lsl r2,r0,#1
ldrh r2,[r5,r2] // item number
// Get the item's text address
ldr r0,=#0x8B1AF94
ldr r1,=#0x8B1A694
bl $80BE260 // r0 = address
// Draw the text
add sp,#-4
mov r1,#1
str r1,[sp,#0]
mov r1,r0
sub r4,#0x34
mov r0,r4
add r2,r6,#1
mov r3,r7
bl $80C9634
add sp,#4
//--------------------------------
// Clobbered code
pop {r0-r7}
bl $80C8BE4
pop {pc}

View File

@ -7,6 +7,7 @@ arch gba.thumb
// Move the weird box font from 0xFCE6C // Move the weird box font from 0xFCE6C
org $80B3274; dd m2_font_relocate org $80B3274; dd m2_font_relocate
//============================================================================== //==============================================================================
// Font hacks // Font hacks
//============================================================================== //==============================================================================
@ -16,144 +17,6 @@ org $8B0F424; incbin m2-mainfont2-empty.bin
org $8B13424; incbin m2-mainfont3-empty.bin org $8B13424; incbin m2-mainfont3-empty.bin
org $8B088A4; incbin m2-shifted-cursor.bin org $8B088A4; incbin m2-shifted-cursor.bin
//==============================================================================
// Control code hacks
//==============================================================================
org $80CA2BC; bl m2_customcodes.check_main
org $80C90A2; bl m2_customcodes.check_status
//==============================================================================
// VWF hacks
//==============================================================================
org $80C96F0; push {lr}; bl m2_vwf.print_string_relative; pop {pc}
// Main entry
org $80CA448; push {lr}; bl m2_vwf.main; b $80CA46C
// Status entry
org $80C9116; push {lr}; bl m2_vwf.status; b $80C9144
// Goods entry
org $80BFB3E; bl m2_goods.entry; b $80BFB78 // unfocused
org $80BF0E2; bl m2_goods.entry2; b $80BF11A // focused
org $80C0162; bl m2_goods.entry2; b $80C0192 // giving item
org $80B999C; bl m2_goods.highlight
// Goods -- skip drawing equip symbols
org $80BFB98; b $80BFBCC
org $80BF134; b $80BF15E
org $80C01B2; b $80C01DC
// Goods -- dirty flags
org $80BF91E; bl m2_goods.dirty1
org $80BF8FC; bl m2_goods.dirty2
org $80B8540; bl m2_goods.dirty3
org $80BFC0E; bl m2_goods.clean
org $80C01F2; bl m2_goods.clean
org $80BF054; bl m2_goods.dirty4
org $80BFF34; bl m2_goods.dirty1
org $80BFF12; bl m2_goods.dirty2
org $80C00D4; bl m2_goods.dirty5
org $80C0260; bl m2_goods.dirty6
// Goods -- redrawing
org $80BA688; bl m2_goods.redraw // pressing B from Give window; redraw old Goods window
org $80B9CF8; bl m2_vwf.main_redraw // selecting the Use option; need to redraw the main menu
// PSI -- dirty flags
org $80B8CD2; bl m2_vwf.psi_menu_clear
org $80B8CEA; bl m2_vwf.psi_menu_draw
org $80B85F0; bl m2_vwf.psi_menu_dirty1
org $80C4048; bl m2_vwf.psi_menu_dirty2
org $80C4080; bl m2_vwf.psi_menu_dirty2
// Menu select entry
org $80B7FC6; bl m2_vwf.print_string_relative
// Selection menu entry
org $80C1CE0
bl m2_customcodes.check_selection_menu
b $80C1D10
bl m2_vwf.selection_menu
b $80C1D0A
org $80C1D18; bne $80C1CE6
// Disable coordinate incrementing
org $80CA48E; nop // X
// Disable menu redrawing
org $80B7E4E; nop; nop // Talk
org $80B81FA; nop; nop // Check
// Save the current tilebase
org $80BDA44; push {lr}; bl m2_vwf.save_tilebase
// Pixel-X resets
org $80BE4E0; bl m2_vwf.x_reset0 // Menu window
org $80BE45E; bl m2_vwf.x_reset3 // Cash window
org $80C9854; bl m2_vwf.x_reset1
org $80C9CBE; bl m2_vwf.x_reset2
org $80C9D5C; bl m2_vwf.x_reset2
org $80CA1FC; bl m2_vwf.x_reset2
org $80CA270; bl m2_vwf.x_reset1
org $80CA30A; bl m2_vwf.x_reset2
org $80CA332; bl m2_vwf.x_reset1
org $80C8F26; bl m2_vwf.x_reset4 // Newline after a menu selection
org $80C888C; bl m2_vwf.x_resetall // Use goods menu
org $80B9B34; bl m2_vwf.x_reset5 // Pressing Help!
// Possible other places: 80BE370, 80BE436,
// Erase a tile
org $80CA560; bl m2_vwf.erase_tile_short // short, one-liner windows
org $80CA8C4; bl m2_vwf.erase_tile_short2
org $80C8F2A; bl m2_vwf.erase_tile_main // main version
// Copy a tile upwards
org $80CA60E; bl m2_vwf.copy_tile
// Re-draw the status screen after exiting the PSI sub-menu
org $80BACFC; bl m2_formatting.status_redraw
org $80BADE6; bl m2_formatting.status_redraw
// PP cost: only print once
org $80B8B56; bl m2_vwf.ppcost_once
org $80B8B98; bl m2_vwf.ppcost_once2
// VWFs for printing character names
org $80D2EF0; ldrb r0,[r6,#0] // allows for 5 letters!
org $80D2F24
mov r1,r6
mov r2,r7
mov r0,r4
bl m2_vwf.weld_entry
b $80D2F52
org $80D2F5A; nop
//==============================================================================
// Formatting hacks
//==============================================================================
// Cash window
org $80B785C; mov r0,#0xC // allocate 3 extra bytes for our positioning code
org $80B8A08; bl m2_formatting.format_cash
org $80B8A24; b $80B8A2E // skip the game's adding the $ and double-zero to the cash window
// Status window
org $80CA78A; mov r0,#0x60 // integer-to-char change
org $80CA7AC; mov r2,#0x69 // integer-to-char change
org $80CA7EC; sub r1,#0xA0 // integer-to-char change
incsrc m2-status-initial.asm
incsrc m2-status-switch.asm
// Make the PSI type window bigger
org $80B7820; mov r1,#4 // X
org $80B7824; mov r3,#6 // width
// Greek letters // Greek letters
org $8B1B907; db $8B // alpha org $8B1B907; db $8B // alpha
org $8B1B90A; db $8C // beta org $8B1B90A; db $8C // beta
@ -161,72 +24,10 @@ org $8B1B90D; db $8D // gamma
org $8B1B910; db $8E // sigma org $8B1B910; db $8E // sigma
org $8B1B913; db $8F // omega org $8B1B913; db $8F // omega
// PSI stuff //==============================================================================
org $80C21E4; bl m2_vwf.print_string_relative // VWF hacks
org $80C21C4; bl m2_vwf.print_string_relative //==============================================================================
org $80C2258; bl m2_vwf.print_string_relative
org $80C2270; bl m2_vwf.print_string_relative
org $80C22AC; bl m2_vwf.print_string_relative
org $80C22C4; bl m2_vwf.print_string_relative
org $80C203E; mov r1,#0x14 // new entry length
org $80C21B4; mov r1,#0x14
org $80C224A; mov r1,#0x14
org $80C229E; mov r1,#0x14
// PSI -- set clean/dirty flags
org $80BAD1A; bl m2_vwf.psi_clear1
org $80BAD28; bl m2_vwf.psi_clean1
org $80BE658; bl m2_vwf.cursor_dirty1
org $80BE764; bl m2_vwf.cursor_dirty1
// PSI help -- set clean/dirty flags
org $80BADCE; bl m2_vwf.psi_help_clear1
org $80BADD4; bl m2_vwf.psi_help_clean1
org $80C476A; bl m2_vwf.psi_help_dirty1
org $80C48B4; bl m2_vwf.psi_help_dirty1
org $80C4644; bl m2_vwf.psi_help_dirty2
org $80C4582; bl m2_vwf.psi_help_dirty2
// PSI target strings
org $80B8B12; mov r0,#0x14
// PSI Rockin
org $80C2192; mov r3,#8 // Y
org $80C219E
mov r2,#0x71
bl m2_formatting.status1
// Make PP cost use correct number values
org $80CA732
add r1,#0x60
// Make PP cost use the correct space value if there's only one digit
org $80CA712
mov r0,#0x50
// Fix PSI target offset calculation
org $80B8B08
mov r1,#100
mul r1,r2
nop
nop
// Enemy name length:
// Start of battle
org $80DB04E; add sp,#-0x20
org $80DB058; mov r2,#0x1D
org $80DB08C; mov r2,#0x19
org $80DB116; mov r1,#0x1D
org $80DB15A; add sp,#0x20
// Bash target
org $80DCD02; add sp,#-0x20
org $80DCD0C; mov r2,#0x1B
org $80DCD64; mov r2,#0x19
org $80DCDA2; mov r1,#0x1D
org $80DCDA8; add sp,#0x20
//============================================================================== //==============================================================================
// Data files // Data files
@ -253,10 +54,6 @@ incbin m2-font-main.bin
m2_font_saturn: m2_font_saturn:
incbin m2-font-saturn.bin incbin m2-font-saturn.bin
// EB font heights
m2_height_table:
db $02, $02, $01, $00 // last byte for alignment
// EB font widths // EB font widths
m2_widths_table: m2_widths_table:
dd m2_widths_main dd m2_widths_main
@ -266,7 +63,8 @@ m2_widths_main:
incbin m2-widths-main.bin incbin m2-widths-main.bin
m2_widths_saturn: m2_widths_saturn:
// tba // tbd
//============================================================================== //==============================================================================
// Misc // Misc
@ -275,6 +73,7 @@ m2_widths_saturn:
org $2027FC0 org $2027FC0
m2_custom_wram: m2_custom_wram:
//============================================================================== //==============================================================================
// Code files // Code files
//============================================================================== //==============================================================================
@ -283,4 +82,3 @@ org $80FCE6C
incsrc m2-vwf.asm incsrc m2-vwf.asm
incsrc m2-formatting.asm incsrc m2-formatting.asm
incsrc m2-customcodes.asm incsrc m2-customcodes.asm
incsrc m2-goods.asm

53
m2-notes.txt Normal file
View File

@ -0,0 +1,53 @@
General notes
=============
Font palette:
- Standard text windows: 0x4 = background, 0xF = foreground
- File select/setup windows: 0x1 = background, 0x9 = foreground
Hard-coded characters:
- 0xFD: bullet (tile 0x1DD)
- 0xFE: equip (tile 0x1DE)
- Null (tile 0x1DF)
- Background (tile 0x1FF)
0x30051EC: tile offset (usually 0x100)
0x3005228: current text palette, << 0xC
0x3005230: addresses of all 11 windows
0x3005270: address of tilemap start in WRAM, can use this to figure out X and Y
LDRB Rx,[Ry,#n]: n has range 0-31
LDRH Rx,[Ry,#n]: n has range 0-62
LDR Rx,[Ry,#n]: n has range 0-124 (0-1020 for SP- and PC-relative)
Subroutines
-----------
Windows
-------
Window structure:
0x00 - 0x03: bitfield
0x00000001: enable
0xFFFFFFFE: ?
0x04 - 0x07: start address of text being displayed
0x08 - 0x0B: same as above?
0x0C - 0x13: unused?
0x14 - 0x1B: ?
0x1C - 0x1F: unused?
0x20 - 0x21: area (width*height)
0x22 - 0x23: text area X
0x24 - 0x25: text area Y
0x26 - 0x27: window width
0x28 - 0x29: window height
0x2A - 0x2B: relative text X
0x2C - 0x2D: relative text Y
0x2E - 0x33: ?
0x34 - 0x35: cursor X
0x36 - 0x37: cursor Y
0x38 - 0x43: unused?
0x44: ?
0x45 - 0x4F: unused?

View File

@ -1,172 +0,0 @@
// Status window: level
org $80C0BB8
mov r3,#6
mul r3,r4
mov r2,#56
sub r2,r2,r3
org $80C0BC6
mov r3,#8
bl m2_formatting.status1
// Status window: max HP
org $80C0C10
mov r5,#6
mul r4,r5
mov r5,#147
sub r4,r5,r4
org $80C0C20
mov r3,#56
bl m2_formatting.status1
// Status window: current HP
org $80C0C6C
mov r5,#6
mul r4,r5
mov r5,#120
sub r4,r5,r4
org $80C0C7C
mov r3,#56
bl m2_formatting.status1
// Status window: max PP
org $80C0CC8
mov r0,#6
mul r4,r0
mov r0,#147
sub r4,r0,r4
org $80C0CD8
mov r3,#72
bl m2_formatting.status1
// Status window: current PP
org $80C0D24
mov r5,#6
mul r4,r5
mov r5,#120
org $80C0D30
sub r2,r5,r4
mov r3,#72
bl m2_formatting.status1
// Status window: total exp
org $80C0D82
mov r1,#6
mul r4,r1
mov r1,#147
sub r4,r1,r4
org $80C0D92
mov r3,#88
bl m2_formatting.status1
// Status window: exp to next level
org $80C0E02
mov r3,#6
mul r4,r3
mov r3,#61
sub r4,r3,r4
org $80C0E12
mov r3,#104
bl m2_formatting.status1
// Status window: offense
org $80C0E90
mov r6,#6
mul r4,r6
mov r6,#225
sub r4,r6,r4
org $80C0EA0
mov r3,#8
bl m2_formatting.status1
// Status window: defense
org $80C0EEA
mov r2,#6
mul r4,r2
sub r4,r6,r4
org $80C0EF8
mov r3,#24
bl m2_formatting.status1
// Status window: speed
org $80C0F42
mov r2,#6
mul r4,r2
sub r4,r6,r4
org $80C0F50
mov r3,#40
bl m2_formatting.status1
// Status window: guts
org $80C0F9A
mov r2,#6
mul r4,r2
sub r4,r6,r4
org $80C0FA8
mov r3,#56
bl m2_formatting.status1
// Status window: vitality
org $80C0FF2
mov r2,#6
mul r4,r2
sub r4,r6,r4
org $80C1000
mov r3,#72
bl m2_formatting.status1
// Status window: IQ
org $80C104A
mov r2,#6
mul r4,r2
sub r4,r6,r4
org $80C1058
mov r3,#88
bl m2_formatting.status1
// Status window: Luck
org $80C10A2
mov r2,#6
mul r4,r2
sub r6,r6,r4
org $80C10B0
mov r3,#104
bl m2_formatting.status1
// Status window: Press A for PSI info
org $80C10F2
mov r2,#44
mov r3,#120
bl m2_formatting.status1
org $80C0BB4; bl m2_formatting.status_clear
org $80C0C0C; nop; nop // spaces
org $80C0C68; nop; nop // spaces
org $80C0CC4; nop; nop // spaces
org $80C0D20; nop; nop // spaces
org $80C0D7E; nop; nop // spaces
org $80C0DFE; nop; nop // spaces
org $80C06F0; nop; nop // ?
org $80C0E8C; nop; nop // spaces
org $80C0EE6; nop; nop // spaces
org $80C0F3E; nop; nop // spaces
org $80C0F96; nop; nop // spaces
org $80C0FEE; nop; nop // spaces
org $80C1046; nop; nop // spaces
org $80C109E; nop; nop // spaces
org $80C1112; nop; nop
org $80C11AC; nop; nop
org $80C11D2; nop; nop

View File

@ -1,170 +0,0 @@
// Status window: level
org $80C139C
mov r3,#6
mul r3,r4
mov r2,#56
sub r2,r2,r3
org $80C13AA
mov r3,#8
bl m2_formatting.status1
// Status window: max HP
org $80C13F6
mov r5,#6
mul r4,r5
mov r5,#147
sub r4,r5,r4
org $80C1406
mov r3,#56
bl m2_formatting.status1
// Status window: current HP
org $80C1452
mov r5,#6
mul r4,r5
mov r5,#120
sub r4,r5,r4
org $80C1462
mov r3,#56
bl m2_formatting.status1
// Status window: max PP
org $80C14AE
mov r0,#6
mul r4,r0
mov r0,#147
sub r4,r0,r4
org $80C14BE
mov r3,#72
bl m2_formatting.status1
// Status window: current PP
org $80C150A
mov r3,#6
mul r4,r3
mov r3,#120
org $80C1516
sub r2,r3,r4
mov r3,#72
bl m2_formatting.status1
// Status window: total exp
org $80C156A
mov r1,#6
mul r4,r1
mov r1,#147
sub r4,r1,r4
org $80C157A
mov r3,#88
bl m2_formatting.status1
// Status window: exp to next level
org $80C15EC
mov r0,#6
mul r4,r0
mov r0,#61
sub r4,r0,r4
org $80C15FC
mov r3,#104
bl m2_formatting.status1
// Status window: offense
org $80C167C
mov r6,#6
mul r4,r6
mov r6,#225
sub r4,r6,r4
org $80C168C
mov r3,#8
bl m2_formatting.status1
// Status window: defense
org $80C16D6
mov r2,#6
mul r4,r2
sub r4,r6,r4
org $80C16E4
mov r3,#24
bl m2_formatting.status1
// Status window: speed
org $80C172E
mov r2,#6
mul r4,r2
sub r4,r6,r4
org $80C173C
mov r3,#40
bl m2_formatting.status1
// Status window: guts
org $80C1786
mov r2,#6
mul r4,r2
sub r4,r6,r4
org $80C1794
mov r3,#56
bl m2_formatting.status1
// Status window: vitality
org $80C17DE
mov r2,#6
mul r4,r2
sub r4,r6,r4
org $80C17EC
mov r3,#72
bl m2_formatting.status1
// Status window: IQ
org $80C1836
mov r2,#6
mul r4,r2
sub r4,r6,r4
org $80C1844
mov r3,#88
bl m2_formatting.status1
// Status window: Luck
org $80C188E
mov r2,#6
mul r4,r2
sub r6,r6,r4
org $80C189C
mov r3,#104
bl m2_formatting.status1
// Status window: Press A for PSI info
org $80C18DA
mov r2,#44
mov r3,#120
bl m2_formatting.status1
org $80C1398; bl m2_formatting.status_clear
org $80C13F2; nop; nop // spaces
org $80C144E; nop; nop // spaces
org $80C14AA; nop; nop // spaces
org $80C1506; nop; nop // spaces
org $80C1566; nop; nop // spaces
org $80C15E8; nop; nop // spaces
org $80C162A; nop; nop // ?
org $80C1678; nop; nop // spaces
org $80C16D2; nop; nop // spaces
org $80C172A; nop; nop // spaces
org $80C17DA; nop; nop // spaces
org $80C1832; nop; nop // spaces
org $80C188A; nop; nop // spaces
org $80C1782; nop; nop
org $80C11AC; nop; nop
org $80C11D2; nop; nop

1930
m2-vwf.asm

File diff suppressed because it is too large Load Diff