Labelling Bank 0D, part 1

This commit is contained in:
DrippingYellow 2025-01-19 15:29:37 -06:00 committed by vulcandth
parent ce247cc761
commit 8514ca51f7
13 changed files with 1325 additions and 1404 deletions

View File

@ -14,6 +14,8 @@ INCLUDE "macros/scripts.asm"
INCLUDE "macros/queue.asm"
INCLUDE "macros/maps.asm"
INCLUDE "macros/battle_commands.asm"
INCLUDE "constants/audio_constants.asm"
INCLUDE "constants/gfx_constants.asm"
INCLUDE "constants/hardware_constants.asm"

View File

@ -241,7 +241,7 @@ DEF ALL_STATUS EQU (1 << PSN) | (1 << BRN) | (1 << FRZ) | (1 << PAR) | SLP
const BATTLEACTION_B
const BATTLEACTION_C
const BATTLEACTION_D
const BATTLEACTION_E
const BATTLEACTION_STRUGGLE
const BATTLEACTION_FORFEIT
; wBattleResult

View File

@ -36,8 +36,8 @@ GiveItemPredef::
add_predef Functiondd5c
add_predef Functionde79
add_predef UpdateHPBar
add_predef Functiondf7d ; 18
add_predef Functiondf91
add_predef CalcMonStats ; 18
add_predef CalcMonStatC
add_predef CanLearnTMHMMove
add_predef GetTMHMMove
add_predef LinkTextboxAtHL

View File

@ -993,7 +993,7 @@ Functiond8b6:
ld c, a
xor a
ld b, a
call Functiondf91
call CalcMonStatC
ldh a, [hDividend+2]
ld [de], a
inc de
@ -1053,7 +1053,7 @@ Functiond8b6:
ld bc, $000a
add hl, bc
ld b, $00
call Functiondf7d
call CalcMonStats
.sub_da26
scf
ret
@ -1303,7 +1303,7 @@ Functiondac8:
add hl, bc
push bc
ld b, $01
call Functiondf7d
call CalcMonStats
pop bc
ld a, [wPokemonWithdrawDepositParameter]
and a
@ -1402,7 +1402,7 @@ Functiondc16:
ld bc, hFFEB
add hl, bc
ld b, $01
call Functiondf7d
call CalcMonStats
pop hl
pop de
ld a, [hli]
@ -1678,7 +1678,7 @@ Functionde79:
ld a, [wCurPartySpecies]
ld [wTempEnemyMonSpecies], a
xor a
ld [wca44], a
ld [wEnemySubStatus5], a
ld hl, AddPokemonToBox
ld a, BANK(AddPokemonToBox)
call FarCall_hl
@ -1805,86 +1805,99 @@ Functiondecd:
.sub_df7a
jp CopyDataUntil
Functiondf7d:
CalcMonStats:
ld c, $00
.sub_df7f
.loop
inc c
call Functiondf91
ldh a, [hDividend+2]
call CalcMonStatC
ldh a, [hMultiplicand + 1]
ld [de], a
inc de
ldh a, [hDividend+3]
ldh a, [hMultiplicand + 2]
ld [de], a
inc de
ld a, c
cp $06
jr nz, .sub_df7f
cp STAT_SDEF
jr nz, .loop
ret
Functiondf91:
CalcMonStatC:
; 'c' is 1-6 and points to the BaseStat
; 1: HP
; 2: Attack
; 3: Defense
; 4: Speed
; 5: SpAtk
; 6: SpDef
push hl
push de
push bc
ld a, b
ld d, a
push hl
ld hl, wMonHBaseHP
ld hl, wMonHBaseStats
dec hl
ld b, $00
ld b, $0
add hl, bc
ld a, [hl]
ld e, a
pop hl
push hl
ld a, c
cp $06
jr nz, .sub_dfa9
; Special defense shares stat exp with special attack
cp STAT_SDEF
jr nz, .not_spdef
dec hl
dec hl
.sub_dfa9
.not_spdef
sla c
ld a, d
and a
jr z, .sub_dfce
jr z, .no_stat_exp
add hl, bc
.sub_dfb0
.sqrt_loop
xor a
ldh [hMultiplicand], a
ldh [hDividend+2], a
ldh [hMultiplicand + 1], a
inc b
ld a, b
cp $ff
jr z, .sub_dfce
ldh [hDividend+3], a
ldh [hDivisor], a
cp -1
jr z, .no_stat_exp
ldh [hMultiplicand + 2], a
ldh [hMultiplier], a
call Multiply
ld a, [hld]
ld d, a
ldh a, [hDividend+3]
ldh a, [hProduct + 3]
sub d
ld a, [hli]
ld d, a
ldh a, [hDividend+2]
ldh a, [hProduct + 2]
sbc d
jr c, .sub_dfb0
.sub_dfce
jr c, .sqrt_loop
.no_stat_exp
srl c
pop hl
push bc
ld bc, $000b
ld bc, MON_DVS - MON_HP_EXP + 1
add hl, bc
pop bc
ld a, c
cp $02
jr z, .sub_e00c
cp $03
jr z, .sub_e013
cp $04
jr z, .sub_e018
cp $05
jr z, .sub_e020
cp $06
jr z, .sub_e020
cp STAT_ATK
jr z, .Attack
cp STAT_DEF
jr z, .Defense
cp STAT_SPD
jr z, .Speed
cp STAT_SATK
jr z, .Special
cp STAT_SDEF
jr z, .Special
; DV_HP = (DV_ATK & 1) << 3 | (DV_DEF & 1) << 2 | (DV_SPD & 1) << 1 | (DV_SPC & 1)
push bc
ld a, [hl]
swap a
@ -1909,98 +1922,106 @@ Functiondf91:
and $01
add b
pop bc
jr .sub_e024
.sub_e00c
jr .GotDV
.Attack
ld a, [hl]
swap a
and $0f
jr .sub_e024
.sub_e013
and $f
jr .GotDV
.Defense
ld a, [hl]
and $0f
jr .sub_e024
.sub_e018
and $f
jr .GotDV
.Speed
inc hl
ld a, [hl]
swap a
and $0f
jr .sub_e024
.sub_e020
and $f
jr .GotDV
.Special
inc hl
ld a, [hl]
and $0f
.sub_e024
and $f
.GotDV
ld d, $00
add e
ld e, a
jr nc, .sub_e02b
jr nc, .no_overflow_1
inc d
.sub_e02b
.no_overflow_1
sla e
rl d
srl b
srl b
ld a, b
add e
jr nc, .sub_e038
jr nc, .no_overflow_2
inc d
.sub_e038
ldh [hDividend+3], a
.no_overflow_2
ldh [hMultiplicand + 2], a
ld a, d
ldh [hDividend+2], a
ldh [hMultiplicand + 1], a
xor a
ldh [hMultiplicand], a
ld a, [wCurPartyLevel]
ldh [hDivisor], a
ldh [hMultiplier], a
call Multiply
ldh a, [hMultiplicand]
ldh a, [hProduct + 1]
ldh [hDividend], a
ldh a, [hDividend+2]
ldh [hMultiplicand], a
ldh a, [hDividend+3]
ldh [hDividend+2], a
ld a, $64
ldh a, [hMultiplicand + 1]
ldh [hDividend + 1], a
ldh a, [hMultiplicand + 2]
ldh [hDividend + 2], a
ld a, MAX_LEVEL
ldh [hDivisor], a
ld a, $03
ld a, 3
ld b, a
call Divide
ld a, c
cp $01
ld a, $05
jr nz, .sub_e077
cp STAT_HP
ld a, STAT_MIN_NORMAL
jr nz, .not_hp
ld a, [wCurPartyLevel]
ld b, a
ldh a, [hDividend+3]
add b
ldh [hDividend+3], a
jr nc, .sub_e075
jr nc, .no_overflow_3
ldh a, [hDividend+2]
inc a
ldh [hDividend+2], a
.sub_e075
ld a, $0a
.sub_e077
.no_overflow_3
ld a, STAT_MIN_HP
.not_hp
ld b, a
ldh a, [hDividend+3]
add b
ldh [hDividend+3], a
jr nc, .sub_e084
jr nc, .no_overflow_4
ldh a, [hDividend+2]
inc a
ldh [hDividend+2], a
.sub_e084
.no_overflow_4
ldh a, [hDividend+2]
cp $04
cp HIGH(MAX_STAT_VALUE + 1) + 1
jr nc, .sub_e094
cp $03
cp HIGH(MAX_STAT_VALUE + 1)
jr c, .sub_e09c
ldh a, [hDividend+3]
cp $e8
cp LOW(MAX_STAT_VALUE + 1)
jr c, .sub_e09c
.sub_e094
ld a, $03
ld a, HIGH(MAX_STAT_VALUE)
ldh [hDividend+2], a
ld a, $e7
ld a, LOW(MAX_STAT_VALUE)
ldh [hDividend+3], a
.sub_e09c
pop bc
@ -3087,8 +3108,8 @@ PokeBallEffect:
ld d, a
push de
ld a, [wBattleMonItem]
ld hl, Function37e3d
ld a, BANK(Function37e3d)
ld hl, GetItemHeldEffect
ld a, BANK(GetItemHeldEffect)
call FarCall_hl
ld a, b
cp $46
@ -3154,7 +3175,7 @@ PokeBallEffect:
ld a, [hl]
push af
push hl
ld hl, wca44
ld hl, wEnemySubStatus5
bit 3, [hl]
jr z, .sub_ea48
ld a, $84
@ -3532,7 +3553,7 @@ Functionedab:
ld bc, $000a
add hl, bc
ld b, $01
predef_jump Functiondf7d
predef_jump CalcMonStats
Functionedbe:
xor a
@ -3724,9 +3745,9 @@ Functionef17:
jr nc, .sub_ef50
xor a
ld [wBattleMonStatus], a
ld hl, wca3f
ld hl, wPlayerSubStatus5
res 0, [hl]
ld hl, wca3b
ld hl, wPlayerSubStatus1
res 0, [hl]
ld a, $24
call GetPartyParamLocation
@ -3846,9 +3867,9 @@ Functionefee:
ld [hl], a
call Functionf113
jr nc, .sub_f049
ld hl, wca3f
ld hl, wPlayerSubStatus5
res 0, [hl]
ld hl, wca3b
ld hl, wPlayerSubStatus1
res 0, [hl]
xor a
ld [wBattleMonStatus], a
@ -4261,7 +4282,7 @@ Functionf2dc:
ld a, [wBattleMode]
and a
jp z, IsntTheTimeMessage
ld hl, wca3e
ld hl, wPlayerSubStatus4
set 0, [hl]
jp Functionf793
@ -4277,7 +4298,7 @@ Functionf2fa:
ld a, [wBattleMode]
and a
jp z, IsntTheTimeMessage
ld hl, wca3e
ld hl, wPlayerSubStatus4
set 1, [hl]
jp Functionf793
@ -4285,7 +4306,7 @@ Functionf309:
ld a, [wBattleMode]
and a
jp z, IsntTheTimeMessage
ld hl, wca3e
ld hl, wPlayerSubStatus4
set 2, [hl]
jp Functionf793

File diff suppressed because it is too large Load Diff

View File

@ -214,7 +214,7 @@ asm_3c1c4:
jp c, asm_3c132
xor a
ld [wce36], a
ld a, [wca3e]
ld a, [wPlayerSubStatus4]
and $60
jp nz, asm_3c281
ld hl, wEnemySubStatus3
@ -224,7 +224,7 @@ asm_3c1c4:
ld a, [hl]
and $12
jp nz, asm_3c281
ld hl, wca3b
ld hl, wPlayerSubStatus1
bit 6, [hl]
jp nz, asm_3c281
@ -234,7 +234,7 @@ asm_3c200:
ld a, [wce06]
and a
ret nz
ld hl, wca3f
ld hl, wPlayerSubStatus5
bit 4, [hl]
jr z, asm_3c246
ld a, [wca49]
@ -243,7 +243,7 @@ asm_3c200:
jr nz, asm_3c229
asm_3c219:
ld hl, wca3f
ld hl, wPlayerSubStatus5
res 4, [hl]
xor a
ldh [hBattleTurn], a
@ -288,7 +288,7 @@ asm_3c246:
asm_3c269:
xor a
ldh [hBattleTurn], a
callfar Function360b1
callfar UpdateMoveData
ld a, [wPlayerMoveStructEffect]
cp $77
jr z, asm_3c285
@ -369,9 +369,9 @@ asm_3c306:
asm_3c311:
xor a
ldh [hBattleTurn], a
callfar Function37e1d
callfar GetUserItem
push bc
callfar Function37e2d
callfar GetOpponentItem
pop de
ld a, d
cp $4a
@ -445,7 +445,7 @@ sub_3c399:
ld a, [wDebugFlags]
bit 0, a
jr nz, asm_3c3b6
ld a, [wca44]
ld a, [wEnemySubStatus5]
bit 7, a
jr nz, asm_3c3b6
call BattleRandom
@ -471,7 +471,7 @@ asm_3c3c7:
ldh [hBattleTurn], a
callfar Function38000
jr c, asm_3c3eb
callfar Function3401c
callfar DoEnemyTurn
call sub_3c473
ld a, [wce06]
and a
@ -483,7 +483,7 @@ asm_3c3eb:
call sub_3c498
jp z, asm_3c883
call DrawHUDsAndHPBars
callfar Function34000
callfar DoPlayerTurn
call sub_3c473
ld a, [wce06]
and a
@ -499,7 +499,7 @@ asm_3c3eb:
jp asm_3c183
asm_3c41d:
callfar Function34000
callfar DoPlayerTurn
call sub_3c473
ld a, [wce06]
and a
@ -513,7 +513,7 @@ asm_3c41d:
ldh [hBattleTurn], a
callfar Function38000
jr c, asm_3c460
callfar Function3401c
callfar DoEnemyTurn
call sub_3c473
ld a, [wce06]
and a
@ -531,13 +531,13 @@ asm_3c460:
jp asm_3c183
sub_3c473:
ld hl, wca44
ld de, wca40
ld hl, wEnemySubStatus5
ld de, wEnemySubStatus1
ldh a, [hBattleTurn]
and a
jr z, asm_3c484
ld hl, wca3f
ld de, wca3b
ld hl, wPlayerSubStatus5
ld de, wPlayerSubStatus1
asm_3c484:
res 6, [hl]
@ -585,12 +585,12 @@ asm_3c4b8:
ld [wNumHits], a
call PlayMoveAnimation
call sub_3c78b
ld hl, wca3f
ld hl, wPlayerSubStatus5
ld de, wca47
ldh a, [hBattleTurn]
and a
jr z, asm_3c4d8
ld hl, wca44
ld hl, wEnemySubStatus5
ld de, wca4f
asm_3c4d8:
@ -612,11 +612,11 @@ asm_3c4e8:
call sub_3c75e
asm_3c4eb:
ld hl, wca3e
ld hl, wPlayerSubStatus4
ldh a, [hBattleTurn]
and a
jr z, asm_3c4f6
ld hl, wca43
ld hl, wEnemySubStatus4
asm_3c4f6:
bit 7, [hl]
@ -638,11 +638,11 @@ asm_3c4f6:
call PrintText
asm_3c51d:
ld hl, wca3b
ld hl, wPlayerSubStatus1
ldh a, [hBattleTurn]
and a
jr z, asm_3c528
ld hl, wca40
ld hl, wEnemySubStatus1
asm_3c528:
bit 0, [hl]
@ -657,11 +657,11 @@ asm_3c528:
call PrintText
asm_3c542:
ld hl, wca3b
ld hl, wPlayerSubStatus1
ldh a, [hBattleTurn]
and a
jr z, asm_3c54d
ld hl, wca40
ld hl, wEnemySubStatus1
asm_3c54d:
bit 1, [hl]
@ -769,12 +769,12 @@ asm_3c632:
ret
sub_3c640:
ld hl, wca3b
ld hl, wPlayerSubStatus1
ld de, wca4a
ldh a, [hBattleTurn]
and a
jr z, asm_3c651
ld hl, wca40
ld hl, wEnemySubStatus1
ld de, wca52
asm_3c651:
@ -817,7 +817,7 @@ asm_3c682:
dec a
ret z
ld hl, wOTPartyMon1HP
ld a, [wca36]
ld a, [wCurOTMon]
ld bc, $30
call AddNTimes
xor a
@ -1152,7 +1152,7 @@ sub_3c8ca:
ld a, [wBattleMode]
dec a
jr z, asm_3c8e2
ld a, [wca36]
ld a, [wCurOTMon]
ld hl, wOTPartyMon1HP
ld bc, $30
call AddNTimes
@ -1169,7 +1169,7 @@ asm_3c8e2:
ld [hli], a
ld [hli], a
ld [hl], a
ld hl, wca40
ld hl, wEnemySubStatus1
ld [hli], a
ld [hli], a
ld [hli], a
@ -1357,7 +1357,7 @@ asm_3ca18:
asm_3ca51:
ld a, [wBattleMonItem]
ld b, a
callfar Function37e3d
callfar GetItemHeldEffect
ld a, b
cp $4c
jr nz, asm_3ca74
@ -1787,7 +1787,7 @@ FindMonInOTPartyToSwitchIntoBattle:
ld a, [wOTPartyCount]
cp b
jp z, ScoreMonTypeMatchups
ld a, [wca36]
ld a, [wCurOTMon]
cp b
jr z, .discourage
ld hl, wOTPartyMon1HP
@ -1941,7 +1941,7 @@ asm_3ced8:
cp 6
jr nc, asm_3ced8
ld b, a
ld a, [wca36]
ld a, [wCurOTMon]
cp b
jr z, asm_3ced8
ld hl, wOTPartyMon1HP
@ -2122,7 +2122,7 @@ sub_3d071:
ld hl, wCurEnemyMove
ld [hli], a
ld [hl], a
ld hl, wca40
ld hl, wEnemySubStatus1
ld [hli], a
ld [hli], a
ld [hli], a
@ -2181,7 +2181,7 @@ TryRunningFromBattle:
ld a, [wBattleMode]
dec a
jp nz, .trainer_battle
ld a, [wca3f]
ld a, [wPlayerSubStatus5]
bit 7, a
jp nz, .cannot_escape
push hl
@ -2189,7 +2189,7 @@ TryRunningFromBattle:
ld a, [wBattleMonItem]
ld [wNumSetBits], a
ld b, a
callfar Function37e3d
callfar GetItemHeldEffect
ld a, b
cp $48
pop de
@ -2444,7 +2444,7 @@ LoadEnemyMonFromParty:
dec b
jr nz, .stat_mod_loop
ld a, [wCurPartyMon]
ld [wca36], a
ld [wCurOTMon], a
ret
Function3d32e:
@ -2456,7 +2456,7 @@ Function3d32e:
ld hl, wStartmenuCursor
ld [hli], a
ld [hl], a
ld [wca38], a
ld [wTypeModifier], a
ld [wPlayerMoveStruct], a
ld b, 1
call GetSGBLayout
@ -2501,7 +2501,7 @@ sub_3d387:
ld hl, wCurPlayerMove
ld [hli], a
ld [hl], a
ld hl, wca3b
ld hl, wPlayerSubStatus1
ld [hli], a
ld [hli], a
ld [hli], a
@ -2598,7 +2598,7 @@ sub_3d42d:
ret
sub_3d43b:
callfar Function37e2d
callfar GetOpponentItem
ld a, b
cp 1
ret nz
@ -2670,11 +2670,11 @@ asm_3d4ac:
ld [wWhichHPBar], a
predef UpdateHPBar
call DrawHUDsAndHPBars
callfar Function37e2d
callfar GetOpponentItem
ld a, [hl]
ld [wNumSetBits], a
call GetItemName
callfar Function37e60
callfar ConsumeHeldItem
ld hl, RecoveredWithItemText
jp PrintText
@ -2726,7 +2726,7 @@ sub_3d51f:
sub_3d537:
ld hl, wOTPartyMon1Item
ld a, [wca36]
ld a, [wCurOTMon]
ld bc, $30
call AddNTimes
ld bc, wEnemyMonItem
@ -2741,7 +2741,7 @@ sub_3d54f:
push bc
ld a, [bc]
ld b, a
callfar Function37e3d
callfar GetItemHeldEffect
ld hl, Data3d59f
asm_3d560:
@ -3261,7 +3261,7 @@ sub_3d930:
ret
asm_3d982:
ld a, [wca3f]
ld a, [wPlayerSubStatus5]
bit 7, a
jr z, asm_3d992
ld hl, CantBringBackText
@ -3570,7 +3570,7 @@ asm_3dbe2:
dec a
cp c
jr z, asm_3dc15
ld a, [wca3f]
ld a, [wPlayerSubStatus5]
bit 3, a
jr nz, asm_3dc05
@ -3877,7 +3877,7 @@ asm_3dde3:
ld de, wNumSetBits
ld bc, $0102
call PrintNumber
callfar Function360b1
callfar UpdateMoveData
ld a, [wPlayerMoveStruct]
ld b, a
ld hl, $c3ef
@ -3917,7 +3917,7 @@ sub_3de6e:
jp asm_3df68
asm_3dea0:
ld hl, wca44
ld hl, wEnemySubStatus5
bit 4, [hl]
jr z, asm_3dedc
ld a, [wca51]
@ -3926,7 +3926,7 @@ asm_3dea0:
jr nz, asm_3dec1
asm_3deb0:
ld hl, wca44
ld hl, wEnemySubStatus5
res 4, [hl]
ld a, 1
ldh [hBattleTurn], a
@ -3950,14 +3950,14 @@ asm_3dec1:
jp asm_3df68
asm_3dedc:
ld a, [wca43]
ld a, [wEnemySubStatus4]
and $60
jp nz, asm_3df86
ld hl, wEnemySubStatus3
ld a, [hl]
and $12
jp nz, asm_3df86
ld hl, wca40
ld hl, wEnemySubStatus1
bit 6, [hl]
jp nz, asm_3df86
ld a, [wEnemySubStatus3]
@ -4035,7 +4035,7 @@ asm_3df68:
asm_3df6b:
ld a, 1
ldh [hBattleTurn], a
callfar Function360b1
callfar UpdateMoveData
ld a, [wEnemyMoveStructEffect]
cp $77
ret z
@ -4117,12 +4117,12 @@ asm_3dff2:
ld a, [wCurEnemySelectedMove]
asm_3e009:
cp $44
cp MOVE_COUNTER
ret nz
ld a, 1
ld [wca3a], a
ld a, [hl]
cp $44
cp MOVE_COUNTER
ret z
ld a, [de]
and a
@ -4137,7 +4137,7 @@ asm_3e009:
ret
asm_3e023:
ld hl, wce29
ld hl, wCurDamage
ld a, [hli]
or [hl]
ret z
@ -4187,7 +4187,7 @@ asm_3e06f:
asm_3e07b:
ld [wEnemyMonItem], a
ld a, [wca44]
ld a, [wEnemySubStatus5]
bit 3, a
ld hl, wcad0
ld a, [hli]
@ -4211,11 +4211,11 @@ asm_3e09c:
ld de, wEnemyMonMaxHP
ld b, 0
ld hl, wcdd4
predef Functiondf7d
predef CalcMonStats
ld a, [wBattleMode]
cp 2
jr z, asm_3e0d2
ld a, [wca44]
ld a, [wEnemySubStatus5]
bit 3, a
jr nz, asm_3e0f1
ld hl, wEnemyMonStatus
@ -4238,7 +4238,7 @@ asm_3e0d2:
ld a, [hld]
ld [wEnemyMonHP], a
ld a, [wCurPartyMon]
ld [wca36], a
ld [wCurOTMon], a
dec hl
ld a, [hl]
ld [wEnemyMonStatus], a
@ -4341,10 +4341,10 @@ Function3e1a4:
Function3e1aa:
ldh a, [hBattleTurn]
and a
ld a, [wca3b]
ld a, [wPlayerSubStatus1]
ld hl, wBattleMonAttack + 1
jr z, asm_3e1bb
ld a, [wca40]
ld a, [wEnemySubStatus1]
ld hl, wEnemyMonAttack + 1
asm_3e1bb:
@ -4372,10 +4372,10 @@ sub_3e1c9:
asm_3e1d1:
ldh a, [hBattleTurn]
and a
ld a, [wca3c]
ld a, [wPlayerSubStatus2]
ld hl, wBattleMonAttack
jr z, asm_3e1e2
ld a, [wca41]
ld a, [wEnemySubStatus2]
ld hl, wEnemyMonAttack
asm_3e1e2:
@ -4946,7 +4946,7 @@ asm_3e507:
add hl, bc
push bc
ld b, 1
predef Functiondf7d
predef CalcMonStats
pop bc
pop de
ld hl, $25
@ -4984,7 +4984,7 @@ asm_3e507:
add hl, bc
ld a, [hl]
ld [wBattleMonLevel], a
ld a, [wca3f]
ld a, [wPlayerSubStatus5]
bit 3, a
jr nz, asm_3e5ae
ld hl, $26
@ -5482,7 +5482,7 @@ asm_3e91d:
ret
Function3e91e:
ld a, [wca3e]
ld a, [wPlayerSubStatus4]
bit 4, a
ld hl, Functioncc44f
jr nz, asm_3e954
@ -5516,7 +5516,7 @@ asm_3e954:
ret
Function3e963:
ld a, [wca43]
ld a, [wEnemySubStatus4]
bit 4, a
ld hl, Functioncc44f
jr nz, asm_3e999
@ -5912,7 +5912,7 @@ asm_3efb8:
ld bc, $0707
predef PlaceGraphic
ld a, $ff
ld [wca36], a
ld [wCurOTMon], a
ld a, 2
ld [wBattleMode], a
ret
@ -6109,7 +6109,7 @@ InitBattleVariables:
ld [hli], a
ld [hl], a
ld [wMenuScrollPosition], a
ld [wca39], a
ld [wCriticalHit], a
ld [wBattleMonSpecies], a
ld [wca37], a
ld [wCurBattleMon], a
@ -6180,7 +6180,7 @@ asm_3f15a:
ld [hli], a
ld [hl], a
ld [wMenuScrollPosition], a
ld hl, wca3b
ld hl, wPlayerSubStatus1
ld b, $18
.clear
ld [hli], a
@ -6205,7 +6205,7 @@ sub_3f19e:
ret z
ld a, [wBattleMonItem]
ld b, a
callfar Function37e3d
callfar GetItemHeldEffect
ld a, b
cp $4c
jr nz, AddBattleMoneyToAccount
@ -6246,7 +6246,7 @@ GotMoneyForWinningText:
prompt
sub_3f1f3:
ld a, [wca36]
ld a, [wCurOTMon]
ld hl, wOTPartyMon1Status
ld bc, $30
call AddNTimes

View File

@ -353,7 +353,7 @@ Function502b5::
ld hl, wTempMonExp + 2
ld de, wTempMonMaxHP
ld b, 1
predef Functiondf7d
predef CalcMonStats
.asm_502d9
ld hl, wd4a7
set 1, [hl]

View File

@ -57,7 +57,7 @@ SGB_BattleColors:
ld bc, PALPACKET_LENGTH
call CopyBytes
ld a, [wca3f]
ld a, [wPlayerSubStatus5]
ld hl, wBattleMon
call Function9567
jr c, .sub_92f7
@ -66,7 +66,7 @@ SGB_BattleColors:
call Function9599
.sub_92f7
ld b, a
ld a, [wca44]
ld a, [wEnemySubStatus5]
ld hl, wTempEnemyMonSpecies
call Function9567
jr c, .sub_9308

View File

@ -289,7 +289,7 @@ AddRandomPokemonToBox:
.loop
push af
xor a
ld [wca44], a
ld [wEnemySubStatus5], a
call RandomUnder246
ld [wTempEnemyMonSpecies], a
ld a, $05

View File

@ -13,7 +13,7 @@ Function1130b:
cp MONS_PER_BOX
jr nc, .fullbox
xor a
ld [wca44], a
ld [wEnemySubStatus5], a
ld a, [wCurPartySpecies]
ld [wTempEnemyMonSpecies], a
callfar AddPokemonToBox

View File

@ -253,7 +253,7 @@ ROMX $0c
ROMX $0d
org $4000
"engine/dumps/bank0d.asm@Function34000"
"engine/dumps/bank0d.asm@DoPlayerTurn"
ROMX $0e
org $4000

186
macros/battle_commands.asm Normal file
View File

@ -0,0 +1,186 @@
MACRO command
const \1_command
DEF \1 EQUS "db \1_command"
ENDM
; BattleCommandPointers indexes (see data/battle/effect_command_pointers.asm)
const_def 1
command checkturn ; 01
command checkobedience ; 02
command usedmovetext ; 03
command doturn ; 04
command critical ; 05
command damagestats ; 06
command stab ; 07
command damagevariation ; 08
command checkhit ; 09
command lowersub ; 0a
command moveanimnosub ; 0b
command raisesub ; 0c
command failuretext ; 0d
command applydamage ; 0e
command criticaltext ; 0f
command supereffectivetext ; 10
command checkfaint ; 11
command buildopponentrage ; 12
command poisontarget ; 13
command sleeptarget ; 14
command draintarget ; 15
command eatdream ; 16
command burntarget ; 17
command freezetarget ; 18
command paralyzetarget ; 19
command selfdestruct ; 1a
command mirrormove ; 1b
command statup ; 1c
command statdown ; 1d
command payday ; 1e
command conversion ; 1f
command resetstats ; 20
command storeenergy ; 21
command unleashenergy ; 22
command forceswitch ; 23
command endloop ; 24
command flinchtarget ; 25
command ohko ; 26
command recoil ; 27
command mist ; 28
command focusenergy ; 29
command confuse ; 2a
command confusetarget ; 2b
command heal ; 2c
command transform ; 2d
command screen ; 2e
command poison ; 2f
command paralyze ; 30
command substitute ; 31
command rechargenextturn ; 32
command mimic ; 33
command metronome ; 34
command leechseed ; 35
command splash ; 36
command disable ; 37
command cleartext ; 38
command charge ; 39
command checkcharge ; 3a
command traptarget ; 3b
command effect0x3c ; 3c
command rampage ; 3d
command checkrampage ; 3e
command constantdamage ; 3f
command counter ; 40
command encore ; 41
command painsplit ; 42
command snore ; 43
command conversion2 ; 44
command lockon ; 45
command sketch ; 46
command defrostopponent ; 47
command sleeptalk ; 48
command destinybond ; 49
command spite ; 4a
command falseswipe ; 4b
command healbell ; 4c
command kingsrock ; 4d
command triplekick ; 4e
command kickcounter ; 4f
command thief ; 50
command arenatrap ; 51
command nightmare ; 52
command defrost ; 53
command curse ; 54
command protect ; 55
command spikes ; 56
command foresight ; 57
command perishsong ; 58
command startsandstorm ; 59
command endure ; 5a
command checkcurl ; 5b
command rolloutpower ; 5c
command effect0x5d ; 5d
command furycutter ; 5e
command attract ; 5f
command happinesspower ; 60
command present ; 61
command damagecalc ; 62
command frustrationpower ; 63
command safeguard ; 64
command checksafeguard ; 65
command getmagnitude ; 66
command batonpass ; 67
command pursuit ; 68
command clearhazards ; 69
command healmorn ; 6a
command healday ; 6b
command healnite ; 6c
command hiddenpower ; 6d
command startrain ; 6e
command startsun ; 6f
command attackup ; 70
command defenseup ; 71
command speedup ; 72
command specialattackup ; 73
command specialdefenseup ; 74
command accuracyup ; 75
command evasionup ; 76
command attackup2 ; 77
command defenseup2 ; 78
command speedup2 ; 79
command specialattackup2 ; 7a
command specialdefenseup2 ; 7b
command accuracyup2 ; 7c
command evasionup2 ; 7d
command attackdown ; 7e
command defensedown ; 7f
command speeddown ; 80
command specialattackdown ; 81
command specialdefensedown ; 82
command accuracydown ; 83
command evasiondown ; 84
command attackdown2 ; 85
command defensedown2 ; 86
command speeddown2 ; 87
command specialattackdown2 ; 88
command specialdefensedown2 ; 89
command accuracydown2 ; 8a
command evasiondown2 ; 8b
command statupmessage ; 8c
command statdownmessage ; 8d
command statupfailtext ; 8e
command statdownfailtext ; 8f
command effectchance ; 90
command statdownanim ; 91
command statupanim ; 92
command switchturn ; 93
command fakeout ; 94
command bellydrum ; 95
command psychup ; 96
command rage ; 97
command doubleflyingdamage ; 98
command doubleundergrounddamage ; 99
command mirrorcoat ; 9a
command checkfuturesight ; 9b
command futuresight ; 9c
command doubleminimizedamage ; 9d
command skipsuncharge ; 9e
command thunderaccuracy ; 9f
command teleport ; a0
command beatup ; a1
command ragedamage ; a2
command resettypematchup ; a3
command allstatsup ; a4
command bidefailtext ; a5
command raisesubnoanim ; a6
command lowersubnoanim ; a7
command beatupfailtext ; a8
command clearmissdamage ; a9
command movedelay ; aa
command moveanim ; ab
command tristatuschance ; ac
command supereffectivelooptext ; ad
command startloop ; ae
command curl ; af
DEF NUM_EFFECT_COMMANDS EQU const_value - 1
const_def -1, -1
command endmove ; ff

View File

@ -400,25 +400,36 @@ wca24:: ds 1
ds 6
wca2b:: ds 1
ds 10
wca36:: ds 1
wCurOTMon:: db
wca37:: ds 1
wca38:: ds 1
wca39:: ds 1
wTypeModifier::
; >10: super-effective
; 10: normal
; <10: not very effective
; bit 7: stab
db
wCriticalHit::
; 0 if not critical
; 1 for a critical hit
; 2 for a OHKO
db
wca3a:: ds 1
wca3b:: ds 1
wca3c:: ds 1
wPlayerSubStatus1:: db
wPlayerSubStatus2:: db
wPlayerSubStatus3:: db
wPlayerSubStatus4:: db
wPlayerSubStatus5:: db
wca3e:: ds 1
wca3f:: ds 1
wca40:: ds 1
wca41:: ds 1
wEnemySubStatus1:: db
wEnemySubStatus2:: db
wEnemySubStatus3:: db
wEnemySubStatus4:: db
wEnemySubStatus5:: db
wca43:: db
wca44:: db
wca45:: db
wca46:: db
wca47:: db
@ -460,7 +471,7 @@ wca5d:: ds 1
wca7b:: ds 1
wca7c:: ds 1
wca7d:: ds 1
wTurnEnded:: db
ds $15
@ -554,8 +565,13 @@ wcad9:: ds 1
wcada:: ds 1
wcadb:: ds 1
wcadc:: ds 1
wPlayerScreens::
wcadd:: ds 1
wEnemyScreens::
wcade:: ds 1
wcadf:: ds 1
wcae0:: ds 1
wcae1:: ds 1
@ -877,11 +893,15 @@ SECTION "CD3C", WRAM0[$CD3C]
wcd3c:: db
wRegularItemsCursor:: db
wBackpackAndKeyItemsCursor:: db
wBattleMenuCursorPosition::
wStartmenuCursor:: db
wcd40:: db
wCurBattleMon::
wcd41:: db
wcd42:: db
wFieldDebugMenuCursorBuffer::
wcd43:: db
@ -914,8 +934,12 @@ wNumMoves::
wcd57:: ds 1
wItemEffectSucceeded::
wBattlePlayerAction::
wFieldMoveSucceeded:: db
wFieldMoveSucceeded::
; 0 - use move
; 1 - use item
; 2 - switch
wBattlePlayerAction:: db
wVramState:: db
ds 3 ; TODO
@ -1125,8 +1149,8 @@ wce26:: ds 1
ds 2
wce29:: ds 1
wce2a:: ds 1
wCurDamage:: dw
;wce2a:: ds 1
ds 2