diff options
-rw-r--r-- | battle/ai/items.asm | 552 | ||||
-rw-r--r-- | battle/ai/scoring.asm | 606 | ||||
-rw-r--r-- | battle/core.asm | 4 | ||||
-rw-r--r-- | battle/effect_commands.asm | 116 | ||||
-rw-r--r-- | constants/battle_constants.asm | 5 | ||||
-rw-r--r-- | constants/item_constants.asm | 13 | ||||
-rw-r--r-- | constants/misc_constants.asm | 21 | ||||
-rw-r--r-- | constants/pokemon_data_constants.asm | 4 | ||||
-rw-r--r-- | engine/phone_scripts.asm | 148 | ||||
-rw-r--r-- | engine/scripting.asm | 7 | ||||
-rw-r--r-- | engine/std_scripts.asm | 10 | ||||
-rw-r--r-- | gfx/pics/animation.asm | 2 | ||||
-rw-r--r-- | home.asm | 224 | ||||
-rw-r--r-- | home/mobile.asm | 143 | ||||
-rw-r--r-- | home/text.asm | 691 | ||||
-rw-r--r-- | items/item_effects.asm | 176 | ||||
-rw-r--r-- | macros.asm | 10 | ||||
-rw-r--r-- | main.asm | 1114 | ||||
-rw-r--r-- | misc/mobile_save.bin | bin | 0 -> 4096 bytes | |||
-rw-r--r-- | trainers/attributes.asm | 302 | ||||
-rw-r--r-- | wram.asm | 207 |
21 files changed, 2218 insertions, 2137 deletions
diff --git a/battle/ai/items.asm b/battle/ai/items.asm index 58c413b87..73362eb63 100644 --- a/battle/ai/items.asm +++ b/battle/ai/items.asm @@ -1,140 +1,150 @@ Function38000: ; 38000 and a + ld a, [IsInBattle] dec a ret z + ld a, [InLinkBattle] and a ret nz + callba Function3e8d1 ret nz + ld a, [PlayerSubStatus5] bit SUBSTATUS_CANT_RUN, a - jr nz, Function38041 + jr nz, DontSwitch + ld a, [$c731] and a - jr nz, Function38041 + jr nz, DontSwitch + ld hl, TrainerClassAttributes + 5 ld a, [$cfc0] and a - jr nz, .asm_38032 + jr nz, .ok ld a, [TrainerClass] dec a ld bc, 7 call AddNTimes - -.asm_38032 - bit 0, [hl] - jp nz, Function38045 - bit 1, [hl] - jp nz, Function38083 - bit 2, [hl] - jp nz, Function380c1 +.ok + bit SWITCH_OFTEN_F, [hl] + jp nz, SwitchOften + bit SWITCH_RARELY_F, [hl] + jp nz, SwitchRarely + bit SWITCH_SOMETIMES_F, [hl] + jp nz, SwitchSometimes ; fallthrough -; 38041 -Function38041: ; 38041 - call Function38105 +DontSwitch: ; 38041 + call AI_TryItem ret ; 38045 -Function38045: ; 38045 +SwitchOften: ; 38045 callab Function34941 ld a, [$c717] and $f0 - jp z, Function38041 + jp z, DontSwitch + cp $10 - jr nz, .asm_38061 + jr nz, .not_10 call Random cp $80 - jr c, .asm_38077 - jp Function38041 + jr c, .switch + jp DontSwitch +.not_10 -.asm_38061 cp $20 - jr nz, .asm_3806f + jr nz, .not_20 call Random - cp $c8 - jr c, .asm_38077 - jp Function38041 + cp 200 + jr c, .switch + jp DontSwitch +.not_20 -.asm_3806f + ; $30 call Random - cp $a - jp c, Function38041 + cp 10 + jp c, DontSwitch -.asm_38077 +.switch ld a, [$c717] and $f inc a ld [$c718], a - jp Function3844b + jp AI_TrySwitch ; 38083 -Function38083: ; 38083 +SwitchRarely: ; 38083 callab Function34941 ld a, [$c717] and $f0 - jp z, Function38041 + jp z, DontSwitch + cp $10 - jr nz, .asm_3809f + jr nz, .not_10 call Random - cp $14 - jr c, .asm_380b5 - jp Function38041 + cp 20 + jr c, .switch + jp DontSwitch +.not_10 -.asm_3809f cp $20 - jr nz, .asm_380ad + jr nz, .not_20 call Random - cp $1e - jr c, .asm_380b5 - jp Function38041 + cp 30 + jr c, .switch + jp DontSwitch +.not_20 -.asm_380ad + ; $30 call Random - cp $c8 - jp c, Function38041 + cp 200 + jp c, DontSwitch -.asm_380b5 +.switch ld a, [$c717] and $f inc a ld [$c718], a - jp Function3844b + jp AI_TrySwitch ; 380c1 -Function380c1: ; 380c1 +SwitchSometimes: ; 380c1 callab Function34941 ld a, [$c717] and $f0 - jp z, Function38041 + jp z, DontSwitch + cp $10 - jr nz, .asm_380dd + jr nz, .not_10 call Random - cp $32 - jr c, .asm_380f3 - jp Function38041 + cp 50 + jr c, .switch + jp DontSwitch +.not_10 -.asm_380dd cp $20 - jr nz, .asm_380eb + jr nz, .not_20 call Random cp $80 - jr c, .asm_380f3 - jp Function38041 + jr c, .switch + jp DontSwitch +.not_20 -.asm_380eb + ; $30 call Random - cp $32 - jp c, Function38041 + cp 50 + jp c, DontSwitch -.asm_380f3 +.switch ld a, [$c717] and $f inc a ld [$c718], a - jp Function3844b + jp AI_TrySwitch ; 380ff @@ -145,17 +155,20 @@ Function380ff: ; 380ff ; 38105 -Function38105: ; 38105 +AI_TryItem: ; 38105 ld a, [$cfc0] and a ret nz + ld a, [$c650] ld b, a ld a, [$c651] or b ret z - call Function38170 + + call .IsHighestLevel ret nc + ld a, [TrainerClass] dec a ld hl, TrainerClassAttributes + 5 @@ -163,232 +176,243 @@ Function38105: ; 38105 call AddNTimes ld b, h ld c, l - ld hl, Unknown_38196 + ld hl, AI_Items ld de, $c650 -.asm_3812c +.loop ld a, [hl] and a inc a ret z + ld a, [de] cp [hl] - jr z, .asm_3813f + jr z, .has_item inc de ld a, [de] cp [hl] - jr z, .asm_3813f + jr z, .has_item + dec de inc hl inc hl inc hl - jr .asm_3812c + jr .loop -.asm_3813f +.has_item inc hl + push hl push de - ld de, .asm_3814a + ld de, .callback push de ld a, [hli] ld h, [hl] ld l, a jp [hl] - -.asm_3814a +.callback pop de pop hl + inc hl inc hl - jr c, .asm_3812c + jr c, .loop + +.used_item xor a ld [de], a inc a ld [$c70f], a - ld hl, EnemySubStatus3 ; $c66f + + ld hl, EnemySubStatus3 res SUBSTATUS_BIDE, [hl] + xor a - ld [EnemyFuryCutterCount], a ; $c680 + ld [EnemyFuryCutterCount], a ld [$c681], a ld [$c72c], a - ld hl, EnemySubStatus4 ; $c670 + + ld hl, EnemySubStatus4 res SUBSTATUS_RAGE, [hl] + xor a - ld [LastPlayerCounterMove], a ; $c6f9 + ld [LastPlayerCounterMove], a + scf ret -Function38170: ; 38170 +.IsHighestLevel: ; 38170 ld a, [OTPartyCount] ld d, a ld e, 0 ld hl, OTPartyMon1Level ld bc, OTPartyMon2 - OTPartyMon1 -.asm_3817c +.next ld a, [hl] cp e - jr c, .asm_38181 + jr c, .ok ld e, a -.asm_38181 +.ok add hl, bc dec d - jr nz, .asm_3817c + jr nz, .next ld a, [CurOTMon] ld hl, OTPartyMon1Level call AddNTimes ld a, [hl] cp e - jr nc, .asm_38194 + jr nc, .yes + +.no and a ret -.asm_38194 +.yes scf ret ; 38196 -Unknown_38196: ; 39196 - dbw FULL_RESTORE, Function38208 - dbw MAX_POTION, Function38220 - dbw HYPER_POTION, Function38284 - dbw SUPER_POTION, Function38292 - dbw POTION, Function382a0 - dbw X_ACCURACY, Function382f9 - dbw FULL_HEAL, Function381be - dbw GUARD_SPEC, Function38305 - dbw DIRE_HIT, Function38311 - dbw X_ATTACK, Function3831d - dbw X_DEFEND, Function38329 - dbw X_SPEED, Function38335 - dbw X_SPECIAL, Function38341 + +AI_Items: ; 39196 + dbw FULL_RESTORE, .FullRestore + dbw MAX_POTION, .MaxPotion + dbw HYPER_POTION, .HyperPotion + dbw SUPER_POTION, .SuperPotion + dbw POTION, .Potion + dbw X_ACCURACY, .XAccuracy + dbw FULL_HEAL, .FullHeal + dbw GUARD_SPEC, .GuardSpec + dbw DIRE_HIT, .DireHit + dbw X_ATTACK, .XAttack + dbw X_DEFEND, .XDefend + dbw X_SPEED, .XSpeed + dbw X_SPECIAL, .XSpecial db $ff ; 381be -Function381be: ; 381be - call Function381ca - jp c, Function38383 +.FullHeal: ; 381be + call .Status + jp c, .DontUse call Function383a3 - jp Function38385 + jp .Use ; 381ca -Function381ca: ; 381ca (e:41ca) - ld a, [EnemyMonStatus] ; $d214 +.Status: ; 381ca (e:41ca) + ld a, [EnemyMonStatus] and a - jp z, Function38383 + jp z, .DontUse ld a, [bc] - bit 6, a + bit CONTEXT_USE_F, a jr nz, .asm_381e7 ld a, [bc] - bit 4, a - jp nz, Function38385 + bit ALWAYS_USE_F, a + jp nz, .Use call Random - cp $32 - jp c, Function38385 - jp Function38383 + cp 50 + jp c, .Use + jp .DontUse .asm_381e7 ld a, [EnemySubStatus5] bit SUBSTATUS_TOXIC, a jr z, .asm_381fd - ld a, [$c67c] - cp $4 + ld a, [EnemyToxicCount] + cp 4 jr c, .asm_381fd call Random cp $80 - jp c, Function38385 + jp c, .Use .asm_381fd ld a, [EnemyMonStatus] and 1 << FRZ | SLP - jp z, Function38383 - jp Function38385 + jp z, .DontUse + jp .Use ; 38208 -Function38208: ; 38208 - call Function3822c - jp nc, Function3821a +.FullRestore: ; 38208 + call .HealItem + jp nc, .asm_3821a ld a, [bc] - bit 6, a - jp z, Function38383 - call Function381ca - jp c, Function38383 + bit CONTEXT_USE_F, a + jp z, .DontUse + call .Status + jp c, .DontUse -Function3821a: ; 3821a (e:421a) +.asm_3821a call Function383b5 - jp Function38385 + jp .Use ; 38220 -Function38220: ; 38220 - call Function3822c - jp c, Function38383 +.MaxPotion: ; 38220 + call .HealItem + jp c, .DontUse call Function383ae - jp Function38385 + jp .Use -Function3822c: ; 3822c (e:422c) +.HealItem: ; 3822c (e:422c) ld a, [bc] - bit 6, a - jr nz, Function38267 + bit CONTEXT_USE_F, a + jr nz, .asm_38267 callab AICheckEnemyHalfHP - jp c, Function38383 + jp c, .DontUse ld a, [bc] - bit 5, a - jp nz, Function38254 + bit UNKNOWN_USE_F, a + jp nz, .asm_38254 callab AICheckEnemyQuarterHP - jp nc, Function38281 + jp nc, .asm_38281 call Random cp $80 - jp c, Function38281 - jp Function38383 + jp c, .asm_38281 + jp .DontUse -Function38254: ; 38254 (e:4254) +.asm_38254: ; 38254 (e:4254) callab AICheckEnemyQuarterHP - jp c, Function38383 + jp c, .DontUse call Random - cp $32 - jp c, Function38383 - jr Function38281 + cp 50 + jp c, .DontUse + jr .asm_38281 -Function38267: ; 38267 (e:4267) +.asm_38267: ; 38267 (e:4267) callab AICheckEnemyHalfHP - jp c, Function38383 + jp c, .DontUse callab AICheckEnemyQuarterHP - jp nc, Function38281 + jp nc, .asm_38281 call Random - cp $32 - jp nc, Function38383 + cp 50 + jp nc, .DontUse -Function38281: ; 38281 (e:4281) - jp Function38385 +.asm_38281: ; 38281 (e:4281) + jp .Use ; 38284 -Function38284: ; 38284 - call Function3822c - jp c, Function38383 +.HyperPotion: ; 38284 + call .HealItem + jp c, .DontUse ld b, 200 call Function383f4 - jp Function38385 + jp .Use ; 38292 (e:4292) -Function38292: ; 38292 - call Function3822c - jp c, Function38383 - -Function38298: ; 38298 +.SuperPotion: ; 38292 + call .HealItem + jp c, .DontUse ld b, 50 call Function383ee - jp Function38385 + jp .Use ; 382a0 -Function382a0: ; 382a0 - call Function3822c - jp c, Function38383 +.Potion: ; 382a0 + call .HealItem + jp c, .DontUse ld b, 20 call Function383e8 - jp Function38385 + jp .Use ; 382ae -Function382ae: ; 382ae +.asm_382ae: ; 382ae callab AICheckEnemyMaxHP jr c, .asm_382e4 push bc @@ -412,111 +436,111 @@ Function382ae: ; 382ae .asm_382d5 pop bc ld a, [bc] - bit 5, a - jp z, Function38385 + bit UNKNOWN_USE_F, a + jp z, .Use call Random cp $80 - jp c, Function38385 + jp c, .Use .asm_382e4 - jp Function38383 + jp .DontUse .asm_382e7 pop bc ld a, [bc] - bit 5, a - jp z, Function38383 + bit UNKNOWN_USE_F, a + jp z, .DontUse call Random - cp $64 - jp c, Function38385 - jp Function38383 + cp 100 + jp c, .Use + jp .DontUse ; 382f9 -Function382f9: ; 382f9 - call Function3834d - jp c, Function38383 +.XAccuracy: ; 382f9 + call .XItem + jp c, .DontUse call Function384f7 - jp Function38385 + jp .Use ; 38305 -Function38305: ; 38305 - call Function3834d - jp c, Function38383 +.GuardSpec: ; 38305 + call .XItem + jp c, .DontUse call Function38504 - jp Function38385 + jp .Use ; 38311 -Function38311: ; 38311 - call Function3834d - jp c, Function38383 +.DireHit: ; 38311 + call .XItem + jp c, .DontUse call Function38511 - jp Function38385 + jp .Use ; 3831d (e:431d) -Function3831d: ; 3831d - call Function3834d - jp c, Function38383 +.XAttack: ; 3831d + call .XItem + jp c, .DontUse call Function38541 - jp Function38385 + jp .Use ; 38329 -Function38329: ; 38329 - call Function3834d - jp c, Function38383 +.XDefend: ; 38329 + call .XItem + jp c, .DontUse call Function38547 - jp Function38385 + jp .Use ; 38335 -Function38335: ; 38335 - call Function3834d - jp c, Function38383 +.XSpeed: ; 38335 + call .XItem + jp c, .DontUse call Function3854d - jp Function38385 + jp .Use ; 38341 -Function38341: ; 38341 - call Function3834d - jp c, Function38383 +.XSpecial: ; 38341 + call .XItem + jp c, .DontUse call Function38553 - jp Function38385 + jp .Use ; 3834d -Function3834d: ; 3834d (e:434d) - ld a, [EnemyTurnsTaken] ; $c6dc +.XItem: ; 3834d (e:434d) + ld a, [EnemyTurnsTaken] and a jr nz, .asm_38372 ld a, [bc] - bit 4, a - jp nz, Function38385 + bit ALWAYS_USE_F, a + jp nz, .Use call Random cp $80 - jp c, Function38383 + jp c, .DontUse ld a, [bc] - bit 6, a - jp nz, Function38385 + bit CONTEXT_USE_F, a + jp nz, .Use call Random cp $80 - jp c, Function38383 - jp Function38385 + jp c, .DontUse + jp .Use .asm_38372 ld a, [bc] - bit 4, a - jp z, Function38383 + bit ALWAYS_USE_F, a + jp z, .DontUse call Random - cp $32 - jp nc, Function38383 - jp Function38385 + cp 50 + jp nc, .DontUse + jp .Use -Function38383: ; 38383 (e:4383) +.DontUse: scf ret -Function38385: ; 38385 (e:4385) +.Use: and a ret -Function38387: ; 38387 +AIUpdateHUD: ; 38387 call UpdateEnemyMonInParty callba UpdateEnemyHUD ld a, $1 @@ -527,7 +551,7 @@ Function38387: ; 38387 ret ; 3839a -Function3839a: ; 3839a +AIUsedItemSound: ; 3839a push de ld de, SFX_FULL_HEAL call PlaySFX @@ -537,44 +561,45 @@ Function3839a: ; 3839a Function383a3: ; 383a3 (e:43a3) - call Function3839a - call Function384e0 + call AIUsedItemSound + call AI_HealStatus ld a, FULL_HEAL jp Function38568 Function383ae: ; 383ae (e:43ae) - ld a, $f + ld a, MAX_POTION ld [$d1f1], a jr asm_383c6 Function383b5: ; 383b5 (e:43b5) - call Function384e0 - ld a, $e + call AI_HealStatus + ld a, FULL_RESTORE ld [$d1f1], a - ld hl, EnemySubStatus3 ; $c66f + ld hl, EnemySubStatus3 res SUBSTATUS_CONFUSED, [hl] xor a - ld [EnemyConfuseCount], a ; $c67b -asm_383c6: ; 383c6 (e:43c6) + ld [EnemyConfuseCount], a + +asm_383c6: ; 383c6 ld de, $d1ec - ld hl, EnemyMonHP + 1 ; $d217 + ld hl, EnemyMonHP + 1 ld a, [hld] ld [de], a inc de ld a, [hl] ld [de], a inc de - ld hl, EnemyMonMaxHP + 1 ; $d219 + ld hl, EnemyMonMaxHP + 1 ld a, [hld] ld [de], a inc de - ld [Buffer1], a ; $d1ea (aliases: MagikarpLength) - ld [EnemyMonHP + 1], a ; $d217 + ld [Buffer1], a + ld [EnemyMonHP + 1], a ld a, [hl] ld [de], a - ld [Buffer2], a ; $d1eb (aliases: MovementType) - ld [EnemyMonHP], a ; $d216 (aliases: EnemyMonHP) - jr asm_38436 + ld [Buffer2], a + ld [EnemyMonHP], a + jr Function38436 ; 383e8 (e:43e8) Function383e8: ; 383e8 @@ -593,34 +618,34 @@ Function383f4: ; 383f4 (e:43f4) Function383f8: ; 383f8 ld [$d1f1], a - ld hl, EnemyMonHP + 1 ; $d217 + ld hl, EnemyMonHP + 1 ld a, [hl] ld [$d1ec], a add b ld [hld], a ld [$d1ee], a ld a, [hl] - ld [$d1ed], a - ld [$d1ef], a + ld [$d1ec + 1], a + ld [$d1ee + 1], a jr nc, .asm_38415 inc a ld [hl], a - ld [$d1ef], a + ld [$d1ee + 1], a .asm_38415 inc hl ld a, [hld] ld b, a - ld de, EnemyMonMaxHP + 1 ; $d219 + ld de, EnemyMonMaxHP + 1 ld a, [de] dec de - ld [Buffer1], a ; $d1ea (aliases: MagikarpLength) + ld [Buffer1], a sub b ld a, [hli] ld b, a ld a, [de] - ld [Buffer2], a ; $d1eb (aliases: MovementType) + ld [Buffer2], a sbc b - jr nc, asm_38436 + jr nc, .asm_38436 inc de ld a, [de] dec de @@ -629,17 +654,19 @@ Function383f8: ; 383f8 ld a, [de] ld [hl], a ld [$d1ef], a -asm_38436: ; 38436 (e:4436) +.asm_38436 + +Function38436: ; 38436 call Function38571 hlcoord 2, 2 xor a ld [$d10a], a - call Function3839a + call AIUsedItemSound predef Functionc6e0 - jp Function38387 + jp AIUpdateHUD -Function3844b: ; 3844b +AI_TrySwitch: ; 3844b ld a, [OTPartyCount] ld c, a ld hl, OTPartyMon1HP @@ -651,7 +678,6 @@ Function3844b: ; 3844b or b jr z, .asm_3845b inc d - .asm_3845b push bc ld bc, PartyMon2 - PartyMon1 @@ -659,14 +685,15 @@ Function3844b: ; 3844b pop bc dec c jr nz, .asm_38454 + ld a, d - cp $2 - jp nc, Function3846c + cp 2 + jp nc, AI_Switch and a ret ; 3846c -Function3846c: ; 3846c +AI_Switch: ; 3846c ld a, $1 ld [$c711], a ld [$c70f], a @@ -689,7 +716,6 @@ Function3846c: ; 3846c jr c, .asm_384a3 ld hl, UnknownText_0x384d0 call PrintText - .asm_384a3 ld a, $1 ld [$d264], a @@ -714,13 +740,13 @@ UnknownText_0x384d0: ; 384d0 ; 384d5 Function384d5: ; 384d5 - call Function3839a - call Function384e0 - ld a, X_SPEED + call AIUsedItemSound + call AI_HealStatus + ld a, FULL_HEAL_RED jp Function38568 ; 384e0 -Function384e0: ; 384e0 +AI_HealStatus: ; 384e0 ld a, [CurOTMon] ld hl, OTPartyMon1Status ld bc, PartyMon2 - PartyMon1 @@ -734,15 +760,15 @@ Function384e0: ; 384e0 ; 384f7 Function384f7: ; 384f7 - call Function3839a + call AIUsedItemSound ld hl, EnemySubStatus4 - set SUBSTATUS_UNLEASH, [hl] + set SUBSTATUS_X_ACCURACY, [hl] ld a, X_ACCURACY jp Function38568 ; 38504 Function38504: ; 38504 - call Function3839a + call AIUsedItemSound ld hl, EnemySubStatus4 set SUBSTATUS_MIST, [hl] ld a, GUARD_SPEC @@ -750,7 +776,7 @@ Function38504: ; 38504 ; 38511 Function38511: ; 38511 - call Function3839a + call AIUsedItemSound ld hl, EnemySubStatus4 set SUBSTATUS_FOCUS_ENERGY, [hl] ld a, DIRE_HIT @@ -805,20 +831,20 @@ Function38553: ; 38553 ld b, SP_ATTACK ld a, X_SPECIAL -Function38557 +Function38557: ld [$d1f1], a push bc call Function38571 pop bc callba Function361ef - jp Function38387 + jp AIUpdateHUD ; 38568 Function38568: ; 38568 ld [$d1f1], a call Function38571 - jp Function38387 + jp AIUpdateHUD ; 38571 Function38571: ; 38571 @@ -827,7 +853,7 @@ Function38571: ; 38571 call GetItemName ld hl, StringBuffer1 ld de, $d050 - ld bc, $000d + ld bc, ITEM_NAME_LENGTH call CopyBytes ld hl, UnknownText_0x3858c jp PrintText diff --git a/battle/ai/scoring.asm b/battle/ai/scoring.asm index bf4b660e5..52112faf6 100644 --- a/battle/ai/scoring.asm +++ b/battle/ai/scoring.asm @@ -1,5 +1,7 @@ -AIScoring_RedStatus: ; 38591 -; Handle the AI of status-only moves and moves with special effects. +AI_Basic: ; 38591 +; Don't do anything redundant: +; -Using status-only moves if the player can't be statused +; -Using moves that fail if they've already been used ld hl, Buffer1 - 1 ld de, EnemyMonMoves @@ -25,7 +27,7 @@ AIScoring_RedStatus: ; 38591 push hl push de push bc - callba AISpecialEffects + callba AI_Redundant pop bc pop de pop hl @@ -69,7 +71,9 @@ AIScoring_RedStatus: ; 38591 -AIScoring_RedStatMods: ; 385e0 +AI_Setup: ; 385e0 +; Use stat-modifying moves on turn 1. + ; 50% chance to greatly encourage stat-up moves during the first turn of enemy's Pokemon. ; 50% chance to greatly encourage stat-down moves during the first turn of player's Pokemon. ; Almost 90% chance to greatly discourage stat-modifying moves otherwise. @@ -97,7 +101,7 @@ AIScoring_RedStatMods: ; 385e0 jr c, .statup ; cp EFFECT_ATTACK_DOWN - 1 - jr z, .checkmove ; ignore EFFECT_ALWAYS_HIT + jr z, .checkmove cp EFFECT_EVASION_DOWN + 1 jr c, .statdown @@ -107,7 +111,7 @@ AIScoring_RedStatMods: ; 385e0 jr c, .statup ; cp EFFECT_ATTACK_DOWN_2 - 1 - jr z, .checkmove ; ignore EFFECT_TRANSFROM + jr z, .checkmove cp EFFECT_EVASION_DOWN_2 + 1 jr c, .statdown @@ -126,7 +130,7 @@ AIScoring_RedStatMods: ; 385e0 jr nz, .discourage .encourage - call AIRandom2 + call AI_50_50 jr c, .checkmove dec [hl] @@ -144,7 +148,7 @@ AIScoring_RedStatMods: ; 385e0 -AIScoring_RedSuperEffective: ; 38635 +AI_Types: ; 38635 ; Dismiss any move that the player is immune to. ; Encourage super-effective moves. ; Discourage not very effective moves unless @@ -236,7 +240,7 @@ AIScoring_RedSuperEffective: ; 38635 -AIScoring_Offensive: ; 386a2 +AI_Offensive: ; 386a2 ; Greatly discourage non-damaging moves. ld hl, Buffer1 - 1 @@ -265,7 +269,7 @@ AIScoring_Offensive: ; 386a2 -AIScoring_Smart: ; 386be +AI_Smart: ; 386be ; Context-specific scoring. ld hl, Buffer1 @@ -314,104 +318,104 @@ AIScoring_Smart: ; 386be jr .checkmove .table_386f2 - dbw EFFECT_SLEEP, AIScoring_Sleep - dbw EFFECT_LEECH_HIT, AIScoring_LeechHit - dbw EFFECT_EXPLOSION, AIScoring_Explosion - dbw EFFECT_DREAM_EATER, AIScoring_DreamEater - dbw EFFECT_MIRROR_MOVE, AIScoring_MirrorMove - dbw EFFECT_EVASION_UP, AIScoring_EvasionUp - dbw EFFECT_ALWAYS_HIT, AIScoring_AlwaysHit - dbw EFFECT_ACCURACY_DOWN, AIScoring_AccuracyDown - dbw EFFECT_HAZE, AIScoring_Haze - dbw EFFECT_BIDE, AIScoring_Bide - dbw EFFECT_WHIRLWIND, AIScoring_Whirlwind - dbw EFFECT_HEAL, AIScoring_Heal - dbw EFFECT_TOXIC, AIScoring_Toxic - dbw EFFECT_LIGHT_SCREEN, AIScoring_LightScreen - dbw EFFECT_OHKO, AIScoring_Ohko - dbw EFFECT_RAZOR_WIND, AIScoring_RazorWind - dbw EFFECT_SUPER_FANG, AIScoring_SuperFang - dbw EFFECT_BIND, AIScoring_Bind - dbw EFFECT_UNUSED_2B, AIScoring_Unused2B - dbw EFFECT_CONFUSE, AIScoring_Confuse - dbw EFFECT_SP_DEF_UP_2, AIScoring_SpDefenseUp2 - dbw EFFECT_REFLECT, AIScoring_Reflect - dbw EFFECT_PARALYZE, AIScoring_Paralyze - dbw EFFECT_SPEED_DOWN_HIT, AIScoring_SpeedDownHit - dbw EFFECT_SUBSTITUTE, AIScoring_Substitute - dbw EFFECT_HYPER_BEAM, AIScoring_HyperBeam - dbw EFFECT_RAGE, AIScoring_Rage - dbw EFFECT_MIMIC, AIScoring_Mimic - dbw EFFECT_LEECH_SEED, AIScoring_LeechSeed - dbw EFFECT_DISABLE, AIScoring_Disable - dbw EFFECT_COUNTER, AIScoring_Counter - dbw EFFECT_ENCORE, AIScoring_Encore - dbw EFFECT_PAIN_SPLIT, AIScoring_PainSplit - dbw EFFECT_SNORE, AIScoring_Snore - dbw EFFECT_CONVERSION2, AIScoring_Conversion2 - dbw EFFECT_LOCK_ON, AIScoring_LockOn - dbw EFFECT_DEFROST_OPPONENT, AIScoring_DefrostOpponent - dbw EFFECT_SLEEP_TALK, AIScoring_SleepTalk - dbw EFFECT_DESTINY_BOND, AIScoring_DestinyBond - dbw EFFECT_REVERSAL, AIScoring_Reversal - dbw EFFECT_SPITE, AIScoring_Spite - dbw EFFECT_HEAL_BELL, AIScoring_HealBell - dbw EFFECT_PRIORITY_HIT, AIScoring_PriorityHit - dbw EFFECT_THIEF, AIScoring_Thief - dbw EFFECT_MEAN_LOOK, AIScoring_MeanLook - dbw EFFECT_NIGHTMARE, AIScoring_Nightmare - dbw EFFECT_FLAME_WHEEL, AIScoring_FlameWheel - dbw EFFECT_CURSE, AIScoring_Curse - dbw EFFECT_PROTECT, AIScoring_Protect - dbw EFFECT_FORESIGHT, AIScoring_Foresight - dbw EFFECT_PERISH_SONG, AIScoring_PerishSong - dbw EFFECT_SANDSTORM, AIScoring_Sandstorm - dbw EFFECT_ENDURE, AIScoring_Endure - dbw EFFECT_ROLLOUT, AIScoring_Rollout - dbw EFFECT_SWAGGER, AIScoring_Swagger - dbw EFFECT_FURY_CUTTER, AIScoring_FuryCutter - dbw EFFECT_ATTRACT, AIScoring_Attract - dbw EFFECT_SAFEGUARD, AIScoring_Safeguard - dbw EFFECT_MAGNITUDE, AIScoring_Magnitude - dbw EFFECT_BATON_PASS, AIScoring_BatonPass - dbw EFFECT_PURSUIT, AIScoring_Pursuit - dbw EFFECT_RAPID_SPIN, AIScoring_RapidSpin - dbw EFFECT_MORNING_SUN, AIScoring_MorningSun - dbw EFFECT_SYNTHESIS, AIScoring_Synthesis - dbw EFFECT_MOONLIGHT, AIScoring_Moonlight - dbw EFFECT_HIDDEN_POWER, AIScoring_HiddenPower - dbw EFFECT_RAIN_DANCE, AIScoring_RainDance - dbw EFFECT_SUNNY_DAY, AIScoring_SunnyDay - dbw EFFECT_BELLY_DRUM, AIScoring_BellyDrum - dbw EFFECT_PSYCH_UP, AIScoring_PsychUp - dbw EFFECT_MIRROR_COAT, AIScoring_MirrorCoat - dbw EFFECT_SKULL_BASH, AIScoring_SkullBash - dbw EFFECT_TWISTER, AIScoring_Twister - dbw EFFECT_EARTHQUAKE, AIScoring_Earthquake - dbw EFFECT_FUTURE_SIGHT, AIScoring_FutureSight - dbw EFFECT_GUST, AIScoring_Gust - dbw EFFECT_STOMP, AIScoring_Stomp - dbw EFFECT_SOLARBEAM, AIScoring_Solarbeam - dbw EFFECT_THUNDER, AIScoring_Thunder - dbw EFFECT_FLY, AIScoring_Fly + dbw EFFECT_SLEEP, AI_Smart_Sleep + dbw EFFECT_LEECH_HIT, AI_Smart_LeechHit + dbw EFFECT_EXPLOSION, AI_Smart_Explosion + dbw EFFECT_DREAM_EATER, AI_Smart_DreamEater + dbw EFFECT_MIRROR_MOVE, AI_Smart_MirrorMove + dbw EFFECT_EVASION_UP, AI_Smart_EvasionUp + dbw EFFECT_ALWAYS_HIT, AI_Smart_AlwaysHit + dbw EFFECT_ACCURACY_DOWN, AI_Smart_AccuracyDown + dbw EFFECT_HAZE, AI_Smart_Haze + dbw EFFECT_BIDE, AI_Smart_Bide + dbw EFFECT_WHIRLWIND, AI_Smart_Whirlwind + dbw EFFECT_HEAL, AI_Smart_Heal + dbw EFFECT_TOXIC, AI_Smart_Toxic + dbw EFFECT_LIGHT_SCREEN, AI_Smart_LightScreen + dbw EFFECT_OHKO, AI_Smart_Ohko + dbw EFFECT_RAZOR_WIND, AI_Smart_RazorWind + dbw EFFECT_SUPER_FANG, AI_Smart_SuperFang + dbw EFFECT_BIND, AI_Smart_Bind + dbw EFFECT_UNUSED_2B, AI_Smart_Unused2B + dbw EFFECT_CONFUSE, AI_Smart_Confuse + dbw EFFECT_SP_DEF_UP_2, AI_Smart_SpDefenseUp2 + dbw EFFECT_REFLECT, AI_Smart_Reflect + dbw EFFECT_PARALYZE, AI_Smart_Paralyze + dbw EFFECT_SPEED_DOWN_HIT, AI_Smart_SpeedDownHit + dbw EFFECT_SUBSTITUTE, AI_Smart_Substitute + dbw EFFECT_HYPER_BEAM, AI_Smart_HyperBeam + dbw EFFECT_RAGE, AI_Smart_Rage + dbw EFFECT_MIMIC, AI_Smart_Mimic + dbw EFFECT_LEECH_SEED, AI_Smart_LeechSeed + dbw EFFECT_DISABLE, AI_Smart_Disable + dbw EFFECT_COUNTER, AI_Smart_Counter + dbw EFFECT_ENCORE, AI_Smart_Encore + dbw EFFECT_PAIN_SPLIT, AI_Smart_PainSplit + dbw EFFECT_SNORE, AI_Smart_Snore + dbw EFFECT_CONVERSION2, AI_Smart_Conversion2 + dbw EFFECT_LOCK_ON, AI_Smart_LockOn + dbw EFFECT_DEFROST_OPPONENT, AI_Smart_DefrostOpponent + dbw EFFECT_SLEEP_TALK, AI_Smart_SleepTalk + dbw EFFECT_DESTINY_BOND, AI_Smart_DestinyBond + dbw EFFECT_REVERSAL, AI_Smart_Reversal + dbw EFFECT_SPITE, AI_Smart_Spite + dbw EFFECT_HEAL_BELL, AI_Smart_HealBell + dbw EFFECT_PRIORITY_HIT, AI_Smart_PriorityHit + dbw EFFECT_THIEF, AI_Smart_Thief + dbw EFFECT_MEAN_LOOK, AI_Smart_MeanLook + dbw EFFECT_NIGHTMARE, AI_Smart_Nightmare + dbw EFFECT_FLAME_WHEEL, AI_Smart_FlameWheel + dbw EFFECT_CURSE, AI_Smart_Curse + dbw EFFECT_PROTECT, AI_Smart_Protect + dbw EFFECT_FORESIGHT, AI_Smart_Foresight + dbw EFFECT_PERISH_SONG, AI_Smart_PerishSong + dbw EFFECT_SANDSTORM, AI_Smart_Sandstorm + dbw EFFECT_ENDURE, AI_Smart_Endure + dbw EFFECT_ROLLOUT, AI_Smart_Rollout + dbw EFFECT_SWAGGER, AI_Smart_Swagger + dbw EFFECT_FURY_CUTTER, AI_Smart_FuryCutter + dbw EFFECT_ATTRACT, AI_Smart_Attract + dbw EFFECT_SAFEGUARD, AI_Smart_Safeguard + dbw EFFECT_MAGNITUDE, AI_Smart_Magnitude + dbw EFFECT_BATON_PASS, AI_Smart_BatonPass + dbw EFFECT_PURSUIT, AI_Smart_Pursuit + dbw EFFECT_RAPID_SPIN, AI_Smart_RapidSpin + dbw EFFECT_MORNING_SUN, AI_Smart_MorningSun + dbw EFFECT_SYNTHESIS, AI_Smart_Synthesis + dbw EFFECT_MOONLIGHT, AI_Smart_Moonlight + dbw EFFECT_HIDDEN_POWER, AI_Smart_HiddenPower + dbw EFFECT_RAIN_DANCE, AI_Smart_RainDance + dbw EFFECT_SUNNY_DAY, AI_Smart_SunnyDay + dbw EFFECT_BELLY_DRUM, AI_Smart_BellyDrum + dbw EFFECT_PSYCH_UP, AI_Smart_PsychUp + dbw EFFECT_MIRROR_COAT, AI_Smart_MirrorCoat + dbw EFFECT_SKULL_BASH, AI_Smart_SkullBash + dbw EFFECT_TWISTER, AI_Smart_Twister + dbw EFFECT_EARTHQUAKE, AI_Smart_Earthquake + dbw EFFECT_FUTURE_SIGHT, AI_Smart_FutureSight + dbw EFFECT_GUST, AI_Smart_Gust + dbw EFFECT_STOMP, AI_Smart_Stomp + dbw EFFECT_SOLARBEAM, AI_Smart_Solarbeam + dbw EFFECT_THUNDER, AI_Smart_Thunder + dbw EFFECT_FLY, AI_Smart_Fly db $ff ; 387e3 -AIScoring_Sleep: ; 387e3 +AI_Smart_Sleep: ; 387e3 ; Greatly encourage sleep inducing moves if the enemy has either Dream Eater or Nightmare. ; 50% chance to greatly encourage sleep inducing moves otherwise. ld b, EFFECT_DREAM_EATER - call AIHasMove + call AIHasMoveEffect jr c, .asm_387f0 ld b, EFFECT_NIGHTMARE - call AIHasMove + call AIHasMoveEffect ret nc .asm_387f0 - call AIRandom2 + call AI_50_50 ret c dec [hl] dec [hl] @@ -419,7 +423,7 @@ AIScoring_Sleep: ; 387e3 ; 387f7 -AIScoring_LeechHit: ; 387f7 +AI_Smart_LeechHit: ; 387f7 push hl ld a, 1 ld [hBattleTurn], a @@ -439,22 +443,23 @@ AIScoring_LeechHit: ; 387f7 ret c ; 80% chance to encourage this move otherwise. - call AIRandom1 + call AI_80_20 ret c + dec [hl] ret .asm_38815 call Random - - cp $64 + cp 100 ret c + inc [hl] ret ; 3881d -AIScoring_LockOn: ; 3881d +AI_Smart_LockOn: ; 3881d ld a, [PlayerSubStatus5] bit SUBSTATUS_LOCK_ON, a jr nz, .asm_38882 @@ -521,7 +526,7 @@ AIScoring_LockOn: ; 3881d .asm_3887a pop hl - call AIRandom2 + call AI_50_50 ret c dec [hl] @@ -560,12 +565,12 @@ AIScoring_LockOn: ; 3881d ; 388a6 -AIScoring_Explosion: ; 388a6 +AI_Smart_Explosion: ; 388a6 ; Selfdestruct, Explosion ; Unless this is the enemy's last Pokemon... push hl - callba Function349f4 + callba CountEnemyAliveMons pop hl jr nc, .asm_388b7 @@ -598,12 +603,12 @@ AIScoring_Explosion: ; 388a6 ; 388ca -AIScoring_DreamEater: ; 388ca +AI_Smart_DreamEater: ; 388ca ; 90% chance to greatly encourage this move. -; The AIScoring_RedStatus layer will make sure that +; The AI_Basic layer will make sure that ; Dream Eater is only used against sleeping targets. call Random - cp $19 + cp 25 ret c dec [hl] dec [hl] @@ -612,7 +617,7 @@ AIScoring_DreamEater: ; 388ca ; 388d4 -AIScoring_EvasionUp: ; 388d4 +AI_Smart_EvasionUp: ; 388d4 ; Dismiss this move if enemy's evasion can't raise anymore. ld a, [EnemyEvaLevel] @@ -627,7 +632,7 @@ AIScoring_EvasionUp: ; 388d4 ld a, [PlayerSubStatus5] bit SUBSTATUS_TOXIC, a jr nz, .asm_388ef - + ; ...70% chance to greatly encourage this move if player is not badly poisoned. call Random cp $b2 @@ -654,13 +659,13 @@ AIScoring_EvasionUp: ; 388d4 jr nc, .asm_3890a ; If enemy's HP is above 50% but not full, 20% chance to greatly encourage this move. - call AIRandom1 + call AI_80_20 jr c, .asm_388ef jr .asm_38911 .asm_3890a ; ...50% chance to greatly discourage this move. - call AIRandom2 + call AI_50_50 jr c, .asm_38911 .asm_3890f @@ -717,7 +722,7 @@ AIScoring_EvasionUp: ; 388d4 ; 50% chance to encourage this move. ; This would partly counter any previous discouragement. .asm_38941 - call AIRandom2 + call AI_50_50 ret c dec [hl] @@ -725,7 +730,7 @@ AIScoring_EvasionUp: ; 388d4 ; 38947 -AIScoring_AlwaysHit: ; 38947 +AI_Smart_AlwaysHit: ; 38947 ; 80% chance to greatly encourage this move if either... ; ...enemy's accuracy level has been lowered three or more stages @@ -739,16 +744,16 @@ AIScoring_AlwaysHit: ; 38947 ret c .asm_38954 - call AIRandom1 - + call AI_80_20 ret c + dec [hl] dec [hl] ret ; 3895b -AIScoring_MirrorMove: ; 3895b +AI_Smart_MirrorMove: ; 3895b ; If the player did not use any move last turn... ld a, [LastEnemyCounterMove] @@ -758,7 +763,7 @@ AIScoring_MirrorMove: ; 3895b ; ...do nothing if enemy is slower than player call AICompareSpeed ret nc - + ; ...or dismiss this move if enemy is faster than player. jp AIDiscourageMove @@ -774,8 +779,9 @@ AIScoring_MirrorMove: ; 3895b ret nc ; If he did, 50% chance to encourage this move... - call AIRandom2 + call AI_50_50 ret c + dec [hl] ; ...and 90% chance to encourage this move again if the enemy is faster. @@ -791,7 +797,7 @@ AIScoring_MirrorMove: ; 3895b ; 38985 -AIScoring_AccuracyDown: ; 38985 +AI_Smart_AccuracyDown: ; 38985 ; If player's HP is full... call AICheckPlayerMaxHP @@ -832,13 +838,13 @@ AIScoring_AccuracyDown: ; 38985 jr nc, .asm_389b8 ; If player's HP is above 50% but not full, 20% chance to greatly encourage this move. - call AIRandom1 + call AI_80_20 jr c, .asm_3899d jr .asm_389bf ; ...50% chance to greatly discourage this move. .asm_389b8 - call AIRandom2 + call AI_50_50 jr c, .asm_389bf .asm_389bd @@ -890,7 +896,7 @@ AIScoring_AccuracyDown: ; 38985 ; 50% chance to encourage this move. ; This would partly counter any previous discouragement. .asm_389ef - call AIRandom2 + call AI_50_50 ret c dec [hl] @@ -898,7 +904,7 @@ AIScoring_AccuracyDown: ; 38985 ; 389f5 -AIScoring_Haze: ; 389f5 +AI_Smart_Haze: ; 389f5 ; 85% chance to encourage this move if any of enemy's stat levels is lower than -2. push hl @@ -941,7 +947,7 @@ AIScoring_Haze: ; 389f5 ; 38a1e -AIScoring_Bide: ; 38a1e +AI_Smart_Bide: ; 38a1e ; 90% chance to discourage this move unless enemy's HP is full. call AICheckEnemyMaxHP @@ -954,7 +960,7 @@ AIScoring_Bide: ; 38a1e ; 38a2a -AIScoring_Whirlwind: ; 38a2a +AI_Smart_Whirlwind: ; 38a2a ; Whirlwind, Roar. ; Discourage this move if the player has not shown @@ -972,10 +978,10 @@ AIScoring_Whirlwind: ; 38a2a ; 38a3a -AIScoring_Heal: -AIScoring_MorningSun: -AIScoring_Synthesis: -AIScoring_Moonlight: ; 38a3a +AI_Smart_Heal: +AI_Smart_MorningSun: +AI_Smart_Synthesis: +AI_Smart_Moonlight: ; 38a3a ; 90% chance to greatly encourage this move if enemy's HP is below 25%. ; Discourage this move if enemy's HP is higher than 50%. ; Do nothing otherwise. @@ -997,8 +1003,8 @@ AIScoring_Moonlight: ; 38a3a ; 38a4e -AIScoring_Toxic: -AIScoring_LeechSeed: ; 38a4e +AI_Smart_Toxic: +AI_Smart_LeechSeed: ; 38a4e ; Discourage this move if player's HP is below 50%. call AICheckPlayerHalfHP @@ -1008,8 +1014,8 @@ AIScoring_LeechSeed: ; 38a4e ; 38a54 -AIScoring_LightScreen: -AIScoring_Reflect: ; 38a54 +AI_Smart_LightScreen: +AI_Smart_Reflect: ; 38a54 ; Over 90% chance to discourage this move unless enemy's HP is full. call AICheckEnemyMaxHP @@ -1022,7 +1028,7 @@ AIScoring_Reflect: ; 38a54 ; 38a60 -AIScoring_Ohko: ; 38a60 +AI_Smart_Ohko: ; 38a60 ; Dismiss this move if player's level is higher than enemy's level. ; Else, discourage this move is player's HP is below 50%. @@ -1038,7 +1044,7 @@ AIScoring_Ohko: ; 38a60 ; 38a71 -AIScoring_Bind: ; 38a71 +AI_Smart_Bind: ; 38a71 ; Bind, Wrap, Fire Spin, Clamp ; 50% chance to discourage this move if the player is already trapped. @@ -1063,7 +1069,7 @@ AIScoring_Bind: ; 38a71 ; 50% chance to discourage this move otherwise. .asm_38a8b - call AIRandom2 + call AI_50_50 ret c inc [hl] ret @@ -1071,7 +1077,7 @@ AIScoring_Bind: ; 38a71 .asm_38a91 call AICheckEnemyQuarterHP ret nc - call AIRandom2 + call AI_50_50 ret c dec [hl] dec [hl] @@ -1079,8 +1085,8 @@ AIScoring_Bind: ; 38a71 ; 38a9c -AIScoring_RazorWind: -AIScoring_Unused2B: ; 38a9c +AI_Smart_RazorWind: +AI_Smart_Unused2B: ; 38a9c ld a, [EnemySubStatus1] bit SUBSTATUS_PERISH, a jr z, .asm_38aaa @@ -1134,7 +1140,7 @@ AIScoring_Unused2B: ; 38a9c ; 38adb -AIScoring_Confuse: ; 38adb +AI_Smart_Confuse: ; 38adb ; 90% chance to discourage this move if player's HP is between 25% and 50%. call AICheckPlayerHalfHP @@ -1153,7 +1159,7 @@ AIScoring_Confuse: ; 38adb ; 38aed -AIScoring_SpDefenseUp2: ; 38aed +AI_Smart_SpDefenseUp2: ; 38aed ; Discourage this move if enemy's HP is lower than 50%. call AICheckEnemyHalfHP @@ -1168,6 +1174,7 @@ AIScoring_SpDefenseUp2: ; 38aed ; enemy's Special Defense level is lower than +2, and the player is of a special type. cp $9 ret nc + ld a, [BattleMonType1] cp SPECIAL jr nc, .asm_38b09 @@ -1176,7 +1183,7 @@ AIScoring_SpDefenseUp2: ; 38aed ret c .asm_38b09 - call AIRandom1 + call AI_80_20 ret c dec [hl] dec [hl] @@ -1188,7 +1195,7 @@ AIScoring_SpDefenseUp2: ; 38aed ; 38b12 -AIScoring_Fly: ; 38b12 +AI_Smart_Fly: ; 38b12 ; Fly, Dig ; Greatly encourage this move if the player is @@ -1208,7 +1215,7 @@ AIScoring_Fly: ; 38b12 ; 38b20 -AIScoring_SuperFang: ; 38b20 +AI_Smart_SuperFang: ; 38b20 ; Discourage this move if player's HP is below 25%. call AICheckPlayerQuarterHP @@ -1218,7 +1225,7 @@ AIScoring_SuperFang: ; 38b20 ; 38b26 -AIScoring_Paralyze: ; 38b26 +AI_Smart_Paralyze: ; 38b26 ; 50% chance to discourage this move if player's HP is below 25%. call AICheckPlayerQuarterHP @@ -1230,21 +1237,21 @@ AIScoring_Paralyze: ; 38b26 ret c call AICheckEnemyQuarterHP ret nc - call AIRandom1 + call AI_80_20 ret c dec [hl] dec [hl] ret .asm_38b3a - call AIRandom2 + call AI_50_50 ret c inc [hl] ret ; 38b40 -AIScoring_SpeedDownHit: ; 38b40 +AI_Smart_SpeedDownHit: ; 38b40 ; Icy Wind ; Almost 90% chance to greatly encourage this move if the following conditions all meet: @@ -1271,7 +1278,7 @@ AIScoring_SpeedDownHit: ; 38b40 ; 38b5c -AIScoring_Substitute: ; 38b5c +AI_Smart_Substitute: ; 38b5c ; Dismiss this move if enemy's HP is below 50%. call AICheckEnemyHalfHP @@ -1280,14 +1287,14 @@ AIScoring_Substitute: ; 38b5c ; 38b63 -AIScoring_HyperBeam: ; 38b63 +AI_Smart_HyperBeam: ; 38b63 call AICheckEnemyHalfHP jr c, .asm_38b72 ; 50% chance to encourage this move if enemy's HP is below 25%. call AICheckEnemyQuarterHP ret c - call AIRandom2 + call AI_50_50 ret c dec [hl] ret @@ -1298,21 +1305,22 @@ AIScoring_HyperBeam: ; 38b63 cp 40 ret c inc [hl] - call AIRandom2 + call AI_50_50 ret c inc [hl] ret ; 38b7f -AIScoring_Rage: ; 38b7f +AI_Smart_Rage: ; 38b7f ld a, [EnemySubStatus4] bit SUBSTATUS_RAGE, a jr z, .asm_38b9b ; If enemy's Rage is building, 50% chance to encourage this move. - call AIRandom2 + call AI_50_50 jr c, .asm_38b8c + dec [hl] ; Encourage this move based on Rage's counter. @@ -1333,7 +1341,7 @@ AIScoring_Rage: ; 38b7f jr nc, .asm_38ba6 ; 50% chance to encourage this move otherwise. - call AIRandom1 + call AI_80_20 ret nc dec [hl] ret @@ -1344,7 +1352,7 @@ AIScoring_Rage: ; 38b7f ; 38ba8 -AIScoring_Mimic: ; 38ba8 +AI_Smart_Mimic: ; 38ba8 ld a, [LastEnemyCounterMove] and a jr z, .asm_38be9 @@ -1366,7 +1374,7 @@ AIScoring_Mimic: ; 38ba8 jr c, .asm_38bef jr z, .asm_38bd4 - call AIRandom2 + call AI_50_50 jr c, .asm_38bd4 dec [hl] @@ -1380,7 +1388,7 @@ AIScoring_Mimic: ; 38ba8 pop hl ret nc - call AIRandom2 + call AI_50_50 ret c dec [hl] ret @@ -1395,7 +1403,7 @@ AIScoring_Mimic: ; 38ba8 ; 38bf1 -AIScoring_Counter: ; 38bf1 +AI_Smart_Counter: ; 38bf1 push hl ld hl, PlayerUsedMoves ld c, 4 @@ -1461,7 +1469,7 @@ AIScoring_Counter: ; 38bf1 ; 38c3b -AIScoring_Encore: ; 38c3b +AI_Smart_Encore: ; 38c3b call AICompareSpeed jr nc, .asm_38c81 @@ -1492,7 +1500,7 @@ AIScoring_Encore: ; 38c3b .asm_38c68 push hl ld a, [LastEnemyCounterMove] - ld hl, .encoremoves + ld hl, .EncoreMoves ld de, 1 call IsInArray pop hl @@ -1512,7 +1520,7 @@ AIScoring_Encore: ; 38c3b inc [hl] ret -.encoremoves +.EncoreMoves: db SWORDS_DANCE db WHIRLWIND db LEER @@ -1547,7 +1555,7 @@ AIScoring_Encore: ; 38c3b ; 38ca4 -AIScoring_PainSplit: ; 38ca4 +AI_Smart_PainSplit: ; 38ca4 ; Discourage this move if [enemy's current HP * 2 > player's current HP]. push hl @@ -1569,8 +1577,8 @@ AIScoring_PainSplit: ; 38ca4 ; 38cba -AIScoring_Snore: -AIScoring_SleepTalk: ; 38cba +AI_Smart_Snore: +AI_Smart_SleepTalk: ; 38cba ; Greatly encourage this move if enemy is fast asleep. ; Greatly discourage this move otherwise. @@ -1592,7 +1600,7 @@ AIScoring_SleepTalk: ; 38cba ; 38ccb -AIScoring_DefrostOpponent: ; 38ccb +AI_Smart_DefrostOpponent: ; 38ccb ; Greatly encourage this move if enemy is frozen. ; No move has EFFECT_DEFROST_OPPONENT, so this layer is unused. @@ -1606,7 +1614,7 @@ AIScoring_DefrostOpponent: ; 38ccb ; 38cd5 -AIScoring_Spite: ; 38cd5 +AI_Smart_Spite: ; 38cd5 ld a, [LastEnemyCounterMove] and a jr nz, .asm_38ce7 @@ -1614,7 +1622,7 @@ AIScoring_Spite: ; 38cd5 call AICompareSpeed jp c, AIDiscourageMove - call AIRandom2 + call AI_50_50 ret c inc [hl] ret @@ -1669,9 +1677,9 @@ Function_0x38d16; 38d16 ; 38d19 -AIScoring_DestinyBond: -AIScoring_Reversal: -AIScoring_SkullBash: ; 38d19 +AI_Smart_DestinyBond: +AI_Smart_Reversal: +AI_Smart_SkullBash: ; 38d19 ; Discourage this move if enemy's HP is above 25%. call AICheckEnemyQuarterHP @@ -1681,7 +1689,7 @@ AIScoring_SkullBash: ; 38d19 ; 38d1f -AIScoring_HealBell: ; 38d1f +AI_Smart_HealBell: ; 38d1f ; Dismiss this move if none of the opponent's Pokemon is statused. ; Encourage this move if the enemy is statused. ; 50% chance to greatly encourage this move if the enemy is fast asleep or frozen. @@ -1699,10 +1707,11 @@ AIScoring_HealBell: ; 38d1f or [hl] jr z, .next + ; status + dec hl dec hl dec hl - dec hl ; status - ld a, [hl] + ld a, [hl] or c ld c, a @@ -1724,7 +1733,7 @@ AIScoring_HealBell: ; 38d1f .ok and 1 << FRZ | SLP ret z - call AIRandom2 + call AI_50_50 ret c dec [hl] dec [hl] @@ -1739,10 +1748,10 @@ AIScoring_HealBell: ; 38d1f ; 38d5a -AIScoring_PriorityHit: ; 38d5a +AI_Smart_PriorityHit: ; 38d5a call AICompareSpeed ret c - + ; Dismiss this move if the player is flying or underground. ld a, [PlayerSubStatus3] and 1 << SUBSTATUS_FLYING | 1 << SUBSTATUS_UNDERGROUND @@ -1772,7 +1781,7 @@ AIScoring_PriorityHit: ; 38d5a ; 38d93 -AIScoring_Thief: ; 38d93 +AI_Smart_Thief: ; 38d93 ; Don't use Thief unless it's the only move available. ld a, [hl] @@ -1782,7 +1791,7 @@ AIScoring_Thief: ; 38d93 ; 38d98 -AIScoring_Conversion2: ; 38d98 +AI_Smart_Conversion2: ; 38d98 ld a, [LastPlayerMove] and a jr nz, .asm_38dc9 @@ -1806,25 +1815,24 @@ AIScoring_Conversion2: ; 38d98 cp $a pop hl jr c, .asm_38dc9 - ret z - call AIRandom2 + call AI_50_50 ret c + dec [hl] ret .asm_38dc9 call Random - - cp $19 + cp 25 ret c inc [hl] ret ; 38dd1 -AIScoring_Disable: ; 38dd1 +AI_Smart_Disable: ; 38dd1 call AICompareSpeed jr nc, .asm_38df3 @@ -1857,7 +1865,7 @@ AIScoring_Disable: ; 38dd1 ; 38dfb -AIScoring_MeanLook: ; 38dfb +AI_Smart_MeanLook: ; 38dfb call AICheckEnemyHalfHP jr nc, .asm_38e24 @@ -1890,7 +1898,7 @@ AIScoring_MeanLook: ; 38dfb ret .asm_38e26 - call AIRandom1 + call AI_80_20 ret c dec [hl] dec [hl] @@ -1926,19 +1934,19 @@ AICheckLastPlayerMon: ; 38e2e ; 38e4a -AIScoring_Nightmare: ; 38e4a +AI_Smart_Nightmare: ; 38e4a ; 50% chance to encourage this move. -; The AIScoring_RedStatus layer will make sure that +; The AI_Basic layer will make sure that ; Dream Eater is only used against sleeping targets. - call AIRandom2 + call AI_50_50 ret c dec [hl] ret ; 38e50 -AIScoring_FlameWheel: ; 38e50 +AI_Smart_FlameWheel: ; 38e50 ; Use this move if the enemy is frozen. ld a, [EnemyMonStatus] @@ -1953,7 +1961,7 @@ AIScoring_FlameWheel: ; 38e50 ; 38e5c -AIScoring_Curse: ; 38e5c +AI_Smart_Curse: ; 38e5c ld a, [EnemyMonType1] cp GHOST jr z, .ghostcurse @@ -1978,7 +1986,7 @@ AIScoring_Curse: ; 38e5c ld a, [BattleMonType2] cp SPECIAL ret nc - call AIRandom1 + call AI_80_20 ret c dec [hl] dec [hl] @@ -1999,7 +2007,7 @@ AIScoring_Curse: ; 38e5c jp nz, AIDiscourageMove push hl - callba Function349f4 + callba CountEnemyAliveMons pop hl jr nc, .asm_38eb0 @@ -2033,16 +2041,16 @@ AIScoring_Curse: ; 38e5c ret nz .asm_38ecb - call AIRandom2 - + call AI_50_50 ret c + dec [hl] dec [hl] ret ; 38ed2 -AIScoring_Protect: ; 38ed2 +AI_Smart_Protect: ; 38ed2 ld a, [$c681] and a jr nz, .asm_38f13 @@ -2077,7 +2085,7 @@ AIScoring_Protect: ; 38ed2 jr c, .asm_38f14 .asm_38f0d - call AIRandom1 + call AI_80_20 ret c dec [hl] ret @@ -2095,7 +2103,7 @@ AIScoring_Protect: ; 38ed2 ; 38f1d -AIScoring_Foresight: ; 38f1d +AI_Smart_Foresight: ; 38f1d ld a, [EnemyAccLevel] cp $5 jr c, .asm_38f41 @@ -2126,15 +2134,15 @@ AIScoring_Foresight: ; 38f1d ; 38f4a -AIScoring_PerishSong: ; 38f4a +AI_Smart_PerishSong: ; 38f4a push hl - callab Function349f4 + callab CountEnemyAliveMons pop hl - jr c, .asm_38f75 + jr c, .no ld a, [PlayerSubStatus5] bit SUBSTATUS_CANT_RUN, a - jr nz, .asm_38f6f + jr nz, .yes push hl callab Function3484e @@ -2143,20 +2151,20 @@ AIScoring_PerishSong: ; 38f4a pop hl ret c - call AIRandom2 + call AI_50_50 ret c inc [hl] ret -.asm_38f6f - call AIRandom2 +.yes + call AI_50_50 ret c dec [hl] ret -.asm_38f75 +.no ld a, [hl] add 5 ld [hl], a @@ -2164,7 +2172,7 @@ AIScoring_PerishSong: ; 38f4a ; 38f7a -AIScoring_Sandstorm: ; 38f7a +AI_Smart_Sandstorm: ; 38f7a ; Greatly discourage this move if the player is immune to Sandstorm damage. ld a, [BattleMonType1] @@ -2188,7 +2196,7 @@ AIScoring_Sandstorm: ; 38f7a jr nc, .asm_38fa6 ; 50% chance to encourage this move otherwise. - call AIRandom2 + call AI_50_50 ret c dec [hl] @@ -2209,7 +2217,7 @@ AIScoring_Sandstorm: ; 38f7a ; 38fac -AIScoring_Endure: ; 38fac +AI_Smart_Endure: ; 38fac ld a, [$c681] and a jr nz, .asm_38fd8 @@ -2221,10 +2229,10 @@ AIScoring_Endure: ; 38fac jr c, .asm_38fd9 ld b, EFFECT_REVERSAL - call AIHasMove + call AIHasMoveEffect jr nc, .asm_38fcb - call AIRandom1 + call AI_80_20 ret c dec [hl] @@ -2236,9 +2244,10 @@ AIScoring_Endure: ; 38fac ld a, [EnemySubStatus5] bit SUBSTATUS_LOCK_ON, a ret z - call AIRandom2 + call AI_50_50 ret c + dec [hl] dec [hl] ret @@ -2252,7 +2261,7 @@ AIScoring_Endure: ; 38fac ; 38fdb -AIScoring_FuryCutter: ; 38fdb +AI_Smart_FuryCutter: ; 38fdb ; Encourage this move based on Fury Cutter's count. ld a, [EnemyFuryCutterCount] @@ -2272,11 +2281,12 @@ AIScoring_FuryCutter: ; 38fdb dec [hl] .end + ; fallthrough ; 38fef -AIScoring_Rollout: ; 38fef +AI_Smart_Rollout: ; 38fef ; Rollout, Fury Cutter ; 80% chance to discourage this move if the enemy is in love, confused, or paralyzed. @@ -2313,15 +2323,15 @@ AIScoring_Rollout: ; 38fef ret .asm_39020 - call AIRandom1 + call AI_80_20 ret c inc [hl] ret ; 39026 -AIScoring_Swagger: -AIScoring_Attract: ; 39026 +AI_Smart_Swagger: +AI_Smart_Attract: ; 39026 ; 80% chance to encourage this move during the first turn of player's Pokemon. ; 80% chance to discourage this move otherwise. @@ -2329,7 +2339,7 @@ AIScoring_Attract: ; 39026 and a jr z, .first_turn - call AIRandom1 + call AI_80_20 ret c inc [hl] ret @@ -2343,20 +2353,20 @@ AIScoring_Attract: ; 39026 ; 3903a -AIScoring_Safeguard: ; 3903a +AI_Smart_Safeguard: ; 3903a ; 80% chance to discourage this move if player's HP is below 50%. call AICheckPlayerHalfHP ret c - call AIRandom1 + call AI_80_20 ret c inc [hl] ret ; 39044 -AIScoring_Magnitude: -AIScoring_Earthquake: ; 39044 +AI_Smart_Magnitude: +AI_Smart_Earthquake: ; 39044 ; Greatly encourage this move if the player is underground and the enemy is faster. ld a, [LastEnemyCounterMove] @@ -2365,7 +2375,7 @@ AIScoring_Earthquake: ; 39044 ld a, [PlayerSubStatus3] bit SUBSTATUS_UNDERGROUND, a - jr z, .couldDig + jr z, .could_dig call AICompareSpeed ret nc @@ -2373,20 +2383,22 @@ AIScoring_Earthquake: ; 39044 dec [hl] ret -; Try to predict if the player will use Dig this turn. -.couldDig +.could_dig + ; Try to predict if the player will use Dig this turn. -; 50% chance to encourage this move if the enemy is slower than the player. + ; 50% chance to encourage this move if the enemy is slower than the player. call AICompareSpeed ret c - call AIRandom2 + + call AI_50_50 ret c + dec [hl] ret ; 39062 -AIScoring_BatonPass: ; 39062 +AI_Smart_BatonPass: ; 39062 ; Discourage this move if the player hasn't shown super-effective moves against the enemy. ; Consider player's type(s) if its moves are unknown. @@ -2401,19 +2413,19 @@ AIScoring_BatonPass: ; 39062 ; 39072 -AIScoring_Pursuit: ; 39072 +AI_Smart_Pursuit: ; 39072 ; 50% chance to greatly encourage this move if player's HP is below 25%. ; 80% chance to discourage this move otherwise. call AICheckPlayerQuarterHP jr nc, .asm_3907d - call AIRandom1 + call AI_80_20 ret c inc [hl] ret .asm_3907d - call AIRandom2 + call AI_50_50 ret c dec [hl] dec [hl] @@ -2421,7 +2433,7 @@ AIScoring_Pursuit: ; 39072 ; 39084 -AIScoring_RapidSpin: ; 39084 +AI_Smart_RapidSpin: ; 39084 ; 80% chance to greatly encourage this move if the enemy is ; trapped (Bind effect), seeded, or scattered with spikes. @@ -2438,15 +2450,16 @@ AIScoring_RapidSpin: ; 39084 ret z .asm_39097 - call AIRandom1 + call AI_80_20 ret c + dec [hl] dec [hl] ret ; 3909e -AIScoring_HiddenPower: ; 3909e +AI_Smart_HiddenPower: ; 3909e push hl ld a, 1 ld [hBattleTurn], a @@ -2458,37 +2471,35 @@ AIScoring_HiddenPower: ; 3909e ; Discourage Hidden Power if not very effective. ld a, [$d265] - cp $a - jr c, .asm_390c9 - + cp 10 + jr c, .bad + ; Discourage Hidden Power if its base power is lower than 50. ld a, d cp 50 - jr c, .asm_390c9 - + jr c, .bad + ; Encourage Hidden Power if super-effective. ld a, [$d265] - cp $b - jr nc, .asm_390c7 - + cp 11 + jr nc, .good + ; Encourage Hidden Power if its base power is 70. ld a, d - cp 70 - -; Do nothing if none of these conditions meet. + cp 70 ret c -.asm_390c7 +.good dec [hl] ret -.asm_390c9 +.bad inc [hl] ret ; 390cb -AIScoring_RainDance: ; 390cb +AI_Smart_RainDance: ; 390cb ; Greatly discourage this move if it would favour the player type-wise. ; Particularly, if the player is a Water-type. @@ -2506,7 +2517,7 @@ AIScoring_RainDance: ; 390cb push hl ld hl, RainDanceMoves - jr AIScoring_WeatherMove + jr AI_Smart_WeatherMove ; 390e7 RainDanceMoves: ; 390e7 @@ -2525,7 +2536,7 @@ RainDanceMoves: ; 390e7 ; 390f3 -AIScoring_SunnyDay: ; 390f3 +AI_Smart_SunnyDay: ; 390f3 ; Greatly discourage this move if it would favour the player type-wise. ; Particularly, if the player is a Fire-type. @@ -2548,7 +2559,7 @@ AIScoring_SunnyDay: ; 390f3 ; 3910d -AIScoring_WeatherMove: ; 3910d +AI_Smart_WeatherMove: ; 3910d ; Rain Dance, Sunny Day ; Greatly discourage this move if the enemy doesn't have @@ -2562,7 +2573,7 @@ AIScoring_WeatherMove: ; 3910d jr nc, AIBadWeatherType ; 50% chance to encourage this move otherwise. - call AIRandom2 + call AI_50_50 ret c dec [hl] @@ -2614,7 +2625,7 @@ SunnyDayMoves: ; 39134 ; 3913d -AIScoring_BellyDrum: ; 3913d +AI_Smart_BellyDrum: ; 3913d ; Dismiss this move if enemy's attack is higher than +2 or if enemy's HP is below 50%. ; Else, discourage this move if enemy's HP is not full. @@ -2624,8 +2635,9 @@ AIScoring_BellyDrum: ; 3913d call AICheckEnemyMaxHP ret c - + inc [hl] + call AICheckEnemyHalfHP ret c @@ -2637,7 +2649,7 @@ AIScoring_BellyDrum: ; 3913d ; 39152 -AIScoring_PsychUp: ; 39152 +AI_Smart_PsychUp: ; 39152 push hl ld hl, EnemyAtkLevel ld b, $8 @@ -2648,7 +2660,7 @@ AIScoring_PsychUp: ; 39152 .asm_3915a ld a, [hli] sub $7 - add c + add c ld c, a dec b jr nz, .asm_3915a @@ -2682,9 +2694,10 @@ AIScoring_PsychUp: ; 39152 ld a, [EnemyEvaLevel] cp $8 ret nc - call AIRandom1 + call AI_80_20 ret c + dec [hl] ret @@ -2695,7 +2708,7 @@ AIScoring_PsychUp: ; 39152 ; 3918b -AIScoring_MirrorCoat: ; 3918b +AI_Smart_MirrorCoat: ; 3918b push hl ld hl, PlayerUsedMoves ld c, $4 @@ -2760,8 +2773,8 @@ AIScoring_MirrorCoat: ; 3918b ; 391d5 -AIScoring_Twister: -AIScoring_Gust: ; 391d5 +AI_Smart_Twister: +AI_Smart_Gust: ; 391d5 ; Greatly encourage this move if the player is flying and the enemy is faster. ld a, [LastEnemyCounterMove] @@ -2774,6 +2787,7 @@ AIScoring_Gust: ; 391d5 call AICompareSpeed ret nc + dec [hl] dec [hl] ret @@ -2784,14 +2798,14 @@ AIScoring_Gust: ; 391d5 ; 50% chance to encourage this move if the enemy is slower than the player. call AICompareSpeed ret c - call AIRandom2 + call AI_50_50 ret c dec [hl] ret ; 391f3 -AIScoring_FutureSight: ; 391f3 +AI_Smart_FutureSight: ; 391f3 ; Greatly encourage this move if the player is ; flying or underground, and slower than the enemy. @@ -2808,14 +2822,14 @@ AIScoring_FutureSight: ; 391f3 ; 39200 -AIScoring_Stomp: ; 39200 +AI_Smart_Stomp: ; 39200 ; 80% chance to encourage this move if the player has used Minimize. ld a, [$c6fe] and a ret z - call AIRandom1 + call AI_80_20 ret c dec [hl] @@ -2823,7 +2837,7 @@ AIScoring_Stomp: ; 39200 ; 3920b -AIScoring_Solarbeam: ; 3920b +AI_Smart_Solarbeam: ; 3920b ; 80% chance to encourage this move when it's sunny. ; 90% chance to discourage this move when it's raining. @@ -2843,7 +2857,7 @@ AIScoring_Solarbeam: ; 3920b ret .asm_3921e - call AIRandom1 + call AI_80_20 ret c dec [hl] @@ -2852,7 +2866,7 @@ AIScoring_Solarbeam: ; 3920b ; 39225 -AIScoring_Thunder: ; 39225 +AI_Smart_Thunder: ; 39225 ; 90% chance to discourage this move when it's sunny. ld a, [Weather] @@ -3021,7 +3035,7 @@ AICheckPlayerQuarterHP: ; 392b3 ; 392ca -AIHasMove: ; 392ca +AIHasMoveEffect: ; 392ca ; Return carry if the enemy has move b. push hl @@ -3031,23 +3045,23 @@ AIHasMove: ; 392ca .checkmove ld a, [hli] and a - jr z, .asm_392e0 + jr z, .no call AIGetEnemyMove ld a, [wEnemyMoveStruct + MOVE_EFFECT] cp b - jr z, .asm_392e3 + jr z, .yes dec c jr nz, .checkmove -.asm_392e0 +.no pop hl and a ret -.asm_392e3 +.yes pop hl scf ret @@ -3061,27 +3075,27 @@ AIHasMoveInArray: ; 392e6 push de push bc -.asm_392e9 +.next ld a, [hli] cp $ff - jr z, .asm_392fd + jr z, .done ld b, a ld c, EnemyMonMovesEnd - EnemyMonMoves + 1 ld de, EnemyMonMoves -.asm_392f4 +.check dec c - jr z, .asm_392e9 + jr z, .next ld a, [de] inc de cp b - jr nz, .asm_392f4 + jr nz, .check scf -.asm_392fd +.done pop bc pop de pop hl @@ -3090,6 +3104,7 @@ AIHasMoveInArray: ; 392e6 UsefulMoves: ; 39301 +; Moves that are usable all-around. db DOUBLE_EDGE db SING db FLAMETHROWER @@ -3113,7 +3128,7 @@ UsefulMoves: ; 39301 ; 39315 -AIScoring_Opportunist: ; 39315 +AI_Opportunist: ; 39315 ; Discourage stall moves when the enemy's HP is low. ; Do nothing if enemy's HP is above 50%. @@ -3125,7 +3140,7 @@ AIScoring_Opportunist: ; 39315 jr nc, .asm_39322 ; 50% chance to discourage stall moves if enemy's HP is between 25% and 50%. - call AIRandom2 + call AI_50_50 ret c .asm_39322 @@ -3198,7 +3213,9 @@ AIScoring_Opportunist: ; 39315 -AIScoring_Aggressive: ; 39369 +AI_Aggressive: ; 39369 +; Use whatever does the most damage. + ; Discourage all damaging moves but the one that does the most damage. ; If no damaging move deals damage to the player (immune), ; no move will be discouraged @@ -3250,13 +3267,12 @@ AIScoring_Aggressive: ; 39369 jr .checkmove .gotstrongestmove -; Discourage moves that do less damage unless they're reckless too. - ; Nothing we can do if no attacks did damage. ld a, c and a jr z, .done +; Discourage moves that do less damage unless they're reckless too. ld hl, Buffer1 - 1 ld de, EnemyMonMoves ld b, 0 @@ -3287,7 +3303,7 @@ AIScoring_Aggressive: ; 39369 push de push bc ld a, [wEnemyMoveStruct + MOVE_EFFECT] - ld hl, .recklessmoves + ld hl, .RecklessMoves ld de, 1 call IsInArray pop bc @@ -3302,7 +3318,7 @@ AIScoring_Aggressive: ; 39369 .done ret -.recklessmoves +.RecklessMoves: db EFFECT_EXPLOSION db EFFECT_RAMPAGE db EFFECT_MULTI_HIT @@ -3337,8 +3353,8 @@ AIDamageCalc: ; 393e7 ; 39418 -AIScoring_Cautious: ; 39418 -; 90% chance to discourage moves with residual effects after enemy's Pokemon first turn. +AI_Cautious: ; 39418 +; 90% chance to discourage moves with residual effects after the first turn. ld a, [EnemyTurnsTaken] and a @@ -3394,7 +3410,7 @@ AIScoring_Cautious: ; 39418 -AIScoring_StatusImmunity: ; 39453 +AI_Status: ; 39453 ; Dismiss status moves that don't affect the player. ld hl, Buffer1 - 1 @@ -3458,7 +3474,7 @@ AIScoring_StatusImmunity: ; 39453 -AIScoring_Risky: ; 394a9 +AI_Risky: ; 394a9 ; Use any move that will KO the target. ; Risky moves will often be an exception (see below). @@ -3483,20 +3499,20 @@ AIScoring_Risky: ; 394a9 ld a, [wEnemyMoveStruct + MOVE_POWER] and a jr z, .nextmove - + +; Don't use risky moves at max hp. ld a, [wEnemyMoveStruct + MOVE_EFFECT] ld de, 1 - ld hl, .riskymoves + ld hl, .RiskyMoves call IsInArray jr nc, .checkko -; Exclude risky moves if enemy's HP is full. call AICheckEnemyMaxHP jr c, .nextmove ; Else, 80% chance to exclude them. call Random - cp 200 + cp 200 ; 1/5 jr c, .nextmove .checkko @@ -3526,7 +3542,7 @@ AIScoring_Risky: ; 394a9 pop de jr .checkmove -.riskymoves +.RiskyMoves: db EFFECT_EXPLOSION db EFFECT_OHKO db $ff @@ -3534,7 +3550,7 @@ AIScoring_Risky: ; 394a9 -AIScoring_None: ; 39502 +AI_None: ; 39502 ret ; 39503 @@ -3569,14 +3585,14 @@ AIGetEnemyMove: ; 39508 ; 39521 -AIRandom1: ; 39521 +AI_80_20: ; 39521 call Random cp 50 ; 1/5 ret ; 39527 -AIRandom2: ; 39527 +AI_50_50: ; 39527 call Random cp $80 ; 1/2 ret diff --git a/battle/core.asm b/battle/core.asm index e550d4480..03eb40b85 100644 --- a/battle/core.asm +++ b/battle/core.asm @@ -480,7 +480,7 @@ Function3c314: ; 3c314 jp .asm_3c3f1 .asm_3c34c - callab Function3846c + callab AI_Switch call SetEnemyTurn call SpikesDamage jp Function3c3f3 @@ -5454,7 +5454,7 @@ Function3e3ad: ; 3e3ad ; 3e3ff Function3e3ff: ; 3e3ff - callab Function3846c + callab AI_Switch call SetEnemyTurn jp SpikesDamage ; 3e40b diff --git a/battle/effect_commands.asm b/battle/effect_commands.asm index 39b36c0af..21d005bc6 100644 --- a/battle/effect_commands.asm +++ b/battle/effect_commands.asm @@ -1041,6 +1041,7 @@ BattleCommand04: ; 34555 ld bc, EnemyTurnsTaken .asm_34570 + ; If we've gotten this far, this counts as a turn. ld a, [bc] inc a @@ -1052,7 +1053,7 @@ BattleCommand04: ; 34555 ret z ld a, [de] - and %111 ; rollout | bide | ??? + and 1 << SUBSTATUS_IN_LOOP | 1 << SUBSTATUS_RAMPAGE | 1 << SUBSTATUS_BIDE ret nz call .asm_345ad @@ -1060,7 +1061,7 @@ BattleCommand04: ; 34555 and a jp nz, EndMoveEffect -; SubStatus5 + ; SubStatus5 inc de inc de @@ -1542,28 +1543,28 @@ Function347d3: ; 347d3 .asm_347e7 ld a, [hli] cp $ff - jr z, .asm_3482f ; 0x347ea $43 + jr z, .asm_3482f cp $fe - jr nz, .asm_347fb ; 0x347ee $b + jr nz, .asm_347fb ld a, BATTLE_VARS_SUBSTATUS1_OPP call GetBattleVar bit SUBSTATUS_IDENTIFIED, a - jr nz, .asm_3482f ; 0x347f7 $36 - jr .asm_347e7 ; 0x347f9 $ec + jr nz, .asm_3482f + jr .asm_347e7 .asm_347fb cp d - jr nz, .asm_34807 ; 0x347fc $9 + jr nz, .asm_34807 ld a, [hli] cp b - jr z, .asm_3480b ; 0x34800 $9 + jr z, .asm_3480b cp c - jr z, .asm_3480b ; 0x34803 $6 - jr .asm_34808 ; 0x34805 $1 + jr z, .asm_3480b + jr .asm_34808 .asm_34807 inc hl .asm_34808 inc hl - jr .asm_347e7 ; 0x34809 $dc + jr .asm_347e7 .asm_3480b xor a ld [$ffb3], a @@ -1572,17 +1573,18 @@ Function347d3: ; 347d3 ld a, [hli] ld [$ffb6], a ld a, [$d265] - ld [$ffb7], a + ld [hMultiplier], a call Multiply - ld a, $a - ld [$ffb7], a + ld a, 10 + ld [hDivisor], a push bc - ld b, $4 + ld b, 4 call Divide pop bc ld a, [$ffb6] ld [$d265], a - jr .asm_347e7 ; 0x3482d $b8 + jr .asm_347e7 + .asm_3482f pop bc pop de @@ -1613,7 +1615,7 @@ Function3484e: ; 3484e push hl push de push bc - ld a, $a + ld a, 10 ld [$c716], a ld hl, PlayerUsedMoves ld a, [hl] @@ -1795,24 +1797,26 @@ Function34939: ; 34939 Function34941: ; 34941 xor a ld [$c717], a - call Function349f4 + call CountEnemyAliveMons ret c ld a, [EnemySubStatus1] bit SUBSTATUS_PERISH, a - jr z, .asm_34986 + jr z, .no_perish ld a, [EnemyPerishCount] cp 1 - jr nz, .asm_34986 + jr nz, .no_perish - call Function349f4 + ; Perish count is 1 + + call CountEnemyAliveMons call Function34b77 call Function34b20 call Function34a85 ld a, e - cp $2 + cp 2 jr nz, .asm_34971 ld a, [$c716] @@ -1821,7 +1825,7 @@ Function34941: ; 34941 ret .asm_34971 - call Function349f4 + call CountEnemyAliveMons sla c sla c ld b, $ff @@ -1836,10 +1840,11 @@ Function34941: ; 34941 ld [$c717], a ret -.asm_34986 +.no_perish + call Function3484e ld a, [$c716] - cp $b + cp 11 ret nc ld a, [LastEnemyCounterMove] @@ -1859,12 +1864,12 @@ Function34941: ; 34941 ld b, a ld a, e - cp $2 + cp 2 jr z, .asm_349be call Function3484e ld a, [$c716] - cp $a + cp 10 ret nc ld a, b @@ -1876,7 +1881,7 @@ Function34941: ; 34941 ld c, $10 call Function3484e ld a, [$c716] - cp $a + cp 10 jr nc, .asm_349cc ld c, $20 @@ -1889,10 +1894,10 @@ Function34941: ; 34941 .asm_349d2 call Function3484e ld a, [$c716] - cp $a + cp 10 ret nc - call Function349f4 + call CountEnemyAliveMons call Function34b77 call Function34b20 call Function34a85 @@ -1908,7 +1913,7 @@ Function34941: ; 34941 ; 349f4 -Function349f4: ; 349f4 +CountEnemyAliveMons: ; 349f4 ld a, [OTPartyCount] cp 2 jr c, .only_one @@ -1964,7 +1969,7 @@ Function34a2a: ; 34a2a ld hl, OTPartyMon1 ld a, [OTPartyCount] ld b, a - ld c, $20 + ld c, 1 << (PARTY_LENGTH - 1) ld d, 0 xor a ld [$c716], a @@ -2027,8 +2032,8 @@ Function34a85: ; 34a85 ld a, [OTPartyCount] ld e, a ld hl, OTPartyMon1HP - ld b, $20 - ld c, $0 + ld b, 1 << (PARTY_LENGTH - 1) + ld c, 0 .asm_34a91 ld a, [hli] or [hl] @@ -2061,9 +2066,9 @@ Function34aa7: ; 34aa7 ld a, $ff ld [$c716], a ld hl, OTPartyMon1Moves - ld b, $20 - ld d, $0 - ld e, $0 + ld b, 1 << (PARTY_LENGTH - 1) + ld d, 0 + ld e, 0 .asm_34ab5 ld a, b and c @@ -2072,7 +2077,7 @@ Function34aa7: ; 34aa7 push hl push bc ld b, NUM_MOVES - ld c, $0 + ld c, 0 .asm_34abf ld a, [hli] and a @@ -2090,14 +2095,14 @@ Function34aa7: ; 34aa7 ld hl, BattleMonType1 call Function347d3 ld a, [$d265] - cp $a + cp 10 jr c, .asm_34ae9 - ld e, $1 - cp $b + ld e, 1 + cp 11 jr c, .asm_34ae9 - ld e, $2 + ld e, 2 jr .asm_34aef .asm_34ae9 @@ -2157,8 +2162,8 @@ Function34aa7: ; 34aa7 Function34b20: ; 34b20 push bc ld hl, OTPartySpecies - ld b, $20 - ld c, $0 + ld b, 1 << (PARTY_LENGTH - 1) + ld c, 0 .asm_34b28 ld a, [hli] @@ -2350,7 +2355,7 @@ BattleCommand09: ; 34d32 call .ThunderRain ret z - call .UnleashedEnergy + call .XAccuracy ret nz ; Perfect-accuracy moves @@ -2545,11 +2550,10 @@ BattleCommand09: ; 34d32 ret -.UnleashedEnergy -; Return nz if unleashing energy from Bide. +.XAccuracy ld a, BATTLE_VARS_SUBSTATUS4 call GetBattleVar - bit SUBSTATUS_UNLEASH, a + bit SUBSTATUS_X_ACCURACY, a ret @@ -6915,8 +6919,9 @@ BattleCommand21: ; 36671 ld a, BATTLE_VARS_SUBSTATUS3 call GetBattleVar - bit 0, a + bit SUBSTATUS_BIDE, a ret z + ld hl, PlayerRolloutCount ld a, [hBattleTurn] and a @@ -6925,9 +6930,10 @@ BattleCommand21: ; 36671 .asm_36684 dec [hl] jr nz, .asm_366dc + ld a, BATTLE_VARS_SUBSTATUS3 call GetBattleVarAddr - res 0, [hl] + res SUBSTATUS_BIDE, [hl] ld hl, UnleashedEnergyText call StdBattleTextBox @@ -6988,13 +6994,13 @@ BattleCommand22: ; 366e5 ld bc, PlayerRolloutCount ld a, [hBattleTurn] and a - jr z, .asm_366f6 ; 366ee $6 + jr z, .asm_366f6 ld de, $c684 ld bc, EnemyRolloutCount .asm_366f6 ld a, BATTLE_VARS_SUBSTATUS3 call GetBattleVarAddr - set 0, [hl] + set SUBSTATUS_BIDE, [hl] xor a ld [de], a inc de @@ -7002,11 +7008,11 @@ BattleCommand22: ; 366e5 ld [wPlayerMoveStruct + MOVE_EFFECT], a ld [wEnemyMoveStruct + MOVE_EFFECT], a call BattleRandom - and $1 + and 1 inc a inc a ld [bc], a - ld a, $1 + ld a, 1 ld [$c689], a call AnimateCurrentMove jp EndMoveEffect @@ -7219,7 +7225,7 @@ BattleCommand23: ; 3680f ld a, [wPlayerMoveStruct + MOVE_ANIM] jp .asm_36975 .asm_36869 - call Function349f4 + call CountEnemyAliveMons jr c, .asm_368ca ; 3686c $5c ld a, [$c70f] and a diff --git a/constants/battle_constants.asm b/constants/battle_constants.asm index f5dbe0b42..7615fbbce 100644 --- a/constants/battle_constants.asm +++ b/constants/battle_constants.asm @@ -109,15 +109,18 @@ SUBSTATUS_LEECH_SEED EQU 7 SUBSTATUS_RAGE EQU 6 SUBSTATUS_RECHARGE EQU 5 SUBSTATUS_SUBSTITUTE EQU 4 +; EQU 3 SUBSTATUS_FOCUS_ENERGY EQU 2 SUBSTATUS_MIST EQU 1 -SUBSTATUS_UNLEASH EQU 0 +SUBSTATUS_X_ACCURACY EQU 0 SUBSTATUS_CANT_RUN EQU 7 SUBSTATUS_DESTINY_BOND EQU 6 SUBSTATUS_LOCK_ON EQU 5 SUBSTATUS_ENCORED EQU 4 SUBSTATUS_TRANSFORMED EQU 3 +; EQU 2 +; EQU 1 SUBSTATUS_TOXIC EQU 0 ; environmental diff --git a/constants/item_constants.asm b/constants/item_constants.asm index e790d1650..fea4632e3 100644 --- a/constants/item_constants.asm +++ b/constants/item_constants.asm @@ -250,7 +250,16 @@ HM_06 EQU $F8 HM_07 EQU $F9 HM_08 EQU $FA -NUM_TMS EQU HM_01 - TM_01 - 2 + +NUM_TMS EQU 50 +NUM_HMS EQU 7 + + +; leftovers from red +SAFARI_BALL EQU 8 ; MOON_STONE +MOON_STONE_RED EQU 10 ; BURN_HEAL +FULL_HEAL_RED EQU 52 ; X_SPEED + ; pockets ITEM EQU 1 @@ -311,6 +320,8 @@ HELD_DRAGON_BOOST EQU $40 HELD_DARK_BOOST EQU $41 HELD_STEEL_BOOST EQU $42 +HELD_CATCH_CHANCE EQU $46 + HELD_ESCAPE EQU $48 HELD_CRITICAL_UP EQU $49 HELD_QUICK_CLAW EQU $4a diff --git a/constants/misc_constants.asm b/constants/misc_constants.asm index 5b291f6e8..9d793f3b0 100644 --- a/constants/misc_constants.asm +++ b/constants/misc_constants.asm @@ -1,9 +1,15 @@ PARTY_LENGTH EQU 6 +MAX_ITEMS EQU 20 +MAX_BALLS EQU 12 +MAX_KEY_ITEMS EQU 25 +MAX_PC_ITEMS EQU 50 + ; strings PLAYER_NAME_LENGTH EQU 8 PKMN_NAME_LENGTH EQU 11 MOVE_NAME_LENGTH EQU 13 +ITEM_NAME_LENGTH EQU 13 NAME_LENGTH EQU 11 LV_CHAR EQU $6e @@ -73,3 +79,18 @@ STEP_TURN EQU 5 STEP_BACK_LEDGE EQU 6 STEP_WALK_IN_PLACE EQU 7 + +; ai +CONTEXT_USE_F EQU 6 +UNKNOWN_USE_F EQU 5 +ALWAYS_USE_F EQU 4 +SWITCH_SOMETIMES_F EQU 2 +SWITCH_RARELY_F EQU 1 +SWITCH_OFTEN_F EQU 0 + +CONTEXT_USE EQU 1 << CONTEXT_USE_F +UNKNOWN_USE EQU 1 << UNKNOWN_USE_F +ALWAYS_USE EQU 1 << ALWAYS_USE_F +SWITCH_SOMETIMES EQU 1 << SWITCH_SOMETIMES_F +SWITCH_RARELY EQU 1 << SWITCH_RARELY_F +SWITCH_OFTEN EQU 1 << SWITCH_OFTEN_F diff --git a/constants/pokemon_data_constants.asm b/constants/pokemon_data_constants.asm index 6d82ca926..86d33f235 100644 --- a/constants/pokemon_data_constants.asm +++ b/constants/pokemon_data_constants.asm @@ -72,7 +72,9 @@ EVOLVE_HAPPINESS EQU 4 EVOLVE_STAT EQU 5 -BASE_HAPPINESS EQU 70 +BASE_HAPPINESS EQU 70 +FRIEND_BALL_HAPPINESS EQU 200 + ; happiness evolution triggers HAPPINESS_TO_EVOLVE EQU 220 TR_ANYTIME EQU 1 diff --git a/engine/phone_scripts.asm b/engine/phone_scripts.asm index 9f57f11bd..419c232b5 100644 --- a/engine/phone_scripts.asm +++ b/engine/phone_scripts.asm @@ -307,7 +307,7 @@ UnknownScript_0xbd0ef: 3jump UnknownScript_0xa08f8 UnknownScript_0xbd0f3: - displaylocation $13, $2 + displaylocation NATIONAL_PARK, $2 3jump UnknownScript_0xa0a2d UnknownScript_0xbd0fa: @@ -331,7 +331,7 @@ UnknownScript_0xbd12a: setflag ENGINE_87 UnknownScript_0xbd12d: - displaylocation $13, $2 + displaylocation NATIONAL_PARK, $2 setflag ENGINE_JACK 3jump UnknownScript_0xa0376 @@ -349,7 +349,7 @@ UnknownScript_0xbd13f: 3jump UnknownScript_0xa0900 UnknownScript_0xbd151: - displaylocation $13, $2 + displaylocation NATIONAL_PARK, $2 3jump UnknownScript_0xa0aa5 UnknownScript_0xbd158: @@ -365,7 +365,7 @@ UnknownScript_0xbd16e: UnknownScript_0xbd172: setflag ENGINE_BEVERLY_HAS_NUGGET - displaylocation $13, $2 + displaylocation NATIONAL_PARK, $2 3jump UnknownScript_0xa061e UnknownScript_0xbd17c: @@ -385,7 +385,7 @@ UnknownScript_0xbd19b: 3jump UnknownScript_0xa0908 UnknownScript_0xbd1a2: - displaylocation $1c, $2 + displaylocation LIGHTHOUSE, $2 3jump UnknownScript_0xa0a32 UnknownScript_0xbd1a9: @@ -406,7 +406,7 @@ UnknownScript_0xbd1cd: setflag ENGINE_88 UnknownScript_0xbd1d0: - displaylocation $1c, $2 + displaylocation LIGHTHOUSE, $2 setflag ENGINE_HUEY 3jump UnknownScript_0xa0376 @@ -426,7 +426,7 @@ UnknownScript_0xbd1f9: 3jump UnknownScript_0xa0910 UnknownScript_0xbd1fd: - displaylocation $5b, $2 + displaylocation ROUTE_26, $2 3jump UnknownScript_0xa0a37 UnknownScript_0xbd204: @@ -448,7 +448,7 @@ UnknownScript_0xbd22c: setflag ENGINE_89 UnknownScript_0xbd22f: - displaylocation $5b, $2 + displaylocation ROUTE_26, $2 setflag ENGINE_GAVEN 3jump UnknownScript_0xa0376 @@ -471,7 +471,7 @@ UnknownScript_0xbd25c: 3jump UnknownScript_0xa0918 UnknownScript_0xbd260: - displaylocation $5b, $2 + displaylocation ROUTE_26, $2 3jump UnknownScript_0xa0a3c UnknownScript_0xbd267: @@ -491,7 +491,7 @@ UnknownScript_0xbd287: setflag ENGINE_8A UnknownScript_0xbd28a: - displaylocation $5b, $2 + displaylocation ROUTE_26, $2 setflag ENGINE_BETH 3jump UnknownScript_0xa037e @@ -513,11 +513,11 @@ UnknownScript_0xbd2b9: 3jump UnknownScript_0xa0920 UnknownScript_0xbd2bd: - displaylocation $5c, $2 + displaylocation ROUTE_27, $2 3jump UnknownScript_0xa0a41 UnknownScript_0xbd2c4: - displaylocation $5c, $2 + displaylocation ROUTE_27, $2 3jump UnknownScript_0xa0a41 UnknownScript_0xbd2cb: @@ -543,7 +543,7 @@ UnknownScript_0xbd301: setflag ENGINE_8B UnknownScript_0xbd304: - displaylocation $5c, $2 + displaylocation ROUTE_27, $2 setflag ENGINE_JOSE 3jump UnknownScript_0xa0376 @@ -552,7 +552,7 @@ UnknownScript_0xbd30e: UnknownScript_0xbd312: setflag ENGINE_JOSE_HAS_STAR_PIECE - displaylocation $5c, $2 + displaylocation ROUTE_27, $2 3jump UnknownScript_0xa05e6 UnknownScript_0xbd31c: @@ -571,7 +571,7 @@ UnknownScript_0xbd33b: 3jump UnknownScript_0xa0928 UnknownScript_0xbd33f: - displaylocation $5c, $2 + displaylocation ROUTE_27, $2 3jump UnknownScript_0xa0a46 UnknownScript_0xbd346: @@ -591,7 +591,7 @@ UnknownScript_0xbd366: setflag ENGINE_8C UnknownScript_0xbd369: - displaylocation $5c, $2 + displaylocation ROUTE_27, $2 setflag ENGINE_REENA 3jump UnknownScript_0xa037e @@ -612,7 +612,7 @@ UnknownScript_0xbd392: 3jump UnknownScript_0xa0930 UnknownScript_0xbd399: - displaylocation $4, $2 + displaylocation ROUTE_30, $2 3jump UnknownScript_0xa0a4b UnknownScript_0xbd3a0: @@ -633,7 +633,7 @@ UnknownScript_0xbd3c4: setflag ENGINE_8D UnknownScript_0xbd3c7: - displaylocation $4, $2 + displaylocation ROUTE_30, $2 setflag ENGINE_JOEY 3jump UnknownScript_0xa0376 @@ -668,11 +668,11 @@ UnknownScript_0xbd416: 3jump UnknownScript_0xa05a4 UnknownScript_0xbd41a: - displaylocation $5, $2 + displaylocation ROUTE_31, $2 3jump UnknownScript_0xa0a50 UnknownScript_0xbd421: - displaylocation $5, $2 + displaylocation ROUTE_31, $2 3jump UnknownScript_0xa0ab5 UnknownScript_0xbd428: @@ -713,7 +713,7 @@ UnknownScript_0xbd484: setflag ENGINE_8E UnknownScript_0xbd487: - displaylocation $5, $2 + displaylocation ROUTE_31, $2 setflag ENGINE_WADE 3jump UnknownScript_0xa0376 @@ -722,7 +722,7 @@ UnknownScript_0xbd491: UnknownScript_0xbd495: setflag ENGINE_WADE_HAS_ITEM - displaylocation $5, $2 + displaylocation ROUTE_31, $2 clearevent EVENT_WADE_HAS_BERRY clearevent EVENT_WADE_HAS_PSNCUREBERRY clearevent EVENT_WADE_HAS_PRZCUREBERRY @@ -769,11 +769,11 @@ UnknownScript_0xbd4f1: 3jump UnknownScript_0xa0940 UnknownScript_0xbd4fb: - displaylocation $8, $2 + displaylocation ROUTE_32, $2 3jump UnknownScript_0xa0a55 UnknownScript_0xbd502: - displaylocation $8, $2 + displaylocation ROUTE_32, $2 3jump UnknownScript_0xa0af5 UnknownScript_0xbd509: @@ -797,7 +797,7 @@ UnknownScript_0xbd537: setflag ENGINE_8F UnknownScript_0xbd53a: - displaylocation $8, $2 + displaylocation ROUTE_32, $2 setflag ENGINE_RALPH 3jump UnknownScript_0xa0376 @@ -806,7 +806,7 @@ UnknownScript_0xbd544: iftrue UnknownScript_0xbd55c setflag ENGINE_SPECIAL_WILDDATA pokenamemem QWILFISH, $1 - displaylocation $8, $2 + displaylocation ROUTE_32, $2 writebyte $1 special $0048 3jump UnknownScript_0xa05d6 @@ -831,7 +831,7 @@ UnknownScript_0xbd57f: 3jump UnknownScript_0xa0948 UnknownScript_0xbd586: - displaylocation $8, $2 + displaylocation ROUTE_32, $2 3jump UnknownScript_0xa0a5a UnknownScript_0xbd58d: @@ -859,7 +859,7 @@ UnknownScript_0xbd5c3: setflag ENGINE_90 UnknownScript_0xbd5c6: - displaylocation $8, $2 + displaylocation ROUTE_32, $2 setflag ENGINE_LIZ 3jump UnknownScript_0xa037e @@ -935,11 +935,11 @@ UnknownScript_0xbd653: 3jump UnknownScript_0xa0950 UnknownScript_0xbd65d: - displaylocation $b, $2 + displaylocation ROUTE_33, $2 3jump UnknownScript_0xa0a5f UnknownScript_0xbd664: - displaylocation $b, $2 + displaylocation ROUTE_33, $2 3jump UnknownScript_0xa0afa UnknownScript_0xbd66b: @@ -963,7 +963,7 @@ UnknownScript_0xbd699: setflag ENGINE_91 UnknownScript_0xbd69c: - displaylocation $b, $2 + displaylocation ROUTE_33, $2 setflag ENGINE_ANTHONY 3jump UnknownScript_0xa0376 @@ -973,7 +973,7 @@ UnknownScript_0xbd6a6: setflag ENGINE_DUNSPARCE_SWARM pokenamemem DUNSPARCE, $1 loadwilddata $0, GROUP_DARK_CAVE_VIOLET_ENTRANCE, MAP_DARK_CAVE_VIOLET_ENTRANCE - displaylocation $2c, $2 + displaylocation DARK_CAVE, $2 3jump UnknownScript_0xa05de UnknownScript_0xbd6bd: @@ -997,7 +997,7 @@ UnknownScript_0xbd6e0: 3jump UnknownScript_0xa0958 UnknownScript_0xbd6ea: - displaylocation $f, $2 + displaylocation ROUTE_34, $2 3jump UnknownScript_0xa0a64 UnknownScript_0xbd6f1: @@ -1028,7 +1028,7 @@ UnknownScript_0xbd72b: setflag ENGINE_92 UnknownScript_0xbd72e: - displaylocation $f, $2 + displaylocation ROUTE_34, $2 setflag ENGINE_TODD 3jump UnknownScript_0xa0376 @@ -1062,11 +1062,11 @@ UnknownScript_0xbd772: 3jump UnknownScript_0xa05c6 UnknownScript_0xbd776: - displaylocation $f, $2 + displaylocation ROUTE_34, $2 3jump UnknownScript_0xa0a69 UnknownScript_0xbd77d: - displaylocation $f, $2 + displaylocation ROUTE_34, $2 3jump UnknownScript_0xa0abd UnknownScript_0xbd784: @@ -1100,7 +1100,7 @@ UnknownScript_0xbd7cc: setflag ENGINE_93 UnknownScript_0xbd7cf: - displaylocation $f, $2 + displaylocation ROUTE_34, $2 setflag ENGINE_GINA 3jump UnknownScript_0xa037e @@ -1109,7 +1109,7 @@ UnknownScript_0xbd7d9: UnknownScript_0xbd7dd: setflag ENGINE_GINA_HAS_LEAF_STONE - displaylocation $f, $2 + displaylocation ROUTE_34, $2 3jump UnknownScript_0xa061e UnknownScript_0xbd7e7: @@ -1150,11 +1150,11 @@ UnknownScript_0xbd832: 3jump UnknownScript_0xa0968 UnknownScript_0xbd83c: - displaylocation $12, $2 + displaylocation ROUTE_35, $2 3jump UnknownScript_0xa0a6e UnknownScript_0xbd843: - displaylocation $12, $2 + displaylocation ROUTE_35, $2 3jump UnknownScript_0xa0aff UnknownScript_0xbd84a: @@ -1178,7 +1178,7 @@ UnknownScript_0xbd87a: setflag ENGINE_94 UnknownScript_0xbd87d: - displaylocation $12, $2 + displaylocation ROUTE_35, $2 setflag ENGINE_ARNIE 3jump UnknownScript_0xa0376 @@ -1188,7 +1188,7 @@ UnknownScript_0xbd887: setflag ENGINE_YANMA_SWARM pokenamemem YANMA, $1 loadwilddata $1, GROUP_ROUTE_35, MAP_ROUTE_35 - displaylocation $12, $2 + displaylocation ROUTE_35, $2 3jump UnknownScript_0xa05ce UnknownScript_0xbd89e: @@ -1215,11 +1215,11 @@ UnknownScript_0xbd8cb: 3jump UnknownScript_0xa0970 UnknownScript_0xbd8cf: - displaylocation $14, $2 + displaylocation ROUTE_36, $2 3jump UnknownScript_0xa0a73 UnknownScript_0xbd8d6: - displaylocation $14, $2 + displaylocation ROUTE_36, $2 3jump UnknownScript_0xa0ac5 UnknownScript_0xbd8dd: @@ -1249,13 +1249,13 @@ UnknownScript_0xbd919: setflag ENGINE_95 UnknownScript_0xbd91c: - displaylocation $14, $2 + displaylocation ROUTE_36, $2 setflag ENGINE_ALAN 3jump UnknownScript_0xa0376 UnknownScript_0xbd926: setflag ENGINE_ALAN_HAS_FIRE_STONE - displaylocation $14, $2 + displaylocation ROUTE_36, $2 3jump UnknownScript_0xa05e6 UnknownScript_0xbd930: @@ -1276,11 +1276,11 @@ UnknownScript_0xbd955: 3jump UnknownScript_0xa0978 UnknownScript_0xbd959: - displaylocation $19, $2 + displaylocation ROUTE_38, $2 3jump UnknownScript_0xa0a78 UnknownScript_0xbd960: - displaylocation $19, $2 + displaylocation ROUTE_38, $2 3jump UnknownScript_0xa0acd UnknownScript_0xbd967: @@ -1312,7 +1312,7 @@ UnknownScript_0xbd9ab: setflag ENGINE_96 UnknownScript_0xbd9ae: - displaylocation $19, $2 + displaylocation ROUTE_38, $2 setflag ENGINE_DANA 3jump UnknownScript_0xa037e @@ -1321,7 +1321,7 @@ UnknownScript_0xbd9b8: UnknownScript_0xbd9bc: setflag ENGINE_LIZ_HAS_THUNDERSTONE - displaylocation $19, $2 + displaylocation ROUTE_38, $2 3jump UnknownScript_0xa061e UnknownScript_0xbd9c6: @@ -1340,7 +1340,7 @@ UnknownScript_0xbd9e5: 3jump UnknownScript_0xa0980 UnknownScript_0xbd9e9: - displaylocation $19, $2 + displaylocation ROUTE_38, $2 3jump UnknownScript_0xa0a7d UnknownScript_0xbd9f0: @@ -1364,7 +1364,7 @@ UnknownScript_0xbda20: setflag ENGINE_97 UnknownScript_0xbda23: - displaylocation $19, $2 + displaylocation ROUTE_38, $2 setflag ENGINE_CHAD 3jump UnknownScript_0xa0376 @@ -1395,7 +1395,7 @@ UnknownScript_0xbda63: 3jump UnknownScript_0xa05a4 UnknownScript_0xbda67: - displaylocation $1a, $2 + displaylocation ROUTE_39, $2 3jump UnknownScript_0xa0ad5 UnknownScript_0xbda6e: @@ -1420,7 +1420,7 @@ UnknownScript_0xbda9e: UnknownScript_0xbdaa2: setflag ENGINE_DEREK_HAS_NUGGET - displaylocation $1a, $2 + displaylocation ROUTE_39, $2 3jump UnknownScript_0xa05e6 UnknownScript_0xbdaac: @@ -1441,11 +1441,11 @@ UnknownScript_0xbdad1: 3jump UnknownScript_0xa0990 UnknownScript_0xbdad5: - displaylocation $22, $2 + displaylocation ROUTE_42, $2 3jump UnknownScript_0xa0a82 UnknownScript_0xbdadc: - displaylocation $22, $2 + displaylocation ROUTE_42, $2 3jump UnknownScript_0xa0add UnknownScript_0xbdae3: @@ -1475,13 +1475,13 @@ UnknownScript_0xbdb1f: setflag ENGINE_98 UnknownScript_0xbdb22: - displaylocation $22, $2 + displaylocation ROUTE_42, $2 setflag ENGINE_TULLY 3jump UnknownScript_0xa0376 UnknownScript_0xbdb2c: setflag ENGINE_TULLY_HAS_WATER_STONE - displaylocation $22, $2 + displaylocation ROUTE_42, $2 3jump UnknownScript_0xa05e6 UnknownScript_0xbdb36: @@ -1500,7 +1500,7 @@ UnknownScript_0xbdb55: 3jump UnknownScript_0xa0998 UnknownScript_0xbdb59: - displaylocation $25, $2 + displaylocation ROUTE_43, $2 3jump UnknownScript_0xa0a87 UnknownScript_0xbdb60: @@ -1522,7 +1522,7 @@ UnknownScript_0xbdb88: setflag ENGINE_99 UnknownScript_0xbdb8b: - displaylocation $25, $2 + displaylocation ROUTE_43, $2 setflag ENGINE_BRENT 3jump UnknownScript_0xa0376 @@ -1547,11 +1547,11 @@ UnknownScript_0xbdbbe: 3jump UnknownScript_0xa09a0 UnknownScript_0xbdbc2: - displaylocation $25, $2 + displaylocation ROUTE_43, $2 3jump UnknownScript_0xa0a8c UnknownScript_0xbdbc9: - displaylocation $25, $2 + displaylocation ROUTE_43, $2 3jump UnknownScript_0xa0ae5 UnknownScript_0xbdbd0: @@ -1583,7 +1583,7 @@ UnknownScript_0xbdc14: setflag ENGINE_9A UnknownScript_0xbdc17: - displaylocation $25, $2 + displaylocation ROUTE_43, $2 setflag ENGINE_TIFFANY 3jump UnknownScript_0xa037e @@ -1625,7 +1625,7 @@ UnknownScript_0xbdc65: UnknownScript_0xbdc69: setflag ENGINE_TIFFANY_HAS_PINK_BOW - displaylocation $25, $2 + displaylocation ROUTE_43, $2 3jump UnknownScript_0xa061e UnknownScript_0xbdc73: @@ -1644,7 +1644,7 @@ UnknownScript_0xbdc92: 3jump UnknownScript_0xa09a8 UnknownScript_0xbdc96: - displaylocation $27, $2 + displaylocation ROUTE_44, $2 3jump UnknownScript_0xa0a91 UnknownScript_0xbdc9d: @@ -1665,7 +1665,7 @@ UnknownScript_0xbdcc1: setflag ENGINE_9B UnknownScript_0xbdcc4: - displaylocation $27, $2 + displaylocation ROUTE_44, $2 setflag ENGINE_VANCE 3jump UnknownScript_0xa0376 @@ -1687,11 +1687,11 @@ UnknownScript_0xbdcf3: 3jump UnknownScript_0xa09b0 UnknownScript_0xbdcf7: - displaylocation $27, $2 + displaylocation ROUTE_44, $2 3jump UnknownScript_0xa0a96 UnknownScript_0xbdcfe: - displaylocation $27, $2 + displaylocation ROUTE_44, $2 3jump UnknownScript_0xa0aed UnknownScript_0xbdd05: @@ -1715,13 +1715,13 @@ UnknownScript_0xbdd33: setflag ENGINE_9C UnknownScript_0xbdd36: - displaylocation $27, $2 + displaylocation ROUTE_44, $2 setflag ENGINE_WILTON 3jump UnknownScript_0xa0376 UnknownScript_0xbdd40: setflag ENGINE_WILTON_HAS_ITEM - displaylocation $27, $2 + displaylocation ROUTE_44, $2 clearevent EVENT_WILTON_HAS_ULTRA_BALL clearevent EVENT_WILTON_HAS_GREAT_BALL clearevent EVENT_WILTON_HAS_POKE_BALL @@ -1771,7 +1771,7 @@ UnknownScript_0xbdda8: 3jump UnknownScript_0xa09b8 UnknownScript_0xbddac: - displaylocation $2b, $2 + displaylocation ROUTE_45, $2 3jump UnknownScript_0xa0a9b UnknownScript_0xbddb3: @@ -1792,7 +1792,7 @@ UnknownScript_0xbddd7: setflag ENGINE_9D UnknownScript_0xbddda: - displaylocation $2b, $2 + displaylocation ROUTE_45, $2 setflag ENGINE_PARRY 3jump UnknownScript_0xa0376 @@ -1812,7 +1812,7 @@ UnknownScript_0xbde03: 3jump UnknownScript_0xa09c0 UnknownScript_0xbde07: - displaylocation $2d, $2 + displaylocation ROUTE_46, $2 3jump UnknownScript_0xa0aa0 UnknownScript_0xbde0e: @@ -1833,7 +1833,7 @@ UnknownScript_0xbde32: setflag ENGINE_9E UnknownScript_0xbde35: - displaylocation $2d, $2 + displaylocation ROUTE_46, $2 setflag ENGINE_ERIN 3jump UnknownScript_0xa037e diff --git a/engine/scripting.asm b/engine/scripting.asm index 7bfe21b54..f08508901 100644 --- a/engine/scripting.asm +++ b/engine/scripting.asm @@ -2123,11 +2123,10 @@ Script_pokenamemem: ; 0x976ae Unknown_976c0: ; 0x976c0 call GetScriptByte - cp $3 - jr c, .asm_976c8 + cp 3 + jr c, .ok xor a -.asm_976c8 -; 976c8 +.ok Function976c8: ; 976c8 ld hl, StringBuffer3 diff --git a/engine/std_scripts.asm b/engine/std_scripts.asm index a35c30e4d..66f3f2226 100644 --- a/engine/std_scripts.asm +++ b/engine/std_scripts.asm @@ -127,7 +127,7 @@ PokeCenterNurseScript: ; bc09c spriteface $fe, $2 pause 10 special $001b - playmusic $0000 + playmusic MUSIC_NONE writebyte $0 special $003e pause 30 @@ -261,9 +261,9 @@ UnknownScript_0xbc1a9: ; 0xbc1a9 ; 0xbc1af UnknownScript_0xbc1af: ; 0xbc1af - playsound $0008 + playsound SFX_READ_TEXT_2 pause 15 - playsound $0027 + playsound SFX_ELEVATOR_END end ; 0xbc1b8 @@ -272,7 +272,7 @@ UnknownScript_0xbc1b8: ; 0xbc1b8 ; 0xbc1bc UnknownScript_0xbc1bc: ; 0xbc1bc - 3jump UnknownScript_0xcf5d + 3jump AskRockSmashScript ; 0xbc1c0 UnknownScript_0xbc1c0: ; 0xbc1c0 @@ -941,7 +941,7 @@ UnknownScript_0xbc6e1: ; 0xbc6e1 UnknownScript_0xbc6e6: ; 0xbc6e6 3writetext UnknownText_0x1b09c4 - playsound $0093 + playsound SFX_REGISTER_PHONE_NUMBER waitbutton keeptextopen end diff --git a/gfx/pics/animation.asm b/gfx/pics/animation.asm index 7f2c3ca88..99ba4e9a8 100644 --- a/gfx/pics/animation.asm +++ b/gfx/pics/animation.asm @@ -899,7 +899,7 @@ Functiond0551: ; d0551 ld a, [hli] ld h, [hl] ld l, a - ld de, $939 + ld de, AttrMap - TileMap add hl, de ret ; d055c @@ -649,14 +649,14 @@ Function327b:: ; 327b ld sp, hl ld a, [$ffd7] ld h, a - ld l, $0 - ld a, $12 + ld l, 0 + ld a, 18 ld [$ffd3], a - ld b, $2 - ld c, $41 + ld b, 1 << 1 ; not in v/hblank + ld c, rSTAT % $100 .loop -rept 10 +rept 20 / 2 pop de .loop\@ ld a, [$ff00+c] @@ -668,7 +668,7 @@ rept 10 inc l endr - ld de, $000c + ld de, 32 - 20 add hl, de ld a, [$ffd3] dec a @@ -848,13 +848,13 @@ GetName:: ; 33c3 push de ld a, [$cf61] - cp 1 ; Pokemon names + cp PKMN_NAME jr nz, .NotPokeName ld a, [CurSpecies] ld [$d265], a call GetPokemonName - ld hl, 11 + ld hl, PKMN_NAME_LENGTH add hl, de ld e, l ld d, h @@ -995,7 +995,7 @@ GetItemName:: ; 3468 jr nc, .TM ld [CurSpecies], a - ld a, 4 ; Item names + ld a, ITEM_NAME ld [$cf61], a call GetName jr .Copied @@ -1047,9 +1047,9 @@ GetTMHMName:: ; 3487 ld a, c jr c, .asm_34b9 sub NUM_TMS +.asm_34b9 ; Divide and mod by 10 to get the top and bottom digits respectively -.asm_34b9 ld b, "0" .mod10 sub 10 @@ -1123,15 +1123,16 @@ IsHMMove:: ; 34e7 GetMoveName:: ; 34f8 push hl -; move name - ld a, $2 ; move names + + ld a, MOVE_NAME ld [$cf61], a -; move id - ld a, [$d265] + + ld a, [$d265] ; move id ld [CurSpecies], a call GetName ld de, StringBuffer1 + pop hl ret ; 350c @@ -1141,12 +1142,14 @@ Function350c:: ; 350c call Function1c66 ld a, [hROMBank] push af - ld a, $9 + + ld a, BANK(Function245af) rst Bankswitch call Function245af call Function3524 call Function245cb + pop af rst Bankswitch @@ -1182,6 +1185,7 @@ Function352f:: ; 352f Function354b:: ; 354b call DelayFrame + ld a, [$ffaa] push af ld a, $1 @@ -1189,11 +1193,12 @@ Function354b:: ; 354b call Functiona57 pop af ld [$ffaa], a + ld a, [$ffa9] - and $f0 + and D_RIGHT + D_LEFT + D_UP + D_DOWN ld c, a ld a, [hJoyPressed] - and $f + and A_BUTTON + B_BUTTON + SELECT + START or c ld c, a ret @@ -1203,12 +1208,13 @@ Function354b:: ; 354b Function3567:: ; 3567 ld a, [hROMBank] push af + call Function2c52 call Function3574 + pop bc ld a, b rst Bankswitch - ret ; 3574 @@ -1218,6 +1224,7 @@ Function3574:: ; 3574 ld a, [hl] cp $ff jr z, .asm_3597 + ld l, a push hl call Function3599 @@ -1239,18 +1246,21 @@ Function3574:: ; 3574 Function3599:: ; 3599 push de + ld hl, $0010 add hl, de ld a, [hl] ld hl, $0011 add hl, de ld e, [hl] - sub $4 + + sub 4 ld d, a ld a, e - sub $4 + sub 4 ld e, a call Function35b0 + pop de ret ; 35b0 @@ -1263,7 +1273,8 @@ Function35b0:: ; 35b0 ld a, [$dbfb] and a jr z, .asm_35d3 -.asm_35bc + +.loop push af ld a, [hl] cp e @@ -1280,11 +1291,11 @@ Function35b0:: ; 35b0 ld l, a jr nc, .asm_35cf inc h - .asm_35cf + pop af dec a - jr nz, .asm_35bc + jr nz, .loop .asm_35d3 and a @@ -1343,8 +1354,8 @@ CheckTrainerBattle2:: ; 3600 ld a, [hROMBank] push af - call Function2c52 + call Function2c52 call CheckTrainerBattle pop bc @@ -1442,7 +1453,7 @@ CheckTrainerBattle:: ; 360d ld a, b ld [$d03f], a ld a, c - ld [MartPointer], a + ld [$d040], a jr Function367e ; 3674 @@ -1450,7 +1461,7 @@ Function3674:: ; 3674 ld a, $1 ld [$d03f], a ld a, $ff - ld [MartPointer], a + ld [$d040], a Function367e:: ; 367e call GetMapScriptHeaderBank @@ -1585,12 +1596,12 @@ Function3718:: ; 3718 cp BATTLETYPE_CANLOSE jr .asm_3724 - ld hl, WalkingTile + ld hl, $d047 jr .asm_3731 .asm_3724 ld a, [$d0ee] - ld hl, WalkingTile + ld hl, $d047 and $f jr z, .asm_3731 ld hl, $d049 @@ -1750,7 +1761,7 @@ Function383d:: ; 383d Function3842:: ; 3842 ld [$d265], a ld de, $d265 - ld b, %01000001 ; flags + ld b, 1 << 6 + 1 jp PrintNum ; 384d @@ -1758,7 +1769,7 @@ Function3842:: ; 3842 Function384d:: ; 384d ld hl, $d25e ld c, a - ld b, $0 + ld b, 0 add hl, bc ld a, [hl] ret @@ -2083,156 +2094,13 @@ Function3b3c:: ; 3b3c INCLUDE "home/audio.asm" +INCLUDE "home/mobile.asm" -Function3e32:: ; 3e32 -; Mobile - cp $2 - ld [$c988], a - ld a, l - ld [$c986], a - ld a, h - ld [$c987], a - jr nz, .asm_3e4f - - ld [$c982], a - ld a, l - ld [$c981], a - ld hl, $c983 - ld a, c - ld [hli], a - ld a, b - ld [hl], a - -.asm_3e4f - ld hl, $c822 - set 6, [hl] - ld a, [hROMBank] - push af - ld a, BANK(Function110030) - ld [$c981], a - rst Bankswitch - - jp Function110030 -; 3e60 - -Function3e60:: ; 3e60 - ld [$c986], a - ld a, l - ld [$c987], a - ld a, h - ld [$c988], a - - pop bc - ld a, b - ld [$c981], a - rst Bankswitch - - ld hl, $c822 - res 6, [hl] - ld hl, $c987 - ld a, [hli] - ld h, [hl] - ld l, a - ld a, [$c986] - ret -; 3e80 - -Function3e80:: ; 3e80 - ld a, [hROMBank] - push af - ld a, BANK(Function1116c5) - ld [$c981], a - rst Bankswitch - - call Function1116c5 - pop bc - ld a, b - ld [$c981], a - rst Bankswitch - - ret -; 3e93 - - -Timer:: ; 3e93 - push af - push bc - push de - push hl - - ld a, [$ffe9] - and a - jr z, .asm_3ed2 - - xor a - ld [rTAC], a - -; Turn off timer interrupt - ld a, [rIF] - and 1 << VBLANK | 1 << LCD_STAT | 1 << SERIAL | 1 << JOYPAD - ld [rIF], a - - ld a, [$c86a] - or a - jr z, .asm_3ed2 - - ld a, [$c822] - bit 1, a - jr nz, .asm_3eca - - ld a, [rSC] - and 1 << rSC_ON - jr nz, .asm_3eca - - ld a, [hROMBank] - push af - ld a, BANK(Function1118de) - ld [$c981], a - rst Bankswitch - - call Function1118de - - pop bc - ld a, b - ld [$c981], a - rst Bankswitch - -.asm_3eca - ld a, [rTMA] - ld [rTIMA], a - - ld a, 1 << rTAC_ON | rTAC_65536_HZ - ld [rTAC], a - -.asm_3ed2 - pop hl - pop de - pop bc - pop af - reti -; 3ed7 - -Function3ed7:: ; 3ed7 - ld [$dc02], a - ld a, [hROMBank] - push af - ld a, BANK(Function114243) - rst Bankswitch - - call Function114243 - pop bc - ld a, b - rst Bankswitch - - ld a, [$dc02] - ret -; 3eea - Function3eea:: ; 3eea push hl push bc - ld de, $0939 + ld de, AttrMap - TileMap add hl, de inc b inc b @@ -2248,8 +2116,8 @@ Function3eea:: ; 3eea Function3efd:: ; 3efd push hl hlcoord 0, 12 - ld b, $4 - ld c, $12 + ld b, 4 + ld c, 18 call Function3f0d pop hl call PrintTextBoxText @@ -2259,7 +2127,7 @@ Function3efd:: ; 3efd Function3f0d:: ; 3f0d push hl push bc - ld de, $0939 + ld de, AttrMap - TileMap add hl, de inc b inc b diff --git a/home/mobile.asm b/home/mobile.asm new file mode 100644 index 000000000..c6c225dc8 --- /dev/null +++ b/home/mobile.asm @@ -0,0 +1,143 @@ +Function3e32:: ; 3e32 +; Mobile + cp $2 + ld [$c988], a + ld a, l + ld [$c986], a + ld a, h + ld [$c987], a + jr nz, .asm_3e4f + + ld [$c982], a + ld a, l + ld [$c981], a + ld hl, $c983 + ld a, c + ld [hli], a + ld a, b + ld [hl], a + +.asm_3e4f + ld hl, $c822 + set 6, [hl] + ld a, [hROMBank] + push af + ld a, BANK(Function110030) + ld [$c981], a + rst Bankswitch + + jp Function110030 +; 3e60 + +Function3e60:: ; 3e60 + ld [$c986], a + ld a, l + ld [$c987], a + ld a, h + ld [$c988], a + + pop bc + ld a, b + ld [$c981], a + rst Bankswitch + + ld hl, $c822 + res 6, [hl] + ld hl, $c987 + ld a, [hli] + ld h, [hl] + ld l, a + ld a, [$c986] + ret +; 3e80 + +Function3e80:: ; 3e80 + ld a, [hROMBank] + push af + ld a, BANK(Function1116c5) + ld [$c981], a + rst Bankswitch + + call Function1116c5 + pop bc + ld a, b + ld [$c981], a + rst Bankswitch + + ret +; 3e93 + + +Timer:: ; 3e93 + push af + push bc + push de + push hl + + ld a, [$ffe9] + and a + jr z, .asm_3ed2 + + xor a + ld [rTAC], a + +; Turn off timer interrupt + ld a, [rIF] + and 1 << VBLANK | 1 << LCD_STAT | 1 << SERIAL | 1 << JOYPAD + ld [rIF], a + + ld a, [$c86a] + or a + jr z, .asm_3ed2 + + ld a, [$c822] + bit 1, a + jr nz, .asm_3eca + + ld a, [rSC] + and 1 << rSC_ON + jr nz, .asm_3eca + + ld a, [hROMBank] + push af + ld a, BANK(Function1118de) + ld [$c981], a + rst Bankswitch + + call Function1118de + + pop bc + ld a, b + ld [$c981], a + rst Bankswitch + +.asm_3eca + ld a, [rTMA] + ld [rTIMA], a + + ld a, 1 << rTAC_ON | rTAC_65536_HZ + ld [rTAC], a + +.asm_3ed2 + pop hl + pop de + pop bc + pop af + reti +; 3ed7 + +Function3ed7:: ; 3ed7 + ld [$dc02], a + ld a, [hROMBank] + push af + ld a, BANK(Function114243) + rst Bankswitch + + call Function114243 + pop bc + ld a, b + rst Bankswitch + + ld a, [$dc02] + ret +; 3eea diff --git a/home/text.asm b/home/text.asm index e319a1bdf..ee4b7174d 100644 --- a/home/text.asm +++ b/home/text.asm @@ -1,20 +1,35 @@ +BORDER_WIDTH EQU 2 +TEXTBOX_WIDTH EQU SCREEN_WIDTH +TEXTBOX_INNERW EQU TEXTBOX_WIDTH - BORDER_WIDTH +TEXTBOX_HEIGHT EQU 6 +TEXTBOX_INNERH EQU TEXTBOX_HEIGHT - BORDER_WIDTH +TEXTBOX_X EQU 0 +TEXTBOX_INNERX EQU TEXTBOX_X + 1 +TEXTBOX_Y EQU SCREEN_HEIGHT - TEXTBOX_HEIGHT +TEXTBOX_INNERY EQU TEXTBOX_Y + 2 + +TEXTBOX_PAL EQU 7 + + ClearBox:: ; fb6 ; Fill a c*b box at hl with blank tiles. ld a, " " + Functionfb8:: +.col push bc push hl -.x +.row ld [hli], a dec c - jr nz, .x + jr nz, .row pop hl - ld bc, 20 ; screen width + ld bc, SCREEN_WIDTH add hl, bc pop bc dec b - jr nz, Functionfb8 + jr nz, .col ret ; fc8 @@ -24,10 +39,10 @@ ClearTileMap:: ; fc8 ld hl, TileMap ld a, " " - ld bc, 360 ; screen dimensions 20*18 + ld bc, TileMapEnd - TileMap call ByteFill -; We aren't done if the LCD is on. + ; Update the BG Map. ld a, [rLCDC] bit 7, a ret z @@ -35,10 +50,10 @@ ClearTileMap:: ; fc8 ; fdb -Functionfdb:: ; fdb - ld a, $7 +ClearScreen:: ; fdb + ld a, TEXTBOX_PAL ld hl, AttrMap - ld bc, $0168 + ld bc, SCREEN_WIDTH * SCREEN_HEIGHT call ByteFill jr ClearTileMap ; fe8 @@ -46,7 +61,7 @@ Functionfdb:: ; fdb TextBox:: ; fe8 -; Draw a text box width c height b at hl +; Draw a text box width c height b at hl. ; Dimensions do not include the border. push bc push hl @@ -59,48 +74,48 @@ TextBox:: ; fe8 TextBoxBorder:: ; ff1 -; Top + ; Top push hl ld a, "┌" ld [hli], a inc a ; "─" - call NPlaceChar + call .PlaceChars inc a ; "┐" ld [hl], a - -; Middle pop hl - ld de, 20 ; screen width + + ; Middle + ld de, SCREEN_WIDTH add hl, de -.PlaceRow +.row push hl ld a, "│" ld [hli], a ld a, " " - call NPlaceChar + call .PlaceChars ld [hl], "│" pop hl - ld de, 20 ; screen width + + ld de, SCREEN_WIDTH add hl, de dec b - jr nz, .PlaceRow + jr nz, .row -; Bottom + ; Bottom ld a, "└" ld [hli], a ld a, "─" - call NPlaceChar + call .PlaceChars ld [hl], "┘" ret ; 101e - -NPlaceChar:: ; 101e -; Place char a c times - ld d,c +.PlaceChars: ; 101e +; Place char a c times. + ld d, c .loop - ld [hli],a + ld [hli], a dec d jr nz, .loop ret @@ -115,41 +130,41 @@ TextBoxPalette:: ; 1024 inc b inc c inc c - ld a, 7 ; pal -.gotoy + ld a, TEXTBOX_PAL +.col push bc push hl -.gotox +.row ld [hli], a dec c - jr nz, .gotox + jr nz, .row pop hl - ld de, 20 ; screen width + ld de, SCREEN_WIDTH add hl, de pop bc dec b - jr nz, .gotoy + jr nz, .col ret ; 103e SpeechTextBox:: ; 103e ; Standard textbox. - hlcoord 0, 12 - ld b, 4 ; height - ld c, 18 ; screen width - 2 (border) + hlcoord TEXTBOX_X, TEXTBOX_Y + ld b, TEXTBOX_INNERH + ld c, TEXTBOX_INNERW jp TextBox ; 1048 -UnknownText_0x1048:: ; 1048 - db $0, "ゲームフりーク!", $57 +TestText:: ; 1048 + text "ゲームフりーク!" + done ; 1052 Function1052:: ; 1052 - ld hl, .text_1056 + ld hl, .stop ret -.text_1056 - db "@" +.stop db "@" ; 1057 @@ -157,18 +172,17 @@ PrintText:: ; 1057 call Function106c Function105a:: ; 105a push hl - hlcoord 1, 14 - ld bc, 18 + 3<<8 + hlcoord TEXTBOX_INNERX, TEXTBOX_INNERY + lb bc, TEXTBOX_INNERH - 1, TEXTBOX_INNERW call ClearBox pop hl PrintTextBoxText:: ; 1065 - bccoord 1, 14 + bccoord TEXTBOX_INNERX, TEXTBOX_INNERY call Function13e5 ret ; 106c - Function106c:: ; 106c push hl call SpeechTextBox @@ -179,7 +193,6 @@ Function106c:: ; 106c ; 1078 - PlaceString:: ; 1078 push hl @@ -198,265 +211,174 @@ NextChar:: ; 1083 jp PlaceNextChar CheckDict:: ; 1087 - cp $15 - jp z, Function117b - cp $4f - jp z, Char4F - cp $4e - jp z, Function12a7 - cp $16 - jp z, Function12b9 +dict: macro +if \1 == 0 and a - jp z, Function1383 - cp $4c - jp z, Function1337 - cp $4b - jp z, Char4B - cp $51 ; Player name - jp z, Function12f2 - cp $49 - jp z, Function1186 - cp $52 ; Mother name - jp z, Function118d - cp $53 - jp z, Function1194 - cp $35 - jp z, Function11e8 - cp $36 - jp z, Function11ef - cp $37 - jp z, Function11f6 - cp $38 - jp z, Function119b - cp $39 - jp z, Function11a2 - cp $54 - jp z, Function11c5 - cp $5b - jp z, Function11b7 - cp $5e - jp z, Function11be - cp $5c - jp z, Function11b0 - cp $5d - jp z, Function11a9 - cp $23 - jp z, Function11cc - cp $22 - jp z, Function12b0 - cp $55 - jp z, Char55 - cp $56 - jp z, Function11d3 - cp $57 - jp z, Function137c - cp $58 - jp z, Function135a - cp $4a - jp z, Function11da - cp $24 - jp z, Function11e1 - cp $25 - jp z, NextChar +else + cp \1 +endc + jp z, \2 +endm + dict $15, Char15 + dict $4f, Line + dict $4e, NextLine + dict $16, Char16 + dict $00, NullChar + dict $4c, Function1337 + dict $4b, Char4B + dict $51, Paragraph + dict $49, PrintMomsName + dict $52, PrintPlayerName + dict $53, PrintRivalName + dict $35, Char35 + dict $36, Char36 + dict $37, Char37 + dict $38, PrintRedsName + dict $39, PrintGreensName + dict $54, Char54 + dict $5b, Char5B + dict $5e, Char5E + dict $5c, Char5C + dict $5d, Char5D + dict $23, Char23 + dict $22, Char22 + dict $55, ContText + dict $56, Char56 + dict $57, DoneText + dict $58, PromptText + dict $4a, Char4A + dict $24, Char24 + dict $25, NextChar cp $1f - jr nz, .asm_1122 + jr nz, .ok ld a, $7f -.asm_1122 - cp $5f - jp z, Char5F - cp $59 - jp z, Function11fd - cp $5a - jp z, Char5D - cp $3f - jp z, Function121b - cp $14 - jp z, Function1252 - cp $e4 - jr z, .asm_1174 ; 0x113d $35 - cp $e5 - jr z, .asm_1174 ; 0x1141 $31 - jr .asm_114c ; 0x1143 $7 +.ok + dict $5f, Char5F + dict $59, Char59 + dict $5a, Char5A + dict $3f, Char3F + dict $14, Char14 + cp $e4 ; handakuten + jr z, .place + cp $e5 ; dakuten + jr z, .place + + jr .nope ld b, a - call Function13c6 + call Diacritic jp NextChar -.asm_114c +.nope + cp $60 - jr nc, .asm_1174 ; 0x114e $24 + jr nc, .place + cp $40 - jr nc, .asm_1165 ; 0x1152 $11 + jr nc, .handakuten + +.dakuten + cp $20 - jr nc, .asm_115c ; 0x1156 $4 + jr nc, .daku1 add $80 - jr .asm_115e ; 0x115a $2 -.asm_115c + jr .daku2 +.daku1 add $90 -.asm_115e - ld b, $e5 - call Function13c6 - jr .asm_1174 ; 0x1163 $f -.asm_1165 - cp $44 - jr nc, .asm_116d ; 0x1167 $4 - add $59 - jr .asm_116f ; 0x116b $2 -.asm_116d - add $86 -.asm_116f - ld b, $e4 - call Function13c6 -.asm_1174 +.daku2 + ld b, $e5 ; dakuten + call Diacritic + jr .place + +.handakuten + cp "ぱ" + jr nc, .han1 + add "ハ" - "パ" + jr .han2 +.han1 + add "は" - "ぱ" +.han2 + ld b, $e4 ; handakuten + call Diacritic + +.place ld [hli], a call PrintLetterDelay jp NextChar ; 0x117b -Function117b:: ; 117b +Char15:: ; 117b ld c, l ld b, h callba Function17f036 jp PlaceNextChar ; 1186 -Function1186:: ; 1186 - push de - ld de, MomsName - jp Function126a -; 118d - -Function118d:: ; 118d - push de - ld de, PlayerName - jp Function126a -; 1194 - -Function1194:: ; 1194 - push de - ld de, RivalName - jp Function126a -; 119b - -Function119b:: ; 119b - push de - ld de, RedsName - jp Function126a -; 11a2 - -Function11a2:: ; 11a2 - push de - ld de, GreensName - jp Function126a -; 11a9 - -Function11a9:: ; 11a9 - push de - ld de, Char5DText - jp Function126a -; 11b0 - -Function11b0:: ; 11b0 - push de - ld de, Char5CText - jp Function126a -; 11b7 - -Function11b7:: ; 11b7 - push de - ld de, Char5BText - jp Function126a -; 11be - -Function11be:: ; 11be - push de - ld de, Char5EText - jp Function126a -; 11c5 - -Function11c5:: ; 11c5 - push de - ld de, Char54Text - jp Function126a -; 11cc - -Function11cc:: ; 11cc - push de - ld de, Char23Text - jp Function126a -; 11d3 - -Function11d3:: ; 11d3 - push de - ld de, Char56Text - jp Function126a -; 11da -Function11da:: ; 11da +print_name: macro push de - ld de, Char4AText + ld de, \1 jp Function126a -; 11e1 - -Function11e1:: ; 11e1 - push de - ld de, Char24Text - jp Function126a -; 11e8 - -Function11e8:: ; 11e8 - push de - ld de, Char37Text - jp Function126a -; 11ef - -Function11ef:: ; 11ef - push de - ld de, Char37Text - jp Function126a -; 11f6 - -Function11f6:: ; 11f6 - push de - ld de, Char37Text - jp Function126a -; 11fd - - -Function11fd:: ; 11fd +endm + +PrintMomsName: print_name MomsName ; 1186 +PrintPlayerName: print_name PlayerName ; 118d +PrintRivalName: print_name RivalName ; 1194 +PrintRedsName: print_name RedsName ; 119b +PrintGreensName: print_name GreensName ; 11a2 + +Char5D: print_name Char5DText ; 11a9 +Char5C: print_name Char5CText ; 11b0 +Char5B: print_name Char5BText ; 11b7 +Char5E: print_name Char5EText ; 11be +Char54: print_name Char54Text ; 11c5 +Char23: print_name Char23Text ; 11cc +Char56: print_name Char56Text ; 11d3 +Char4A: print_name Char4AText ; 11da +Char24: print_name Char24Text ; 11e1 +Char35: print_name Char35Text ; 11e8 +Char36: print_name Char36Text ; 11ef +Char37: print_name Char37Text ; 11f6 + + +Char59:: ; 11fd ld a, [hBattleTurn] - xor $1 - jr Function1205 -; 1203 + xor 1 + jr Char59_5A -Char5D:: ; 1203 +Char5A:: ; 1203 ld a, [hBattleTurn] -; 1205 -Function1205:: ; 1205 +Char59_5A: ; 1205 push de and a - jr nz, .asm_120e ; 0x1207 $5 + jr nz, .enemy + ld de, BattleMonNick - jr Function126a ; 0x120c $5c -.asm_120e + jr Function126a + +.enemy ld de, Char5AText ; Enemy call PlaceString ld h, b ld l, c ld de, EnemyMonNick - jr Function126a ; 0x1219 $4f + jr Function126a + -Function121b:: ; 121b +Char3F:: ; 121b push de + ld a, [InLinkBattle] and a jr nz, .linkbattle + ld a, [TrainerClass] cp RIVAL1 - jr z, .asm_1248 ; 0x1227 $1f + jr z, .rival cp RIVAL2 - jr z, .asm_1248 ; 0x122b $1b - ld de, $c656 + jr z, .rival + + ld de, OTName call PlaceString ld h, b ld l, c @@ -466,15 +388,18 @@ Function121b:: ; 121b callab Function39939 pop hl ld de, StringBuffer1 - jr Function126a ; 0x1246 $22 -.asm_1248 + jr Function126a + +.rival ld de, RivalName - jr Function126a ; 0x124b $1d + jr Function126a + .linkbattle - ld de, $c656 - jr Function126a ; 0x1250 $18 + ld de, OTName + jr Function126a + -Function1252:: ; 1252 +Char14:: ; 1252 push de ld de, PlayerName call PlaceString @@ -483,9 +408,10 @@ Function1252:: ; 1252 ld a, [PlayerGender] bit 0, a ld de, String12a5 - jr z, Function126a ; 0x1263 $5 + jr z, Function126a ld de, String12a6 - jr Function126a ; 0x1268 $0 + jr Function126a + Function126a:: ; 126a call PlaceString @@ -495,67 +421,53 @@ Function126a:: ; 126a jp NextChar ; 0x1273 -Char5CText:: ; 1273 - db "TM@" -Char5DText:: ; 1276 - db "TRAINER@" -Char5BText:: ; 127e - db "PC@" -Char5EText:: ; 1281 - db "ROCKET@" -Char54Text:: ; 1288 - db "POKé@" -Char23Text:: ; 128d - db "こうげき@" -Char56Text::; 1292 - db "……@" -Char5AText:: ; 1295 - db "Enemy @" -Char4AText:: ; 129c - db $e1, $e2, "@" ; PK MN -Char24Text:: ; 129f - db $70, $71, "@" ; PO KE -String12a2:: ; 12a2 - db " @" +Char5CText:: db "TM@" ; 1273 +Char5DText:: db "TRAINER@" ; 1276 +Char5BText:: db "PC@" ; 127e +Char5EText:: db "ROCKET@" ; 1281 +Char54Text:: db "POKé@" ; 1288 +Char23Text:: db "こうげき@" ; 128d +Char56Text:: db "……@" ; 1292 +Char5AText:: db "Enemy @" ; 1295 +Char4AText:: db $e1, $e2, "@" ; PK MN ; 129c +Char24Text:: db $70, $71, "@" ; PO KE ; 129f +String12a2:: db " @" ; 12a2 Char35Text:: Char36Text:: -Char37Text:: ; 12a4 - db "@" -String12a5:: ; 12a5 - db "@" -String12a6:: ; 12a6 - db "@" +Char37Text:: db "@" ; 12a4 +String12a5:: db "@" ; 12a5 +String12a6:: db "@" ; 12a6 ; 12a7 -Function12a7:: ; 12a7 +NextLine:: ; 12a7 pop hl - ld bc, $0028 + ld bc, SCREEN_WIDTH * 2 add hl, bc push hl jp NextChar ; 12b0 -Function12b0:: ; 12b0 +Char22:: ; 12b0 pop hl - ld bc, $0014 + ld bc, SCREEN_WIDTH add hl, bc push hl jp NextChar ; 12b9 -Function12b9:: ; 12b9 +Char16:: ; 12b9 pop hl push de - ld bc, $3b60 + ld bc, -TileMap + $10000 add hl, bc - ld de, $ffec - ld c, $1 + ld de, -SCREEN_WIDTH + ld c, 1 .asm_12c4 ld a, h and a jr nz, .asm_12cd ld a, l - cp $14 + cp SCREEN_WIDTH jr c, .asm_12d1 .asm_12cd @@ -565,7 +477,7 @@ Function12b9:: ; 12b9 .asm_12d1 ld hl, TileMap - ld de, $0014 + ld de, SCREEN_WIDTH ld a, c .asm_12d8 and a @@ -579,39 +491,40 @@ Function12b9:: ; 12b9 inc de ld a, [de] ld c, a - ld b, $0 + ld b, 0 add hl, bc push hl jp NextChar ; 12ea -Char4F:: ; 12ea +Line:: ; 12ea pop hl - hlcoord 1, 16 + hlcoord TEXTBOX_INNERX, TEXTBOX_INNERY + 2 push hl jp NextChar ; 0x12f2 -Function12f2:: ; 12f2 +Paragraph:: ; 12f2 push de + ld a, [InLinkBattle] cp $3 jr z, .asm_1301 cp $4 jr z, .asm_1301 call Function13c7 - .asm_1301 + call Function13b6 call Functionaaf - hlcoord 1, 14 - ld bc, $0312 + hlcoord TEXTBOX_INNERX, TEXTBOX_INNERY + lb bc, TEXTBOX_INNERH - 1, TEXTBOX_INNERW call ClearBox call Function13cd - ld c, $14 + ld c, 20 call DelayFrames - hlcoord 1, 14 + hlcoord TEXTBOX_INNERX, TEXTBOX_INNERY pop de jp NextChar ; 131f @@ -622,8 +535,8 @@ Char4B:: ; 131f or a jr nz, .asm_1328 call Function13c7 - .asm_1328 + call Function13b6 push de @@ -638,15 +551,15 @@ Function1337:: ; 1337 push de call Function138c call Function138c - hlcoord 1, 16 + hlcoord TEXTBOX_INNERX, TEXTBOX_INNERY + 2 pop de jp NextChar ; 1345 -Char55:: ; 1345 +ContText:: ; 1345 push de - ld de, Text_1354 + ld de, .cont ld b, h ld c, l call PlaceString @@ -654,80 +567,77 @@ Char55:: ; 1345 ld l, c pop de jp NextChar -; 1354 -Text_1354:: ; 1354 - db $4b, "@" +.cont db $4b, "@" ; 1356 Char5F:: ; 1356 -; ends a Pokédex entry +; Legacy: ends a Pokédex entry (Red). +; Dex entries are now regular strings. ld [hl], "." pop hl ret ; 135a -Function135a:: ; 135a +PromptText:: ; 135a ld a, [InLinkBattle] cp $3 - jr z, .asm_1368 + jr z, .ok cp $4 - jr z, .asm_1368 + jr z, .ok call Function13c7 +.ok -.asm_1368 call Function13b6 call Functionaaf ld a, [InLinkBattle] cp $3 - jr z, Function137c + jr z, DoneText cp $4 - jr z, Function137c + jr z, DoneText call Function13cd -Function137c:: ; 137c +DoneText:: ; 137c pop hl - ld de, .string_1382 + ld de, .stop dec de ret - -.string_1382 - db "@" +.stop db "@" ; 1383 -Function1383:: ; 1383 - ld a, $e6 +NullChar:: ; 1383 + ld a, "?" ld [hli], a call PrintLetterDelay jp NextChar ; 138c Function138c:: ; 138c - hlcoord 1, 14 - decoord 1, 13 - ld a, $3 -.asm_1394 + hlcoord TEXTBOX_INNERX, TEXTBOX_INNERY + decoord TEXTBOX_INNERX, TEXTBOX_INNERY - 1 + ld a, TEXTBOX_INNERH - 1 +.col push af - ld c, $12 -.asm_1397 + ld c, TEXTBOX_INNERW +.row ld a, [hli] ld [de], a inc de dec c - jr nz, .asm_1397 + jr nz, .row inc de inc de inc hl inc hl pop af dec a - jr nz, .asm_1394 - hlcoord 1, 16 - ld a, $7f - ld bc, $0012 + jr nz, .col + hlcoord TEXTBOX_INNERX, TEXTBOX_INNERY + 2 + ld a, " " + ld bc, TEXTBOX_INNERW call ByteFill - ld c, $5 + ld c, 5 call DelayFrames ret ; 13b6 @@ -736,7 +646,7 @@ Function13b6:: ; 13b6 push bc ld a, [hOAMUpdate] push af - ld a, $1 + ld a, 1 ld [hOAMUpdate], a call WaitBGMap pop af @@ -745,12 +655,12 @@ Function13b6:: ; 13b6 ret ; 13c6 -Function13c6:: ; 13c6 +Diacritic:: ; 13c6 ret ; 13c7 Function13c7:: ; 13c7 - ld a, $ee + ld a, "▼" ld [$c606], a ret ; 13cd @@ -761,26 +671,25 @@ Function13cd:: ; 13cd ret ; 13d4 -Function13d4:: ; 13d4 +FarString:: ; 13d4 ld b, a ld a, [hROMBank] push af + ld a, b rst Bankswitch - call PlaceString + pop af rst Bankswitch - ret ; 13e0 Function13e0:: ; 13e0 - ld hl, String_13e4 + ld hl, .stop ret -String_13e4: ; 13e4 - db "@" +.stop db "@" ; 13e5 @@ -789,22 +698,22 @@ Function13e5:: ; 13e5 push af set 1, a ld [$cfcf], a + call Function13f6 + pop af ld [$cfcf], a ret ; 13f6 Function13f6:: ; 13f6 -.asm_13f6 ld a, [hli] cp "@" ret z - call Function13ff - jr .asm_13f6 -; 13ff + call .TextCommand + jr Function13f6 -Function13ff:: ; 13ff +.TextCommand: push hl push bc ld c, a @@ -817,8 +726,8 @@ Function13ff:: ; 13ff ld d, [hl] pop bc pop hl - -; jp de + + ; jp de push de ret ; 1410 @@ -914,9 +823,8 @@ Text_16:: ; 1455 ; 1470 Text_02:: ; 1470 -; TX_NUM -; write bcdnumber from address, typically ram -; little endian +; TX_BCD +; write bcd from address, typically ram ; [$02][addr][flags] ; flags: see PrintBCDNumber @@ -939,14 +847,13 @@ Text_02:: ; 1470 Text_03:: ; 1480 ; TX_MOVE ; move to a new tile -; little endian -; [$03][tileaddr] +; [$03][addr] ld a, [hli] ld [$d0e6], a ld c, a ld a, [hli] - ld [$d0e7], a + ld [$d0e6 + 1], a ld b, a ret ; 148b @@ -955,7 +862,7 @@ Text_04:: ; 148b ; TX_BOX ; draw a box ; little endian -; [$04][tileaddr][height][width] +; [$04][addr][height][width] ld a, [hli] ld e, a @@ -978,7 +885,7 @@ Text_05:: ; 149b ; write text at (1,16) ; [$05] - bccoord 1, 16 + bccoord TEXTBOX_INNERX, TEXTBOX_INNERY + 2 ret ; 149f @@ -993,6 +900,7 @@ Text_06:: ; 149f jp z, Text_0D cp $4 jp z, Text_0D + push hl call Function13c7 push bc @@ -1009,25 +917,26 @@ Text_07:: ; 14ba call Function138c call Function138c pop hl - bccoord 1, 16 + bccoord TEXTBOX_INNERX, TEXTBOX_INNERY + 2 ret ; 14c9 Text_08:: ; 14c9 ; TX_ASM -; rom only? bit 7, h - jr nz, .asm_14ce + jr nz, .not_rom jp [hl] -.asm_14ce +.not_rom ld a, "@" ld [hl], a ret ; 14d2 Text_09:: ; 14d2 +; TX_NUM +; [$09][addr][hi:bytes lo:digits] ld a, [hli] ld e, a ld a, [hli] @@ -1057,11 +966,10 @@ Text_0A:: ; 14ed call GetJoypad ld a, [hJoyDown] and A_BUTTON | B_BUTTON - jr nz, .asm_14fd + jr nz, .done ld c, 30 call DelayFrames - -.asm_14fd +.done pop bc pop hl ret @@ -1078,17 +986,17 @@ Text_PlaySound:: ; 1500 ld b, a push hl ld hl, TextSFX -.asm_1508 +.loop ld a, [hli] - cp $ff - jr z, .asm_151f + cp -1 + jr z, .done cp b - jr z, .asm_1514 + jr z, .play inc hl inc hl - jr .asm_1508 + jr .loop -.asm_1514 +.play push de ld e, [hl] inc hl @@ -1097,7 +1005,7 @@ Text_PlaySound:: ; 1500 call WaitSFX pop de -.asm_151f +.done pop hl pop bc ret @@ -1123,29 +1031,30 @@ TextSFX:: ; 152d dbw $10, SFX_CAUGHT_MON dbw $11, SFX_DEX_FANFARE_80_109 dbw $13, SFX_SLOT_MACHINE_START - db $ff ; end + db -1 ; 1543 Text_0C:: ; 1543 +; [$0C][num] ld a, [hli] ld d, a push hl ld h, b ld l, c -.asm_1548 +.loop push de ld a, "…" ld [hli], a call GetJoypad ld a, [hJoyDown] and A_BUTTON | B_BUTTON - jr nz, .asm_155a + jr nz, .next ld c, 10 call DelayFrames -.asm_155a +.next pop de dec d - jr nz, .asm_1548 + jr nz, .loop ld b, h ld c, l pop hl @@ -1216,7 +1125,6 @@ Text_15:: ; 1582 call PlaceString pop hl ret -; 15a2 .Days ; 15a2 dw .Sun @@ -1236,4 +1144,3 @@ Text_15:: ; 1582 .Satur db "SATUR@" .Day db "DAY@" ; 15d8 - diff --git a/items/item_effects.asm b/items/item_effects.asm index 116d4ea7e..7a4ae00e3 100644 --- a/items/item_effects.asm +++ b/items/item_effects.asm @@ -213,7 +213,7 @@ ParkBall: ; e8a2 jp nz, Functionf7a0 ld a, [PartyCount] - cp 6 + cp PARTY_LENGTH jr nz, .asm_e8c0 ld a, $1 @@ -231,7 +231,7 @@ ParkBall: ; e8a2 call nz, Functionedfa ld hl, Options - res 4, [hl] + res NO_TEXT_SCROLL, [hl] ld hl, UsedItemText call PrintText @@ -323,15 +323,14 @@ ParkBall: ; e8a2 pop bc ld a, b - ld [hMultiplier], a + ld [hDivisor], a ld b, $4 call Divide ld a, [$ffb6] and a jr nz, .asm_e960 - ld a, $1 - + ld a, 1 .asm_e960 ld b, a ld a, [EnemyMonStatus] @@ -342,29 +341,40 @@ ParkBall: ; e8a2 ld c, 5 jr nz, .asm_e971 ld c, 0 - .asm_e971 ld a, b add c jr nc, .asm_e977 ld a, $ff - .asm_e977 + ld d, a push de + + ; BUG: callba overwrites a, + ; and GetItem takes b anyway. + + ; This is probably the reason + ; the HELD_CATCH_CHANCE effect + ; is never used. + + ; Uncomment the line below to fix. + ld a, [BattleMonItem] +; ld b, a callba GetItem - ld a, b - cp $46 + cp HELD_CATCH_CHANCE + pop de ld a, d + jr nz, .asm_e98e add c jr nc, .asm_e98e ld a, $ff - .asm_e98e + ld b, a ld [Buffer1], a call Random @@ -383,13 +393,12 @@ ParkBall: ; e8a2 call DelayFrames ld a, [CurItem] - cp $6 + cp POKE_BALL + 1 ; Assumes Master/Ultra/Great come before jr c, .asm_e9b0 - ld a, POKE_BALL - .asm_e9b0 ld [$c689], a + ld de, ANIM_THROW_POKE_BALL ld a, e ld [FXAnimIDLo], a @@ -417,8 +426,8 @@ ParkBall: ; e8a2 cp $4 ld hl, UnknownText_0xedc4 jp z, .asm_ebdc - .asm_e9f5 + ld hl, EnemyMonStatus ld a, [hli] push af @@ -435,8 +444,8 @@ ParkBall: ; e8a2 ld hl, EnemySubStatus5 ld a, [hl] push af - set 3, [hl] - bit 3, a + set SUBSTATUS_TRANSFORMED, [hl] + bit SUBSTATUS_TRANSFORMED, a jr nz, .asm_ea13 jr .asm_ea1a @@ -462,6 +471,7 @@ ParkBall: ; e8a2 pop af ld [EnemySubStatus5], a + pop hl pop af ld [hl], a @@ -473,8 +483,9 @@ ParkBall: ; e8a2 dec hl pop af ld [hl], a + ld hl, EnemySubStatus5 - bit 3, [hl] + bit SUBSTATUS_TRANSFORMED, [hl] jr nz, .asm_ea67 ld hl, $c735 ld de, EnemyMonMoves @@ -485,15 +496,16 @@ ParkBall: ; e8a2 ld de, EnemyMonPP ld bc, NUM_MOVES call CopyBytes - .asm_ea67 + ld a, [EnemyMonSpecies] ld [$c64e], a ld [CurPartySpecies], a ld [$d265], a ld a, [BattleType] - cp $3 + cp BATTLETYPE_TUTORIAL jp z, .asm_ebd9 + callba Function10607f ld hl, UnknownText_0xedc9 @@ -510,13 +522,13 @@ ParkBall: ; e8a2 ld a, [$d265] dec a call SetSeenAndCaughtMon - pop af and a jr nz, .asm_eab7 - call Function2ead + call Function2ead jr z, .asm_eab7 + ld hl, UnknownText_0xedf0 call PrintText @@ -528,16 +540,16 @@ ParkBall: ; e8a2 .asm_eab7 ld a, [BattleType] - cp $6 + cp BATTLETYPE_CONTEST jp z, .asm_ebd1 - cp $b + cp BATTLETYPE_CELEBI jr nz, .asm_eac8 ld hl, $d0ee set 6, [hl] - .asm_eac8 + ld a, [PartyCount] - cp 6 + cp PARTY_LENGTH jr z, .asm_eb3c xor a @@ -558,10 +570,10 @@ ParkBall: ; e8a2 ld bc, PartyMon2 - PartyMon1 call AddNTimes - ld a, 200 + ld a, FRIEND_BALL_HAPPINESS ld [hl], a - .asm_eaf8 + ld hl, UnknownText_0xedf5 call PrintText @@ -570,7 +582,6 @@ ParkBall: ; e8a2 call GetPokemonName call YesNoBox - jp c, .asm_ebe2 ld a, [PartyCount] @@ -609,7 +620,7 @@ ParkBall: ; e8a2 call GetSRAMBank ld a, [$ad10] - cp $14 + cp MONS_PER_BOX jr nz, .asm_eb5b ld hl, $d0ee set 7, [hl] @@ -618,7 +629,7 @@ ParkBall: ; e8a2 ld a, [CurItem] cp FRIEND_BALL jr nz, .asm_eb67 - ld a, 200 + ld a, FRIEND_BALL_HAPPINESS ld [$ad41], a .asm_eb67 @@ -632,7 +643,6 @@ ParkBall: ; e8a2 call GetPokemonName call YesNoBox - jr c, .asm_ebaf xor a @@ -692,23 +702,23 @@ ParkBall: ; e8a2 ret z cp 2 ret z - cp 6 - jr z, .asm_ec05 + cp BATTLETYPE_CONTEST + jr z, .used_park_ball ld a, [$c64e] and a - jr z, .asm_ebfb + jr z, .toss call WhiteBGMap call ClearTileMap -.asm_ebfb +.toss ld hl, NumItems inc a ld [$d10c], a jp TossItem -.asm_ec05 +.used_park_ball ld hl, $dc79 dec [hl] ret @@ -716,29 +726,33 @@ ParkBall: ; e8a2 Table_0xec0a: ; ec0a - dbw ULTRA_BALL, Function_0xec29 - dbw GREAT_BALL, Function_0xec2f - dbw MOON_STONE, Function_0xec2f - dbw HEAVY_BALL, Function_0xec50 - dbw LEVEL_BALL, Function_0xed8c - dbw LURE_BALL, Function_0xeccc - dbw FAST_BALL, Function_0xed68 - dbw MOON_BALL, Function_0xecdd - dbw LOVE_BALL, Function_0xed12 - dbw PARK_BALL, Function_0xec2f +; Note: SAFARI_BALL does not exist. + dbw ULTRA_BALL, UltraBallChance + dbw GREAT_BALL, GreatBallChance + dbw SAFARI_BALL, SafariBallChance + dbw HEAVY_BALL, HeavyBallChance + dbw LEVEL_BALL, LevelBallChance + dbw LURE_BALL, LureBallChance + dbw FAST_BALL, FastBallChance + dbw MOON_BALL, MoonBallChance + dbw LOVE_BALL, LoveBallChance + dbw PARK_BALL, ParkBallChance db $ff ; ec29 -Function_0xec29: ; ec29 +UltraBallChance: ; ec29 +; x2 sla b ret nc ld b, $ff ret ; ec2f - -Function_0xec2f: ; ec2f +GreatBallChance: ; ec2f +ParkBallChance: +SafariBallChance: +; x1.5 ld a, b srl a add b @@ -778,7 +792,7 @@ GLOBAL PokedexEntries4 db BANK(PokedexEntries4) ; ec50 -Function_0xec50: ; ec50 +HeavyBallChance: ; ec50 ld a, [EnemyMonSpecies] ld hl, PokedexDataPointerTable dec a @@ -806,14 +820,11 @@ Function_0xec50: ; ec50 rr l ld b, h ld c, l + + rept 4 srl b rr c - srl b - rr c - srl b - rr c - srl b - rr c + endr call .asm_ec99 srl b @@ -869,34 +880,33 @@ Function_0xec50: ; ec50 ret .table_ecc4 - db 8, 0 - db 12, 20 - db 16, 30 + db 8, 0 + db 12, 20 + db 16, 30 db 255, 40 ; eccc -Function_0xeccc: ; eccc +LureBallChance: ; eccc ld a, [BattleType] - cp $4 + cp BATTLETYPE_FISH ret nz + ld a, b add a - jr c, .asm_ecd9 + jr c, .max add b - jr nc, .asm_ecdb - -.asm_ecd9 + jr nc, .done +.max ld a, $ff - -.asm_ecdb +.done ld b, a ret ; ecdd -Function_0xecdd: ; ecdd +MoonBallChance: ; ecdd GLOBAL EvosAttacks GLOBAL EvosAttacksPointers @@ -924,13 +934,17 @@ GLOBAL EvosAttacksPointers inc hl inc hl -; It appears that Moon Stone's constant from Pokémon Red is used. -; No Pokémon evolve with Burn Heal, so -; Moon Balls always have a catch rate of 1x. + ; It appears that Moon Stone's + ; constant from Pokémon Red is used. + + ; No Pokémon evolve with Burn Heal, + ; so Moon Balls always have + ; a catch rate of 1x. + push bc ld a, BANK(EvosAttacks) call GetFarByte - cp MOON_STONE + 2 ; BURN_HEAL + cp MOON_STONE_RED ; BURN_HEAL pop bc ret nz @@ -945,7 +959,7 @@ GLOBAL EvosAttacksPointers ; ed12 -Function_0xed12: ; ed12 +LoveBallChance: ; ed12 ld a, [TempEnemyMonSpecies] ld c, a ld a, [TempBattleMonSpecies] @@ -1005,7 +1019,7 @@ Function_0xed12: ; ed12 ; ed68 -Function_0xed68: ; ed68 +FastBallChance: ; ed68 ld a, [TempEnemyMonSpecies] ld c, a ld hl, FleeMons @@ -1037,20 +1051,20 @@ Function_0xed68: ; ed68 ; ed8c -Function_0xed8c: ; ed8c +LevelBallChance: ; ed8c ld a, [BattleMonLevel] ld c, a ld a, [EnemyMonLevel] cp c ret nc sla b - jr c, .asm_eda8 + jr c, .max srl c cp c ret nc sla b - jr c, .asm_eda8 + jr c, .max srl c cp c @@ -1058,7 +1072,7 @@ Function_0xed8c: ; ed8c sla b ret nc -.asm_eda8 +.max ld b, $ff ret ; edab @@ -1810,7 +1824,7 @@ Functionf1db: ; f1db (3:71db) pop de ld a, [CurPartyMon] ; $d109 hlcoord 11, 0 - ld bc, $28 + ld bc, SCREEN_WIDTH * 2 call AddNTimes ld a, $2 ld [$d10a], a @@ -2242,9 +2256,9 @@ UnknownText_0xf47d: ; 0xf47d XAccuracy: ; f482 ld hl, PlayerSubStatus4 - bit 0, [hl] + bit SUBSTATUS_X_ACCURACY, [hl] jp nz, WontHaveAnyEffect_NotUsedMessage - set 0, [hl] + set SUBSTATUS_X_ACCURACY, [hl] jp Functionf789 ; f48f diff --git a/macros.asm b/macros.asm index 5973de043..89cf62c63 100644 --- a/macros.asm +++ b/macros.asm @@ -40,7 +40,7 @@ dbbw: MACRO ENDM dn: MACRO - db \1 << 4 + \2 + db (\1) << 4 + (\2) ENDM dt: MACRO ; three-byte (big-endian) @@ -67,7 +67,7 @@ callba: MACRO ; bank, address lb: MACRO ; r, hi, lo - ld \1, \2 << 8 + \3 + ld \1, (\2) << 8 + (\3) ENDM @@ -95,12 +95,12 @@ TX_FAR: MACRO ENDM RGB: MACRO - dw ((\3 << 10) | (\2 << 5) | (\1)) + dw (((\3) << 10) | ((\2) << 5) | (\1)) ENDM note: MACRO - db \1 << 4 + (\2 - 1) + db (\1) << 4 + ((\2) - 1) ENDM ; pitch @@ -192,7 +192,7 @@ x = 0 rept $20 ; Round up. dw (sin(x) + (sin(x) & $ff)) >> 8 -x = x + \1 * $40000 +x = x + (\1) * $40000 endr ENDM @@ -4763,7 +4763,7 @@ Function6219: ; 6219 ld [rSVBK], a ld hl, rLCDC res 2, [hl] - call Functionfdb + call ClearScreen call Function3200 xor a ld [hLCDStatCustom], a @@ -8635,7 +8635,7 @@ _PrintNum:: ; c4c7 .two dec e jr nz, .asm_c583 - ld a, $f6 + ld a, "0" ld [$ffb3], a .asm_c583 @@ -8701,10 +8701,10 @@ _PrintNum:: ; c4c7 .PrintDigit: ; c5cb (3:45cb) dec e jr nz, .ok - ld a, $f6 + ld a, "0" ld [$ffb3], a .ok - ld c, $0 + ld c, 0 .asm_c5d4 ld a, [$ffb7] ld b, a @@ -8721,7 +8721,7 @@ _PrintNum:: ; c4c7 cp b jr nc, .asm_c5f6 ld a, [$ffb4] - or $0 + or 0 jr z, .asm_c620 dec a ld [$ffb4], a @@ -8772,7 +8772,7 @@ _PrintNum:: ; c4c7 ld [hli], a res 5, d .asm_c637 - ld a, $f6 + ld a, "0" add c ld [hl], a ld [$ffb3], a @@ -10332,6 +10332,7 @@ UnknownText_0xce78: ; 0xce78 db "@" ; 0xce7d + Functionce7d: ; ce7d call Functionce86 and $7f @@ -10342,13 +10343,14 @@ Functionce7d: ; ce7d Functionce86: ; ce86 call GetFacingTileCoord call CheckHeadbuttTreeTile - jr nz, .asm_ce97 - ld hl, UnknownScript_0xcea7 + jr nz, .no_tree + + ld hl, HeadbuttFromMenuScript call Function31cd ld a, $81 ret -.asm_ce97 +.no_tree call Functionc779 ld a, $80 ret @@ -10366,25 +10368,26 @@ UnknownText_0xcea2: ; 0xcea2 db "@" ; 0xcea7 -UnknownScript_0xcea7: ; 0xcea7 +HeadbuttFromMenuScript: ; 0xcea7 reloadmappart special $0035 -UnknownScript_0xceab: ; 0xceab +HeadbuttScript: ; 0xceab 3callasm GetPartyNick 2writetext UnknownText_0xce9d + reloadmappart - 3callasm Function8c80a - 3callasm Functionb81ea - iffalse UnknownScript_0xcec3 + 3callasm ShakeHeadbuttTree + + 3callasm TreeMonEncounter + iffalse .no_battle loadmovesprites battlecheck startbattle returnafterbattle end -; 0xcec3 -UnknownScript_0xcec3: ; 0xcec3 +.no_battle 2writetext UnknownText_0xcea2 closetext loadmovesprites @@ -10394,23 +10397,24 @@ UnknownScript_0xcec3: ; 0xcec3 TryHeadbuttOW:: ; cec9 ld d, HEADBUTT call CheckPartyMove - jr c, .asm_ceda - ld a, BANK(UnknownScript_0xcedc) - ld hl, UnknownScript_0xcedc + jr c, .no + + ld a, BANK(AskHeadbuttScript) + ld hl, AskHeadbuttScript call CallScript scf ret -.asm_ceda +.no xor a ret ; cedc -UnknownScript_0xcedc: ; 0xcedc +AskHeadbuttScript: ; 0xcedc loadfont 2writetext UnknownText_0xcee6 yesorno - iftrue UnknownScript_0xceab + iftrue HeadbuttScript loadmovesprites end ; 0xcee6 @@ -10421,6 +10425,7 @@ UnknownText_0xcee6: ; 0xcee6 db "@" ; 0xceeb + Functionceeb: ; ceeb call Functioncef4 and $7f @@ -10430,16 +10435,17 @@ Functionceeb: ; ceeb Functioncef4: ; cef4 call Functioncf0d - jr c, .asm_cf07 + jr c, .no_rock ld a, d cp $18 - jr nz, .asm_cf07 - ld hl, UnknownScript_0xcf2e + jr nz, .no_rock + + ld hl, RockSmashFromMenuScript call Function31cd ld a, $81 ret -.asm_cf07 +.no_rock call Functionc779 ld a, $80 ret @@ -10448,6 +10454,7 @@ Functioncef4: ; cef4 Functioncf0d: ; cf0d callba CheckFacingObject jr nc, .asm_cf2c + ld a, [$ffb0] call Function1ae5 ld hl, $0001 @@ -10467,11 +10474,11 @@ Functioncf0d: ; cf0d ret ; cf2e -UnknownScript_0xcf2e: ; 0xcf2e +RockSmashFromMenuScript: ; 0xcf2e reloadmappart special $0035 -UnknownScript_0xcf32: ; cf32 +RockSmashScript: ; cf32 3callasm GetPartyNick 2writetext UnknownText_0xcf58 loadmovesprites @@ -10480,7 +10487,8 @@ UnknownScript_0xcf32: ; cf32 earthquake 84 applymovement2 MovementData_0xcf55 disappear $fe - 3callasm Functionb8219 + + 3callasm RockMonEncounter copybytetovar $d22e iffalse .done battlecheck @@ -10496,21 +10504,20 @@ MovementData_0xcf55: ; 0xcf55 UnknownText_0xcf58: ; 0xcf58 text_jump UnknownText_0x1c08f0 - db $50 + db "@" ; 0xcf5d -UnknownScript_0xcf5d: ; 0xcf5d - 3callasm Functioncf7c - if_equal $1, UnknownScript_0xcf6f +AskRockSmashScript: ; 0xcf5d + 3callasm HasRockSmash + if_equal 1, .no + loadfont 2writetext UnknownText_0xcf77 yesorno - iftrue UnknownScript_0xcf32 + iftrue RockSmashScript loadmovesprites end -; 0xcf6f - -UnknownScript_0xcf6f: ; 0xcf6f +.no jumptext UnknownText_0xcf72 ; 0xcf72 @@ -10526,17 +10533,18 @@ UnknownText_0xcf77: ; 0xcf77 db "@" ; 0xcf7c -Functioncf7c: ; cf7c +HasRockSmash: ; cf7c ld d, ROCK_SMASH call CheckPartyMove - jr nc, .asm_cf87 - ld a, $1 - jr .asm_cf8a -.asm_cf87 + jr nc, .yes +.no + ld a, 1 + jr .done +.yes xor a - jr .asm_cf8a -.asm_cf8a - ld [ScriptVar], a ; $c2dd + jr .done +.done + ld [ScriptVar], a ret @@ -10565,9 +10573,9 @@ Jumptable_cfa5: ; cfa5 Functioncfaf: ; cfaf ld a, [PlayerState] - cp $4 + cp PLAYER_SURF jr z, .asm_cfc4 - cp $8 + cp PLAYER_SURF_PIKA jr z, .asm_cfc4 call GetFacingTileCoord call GetTileCollision @@ -10772,9 +10780,9 @@ Functiond0bc: ; d0bc call Functiond121 jr c, .asm_d110 ld a, [PlayerState] - cp $0 + cp PLAYER_NORMAL jr z, .asm_d0ce - cp $1 + cp PLAYER_BIKE jr z, .asm_d0f7 jr .asm_d110 @@ -10877,7 +10885,8 @@ UnknownScript_0xd158: ; 0xd158 writecode $8, $0 2writetext UnknownText_0xd181 closetext -UnknownScript_0xd163 + +UnknownScript_0xd163: loadmovesprites special $0038 special $003c @@ -10914,28 +10923,31 @@ UnknownText_0xd181: ; 0xd181 db "@" ; 0xd186 + TryCutOW:: ; d186 ld d, CUT call CheckPartyMove - jr c, .asm_d19f + jr c, .cant_cut + ld de, ENGINE_HIVEBADGE call CheckEngineFlag - jr c, .asm_d19f - ld a, BANK(UnknownScript_0xd1a9) - ld hl, UnknownScript_0xd1a9 + jr c, .cant_cut + + ld a, BANK(AskCutScript) + ld hl, AskCutScript call CallScript scf ret -.asm_d19f - ld a, BANK(UnknownScript_0xd1cd) - ld hl, UnknownScript_0xd1cd +.cant_cut + ld a, BANK(CantCutScript) + ld hl, CantCutScript call CallScript scf ret ; d1a9 -UnknownScript_0xd1a9: ; 0xd1a9 +AskCutScript: ; 0xd1a9 loadfont 2writetext UnknownText_0xd1c8 yesorno @@ -10952,7 +10964,7 @@ Functiond1ba: ; d1ba ld [ScriptVar], a call Functionc7ce ret c - ld a, $1 + ld a, 1 ld [ScriptVar], a ret ; d1c8 @@ -10962,7 +10974,7 @@ UnknownText_0xd1c8: ; 0xd1c8 db "@" ; 0xd1cd -UnknownScript_0xd1cd: ; 0xd1cd +CantCutScript: ; 0xd1cd jumptext UnknownText_0xd1d0 ; 0xd1d0 @@ -18353,7 +18365,7 @@ String_121dd: ; 122dd String_1224f: ; 1224f db "a b c d e f g h i j" - db "k l m n o p q r s t + db "k l m n o p q r s t" db "u v w x y z . - /" db "'d 'l 'm 'r 's 't 'v & ( )" db $72, " ", $73, " [ ] ' : ; " @@ -18719,7 +18731,7 @@ UnknownText_0x124f5: ; 0x124f5 Function124fa: ; 124fa call ClearPalettes - call Functionfdb + call ClearScreen call Function3200 call HideSprites call Function4f0 @@ -31158,7 +31170,7 @@ Function241d5: ; 241d5 call Function24329 .asm_241d8 call Function2431a - call $402d ; This call jumps to the middle of an instruction. + call Function10402d ; BUG: This function is in a different bank. call Function241fa jr nc, .asm_241f9 call Function24270 @@ -35987,13 +35999,13 @@ Unknown_271de: ; 271de db HELD_HEAL_PARALYZE db HELD_HEAL_STATUS db $1e - db $1f - db $20 - db $21 - db $22 - db $23 - db $24 - db $25 + db HELD_ATTACK_UP + db HELD_DEFENSE_UP + db HELD_SPEED_UP + db HELD_SP_ATTACK_UP + db HELD_SP_DEFENSE_UP + db HELD_ACCURACY_UP + db HELD_EVASION_UP db $26 db $47 db HELD_ESCAPE @@ -36020,7 +36032,7 @@ Function28000: ; 28000 call WhiteBGMap ld c, $50 call DelayFrames - call Functionfdb + call ClearScreen call ClearSprites call Function1ad2 xor a @@ -36028,7 +36040,7 @@ Function28000: ; 28000 ld [hSCY], a ld c, $50 call DelayFrames - call Functionfdb + call ClearScreen call Function1ad2 call Functione51 call Functione58 @@ -36437,7 +36449,7 @@ Function28177: ; 28177 jr nz, .asm_283a9 ld a, CAL ld [OtherTrainerClass], a - call Functionfdb + call ClearScreen callba Function4d354 ld hl, Options ld a, [hl] @@ -36512,7 +36524,7 @@ Function283b2: ; 283b2 bccoord 1, 14 call Function13e5 call Function4b6 - call Functionfdb + call ClearScreen ld b, $8 call GetSGBLayout call Function3200 @@ -37209,7 +37221,7 @@ Function287d8: ; 287d8 ; 287e3 Function287e3: ; 287e3 - call Functionfdb + call ClearScreen call Function28ef8 callba Function16d673 xor a @@ -37599,7 +37611,7 @@ Function28ade: ; 28ade Function28b22: ; 28b22 call Function4b6 - call Functionfdb + call ClearScreen ld b, $8 call GetSGBLayout call Function3200 @@ -37936,7 +37948,7 @@ Function28b87: ; 28b87 dec a ld [CurPartyMon], a callab Function421d8 - call Functionfdb + call ClearScreen call Function28ef8 call Function28eff callba Function4d354 @@ -38649,7 +38661,7 @@ Function292f6: ; 292f6 ld de, $c736 call PlaceString ld hl, $c741 - ld de, NULL + ld de, 0 .asm_2931e ld a, [hli] cp $50 @@ -41681,204 +41693,206 @@ TrainerClassNames:: ; 2c1ef -AISpecialEffects: ; 2c41a (b:441a) -; Specific AI for certain move effects. +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, SpecialEffectMoves + ld hl, .Moves call IsInArray - jp nc, Function2c545 + jp nc, .NotRedundant inc hl ld a, [hli] ld h, [hl] ld l, a jp [hl] -; 2c42c (b:442c) - -SpecialEffectMoves: ; 2c42c - dbw EFFECT_DREAM_EATER, Function2c524 - dbw EFFECT_HEAL, Function2c539 - dbw EFFECT_LIGHT_SCREEN, Function2c487 - dbw EFFECT_MIST, Function2c48d - dbw EFFECT_FOCUS_ENERGY, Function2c493 - dbw EFFECT_CONFUSE, Function2c499 - dbw EFFECT_TRANSFORM, Function2c4a5 - dbw EFFECT_REFLECT, Function2c4ab - dbw EFFECT_SUBSTITUTE, Function2c4b1 - dbw EFFECT_LEECH_SEED, Function2c4b7 - dbw EFFECT_DISABLE, Function2c4bd - dbw EFFECT_ENCORE, Function2c4c2 - dbw EFFECT_SNORE, Function2c4c8 - dbw EFFECT_SLEEP_TALK, Function2c4c8 - dbw EFFECT_MEAN_LOOK, Function2c4d1 - dbw EFFECT_NIGHTMARE, Function2c4d7 - dbw EFFECT_SPIKES, Function2c4e3 - dbw EFFECT_FORESIGHT, Function2c4e9 - dbw EFFECT_PERISH_SONG, Function2c4ef - dbw EFFECT_SANDSTORM, Function2c4f5 - dbw EFFECT_ATTRACT, Function2c4fe - dbw EFFECT_SAFEGUARD, Function2c50c - dbw EFFECT_RAIN_DANCE, Function2c512 - dbw EFFECT_SUNNY_DAY, Function2c51b - dbw EFFECT_TELEPORT, Function2c541 - dbw EFFECT_MORNING_SUN, Function2c539 - dbw EFFECT_SYNTHESIS, Function2c539 - dbw EFFECT_MOONLIGHT, Function2c539 - dbw EFFECT_SWAGGER, Function2c52d - dbw EFFECT_FUTURE_SIGHT, Function2c533 - db $ff -; 2c487 -Function2c487: ; 2c487 - ld a, [EnemyScreens] ; $c700 - bit 3, a +.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 -Function2c48d: ; 2c48d - ld a, [EnemySubStatus4] ; $c670 - bit 1, a +.Mist: ; 2c48d + ld a, [EnemySubStatus4] + bit SUBSTATUS_MIST, a ret -Function2c493: ; 2c493 - ld a, [EnemySubStatus4] ; $c670 - bit 2, a +.FocusEnergy: ; 2c493 + ld a, [EnemySubStatus4] + bit SUBSTATUS_FOCUS_ENERGY, a ret -Function2c499: ; 2c499 - ld a, [PlayerSubStatus3] ; $c66a - bit 7, a +.Confuse: ; 2c499 + ld a, [PlayerSubStatus3] + bit SUBSTATUS_CONFUSED, a ret nz - ld a, [PlayerScreens] ; $c6ff - bit 2, a + ld a, [PlayerScreens] + bit SCREENS_SAFEGUARD, a ret -Function2c4a5: ; 2c4a5 - ld a, [EnemySubStatus5] ; $c671 - bit 3, a +.Transform: ; 2c4a5 + ld a, [EnemySubStatus5] + bit SUBSTATUS_TRANSFORMED, a ret -Function2c4ab: ; 2c4ab - ld a, [EnemyScreens] ; $c700 - bit 4, a +.Reflect: ; 2c4ab + ld a, [EnemyScreens] + bit SCREENS_REFLECT, a ret -; 2c4b1 (b:44b1) -Function2c4b1: ; 2c4b1 +.Substitute: ; 2c4b1 ld a, [EnemySubStatus4] - bit 4, a + bit SUBSTATUS_SUBSTITUTE, a ret -Function2c4b7: ; 2c4b7 - ld a, [PlayerSubStatus4] ; $c66b - bit 7, a +.LeechSeed: ; 2c4b7 + ld a, [PlayerSubStatus4] + bit SUBSTATUS_LEECH_SEED, a ret -Function2c4bd: ; 2c4bd - ld a, [PlayerDisableCount] ; $c675 +.Disable: ; 2c4bd + ld a, [PlayerDisableCount] and a ret -Function2c4c2: ; 2c4c2 - ld a, [PlayerSubStatus5] ; $c66c - bit 4, a +.Encore: ; 2c4c2 + ld a, [PlayerSubStatus5] + bit SUBSTATUS_ENCORED, a ret -Function2c4c8: ; 2c4c8 - ld a, [EnemyMonStatus] ; $d214 - and $7 - jr z, Function2c541 - jr Function2c545 +.Snore: +.SleepTalk: ; 2c4c8 + ld a, [EnemyMonStatus] + and SLP + jr z, .Redundant + jr .NotRedundant -Function2c4d1: ; 2c4d1 - ld a, [EnemySubStatus5] ; $c671 - bit 7, a +.MeanLook: ; 2c4d1 + ld a, [EnemySubStatus5] + bit SUBSTATUS_CANT_RUN, a ret -; 2c4d7 (b:44d7) -Function2c4d7: ; 2c4d7 +.Nightmare: ; 2c4d7 ld a, [BattleMonStatus] and a - jr z, Function2c541 + jr z, .Redundant ld a, [PlayerSubStatus1] - bit 0, a + bit SUBSTATUS_NIGHTMARE, a ret -Function2c4e3: ; 2c4e3 - ld a, [PlayerScreens] ; $c6ff - bit 0, a +.Spikes: ; 2c4e3 + ld a, [PlayerScreens] + bit SCREENS_SPIKES, a ret -Function2c4e9: ; 2c4e9 - ld a, [PlayerSubStatus1] ; $c668 - bit 3, a +.Foresight: ; 2c4e9 + ld a, [PlayerSubStatus1] + bit SUBSTATUS_IDENTIFIED, a ret -Function2c4ef: ; 2c4ef - ld a, [PlayerSubStatus1] ; $c668 - bit 4, a +.PerishSong: ; 2c4ef + ld a, [PlayerSubStatus1] + bit SUBSTATUS_PERISH, a ret -Function2c4f5: ; 2c4f5 - ld a, [Weather] ; $c70a - cp $3 - jr z, Function2c541 - jr Function2c545 +.Sandstorm: ; 2c4f5 + ld a, [Weather] + cp WEATHER_SANDSTORM + jr z, .Redundant + jr .NotRedundant -Function2c4fe: ; 2c4fe +.Attract: ; 2c4fe callba Function377f5 - jr c, Function2c541 - ld a, [PlayerSubStatus1] ; $c668 - bit 7, a + jr c, .Redundant + ld a, [PlayerSubStatus1] + bit SUBSTATUS_IN_LOVE, a ret -Function2c50c: ; 2c50c - ld a, [EnemyScreens] ; $c700 - bit 2, a +.Safeguard: ; 2c50c + ld a, [EnemyScreens] + bit SCREENS_SAFEGUARD, a ret -Function2c512: ; 2c512 - ld a, [Weather] ; $c70a - cp $1 - jr z, Function2c541 - jr Function2c545 +.RainDance: ; 2c512 + ld a, [Weather] + cp WEATHER_RAIN + jr z, .Redundant + jr .NotRedundant -Function2c51b: ; 2c51b - ld a, [Weather] ; $c70a - cp $2 - jr z, Function2c541 - jr Function2c545 +.SunnyDay: ; 2c51b + ld a, [Weather] + cp WEATHER_SUN + jr z, .Redundant + jr .NotRedundant -Function2c524: ; 2c524 - ld a, [BattleMonStatus] ; $c63a - and $7 - jr z, Function2c541 - jr Function2c545 +.DreamEater: ; 2c524 + ld a, [BattleMonStatus] + and SLP + jr z, .Redundant + jr .NotRedundant -Function2c52d: ; 2c52d - ld a, [PlayerSubStatus3] ; $c66a - bit 7, a +.Swagger: ; 2c52d + ld a, [PlayerSubStatus3] + bit SUBSTATUS_CONFUSED, a ret -Function2c533: ; 2c533 - ld a, [EnemyScreens] ; $c700 +.FutureSight: ; 2c533 + ld a, [EnemyScreens] bit 5, a ret -Function2c539: ; 2c539 +.Heal: +.MorningSun: +.Synthesis: +.Moonlight: ; 2c539 callba AICheckEnemyMaxHP - jr nc, Function2c545 + jr nc, .NotRedundant -Function2c541: ; 2c541 - ld a, $1 +.Teleport: +.Redundant: ; 2c541 + ld a, 1 and a ret -Function2c545: ; 2c545 (b:4545) +.NotRedundant: ; 2c545 xor a ret + Function2c547: ; 2c547 ld hl, UnknownText_0x2c5ef call PrintText @@ -47153,7 +47167,7 @@ AIChooseMove: ; 440ce jr z, .DecrementScores push bc - ld d, $e ; BANK(TrainerAI) + ld d, BANK(TrainerClassAttributes) predef FlagPredef ld d, c pop bc @@ -47180,13 +47194,13 @@ AIChooseMove: ; 440ce jr .CheckLayer ; Decrement the scores of all moves one by one until one reaches 0. -; If the Pokemon has no moves, the game goes into an endless loop. .DecrementScores ld hl, Buffer1 ld de, EnemyMonMoves ld c, EnemyMonMovesEnd - EnemyMonMoves .DecrementNextScore + ; If the enemy has no moves, this will infinite. ld a, [de] inc de and a @@ -47264,22 +47278,22 @@ AIChooseMove: ; 440ce AIScoringPointers: ; 441af - dw AIScoring_RedStatus - dw AIScoring_RedStatMods - dw AIScoring_RedSuperEffective - dw AIScoring_Offensive - dw AIScoring_Smart - dw AIScoring_Opportunist - dw AIScoring_Aggressive - dw AIScoring_Cautious - dw AIScoring_StatusImmunity - dw AIScoring_Risky - dw AIScoring_None - dw AIScoring_None - dw AIScoring_None - dw AIScoring_None - dw AIScoring_None - dw AIScoring_None + dw AI_Basic + dw AI_Setup + dw AI_Types + dw AI_Offensive + dw AI_Smart + dw AI_Opportunist + dw AI_Aggressive + dw AI_Cautious + dw AI_Status + dw AI_Risky + dw AI_None + dw AI_None + dw AI_None + dw AI_None + dw AI_None + dw AI_None ; 441cf @@ -47375,7 +47389,7 @@ Function4424d: ; 4424d ld a, b push af hlcoord 9, 5 - call Function13d4 + call FarString ld h, b ld l, c push de @@ -47463,7 +47477,7 @@ Function4424d: ; 4424d pop af hlcoord 2, 11 push af - call Function13d4 + call FarString pop bc ld a, [$cf65] or a @@ -47489,7 +47503,7 @@ Function4424d: ; 4424d inc de pop af hlcoord 2, 11 - call Function13d4 + call FarString ret ; 44331 @@ -49849,7 +49863,7 @@ Function48cdc: ; 48cdc (12:4cdc) call Function48cfd pop hl pop bc - ld de, $939 + ld de, AttrMap - TileMap add hl, de inc b inc b @@ -50125,7 +50139,7 @@ INCBIN "gfx/misc/pack_f.w40.2bpp" Function4925b: ; 4925b call FadeToMenu call WhiteBGMap - call Functionfdb + call ClearScreen call DelayFrame ld b, $14 call GetSGBLayout @@ -54551,7 +54565,7 @@ Function4d319: ; 4d319 ld a, [CurPartyMon] inc a ld [$cfa9], a - call Functionfdb + call ClearScreen call WhiteBGMap call MaxVolume callba Function28ef8 @@ -54577,7 +54591,7 @@ Function4d35b: ; 4d35b call Function4d37e pop hl pop bc - ld de, $0939 + ld de, AttrMap - TileMap add hl, de inc b inc b @@ -64604,7 +64618,7 @@ Function84785: ; 84785 ld d, [hl] hlcoord 1, 7 ld a, $77 - call Function13d4 + call FarString hlcoord 2, 15 ld de, String_847f5 call PlaceString @@ -64636,7 +64650,7 @@ Function847bd: ; 847bd ld d, [hl] hlcoord 4, 7 ld a, BANK(GBPrinterStrings) - call Function13d4 + call FarString hlcoord 4, 15 ld de, String_847f5 call PlaceString @@ -66435,7 +66449,7 @@ Function8920f: ; 8920f Function89215: ; 89215 push hl push bc - ld bc, $0939 + ld bc, AttrMap - TileMap add hl, bc ld [hl], a pop bc @@ -68961,7 +68975,7 @@ Function8a0a1: ; 8a0a1 (22:60a1) Function8a0c1: ; 8a0c1 (22:60c1) push hl - ld bc, $939 + ld bc, AttrMap - TileMap add hl, bc ld a, [hl] pop hl @@ -68987,7 +69001,7 @@ Function8a0c9: ; 8a0c9 (22:60c9) Function8a0de: ; 8a0de (22:60de) call Function8a0c9 - ld de, $939 + ld de, AttrMap - TileMap add hl, de ret @@ -70839,7 +70853,7 @@ Function8ae68: ; 8ae68 .asm_8aea5 call Function8af09 - ld bc, $0939 + ld bc, AttrMap - TileMap add hl, bc call Function8aee9 call Function3200 @@ -72369,7 +72383,7 @@ Function8b73e: ; 8b73e ; 8b744 Function8b744: ; 8b744 - ld de, $0939 + ld de, AttrMap - TileMap add hl, de inc b inc b @@ -74073,7 +74087,7 @@ Function8c7e1: ; 8c7e1 ret ; 8c80a -Function8c80a: ; 8c80a +ShakeHeadbuttTree: ; 8c80a callba Function8cf53 ld de, GFX_8c9cc ld hl, VTiles1 @@ -74159,10 +74173,10 @@ Function8c913: ; 8c913 ; 8c938 Unknown_8c938: ; 8c938 - dw $c570 ; ( 8, 10) - dw $c520 ; ( 8, 6) - dw $c546 ; ( 6, 8) - dw $c54a ; (10, 8) + dw TileMap + 8 + 10 * SCREEN_WIDTH + dw TileMap + 8 + 6 * SCREEN_WIDTH + dw TileMap + 6 + 8 * SCREEN_WIDTH + dw TileMap + 10 + 8 * SCREEN_WIDTH ; 8c940 Function8c940: ; 8c940 @@ -74195,7 +74209,7 @@ Function8c96d: ; 8c96d lb bc, BANK(GFX_8c9cc), 4 call Request2bpp ld de, CutTreeGFX - ld hl, $8840 + ld hl, VTiles1 + $40 lb bc, BANK(CutTreeGFX), 4 call Request2bpp ret @@ -81538,8 +81552,8 @@ Function91753: ; 91753 (24:5753) xor a ; OAKS_POKEMON_TALK ld [$d002], a ld [$d005], a - ld a, BANK(Functionb8612) - ld hl, Functionb8612 + ld a, BANK(PlayRadioShow) + ld hl, PlayRadioShow call Function9187c ld de, OaksPkmnTalkName ret @@ -81549,8 +81563,8 @@ Function91766: ; 91766 (24:5766) ld [$d002], a xor a ld [$d005], a - ld a, BANK(Functionb8612) - ld hl, Functionb8612 + ld a, BANK(PlayRadioShow) + ld hl, PlayRadioShow call Function9187c ld de, PokedexShowName ret @@ -81560,8 +81574,8 @@ Function9177b: ; 9177b (24:577b) ld [$d002], a xor a ld [$d005], a - ld a, BANK(Functionb8612) - ld hl, Functionb8612 + ld a, BANK(PlayRadioShow) + ld hl, PlayRadioShow call Function9187c ld de, PokemonMusicName ret @@ -81571,8 +81585,8 @@ Function91790: ; 91790 (24:5790) ld [$d002], a xor a ld [$d005], a - ld a, BANK(Functionb8612) - ld hl, Functionb8612 + ld a, BANK(PlayRadioShow) + ld hl, PlayRadioShow call Function9187c ld de, LuckyChannelName ret @@ -81582,8 +81596,8 @@ Function917a5: ; 917a5 (24:57a5) ld [$d002], a xor a ld [$d005], a - ld a, BANK(Functionb8612) - ld hl, Functionb8612 + ld a, BANK(PlayRadioShow) + ld hl, PlayRadioShow call Function9187c ld de, NotBuenasPasswordName ld a, [StatusFlags2] ; $d84d @@ -81601,8 +81615,8 @@ Function917d5: ; 917d5 (24:57d5) ld [$d002], a xor a ld [$d005], a - ld a, BANK(Functionb8612) - ld hl, Functionb8612 + ld a, BANK(PlayRadioShow) + ld hl, PlayRadioShow call Function9187c ld de, UnknownStationName ret @@ -81612,8 +81626,8 @@ Function917ea: ; 917ea (24:57ea) ld [$d002], a xor a ld [$d005], a - ld a, BANK(Functionb8612) - ld hl, Functionb8612 + ld a, BANK(PlayRadioShow) + ld hl, PlayRadioShow call Function9187c ld de, PlacesAndPeopleName ret @@ -81623,8 +81637,8 @@ Function917ff: ; 917ff (24:57ff) ld [$d002], a xor a ld [$d005], a - ld a, BANK(Functionb8612) - ld hl, Functionb8612 + ld a, BANK(PlayRadioShow) + ld hl, PlayRadioShow call Function9187c ld de, LetsAllSingName ret @@ -81635,8 +81649,8 @@ Function91814: ; 91814 ld [$d002], a xor a ld [$d005], a - ld a, BANK(Functionb8612) - ld hl, Functionb8612 + ld a, BANK(PlayRadioShow) + ld hl, PlayRadioShow call Function9187c ld de, LetsAllSingName ret @@ -81647,8 +81661,8 @@ Function91829: ; 91829 (24:5829) ld [$d002], a xor a ld [$d005], a - ld a, BANK(Functionb8612) - ld hl, Functionb8612 + ld a, BANK(PlayRadioShow) + ld hl, PlayRadioShow call Function9187c ld de, PokeFluteStationName ret @@ -81658,8 +81672,8 @@ Function9183e: ; 9183e (24:583e) ld [$d002], a xor a ld [$d005], a - ld a, BANK(Functionb8612) - ld hl, Functionb8612 + ld a, BANK(PlayRadioShow) + ld hl, PlayRadioShow call Function9187c ld de, UnknownStationName ret @@ -85371,7 +85385,7 @@ Functionb8101: ; b8101 (2e:4101) Functionb8115: ; b8115 - ld de, $0939 + ld de, AttrMap - TileMap add hl, de inc b inc b @@ -85522,143 +85536,157 @@ Functionb81e2: ; b81e2 ret ; b81ea -Functionb81ea: ; b81ea + +TreeMonEncounter: ; b81ea callba Function1060ef + xor a ld [$d22e], a ld [CurPartyLevel], a + ld hl, TreeMonMaps - call GetTreeMonEncounterTable - jr nc, .asm_b8214 - call LoadTreeMonData - jr nc, .asm_b8214 - call Functionb83e5 - jr nc, .asm_b8214 + call GetTreeMonSet + jr nc, .no_battle + + call GetTreeMons + jr nc, .no_battle + + call GetTreeMon + jr nc, .no_battle + ld a, BATTLETYPE_TREE ld [BattleType], a - ld a, $1 + ld a, 1 ld [ScriptVar], a ret -.asm_b8214 +.no_battle xor a ld [ScriptVar], a ret ; b8219 -Functionb8219: ; b8219 -; get a RockMon encounter +RockMonEncounter: ; b8219 xor a ld [$d22e], a ld [CurPartyLevel], a ld hl, RockMonMaps - call GetTreeMonEncounterTable - jr nc, .quit + call GetTreeMonSet + jr nc, .no_battle - call LoadTreeMonData - jr nc, .quit + call GetTreeMons + jr nc, .no_battle ld a, 10 call RandomRange cp 4 - jr nc, .quit + jr nc, .no_battle - call Functionb841f - jr nc, .quit + call SelectTreeMon + jr nc, .no_battle ret -.quit +.no_battle xor a ret ; b823e db $05 ; ???? -GetTreeMonEncounterTable: ; b823f -; Return carry and table id in a -; if MapGroup and MapNumber are in table hl +GetTreeMonSet: ; b823f +; Return carry and treemon set in a +; if the current map is in table hl. ld a, [MapNumber] ld e, a ld a, [MapGroup] ld d, a .loop ld a, [hli] - cp $ff - jr z, .quit + cp -1 + jr z, .not_in_table + cp d jr nz, .skip2 + ld a, [hli] cp e jr nz, .skip1 - jr .end + + jr .in_table + .skip2 inc hl .skip1 inc hl jr .loop -.quit + +.not_in_table xor a ret -.end + +.in_table ld a, [hl] scf ret ; b825e TreeMonMaps: ; b825e - db GROUP_ROUTE_26, MAP_ROUTE_26, 4 - db GROUP_ROUTE_27, MAP_ROUTE_27, 4 - db GROUP_ROUTE_28, MAP_ROUTE_28, 0 - db GROUP_ROUTE_29, MAP_ROUTE_29, 3 - db GROUP_ROUTE_30, MAP_ROUTE_30, 3 - db GROUP_ROUTE_31, MAP_ROUTE_31, 3 - db GROUP_ROUTE_32, MAP_ROUTE_32, 4 - db GROUP_ROUTE_33, MAP_ROUTE_33, 2 - db GROUP_ROUTE_34, MAP_ROUTE_34, 3 - db GROUP_ROUTE_35, MAP_ROUTE_35, 3 - db GROUP_ROUTE_36, MAP_ROUTE_36, 3 - db GROUP_ROUTE_37, MAP_ROUTE_37, 3 - db GROUP_ROUTE_38, MAP_ROUTE_38, 3 - db GROUP_ROUTE_39, MAP_ROUTE_39, 3 - db GROUP_ROUTE_40, MAP_ROUTE_40, 0 - db GROUP_ROUTE_41, MAP_ROUTE_41, 0 - db GROUP_ROUTE_42, MAP_ROUTE_42, 2 - db GROUP_ROUTE_43, MAP_ROUTE_43, 5 - db GROUP_ROUTE_44, MAP_ROUTE_44, 1 - db GROUP_ROUTE_45, MAP_ROUTE_45, 1 - db GROUP_ROUTE_46, MAP_ROUTE_46, 1 - db GROUP_NEW_BARK_TOWN, MAP_NEW_BARK_TOWN, 0 - db GROUP_CHERRYGROVE_CITY, MAP_CHERRYGROVE_CITY, 0 - db GROUP_VIOLET_CITY, MAP_VIOLET_CITY, 0 - db GROUP_AZALEA_TOWN, MAP_AZALEA_TOWN, 2 - db GROUP_CIANWOOD_CITY, MAP_CIANWOOD_CITY, 0 - db GROUP_GOLDENROD_CITY, MAP_GOLDENROD_CITY, 0 - db GROUP_OLIVINE_CITY, MAP_OLIVINE_CITY, 0 - db GROUP_ECRUTEAK_CITY, MAP_ECRUTEAK_CITY, 0 - db GROUP_MAHOGANY_TOWN, MAP_MAHOGANY_TOWN, 0 - db GROUP_LAKE_OF_RAGE, MAP_LAKE_OF_RAGE, 5 - db GROUP_BLACKTHORN_CITY, MAP_BLACKTHORN_CITY, 0 - db GROUP_SILVER_CAVE_OUTSIDE, MAP_SILVER_CAVE_OUTSIDE, 0 - db GROUP_ILEX_FOREST, MAP_ILEX_FOREST, 6 +treemon_map: macro + map \1 + db \2 ; treemon set +endm + treemon_map ROUTE_26, 4 + treemon_map ROUTE_27, 4 + treemon_map ROUTE_28, 0 + treemon_map ROUTE_29, 3 + treemon_map ROUTE_30, 3 + treemon_map ROUTE_31, 3 + treemon_map ROUTE_32, 4 + treemon_map ROUTE_33, 2 + treemon_map ROUTE_34, 3 + treemon_map ROUTE_35, 3 + treemon_map ROUTE_36, 3 + treemon_map ROUTE_37, 3 + treemon_map ROUTE_38, 3 + treemon_map ROUTE_39, 3 + treemon_map ROUTE_40, 0 + treemon_map ROUTE_41, 0 + treemon_map ROUTE_42, 2 + treemon_map ROUTE_43, 5 + treemon_map ROUTE_44, 1 + treemon_map ROUTE_45, 1 + treemon_map ROUTE_46, 1 + treemon_map NEW_BARK_TOWN, 0 + treemon_map CHERRYGROVE_CITY, 0 + treemon_map VIOLET_CITY, 0 + treemon_map AZALEA_TOWN, 2 + treemon_map CIANWOOD_CITY, 0 + treemon_map GOLDENROD_CITY, 0 + treemon_map OLIVINE_CITY, 0 + treemon_map ECRUTEAK_CITY, 0 + treemon_map MAHOGANY_TOWN, 0 + treemon_map LAKE_OF_RAGE, 5 + treemon_map BLACKTHORN_CITY, 0 + treemon_map SILVER_CAVE_OUTSIDE, 0 + treemon_map ILEX_FOREST, 6 db -1 ; b82c5 RockMonMaps: ; b82c5 - db GROUP_CIANWOOD_CITY, MAP_CIANWOOD_CITY, 7 - db GROUP_ROUTE_40, MAP_ROUTE_40, 7 - db GROUP_DARK_CAVE_VIOLET_ENTRANCE, MAP_DARK_CAVE_VIOLET_ENTRANCE, 7 - db GROUP_SLOWPOKE_WELL_B1F, MAP_SLOWPOKE_WELL_B1F, 7 + treemon_map CIANWOOD_CITY, 7 + treemon_map ROUTE_40, 7 + treemon_map DARK_CAVE_VIOLET_ENTRANCE, 7 + treemon_map SLOWPOKE_WELL_B1F, 7 db -1 ; b82d2 -LoadTreeMonData: ; b82d2 -; Return TreeMon pointer a in hl -; Return carry on success +GetTreeMons: ; b82d2 +; Return the address of TreeMon table a in hl. +; Return nc if table a doesn't exist. -; only 7 tables cp 8 jr nc, .quit @@ -85667,7 +85695,7 @@ LoadTreeMonData: ; b82d2 ld e, a ld d, 0 - ld hl, TreeMonPointers + ld hl, TreeMons add hl, de add hl, de @@ -85683,212 +85711,186 @@ LoadTreeMonData: ; b82d2 ret ; b82e8 -TreeMonPointers: ; b82e8 -; seems to point to "normal" tree encounter data -; so only odd-numbered tables are used - dw TreeMons1 ; 0 - dw TreeMons1 ; 1 - dw TreeMons3 ; 2 - dw TreeMons5 ; 3 - dw TreeMons7 ; 4 - dw TreeMons9 ; 5 - dw TreeMons11 ; 6 - dw RockMons ; 7 - dw TreeMons1 ; filler -; b82fa - -; structure: % species level +TreeMons: ; b82e8 + dw TreeMons1 + dw TreeMons1 + dw TreeMons2 + dw TreeMons3 + dw TreeMons4 + dw TreeMons5 + dw TreeMons6 + dw RockMons + dw TreeMons1 + +; Two tables each (normal, rare). +; Structure: +; db %, species, level TreeMons1: ; b82fa - db 50, SPEAROW, 10 - db 15, SPEAROW, 10 - db 15, SPEAROW, 10 - db 10, AIPOM, 10 - db 5, AIPOM, 10 - db 5, AIPOM, 10 - db $ff ; end -; b830d - -TreeMons2 ; b830d -; unused - db 50, SPEAROW, 10 - db 15, HERACROSS, 10 - db 15, HERACROSS, 10 - db 10, AIPOM, 10 - db 5, AIPOM, 10 - db 5, AIPOM, 10 - db $ff ; end -; b8320 - -TreeMons3: ; b8320 - db 50, SPEAROW, 10 - db 15, EKANS, 10 - db 15, SPEAROW, 10 - db 10, AIPOM, 10 - db 5, AIPOM, 10 - db 5, AIPOM, 10 - db $ff ; end -; b8333 - -TreeMons4: ; b8333 -; unused - db 50, SPEAROW, 10 - db 15, HERACROSS, 10 - db 15, HERACROSS, 10 - db 10, AIPOM, 10 - db 5, AIPOM, 10 - db 5, AIPOM, 10 - db $ff ; end -; b8346 - -TreeMons5: ; b8346 - db 50, HOOTHOOT, 10 - db 15, SPINARAK, 10 - db 15, LEDYBA, 10 - db 10, EXEGGCUTE, 10 - db 5, EXEGGCUTE, 10 - db 5, EXEGGCUTE, 10 - db $ff ; end -; b8359 - -TreeMons6: ; b8359 -; unused - db 50, HOOTHOOT, 10 - db 15, PINECO, 10 - db 15, PINECO, 10 - db 10, EXEGGCUTE, 10 - db 5, EXEGGCUTE, 10 - db 5, EXEGGCUTE, 10 - db $ff ; end -; b836c - -TreeMons7: ; b836c - db 50, HOOTHOOT, 10 - db 15, EKANS, 10 - db 15, HOOTHOOT, 10 - db 10, EXEGGCUTE, 10 - db 5, EXEGGCUTE, 10 - db 5, EXEGGCUTE, 10 - db $ff ; end -; b837f - -TreeMons8: ; b837f -; unused - db 50, HOOTHOOT, 10 - db 15, PINECO, 10 - db 15, PINECO, 10 - db 10, EXEGGCUTE, 10 - db 5, EXEGGCUTE, 10 - db 5, EXEGGCUTE, 10 - db $ff ; end -; b8392 - -TreeMons9: ; b8392 - db 50, HOOTHOOT, 10 - db 15, VENONAT, 10 - db 15, HOOTHOOT, 10 - db 10, EXEGGCUTE, 10 - db 5, EXEGGCUTE, 10 - db 5, EXEGGCUTE, 10 - db $ff ; end -; b83a5 - -TreeMons10: ; b83a5 -; unused - db 50, HOOTHOOT, 10 - db 15, PINECO, 10 - db 15, PINECO, 10 - db 10, EXEGGCUTE, 10 - db 5, EXEGGCUTE, 10 - db 5, EXEGGCUTE, 10 - db $ff ; end -; b83b8 - -TreeMons11: ; b83b8 - db 50, HOOTHOOT, 10 - db 15, PINECO, 10 - db 15, PINECO, 10 - db 10, NOCTOWL, 10 - db 5, BUTTERFREE, 10 - db 5, BEEDRILL, 10 - db $ff ; end -; b83cb - -TreeMons12; b83cb -; unused - db 50, HOOTHOOT, 10 - db 15, CATERPIE, 10 - db 15, WEEDLE, 10 - db 10, HOOTHOOT, 10 - db 5, METAPOD, 10 - db 5, KAKUNA, 10 - db $ff ; end -; b83de + db 50, SPEAROW, 10 + db 15, SPEAROW, 10 + db 15, SPEAROW, 10 + db 10, AIPOM, 10 + db 5, AIPOM, 10 + db 5, AIPOM, 10 + db -1 + + db 50, SPEAROW, 10 + db 15, HERACROSS, 10 + db 15, HERACROSS, 10 + db 10, AIPOM, 10 + db 5, AIPOM, 10 + db 5, AIPOM, 10 + db -1 + +TreeMons2: ; b8320 + db 50, SPEAROW, 10 + db 15, EKANS, 10 + db 15, SPEAROW, 10 + db 10, AIPOM, 10 + db 5, AIPOM, 10 + db 5, AIPOM, 10 + db -1 + + db 50, SPEAROW, 10 + db 15, HERACROSS, 10 + db 15, HERACROSS, 10 + db 10, AIPOM, 10 + db 5, AIPOM, 10 + db 5, AIPOM, 10 + db -1 + +TreeMons3: ; b8346 + db 50, HOOTHOOT, 10 + db 15, SPINARAK, 10 + db 15, LEDYBA, 10 + db 10, EXEGGCUTE, 10 + db 5, EXEGGCUTE, 10 + db 5, EXEGGCUTE, 10 + db -1 + + db 50, HOOTHOOT, 10 + db 15, PINECO, 10 + db 15, PINECO, 10 + db 10, EXEGGCUTE, 10 + db 5, EXEGGCUTE, 10 + db 5, EXEGGCUTE, 10 + db -1 + +TreeMons4: ; b836c + db 50, HOOTHOOT, 10 + db 15, EKANS, 10 + db 15, HOOTHOOT, 10 + db 10, EXEGGCUTE, 10 + db 5, EXEGGCUTE, 10 + db 5, EXEGGCUTE, 10 + db -1 + + db 50, HOOTHOOT, 10 + db 15, PINECO, 10 + db 15, PINECO, 10 + db 10, EXEGGCUTE, 10 + db 5, EXEGGCUTE, 10 + db 5, EXEGGCUTE, 10 + db -1 + +TreeMons5: ; b8392 + db 50, HOOTHOOT, 10 + db 15, VENONAT, 10 + db 15, HOOTHOOT, 10 + db 10, EXEGGCUTE, 10 + db 5, EXEGGCUTE, 10 + db 5, EXEGGCUTE, 10 + db -1 + + db 50, HOOTHOOT, 10 + db 15, PINECO, 10 + db 15, PINECO, 10 + db 10, EXEGGCUTE, 10 + db 5, EXEGGCUTE, 10 + db 5, EXEGGCUTE, 10 + db -1 + +TreeMons6: ; b83b8 + db 50, HOOTHOOT, 10 + db 15, PINECO, 10 + db 15, PINECO, 10 + db 10, NOCTOWL, 10 + db 5, BUTTERFREE, 10 + db 5, BEEDRILL, 10 + db -1 + + db 50, HOOTHOOT, 10 + db 15, CATERPIE, 10 + db 15, WEEDLE, 10 + db 10, HOOTHOOT, 10 + db 5, METAPOD, 10 + db 5, KAKUNA, 10 + db -1 RockMons: ; b83de - db 90, KRABBY, 15 - db 10, SHUCKLE, 15 - db $ff ; end + db 90, KRABBY, 15 + db 10, SHUCKLE, 15 + db -1 ; b83e5 -Functionb83e5: ; b83e5 +GetTreeMon: ; b83e5 push hl - call Functionb8443 + call GetTreeScore pop hl and a - jr z, .asm_b83f6 - cp $1 - jr z, .asm_b8400 - cp $2 - jr z, .asm_b840b + jr z, .bad + cp 1 + jr z, .good + cp 2 + jr z, .rare ret -.asm_b83f6 +.bad ld a, 10 call RandomRange and a - jr nz, Functionb843b - jr Functionb841f + jr nz, NoTreeMon + jr SelectTreeMon -.asm_b8400 +.good ld a, 10 call RandomRange cp 5 - jr nc, Functionb843b - jr Functionb841f + jr nc, NoTreeMon + jr SelectTreeMon -.asm_b840b +.rare ld a, 10 call RandomRange cp 8 - jr nc, Functionb843b - jr .asm_b8416 - -.asm_b8416 + jr nc, NoTreeMon + jr .skip +.skip ld a, [hli] - cp $ff - jr nz, .asm_b8416 - call Functionb841f + cp -1 + jr nz, .skip + call SelectTreeMon ret ; b841f -Functionb841f: ; b841f -; Read a TreeMons table. +SelectTreeMon: ; b841f +; Read a TreeMons table and pick one monster at random. ld a, 100 call RandomRange -.asm_b8424 +.loop sub [hl] - jr c, .asm_b842c + jr c, .ok inc hl inc hl inc hl - jr .asm_b8424 + jr .loop -.asm_b842c +.ok ld a, [hli] cp $ff - jr z, Functionb843b + jr z, NoTreeMon ld a, [hli] ld [$d22e], a @@ -85897,58 +85899,60 @@ Functionb841f: ; b841f scf ret -Functionb843b: ; b843b +NoTreeMon: ; b843b xor a ld [$d22e], a ld [CurPartyLevel], a ret ; b8443 -Functionb8443: ; b8443 - call Functionb8466 +GetTreeScore: ; b8443 + call .CoordScore ld [Buffer1], a - call Functionb849d + call .OTIDScore ld [Buffer2], a ld c, a ld a, [Buffer1] sub c - jr z, .asm_b8463 - jr nc, .asm_b845a - add $a + jr z, .rare + jr nc, .ok + add 10 +.ok + cp 5 + jr c, .good -.asm_b845a - cp $5 - jr c, .asm_b8460 +.bad xor a ret -.asm_b8460 - ld a, $1 +.good + ld a, 1 ret -.asm_b8463 - ld a, $2 +.rare + ld a, 2 ret ; b8466 -Functionb8466: ; b8466 +.CoordScore: ; b8466 call GetFacingTileCoord - ld hl, $0000 + ld hl, 0 ld c, e - ld b, $0 + ld b, 0 ld a, d - and a - jr z, .asm_b8477 -.asm_b8473 + and a + jr z, .next +.loop add hl, bc dec a - jr nz, .asm_b8473 + jr nz, .loop +.next -.asm_b8477 add hl, bc ld c, d add hl, bc + ld a, h ld [hDividend], a ld a, l @@ -85957,6 +85961,7 @@ Functionb8466: ; b8466 ld [hDivisor], a ld b, 2 call Divide + ld a, [hQuotient + 1] ld [hDividend], a ld a, [hQuotient + 2] @@ -85965,11 +85970,12 @@ Functionb8466: ; b8466 ld [hDivisor], a ld b, 2 call Divide + ld a, [hQuotient + 3] ret ; b849d -Functionb849d: ; b849d +.OTIDScore: ; b849d ld a, [PlayerID] ld [hDividend], a ld a, [PlayerID + 1] @@ -85982,26 +85988,29 @@ Functionb849d: ; b849d ret ; b84b3 + Functionb84b3: ; b84b3 ld a, [rVBK] push af ld a, $1 ld [rVBK], a + ld de, FishingGFX ld a, [PlayerGender] bit 0, a jr z, .asm_b84c7 ld de, KrisFishingGFX - .asm_b84c7 + ld hl, $8020 call Functionb84e3 ld hl, $8060 call Functionb84e3 ld hl, $80a0 call Functionb84e3 - ld hl, $8fc0 + ld hl, $9000 - $40 call Functionb84e3 + pop af ld [rVBK], a ret @@ -86012,7 +86021,7 @@ Functionb84e3: ; b84e3 push de call Get2bpp pop de - ld hl, $0020 + ld hl, $20 add hl, de ld d, h ld e, l @@ -86027,7 +86036,8 @@ KrisFishingGFX: ; b8582 INCBIN "baserom.gbc",$b8582,$b8612 - $b8582 ; b8612 -Functionb8612: ; b8612 + +PlayRadioShow: ; b8612 ld a, [$d002] cp 8 jr nc, .ok @@ -90064,7 +90074,7 @@ Functione03ec: ; e03ec ld a, [hCGB] and a ret z - ld de, $0939 + ld de, AttrMap - TileMap add hl, de ld a, [CurEnemyMoveNum] and 3 @@ -94692,7 +94702,7 @@ Functione31e7: ; e31e7 pop hl ld a, [wCurBox] push af - ld bc, NULL + ld bc, 0 ld a, [$cb31] and a jr nz, .asm_e3215 @@ -107791,7 +107801,7 @@ Function1176ee: ; 1176ee (45:76ee) .asm_117709 callba Function8cf53 call WhiteBGMap - call Functionfdb + call ClearScreen call ClearSprites ret @@ -111090,7 +111100,7 @@ Function11c1ca: ; 11c1ca call Function11c254 call WhiteBGMap call ClearSprites - call Functionfdb + call ClearScreen call Function11d323 call Function32f9 call DisableLCD @@ -113467,7 +113477,7 @@ Function16d61d: ; 16d61d call Function16d640 pop hl pop bc - ld de, $0939 + ld de, AttrMap - TileMap add hl, de inc b inc b @@ -113875,7 +113885,7 @@ Function1704e1: ; 1704e1 Function1704f1: ; 1704f1 call WhiteBGMap call ClearSprites - call Functionfdb + call ClearScreen .asm_1704fa call Functiona57 ld a, [$cf63] @@ -115490,7 +115500,7 @@ Function17d370: ; 17d370 ld [$cd6c], a call WhiteBGMap call ClearSprites - call Functionfdb + call ClearScreen callba Function104061 call DisableLCD ld hl, $8ee0 @@ -116360,16 +116370,16 @@ Function17f41d: ; 17f41d push af ld l, c ld h, b - ld bc, $3b60 + ld bc, -TileMap + $10000 add hl, bc - ld de, $ffec + ld de, -SCREEN_WIDTH ld c, $1 .asm_17f42c ld a, h and a jr nz, .asm_17f435 ld a, l - cp $14 + cp SCREEN_WIDTH jr c, .asm_17f439 .asm_17f435 @@ -116379,7 +116389,7 @@ Function17f41d: ; 17f41d .asm_17f439 ld hl, TileMap - ld de, $0014 + ld de, SCREEN_WIDTH ld a, c .asm_17f440 and a @@ -116391,7 +116401,7 @@ Function17f41d: ; 17f41d .asm_17f447 pop af ld e, a - ld d, $0 + ld d, 0 add hl, de pop de and a @@ -116412,7 +116422,7 @@ Function17f44f: ; 17f44f ld l, c ld h, b ld c, a - ld b, $0 + ld b, 0 add hl, bc ld a, [de] cp $50 @@ -116961,7 +116971,7 @@ Function1dc1b0: ; 1dc1b0 pop af ld a, b ld hl, $cb6d - call nz, Function13d4 + call nz, FarString ld hl, $caa3 ld [hl], $35 ld de, $0014 @@ -117011,7 +117021,7 @@ Function1dc213: ; 1dc213 pop af ld hl, $caa5 ld a, b - call nz, Function13d4 + call nz, FarString ret ; 1dc26a @@ -117793,7 +117803,7 @@ INCBIN "baserom.gbc",$1f4000,$1f4003 - $1f4000 Function1f4003: ; 1f4003 ld a, $6 call GetSRAMBank - ld hl, $4018 + ld hl, MobileSave ld de, $a000 ld bc, $1000 call CopyBytes @@ -117801,7 +117811,9 @@ Function1f4003: ; 1f4003 ret ; 1f4018 -INCBIN "baserom.gbc",$1f4018,$1f636a - $1f4018 +MobileSave: INCBIN "misc/mobile_save.bin" + +INCBIN "baserom.gbc",$1f5018,$1f636a - $1f5018 SECTION "bank7E", ROMX, BANK[$7E] diff --git a/misc/mobile_save.bin b/misc/mobile_save.bin Binary files differnew file mode 100644 index 000000000..fc9afb13c --- /dev/null +++ b/misc/mobile_save.bin diff --git a/trainers/attributes.asm b/trainers/attributes.asm index 15fd48591..c6d4037da 100644 --- a/trainers/attributes.asm +++ b/trainers/attributes.asm @@ -1,20 +1,20 @@ - -AI_STATUS_RED EQU 1 << 0 -AI_STAT_MODS_RED EQU 1 << 1 -AI_TYPES_RED EQU 1 << 2 -AI_OFFENSIVE EQU 1 << 3 -AI_SMART EQU 1 << 4 -AI_OPPORTUNIST EQU 1 << 5 -AI_AGGRESSIVE EQU 1 << 6 -AI_CAUTIOUS EQU 1 << 7 -AI_STATUS_IMMUNE EQU 1 << 8 -AI_RISKY EQU 1 << 9 -AI_10 EQU 1 << 10 -AI_11 EQU 1 << 11 -AI_12 EQU 1 << 12 -AI_13 EQU 1 << 13 -AI_14 EQU 1 << 14 -AI_15 EQU 1 << 15 +NO_AI EQU 0 +AI_BASIC EQU 1 << 0 +AI_SETUP EQU 1 << 1 +AI_TYPES EQU 1 << 2 +AI_OFFENSIVE EQU 1 << 3 +AI_SMART EQU 1 << 4 +AI_OPPORTUNIST EQU 1 << 5 +AI_AGGRESSIVE EQU 1 << 6 +AI_CAUTIOUS EQU 1 << 7 +AI_STATUS EQU 1 << 8 +AI_RISKY EQU 1 << 9 +AI_10 EQU 1 << 10 +AI_11 EQU 1 << 11 +AI_12 EQU 1 << 12 +AI_13 EQU 1 << 13 +AI_14 EQU 1 << 14 +AI_15 EQU 1 << 15 TrainerClassAttributes: ; 3959c @@ -22,404 +22,404 @@ TrainerClassAttributes: ; 3959c ; Falkner db NONE, NONE ; items db 25 ; base reward - dw AI_STATUS_RED | AI_STAT_MODS_RED | AI_SMART | AI_AGGRESSIVE | AI_CAUTIOUS | AI_STATUS_IMMUNE | AI_RISKY - db $44, $00 + dw AI_BASIC + AI_SETUP + AI_SMART + AI_AGGRESSIVE + AI_CAUTIOUS + AI_STATUS + AI_RISKY + dw CONTEXT_USE + SWITCH_SOMETIMES ; Whitney db NONE, NONE ; items db 25 ; base reward - dw AI_STATUS_RED | AI_STAT_MODS_RED | AI_SMART | AI_AGGRESSIVE | AI_CAUTIOUS | AI_STATUS_IMMUNE | AI_RISKY - db $44, $00 + dw AI_BASIC + AI_SETUP + AI_SMART + AI_AGGRESSIVE + AI_CAUTIOUS + AI_STATUS + AI_RISKY + dw CONTEXT_USE + SWITCH_SOMETIMES ; Bugsy db NONE, NONE ; items db 25 ; base reward - dw AI_STATUS_RED | AI_STAT_MODS_RED | AI_SMART | AI_AGGRESSIVE | AI_CAUTIOUS | AI_STATUS_IMMUNE | AI_RISKY - db $44, $00 + dw AI_BASIC + AI_SETUP + AI_SMART + AI_AGGRESSIVE + AI_CAUTIOUS + AI_STATUS + AI_RISKY + dw CONTEXT_USE + SWITCH_SOMETIMES ; Morty db NONE, NONE ; items db 25 ; base reward - dw AI_STATUS_RED | AI_STAT_MODS_RED | AI_SMART | AI_AGGRESSIVE | AI_CAUTIOUS | AI_STATUS_IMMUNE | AI_RISKY - db $44, $00 + dw AI_BASIC + AI_SETUP + AI_SMART + AI_AGGRESSIVE + AI_CAUTIOUS + AI_STATUS + AI_RISKY + dw CONTEXT_USE + SWITCH_SOMETIMES ; Pryce db HYPER_POTION, NONE ; items db 25 ; base reward - dw AI_STATUS_RED | AI_STAT_MODS_RED | AI_SMART | AI_AGGRESSIVE | AI_CAUTIOUS | AI_STATUS_IMMUNE | AI_RISKY - db $44, $00 + dw AI_BASIC + AI_SETUP + AI_SMART + AI_AGGRESSIVE + AI_CAUTIOUS + AI_STATUS + AI_RISKY + dw CONTEXT_USE + SWITCH_SOMETIMES ; Jasmine db HYPER_POTION, NONE ; items db 25 ; base reward - dw AI_STATUS_RED | AI_STAT_MODS_RED | AI_SMART | AI_AGGRESSIVE | AI_CAUTIOUS | AI_STATUS_IMMUNE | AI_RISKY - db $44, $00 + dw AI_BASIC + AI_SETUP + AI_SMART + AI_AGGRESSIVE + AI_CAUTIOUS + AI_STATUS + AI_RISKY + dw CONTEXT_USE + SWITCH_SOMETIMES ; Chuck db FULL_HEAL, NONE ; items db 25 ; base reward - dw AI_STATUS_RED | AI_STAT_MODS_RED | AI_SMART | AI_AGGRESSIVE | AI_CAUTIOUS | AI_STATUS_IMMUNE | AI_RISKY - db $44, $00 + dw AI_BASIC + AI_SETUP + AI_SMART + AI_AGGRESSIVE + AI_CAUTIOUS + AI_STATUS + AI_RISKY + dw CONTEXT_USE + SWITCH_SOMETIMES ; Clair db FULL_HEAL, HYPER_POTION ; items db 25 ; base reward - dw AI_STATUS_RED | AI_STAT_MODS_RED | AI_SMART | AI_AGGRESSIVE | AI_CAUTIOUS | AI_STATUS_IMMUNE | AI_RISKY - db $44, $00 + dw AI_BASIC + AI_SETUP + AI_SMART + AI_AGGRESSIVE + AI_CAUTIOUS + AI_STATUS + AI_RISKY + dw CONTEXT_USE + SWITCH_SOMETIMES ; Rival1 db NONE, NONE ; items db 15 ; base reward - dw AI_STATUS_RED | AI_STAT_MODS_RED | AI_SMART | AI_AGGRESSIVE | AI_CAUTIOUS | AI_STATUS_IMMUNE | AI_RISKY - db $44, $00 + dw AI_BASIC + AI_SETUP + AI_SMART + AI_AGGRESSIVE + AI_CAUTIOUS + AI_STATUS + AI_RISKY + dw CONTEXT_USE + SWITCH_SOMETIMES ; Pokemon Prof db NONE, NONE ; items db 25 ; base reward - dw AI_STATUS_RED | AI_AGGRESSIVE | AI_STATUS_IMMUNE - db $44, $00 + dw AI_BASIC + AI_AGGRESSIVE + AI_STATUS + dw CONTEXT_USE + SWITCH_SOMETIMES ; Will db MAX_POTION, NONE ; items db 25 ; base reward - dw AI_STATUS_RED | AI_STAT_MODS_RED | AI_SMART | AI_AGGRESSIVE | AI_CAUTIOUS | AI_STATUS_IMMUNE | AI_RISKY - db $44, $00 + dw AI_BASIC + AI_SETUP + AI_SMART + AI_AGGRESSIVE + AI_CAUTIOUS + AI_STATUS + AI_RISKY + dw CONTEXT_USE + SWITCH_SOMETIMES ; Cal db NONE, NONE ; items db 25 ; base reward - dw AI_STATUS_RED | AI_STAT_MODS_RED | AI_SMART | AI_AGGRESSIVE | AI_CAUTIOUS | AI_STATUS_IMMUNE | AI_RISKY - db $44, $00 + dw AI_BASIC + AI_SETUP + AI_SMART + AI_AGGRESSIVE + AI_CAUTIOUS + AI_STATUS + AI_RISKY + dw CONTEXT_USE + SWITCH_SOMETIMES ; Bruno db MAX_POTION, NONE ; items db 25 ; base reward - dw AI_STATUS_RED | AI_STAT_MODS_RED | AI_SMART | AI_AGGRESSIVE | AI_CAUTIOUS | AI_STATUS_IMMUNE | AI_RISKY - db $44, $00 + dw AI_BASIC + AI_SETUP + AI_SMART + AI_AGGRESSIVE + AI_CAUTIOUS + AI_STATUS + AI_RISKY + dw CONTEXT_USE + SWITCH_SOMETIMES ; Karen db FULL_HEAL, MAX_POTION ; items db 25 ; base reward - dw AI_STATUS_RED | AI_STAT_MODS_RED | AI_SMART | AI_AGGRESSIVE | AI_CAUTIOUS | AI_STATUS_IMMUNE | AI_RISKY - db $44, $00 + dw AI_BASIC + AI_SETUP + AI_SMART + AI_AGGRESSIVE + AI_CAUTIOUS + AI_STATUS + AI_RISKY + dw CONTEXT_USE + SWITCH_SOMETIMES ; Koga db FULL_HEAL, FULL_RESTORE ; items db 25 ; base reward - dw AI_STATUS_RED | AI_STAT_MODS_RED | AI_SMART | AI_AGGRESSIVE | AI_CAUTIOUS | AI_STATUS_IMMUNE | AI_RISKY - db $44, $00 + dw AI_BASIC + AI_SETUP + AI_SMART + AI_AGGRESSIVE + AI_CAUTIOUS + AI_STATUS + AI_RISKY + dw CONTEXT_USE + SWITCH_SOMETIMES ; Champion db FULL_HEAL, FULL_RESTORE ; items db 25 ; base reward - dw AI_STATUS_RED | AI_STAT_MODS_RED | AI_SMART | AI_AGGRESSIVE | AI_CAUTIOUS | AI_STATUS_IMMUNE | AI_RISKY - db $44, $00 + dw AI_BASIC + AI_SETUP + AI_SMART + AI_AGGRESSIVE + AI_CAUTIOUS + AI_STATUS + AI_RISKY + dw CONTEXT_USE + SWITCH_SOMETIMES ; Brock db HYPER_POTION, NONE ; items db 25 ; base reward - dw AI_STATUS_RED | AI_STAT_MODS_RED | AI_SMART | AI_AGGRESSIVE | AI_CAUTIOUS | AI_STATUS_IMMUNE | AI_RISKY - db $44, $00 + dw AI_BASIC + AI_SETUP + AI_SMART + AI_AGGRESSIVE + AI_CAUTIOUS + AI_STATUS + AI_RISKY + dw CONTEXT_USE + SWITCH_SOMETIMES ; Misty db FULL_HEAL, NONE ; items db 25 ; base reward - dw AI_STATUS_RED | AI_STAT_MODS_RED | AI_SMART | AI_AGGRESSIVE | AI_CAUTIOUS | AI_STATUS_IMMUNE | AI_RISKY - db $44, $00 + dw AI_BASIC + AI_SETUP + AI_SMART + AI_AGGRESSIVE + AI_CAUTIOUS + AI_STATUS + AI_RISKY + dw CONTEXT_USE + SWITCH_SOMETIMES ; Lt Surge db HYPER_POTION, NONE ; items db 25 ; base reward - dw AI_STATUS_RED | AI_STAT_MODS_RED | AI_SMART | AI_AGGRESSIVE | AI_CAUTIOUS | AI_STATUS_IMMUNE | AI_RISKY - db $44, $00 + dw AI_BASIC + AI_SETUP + AI_SMART + AI_AGGRESSIVE + AI_CAUTIOUS + AI_STATUS + AI_RISKY + dw CONTEXT_USE + SWITCH_SOMETIMES ; Scientist db NONE, NONE ; items db 25 ; base reward - dw AI_STATUS_RED | AI_STAT_MODS_RED | AI_TYPES_RED | AI_STATUS_IMMUNE | AI_RISKY - db $44, $00 + dw AI_BASIC + AI_SETUP + AI_TYPES + AI_STATUS + AI_RISKY + dw CONTEXT_USE + SWITCH_SOMETIMES ; Erika db HYPER_POTION, NONE ; items db 25 ; base reward - dw AI_STATUS_RED | AI_STAT_MODS_RED | AI_SMART | AI_AGGRESSIVE | AI_CAUTIOUS | AI_STATUS_IMMUNE | AI_RISKY - db $44, $00 + dw AI_BASIC + AI_SETUP + AI_SMART + AI_AGGRESSIVE + AI_CAUTIOUS + AI_STATUS + AI_RISKY + dw CONTEXT_USE + SWITCH_SOMETIMES ; Youngster db NONE, NONE ; items db 4 ; base reward - dw AI_STATUS_RED | AI_STATUS_IMMUNE - db $44, $00 + dw AI_BASIC + AI_STATUS + dw CONTEXT_USE + SWITCH_SOMETIMES ; Schoolboy db NONE, NONE ; items db 8 ; base reward - dw AI_STATUS_RED | AI_STAT_MODS_RED | AI_TYPES_RED | AI_OPPORTUNIST | AI_CAUTIOUS | AI_STATUS_IMMUNE - db $41, $00 + dw AI_BASIC + AI_SETUP + AI_TYPES + AI_OPPORTUNIST + AI_CAUTIOUS + AI_STATUS + dw CONTEXT_USE + SWITCH_OFTEN ; Bird Keeper db NONE, NONE ; items db 6 ; base reward - dw AI_STATUS_RED | AI_TYPES_RED | AI_OFFENSIVE | AI_OPPORTUNIST | AI_STATUS_IMMUNE - db $44, $00 + dw AI_BASIC + AI_TYPES + AI_OFFENSIVE + AI_OPPORTUNIST + AI_STATUS + dw CONTEXT_USE + SWITCH_SOMETIMES ; Lass db NONE, NONE ; items db 6 ; base reward - dw AI_STATUS_RED | AI_CAUTIOUS | AI_STATUS_IMMUNE - db $41, $00 + dw AI_BASIC + AI_CAUTIOUS + AI_STATUS + dw CONTEXT_USE + SWITCH_OFTEN ; Janine db DIRE_HIT, NONE ; items db 25 ; base reward - dw AI_STATUS_RED | AI_STAT_MODS_RED | AI_SMART | AI_AGGRESSIVE | AI_CAUTIOUS | AI_STATUS_IMMUNE | AI_RISKY - db $44, $00 + dw AI_BASIC + AI_SETUP + AI_SMART + AI_AGGRESSIVE + AI_CAUTIOUS + AI_STATUS + AI_RISKY + dw CONTEXT_USE + SWITCH_SOMETIMES ; Cooltrainerm db NONE, NONE ; items db 12 ; base reward - dw AI_STATUS_RED | AI_STAT_MODS_RED | AI_SMART | AI_AGGRESSIVE | AI_CAUTIOUS | AI_STATUS_IMMUNE | AI_RISKY - db $44, $00 + dw AI_BASIC + AI_SETUP + AI_SMART + AI_AGGRESSIVE + AI_CAUTIOUS + AI_STATUS + AI_RISKY + dw CONTEXT_USE + SWITCH_SOMETIMES ; Cooltrainerf db NONE, NONE ; items db 12 ; base reward - dw AI_STATUS_RED | AI_STAT_MODS_RED | AI_SMART | AI_AGGRESSIVE | AI_CAUTIOUS | AI_STATUS_IMMUNE | AI_RISKY - db $44, $00 + dw AI_BASIC + AI_SETUP + AI_SMART + AI_AGGRESSIVE + AI_CAUTIOUS + AI_STATUS + AI_RISKY + dw CONTEXT_USE + SWITCH_SOMETIMES ; Beauty db NONE, NONE ; items db 22 ; base reward - dw AI_STATUS_RED | AI_TYPES_RED | AI_OPPORTUNIST | AI_CAUTIOUS | AI_STATUS_IMMUNE - db $44, $00 + dw AI_BASIC + AI_TYPES + AI_OPPORTUNIST + AI_CAUTIOUS + AI_STATUS + dw CONTEXT_USE + SWITCH_SOMETIMES ; Pokemaniac db NONE, NONE ; items db 15 ; base reward - dw AI_STATUS_RED | AI_STAT_MODS_RED | AI_OFFENSIVE | AI_AGGRESSIVE | AI_STATUS_IMMUNE - db $44, $00 + dw AI_BASIC + AI_SETUP + AI_OFFENSIVE + AI_AGGRESSIVE + AI_STATUS + dw CONTEXT_USE + SWITCH_SOMETIMES ; Gruntm db NONE, NONE ; items db 10 ; base reward - dw AI_STATUS_RED | AI_STAT_MODS_RED | AI_TYPES_RED | AI_OPPORTUNIST | AI_CAUTIOUS | AI_STATUS_IMMUNE | AI_RISKY - db $44, $00 + dw AI_BASIC + AI_SETUP + AI_TYPES + AI_OPPORTUNIST + AI_CAUTIOUS + AI_STATUS + AI_RISKY + dw CONTEXT_USE + SWITCH_SOMETIMES ; Gentleman db NONE, NONE ; items db 18 ; base reward - dw AI_STATUS_RED | AI_STAT_MODS_RED | AI_AGGRESSIVE | AI_STATUS_IMMUNE - db $44, $00 + dw AI_BASIC + AI_SETUP + AI_AGGRESSIVE + AI_STATUS + dw CONTEXT_USE + SWITCH_SOMETIMES ; Skier db NONE, NONE ; items db 18 ; base reward - dw AI_STATUS_RED | AI_STAT_MODS_RED | AI_TYPES_RED | AI_STATUS_IMMUNE | AI_RISKY - db $44, $00 + dw AI_BASIC + AI_SETUP + AI_TYPES + AI_STATUS + AI_RISKY + dw CONTEXT_USE + SWITCH_SOMETIMES ; Teacher db NONE, NONE ; items db 18 ; base reward - dw AI_STATUS_RED | AI_OPPORTUNIST | AI_AGGRESSIVE | AI_STATUS_IMMUNE - db $44, $00 + dw AI_BASIC + AI_OPPORTUNIST + AI_AGGRESSIVE + AI_STATUS + dw CONTEXT_USE + SWITCH_SOMETIMES ; Sabrina db HYPER_POTION, NONE ; items db 25 ; base reward - dw AI_STATUS_RED | AI_STAT_MODS_RED | AI_SMART | AI_AGGRESSIVE | AI_CAUTIOUS | AI_STATUS_IMMUNE | AI_RISKY - db $44, $00 + dw AI_BASIC + AI_SETUP + AI_SMART + AI_AGGRESSIVE + AI_CAUTIOUS + AI_STATUS + AI_RISKY + dw CONTEXT_USE + SWITCH_SOMETIMES ; Bug Catcher db NONE, NONE ; items db 4 ; base reward - dw AI_STATUS_RED | AI_STAT_MODS_RED | AI_STATUS_IMMUNE - db $44, $00 + dw AI_BASIC + AI_SETUP + AI_STATUS + dw CONTEXT_USE + SWITCH_SOMETIMES ; Fisher db NONE, NONE ; items db 10 ; base reward - dw AI_STATUS_RED | AI_TYPES_RED | AI_OPPORTUNIST | AI_CAUTIOUS | AI_STATUS_IMMUNE - db $41, $00 + dw AI_BASIC + AI_TYPES + AI_OPPORTUNIST + AI_CAUTIOUS + AI_STATUS + dw CONTEXT_USE + SWITCH_OFTEN ; Swimmerm db NONE, NONE ; items db 2 ; base reward - dw AI_STATUS_RED | AI_STAT_MODS_RED | AI_TYPES_RED | AI_OFFENSIVE | AI_STATUS_IMMUNE - db $44, $00 + dw AI_BASIC + AI_SETUP + AI_TYPES + AI_OFFENSIVE + AI_STATUS + dw CONTEXT_USE + SWITCH_SOMETIMES ; Swimmerf db NONE, NONE ; items db 5 ; base reward - dw AI_STATUS_RED | AI_STAT_MODS_RED | AI_TYPES_RED | AI_CAUTIOUS | AI_STATUS_IMMUNE - db $44, $00 + dw AI_BASIC + AI_SETUP + AI_TYPES + AI_CAUTIOUS + AI_STATUS + dw CONTEXT_USE + SWITCH_SOMETIMES ; Sailor db NONE, NONE ; items db 10 ; base reward - dw AI_STATUS_RED | AI_OFFENSIVE | AI_OPPORTUNIST | AI_STATUS_IMMUNE - db $44, $00 + dw AI_BASIC + AI_OFFENSIVE + AI_OPPORTUNIST + AI_STATUS + dw CONTEXT_USE + SWITCH_SOMETIMES ; Super Nerd db NONE, NONE ; items db 8 ; base reward - dw AI_STATUS_RED | AI_TYPES_RED | AI_SMART | AI_STATUS_IMMUNE - db $44, $00 + dw AI_BASIC + AI_TYPES + AI_SMART + AI_STATUS + dw CONTEXT_USE + SWITCH_SOMETIMES ; Rival2 db NONE, NONE ; items db 25 ; base reward - dw AI_STATUS_RED | AI_STAT_MODS_RED | AI_SMART | AI_AGGRESSIVE | AI_CAUTIOUS | AI_STATUS_IMMUNE | AI_RISKY - db $44, $00 + dw AI_BASIC + AI_SETUP + AI_SMART + AI_AGGRESSIVE + AI_CAUTIOUS + AI_STATUS + AI_RISKY + dw CONTEXT_USE + SWITCH_SOMETIMES ; Guitarist db NONE, NONE ; items db 8 ; base reward - dw AI_STATUS_RED | AI_STAT_MODS_RED | AI_TYPES_RED | AI_CAUTIOUS | AI_STATUS_IMMUNE - db $44, $00 + dw AI_BASIC + AI_SETUP + AI_TYPES + AI_CAUTIOUS + AI_STATUS + dw CONTEXT_USE + SWITCH_SOMETIMES ; Hiker db NONE, NONE ; items db 8 ; base reward - dw AI_STATUS_RED | AI_OFFENSIVE | AI_STATUS_IMMUNE - db $44, $00 + dw AI_BASIC + AI_OFFENSIVE + AI_STATUS + dw CONTEXT_USE + SWITCH_SOMETIMES ; Biker db NONE, NONE ; items db 8 ; base reward - dw AI_STATUS_RED | AI_TYPES_RED | AI_STATUS_IMMUNE | AI_RISKY - db $44, $00 + dw AI_BASIC + AI_TYPES + AI_STATUS + AI_RISKY + dw CONTEXT_USE + SWITCH_SOMETIMES ; Blaine db MAX_POTION, FULL_HEAL ; items db 25 ; base reward - dw AI_STATUS_RED | AI_STAT_MODS_RED | AI_SMART | AI_AGGRESSIVE | AI_CAUTIOUS | AI_STATUS_IMMUNE | AI_RISKY - db $44, $00 + dw AI_BASIC + AI_SETUP + AI_SMART + AI_AGGRESSIVE + AI_CAUTIOUS + AI_STATUS + AI_RISKY + dw CONTEXT_USE + SWITCH_SOMETIMES ; Burglar db NONE, NONE ; items db 22 ; base reward - dw AI_STATUS_RED | AI_OFFENSIVE | AI_CAUTIOUS | AI_STATUS_IMMUNE - db $44, $00 + dw AI_BASIC + AI_OFFENSIVE + AI_CAUTIOUS + AI_STATUS + dw CONTEXT_USE + SWITCH_SOMETIMES ; Firebreather db NONE, NONE ; items db 12 ; base reward - dw AI_STATUS_RED | AI_STAT_MODS_RED | AI_OFFENSIVE | AI_OPPORTUNIST | AI_STATUS_IMMUNE - db $44, $00 + dw AI_BASIC + AI_SETUP + AI_OFFENSIVE + AI_OPPORTUNIST + AI_STATUS + dw CONTEXT_USE + SWITCH_SOMETIMES ; Juggler db NONE, NONE ; items db 10 ; base reward - dw AI_STATUS_RED | AI_TYPES_RED | AI_SMART | AI_STATUS_IMMUNE - db $44, $00 + dw AI_BASIC + AI_TYPES + AI_SMART + AI_STATUS + dw CONTEXT_USE + SWITCH_SOMETIMES ; Blackbelt T db NONE, NONE ; items db 6 ; base reward - dw AI_STATUS_RED | AI_OFFENSIVE | AI_STATUS_IMMUNE | AI_RISKY - db $44, $00 + dw AI_BASIC + AI_OFFENSIVE + AI_STATUS + AI_RISKY + dw CONTEXT_USE + SWITCH_SOMETIMES ; Executivem db NONE, NONE ; items db 18 ; base reward - dw AI_STATUS_RED | AI_STAT_MODS_RED | AI_TYPES_RED | AI_SMART | AI_OPPORTUNIST | AI_CAUTIOUS | AI_STATUS_IMMUNE | AI_RISKY - db $44, $00 + dw AI_BASIC + AI_SETUP + AI_TYPES + AI_SMART + AI_OPPORTUNIST + AI_CAUTIOUS + AI_STATUS + AI_RISKY + dw CONTEXT_USE + SWITCH_SOMETIMES ; Psychic T db NONE, NONE ; items db 8 ; base reward - dw AI_STATUS_RED | AI_TYPES_RED | AI_OPPORTUNIST | AI_CAUTIOUS | AI_STATUS_IMMUNE - db $44, $00 + dw AI_BASIC + AI_TYPES + AI_OPPORTUNIST + AI_CAUTIOUS + AI_STATUS + dw CONTEXT_USE + SWITCH_SOMETIMES ; Picnicker db NONE, NONE ; items db 5 ; base reward - dw AI_STATUS_RED | AI_CAUTIOUS | AI_STATUS_IMMUNE - db $44, $00 + dw AI_BASIC + AI_CAUTIOUS + AI_STATUS + dw CONTEXT_USE + SWITCH_SOMETIMES ; Camper db NONE, NONE ; items db 5 ; base reward - dw AI_STATUS_RED | AI_CAUTIOUS | AI_STATUS_IMMUNE - db $44, $00 + dw AI_BASIC + AI_CAUTIOUS + AI_STATUS + dw CONTEXT_USE + SWITCH_SOMETIMES ; Executivef db NONE, NONE ; items db 18 ; base reward - dw AI_STATUS_RED | AI_STAT_MODS_RED | AI_TYPES_RED | AI_SMART | AI_OPPORTUNIST | AI_CAUTIOUS | AI_STATUS_IMMUNE | AI_RISKY - db $44, $00 + dw AI_BASIC + AI_SETUP + AI_TYPES + AI_SMART + AI_OPPORTUNIST + AI_CAUTIOUS + AI_STATUS + AI_RISKY + dw CONTEXT_USE + SWITCH_SOMETIMES ; Sage db NONE, NONE ; items db 8 ; base reward - dw AI_STATUS_RED | AI_STAT_MODS_RED | AI_TYPES_RED | AI_CAUTIOUS | AI_STATUS_IMMUNE | AI_RISKY - db $44, $00 + dw AI_BASIC + AI_SETUP + AI_TYPES + AI_CAUTIOUS + AI_STATUS + AI_RISKY + dw CONTEXT_USE + SWITCH_SOMETIMES ; Medium db NONE, NONE ; items db 10 ; base reward - dw AI_STATUS_RED | AI_STAT_MODS_RED | AI_TYPES_RED | AI_CAUTIOUS | AI_STATUS_IMMUNE | AI_RISKY - db $44, $00 + dw AI_BASIC + AI_SETUP + AI_TYPES + AI_CAUTIOUS + AI_STATUS + AI_RISKY + dw CONTEXT_USE + SWITCH_SOMETIMES ; Boarder db NONE, NONE ; items db 18 ; base reward - dw AI_STATUS_RED | AI_TYPES_RED | AI_OPPORTUNIST | AI_STATUS_IMMUNE - db $44, $00 + dw AI_BASIC + AI_TYPES + AI_OPPORTUNIST + AI_STATUS + dw CONTEXT_USE + SWITCH_SOMETIMES ; Pokefanm db NONE, NONE ; items db 20 ; base reward - dw AI_STATUS_RED | AI_TYPES_RED | AI_SMART | AI_STATUS_IMMUNE - db $44, $00 + dw AI_BASIC + AI_TYPES + AI_SMART + AI_STATUS + dw CONTEXT_USE + SWITCH_SOMETIMES ; Kimono Girl db NONE, NONE ; items db 18 ; base reward - dw AI_STATUS_RED | AI_TYPES_RED | AI_OPPORTUNIST | AI_CAUTIOUS | AI_STATUS_IMMUNE - db $44, $00 + dw AI_BASIC + AI_TYPES + AI_OPPORTUNIST + AI_CAUTIOUS + AI_STATUS + dw CONTEXT_USE + SWITCH_SOMETIMES ; Twins db NONE, NONE ; items db 5 ; base reward - dw NONE - db $41, $00 + dw NO_AI + dw CONTEXT_USE + SWITCH_OFTEN ; Pokefanf db NONE, NONE ; items db 20 ; base reward - dw AI_STATUS_RED | AI_TYPES_RED | AI_SMART | AI_STATUS_IMMUNE - db $44, $00 + dw AI_BASIC + AI_TYPES + AI_SMART + AI_STATUS + dw CONTEXT_USE + SWITCH_SOMETIMES ; Red db FULL_RESTORE, FULL_RESTORE ; items db 25 ; base reward - dw AI_STATUS_RED | AI_STAT_MODS_RED | AI_SMART | AI_AGGRESSIVE | AI_CAUTIOUS | AI_STATUS_IMMUNE | AI_RISKY - db $44, $00 + dw AI_BASIC + AI_SETUP + AI_SMART + AI_AGGRESSIVE + AI_CAUTIOUS + AI_STATUS + AI_RISKY + dw CONTEXT_USE + SWITCH_SOMETIMES ; Blue db FULL_RESTORE, FULL_RESTORE ; items db 25 ; base reward - dw AI_STATUS_RED | AI_STAT_MODS_RED | AI_SMART | AI_AGGRESSIVE | AI_CAUTIOUS | AI_STATUS_IMMUNE | AI_RISKY - db $44, $00 + dw AI_BASIC + AI_SETUP + AI_SMART + AI_AGGRESSIVE + AI_CAUTIOUS + AI_STATUS + AI_RISKY + dw CONTEXT_USE + SWITCH_SOMETIMES ; Officer db NONE, NONE ; items db 10 ; base reward - dw AI_STATUS_RED | AI_TYPES_RED | AI_OPPORTUNIST | AI_STATUS_IMMUNE - db $44, $00 + dw AI_BASIC + AI_TYPES + AI_OPPORTUNIST + AI_STATUS + dw CONTEXT_USE + SWITCH_SOMETIMES ; Gruntf db NONE, NONE ; items db 10 ; base reward - dw AI_STATUS_RED | AI_TYPES_RED | AI_OPPORTUNIST | AI_CAUTIOUS | AI_STATUS_IMMUNE | AI_RISKY - db $44, $00 + dw AI_BASIC + AI_TYPES + AI_OPPORTUNIST + AI_CAUTIOUS + AI_STATUS + AI_RISKY + dw CONTEXT_USE + SWITCH_SOMETIMES ; Mysticalman db NONE, NONE ; items db 25 ; base reward - dw AI_STATUS_RED | AI_STAT_MODS_RED | AI_SMART | AI_AGGRESSIVE | AI_CAUTIOUS | AI_STATUS_IMMUNE | AI_RISKY - db $44, $00 + dw AI_BASIC + AI_SETUP + AI_SMART + AI_AGGRESSIVE + AI_CAUTIOUS + AI_STATUS + AI_RISKY + dw CONTEXT_USE + SWITCH_SOMETIMES ; 39771 @@ -116,26 +116,29 @@ channel_struct: MACRO ds 1 ; c132 ENDM -SECTION "tiles0",VRAM[$8000],BANK[0] + + +SECTION "CHR0", VRAM [$8000], BANK [0] VTiles0:: -SECTION "tiles1",VRAM[$8800],BANK[0] +SECTION "CHR1", VRAM [$8800], BANK [0] VTiles1:: -SECTION "tiles2",VRAM[$9000],BANK[0] +SECTION "CHR2", VRAM [$9000], BANK [0] VTiles2:: -SECTION "bgmap0",VRAM[$9800],BANK[0] +SECTION "BG0", VRAM [$9800], BANK [0] VBGMap0:: -SECTION "bgmap1",VRAM[$9C00],BANK[0] +SECTION "BG1", VRAM [$9C00], BANK [0] VBGMap1:: -SECTION "WRAMBank0",WRAM0[$c000] +SECTION "Stack", WRAM0 + ds $ff +Stack:: + ds 1 -SECTION "stack",WRAM0[$c0ff] -Stack:: ds -$100 ; c0ff +SECTION "Audio", WRAM0 -SECTION "audio",WRAM0[$c100] MusicPlaying:: ; c100 ; nonzero if playing ds 1 @@ -249,6 +252,9 @@ wMapMusic:: ; c2c0 ds 1 + +SECTION "WRAM", WRAM0 + wLZAddress:: dw ; c2c2 wLZBank:: db ; c2c4 @@ -274,8 +280,8 @@ InLinkBattle:: ; c2dc ScriptVar:: ; c2dd ds 1 + ds 28 -SECTION "tiles",WRAM0[$c2fa] TileDown:: ; c2fa ds 1 TileUp:: ; c2fb @@ -294,19 +300,22 @@ TilePermissions:: ; c2fe ; bit 0: right ds 1 -SECTION "icons",WRAM0[$c3b6] + ds 183 CurIcon:: ; c3b6 ds 1 -SECTION "gfx",WRAM0[$c400] + ds 73 + + +SECTION "Sprites", WRAM0 [$c400] Sprites:: ; c400 ; 4 bytes per sprite ; 40 sprites ; struct: -; y in pixels -; x in pixels +; y (px) +; x (px) ; tile id ; attributes: ; bit 7: priority @@ -318,12 +327,17 @@ Sprites:: ; c400 ds 4 * 40 SpritesEnd:: + +SECTION "Tilemap", WRAM0 + TileMap:: ; c4a0 ; 20x18 grid of 8x8 tiles ds SCREEN_WIDTH * SCREEN_HEIGHT TileMapEnd:: +SECTION "Battle", WRAM0 + wBattle:: wEnemyMoveStruct:: ds MOVE_LENGTH ; c608 @@ -333,16 +347,16 @@ EnemyMonNick:: ds PKMN_NAME_LENGTH ; c616 BattleMonNick:: ds PKMN_NAME_LENGTH ; c621 BattleMon:: battle_struct BattleMon ; c62c + ds 10 -OTName:: ; c656 - ds NAME_LENGTH +OTName:: ds NAME_LENGTH ; c656 ds 2 CurOTMon:: ; c663 ds 1 - + ds 1 TypeModifier:: ; c665 @@ -355,11 +369,11 @@ TypeModifier:: ; c665 CriticalHit:: ; c666 ; nonzero for a critical hit ds 1 - + AttackMissed:: ; c667 ; nonzero for a miss ds 1 - + PlayerSubStatus1:: ; c668 ; bit ; 7 attract @@ -472,7 +486,7 @@ EnemyDamageTaken:: ; c684 ds 2 ds 3 - + ds 1 BattleScriptBuffer:: ; c68a @@ -584,7 +598,7 @@ AlreadyFailed:: ; c6fb ds 1 ds 3 - + PlayerScreens:: ; c6ff ; bit ; 4 reflect @@ -662,21 +676,25 @@ BattleEnded:: ; c734 wBattleEnd:: ; c741 -SECTION "overworldmap",WRAM0[$c800] + ds 191 + + +SECTION "Overworld Map", WRAM0 [$c800] OverworldMap:: ; c800 ds 1300 OverworldMapEnd:: - + ds 12 -SECTION "gfx2",WRAM0[$cd20] + +SECTION "Video", WRAM0 [$cd20] CreditsPos:: BGMapBuffer:: ; cd20 ds 2 CreditsTimer:: ; cd22 ds 1 ds 37 - + BGMapPalBuffer:: ; cd48 ds 40 @@ -690,7 +708,7 @@ PlayerHPPal:: ; cd99 ds 1 EnemyHPPal:: ; cd9a ds 1 - + ds 62 AttrMap:: ; cdd9 @@ -702,7 +720,7 @@ AttrMap:: ; cdd9 AttrMapEnd:: ds 30 - + MonType:: ; cf5f ds 1 @@ -730,9 +748,8 @@ Requested1bppDest:: ; cf6f MenuSelection:: ; cf74 ds 1 + ds 60 - -SECTION "VBlank",WRAM0[$cfb1] OverworldDelay:: ; cfb1 ds 1 TextDelayFrames:: ; cfb2 @@ -753,7 +770,8 @@ GameTimerPause:: ; cfbc ; bit 0 ds 1 -SECTION "Engine",WRAM0[$cfc2] + ds 5 + FXAnimID:: FXAnimIDLo:: ; cfc2 ds 1 @@ -776,13 +794,13 @@ Options:: ; cfcc ; bit 6: battle style shift/set ; bit 7: battle scene off/on ds 1 - + ds 1 TextBoxFrame:: ; cfce ; bits 0-2: textbox frame 0-7 ds 1 - + ds 1 GBPrinter:: ; cfd0 @@ -799,12 +817,12 @@ Options2:: ; cfd1 ds 1 ds 46 - -SECTION "WRAMBank1",WRAMX[$d000],BANK[1] + +SECTION "WRAM 1", WRAMX, BANK [1] ds 2 - + DefaultFlypoint:: ; d002 ds 1 ; d003 @@ -888,7 +906,7 @@ CurItem:: ; d106 ds 1 ds 1 - + CurPartySpecies:: ; d108 ds 1 @@ -912,14 +930,14 @@ PartyMenuActionText:: ; d141 CurPartyLevel:: ; d143 ds 1 + ds 16 -SECTION "UsedSprites",WRAMX[$d154],BANK[1] UsedSprites:: ; d154 ds 32 -SECTION "map",WRAMX[$d19d],BANK[1] + ds 41 -; both are in blocks (2x2 walkable tiles, 4x4 graphics tiles) +; width/height are in blocks (2x2 walkable tiles, 4x4 graphics tiles) MapHeader:: ; d19d MapBorderBlock:: ; d19d ds 1 @@ -1043,6 +1061,7 @@ TilesetPalettes:: ; d1e6 ; bank 3f ds 2 + EvolvableFlags:: ; d1e8 flag_array PARTY_LENGTH @@ -1055,7 +1074,9 @@ MovementType:: Buffer2:: ; d1eb ds 1 -SECTION "BattleMons2",WRAMX[$d1fa],BANK[1] + ds 14 + + LinkBattleRNs:: ; d1fa ds 10 @@ -1074,7 +1095,7 @@ IsInBattle:: ; d22d ; 1: wild battle ; 2: trainer battle ds 1 - + ds 1 OtherTrainerClass:: ; d22f @@ -1163,14 +1184,15 @@ BaseTMHM:: ; d24e CurDamage:: ; d256 ds 2 - -SECTION "TimeOfDay",WRAMX[$d269],BANK[1] + ds 17 TimeOfDay:: ; d269 ds 1 + ds 22 -SECTION "OTParty",WRAMX[$d280],BANK[1] + +SECTION "Enemy Party", WRAMX, BANK [1] OTPartyCount:: ds 1 ; d280 OTPartySpecies:: ds PARTY_LENGTH ; d281 @@ -1220,7 +1242,8 @@ ScriptPos:: ; d43a ScriptDelay:: ; d44d ds 1 -SECTION "Player",WRAMX[$d472],BANK[1] + ds 36 + PlayerGender:: ; d472 ; bit 0: ; 0 male @@ -1346,17 +1369,18 @@ ObjectStruct12:: ; d6b6 ds 40 ; d6de -SECTION "Objects",WRAMX[$d71e],BANK[1] + ds 64 + MapObjects:: ; d71e ds OBJECT_LENGTH * NUM_OBJECTS + ds 16 -SECTION "VariableSprites",WRAMX[$d82e],BANK[1] VariableSprites:: ; d82e ds $10 + ds 3 -SECTION "Status",WRAMX[$d841],BANK[1] TimeOfDayPal:: ; d841 ds 1 ds 4 @@ -1365,7 +1389,7 @@ TimeOfDayPal:: ; d841 ds 1 CurTimeOfDay:: ; d848 ds 1 - + ds 3 StatusFlags:: ; d84c @@ -1383,42 +1407,42 @@ wMomSavingMoney:: ; d854 Coins:: ; d855 ds 2 - + Badges:: JohtoBadges:: ; d857 flag_array 8 KantoBadges:: ; d858 flag_array 8 - -SECTION "Items",WRAMX[$d859],BANK[1] + + TMsHMs:: ; d859 - ds 57 + ds NUM_TMS + NUM_HMS TMsHMsEnd:: NumItems:: ; d892 ds 1 Items:: ; d893 - ds 41 + ds MAX_ITEMS * 2 + 1 ItemsEnd:: NumKeyItems:: ; d8bc ds 1 KeyItems:: ; d8bd - ds 26 + ds MAX_KEY_ITEMS + 1 KeyItemsEnd:: NumBalls:: ; d8d7 ds 1 Balls:: ; d8d8 - ds 25 + ds MAX_BALLS * 2 + 1 BallsEnd:: PCItems:: ; d8f1 - ds 101 + ds MAX_PC_ITEMS * 2 + 1 PCItemsEnd:: + ds 5 -SECTION "overworld",WRAMX[$d95b],BANK[1] WhichRegisteredItem:: ; d95b ds 1 RegisteredItem:: ; d95c @@ -1427,7 +1451,8 @@ RegisteredItem:: ; d95c PlayerState:: ; d95d ds 1 -SECTION "scriptram",WRAMX[$d962],BANK[1] + ds 4 + MooMooBerries:: ; d962 ds 1 ; how many berries fed to MooMoo UndergroundSwitchPositions:: ; d963 @@ -1435,7 +1460,10 @@ UndergroundSwitchPositions:: ; d963 FarfetchdPosition:: ; d964 ds 1 ; which position the ilex farfetch'd is in -SECTION "Map Triggers", WRAMX[$d972], BANK[1] + ds 13 + + +SECTION "Map Triggers", WRAMX, BANK [1] wPokecenter2FTrigger:: ds 1 ; d972 wTradeCenterTrigger:: ds 1 ; d973 @@ -1517,8 +1545,12 @@ wMountMoonSquareTrigger:: ds 1 ; d9be wMobileTradeRoomMobileTrigger:: ds 1 ; d9bf wMobileBattleRoomTrigger:: ds 1 ; d9c0 + ds 49 -SECTION "Events",WRAMX[$da72],BANK[1] + +SECTION "Events", WRAMX, BANK [1] + + ds 128 EventFlags:: ; da72 ;RoomDecorations:: ; dac6 @@ -1529,7 +1561,7 @@ EventFlags:: ; da72 flag_array 2000 ; db6c -SECTION "Boxes",WRAMX[$db72],BANK[1] + ds 6 wCurBox:: ; db72 ds 1 @@ -1539,13 +1571,15 @@ wCurBox:: ; db72 ; 8 chars + $50 wBoxNames:: ds 9 * NUM_BOXES ; db75 -SECTION "bike", WRAMX[$dbf5],BANK[1] + ds 2 + BikeFlags:: ; dbf5 ; bit 1: always on bike ; bit 2: downhill ds 1 -SECTION "decorations", WRAMX[$dc0f],BANK[1] + ds 25 + ; Sprite id of each decoration Bed:: ; dc0f ds 1 @@ -1564,21 +1598,24 @@ RightOrnament:: ; dc15 BigDoll:: ; dc16 ds 1 -SECTION "fruittrees", WRAMX[$dc27],BANK[1] + ds 16 + FruitTreeFlags:: ; dc27 ds 1 -SECTION "steps", WRAMX[$dc73],BANK[1] + ds 75 + StepCount:: ; dc73 ds 1 PoisonStepCount:: ; dc74 ds 1 -SECTION "Visited Spawn Points", WRAMX[$dca5],BANK[1] + ds 48 + VisitedSpawns:: ; dca5 flag_array 27 -SECTION "BackupMapInfo", WRAMX[$dcad],BANK[1] + ds 4 ; used on maps like second floor pokécenter, which are reused, so we know which ; map to return to @@ -1587,7 +1624,7 @@ BackupMapGroup:: ; dcad BackupMapNumber:: ; dcae ds 1 -SECTION "PlayerMapInfo", WRAMX[$dcb4],BANK[1] + ds 5 WarpNumber:: ; dcb4 ds 1 @@ -1600,7 +1637,10 @@ YCoord:: ; dcb7 XCoord:: ; dcb8 ds 1 ; current x coordinate relative to top-left corner of current map -SECTION "PlayerParty",WRAMX[$dcd7],BANK[1] + ds 30 + + +SECTION "Party", WRAMX, BANK [1] PartyCount:: ; dcd7 ds 1 ; number of Pokémon in party @@ -1623,7 +1663,10 @@ PartyMonNicknames:: ds PKMN_NAME_LENGTH * PARTY_LENGTH ; de41 PartyMonNicknamesEnd:: -SECTION "Pokedex", WRAMX[$de99], BANK[1] + ds 22 + + +SECTION "Pokedex", WRAMX, BANK [1] PokedexCaught:: ; de99 flag_array NUM_POKEMON @@ -1640,6 +1683,9 @@ UnlockedUnowns:: ; def3 ds 1 + +SECTION "Daycare", WRAMX, BANK [1] + wDaycareMan:: ; def5 ; bit 7: active ; bit 6: monsters are compatible @@ -1675,6 +1721,9 @@ wEggMon:: box_struct wEggMon ; df7b ds 1 + +SECTION "Misc Pokemon", WRAMX, BANK [1] + wContestMon:: party_struct wContestMon ; df9c ds 3 @@ -1694,7 +1743,7 @@ wRoamMon3:: roam_struct wRoamMon3 ; dfdd -SECTION "WRAMBank5",WRAMX[$d000],BANK[5] +SECTION "GBC Video", WRAMX, BANK [5] ; 8 4-color palettes Unkn1Pals:: ds 8 * 8 ; d000 @@ -1706,14 +1755,18 @@ LYOverrides:: ; d100 ds SCREEN_HEIGHT_PX LYOverridesEnd:: - ds 112 + ds $100 - SCREEN_HEIGHT_PX LYOverridesBackup:: ; d200 ds SCREEN_HEIGHT_PX LYOverridesBackupEnd:: + ds $100 - SCREEN_HEIGHT_PX + -SECTION "Battle Animations", WRAMX[$d30a], BANK[5] +SECTION "Battle Animations", WRAMX, BANK [5] + + ds 10 ActiveAnimObjects:: ; d30a ds 4 * 40 @@ -1744,12 +1797,12 @@ BattleAnimTemps:: ; d419 ds 8 -SECTION "Scratch", SRAM, BANK[0] +SECTION "Scratch", SRAM, BANK [0] -SECTION "SRAM Bank 1", SRAM, BANK[1] +SECTION "SRAM Bank 1", SRAM, BANK [1] -SECTION "BoxMons", SRAM[$ad10], BANK[1] +SECTION "BoxMons", SRAM [$ad10], BANK [1] sBoxCount:: ds 1 ; ad10 sBoxSpecies:: ds MONS_PER_BOX ; ad11 |