diff options
-rw-r--r-- | Hard-coded-logic.md | 111 |
1 files changed, 67 insertions, 44 deletions
diff --git a/Hard-coded-logic.md b/Hard-coded-logic.md index d8219a4..b38819a 100644 --- a/Hard-coded-logic.md +++ b/Hard-coded-logic.md @@ -3,60 +3,37 @@ Much of the game logic can be changed via the files in [data/](../blob/master/da ## Contents +- [Tilesets that have per-mapgroup roofs](#tilesets-that-have-per-mapgroup-roofs) +- [Maps that don't display a location sign](#maps-that-dont-display-a-location-sign) +- [Outdoor maps within indoor maps don't confuse Dig or Escape Rope](#outdoor-maps-within-indoor-maps-dont-confuse-dig-or-escape-rope) +- [Trainer classes with different battle music](#trainer-classes-with-different-battle-music) - [`RIVAL1`'s first Pokémon has no held item](#rival1s-first-pokémon-has-no-held-item) - [`RIVAL1` and `RIVAL2` don't print their trainer class in battle](#rival1-and-rival2-dont-print-their-trainer-class-in-battle) -- [Some trainer classes have different battle music](#some-trainer-classes-have-different-battle-music) -- [Some maps don't display a location sign](#some-maps-dont-display-a-location-sign) -- [Outdoor maps within indoor maps don't confuse Dig or Escape Rope](#outdoor-maps-within-indoor-maps-dont-confuse-dig-or-escape-rope) -## `RIVAL1`'s first Pokémon has no held item +## Tilesets that have per-mapgroup roofs -This is caused by `InitEnemyTrainer` in [engine/battle/core.asm](../blob/master/engine/battle/core.asm): +This is caused by `LoadTilesetGFX` in [home/map.asm](../blob.master/home/map.asm): ```asm - ; RIVAL1's first mon has no held item - ld a, [TrainerClass] - cp RIVAL1 - jr nz, .ok - xor a - ld [OTPartyMon1Item], a -.ok +; These tilesets support dynamic per-mapgroup roof tiles. + ld a, [wTileset] + cp TILESET_JOHTO + jr z, .load_roof + cp TILESET_JOHTO_MODERN + jr z, .load_roof + cp TILESET_BATTLE_TOWER_OUTSIDE + jr z, .load_roof + jr .skip_roof + +.load_roof + farcall LoadMapGroupRoof + +.skip_roof ``` -## `RIVAL1` and `RIVAL2` don't print their trainer class in battle - -Both of these classes are named "RIVAL", but battles just print "SILVER wants to battle!", not "RIVAL SILVER wants to battle!" - -This is caused by `PlaceEnemysName` in [home/text.asm](../blob/master/home/text.asm): - -```asm - ld a, [TrainerClass] - cp RIVAL1 - jr z, .rival - cp RIVAL2 - jr z, .rival -``` - - -## Some trainer classes have different battle music - -This is caused by `PlayBattleMusic` in [engine/battle/start_battle.asm](../blob/master/engine/battle/start_battle.asm). The routine's logic is: - -1. If `[BattleType]` is `BATTLETYPE_SUICUNE` or `BATTLETYPE_ROAMING`, play `MUSIC_SUICUNE_BATTLE`. -2. If it's a wild battle, play `MUSIC_KANTO_WILD_BATTLE` if we're in Kanto, `MUSIC_JOHTO_WILD_BATTLE_NIGHT` in Johto at night, or `MUSIC_JOHTO_WILD_BATTLE` during morning and day. -3. If `[OtherTrainerClass]` is `CHAMPION` or `RED`, play `MUSIC_CHAMPION_BATTLE`. -4. If `[OtherTrainerClass]` is `GRUNTM` or `GRUNTF`, play `MUSIC_ROCKET_BATTLE`. (They should have included `EXECUTIVEM`, `EXECUTIVEF`, and `SCIENTIST` too…) -5. If `[OtherTrainerClass]` is listed under `KantoGymLeaders` in [data/trainers/leaders.asm](../blob/master/data/trainers/leaders.asm), play `MUSIC_KANTO_GYM_LEADER_BATTLE`. -6. If `[OtherTrainerClass]` is listed under `GymLeaders` in [data/trainers/leaders.asm](../blob/master/data/trainers/leaders.asm), play `MUSIC_JOHTO_GYM_LEADER_BATTLE`. (`CHAMPION`, `RED`, and the Kanto Gym leaders are listed but have already been accounted for at this point.) -7. If `[OtherTrainerClass]` is `RIVAL2` and `[OtherTrainerID]` is at least `RIVAL2_2_CHIKORITA` (i.e. we're battling our rival in Indigo Plateau), play `MUSIC_CHAMPION_BATTLE`. -8. If `[OtherTrainerClass]` is `RIVAL1` or `RIVAL2`, play `MUSIC_RIVAL_BATTLE`. -9. If it's a link battle, play `MUSIC_JOHTO_TRAINER_BATTLE`. -10. Play `MUSIC_KANTO_TRAINER_BATTLE` if we're in Kanto or `MUSIC_JOHTO_TRAINER_BATTLE` if we're in Johto. - - -## Some maps don't display a location sign +## Maps that don't display a location sign This is caused by `ReturnFromMapSetupScript.CheckSpecialMap` in [engine/events/map_name_sign.asm](../blob/master/engine/events/map_name_sign.asm): @@ -103,3 +80,49 @@ There's no "outdoor-within-indoor" map environment, so the few maps in this situ ret z .not_mt_moon_or_tin_tower ``` + + +## `RIVAL1`'s first Pokémon has no held item + +This is caused by `InitEnemyTrainer` in [engine/battle/core.asm](../blob/master/engine/battle/core.asm): + +```asm + ; RIVAL1's first mon has no held item + ld a, [TrainerClass] + cp RIVAL1 + jr nz, .ok + xor a + ld [OTPartyMon1Item], a +.ok +``` + + +## Trainer classes with different battle music + +This is caused by `PlayBattleMusic` in [engine/battle/start_battle.asm](../blob/master/engine/battle/start_battle.asm). The routine's logic is: + +1. If `[BattleType]` is `BATTLETYPE_SUICUNE` or `BATTLETYPE_ROAMING`, play `MUSIC_SUICUNE_BATTLE`. +2. If it's a wild battle, play `MUSIC_KANTO_WILD_BATTLE` if we're in Kanto, `MUSIC_JOHTO_WILD_BATTLE_NIGHT` in Johto at night, or `MUSIC_JOHTO_WILD_BATTLE` during morning and day. +3. If `[OtherTrainerClass]` is `CHAMPION` or `RED`, play `MUSIC_CHAMPION_BATTLE`. +4. If `[OtherTrainerClass]` is `GRUNTM` or `GRUNTF`, play `MUSIC_ROCKET_BATTLE`. (They should have included `EXECUTIVEM`, `EXECUTIVEF`, and `SCIENTIST` too…) +5. If `[OtherTrainerClass]` is listed under `KantoGymLeaders` in [data/trainers/leaders.asm](../blob/master/data/trainers/leaders.asm), play `MUSIC_KANTO_GYM_LEADER_BATTLE`. +6. If `[OtherTrainerClass]` is listed under `GymLeaders` in [data/trainers/leaders.asm](../blob/master/data/trainers/leaders.asm), play `MUSIC_JOHTO_GYM_LEADER_BATTLE`. (`CHAMPION`, `RED`, and the Kanto Gym leaders are listed but have already been accounted for at this point.) +7. If `[OtherTrainerClass]` is `RIVAL2` and `[OtherTrainerID]` is at least `RIVAL2_2_CHIKORITA` (i.e. we're battling our rival in Indigo Plateau), play `MUSIC_CHAMPION_BATTLE`. +8. If `[OtherTrainerClass]` is `RIVAL1` or `RIVAL2`, play `MUSIC_RIVAL_BATTLE`. +9. If it's a link battle, play `MUSIC_JOHTO_TRAINER_BATTLE`. +10. Play `MUSIC_KANTO_TRAINER_BATTLE` if we're in Kanto or `MUSIC_JOHTO_TRAINER_BATTLE` if we're in Johto. + + +## `RIVAL1` and `RIVAL2` don't print their trainer class in battle + +Both of these classes are named "RIVAL", but battles just print "SILVER wants to battle!", not "RIVAL SILVER wants to battle!" + +This is caused by `PlaceEnemysName` in [home/text.asm](../blob/master/home/text.asm): + +```asm + ld a, [TrainerClass] + cp RIVAL1 + jr z, .rival + cp RIVAL2 + jr z, .rival +``` |