Label BCD math predefs.

This commit is contained in:
yenatch 2014-05-25 17:27:02 -07:00
parent bba8405992
commit 4be11293e5
14 changed files with 92 additions and 83 deletions

View file

@ -36,8 +36,8 @@ Func_137aa: ; 137aa (4:77aa)
jr z, .asm_1380a
ld de, wPlayerMoney + 2 ; $d349
ld c, $3
ld a, $b
call Predef ; indirect jump to Func_f81d (f81d (3:781d))
ld a, $b ; AddBCDPredef
call Predef
ld hl, PickUpPayDayMoneyText
call PrintText
.asm_1380a

View file

@ -120,7 +120,7 @@ PayDayEffect_ ; 2feb8 (b:7eb8)
ld [hl], a
ld de, $cce7
ld c, $3
ld a, $b
ld a, $b ; AddBCDPredef
call Predef
ld hl, CoinsScatteredText ; $7f04
jp PrintText

View file

@ -996,8 +996,8 @@ TrainerBattleVictory: ; 3c696 (f:4696)
ld de, wPlayerMoney + 2 ; $d349
ld hl, $d07b
ld c, $3
ld a, $b
jp Predef ; indirect jump to Func_f81d (f81d (3:781d))
ld a, $b ; AddBCDPredef
jp Predef
MoneyForWinningText: ; 3c6e4 (f:46e4)
TX_FAR _MoneyForWinningText

View file

@ -71,8 +71,8 @@ VendingMachineMenu: ; 74ee0 (1d:4ee0)
ld hl, $ffde
ld de, wPlayerMoney + 2 ; $d349
ld c, $3
ld a, $c
call Predef ; indirect jump to Func_f836 (f836 (3:7836))
ld a, $c ; SubtractBCDPredef
call Predef
ld a, $13
ld [$d125], a
jp DisplayTextBoxID

View file

@ -104,7 +104,7 @@ HiddenCoins: ; 76799 (1d:6799)
ld de, $d5a5
ld hl, $ffa1
ld c, $2
ld a, $b
ld a, $b ; AddBCDPredef
call Predef
ld hl, $d6fe
ld a, [$cd41]

View file

@ -70,12 +70,13 @@ HealPartyPredef: ; 4fe8e (13:7e8e)
dbw BANK(HealParty),HealParty
MoveAnimationPredef: ; 4fe91 (13:7e91)
dbw BANK(MoveAnimation),MoveAnimation; 08 play move animation
dbw BANK(Func_f71e),Func_f71e
dbw BANK(Func_f71e),Func_f71e
dbw BANK(Func_f81d),Func_f81d
dbw BANK(Func_f836),Func_f836
dbw BANK(Func_f71e),Func_f71e
dbw BANK(Func_f71e),Func_f71e
dbw BANK(DivideBCDPredef),DivideBCDPredef
dbw BANK(DivideBCDPredef),DivideBCDPredef
dbw BANK(AddBCDPredef),AddBCDPredef
db BANK(SubtractBCDPredef)
dw SubtractBCDPredef
dbw BANK(DivideBCDPredef),DivideBCDPredef
dbw BANK(DivideBCDPredef),DivideBCDPredef
db BANK(InitializePlayerData)
dw InitializePlayerData
dbw BANK(FlagActionPredef),FlagActionPredef

View file

@ -618,7 +618,7 @@ SlotMachine_37741: ; 37741 (d:7741)
ld [hli], a
ld de, $d5a5
ld c, $2
ld a, $c
ld a, $c ; SubtractBCDPredef
call Predef
SlotMachine_37754: ; 37754 (d:7754)
@ -660,7 +660,7 @@ SlotMachine_3776b: ; 3776b (d:776b)
ld hl, $cd47
ld de, $d5a5
ld c, $2
ld a, $b
ld a, $b ; AddBCDPredef
call Predef
call SlotMachine_37754
call SlotMachine_3775f

View file

@ -917,9 +917,9 @@ HandleBlackOut::
call StopMusic
ld hl, $d72e
res 5, [hl]
ld a, Bank(Func_40b0) ; Bank(Func_40b0) and Bank(Func_62ce) need to be equal.
ld a, Bank(Func_40b0) ; also Bank(Func_62ce) and Bank(Func_5d5f)
ld [H_LOADEDROMBANK], a
ld [$2000], a
ld [MBC3RomBank], a
call Func_40b0
call Func_62ce
call Func_2312
@ -8302,24 +8302,24 @@ GetTrainerName:: ; 359e (0:359e)
ld hl, GetTrainerName_
jp Bankswitch
; tests if player's money are at least as much as [$ff9f]
; sets carry flag if not enough money
; sets zero flag if amounts match exactly
HasEnoughMoney:: ; 35a6 (0:35a6)
ld de, wPlayerMoney ; $d347
HasEnoughMoney::
; Check if the player has at least as much
; money as the 3-byte BCD value at $ff9f.
ld de, wPlayerMoney
ld hl, $ff9f
ld c, $3
ld c, 3
jp StringCmp
; tests if player's game corner coins are at least as many as [$ffa0]
; sets carry flag if not enough coins
; sets zero flag if amounts match exactly
HasEnoughCoins:: ; 35b1 (0:35b1)
HasEnoughCoins::
; Check if the player has at least as many
; coins as the 2-byte BCD value at $ffa0.
ld de, wPlayerCoins
ld hl, $ffa0
ld c, $2
ld c, 2
jp StringCmp
BankswitchHome:: ; 35bc (0:35bc)
; switches to bank # in a
; Only use this when in the home bank!

View file

@ -63,49 +63,55 @@ SpriteOAMParametersFlipped: ; 40a4 (1:40a4)
db $08,$08, OAMFLAG_VFLIPPED | OAMFLAG_CANBEMASKED
db $08,$00, OAMFLAG_VFLIPPED | OAMFLAG_CANBEMASKED | OAMFLAG_ENDOFDATA
Func_40b0: ; 40b0 (1:40b0)
Func_40b0::
; Reset player status on blackout.
xor a
ld [$cf0b], a
ld [$d700], a
ld [W_ISINBATTLE], a ; $d057
ld [W_ISINBATTLE], a
ld [$d35d], a
ld [$cf10], a
ld [hJoyHeld], a
ld [$cc57], a
ld [wFlags_0xcd60], a
ld [$ff9f], a
ld [$ffa0], a
ld [$ffa1], a
ld [$ff9f + 1], a
ld [$ff9f + 2], a
call HasEnoughMoney
jr c, .asm_40ff
ld a, [wPlayerMoney] ; $d347
jr c, .lostmoney ; never happens
; Halve the player's money.
ld a, [wPlayerMoney]
ld [$ff9f], a
ld a, [wPlayerMoney + 1] ; $d348
ld [$ffa0], a
ld a, [wPlayerMoney + 2] ; $d349
ld [$ffa1], a
ld a, [wPlayerMoney + 1]
ld [$ff9f + 1], a
ld a, [wPlayerMoney + 2]
ld [$ff9f + 2], a
xor a
ld [$ffa2], a
ld [$ffa3], a
ld a, $2
ld a, 2
ld [$ffa4], a
ld a, $d
call Predef ; indirect jump to Func_f71e (f71e (3:771e))
ld a, $d ; DivideBCDPredef
call Predef
ld a, [$ffa2]
ld [wPlayerMoney], a ; $d347
ld a, [$ffa3]
ld [wPlayerMoney + 1], a ; $d348
ld a, [$ffa4]
ld [wPlayerMoney + 2], a ; $d349
.asm_40ff
ld [wPlayerMoney], a
ld a, [$ffa2 + 1]
ld [wPlayerMoney + 1], a
ld a, [$ffa2 + 2]
ld [wPlayerMoney + 2], a
.lostmoney
ld hl, $d732
set 2, [hl]
res 3, [hl]
set 6, [hl]
ld a, $ff
ld a, %11111111
ld [wJoyIgnore], a
ld a, $7
jp Predef ; indirect jump to HealParty (f6a5 (3:76a5))
ld a, $7 ; HealParty
jp Predef
MewPicFront:: INCBIN "pic/bmon/mew.pic"
MewPicBack:: INCBIN "pic/monback/mewb.pic"
@ -5309,12 +5315,10 @@ HealParty:
ret
; predef $9
; predef $a
; predef $d
; predef $e
Func_f71e: ; f71e (3:771e)
DivideBCDPredef::
call GetPredefRegisters
DivideBCD::
xor a
ld [$ffa5], a
ld [$ffa6], a
@ -5462,15 +5466,18 @@ Func_f800: ; f800 (3:7800)
ld de, $ffa1
ld hl, $ffa4
push bc
call Func_f839
call SubtractBCD
pop bc
jr .asm_f803
Func_f81d: ; f81d (3:781d)
AddBCDPredef::
call GetPredefRegisters
AddBCD::
and a
ld b, c
.asm_f822
.add
ld a, [de]
adc [hl]
daa
@ -5478,25 +5485,26 @@ Func_f81d: ; f81d (3:781d)
dec de
dec hl
dec c
jr nz, .asm_f822
jr nc, .asm_f835
jr nz, .add
jr nc, .done
ld a, $99
inc de
.asm_f830
.fill
ld [de], a
inc de
dec b
jr nz, .asm_f830
.asm_f835
jr nz, .fill
.done
ret
Func_f836: ; f836 (3:7836)
SubtractBCDPredef::
call GetPredefRegisters
Func_f839: ; f839 (3:7839)
SubtractBCD::
and a
ld b, c
.asm_f83b
.sub
ld a, [de]
sbc [hl]
daa
@ -5504,17 +5512,17 @@ Func_f839: ; f839 (3:7839)
dec de
dec hl
dec c
jr nz, .asm_f83b
jr nc, .asm_f84f
ld a, $0
jr nz, .sub
jr nc, .done
ld a, $00
inc de
.asm_f849
.fill
ld [de], a
inc de
dec b
jr nz, .asm_f849
jr nz, .fill
scf
.asm_f84f
.done
ret

View file

@ -157,7 +157,7 @@ CeladonGameCornerText2: ; 48ca9 (12:4ca9)
ld hl, $ffa1
ld de, $d349
ld c, $3
ld a, $c
ld a, $c ; SubtractBCDPredef
call Predef
xor a
ldh [$9f], a
@ -167,7 +167,7 @@ CeladonGameCornerText2: ; 48ca9 (12:4ca9)
ld de, $d5a5
ld hl, $ffa1
ld c, $2
ld a, $b
ld a, $b ; AddBCDPredef
call Predef
call CeladonGameCornerScript_48f1e
ld hl, CeladonGameCornerText_48d27
@ -236,7 +236,7 @@ CeladonGameCornerText5: ; 48d4a (12:4d4a)
ld de, $d5a5
ld hl, $ffa1
ld c, $2
ld a, $b
ld a, $b ; AddBCDPredef
call Predef
ld hl, $d77e
set 2, [hl]
@ -319,7 +319,7 @@ CeladonGameCornerText9: ; 48dd9 (12:4dd9)
ld de, $d5a5
ld hl, $ffa1
ld c, $2
ld a, $b
ld a, $b ; AddBCDPredef
call Predef
ld hl, $d77e
set 4, [hl]
@ -373,7 +373,7 @@ CeladonGameCornerText10: ; 48e3b (12:4e3b)
ld de, $d5a5
ld hl, $ffa1
ld c, $2
ld a, $b
ld a, $b ; AddBCDPredef
call Predef
ld hl, $d77e
set 3, [hl]

View file

@ -120,7 +120,7 @@ DayCareMScript_562e1: ; 562e1 (15:62e1)
push hl
push de
push bc
ld a, $b
ld a, $b ; AddBCDPredef
call Predef
pop bc
pop de
@ -156,7 +156,7 @@ DayCareMScript_562e1: ; 562e1 (15:62e1)
inc hl
ld de, $d349
ld c, $3
ld a, $c
ld a, $c ; SubtractBCDPredef
call Predef
ld a, (SFX_02_5a - SFX_Headers_02) / 3
call PlaySoundWaitForCurrent

View file

@ -55,7 +55,7 @@ MtMoonPokecenterText4: ; 492ec (12:52ec)
ld hl, $cd3f
ld de, $d349
ld c, $3
ld a, $c
ld a, $c ; SubtractBCDPredef
call Predef
ld a, $13
ld [$d125], a

View file

@ -103,7 +103,7 @@ Museum1FText1: ; 5c135 (17:4135)
ld hl, $cd3f
ld de, $d349
ld c, $3
ld a, $c
ld a, $c ; SubtractBCDPredef
call Predef
ld a, $13
ld [$d125], a

View file

@ -176,7 +176,7 @@ SafariZoneEntranceText4: ; 752ca (1d:52ca)
ld hl, $cd3f
ld de, $d349
ld c, $3
ld a, $c
ld a, $c ; SubtractBCDPredef
call Predef
ld a, $13
ld [$d125], a