summaryrefslogtreecommitdiff
path: root/battle
diff options
context:
space:
mode:
authorPikalaxALT <PikalaxALT@gmail.com>2015-12-13 14:15:16 -0500
committerPikalaxALT <PikalaxALT@gmail.com>2015-12-13 14:15:16 -0500
commitacd92eee94f0c8a7e0757ce2a1f486f08a4a9ad7 (patch)
treea26ab1bc2b4e891f2f5be5dbc4276e1ac2ce0f79 /battle
parentecd277204a1e32e923702a57a6212579635a9b4c (diff)
Pack
Diffstat (limited to 'battle')
-rwxr-xr-xbattle/ai/redundant.asm198
-rw-r--r--battle/core.asm12
-rwxr-xr-xbattle/sliding_intro.asm2
-rwxr-xr-xbattle/trainer_huds.asm275
4 files changed, 480 insertions, 7 deletions
diff --git a/battle/ai/redundant.asm b/battle/ai/redundant.asm
new file mode 100755
index 000000000..da71d0ece
--- /dev/null
+++ b/battle/ai/redundant.asm
@@ -0,0 +1,198 @@
+AI_Redundant: ; 2c41a
+; Check if move effect c will fail because it's already been used.
+; Return z if the move is a good choice.
+; Return nz if the move is a bad choice.
+ ld a, c
+ ld de, 3
+ ld hl, .Moves
+ call IsInArray
+ jp nc, .NotRedundant
+ inc hl
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ jp [hl]
+
+.Moves: ; 2c42c
+ dbw EFFECT_DREAM_EATER, .DreamEater
+ dbw EFFECT_HEAL, .Heal
+ dbw EFFECT_LIGHT_SCREEN, .LightScreen
+ dbw EFFECT_MIST, .Mist
+ dbw EFFECT_FOCUS_ENERGY, .FocusEnergy
+ dbw EFFECT_CONFUSE, .Confuse
+ dbw EFFECT_TRANSFORM, .Transform
+ dbw EFFECT_REFLECT, .Reflect
+ dbw EFFECT_SUBSTITUTE, .Substitute
+ dbw EFFECT_LEECH_SEED, .LeechSeed
+ dbw EFFECT_DISABLE, .Disable
+ dbw EFFECT_ENCORE, .Encore
+ dbw EFFECT_SNORE, .Snore
+ dbw EFFECT_SLEEP_TALK, .SleepTalk
+ dbw EFFECT_MEAN_LOOK, .MeanLook
+ dbw EFFECT_NIGHTMARE, .Nightmare
+ dbw EFFECT_SPIKES, .Spikes
+ dbw EFFECT_FORESIGHT, .Foresight
+ dbw EFFECT_PERISH_SONG, .PerishSong
+ dbw EFFECT_SANDSTORM, .Sandstorm
+ dbw EFFECT_ATTRACT, .Attract
+ dbw EFFECT_SAFEGUARD, .Safeguard
+ dbw EFFECT_RAIN_DANCE, .RainDance
+ dbw EFFECT_SUNNY_DAY, .SunnyDay
+ dbw EFFECT_TELEPORT, .Teleport
+ dbw EFFECT_MORNING_SUN, .MorningSun
+ dbw EFFECT_SYNTHESIS, .Synthesis
+ dbw EFFECT_MOONLIGHT, .Moonlight
+ dbw EFFECT_SWAGGER, .Swagger
+ dbw EFFECT_FUTURE_SIGHT, .FutureSight
+ db -1
+
+.LightScreen: ; 2c487
+ ld a, [EnemyScreens]
+ bit SCREENS_LIGHT_SCREEN, a
+ ret
+
+.Mist: ; 2c48d
+ ld a, [EnemySubStatus4]
+ bit SUBSTATUS_MIST, a
+ ret
+
+.FocusEnergy: ; 2c493
+ ld a, [EnemySubStatus4]
+ bit SUBSTATUS_FOCUS_ENERGY, a
+ ret
+
+.Confuse: ; 2c499
+ ld a, [PlayerSubStatus3]
+ bit SUBSTATUS_CONFUSED, a
+ ret nz
+ ld a, [PlayerScreens]
+ bit SCREENS_SAFEGUARD, a
+ ret
+
+.Transform: ; 2c4a5
+ ld a, [EnemySubStatus5]
+ bit SUBSTATUS_TRANSFORMED, a
+ ret
+
+.Reflect: ; 2c4ab
+ ld a, [EnemyScreens]
+ bit SCREENS_REFLECT, a
+ ret
+
+.Substitute: ; 2c4b1
+ ld a, [EnemySubStatus4]
+ bit SUBSTATUS_SUBSTITUTE, a
+ ret
+
+.LeechSeed: ; 2c4b7
+ ld a, [PlayerSubStatus4]
+ bit SUBSTATUS_LEECH_SEED, a
+ ret
+
+.Disable: ; 2c4bd
+ ld a, [PlayerDisableCount]
+ and a
+ ret
+
+.Encore: ; 2c4c2
+ ld a, [PlayerSubStatus5]
+ bit SUBSTATUS_ENCORED, a
+ ret
+
+.Snore:
+.SleepTalk: ; 2c4c8
+ ld a, [EnemyMonStatus]
+ and SLP
+ jr z, .Redundant
+ jr .NotRedundant
+
+.MeanLook: ; 2c4d1
+ ld a, [EnemySubStatus5]
+ bit SUBSTATUS_CANT_RUN, a
+ ret
+
+.Nightmare: ; 2c4d7
+ ld a, [BattleMonStatus]
+ and a
+ jr z, .Redundant
+ ld a, [PlayerSubStatus1]
+ bit SUBSTATUS_NIGHTMARE, a
+ ret
+
+.Spikes: ; 2c4e3
+ ld a, [PlayerScreens]
+ bit SCREENS_SPIKES, a
+ ret
+
+.Foresight: ; 2c4e9
+ ld a, [PlayerSubStatus1]
+ bit SUBSTATUS_IDENTIFIED, a
+ ret
+
+.PerishSong: ; 2c4ef
+ ld a, [PlayerSubStatus1]
+ bit SUBSTATUS_PERISH, a
+ ret
+
+.Sandstorm: ; 2c4f5
+ ld a, [Weather]
+ cp WEATHER_SANDSTORM
+ jr z, .Redundant
+ jr .NotRedundant
+
+.Attract: ; 2c4fe
+ callba CheckOppositeGender
+ jr c, .Redundant
+ ld a, [PlayerSubStatus1]
+ bit SUBSTATUS_IN_LOVE, a
+ ret
+
+.Safeguard: ; 2c50c
+ ld a, [EnemyScreens]
+ bit SCREENS_SAFEGUARD, a
+ ret
+
+.RainDance: ; 2c512
+ ld a, [Weather]
+ cp WEATHER_RAIN
+ jr z, .Redundant
+ jr .NotRedundant
+
+.SunnyDay: ; 2c51b
+ ld a, [Weather]
+ cp WEATHER_SUN
+ jr z, .Redundant
+ jr .NotRedundant
+
+.DreamEater: ; 2c524
+ ld a, [BattleMonStatus]
+ and SLP
+ jr z, .Redundant
+ jr .NotRedundant
+
+.Swagger: ; 2c52d
+ ld a, [PlayerSubStatus3]
+ bit SUBSTATUS_CONFUSED, a
+ ret
+
+.FutureSight: ; 2c533
+ ld a, [EnemyScreens]
+ bit 5, a
+ ret
+
+.Heal:
+.MorningSun:
+.Synthesis:
+.Moonlight: ; 2c539
+ callba AICheckEnemyMaxHP
+ jr nc, .NotRedundant
+
+.Teleport:
+.Redundant: ; 2c541
+ ld a, 1
+ and a
+ ret
+
+.NotRedundant: ; 2c545
+ xor a
+ ret
diff --git a/battle/core.asm b/battle/core.asm
index 8fa465018..dd01268f6 100644
--- a/battle/core.asm
+++ b/battle/core.asm
@@ -2412,7 +2412,7 @@ Function3cf4a: ; 3cf4a
ld e, HP_BAR_LENGTH_PX
call UpdateHPPal
call WaitBGMap
- callba Function2c012
+ callba EnemySwitch_TrainerHud
ld a, [wLinkMode]
and a
jr z, .not_linked
@@ -4853,7 +4853,7 @@ DrawPlayerHUD: ; 3df58
lb bc, 5, 11
call ClearBox
- callba DrawPlayerExpBar
+ callba DrawPlayerHUDBorder
hlcoord 18, 9
ld [hl], $73 ; vertical bar
@@ -4995,7 +4995,7 @@ DrawEnemyHUD: ; 3e043
lb bc, 4, 11
call ClearBox
- callba Function2c0c5
+ callba DrawEnemyHUDBorder
ld a, [TempEnemyMonSpecies]
ld [CurSpecies], a
@@ -9610,7 +9610,7 @@ BattleStartMessage: ; 3fc8b
ld d, $0
ld e, ANIM_MON_NORMAL
predef AnimateFrontpic
- jr .skip_cry
+ jr .skip_cry ; cry is played during the animation
.cry_no_anim
ld a, $0f
@@ -9623,7 +9623,7 @@ BattleStartMessage: ; 3fc8b
cp BATTLETYPE_FISH
jr nz, .NotFishing
- callba MobileFn_106086
+ callba MobileFn_106086 ; update fishing records?
ld hl, HookedPokemonAttackedText
jr .PlaceBattleStartText
@@ -9639,7 +9639,7 @@ BattleStartMessage: ; 3fc8b
.PlaceBattleStartText
push hl
- callba Function2c000
+ callba BattleStart_TrainerHuds
pop hl
call StdBattleTextBox
diff --git a/battle/sliding_intro.asm b/battle/sliding_intro.asm
index e139218a5..0611c91d9 100755
--- a/battle/sliding_intro.asm
+++ b/battle/sliding_intro.asm
@@ -62,7 +62,7 @@ endr
; 4e9d6
.subfunction3: ; 4e9d6
- ld hl, Sprites + 1
+ ld hl, Sprites + 1 ; x pixel
ld c, $12 ; 18
ld de, $4
.loop3
diff --git a/battle/trainer_huds.asm b/battle/trainer_huds.asm
new file mode 100755
index 000000000..0ac043d44
--- /dev/null
+++ b/battle/trainer_huds.asm
@@ -0,0 +1,275 @@
+wPlaceBallsDirection EQU $d003
+wTrainerHUDTiles EQU $d004
+wPlaceBallsX EQU $cfc4
+wPlaceBallsY EQU $cfc5
+GLOBAL wPlaceBallsDirection, wTrainerHUDTiles, wPlaceBallsX, wPlaceBallsY
+
+BattleStart_TrainerHuds: ; 2c000
+ ld a, $e4
+ ld [rOBP0], a
+ call LoadBallIconGFX
+ call ShowPlayerMonsRemaining
+ ld a, [wBattleMode]
+ dec a
+ ret z
+ jp ShowOTTrainerMonsRemaining
+; 2c012
+
+EnemySwitch_TrainerHud: ; 2c012
+ ld a, $e4
+ ld [rOBP0], a
+ call LoadBallIconGFX
+ jp ShowOTTrainerMonsRemaining
+; 2c01c
+
+ShowPlayerMonsRemaining: ; 2c01c
+ call DrawPlayerPartyIconHUDBorder
+ ld hl, PartyMon1HP
+ ld de, PartyCount
+ call StageBallTilesData
+ ; ldpixel wPlaceBallsX, 12, 12
+ ld a, 12 * 8
+ ld hl, wPlaceBallsX
+ ld [hli], a
+ ld [hl], a
+ ld a, 8
+ ld [wPlaceBallsDirection], a
+ ld hl, Sprites
+ jp LoadTrainerHudOAM
+; 2c03a
+
+ShowOTTrainerMonsRemaining: ; 2c03a
+ call DrawEnemyHUDBorder
+ ld hl, OTPartyMon1HP
+ ld de, OTPartyCount
+ call StageBallTilesData
+ ; ldpixel wPlaceBallsX, 9, 4
+ ld hl, wPlaceBallsX
+ ld a, 9 * 8
+ ld [hli], a
+ ld [hl], 4 * 8
+ ld a, -8
+ ld [wPlaceBallsDirection], a
+ ld hl, Sprites + PARTY_LENGTH * 4
+ jp LoadTrainerHudOAM
+; 2c059
+
+StageBallTilesData: ; 2c059
+ ld a, [de]
+ push af
+ ld de, Buffer1
+ ld c, PARTY_LENGTH
+ ld a, $34 ; empty slot
+.loop1
+ ld [de], a
+ inc de
+ dec c
+ jr nz, .loop1
+ pop af
+ ld de, Buffer1
+.loop2
+ push af
+ call .GetHUDTile
+ inc de
+ pop af
+ dec a
+ jr nz, .loop2
+ ret
+; 2c075
+
+.GetHUDTile: ; 2c075
+ ld a, [hli]
+ and a
+ jr nz, .got_hp
+ ld a, [hl]
+ and a
+ ld b, $33 ; fainted
+ jr z, .fainted
+
+.got_hp
+rept 3
+ dec hl
+endr
+ ld a, [hl]
+ and a
+ ld b, $32 ; statused
+ jr nz, .load
+ dec b ; normal
+ jr .load
+
+.fainted
+rept 3
+ dec hl
+endr
+
+.load
+ ld a, b
+ ld [de], a
+ ld bc, PARTYMON_STRUCT_LENGTH + MON_HP - MON_STATUS
+ add hl, bc
+ ret
+; 2c095
+
+DrawPlayerHUDBorder: ; 2c095
+ ld hl, .tiles
+ ld de, wTrainerHUDTiles
+ ld bc, 4
+ call CopyBytes
+ hlcoord 18, 10
+ ld de, -1 ; start on right
+ jr PlaceHUDBorderTiles
+
+.tiles
+ db $73 ; right side
+ db $77 ; bottom right
+ db $6f ; bottom left
+ db $76 ; bottom side
+; 2c0ad
+
+DrawPlayerPartyIconHUDBorder: ; 2c0ad
+ ld hl, .tiles
+ ld de, wTrainerHUDTiles
+ ld bc, 4
+ call CopyBytes
+ hlcoord 18, 10
+ ld de, -1 ; start on right
+ jr PlaceHUDBorderTiles
+
+.tiles
+ db $73 ; right side
+ db $5c ; bottom right
+ db $6f ; bottom left
+ db $76 ; bottom side
+; 2c0c5
+
+DrawEnemyHUDBorder: ; 2c0c5
+ ld hl, .tiles
+ ld de, wTrainerHUDTiles
+ ld bc, 4
+ call CopyBytes
+ hlcoord 1, 2
+ ld de, 1 ; start on left
+ call PlaceHUDBorderTiles
+ ld a, [wBattleMode]
+ dec a
+ ret nz
+ ld a, [TempEnemyMonSpecies]
+ dec a
+ call CheckCaughtMon
+ ret z
+ hlcoord 1, 1
+ ld [hl], $5d
+ ret
+
+.tiles
+ db $6d ; left side
+ db $74 ; bottom left
+ db $78 ; bottom right
+ db $76 ; bottom side
+; 2c0f1
+
+PlaceHUDBorderTiles: ; 2c0f1
+ ld a, [wTrainerHUDTiles]
+ ld [hl], a
+ ld bc, SCREEN_WIDTH
+ add hl, bc
+ ld a, [StartFlypoint]
+ ld [hl], a
+ ld b, $8
+.loop
+ add hl, de
+ ld a, [MovementBuffer]
+ ld [hl], a
+ dec b
+ jr nz, .loop
+ add hl, de
+ ld a, [EndFlypoint]
+ ld [hl], a
+ ret
+; 2c10d
+
+LinkBattle_TrainerHuds: ; 2c10d
+ call LoadBallIconGFX
+ ld hl, PartyMon1HP
+ ld de, PartyCount
+ call StageBallTilesData
+ ld hl, wPlaceBallsX
+ ld a, 10 * 8
+ ld [hli], a
+ ld [hl], 8 * 8
+ ld a, $8
+ ld [wPlaceBallsDirection], a
+ ld hl, Sprites
+ call LoadTrainerHudOAM
+
+ ld hl, OTPartyMon1HP
+ ld de, OTPartyCount
+ call StageBallTilesData
+ ld hl, wPlaceBallsX
+ ld a, 10 * 8
+ ld [hli], a
+ ld [hl], 13 * 8
+ ld hl, Sprites + PARTY_LENGTH * 4
+ jp LoadTrainerHudOAM
+; 2c143
+
+LoadTrainerHudOAM: ; 2c143
+ ld de, Buffer1
+ ld c, PARTY_LENGTH
+.loop
+ ld a, [wPlaceBallsY]
+ ld [hli], a
+ ld a, [wPlaceBallsX]
+ ld [hli], a
+ ld a, [de]
+ ld [hli], a
+ ld a, $3
+ ld [hli], a
+ ld a, [wPlaceBallsX]
+ ld b, a
+ ld a, [wPlaceBallsDirection]
+ add b
+ ld [wPlaceBallsX], a
+ inc de
+ dec c
+ jr nz, .loop
+ ret
+; 2c165
+
+LoadBallIconGFX: ; 2c165
+ ld de, .gfx
+ ld hl, VTiles0 tile $31
+ lb bc, BANK(LoadBallIconGFX), 4
+ call Get2bpp_2
+ ret
+; 2c172
+
+.gfx: ; 2c172
+INCBIN "gfx/battle/balls.2bpp"
+; 2c1b2
+
+_ShowLinkBattleParticipants: ; 2c1b2
+ call ClearBGPalettes
+ call LoadFontsExtra
+ hlcoord 2, 3
+ ld b, 9
+ ld c, 14
+ call TextBox
+ hlcoord 4, 5
+ ld de, PlayerName
+ call PlaceString
+ hlcoord 4, 10
+ ld de, OTPlayerName
+ call PlaceString
+ hlcoord 9, 8
+ ld a, $69 ; "V"
+ ld [hli], a
+ ld [hl], $6a ; "S"
+ callba LinkBattle_TrainerHuds ; no need to callba
+ ld b, SCGB_08
+ call GetSGBLayout
+ call SetPalettes
+ ld a, $e4
+ ld [rOBP0], a
+ ret
+; 2c1ef