Reorganize math-related HRAM union (ffb3)

This commit is contained in:
Rangi 2018-08-25 21:49:26 -04:00
parent 919ed1d4f5
commit b2adcd6d6f
6 changed files with 180 additions and 184 deletions

View File

@ -259,7 +259,7 @@ GetTreeScore:
ld b, 2 ld b, 2
call Divide call Divide
ldh a, [hQuotient + 3] ldh a, [hRemainder]
ret ret
.OTIDScore: .OTIDScore:
@ -271,5 +271,5 @@ GetTreeScore:
ldh [hDivisor], a ldh [hDivisor], a
ld b, 2 ld b, 2
call Divide call Divide
ldh a, [hQuotient + 3] ldh a, [hRemainder]
ret ret

View File

@ -239,10 +239,10 @@ Function104a95:
cp $6c cp $6c
jr nz, .loop2 jr nz, .loop2
ldh a, [hPrintNum9] ldh a, [hPrintNumBuffer + 8]
cp $2 cp $2
jr z, Function104b22 jr z, Function104b22
ld hl, hPrintNum1 ld hl, hPrintNumBuffer
ld b, $1 ld b, $1
call Function104d56 call Function104d56
jr nz, .ly_loop jr nz, .ly_loop
@ -321,7 +321,7 @@ Function104b22:
jp Function104bd0 jp Function104bd0
Function104b40: Function104b40:
ld hl, hPrintNum1 ld hl, hPrintNumBuffer
ld b, $1 ld b, $1
call Function104d56 call Function104d56
ret nz ret nz
@ -331,14 +331,14 @@ Function104b49:
ldh a, [hMGStatusFlags] ldh a, [hMGStatusFlags]
cp $6c cp $6c
ret nz ret nz
ldh a, [hPrintNum1] ldh a, [hPrintNumBuffer]
cp $96 cp $96
jp nz, Function104d32 jp nz, Function104d32
ld a, $90 ld a, $90
ldh [hPrintNum1], a ldh [hPrintNumBuffer], a
call Function104d38 call Function104d38
ret nz ret nz
ld hl, hPrintNum1 ld hl, hPrintNumBuffer
ld b, $1 ld b, $1
call Function104d4e call Function104d4e
ret nz ret nz
@ -360,8 +360,8 @@ Function104b49:
Function104b88: Function104b88:
ld a, $96 ld a, $96
ldh [hPrintNum1], a ldh [hPrintNumBuffer], a
ld hl, hPrintNum1 ld hl, hPrintNumBuffer
ld b, $1 ld b, $1
call Function104d4e call Function104d4e
ret nz ret nz
@ -371,7 +371,7 @@ Function104b88:
ret nz ret nz
call Function104d43 call Function104d43
ret nz ret nz
ld hl, hPrintNum1 ld hl, hPrintNumBuffer
ld b, $1 ld b, $1
call Function104d56 call Function104d56
ret nz ret nz
@ -379,7 +379,7 @@ Function104b88:
ldh a, [hMGStatusFlags] ldh a, [hMGStatusFlags]
cp $6c cp $6c
ret nz ret nz
ldh a, [hPrintNum1] ldh a, [hPrintNumBuffer]
cp $90 cp $90
jp nz, Function104d32 jp nz, Function104d32
call Function104d38 call Function104d38
@ -415,7 +415,7 @@ Function104bd0:
call MysteryGift_ClearTrainerData call MysteryGift_ClearTrainerData
ld a, $26 ld a, $26
ld [wca02], a ld [wca02], a
ldh a, [hPrintNum9] ldh a, [hPrintNumBuffer + 8]
cp $2 cp $2
jr z, .asm_104c10 jr z, .asm_104c10
call Function104d43 call Function104d43
@ -453,7 +453,7 @@ Function104c2d:
jp z, Function104d1c jp z, Function104d1c
cp $6c cp $6c
jr nz, .asm_104c37 jr nz, .asm_104c37
ldh a, [hPrintNum9] ldh a, [hPrintNumBuffer + 8]
cp $2 cp $2
jr z, .asm_104c6c jr z, .asm_104c6c
call Function104c8a call Function104c8a
@ -479,7 +479,7 @@ Function104c2d:
jp Function104d1c jp Function104d1c
Function104c8a: Function104c8a:
ld hl, hPrintNum1 ld hl, hPrintNumBuffer
ld b, $1 ld b, $1
call Function104d56 call Function104d56
ret nz ret nz
@ -487,14 +487,14 @@ Function104c8a:
ldh a, [hMGStatusFlags] ldh a, [hMGStatusFlags]
cp $6c cp $6c
ret nz ret nz
ldh a, [hPrintNum1] ldh a, [hPrintNumBuffer]
cp $3c cp $3c
jp nz, Function104d32 jp nz, Function104d32
swap a swap a
ldh [hPrintNum1], a ldh [hPrintNumBuffer], a
call Function104d38 call Function104d38
ret nz ret nz
ld hl, hPrintNum1 ld hl, hPrintNumBuffer
ld b, $1 ld b, $1
call Function104d4e call Function104d4e
ret nz ret nz
@ -516,8 +516,8 @@ Function104c8a:
Function104cd2: Function104cd2:
ld a, $3c ld a, $3c
ldh [hPrintNum1], a ldh [hPrintNumBuffer], a
ld hl, hPrintNum1 ld hl, hPrintNumBuffer
ld b, $1 ld b, $1
call Function104d4e call Function104d4e
ret nz ret nz
@ -527,7 +527,7 @@ Function104cd2:
ret nz ret nz
call Function104d43 call Function104d43
ret nz ret nz
ld hl, hPrintNum1 ld hl, hPrintNumBuffer
ld b, $1 ld b, $1
call Function104d56 call Function104d56
ret nz ret nz
@ -535,7 +535,7 @@ Function104cd2:
ldh a, [hMGStatusFlags] ldh a, [hMGStatusFlags]
cp $6c cp $6c
ret nz ret nz
ldh a, [hPrintNum1] ldh a, [hPrintNumBuffer]
swap a swap a
cp $3c cp $3c
jp nz, Function104d32 jp nz, Function104d32
@ -641,7 +641,7 @@ Function104d96:
ld a, $c0 ld a, $c0
call Function104e8c call Function104e8c
ld a, $1 ld a, $1
ldh [hPrintNum9], a ldh [hPrintNumBuffer + 8], a
ret ret
Function104da0: Function104da0:
@ -701,7 +701,7 @@ Function104ddd:
ld d, $0 ld d, $0
ld e, d ld e, d
ld a, $1 ld a, $1
ldh [hPrintNum9], a ldh [hPrintNumBuffer + 8], a
.loop .loop
call MysteryGift_ReadJoypad call MysteryGift_ReadJoypad
ld b, $2 ld b, $2
@ -760,7 +760,7 @@ Function104e3a:
jr nz, .loop jr nz, .loop
Function104e46: Function104e46:
ld a, $2 ld a, $2
ldh [hPrintNum9], a ldh [hPrintNumBuffer + 8], a
ld c, LOW(rRP) ld c, LOW(rRP)
ld d, $0 ld d, $0
ld e, d ld e, d
@ -798,14 +798,14 @@ Function104e8c:
Function104e93: Function104e93:
xor a xor a
ldh [hPrintNum5], a ldh [hPrintNumBuffer + 4], a
ldh [hPrintNum6], a ldh [hPrintNumBuffer + 5], a
push hl push hl
push bc push bc
ld c, LOW(rRP) ld c, LOW(rRP)
ld d, $3d ld d, $3d
call Function104dd1 call Function104dd1
ld hl, hPrintNum2 ld hl, hPrintNumBuffer + 1
ld a, $5a ld a, $5a
ld [hli], a ld [hli], a
ld [hl], b ld [hl], b
@ -815,21 +815,21 @@ Function104e93:
pop bc pop bc
pop hl pop hl
call Function104ed6 call Function104ed6
ldh a, [hPrintNum5] ldh a, [hPrintNumBuffer + 4]
ldh [hPrintNum2], a ldh [hPrintNumBuffer + 1], a
ldh a, [hPrintNum6] ldh a, [hPrintNumBuffer + 5]
ldh [hPrintNum3], a ldh [hPrintNumBuffer + 2], a
push hl push hl
ld hl, hPrintNum2 ld hl, hPrintNumBuffer + 1
ld b, $2 ld b, $2
call Function104ed6 call Function104ed6
ld hl, hMGStatusFlags ld hl, hMGStatusFlags
ld b, $1 ld b, $1
call Function104faf call Function104faf
ldh a, [hPrintNum2] ldh a, [hPrintNumBuffer + 1]
ldh [hPrintNum5], a ldh [hPrintNumBuffer + 4], a
ldh a, [hPrintNum3] ldh a, [hPrintNumBuffer + 2]
ldh [hPrintNum6], a ldh [hPrintNumBuffer + 5], a
pop hl pop hl
ret ret
@ -850,15 +850,15 @@ Function104ed6:
inc b inc b
jr z, .asm_104f2e jr z, .asm_104f2e
ld a, $8 ld a, $8
ldh [hPrintNum4], a ldh [hPrintNumBuffer + 3], a
ld a, [hli] ld a, [hli]
ld e, a ld e, a
ldh a, [hPrintNum5] ldh a, [hPrintNumBuffer + 4]
add e add e
ldh [hPrintNum5], a ldh [hPrintNumBuffer + 4], a
ldh a, [hPrintNum6] ldh a, [hPrintNumBuffer + 5]
adc 0 adc 0
ldh [hPrintNum6], a ldh [hPrintNumBuffer + 5], a
.asm_104f02 .asm_104f02
xor a xor a
ldh [rIF], a ldh [rIF], a
@ -883,10 +883,10 @@ Function104ed6:
ldh [rIF], a ldh [rIF], a
halt halt
.asm_104f25 .asm_104f25
ldh a, [hPrintNum4] ldh a, [hPrintNumBuffer + 3]
dec a dec a
jr z, .asm_104eee jr z, .asm_104eee
ldh [hPrintNum4], a ldh [hPrintNumBuffer + 3], a
jr .asm_104f02 jr .asm_104f02
.asm_104f2e .asm_104f2e
ld a, $fe ld a, $fe
@ -920,35 +920,35 @@ Function104f50:
Function104f57: Function104f57:
xor a xor a
ldh [hPrintNum5], a ldh [hPrintNumBuffer + 4], a
ldh [hPrintNum6], a ldh [hPrintNumBuffer + 5], a
push bc push bc
push hl push hl
ld hl, hPrintNum2 ld hl, hPrintNumBuffer + 1
ld b, $2 ld b, $2
call Function104faf call Function104faf
ldh a, [hPrintNum3] ldh a, [hPrintNumBuffer + 2]
ldh [hPrintNum8], a ldh [hPrintNumBuffer + 7], a
ld b, a ld b, a
pop hl pop hl
pop af pop af
cp b cp b
jp c, Function104f50 jp c, Function104f50
ldh a, [hPrintNum2] ldh a, [hPrintNumBuffer + 1]
cp $5a cp $5a
jp nz, Function104f50 jp nz, Function104f50
call Function104faf call Function104faf
ldh a, [hPrintNum5] ldh a, [hPrintNumBuffer + 4]
ld d, a ld d, a
ldh a, [hPrintNum6] ldh a, [hPrintNumBuffer + 5]
ld e, a ld e, a
push hl push hl
push de push de
ld hl, hPrintNum2 ld hl, hPrintNumBuffer + 1
ld b, $2 ld b, $2
call Function104faf call Function104faf
pop de pop de
ld hl, hPrintNum2 ld hl, hPrintNumBuffer + 1
ld a, [hli] ld a, [hli]
xor d xor d
ld b, a ld b, a
@ -965,9 +965,9 @@ Function104f57:
pop de pop de
pop hl pop hl
ld a, d ld a, d
ldh [hPrintNum5], a ldh [hPrintNumBuffer + 4], a
ld a, e ld a, e
ldh [hPrintNum6], a ldh [hPrintNumBuffer + 5], a
ret ret
Function104faf: Function104faf:
@ -991,7 +991,7 @@ Function104faf:
inc b inc b
jr z, .asm_10501a jr z, .asm_10501a
ld a, $8 ld a, $8
ldh [hPrintNum4], a ldh [hPrintNumBuffer + 3], a
.asm_104fd9 .asm_104fd9
ld d, $0 ld d, $0
.asm_104fdb .asm_104fdb
@ -1020,9 +1020,9 @@ Function104faf:
.asm_104ffd .asm_104ffd
res 0, e res 0, e
.asm_104fff .asm_104fff
ldh a, [hPrintNum4] ldh a, [hPrintNumBuffer + 3]
dec a dec a
ldh [hPrintNum4], a ldh [hPrintNumBuffer + 3], a
jr z, .asm_10500b jr z, .asm_10500b
ld a, e ld a, e
rlca rlca
@ -1031,12 +1031,12 @@ Function104faf:
.asm_10500b .asm_10500b
ld a, e ld a, e
ld [hli], a ld [hli], a
ldh a, [hPrintNum5] ldh a, [hPrintNumBuffer + 4]
add e add e
ldh [hPrintNum5], a ldh [hPrintNumBuffer + 4], a
ldh a, [hPrintNum6] ldh a, [hPrintNumBuffer + 5]
adc 0 adc 0
ldh [hPrintNum6], a ldh [hPrintNumBuffer + 5], a
jr .asm_104fd2 jr .asm_104fd2
.asm_10501a .asm_10501a
call Function104d74 call Function104d74

View File

@ -23,9 +23,9 @@ _PrintNum::
.main .main
xor a xor a
ldh [hPrintNum1], a ldh [hPrintNumBuffer + 0], a
ldh [hPrintNum2], a ldh [hPrintNumBuffer + 1], a
ldh [hPrintNum3], a ldh [hPrintNumBuffer + 2], a
ld a, b ld a, b
and $f and $f
cp 1 cp 1
@ -35,26 +35,26 @@ _PrintNum::
; maximum 3 bytes ; maximum 3 bytes
.long .long
ld a, [de] ld a, [de]
ldh [hPrintNum2], a ldh [hPrintNumBuffer + 1], a
inc de inc de
ld a, [de] ld a, [de]
ldh [hPrintNum3], a ldh [hPrintNumBuffer + 2], a
inc de inc de
ld a, [de] ld a, [de]
ldh [hPrintNum4], a ldh [hPrintNumBuffer + 3], a
jr .start jr .start
.word .word
ld a, [de] ld a, [de]
ldh [hPrintNum3], a ldh [hPrintNumBuffer + 2], a
inc de inc de
ld a, [de] ld a, [de]
ldh [hPrintNum4], a ldh [hPrintNumBuffer + 3], a
jr .start jr .start
.byte .byte
ld a, [de] ld a, [de]
ldh [hPrintNum4], a ldh [hPrintNumBuffer + 3], a
.start .start
push de push de
@ -81,51 +81,51 @@ _PrintNum::
.seven .seven
ld a, HIGH(1000000 >> 8) ld a, HIGH(1000000 >> 8)
ldh [hPrintNum5], a ldh [hPrintNumBuffer + 4], a
ld a, HIGH(1000000) ; mid ld a, HIGH(1000000) ; mid
ldh [hPrintNum6], a ldh [hPrintNumBuffer + 5], a
ld a, LOW(1000000) ld a, LOW(1000000)
ldh [hPrintNum7], a ldh [hPrintNumBuffer + 6], a
call .PrintDigit call .PrintDigit
call .AdvancePointer call .AdvancePointer
.six .six
ld a, HIGH(100000 >> 8) ld a, HIGH(100000 >> 8)
ldh [hPrintNum5], a ldh [hPrintNumBuffer + 4], a
ld a, HIGH(100000) ; mid ld a, HIGH(100000) ; mid
ldh [hPrintNum6], a ldh [hPrintNumBuffer + 5], a
ld a, LOW(100000) ld a, LOW(100000)
ldh [hPrintNum7], a ldh [hPrintNumBuffer + 6], a
call .PrintDigit call .PrintDigit
call .AdvancePointer call .AdvancePointer
.five .five
xor a ; HIGH(10000 >> 8) xor a ; HIGH(10000 >> 8)
ldh [hPrintNum5], a ldh [hPrintNumBuffer + 4], a
ld a, HIGH(10000) ; mid ld a, HIGH(10000) ; mid
ldh [hPrintNum6], a ldh [hPrintNumBuffer + 5], a
ld a, LOW(10000) ld a, LOW(10000)
ldh [hPrintNum7], a ldh [hPrintNumBuffer + 6], a
call .PrintDigit call .PrintDigit
call .AdvancePointer call .AdvancePointer
.four .four
xor a ; HIGH(1000 >> 8) xor a ; HIGH(1000 >> 8)
ldh [hPrintNum5], a ldh [hPrintNumBuffer + 4], a
ld a, HIGH(1000) ; mid ld a, HIGH(1000) ; mid
ldh [hPrintNum6], a ldh [hPrintNumBuffer + 5], a
ld a, LOW(1000) ld a, LOW(1000)
ldh [hPrintNum7], a ldh [hPrintNumBuffer + 6], a
call .PrintDigit call .PrintDigit
call .AdvancePointer call .AdvancePointer
.three .three
xor a ; HIGH(100 >> 8) xor a ; HIGH(100 >> 8)
ldh [hPrintNum5], a ldh [hPrintNumBuffer + 4], a
xor a ; HIGH(100) ; mid xor a ; HIGH(100) ; mid
ldh [hPrintNum6], a ldh [hPrintNumBuffer + 5], a
ld a, LOW(100) ld a, LOW(100)
ldh [hPrintNum7], a ldh [hPrintNumBuffer + 6], a
call .PrintDigit call .PrintDigit
call .AdvancePointer call .AdvancePointer
@ -133,11 +133,11 @@ _PrintNum::
dec e dec e
jr nz, .two_skip jr nz, .two_skip
ld a, "0" ld a, "0"
ldh [hPrintNum1], a ldh [hPrintNumBuffer + 0], a
.two_skip .two_skip
ld c, 0 ld c, 0
ldh a, [hPrintNum4] ldh a, [hPrintNumBuffer + 3]
.mod_10 .mod_10
cp 10 cp 10
jr c, .modded_10 jr c, .modded_10
@ -147,7 +147,7 @@ _PrintNum::
.modded_10 .modded_10
ld b, a ld b, a
ldh a, [hPrintNum1] ldh a, [hPrintNumBuffer + 0]
or c or c
jr nz, .money jr nz, .money
call .PrintLeadingZero call .PrintLeadingZero
@ -160,7 +160,7 @@ _PrintNum::
add c add c
ld [hl], a ld [hl], a
pop af pop af
ldh [hPrintNum1], a ldh [hPrintNumBuffer + 0], a
inc e inc e
dec e dec e
jr nz, .money_leading_zero jr nz, .money_leading_zero
@ -180,7 +180,7 @@ _PrintNum::
.PrintYen: .PrintYen:
push af push af
ldh a, [hPrintNum1] ldh a, [hPrintNumBuffer + 0]
and a and a
jr nz, .stop jr nz, .stop
bit 5, d bit 5, d
@ -197,68 +197,68 @@ _PrintNum::
dec e dec e
jr nz, .ok jr nz, .ok
ld a, "0" ld a, "0"
ldh [hPrintNum1], a ldh [hPrintNumBuffer + 0], a
.ok .ok
ld c, 0 ld c, 0
.loop .loop
ldh a, [hPrintNum5] ldh a, [hPrintNumBuffer + 4]
ld b, a ld b, a
ldh a, [hPrintNum2] ldh a, [hPrintNumBuffer + 1]
ldh [hPrintNum8], a ldh [hPrintNumBuffer + 7], a
cp b cp b
jr c, .skip1 jr c, .skip1
sub b sub b
ldh [hPrintNum2], a ldh [hPrintNumBuffer + 1], a
ldh a, [hPrintNum6] ldh a, [hPrintNumBuffer + 5]
ld b, a ld b, a
ldh a, [hPrintNum3] ldh a, [hPrintNumBuffer + 2]
ldh [hPrintNum9], a ldh [hPrintNumBuffer + 8], a
cp b cp b
jr nc, .skip2 jr nc, .skip2
ldh a, [hPrintNum2] ldh a, [hPrintNumBuffer + 1]
or 0 or 0
jr z, .skip3 jr z, .skip3
dec a dec a
ldh [hPrintNum2], a ldh [hPrintNumBuffer + 1], a
ldh a, [hPrintNum3] ldh a, [hPrintNumBuffer + 2]
.skip2 .skip2
sub b sub b
ldh [hPrintNum3], a ldh [hPrintNumBuffer + 2], a
ldh a, [hPrintNum7] ldh a, [hPrintNumBuffer + 6]
ld b, a ld b, a
ldh a, [hPrintNum4] ldh a, [hPrintNumBuffer + 3]
ldh [hPrintNum10], a ldh [hPrintNumBuffer + 9], a
cp b cp b
jr nc, .skip4 jr nc, .skip4
ldh a, [hPrintNum3] ldh a, [hPrintNumBuffer + 2]
and a and a
jr nz, .skip5 jr nz, .skip5
ldh a, [hPrintNum2] ldh a, [hPrintNumBuffer + 1]
and a and a
jr z, .skip6 jr z, .skip6
dec a dec a
ldh [hPrintNum2], a ldh [hPrintNumBuffer + 1], a
xor a xor a
.skip5 .skip5
dec a dec a
ldh [hPrintNum3], a ldh [hPrintNumBuffer + 2], a
ldh a, [hPrintNum4] ldh a, [hPrintNumBuffer + 3]
.skip4 .skip4
sub b sub b
ldh [hPrintNum4], a ldh [hPrintNumBuffer + 3], a
inc c inc c
jr .loop jr .loop
.skip6 .skip6
ldh a, [hPrintNum9] ldh a, [hPrintNumBuffer + 8]
ldh [hPrintNum3], a ldh [hPrintNumBuffer + 2], a
.skip3 .skip3
ldh a, [hPrintNum8] ldh a, [hPrintNumBuffer + 7]
ldh [hPrintNum2], a ldh [hPrintNumBuffer + 1], a
.skip1 .skip1
ldh a, [hPrintNum1] ldh a, [hPrintNumBuffer + 0]
or c or c
jr z, .PrintLeadingZero jr z, .PrintLeadingZero
ldh a, [hPrintNum1] ldh a, [hPrintNumBuffer + 0]
and a and a
jr nz, .done jr nz, .done
bit 5, d bit 5, d
@ -270,7 +270,7 @@ _PrintNum::
ld a, "0" ld a, "0"
add c add c
ld [hl], a ld [hl], a
ldh [hPrintNum1], a ldh [hPrintNumBuffer + 0], a
inc e inc e
dec e dec e
ret nz ret nz
@ -292,7 +292,7 @@ _PrintNum::
jr nz, .inc jr nz, .inc
bit 6, d ; left alignment or right alignment? bit 6, d ; left alignment or right alignment?
jr z, .inc jr z, .inc
ldh a, [hPrintNum1] ldh a, [hPrintNumBuffer + 0]
and a and a
ret z ret z
.inc .inc

View File

@ -62,45 +62,41 @@ ENDU ; ffb1
hEnemyMonSpeed:: dw ; ffb1 hEnemyMonSpeed:: dw ; ffb1
UNION ; ffb3 UNION ; ffb3
; miscellaneous
ds 2 ds 2
hPartyMon1Speed:: dw ; ffb5 hPartyMon1Speed:: dw ; ffb5
ds 5
hMGStatusFlags:: db ; ffbc
NEXTU ; ffb3 NEXTU ; ffb3
hDividend:: ds 4 ; ffb3 ; inputs to Multiply
hDivisor:: db ; ffb7
NEXTU ; ffb3
ds 1
hQuotient:: ds 3 ; ffb4
hRemainder:: db ; ffb7
NEXTU ; ffb3
ds 1 ds 1
hMultiplicand:: ds 3 ; ffb4 hMultiplicand:: ds 3 ; ffb4
hMultiplier:: db ; ffb7 hMultiplier:: db ; ffb7
NEXTU ; ffb3 NEXTU ; ffb3
; result of Multiply
hProduct:: ds 4 ; ffb3 hProduct:: ds 4 ; ffb3
NEXTU ; ffb3 NEXTU ; ffb3
; inputs to Divide
hDividend:: ds 4 ; ffb3
hDivisor:: db ; ffb7
NEXTU ; ffb3
; results of Divide
ds 1
hQuotient:: ds 3 ; ffb4
hRemainder:: db ; ffb7
NEXTU ; ffb3
; math-related scratch space
ds 5 ds 5
hMathBuffer:: ds 5 ; ffb8 hMathBuffer:: ds 5 ; ffb8
NEXTU ; ffb3 NEXTU ; ffb3
hPrintNum1:: db ; ffb3 ; PrintNum scratch space
hPrintNum2:: db ; ffb4 hPrintNumBuffer:: ds 10 ; ffb3
hPrintNum3:: db ; ffb5
hPrintNum4:: db ; ffb6
hPrintNum5:: db ; ffb7
hPrintNum6:: db ; ffb8
hPrintNum7:: db ; ffb9
hPrintNum8:: db ; ffba
hPrintNum9:: db ; ffbb
hPrintNum10:: db ; ffbc
NEXTU ; ffb3
ds 9
hMGStatusFlags:: db ; ffbc
ENDU ; ffbd ENDU ; ffbd
hUsedSpriteIndex:: db ; ffbd hUsedSpriteIndex:: db ; ffbd

View File

@ -586,9 +586,9 @@ _MobilePrintNum::
; hl: where to print the converted string ; hl: where to print the converted string
push bc push bc
xor a xor a
ldh [hPrintNum1], a ldh [hPrintNumBuffer + 0], a
ldh [hPrintNum2], a ldh [hPrintNumBuffer + 1], a
ldh [hPrintNum3], a ldh [hPrintNumBuffer + 2], a
ld a, b ld a, b
and $f and $f
cp $1 cp $1
@ -599,29 +599,29 @@ _MobilePrintNum::
jr z, .three_bytes jr z, .three_bytes
; four bytes ; four bytes
ld a, [de] ld a, [de]
ldh [hPrintNum1], a ldh [hPrintNumBuffer + 0], a
inc de inc de
.three_bytes .three_bytes
ld a, [de] ld a, [de]
ldh [hPrintNum2], a ldh [hPrintNumBuffer + 1], a
inc de inc de
.two_bytes .two_bytes
ld a, [de] ld a, [de]
ldh [hPrintNum3], a ldh [hPrintNumBuffer + 2], a
inc de inc de
.one_byte .one_byte
ld a, [de] ld a, [de]
ldh [hPrintNum4], a ldh [hPrintNumBuffer + 3], a
inc de inc de
push de push de
xor a xor a
ldh [hPrintNum9], a ldh [hPrintNumBuffer + 8], a
ld a, b ld a, b
ldh [hPrintNum10], a ldh [hPrintNumBuffer + 9], a
ld a, c ld a, c
cp 2 cp 2
jr z, .two_digits jr z, .two_digits
@ -668,7 +668,7 @@ endr
.two_digits .two_digits
ld c, 0 ld c, 0
ldh a, [hPrintNum4] ldh a, [hPrintNumBuffer + 3]
.mod_ten_loop .mod_ten_loop
cp 10 cp 10
jr c, .simple_divide_done jr c, .simple_divide_done
@ -678,9 +678,9 @@ endr
.simple_divide_done .simple_divide_done
ld b, a ld b, a
ldh a, [hPrintNum9] ldh a, [hPrintNumBuffer + 8]
or c or c
ldh [hPrintNum9], a ldh [hPrintNumBuffer + 8], a
jr nz, .create_digit jr nz, .create_digit
call .LoadMinusTenIfNegative call .LoadMinusTenIfNegative
jr .done jr .done
@ -714,53 +714,53 @@ endr
ld a, [de] ld a, [de]
dec de dec de
ld b, a ld b, a
ldh a, [hPrintNum4] ldh a, [hPrintNumBuffer + 3]
sub b sub b
ldh [hPrintNum8], a ldh [hPrintNumBuffer + 7], a
ld a, [de] ld a, [de]
dec de dec de
ld b, a ld b, a
ldh a, [hPrintNum3] ldh a, [hPrintNumBuffer + 2]
sbc b sbc b
ldh [hPrintNum7], a ldh [hPrintNumBuffer + 6], a
ld a, [de] ld a, [de]
dec de dec de
ld b, a ld b, a
ldh a, [hPrintNum2] ldh a, [hPrintNumBuffer + 1]
sbc b sbc b
ldh [hPrintNum6], a ldh [hPrintNumBuffer + 5], a
ld a, [de] ld a, [de]
inc de inc de
inc de inc de
inc de inc de
ld b, a ld b, a
ldh a, [hPrintNum1] ldh a, [hPrintNumBuffer + 0]
sbc b sbc b
ldh [hPrintNum5], a ldh [hPrintNumBuffer + 4], a
jr c, .asm_1062eb jr c, .asm_1062eb
ldh a, [hPrintNum5] ldh a, [hPrintNumBuffer + 4]
ldh [hPrintNum1], a ldh [hPrintNumBuffer + 0], a
ldh a, [hPrintNum6] ldh a, [hPrintNumBuffer + 5]
ldh [hPrintNum2], a ldh [hPrintNumBuffer + 1], a
ldh a, [hPrintNum7] ldh a, [hPrintNumBuffer + 6]
ldh [hPrintNum3], a ldh [hPrintNumBuffer + 2], a
ldh a, [hPrintNum8] ldh a, [hPrintNumBuffer + 7]
ldh [hPrintNum4], a ldh [hPrintNumBuffer + 3], a
inc c inc c
jr .asm_1062b4 jr .asm_1062b4
.asm_1062eb .asm_1062eb
ldh a, [hPrintNum9] ldh a, [hPrintNumBuffer + 8]
or c or c
jr z, .LoadMinusTenIfNegative jr z, .LoadMinusTenIfNegative
ld a, -10 ld a, -10
add c add c
ld [hl], a ld [hl], a
ldh [hPrintNum9], a ldh [hPrintNumBuffer + 8], a
ret ret
.LoadMinusTenIfNegative: .LoadMinusTenIfNegative:
ldh a, [hPrintNum10] ldh a, [hPrintNumBuffer + 9]
bit 7, a bit 7, a
ret z ret z
@ -768,12 +768,12 @@ endr
ret ret
.Function1062ff: .Function1062ff:
ldh a, [hPrintNum10] ldh a, [hPrintNumBuffer + 9]
bit 7, a bit 7, a
jr nz, .asm_10630d jr nz, .asm_10630d
bit 6, a bit 6, a
jr z, .asm_10630d jr z, .asm_10630d
ldh a, [hPrintNum9] ldh a, [hPrintNumBuffer + 8]
and a and a
ret z ret z

View File

@ -5148,7 +5148,7 @@ Function11a80c:
ld bc, hQuotient ld bc, hQuotient
ld hl, Unknown_11a8ba ld hl, Unknown_11a8ba
call Function11a88c call Function11a88c
ld bc, hPrintNum3 ld bc, hPrintNumBuffer + 2
ld hl, Unknown_11a8da ld hl, Unknown_11a8da
call Function11a88c call Function11a88c
xor a xor a
@ -5156,11 +5156,11 @@ Function11a80c:
ldh a, [hDivisor] ldh a, [hDivisor]
and $f and $f
ld e, a ld e, a
ldh a, [hPrintNum7] ldh a, [hPrintNumBuffer + 6]
and $f and $f
call Function11a884 call Function11a884
ld e, a ld e, a
ldh a, [hPrintNum9] ldh a, [hPrintNumBuffer + 8]
and $f and $f
call Function11a884 call Function11a884
ld [wcd62], a ld [wcd62], a
@ -5172,12 +5172,12 @@ Function11a80c:
swap a swap a
call Function11a884 call Function11a884
ld e, a ld e, a
ldh a, [hPrintNum7] ldh a, [hPrintNumBuffer + 6]
and $f0 and $f0
swap a swap a
call Function11a884 call Function11a884
ld e, a ld e, a
ldh a, [hPrintNum9] ldh a, [hPrintNumBuffer + 8]
and $f0 and $f0
swap a swap a
call Function11a884 call Function11a884
@ -5189,11 +5189,11 @@ Function11a80c:
and $f and $f
call Function11a884 call Function11a884
ld e, a ld e, a
ldh a, [hPrintNum8] ldh a, [hPrintNumBuffer + 7]
and $f and $f
call Function11a884 call Function11a884
ld e, a ld e, a
ldh a, [hPrintNum10] ldh a, [hPrintNumBuffer + 9]
and $f and $f
call Function11a884 call Function11a884
ld [wcd64], a ld [wcd64], a