This commit is contained in:
dannye 2021-03-23 00:53:43 -05:00
commit e8dd755e18
3702 changed files with 163333 additions and 159040 deletions

796
engine/battle/animations.asm Executable file → Normal file

File diff suppressed because it is too large Load diff

View file

@ -1,17 +1,17 @@
BattleTransition:
ld a, 1
ld [H_AUTOBGTRANSFERENABLED], a
ldh [hAutoBGTransferEnabled], a
call Delay3
xor a
ld [hWY], a
ldh [hWY], a
dec a
ld [wUpdateSpritesEnabled], a
call DelayFrame
; Determine which OAM block is being used by the enemy trainer sprite (if there
; is one).
ld hl, wSpriteStateData1 + 2
ld a, [hSpriteIndexOrTextID] ; enemy trainer sprite index (0 if wild battle)
ld hl, wSpritePlayerStateData1ImageIndex
ldh a, [hSpriteIndexOrTextID] ; enemy trainer sprite index (0 if wild battle)
ld c, a
ld b, 0
ld de, $10
@ -82,7 +82,7 @@ BattleTransitions:
GetBattleTransitionID_WildOrTrainer:
ld a, [wCurOpponent]
cp 200
cp OPP_ID_OFFSET
jr nc, .trainer
res 0, c
ret
@ -118,9 +118,6 @@ GetBattleTransitionID_CompareLevels:
ld [wBattleTransitionSpiralDirection], a
ret
; fails to recognize VICTORY_ROAD_2F, VICTORY_ROAD_3F, all ROCKET_HIDEOUT maps,
; POKEMON_MANSION_1F, SEAFOAM_ISLANDS_[B1F-B4F], POWER_PLANT, DIGLETTS_CAVE
; and SILPH_CO_[9-11]F as dungeon maps
GetBattleTransitionID_IsDungeonMap:
ld a, [wCurMap]
ld e, a
@ -151,51 +148,21 @@ GetBattleTransitionID_IsDungeonMap:
res 2, c
ret
; GetBattleTransitionID_IsDungeonMap checks if wCurMap
; is equal to one of these maps
DungeonMaps1:
db VIRIDIAN_FOREST
db ROCK_TUNNEL_1F
db SEAFOAM_ISLANDS_1F
db ROCK_TUNNEL_B1F
db $FF
; GetBattleTransitionID_IsDungeonMap checks if wCurMap
; is in between or equal to each pair of maps
DungeonMaps2:
; all MT_MOON maps
db MT_MOON_1F
db MT_MOON_B2F
; all SS_ANNE maps, VICTORY_ROAD_1F, LANCES_ROOM, and HALL_OF_FAME
db SS_ANNE_1F
db HALL_OF_FAME
; all POKEMON_TOWER maps and Lavender Town buildings
db LAVENDER_POKECENTER
db LAVENDER_CUBONE_HOUSE
; SILPH_CO_[2-8]F, POKEMON_MANSION[2F-B1F], SAFARI_ZONE, and
; CERULEAN_CAVE maps, except for SILPH_CO_1F
db SILPH_CO_2F
db CERULEAN_CAVE_1F
db $FF
INCLUDE "data/maps/dungeon_maps.asm"
LoadBattleTransitionTile:
ld hl, vChars1 + $7f0
ld hl, vChars1 tile $7f
ld de, BattleTransitionTile
lb bc, BANK(BattleTransitionTile), (BattleTransitionTileEnd - BattleTransitionTile) / $10
lb bc, BANK(BattleTransitionTile), 1
jp CopyVideoData
BattleTransitionTile:
INCBIN "gfx/battle_transition.2bpp"
BattleTransitionTileEnd:
BattleTransitionTile: INCBIN "gfx/overworld/battle_transition.2bpp"
BattleTransition_BlackScreen:
ld a, $ff
ld [rBGP], a
ld [rOBP0], a
ld [rOBP1], a
ldh [rBGP], a
ldh [rOBP0], a
ldh [rOBP1], a
ret
; for non-dungeon trainer battles
@ -209,7 +176,7 @@ BattleTransition_Spiral:
call BattleTransition_InwardSpiral
jr .done
.outwardSpiral
coord hl, 10, 10
hlcoord 10, 10
ld a, $3
ld [wOutwardSpiralCurrentDirection], a
ld a, l
@ -238,7 +205,7 @@ BattleTransition_Spiral:
BattleTransition_InwardSpiral:
ld a, 7
ld [wInwardSpiralUpdateScreenCounter], a
coord hl, 0, 0
hlcoord 0, 0
ld c, SCREEN_HEIGHT - 1
ld de, SCREEN_WIDTH
call BattleTransition_InwardSpiral_
@ -356,9 +323,9 @@ BattleTransition_FlashScreen_:
ld hl, BattleTransition_FlashScreenPalettes
.loop
ld a, [hli]
cp $1
cp 1
jr z, .done
ld [rBGP], a
ldh [rBGP], a
ld c, 2
call DelayFrames
jr .loop
@ -368,8 +335,19 @@ BattleTransition_FlashScreen_:
ret
BattleTransition_FlashScreenPalettes:
db $F9,$FE,$FF,$FE,$F9,$E4,$90,$40,$00,$40,$90,$E4
db $01 ; terminator
db %11111001
db %11111110
db %11111111
db %11111110
db %11111001
db %11100100
db %10010000
db %01000000
db %00000000
db %01000000
db %10010000
db %11100100
db 1 ; end
; used for low level trainer dungeon battles
BattleTransition_Shrink:
@ -377,25 +355,25 @@ BattleTransition_Shrink:
.loop
push bc
xor a
ld [H_AUTOBGTRANSFERENABLED], a
coord hl, 0, 7
coord de, 0, 8
ldh [hAutoBGTransferEnabled], a
hlcoord 0, 7
decoord 0, 8
ld bc, -SCREEN_WIDTH * 2
call BattleTransition_CopyTiles1
coord hl, 0, 10
coord de, 0, 9
hlcoord 0, 10
decoord 0, 9
ld bc, SCREEN_WIDTH * 2
call BattleTransition_CopyTiles1
coord hl, 8, 0
coord de, 9, 0
hlcoord 8, 0
decoord 9, 0
ld bc, -2
call BattleTransition_CopyTiles2
coord hl, 11, 0
coord de, 10, 0
hlcoord 11, 0
decoord 10, 0
ld bc, 2
call BattleTransition_CopyTiles2
ld a, $1
ld [H_AUTOBGTRANSFERENABLED], a
ldh [hAutoBGTransferEnabled], a
ld c, 6
call DelayFrames
pop bc
@ -409,23 +387,23 @@ BattleTransition_Shrink:
BattleTransition_Split:
ld c, SCREEN_HEIGHT / 2
xor a
ld [H_AUTOBGTRANSFERENABLED], a
ldh [hAutoBGTransferEnabled], a
.loop
push bc
coord hl, 0, 16
coord de, 0, 17
hlcoord 0, 16
decoord 0, 17
ld bc, -SCREEN_WIDTH * 2
call BattleTransition_CopyTiles1
coord hl, 0, 1
coord de, 0, 0
hlcoord 0, 1
decoord 0, 0
ld bc, SCREEN_WIDTH * 2
call BattleTransition_CopyTiles1
coord hl, 18, 0
coord de, 19, 0
hlcoord 18, 0
decoord 19, 0
ld bc, -2
call BattleTransition_CopyTiles2
coord hl, 1, 0
coord de, 0, 0
hlcoord 1, 0
decoord 0, 0
ld bc, 2
call BattleTransition_CopyTiles2
call BattleTransition_TransferDelay3
@ -521,10 +499,10 @@ BattleTransition_CopyTiles2:
; used for high level wild dungeon battles
BattleTransition_VerticalStripes:
ld c, SCREEN_HEIGHT
coord hl, 0, 0
coord de, 1, 17
hlcoord 0, 0
decoord 1, 17
xor a
ld [H_AUTOBGTRANSFERENABLED], a
ldh [hAutoBGTransferEnabled], a
.loop
push bc
push hl
@ -560,10 +538,10 @@ BattleTransition_VerticalStripes_:
; used for low level wild dungeon battles
BattleTransition_HorizontalStripes:
ld c, SCREEN_WIDTH
coord hl, 0, 0
coord de, 19, 1
hlcoord 0, 0
decoord 19, 1
xor a
ld [H_AUTOBGTRANSFERENABLED], a
ldh [hAutoBGTransferEnabled], a
.loop
push bc
push hl
@ -610,7 +588,7 @@ BattleTransition_FlashScreen:
ld b, $3
call BattleTransition_FlashScreen_
xor a
ld [H_AUTOBGTRANSFERENABLED], a
ldh [hAutoBGTransferEnabled], a
ret
BattleTransition_Circle_Sub1:
@ -629,10 +607,10 @@ BattleTransition_Circle_Sub1:
BattleTransition_TransferDelay3:
ld a, 1
ld [H_AUTOBGTRANSFERENABLED], a
ldh [hAutoBGTransferEnabled], a
call Delay3
xor a
ld [H_AUTOBGTRANSFERENABLED], a
ldh [hAutoBGTransferEnabled], a
ret
; used for low level wild non-dungeon battles
@ -679,87 +657,41 @@ BattleTransition_Circle_Sub2:
ld l, a
jp BattleTransition_Circle_Sub3
; halves
const_def
const CIRCLE_LEFT
const CIRCLE_RIGHT
half_circle: MACRO
; quadrant x, circle data, target coord
db \1
dw \2
dwcoord \3, \4
ENDM
BattleTransition_HalfCircle1:
db $01
dw BattleTransition_CircleData1
dwCoord 18, 6
db $01
dw BattleTransition_CircleData2
dwCoord 19, 3
db $01
dw BattleTransition_CircleData3
dwCoord 18, 0
db $01
dw BattleTransition_CircleData4
dwCoord 14, 0
db $01
dw BattleTransition_CircleData5
dwCoord 10, 0
db $00
dw BattleTransition_CircleData5
dwCoord 9, 0
db $00
dw BattleTransition_CircleData4
dwCoord 5, 0
db $00
dw BattleTransition_CircleData3
dwCoord 1, 0
db $00
dw BattleTransition_CircleData2
dwCoord 0, 3
db $00
dw BattleTransition_CircleData1
dwCoord 1, 6
half_circle CIRCLE_RIGHT, BattleTransition_CircleData1, 18, 6
half_circle CIRCLE_RIGHT, BattleTransition_CircleData2, 19, 3
half_circle CIRCLE_RIGHT, BattleTransition_CircleData3, 18, 0
half_circle CIRCLE_RIGHT, BattleTransition_CircleData4, 14, 0
half_circle CIRCLE_RIGHT, BattleTransition_CircleData5, 10, 0
half_circle CIRCLE_LEFT, BattleTransition_CircleData5, 9, 0
half_circle CIRCLE_LEFT, BattleTransition_CircleData4, 5, 0
half_circle CIRCLE_LEFT, BattleTransition_CircleData3, 1, 0
half_circle CIRCLE_LEFT, BattleTransition_CircleData2, 0, 3
half_circle CIRCLE_LEFT, BattleTransition_CircleData1, 1, 6
BattleTransition_HalfCircle2:
db $00
dw BattleTransition_CircleData1
dwCoord 1, 11
db $00
dw BattleTransition_CircleData2
dwCoord 0, 14
db $00
dw BattleTransition_CircleData3
dwCoord 1, 17
db $00
dw BattleTransition_CircleData4
dwCoord 5, 17
db $00
dw BattleTransition_CircleData5
dwCoord 9, 17
db $01
dw BattleTransition_CircleData5
dwCoord 10, 17
db $01
dw BattleTransition_CircleData4
dwCoord 14, 17
db $01
dw BattleTransition_CircleData3
dwCoord 18, 17
db $01
dw BattleTransition_CircleData2
dwCoord 19, 14
db $01
dw BattleTransition_CircleData1
dwCoord 18, 11
half_circle CIRCLE_LEFT, BattleTransition_CircleData1, 1, 11
half_circle CIRCLE_LEFT, BattleTransition_CircleData2, 0, 14
half_circle CIRCLE_LEFT, BattleTransition_CircleData3, 1, 17
half_circle CIRCLE_LEFT, BattleTransition_CircleData4, 5, 17
half_circle CIRCLE_LEFT, BattleTransition_CircleData5, 9, 17
half_circle CIRCLE_RIGHT, BattleTransition_CircleData5, 10, 17
half_circle CIRCLE_RIGHT, BattleTransition_CircleData4, 14, 17
half_circle CIRCLE_RIGHT, BattleTransition_CircleData3, 18, 17
half_circle CIRCLE_RIGHT, BattleTransition_CircleData2, 19, 14
half_circle CIRCLE_RIGHT, BattleTransition_CircleData1, 18, 11
BattleTransition_Circle_Sub3:
push hl
@ -788,7 +720,7 @@ BattleTransition_Circle_Sub3:
add hl, bc
ld a, [de]
inc de
cp $ff
cp -1
ret z
and a
jr z, BattleTransition_Circle_Sub3
@ -806,17 +738,8 @@ BattleTransition_Circle_Sub3:
jr nz, .loop2
jr BattleTransition_Circle_Sub3
BattleTransition_CircleData1:
db $02,$03,$05,$04,$09,$FF
BattleTransition_CircleData2:
db $01,$01,$02,$02,$04,$02,$04,$02,$03,$FF
BattleTransition_CircleData3:
db $02,$01,$03,$01,$04,$01,$04,$01,$04,$01,$03,$01,$02,$01,$01,$01,$01,$FF
BattleTransition_CircleData4:
db $04,$01,$04,$00,$03,$01,$03,$00,$02,$01,$02,$00,$01,$FF
BattleTransition_CircleData5:
db $04,$00,$03,$00,$03,$00,$02,$00,$02,$00,$01,$00,$01,$00,$01,$FF
BattleTransition_CircleData1: db 2, 3, 5, 4, 9, -1
BattleTransition_CircleData2: db 1, 1, 2, 2, 4, 2, 4, 2, 3, -1
BattleTransition_CircleData3: db 2, 1, 3, 1, 4, 1, 4, 1, 4, 1, 3, 1, 2, 1, 1, 1, 1, -1
BattleTransition_CircleData4: db 4, 1, 4, 0, 3, 1, 3, 0, 2, 1, 2, 0, 1, -1
BattleTransition_CircleData5: db 4, 0, 3, 0, 3, 0, 2, 0, 2, 0, 1, 0, 1, 0, 1, -1

View file

@ -5,7 +5,7 @@ PrintBeginningBattleText:
ld a, [wCurMap]
cp POKEMON_TOWER_3F
jr c, .notPokemonTower
cp MR_FUJIS_HOUSE
cp POKEMON_TOWER_7F + 1
jr c, .pokemonTower
.notPokemonTower
ld a, [wEnemyMonSpecies2]
@ -24,7 +24,7 @@ PrintBeginningBattleText:
ld hl, TrainerWantsToFightText
.wildBattle
push hl
callab DrawAllPokeballs
callfar DrawAllPokeballs
pop hl
call PrintText
jr .done
@ -33,12 +33,12 @@ PrintBeginningBattleText:
call IsItemInBag
ld a, [wEnemyMonSpecies2]
ld [wcf91], a
cp MAROWAK
cp RESTLESS_SOUL
jr z, .isMarowak
ld a, b
and a
jr z, .noSilphScope
callab LoadEnemyMonData
callfar LoadEnemyMonData
jr .notPokemonTower
.noSilphScope
ld hl, EnemyAppearedText
@ -54,8 +54,8 @@ PrintBeginningBattleText:
call PrintText
ld hl, UnveiledGhostText
call PrintText
callab LoadEnemyMonData
callab MarowakAnim
callfar LoadEnemyMonData
callfar MarowakAnim
ld hl, WildMonAppearedText
call PrintText
@ -71,28 +71,28 @@ PrintBeginningBattleText:
ret
WildMonAppearedText:
TX_FAR _WildMonAppearedText
db "@"
text_far _WildMonAppearedText
text_end
HookedMonAttackedText:
TX_FAR _HookedMonAttackedText
db "@"
text_far _HookedMonAttackedText
text_end
EnemyAppearedText:
TX_FAR _EnemyAppearedText
db "@"
text_far _EnemyAppearedText
text_end
TrainerWantsToFightText:
TX_FAR _TrainerWantsToFightText
db "@"
text_far _TrainerWantsToFightText
text_end
UnveiledGhostText:
TX_FAR _UnveiledGhostText
db "@"
text_far _UnveiledGhostText
text_end
GhostCantBeIDdText:
TX_FAR _GhostCantBeIDdText
db "@"
text_far _GhostCantBeIDdText
text_end
PrintSendOutMonMessage:
ld hl, wEnemyMonHP
@ -101,16 +101,16 @@ PrintSendOutMonMessage:
ld hl, GoText
jr z, .printText
xor a
ld [H_MULTIPLICAND], a
ldh [hMultiplicand], a
ld hl, wEnemyMonHP
ld a, [hli]
ld [wLastSwitchInEnemyMonHP], a
ld [H_MULTIPLICAND + 1], a
ldh [hMultiplicand + 1], a
ld a, [hl]
ld [wLastSwitchInEnemyMonHP + 1], a
ld [H_MULTIPLICAND + 2], a
ldh [hMultiplicand + 2], a
ld a, 25
ld [H_MULTIPLIER], a
ldh [hMultiplier], a
call Multiply
ld hl, wEnemyMonMaxHP
ld a, [hli]
@ -121,9 +121,9 @@ PrintSendOutMonMessage:
rr b
ld a, b
ld b, 4
ld [H_DIVISOR], a ; enemy mon max HP divided by 4
ldh [hDivisor], a ; enemy mon max HP divided by 4
call Divide
ld a, [H_QUOTIENT + 3] ; a = (enemy mon current HP * 25) / (enemy max HP / 4); this approximates the current percentage of max HP
ldh a, [hQuotient + 3] ; a = (enemy mon current HP * 25) / (enemy max HP / 4); this approximates the current percentage of max HP
ld hl, GoText ; 70% or greater
cp 70
jr nc, .printText
@ -138,39 +138,39 @@ PrintSendOutMonMessage:
jp PrintText
GoText:
TX_FAR _GoText
TX_ASM
text_far _GoText
text_asm
jr PrintPlayerMon1Text
DoItText:
TX_FAR _DoItText
TX_ASM
text_far _DoItText
text_asm
jr PrintPlayerMon1Text
GetmText:
TX_FAR _GetmText
TX_ASM
text_far _GetmText
text_asm
jr PrintPlayerMon1Text
EnemysWeakText:
TX_FAR _EnemysWeakText
TX_ASM
text_far _EnemysWeakText
text_asm
PrintPlayerMon1Text:
ld hl, PlayerMon1Text
ret
PlayerMon1Text:
TX_FAR _PlayerMon1Text
db "@"
text_far _PlayerMon1Text
text_end
RetreatMon:
ld hl, PlayerMon2Text
jp PrintText
PlayerMon2Text:
TX_FAR _PlayerMon2Text
TX_ASM
text_far _PlayerMon2Text
text_asm
push de
push bc
ld hl, wEnemyMonHP + 1
@ -179,14 +179,14 @@ PlayerMon2Text:
dec hl
ld a, [de]
sub b
ld [H_MULTIPLICAND + 2], a
ldh [hMultiplicand + 2], a
dec de
ld b, [hl]
ld a, [de]
sbc b
ld [H_MULTIPLICAND + 1], a
ldh [hMultiplicand + 1], a
ld a, 25
ld [H_MULTIPLIER], a
ldh [hMultiplier], a
call Multiply
ld hl, wEnemyMonMaxHP
ld a, [hli]
@ -197,11 +197,11 @@ PlayerMon2Text:
rr b
ld a, b
ld b, 4
ld [H_DIVISOR], a
ldh [hDivisor], a
call Divide
pop bc
pop de
ld a, [H_QUOTIENT + 3] ; a = ((LastSwitchInEnemyMonHP - CurrentEnemyMonHP) / 25) / (EnemyMonMaxHP / 4)
ldh a, [hQuotient + 3] ; a = ((LastSwitchInEnemyMonHP - CurrentEnemyMonHP) / 25) / (EnemyMonMaxHP / 4)
; Assuming that the enemy mon hasn't gained HP since the last switch in,
; a approximates the percentage that the enemy mon's total HP has decreased
; since the last switch in.
@ -220,18 +220,18 @@ PlayerMon2Text:
ret
EnoughText:
TX_FAR _EnoughText
TX_ASM
text_far _EnoughText
text_asm
jr PrintComeBackText
OKExclamationText:
TX_FAR _OKExclamationText
TX_ASM
text_far _OKExclamationText
text_asm
jr PrintComeBackText
GoodText:
TX_FAR _GoodText
TX_ASM
text_far _GoodText
text_asm
jr PrintComeBackText
PrintComeBackText:
@ -239,5 +239,5 @@ PrintComeBackText:
ret
ComeBackText:
TX_FAR _ComeBackText
db "@"
text_far _ComeBackText
text_end

2860
engine/battle/core.asm Executable file → Normal file

File diff suppressed because it is too large Load diff

View file

@ -37,7 +37,7 @@ DecrementPP:
ld a, [wPlayerMoveListIndex] ; which move (0, 1, 2, 3) did we use?
ld c, a
ld b, 0
add hl ,bc ; calculate the address in memory of the PP we need to decrement
add hl, bc ; calculate the address in memory of the PP we need to decrement
; based on the move chosen.
dec [hl] ; Decrement PP
ret

View file

@ -10,9 +10,9 @@ DisplayEffectiveness:
jp PrintText
SuperEffectiveText:
TX_FAR _SuperEffectiveText
db "@"
text_far _SuperEffectiveText
text_end
NotVeryEffectiveText:
TX_FAR _NotVeryEffectiveText
db "@"
text_far _NotVeryEffectiveText
text_end

View file

@ -12,7 +12,7 @@ DrawEnemyPokeballs:
LoadPartyPokeballGfx:
ld de, PokeballTileGraphics
ld hl, vSprites + $310
ld hl, vSprites tile $31
lb bc, BANK(PokeballTileGraphics), (PokeballTileGraphicsEnd - PokeballTileGraphics) / $10
jp CopyVideoData
@ -121,7 +121,7 @@ PlacePlayerHUDTiles:
ld de, wHUDGraphicsTiles
ld bc, $3
call CopyData
coord hl, 18, 10
hlcoord 18, 10
ld de, -1
jr PlaceHUDTiles
@ -136,7 +136,7 @@ PlaceEnemyHUDTiles:
ld de, wHUDGraphicsTiles
ld bc, $3
call CopyData
coord hl, 1, 2
hlcoord 1, 2
ld de, $1
jr PlaceHUDTiles
@ -188,5 +188,5 @@ SetupPlayerAndEnemyPokeballs:
; four tiles: pokeball, black pokeball (status ailment), crossed out pokeball (fainted) and pokeball slot (no mon)
PokeballTileGraphics::
INCBIN "gfx/pokeball.2bpp"
INCBIN "gfx/battle/balls.2bpp"
PokeballTileGraphicsEnd:

1497
engine/battle/effects.asm Normal file

File diff suppressed because it is too large Load diff

10
engine/battle/end_of_battle.asm Executable file → Normal file
View file

@ -10,7 +10,7 @@ EndOfBattle:
ld a, [wEnemyMonStatus]
ld [hl], a
call ClearScreen
callab DisplayLinkBattleVersusTextBox
callfar DisplayLinkBattleVersusTextBox
ld a, [wBattleResult]
cp $1
ld de, YouWinText
@ -19,7 +19,7 @@ EndOfBattle:
jr z, .placeWinOrLoseString
ld de, DrawText
.placeWinOrLoseString
coord hl, 6, 8
hlcoord 6, 8
call PlaceString
ld c, 200
call DelayFrames
@ -46,7 +46,7 @@ EndOfBattle:
.resetVariables
xor a
ld [wDanger], a ;disable low health alarm
ld [wChannelSoundIDs + Ch4], a
ld [wChannelSoundIDs + Ch5], a
ld [wIsInBattle], a
ld [wBattleType], a
ld [wMoveMissed], a
@ -84,5 +84,5 @@ DrawText:
db " DRAW@"
PickUpPayDayMoneyText:
TX_FAR _PickUpPayDayMoneyText
db "@"
text_far _PickUpPayDayMoneyText
text_end

View file

@ -55,15 +55,15 @@ GainExperience:
jr .gainStatExpLoop
.statExpDone
xor a
ld [H_MULTIPLICAND], a
ld [H_MULTIPLICAND + 1], a
ldh [hMultiplicand], a
ldh [hMultiplicand + 1], a
ld a, [wEnemyMonBaseExp]
ld [H_MULTIPLICAND + 2], a
ldh [hMultiplicand + 2], a
ld a, [wEnemyMonLevel]
ld [H_MULTIPLIER], a
ldh [hMultiplier], a
call Multiply
ld a, 7
ld [H_DIVISOR], a
ldh [hDivisor], a
ld b, 4
call Divide
ld hl, wPartyMon1OTID - (wPartyMon1DVs - 1)
@ -91,12 +91,12 @@ GainExperience:
inc hl
; add the gained exp to the party mon's exp
ld b, [hl]
ld a, [H_QUOTIENT + 3]
ldh a, [hQuotient + 3]
ld [wExpAmountGained + 1], a
add b
ld [hld], a
ld b, [hl]
ld a, [H_QUOTIENT + 2]
ldh a, [hQuotient + 2]
ld [wExpAmountGained], a
adc b
ld [hl], a
@ -117,13 +117,13 @@ GainExperience:
ld [wd0b5], a
call GetMonHeader
ld d, MAX_LEVEL
callab CalcExperience ; get max exp
callfar CalcExperience ; get max exp
; compare max exp with current exp
ld a, [hExperience]
ldh a, [hExperience]
ld b, a
ld a, [hExperience + 1]
ldh a, [hExperience + 1]
ld c, a
ld a, [hExperience + 2]
ldh a, [hExperience + 2]
ld d, a
pop hl
ld a, [hld]
@ -155,7 +155,7 @@ GainExperience:
ld bc, wPartyMon1Level - wPartyMon1Exp
add hl, bc
push hl
callba CalcLevelFromExperience
farcall CalcLevelFromExperience
pop hl
ld a, [hl] ; current level
cp d
@ -233,11 +233,11 @@ GainExperience:
.recalcStatChanges
xor a ; battle mon
ld [wCalculateWhoseStats], a
callab CalculateModifiedStats
callab ApplyBurnAndParalysisPenaltiesToPlayer
callab ApplyBadgeStatBoosts
callab DrawPlayerHUDAndHPBar
callab PrintEmptyString
callfar CalculateModifiedStats
callfar ApplyBurnAndParalysisPenaltiesToPlayer
callfar ApplyBadgeStatBoosts
callfar DrawPlayerHUDAndHPBar
callfar PrintEmptyString
call SaveScreenTilesToBuffer1
.printGrewLevelText
ld hl, GrewLevelText
@ -246,7 +246,7 @@ GainExperience:
ld [wMonDataLocation], a
call LoadMonData
ld d, $1
callab PrintStatsBox
callfar PrintStatsBox
call WaitForTextScrollButtonPress
call LoadScreenTilesFromBuffer1
xor a ; PLAYER_PARTY_DATA
@ -311,14 +311,14 @@ DivideExpDataByNumMonsGainingExp:
ld c, wEnemyMonBaseExp + 1 - wEnemyMonBaseStats
.divideLoop
xor a
ld [H_DIVIDEND], a
ldh [hDividend], a
ld a, [hl]
ld [H_DIVIDEND + 1], a
ldh [hDividend + 1], a
ld a, [wd11e]
ld [H_DIVISOR], a
ldh [hDivisor], a
ld b, $2
call Divide ; divide value by number of mons gaining exp
ld a, [H_QUOTIENT + 3]
ldh a, [hQuotient + 3]
ld [hli], a
dec c
jr nz, .divideLoop
@ -326,22 +326,22 @@ DivideExpDataByNumMonsGainingExp:
; multiplies exp by 1.5
BoostExp:
ld a, [H_QUOTIENT + 2]
ldh a, [hQuotient + 2]
ld b, a
ld a, [H_QUOTIENT + 3]
ldh a, [hQuotient + 3]
ld c, a
srl b
rr c
add c
ld [H_QUOTIENT + 3], a
ld a, [H_QUOTIENT + 2]
ldh [hQuotient + 3], a
ldh a, [hQuotient + 2]
adc b
ld [H_QUOTIENT + 2], a
ldh [hQuotient + 2], a
ret
GainedText:
TX_FAR _GainedText
TX_ASM
text_far _GainedText
text_asm
ld a, [wBoostExpByExpAll]
ld hl, WithExpAllText
and a
@ -354,19 +354,19 @@ GainedText:
ret
WithExpAllText:
TX_FAR _WithExpAllText
TX_ASM
text_far _WithExpAllText
text_asm
ld hl, ExpPointsText
ret
BoostedText:
TX_FAR _BoostedText
text_far _BoostedText
ExpPointsText:
TX_FAR _ExpPointsText
db "@"
text_far _ExpPointsText
text_end
GrewLevelText:
TX_FAR _GrewLevelText
TX_SFX_LEVEL_UP
db "@"
text_far _GrewLevelText
sound_level_up
text_end

View file

@ -1,15 +1,15 @@
GetTrainerName_:
GetTrainerName_::
ld hl, wGrassRate
ld a, [wLinkState]
and a
jr nz, .foundName
ld hl, wRivalName
ld a, [wTrainerClass]
cp SONY1
cp RIVAL1
jr z, .foundName
cp SONY2
cp RIVAL2
jr z, .foundName
cp SONY3
cp RIVAL3
jr z, .foundName
ld [wd0b5], a
ld a, TRAINER_NAME

View file

@ -1,21 +1,21 @@
MarowakAnim:
; animate the ghost being unveiled as a Marowak
ld a, $e4
ld [rOBP1], a
ldh [rOBP1], a
call CopyMonPicFromBGToSpriteVRAM ; cover the BG ghost pic with a sprite ghost pic that looks the same
; now that the ghost pic is being displayed using sprites, clear the ghost pic from the BG tilemap
coord hl, 12, 0
hlcoord 12, 0
lb bc, 7, 7
call ClearScreenArea
call Delay3
xor a
ld [H_AUTOBGTRANSFERENABLED], a ; disable BG transfer so we don't see the Marowak too soon
ldh [hAutoBGTransferEnabled], a ; disable BG transfer so we don't see the Marowak too soon
; replace ghost pic with Marowak in BG
ld a, MAROWAK
ld a, RESTLESS_SOUL
ld [wChangeMonPicEnemyTurnSpecies], a
ld a, $1
ld [H_WHOSETURN], a
callab ChangeMonPic
ldh [hWhoseTurn], a
callfar ChangeMonPic
; alternate between black and light grey 8 times.
; this makes the ghost's body appear to flash
ld d, $80
@ -23,10 +23,10 @@ MarowakAnim:
.fadeOutGhostLoop
ld c, 10
call DelayFrames
ld a, [rOBP1]
ldh a, [rOBP1]
sla a
sla a
ld [rOBP1], a
ldh [rOBP1], a
jr nz, .fadeOutGhostLoop
call ClearSprites
call CopyMonPicFromBGToSpriteVRAM ; copy Marowak pic from BG to sprite VRAM
@ -34,17 +34,17 @@ MarowakAnim:
.fadeInMarowakLoop
ld c, 10
call DelayFrames
ld a, [rOBP1]
ldh a, [rOBP1]
srl b
rra
srl b
rra
ld [rOBP1], a
ldh [rOBP1], a
ld a, b
and a
jr nz, .fadeInMarowakLoop
ld a, $1
ld [H_AUTOBGTRANSFERENABLED], a ; enable BG transfer so the BG Marowak pic will be visible after the sprite one is cleared
ldh [hAutoBGTransferEnabled], a ; enable BG transfer so the BG Marowak pic will be visible after the sprite one is cleared
call Delay3
jp ClearSprites
@ -74,7 +74,7 @@ CopyMonPicFromBGToSpriteVRAM:
ld [hli], a
ld a, d
ld [hli], a
ld a, $10 ; use OBP1
ld a, OAM_OBP1
ld [hli], a
inc d
dec c

View file

@ -1,6 +1,6 @@
InitBattleVariables:
ld a, [hTilesetType]
ld [wSavedTilesetType], a
ldh a, [hTileAnimations]
ld [wSavedTileAnimations], a
xor a
ld [wActionResultOrTookBattleTurn], a
ld [wBattleResult], a
@ -35,4 +35,4 @@ InitBattleVariables:
ld a, BATTLE_TYPE_SAFARI
ld [wBattleType], a
.notSafariBattle
jpab PlayBattleMusic
jpfar PlayBattleMusic

View file

@ -1,23 +1,23 @@
; display "[player] VS [enemy]" text box with pokeballs representing their parties next to the names
DisplayLinkBattleVersusTextBox:
call LoadTextBoxTilePatterns
coord hl, 3, 4
hlcoord 3, 4
ld b, 7
ld c, 12
call TextBoxBorder
coord hl, 4, 5
hlcoord 4, 5
ld de, wPlayerName
call PlaceString
coord hl, 4, 10
hlcoord 4, 10
ld de, wLinkEnemyTrainerName
call PlaceString
; place bold "VS" tiles between the names
coord hl, 9, 8
hlcoord 9, 8
ld a, $69
ld [hli], a
ld [hl], $6a
xor a
ld [wUpdateSpritesEnabled], a
callab SetupPlayerAndEnemyPokeballs
callfar SetupPlayerAndEnemyPokeballs
ld c, 150
jp DelayFrames

View file

View file

@ -1,7 +1,7 @@
ConversionEffect_:
ld hl, wEnemyMonType1
ld de, wBattleMonType1
ld a, [H_WHOSETURN]
ldh a, [hWhoseTurn]
and a
ld a, [wEnemyBattleStatus1]
jr z, .conversionEffect
@ -25,8 +25,8 @@ ConversionEffect_:
jp PrintText
ConvertedTypeText:
TX_FAR _ConvertedTypeText
db "@"
text_far _ConvertedTypeText
text_end
PrintButItFailedText:
ld hl, PrintButItFailedText_

View file

@ -14,7 +14,7 @@ DrainHPEffect_:
.getAttackerHP
ld hl, wBattleMonHP
ld de, wBattleMonMaxHP
ld a, [H_WHOSETURN]
ldh a, [hWhoseTurn]
and a
jp z, .addDamageToAttackerHP
ld hl, wEnemyMonHP
@ -69,21 +69,21 @@ DrainHPEffect_:
ld [wHPBarNewHP+1], a
inc de
.next
ld a, [H_WHOSETURN]
ldh a, [hWhoseTurn]
and a
coord hl, 10, 9
hlcoord 10, 9
ld a, $1
jr z, .next2
coord hl, 2, 2
hlcoord 2, 2
xor a
.next2
ld [wHPBarType], a
predef UpdateHPBar2
predef DrawPlayerHUDAndHPBar
predef DrawEnemyHUDAndHPBar
callab ReadPlayerMonCurHPAndStatus
callfar ReadPlayerMonCurHPAndStatus
ld hl, SuckedHealthText
ld a, [H_WHOSETURN]
ldh a, [hWhoseTurn]
and a
ld a, [wPlayerMoveEffect]
jr z, .next3
@ -96,9 +96,9 @@ DrainHPEffect_:
jp PrintText
SuckedHealthText:
TX_FAR _SuckedHealthText
db "@"
text_far _SuckedHealthText
text_end
DreamWasEatenText:
TX_FAR _DreamWasEatenText
db "@"
text_far _DreamWasEatenText
text_end

View file

@ -1,6 +1,6 @@
FocusEnergyEffect_:
ld hl, wPlayerBattleStatus2
ld a, [H_WHOSETURN]
ldh a, [hWhoseTurn]
and a
jr z, .notEnemy
ld hl, wEnemyBattleStatus2
@ -8,15 +8,15 @@ FocusEnergyEffect_:
bit GETTING_PUMPED, [hl] ; is mon already using focus energy?
jr nz, .alreadyUsing
set GETTING_PUMPED, [hl] ; mon is now using focus energy
callab PlayCurrentMoveAnimation
callfar PlayCurrentMoveAnimation
ld hl, GettingPumpedText
jp PrintText
.alreadyUsing
ld c, 50
call DelayFrames
jpab PrintButItFailedText_
jpfar PrintButItFailedText_
GettingPumpedText:
TX_DELAY
TX_FAR _GettingPumpedText
db "@"
text_pause
text_far _GettingPumpedText
text_end

View file

@ -15,7 +15,7 @@ HazeEffect_:
; cure non-volatile status, but only for the target
ld hl, wEnemyMonStatus
ld de, wEnemySelectedMove
ld a, [H_WHOSETURN]
ldh a, [hWhoseTurn]
and a
jr z, .cureStatuses
ld hl, wBattleMonStatus
@ -77,5 +77,5 @@ ResetStats:
ret
StatusChangesEliminatedText:
TX_FAR _StatusChangesEliminatedText
db "@"
text_far _StatusChangesEliminatedText
text_end

View file

@ -1,5 +1,5 @@
HealEffect_:
ld a, [H_WHOSETURN]
ldh a, [hWhoseTurn]
and a
ld de, wBattleMonHP
ld hl, wBattleMonMaxHP
@ -27,7 +27,7 @@ HealEffect_:
ld c, 50
call DelayFrames
ld hl, wBattleMonStatus
ld a, [H_WHOSETURN]
ldh a, [hWhoseTurn]
and a
jr z, .restEffect
ld hl, wEnemyMonStatus
@ -86,35 +86,35 @@ HealEffect_:
ld [wHPBarNewHP], a
.playAnim
ld hl, PlayCurrentMoveAnimation
call BankswitchEtoF
ld a, [H_WHOSETURN]
call EffectCallBattleCore
ldh a, [hWhoseTurn]
and a
coord hl, 10, 9
hlcoord 10, 9
ld a, $1
jr z, .updateHPBar
coord hl, 2, 2
hlcoord 2, 2
xor a
.updateHPBar
ld [wHPBarType], a
predef UpdateHPBar2
ld hl, DrawHUDsAndHPBars
call BankswitchEtoF
call EffectCallBattleCore
ld hl, RegainedHealthText
jp PrintText
.failed
ld c, 50
call DelayFrames
ld hl, PrintButItFailedText_
jp BankswitchEtoF
jp EffectCallBattleCore
StartedSleepingEffect:
TX_FAR _StartedSleepingEffect
db "@"
text_far _StartedSleepingEffect
text_end
FellAsleepBecameHealthyText:
TX_FAR _FellAsleepBecameHealthyText
db "@"
text_far _FellAsleepBecameHealthyText
text_end
RegainedHealthText:
TX_FAR _RegainedHealthText
db "@"
text_far _RegainedHealthText
text_end

View file

@ -1,11 +1,11 @@
LeechSeedEffect_:
callab MoveHitTest
callfar MoveHitTest
ld a, [wMoveMissed]
and a
jr nz, .moveMissed
ld hl, wEnemyBattleStatus2
ld de, wEnemyMonType1
ld a, [H_WHOSETURN]
ldh a, [hWhoseTurn]
and a
jr z, .leechSeedEffect
ld hl, wPlayerBattleStatus2
@ -22,7 +22,7 @@ LeechSeedEffect_:
bit SEEDED, [hl]
jr nz, .moveMissed
set SEEDED, [hl]
callab PlayCurrentMoveAnimation
callfar PlayCurrentMoveAnimation
ld hl, WasSeededText
jp PrintText
.moveMissed
@ -32,9 +32,9 @@ LeechSeedEffect_:
jp PrintText
WasSeededText:
TX_FAR _WasSeededText
db "@"
text_far _WasSeededText
text_end
EvadedAttackText:
TX_FAR _EvadedAttackText
db "@"
text_far _EvadedAttackText
text_end

View file

@ -1,6 +1,6 @@
MistEffect_:
ld hl, wPlayerBattleStatus2
ld a, [H_WHOSETURN]
ldh a, [hWhoseTurn]
and a
jr z, .mistEffect
ld hl, wEnemyBattleStatus2
@ -8,12 +8,12 @@ MistEffect_:
bit PROTECTED_BY_MIST, [hl] ; is mon protected by mist?
jr nz, .mistAlreadyInUse
set PROTECTED_BY_MIST, [hl] ; mon is now protected by mist
callab PlayCurrentMoveAnimation
callfar PlayCurrentMoveAnimation
ld hl, ShroudedInMistText
jp PrintText
.mistAlreadyInUse
jpab PrintButItFailedText_
jpfar PrintButItFailedText_
ShroudedInMistText:
TX_FAR _ShroudedInMistText
db "@"
text_far _ShroudedInMistText
text_end

View file

@ -7,7 +7,7 @@ OneHitKOEffect_:
ld [wCriticalHitOrOHKO], a
ld hl, wBattleMonSpeed + 1
ld de, wEnemyMonSpeed + 1
ld a, [H_WHOSETURN]
ldh a, [hWhoseTurn]
and a
jr z, .compareSpeed
ld hl, wEnemyMonSpeed + 1

View file

@ -1,7 +1,7 @@
ParalyzeEffect_:
ld hl, wEnemyMonStatus
ld de, wPlayerMoveType
ld a, [H_WHOSETURN]
ldh a, [hWhoseTurn]
and a
jp z, .next
ld hl, wBattleMonStatus
@ -26,22 +26,22 @@ ParalyzeEffect_:
jr z, .doesntAffect
.hitTest
push hl
callab MoveHitTest
callfar MoveHitTest
pop hl
ld a, [wMoveMissed]
and a
jr nz, .didntAffect
set PAR, [hl]
callab QuarterSpeedDueToParalysis
callfar QuarterSpeedDueToParalysis
ld c, 30
call DelayFrames
callab PlayCurrentMoveAnimation
jpab PrintMayNotAttackText
callfar PlayCurrentMoveAnimation
jpfar PrintMayNotAttackText
.didntAffect
ld c, 50
call DelayFrames
jpab PrintDidntAffectText
jpfar PrintDidntAffectText
.doesntAffect
ld c, 50
call DelayFrames
jpab PrintDoesntAffectText
jpfar PrintDoesntAffectText

View file

@ -2,7 +2,7 @@ PayDayEffect_:
xor a
ld hl, wcd6d
ld [hli], a
ld a, [H_WHOSETURN]
ldh a, [hWhoseTurn]
and a
ld a, [wBattleMonLevel]
jr z, .payDayEffect
@ -10,28 +10,28 @@ PayDayEffect_:
.payDayEffect
; level * 2
add a
ld [H_DIVIDEND + 3], a
ldh [hDividend + 3], a
xor a
ld [H_DIVIDEND], a
ld [H_DIVIDEND + 1], a
ld [H_DIVIDEND + 2], a
ldh [hDividend], a
ldh [hDividend + 1], a
ldh [hDividend + 2], a
; convert to BCD
ld a, 100
ld [H_DIVISOR], a
ldh [hDivisor], a
ld b, $4
call Divide
ld a, [H_QUOTIENT + 3]
ldh a, [hQuotient + 3]
ld [hli], a
ld a, [H_REMAINDER]
ld [H_DIVIDEND + 3], a
ldh a, [hRemainder]
ldh [hDividend + 3], a
ld a, 10
ld [H_DIVISOR], a
ldh [hDivisor], a
ld b, $4
call Divide
ld a, [H_QUOTIENT + 3]
ldh a, [hQuotient + 3]
swap a
ld b, a
ld a, [H_REMAINDER]
ldh a, [hRemainder]
add b
ld [hl], a
ld de, wTotalPayDayMoney + 2
@ -41,5 +41,5 @@ PayDayEffect_:
jp PrintText
CoinsScatteredText:
TX_FAR _CoinsScatteredText
db "@"
text_far _CoinsScatteredText
text_end

View file

@ -1,5 +1,5 @@
RecoilEffect_:
ld a, [H_WHOSETURN]
ldh a, [hWhoseTurn]
and a
ld a, [wPlayerMoveNum]
ld hl, wBattleMonMaxHP
@ -53,12 +53,12 @@ RecoilEffect_:
ld [hli], a
ld [hl], a
.getHPBarCoords
coord hl, 10, 9
ld a, [H_WHOSETURN]
hlcoord 10, 9
ldh a, [hWhoseTurn]
and a
ld a, $1
jr z, .updateHPBar
coord hl, 2, 2
hlcoord 2, 2
xor a
.updateHPBar
ld [wHPBarType], a
@ -66,5 +66,5 @@ RecoilEffect_:
ld hl, HitWithRecoilText
jp PrintText
HitWithRecoilText:
TX_FAR _HitWithRecoilText
db "@"
text_far _HitWithRecoilText
text_end

View file

@ -1,7 +1,7 @@
ReflectLightScreenEffect_:
ld hl, wPlayerBattleStatus3
ld de, wPlayerMoveEffect
ld a, [H_WHOSETURN]
ldh a, [hWhoseTurn]
and a
jr z, .reflectLightScreenEffect
ld hl, wEnemyBattleStatus3
@ -23,23 +23,23 @@ ReflectLightScreenEffect_:
.playAnim
push hl
ld hl, PlayCurrentMoveAnimation
call BankswitchEtoF
call EffectCallBattleCore
pop hl
jp PrintText
.moveFailed
ld c, 50
call DelayFrames
ld hl, PrintButItFailedText_
jp BankswitchEtoF
jp EffectCallBattleCore
LightScreenProtectedText:
TX_FAR _LightScreenProtectedText
db "@"
text_far _LightScreenProtectedText
text_end
ReflectGainedArmorText:
TX_FAR _ReflectGainedArmorText
db "@"
text_far _ReflectGainedArmorText
text_end
BankswitchEtoF:
EffectCallBattleCore:
ld b, BANK(BattleCore)
jp Bankswitch

View file

@ -4,7 +4,7 @@ SubstituteEffect_:
ld hl, wBattleMonMaxHP
ld de, wPlayerSubstituteHP
ld bc, wPlayerBattleStatus2
ld a, [H_WHOSETURN]
ldh a, [hWhoseTurn]
and a
jr z, .notEnemy
ld hl, wEnemyMonMaxHP
@ -28,7 +28,7 @@ SubstituteEffect_:
add hl, de ; point hl to current HP low byte
pop de
ld a, b
ld [de], a ; save copy of HP to subtract in ccd7/ccd8 [how much HP substitute has]
ld [de], a ; save copy of HP to subtract in wPlayerSubstituteHP/wEnemySubstituteHP
ld a, [hld]
; subtract [max hp / 4] to current HP
sub b
@ -55,7 +55,7 @@ SubstituteEffect_:
call Bankswitch ; jump to routine depending on animation setting
ld hl, SubstituteText
call PrintText
jpab DrawHUDsAndHPBars
jpfar DrawHUDsAndHPBars
.alreadyHasSubstitute
ld hl, HasSubstituteText
jr .printText
@ -65,13 +65,13 @@ SubstituteEffect_:
jp PrintText
SubstituteText:
TX_FAR _SubstituteText
db "@"
text_far _SubstituteText
text_end
HasSubstituteText:
TX_FAR _HasSubstituteText
db "@"
text_far _HasSubstituteText
text_end
TooWeakSubstituteText:
TX_FAR _TooWeakSubstituteText
db "@"
text_far _TooWeakSubstituteText
text_end

View file

@ -3,7 +3,7 @@ TransformEffect_:
ld de, wEnemyMonSpecies
ld bc, wEnemyBattleStatus3
ld a, [wEnemyBattleStatus1]
ld a, [H_WHOSETURN]
ldh a, [hWhoseTurn]
and a
jr nz, .hitTest
ld hl, wEnemyMonSpecies
@ -18,7 +18,7 @@ TransformEffect_:
push de
push bc
ld hl, wPlayerBattleStatus2
ld a, [H_WHOSETURN]
ldh a, [hWhoseTurn]
and a
jr z, .transformEffect
ld hl, wEnemyBattleStatus2
@ -64,7 +64,7 @@ TransformEffect_:
inc bc
inc bc
call CopyData
ld a, [H_WHOSETURN]
ldh a, [hWhoseTurn]
and a
jr z, .next
; save enemy mon DVs at wTransformedEnemyMonOriginalDVs
@ -128,7 +128,7 @@ TransformEffect_:
jp PrintText
.copyBasedOnTurn
ld a, [H_WHOSETURN]
ldh a, [hWhoseTurn]
and a
jr z, .gotStatsOrModsToCopy
push hl
@ -141,8 +141,8 @@ TransformEffect_:
.failed
ld hl, PrintButItFailedText_
jp BankswitchEtoF
jp EffectCallBattleCore
TransformedText:
TX_FAR _TransformedText
db "@"
text_far _TransformedText
text_end

View file

@ -49,4 +49,4 @@ PrintType_:
pop hl
jp PlaceString
INCLUDE "text/type_names.asm"
INCLUDE "data/types/names.asm"

8
engine/battle/read_trainer_party.asm Executable file → Normal file
View file

@ -16,7 +16,7 @@ ReadTrainer:
; get the pointer to trainer data for this class
ld a, [wCurOpponent]
sub $C9 ; convert value from pokemon to trainer
sub OPP_ID_OFFSET + 1 ; convert value from pokemon to trainer
add a
ld hl, TrainerDataPointers
ld c, a
@ -79,7 +79,7 @@ ReadTrainer:
pop hl
jr .SpecialTrainer
.AddLoneMove
; does the trainer have a single monster with a different move
; does the trainer have a single monster with a different move?
ld a, [wLoneAttackNo] ; Brock is 01, Misty is 02, Erika is 04, etc
and a
jr z, .AddTeamMove
@ -101,7 +101,7 @@ ReadTrainer:
; get trainer class number
ld a, [wCurOpponent]
sub 200
sub OPP_ID_OFFSET
ld b, a
ld hl, TeamMoves
@ -116,7 +116,7 @@ ReadTrainer:
; no matches found. is this trainer champion rival?
ld a, b
cp SONY3
cp RIVAL3
jr z, .ChampionRival
jr .FinishUp ; nope
.GiveTeamMoves

18
engine/battle/safari_zone.asm Executable file → Normal file
View file

@ -2,18 +2,18 @@ PrintSafariZoneBattleText:
ld hl, wSafariBaitFactor
ld a, [hl]
and a
jr z, .asm_4284
jr z, .no_bait
dec [hl]
ld hl, SafariZoneEatingText
jr .asm_429f
.asm_4284
jr .done
.no_bait
dec hl
ld a, [hl]
and a
ret z
dec [hl]
ld hl, SafariZoneAngryText
jr nz, .asm_429f
jr nz, .done
push hl
ld a, [wEnemyMonSpecies]
ld [wd0b5], a
@ -21,16 +21,16 @@ PrintSafariZoneBattleText:
ld a, [wMonHCatchRate]
ld [wEnemyMonActualCatchRate], a
pop hl
.asm_429f
.done
push hl
call LoadScreenTilesFromBuffer1
pop hl
jp PrintText
SafariZoneEatingText:
TX_FAR _SafariZoneEatingText
db "@"
text_far _SafariZoneEatingText
text_end
SafariZoneAngryText:
TX_FAR _SafariZoneAngryText
db "@"
text_far _SafariZoneAngryText
text_end

View file

@ -1,4 +1,4 @@
SaveTrainerName:
SaveTrainerName::
ld hl, TrainerNamePointers
ld a, [wTrainerClass]
dec a
@ -18,95 +18,4 @@ SaveTrainerName:
jr nz, .CopyCharacter
ret
TrainerNamePointers:
; what is the point of these?
dw YoungsterName
dw BugCatcherName
dw LassName
dw wTrainerName
dw JrTrainerMName
dw JrTrainerFName
dw PokemaniacName
dw SuperNerdName
dw wTrainerName
dw wTrainerName
dw BurglarName
dw EngineerName
dw JugglerXName
dw wTrainerName
dw SwimmerName
dw wTrainerName
dw wTrainerName
dw BeautyName
dw wTrainerName
dw RockerName
dw JugglerName
dw wTrainerName
dw wTrainerName
dw BlackbeltName
dw wTrainerName
dw ProfOakName
dw ChiefName
dw ScientistName
dw wTrainerName
dw RocketName
dw CooltrainerMName
dw CooltrainerFName
dw wTrainerName
dw wTrainerName
dw wTrainerName
dw wTrainerName
dw wTrainerName
dw wTrainerName
dw wTrainerName
dw wTrainerName
dw wTrainerName
dw wTrainerName
dw wTrainerName
dw wTrainerName
dw wTrainerName
dw wTrainerName
dw wTrainerName
YoungsterName:
db "YOUNGSTER@"
BugCatcherName:
db "BUG CATCHER@"
LassName:
db "LASS@"
JrTrainerMName:
db "JR.TRAINER♂@"
JrTrainerFName:
db "JR.TRAINER♀@"
PokemaniacName:
db "POKéMANIAC@"
SuperNerdName:
db "SUPER NERD@"
BurglarName:
db "BURGLAR@"
EngineerName:
db "ENGINEER@"
JugglerXName:
db "JUGGLER@"
SwimmerName:
db "SWIMMER@"
BeautyName:
db "BEAUTY@"
RockerName:
db "ROCKER@"
JugglerName:
db "JUGGLER@"
BlackbeltName:
db "BLACKBELT@"
ProfOakName:
db "PROF.OAK@"
ChiefName:
db "CHIEF@"
ScientistName:
db "SCIENTIST@"
RocketName:
db "ROCKET@"
CooltrainerMName:
db "COOLTRAINER♂@"
CooltrainerFName:
db "COOLTRAINER♀@"
INCLUDE "data/trainers/name_pointers.asm"

View file

@ -4,11 +4,11 @@
ScaleSpriteByTwo:
ld de, sSpriteBuffer1 + (4*4*8) - 5 ; last byte of input data, last 4 rows already skipped
ld hl, sSpriteBuffer0 + SPRITEBUFFERSIZE - 1 ; end of destination buffer
call ScaleLastSpriteColumnByTwo ; last tile column is special case
call ScaleFirstThreeSpriteColumnsByTwo ; scale first 3 tile columns
call ScaleLastSpriteColumnByTwo ; last tile column is special case
call ScaleFirstThreeSpriteColumnsByTwo ; scale first 3 tile columns
ld de, sSpriteBuffer2 + (4*4*8) - 5 ; last byte of input data, last 4 rows already skipped
ld hl, sSpriteBuffer1 + SPRITEBUFFERSIZE - 1 ; end of destination buffer
call ScaleLastSpriteColumnByTwo ; last tile column is special case
call ScaleLastSpriteColumnByTwo ; last tile column is special case
ScaleFirstThreeSpriteColumnsByTwo:
ld b, $3 ; 3 tile columns
@ -17,7 +17,7 @@ ScaleFirstThreeSpriteColumnsByTwo:
.columnInnerLoop
push bc
ld a, [de]
ld bc, -(7*8)+1 ; $ffc9, scale lower nybble and seek to previous output column
ld bc, -(7*8)+1 ; -$37, scale lower nybble and seek to previous output column
call ScalePixelsByTwo
ld a, [de]
dec de
@ -32,7 +32,7 @@ ScaleFirstThreeSpriteColumnsByTwo:
dec de
dec de
ld a, b
ld bc, -7*8 ; $ffc8, skip one output column (which has already been written along with the current one)
ld bc, -7*8 ; -$38, skip one output column (which has already been written along with the current one)
add hl, bc
ld b, a
dec b
@ -41,16 +41,16 @@ ScaleFirstThreeSpriteColumnsByTwo:
ScaleLastSpriteColumnByTwo:
ld a, 4*8 - 4 ; $1c, 4 tiles minus 4 unused rows
ld [H_SPRITEINTERLACECOUNTER], a
ldh [hSpriteInterlaceCounter], a
ld bc, -1
.columnInnerLoop
ld a, [de]
dec de
swap a ; only high nybble contains information
call ScalePixelsByTwo
ld a, [H_SPRITEINTERLACECOUNTER]
ldh a, [hSpriteInterlaceCounter]
dec a
ld [H_SPRITEINTERLACECOUNTER], a
ldh [hSpriteInterlaceCounter], a
jr nz, .columnInnerLoop
dec de ; skip last 4 rows of new column
dec de
@ -79,7 +79,19 @@ ScalePixelsByTwo:
; repeats each input bit twice
DuplicateBitsTable:
db $00, $03, $0c, $0f
db $30, $33, $3c, $3f
db $c0, $c3, $cc, $cf
db $f0, $f3, $fc, $ff
db %00000000
db %00000011
db %00001100
db %00001111
db %00110000
db %00110011
db %00111100
db %00111111
db %11000000
db %11000011
db %11001100
db %11001111
db %11110000
db %11110011
db %11111100
db %11111111

View file

@ -5,8 +5,8 @@ _ScrollTrainerPicAfterBattle:
ld [wEnemyMonSpecies2], a
ld b, SET_PAL_BATTLE
call RunPaletteCommand
callab _LoadTrainerPic
coord hl, 19, 0
callfar _LoadTrainerPic
hlcoord 19, 0
ld c, $0
.scrollLoop
inc c

View file

@ -134,7 +134,7 @@ AIMoveChoiceModification1:
push de
push bc
ld hl, StatusAilmentMoveEffects
ld de, $0001
ld de, 1
call IsInArray
pop bc
pop de
@ -146,11 +146,11 @@ AIMoveChoiceModification1:
jr .nextMove
StatusAilmentMoveEffects:
db $01 ; unused sleep effect
db EFFECT_01 ; unused sleep effect
db SLEEP_EFFECT
db POISON_EFFECT
db PARALYZE_EFFECT
db $FF
db -1 ; end
; slightly encourage moves with specific effects.
; in particular, stat-modifying moves and other move effects
@ -204,7 +204,7 @@ AIMoveChoiceModification3:
push hl
push bc
push de
callab AIGetTypeEffectiveness
callfar AIGetTypeEffectiveness
pop de
pop bc
pop hl
@ -273,68 +273,19 @@ ReadMove:
pop hl
ret
; move choice modification methods that are applied for each trainer class
; 0 is sentinel value
TrainerClassMoveChoiceModifications:
db 0 ; YOUNGSTER
db 1,0 ; BUG CATCHER
db 1,0 ; LASS
db 1,3,0 ; SAILOR
db 1,0 ; JR_TRAINER_M
db 1,0 ; JR_TRAINER_F
db 1,2,3,0; POKEMANIAC
db 1,2,0 ; SUPER_NERD
db 1,0 ; HIKER
db 1,0 ; BIKER
db 1,3,0 ; BURGLAR
db 1,0 ; ENGINEER
db 1,2,0 ; JUGGLER_X
db 1,3,0 ; FISHER
db 1,3,0 ; SWIMMER
db 0 ; CUE_BALL
db 1,0 ; GAMBLER
db 1,3,0 ; BEAUTY
db 1,2,0 ; PSYCHIC_TR
db 1,3,0 ; ROCKER
db 1,0 ; JUGGLER
db 1,0 ; TAMER
db 1,0 ; BIRD_KEEPER
db 1,0 ; BLACKBELT
db 1,0 ; SONY1
db 1,3,0 ; PROF_OAK
db 1,2,0 ; CHIEF
db 1,2,0 ; SCIENTIST
db 1,3,0 ; GIOVANNI
db 1,0 ; ROCKET
db 1,3,0 ; COOLTRAINER_M
db 1,3,0 ; COOLTRAINER_F
db 1,0 ; BRUNO
db 1,0 ; BROCK
db 1,3,0 ; MISTY
db 1,3,0 ; LT_SURGE
db 1,3,0 ; ERIKA
db 1,3,0 ; KOGA
db 1,3,0 ; BLAINE
db 1,3,0 ; SABRINA
db 1,2,0 ; GENTLEMAN
db 1,3,0 ; SONY2
db 1,3,0 ; SONY3
db 1,2,3,0; LORELEI
db 1,0 ; CHANNELER
db 1,0 ; AGATHA
db 1,3,0 ; LANCE
INCLUDE "data/trainers/move_choices.asm"
INCLUDE "engine/battle/trainer_pic_money_pointers.asm"
INCLUDE "data/trainers/pic_pointers_money.asm"
INCLUDE "text/trainer_names.asm"
INCLUDE "data/trainers/names.asm"
INCLUDE "engine/battle/bank_e_misc.asm"
INCLUDE "engine/battle/misc.asm"
INCLUDE "engine/battle/read_trainer_party.asm"
INCLUDE "data/trainer_moves.asm"
INCLUDE "data/trainers/special_moves.asm"
INCLUDE "data/trainer_parties.asm"
INCLUDE "data/trainers/parties.asm"
TrainerAI:
and a
@ -343,7 +294,7 @@ TrainerAI:
ret z ; if not a trainer, we're done here
ld a, [wLinkState]
cp LINK_STATE_BATTLING
ret z
ret z ; if in a link battle, we're done as well
ld a, [wTrainerClass] ; what trainer class is this?
dec a
ld c, a
@ -368,81 +319,31 @@ TrainerAI:
call Random
jp hl
TrainerAIPointers:
; one entry per trainer class
; first byte, number of times (per Pokémon) it can occur
; next two bytes, pointer to AI subroutine for trainer class
dbw 3,GenericAI
dbw 3,GenericAI
dbw 3,GenericAI
dbw 3,GenericAI
dbw 3,GenericAI
dbw 3,GenericAI
dbw 3,GenericAI
dbw 3,GenericAI
dbw 3,GenericAI
dbw 3,GenericAI
dbw 3,GenericAI
dbw 3,GenericAI
dbw 3,JugglerAI ; juggler_x
dbw 3,GenericAI
dbw 3,GenericAI
dbw 3,GenericAI
dbw 3,GenericAI
dbw 3,GenericAI
dbw 3,GenericAI
dbw 3,GenericAI
dbw 3,JugglerAI ; juggler
dbw 3,GenericAI
dbw 3,GenericAI
dbw 2,BlackbeltAI ; blackbelt
dbw 3,GenericAI
dbw 3,GenericAI
dbw 1,GenericAI ; chief
dbw 3,GenericAI
dbw 1,GiovanniAI ; giovanni
dbw 3,GenericAI
dbw 2,CooltrainerMAI ; cooltrainerm
dbw 1,CooltrainerFAI ; cooltrainerf
dbw 2,BrunoAI ; bruno
dbw 5,BrockAI ; brock
dbw 1,MistyAI ; misty
dbw 1,LtSurgeAI ; surge
dbw 1,ErikaAI ; erika
dbw 2,KogaAI ; koga
dbw 2,BlaineAI ; blaine
dbw 1,SabrinaAI ; sabrina
dbw 3,GenericAI
dbw 1,Sony2AI ; sony2
dbw 1,Sony3AI ; sony3
dbw 2,LoreleiAI ; lorelei
dbw 3,GenericAI
dbw 2,AgathaAI ; agatha
dbw 1,LanceAI ; lance
INCLUDE "data/trainers/ai_pointers.asm"
JugglerAI:
cp $40
cp 25 percent + 1
ret nc
jp AISwitchIfEnoughMons
BlackbeltAI:
cp $20
cp 13 percent - 1
ret nc
jp AIUseXAttack
GiovanniAI:
cp $40
cp 25 percent + 1
ret nc
jp AIUseGuardSpec
CooltrainerMAI:
cp $40
cp 25 percent + 1
ret nc
jp AIUseXAttack
CooltrainerFAI:
cp $40
ld a, $A
cp 25 percent + 1
ld a, 10
call AICheckIfHPBelowFraction
jp c, AIUseHyperPotion
ld a, 5
@ -458,51 +359,51 @@ BrockAI:
jp AIUseFullHeal
MistyAI:
cp $40
cp 25 percent + 1
ret nc
jp AIUseXDefend
LtSurgeAI:
cp $40
cp 25 percent + 1
ret nc
jp AIUseXSpeed
ErikaAI:
cp $80
cp 50 percent + 1
ret nc
ld a, $A
ld a, 10
call AICheckIfHPBelowFraction
ret nc
jp AIUseSuperPotion
KogaAI:
cp $40
cp 25 percent + 1
ret nc
jp AIUseXAttack
BlaineAI:
cp $40
cp 25 percent + 1
ret nc
jp AIUseSuperPotion
SabrinaAI:
cp $40
cp 25 percent + 1
ret nc
ld a, $A
ld a, 10
call AICheckIfHPBelowFraction
ret nc
jp AIUseHyperPotion
Sony2AI:
cp $20
Rival2AI:
cp 13 percent - 1
ret nc
ld a, 5
call AICheckIfHPBelowFraction
ret nc
jp AIUsePotion
Sony3AI:
cp $20
Rival3AI:
cp 13 percent - 1
ret nc
ld a, 5
call AICheckIfHPBelowFraction
@ -510,7 +411,7 @@ Sony3AI:
jp AIUseFullRestore
LoreleiAI:
cp $80
cp 50 percent + 1
ret nc
ld a, 5
call AICheckIfHPBelowFraction
@ -518,14 +419,14 @@ LoreleiAI:
jp AIUseSuperPotion
BrunoAI:
cp $40
cp 25 percent + 1
ret nc
jp AIUseXDefend
AgathaAI:
cp $14
cp 8 percent
jp c, AISwitchIfEnoughMons
cp $80
cp 50 percent + 1
ret nc
ld a, 4
call AICheckIfHPBelowFraction
@ -533,7 +434,7 @@ AgathaAI:
jp AIUseSuperPotion
LanceAI:
cp $80
cp 50 percent + 1
ret nc
ld a, 5
call AICheckIfHPBelowFraction
@ -641,14 +542,14 @@ AIRecoverHP:
AIPrintItemUseAndUpdateHPBar:
call AIPrintItemUse_
coord hl, 2, 2
hlcoord 2, 2
xor a
ld [wHPBarType], a
predef UpdateHPBar2
jp DecrementAICount
AISwitchIfEnoughMons:
; enemy trainer switches if there are 3 or more unfainted mons in party
; enemy trainer switches if there are 2 or more unfainted mons in party
ld a, [wEnemyPartyCount]
ld c, a
ld hl, wEnemyMon1HP
@ -672,7 +573,7 @@ AISwitchIfEnoughMons:
jr nz, .loop
ld a, d ; how many available monsters are there?
cp 2 ; don't bother if only 1 or 2
cp 2 ; don't bother if only 1
jp nc, SwitchEnemyMon
and a
ret
@ -698,7 +599,7 @@ SwitchEnemyMon:
; switching in a new mon in response to this switch.
ld a, 1
ld [wFirstMonsNotOutYet], a
callab EnemySendOut
callfar EnemySendOut
xor a
ld [wFirstMonsNotOutYet], a
@ -709,8 +610,8 @@ SwitchEnemyMon:
ret
AIBattleWithdrawText:
TX_FAR _AIBattleWithdrawText
db "@"
text_far _AIBattleWithdrawText
text_end
AIUseFullHeal:
call AIPlayRestoringSFX
@ -754,17 +655,17 @@ AIUseDireHit: ; unused
AICheckIfHPBelowFraction:
; return carry if enemy trainer's current HP is below 1 / a of the maximum
ld [H_DIVISOR], a
ldh [hDivisor], a
ld hl, wEnemyMonMaxHP
ld a, [hli]
ld [H_DIVIDEND], a
ldh [hDividend], a
ld a, [hl]
ld [H_DIVIDEND + 1], a
ldh [hDividend + 1], a
ld b, 2
call Divide
ld a, [H_QUOTIENT + 3]
ldh a, [hQuotient + 3]
ld c, a
ld a, [H_QUOTIENT + 2]
ldh a, [hQuotient + 2]
ld b, a
ld hl, wEnemyMonHP + 1
ld a, [hld]
@ -812,7 +713,7 @@ AIIncreaseStat:
ld a, ANIM_AF
ld [hli], a
ld [hl], b
callab StatModifierUpEffect
callfar StatModifierUpEffect
pop hl
pop af
ld [hli], a
@ -834,5 +735,5 @@ AIPrintItemUse_:
jp PrintText
AIBattleUseItemText:
TX_FAR _AIBattleUseItemText
db "@"
text_far _AIBattleUseItemText
text_end

View file

@ -1,143 +0,0 @@
TrainerPicAndMoneyPointers:
; trainer pic pointers and base money.
; money received after battle = base money × level of highest-level enemy mon
dw YoungsterPic
money 1500
dw BugCatcherPic
money 1000
dw LassPic
money 1500
dw SailorPic
money 3000
dw JrTrainerMPic
money 2000
dw JrTrainerFPic
money 2000
dw PokemaniacPic
money 5000
dw SuperNerdPic
money 2500
dw HikerPic
money 3500
dw BikerPic
money 2000
dw BurglarPic
money 9000
dw EngineerPic
money 5000
dw JugglerPic
money 3500
dw FisherPic
money 3500
dw SwimmerPic
money 500
dw CueBallPic
money 2500
dw GamblerPic
money 7000
dw BeautyPic
money 7000
dw PsychicPic
money 1000
dw RockerPic
money 2500
dw JugglerPic
money 3500
dw TamerPic
money 4000
dw BirdKeeperPic
money 2500
dw BlackbeltPic
money 2500
dw Rival1Pic
money 3500
dw ProfOakPic
money 9900
dw ChiefPic
money 3000
dw ScientistPic
money 5000
dw GiovanniPic
money 9900
dw RocketPic
money 3000
dw CooltrainerMPic
money 3500
dw CooltrainerFPic
money 3500
dw BrunoPic
money 9900
dw BrockPic
money 9900
dw MistyPic
money 9900
dw LtSurgePic
money 9900
dw ErikaPic
money 9900
dw KogaPic
money 9900
dw BlainePic
money 9900
dw SabrinaPic
money 9900
dw GentlemanPic
money 7000
dw Rival2Pic
money 6500
dw Rival3Pic
money 9900
dw LoreleiPic
money 9900
dw ChannelerPic
money 3000
dw AgathaPic
money 9900
dw LancePic
money 9900

View file

@ -1,6 +1,6 @@
; does nothing since no stats are ever selected (barring glitches)
DoubleSelectedStats:
ld a, [H_WHOSETURN]
ldh a, [hWhoseTurn]
and a
ld a, [wPlayerStatsToDouble]
ld hl, wBattleMonAttack + 1
@ -30,7 +30,7 @@ DoubleSelectedStats:
; does nothing since no stats are ever selected (barring glitches)
HalveSelectedStats:
ld a, [H_WHOSETURN]
ldh a, [hWhoseTurn]
and a
ld a, [wPlayerStatsToHalve]
ld hl, wBattleMonAttack

View file

@ -7,14 +7,14 @@ TryDoWildEncounter:
ld a, [wd736]
and a
ret nz
callab IsPlayerStandingOnDoorTileOrWarpTile
callfar IsPlayerStandingOnDoorTileOrWarpTile
jr nc, .notStandingOnDoorOrWarpTile
.CantEncounter
ld a, $1
and a
ret
.notStandingOnDoorOrWarpTile
callab IsPlayerJustOutsideMap
callfar IsPlayerJustOutsideMap
jr z, .CantEncounter
ld a, [wRepelRemainingSteps]
and a
@ -25,7 +25,7 @@ TryDoWildEncounter:
.next
; determine if wild pokemon can appear in the half-block we're standing in
; is the bottom right tile (9,9) of the half-block we're standing in a grass/water tile?
coord hl, 9, 9
hlcoord 9, 9
ld c, [hl]
ld a, [wGrassTile]
cp c
@ -39,7 +39,7 @@ TryDoWildEncounter:
; so long as the map is "indoor" and has wild pokemon defined.
; ...as long as it's not Viridian Forest or Safari Zone.
ld a, [wCurMap]
cp REDS_HOUSE_1F ; is this an indoor map?
cp FIRST_INDOOR_MAP ; is this an indoor map?
jr c, .CantEncounter2
ld a, [wCurMapTileset]
cp FOREST ; Viridian Forest/Safari Zone
@ -48,10 +48,10 @@ TryDoWildEncounter:
.CanEncounter
; compare encounter chance with a random number to determine if there will be an encounter
ld b, a
ld a, [hRandomAdd]
ldh a, [hRandomAdd]
cp b
jr nc, .CantEncounter2
ld a, [hRandomSub]
ldh a, [hRandomSub]
ld b, a
ld hl, WildMonEncounterSlotChances
.determineEncounterSlot
@ -64,7 +64,7 @@ TryDoWildEncounter:
; determine which wild pokemon (grass or water) can appear in the half-block we're standing in
ld c, [hl]
ld hl, wGrassMons
aCoord 8, 9
lda_coord 8, 9
cp $14 ; is the bottom left tile (8,9) of the half-block we're standing in a water tile?
jr nz, .gotWildEncounterType ; else, it's treated as a grass tile by default
ld hl, wWaterMons
@ -90,7 +90,7 @@ TryDoWildEncounter:
.lastRepelStep
ld [wRepelRemainingSteps], a
ld a, TEXT_REPEL_WORE_OFF
ld [hSpriteIndexOrTextID], a
ldh [hSpriteIndexOrTextID], a
call EnableAutoTextBoxDrawing
call DisplayTextID
.CantEncounter2
@ -101,18 +101,4 @@ TryDoWildEncounter:
xor a
ret
WildMonEncounterSlotChances:
; There are 10 slots for wild pokemon, and this is the table that defines how common each of
; those 10 slots is. A random number is generated and then the first byte of each pair in this
; table is compared against that random number. If the random number is less than or equal
; to the first byte, then that slot is chosen. The second byte is double the slot number.
db $32, $00 ; 51/256 = 19.9% chance of slot 0
db $65, $02 ; 51/256 = 19.9% chance of slot 1
db $8C, $04 ; 39/256 = 15.2% chance of slot 2
db $A5, $06 ; 25/256 = 9.8% chance of slot 3
db $BE, $08 ; 25/256 = 9.8% chance of slot 4
db $D7, $0A ; 25/256 = 9.8% chance of slot 5
db $E4, $0C ; 13/256 = 5.1% chance of slot 6
db $F1, $0E ; 13/256 = 5.1% chance of slot 7
db $FC, $10 ; 11/256 = 4.3% chance of slot 8
db $FF, $12 ; 3/256 = 1.2% chance of slot 9
INCLUDE "data/wild/probabilities.asm"