Created
December 25, 2022 23:53
-
-
Save Prof9/40c6af6c9563c4e5edf3d5794c6fa31c to your computer and use it in GitHub Desktop.
MMBN4 (Blue Moon US) - Display Emotion Value during battle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
C0F2= | |
C1F2=! | |
C2F2=" | |
C3F2=# | |
C4F2=$ | |
C5F2=% | |
C6F2=& | |
C7F2=' | |
C8F2=( | |
C9F2=) | |
CAF2=* | |
CBF2=+ | |
CCF2=, | |
CDF2=- | |
CEF2=. | |
CFF2=/ | |
D0F2=0 | |
D1F2=1 | |
D2F2=2 | |
D3F2=3 | |
D4F2=4 | |
D5F2=5 | |
D6F2=6 | |
D7F2=7 | |
D8F2=8 | |
D9F2=9 | |
DAF2=: | |
DBF2=; | |
DCF2=< | |
DDF2== | |
DEF2=> | |
DFF2=? | |
E0F2=@ | |
E1F2=A | |
E2F2=B | |
E3F2=C | |
E4F2=D | |
E5F2=E | |
E6F2=F | |
E7F2=G | |
E8F2=H | |
E9F2=I | |
EAF2=J | |
EBF2=K | |
ECF2=L | |
EDF2=M | |
EEF2=N | |
EFF2=O | |
F0F2=P | |
F1F2=Q | |
F2F2=R | |
F3F2=S | |
F4F2=T | |
F5F2=U | |
F6F2=V | |
F7F2=W | |
F8F2=X | |
F9F2=Y | |
FAF2=Z |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.definelabel TRUE, 0x1 | |
.definelabel FALSE, 0x0 | |
.gba | |
.open ROM_IN,ROM_OUT,0x8000000 | |
.org 0x8006132 // Disable ASLR | |
mov r0,0x0 | |
.org 0x8014DD0 // Hook function that draws player HP | |
ldr r0,=drawEmotionValue|1 | |
mov r14,r15 | |
bx r0 | |
b @@end | |
.pool | |
@@end: | |
.org 0x87F739C | |
fspace: | |
drawEmotionValue: | |
// Free registers: r0, r1, r2, r3, r4, r5, r7 | |
push r14 | |
// Clear existing data | |
ldr r1,[sp,0x4] // originally sp+0x0 | |
ldrb r0,[r1,0x7] // screen x | |
cmp r0,0x0 // only draw if screen not scrolled | |
bne @@end | |
// Render base tilemap to VRAM | |
ldrb r1,[r1,0x8] // screen y | |
// add r0,(0) // x | |
add r1,(5) // y | |
mov r2,(3) // BG3 | |
add r3,=@@baseMap // tilemap | |
mov r4,@@baseMap_length // width | |
mov r5,(1) // height | |
ldr r7,=0x8001DFC|1 | |
mov r14,r15 | |
bx r7 | |
// Get player side | |
mov r0,r10 | |
ldr r0,[r0,0x18] | |
ldr r0,[r0,0x44] // player object | |
ldrb r0,[r0,0x16] // player side | |
// Get data region for player side | |
ldr r1,=0x800D742|1 | |
mov r14,r15 | |
bx r1 | |
// Get player emotion value | |
ldrb r0,[r0] // emotion value | |
// Convert to BCD | |
ldr r1,=0x8000A38|1 | |
mov r14,r15 | |
bx r1 // r0 = BCD emotion value | |
// Allocate buffer (size 0x8) | |
mov r1,0x0 | |
push r1 | |
push r1 | |
@@DIGIT_COUNT equ 3 | |
// Draw digits | |
// r0 = BCD emotion value | |
// r4 = buffer ptr | |
// r5 = digit idx | |
// r7 = drew digit | |
mov r4,sp | |
mov r5,(0) // digit idx | |
mov r7,FALSE // drew digit | |
@@loop: | |
mov r1,(8 - @@DIGIT_COUNT) | |
add r1,r1,r5 | |
lsl r1,r1,0x2 // ((8 - N) + i) x 4 | |
mov r2,r0 // BCD | |
lsl r2,r1 | |
lsr r2,r2,0x1C // get single digit | |
bne @@draw // if nonzero, draw digit | |
cmp r7,FALSE // check drew digit | |
bne @@draw // if already drew digit, draw zero now | |
cmp r5,(@@DIGIT_COUNT-1) | |
bne @@next | |
@@draw: | |
ldr r1,[@@zeroMap] | |
add r1,r1,r2 | |
strh r1,[r4] | |
mov r7,TRUE // set drew digit | |
@@next: | |
add r4,0x2 | |
add r5,(1) // digit idx | |
cmp r5,(@@DIGIT_COUNT) | |
blo @@loop | |
// Render digits tilemap to VRAM | |
ldr r1,[sp,0x4+0x8] // originally sp+0x0 | |
ldrb r0,[r1,0x7] // screen x | |
ldrb r1,[r1,0x8] // screen y | |
add r0,@@baseMap_length // x | |
add r1,(5) // y | |
mov r2,(3) // BG3 | |
mov r3,sp // tilemap | |
mov r4,(@@DIGIT_COUNT+1) // width (+1 to render space after) | |
mov r5,(1) // height | |
ldr r7,=0x8001DFC|1 | |
mov r14,r15 | |
bx r7 | |
// Deallocate buffer | |
add sp,0x8 | |
@@end: | |
// Original instructions | |
ldr r5,[sp,0x4] // was sp+0x0 | |
ldrb r0,[r5,0x7] | |
add r0,0x1 | |
ldrb r1,[r5,0x8] | |
mov r2,0x3 | |
mov r3,r6 | |
pop r15 | |
.pool | |
@@baseMap: | |
.string "EV:" | |
.definelabel @@baseMap_length, ((. - @@baseMap) / 2) | |
.align 4 | |
@@zeroMap: | |
.loadtable "debugfont.tbl" | |
.string "0" | |
.align 4 | |
.close |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment