diff options
Diffstat (limited to 'engine')
190 files changed, 7759 insertions, 4904 deletions
diff --git a/engine/battle/ai/items.asm b/engine/battle/ai/items.asm index 09595077a..5bdc070ec 100644 --- a/engine/battle/ai/items.asm +++ b/engine/battle/ai/items.asm @@ -291,7 +291,7 @@ AI_Items: ; 39196 dbw X_DEFEND, .XDefend dbw X_SPEED, .XSpeed dbw X_SPECIAL, .XSpecial - db $ff + db -1 ; end ; 381be .FullHeal: ; 381be @@ -545,7 +545,7 @@ AI_Items: ; 39196 AIUpdateHUD: ; 38387 call UpdateEnemyMonInParty - farcall UpdateEnemyHUD + farcall Predef_UpdateEnemyHUD ld a, $1 ld [hBGMapMode], a ld hl, wEnemyItemState @@ -664,7 +664,7 @@ EnemyPotionFinish: ; 38436 xor a ld [wWhichHPBar], a call AIUsedItemSound - predef AnimateHPBar + predef Predef_AnimateHPBar jp AIUpdateHUD diff --git a/engine/battle/ai/move.asm b/engine/battle/ai/move.asm index 11586c0da..d04fb9930 100755 --- a/engine/battle/ai/move.asm +++ b/engine/battle/ai/move.asm @@ -56,7 +56,7 @@ AIChooseMove: ; 440ce inc hl ld a, [de] inc de - and $3f + and PP_MASK jr nz, .CheckMovePP ld [hl], 80 jr .CheckMovePP @@ -92,7 +92,7 @@ AIChooseMove: ; 440ce push bc ld d, BANK(TrainerClassAttributes) - predef FlagPredef + predef Predef_SmallFarFlagAction ld d, c pop bc @@ -186,7 +186,7 @@ AIChooseMove: ; 440ce .ChooseMove: ld hl, Buffer1 call Random - and 3 + maskbits NUM_MOVES +- 1 ld c, a ld b, 0 add hl, bc diff --git a/engine/battle/ai/scoring.asm b/engine/battle/ai/scoring.asm index 44194d6f7..c1d175c38 100644 --- a/engine/battle/ai/scoring.asm +++ b/engine/battle/ai/scoring.asm @@ -68,7 +68,7 @@ AI_Basic: ; 38591 db EFFECT_TOXIC db EFFECT_POISON db EFFECT_PARALYZE - db $ff + db -1 ; end ; 385e0 @@ -400,7 +400,7 @@ AI_Smart: ; 386be dbw EFFECT_SOLARBEAM, AI_Smart_Solarbeam dbw EFFECT_THUNDER, AI_Smart_Thunder dbw EFFECT_FLY, AI_Smart_Fly - db $ff + db -1 ; end ; 387e3 @@ -1488,7 +1488,7 @@ AI_Smart_Encore: ; 38c3b push hl ld a, [wEnemyMoveStruct + MOVE_TYPE] ld hl, EnemyMonType1 - predef CheckTypeMatchup + predef Predef_CheckTypeMatchup pop hl ld a, [wd265] @@ -1553,7 +1553,7 @@ AI_Smart_Encore: ; 38c3b db AEROBLAST db COTTON_SPORE db POWDER_SNOW - db $ff + db -1 ; end ; 38ca4 @@ -2214,7 +2214,7 @@ AI_Smart_Sandstorm: ; 38f7a db ROCK db GROUND db STEEL - db $ff + db -1 ; end ; 38fac @@ -2533,7 +2533,7 @@ RainDanceMoves: ; 390e7 db CRABHAMMER db OCTAZOOKA db WHIRLPOOL - db $ff + db -1 ; end ; 390f3 @@ -2622,7 +2622,7 @@ SunnyDayMoves: ; 39134 db SACRED_FIRE db MORNING_SUN db SYNTHESIS - db $ff + db -1 ; end ; 3913d @@ -3125,7 +3125,7 @@ UsefulMoves: ; 39301 db FIRE_BLAST db SOFTBOILED db SUPER_FANG - db $ff + db -1 ; end ; 39315 @@ -3209,7 +3209,7 @@ AI_Opportunist: ; 39315 db CONVERSION db SUBSTITUTE db FLAME_WHEEL - db $ff + db -1 ; end ; 39369 @@ -3324,7 +3324,7 @@ AI_Aggressive: ; 39369 db EFFECT_RAMPAGE db EFFECT_MULTI_HIT db EFFECT_DOUBLE_HIT - db $ff + db -1 ; end ; 393e7 @@ -3350,7 +3350,7 @@ AIDamageCalc: ; 393e7 db EFFECT_STATIC_DAMAGE db EFFECT_LEVEL_DAMAGE db EFFECT_PSYWAVE - db $ff + db -1 ; end ; 39418 @@ -3406,7 +3406,7 @@ AI_Cautious: ; 39418 db CONVERSION db SUBSTITUTE db SPIKES - db $ff + db -1 ; end ; 39453 @@ -3544,7 +3544,7 @@ endr .RiskyMoves: db EFFECT_SELFDESTRUCT db EFFECT_OHKO - db $ff + db -1 ; end ; 39502 diff --git a/engine/battle/ai/switch.asm b/engine/battle/ai/switch.asm index c2f83fa1f..cb278676e 100755 --- a/engine/battle/ai/switch.asm +++ b/engine/battle/ai/switch.asm @@ -28,7 +28,7 @@ CheckPlayerMoveTypeMatchups: ; 3484e inc hl call GetMoveByte ld hl, EnemyMonType - call CheckTypeMatchup + call Predef_CheckTypeMatchup ld a, [wTypeMatchup] cp 10 + 1 ; 1.0 + 0.1 jr nc, .super_effective @@ -73,7 +73,7 @@ CheckPlayerMoveTypeMatchups: ; 3484e ld a, [BattleMonType1] ld b, a ld hl, EnemyMonType1 - call CheckTypeMatchup + call Predef_CheckTypeMatchup ld a, [wTypeMatchup] cp 10 + 1 ; 1.0 + 0.1 jr c, .ok @@ -82,7 +82,7 @@ CheckPlayerMoveTypeMatchups: ; 3484e ld a, [BattleMonType2] cp b jr z, .ok2 - call CheckTypeMatchup + call Predef_CheckTypeMatchup ld a, [wTypeMatchup] cp 10 + 1 ; 1.0 + 0.1 jr c, .ok2 @@ -123,7 +123,7 @@ CheckPlayerMoveTypeMatchups: ; 3484e inc hl call GetMoveByte ld hl, BattleMonType1 - call CheckTypeMatchup + call Predef_CheckTypeMatchup ld a, [wTypeMatchup] ; immune @@ -390,7 +390,7 @@ FindEnemyMonsImmuneToLastCounterMove: ; 34a2a inc hl call GetMoveByte ld hl, BaseType - call CheckTypeMatchup + call Predef_CheckTypeMatchup ld a, [wTypeMatchup] and a jr nz, .next @@ -481,7 +481,7 @@ FindEnemyMonsWithASuperEffectiveMove: ; 34aa7 inc hl call GetMoveByte ld hl, BattleMonType1 - call CheckTypeMatchup + call Predef_CheckTypeMatchup ; if immune or not very effective: continue ld a, [wTypeMatchup] @@ -585,7 +585,7 @@ FindEnemyMonsThatResistPlayer: ; 34b20 .skip_move ld a, [BattleMonType1] ld hl, BaseType - call CheckTypeMatchup + call Predef_CheckTypeMatchup ld a, [wTypeMatchup] cp 10 + 1 jr nc, .dont_choose_mon @@ -593,7 +593,7 @@ FindEnemyMonsThatResistPlayer: ; 34b20 .check_type ld hl, BaseType - call CheckTypeMatchup + call Predef_CheckTypeMatchup ld a, [wTypeMatchup] cp 10 + 1 jr nc, .dont_choose_mon diff --git a/engine/battle/anim_hp_bar.asm b/engine/battle/anim_hp_bar.asm index 71276d27e..d67a46a70 100755 --- a/engine/battle/anim_hp_bar.asm +++ b/engine/battle/anim_hp_bar.asm @@ -67,7 +67,7 @@ _AnimateHPBar: ; d627 ld a, [hli] ld b, a pop hl - call ComputeHPBarPixels + call Predef_ComputeHPBarPixels ld a, e ld [wCurHPBarPixels], a @@ -79,7 +79,7 @@ _AnimateHPBar: ; d627 ld e, a ld a, [wCurHPAnimMaxHP + 1] ld d, a - call ComputeHPBarPixels + call Predef_ComputeHPBarPixels ld a, e ld [wNewHPBarPixels], a @@ -183,11 +183,11 @@ LongAnim_UpdateVariables: ; d6f5 ld c, a ld a, [hli] ld b, a - ; This routine is buggy. The result from ComputeHPBarPixels is stored + ; This routine is buggy. The result from Predef_ComputeHPBarPixels is stored ; in e. However, the pop de opcode deletes this result before it is even ; used. The game then proceeds as though it never deleted that output. ; To fix, uncomment the line below. - call ComputeHPBarPixels + call Predef_ComputeHPBarPixels ; ld a, e pop bc pop de @@ -227,7 +227,7 @@ LongHPBarAnim_UpdateTiles: ; d749 ld e, a ld a, [wCurHPAnimMaxHP + 1] ld d, a - call ComputeHPBarPixels + call Predef_ComputeHPBarPixels ld c, e ld d, HP_BAR_LENGTH ld a, [wWhichHPBar] diff --git a/engine/battle/battle_transition.asm b/engine/battle/battle_transition.asm index 85ba44072..f035867b5 100644 --- a/engine/battle/battle_transition.asm +++ b/engine/battle/battle_transition.asm @@ -1,4 +1,4 @@ -Predef_StartBattle: ; 8c20f +Predef_DoBattleTransition: ; 8c20f call .InitGFX ld a, [rBGP] ld [wBGP], a @@ -16,14 +16,14 @@ Predef_StartBattle: ; 8c20f ld a, [wJumptableIndex] bit 7, a jr nz, .done - call FlashyTransitionToBattle + call BattleTransitionJumptable call DelayFrame jr .loop .done ld a, [rSVBK] push af - ld a, $5 + ld a, BANK(wBGPals1) ld [rSVBK], a ld hl, wBGPals1 @@ -44,7 +44,7 @@ Predef_StartBattle: ; 8c20f ld [hLYOverrideEnd], a ld [hSCY], a - ld a, $1 + ld a, 1 ; unnecessary bankswitch? ld [rSVBK], a pop af ld [hVBlank], a @@ -116,7 +116,7 @@ LoadTrainerBattlePokeballTiles: ConvertTrainerBattlePokeballTilesTo2bpp: ; 8c2cf ld a, [rSVBK] push af - ld a, $6 + ld a, BANK(wDecompressScratch) ld [rSVBK], a push hl ld hl, wDecompressScratch @@ -144,7 +144,7 @@ TrainerBattlePokeballTiles: ; 8c2f4 INCBIN "gfx/overworld/trainer_battle_pokeball_tiles.2bpp" -FlashyTransitionToBattle: ; 8c314 +BattleTransitionJumptable: ; 8c314 jumptable .dw, wJumptableIndex ; 8c323 @@ -298,7 +298,7 @@ StartTrainerBattle_Flash: ; 8c3ab (23:43ab) StartTrainerBattle_SetUpForWavyOutro: ; 8c3e8 (23:43e8) farcall Function5602 - ld a, $5 ; BANK(LYOverrides) + ld a, BANK(LYOverrides) ld [rSVBK], a call StartTrainerBattle_NextScene @@ -356,7 +356,7 @@ StartTrainerBattle_SineWave: ; 8c408 (23:4408) StartTrainerBattle_SetUpForSpinOutro: ; 8c43d (23:443d) farcall Function5602 - ld a, $5 ; BANK(LYOverrides) + ld a, BANK(LYOverrides) ld [rSVBK], a call StartTrainerBattle_NextScene xor a @@ -498,7 +498,7 @@ ENDM StartTrainerBattle_SetUpForRandomScatterOutro: ; 8c578 (23:4578) farcall Function5602 - ld a, $5 ; BANK(LYOverrides) + ld a, BANK(LYOverrides) ld [rSVBK], a call StartTrainerBattle_NextScene ld a, $10 @@ -589,7 +589,7 @@ StartTrainerBattle_LoadPokeBallGraphics: ; 8c5dc (23:45dc) dec b jr nz, .loop - call .loadpokeballgfx ; ld a, [OtherTrainerClass] \ ld de, PokeBallTransition \ ret + call .loadpokeballgfx hlcoord 2, 1 ld b, SCREEN_WIDTH - 4 @@ -640,14 +640,14 @@ StartTrainerBattle_LoadPokeBallGraphics: ; 8c5dc (23:45dc) .cgb ld hl, .daypals ld a, [TimeOfDayPal] - and (1 << 2) - 1 - cp 3 + maskbits NUM_DAYTIMES +- 1 + cp DARKNESS_F jr nz, .daytime ld hl, .nightpals .daytime ld a, [rSVBK] push af - ld a, $5 ; WRAM5 = palettes + ld a, BANK(wBGPals1) ld [rSVBK], a call .copypals push hl @@ -691,17 +691,12 @@ StartTrainerBattle_LoadPokeBallGraphics: ; 8c5dc (23:45dc) ; 8c6a1 (23:46a1) .daypals ; 8c6a1 - RGB 31, 18, 29 - RGB 31, 11, 15 - RGB 31, 05, 05 - RGB 07, 07, 07 +INCLUDE "gfx/overworld/trainer_battle_day.pal" ; 8c6a9 .nightpals ; 8c6a9 - RGB 31, 18, 29 - RGB 31, 05, 05 - RGB 31, 05, 05 - RGB 31, 05, 05 +INCLUDE "gfx/overworld/trainer_battle_nite.pal" +; 8c6b1 .loadpokeballgfx ld a, [OtherTrainerClass] @@ -729,7 +724,7 @@ PokeBallTransition: WipeLYOverrides: ; 8c6d8 ld a, [rSVBK] push af - ld a, $5 + ld a, BANK(LYOverrides) ld [rSVBK], a ld hl, LYOverrides @@ -754,22 +749,23 @@ WipeLYOverrides: ; 8c6d8 StartTrainerBattle_DrawSineWave: ; 8c6f7 (23:46f7) - and (1 << 6) - 1 - cp 1 << 5 - jr nc, .okay - call .DoSineWave +; a = d * sin(a * pi/32) + and %111111 + cp %100000 + jr nc, .negative + call .ApplySineWave ld a, h ret -.okay - and (1 << 5) - 1 - call .DoSineWave +.negative + and %011111 + call .ApplySineWave ld a, h - xor -1 ; cpl + xor $ff inc a ret -.DoSineWave: ; 8c70c (23:470c) +.ApplySineWave: ; 8c70c (23:470c) ld e, a ld a, d ld d, 0 @@ -780,15 +776,15 @@ StartTrainerBattle_DrawSineWave: ; 8c6f7 (23:46f7) inc hl ld d, [hl] ld hl, 0 -.loop +.multiply srl a - jr nc, .skip + jr nc, .even add hl, de -.skip +.even sla e rl d and a - jr nz, .loop + jr nz, .multiply ret ; 8c728 (23:4728) @@ -863,8 +859,7 @@ ENDM ret ; 8c7c9 (23:47c9) -Function8c7c9: -; XXX +Unreferenced_Function8c7c9: ld a, $1 ld [hBGMapMode], a call WaitBGMap diff --git a/engine/battle/checkbattlescene.asm b/engine/battle/checkbattlescene.asm index b63f00907..a33cc62e3 100644 --- a/engine/battle/checkbattlescene.asm +++ b/engine/battle/checkbattlescene.asm @@ -1,7 +1,7 @@ CheckBattleScene: ; 4ea44 ; Return carry if battle scene is turned off. - ld a, 0 + ld a, BANK(wLinkMode) ld hl, wLinkMode call GetFarWRAMByte cp LINK_MOBILE @@ -19,9 +19,9 @@ CheckBattleScene: ; 4ea44 and a jr nz, .from_wram - ld a, $4 + ld a, 4 ; MBC30 bank used by JP Crystal; inaccessible by MBC3 call GetSRAMBank - ld a, [$a60c] + ld a, [$a60c] ; address of MBC30 bank ld c, a call CloseSRAM @@ -33,7 +33,7 @@ CheckBattleScene: ; 4ea44 ret .from_wram - ld a, $5 + ld a, BANK(w5_dc00) ld hl, w5_dc00 call GetFarWRAMByte bit 0, a diff --git a/engine/battle/core.asm b/engine/battle/core.asm index 08021fc8b..cf9c821b7 100644 --- a/engine/battle/core.asm +++ b/engine/battle/core.asm @@ -47,7 +47,7 @@ DoBattle: ; 3c000 .player_2 call LoadTileMapToTempTileMap - call CheckPlayerPartyForFitPkmn + call Predef_CheckPlayerPartyForFitPkmn ld a, d and a jp z, LostBattle @@ -160,7 +160,7 @@ WildFled_EnemyFled_LinkBattleCanceled: ; 3c0e5 BattleTurn: ; 3c12f .loop - call MobileFn_3c1bf + call Stubbed_Function3c1bf call CheckContestBattleOver jp c, .quit @@ -231,10 +231,11 @@ BattleTurn: ; 3c12f ret ; 3c1bf -MobileFn_3c1bf: mobile - ld a, $5 +Stubbed_Function3c1bf: + ret + ld a, 5 ; MBC30 bank used by JP Crystal; inaccessible by MBC3 call GetSRAMBank - ld hl, $a89b ; s5_a89b + ld hl, $a89b ; address of MBC30 bank inc [hl] jr nz, .finish dec hl @@ -730,7 +731,7 @@ HandleEncore: ; 3c4df ld b, 0 add hl, bc ld a, [hl] - and $3f + and PP_MASK ret nz .end_player_encore @@ -754,7 +755,7 @@ HandleEncore: ; 3c4df ld b, 0 add hl, bc ld a, [hl] - and $3f + and PP_MASK ret nz .end_enemy_encore @@ -857,7 +858,7 @@ GetMovePriority: ; 3c5c5 cp -1 jr nz, .loop - ld a, 1 + ld a, BASE_PRIORITY ret .done @@ -865,15 +866,7 @@ GetMovePriority: ; 3c5c5 ret ; 3c5df -MoveEffectPriorities: ; 3c5df - db EFFECT_PROTECT, 3 - db EFFECT_ENDURE, 3 - db EFFECT_PRIORITY_HIT, 2 - db EFFECT_FORCE_SWITCH, 0 - db EFFECT_COUNTER, 0 - db EFFECT_MIRROR_COAT, 0 - db -1 -; 3c5ec +INCLUDE "data/moves/effects_priorities.asm" GetMoveEffect: ; 3c5ec ld a, b @@ -1285,7 +1278,7 @@ HandleWrap: ; 3c874 xor a ld [wNumHits], a ld [FXAnimID + 1], a - predef PlayBattleAnim + predef Predef_PlayBattleAnim call SwitchTurnCore .skip_anim @@ -1409,7 +1402,7 @@ HandleMysteryberry: ; 3c93c and a jr z, .quit ld a, [de] - and $3f + and PP_MASK jr z, .restore inc hl inc de @@ -1951,8 +1944,7 @@ GetMaxHP: ; 3ccac ret ; 3ccc2 -GetHalfHP: ; 3ccc2 -; unreferenced +Unreferenced_GetHalfHP: ; 3ccc2 ld hl, BattleMonHP ld a, [hBattleTurn] and a @@ -2048,7 +2040,7 @@ UpdateHPBar: ; 3cd3c .ok push bc ld [wWhichHPBar], a - predef AnimateHPBar + predef Predef_AnimateHPBar pop bc ret ; 3cd55 @@ -2062,7 +2054,7 @@ HandleEnemyMonFaint: ; 3cd55 xor a ld [wWhichMonFaintedFirst], a call UpdateBattleStateAndExperienceAfterEnemyFaint - call CheckPlayerPartyForFitPkmn + call Predef_CheckPlayerPartyForFitPkmn ld a, d and a jp z, LostBattle @@ -2070,7 +2062,7 @@ HandleEnemyMonFaint: ; 3cd55 ld hl, BattleMonHP ld a, [hli] or [hl] - call nz, UpdatePlayerHUD + call nz, Predef_UpdatePlayerHUD ld a, $1 ld [hBGMapMode], a @@ -2194,7 +2186,7 @@ UpdateBattleStateAndExperienceAfterEnemyFaint: ; 3ce01 call PlayerMonFaintHappinessMod .player_mon_did_not_faint - call CheckPlayerPartyForFitPkmn + call Predef_CheckPlayerPartyForFitPkmn ld a, d and a ret z @@ -2460,7 +2452,7 @@ WinTrainerBattle: ; 3cfa4 ld c, 40 call DelayFrames call EmptyBattleTextBox - ld c, $3 + ld c, BATTLETOWERTEXT_LOSS_TEXT farcall BattleTowerText call WaitPressAorB_BlinkCursor ld hl, wPayDayMoney @@ -2589,7 +2581,7 @@ AddBattleMoneyToAccount: ; 3d0be push bc ld b, h ld c, l - farcall TrainerRankings_AddToBattlePayouts + farcall StubbedTrainerRankings_AddToBattlePayouts pop bc pop hl .loop @@ -2640,7 +2632,7 @@ PlayVictoryMusic: ; 3d0ea .trainer_victory ld de, MUSIC_GYM_VICTORY - call IsJohtoGymLeader + call IsGymLeader jr c, .play_music ld de, MUSIC_TRAINER_VICTORY @@ -2652,58 +2644,22 @@ PlayVictoryMusic: ; 3d0ea ret ; 3d123 -; These functions check if the current opponent is a gym leader or one of a -; few other special trainers. - -; Note: KantoGymLeaders is a subset of JohtoGymLeaders. If you wish to -; differentiate between the two, call IsKantoGymLeader first. - -; The Lance and Red entries are unused for music checks; those trainers are -; accounted for elsewhere. - IsKantoGymLeader: ; 0x3d123 ld hl, KantoGymLeaders jr IsGymLeaderCommon -IsJohtoGymLeader: ; 0x3d128 - ld hl, JohtoGymLeaders +IsGymLeader: ; 0x3d128 + ld hl, GymLeaders IsGymLeaderCommon: push de ld a, [OtherTrainerClass] - ld de, $0001 + ld de, $1 call IsInArray pop de ret ; 0x3d137 -JohtoGymLeaders: - db FALKNER - db WHITNEY - db BUGSY - db MORTY - db PRYCE - db JASMINE - db CHUCK - db CLAIR - db WILL - db BRUNO - db KAREN - db KOGA -; fallthrough -; these two entries are unused - db CHAMPION - db RED -; fallthrough -KantoGymLeaders: - db BROCK - db MISTY - db LT_SURGE - db ERIKA - db JANINE - db SABRINA - db BLAINE - db BLUE - db -1 +INCLUDE "data/trainers/leaders.asm" HandlePlayerMonFaint: ; 3d14e call FaintYourPokemon @@ -2714,7 +2670,7 @@ HandlePlayerMonFaint: ; 3d14e ld a, $1 ld [wWhichMonFaintedFirst], a call PlayerMonFaintHappinessMod - call CheckPlayerPartyForFitPkmn + call Predef_CheckPlayerPartyForFitPkmn ld a, d and a jp z, LostBattle @@ -2760,7 +2716,7 @@ PlayerMonFaintHappinessMod: ; 3d1aa ld c, a ld hl, wBattleParticipantsNotFainted ld b, RESET_FLAG - predef FlagPredef + predef Predef_SmallFarFlagAction ld hl, EnemySubStatus3 res SUBSTATUS_IN_LOOP, [hl] xor a @@ -3066,7 +3022,7 @@ LostBattle: ; 3d38e call DelayFrames call EmptyBattleTextBox - ld c, 2 + ld c, BATTLETOWERTEXT_WIN_TEXT farcall BattleTowerText call WaitPressAorB_BlinkCursor call ClearTileMap @@ -3357,10 +3313,10 @@ AddBattleParticipant: ; 3d581 ld hl, wBattleParticipantsNotFainted ld b, SET_FLAG push bc - predef FlagPredef + predef Predef_SmallFarFlagAction pop bc ld hl, wBattleParticipantsIncludingFainted - predef_jump FlagPredef + predef_jump Predef_SmallFarFlagAction ; 3d599 FindPkmnInOTPartyToSwitchIntoBattle: ; 3d599 @@ -3578,7 +3534,7 @@ LoadEnemyPkmnToSwitchTo: ; 3d6ca and a jr nz, .skip_unown ld hl, EnemyMonDVs - predef GetUnownLetter + predef Predef_GetUnownLetter ld a, [UnownLetter] ld [wFirstUnownSeen], a .skip_unown @@ -3688,8 +3644,8 @@ Function_SetEnemyPkmnAndSendOutAnimation: ; 3d7c7 call GetBaseData ld a, OTPARTYMON ld [MonType], a - predef CopyPkmnToTempMon - call GetEnemyMonFrontpic + predef Predef_CopyPkmnToTempMon + call Predef_GetEnemyMonFrontpic xor a ld [wNumHits], a @@ -3714,7 +3670,7 @@ Function_SetEnemyPkmnAndSendOutAnimation: ; 3d7c7 hlcoord 12, 0 ld d, $0 ld e, ANIM_MON_SLOW - predef AnimateFrontpic + predef Predef_AnimateFrontpic jr .skip_cry .cry_no_anim @@ -3724,7 +3680,7 @@ Function_SetEnemyPkmnAndSendOutAnimation: ; 3d7c7 call PlayStereoCry .skip_cry - call UpdateEnemyHUD + call Predef_UpdateEnemyHUD ld a, $1 ld [hBGMapMode], a ret @@ -3765,7 +3721,7 @@ ResetEnemyStatLevels: ; 3d867 ret ; 3d873 -CheckPlayerPartyForFitPkmn: ; 3d873 +Predef_CheckPlayerPartyForFitPkmn: ; 3d873 ; Has the player any Pkmn in his Party that can fight? ld a, [PartyCount] ld e, a @@ -4168,7 +4124,7 @@ SwitchPlayerMon: ; 3db32 SendOutPlayerMon: ; 3db5f ld hl, BattleMonDVs - predef GetUnownLetter + predef Predef_GetUnownLetter hlcoord 1, 5 ld b, 7 ld c, 8 @@ -4176,7 +4132,7 @@ SendOutPlayerMon: ; 3db5f call WaitBGMap xor a ld [hBGMapMode], a - call GetBattleMonBackpic + call Predef_GetBattleMonBackpic xor a ld [hGraphicStartTile], a ld [wBattleMenuCursorBuffer], a @@ -4216,7 +4172,7 @@ SendOutPlayerMon: ; 3db5f call PlayStereoCry .statused - call UpdatePlayerHUD + call Predef_UpdatePlayerHUD ld a, $1 ld [hBGMapMode], a ret @@ -4262,13 +4218,13 @@ BreakAttraction: ; 3dc18 SpikesDamage: ; 3dc23 ld hl, PlayerScreens ld de, BattleMonType - ld bc, UpdatePlayerHUD + ld bc, Predef_UpdatePlayerHUD ld a, [hBattleTurn] and a jr z, .ok ld hl, EnemyScreens ld de, EnemyMonType - ld bc, UpdateEnemyHUD + ld bc, Predef_UpdateEnemyHUD .ok bit SCREENS_SPIKES, [hl] @@ -4350,7 +4306,7 @@ PursuitSwitch: ; 3dc5b ld c, a ld hl, wBattleParticipantsNotFainted ld b, RESET_FLAG - predef FlagPredef + predef Predef_SmallFarFlagAction call PlayerMonFaintedAnimation ld hl, BattleText_PkmnFainted jr .done_fainted @@ -4499,7 +4455,7 @@ HandleHPHealingItem: ; 3dd2f .got_hp_bar_coords ld [wWhichHPBar], a - predef AnimateHPBar + predef Predef_AnimateHPBar UseOpponentItem: call RefreshBattleHuds callfar GetOpponentItem @@ -4522,7 +4478,7 @@ ItemRecoveryAnim: ; 3ddc8 xor a ld [wNumHits], a ld [FXAnimID + 1], a - predef PlayBattleAnim + predef Predef_PlayBattleAnim call SwitchTurnCore pop bc pop de @@ -4586,13 +4542,13 @@ UseHeldStatusHealingItem: ; 3dde9 ; 3de44 .Statuses: ; 3de44 - db HELD_HEAL_POISON, 1 << PSN - db HELD_HEAL_FREEZE, 1 << FRZ - db HELD_HEAL_BURN, 1 << BRN - db HELD_HEAL_SLEEP, SLP + db HELD_HEAL_POISON, 1 << PSN + db HELD_HEAL_FREEZE, 1 << FRZ + db HELD_HEAL_BURN, 1 << BRN + db HELD_HEAL_SLEEP, SLP db HELD_HEAL_PARALYZE, 1 << PAR - db HELD_HEAL_STATUS, ALL_STATUS - db $ff + db HELD_HEAL_STATUS, ALL_STATUS + db -1 ; end ; 3de51 UseConfusionHealingItem: ; 3de51 @@ -4716,7 +4672,7 @@ HandleStatBoostingHeldItems: ; 3de97 dbw HELD_SP_DEFENSE_UP, BattleCommand_SpecialDefenseUp dbw HELD_ACCURACY_UP, BattleCommand_AccuracyUp dbw HELD_EVASION_UP, BattleCommand_EvasionUp - db $ff + db -1 ; end ; 3df12 GetPartymonItem: ; 3df12 @@ -4752,7 +4708,7 @@ UpdateBattleHUDs: ; 3df2c ret ; 3df48 -UpdatePlayerHUD:: ; 3df48 +Predef_UpdatePlayerHUD:: ; 3df48 push hl push de push bc @@ -4785,7 +4741,7 @@ DrawPlayerHUD: ; 3df58 ld b, 1 xor a ; PARTYMON ld [MonType], a - predef DrawPlayerHP + predef Predef_DrawPlayerHP ; Exp bar push de @@ -4798,7 +4754,7 @@ DrawPlayerHUD: ; 3df58 hlcoord 10, 11 ld a, [TempMonLevel] ld b, a - call FillInExpBar + call Predef_FillInExpBar pop de ret ; 3df98 @@ -4852,7 +4808,7 @@ PrintPlayerHUD: ; 3dfbf ld [de], a ld hl, BattleMonLevel ld de, TempMonLevel - ld bc, $0011 + ld bc, $11 call CopyBytes ld a, [CurBattleMon] ld hl, PartyMon1Species @@ -4867,7 +4823,7 @@ PrintPlayerHUD: ; 3dfbf ld a, TEMPMON ld [MonType], a - callfar GetGender + callfar Predef_GetGender ld a, " " jr c, .got_gender_char ld a, "♂" @@ -4881,7 +4837,7 @@ PrintPlayerHUD: ; 3dfbf push af ; back up gender push hl ld de, BattleMonStatus - predef PlaceNonFaintStatus + predef Predef_PlaceNonFaintStatus pop hl pop bc ret nz @@ -4896,7 +4852,7 @@ PrintPlayerHUD: ; 3dfbf jp PrintLevel ; 3e036 -UpdateEnemyHUD:: ; 3e036 +Predef_UpdateEnemyHUD:: ; 3e036 push hl push de push bc @@ -4945,7 +4901,7 @@ DrawEnemyHUD: ; 3e043 ld a, TEMPMON ld [MonType], a - callfar GetGender + callfar Predef_GetGender ld a, " " jr c, .got_gender ld a, "♂" @@ -4960,7 +4916,7 @@ DrawEnemyHUD: ; 3e043 push af push hl ld de, EnemyMonStatus - predef PlaceNonFaintStatus + predef Predef_PlaceNonFaintStatus pop hl pop bc jr nz, .skip_level @@ -5185,8 +5141,8 @@ BattleMenu_Pack: ; 3e1c7 call ClearPalettes call DelayFrame call _LoadBattleFontsHPBar - call GetBattleMonBackpic - call GetEnemyMonFrontpic + call Predef_GetBattleMonBackpic + call Predef_GetEnemyMonFrontpic call ExitMenu call WaitBGMap call FinishBattleAnim @@ -5218,10 +5174,10 @@ BattleMenu_Pack: ; 3e1c7 ld a, [BattleType] cp BATTLETYPE_TUTORIAL jr z, .tutorial2 - call GetBattleMonBackpic + call Predef_GetBattleMonBackpic .tutorial2 - call GetEnemyMonFrontpic + call Predef_GetEnemyMonFrontpic ld a, $1 ld [wMenuCursorY], a call ExitMenu @@ -5575,7 +5531,7 @@ MoveSelectionScreen: ; 3e4bc .got_start_coord ld a, SCREEN_WIDTH ld [Buffer1], a - predef ListMoves + predef Predef_ListMoves ld b, 5 ld a, [wMoveSelectionMenuType] @@ -5694,7 +5650,7 @@ MoveSelectionScreen: ; 3e4bc ld b, 0 add hl, bc ld a, [hl] - and $3f + and PP_MASK jr z, .no_pp_left ld a, [PlayerDisableCount] swap a @@ -5893,7 +5849,7 @@ MoveInfoBox: ; 3e6c8 ld hl, BattleMonPP add hl, bc ld a, [hl] - and $3f + and PP_MASK ld [StringBuffer1], a call .PrintPP @@ -5908,7 +5864,7 @@ MoveInfoBox: ; 3e6c8 ld a, [wPlayerMoveStruct + MOVE_ANIM] ld b, a hlcoord 2, 10 - predef PrintMoveType + predef Predef_PrintMoveType .done ret @@ -5956,7 +5912,7 @@ CheckPlayerHasUsableMoves: ; 3e786 or [hl] inc hl or [hl] - and $3f + and PP_MASK ret nz jr .force_struggle @@ -5978,8 +5934,7 @@ CheckPlayerHasUsableMoves: ; 3e786 .done ; Bug: this will result in a move with PP Up confusing the game. - ; Replace with "and $3f" to fix. - and a + and a ; should be "and PP_MASK" ret nz .force_struggle @@ -6058,7 +6013,7 @@ ParseEnemyAction: ; 3e7c1 cp [hl] jr z, .disabled ld a, [de] - and $3f + and PP_MASK jr nz, .enough_pp .disabled @@ -6076,7 +6031,7 @@ ParseEnemyAction: ; 3e7c1 .loop2 ld hl, EnemyMonMoves call BattleRandom - and 3 ; TODO factor in NUM_MOVES + maskbits NUM_MOVES +- 1 ld c, a ld b, 0 add hl, bc @@ -6093,7 +6048,7 @@ ParseEnemyAction: ; 3e7c1 add hl, bc ld b, a ld a, [hl] - and $3f + and PP_MASK jr z, .loop2 ld a, c ld [CurEnemyMoveNum], a @@ -6364,7 +6319,7 @@ LoadEnemyMon: ; 3e8eb ; Get letter based on DVs ld hl, EnemyMonDVs - predef GetUnownLetter + predef Predef_GetUnownLetter ; Can't use any letters that haven't been unlocked ; If combined with forced shiny battletype, causes an infinite loop call CheckUnownLetter @@ -6376,9 +6331,9 @@ LoadEnemyMon: ; 3e8eb ; but the value is in feet and inches (one byte each). ; The first filter is supposed to make very large Magikarp even rarer, -; by targeting those 1600 mm or larger. +; by targeting those 1600 mm (= 5'3") or larger. ; After the conversion to feet, it is unable to target any, -; as the largest possible Magikarp is 5'3'', which reads as 1283. +; since the largest possible Magikarp is 5'3", and $0503 = 1283 mm. ld a, [TempEnemyMonSpecies] cp MAGIKARP jr nz, .Happiness @@ -6388,42 +6343,43 @@ LoadEnemyMon: ; 3e8eb ld bc, PlayerID callfar CalcMagikarpLength -; No reason to keep going if length > 1536 (i.e. if length / 256 != 6) +; No reason to keep going if length > 1536 mm (i.e. if HIGH(length) > 6 feet) ld a, [wMagikarpLength] - cp HIGH(1536) ; this compares to 6'0'', should be cp 5 + cp HIGH(1536) ; should be "cp 5", since 1536 mm = 5'0", but HIGH(1536) = 6 jr nz, .CheckMagikarpArea ; 5% chance of skipping both size checks call Random cp 5 percent jr c, .CheckMagikarpArea -; Try again if length > 1615 +; Try again if length >= 1616 mm (i.e. if LOW(length) >= 3 inches) ld a, [wMagikarpLength + 1] - cp LOW(1616) ; this compares to 6'80'', should be cp 3 + cp LOW(1616) ; should be "cp 3", since 1616 mm = 5'3", but LOW(1616) = 80 jr nc, .GenerateDVs ; 20% chance of skipping this check call Random cp 20 percent - 1 jr c, .CheckMagikarpArea -; Try again if length > 1599 +; Try again if length >= 1600 mm (i.e. if LOW(length) >= 2 inches) ld a, [wMagikarpLength + 1] - cp LOW(1600) ; this compares to 6'64'', should be cp 2 + cp LOW(1600) ; should be "cp 2", since 1600 mm = 5'2", but LOW(1600) = 64 jr nc, .GenerateDVs .CheckMagikarpArea: -; The z checks are supposed to be nz -; Instead, all maps in GROUP_LAKE_OF_RAGE (mahogany area) -; and routes 20 and 44 are treated as Lake of Rage +; The "jr z" checks are supposed to be "jr nz". + +; Instead, all maps in GROUP_LAKE_OF_RAGE (Mahogany area) +; and Routes 20 and 44 are treated as Lake of Rage. ; This also means Lake of Rage Magikarp can be smaller than ones -; caught elsewhere rather than the other way around +; caught elsewhere rather than the other way around. -; Intended behavior enforces a minimum size at Lake of Rage -; The real behavior prevents size flooring in the Lake of Rage area +; Intended behavior enforces a minimum size at Lake of Rage. +; The real behavior prevents a minimum size in the Lake of Rage area. -; Moreover, due to the check not being translated to feet, all Magikarp -; smaller than 4'0'' may be caught by the filter, a lot more than intended +; Moreover, due to the check not being translated to feet+inches, all Magikarp +; smaller than 4'0" may be caught by the filter, a lot more than intended. ld a, [MapGroup] cp GROUP_LAKE_OF_RAGE jr z, .Happiness @@ -6434,9 +6390,9 @@ LoadEnemyMon: ; 3e8eb call Random cp 40 percent - 2 jr c, .Happiness -; Floor at length 1024 +; Try again if length < 1024 mm (i.e. if HIGH(length) < 3 feet) ld a, [wMagikarpLength] - cp HIGH(1024) ; compares to 4'0'', cp 3 would be closer to intended value + cp HIGH(1024) ; should be "cp 3", since 1024 mm = 3'4", but HIGH(1024) = 4 jr c, .GenerateDVs ; try again ; Finally done with DVs @@ -6452,7 +6408,7 @@ LoadEnemyMon: ; 3e8eb ld de, EnemyMonMaxHP ld b, FALSE ld hl, EnemyMonDVs - (MON_DVS - MON_STAT_EXP + 1) ; LinkBattleRNs + 7 ; ? - predef CalcPkmnStats + predef Predef_CalcPkmnStats ; If we're in a trainer battle, ; get the rest of the parameters from the party struct @@ -6567,7 +6523,7 @@ LoadEnemyMon: ; 3e8eb ; Make sure the predef knows this isn't a partymon ld [wEvolutionOldSpecies], a ; Fill moves based on level - predef FillMoves + predef Predef_FillMoves .PP: ; Trainer battle? @@ -6578,7 +6534,7 @@ LoadEnemyMon: ; 3e8eb ; Fill wild PP ld hl, EnemyMonMoves ld de, EnemyMonPP - predef FillPP + predef Predef_FillPP jr .Finish .TrainerPP: @@ -6631,7 +6587,7 @@ LoadEnemyMon: ; 3e8eb ld c, a ld b, SET_FLAG ld hl, PokedexSeen - predef FlagPredef + predef Predef_SmallFarFlagAction ld hl, EnemyMonStats ld de, EnemyStats @@ -6651,13 +6607,13 @@ CheckSleepingTreeMon: ; 3eb38 jr nz, .NotSleeping ; Get list for the time of day - ld hl, .Morn + ld hl, AsleepTreeMonsMorn ld a, [TimeOfDay] cp DAY_F jr c, .Check - ld hl, .Day + ld hl, AsleepTreeMonsDay jr z, .Check - ld hl, .Nite + ld hl, AsleepTreeMonsNite .Check: ld a, [TempEnemyMonSpecies] @@ -6670,36 +6626,7 @@ CheckSleepingTreeMon: ; 3eb38 and a ret -.Nite: - db CATERPIE - db METAPOD - db BUTTERFREE - db WEEDLE - db KAKUNA - db BEEDRILL - db SPEAROW - db EKANS - db EXEGGCUTE - db LEDYBA - db AIPOM - db -1 ; end - -.Day: - db VENONAT - db HOOTHOOT - db NOCTOWL - db SPINARAK - db HERACROSS - db -1 ; end - -.Morn: - db VENONAT - db HOOTHOOT - db NOCTOWL - db SPINARAK - db HERACROSS - db -1 ; end -; 3eb75 +INCLUDE "data/wild/treemons_asleep.asm" CheckUnownLetter: ; 3eb75 ; Return carry if the Unown letter hasn't been unlocked yet @@ -6769,8 +6696,7 @@ CheckUnownLetter: ; 3eb75 ; 3ebc7 -SwapBattlerLevels: ; 3ebc7 -; unreferenced +Unreferenced_SwapBattlerLevels: ; 3ebc7 push bc ld a, [BattleMonLevel] ld b, a @@ -6789,7 +6715,7 @@ BattleWinSlideInEnemyTrainerFrontpic: ; 3ebd8 ld a, [OtherTrainerClass] ld [TrainerClass], a ld de, vTiles2 - callfar GetTrainerPic + callfar Predef_GetTrainerPic hlcoord 19, 0 ld c, 0 @@ -7162,7 +7088,7 @@ _LoadHPBar: ; 3eda6 ret ; 3edad -LoadHPExpBarGFX: ; unreferenced +Unreferenced_LoadHPExpBarGFX: ld de, EnemyHPBarBorderGFX ld hl, vTiles2 tile $6c lb bc, BANK(EnemyHPBarBorderGFX), 4 @@ -7266,7 +7192,7 @@ Call_PlayBattleAnim: ; 3ee17 ld a, d ld [FXAnimID + 1], a call WaitBGMap - predef_jump PlayBattleAnim + predef_jump Predef_PlayBattleAnim ; 3ee27 FinishBattleAnim: ; 3ee27 @@ -7314,7 +7240,7 @@ GiveExperiencePoints: ; 3ee3b ld c, a ld b, CHECK_FLAG ld d, $0 - predef FlagPredef + predef Predef_SmallFarFlagAction ld a, c and a pop bc @@ -7492,7 +7418,7 @@ GiveExperiencePoints: ; 3ee3b .not_max_exp xor a ; PARTYMON ld [MonType], a - predef CopyPkmnToTempMon + predef Predef_CopyPkmnToTempMon callfar CalcLevel pop bc ld hl, MON_LEVEL @@ -7529,7 +7455,7 @@ GiveExperiencePoints: ; 3ee3b add hl, bc push bc ld b, TRUE - predef CalcPkmnStats + predef Predef_CalcPkmnStats pop bc pop de ld hl, MON_MAXHP + 1 @@ -7582,7 +7508,7 @@ GiveExperiencePoints: ; 3ee3b call ApplyStatLevelMultiplierOnAllStats callfar ApplyStatusEffectOnPlayerStats callfar BadgeStatBoosts - callfar UpdatePlayerHUD + callfar Predef_UpdatePlayerHUD call EmptyBattleTextBox call LoadTileMapToTempTileMap ld a, $1 @@ -7605,14 +7531,14 @@ GiveExperiencePoints: ; 3ee3b .skip_animation2 xor a ; PARTYMON ld [MonType], a - predef CopyPkmnToTempMon + predef Predef_CopyPkmnToTempMon hlcoord 9, 0 ld b, $a ld c, $9 call TextBox hlcoord 11, 1 ld bc, 4 - predef PrintTempMonStats + predef Predef_PrintTempMonStats ld c, $1e call DelayFrames call WaitPressAorB_BlinkCursor @@ -7632,7 +7558,7 @@ GiveExperiencePoints: ; 3ee3b ld a, b ld [CurPartyLevel], a push bc - predef LearnLevelMoves + predef Predef_LearnLevelMoves pop bc ld a, b cp c @@ -7643,7 +7569,7 @@ GiveExperiencePoints: ; 3ee3b ld a, [CurPartyMon] ld c, a ld b, SET_FLAG - predef FlagPredef + predef Predef_SmallFarFlagAction pop af ld [CurPartyLevel], a @@ -7765,7 +7691,7 @@ AnimateExpBar: ; 3f136 ld [wd002], a xor a ; PARTYMON ld [MonType], a - predef CopyPkmnToTempMon + predef Predef_CopyPkmnToTempMon ld a, [TempMonLevel] ld b, a ld e, a @@ -8093,7 +8019,7 @@ TextJump_GoodComeBack: ; 3f352 db "@" ; 3f357 -UnusedFunction_TextJump_ComeBack: ; 3f357 +Unreferenced_TextJump_ComeBack: ; 3f357 ; this function doesn't seem to be used ld hl, TextJump_ComeBack ret @@ -8104,7 +8030,7 @@ TextJump_ComeBack: ; 3f35b db "@" ; 3f360 -HandleSafariAngerEatingStatus: ; unreferenced +Unreferenced_HandleSafariAngerEatingStatus: ld hl, wSafariMonEating ld a, [hl] and a @@ -8136,7 +8062,7 @@ HandleSafariAngerEatingStatus: ; unreferenced jp StdBattleTextBox ; 3f390 -FillInExpBar: ; 3f390 +Predef_FillInExpBar: ; 3f390 push hl call CalcExpBar pop hl @@ -8278,7 +8204,7 @@ PlaceExpBar: ; 3f41c ret ; 3f43d -GetBattleMonBackpic: ; 3f43d +Predef_GetBattleMonBackpic: ; 3f43d ld a, [PlayerSubStatus4] bit SUBSTATUS_SUBSTITUTE, a ld hl, BattleAnimCmd_RaiseSub @@ -8294,9 +8220,9 @@ DropPlayerSub: ; 3f447 ld a, [BattleMonSpecies] ld [CurPartySpecies], a ld hl, BattleMonDVs - predef GetUnownLetter + predef Predef_GetUnownLetter ld de, vTiles2 tile $31 - predef GetMonBackpic + predef Predef_GetMonBackpic pop af ld [CurPartySpecies], a ret @@ -8314,7 +8240,7 @@ GetBattleMonBackpic_DoAnim: ; 3f46f ret ; 3f47c -GetEnemyMonFrontpic: ; 3f47c +Predef_GetEnemyMonFrontpic: ; 3f47c ld a, [EnemySubStatus4] bit SUBSTATUS_SUBSTITUTE, a ld hl, BattleAnimCmd_RaiseSub @@ -8333,9 +8259,9 @@ DropEnemySub: ; 3f486 ld [CurPartySpecies], a call GetBaseData ld hl, EnemyMonDVs - predef GetUnownLetter + predef Predef_GetUnownLetter ld de, vTiles2 - predef GetAnimatedFrontpicPredef + predef Predef_GetAnimatedFrontpic pop af ld [CurPartySpecies], a ret @@ -8352,7 +8278,7 @@ GetEnemyMonFrontpic_DoAnim: ; 3f4b4 ret ; 3f4c1 -StartBattle: ; 3f4c1 +Predef_StartBattle: ; 3f4c1 ; This check prevents you from entering a battle without any Pokemon. ; Those using walk-through-walls to bypass getting a Pokemon experience ; the effects of this check. @@ -8371,14 +8297,13 @@ StartBattle: ; 3f4c1 ret ; 3f4d9 -_DoBattle: ; 3f4d9 -; unreferenced +Unreferenced_DoBattle: ; 3f4d9 call DoBattle ret ; 3f4dd BattleIntro: ; 3f4dd - farcall TrainerRankings_Battles ; mobile + farcall StubbedTrainerRankings_Battles ; mobile call LoadTrainerOrWildMonPic xor a ld [TempBattleMonSpecies], a @@ -8412,7 +8337,7 @@ BattleIntro: ; 3f4dd call ClearSprites ld a, [wBattleMode] cp WILD_BATTLE - call z, UpdateEnemyHUD + call z, Predef_UpdateEnemyHUD ld a, $1 ld [hBGMapMode], a ret @@ -8440,7 +8365,7 @@ InitEnemy: ; 3f55e BackUpBGMap2: ; 3f568 ld a, [rSVBK] push af - ld a, $6 ; BANK(wDecompressScratch) + ld a, BANK(wDecompressScratch) ld [rSVBK], a ld hl, wDecompressScratch ld bc, $40 tiles ; vBGMap3 - vBGMap2 @@ -8463,7 +8388,7 @@ BackUpBGMap2: ; 3f568 InitEnemyTrainer: ; 3f594 ld [TrainerClass], a - farcall TrainerRankings_TrainerBattles + farcall StubbedTrainerRankings_TrainerBattles xor a ld [TempEnemyMonSpecies], a callfar GetTrainerAttributes @@ -8477,20 +8402,20 @@ InitEnemyTrainer: ; 3f594 .ok ld de, vTiles2 - callfar GetTrainerPic + callfar Predef_GetTrainerPic xor a ld [hGraphicStartTile], a dec a ld [wEnemyItemState], a hlcoord 12, 0 lb bc, 7, 7 - predef PlaceGraphic + predef Predef_PlaceGraphic ld a, -1 ld [CurOTMon], a ld a, TRAINER_BATTLE ld [wBattleMode], a - call IsJohtoGymLeader + call IsGymLeader jr nc, .done xor a ld [CurPartyMon], a @@ -8519,7 +8444,7 @@ InitEnemyTrainer: ; 3f594 InitEnemyWildmon: ; 3f607 ld a, WILD_BATTLE ld [wBattleMode], a - farcall TrainerRankings_WildBattles + farcall StubbedTrainerRankings_WildBattles call LoadEnemyMon ld hl, EnemyMonMoves ld de, wWildMonMoves @@ -8530,7 +8455,7 @@ InitEnemyWildmon: ; 3f607 ld bc, NUM_MOVES call CopyBytes ld hl, EnemyMonDVs - predef GetUnownLetter + predef Predef_GetUnownLetter ld a, [CurPartySpecies] cp UNOWN jr nz, .skip_unown @@ -8541,18 +8466,17 @@ InitEnemyWildmon: ; 3f607 ld [wFirstUnownSeen], a .skip_unown ld de, vTiles2 - predef GetAnimatedFrontpicPredef + predef Predef_GetAnimatedFrontpic xor a ld [TrainerClass], a ld [hGraphicStartTile], a hlcoord 12, 0 lb bc, 7, 7 - predef PlaceGraphic + predef Predef_PlaceGraphic ret ; 3f662 -Function3f662: ; 3f662 -; XXX +Unreferenced_Function3f662: ; 3f662 ld hl, EnemyMonMoves ld de, wListMoves_MoveIndicesBuffer ld b, NUM_MOVES @@ -8627,7 +8551,7 @@ ExitBattle: ; 3f69e call CheckPayDay xor a ld [wForceEvolution], a - predef EvolveAfterBattle + predef Predef_EvolveAfterBattle farcall GivePokerusAndConvertBerries ret ; 3f6d0 @@ -8702,7 +8626,7 @@ CheckPayDay: ; 3f71d ; 3f759 ShowLinkBattleParticipantsAfterEnd: ; 3f759 - farcall TrainerRankings_LinkBattles + farcall StubbedTrainerRankings_LinkBattles farcall BackupMobileEventIndex ld a, [CurOTMon] ld hl, OTPartyMon1Status @@ -8732,17 +8656,17 @@ DisplayLinkBattleResult: ; 3f77c cp $1 jr c, .victory jr z, .loss - farcall TrainerRankings_ColosseumDraws + farcall StubbedTrainerRankings_ColosseumDraws ld de, .Draw jr .store_result .victory - farcall TrainerRankings_ColosseumWins + farcall StubbedTrainerRankings_ColosseumWins ld de, .Win jr .store_result .loss - farcall TrainerRankings_ColosseumLosses + farcall StubbedTrainerRankings_ColosseumLosses ld de, .Lose jr .store_result @@ -9301,7 +9225,7 @@ InitBattleDisplay: ; 3fb6c ld [hGraphicStartTile], a hlcoord 2, 6 lb bc, 6, 6 - predef PlaceGraphic + predef Predef_PlaceGraphic xor a ld [hWY], a ld [rWY], a @@ -9320,7 +9244,7 @@ InitBattleDisplay: ; 3fb6c .BlankBGMap: ; 3fbd6 ld a, [rSVBK] push af - ld a, $6 + ld a, BANK(wDecompressScratch) ld [rSVBK], a ld hl, wDecompressScratch @@ -9374,14 +9298,14 @@ GetTrainerBackpic: ; 3fbff .Decompress: ld de, vTiles2 tile $31 ld c, $31 - predef DecompressPredef + predef Predef_Decompress ret ; 3fc30 CopyBackpic: ; 3fc30 ld a, [rSVBK] push af - ld a, $6 + ld a, BANK(wDecompressScratch) ld [rSVBK], a ld hl, vTiles0 ld de, vTiles2 tile $31 @@ -9396,32 +9320,32 @@ CopyBackpic: ; 3fc30 ld [hGraphicStartTile], a hlcoord 2, 6 lb bc, 6, 6 - predef PlaceGraphic + predef Predef_PlaceGraphic ret ; 3fc5b .LoadTrainerBackpicAsOAM: ; 3fc5b - ld hl, Sprites + ld hl, Sprite01 xor a ld [hMapObjectIndexBuffer], a - ld b, $6 - ld e, 21 * 8 + ld b, 6 + ld e, (SCREEN_WIDTH + 1) * TILE_WIDTH .outer_loop - ld c, $3 - ld d, 8 * 8 + ld c, 3 + ld d, 8 * TILE_WIDTH .inner_loop - ld [hl], d + ld [hl], d ; y inc hl - ld [hl], e + ld [hl], e ; x inc hl ld a, [hMapObjectIndexBuffer] - ld [hli], a + ld [hli], a ; tile id inc a ld [hMapObjectIndexBuffer], a - ld a, $1 - ld [hli], a + ld a, PAL_BATTLE_OB_PLAYER + ld [hli], a ; attributes ld a, d - add $8 + add 1 * TILE_WIDTH ld d, a dec c jr nz, .inner_loop @@ -9429,7 +9353,7 @@ CopyBackpic: ; 3fc30 add $3 ld [hMapObjectIndexBuffer], a ld a, e - add $8 + add 1 * TILE_WIDTH ld e, a dec b jr nz, .outer_loop @@ -9476,7 +9400,7 @@ BattleStartMessage: ; 3fc8b hlcoord 12, 0 ld d, $0 ld e, ANIM_MON_NORMAL - predef AnimateFrontpic + predef Predef_AnimateFrontpic jr .skip_cry ; cry is played during the animation .cry_no_anim @@ -9490,7 +9414,7 @@ BattleStartMessage: ; 3fc8b cp BATTLETYPE_FISH jr nz, .NotFishing - farcall TrainerRankings_HookedEncounters + farcall StubbedTrainerRankings_HookedEncounters ld hl, HookedPokemonAttackedText jr .PlaceBattleStartText diff --git a/engine/battle/effect_commands.asm b/engine/battle/effect_commands.asm index f86f90479..c46ded638 100644 --- a/engine/battle/effect_commands.asm +++ b/engine/battle/effect_commands.asm @@ -64,7 +64,7 @@ DoMove: ; 3402c inc hl ld [de], a inc de - cp $ff + cp -1 jr nz, .GetMoveEffect ; Start at the first command. @@ -138,7 +138,7 @@ BattleCommand_CheckTurn: ; 34084 ld [AlreadyFailed], a ld [wSomeoneIsRampaging], a - ld a, 10 ; 1.0 + ld a, EFFECTIVE ld [TypeModifier], a ld a, [hBattleTurn] @@ -182,7 +182,7 @@ CheckPlayerTurn: call StdBattleTextBox call CantMove call UpdateBattleMonInParty - ld hl, UpdatePlayerHUD + ld hl, Predef_UpdatePlayerHUD call CallBattleCore ld a, $1 ld [hBGMapMode], a @@ -282,7 +282,7 @@ CheckPlayerTurn: ; 50% chance of hitting itself call BattleRandom - cp $80 + cp 50 percent + 1 jr nc, .not_confused ; clear confusion-dependent substatus @@ -311,7 +311,7 @@ CheckPlayerTurn: ; 50% chance of infatuation call BattleRandom - cp $80 + cp 50 percent + 1 jr c, .not_infatuated ld hl, InfatuationText @@ -345,7 +345,7 @@ CheckPlayerTurn: ; 25% chance to be fully paralyzed call BattleRandom - cp $3f + cp 25 percent ret nc ld hl, FullyParalyzedText @@ -433,7 +433,7 @@ CheckEnemyTurn: ; 3421f call StdBattleTextBox call CantMove call UpdateEnemyMonInParty - ld hl, UpdateEnemyHUD + ld hl, Predef_UpdateEnemyHUD call CallBattleCore ld a, $1 ld [hBGMapMode], a @@ -457,6 +457,8 @@ CheckEnemyTurn: ; 3421f ld hl, EnemyMonStatus bit FRZ, [hl] jr z, .not_frozen + + ; Flame Wheel and Sacred Fire thaw the user. ld a, [CurEnemyMove] cp FLAME_WHEEL jr z, .not_frozen @@ -611,7 +613,7 @@ CheckEnemyTurn: ; 3421f ; 25% chance to be fully paralyzed call BattleRandom - cp $3f + cp 25 percent ret nc ld hl, FullyParalyzedText @@ -670,7 +672,7 @@ HitConfusion: ; 343a5 and 1 << SUBSTATUS_FLYING | 1 << SUBSTATUS_UNDERGROUND call z, PlayFXAnimID - ld hl, UpdatePlayerHUD + ld hl, Predef_UpdatePlayerHUD call CallBattleCore ld a, $1 ld [hBGMapMode], a @@ -844,19 +846,20 @@ BattleCommand_CheckObedience: ; 343db .DoNothing: + ; 4 random choices call BattleRandom - and 3 + and %11 ld hl, LoafingAroundText - and a + and a ; 0 jr z, .Print ld hl, WontObeyText - dec a + dec a ; 1 jr z, .Print ld hl, TurnedAwayText - dec a + dec a ; 2 jr z, .Print ld hl, IgnoredOrdersText @@ -886,7 +889,7 @@ BattleCommand_CheckObedience: ; 343db .GetTotalPP: ld a, [hli] - and $3f ; exclude pp up + and PP_MASK add b ld b, a @@ -909,7 +912,7 @@ BattleCommand_CheckObedience: ; 343db ; Can't use another move if only one move has PP. ld a, [hl] - and $3f + and PP_MASK cp b jr z, .DoNothing @@ -929,7 +932,7 @@ BattleCommand_CheckObedience: ; 343db .RandomMove: call BattleRandom - and 3 ; TODO NUM_MOVES + maskbits NUM_MOVES +- 1 cp b jr nc, .RandomMove @@ -945,7 +948,7 @@ BattleCommand_CheckObedience: ; 343db ld d, 0 add hl, de ld a, [hl] - and $3f + and PP_MASK jr z, .RandomMove @@ -989,6 +992,7 @@ IgnoreSleepOnly: ; 3451f ld a, BATTLE_VARS_MOVE_ANIM call GetBattleVar + ; Snore and Sleep Talk bypass sleep. cp SNORE jr z, .CheckSleep cp SLEEP_TALK @@ -1115,7 +1119,7 @@ BattleCommand_DoTurn: ; 34555 ld b, 0 add hl, bc ld a, [hl] - and $3f + and PP_MASK jr z, .out_of_pp dec [hl] ld b, 0 @@ -1172,7 +1176,7 @@ BattleCommand_DoTurn: ; 34555 db EFFECT_ROLLOUT db EFFECT_BIDE db EFFECT_RAMPAGE - db $ff + db -1 ; 3460b CheckMimicUsed: ; 3460b @@ -1266,7 +1270,7 @@ BattleCommand_Critical: ; 34631 ld a, BATTLE_VARS_MOVE_ANIM call GetBattleVar ld de, 1 - ld hl, .Criticals + ld hl, CriticalHitMoves push bc call IsInArray pop bc @@ -1288,7 +1292,7 @@ BattleCommand_Critical: ; 34631 inc c .Tally: - ld hl, .Chances + ld hl, CriticalHitChances ld b, 0 add hl, bc call BattleRandom @@ -1298,12 +1302,7 @@ BattleCommand_Critical: ; 34631 ld [CriticalHit], a ret -.Criticals: - db KARATE_CHOP, RAZOR_WIND, RAZOR_LEAF, CRABHAMMER, SLASH, AEROBLAST, CROSS_CHOP, $ff -.Chances: - ; 6.25% 12.1% 24.6% 33.2% 49.6% 49.6% 49.6% - db $11, $20, $40, $55, $80, $80, $80 - ; 0 1 2 3 4 5 6 +INCLUDE "data/battle/critical_hits.asm" ; 346b2 @@ -1433,11 +1432,11 @@ BattleCommand_Stab: ; 346d2 .TypesLoop: ld a, [hli] - cp $ff + cp -1 jr z, .end ; foresight - cp $fe + cp -2 jr nz, .SkipForesightCheck ld a, BATTLE_VARS_SUBSTATUS1_OPP call GetBattleVar @@ -1539,12 +1538,12 @@ BattleCheckTypeMatchup: ; 347c8 ld hl, EnemyMonType1 ld a, [hBattleTurn] and a - jr z, CheckTypeMatchup + jr z, Predef_CheckTypeMatchup ld hl, BattleMonType1 -CheckTypeMatchup: ; 347d3 +Predef_CheckTypeMatchup: ; 347d3 ; There is an incorrect assumption about this function made in the AI related code: when -; the AI calls CheckTypeMatchup (not BattleCheckTypeMatchup), it assumes that placing the -; offensive type in a will make this function do the right thing. Since a is overwritten, +; the AI calls Predef_CheckTypeMatchup (not BattleCheckTypeMatchup), it assumes that placing +; the offensive type in a will make this function do the right thing. Since a is overwritten, ; this assumption is incorrect. A simple fix would be to load the move type for the ; current move into a in BattleCheckTypeMatchup, before falling through, which is ; consistent with how the rest of the code assumes this code works like. @@ -1562,9 +1561,9 @@ CheckTypeMatchup: ; 347d3 ld hl, TypeMatchups .TypesLoop: ld a, [hli] - cp $ff + cp -1 jr z, .End - cp $fe + cp -2 jr nz, .Next ld a, BATTLE_VARS_SUBSTATUS1_OPP call GetBattleVar @@ -1640,7 +1639,7 @@ BattleCommand_ResetTypeMatchup: ; 34833 INCLUDE "engine/battle/ai/switch.asm" -INCLUDE "data/type_matchups.asm" +INCLUDE "data/battle/type_matchups.asm" BattleCommand_DamageVariation: ; 34cfd ; damagevariation @@ -1675,7 +1674,7 @@ BattleCommand_DamageVariation: ; 34cfd .loop call BattleRandom rrca - cp $d9 ; 85% + cp 85 percent + 1 jr c, .loop ld [hMultiplier], a @@ -1756,7 +1755,7 @@ BattleCommand_CheckHit: ; 34d32 .skip_brightpowder ld a, b - cp $ff + cp -1 jr z, .Hit call BattleRandom @@ -1954,7 +1953,7 @@ BattleCommand_CheckHit: ; 34d32 .skip_foresight_check ; subtract evasion from 14 - ld a, 14 + ld a, MAX_STAT_LEVEL + 1 sub c ld c, a ; store the base move accuracy for math ops @@ -1969,7 +1968,7 @@ BattleCommand_CheckHit: ; 34d32 .accuracy_loop ; look up the multiplier from the table push bc - ld hl, .AccProb + ld hl, AccuracyLevelMultipliers dec b sla b ld c, b @@ -2013,21 +2012,7 @@ BattleCommand_CheckHit: ; 34d32 ld [hl], a ret -.AccProb: - db 33, 100 ; 33% -6 - db 36, 100 ; 36% -5 - db 43, 100 ; 43% -4 - db 50, 100 ; 50% -3 - db 60, 100 ; 60% -2 - db 75, 100 ; 75% -1 - db 1, 1 ; 100% 0 - db 133, 100 ; 133% +1 - db 166, 100 ; 166% +2 - db 2, 1 ; 200% +3 - db 233, 100 ; 233% +4 - db 133, 50 ; 266% +5 - db 3, 1 ; 300% +6 - +INCLUDE "data/battle/accuracy_multipliers.asm" ; 34ecc @@ -2199,7 +2184,7 @@ BattleCommand_HitTargetNoSub: ; 34f60 xor 1 ld [wKickCounter], a ld a, [de] - cp $1 + cp 1 push af ld a, BATTLE_VARS_MOVE_ANIM call GetBattleVar @@ -2438,7 +2423,7 @@ GetFailureResultText: ; 350e4 ld hl, AttackMissedText ld de, AttackMissed2Text ld a, [CriticalHit] - cp $ff + cp -1 jr nz, .got_text ld hl, UnaffectedText .got_text @@ -2636,7 +2621,7 @@ BattleCommand_CheckDestinyBond: ; 351c0 ld [Buffer6], a ld h, b ld l, c - predef AnimateHPBar + predef Predef_AnimateHPBar call RefreshBattleHuds call BattleCommand_SwitchTurn @@ -3519,7 +3504,7 @@ BattleCommand_DamageCalc: ; 35612 .NextItem: ld a, [hli] - cp $ff + cp -1 jr z, .DoneItem ; Item effect @@ -3657,26 +3642,7 @@ BattleCommand_DamageCalc: ; 35612 ; 35703 -TypeBoostItems: ; 35703 - db HELD_NORMAL_BOOST, NORMAL ; Pink/Polkadot Bow - db HELD_FIGHTING_BOOST, FIGHTING ; Blackbelt - db HELD_FLYING_BOOST, FLYING ; Sharp Beak - db HELD_POISON_BOOST, POISON ; Poison Barb - db HELD_GROUND_BOOST, GROUND ; Soft Sand - db HELD_ROCK_BOOST, ROCK ; Hard Stone - db HELD_BUG_BOOST, BUG ; Silverpowder - db HELD_GHOST_BOOST, GHOST ; Spell Tag - db HELD_FIRE_BOOST, FIRE ; Charcoal - db HELD_WATER_BOOST, WATER ; Mystic Water - db HELD_GRASS_BOOST, GRASS ; Miracle Seed - db HELD_ELECTRIC_BOOST, ELECTRIC ; Magnet - db HELD_PSYCHIC_BOOST, PSYCHIC ; Twistedspoon - db HELD_ICE_BOOST, ICE ; Nevermeltice - db HELD_DRAGON_BOOST, DRAGON ; Dragon Scale - db HELD_DARK_BOOST, DARK ; Blackglasses - db HELD_STEEL_BOOST, STEEL ; Metal Coat - db $ff -; 35726 +INCLUDE "data/battle/type_boost_items.asm" BattleCommand_ConstantDamage: ; 35726 @@ -3941,7 +3907,7 @@ BattleCommand_Encore: ; 35864 ld bc, BattleMonPP - BattleMonMoves - 1 add hl, bc ld a, [hl] - and $3f + and PP_MASK jp z, .failed ld a, [AttackMissed] and a @@ -4049,7 +4015,7 @@ BattleCommand_PainSplit: ; 35926 ld a, $1 ld [wWhichHPBar], a hlcoord 10, 9 - predef AnimateHPBar + predef Predef_AnimateHPBar ld hl, EnemyMonHP ld a, [hli] ld [Buffer4], a @@ -4064,7 +4030,7 @@ BattleCommand_PainSplit: ; 35926 ld [wWhichHPBar], a call ResetDamage hlcoord 2, 2 - predef AnimateHPBar + predef Predef_AnimateHPBar farcall _UpdateBattleHUDs ld hl, SharedPainText @@ -4206,7 +4172,7 @@ BattleCommand_Conversion2: ; 359e6 ld a, [hl] ld [wNamedObjectIndexBuffer], a - predef GetTypeName + predef Predef_GetTypeName ld hl, TransformedTypeText jp StdBattleTextBox @@ -4421,7 +4387,7 @@ BattleCommand_SleepTalk: ; 35b33 .sample_move push hl call BattleRandom - and 3 ; TODO factor in NUM_MOVES + maskbits NUM_MOVES +- 1 ld c, a ld b, 0 add hl, bc @@ -4585,17 +4551,18 @@ BattleCommand_Spite: ; 35c0f add hl, bc pop bc ld a, [hl] - and $3f + and PP_MASK jr z, .failed push bc call GetMoveName + ; lose 2-5 PP call BattleRandom - and 3 + and %11 inc a inc a ld b, a ld a, [hl] - and $3f + and PP_MASK cp b jr nc, .deplete_pp ld b, a @@ -4671,7 +4638,7 @@ BattleCommand_FalseSwipe: ; 35c94 ld [de], a .okay ld a, [CriticalHit] - cp $2 + cp 2 jr nz, .carry xor a ld [CriticalHit], a @@ -4744,7 +4711,7 @@ PlayFXAnimID: ; 35d08 ld c, 3 call DelayFrames - callfar PlayBattleAnim + callfar Predef_PlayBattleAnim ret @@ -4806,7 +4773,7 @@ EnemyHurtItself: ; 35d1c hlcoord 2, 2 xor a ld [wWhichHPBar], a - predef AnimateHPBar + predef Predef_AnimateHPBar .did_no_damage jp RefreshBattleHuds @@ -4866,7 +4833,7 @@ PlayerHurtItself: ; 35d7e hlcoord 10, 9 ld a, $1 ld [wWhichHPBar], a - predef AnimateHPBar + predef Predef_AnimateHPBar .did_no_damage jp RefreshBattleHuds @@ -5049,7 +5016,7 @@ BattleCommand_SleepTarget: ; 35e5c jr nz, .dont_fail call BattleRandom - cp $40 ; 25% + cp 25 percent + 1 ; 25% chance AI fails ret c .dont_fail @@ -5149,7 +5116,7 @@ BattleCommand_Poison: ; 35f2c jr nz, .mimic_random call BattleRandom - cp $40 ; 25% chance AI fails + cp 25 percent + 1 ; 25% chance AI fails jr c, .failed .mimic_random @@ -5334,7 +5301,7 @@ SapHealth: ; 36011 xor a .hp_bar ld [wWhichHPBar], a - predef AnimateHPBar + predef Predef_AnimateHPBar call RefreshBattleHuds jp UpdateBattleMonInParty @@ -5827,7 +5794,7 @@ BattleCommand_StatDown: ; 362e3 inc b .ComputerMiss: -; Computer opponents have a 1/4 chance of failing. +; Computer opponents have a 25% chance of failing. ld a, [hBattleTurn] and a jr z, .DidntMiss @@ -5852,7 +5819,7 @@ BattleCommand_StatDown: ; 362e3 jr z, .DidntMiss call BattleRandom - cp $40 + cp 25 percent + 1 ; 25% chance AI fails jr c, .Failed .DidntMiss: @@ -6104,7 +6071,7 @@ BattleCommand_StatDownFailText: ; 3646a GetStatName: ; 3648f - ld hl, .names + ld hl, StatNames ld c, "@" .CheckName: dec b @@ -6120,33 +6087,10 @@ GetStatName: ; 3648f ld bc, StringBuffer3 - StringBuffer2 jp CopyBytes -.names - db "ATTACK@" - db "DEFENSE@" - db "SPEED@" - db "SPCL.ATK@" - db "SPCL.DEF@" - db "ACCURACY@" - db "EVASION@" - db "ABILITY@" -; 364e6 - - -StatLevelMultipliers: ; 364e6 - db 25, 100 ; 0.25x - db 28, 100 ; 0.28x - db 33, 100 ; 0.33x - db 40, 100 ; 0.40x - db 50, 100 ; 0.50x - db 66, 100 ; 0.66x - db 1, 1 ; 1.00x - db 15, 10 ; 1.50x - db 2, 1 ; 2.00x - db 25, 10 ; 2.50x - db 3, 1 ; 3.00x - db 35, 10 ; 3.50x - db 4, 1 ; 4.00x -; 36500 +INCLUDE "data/battle/stat_names.asm" + + +INCLUDE "data/battle/stat_multipliers.asm" BattleCommand_AllStatsUp: ; 36500 @@ -6266,13 +6210,12 @@ BattleCommand_TriStatusChance: ; 3658f call BattleCommand_EffectChance -; 1/3 chance of each status .loop + ; 1/3 chance of each status call BattleRandom swap a - and 3 + and %11 jr z, .loop -; jump dec a ld hl, .ptrs rst JumpTable @@ -6296,11 +6239,11 @@ BattleCommand_Curl: ; 365a7 BattleCommand_RaiseSubNoAnim: ; 365af - ld hl, GetBattleMonBackpic + ld hl, Predef_GetBattleMonBackpic ld a, [hBattleTurn] and a jr z, .PlayerTurn - ld hl, GetEnemyMonFrontpic + ld hl, Predef_GetEnemyMonFrontpic .PlayerTurn: xor a ld [hBGMapMode], a @@ -7450,7 +7393,8 @@ BattleCommand_TrapTarget: ; 36c2d bit SUBSTATUS_SUBSTITUTE, a ret nz call BattleRandom - and 3 + ; trapped for 2-5 turns + and %11 inc a inc a inc a @@ -7581,7 +7525,7 @@ BattleCommand_Recoil: ; 36cb2 xor a .animate_hp_bar ld [wWhichHPBar], a - predef AnimateHPBar + predef Predef_AnimateHPBar call RefreshBattleHuds ld hl, RecoilText jp StdBattleTextBox @@ -7648,8 +7592,9 @@ BattleCommand_FinishConfusingTarget: ; 36d70 .got_confuse_count set SUBSTATUS_CONFUSED, [hl] + ; confused for 2-5 turns call BattleRandom - and 3 + and %11 inc a inc a ld [bc], a @@ -8078,7 +8023,7 @@ BattleCommand_LeechSeed: ; 36f9d BattleCommand_Splash: ; 36fe1 call AnimateCurrentMove - farcall TrainerRankings_Splash + farcall StubbedTrainerRankings_Splash jp PrintNothingHappened ; 36fed @@ -8259,7 +8204,7 @@ BattleCommand_Conversion: ; 3707f .done .loop3 call BattleRandom - and 3 ; TODO factor in NUM_MOVES + maskbits NUM_MOVES +- 1 ld c, a ld b, 0 ld hl, StringBuffer1 @@ -8282,7 +8227,7 @@ BattleCommand_Conversion: ; 3707f inc de ld [de], a ld [wNamedObjectIndexBuffer], a - farcall GetTypeName + farcall Predef_GetTypeName call AnimateCurrentMove ld hl, TransformedTypeText jp StdBattleTextBox @@ -8605,7 +8550,7 @@ CheckSubstituteOpp: ; 37378 BattleCommand_Selfdestruct: ; 37380 - farcall TrainerRankings_Selfdestruct + farcall StubbedTrainerRankings_Selfdestruct ld a, BATTLEANIM_PLAYER_DAMAGE ld [wNumHits], a ld c, 3 @@ -9911,7 +9856,7 @@ PlayUserBattleAnim: ; 37e47 push hl push de push bc - callfar PlayBattleAnim + callfar Predef_PlayBattleAnim pop bc pop de pop hl @@ -9933,7 +9878,7 @@ PlayOpponentBattleAnim: ; 37e54 push bc call BattleCommand_SwitchTurn - callfar PlayBattleAnim + callfar Predef_PlayBattleAnim call BattleCommand_SwitchTurn pop bc diff --git a/engine/battle/effect_commands/attract.asm b/engine/battle/effect_commands/attract.asm index 0a6d7c975..fc73d234c 100755 --- a/engine/battle/effect_commands/attract.asm +++ b/engine/battle/effect_commands/attract.asm @@ -35,7 +35,7 @@ CheckOppositeGender: ; 377f5 xor a ld [MonType], a - farcall GetGender + farcall Predef_GetGender jr c, .genderless_samegender ld b, 1 @@ -58,7 +58,7 @@ CheckOppositeGender: ; 377f5 ld [TempMonDVs + 1], a ld a, 3 ld [MonType], a - farcall GetGender + farcall Predef_GetGender pop bc jr c, .genderless_samegender diff --git a/engine/battle/effect_commands/present.asm b/engine/battle/effect_commands/present.asm index 819294f8c..2b358e8b9 100755 --- a/engine/battle/effect_commands/present.asm +++ b/engine/battle/effect_commands/present.asm @@ -31,7 +31,7 @@ BattleCommand_Present: ; 37874 ld c, 0 .next ld a, [hli] - cp $ff + cp -1 jr z, .heal_effect ; 378a4 $11 cp b jr nc, .got_power ; 378a7 $4 @@ -89,5 +89,5 @@ BattleCommand_Present: ; 37874 db 40 percent, 40 db 70 percent + 1, 80 db 80 percent, 120 - db $ff + db -1 ; end ; 3790e diff --git a/engine/battle/hidden_power.asm b/engine/battle/hidden_power.asm index c75a67ab3..a1d3957e4 100644 --- a/engine/battle/hidden_power.asm +++ b/engine/battle/hidden_power.asm @@ -16,12 +16,12 @@ HiddenPowerDamage: ; fbced ; Attack ld a, [hl] swap a - and 8 + and %1000 ; Defense ld b, a ld a, [hli] - and 8 + and %1000 srl a or b @@ -29,7 +29,7 @@ HiddenPowerDamage: ; fbced ld b, a ld a, [hl] swap a - and 8 + and %1000 srl a srl a or b @@ -37,7 +37,7 @@ HiddenPowerDamage: ; fbced ; Special ld b, a ld a, [hl] - and 8 + and %1000 srl a srl a srl a @@ -52,7 +52,7 @@ HiddenPowerDamage: ; fbced ; Add Special & 3 ld b, a ld a, [hld] - and 3 + and %0011 add b ; Divide by 2 and add 30 + 1 @@ -67,12 +67,12 @@ HiddenPowerDamage: ; fbced ; Def & 3 ld a, [hl] - and 3 + and %0011 ld b, a ; + (Atk & 3) << 2 ld a, [hl] - and 3 << 4 + and %0011 << 4 swap a add a add a diff --git a/engine/battle/menu.asm b/engine/battle/menu.asm index ccca4402a..dd3d4ef07 100755 --- a/engine/battle/menu.asm +++ b/engine/battle/menu.asm @@ -34,8 +34,7 @@ Function24f19: ; 24f19 BattleMenuDataHeader: ; 24f2c db MENU_BACKUP_TILES ; flags - db 12, 08 ; start coords - db 17, 19 ; end coords + menu_coords 8, 12, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1 dw MenuData_0x24f34 db 1 ; default option ; 24f34 @@ -57,8 +56,7 @@ Strings24f3d: ; 0x24f3d MenuDataHeader_0x24f4e: ; 24f4e db MENU_BACKUP_TILES ; flags - db 12, 00 ; start coords - db 17, 19 ; end coords + menu_coords 0, 12, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1 dw MenuData_0x24f56 db 1 ; default option ; 24f56 @@ -88,8 +86,7 @@ Function24f7c: ; 24f7c MenuDataHeader_0x24f89: ; 24f89 db MENU_BACKUP_TILES ; flags - db 12, 02 ; start coords - db 17, 19 ; end coords + menu_coords 2, 12, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1 dw MenuData_0x24f91 db 1 ; default option ; 24f91 diff --git a/engine/battle/misc.asm b/engine/battle/misc.asm index c78e9fd84..40c472e50 100644 --- a/engine/battle/misc.asm +++ b/engine/battle/misc.asm @@ -33,7 +33,7 @@ AppearUser: ; fbd77 (3e:7d77) ld a, $31 .okay ld [hGraphicStartTile], a - predef PlaceGraphic + predef Predef_PlaceGraphic FinishAppearDisappearUser: ; fbd91 (3e:7d91) ld a, $1 ld [hBGMapMode], a @@ -146,15 +146,15 @@ DoWeatherModifiers: ; fbda4 ret .WeatherTypeModifiers: - db WEATHER_RAIN, WATER, 15 - db WEATHER_RAIN, FIRE, 05 - db WEATHER_SUN, FIRE, 15 - db WEATHER_SUN, WATER, 05 - db $ff + db WEATHER_RAIN, WATER, MORE_EFFECTIVE + db WEATHER_RAIN, FIRE, NOT_VERY_EFFECTIVE + db WEATHER_SUN, FIRE, MORE_EFFECTIVE + db WEATHER_SUN, WATER, NOT_VERY_EFFECTIVE + db -1 ; end .WeatherMoveModifiers: - db WEATHER_RAIN, EFFECT_SOLARBEAM, 05 - db $ff + db WEATHER_RAIN, EFFECT_SOLARBEAM, NOT_VERY_EFFECTIVE + db -1 ; end ; fbe24 @@ -183,7 +183,7 @@ DoBadgeTypeBoosts: ; fbe24 .CheckBadge: ld a, [hl] - cp $ff + cp -1 jr z, .done srl b @@ -236,22 +236,24 @@ DoBadgeTypeBoosts: ; fbe24 ret .BadgeTypes: - db FLYING ; zephyrbadge - db BUG ; hivebadge - db NORMAL ; plainbadge - db GHOST ; fogbadge - db STEEL ; mineralbadge - db FIGHTING ; stormbadge - db ICE ; glacierbadge - db DRAGON ; risingbadge - - db ROCK ; boulderbadge - db WATER ; cascadebadge - db ELECTRIC ; thunderbadge - db GRASS ; rainbowbadge - db POISON ; soulbadge - db PSYCHIC ; marshbadge - db FIRE ; volcanobadge - db GROUND ; earthbadge - db $ff +; entries correspond to wJohtoBadges constants + db FLYING ; ZEPHYRBADGE + db BUG ; HIVEBADGE + db NORMAL ; PLAINBADGE + db GHOST ; FOGBADGE + db STEEL ; MINERALBADGE + db FIGHTING ; STORMBADGE + db ICE ; GLACIERBADGE + db DRAGON ; RISINGBADGE + ; fallthrough +; entries correspond to wKantoBadges constants + db ROCK ; BOULDERBADGE + db WATER ; CASCADEBADGE + db ELECTRIC ; THUNDERBADGE + db GRASS ; RAINBOWBADGE + db POISON ; SOULBADGE + db PSYCHIC ; MARSHBADGE + db FIRE ; VOLCANOBADGE + db GROUND ; EARTHBADGE + db -1 ; end ; fbe91 diff --git a/engine/battle/read_trainer_party.asm b/engine/battle/read_trainer_party.asm index a09c6dd08..4f3dc8e55 100755 --- a/engine/battle/read_trainer_party.asm +++ b/engine/battle/read_trainer_party.asm @@ -103,7 +103,7 @@ TrainerType1: ; 397eb ld a, OTPARTYMON ld [MonType], a push hl - predef TryAddMonToParty + predef Predef_TryAddMonToParty pop hl jr .loop ; 39806 @@ -124,7 +124,7 @@ TrainerType2: ; 39806 ld [MonType], a push hl - predef TryAddMonToParty + predef Predef_TryAddMonToParty ld a, [OTPartyCount] dec a ld hl, OTPartyMon1Moves @@ -200,7 +200,7 @@ TrainerType3: ; 39871 ld a, OTPARTYMON ld [MonType], a push hl - predef TryAddMonToParty + predef Predef_TryAddMonToParty ld a, [OTPartyCount] dec a ld hl, OTPartyMon1Item @@ -231,7 +231,7 @@ TrainerType4: ; 3989d ld [MonType], a push hl - predef TryAddMonToParty + predef Predef_TryAddMonToParty ld a, [OTPartyCount] dec a ld hl, OTPartyMon1Item diff --git a/engine/battle/returntobattle_useball.asm b/engine/battle/returntobattle_useball.asm index e6e33f900..4254d24f4 100644 --- a/engine/battle/returntobattle_useball.asm +++ b/engine/battle/returntobattle_useball.asm @@ -4,13 +4,13 @@ _ReturnToBattle_UseBall: ; 2715c ld a, [BattleType] cp BATTLETYPE_TUTORIAL jr z, .gettutorialbackpic - farcall GetBattleMonBackpic + farcall Predef_GetBattleMonBackpic jr .continue .gettutorialbackpic farcall GetTrainerBackpic .continue - farcall GetEnemyMonFrontpic + farcall Predef_GetEnemyMonFrontpic farcall _LoadBattleFontsHPBar call GetMemSGBLayout call CloseWindow diff --git a/engine/battle/sliding_intro.asm b/engine/battle/sliding_intro.asm index ed78add8e..418454283 100755 --- a/engine/battle/sliding_intro.asm +++ b/engine/battle/sliding_intro.asm @@ -1,7 +1,7 @@ BattleIntroSlidingPics: ; 4e980 ld a, [rSVBK] push af - ld a, $5 + ld a, BANK(LYOverrides) ld [rSVBK], a call .subfunction1 ld a, rSCX - $ff00 @@ -60,9 +60,9 @@ BattleIntroSlidingPics: ; 4e980 ; 4e9d6 .subfunction3 ; 4e9d6 - ld hl, Sprites + 1 ; x pixel + ld hl, Sprite01XCoord ld c, $12 ; 18 - ld de, $4 + ld de, SPRITEOAMSTRUCT_LENGTH .loop3 dec [hl] dec [hl] diff --git a/engine/battle/start_battle.asm b/engine/battle/start_battle.asm index 7f0bff96b..b97eda1b3 100644 --- a/engine/battle/start_battle.asm +++ b/engine/battle/start_battle.asm @@ -33,7 +33,7 @@ FindFirstAliveMonAndStartBattle: ; 2ee2f add hl, de ld a, [hl] ld [BattleMonLevel], a - predef Predef_StartBattle + predef Predef_DoBattleTransition farcall _LoadBattleFontsHPBar ld a, 1 ld [hBGMapMode], a @@ -93,7 +93,7 @@ PlayBattleMusic: ; 2ee6c cp RED jr z, .done - ; really, they should have included admins and scientists here too... + ; They should have included EXECUTIVEM, EXECUTIVEF, and SCIENTIST too... ld de, MUSIC_ROCKET_BATTLE cp GRUNTM jr z, .done @@ -104,8 +104,10 @@ PlayBattleMusic: ; 2ee6c farcall IsKantoGymLeader jr c, .done + ; IsGymLeader also counts CHAMPION, RED, and the Kanto gym leaders + ; but they have been taken care of before this ld de, MUSIC_JOHTO_GYM_LEADER_BATTLE - farcall IsJohtoGymLeader + farcall IsGymLeader jr c, .done ld de, MUSIC_RIVAL_BATTLE diff --git a/engine/battle/trainer_huds.asm b/engine/battle/trainer_huds.asm index b236fc56b..179cc806d 100755 --- a/engine/battle/trainer_huds.asm +++ b/engine/battle/trainer_huds.asm @@ -28,7 +28,7 @@ ShowPlayerMonsRemaining: ; 2c01c ld [hl], a ld a, 8 ld [wPlaceBallsDirection], a - ld hl, Sprites + ld hl, Sprite01 jp LoadTrainerHudOAM ; 2c03a @@ -44,7 +44,7 @@ ShowOTTrainerMonsRemaining: ; 2c03a ld [hl], 4 * 8 ld a, -8 ld [wPlaceBallsDirection], a - ld hl, Sprites + PARTY_LENGTH * 4 + ld hl, Sprite07 jp LoadTrainerHudOAM ; 2c059 @@ -193,7 +193,7 @@ LinkBattle_TrainerHuds: ; 2c10d ld [hl], 8 * 8 ld a, $8 ld [wPlaceBallsDirection], a - ld hl, Sprites + ld hl, Sprite01 call LoadTrainerHudOAM ld hl, OTPartyMon1HP @@ -203,7 +203,7 @@ LinkBattle_TrainerHuds: ; 2c10d ld a, 10 * 8 ld [hli], a ld [hl], 13 * 8 - ld hl, Sprites + PARTY_LENGTH * 4 + ld hl, Sprite07 jp LoadTrainerHudOAM ; 2c143 @@ -212,13 +212,13 @@ LoadTrainerHudOAM: ; 2c143 ld c, PARTY_LENGTH .loop ld a, [wPlaceBallsY] - ld [hli], a + ld [hli], a ; y ld a, [wPlaceBallsX] - ld [hli], a + ld [hli], a ; x ld a, [de] - ld [hli], a - ld a, $3 - ld [hli], a + ld [hli], a ; tile id + ld a, PAL_BATTLE_OB_YELLOW + ld [hli], a ; attributes ld a, [wPlaceBallsX] ld b, a ld a, [wPlaceBallsDirection] diff --git a/engine/battle/used_move_text.asm b/engine/battle/used_move_text.asm index ce9e51359..1b5aa564c 100755 --- a/engine/battle/used_move_text.asm +++ b/engine/battle/used_move_text.asm @@ -157,12 +157,12 @@ GetMoveGrammar: ; 105e5c .loop ld a, [hli] ; end of table? - cp $ff + cp -1 jr z, .end ; match? cp c jr z, .end -; advance grammar type at $00 +; advance grammar type at 0 and a jr nz, .loop ; next grammar type @@ -179,106 +179,7 @@ GetMoveGrammar: ; 105e5c ret ; 105e7a -MoveGrammar: ; 105e7a -; made redundant in localization -; each move is given an identifier for what usedmovetext to use (0-4): - -; 0 - db SWORDS_DANCE - db GROWTH - db STRENGTH - db HARDEN - db MINIMIZE - db SMOKESCREEN - db WITHDRAW - db DEFENSE_CURL - db EGG_BOMB - db SMOG - db BONE_CLUB - db FLASH - db SPLASH - db ACID_ARMOR - db BONEMERANG - db REST - db SHARPEN - db SUBSTITUTE - db MIND_READER - db SNORE - db PROTECT - db SPIKES - db ENDURE - db ROLLOUT - db SWAGGER - db SLEEP_TALK - db HIDDEN_POWER - db PSYCH_UP - db EXTREMESPEED - db 0 ; end set - -; 1 - db RECOVER - db TELEPORT - db BIDE - db SELFDESTRUCT - db AMNESIA - db FLAIL - db 0 ; end set - -; 2 - db MEDITATE - db AGILITY - db MIMIC - db DOUBLE_TEAM - db BARRAGE - db TRANSFORM - db STRUGGLE - db SCARY_FACE - db 0 ; end set - -; 3 - db POUND - db SCRATCH - db VICEGRIP - db WING_ATTACK - db FLY - db BIND - db SLAM - db HORN_ATTACK - db WRAP - db THRASH - db TAIL_WHIP - db LEER - db BITE - db GROWL - db ROAR - db SING - db PECK - db ABSORB - db STRING_SHOT - db EARTHQUAKE - db FISSURE - db DIG - db TOXIC - db SCREECH - db METRONOME - db LICK - db CLAMP - db CONSTRICT - db POISON_GAS - db BUBBLE - db SLASH - db SPIDER_WEB - db NIGHTMARE - db CURSE - db FORESIGHT - db CHARM - db ATTRACT - db ROCK_SMASH - db 0 ; end set - -; all other moves = 4 - db $ff ; end -; 105ed0 +INCLUDE "data/moves/grammar.asm" UpdateUsedMoves: ; 105ed0 diff --git a/engine/battle_anims/anim_commands.asm b/engine/battle_anims/anim_commands.asm index 27d57e68f..ee13fbd96 100644 --- a/engine/battle_anims/anim_commands.asm +++ b/engine/battle_anims/anim_commands.asm @@ -1,11 +1,11 @@ ; Battle animation command interpreter. -PlayBattleAnim: ; cc0d6 +Predef_PlayBattleAnim: ; cc0d6 ld a, [rSVBK] push af - ld a, 5 + ld a, BANK(ActiveAnimObjects) ld [rSVBK], a call _PlayBattleAnim @@ -163,11 +163,11 @@ BattleAnimRestoreHuds: ; cc1bb ld a, [rSVBK] push af - ld a, $1 + ld a, BANK(CurBattleMon) ; alternatively: BANK(TempMon), BANK(PartyMon1), several others ld [rSVBK], a ld hl, UpdateBattleHuds - ld a, BANK(UpdatePlayerHUD) + ld a, BANK(Predef_UpdatePlayerHUD) rst FarCall ; Why not "call UpdateBattleHuds"? pop af @@ -232,8 +232,7 @@ ClearActorHud: ; cc207 ret ; cc220 -Functioncc220: ; cc220 -; Appears to be unused. +Unreferenced_Functioncc220: ; cc220 xor a ld [hBGMapMode], a ld a, LOW(vBGMap0 tile $28) @@ -258,15 +257,15 @@ BattleAnim_ClearCGB_OAMFlags: ; cc23d bit 3, a jr z, .delete - ld hl, Sprites + 3 - ld c, (SpritesEnd - Sprites) / 4 + ld hl, Sprite01Attributes + ld c, NUM_SPRITE_OAM_STRUCTS .loop ld a, [hl] and $f0 ld [hli], a +rept SPRITEOAMSTRUCT_LENGTH +- 1 inc hl - inc hl - inc hl +endr dec c jr nz, .loop ret @@ -917,7 +916,7 @@ BattleAnimCmd_E7: ; cc5db (33:45db) BattleAnimCmd_Transform: ; cc5dc (33:45dc) ld a, [rSVBK] push af - ld a, 1 + ld a, BANK(CurPartySpecies) ld [rSVBK], a ld a, [CurPartySpecies] ; CurPartySpecies push af @@ -929,18 +928,18 @@ BattleAnimCmd_Transform: ; cc5dc (33:45dc) ld a, [TempBattleMonSpecies] ; TempBattleMonSpecies ld [CurPartySpecies], a ; CurPartySpecies ld hl, BattleMonDVs ; BattleMonDVs - predef GetUnownLetter + predef Predef_GetUnownLetter ld de, vTiles0 tile $00 - predef GetMonFrontpic + predef Predef_GetMonFrontpic jr .done .player ld a, [TempEnemyMonSpecies] ; TempEnemyMonSpecies ld [CurPartySpecies], a ; CurPartySpecies ld hl, EnemyMonDVs ; EnemyMonDVs - predef GetUnownLetter + predef Predef_GetUnownLetter ld de, vTiles0 tile $00 - predef GetMonBackpic + predef Predef_GetMonBackpic .done pop af @@ -973,9 +972,9 @@ BattleAnimCmd_RaiseSub: ; cc640 (33:4640) ld a, [rSVBK] push af - ld a, 1 + ld a, 1 ; unnecessary bankswitch? ld [rSVBK], a - xor a + xor a ; sScratch call GetSRAMBank GetSubstitutePic: ; cc64c @@ -1047,9 +1046,9 @@ GetSubstitutePic: ; cc64c BattleAnimCmd_MinimizeOpp: ; cc6cf (33:46cf) ld a, [rSVBK] push af - ld a, $1 + ld a, 1 ; unnecessary bankswitch? ld [rSVBK], a - xor a + xor a ; sScratch call GetSRAMBank call GetMinimizePic call Request2bpp @@ -1077,7 +1076,7 @@ GetMinimizePic: ; cc6e7 (33:46e7) call CopyMinimizePic ld hl, vTiles2 tile $00 ld de, sScratch - lb bc, BANK(GetMinimizePic), $31 + lb bc, BANK(GetMinimizePic), 7 * 7 ret .player @@ -1085,7 +1084,7 @@ GetMinimizePic: ; cc6e7 (33:46e7) call CopyMinimizePic ld hl, vTiles2 tile $31 ld de, sScratch - lb bc, BANK(GetMinimizePic), $24 + lb bc, BANK(GetMinimizePic), 6 * 6 ret CopyMinimizePic: ; cc719 (33:4719) @@ -1103,9 +1102,9 @@ INCBIN "gfx/battle/minimize.2bpp" BattleAnimCmd_Minimize: ; cc735 (33:4735) ld a, [rSVBK] push af - ld a, $1 + ld a, 1 ; unnecessary bankswitch? ld [rSVBK], a - xor a + xor a ; sScratch call GetSRAMBank call GetMinimizePic ld hl, vTiles0 tile $00 @@ -1118,7 +1117,7 @@ BattleAnimCmd_Minimize: ; cc735 (33:4735) BattleAnimCmd_DropSub: ; cc750 (33:4750) ld a, [rSVBK] push af - ld a, $1 + ld a, BANK(CurPartySpecies) ld [rSVBK], a ld a, [CurPartySpecies] ; CurPartySpecies @@ -1143,7 +1142,7 @@ BattleAnimCmd_DropSub: ; cc750 (33:4750) BattleAnimCmd_BeatUp: ; cc776 (33:4776) ld a, [rSVBK] push af - ld a, $1 + ld a, BANK(CurPartySpecies) ld [rSVBK], a ld a, [CurPartySpecies] ; CurPartySpecies push af @@ -1156,16 +1155,16 @@ BattleAnimCmd_BeatUp: ; cc776 (33:4776) jr z, .player ld hl, BattleMonDVs - predef GetUnownLetter + predef Predef_GetUnownLetter ld de, vTiles2 tile $00 - predef GetMonFrontpic + predef Predef_GetMonFrontpic jr .done .player ld hl, EnemyMonDVs - predef GetUnownLetter + predef Predef_GetUnownLetter ld de, vTiles2 tile $31 - predef GetMonBackpic + predef Predef_GetMonBackpic .done pop af @@ -1207,7 +1206,7 @@ BattleAnimCmd_Sound: ; cc7cd (33:47cd) srl a ld [wSFXDuration], a call .GetCryTrack - and 3 + maskbits NUM_NOISE_CHANS +- 1 ld [CryTracks], a ; CryTracks ld e, a @@ -1244,7 +1243,7 @@ BattleAnimCmd_Sound: ; cc7cd (33:47cd) BattleAnimCmd_Cry: ; cc807 (33:4807) call GetBattleAnimByte - and 3 + maskbits NUM_NOISE_CHANS +- 1 ld e, a ld d, 0 ld hl, .CryData @@ -1254,7 +1253,7 @@ endr ld a, [rSVBK] push af - ld a, 1 + ld a, BANK(EnemyMon) ; BattleMon is in WRAM0, but EnemyMon is in WRAMX ld [rSVBK], a ld a, [hBattleTurn] @@ -1262,14 +1261,14 @@ endr jr nz, .enemy ld a, $f0 - ld [CryTracks], a ; CryTracks - ld a, [BattleMonSpecies] ; BattleMonSpecies + ld [CryTracks], a + ld a, [BattleMonSpecies] jr .done_cry_tracks .enemy ld a, $0f - ld [CryTracks], a ; CryTracks - ld a, [EnemyMonSpecies] ; EnemyMon + ld [CryTracks], a + ld a, [EnemyMonSpecies] .done_cry_tracks push hl @@ -1431,7 +1430,7 @@ BattleAnim_SetBGPals: ; cc91a ret z ld a, [rSVBK] push af - ld a, $5 + ld a, BANK(wBGPals1) ld [rSVBK], a ld hl, wBGPals2 ld de, wBGPals1 @@ -1459,7 +1458,7 @@ BattleAnim_SetOBPals: ; cc94b ret z ld a, [rSVBK] push af - ld a, $5 + ld a, BANK(wOBPals1) ld [rSVBK], a ld hl, wOBPals2 palette PAL_BATTLE_OB_GRAY ld de, wOBPals1 palette PAL_BATTLE_OB_GRAY diff --git a/engine/battle_anims/bg_effects.asm b/engine/battle_anims/bg_effects.asm index bb8feb1f9..a7c2012e5 100644 --- a/engine/battle_anims/bg_effects.asm +++ b/engine/battle_anims/bg_effects.asm @@ -506,13 +506,13 @@ BattleBGEffect_HeadFollow: ; c8281 (32:4281) push bc call BGEffect_CheckBattleTurn jr nz, .player_turn - ld a, ANIM_OBJ_BA + ld a, ANIM_OBJ_PLAYERHEADFOLLOW ld [wBattleAnimTemp0], a ld a, 16 * 8 + 4 jr .okay .player_turn - ld a, ANIM_OBJ_BB + ld a, ANIM_OBJ_ENEMYHEADFOLLOW ld [wBattleAnimTemp0], a ld a, 6 * 8 .okay @@ -2578,7 +2578,7 @@ BGEffects_LoadBGPal0_OBPal1: ; c8e52 (32:4e52) ld h, a ld a, [rSVBK] push af - ld a, $5 + ld a, BANK(wBGPals1) ld [rSVBK], a ld a, h push bc @@ -2605,7 +2605,7 @@ BGEffects_LoadBGPal1_OBPal0: ; c8e7f (32:4e7f) ld h, a ld a, [rSVBK] push af - ld a, $5 + ld a, BANK(wBGPals1) ld [rSVBK], a ld a, h push bc diff --git a/engine/battle_anims/engine.asm b/engine/battle_anims/core.asm index 55adeae8c..55adeae8c 100755 --- a/engine/battle_anims/engine.asm +++ b/engine/battle_anims/core.asm diff --git a/engine/battle_anims/functions.asm b/engine/battle_anims/functions.asm index ea9fb70b3..5e85ffdb0 100755 --- a/engine/battle_anims/functions.asm +++ b/engine/battle_anims/functions.asm @@ -428,9 +428,9 @@ GetBallAnimPal: ; cd249 (33:5249) ld hl, BallColors ld a, [rSVBK] push af - ld a, $1 + ld a, BANK(CurItem) ld [rSVBK], a - ld a, [CurItem] ; CurItem + ld a, [CurItem] ld e, a pop af ld [rSVBK], a @@ -4083,18 +4083,19 @@ BattleAnim_IncAnonJumptableIndex: ; ce72c (33:672c) ret BattleAnim_Cosine: ; ce732 (33:6732) - add $10 +; a = d * cos(a * pi/32) + add %010000 BattleAnim_Sine: ; ce734 (33:6734) -; a = d sin a - and $3f - cp $20 +; a = d * sin(a * pi/32) + and %111111 + cp %100000 jr nc, .negative call .ApplySineWave ld a, h ret .negative - and $1f + and %011111 call .ApplySineWave ld a, h xor $ff @@ -4111,7 +4112,7 @@ BattleAnim_Sine: ; ce734 (33:6734) ld e, [hl] inc hl ld d, [hl] - ld hl, $0 + ld hl, 0 .multiply srl a jr nc, .even diff --git a/engine/battle_anims/getpokeballwobble.asm b/engine/battle_anims/getpokeballwobble.asm index 7fb4d3e38..2bc53d798 100755 --- a/engine/battle_anims/getpokeballwobble.asm +++ b/engine/battle_anims/getpokeballwobble.asm @@ -8,7 +8,7 @@ GetPokeBallWobble: ; f971 (3:7971) ld d, a push de - ld a, 1 ; BANK(Buffer2) + ld a, BANK(Buffer2) ld [rSVBK], a ld a, [Buffer2] diff --git a/engine/billspc.asm b/engine/billspc.asm index 10034c806..596679118 100755 --- a/engine/billspc.asm +++ b/engine/billspc.asm @@ -136,7 +136,7 @@ _DepositPKMN: ; e2391 (38:6391) jp c, BillsPCDepositFuncCancel ld a, [wMenuCursorY] dec a - and $3 + and %11 ld e, a ld d, 0 ld hl, BillsPCDepositJumptable @@ -230,8 +230,7 @@ BillsPCDepositFuncCancel: ; e2537 (38:6537) BillsPCDepositMenuDataHeader: ; 0xe253d (38:653d) db MENU_BACKUP_TILES ; flags - db 04, 09 ; start coords - db 13, 19 ; end coords + menu_coords 9, 4, SCREEN_WIDTH - 1, 13 dw .MenuData2 db 1 ; default option ; 0xe2545 @@ -245,8 +244,7 @@ BillsPCDepositMenuDataHeader: ; 0xe253d (38:653d) db "CANCEL@" ; 0xe2564 (38:6564) -BillsPC_ClearThreeBoxes: ; e2564 -; unreferenced +Unreferenced_BillsPCClearThreeBoxes: ; e2564 hlcoord 0, 0 ld b, 4 ld c, 8 @@ -401,7 +399,7 @@ BillsPC_Withdraw: ; e2675 (38:6675) jp c, .cancel ld a, [wMenuCursorY] dec a - and 3 + and %11 ld e, a ld d, 0 ld hl, .dw @@ -491,8 +489,7 @@ BillsPC_Withdraw: ; e2675 (38:6675) .MenuDataHeader: ; 0xe2731 db MENU_BACKUP_TILES ; flags - db 04, 09 ; start coords - db 13, 19 ; end coords + menu_coords 9, 4, SCREEN_WIDTH - 1, 13 dw .MenuData db 1 ; default option ; 0xe2739 @@ -663,7 +660,7 @@ _MovePKMNWithoutMail: ; e2759 jp c, .Cancel ld a, [wMenuCursorY] dec a - and 3 + and %11 ld e, a ld d, 0 ld hl, .Jumptable2 @@ -715,8 +712,7 @@ _MovePKMNWithoutMail: ; e2759 .MenuDataHeader: ; 0xe28c3 db MENU_BACKUP_TILES ; flags - db 04, 09 ; start coords - db 13, 19 ; end coords + menu_coords 9, 4, SCREEN_WIDTH - 1, 13 dw .MenuData2 db 1 ; default option ; 0xe28cb @@ -1099,10 +1095,10 @@ PCMonInfo: ; e2ac6 (38:6ac6) ld [CurPartySpecies], a ld [CurSpecies], a ld hl, TempMonDVs - predef GetUnownLetter + predef Predef_GetUnownLetter call GetBaseData ld de, vTiles2 tile $00 - predef GetMonFrontpic + predef Predef_GetMonFrontpic xor a ld [wBillsPC_MonHasMail], a ld a, [CurPartySpecies] @@ -1119,7 +1115,7 @@ PCMonInfo: ; e2ac6 (38:6ac6) ld a, $3 ld [MonType], a - farcall GetGender + farcall Predef_GetGender jr c, .skip_gender ld a, "♂" jr nz, .printgender @@ -1502,7 +1498,7 @@ BillsPC_UpdateSelectionCursor: ; e2e01 (38:6e01) .place_cursor ld hl, .OAM - ld de, Sprites + ld de, Sprite01 .loop ld a, [hl] cp -1 @@ -1512,9 +1508,9 @@ BillsPC_UpdateSelectionCursor: ; e2e01 (38:6e01) swap a add [hl] inc hl - ld [de], a + ld [de], a ; y inc de -rept 3 +rept SPRITEOAMSTRUCT_LENGTH +- 1 ld a, [hli] ld [de], a inc de @@ -1523,36 +1519,36 @@ endr ; e2e2b (38:6e2b) .OAM: ; e2e2b - dsprite 4, 6, 10, 0, $00, $00 - dsprite 4, 6, 11, 0, $00, $00 - dsprite 4, 6, 12, 0, $00, $00 - dsprite 4, 6, 13, 0, $00, $00 - dsprite 4, 6, 14, 0, $00, $00 - dsprite 4, 6, 15, 0, $00, $00 - dsprite 4, 6, 16, 0, $00, $00 - dsprite 4, 6, 17, 0, $00, $00 - dsprite 4, 6, 18, 0, $00, $00 - dsprite 4, 6, 18, 7, $00, $00 - dsprite 7, 1, 10, 0, $00, $40 - dsprite 7, 1, 11, 0, $00, $40 - dsprite 7, 1, 12, 0, $00, $40 - dsprite 7, 1, 13, 0, $00, $40 - dsprite 7, 1, 14, 0, $00, $40 - dsprite 7, 1, 15, 0, $00, $40 - dsprite 7, 1, 16, 0, $00, $40 - dsprite 7, 1, 17, 0, $00, $40 - dsprite 7, 1, 18, 0, $00, $40 - dsprite 7, 1, 18, 7, $00, $40 - dsprite 5, 6, 9, 6, $01, $00 - dsprite 6, 1, 9, 6, $01, $40 - dsprite 5, 6, 19, 1, $01, $20 - dsprite 6, 1, 19, 1, $01, $60 + dsprite 4, 6, 10, 0, $00, 0 + dsprite 4, 6, 11, 0, $00, 0 + dsprite 4, 6, 12, 0, $00, 0 + dsprite 4, 6, 13, 0, $00, 0 + dsprite 4, 6, 14, 0, $00, 0 + dsprite 4, 6, 15, 0, $00, 0 + dsprite 4, 6, 16, 0, $00, 0 + dsprite 4, 6, 17, 0, $00, 0 + dsprite 4, 6, 18, 0, $00, 0 + dsprite 4, 6, 18, 7, $00, 0 + dsprite 7, 1, 10, 0, $00, 0 | Y_FLIP + dsprite 7, 1, 11, 0, $00, 0 | Y_FLIP + dsprite 7, 1, 12, 0, $00, 0 | Y_FLIP + dsprite 7, 1, 13, 0, $00, 0 | Y_FLIP + dsprite 7, 1, 14, 0, $00, 0 | Y_FLIP + dsprite 7, 1, 15, 0, $00, 0 | Y_FLIP + dsprite 7, 1, 16, 0, $00, 0 | Y_FLIP + dsprite 7, 1, 17, 0, $00, 0 | Y_FLIP + dsprite 7, 1, 18, 0, $00, 0 | Y_FLIP + dsprite 7, 1, 18, 7, $00, 0 | Y_FLIP + dsprite 5, 6, 9, 6, $01, 0 + dsprite 6, 1, 9, 6, $01, 0 | Y_FLIP + dsprite 5, 6, 19, 1, $01, 0 | X_FLIP + dsprite 6, 1, 19, 1, $01, 0 | X_FLIP | Y_FLIP db -1 ; e2e8c BillsPC_UpdateInsertCursor: ; e2e8c ld hl, .OAM - ld de, Sprites + ld de, Sprite01 .loop ld a, [hl] cp -1 @@ -1562,9 +1558,9 @@ BillsPC_UpdateInsertCursor: ; e2e8c swap a add [hl] inc hl - ld [de], a + ld [de], a ; y inc de -rept 3 +rept SPRITEOAMSTRUCT_LENGTH +- 1 ld a, [hli] ld [de], a inc de @@ -1573,20 +1569,20 @@ endr ; e2eac .OAM: ; e2eac - dsprite 4, 7, 10, 0, $06, $00 - dsprite 5, 3, 11, 0, $00, $40 - dsprite 5, 3, 12, 0, $00, $40 - dsprite 5, 3, 13, 0, $00, $40 - dsprite 5, 3, 14, 0, $00, $40 - dsprite 5, 3, 15, 0, $00, $40 - dsprite 5, 3, 16, 0, $00, $40 - dsprite 5, 3, 17, 0, $00, $40 - dsprite 5, 3, 18, 0, $00, $40 - dsprite 4, 7, 19, 0, $07, $00 + dsprite 4, 7, 10, 0, $06, 0 + dsprite 5, 3, 11, 0, $00, 0 | Y_FLIP + dsprite 5, 3, 12, 0, $00, 0 | Y_FLIP + dsprite 5, 3, 13, 0, $00, 0 | Y_FLIP + dsprite 5, 3, 14, 0, $00, 0 | Y_FLIP + dsprite 5, 3, 15, 0, $00, 0 | Y_FLIP + dsprite 5, 3, 16, 0, $00, 0 | Y_FLIP + dsprite 5, 3, 17, 0, $00, 0 | Y_FLIP + dsprite 5, 3, 18, 0, $00, 0 | Y_FLIP + dsprite 4, 7, 19, 0, $07, 0 db -1 ; e2ed5 -BillsPC_UnusedFillBox: ; e2ed5 +Unreferenced_BillsPC_FillBox: ; e2ed5 .row push bc push hl @@ -1702,7 +1698,7 @@ BillsPC_StatsScreen: ; e2f7e (38:6f7e) call BillsPC_CopyMon ld a, $3 ld [MonType], a - predef StatsScreenInit + predef Predef_StatsScreenInit call BillsPC_InitGFX call MaxVolume ret @@ -1730,7 +1726,7 @@ StatsScreenDPad: ; e2f95 (38:6f95) ld [CurPartySpecies], a ld [CurSpecies], a ld hl, TempMonDVs - predef GetUnownLetter + predef Predef_GetUnownLetter call GetBaseData call BillsPC_CopyMon .pressed_a_b_right_left @@ -1823,7 +1819,7 @@ DepositPokemon: ; e307c (38:707c) call GetNick ld a, PC_DEPOSIT ld [wPokemonWithdrawDepositParameter], a - predef SentGetPkmnIntoFromBox + predef Predef_SendGetPkmnIntoFromBox jr c, .asm_boxisfull xor a ld [wPokemonWithdrawDepositParameter], a @@ -1878,7 +1874,7 @@ TryWithdrawPokemon: ; e30fa (38:70fa) call CloseSRAM xor a ld [wPokemonWithdrawDepositParameter], a - predef SentGetPkmnIntoFromBox + predef Predef_SendGetPkmnIntoFromBox jr c, .PartyFull ld a, PC_DEPOSIT ld [wPokemonWithdrawDepositParameter], a @@ -2104,7 +2100,7 @@ MovePKMNWitoutMail_InsertMon: ; e31e7 ld hl, wBillsPC_BackupScrollPosition add [hl] ld [CurPartyMon], a - ld a, $1 + ld a, BANK(sBox) call GetSRAMBank ld hl, sBoxSpecies call CopySpeciesToTemp @@ -2333,15 +2329,14 @@ BillsPC_ClearTilemap: ; e35e2 (38:75e2) ; e35f1 (38:75f1) _ChangeBox_menudataheader: ; 0xe35f1 - db $40 ; flags - db 05, 01 ; start coords - db 12, 09 ; end coords + db MENU_BACKUP_TILES ; flags + menu_coords 1, 5, 9, 12 dw .menudata2 db 1 ; default option ; 0xe35f9 .menudata2 ; 0xe35f9 - db $22 ; flags + db MENU_UNUSED_1 | MENU_UNUSED_3 ; flags db 4, 0 db 1 dba .boxes @@ -2559,12 +2554,11 @@ BillsPC_ChangeBoxSubmenu: ; e36f9 (38:76f9) ret ; e3778 (38:7778) - hlcoord 11, 7 ; XXX + hlcoord 11, 7 ; unused .MenuDataHeader: ; 0xe377b db MENU_BACKUP_TILES ; flags - db 04, 11 ; start coords - db 13, 19 ; end coords + menu_coords 11, 4, SCREEN_WIDTH - 1, 13 dw .MenuData2 db 1 ; default option ; 0xe3783 diff --git a/engine/billspctop.asm b/engine/billspctop.asm index f5ee3d7d8..ac70082d6 100755 --- a/engine/billspctop.asm +++ b/engine/billspctop.asm @@ -70,8 +70,7 @@ _BillsPC: ; e3fd .MenuDataHeader: ; 0xe46f db MENU_BACKUP_TILES ; flags - db 00, 00 ; start coords - db 17, 19 ; end coords + menu_coords 0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1 dw .MenuData2 db 1 ; default option @@ -143,7 +142,7 @@ BillsPC_DepositMenu: ; e4fe (3:64fe) and a ret -Functione512: ; unused +Unreferenced_Functione512: ld a, [PartyCount] and a jr z, .no_pkmn @@ -212,7 +211,7 @@ BillsPC_WithdrawMenu: ; e559 (3:6559) and a ret -Functione56d: ; unused +Unreferenced_Functione56d: ld a, [PartyCount] cp PARTY_LENGTH jr nc, .asm_e576 @@ -268,7 +267,7 @@ CopyBoxmonToTempMon: ; e5bb call CloseSRAM ret -Functione5d9: ; unreferenced +Unreferenced_Functione5d9: ld a, [wCurBox] cp b jr z, .same_box diff --git a/engine/breeding.asm b/engine/breeding.asm index 234e05448..e86cf5832 100755 --- a/engine/breeding.asm +++ b/engine/breeding.asm @@ -10,7 +10,7 @@ CheckBreedmonCompatibility: ; 16e1d ld [TempMonDVs + 1], a ld a, TEMPMON ld [MonType], a - predef GetGender + predef Predef_GetGender jr c, .genderless ld b, $1 jr nz, .breedmon2 @@ -26,7 +26,7 @@ CheckBreedmonCompatibility: ; 16e1d ld [TempMonDVs + 1], a ld a, $3 ld [MonType], a - predef GetGender + predef Predef_GetGender pop bc jr c, .genderless ld a, $1 @@ -232,7 +232,7 @@ HatchEggs: ; 16f70 (5:6f70) push de farcall SetEggMonCaughtData - farcall TrainerRankings_EggsHatched + farcall StubbedTrainerRankings_EggsHatched ld a, [CurPartyMon] ld hl, PartyMon1Species ld bc, PARTYMON_STRUCT_LENGTH @@ -289,7 +289,7 @@ HatchEggs: ; 16f70 (5:6f70) ld bc, MON_STAT_EXP - 1 add hl, bc ld b, $0 - predef CalcPkmnStats + predef Predef_CalcPkmnStats pop bc ld hl, MON_MAXHP add hl, bc @@ -514,7 +514,7 @@ GLOBAL EggMoves cp b jr nz, .loop5 ld [wPutativeTMHMMove], a - predef CanLearnTMHMMove + predef Predef_CanLearnTMHMMove ld a, c and a jr z, .done @@ -559,7 +559,7 @@ LoadEggMove: ; 17169 ld [hl], b ld hl, wEggMonMoves ld de, wEggMonPP - predef FillPP + predef Predef_FillPP pop bc pop de ret @@ -590,7 +590,7 @@ GetHeritableMoves: ; 17197 ld [TempMonDVs + 1], a ld a, TEMPMON ld [MonType], a - predef GetGender + predef Predef_GetGender jr c, .inherit_mon2_moves jr nz, .inherit_mon2_moves jr .inherit_mon1_moves @@ -606,7 +606,7 @@ GetHeritableMoves: ; 17197 ld [TempMonDVs + 1], a ld a, TEMPMON ld [MonType], a - predef GetGender + predef Predef_GetGender jr c, .inherit_mon1_moves jr nz, .inherit_mon1_moves @@ -647,9 +647,9 @@ GetEggFrontpic: ; 17224 (5:7224) ld [CurSpecies], a call GetBaseData ld hl, BattleMonDVs - predef GetUnownLetter + predef Predef_GetUnownLetter pop de - predef_jump GetMonFrontpic + predef_jump Predef_GetMonFrontpic GetHatchlingFrontpic: ; 1723c (5:723c) push de @@ -657,9 +657,9 @@ GetHatchlingFrontpic: ; 1723c (5:723c) ld [CurSpecies], a call GetBaseData ld hl, BattleMonDVs - predef GetUnownLetter + predef Predef_GetUnownLetter pop de - predef_jump GetAnimatedFrontpicPredef + predef_jump Predef_GetAnimatedFrontpic Hatch_UpdateFrontpicBGMapCenter: ; 17254 (5:7254) push af @@ -677,7 +677,7 @@ Hatch_UpdateFrontpicBGMapCenter: ; 17254 (5:7254) ld a, c ld [hGraphicStartTile], a lb bc, 7, 7 - predef PlaceGraphic + predef Predef_PlaceGraphic pop af call Hatch_LoadFrontpicPal call SetPalettes @@ -726,11 +726,11 @@ EggHatch_AnimationSequence: ; 1728f (5:728f) ld c, 80 call DelayFrames xor a - ld [wcf64], a + ld [wFrameCounter], a ld a, [hSCX] ld b, a .outerloop - ld hl, wcf64 + ld hl, wFrameCounter ld a, [hl] inc [hl] cp 8 @@ -779,7 +779,7 @@ EggHatch_AnimationSequence: ; 1728f (5:728f) hlcoord 6, 3 ld d, $0 ld e, ANIM_MON_HATCH - predef AnimateFrontpic + predef Predef_AnimateFrontpic pop af ld [CurSpecies], a ret @@ -791,7 +791,7 @@ Hatch_LoadFrontpicPal: ; 17363 (5:7363) jp GetSGBLayout EggHatch_CrackShell: ; 1736d (5:736d) - ld a, [wcf64] + ld a, [wFrameCounter] dec a and $7 cp $7 @@ -860,18 +860,22 @@ Hatch_InitShellFragments: ; 173b3 (5:73b3) ret ; 173ef (5:73ef) +shell_fragment: MACRO +; y tile, y pxl, x tile, x pxl, frameset offset, ??? + db (\1 * 8) % $100 + \2, (\3 * 8) % $100 + \4, \5 - SPRITE_ANIM_FRAMESET_EGG_HATCH_1, \6 +ENDM + .SpriteData: ; 173ef -; Probably OAM. - dsprite 10, 4, 9, 0, $00, $3c - dsprite 11, 4, 9, 0, $01, $04 - dsprite 10, 4, 10, 0, $00, $30 - dsprite 11, 4, 10, 0, $01, $10 - dsprite 10, 4, 11, 0, $02, $24 - dsprite 11, 4, 11, 0, $03, $1c - dsprite 10, 0, 9, 4, $00, $36 - dsprite 12, 0, 9, 4, $01, $0a - dsprite 10, 0, 10, 4, $02, $2a - dsprite 12, 0, 10, 4, $03, $16 + shell_fragment 10, 4, 9, 0, SPRITE_ANIM_FRAMESET_EGG_HATCH_1, $3c + shell_fragment 11, 4, 9, 0, SPRITE_ANIM_FRAMESET_EGG_HATCH_2, $04 + shell_fragment 10, 4, 10, 0, SPRITE_ANIM_FRAMESET_EGG_HATCH_1, $30 + shell_fragment 11, 4, 10, 0, SPRITE_ANIM_FRAMESET_EGG_HATCH_2, $10 + shell_fragment 10, 4, 11, 0, SPRITE_ANIM_FRAMESET_EGG_HATCH_3, $24 + shell_fragment 11, 4, 11, 0, SPRITE_ANIM_FRAMESET_EGG_HATCH_4, $1c + shell_fragment 10, 0, 9, 4, SPRITE_ANIM_FRAMESET_EGG_HATCH_1, $36 + shell_fragment 12, 0, 9, 4, SPRITE_ANIM_FRAMESET_EGG_HATCH_2, $0a + shell_fragment 10, 0, 10, 4, SPRITE_ANIM_FRAMESET_EGG_HATCH_3, $2a + shell_fragment 12, 0, 10, 4, SPRITE_ANIM_FRAMESET_EGG_HATCH_4, $16 db -1 ; 17418 @@ -981,8 +985,7 @@ DayCareMonCompatibilityText: ; 1746c db "@" ; 0x174b5 -DayCareMonPrintEmptyString: ; 174b5 -; unreferenced +Unreferenced_DayCareMonPrintEmptyString: ; 174b5 ld hl, .string ret ; 174b9 diff --git a/engine/buy_sell_toss.asm b/engine/buy_sell_toss.asm index 358ef4f30..ff2bd2967 100755 --- a/engine/buy_sell_toss.asm +++ b/engine/buy_sell_toss.asm @@ -215,24 +215,21 @@ BuySell_DisplaySubtotal: ; 250d1 TossItem_MenuDataHeader: ; 0x250ed db MENU_BACKUP_TILES ; flags - db 09, 15 ; start coords - db 11, 19 ; end coords + menu_coords 15, 9, SCREEN_WIDTH - 1, TEXTBOX_Y - 1 dw ret_25097 db 0 ; default option ; 0x250f5 BuyItem_MenuDataHeader: ; 0x250f5 db MENU_BACKUP_TILES ; flags - db 15, 07 ; start coords - db 17, 19 ; end coords + menu_coords 7, 15, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1 dw DisplayPurchasePrice db -1 ; default option ; 0x250fd SellItem_MenuDataHeader: ; 0x250fd db MENU_BACKUP_TILES ; flags - db 15, 07 ; start coords - db 17, 19 ; end coords + menu_coords 7, 15, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1 dw DisplaySellingPrice db 0 ; default option ; 0x25105 diff --git a/engine/card_flip.asm b/engine/card_flip.asm index 158f3fa05..ae90b124a 100755 --- a/engine/card_flip.asm +++ b/engine/card_flip.asm @@ -1,7 +1,15 @@ CARDFLIP_LIGHT_OFF EQU $ef CARDFLIP_LIGHT_ON EQU $f5 + CARDFLIP_DECK_SIZE EQU 4 * 6 +; two labels below called from inside ./dummy_game.asm +Unknown_e00ed: ; e00ed (38:40ed) +; Graphics for an unused Game Corner +; game were meant to be here. +ret_e00ed: ; e00ed (38:40ed) + ret + _CardFlip: ; e00ee (38:40ee) ld hl, Options set 4, [hl] @@ -25,11 +33,11 @@ _CardFlip: ; e00ee (38:40ee) ld de, vTiles0 tile $00 call Decompress ld hl, CardFlipOffButtonGFX - ld de, vTiles1 tile $6f + ld de, vTiles0 tile CARDFLIP_LIGHT_OFF ld bc, 1 tiles call CopyBytes ld hl, CardFlipOnButtonGFX - ld de, vTiles1 tile $75 + ld de, vTiles0 tile CARDFLIP_LIGHT_ON ld bc, 1 tiles call CopyBytes @@ -593,23 +601,23 @@ CardFlip_CopyToBox: ; e04f7 (38:44f7) ; e0509 (38:4509) CardFlip_CopyOAM: ; e0509 - ld de, Sprites + ld de, Sprite01 ld a, [hli] .loop push af ld a, [hli] add b - ld [de], a + ld [de], a ; y inc de ld a, [hli] add c - ld [de], a + ld [de], a ; x inc de ld a, [hli] - ld [de], a + ld [de], a ; tile id inc de ld a, [hli] - ld [de], a + ld [de], a ; attributes inc de pop af dec a @@ -618,11 +626,11 @@ CardFlip_CopyOAM: ; e0509 ; e0521 CardFlip_ShiftDigitsLeftTwoPixels: ; e0521 (38:4521) - ld de, vTiles1 tile ("0" & $7f) - ld hl, vTiles1 tile ("0" & $7f) + 2 + ld de, vTiles0 tile "0" + ld hl, vTiles0 tile "0" + 2 ld bc, 10 tiles - 2 call CopyBytes - ld hl, vTiles1 tile $7f + 1 tiles - 2 + ld hl, vTiles0 tile "9" + 1 tiles - 2 xor a ld [hli], a ld [hl], a @@ -1210,29 +1218,29 @@ PlaceOAMCardBorder: ; e0849 .SpriteData: ; e0853 db 18 - dsprite 0, 0, 0, 0, $04, $00 - dsprite 0, 0, 1, 0, $06, $00 - dsprite 0, 0, 2, 0, $06, $00 - dsprite 0, 0, 3, 0, $06, $00 - dsprite 0, 0, 4, 0, $04, $20 + dsprite 0, 0, 0, 0, $04, 0 + dsprite 0, 0, 1, 0, $06, 0 + dsprite 0, 0, 2, 0, $06, 0 + dsprite 0, 0, 3, 0, $06, 0 + dsprite 0, 0, 4, 0, $04, 0 | X_FLIP - dsprite 1, 0, 0, 0, $05, $00 - dsprite 1, 0, 4, 0, $05, $20 + dsprite 1, 0, 0, 0, $05, 0 + dsprite 1, 0, 4, 0, $05, 0 | X_FLIP - dsprite 2, 0, 0, 0, $05, $00 - dsprite 2, 0, 4, 0, $05, $20 + dsprite 2, 0, 0, 0, $05, 0 + dsprite 2, 0, 4, 0, $05, 0 | X_FLIP - dsprite 3, 0, 0, 0, $05, $00 - dsprite 3, 0, 4, 0, $05, $20 + dsprite 3, 0, 0, 0, $05, 0 + dsprite 3, 0, 4, 0, $05, 0 | X_FLIP dsprite 4, 0, 0, 0, $05, $00 - dsprite 4, 0, 4, 0, $05, $20 + dsprite 4, 0, 4, 0, $05, 0 | X_FLIP - dsprite 5, 0, 0, 0, $04, $40 - dsprite 5, 0, 1, 0, $06, $40 - dsprite 5, 0, 2, 0, $06, $40 - dsprite 5, 0, 3, 0, $06, $40 - dsprite 5, 0, 4, 0, $04, $60 + dsprite 5, 0, 0, 0, $04, 0 | Y_FLIP + dsprite 5, 0, 1, 0, $06, 0 | Y_FLIP + dsprite 5, 0, 2, 0, $06, 0 | Y_FLIP + dsprite 5, 0, 3, 0, $06, 0 | Y_FLIP + dsprite 5, 0, 4, 0, $04, 0 | X_FLIP | Y_FLIP ; e089c ChooseCard_HandleJoypad: ; e089c @@ -1471,145 +1479,145 @@ ENDM .SingleTile: ; e0a41 db 6 - dsprite 0, 0, -1, 7, $00, $80 - dsprite 0, 0, 0, 0, $02, $80 - dsprite 0, 0, 1, 0, $03, $80 - dsprite 0, 5, -1, 7, $00, $c0 - dsprite 0, 5, 0, 0, $02, $c0 - dsprite 0, 5, 1, 0, $03, $80 + dsprite 0, 0, -1, 7, $00, 0 | PRIORITY + dsprite 0, 0, 0, 0, $02, 0 | PRIORITY + dsprite 0, 0, 1, 0, $03, 0 | PRIORITY + dsprite 0, 5, -1, 7, $00, 0 | Y_FLIP | PRIORITY + dsprite 0, 5, 0, 0, $02, 0 | Y_FLIP | PRIORITY + dsprite 0, 5, 1, 0, $03, 0 | PRIORITY .PokeGroup: ; e0a5a db 26 - dsprite 0, 0, -1, 7, $00, $80 - dsprite 0, 0, 0, 0, $02, $80 - dsprite 0, 0, 1, 0, $00, $a0 - dsprite 1, 0, -1, 7, $01, $80 - dsprite 1, 0, 1, 0, $01, $a0 - dsprite 2, 0, -1, 7, $01, $80 - dsprite 2, 0, 1, 0, $03, $80 - dsprite 3, 0, -1, 7, $01, $80 - dsprite 3, 0, 1, 0, $03, $80 - dsprite 4, 0, -1, 7, $01, $80 - dsprite 4, 0, 1, 0, $03, $80 - dsprite 5, 0, -1, 7, $01, $80 - dsprite 5, 0, 1, 0, $03, $80 - dsprite 6, 0, -1, 7, $01, $80 - dsprite 6, 0, 1, 0, $03, $80 - dsprite 7, 0, -1, 7, $01, $80 - dsprite 7, 0, 1, 0, $03, $80 - dsprite 8, 0, -1, 7, $01, $80 - dsprite 8, 0, 1, 0, $03, $80 - dsprite 9, 0, -1, 7, $01, $80 - dsprite 9, 0, 1, 0, $03, $80 - dsprite 10, 0, -1, 7, $01, $80 - dsprite 10, 0, 1, 0, $03, $80 - dsprite 10, 1, -1, 7, $00, $c0 - dsprite 10, 1, 0, 0, $02, $c0 - dsprite 10, 1, 1, 0, $03, $80 + dsprite 0, 0, -1, 7, $00, 0 | PRIORITY + dsprite 0, 0, 0, 0, $02, 0 | PRIORITY + dsprite 0, 0, 1, 0, $00, 0 | X_FLIP | PRIORITY + dsprite 1, 0, -1, 7, $01, 0 | PRIORITY + dsprite 1, 0, 1, 0, $01, 0 | X_FLIP | PRIORITY + dsprite 2, 0, -1, 7, $01, 0 | PRIORITY + dsprite 2, 0, 1, 0, $03, 0 | PRIORITY + dsprite 3, 0, -1, 7, $01, 0 | PRIORITY + dsprite 3, 0, 1, 0, $03, 0 | PRIORITY + dsprite 4, 0, -1, 7, $01, 0 | PRIORITY + dsprite 4, 0, 1, 0, $03, 0 | PRIORITY + dsprite 5, 0, -1, 7, $01, 0 | PRIORITY + dsprite 5, 0, 1, 0, $03, 0 | PRIORITY + dsprite 6, 0, -1, 7, $01, 0 | PRIORITY + dsprite 6, 0, 1, 0, $03, 0 | PRIORITY + dsprite 7, 0, -1, 7, $01, 0 | PRIORITY + dsprite 7, 0, 1, 0, $03, 0 | PRIORITY + dsprite 8, 0, -1, 7, $01, 0 | PRIORITY + dsprite 8, 0, 1, 0, $03, 0 | PRIORITY + dsprite 9, 0, -1, 7, $01, 0 | PRIORITY + dsprite 9, 0, 1, 0, $03, 0 | PRIORITY + dsprite 10, 0, -1, 7, $01, 0 | PRIORITY + dsprite 10, 0, 1, 0, $03, 0 | PRIORITY + dsprite 10, 1, -1, 7, $00, 0 | Y_FLIP | PRIORITY + dsprite 10, 1, 0, 0, $02, 0 | Y_FLIP | PRIORITY + dsprite 10, 1, 1, 0, $03, 0 | PRIORITY .NumGroup: ; e0ac3 db 20 - dsprite 0, 0, -1, 7, $00, $80 - dsprite 0, 0, 0, 0, $02, $80 - dsprite 0, 0, 1, 0, $02, $80 - dsprite 0, 0, 2, 0, $03, $80 - dsprite 0, 0, 3, 0, $02, $80 - dsprite 0, 0, 4, 0, $03, $80 - dsprite 0, 0, 5, 0, $02, $80 - dsprite 0, 0, 6, 0, $03, $80 - dsprite 0, 0, 7, 0, $02, $80 - dsprite 0, 0, 8, 0, $03, $80 - dsprite 0, 5, -1, 7, $00, $c0 - dsprite 0, 5, 0, 0, $02, $c0 - dsprite 0, 5, 1, 0, $02, $c0 - dsprite 0, 5, 2, 0, $03, $80 - dsprite 0, 5, 3, 0, $02, $c0 - dsprite 0, 5, 4, 0, $03, $80 - dsprite 0, 5, 5, 0, $02, $c0 - dsprite 0, 5, 6, 0, $03, $80 - dsprite 0, 5, 7, 0, $02, $c0 - dsprite 0, 5, 8, 0, $03, $80 + dsprite 0, 0, -1, 7, $00, 0 | PRIORITY + dsprite 0, 0, 0, 0, $02, 0 | PRIORITY + dsprite 0, 0, 1, 0, $02, 0 | PRIORITY + dsprite 0, 0, 2, 0, $03, 0 | PRIORITY + dsprite 0, 0, 3, 0, $02, 0 | PRIORITY + dsprite 0, 0, 4, 0, $03, 0 | PRIORITY + dsprite 0, 0, 5, 0, $02, 0 | PRIORITY + dsprite 0, 0, 6, 0, $03, 0 | PRIORITY + dsprite 0, 0, 7, 0, $02, 0 | PRIORITY + dsprite 0, 0, 8, 0, $03, 0 | PRIORITY + dsprite 0, 5, -1, 7, $00, 0 | Y_FLIP | PRIORITY + dsprite 0, 5, 0, 0, $02, 0 | Y_FLIP | PRIORITY + dsprite 0, 5, 1, 0, $02, 0 | Y_FLIP | PRIORITY + dsprite 0, 5, 2, 0, $03, 0 | PRIORITY + dsprite 0, 5, 3, 0, $02, 0 | Y_FLIP | PRIORITY + dsprite 0, 5, 4, 0, $03, 0 | PRIORITY + dsprite 0, 5, 5, 0, $02, 0 | Y_FLIP | PRIORITY + dsprite 0, 5, 6, 0, $03, 0 | PRIORITY + dsprite 0, 5, 7, 0, $02, 0 | Y_FLIP | PRIORITY + dsprite 0, 5, 8, 0, $03, 0 | PRIORITY .NumGroupPair: ; e0b14 db 30 - dsprite 0, 0, 0, 0, $00, $80 - dsprite 0, 0, 1, 0, $02, $80 - dsprite 0, 0, 2, 0, $02, $80 - dsprite 0, 0, 3, 0, $03, $80 - dsprite 0, 0, 4, 0, $02, $80 - dsprite 0, 0, 5, 0, $03, $80 - dsprite 0, 0, 6, 0, $02, $80 - dsprite 0, 0, 7, 0, $03, $80 - dsprite 0, 0, 8, 0, $02, $80 - dsprite 0, 0, 9, 0, $03, $80 - dsprite 1, 0, 0, 0, $01, $80 - dsprite 1, 0, 3, 0, $03, $80 - dsprite 1, 0, 5, 0, $03, $80 - dsprite 1, 0, 7, 0, $03, $80 - dsprite 1, 0, 9, 0, $03, $80 - dsprite 2, 0, 0, 0, $01, $80 - dsprite 2, 0, 3, 0, $03, $80 - dsprite 2, 0, 5, 0, $03, $80 - dsprite 2, 0, 7, 0, $03, $80 - dsprite 2, 0, 9, 0, $03, $80 - dsprite 2, 1, 0, 0, $00, $c0 - dsprite 2, 1, 1, 0, $02, $c0 - dsprite 2, 1, 2, 0, $02, $c0 - dsprite 2, 1, 3, 0, $03, $80 - dsprite 2, 1, 4, 0, $03, $80 - dsprite 2, 1, 5, 0, $03, $80 - dsprite 2, 1, 6, 0, $03, $80 - dsprite 2, 1, 7, 0, $03, $80 - dsprite 2, 1, 8, 0, $03, $80 - dsprite 2, 1, 9, 0, $03, $80 + dsprite 0, 0, 0, 0, $00, 0 | PRIORITY + dsprite 0, 0, 1, 0, $02, 0 | PRIORITY + dsprite 0, 0, 2, 0, $02, 0 | PRIORITY + dsprite 0, 0, 3, 0, $03, 0 | PRIORITY + dsprite 0, 0, 4, 0, $02, 0 | PRIORITY + dsprite 0, 0, 5, 0, $03, 0 | PRIORITY + dsprite 0, 0, 6, 0, $02, 0 | PRIORITY + dsprite 0, 0, 7, 0, $03, 0 | PRIORITY + dsprite 0, 0, 8, 0, $02, 0 | PRIORITY + dsprite 0, 0, 9, 0, $03, 0 | PRIORITY + dsprite 1, 0, 0, 0, $01, 0 | PRIORITY + dsprite 1, 0, 3, 0, $03, 0 | PRIORITY + dsprite 1, 0, 5, 0, $03, 0 | PRIORITY + dsprite 1, 0, 7, 0, $03, 0 | PRIORITY + dsprite 1, 0, 9, 0, $03, 0 | PRIORITY + dsprite 2, 0, 0, 0, $01, 0 | PRIORITY + dsprite 2, 0, 3, 0, $03, 0 | PRIORITY + dsprite 2, 0, 5, 0, $03, 0 | PRIORITY + dsprite 2, 0, 7, 0, $03, 0 | PRIORITY + dsprite 2, 0, 9, 0, $03, 0 | PRIORITY + dsprite 2, 1, 0, 0, $00, 0 | Y_FLIP | PRIORITY + dsprite 2, 1, 1, 0, $02, 0 | Y_FLIP | PRIORITY + dsprite 2, 1, 2, 0, $02, 0 | Y_FLIP | PRIORITY + dsprite 2, 1, 3, 0, $03, 0 | PRIORITY + dsprite 2, 1, 4, 0, $03, 0 | PRIORITY + dsprite 2, 1, 5, 0, $03, 0 | PRIORITY + dsprite 2, 1, 6, 0, $03, 0 | PRIORITY + dsprite 2, 1, 7, 0, $03, 0 | PRIORITY + dsprite 2, 1, 8, 0, $03, 0 | PRIORITY + dsprite 2, 1, 9, 0, $03, 0 | PRIORITY .PokeGroupPair: ; e0b8d db 38 - dsprite 0, 0, -1, 7, $00, $80 - dsprite 0, 0, 3, 0, $00, $a0 - dsprite 1, 0, -1, 7, $01, $80 - dsprite 1, 0, 3, 0, $01, $a0 - dsprite 2, 0, -1, 7, $01, $80 - dsprite 2, 0, 3, 0, $01, $a0 - dsprite 3, 0, -1, 7, $01, $80 - dsprite 3, 0, 1, 0, $03, $80 - dsprite 3, 0, 3, 0, $03, $80 - dsprite 4, 0, -1, 7, $01, $80 - dsprite 4, 0, 1, 0, $03, $80 - dsprite 4, 0, 3, 0, $03, $80 - dsprite 5, 0, -1, 7, $01, $80 - dsprite 5, 0, 1, 0, $03, $80 - dsprite 5, 0, 3, 0, $03, $80 - dsprite 6, 0, -1, 7, $01, $80 - dsprite 6, 0, 1, 0, $03, $80 - dsprite 6, 0, 3, 0, $03, $80 - dsprite 7, 0, -1, 7, $01, $80 - dsprite 7, 0, 1, 0, $03, $80 - dsprite 7, 0, 3, 0, $03, $80 - dsprite 8, 0, -1, 7, $01, $80 - dsprite 8, 0, 1, 0, $03, $80 - dsprite 8, 0, 3, 0, $03, $80 - dsprite 9, 0, -1, 7, $01, $80 - dsprite 9, 0, 1, 0, $03, $80 - dsprite 9, 0, 3, 0, $03, $80 - dsprite 10, 0, -1, 7, $01, $80 - dsprite 10, 0, 1, 0, $03, $80 - dsprite 10, 0, 3, 0, $03, $80 - dsprite 11, 0, -1, 7, $01, $80 - dsprite 11, 0, 1, 0, $03, $80 - dsprite 11, 0, 3, 0, $03, $80 - dsprite 11, 1, -1, 7, $00, $c0 - dsprite 11, 1, 0, 0, $02, $c0 - dsprite 11, 1, 1, 0, $03, $c0 - dsprite 11, 1, 2, 0, $02, $c0 - dsprite 11, 1, 3, 0, $03, $e0 + dsprite 0, 0, -1, 7, $00, 0 | PRIORITY + dsprite 0, 0, 3, 0, $00, 0 | X_FLIP | PRIORITY + dsprite 1, 0, -1, 7, $01, 0 | PRIORITY + dsprite 1, 0, 3, 0, $01, 0 | X_FLIP | PRIORITY + dsprite 2, 0, -1, 7, $01, 0 | PRIORITY + dsprite 2, 0, 3, 0, $01, 0 | X_FLIP | PRIORITY + dsprite 3, 0, -1, 7, $01, 0 | PRIORITY + dsprite 3, 0, 1, 0, $03, 0 | PRIORITY + dsprite 3, 0, 3, 0, $03, 0 | PRIORITY + dsprite 4, 0, -1, 7, $01, 0 | PRIORITY + dsprite 4, 0, 1, 0, $03, 0 | PRIORITY + dsprite 4, 0, 3, 0, $03, 0 | PRIORITY + dsprite 5, 0, -1, 7, $01, 0 | PRIORITY + dsprite 5, 0, 1, 0, $03, 0 | PRIORITY + dsprite 5, 0, 3, 0, $03, 0 | PRIORITY + dsprite 6, 0, -1, 7, $01, 0 | PRIORITY + dsprite 6, 0, 1, 0, $03, 0 | PRIORITY + dsprite 6, 0, 3, 0, $03, 0 | PRIORITY + dsprite 7, 0, -1, 7, $01, 0 | PRIORITY + dsprite 7, 0, 1, 0, $03, 0 | PRIORITY + dsprite 7, 0, 3, 0, $03, 0 | PRIORITY + dsprite 8, 0, -1, 7, $01, 0 | PRIORITY + dsprite 8, 0, 1, 0, $03, 0 | PRIORITY + dsprite 8, 0, 3, 0, $03, 0 | PRIORITY + dsprite 9, 0, -1, 7, $01, 0 | PRIORITY + dsprite 9, 0, 1, 0, $03, 0 | PRIORITY + dsprite 9, 0, 3, 0, $03, 0 | PRIORITY + dsprite 10, 0, -1, 7, $01, 0 | PRIORITY + dsprite 10, 0, 1, 0, $03, 0 | PRIORITY + dsprite 10, 0, 3, 0, $03, 0 | PRIORITY + dsprite 11, 0, -1, 7, $01, 0 | PRIORITY + dsprite 11, 0, 1, 0, $03, 0 | PRIORITY + dsprite 11, 0, 3, 0, $03, 0 | PRIORITY + dsprite 11, 1, -1, 7, $00, 0 | Y_FLIP | PRIORITY + dsprite 11, 1, 0, 0, $02, 0 | Y_FLIP | PRIORITY + dsprite 11, 1, 1, 0, $03, 0 | Y_FLIP | PRIORITY + dsprite 11, 1, 2, 0, $02, 0 | Y_FLIP | PRIORITY + dsprite 11, 1, 3, 0, $03, 0 | X_FLIP | Y_FLIP | PRIORITY .Impossible: ; e0c26 db 4 - dsprite 0, 0, 0, 0, $00, $80 - dsprite 0, 0, 1, 0, $00, $a0 - dsprite 1, 0, 0, 0, $00, $c0 - dsprite 1, 0, 1, 0, $00, $e0 + dsprite 0, 0, 0, 0, $00, 0 | PRIORITY + dsprite 0, 0, 1, 0, $00, 0 | X_FLIP | PRIORITY + dsprite 1, 0, 0, 0, $00, 0 | Y_FLIP | PRIORITY + dsprite 1, 0, 1, 0, $00, 0 | X_FLIP | Y_FLIP | PRIORITY ; e0c37 CardFlip_InitAttrPals: ; e0c37 (38:4c37) @@ -1649,7 +1657,7 @@ CardFlip_InitAttrPals: ; e0c37 (38:4c37) ld a, [rSVBK] push af - ld a, $5 + ld a, BANK(wBGPals1) ld [rSVBK], a ld hl, .palettes ld de, wBGPals1 @@ -1661,7 +1669,7 @@ CardFlip_InitAttrPals: ; e0c37 (38:4c37) ; e0c93 (38:4c93) .palettes ; e0c93 -INCLUDE "data/palettes/card_flip.pal" +INCLUDE "gfx/card_flip/card_flip.pal" ; e0cdb CardFlipLZ03: ; e0cdb diff --git a/engine/caught_data.asm b/engine/caught_data.asm index 1f8b8cac4..56ef8a839 100644 --- a/engine/caught_data.asm +++ b/engine/caught_data.asm @@ -1,4 +1,4 @@ -CheckPartyFullAfterContest: ; 4d9e5 +Special_CheckPartyFullAfterContest: ; 4d9e5 ld a, [wContestMon] and a jp z, .DidntCatchAnything @@ -7,17 +7,17 @@ CheckPartyFullAfterContest: ; 4d9e5 call GetBaseData ld hl, PartyCount ld a, [hl] - cp 6 + cp PARTY_LENGTH jp nc, .TryAddToBox inc a ld [hl], a ld c, a - ld b, $0 + ld b, 0 add hl, bc ld a, [wContestMon] ld [hli], a ld [CurSpecies], a - ld a, $ff + ld a, -1 ld [hl], a ld hl, PartyMon1Species ld a, [PartyCount] @@ -75,13 +75,13 @@ CheckPartyFullAfterContest: ; 4d9e5 ld hl, PartyMon1CaughtLocation call GetPartyLocation ld a, [hl] - and $80 - ld b, $13 + and CAUGHT_GENDER_MASK + ld b, NATIONAL_PARK or b ld [hl], a xor a ld [wContestMon], a - and a + and a ; BUGCONTEST_CAUGHT_MON ld [ScriptVar], a ret @@ -135,19 +135,19 @@ CheckPartyFullAfterContest: ; 4d9e5 call GetSRAMBank ld hl, sBoxMon1CaughtLocation ld a, [hl] - and $80 - ld b, $13 + and CAUGHT_GENDER_MASK + ld b, NATIONAL_PARK or b ld [hl], a call CloseSRAM xor a ld [wContestMon], a - ld a, $1 + ld a, BUGCONTEST_BOXED_MON ld [ScriptVar], a ret .DidntCatchAnything: ; 4db35 - ld a, $2 + ld a, BUGCONTEST_NO_CATCH ld [ScriptVar], a ret @@ -227,7 +227,7 @@ SetGiftPartyMonCaughtData: ; 4dba3 SetGiftMonCaughtData: ; 4dbaf xor a ld [hli], a - ld a, $7e + ld a, GIFT_LOCATION rrc b or b ld [hl], a @@ -239,7 +239,7 @@ SetEggMonCaughtData: ; 4dbb8 (13:5bb8) call GetPartyLocation ld a, [CurPartyLevel] push af - ld a, $1 + ld a, CAUGHT_EGG_LEVEL ld [CurPartyLevel], a call SetBoxmonOrEggmonCaughtData pop af diff --git a/engine/cgb_layouts.asm b/engine/cgb_layouts.asm index 74d476dec..70429a453 100644 --- a/engine/cgb_layouts.asm +++ b/engine/cgb_layouts.asm @@ -6,7 +6,7 @@ CheckCGB: ; 8d55 ret ; 8d59 -Predef_LoadSGBLayoutCGB: ; 8d59 +LoadSGBLayoutCGB: ; 8d59 ld a, b cp SCGB_RAM jr nz, .not_ram @@ -258,30 +258,11 @@ _CGB_StatsScreenHPPals: ; 8edb ; 8f52 StatsScreenPagePals: ; 8f52 -; pink - RGB 31, 31, 31 - RGB 31, 19, 31 - RGB 31, 15, 31 - RGB 00, 00, 00 -; green - RGB 31, 31, 31 - RGB 21, 31, 14 - RGB 17, 31, 00 - RGB 00, 00, 00 -; blue - RGB 31, 31, 31 - RGB 17, 31, 31 - RGB 17, 31, 31 - RGB 00, 00, 00 +INCLUDE "gfx/stats/pages.pal" ; 8f6a StatsScreenPals: ; 8f6a -; pink - RGB 31, 19, 31 -; green - RGB 21, 31, 14 -; blue - RGB 17, 31, 31 +INCLUDE "gfx/stats/stats.pal" ; 8f70 _CGB_Pokedex: ; 8f70 @@ -319,16 +300,11 @@ _CGB_Pokedex: ; 8f70 ; 8fba .PokedexQuestionMarkPalette: ; 8fba - RGB 11, 23, 00 - RGB 07, 17, 00 - RGB 06, 16, 03 - RGB 05, 12, 01 +INCLUDE "gfx/pokedex/question_mark.pal" +; 8fc2 .PokedexCursorPalette: ; 8fc2 - RGB 00, 00, 00 - RGB 11, 23, 00 - RGB 07, 17, 00 - RGB 00, 00, 00 +INCLUDE "gfx/pokedex/cursor.pal" ; 8fca _CGB_BillsPC: ; 8fca @@ -385,10 +361,7 @@ _CGB_BillsPC: ; 8fca ; 9036 .BillsPCOrangePalette: ; 9036 - RGB 31, 15, 00 - RGB 23, 12, 00 - RGB 15, 07, 00 - RGB 00, 00, 00 +INCLUDE "gfx/pc/orange.pal" ; 903e _CGB_PokedexUnownMode: ; 903e @@ -891,11 +864,11 @@ _CGB_PackPals: ; 93d3 ; 9439 .ChrisPackPals: ; 9439 -INCLUDE "data/palettes/pack.pal" +INCLUDE "gfx/pack/pack.pal" ; 9469 .KrisPackPals: ; 9469 -INCLUDE "data/palettes/pack_f.pal" +INCLUDE "gfx/pack/pack_f.pal" ; 9499 _CGB_Pokepic: ; 9499 @@ -970,10 +943,7 @@ _CGB_GamefreakLogo: ; 94fa ; 9521 .Palette: ; 9521 - RGB 31, 31, 31 - RGB 13, 11, 00 - RGB 23, 12, 28 - RGB 00, 00, 00 +INCLUDE "gfx/splash/logo.pal" ; 9529 _CGB_PlayerOrMonFrontpicPals: ; 9529 @@ -1059,13 +1029,5 @@ _CGB_MysteryGift: ; 9591 ; 95e0 .Palettes: ; 95e0 - RGB 31, 31, 31 - RGB 16, 31, 14 - RGB 05, 14, 21 - RGB 05, 13, 10 - - RGB 31, 31, 31 - RGB 11, 21, 25 - RGB 05, 14, 21 - RGB 00, 03, 19 +INCLUDE "gfx/mystery_gift/mystery_gift.pal" ; 95f0 diff --git a/engine/clock_reset.asm b/engine/clock_reset.asm index c81271442..82b81b85c 100755 --- a/engine/clock_reset.asm +++ b/engine/clock_reset.asm @@ -220,6 +220,7 @@ RestartClock: ; 20021 (8:4021) ret ; 20160 (8:4160) +; unused .unreferenced ; 20160 ld a, [Buffer3] ld b, a diff --git a/engine/color.asm b/engine/color.asm index 04b24fde9..7376cdf1a 100644 --- a/engine/color.asm +++ b/engine/color.asm @@ -43,8 +43,7 @@ CheckShininess: and a ret -; unreferenced -CheckContestMon: +UnusedPredef_CheckContestMon: ; Check a mon's DVs at hl in the bug catching contest. ; Return carry if its DVs are good enough to place in the contest. @@ -78,8 +77,7 @@ CheckContestMon: and a ret -Function8aa4: -; XXX +Unreferenced_Function8aa4: push de push bc ld hl, PalPacket_9ce6 @@ -136,21 +134,20 @@ SGB_ApplyPartyMenuHPPals: ; 8ade ld [hl], e ret -Function8b07: -; Unreferenced +Unreferenced_Function8b07: call CheckCGB ret z ; CGB only ld hl, .BGPal ld de, wBGPals1 ld bc, 1 palettes - ld a, $5 + ld a, BANK(wBGPals1) call FarCopyWRAM ld hl, .OBPal ld de, wOBPals1 ld bc, 1 palettes - ld a, $5 + ld a, BANK(wOBPals1) call FarCopyWRAM call ApplyPals @@ -170,8 +167,7 @@ Function8b07: RGB 08, 16, 28 RGB 00, 00, 00 -Function8b3f: -; Unreferenced +Unreferenced_Function8b3f: call CheckCGB ret nz ld a, [hSGB] @@ -180,8 +176,7 @@ Function8b3f: ld hl, BlkPacket_9a86 jp PushSGBPals_ -Function8b4d: -; XXX +Unreferenced_Function8b4d: call CheckCGB jr nz, .cgb ld a, [hSGB] @@ -196,8 +191,7 @@ Function8b4d: call GetPredefPal jp LoadHLPaletteIntoDE -Function8b67: -; XXX +Unreferenced_Function8b67: call CheckCGB jr nz, .cgb ld a, [hSGB] @@ -212,8 +206,7 @@ Function8b67: call GetPredefPal jp LoadHLPaletteIntoDE -Function8b81: -; XXX +Unreferenced_Function8b81: call CheckCGB jr nz, .cgb ld a, [hSGB] @@ -281,8 +274,7 @@ got_palette_pointer_8bd7 call LoadPalette_White_Col1_Col2_Black ret -Function8bec: -; XXX +Unreferenced_Function8bec: ld a, [hCGB] and a jr nz, .cgb @@ -359,7 +351,7 @@ ApplyHPBarPals: ld bc, HPBarPals add hl, bc ld bc, 4 - ld a, $5 + ld a, BANK(wBGPals2) call FarCopyWRAM ld a, $1 ld [hCGBPalUpdate], a @@ -394,7 +386,7 @@ LoadStatsScreenPals: add hl, bc ld a, [rSVBK] push af - ld a, $5 + ld a, BANK(wBGPals1) ld [rSVBK], a ld a, [hli] ld [wBGPals1 palette 0], a @@ -443,7 +435,7 @@ LoadMailPalettes: .cgb ld de, wBGPals1 ld bc, 1 palettes - ld a, $5 + ld a, BANK(wBGPals1) call FarCopyWRAM call ApplyPals call WipeAttrMap @@ -451,16 +443,15 @@ LoadMailPalettes: ret .MailPals: -INCLUDE "data/palettes/mail.pal" +INCLUDE "gfx/mail/mail.pal" INCLUDE "engine/cgb_layouts.asm" -Function95f0: -; XXX +Unreferenced_Function95f0: ld hl, .Palette ld de, wBGPals1 ld bc, 1 palettes - ld a, $5 + ld a, BANK(wBGPals1) call FarCopyWRAM call ApplyPals call WipeAttrMap @@ -504,7 +495,7 @@ GetPredefPal: LoadHLPaletteIntoDE: ld a, [rSVBK] push af - ld a, $5 + ld a, BANK(wOBPals1) ld [rSVBK], a ld c, $8 .loop @@ -520,7 +511,7 @@ LoadHLPaletteIntoDE: LoadPalette_White_Col1_Col2_Black: ld a, [rSVBK] push af - ld a, $5 + ld a, BANK(wBGPals1) ld [rSVBK], a ld a, LOW(palred 31 + palgreen 31 + palblue 31) @@ -572,7 +563,7 @@ ResetBGPals: ld a, [rSVBK] push af - ld a, $5 + ld a, BANK(wBGPals1) ld [rSVBK], a ld hl, wBGPals1 @@ -611,7 +602,7 @@ ApplyPals: ld hl, wBGPals1 ld de, wBGPals2 ld bc, 16 palettes - ld a, $5 + ld a, BANK(wPals) call FarCopyWRAM ret @@ -688,7 +679,7 @@ InitPartyMenuOBPals: ld hl, PartyMenuOBPals ld de, wOBPals1 ld bc, 2 palettes - ld a, $5 + ld a, BANK(wOBPals1) call FarCopyWRAM ret @@ -746,7 +737,8 @@ GetMonPalettePointer_: call GetMonPalettePointer ret -Function9779: mobile +Unreferenced_Function9779: + ret call CheckCGB ret z ld hl, BattleObjectPals @@ -761,15 +753,14 @@ Function9779: mobile ld hl, BattleObjectPals ld de, wOBPals1 palette 2 ld bc, 2 palettes - ld a, $5 + ld a, BANK(wOBPals1) call FarCopyWRAM ret BattleObjectPals: -INCLUDE "data/palettes/battle_objects.pal" +INCLUDE "gfx/battle_anims/battle_anims.pal" -Function97cc: -; XXX +Unreferenced_Function97cc: call CheckCGB ret z ld a, $90 @@ -864,7 +855,7 @@ PushSGBPals: jr nz, .loop ret -InitSGBBorder: +Predef_InitSGBBorder: call CheckCGB ret nz ; SGB/DMG only @@ -930,7 +921,7 @@ InitCGBPals:: jr nz, .obpals_loop ld a, [rSVBK] push af - ld a, $5 + ld a, BANK(wBGPals1) ld [rSVBK], a ld hl, wBGPals1 call .LoadWhitePals @@ -979,8 +970,7 @@ _InitSGBBorderPals: dw PalPacket_9dd6 dw PalPacket_9de6 -Function9911: -; XXX +Unreferenced_Function9911: di xor a ld [rJOYP], a @@ -1197,26 +1187,27 @@ SGBDelayCycles: jr nz, .wait ret -INCLUDE "data/palettes/blk_packets.asm" +INCLUDE "gfx/sgb/blk_packets.asm" -INCLUDE "data/palettes/pal_packets.asm" +INCLUDE "gfx/sgb/pal_packets.asm" PredefPals: -INCLUDE "data/palettes/predef.pal" +INCLUDE "gfx/sgb/predef.pal" -INCLUDE "data/sgb_border_map.asm" +SGBBorderMap: +INCBIN "gfx/sgb/sgb_border.tilemap" SGBBorderPalettes: -INCLUDE "data/palettes/sgb_border.pal" +INCLUDE "gfx/sgb/sgb_border.pal" SGBBorder: INCBIN "gfx/sgb/sgb_border.2bpp" HPBarPals: -INCLUDE "data/palettes/hp_bar.pal" +INCLUDE "gfx/battle/hp_bar.pal" ExpBarPalette: -INCLUDE "data/palettes/exp_bar.pal" +INCLUDE "gfx/battle/exp_bar.pal" INCLUDE "data/pokemon/palettes.asm" @@ -1239,7 +1230,7 @@ LoadMapPals: ld l, a ; Futher refine by time of day ld a, [TimeOfDayPal] - and 3 + maskbits NUM_DAYTIMES +- 1 add a add a add a @@ -1251,7 +1242,7 @@ LoadMapPals: ; Switch to palettes WRAM bank ld a, [rSVBK] push af - ld a, $5 + ld a, BANK(wBGPals1) ld [rSVBK], a ld hl, wBGPals1 ld b, 8 @@ -1285,7 +1276,7 @@ LoadMapPals: .got_pals ld a, [TimeOfDayPal] - and 3 + maskbits NUM_DAYTIMES +- 1 ld bc, 8 palettes ld hl, MapObjectPals call AddNTimes @@ -1309,7 +1300,7 @@ LoadMapPals: ld de, RoofPals add hl, de ld a, [TimeOfDayPal] - and 3 + maskbits NUM_DAYTIMES +- 1 cp NITE_F jr c, .morn_day rept 4 @@ -1318,7 +1309,7 @@ endr .morn_day ld de, wBGPals1 palette PAL_BG_ROOF + 2 ld bc, 4 - ld a, $5 + ld a, BANK(wBGPals1) call FarCopyWRAM ret @@ -1337,34 +1328,34 @@ Palette_b311: ; b311 not mobile RGB 00, 00, 00 TilesetBGPalette: -INCLUDE "data/palettes/overworld/tileset_bg.pal" +INCLUDE "gfx/tilesets/bg_tiles.pal" MapObjectPals:: -INCLUDE "data/palettes/overworld/map_objects.pal" +INCLUDE "gfx/overworld/npc_sprites.pal" RoofPals: -INCLUDE "data/palettes/overworld/roofs.pal" +INCLUDE "gfx/tilesets/roofs.pal" DiplomaPalettes: -INCLUDE "data/palettes/diploma.pal" +INCLUDE "gfx/diploma/diploma.pal" PartyMenuOBPals: -INCLUDE "data/palettes/party_menu.pal" +INCLUDE "gfx/icons/party_menu.pal" Palettes_b6f1: -INCLUDE "data/palettes/unknown/b6f1.pal" +INCLUDE "gfx/unknown/b6f1.pal" Palettes_b719: -INCLUDE "data/palettes/unknown/b719.pal" +INCLUDE "gfx/unknown/b719.pal" MalePokegearPals: -INCLUDE "data/palettes/pokegear.pal" +INCLUDE "gfx/pokegear/pokegear.pal" FemalePokegearPals: -INCLUDE "data/palettes/pokegear_f.pal" +INCLUDE "gfx/pokegear/pokegear_f.pal" Palettes_b789: -INCLUDE "data/palettes/unknown/b789.pal" +INCLUDE "gfx/unknown/b789.pal" SlotMachinePals: -INCLUDE "data/palettes/slot_machine.pal" +INCLUDE "gfx/slots/slots.pal" diff --git a/engine/credits.asm b/engine/credits.asm index 3dddb4126..ac5064a41 100644 --- a/engine/credits.asm +++ b/engine/credits.asm @@ -1,4 +1,4 @@ -INCLUDE "includes.asm" +INCLUDE "constants.asm" SECTION "Credits", ROMX @@ -13,7 +13,7 @@ Credits:: ; 109847 ld a, [rSVBK] push af - ld a, $5 + ld a, BANK(wPals) ld [rSVBK], a call ClearBGPalettes @@ -34,17 +34,17 @@ Credits:: ; 109847 ld de, CreditsBorderGFX ld hl, vTiles2 tile $20 - lb bc, BANK(CreditsBorderGFX), $09 + lb bc, BANK(CreditsBorderGFX), 9 call Request2bpp ld de, CopyrightGFX ld hl, vTiles2 tile $60 - lb bc, BANK(CopyrightGFX), $1d + lb bc, BANK(CopyrightGFX), 29 call Request2bpp ld de, TheEndGFX ld hl, vTiles2 tile $40 - lb bc, BANK(TheEndGFX), $10 + lb bc, BANK(TheEndGFX), 16 call Request2bpp ld a, $ff @@ -504,7 +504,7 @@ GetCreditsPalette: ; 109b2c .GetPalAddress: ; Each set of palette data is 24 bytes long. ld a, [wCreditsBorderMon] ; scene - and 3 + and %11 add a add a ; * 8 add a @@ -540,7 +540,7 @@ GetCreditsPalette: ; 109b2c ret CreditsPalettes: -INCLUDE "data/palettes/credits.pal" +INCLUDE "gfx/credits/credits.pal" ; 109bca Credits_LoadBorderGFX: ; 109bca (42:5bca) @@ -549,13 +549,13 @@ Credits_LoadBorderGFX: ; 109bca (42:5bca) cp $ff jr z, .init - and 3 + and %11 ld e, a inc a - and 3 + and %11 ld [hl], a ld a, [wCreditsBorderMon] - and 3 + and %11 add a add a add e diff --git a/engine/crystal_colors.asm b/engine/crystal_colors.asm index 5d2ba236c..31344791e 100755 --- a/engine/crystal_colors.asm +++ b/engine/crystal_colors.asm @@ -113,7 +113,7 @@ MG_Mobile_Layout_CreatePalBoxes: ; 49384 (12:5384) ; 493e1 (12:53e1) Palette_493e1: ; 493e1 -INCLUDE "data/palettes/mg_mobile.pal" +INCLUDE "gfx/mystery_gift/mg_mobile.pal" ; 49409 LoadOW_BGPal7:: ; 49409 @@ -126,11 +126,11 @@ LoadOW_BGPal7:: ; 49409 ; 49418 Palette_TextBG7: ; 49418 -INCLUDE "data/palettes/overworld/bg_text.pal" +INCLUDE "gfx/font/bg_text.pal" ; 49420 Function49420:: ; 49420 (12:5420) - ld hl, MansionPalette4 + ld hl, MansionPalette1 + 8 palettes ld de, wBGPals1 palette PAL_BG_ROOF ld bc, 1 palettes ld a, BANK(wBGPals1) @@ -204,7 +204,7 @@ Function49496: ; 49496 ret ; 494ac -INCLUDE "tilesets/special_palettes.asm" +INCLUDE "engine/tileset_palettes.asm" MG_Mobile_Layout02: ; 49706 ld hl, .Palette_49732 @@ -241,14 +241,14 @@ Function49742: ; 49742 ld hl, .Palette_49757 ld de, wBGPals1 ld bc, 8 palettes - ld a, $5 + ld a, BANK(wBGPals1) call FarCopyWRAM farcall ApplyPals ret ; 49757 .Palette_49757: ; 49757 -INCLUDE "data/palettes/unknown/49757.pal" +INCLUDE "gfx/unknown/49757.pal" ; 49797 _InitMG_Mobile_LinkTradePalMap: ; 49797 @@ -314,7 +314,7 @@ LoadTradeRoomBGPals: ; 49811 ; 49826 TradeRoomPalette: ; 49826 -INCLUDE "data/palettes/trade_room.pal" +INCLUDE "gfx/trade/border.pal" ; 49856 InitMG_Mobile_LinkTradePalMap: ; 49856 @@ -322,5 +322,5 @@ InitMG_Mobile_LinkTradePalMap: ; 49856 ret ; 4985a -Unknown_4985a: ; unreferenced -INCLUDE "data/palettes/unknown/4985a.asm" +; unused +INCLUDE "gfx/unknown/4985a.asm" diff --git a/engine/crystal_intro.asm b/engine/crystal_intro.asm index 302490a3b..ea6828f14 100755 --- a/engine/crystal_intro.asm +++ b/engine/crystal_intro.asm @@ -52,12 +52,12 @@ Copyright_GFPresents: ; e4579 .GetGFLogoGFX: ; e45e8 ld de, GameFreakLogo ld hl, vTiles2 - lb bc, BANK(GameFreakLogo), $1c + lb bc, BANK(GameFreakLogo), 28 call Get1bpp ld a, [rSVBK] push af - ld a, $6 + ld a, BANK(wDecompressScratch) ld [rSVBK], a ld hl, IntroLogoGFX @@ -94,7 +94,7 @@ Copyright_GFPresents: ; e4579 xor a ld [wJumptableIndex], a ld [wIntroSceneFrameCounter], a - ld [wcf65], a + ld [wIntroSceneTimer], a ld [hSCX], a ld [hSCY], a ld a, $1 @@ -146,7 +146,7 @@ PlaceGameFreakPresents_0: ; e468c ; e468d PlaceGameFreakPresents_1: ; e468d - ld hl, wcf65 + ld hl, wIntroSceneTimer ld a, [hl] cp $20 jr nc, .PlaceGameFreak @@ -173,7 +173,7 @@ PlaceGameFreakPresents_1: ; e468d ; e46ba PlaceGameFreakPresents_2: ; e46ba - ld hl, wcf65 + ld hl, wIntroSceneTimer ld a, [hl] cp $40 jr nc, .place_presents @@ -197,7 +197,7 @@ PlaceGameFreakPresents_2: ; e46ba ; e46dd PlaceGameFreakPresents_3: ; e46dd - ld hl, wcf65 + ld hl, wIntroSceneTimer ld a, [hl] cp $80 jr nc, .finish @@ -247,10 +247,10 @@ GameFreakLogoScene2: ; e470d (39:470d) ld hl, SPRITEANIMSTRUCT_0D add hl, bc ld a, [hl] - and $3f - cp $20 + and %111111 + cp %100000 jr nc, .asm_e4723 - add $20 + add %100000 .asm_e4723 ld e, a farcall BattleAnim_Sine_e @@ -319,7 +319,7 @@ GameFreakLogoScene4: ; e4776 (39:4776) add hl, de ld a, [rSVBK] push af - ld a, $5 + ld a, BANK(wOBPals2) ld [rSVBK], a ld a, [hli] ld [wOBPals2 + 12], a @@ -341,7 +341,7 @@ GameFreakLogoScene5: ; e47ab (39:47ab) ; e47ac (39:47ac) GameFreakLogoPalettes: ; e47ac -INCLUDE "data/palettes/crystal_intro/gamefreak_logo.pal" +INCLUDE "gfx/intro/gamefreak_logo.pal" ; e47cc GameFreakLogo: ; e47cc @@ -352,7 +352,7 @@ INCBIN "gfx/splash/logo2.1bpp" CrystalIntro: ; e48ac ld a, [rSVBK] push af - ld a, 5 + ld a, BANK(wPals) ld [rSVBK], a ld a, [hInMenu] push af @@ -480,7 +480,7 @@ IntroScene1: ; e495b (39:495b) call Intro_DecompressRequest2bpp_64Tiles ld a, [rSVBK] push af - ld a, $5 + ld a, BANK(wBGPals1) ld [rSVBK], a ld hl, Palette_365ad ld de, wBGPals1 @@ -503,7 +503,7 @@ IntroScene1: ; e495b (39:495b) call Intro_SetCGBPalUpdate xor a ld [wIntroSceneFrameCounter], a - ld [wcf65], a + ld [wIntroSceneTimer], a call NextIntroScene ret @@ -523,7 +523,7 @@ IntroScene2: ; e49d6 (39:49d6) call PlaySFX pop af .DontPlaySound: - ld [wcf65], a + ld [wIntroSceneTimer], a xor a call CrystalIntro_UnownFade ret @@ -553,7 +553,7 @@ IntroScene3: ; e49fd (39:49fd) call Intro_DecompressRequest2bpp_64Tiles ld a, [rSVBK] push af - ld a, $5 + ld a, BANK(wBGPals1) ld [rSVBK], a ld hl, Palette_e5edd ld de, wBGPals1 @@ -619,7 +619,7 @@ IntroScene5: ; e4a7a (39:4a7a) call Intro_DecompressRequest2bpp_64Tiles ld a, [rSVBK] push af - ld a, $5 + ld a, BANK(wBGPals1) ld [rSVBK], a ld hl, Palette_365ad ld de, wBGPals1 @@ -642,7 +642,7 @@ IntroScene5: ; e4a7a (39:4a7a) call Intro_SetCGBPalUpdate xor a ld [wIntroSceneFrameCounter], a - ld [wcf65], a + ld [wIntroSceneTimer], a call NextIntroScene ret @@ -669,7 +669,7 @@ IntroScene6: ; e4af7 (39:4af7) call PlaySFX pop af .NoUnown: - ld [wcf65], a + ld [wIntroSceneTimer], a xor a call CrystalIntro_UnownFade ret @@ -682,7 +682,7 @@ IntroScene6: ; e4af7 (39:4af7) call PlaySFX pop af .StopUnown: - ld [wcf65], a + ld [wIntroSceneTimer], a ld a, $1 call CrystalIntro_UnownFade ret @@ -725,7 +725,7 @@ IntroScene7: ; e4b3f (39:4b3f) ld a, [rSVBK] push af - ld a, $5 + ld a, BANK(wBGPals1) ld [rSVBK], a ld hl, Palette_e5edd @@ -758,7 +758,7 @@ IntroScene7: ; e4b3f (39:4b3f) call Intro_SetCGBPalUpdate xor a ld [wIntroSceneFrameCounter], a - ld [wcf65], a + ld [wIntroSceneTimer], a call NextIntroScene ret @@ -884,7 +884,7 @@ IntroScene11: ; e4c86 (39:4c86) call Intro_DecompressRequest2bpp_64Tiles ld a, [rSVBK] push af - ld a, $5 + ld a, BANK(wBGPals1) ld [rSVBK], a ld hl, Palette_365ad ld de, wBGPals1 @@ -907,7 +907,7 @@ IntroScene11: ; e4c86 (39:4c86) call Intro_SetCGBPalUpdate xor a ld [wIntroSceneFrameCounter], a - ld [wcf65], a + ld [wIntroSceneTimer], a call NextIntroScene ret @@ -925,7 +925,7 @@ IntroScene12: ; e4cfa (39:4cfa) ld c, a and $1f sla a - ld [wcf65], a + ld [wIntroSceneTimer], a ld a, c and $e0 srl a @@ -939,7 +939,7 @@ IntroScene12: ; e4cfa (39:4cfa) and $f sla a sla a - ld [wcf65], a + ld [wIntroSceneTimer], a ld a, c and $70 or $40 @@ -1011,7 +1011,7 @@ IntroScene13: ; e4d6d (39:4d6d) call Intro_DecompressRequest2bpp_64Tiles ld a, [rSVBK] push af - ld a, $5 + ld a, BANK(wBGPals1) ld [rSVBK], a ld hl, Palette_e5edd ld de, wBGPals1 @@ -1041,7 +1041,7 @@ IntroScene13: ; e4d6d (39:4d6d) call Intro_SetCGBPalUpdate xor a ld [wIntroSceneFrameCounter], a - ld [wcf65], a + ld [wIntroSceneTimer], a call NextIntroScene ret @@ -1068,7 +1068,7 @@ IntroScene14: ; e4dfa (39:4dfa) .asm_e4e1a ld a, $1 - ld [wcf65], a + ld [wIntroSceneTimer], a ld a, [wGlobalAnimXOffset] cp $88 jr c, .asm_e4e2c @@ -1120,7 +1120,7 @@ IntroScene15: ; e4e40 (39:4e40) call Intro_LoadTilemap ld a, [rSVBK] push af - ld a, $5 + ld a, BANK(wBGPals1) ld [rSVBK], a ld hl, Palette_e77dd ld de, wBGPals1 @@ -1150,7 +1150,7 @@ IntroScene15: ; e4e40 (39:4e40) call _InitSpriteAnimStruct xor a ld [wIntroSceneFrameCounter], a - ld [wcf65], a + ld [wIntroSceneTimer], a call NextIntroScene ret @@ -1194,7 +1194,7 @@ IntroScene17: ; e4ef5 (39:4ef5) call Intro_DecompressRequest2bpp_64Tiles ld a, [rSVBK] push af - ld a, $5 + ld a, BANK(wBGPals1) ld [rSVBK], a ld hl, Palette_e6d6d ld de, wBGPals1 @@ -1217,7 +1217,7 @@ IntroScene17: ; e4ef5 (39:4ef5) call Intro_SetCGBPalUpdate xor a ld [wIntroSceneFrameCounter], a - ld [wcf65], a + ld [wIntroSceneTimer], a call NextIntroScene ret @@ -1268,7 +1268,7 @@ IntroScene19: ; e4f7e (39:4f7e) call Intro_LoadTilemap ld a, [rSVBK] push af - ld a, $5 + ld a, BANK(wBGPals1) ld [rSVBK], a ld hl, Palette_e77dd ld de, wBGPals1 @@ -1299,7 +1299,7 @@ IntroScene19: ; e4f7e (39:4f7e) call _InitSpriteAnimStruct xor a ld [wIntroSceneFrameCounter], a - ld [wcf65], a + ld [wIntroSceneTimer], a call NextIntroScene ret @@ -1331,7 +1331,7 @@ IntroScene20: ; e5019 (39:5019) and $1c srl a srl a - ld [wcf65], a + ld [wIntroSceneTimer], a xor a call Intro_Scene20_AppearUnown ret @@ -1341,7 +1341,7 @@ IntroScene20: ; e5019 (39:5019) and $1c srl a srl a - ld [wcf65], a + ld [wIntroSceneTimer], a ld a, 1 call Intro_Scene20_AppearUnown ret @@ -1358,7 +1358,7 @@ IntroScene21: ; e505d (39:505d) xor a ld [hBGMapMode], a ld [wIntroSceneFrameCounter], a - ld [wcf65], a + ld [wIntroSceneTimer], a call NextIntroScene ret @@ -1438,7 +1438,7 @@ IntroScene26: ; e50bb (39:50bb) call Intro_DecompressRequest2bpp_64Tiles ld a, [rSVBK] push af - ld a, $5 + ld a, BANK(wBGPals1) ld [rSVBK], a ld hl, Palette_e679d ld de, wBGPals1 @@ -1461,13 +1461,13 @@ IntroScene26: ; e50bb (39:50bb) call Intro_SetCGBPalUpdate xor a ld [wIntroSceneFrameCounter], a - ld [wcf65], a + ld [wIntroSceneTimer], a call NextIntroScene ret IntroScene27: ; e512d (39:512d) ; Spell out C R Y S T A L with Unown. - ld hl, wcf65 + ld hl, wIntroSceneTimer inc [hl] ld hl, wIntroSceneFrameCounter ld a, [hl] @@ -1477,7 +1477,7 @@ IntroScene27: ; e512d (39:512d) ld c, a and $f - ld [wcf65], a + ld [wIntroSceneTimer], a ld a, c and $70 swap a @@ -1526,7 +1526,7 @@ Intro_Scene24_ApplyPaletteFade: ; e5172 (39:5172) ld a, [rSVBK] push af - ld a, $5 + ld a, BANK(wBGPals2) ld [rSVBK], a ld de, wBGPals2 ld b, 8 ; number of BG pals @@ -1550,7 +1550,7 @@ Intro_Scene24_ApplyPaletteFade: ; e5172 (39:5172) ; e519c (39:519c) .FadePals: ; e519c -INCLUDE "data/palettes/crystal_intro/fade.pal" +INCLUDE "gfx/intro/fade.pal" ; e51dc CrystalIntro_InitUnownAnim: ; e51dc (39:51dc) @@ -1603,13 +1603,13 @@ CrystalIntro_UnownFade: ; e5223 (39:5223) add hl, de inc hl inc hl - ld a, [wcf65] - and $3f - cp $1f + ld a, [wIntroSceneTimer] + and %111111 + cp %011111 jr z, .okay jr c, .okay ld c, a - ld a, $3f + ld a, %111111 sub c .okay @@ -1617,7 +1617,7 @@ CrystalIntro_UnownFade: ; e5223 (39:5223) ld b, $0 ld a, [rSVBK] push af - ld a, $5 + ld a, BANK(wBGPals2) ld [rSVBK], a push hl @@ -1714,7 +1714,7 @@ Intro_Scene20_AppearUnown: ; e5348 (39:5348) ld hl, .pal2 .got_pointer - ld a, [wcf65] + ld a, [wIntroSceneTimer] and $7 add a add a @@ -1722,7 +1722,7 @@ Intro_Scene20_AppearUnown: ; e5348 (39:5348) ld c, a ld a, [rSVBK] push af - ld a, $5 + ld a, BANK(wBGPals2) ld [rSVBK], a push bc @@ -1784,14 +1784,14 @@ Intro_FadeUnownWordPals: ; e539d (39:539d) rept 4 inc hl endr - ld a, [wcf65] + ld a, [wIntroSceneTimer] add a ld c, a ld b, $0 ld a, [rSVBK] push af - ld a, $5 + ld a, BANK(wBGPals2) ld [rSVBK], a push hl @@ -1846,7 +1846,7 @@ endr Intro_LoadTilemap: ; e541b (39:541b) ld a, [rSVBK] push af - ld a, $6 + ld a, BANK(wDecompressScratch) ld [rSVBK], a ld hl, wDecompressScratch @@ -1946,7 +1946,7 @@ Intro_SetCGBPalUpdate: ; e549e (39:549e) Intro_ClearBGPals: ; e54a3 (39:54a3) ld a, [rSVBK] push af - ld a, $5 + ld a, BANK(wBGPals2) ld [rSVBK], a ld hl, wBGPals2 @@ -1965,7 +1965,7 @@ Intro_ClearBGPals: ; e54a3 (39:54a3) Intro_DecompressRequest2bpp_128Tiles: ; e54c2 (39:54c2) ld a, [rSVBK] push af - ld a, $6 + ld a, BANK(wDecompressScratch) ld [rSVBK], a push de @@ -1984,7 +1984,7 @@ Intro_DecompressRequest2bpp_128Tiles: ; e54c2 (39:54c2) Intro_DecompressRequest2bpp_255Tiles: ; e54de (39:54de) ld a, [rSVBK] push af - ld a, $6 + ld a, BANK(wDecompressScratch) ld [rSVBK], a push de @@ -2003,7 +2003,7 @@ Intro_DecompressRequest2bpp_255Tiles: ; e54de (39:54de) Intro_DecompressRequest2bpp_64Tiles: ; e54fa (39:54fa) ld a, [rSVBK] push af - ld a, $6 + ld a, BANK(wDecompressScratch) ld [rSVBK], a push de @@ -2022,7 +2022,7 @@ Intro_DecompressRequest2bpp_64Tiles: ; e54fa (39:54fa) Intro_ResetLYOverrides: ; e5516 (39:5516) ld a, [rSVBK] push af - ld a, $5 + ld a, BANK(LYOverrides) ld [rSVBK], a ld hl, LYOverrides @@ -2039,7 +2039,7 @@ Intro_ResetLYOverrides: ; e5516 (39:5516) Intro_PerspectiveScrollBG: ; e552f (39:552f) ld a, [rSVBK] push af - ld a, $5 + ld a, BANK(LYOverrides) ld [rSVBK], a ; Scroll the grass every frame. ; Scroll the trees every other frame and at half speed. @@ -2088,7 +2088,7 @@ INCBIN "gfx/intro/003.tilemap.lz" ; e5edd Palette_e5edd: ; e5edd -INCLUDE "data/palettes/crystal_intro/intro_1.pal" +INCLUDE "gfx/intro/intro_1.pal" ; e5f5d IntroUnownsGFX: ; e5f5d @@ -2124,7 +2124,7 @@ INCBIN "gfx/intro/007.tilemap.lz" ; e65ad Palette_365ad: ; e65ad -INCLUDE "data/palettes/crystal_intro/intro_2.pal" +INCLUDE "gfx/intro/intro_2.pal" ; e662d IntroCrystalUnownsGFX: ; e662d @@ -2140,7 +2140,7 @@ INCBIN "gfx/intro/015.tilemap.lz" ; e679d Palette_e679d: ; e679d -INCLUDE "data/palettes/crystal_intro/intro_3.pal" +INCLUDE "gfx/intro/intro_3.pal" ; e681d IntroSuicuneCloseGFX: ; e681d @@ -2156,7 +2156,7 @@ INCBIN "gfx/intro/011.tilemap.lz" ; e6d6d Palette_e6d6d: ; e6d6d -INCLUDE "data/palettes/crystal_intro/intro_4.pal" +INCLUDE "gfx/intro/intro_4.pal" ; e6ded IntroSuicuneJumpGFX: ; e6ded @@ -2184,7 +2184,7 @@ INCBIN "gfx/intro/013.tilemap.lz" ; e77dd Palette_e77dd: ; e77dd -INCLUDE "data/palettes/crystal_intro/intro_5.pal" +INCLUDE "gfx/intro/intro_5.pal" IntroUnownBackGFX: ; e785d INCBIN "gfx/intro/unown_back.2bpp.lz" diff --git a/engine/debug.asm b/engine/debug.asm index 1e0d042e0..a23e9d674 100755 --- a/engine/debug.asm +++ b/engine/debug.asm @@ -155,7 +155,7 @@ Function819a7: ; 819a7 ret z ld a, [rSVBK] push af - ld a, $5 + ld a, BANK(wBGPals2) ld [rSVBK], a ld hl, Palette_819f4 ld de, wBGPals2 @@ -193,10 +193,10 @@ Function819a7: ; 819a7 ; 819f4 Palette_819f4: ; 819f4 -INCLUDE "data/palettes/debug/bg.pal" +INCLUDE "gfx/debug/bg.pal" Palette_81a34: ; 81a34 -INCLUDE "data/palettes/debug/ob.pal" +INCLUDE "gfx/debug/ob.pal" ; 81a74 Function81a74: ; 81a74 @@ -315,12 +315,12 @@ Function81adb: ; 81adb hlcoord 12, 3 call _PrepMonFrontpic ld de, vTiles2 tile $31 - predef GetMonBackpic + predef Predef_GetMonBackpic ld a, $31 ld [hGraphicStartTile], a hlcoord 2, 4 lb bc, 6, 6 - predef PlaceGraphic + predef Predef_PlaceGraphic ld a, [wd003] and a jr z, .asm_81b66 @@ -346,13 +346,13 @@ Function81adb: ; 81adb hlcoord 4, 1 call PlaceString ld de, vTiles2 - callfar GetTrainerPic + callfar Predef_GetTrainerPic xor a ld [TempEnemyMonSpecies], a ld [hGraphicStartTile], a hlcoord 2, 3 lb bc, 7, 7 - predef PlaceGraphic + predef Predef_PlaceGraphic .asm_81ba9 ld a, $1 @@ -436,7 +436,7 @@ Function81c33: ; 81c33 jr z, .asm_81c69 ld a, [rSVBK] push af - ld a, $5 + ld a, BANK(wBGPals2) ld [rSVBK], a ld hl, wBGPals2 ld de, wc608 @@ -739,7 +739,7 @@ Function81df4: ; 81df4 ld a, [wd004] inc a ld [wd265], a - predef GetTMHMMove + predef Predef_GetTMHMMove ld a, [wd265] ld [wPutativeTMHMMove], a call GetMoveName @@ -748,7 +748,7 @@ Function81df4: ; 81df4 ld a, [wd004] call Function81e55 ld [CurItem], a - predef CanLearnTMHMMove + predef Predef_CanLearnTMHMMove ld a, c and a ld de, String_81e46 @@ -1016,17 +1016,17 @@ Function81f5e: ; 81f5e .asm_81fb7 ld a, b - ld [hli], a + ld [hli], a ; y ld a, [de] add a add a - add $18 - ld [hli], a + add 3 * TILE_WIDTH + ld [hli], a ; x xor a - ld [hli], a + ld [hli], a ; tile id ld a, c - ld [hli], a - ld a, $10 + ld [hli], a ; attributes + ld a, 2 * TILE_WIDTH add b ld b, a inc c @@ -1061,9 +1061,9 @@ TilesetColorTest: call WaitBGMap2 xor a ld [hBGMapMode], a - ld de, DebugColorTestGFX + $10 + ld de, DebugColorTestGFX + 1 tiles ld hl, vTiles2 tile $6a - lb bc, BANK(DebugColorTestGFX), $16 + lb bc, BANK(DebugColorTestGFX), 22 call Request2bpp ld de, DebugColorTestGFX ld hl, vTiles1 @@ -1145,7 +1145,7 @@ Function82203: ; 82203 Function8220f: ; 8220f ld a, [rSVBK] push af - ld a, $5 + ld a, BANK(wBGPals1) ld [rSVBK], a ld a, [wcf64] ld l, a @@ -1198,7 +1198,7 @@ Function82236: ; 82236 call Function821d8 ld a, [rSVBK] push af - ld a, $5 + ld a, BANK(wBGPals2) ld [rSVBK], a ld hl, wBGPals2 ld a, [wcf64] @@ -1228,7 +1228,7 @@ Function82236: ; 82236 Function822a3: ; 822a3 ld a, [rSVBK] push af - ld a, $5 + ld a, BANK(wBGPals2) ld [rSVBK], a ld hl, wBGPals2 ld a, [wcf64] diff --git a/engine/decorations.asm b/engine/decorations.asm index 72a4d1aee..413a049a2 100755 --- a/engine/decorations.asm +++ b/engine/decorations.asm @@ -38,8 +38,7 @@ _KrisDecorationMenu: ; 0x2675c .MenuDataHeader: ; 0x2679a db MENU_BACKUP_TILES ; flags - db 00, 05 ; start coords - db 17, 19 ; end coords + menu_coords 5, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1 dw .MenuData2 db 1 ; default option ; 0x267a2 @@ -424,8 +423,7 @@ PopulateDecoCategoryMenu: ; 2695b .NonscrollingMenuDataHeader: ; 0x269b5 db MENU_BACKUP_TILES ; flags - db 00, 00 ; start coords - db 17, 19 ; end coords + menu_coords 0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1 dw .NonscrollingMenuData2 db 1 ; default option ; 0x269bd @@ -440,8 +438,7 @@ PopulateDecoCategoryMenu: ; 2695b .ScrollingMenuDataHeader: ; 0x269c5 db MENU_BACKUP_TILES ; flags - db 01, 01 ; start coords - db 16, 18 ; end coords + menu_coords 1, 1, SCREEN_WIDTH - 2, SCREEN_HEIGHT - 2 dw .ScrollingMenuData2 db 1 ; default option ; 0x269cd @@ -952,8 +949,7 @@ QueryWhichSide: ; 26e9a MenuDataHeader_0x26eab: ; 0x26eab db MENU_BACKUP_TILES ; flags - db 00, 00 ; start coords - db 07, 13 ; end coords + menu_coords 0, 0, 13, 7 dw MenuData2_0x26eb3 db 1 ; default option ; 0x26eb3 @@ -1061,12 +1057,13 @@ INCLUDE "data/decorations/decorations.asm" DescribeDecoration:: ; 26f59 ld a, b - ld hl, JumpTable_DecorationDesc + ld hl, .JumpTable rst JumpTable ret ; 26f5f -JumpTable_DecorationDesc: ; 26f5f +.JumpTable: ; 26f5f +; entries correspond to DECODESC_* constants dw DecorationDesc_Poster dw DecorationDesc_LeftOrnament dw DecorationDesc_RightOrnament @@ -1197,7 +1194,7 @@ DecorationDesc_GiantOrnament: ; 26fdd db "@" ; 0x26feb -ToggleMaptileDecorations: ; 26feb +Special_ToggleMaptileDecorations: ; 26feb lb de, 0, 4 ld a, [Bed] call SetDecorationTile @@ -1251,7 +1248,7 @@ SetDecorationTile: ; 27037 ret ; 27043 -ToggleDecorationsVisibility: ; 27043 +Special_ToggleDecorationsVisibility: ; 27043 ld de, EVENT_KRISS_HOUSE_2F_CONSOLE ld hl, VariableSprites + SPRITE_CONSOLE - SPRITE_VARS ld a, [Console] diff --git a/engine/delete_save_change_clock.asm b/engine/delete_save_change_clock.asm index b00c1ccc4..8a711cc5e 100755 --- a/engine/delete_save_change_clock.asm +++ b/engine/delete_save_change_clock.asm @@ -48,8 +48,7 @@ _ResetClock: ; 4d3b1 .NoYes_MenuDataHeader: ; 0x4d40d db 0 ; flags - db 07, 14 ; start coords - db 11, 19 ; end coords + menu_coords 14, 7, SCREEN_WIDTH - 1, TEXTBOX_Y - 1 dw .NoYes_MenuData2 db 1 ; default option @@ -286,8 +285,7 @@ _DeleteSaveData: ; 4d54c .NoYesMenuDataHeader: ; 0x4d585 db 0 ; flags - db 07, 14 ; start coords - db 11, 19 ; end coords + menu_coords 14, 7, SCREEN_WIDTH - 1, TEXTBOX_Y - 1 dw .MenuData2 db 1 ; default option diff --git a/engine/dma_transfer.asm b/engine/dma_transfer.asm index 56e7d56da..60b515acf 100755 --- a/engine/dma_transfer.asm +++ b/engine/dma_transfer.asm @@ -112,14 +112,14 @@ Mobile_ReloadMapPart: ; 104099 ret ; 1040d4 -; XXX +; unused ld hl, .unreferenced_1040da jp CallInSafeGFXMode .unreferenced_1040da ld a, $1 ld [rVBK], a - ld a, $3 + ld a, BANK(w3_d800) ld [rSVBK], a ld de, w3_d800 ld a, [hBGMapAddress + 1] @@ -136,14 +136,14 @@ Mobile_ReloadMapPart: ; 104099 ret ; 1040fb -; XXX +; unused ld hl, .unreferenced_104101 jp CallInSafeGFXMode .unreferenced_104101 ld a, $1 ld [rVBK], a - ld a, $3 + ld a, BANK(w3_d800) ld [rSVBK], a ld hl, w3_d800 call HDMATransferToWRAMBank3 @@ -221,7 +221,7 @@ CallInSafeGFXMode: ; 104177 ld [hMapAnims], a ld a, [rSVBK] push af - ld a, $6 + ld a, BANK(wScratchTileMap) ld [rSVBK], a ld a, [rVBK] push af @@ -472,7 +472,7 @@ _Get2bpp:: ; 104284 ; switch to WRAM bank 6 ld a, [rSVBK] push af - ld a, $6 + ld a, BANK(wScratchTileMap) ld [rSVBK], a push bc @@ -542,7 +542,7 @@ _Get1bpp:: ; 1042b2 .bankswitch ; 1042d6 ld a, [rSVBK] push af - ld a, $6 + ld a, BANK(wScratchTileMap) ld [rSVBK], a push bc diff --git a/engine/events.asm b/engine/events.asm index 7356a8910..f95e9ab12 100644 --- a/engine/events.asm +++ b/engine/events.asm @@ -1,4 +1,5 @@ -INCLUDE "includes.asm" +INCLUDE "constants.asm" + SECTION "Events", ROMX @@ -994,6 +995,7 @@ CountStep: ; 96b79 ret ; 96bd3 +; unused .unreferenced ; 96bd3 ld a, 7 scf @@ -1060,7 +1062,7 @@ Invalid_0x96c2d: ; 96c2d end ; 96c2e -; unreferenced +; unused end ; 96c2f @@ -1105,4 +1107,5 @@ ChangeDirectionScript: ; 9 ; 96c56 INCLUDE "engine/scripting.asm" + INCLUDE "engine/events_2.asm" diff --git a/engine/events/battle_tower/battle_tower.asm b/engine/events/battle_tower/battle_tower.asm new file mode 100755 index 000000000..93b283d27 --- /dev/null +++ b/engine/events/battle_tower/battle_tower.asm @@ -0,0 +1,1669 @@ +Special_BattleTowerRoomMenu: ; 1700b0 +; special + call InitBattleTowerChallengeRAM + farcall _BattleTowerRoomMenu + ret +; 1700ba + +Special_Function1700ba: ; 1700ba + call InitBattleTowerChallengeRAM + farcall Function11811a + ret +; 1700c4 + +Function1700c4: ; 1700c4 + ld a, [rSVBK] + push af + ld a, $3 + ld [rSVBK], a + + call Function17042c + + ld a, $5 + call GetSRAMBank + ld a, $1 + ld [$be45], a + xor a + ld [$be46], a + ld hl, w3_dffc + ld de, $aa41 + ld bc, 4 + call CopyBytes + ld hl, w3_d202Name + ld de, $aa8e + ld bc, 7 * $cc ; length of battle tower struct from japanese games? + call CopyBytes + ld hl, $aa5d ; some sort of count + ld a, [hl] + inc [hl] + inc hl + sla a + sla a + ld e, a + ld d, $0 + add hl, de + ld e, l + ld d, h + ld hl, w3_dffc + ld bc, 4 + call CopyBytes + call CloseSRAM + pop af + ld [rSVBK], a + ret +; 170114 + +Special_Function170114: ; 170114 + call InitBattleTowerChallengeRAM + call .Function170121 + farcall Function11805f + ret +; 170121 + +.Function170121: ; 170121 + ld a, $5 + call GetSRAMBank + ld hl, $a948 + ld de, wMisc + ld bc, $f6 ; 246 + call CopyBytes + call CloseSRAM + call Function170c8b + ret +; 170139 + +Function170139: ; 170139 +; Convert the 4-digit decimal number at 5:aa41 into binary + ld a, $5 + call GetSRAMBank + ld de, $aa41 + ld h, $0 + ld l, h + ld bc, 1000 + call .DecToBin + ld bc, 100 + call .DecToBin + ld bc, 10 + call .DecToBin + ld a, [de] + ld c, a + ld b, $0 + add hl, bc + call CloseSRAM +; Store that number in wMisc + ld a, h + ld [wMisc], a + ld a, l + ld [wMisc + 1], a + ld hl, wBT_OTTempPkmn1DVs + ld a, [PlayerID] + ld [hli], a + ld a, [PlayerID + 1] + ld [hli], a + ld a, [wSecretID] + ld [hli], a + ld a, [wSecretID + 1] + ld [hli], a + ld e, l + ld d, h + ld hl, PlayerName + ld bc, NAME_LENGTH_JAPANESE - 1 + call CopyBytes + ld bc, PlayerID + ld de, wPlayerGender + farcall GetMobileOTTrainerClass + ld de, wBT_OTTempPkmn1CaughtGender + ld a, c + ld [de], a + inc de + ld a, LOW(PartyMons) + ld [wcd49], a + ld a, HIGH(PartyMons) + ld [wcd4a], a + ld a, LOW(PartyMonNicknames) + ld [wcd4b], a + ld a, HIGH(PartyMonNicknames) + ld [wcd4c], a + ld a, 3 +.CopyLoop: + push af + ld a, [wcd49] + ld l, a + ld a, [wcd4a] + ld h, a + ld bc, PARTYMON_STRUCT_LENGTH + call CopyBytes + ld a, l + ld [wcd49], a + ld a, h + ld [wcd4a], a + ld a, [wcd4b] + ld l, a + ld a, [wcd4c] + ld h, a + ld bc, $0006 + call CopyBytes + ld a, l + ld [wcd4b], a + ld a, h + ld [wcd4c], a + pop af + dec a + jr nz, .CopyLoop + ld a, $4 + call GetSRAMBank + ld hl, $a013 + ld bc, $24 + call CopyBytes + call CloseSRAM + ld a, $5 + call GetSRAMBank + ld hl, $a894 + ld bc, NAME_LENGTH_JAPANESE + call CopyBytes + ld hl, wMisc + ld de, $a948 + ld bc, $f6 + call CopyBytes + call CloseSRAM + ret +; 17020c + +.DecToBin: ; 17020c + ld a, [de] + inc de + and a + ret z + +.digit_loop + add hl, bc + dec a + jr nz, .digit_loop + ret +; 170215 + +Special_BattleTowerBattle: ; 170215 + xor a + ld [wBattleTowerBattleEnded], a + call _BattleTowerBattle + ret +; 17021d + +DummySpecial_17021d: ; 17021d + ret +; 17021e + +InitBattleTowerChallengeRAM: ; 17021e + xor a + ld [wBattleTowerBattleEnded], a + ld [wNrOfBeatenBattleTowerTrainers], a + ld [wcf65], a + ld [wcf66], a + ret +; 17022c + +_BattleTowerBattle: ; 17022c +.loop + call .do_dw + call DelayFrame + ld a, [wBattleTowerBattleEnded] + cp $1 + jr nz, .loop + ret +; 17023a + +.do_dw ; 17023a + ld a, [wBattleTowerBattleEnded] + ld e, a + ld d, 0 + ld hl, .dw + add hl, de + add hl, de + ld a, [hli] + ld h, [hl] + ld l, a + jp hl +; 170249 + +.dw ; 170249 + dw RunBattleTowerTrainer + dw SkipBattleTowerTrainer +; 17024d + +RunBattleTowerTrainer: ; 17024d + ld a, [Options] + push af + ld hl, Options + set BATTLE_SHIFT, [hl] ; SET MODE + + ld a, [InBattleTowerBattle] + push af + or $1 + ld [InBattleTowerBattle], a + + xor a + ld [wLinkMode], a + farcall Special_StubbedTrainerRankings_Healings + farcall HealParty + call ReadBTTrainerParty + call Clears5_a89a + + predef Predef_StartBattle + + farcall LoadPokemonData + farcall HealParty + ld a, [wBattleResult] + ld [ScriptVar], a + and a + jr nz, .lost + ld a, BANK(sNrOfBeatenBattleTowerTrainers) + call GetSRAMBank + ld a, [sNrOfBeatenBattleTowerTrainers] + ld [wNrOfBeatenBattleTowerTrainers], a + call CloseSRAM + ld hl, StringBuffer3 + ld a, [wNrOfBeatenBattleTowerTrainers] + add "1" + ld [hli], a + ld a, "@" + ld [hl], a + +.lost + pop af + ld [InBattleTowerBattle], a + pop af + ld [Options], a + ld a, $1 + ld [wBattleTowerBattleEnded], a + ret + + +ReadBTTrainerParty: ; 1702b7 +; Initialise the BattleTower-Trainer and his Pkmn + call CopyBTTrainer_FromBT_OT_TowBT_OTTemp + +; Check the nicknames for illegal characters, and replace bad nicknames +; with their species names. + ld de, wBT_OTTempPkmn1Name ; $c643 + ld c, PKMN_NAME_LENGTH + farcall CheckStringForErrors + jr nc, .skip_mon_1 + + ld a, [wBT_OTTempPkmn1] + ld [wNamedObjectIndexBuffer], a + call GetPokemonName + ld l, e + ld h, d + ld de, wBT_OTTempPkmn1Name ; $c643 + ld bc, PKMN_NAME_LENGTH + call CopyBytes + +.skip_mon_1 + ld de, wBT_OTTempPkmn2Name ; $c67e + ld c, PKMN_NAME_LENGTH + farcall CheckStringForErrors + jr nc, .skip_mon_2 + ld a, [wBT_OTTempPkmn2] ; [$c64e] + ld [wNamedObjectIndexBuffer], a + call GetPokemonName + ld l, e + ld h, d + ld de, wBT_OTTempPkmn2Name ; $c67e + ld bc, PKMN_NAME_LENGTH + call CopyBytes + +.skip_mon_2 + ld de, wBT_OTTempPkmn3Name ; $c686 + 51 = $c6b9 + ld c, PKMN_NAME_LENGTH + farcall CheckStringForErrors + jr nc, .skip_mon_3 + ld a, [wBT_OTTempPkmn3] ; [$c689] + ld [wNamedObjectIndexBuffer], a + call GetPokemonName + ld l, e + ld h, d + ld de, wBT_OTTempPkmn3Name ; $c686 + 51 = $c6b9 + ld bc, PKMN_NAME_LENGTH + call CopyBytes + +.skip_mon_3 +; Add the terminator character to each of these names + ld a, "@" + ld [wBT_OTTempPkmn1NameEnd - 1], a ; $c64d + ld [wBT_OTTempPkmn2NameEnd - 1], a ; $c688 + ld [wBT_OTTempPkmn3NameEnd - 1], a ; $c68a + 57 = $c6c3 +; Fix errors in the movesets + call CheckBTMonMovesForErrors +; Repair the trainer name if needed, then copy it to OTPlayerName + ld de, wBT_OTTempName + ld c, NAME_LENGTH - 1 + farcall CheckStringForErrors + jr nc, .trainer_name_okay + ld hl, BT_ChrisName + jr .done_trainer_name + +.trainer_name_okay + ld hl, wBT_OTTempName ; 0xc608 + +.done_trainer_name + ld de, OTPlayerName + ld bc, NAME_LENGTH - 1 + call CopyBytes + ld a, "@" + ld [de], a + + ld hl, wBT_OTTempTrainerClass + ld a, [hli] + ld [OtherTrainerClass], a + ld a, LOW(OTPartyMonNicknames) + ld [BGMapBuffer], a + ld a, HIGH(OTPartyMonNicknames) + ld [BGMapBuffer + 1], a + + ; Copy Pkmn into Memory from the address in hl + ld de, OTPartyMon1Species + ld bc, OTPartyCount + ld a, BATTLETOWER_NROFPKMNS ; Number of Pkmn the BattleTower-Trainer has + ld [bc], a + inc bc +.otpartymon_loop + push af + ld a, [hl] + ld [bc], a + inc bc + push bc + ld bc, PARTYMON_STRUCT_LENGTH + call CopyBytes + push de + ld a, [BGMapBuffer] + ld e, a + ld a, [BGMapBuffer + 1] + ld d, a + ld bc, PKMN_NAME_LENGTH + call CopyBytes + ld a, e + ld [BGMapBuffer], a + ld a, d + ld [BGMapBuffer + 1], a + pop de + pop bc + pop af + dec a + and a + jr nz, .otpartymon_loop + ld a, -1 + ld [bc], a + ret +; 170394 + +ValidateBTParty: ; 170394 +; Check for and fix errors in party data + ld hl, wBT_OTTempPkmn1Species + ld d, BATTLETOWER_NROFPKMNS +.pkmn_loop + push de + push hl + ld b, h + ld c, l + ld a, [hl] + and a +idx = $ff +rept ($ff +- NUM_POKEMON) + jr z, .invalid + cp idx +idx = idx +- 1 +endr + jr nz, .valid + +.invalid + ld a, SMEARGLE + ld [hl], a + +.valid + ld [CurSpecies], a + call GetBaseData + ld a, $5 + call GetSRAMBank + ld a, [$b2fb] ; s5_b2fb ; max level? + call CloseSRAM + ld e, a + ld hl, MON_LEVEL + add hl, bc + ld a, [hl] + cp MIN_LEVEL + ld a, MIN_LEVEL + jr c, .load + ld a, [hl] + cp e + jr c, .dont_load + ld a, e + +.load + ld [hl], a + +.dont_load + ld [CurPartyLevel], a + ld hl, MON_MOVES + add hl, bc + ld d, NUM_MOVES - 1 + ld a, [hli] + and a + jr z, .not_move + cp NUM_ATTACKS + 1 + jr nc, .not_move + jr .valid_move + +.not_move + dec hl + ld a, POUND + ld [hli], a + xor a + ld [hli], a + ld [hli], a + ld [hl], a + jr .done_moves + +.valid_move + ld a, [hl] + cp NUM_ATTACKS + 1 + jr c, .next + ld [hl], $0 + +.next + inc hl + dec d + jr nz, .valid_move + +.done_moves + ld hl, MON_MAXHP + add hl, bc + ld d, h + ld e, l + push hl + push de + ld hl, MON_STAT_EXP - 1 + add hl, bc + ld b, $1 + predef Predef_CalcPkmnStats + pop de + pop hl + dec de + dec de + ld a, [hli] + ld [de], a + inc de + ld a, [hl] + ld [de], a + pop hl + ld bc, PARTYMON_STRUCT_LENGTH + PKMN_NAME_LENGTH + add hl, bc + pop de + dec d + jp nz, .pkmn_loop + ret +; 170426 + +BT_ChrisName: ; 170426 + db "CHRIS@" +; 17042c + +Function17042c: ; 17042c + ld hl, w3_d202TrainerData + ld a, BATTLETOWER_NROFTRAINERS +.loop + push af + push hl + ld c, BATTLETOWER_TRAINERDATALENGTH / 2 +.loop2 + ; First byte is a comparison value. + ld a, [hli] + ld b, a + ; Second byte is a lookup index. + ld a, [hli] + and a + jr z, .empty + cp 15 + jr nc, .copy_data + + push hl + ld hl, Unknown_170470 + dec a + ld e, a + ld d, 0 + add hl, de + ld a, [hl] + pop hl + + ; If Unknown_170470[a-1] <= b, overwrite the current trainer's data + ; with Unknown17047e, and exit the inner loop. + cp b + jr c, .copy_data + jr z, .copy_data + jr .next_iteration + +.empty + ; If a == 0 and b >= $fc, overwrite the current trainer's data with + ; Unknown17047e, and exit the inner loop. + ld a, b + cp $fc + jr nc, .copy_data + +.next_iteration + dec c + jr nz, .loop2 + jr .next_trainer + +.copy_data + pop de + push de + ld hl, Unknown_17047e + ld bc, BATTLETOWER_TRAINERDATALENGTH + call CopyBytes + +.next_trainer + pop hl + ld de, BATTLE_TOWER_STRUCT_LENGTH + add hl, de + pop af + dec a + jr nz, .loop + ret +; 170470 + +INCLUDE "data/battle_tower/unknown_levels.asm" + + +CopyBTTrainer_FromBT_OT_TowBT_OTTemp: ; 1704a2 +; copy the BattleTower-Trainer data that lies at 'BT_OTTrainer' to 'wBT_OTTemp' + ld a, [rSVBK] + push af + ld a, BANK(BT_OTTrainer) + ld [rSVBK], a + + ld hl, BT_OTTrainer + ld de, wBT_OTTemp + ld bc, BATTLE_TOWER_STRUCT_LENGTH + call CopyBytes + + pop af + ld [rSVBK], a + + ld a, BANK(sBattleTowerChallengeState) + call GetSRAMBank + ld a, BATTLETOWER_CHALLENGE_IN_PROGESS + ld [sBattleTowerChallengeState], a + ld hl, sNrOfBeatenBattleTowerTrainers + inc [hl] + call CloseSRAM +SkipBattleTowerTrainer: ; 1704c9 + ret +; 1704ca + +Unreferenced_Function1704ca: ; 1704ca + ld a, [$be46] + cp $7 + jr c, .asm_1704d3 + ld a, $6 + +.asm_1704d3 + ld hl, $afce + ld de, -$e0 +.asm_1704d9 + and a + jr z, .asm_1704e0 + add hl, de + dec a + jr .asm_1704d9 + +.asm_1704e0 + ret +; 1704e1 + +UnusedSpecial_Function1704e1: ; 1704e1 + call SpeechTextBox + call FadeToMenu + call InitBattleTowerChallengeRAM + call .JumptableLoop + call CloseSubmenu + ret +; 1704f1 + +.JumptableLoop: ; 1704f1 + call ClearBGPalettes + call ClearSprites + call ClearScreen +.loop + call JoyTextDelay + ld a, [wJumptableIndex] + bit 7, a + jr nz, .done + call .DoJumptable + farcall ReloadMapPart + jr .loop + +.done + ret +; 170510 + +.DoJumptable: ; 170510 + ld a, [wJumptableIndex] + ld e, a + ld d, 0 + ld hl, .dw + add hl, de + add hl, de + ld a, [hli] + ld h, [hl] + ld l, a + jp hl +; 17051f + +.dw ; 17051f + dw .Jumptable_0 + dw .Jumptable_1 + dw .Jumptable_2 +; 170525 + +.Jumptable_0: ; 170525 + ld a, $5 + call GetSRAMBank + + ld hl, $a89c + ld de, StringBuffer3 + ld bc, $16 + call CopyBytes + + ld hl, $a8b2 + ld de, wMisc + ld bc, $0096 + call CopyBytes + + call CloseSRAM + hlcoord 1, 1 + ld de, StringBuffer3 + call PlaceString + hlcoord 1, 3 + ld de, .String_Mail + call PlaceString + hlcoord 4, 3 + ld de, StringBuffer4 + call PlaceString + hlcoord 8, 3 + ld de, .String_PastReaders + call PlaceString + call .DrawBorder + call .PlaceTextItems + jr .NextJumptableFunction + + +.Jumptable_1: + call SetPalettes + call .NextJumptableFunction + + +.Jumptable_2: + ld hl, hJoyPressed + ld a, [hl] + and A_BUTTON + jr nz, .pressed_a_or_b + ld a, [hl] + and B_BUTTON + jr nz, .pressed_a_or_b + ld a, [hl] + and D_UP + jr nz, .pressed_up + ld a, [hl] + and D_DOWN + jr nz, .pressed_down + ret + +.pressed_up + ld a, [wNrOfBeatenBattleTowerTrainers] + and a + ret z + sub 15 + ld [wNrOfBeatenBattleTowerTrainers], a + call .PlaceTextItems + ret + +.pressed_down + ld a, [wNrOfBeatenBattleTowerTrainers] + cp 60 + ret z + add 15 + ld [wNrOfBeatenBattleTowerTrainers], a + call .PlaceTextItems + ret + +.pressed_a_or_b + ld hl, wJumptableIndex + set 7, [hl] + ret + +.NextJumptableFunction: + ld hl, wJumptableIndex + inc [hl] + ret +; 1705b7 + +.DrawBorder: ; 1705b7 + hlcoord 0, 4 + ld a, "┌" + ld [hli], a + ld c, SCREEN_WIDTH - 2 +.top_border_loop + ld a, "─" + ld [hli], a + dec c + jr nz, .top_border_loop + ld a, "┐" + ld [hli], a + ld de, SCREEN_WIDTH + ld c, 12 +.left_border_loop + ld a, "│" + ld [hl], a + add hl, de + dec c + jr nz, .left_border_loop + ld a, "└" + ld [hli], a + ld c, SCREEN_WIDTH - 2 +.bottom_border_loop + ld a, "─" + ld [hli], a + dec c + jr nz, .bottom_border_loop + ld a, "┘" + ld [hl], a + ld de, -SCREEN_WIDTH + add hl, de + ld c, 12 +.right_border_loop + ld a, "│" + ld [hl], a + add hl, de + dec c + jr nz, .right_border_loop + ret +; 1705f0 + +.PlaceTextItems: ; 1705f0 + call .ClearBox + call .PlaceUpDownArrows + ld a, $50 + ld [wcd4e], a + ld hl, wMisc + ld a, [wNrOfBeatenBattleTowerTrainers] + ld c, a + xor a + ld b, a + add hl, bc + push hl + pop bc + hlcoord 1, 6 + ld a, 6 +.loop1 + push af + push hl + ld a, 3 +.loop2 + push af + ld de, wcd49 + ld a, [bc] + and a + jr z, .fill_with_e3 +; .copy + ld a, 5 +.loop3a + push af + ld a, [bc] + ld [de], a + inc bc + inc de + pop af + dec a + jr nz, .loop3a + jr .rejoin + +.fill_with_e3 + ld a, 5 +.loop3b + push af + ld a, $e3 + ld [de], a + inc de + inc bc + pop af + dec a + jr nz, .loop3b + +.rejoin + ld de, wcd49 + push bc + call PlaceString + ld de, NAME_LENGTH_JAPANESE + add hl, de + pop bc + pop af + dec a + jr nz, .loop2 + pop hl + ld de, $28 + add hl, de + pop af + dec a + jr nz, .loop1 + ret +; 17064b + +.ClearBox: ; 17064b + hlcoord 1, 5 + xor a + ld b, 12 +.clearbox_row + ld c, SCREEN_WIDTH - 2 +.clearbox_column + ld [hli], a + dec c + jr nz, .clearbox_column + inc hl + inc hl + dec b + jr nz, .clearbox_row + ret +; 17065d + +.PlaceUpDownArrows: ; 17065d + ld a, [wNrOfBeatenBattleTowerTrainers] + and a + jr z, .nope + hlcoord 18, 5 + ld a, "▲" + ld [hl], a + +.nope + ld a, [wNrOfBeatenBattleTowerTrainers] + cp 60 + ret z + hlcoord 18, 16 + ld a, "▼" + ld [hl], a + ret +; 170676 + +.String_Mail: ; 170676 + db "ルーム@" +; 17067a + +.String_PastReaders: ; 17067a + db "れきだいりーダーいちらん@" +; 170687 + +Special_BattleTowerAction: ; 170687 + ld a, [ScriptVar] + ld e, a + ld d, 0 + ld hl, .dw + add hl, de + add hl, de + ld a, [hli] + ld h, [hl] + ld l, a + jp hl +; 170696 + + +.dw ; 170696 (5c:4696) + dw BattleTowerAction_CheckExplanationRead ; 0x00 + dw BattleTowerAction_SetExplanationRead ; 0x01 + dw BattleTowerAction_GetChallengeState ; 0x02 + dw BattleTowerAction_SetByteToQuickSaveChallenge ; 0x03 + dw BattleTowerAction_SetByteToCancelChallenge ; 0x04 + dw Function1707ac ; 0x05 + dw Function1707f4 ; 0x06 + dw SaveBattleTowerLevelGroup ; 0x07 + dw LoadBattleTowerLevelGroup ; 0x08 + dw BattleTower_CheckSaveFileExistsAndIsYours ; 0x09 + dw Function1708b1 ; 0x0a + dw CheckMobileEventIndex ; 0x0b + dw Function1708c8 ; 0x0c + dw Function1708f0 ; 0x0d + dw BattleTowerAction_EggTicket ; 0x0e + dw Function1709aa ; 0x0f + dw Function1709bb ; 0x10 + dw Function170a9c ; 0x11 + dw Function170aa0 ; 0x12 + dw Function170aaf ; 0x13 + dw Function170abe ; 0x14 + dw Function170ad7 ; 0x15 + dw Function170807 ; 0x16 + dw Function17081d ; 0x17 + dw BattleTowerAction_LevelCheck ; 0x18 + dw BattleTowerAction_UbersCheck ; 0x19 + dw ResetBattleTowerTrainersSRAM ; 0x1a + dw BattleTower_GiveReward ; 0x1b + dw Function17071b ; 0x1c + dw Function170729 ; 0x1d + dw BattleTower_RandomlyChooseReward ; 0x1e + dw BattleTower_SaveOptions ; 0x1f + + +; Reset the save memory for BattleTower-Trainers (Counter and all 7 TrainerBytes) +ResetBattleTowerTrainersSRAM: ; 1706d6 (5c:46d6) BattleTowerAction $1a + ld a, BANK(sBTTrainers) + call GetSRAMBank + + ld a, $ff + ld hl, sBTTrainers + ld bc, BATTLETOWER_NROFTRAINERS + call ByteFill + + xor a + ld [sNrOfBeatenBattleTowerTrainers], a + + call CloseSRAM + + ret + +BattleTower_GiveReward: ; 1706ee (5c:46ee) BattleTowerAction $1b + ld a, BANK(sBattleTowerReward) + call GetSRAMBank + + ld a, [sBattleTowerReward] + call CloseSRAM + ld [ScriptVar], a + ld hl, NumItems + ld a, [hli] + cp MAX_ITEMS + ret c + ld b, MAX_ITEMS + ld a, [ScriptVar] + ld c, a +.loop + ld a, [hli] + cp c + jr nz, .next + ld a, [hl] + cp 95 + ret c +.next + inc hl + dec b + jr nz, .loop + ld a, POTION + ld [ScriptVar], a + ret + +Function17071b: ; 17071b (5c:471b) BattleTowerAction $1c + ld a, BANK(sBattleTowerChallengeState) + call GetSRAMBank + ld a, BATTLETOWER_WON_CHALLENGE + ld [sBattleTowerChallengeState], a + call CloseSRAM + ret + +Function170729: ; 170729 (5c:4729) BattleTowerAction $1d + ld a, BANK(sBattleTowerChallengeState) + call GetSRAMBank + ld a, BATTLETOWER_RECEIVED_REWARD + ld [sBattleTowerChallengeState], a + call CloseSRAM + ret + +BattleTower_SaveOptions: ; 170737 (5c:4737) BattleTowerAction $1f + farcall SaveOptions + ret + +BattleTower_RandomlyChooseReward: ; 17073e (5c:473e) BattleTowerAction $1e +; Generate a random stat boosting item. +.loop + call Random + ld a, [hRandomAdd] + and $7 + cp 6 + jr c, .okay + sub 6 +.okay + add HP_UP + cp LUCKY_PUNCH + jr z, .loop + push af + ld a, BANK(sBattleTowerReward) + call GetSRAMBank + pop af + ld [sBattleTowerReward], a + call CloseSRAM + ret + +BattleTowerAction_CheckExplanationRead: ; 17075f (5c:475f) BattleTowerAction $00 + call BattleTower_CheckSaveFileExistsAndIsYours + ld a, [ScriptVar] + and a + ret z + + ld a, BANK(sBattleTowerSaveFileFlags) + call GetSRAMBank + ld a, [sBattleTowerSaveFileFlags] + and $2 + ld [ScriptVar], a + call CloseSRAM + ret + +BattleTowerAction_GetChallengeState: ; 170778 (5c:4778) BattleTowerAction $02 + ld hl, sBattleTowerChallengeState + ld a, BANK(sBattleTowerChallengeState) + call GetSRAMBank + ld a, [hl] + ld [ScriptVar], a + call CloseSRAM + ret + +BattleTowerAction_SetExplanationRead: ; 170788 (5c:4788) BattleTowerAction $01 + ld a, BANK(sBattleTowerSaveFileFlags) + call GetSRAMBank + ld a, [sBattleTowerSaveFileFlags] + or $2 + ld [sBattleTowerSaveFileFlags], a + call CloseSRAM + ret + +BattleTowerAction_SetByteToQuickSaveChallenge: ; 170799 (5c:4799) BattleTowerAction $03 + ld c, BATTLETOWER_SAVED_AND_LEFT + jr asm_17079f + +BattleTowerAction_SetByteToCancelChallenge: ; 17079d (5c:479d) BattleTowerAction $04 + ld c, BATTLETOWER_NO_CHALLENGE +asm_17079f: ; 17079f (5c:479f) + ld a, BANK(sBattleTowerChallengeState) + call GetSRAMBank + ld a, c + ld [sBattleTowerChallengeState], a + call CloseSRAM + ret + +Function1707ac: ; 1707ac (5c:47ac) BattleTowerAction $05 + ld a, $5 + call GetSRAMBank + ld a, [$aa8c] + ld b, a + ld a, [$be46] + ld [ScriptVar], a + call CloseSRAM + and a + ret z + ld a, b + cp $2 + jr nc, .asm_1707ef + push bc + call UpdateTime + pop bc + ld a, $5 + call GetSRAMBank + ld a, [$aa8b] + call CloseSRAM + ld c, a + ld a, [CurDay] + sub c + jr c, .asm_1707e5 + cp $8 + jr nc, .asm_1707ef + ld a, b + and a + jr nz, .asm_1707ef + ret +.asm_1707e5 + ld hl, CurDay + ld a, $8c + sub c + add [hl] + cp $8 + ret c +.asm_1707ef + ld a, $8 + ld [ScriptVar], a + +Function1707f4: ; 1707f4 (5c:47f4) BattleTowerAction $06 + ld a, $5 + call GetSRAMBank + xor a + ld [$be46], a + ld [$aa8b], a + ld [$aa8c], a + call CloseSRAM + ret + +Function170807: ; 170807 (5c:4807) BattleTowerAction $16 + call UpdateTime + ld a, $5 + call GetSRAMBank + ld a, [CurDay] + ld [$b2f9], a + xor a + ld [$b2fa], a + call CloseSRAM + ret + +Function17081d: ; 17081d (5c:481d) BattleTowerAction $17 + xor a + ld [ScriptVar], a + ld a, $5 + call GetSRAMBank + ld a, [$b2f9] + ld c, a + ld a, [$b2fa] + ld b, a + call CloseSRAM + cp $2 + jr nc, .asm_170853 + push bc + call UpdateTime + pop bc + ld a, [CurDay] + sub c + jr c, .asm_170849 + cp $b + jr nc, .asm_170853 + ld a, b + and a + jr nz, .asm_170853 + ret + +.asm_170849 + ld hl, CurDay + ld a, 140 + sub c + add [hl] + cp $b + ret c +.asm_170853 + ld a, $1 + ld [ScriptVar], a + ld a, $5 + call GetSRAMBank + xor a + ld [$b2f9], a + ld [$b2fa], a + call CloseSRAM + ret + +SaveBattleTowerLevelGroup: ; 170868 (5c:4868) BattleTowerAction $07 + ld a, BANK(sBTChoiceOfLevelGroup) + call GetSRAMBank + ld a, [rSVBK] + push af + ld a, $3 + ld [rSVBK], a + ld a, [wBTChoiceOfLvlGroup] + ld [sBTChoiceOfLevelGroup], a + pop af + ld [rSVBK], a + call CloseSRAM + ret + +LoadBattleTowerLevelGroup: ; 170881 (5c:4881) BattleTowerAction $08 ; Load level group choice + ld a, BANK(sBTChoiceOfLevelGroup) + call GetSRAMBank + ld a, [rSVBK] + push af + ld a, $3 + ld [rSVBK], a + ld a, [sBTChoiceOfLevelGroup] + ld [wBTChoiceOfLvlGroup], a + pop af + ld [rSVBK], a + call CloseSRAM + ret + +BattleTower_CheckSaveFileExistsAndIsYours: ; 17089a BattleTowerAction $09 + ld a, [wSaveFileExists] + and a + jr z, .nope + farcall CompareLoadedAndSavedPlayerID + jr z, .yes + xor a + jr .nope + +.yes + ld a, $1 + +.nope + ld [ScriptVar], a + ret +; 1708b1 + + +Function1708b1: ; 1708b1 (5c:48b1) BattleTowerAction $0a + xor a + ld [MusicFade], a + call MaxVolume + ret + +CheckMobileEventIndex: ; 1708b9 (5c:48b9) BattleTowerAction $0b something to do with GS Ball + ld a, BANK(sMobileEventIndex) + call GetSRAMBank + ld a, [sMobileEventIndex] + ld [ScriptVar], a + call CloseSRAM + ret + +Function1708c8: ; 1708c8 (5c:48c8) BattleTowerAction $0c + call UpdateTime + ld a, $5 + call GetSRAMBank + ld a, [CurDay] + ld [$aa8b], a + xor a + ld [$aa8c], a + ld a, [$aa5d] + cp $2 + jr nc, .asm_1708ec + ld a, [CurDay] + ld [$aa48], a + ld a, $1 + ld [$aa47], a +.asm_1708ec + call CloseSRAM + ret + +Function1708f0: ; 1708f0 (5c:48f0) BattleTowerAction $0d + xor a + ld [ScriptVar], a + call UpdateTime + ld a, $5 + call GetSRAMBank + ld a, [$aa48] + ld c, a + ld a, [$aa47] + call CloseSRAM + and a + ret z + ld hl, CurDay + ld a, c + cp [hl] + jr nz, Function170923 + ld a, $5 + call GetSRAMBank + ld a, [$aa5d] + call CloseSRAM + cp $5 + ret c + ld a, $1 + ld [ScriptVar], a + ret + + +Function170923: ; 170923 + ld a, $5 + call GetSRAMBank + xor a + ld [$aa48], a + ld [$aa47], a + ld hl, $aa5d + ld bc, $0011 + call ByteFill + call CloseSRAM + ret +; 17093c + + +BattleTowerAction_EggTicket: ; 17093c (5c:493c) BattleTowerAction $0e + xor a + ld [ScriptVar], a + ld a, EGG_TICKET + ld [CurItem], a + ld hl, NumItems + call CheckItem + ret nc + ld a, [PartyCount] + ld b, 0 + ld c, a + ld hl, PartySpecies +.loop + ld a, [hli] + cp EGG + jr nz, .not_egg + push hl + ld hl, PartyMonOT + ld de, NAME_LENGTH_JAPANESE + ld a, b + and a + jr z, .skip +.loop2 + add hl, de + dec a + jr nz, .loop2 +.skip + ld de, String_1709a4 + ld a, NAME_LENGTH_JAPANESE +.compare_loop + push af + ld a, [de] + inc de + cp [hl] + inc hl + jr nz, .different + pop af + dec a + jr nz, .compare_loop +rept 4 + dec hl +endr + ld a, "@" + ld [hli], a + ld [hli], a + pop hl + ld a, EGG_TICKET + ld [CurItem], a + ld a, 1 + ld [wItemQuantityChangeBuffer], a + ld a, -1 + ld [CurItemQuantity], a + ld hl, NumItems + call TossItem + ld a, $1 + ld [ScriptVar], a + ret + +.different + pop af + pop hl +.not_egg + inc b + dec c + jr nz, .loop + ret +; 1709a4 (5c:49a4) + +String_1709a4: ; 1709a4 + db "なぞナゾ@@" + +Function1709aa: ; 1709aa (5c:49aa) BattleTowerAction $0f + ld a, [rSVBK] + push af + ld a, BANK(w3_d090) + ld [rSVBK], a + ld a, [w3_d090] + ld [ScriptVar], a + pop af + ld [rSVBK], a + ret + +Function1709bb: ; 1709bb (5c:49bb) BattleTowerAction $10 + xor a + ld [ScriptVar], a + ld a, $5 + call GetSRAMBank + ld a, [$a800] + call CloseSRAM + cp 6 + jr nc, .invalid + ld e, a + ld d, 0 + ld hl, Jumptable_1709e7 + add hl, de + add hl, de + ld a, [hli] + ld h, [hl] + ld l, a + jp hl + +.invalid + ld a, $5 + call GetSRAMBank + xor a + ld [$a800], a + call CloseSRAM + ret +; 1709e7 (5c:49e7) + +Jumptable_1709e7: ; 1709e7 + dw .NoAction + dw .NoAction + dw .DoAction1 + dw .DoAction1 + dw .Action4 + dw .Action5 +; 1709f3 + +.DoAction1: ; 1709f3 + ld a, $5 + call GetSRAMBank + ld a, $1 + ld [$a800], a + call CloseSRAM + +.NoAction: ; 170a00 + ret +; 170a01 + +.Action4: ; 170a01 + ld a, $5 + call GetSRAMBank + ld hl, $b023 + ld de, wMisc + ld bc, $0069 + call CopyBytes + ld a, [$a825] + ld [wcd30], a + ld a, [$a826] + ld [wcd31], a + call CloseSRAM + farcall Function11b6b4 + farcall Function17d0f3 + ld a, $1 + ld [ScriptVar], a + ret +; 170a33 + +.Action5: ; 170a33 + ld a, $0 + call GetSRAMBank + ld hl, wRTC + ld de, wMisc + ld bc, $0004 + call CopyBytes + call CloseSRAM + ld a, $5 + call GetSRAMBank + ld hl, $b08c + ld de, wMisc + ld c, $4 +.compare_loop + ld a, [de] + inc de + cp [hl] + jr nz, .different + inc hl + dec c + jr nz, .compare_loop + call CloseSRAM + ld a, [MapGroup] + ld b, a + ld a, [MapNumber] + ld c, a + call GetMapSceneID + ld a, d + or e + jr z, .no_scene + ld a, [de] + and a + ret nz + +.no_scene + ld a, $1 + ld [ScriptVar], a + ret + +.different + call CloseSRAM + ld a, $5 + call GetSRAMBank + xor a + ld [$a800], a + call CloseSRAM + ld [ScriptVar], a + ld a, [MapGroup] + ld b, a + ld a, [MapNumber] + ld c, a + call GetMapSceneID + ld a, d + or e + jr z, .no_scene_2 + xor a + ld [de], a + +.no_scene_2 + ret +; 170a9c + +Function170a9c: ; 170a9c (5c:4a9c) BattleTowerAction $11 + ld c, $0 + jr asm_170aa2 + +Function170aa0: ; 170aa0 (5c:4aa0) BattleTowerAction $12 + ld c, $1 +asm_170aa2: ; 170aa2 (5c:4aa2) + ld a, $5 + call GetSRAMBank + ld a, c + ld [$aa8d], a + call CloseSRAM + ret + +Function170aaf: ; 170aaf (5c:4aaf) BattleTowerAction $13 + ld a, $5 + call GetSRAMBank + ld a, [$aa8d] + ld [ScriptVar], a + call CloseSRAM + ret + +Function170abe: ; 170abe (5c:4abe) BattleTowerAction $14 + call BattleTower_CheckSaveFileExistsAndIsYours + ld a, [ScriptVar] + and a + ret z + + ld a, BANK(sBattleTowerSaveFileFlags) + call GetSRAMBank + ld a, [sBattleTowerSaveFileFlags] + and $1 + ld [ScriptVar], a + call CloseSRAM + ret + +Function170ad7: ; 170ad7 (5c:4ad7) BattleTowerAction $15 + ld a, BANK(sBattleTowerSaveFileFlags) + call GetSRAMBank + ld a, [sBattleTowerSaveFileFlags] + or $1 + ld [sBattleTowerSaveFileFlags], a + call CloseSRAM + ret + +BattleTowerAction_LevelCheck: ; 170ae8 (5c:4ae8) BattleTowerAction $18 + ld a, $5 + call GetSRAMBank + ld a, [$b2fb] + call CloseSRAM + ld c, 10 + call SimpleDivide + ld a, b + ld [wcd4f], a + xor a + ld [ScriptVar], a + farcall BattleTower_LevelCheck ; level check + ret nc + ld a, $5 + call GetSRAMBank + ld a, [$b2fb] + call CloseSRAM + ld [ScriptVar], a + ret + +BattleTowerAction_UbersCheck: ; 170b16 (5c:4b16) BattleTowerAction $19 + ld a, $5 + call GetSRAMBank + ld a, [$b2fb] + call CloseSRAM + ld c, 10 + call SimpleDivide + ld a, b + ld [wcd4f], a + xor a + ld [ScriptVar], a + farcall BattleTower_UbersCheck + ret nc + ld a, $5 + call GetSRAMBank + ld a, [$b2fb] + call CloseSRAM + ld [ScriptVar], a + ret + +Special_LoadOpponentTrainerAndPokemonWithOTSprite: ; 0x170b44 + farcall Function_LoadOpponentTrainerAndPokemons + ld a, [rSVBK] + push af + ld a, $3 + ld [rSVBK], a + ld hl, BT_OTTrainerClass + ld a, [hl] + dec a + ld c, a + ld b, $0 + pop af + ld [rSVBK], a + ld hl, BTTrainerClassSprites + add hl, bc + ld a, [hl] + ld [wBTTempOTSprite], a + +; Load sprite of the opponent trainer +; because s/he is chosen randomly and appears out of nowhere + ld a, [ScriptVar] + dec a + sla a + ld e, a + sla a + sla a + sla a + ld c, a + ld b, 0 + ld d, 0 + ld hl, MapObjects + add hl, bc + inc hl + ld a, [wBTTempOTSprite] + ld [hl], a + ld hl, UsedSprites + add hl, de + ld [hli], a + ld [hUsedSpriteIndex], a + ld a, [hl] + ld [hUsedSpriteTile], a + farcall GetUsedSprite + ret +; 170b90 + +INCLUDE "data/trainers/sprites.asm" + +DummySpecial_170bd2: ; 170bd2 + ret +; 170bd3 + +Special_CheckForBattleTowerRules: ; 170bd3 + farcall CheckForBattleTowerRules + jr c, .asm_170bde + xor a ; FALSE + jr .asm_170be0 + +.asm_170bde + ld a, TRUE + +.asm_170be0 + ld [ScriptVar], a + ret +; 170be4 diff --git a/engine/events/battle_tower/get_trainer_class.asm b/engine/events/battle_tower/get_trainer_class.asm new file mode 100644 index 000000000..37fe91c56 --- /dev/null +++ b/engine/events/battle_tower/get_trainer_class.asm @@ -0,0 +1,46 @@ +GetMobileOTTrainerClass: ; mobile function + ld h, b + ld l, c + call .GetMobileOTTrainerClass + ld c, a + ret + +.GetMobileOTTrainerClass: ; 4e930 + ld a, [hli] + xor [hl] + ld c, a + jr z, .skip_male_trainers + srl c + srl c +.male_trainer_loop + srl c + ld a, c + cp MaleTrainersEnd - MaleTrainers - 1 + jr nc, .male_trainer_loop + inc c + +.skip_male_trainers + ld a, [de] + cp $1 + ld hl, MaleTrainers + jr nz, .finished + + ld hl, FemaleTrainers + ld a, c + and a + jr z, .finished + +.female_trainer_loop + srl c + ld a, c + cp FemaleTrainersEnd - FemaleTrainers - 1 + jr nc, .female_trainer_loop + inc c + +.finished + ld b, $0 + add hl, bc + ld a, [hl] + ret + +INCLUDE "data/trainers/gendered_trainers.asm" diff --git a/engine/events/battle_tower.asm b/engine/events/battle_tower/load_trainer.asm index a0de6ee84..006e0afa3 100644 --- a/engine/events/battle_tower.asm +++ b/engine/events/battle_tower/load_trainer.asm @@ -26,12 +26,14 @@ Function_LoadOpponentTrainerAndPokemons: ; 1f8000 ld a, [hRandomAdd] add b ld b, a ; b contains the nr of the trainer -if DEF(CRYSTAL11) - and (1 << 7) - 1 - cp 70 +if DEF(_CRYSTAL11) + maskbits BATTLETOWER_NUM_UNIQUE_TRAINERS +- 1 + cp BATTLETOWER_NUM_UNIQUE_TRAINERS else - and (1 << 5) - 1 - cp 21 +; Crystal 1.0 used the wrong constant here, so only the first 21 +; trainers in BattleTowerTrainers can be sampled. + maskbits BATTLETOWER_NUM_UNIQUE_PKMN +- 1 + cp BATTLETOWER_NUM_UNIQUE_PKMN endc jr nc, .resample ld b, a @@ -100,7 +102,7 @@ Function_LoadRandomBattleTowerPkmn: ; 1f8081 .FindARandomBattleTowerPkmn: ; From Which LevelGroup are the Pkmn loaded ; a = 1..10 - ld a, [wBTChoiceOfLvlGroup] ; [$d800] + ld a, [wBTChoiceOfLvlGroup] dec a ld hl, BattleTowerMons ld bc, BattleTowerMons2 - BattleTowerMons1 @@ -113,8 +115,8 @@ Function_LoadRandomBattleTowerPkmn: ; 1f8081 ld a, [hRandomAdd] add b ld b, a - and $1f - cp BATTLETOWER_NRMONSPERLEVELBRACKET + maskbits BATTLETOWER_NUM_UNIQUE_PKMN +- 1 + cp BATTLETOWER_NUM_UNIQUE_PKMN jr nc, .resample ; in register 'a' is the chosen Pkmn of the LevelGroup @@ -207,4 +209,6 @@ Function_LoadRandomBattleTowerPkmn: ; 1f8081 ret ; 1f814e -INCLUDE "data/battle_tower.asm" +INCLUDE "data/battle_tower/classes.asm" + +INCLUDE "data/battle_tower/parties.asm" diff --git a/engine/events/battle_tower_rules.asm b/engine/events/battle_tower/rules.asm index de6022145..8d037951b 100644 --- a/engine/events/battle_tower_rules.asm +++ b/engine/events/battle_tower/rules.asm @@ -213,7 +213,7 @@ BattleTower_ExecuteJumptable: ; 8b25b BattleTower_CheckPartyLengthIs3: ; 8b2bb ld a, [PartyCount] - cp 3 + cp BATTLETOWER_NROFPKMNS ret ; 8b2c1 @@ -235,13 +235,13 @@ BattleTower_CheckPartyHasThreeMonsThatAreNotEggs: ; 8b2c1 cp b ret z ld a, b - cp 3 + cp BATTLETOWER_NROFPKMNS ret ; 8b2da Function_PartyCountEq3: ; 8b2da ld a, [PartyCount] - cp 3 + cp BATTLETOWER_NROFPKMNS ret z scf ret diff --git a/engine/events/battle_tower/trainer_text.asm b/engine/events/battle_tower/trainer_text.asm new file mode 100755 index 000000000..96c91caa9 --- /dev/null +++ b/engine/events/battle_tower/trainer_text.asm @@ -0,0 +1,718 @@ +BattleTowerText:: ; 11c000 +; Print text c for trainer [BT_OTTrainerClass] +; 1: Intro text +; 2: Player lost +; 3: Player won + ld a, [rSVBK] + push af + ld a, BANK(BT_OTTrainerClass) + ld [rSVBK], a +if DEF(_CRYSTAL11) + ld hl, BT_OTTrainerClass +else +; BUG ALERT +; Instead of loading the Trainer Class, this routine +; loads the 6th character in the Trainer's name, then +; uses it to get the gender of the trainer. +; As a consequence, the enemy trainer's dialog will +; always be sampled from the female array. + ld hl, BT_OTName + NAME_LENGTH_JAPANESE - 1 +endc + ld a, [hl] + dec a + ld e, a + ld d, 0 + ld hl, BTTrainerClassGenders + add hl, de + ld a, [hl] + and a + jr nz, .female + ; generate a random number between 0 and 24 + ld a, [hRandomAdd] + and $1f + cp 25 + jr c, .okay0 + sub 25 + +.okay0 + ld hl, BTMaleTrainerTexts + jr .proceed + +.female + ; generate a random number between 0 and 14 + ld a, [hRandomAdd] + and $f + cp 15 + jr c, .okay1 + sub 15 + +.okay1 + ld hl, BTFemaleTrainerTexts + +.proceed + ld b, 0 + dec c + jr nz, .restore + ld [BT_TrainerTextIndex], a + jr .okay2 + +.restore + ld a, [BT_TrainerTextIndex] + +.okay2 + push af + add hl, bc + add hl, bc + ld a, [hli] + ld c, a + ld a, [hl] + ld h, a + ld l, c + pop af + ld c, a + ld b, 0 + add hl, bc + add hl, bc + ld a, [hli] + ld c, a + ld a, [hl] + ld l, c + ld h, a + bccoord 1, 14 + pop af + ld [rSVBK], a + call PlaceHLTextAtBC + ret +; 11c05d + +INCLUDE "mobile/fixed_words.asm" + +INCLUDE "data/trainers/genders.asm" + + +BTMaleTrainerTexts: ; 11f332 + dw .Greetings + dw .PlayerLost + dw .PlayerWon + +.Greetings: ; 11f338 + dw BTGreetingM1 + dw BTGreetingM2 + dw BTGreetingM3 + dw BTGreetingM4 + dw BTGreetingM5 + dw BTGreetingM6 + dw BTGreetingM7 + dw BTGreetingM8 + dw BTGreetingM9 + dw BTGreetingM10 + dw BTGreetingM11 + dw BTGreetingM12 + dw BTGreetingM13 + dw BTGreetingM14 + dw BTGreetingM15 + dw BTGreetingM16 + dw BTGreetingM17 + dw BTGreetingM18 + dw BTGreetingM19 + dw BTGreetingM20 + dw BTGreetingM21 + dw BTGreetingM22 + dw BTGreetingM23 + dw BTGreetingM24 + dw BTGreetingM25 + +.PlayerLost: ; 11f36a + dw BTLossM1 + dw BTLossM2 + dw BTLossM3 + dw BTLossM4 + dw BTLossM5 + dw BTLossM6 + dw BTLossM7 + dw BTLossM8 + dw BTLossM9 + dw BTLossM10 + dw BTLossM11 + dw BTLossM12 + dw BTLossM13 + dw BTLossM14 + dw BTLossM15 + dw BTLossM16 + dw BTLossM17 + dw BTLossM18 + dw BTLossM19 + dw BTLossM20 + dw BTLossM21 + dw BTLossM22 + dw BTLossM23 + dw BTLossM24 + dw BTLossM25 + +.PlayerWon: ; 11f39c + dw BTWinM1 + dw BTWinM2 + dw BTWinM3 + dw BTWinM4 + dw BTWinM5 + dw BTWinM6 + dw BTWinM7 + dw BTWinM8 + dw BTWinM9 + dw BTWinM10 + dw BTWinM11 + dw BTWinM12 + dw BTWinM13 + dw BTWinM14 + dw BTWinM15 + dw BTWinM16 + dw BTWinM17 + dw BTWinM18 + dw BTWinM19 + dw BTWinM20 + dw BTWinM21 + dw BTWinM22 + dw BTWinM23 + dw BTWinM24 + dw BTWinM25 + + +BTFemaleTrainerTexts: + dw .Greetings + dw .PlayerLost + dw .PlayerWon + +.Greetings: ; 11f3d4 + dw BTGreetingF1 + dw BTGreetingF2 + dw BTGreetingF3 + dw BTGreetingF4 + dw BTGreetingF5 + dw BTGreetingF6 + dw BTGreetingF7 + dw BTGreetingF8 + dw BTGreetingF9 + dw BTGreetingF10 + dw BTGreetingF11 + dw BTGreetingF12 + dw BTGreetingF13 + dw BTGreetingF14 + dw BTGreetingF15 + +.PlayerLost: ; 11f3f2 + dw BTLossF1 + dw BTLossF2 + dw BTLossF3 + dw BTLossF4 + dw BTLossF5 + dw BTLossF6 + dw BTLossF7 + dw BTLossF8 + dw BTLossF9 + dw BTLossF10 + dw BTLossF11 + dw BTLossF12 + dw BTLossF13 + dw BTLossF14 + dw BTLossF15 + +.PlayerWon: ; 11f410 + dw BTWinF1 + dw BTWinF2 + dw BTWinF3 + dw BTWinF4 + dw BTWinF5 + dw BTWinF6 + dw BTWinF7 + dw BTWinF8 + dw BTWinF9 + dw BTWinF10 + dw BTWinF11 + dw BTWinF12 + dw BTWinF13 + dw BTWinF14 + dw BTWinF15 + + +BTGreetingM1: ; 0x11f42e + text_jump BattleTowerText_0x1ec000 + db "@" + +BTLossM1: ; 0x11f433 + text_jump BattleTowerText_0x1ec03b + db "@" + +BTWinM1: ; 0x11f438 + text_jump UnknownText_0x1ec060 + db "@" + +BTGreetingM2: ; 0x11f43d + text_jump BattleTowerText_0x1ec080 + db "@" + +BTLossM2: ; 0x11f442 + text_jump UnknownText_0x1ec0a3 + db "@" + +BTWinM2: ; 0x11f447 + text_jump UnknownText_0x1ec0c4 + db "@" + +BTGreetingM3: ; 0x11f44c + text_jump UnknownText_0x1ec0e1 + db "@" + +BTLossM3: ; 0x11f451 + text_jump UnknownText_0x1ec108 + db "@" + +BTWinM3: ; 0x11f456 + text_jump UnknownText_0x1ec12a + db "@" + +BTGreetingM4: ; 0x11f45b + text_jump UnknownText_0x1ec14d + db "@" + +BTLossM4: ; 0x11f460 + text_jump UnknownText_0x1ec16f + db "@" + +BTWinM4: ; 0x11f465 + text_jump UnknownText_0x1ec190 + db "@" + +BTGreetingM5: ; 0x11f46a + text_jump UnknownText_0x1ec1ae + db "@" + +BTLossM5: ; 0x11f46f + text_jump UnknownText_0x1ec1d0 + db "@" + +BTWinM5: ; 0x11f474 + text_jump UnknownText_0x1ec1f4 + db "@" + +BTGreetingM6: ; 0x11f479 + text_jump UnknownText_0x1ec216 + db "@" + +BTLossM6: ; 0x11f47e + text_jump UnknownText_0x1ec238 + db "@" + +BTWinM6: ; 0x11f483 + text_jump UnknownText_0x1ec259 + db "@" + +BTGreetingM7: ; 0x11f488 + text_jump UnknownText_0x1ec27b + db "@" + +BTLossM7: ; 0x11f48d + text_jump UnknownText_0x1ec2a0 + db "@" + +BTWinM7: ; 0x11f492 + text_jump UnknownText_0x1ec2c0 + db "@" + +BTGreetingM8: ; 0x11f497 + text_jump UnknownText_0x1ec2d9 + db "@" + +BTLossM8: ; 0x11f49c + text_jump UnknownText_0x1ec2fe + db "@" + +BTWinM8: ; 0x11f4a1 + text_jump UnknownText_0x1ec320 + db "@" + +BTGreetingM9: ; 0x11f4a6 + text_jump UnknownText_0x1ec33f + db "@" + +BTLossM9: ; 0x11f4ab + text_jump UnknownText_0x1ec36c + db "@" + +BTWinM9: ; 0x11f4b0 + text_jump UnknownText_0x1ec389 + db "@" + +BTGreetingM10: ; 0x11f4b5 + text_jump UnknownText_0x1ec3ad + db "@" + +BTLossM10: ; 0x11f4ba + text_jump UnknownText_0x1ec3c5 + db "@" + +BTWinM10: ; 0x11f4bf + text_jump UnknownText_0x1ec3e5 + db "@" + +BTGreetingM11: ; 0x11f4c4 + text_jump UnknownText_0x1ec402 + db "@" + +BTLossM11: ; 0x11f4c9 + text_jump UnknownText_0x1ec411 + db "@" + +BTWinM11: ; 0x11f4ce + text_jump UnknownText_0x1ec41f + db "@" + +BTGreetingM12: ; 0x11f4d3 + text_jump UnknownText_0x1ec42e + db "@" + +BTLossM12: ; 0x11f4d8 + text_jump UnknownText_0x1ec461 + db "@" + +BTWinM12: ; 0x11f4dd + text_jump UnknownText_0x1ec4a0 + db "@" + +BTGreetingM13: ; 0x11f4e2 + text_jump UnknownText_0x1ec4d6 + db "@" + +BTLossM13: ; 0x11f4e7 + text_jump UnknownText_0x1ec4f5 + db "@" + +BTWinM13: ; 0x11f4ec + text_jump UnknownText_0x1ec512 + db "@" + +BTGreetingM14: ; 0x11f4f1 + text_jump UnknownText_0x1ec532 + db "@" + +BTLossM14: ; 0x11f4f6 + text_jump UnknownText_0x1ec54b + db "@" + +BTWinM14: ; 0x11f4fb + text_jump UnknownText_0x1ec565 + db "@" + +BTGreetingM15: ; 0x11f500 + text_jump UnknownText_0x1ec580 + db "@" + +BTLossM15: ; 0x11f505 + text_jump UnknownText_0x1ec59d + db "@" + +BTWinM15: ; 0x11f50a + text_jump UnknownText_0x1ec5b5 + db "@" + +BTGreetingM16: ; 0x11f50f + text_jump UnknownText_0x1ec5d3 + db "@" + +BTLossM16: ; 0x11f514 + text_jump UnknownText_0x1ec5ee + db "@" + +BTWinM16: ; 0x11f519 + text_jump UnknownText_0x1ec60d + db "@" + +BTGreetingM17: ; 0x11f51e + text_jump UnknownText_0x1ec631 + db "@" + +BTLossM17: ; 0x11f523 + text_jump UnknownText_0x1ec651 + db "@" + +BTWinM17: ; 0x11f528 + text_jump UnknownText_0x1ec68f + db "@" + +BTGreetingM18: ; 0x11f52d + text_jump UnknownText_0x1ec6b1 + db "@" + +BTLossM18: ; 0x11f532 + text_jump UnknownText_0x1ec6d0 + db "@" + +BTWinM18: ; 0x11f537 + text_jump UnknownText_0x1ec708 + db "@" + +BTGreetingM19: ; 0x11f53c + text_jump UnknownText_0x1ec720 + db "@" + +BTLossM19: ; 0x11f541 + text_jump UnknownText_0x1ec73e + db "@" + +BTWinM19: ; 0x11f546 + text_jump UnknownText_0x1ec75b + db "@" + +BTGreetingM20: ; 0x11f54b + text_jump UnknownText_0x1ec77f + db "@" + +BTLossM20: ; 0x11f550 + text_jump UnknownText_0x1ec798 + db "@" + +BTWinM20: ; 0x11f555 + text_jump UnknownText_0x1ec7bb + db "@" + +BTGreetingM21: ; 0x11f55a + text_jump UnknownText_0x1ec7d8 + db "@" + +BTLossM21: ; 0x11f55f + text_jump UnknownText_0x1ec818 + db "@" + +BTWinM21: ; 0x11f564 + text_jump UnknownText_0x1ec837 + db "@" + +BTGreetingM22: ; 0x11f569 + text_jump UnknownText_0x1ec858 + db "@" + +BTLossM22: ; 0x11f56e + text_jump UnknownText_0x1ec876 + db "@" + +BTWinM22: ; 0x11f573 + text_jump UnknownText_0x1ec898 + db "@" + +BTGreetingM23: ; 0x11f578 + text_jump UnknownText_0x1ec8b1 + db "@" + +BTLossM23: ; 0x11f57d + text_jump UnknownText_0x1ec8d5 + db "@" + +BTWinM23: ; 0x11f582 + text_jump UnknownText_0x1ec8f0 + db "@" + +BTGreetingM24: ; 0x11f587 + text_jump UnknownText_0x1ec911 + db "@" + +BTLossM24: ; 0x11f58c + text_jump UnknownText_0x1ec928 + db "@" + +BTWinM24: ; 0x11f591 + text_jump UnknownText_0x1ec949 + db "@" + +BTGreetingM25: ; 0x11f596 + text_jump UnknownText_0x1ec969 + db "@" + +BTLossM25: ; 0x11f59b + text_jump UnknownText_0x1ec986 + db "@" + +BTWinM25: ; 0x11f5a0 + text_jump UnknownText_0x1ec99b + db "@" + + + + +BTGreetingF1: ; 0x11f5a5 + text_jump UnknownText_0x1ec9bd + db "@" + +BTLossF1: ; 0x11f5aa + text_jump UnknownText_0x1ec9d9 + db "@" + +BTWinF1: ; 0x11f5af + text_jump UnknownText_0x1ec9f7 + db "@" + +BTGreetingF2: ; 0x11f5b4 + text_jump UnknownText_0x1eca0a + db "@" + +BTLossF2: ; 0x11f5b9 + text_jump UnknownText_0x1eca2a + db "@" + +BTWinF2: ; 0x11f5be + text_jump UnknownText_0x1eca47 + db "@" + +BTGreetingF3: ; 0x11f5c3 + text_jump UnknownText_0x1eca64 + db "@" + +BTLossF3: ; 0x11f5c8 + text_jump UnknownText_0x1eca82 + db "@" + +BTWinF3: ; 0x11f5cd + text_jump UnknownText_0x1eca9d + db "@" + +BTGreetingF4: ; 0x11f5d2 + text_jump UnknownText_0x1ecabf + db "@" + +BTLossF4: ; 0x11f5d7 + text_jump UnknownText_0x1ecade + db "@" + +BTWinF4: ; 0x11f5dc + text_jump UnknownText_0x1ecafa + db "@" + +BTGreetingF5: ; 0x11f5e1 + text_jump UnknownText_0x1ecb19 + db "@" + +BTLossF5: ; 0x11f5e6 + text_jump UnknownText_0x1ecb37 + db "@" + +BTWinF5: ; 0x11f5eb + text_jump UnknownText_0x1ecb55 + db "@" + +BTGreetingF6: ; 0x11f5f0 + text_jump UnknownText_0x1ecb70 + db "@" + +BTLossF6: ; 0x11f5f5 + text_jump UnknownText_0x1ecb92 + db "@" + +BTWinF6: ; 0x11f5fa + text_jump UnknownText_0x1ecbb6 + db "@" + +BTGreetingF7: ; 0x11f5ff + text_jump UnknownText_0x1ecbd9 + db "@" + +BTLossF7: ; 0x11f604 + text_jump UnknownText_0x1ecbf3 + db "@" + +BTWinF7: ; 0x11f609 + text_jump UnknownText_0x1ecc15 + db "@" + +BTGreetingF8: ; 0x11f60e + text_jump UnknownText_0x1ecc39 + db "@" + +BTLossF8: ; 0x11f613 + text_jump UnknownText_0x1ecc55 + db "@" + +BTWinF8: ; 0x11f618 + text_jump UnknownText_0x1ecc75 + db "@" + +BTGreetingF9: ; 0x11f61d + text_jump UnknownText_0x1ecc92 + db "@" + +BTLossF9: ; 0x11f622 + text_jump UnknownText_0x1ecca7 + db "@" + +BTWinF9: ; 0x11f627 + text_jump UnknownText_0x1eccc1 + db "@" + +BTGreetingF10: ; 0x11f62c + text_jump UnknownText_0x1eccd7 + db "@" + +BTLossF10: ; 0x11f631 + text_jump UnknownText_0x1eccef + db "@" + +BTWinF10: ; 0x11f636 + text_jump UnknownText_0x1ecd0e + db "@" + +BTGreetingF11: ; 0x11f63b + text_jump UnknownText_0x1ecd2b + db "@" + +BTLossF11: ; 0x11f640 + text_jump UnknownText_0x1ecd4d + db "@" + +BTWinF11: ; 0x11f645 + text_jump UnknownText_0x1ecd6b + db "@" + +BTGreetingF12: ; 0x11f64a + text_jump UnknownText_0x1ecd8d + db "@" + +BTLossF12: ; 0x11f64f + text_jump UnknownText_0x1ecdaf + db "@" + +BTWinF12: ; 0x11f654 + text_jump UnknownText_0x1ecdcf + db "@" + +BTGreetingF13: ; 0x11f659 + text_jump UnknownText_0x1ecded + db "@" + +BTLossF13: ; 0x11f65e + text_jump UnknownText_0x1ece0d + db "@" + +BTWinF13: ; 0x11f663 + text_jump UnknownText_0x1ece2a + db "@" + +BTGreetingF14: ; 0x11f668 + text_jump UnknownText_0x1ece4b + db "@" + +BTLossF14: ; 0x11f66d + text_jump UnknownText_0x1ece70 + db "@" + +BTWinF14: ; 0x11f672 + text_jump UnknownText_0x1ece8a + db "@" + +BTGreetingF15: ; 0x11f677 + text_jump UnknownText_0x1ecea8 + db "@" + +BTLossF15: ; 0x11f67c + text_jump UnknownText_0x1ecec9 + db "@" + +BTWinF15: ; 0x11f681 + text_jump UnknownText_0x1ecee8 + db "@" diff --git a/engine/events/buena.asm b/engine/events/buena.asm index 6070895fe..cd0ecc98d 100644 --- a/engine/events/buena.asm +++ b/engine/events/buena.asm @@ -1,4 +1,4 @@ -SpecialBuenasPassword: ; 8af6b +Special_BuenasPassword: ; 8af6b xor a ld [wWhichIndexSet], a ld hl, .MenuDataHeader @@ -17,7 +17,7 @@ SpecialBuenasPassword: ; 8af6b ld a, [MenuSelection] ld c, a ld a, [wBuenasPassword] - and $3 + maskbits NUM_PASSWORDS_PER_CATEGORY +- 1 cp c jr nz, .wrong ld b, $1 @@ -30,8 +30,7 @@ SpecialBuenasPassword: ; 8af6b .MenuDataHeader: ; 0x8afa9 db MENU_BACKUP_TILES ; flags - db 00, 00 ; start coords - db 07, 10 ; end coords + menu_coords 0, 0, 10, 7 dw .MenuData2 db 1 ; default option ; 0x8afb1 @@ -46,8 +45,12 @@ SpecialBuenasPassword: ; 8af6b ; 0x8afb4 .PasswordIndices: ; 8afb8 - db 3 - db 0, 1, 2 + db NUM_PASSWORDS_PER_CATEGORY +x = 0 +rept NUM_PASSWORDS_PER_CATEGORY + db x +x = x + 1 +endr db -1 .PlacePasswordChoices: ; 8afbd @@ -64,7 +67,7 @@ SpecialBuenasPassword: ; 8af6b ret ; 8afd4 -SpecialBuenaPrize: ; 8afd4 +Special_BuenaPrize: ; 8afd4 xor a ld [wMenuScrollPosition], a ld a, $1 @@ -226,8 +229,7 @@ PrintBlueCardBalance: ; 8b097 BlueCardBalanceMenuDataHeader: ; 0x8b0d1 db MENU_BACKUP_TILES ; flags - db 11, 00 ; start coords - db 13, 11 ; end coords + menu_coords 0, 11, 11, 13 ; 8b0d6 Buena_PlacePrizeMenuBox: ; 8b0d6 @@ -238,8 +240,7 @@ Buena_PlacePrizeMenuBox: ; 8b0d6 .menudataheader ; 0x8b0dd db MENU_BACKUP_TILES ; flags - db 00, 00 ; start coords - db 11, 17 ; end coords + menu_coords 0, 0, 17, TEXTBOX_Y - 1 ; 8b0e2 Buena_PrizeMenu: ; 8b0e2 @@ -271,8 +272,7 @@ Buena_PrizeMenu: ; 8b0e2 .MenuDataHeader: ; 0x8b113 db MENU_BACKUP_TILES ; flags - db 01, 01 ; start coords - db 09, 16 ; end coords + menu_coords 1, 1, 16, 9 dw .MenuData2 db 1 ; default option ; 0x8b11b diff --git a/engine/events/buena_menu.asm b/engine/events/buena_menu.asm index b453da783..cf6fecf72 100644 --- a/engine/events/buena_menu.asm +++ b/engine/events/buena_menu.asm @@ -1,4 +1,4 @@ -AskRememberPassword: ; 4ae12 +Special_AskRememberPassword: ; 4ae12 call .DoMenu ld a, $0 jr c, .okay diff --git a/engine/events/bug_contest/contest_2.asm b/engine/events/bug_contest/contest_2.asm index 493c69d0c..7ade44815 100755 --- a/engine/events/bug_contest/contest_2.asm +++ b/engine/events/bug_contest/contest_2.asm @@ -2,7 +2,7 @@ Special_SelectRandomBugContestContestants: ; 139a8 ; Select five random people to participate in the current contest. ; First we have to make sure that any old data is cleared away. - ld c, 10 ; Number of people to choose from. + ld c, NUM_BUG_CONTESTANTS ld hl, BugCatchingContestantEventFlagTable .loop1 push bc @@ -26,9 +26,9 @@ Special_SelectRandomBugContestContestants: ; 139a8 .next ; Choose a flag at uniform random to be set. call Random - cp 250 + cp $ff / NUM_BUG_CONTESTANTS * NUM_BUG_CONTESTANTS jr nc, .next - ld c, 25 + ld c, $ff / NUM_BUG_CONTESTANTS call SimpleDivide ld e, b ld d, 0 @@ -59,7 +59,7 @@ Special_SelectRandomBugContestContestants: ; 139a8 Special_CheckBugContestContestantFlag: ; 139ed ; Checks the flag of the Bug Catching Contestant whose index is loaded in a. -; Bug: If a >= 10 when this is called, it will read beyond the table. +; Bug: If a >= NUM_BUG_CONTESTANTS when this is called, it will read beyond the table. ld hl, BugCatchingContestantEventFlagTable ld e, a @@ -74,20 +74,9 @@ Special_CheckBugContestContestantFlag: ; 139ed ret ; 139fe -BugCatchingContestantEventFlagTable: ; 139fe - dw EVENT_BUG_CATCHING_CONTESTANT_1A - dw EVENT_BUG_CATCHING_CONTESTANT_2A - dw EVENT_BUG_CATCHING_CONTESTANT_3A - dw EVENT_BUG_CATCHING_CONTESTANT_4A - dw EVENT_BUG_CATCHING_CONTESTANT_5A - dw EVENT_BUG_CATCHING_CONTESTANT_6A - dw EVENT_BUG_CATCHING_CONTESTANT_7A - dw EVENT_BUG_CATCHING_CONTESTANT_8A - dw EVENT_BUG_CATCHING_CONTESTANT_9A - dw EVENT_BUG_CATCHING_CONTESTANT_10A -; 13a12 +INCLUDE "data/bug_contest_flags.asm" -ContestDropOffMons: ; 13a12 +Special_ContestDropOffMons: ; 13a12 ld hl, PartyMon1HP ld a, [hli] or [hl] @@ -101,7 +90,7 @@ ContestDropOffMons: ; 13a12 ld a, [hl] ld [wBugContestSecondPartySpecies], a ; ... and replacing it with the terminator byte - ld [hl], $ff + ld [hl], -1 xor a ld [ScriptVar], a ret @@ -112,13 +101,13 @@ ContestDropOffMons: ; 13a12 ret ; 13a31 -ContestReturnMons: ; 13a31 +Special_ContestReturnMons: ; 13a31 ; Restore the species of the second mon. ld hl, PartySpecies + 1 ld a, [wBugContestSecondPartySpecies] ld [hl], a ; Restore the party count, which must be recomputed. - ld b, $1 + ld b, 1 .loop ld a, [hli] cp -1 diff --git a/engine/events/bug_contest/display_stats.asm b/engine/events/bug_contest/display_stats.asm index d6ad3997e..0e2567c28 100644 --- a/engine/events/bug_contest/display_stats.asm +++ b/engine/events/bug_contest/display_stats.asm @@ -101,7 +101,7 @@ DisplayAlreadyCaughtText: ; cc0c7 text_jump UnknownText_0x1c10dd db "@" -Predef2F: -Predef38: -Predef39: ; cc0d5 +DummyPredef2F: +DummyPredef38: +DummyPredef39: ; cc0d5 ret diff --git a/engine/events/bug_contest/judging.asm b/engine/events/bug_contest/judging.asm index 901ae88fa..8681feb8d 100755 --- a/engine/events/bug_contest/judging.asm +++ b/engine/events/bug_contest/judging.asm @@ -1,6 +1,6 @@ -_BugContestJudging: ; 1369d +_Special_BugContestJudging: ; 1369d call ContestScore - farcall TrainerRankings_BugContestScore + farcall StubbedTrainerRankings_BugContestScore call BugContest_JudgeContestants ld a, [wBugContestThirdPlaceWinnerID] call LoadContestantName @@ -77,9 +77,8 @@ BugContest_ThirdPlaceScoreText: ; 0x1372b ; 0x13730 LoadContestantName: ; 13730 - -; If a = 0, get your name. - dec a +; If a = 1, get your name. + dec a ; BUG_CONTEST_PLAYER jr z, .player ; Find the pointer for the trainer class of the Bug Catching Contestant whose ID is in a. ld c, a @@ -141,11 +140,11 @@ INCLUDE "data/bug_contest_winners.asm" BugContest_GetPlayersResult: ; 13807 ld hl, wBugContestThirdPlaceWinnerID - ld de, -4 - ld b, 3 + ld de, - BUG_CONTESTANT_SIZE + ld b, 3 ; 3rd, 2nd, or 1st .loop ld a, [hl] - cp 1 ; Player + cp BUG_CONTEST_PLAYER jr z, .done add hl, de dec b @@ -159,7 +158,7 @@ BugContest_JudgeContestants: ; 13819 call ClearContestResults call ComputeAIContestantScores ld hl, wBugContestTempWinnerID - ld a, 1 ; Player + ld a, BUG_CONTEST_PLAYER ld [hli], a ld a, [wContestMon] ld [hli], a @@ -190,11 +189,11 @@ DetermineContestWinners: ; 1383e jr c, .not_first_place ld hl, wBugContestSecondPlaceWinnerID ld de, wBugContestThirdPlaceWinnerID - ld bc, 4 + ld bc, BUG_CONTESTANT_SIZE call CopyBytes ld hl, wBugContestFirstPlaceWinnerID ld de, wBugContestSecondPlaceWinnerID - ld bc, 4 + ld bc, BUG_CONTESTANT_SIZE call CopyBytes ld hl, wBugContestFirstPlaceWinnerID call CopyTempContestant @@ -208,7 +207,7 @@ DetermineContestWinners: ; 1383e jr c, .not_second_place ld hl, wBugContestSecondPlaceWinnerID ld de, wBugContestThirdPlaceWinnerID - ld bc, 4 + ld bc, BUG_CONTESTANT_SIZE call CopyBytes ld hl, wBugContestSecondPlaceWinnerID call CopyTempContestant @@ -230,7 +229,7 @@ DetermineContestWinners: ; 1383e CopyTempContestant: ; 138a0 ; Could've just called CopyBytes. ld de, wBugContestTempWinnerID -rept 3 +rept BUG_CONTESTANT_SIZE +- 1 ld a, [de] inc de ld [hli], a @@ -264,6 +263,7 @@ ComputeAIContestantScores: ; 138b0 inc hl inc hl .loop2 + ; 0, 1, or 2 for 1st, 2nd, or 3rd call Random and 3 cp 3 @@ -278,8 +278,9 @@ ComputeAIContestantScores: ; 138b0 ld a, [hli] ld h, [hl] ld l, a + ; randomly perturb score call Random - and 7 + and %111 ld c, a ld b, 0 add hl, bc @@ -294,7 +295,7 @@ ComputeAIContestantScores: ; 138b0 .done inc e ld a, e - cp 10 + cp NUM_BUG_CONTESTANTS jr nz, .loop ret ; 13900 @@ -337,26 +338,26 @@ ContestScore: ; 13900 ; DVs ld a, [wContestMonDVs + 0] ld b, a - and 2 + and %0010 add a add a ld c, a swap b ld a, b - and 2 + and %0010 add a add c ld d, a ld a, [wContestMonDVs + 1] ld b, a - and 2 + and %0010 ld c, a swap b ld a, b - and 2 + and %0010 srl a add c add c diff --git a/engine/events/catch_tutorial.asm b/engine/events/catch_tutorial.asm index b9352ccd6..d91af65fe 100644 --- a/engine/events/catch_tutorial.asm +++ b/engine/events/catch_tutorial.asm @@ -41,7 +41,7 @@ CatchTutorial:: ; 4e554 ld hl, .AutoInput ld a, BANK(.AutoInput) call StartAutoInput - callfar StartBattle + callfar Predef_StartBattle call StopAutoInput pop af diff --git a/engine/events/celebi.asm b/engine/events/celebi.asm index 1139ad3d5..81565c27e 100755 --- a/engine/events/celebi.asm +++ b/engine/events/celebi.asm @@ -1,3 +1,5 @@ +SPECIALCELEBIEVENT_CELEBI EQU $84 + Special_CelebiShrineEvent: ; 4989a call DelayFrame ld a, [VramState] @@ -10,7 +12,7 @@ Special_CelebiShrineEvent: ; 4989a call _InitSpriteAnimStruct ld hl, SPRITEANIMSTRUCT_TILE_ID add hl, bc - ld [hl], $84 + ld [hl], SPECIALCELEBIEVENT_CELEBI ld hl, SPRITEANIMSTRUCT_ANIM_SEQ_ID add hl, bc ld [hl], SPRITE_ANIM_SEQ_CELEBI @@ -19,7 +21,7 @@ Special_CelebiShrineEvent: ; 4989a ld a, $80 ld [hl], a ld a, 160 ; frame count - ld [wcf64], a + ld [wFrameCounter], a ld d, $0 .loop ld a, [wJumptableIndex] @@ -43,26 +45,26 @@ Special_CelebiShrineEvent: ; 4989a .done pop af ld [VramState], a - call .RefreshPlayerSprite_ClearAllOthers + call .RestorePlayerSprite_DespawnLeaves call CelebiEvent_SetBattleType ret ; 498f9 -.RefreshPlayerSprite_ClearAllOthers: ; 498f9 - ld hl, Sprites + 2 +.RestorePlayerSprite_DespawnLeaves: ; 498f9 + ld hl, Sprite01TileID xor a - ld c, $4 + ld c, 4 .OAMloop: - ld [hli], a - inc hl - inc hl + ld [hli], a ; tile id +rept SPRITEOAMSTRUCT_LENGTH +- 1 inc hl +endr inc a dec c jr nz, .OAMloop - ld hl, Sprites + 4 * 4 - ld bc, 36 * 4 + ld hl, Sprite05 + ld bc, SpritesEnd - Sprite05 xor a call ByteFill ret @@ -76,8 +78,8 @@ LoadCelebiGFX: ; 49912 lb bc, BANK(SpecialCelebiLeafGFX), 4 call Request2bpp ld de, SpecialCelebiGFX - ld hl, vTiles0 tile $84 - lb bc, BANK(SpecialCelebiGFX), $10 + ld hl, vTiles0 tile SPECIALCELEBIEVENT_CELEBI + lb bc, BANK(SpecialCelebiGFX), 4 * 4 call Request2bpp xor a ld [wJumptableIndex], a @@ -86,7 +88,7 @@ LoadCelebiGFX: ; 49912 ; 49935 CelebiEvent_CountDown: ; 49935 - ld hl, wcf64 + ld hl, wFrameCounter ld a, [hl] and a jr z, .done @@ -238,27 +240,27 @@ UpdateCelebiPosition: ; 49aa2 (12:5aa2) CelebiEvent_Cosine: ; 49b3b (12:5b3b) - add $10 - and $3f - cp $20 +; a = d * cos(a * pi/32) + add %010000 + and %111111 + cp %100000 jr nc, .negative - call .SineFunction + call .ApplySineWave ld a, h ret .negative - and $1f - call .SineFunction + and %011111 + call .ApplySineWave ld a, h xor $ff inc a ret - -.SineFunction: ; 49b52 (12:5b52) +.ApplySineWave: ; 49b52 (12:5b52) ld e, a ld a, d - ld d, $0 + ld d, 0 ld hl, .sinewave add hl, de add hl, de @@ -276,7 +278,6 @@ CelebiEvent_Cosine: ; 49b3b (12:5b3b) and a jr nz, .multiply ret - ; 49b6e (12:5b6e) .sinewave ; 49b6e @@ -307,22 +308,22 @@ GetCelebiSpriteTile: ; 49bae .Frame1: - ld a, $84 + ld a, SPECIALCELEBIEVENT_CELEBI jr .load_tile .Frame2: - ld a, $88 + ld a, SPECIALCELEBIEVENT_CELEBI + 4 jr .load_tile .Frame3: - ld a, $8c + ld a, SPECIALCELEBIEVENT_CELEBI + 8 jr .load_tile .Frame4: - ld a, $90 + ld a, SPECIALCELEBIEVENT_CELEBI + 12 .load_tile ld hl, SPRITEANIMSTRUCT_TILE_ID @@ -361,7 +362,7 @@ CelebiEvent_SetBattleType: ; 49bf3 ; 49bf9 -CheckCaughtCelebi: ; 49bf9 +Special_CheckCaughtCelebi: ; 49bf9 ld a, [wBattleResult] bit 6, a jr z, .false diff --git a/engine/events/checkforhiddenitems.asm b/engine/events/checkforhiddenitems.asm new file mode 100644 index 000000000..3c13412d8 --- /dev/null +++ b/engine/events/checkforhiddenitems.asm @@ -0,0 +1,85 @@ +CheckForHiddenItems: ; b8172 +; Checks to see if there are hidden items on the screen that have not yet been found. If it finds one, returns carry. + call GetMapScriptHeaderBank + ld [Buffer1], a +; Get the coordinate of the bottom right corner of the screen, and load it in Buffer3/Buffer4. + ld a, [XCoord] + add SCREEN_WIDTH / 4 + ld [Buffer4], a + ld a, [YCoord] + add SCREEN_HEIGHT / 4 + ld [Buffer3], a +; Get the pointer for the first BG event header in the map... + ld hl, wCurrMapBGEventHeaderPointer + ld a, [hli] + ld h, [hl] + ld l, a +; ... before even checking to see if there are any BG events on this map. + ld a, [wCurrMapBGEventCount] + and a + jr z, .nobgeventitems +; For i = 1:wCurrMapBGEventCount... +.loop +; Store the counter in Buffer2, and store the BG event header pointer in the stack. + ld [Buffer2], a + push hl +; Get the Y coordinate of the BG event. + call .GetFarByte + ld e, a +; Is the Y coordinate of the BG event on the screen? If not, go to the next BG event. + ld a, [Buffer3] + sub e + jr c, .next + cp SCREEN_HEIGHT / 2 + jr nc, .next +; Is the X coordinate of the BG event on the screen? If not, go to the next BG event. + call .GetFarByte + ld d, a + ld a, [Buffer4] + sub d + jr c, .next + cp SCREEN_WIDTH / 2 + jr nc, .next +; Is this BG event a hidden item? If not, go to the next BG event. + call .GetFarByte + cp BGEVENT_ITEM + jr nz, .next +; Has this item already been found? If not, set off the Itemfinder. + ld a, [Buffer1] + call GetFarHalfword + ld a, [Buffer1] + call GetFarHalfword + ld d, h + ld e, l + ld b, CHECK_FLAG + call EventFlagAction + ld a, c + and a + jr z, .itemnearby + +.next +; Restore the BG event header pointer and increment it by the length of a BG event header. + pop hl + ld bc, 5 + add hl, bc +; Restore the BG event counter and decrement it. If it hits zero, there are no hidden items in range. + ld a, [Buffer2] + dec a + jr nz, .loop + +.nobgeventitems + xor a + ret + +.itemnearby + pop hl + scf + ret +; b81e2 + +.GetFarByte: ; b81e2 + ld a, [Buffer1] + call GetFarByte + inc hl + ret +; b81ea diff --git a/engine/events/daycare.asm b/engine/events/daycare.asm index 6395a40fb..6310787ac 100755 --- a/engine/events/daycare.asm +++ b/engine/events/daycare.asm @@ -465,14 +465,14 @@ Special_DayCareManOutside: ; 16936 .Load0: call PrintText - xor a + xor a ; FALSE ld [ScriptVar], a ret .PartyFull: ld hl, .PartyFullText call PrintText - ld a, $1 + ld a, TRUE ld [ScriptVar], a ret ; 16993 @@ -565,7 +565,7 @@ DayCare_GiveEgg: ; 169ac pop hl push bc ld b, $0 - predef CalcPkmnStats + predef Predef_CalcPkmnStats pop bc ld hl, MON_HP add hl, bc @@ -639,7 +639,7 @@ DayCare_InitBreeding: ; 16a3b cp DITTO ld a, $0 jr z, .LoadWhichBreedmonIsTheMother - farcall GetGender + farcall Predef_GetGender ld a, $0 jr z, .LoadWhichBreedmonIsTheMother inc a @@ -684,7 +684,7 @@ DayCare_InitBreeding: ; 16a3b ld de, wEggMonMoves xor a ld [Buffer1], a - predef FillMoves + predef Predef_FillMoves farcall InitEggMoves ld hl, wEggMonID ld a, [PlayerID] @@ -726,7 +726,7 @@ DayCare_InitBreeding: ; 16a3b ld a, TEMPMON ld [MonType], a push hl - farcall GetGender + farcall Predef_GetGender pop hl ld de, wBreedMon1DVs ld bc, wBreedMon2DVs @@ -770,7 +770,7 @@ DayCare_InitBreeding: ; 16a3b call CopyBytes ld hl, wEggMonMoves ld de, wEggMonPP - predef FillPP + predef Predef_FillPP ld hl, wMonOrItemNameBuffer ld de, StringBuffer1 ld bc, NAME_LENGTH diff --git a/engine/events/dratini.asm b/engine/events/dratini.asm index f110b34ab..83732bef2 100644 --- a/engine/events/dratini.asm +++ b/engine/events/dratini.asm @@ -1,4 +1,4 @@ -SpecialDratini: ; 0x8b170 +Special_Dratini: ; 0x8b170 ; if ScriptVar is 0 or 1, change the moveset of the last Dratini in the party. ; 0: give it a special moveset with Extremespeed. ; 1: give it the normal moveset of a level 15 Dratini. diff --git a/engine/events/elevator.asm b/engine/events/elevator.asm index e936976bb..e0426c5bd 100755 --- a/engine/events/elevator.asm +++ b/engine/events/elevator.asm @@ -189,8 +189,7 @@ Elevator_GetCurrentFloorString: ; 1353f Elevator_MenuDataHeader: ; 0x13550 db MENU_BACKUP_TILES ; flags - db 01, 12 ; start coords - db 09, 18 ; end coords + menu_coords 12, 1, 18, 9 dw Elevator_MenuData2 db 1 ; default option ; 0x13558 @@ -200,12 +199,12 @@ Elevator_MenuData2: ; 0x13558 db 4, 0 ; rows, columns db 1 ; horizontal spacing dbw 0, CurElevator - dba GetElevatorFlorStrings + dba GetElevatorFloorStrings dba NULL dba NULL ; 13568 -GetElevatorFlorStrings: ; 13568 +GetElevatorFloorStrings: ; 13568 ld a, [MenuSelection] GetFloorString: ; 1356b push de @@ -220,7 +219,7 @@ FloorToString: ; 13575 push de ld e, a ld d, 0 - ld hl, .floors + ld hl, ElevatorFloorNames add hl, de add hl, de ld a, [hli] @@ -230,54 +229,4 @@ FloorToString: ; 13575 ret ; 13583 -.floors - dw .b4f - dw .b3f - dw .b2f - dw .b1f - dw ._1f - dw ._2f - dw ._3f - dw ._4f - dw ._5f - dw ._6f - dw ._7f - dw ._8f - dw ._9f - dw ._10f - dw ._11f - dw .roof - -.b4f - db "B4F@" -.b3f - db "B3F@" -.b2f - db "B2F@" -.b1f - db "B1F@" -._1f - db "1F@" -._2f - db "2F@" -._3f - db "3F@" -._4f - db "4F@" -._5f - db "5F@" -._6f - db "6F@" -._7f - db "7F@" -._8f - db "8F@" -._9f - db "9F@" -._10f - db "10F@" -._11f - db "11F@" -.roof - db "ROOF@" -; 135db +INCLUDE "data/elevator_floors.asm" diff --git a/engine/events/field_moves.asm b/engine/events/field_moves.asm index a1a2e2e79..3fb1fe9e6 100755 --- a/engine/events/field_moves.asm +++ b/engine/events/field_moves.asm @@ -7,7 +7,7 @@ PlayWhirlpoolSound: ; 8c7d4 ; 8c7e1 BlindingFlash: ; 8c7e1 - farcall FadeOutPalettes + farcall Special_FadeOutPalettes ld hl, wStatusFlags set 2, [hl] ; Flash farcall ReplaceTimeOfDayPals @@ -15,7 +15,7 @@ BlindingFlash: ; 8c7e1 ld b, SCGB_MAPPALS call GetSGBLayout farcall LoadOW_BGPal7 - farcall FadeInPalettes + farcall Special_FadeInPalettes ret ; 8c80a @@ -39,13 +39,13 @@ ShakeHeadbuttTree: ; 8c80a ld [wCurrSpriteOAMAddr], a farcall DoNextFrameForAllSprites call HideHeadbuttTree - ld a, $20 - ld [wcf64], a + ld a, 32 + ld [wFrameCounter], a call WaitSFX ld de, SFX_SANDSTORM call PlaySFX .loop - ld hl, wcf64 + ld hl, wFrameCounter ld a, [hl] and a jr z, .done @@ -62,8 +62,8 @@ ShakeHeadbuttTree: ; 8c80a xor a ld [hBGMapMode], a farcall ClearSpriteAnims - ld hl, Sprites + 36 * 4 - ld bc, SpritesEnd - (Sprites + 36 * 4) + ld hl, Sprite37 + ld bc, SpritesEnd - Sprite37 xor a call ByteFill ld de, Font @@ -188,7 +188,7 @@ Cut_SpawnAnimateTree: ; 8ca23 (23:4a23) add hl, bc ld [hl], $84 ld a, 32 - ld [wcf64], a + ld [wFrameCounter], a ; Cut_StartWaiting ld hl, wJumptableIndex inc [hl] @@ -206,7 +206,7 @@ Cut_SpawnAnimateLeaves: ; 8ca3c (23:4a3c) ld a, $30 call Cut_SpawnLeaf ld a, 32 ; frames - ld [wcf64], a + ld [wFrameCounter], a ; Cut_StartWaiting ld hl, wJumptableIndex inc [hl] @@ -220,7 +220,7 @@ Cut_StartWaiting: ; 8ca5c (23:4a5c) inc [hl] Cut_WaitAnimSFX: ; 8ca64 (23:4a64) - ld hl, wcf64 + ld hl, wFrameCounter ld a, [hl] and a jr z, .finished @@ -336,7 +336,7 @@ FlyFromAnim: ; 8caed add hl, bc ld [hl], SPRITE_ANIM_SEQ_FLY_FROM ld a, 128 - ld [wcf64], a + ld [wFrameCounter], a .loop ld a, [wJumptableIndex] bit 7, a @@ -374,7 +374,7 @@ FlyToAnim: ; 8cb33 add hl, bc ld [hl], 11 * 8 ld a, 64 - ld [wcf64], a + ld [wFrameCounter], a .loop ld a, [wJumptableIndex] bit 7, a @@ -393,19 +393,19 @@ FlyToAnim: ; 8cb33 ret .RestorePlayerSprite_DespawnLeaves: ; 8cb82 (23:4b82) - ld hl, Sprites + 2 ; Tile ID + ld hl, Sprite01TileID xor a - ld c, $4 -.loop2 - ld [hli], a - inc hl - inc hl + ld c, 4 +.OAMloop + ld [hli], a ; tile id +rept SPRITEOAMSTRUCT_LENGTH +- 1 inc hl +endr inc a dec c - jr nz, .loop2 - ld hl, Sprites + 4 * 4 - ld bc, SpritesEnd - (Sprites + 4 * 4) + jr nz, .OAMloop + ld hl, Sprite05 + ld bc, SpritesEnd - Sprite05 xor a call ByteFill ret @@ -431,7 +431,7 @@ FlyFunction_InitGFX: ; 8cb9b (23:4b9b) FlyFunction_FrameTimer: ; 8cbc8 (23:4bc8) call .SpawnLeaf - ld hl, wcf64 + ld hl, wFrameCounter ld a, [hl] and a jr z, .exit diff --git a/engine/events/fish.asm b/engine/events/fish.asm index 9d1ea63ae..05bd7f530 100644 --- a/engine/events/fish.asm +++ b/engine/events/fish.asm @@ -80,7 +80,7 @@ rept 4 endr ld a, [TimeOfDay] - and 3 + maskbits NUM_DAYTIMES +- 1 cp NITE_F jr c, .time_species inc hl diff --git a/engine/events/fruit_trees.asm b/engine/events/fruit_trees.asm index d0b0bac15..44f2315a0 100644 --- a/engine/events/fruit_trees.asm +++ b/engine/events/fruit_trees.asm @@ -2,7 +2,7 @@ FruitTreeScript:: ; 44000 callasm GetCurTreeFruit opentext copybytetovar CurFruit - itemtotext $0, $0 + itemtotext USE_SCRIPT_VAR, MEM_BUFFER_0 writetext FruitBearingTreeText buttonsound callasm TryResetFruitTrees @@ -58,7 +58,7 @@ CheckFruitTree: ; 44055 ; 4405f PickedFruitTree: ; 4405f - farcall TrainerRankings_FruitPicked + farcall StubbedTrainerRankings_FruitPicked ld b, 1 jp GetFruitTreeFlag ; 4406a diff --git a/engine/events/halloffame.asm b/engine/events/halloffame.asm index f1981c2fd..c3e90b597 100755 --- a/engine/events/halloffame.asm +++ b/engine/events/halloffame.asm @@ -42,7 +42,7 @@ RedCredits:: ; 86455 ld [MusicFadeID + 1], a ld a, 10 ld [MusicFade], a - farcall FadeOutPalettes + farcall Special_FadeOutPalettes xor a ld [VramState], a ld [hMapAnims], a @@ -65,7 +65,7 @@ HallOfFame_FadeOutMusic: ; 8648e ld [MusicFadeID + 1], a ld a, 10 ld [MusicFade], a - farcall FadeOutPalettes + farcall Special_FadeOutPalettes xor a ld [VramState], a ld [hMapAnims], a @@ -92,9 +92,9 @@ AnimateHallOfFame: ; 864c3 ld de, MUSIC_HALL_OF_FAME call HallOfFame_PlayMusicDE xor a - ld [wcf64], a + ld [wHallOfFameMonCounter], a .loop - ld a, [wcf64] + ld a, [wHallOfFameMonCounter] cp PARTY_LENGTH jr nc, .done ld hl, wHallOfFameTempMon1 @@ -108,7 +108,7 @@ AnimateHallOfFame: ; 864c3 pop hl call .DisplayNewHallOfFamer jr c, .done - ld hl, wcf64 + ld hl, wHallOfFameMonCounter inc [hl] jr .loop @@ -130,7 +130,7 @@ AnimateHallOfFame: ; 864c3 call WaitBGMap decoord 6, 5 ld c, $6 - predef HOF_AnimateFrontpic + predef HOF_Predef_AnimateFrontpic ld c, 60 call DelayFrames and a @@ -244,18 +244,18 @@ AnimateHOFMonEntrance: ; 865b5 ld a, [hli] ld [TempMonDVs + 1], a ld hl, TempMonDVs - predef GetUnownLetter + predef Predef_GetUnownLetter hlcoord 0, 0 ld bc, SCREEN_WIDTH * SCREEN_HEIGHT ld a, " " call ByteFill ld de, vTiles2 tile $31 - predef GetMonBackpic + predef Predef_GetMonBackpic ld a, $31 ld [hGraphicStartTile], a hlcoord 6, 6 lb bc, 6, 6 - predef PlaceGraphic + predef Predef_PlaceGraphic ld a, $d0 ld [hSCY], a ld a, $90 @@ -321,7 +321,7 @@ _HallOfFamePC: ; 86650 .DisplayTeam: xor a - ld [wcf64], a + ld [wHallOfFameMonCounter], a .next call .DisplayMonAndStrings jr c, .start_button @@ -341,7 +341,7 @@ _HallOfFamePC: ; 86650 jr .loop .a_button - ld hl, wcf64 + ld hl, wHallOfFameMonCounter inc [hl] jr .next @@ -356,7 +356,7 @@ _HallOfFamePC: ; 86650 .DisplayMonAndStrings: ; Print the number of times the player has entered the Hall of Fame. ; If that number is above 200, print "HOF Master!" instead. - ld a, [wcf64] + ld a, [wHallOfFameMonCounter] cp PARTY_LENGTH jr nc, .fail ld hl, wHallOfFameTempMon1 @@ -403,7 +403,7 @@ _HallOfFamePC: ; 86650 call SetPalettes decoord 6, 5 ld c, $6 - predef HOF_AnimateFrontpic + predef HOF_Predef_AnimateFrontpic and a ret @@ -478,7 +478,7 @@ DisplayHOFMon: ; 86748 ld [CurPartySpecies], a ld [wd265], a ld hl, TempMonDVs - predef GetUnownLetter + predef Predef_GetUnownLetter xor a ld [wBoxAlignment], a hlcoord 6, 5 @@ -499,7 +499,7 @@ DisplayHOFMon: ; 86748 call PlaceString ld a, TEMPMON ld [MonType], a - farcall GetGender + farcall Predef_GetGender ld a, " " jr c, .got_gender ld a, "♂" @@ -546,7 +546,7 @@ HOF_AnimatePlayerPic: ; 86810 ld [hGraphicStartTile], a hlcoord 6, 6 lb bc, 6, 6 - predef PlaceGraphic + predef Predef_PlaceGraphic ld a, $d0 ld [hSCY], a ld a, $90 @@ -570,7 +570,7 @@ HOF_AnimatePlayerPic: ; 86810 ld [hGraphicStartTile], a hlcoord 12, 5 lb bc, 7, 7 - predef PlaceGraphic + predef Predef_PlaceGraphic ld a, $c0 ld [hSCX], a call WaitBGMap diff --git a/engine/events/happiness_egg.asm b/engine/events/happiness_egg.asm index a4ae8b7e6..2db54a1a7 100755 --- a/engine/events/happiness_egg.asm +++ b/engine/events/happiness_egg.asm @@ -1,4 +1,4 @@ -GetFirstPokemonHappiness: ; 718d +Special_GetFirstPokemonHappiness: ; 718d ld hl, PartyMon1Happiness ld bc, PARTYMON_STRUCT_LENGTH ld de, PartySpecies @@ -17,11 +17,11 @@ GetFirstPokemonHappiness: ; 718d call GetPokemonName jp CopyPokemonName_Buffer1_Buffer3 -CheckFirstMonIsEgg: ; 71ac +Special_CheckFirstMonIsEgg: ; 71ac ld a, [PartySpecies] ld [wd265], a cp EGG - ld a, $1 + ld a, 1 jr z, .egg xor a diff --git a/engine/events/heal_machine_anim.asm b/engine/events/heal_machine_anim.asm index 493330e58..da3b845e5 100755 --- a/engine/events/heal_machine_anim.asm +++ b/engine/events/heal_machine_anim.asm @@ -1,4 +1,4 @@ -HealMachineAnim: ; 12324 +Special_HealMachineAnim: ; 12324 ; If you have no Pokemon, don't change the buffer. This can lead to some glitchy effects if you have no Pokemon. ld a, [PartyCount] and a @@ -47,6 +47,7 @@ HealMachineAnim: ; 12324 ; 12365 .Pointers: ; 12365 +; entries correspond to HEALMACHINE_* constants dw .Pokecenter dw .ElmLab dw .HallOfFame @@ -73,20 +74,20 @@ HealMachineAnim: ; 12324 call .LoadPalettes ld de, .HealMachineGFX ld hl, vTiles0 tile $7c - lb bc, BANK(.HealMachineGFX), $2 + lb bc, BANK(.HealMachineGFX), 2 call Request2bpp ret ; 12393 .PC_LoadBallsOntoMachine: ; 12393 - ld hl, Sprites + $80 + ld hl, Sprite33 ld de, .PC_ElmsLab_OAM call .PlaceHealingMachineTile call .PlaceHealingMachineTile jr .LoadBallsOntoMachine .HOF_LoadBallsOntoMachine: ; 123a1 - ld hl, Sprites + $80 + ld hl, Sprite33 ld de, .HOF_OAM .LoadBallsOntoMachine: ; 123a7 @@ -160,7 +161,7 @@ INCBIN "gfx/overworld/heal_machine.2bpp" ld hl, .palettes ld de, wOBPals2 palette PAL_OW_TREE ld bc, 1 palettes - ld a, $5 + ld a, BANK(wOBPals2) call FarCopyWRAM ld a, $1 ld [hCGBPalUpdate], a @@ -168,14 +169,11 @@ INCBIN "gfx/overworld/heal_machine.2bpp" ; 12451 .palettes ; 12451 - RGB 31, 31, 31 - RGB 31, 19, 10 - RGB 31, 07, 01 - RGB 00, 00, 00 +INCLUDE "gfx/overworld/heal_machine.pal" ; 12459 .FlashPalettes8Times: ; 12459 - ld c, $8 + ld c, 8 .palette_loop push bc call .FlashPalettes @@ -198,7 +196,7 @@ INCBIN "gfx/overworld/heal_machine.2bpp" .go ld a, [rSVBK] push af - ld a, $5 + ld a, BANK(wOBPals2) ld [rSVBK], a ld hl, wOBPals2 palette PAL_OW_TREE @@ -249,17 +247,17 @@ INCBIN "gfx/overworld/heal_machine.2bpp" ld a, [de] add c inc de - ld [hli], a + ld [hli], a ; y ld a, [de] add b inc de - ld [hli], a + ld [hli], a ; x ld a, [de] inc de - ld [hli], a + ld [hli], a ; tile id ld a, [de] inc de - ld [hli], a + ld [hli], a ; attributes pop bc ret ; 124c1 diff --git a/engine/events/kurt.asm b/engine/events/kurt.asm index 4f3343dd1..13bde6f7e 100644 --- a/engine/events/kurt.asm +++ b/engine/events/kurt.asm @@ -76,7 +76,7 @@ Kurt_SelectApricorn: ; 88055 jr nz, .done .nope - xor a + xor a ; FALSE .done ld c, a @@ -85,13 +85,12 @@ Kurt_SelectApricorn: ; 88055 .MenuDataHeader: ; 0x88086 db MENU_BACKUP_TILES ; flags - db 01, 01 ; start coords - db 10, 13 ; end coords + menu_coords 1, 1, 13, 10 dw .MenuData2 db 1 ; default option ; 0x8808e - db 0 + db 0 ; XXX .MenuData2: ; 0x8808f db SCROLLINGMENU_DISPLAY_ARROWS ; flags @@ -160,8 +159,7 @@ Kurt_SelectQuantity: ; 880c2 .MenuDataHeader: ; 0x8810d db MENU_BACKUP_TILES ; flags - db 09, 06 ; start coords - db 12, 19 ; end coords + menu_coords 6, 9, SCREEN_WIDTH - 1, 12 dw NULL db -1 ; default option db 0 diff --git a/engine/events/lucky_number.asm b/engine/events/lucky_number.asm index 4488cfcc9..a172fc431 100644 --- a/engine/events/lucky_number.asm +++ b/engine/events/lucky_number.asm @@ -103,7 +103,7 @@ Special_CheckForLuckyNumberWinners: ; 4d87a ld a, [ScriptVar] and a ret z ; found nothing - farcall TrainerRankings_LuckyNumberShow + farcall StubbedTrainerRankings_LuckyNumberShow ld a, [wFoundMatchingIDInParty] and a push af diff --git a/engine/events/magikarp.asm b/engine/events/magikarp.asm index 68e8baad7..6588295b8 100644 --- a/engine/events/magikarp.asm +++ b/engine/events/magikarp.asm @@ -28,7 +28,7 @@ Special_CheckMagikarpLength: ; fbb32 ld c, l call CalcMagikarpLength call PrintMagikarpLength - farcall TrainerRankings_MagikarpLength + farcall StubbedTrainerRankings_MagikarpLength ld hl, .MeasureItText call PrintText @@ -52,22 +52,22 @@ Special_CheckMagikarpLength: ; fbb32 ld hl, PartyMonOT call SkipNames call CopyBytes - ld a, 3 + ld a, MAGIKARPLENGTH_BEAT_RECORD ld [ScriptVar], a ret .not_long_enough - ld a, 2 + ld a, MAGIKARPLENGTH_TOO_SHORT ld [ScriptVar], a ret .declined - ld a, 1 + ld a, MAGIKARPLENGTH_REFUSED ld [ScriptVar], a ret .not_magikarp - xor a + xor a ; MAGIKARPLENGTH_NOT_MAGIKARP ld [ScriptVar], a ret ; fbba9 diff --git a/engine/events/magnet_train.asm b/engine/events/magnet_train.asm index c85642ab8..c2ff36135 100755 --- a/engine/events/magnet_train.asm +++ b/engine/events/magnet_train.asm @@ -16,7 +16,7 @@ Special_MagnetTrain: ; 8cc04 ld h, a ld a, [rSVBK] push af - ld a, $5 + ld a, BANK(wMagnetTrain) ld [rSVBK], a ld a, h @@ -86,20 +86,20 @@ Special_MagnetTrain: ; 8cc04 MagnetTrain_UpdateLYOverrides: ; 8cc99 ld hl, LYOverridesBackup ld c, $2f - ld a, [wcf64] + ld a, [wMagnetTrainOffset] add a ld [hSCX], a call .loadloop ld c, $30 - ld a, [wcf65] + ld a, [wMagnetTrainPosition] call .loadloop ld c, $31 - ld a, [wcf64] + ld a, [wMagnetTrainOffset] add a call .loadloop ld a, [wMagnetTrainDirection] ld d, a - ld hl, wcf64 + ld hl, wMagnetTrainOffset ld a, [hl] add d add d @@ -129,7 +129,7 @@ MagntTrain_LoadGFX_PlayMusic: ; 8ccc9 ld [hSCY], a ld a, [rSVBK] push af - ld a, $1 + ld a, BANK(wPlayerGender) ld [rSVBK], a farcall GetPlayerIcon pop af @@ -147,11 +147,11 @@ MagntTrain_LoadGFX_PlayMusic: ; 8ccc9 call MagnetTrain_InitLYOverrides ld hl, wJumptableIndex xor a - ld [hli], a + ld [hli], a ; wJumptableIndex ld a, [wMagnetTrainInitPosition] - ld [hli], a - ld [hli], a - ld [hli], a + ld [hli], a ; wMagnetTrainOffset + ld [hli], a ; wMagnetTrainPosition + ld [hli], a ; wMagnetTrainWaitCounter ld de, MUSIC_MAGNET_TRAIN call PlayMusic2 ret @@ -220,8 +220,7 @@ GetMagnetTrainBGTiles: ; 8cd74 ; 8cd82 MagnetTrainBGTiles: ; 8cd82 -; Alternating tiles for each line -; of the Magnet Train tilemap. +; Alternating tiles for each line of the Magnet Train tilemap. db $4c, $4d ; bush db $5c, $5d ; bush db $4c, $4d ; bush @@ -263,25 +262,25 @@ SetMagnetTrainPals: ; 8cdc3 ; bushes hlbgcoord 0, 0 ld bc, 4 * BG_MAP_WIDTH - ld a, $2 + ld a, PAL_BG_GREEN call ByteFill ; train hlbgcoord 0, 4 ld bc, 10 * BG_MAP_WIDTH - xor a + xor a ; PAL_BG_GRAY call ByteFill ; more bushes hlbgcoord 0, 14 ld bc, 4 * BG_MAP_WIDTH - ld a, $2 + ld a, PAL_BG_GREEN call ByteFill ; train window hlbgcoord 7, 8 ld bc, 6 - ld a, $4 + ld a, PAL_BG_YELLOW call ByteFill ld a, $0 @@ -325,7 +324,7 @@ MagnetTrain_Jumptable: ; 8cdf7 ld b, SPRITE_ANIM_INDEX_MAGNET_TRAIN_RED ld a, [rSVBK] push af - ld a, $1 + ld a, BANK(wPlayerGender) ld [rSVBK], a ld a, [wPlayerGender] bit 0, a @@ -342,13 +341,13 @@ MagnetTrain_Jumptable: ; 8cdf7 ld [hl], $0 call .Next ld a, $80 - ld [wcf66], a + ld [wMagnetTrainWaitCounter], a ret ; 8ce47 .MoveTrain1: ; 8ce47 ld hl, wMagnetTrainHoldPosition - ld a, [wcf65] + ld a, [wMagnetTrainPosition] cp [hl] jr z, .PrepareToHoldTrain ld e, a @@ -356,7 +355,7 @@ MagnetTrain_Jumptable: ; 8cdf7 xor $ff inc a add e - ld [wcf65], a + ld [wMagnetTrainPosition], a ld hl, wGlobalAnimXOffset ld a, [wMagnetTrainDirection] add [hl] @@ -366,12 +365,12 @@ MagnetTrain_Jumptable: ; 8cdf7 .PrepareToHoldTrain: call .Next ld a, $80 - ld [wcf66], a + ld [wMagnetTrainWaitCounter], a ret ; 8ce6d .WaitScene: ; 8ce6d - ld hl, wcf66 + ld hl, wMagnetTrainWaitCounter ld a, [hl] and a jr z, .DoneWaiting @@ -385,7 +384,7 @@ MagnetTrain_Jumptable: ; 8cdf7 .MoveTrain2: ; 8ce7a ld hl, wMagnetTrainFinalPosition - ld a, [wcf65] + ld a, [wMagnetTrainPosition] cp [hl] jr z, .PrepareToFinishAnim ld e, a @@ -396,7 +395,7 @@ MagnetTrain_Jumptable: ; 8cdf7 ld a, e add d add d - ld [wcf65], a + ld [wMagnetTrainPosition], a ld hl, wGlobalAnimXOffset ld a, [wMagnetTrainDirection] ld d, a @@ -429,14 +428,14 @@ MagnetTrain_Jumptable_FirstRunThrough: ; 8ceae call DelayFrame ld a, [rSVBK] push af - ld a, $1 + ld a, BANK(wEnvironment) ld [rSVBK], a ld a, [TimeOfDayPal] push af ld a, [wEnvironment] push af ld a, [TimeOfDay] - and $3 + maskbits NUM_DAYTIMES +- 1 ld [TimeOfDayPal], a ld a, $1 ld [wEnvironment], a @@ -459,23 +458,11 @@ MagnetTrain_Jumptable_FirstRunThrough: ; 8ceae ; 8ceff MagnetTrainTilemap1: - db $1f, $05, $06, $0a, $0a - db $0a, $09, $0a, $0a, $0a - db $0a, $0a, $0a, $09, $0a - db $0a, $0a, $0b, $0c, $1f + db $1f, $05, $06, $0a, $0a, $0a, $09, $0a, $0a, $0a, $0a, $0a, $0a, $09, $0a, $0a, $0a, $0b, $0c, $1f MagnetTrainTilemap2: - db $14, $15, $16, $1a, $1a - db $1a, $19, $1a, $1a, $1a - db $1a, $1a, $1a, $19, $1a - db $1a, $1a, $1b, $1c, $1d + db $14, $15, $16, $1a, $1a, $1a, $19, $1a, $1a, $1a, $1a, $1a, $1a, $19, $1a, $1a, $1a, $1b, $1c, $1d MagnetTrainTilemap3: - db $24, $25, $26, $27, $07 - db $2f, $29, $28, $28, $28 - db $28, $28, $28, $29, $07 - db $2f, $2a, $2b, $2c, $2d + db $24, $25, $26, $27, $07, $2f, $29, $28, $28, $28, $28, $28, $28, $29, $07, $2f, $2a, $2b, $2c, $2d MagnetTrainTilemap4: - db $20, $1f, $2e, $1f, $17 - db $00, $2e, $1f, $1f, $1f - db $1f, $1f, $1f, $2e, $17 - db $00, $1f, $2e, $1f, $0f + db $20, $1f, $2e, $1f, $17, $00, $2e, $1f, $1f, $1f, $1f, $1f, $1f, $2e, $17, $00, $1f, $2e, $1f, $0f ; 8cf4f diff --git a/engine/events/map_name_sign.asm b/engine/events/map_name_sign.asm new file mode 100644 index 000000000..b20d74ee4 --- /dev/null +++ b/engine/events/map_name_sign.asm @@ -0,0 +1,274 @@ +MAP_NAME_SIGN_START EQU $60 + +ReturnFromMapSetupScript:: ; b8000 + xor a + ld [hBGMapMode], a + farcall .inefficient_farcall ; this is a waste of 6 ROM bytes and 6 stack bytes + ret +; b800a + +; should have just been a fallthrough +.inefficient_farcall ; b800a + ld a, [MapGroup] + ld b, a + ld a, [MapNumber] + ld c, a + call GetWorldMapLocation + ld [wCurrentLandmark], a + call .CheckNationalParkGate + jr z, .nationalparkgate + + call GetMapEnvironment + cp GATE + jr nz, .not_gate + +.nationalparkgate + ld a, -1 + ld [wCurrentLandmark], a + +.not_gate + ld hl, wEnteredMapFromContinue + bit 1, [hl] + res 1, [hl] + jr nz, .dont_do_map_sign + + call .CheckMovingWithinLandmark + jr z, .dont_do_map_sign + ld a, [wCurrentLandmark] + ld [wPreviousLandmark], a + + call .CheckSpecialMap + jr z, .dont_do_map_sign + +; Display for 60 frames + ld a, 60 + ld [wLandmarkSignTimer], a + call LoadMapNameSignGFX + call InitMapNameFrame + farcall HDMATransfer_OnlyTopFourRows + ret + +.dont_do_map_sign + ld a, [wCurrentLandmark] + ld [wPreviousLandmark], a + ld a, $90 + ld [rWY], a + ld [hWY], a + xor a + ld [hLCDCPointer], a + ret +; b8064 + +.CheckMovingWithinLandmark: ; b8064 + ld a, [wCurrentLandmark] + ld c, a + ld a, [wPreviousLandmark] + cp c + ret z + cp SPECIAL_MAP + ret +; b8070 + +.CheckSpecialMap: ; b8070 +; These landmarks do not get pop-up signs. + cp -1 + ret z + cp SPECIAL_MAP + ret z + cp RADIO_TOWER + ret z + cp LAV_RADIO_TOWER + ret z + cp UNDERGROUND_PATH + ret z + cp INDIGO_PLATEAU + ret z + cp POWER_PLANT + ret z + ld a, $1 + and a + ret +; b8089 + +.CheckNationalParkGate: ; b8089 + ld a, [MapGroup] + cp GROUP_ROUTE_35_NATIONAL_PARK_GATE + ret nz + ld a, [MapNumber] + cp MAP_ROUTE_35_NATIONAL_PARK_GATE + ret z + cp MAP_ROUTE_36_NATIONAL_PARK_GATE + ret +; b8098 + + +PlaceMapNameSign:: ; b8098 (2e:4098) + ld hl, wLandmarkSignTimer + ld a, [hl] + and a + jr z, .disappear + dec [hl] + cp 60 + ret z + cp 59 + jr nz, .skip2 + call InitMapNameFrame + call PlaceMapNameCenterAlign + farcall HDMATransfer_OnlyTopFourRows +.skip2 + ld a, $80 + ld a, $70 + ld [rWY], a + ld [hWY], a + ret + +.disappear + ld a, $90 + ld [rWY], a + ld [hWY], a + xor a + ld [hLCDCPointer], a + ret + + +LoadMapNameSignGFX: ; b80c6 + ld de, MapEntryFrameGFX + ld hl, vTiles2 tile MAP_NAME_SIGN_START + lb bc, BANK(MapEntryFrameGFX), 14 + call Get2bpp + ret +; b80d3 + +InitMapNameFrame: ; b80d3 + hlcoord 0, 0 + ld b, 2 + ld c, 18 + call InitMapSignAttrMap + call PlaceMapNameFrame + ret +; b80e1 + + +PlaceMapNameCenterAlign: ; b80e1 (2e:40e1) + ld a, [wCurrentLandmark] + ld e, a + farcall GetLandmarkName + call .GetNameLength + ld a, SCREEN_WIDTH + sub c + srl a + ld b, $0 + ld c, a + hlcoord 0, 2 + add hl, bc + ld de, StringBuffer1 + call PlaceString + ret + +.GetNameLength: ; b8101 (2e:4101) + ld c, 0 + push hl + ld hl, StringBuffer1 +.loop + ld a, [hli] + cp "@" + jr z, .stop + cp "%" + jr z, .loop + inc c + jr .loop +.stop + pop hl + ret + + +InitMapSignAttrMap: ; b8115 + ld de, AttrMap - TileMap + add hl, de + inc b + inc b + inc c + inc c + ld a, PAL_BG_TEXT | PRIORITY +.loop + push bc + push hl +.inner_loop + ld [hli], a + dec c + jr nz, .inner_loop + pop hl + ld de, SCREEN_WIDTH + add hl, de + pop bc + dec b + jr nz, .loop + ret +; b812f + +PlaceMapNameFrame: ; b812f + hlcoord 0, 0 + ; top left + ld a, MAP_NAME_SIGN_START + 1 + ld [hli], a + ; top row + ld a, MAP_NAME_SIGN_START + 2 + call .FillTopBottom + ; top right + ld a, MAP_NAME_SIGN_START + 4 + ld [hli], a + ; left, first line + ld a, MAP_NAME_SIGN_START + 5 + ld [hli], a + ; first line + call .FillMiddle + ; right, first line + ld a, MAP_NAME_SIGN_START + 11 + ld [hli], a + ; left, second line + ld a, MAP_NAME_SIGN_START + 6 + ld [hli], a + ; second line + call .FillMiddle + ; right, second line + ld a, MAP_NAME_SIGN_START + 12 + ld [hli], a + ; bottom left + ld a, MAP_NAME_SIGN_START + 7 + ld [hli], a + ; bottom + ld a, MAP_NAME_SIGN_START + 8 + call .FillTopBottom + ; bottom right + ld a, MAP_NAME_SIGN_START + 10 + ld [hl], a + ret +; b815b + +.FillMiddle: ; b815b + ld c, SCREEN_WIDTH - 2 + ld a, MAP_NAME_SIGN_START + 13 +.loop + ld [hli], a + dec c + jr nz, .loop + ret +; b8164 + +.FillTopBottom: ; b8164 + ld c, 5 + jr .enterloop + +.continueloop + ld [hli], a + ld [hli], a + +.enterloop + inc a + ld [hli], a + ld [hli], a + dec a + dec c + jr nz, .continueloop + ret +; b8172 diff --git a/engine/events/misc_scripts.asm b/engine/events/misc_scripts.asm index 97372a57a..73ed89143 100755 --- a/engine/events/misc_scripts.asm +++ b/engine/events/misc_scripts.asm @@ -2,7 +2,7 @@ Script_AbortBugContest: ; 0x122c1 checkflag ENGINE_BUG_CONTEST_TIMER iffalse .finish setflag ENGINE_DAILY_BUG_CONTEST - special ContestReturnMons + special Special_ContestReturnMons .finish end diff --git a/engine/events/misc_scripts_2.asm b/engine/events/misc_scripts_2.asm index c4c51d5e6..29416a9e5 100644 --- a/engine/events/misc_scripts_2.asm +++ b/engine/events/misc_scripts_2.asm @@ -13,7 +13,7 @@ RepelWoreOffScript:: ; 0x13619 HiddenItemScript:: ; 0x13625 opentext copybytetovar EngineBuffer3 - itemtotext 0, 0 + itemtotext USE_SCRIPT_VAR, MEM_BUFFER_0 writetext .found_text giveitem ITEM_FROM_MEM iffalse .bag_full diff --git a/engine/events/mom.asm b/engine/events/mom.asm index 061c12f8f..c7e1cd6e9 100644 --- a/engine/events/mom.asm +++ b/engine/events/mom.asm @@ -146,7 +146,7 @@ Special_BankOfMom: ; 16218 ld [hli], a ld [hl], a ld a, $5 - ld [wcf64], a + ld [wMomBankDigitCursorPosition], a call LoadStandardMenuDataHeader call Mom_SetUpDepositMenu call Mom_Wait10Frames @@ -213,7 +213,7 @@ Special_BankOfMom: ; 16218 ld [hli], a ld [hl], a ld a, $5 - ld [wcf64], a + ld [wMomBankDigitCursorPosition], a call LoadStandardMenuDataHeader call Mom_SetUpWithdrawMenu call Mom_Wait10Frames @@ -729,8 +729,7 @@ Mom_HeldString: ; 166b0 MenuDataHeader_0x166b5: ; 0x166b5 db MENU_BACKUP_TILES ; flags - db 00, 00 ; start coords - db 10, 10 ; end coords + menu_coords 0, 0, 10, 10 dw MenuData2_0x166bd db 1 ; default option ; 0x166bd diff --git a/engine/events/mom_phone.asm b/engine/events/mom_phone.asm index bef7d5688..50496e663 100755 --- a/engine/events/mom_phone.asm +++ b/engine/events/mom_phone.asm @@ -217,7 +217,7 @@ endr INCLUDE "data/items/mom_phone.asm" - db 0, 0, 0 ; XXX + db 0, 0, 0 ; unused _MomText_HiHowAreYou: ; 0xfd1b1 ; Hi, ! How are you? @@ -255,10 +255,10 @@ _MomText_ItsInRoom: ; 0xfd1ca db "@" ; 0xfd1cf - db 0 ; XXX + db 0 ; unused -Predef3A: ; fd1d0 +DummyPredef3A: ; fd1d0 ret ; fd1d1 - ret ; XXX + ret ; unused diff --git a/engine/events/move_deleter.asm b/engine/events/move_deleter.asm index 95fc0f1d8..3e06113ae 100644 --- a/engine/events/move_deleter.asm +++ b/engine/events/move_deleter.asm @@ -1,4 +1,4 @@ -MoveDeletion: +Special_MoveDeletion: ld hl, .IntroText call PrintText call YesNoBox diff --git a/engine/events/move_tutor.asm b/engine/events/move_tutor.asm index 5082364e0..8bb29f9ae 100644 --- a/engine/events/move_tutor.asm +++ b/engine/events/move_tutor.asm @@ -22,7 +22,7 @@ Special_MoveTutor: ; 4925b .enter_loop call CheckCanLearnMoveTutorMove jr nc, .loop - xor a + xor a ; FALSE ld [ScriptVar], a jr .quit @@ -35,10 +35,11 @@ Special_MoveTutor: ; 4925b .GetMoveTutorMove: ; 492a5 ld a, [ScriptVar] - cp 1 + cp MOVETUTOR_FLAMETHROWER jr z, .flamethrower - cp 2 + cp MOVETUTOR_THUNDERBOLT jr z, .thunderbolt + ; MOVETUTOR_ICE_BEAM ld a, ICE_BEAM ret @@ -54,7 +55,7 @@ CheckCanLearnMoveTutorMove: ; 492b9 ld hl, .MenuDataHeader call LoadMenuDataHeader - predef CanLearnTMHMMove + predef Predef_CanLearnTMHMMove push bc ld a, [CurPartyMon] @@ -78,7 +79,7 @@ CheckCanLearnMoveTutorMove: ; 492b9 callfar KnowsMove jr c, .didnt_learn - predef LearnMove + predef Predef_LearnMove ld a, b and a jr z, .didnt_learn @@ -99,5 +100,4 @@ CheckCanLearnMoveTutorMove: ; 492b9 .MenuDataHeader: ; 0x4930a db MENU_BACKUP_TILES ; flags - db 12, 00 ; start coords - db 17, 19 ; end coords + menu_coords 0, 12, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1 diff --git a/engine/events/overworld.asm b/engine/events/overworld.asm index 17ec54bb1..c9e0a5fe5 100755 --- a/engine/events/overworld.asm +++ b/engine/events/overworld.asm @@ -427,7 +427,7 @@ UsedSurfScript: ; c986 end .empty_fn ; c9a2 - farcall TrainerRankings_Surf + farcall StubbedTrainerRankings_Surf ret UsedSurfText: ; c9a9 @@ -623,7 +623,7 @@ FlyFunction: ; ca3b special UpdateTimePals callasm FlyFromAnim farscall Script_AbortBugContest - special WarpToSpawnPoint + special Special_WarpToSpawnPoint callasm DelayLoadingNewSprites writecode VAR_MOVEMENT, PLAYER_NORMAL newloadmap MAPSETUP_FLY @@ -700,7 +700,7 @@ Script_UsedWaterfall: ; 0xcb20 ld a, [PlayerStandingTile] call CheckWaterfallTile ret z - farcall TrainerRankings_Waterfall + farcall StubbedTrainerRankings_Waterfall ld a, $1 ld [ScriptVar], a ret @@ -871,7 +871,7 @@ dig_incave playsound SFX_WARP_TO applymovement PLAYER, .DigOut farscall Script_AbortBugContest - special WarpToSpawnPoint + special Special_WarpToSpawnPoint writecode VAR_MOVEMENT, PLAYER_NORMAL newloadmap MAPSETUP_DOOR playsound SFX_WARP_FROM @@ -958,7 +958,7 @@ TeleportFunction: ; cc61 playsound SFX_WARP_TO applymovement PLAYER, .TeleportFrom farscall Script_AbortBugContest - special WarpToSpawnPoint + special Special_WarpToSpawnPoint writecode VAR_MOVEMENT, PLAYER_NORMAL newloadmap MAPSETUP_TELEPORT playsound SFX_WARP_FROM @@ -986,7 +986,7 @@ StrengthFunction: ; cce5 jr c, .Failed jr .UseStrength -.AlreadyUsing: ; unreferenced +.Unreferenced_AlreadyUsing: ld hl, .JumpText call MenuTextBoxBackup ld a, $80 @@ -1749,7 +1749,7 @@ Script_GetOnBike_Register: ; 0xd14e special ReplaceKrisSprite end -; XXX +; unused nop ret diff --git a/engine/events/poisonstep.asm b/engine/events/poisonstep.asm index 00c7477bc..366ad1c03 100755 --- a/engine/events/poisonstep.asm +++ b/engine/events/poisonstep.asm @@ -104,7 +104,7 @@ DoPoisonStep:: ; 505da ld de, SFX_POISON call PlaySFX ld b, $2 - predef LoadPoisonBGPals + predef Predef_LoadPoisonBGPals call DelayFrame ret ; 50669 @@ -145,7 +145,7 @@ DoPoisonStep:: ; 505da ld a, [PartyCount] cp [hl] jr nz, .party_loop - predef CheckPlayerPartyForFitPkmn + predef Predef_CheckPlayerPartyForFitPkmn ld a, d ld [ScriptVar], a ret diff --git a/engine/events/poisonstep_pals.asm b/engine/events/poisonstep_pals.asm index 498ae8f18..326629138 100644 --- a/engine/events/poisonstep_pals.asm +++ b/engine/events/poisonstep_pals.asm @@ -1,4 +1,4 @@ -LoadPoisonBGPals: ; cbcdd +Predef_LoadPoisonBGPals: ; cbcdd call .LoadPals ld a, [hCGB] and a @@ -10,8 +10,8 @@ LoadPoisonBGPals: ; cbcdd and a jr nz, .cgb ld a, [TimeOfDayPal] - and $3 - cp $3 + maskbits NUM_DAYTIMES +- 1 + cp DARKNESS_F ld a, %00000000 jr z, .convert_pals ld a, %10101010 @@ -26,12 +26,11 @@ LoadPoisonBGPals: ; cbcdd .cgb ld a, [rSVBK] push af - ld a, $5 + ld a, BANK(wBGPals2) ld [rSVBK], a ld hl, wBGPals2 ld c, 4 palettes .loop -; RGB 28, 21, 31 ld a, LOW(palred 28 + palgreen 21 + palblue 31) ld [hli], a ld a, HIGH(palred 28 + palgreen 21 + palblue 31) diff --git a/engine/events/poke_seer.asm b/engine/events/poke_seer.asm index d6e335298..c7e6bd5ee 100644 --- a/engine/events/poke_seer.asm +++ b/engine/events/poke_seer.asm @@ -15,12 +15,12 @@ const SEERACTION_CANT_TELL_2 const SEERACTION_LEVEL_ONLY -SpecialPokeSeer: ; 4f0bc +Special_PokeSeer: ; 4f0bc ld a, SEER_INTRO call PrintSeerText call JoyWaitAorB - ld b, $6 + ld b, PARTY_LENGTH farcall SelectMonFromParty jr c, .cancel @@ -163,11 +163,11 @@ GetCaughtLevel: ; 4f18c call ByteFill ; caught level - ; Limited to between 1 and 63 for some reason. + ; Limited to between 1 and 63 since it's a 6-bit quantity. ld a, [wSeerCaughtData] - and $3f + and CAUGHT_LEVEL_MASK jr z, .unknown - cp 1 ; hatched from an egg + cp CAUGHT_EGG_LEVEL ; egg marker value jr nz, .print ld a, EGG_LEVEL ; egg hatch level @@ -193,7 +193,7 @@ GetCaughtLevel: ; 4f18c GetCaughtTime: ; 4f1c5 ld a, [wSeerCaughtData] - and $c0 + and CAUGHT_TIME_MASK jr z, .none rlca @@ -233,11 +233,11 @@ UnknownCaughtData: ; 4f1f8 GetCaughtLocation: ; 4f20a ld a, [wSeerCaughtGender] - and $7f + and CAUGHT_LOCATION_MASK jr z, .Unknown - cp $7f + cp EVENT_LOCATION jr z, .event - cp $7e + cp GIFT_LOCATION jr z, .fail ld e, a farcall GetLandmarkName @@ -440,22 +440,22 @@ GetCaughtGender: ; 4f301 add hl, bc ld a, [hl] - and $7f + and CAUGHT_LOCATION_MASK jr z, .genderless - cp $7f + cp EVENT_LOCATION jr z, .genderless ld a, [hl] - and $80 + and CAUGHT_GENDER_MASK jr nz, .male - ld c, 1 + ld c, CAUGHT_BY_GIRL ret .male - ld c, 2 + ld c, CAUGHT_BY_BOY ret .genderless - ld c, 0 + ld c, CAUGHT_BY_UNKNOWN ret ; 4f31c diff --git a/engine/events/pokecenter_pc.asm b/engine/events/pokecenter_pc.asm index 5d2dd35df..61d7346df 100755 --- a/engine/events/pokecenter_pc.asm +++ b/engine/events/pokecenter_pc.asm @@ -1,4 +1,4 @@ -PokemonCenterPC: ; 1559a +Special_PokemonCenterPC: ; 1559a call PC_CheckPartyForPokemon ret c call PC_PlayBootSound @@ -28,8 +28,7 @@ PokemonCenterPC: ; 1559a .TopMenu: db MENU_BACKUP_TILES | MENU_NO_CLICK_SFX ; flags - db 00, 00 ; start coords - db 12, 15 ; end coords + menu_coords 0, 0, 15, 12 dw .MenuData2 db 1 ; default option @@ -354,7 +353,7 @@ KrisWithdrawItemMenu: ; 0x157d1 ld [CurItemQuantity], a ld hl, PCItems call TossItem - predef PartyMonItemName + predef Predef_PartyMonItemName ld hl, .WithdrewText call MenuTextBox xor a @@ -421,7 +420,7 @@ KrisDepositItemMenu: ; 0x1588b farcall DepositSellInitPackBuffers .loop farcall DepositSellPack - ld a, [wcf66] + ld a, [wPackUsedItem] and a jr z, .close call .TryDepositItem @@ -518,7 +517,7 @@ KrisDepositItemMenu: ; 0x1588b ld [CurItemQuantity], a ld hl, NumItems call TossItem - predef PartyMonItemName + predef Predef_PartyMonItemName ld hl, .DepositText call PrintText ret @@ -620,9 +619,8 @@ PCItemsJoypad: ; 0x15985 ret .PCItemsMenuData: - db MENU_BACKUP_TILES - db 1, 4 ; start coords - db 10, 18 ; end coords + db MENU_BACKUP_TILES ; flags + menu_coords 4, 1, 18, 10 dw .MenuData2 db 1 ; default option diff --git a/engine/events/pokepic.asm b/engine/events/pokepic.asm index 854e73d01..1a433cb25 100755 --- a/engine/events/pokepic.asm +++ b/engine/events/pokepic.asm @@ -12,7 +12,7 @@ Pokepic:: ; 244e3 ld [CurSpecies], a call GetBaseData ld de, vTiles1 - predef GetMonFrontpic + predef Predef_GetMonFrontpic ld a, [wMenuBorderTopCoord] inc a ld b, a @@ -23,7 +23,7 @@ Pokepic:: ; 244e3 ld a, $80 ld [hGraphicStartTile], a lb bc, 7, 7 - predef PlaceGraphic + predef Predef_PlaceGraphic call WaitBGMap ret @@ -43,7 +43,6 @@ ClosePokepic:: ; 24528 PokepicMenuDataHeader: ; 0x24547 db MENU_BACKUP_TILES ; flags - db 04, 06 ; start coords - db 13, 14 ; end coords + menu_coords 6, 4, 14, 13 dw NULL db 1 ; default option diff --git a/engine/events/print_photo.asm b/engine/events/print_photo.asm index 06b01bbcf..54aa1892d 100755 --- a/engine/events/print_photo.asm +++ b/engine/events/print_photo.asm @@ -1,4 +1,4 @@ -PhotoStudio: ; 16dc7 +Special_PhotoStudio: ; 16dc7 ld hl, .Text_AskWhichMon call PrintText farcall SelectMonFromParty diff --git a/engine/events/print_unown.asm b/engine/events/print_unown.asm index 72248a67b..41f2bab9c 100644 --- a/engine/events/print_unown.asm +++ b/engine/events/print_unown.asm @@ -140,13 +140,13 @@ UnownPrinter: ; 16be4 xor a ld [wBoxAlignment], a ld de, vTiles2 - predef GetMonFrontpic + predef Predef_GetMonFrontpic call .Load2bppToSRAM hlcoord 1, 6 xor a ld [hGraphicStartTile], a lb bc, 7, 7 - predef PlaceGraphic + predef Predef_PlaceGraphic ld de, vTiles2 tile $31 farcall RotateUnownFrontpic ret @@ -154,7 +154,7 @@ UnownPrinter: ; 16be4 .Load2bppToSRAM: ; 16cff ld a, [rSVBK] push af - ld a, $6 + ld a, BANK(wDecompressScratch) ld [rSVBK], a ld a, BANK(sScratch) @@ -178,7 +178,7 @@ UnownPrinter: ; 16be4 hlcoord 1, 9 ld de, UnownDexVacantString call PlaceString - xor a + xor a ; sScratch call GetSRAMBank ld hl, sScratch ld bc, $31 tiles @@ -228,6 +228,6 @@ PlaceUnownPrinterFrontpic: ; 16dac ld a, $31 ld [hGraphicStartTile], a lb bc, 7, 7 - predef PlaceGraphic + predef Predef_PlaceGraphic ret ; 16dc7 diff --git a/engine/events/print_unown_2.asm b/engine/events/print_unown_2.asm index c932ded38..1e0b90fc5 100644 --- a/engine/events/print_unown_2.asm +++ b/engine/events/print_unown_2.asm @@ -1,7 +1,7 @@ RotateUnownFrontpic: ; e0000 ; something to do with Unown printer push de - xor a + xor a ; sScratch call GetSRAMBank ld hl, sScratch ld bc, 0 diff --git a/engine/events/prof_oaks_pc.asm b/engine/events/prof_oaks_pc.asm index 69949940b..ae84a43a5 100755 --- a/engine/events/prof_oaks_pc.asm +++ b/engine/events/prof_oaks_pc.asm @@ -3,7 +3,7 @@ ProfOaksPC: ; 0x265d3 call MenuTextBox call YesNoBox jr c, .shutdown - call ProfOaksPCBoot ; player chose "yes"? + call Special_ProfOaksPCBoot ; player chose "yes"? .shutdown ld hl, OakPCText4 call PrintText @@ -11,7 +11,7 @@ ProfOaksPC: ; 0x265d3 call ExitMenu ret -ProfOaksPCBoot ; 0x265ee +Special_ProfOaksPCBoot ; 0x265ee ld hl, OakPCText2 call PrintText call Rate diff --git a/engine/events/sacred_ash.asm b/engine/events/sacred_ash.asm index cc46eac9f..65ed83438 100755 --- a/engine/events/sacred_ash.asm +++ b/engine/events/sacred_ash.asm @@ -52,12 +52,12 @@ SacredAshScript: ; 0x50821 special HealParty reloadmappart playsound SFX_WARP_TO - special FadeOutPalettes - special FadeInPalettes - special FadeOutPalettes - special FadeInPalettes - special FadeOutPalettes - special FadeInPalettes + special Special_FadeOutPalettes + special Special_FadeInPalettes + special Special_FadeOutPalettes + special Special_FadeInPalettes + special Special_FadeOutPalettes + special Special_FadeInPalettes waitsfx writetext UnknownText_0x50845 playsound SFX_CAUGHT_MON diff --git a/engine/events/special.asm b/engine/events/special.asm index 939db4a25..62e0a620e 100755 --- a/engine/events/special.asm +++ b/engine/events/special.asm @@ -1,4 +1,6 @@ -SpecialGiveShuckle: ; 7305 +MANIA_OT_ID EQU 00518 + +Special_GiveShuckle: ; 7305 ; Adding to the party. xor a @@ -10,7 +12,7 @@ SpecialGiveShuckle: ; 7305 ld a, 15 ld [CurPartyLevel], a - predef TryAddMonToParty + predef Predef_TryAddMonToParty jr nc, .NotGiven ; Caught data. @@ -32,9 +34,9 @@ SpecialGiveShuckle: ; 7305 ; OT ID. ld hl, PartyMon1ID call AddNTimes - ld a, $2 + ld a, HIGH(MANIA_OT_ID) ld [hli], a - ld [hl], $6 + ld [hl], LOW(MANIA_OT_ID) ; Nickname. ld a, [PartyCount] @@ -54,8 +56,7 @@ SpecialGiveShuckle: ; 7305 ; Engine flag for this event. ld hl, wDailyFlags - set 5, [hl] -; setflag ENGINE_SHUCKLE_GIVEN + set 5, [hl] ; ENGINE_SHUCKLE_GIVEN ld a, 1 ld [ScriptVar], a ret @@ -70,7 +71,7 @@ SpecialShuckleOT: SpecialShuckleNick: db "SHUCKIE@" -SpecialReturnShuckle: ; 737e +Special_ReturnShuckle: ; 737e farcall SelectMonFromParty jr c, .refused @@ -85,10 +86,10 @@ SpecialReturnShuckle: ; 737e ; OT ID ld a, [hli] - cp HIGH(00518) + cp HIGH(MANIA_OT_ID) jr nz, .DontReturn ld a, [hl] - cp LOW(00518) + cp LOW(MANIA_OT_ID) jr nz, .DontReturn ; OT @@ -115,28 +116,28 @@ SpecialReturnShuckle: ; 737e call AddNTimes ld a, [hl] cp 150 - ld a, $3 + ld a, SHUCKIE_HAPPY jr nc, .HappyToStayWithYou xor a ; take from pc ld [wPokemonWithdrawDepositParameter], a callfar RemoveMonFromPartyOrBox - ld a, $2 + ld a, SHUCKIE_RETURNED .HappyToStayWithYou: ld [ScriptVar], a ret .refused - ld a, $1 + ld a, SHUCKIE_REFUSED ld [ScriptVar], a ret .DontReturn: - xor a + xor a ; SHUCKIE_WRONG_MON ld [ScriptVar], a ret .fainted - ld a, $4 + ld a, SHUCKIE_FAINTED ld [ScriptVar], a ret @@ -230,6 +231,5 @@ CopyPokemonName_Buffer1_Buffer3: ; 746e ld bc, PKMN_NAME_LENGTH jp CopyBytes -Predef1: ; 747a -; not used +DummyPredef1: ; 747a ret diff --git a/engine/events/std_scripts.asm b/engine/events/std_scripts.asm index 315e80d17..216ce0058 100644 --- a/engine/events/std_scripts.asm +++ b/engine/events/std_scripts.asm @@ -1,4 +1,5 @@ StdScripts:: +; entries correspond to constants/std_constants.asm dba PokecenterNurseScript dba DifficultBookshelfScript dba PictureBookshelfScript @@ -107,13 +108,13 @@ PokecenterNurseScript: farwritetext NurseTakePokemonText pause 20 - special TrainerRankings_Healings + special Special_StubbedTrainerRankings_Healings spriteface LAST_TALKED, LEFT pause 10 special HealParty playmusic MUSIC_NONE - writebyte 0 ; Machine is at a Pokemon Center - special HealMachineAnim + writebyte HEALMACHINE_POKECENTER + special Special_HealMachineAnim pause 30 special RestartMapMusic spriteface LAST_TALKED, DOWN @@ -123,7 +124,7 @@ PokecenterNurseScript: iftrue .no checkflag ENGINE_POKERUS ; nurse already talked about pokerus iftrue .no - special SpecialCheckPokerus + special Special_CheckPokerus iftrue .pokerus .no @@ -203,7 +204,7 @@ HomepageScript: Radio1Script: opentext writebyte MAPRADIO_POKEMON_CHANNEL - special MapRadio + special Special_MapRadio closetext end @@ -211,7 +212,7 @@ Radio2Script: ; Lucky Channel opentext writebyte MAPRADIO_LUCKY_CHANNEL - special MapRadio + special Special_MapRadio closetext end @@ -220,7 +221,7 @@ TrashCanScript: ; 0xbc1a5 PCScript: opentext - special PokemonCenterPC + special Special_PokemonCenterPC closetext end @@ -250,25 +251,25 @@ DayToTextScript: if_equal THURSDAY, .Thursday if_equal FRIDAY, .Friday if_equal SATURDAY, .Saturday - stringtotext .SundayText, 0 + stringtotext .SundayText, MEM_BUFFER_0 end .Monday: - stringtotext .MondayText, 0 + stringtotext .MondayText, MEM_BUFFER_0 end .Tuesday: - stringtotext .TuesdayText, 0 + stringtotext .TuesdayText, MEM_BUFFER_0 end .Wednesday: - stringtotext .WednesdayText, 0 + stringtotext .WednesdayText, MEM_BUFFER_0 end .Thursday: - stringtotext .ThursdayText, 0 + stringtotext .ThursdayText, MEM_BUFFER_0 end .Friday: - stringtotext .FridayText, 0 + stringtotext .FridayText, MEM_BUFFER_0 end .Saturday: - stringtotext .SaturdayText, 0 + stringtotext .SaturdayText, MEM_BUFFER_0 end .SundayText: db "SUNDAY@" @@ -297,7 +298,7 @@ RadioTowerRocketsScript: clearevent EVENT_USED_THE_CARD_KEY_IN_THE_RADIO_TOWER setevent EVENT_MAHOGANY_TOWN_POKEFAN_M_BLOCKS_EAST specialphonecall SPECIALCALL_WEIRDBROADCAST - setmapscene MAHOGANY_TOWN, $1 + setmapscene MAHOGANY_TOWN, 1 end BugContestResultsWarpScript: @@ -306,7 +307,7 @@ BugContestResultsWarpScript: setevent EVENT_ROUTE_36_NATIONAL_PARK_GATE_OFFICER_CONTEST_DAY clearevent EVENT_ROUTE_36_NATIONAL_PARK_GATE_OFFICER_NOT_CONTEST_DAY setevent EVENT_WARPED_FROM_ROUTE_35_NATIONAL_PARK_GATE - warp ROUTE_36_NATIONAL_PARK_GATE, $0, $4 + warp ROUTE_36_NATIONAL_PARK_GATE, 0, 4 applymovement PLAYER, Movement_ContestResults_WalkAfterWarp BugContestResultsScript: @@ -319,8 +320,8 @@ BugContestResultsScript: opentext farwritetext ContestResults_ReadyToJudgeText waitbutton - special BugContestJudging - RAM2MEM $0 + special Special_BugContestJudging + vartomem MEM_BUFFER_0 if_equal 1, BugContestResults_FirstPlace if_equal 2, BugContestResults_SecondPlace if_equal 3, BugContestResults_ThirdPlace @@ -345,17 +346,18 @@ BugContestResults_FinishUp iffalse BugContestResults_DidNotLeaveMons farwritetext ContestResults_ReturnPartyText waitbutton - special ContestReturnMons + special Special_ContestReturnMons BugContestResults_DidNotLeaveMons - special CheckPartyFullAfterContest - if_equal $0, BugContestResults_CleanUp - if_equal $2, BugContestResults_CleanUp + special Special_CheckPartyFullAfterContest + if_equal BUGCONTEST_CAUGHT_MON, BugContestResults_CleanUp + if_equal BUGCONTEST_NO_CATCH, BugContestResults_CleanUp + ; BUGCONTEST_BOXED_MON farwritetext ContestResults_PartyFullText waitbutton BugContestResults_CleanUp closetext - setscene $0 - setmapscene ROUTE_35_NATIONAL_PARK_GATE, $0 + setscene 0 + setmapscene ROUTE_35_NATIONAL_PARK_GATE, 0 setevent EVENT_BUG_CATCHING_CONTESTANT_1A setevent EVENT_BUG_CATCHING_CONTESTANT_2A setevent EVENT_BUG_CATCHING_CONTESTANT_3A @@ -383,7 +385,7 @@ BugContestResults_CleanUp BugContestResults_FirstPlace ; 0xbc31e setevent EVENT_GAVE_KURT_APRICORNS - itemtotext SUN_STONE, $1 + itemtotext SUN_STONE, MEM_BUFFER_1 farwritetext ContestResults_PlayerWonAPrizeText waitbutton verbosegiveitem SUN_STONE @@ -392,7 +394,7 @@ BugContestResults_FirstPlace ; 0xbc31e ; 0xbc332 BugContestResults_SecondPlace ; 0xbc332 - itemtotext EVERSTONE, $1 + itemtotext EVERSTONE, MEM_BUFFER_1 farwritetext ContestResults_PlayerWonAPrizeText waitbutton verbosegiveitem EVERSTONE @@ -401,7 +403,7 @@ BugContestResults_SecondPlace ; 0xbc332 ; 0xbc343 BugContestResults_ThirdPlace ; 0xbc343 - itemtotext GOLD_BERRY, $1 + itemtotext GOLD_BERRY, MEM_BUFFER_1 farwritetext ContestResults_PlayerWonAPrizeText waitbutton verbosegiveitem GOLD_BERRY @@ -620,7 +622,7 @@ InitializeEventsScript: return AskNumber1MScript: - special RandomPhoneMon + special Special_RandomPhoneMon checkcode VAR_CALLERID if_equal PHONE_SCHOOLBOY_JACK, .Jack if_equal PHONE_SAILOR_HUEY, .Huey @@ -705,7 +707,7 @@ AskNumber1MScript: end AskNumber2MScript: - special RandomPhoneMon + special Special_RandomPhoneMon checkcode VAR_CALLERID if_equal PHONE_SCHOOLBOY_JACK, .Jack if_equal PHONE_SAILOR_HUEY, .Huey @@ -1758,7 +1760,7 @@ RematchGiftFScript: end GymStatue1Script: - mapnametotext $0 + mapnametotext MEM_BUFFER_0 opentext farwritetext GymStatue_CityGymText waitbutton @@ -1766,7 +1768,7 @@ GymStatue1Script: end GymStatue2Script: - mapnametotext $0 + mapnametotext MEM_BUFFER_0 opentext farwritetext GymStatue_CityGymText buttonsound @@ -1812,18 +1814,18 @@ CoinVendor_IntroScript: ; 0xbcde0 loadmenudata .MenuDataHeader verticalmenu closewindow - if_equal $1, .Buy50 - if_equal $2, .Buy500 + if_equal 1, .Buy50 + if_equal 2, .Buy500 jump .Cancel ; 0xbcdf7 .Buy50: ; 0xbcdf7 - checkcoins 9949 - if_equal $0, .CoinCaseFull - checkmoney $0, 1000 - if_equal $2, .NotEnoughMoney + checkcoins MAX_COINS - 50 + if_equal HAVE_MORE, .CoinCaseFull + checkmoney YOUR_MONEY, 1000 + if_equal HAVE_LESS, .NotEnoughMoney givecoins 50 - takemoney $0, 1000 + takemoney YOUR_MONEY, 1000 waitsfx playsound SFX_TRANSACTION farwritetext CoinVendor_Buy50CoinsText @@ -1832,12 +1834,12 @@ CoinVendor_IntroScript: ; 0xbcde0 ; 0xbce1b .Buy500: ; 0xbce1b - checkcoins 9499 - if_equal $0, .CoinCaseFull - checkmoney $0, 10000 - if_equal $2, .NotEnoughMoney + checkcoins MAX_COINS - 500 + if_equal HAVE_MORE, .CoinCaseFull + checkmoney YOUR_MONEY, 10000 + if_equal HAVE_LESS, .NotEnoughMoney givecoins 500 - takemoney $0, 10000 + takemoney YOUR_MONEY, 10000 waitsfx playsound SFX_TRANSACTION farwritetext CoinVendor_Buy500CoinsText @@ -1869,8 +1871,7 @@ CoinVendor_IntroScript: ; 0xbcde0 .MenuDataHeader: db MENU_BACKUP_TILES ; flags - db 04, 00 ; start coords - db 11, 15 ; end coords + menu_coords 0, 4, 15, TEXTBOX_Y - 1 dw .MenuData2 db 1 ; default option @@ -1886,7 +1887,7 @@ CoinVendor_IntroScript: ; 0xbcde0 HappinessCheckScript: faceplayer opentext - special GetFirstPokemonHappiness + special Special_GetFirstPokemonHappiness if_less_than 50, .Unhappy if_less_than 150, .KindaHappy farwritetext HappinessText3 diff --git a/engine/events/treemons.asm b/engine/events/treemons.asm new file mode 100755 index 000000000..780fef2cc --- /dev/null +++ b/engine/events/treemons.asm @@ -0,0 +1,285 @@ +TreeMonEncounter: ; b81ea + farcall StubbedTrainerRankings_TreeEncounters + + xor a + ld [TempWildMonSpecies], a + ld [CurPartyLevel], a + + ld hl, TreeMonMaps + 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 [ScriptVar], a + ret + +.no_battle + xor a + ld [ScriptVar], a + ret +; b8219 + +RockMonEncounter: ; b8219 + + xor a + ld [TempWildMonSpecies], a + ld [CurPartyLevel], a + + ld hl, RockMonMaps + call GetTreeMonSet + jr nc, .no_battle + + call GetTreeMons + jr nc, .no_battle + + ; 40% chance of an encounter + ld a, 10 + call RandomRange + cp 4 + jr nc, .no_battle + + call SelectTreeMon + jr nc, .no_battle + + ret + +.no_battle + xor a + ret +; b823e + + db $05 ; ???? + +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 -1 + jr z, .not_in_table + + cp d + jr nz, .skip2 + + ld a, [hli] + cp e + jr nz, .skip1 + + jr .in_table + +.skip2 + inc hl +.skip1 + inc hl + jr .loop + +.not_in_table + xor a + ret + +.in_table + ld a, [hl] + scf + ret +; b825e + +INCLUDE "data/wild/treemon_maps.asm" + +GetTreeMons: ; b82d2 +; Return the address of TreeMon table a in hl. +; Return nc if table a doesn't exist. + + cp NUM_TREEMON_SETS + jr nc, .quit + + and a + jr z, .quit + + ld e, a + ld d, 0 + ld hl, TreeMons + add hl, de + add hl, de + + ld a, [hli] + ld h, [hl] + ld l, a + + scf + ret + +.quit + xor a + ret +; b82e8 + +INCLUDE "data/wild/treemons.asm" + +GetTreeMon: ; b83e5 + push hl + call GetTreeScore + pop hl + and a ; TREEMON_SCORE_BAD + jr z, .bad + cp TREEMON_SCORE_GOOD + jr z, .good + cp TREEMON_SCORE_RARE + jr z, .rare + ret + +.bad + ; 10% chance of an encounter + ld a, 10 + call RandomRange + and a + jr nz, NoTreeMon + jr SelectTreeMon + +.good + ; 50% chance of an encounter + ld a, 10 + call RandomRange + cp 5 + jr nc, NoTreeMon + jr SelectTreeMon + +.rare + ; 80% chance of an encounter + ld a, 10 + call RandomRange + cp 8 + jr nc, NoTreeMon + jr .skip +.skip + ld a, [hli] + cp -1 + jr nz, .skip + call SelectTreeMon + ret +; b841f + +SelectTreeMon: ; b841f +; Read a TreeMons table and pick one monster at random. + + ld a, 100 + call RandomRange +.loop + sub [hl] + jr c, .ok + inc hl + inc hl + inc hl + jr .loop + +.ok + ld a, [hli] + cp -1 + jr z, NoTreeMon + + ld a, [hli] + ld [TempWildMonSpecies], a + ld a, [hl] + ld [CurPartyLevel], a + scf + ret + +NoTreeMon: ; b843b + xor a + ld [TempWildMonSpecies], a + ld [CurPartyLevel], a + ret +; b8443 + +GetTreeScore: ; b8443 + call .CoordScore + ld [Buffer1], a + call .OTIDScore + ld [Buffer2], a + ld c, a + ld a, [Buffer1] + sub c + jr z, .rare + jr nc, .ok + add 10 +.ok + cp 5 + jr c, .good + +.bad + xor a ; TREEMON_SCORE_BAD + ret + +.good + ld a, TREEMON_SCORE_GOOD + ret + +.rare + ld a, TREEMON_SCORE_RARE + ret +; b8466 + +.CoordScore: ; b8466 + call GetFacingTileCoord + ld hl, 0 + ld c, e + ld b, 0 + ld a, d + + and a + jr z, .next +.loop + add hl, bc + dec a + jr nz, .loop +.next + + add hl, bc + ld c, d + add hl, bc + + ld a, h + ld [hDividend], a + ld a, l + ld [hDividend + 1], a + ld a, 5 + ld [hDivisor], a + ld b, 2 + call Divide + + ld a, [hQuotient + 1] + ld [hDividend], a + ld a, [hQuotient + 2] + ld [hDividend + 1], a + ld a, 10 + ld [hDivisor], a + ld b, 2 + call Divide + + ld a, [hQuotient + 3] + ret +; b849d + +.OTIDScore: ; b849d + ld a, [PlayerID] + ld [hDividend], a + ld a, [PlayerID + 1] + ld [hDividend + 1], a + ld a, 10 + ld [hDivisor], a + ld b, 2 + call Divide + ld a, [hQuotient + 3] + ret +; b84b3 diff --git a/engine/events/crystal_unown.asm b/engine/events/unown_walls.asm index 54196498b..af7e80bf0 100644 --- a/engine/events/crystal_unown.asm +++ b/engine/events/unown_walls.asm @@ -1,4 +1,4 @@ -SpecialHoOhChamber: ; 0x8addb +Special_HoOhChamber: ; 0x8addb ld hl, PartySpecies ld a, [hl] cp HO_OH ; is Ho-oh the first Pokémon in the party? @@ -11,7 +11,7 @@ SpecialHoOhChamber: ; 0x8addb ret ; 0x8adef -SpecialOmanyteChamber: ; 8adef +Special_OmanyteChamber: ; 8adef call GetSecondaryMapHeaderPointer ld de, EVENT_WALL_OPENED_IN_OMANYTE_CHAMBER ld b, CHECK_FLAG @@ -105,7 +105,7 @@ SpecialKabutoChamber: ; 8ae4e Special_DisplayUnownWords: ; 8ae68 ld a, [ScriptVar] - ld hl, .MenuDataHeaders_UnownWalls + ld hl, MenuDataHeaders_UnownWalls and a jr z, .load @@ -131,21 +131,21 @@ Special_DisplayUnownWords: ; 8ae68 add hl, de ld a, [ScriptVar] ld c, a - ld de, .UnownText + ld de, UnownWalls and a jr z, .copy .loop2 ld a, [de] inc de - cp $ff + cp -1 jr nz, .loop2 dec c jr nz, .loop2 .copy - call .CopyWord + call _DisplayUnownWords_CopyWord ld bc, AttrMap - TileMap add hl, bc - call .FillAttr + call _DisplayUnownWords_FillAttr call WaitBGMap2 call JoyWaitAorB call PlayClickSFX @@ -153,66 +153,9 @@ Special_DisplayUnownWords: ; 8ae68 ret ; 8aebc -unownwall: MACRO -rept _NARG -if \1 == "-" -x = $64 -else -if \1 >= "Y" -x = 2 * (\1 - "Y") + $60 -else -if \1 >= "Q" -x = 2 * (\1 - "Q") + $40 -else -if \1 >= "I" -x = 2 * (\1 - "I") + $20 -else -x = 2 * (\1 - "A") -endc -endc -endc -endc - db x -shift -endr - db $ff -ENDM - -.UnownText: ; 8aebc -;.UnownText_Escape: - ; db $08, $44, $04, $00, $2e, $08, $ff - unownwall "E", "S", "C", "A", "P", "E" -;.UnownText_Light: - ; db $26, $20, $0c, $0e, $46, $ff - unownwall "L", "I", "G", "H", "T" -;.UnownText_Water: - ; db $4c, $00, $46, $08, $42, $ff - unownwall "W", "A", "T", "E", "R" -;.UnownText_Ho_Oh: - ; db $0e, $2c, $64, $2c, $0e, $ff - unownwall "H", "O", "-", "O", "H" -; 8aed5 - -.MenuDataHeaders_UnownWalls: ; 0x8aed5 -;.MenuDataHeader_Escape: - db MENU_BACKUP_TILES ; flags - db 04, 03 ; start coords - db 09, 16 ; end coords -;.MenuDataHeader_Light: - db MENU_BACKUP_TILES ; flags - db 04, 04 ; start coords - db 09, 15 ; end coords -;.MenuDataHeader_Water: - db MENU_BACKUP_TILES ; flags - db 04, 04 ; start coords - db 09, 15 ; end coords -;.MenuDataHeader_Ho_Oh: - db MENU_BACKUP_TILES ; flags - db 04, 04 ; start coords - db 09, 15 ; end coords -; 8aee9 +INCLUDE "data/unown_walls.asm" -.FillAttr: ; 8aee9 +_DisplayUnownWords_FillAttr: ; 8aee9 ld a, [de] cp $ff ret z @@ -226,7 +169,7 @@ ENDM inc hl inc hl inc de - jr .FillAttr + jr _DisplayUnownWords_FillAttr ; 8aefd .PlaceSquare: ; 8aefd @@ -242,7 +185,7 @@ ENDM ret ; 8af09 -.CopyWord: ; 8af09 +_DisplayUnownWords_CopyWord: ; 8af09 push hl push de .word_loop diff --git a/engine/events/whiteout.asm b/engine/events/whiteout.asm index a9d6f900e..aa629682f 100755 --- a/engine/events/whiteout.asm +++ b/engine/events/whiteout.asm @@ -4,13 +4,13 @@ Script_BattleWhiteout:: ; 0x124c1 ; 0x124c8 Script_OverworldWhiteout:: ; 0x124c8 - refreshscreen $0 + refreshscreen callasm OverworldBGMap Script_Whiteout: ; 0x124ce writetext .WhitedOutText waitbutton - special FadeOutPalettes + special Special_FadeOutPalettes pause 40 special HealParty checkflag ENGINE_BUG_CONTEST_TIMER @@ -18,7 +18,7 @@ Script_Whiteout: ; 0x124ce callasm HalveMoney callasm GetWhiteoutSpawn farscall Script_AbortBugContest - special WarpToSpawnPoint + special Special_WarpToSpawnPoint newloadmap MAPSETUP_WARP end_all @@ -49,7 +49,7 @@ BattleBGMap: ; 1250a ; 12513 HalveMoney: ; 12513 - farcall TrainerRankings_WhiteOuts + farcall StubbedTrainerRankings_WhiteOuts ; Halve the player's money. ld hl, Money diff --git a/engine/events_2.asm b/engine/events_2.asm index cac736bab..e4458d9aa 100644 --- a/engine/events_2.asm +++ b/engine/events_2.asm @@ -1,7 +1,7 @@ ; More overworld event handling. -WarpToSpawnPoint:: ; 97c28 +Special_WarpToSpawnPoint:: ; 97c28 ld hl, wStatusFlags2 res 1, [hl] ; safari zone? res 2, [hl] ; bug contest @@ -361,7 +361,7 @@ HandleCmdQueue:: ; 97e08 ret ; 97e25 -GetNthCmdQueueEntry: ; 97e25 unreferenced +Unreferenced_GetNthCmdQueueEntry: ; 97e25 ld hl, wCmdQueue ld bc, CMDQUEUE_ENTRY_SIZE call AddNTimes diff --git a/engine/events_3.asm b/engine/events_3.asm deleted file mode 100755 index 5ee113a95..000000000 --- a/engine/events_3.asm +++ /dev/null @@ -1,689 +0,0 @@ -ReturnFromMapSetupScript:: ; b8000 - xor a - ld [hBGMapMode], a - ; For some reson, GameFreak chose to use a farcall here instead of just falling through. - ; No other function in the game references the function at 2E:400A, here labeled - ; ReturnFromMapSetupScript.inefficient_farcall. - farcall .inefficient_farcall ; this is a waste of 6 ROM bytes and 6 stack bytes - ret -; b800a - -.inefficient_farcall ; b800a - ld a, [MapGroup] - ld b, a - ld a, [MapNumber] - ld c, a - call GetWorldMapLocation - ld [wCurrentLandmark], a - call .CheckNationalParkGate - jr z, .nationalparkgate - - call GetMapEnvironment - cp GATE - jr nz, .not_gate - -.nationalparkgate - ld a, -1 - ld [wCurrentLandmark], a - -.not_gate - ld hl, wEnteredMapFromContinue - bit 1, [hl] - res 1, [hl] - jr nz, .dont_do_map_sign - - call .CheckMovingWithinLandmark - jr z, .dont_do_map_sign - ld a, [wCurrentLandmark] - ld [wPreviousLandmark], a - - call .CheckSpecialMap - jr z, .dont_do_map_sign - -; Display for 60 frames - ld a, 60 - ld [wLandmarkSignTimer], a - call LoadMapNameSignGFX - call InitMapNameFrame - farcall HDMATransfer_OnlyTopFourRows - ret - -.dont_do_map_sign - ld a, [wCurrentLandmark] - ld [wPreviousLandmark], a - ld a, $90 - ld [rWY], a - ld [hWY], a - xor a - ld [hLCDCPointer], a - ret -; b8064 - -.CheckMovingWithinLandmark: ; b8064 - ld a, [wCurrentLandmark] - ld c, a - ld a, [wPreviousLandmark] - cp c - ret z - cp SPECIAL_MAP - ret -; b8070 - -.CheckSpecialMap: ; b8070 - cp -1 - ret z - cp SPECIAL_MAP - ret z - cp RADIO_TOWER - ret z - cp LAV_RADIO_TOWER - ret z - cp UNDERGROUND_PATH - ret z - cp INDIGO_PLATEAU - ret z - cp POWER_PLANT - ret z - ld a, $1 - and a - ret -; b8089 - -.CheckNationalParkGate: ; b8089 - ld a, [MapGroup] - cp GROUP_ROUTE_35_NATIONAL_PARK_GATE - ret nz - ld a, [MapNumber] - cp MAP_ROUTE_35_NATIONAL_PARK_GATE - ret z - cp MAP_ROUTE_36_NATIONAL_PARK_GATE - ret -; b8098 - - -PlaceMapNameSign:: ; b8098 (2e:4098) - ld hl, wLandmarkSignTimer - ld a, [hl] - and a - jr z, .disappear - dec [hl] - cp 60 - ret z - cp 59 - jr nz, .skip2 - call InitMapNameFrame - call PlaceMapNameCenterAlign - farcall HDMATransfer_OnlyTopFourRows -.skip2 - ld a, $80 - ld a, $70 - ld [rWY], a - ld [hWY], a - ret - -.disappear - ld a, $90 - ld [rWY], a - ld [hWY], a - xor a - ld [hLCDCPointer], a - ret - - -LoadMapNameSignGFX: ; b80c6 - ld de, MapEntryFrameGFX - ld hl, vTiles2 tile $60 - lb bc, BANK(MapEntryFrameGFX), $e - call Get2bpp - ret -; b80d3 - -InitMapNameFrame: ; b80d3 - hlcoord 0, 0 - ld b, 2 - ld c, 18 - call InitMapSignAttrMap - call PlaceMapNameFrame - ret -; b80e1 - - -PlaceMapNameCenterAlign: ; b80e1 (2e:40e1) - ld a, [wCurrentLandmark] - ld e, a - farcall GetLandmarkName - call .GetNameLength - ld a, SCREEN_WIDTH - sub c - srl a - ld b, $0 - ld c, a - hlcoord 0, 2 - add hl, bc - ld de, StringBuffer1 - call PlaceString - ret - -.GetNameLength: ; b8101 (2e:4101) - ld c, 0 - push hl - ld hl, StringBuffer1 -.loop - ld a, [hli] - cp "@" - jr z, .stop - cp "%" - jr z, .loop - inc c - jr .loop -.stop - pop hl - ret - - -InitMapSignAttrMap: ; b8115 - ld de, AttrMap - TileMap - add hl, de - inc b - inc b - inc c - inc c - ld a, $87 -.loop - push bc - push hl -.inner_loop - ld [hli], a - dec c - jr nz, .inner_loop - pop hl - ld de, SCREEN_WIDTH - add hl, de - pop bc - dec b - jr nz, .loop - ret -; b812f - -PlaceMapNameFrame: ; b812f - hlcoord 0, 0 - ; top left - ld a, $61 - ld [hli], a - ; top row - ld a, $62 - call .FillTopBottom - ; top right - ld a, $64 - ld [hli], a - ; left, first line - ld a, $65 - ld [hli], a - ; first line - call .FillMiddle - ; right, first line - ld a, $6b - ld [hli], a - ; left, second line - ld a, $66 - ld [hli], a - ; second line - call .FillMiddle - ; right, second line - ld a, $6c - ld [hli], a - ; bottom left - ld a, $67 - ld [hli], a - ; bottom - ld a, $68 - call .FillTopBottom - ; bottom right - ld a, $6a - ld [hl], a - ret -; b815b - -.FillMiddle: ; b815b - ld c, 18 - ld a, $6d -.loop - ld [hli], a - dec c - jr nz, .loop - ret -; b8164 - -.FillTopBottom: ; b8164 - ld c, 5 - jr .enterloop - -.continueloop - ld [hli], a - ld [hli], a - -.enterloop - inc a - ld [hli], a - ld [hli], a - dec a - dec c - jr nz, .continueloop - ret -; b8172 - -CheckForHiddenItems: ; b8172 -; Checks to see if there are hidden items on the screen that have not yet been found. If it finds one, returns carry. - call GetMapScriptHeaderBank - ld [Buffer1], a -; Get the coordinate of the bottom right corner of the screen, and load it in Buffer3/Buffer4. - ld a, [XCoord] - add SCREEN_WIDTH / 4 - ld [Buffer4], a - ld a, [YCoord] - add SCREEN_HEIGHT / 4 - ld [Buffer3], a -; Get the pointer for the first BG event header in the map... - ld hl, wCurrMapBGEventHeaderPointer - ld a, [hli] - ld h, [hl] - ld l, a -; ... before even checking to see if there are any BG events on this map. - ld a, [wCurrMapBGEventCount] - and a - jr z, .nobgeventitems -; For i = 1:wCurrMapBGEventCount... -.loop -; Store the counter in Buffer2, and store the BG event header pointer in the stack. - ld [Buffer2], a - push hl -; Get the Y coordinate of the BG event. - call .GetFarByte - ld e, a -; Is the Y coordinate of the BG event on the screen? If not, go to the next BG event. - ld a, [Buffer3] - sub e - jr c, .next - cp SCREEN_HEIGHT / 2 - jr nc, .next -; Is the X coordinate of the BG event on the screen? If not, go to the next BG event. - call .GetFarByte - ld d, a - ld a, [Buffer4] - sub d - jr c, .next - cp SCREEN_WIDTH / 2 - jr nc, .next -; Is this BG event a hidden item? If not, go to the next BG event. - call .GetFarByte - cp BGEVENT_ITEM - jr nz, .next -; Has this item already been found? If not, set off the Itemfinder. - ld a, [Buffer1] - call GetFarHalfword - ld a, [Buffer1] - call GetFarHalfword - ld d, h - ld e, l - ld b, CHECK_FLAG - call EventFlagAction - ld a, c - and a - jr z, .itemnearby - -.next -; Restore the BG event header pointer and increment it by the length of a BG event header. - pop hl - ld bc, 5 - add hl, bc -; Restore the BG event counter and decrement it. If it hits zero, there are no hidden items in range. - ld a, [Buffer2] - dec a - jr nz, .loop - -.nobgeventitems - xor a - ret - -.itemnearby - pop hl - scf - ret -; b81e2 - -.GetFarByte: ; b81e2 - ld a, [Buffer1] - call GetFarByte - inc hl - ret -; b81ea - - -TreeMonEncounter: ; b81ea - farcall TrainerRankings_TreeEncounters - - xor a - ld [TempWildMonSpecies], a - ld [CurPartyLevel], a - - ld hl, TreeMonMaps - 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 [ScriptVar], a - ret - -.no_battle - xor a - ld [ScriptVar], a - ret -; b8219 - -RockMonEncounter: ; b8219 - - xor a - ld [TempWildMonSpecies], a - ld [CurPartyLevel], a - - ld hl, RockMonMaps - call GetTreeMonSet - jr nc, .no_battle - - call GetTreeMons - jr nc, .no_battle - - ld a, 10 - call RandomRange - cp 4 - jr nc, .no_battle - - call SelectTreeMon - jr nc, .no_battle - - ret - -.no_battle - xor a - ret -; b823e - - db $05 ; ???? - -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 -1 - jr z, .not_in_table - - cp d - jr nz, .skip2 - - ld a, [hli] - cp e - jr nz, .skip1 - - jr .in_table - -.skip2 - inc hl -.skip1 - inc hl - jr .loop - -.not_in_table - xor a - ret - -.in_table - ld a, [hl] - scf - ret -; b825e - -INCLUDE "data/wild/treemon_maps.asm" - -GetTreeMons: ; b82d2 -; Return the address of TreeMon table a in hl. -; Return nc if table a doesn't exist. - - cp 8 - jr nc, .quit - - and a - jr z, .quit - - ld e, a - ld d, 0 - ld hl, TreeMons - add hl, de - add hl, de - - ld a, [hli] - ld h, [hl] - ld l, a - - scf - ret - -.quit - xor a - ret -; b82e8 - -INCLUDE "data/wild/treemons.asm" - -GetTreeMon: ; b83e5 - push hl - call GetTreeScore - pop hl - and a - jr z, .bad - cp 1 - jr z, .good - cp 2 - jr z, .rare - ret - -.bad - ld a, 10 - call RandomRange - and a - jr nz, NoTreeMon - jr SelectTreeMon - -.good - ld a, 10 - call RandomRange - cp 5 - jr nc, NoTreeMon - jr SelectTreeMon - -.rare - ld a, 10 - call RandomRange - cp 8 - jr nc, NoTreeMon - jr .skip -.skip - ld a, [hli] - cp -1 - jr nz, .skip - call SelectTreeMon - ret -; b841f - -SelectTreeMon: ; b841f -; Read a TreeMons table and pick one monster at random. - - ld a, 100 - call RandomRange -.loop - sub [hl] - jr c, .ok - inc hl - inc hl - inc hl - jr .loop - -.ok - ld a, [hli] - cp $ff - jr z, NoTreeMon - - ld a, [hli] - ld [TempWildMonSpecies], a - ld a, [hl] - ld [CurPartyLevel], a - scf - ret - -NoTreeMon: ; b843b - xor a - ld [TempWildMonSpecies], a - ld [CurPartyLevel], a - ret -; b8443 - -GetTreeScore: ; b8443 - call .CoordScore - ld [Buffer1], a - call .OTIDScore - ld [Buffer2], a - ld c, a - ld a, [Buffer1] - sub c - jr z, .rare - jr nc, .ok - add 10 -.ok - cp 5 - jr c, .good - -.bad - xor a - ret - -.good - ld a, 1 - ret - -.rare - ld a, 2 - ret -; b8466 - -.CoordScore: ; b8466 - call GetFacingTileCoord - ld hl, 0 - ld c, e - ld b, 0 - ld a, d - - and a - jr z, .next -.loop - add hl, bc - dec a - jr nz, .loop -.next - - add hl, bc - ld c, d - add hl, bc - - ld a, h - ld [hDividend], a - ld a, l - ld [hDividend + 1], a - ld a, 5 - ld [hDivisor], a - ld b, 2 - call Divide - - ld a, [hQuotient + 1] - ld [hDividend], a - ld a, [hQuotient + 2] - ld [hDividend + 1], a - ld a, 10 - ld [hDivisor], a - ld b, 2 - call Divide - - ld a, [hQuotient + 3] - ret -; b849d - -.OTIDScore: ; b849d - ld a, [PlayerID] - ld [hDividend], a - ld a, [PlayerID + 1] - ld [hDividend + 1], a - ld a, 10 - ld [hDivisor], a - ld b, 2 - call Divide - ld a, [hQuotient + 3] - ret -; b84b3 - -LoadFishingGFX: ; b84b3 - ld a, [rVBK] - push af - ld a, $1 - ld [rVBK], a - - ld de, FishingGFX - ld a, [wPlayerGender] - bit 0, a - jr z, .got_gender - ld de, KrisFishingGFX -.got_gender - - ld hl, vTiles0 tile $02 - call .LoadGFX - ld hl, vTiles0 tile $06 - call .LoadGFX - ld hl, vTiles0 tile $0a - call .LoadGFX - ld hl, vTiles1 tile $7c - call .LoadGFX - - pop af - ld [rVBK], a - ret -; b84e3 - -.LoadGFX: ; b84e3 - lb bc, BANK(FishingGFX), 2 - push de - call Get2bpp - pop de - ld hl, 2 tiles - add hl, de - ld d, h - ld e, l - ret -; b84f2 - -FishingGFX: ; b84f2 -INCBIN "gfx/overworld/chris_fish.2bpp" -; b8582 - -KrisFishingGFX: ; b8582 -INCBIN "gfx/overworld/kris_fish.2bpp" -; b8612 diff --git a/engine/evolution_animation.asm b/engine/evolution_animation.asm index 1fa55c10a..365f4e729 100755 --- a/engine/evolution_animation.asm +++ b/engine/evolution_animation.asm @@ -122,7 +122,7 @@ EvolutionAnimation: ; 4e5e1 hlcoord 7, 2 ld d, $0 ld e, ANIM_MON_EVOLVE - predef AnimateFrontpic + predef Predef_AnimateFrontpic pop af ld [CurPartySpecies], a @@ -168,7 +168,7 @@ EvolutionAnimation: ; 4e5e1 ld a, $1 ld [wBoxAlignment], a ld de, vTiles2 - predef GetAnimatedFrontpicPredef + predef Predef_GetAnimatedFrontpic xor a ld [wBoxAlignment], a ret @@ -346,15 +346,15 @@ EvolutionAnimation: ; 4e5e1 inc a and $7 ld b, a - ld hl, Sprites + 3 ; attributes - ld c, 40 + ld hl, Sprite01Attributes + ld c, NUM_SPRITE_OAM_STRUCTS .loop6 ld a, [hl] or b - ld [hli], a - inc hl - inc hl + ld [hli], a ; attributes +rept SPRITEOAMSTRUCT_LENGTH +- 1 inc hl +endr dec c jr nz, .loop6 pop bc diff --git a/engine/evolve.asm b/engine/evolve.asm index c335229d6..877dd9031 100755 --- a/engine/evolve.asm +++ b/engine/evolve.asm @@ -6,7 +6,7 @@ EvolvePokemon: ; 421d8 ld c, a ld b, SET_FLAG call EvoFlagAction -EvolveAfterBattle: ; 421e6 +Predef_EvolveAfterBattle: ; 421e6 xor a ld [wMonTriedToEvolve], a dec a @@ -55,7 +55,7 @@ EvolveAfterBattle_MasterLoop push hl xor a ld [MonType], a - predef CopyPkmnToTempMon + predef Predef_CopyPkmnToTempMon pop hl .loop @@ -247,7 +247,7 @@ EvolveAfterBattle_MasterLoop push hl ld hl, Text_EvolvedIntoPKMN call PrintTextBoxText - farcall TrainerRankings_MonsEvolved + farcall StubbedTrainerRankings_MonsEvolved ld de, MUSIC_NONE call PlayMusic @@ -265,7 +265,7 @@ EvolveAfterBattle_MasterLoop ld hl, TempMonExp + 2 ld de, TempMonMaxHP ld b, $1 - predef CalcPkmnStats + predef Predef_CalcPkmnStats ld a, [CurPartyMon] ld hl, PartyMons @@ -301,7 +301,7 @@ EvolveAfterBattle_MasterLoop ld [wd265], a xor a ld [MonType], a - call LearnLevelMoves + call Predef_LearnLevelMoves ld a, [wd265] dec a call SetSeenAndCaughtMon @@ -311,7 +311,7 @@ EvolveAfterBattle_MasterLoop jr nz, .skip_unown ld hl, TempMonDVs - predef GetUnownLetter + predef Predef_GetUnownLetter callfar UpdateUnownDex .skip_unown @@ -333,7 +333,7 @@ EvolveAfterBattle_MasterLoop inc hl jp .loop -; XXX +; unused pop hl .ReturnToMap: pop de @@ -429,7 +429,7 @@ Text_WhatEvolving: ; 0x42482 ; 0x42487 -LearnLevelMoves: ; 42487 +Predef_LearnLevelMoves: ; 42487 ld a, [wd265] ld [CurPartySpecies], a dec a @@ -484,7 +484,7 @@ LearnLevelMoves: ; 42487 ld [wd265], a call GetMoveName call CopyName1 - predef LearnMove + predef Predef_LearnMove pop hl jr .find_move @@ -495,7 +495,7 @@ LearnLevelMoves: ; 42487 ; 424e1 -FillMoves: ; 424e1 +Predef_FillMoves: ; 424e1 ; Fill in moves at de for CurPartySpecies at CurPartyLevel push hl @@ -621,7 +621,7 @@ ShiftMoves: ; 4256e EvoFlagAction: ; 42577 push de ld d, $0 - predef FlagPredef + predef Predef_SmallFarFlagAction pop de ret ; 42581 diff --git a/engine/gbc_only.asm b/engine/gbc_only.asm index efceae701..b2207d436 100644 --- a/engine/gbc_only.asm +++ b/engine/gbc_only.asm @@ -10,16 +10,16 @@ GBCOnlyScreen: ; 4ea82 call ClearTileMap ld hl, GBCOnlyGFX - ld de, $d000 + ld de, wd000 ld a, [rSVBK] push af - ld a, 0 + ld a, 0 ; this has the same effect as selecting bank 1 (http://gbdev.gg8.se/files/docs/mirrors/pandocs.html#videodisplay) ld [rSVBK], a call Decompress pop af ld [rSVBK], a - ld de, $d000 + ld de, wd000 ld hl, vTiles2 lb bc, BANK(GBCOnlyGFX), $54 call Get2bpp diff --git a/engine/health.asm b/engine/health.asm index 0f7ba156d..eba75ddf4 100755 --- a/engine/health.asm +++ b/engine/health.asm @@ -52,7 +52,7 @@ HealPartyMon: ; c677 farcall RestoreAllPP ret -ComputeHPBarPixels: ; c699 +Predef_ComputeHPBarPixels: ; c699 ; e = bc * (6 * 8) / de ld a, b or c @@ -103,7 +103,7 @@ ComputeHPBarPixels: ; c699 ld e, 0 ret -AnimateHPBar: ; c6e0 +Predef_AnimateHPBar: ; c6e0 call WaitBGMap call _AnimateHPBar call WaitBGMap diff --git a/engine/init_gender.asm b/engine/init_gender.asm index 92be6c371..540a0b63f 100755 --- a/engine/init_gender.asm +++ b/engine/init_gender.asm @@ -45,8 +45,7 @@ InitGender: ; 48dcb (12:4dcb) .MenuDataHeader: ; 0x48dfc db MENU_BACKUP_TILES ; flags - db 04, 06 ; start coords - db 09, 12 ; end coords + menu_coords 6, 4, 12, 9 dw .MenuData2 db 1 ; default option ; 0x48e04 @@ -90,17 +89,14 @@ LoadGenderScreenPal: ; 48e47 (12:4e47) ld hl, .Palette ld de, wBGPals1 ld bc, 1 palettes - ld a, $5 + ld a, BANK(wBGPals1) call FarCopyWRAM farcall ApplyPals ret ; 48e5c (12:4e5c) .Palette: ; 48e5c - RGB 31, 31, 31 - RGB 09, 30, 31 - RGB 01, 11, 31 - RGB 00, 00, 00 +INCLUDE "gfx/intro/gender_screen.pal" ; 48e64 LoadGenderScreenLightBlueTile: ; 48e64 (12:4e64) diff --git a/engine/init_hof_credits.asm b/engine/init_hof_credits.asm index 8e3db75eb..e72ae011c 100644 --- a/engine/init_hof_credits.asm +++ b/engine/init_hof_credits.asm @@ -63,7 +63,7 @@ InitDisplayForRedCredits: ; 4e8c2 ResetDisplayBetweenHallOfFameMons: ; 4e906 ld a, [rSVBK] push af - ld a, $6 + ld a, BANK(wDecompressScratch) ld [rSVBK], a ld hl, wDecompressScratch ld bc, wScratchAttrMap - wDecompressScratch diff --git a/engine/init_map.asm b/engine/init_map.asm index e5bee971d..e1b6b9ab9 100644 --- a/engine/init_map.asm +++ b/engine/init_map.asm @@ -79,7 +79,7 @@ LoadFonts_NoOAMUpdate:: ; 64bf HDMATransfer_FillBGMap0WithBlack: ; 64db ld a, [rSVBK] push af - ld a, $6 + ld a, BANK(wDecompressScratch) ld [rSVBK], a ld a, "<BLACK>" ; $60 diff --git a/engine/intro_menu.asm b/engine/intro_menu.asm index a91327b1c..fa9cd1a92 100755 --- a/engine/intro_menu.asm +++ b/engine/intro_menu.asm @@ -10,7 +10,7 @@ _MainMenu: ; 5ae8 jp StartTitleScreen ; 5b04 -; unreferenced +; unused ret ; 5b05 @@ -554,8 +554,7 @@ Continue_LoadMenuHeader: ; 5ebf .MenuDataHeader_Dex: ; 5ed9 db MENU_BACKUP_TILES ; flags - db 00, 00 ; start coords - db 09, 15 ; end coords + menu_coords 0, 0, 15, 9 dw .MenuData2_Dex db 1 ; default option ; 5ee1 @@ -571,8 +570,7 @@ Continue_LoadMenuHeader: ; 5ebf .MenuDataHeader_NoDex: ; 5efb db MENU_BACKUP_TILES ; flags - db 00, 00 ; start coords - db 09, 15 ; end coords + menu_coords 0, 0, 15, 9 dw .MenuData2_NoDex db 1 ; default option ; 5f03 @@ -827,7 +825,7 @@ NamePlayer: ; 0x6074 db "KRIS@@@@@@@" ; 60e9 -Function60e9: ; Unreferenced +Unreferenced_Function60e9: call LoadMenuDataHeader call VerticalMenu ld a, [wMenuCursorY] @@ -853,7 +851,7 @@ ShrinkPlayer: ; 610f ld a, [hROMBank] push af - ld a, 0 << 7 | 32 ; fade out + ld a, 32 ; fade time ld [MusicFade], a ld de, MUSIC_NONE ld a, e @@ -943,24 +941,24 @@ Intro_WipeInFrontpic: ; 6182 Intro_PrepTrainerPic: ; 619c ld de, vTiles2 - farcall GetTrainerPic + farcall Predef_GetTrainerPic xor a ld [hGraphicStartTile], a hlcoord 6, 4 lb bc, 7, 7 - predef PlaceGraphic + predef Predef_PlaceGraphic ret ; 61b4 ShrinkFrame: ; 61b4 ld de, vTiles2 ld c, $31 - predef DecompressPredef + predef Predef_Decompress xor a ld [hGraphicStartTile], a hlcoord 6, 4 lb bc, 7, 7 - predef PlaceGraphic + predef Predef_PlaceGraphic ret ; 61cd @@ -971,7 +969,7 @@ Intro_PlacePlayerSprite: ; 61cd ld hl, vTiles0 call Request2bpp - ld hl, Sprites + ld hl, Sprite01 ld de, .sprites ld a, [de] inc de @@ -980,19 +978,19 @@ Intro_PlacePlayerSprite: ; 61cd .loop ld a, [de] inc de - ld [hli], a + ld [hli], a ; y ld a, [de] inc de - ld [hli], a + ld [hli], a ; x ld a, [de] inc de - ld [hli], a + ld [hli], a ; tile id - ld b, 0 + ld b, PAL_OW_RED ld a, [wPlayerGender] bit 0, a jr z, .male - ld b, 1 + ld b, PAL_OW_BLUE .male ld a, b @@ -1004,6 +1002,7 @@ Intro_PlacePlayerSprite: ; 61cd .sprites ; 61fe db 4 + ; y pxl, x pxl, tile offset db 9 * 8 + 4, 9 * 8, 0 db 9 * 8 + 4, 10 * 8, 1 db 10 * 8 + 4, 9 * 8, 2 @@ -1019,7 +1018,7 @@ CrystalIntroSequence: ; 620b StartTitleScreen: ; 6219 ld a, [rSVBK] push af - ld a, $5 + ld a, BANK(wBGPals1) ld [rSVBK], a call .TitleScreen @@ -1094,7 +1093,7 @@ RunTitleScreen: ; 627b ret ; 6292 -Function6292: ; 6292 ; unreferenced +Unreferenced_Function6292: ; 6292 ld a, [hVBlankCounter] and $7 ret nz @@ -1125,7 +1124,7 @@ TitleScreenScene: ; 62a3 dw TitleScreenEnd ; 62b7 -.NextScene: ; Unreferenced +.Unreferenced_NextScene: ld hl, wJumptableIndex inc [hl] ret @@ -1329,10 +1328,10 @@ ResetClock: ; 6392 jp Init ; 639b -Function639b: ; unreferenced +Unreferenced_Function639b: ; If bit 0 or 1 of [wTitleScreenTimer] is set, we don't need to be here. ld a, [wTitleScreenTimer] - and $3 + and %00000011 ret nz ld bc, SpriteAnim10 ld hl, SPRITEANIMSTRUCT_FRAME @@ -1377,7 +1376,7 @@ Copyright: ; 63e2 call LoadFontsExtra ld de, CopyrightGFX ld hl, vTiles2 tile $60 - lb bc, BANK(CopyrightGFX), $1d + lb bc, BANK(CopyrightGFX), 29 call Request2bpp hlcoord 2, 7 ld de, CopyrightString diff --git a/engine/item_effects.asm b/engine/item_effects.asm index 90dfdc7e0..a15e01247 100644 --- a/engine/item_effects.asm +++ b/engine/item_effects.asm @@ -415,7 +415,7 @@ ParkBall: ; e8a2 ld [hBattleTurn], a ld [Buffer2], a ld [wNumHits], a - predef PlayBattleAnim + predef Predef_PlayBattleAnim ld a, [wWildMon] and a @@ -517,7 +517,7 @@ ParkBall: ; e8a2 cp BATTLETYPE_TUTORIAL jp z, .FinishTutorial - farcall TrainerRankings_WildMonsCaught + farcall StubbedTrainerRankings_WildMonsCaught ld hl, Text_GotchaMonWasCaught call PrintText @@ -547,7 +547,7 @@ ParkBall: ; e8a2 ld a, [EnemyMonSpecies] ld [wd265], a - predef NewPokedexEntry + predef Predef_NewPokedexEntry .skip_pokedex ld a, [BattleType] @@ -567,7 +567,7 @@ ParkBall: ; e8a2 ld [MonType], a call ClearSprites - predef TryAddMonToParty + predef Predef_TryAddMonToParty farcall SetCaughtData @@ -623,7 +623,7 @@ ParkBall: ; e8a2 .SendToPC: call ClearSprites - predef SentPkmnIntoBox + predef Predef_SendPkmnIntoBox farcall SetBoxMonCaughtData @@ -748,7 +748,7 @@ BallMultiplierFunctionTable: dbw MOON_BALL, MoonBallMultiplier dbw LOVE_BALL, LoveBallMultiplier dbw PARK_BALL, ParkBallMultiplier - db $ff + db -1 ; end UltraBallMultiplier: ; multiply catch rate by 2 @@ -775,7 +775,7 @@ GetPokedexEntryBank: ld a, [EnemyMonSpecies] rlca rlca - and 3 + maskbits NUM_DEX_ENTRY_BANKS +- 1 ld hl, .PokedexEntryBanks ld d, 0 ld e, a @@ -786,12 +786,6 @@ GetPokedexEntryBank: ret .PokedexEntryBanks: - -GLOBAL PokedexEntries1 -GLOBAL PokedexEntries2 -GLOBAL PokedexEntries3 -GLOBAL PokedexEntries4 - db BANK(PokedexEntries1) db BANK(PokedexEntries2) db BANK(PokedexEntries3) @@ -985,7 +979,7 @@ LoveBallMultiplier: ld [MonType], a ld a, [CurBattleMon] ld [CurPartyMon], a - farcall GetGender + farcall Predef_GetGender jr c, .done1 ; no effect on genderless ld d, 0 ; male @@ -999,7 +993,7 @@ LoveBallMultiplier: ld [CurPartySpecies], a ld a, WILDMON ld [MonType], a - farcall GetGender + farcall Predef_GetGender jr c, .done2 ; no effect on genderless ld d, 0 ; male @@ -1289,7 +1283,7 @@ UpdateStatsAfterItem: ; ee8c ld a, MON_STAT_EXP - 1 call GetPartyParamLocation ld b, $1 - predef_jump CalcPkmnStats + predef_jump Predef_CalcPkmnStats ; ee9f RareCandy_StatBooster_ExitMenu: ; ee9f @@ -1428,7 +1422,7 @@ RareCandy: ; ef14 xor a ; PARTYMON ld [MonType], a - predef CopyPkmnToTempMon + predef Predef_CopyPkmnToTempMon hlcoord 9, 0 ld b, 10 @@ -1436,8 +1430,8 @@ RareCandy: ; ef14 call TextBox hlcoord 11, 1 - ld bc, $0004 - predef PrintTempMonStats + ld bc, 4 + predef Predef_PrintTempMonStats call WaitPressAorB_BlinkCursor @@ -1445,7 +1439,7 @@ RareCandy: ; ef14 ld [MonType], a ld a, [CurPartySpecies] ld [wd265], a - predef LearnLevelMoves + predef Predef_LearnLevelMoves xor a ld [wForceEvolution], a @@ -1576,7 +1570,7 @@ HealStatus: ; f030 (3:7030) GetItemHealingAction: ; f058 (3:7058) push hl ld a, [CurItem] - ld hl, .healingactions + ld hl, StatusHealingActions ld bc, 3 .next cp [hl] @@ -1595,24 +1589,7 @@ GetItemHealingAction: ; f058 (3:7058) ret ; f071 (3:7071) -.healingactions ; f071 -; item, party menu action text, status - db ANTIDOTE, PARTYMENUTEXT_HEAL_PSN, 1 << PSN - db BURN_HEAL, PARTYMENUTEXT_HEAL_BRN, 1 << BRN - db ICE_HEAL, PARTYMENUTEXT_HEAL_FRZ, 1 << FRZ - db AWAKENING, PARTYMENUTEXT_HEAL_SLP, SLP - db PARLYZ_HEAL, PARTYMENUTEXT_HEAL_PAR, 1 << PAR - db FULL_HEAL, PARTYMENUTEXT_HEAL_ALL, %11111111 - db FULL_RESTORE, PARTYMENUTEXT_HEAL_ALL, %11111111 - db HEAL_POWDER, PARTYMENUTEXT_HEAL_ALL, %11111111 - db PSNCUREBERRY, PARTYMENUTEXT_HEAL_PSN, 1 << PSN - db PRZCUREBERRY, PARTYMENUTEXT_HEAL_PAR, 1 << PAR - db BURNT_BERRY, PARTYMENUTEXT_HEAL_FRZ, 1 << FRZ - db ICE_BERRY, PARTYMENUTEXT_HEAL_BRN, 1 << BRN - db MINT_BERRY, PARTYMENUTEXT_HEAL_SLP, SLP - db MIRACLEBERRY, PARTYMENUTEXT_HEAL_ALL, %11111111 - db -1, 0, 0 -; f09e +INCLUDE "data/items/heal_status.asm" StatusHealer_Jumptable: ; f09e (3:709e) ld hl, .dw @@ -1668,7 +1645,7 @@ RevivePokemon: ; f0d6 ld d, 0 ld hl, wBattleParticipantsIncludingFainted ld b, CHECK_FLAG - predef FlagPredef + predef Predef_SmallFarFlagAction ld a, c and a jr z, .skip_to_revive @@ -1677,7 +1654,7 @@ RevivePokemon: ; f0d6 ld c, a ld hl, wBattleParticipantsNotFainted ld b, SET_FLAG - predef FlagPredef + predef Predef_SmallFarFlagAction .skip_to_revive xor a @@ -1844,7 +1821,7 @@ HealHP_SFX_GFX: ; f1db (3:71db) call AddNTimes ld a, $2 ld [wWhichHPBar], a - predef_jump AnimateHPBar + predef_jump Predef_AnimateHPBar UseItem_SelectMon: ; f1f9 (3:71f9) call .SelectMon @@ -2118,7 +2095,7 @@ GetOneFifthMaxHP: ; f378 (3:7378) GetHealingItemAmount: ; f395 (3:7395) push hl ld a, [CurItem] - ld hl, .Healing + ld hl, HealingHPAmounts ld d, a .next ld a, [hli] @@ -2140,24 +2117,7 @@ GetHealingItemAmount: ; f395 (3:7395) ret ; f3af (3:73af) -.Healing: ; f3af - dbw FRESH_WATER, 50 - dbw SODA_POP, 60 - dbw LEMONADE, 80 - dbw HYPER_POTION, 200 - dbw SUPER_POTION, 50 - dbw POTION, 20 - dbw MAX_POTION, MAX_STAT_VALUE - dbw FULL_RESTORE, MAX_STAT_VALUE - dbw MOOMOO_MILK, 100 - dbw BERRY, 10 - dbw GOLD_BERRY, 30 - dbw ENERGYPOWDER, 50 - dbw ENERGY_ROOT, 200 - dbw RAGECANDYBAR, 20 - dbw BERRY_JUICE, 20 - dbw -1, 0 -; f3df +INCLUDE "data/items/heal_hp.asm" Softboiled_MilkDrinkFunction: ; f3df (3:73df) ; Softboiled/Milk Drink in the field @@ -2291,7 +2251,7 @@ PokeDoll: ; f48f inc a ld [wForcedSwitch], a ld a, [wBattleResult] - and 3 << 6 + and $c0 or $2 ld [wBattleResult], a jp UseItemText @@ -2328,7 +2288,7 @@ XSpecial: ; f4c5 call UseItemText ld a, [CurItem] - ld hl, .x_item_table + ld hl, XItemStats .loop cp [hl] @@ -2357,12 +2317,7 @@ XSpecial: ; f4c5 ret ; f504 -.x_item_table ; f504 - db X_ATTACK, ATTACK - db X_DEFEND, DEFENSE - db X_SPEED, SPEED - db X_SPECIAL, SP_ATTACK -; f50c +INCLUDE "data/items/x_stats.asm" PokeFlute: ; f50c @@ -2572,10 +2527,10 @@ Mysteryberry: ; f5bf cp SKETCH jr z, .CantUsePPUpOnSketch - ld bc, $0015 + ld bc, MON_PP - MON_MOVES add hl, bc ld a, [hl] - cp 3 << 6 ; have 3 PP Ups already been used? + cp PP_UP_MASK jr c, .do_ppup .CantUsePPUpOnSketch: @@ -2586,7 +2541,7 @@ Mysteryberry: ; f5bf .do_ppup ld a, [hl] - add 1 << 6 ; increase PP Up count by 1 + add PP_UP_ONE ld [hl], a ld a, $1 ld [wd265], a @@ -2714,7 +2669,7 @@ RestorePP: ; f6e8 ld a, [wd265] ld b, a ld a, [hl] - and (1 << 6) - 1 + and PP_MASK cp b jr nc, .dont_restore @@ -2732,7 +2687,7 @@ RestorePP: ; f6e8 .restore_some ld a, [hl] - and (1 << 6) - 1 + and PP_MASK add c cp b jr nc, .restore_all @@ -2740,7 +2695,7 @@ RestorePP: ; f6e8 .restore_all ld a, [hl] - and 3 << 6 + and PP_UP_MASK or b ld [hl], a ret @@ -2957,7 +2912,7 @@ UseBallInTrainerBattle: ; f7a0 ld [wBattleAnimParam], a ld [hBattleTurn], a ld [wNumHits], a - predef PlayBattleAnim + predef Predef_PlayBattleAnim ld hl, BlockedTheBallText call PrintText ld hl, DontBeAThiefText @@ -3104,7 +3059,7 @@ ApplyPPUp: ; f84c call GetPartyParamLocation push hl ld de, Buffer1 - predef FillPP + predef Predef_FillPP pop hl ld bc, MON_PP - MON_MOVES add hl, bc @@ -3125,7 +3080,7 @@ ApplyPPUp: ; f84c .use ld a, [hl] - and 3 << 6 + and PP_UP_MASK ld a, [de] ; wasted cycle call nz, ComputeMaxPP @@ -3209,7 +3164,7 @@ RestoreAllPP: ; f8b9 pop bc pop de ld a, [de] - and 3 << 6 + and PP_UP_MASK ld b, a ld a, [wd265] add b @@ -3282,7 +3237,7 @@ GetMaxPPOfMove: ; f8ec .notwild add hl, bc ld a, [hl] - and 3 << 6 + and PP_UP_MASK pop bc or b @@ -3293,7 +3248,7 @@ GetMaxPPOfMove: ; f8ec ld a, b ; this gets lost anyway call ComputeMaxPP ld a, [hl] - and (1 << 6) - 1 + and PP_MASK ld [wd265], a pop af diff --git a/engine/landmarks.asm b/engine/landmarks.asm index 75605bbd9..452bd2e92 100644 --- a/engine/landmarks.asm +++ b/engine/landmarks.asm @@ -80,8 +80,8 @@ RegionCheck: ; 0x1caea1 jr c, .kanto .johto - ld e, 0 + ld e, JOHTO_REGION ret .kanto - ld e, 1 + ld e, KANTO_REGION ret diff --git a/engine/learn.asm b/engine/learn.asm index d2751235f..ceb814650 100755 --- a/engine/learn.asm +++ b/engine/learn.asm @@ -1,4 +1,4 @@ -LearnMove: ; 6508 +Predef_LearnMove: ; 6508 call LoadTileMapToTempTileMap ld a, [CurPartyMon] ld hl, PartyMonNicknames @@ -144,7 +144,7 @@ ForgetMove: ; 65d3 hlcoord 5 + 2, 2 + 2 ld a, SCREEN_WIDTH * 2 ld [Buffer1], a - predef ListMoves + predef Predef_ListMoves ; wMenuData3 ld a, $4 ld [w2DMenuCursorInitY], a diff --git a/engine/link.asm b/engine/link.asm index 5c45707d7..0f17f1305 100755 --- a/engine/link.asm +++ b/engine/link.asm @@ -150,7 +150,7 @@ TimeCapsule: ; 2805d ld [wd265], a push hl push de - callfar ConvertMon_1to2 + callfar Predef_ConvertMon_1to2 pop de pop hl ld a, [wd265] @@ -449,7 +449,7 @@ Gen2ToGen2LinkComms: ; 28177 pop af ld [rIF], a - predef StartBattle + predef Predef_StartBattle ld a, [rIF] ld h, a @@ -786,7 +786,7 @@ Link_PrepPartyData_Gen1: ; 28499 add hl, bc ld c, STAT_SATK ld b, TRUE - predef CalcPkmnStatC + predef Predef_CalcPkmnStatC pop bc pop de @@ -811,31 +811,24 @@ Link_PrepPartyData_Gen2: ; 28595 inc de dec b jr nz, .loop1 - ; de = $c806 ld hl, PlayerName ld bc, NAME_LENGTH call CopyBytes - ; de = $c811 ld hl, PartyCount ld bc, 1 + PARTY_LENGTH + 1 call CopyBytes - ; de = $c819 ld hl, PlayerID ld bc, 2 call CopyBytes - ; de = $c81b ld hl, PartyMon1Species ld bc, PARTY_LENGTH * PARTYMON_STRUCT_LENGTH call CopyBytes - ; de = $c93b ld hl, PartyMonOT ld bc, PARTY_LENGTH * NAME_LENGTH call CopyBytes - ; de = $c97d ld hl, PartyMonNicknames ld bc, PARTY_LENGTH * PKMN_NAME_LENGTH call CopyBytes - ; de = $c9bf ; Okay, we did all that. Now, are we in the trade center? ld a, [wLinkMode] @@ -993,7 +986,7 @@ Function2868a: ; 2868a push bc push de ld [wd265], a - callfar ConvertMon_1to2 + callfar Predef_ConvertMon_1to2 pop de pop bc ld a, [wd265] @@ -1072,7 +1065,7 @@ Function2868a: ; 2868a add hl, bc ld c, STAT_SATK ld b, TRUE - predef CalcPkmnStatC + predef Predef_CalcPkmnStatC pop bc pop hl ld a, [hQuotient + 1] @@ -1085,7 +1078,7 @@ Function2868a: ; 2868a add hl, bc ld c, STAT_SDEF ld b, TRUE - predef CalcPkmnStatC + predef Predef_CalcPkmnStatC pop bc pop hl ld a, [hQuotient + 1] @@ -1130,7 +1123,7 @@ TimeCapsule_ReplaceTeruSama: ; 28771 ret -INCLUDE "data/time_capsule/catch_rate_items.asm" +INCLUDE "data/items/catch_rate_items.asm" Link_CopyOTData: ; 2879e @@ -1597,8 +1590,7 @@ Function28b22: ; 28b22 ret ; 28b42 -Function28b42: ; 28b42 -; unreferenced +Unreferenced_Function28b42: ; 28b42 hlcoord 0, 16 ld a, "┘" ld bc, 2 * SCREEN_WIDTH @@ -1892,11 +1884,11 @@ LinkTrade: ; 28b87 ld a, [hLinkPlayerNumber] cp $1 jr z, .player_2 - predef TradeAnimation + predef Predef_TradeAnimation jr .done_animation .player_2 - predef TradeAnimationPlayer2 + predef Predef_TradeAnimationPlayer2 .done_animation pop af @@ -1914,7 +1906,7 @@ LinkTrade: ; 28b87 ld de, TempMonSpecies ld bc, PARTYMON_STRUCT_LENGTH call CopyBytes - predef AddTempmonToParty + predef Predef_AddTempmonToParty ld a, [PartyCount] dec a ld [CurPartyMon], a @@ -1958,7 +1950,7 @@ LinkTrade: ; 28b87 .save farcall SaveAfterLinkTrade - farcall TrainerRankings_Trades + farcall StubbedTrainerRankings_Trades farcall BackupMobileEventIndex ld c, 40 call DelayFrames @@ -2020,8 +2012,7 @@ SetTradeRoomBGPals: ; 28eff ret ; 28f09 -Function28f09: ; 28f09 -; unreferenced +Unreferenced_Function28f09: ; 28f09 hlcoord 0, 0 ld b, 6 ld c, 18 @@ -2045,12 +2036,12 @@ Special_CheckTimeCapsuleCompatibility: ; 29bfb ; If any party Pokemon was introduced in the generation 2 games, don't let it in. ld hl, PartySpecies - ld b, PARTY_LENGTH ; 6 + ld b, PARTY_LENGTH .loop ld a, [hli] cp -1 jr z, .checkitem - cp CHIKORITA ; MEW + 1 ; 151 + 1 + cp JOHTO_POKEMON jr nc, .mon_too_new dec b jr nz, .loop @@ -2145,7 +2136,7 @@ Special_EnterTimeCapsule: ; 29c7b ret ; 29c92 -WaitForOtherPlayerToExit: ; 29c92 +Special_WaitForOtherPlayerToExit: ; 29c92 ld c, 3 call DelayFrames ld a, -1 @@ -2577,17 +2568,16 @@ Special_CableClubCheckWhichChris: ; 29f47 ret ; 29f54 -UnusedGen1LinkCommsBorderGFX: ; 29f54 -; unreferenced +Unreferenced_Gen1LinkCommsBorderGFX: ; 29f54 INCBIN "gfx/trade/unused_gen_1_border_tiles.2bpp" ; 29fe4 -Function29fe4: ; unreferenced +Unreferenced_Function29fe4: ld a, BANK(sPartyMail) call GetSRAMBank ld d, $0 ld b, CHECK_FLAG - predef FlagPredef + predef Predef_SmallFarFlagAction call CloseSRAM ld a, c and a diff --git a/engine/link_2.asm b/engine/link_2.asm index 72e5262b3..03b95b39a 100644 --- a/engine/link_2.asm +++ b/engine/link_2.asm @@ -3,7 +3,7 @@ LinkMonStatsScreen: ; 4d319 dec a ld [CurPartyMon], a call LowVolume - predef StatsScreenInit + predef Predef_StatsScreenInit ld a, [CurPartyMon] inc a ld [wMenuCursorY], a diff --git a/engine/mail.asm b/engine/mail.asm index 04c31af17..68b16fd10 100755 --- a/engine/mail.asm +++ b/engine/mail.asm @@ -128,7 +128,7 @@ CheckPokeItem:: ; 44654 push bc push de farcall SelectMonFromParty - ld a, $2 + ld a, POKEMAIL_REFUSED jr c, .pop_return ld a, [CurPartyMon] @@ -137,7 +137,7 @@ CheckPokeItem:: ; 44654 call AddNTimes ld d, [hl] farcall ItemIsMail - ld a, $3 + ld a, POKEMAIL_NO_MAIL jr nc, .pop_return ld a, BANK(sPartyMail) @@ -162,7 +162,7 @@ CheckPokeItem:: ; 44654 cp "@" jr z, .done cp c - ld a, $0 + ld a, POKEMAIL_WRONG_MAIL jr nz, .close_sram_return inc hl inc de @@ -173,12 +173,12 @@ CheckPokeItem:: ; 44654 .done farcall CheckCurPartyMonFainted - ld a, $4 + ld a, POKEMAIL_LAST_MON jr c, .close_sram_return xor a ld [wPokemonWithdrawDepositParameter], a farcall RemoveMonFromPartyOrBox - ld a, $1 + ld a, POKEMAIL_CORRECT .close_sram_return call CloseSRAM @@ -559,8 +559,7 @@ MailboxPC: ; 0x44806 .TopMenuDataHeader: ; 0x4494c db MENU_BACKUP_TILES ; flags - db 1, 8 ; start coords - db 10, 18 ; end coords + menu_coords 8, 1, SCREEN_WIDTH - 2, 10 dw .TopMenuData2 db 1 ; default option @@ -575,8 +574,7 @@ MailboxPC: ; 0x44806 .SubMenuDataHeader: ; 0x44964 db MENU_BACKUP_TILES ; flags - db 0, 0 ; start coords - db 9, 13 ; end coords + menu_coords 0, 0, 13, 9 dw .SubMenuData2 db 1 ; default option diff --git a/engine/mail_2.asm b/engine/mail_2.asm index d66bbbbd7..4450063a4 100755 --- a/engine/mail_2.asm +++ b/engine/mail_2.asm @@ -69,7 +69,7 @@ ReadAnyMail: ; b9237 ld h, d ld l, e push hl - ld a, $0 + ld a, BANK(sPartyMail) call GetSRAMBank ld de, sPartyMon1MailAuthorID - sPartyMon1Mail add hl, de @@ -725,8 +725,7 @@ MailGFX_PlaceMessage: ; b9803 jp PlaceString ; b984e -Functionb984e: ; b984e -; XXX +Unreferenced_Functionb984e: ; b984e .loop ld a, [hl] xor $ff diff --git a/engine/main_menu.asm b/engine/main_menu.asm index 1f6686d1f..f82c6072a 100755 --- a/engine/main_menu.asm +++ b/engine/main_menu.asm @@ -31,8 +31,7 @@ MainMenu: ; 49cdc .MenuDataHeader: ; 49d14 db MENU_BACKUP_TILES ; flags - db 00, 00 ; start coords - db 07, 16 ; end coords + menu_coords 0, 0, 16, 7 dw .MenuData2 db 1 ; default option ; 49d1c @@ -279,7 +278,7 @@ MainMenu_PrintCurrentTimeAndDay: ; 49e09 ret .min -; unreferenced +; unused db "min.@" ; 49e75 diff --git a/engine/map_objects.asm b/engine/map_objects.asm index fe3c13a13..0f04a0a16 100644 --- a/engine/map_objects.asm +++ b/engine/map_objects.asm @@ -1,6 +1,6 @@ -INCLUDE "data/facings.asm" +INCLUDE "data/sprites/facings.asm" -INCLUDE "data/map_objects.asm" +INCLUDE "data/sprites/map_objects.asm" ; 4357 @@ -392,6 +392,7 @@ StepVectors: ; 4700 db -4, 0, 4, 4 db 4, 0, 4, 4 ; 4730 + GetStepVectorSign: ; 4730 add a ret z ; 0 or 128 @@ -400,6 +401,7 @@ GetStepVectorSign: ; 4730 ld a, -1 ret ; 129 - 255 ; 4738 + UpdatePlayerStep: ; 4738 ld hl, OBJECT_DIRECTION_WALKING add hl, bc @@ -418,8 +420,7 @@ UpdatePlayerStep: ; 4738 ret ; 4759 -Function4759: ; 4759 -; unreferenced +Unreferenced_Function4759: ; 4759 push bc ld e, a ld d, 0 @@ -892,7 +893,7 @@ MapObjectMovementPattern: ; 47dd ld hl, OBJECT_DIRECTION_WALKING add hl, de ld a, [hl] - and 3 + maskbits NUM_DIRECTIONS +- 1 ld d, 1 * 8 + 6 cp DOWN jr z, .ok_13 @@ -1571,7 +1572,7 @@ StepType05: ; 4e0c ld [hl], a call IncrementObjectStructField1c StepType04: ; 4e21 - call MobileFn_4fb2 + call Stubbed_Function4fb2 ld hl, OBJECT_DIRECTION_WALKING add hl, bc ld [hl], STANDING @@ -1579,7 +1580,7 @@ StepType04: ; 4e21 ; 4e2b NPCStep: ; 4e2b - call MobileFn_4fb2 + call Stubbed_Function4fb2 call AddStepVector ld hl, OBJECT_STEP_DURATION add hl, bc @@ -1842,7 +1843,8 @@ SkyfallTop: ; 4f83 ret ; 4fb2 -MobileFn_4fb2: mobile +Stubbed_Function4fb2: + ret ld hl, OBJECT_1D add hl, bc inc [hl] @@ -2793,6 +2795,7 @@ Function5903: ; 5903 db SPRITEMOVEDATA_STANDING_LEFT db SPRITEMOVEDATA_STANDING_RIGHT ; 5920 + _UpdateSprites:: ; 5920 ld a, [VramState] bit 0, a @@ -2814,18 +2817,18 @@ _UpdateSprites:: ; 5920 bit 1, a ld b, LOW(SpritesEnd) jr z, .ok - ld b, 28 * 4 + ld b, 28 * SPRITEOAMSTRUCT_LENGTH .ok ld a, [hUsedSpriteIndex] cp b ret nc ld l, a ld h, HIGH(Sprites) - ld de, 4 + ld de, SPRITEOAMSTRUCT_LENGTH ld a, b - ld c, SCREEN_HEIGHT_PX + 16 + ld c, SCREEN_HEIGHT_PX + 2 * TILE_WIDTH .loop - ld [hl], c + ld [hl], c ; y add hl, de cp l jr nz, .loop @@ -3042,12 +3045,12 @@ PRIORITY_HIGH EQU $30 ld a, [hFFC0] add [hl] inc hl - ld [bc], a + ld [bc], a ; y inc c ld a, [hFFBF] add [hl] inc hl - ld [bc], a + ld [bc], a ; x inc c ld e, [hl] inc hl @@ -3058,7 +3061,7 @@ PRIORITY_HIGH EQU $30 .nope1 add [hl] inc hl - ld [bc], a + ld [bc], a ; tile id inc c ld a, e bit 1, a @@ -3068,7 +3071,7 @@ PRIORITY_HIGH EQU $30 .nope2 and %11110000 or d - ld [bc], a + ld [bc], a ; attributes inc c ld a, [hUsedSpriteTile] dec a diff --git a/engine/map_setup.asm b/engine/map_setup.asm index 078e6a2fd..b3905b71e 100644 --- a/engine/map_setup.asm +++ b/engine/map_setup.asm @@ -79,7 +79,7 @@ MapSetupCommands: ; 15440 dba LoadGraphics ; 0e dba LoadTileset ; 0f dba LoadMapTimeOfDay ; 10 - dba LoadMapPalettes ; 11 + dba Special_LoadMapPalettes ; 11 dba LoadWildMonData ; 12 dba RefreshMapSprites ; 13 dba HandleNewMap ; 14 @@ -91,8 +91,8 @@ MapSetupCommands: ; 15440 dba LoadMapAttributes ; 1a dba LoadMapAttributes_SkipPeople ; 1b dba ClearBGPalettes ; 1c - dba FadeOutPalettes ; 1d - dba FadeInPalettes ; 1e + dba Special_FadeOutPalettes ; 1d + dba Special_FadeInPalettes ; 1e dba GetCoordOfUpperLeftCorner ; 1f dba RestoreFacingAfterWarp ; 20 dba SpawnInFacingDown ; 21 @@ -137,7 +137,7 @@ LoadObjectsRunCallback_02: ; 154d7 ret ; 154ea (5:54ea) -; unreferenced +; unused ret ; 154eb diff --git a/engine/mapgroup_roofs.asm b/engine/mapgroup_roofs.asm new file mode 100644 index 000000000..2cd734234 --- /dev/null +++ b/engine/mapgroup_roofs.asm @@ -0,0 +1,20 @@ +LoadMapGroupRoof:: ; 1c000 + ld a, [MapGroup] + ld e, a + ld d, 0 + ld hl, MapGroupRoofs + add hl, de + ld a, [hl] + cp -1 + ret z + ld hl, Roofs + ld bc, 9 tiles + call AddNTimes + ld de, vTiles2 tile $0a + ld bc, 9 tiles + call CopyBytes + ret +; 1c021 + + +INCLUDE "data/maps/roofs.asm" diff --git a/engine/mart.asm b/engine/mart.asm index 44f3b087b..2f1b9c6a6 100755 --- a/engine/mart.asm +++ b/engine/mart.asm @@ -443,7 +443,7 @@ GetMartDialogGroup: ; 15ca3 BuyMenuLoop: ; 15cef - farcall PlaceMoneyTopRight + farcall Special_PlaceMoneyTopRight call UpdateSprites ld hl, MenuDataHeader_Buy call CopyMenuDataHeader @@ -525,7 +525,7 @@ StandardMartAskPurchaseQuantity: ; 15d97 MartConfirmPurchase: ; 15d97 - predef PartyMonItemName + predef Predef_PartyMonItemName ld a, MARTTEXT_COSTS_THIS_MUCH call LoadBuyMenuText call YesNoBox @@ -618,8 +618,7 @@ Text_Mart_CostsThisMuch: ; 0x15e13 MenuDataHeader_Buy: ; 0x15e18 db MENU_BACKUP_TILES ; flags - db 03, 01 ; start coords - db 11, 19 ; end coords + menu_coords 1, 3, SCREEN_WIDTH - 1, TEXTBOX_Y - 1 dw .menudata2 db 1 ; default option ; 0x15e20 @@ -785,7 +784,7 @@ SellMenu: ; 15eb3 farcall DepositSellInitPackBuffers .loop farcall DepositSellPack - ld a, [wcf66] + ld a, [wPackUsedItem] and a jp z, .quit call .TryToSellItem @@ -797,7 +796,7 @@ SellMenu: ; 15eb3 ret ; 15ed3 -.NothingToSell: ; unreferenced +.Unreferenced_NothingToSell: ld hl, .NothingToSellText call MenuTextBoxBackup and a @@ -864,7 +863,7 @@ SellMenu: ; 15eb3 ld a, [wMartItemID] ld hl, NumItems call TossItem - predef PartyMonItemName + predef Predef_PartyMonItemName hlcoord 1, 14 lb bc, 3, 18 call ClearBox @@ -892,7 +891,7 @@ Text_Mart_ICanPayThisMuch: ; 0x15f78 db "@" ; 0x15f7d -DummyString ; 15f7d +.UnusedString15f7d: ; 15f7d db "!ダミー!@" Text_Mart_HowMayIHelpYou: ; 0x15f83 @@ -903,8 +902,7 @@ Text_Mart_HowMayIHelpYou: ; 0x15f83 MenuDataHeader_BuySell: ; 0x15f88 db MENU_BACKUP_TILES ; flags - db 00, 00 ; start coords - db 08, 07 ; end coords + menu_coords 0, 0, 7, 8 dw .menudata2 db 1 ; default option ; 0x15f90 diff --git a/engine/menu.asm b/engine/menu.asm index 636b26dbf..802bece08 100755 --- a/engine/menu.asm +++ b/engine/menu.asm @@ -291,8 +291,7 @@ MobileMenuJoypad: ; 241ba ; 241d5 -Function241d5: ; 241d5 -; Unreferenced +Unreferenced_Function241d5: ; 241d5 call Place2DMenuCursor .loop call Move2DMenuCursor @@ -586,7 +585,7 @@ Place2DMenuCursor: ; 24329 _PushWindow:: ; 24374 ld a, [rSVBK] push af - ld a, $7 + ld a, BANK(wWindowStack) ld [rSVBK], a ld hl, wWindowStackPointer @@ -691,7 +690,7 @@ _ExitMenu:: ; 243e8 ld a, [rSVBK] push af - ld a, $7 + ld a, BANK(wWindowStack) ld [rSVBK], a call GetWindowStackTop @@ -725,12 +724,11 @@ _ExitMenu:: ; 243e8 ret ; 24423 -Function24423: ; 24423 -; Unreferenced +Unreferenced_Function24423: ; 24423 ld a, [VramState] bit 0, a ret z - xor a + xor a ; sScratch call GetSRAMBank hlcoord 0, 0 ld de, sScratch @@ -738,7 +736,7 @@ Function24423: ; 24423 call CopyBytes call CloseSRAM call OverworldTextModeSwitch - xor a + xor a ; sScratch call GetSRAMBank ld hl, sScratch decoord 0, 0 diff --git a/engine/menu_2.asm b/engine/menu_2.asm index d3eb499bf..94be32eab 100644 --- a/engine/menu_2.asm +++ b/engine/menu_2.asm @@ -27,7 +27,7 @@ PlaceMenuItemQuantity: ; 0x24ac3 .done ret -PlaceMoneyTopRight: ; 24ae8 +Special_PlaceMoneyTopRight: ; 24ae8 ld hl, MenuDataHeader_0x24b15 call CopyMenuDataHeader jr PlaceMoneyDataHeader @@ -54,15 +54,13 @@ PlaceMoneyDataHeader: ; 24b01 MenuDataHeader_0x24b15: ; 0x24b15 db MENU_BACKUP_TILES ; flags - db 00, 11 ; start coords - db 02, 19 ; end coords + menu_coords 11, 0, SCREEN_WIDTH - 1, 2 dw NULL db 1 ; default option MenuDataHeader_0x24b1d: ; 0x24b1d db MENU_BACKUP_TILES ; flags - db 11, 00 ; start coords - db 13, 08 ; end coords + menu_coords 0, 11, 8, 13 dw NULL db 1 ; default option @@ -112,8 +110,8 @@ CoinString: ; 24b89 ShowMoney_TerminatorString: ; 24b8e db "@" -Function24b8f: ; 24b8f -; unreferenced, related to safari? +Unreferenced_Function24b8f: ; 24b8f +; related to safari? ld hl, Options ld a, [hl] push af @@ -216,7 +214,7 @@ FindApricornsInBag: ; 24c64 ld bc, 10 call ByteFill - ld hl, .ApricornBalls + ld hl, ApricornBalls .loop ld a, [hl] cp -1 @@ -252,12 +250,4 @@ FindApricornsInBag: ; 24c64 pop hl ret -.ApricornBalls: ; 24ca0 - db RED_APRICORN, LEVEL_BALL - db BLU_APRICORN, LURE_BALL - db YLW_APRICORN, MOON_BALL - db GRN_APRICORN, FRIEND_BALL - db WHT_APRICORN, FAST_BALL - db BLK_APRICORN, HEAVY_BALL - db PNK_APRICORN, LOVE_BALL - db -1 +INCLUDE "data/items/apricorn_balls.asm" diff --git a/engine/mon_icons.asm b/engine/mon_icons.asm index 316ff3bac..db1a68ceb 100755 --- a/engine/mon_icons.asm +++ b/engine/mon_icons.asm @@ -281,8 +281,7 @@ FlyFunction_GetMonIcon: ; 8e9bc (23:69bc) ret ; 8e9cc (23:69cc) -GetMonIcon2: ; 8e9cc -; unreferenced +Unreferenced_GetMonIcon2: ; 8e9cc push de ld a, [wd265] call ReadMonMenuIcon @@ -307,8 +306,8 @@ GetIconGFX: ; 8e9de ret HeldItemIcons: -INCBIN "gfx/icon/mail.2bpp" -INCBIN "gfx/icon/item.2bpp" +INCBIN "gfx/icons/mail.2bpp" +INCBIN "gfx/icons/item.2bpp" ; 8ea17 GetIcon_de: ; 8ea17 diff --git a/engine/mon_menu.asm b/engine/mon_menu.asm index dfd11e42a..d7e8446d0 100755 --- a/engine/mon_menu.asm +++ b/engine/mon_menu.asm @@ -55,9 +55,8 @@ MonSubmenu: ; 24d19 ; 24d3f .MenuDataHeader: ; 24d3f - db MENU_BACKUP_TILES ; tile backup - db 00, 06 ; start coords - db 17, 19 ; end coords + db MENU_BACKUP_TILES ; flags + menu_coords 6, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1 dw 0 db 1 ; default option ; 24d47 @@ -78,7 +77,7 @@ MonSubmenu: ; 24d19 MonMenuLoop: ; 24d59 .loop - ld a, $a0 ; flags + ld a, MENU_UNUSED_3 | MENU_BACKUP_TILES_2 ; flags ld [wMenuData2Flags], a ld a, [Buffer1] ; items ld [wMenuData2Items], a @@ -326,8 +325,7 @@ BattleMonMenu: ; 24e99 MenuDataHeader_0x24ed4: ; 24ed4 db 0 ; flags - db 11, 11 ; start coords - db 17, 19 ; end coords + menu_coords 11, 11, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1 dw MenuData2_0x24edc db 1 ; default option ; 24edc diff --git a/engine/mon_stats.asm b/engine/mon_stats.asm index a3039eefd..a297b7760 100644 --- a/engine/mon_stats.asm +++ b/engine/mon_stats.asm @@ -1,8 +1,8 @@ -DrawPlayerHP: ; 50b0a +Predef_DrawPlayerHP: ; 50b0a ld a, $1 jr DrawHP -DrawEnemyHP: ; 50b0e +Predef_DrawEnemyHP: ; 50b0e ld a, $2 DrawHP: ; 50b10 @@ -43,7 +43,7 @@ DrawHP: ; 50b10 ld c, e .not_boxmon - predef ComputeHPBarPixels + predef Predef_ComputeHPBarPixels ld a, 6 ld d, a ld c, a @@ -82,7 +82,7 @@ DrawHP: ; 50b10 pop de ret -PrintTempMonStats: ; 50b7b +Predef_PrintTempMonStats: ; 50b7b ; Print TempMon's stats at hl, with spacing bc. push bc push hl @@ -121,7 +121,7 @@ PrintTempMonStats: ; 50b7b next "SPEED" next "@" -GetGender: ; 50bdd +Predef_GetGender: ; 50bdd ; Return the gender of a given monster (CurPartyMon/CurOTMon/CurWildMon). ; When calling this function, a should be set to an appropriate MonType value. @@ -174,7 +174,7 @@ GetGender: ; 50bdd ; sBoxMon data is read directly from SRAM. ld a, [MonType] cp BOXMON - ld a, 1 + ld a, BANK(sBox) call z, GetSRAMBank ; Attack DV @@ -235,7 +235,7 @@ GetGender: ; 50bdd scf ret -ListMovePP: ; 50c50 +Predef_ListMovePP: ; 50c50 ld a, [wNumMoves] inc a ld c, a @@ -324,8 +324,7 @@ ListMovePP: ; 50c50 jr nz, .load_loop ret -Function50cd0: ; 50cd0 -; XXX +Unreferenced_Function50cd0: ; 50cd0 .loop ld [hl], $32 inc hl @@ -336,7 +335,7 @@ Function50cd0: ; 50cd0 jr nz, .loop ret -Predef22: ; unreferenced predef +UnusedPredef22: push hl push hl ld hl, PartyMonNicknames @@ -344,7 +343,7 @@ Predef22: ; unreferenced predef call GetNick pop hl call PlaceString - call CopyPkmnToTempMon + call Predef_CopyPkmnToTempMon pop hl ld a, [CurPartySpecies] cp EGG @@ -353,7 +352,7 @@ Predef22: ; unreferenced predef ld bc, -12 add hl, bc ld b, $0 - call DrawEnemyHP + call Predef_DrawEnemyHP pop hl ld bc, 5 add hl, bc @@ -364,7 +363,7 @@ Predef22: ; unreferenced predef .egg ret -PlaceStatusString: ; 50d0a +Predef_PlaceStatusString: ; 50d0a push de inc de inc de @@ -374,7 +373,7 @@ PlaceStatusString: ; 50d0a ld a, [de] or b pop de - jr nz, PlaceNonFaintStatus + jr nz, Predef_PlaceNonFaintStatus push de ld de, FntString call CopyStatusString @@ -397,7 +396,7 @@ CopyStatusString: ; 50d25 ld [hl], a ret -PlaceNonFaintStatus: ; 50d2e +Predef_PlaceNonFaintStatus: ; 50d2e push de ld a, [de] ld de, PsnString @@ -431,7 +430,7 @@ BrnString: db "BRN@" FrzString: db "FRZ@" ParString: db "PAR@" -ListMoves: ; 50d6f +Predef_ListMoves: ; 50d6f ; List moves at hl, spaced every [Buffer1] tiles. ld de, wListMoves_MoveIndicesBuffer ld b, $0 diff --git a/engine/move_mon.asm b/engine/move_mon.asm index 90728e84c..426a3ba8b 100755 --- a/engine/move_mon.asm +++ b/engine/move_mon.asm @@ -1,4 +1,4 @@ -TryAddMonToParty: ; d88c +Predef_TryAddMonToParty: ; d88c ; Check if to copy wild Pkmn or generate new Pkmn ; Whose is it? ld de, PartyCount @@ -120,7 +120,7 @@ GeneratePartyMonStats: ; d906 endr ld [hl], a ld [Buffer1], a - predef FillMoves + predef Predef_FillMoves .next pop de @@ -195,7 +195,7 @@ endr push de inc hl inc hl - call FillPP + call Predef_FillPP pop de pop hl rept 4 @@ -224,7 +224,7 @@ endr ld a, $1 ld c, a ld b, FALSE - call CalcPkmnStatC + call Predef_CalcPkmnStatC ld a, [hProduct + 2] ld [de], a inc de @@ -297,7 +297,7 @@ endr ld bc, MON_STAT_EXP - 1 add hl, bc ld b, $0 ; if b = 1, then stat calculation takes stat exp into account. - call CalcPkmnStats + call Predef_CalcPkmnStats .next3 ld a, [MonType] @@ -311,7 +311,7 @@ endr dec a ld bc, PARTYMON_STRUCT_LENGTH call AddNTimes - predef GetUnownLetter + predef Predef_GetUnownLetter callfar UpdateUnownDex .done @@ -319,7 +319,7 @@ endr ret ; da6d -FillPP: ; da6d +Predef_FillPP: ; da6d push bc ld b, NUM_MOVES .loop @@ -350,7 +350,7 @@ FillPP: ; da6d ret ; da96 -AddTempmonToParty: ; da96 +Predef_AddTempmonToParty: ; da96 ld hl, PartyCount ld a, [hl] cp PARTY_LENGTH @@ -422,7 +422,7 @@ AddTempmonToParty: ; da96 dec a ld bc, PARTYMON_STRUCT_LENGTH call AddNTimes - predef GetUnownLetter + predef Predef_GetUnownLetter callfar UpdateUnownDex ld a, [wFirstUnownSeen] and a @@ -434,7 +434,7 @@ AddTempmonToParty: ; da96 and a ret -SentGetPkmnIntoFromBox: ; db3f +Predef_SendGetPkmnIntoFromBox: ; db3f ; Sents/Gets Pkmn into/from Box depending on Parameter ; wPokemonWithdrawDepositParameter == 0: get Pkmn into Party ; wPokemonWithdrawDepositParameter == 1: sent Pkmn into Box @@ -597,7 +597,7 @@ SentGetPkmnIntoFromBox: ; db3f srl a add $2 ld [MonType], a - predef CopyPkmnToTempMon + predef Predef_CopyPkmnToTempMon callfar CalcLevel ld a, d ld [CurPartyLevel], a @@ -617,7 +617,7 @@ SentGetPkmnIntoFromBox: ; db3f push bc ld b, $1 - call CalcPkmnStats + call Predef_CalcPkmnStats pop bc ld a, [wPokemonWithdrawDepositParameter] @@ -830,7 +830,7 @@ Functiondd64: ; dd64 add hl, bc push bc ld b, $1 - call CalcPkmnStats + call Predef_CalcPkmnStats ld hl, PartyMon1Moves ld a, [PartyCount] dec a @@ -840,7 +840,7 @@ Functiondd64: ; dd64 ld e, l ld a, $1 ld [Buffer1], a - predef FillMoves + predef Predef_FillMoves ld a, [PartyCount] dec a ld [CurPartyMon], a @@ -904,8 +904,8 @@ DepositBreedmon: ; de44 ld bc, BOXMON_STRUCT_LENGTH jp CopyBytes -SentPkmnIntoBox: ; de6e -; Sents the Pkmn into one of Bills Boxes +Predef_SendPkmnIntoBox: ; de6e +; Sends the Pkmn into one of Bills Boxes ; the data comes mainly from 'EnemyMon:' ld a, BANK(sBoxCount) call GetSRAMBank @@ -1010,7 +1010,7 @@ SentPkmnIntoBox: ; de6e cp UNOWN jr nz, .not_unown ld hl, sBoxMon1DVs - predef GetUnownLetter + predef Predef_GetUnownLetter callfar UpdateUnownDex .not_unown @@ -1086,7 +1086,7 @@ ShiftBoxMon: ; df47 ret ; df8c -GiveEgg:: ; df8c +Predef_GiveEgg:: ; df8c ld a, [CurPartySpecies] push af callfar GetPreEvolution @@ -1094,7 +1094,7 @@ GiveEgg:: ; df8c ld a, [CurPartySpecies] dec a -; TryAddMonToParty sets Seen and Caught flags +; Predef_TryAddMonToParty sets Seen and Caught flags ; when it is successful. This routine will make ; sure that we aren't newly setting flags. push af @@ -1104,11 +1104,11 @@ GiveEgg:: ; df8c call CheckSeenMon push bc - call TryAddMonToParty + call Predef_TryAddMonToParty ; If we haven't caught this Pokemon before receiving ; the Egg, reset the flag that was just set by -; TryAddMonToParty. +; Predef_TryAddMonToParty. pop bc ld a, c and a @@ -1119,12 +1119,12 @@ GiveEgg:: ; df8c ld d, $0 ld hl, PokedexCaught ld b, RESET_FLAG - predef FlagPredef + predef Predef_SmallFarFlagAction .skip_caught_flag ; If we haven't seen this Pokemon before receiving ; the Egg, reset the flag that was just set by -; TryAddMonToParty. +; Predef_TryAddMonToParty. pop bc ld a, c and a @@ -1135,7 +1135,7 @@ GiveEgg:: ; df8c ld d, $0 ld hl, PokedexSeen ld b, RESET_FLAG - predef FlagPredef + predef Predef_SmallFarFlagAction .skip_seen_flag pop af @@ -1360,7 +1360,7 @@ ComputeNPCTrademonStats: ; e134 ld a, MON_STAT_EXP - 1 call GetPartyParamLocation ld b, $1 - call CalcPkmnStats + call Predef_CalcPkmnStats pop de ld a, MON_HP call GetPartyParamLocation @@ -1372,7 +1372,7 @@ ComputeNPCTrademonStats: ; e134 ret ; e167 -CalcPkmnStats: ; e167 +Predef_CalcPkmnStats: ; e167 ; Calculates all 6 Stats of a Pkmn ; b: Take into account stat EXP if TRUE ; 'c' counts from 1-6 and points with 'BaseStats' to the base value @@ -1382,7 +1382,7 @@ CalcPkmnStats: ; e167 ld c, $0 .loop inc c - call CalcPkmnStatC + call Predef_CalcPkmnStatC ld a, [hMultiplicand + 1] ld [de], a inc de @@ -1395,7 +1395,7 @@ CalcPkmnStats: ; e167 ret ; e17b -CalcPkmnStatC: ; e17b +Predef_CalcPkmnStatC: ; e17b ; 'c' is 1-6 and points to the BaseStat ; 1: HP ; 2: Attack @@ -1596,7 +1596,7 @@ GivePoke:: ; e277 push bc xor a ; PARTYMON ld [MonType], a - call TryAddMonToParty + call Predef_TryAddMonToParty jr nc, .failed ld hl, PartyMonNicknames ld a, [PartyCount] @@ -1626,7 +1626,7 @@ GivePoke:: ; e277 ld a, [CurPartySpecies] ld [TempEnemyMonSpecies], a callfar LoadEnemyMon - call SentPkmnIntoBox + call Predef_SendPkmnIntoBox jp nc, .FailedToGiveMon ld a, BOXMON ld [MonType], a @@ -1795,7 +1795,7 @@ InitNickname: ; e3de pop hl ld de, StringBuffer1 call InitName - ld a, $4 ; XXX could this be in bank 4 in pokered? + ld a, $4 ; ExitAllMenus is in bank 0, XXX could this be in bank 4 in pokered? ld hl, ExitAllMenus rst FarCall ret diff --git a/engine/mystery_gift.asm b/engine/mystery_gift.asm index 67ce10168..0f5265bf7 100755 --- a/engine/mystery_gift.asm +++ b/engine/mystery_gift.asm @@ -63,7 +63,7 @@ DoMysteryGift: ; 1048ba (41:48ba) jr z, .skip_append_save call .SaveMysteryGiftTrainerName farcall RestoreMobileEventIndex - farcall TrainerRankings_MysteryGift + farcall StubbedTrainerRankings_MysteryGift farcall BackupMobileEventIndex .skip_append_save ld a, [wMysteryGiftPartnerSentDeco] @@ -1117,7 +1117,7 @@ MysteryGift_CheckAndSetDecorationAlreadyReceived: ; 105069 (41:5069) ld d, $0 ld b, CHECK_FLAG ld hl, sMysteryGiftDecorationsReceived - predef_id FlagPredef + predef_id Predef_SmallFarFlagAction push hl push bc call Predef @@ -1129,7 +1129,7 @@ MysteryGift_CheckAndSetDecorationAlreadyReceived: ; 105069 (41:5069) ret nz call GetMysteryGiftBank ld b, SET_FLAG - predef FlagPredef + predef Predef_SmallFarFlagAction call CloseSRAM xor a ret @@ -1142,7 +1142,7 @@ MysteryGift_CopyReceivedDecosToPC: ; 105091 (41:5091) ld d, $0 ld b, CHECK_FLAG ld hl, sMysteryGiftDecorationsReceived - predef FlagPredef + predef Predef_SmallFarFlagAction ld a, c and a pop bc @@ -1369,7 +1369,7 @@ InitMysteryGiftLayout: ; 105153 (41:5153) jr .gfx_loop ; 105232 (41:5232) -.Load6GFX: ; unreferenced +.Unreferenced_Load6GFX: ld b, 6 jr .gfx_loop @@ -1456,33 +1456,33 @@ Function105688: ; 105688 (41:5688) jr asm_105726 Function1056eb: ; 1056eb (41:56eb) - ld c, $10 -.asm_1056ed - ld hl, Sprites - ld b, $8 -.asm_1056f2 + ld c, 16 +.loop + ld hl, Sprite01YCoord + ld b, 8 +.dec_y_loop dec [hl] -rept 4 +rept SPRITEOAMSTRUCT_LENGTH inc hl endr dec b - jr nz, .asm_1056f2 - ld hl, Sprites + $20 - ld b, $8 -.asm_1056ff + jr nz, .dec_y_loop + ld hl, Sprite09YCoord + ld b, 8 +.inc_y_loop inc [hl] -rept 4 +rept SPRITEOAMSTRUCT_LENGTH inc hl endr dec b - jr nz, .asm_1056ff + jr nz, .inc_y_loop dec c ret z push bc ld c, 4 call DelayFrames pop bc - jr .asm_1056ed + jr .loop Function105712: ; 105712 (41:5712) call Function105777 @@ -1561,12 +1561,12 @@ Function10578c: ; 10578c (41:578c) ld a, [sCrystalData + 0] ld [de], a inc de - ld a, $4 + ld a, 4 ; MBC30 bank used by JP Crystal; inaccessible by MBC3 call GetSRAMBank - ld hl, $a603 + ld hl, $a603 ; address of MBC30 bank ld bc, $8 call CopyBytes - ld hl, $a007 + ld hl, $a007 ; address of MBC30 bank ld bc, $c call CopyBytes call CloseSRAM @@ -1580,7 +1580,7 @@ Function1057d7: ; 1057d7 (41:57d7) ld a, BANK(MysteryGiftJP_GFX) lb bc, 4, 0 call FarCopyBytes - ld hl, MysteryGiftJP_GFX + $400 + ld hl, MysteryGiftJP_GFX + $40 tiles ld de, vTiles0 tile $00 ld a, BANK(MysteryGiftJP_GFX) ld bc, $80 @@ -1656,9 +1656,9 @@ Function1057d7: ; 1057d7 (41:57d7) ld [hl], $3c hlcoord 17, 15 ld [hl], $3e - ld de, Sprites + ld de, Sprite01 ld hl, .OAM_data - ld bc, $40 + ld bc, 16 * SPRITEOAMSTRUCT_LENGTH call CopyBytes call EnableLCD call WaitBGMap @@ -1713,22 +1713,22 @@ Function1057d7: ; 1057d7 (41:57d7) ; 1058f0 (41:58f0) .OAM_data: ; 1058f0 - dsprite 2, 1, 6, 4, $00, $00 - dsprite 2, 1, 7, 4, $01, $00 - dsprite 2, 1, 8, 4, $02, $00 - dsprite 2, 1, 9, 4, $03, $00 - dsprite 3, 1, 6, 4, $04, $00 - dsprite 3, 1, 7, 4, $05, $00 - dsprite 3, 1, 8, 4, $06, $00 - dsprite 3, 1, 9, 4, $07, $00 - dsprite 0, 1, 11, 4, $00, $00 - dsprite 0, 1, 12, 4, $01, $00 - dsprite 0, 1, 13, 4, $02, $00 - dsprite 0, 1, 14, 4, $03, $00 - dsprite 1, 1, 11, 4, $04, $00 - dsprite 1, 1, 12, 4, $05, $00 - dsprite 1, 1, 13, 4, $06, $00 - dsprite 1, 1, 14, 4, $07, $00 + dsprite 2, 1, 6, 4, $00, 0 + dsprite 2, 1, 7, 4, $01, 0 + dsprite 2, 1, 8, 4, $02, 0 + dsprite 2, 1, 9, 4, $03, 0 + dsprite 3, 1, 6, 4, $04, 0 + dsprite 3, 1, 7, 4, $05, 0 + dsprite 3, 1, 8, 4, $06, 0 + dsprite 3, 1, 9, 4, $07, 0 + dsprite 0, 1, 11, 4, $00, 0 + dsprite 0, 1, 12, 4, $01, 0 + dsprite 0, 1, 13, 4, $02, 0 + dsprite 0, 1, 14, 4, $03, 0 + dsprite 1, 1, 11, 4, $04, 0 + dsprite 1, 1, 12, 4, $05, 0 + dsprite 1, 1, 13, 4, $06, 0 + dsprite 1, 1, 14, 4, $07, 0 ; japanese mystery gift gfx MysteryGiftJP_GFX: ; 105930 diff --git a/engine/mystery_gift_2.asm b/engine/mystery_gift_2.asm index 1d180f714..72767aa17 100755 --- a/engine/mystery_gift_2.asm +++ b/engine/mystery_gift_2.asm @@ -29,7 +29,7 @@ PrepMysteryGiftDataToSend: ; 2c642 (b:4642) inc de ; wc80f call CloseSRAM call Random - and $1 + and 1 ld [de], a inc de ; wc810 call .RandomSample @@ -59,10 +59,10 @@ PrepMysteryGiftDataToSend: ; 2c642 (b:4642) .RandomSample: ; 2c6ac (b:46ac) push de call Random - cp $19 ; 10 percent + cp 10 percent jr c, .tenpercent call Random - and $7 + and %111 ld d, a rl d ld e, $80 @@ -80,10 +80,10 @@ PrepMysteryGiftDataToSend: ; 2c642 (b:4642) .tenpercent call Random - cp $32 ; 20 percent + cp 20 percent - 1 jr c, .twopercent call Random - and $3 + and %011 ld d, a rl d ld e, $80 @@ -102,7 +102,7 @@ PrepMysteryGiftDataToSend: ; 2c642 (b:4642) .twopercent call Random - cp $32 ; 50 ; 20 percent + cp 20 percent - 1 jr c, .pointfourpercent ld a, b swap a @@ -147,6 +147,6 @@ MysteryGiftFallbackItem: ; 2c722 (b:4722) ; 2c725 (b:4725) -INCLUDE "data/mystery_gift_items.asm" +INCLUDE "data/items/mystery_gift_items.asm" -INCLUDE "data/mystery_gift_decos.asm" +INCLUDE "data/decorations/mystery_gift_decos.asm" diff --git a/engine/namingscreen.asm b/engine/namingscreen.asm index 177f06f73..f16f7176f 100755 --- a/engine/namingscreen.asm +++ b/engine/namingscreen.asm @@ -1,3 +1,9 @@ +NAMINGSCREEN_CURSOR EQU $7e + +NAMINGSCREEN_BORDER EQUS "\"<BLACK>\"" ; $60 +NAMINGSCREEN_MIDDLELINE EQUS "\"→\"" ; $eb +NAMINGSCREEN_UNDERLINE EQUS "\"<DOT>\"" ; $f2 + _NamingScreen: ; 0x116b7 call DisableSpriteUpdates call NamingScreen @@ -103,7 +109,7 @@ NamingScreen: ; 116c1 inc de hlcoord 5, 4 call PlaceString - farcall GetGender + farcall Predef_GetGender jr c, .genderless ld a, "♂" jr nz, .place_gender @@ -176,7 +182,7 @@ NamingScreen: ; 116c1 .Box: ; 117f5 (4:57f5) ld de, PokeBallSpriteGFX ld hl, vTiles0 tile $00 - lb bc, BANK(PokeBallSpriteGFX), $4 + lb bc, BANK(PokeBallSpriteGFX), 4 call Request2bpp xor a ld hl, wSpriteAnimDict @@ -287,7 +293,7 @@ NamingScreen_InitText: ; 118a8 call WaitTop hlcoord 0, 0 ld bc, SCREEN_WIDTH * SCREEN_HEIGHT - ld a, $60 + ld a, NAMINGSCREEN_BORDER call ByteFill hlcoord 1, 1 lb bc, 6, 18 @@ -490,7 +496,7 @@ NamingScreenJoypadLoop: ; 11915 ret .select - ld hl, wcf64 + ld hl, wNamingScreenLetterCase ld a, [hl] xor 1 ld [hl], a @@ -562,14 +568,14 @@ NamingScreen_AnimateCursor: ; 11a3b (4:5a3b) .ok cp d ld de, .LetterEntries - ld a, $0 + ld a, SPRITE_ANIM_FRAMESET_TEXT_ENTRY_CURSOR - SPRITE_ANIM_FRAMESET_TEXT_ENTRY_CURSOR ; 0 jr nz, .ok2 ld de, .CaseDelEnd - ld a, $1 + ld a, SPRITE_ANIM_FRAMESET_TEXT_ENTRY_CURSOR_BIG - SPRITE_ANIM_FRAMESET_TEXT_ENTRY_CURSOR ; 1 .ok2 ld hl, SPRITEANIMSTRUCT_0E add hl, bc - add [hl] + add [hl] ; default SPRITE_ANIM_FRAMESET_TEXT_ENTRY_CURSOR ld hl, SPRITEANIMSTRUCT_FRAMESET_ID add hl, bc ld [hl], a @@ -729,7 +735,7 @@ NamingScreen_AdvanceCursor_CheckEndOfString: ; 11b27 ld a, [hl] cp "@" jr z, .end_of_string - ld [hl], $f2 + ld [hl], NAMINGSCREEN_UNDERLINE and a ret @@ -739,7 +745,7 @@ NamingScreen_AdvanceCursor_CheckEndOfString: ; 11b27 ; 11b39 (4:5b39) -; XXX +; unused ld a, [wNamingScreenCurrNameLength] and a ret z @@ -765,21 +771,7 @@ NamingScreen_AdvanceCursor_CheckEndOfString: ; 11b27 ; 11b56 -Dakutens: ; Dummied out - db "かが", "きぎ", "くぐ", "けげ", "こご" - db "さざ", "しじ", "すず", "せぜ", "そぞ" - db "ただ", "ちぢ", "つづ", "てで", "とど" - db "はば", "ひび", "ふぶ", "へべ", "ほぼ" - db "カガ", "キギ", "クグ", "ケゲ", "コゴ" - db "サザ", "シジ", "スズ", "セゼ", "ソゾ" - db "タダ", "チヂ", "ツヅ", "テデ", "トド" - db "ハバ", "ヒビ", "フブ", "へべ", "ホボ" - db $ff - -Handakutens: ; Dummied out - db "はぱ", "ひぴ", "ふぷ", "へぺ", "ほぽ" - db "ハパ", "ヒピ", "フプ", "へぺ", "ホポ" - db $ff +INCLUDE "data/unused_text/dakutens.asm" ; 11bbc @@ -790,12 +782,12 @@ NamingScreen_DeleteCharacter: ; 11bbc (4:5bbc) ret z dec [hl] call NamingScreen_GetTextCursorPosition - ld [hl], $f2 + ld [hl], NAMINGSCREEN_UNDERLINE inc hl ld a, [hl] - cp $f2 + cp NAMINGSCREEN_UNDERLINE ret nz - ld [hl], $eb + ld [hl], NAMINGSCREEN_MIDDLELINE ret NamingScreen_GetTextCursorPosition: ; 11bd0 (4:5bd0) @@ -814,17 +806,17 @@ NamingScreen_GetTextCursorPosition: ; 11bd0 (4:5bd0) ; 11be0 NamingScreen_InitNameEntry: ; 11be0 -; load $f2, ($eb * [wNamingScreenMaxNameLength]), $50 into the dw address at wNamingScreenDestinationPointer +; load NAMINGSCREEN_UNDERLINE, (NAMINGSCREEN_MIDDLELINE * [wNamingScreenMaxNameLength]), "@" into the dw address at wNamingScreenDestinationPointer ld hl, wNamingScreenDestinationPointer ld a, [hli] ld h, [hl] ld l, a - ld [hl], $f2 + ld [hl], NAMINGSCREEN_UNDERLINE inc hl ld a, [wNamingScreenMaxNameLength] dec a ld c, a - ld a, $eb + ld a, NAMINGSCREEN_MIDDLELINE .loop ld [hli], a dec c @@ -843,9 +835,9 @@ NamingScreen_StoreEntry: ; 11bf7 (4:5bf7) ld c, a .loop ld a, [hl] - cp $eb + cp NAMINGSCREEN_MIDDLELINE jr z, .terminator - cp $f2 + cp NAMINGSCREEN_UNDERLINE jr nz, .not_terminator .terminator ld [hl], "@" @@ -905,22 +897,22 @@ LoadNamingScreenGFX: ; 11c51 call LoadFontsExtra ld de, NamingScreenGFX_MiddleLine - ld hl, vTiles1 tile $6b + ld hl, vTiles0 tile NAMINGSCREEN_MIDDLELINE lb bc, BANK(NamingScreenGFX_MiddleLine), 1 call Get1bpp ld de, NamingScreenGFX_UnderLine - ld hl, vTiles1 tile $72 + ld hl, vTiles0 tile NAMINGSCREEN_UNDERLINE lb bc, BANK(NamingScreenGFX_UnderLine), 1 call Get1bpp - ld de, vTiles2 tile $60 + ld de, vTiles2 tile NAMINGSCREEN_BORDER ld hl, NamingScreenGFX_Border ld bc, 1 tiles ld a, BANK(NamingScreenGFX_Border) call FarCopyBytes - ld de, vTiles0 tile $7e + ld de, vTiles0 tile NAMINGSCREEN_CURSOR ld hl, NamingScreenGFX_Cursor ld bc, 2 tiles ld a, BANK(NamingScreenGFX_Cursor) @@ -929,14 +921,14 @@ LoadNamingScreenGFX: ; 11c51 ld a, $5 ld hl, wSpriteAnimDict + 9 * 2 ld [hli], a - ld [hl], $7e + ld [hl], NAMINGSCREEN_CURSOR xor a ld [hSCY], a ld [wGlobalAnimYOffset], a ld [hSCX], a ld [wGlobalAnimXOffset], a ld [wJumptableIndex], a - ld [wcf64], a + ld [wNamingScreenLetterCase], a ld [hBGMapMode], a ld [wNamingScreenCurrNameLength], a ld a, $7 @@ -1033,15 +1025,15 @@ _ComposeMailMessage: ; 11e75 (mail?) ld e, [hl] inc hl ld d, [hl] - ld hl, $10 + ld hl, MAIL_LINE_LENGTH add hl, de - ld [hl], $4e + ld [hl], "<NEXT>" ret ; 11ef4 (4:5ef4) .MailIcon: ; 11ef4 -INCBIN "gfx/icon/mail2.2bpp" +INCBIN "gfx/icons/mail2.2bpp" ; 11f74 .initwNamingScreenMaxNameLength ; 11f74 (4:5f74) @@ -1051,7 +1043,7 @@ INCBIN "gfx/icon/mail2.2bpp" ; 11f7a (4:5f7a) -.Dummy: ; dummied out +.UnusedString11f7a: db "メールを かいてね@" ; 11f84 @@ -1060,7 +1052,7 @@ INCBIN "gfx/icon/mail2.2bpp" call WaitTop hlcoord 0, 0 ld bc, 6 * SCREEN_WIDTH - ld a, $60 ; border + ld a, NAMINGSCREEN_BORDER call ByteFill hlcoord 0, 6 ld bc, 12 * SCREEN_WIDTH @@ -1190,13 +1182,13 @@ INCBIN "gfx/icon/mail2.2bpp" jr c, .start ld hl, wNamingScreenCurrNameLength ld a, [hl] - cp $10 + cp MAIL_LINE_LENGTH ret nz inc [hl] call NamingScreen_GetTextCursorPosition - ld [hl], $f2 + ld [hl], NAMINGSCREEN_UNDERLINE dec hl - ld [hl], $4e + ld [hl], "<NEXT>" ret .start @@ -1216,13 +1208,13 @@ INCBIN "gfx/icon/mail2.2bpp" call NamingScreen_DeleteCharacter ld hl, wNamingScreenCurrNameLength ld a, [hl] - cp $10 + cp MAIL_LINE_LENGTH ret nz dec [hl] call NamingScreen_GetTextCursorPosition - ld [hl], $f2 + ld [hl], NAMINGSCREEN_UNDERLINE inc hl - ld [hl], $4e + ld [hl], "<NEXT>" ret .finished @@ -1232,9 +1224,9 @@ INCBIN "gfx/icon/mail2.2bpp" ret .select - ld hl, wcf64 + ld hl, wNamingScreenLetterCase ld a, [hl] - xor $1 + xor 1 ld [hl], a jr nz, .switch_to_lowercase ld de, MailEntry_Uppercase @@ -1434,7 +1426,7 @@ MailComposition_TryAddLastCharacter: ; 121ac (4:61ac) ; 121b2 (4:61b2) -; XXX +; unused ld a, [wNamingScreenCurrNameLength] and a ret z diff --git a/engine/npc_movement.asm b/engine/npc_movement.asm index a2508e0f6..71583408e 100755 --- a/engine/npc_movement.asm +++ b/engine/npc_movement.asm @@ -70,14 +70,14 @@ Function6f07: ; 6f07 ld e, [hl] ld hl, OBJECT_PALETTE add hl, bc - bit 7, [hl] + bit OAM_PRIORITY, [hl] jp nz, Function6fa1 ld hl, OBJECT_NEXT_TILE add hl, bc ld a, [hl] ld d, a call GetTileCollision - and a ; land + and a ; LANDTILE jr z, Function6f3e scf ret @@ -106,7 +106,7 @@ Function6f3e: ; 6f3e ld hl, OBJECT_DIRECTION_WALKING add hl, bc ld a, [hl] - and 3 + maskbits NUM_DIRECTIONS +- 1 ld e, a ld d, 0 ld hl, .data_6f5b @@ -131,7 +131,7 @@ Function6f5f: ; 6f5f push af ld hl, OBJECT_DIRECTION_WALKING add hl, bc - and 3 + maskbits NUM_DIRECTIONS +- 1 ld e, a ld d, 0 ld hl, .data_6f7b @@ -178,49 +178,49 @@ Function6fa1: ; 6fa1 ld hl, OBJECT_DIRECTION_WALKING add hl, bc ld a, [hl] - and 3 - jr z, .asm_6fb2 + maskbits NUM_DIRECTIONS +- 1 + jr z, .down dec a - jr z, .asm_6fb7 + jr z, .up dec a - jr z, .asm_6fbb - jr .asm_6fbf + jr z, .left + jr .right -.asm_6fb2 +.down inc e push de inc d - jr .asm_6fc2 + jr .continue -.asm_6fb7 +.up push de inc d - jr .asm_6fc2 + jr .continue -.asm_6fbb +.left push de inc e - jr .asm_6fc2 + jr .continue -.asm_6fbf +.right inc d push de inc e -.asm_6fc2 +.continue call GetCoordTile call GetTileCollision pop de - and a ; land - jr nz, .asm_6fd7 + and a ; LANDTILE + jr nz, .not_land call GetCoordTile call GetTileCollision - and a ; land - jr nz, .asm_6fd7 + and a ; LANDTILE + jr nz, .not_land xor a ret -.asm_6fd7 +.not_land scf ret ; 6fd9 @@ -279,7 +279,7 @@ WillObjectBumpIntoSomeoneElse: ; 7009 jr IsNPCAtCoord ; 7015 -Function7015: ; unreferenced +Unreferenced_Function7015: ld a, [hMapObjectIndexBuffer] call GetObjectStruct call .CheckWillBeFacingNPC @@ -482,7 +482,7 @@ IsObjectMovingOffEdgeOfScreen: ; 70ed ret ; 7113 -Function7113: ; unreferenced +Unreferenced_Function7113: ld a, [PlayerStandingMapX] ld d, a ld a, [PlayerStandingMapY] diff --git a/engine/npctrade.asm b/engine/npctrade.asm index 1455dce62..7e3fa4683 100755 --- a/engine/npctrade.asm +++ b/engine/npctrade.asm @@ -1,11 +1,3 @@ -; Trade dialogs - const_def - const TRADE_INTRO - const TRADE_CANCEL - const TRADE_WRONG - const TRADE_COMPLETE - const TRADE_AFTER - NPCTrade:: ; fcba8 ld a, e ld [wJumptableIndex], a @@ -67,7 +59,7 @@ NPCTrade:: ; fcba8 push af ld a, [wcf64] push af - predef TradeAnimation + predef Predef_TradeAnimation pop af ld [wcf64], a pop af @@ -83,17 +75,17 @@ CheckTradeGender: ; fcc23 ld e, TRADE_GENDER call GetTradeAttribute ld a, [hl] - and a + and a ; TRADE_EITHER_GENDER jr z, .matching - cp 1 + cp TRADE_MALE_ONLY jr z, .check_male - farcall GetGender + farcall Predef_GetGender jr nz, .not_matching jr .matching .check_male - farcall GetGender + farcall Predef_GetGender jr z, .not_matching .matching @@ -109,7 +101,7 @@ TradeFlagAction: ; fcc4a ld hl, wTradeFlags ld a, [wJumptableIndex] ld c, a - predef FlagPredef + predef Predef_SmallFarFlagAction ld a, c and a ret @@ -178,10 +170,10 @@ DoNPCTrade: ; fcc63 ld e, TRADE_DIALOG call GetTradeAttribute ld a, [hl] - cp 3 - ld a, 1 + cp TRADE_DIALOG_GIRL + ld a, CAUGHT_BY_GIRL jr c, .okay - ld a, 2 + ld a, CAUGHT_BY_BOY .okay ld [wOTTrademonCaughtData], a @@ -196,7 +188,7 @@ DoNPCTrade: ; fcc63 ld [MonType], a ld [wPokemonWithdrawDepositParameter], a callfar RemoveMonFromPartyOrBox - predef TryAddMonToParty + predef Predef_TryAddMonToParty ld e, TRADE_DIALOG call GetTradeAttribute @@ -332,8 +324,7 @@ CopyTradeName: ; fcdf4 ret ; fcdfb -Functionfcdfb: ; fcdfb -; unreferenced +Unreferenced_Functionfcdfb: ; fcdfb ld bc, 4 call CopyBytes ld a, "@" @@ -341,8 +332,7 @@ Functionfcdfb: ; fcdfb ret ; fce05 -Functionfce05: ; fce05 -; unreferenced +Unreferenced_Functionfce05: ; fce05 ld bc, 3 call CopyBytes ld a, "@" @@ -400,7 +390,7 @@ GetTradeMonNames: ; fce1b and a ret z - cp 1 + cp TRADE_MALE_ONLY ld a, "♂" jr z, .done ld a, "♀" @@ -433,31 +423,28 @@ PrintTradeText: ; fcf38 ; fcf53 TradeTexts: ; fcf53 -; intro +; entries correspond to TRADE_* × TRADE_DIALOG_* constants +; TRADE_INTRO dw TradeIntroText1 dw TradeIntroText2 dw TradeIntroText3 dw TradeIntroText4 - -; cancel +; TRADE_CANCEL dw TradeCancelText1 dw TradeCancelText2 dw TradeCancelText3 dw TradeCancelText4 - -; wrong mon +; TRADE_WRONG dw TradeWrongText1 dw TradeWrongText2 dw TradeWrongText3 dw TradeWrongText4 - -; completed +; TRADE_COMPLETE dw TradeCompleteText1 dw TradeCompleteText2 dw TradeCompleteText3 dw TradeCompleteText4 - -; after +; TRADE_AFTER dw TradeAfterText1 dw TradeAfterText2 dw TradeAfterText3 diff --git a/engine/overworld.asm b/engine/overworld.asm index 68b8adaed..4c379711d 100755 --- a/engine/overworld.asm +++ b/engine/overworld.asm @@ -23,7 +23,7 @@ Function14146: ; mobile push af res 7, [hl] set 6, [hl] - call MapCallbackSprites_LoadUsedSpritesGFX + call Special_LoadUsedSpritesGFX pop af ld [wSpriteFlags], a ret @@ -35,15 +35,15 @@ Function14157: ; mobile push af set 7, [hl] res 6, [hl] - call MapCallbackSprites_LoadUsedSpritesGFX + call Special_LoadUsedSpritesGFX pop af ld [wSpriteFlags], a ret ; 14168 -RefreshSprites:: ; 14168 +Special_RefreshSprites:: ; 14168 call .Refresh - call MapCallbackSprites_LoadUsedSpritesGFX + call Special_LoadUsedSpritesGFX ret ; 1416f @@ -77,7 +77,7 @@ GetPlayerSprite: ; 14183 cp c jr z, .good inc hl - cp $ff + cp -1 jr nz, .loop ; Any player state not in the array defaults to Chris's sprite. @@ -100,14 +100,14 @@ GetPlayerSprite: ; 14183 db PLAYER_BIKE, SPRITE_CHRIS_BIKE db PLAYER_SURF, SPRITE_SURF db PLAYER_SURF_PIKA, SPRITE_SURFING_PIKACHU - db $ff + db -1 ; end .Kris: db PLAYER_NORMAL, SPRITE_KRIS db PLAYER_BIKE, SPRITE_KRIS_BIKE db PLAYER_SURF, SPRITE_SURF db PLAYER_SURF_PIKA, SPRITE_SURFING_PIKACHU - db $ff + db -1 ; end ; 141c9 @@ -164,7 +164,7 @@ AddOutdoorSprites: ; 141ee ; 14209 -MapCallbackSprites_LoadUsedSpritesGFX: ; 14209 +Special_LoadUsedSpritesGFX: ; 14209 ld a, MAPCALLBACK_SPRITES call RunMapCallback call GetUsedSprites @@ -719,10 +719,10 @@ LoadEmote:: ; 1442f ; 1444d -INCLUDE "data/emotes.asm" +INCLUDE "data/sprites/emotes.asm" -INCLUDE "data/sprite_mons.asm" +INCLUDE "data/sprites/sprite_mons.asm" INCLUDE "data/maps/outdoor_sprites.asm" -INCLUDE "data/sprites.asm" +INCLUDE "data/sprites/sprites.asm" diff --git a/engine/pack.asm b/engine/pack.asm index 3e6470faf..c013994a0 100644 --- a/engine/pack.asm +++ b/engine/pack.asm @@ -1,3 +1,17 @@ +; Pack.Jumptable and BattlePack.Jumptable indexes + const_def + const PACKSTATE_INITGFX ; 0 + const PACKSTATE_INITITEMSPOCKET ; 1 + const PACKSTATE_ITEMSPOCKETMENU ; 2 + const PACKSTATE_INITBALLSPOCKET ; 3 + const PACKSTATE_BALLSPOCKETMENU ; 4 + const PACKSTATE_INITKEYITEMSPOCKET ; 5 + const PACKSTATE_KEYITEMSPOCKETMENU ; 6 + const PACKSTATE_INITTMHMPOCKET ; 7 + const PACKSTATE_TMHMPOCKETMENU ; 8 + const PACKSTATE_QUITNOSCRIPT ; 9 + const PACKSTATE_QUITRUNSCRIPT ; 10 + Pack: ; 10000 ld hl, Options set NO_TEXT_SCROLL, [hl] @@ -28,6 +42,7 @@ Pack: ; 10000 ; 10030 .Jumptable: ; 10030 (4:4030) +; entries correspond to PACKSTATE_* constants dw .InitGFX ; 0 dw .InitItemsPocket ; 1 dw .ItemsPocketMenu ; 2 @@ -44,13 +59,13 @@ Pack: ; 10000 xor a ld [hBGMapMode], a call Pack_InitGFX - ld a, [wcf64] + ld a, [wPackJumptableIndex] ld [wJumptableIndex], a call Pack_InitColors ret .InitItemsPocket: ; 10056 (4:4056) - xor a + xor a ; ITEM_POCKET ld [wCurrPocket], a call ClearPocketList call DrawPocketName @@ -70,15 +85,15 @@ Pack: ; 10000 ld [wItemsPocketScrollPosition], a ld a, [wMenuCursorY] ld [wItemsPocketCursor], a - ld b, $7 - ld c, $3 + ld b, PACKSTATE_INITTMHMPOCKET ; left + ld c, PACKSTATE_INITBALLSPOCKET ; right call Pack_InterpretJoypad ret c call .ItemBallsKey_LoadSubmenu ret .InitKeyItemsPocket: ; 10094 (4:4094) - ld a, $2 + ld a, KEY_ITEM_POCKET ld [wCurrPocket], a call ClearPocketList call DrawPocketName @@ -98,15 +113,15 @@ Pack: ; 10000 ld [wKeyItemsPocketScrollPosition], a ld a, [wMenuCursorY] ld [wKeyItemsPocketCursor], a - ld b, $3 - ld c, $7 + ld b, PACKSTATE_INITBALLSPOCKET ; left + ld c, PACKSTATE_INITTMHMPOCKET ; right call Pack_InterpretJoypad ret c call .ItemBallsKey_LoadSubmenu ret .InitTMHMPocket: ; 100d3 (4:40d3) - ld a, $3 + ld a, TM_HM_POCKET ld [wCurrPocket], a call ClearPocketList call DrawPocketName @@ -118,8 +133,8 @@ Pack: ; 10000 .TMHMPocketMenu: ; 100e8 (4:40e8) farcall TMHMPocket - ld b, $5 - ld c, $1 + ld b, PACKSTATE_INITKEYITEMSPOCKET ; left + ld c, PACKSTATE_INITITEMSPOCKET ; right call Pack_InterpretJoypad ret c farcall _CheckTossableItem @@ -148,8 +163,7 @@ Pack: ; 10000 ; 10124 (4:4124) .MenuDataHeader1: ; 0x10124 db MENU_BACKUP_TILES ; flags - db 07, 13 ; start coords - db 11, 19 ; end coords + menu_coords 13, 7, SCREEN_WIDTH - 1, TEXTBOX_Y - 1 dw .MenuData2_1 db 1 ; default option ; 0x1012c @@ -162,7 +176,6 @@ Pack: ; 10000 ; 0x10137 .Jumptable1: ; 10137 - dw .UseItem dw QuitItemSubmenu @@ -170,8 +183,7 @@ Pack: ; 10000 .MenuDataHeader2: ; 0x1013b db MENU_BACKUP_TILES ; flags - db 05, 13 ; start coords - db 11, 19 ; end coords + menu_coords 13, 5, SCREEN_WIDTH - 1, TEXTBOX_Y - 1 dw .MenuData2_2 db 1 ; default option ; 0x10143 @@ -211,7 +223,7 @@ Pack: ; 10000 ret .InitBallsPocket: ; 10186 (4:4186) - ld a, $1 + ld a, BALL_POCKET ld [wCurrPocket], a call ClearPocketList call DrawPocketName @@ -231,8 +243,8 @@ Pack: ; 10000 ld [wBallsPocketScrollPosition], a ld a, [wMenuCursorY] ld [wBallsPocketCursor], a - ld b, $1 - ld c, $5 + ld b, PACKSTATE_INITITEMSPOCKET ; left + ld c, PACKSTATE_INITKEYITEMSPOCKET ; right call Pack_InterpretJoypad ret c call .ItemBallsKey_LoadSubmenu @@ -310,8 +322,7 @@ Pack: ; 10000 ; 10249 (4:4249) MenuDataHeader_UsableKeyItem: ; 0x10249 db MENU_BACKUP_TILES ; flags - db 01, 13 ; start coords - db 11, 19 ; end coords + menu_coords 13, 1, SCREEN_WIDTH - 1, TEXTBOX_Y - 1 dw .MenuData2 db 1 ; default option ; 0x10251 @@ -327,7 +338,6 @@ MenuDataHeader_UsableKeyItem: ; 0x10249 ; 0x1026a Jumptable_UseGiveTossRegisterQuit: ; 1026a - dw UseItem dw GiveItem dw TossMenu @@ -337,8 +347,7 @@ Jumptable_UseGiveTossRegisterQuit: ; 1026a MenuDataHeader_UsableItem: ; 0x10274 db MENU_BACKUP_TILES ; flags - db 03, 13 ; start coords - db 11, 19 ; end coords + menu_coords 13, 3, SCREEN_WIDTH - 1, TEXTBOX_Y - 1 dw .MenuData2 db 1 ; default option ; 0x1027c @@ -353,7 +362,6 @@ MenuDataHeader_UsableItem: ; 0x10274 ; 0x10291 Jumptable_UseGiveTossQuit: ; 10291 - dw UseItem dw GiveItem dw TossMenu @@ -362,8 +370,7 @@ Jumptable_UseGiveTossQuit: ; 10291 MenuDataHeader_UnusableItem: ; 0x10299 db MENU_BACKUP_TILES ; flags - db 07, 13 ; start coords - db 11, 19 ; end coords + menu_coords 13, 7, SCREEN_WIDTH - 1, TEXTBOX_Y - 1 dw .MenuData2 db 1 ; default option ; 0x102a1 @@ -376,15 +383,13 @@ MenuDataHeader_UnusableItem: ; 0x10299 ; 0x102ac Jumptable_UseQuit: ; 102ac - dw UseItem dw QuitItemSubmenu ; 102b0 MenuDataHeader_UnusableKeyItem: ; 0x102b0 db MENU_BACKUP_TILES ; flags - db 05, 13 ; start coords - db 11, 19 ; end coords + menu_coords 13, 5, SCREEN_WIDTH - 1, TEXTBOX_Y - 1 dw .MenuData2 db 1 ; default option ; 0x102b8 @@ -398,7 +403,6 @@ MenuDataHeader_UnusableKeyItem: ; 0x102b0 ; 0x102c7 Jumptable_UseRegisterQuit: ; 102c7 - dw UseItem dw RegisterItem dw QuitItemSubmenu @@ -406,8 +410,7 @@ Jumptable_UseRegisterQuit: ; 102c7 MenuDataHeader_HoldableKeyItem: ; 0x102cd db MENU_BACKUP_TILES ; flags - db 03, 13 ; start coords - db 11, 19 ; end coords + menu_coords 13, 3, SCREEN_WIDTH - 1, TEXTBOX_Y - 1 dw .MenuData2 db 1 ; default option ; 0x102d5 @@ -422,7 +425,6 @@ MenuDataHeader_HoldableKeyItem: ; 0x102cd ; 0x102ea Jumptable_GiveTossRegisterQuit: ; 102ea - dw GiveItem dw TossMenu dw RegisterItem @@ -431,8 +433,7 @@ Jumptable_GiveTossRegisterQuit: ; 102ea MenuDataHeader_HoldableItem: ; 0x102f2 db MENU_BACKUP_TILES ; flags - db 05, 13 ; start coords - db 11, 19 ; end coords + menu_coords 13, 5, SCREEN_WIDTH - 1, TEXTBOX_Y - 1 dw .MenuData2 db 1 ; default option ; 0x102fa @@ -446,7 +447,6 @@ MenuDataHeader_HoldableItem: ; 0x102f2 ; 0x1030b Jumptable_GiveTossQuit: ; 1030b - dw GiveItem dw TossMenu dw QuitItemSubmenu @@ -462,14 +462,14 @@ UseItem: ; 10311 ; 1031f .dw ; 1031f (4:431f) - +; entries correspond to ITEMMENU_* constants + dw .Oak ; ITEMMENU_NOUSE dw .Oak dw .Oak dw .Oak - dw .Oak - dw .Current - dw .Party - dw .Field + dw .Current ; ITEMMENU_CURRENT + dw .Party ; ITEMMENU_PARTY + dw .Field ; ITEMMENU_CLOSE ; 1035c .Oak: ; 1032d (4:432d) @@ -503,7 +503,7 @@ UseItem: ; 10311 ld a, [wItemEffectSucceeded] and a jr z, .Oak - ld a, $a + ld a, PACKSTATE_QUITRUNSCRIPT ld [wJumptableIndex], a ret ; 10364 (4:4364) @@ -534,14 +534,13 @@ TossMenu: ; 10364 ret ; 1039d -ResetPocketCursorPositions: ; 1039d -; unreferenced +Unreferenced_ResetPocketCursorPositions: ; 1039d ld a, [wCurrPocket] - and a + and a ; ITEM_POCKET jr z, .items - dec a + dec a ; BALL_POCKET jr z, .balls - dec a + dec a ; KEY_ITEM_POCKET jr z, .key ret @@ -626,7 +625,7 @@ GiveItem: ; 103fd .give ld a, [wJumptableIndex] push af - ld a, [wcf64] + ld a, [wPackJumptableIndex] push af call GetCurNick ld hl, StringBuffer1 @@ -635,7 +634,7 @@ GiveItem: ; 103fd call CopyBytes call TryGiveItemToPartymon pop af - ld [wcf64], a + ld [wPackJumptableIndex], a pop af ld [wJumptableIndex], a .finish @@ -693,6 +692,7 @@ BattlePack: ; 10493 ; 104c3 .Jumptable: ; 104c3 (4:44c3) +; entries correspond to PACKSTATE_* constants dw .InitGFX ; 0 dw .InitItemsPocket ; 1 dw .ItemsPocketMenu ; 2 @@ -709,13 +709,13 @@ BattlePack: ; 10493 xor a ld [hBGMapMode], a call Pack_InitGFX - ld a, [wcf64] + ld a, [wPackJumptableIndex] ld [wJumptableIndex], a call Pack_InitColors ret .InitItemsPocket: ; 104e9 (4:44e9) - xor a + xor a ; ITEM_POCKET ld [wCurrPocket], a call ClearPocketList call DrawPocketName @@ -735,15 +735,15 @@ BattlePack: ; 10493 ld [wItemsPocketScrollPosition], a ld a, [wMenuCursorY] ld [wItemsPocketCursor], a - ld b, $7 - ld c, $3 + ld b, PACKSTATE_INITTMHMPOCKET ; left + ld c, PACKSTATE_INITBALLSPOCKET ; right call Pack_InterpretJoypad ret c call ItemSubmenu ret .InitKeyItemsPocket: ; 10527 (4:4527) - ld a, $2 + ld a, KEY_ITEM_POCKET ld [wCurrPocket], a call ClearPocketList call DrawPocketName @@ -763,15 +763,15 @@ BattlePack: ; 10493 ld [wKeyItemsPocketScrollPosition], a ld a, [wMenuCursorY] ld [wKeyItemsPocketCursor], a - ld b, $3 - ld c, $7 + ld b, PACKSTATE_INITBALLSPOCKET ; left + ld c, PACKSTATE_INITTMHMPOCKET ; right call Pack_InterpretJoypad ret c call ItemSubmenu ret .InitTMHMPocket: ; 10566 (4:4566) - ld a, $3 + ld a, TM_HM_POCKET ld [wCurrPocket], a call ClearPocketList call DrawPocketName @@ -785,8 +785,8 @@ BattlePack: ; 10493 .TMHMPocketMenu: ; 10581 (4:4581) farcall TMHMPocket - ld b, $5 - ld c, $1 + ld b, PACKSTATE_INITKEYITEMSPOCKET ; left + ld c, PACKSTATE_INITITEMSPOCKET ; right call Pack_InterpretJoypad ret c xor a @@ -794,7 +794,7 @@ BattlePack: ; 10493 ret .InitBallsPocket: ; 10594 (4:4594) - ld a, $1 + ld a, BALL_POCKET ld [wCurrPocket], a call ClearPocketList call DrawPocketName @@ -814,8 +814,8 @@ BattlePack: ; 10493 ld [wBallsPocketScrollPosition], a ld a, [wMenuCursorY] ld [wBallsPocketCursor], a - ld b, $1 - ld c, $5 + ld b, PACKSTATE_INITITEMSPOCKET ; left + ld c, PACKSTATE_INITKEYITEMSPOCKET ; right call Pack_InterpretJoypad ret c call ItemSubmenu @@ -848,15 +848,14 @@ TMHMSubmenu: ; 105dc (4:45dc) ; 10601 (4:4601) .UsableMenuDataHeader: ; 0x10601 - db $40 ; flags - db 07, 13 ; start coords - db 11, 19 ; end coords + db MENU_BACKUP_TILES ; flags + menu_coords 13, 7, SCREEN_WIDTH - 1, TEXTBOX_Y - 1 dw .UsableMenuData2 db 1 ; default option ; 0x10609 .UsableMenuData2: ; 0x10609 - db $c0 ; flags + db STATICMENU_CURSOR | STATICMENU_NO_TOP_SPACING ; flags db 2 ; items db "USE@" db "QUIT@" @@ -868,15 +867,14 @@ TMHMSubmenu: ; 105dc (4:45dc) ; 10618 .UnusableMenuDataHeader: ; 0x10618 - db $40 ; flags - db 09, 13 ; start coords - db 11, 19 ; end coords + db MENU_BACKUP_TILES ; flags + menu_coords 13, 9, SCREEN_WIDTH - 1, TEXTBOX_Y - 1 dw .UnusableMenuData2 db 1 ; default option ; 0x10620 .UnusableMenuData2: ; 0x10620 - db $c0 ; flags + db STATICMENU_CURSOR | STATICMENU_NO_TOP_SPACING ; flags db 1 ; items db "QUIT@" ; 0x10627 @@ -893,13 +891,14 @@ TMHMSubmenu: ; 105dc (4:45dc) ret .ItemFunctionJumptable: ; 10637 (4:4637) +; entries correspond to ITEMMENU_* constants + dw .Oak ; ITEMMENU_NOUSE dw .Oak dw .Oak dw .Oak - dw .Oak - dw .Unused - dw .BattleField - dw .BattleOnly + dw .Unused ; ITEMMENU_CURRENT + dw .BattleField ; ITEMMENU_PARTY + dw .BattleOnly ; ITEMMENU_CLOSE .Oak: ; 10645 (4:4645) ld hl, Text_ThisIsntTheTime @@ -937,7 +936,7 @@ TMHMSubmenu: ; 105dc (4:45dc) cp $2 jr z, .didnt_use_item .quit_run_script ; 1067e (4:467e) - ld a, 10 + ld a, PACKSTATE_QUITRUNSCRIPT ld [wJumptableIndex], a ret @@ -953,15 +952,16 @@ TMHMSubmenu: ; 105dc (4:45dc) InitPackBuffers: ; 1068a xor a ld [wJumptableIndex], a + ; pocket id -> jumptable index ld a, [wLastPocket] - and $3 + maskbits NUM_POCKETS +- 1 ld [wCurrPocket], a inc a add a dec a - ld [wcf64], a - xor a - ld [wcf66], a + ld [wPackJumptableIndex], a + xor a ; FALSE + ld [wPackUsedItem], a xor a ld [wSwitchItem], a ret @@ -970,10 +970,10 @@ InitPackBuffers: ; 1068a DepositSellInitPackBuffers: ; 106a5 xor a ld [hBGMapMode], a - ld [wJumptableIndex], a - ld [wcf64], a - ld [wCurrPocket], a - ld [wcf66], a + ld [wJumptableIndex], a ; PACKSTATE_INITGFX + ld [wPackJumptableIndex], a ; PACKSTATE_INITGFX + ld [wCurrPocket], a ; ITEM_POCKET + ld [wPackUsedItem], a ld [wSwitchItem], a call Pack_InitGFX call Pack_InitColors @@ -997,13 +997,14 @@ DepositSellPack: ; 106be ; 106d1 .Jumptable: ; 106d1 (4:46d1) +; entries correspond to *_POCKET constants dw .ItemsPocket dw .BallsPocket dw .KeyItemsPocket dw .TMHMPocket .ItemsPocket: ; 106d9 (4:46d9) - xor a + xor a ; ITEM_POCKET call InitPocket ld hl, PC_Mart_ItemsPocketMenuDataHeader call CopyMenuDataHeader @@ -1019,7 +1020,7 @@ DepositSellPack: ; 106be ret .KeyItemsPocket: ; 106ff (4:46ff) - ld a, 2 + ld a, KEY_ITEM_POCKET call InitPocket ld hl, PC_Mart_KeyItemsPocketMenuDataHeader call CopyMenuDataHeader @@ -1035,7 +1036,7 @@ DepositSellPack: ; 106be ret .TMHMPocket: ; 10726 (4:4726) - ld a, 3 + ld a, TM_HM_POCKET call InitPocket call WaitBGMap_DrawPackGFX farcall TMHMPocket @@ -1044,7 +1045,7 @@ DepositSellPack: ; 106be ret .BallsPocket: ; 1073b (4:473b) - ld a, 1 + ld a, BALL_POCKET call InitPocket ld hl, PC_Mart_BallsPocketMenuDataHeader call CopyMenuDataHeader @@ -1085,20 +1086,20 @@ DepositSellTutorial_InterpretJoypad: ; 1076f .a_button ld a, TRUE - ld [wcf66], a + ld [wPackUsedItem], a and a ret .b_button - xor a - ld [wcf66], a + xor a ; FALSE + ld [wPackUsedItem], a and a ret .d_left ld a, [wJumptableIndex] dec a - and $3 + maskbits NUM_POCKETS +- 1 ld [wJumptableIndex], a push de ld de, SFX_SWITCH_POCKETS @@ -1110,7 +1111,7 @@ DepositSellTutorial_InterpretJoypad: ; 1076f .d_right ld a, [wJumptableIndex] inc a - and $3 + maskbits NUM_POCKETS +- 1 ld [wJumptableIndex], a push de ld de, SFX_SWITCH_POCKETS @@ -1130,8 +1131,8 @@ TutorialPack: ; 107bb call .RunJumptable call DepositSellTutorial_InterpretJoypad jr c, .loop - xor a - ld [wcf66], a + xor a ; FALSE + ld [wPackUsedItem], a ret ; 107d7 @@ -1144,28 +1145,27 @@ TutorialPack: ; 107bb ; 107e1 .dw ; 107e1 (4:47e1) - +; entries correspond to *_POCKET constants dw .Items dw .Balls dw .KeyItems dw .TMHM .Items: ; 107e9 (4:47e9) - xor a + xor a ; ITEM_POCKET ld hl, .ItemsMenuDataHeader jr .DisplayPocket ; 107ef (4:47ef) .ItemsMenuDataHeader: ; 0x107ef - db $40 ; flags - db 01, 07 ; start coords - db 11, 19 ; end coords + db MENU_BACKUP_TILES ; flags + menu_coords 7, 1, SCREEN_WIDTH - 1, TEXTBOX_Y - 1 dw .ItemsMenuData2 db 1 ; default option ; 0x107f7 .ItemsMenuData2: ; 0x107f7 - db $ae ; flags + db STATICMENU_ENABLE_SELECT | STATICMENU_ENABLE_LEFT_RIGHT | STATICMENU_ENABLE_START | STATICMENU_WRAP | STATICMENU_CURSOR ; flags db 5, 8 ; rows, columns db 2 ; horizontal spacing dbw 0, wDudeNumItems @@ -1175,21 +1175,20 @@ TutorialPack: ; 107bb ; 10807 .KeyItems: ; 10807 (4:4807) - ld a, 2 + ld a, KEY_ITEM_POCKET ld hl, .KeyItemsMenuDataHeader jr .DisplayPocket ; 1080e (4:480e) .KeyItemsMenuDataHeader: ; 0x1080e - db $40 ; flags - db 01, 07 ; start coords - db 11, 19 ; end coords + db MENU_BACKUP_TILES ; flags + menu_coords 7, 1, SCREEN_WIDTH - 1, TEXTBOX_Y - 1 dw .KeyItemsMenuData2 db 1 ; default option ; 0x10816 .KeyItemsMenuData2: ; 0x10816 - db $ae ; flags + db STATICMENU_ENABLE_SELECT | STATICMENU_ENABLE_LEFT_RIGHT | STATICMENU_ENABLE_START | STATICMENU_WRAP | STATICMENU_CURSOR ; flags db 5, 8 ; rows, columns db 1 ; horizontal spacing dbw 0, wDudeNumKeyItems @@ -1199,7 +1198,7 @@ TutorialPack: ; 107bb ; 10826 .TMHM: ; 10826 (4:4826) - ld a, 3 + ld a, TM_HM_POCKET call InitPocket call WaitBGMap_DrawPackGFX farcall TMHMPocket @@ -1208,21 +1207,20 @@ TutorialPack: ; 107bb ret .Balls: ; 1083b (4:483b) - ld a, 1 + ld a, BALL_POCKET ld hl, .BallsMenuDataHeader jr .DisplayPocket ; 10842 (4:4842) .BallsMenuDataHeader: ; 0x10842 - db $40 ; flags - db 01, 07 ; start coords - db 11, 19 ; end coords + db MENU_BACKUP_TILES ; flags + menu_coords 7, 1, SCREEN_WIDTH - 1, TEXTBOX_Y - 1 dw .BallsMenuData2 db 1 ; default option ; 0x1084a .BallsMenuData2: ; 0x1084a - db $ae ; flags + db STATICMENU_ENABLE_SELECT | STATICMENU_ENABLE_LEFT_RIGHT | STATICMENU_ENABLE_START | STATICMENU_WRAP | STATICMENU_CURSOR ; flags db 5, 8 ; rows, columns db 2 ; horizontal spacing dbw 0, wDudeNumBalls @@ -1258,15 +1256,15 @@ Pack_GetJumptablePointer: ; 1086b Pack_QuitNoScript: ; 10874 (4:4874) ld hl, wJumptableIndex set 7, [hl] - xor a - ld [wcf66], a + xor a ; FALSE + ld [wPackUsedItem], a ret Pack_QuitRunScript: ; 1087e (4:487e) ld hl, wJumptableIndex set 7, [hl] ld a, TRUE - ld [wcf66], a + ld [wPackUsedItem], a ret Pack_PrintTextNoScroll: ; 10889 (4:4889) @@ -1283,7 +1281,7 @@ WaitBGMap_DrawPackGFX: ; 1089a (4:489a) call WaitBGMap DrawPackGFX: ; 1089d ld a, [wCurrPocket] - and $3 + maskbits NUM_POCKETS +- 1 ld e, a ld d, $0 ld a, [BattleType] @@ -1310,10 +1308,10 @@ DrawPackGFX: ; 1089d ; 108cc PackGFXPointers: ; 108cc - dw PackGFX + (15 tiles) * 1 - dw PackGFX + (15 tiles) * 3 - dw PackGFX + (15 tiles) * 0 - dw PackGFX + (15 tiles) * 2 + dw PackGFX + (15 tiles) * 1 ; ITEM_POCKET + dw PackGFX + (15 tiles) * 3 ; BALL_POCKET + dw PackGFX + (15 tiles) * 0 ; KEY_ITEM_POCKET + dw PackGFX + (15 tiles) * 2 ; TM_HM_POCKET ; 108d4 Pack_InterpretJoypad: ; 108d4 (4:48d4) @@ -1344,7 +1342,7 @@ Pack_InterpretJoypad: ; 108d4 (4:48d4) ret .b_button - ld a, 9 + ld a, PACKSTATE_QUITNOSCRIPT ld [wJumptableIndex], a scf ret @@ -1352,7 +1350,7 @@ Pack_InterpretJoypad: ; 108d4 (4:48d4) .d_left ld a, b ld [wJumptableIndex], a - ld [wcf64], a + ld [wPackJumptableIndex], a push de ld de, SFX_SWITCH_POCKETS call PlaySFX @@ -1363,7 +1361,7 @@ Pack_InterpretJoypad: ; 108d4 (4:48d4) .d_right ld a, c ld [wJumptableIndex], a - ld [wcf64], a + ld [wPackJumptableIndex], a push de ld de, SFX_SWITCH_POCKETS call PlaySFX @@ -1489,15 +1487,19 @@ DrawPocketName: ; 109bb ; 109e1 .tilemap ; 109e1 +; ITEM_POCKET db $00, $04, $04, $04, $01 ; top border db $06, $07, $08, $09, $0a ; Items db $02, $05, $05, $05, $03 ; bottom border +; BALL_POCKET db $00, $04, $04, $04, $01 ; top border db $15, $16, $17, $18, $19 ; Balls db $02, $05, $05, $05, $03 ; bottom border +; KEY_ITEM_POCKET db $00, $04, $04, $04, $01 ; top border db $0b, $0c, $0d, $0e, $0f ; Key Items db $02, $05, $05, $05, $03 ; bottom border +; TM_HM_POCKET db $00, $04, $04, $04, $01 ; top border db $10, $11, $12, $13, $14 ; TM/HM db $02, $05, $05, $05, $03 ; bottom border @@ -1511,8 +1513,7 @@ Pack_GetItemName: ; 10a1d ret ; 10a2a -Pack_ClearTilemap: ; 10a2a -; unreferenced +Unreferenced_Pack_ClearTilemap: ; 10a2a hlcoord 0, 0 ld bc, SCREEN_WIDTH * SCREEN_HEIGHT ld a, " " @@ -1536,15 +1537,14 @@ Pack_InitColors: ; 10a40 ; 10a4f ItemsPocketMenuDataHeader: ; 0x10a4f - db $40 ; flags - db 01, 07 ; start coords - db 11, 19 ; end coords + db MENU_BACKUP_TILES ; flags + menu_coords 7, 1, SCREEN_WIDTH - 1, TEXTBOX_Y - 1 dw .MenuData2 db 1 ; default option ; 0x10a57 .MenuData2: ; 0x10a57 - db $ae ; flags + db STATICMENU_ENABLE_SELECT | STATICMENU_ENABLE_LEFT_RIGHT | STATICMENU_ENABLE_START | STATICMENU_WRAP | STATICMENU_CURSOR ; flags db 5, 8 ; rows, columns db 2 ; horizontal spacing dbw 0, NumItems @@ -1554,15 +1554,14 @@ ItemsPocketMenuDataHeader: ; 0x10a4f ; 10a67 PC_Mart_ItemsPocketMenuDataHeader: ; 0x10a67 - db $40 ; flags - db 01, 07 ; start coords - db 11, 19 ; end coords + db MENU_BACKUP_TILES ; flags + menu_coords 7, 1, SCREEN_WIDTH - 1, TEXTBOX_Y - 1 dw .MenuData2 db 1 ; default option ; 0x10a6f .MenuData2: ; 0x10a6f - db $2e ; flags + db STATICMENU_ENABLE_SELECT | STATICMENU_ENABLE_LEFT_RIGHT | STATICMENU_ENABLE_START | STATICMENU_WRAP ; flags db 5, 8 ; rows, columns db 2 ; horizontal spacing dbw 0, NumItems @@ -1572,15 +1571,14 @@ PC_Mart_ItemsPocketMenuDataHeader: ; 0x10a67 ; 10a7f KeyItemsPocketMenuDataHeader: ; 0x10a7f - db $40 ; flags - db 01, 07 ; start coords - db 11, 19 ; end coords + db MENU_BACKUP_TILES ; flags + menu_coords 7, 1, SCREEN_WIDTH - 1, TEXTBOX_Y - 1 dw .MenuData2 db 1 ; default option ; 0x10a87 .MenuData2: ; 0x10a87 - db $ae ; flags + db STATICMENU_ENABLE_SELECT | STATICMENU_ENABLE_LEFT_RIGHT | STATICMENU_ENABLE_START | STATICMENU_WRAP | STATICMENU_CURSOR ; flags db 5, 8 ; rows, columns db 1 ; horizontal spacing dbw 0, NumKeyItems @@ -1590,15 +1588,14 @@ KeyItemsPocketMenuDataHeader: ; 0x10a7f ; 10a97 PC_Mart_KeyItemsPocketMenuDataHeader: ; 0x10a97 - db $40 ; flags - db 01, 07 ; start coords - db 11, 19 ; end coords + db MENU_BACKUP_TILES ; flags + menu_coords 7, 1, SCREEN_WIDTH - 1, TEXTBOX_Y - 1 dw .MenuData2 db 1 ; default option ; 0x10a9f .MenuData2: ; 0x10a9f - db $2e ; flags + db STATICMENU_ENABLE_SELECT | STATICMENU_ENABLE_LEFT_RIGHT | STATICMENU_ENABLE_START | STATICMENU_WRAP ; flags db 5, 8 ; rows, columns db 1 ; horizontal spacing dbw 0, NumKeyItems @@ -1608,15 +1605,14 @@ PC_Mart_KeyItemsPocketMenuDataHeader: ; 0x10a97 ; 10aaf BallsPocketMenuDataHeader: ; 0x10aaf - db $40 ; flags - db 01, 07 ; start coords - db 11, 19 ; end coords + db MENU_BACKUP_TILES ; flags + menu_coords 7, 1, SCREEN_WIDTH - 1, TEXTBOX_Y - 1 dw .MenuData2 db 1 ; default option ; 0x10ab7 .MenuData2: ; 0x10ab7 - db $ae ; flags + db STATICMENU_ENABLE_SELECT | STATICMENU_ENABLE_LEFT_RIGHT | STATICMENU_ENABLE_START | STATICMENU_WRAP | STATICMENU_CURSOR ; flags db 5, 8 ; rows, columns db 2 ; horizontal spacing dbw 0, NumBalls @@ -1626,15 +1622,14 @@ BallsPocketMenuDataHeader: ; 0x10aaf ; 10ac7 PC_Mart_BallsPocketMenuDataHeader: ; 0x10ac7 - db $40 ; flags - db 01, 07 ; start coords - db 11, 19 ; end coords + db MENU_BACKUP_TILES ; flags + menu_coords 7, 1, SCREEN_WIDTH - 1, TEXTBOX_Y - 1 dw .MenuData2 db 1 ; default option ; 0x10acf .MenuData2: ; 0x10acf - db $2e ; flags + db STATICMENU_ENABLE_SELECT | STATICMENU_ENABLE_LEFT_RIGHT | STATICMENU_ENABLE_START | STATICMENU_WRAP ; flags db 5, 8 ; rows, columns db 2 ; horizontal spacing dbw 0, NumBalls @@ -1710,7 +1705,7 @@ TextJump_YouCantUseItInABattle: ; 0x10b11 db "@" ; 0x10b16 -PackMenuGFX: +PackMenuGFX:: INCBIN "gfx/pack/pack_menu.2bpp" PackGFX: INCBIN "gfx/pack/pack.2bpp" diff --git a/engine/party_menu.asm b/engine/party_menu.asm index 0415e29e4..1efcfe417 100644 --- a/engine/party_menu.asm +++ b/engine/party_menu.asm @@ -50,23 +50,23 @@ WritePartyMenuTilemap: ; 0x5005f ld hl, Options ld a, [hl] push af - set 4, [hl] ; Disable text delay + set NO_TEXT_SCROLL, [hl] xor a ld [hBGMapMode], a hlcoord 0, 0 ld bc, SCREEN_WIDTH * SCREEN_HEIGHT ld a, " " call ByteFill ; blank the tilemap - call GetPartyMenuTilemapPointers ; This reads from a pointer table??? + call GetPartyMenuQualityIndexes .loop ld a, [hli] - cp $ff - jr z, .end ; 0x5007a $8 + cp -1 + jr z, .end push hl ld hl, .Jumptable rst JumpTable pop hl - jr .loop ; 0x50082 $f3 + jr .loop .end pop af ld [Options], a @@ -74,6 +74,7 @@ WritePartyMenuTilemap: ; 0x5005f ; 0x50089 .Jumptable: ; 50089 +; entries correspond to PARTYMENUQUALITY_* constants dw PlacePartyNicknames dw PlacePartyHPBar dw PlacePartyMenuHPDigits @@ -188,7 +189,7 @@ PlacePartymonHPBar: ; 50117 ld d, a ld a, [hli] ld e, a - predef ComputeHPBarPixels + predef Predef_ComputeHPBarPixels ret ; 50138 @@ -297,7 +298,7 @@ PlacePartyMonStatus: ; 501b2 ld e, l ld d, h pop hl - call PlaceStatusString + call Predef_PlaceStatusString .next pop hl @@ -329,7 +330,7 @@ PlacePartyMonTMHMCompatibility: ; 501e0 add hl, de ld a, [hl] ld [CurPartySpecies], a - predef CanLearnTMHMMove + predef Predef_CanLearnTMHMMove pop hl call .PlaceAbleNotAble call PlaceString @@ -468,7 +469,7 @@ PlacePartyMonGender: ; 502b1 ld [CurPartyMon], a xor a ld [MonType], a - call GetGender + call Predef_GetGender ld de, .unknown jr c, .got_gender ld de, .male @@ -598,7 +599,7 @@ PartyMenuCheckEgg: ; 50389 ret ; 50396 -GetPartyMenuTilemapPointers: ; 50396 +GetPartyMenuQualityIndexes: ; 50396 ld a, [PartyMenuActionText] and $f0 jr nz, .skip @@ -606,7 +607,7 @@ GetPartyMenuTilemapPointers: ; 50396 and $f ld e, a ld d, 0 - ld hl, .Pointers + ld hl, PartyMenuQualityPointers add hl, de add hl, de ld a, [hli] @@ -615,29 +616,11 @@ GetPartyMenuTilemapPointers: ; 50396 ret .skip - ld hl, .Default + ld hl, PartyMenuQualityPointers.Default ret ; 503b2 -.Pointers: ; 503b2 - dw .Default - dw .Default - dw .Default - dw .TMHM - dw .Default - dw .EvoStone - dw .Gender - dw .Gender - dw .Default - dw .Mobile -; 503c6 - -.Default: db 0, 1, 2, 3, 4, $ff -.TMHM: db 0, 5, 3, 4, $ff -.EvoStone: db 0, 6, 3, 4, $ff -.Gender: db 0, 7, 3, 4, $ff -.Mobile: db 0, 8, 3, 4, $ff -; 503e0 +INCLUDE "data/party_menu_qualities.asm" InitPartyMenuGFX: ; 503e0 @@ -817,25 +800,33 @@ PartyMenuStrings: ; 0x504d2 ChooseAMonString: ; 0x504e4 db "Choose a #MON.@" + UseOnWhichPKMNString: ; 0x504f3 db "Use on which <PK><MN>?@" + WhichPKMNString: ; 0x50504 db "Which <PK><MN>?@" + TeachWhichPKMNString: ; 0x5050e db "Teach which <PK><MN>?@" + MoveToWhereString: ; 0x5051e db "Move to where?@" -ChooseAFemalePKMNString: ; 0x5052d ; UNUSED + +ChooseAFemalePKMNString: ; 0x5052d +; unused db "Choose a ♀<PK><MN>.@" -ChooseAMalePKMNString: ; 0x5053b ; UNUSED + +ChooseAMalePKMNString: ; 0x5053b +; unused db "Choose a ♂<PK><MN>.@" + ToWhichPKMNString: ; 0x50549 db "To which <PK><MN>?@" YouHaveNoPKMNString: ; 0x50556 db "You have no <PK><MN>!@" - PrintPartyMenuActionText: ; 50566 ld a, [CurPartyMon] ld hl, PartyMonNicknames diff --git a/engine/phone/buenas_password.asm b/engine/phone/buenas_password.asm index 858ce5540..0d144afa6 100644 --- a/engine/phone/buenas_password.asm +++ b/engine/phone/buenas_password.asm @@ -167,4 +167,4 @@ BuenaPhoneScript_Random1: end ; a0c28 -INCLUDE "text/phone/buena.asm" +INCLUDE "data/phone/text/buena.asm" diff --git a/engine/phone/generic_calls.asm b/engine/phone/generic_calls.asm index e1b53a950..937fc67c0 100644 --- a/engine/phone/generic_calls.asm +++ b/engine/phone/generic_calls.asm @@ -1240,7 +1240,7 @@ PhoneScript_Generic_Female: end PhoneScript_MonFlavorText: - special RandomPhoneMon + special Special_RandomPhoneMon farscall PhoneScript_Random2 if_equal $0, .TooEnergetic farwritetext UnknownText_0x1b518b diff --git a/engine/phone/phone.asm b/engine/phone/phone.asm index 53bb519b3..be18c569e 100644 --- a/engine/phone/phone.asm +++ b/engine/phone/phone.asm @@ -75,20 +75,20 @@ GetRemainingSpaceInPhoneList: ; 90040 cp -1 jr z, .done cp c - jr z, .elm_or_mom + jr z, .continue + push bc push hl ld c, a call _CheckCellNum - jr c, .elm_or_mom_in_list + jr c, .permanent ld hl, Buffer1 inc [hl] - -.elm_or_mom_in_list +.permanent pop hl pop bc -.elm_or_mom +.continue jr .loop .done @@ -98,9 +98,7 @@ GetRemainingSpaceInPhoneList: ; 90040 ret ; 90066 -PermanentNumbers: ; 90066 - db PHONECONTACT_MOM, PHONECONTACT_ELM, -1 -; 90069 +INCLUDE "data/phone/permanent_numbers.asm" FarPlaceString: ; 90069 @@ -439,7 +437,7 @@ WrongNumber: ; 90233 ; 90241 Script_ReceivePhoneCall: ; 0x90241 - refreshscreen $0 + refreshscreen callasm RingTwice_StartCall ptcall wPhoneScriptPointer waitbutton @@ -471,7 +469,7 @@ UnknownScript_0x90261: ; 0x90261 RingTwice_StartCall: ; 9026f call .Ring call .Ring - farcall TrainerRankings_PhoneCalls + farcall StubbedTrainerRankings_PhoneCalls ret ; 9027c @@ -500,7 +498,7 @@ PhoneCall:: ; 9029a ld [PhoneCaller + 1], a call Phone_FirstOfTwoRings call Phone_FirstOfTwoRings - farcall TrainerRankings_PhoneCalls + farcall StubbedTrainerRankings_PhoneCalls ret ; 902b3 @@ -761,9 +759,9 @@ GetCallerLocation: ; 90439 ; 9045f -INCLUDE "data/phone_contacts.asm" +INCLUDE "data/phone/phone_contacts.asm" -INCLUDE "data/phone_special.asm" +INCLUDE "data/phone/special_calls.asm" UnknownScript_0x90657: ; 0x90657 diff --git a/engine/phone/phone_callers.asm b/engine/phone/phone_callers.asm index c90448d33..cb333ae8d 100644 --- a/engine/phone/phone_callers.asm +++ b/engine/phone/phone_callers.asm @@ -1,5 +1,5 @@ Phone_GenericCall_Male: - special RandomPhoneMon + special Special_RandomPhoneMon farscall PhoneScript_Random2 if_equal 0, .Bragging farscall PhoneScript_Generic_Male @@ -9,7 +9,7 @@ Phone_GenericCall_Male: farjump Phone_BraggingCall_Male Phone_GenericCall_Female: - special RandomPhoneMon + special Special_RandomPhoneMon farscall PhoneScript_Random2 if_equal 0, .Bragging farscall PhoneScript_Generic_Female @@ -27,7 +27,7 @@ Phone_BraggingCall_Female: farjump Phone_FoundAMon_Female Phone_FoundAMon_Male: - special RandomPhoneWildMon + special Special_RandomPhoneWildMon farscall PhoneScript_Random2 if_equal 0, .GotAway farscall Phone_WhoDefeatedMon_Male @@ -37,7 +37,7 @@ Phone_FoundAMon_Male: farjump Phone_GotAwayCall_Male Phone_FoundAMon_Female: - special RandomPhoneWildMon + special Special_RandomPhoneWildMon farscall PhoneScript_Random2 if_equal 0, .GotAway farscall Phone_WhoDefeatedMon_Female @@ -851,7 +851,7 @@ Phone_CheckIfUnseenRare_Female: farjump PhoneScript_HangupText_Female PhoneScriptRareWildMon: - special RandomUnseenWildMon + special Special_RandomUnseenWildMon end PhoneScript_BugCatchingContest: diff --git a/engine/phone/phone_scripts.asm b/engine/phone/phone_scripts.asm index 62eb4ac87..646040641 100644 --- a/engine/phone/phone_scripts.asm +++ b/engine/phone/phone_scripts.asm @@ -20,10 +20,10 @@ MomPhoneScript: ; 0xbceaa iftrue MomPhoneHangUpScript farwritetext MomPhoneGreetingText buttonsound - mapnametotext $0 + mapnametotext MEM_BUFFER_0 checkcode VAR_ROOFPALETTE - if_equal $1, MomPhonePalette1 - if_equal $2, MomPhonePalette2 + if_equal 1, MomPhonePalette1 + if_equal 2, MomPhonePalette2 jump MomPhoneOther MomPhoneLandmark: ; 0xbcedf @@ -53,13 +53,13 @@ MomPhonePalette1: ; 0xbcee7 jump MomSavingMoney .violet ; 0xbcf15 - landmarktotext SPROUT_TOWER, 1 + landmarktotext SPROUT_TOWER, MEM_BUFFER_1 jump MomPhoneLandmark .azalea ; 0xbcf1b - landmarktotext SLOWPOKE_WELL, 1 + landmarktotext SLOWPOKE_WELL, MEM_BUFFER_1 jump MomPhoneLandmark .goldenrod ; 0xbcf21 - landmarktotext RADIO_TOWER, 1 + landmarktotext RADIO_TOWER, MEM_BUFFER_1 jump MomPhoneLandmark MomPhonePalette2: ; 0xbcf27 @@ -75,17 +75,17 @@ MomPhoneOther: ; 0xbcf2f MomSavingMoney: ; 0xbcf37 checkflag ENGINE_MOM_SAVING_MONEY iffalse MomIsNotSaving - checkmoney $1, 0 - if_equal $0, MomSavingHasMoney + checkmoney MOMS_MONEY, 0 + if_equal HAVE_MORE, MomSavingHasMoney jump MomSavingButBroke MomIsNotSaving: ; 0xbcf49 - checkmoney $1, 0 - if_equal $0, MomHasMoney + checkmoney MOMS_MONEY, 0 + if_equal HAVE_MORE, MomHasMoney jump MomHasNoMoney MomSavingHasMoney: ; 0xbcf55 - readmoney $1, $0 + readmoney MOMS_MONEY, MEM_BUFFER_0 farwritetext MomCheckBalanceText yesorno iftrue MomPhoneSaveMoneyScript @@ -104,7 +104,7 @@ MomHasNoMoney: ; 0xbcf6e jump MomPhoneWontSaveMoneyScript MomHasMoney: ; 0xbcf79 - readmoney $1, $0 + readmoney MOMS_MONEY, MEM_BUFFER_0 farwritetext MomYouveSavedText yesorno iftrue MomPhoneSaveMoneyScript @@ -172,9 +172,9 @@ BillPhoneScript1: ; 0xbcfc5 farwritetext BillPhoneGeneriText buttonsound checkcode VAR_BOXSPACE - RAM2MEM $0 - if_equal $0, .full - if_less_than $6, .nearlyfull + vartomem MEM_BUFFER_0 + if_equal 0, .full + if_less_than PARTY_LENGTH, .nearlyfull farwritetext BillPhoneNotFullText end @@ -195,7 +195,7 @@ BillPhoneScript2: ; 0xbd007 ElmPhoneScript1: ; 0xbd00d checkcode VAR_SPECIALPHONECALL - if_equal $1, .pokerus + if_equal SPECIALCALL_POKERUS, .pokerus checkevent EVENT_SHOWED_TOGEPI_TO_ELM iftrue .discovery checkevent EVENT_GOT_TOGEPI_EGG_FROM_ELMS_AIDE @@ -242,8 +242,8 @@ ElmPhoneScript1: ; 0xbd00d end .discovery ; 0xbd069 - random $2 - if_equal $0, .nextdiscovery + random 2 + if_equal 0, .nextdiscovery farwritetext ElmPhoneDiscovery1Text end @@ -258,11 +258,11 @@ ElmPhoneScript1: ; 0xbd00d ElmPhoneScript2: ; 0xbd081 checkcode VAR_SPECIALPHONECALL - if_equal $2, .disaster - if_equal $3, .assistant - if_equal $4, .rocket - if_equal $5, .gift - if_equal $8, .gift + if_equal SPECIALCALL_ROBBED, .disaster + if_equal SPECIALCALL_ASSISTANT, .assistant + if_equal SPECIALCALL_WEIRDBROADCAST, .rocket + if_equal SPECIALCALL_SSTICKET, .gift + if_equal SPECIALCALL_MASTERBALL, .gift farwritetext ElmPhonePokerusText specialphonecall SPECIALCALL_NONE end @@ -299,7 +299,7 @@ ElmPhoneScript2: ; 0xbd081 ; Jack JackPhoneScript1: - trainertotext SCHOOLBOY, JACK1, $0 + trainertotext SCHOOLBOY, JACK1, MEM_BUFFER_0 checkflag ENGINE_JACK iftrue .WantsBattle farscall PhoneScript_AnswerPhone_Male @@ -314,31 +314,31 @@ JackPhoneScript1: farjump JackPhoneTips .WantsBattle: - landmarktotext NATIONAL_PARK, $2 + landmarktotext NATIONAL_PARK, MEM_BUFFER_2 farjump JackWantsBattleScript JackPhoneScript2: - trainertotext SCHOOLBOY, JACK1, $0 + trainertotext SCHOOLBOY, JACK1, MEM_BUFFER_0 farscall PhoneScript_GreetPhone_Male farscall PhoneScript_Random2 - if_equal $0, JackBattleTrivia + if_equal 0, JackBattleTrivia checkflag ENGINE_JACK iftrue .WaitingForBattle checkflag ENGINE_JACK_MONDAY_MORNING iftrue .WaitingForBattle farscall PhoneScript_Random2 - if_equal $0, JackWantsToBattle + if_equal 0, JackWantsToBattle .WaitingForBattle: farscall PhoneScript_Random3 - if_equal $0, JackFindsRare + if_equal 0, JackFindsRare farjump Phone_GenericCall_Male JackMondayMorning: setflag ENGINE_JACK_MONDAY_MORNING JackWantsToBattle: - landmarktotext NATIONAL_PARK, $2 + landmarktotext NATIONAL_PARK, MEM_BUFFER_2 setflag ENGINE_JACK farjump PhoneScript_WantsToBattle_Male @@ -351,36 +351,36 @@ JackBattleTrivia: ; Beverly BeverlyPhoneScript1: - trainertotext POKEFANF, BEVERLY1, $0 + trainertotext POKEFANF, BEVERLY1, MEM_BUFFER_0 farscall PhoneScript_AnswerPhone_Female checkflag ENGINE_BEVERLY_HAS_NUGGET iftrue .HasNugget farjump UnknownScript_0xa0900 .HasNugget: - landmarktotext NATIONAL_PARK, $2 + landmarktotext NATIONAL_PARK, MEM_BUFFER_2 farjump UnknownScript_0xa0aa5 BeverlyPhoneScript2: - trainertotext POKEFANF, BEVERLY1, $0 + trainertotext POKEFANF, BEVERLY1, MEM_BUFFER_0 farscall PhoneScript_GreetPhone_Female checkflag ENGINE_BEVERLY_HAS_NUGGET iftrue .HasNugget farscall PhoneScript_Random4 - if_equal $0, .FoundNugget + if_equal 0, .FoundNugget .HasNugget: farjump Phone_GenericCall_Female .FoundNugget: setflag ENGINE_BEVERLY_HAS_NUGGET - landmarktotext NATIONAL_PARK, $2 + landmarktotext NATIONAL_PARK, MEM_BUFFER_2 farjump PhoneScript_FoundItem_Female ; Huey HueyPhoneScript1: - trainertotext SAILOR, HUEY1, $0 + trainertotext SAILOR, HUEY1, MEM_BUFFER_0 checkflag ENGINE_HUEY iftrue .WantsBattle farscall PhoneScript_AnswerPhone_Male @@ -392,23 +392,23 @@ HueyPhoneScript1: iftrue HueyWednesdayNight .NotWednesday: - special RandomPhoneMon + special Special_RandomPhoneMon farjump UnknownScript_0xa0908 .WantsBattle: - landmarktotext LIGHTHOUSE, $2 + landmarktotext LIGHTHOUSE, MEM_BUFFER_2 farjump HueyWantsBattleScript HueyPhoneScript2: - trainertotext SAILOR, HUEY1, $0 + trainertotext SAILOR, HUEY1, MEM_BUFFER_0 farscall PhoneScript_GreetPhone_Male checkflag ENGINE_HUEY iftrue .Flavor checkflag ENGINE_HUEY_WEDNESDAY_NIGHT iftrue .Flavor farscall PhoneScript_Random3 - if_equal $0, HueyWantsBattle - if_equal $1, HueyWantsBattle + if_equal 0, HueyWantsBattle + if_equal 1, HueyWantsBattle .Flavor: farjump PhoneScript_MonFlavorText @@ -417,14 +417,14 @@ HueyWednesdayNight: setflag ENGINE_HUEY_WEDNESDAY_NIGHT HueyWantsBattle: - landmarktotext LIGHTHOUSE, $2 + landmarktotext LIGHTHOUSE, MEM_BUFFER_2 setflag ENGINE_HUEY farjump PhoneScript_WantsToBattle_Male ; Gaven GavenPhoneScript1: - trainertotext COOLTRAINERM, GAVEN3, $0 + trainertotext COOLTRAINERM, GAVEN3, MEM_BUFFER_0 checkflag ENGINE_GAVEN iftrue .WantsBattle farscall PhoneScript_AnswerPhone_Male @@ -439,29 +439,29 @@ GavenPhoneScript1: farjump UnknownScript_0xa0910 .WantsBattle: - landmarktotext ROUTE_26, $2 + landmarktotext ROUTE_26, MEM_BUFFER_2 farjump UnknownScript_0xa0a37 GavenPhoneScript2: - trainertotext COOLTRAINERM, GAVEN3, $0 + trainertotext COOLTRAINERM, GAVEN3, MEM_BUFFER_0 farscall PhoneScript_GreetPhone_Male checkflag ENGINE_GAVEN iftrue .WaitingForBattle checkflag ENGINE_GAVEN_THURSDAY_MORNING iftrue .WaitingForBattle farscall PhoneScript_Random2 - if_equal $0, GavenWantsRematch + if_equal 0, GavenWantsRematch .WaitingForBattle: farscall PhoneScript_Random3 - if_equal $0, GavenFoundRare + if_equal 0, GavenFoundRare farjump Phone_GenericCall_Male GavenThursdayMorning: setflag ENGINE_GAVEN_THURSDAY_MORNING GavenWantsRematch: - landmarktotext ROUTE_26, $2 + landmarktotext ROUTE_26, MEM_BUFFER_2 setflag ENGINE_GAVEN farjump PhoneScript_WantsToBattle_Male @@ -471,7 +471,7 @@ GavenFoundRare: ; Beth BethPhoneScript1: - trainertotext COOLTRAINERF, BETH1, $0 + trainertotext COOLTRAINERF, BETH1, MEM_BUFFER_0 checkflag ENGINE_BETH iftrue .WantsBattle farscall PhoneScript_AnswerPhone_Female @@ -486,18 +486,18 @@ BethPhoneScript1: farjump UnknownScript_0xa0918 .WantsBattle: - landmarktotext ROUTE_26, $2 + landmarktotext ROUTE_26, MEM_BUFFER_2 farjump BethBattleReminderScript BethPhoneScript2: - trainertotext COOLTRAINERF, BETH1, $0 + trainertotext COOLTRAINERF, BETH1, MEM_BUFFER_0 farscall PhoneScript_GreetPhone_Female checkflag ENGINE_BETH iftrue .Generic checkflag ENGINE_BETH_FRIDAY_AFTERNOON iftrue .Generic farscall PhoneScript_Random2 - if_equal $0, BethWantsBattle + if_equal 0, BethWantsBattle .Generic: farjump Phone_GenericCall_Female @@ -506,14 +506,14 @@ BethFridayAfternoon: setflag ENGINE_BETH_FRIDAY_AFTERNOON BethWantsBattle: - landmarktotext ROUTE_26, $2 + landmarktotext ROUTE_26, MEM_BUFFER_2 setflag ENGINE_BETH farjump PhoneScript_WantsToBattle_Female ; Jose JosePhoneScript1: - trainertotext BIRD_KEEPER, JOSE2, $0 + trainertotext BIRD_KEEPER, JOSE2, MEM_BUFFER_0 checkflag ENGINE_JOSE iftrue .WantsBattle farscall PhoneScript_AnswerPhone_Male @@ -530,15 +530,15 @@ JosePhoneScript1: farjump UnknownScript_0xa0920 .WantsBattle: - landmarktotext ROUTE_27, $2 + landmarktotext ROUTE_27, MEM_BUFFER_2 farjump UnknownScript_0xa0a41 .HasItem: - landmarktotext ROUTE_27, $2 + landmarktotext ROUTE_27, MEM_BUFFER_2 farjump UnknownScript_0xa0a41 JosePhoneScript2: - trainertotext BIRD_KEEPER, JOSE2, $0 + trainertotext BIRD_KEEPER, JOSE2, MEM_BUFFER_0 farscall PhoneScript_GreetPhone_Male checkflag ENGINE_JOSE iftrue .Generic @@ -547,20 +547,20 @@ JosePhoneScript2: checkflag ENGINE_JOSE_HAS_STAR_PIECE iftrue .Generic farscall PhoneScript_Random3 - if_equal $0, JoseWantsBattle + if_equal 0, JoseWantsBattle farscall PhoneScript_Random3 - if_equal $0, JoseHasStarPiece + if_equal 0, JoseHasStarPiece .Generic: farscall PhoneScript_Random3 - if_equal $0, JoseFoundRare + if_equal 0, JoseFoundRare farjump Phone_GenericCall_Male JoseSaturdayNight: setflag ENGINE_JOSE_SATURDAY_NIGHT JoseWantsBattle: - landmarktotext ROUTE_27, $2 + landmarktotext ROUTE_27, MEM_BUFFER_2 setflag ENGINE_JOSE farjump PhoneScript_WantsToBattle_Male @@ -569,13 +569,13 @@ JoseFoundRare: JoseHasStarPiece: setflag ENGINE_JOSE_HAS_STAR_PIECE - landmarktotext ROUTE_27, $2 + landmarktotext ROUTE_27, MEM_BUFFER_2 farjump PhoneScript_FoundItem_Male ; Reena ReenaPhoneScript1: - trainertotext COOLTRAINERF, REENA1, $0 + trainertotext COOLTRAINERF, REENA1, MEM_BUFFER_0 checkflag ENGINE_REENA iftrue .WantsBattle farscall PhoneScript_AnswerPhone_Female @@ -590,18 +590,18 @@ ReenaPhoneScript1: farjump UnknownScript_0xa0928 .WantsBattle: - landmarktotext ROUTE_27, $2 + landmarktotext ROUTE_27, MEM_BUFFER_2 farjump UnknownScript_0xa0a46 ReenaPhoneScript2: - trainertotext COOLTRAINERF, REENA1, $0 + trainertotext COOLTRAINERF, REENA1, MEM_BUFFER_0 farscall PhoneScript_GreetPhone_Female checkflag ENGINE_REENA iftrue .Generic checkflag ENGINE_REENA_SUNDAY_MORNING iftrue .Generic farscall PhoneScript_Random2 - if_equal $0, ReenaWantsBattle + if_equal 0, ReenaWantsBattle .Generic: farjump Phone_GenericCall_Female @@ -610,14 +610,14 @@ ReenaSundayMorning: setflag ENGINE_REENA_SUNDAY_MORNING ReenaWantsBattle: - landmarktotext ROUTE_27, $2 + landmarktotext ROUTE_27, MEM_BUFFER_2 setflag ENGINE_REENA farjump PhoneScript_WantsToBattle_Female ; Joey JoeyPhoneScript1: - trainertotext YOUNGSTER, JOEY1, $0 + trainertotext YOUNGSTER, JOEY1, MEM_BUFFER_0 checkflag ENGINE_JOEY iftrue .WantsBattle farscall PhoneScript_AnswerPhone_Male @@ -629,23 +629,23 @@ JoeyPhoneScript1: iftrue JoeyMondayAfternoon .NotMonday: - special RandomPhoneMon + special Special_RandomPhoneMon farjump UnknownScript_0xa0930 .WantsBattle: - landmarktotext ROUTE_30, $2 + landmarktotext ROUTE_30, MEM_BUFFER_2 farjump UnknownScript_0xa0a4b JoeyPhoneScript2: - trainertotext YOUNGSTER, JOEY1, $0 + trainertotext YOUNGSTER, JOEY1, MEM_BUFFER_0 farscall PhoneScript_GreetPhone_Male checkflag ENGINE_JOEY iftrue .Generic checkflag ENGINE_JOEY_MONDAY_AFTERNOON iftrue .Generic farscall PhoneScript_Random3 - if_equal $0, JoeyWantsBattle - if_equal $1, JoeyWantsBattle + if_equal 0, JoeyWantsBattle + if_equal 1, JoeyWantsBattle .Generic: farjump Phone_GenericCall_Male @@ -654,14 +654,14 @@ JoeyMondayAfternoon: setflag ENGINE_JOEY_MONDAY_AFTERNOON JoeyWantsBattle: - landmarktotext ROUTE_30, $2 + landmarktotext ROUTE_30, MEM_BUFFER_2 setflag ENGINE_JOEY farjump PhoneScript_WantsToBattle_Male ; Wade WadePhoneScript1: - trainertotext BUG_CATCHER, WADE1, $0 + trainertotext BUG_CATCHER, WADE1, MEM_BUFFER_0 checkflag ENGINE_WADE iftrue WadeWantsBattle farscall PhoneScript_AnswerPhone_Male @@ -676,7 +676,7 @@ WadePhoneScript1: .NotTuesday: farscall PhoneScript_Random2 - if_equal $0, .NoContest + if_equal 0, .NoContest checkflag ENGINE_DAILY_BUG_CONTEST iftrue .NoContest checkcode VAR_WEEKDAY @@ -691,18 +691,18 @@ WadeContestToday: farjump PhoneScript_BugCatchingContest WadeWantsBattle: - landmarktotext ROUTE_31, $2 + landmarktotext ROUTE_31, MEM_BUFFER_2 farjump UnknownScript_0xa0a50 WadeHasItem: - landmarktotext ROUTE_31, $2 + landmarktotext ROUTE_31, MEM_BUFFER_2 farjump UnknownScript_0xa0ab5 WadePhoneScript2: - trainertotext BUG_CATCHER, WADE1, $0 + trainertotext BUG_CATCHER, WADE1, MEM_BUFFER_0 farscall PhoneScript_GreetPhone_Male farscall PhoneScript_Random2 - if_equal $0, .NoContest + if_equal 0, .NoContest checkflag ENGINE_DAILY_BUG_CONTEST iftrue .NoContest checkcode VAR_WEEKDAY @@ -718,15 +718,15 @@ WadePhoneScript2: checkflag ENGINE_WADE_HAS_ITEM iftrue .next farscall PhoneScript_Random2 - if_equal $0, WadeHasItem2 + if_equal 0, WadeHasItem2 checkflag ENGINE_FLYPOINT_GOLDENROD iffalse .next farscall PhoneScript_Random2 - if_equal $0, WadeWantsBattle2 + if_equal 0, WadeWantsBattle2 .next: farscall PhoneScript_Random3 - if_equal $0, WadeFoundRare + if_equal 0, WadeFoundRare farjump Phone_GenericCall_Male Wade_ContestToday: @@ -736,7 +736,7 @@ WadeTuesdayNight: setflag ENGINE_WADE_TUESDAY_NIGHT WadeWantsBattle2: - landmarktotext ROUTE_31, $2 + landmarktotext ROUTE_31, MEM_BUFFER_2 setflag ENGINE_WADE farjump PhoneScript_WantsToBattle_Male @@ -745,16 +745,16 @@ WadeFoundRare: WadeHasItem2: setflag ENGINE_WADE_HAS_ITEM - landmarktotext ROUTE_31, $2 + landmarktotext ROUTE_31, MEM_BUFFER_2 clearevent EVENT_WADE_HAS_BERRY clearevent EVENT_WADE_HAS_PSNCUREBERRY clearevent EVENT_WADE_HAS_PRZCUREBERRY clearevent EVENT_WADE_HAS_BITTER_BERRY - random $4 - if_equal $0, .Berry - if_equal $1, .PsnCureBerry - if_equal $2, .PrzCureBerry - if_equal $3, .Bitterberry + random 4 + if_equal 0, .Berry + if_equal 1, .PsnCureBerry + if_equal 2, .PrzCureBerry + if_equal 3, .Bitterberry .Berry: setevent EVENT_WADE_HAS_BERRY @@ -777,7 +777,7 @@ WadeHasItem2: ; Ralph RalphPhoneScript1: - trainertotext FISHER, RALPH1, $0 + trainertotext FISHER, RALPH1, MEM_BUFFER_0 checkflag ENGINE_RALPH iftrue Ralph_Rematch farscall PhoneScript_AnswerPhone_Male @@ -793,15 +793,15 @@ Ralph_CheckSwarm: farjump UnknownScript_0xa0940 Ralph_Rematch: - landmarktotext ROUTE_32, $2 + landmarktotext ROUTE_32, MEM_BUFFER_2 farjump UnknownScript_0xa0a55 Ralph_ReportSwarm: - landmarktotext ROUTE_32, $2 + landmarktotext ROUTE_32, MEM_BUFFER_2 farjump UnknownScript_0xa0af5 RalphPhoneScript2: - trainertotext FISHER, RALPH1, $0 + trainertotext FISHER, RALPH1, MEM_BUFFER_0 farscall PhoneScript_GreetPhone_Male checkflag ENGINE_FLYPOINT_GOLDENROD iffalse Ralph_CheckSwarm2 @@ -810,16 +810,16 @@ RalphPhoneScript2: checkflag ENGINE_RALPH_WEDNESDAY_MORNING iftrue Ralph_CheckSwarm2 farscall PhoneScript_Random2 - if_equal $0, Ralph_FightMe + if_equal 0, Ralph_FightMe Ralph_CheckSwarm2: farscall PhoneScript_Random5 - if_equal $0, Ralph_SetUpSwarm + if_equal 0, Ralph_SetUpSwarm farjump Phone_GenericCall_Male Ralph_WednesdayMorning: setflag ENGINE_RALPH_WEDNESDAY_MORNING Ralph_FightMe: - landmarktotext ROUTE_32, $2 + landmarktotext ROUTE_32, MEM_BUFFER_2 setflag ENGINE_RALPH farjump PhoneScript_WantsToBattle_Male @@ -827,8 +827,8 @@ Ralph_SetUpSwarm: checkflag ENGINE_SPECIAL_WILDDATA iftrue .Generic setflag ENGINE_SPECIAL_WILDDATA - pokenamemem QWILFISH, $1 - landmarktotext ROUTE_32, $2 + pokenamemem QWILFISH, MEM_BUFFER_1 + landmarktotext ROUTE_32, MEM_BUFFER_2 writebyte FISHSWARM_QWILFISH special Special_ActivateFishingSwarm farjump UnknownScript_0xa05d6 @@ -839,7 +839,7 @@ Ralph_SetUpSwarm: ; Liz LizPhoneScript1: - trainertotext PICNICKER, LIZ1, $0 + trainertotext PICNICKER, LIZ1, MEM_BUFFER_0 checkflag ENGINE_LIZ iftrue .WantsBattle farscall PhoneScript_AnswerPhone_Female @@ -851,17 +851,17 @@ LizPhoneScript1: iftrue LizThursdayAfternoon .NotThursday: - special RandomPhoneMon + special Special_RandomPhoneMon farjump UnknownScript_0xa0948 .WantsBattle: - landmarktotext ROUTE_32, $2 + landmarktotext ROUTE_32, MEM_BUFFER_2 farjump UnknownScript_0xa0a5a LizPhoneScript2: - trainertotext PICNICKER, LIZ1, $0 + trainertotext PICNICKER, LIZ1, MEM_BUFFER_0 farscall PhoneScript_Random4 - if_equal $0, LizWrongNumber + if_equal 0, LizWrongNumber farscall PhoneScript_GreetPhone_Female checkflag ENGINE_LIZ iftrue .next @@ -870,11 +870,11 @@ LizPhoneScript2: .next: farscall PhoneScript_Random2 - if_equal $0, LizGossip + if_equal 0, LizGossip checkflag ENGINE_FLYPOINT_GOLDENROD iffalse .Generic farscall PhoneScript_Random2 - if_equal $0, LizWantsBattle + if_equal 0, LizWantsBattle .Generic: farjump Phone_GenericCall_Female @@ -883,7 +883,7 @@ LizThursdayAfternoon: setflag ENGINE_LIZ_THURSDAY_AFTERNOON LizWantsBattle: - landmarktotext ROUTE_32, $2 + landmarktotext ROUTE_32, MEM_BUFFER_2 setflag ENGINE_LIZ farjump PhoneScript_WantsToBattle_Female @@ -891,51 +891,51 @@ LizWrongNumber: farjump LizWrongNumberScript LizGossip: - random $9 - if_equal $0, .CoolTrainerM - if_equal $1, .Beauty - if_equal $2, .Grunt - if_equal $3, .Teacher - if_equal $4, .SwimmerF - if_equal $5, .KimonoGirl - if_equal $6, .Skier - if_equal $7, .Medium - if_equal $8, .PokefanM + random 9 + if_equal 0, .CoolTrainerM + if_equal 1, .Beauty + if_equal 2, .Grunt + if_equal 3, .Teacher + if_equal 4, .SwimmerF + if_equal 5, .KimonoGirl + if_equal 6, .Skier + if_equal 7, .Medium + if_equal 8, .PokefanM .CoolTrainerM: - trainerclassname COOLTRAINERM, $1 + trainerclassname COOLTRAINERM, NICK jump LizGossipScript .Beauty: - trainerclassname BEAUTY, $1 + trainerclassname BEAUTY, VICTORIA jump LizGossipScript .Grunt: - trainerclassname GRUNTM, $1 + trainerclassname GRUNTM, GRUNTM_1 jump LizGossipScript .Teacher: - trainerclassname TEACHER, $1 + trainerclassname TEACHER, COLETTE jump LizGossipScript .SwimmerF: - trainerclassname SWIMMERF, $1 + trainerclassname SWIMMERF, ELAINE jump LizGossipScript .KimonoGirl: - trainerclassname KIMONO_GIRL, $1 + trainerclassname KIMONO_GIRL, NAOKO1 jump LizGossipScript .Skier: - trainerclassname SKIER, $1 + trainerclassname SKIER, ROXANNE jump LizGossipScript .Medium: - trainerclassname MEDIUM, $1 + trainerclassname MEDIUM, MARTHA jump LizGossipScript .PokefanM: - trainerclassname POKEFANM, $1 + trainerclassname POKEFANM, WILLIAM jump LizGossipScript LizGossipScript: @@ -944,7 +944,7 @@ LizGossipScript: ; Anthony AnthonyPhoneScript1: - trainertotext HIKER, ANTHONY2, $0 + trainertotext HIKER, ANTHONY2, MEM_BUFFER_0 checkflag ENGINE_ANTHONY iftrue .WantsBattle farscall PhoneScript_AnswerPhone_Male @@ -961,15 +961,15 @@ AnthonyPhoneScript1: farjump UnknownScript_0xa0950 .WantsBattle: - landmarktotext ROUTE_33, $2 + landmarktotext ROUTE_33, MEM_BUFFER_2 farjump UnknownScript_0xa0a5f .AlreadySwarming: - landmarktotext ROUTE_33, $2 + landmarktotext ROUTE_33, MEM_BUFFER_2 farjump UnknownScript_0xa0afa AnthonyPhoneScript2: - trainertotext HIKER, ANTHONY2, $0 + trainertotext HIKER, ANTHONY2, MEM_BUFFER_0 farscall PhoneScript_GreetPhone_Male checkflag ENGINE_FLYPOINT_GOLDENROD iffalse .TriesSwarm @@ -978,18 +978,18 @@ AnthonyPhoneScript2: checkflag ENGINE_ANTHONY_FRIDAY_NIGHT iftrue .TriesSwarm farscall PhoneScript_Random2 - if_equal $0, AnthonyWantsBattle + if_equal 0, AnthonyWantsBattle .TriesSwarm: farscall PhoneScript_Random5 - if_equal $0, AnthonyTriesDunsparceSwarm + if_equal 0, AnthonyTriesDunsparceSwarm farjump Phone_GenericCall_Male AnthonyFridayNight: setflag ENGINE_ANTHONY_FRIDAY_NIGHT AnthonyWantsBattle: - landmarktotext ROUTE_33, $2 + landmarktotext ROUTE_33, MEM_BUFFER_2 setflag ENGINE_ANTHONY farjump PhoneScript_WantsToBattle_Male @@ -997,9 +997,9 @@ AnthonyTriesDunsparceSwarm: checkflag ENGINE_DUNSPARCE_SWARM iftrue .Generic setflag ENGINE_DUNSPARCE_SWARM - pokenamemem DUNSPARCE, $1 + pokenamemem DUNSPARCE, MEM_BUFFER_1 swarm SWARM_DUNSPARCE, DARK_CAVE_VIOLET_ENTRANCE - landmarktotext DARK_CAVE, $2 + landmarktotext DARK_CAVE, MEM_BUFFER_2 farjump UnknownScript_0xa05de .Generic: @@ -1008,7 +1008,7 @@ AnthonyTriesDunsparceSwarm: ; Todd ToddPhoneScript1: - trainertotext CAMPER, TODD1, $0 + trainertotext CAMPER, TODD1, MEM_BUFFER_0 checkflag ENGINE_TODD iftrue .WantsBattle farscall PhoneScript_AnswerPhone_Male @@ -1025,14 +1025,14 @@ ToddPhoneScript1: farjump UnknownScript_0xa0958 .WantsBattle: - landmarktotext ROUTE_34, $2 + landmarktotext ROUTE_34, MEM_BUFFER_2 farjump UnknownScript_0xa0a64 .SaleOn: farjump UnknownScript_0xa0b04 ToddPhoneScript2: - trainertotext CAMPER, TODD1, $0 + trainertotext CAMPER, TODD1, MEM_BUFFER_0 farscall PhoneScript_GreetPhone_Male checkflag ENGINE_TODD iftrue .TryForSale @@ -1041,22 +1041,22 @@ ToddPhoneScript2: checkflag ENGINE_FLYPOINT_GOLDENROD iffalse ToddNoGoldenrod farscall PhoneScript_Random2 - if_equal $0, ToddWantsBattle + if_equal 0, ToddWantsBattle .TryForSale: farscall PhoneScript_Random2 - if_equal $0, ToddDeptStoreSale + if_equal 0, ToddDeptStoreSale ToddNoGoldenrod: farscall PhoneScript_Random3 - if_equal $0, ToddFoundRare + if_equal 0, ToddFoundRare farjump Phone_GenericCall_Male ToddSaturdayMorning: setflag ENGINE_TODD_SATURDAY_MORNING ToddWantsBattle: - landmarktotext ROUTE_34, $2 + landmarktotext ROUTE_34, MEM_BUFFER_2 setflag ENGINE_TODD farjump PhoneScript_WantsToBattle_Male @@ -1070,7 +1070,7 @@ ToddDeptStoreSale: ; Gina GinaPhoneScript1: - trainertotext PICNICKER, GINA1, $0 + trainertotext PICNICKER, GINA1, MEM_BUFFER_0 checkflag ENGINE_GINA iftrue .WantsBattle farscall PhoneScript_AnswerPhone_Female @@ -1092,15 +1092,15 @@ GinaPhoneScript1: farjump UnknownScript_0xa05c6 .WantsBattle: - landmarktotext ROUTE_34, $2 + landmarktotext ROUTE_34, MEM_BUFFER_2 farjump UnknownScript_0xa0a69 .HasLeafStone: - landmarktotext ROUTE_34, $2 + landmarktotext ROUTE_34, MEM_BUFFER_2 farjump UnknownScript_0xa0abd GinaPhoneScript2: - trainertotext PICNICKER, GINA1, $0 + trainertotext PICNICKER, GINA1, MEM_BUFFER_0 farscall PhoneScript_GreetPhone_Female checkflag ENGINE_ROCKETS_IN_RADIO_TOWER iftrue GinaRockets @@ -1113,15 +1113,15 @@ GinaPhoneScript2: checkevent EVENT_GINA_GAVE_LEAF_STONE iftrue .GaveLeafStone farscall PhoneScript_Random2 - if_equal $0, GinaHasLeafStone + if_equal 0, GinaHasLeafStone .GaveLeafStone: farscall PhoneScript_Random11 - if_equal $0, GinaHasLeafStone + if_equal 0, GinaHasLeafStone checkflag ENGINE_FLYPOINT_GOLDENROD iffalse .Generic farscall PhoneScript_Random3 - if_equal $0, GinaWantsBattle + if_equal 0, GinaWantsBattle .Generic: farjump Phone_GenericCall_Female @@ -1130,7 +1130,7 @@ GinaSundayDay: setflag ENGINE_GINA_SUNDAY_AFTERNOON GinaWantsBattle: - landmarktotext ROUTE_34, $2 + landmarktotext ROUTE_34, MEM_BUFFER_2 setflag ENGINE_GINA farjump PhoneScript_WantsToBattle_Female @@ -1139,13 +1139,13 @@ GinaRockets: GinaHasLeafStone: setflag ENGINE_GINA_HAS_LEAF_STONE - landmarktotext ROUTE_34, $2 + landmarktotext ROUTE_34, MEM_BUFFER_2 farjump PhoneScript_FoundItem_Female ; Irwin IrwinPhoneScript1: - trainertotext JUGGLER, IRWIN1, $0 + trainertotext JUGGLER, IRWIN1, MEM_BUFFER_0 farscall PhoneScript_AnswerPhone_Male checkflag ENGINE_ROCKETS_IN_RADIO_TOWER iftrue .Rockets @@ -1155,7 +1155,7 @@ IrwinPhoneScript1: farjump IrwinRocketRumor IrwinPhoneScript2: - trainertotext JUGGLER, IRWIN1, $0 + trainertotext JUGGLER, IRWIN1, MEM_BUFFER_0 farscall PhoneScript_GreetPhone_Male checkflag ENGINE_ROCKETS_IN_RADIO_TOWER iftrue .Rockets @@ -1167,7 +1167,7 @@ IrwinPhoneScript2: ; Arnie ArniePhoneScript1: - trainertotext BUG_CATCHER, ARNIE1, $0 + trainertotext BUG_CATCHER, ARNIE1, MEM_BUFFER_0 checkflag ENGINE_ARNIE iftrue .WantsBattle farscall PhoneScript_AnswerPhone_Male @@ -1184,35 +1184,35 @@ ArniePhoneScript1: farjump UnknownScript_0xa0968 .WantsBattle: - landmarktotext ROUTE_35, $2 + landmarktotext ROUTE_35, MEM_BUFFER_2 farjump UnknownScript_0xa0a6e .AlreadySwarming: - landmarktotext ROUTE_35, $2 + landmarktotext ROUTE_35, MEM_BUFFER_2 farjump UnknownScript_0xa0aff ArniePhoneScript2: - trainertotext BUG_CATCHER, ARNIE1, $0 + trainertotext BUG_CATCHER, ARNIE1, MEM_BUFFER_0 farscall PhoneScript_GreetPhone_Male checkflag ENGINE_ARNIE iftrue .Swarm checkflag ENGINE_ARNIE_TUESDAY_MORNING iftrue .Swarm farscall PhoneScript_Random2 - if_equal $0, ArnieWantsBattle + if_equal 0, ArnieWantsBattle .Swarm: farscall PhoneScript_Random5 - if_equal $0, ArnieYanmaSwarm + if_equal 0, ArnieYanmaSwarm farscall PhoneScript_Random3 - if_equal $0, ArnieFoundRare + if_equal 0, ArnieFoundRare farjump Phone_GenericCall_Male ArnieTuesdayMorning: setflag ENGINE_ARNIE_TUESDAY_MORNING ArnieWantsBattle: - landmarktotext ROUTE_35, $2 + landmarktotext ROUTE_35, MEM_BUFFER_2 setflag ENGINE_ARNIE farjump PhoneScript_WantsToBattle_Male @@ -1220,9 +1220,9 @@ ArnieYanmaSwarm: ; start swarm checkflag ENGINE_YANMA_SWARM iftrue ArnieYanmaAlreadySwarming setflag ENGINE_YANMA_SWARM - pokenamemem YANMA, $1 + pokenamemem YANMA, MEM_BUFFER_1 swarm SWARM_YANMA, ROUTE_35 - landmarktotext ROUTE_35, $2 + landmarktotext ROUTE_35, MEM_BUFFER_2 farjump UnknownScript_0xa05ce ArnieFoundRare: @@ -1234,7 +1234,7 @@ ArnieYanmaAlreadySwarming: ; Alan AlanPhoneScript1: - trainertotext SCHOOLBOY, ALAN1, $0 + trainertotext SCHOOLBOY, ALAN1, MEM_BUFFER_0 checkflag ENGINE_ALAN iftrue .WantsBattle farscall PhoneScript_AnswerPhone_Male @@ -1251,15 +1251,15 @@ AlanPhoneScript1: farjump UnknownScript_0xa0970 .WantsBattle: - landmarktotext ROUTE_36, $2 + landmarktotext ROUTE_36, MEM_BUFFER_2 farjump UnknownScript_0xa0a73 .FireStone: - landmarktotext ROUTE_36, $2 + landmarktotext ROUTE_36, MEM_BUFFER_2 farjump UnknownScript_0xa0ac5 AlanPhoneScript2: - trainertotext SCHOOLBOY, ALAN1, $0 + trainertotext SCHOOLBOY, ALAN1, MEM_BUFFER_0 farscall PhoneScript_GreetPhone_Male checkflag ENGINE_ALAN iftrue AlanGenericCall @@ -1268,15 +1268,15 @@ AlanPhoneScript2: checkflag ENGINE_ALAN_HAS_FIRE_STONE iftrue AlanGenericCall farscall PhoneScript_Random3 - if_equal $0, AlanWantsBattle + if_equal 0, AlanWantsBattle checkevent EVENT_ALAN_GAVE_FIRE_STONE iftrue .FireStone farscall PhoneScript_Random2 - if_equal $0, AlanHasFireStone + if_equal 0, AlanHasFireStone .FireStone: farscall PhoneScript_Random11 - if_equal $0, AlanHasFireStone + if_equal 0, AlanHasFireStone AlanGenericCall: farjump Phone_GenericCall_Male @@ -1285,19 +1285,19 @@ AlanWednesdayDay: setflag ENGINE_ALAN_WEDNESDAY_AFTERNOON AlanWantsBattle: - landmarktotext ROUTE_36, $2 + landmarktotext ROUTE_36, MEM_BUFFER_2 setflag ENGINE_ALAN farjump PhoneScript_WantsToBattle_Male AlanHasFireStone: setflag ENGINE_ALAN_HAS_FIRE_STONE - landmarktotext ROUTE_36, $2 + landmarktotext ROUTE_36, MEM_BUFFER_2 farjump PhoneScript_FoundItem_Male ; Dana DanaPhoneScript1: - trainertotext LASS, DANA1, $0 + trainertotext LASS, DANA1, MEM_BUFFER_0 checkflag ENGINE_DANA iftrue .WantsBattle farscall PhoneScript_AnswerPhone_Female @@ -1314,15 +1314,15 @@ DanaPhoneScript1: farjump UnknownScript_0xa0978 .WantsBattle: - landmarktotext ROUTE_38, $2 + landmarktotext ROUTE_38, MEM_BUFFER_2 farjump UnknownScript_0xa0a78 .HasThunderstone: - landmarktotext ROUTE_38, $2 + landmarktotext ROUTE_38, MEM_BUFFER_2 farjump UnknownScript_0xa0acd DanaPhoneScript2: - trainertotext LASS, DANA1, $0 + trainertotext LASS, DANA1, MEM_BUFFER_0 farscall PhoneScript_GreetPhone_Female checkflag ENGINE_DANA iftrue .Generic @@ -1331,26 +1331,26 @@ DanaPhoneScript2: checkflag ENGINE_DANA_HAS_THUNDERSTONE iftrue .Generic farscall PhoneScript_Random3 - if_equal $0, DanaWantsBattle + if_equal 0, DanaWantsBattle checkevent EVENT_DANA_GAVE_THUNDERSTONE iftrue .Thunderstone farscall PhoneScript_Random2 - if_equal $0, DanaHasThunderstone + if_equal 0, DanaHasThunderstone .Thunderstone: farscall PhoneScript_Random11 - if_equal $0, DanaHasThunderstone + if_equal 0, DanaHasThunderstone .Generic: farscall PhoneScript_Random3 - if_equal $0, DanaFoundRare + if_equal 0, DanaFoundRare farjump Phone_GenericCall_Female DanaThursdayNight: setflag ENGINE_DANA_THURSDAY_NIGHT DanaWantsBattle: - landmarktotext ROUTE_38, $2 + landmarktotext ROUTE_38, MEM_BUFFER_2 setflag ENGINE_DANA farjump PhoneScript_WantsToBattle_Female @@ -1359,13 +1359,13 @@ DanaFoundRare: DanaHasThunderstone: setflag ENGINE_DANA_HAS_THUNDERSTONE - landmarktotext ROUTE_38, $2 + landmarktotext ROUTE_38, MEM_BUFFER_2 farjump PhoneScript_FoundItem_Female ; Chad ChadPhoneScript1: - trainertotext SCHOOLBOY, CHAD1, $0 + trainertotext SCHOOLBOY, CHAD1, MEM_BUFFER_0 checkflag ENGINE_CHAD iftrue .WantsBattle farscall PhoneScript_AnswerPhone_Male @@ -1380,31 +1380,31 @@ ChadPhoneScript1: farjump UnknownScript_0xa0980 .WantsBattle: - landmarktotext ROUTE_38, $2 + landmarktotext ROUTE_38, MEM_BUFFER_2 farjump UnknownScript_0xa0a7d ChadPhoneScript2: - trainertotext SCHOOLBOY, CHAD1, $0 + trainertotext SCHOOLBOY, CHAD1, MEM_BUFFER_0 farscall PhoneScript_GreetPhone_Male farscall PhoneScript_Random2 - if_equal $0, ChadOakGossip + if_equal 0, ChadOakGossip checkflag ENGINE_CHAD iftrue .Generic checkflag ENGINE_CHAD_FRIDAY_MORNING iftrue .Generic farscall PhoneScript_Random2 - if_equal $0, ChadWantsBattle + if_equal 0, ChadWantsBattle .Generic: farscall PhoneScript_Random3 - if_equal $0, ChadFoundRare + if_equal 0, ChadFoundRare farjump Phone_GenericCall_Male ChadFridayMorning: setflag ENGINE_CHAD_FRIDAY_MORNING ChadWantsBattle: - landmarktotext ROUTE_38, $2 + landmarktotext ROUTE_38, MEM_BUFFER_2 setflag ENGINE_CHAD farjump PhoneScript_WantsToBattle_Male @@ -1415,12 +1415,12 @@ ChadOakGossip: farjump ChadOakGossipScript DerekPhoneScript1: - trainertotext POKEFANM, DEREK1, $0 + trainertotext POKEFANM, DEREK1, MEM_BUFFER_0 farscall PhoneScript_AnswerPhone_Male checkflag ENGINE_DEREK_HAS_NUGGET iftrue .Nugget farscall PhoneScript_Random2 - if_equal $0, .NoContest + if_equal 0, .NoContest checkflag ENGINE_DAILY_BUG_CONTEST iftrue .NoContest checkcode VAR_WEEKDAY @@ -1435,14 +1435,14 @@ DerekPhoneScript1: farjump PhoneScript_BugCatchingContest .Nugget: - landmarktotext ROUTE_39, $2 + landmarktotext ROUTE_39, MEM_BUFFER_2 farjump UnknownScript_0xa0ad5 DerekPhoneScript2: - trainertotext POKEFANM, DEREK1, $0 + trainertotext POKEFANM, DEREK1, MEM_BUFFER_0 farscall PhoneScript_GreetPhone_Male farscall PhoneScript_Random2 - if_equal $0, .NoContest + if_equal 0, .NoContest checkflag ENGINE_DAILY_BUG_CONTEST iftrue .NoContest checkcode VAR_WEEKDAY @@ -1452,7 +1452,7 @@ DerekPhoneScript2: .NoContest: farscall PhoneScript_Random4 - if_equal $0, .Nugget + if_equal 0, .Nugget farjump Phone_GenericCall_Male .ContestToday: @@ -1460,11 +1460,11 @@ DerekPhoneScript2: .Nugget: setflag ENGINE_DEREK_HAS_NUGGET - landmarktotext ROUTE_39, $2 + landmarktotext ROUTE_39, MEM_BUFFER_2 farjump PhoneScript_FoundItem_Male TullyPhoneScript1: - trainertotext FISHER, TULLY1, $0 + trainertotext FISHER, TULLY1, MEM_BUFFER_0 checkflag ENGINE_TULLY iftrue .WantsBattle farscall PhoneScript_AnswerPhone_Male @@ -1481,15 +1481,15 @@ TullyPhoneScript1: farjump UnknownScript_0xa0990 .WantsBattle: - landmarktotext ROUTE_42, $2 + landmarktotext ROUTE_42, MEM_BUFFER_2 farjump UnknownScript_0xa0a82 TullyHasWaterStone: - landmarktotext ROUTE_42, $2 + landmarktotext ROUTE_42, MEM_BUFFER_2 farjump UnknownScript_0xa0add TullyPhoneScript2: - trainertotext FISHER, TULLY1, $0 + trainertotext FISHER, TULLY1, MEM_BUFFER_0 farscall PhoneScript_GreetPhone_Male checkflag ENGINE_TULLY iftrue .Generic @@ -1498,15 +1498,15 @@ TullyPhoneScript2: checkflag ENGINE_TULLY_HAS_WATER_STONE iftrue .Generic farscall PhoneScript_Random3 - if_equal $0, TullyWantsBattle + if_equal 0, TullyWantsBattle checkevent EVENT_TULLY_GAVE_WATER_STONE iftrue .WaterStone farscall PhoneScript_Random2 - if_equal $0, TullyFoundWaterStone + if_equal 0, TullyFoundWaterStone .WaterStone: farscall PhoneScript_Random11 - if_equal $0, TullyFoundWaterStone + if_equal 0, TullyFoundWaterStone .Generic: farjump Phone_GenericCall_Male @@ -1515,17 +1515,17 @@ TullySundayNight: setflag ENGINE_TULLY_SUNDAY_NIGHT TullyWantsBattle: - landmarktotext ROUTE_42, $2 + landmarktotext ROUTE_42, MEM_BUFFER_2 setflag ENGINE_TULLY farjump PhoneScript_WantsToBattle_Male TullyFoundWaterStone: setflag ENGINE_TULLY_HAS_WATER_STONE - landmarktotext ROUTE_42, $2 + landmarktotext ROUTE_42, MEM_BUFFER_2 farjump PhoneScript_FoundItem_Male BrentPhoneScript1: - trainertotext POKEMANIAC, BRENT1, $0 + trainertotext POKEMANIAC, BRENT1, MEM_BUFFER_0 checkflag ENGINE_BRENT iftrue .WantsBattle farscall PhoneScript_AnswerPhone_Male @@ -1540,20 +1540,20 @@ BrentPhoneScript1: farjump UnknownScript_0xa0998 .WantsBattle: - landmarktotext ROUTE_43, $2 + landmarktotext ROUTE_43, MEM_BUFFER_2 farjump UnknownScript_0xa0a87 BrentPhoneScript2: - trainertotext POKEMANIAC, BRENT1, $0 + trainertotext POKEMANIAC, BRENT1, MEM_BUFFER_0 farscall PhoneScript_GreetPhone_Male farscall PhoneScript_Random2 - if_equal $0, BrentBillTrivia + if_equal 0, BrentBillTrivia checkflag ENGINE_BRENT iftrue .Generic checkflag ENGINE_BRENT_MONDAY_MORNING iftrue .Generic farscall PhoneScript_Random2 - if_equal $0, BrentWantsBattle + if_equal 0, BrentWantsBattle .Generic: farjump Phone_GenericCall_Male @@ -1562,7 +1562,7 @@ BrentMondayMorning: setflag ENGINE_BRENT_MONDAY_MORNING BrentWantsBattle: - landmarktotext ROUTE_43, $2 + landmarktotext ROUTE_43, MEM_BUFFER_2 setflag ENGINE_BRENT farjump PhoneScript_WantsToBattle_Male @@ -1570,7 +1570,7 @@ BrentBillTrivia: farjump BrentBillTriviaScript TiffanyPhoneScript1: - trainertotext PICNICKER, TIFFANY3, $0 + trainertotext PICNICKER, TIFFANY3, MEM_BUFFER_0 checkflag ENGINE_TIFFANY iftrue .WantsBattle farscall PhoneScript_AnswerPhone_Female @@ -1587,17 +1587,17 @@ TiffanyPhoneScript1: farjump UnknownScript_0xa09a0 .WantsBattle: - landmarktotext ROUTE_43, $2 + landmarktotext ROUTE_43, MEM_BUFFER_2 farjump UnknownScript_0xa0a8c .HasItem: - landmarktotext ROUTE_43, $2 + landmarktotext ROUTE_43, MEM_BUFFER_2 farjump UnknownScript_0xa0ae5 TiffanyPhoneScript2: - trainertotext PICNICKER, TIFFANY3, $0 + trainertotext PICNICKER, TIFFANY3, MEM_BUFFER_0 farscall PhoneScript_Random4 - if_equal $0, TiffanysFamilyMembers + if_equal 0, TiffanysFamilyMembers farscall PhoneScript_GreetPhone_Female checkflag ENGINE_TIFFANY iftrue TiffanyGenericCall @@ -1606,15 +1606,15 @@ TiffanyPhoneScript2: checkflag ENGINE_TIFFANY_HAS_PINK_BOW iftrue TiffanyGenericCall farscall PhoneScript_Random3 - if_equal $0, TiffanyWantsBattle + if_equal 0, TiffanyWantsBattle checkevent EVENT_TIFFANY_GAVE_PINK_BOW iftrue .PinkBow farscall PhoneScript_Random2 - if_equal $0, TiffanyHasPinkBow + if_equal 0, TiffanyHasPinkBow .PinkBow: farscall PhoneScript_Random11 - if_equal $0, TiffanyHasPinkBow + if_equal 0, TiffanyHasPinkBow TiffanyGenericCall: farjump Phone_GenericCall_Female @@ -1623,41 +1623,41 @@ TiffanyTuesdayAfternoon: setflag ENGINE_TIFFANY_TUESDAY_AFTERNOON TiffanyWantsBattle: - landmarktotext ROUTE_43, $2 + landmarktotext ROUTE_43, MEM_BUFFER_2 setflag ENGINE_TIFFANY farjump PhoneScript_WantsToBattle_Female TiffanysFamilyMembers: - random $6 - if_equal $0, .Grandma - if_equal $1, .Grandpa - if_equal $2, .Mom - if_equal $3, .Dad - if_equal $4, .Sister - if_equal $5, .Brother + random 6 + if_equal 0, .Grandma + if_equal 1, .Grandpa + if_equal 2, .Mom + if_equal 3, .Dad + if_equal 4, .Sister + if_equal 5, .Brother .Grandma: - stringtotext GrandmaString, $1 + stringtotext GrandmaString, MEM_BUFFER_1 jump TiffanysPoorClefairy .Grandpa: - stringtotext GrandpaString, $1 + stringtotext GrandpaString, MEM_BUFFER_1 jump TiffanysPoorClefairy .Mom: - stringtotext MomString, $1 + stringtotext MomString, MEM_BUFFER_1 jump TiffanysPoorClefairy .Dad: - stringtotext DadString, $1 + stringtotext DadString, MEM_BUFFER_1 jump TiffanysPoorClefairy .Sister: - stringtotext SisterString, $1 + stringtotext SisterString, MEM_BUFFER_1 jump TiffanysPoorClefairy .Brother: - stringtotext BrotherString, $1 + stringtotext BrotherString, MEM_BUFFER_1 jump TiffanysPoorClefairy TiffanysPoorClefairy: @@ -1665,13 +1665,13 @@ TiffanysPoorClefairy: TiffanyHasPinkBow: setflag ENGINE_TIFFANY_HAS_PINK_BOW - landmarktotext ROUTE_43, $2 + landmarktotext ROUTE_43, MEM_BUFFER_2 farjump PhoneScript_FoundItem_Female ; Vance VancePhoneScript1: - trainertotext BIRD_KEEPER, VANCE1, $0 + trainertotext BIRD_KEEPER, VANCE1, MEM_BUFFER_0 checkflag ENGINE_VANCE iftrue VanceWantsBattle farscall PhoneScript_AnswerPhone_Male @@ -1686,19 +1686,19 @@ VancePhoneScript1: farjump VanceLookingForward VanceWantsBattle: - landmarktotext ROUTE_44, $2 + landmarktotext ROUTE_44, MEM_BUFFER_2 farjump VanceHurryHurry VancePhoneScript2: - trainertotext BIRD_KEEPER, VANCE1, $0 + trainertotext BIRD_KEEPER, VANCE1, MEM_BUFFER_0 farscall PhoneScript_GreetPhone_Male checkflag ENGINE_VANCE iftrue .WantsBattle checkflag ENGINE_VANCE_WEDNESDAY_NIGHT iftrue .WantsBattle farscall PhoneScript_Random3 - if_equal $0, VanceWantsRematch - if_equal $1, VanceWantsRematch + if_equal 0, VanceWantsRematch + if_equal 1, VanceWantsRematch .WantsBattle: farjump Phone_GenericCall_Male @@ -1707,12 +1707,12 @@ VanceWednesdayNight: setflag ENGINE_VANCE_WEDNESDAY_NIGHT VanceWantsRematch: - landmarktotext ROUTE_44, $2 + landmarktotext ROUTE_44, MEM_BUFFER_2 setflag ENGINE_VANCE farjump PhoneScript_WantsToBattle_Male WiltonPhoneScript1: - trainertotext FISHER, WILTON1, $0 + trainertotext FISHER, WILTON1, MEM_BUFFER_0 checkflag ENGINE_WILTON iftrue .WantsBattle farscall PhoneScript_AnswerPhone_Male @@ -1729,15 +1729,15 @@ WiltonPhoneScript1: farjump WiltonHaventFoundAnything .WantsBattle: - landmarktotext ROUTE_44, $2 + landmarktotext ROUTE_44, MEM_BUFFER_2 farjump WiltonNotBiting .HasItem: - landmarktotext ROUTE_44, $2 + landmarktotext ROUTE_44, MEM_BUFFER_2 farjump WiltonWantThis WiltonPhoneScript2: - trainertotext FISHER, WILTON1, $0 + trainertotext FISHER, WILTON1, MEM_BUFFER_0 farscall PhoneScript_GreetPhone_Male checkflag ENGINE_WILTON iftrue .GenericCall @@ -1746,9 +1746,9 @@ WiltonPhoneScript2: checkflag ENGINE_WILTON_HAS_ITEM iftrue .GenericCall farscall PhoneScript_Random2 - if_equal $0, WiltonWantsBattle + if_equal 0, WiltonWantsBattle farscall PhoneScript_Random2 - if_equal $0, WiltonHasItem + if_equal 0, WiltonHasItem .GenericCall: farjump Phone_GenericCall_Male @@ -1757,20 +1757,20 @@ WiltonThursdayMorning: setflag ENGINE_WILTON_THURSDAY_MORNING WiltonWantsBattle: - landmarktotext ROUTE_44, $2 + landmarktotext ROUTE_44, MEM_BUFFER_2 setflag ENGINE_WILTON farjump PhoneScript_WantsToBattle_Male WiltonHasItem: setflag ENGINE_WILTON_HAS_ITEM - landmarktotext ROUTE_44, $2 + landmarktotext ROUTE_44, MEM_BUFFER_2 clearevent EVENT_WILTON_HAS_ULTRA_BALL clearevent EVENT_WILTON_HAS_GREAT_BALL clearevent EVENT_WILTON_HAS_POKE_BALL - random $5 - if_equal $0, .UltraBall - random $3 - if_equal $0, .GreatBall + random 5 + if_equal 0, .UltraBall + random 3 + if_equal 0, .GreatBall jump .PokeBall .UltraBall: @@ -1790,19 +1790,19 @@ WiltonHasItem: ; Kenji KenjiPhoneScript1: - trainertotext BLACKBELT_T, KENJI3, $0 + trainertotext BLACKBELT_T, KENJI3, MEM_BUFFER_0 farscall PhoneScript_AnswerPhone_Male farjump KenjiAnswerPhoneScript KenjiPhoneScript2: - trainertotext BLACKBELT_T, KENJI3, $0 + trainertotext BLACKBELT_T, KENJI3, MEM_BUFFER_0 farscall PhoneScript_GreetPhone_Male farjump KenjiCallingPhoneScript ; Parry ParryPhoneScript1: - trainertotext HIKER, PARRY1, $0 + trainertotext HIKER, PARRY1, MEM_BUFFER_0 checkflag ENGINE_PARRY iftrue .WantsBattle farscall PhoneScript_AnswerPhone_Male @@ -1817,19 +1817,19 @@ ParryPhoneScript1: farjump ParryBattleWithMe .WantsBattle: - landmarktotext ROUTE_45, $2 + landmarktotext ROUTE_45, MEM_BUFFER_2 farjump ParryHaventYouGottenTo ParryPhoneScript2: - trainertotext HIKER, PARRY1, $0 + trainertotext HIKER, PARRY1, MEM_BUFFER_0 farscall PhoneScript_GreetPhone_Male checkflag ENGINE_PARRY iftrue .GenericCall checkflag ENGINE_PARRY_FRIDAY_AFTERNOON iftrue .GenericCall farscall PhoneScript_Random2 - if_equal $0, ParryWantsBattle - if_equal $1, ParryWantsBattle + if_equal 0, ParryWantsBattle + if_equal 1, ParryWantsBattle .GenericCall: farjump Phone_GenericCall_Male @@ -1838,14 +1838,14 @@ ParryFridayDay: setflag ENGINE_PARRY_FRIDAY_AFTERNOON ParryWantsBattle: - landmarktotext ROUTE_45, $2 + landmarktotext ROUTE_45, MEM_BUFFER_2 setflag ENGINE_PARRY farjump PhoneScript_WantsToBattle_Male ; Erin ErinPhoneScript1: - trainertotext PICNICKER, ERIN1, $0 + trainertotext PICNICKER, ERIN1, MEM_BUFFER_0 checkflag ENGINE_ERIN iftrue .WantsBattle farscall PhoneScript_AnswerPhone_Female @@ -1860,19 +1860,19 @@ ErinPhoneScript1: farjump ErinWorkingHardScript .WantsBattle: - landmarktotext ROUTE_46, $2 + landmarktotext ROUTE_46, MEM_BUFFER_2 farjump ErinComeBattleScript ErinPhoneScript2: - trainertotext PICNICKER, ERIN1, $0 + trainertotext PICNICKER, ERIN1, MEM_BUFFER_0 farscall PhoneScript_GreetPhone_Female checkflag ENGINE_ERIN iftrue .GenericCall checkflag ENGINE_ERIN_SATURDAY_NIGHT iftrue .GenericCall farscall PhoneScript_Random3 - if_equal $0, ErinWantsBattle - if_equal $1, ErinWantsBattle + if_equal 0, ErinWantsBattle + if_equal 1, ErinWantsBattle .GenericCall: farjump Phone_GenericCall_Female @@ -1881,6 +1881,6 @@ ErinSaturdayNight: setflag ENGINE_ERIN_SATURDAY_NIGHT ErinWantsBattle: - landmarktotext ROUTE_46, $2 + landmarktotext ROUTE_46, MEM_BUFFER_2 setflag ENGINE_ERIN farjump PhoneScript_WantsToBattle_Female diff --git a/engine/pic_animation.asm b/engine/pic_animation.asm index 33b770b14..062998e5f 100644 --- a/engine/pic_animation.asm +++ b/engine/pic_animation.asm @@ -1,54 +1,54 @@ ; Pic animation arrangement. -AnimateMon_Slow_Normal: ; d0000 +UnusedPredef_AnimateMon_Slow_Normal: ; d0000 hlcoord 12, 0 ld a, [wBattleMode] cp WILD_BATTLE jr z, .wild ld e, ANIM_MON_SLOW ld d, $0 - call AnimateFrontpic + call Predef_AnimateFrontpic ret .wild ld e, ANIM_MON_NORMAL ld d, $0 - call AnimateFrontpic + call Predef_AnimateFrontpic ret ; d001a AnimateMon_Menu: ; d001a ld e, ANIM_MON_MENU ld d, $0 - call AnimateFrontpic + call Predef_AnimateFrontpic ret ; d0022 AnimateMon_Trade: ; d0022 ld e, ANIM_MON_TRADE ld d, $0 - call AnimateFrontpic + call Predef_AnimateFrontpic ret ; d002a AnimateMon_Evolve: ; d002a ld e, ANIM_MON_EVOLVE ld d, $0 - call AnimateFrontpic + call Predef_AnimateFrontpic ret ; d0032 AnimateMon_Hatch: ; d0032 ld e, ANIM_MON_HATCH ld d, $0 - call AnimateFrontpic + call Predef_AnimateFrontpic ret ; d003a AnimateMon_Unused: ; d003a ld e, ANIM_MON_UNUSED ld d, $0 - call AnimateFrontpic + call Predef_AnimateFrontpic ret ; d0042 @@ -86,10 +86,10 @@ PokeAnims: ; d0042 .Egg2: pokeanim Idle, Play -AnimateFrontpic: ; d008e +Predef_AnimateFrontpic: ; d008e call AnimateMon_CheckIfPokemon ret c - call LoadMonAnimation + call Predef_LoadMonAnimation .loop call SetUpPokeAnim push af @@ -99,7 +99,7 @@ AnimateFrontpic: ; d008e ret ; d00a3 -LoadMonAnimation: ; d00a3 +Predef_LoadMonAnimation: ; d00a3 push hl ld c, e ld b, 0 @@ -279,7 +279,7 @@ PokeAnim_StereoCry: ; d0196 PokeAnim_DeinitFrames: ; d01a9 ld a, [rSVBK] push af - ld a, $2 + ld a, BANK(wPokeAnimCoord) ld [rSVBK], a call PokeAnim_PlaceGraphic farcall HDMATransferTileMapToWRAMBank3 @@ -335,12 +335,12 @@ PokeAnim_InitPicAttributes: ; d01d6 ld a, d ld [wPokeAnimGraphicStartTile], a - ld a, $1 + ld a, BANK(CurPartySpecies) ld hl, CurPartySpecies call GetFarWRAMByte ld [wPokeAnimSpecies], a - ld a, $1 + ld a, BANK(UnownLetter) ld hl, UnownLetter call GetFarWRAMByte ld [wPokeAnimUnownLetter], a @@ -695,7 +695,7 @@ PokeAnim_ConvertAndApplyBitmask: ; d036b ret ; d03f4 -; XXX +; unused db 6, 5, 4 .GetTilemap: ; d03f7 @@ -876,7 +876,7 @@ PokeAnim_PlaceGraphic: ; d04bd PokeAnim_SetVBank1: ; d0504 ld a, [rSVBK] push af - ld a, $2 + ld a, BANK(wPokeAnimCoord) ld [rSVBK], a xor a ld [hBGMapMode], a @@ -1024,7 +1024,7 @@ GetMonFramesPointer: ; d05ce ld hl, UnownFramesPointers jr z, .got_frames ld a, [wPokeAnimSpecies] - cp CHIKORITA + cp JOHTO_POKEMON ld b, BANK(FramesPointers) ld c, BANK(KantoFrames) ld hl, FramesPointers @@ -1110,10 +1110,11 @@ PokeAnim_GetSpeciesOrUnown: ; d065c ret ; d0669 -Predef48: ; d0669 Predef 48 +UnusedPredef48: ; d0669 Predef 48 ld a, $1 ld [wBoxAlignment], a -HOF_AnimateFrontpic: ; d066e Predef 49 + +HOF_Predef_AnimateFrontpic: ; d066e Predef 49 call AnimateMon_CheckIfPokemon jr c, .fail ld h, d @@ -1121,12 +1122,12 @@ HOF_AnimateFrontpic: ; d066e Predef 49 push bc push hl ld de, vTiles2 - predef GetAnimatedFrontpicPredef + predef Predef_GetAnimatedFrontpic pop hl pop bc ld d, 0 ld e, c - call AnimateFrontpic + call Predef_AnimateFrontpic xor a ld [wBoxAlignment], a ret diff --git a/engine/player_gfx.asm b/engine/player_gfx.asm index 98a54684b..8da7ad564 100644 --- a/engine/player_gfx.asm +++ b/engine/player_gfx.asm @@ -1,5 +1,4 @@ -Function88248: ; 88248 -; XXX +Unreferenced_Function88248: ; 88248 ld c, CAL ld a, [wPlayerGender] bit 0, a @@ -31,7 +30,7 @@ MovePlayerPic: ; 88266 xor a ld [hBGMapMode], a lb bc, 7, 7 - predef PlaceGraphic + predef Predef_PlaceGraphic xor a ld [hBGMapThird], a call WaitBGMap @@ -71,7 +70,7 @@ ShowPlayerNamingChoices: ; 88297 call CloseWindow ret -INCLUDE "data/default_names.asm" +INCLUDE "data/player_names.asm" GetPlayerNameArray: ; 88318 This Function is never called ld hl, PlayerName @@ -142,7 +141,7 @@ GetChrisBackpic: ; 88830 ld b, BANK(ChrisBackpic) ld de, vTiles2 tile $31 ld c, 7 * 7 - predef DecompressPredef + predef Predef_Decompress ret HOF_LoadTrainerFrontpic: ; 88840 @@ -204,7 +203,7 @@ DrawIntroPlayerPic: ; 88874 ld [hGraphicStartTile], a hlcoord 6, 4 lb bc, 7, 7 - predef PlaceGraphic + predef Predef_PlaceGraphic ret ChrisPic: ; 888a9 diff --git a/engine/player_movement.asm b/engine/player_movement.asm index fa7cc84a5..e475bf6a4 100755 --- a/engine/player_movement.asm +++ b/engine/player_movement.asm @@ -140,7 +140,7 @@ DoPlayerMovement:: ; 80000 .water ld a, c - and 3 + maskbits NUM_DIRECTIONS +- 1 ld c, a ld b, 0 ld hl, .water_table @@ -244,7 +244,7 @@ DoPlayerMovement:: ; 80000 ld a, [PlayerDirection] rrca rrca - and 3 + maskbits NUM_DIRECTIONS +- 1 cp e jr z, .not_turning @@ -316,7 +316,7 @@ DoPlayerMovement:: ; 80000 scf ret -; unused? +; unused xor a ret @@ -430,7 +430,7 @@ DoPlayerMovement:: ; 80000 ld a, [PlayerDirection] rrca rrca - and 3 + maskbits NUM_DIRECTIONS +- 1 cp e jr nz, .not_warp call WarpCheck @@ -559,7 +559,7 @@ DoPlayerMovement:: ; 80000 cp 0 ret z - and 3 + maskbits NUM_DIRECTIONS +- 1 ld e, a ld d, 0 ld hl, .forced_dpad diff --git a/engine/player_object.asm b/engine/player_object.asm index 6d5cb7e84..50cabadf6 100755 --- a/engine/player_object.asm +++ b/engine/player_object.asm @@ -589,7 +589,7 @@ Special_SurfStartStep: ; 8379 ld a, [PlayerDirection] srl a srl a - and 3 + maskbits NUM_DIRECTIONS +- 1 ld e, a ld d, 0 ld hl, .movement_data diff --git a/engine/player_step.asm b/engine/player_step.asm index 996a9b422..3af41be59 100755 --- a/engine/player_step.asm +++ b/engine/player_step.asm @@ -76,7 +76,7 @@ HandlePlayerStep: ; d4e5 (3:54e5) ret .mobile ; d509 (3:5509) - farcall TrainerRankings_StepCount + farcall StubbedTrainerRankings_StepCount ret .fail2 ; d510 (3:5510) @@ -154,7 +154,7 @@ UpdateOverworldMap: ; d536 (3:5536) jr nc, .not_overflowed ld a, [wBGMapAnchor + 1] inc a - and $3 + and %11 or HIGH(vBGMap0) ld [wBGMapAnchor + 1], a .not_overflowed @@ -185,7 +185,7 @@ UpdateOverworldMap: ; d536 (3:5536) jr nc, .not_underflowed ld a, [wBGMapAnchor + 1] dec a - and $3 + and %11 or HIGH(vBGMap0) ld [wBGMapAnchor + 1], a .not_underflowed diff --git a/engine/pokedex.asm b/engine/pokedex.asm index 5dc3dc2a7..fb16f83d1 100644 --- a/engine/pokedex.asm +++ b/engine/pokedex.asm @@ -1,3 +1,4 @@ +; Pokedex_RunJumptable.Jumptable indexes const_def const DEXSTATE_MAIN_SCR const DEXSTATE_UPDATE_MAIN_SCR @@ -86,8 +87,8 @@ InitPokedex: ; 40063 xor a ld [wJumptableIndex], a - ld [wDexEntryPrevJumptableIndex], a - ld [wcf65], a + ld [wPrevDexEntryJumptableIndex], a + ld [wPrevDexEntryBackup], a ld [wcf66], a call Pokedex_CheckUnlockedUnownMode @@ -118,7 +119,7 @@ Pokedex_CheckUnlockedUnownMode: ; 400a2 Pokedex_InitCursorPosition: ; 400b4 ld hl, wPokedexOrder - ld a, [wLastDexEntry] + ld a, [wPrevDexEntry] and a jr z, .done cp NUM_POKEMON + 1 @@ -185,6 +186,7 @@ Pokedex_RunJumptable: ; 4010b jp hl .Jumptable: ; 40115 (10:4115) +; entries correspond to DEXSTATE_* constants dw Pokedex_InitMainScreen dw Pokedex_UpdateMainScreen dw Pokedex_InitDexEntryScreen @@ -289,7 +291,7 @@ Pokedex_UpdateMainScreen: ; 401ae (10:41ae) ld a, DEXSTATE_DEX_ENTRY_SCR ld [wJumptableIndex], a ld a, DEXSTATE_MAIN_SCR - ld [wDexEntryPrevJumptableIndex], a + ld [wPrevDexEntryJumptableIndex], a ret .select @@ -330,7 +332,7 @@ Pokedex_InitDexEntryScreen: ; 40217 (10:4217) call Pokedex_DrawDexEntryScreenBG call Pokedex_InitArrowCursor call Pokedex_GetSelectedMon - ld [wLastDexEntry], a + ld [wPrevDexEntry], a farcall DisplayDexEntry call Pokedex_DrawFootprint call WaitBGMap @@ -375,7 +377,7 @@ Pokedex_UpdateDexEntryScreen: ; 40258 (10:4258) .max_volume call MaxVolume - ld a, [wDexEntryPrevJumptableIndex] + ld a, [wPrevDexEntryJumptableIndex] ld [wJumptableIndex], a ret @@ -384,7 +386,7 @@ Pokedex_Page: ; 40292 xor $1 ld [wPokedexStatus], a call Pokedex_GetSelectedMon - ld [wLastDexEntry], a + ld [wPrevDexEntry], a farcall DisplayDexEntry call WaitBGMap ret @@ -400,7 +402,7 @@ Pokedex_ReinitDexEntryScreen: ; 402aa (10:42aa) call Pokedex_InitArrowCursor call Pokedex_LoadCurrentFootprint call Pokedex_GetSelectedMon - ld [wLastDexEntry], a + ld [wPrevDexEntry], a farcall DisplayDexEntry call Pokedex_DrawFootprint call Pokedex_LoadSelectedMonTiles @@ -441,7 +443,7 @@ DexEntryScreen_MenuActionJumptable: ; 402f2 call Pokedex_GetSelectedMon ld a, [wDexCurrentLocation] ld e, a - predef _Area + predef Predef_Pokedex_GetArea call Pokedex_BlackOutBG call DelayFrame xor a @@ -473,9 +475,9 @@ DexEntryScreen_MenuActionJumptable: ; 402f2 call Pokedex_ApplyPrintPals xor a ld [hSCX], a - ld a, [wcf65] + ld a, [wPrevDexEntryBackup] push af - ld a, [wDexEntryPrevJumptableIndex] + ld a, [wPrevDexEntryJumptableIndex] push af ld a, [wJumptableIndex] push af @@ -483,9 +485,9 @@ DexEntryScreen_MenuActionJumptable: ; 402f2 pop af ld [wJumptableIndex], a pop af - ld [wDexEntryPrevJumptableIndex], a + ld [wPrevDexEntryJumptableIndex], a pop af - ld [wcf65], a + ld [wPrevDexEntryBackup], a call ClearBGPalettes call DisableLCD call Pokedex_LoadInvertedFont @@ -695,8 +697,8 @@ Pokedex_UpdateSearchScreen: ; 40471 (10:4471) ld [wDexListingScrollOffsetBackup], a ld a, [wDexListingCursor] ld [wDexListingCursorBackup], a - ld a, [wLastDexEntry] - ld [wcf65], a + ld a, [wPrevDexEntry] + ld [wPrevDexEntryBackup], a xor a ld [wDexListingScrollOffset], a ld [wDexListingCursor], a @@ -739,7 +741,7 @@ Pokedex_InitSearchResultsScreen: ; 4050a (10:450a) farcall DrawPokedexSearchResultsWindow call Pokedex_PlaceSearchResultsTypeStrings call Pokedex_UpdateSearchResultsCursorOAM - ld a, $ff + ld a, -1 ld [CurPartySpecies], a ld a, SCGB_POKEDEX call Pokedex_GetSGBLayout @@ -771,7 +773,7 @@ Pokedex_UpdateSearchResultsScreen: ; 40562 (10:4562) ld a, DEXSTATE_DEX_ENTRY_SCR ld [wJumptableIndex], a ld a, DEXSTATE_SEARCH_RESULTS_SCR - ld [wDexEntryPrevJumptableIndex], a + ld [wPrevDexEntryJumptableIndex], a ret .return_to_search_screen @@ -779,8 +781,8 @@ Pokedex_UpdateSearchResultsScreen: ; 40562 (10:4562) ld [wDexListingScrollOffset], a ld a, [wDexListingCursorBackup] ld [wDexListingCursor], a - ld a, [wcf65] - ld [wLastDexEntry], a + ld a, [wPrevDexEntryBackup] + ld [wPrevDexEntry], a call Pokedex_BlackOutBG call ClearSprites call Pokedex_OrderMonsByMode @@ -827,7 +829,7 @@ Pokedex_UpdateUnownMode: ; 405df (10:45df) .decompress ld hl, PokedexLZ ld de, vTiles2 tile $31 - lb bc, BANK(PokedexLZ), $3a + lb bc, BANK(PokedexLZ), 58 call DecompressRequest2bpp .done @@ -1123,13 +1125,14 @@ Pokedex_DrawMainScreenBG: ; 4074c (10:474c) ret String_SEEN: ; 407e1 - db "SEEN", $ff + db "SEEN", -1 String_OWN: ; 407e6 - db "OWN", $ff + db "OWN", -1 String_SELECT_OPTION: ; 407ea db $3b, $48, $49, $4a, $44, $45, $46, $47 ; SELECT > OPTION + ; fallthrough String_START_SEARCH: ; 407f2 - db $3c, $3b, $41, $42, $43, $4b, $4c, $4d, $4e, $3c, $ff ; START > SEARCH + db $3c, $3b, $41, $42, $43, $4b, $4c, $4d, $4e, $3c, -1 ; START > SEARCH Pokedex_DrawDexEntryScreenBG: ; 407fd call Pokedex_FillBackgroundColor2 @@ -1164,13 +1167,13 @@ Pokedex_DrawDexEntryScreenBG: ; 407fd ret .Unused: ; 4084f - db $5c, $5d, $ff ; No. + db $5c, $5d, -1 ; No. .Height: ; 40852 - db "HT ?", $5e, "??", $5f, $ff ; HT ?'??" + db "HT ?", $5e, "??", $5f, -1 ; HT ?'??" .Weight: ; 4085c - db "WT ???lb", $ff ; WT ???lb + db "WT ???lb", -1 ; WT ???lb .MenuItems: ; 40867 - db $3b, " PAGE AREA CRY PRNT", $ff + db $3b, " PAGE AREA CRY PRNT", -1 Pokedex_DrawOptionScreenBG: ; 4087c (10:487c) call Pokedex_FillBackgroundColor2 @@ -1195,7 +1198,7 @@ Pokedex_DrawOptionScreenBG: ; 4087c (10:487c) ret .Title: ; 408b2 - db $3b, " OPTION ", $3c, $ff + db $3b, " OPTION ", $3c, -1 .Modes: ; 408bd db "NEW #DEX MODE" @@ -1229,10 +1232,10 @@ Pokedex_DrawSearchScreenBG: ; 408f0 (10:48f0) ret .Title: ; 4092a - db $3b, " SEARCH ", $3c, $ff + db $3b, " SEARCH ", $3c, -1 .TypeLeftRightArrows: ; 40935 - db $3d, " ", $3e, $ff + db $3d, " ", $3e, -1 .Types: ; 40940 db "TYPE1" @@ -1794,7 +1797,7 @@ Pokedex_PrevSearchMonType: ; 40f65 ld hl, wDexSearchMonType1 ld a, [hl] - cp $1 + cp 1 jr z, .wrap_around dec [hl] jr .done @@ -1808,7 +1811,7 @@ Pokedex_PrevSearchMonType: ; 40f65 jr .done .wrap_around - ld [hl], $11 + ld [hl], NUM_TYPES - 1 .done scf @@ -1821,18 +1824,18 @@ Pokedex_NextSearchMonType: ; 40f84 ld hl, wDexSearchMonType1 ld a, [hl] - cp $11 + cp NUM_TYPES - 1 jr nc, .type1_wrap_around inc [hl] jr .done .type1_wrap_around - ld [hl], $1 + ld [hl], 1 jr .done .type2 ld hl, wDexSearchMonType2 ld a, [hl] - cp $11 + cp NUM_TYPES - 1 jr nc, .type2_wrap_around inc [hl] jr .done @@ -1864,7 +1867,7 @@ Pokedex_PlaceTypeString: ; 40fcd (10:4fcd) push hl ld e, a ld d, 0 - ld hl, .TypeStrings + ld hl, PokedexTypeSearchStrings rept 9 add hl, de endr @@ -1874,25 +1877,7 @@ endr call PlaceString ret -.TypeStrings: ; 40fe4 - db " ---- @" - db " NORMAL @" - db " FIRE @" - db " WATER @" - db " GRASS @" - db "ELECTRIC@" - db " ICE @" - db "FIGHTING@" - db " POISON @" - db " GROUND @" - db " FLYING @" - db "PSYCHIC @" - db " BUG @" - db " ROCK @" - db " GHOST @" - db " DRAGON @" - db " DARK @" - db " STEEL @" +INCLUDE "data/types/search_strings.asm" Pokedex_SearchForMons: ; 41086 ld a, [wDexSearchMonType2] @@ -1907,7 +1892,7 @@ Pokedex_SearchForMons: ; 41086 dec a ld e, a ld d, 0 - ld hl, .TypeConversionTable + ld hl, PokedexTypeSearchConversionTable add hl, de ld a, [hl] ld [wDexConvertedMonType], a @@ -1969,24 +1954,7 @@ Pokedex_SearchForMons: ; 41086 .done ret -.TypeConversionTable: ; 410f6 - db NORMAL - db FIRE - db WATER - db GRASS - db ELECTRIC - db ICE - db FIGHTING - db POISON - db GROUND - db FLYING - db PSYCHIC - db BUG - db ROCK - db GHOST - db DRAGON - db DARK - db STEEL +INCLUDE "data/types/search_types.asm" Pokedex_DisplayTypeNotFoundMessage: ; 41107 xor a @@ -2026,60 +1994,60 @@ Pokedex_PutOldModeCursorOAM: ; 41157 (10:5157) ret .CursorOAM: ; 41167 - db $18, $47, $30, $07 - db $10, $47, $31, $07 - db $10, $4f, $32, $07 - db $10, $57, $32, $07 - db $10, $5f, $32, $07 - db $10, $67, $33, $07 - db $10, $7e, $33, $27 - db $10, $86, $32, $27 - db $10, $8e, $32, $27 - db $10, $96, $32, $27 - db $10, $9e, $31, $27 - db $18, $9e, $30, $27 - db $20, $47, $30, $47 - db $28, $47, $31, $47 - db $28, $4f, $32, $47 - db $28, $57, $32, $47 - db $28, $5f, $32, $47 - db $28, $67, $33, $47 - db $28, $7e, $33, $67 - db $28, $86, $32, $67 - db $28, $8e, $32, $67 - db $28, $96, $32, $67 - db $28, $9e, $31, $67 - db $20, $9e, $30, $67 - db $ff + dsprite 3, 0, 9, -1, $30, 7 + dsprite 2, 0, 9, -1, $31, 7 + dsprite 2, 0, 10, -1, $32, 7 + dsprite 2, 0, 11, -1, $32, 7 + dsprite 2, 0, 12, -1, $32, 7 + dsprite 2, 0, 13, -1, $33, 7 + dsprite 2, 0, 16, -2, $33, 7 | X_FLIP + dsprite 2, 0, 17, -2, $32, 7 | X_FLIP + dsprite 2, 0, 18, -2, $32, 7 | X_FLIP + dsprite 2, 0, 19, -2, $32, 7 | X_FLIP + dsprite 2, 0, 20, -2, $31, 7 | X_FLIP + dsprite 3, 0, 20, -2, $30, 7 | X_FLIP + dsprite 4, 0, 9, -1, $30, 7 | Y_FLIP + dsprite 5, 0, 9, -1, $31, 7 | Y_FLIP + dsprite 5, 0, 10, -1, $32, 7 | Y_FLIP + dsprite 5, 0, 11, -1, $32, 7 | Y_FLIP + dsprite 5, 0, 12, -1, $32, 7 | Y_FLIP + dsprite 5, 0, 13, -1, $33, 7 | Y_FLIP + dsprite 5, 0, 16, -2, $33, 7 | X_FLIP | Y_FLIP + dsprite 5, 0, 17, -2, $32, 7 | X_FLIP | Y_FLIP + dsprite 5, 0, 18, -2, $32, 7 | X_FLIP | Y_FLIP + dsprite 5, 0, 19, -2, $32, 7 | X_FLIP | Y_FLIP + dsprite 5, 0, 20, -2, $31, 7 | X_FLIP | Y_FLIP + dsprite 4, 0, 20, -2, $30, 7 | X_FLIP | Y_FLIP + db -1 .CursorAtTopOAM: ; 411c8 ; OAM data for when the cursor is at the top of the list. The tiles at the top ; are cut off so they don't show up outside the list area. - db $18, $47, $30, $07 - db $10, $47, $34, $07 - db $10, $4f, $35, $07 - db $10, $57, $35, $07 - db $10, $5f, $35, $07 - db $10, $67, $36, $07 - db $10, $7e, $36, $27 - db $10, $86, $35, $27 - db $10, $8e, $35, $27 - db $10, $96, $35, $27 - db $10, $9e, $34, $27 - db $18, $9e, $30, $27 - db $20, $47, $30, $47 - db $28, $47, $31, $47 - db $28, $4f, $32, $47 - db $28, $57, $32, $47 - db $28, $5f, $32, $47 - db $28, $67, $33, $47 - db $28, $7e, $33, $67 - db $28, $86, $32, $67 - db $28, $8e, $32, $67 - db $28, $96, $32, $67 - db $28, $9e, $31, $67 - db $20, $9e, $30, $67 - db $ff + dsprite 3, 0, 9, -1, $30, 7 + dsprite 2, 0, 9, -1, $34, 7 + dsprite 2, 0, 10, -1, $35, 7 + dsprite 2, 0, 11, -1, $35, 7 + dsprite 2, 0, 12, -1, $35, 7 + dsprite 2, 0, 13, -1, $36, 7 + dsprite 2, 0, 16, -2, $36, 7 | X_FLIP + dsprite 2, 0, 17, -2, $35, 7 | X_FLIP + dsprite 2, 0, 18, -2, $35, 7 | X_FLIP + dsprite 2, 0, 19, -2, $35, 7 | X_FLIP + dsprite 2, 0, 20, -2, $34, 7 | X_FLIP + dsprite 3, 0, 20, -2, $30, 7 | X_FLIP + dsprite 4, 0, 9, -1, $30, 7 | Y_FLIP + dsprite 5, 0, 9, -1, $31, 7 | Y_FLIP + dsprite 5, 0, 10, -1, $32, 7 | Y_FLIP + dsprite 5, 0, 11, -1, $32, 7 | Y_FLIP + dsprite 5, 0, 12, -1, $32, 7 | Y_FLIP + dsprite 5, 0, 13, -1, $33, 7 | Y_FLIP + dsprite 5, 0, 16, -2, $33, 7 | X_FLIP | Y_FLIP + dsprite 5, 0, 17, -2, $32, 7 | X_FLIP | Y_FLIP + dsprite 5, 0, 18, -2, $32, 7 | X_FLIP | Y_FLIP + dsprite 5, 0, 19, -2, $32, 7 | X_FLIP | Y_FLIP + dsprite 5, 0, 20, -2, $31, 7 | X_FLIP | Y_FLIP + dsprite 4, 0, 20, -2, $30, 7 | X_FLIP | Y_FLIP + db -1 Pokedex_PutNewModeABCModeCursorOAM: ; 41229 (10:5229) ld hl, .CursorOAM @@ -2087,27 +2055,27 @@ Pokedex_PutNewModeABCModeCursorOAM: ; 41229 (10:5229) ret .CursorOAM: ; 41230 - db $1b, $47, $30, $07 - db $13, $47, $31, $07 - db $13, $4f, $32, $07 - db $13, $57, $32, $07 - db $13, $5f, $33, $07 - db $13, $80, $33, $27 - db $13, $88, $32, $27 - db $13, $90, $32, $27 - db $13, $98, $31, $27 - db $1b, $98, $30, $27 - db $23, $47, $30, $47 - db $2b, $47, $31, $47 - db $2b, $4f, $32, $47 - db $2b, $57, $32, $47 - db $2b, $5f, $33, $47 - db $2b, $80, $33, $67 - db $2b, $88, $32, $67 - db $2b, $90, $32, $67 - db $2b, $98, $31, $67 - db $23, $98, $30, $67 - db $ff + dsprite 3, 3, 9, -1, $30, 7 + dsprite 2, 3, 9, -1, $31, 7 + dsprite 2, 3, 10, -1, $32, 7 + dsprite 2, 3, 11, -1, $32, 7 + dsprite 2, 3, 12, -1, $33, 7 + dsprite 2, 3, 16, 0, $33, 7 | X_FLIP + dsprite 2, 3, 17, 0, $32, 7 | X_FLIP + dsprite 2, 3, 18, 0, $32, 7 | X_FLIP + dsprite 2, 3, 19, 0, $31, 7 | X_FLIP + dsprite 3, 3, 19, 0, $30, 7 | X_FLIP + dsprite 4, 3, 9, -1, $30, 7 | Y_FLIP + dsprite 5, 3, 9, -1, $31, 7 | Y_FLIP + dsprite 5, 3, 10, -1, $32, 7 | Y_FLIP + dsprite 5, 3, 11, -1, $32, 7 | Y_FLIP + dsprite 5, 3, 12, -1, $33, 7 | Y_FLIP + dsprite 5, 3, 16, 0, $33, 7 | X_FLIP | Y_FLIP + dsprite 5, 3, 17, 0, $32, 7 | X_FLIP | Y_FLIP + dsprite 5, 3, 18, 0, $32, 7 | X_FLIP | Y_FLIP + dsprite 5, 3, 19, 0, $31, 7 | X_FLIP | Y_FLIP + dsprite 4, 3, 19, 0, $30, 7 | X_FLIP | Y_FLIP + db -1 Pokedex_UpdateSearchResultsCursorOAM: ; 41281 (10:5281) ld a, [wCurrentDexMode] @@ -2118,52 +2086,52 @@ Pokedex_UpdateSearchResultsCursorOAM: ; 41281 (10:5281) ret .CursorOAM: ; 41290 - db $1b, $47, $30, $07 - db $13, $47, $31, $07 - db $13, $4f, $32, $07 - db $13, $57, $32, $07 - db $13, $5f, $32, $07 - db $13, $67, $33, $07 - db $13, $7e, $33, $27 - db $13, $86, $32, $27 - db $13, $8e, $32, $27 - db $13, $96, $32, $27 - db $13, $9e, $31, $27 - db $1b, $9e, $30, $27 - db $23, $47, $30, $47 - db $2b, $47, $31, $47 - db $2b, $4f, $32, $47 - db $2b, $57, $32, $47 - db $2b, $5f, $32, $47 - db $2b, $67, $33, $47 - db $2b, $7e, $33, $67 - db $2b, $86, $32, $67 - db $2b, $8e, $32, $67 - db $2b, $96, $32, $67 - db $2b, $9e, $31, $67 - db $23, $9e, $30, $67 - db $ff + dsprite 3, 3, 9, -1, $30, 7 + dsprite 2, 3, 9, -1, $31, 7 + dsprite 2, 3, 10, -1, $32, 7 + dsprite 2, 3, 11, -1, $32, 7 + dsprite 2, 3, 12, -1, $32, 7 + dsprite 2, 3, 13, -1, $33, 7 + dsprite 2, 3, 16, -2, $33, 7 | X_FLIP + dsprite 2, 3, 17, -2, $32, 7 | X_FLIP + dsprite 2, 3, 18, -2, $32, 7 | X_FLIP + dsprite 2, 3, 19, -2, $32, 7 | X_FLIP + dsprite 2, 3, 20, -2, $31, 7 | X_FLIP + dsprite 3, 3, 20, -2, $30, 7 | X_FLIP + dsprite 4, 3, 9, -1, $30, 7 | Y_FLIP + dsprite 5, 3, 9, -1, $31, 7 | Y_FLIP + dsprite 5, 3, 10, -1, $32, 7 | Y_FLIP + dsprite 5, 3, 11, -1, $32, 7 | Y_FLIP + dsprite 5, 3, 12, -1, $32, 7 | Y_FLIP + dsprite 5, 3, 13, -1, $33, 7 | Y_FLIP + dsprite 5, 3, 16, -2, $33, 7 | X_FLIP | Y_FLIP + dsprite 5, 3, 17, -2, $32, 7 | X_FLIP | Y_FLIP + dsprite 5, 3, 18, -2, $32, 7 | X_FLIP | Y_FLIP + dsprite 5, 3, 19, -2, $32, 7 | X_FLIP | Y_FLIP + dsprite 5, 3, 20, -2, $31, 7 | X_FLIP | Y_FLIP + dsprite 4, 3, 20, -2, $30, 7 | X_FLIP | Y_FLIP + db -1 Pokedex_LoadCursorOAM: ; 412f1 (10:52f1) - ld de, Sprites + ld de, Sprite01 .loop ld a, [hl] - cp $ff + cp -1 ret z ld a, [wDexListingCursor] and $7 swap a - add [hl] + add [hl] ; y inc hl ld [de], a inc de - ld a, [hli] + ld a, [hli] ; x ld [de], a inc de - ld a, [hli] + ld a, [hli] ; tile id ld [de], a inc de - ld a, [hli] + ld a, [hli] ; attributes ld [de], a inc de jr .loop @@ -2348,7 +2316,7 @@ Pokedex_BlackOutBG: ; 41401 (10:5401) ; Make BG palettes black so that the BG becomes all black. ld a, [rSVBK] push af - ld a, $5 + ld a, BANK(wBGPals1) ld [rSVBK], a ld hl, wBGPals1 ld bc, 8 palettes @@ -2399,7 +2367,7 @@ Pokedex_LoadSelectedMonTiles: ; 4143b ld [CurPartySpecies], a call GetBaseData ld de, vTiles2 - predef GetMonFrontpic + predef Predef_GetMonFrontpic ret .QuestionMark: @@ -2422,7 +2390,7 @@ Pokedex_LoadCurrentFootprint: ; 41478 (10:5478) Pokedex_LoadAnyFootprint: ; 4147b ld a, [wd265] dec a - and ($ff ^ $07) ; $f8 ; $1f << 3 + and %11111000 srl a srl a srl a @@ -2430,7 +2398,7 @@ Pokedex_LoadAnyFootprint: ; 4147b ld d, a ld a, [wd265] dec a - and 7 + and %111 swap a ; * $10 ld l, a ld h, 0 @@ -2552,7 +2520,7 @@ Pokedex_LoadUnownFrontpicTiles: ; 41a58 (10:5a58) ld [CurPartySpecies], a call GetBaseData ld de, vTiles2 tile $00 - predef GetMonFrontpic + predef Predef_GetMonFrontpic pop af ld [UnownLetter], a ret @@ -2582,7 +2550,7 @@ _NewPokedexEntry: ; 41a7f call WaitBGMap call GetBaseData ld de, vTiles2 - predef GetMonFrontpic + predef Predef_GetMonFrontpic ld a, SCGB_POKEDEX call Pokedex_GetSGBLayout ld a, [CurPartySpecies] diff --git a/engine/pokedex_2.asm b/engine/pokedex_2.asm index 83b366017..4a5a08803 100644 --- a/engine/pokedex_2.asm +++ b/engine/pokedex_2.asm @@ -40,16 +40,16 @@ AnimateDexSearchSlowpoke: ; 441cf DoDexSearchSlowpokeFrame: ; 44207 ld a, [wDexSearchSlowpokeFrame] - ld hl, .SpriteData - ld de, Sprites + ld hl, .SlowpokeSpriteData + ld de, Sprite01 .loop ld a, [hli] cp -1 ret z - ld [de], a + ld [de], a ; y inc de ld a, [hli] - ld [de], a + ld [de], a ; x inc de ld a, [wDexSearchSlowpokeFrame] ld b, a @@ -57,23 +57,23 @@ DoDexSearchSlowpokeFrame: ; 44207 add b add [hl] inc hl - ld [de], a + ld [de], a ; tile id inc de ld a, [hli] - ld [de], a + ld [de], a ; attributes inc de jr .loop -.SpriteData: ; 44228 - dsprite 11, 0, 9, 0, $00, $00 - dsprite 11, 0, 10, 0, $01, $00 - dsprite 11, 0, 11, 0, $02, $00 - dsprite 12, 0, 9, 0, $10, $00 - dsprite 12, 0, 10, 0, $11, $00 - dsprite 12, 0, 11, 0, $12, $00 - dsprite 13, 0, 9, 0, $20, $00 - dsprite 13, 0, 10, 0, $21, $00 - dsprite 13, 0, 11, 0, $22, $00 +.SlowpokeSpriteData: ; 44228 + dsprite 11, 0, 9, 0, $00, 0 + dsprite 11, 0, 10, 0, $01, 0 + dsprite 11, 0, 11, 0, $02, 0 + dsprite 12, 0, 9, 0, $10, 0 + dsprite 12, 0, 10, 0, $11, 0 + dsprite 12, 0, 11, 0, $12, 0 + dsprite 13, 0, 9, 0, $20, 0 + dsprite 13, 0, 10, 0, $21, 0 + dsprite 13, 0, 11, 0, $22, 0 db -1 DisplayDexEntry: ; 4424d @@ -230,7 +230,7 @@ GetDexEntryPointer: ; 44333 push de rlca rlca - and $3 + maskbits NUM_DEX_ENTRY_BANKS +- 1 ld hl, .PokedexEntryBanks ld d, 0 ld e, a @@ -241,12 +241,6 @@ GetDexEntryPointer: ; 44333 ret .PokedexEntryBanks: ; 44351 - -GLOBAL PokedexEntries1 -GLOBAL PokedexEntries2 -GLOBAL PokedexEntries3 -GLOBAL PokedexEntries4 - db BANK(PokedexEntries1) db BANK(PokedexEntries2) db BANK(PokedexEntries3) diff --git a/engine/pokedex_3.asm b/engine/pokedex_3.asm index 482f55799..dc52f83d3 100644 --- a/engine/pokedex_3.asm +++ b/engine/pokedex_3.asm @@ -7,7 +7,7 @@ LoadSGBPokedexGFX: ; 1ddf1c LoadSGBPokedexGFX2: ; 1ddf26 (77:5f26) ld hl, SGBPokedexGFX_LZ ld de, vTiles2 tile $31 - lb bc, BANK(SGBPokedexGFX_LZ), $3a + lb bc, BANK(SGBPokedexGFX_LZ), 58 call DecompressRequest2bpp ret diff --git a/engine/pokegear.asm b/engine/pokegear.asm index dba071b28..6f9192f19 100755 --- a/engine/pokegear.asm +++ b/engine/pokegear.asm @@ -1,3 +1,27 @@ +; Pokégear cards + const_def + const POKEGEARCARD_CLOCK ; 0 + const POKEGEARCARD_MAP ; 1 + const POKEGEARCARD_PHONE ; 2 + const POKEGEARCARD_RADIO ; 3 +NUM_POKEGEAR_CARDS EQU const_value + +; PokegearJumptable.Jumptable indexes + const_def + const POKEGEARSTATE_CLOCKINIT ; 0 + const POKEGEARSTATE_CLOCKJOYPAD ; 1 + const POKEGEARSTATE_MAPCHECKREGION ; 2 + const POKEGEARSTATE_JOHTOMAPINIT ; 3 + const POKEGEARSTATE_JOHTOMAPJOYPAD ; 4 + const POKEGEARSTATE_KANTOMAPINIT ; 5 + const POKEGEARSTATE_KANTOMAPJOYPAD ; 6 + const POKEGEARSTATE_PHONEINIT ; 7 + const POKEGEARSTATE_PHONEJOYPAD ; 8 + const POKEGEARSTATE_MAKEPHONECALL ; 9 + const POKEGEARSTATE_FINISHPHONECALL ; a + const POKEGEARSTATE_RADIOINIT ; b + const POKEGEARSTATE_RADIOJOYPAD ; c + PokeGear: ; 90b8d (24:4b8d) ld hl, Options ld a, [hl] @@ -63,9 +87,9 @@ PokeGear: ; 90b8d (24:4b8d) ld [rLCDC], a call TownMap_InitCursorAndPlayerIconPositions xor a - ld [wJumptableIndex], a - ld [wcf64], a - ld [wcf65], a + ld [wJumptableIndex], a ; POKEGEARSTATE_CLOCKINIT + ld [wPokegearCard], a ; POKEGEARCARD_CLOCK + ld [wPokegearMapRegion], a ; JOHTO_REGION ld [wcf66], a ld [wPokegearPhoneScrollPosition], a ld [wPokegearPhoneCursorPosition], a @@ -92,7 +116,7 @@ Pokegear_LoadGFX: ; 90c4e ld a, BANK(TownMapGFX) call FarDecompress ld hl, PokegearGFX - ld de, vTiles2 + $30 tiles + ld de, vTiles2 tile $30 ld a, BANK(PokegearGFX) call FarDecompress ld hl, PokegearSpritesGFX @@ -149,7 +173,7 @@ InitPokegearModeIndicatorArrow: ; 90d32 (24:4d32) ret AnimatePokegearModeIndicatorArrow: ; 90d41 (24:4d41) - ld hl, wcf64 + ld hl, wPokegearCard ld e, [hl] ld d, 0 ld hl, .XCoords @@ -163,7 +187,10 @@ AnimatePokegearModeIndicatorArrow: ; 90d41 (24:4d41) ; 90d52 (24:4d52) .XCoords: ; 90d52 - db $00, $10, $20, $30 + db $00 ; POKEGEARCARD_CLOCK + db $10 ; POKEGEARCARD_MAP + db $20 ; POKEGEARCARD_PHONE + db $30 ; POKEGEARCARD_RADIO ; 90d56 TownMap_GetCurrentLandmark: ; 90d56 @@ -210,10 +237,10 @@ TownMap_InitCursorAndPlayerIconPositions: ; 90d70 (24:4d70) ret Pokegear_InitJumptableIndices: ; 90d9e (24:4d9e) - ld a, $0 + ld a, POKEGEARSTATE_CLOCKINIT ld [wJumptableIndex], a - xor a - ld [wcf64], a + xor a ; POKEGEARCARD_CLOCK + ld [wPokegearCard], a ret InitPokegearTilemap: ; 90da8 (24:4da8) @@ -223,8 +250,8 @@ InitPokegearTilemap: ; 90da8 (24:4da8) ld bc, TileMapEnd - TileMap ld a, $4f call ByteFill - ld a, [wcf64] - and $3 + ld a, [wPokegearCard] + maskbits NUM_POKEGEAR_CARDS +- 1 add a ld e, a ld d, 0 @@ -240,7 +267,7 @@ InitPokegearTilemap: ; 90da8 (24:4da8) .return_from_jumptable call Pokegear_FinishTilemap farcall TownMapPals - ld a, [wcf65] + ld a, [wPokegearMapRegion] and a jr nz, .kanto_0 xor a ; LOW(vBGMap0) @@ -260,10 +287,11 @@ InitPokegearTilemap: ; 90da8 (24:4da8) xor a .finish ld [hWY], a - ld a, [wcf65] - and 1 + ; swap region maps + ld a, [wPokegearMapRegion] + maskbits NUM_REGIONS +- 1 xor 1 - ld [wcf65], a + ld [wPokegearMapRegion], a ret .UpdateBGMap: ; 90e00 (24:4e00) @@ -281,6 +309,7 @@ InitPokegearTilemap: ; 90da8 (24:4da8) ; 90e12 (24:4e12) .Jumptable: ; 90e12 +; entries correspond to POKEGEARCARD_* constants dw .Clock dw .Map dw .Phone @@ -319,12 +348,12 @@ InitPokegearTilemap: ; 90da8 (24:4da8) ld e, 1 .ok farcall PokegearMap - ld a, $7 + ld a, $07 ld bc, $12 hlcoord 1, 2 call ByteFill hlcoord 0, 2 - ld [hl], $6 + ld [hl], $06 hlcoord 19, 2 ld [hl], $17 ld a, [wPokegearMapCursorLandmark] @@ -382,13 +411,13 @@ Pokegear_FinishTilemap: ; 90eb0 (24:4eb0) call ByteFill ld de, wPokegearFlags ld a, [de] - bit 0, a + bit 0, a ; ENGINE_MAP_CARD call nz, .PlaceMapIcon ld a, [de] - bit 2, a + bit 2, a ; ENGINE_PHONE_CARD call nz, .PlacePhoneIcon ld a, [de] - bit 1, a + bit 1, a ; ENGINE_RADIO_CARD call nz, .PlaceRadioIcon hlcoord 0, 0 ld a, $46 @@ -433,6 +462,7 @@ PokegearJumptable: ; 90f04 (24:4f04) jp hl .Jumptable: ; 90f13 (24:4f13) +; entries correspond to POKEGEARSTATE_* constants dw PokegearClock_Init dw PokegearClock_Joypad dw PokegearMap_CheckRegion @@ -460,32 +490,32 @@ PokegearClock_Joypad: ; 90f3e (24:4f3e) call .UpdateClock ld hl, hJoyLast ld a, [hl] - and A_BUTTON + B_BUTTON + START + SELECT + and A_BUTTON | B_BUTTON | START | SELECT jr nz, .quit ld a, [hl] and D_RIGHT ret z ld a, [wPokegearFlags] - bit 0, a + bit 0, a ; ENGINE_MAP_CARD jr z, .no_map_card - ld c, $2 - ld b, $1 + ld c, POKEGEARSTATE_MAPCHECKREGION + ld b, POKEGEARCARD_MAP jr .done .no_map_card ld a, [wPokegearFlags] - bit 2, a + bit 2, a ; ENGINE_PHONE_CARD jr z, .no_phone_card - ld c, $7 - ld b, $2 + ld c, POKEGEARSTATE_PHONEINIT + ld b, POKEGEARCARD_PHONE jr .done .no_phone_card ld a, [wPokegearFlags] - bit 1, a + bit 1, a ; ENGINE_RADIO_CARD ret z - ld c, $b - ld b, $3 + ld c, POKEGEARSTATE_RADIOINIT + ld b, POKEGEARCARD_RADIO .done call Pokegear_SwitchPage ret @@ -535,12 +565,12 @@ PokegearMap_CheckRegion: ; 90fb4 (24:4fb4) cp KANTO_LANDMARK jr nc, .kanto .johto - ld a, 3 + ld a, POKEGEARSTATE_JOHTOMAPINIT jr .done ret .kanto - ld a, 5 + ld a, POKEGEARSTATE_KANTOMAPINIT .done ld [wJumptableIndex], a call ExitPokegearRadio_HandleMusic @@ -583,23 +613,23 @@ PokegearMap_ContinueMap: ; 90ff2 (24:4ff2) .right ld a, [wPokegearFlags] - bit 2, a + bit 2, a ; ENGINE_PHONE_CARD jr z, .no_phone - ld c, $7 - ld b, $2 + ld c, POKEGEARSTATE_PHONEINIT + ld b, POKEGEARCARD_PHONE jr .done .no_phone ld a, [wPokegearFlags] - bit 1, a + bit 1, a ; ENGINE_RADIO_CARD ret z - ld c, $b - ld b, $3 + ld c, POKEGEARSTATE_RADIOINIT + ld b, POKEGEARCARD_RADIO jr .done .left - ld c, $0 - ld b, $0 + ld c, POKEGEARSTATE_CLOCKINIT + ld b, POKEGEARCARD_CLOCK .done call Pokegear_SwitchPage ret @@ -657,7 +687,7 @@ PokegearMap_InitPlayerIcon: ; 9106a depixel 0, 0 ld b, SPRITE_ANIM_INDEX_RED_WALK ld a, [wPlayerGender] - bit 0, a + bit 0, a ; ENGINE_PLAYER_IS_FEMALE jr z, .got_gender ld b, SPRITE_ANIM_INDEX_BLUE_WALK .got_gender @@ -688,7 +718,7 @@ PokegearMap_InitCursor: ; 91098 call _InitSpriteAnimStruct ld hl, SPRITEANIMSTRUCT_TILE_ID add hl, bc - ld [hl], $4 + ld [hl], $04 ld hl, SPRITEANIMSTRUCT_ANIM_SEQ_ID add hl, bc ld [hl], SPRITE_ANIM_SEQ_NULL @@ -734,7 +764,7 @@ PokegearMap_UpdateCursorPosition: ; 910d4 TownMap_GetKantoLandmarkLimits: ; 910e8 ld a, [wStatusFlags] - bit 6, a + bit 6, a ; ENGINE_CREDITS_SKIP jr z, .not_hof ld d, ROUTE_28 ld e, PALLET_TOWN @@ -754,7 +784,7 @@ PokegearRadio_Init: ; 910f9 (24:50f9) call _InitSpriteAnimStruct ld hl, SPRITEANIMSTRUCT_TILE_ID add hl, bc - ld [hl], $8 + ld [hl], $08 call _UpdateRadioStation ld hl, wJumptableIndex inc [hl] @@ -780,23 +810,23 @@ PokegearRadio_Joypad: ; 91112 (24:5112) .left ld a, [wPokegearFlags] - bit 2, a + bit 2, a ; ENGINE_PHONE_CARD jr z, .no_phone - ld c, $7 - ld b, $2 + ld c, POKEGEARSTATE_PHONEINIT + ld b, POKEGEARCARD_PHONE jr .switch_page .no_phone ld a, [wPokegearFlags] - bit 0, a + bit 0, a ; ENGINE_MAP_CARD jr z, .no_map - ld c, $2 - ld b, $1 + ld c, POKEGEARSTATE_MAPCHECKREGION + ld b, POKEGEARCARD_MAP jr .switch_page .no_map - ld c, $0 - ld b, $0 + ld c, POKEGEARSTATE_CLOCKINIT + ld b, POKEGEARCARD_CLOCK .switch_page call Pokegear_SwitchPage ret @@ -839,23 +869,23 @@ PokegearPhone_Joypad: ; 91171 (24:5171) .left ld a, [wPokegearFlags] - bit 0, a + bit 0, a ; ENGINE_MAP_CARD jr z, .no_map - ld c, $2 - ld b, $1 + ld c, POKEGEARSTATE_MAPCHECKREGION + ld b, POKEGEARCARD_MAP jr .switch_page .no_map - ld c, $0 - ld b, $0 + ld c, POKEGEARSTATE_CLOCKINIT + ld b, POKEGEARCARD_CLOCK jr .switch_page .right ld a, [wPokegearFlags] - bit 1, a + bit 1, a ; ENGINE_RADIO_CARD ret z - ld c, $b - ld b, $3 + ld c, POKEGEARSTATE_RADIOINIT + ld b, POKEGEARCARD_RADIO .switch_page call Pokegear_SwitchPage ret @@ -891,7 +921,7 @@ PokegearPhone_Joypad: ; 91171 (24:5171) ret .quit_submenu - ld a, $8 + ld a, POKEGEARSTATE_PHONEJOYPAD ld [wJumptableIndex], a ret @@ -931,7 +961,7 @@ PokegearPhone_MakePhoneCall: ; 911eb (24:51eb) farcall Phone_NoSignal ld hl, .OutOfServiceArea call PrintText - ld a, $8 + ld a, POKEGEARSTATE_PHONEJOYPAD ld [wJumptableIndex], a ld hl, PokegearText_WhomToCall call PrintText @@ -958,7 +988,7 @@ PokegearPhone_FinishPhoneCall: ; 91256 (24:5256) and A_BUTTON | B_BUTTON ret z farcall HangUp - ld a, $8 + ld a, POKEGEARSTATE_PHONEJOYPAD ld [wJumptableIndex], a ld hl, PokegearText_WhomToCall call PrintText @@ -993,7 +1023,7 @@ PokegearPhone_GetDPad: ; 9126d (24:526d) .down ld hl, wPokegearPhoneCursorPosition ld a, [hl] - cp $3 + cp 3 jr nc, .scroll_page_down inc [hl] jr .done_joypad_same_page @@ -1001,7 +1031,7 @@ PokegearPhone_GetDPad: ; 9126d (24:526d) .scroll_page_down ld hl, wPokegearPhoneScrollPosition ld a, [hl] - cp $6 + cp 6 ret nc inc [hl] jr .done_joypad_update_page @@ -1075,7 +1105,7 @@ PokegearPhone_UpdateDisplayList: ; 912d8 (24:52d8) ld a, [wPokegearPhoneLoadNameBuffer] inc a ld [wPokegearPhoneLoadNameBuffer], a - cp $4 + cp 4 jr c, .loop call PokegearPhone_UpdateCursor ret @@ -1309,7 +1339,7 @@ PokegearPhoneContactSubmenu: ; 91342 (24:5342) ; 9146e -; XXX +; unused ld a, [hHours] cp 12 jr c, .am @@ -1331,15 +1361,15 @@ Pokegear_SwitchPage: ; 91480 (24:5480) ld a, c ld [wJumptableIndex], a ld a, b - ld [wcf64], a + ld [wPokegearCard], a call DeleteSpriteAnimStruct2ToEnd ret ExitPokegearRadio_HandleMusic: ; 91492 ld a, [wPokegearRadioMusicPlaying] - cp $fe + cp RESTART_MAP_MUSIC jr z, .restart_map_music - cp $ff + cp ENTER_MAP_MUSIC call z, EnterMapMusic xor a ld [wPokegearRadioMusicPlaying], a @@ -1364,11 +1394,11 @@ DeleteSpriteAnimStruct2ToEnd: ; 914ab (24:54ab) Pokegear_LoadTilemapRLE: ; 914bb (24:54bb) ; Format: repeat count, tile ID - ; Terminated with $FF + ; Terminated with -1 hlcoord 0, 0 .loop ld a, [de] - cp $ff + cp -1 ret z ld b, a inc de @@ -1499,7 +1529,7 @@ UpdateRadioStation: ; 9166f (24:566f) ; 916a1 (24:56a1) -; XXX +; unused ld [wPokegearRadioChannelBank], a ld a, [hli] ld [wPokegearRadioChannelAddr], a @@ -1510,7 +1540,7 @@ UpdateRadioStation: ; 9166f (24:566f) ; 916ad RadioChannels: -; frequencies and the shows that play on them. +; entries correspond to constants/radio_constants.asm ; frequency value given here = 4 × ingame_frequency − 2 dbw 16, .PkmnTalkAndPokedexShow @@ -1560,7 +1590,7 @@ RadioChannels: call .InJohto jr c, .NoSignal ld a, [wPokegearFlags] - bit 3, a + bit 3, a ; ENGINE_EXPN_CARD jr z, .NoSignal jp LoadStation_PlacesAndPeople @@ -1568,7 +1598,7 @@ RadioChannels: call .InJohto jr c, .NoSignal ld a, [wPokegearFlags] - bit 3, a + bit 3, a ; ENGINE_EXPN_CARD jr z, .NoSignal jp LoadStation_LetsAllSing @@ -1576,14 +1606,14 @@ RadioChannels: call .InJohto jr c, .NoSignal ld a, [wPokegearFlags] - bit 3, a + bit 3, a ; ENGINE_EXPN_CARD jr z, .NoSignal jp LoadStation_PokeFluteRadio .EvolutionRadio: ; This station airs in the Lake of Rage area when Rocket are still in Mahogany. ld a, [wStatusFlags] - bit 4, a + bit 4, a ; ENGINE_ROCKET_SIGNAL_ON_CH20 jr z, .NoSignal ld a, [wPokegearMapPlayerIconLandmark] cp MAHOGANY_TOWN @@ -1669,7 +1699,7 @@ LoadStation_BuenasPassword: ; 917a5 (24:57a5) call Radio_BackUpFarCallParams ld de, NotBuenasPasswordName ld a, [wStatusFlags2] - bit 0, a + bit 0, a ; ENGINE_ROCKETS_IN_RADIO_TOWER ret z ld de, BuenasPasswordName ret @@ -1751,7 +1781,7 @@ LoadStation_EvolutionRadio: ; 9183e (24:583e) ; 91853 (24:5853) -LoadStation_Dummy: ; 91853 +Unreferenced_LoadStation: ; 91853 ret RadioMusicRestartDE: ; 91854 (24:5854) @@ -1768,7 +1798,7 @@ RadioMusicRestartDE: ; 91854 (24:5854) RadioMusicRestartPokemonChannel: ; 91868 (24:5868) push de - ld a, $fe + ld a, RESTART_MAP_MUSIC ld [wPokegearRadioMusicPlaying], a ld de, MUSIC_NONE call PlayMusic @@ -1799,7 +1829,7 @@ NoRadioStation: ; 91888 (24:5888) NoRadioMusic: ; 9189d (24:589d) ld de, MUSIC_NONE call PlayMusic - ld a, $ff + ld a, ENTER_MAP_MUSIC ld [wPokegearRadioMusicPlaying], a ret @@ -1810,7 +1840,7 @@ NoRadioName: ; 918a9 (24:58a9) lb bc, 3, 18 call ClearBox hlcoord 0, 12 - ld bc, $412 + lb bc, 4, 18 call TextBox ret @@ -1966,26 +1996,26 @@ _TownMap: ; 9191c ld a, [wTownMapPlayerIconLandmark] cp KANTO_LANDMARK jr nc, .kanto2 - ld e, $0 + ld e, JOHTO_REGION jr .okay_tilemap .kanto2 - ld e, $1 + ld e, KANTO_REGION .okay_tilemap farcall PokegearMap - ld a, $7 + ld a, $07 ld bc, 6 hlcoord 1, 0 call ByteFill hlcoord 0, 0 - ld [hl], $6 + ld [hl], $06 hlcoord 7, 0 ld [hl], $17 hlcoord 7, 1 ld [hl], $16 hlcoord 7, 2 ld [hl], $26 - ld a, $7 + ld a, $07 ld bc, NAME_LENGTH hlcoord 8, 2 call ByteFill @@ -2001,7 +2031,7 @@ PlayRadio: ; 91a53 ld hl, Options ld a, [hl] push af - set 4, [hl] + set NO_TEXT_SCROLL, [hl] call .PlayStation ld c, 100 call DelayFrames @@ -2031,10 +2061,10 @@ PlayRadio: ; 91a53 ; 91a87 .PlayStation: ; 91a87 - ld a, -1 - ld [EnemyTurnsTaken], a + ld a, ENTER_MAP_MUSIC + ld [wPokegearRadioMusicPlaying], a ld hl, .StationPointers - ld d, $0 + ld d, 0 add hl, de add hl, de ld a, [hli] @@ -2063,6 +2093,7 @@ PlayRadio: ; 91a53 ; 91ab9 .StationPointers: ; 91ab9 +; entries correspond to radio station constants dw .OakOrPnP dw LoadStation_OaksPokemonTalk dw LoadStation_PokedexShow @@ -2286,7 +2317,7 @@ TownMapBubble: ; 91bb5 GetMapCursorCoordinates: ; 91c17 ld a, [wTownMapPlayerIconLandmark] ld l, a - ld h, $0 + ld h, 0 add hl, hl ld de, Flypoints add hl, de @@ -2296,10 +2327,10 @@ GetMapCursorCoordinates: ; 91c17 ld c, a ld a, [wTownMapCursorCoordinates + 1] ld b, a - ld hl, $4 + ld hl, 4 add hl, bc ld [hl], e - ld hl, $5 + ld hl, 5 add hl, bc ld [hl], d ret @@ -2331,7 +2362,7 @@ HasVisitedSpawn: ; 91c50 ld hl, wVisitedSpawns ld b, CHECK_FLAG ld d, 0 - predef FlagPredef + predef Predef_SmallFarFlagAction ld a, c ret @@ -2440,7 +2471,7 @@ FlyMap: ; 91c90 ; 91d11 -_Area: ; 91d11 +Predef_Pokedex_GetArea: ; 91d11 ; e: Current landmark ld a, [wTownMapPlayerIconLandmark] push af @@ -2477,7 +2508,7 @@ _Area: ; 91d11 call SetPalettes xor a ld [hBGMapMode], a - xor a ; Johto + xor a ; JOHTO_REGION call .GetAndPlaceNest .loop call JoyTextDelay @@ -2524,13 +2555,13 @@ _Area: ; 91d11 call ClearSprites ld a, $90 ld [hWY], a - xor a ; Johto + xor a ; JOHTO_REGION call .GetAndPlaceNest ret .right ld a, [wStatusFlags] - bit 6, a ; hall of fame + bit 6, a ; ENGINE_CREDITS_SKIP ret z ld a, [hWY] and a @@ -2538,7 +2569,7 @@ _Area: ; 91d11 call ClearSprites xor a ld [hWY], a - ld a, 1 ; Kanto + ld a, KANTO_REGION call .GetAndPlaceNest ret @@ -2596,7 +2627,7 @@ _Area: ; 91d11 ld e, a farcall FindNest ; load nest landmarks into TileMap[0,0] decoord 0, 0 - ld hl, Sprites + ld hl, Sprite01 .nestloop ld a, [de] and a @@ -2609,14 +2640,14 @@ _Area: ; 91d11 ; load into OAM ld a, d sub 4 - ld [hli], a + ld [hli], a ; y ld a, e sub 4 - ld [hli], a - ld a, $7f ; nest icon in this context - ld [hli], a + ld [hli], a ; x + ld a, $7f ; nest icon + ld [hli], a ; tile id xor a - ld [hli], a + ld [hli], a ; attributes ; next pop de inc de @@ -2640,37 +2671,37 @@ _Area: ; 91d11 ld c, e ld b, d ld de, .PlayerOAM - ld hl, Sprites + ld hl, Sprite01 .ShowPlayerLoop: ld a, [de] cp $80 jr z, .clear_oam add b - ld [hli], a + ld [hli], a ; y inc de ld a, [de] add c - ld [hli], a + ld [hli], a ; x inc de ld a, [de] add $78 ; where the player's sprite is loaded - ld [hli], a + ld [hli], a ; tile id inc de push bc - ld c, 0 ; RED + ld c, PAL_OW_RED ld a, [wPlayerGender] bit 0, a - jr z, .got_gender - inc c ; BLUE -.got_gender + jr z, .male + inc c ; PAL_OW_BLUE +.male ld a, c - ld [hli], a + ld [hli], a ; attributes pop bc jr .ShowPlayerLoop .clear_oam - ld hl, Sprites + 4 * 4 - ld bc, SpritesEnd - (Sprites + 4 * 4) + ld hl, Sprite05 + ld bc, SpritesEnd - Sprite05 xor a call ByteFill ret @@ -2678,10 +2709,11 @@ _Area: ; 91d11 ; 91e9c .PlayerOAM: ; 91e9c - db -1 * 8, -1 * 8, 0 ; top left - db -1 * 8, 0 * 8, 1 ; top right - db 0 * 8, -1 * 8, 2 ; bottom left - db 0 * 8, 0 * 8, 3 ; bottom right + ; y pxl, x pxl, tile offset + db -1 * 8, -1 * 8, 0 ; top left + db -1 * 8, 0 * 8, 1 ; top right + db 0 * 8, -1 * 8, 2 ; bottom left + db 0 * 8, 0 * 8, 3 ; bottom right db $80 ; terminator ; 91ea9 @@ -2790,12 +2822,11 @@ TownMapPals: ; 91f13 ; Current tile ld a, [hli] push hl -; HP/borders use palette 0 +; The palette map covers tiles $00 to $5f; $60 and above use palette 0 cp $60 jr nc, .pal0 -; The palette data is condensed to nybbles, -; least-significant first. +; The palette data is condensed to nybbles, least-significant first. ld hl, .PalMap srl a jr c, .odd @@ -2806,7 +2837,7 @@ TownMapPals: ; 91f13 adc 0 ld h, a ld a, [hl] - and %111 + and PALETTE_MASK jr .update .odd @@ -2818,7 +2849,7 @@ TownMapPals: ; 91f13 ld h, a ld a, [hl] swap a - and %111 + and PALETTE_MASK jr .update .pal0 @@ -2834,11 +2865,11 @@ TownMapPals: ; 91f13 ret .PalMap: -INCLUDE "data/palettes/town_map.asm" +INCLUDE "gfx/pokegear/town_map_palette_map.asm" ; 91f7b TownMapMon: ; 91f7b -; Draw the FlyMon icon at town map location in +; Draw the FlyMon icon at town map location ; Get FlyMon species ld a, [CurPartyMon] @@ -2849,7 +2880,7 @@ TownMapMon: ; 91f7b ld a, [hl] ld [wd265], a ; Get FlyMon icon - ld e, 8 ; starting tile in VRAM + ld e, $08 ; starting tile in VRAM farcall GetSpeciesIcon ; Animation/palette depixel 0, 0 @@ -2857,7 +2888,7 @@ TownMapMon: ; 91f7b call _InitSpriteAnimStruct ld hl, SPRITEANIMSTRUCT_TILE_ID add hl, bc - ld [hl], $8 + ld [hl], $08 ld hl, SPRITEANIMSTRUCT_ANIM_SEQ_ID add hl, bc ld [hl], SPRITE_ANIM_SEQ_NULL @@ -2913,7 +2944,7 @@ TownMapPlayerIcon: ; 91fa6 LoadTownMapGFX: ; 91ff2 ld hl, TownMapGFX ld de, vTiles2 - lb bc, BANK(TownMapGFX), $30 + lb bc, BANK(TownMapGFX), 48 call DecompressRequest2bpp ret @@ -2932,7 +2963,7 @@ INCBIN "gfx/pokegear/dexmap_nest_icon.2bpp" FlyMapLabelBorderGFX: ; 922e1 INCBIN "gfx/pokegear/flymap_label_border.1bpp" -; XXX +Unreferenced_Function92311: xor a ld [wTownMapPlayerIconLandmark], a call ClearBGPalettes diff --git a/engine/predef.asm b/engine/predef.asm index 837f7b96b..62ca7b147 100644 --- a/engine/predef.asm +++ b/engine/predef.asm @@ -30,79 +30,79 @@ PredefPointers:: ; 856b ; $4b Predef pointers ; address, bank - add_predef LearnMove ; $0 - add_predef Predef1 - add_predef HealParty - add_predef FlagPredef - add_predef ComputeHPBarPixels - add_predef FillPP - add_predef TryAddMonToParty - add_predef AddTempmonToParty - add_predef SentGetPkmnIntoFromBox - add_predef SentPkmnIntoBox - add_predef GiveEgg - add_predef AnimateHPBar - add_predef CalcPkmnStats - add_predef CalcPkmnStatC - add_predef CanLearnTMHMMove - add_predef GetTMHMMove + add_predef Predef_LearnMove ; $0 + add_predef DummyPredef1 + add_predef HealParty ; this is both a special and a predef + add_predef Predef_SmallFarFlagAction + add_predef Predef_ComputeHPBarPixels + add_predef Predef_FillPP + add_predef Predef_TryAddMonToParty + add_predef Predef_AddTempmonToParty + add_predef Predef_SendGetPkmnIntoFromBox + add_predef Predef_SendPkmnIntoBox + add_predef Predef_GiveEgg + add_predef Predef_AnimateHPBar + add_predef Predef_CalcPkmnStats + add_predef Predef_CalcPkmnStatC + add_predef Predef_CanLearnTMHMMove + add_predef Predef_GetTMHMMove add_predef Predef_LinkTextbox ; $ 10 - add_predef PrintMoveDesc - add_predef UpdatePlayerHUD - add_predef PlaceGraphic - add_predef CheckPlayerPartyForFitPkmn - add_predef UpdateEnemyHUD - add_predef StartBattle - add_predef FillInExpBar - add_predef GetBattleMonBackpic ; $18 - add_predef GetEnemyMonFrontpic - add_predef LearnLevelMoves - add_predef FillMoves - add_predef EvolveAfterBattle - add_predef TradeAnimationPlayer2 - add_predef TradeAnimation - add_predef CopyPkmnToTempMon - add_predef ListMoves ; $20 - add_predef PlaceNonFaintStatus - add_predef Predef22 - add_predef ListMovePP - add_predef GetGender - add_predef StatsScreenInit - add_predef DrawPlayerHP - add_predef DrawEnemyHP - add_predef PrintTempMonStats ; $28 - add_predef GetTypeName - add_predef PrintMoveType - add_predef PrintType - add_predef PrintMonTypes - add_predef GetUnownLetter - add_predef LoadPoisonBGPals - add_predef Predef2F - add_predef InitSGBBorder ; $30 - add_predef Predef_LoadSGBLayout - add_predef _Area - add_predef CheckContestMon + add_predef Predef_PrintMoveDesc + add_predef Predef_UpdatePlayerHUD + add_predef Predef_PlaceGraphic + add_predef Predef_CheckPlayerPartyForFitPkmn + add_predef Predef_UpdateEnemyHUD add_predef Predef_StartBattle - add_predef Predef35 - add_predef Predef36 - add_predef PlayBattleAnim - add_predef Predef38 ; $38 - add_predef Predef39 - add_predef Predef3A - add_predef PartyMonItemName - add_predef GetMonFrontpic - add_predef GetMonBackpic - add_predef GetAnimatedFrontpicPredef - add_predef GetTrainerPic - add_predef DecompressPredef ; $40 - add_predef CheckTypeMatchup - add_predef ConvertMon_1to2 - add_predef NewPokedexEntry - add_predef AnimateMon_Slow_Normal - add_predef PlaceStatusString - add_predef LoadMonAnimation - add_predef AnimateFrontpic - add_predef Predef48 ; $48 - add_predef HOF_AnimateFrontpic + add_predef Predef_FillInExpBar + add_predef Predef_GetBattleMonBackpic ; $18 + add_predef Predef_GetEnemyMonFrontpic + add_predef Predef_LearnLevelMoves + add_predef Predef_FillMoves + add_predef Predef_EvolveAfterBattle + add_predef Predef_TradeAnimationPlayer2 + add_predef Predef_TradeAnimation + add_predef Predef_CopyPkmnToTempMon + add_predef Predef_ListMoves ; $20 + add_predef Predef_PlaceNonFaintStatus + add_predef UnusedPredef22 + add_predef Predef_ListMovePP + add_predef Predef_GetGender + add_predef Predef_StatsScreenInit + add_predef Predef_DrawPlayerHP + add_predef Predef_DrawEnemyHP + add_predef Predef_PrintTempMonStats ; $28 + add_predef Predef_GetTypeName + add_predef Predef_PrintMoveType + add_predef Predef_PrintType + add_predef Predef_PrintMonTypes + add_predef Predef_GetUnownLetter + add_predef Predef_LoadPoisonBGPals + add_predef DummyPredef2F + add_predef Predef_InitSGBBorder ; $30 + add_predef Predef_LoadSGBLayout + add_predef Predef_Pokedex_GetArea + add_predef UnusedPredef_CheckContestMon + add_predef Predef_DoBattleTransition + add_predef DummyPredef35 + add_predef DummyPredef36 + add_predef Predef_PlayBattleAnim + add_predef DummyPredef38 ; $38 + add_predef DummyPredef39 + add_predef DummyPredef3A + add_predef Predef_PartyMonItemName + add_predef Predef_GetMonFrontpic + add_predef Predef_GetMonBackpic + add_predef Predef_GetAnimatedFrontpic + add_predef Predef_GetTrainerPic + add_predef Predef_Decompress ; $40 + add_predef Predef_CheckTypeMatchup + add_predef Predef_ConvertMon_1to2 + add_predef Predef_NewPokedexEntry + add_predef UnusedPredef_AnimateMon_Slow_Normal + add_predef Predef_PlaceStatusString + add_predef Predef_LoadMonAnimation + add_predef Predef_AnimateFrontpic + add_predef UnusedPredef48 ; $48 + add_predef HOF_Predef_AnimateFrontpic dbw $ff, InexplicablyEmptyFunction ; ??? ; 864c diff --git a/engine/print_party.asm b/engine/print_party.asm index f2420dfe8..28f7a7c53 100755 --- a/engine/print_party.asm +++ b/engine/print_party.asm @@ -1,3 +1,5 @@ +PRINTPARTY_HP EQUS "\"◀\"" ; $71 + PrintPage1: ; 1dc1b0 hlcoord 0, 0 decoord 0, 0, wPrinterTileMapBuffer @@ -141,23 +143,23 @@ PrintPartyMonPage1: ; 1dc381 call LoadFontsBattleExtra ld de, GBPrinterHPIcon - ld hl, vTiles2 tile $71 + ld hl, vTiles2 tile PRINTPARTY_HP lb bc, BANK(GBPrinterHPIcon), 1 call Request1bpp ld de, GBPrinterLvIcon - ld hl, vTiles2 tile $6e + ld hl, vTiles2 tile "<LV>" lb bc, BANK(GBPrinterLvIcon), 1 call Request1bpp - ld de, ShinyIconGFX - ld hl, vTiles2 tile $3f - lb bc, BANK(ShinyIconGFX), 1 + ld de, StatsScreenPageTilesGFX + 14 tiles ; shiny icon + ld hl, vTiles2 tile "<SHINY>" + lb bc, BANK(StatsScreenPageTilesGFX), 1 call Get2bpp xor a ld [MonType], a - farcall CopyPkmnToTempMon + farcall Predef_CopyPkmnToTempMon hlcoord 0, 7 ld b, 9 ld c, 18 @@ -166,7 +168,7 @@ PrintPartyMonPage1: ; 1dc381 ld a, [TempMonLevel] call PrintLevel_Force3Digits hlcoord 12, 2 - ld [hl], "◀" ; Filled left triangle + ld [hl], PRINTPARTY_HP inc hl ld de, TempMonMaxHP lb bc, 2, 3 @@ -213,7 +215,7 @@ PrintPartyMonPage1: ; 1dc381 call Function1dc51a call Function1dc52c ld hl, TempMonDVs - predef GetUnownLetter + predef Predef_GetUnownLetter ld hl, wBoxAlignment xor a ld [hl], a @@ -241,7 +243,7 @@ PrintPartyMonPage2: ; 1dc47b call LoadFontsBattleExtra xor a ld [MonType], a - farcall CopyPkmnToTempMon + farcall Predef_CopyPkmnToTempMon hlcoord 0, 0 ld b, 15 ld c, 18 @@ -316,7 +318,7 @@ Function1dc51a: ; 1dc51a ; 1dc52c Function1dc52c: ; 1dc52c - farcall GetGender + farcall Predef_GetGender ld a, " " jr c, .got_gender ld a, "♂" diff --git a/engine/printer.asm b/engine/printer.asm index 68c3c6c9f..0e0696e2b 100755 --- a/engine/printer.asm +++ b/engine/printer.asm @@ -596,8 +596,7 @@ PlacePrinterStatusString: ; 84785 ret ; 847bd -Function847bd: ; 847bd -; XXX +Unreferenced_Function847bd: ; 847bd ld a, [wPrinterStatus] and a ret z @@ -861,7 +860,7 @@ Printer_GetMonGender: ; 8498a (21:498a) ld [CurPartyMon], a ld a, TEMPMON ld [MonType], a - farcall GetGender + farcall Predef_GetGender ld a, " " jr c, .got_gender ld a, "♂" diff --git a/engine/printnum.asm b/engine/printnum.asm index d1d7e7ad3..fec798d5c 100755 --- a/engine/printnum.asm +++ b/engine/printnum.asm @@ -165,7 +165,7 @@ _PrintNum:: ; c4c7 dec e jr nz, .money_leading_zero inc hl - ld [hl], $f2 ; XXX + ld [hl], "<DOT>" .money_leading_zero call .AdvancePointer diff --git a/engine/radio.asm b/engine/radio.asm index 42db63ab0..de19a289c 100644 --- a/engine/radio.asm +++ b/engine/radio.asm @@ -28,6 +28,7 @@ PlayRadioShow: jp hl RadioJumptable: +; entries correspond to constants/radio_constants.asm dw OaksPkmnTalk1 ; $00 dw PokedexShow1 ; $01 dw BenMonMusic1 ; $02 @@ -203,11 +204,11 @@ OaksPkmnTalk4: ; Choose a random route, and a random Pokemon from that route. .sample call Random - and $1f - cp $f ; so wasteful + and %11111 + cp (OaksPkmnTalkRoutesEnd - OaksPkmnTalkRoutes) / 2 jr nc, .sample ; We now have a number between 0 and 14. - ld hl, .routes + ld hl, OaksPkmnTalkRoutes ld c, a ld b, 0 add hl, bc @@ -239,14 +240,15 @@ OaksPkmnTalk4: jr .loop .done + ; Point hl to the list of morning Pokémon., skipping percentages rept 4 inc hl endr ; Generate a number, either 0, 1, or 2, to choose a time of day. .loop2 call Random - and 3 - cp 3 + maskbits NUM_DAYTIMES +- 1 + cp DARKNESS_F jr z, .loop2 ld bc, 2 * NUM_GRASSMON @@ -273,6 +275,7 @@ endr ld de, wMonOrItemNameBuffer ld bc, PKMN_NAME_LENGTH call CopyBytes + ; Now that we've chosen our wild Pokemon, ; let's recover the map index info and get its name. pop bc @@ -289,22 +292,7 @@ endr ld a, OAKS_POKEMON_TALK jp PrintRadioLine -.routes - map ROUTE_29 - map ROUTE_46 - map ROUTE_30 - map ROUTE_32 - map ROUTE_34 - map ROUTE_35 - map ROUTE_37 - map ROUTE_38 - map ROUTE_39 - map ROUTE_42 - map ROUTE_43 - map ROUTE_44 - map ROUTE_45 - map ROUTE_36 - map ROUTE_31 +INCLUDE "data/radio/oaks_pkmn_talk_routes.asm" OaksPkmnTalk5: ld hl, OPT_OakText2 @@ -360,11 +348,13 @@ OPT_MaryText1: db "@" OaksPkmnTalk8: + ; 0-15 are all valid indexes into .Adverbs, + ; so no need for a retry loop call Random - and $f + maskbits NUM_OAKS_MON_TALK_ADVERBS +- 1 ld e, a ld d, 0 - ld hl, .Descriptors + ld hl, .Adverbs add hl, de add hl, de ld a, [hli] @@ -373,7 +363,8 @@ OaksPkmnTalk8: ld a, OAKS_POKEMON_TALK_9 jp NextRadioLine -.Descriptors: +.Adverbs: +; there are NUM_OAKS_MON_TALK_ADVERBS entries dw .sweetadorably dw .wigglyslickly dw .aptlynamed @@ -472,11 +463,13 @@ OaksPkmnTalk8: db "@" OaksPkmnTalk9: + ; 0-15 are all valid indexes into .Adjectives, + ; so no need for a retry loop call Random - and $f + maskbits NUM_OAKS_MON_TALK_ADJECTIVES +- 1 ld e, a ld d, 0 - ld hl, .Descriptors + ld hl, .Adjectives add hl, de add hl, de ld a, [hli] @@ -493,7 +486,8 @@ OaksPkmnTalk9: .ok jp NextRadioLine -.Descriptors: +.Adjectives: +; there are NUM_OAKS_MON_TALK_ADJECTIVES entries dw .cute dw .weird dw .pleasant @@ -652,7 +646,7 @@ OaksPkmnTalk14: ld hl, wRadioTextDelay dec [hl] ret nz - ld de, $1d + ld de, MUSIC_POKEMON_TALK callfar RadioMusicRestartDE ld hl, .terminator call PrintText @@ -698,8 +692,8 @@ PokedexShow_GetDexEntryBank: dec a rlca rlca - and 3 - ld hl, .pokedexbanks + maskbits NUM_DEX_ENTRY_BANKS +- 1 + ld hl, .PokedexEntryBanks ld d, 0 ld e, a add hl, de @@ -708,7 +702,7 @@ PokedexShow_GetDexEntryBank: pop hl ret -.pokedexbanks +.PokedexEntryBanks db BANK(PokedexEntries1) db BANK(PokedexEntries2) db BANK(PokedexEntries3) @@ -1146,7 +1140,7 @@ PeoplePlaces2: PeoplePlaces3: ld hl, PnP_Text3 call Random - cp $7b ; 48 percent + cp 49 percent - 1 ld a, PLACES_AND_PEOPLE_4 ; People jr c, .ok ld a, PLACES_AND_PEOPLE_6 ; Places @@ -1170,20 +1164,20 @@ PnP_Text3: PeoplePlaces4: ; People call Random - and $7f + maskbits NUM_TRAINER_CLASSES +- 1 inc a cp NUM_TRAINER_CLASSES - 1 jr nc, PeoplePlaces4 push af - ld hl, .E4Names + ld hl, PnP_HiddenPeople ld a, [wStatusFlags] bit 6, a ; ENGINE_CREDITS_SKIP jr z, .ok - ld hl, .KantoLeaderNames + ld hl, PnP_HiddenPeople_BeatE4 ld a, [wKantoBadges] - cp %11111111 + cp %11111111 ; all badges jr nz, .ok - ld hl, .MiscNames + ld hl, PnP_HiddenPeople_BeatKanto .ok pop af ld c, a @@ -1203,10 +1197,7 @@ PeoplePlaces4: ; People ld a, PLACES_AND_PEOPLE_5 jp NextRadioLine -.E4Names: db WILL, BRUNO, KAREN, KOGA, CHAMPION -.KantoLeaderNames: db BROCK, MISTY, LT_SURGE, ERIKA, JANINE, SABRINA, BLAINE, BLUE -.MiscNames: db RIVAL1, POKEMON_PROF, CAL, RIVAL2, RED - db -1 +INCLUDE "data/radio/pnp_hidden_people.asm" PnP_Text4: ; @ @ @ @@ -1214,29 +1205,32 @@ PnP_Text4: db "@" PeoplePlaces5: + ; 0-15 are all valid indexes into .Adjectives, + ; so no need for a retry loop call Random - and $f + maskbits NUM_PNP_PEOPLE_ADJECTIVES +- 1 ld e, a ld d, 0 - ld hl, .Descriptors + ld hl, .Adjectives add hl, de add hl, de ld a, [hli] ld h, [hl] ld l, a call Random - cp $a ; 6.25 percent + cp 4 percent ld a, PLACES_AND_PEOPLE jr c, .ok call Random - cp $7b ; 48 percent + cp 49 percent - 1 ld a, PLACES_AND_PEOPLE_4 ; People jr c, .ok ld a, PLACES_AND_PEOPLE_6 ; Places .ok jp NextRadioLine -.Descriptors: +.Adjectives: +; there are NUM_PNP_PEOPLE_ADJECTIVES entries dw PnP_cute dw PnP_lazy dw PnP_happy @@ -1336,9 +1330,9 @@ PnP_odd: PeoplePlaces6: ; Places call Random - cp 9 + cp (PnP_HiddenPlacesEnd - PnP_HiddenPlaces) / 2 jr nc, PeoplePlaces6 - ld hl, .Maps + ld hl, PnP_HiddenPlaces ld c, a ld b, 0 add hl, bc @@ -1353,16 +1347,7 @@ PeoplePlaces6: ; Places ld a, PLACES_AND_PEOPLE_7 jp NextRadioLine -.Maps: - map PALLET_TOWN - map ROUTE_22 - map PEWTER_CITY - map CERULEAN_POLICE_STATION - map ROUTE_12 - map ROUTE_11 - map ROUTE_16 - map ROUTE_14 - map CINNABAR_POKECENTER_2F_BETA +INCLUDE "data/radio/pnp_hidden_places.asm" PnP_Text5: ; @ @ @@ -1370,11 +1355,13 @@ PnP_Text5: db "@" PeoplePlaces7: + ; 0-15 are all valid indexes into .Adjectives, + ; so no need for a retry loop call Random - and $f + maskbits NUM_PNP_PLACES_ADJECTIVES +- 1 ld e, a ld d, 0 - ld hl, .Descriptors + ld hl, .Adjectives add hl, de add hl, de ld a, [hli] @@ -1386,14 +1373,15 @@ PeoplePlaces7: ld a, PLACES_AND_PEOPLE jr c, .ok call Random - cp 1 + 48 percent + cp 49 percent - 1 ld a, PLACES_AND_PEOPLE_4 ; People jr c, .ok ld a, PLACES_AND_PEOPLE_6 ; Places .ok jp PrintRadioLine -.Descriptors: +.Adjectives: +; there are NUM_PNP_PLACES_ADJECTIVES entries dw PnP_cute dw PnP_lazy dw PnP_happy @@ -1572,12 +1560,12 @@ BuenasPassword4: ld a, [wBuenasPassword] ; If we already generated the password today, we don't need to generate a new one. ld hl, wWeeklyFlags - bit 7, [hl] + bit 7, [hl] ; ENGINE_BUENAS_PASSWORD jr nz, .AlreadyGotIt ; There are only 11 groups to choose from. .greater_than_11 call Random - maskbits NUM_PASSWORD_CATEGORIES + maskbits NUM_PASSWORD_CATEGORIES +- 1 cp NUM_PASSWORD_CATEGORIES jr nc, .greater_than_11 ; Store it in the high nybble of e. @@ -1586,7 +1574,7 @@ BuenasPassword4: ; For each group, choose one of the three passwords. .greater_than_three call Random - and $3 + maskbits NUM_PASSWORDS_PER_CATEGORY +- 1 cp NUM_PASSWORDS_PER_CATEGORY jr nc, .greater_than_three ; The high nybble of wBuenasPassword will now contain the password group index, and the low nybble contains the actual password. @@ -1594,7 +1582,7 @@ BuenasPassword4: ld [wBuenasPassword], a ; Set the flag so that we don't generate a new password this week. ld hl, wWeeklyFlags - set 7, [hl] + set 7, [hl] ; ENGINE_BUENAS_PASSWORD .AlreadyGotIt: ld c, a call GetBuenasPassword @@ -1608,7 +1596,7 @@ GetBuenasPassword: ld a, c swap a and $f - ld hl, PasswordTable + ld hl, BuenasPasswordTable ld d, 0 ld e, a add hl, de @@ -1640,11 +1628,11 @@ GetBuenasPassword: ret .StringFunctionJumpTable: - dw .Mon - dw .Item - dw .Move - dw .RawString - +; entries correspond to BUENA_* constants + dw .Mon ; BUENA_MON + dw .Item ; BUENA_ITEM + dw .Move ; BUENA_MOVE + dw .RawString ; BUENA_STRING .Mon: call .GetTheIndex @@ -1693,30 +1681,7 @@ GetBuenasPassword: ld de, StringBuffer1 ret -PasswordTable: - dw .JohtoStarters - dw .Beverages - dw .HealingItems - dw .Balls - dw .Pokemon1 - dw .Pokemon2 - dw .JohtoTowns - dw .Types - dw .Moves - dw .XItems - dw .RadioStations - ; string type, points, option 1, option 2, option 3 -.JohtoStarters: db BUENA_MON, 10, CYNDAQUIL, TOTODILE, CHIKORITA -.Beverages: db BUENA_ITEM, 12, FRESH_WATER, SODA_POP, LEMONADE -.HealingItems: db BUENA_ITEM, 12, POTION, ANTIDOTE, PARLYZ_HEAL -.Balls: db BUENA_ITEM, 12, POKE_BALL, GREAT_BALL, ULTRA_BALL -.Pokemon1: db BUENA_MON, 10, PIKACHU, RATTATA, GEODUDE -.Pokemon2: db BUENA_MON, 10, HOOTHOOT, SPINARAK, DROWZEE -.JohtoTowns: db BUENA_STRING, 16, "NEW BARK TOWN@", "CHERRYGROVE CITY@", "AZALEA TOWN@" -.Types: db BUENA_STRING, 6, "FLYING@", "BUG@", "GRASS@" -.Moves: db BUENA_MOVE, 12, TACKLE, GROWL, MUD_SLAP -.XItems: db BUENA_ITEM, 12, X_ATTACK, X_DEFEND, X_SPEED -.RadioStations: db BUENA_STRING, 13, "#MON Talk@", "#MON Music@", "Lucky Channel@" +INCLUDE "data/radio/buenas_passwords.asm" BuenasPassword5: ld hl, BuenaRadioText5 @@ -1738,14 +1703,14 @@ BuenasPassword7: BuenasPasswordAfterMidnight: push hl ld hl, wWeeklyFlags - res 7, [hl] + res 7, [hl] ; ENGINE_BUENAS_PASSWORD pop hl ld a, BUENAS_PASSWORD_8 jp NextRadioLine BuenasPassword8: ld hl, wWeeklyFlags - res 7, [hl] + res 7, [hl] ; ENGINE_BUENAS_PASSWORD ld hl, BuenaRadioMidnightText10 ld a, BUENAS_PASSWORD_9 jp NextRadioLine @@ -1958,18 +1923,7 @@ StartRadioStation: callfar RadioMusicRestartDE ret -RadioChannelSongs: - dw MUSIC_POKEMON_TALK - dw MUSIC_POKEMON_CENTER - dw MUSIC_TITLE - dw MUSIC_GAME_CORNER - dw MUSIC_BUENAS_PASSWORD - dw MUSIC_VIRIDIAN_CITY - dw MUSIC_BICYCLE - dw MUSIC_ROCKET_OVERTURE - dw MUSIC_POKE_FLUTE_CHANNEL - dw MUSIC_RUINS_OF_ALPH_RADIO - dw MUSIC_LAKE_OF_RAGE_ROCKET_RADIO +INCLUDE "data/radio/channel_music.asm" NextRadioLine: push af diff --git a/engine/routines/correcterrorsinplayerparty.asm b/engine/routines/correcterrorsinplayerparty.asm index 2fa98a545..fcc2f36af 100644 --- a/engine/routines/correcterrorsinplayerparty.asm +++ b/engine/routines/correcterrorsinplayerparty.asm @@ -1,4 +1,4 @@ -CorrectErrorsInPlayerParty: ; unreferenced +Unreferenced_CorrectErrorsInPlayerParty: ld hl, PartyCount ld a, [hl] and a @@ -90,7 +90,7 @@ CorrectErrorsInPlayerParty: ; unreferenced ld hl, MON_STAT_EXP - 1 add hl, bc ld b, $1 - predef CalcPkmnStats + predef Predef_CalcPkmnStats pop hl ld bc, PARTYMON_STRUCT_LENGTH add hl, bc diff --git a/engine/routines/drawkrispackgfx.asm b/engine/routines/drawkrispackgfx.asm index 457dd7110..54a21e447 100644 --- a/engine/routines/drawkrispackgfx.asm +++ b/engine/routines/drawkrispackgfx.asm @@ -11,10 +11,10 @@ DrawKrisPackGFX: ; 48e81 ret PackFGFXPointers: ; 48e93 - dw PackFGFX + (15 tiles) * 1 - dw PackFGFX + (15 tiles) * 3 - dw PackFGFX + (15 tiles) * 0 - dw PackFGFX + (15 tiles) * 2 + dw PackFGFX + (15 tiles) * 1 ; ITEM_POCKET + dw PackFGFX + (15 tiles) * 3 ; BALL_POCKET + dw PackFGFX + (15 tiles) * 0 ; KEY_ITEM_POCKET + dw PackFGFX + (15 tiles) * 2 ; TM_HM_POCKET PackFGFX: ; 48e9b INCBIN "gfx/pack/pack_f.2bpp" diff --git a/engine/routines/emptyallsrambanks.asm b/engine/routines/emptyallsrambanks.asm index aa4b28e0d..8b060f3ef 100644 --- a/engine/routines/emptyallsrambanks.asm +++ b/engine/routines/emptyallsrambanks.asm @@ -1,11 +1,11 @@ EmptyAllSRAMBanks: ; 4cf1f - ld a, $0 + ld a, 0 call .EmptyBank - ld a, $1 + ld a, 1 call .EmptyBank - ld a, $2 + ld a, 2 call .EmptyBank - ld a, $3 + ld a, 3 call .EmptyBank ret diff --git a/engine/routines/flagpredef.asm b/engine/routines/flagpredef.asm index bd4f37882..676960c31 100644 --- a/engine/routines/flagpredef.asm +++ b/engine/routines/flagpredef.asm @@ -1,5 +1,5 @@ -FlagPredef: ; 4d7c1 -; Perform action b on flag c in flag array hl. +Predef_SmallFarFlagAction: ; 4d7c1 +; Perform action b on bit c in flag array hl. ; If checking a flag, check flag array d:hl unless d is 0. ; For longer flag arrays, see FlagAction. diff --git a/engine/routines/loadpushoam.asm b/engine/routines/loadpushoam.asm index 6af0ddf6d..c07c06d0f 100644 --- a/engine/routines/loadpushoam.asm +++ b/engine/routines/loadpushoam.asm @@ -13,7 +13,7 @@ LoadPushOAM:: ; 4031 .PushOAM: ; 403f ld a, HIGH(Sprites) ld [rDMA], a - ld a, (SpritesEnd - Sprites) / 4 ; 40 + ld a, NUM_SPRITE_OAM_STRUCTS .pushoam_loop dec a jr nz, .pushoam_loop diff --git a/engine/routines/newpokedexentry.asm b/engine/routines/newpokedexentry.asm index acf9fca7b..c52188f6e 100644 --- a/engine/routines/newpokedexentry.asm +++ b/engine/routines/newpokedexentry.asm @@ -1,4 +1,4 @@ -NewPokedexEntry: ; fb877 +Predef_NewPokedexEntry: ; fb877 ld a, [hMapAnims] push af xor a diff --git a/engine/routines/placegraphic.asm b/engine/routines/placegraphic.asm index d72364776..28b69fc23 100644 --- a/engine/routines/placegraphic.asm +++ b/engine/routines/placegraphic.asm @@ -1,4 +1,4 @@ -PlaceGraphic: ; 2ef6e +Predef_PlaceGraphic: ; 2ef6e ; Fill wBoxAlignment-aligned box width b height c ; with iterating tile starting from hGraphicStartTile at hl. ; Predef $13 diff --git a/engine/routines/playslowcry.asm b/engine/routines/playslowcry.asm index 3cc347a55..636741bcf 100644 --- a/engine/routines/playslowcry.asm +++ b/engine/routines/playslowcry.asm @@ -1,4 +1,4 @@ -PlaySlowCry: ; fb841 +Special_PlaySlowCry: ; fb841 ld a, [ScriptVar] call LoadCryHeader jr c, .done diff --git a/engine/routines/printhoursmins.asm b/engine/routines/printhoursmins.asm index 50117188c..eb7dc1619 100644 --- a/engine/routines/printhoursmins.asm +++ b/engine/routines/printhoursmins.asm @@ -1,5 +1,4 @@ -Function1dd6a9: ; 1dd6a9 -; XXX +Unreferenced_Function1dd6a9: ; 1dd6a9 ld a, b ld b, c ld c, a diff --git a/engine/routines/printitemdescription.asm b/engine/routines/printitemdescription.asm new file mode 100644 index 000000000..4da061fda --- /dev/null +++ b/engine/routines/printitemdescription.asm @@ -0,0 +1,31 @@ +PrintItemDescription: ; 0x1c8955 +; Print the description for item [CurSpecies] at de. + + ld a, [CurSpecies] + cp TM01 + jr c, .not_a_tm + + ld [CurItem], a + push de + farcall GetTMHMItemMove + pop hl + ld a, [wd265] + ld [CurSpecies], a + predef Predef_PrintMoveDesc + ret + +.not_a_tm + push de + ld hl, ItemDescriptions + ld a, [CurSpecies] + dec a + ld c, a + ld b, 0 + add hl, bc + add hl, bc + ld e, [hl] + inc hl + ld d, [hl] + pop hl + jp PlaceString +; 0x1c8987 diff --git a/engine/routines/sine.asm b/engine/routines/sine.asm index 89a905d2e..5f56a10a8 100755 --- a/engine/routines/sine.asm +++ b/engine/routines/sine.asm @@ -7,7 +7,6 @@ _Sine:: ; 84d9 and %111111 cp %100000 jr nc, .negative - call .ApplySineWave ld a, h ret @@ -16,7 +15,7 @@ _Sine:: ; 84d9 and %011111 call .ApplySineWave ld a, h - xor -1 + xor $ff inc a ret @@ -31,7 +30,6 @@ _Sine:: ; 84d9 inc hl ld d, [hl] ld hl, 0 - ; Factor amplitude .multiply srl a diff --git a/engine/routines/switchpartymons.asm b/engine/routines/switchpartymons.asm index cde9c82b2..1379dff9c 100644 --- a/engine/routines/switchpartymons.asm +++ b/engine/routines/switchpartymons.asm @@ -25,13 +25,13 @@ _SwitchPartyMons: ld a, " " call ByteFill pop af - ld hl, Sprites - ld bc, $10 + ld hl, Sprite01 + ld bc, 4 * SPRITEOAMSTRUCT_LENGTH call AddNTimes - ld de, $4 - ld c, $4 + ld de, SPRITEOAMSTRUCT_LENGTH + ld c, 4 .gfx_loop - ld [hl], $a0 + ld [hl], SCREEN_WIDTH_PX ; y (off-screen) add hl, de dec c jr nz, .gfx_loop diff --git a/engine/routines/trademonfrontpic.asm b/engine/routines/trademonfrontpic.asm index e312042ff..2d05a1c04 100644 --- a/engine/routines/trademonfrontpic.asm +++ b/engine/routines/trademonfrontpic.asm @@ -4,13 +4,13 @@ GetTrademonFrontpic: ; 4d7fd ld de, vTiles2 push de push af - predef GetUnownLetter + predef Predef_GetUnownLetter pop af ld [CurPartySpecies], a ld [CurSpecies], a call GetBaseData pop de - predef GetAnimatedFrontpicPredef + predef Predef_GetAnimatedFrontpic ret AnimateTrademonFrontpic: ; 4d81e @@ -34,5 +34,5 @@ AnimateTrademonFrontpic: ; 4d81e hlcoord 7, 2 ld d, $0 ld e, ANIM_MON_TRADE - predef AnimateFrontpic + predef Predef_AnimateFrontpic ret diff --git a/engine/rtc.asm b/engine/rtc.asm index dc49a9630..571de9284 100755 --- a/engine/rtc.asm +++ b/engine/rtc.asm @@ -1,4 +1,4 @@ -StopRTC: ; Unreferenced??? +Unreferenced_StopRTC: ld a, SRAM_ENABLE ld [MBC3SRamEnable], a call LatchClock @@ -58,7 +58,7 @@ TimesOfDay: ; 14044 db -1, MORN_F ; 1404e -Unknown_1404e: ; unreferenced +Unreferenced_1404e: db 20, NITE_F db 40, MORN_F db 60, DAY_F @@ -146,14 +146,14 @@ Function140ae: ; 140ae farcall ClearDailyTimers farcall Function170923 ; mobile - ld a, $5 + ld a, 5 ; MBC30 bank used by JP Crystal; inaccessible by MBC3 call GetSRAMBank - ld a, [$aa8c] + ld a, [$aa8c] ; address of MBC30 bank inc a - ld [$aa8c], a - ld a, [$b2fa] + ld [$aa8c], a ; address of MBC30 bank + ld a, [$b2fa] ; address of MBC30 bank inc a - ld [$b2fa], a + ld [$b2fa], a ; address of MBC30 bank call CloseSRAM ret diff --git a/engine/save.asm b/engine/save.asm index af24b4d2f..d9f48d62c 100644 --- a/engine/save.asm +++ b/engine/save.asm @@ -415,13 +415,12 @@ EraseHallOfFame: ; 14d06 jp CloseSRAM ; 14d18 -Function14d18: ; 14d18 -; XXX +Unreferenced_Function14d18: ; 14d18 ; copy .Data to SRA4:a007 - ld a, $4 + ld a, 4 ; MBC30 bank used by JP Crystal; inaccessible by MBC3 call GetSRAMBank ld hl, .Data - ld de, $a007 + ld de, $a007 ; address of MBC30 bank ld bc, .DataEnd - .Data call CopyBytes jp CloseSRAM @@ -452,11 +451,10 @@ SaveData: ; 14d68 ret ; 14d6c -Function14d6c: ; 14d6c -; XXX - ld a, $4 +Unreferenced_Function14d6c: ; 14d6c + ld a, 4 ; MBC30 bank used by JP Crystal; inaccessible by MBC3 call GetSRAMBank - ld a, [$a60b] + ld a, [$a60b] ; address of MBC30 bank ld b, $0 and a jr z, .ok @@ -464,28 +462,26 @@ Function14d6c: ; 14d6c .ok ld a, b - ld [$a60b], a + ld [$a60b], a ; address of MBC30 bank call CloseSRAM ret ; 14d83 -Function14d83: ; 14d83 -; XXX - ld a, $4 +Unreferenced_Function14d83: ; 14d83 + ld a, 4 ; MBC30 bank used by JP Crystal; inaccessible by MBC3 call GetSRAMBank xor a - ld [$a60c], a - ld [$a60d], a + ld [$a60c], a ; address of MBC30 bank + ld [$a60d], a ; address of MBC30 bank call CloseSRAM ret ; 14d93 -Function14d93: ; 14d93 -; XXX - ld a, $7 +Unreferenced_Function14d93: ; 14d93 + ld a, 7 ; MBC30 bank used by JP Crystal; inaccessible by MBC3 call GetSRAMBank xor a - ld [$a000], a + ld [$a000], a ; address of MBC30 bank call CloseSRAM ret ; 14da0 @@ -873,6 +869,11 @@ VerifyBackupChecksum: ; 1507c (5:507c) _SaveData: ; 1509a + ; This is called within two scenarios: + ; a) ErasePreviousSave (the process of erasing the save from a previous game file) + ; b) unused mobile functionality + ; It is not part of a regular save. + ld a, BANK(sCrystalData) call GetSRAMBank ld hl, wCrystalData @@ -880,7 +881,11 @@ _SaveData: ; 1509a ld bc, wCrystalDataEnd - wCrystalData call CopyBytes - ; XXX SRAM bank 7 + ; This block originally had some mobile functionality, but since we're still in + ; BANK(sCrystalData), it instead overwrites the sixteen EventFlags starting at 1:a603 with + ; garbage from wd479. This isn't an issue, since ErasePreviousSave is followed by a regular + ; save that unwrites the garbage. + ld hl, wd479 ld a, [hli] ld [$a60e + 0], a @@ -897,8 +902,10 @@ _LoadData: ; 150b9 ld de, wCrystalData ld bc, wCrystalDataEnd - wCrystalData call CopyBytes - - ; XXX SRAM bank 7 + + ; This block originally had some mobile functionality to mirror _SaveData above, but instead it + ; (harmlessly) writes the aforementioned EventFlags to the unused wd479. + ld hl, wd479 ld a, [$a60e + 0] ld [hli], a diff --git a/engine/scripting.asm b/engine/scripting.asm index 9a89c375a..5e06c2ef8 100644 --- a/engine/scripting.asm +++ b/engine/scripting.asm @@ -128,7 +128,7 @@ ScriptCommandTable: dw Script_warp ; 3c dw Script_readmoney ; 3d dw Script_readcoins ; 3e - dw Script_RAM2MEM ; 3f + dw Script_vartomem ; 3f dw Script_pokenamemem ; 40 dw Script_itemtotext ; 41 dw Script_mapnametotext ; 42 @@ -255,8 +255,7 @@ StopScript: Script_callasm: ; script command 0xe -; parameters: -; asm (AsmPointerParam) +; parameters: asm call GetScriptByte ld b, a @@ -270,8 +269,7 @@ Script_callasm: Script_special: ; script command 0xf -; parameters: -; predefined_script (MultiByteParam) +; parameters: predefined_script call GetScriptByte ld e, a @@ -282,8 +280,7 @@ Script_special: Script_ptcallasm: ; script command 0x10 -; parameters: -; asm (PointerToAsmPointerParam) +; parameters: asm call GetScriptByte ld l, a @@ -300,8 +297,7 @@ Script_ptcallasm: Script_jumptextfaceplayer: ; script command 0x51 -; parameters: -; text_pointer (RawTextPointerLabelParam) +; parameters: text_pointer ld a, [ScriptBank] ld [wScriptTextBank], a @@ -315,8 +311,7 @@ Script_jumptextfaceplayer: Script_jumptext: ; script command 0x53 -; parameters: -; text_pointer (RawTextPointerLabelParam) +; parameters: text_pointer ld a, [ScriptBank] ld [wScriptTextBank], a @@ -342,8 +337,7 @@ if _CRYSTAL Script_farjumptext: ; script command 0x52 -; parameters: -; text_pointer (PointerLabelBeforeBank) +; parameters: text_pointer call GetScriptByte ld [wScriptTextBank], a @@ -360,8 +354,7 @@ endc Script_writetext: ; script command 0x4c -; parameters: -; text_pointer (RawTextPointerLabelParam) +; parameters: text_pointer call GetScriptByte ld l, a @@ -374,8 +367,7 @@ Script_writetext: Script_farwritetext: ; script command 0x4b -; parameters: -; text_pointer (PointerLabelBeforeBank) +; parameters: text_pointer call GetScriptByte ld b, a @@ -388,9 +380,7 @@ Script_farwritetext: Script_repeattext: ; script command 0x4d -; parameters: -; byte (SingleByteParam) -; byte (SingleByteParam) +; parameters: byte, byte call GetScriptByte ld l, a @@ -444,8 +434,7 @@ Script_yesorno: Script_loadmenudata: ; script command 0x4f -; parameters: -; data (MenuDataPointerParam) +; parameters: data call GetScriptByte ld l, a @@ -466,8 +455,7 @@ Script_closewindow: Script_pokepic: ; script command 0x56 -; parameters: -; pokemon (PokemonParam) +; parameters: pokemon call GetScriptByte and a @@ -512,9 +500,7 @@ Script__2dmenu: Script_battletowertext: ; script command 0xa4 -; parameters: -; pointer (PointerLabelBeforeBank) -; memory (SingleByteParam) +; parameters: pointer, memory call SetUpTextBox call GetScriptByte @@ -524,9 +510,7 @@ Script_battletowertext: Script_verbosegiveitem: ; script command 0x9e -; parameters: -; item (ItemLabelByte) -; quantity (DecimalParam) +; parameters: item, quantity call Script_giveitem call CurItemName @@ -563,9 +547,7 @@ ReceivedItemText: Script_verbosegiveitem2: ; script command 0x9f -; parameters: -; item (ItemLabelByte) -; var (SingleByteParam) +; parameters: item, var call GetScriptByte cp -1 @@ -632,7 +614,7 @@ GetPocketName: ld a, [wItemAttributeParamBuffer] dec a ld hl, .Pockets - and 3 + maskbits NUM_POCKETS +- 1 add a ld e, a ld d, 0 @@ -677,9 +659,7 @@ PocketIsFullText: Script_pokemart: ; script command 0x94 -; parameters: -; dialog_id (SingleByteParam) -; mart_id (MultiByteParam) +; parameters: dialog_id, mart_id call GetScriptByte ld c, a @@ -694,8 +674,7 @@ Script_pokemart: Script_elevator: ; script command 0x95 -; parameters: -; floor_list_pointer (PointerLabelParam) +; parameters: floor_list_pointer xor a ld [ScriptVar], a @@ -713,8 +692,7 @@ Script_elevator: Script_trade: ; script command 0x96 -; parameters: -; trade_id (SingleByteParam) +; parameters: trade_id call GetScriptByte ld e, a @@ -723,8 +701,7 @@ Script_trade: Script_phonecall: ; script command 0x98 -; parameters: -; caller_name (RawTextPointerLabelParam) +; parameters: caller_name call GetScriptByte ld e, a @@ -743,8 +720,7 @@ Script_hangup: Script_askforphonenumber: ; script command 0x97 -; parameters: -; number (SingleByteParam) +; parameters: number call YesNoBox jr c, .refused @@ -752,22 +728,21 @@ Script_askforphonenumber: ld c, a farcall AddPhoneNumber jr c, .phonefull - xor a + xor a ; PHONE_CONTACT_GOT jr .done .phonefull - ld a, 1 + ld a, PHONE_CONTACTS_FULL jr .done .refused call GetScriptByte - ld a, 2 + ld a, PHONE_CONTACT_REFUSED .done ld [ScriptVar], a ret Script_describedecoration: ; script command 0x9a -; parameters: -; byte (SingleByteParam) +; parameters: byte call GetScriptByte ld b, a @@ -778,8 +753,7 @@ Script_describedecoration: Script_fruittree: ; script command 0x9b -; parameters: -; tree_id (SingleByteParam) +; parameters: tree_id call GetScriptByte ld [CurFruitTree], a @@ -789,10 +763,7 @@ Script_fruittree: Script_swarm: ; script command 0xa0 -; parameters: -; flag (SingleByteParam) -; map_group (MapGroupParam) -; map_id (MapIdParam) +; parameters: flag, map_group, map_id call GetScriptByte ld c, a @@ -805,8 +776,7 @@ Script_swarm: Script_trainertext: ; script command 0x62 -; parameters: -; which_text (SingleByteParam) +; parameters: which_text call GetScriptByte ld c, a @@ -835,8 +805,7 @@ Script_scripttalkafter: Script_trainerflagaction: ; script command 0x63 -; parameters: -; action (SingleByteParam) +; parameters: action xor a ld [ScriptVar], a @@ -856,9 +825,7 @@ Script_trainerflagaction: Script_winlosstext: ; script command 0x64 -; parameters: -; win_text_pointer (TextPointerLabelParam) -; loss_text_pointer (TextPointerLabelParam) +; parameters: win_text_pointer, loss_text_pointer ld hl, wWinTextPointer call GetScriptByte @@ -908,8 +875,7 @@ Script_playmapmusic: Script_playmusic: ; script command 0x7f -; parameters: -; music_pointer (MultiByteParam) +; parameters: music_pointer ld de, MUSIC_NONE call PlayMusic @@ -925,23 +891,20 @@ Script_playmusic: Script_musicfadeout: ; script command 0x81 -; parameters: -; music (MultiByteParam) -; fadetime (SingleByteParam) +; parameters: music, fadetime call GetScriptByte ld [MusicFadeID], a call GetScriptByte ld [MusicFadeID + 1], a call GetScriptByte - and $7f + and $ff ^ (1 << MUSIC_FADE_IN_F) ld [MusicFade], a ret Script_playsound: ; script command 0x85 -; parameters: -; sound_pointer (MultiByteParam) +; parameters: sound_pointer call GetScriptByte ld e, a @@ -965,8 +928,7 @@ Script_warpsound: Script_cry: ; script command 0x84 -; parameters: -; cry_id (MultiByteParam) +; parameters: cry_id call GetScriptByte push af @@ -989,8 +951,7 @@ GetScriptObject: Script_setlasttalked: ; script command 0x68 -; parameters: -; object id (SingleByteParam) +; parameters: object_id call GetScriptByte call GetScriptObject @@ -999,9 +960,7 @@ Script_setlasttalked: Script_applymovement: ; script command 0x69 -; parameters: -; object id (SingleByteParam) -; data (MovementPointerLabelParam) +; parameters: object_id, data call GetScriptByte call GetScriptObject @@ -1036,10 +995,9 @@ SetFlagsForMovement_2: ret Script_applymovement2: -; apply movement to last talked ; script command 0x6a -; parameters: -; data (MovementPointerLabelParam) +; parameters: data +; apply movement to last talked ld a, [hLastTalked] ld c, a @@ -1066,9 +1024,7 @@ Script_faceplayer: Script_faceobject: ; script command 0x6c -; parameters: -; object1 (SingleByteParam) -; object2 (SingleByteParam) +; parameters: object1, object2 call GetScriptByte call GetScriptObject @@ -1098,9 +1054,7 @@ Script_faceobject: Script_spriteface: ; script command 0x76 -; parameters: -; object id (SingleByteParam) -; facing (SingleByteParam) +; parameters: object_id, facing call GetScriptByte call GetScriptObject @@ -1163,9 +1117,7 @@ ApplyObjectFacing: Script_variablesprite: ; script command 0x6d -; parameters: -; byte (SingleByteParam) -; sprite (SingleByteParam) +; parameters: byte, sprite call GetScriptByte ld e, a @@ -1178,8 +1130,7 @@ Script_variablesprite: Script_appear: ; script command 0x6f -; parameters: -; object id (SingleByteParam) +; parameters: object_id call GetScriptByte call GetScriptObject @@ -1191,8 +1142,7 @@ Script_appear: Script_disappear: ; script command 0x6e -; parameters: -; object id (SingleByteParam) +; parameters: object_id call GetScriptByte call GetScriptObject @@ -1229,9 +1179,7 @@ ApplyEventActionAppearDisappear: Script_follow: ; script command 0x70 -; parameters: -; object2 (SingleByteParam) -; object1 (SingleByteParam) +; parameters: object2, object1 call GetScriptByte call GetScriptObject @@ -1250,10 +1198,7 @@ Script_stopfollow: Script_moveobject: ; script command 0x72 -; parameters: -; object id (SingleByteParam) -; x (SingleByteParam) -; y (SingleByteParam) +; parameters: object id, x, y call GetScriptByte call GetScriptObject @@ -1269,8 +1214,7 @@ Script_moveobject: Script_writeobjectxy: ; script command 0x73 -; parameters: -; object id (SingleByteParam) +; parameters: object_id call GetScriptByte call GetScriptObject @@ -1284,9 +1228,7 @@ Script_writeobjectxy: Script_follownotexact: ; script command 0x77 -; parameters: -; object2 (SingleByteParam) -; object1 (SingleByteParam) +; parameters: object2, object1 call GetScriptByte call GetScriptObject @@ -1299,8 +1241,7 @@ Script_follownotexact: Script_loademote: ; script command 0x74 -; parameters: -; bubble (SingleByteParam) +; parameters: bubble call GetScriptByte cp -1 @@ -1313,10 +1254,7 @@ Script_loademote: Script_showemote: ; script command 0x75 -; parameters: -; bubble (SingleByteParam) -; object id (SingleByteParam) -; time (DecimalParam) +; parameters: bubble, object_id, time call GetScriptByte ld [ScriptVar], a @@ -1352,8 +1290,7 @@ ShowEmoteScript: Script_earthquake: ; script command 0x78 -; parameters: -; param (DecimalParam) +; parameters: param ld hl, EarthquakeMovement ld de, wEarthquakeMovementDataBuffer @@ -1407,9 +1344,7 @@ Script_loadmemtrainer: Script_loadwildmon: ; script command 0x5d -; parameters: -; pokemon (PokemonParam) -; level (DecimalParam) +; parameters: pokemon, level ld a, (1 << 7) ld [wBattleScriptFlags], a @@ -1421,9 +1356,7 @@ Script_loadwildmon: Script_loadtrainer: ; script command 0x5e -; parameters: -; trainer_group (TrainerGroupParam) -; trainer_id (TrainerIdParam) +; parameters: trainer_group, trainer_id ld a, (1 << 7) | 1 ld [wBattleScriptFlags], a @@ -1437,7 +1370,7 @@ Script_startbattle: ; script command 0x5f call BufferScreen - predef StartBattle + predef Predef_StartBattle ld a, [wBattleResult] and $3f ld [ScriptVar], a @@ -1445,8 +1378,7 @@ Script_startbattle: Script_catchtutorial: ; script command 0x61 -; parameters: -; byte (SingleByteParam) +; parameters: byte call GetScriptByte ld [BattleType], a @@ -1498,8 +1430,7 @@ Script_reloadmap: Script_scall: ; script command 0x0 -; parameters: -; pointer (ScriptPointerLabelParam) +; parameters: pointer ld a, [ScriptBank] ld b, a @@ -1511,8 +1442,7 @@ Script_scall: Script_farscall: ; script command 0x1 -; parameters: -; pointer (ScriptPointerLabelBeforeBank) +; parameters: pointer call GetScriptByte ld b, a @@ -1524,8 +1454,7 @@ Script_farscall: Script_ptcall: ; script command 0x2 -; parameters: -; pointer (PointerLabelToScriptPointer) +; parameters: pointer call GetScriptByte ld l, a @@ -1577,8 +1506,7 @@ CallCallback:: Script_jump: ; script command 0x3 -; parameters: -; pointer (ScriptPointerLabelParam) +; parameters: pointer call GetScriptByte ld l, a @@ -1590,8 +1518,7 @@ Script_jump: Script_farjump: ; script command 0x4 -; parameters: -; pointer (ScriptPointerLabelBeforeBank) +; parameters: pointer call GetScriptByte ld b, a @@ -1603,8 +1530,7 @@ Script_farjump: Script_ptjump: ; script command 0x5 -; parameters: -; pointer (PointerLabelToScriptPointer) +; parameters: pointer call GetScriptByte ld l, a @@ -1619,8 +1545,7 @@ Script_ptjump: Script_iffalse: ; script command 0x8 -; parameters: -; pointer (ScriptPointerLabelParam) +; parameters: pointer ld a, [ScriptVar] and a @@ -1629,8 +1554,7 @@ Script_iffalse: Script_iftrue: ; script command 0x9 -; parameters: -; pointer (ScriptPointerLabelParam) +; parameters: pointer ld a, [ScriptVar] and a @@ -1639,9 +1563,7 @@ Script_iftrue: Script_if_equal: ; script command 0x6 -; parameters: -; byte (SingleByteParam) -; pointer (ScriptPointerLabelParam) +; parameters: byte, pointer call GetScriptByte ld hl, ScriptVar @@ -1651,9 +1573,7 @@ Script_if_equal: Script_if_not_equal: ; script command 0x7 -; parameters: -; byte (SingleByteParam) -; pointer (ScriptPointerLabelParam) +; parameters: byte, pointer call GetScriptByte ld hl, ScriptVar @@ -1663,9 +1583,7 @@ Script_if_not_equal: Script_if_greater_than: ; script command 0xa -; parameters: -; byte (SingleByteParam) -; pointer (ScriptPointerLabelParam) +; parameters: byte, pointer ld a, [ScriptVar] ld b, a @@ -1676,9 +1594,7 @@ Script_if_greater_than: Script_if_less_than: ; script command 0xb -; parameters: -; byte (SingleByteParam) -; pointer (ScriptPointerLabelParam) +; parameters: byte, pointer call GetScriptByte ld b, a @@ -1689,16 +1605,14 @@ Script_if_less_than: Script_jumpstd: ; script command 0xc -; parameters: -; predefined_script (MultiByteParam) +; parameters: predefined_script call StdScript jr ScriptJump Script_callstd: ; script command 0xd -; parameters: -; predefined_script (MultiByteParam) +; parameters: predefined_script call StdScript ld d, h @@ -1738,8 +1652,7 @@ ScriptJump: Script_priorityjump: ; script command 0x8d -; parameters: -; pointer (ScriptPointerLabelParam) +; parameters: pointer ld a, [ScriptBank] ld [wPriorityScriptBank], a @@ -1766,9 +1679,7 @@ Script_checkscene: Script_checkmapscene: ; script command 0x11 -; parameters: -; map_group (SingleByteParam) -; map_id (SingleByteParam) +; parameters: map_group, map_id call GetScriptByte ld b, a @@ -1789,8 +1700,7 @@ Script_checkmapscene: Script_setscene: ; script command 0x14 -; parameters: -; scene_id (SingleByteParam) +; parameters: scene_id ld a, [MapGroup] ld b, a @@ -1800,10 +1710,7 @@ Script_setscene: Script_setmapscene: ; script command 0x12 -; parameters: -; map_group (MapGroupParam) -; map_id (MapIdParam) -; scene_id (SingleByteParam) +; parameters: map_group, map_id, scene_id call GetScriptByte ld b, a @@ -1821,8 +1728,7 @@ DoScene: Script_copybytetovar: ; script command 0x19 -; parameters: -; address (RAMAddressParam) +; parameters: address call GetScriptByte ld l, a @@ -1834,8 +1740,7 @@ Script_copybytetovar: Script_copyvartobyte: ; script command 0x1a -; parameters: -; address (RAMAddressParam) +; parameters: address call GetScriptByte ld l, a @@ -1847,9 +1752,7 @@ Script_copyvartobyte: Script_loadvar: ; script command 0x1b -; parameters: -; address (RAMAddressParam) -; value (SingleByteParam) +; parameters: address, value call GetScriptByte ld l, a @@ -1861,8 +1764,7 @@ Script_loadvar: Script_writebyte: ; script command 0x15 -; parameters: -; value (SingleByteParam) +; parameters: value call GetScriptByte ld [ScriptVar], a @@ -1870,8 +1772,7 @@ Script_writebyte: Script_addvar: ; script command 0x16 -; parameters: -; value (SingleByteParam) +; parameters: value call GetScriptByte ld hl, ScriptVar @@ -1881,8 +1782,7 @@ Script_addvar: Script_random: ; script command 0x17 -; parameters: -; input (SingleByteParam) +; parameters: input call GetScriptByte ld [ScriptVar], a @@ -1935,8 +1835,7 @@ Script_random: Script_checkcode: ; script command 0x1c -; parameters: -; variable_id (SingleByteParam) +; parameters: variable_id call GetScriptByte call GetVarAction @@ -1946,8 +1845,7 @@ Script_checkcode: Script_writevarcode: ; script command 0x1d -; parameters: -; variable_id (SingleByteParam) +; parameters: variable_id call GetScriptByte call GetVarAction @@ -1957,9 +1855,7 @@ Script_writevarcode: Script_writecode: ; script command 0x1e -; parameters: -; variable_id (SingleByteParam) -; value (SingleByteParam) +; parameters: variable_id, value call GetScriptByte call GetVarAction @@ -1975,18 +1871,16 @@ GetVarAction: Script_checkver: ; script command 0x18 - ld a, [Version] + ld a, [.gs_version] ld [ScriptVar], a ret -Version: - db VERSION +.gs_version: + db GS_VERSION Script_pokenamemem: ; script command 0x40 -; parameters: -; pokemon (PokemonParam); leave $0 to draw from script var -; memory (SingleByteParam) +; parameters: pokemon (0 aka USE_SCRIPT_VAR to use ScriptVar), memory call GetScriptByte and a @@ -1999,7 +1893,7 @@ Script_pokenamemem: ConvertMemToText: call GetScriptByte - cp 3 + cp NUM_MEM_BUFFERS jr c, .ok xor a .ok @@ -2013,12 +1907,10 @@ CopyConvertedText: Script_itemtotext: ; script command 0x41 -; parameters: -; item (ItemLabelByte); use 0 to draw from ScriptVar -; memory (SingleByteParam) +; parameters: item (0 aka USE_SCRIPT_VAR to use ScriptVar), memory call GetScriptByte - and a + and a ; USE_SCRIPT_VAR jr nz, .ok ld a, [ScriptVar] .ok @@ -2029,8 +1921,7 @@ Script_itemtotext: Script_mapnametotext: ; script command 0x42 -; parameters: -; memory (SingleByteParam) +; parameters: memory ld a, [MapGroup] ld b, a @@ -2046,19 +1937,14 @@ ConvertLandmarkToText: Script_landmarktotext: ; script command 0xa5 -; parameters: -; id (SingleByteParam) -; memory (SingleByteParam) +; parameters: id, memory call GetScriptByte jr ConvertLandmarkToText Script_trainertotext: ; script command 0x43 -; parameters: -; trainer_id (TrainerGroupParam) -; trainer_group (TrainerIdParam) -; memory (SingleByteParam) +; parameters: trainer_id, trainer_group, memory call GetScriptByte ld c, a @@ -2069,10 +1955,7 @@ Script_trainertotext: Script_name: ; script command 0xa7 -; parameters: -; type (SingleByteParam) -; id (SingleByteParam) -; memory (SingleByteParam) +; parameters: type, id, memory call GetScriptByte ld [wNamedObjectTypeBuffer], a @@ -2086,9 +1969,7 @@ ContinueToGetName: Script_trainerclassname: ; script command 0xa6 -; parameters: -; id (SingleByteParam) -; memory (SingleByteParam) +; parameters: id, memory ld a, TRAINER_NAME ld [wNamedObjectTypeBuffer], a @@ -2096,9 +1977,7 @@ Script_trainerclassname: Script_readmoney: ; script command 0x3d -; parameters: -; account (SingleByteParam) -; memory (SingleByteParam) +; parameters: account, memory call ResetStringBuffer1 call GetMoneyAccount @@ -2110,8 +1989,7 @@ Script_readmoney: Script_readcoins: ; script command 0x3e -; parameters: -; memory (SingleByteParam) +; parameters: memory call ResetStringBuffer1 ld hl, StringBuffer1 @@ -2121,10 +1999,9 @@ Script_readcoins: ld de, StringBuffer1 jp ConvertMemToText -Script_RAM2MEM: +Script_vartomem: ; script command 0x3f -; parameters: -; memory (SingleByteParam) +; parameters: memory call ResetStringBuffer1 ld de, ScriptVar @@ -2143,9 +2020,7 @@ ResetStringBuffer1: Script_stringtotext: ; script command 0x44 -; parameters: -; text_pointer (EncodedTextLabelParam) -; memory (SingleByteParam) +; parameters: text_pointer, memory call GetScriptByte ld e, a @@ -2159,8 +2034,7 @@ Script_stringtotext: Script_givepokeitem: ; script command 0x2f -; parameters: -; pointer (PointerParamToItemAndLetter) +; parameters: pointer call GetScriptByte ld l, a @@ -2181,8 +2055,7 @@ Script_givepokeitem: Script_checkpokeitem: ; script command 0x30 -; parameters: -; pointer (PointerParamToItemAndLetter) +; parameters: pointer call GetScriptByte ld e, a @@ -2195,9 +2068,7 @@ Script_checkpokeitem: Script_giveitem: ; script command 0x1f -; parameters: -; item (ItemLabelByte) -; quantity (SingleByteParam) +; parameters: item, quantity call GetScriptByte cp ITEM_FROM_MEM @@ -2220,9 +2091,7 @@ Script_giveitem: Script_takeitem: ; script command 0x20 -; parameters: -; item (ItemLabelByte) -; quantity (DecimalParam) +; parameters: item, quantity xor a ld [ScriptVar], a @@ -2241,8 +2110,7 @@ Script_takeitem: Script_checkitem: ; script command 0x21 -; parameters: -; item (ItemLabelByte) +; parameters: item xor a ld [ScriptVar], a @@ -2257,9 +2125,7 @@ Script_checkitem: Script_givemoney: ; script command 0x22 -; parameters: -; account (SingleByteParam) -; money (MoneyByteParam) +; parameters: account, money call GetMoneyAccount call LoadMoneyAmountToMem @@ -2268,9 +2134,7 @@ Script_givemoney: Script_takemoney: ; script command 0x23 -; parameters: -; account (SingleByteParam) -; money (MoneyByteParam) +; parameters: account, money call GetMoneyAccount call LoadMoneyAmountToMem @@ -2279,24 +2143,22 @@ Script_takemoney: Script_checkmoney: ; script command 0x24 -; parameters: -; account (SingleByteParam) -; money (MoneyByteParam) +; parameters: account, money call GetMoneyAccount call LoadMoneyAmountToMem farcall CompareMoney CompareMoneyAction: - jr c, .two - jr z, .one - ld a, 0 + jr c, .less + jr z, .exact + ld a, HAVE_MORE jr .done -.one - ld a, 1 +.exact + ld a, HAVE_AMOUNT jr .done -.two - ld a, 2 +.less + ld a, HAVE_LESS .done ld [ScriptVar], a ret @@ -2304,9 +2166,9 @@ CompareMoneyAction: GetMoneyAccount: call GetScriptByte and a - ld de, Money + ld de, Money ; YOUR_MONEY ret z - ld de, wMomsMoney + ld de, wMomsMoney ; MOMS_MONEY ret LoadMoneyAmountToMem: @@ -2325,8 +2187,7 @@ LoadMoneyAmountToMem: Script_givecoins: ; script command 0x25 -; parameters: -; coins (CoinByteParam) +; parameters: coins call LoadCoinAmountToMem farcall GiveCoins @@ -2334,8 +2195,7 @@ Script_givecoins: Script_takecoins: ; script command 0x26 -; parameters: -; coins (CoinByteParam) +; parameters: coins call LoadCoinAmountToMem farcall TakeCoins @@ -2343,8 +2203,7 @@ Script_takecoins: Script_checkcoins: ; script command 0x27 -; parameters: -; coins (CoinByteParam) +; parameters: coins call LoadCoinAmountToMem farcall CheckCoins @@ -2360,8 +2219,7 @@ LoadCoinAmountToMem: Script_checktime: ; script command 0x2b -; parameters: -; time (SingleByteParam) +; parameters: time xor a ld [ScriptVar], a @@ -2375,8 +2233,7 @@ Script_checktime: Script_checkpoke: ; script command 0x2c -; parameters: -; pkmn (PokemonParam) +; parameters: pokemon xor a ld [ScriptVar], a @@ -2391,8 +2248,7 @@ Script_checkpoke: Script_addcellnum: ; script command 0x28 -; parameters: -; person (SingleByteParam) +; parameters: person xor a ld [ScriptVar], a @@ -2406,8 +2262,7 @@ Script_addcellnum: Script_delcellnum: ; script command 0x29 -; parameters: -; person (SingleByteParam) +; parameters: person xor a ld [ScriptVar], a @@ -2421,8 +2276,7 @@ Script_delcellnum: Script_checkcellnum: ; script command 0x2a -; parameters: -; person (SingleByteParam) +; parameters: person ; returns false if the cell number is not in your phone xor a @@ -2437,8 +2291,7 @@ Script_checkcellnum: Script_specialphonecall: ; script command 0x9c -; parameters: -; call_id (MultiByteParam) +; parameters: call_id call GetScriptByte ld [wSpecialPhoneCallID], a @@ -2460,13 +2313,7 @@ Script_checkphonecall: Script_givepoke: ; script command 0x2d -; parameters: -; pokemon (PokemonParam) -; level (DecimalParam) -; item (ItemLabelByte) -; trainer (DecimalParam) -; trainer_name_pointer (MultiByteParam) -; pkmn_nickname (MultiByteParam) +; parameters: pokemon, level, item, trainer, trainer_name_pointer, pkmn_nickname call GetScriptByte ld [CurPartySpecies], a @@ -2494,9 +2341,7 @@ Script_givepoke: Script_giveegg: ; script command 0x2e -; parameters: -; pkmn (PokemonParam) -; level (DecimalParam) +; parameters: pokemon, level ; if no room in the party, return 0 in ScriptVar; else, return 2 xor a ; PARTYMON @@ -2506,7 +2351,7 @@ Script_giveegg: ld [CurPartySpecies], a call GetScriptByte ld [CurPartyLevel], a - farcall GiveEgg + farcall Predef_GiveEgg ret nc ld a, 2 ld [ScriptVar], a @@ -2514,8 +2359,7 @@ Script_giveegg: Script_setevent: ; script command 0x33 -; parameters: -; bit_number (MultiByteParam) +; parameters: bit_number call GetScriptByte ld e, a @@ -2527,8 +2371,7 @@ Script_setevent: Script_clearevent: ; script command 0x32 -; parameters: -; bit_number (MultiByteParam) +; parameters: bit_number call GetScriptByte ld e, a @@ -2540,8 +2383,7 @@ Script_clearevent: Script_checkevent: ; script command 0x31 -; parameters: -; bit_number (MultiByteParam) +; parameters: bit_number call GetScriptByte ld e, a @@ -2559,8 +2401,7 @@ Script_checkevent: Script_setflag: ; script command 0x36 -; parameters: -; bit_number (MultiByteParam) +; parameters: bit_number call GetScriptByte ld e, a @@ -2572,8 +2413,7 @@ Script_setflag: Script_clearflag: ; script command 0x35 -; parameters: -; bit_number (MultiByteParam) +; parameters: bit_number call GetScriptByte ld e, a @@ -2585,14 +2425,13 @@ Script_clearflag: Script_checkflag: ; script command 0x34 -; parameters: -; bit_number (MultiByteParam) +; parameters: bit_number call GetScriptByte ld e, a call GetScriptByte ld d, a - ld b, 2 ; check + ld b, CHECK_FLAG call _EngineFlagAction ld a, c and a @@ -2622,8 +2461,7 @@ Script_wildon: Script_xycompare: ; script command 0x39 -; parameters: -; pointer (MultiByteParam) +; parameters: pointer call GetScriptByte ld [wXYComparePointer], a @@ -2633,15 +2471,10 @@ Script_xycompare: Script_warpfacing: ; script command 0xa3 -; parameters: -; facing (SingleByteParam) -; map_group (MapGroupParam) -; map_id (MapIdParam) -; x (SingleByteParam) -; y (SingleByteParam) +; parameters: facing, map_group, map_id, x, y call GetScriptByte - and $3 + maskbits NUM_DIRECTIONS +- 1 ld c, a ld a, [wPlayerSpriteSetupFlags] set 5, a @@ -2651,11 +2484,7 @@ Script_warpfacing: Script_warp: ; script command 0x3c -; parameters: -; map_group (MapGroupParam) -; map_id (MapIdParam) -; x (SingleByteParam) -; y (SingleByteParam) +; parameters: map_group, map_id, x, y ; This seems to be some sort of error handling case. call GetScriptByte @@ -2692,10 +2521,7 @@ Script_warp: Script_warpmod: ; script command 0x3a -; parameters: -; warp_id (SingleByteParam) -; map_group (MapGroupParam) -; map_id (MapIdParam) +; parameters: warp_id, map_group, map_id call GetScriptByte ld [BackupWarpNumber], a @@ -2707,9 +2533,7 @@ Script_warpmod: Script_blackoutmod: ; script command 0x3b -; parameters: -; map_group (MapGroupParam) -; map_id (MapIdParam) +; parameters: map_group, map_id call GetScriptByte ld [wLastSpawnMapGroup], a @@ -2726,8 +2550,7 @@ Script_dontrestartmapmusic: Script_writecmdqueue: ; script command 0x7d -; parameters: -; queue_pointer (MultiByteParam) +; parameters: queue_pointer call GetScriptByte ld e, a @@ -2740,8 +2563,7 @@ Script_writecmdqueue: Script_delcmdqueue: ; script command 0x7e -; parameters: -; byte (SingleByteParam) +; parameters: byte xor a ld [ScriptVar], a @@ -2755,8 +2577,7 @@ Script_delcmdqueue: Script_changemap: ; script command 0x79 -; parameters: -; map_data_pointer (MapDataPointerParam) +; parameters: map_data_pointer call GetScriptByte ld [MapBlockDataBank], a @@ -2770,10 +2591,7 @@ Script_changemap: Script_changeblock: ; script command 0x7a -; parameters: -; x (SingleByteParam) -; y (SingleByteParam) -; block (SingleByteParam) +; parameters: x, y, block call GetScriptByte add 4 @@ -2806,14 +2624,14 @@ Script_warpcheck: farcall EnableEvents ret -Script_enableevents: ; unreferenced +Script_enableevents: +; unused farcall EnableEvents ret Script_newloadmap: ; script command 0x8a -; parameters: -; which_method (SingleByteParam) +; parameters: which_method call GetScriptByte ld [hMapEntryMethod], a @@ -2836,8 +2654,7 @@ Script_textbox: Script_refreshscreen: ; script command 0x48 -; parameters: -; dummy (SingleByteParam) +; parameters: dummy call RefreshScreen call GetScriptByte @@ -2845,14 +2662,13 @@ Script_refreshscreen: Script_loadbytec2cf: ; script command 0x4a -; parameters: -; byte (SingleByteParam) +; parameters: byte call GetScriptByte ld [wc2cf], a ret - ld c, c ; XXX + db closetext_command ; unused Script_closetext: ; script command 0x49 @@ -2864,8 +2680,7 @@ Script_closetext: Script_passtoengine: ; script command 0x89 -; parameters: -; data_pointer (PointerLabelBeforeBank) +; parameters: data_pointer call GetScriptByte push af @@ -2879,8 +2694,7 @@ Script_passtoengine: Script_pause: ; script command 0x8b -; parameters: -; length (DecimalParam) +; parameters: length call GetScriptByte and a @@ -2896,8 +2710,7 @@ Script_pause: Script_deactivatefacing: ; script command 0x8c -; parameters: -; time (SingleByteParam) +; parameters: time call GetScriptByte and a @@ -2911,8 +2724,7 @@ Script_deactivatefacing: Script_ptpriorityjump: ; script command 0x8f -; parameters: -; pointer (ScriptPointerLabelParam) +; parameters: pointer call StopScript jp Script_jump @@ -2993,8 +2805,8 @@ Script_halloffame: ld hl, wGameTimerPause res 0, [hl] - farcall TrainerRankings_HallOfFame - farcall TrainerRankings_HallOfFame2 + farcall StubbedTrainerRankings_HallOfFame + farcall StubbedTrainerRankings_HallOfFame2 farcall HallOfFame ld hl, wGameTimerPause set 0, [hl] @@ -3013,8 +2825,7 @@ ReturnFromCredits: Script_wait: ; script command 0xa8 -; parameters: -; unknown (SingleByteParam) +; parameters: unknown push bc call GetScriptByte @@ -3037,7 +2848,7 @@ Script_check_save: ret -; unreferenced +; unused ld a, [.byte] ld [ScriptVar], a ret diff --git a/engine/scrolling_menu.asm b/engine/scrolling_menu.asm index 32f22188a..32acf2def 100755 --- a/engine/scrolling_menu.asm +++ b/engine/scrolling_menu.asm @@ -84,7 +84,7 @@ ScrollingMenuJoyAction: ; 24609 jr .loop ; 24640 -.unreferenced ; unreferenced +.unreferenced ; unused ld a, -1 and a ret diff --git a/engine/search.asm b/engine/search.asm index 76be0e159..495d4cc5e 100755 --- a/engine/search.asm +++ b/engine/search.asm @@ -1,4 +1,4 @@ -SpecialBeastsCheck: ; 0x4a6e8 +Special_BeastsCheck: ; 0x4a6e8 ; Check if the player owns all three legendary beasts. ; They must exist in either party or PC, and have the player's OT and ID. ; Return the result in ScriptVar. @@ -29,7 +29,7 @@ SpecialBeastsCheck: ; 0x4a6e8 ret -SpecialMonCheck: ; 0x4a711 +Special_MonCheck: ; 0x4a711 ; Check if the player owns any monsters of the species in ScriptVar. ; Return the result in ScriptVar. diff --git a/engine/sgb_layouts.asm b/engine/sgb_layouts.asm index 36dbde84c..02055377a 100644 --- a/engine/sgb_layouts.asm +++ b/engine/sgb_layouts.asm @@ -1,7 +1,6 @@ Predef_LoadSGBLayout: ; 864c -; LoadSGBLayout call CheckCGB - jp nz, Predef_LoadSGBLayoutCGB + jp nz, LoadSGBLayoutCGB ld a, b cp SCGB_RAM @@ -18,7 +17,7 @@ Predef_LoadSGBLayout: ; 864c ld a, [hli] ld h, [hl] ld l, a - ld de, .Finish + ld de, _LoadSGBLayout_ReturnFromJumpTable push de jp hl ; 866f @@ -389,15 +388,13 @@ endr jr z, .partymon ; Egg ld hl, wSGBPals + 3 - ; RGB 7, 7, 7 - ld [hl], $e7 + ld [hl], LOW(palred 7 + palgreen 7 + palblue 7) inc hl - ld [hl], $1c + ld [hl], HIGH(palred 7 + palgreen 7 + palblue 7) inc hl - ; RGB 2, 3, 3 - ld [hl], $62 + ld [hl], LOW(palred 2 + palgreen 3 + palblue 3) inc hl - ld [hl], $c + ld [hl], HIGH(palred 2 + palgreen 3 + palblue 3) jr .done .partymon @@ -576,7 +573,7 @@ endr ld a, [MapGroup] ld e, a ld d, 0 - ld hl, .SGBRoofPalInds + ld hl, MapGroupRoofSGBPalInds add hl, de ld a, [hl] ret @@ -598,37 +595,9 @@ endr ret ; 8a45 -.SGBRoofPalInds: ; 8a45 - db $00 ; Unused - db $12 ; Olivine - db $14 ; Mahogany - db $18 ; Various Dungeons - db $11 ; Ecruteak - db $15 ; Blackthorn - db $09 ; Cinnabar - db $04 ; Cerulean - db $0f ; Azalea - db $16 ; Lake Of Rage - db $0e ; Violet - db $10 ; Goldenrod - db $06 ; Vermilion - db $01 ; Palette - db $03 ; Pewter - db $06 ; Fast Ship - db $0b ; Indigo Plateau - db $08 ; Fuchsia - db $05 ; Lavender - db $17 ; Silver Cave Outside - db $08 ; Pokemon Center 2F - db $07 ; Celadon - db $13 ; Cianwood - db $02 ; Viridian - db $0c ; New Bark - db $0a ; Saffron - db $0d ; Cherrygrove -; 8a60 - -.Finish: ; 8a60 +INCLUDE "gfx/sgb/roof_pal_inds.asm" + +_LoadSGBLayout_ReturnFromJumpTable: ; 8a60 push de call PushSGBPals_ pop hl diff --git a/engine/slot_machine.asm b/engine/slot_machine.asm index 17552878d..cfec11091 100755 --- a/engine/slot_machine.asm +++ b/engine/slot_machine.asm @@ -1,11 +1,13 @@ -SLOTS_NOBIAS EQU -1 -SLOTS_NOMATCH EQU -1 -SLOTS_SEVEN EQU $00 +SLOTS_NO_BIAS EQU -1 +SLOTS_NO_MATCH EQU -1 + +SLOTS_SEVEN EQU $00 SLOTS_POKEBALL EQU $04 -SLOTS_CHERRY EQU $08 -SLOTS_PIKACHU EQU $0c +SLOTS_CHERRY EQU $08 +SLOTS_PIKACHU EQU $0c SLOTS_SQUIRTLE EQU $10 -SLOTS_STARYU EQU $14 +SLOTS_STARYU EQU $14 + REEL_SIZE EQU 15 ; Constants for slot_reel offsets (see macros/wram.asm) @@ -85,7 +87,7 @@ _SlotMachine: call PlaySFX call WaitSFX call ClearBGPalettes - farcall TrainerRankings_EndSlotsWinStreak + farcall StubbedTrainerRankings_EndSlotsWinStreak ld hl, Options res NO_TEXT_SCROLL, [hl] ld hl, rLCDC @@ -148,7 +150,7 @@ _SlotMachine: ld [hl], $40 xor a ; SLOTS_INIT ld [wJumptableIndex], a - ld a, SLOTS_NOBIAS + ld a, SLOTS_NO_BIAS ld [wSlotBias], a ld de, MUSIC_GAME_CORNER call PlayMusic @@ -183,7 +185,7 @@ SlotsLoop: ; 927af (24:67af) ld [wCurrSpriteOAMAddr], a callfar DoNextFrameForFirst16Sprites call .PrintCoinsAndPayout - call .DummyFunc + call .Stubbed_Function927d3 call DelayFrame and a ret @@ -192,7 +194,7 @@ SlotsLoop: ; 927af (24:67af) scf ret -.DummyFunc: ; 927d3 (24:67d3) +.Stubbed_Function927d3: ; 927d3 (24:67d3) ; dummied out ret ld a, [wReel1ReelAction] @@ -232,8 +234,8 @@ SlotsLoop: ; 927af (24:67af) ; 92811 (24:6811) -Function92811: ; 92811 -; unreferenced - debug function? +Unreferenced_Function92811: ; 92811 +; debug function? ld a, [wSlotBias] add 0 daa @@ -252,23 +254,22 @@ Function92811: ; 92811 ; 9282c -Function9282c: ; 9282c -; unreferenced +Unreferenced_Function9282c: ; 9282c ; animate OAM tiles? ld hl, wcf66 ld a, [hl] inc [hl] and $7 ret nz - ld hl, Sprites + 16 * 4 + 2 - ld c, 40 - 16 + ld hl, Sprite17TileID + ld c, NUM_SPRITE_OAM_STRUCTS - 16 .loop ld a, [hl] - xor $20 - ld [hli], a - inc hl - inc hl + xor %00100000 + ld [hli], a ; tile id +rept SPRITEOAMSTRUCT_LENGTH +- 1 inc hl +endr dec c jr nz, .loop ret @@ -309,7 +310,7 @@ SlotsAction_Init: ; 9287e (24:687e) xor a ld [wFirstTwoReelsMatching], a ld [wFirstTwoReelsMatchingSevens], a - ld a, SLOTS_NOMATCH + ld a, SLOTS_NO_MATCH ld [wSlotMatched], a ret @@ -417,7 +418,7 @@ SlotsAction_WaitStopReel3: ; 9293a (24:693a) SlotsAction_FlashIfWin: ; 92955 (24:6955) ld a, [wSlotMatched] - cp SLOTS_NOMATCH + cp SLOTS_NO_MATCH jr nz, .GotIt call SlotsAction_Next call SlotsAction_Next @@ -587,7 +588,7 @@ Slots_StopReel2: ; 92a2e (24:6a2e) ld a, [wSlotBias] and a jr z, .skip - cp SLOTS_NOBIAS + cp SLOTS_NO_BIAS jr nz, .dont_jump .skip call .CheckReel1ForASeven @@ -670,7 +671,7 @@ Slots_InitReelTiles: ; 92a98 (24:6a98) ld bc, wReel1 ld hl, REEL_OAM_ADDR add hl, bc - ld de, Sprites + 16 * 4 + ld de, Sprite17 ld [hl], e inc hl ld [hl], d @@ -688,7 +689,7 @@ Slots_InitReelTiles: ; 92a98 (24:6a98) ld bc, wReel2 ld hl, REEL_OAM_ADDR add hl, bc - ld de, Sprites + 24 * 4 + ld de, Sprite25 ld [hl], e inc hl ld [hl], d @@ -706,7 +707,7 @@ Slots_InitReelTiles: ; 92a98 (24:6a98) ld bc, wReel3 ld hl, REEL_OAM_ADDR add hl, bc - ld de, Sprites + 32 * 4 + ld de, Sprite33 ld [hl], e inc hl ld [hl], d @@ -821,41 +822,40 @@ Slots_UpdateReelPositionAndOAM: ; 92b53 (24:6b53) ld l, a .loop ld a, [wCurrReelYCoord] - ld [hli], a + ld [hli], a ; y ld a, [wCurrReelXCoord] - ld [hli], a + ld [hli], a ; x ld a, [de] - ld [hli], a + ld [hli], a ; tile id srl a srl a - set 7, a - ld [hli], a + set OAM_PRIORITY, a + ld [hli], a ; attributes ld a, [wCurrReelYCoord] - ld [hli], a + ld [hli], a ; y ld a, [wCurrReelXCoord] - add 1 * 8 - ld [hli], a + add 1 * TILE_WIDTH + ld [hli], a ; x ld a, [de] inc a inc a - ld [hli], a + ld [hli], a ; tile id srl a srl a - set 7, a - ld [hli], a + set OAM_PRIORITY, a + ld [hli], a ; attributes inc de ld a, [wCurrReelYCoord] - sub 2 * 8 + sub 2 * TILE_WIDTH ld [wCurrReelYCoord], a - cp 2 * 8 + cp 2 * TILE_WIDTH jr nz, .loop ret ; 92bbe (24:6bbe) -; unreferenced -Function92bbe: ; 92bbe +Unreferenced_Function92bbe: ; 92bbe push hl srl a srl a @@ -997,7 +997,7 @@ ReelAction_StopReel1: ; 92c5e ; even if the current bet won't allow lining it up. ld a, [wSlotBias] - cp SLOTS_NOBIAS + cp SLOTS_NO_BIAS jr z, .NoBias ld hl, REEL_MANIP_COUNTER add hl, bc @@ -1043,7 +1043,7 @@ ReelAction_StopReel2: ; 92c86 jr z, .NoBias .nope ld a, [wSlotBias] - cp SLOTS_NOBIAS + cp SLOTS_NO_BIAS jr z, .NoBias ld hl, REEL_MANIP_COUNTER add hl, bc @@ -1079,7 +1079,7 @@ ReelAction_StopReel3: ; 92ca9 .NoMatch: ld a, [wSlotBias] - cp SLOTS_NOBIAS + cp SLOTS_NO_BIAS jr z, .NoBias ld hl, REEL_MANIP_COUNTER add hl, bc @@ -1532,7 +1532,7 @@ Slots_CheckMatchedFirstTwoReels: ; 92e94 ; 92f1d Slots_CheckMatchedAllThreeReels: ; 92f1d - ld a, SLOTS_NOMATCH + ld a, SLOTS_NO_MATCH ld [wSlotMatched], a call Slots_GetCurrentReelState call Slots_CopyReelState @@ -1552,7 +1552,7 @@ Slots_CheckMatchedAllThreeReels: ; 92f1d .return ld a, [wSlotMatched] - cp SLOTS_NOMATCH + cp SLOTS_NO_MATCH jr nz, .matched_nontrivial and a ret @@ -1753,7 +1753,7 @@ Slots_InitBias: ; 93002 (24:7002) db $14, SLOTS_SQUIRTLE ; 5/128 db $28, SLOTS_PIKACHU ; 5/64 db $30, SLOTS_CHERRY ; 1/32 - db $ff, SLOTS_NOBIAS ; everything else + db $ff, SLOTS_NO_BIAS ; everything else ; 93031 .Lucky: ; 93031 @@ -1763,7 +1763,7 @@ Slots_InitBias: ; 93002 (24:7002) db $10, SLOTS_SQUIRTLE ; 1/32 db $1e, SLOTS_PIKACHU ; 7/128 db $50, SLOTS_CHERRY ; 25/128 - db $ff, SLOTS_NOBIAS ; everything else + db $ff, SLOTS_NO_BIAS ; everything else ; 9303f Slots_IlluminateBetLights: ; 9303f (24:703f) @@ -1869,8 +1869,7 @@ Slots_AskBet: ; 9307c (24:707c) .MenuDataHeader: ; 0x930d6 db MENU_BACKUP_TILES ; flags - db 10, 14 ; start coords - db 17, 19 ; end coords + menu_coords 14, 10, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1 dw .MenuData2 db 1 ; default option ; 0x930de @@ -1924,7 +1923,7 @@ Slots_AskPlayAgain: ; 930e9 (24:70e9) Slots_GetPayout: ; 93124 (24:7124) ld a, [wSlotMatched] - cp SLOTS_NOMATCH + cp SLOTS_NO_MATCH jr z, .no_win srl a ld e, a @@ -1937,7 +1936,7 @@ Slots_GetPayout: ; 93124 (24:7124) ld a, [hl] ld [wPayout], a ld d, a - farcall TrainerRankings_AddToSlotsPayouts + farcall StubbedTrainerRankings_AddToSlotsPayouts ret .PayoutTable: @@ -1957,11 +1956,11 @@ Slots_GetPayout: ; 93124 (24:7124) Slots_PayoutText: ; 93158 (24:7158) ld a, [wSlotMatched] - cp SLOTS_NOMATCH + cp SLOTS_NO_MATCH jr nz, .MatchedSomething ld hl, .Text_Darn call PrintText - farcall TrainerRankings_EndSlotsWinStreak + farcall StubbedTrainerRankings_EndSlotsWinStreak ret .MatchedSomething: @@ -1985,7 +1984,7 @@ Slots_PayoutText: ; 93158 (24:7158) .return ld hl, .Text_PrintPayout call PrintText - farcall TrainerRankings_AddToSlotsWinStreak + farcall StubbedTrainerRankings_AddToSlotsWinStreak ret ; 93195 (24:7195) @@ -2047,7 +2046,7 @@ endr call Random and %0010100 ret z ; 25% chance to stick with seven symbol bias - ld a, SLOTS_NOBIAS + ld a, SLOTS_NO_BIAS ld [wSlotBias], a ret @@ -2055,7 +2054,7 @@ endr call Random and %0011100 ret z ; 12.5% chance to stick with seven symbol bias - ld a, SLOTS_NOBIAS + ld a, SLOTS_NO_BIAS ld [wSlotBias], a ret diff --git a/engine/specials.asm b/engine/specials.asm index cd2394b96..cb8eb3a6b 100644 --- a/engine/specials.asm +++ b/engine/specials.asm @@ -15,7 +15,7 @@ Special:: ; c01b ; c029 SpecialsPointers:: ; c029 - add_special WarpToSpawnPoint + add_special Special_WarpToSpawnPoint ; Communications add_special Special_SetBitsForLinkTradeRequest @@ -25,7 +25,7 @@ SpecialsPointers:: ; c029 add_special Special_CheckBothSelectedSameRoom add_special Special_FailedLinkToPast add_special Special_CloseLink - add_special WaitForOtherPlayerToExit + add_special Special_WaitForOtherPlayerToExit add_special Special_SetBitsForBattleRequest add_special Special_SetBitsForTimeCapsuleRequest add_special Special_CheckTimeCapsuleCompatibility @@ -39,160 +39,160 @@ SpecialsPointers:: ; c029 add_special Special_UnlockMysteryGift ; Map Events - add_special BugContestJudging - add_special CheckPartyFullAfterContest - add_special ContestDropOffMons - add_special ContestReturnMons + add_special Special_BugContestJudging + add_special Special_CheckPartyFullAfterContest + add_special Special_ContestDropOffMons + add_special Special_ContestReturnMons add_special Special_GiveParkBalls add_special Special_CheckMagikarpLength add_special Special_MagikarpHouseSign - add_special HealParty - add_special PokemonCenterPC + add_special HealParty ; this is both a special and a predef + add_special Special_PokemonCenterPC add_special Special_KrissHousePC add_special Special_DayCareMan add_special Special_DayCareLady add_special Special_DayCareManOutside - add_special MoveDeletion + add_special Special_MoveDeletion add_special Special_BankOfMom add_special Special_MagnetTrain - add_special SpecialNameRival + add_special Special_NameRival add_special Special_SetDayOfWeek add_special Special_TownMap add_special Special_UnownPrinter - add_special MapRadio + add_special Special_MapRadio add_special Special_UnownPuzzle add_special Special_SlotMachine add_special Special_CardFlip add_special Special_DummyNonfunctionalGameCornerGame add_special Special_ClearBGPalettesBufferScreen - add_special FadeOutPalettes + add_special Special_FadeOutPalettes add_special Special_BattleTowerFade add_special Special_FadeBlackQuickly - add_special FadeInPalettes + add_special Special_FadeInPalettes add_special Special_FadeInQuickly - add_special Special_ReloadSpritesNoPalettes - add_special ClearBGPalettes - add_special UpdateTimePals - add_special ClearTileMap - add_special UpdateSprites - add_special ReplaceKrisSprite + add_special ReloadSpritesNoPalettes ; bank 0 + add_special ClearBGPalettes ; bank 0 + add_special UpdateTimePals ; bank 0 + add_special ClearTileMap ; bank 0 + add_special UpdateSprites ; bank 0 + add_special ReplaceKrisSprite ; bank 0 add_special Special_GameCornerPrizeMonCheckDex - add_special SpecialSeenMon - add_special WaitSFX - add_special PlayMapMusic - add_special RestartMapMusic - add_special HealMachineAnim + add_special UnusedSpecial_SeenMon + add_special WaitSFX ; bank 0 + add_special PlayMapMusic ; bank 0 + add_special RestartMapMusic ; bank 0 + add_special Special_HealMachineAnim add_special Special_SurfStartStep add_special Special_FindGreaterThanThatLevel add_special Special_FindAtLeastThatHappy add_special Special_FindThatSpecies add_special Special_FindThatSpeciesYourTrainerID - add_special Special_CheckUnusedTwoDayTimer ; unreferenced + add_special UnusedSpecial_CheckUnusedTwoDayTimer add_special Special_DayCareMon1 add_special Special_DayCareMon2 add_special Special_SelectRandomBugContestContestants add_special Special_ActivateFishingSwarm - add_special ToggleMaptileDecorations - add_special ToggleDecorationsVisibility - add_special SpecialGiveShuckle - add_special SpecialReturnShuckle + add_special Special_ToggleMaptileDecorations + add_special Special_ToggleDecorationsVisibility + add_special Special_GiveShuckle + add_special Special_ReturnShuckle add_special Special_BillsGrandfather - add_special SpecialCheckPokerus + add_special Special_CheckPokerus add_special Special_DisplayCoinCaseBalance add_special Special_DisplayMoneyAndCoinBalance - add_special PlaceMoneyTopRight + add_special Special_PlaceMoneyTopRight add_special Special_CheckForLuckyNumberWinners add_special Special_CheckLuckyNumberShowFlag add_special Special_ResetLuckyNumberShowFlag add_special Special_PrintTodaysLuckyNumber add_special Special_SelectApricornForKurt - add_special SpecialNameRater + add_special Special_NameRater add_special Special_DisplayLinkRecord - add_special GetFirstPokemonHappiness - add_special CheckFirstMonIsEgg - add_special RandomUnseenWildMon - add_special RandomPhoneWildMon - add_special RandomPhoneMon - add_special MapCallbackSprites_LoadUsedSpritesGFX - add_special PlaySlowCry - add_special SpecialSnorlaxAwake + add_special Special_GetFirstPokemonHappiness + add_special Special_CheckFirstMonIsEgg + add_special Special_RandomUnseenWildMon + add_special Special_RandomPhoneWildMon + add_special Special_RandomPhoneMon + add_special Special_LoadUsedSpritesGFX + add_special Special_PlaySlowCry + add_special Special_SnorlaxAwake add_special Special_YoungerHaircutBrother add_special Special_OlderHaircutBrother add_special Special_DaisyMassage - add_special PlayCurMonCry - add_special ProfOaksPCBoot - add_special SpecialGameboyCheck - add_special SpecialTrainerHouse - add_special PhotoStudio - add_special InitRoamMons + add_special Special_PlayCurMonCry + add_special Special_ProfOaksPCBoot + add_special Special_GameboyCheck + add_special Special_TrainerHouse + add_special Special_PhotoStudio + add_special Special_InitRoamMons add_special Special_FadeOutMusic - add_special Diploma - add_special PrintDiploma + add_special Special_Diploma + add_special Special_PrintDiploma ; Crystal - add_special Function11ac3e - add_special Function11b444 - add_special Function11b5e8 - add_special Function11b7e5 - add_special Function11b879 - add_special Function11b920 - add_special Function11b93b - add_special BattleTowerRoomMenu - add_special Function1700ba - add_special Function170114 - add_special BattleTowerBattle - add_special Function1704e1 - add_special EmptySpecial_17021d - add_special Function_LoadOpponentTrainerAndPokemonsWithOTSprite - add_special Function11ba38 - add_special SpecialCheckForBattleTowerRules + add_special Special_Function11ac3e + add_special Special_Function11b444 + add_special Special_Function11b5e8 + add_special Special_Function11b7e5 + add_special Special_Function11b879 + add_special Special_Function11b920 + add_special Special_Function11b93b + add_special Special_BattleTowerRoomMenu + add_special Special_Function1700ba + add_special Special_Function170114 + add_special Special_BattleTowerBattle + add_special UnusedSpecial_Function1704e1 + add_special DummySpecial_17021d + add_special Special_LoadOpponentTrainerAndPokemonWithOTSprite + add_special Special_Function11ba38 + add_special Special_CheckForBattleTowerRules add_special Special_GiveOddEgg - add_special Reset - add_special Function1011f1 - add_special Function101220 - add_special Function101225 - add_special Function101231 + add_special Reset ; bank 0 + add_special Special_Function1011f1 + add_special Special_Function101220 + add_special Special_Function101225 + add_special Special_Function101231 add_special Special_MoveTutor - add_special SpecialOmanyteChamber - add_special Function11c1ab - add_special BattleTowerAction + add_special Special_OmanyteChamber + add_special Special_Function11c1ab + add_special Special_BattleTowerAction add_special Special_DisplayUnownWords add_special Special_Menu_ChallengeExplanationCancel - add_special Function17d2b6 - add_special Function17d2ce - add_special BattleTowerMobileError - add_special AskMobileOrCable - add_special SpecialHoOhChamber - add_special Function102142 + add_special Special_Function17d2b6 + add_special Special_Function17d2ce + add_special Special_BattleTowerMobileError + add_special Special_AskMobileOrCable + add_special Special_HoOhChamber + add_special Special_Function102142 add_special Special_CelebiShrineEvent - add_special CheckCaughtCelebi - add_special SpecialPokeSeer - add_special SpecialBuenasPassword - add_special SpecialBuenaPrize - add_special SpecialDratini + add_special Special_CheckCaughtCelebi + add_special Special_PokeSeer + add_special Special_BuenasPassword + add_special Special_BuenaPrize + add_special Special_Dratini add_special Special_SampleKenjiBreakCountdown - add_special SpecialBeastsCheck - add_special SpecialMonCheck + add_special Special_BeastsCheck + add_special Special_MonCheck add_special Special_SetPlayerPalette - add_special ret_170bd2 - add_special Mobile_SelectThreeMons - add_special Function1037eb - add_special Function10383c - add_special TrainerRankings_Healings - add_special RefreshSprites - add_special Function1037c2 - add_special Mobile_DummyReturnFalse - add_special Function103780 - add_special Function10387b - add_special AskRememberPassword - add_special LoadMapPalettes - add_special FindItemInPCOrBag + add_special DummySpecial_170bd2 + add_special Special_Mobile_SelectThreeMons + add_special Special_Function1037eb + add_special Special_Function10383c + add_special Special_StubbedTrainerRankings_Healings + add_special Special_RefreshSprites + add_special Special_Function1037c2 + add_special Special_Mobile_DummyReturnFalse + add_special Special_Function103780 + add_special Special_Function10387b + add_special Special_AskRememberPassword + add_special Special_LoadMapPalettes + add_special UnusedSpecial_FindItemInPCOrBag add_special Special_InitialSetDSTFlag add_special Special_InitialClearDSTFlag - add_special SpecialNone + add_special DummySpecial_c224 ; c224 -SpecialNone: ; c224 +DummySpecial_c224: ; c224 ret ; c225 @@ -214,12 +214,12 @@ Special_GameCornerPrizeMonCheckDex: ; c230 call FadeToMenu ld a, [ScriptVar] ld [wd265], a - farcall NewPokedexEntry + farcall Predef_NewPokedexEntry call ExitAllMenus ret ; c252 -SpecialSeenMon: ; c252 +UnusedSpecial_SeenMon: ; c252 ld a, [ScriptVar] dec a call SetSeenMon @@ -265,7 +265,7 @@ FoundNone: ; c298 ret ; c29d -SpecialNameRival: ; 0xc29d +Special_NameRival: ; 0xc29d ld b, $2 ; rival ld de, RivalName farcall _NamingScreen @@ -279,7 +279,7 @@ SpecialNameRival: ; 0xc29d DefaultRivalName: ; 0xc2b2 db "SILVER@" -SpecialNameRater: ; c2b9 +Special_NameRater: ; c2b9 farcall NameRater ret ; c2c0 @@ -363,14 +363,14 @@ Special_GetMysteryGiftItem: ; c309 db "@" ; 0xc34a -BugContestJudging: ; c34a - farcall _BugContestJudging +Special_BugContestJudging: ; c34a + farcall _Special_BugContestJudging ld a, b ld [ScriptVar], a ret ; c355 -MapRadio: ; c355 +Special_MapRadio: ; c355 ld a, [ScriptVar] ld e, a farcall PlayRadio @@ -483,7 +483,7 @@ ScriptReturnCarry: ; c3e2 ret ; c3ef -Special_CheckUnusedTwoDayTimer: ; c3ef +UnusedSpecial_CheckUnusedTwoDayTimer: ; c3ef farcall CheckUnusedTwoDayTimer ld a, [wUnusedTwoDayTimer] ld [ScriptVar], a @@ -517,7 +517,7 @@ StoreSwarmMapIndices:: ; c403 ; c419 -SpecialCheckPokerus: ; c419 +Special_CheckPokerus: ; c419 ; Check if a monster in your party has Pokerus farcall CheckPokerus jp ScriptReturnCarry @@ -536,7 +536,7 @@ Special_CheckLuckyNumberShowFlag: ; c434 jp ScriptReturnCarry ; c43d -SpecialSnorlaxAwake: ; 0xc43d +Special_SnorlaxAwake: ; 0xc43d ; Check if the Poké Flute channel is playing, and if the player is standing ; next to Snorlax. @@ -587,13 +587,13 @@ SpecialSnorlaxAwake: ; 0xc43d db -1 -PlayCurMonCry: ; c472 +Special_PlayCurMonCry: ; c472 ld a, [CurPartySpecies] jp PlayCry ; c478 -SpecialGameboyCheck: ; c478 +Special_GameboyCheck: ; c478 ld a, [hCGB] and a jr nz, .cgb @@ -603,13 +603,13 @@ SpecialGameboyCheck: ; c478 jr nz, .sgb .gb - xor a + xor a ; GBCHECK_GB jr .done .sgb - ld a, 1 + ld a, GBCHECK_SGB jr .done .cgb - ld a, 2 + ld a, GBCHECK_CGB .done ld [ScriptVar], a ret @@ -625,21 +625,21 @@ Special_FadeOutMusic: ; c48f ret ; c49f -Diploma: ; c49f +Special_Diploma: ; c49f call FadeToMenu farcall _Diploma call ExitAllMenus ret ; c4ac -PrintDiploma: ; c4ac +Special_PrintDiploma: ; c4ac call FadeToMenu farcall _PrintDiploma call ExitAllMenus ret ; c4b9 -SpecialTrainerHouse: ; 0xc4b9 +Special_TrainerHouse: ; 0xc4b9 ld a, BANK(sMysteryGiftTrainerHouseFlag) call GetSRAMBank ld a, [sMysteryGiftTrainerHouseFlag] diff --git a/engine/sprite_anims.asm b/engine/sprite_anims.asm index 9fb78a5d7..29af03d89 100755 --- a/engine/sprite_anims.asm +++ b/engine/sprite_anims.asm @@ -27,7 +27,7 @@ DoAnimFrame: ; 8d24b dw .SlotsChansey dw .SlotsChanseyEgg dw .MailCursor - dw .ForUnusedCursor + dw .UnusedCursor dw .DummyGameCursor dw .PokegearArrow dw .TradePokeBall @@ -39,11 +39,11 @@ DoAnimFrame: ; 8d24b dw .FlyFrom dw .FlyLeaf dw .FlyTo - dw .sprite_anim_seq_19 - dw .sprite_anim_seq_1A - dw .sprite_anim_seq_1B - dw .sprite_anim_seq_1C - dw .IntroSuicune + dw .GSIntroHoOh + dw .EZChatCursor + dw .MobileTradeSentPulse + dw .MobileTradeOTPulse + dw .IntroSuicune dw .IntroPichuWooper dw .Celebi dw .IntroUnown @@ -202,7 +202,7 @@ DoAnimFrame: ; 8d24b ret ; 8d35a -.sprite_anim_seq_19 ; 8d35a (23:535a) +.GSIntroHoOh ; 8d35a (23:535a) ld hl, SPRITEANIMSTRUCT_0C add hl, bc ld a, [hl] @@ -403,7 +403,7 @@ DoAnimFrame: ; 8d24b ld [hl], a ret -.ForUnusedCursor ; 8d46e (23:546e) +.UnusedCursor ; 8d46e (23:546e) callfar ret_e00ed ret @@ -430,7 +430,7 @@ DoAnimFrame: ; 8d24b ; 8d493 .TradePokeBall_zero ; 8d493 - ld a, SPRITE_ANIM_FRAMESET_TRADE_POKE_BALL_0 + ld a, SPRITE_ANIM_FRAMESET_TRADE_POKE_BALL_WIGGLE call _ReinitSpriteAnimFrame ld hl, SPRITEANIMSTRUCT_JUMPTABLE_INDEX @@ -748,11 +748,11 @@ DoAnimFrame: ; 8d24b ld [hl], a ret -.sprite_anim_seq_1B ; 8d630 (23:5630) +.MobileTradeSentPulse ; 8d630 (23:5630) farcall Function108bc7 ret -.sprite_anim_seq_1C ; 8d637 (23:5637) +.MobileTradeOTPulse ; 8d637 (23:5637) farcall Function108be0 ret @@ -845,7 +845,7 @@ DoAnimFrame: ; 8d24b ld [hl], a ret -.sprite_anim_seq_1A ; 8d6b7 (23:56b7) +.EZChatCursor ; 8d6b7 (23:56b7) farcall AnimateEZChatCursor ret diff --git a/engine/sprites.asm b/engine/sprites.asm index e1aad4832..7928fe1f0 100755 --- a/engine/sprites.asm +++ b/engine/sprites.asm @@ -36,7 +36,7 @@ PlaySpriteAnimations: ; 8cf69 DoNextFrameForAllSprites: ; 8cf7a ld hl, wSpriteAnimationStructs - ld e, 10 ; There are 10 structs here. + ld e, NUM_SPRITE_ANIM_STRUCTS .loop ld a, [hl] @@ -53,7 +53,7 @@ DoNextFrameForAllSprites: ; 8cf7a jr c, .done .next - ld bc, $10 + ld bc, SPRITEANIMSTRUCT_LENGTH add hl, bc dec e jr nz, .loop @@ -76,7 +76,7 @@ DoNextFrameForAllSprites: ; 8cf7a DoNextFrameForFirst16Sprites: ; 8cfa8 (23:4fa8) ld hl, wSpriteAnimationStructs - ld e, 10 + ld e, NUM_SPRITE_ANIM_STRUCTS .loop ld a, [hl] @@ -93,18 +93,18 @@ DoNextFrameForFirst16Sprites: ; 8cfa8 (23:4fa8) jr c, .done .next - ld bc, $10 + ld bc, SPRITEANIMSTRUCT_LENGTH add hl, bc dec e jr nz, .loop ld a, [wCurrSpriteOAMAddr] ld l, a - ld h, HIGH(Sprites + 16 * 4) + ld h, HIGH(Sprite17) .loop2 ; Clear (Sprites + [wCurrSpriteOAMAddr] --> Sprites + $40) ld a, l - cp LOW(Sprites + 16 * 4) + cp LOW(Sprite17) jr nc, .done xor a ld [hli], a @@ -119,12 +119,12 @@ InitSpriteAnimStruct:: ; 8cfd6 push de push af ld hl, wSpriteAnimationStructs - ld e, 10 + ld e, NUM_SPRITE_ANIM_STRUCTS .loop ld a, [hl] and a jr z, .found - ld bc, $10 + ld bc, SPRITEANIMSTRUCT_LENGTH add hl, bc dec e jr nz, .loop @@ -222,8 +222,8 @@ DeinitializeSprite: ; 8d036 DeinitializeAllSprites: ; 8d03d (23:503d) ; Clear the index field of every struct in the wSpriteAnimationStructs array. ld hl, wSpriteAnimationStructs - ld bc, $10 - ld e, 10 + ld bc, SPRITEANIMSTRUCT_LENGTH + ld e, NUM_SPRITE_ANIM_STRUCTS xor a .loop ld [hl], a @@ -391,7 +391,7 @@ GetSpriteAnimVTile: ; 8d109 push bc ld hl, wSpriteAnimDict ld b, a - ld c, 10 + ld c, NUM_SPRITE_ANIM_STRUCTS .loop ld a, [hli] cp b @@ -527,8 +527,7 @@ GetFrameOAMPointer: ; 8d1a2 ret ; 8d1ac -BrokenGetStdGraphics: ; 8d1ac -; dummied out +Unreferenced_BrokenGetStdGraphics: ; 8d1ac push hl ld l, a ld h, 0 @@ -576,21 +575,22 @@ BrokenStdGFXPointers: ; Broken 2bpp pointers Sprites_Cosine: ; 8e72a - add $10 +; a = d * cos(a * pi/32) + add %010000 Sprites_Sine: ; 8e72c -; floor(d * sin(a * pi/32)) - and $3f - cp $20 +; a = d * sin(a * pi/32) + and %111111 + cp %100000 jr nc, .negative call .ApplySineWave ld a, h ret .negative - and $1f + and %011111 call .ApplySineWave ld a, h - xor $ff ; cpl + xor $ff inc a ret ; 8e741 @@ -610,7 +610,6 @@ Sprites_Sine: ; 8e72c srl a jr nc, .even add hl, de - .even sla e rl d @@ -650,8 +649,8 @@ AnimateEndOfExpBar: ; 8e79d ; 8e7c6 .AnimateFrame: ; 8e7c6 - ld hl, Sprites - ld c, $8 + ld hl, Sprite01 + ld c, 8 ; number of animated circles .anim_loop ld a, c and a @@ -669,8 +668,8 @@ AnimateEndOfExpBar: ; 8e79d call Sprites_Sine pop hl pop de - add 13 * 8 - ld [hli], a + add 13 * TILE_WIDTH + ld [hli], a ; y pop af push de @@ -678,13 +677,13 @@ AnimateEndOfExpBar: ; 8e79d call Sprites_Cosine pop hl pop de - add 10 * 8 + 4 - ld [hli], a + add 10 * TILE_WIDTH + 4 + ld [hli], a ; x ld a, $0 - ld [hli], a + ld [hli], a ; tile id ld a, PAL_BATTLE_OB_BLUE - ld [hli], a + ld [hli], a ; attributes jr .anim_loop ; 8e7f4 diff --git a/engine/start_menu.asm b/engine/start_menu.asm index a07e8ff4a..78de950b8 100755 --- a/engine/start_menu.asm +++ b/engine/start_menu.asm @@ -153,15 +153,13 @@ StartMenu:: ; 125cd .MenuDataHeader: db MENU_BACKUP_TILES ; flags - db 0, 10 ; start coords - db 17, 19 ; end coords + menu_coords 10, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1 dw .MenuData db 1 ; default selection .ContestMenuDataHeader: db MENU_BACKUP_TILES ; flags - db 2, 10 ; start coords - db 17, 19 ; end coords + menu_coords 10, 2, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1 dw .MenuData db 1 ; default selection @@ -503,7 +501,7 @@ StartMenu_Pack: ; 1295b call FadeToMenu farcall Pack - ld a, [wcf66] + ld a, [wPackUsedItem] and a jr nz, .used_item call CloseSubmenu @@ -593,7 +591,7 @@ HasNoItems: ; 129d5 TossItemFromPC: ; 129f4 push de - call PartyMonItemName + call Predef_PartyMonItemName farcall _CheckTossableItem ld a, [wItemAttributeParamBuffer] and a @@ -616,7 +614,7 @@ TossItemFromPC: ; 129f4 pop hl ld a, [CurItemQuantity] call TossItem - call PartyMonItemName + call Predef_PartyMonItemName ld hl, .TossedThisMany call MenuTextBox call ExitMenu @@ -668,7 +666,7 @@ CantUseItemText: ; 12a67 ; 12a6c -PartyMonItemName: ; 12a6c +Predef_PartyMonItemName: ; 12a6c ld a, [CurItem] ld [wd265], a call GetItemName @@ -862,7 +860,7 @@ GiveTakePartyMonItem: ; 12b60 TryGiveItemToPartymon: ; 12bd9 call SpeechTextBox - call PartyMonItemName + call Predef_PartyMonItemName call GetPartyItemLocation ld a, [hl] and a @@ -976,14 +974,13 @@ TakePartyItem: ; 12c60 GiveTakeItemMenuData: ; 12c9b - db %01010000 - db 12, 12 ; start coords - db 17, 19 ; end coords + db MENU_SPRITE_ANIMS | MENU_BACKUP_TILES ; flags + menu_coords 12, 12, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1 dw .Items db 1 ; default option .Items: - db %10000000 ; x padding + db STATICMENU_CURSOR ; flags db 2 ; # items db "GIVE@" db "TAKE@" @@ -1166,8 +1163,7 @@ MonMailAction: ; 12d45 .MenuDataHeader: db MENU_BACKUP_TILES ; flags - db 10, 12 ; start coords - db 17, 19 ; end coords + menu_coords 12, 10, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1 dw .MenuData2 db 1 ; default option ; 0x12dd1 @@ -1225,7 +1221,7 @@ OpenPartyStats: ; 12e00 xor a ld [MonType], a call LowVolume - predef StatsScreenInit + predef Predef_StatsScreenInit call MaxVolume call Call_ExitMenu ld a, 0 @@ -1255,7 +1251,7 @@ MonMenu_Fly: ; 12e30 jr z, .Fail cp $0 jr z, .Error - farcall TrainerRankings_Fly + farcall StubbedTrainerRankings_Fly ld b, $4 ld a, $2 ret @@ -1268,7 +1264,7 @@ MonMenu_Fly: ; 12e30 ld a, $0 ret -.Unused: +.Unreferenced: ld a, $1 ret ; 12e55 @@ -1792,7 +1788,7 @@ SetUpMoveScreenBG: ; 13172 hlcoord 5, 1 call PlaceString push bc - farcall CopyPkmnToTempMon + farcall Predef_CopyPkmnToTempMon pop hl call PrintLevel ld hl, PlayerHPPal @@ -1809,7 +1805,7 @@ SetUpMoveList: ; 131ef ld [hBGMapMode], a ld [wMoveSwapBuffer], a ld [MonType], a - predef CopyPkmnToTempMon + predef Predef_CopyPkmnToTempMon ld hl, TempMonMoves ld de, wListMoves_MoveIndicesBuffer ld bc, NUM_MOVES @@ -1817,9 +1813,9 @@ SetUpMoveList: ; 131ef ld a, SCREEN_WIDTH * 2 ld [Buffer1], a hlcoord 2, 3 - predef ListMoves + predef Predef_ListMoves hlcoord 10, 4 - predef ListMovePP + predef Predef_ListMovePP call WaitBGMap call SetPalettes ld a, [wNumMoves] @@ -1863,7 +1859,7 @@ PlaceMoveData: ; 13256 ld a, [CurMove] ld b, a hlcoord 2, 12 - predef PrintMoveType + predef Predef_PrintMoveType ld a, [CurMove] dec a ld hl, Moves + MOVE_POWER @@ -1886,7 +1882,7 @@ PlaceMoveData: ; 13256 .description hlcoord 1, 14 - predef PrintMoveDesc + predef Predef_PrintMoveDesc ld a, $1 ld [hBGMapMode], a ret diff --git a/engine/stats_screen.asm b/engine/stats_screen.asm index 9f632f388..6bceaa1e9 100755 --- a/engine/stats_screen.asm +++ b/engine/stats_screen.asm @@ -1,14 +1,20 @@ +const_value set 1 + const PINK_PAGE ; 1 + const GREEN_PAGE ; 2 + const BLUE_PAGE ; 3 +NUM_STAT_PAGES EQU const_value +- 1 + BattleStatsScreenInit: ; 4dc7b (13:5c7b) ld a, [wLinkMode] cp LINK_MOBILE - jr nz, StatsScreenInit + jr nz, Predef_StatsScreenInit ld a, [wBattleMode] and a - jr z, StatsScreenInit + jr z, Predef_StatsScreenInit jr _MobileStatsScreenInit -StatsScreenInit: ; 4dc8a +Predef_StatsScreenInit: ; 4dc8a ld hl, StatsScreenMain jr StatsScreenInit_gotaddress @@ -58,12 +64,12 @@ StatsScreenMain: ; 0x4dcd2 ; stupid interns ld [wcf64], a ld a, [wcf64] - and $fc - or $1 + and %11111100 + or 1 ld [wcf64], a .loop ; 4dce3 ld a, [wJumptableIndex] - and $7f + and $ff ^ (1 << 7) ld hl, StatsScreenPointerTable rst JumpTable call StatsScreen_WaitAnim ; check for keys? @@ -79,13 +85,13 @@ StatsScreenMobile: ; 4dcf7 ; stupid interns ld [wcf64], a ld a, [wcf64] - and $fc - or $1 + and %11111100 + or 1 ld [wcf64], a .loop farcall Mobile_SetOverworldDelay ld a, [wJumptableIndex] - and $7f + and $ff ^ (1 << 7) ld hl, StatsScreenPointerTable rst JumpTable call StatsScreen_WaitAnim @@ -234,7 +240,7 @@ StatsScreen_CopyToTempMon: ; 4ddf2 (13:5df2) jr .done .breedmon - farcall CopyPkmnToTempMon + farcall Predef_CopyPkmnToTempMon ld a, [CurPartySpecies] cp EGG jr z, .done @@ -277,7 +283,7 @@ StatsScreen_GetJoypad: ; 4de2c (13:5e2c) StatsScreen_JoypadAction: ; 4de54 (13:5e54) push af ld a, [wcf64] - and $3 + maskbits NUM_STAT_PAGES +- 1 ld c, a pop af bit B_BUTTON_F, a @@ -335,20 +341,20 @@ StatsScreen_JoypadAction: ; 4de54 (13:5e54) .a_button ld a, c - cp $3 + cp BLUE_PAGE ; last page jr z, .b_button .d_right inc c - ld a, $3 + ld a, BLUE_PAGE ; last page cp c jr nc, .set_page - ld c, $1 + ld c, PINK_PAGE ; first page jr .set_page .d_left dec c jr nz, .set_page - ld c, $3 + ld c, BLUE_PAGE ; last page jr .set_page .done @@ -419,7 +425,7 @@ StatsScreen_InitUpperHalf: ; 4deea (13:5eea) ld a, [hli] ld d, a ld e, [hl] - farcall ComputeHPBarPixels + farcall Predef_ComputeHPBarPixels ld hl, wCurHPPal call SetHPPal ld b, SCGB_STATS_SCREEN_HP_PALS @@ -429,7 +435,7 @@ StatsScreen_InitUpperHalf: ; 4deea (13:5eea) .PlaceGenderChar: ; 4df66 (13:5f66) push hl - farcall GetGender + farcall Predef_GetGender pop hl ret c ld a, "♂" @@ -447,13 +453,12 @@ StatsScreen_InitUpperHalf: ; 4deea (13:5eea) dw wBufferMonNick ; 4df7f -Function4df7f: ; 4df7f -; unreferenced +Unreferenced_Function4df7f: ; 4df7f hlcoord 7, 0 ld bc, SCREEN_WIDTH ld d, SCREEN_HEIGHT .loop - ld a, "|" + ld a, $31 ; vertical divider ld [hl], a add hl, bc dec d @@ -464,7 +469,7 @@ Function4df7f: ; 4df7f StatsScreen_PlaceHorizontalDivider: ; 4df8f (13:5f8f) hlcoord 0, 7 ld b, SCREEN_WIDTH - ld a, "_" + ld a, $62 ; horizontal divider (empty HP/exp bar) .loop ld [hli], a dec b @@ -507,7 +512,7 @@ StatsScreen_LoadGFX: ; 4dfb6 (13:5fb6) .ClearBox: ; 4dfda (13:5fda) ld a, [wcf64] - and $3 + maskbits NUM_STAT_PAGES +- 1 ld c, a call StatsScreen_LoadPageIndicators hlcoord 0, 8 @@ -517,7 +522,7 @@ StatsScreen_LoadGFX: ; 4dfb6 (13:5fb6) .LoadPals: ; 4dfed (13:5fed) ld a, [wcf64] - and $3 + maskbits NUM_STAT_PAGES +- 1 ld c, a farcall LoadStatsScreenPals call DelayFrame @@ -527,13 +532,14 @@ StatsScreen_LoadGFX: ; 4dfb6 (13:5fb6) .PageTilemap: ; 4e002 (13:6002) ld a, [wcf64] - and $3 + maskbits NUM_STAT_PAGES +- 1 dec a ld hl, .Jumptable rst JumpTable ret .Jumptable: ; 4e00d (13:600d) +; entries correspond to *_PAGE constants dw .PinkPage dw .GreenPage dw .BluePage @@ -541,9 +547,9 @@ StatsScreen_LoadGFX: ; 4dfb6 (13:5fb6) .PinkPage: ; 4e013 (13:6013) hlcoord 0, 9 ld b, $0 - predef DrawPlayerHP + predef Predef_DrawPlayerHP hlcoord 8, 9 - ld [hl], $41 + ld [hl], $41 ; right HP/exp bar end cap ld de, .Status_Type hlcoord 0, 12 call PlaceString @@ -555,7 +561,7 @@ StatsScreen_LoadGFX: ; 4dfb6 (13:5fb6) and $f0 jr z, .NotImmuneToPkrs hlcoord 8, 8 - ld [hl], "." + ld [hl], "." ; Pokérus immunity dot .NotImmuneToPkrs: ld a, [MonType] cp BOXMON @@ -563,7 +569,7 @@ StatsScreen_LoadGFX: ; 4dfb6 (13:5fb6) hlcoord 6, 13 push hl ld de, TempMonStatus - predef PlaceStatusString + predef Predef_PlaceStatusString pop hl jr nz, .done_status jr .StatusOK @@ -577,11 +583,11 @@ StatsScreen_LoadGFX: ; 4dfb6 (13:5fb6) call PlaceString .done_status hlcoord 1, 15 - predef PrintMonTypes + predef Predef_PrintMonTypes hlcoord 9, 8 ld de, SCREEN_WIDTH ld b, 10 - ld a, "|" + ld a, $31 ; vertical divider .vertical_divider ld [hl], a add hl, de @@ -611,11 +617,11 @@ StatsScreen_LoadGFX: ; 4dfb6 (13:5fb6) ld a, [TempMonLevel] ld b, a ld de, TempMonExp + 2 - predef FillInExpBar + predef Predef_FillInExpBar hlcoord 10, 16 - ld [hl], $40 + ld [hl], $40 ; left exp bar end cap hlcoord 19, 16 - ld [hl], $41 + ld [hl], $41 ; right exp bar end cap ret .PrintNextLevel: ; 4e0d3 (13:60d3) @@ -704,11 +710,11 @@ StatsScreen_LoadGFX: ; 4dfb6 (13:5fb6) hlcoord 8, 10 ld a, SCREEN_WIDTH * 2 ld [Buffer1], a - predef ListMoves + predef Predef_ListMoves hlcoord 12, 11 ld a, SCREEN_WIDTH * 2 ld [Buffer1], a - predef ListMovePP + predef Predef_ListMovePP ret .GetItemName: ; 4e189 (13:6189) @@ -741,7 +747,7 @@ StatsScreen_LoadGFX: ; 4dfb6 (13:5fb6) hlcoord 10, 8 ld de, SCREEN_WIDTH ld b, 10 - ld a, "|" + ld a, $31 ; vertical divider .BluePageVerticalDivider: ld [hl], a add hl, de @@ -749,7 +755,7 @@ StatsScreen_LoadGFX: ; 4dfb6 (13:5fb6) jr nz, .BluePageVerticalDivider hlcoord 11, 8 ld bc, 6 - predef PrintTempMonStats + predef Predef_PrintTempMonStats ret .PlaceOTInfo: ; 4e1cc (13:61cc) @@ -802,7 +808,7 @@ OTString: ; 4e222 StatsScreen_PlaceFrontpic: ; 4e226 (13:6226) ld hl, TempMonDVs - predef GetUnownLetter + predef Predef_GetUnownLetter call StatsScreen_GetAnimationParam jr c, .egg and a @@ -864,11 +870,11 @@ StatsScreen_PlaceFrontpic: ; 4e226 (13:6226) ret c call StatsScreen_LoadTextBoxSpaceGFX ld de, vTiles2 tile $00 - predef GetAnimatedFrontpicPredef + predef Predef_GetAnimatedFrontpic hlcoord 0, 0 ld d, $0 ld e, ANIM_MON_MENU - predef LoadMonAnimation + predef Predef_LoadMonAnimation ld hl, wcf64 set 6, [hl] ret @@ -951,7 +957,7 @@ StatsScreen_LoadTextBoxSpaceGFX: ; 4e307 (13:6307) ld [rVBK], a ld de, TextBoxSpaceGFX lb bc, BANK(TextBoxSpaceGFX), 1 - ld hl, vTiles2 tile $7f + ld hl, vTiles2 tile " " call Get2bpp pop af ld [rVBK], a @@ -962,9 +968,8 @@ StatsScreen_LoadTextBoxSpaceGFX: ; 4e307 (13:6307) ret ; 4e32a (13:632a) -; unreferenced -Unknown_4e32a: ; 4e32a -; A blank tile? +Unreferenced_4e32a: ; 4e32a +; A blank space tile? ds 16 ; 4e33a @@ -1069,33 +1074,33 @@ StatsScreen_AnimateEgg: ; 4e497 (13:6497) ld [wBoxAlignment], a call StatsScreen_LoadTextBoxSpaceGFX ld de, vTiles2 tile $00 - predef GetAnimatedFrontpicPredef + predef Predef_GetAnimatedFrontpic pop de hlcoord 0, 0 ld d, $0 - predef LoadMonAnimation + predef Predef_LoadMonAnimation ld hl, wcf64 set 6, [hl] ret StatsScreen_LoadPageIndicators: ; 4e4cd (13:64cd) hlcoord 13, 5 - ld a, $36 + ld a, $36 ; first of 4 small square tiles call .load_square hlcoord 15, 5 - ld a, $36 + ld a, $36 ; """ call .load_square hlcoord 17, 5 - ld a, $36 + ld a, $36 ; """ call .load_square ld a, c - cp $2 - ld a, $3a - hlcoord 13, 5 + cp GREEN_PAGE + ld a, $3a ; first of 4 large square tiles + hlcoord 13, 5 ; PINK_PAGE (< GREEN_PAGE) jr c, .load_square - hlcoord 15, 5 + hlcoord 15, 5 ; GREEN_PAGE (= GREEN_PAGE) jr z, .load_square - hlcoord 17, 5 + hlcoord 17, 5 ; BLUE_PAGE (> GREEN_PAGE) .load_square ; 4e4f7 (13:64f7) push bc ld [hli], a @@ -1113,7 +1118,7 @@ StatsScreen_LoadPageIndicators: ; 4e4cd (13:64cd) CopyNickname: ; 4e505 (13:6505) ld de, StringBuffer1 ld bc, PKMN_NAME_LENGTH - jr .okay ; uuterly pointless + jr .okay ; utterly pointless .okay ld a, [MonType] cp BOXMON @@ -1157,7 +1162,7 @@ CheckFaintedFrzSlp: ; 4e53f ld hl, MON_STATUS add hl, bc ld a, [hl] - and (1 << FRZ) | SLP + and 1 << FRZ | SLP jr nz, .fainted_frz_slp and a ret diff --git a/engine/tempmon.asm b/engine/tempmon.asm index be989d14b..abd85a9ec 100644 --- a/engine/tempmon.asm +++ b/engine/tempmon.asm @@ -1,4 +1,4 @@ -CopyPkmnToTempMon: ; 5084a +Predef_CopyPkmnToTempMon: ; 5084a ; gets the BaseData of a Pkmn ; and copys the PkmnStructure to TempMon @@ -51,7 +51,7 @@ _TempMonStatsCalculation: ; 50893 add hl, bc push bc ld b, $1 - predef CalcPkmnStats + predef Predef_CalcPkmnStats pop bc ld hl, MON_HP add hl, bc diff --git a/engine/tileset_anims.asm b/engine/tileset_anims.asm new file mode 100644 index 000000000..74679b1ee --- /dev/null +++ b/engine/tileset_anims.asm @@ -0,0 +1,1060 @@ +_AnimateTileset:: ; fc000 +; Iterate over a given pointer array of +; animation functions (one per frame). + +; Typically in wra1, vra0 + + ld a, [TilesetAnim] + ld e, a + ld a, [TilesetAnim + 1] + ld d, a + + ld a, [hTileAnimFrame] + ld l, a + inc a + ld [hTileAnimFrame], a + + ld h, 0 + add hl, hl + add hl, hl + add hl, de + +; 2-byte parameter +; All functions take input de. + ld e, [hl] + inc hl + ld d, [hl] + inc hl + +; Function address + ld a, [hli] + ld h, [hl] + ld l, a + + jp hl +; fc01b + +Tileset0Anim: ; 0xfc01b +TilesetJohto2Anim: ; 0xfc01b +TilesetKantoAnim: ; 0xfc01b + dw vTiles2 tile $14, AnimateWaterTile + dw NULL, WaitTileAnimation + dw NULL, WaitTileAnimation + dw NULL, WaitTileAnimation + dw NULL, TileAnimationPalette + dw NULL, WaitTileAnimation + dw NULL, AnimateFlowerTile + dw NULL, WaitTileAnimation + dw NULL, WaitTileAnimation + dw NULL, StandingTileFrame8 + dw NULL, DoneTileAnimation +; 0xfc047 + +TilesetParkAnim: ; 0xfc047 + dw vTiles2 tile $14, AnimateWaterTile + dw NULL, WaitTileAnimation + dw vTiles2 tile $5f, AnimateFountain + dw NULL, WaitTileAnimation + dw NULL, TileAnimationPalette + dw NULL, WaitTileAnimation + dw NULL, AnimateFlowerTile + dw NULL, WaitTileAnimation + dw NULL, WaitTileAnimation + dw NULL, StandingTileFrame8 + dw NULL, DoneTileAnimation +; 0xfc073 + +TilesetIlexForestAnim: ; 0xfc073 + dw NULL, ForestTreeLeftAnimation + dw NULL, ForestTreeRightAnimation + dw NULL, WaitTileAnimation + dw NULL, WaitTileAnimation + dw NULL, WaitTileAnimation + dw NULL, ForestTreeLeftAnimation2 + dw NULL, ForestTreeRightAnimation2 + dw NULL, AnimateFlowerTile + dw vTiles2 tile $14, AnimateWaterTile + dw NULL, TileAnimationPalette + dw NULL, StandingTileFrame8 + dw NULL, DoneTileAnimation +; 0xfc0a3 + +TilesetJohto1Anim: ; 0xfc0a3 + dw vTiles2 tile $14, AnimateWaterTile + dw NULL, WaitTileAnimation + dw NULL, WaitTileAnimation + dw NULL, TileAnimationPalette + dw NULL, WaitTileAnimation + dw NULL, AnimateFlowerTile + dw WhirlpoolFrames1, AnimateWhirlpoolTile + dw WhirlpoolFrames2, AnimateWhirlpoolTile + dw WhirlpoolFrames3, AnimateWhirlpoolTile + dw WhirlpoolFrames4, AnimateWhirlpoolTile + dw NULL, WaitTileAnimation + dw NULL, StandingTileFrame8 + dw NULL, DoneTileAnimation +; 0xfc0d7 + +UnusedTilesetAnim_fc0d7: ; 0xfc0d7 + dw vTiles2 tile $03, WriteTileToBuffer + dw wTileAnimBuffer, ScrollTileRightLeft + dw vTiles2 tile $03, WriteTileFromBuffer + dw NULL, WaitTileAnimation + dw NULL, WaitTileAnimation + dw NULL, WaitTileAnimation + dw NULL, AnimateFlowerTile + dw NULL, WaitTileAnimation + dw NULL, WaitTileAnimation + dw NULL, WaitTileAnimation + dw NULL, DoneTileAnimation +; 0xfc103 + +UnusedTilesetAnim_fc103: ; 0xfc103 + dw vTiles2 tile $14, WriteTileToBuffer + dw wTileAnimBuffer, ScrollTileRightLeft + dw vTiles2 tile $14, WriteTileFromBuffer + dw NULL, WaitTileAnimation + dw NULL, WaitTileAnimation + dw NULL, WaitTileAnimation + dw NULL, WaitTileAnimation + dw NULL, WaitTileAnimation + dw NULL, WaitTileAnimation + dw NULL, WaitTileAnimation + dw NULL, DoneTileAnimation +; 0xfc12f + +TilesetPortAnim: ; 0xfc12f + dw vTiles2 tile $14, AnimateWaterTile + dw NULL, WaitTileAnimation + dw NULL, WaitTileAnimation + dw NULL, WaitTileAnimation + dw NULL, WaitTileAnimation + dw NULL, TileAnimationPalette + dw NULL, WaitTileAnimation + dw NULL, WaitTileAnimation + dw NULL, WaitTileAnimation + dw NULL, WaitTileAnimation + dw NULL, StandingTileFrame8 + dw NULL, DoneTileAnimation +; 0xfc15f + +TilesetGym1Anim: ; 0xfc15f + dw NULL, LavaBubbleAnim2 + dw NULL, WaitTileAnimation + dw NULL, WaitTileAnimation + dw NULL, WaitTileAnimation + dw NULL, LavaBubbleAnim1 + dw NULL, WaitTileAnimation + dw NULL, StandingTileFrame8 + dw NULL, DoneTileAnimation +; 0xfc17f + +UnusedTilesetAnim_fc17f: ; 0xfc17f + dw vTiles2 tile $53, WriteTileToBuffer + dw wTileAnimBuffer, ScrollTileDown + dw wTileAnimBuffer, ScrollTileDown + dw vTiles2 tile $53, WriteTileFromBuffer + dw vTiles2 tile $03, WriteTileToBuffer + dw wTileAnimBuffer, ScrollTileRightLeft + dw vTiles2 tile $03, WriteTileFromBuffer + dw vTiles2 tile $53, WriteTileToBuffer + dw wTileAnimBuffer, ScrollTileDown + dw wTileAnimBuffer, ScrollTileDown + dw vTiles2 tile $53, WriteTileFromBuffer + dw NULL, DoneTileAnimation +; 0xfc1af + +UnusedTilesetAnim_fc1af: ; 0xfc1af + dw vTiles2 tile $54, WriteTileToBuffer + dw wTileAnimBuffer, ScrollTileDown + dw wTileAnimBuffer, ScrollTileDown + dw vTiles2 tile $54, WriteTileFromBuffer + dw NULL, WaitTileAnimation + dw vTiles2 tile $03, WriteTileToBuffer + dw wTileAnimBuffer, ScrollTileRightLeft + dw vTiles2 tile $03, WriteTileFromBuffer + dw NULL, WaitTileAnimation + dw vTiles2 tile $54, WriteTileToBuffer + dw wTileAnimBuffer, ScrollTileDown + dw wTileAnimBuffer, ScrollTileDown + dw vTiles2 tile $54, WriteTileFromBuffer + dw NULL, DoneTileAnimation +; 0xfc1e7 + +TilesetCaveAnim: ; 0xfc1e7 +TilesetWhirlIslandsAnim: ; 0xfc1e7 + dw vTiles2 tile $14, WriteTileToBuffer + dw NULL, FlickeringCaveEntrancePalette + dw wTileAnimBuffer, ScrollTileRightLeft + dw NULL, FlickeringCaveEntrancePalette + dw vTiles2 tile $14, WriteTileFromBuffer + dw NULL, FlickeringCaveEntrancePalette + dw NULL, TileAnimationPalette + dw NULL, FlickeringCaveEntrancePalette + dw vTiles2 tile $40, WriteTileToBuffer + dw NULL, FlickeringCaveEntrancePalette + dw wTileAnimBuffer, ScrollTileDown + dw NULL, FlickeringCaveEntrancePalette + dw wTileAnimBuffer, ScrollTileDown + dw NULL, FlickeringCaveEntrancePalette + dw wTileAnimBuffer, ScrollTileDown + dw NULL, FlickeringCaveEntrancePalette + dw vTiles2 tile $40, WriteTileFromBuffer + dw NULL, FlickeringCaveEntrancePalette + dw NULL, DoneTileAnimation +; 0xfc233 + +TilesetIcePathAnim: ; 0xfc233 + dw vTiles2 tile $35, WriteTileToBuffer + dw NULL, FlickeringCaveEntrancePalette + dw wTileAnimBuffer, ScrollTileRightLeft + dw NULL, FlickeringCaveEntrancePalette + dw vTiles2 tile $35, WriteTileFromBuffer + dw NULL, FlickeringCaveEntrancePalette + dw NULL, TileAnimationPalette + dw NULL, FlickeringCaveEntrancePalette + dw vTiles2 tile $31, WriteTileToBuffer + dw NULL, FlickeringCaveEntrancePalette + dw wTileAnimBuffer, ScrollTileDown + dw NULL, FlickeringCaveEntrancePalette + dw wTileAnimBuffer, ScrollTileDown + dw NULL, FlickeringCaveEntrancePalette + dw wTileAnimBuffer, ScrollTileDown + dw NULL, FlickeringCaveEntrancePalette + dw vTiles2 tile $31, WriteTileFromBuffer + dw NULL, FlickeringCaveEntrancePalette + dw NULL, DoneTileAnimation +; 0xfc27f + +TilesetSproutTowerAnim: ; 0xfc27f + dw SproutPillarTilePointer9, AnimateSproutPillarTile + dw SproutPillarTilePointer10, AnimateSproutPillarTile + dw SproutPillarTilePointer7, AnimateSproutPillarTile + dw SproutPillarTilePointer8, AnimateSproutPillarTile + dw SproutPillarTilePointer5, AnimateSproutPillarTile + dw SproutPillarTilePointer6, AnimateSproutPillarTile + dw SproutPillarTilePointer3, AnimateSproutPillarTile + dw SproutPillarTilePointer4, AnimateSproutPillarTile + dw SproutPillarTilePointer1, AnimateSproutPillarTile + dw SproutPillarTilePointer2, AnimateSproutPillarTile + dw NULL, StandingTileFrame + dw NULL, WaitTileAnimation + dw NULL, WaitTileAnimation + dw NULL, WaitTileAnimation + dw NULL, WaitTileAnimation + dw NULL, DoneTileAnimation +; 0xfc2bf + +UnusedTilesetAnim_fc2bf: ; 0xfc2bf + dw vTiles2 tile $4f, WriteTileToBuffer + dw wTileAnimBuffer, ScrollTileRightLeft + dw vTiles2 tile $4f, WriteTileFromBuffer + dw NULL, WaitTileAnimation + dw NULL, WaitTileAnimation + dw NULL, WaitTileAnimation + dw NULL, WaitTileAnimation + dw NULL, WaitTileAnimation + dw NULL, WaitTileAnimation + dw NULL, DoneTileAnimation +; 0xfc2e7 + +TilesetBattleTowerOutsideAnim: ; 0xfc2e7 +TilesetHouse1Anim: ; 0xfc2e7 +TilesetPlayersHouseAnim: ; 0xfc2e7 +TilesetPokecenterAnim: ; 0xfc2e7 +TilesetGateAnim: ; 0xfc2e7 +TilesetLabAnim: ; 0xfc2e7 +TilesetPowerPlantAnim: ; 0xfc2e7 +TilesetMartAnim: ; 0xfc2e7 +TilesetCeladonMansionAnim: ; 0xfc2e7 +TilesetGameCornerAnim: ; 0xfc2e7 +TilesetKurtsHouseAnim: ; 0xfc2e7 +TilesetTrainStationAnim: ; 0xfc2e7 +TilesetOlivineGymAnim: ; 0xfc2e7 +TilesetLighthouseAnim: ; 0xfc2e7 +TilesetPlayersHouse2FAnim: ; 0xfc2e7 +TilesetPokeComCenterAnim: ; 0xfc2e7 +TilesetBattleTowerAnim: ; 0xfc2e7 +TilesetRuinsOfAlphAnim: ; 0xfc2e7 +TilesetRadioTowerAnim: ; 0xfc2e7 +TilesetUndergroundAnim: ; 0xfc2e7 +TilesetBetaWordRoomAnim: ; 0xfc2e7 +TilesetHoOhWordRoomAnim: ; 0xfc2e7 +TilesetKabutoWordRoomAnim: ; 0xfc2e7 +TilesetOmanyteWordRoomAnim: ; 0xfc2e7 +TilesetAerodactylWordRoomAnim: ; 0xfc2e7 + dw NULL, WaitTileAnimation + dw NULL, WaitTileAnimation + dw NULL, WaitTileAnimation + dw NULL, WaitTileAnimation + dw NULL, DoneTileAnimation +; 0xfc2fb + +DoneTileAnimation: ; fc2fb +; Reset the animation command loop. + xor a + ld [hTileAnimFrame], a + +WaitTileAnimation: ; fc2fe +; Do nothing this frame. + ret +; fc2ff + +StandingTileFrame8: ; fc2ff + ld a, [TileAnimationTimer] + inc a + and %111 + ld [TileAnimationTimer], a + ret +; fc309 + + +ScrollTileRightLeft: ; fc309 +; Scroll right for 4 ticks, then left for 4 ticks. + ld a, [TileAnimationTimer] + inc a + and %111 + ld [TileAnimationTimer], a + and %100 + jr nz, ScrollTileLeft + jr ScrollTileRight +; fc318 + +ScrollTileUpDown: ; fc318 +; Scroll up for 4 ticks, then down for 4 ticks. + ld a, [TileAnimationTimer] + inc a + and %111 + ld [TileAnimationTimer], a + and %100 + jr nz, ScrollTileDown + jr ScrollTileUp +; fc327 + +ScrollTileLeft: ; fc327 + ld h, d + ld l, e + ld c, 4 +.loop +rept 4 + ld a, [hl] + rlca + ld [hli], a +endr + dec c + jr nz, .loop + ret +; fc33b + +ScrollTileRight: ; fc33b + ld h, d + ld l, e + ld c, 4 +.loop +rept 4 + ld a, [hl] + rrca + ld [hli], a +endr + dec c + jr nz, .loop + ret +; fc34f + +ScrollTileUp: ; fc34f + ld h, d + ld l, e + ld d, [hl] + inc hl + ld e, [hl] + ld bc, TILE_WIDTH * 2 - 2 + add hl, bc + ld a, TILE_WIDTH / 2 +.loop + ld c, [hl] + ld [hl], e + dec hl + ld b, [hl] + ld [hl], d + dec hl + ld e, [hl] + ld [hl], c + dec hl + ld d, [hl] + ld [hl], b + dec hl + dec a + jr nz, .loop + ret +; fc36a + +ScrollTileDown: ; fc36a + ld h, d + ld l, e + ld de, TILE_WIDTH * 2 - 2 + push hl + add hl, de + ld d, [hl] + inc hl + ld e, [hl] + pop hl + ld a, TILE_WIDTH / 2 +.loop + ld b, [hl] + ld [hl], d + inc hl + ld c, [hl] + ld [hl], e + inc hl + ld d, [hl] + ld [hl], b + inc hl + ld e, [hl] + ld [hl], c + inc hl + dec a + jr nz, .loop + ret +; fc387 + + +AnimateFountain: ; fc387 + ld hl, sp+0 + ld b, h + ld c, l + ld hl, .frames + ld a, [TileAnimationTimer] + and %111 + add a + add l + ld l, a + jr nc, .okay + inc h +.okay + ld a, [hli] + ld h, [hl] + ld l, a + ld sp, hl + ld l, e + ld h, d + jp WriteTile + +.frames + dw .frame1 + dw .frame2 + dw .frame3 + dw .frame4 + dw .frame3 + dw .frame4 + dw .frame5 + dw .frame1 + +.frame1 INCBIN "gfx/tilesets/fountain/1.2bpp" +.frame2 INCBIN "gfx/tilesets/fountain/2.2bpp" +.frame3 INCBIN "gfx/tilesets/fountain/3.2bpp" +.frame4 INCBIN "gfx/tilesets/fountain/4.2bpp" +.frame5 INCBIN "gfx/tilesets/fountain/5.2bpp" +; fc402 + + +AnimateWaterTile: ; fc402 +; Draw a water tile for the current frame in VRAM tile at de. + +; Save sp in bc (see WriteTile). + ld hl, sp+0 + ld b, h + ld c, l + + ld a, [TileAnimationTimer] + +; 4 tile graphics, updated every other frame. + and %110 + +; 2 x 8 = 16 bytes per tile + add a + add a + add a + + add LOW(WaterTileFrames) + ld l, a + ld a, 0 + adc HIGH(WaterTileFrames) + ld h, a + +; Stack now points to the start of the tile for this frame. + ld sp, hl + + ld l, e + ld h, d + + jp WriteTile +; fc41c + +WaterTileFrames: ; fc41c + INCBIN "gfx/tilesets/water/water.2bpp" +; fc45c + + +ForestTreeLeftAnimation: ; fc45c + ld hl, sp+0 + ld b, h + ld c, l + +; Only during the Celebi event. + ld a, [wCelebiEvent] + bit 2, a + jr nz, .asm_fc46c + ld hl, ForestTreeLeftFrames + jr .asm_fc47d + +.asm_fc46c + ld a, [TileAnimationTimer] + call GetForestTreeFrame + add a + add a + add a + add LOW(ForestTreeLeftFrames) + ld l, a + ld a, 0 + adc HIGH(ForestTreeLeftFrames) + ld h, a + +.asm_fc47d + ld sp, hl + ld hl, vTiles2 tile $0c + jp WriteTile +; fc484 + + +ForestTreeLeftFrames: ; fc484 + INCBIN "gfx/tilesets/forest-tree/1.2bpp" + INCBIN "gfx/tilesets/forest-tree/2.2bpp" +; fc4a4 + +ForestTreeRightFrames: ; fc4a4 + INCBIN "gfx/tilesets/forest-tree/3.2bpp" + INCBIN "gfx/tilesets/forest-tree/4.2bpp" +; fc4c4 + + +ForestTreeRightAnimation: ; fc4c4 + ld hl, sp+0 + ld b, h + ld c, l + +; Only during the Celebi event. + ld a, [wCelebiEvent] + bit 2, a + jr nz, .asm_fc4d4 + ld hl, ForestTreeRightFrames + jr .asm_fc4eb + +.asm_fc4d4 + ld a, [TileAnimationTimer] + call GetForestTreeFrame + add a + add a + add a + add LOW(ForestTreeLeftFrames) + ld l, a + ld a, 0 + adc HIGH(ForestTreeLeftFrames) + ld h, a + push bc + ld bc, ForestTreeRightFrames - ForestTreeLeftFrames + add hl, bc + pop bc + +.asm_fc4eb + ld sp, hl + ld hl, vTiles2 tile $0f + jp WriteTile +; fc4f2 + + +ForestTreeLeftAnimation2: ; fc4f2 + ld hl, sp+0 + ld b, h + ld c, l + +; Only during the Celebi event. + ld a, [wCelebiEvent] + bit 2, a + jr nz, .asm_fc502 + ld hl, ForestTreeLeftFrames + jr .asm_fc515 + +.asm_fc502 + ld a, [TileAnimationTimer] + call GetForestTreeFrame + xor 2 + add a + add a + add a + add LOW(ForestTreeLeftFrames) + ld l, a + ld a, 0 + adc HIGH(ForestTreeLeftFrames) + ld h, a + +.asm_fc515 + ld sp, hl + ld hl, vTiles2 tile $0c + jp WriteTile +; fc51c + + +ForestTreeRightAnimation2: ; fc51c + ld hl, sp+0 + ld b, h + ld c, l + +; Only during the Celebi event. + ld a, [wCelebiEvent] + bit 2, a + jr nz, .asm_fc52c + ld hl, ForestTreeRightFrames + jr .asm_fc545 + +.asm_fc52c + ld a, [TileAnimationTimer] + call GetForestTreeFrame + xor 2 + add a + add a + add a + add LOW(ForestTreeLeftFrames) + ld l, a + ld a, 0 + adc HIGH(ForestTreeLeftFrames) + ld h, a + push bc + ld bc, ForestTreeRightFrames - ForestTreeLeftFrames + add hl, bc + pop bc + +.asm_fc545 + ld sp, hl + ld hl, vTiles2 tile $0f + jp WriteTile +; fc54c + + +GetForestTreeFrame: ; fc54c +; Return 0 if a is even, or 2 if odd. + and a + jr z, .even + cp 1 + jr z, .odd + cp 2 + jr z, .even + cp 3 + jr z, .odd + cp 4 + jr z, .even + cp 5 + jr z, .odd + cp 6 + jr z, .even +.odd + ld a, 2 + scf + ret +.even + xor a + ret +; fc56d + + +AnimateFlowerTile: ; fc56d +; No parameters. + +; Save sp in bc (see WriteTile). + ld hl, sp+0 + ld b, h + ld c, l + +; Alternate tile graphic every other frame + ld a, [TileAnimationTimer] + and %10 + ld e, a + +; CGB has different color mappings for flowers. + ld a, [hCGB] + and 1 + + add e + swap a + ld e, a + ld d, 0 + ld hl, FlowerTileFrames + add hl, de + ld sp, hl + + ld hl, vTiles2 tile $03 + + jp WriteTile +; fc58c + +FlowerTileFrames: ; fc58c + INCBIN "gfx/tilesets/flower/dmg_1.2bpp" + INCBIN "gfx/tilesets/flower/cgb_1.2bpp" + INCBIN "gfx/tilesets/flower/dmg_2.2bpp" + INCBIN "gfx/tilesets/flower/cgb_2.2bpp" +; fc5cc + + +LavaBubbleAnim1: ; fc5cc +; Splash in the bottom-right corner of the fountain. + ld hl, sp+0 + ld b, h + ld c, l + ld a, [TileAnimationTimer] + and %110 + srl a + inc a + inc a + and %011 + swap a + ld e, a + ld d, 0 + ld hl, LavaBubbleFrames + add hl, de + ld sp, hl + ld hl, vTiles2 tile $5b + jp WriteTile +; fc5eb + + +LavaBubbleAnim2: ; fc5eb +; Splash in the top-left corner of the fountain. + ld hl, sp+0 + ld b, h + ld c, l + ld a, [TileAnimationTimer] + and %110 + add a + add a + add a + ld e, a + ld d, 0 + ld hl, LavaBubbleFrames + add hl, de + ld sp, hl + ld hl, vTiles2 tile $38 + jp WriteTile +; fc605 + + +LavaBubbleFrames: ; fc605 + INCBIN "gfx/tilesets/lava/1.2bpp" + INCBIN "gfx/tilesets/lava/2.2bpp" + INCBIN "gfx/tilesets/lava/3.2bpp" + INCBIN "gfx/tilesets/lava/4.2bpp" +; fc645 + + +AnimateSproutPillarTile: ; fc645 +; Read from struct at de: +; Destination (VRAM) +; Address of the first tile in the frame array + + ld hl, sp+0 + ld b, h + ld c, l + + ld a, [TileAnimationTimer] + and %111 + +; Get frame index a + ld hl, .frames + add l + ld l, a + ld a, 0 + adc h + ld h, a + ld a, [hl] + +; Destination + ld l, e + ld h, d + ld e, [hl] + inc hl + ld d, [hl] + inc hl + +; Add the frame index to the starting address + add [hl] + inc hl + ld h, [hl] + ld l, a + ld a, 0 + adc h + ld h, a + + ld sp, hl + ld l, e + ld h, d + jr WriteTile + +.frames + db $00, $10, $20, $30, $40, $30, $20, $10 +; fc673 + + +StandingTileFrame: ; fc673 + ld hl, TileAnimationTimer + inc [hl] + ret +; fc678 + + +AnimateWhirlpoolTile: ; fc678 +; Update whirlpool tile using struct at de. + +; Struct: +; VRAM address +; Address of the first tile + +; Only does one of 4 tiles at a time. + +; Save sp in bc (see WriteTile). + ld hl, sp+0 + ld b, h + ld c, l + +; de = VRAM address + ld l, e + ld h, d + ld e, [hl] + inc hl + ld d, [hl] + inc hl +; Tile address is now at hl. + +; Get the tile for this frame. + ld a, [TileAnimationTimer] + and %11 ; 4 frames x2 + swap a ; * 16 bytes per tile + + add [hl] + inc hl + ld h, [hl] + ld l, a + ld a, 0 + adc h + ld h, a + +; Stack now points to the desired frame. + ld sp, hl + + ld l, e + ld h, d + + jr WriteTile +; fc696 + + +WriteTileFromBuffer: ; fc696 +; Write tiledata at wTileAnimBuffer to de. +; wTileAnimBuffer is loaded to sp for WriteTile. + + ld hl, sp+0 + ld b, h + ld c, l + + ld hl, wTileAnimBuffer + ld sp, hl + + ld h, d + ld l, e + jr WriteTile +; fc6a2 + + +WriteTileToBuffer: ; fc6a2 +; Write tiledata de to wTileAnimBuffer. +; de is loaded to sp for WriteTile. + + ld hl, sp+0 + ld b, h + ld c, l + + ld h, d + ld l, e + ld sp, hl + + ld hl, wTileAnimBuffer + + ; fallthrough + +WriteTile: ; fc6ac +; Write one 8x8 tile ($10 bytes) from sp to hl. + +; Warning: sp is saved in bc so we can abuse pop. +; sp is restored to address bc. Save sp in bc before calling. + + pop de + ld [hl], e + inc hl + ld [hl], d + +rept 7 + pop de + inc hl + ld [hl], e + inc hl + ld [hl], d +endr + +; restore sp + ld h, b + ld l, c + ld sp, hl + ret +; fc6d7 + + +TileAnimationPalette: ; fc6d7 +; Transition between color values 0-2 for color 0 in palette 3. + +; No palette changes on DMG. + ld a, [hCGB] + and a + ret z + +; We don't want to mess with non-standard palettes. + ld a, [rBGP] ; BGP + cp %11100100 + ret nz + +; Only update on even frames. + ld a, [TileAnimationTimer] + ld l, a + and 1 ; odd + ret nz + +; Ready for BGPD input... + + ld a, (1 << rBGPI_AUTO_INCREMENT) palette PAL_BG_WATER + ld [rBGPI], a + + ld a, [rSVBK] + push af + ld a, BANK(wBGPals1) + ld [rSVBK], a + +; Update color 0 in order 0 1 2 1 + ld a, l + and %110 ; frames 0 2 4 6 + jr z, .color0 + cp %100 ; frame 4 + jr z, .color2 + +.color1 + ld hl, wBGPals1 palette PAL_BG_WATER + 2 + ld a, [hli] + ld [rBGPD], a + ld a, [hli] + ld [rBGPD], a + jr .end + +.color0 + ld hl, wBGPals1 palette PAL_BG_WATER + ld a, [hli] + ld [rBGPD], a + ld a, [hli] + ld [rBGPD], a + jr .end + +.color2 + ld hl, wBGPals1 palette PAL_BG_WATER + 4 + ld a, [hli] + ld [rBGPD], a + ld a, [hli] + ld [rBGPD], a + +.end + pop af + ld [rSVBK], a + ret +; fc71e + + +FlickeringCaveEntrancePalette: ; fc71e +; No palette changes on DMG. + ld a, [hCGB] + and a + ret z +; We don't want to mess with non-standard palettes. + ld a, [rBGP] + cp %11100100 + ret nz +; We only want to be here if we're in a dark cave. + ld a, [wTimeOfDayPalset] + cp %11111111 ; 3,3,3,3 + ret nz + + ld a, [rSVBK] + push af + ld a, BANK(wBGPals1) + ld [rSVBK], a +; Ready for BGPD input... + ld a, (1 << rBGPI_AUTO_INCREMENT) palette PAL_BG_YELLOW + ld [rBGPI], a + ld a, [hVBlankCounter] + and %10 + jr nz, .bit1set + ld hl, wBGPals1 palette PAL_BG_YELLOW + jr .okay + +.bit1set + ld hl, wBGPals1 palette PAL_BG_YELLOW + 2 + +.okay + ld a, [hli] + ld [rBGPD], a + ld a, [hli] + ld [rBGPD], a + + pop af + ld [rSVBK], a + ret +; fc750 + + +SproutPillarTilePointer1: dw vTiles2 tile $2d, SproutPillarTile1 +SproutPillarTilePointer2: dw vTiles2 tile $2f, SproutPillarTile2 +SproutPillarTilePointer3: dw vTiles2 tile $3d, SproutPillarTile3 +SproutPillarTilePointer4: dw vTiles2 tile $3f, SproutPillarTile4 +SproutPillarTilePointer5: dw vTiles2 tile $3c, SproutPillarTile5 +SproutPillarTilePointer6: dw vTiles2 tile $2c, SproutPillarTile6 +SproutPillarTilePointer7: dw vTiles2 tile $4d, SproutPillarTile7 +SproutPillarTilePointer8: dw vTiles2 tile $4f, SproutPillarTile8 +SproutPillarTilePointer9: dw vTiles2 tile $5d, SproutPillarTile9 +SproutPillarTilePointer10: dw vTiles2 tile $5f, SproutPillarTile10 + +SproutPillarTile1: INCBIN "gfx/tilesets/sprout-pillar/1.2bpp" +SproutPillarTile2: INCBIN "gfx/tilesets/sprout-pillar/2.2bpp" +SproutPillarTile3: INCBIN "gfx/tilesets/sprout-pillar/3.2bpp" +SproutPillarTile4: INCBIN "gfx/tilesets/sprout-pillar/4.2bpp" +SproutPillarTile5: INCBIN "gfx/tilesets/sprout-pillar/5.2bpp" +SproutPillarTile6: INCBIN "gfx/tilesets/sprout-pillar/6.2bpp" +SproutPillarTile7: INCBIN "gfx/tilesets/sprout-pillar/7.2bpp" +SproutPillarTile8: INCBIN "gfx/tilesets/sprout-pillar/8.2bpp" +SproutPillarTile9: INCBIN "gfx/tilesets/sprout-pillar/9.2bpp" +SproutPillarTile10: INCBIN "gfx/tilesets/sprout-pillar/10.2bpp" +; fca98 + + +WhirlpoolFrames1: dw vTiles2 tile $32, WhirlpoolTiles1 +WhirlpoolFrames2: dw vTiles2 tile $33, WhirlpoolTiles2 +WhirlpoolFrames3: dw vTiles2 tile $42, WhirlpoolTiles3 +WhirlpoolFrames4: dw vTiles2 tile $43, WhirlpoolTiles4 +; fcaa8 + +WhirlpoolTiles1: INCBIN "gfx/tilesets/whirlpool/1.2bpp" +WhirlpoolTiles2: INCBIN "gfx/tilesets/whirlpool/2.2bpp" +WhirlpoolTiles3: INCBIN "gfx/tilesets/whirlpool/3.2bpp" +WhirlpoolTiles4: INCBIN "gfx/tilesets/whirlpool/4.2bpp" +; fcba8 diff --git a/engine/tileset_palettes.asm b/engine/tileset_palettes.asm new file mode 100644 index 000000000..9aba2f20e --- /dev/null +++ b/engine/tileset_palettes.asm @@ -0,0 +1,151 @@ +LoadSpecialMapPalette: ; 494ac + ld a, [wTileset] + cp TILESET_POKECOM_CENTER + jr z, .pokecom_2f + cp TILESET_BATTLE_TOWER + jr z, .battle_tower + cp TILESET_ICE_PATH + jr z, .ice_path + cp TILESET_HOUSE_1 + jr z, .house + cp TILESET_RADIO_TOWER + jr z, .radio_tower + cp TILESET_CELADON_MANSION + jr z, .mansion_mobile + jr .do_nothing + +.pokecom_2f + call LoadPokeComPalette + scf + ret + +.battle_tower + call LoadBattleTowerPalette + scf + ret + +.ice_path + ld a, [wEnvironment] + and $7 + cp INDOOR ; Hall of Fame + jr z, .do_nothing + call LoadIcePathPalette + scf + ret + +.house + call LoadHousePalette + scf + ret + +.radio_tower + call LoadRadioTowerPalette + scf + ret + +.mansion_mobile + call LoadMansionPalette + scf + ret + +.do_nothing + and a + ret +; 494f2 + +LoadPokeComPalette: ; 494f2 + ld a, BANK(wBGPals1) + ld de, wBGPals1 + ld hl, PokeComPalette + ld bc, 8 palettes + call FarCopyWRAM + ret +; 49501 + +PokeComPalette: ; 49501 +INCLUDE "gfx/tilesets/pokecom_center.pal" +; 49541 + +LoadBattleTowerPalette: ; 49541 + ld a, BANK(wBGPals1) + ld de, wBGPals1 + ld hl, BattleTowerPalette + ld bc, 8 palettes + call FarCopyWRAM + ret +; 49550 + +BattleTowerPalette: ; 49550 +INCLUDE "gfx/tilesets/battle_tower.pal" +; 49590 + +LoadIcePathPalette: ; 49590 + ld a, BANK(wBGPals1) + ld de, wBGPals1 + ld hl, IcePathPalette + ld bc, 8 palettes + call FarCopyWRAM + ret +; 4959f + +IcePathPalette: ; 4959f +INCLUDE "gfx/tilesets/ice_path.pal" +; 495df + +LoadHousePalette: ; 495df + ld a, BANK(wBGPals1) + ld de, wBGPals1 + ld hl, HousePalette + ld bc, 8 palettes + call FarCopyWRAM + ret +; 495ee + +HousePalette: ; 495ee +INCLUDE "gfx/tilesets/house_1.pal" +; 4962e + +LoadRadioTowerPalette: ; 4962e + ld a, BANK(wBGPals1) + ld de, wBGPals1 + ld hl, RadioTowerPalette + ld bc, 8 palettes + call FarCopyWRAM + ret +; 4963d + +RadioTowerPalette: ; 4963d +INCLUDE "gfx/tilesets/radio_tower.pal" +; 4967d + +MansionPalette1: ; 4967d +INCLUDE "gfx/tilesets/celadon_mansion_1.pal" +; 496c5 + +LoadMansionPalette: ; 496c5 + ld a, BANK(wBGPals1) + ld de, wBGPals1 + ld hl, MansionPalette1 + ld bc, 8 palettes + call FarCopyWRAM + ld a, BANK(wBGPals1) + ld de, wBGPals1 palette PAL_BG_YELLOW + ld hl, MansionPalette2 + ld bc, 1 palettes + call FarCopyWRAM + ld a, BANK(wBGPals1) + ld de, wBGPals1 palette PAL_BG_WATER + ld hl, MansionPalette1 + 6 palettes + ld bc, 1 palettes + call FarCopyWRAM + ld a, BANK(wBGPals1) + ld de, wBGPals1 palette PAL_BG_ROOF + ld hl, MansionPalette1 + 8 palettes + ld bc, 1 palettes + call FarCopyWRAM + ret +; 496fe + +MansionPalette2: ; 496fe +INCLUDE "gfx/tilesets/celadon_mansion_2.pal" +; 49706 diff --git a/engine/time.asm b/engine/time.asm index 799a24f49..29c811810 100755 --- a/engine/time.asm +++ b/engine/time.asm @@ -133,16 +133,16 @@ endr Special_SampleKenjiBreakCountdown: ; 11485 ; Generate a random number between 3 and 6 call Random - and 3 + and %11 add 3 ld [wKenjiBreakTimer], a ret ; 11490 StartBugContestTimer: ; 11490 - ld a, 20 + ld a, BUG_CONTEST_MINUTES ld [wBugContestMinsRemaining], a - ld a, 0 + ld a, BUG_CONTEST_SECONDS ld [wBugContestSecsRemaining], a call UpdateTime ld hl, wBugContestStartTime @@ -225,13 +225,13 @@ CheckUnusedTwoDayTimer: ; 1150c ret ; 1151c -; XXX +; unused ld hl, wDailyFlags set 2, [hl] ret ; 11522 -; XXX +; unused and a ld hl, wDailyFlags bit 2, [hl] @@ -252,7 +252,7 @@ RestartLuckyNumberCountdown: ; 1152b ld a, FRIDAY sub c jr z, .friday_saturday - jr nc, .earlier ; should've done "ret nc" + jr nc, .earlier ; could have done "ret nc" .friday_saturday add 7 diff --git a/engine/time_capsule.asm b/engine/time_capsule.asm index 577b2dce8..96f61833b 100755 --- a/engine/time_capsule.asm +++ b/engine/time_capsule.asm @@ -144,4 +144,4 @@ PlaceTradePartnerNamesAndParty: ; fb60d jr .loop ; fb656 -INCLUDE "data/time_capsule/special_stats.asm" +INCLUDE "data/pokemon/rby_base_special.asm" diff --git a/engine/time_capsule_2.asm b/engine/time_capsule_2.asm index 5da72e7c8..c114e6952 100644 --- a/engine/time_capsule_2.asm +++ b/engine/time_capsule_2.asm @@ -18,7 +18,7 @@ ConvertMon_2to1: ; fb8f1 ret ; fb908 -ConvertMon_1to2: ; fb908 +Predef_ConvertMon_1to2: ; fb908 ; Takes the Gen-1 Pokemon number stored in wd265 and returns the corresponding value from Pokered_MonIndices in wd265. push bc push hl @@ -36,4 +36,4 @@ ConvertMon_1to2: ; fb908 ; fb91c -INCLUDE "data/time_capsule/mon_order.asm" +INCLUDE "data/pokemon/rby_order.asm" diff --git a/engine/timeofdaypals.asm b/engine/timeofdaypals.asm index 0b1ea71a2..2f24dcb95 100644 --- a/engine/timeofdaypals.asm +++ b/engine/timeofdaypals.asm @@ -1,5 +1,5 @@ -Predef35: ; 8c000 -Predef36: +DummyPredef35: ; 8c000 +DummyPredef36: ret UpdateTimeOfDayPal:: ; 8c001 @@ -47,8 +47,8 @@ _TimeOfDayPals:: ; 8c011 ; save wram bank ld a, [rSVBK] ld b, a -; wram bank 5 - ld a, $5 + + ld a, BANK(wBGPals1) ld [rSVBK], a ; push palette @@ -78,8 +78,8 @@ _TimeOfDayPals:: ; 8c011 ; save wram bank ld a, [rSVBK] ld d, a -; wram bank 5 - ld a, 5 + + ld a, BANK(wOBPals1) ld [rSVBK], a ; pop palette @@ -119,7 +119,7 @@ _UpdateTimePals:: ; 8c070 ret ; 8c079 -FadeInPalettes:: ; 8c079 +Special_FadeInPalettes:: ; 8c079 ld c, $12 call GetTimePalFade ld b, $4 @@ -127,7 +127,7 @@ FadeInPalettes:: ; 8c079 ret ; 8c084 -FadeOutPalettes:: ; 8c084 +Special_FadeOutPalettes:: ; 8c084 call FillWhiteBGColor ld c, $9 call GetTimePalFade @@ -173,7 +173,7 @@ Special_FadeBlackQuickly: ; 8c0b6 FillWhiteBGColor: ; 8c0c1 ld a, [rSVBK] push af - ld a, $5 + ld a, BANK(wBGPals1) ld [rSVBK], a ld hl, wBGPals1 diff --git a/engine/timeset.asm b/engine/timeset.asm index f05e31ab5..b97103ed1 100755 --- a/engine/timeset.asm +++ b/engine/timeset.asm @@ -1,3 +1,6 @@ +TIMESET_UP_ARROW EQUS "\"♂\"" ; $ef +TIMESET_DOWN_ARROW EQUS "\"♀\"" ; $f5 + InitClock: ; 90672 (24:4672) ; Ask the player to set the time. ld a, [hInMenu] @@ -410,11 +413,11 @@ Special_SetDayOfWeek: ; 90913 ld a, $1 ld [hInMenu], a ld de, TimeSetUpArrowGFX - ld hl, vTiles1 tile $6f + ld hl, vTiles0 tile TIMESET_UP_ARROW lb bc, BANK(TimeSetUpArrowGFX), 1 call Request1bpp ld de, TimeSetDownArrowGFX - ld hl, vTiles1 tile $75 + ld hl, vTiles0 tile TIMESET_DOWN_ARROW lb bc, BANK(TimeSetDownArrowGFX), 1 call Request1bpp xor a @@ -431,9 +434,9 @@ Special_SetDayOfWeek: ; 90913 ld c, 9 call TextBox hlcoord 14, 3 - ld [hl], "♂" ; gets overwritten with special up arrow + ld [hl], TIMESET_UP_ARROW hlcoord 14, 6 - ld [hl], "♀" ; gets overwritten with special down arrow + ld [hl], TIMESET_DOWN_ARROW hlcoord 10, 5 call .PlaceWeekdayString call ApplyTilemap diff --git a/engine/title.asm b/engine/title.asm index 2380cfedf..55ba145bf 100644 --- a/engine/title.asm +++ b/engine/title.asm @@ -139,7 +139,7 @@ _TitleScreen: ; 10ed67 ld a, [rSVBK] push af ; WRAM bank 5 - ld a, 5 + ld a, BANK(wBGPals1) ld [rSVBK], a ; Update palette colors @@ -162,13 +162,13 @@ _TitleScreen: ; 10ed67 ld a, [rSVBK] push af - ld a, 5 ; BANK(LYOverrides) + ld a, BANK(LYOverrides) ld [rSVBK], a ; Make alternating lines come in from opposite sides -; ( This part is actually totally pointless, you can't -; see anything until these values are overwritten! ) +; (This part is actually totally pointless, you can't +; see anything until these values are overwritten!) ld b, 80 / 2 ; alternate for 80 lines ld hl, LYOverrides @@ -237,11 +237,11 @@ SuicuneFrameIterator: ; 10eea7 inc [hl] ; Only do this once every eight frames - and (1 << 3) - 1 + and %111 ret nz ld a, c - and 3 << 3 + and %11000 sla a swap a ld e, a @@ -323,7 +323,7 @@ DrawTitleGraphic: ; 10eeef ; 10ef06 InitializeBackground: ; 10ef06 - ld hl, Sprites + ld hl, Sprite01 ld d, -$22 ld e, $0 ld c, 5 @@ -344,17 +344,17 @@ InitializeBackground: ; 10ef06 ld b, $40 .loop2 ld a, d - ld [hli], a + ld [hli], a ; y ld a, b - ld [hli], a + ld [hli], a ; x add $8 ld b, a ld a, e - ld [hli], a + ld [hli], a ; tile id inc e inc e - ld a, $80 - ld [hli], a + ld a, 0 | PRIORITY + ld [hli], a ; attributes dec c jr nz, .loop2 ret @@ -366,9 +366,9 @@ AnimateTitleCrystal: ; 10ef32 ; Stop at y=6 ; y is really from the bottom of the sprite, which is two tiles high - ld hl, Sprites + ld hl, Sprite01YCoord ld a, [hl] - cp 6 + $10 + cp 6 + 2 * TILE_WIDTH ret z ; Move all 30 parts of the crystal down by 2 @@ -376,10 +376,10 @@ AnimateTitleCrystal: ; 10ef32 .loop ld a, [hl] add 2 - ld [hli], a - inc hl - inc hl + ld [hli], a ; y +rept SPRITEOAMSTRUCT_LENGTH +- 1 inc hl +endr dec c jr nz, .loop @@ -399,4 +399,4 @@ INCBIN "gfx/title/crystal.2bpp.lz" ; 10fede TitleScreenPalettes: -INCLUDE "data/palettes/title.pal" +INCLUDE "gfx/title/title.pal" diff --git a/engine/tmhm.asm b/engine/tmhm.asm index 6a9c76f00..11f692cb6 100755 --- a/engine/tmhm.asm +++ b/engine/tmhm.asm @@ -1,4 +1,4 @@ -CanLearnTMHMMove: ; 11639 +Predef_CanLearnTMHMMove: ; 11639 ld a, [CurPartySpecies] ld [CurSpecies], a call GetBaseData @@ -23,7 +23,7 @@ CanLearnTMHMMove: ; 11639 ld b, CHECK_FLAG push de ld d, 0 - predef FlagPredef + predef Predef_SmallFarFlagAction pop de ret @@ -33,7 +33,7 @@ CanLearnTMHMMove: ; 11639 ret ; 1166a -GetTMHMMove: ; 1166a +Predef_GetTMHMMove: ; 1166a ld a, [wd265] dec a ld hl, TMHMMoves diff --git a/engine/tmhm2.asm b/engine/tmhm2.asm index c111fa7f9..ddc27da07 100755 --- a/engine/tmhm2.asm +++ b/engine/tmhm2.asm @@ -38,7 +38,7 @@ ConvertCurItemIntoCurTMHM: ; 2c7a7 (b:47a7) GetTMHMItemMove: ; 2c7b6 (b:47b6) call ConvertCurItemIntoCurTMHM - predef GetTMHMMove + predef Predef_GetTMHMMove ret AskTeachTMHM: ; 2c7bf (b:47bf) @@ -118,7 +118,7 @@ ChooseMonToLearnTMHM_NoRefresh: ; 2c80a ; 2c867 TeachTMHM: ; 2c867 - predef CanLearnTMHMMove + predef Predef_CanLearnTMHMMove push bc ld a, [CurPartyMon] @@ -141,12 +141,12 @@ TeachTMHM: ; 2c867 callfar KnowsMove jr c, .nope - predef LearnMove + predef Predef_LearnMove ld a, b and a jr z, .nope - farcall TrainerRankings_TMsHMsTaught + farcall StubbedTrainerRankings_TMsHMsTaught ld a, [CurItem] call IsHM ret c @@ -258,11 +258,11 @@ TMHM_ShowTMMoveDescription: ; 2c946 (b:4946) cp NUM_TMS + NUM_HMS + 1 jr nc, TMHM_JoypadLoop ld [wd265], a - predef GetTMHMMove + predef Predef_GetTMHMMove ld a, [wd265] ld [CurSpecies], a hlcoord 1, 14 - call PrintMoveDesc + call Predef_PrintMoveDesc jp TMHM_JoypadLoop TMHM_ChooseTMorHM: ; 2c974 (b:4974) @@ -386,7 +386,7 @@ TMHM_DisplayPocketItems: ; 2c9e2 (b:49e2) pop af ld [wd265], a .okay - predef GetTMHMMove + predef Predef_GetTMHMMove ld a, [wd265] ld [wPutativeTMHMMove], a call GetMoveName @@ -447,12 +447,11 @@ TMHMPocket_GetCurrentLineCoord: ; 2ca86 (b:4a86) ret ; 2ca95 (b:4a95) -Function2ca95: ; 2ca95 -; unreferenced +Unreferenced_Function2ca95: ; 2ca95 pop hl ld bc, 3 add hl, bc - predef GetTMHMMove + predef Predef_GetTMHMMove ld a, [wd265] ld [wPutativeTMHMMove], a call GetMoveName @@ -499,8 +498,7 @@ TMHM_PlaySFX_ReadText2: ; 2cad6 (b:4ad6) ret ; 2cadf (b:4adf) -Function2cadf: ; 2cadf -; unreferenced +Unreferenced_Function2cadf: ; 2cadf call ConvertCurItemIntoCurTMHM call .CheckHaveRoomForTMHM ld hl, .NoRoomText @@ -574,7 +572,7 @@ CountTMsHMs: ; 2cb2a (b:4b2a) ld [wd265], a ret -PrintMoveDesc: ; 2cb3e +Predef_PrintMoveDesc: ; 2cb3e push hl ld hl, MoveDescriptions ld a, [CurSpecies] diff --git a/engine/trade_animation.asm b/engine/trade_animation.asm index d5b97d563..2ded0807a 100755 --- a/engine/trade_animation.asm +++ b/engine/trade_animation.asm @@ -1,4 +1,15 @@ -TradeAnimation: ; 28f24 +TRADEANIM_RIGHT_ARROW EQU $ed +TRADEANIM_LEFT_ARROW EQU $ee + +; TradeAnim_TubeAnimJumptable.Jumptable indexes + const_def + const TRADEANIMSTATE_0 ; 0 + const TRADEANIMSTATE_1 ; 1 + const TRADEANIMSTATE_2 ; 2 + const TRADEANIMSTATE_3 ; 3 +TRADEANIMJUMPTABLE_LENGTH EQU const_value + +Predef_TradeAnimation: ; 28f24 xor a ld [wcf66], a ld hl, wPlayerTrademonSenderName @@ -49,7 +60,7 @@ TradeAnimation: ; 28f24 tradeanim_scroll_out_right tradeanim_end -TradeAnimationPlayer2: ; 28f63 +Predef_TradeAnimationPlayer2: ; 28f63 xor a ld [wcf66], a ld hl, wOTTrademonSenderName @@ -165,13 +176,13 @@ RunTradeAnimScript: ; 28fa1 ld de, vTiles2 tile $31 call Decompress ld hl, TradeArrowGFX - ld de, vTiles1 tile $6d - ld bc, $10 + ld de, vTiles0 tile TRADEANIM_RIGHT_ARROW + ld bc, 1 tiles ld a, BANK(TradeArrowGFX) call FarCopyBytes - ld hl, TradeArrowGFX + $10 - ld de, vTiles1 tile $6e - ld bc, $10 + ld hl, TradeArrowGFX + 1 tiles + ld de, vTiles0 tile TRADEANIM_LEFT_ARROW + ld bc, 1 tiles ld a, BANK(TradeArrowGFX) call FarCopyBytes xor a @@ -317,7 +328,7 @@ TradeAnim_End: ; 29123 ; 29129 TradeAnim_TubeToOT1: ; 29129 - ld a, $ed ; >>>>>>>> + ld a, TRADEANIM_RIGHT_ARROW call TradeAnim_PlaceTrademonStatsOnTubeAnim ld a, [wLinkTradeSendmonSpecies] ld [wd265], a @@ -327,11 +338,11 @@ TradeAnim_TubeToOT1: ; 29129 jr TradeAnim_InitTubeAnim TradeAnim_TubeToPlayer1: ; 2913c - ld a, $ee ; <<<<<<<< + ld a, TRADEANIM_LEFT_ARROW call TradeAnim_PlaceTrademonStatsOnTubeAnim ld a, [wLinkTradeGetmonSpecies] ld [wd265], a - ld a, $2 + ld a, TRADEANIMSTATE_2 depixel 9, 18, 4, 4 ld b, $4 TradeAnim_InitTubeAnim: ; 2914e @@ -387,8 +398,8 @@ TradeAnim_InitTubeAnim: ; 2914e call DmgToCgbObjPal0 call TradeAnim_IncrementJumptableIndex - ld a, $5c - ld [wcf64], a + ld a, 92 + ld [wFrameCounter], a ret ; 291af @@ -400,7 +411,7 @@ TradeAnim_TubeToOT2: ; 291af ld [hSCX], a cp $50 ret nz - ld a, $1 + ld a, TRADEANIMSTATE_1 call TradeAnim_TubeAnimJumptable call TradeAnim_IncrementJumptableIndex ret @@ -414,7 +425,7 @@ TradeAnim_TubeToOT3: ; 291c4 ld [hSCX], a cp $a0 ret nz - ld a, $2 + ld a, TRADEANIMSTATE_2 call TradeAnim_TubeAnimJumptable call TradeAnim_IncrementJumptableIndex ret @@ -440,7 +451,7 @@ TradeAnim_TubeToPlayer3: ; 291e8 ld [hSCX], a cp $b0 ret nz - ld a, $1 + ld a, TRADEANIMSTATE_1 call TradeAnim_TubeAnimJumptable call TradeAnim_IncrementJumptableIndex ret @@ -454,7 +465,7 @@ TradeAnim_TubeToPlayer4: ; 291fd ld [hSCX], a cp $60 ret nz - xor a + xor a ; TRADEANIMSTATE_0 call TradeAnim_TubeAnimJumptable call TradeAnim_IncrementJumptableIndex ret @@ -475,8 +486,8 @@ TradeAnim_TubeToPlayer5: ; 29211 TradeAnim_TubeToOT6: TradeAnim_TubeToPlayer6: ; 29220 - ld a, $80 - ld [wcf64], a + ld a, 128 + ld [wFrameCounter], a call TradeAnim_IncrementJumptableIndex ret @@ -511,7 +522,7 @@ TradeAnim_TubeToOT7: TradeAnim_TubeToPlayer2: TradeAnim_TubeToPlayer7: ; 2925d call TradeAnim_FlashBGPals - ld hl, wcf64 + ld hl, wFrameCounter ld a, [hl] and a jr z, .done @@ -541,7 +552,7 @@ TradeAnim_GetTrademonSFX: ; 29277 ; 29281 TradeAnim_TubeAnimJumptable: ; 29281 - and 3 + maskbits TRADEANIMJUMPTABLE_LENGTH +- 1 ld e, a ld d, 0 ld hl, .Jumptable @@ -554,6 +565,7 @@ TradeAnim_TubeAnimJumptable: ; 29281 ; 2928f .Jumptable: ; 2928f +; entries correspond to TRADEANIMSTATE_* constants dw .Zero dw .One dw .Two @@ -871,13 +883,13 @@ TradeAnim_AnimateFrontpic: ; 29487 TradeAnim_GetFrontpic: ; 29491 push de push af - predef GetUnownLetter + predef Predef_GetUnownLetter pop af ld [CurPartySpecies], a ld [CurSpecies], a call GetBaseData pop de - predef GetMonFrontpic + predef Predef_GetMonFrontpic ret ; 294a9 @@ -911,7 +923,7 @@ TradeAnim_ShowFrontpic: ; 294c3 xor a ld [hGraphicStartTile], a lb bc, 7, 7 - predef PlaceGraphic + predef Predef_PlaceGraphic call WaitBGMap ret @@ -1114,8 +1126,8 @@ TradeAnim_RockingBall: ; 2961b ld a, SPRITE_ANIM_INDEX_TRADE_POKE_BALL call _InitSpriteAnimStruct call TradeAnim_AdvanceScriptPointer - ld a, $20 - ld [wcf64], a + ld a, 32 + ld [wFrameCounter], a ret ; 2962c @@ -1131,8 +1143,8 @@ TradeAnim_DropBall: ; 2962c add hl, bc ld [hl], $dc call TradeAnim_AdvanceScriptPointer - ld a, $38 - ld [wcf64], a + ld a, 56 + ld [wFrameCounter], a ret ; 29649 @@ -1142,8 +1154,8 @@ TradeAnim_Poof: ; 29649 ld a, SPRITE_ANIM_INDEX_TRADE_POOF call _InitSpriteAnimStruct call TradeAnim_AdvanceScriptPointer - ld a, $10 - ld [wcf64], a + ld a, 16 + ld [wFrameCounter], a ld de, SFX_BALL_POOF call PlaySFX ret @@ -1157,8 +1169,8 @@ TradeAnim_BulgeThroughTube: ; 29660 ld a, SPRITE_ANIM_INDEX_TRADE_TUBE_BULGE call _InitSpriteAnimStruct call TradeAnim_AdvanceScriptPointer - ld a, $40 - ld [wcf64], a + ld a, 64 + ld [wFrameCounter], a ret ; 29676 @@ -1500,15 +1512,15 @@ LoadTradeBallAndCableGFX: ; 2982b call DelayFrame ld de, TradeBallGFX ld hl, vTiles0 tile $62 - lb bc, BANK(TradeBallGFX), $6 + lb bc, BANK(TradeBallGFX), 6 call Request2bpp ld de, TradePoofGFX ld hl, vTiles0 tile $68 - lb bc, BANK(TradePoofGFX), $c + lb bc, BANK(TradePoofGFX), 12 call Request2bpp ld de, TradeCableGFX ld hl, vTiles0 tile $74 - lb bc, BANK(TradeCableGFX), $4 + lb bc, BANK(TradeCableGFX), 4 call Request2bpp xor a ld hl, wSpriteAnimDict @@ -1524,7 +1536,7 @@ LoadTradeBubbleGFX: ; 2985a callfar LoadMenuMonIcon ld de, TradeBubbleGFX ld hl, vTiles0 tile $72 - lb bc, BANK(TradeBubbleGFX), $4 + lb bc, BANK(TradeBubbleGFX), 4 call Request2bpp xor a ld hl, wSpriteAnimDict @@ -1535,7 +1547,7 @@ LoadTradeBubbleGFX: ; 2985a ; 29879 TradeAnim_WaitAnim: ; 29879 - ld hl, wcf64 + ld hl, wFrameCounter ld a, [hl] and a jr z, .done @@ -1549,7 +1561,7 @@ TradeAnim_WaitAnim: ; 29879 ; 29886 TradeAnim_WaitAnim2: ; 29886 - ld hl, wcf64 + ld hl, wFrameCounter ld a, [hl] and a jr z, .done @@ -1563,8 +1575,8 @@ TradeAnim_WaitAnim2: ; 29886 ; 29893 -DebugTrade: ; 29893 -; This function is unreferenced. +Unreferenced_DebugTrade: ; 29893 +; This function is not referenced. ; It was meant for use in Japanese versions, so the ; constant used for copy length was changed by accident. diff --git a/engine/trainer_card.asm b/engine/trainer_card.asm index 87cab0103..c80553ecd 100755 --- a/engine/trainer_card.asm +++ b/engine/trainer_card.asm @@ -1,3 +1,13 @@ +; TrainerCard.Jumptable indexes + const_def + const TRAINERCARDSTATE_PAGE1_LOADGFX ; 0 + const TRAINERCARDSTATE_PAGE1_JOYPAD ; 1 + const TRAINERCARDSTATE_PAGE2_LOADGFX ; 2 + const TRAINERCARDSTATE_PAGE2_JOYPAD ; 3 + const TRAINERCARDSTATE_PAGE3_LOADGFX ; 4 + const TRAINERCARDSTATE_PAGE3_JOYPAD ; 5 + const TRAINERCARDSTATE_QUIT ; 6 + TrainerCard: ; 25105 ld a, [VramState] push af @@ -6,7 +16,7 @@ TrainerCard: ; 25105 ld hl, Options ld a, [hl] push af - set 4, [hl] + set NO_TEXT_SCROLL, [hl] call .InitRAM .loop call UpdateTime @@ -61,17 +71,18 @@ TrainerCard: ; 25105 call SetPalettes call WaitBGMap ld hl, wJumptableIndex - xor a - ld [hli], a - ld [hli], a - ld [hli], a - ld [hl], a + xor a ; TRAINERCARDSTATE_PAGE1_LOADGFX + ld [hli], a ; wJumptableIndex + ld [hli], a ; wTrainerCardBadgeFrameCounter + ld [hli], a ; wTrainerCardBadgeTileID + ld [hl], a ; wTrainerCardBadgeAttributes ret .RunJumptable: ; 2518e (9:518e) jumptable .Jumptable, wJumptableIndex .Jumptable: ; 2519d (9:519d) +; entries correspond to TRAINERCARDSTATE_* constants dw TrainerCard_Page1_LoadGFX dw TrainerCard_Page1_Joypad dw TrainerCard_Page2_LoadGFX @@ -113,16 +124,15 @@ TrainerCard_Page1_Joypad: ; 251d7 (9:51d7) ret .pressed_right_a - ld a, $2 + ld a, TRAINERCARDSTATE_PAGE2_LOADGFX ld [wJumptableIndex], a ret -.KantoCheck: -; unreferenced +.Unreferenced_KantoCheck: ld a, [wKantoBadges] and a ret z - ld a, $4 + ld a, TRAINERCARDSTATE_PAGE3_LOADGFX ld [wJumptableIndex], a ret @@ -136,11 +146,11 @@ TrainerCard_Page2_LoadGFX: ; 251f4 (9:51f4) call WaitBGMap ld de, LeaderGFX ld hl, vTiles2 tile $29 - lb bc, BANK(LeaderGFX), $56 + lb bc, BANK(LeaderGFX), 86 call Request2bpp ld de, BadgeGFX ld hl, vTiles0 tile $00 - lb bc, BANK(BadgeGFX), $2c + lb bc, BANK(BadgeGFX), 44 call Request2bpp call TrainerCard_Page2_3_InitObjectsAndStrings call TrainerCard_IncrementJumptable @@ -159,21 +169,20 @@ TrainerCard_Page2_Joypad: ; 25221 (9:5221) ret .d_left - ld a, $0 + ld a, TRAINERCARDSTATE_PAGE1_LOADGFX ld [wJumptableIndex], a ret -.KantoCheck: -; unreferenced +.Unreferenced_KantoCheck: ld a, [wKantoBadges] and a ret z - ld a, $4 + ld a, TRAINERCARDSTATE_PAGE3_LOADGFX ld [wJumptableIndex], a ret .Quit: - ld a, $6 + ld a, TRAINERCARDSTATE_QUIT ld [wJumptableIndex], a ret @@ -185,11 +194,11 @@ TrainerCard_Page3_LoadGFX: ; 2524c (9:524c) call WaitBGMap ld de, LeaderGFX2 ld hl, vTiles2 tile $29 - lb bc, BANK(LeaderGFX2), $56 + lb bc, BANK(LeaderGFX2), 86 call Request2bpp ld de, BadgeGFX2 ld hl, vTiles0 tile $00 - lb bc, BANK(BadgeGFX2), $2c + lb bc, BANK(BadgeGFX2), 44 call Request2bpp call TrainerCard_Page2_3_InitObjectsAndStrings call TrainerCard_IncrementJumptable @@ -208,12 +217,12 @@ TrainerCard_Page3_Joypad: ; 25279 (9:5279) ret .left - ld a, $2 + ld a, TRAINERCARDSTATE_PAGE2_LOADGFX ld [wJumptableIndex], a ret .right - ld a, $0 + ld a, TRAINERCARDSTATE_PAGE1_LOADGFX ld [wJumptableIndex], a ret @@ -245,7 +254,7 @@ TrainerCard_PrintTopHalfOfCard: ; 25299 (9:5299) lb bc, 5, 7 xor a ld [hGraphicStartTile], a - predef PlaceGraphic + predef Predef_PlaceGraphic ret ; 252ec (9:52ec) @@ -256,10 +265,10 @@ TrainerCard_PrintTopHalfOfCard: ; 25299 (9:5299) next "MONEY@" .ID_No: ; 252f9 - db $27, $28, $ff ; ID NO + db $27, $28, -1 ; ID NO .HorizontalDivider: ; 252fc - db $25, $25, $25, $25, $25, $25, $25, $25, $25, $25, $25, $25, $26, $ff ; ____________> + db $25, $25, $25, $25, $25, $25, $25, $25, $25, $25, $25, $25, $26, -1 ; ____________> ; 2530a TrainerCard_Page1_PrintDexCaught_GameTime: ; 2530a (9:530a) @@ -281,7 +290,7 @@ TrainerCard_Page1_PrintDexCaught_GameTime: ; 2530a (9:530a) ld de, .StatusTilemap call TrainerCardSetup_PlaceTilemapString ld a, [wStatusFlags] - bit 0, a + bit 0, a ; ENGINE_POKEDEX ret nz hlcoord 1, 9 lb bc, 2, 17 @@ -296,7 +305,7 @@ TrainerCard_Page1_PrintDexCaught_GameTime: ; 2530a (9:530a) db " BADGES▶@" .StatusTilemap: ; 25366 - db $29, $2a, $2b, $2c, $2d, $ff + db $29, $2a, $2b, $2c, $2d, -1 ; 2536c TrainerCard_Page2_3_InitObjectsAndStrings: ; 2536c (9:536c) @@ -324,7 +333,7 @@ endr dec c jr nz, .loop2 xor a - ld [wcf64], a + ld [wTrainerCardBadgeFrameCounter], a ld hl, TrainerCard_JohtoBadgesOAM call TrainerCard_Page2_3_OAMUpdate ret @@ -332,20 +341,20 @@ endr ; 253a2 (9:53a2) .BadgesTilemap: ; 253a2 - db $79, $7a, $7b, $7c, $7d, $ff ; "BADGES" + db $79, $7a, $7b, $7c, $7d, -1 ; "BADGES" ; 253a8 TrainerCardSetup_PlaceTilemapString: ; 253a8 (9:53a8) .loop ld a, [de] - cp $ff + cp -1 ret z ld [hli], a inc de jr .loop TrainerCard_InitBorder: ; 253b0 (9:53b0) - ld e, 20 + ld e, SCREEN_WIDTH .loop1 ld a, $23 ld [hli], a @@ -354,7 +363,7 @@ TrainerCard_InitBorder: ; 253b0 (9:53b0) ld a, $23 ld [hli], a - ld e, 17 + ld e, SCREEN_HEIGHT - 1 ld a, " " .loop2 ld [hli], a @@ -369,7 +378,7 @@ TrainerCard_InitBorder: ; 253b0 (9:53b0) ld a, $23 ld [hli], a - ld e, 18 + ld e, SCREEN_HEIGHT ld a, " " .loop4 ld [hli], a @@ -386,7 +395,7 @@ TrainerCard_InitBorder: ; 253b0 (9:53b0) ld a, $24 ld [hli], a - ld e, 17 + ld e, SCREEN_HEIGHT - 1 ld a, " " .loop5 ld [hli], a @@ -394,7 +403,7 @@ TrainerCard_InitBorder: ; 253b0 (9:53b0) jr nz, .loop5 ld a, $23 ld [hli], a - ld e, 20 + ld e, SCREEN_WIDTH .loop6 ld a, $23 ld [hli], a @@ -453,12 +462,12 @@ TrainerCard_Page1_PrintGameTime: ; 25415 (9:5415) TrainerCard_Page2_3_AnimateBadges: ; 25438 (9:5438) ld a, [hVBlankCounter] - and $7 + and %111 ret nz - ld a, [wcf64] + ld a, [wTrainerCardBadgeFrameCounter] inc a - and $7 - ld [wcf64], a + and %111 + ld [wTrainerCardBadgeFrameCounter], a jr TrainerCard_Page2_3_OAMUpdate TrainerCard_Page2_3_OAMUpdate: ; 25448 (9:5448) @@ -470,8 +479,8 @@ TrainerCard_Page2_3_OAMUpdate: ; 25448 (9:5448) ld d, a ld a, [de] ld c, a - ld de, Sprites - ld b, 8 + ld de, Sprite01 + ld b, NUM_JOHTO_BADGES .loop srl c push bc @@ -482,15 +491,15 @@ TrainerCard_Page2_3_OAMUpdate: ; 25448 (9:5448) ld a, [hli] ; x ld c, a ld a, [hli] ; pal - ld [wcf66], a - ld a, [wcf64] + ld [wTrainerCardBadgeAttributes], a + ld a, [wTrainerCardBadgeFrameCounter] add l ld l, a ld a, 0 adc h ld h, a ld a, [hl] - ld [wcf65], a + ld [wTrainerCardBadgeTileID], a call .PrepOAM pop hl .skip_badge @@ -502,8 +511,8 @@ TrainerCard_Page2_3_OAMUpdate: ; 25448 (9:5448) ret .PrepOAM: ; 2547b (9:547b) - ld a, [wcf65] - and $80 + ld a, [wTrainerCardBadgeTileID] + and 1 << 7 jr nz, .xflip ld hl, .facing1 jr .loop2 @@ -512,27 +521,27 @@ TrainerCard_Page2_3_OAMUpdate: ; 25448 (9:5448) ld hl, .facing2 .loop2 ld a, [hli] - cp $ff + cp -1 ret z add b - ld [de], a + ld [de], a ; y inc de ld a, [hli] add c - ld [de], a + ld [de], a ; x inc de - ld a, [wcf65] - and $7f + ld a, [wTrainerCardBadgeTileID] + and $ff ^ (1 << 7) add [hl] - ld [de], a + ld [de], a ; tile id inc hl inc de - ld a, [wcf66] + ld a, [wTrainerCardBadgeAttributes] add [hl] - ld [de], a + ld [de], a ; attributes inc hl inc de jr .loop2 @@ -540,18 +549,17 @@ TrainerCard_Page2_3_OAMUpdate: ; 25448 (9:5448) ; 254a7 (9:54a7) .facing1 ; 254a7 - ; y, x, tile, OAM attributes - db 0, 0, 0, 0 - db 0, 8, 1, 0 - db 8, 0, 2, 0 - db 8, 8, 3, 0 + dsprite 0, 0, 0, 0, $00, 0 + dsprite 0, 0, 1, 0, $01, 0 + dsprite 1, 0, 0, 0, $02, 0 + dsprite 1, 0, 1, 0, $03, 0 db -1 .facing2 ; 254b8 - db 0, 0, 1, X_FLIP - db 0, 8, 0, X_FLIP - db 8, 0, 3, X_FLIP - db 8, 8, 2, X_FLIP + dsprite 0, 0, 0, 0, $01, 0 | X_FLIP + dsprite 0, 0, 1, 0, $00, 0 | X_FLIP + dsprite 1, 0, 0, 0, $03, 0 | X_FLIP + dsprite 1, 0, 1, 0, $02, 0 | X_FLIP db -1 TrainerCard_JohtoBadgesOAM: ; 254c9 @@ -565,44 +573,44 @@ TrainerCard_JohtoBadgesOAM: ; 254c9 ; Zephyrbadge db $68, $18, 0 - db $00, $20, $24, $20 | $80 - db $00, $20, $24, $20 | $80 + db $00, $20, $24, $20 | (1 << 7) + db $00, $20, $24, $20 | (1 << 7) ; Hivebadge db $68, $38, 0 - db $04, $20, $24, $20 | $80 - db $04, $20, $24, $20 | $80 + db $04, $20, $24, $20 | (1 << 7) + db $04, $20, $24, $20 | (1 << 7) ; Plainbadge db $68, $58, 0 - db $08, $20, $24, $20 | $80 - db $08, $20, $24, $20 | $80 + db $08, $20, $24, $20 | (1 << 7) + db $08, $20, $24, $20 | (1 << 7) ; Fogbadge db $68, $78, 0 - db $0c, $20, $24, $20 | $80 - db $0c, $20, $24, $20 | $80 + db $0c, $20, $24, $20 | (1 << 7) + db $0c, $20, $24, $20 | (1 << 7) ; Mineralbadge db $80, $38, 0 - db $10, $20, $24, $20 | $80 - db $10, $20, $24, $20 | $80 + db $10, $20, $24, $20 | (1 << 7) + db $10, $20, $24, $20 | (1 << 7) ; Stormbadge db $80, $18, 0 - db $14, $20, $24, $20 | $80 - db $14, $20, $24, $20 | $80 + db $14, $20, $24, $20 | (1 << 7) + db $14, $20, $24, $20 | (1 << 7) ; Glacierbadge db $80, $58, 0 - db $18, $20, $24, $20 | $80 - db $18, $20, $24, $20 | $80 + db $18, $20, $24, $20 | (1 << 7) + db $18, $20, $24, $20 | (1 << 7) ; Risingbadge ; X-flips on alternate cycles. db $80, $78, 0 - db $1c, $20, $24, $20 | $80 - db $1c | $80, $20, $24, $20 | $80 + db $1c, $20, $24, $20 | (1 << 7) + db $1c | (1 << 7), $20, $24, $20 | (1 << 7) ; 25523 CardStatusGFX: INCBIN "gfx/trainer_card/card_status.2bpp" diff --git a/engine/types.asm b/engine/types.asm index 375bfe434..0cd52eda7 100644 --- a/engine/types.asm +++ b/engine/types.asm @@ -1,4 +1,4 @@ -PrintMonTypes: ; 5090d +Predef_PrintMonTypes: ; 5090d ; Print one or both types of [CurSpecies] ; on the stats screen at hl. @@ -24,7 +24,7 @@ PrintMonTypes: ; 5090d .Print: ld b, a - jr PrintType + jr Predef_PrintType .hide_type_2 ; Erase any type name that was here before. @@ -40,7 +40,7 @@ PrintMonTypes: ; 5090d ; 5093a -PrintMoveType: ; 5093a +Predef_PrintMoveType: ; 5093a ; Print the type of move b at hl. push hl @@ -58,7 +58,7 @@ PrintMoveType: ; 5093a ld b, a -PrintType: ; 50953 +Predef_PrintType: ; 50953 ; Print type b at hl. ld a, b @@ -78,7 +78,7 @@ PrintType: ; 50953 ; 50964 -GetTypeName: ; 50964 +Predef_GetTypeName: ; 50964 ; Copy the name of type [wd265] to StringBuffer1. ld a, [wd265] @@ -96,6 +96,4 @@ GetTypeName: ; 50964 ; 5097b -INCLUDE "data/type_names.asm" - -; 50a28 +INCLUDE "data/types/names.asm" diff --git a/engine/unown_puzzle.asm b/engine/unown_puzzle.asm index ee76f817c..429bfaefd 100755 --- a/engine/unown_puzzle.asm +++ b/engine/unown_puzzle.asm @@ -157,7 +157,7 @@ PlaceStartCancelBoxBorder: ; e128d ld a, $f3 ld [hli], a ld bc, 10 - ld a, $ef + ld a, PUZZLE_VOID call ByteFill hlcoord 15, 16 ld a, $f3 @@ -218,7 +218,7 @@ UnownPuzzleJumptable: ; e12ca ld a, [hl] cp 1 puzcoord 0 ret c - sub $6 + sub 6 ld [hl], a jr .done_joypad @@ -235,7 +235,7 @@ UnownPuzzleJumptable: ; e12ca ret z cp 5 puzcoord 0 ret nc - add $6 + add 6 ld [hl], a jr .done_joypad @@ -549,51 +549,51 @@ RedrawUnownPuzzlePieces: ; e14d9 ld hl, .OAM_NotHoldingPiece .load - ld de, Sprites + ld de, Sprite01 .loop ld a, [hli] cp -1 ret z add b - ld [de], a + ld [de], a ; y inc de ld a, [hli] add c - ld [de], a + ld [de], a ; x inc de ld a, [wd002] add [hl] - ld [de], a + ld [de], a ; tile id inc hl inc de ld a, [hli] - ld [de], a + ld [de], a ; attributes inc de jr .loop ; e150f .OAM_HoldingPiece: ; e150f - dsprite -1, -4, -1, -4, $00, $00 - dsprite -1, -4, 0, -4, $01, $00 - dsprite -1, -4, 0, 4, $02, $00 - dsprite 0, -4, -1, -4, $0c, $00 - dsprite 0, -4, 0, -4, $0d, $00 - dsprite 0, -4, 0, 4, $0e, $00 - dsprite 0, 4, -1, -4, $18, $00 - dsprite 0, 4, 0, -4, $19, $00 - dsprite 0, 4, 0, 4, $1a, $00 + dsprite -1, -4, -1, -4, $00, 0 + dsprite -1, -4, 0, -4, $01, 0 + dsprite -1, -4, 0, 4, $02, 0 + dsprite 0, -4, -1, -4, $0c, 0 + dsprite 0, -4, 0, -4, $0d, 0 + dsprite 0, -4, 0, 4, $0e, 0 + dsprite 0, 4, -1, -4, $18, 0 + dsprite 0, 4, 0, -4, $19, 0 + dsprite 0, 4, 0, 4, $1a, 0 db -1 .OAM_NotHoldingPiece: ; e1534 - dsprite -1, -4, -1, -4, $00, $00 - dsprite -1, -4, 0, -4, $01, $00 - dsprite -1, -4, 0, 4, $00, $20 ; xflip - dsprite 0, -4, -1, -4, $02, $00 - dsprite 0, -4, 0, -4, $03, $00 - dsprite 0, -4, 0, 4, $02, $20 ; xflip - dsprite 0, 4, -1, -4, $00, $40 ; yflip - dsprite 0, 4, 0, -4, $01, $40 ; yflip - dsprite 0, 4, 0, 4, $00, $60 ; xflip, yflip + dsprite -1, -4, -1, -4, $00, 0 + dsprite -1, -4, 0, -4, $01, 0 + dsprite -1, -4, 0, 4, $00, 0 | X_FLIP + dsprite 0, -4, -1, -4, $02, 0 + dsprite 0, -4, 0, -4, $03, 0 + dsprite 0, -4, 0, 4, $02, 0 | X_FLIP + dsprite 0, 4, -1, -4, $00, 0 | Y_FLIP + dsprite 0, 4, 0, -4, $01, 0 | Y_FLIP + dsprite 0, 4, 0, 4, $00, 0 | X_FLIP | Y_FLIP db -1 UnownPuzzleCoordData: ; e1559 @@ -835,7 +835,7 @@ INCBIN "gfx/unown_puzzle/tile_borders.2bpp" LoadUnownPuzzlePiecesGFX: ; e17a3 ld a, [ScriptVar] - and 3 + maskbits NUM_UNOWN_PUZZLES +- 1 ld e, a ld d, 0 ld hl, .LZPointers @@ -851,6 +851,7 @@ LoadUnownPuzzlePiecesGFX: ; e17a3 ; e17bd .LZPointers: ; e17bd +; entries correspond to UNOWNPUZZLE_* constants dw KabutoPuzzleLZ dw OmanytePuzzleLZ dw AerodactylPuzzleLZ diff --git a/engine/unused_title.asm b/engine/unused_title.asm index f0b59b527..516fc902e 100644 --- a/engine/unused_title.asm +++ b/engine/unused_title.asm @@ -32,7 +32,7 @@ UnusedTitleScreen: ; 10c000 ld hl, UnusedTitleBG_Tilemap debgcoord 0, 0 - ld bc, 32 * 32 + ld bc, BG_MAP_WIDTH * BG_MAP_HEIGHT .copy ld a, 0 ld [rVBK], a @@ -49,8 +49,8 @@ UnusedTitleScreen: ; 10c000 jr nz, .copy ld hl, UnusedTitleFG_OAM - ld de, Sprites - ld bc, $a0 + ld de, Sprite01 + ld bc, SPRITEOAMSTRUCT_LENGTH * NUM_SPRITE_OAM_STRUCTS call CopyBytes call EnableLCD @@ -63,7 +63,7 @@ UnusedTitleScreen: ; 10c000 ld a, [rSVBK] push af - ld a, $5 + ld a, BANK(wBGPals1) ld [rSVBK], a ld hl, UnusedTitleBG_Palettes @@ -103,60 +103,12 @@ INCBIN "gfx/title/old_bg.2bpp" ; 10d0b1 UnusedTitleBG_Tilemap: ; 10d0b1 -; 32x32 (tile, attributes) - db $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $01,$00, $02,$01, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00 - db $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $03,$00, $04,$00, $05,$01, $06,$01, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00 - db $00,$00, $00,$00, $07,$05, $08,$05, $09,$05, $0a,$05, $0b,$00, $0c,$00, $0d,$00, $0e,$00, $0f,$01, $10,$01, $11,$01, $12,$01, $13,$05, $14,$05, $15,$05, $16,$05, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00 - db $00,$00, $00,$00, $17,$04, $18,$04, $19,$04, $1a,$04, $1b,$00, $1c,$00, $1d,$02, $1e,$02, $1f,$07, $20,$07, $21,$01, $22,$01, $23,$04, $24,$04, $25,$04, $26,$04, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00 - db $00,$00, $00,$00, $27,$04, $28,$04, $29,$04, $2a,$04, $2b,$00, $2c,$00, $2d,$03, $2e,$01, $2f,$01, $30,$01, $31,$01, $32,$01, $33,$04, $34,$04, $35,$04, $36,$04, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00 - db $00,$00, $00,$00, $37,$04, $38,$04, $39,$04, $3a,$04, $3b,$00, $3c,$00, $3d,$01, $00,$00, $00,$00, $3e,$07, $3f,$01, $40,$01, $41,$04, $42,$04, $43,$04, $44,$04, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00 - db $00,$00, $00,$00, $45,$04, $46,$04, $47,$04, $48,$04, $49,$00, $3c,$00, $4a,$01, $00,$00, $00,$00, $4b,$07, $3f,$01, $4c,$01, $4d,$06, $4e,$06, $4f,$06, $50,$06, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00 - db $00,$00, $00,$00, $51,$04, $52,$06, $53,$06, $54,$06, $55,$00, $3c,$00, $56,$01, $00,$00, $00,$00, $57,$07, $58,$01, $59,$01, $5a,$06, $5b,$06, $5c,$06, $5d,$06, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00 - db $00,$00, $00,$00, $5e,$06, $5f,$06, $60,$06, $61,$06, $62,$00, $63,$00, $64,$03, $65,$01, $66,$01, $67,$07, $68,$01, $69,$01, $26,$04, $6a,$06, $26,$04, $26,$04, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00 - db $00,$00, $00,$00, $6b,$00, $6c,$05, $6d,$05, $6e,$05, $6f,$00, $70,$02, $71,$02, $72,$01, $73,$00, $74,$02, $75,$01, $76,$01, $77,$05, $78,$05, $79,$05, $6b,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00 - db $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $7a,$00, $7b,$00, $7c,$00, $7d,$00, $0f,$01, $7e,$01, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00 - db $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $a2,$00, $80,$00, $81,$00, $82,$00, $83,$00, $84,$07, $85,$01, $86,$01, $87,$01, $88,$01, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00 - db $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $89,$00, $8a,$00, $8b,$00, $8c,$07, $8d,$01, $8e,$01, $8f,$01, $90,$01, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00 - db $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $91,$01, $92,$01, $93,$01, $94,$01, $95,$01, $00,$00, $00,$00, $00,$00, $96,$05, $97,$05, $98,$05, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00 - db $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $99,$05, $9a,$05, $9b,$05, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00 - db $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $9c,$05, $9d,$05, $9e,$05, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00 - db $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $9f,$05, $a0,$05, $a1,$05, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00 - db $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00 - db $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00 - db $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00 - db $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00 - db $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00 - db $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00 - db $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00 - db $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00 - db $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00 - db $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $6b,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00 - db $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00 - db $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00 - db $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00 - db $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00 - db $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00 +; 32x32 (alternating tiles and attributes) +INCBIN "gfx/title/old_bg.tilemap" ; 10d8b1 UnusedTitleBG_Palettes: ; 10d8b1 -INCLUDE "data/palettes/unused_title/bg.pal" - - RGB 31, 31, 31 - RGB 31, 31, 31 - RGB 31, 31, 31 - RGB 31, 31, 31 - - RGB 31, 31, 31 - RGB 20, 04, 20 - RGB 16, 08, 16 - RGB 24, 00, 24 - -rept 54 - RGB 31, 31, 31 - RGB 31, 31, 31 - RGB 31, 31, 31 - RGB 31, 31, 31 -endr +INCLUDE "gfx/title/old_bg.pal" ; 10dab1 UnusedTitleFG_GFX: ; 10dab1 @@ -164,27 +116,52 @@ INCBIN "gfx/title/old_fg.2bpp" ; 10eab1 UnusedTitleFG_Palettes: ; 10eab1 -INCLUDE "data/palettes/unused_title/ob.pal" +INCLUDE "gfx/title/old_fg.pal" ; 10ecb1 UnusedTitleFG_OAM: ; 10ecb1 - db $18, $38, $00, $01, $18, $40, $02, $01, $18, $48, $04, $01, $18, $50, $06, $01 - db $18, $58, $08, $01, $18, $60, $0a, $01, $18, $68, $0c, $01, $18, $70, $0e, $01 - - db $28, $38, $10, $00, $28, $40, $12, $00, $28, $48, $14, $00, $28, $50, $16, $00 - db $28, $58, $18, $00, $28, $60, $1a, $00, $28, $68, $1c, $00, $28, $70, $1e, $00 - - db $38, $38, $20, $00, $38, $40, $22, $00, $38, $48, $24, $00, $38, $50, $26, $00 - db $38, $58, $28, $00, $38, $60, $2a, $00, $38, $68, $2c, $00, $38, $70, $2e, $00 - - db $48, $38, $30, $02, $48, $40, $32, $02, $48, $48, $34, $02, $48, $50, $36, $02 - db $48, $58, $38, $02, $48, $60, $3a, $02, $48, $68, $3c, $02, $48, $70, $3e, $02 - - db $58, $38, $40, $01, $58, $40, $42, $01, $58, $48, $44, $01, $58, $50, $46, $01 - db $58, $58, $48, $01, $58, $60, $4a, $01, $58, $68, $4c, $01, $58, $70, $4e, $01 + dsprite 3, 0, 7, 0, $00, 1 + dsprite 3, 0, 8, 0, $02, 1 + dsprite 3, 0, 9, 0, $04, 1 + dsprite 3, 0, 10, 0, $06, 1 + dsprite 3, 0, 11, 0, $08, 1 + dsprite 3, 0, 12, 0, $0a, 1 + dsprite 3, 0, 13, 0, $0c, 1 + dsprite 3, 0, 14, 0, $0e, 1 + dsprite 5, 0, 7, 0, $10, 0 + dsprite 5, 0, 8, 0, $12, 0 + dsprite 5, 0, 9, 0, $14, 0 + dsprite 5, 0, 10, 0, $16, 0 + dsprite 5, 0, 11, 0, $18, 0 + dsprite 5, 0, 12, 0, $1a, 0 + dsprite 5, 0, 13, 0, $1c, 0 + dsprite 5, 0, 14, 0, $1e, 0 + dsprite 7, 0, 7, 0, $20, 0 + dsprite 7, 0, 8, 0, $22, 0 + dsprite 7, 0, 9, 0, $24, 0 + dsprite 7, 0, 10, 0, $26, 0 + dsprite 7, 0, 11, 0, $28, 0 + dsprite 7, 0, 12, 0, $2a, 0 + dsprite 7, 0, 13, 0, $2c, 0 + dsprite 7, 0, 14, 0, $2e, 0 + dsprite 9, 0, 7, 0, $30, 2 + dsprite 9, 0, 8, 0, $32, 2 + dsprite 9, 0, 9, 0, $34, 2 + dsprite 9, 0, 10, 0, $36, 2 + dsprite 9, 0, 11, 0, $38, 2 + dsprite 9, 0, 12, 0, $3a, 2 + dsprite 9, 0, 13, 0, $3c, 2 + dsprite 9, 0, 14, 0, $3e, 2 + dsprite 11, 0, 7, 0, $40, 1 + dsprite 11, 0, 8, 0, $42, 1 + dsprite 11, 0, 9, 0, $44, 1 + dsprite 11, 0, 10, 0, $46, 1 + dsprite 11, 0, 11, 0, $48, 1 + dsprite 11, 0, 12, 0, $4a, 1 + dsprite 11, 0, 13, 0, $4c, 1 + dsprite 11, 0, 14, 0, $4e, 1 ; 10ed51 - Function10ed51: ; 10ed51 call _TitleScreen .loop diff --git a/engine/variables.asm b/engine/variables.asm index 1b418ea3c..56c49f085 100755 --- a/engine/variables.asm +++ b/engine/variables.asm @@ -35,9 +35,10 @@ _GetVarAction:: ; 80648 (20:4648) ; 80671 (20:4671) .VarActionTable: ; 80671 -; RETVAR_STRBUF2: copy [de] to StringBuffer2 -; RETVAR_ADDR_DE: return address in de -; RETVAR_EXECUTE: call function +; entries correspond to VAR_* constants + ; RETVAR_STRBUF2: copy [de] to StringBuffer2 + ; RETVAR_ADDR_DE: return address in de + ; RETVAR_EXECUTE: call function dwb StringBuffer2, RETVAR_STRBUF2 dwb PartyCount, RETVAR_STRBUF2 dwb .BattleResult, RETVAR_EXECUTE @@ -125,7 +126,7 @@ _GetVarAction:: ; 80648 (20:4648) ret z inc b ld a, b - cp 26 + cp NUM_UNOWN jr c, .loop ret ; 80715 diff --git a/engine/warp_connection.asm b/engine/warp_connection.asm index a0784caac..28908e793 100755 --- a/engine/warp_connection.asm +++ b/engine/warp_connection.asm @@ -174,8 +174,11 @@ LoadWarpData: ; 1046c6 call GetAnyMapEnvironment call CheckIndoorMap ret nz + +; MOUNT_MOON_SQUARE and TIN_TOWER_ROOF are outdoor maps within indoor maps. +; Dig and Escape Rope should not take you to them. ld a, [wPrevMapGroup] - cp GROUP_MOUNT_MOON_SQUARE + cp GROUP_MOUNT_MOON_SQUARE ; GROUP_TIN_TOWER_ROOF jr nz, .not_mt_moon_or_tin_tower ld a, [wPrevMapNumber] cp MAP_MOUNT_MOON_SQUARE @@ -183,6 +186,7 @@ LoadWarpData: ; 1046c6 cp MAP_TIN_TOWER_ROOF ret z .not_mt_moon_or_tin_tower + ld a, [wPrevWarp] ld [wDigWarpNumber], a ld a, [wPrevMapGroup] @@ -206,6 +210,8 @@ LoadWarpData: ; 1046c6 ld b, a ld a, [wNextMapNumber] ld c, a + +; Respawn in Pokémon Centers. call GetAnyMapTileset ld a, c cp TILESET_POKECENTER @@ -214,6 +220,7 @@ LoadWarpData: ; 1046c6 jr z, .pokecenter_pokecom ret .pokecenter_pokecom + ld a, [wPrevMapGroup] ld [wLastSpawnMapGroup], a ld a, [wPrevMapNumber] @@ -298,12 +305,12 @@ LoadGraphics: ; 1047cf ld [hMapAnims], a xor a ld [hTileAnimFrame], a - farcall RefreshSprites + farcall Special_RefreshSprites call LoadFontsExtra farcall LoadOverworldFont ret -LoadMapPalettes: ; 1047eb +Special_LoadMapPalettes: ; 1047eb ld b, SCGB_MAPPALS jp GetSGBLayout ; 1047f0 diff --git a/engine/wildmons.asm b/engine/wildmons.asm index dc62093b8..287ffe6ac 100755 --- a/engine/wildmons.asm +++ b/engine/wildmons.asm @@ -508,7 +508,7 @@ LookUpWildmonsForMapDE: ; 2a288 ; 2a2a0 -InitRoamMons: ; 2a2a0 +Special_InitRoamMons: ; 2a2a0 ; initialize wRoamMon structs ; species @@ -678,9 +678,9 @@ UpdateRoamMons: ; 2a30d ld l, e ; Choose which map to warp to. call Random - and $1f ; 1/8n chance it moves to a completely random map, where n is the number of roaming connections from the current map. + and %00011111 ; 1/8n chance it moves to a completely random map, where n is the number of roaming connections from the current map. jr z, JumpRoamMon - and 3 + and %11 cp [hl] jr nc, .update_loop ; invalid index, try again inc hl @@ -739,10 +739,10 @@ JumpRoamMons: ; 2a394 JumpRoamMon: ; 2a3cd .loop ld hl, RoamMaps -.innerloop1 ; This loop is completely unnecessary. - call Random ; Choose a random number - and $f ; Take the lower nybble only. This gives a number between 0 and 15. - cp $10 ; If the number is greater than or equal to 16, loop back and try again. +.innerloop1 ; This loop is completely unnecessary. + call Random ; Choose a random number. + maskbits $10 - 1 ; Mask the number to limit it between 0 and 15. + cp $10 ; If the number is not less than 16, try again. jr nc, .innerloop1 ; I'm sure you can guess why this check is bogus. inc a ld b, a @@ -804,7 +804,7 @@ ValidateTempWildMonSpecies: ; 2a4a0 ; Finds a rare wild Pokemon in the route of the trainer calling, then checks if it's been Seen already. ; The trainer will then tell you about the Pokemon if you haven't seen it. -RandomUnseenWildMon: ; 2a4ab +Special_RandomUnseenWildMon: ; 2a4ab farcall GetCallerLocation ld d, b ld e, c @@ -825,7 +825,7 @@ RandomUnseenWildMon: ; 2a4ab call AddNTimes .randloop1 call Random - and $3 + and %11 jr z, .randloop1 dec a ld c, a @@ -877,7 +877,7 @@ RandomUnseenWildMon: ; 2a4ab db "@" ; 0x2a51f -RandomPhoneWildMon: ; 2a51f +Special_RandomPhoneWildMon: ; 2a51f farcall GetCallerLocation ld d, b ld e, c @@ -902,7 +902,7 @@ RandomPhoneWildMon: ; 2a51f .done call Random - and $3 + and %11 ld c, a ld b, $0 add hl, bc @@ -917,7 +917,7 @@ RandomPhoneWildMon: ; 2a51f jp CopyBytes ; 2a567 -RandomPhoneMon: ; 2a567 +Special_RandomPhoneMon: ; 2a567 ; Get a random monster owned by the trainer who's calling. farcall GetCallerLocation ld hl, TrainerGroups |