diff options
author | dannye <33dannye@gmail.com> | 2021-10-15 17:09:10 -0500 |
---|---|---|
committer | dannye <33dannye@gmail.com> | 2021-10-15 17:09:10 -0500 |
commit | c259f271d96c878d6c82a84378719790cc0b80b4 (patch) | |
tree | 3933a8b31dcd0fce94afea888595c280d4eab3fc | |
parent | d9baef02df5210fcd829b15a6f1e14c87545934e (diff) |
Split part of bank 4
-rw-r--r-- | src/data/overworld_map/cursor_transitions.asm | 78 | ||||
-rw-r--r-- | src/data/overworld_map/map_positions.asm | 14 | ||||
-rw-r--r-- | src/data/overworld_map/overworld_warps.asm (renamed from src/data/overworld_indexes.asm) | 2 | ||||
-rw-r--r-- | src/data/overworld_map/player_movement_paths.asm | 664 | ||||
-rw-r--r-- | src/engine/bank04.asm | 2154 | ||||
-rw-r--r-- | src/engine/challenge_machine.asm | 830 | ||||
-rw-r--r-- | src/engine/duel/animations/core.asm | 2 | ||||
-rw-r--r-- | src/engine/link/printer.asm | 4 | ||||
-rw-r--r-- | src/engine/menus/duel.asm | 12 | ||||
-rw-r--r-- | src/engine/menus/glossary.asm | 6 | ||||
-rw-r--r-- | src/engine/menus/play_area.asm | 4 | ||||
-rw-r--r-- | src/engine/menus/unknown.asm | 4 | ||||
-rw-r--r-- | src/engine/overworld/overworld.asm | 2 | ||||
-rw-r--r-- | src/engine/overworld/scripting.asm | 8 | ||||
-rw-r--r-- | src/engine/overworld_map.asm | 566 | ||||
-rw-r--r-- | src/home/bg_map.asm | 2 | ||||
-rw-r--r-- | src/home/scroll.asm | 1 |
17 files changed, 2178 insertions, 2175 deletions
diff --git a/src/data/overworld_map/cursor_transitions.asm b/src/data/overworld_map/cursor_transitions.asm new file mode 100644 index 0000000..97e0097 --- /dev/null +++ b/src/data/overworld_map/cursor_transitions.asm @@ -0,0 +1,78 @@ +OverworldMap_CursorTransitions: + ; unused + db OWMAP_SCIENCE_CLUB ; NORTH + db OWMAP_SCIENCE_CLUB ; EAST + db OWMAP_SCIENCE_CLUB ; SOUTH + db OWMAP_SCIENCE_CLUB ; WEST + + ; OWMAP_MASON_LABORATORY + db OWMAP_LIGHTNING_CLUB ; NORTH + db OWMAP_FIGHTING_CLUB ; EAST + db $00 ; SOUTH + db $00 ; WEST + + ; OWMAP_ISHIHARAS_HOUSE + db $00 ; NORTH + db OWMAP_CHALLENGE_HALL ; EAST + db OWMAP_ROCK_CLUB ; SOUTH + db $00 ; WEST + + ; OWMAP_FIGHTING_CLUB + db OWMAP_LIGHTNING_CLUB ; NORTH + db OWMAP_WATER_CLUB ; EAST + db $00 ; SOUTH + db OWMAP_MASON_LABORATORY ; WEST + + ; OWMAP_ROCK_CLUB + db OWMAP_ISHIHARAS_HOUSE ; NORTH + db OWMAP_POKEMON_DOME ; EAST + db OWMAP_LIGHTNING_CLUB ; SOUTH + db $00 ; WEST + + ; OWMAP_WATER_CLUB + db OWMAP_GRASS_CLUB ; NORTH + db $00 ; EAST + db $00 ; SOUTH + db OWMAP_FIGHTING_CLUB ; WEST + + ; OWMAP_LIGHTNING_CLUB + db OWMAP_ROCK_CLUB ; NORTH + db OWMAP_POKEMON_DOME ; EAST + db OWMAP_FIGHTING_CLUB ; SOUTH + db OWMAP_MASON_LABORATORY ; WEST + + ; OWMAP_GRASS_CLUB + db OWMAP_SCIENCE_CLUB ; NORTH + db $00 ; EAST + db OWMAP_WATER_CLUB ; SOUTH + db OWMAP_PSYCHIC_CLUB ; WEST + + ; OWMAP_PSYCHIC_CLUB + db OWMAP_FIRE_CLUB ; NORTH + db OWMAP_SCIENCE_CLUB ; EAST + db OWMAP_GRASS_CLUB ; SOUTH + db OWMAP_POKEMON_DOME ; WEST + + ; OWMAP_SCIENCE_CLUB + db OWMAP_FIRE_CLUB ; NORTH + db $00 ; EAST + db OWMAP_GRASS_CLUB ; SOUTH + db OWMAP_PSYCHIC_CLUB ; WEST + + ; OWMAP_FIRE_CLUB + db $00 ; NORTH + db OWMAP_SCIENCE_CLUB ; EAST + db OWMAP_SCIENCE_CLUB ; SOUTH + db OWMAP_PSYCHIC_CLUB ; WEST + + ; OWMAP_CHALLENGE_HALL + db $00 ; NORTH + db OWMAP_PSYCHIC_CLUB ; EAST + db OWMAP_POKEMON_DOME ; SOUTH + db OWMAP_ISHIHARAS_HOUSE ; WEST + + ; OWMAP_POKEMON_DOME + db OWMAP_CHALLENGE_HALL ; NORTH + db OWMAP_PSYCHIC_CLUB ; EAST + db OWMAP_FIGHTING_CLUB ; SOUTH + db OWMAP_ROCK_CLUB ; WEST diff --git a/src/data/overworld_map/map_positions.asm b/src/data/overworld_map/map_positions.asm new file mode 100644 index 0000000..48dafd9 --- /dev/null +++ b/src/data/overworld_map/map_positions.asm @@ -0,0 +1,14 @@ +OverworldMap_MapPositions: + db $00, $00 ; unused + db $0c, $68 ; OWMAP_MASON_LABORATORY + db $04, $18 ; OWMAP_ISHIHARAS_HOUSE + db $34, $68 ; OWMAP_FIGHTING_CLUB + db $14, $38 ; OWMAP_ROCK_CLUB + db $6c, $64 ; OWMAP_WATER_CLUB + db $24, $50 ; OWMAP_LIGHTNING_CLUB + db $7c, $40 ; OWMAP_GRASS_CLUB + db $5c, $2c ; OWMAP_PSYCHIC_CLUB + db $7c, $20 ; OWMAP_SCIENCE_CLUB + db $6c, $10 ; OWMAP_FIRE_CLUB + db $3c, $20 ; OWMAP_CHALLENGE_HALL + db $44, $44 ; OWMAP_POKEMON_DOME diff --git a/src/data/overworld_indexes.asm b/src/data/overworld_map/overworld_warps.asm index dfc7b85..ce8c827 100644 --- a/src/data/overworld_indexes.asm +++ b/src/data/overworld_map/overworld_warps.asm @@ -3,7 +3,7 @@ ; 2: player's x coordinate when entering the map ; 2: player's y coordinate when entering the map ; 4: 00 -OverworldMapIndexes: ; 10f88 (4:4f88) +OverworldMapWarps: db $00, $00, $00, $00 db MASON_LABORATORY, $0e, $1a, $00 db ISHIHARAS_HOUSE, $08, $14, $00 diff --git a/src/data/overworld_map/player_movement_paths.asm b/src/data/overworld_map/player_movement_paths.asm new file mode 100644 index 0000000..a1d8d9f --- /dev/null +++ b/src/data/overworld_map/player_movement_paths.asm @@ -0,0 +1,664 @@ +OverworldMap_PlayerMovementPaths: + dw OverworldMap_MasonLaboratoryPaths + dw OverworldMap_IshiharasHousePaths + dw OverworldMap_FightingClubPaths + dw OverworldMap_RockClubPaths + dw OverworldMap_WaterClubPaths + dw OverworldMap_LightningClubPaths + dw OverworldMap_GrassClubPaths + dw OverworldMap_PsychicClubPaths + dw OverworldMap_ScienceClubPaths + dw OverworldMap_FireClubPaths + dw OverworldMap_ChallengeHallPaths + dw OverworldMap_PokemonDomePaths + +OverworldMap_MasonLaboratoryPaths: + dw OverworldMap_NoMovement + dw OverworldMap_MasonLaboratoryPathToIshiharasHouse + dw OverworldMap_StraightPath + dw OverworldMap_MasonLaboratoryPathToRockClub + dw OverworldMap_MasonLaboratoryPathToWaterClub + dw OverworldMap_MasonLaboratoryPathToLightningClub + dw OverworldMap_MasonLaboratoryPathToGrassClub + dw OverworldMap_MasonLaboratoryPathToPsychicClub + dw OverworldMap_MasonLaboratoryPathToScienceClub + dw OverworldMap_MasonLaboratoryPathToFireClub + dw OverworldMap_MasonLaboratoryPathToChallengeHall + dw OverworldMap_MasonLaboratoryPathToPokemonDome + +OverworldMap_IshiharasHousePaths: + dw OverworldMap_IshiharasHousePathToMasonLaboratory + dw OverworldMap_NoMovement + dw OverworldMap_IshiharasHousePathToFightingClub + dw OverworldMap_IshiharasHousePathToRockClub + dw OverworldMap_IshiharasHousePathToWaterClub + dw OverworldMap_IshiharasHousePathToLightningClub + dw OverworldMap_IshiharasHousePathToGrassClub + dw OverworldMap_IshiharasHousePathToPsychicClub + dw OverworldMap_IshiharasHousePathToScienceClub + dw OverworldMap_IshiharasHousePathToFireClub + dw OverworldMap_IshiharasHousePathToChallengeHall + dw OverworldMap_IshiharasHousePathToPokemonDome + +OverworldMap_FightingClubPaths: + dw OverworldMap_StraightPath + dw OverworldMap_FightingClubPathToIshiharasHouse + dw OverworldMap_NoMovement + dw OverworldMap_FightingClubPathToRockClub + dw OverworldMap_FightingClubPathToWaterClub + dw OverworldMap_StraightPath + dw OverworldMap_StraightPath + dw OverworldMap_FightingClubPathToPsychicClub + dw OverworldMap_StraightPath + dw OverworldMap_FightingClubPathToFireClub + dw OverworldMap_FightingClubPathToChallengeHall + dw OverworldMap_StraightPath + +OverworldMap_RockClubPaths: + dw OverworldMap_RockClubPathToMasonLaboratory + dw OverworldMap_RockClubPathToIshiharasHouse + dw OverworldMap_RockClubPathToFightingClub + dw OverworldMap_NoMovement + dw OverworldMap_RockClubPathToWaterClub + dw OverworldMap_StraightPath + dw OverworldMap_RockClubPathToGrassClub + dw OverworldMap_StraightPath + dw OverworldMap_RockClubPathToScienceClub + dw OverworldMap_RockClubPathToFireClub + dw OverworldMap_StraightPath + dw OverworldMap_StraightPath + +OverworldMap_WaterClubPaths: + dw OverworldMap_WaterClubPathToMasonLaboratory + dw OverworldMap_WaterClubPathToIshiharasHouse + dw OverworldMap_WaterClubPathToFightingClub + dw OverworldMap_WaterClubPathToRockClub + dw OverworldMap_NoMovement + dw OverworldMap_WaterClubPathToLightningClub + dw OverworldMap_WaterClubPathToGrassClub + dw OverworldMap_WaterClubPathToPsychicClub + dw OverworldMap_WaterClubPathToScienceClub + dw OverworldMap_WaterClubPathToFireClub + dw OverworldMap_WaterClubPathToChallengeHall + dw OverworldMap_WaterClubPathToPokemonDome + +OverworldMap_LightningClubPaths: + dw OverworldMap_LightningClubPathToMasonLaboratory + dw OverworldMap_LightningClubPathToIshiharasHouse + dw OverworldMap_StraightPath + dw OverworldMap_StraightPath + dw OverworldMap_LightningClubPathToWaterClub + dw OverworldMap_NoMovement + dw OverworldMap_StraightPath + dw OverworldMap_LightningClubPathToPsychicClub + dw OverworldMap_LightningClubPathToScienceClub + dw OverworldMap_LightningClubPathToFireClub + dw OverworldMap_StraightPath + dw OverworldMap_StraightPath + +OverworldMap_GrassClubPaths: + dw OverworldMap_GrassClubPathToMasonLaboratory + dw OverworldMap_GrassClubPathToIshiharasHouse + dw OverworldMap_StraightPath + dw OverworldMap_GrassClubPathToRockClub + dw OverworldMap_GrassClubPathToWaterClub + dw OverworldMap_StraightPath + dw OverworldMap_NoMovement + dw OverworldMap_StraightPath + dw OverworldMap_StraightPath + dw OverworldMap_StraightPath + dw OverworldMap_GrassClubPathToChallengeHall + dw OverworldMap_StraightPath + +OverworldMap_PsychicClubPaths: + dw OverworldMap_PsychicClubPathToMasonLaboratory + dw OverworldMap_PsychicClubPathToIshiharasHouse + dw OverworldMap_PsychicClubPathToFightingClub + dw OverworldMap_StraightPath + dw OverworldMap_PsychicClubPathToWaterClub + dw OverworldMap_PsychicClubPathToLightningClub + dw OverworldMap_StraightPath + dw OverworldMap_NoMovement + dw OverworldMap_StraightPath + dw OverworldMap_StraightPath + dw OverworldMap_StraightPath + dw OverworldMap_StraightPath + +OverworldMap_ScienceClubPaths: + dw OverworldMap_ScienceClubPathToMasonLaboratory + dw OverworldMap_ScienceClubPathToIshiharasHouse + dw OverworldMap_StraightPath + dw OverworldMap_ScienceClubPathToRockClub + dw OverworldMap_ScienceClubPathToWaterClub + dw OverworldMap_ScienceClubPathToLightningClub + dw OverworldMap_StraightPath + dw OverworldMap_StraightPath + dw OverworldMap_NoMovement + dw OverworldMap_StraightPath + dw OverworldMap_ScienceClubPathToChallengeHall + dw OverworldMap_StraightPath + +OverworldMap_FireClubPaths: + dw OverworldMap_FireClubPathToMasonLaboratory + dw OverworldMap_FireClubPathToIshiharasHouse + dw OverworldMap_FireClubPathToFightingClub + dw OverworldMap_FireClubPathToRockClub + dw OverworldMap_FireClubPathToWaterClub + dw OverworldMap_FireClubPathToLightningClub + dw OverworldMap_StraightPath + dw OverworldMap_StraightPath + dw OverworldMap_StraightPath + dw OverworldMap_NoMovement + dw OverworldMap_FireClubPathToChallengeHall + dw OverworldMap_FireClubPathToPokemonDome + +OverworldMap_ChallengeHallPaths: + dw OverworldMap_ChallengeHallPathToMasonLaboratory + dw OverworldMap_ChallengeHallPathToIshiharasHouse + dw OverworldMap_ChallengeHallPathToFightingClub + dw OverworldMap_StraightPath + dw OverworldMap_ChallengeHallPathToWaterClub + dw OverworldMap_StraightPath + dw OverworldMap_ChallengeHallPathToGrassClub + dw OverworldMap_StraightPath + dw OverworldMap_ChallengeHallPathToScienceClub + dw OverworldMap_ChallengeHallPathToFireClub + dw OverworldMap_NoMovement + dw OverworldMap_StraightPath + +OverworldMap_PokemonDomePaths: + dw OverworldMap_PokemonDomePathToMasonLaboratory + dw OverworldMap_PokemonDomePathToIshiharasHouse + dw OverworldMap_StraightPath + dw OverworldMap_StraightPath + dw OverworldMap_PokemonDomePathToWaterClub + dw OverworldMap_StraightPath + dw OverworldMap_StraightPath + dw OverworldMap_StraightPath + dw OverworldMap_StraightPath + dw OverworldMap_PokemonDomePathToFireClub + dw OverworldMap_StraightPath + dw OverworldMap_NoMovement + +OverworldMap_IshiharasHousePathToRockClub: +OverworldMap_RockClubPathToIshiharasHouse: + db $2c, $28 + db $00, $00 + db $ff, $ff + +OverworldMap_MasonLaboratoryPathToWaterClub: + db $2c, $78 + db $3c, $68 + db $5c, $68 + db $5c, $7c + db $74, $7c + db $00, $00 + db $ff, $ff + +OverworldMap_WaterClubPathToMasonLaboratory: + db $74, $7c + db $5c, $7c + db $5c, $68 + db $3c, $68 + db $2c, $78 + db $00, $00 + db $ff, $ff + +OverworldMap_IshiharasHousePathToFireClub: + db $2c, $28 + db $3c, $40 + db $5c, $30 + db $00, $00 + db $ff, $ff + +OverworldMap_FireClubPathToIshiharasHouse: + db $5c, $30 + db $3c, $40 + db $2c, $28 + db $00, $00 + db $ff, $ff + +OverworldMap_MasonLaboratoryPathToIshiharasHouse: + db $2c, $78 + db $3c, $68 + db $3c, $40 + db $2c, $28 + db $00, $00 + db $ff, $ff + +OverworldMap_IshiharasHousePathToMasonLaboratory: + db $2c, $28 + db $3c, $40 + db $3c, $68 + db $2c, $78 + db $00, $00 + db $ff, $ff + +OverworldMap_MasonLaboratoryPathToRockClub: + db $2c, $78 + db $3c, $68 + db $3c, $48 + db $00, $00 + db $ff, $ff + +OverworldMap_RockClubPathToMasonLaboratory: + db $3c, $48 + db $3c, $68 + db $2c, $78 + db $00, $00 + db $ff, $ff + +OverworldMap_MasonLaboratoryPathToLightningClub: +OverworldMap_LightningClubPathToMasonLaboratory: + db $2c, $78 + db $00, $00 + db $ff, $ff + +OverworldMap_MasonLaboratoryPathToGrassClub: + db $2c, $78 + db $3c, $68 + db $5c, $68 + db $00, $00 + db $ff, $ff + +OverworldMap_GrassClubPathToMasonLaboratory: + db $5c, $68 + db $3c, $68 + db $2c, $78 + db $00, $00 + db $ff, $ff + +OverworldMap_MasonLaboratoryPathToPsychicClub: + db $2c, $78 + db $3c, $68 + db $5c, $68 + db $5c, $48 + db $00, $00 + db $ff, $ff + +OverworldMap_PsychicClubPathToMasonLaboratory: + db $5c, $48 + db $5c, $68 + db $3c, $68 + db $2c, $78 + db $00, $00 + db $ff, $ff + +OverworldMap_MasonLaboratoryPathToScienceClub: + db $2c, $78 + db $3c, $68 + db $5c, $68 + db $00, $00 + db $ff, $ff + +OverworldMap_ScienceClubPathToMasonLaboratory: + db $5c, $68 + db $3c, $68 + db $2c, $78 + db $00, $00 + db $ff, $ff + +OverworldMap_MasonLaboratoryPathToFireClub: + db $2c, $78 + db $3c, $68 + db $5c, $68 + db $5c, $30 + db $00, $00 + db $ff, $ff + +OverworldMap_FireClubPathToMasonLaboratory: + db $5c, $30 + db $5c, $68 + db $3c, $68 + db $2c, $78 + db $00, $00 + db $ff, $ff + +OverworldMap_MasonLaboratoryPathToChallengeHall: + db $2c, $78 + db $3c, $68 + db $3c, $40 + db $00, $00 + db $ff, $ff + +OverworldMap_ChallengeHallPathToMasonLaboratory: + db $3c, $40 + db $3c, $68 + db $2c, $78 + db $00, $00 + db $ff, $ff + +OverworldMap_MasonLaboratoryPathToPokemonDome: + db $2c, $78 + db $3c, $68 + db $00, $00 + db $ff, $ff + +OverworldMap_PokemonDomePathToMasonLaboratory: + db $3c, $68 + db $2c, $78 + db $00, $00 + db $ff, $ff + +OverworldMap_IshiharasHousePathToFightingClub: +OverworldMap_FightingClubPathToIshiharasHouse: + db $2c, $28 + db $00, $00 + db $ff, $ff + +OverworldMap_IshiharasHousePathToWaterClub: + db $2c, $28 + db $3c, $48 + db $3c, $68 + db $5c, $68 + db $5c, $7c + db $74, $7c + db $00, $00 + db $ff, $ff + +OverworldMap_WaterClubPathToIshiharasHouse: + db $74, $7c + db $5c, $7c + db $5c, $68 + db $3c, $68 + db $3c, $48 + db $2c, $28 + db $00, $00 + db $ff, $ff + +OverworldMap_IshiharasHousePathToLightningClub: +OverworldMap_LightningClubPathToIshiharasHouse: + db $2c, $28 + db $00, $00 + db $ff, $ff + +OverworldMap_IshiharasHousePathToGrassClub: + db $2c, $28 + db $3c, $40 + db $5c, $48 + db $00, $00 + db $ff, $ff + +OverworldMap_GrassClubPathToIshiharasHouse: + db $5c, $48 + db $3c, $40 + db $2c, $28 + db $00, $00 + db $ff, $ff + +OverworldMap_IshiharasHousePathToPsychicClub: + db $2c, $28 + db $3c, $40 + db $00, $00 + db $ff, $ff + +OverworldMap_PsychicClubPathToIshiharasHouse: + db $3c, $40 + db $2c, $28 + db $00, $00 + db $ff, $ff + +OverworldMap_IshiharasHousePathToScienceClub: + db $2c, $28 + db $3c, $40 + db $5c, $48 + db $00, $00 + db $ff, $ff + +OverworldMap_ScienceClubPathToIshiharasHouse: + db $5c, $48 + db $3c, $40 + db $2c, $28 + db $00, $00 + db $ff, $ff + +OverworldMap_IshiharasHousePathToChallengeHall: + db $2c, $28 + db $3c, $40 + db $00, $00 + db $ff, $ff + +OverworldMap_ChallengeHallPathToIshiharasHouse: + db $3c, $40 + db $2c, $28 + db $00, $00 + db $ff, $ff + +OverworldMap_IshiharasHousePathToPokemonDome: + db $2c, $28 + db $3c, $48 + db $00, $00 + db $ff, $ff + +OverworldMap_PokemonDomePathToIshiharasHouse: + db $3c, $48 + db $2c, $28 + db $00, $00 + db $ff, $ff + +OverworldMap_FightingClubPathToRockClub: + db $3c, $68 + db $3c, $48 + db $00, $00 + db $ff, $ff + +OverworldMap_RockClubPathToFightingClub: + db $3c, $48 + db $3c, $68 + db $00, $00 + db $ff, $ff + +OverworldMap_FightingClubPathToWaterClub: + db $3c, $68 + db $5c, $68 + db $5c, $7c + db $74, $7c + db $00, $00 + db $ff, $ff + +OverworldMap_WaterClubPathToFightingClub: + db $74, $7c + db $5c, $7c + db $5c, $68 + db $3c, $68 + db $00, $00 + db $ff, $ff + +OverworldMap_FightingClubPathToPsychicClub: +OverworldMap_PsychicClubPathToFightingClub: + db $5c, $68 + db $00, $00 + db $ff, $ff + +OverworldMap_FightingClubPathToFireClub: + db $5c, $68 + db $5c, $30 + db $00, $00 + db $ff, $ff + +OverworldMap_FireClubPathToFightingClub: + db $5c, $30 + db $5c, $68 + db $00, $00 + db $ff, $ff + +OverworldMap_FightingClubPathToChallengeHall: +OverworldMap_ChallengeHallPathToFightingClub: + db $3c, $40 + db $00, $00 + db $ff, $ff + +OverworldMap_RockClubPathToWaterClub: + db $3c, $48 + db $3c, $68 + db $5c, $68 + db $5c, $7c + db $74, $7c + db $00, $00 + db $ff, $ff + +OverworldMap_WaterClubPathToRockClub: + db $74, $7c + db $5c, $7c + db $5c, $68 + db $3c, $68 + db $3c, $48 + db $00, $00 + db $ff, $ff + +OverworldMap_RockClubPathToGrassClub: +OverworldMap_GrassClubPathToRockClub: + db $3c, $40 + db $00, $00 + db $ff, $ff + +OverworldMap_RockClubPathToFireClub: + db $3c, $40 + db $5c, $30 + db $00, $00 + db $ff, $ff + +OverworldMap_FireClubPathToRockClub: + db $5c, $30 + db $3c, $40 + db $00, $00 + db $ff, $ff + +OverworldMap_WaterClubPathToLightningClub: + db $74, $7c + db $5c, $7c + db $5c, $68 + db $3c, $68 + db $00, $00 + db $ff, $ff + +OverworldMap_LightningClubPathToWaterClub: + db $3c, $68 + db $5c, $68 + db $5c, $7c + db $74, $7c + db $00, $00 + db $ff, $ff + +OverworldMap_WaterClubPathToGrassClub: +OverworldMap_WaterClubPathToPsychicClub: +OverworldMap_WaterClubPathToScienceClub: + db $74, $7c + db $5c, $7c + db $5c, $68 + db $00, $00 + db $ff, $ff + +OverworldMap_GrassClubPathToWaterClub: +OverworldMap_PsychicClubPathToWaterClub: +OverworldMap_ScienceClubPathToWaterClub: + db $5c, $68 + db $5c, $7c + db $74, $7c + db $00, $00 + db $ff, $ff + +OverworldMap_WaterClubPathToFireClub: + db $74, $7c + db $5c, $7c + db $5c, $30 + db $00, $00 + db $ff, $ff + +OverworldMap_FireClubPathToWaterClub: + db $5c, $30 + db $5c, $7c + db $74, $7c + db $00, $00 + db $ff, $ff + +OverworldMap_WaterClubPathToChallengeHall: + db $74, $7c + db $5c, $7c + db $5c, $48 + db $00, $00 + db $ff, $ff + +OverworldMap_ChallengeHallPathToWaterClub: + db $5c, $48 + db $5c, $7c + db $74, $7c + db $00, $00 + db $ff, $ff + +OverworldMap_WaterClubPathToPokemonDome: + db $74, $7c + db $5c, $7c + db $00, $00 + db $ff, $ff + +OverworldMap_PokemonDomePathToWaterClub: + db $5c, $7c + db $74, $7c + db $00, $00 + db $ff, $ff + +OverworldMap_LightningClubPathToPsychicClub: +OverworldMap_PsychicClubPathToLightningClub: + db $3c, $40 + db $00, $00 + db $ff, $ff + +OverworldMap_LightningClubPathToScienceClub: + db $3c, $68 + db $5c, $68 + db $00, $00 + db $ff, $ff + +OverworldMap_ScienceClubPathToLightningClub: + db $5c, $68 + db $3c, $68 + db $00, $00 + db $ff, $ff + +OverworldMap_LightningClubPathToFireClub: + db $3c, $48 + db $5c, $30 + db $00, $00 + db $ff, $ff + +OverworldMap_FireClubPathToLightningClub: + db $5c, $30 + db $3c, $48 + db $00, $00 + db $ff, $ff + +OverworldMap_GrassClubPathToChallengeHall: +OverworldMap_ScienceClubPathToChallengeHall: +OverworldMap_ChallengeHallPathToGrassClub: +OverworldMap_ChallengeHallPathToScienceClub: + db $5c, $48 + db $00, $00 + db $ff, $ff + +OverworldMap_FireClubPathToChallengeHall: +OverworldMap_FireClubPathToPokemonDome: +OverworldMap_ChallengeHallPathToFireClub: +OverworldMap_PokemonDomePathToFireClub: + db $5c, $30 + db $00, $00 + db $ff, $ff + +OverworldMap_RockClubPathToScienceClub: + db $3c, $40 + db $5c, $48 + db $00, $00 + db $ff, $ff + +OverworldMap_ScienceClubPathToRockClub: + db $5c, $48 + db $3c, $40 + db $00, $00 + db $ff, $ff + +OverworldMap_StraightPath: + db $00, $00 + db $ff, $ff + +OverworldMap_NoMovement: + db $ff, $ff diff --git a/src/engine/bank04.asm b/src/engine/bank04.asm index add4bb3..745bc04 100644 --- a/src/engine/bank04.asm +++ b/src/engine/bank04.asm @@ -2284,662 +2284,7 @@ Unknown_10e17: ; 10e17 (4:4e17) db SYM_SPACE ; tile behind cursor dw NULL ; function pointer if non-0 -; refresh the cursor's position based on the currently selected map -; and refresh the player's position based on the starting map -; but only if the player is not being animated across the overworld -OverworldMap_UpdatePlayerAndCursorSprites: ; 10e28 (4:4e28) - push hl - push bc - push de - ld a, [wOverworldMapCursorSprite] - ld [wWhichSprite], a - ld a, [wOverworldMapSelection] - ld d, 0 - ld e, -12 - call OverworldMap_SetSpritePosition - ld a, [wOverworldMapPlayerAnimationState] - or a - jr nz, .player_walking - ld a, [wPlayerSpriteIndex] - ld [wWhichSprite], a - ld a, [wOverworldMapStartingPosition] - ld d, 0 - ld e, 0 - call OverworldMap_SetSpritePosition -.player_walking - pop de - pop bc - pop hl - ret - -; if no selection has been made yet, call OverworldMap_HandleKeyPress -; if the player is being animated across the screen, call OverworldMap_UpdatePlayerWalkingAnimation -; if the player has finished walking, call OverworldMap_LoadSelectedMap -OverworldMap_Update: ; 10e55 (4:4e55) - ld a, [wPlayerSpriteIndex] - ld [wWhichSprite], a - ld a, [wOverworldMapPlayerAnimationState] - or a - jr nz, .player_walking - call OverworldMap_HandleKeyPress - ret -.player_walking - cp 2 - jr z, .player_finished_walking - call OverworldMap_UpdatePlayerWalkingAnimation - ret -.player_finished_walking - call OverworldMap_LoadSelectedMap - ret - -; update the map selection if the DPad is pressed -; or finalize the selection if the A button is pressed -OverworldMap_HandleKeyPress: ; 10e71 (4:4e71) - ldh a, [hKeysPressed] - and D_PAD - jr z, .no_d_pad - farcall GetDirectionFromDPad - ld [wPlayerDirection], a - call OverworldMap_HandleDPad - jr .done -.no_d_pad - ldh a, [hKeysPressed] - and A_BUTTON - jr z, .done - ld a, SFX_02 - call PlaySFX - call OverworldMap_UpdateCursorAnimation - call OverworldMap_BeginPlayerMovement - jr .done -.done - ret - -; update wOverworldMapSelection based on the pressed direction in wPlayerDirection -OverworldMap_HandleDPad: ; 10e97 (4:4e97) - push hl - pop hl - ld a, [wOverworldMapSelection] - rlca - rlca - ld c, a - ld a, [wPlayerDirection] - add c - ld c, a - ld b, 0 - ld hl, OverworldMap_CursorTransitions - add hl, bc - ld a, [hl] - or a - jr z, .no_transition - ld [wOverworldMapSelection], a - call OverworldMap_PrintMapName - ld a, SFX_01 - call PlaySFX -.no_transition - pop bc - pop hl - ret - -OverworldMap_CursorTransitions: ; 10ebc (4:4ebc) - ; unused - db OWMAP_SCIENCE_CLUB ; NORTH - db OWMAP_SCIENCE_CLUB ; EAST - db OWMAP_SCIENCE_CLUB ; SOUTH - db OWMAP_SCIENCE_CLUB ; WEST - - ; OWMAP_MASON_LABORATORY - db OWMAP_LIGHTNING_CLUB ; NORTH - db OWMAP_FIGHTING_CLUB ; EAST - db $00 ; SOUTH - db $00 ; WEST - - ; OWMAP_ISHIHARAS_HOUSE - db $00 ; NORTH - db OWMAP_CHALLENGE_HALL ; EAST - db OWMAP_ROCK_CLUB ; SOUTH - db $00 ; WEST - - ; OWMAP_FIGHTING_CLUB - db OWMAP_LIGHTNING_CLUB ; NORTH - db OWMAP_WATER_CLUB ; EAST - db $00 ; SOUTH - db OWMAP_MASON_LABORATORY ; WEST - - ; OWMAP_ROCK_CLUB - db OWMAP_ISHIHARAS_HOUSE ; NORTH - db OWMAP_POKEMON_DOME ; EAST - db OWMAP_LIGHTNING_CLUB ; SOUTH - db $00 ; WEST - - ; OWMAP_WATER_CLUB - db OWMAP_GRASS_CLUB ; NORTH - db $00 ; EAST - db $00 ; SOUTH - db OWMAP_FIGHTING_CLUB ; WEST - - ; OWMAP_LIGHTNING_CLUB - db OWMAP_ROCK_CLUB ; NORTH - db OWMAP_POKEMON_DOME ; EAST - db OWMAP_FIGHTING_CLUB ; SOUTH - db OWMAP_MASON_LABORATORY ; WEST - - ; OWMAP_GRASS_CLUB - db OWMAP_SCIENCE_CLUB ; NORTH - db $00 ; EAST - db OWMAP_WATER_CLUB ; SOUTH - db OWMAP_PSYCHIC_CLUB ; WEST - - ; OWMAP_PSYCHIC_CLUB - db OWMAP_FIRE_CLUB ; NORTH - db OWMAP_SCIENCE_CLUB ; EAST - db OWMAP_GRASS_CLUB ; SOUTH - db OWMAP_POKEMON_DOME ; WEST - - ; OWMAP_SCIENCE_CLUB - db OWMAP_FIRE_CLUB ; NORTH - db $00 ; EAST - db OWMAP_GRASS_CLUB ; SOUTH - db OWMAP_PSYCHIC_CLUB ; WEST - - ; OWMAP_FIRE_CLUB - db $00 ; NORTH - db OWMAP_SCIENCE_CLUB ; EAST - db OWMAP_SCIENCE_CLUB ; SOUTH - db OWMAP_PSYCHIC_CLUB ; WEST - - ; OWMAP_CHALLENGE_HALL - db $00 ; NORTH - db OWMAP_PSYCHIC_CLUB ; EAST - db OWMAP_POKEMON_DOME ; SOUTH - db OWMAP_ISHIHARAS_HOUSE ; WEST - - ; OWMAP_POKEMON_DOME - db OWMAP_CHALLENGE_HALL ; NORTH - db OWMAP_PSYCHIC_CLUB ; EAST - db OWMAP_FIGHTING_CLUB ; SOUTH - db OWMAP_ROCK_CLUB ; WEST - -; set the active sprite (player or cursor) at the appropriate map position -; input: -; a = OWMAP_* value -; d = x offset -; e = y offset -OverworldMap_SetSpritePosition: ; 10ef0 (4:4ef0) - call OverworldMap_GetMapPosition - ld c, SPRITE_ANIM_COORD_X - call GetSpriteAnimBufferProperty - ld a, d - ld [hli], a - ld a, e - ld [hl], a - ret - -; input: -; a = OWMAP_* value -; d = x offset -; e = y offset -; output: -; d = x position -; e = y position -OverworldMap_GetMapPosition: ; 10efd (4:4efd) - push hl - push de - rlca - ld e, a - ld d, 0 - ld hl, OverworldMap_MapPositions - add hl, de - pop de - ld a, [hli] - add $8 - add d - ld d, a - ld a, [hl] - add $10 - add e - ld e, a - pop hl - ret - -OverworldMap_MapPositions: ; 10f14 (4:4f14) - db $00, $00 ; unused - db $0c, $68 ; OWMAP_MASON_LABORATORY - db $04, $18 ; OWMAP_ISHIHARAS_HOUSE - db $34, $68 ; OWMAP_FIGHTING_CLUB - db $14, $38 ; OWMAP_ROCK_CLUB - db $6c, $64 ; OWMAP_WATER_CLUB - db $24, $50 ; OWMAP_LIGHTNING_CLUB - db $7c, $40 ; OWMAP_GRASS_CLUB - db $5c, $2c ; OWMAP_PSYCHIC_CLUB - db $7c, $20 ; OWMAP_SCIENCE_CLUB - db $6c, $10 ; OWMAP_FIRE_CLUB - db $3c, $20 ; OWMAP_CHALLENGE_HALL - db $44, $44 ; OWMAP_POKEMON_DOME - -OverworldMap_PrintMapName: ; 10f2e (4:4f2e) - push hl - push de - lb de, 1, 1 - call InitTextPrinting - call OverworldMap_GetOWMapID - rlca - ld e, a - ld d, 0 - ld hl, OverworldMapNames - add hl, de - ld a, [hli] - ld h, [hl] - ld l, a - call ProcessTextFromID - pop de - pop hl - ret - -; returns [wOverworldMapSelection] in a -; or OWMAP_MYSTERY_HOUSE if [wOverworldMapSelection] == OWMAP_ISHIHARAS_HOUSE -; and EVENT_ISHIHARAS_HOUSE_MENTIONED == FALSE -OverworldMap_GetOWMapID: ; 10f4a (4:4f4a) - push bc - ld a, [wOverworldMapSelection] - cp OWMAP_ISHIHARAS_HOUSE - jr nz, .got_map - ld c, a - ld a, EVENT_ISHIHARAS_HOUSE_MENTIONED - farcall GetEventValue - or a - ld a, c - jr nz, .got_map - ld a, OWMAP_MYSTERY_HOUSE -.got_map - pop bc - ret - -OverworldMap_LoadSelectedMap: ; 10f61 (4:4f61) - push hl - push bc - ld a, [wOverworldMapSelection] - rlca - rlca - ld c, a - ld b, 0 - ld hl, OverworldMapIndexes - add hl, bc - ld a, [hli] - ld [wTempMap], a - ld a, [hli] - ld [wTempPlayerXCoord], a - ld a, [hli] - ld [wTempPlayerYCoord], a - ld a, NORTH - ld [wTempPlayerDirection], a - ld hl, wOverworldTransition - set 4, [hl] - pop bc - pop hl - ret - -INCLUDE "data/overworld_indexes.asm" - -OverworldMap_InitVolcanoSprite: ; 10fbc (4:4fbc) - ld a, SPRITE_OW_MAP_OAM - farcall CreateSpriteAndAnimBufferEntry - ld c, SPRITE_ANIM_COORD_X - call GetSpriteAnimBufferProperty - ld a, $80 - ld [hli], a ; x - ld a, $10 - ld [hl], a ; y - ld b, SPRITE_ANIM_SGB_VOLCANO_SMOKE - ld a, [wConsole] - cp CONSOLE_CGB - jr nz, .not_cgb - ld b, SPRITE_ANIM_CGB_VOLCANO_SMOKE -.not_cgb - ld a, b - farcall StartNewSpriteAnimation - ret - -OverworldMap_InitCursorSprite: ; 10fde (4:4fde) - ld a, [wOverworldMapSelection] - ld [wOverworldMapStartingPosition], a - xor a - ld [wOverworldMapPlayerAnimationState], a - ld a, SPRITE_OW_MAP_OAM - call CreateSpriteAndAnimBufferEntry - ld a, [wWhichSprite] - ld [wOverworldMapCursorSprite], a - ld b, SPRITE_ANIM_SGB_OWMAP_CURSOR - ld a, [wConsole] - cp CONSOLE_CGB - jr nz, .not_cgb - ld b, SPRITE_ANIM_CGB_OWMAP_CURSOR -.not_cgb - ld a, b - ld [wOverworldMapCursorAnimation], a - call StartNewSpriteAnimation - ld a, EVENT_MASON_LAB_STATE - farcall GetEventValue - or a - jr nz, .visited_lab - ld c, SPRITE_ANIM_FLAGS - call GetSpriteAnimBufferProperty - set SPRITE_ANIM_FLAG_UNSKIPPABLE, [hl] -.visited_lab - ret - -; play animation SPRITE_ANIM_SGB_OWMAP_CURSOR_FAST (non-cgb) or SPRITE_ANIM_CGB_OWMAP_CURSOR_FAST (cgb) -; to make the cursor blink faster after a selection is made -OverworldMap_UpdateCursorAnimation: ; 11016 (4:5016) - ld a, [wOverworldMapCursorSprite] - ld [wWhichSprite], a - ld a, [wOverworldMapCursorAnimation] - inc a - call StartNewSpriteAnimation - ret - -; begin walking the player across the overworld -; from wOverworldMapStartingPosition to wOverworldMapSelection -OverworldMap_BeginPlayerMovement: ; 11024 (4:5024) - ld a, SFX_57 - call PlaySFX - ld a, [wPlayerSpriteIndex] - ld [wWhichSprite], a - ld c, SPRITE_ANIM_FLAGS - call GetSpriteAnimBufferProperty - set SPRITE_ANIM_FLAG_SPEED, [hl] - -; get pointer table for starting map - ld hl, OverworldMap_PlayerMovementPaths - ld a, [wOverworldMapStartingPosition] - dec a - add a - ld c, a - ld b, 0 - add hl, bc - ld a, [hli] - ld h, [hl] - ld l, a - -; get path sequence for selected map - ld a, [wOverworldMapSelection] - dec a - add a - ld c, a - ld b, 0 - add hl, bc - ld a, [hli] - ld [wOverworldMapPlayerMovementPtr], a - ld a, [hl] - ld [wOverworldMapPlayerMovementPtr + 1], a - - ld a, 1 - ld [wOverworldMapPlayerAnimationState], a - xor a - ld [wOverworldMapPlayerMovementCounter], a - ret - -; update the player walking across the overworld -; either by advancing along the current path -; or determining the next direction to move along the path -OverworldMap_UpdatePlayerWalkingAnimation: ; 11060 (4:5060) - ld a, [wPlayerSpriteIndex] - ld [wWhichSprite], a - ld a, [wOverworldMapPlayerMovementCounter] - or a - jp nz, OverworldMap_ContinuePlayerWalkingAnimation - -; get next x,y on the path - ld a, [wOverworldMapPlayerMovementPtr] - ld l, a - ld a, [wOverworldMapPlayerMovementPtr + 1] - ld h, a - ld a, [hli] - ld b, a - ld a, [hli] - ld c, a - and b - cp $ff - jr z, .player_finished_walking - ld a, c - or b - jr nz, .next_point - -; point 0,0 means walk straight towards [wOverworldMapSelection] - ld a, [wOverworldMapStartingPosition] - ld e, a - ld a, [wOverworldMapSelection] - cp e - jr z, .player_finished_walking - lb de, 0, 0 - call OverworldMap_GetMapPosition - ld b, d - ld c, e - -.next_point - ld a, l - ld [wOverworldMapPlayerMovementPtr], a - ld a, h - ld [wOverworldMapPlayerMovementPtr + 1], a - call OverworldMap_InitNextPlayerVelocity - ret - -.player_finished_walking - ld a, 2 - ld [wOverworldMapPlayerAnimationState], a - ret - -; input: -; b = target x position -; c = target y position -OverworldMap_InitNextPlayerVelocity: ; 110a6 (4:50a6) - push hl - push bc - ld c, SPRITE_ANIM_COORD_X - call GetSpriteAnimBufferProperty - - pop bc - ld a, b - sub [hl] ; a = target x - current x - ld [wOverworldMapPlayerPathHorizontalMovement], a - ld a, 0 - sbc 0 - ld [wOverworldMapPlayerPathHorizontalMovement + 1], a - - inc hl - ld a, c - sub [hl] ; a = target y - current y - ld [wOverworldMapPlayerPathVerticalMovement], a - ld a, 0 - sbc 0 - ld [wOverworldMapPlayerPathVerticalMovement + 1], a - - ld a, [wOverworldMapPlayerPathHorizontalMovement] - ld b, a - ld a, [wOverworldMapPlayerPathHorizontalMovement + 1] - bit 7, a - jr z, .positive -; absolute value - ld a, [wOverworldMapPlayerPathHorizontalMovement] - cpl - inc a - ld b, a - -.positive - ld a, [wOverworldMapPlayerPathVerticalMovement] - ld c, a - ld a, [wOverworldMapPlayerPathVerticalMovement + 1] - bit 7, a - jr z, .positive2 -; absolute value - ld a, [wOverworldMapPlayerPathVerticalMovement] - cpl - inc a - ld c, a - -.positive2 -; if the absolute value of wOverworldMapPlayerPathVerticalMovement is larger than -; the absolute value of wOverworldMapPlayerPathHorizontalMovement, this is dominantly -; a north/south movement. otherwise, an east/west movement - ld a, b - cp c - jr c, .north_south - call OverworldMap_InitPlayerEastWestMovement - jr .done -.north_south - call OverworldMap_InitPlayerNorthSouthMovement -.done - xor a - ld [wOverworldMapPlayerHorizontalSubPixelPosition], a - ld [wOverworldMapPlayerVerticalSubPixelPosition], a - farcall UpdatePlayerSprite - pop hl - ret - -; input: -; b = absolute value of horizontal movement distance -; c = absolute value of vertical movement distance -OverworldMap_InitPlayerEastWestMovement: ; 11102 (4:5102) -; use horizontal distance for counter - ld a, b - ld [wOverworldMapPlayerMovementCounter], a - -; de = absolute horizontal distance, for later - ld e, a - ld d, 0 - -; overwrite wOverworldMapPlayerPathHorizontalMovement with either -1.0 or +1.0 -; always move east/west by 1 pixel per frame - ld hl, wOverworldMapPlayerPathHorizontalMovement - xor a - ld [hli], a - bit 7, [hl] - jr z, .east - dec a - jr .west -.east - inc a -.west - ld [hl], a - -; divide (total vertical distance * $100) by total horizontal distance - ld b, c ; vertical distance in high byte - ld c, 0 - call DivideBCbyDE - ld a, [wOverworldMapPlayerPathVerticalMovement + 1] - bit 7, a - jr z, .positive -; restore negative sign - call OverworldMap_NegateBC -.positive - ld a, c - ld [wOverworldMapPlayerPathVerticalMovement], a - ld a, b - ld [wOverworldMapPlayerPathVerticalMovement + 1], a - -; set player direction - ld hl, wOverworldMapPlayerPathHorizontalMovement + 1 - ld a, EAST - bit 7, [hl] - jr z, .east2 - ld a, WEST -.east2 - ld [wPlayerDirection], a - ret - -; input: -; b = absolute value of horizontal movement distance -; c = absolute value of vertical movement distance -OverworldMap_InitPlayerNorthSouthMovement: ; 1113e (4:513e) -; use vertical distance for counter - ld a, c - ld [wOverworldMapPlayerMovementCounter], a - -; de = absolute vertical distance, for later - ld e, a - ld d, 0 - -; overwrite wOverworldMapPlayerPathVerticalMovement with either -1.0 or +1.0 -; always move north/south by 1 pixel per frame - ld hl, wOverworldMapPlayerPathVerticalMovement - xor a - ld [hli], a - bit 7, [hl] - jr z, .south - dec a - jr .north -.south - inc a -.north - ld [hl], a - -; divide (total horizontal distance * $100) by total vertical distance -; horizontal distance in high byte - ld c, 0 - call DivideBCbyDE - ld a, [wOverworldMapPlayerPathHorizontalMovement + 1] - bit 7, a - jr z, .positive -; restore negative sign - call OverworldMap_NegateBC -.positive - ld a, c - ld [wOverworldMapPlayerPathHorizontalMovement], a - ld a, b - ld [wOverworldMapPlayerPathHorizontalMovement + 1], a - -; set player direction - ld hl, wOverworldMapPlayerPathVerticalMovement + 1 - ld a, SOUTH - bit 7, [hl] - jr z, .south2 - ld a, NORTH -.south2 - ld [wPlayerDirection], a - ret - -; output: -; bc = bc * -1 -OverworldMap_NegateBC: ; 11179 (4:5179) - ld a, c - cpl - add 1 - ld c, a - ld a, b - cpl - adc 0 - ld b, a - ret - -; add the x/y speed to the current sprite position, -; accounting for sub-pixel position -; and decrement [wOverworldMapPlayerMovementCounter] -OverworldMap_ContinuePlayerWalkingAnimation: ; 11184 (4:5184) - ld a, [wOverworldMapPlayerHorizontalSubPixelPosition] - ld d, a - ld a, [wOverworldMapPlayerVerticalSubPixelPosition] - ld e, a - ld c, SPRITE_ANIM_COORD_X - call GetSpriteAnimBufferProperty - ld a, [wOverworldMapPlayerPathHorizontalMovement] - add d - ld d, a - ld a, [wOverworldMapPlayerPathHorizontalMovement + 1] - adc [hl] ; add carry from sub-pixel movement - ld [hl], a - inc hl - ld a, [wOverworldMapPlayerPathVerticalMovement] - add e - ld e, a - ld a, [wOverworldMapPlayerPathVerticalMovement + 1] - adc [hl] ; add carry from sub-pixel movement - ld [hl], a - ld a, d - ld [wOverworldMapPlayerHorizontalSubPixelPosition], a - ld a, e - ld [wOverworldMapPlayerVerticalSubPixelPosition], a - ld hl, wOverworldMapPlayerMovementCounter - dec [hl] - ret +INCLUDE "engine/overworld_map.asm" ; prints $ff-terminated list of text to text box ; given 2 bytes for text alignment and 2 bytes for text ID @@ -4312,7 +3657,6 @@ OverworldScriptTable: ; 1217b (4:617b) dw ScriptCommand_EndScript dw ScriptCommand_EndScript - MultichoiceTextbox_ConfigTable_ChooseDeckToDuelAgainst: ; 1224b (4:624b) db $04, $00 ; x, y to start drawing box db $10, $08 ; width, height of box @@ -4373,670 +3717,7 @@ SamRulesMultichoice_ConfigurationTable: ; 1228e (4:628e) db SYM_SPACE ; tile behind cursor dw NULL ; function pointer if non-0 -OverworldMap_PlayerMovementPaths: ; 1229f (4:629f) - dw OverworldMap_MasonLaboratoryPaths - dw OverworldMap_IshiharasHousePaths - dw OverworldMap_FightingClubPaths - dw OverworldMap_RockClubPaths - dw OverworldMap_WaterClubPaths - dw OverworldMap_LightningClubPaths - dw OverworldMap_GrassClubPaths - dw OverworldMap_PsychicClubPaths - dw OverworldMap_ScienceClubPaths - dw OverworldMap_FireClubPaths - dw OverworldMap_ChallengeHallPaths - dw OverworldMap_PokemonDomePaths - -OverworldMap_MasonLaboratoryPaths: ; 122b7 (4:62b7) - dw OverworldMap_NoMovement - dw OverworldMap_MasonLaboratoryPathToIshiharasHouse - dw OverworldMap_StraightPath - dw OverworldMap_MasonLaboratoryPathToRockClub - dw OverworldMap_MasonLaboratoryPathToWaterClub - dw OverworldMap_MasonLaboratoryPathToLightningClub - dw OverworldMap_MasonLaboratoryPathToGrassClub - dw OverworldMap_MasonLaboratoryPathToPsychicClub - dw OverworldMap_MasonLaboratoryPathToScienceClub - dw OverworldMap_MasonLaboratoryPathToFireClub - dw OverworldMap_MasonLaboratoryPathToChallengeHall - dw OverworldMap_MasonLaboratoryPathToPokemonDome - -OverworldMap_IshiharasHousePaths: ; 122cf (4:62cf) - dw OverworldMap_IshiharasHousePathToMasonLaboratory - dw OverworldMap_NoMovement - dw OverworldMap_IshiharasHousePathToFightingClub - dw OverworldMap_IshiharasHousePathToRockClub - dw OverworldMap_IshiharasHousePathToWaterClub - dw OverworldMap_IshiharasHousePathToLightningClub - dw OverworldMap_IshiharasHousePathToGrassClub - dw OverworldMap_IshiharasHousePathToPsychicClub - dw OverworldMap_IshiharasHousePathToScienceClub - dw OverworldMap_IshiharasHousePathToFireClub - dw OverworldMap_IshiharasHousePathToChallengeHall - dw OverworldMap_IshiharasHousePathToPokemonDome - -OverworldMap_FightingClubPaths: ; 122e7 (4:62e7) - dw OverworldMap_StraightPath - dw OverworldMap_FightingClubPathToIshiharasHouse - dw OverworldMap_NoMovement - dw OverworldMap_FightingClubPathToRockClub - dw OverworldMap_FightingClubPathToWaterClub - dw OverworldMap_StraightPath - dw OverworldMap_StraightPath - dw OverworldMap_FightingClubPathToPsychicClub - dw OverworldMap_StraightPath - dw OverworldMap_FightingClubPathToFireClub - dw OverworldMap_FightingClubPathToChallengeHall - dw OverworldMap_StraightPath - -OverworldMap_RockClubPaths: ; 122ff (4:62ff) - dw OverworldMap_RockClubPathToMasonLaboratory - dw OverworldMap_RockClubPathToIshiharasHouse - dw OverworldMap_RockClubPathToFightingClub - dw OverworldMap_NoMovement - dw OverworldMap_RockClubPathToWaterClub - dw OverworldMap_StraightPath - dw OverworldMap_RockClubPathToGrassClub - dw OverworldMap_StraightPath - dw OverworldMap_RockClubPathToScienceClub - dw OverworldMap_RockClubPathToFireClub - dw OverworldMap_StraightPath - dw OverworldMap_StraightPath - -OverworldMap_WaterClubPaths: ; 12317 (4:6317) - dw OverworldMap_WaterClubPathToMasonLaboratory - dw OverworldMap_WaterClubPathToIshiharasHouse - dw OverworldMap_WaterClubPathToFightingClub - dw OverworldMap_WaterClubPathToRockClub - dw OverworldMap_NoMovement - dw OverworldMap_WaterClubPathToLightningClub - dw OverworldMap_WaterClubPathToGrassClub - dw OverworldMap_WaterClubPathToPsychicClub - dw OverworldMap_WaterClubPathToScienceClub - dw OverworldMap_WaterClubPathToFireClub - dw OverworldMap_WaterClubPathToChallengeHall - dw OverworldMap_WaterClubPathToPokemonDome - -OverworldMap_LightningClubPaths: ; 1232f (4:632f) - dw OverworldMap_LightningClubPathToMasonLaboratory - dw OverworldMap_LightningClubPathToIshiharasHouse - dw OverworldMap_StraightPath - dw OverworldMap_StraightPath - dw OverworldMap_LightningClubPathToWaterClub - dw OverworldMap_NoMovement - dw OverworldMap_StraightPath - dw OverworldMap_LightningClubPathToPsychicClub - dw OverworldMap_LightningClubPathToScienceClub - dw OverworldMap_LightningClubPathToFireClub - dw OverworldMap_StraightPath - dw OverworldMap_StraightPath - -OverworldMap_GrassClubPaths: ; 12347 (4:6347) - dw OverworldMap_GrassClubPathToMasonLaboratory - dw OverworldMap_GrassClubPathToIshiharasHouse - dw OverworldMap_StraightPath - dw OverworldMap_GrassClubPathToRockClub - dw OverworldMap_GrassClubPathToWaterClub - dw OverworldMap_StraightPath - dw OverworldMap_NoMovement - dw OverworldMap_StraightPath - dw OverworldMap_StraightPath - dw OverworldMap_StraightPath - dw OverworldMap_GrassClubPathToChallengeHall - dw OverworldMap_StraightPath - -OverworldMap_PsychicClubPaths: ; 1235f (4:635f) - dw OverworldMap_PsychicClubPathToMasonLaboratory - dw OverworldMap_PsychicClubPathToIshiharasHouse - dw OverworldMap_PsychicClubPathToFightingClub - dw OverworldMap_StraightPath - dw OverworldMap_PsychicClubPathToWaterClub - dw OverworldMap_PsychicClubPathToLightningClub - dw OverworldMap_StraightPath - dw OverworldMap_NoMovement - dw OverworldMap_StraightPath - dw OverworldMap_StraightPath - dw OverworldMap_StraightPath - dw OverworldMap_StraightPath - -OverworldMap_ScienceClubPaths: ; 12377 (4:6377) - dw OverworldMap_ScienceClubPathToMasonLaboratory - dw OverworldMap_ScienceClubPathToIshiharasHouse - dw OverworldMap_StraightPath - dw OverworldMap_ScienceClubPathToRockClub - dw OverworldMap_ScienceClubPathToWaterClub - dw OverworldMap_ScienceClubPathToLightningClub - dw OverworldMap_StraightPath - dw OverworldMap_StraightPath - dw OverworldMap_NoMovement - dw OverworldMap_StraightPath - dw OverworldMap_ScienceClubPathToChallengeHall - dw OverworldMap_StraightPath - -OverworldMap_FireClubPaths: ; 1238f (4:638f) - dw OverworldMap_FireClubPathToMasonLaboratory - dw OverworldMap_FireClubPathToIshiharasHouse - dw OverworldMap_FireClubPathToFightingClub - dw OverworldMap_FireClubPathToRockClub - dw OverworldMap_FireClubPathToWaterClub - dw OverworldMap_FireClubPathToLightningClub - dw OverworldMap_StraightPath - dw OverworldMap_StraightPath - dw OverworldMap_StraightPath - dw OverworldMap_NoMovement - dw OverworldMap_FireClubPathToChallengeHall - dw OverworldMap_FireClubPathToPokemonDome - -OverworldMap_ChallengeHallPaths: ; 123a7 (4:63a7) - dw OverworldMap_ChallengeHallPathToMasonLaboratory - dw OverworldMap_ChallengeHallPathToIshiharasHouse - dw OverworldMap_ChallengeHallPathToFightingClub - dw OverworldMap_StraightPath - dw OverworldMap_ChallengeHallPathToWaterClub - dw OverworldMap_StraightPath - dw OverworldMap_ChallengeHallPathToGrassClub - dw OverworldMap_StraightPath - dw OverworldMap_ChallengeHallPathToScienceClub - dw OverworldMap_ChallengeHallPathToFireClub - dw OverworldMap_NoMovement - dw OverworldMap_StraightPath - -OverworldMap_PokemonDomePaths: ; 123bf (4:63bf) - dw OverworldMap_PokemonDomePathToMasonLaboratory - dw OverworldMap_PokemonDomePathToIshiharasHouse - dw OverworldMap_StraightPath - dw OverworldMap_StraightPath - dw OverworldMap_PokemonDomePathToWaterClub - dw OverworldMap_StraightPath - dw OverworldMap_StraightPath - dw OverworldMap_StraightPath - dw OverworldMap_StraightPath - dw OverworldMap_PokemonDomePathToFireClub - dw OverworldMap_StraightPath - dw OverworldMap_NoMovement - -OverworldMap_IshiharasHousePathToRockClub: ; 123d7 (4:63d7) -OverworldMap_RockClubPathToIshiharasHouse: ; 123d7 (4:63d7) - db $2c, $28 - db $00, $00 - db $ff, $ff - -OverworldMap_MasonLaboratoryPathToWaterClub: ; 123dd (4:63dd) - db $2c, $78 - db $3c, $68 - db $5c, $68 - db $5c, $7c - db $74, $7c - db $00, $00 - db $ff, $ff - -OverworldMap_WaterClubPathToMasonLaboratory: ; 123eb (4:63eb) - db $74, $7c - db $5c, $7c - db $5c, $68 - db $3c, $68 - db $2c, $78 - db $00, $00 - db $ff, $ff - -OverworldMap_IshiharasHousePathToFireClub: ; 123f9 (4:63f9) - db $2c, $28 - db $3c, $40 - db $5c, $30 - db $00, $00 - db $ff, $ff - -OverworldMap_FireClubPathToIshiharasHouse: ; 12403 (4:6403) - db $5c, $30 - db $3c, $40 - db $2c, $28 - db $00, $00 - db $ff, $ff - -OverworldMap_MasonLaboratoryPathToIshiharasHouse: ; 1240d (4:640d) - db $2c, $78 - db $3c, $68 - db $3c, $40 - db $2c, $28 - db $00, $00 - db $ff, $ff - -OverworldMap_IshiharasHousePathToMasonLaboratory: ; 12419 (4:6419) - db $2c, $28 - db $3c, $40 - db $3c, $68 - db $2c, $78 - db $00, $00 - db $ff, $ff - -OverworldMap_MasonLaboratoryPathToRockClub: ; 12425 (4:6425) - db $2c, $78 - db $3c, $68 - db $3c, $48 - db $00, $00 - db $ff, $ff - -OverworldMap_RockClubPathToMasonLaboratory: ; 1242f (4:642f) - db $3c, $48 - db $3c, $68 - db $2c, $78 - db $00, $00 - db $ff, $ff - -OverworldMap_MasonLaboratoryPathToLightningClub: ; 12439 (4:6439) -OverworldMap_LightningClubPathToMasonLaboratory: ; 12439 (4:6439) - db $2c, $78 - db $00, $00 - db $ff, $ff - -OverworldMap_MasonLaboratoryPathToGrassClub: ; 1243f (4:643f) - db $2c, $78 - db $3c, $68 - db $5c, $68 - db $00, $00 - db $ff, $ff - -OverworldMap_GrassClubPathToMasonLaboratory: ; 12449 (4:6449) - db $5c, $68 - db $3c, $68 - db $2c, $78 - db $00, $00 - db $ff, $ff - -OverworldMap_MasonLaboratoryPathToPsychicClub: ; 12453 (4:6453) - db $2c, $78 - db $3c, $68 - db $5c, $68 - db $5c, $48 - db $00, $00 - db $ff, $ff - -OverworldMap_PsychicClubPathToMasonLaboratory: ; 1245f (4:645f) - db $5c, $48 - db $5c, $68 - db $3c, $68 - db $2c, $78 - db $00, $00 - db $ff, $ff - -OverworldMap_MasonLaboratoryPathToScienceClub: ; 1246b (4:646b) - db $2c, $78 - db $3c, $68 - db $5c, $68 - db $00, $00 - db $ff, $ff - -OverworldMap_ScienceClubPathToMasonLaboratory: ; 12475 (4:6475) - db $5c, $68 - db $3c, $68 - db $2c, $78 - db $00, $00 - db $ff, $ff - -OverworldMap_MasonLaboratoryPathToFireClub: ; 1247f (4:647f) - db $2c, $78 - db $3c, $68 - db $5c, $68 - db $5c, $30 - db $00, $00 - db $ff, $ff - -OverworldMap_FireClubPathToMasonLaboratory: ; 1248b (4:648b) - db $5c, $30 - db $5c, $68 - db $3c, $68 - db $2c, $78 - db $00, $00 - db $ff, $ff - -OverworldMap_MasonLaboratoryPathToChallengeHall: ; 12497 (4:6497) - db $2c, $78 - db $3c, $68 - db $3c, $40 - db $00, $00 - db $ff, $ff - -OverworldMap_ChallengeHallPathToMasonLaboratory: ; 124a1 (4:64a1) - db $3c, $40 - db $3c, $68 - db $2c, $78 - db $00, $00 - db $ff, $ff - -OverworldMap_MasonLaboratoryPathToPokemonDome: ; 124ab (4:64ab) - db $2c, $78 - db $3c, $68 - db $00, $00 - db $ff, $ff - -OverworldMap_PokemonDomePathToMasonLaboratory: ; 124b3 (4:64b3) - db $3c, $68 - db $2c, $78 - db $00, $00 - db $ff, $ff - -OverworldMap_IshiharasHousePathToFightingClub: ; 124bb (4:64bb) -OverworldMap_FightingClubPathToIshiharasHouse: ; 124bb (4:64bb) - db $2c, $28 - db $00, $00 - db $ff, $ff - -OverworldMap_IshiharasHousePathToWaterClub: ; 124c1 (4:64c1) - db $2c, $28 - db $3c, $48 - db $3c, $68 - db $5c, $68 - db $5c, $7c - db $74, $7c - db $00, $00 - db $ff, $ff - -OverworldMap_WaterClubPathToIshiharasHouse: ; 124d1 (4:64d1) - db $74, $7c - db $5c, $7c - db $5c, $68 - db $3c, $68 - db $3c, $48 - db $2c, $28 - db $00, $00 - db $ff, $ff - -OverworldMap_IshiharasHousePathToLightningClub: ; 124e1 (4:64e1) -OverworldMap_LightningClubPathToIshiharasHouse: ; 124e1 (4:64e1) - db $2c, $28 - db $00, $00 - db $ff, $ff - -OverworldMap_IshiharasHousePathToGrassClub: ; 124e7 (4:64e7) - db $2c, $28 - db $3c, $40 - db $5c, $48 - db $00, $00 - db $ff, $ff - -OverworldMap_GrassClubPathToIshiharasHouse: ; 124f1 (4:64f1) - db $5c, $48 - db $3c, $40 - db $2c, $28 - db $00, $00 - db $ff, $ff - -OverworldMap_IshiharasHousePathToPsychicClub: ; 124fb (4:64fb) - db $2c, $28 - db $3c, $40 - db $00, $00 - db $ff, $ff - -OverworldMap_PsychicClubPathToIshiharasHouse: ; 12503 (4:6503) - db $3c, $40 - db $2c, $28 - db $00, $00 - db $ff, $ff - -OverworldMap_IshiharasHousePathToScienceClub: ; 1250b (4:650b) - db $2c, $28 - db $3c, $40 - db $5c, $48 - db $00, $00 - db $ff, $ff - -OverworldMap_ScienceClubPathToIshiharasHouse: ; 12515 (4:6515) - db $5c, $48 - db $3c, $40 - db $2c, $28 - db $00, $00 - db $ff, $ff - -OverworldMap_IshiharasHousePathToChallengeHall: ; 1251f (4:651f) - db $2c, $28 - db $3c, $40 - db $00, $00 - db $ff, $ff - -OverworldMap_ChallengeHallPathToIshiharasHouse: ; 12527 (4:6527) - db $3c, $40 - db $2c, $28 - db $00, $00 - db $ff, $ff - -OverworldMap_IshiharasHousePathToPokemonDome: ; 1252f (4:652f) - db $2c, $28 - db $3c, $48 - db $00, $00 - db $ff, $ff - -OverworldMap_PokemonDomePathToIshiharasHouse: ; 12537 (4:6537) - db $3c, $48 - db $2c, $28 - db $00, $00 - db $ff, $ff - -OverworldMap_FightingClubPathToRockClub: ; 1253f (4:653f) - db $3c, $68 - db $3c, $48 - db $00, $00 - db $ff, $ff - -OverworldMap_RockClubPathToFightingClub: ; 12547 (4:6547) - db $3c, $48 - db $3c, $68 - db $00, $00 - db $ff, $ff - -OverworldMap_FightingClubPathToWaterClub: ; 1254f (4:654f) - db $3c, $68 - db $5c, $68 - db $5c, $7c - db $74, $7c - db $00, $00 - db $ff, $ff - -OverworldMap_WaterClubPathToFightingClub: ; 1255b (4:655b) - db $74, $7c - db $5c, $7c - db $5c, $68 - db $3c, $68 - db $00, $00 - db $ff, $ff - -OverworldMap_FightingClubPathToPsychicClub: ; 12567 (4:6567) -OverworldMap_PsychicClubPathToFightingClub: ; 12567 (4:6567) - db $5c, $68 - db $00, $00 - db $ff, $ff - -OverworldMap_FightingClubPathToFireClub: ; 1256d (4:656d) - db $5c, $68 - db $5c, $30 - db $00, $00 - db $ff, $ff - -OverworldMap_FireClubPathToFightingClub: ; 12575 (4:6575) - db $5c, $30 - db $5c, $68 - db $00, $00 - db $ff, $ff - -OverworldMap_FightingClubPathToChallengeHall: ; 1257d (4:657d) -OverworldMap_ChallengeHallPathToFightingClub: ; 1257d (4:657d) - db $3c, $40 - db $00, $00 - db $ff, $ff - -OverworldMap_RockClubPathToWaterClub: ; 12583 (4:6583) - db $3c, $48 - db $3c, $68 - db $5c, $68 - db $5c, $7c - db $74, $7c - db $00, $00 - db $ff, $ff - -OverworldMap_WaterClubPathToRockClub: ; 12591 (4:6591) - db $74, $7c - db $5c, $7c - db $5c, $68 - db $3c, $68 - db $3c, $48 - db $00, $00 - db $ff, $ff - -OverworldMap_RockClubPathToGrassClub: ; 1259f (4:659f) -OverworldMap_GrassClubPathToRockClub: ; 1259f (4:659f) - db $3c, $40 - db $00, $00 - db $ff, $ff - -OverworldMap_RockClubPathToFireClub: ; 125a5 (4:65a5) - db $3c, $40 - db $5c, $30 - db $00, $00 - db $ff, $ff - -OverworldMap_FireClubPathToRockClub: ; 125ad (4:65ad) - db $5c, $30 - db $3c, $40 - db $00, $00 - db $ff, $ff - -OverworldMap_WaterClubPathToLightningClub: ; 125b5 (4:65b5) - db $74, $7c - db $5c, $7c - db $5c, $68 - db $3c, $68 - db $00, $00 - db $ff, $ff - -OverworldMap_LightningClubPathToWaterClub: ; 125c1 (4:65c1) - db $3c, $68 - db $5c, $68 - db $5c, $7c - db $74, $7c - db $00, $00 - db $ff, $ff - -OverworldMap_WaterClubPathToGrassClub: ; 125cd (4:65cd) -OverworldMap_WaterClubPathToPsychicClub: ; 125cd (4:65cd) -OverworldMap_WaterClubPathToScienceClub: ; 125cd (4:65cd) - db $74, $7c - db $5c, $7c - db $5c, $68 - db $00, $00 - db $ff, $ff - -OverworldMap_GrassClubPathToWaterClub: ; 125d7 (4:65d7) -OverworldMap_PsychicClubPathToWaterClub: ; 125d7 (4:65d7) -OverworldMap_ScienceClubPathToWaterClub: ; 125d7 (4:65d7) - db $5c, $68 - db $5c, $7c - db $74, $7c - db $00, $00 - db $ff, $ff - -OverworldMap_WaterClubPathToFireClub: ; 125e1 (4:65e1) - db $74, $7c - db $5c, $7c - db $5c, $30 - db $00, $00 - db $ff, $ff - -OverworldMap_FireClubPathToWaterClub: ; 125eb (4:65eb) - db $5c, $30 - db $5c, $7c - db $74, $7c - db $00, $00 - db $ff, $ff - -OverworldMap_WaterClubPathToChallengeHall: ; 125f5 (4:65f5) - db $74, $7c - db $5c, $7c - db $5c, $48 - db $00, $00 - db $ff, $ff - -OverworldMap_ChallengeHallPathToWaterClub: ; 125ff (4:65ff) - db $5c, $48 - db $5c, $7c - db $74, $7c - db $00, $00 - db $ff, $ff - -OverworldMap_WaterClubPathToPokemonDome: ; 12609 (4:6609) - db $74, $7c - db $5c, $7c - db $00, $00 - db $ff, $ff - -OverworldMap_PokemonDomePathToWaterClub: ; 12611 (4:6611) - db $5c, $7c - db $74, $7c - db $00, $00 - db $ff, $ff - -OverworldMap_LightningClubPathToPsychicClub: ; 12619 (4:6619) -OverworldMap_PsychicClubPathToLightningClub: ; 12619 (4:6619) - db $3c, $40 - db $00, $00 - db $ff, $ff - -OverworldMap_LightningClubPathToScienceClub: ; 1261f (4:661f) - db $3c, $68 - db $5c, $68 - db $00, $00 - db $ff, $ff - -OverworldMap_ScienceClubPathToLightningClub: ; 12627 (4:6627) - db $5c, $68 - db $3c, $68 - db $00, $00 - db $ff, $ff - -OverworldMap_LightningClubPathToFireClub: ; 1262f (4:662f) - db $3c, $48 - db $5c, $30 - db $00, $00 - db $ff, $ff - -OverworldMap_FireClubPathToLightningClub: ; 12637 (4:6637) - db $5c, $30 - db $3c, $48 - db $00, $00 - db $ff, $ff - -OverworldMap_GrassClubPathToChallengeHall: ; 1263f (4:663f) -OverworldMap_ScienceClubPathToChallengeHall: ; 1263f (4:663f) -OverworldMap_ChallengeHallPathToGrassClub: ; 1263f (4:663f) -OverworldMap_ChallengeHallPathToScienceClub: ; 1263f (4:663f) - db $5c, $48 - db $00, $00 - db $ff, $ff - -OverworldMap_FireClubPathToChallengeHall: ; 12645 (4:6645) -OverworldMap_FireClubPathToPokemonDome: ; 12645 (4:6645) -OverworldMap_ChallengeHallPathToFireClub: ; 12645 (4:6645) -OverworldMap_PokemonDomePathToFireClub: ; 12645 (4:6645) - db $5c, $30 - db $00, $00 - db $ff, $ff - -OverworldMap_RockClubPathToScienceClub: ; 1264b (4:664b) - db $3c, $40 - db $5c, $48 - db $00, $00 - db $ff, $ff - -OverworldMap_ScienceClubPathToRockClub: ; 12653 (4:6653) - db $5c, $48 - db $3c, $40 - db $00, $00 - db $ff, $ff - -OverworldMap_StraightPath: ; 1265b (4:665b) - db $00, $00 - db $ff, $ff - -OverworldMap_NoMovement: ; 1265f (4:665f) - db $ff, $ff +INCLUDE "data/overworld_map/player_movement_paths.asm" ; unreferenced debug menu Func_12661: ; 12661 (4:6661) @@ -6897,836 +5578,7 @@ BoosterLogoOAM: ; 13132 (4:7132) db $18, $30, $1e, $00 db $18, $38, $1f, $00 -Func_131b3: ; 131b3 (4:71b3) - call ChallengeMachine_Initialize - call EnableSRAM - xor a - ld [sTotalChallengeMachineWins], a - ld [sTotalChallengeMachineWins + 1], a - ld [sPresentConsecutiveWins], a - ld [sPresentConsecutiveWins + 1], a - ld [sPresentConsecutiveWinsBackup], a - ld [sPresentConsecutiveWinsBackup + 1], a - ld [sPlayerInChallengeMachine], a - call DisableSRAM - ret - -; if a challenge is already in progress, then resume -; otherwise, start a new 5 round challenge -ChallengeMachine_Start: ; 131d3 (4:71d3) - ld a, 0 - ld [wLineSeparation], a - call Func_10a9b - call ChallengeMachine_Initialize - - call EnableSRAM - ld a, [sPlayerInChallengeMachine] - call DisableSRAM - cp $ff - jr z, .resume_challenge - -; new challenge - call ChallengeMachine_PickOpponentSequence - call ChallengeMachine_DrawScoreScreen - call FlashWhiteScreen - ldtx hl, PlayTheChallengeMachineText - call YesOrNoMenuWithText_SetCursorToYes - jp c, .end_challenge - - ldtx hl, LetUsChooseYourOpponentText - call PrintScrollableText_NoTextBoxLabel - call Func_10ab4 - call EnableSRAM - xor a - ld [sPresentConsecutiveWinsBackup], a - ld [sPresentConsecutiveWinsBackup + 1], a - call DisableSRAM - - call ChallengeMachine_DrawOpponentList - call FlashWhiteScreen - ldtx hl, YourOpponentsForThisGameText - call PrintScrollableText_NoTextBoxLabel -; begin challenge loop -.next_opponent - call ChallengeMachine_GetCurrentOpponent - call ChallengeMachine_AreYouReady - jr nc, .start_duel - ldtx hl, IfYouQuitTheDuelText - call PrintScrollableText_NoTextBoxLabel - ldtx hl, WouldYouLikeToQuitTheDuelText - call YesOrNoMenuWithText - jr c, .next_opponent - jp .quit - -.start_duel - call EnableSRAM - ld a, $ff - ld [sPlayerInChallengeMachine], a - call DisableSRAM - call ChallengeMachine_Duel -.resume_challenge - call EnableSRAM - xor a - ld [sPlayerInChallengeMachine], a - bank1call DiscardSavedDuelData - call DisableSRAM - call ChallengeMachine_GetCurrentOpponent - call ChallengeMachine_RecordDuelResult - call ChallengeMachine_DrawOpponentList - call FlashWhiteScreen - ld a, [wDuelResult] - or a - jr nz, .lost -; won - call ChallengeMachine_DuelWon - call EnableSRAM - ld a, [sChallengeMachineOpponentNumber] - cp NUM_CHALLENGE_MACHINE_OPPONENTS - 1 - jr z, .defeated_five_opponents - ld hl, sChallengeMachineOpponentNumber - inc [hl] - call DisableSRAM - jr .next_opponent - -.defeated_five_opponents - ld hl, sTotalChallengeMachineWins - call ChallengeMachine_IncrementHLMax999 - call Func_10ab4 - call ChallengeMachine_CheckForNewRecord - call ChallengeMachine_DrawScoreScreen - call FlashWhiteScreen - call EnableSRAM - ld a, [sTotalChallengeMachineWins] - ld [wTxRam3], a - ld a, [sTotalChallengeMachineWins + 1] - ld [wTxRam3 + 1], a - call DisableSRAM - ldtx hl, SuccessfullyDefeated5OpponentsText - call PrintScrollableText_NoTextBoxLabel - jr .end_challenge - -.lost - call ChallengeMachine_GetCurrentOpponent - call EnableSRAM - ld a, [sChallengeMachineOpponentNumber] - inc a - ld [wTxRam3], a - xor a - ld [wTxRam3 + 1], a - call DisableSRAM - call ChallengeMachine_GetOpponentNameAndDeck - ld a, [wOpponentName] - ld [wTxRam2], a - ld a, [wOpponentName + 1] - ld [wTxRam2 + 1], a - ldtx hl, LostToTheNthOpponentText - call PrintScrollableText_NoTextBoxLabel -.quit - call ChallengeMachine_PrintFinalConsecutiveWinStreak - call Func_10ab4 - call ChallengeMachine_CheckForNewRecord - call ChallengeMachine_DrawScoreScreen - call FlashWhiteScreen - call EnableSRAM -; reset streak - xor a - ld [sPresentConsecutiveWins], a - ld [sPresentConsecutiveWins + 1], a - call DisableSRAM -.end_challenge ; end, win or lose - call ChallengeMachine_CheckForNewRecord ; redundant? - call EnableSRAM - ld a, [sPresentConsecutiveWins] - ld [sPresentConsecutiveWinsBackup], a - ld a, [sPresentConsecutiveWins + 1] - ld [sPresentConsecutiveWinsBackup + 1], a - call ChallengeMachine_ShowNewRecord - call DisableSRAM - ldtx hl, WeAwaitYourNextChallengeText - call PrintScrollableText_NoTextBoxLabel - ret - -; update wChallengeMachineOpponent with the current -; opponent in the sChallengeMachineOpponents list -ChallengeMachine_GetCurrentOpponent: ; 1330b (4:730b) - call EnableSRAM - ld a, [sChallengeMachineOpponentNumber] - ld e, a - ld d, 0 - ld hl, sChallengeMachineOpponents - add hl, de - ld a, [hl] - ld [wChallengeMachineOpponent], a - call DisableSRAM - ret - -; play the appropriate match start theme -; then duel the current opponent -ChallengeMachine_Duel: ; 13320 (4:7320) - call ChallengeMachine_PrepareDuel - call EnableSRAM - ld a, [sChallengeMachineOpponentNumber] - ld e, a - call DisableSRAM - ld d, 0 - ld hl, ChallengeMachine_SongIDs - add hl, de - ld a, [hl] - call PlaySong - call WaitForSongToFinish - xor a - ld [wSongOverride], a - call SaveGeneralSaveData - bank1call StartDuel_VSAIOpp - ret - -ChallengeMachine_SongIDs: ; 13345 (4:7345) - db MUSIC_MATCH_START_1 - db MUSIC_MATCH_START_1 - db MUSIC_MATCH_START_1 - db MUSIC_MATCH_START_2 - db MUSIC_MATCH_START_2 - -; get the current opponent's name, deck, and prize count -ChallengeMachine_PrepareDuel: ; 1334a (4:734a) - call ChallengeMachine_GetOpponentNameAndDeck - call EnableSRAM - ld a, [sChallengeMachineOpponentNumber] - ld e, a - call DisableSRAM - ld d, 0 - ld hl, ChallengeMachine_Prizes - add hl, de - ld a, [hl] - ld [wNPCDuelPrizes], a - ret - -ChallengeMachine_Prizes: ; 13362 (4:7362) - db PRIZES_4 - db PRIZES_4 - db PRIZES_4 - db PRIZES_6 - db PRIZES_6 - -; store the result of the last duel in the current -; position of the sChallengeMachineDuelResults list -ChallengeMachine_RecordDuelResult: ; 13367 (4:7367) - call EnableSRAM - ld a, [sChallengeMachineOpponentNumber] - ld e, a - ld d, 0 - ld hl, sChallengeMachineDuelResults - add hl, de - ld a, [wDuelResult] - or a - jr nz, .lost - ld a, 1 ; won - ld [hl], a - call DisableSRAM - ld hl, sPresentConsecutiveWins - call ChallengeMachine_IncrementHLMax999 - ret - -.lost - ld a, 2 ; lost - ld [hl], a - call DisableSRAM - ret - -; increment the value at hl -; without going above 999 -ChallengeMachine_IncrementHLMax999: ; 1338e (4:738e) - call EnableSRAM - inc hl - ld a, [hld] - cp HIGH(999) - jr nz, .increment - ld a, [hl] - cp LOW(999) - jr z, .skip -.increment - ld a, [hl] - add 1 - ld [hli], a - ld a, [hl] - adc 0 - ld [hl], a -.skip - call DisableSRAM - ret - -; update sMaximumConsecutiveWins if the player set a new record -ChallengeMachine_CheckForNewRecord: ; 133a8 (4:73a8) - call EnableSRAM - ld hl, sMaximumConsecutiveWins + 1 - ld a, [sPresentConsecutiveWins + 1] - cp [hl] - jr nz, .high_bytes_different -; high bytes equal, check low bytes - dec hl - ld a, [sPresentConsecutiveWins] - cp [hl] -.high_bytes_different - jr c, .no_record - jr z, .no_record -; new record - ld hl, sMaximumConsecutiveWins - ld a, [sPresentConsecutiveWins] - ld [hli], a - ld a, [sPresentConsecutiveWins + 1] - ld [hl], a - ld hl, sPlayerName - ld de, sChallengeMachineRecordHolderName - ld bc, NAME_BUFFER_LENGTH - call CopyDataHLtoDE_SaveRegisters -; remember to show congrats message later - ld a, TRUE - ld [sConsecutiveWinRecordIncreased], a -.no_record - call DisableSRAM - ret - -; print the next opponent's name and ask the -; player if they want to begin the next duel -ChallengeMachine_AreYouReady: ; 133dd (4:73dd) - call EnableSRAM - ld a, [sChallengeMachineOpponentNumber] - inc a - ld [wTxRam3], a - ld [wTxRam3_b], a - xor a - ld [wTxRam3 + 1], a - ld [wTxRam3_b + 1], a - ldtx hl, NthOpponentIsText - ld a, [sPresentConsecutiveWins + 1] - or a - jr nz, .streak - ld a, [sPresentConsecutiveWins] - cp 2 - jr c, .no_streak -.streak - ldtx hl, XConsecutiveWinsNthOpponentIsText - ld a, [sPresentConsecutiveWins] - ld [wTxRam3], a - ld a, [sPresentConsecutiveWins + 1] - ld [wTxRam3 + 1], a -.no_streak - call DisableSRAM - push hl ; text id - call ChallengeMachine_GetOpponentNameAndDeck - ld a, [wOpponentName] - ld [wTxRam2], a - ld a, [wOpponentName + 1] - ld [wTxRam2 + 1], a - pop hl ; text id - call PrintScrollableText_NoTextBoxLabel - ldtx hl, WouldYouLikeToBeginTheDuelText - call YesOrNoMenuWithText_SetCursorToYes - ret - -; print opponent win count -; play a jingle for beating 5 opponents -ChallengeMachine_DuelWon: ; 1342e (4:742e) - call EnableSRAM - ld a, [sChallengeMachineOpponentNumber] - inc a - ld [wTxRam3], a - xor a - ld [wTxRam3 + 1], a - ldtx hl, WonAgainstXOpponentsText - ld a, [sChallengeMachineOpponentNumber] - call DisableSRAM - cp NUM_CHALLENGE_MACHINE_OPPONENTS - 1 - jr z, .beat_five_opponents - call PrintScrollableText_NoTextBoxLabel - ret - -.beat_five_opponents - call PauseSong - ld a, MUSIC_MEDAL - call PlaySong - ldtx hl, Defeated5OpponentsText - call PrintScrollableText_NoTextBoxLabel - call WaitForSongToFinish - call ResumeSong - ret - -; when a player's streak ends, print the final -; consecutive win count -ChallengeMachine_PrintFinalConsecutiveWinStreak: ; 13462 (4:7462) - call EnableSRAM - ld a, [sPresentConsecutiveWins] - ld [wTxRam3], a - ld a, [sPresentConsecutiveWins + 1] - ld [wTxRam3 + 1], a - or a - jr nz, .streak - ld a, [sPresentConsecutiveWins] - cp 2 - jr c, .no_streak -.streak - ldtx hl, ConsecutiveWinsEndedAtText - call PrintScrollableText_NoTextBoxLabel -.no_streak - call DisableSRAM - ret - -; if the player achieved a new record, play a jingle -; otherwise, do nothing -ChallengeMachine_ShowNewRecord: ; 13485 (4:7485) - call EnableSRAM - ld a, [sConsecutiveWinRecordIncreased] - or a - ret z ; no new record - ld a, [sMaximumConsecutiveWins] - ld [wTxRam3], a - ld a, [sMaximumConsecutiveWins + 1] - ld [wTxRam3 + 1], a - call DisableSRAM - call PauseSong - ld a, MUSIC_MEDAL - call PlaySong - ldtx hl, ConsecutiveWinRecordIncreasedText - call PrintScrollableText_NoTextBoxLabel - call WaitForSongToFinish - call ResumeSong - ret - -ChallengeMachine_DrawScoreScreen: ; 134b1 (4:74b1) - call Func_10000 - lb de, $30, $bf - call SetupText - lb de, 0, 0 - lb bc, 20, 13 - call DrawRegularTextBox - lb de, 0, 12 - lb bc, 20, 6 - call DrawRegularTextBox - call EnableSRAM - ld hl, sChallengeMachineRecordHolderName - ld de, wDefaultText - ld bc, NAME_BUFFER_LENGTH - call CopyDataHLtoDE - call DisableSRAM - xor a - ld [wTxRam2], a - ld [wTxRam2 + 1], a - ld hl, ChallengeMachine_PlayerScoreTexts - call Func_111b3 - ld hl, ChallengeMachine_PlayerScoreValues - call ChallengeMachine_PrintScores - ret - -ChallengeMachine_PlayerScoreTexts: ; 134f2 (4:74f2) - db 1, 0 - tx ChallengeMachineText - - db 1, 2 - tx PlayersScoreText - - db 2, 4 - tx Defeated5OpponentsXTimesText - - db 2, 6 - tx PresentConsecutiveWinsText - - db 1, 8 - tx MaximumConsecutiveWinsText - - db 17, 6 - tx WinsText - - db 16, 10 - tx WinsText - db $ff - -ChallengeMachine_PlayerScoreValues: ; 1350f (4:750f) - dw sTotalChallengeMachineWins - db 12, 4 - - dw sPresentConsecutiveWins - db 14, 6 - - dw sMaximumConsecutiveWins - db 13, 10 - - dw NULL - -ChallengeMachine_DrawOpponentList: ; 1351d (4:751d) - call Func_10000 - lb de, $30, $bf - call SetupText - lb de, 0, 0 - lb bc, 20, 13 - call DrawRegularTextBox - lb de, 0, 12 - lb bc, 20, 6 - call DrawRegularTextBox - ld hl, ChallengeMachine_OpponentNumberTexts - call Func_111b3 - call ChallengeMachine_PrintOpponentInfo - call ChallengeMachine_PrintDuelResultIcons - ret - -ChallengeMachine_OpponentNumberTexts: ; 13545 (4:7545) - db 1, 0 - tx ChallengeMachineText - - db 2, 2 - tx ChallengeMachineOpponent1Text - - db 2, 4 - tx ChallengeMachineOpponent2Text - - db 2, 6 - tx ChallengeMachineOpponent3Text - - db 2, 8 - tx ChallengeMachineOpponent4Text - - db 2, 10 - tx ChallengeMachineOpponent5Text - db $ff - -ChallengeMachine_PrintOpponentInfo: ; 1355e (4:755e) - ld hl, sChallengeMachineOpponents - ld bc, 2 ; beginning y-pos - ld e, NUM_CHALLENGE_MACHINE_OPPONENTS -.loop - push hl - push bc - push de - call EnableSRAM - ld a, [hl] - ld [wChallengeMachineOpponent], a - ld b, 14 ; x-pos - call ChallengeMachine_PrintOpponentName - ld b, 4 ; x-pos - call ChallengeMachine_PrintOpponentClubStatus - pop de - pop bc - pop hl - inc hl - -; down two rows - inc c - inc c - - dec e - jr nz, .loop - call DisableSRAM - ret - -ChallengeMachine_PrintOpponentName: ; 13587 (4:7587) - push bc - call ChallengeMachine_GetOpponentNameAndDeck - ld de, 2 ; name - add hl, de - call ChallengeMachine_PrintText - pop bc - ret - -ChallengeMachine_PrintText: ; 13594 (4:7594) - ld a, [hli] - ld h, [hl] - ld l, a - ld e, c - ld d, b - push de - call InitTextPrinting - call PrintTextNoDelay - pop de - ret - -; print the opponent's rank and element -ChallengeMachine_PrintOpponentClubStatus: ; 135a2 (4:75a2) - push bc - call ChallengeMachine_GetOpponentNameAndDeck - push hl - ld de, 6 ; rank - add hl, de - call ChallengeMachine_PrintText - ld a, d - add $07 - ld d, a - call InitTextPrinting - pop hl - ld bc, 8 ; element - add hl, bc - ld a, [hli] - ld h, [hl] - ld l, a - or h - jr z, .no_element - call PrintTextNoDelay -.no_element - pop bc - ret - -ChallengeMachine_GetOpponentNameAndDeck: ; 135c5 (4:75c5) - push de - ld a, [wChallengeMachineOpponent] - ld e, a - ld d, 0 - ld hl, ChallengeMachine_OpponentDeckIDs - add hl, de - ld a, [hl] - ld [wNPCDuelDeckID], a - call _GetChallengeMachineDuelConfigurations - pop de - ret - -ChallengeMachine_PrintDuelResultIcons: ; 135d9 (4:75d9) - ld hl, sChallengeMachineDuelResults - ld c, NUM_CHALLENGE_MACHINE_OPPONENTS - lb de, 1, 2 -.print_loop - push hl - push bc - push de - call InitTextPrinting - call EnableSRAM - ld a, [hl] - add a - ld e, a - ld d, 0 - ld hl, ChallengeMachine_DuelResultIcons - add hl, de - ld a, [hli] - ld h, [hl] - ld l, a - call PrintTextNoDelay - pop de - pop bc - pop hl - inc hl - -; down two rows - inc e - inc e - - dec c - jr nz, .print_loop - call DisableSRAM - ret - -ChallengeMachine_DuelResultIcons: ; 13606 (4:7606) - tx ChallengeMachineNotDuelledIconText - tx ChallengeMachineDuelWonIconText - tx ChallengeMachineDuelLostIconText - -; print all scores in the table pointed to by hl -ChallengeMachine_PrintScores: ; 1360c (4:760c) -.loop - call EnableSRAM - ld a, [hli] - ld e, a - ld a, [hli] - ld d, a - or e - jr z, .done - ld b, [hl] - inc hl - ld c, [hl] - inc hl - push hl - push bc - ld a, [de] - ld l, a - inc de - ld a, [de] - ld h, a - call Func_10217 - pop bc - call BCCoordToBGMap0Address - ld hl, wd4b4 - ld b, 3 - call SafeCopyDataHLtoDE - pop hl - jr .loop - -.done - call DisableSRAM - ret - -; if this is the first time the challenge machine has ever -; been used on this cartridge, then clear all vars and -; set Dr. Mason as the record holder -ChallengeMachine_Initialize: ; 13637 (4:7637) - call EnableSRAM - ld a, [sChallengeMachineMagic] - cp $e3 - jr nz, .init_vars - ld a, [sChallengeMachineMagic + 1] - cp $95 - jr z, .done - -.init_vars - ld hl, sChallengeMachineMagic - ld c, sChallengeMachineEnd - sChallengeMachineStart - ld a, $e3 - ld [hli], a - ld a, $95 - ld [hli], a - - xor a -.clear_loop - ld [hli], a - dec c - jr nz, .clear_loop - - ld hl, ChallengeMachine_DrMasonText - ld de, sChallengeMachineRecordHolderName - ld bc, NAME_BUFFER_LENGTH - call CopyDataHLtoDE_SaveRegisters - ld a, 1 - ld [sMaximumConsecutiveWins], a - xor a - ld [sMaximumConsecutiveWins + 1], a - -.done - ld a, [sPlayerInChallengeMachine] - call DisableSRAM - ret - -ChallengeMachine_DrMasonText: ; 13674 (4:7674) - text "Dr. Mason", TX_END, TX_END, TX_END, TX_END, TX_END, TX_END - -; pick the next opponent sequence and clear challenge vars -ChallengeMachine_PickOpponentSequence: ; 13684 (4:7684) - call EnableSRAM - -; pick first opponent - ld a, CLUB_MASTERS_START - call Random - ld [sChallengeMachineOpponents], a - -.pick_second_opponent - ld a, CLUB_MASTERS_START - call Random - ld c, 1 - call ChallengeMachine_CheckIfOpponentAlreadySelected - jr c, .pick_second_opponent - ld [sChallengeMachineOpponents + 1], a - -.pick_third_opponent - ld a, CLUB_MASTERS_START - call Random - ld c, 2 - call ChallengeMachine_CheckIfOpponentAlreadySelected - jr c, .pick_third_opponent - ld [sChallengeMachineOpponents + 2], a - -; pick fourth opponent - ld a, GRAND_MASTERS_START - CLUB_MASTERS_START - call Random - add CLUB_MASTERS_START - ld [sChallengeMachineOpponents + 3], a - -; pick fifth opponent - call UpdateRNGSources - ld hl, ChallengeMachine_FinalOpponentProbabilities -.next - sub [hl] - jr c, .got_opponent - inc hl - inc hl - jr .next -.got_opponent - inc hl - ld a, [hl] - ld [sChallengeMachineOpponents + 4], a - - xor a - ld [sChallengeMachineOpponentNumber], a - ld [sConsecutiveWinRecordIncreased], a - ld hl, sChallengeMachineDuelResults - ld c, NUM_CHALLENGE_MACHINE_OPPONENTS -.clear_results - ld [hli], a - dec c - jr nz, .clear_results - ld a, [sPresentConsecutiveWinsBackup] - ld [sPresentConsecutiveWins], a - ld a, [sPresentConsecutiveWinsBackup + 1] - ld [sPresentConsecutiveWins + 1], a - call DisableSRAM - ret - -ChallengeMachine_FinalOpponentProbabilities: ; 136e9 (4:76e9) - db 56, GRAND_MASTERS_START + 0 ; 56/256, courtney - db 56, GRAND_MASTERS_START + 1 ; 56/256, steve - db 56, GRAND_MASTERS_START + 2 ; 56/256, jack - db 56, GRAND_MASTERS_START + 3 ; 56/256, rod - db 8, GRAND_MASTERS_START + 4 ; 8/256, aaron - db 8, GRAND_MASTERS_START + 5 ; 8/256, aaron - db 8, GRAND_MASTERS_START + 6 ; 8/256, aaron - db 255, GRAND_MASTERS_START + 7 ; 8/256, imakuni (catch-all) - -; return carry if the opponent in a is already among -; the first c opponents in sChallengeMachineOpponents -ChallengeMachine_CheckIfOpponentAlreadySelected: ; 136f9 (4:76f9) - ld hl, sChallengeMachineOpponents -.loop - cp [hl] - jr z, .found - inc hl - dec c - jr nz, .loop -; not found - or a - ret -.found - scf - ret - -ChallengeMachine_OpponentDeckIDs: ; 13707 (4:7707) -.club_members - db MUSCLES_FOR_BRAINS_DECK_ID - db HEATED_BATTLE_DECK_ID - db LOVE_TO_BATTLE_DECK_ID - db EXCAVATION_DECK_ID - db BLISTERING_POKEMON_DECK_ID - db HARD_POKEMON_DECK_ID - db WATERFRONT_POKEMON_DECK_ID - db LONELY_FRIENDS_DECK_ID - db SOUND_OF_THE_WAVES_DECK_ID - db PIKACHU_DECK_ID - db BOOM_BOOM_SELFDESTRUCT_DECK_ID - db POWER_GENERATOR_DECK_ID - db ETCETERA_DECK_ID - db FLOWER_GARDEN_DECK_ID - db KALEIDOSCOPE_DECK_ID - db GHOST_DECK_ID - db NAP_TIME_DECK_ID - db STRANGE_POWER_DECK_ID - db FLYIN_POKEMON_DECK_ID - db LOVELY_NIDORAN_DECK_ID - db POISON_DECK_ID - db ANGER_DECK_ID - db FLAMETHROWER_DECK_ID - db RESHUFFLE_DECK_ID -.club_masters - db FIRST_STRIKE_DECK_ID - db ROCK_CRUSHER_DECK_ID - db GO_GO_RAIN_DANCE_DECK_ID - db ZAPPING_SELFDESTRUCT_DECK_ID - db FLOWER_POWER_DECK_ID - db STRANGE_PSYSHOCK_DECK_ID - db WONDERS_OF_SCIENCE_DECK_ID - db FIRE_CHARGE_DECK_ID -.grand_masters - db LEGENDARY_MOLTRES_DECK_ID - db LEGENDARY_ZAPDOS_DECK_ID - db LEGENDARY_ARTICUNO_DECK_ID - db LEGENDARY_DRAGONITE_DECK_ID - db LIGHTNING_AND_FIRE_DECK_ID - db WATER_AND_FIGHTING_DECK_ID - db GRASS_AND_PSYCHIC_DECK_ID - db IMAKUNI_DECK_ID - -CLUB_MASTERS_START EQU ChallengeMachine_OpponentDeckIDs.club_masters - ChallengeMachine_OpponentDeckIDs.club_members -GRAND_MASTERS_START EQU ChallengeMachine_OpponentDeckIDs.grand_masters - ChallengeMachine_OpponentDeckIDs.club_members +INCLUDE "engine/challenge_machine.asm" INCLUDE "data/npc_map_data.asm" INCLUDE "data/map_objects.asm" diff --git a/src/engine/challenge_machine.asm b/src/engine/challenge_machine.asm new file mode 100644 index 0000000..58e675b --- /dev/null +++ b/src/engine/challenge_machine.asm @@ -0,0 +1,830 @@ +ChallengeMachine_Reset: + call ChallengeMachine_Initialize + call EnableSRAM + xor a + ld [sTotalChallengeMachineWins], a + ld [sTotalChallengeMachineWins + 1], a + ld [sPresentConsecutiveWins], a + ld [sPresentConsecutiveWins + 1], a + ld [sPresentConsecutiveWinsBackup], a + ld [sPresentConsecutiveWinsBackup + 1], a + ld [sPlayerInChallengeMachine], a + call DisableSRAM + ret + +; if a challenge is already in progress, then resume +; otherwise, start a new 5 round challenge +ChallengeMachine_Start: + ld a, 0 + ld [wLineSeparation], a + call Func_10a9b + call ChallengeMachine_Initialize + + call EnableSRAM + ld a, [sPlayerInChallengeMachine] + call DisableSRAM + cp $ff + jr z, .resume_challenge + +; new challenge + call ChallengeMachine_PickOpponentSequence + call ChallengeMachine_DrawScoreScreen + call FlashWhiteScreen + ldtx hl, PlayTheChallengeMachineText + call YesOrNoMenuWithText_SetCursorToYes + jp c, .end_challenge + + ldtx hl, LetUsChooseYourOpponentText + call PrintScrollableText_NoTextBoxLabel + call Func_10ab4 + call EnableSRAM + xor a + ld [sPresentConsecutiveWinsBackup], a + ld [sPresentConsecutiveWinsBackup + 1], a + call DisableSRAM + + call ChallengeMachine_DrawOpponentList + call FlashWhiteScreen + ldtx hl, YourOpponentsForThisGameText + call PrintScrollableText_NoTextBoxLabel +; begin challenge loop +.next_opponent + call ChallengeMachine_GetCurrentOpponent + call ChallengeMachine_AreYouReady + jr nc, .start_duel + ldtx hl, IfYouQuitTheDuelText + call PrintScrollableText_NoTextBoxLabel + ldtx hl, WouldYouLikeToQuitTheDuelText + call YesOrNoMenuWithText + jr c, .next_opponent + jp .quit + +.start_duel + call EnableSRAM + ld a, $ff + ld [sPlayerInChallengeMachine], a + call DisableSRAM + call ChallengeMachine_Duel +.resume_challenge + call EnableSRAM + xor a + ld [sPlayerInChallengeMachine], a + bank1call DiscardSavedDuelData + call DisableSRAM + call ChallengeMachine_GetCurrentOpponent + call ChallengeMachine_RecordDuelResult + call ChallengeMachine_DrawOpponentList + call FlashWhiteScreen + ld a, [wDuelResult] + or a + jr nz, .lost +; won + call ChallengeMachine_DuelWon + call EnableSRAM + ld a, [sChallengeMachineOpponentNumber] + cp NUM_CHALLENGE_MACHINE_OPPONENTS - 1 + jr z, .defeated_five_opponents + ld hl, sChallengeMachineOpponentNumber + inc [hl] + call DisableSRAM + jr .next_opponent + +.defeated_five_opponents + ld hl, sTotalChallengeMachineWins + call ChallengeMachine_IncrementHLMax999 + call Func_10ab4 + call ChallengeMachine_CheckForNewRecord + call ChallengeMachine_DrawScoreScreen + call FlashWhiteScreen + call EnableSRAM + ld a, [sTotalChallengeMachineWins] + ld [wTxRam3], a + ld a, [sTotalChallengeMachineWins + 1] + ld [wTxRam3 + 1], a + call DisableSRAM + ldtx hl, SuccessfullyDefeated5OpponentsText + call PrintScrollableText_NoTextBoxLabel + jr .end_challenge + +.lost + call ChallengeMachine_GetCurrentOpponent + call EnableSRAM + ld a, [sChallengeMachineOpponentNumber] + inc a + ld [wTxRam3], a + xor a + ld [wTxRam3 + 1], a + call DisableSRAM + call ChallengeMachine_GetOpponentNameAndDeck + ld a, [wOpponentName] + ld [wTxRam2], a + ld a, [wOpponentName + 1] + ld [wTxRam2 + 1], a + ldtx hl, LostToTheNthOpponentText + call PrintScrollableText_NoTextBoxLabel +.quit + call ChallengeMachine_PrintFinalConsecutiveWinStreak + call Func_10ab4 + call ChallengeMachine_CheckForNewRecord + call ChallengeMachine_DrawScoreScreen + call FlashWhiteScreen + call EnableSRAM +; reset streak + xor a + ld [sPresentConsecutiveWins], a + ld [sPresentConsecutiveWins + 1], a + call DisableSRAM +.end_challenge ; end, win or lose + call ChallengeMachine_CheckForNewRecord ; redundant? + call EnableSRAM + ld a, [sPresentConsecutiveWins] + ld [sPresentConsecutiveWinsBackup], a + ld a, [sPresentConsecutiveWins + 1] + ld [sPresentConsecutiveWinsBackup + 1], a + call ChallengeMachine_ShowNewRecord + call DisableSRAM + ldtx hl, WeAwaitYourNextChallengeText + call PrintScrollableText_NoTextBoxLabel + ret + +; update wChallengeMachineOpponent with the current +; opponent in the sChallengeMachineOpponents list +ChallengeMachine_GetCurrentOpponent: + call EnableSRAM + ld a, [sChallengeMachineOpponentNumber] + ld e, a + ld d, 0 + ld hl, sChallengeMachineOpponents + add hl, de + ld a, [hl] + ld [wChallengeMachineOpponent], a + call DisableSRAM + ret + +; play the appropriate match start theme +; then duel the current opponent +ChallengeMachine_Duel: + call ChallengeMachine_PrepareDuel + call EnableSRAM + ld a, [sChallengeMachineOpponentNumber] + ld e, a + call DisableSRAM + ld d, 0 + ld hl, ChallengeMachine_SongIDs + add hl, de + ld a, [hl] + call PlaySong + call WaitForSongToFinish + xor a + ld [wSongOverride], a + call SaveGeneralSaveData + bank1call StartDuel_VSAIOpp + ret + +ChallengeMachine_SongIDs: + db MUSIC_MATCH_START_1 + db MUSIC_MATCH_START_1 + db MUSIC_MATCH_START_1 + db MUSIC_MATCH_START_2 + db MUSIC_MATCH_START_2 + +; get the current opponent's name, deck, and prize count +ChallengeMachine_PrepareDuel: + call ChallengeMachine_GetOpponentNameAndDeck + call EnableSRAM + ld a, [sChallengeMachineOpponentNumber] + ld e, a + call DisableSRAM + ld d, 0 + ld hl, ChallengeMachine_Prizes + add hl, de + ld a, [hl] + ld [wNPCDuelPrizes], a + ret + +ChallengeMachine_Prizes: + db PRIZES_4 + db PRIZES_4 + db PRIZES_4 + db PRIZES_6 + db PRIZES_6 + +; store the result of the last duel in the current +; position of the sChallengeMachineDuelResults list +ChallengeMachine_RecordDuelResult: + call EnableSRAM + ld a, [sChallengeMachineOpponentNumber] + ld e, a + ld d, 0 + ld hl, sChallengeMachineDuelResults + add hl, de + ld a, [wDuelResult] + or a + jr nz, .lost + ld a, 1 ; won + ld [hl], a + call DisableSRAM + ld hl, sPresentConsecutiveWins + call ChallengeMachine_IncrementHLMax999 + ret + +.lost + ld a, 2 ; lost + ld [hl], a + call DisableSRAM + ret + +; increment the value at hl +; without going above 999 +ChallengeMachine_IncrementHLMax999: + call EnableSRAM + inc hl + ld a, [hld] + cp HIGH(999) + jr nz, .increment + ld a, [hl] + cp LOW(999) + jr z, .skip +.increment + ld a, [hl] + add 1 + ld [hli], a + ld a, [hl] + adc 0 + ld [hl], a +.skip + call DisableSRAM + ret + +; update sMaximumConsecutiveWins if the player set a new record +ChallengeMachine_CheckForNewRecord: + call EnableSRAM + ld hl, sMaximumConsecutiveWins + 1 + ld a, [sPresentConsecutiveWins + 1] + cp [hl] + jr nz, .high_bytes_different +; high bytes equal, check low bytes + dec hl + ld a, [sPresentConsecutiveWins] + cp [hl] +.high_bytes_different + jr c, .no_record + jr z, .no_record +; new record + ld hl, sMaximumConsecutiveWins + ld a, [sPresentConsecutiveWins] + ld [hli], a + ld a, [sPresentConsecutiveWins + 1] + ld [hl], a + ld hl, sPlayerName + ld de, sChallengeMachineRecordHolderName + ld bc, NAME_BUFFER_LENGTH + call CopyDataHLtoDE_SaveRegisters +; remember to show congrats message later + ld a, TRUE + ld [sConsecutiveWinRecordIncreased], a +.no_record + call DisableSRAM + ret + +; print the next opponent's name and ask the +; player if they want to begin the next duel +ChallengeMachine_AreYouReady: + call EnableSRAM + ld a, [sChallengeMachineOpponentNumber] + inc a + ld [wTxRam3], a + ld [wTxRam3_b], a + xor a + ld [wTxRam3 + 1], a + ld [wTxRam3_b + 1], a + ldtx hl, NthOpponentIsText + ld a, [sPresentConsecutiveWins + 1] + or a + jr nz, .streak + ld a, [sPresentConsecutiveWins] + cp 2 + jr c, .no_streak +.streak + ldtx hl, XConsecutiveWinsNthOpponentIsText + ld a, [sPresentConsecutiveWins] + ld [wTxRam3], a + ld a, [sPresentConsecutiveWins + 1] + ld [wTxRam3 + 1], a +.no_streak + call DisableSRAM + push hl ; text id + call ChallengeMachine_GetOpponentNameAndDeck + ld a, [wOpponentName] + ld [wTxRam2], a + ld a, [wOpponentName + 1] + ld [wTxRam2 + 1], a + pop hl ; text id + call PrintScrollableText_NoTextBoxLabel + ldtx hl, WouldYouLikeToBeginTheDuelText + call YesOrNoMenuWithText_SetCursorToYes + ret + +; print opponent win count +; play a jingle for beating 5 opponents +ChallengeMachine_DuelWon: + call EnableSRAM + ld a, [sChallengeMachineOpponentNumber] + inc a + ld [wTxRam3], a + xor a + ld [wTxRam3 + 1], a + ldtx hl, WonAgainstXOpponentsText + ld a, [sChallengeMachineOpponentNumber] + call DisableSRAM + cp NUM_CHALLENGE_MACHINE_OPPONENTS - 1 + jr z, .beat_five_opponents + call PrintScrollableText_NoTextBoxLabel + ret + +.beat_five_opponents + call PauseSong + ld a, MUSIC_MEDAL + call PlaySong + ldtx hl, Defeated5OpponentsText + call PrintScrollableText_NoTextBoxLabel + call WaitForSongToFinish + call ResumeSong + ret + +; when a player's streak ends, print the final +; consecutive win count +ChallengeMachine_PrintFinalConsecutiveWinStreak: + call EnableSRAM + ld a, [sPresentConsecutiveWins] + ld [wTxRam3], a + ld a, [sPresentConsecutiveWins + 1] + ld [wTxRam3 + 1], a + or a + jr nz, .streak + ld a, [sPresentConsecutiveWins] + cp 2 + jr c, .no_streak +.streak + ldtx hl, ConsecutiveWinsEndedAtText + call PrintScrollableText_NoTextBoxLabel +.no_streak + call DisableSRAM + ret + +; if the player achieved a new record, play a jingle +; otherwise, do nothing +ChallengeMachine_ShowNewRecord: + call EnableSRAM + ld a, [sConsecutiveWinRecordIncreased] + or a + ret z ; no new record + ld a, [sMaximumConsecutiveWins] + ld [wTxRam3], a + ld a, [sMaximumConsecutiveWins + 1] + ld [wTxRam3 + 1], a + call DisableSRAM + call PauseSong + ld a, MUSIC_MEDAL + call PlaySong + ldtx hl, ConsecutiveWinRecordIncreasedText + call PrintScrollableText_NoTextBoxLabel + call WaitForSongToFinish + call ResumeSong + ret + +ChallengeMachine_DrawScoreScreen: + call Func_10000 + lb de, $30, $bf + call SetupText + lb de, 0, 0 + lb bc, 20, 13 + call DrawRegularTextBox + lb de, 0, 12 + lb bc, 20, 6 + call DrawRegularTextBox + call EnableSRAM + ld hl, sChallengeMachineRecordHolderName + ld de, wDefaultText + ld bc, NAME_BUFFER_LENGTH + call CopyDataHLtoDE + call DisableSRAM + xor a + ld [wTxRam2], a + ld [wTxRam2 + 1], a + ld hl, ChallengeMachine_PlayerScoreTexts + call Func_111b3 + ld hl, ChallengeMachine_PlayerScoreValues + call ChallengeMachine_PrintScores + ret + +ChallengeMachine_PlayerScoreTexts: + db 1, 0 + tx ChallengeMachineText + + db 1, 2 + tx PlayersScoreText + + db 2, 4 + tx Defeated5OpponentsXTimesText + + db 2, 6 + tx PresentConsecutiveWinsText + + db 1, 8 + tx MaximumConsecutiveWinsText + + db 17, 6 + tx WinsText + + db 16, 10 + tx WinsText + db $ff + +ChallengeMachine_PlayerScoreValues: + dw sTotalChallengeMachineWins + db 12, 4 + + dw sPresentConsecutiveWins + db 14, 6 + + dw sMaximumConsecutiveWins + db 13, 10 + + dw NULL + +ChallengeMachine_DrawOpponentList: + call Func_10000 + lb de, $30, $bf + call SetupText + lb de, 0, 0 + lb bc, 20, 13 + call DrawRegularTextBox + lb de, 0, 12 + lb bc, 20, 6 + call DrawRegularTextBox + ld hl, ChallengeMachine_OpponentNumberTexts + call Func_111b3 + call ChallengeMachine_PrintOpponentInfo + call ChallengeMachine_PrintDuelResultIcons + ret + +ChallengeMachine_OpponentNumberTexts: + db 1, 0 + tx ChallengeMachineText + + db 2, 2 + tx ChallengeMachineOpponent1Text + + db 2, 4 + tx ChallengeMachineOpponent2Text + + db 2, 6 + tx ChallengeMachineOpponent3Text + + db 2, 8 + tx ChallengeMachineOpponent4Text + + db 2, 10 + tx ChallengeMachineOpponent5Text + db $ff + +ChallengeMachine_PrintOpponentInfo: + ld hl, sChallengeMachineOpponents + ld bc, 2 ; beginning y-pos + ld e, NUM_CHALLENGE_MACHINE_OPPONENTS +.loop + push hl + push bc + push de + call EnableSRAM + ld a, [hl] + ld [wChallengeMachineOpponent], a + ld b, 14 ; x-pos + call ChallengeMachine_PrintOpponentName + ld b, 4 ; x-pos + call ChallengeMachine_PrintOpponentClubStatus + pop de + pop bc + pop hl + inc hl + +; down two rows + inc c + inc c + + dec e + jr nz, .loop + call DisableSRAM + ret + +ChallengeMachine_PrintOpponentName: + push bc + call ChallengeMachine_GetOpponentNameAndDeck + ld de, 2 ; name + add hl, de + call ChallengeMachine_PrintText + pop bc + ret + +ChallengeMachine_PrintText: + ld a, [hli] + ld h, [hl] + ld l, a + ld e, c + ld d, b + push de + call InitTextPrinting + call PrintTextNoDelay + pop de + ret + +; print the opponent's rank and element +ChallengeMachine_PrintOpponentClubStatus: + push bc + call ChallengeMachine_GetOpponentNameAndDeck + push hl + ld de, 6 ; rank + add hl, de + call ChallengeMachine_PrintText + ld a, d + add $07 + ld d, a + call InitTextPrinting + pop hl + ld bc, 8 ; element + add hl, bc + ld a, [hli] + ld h, [hl] + ld l, a + or h + jr z, .no_element + call PrintTextNoDelay +.no_element + pop bc + ret + +ChallengeMachine_GetOpponentNameAndDeck: + push de + ld a, [wChallengeMachineOpponent] + ld e, a + ld d, 0 + ld hl, ChallengeMachine_OpponentDeckIDs + add hl, de + ld a, [hl] + ld [wNPCDuelDeckID], a + call _GetChallengeMachineDuelConfigurations + pop de + ret + +ChallengeMachine_PrintDuelResultIcons: + ld hl, sChallengeMachineDuelResults + ld c, NUM_CHALLENGE_MACHINE_OPPONENTS + lb de, 1, 2 +.print_loop + push hl + push bc + push de + call InitTextPrinting + call EnableSRAM + ld a, [hl] + add a + ld e, a + ld d, 0 + ld hl, ChallengeMachine_DuelResultIcons + add hl, de + ld a, [hli] + ld h, [hl] + ld l, a + call PrintTextNoDelay + pop de + pop bc + pop hl + inc hl + +; down two rows + inc e + inc e + + dec c + jr nz, .print_loop + call DisableSRAM + ret + +ChallengeMachine_DuelResultIcons: + tx ChallengeMachineNotDuelledIconText + tx ChallengeMachineDuelWonIconText + tx ChallengeMachineDuelLostIconText + +; print all scores in the table pointed to by hl +ChallengeMachine_PrintScores: +.loop + call EnableSRAM + ld a, [hli] + ld e, a + ld a, [hli] + ld d, a + or e + jr z, .done + ld b, [hl] + inc hl + ld c, [hl] + inc hl + push hl + push bc + ld a, [de] + ld l, a + inc de + ld a, [de] + ld h, a + call Func_10217 + pop bc + call BCCoordToBGMap0Address + ld hl, wd4b4 + ld b, 3 + call SafeCopyDataHLtoDE + pop hl + jr .loop + +.done + call DisableSRAM + ret + +; if this is the first time the challenge machine has ever +; been used on this cartridge, then clear all vars and +; set Dr. Mason as the record holder +ChallengeMachine_Initialize: + call EnableSRAM + ld a, [sChallengeMachineMagic] + cp $e3 + jr nz, .init_vars + ld a, [sChallengeMachineMagic + 1] + cp $95 + jr z, .done + +.init_vars + ld hl, sChallengeMachineMagic + ld c, sChallengeMachineEnd - sChallengeMachineStart + ld a, $e3 + ld [hli], a + ld a, $95 + ld [hli], a + + xor a +.clear_loop + ld [hli], a + dec c + jr nz, .clear_loop + + ld hl, ChallengeMachine_DrMasonText + ld de, sChallengeMachineRecordHolderName + ld bc, NAME_BUFFER_LENGTH + call CopyDataHLtoDE_SaveRegisters + ld a, 1 + ld [sMaximumConsecutiveWins], a + xor a + ld [sMaximumConsecutiveWins + 1], a + +.done + ld a, [sPlayerInChallengeMachine] + call DisableSRAM + ret + +ChallengeMachine_DrMasonText: + text "Dr. Mason", TX_END, TX_END, TX_END, TX_END, TX_END, TX_END + +; pick the next opponent sequence and clear challenge vars +ChallengeMachine_PickOpponentSequence: + call EnableSRAM + +; pick first opponent + ld a, CLUB_MASTERS_START + call Random + ld [sChallengeMachineOpponents], a + +.pick_second_opponent + ld a, CLUB_MASTERS_START + call Random + ld c, 1 + call ChallengeMachine_CheckIfOpponentAlreadySelected + jr c, .pick_second_opponent + ld [sChallengeMachineOpponents + 1], a + +.pick_third_opponent + ld a, CLUB_MASTERS_START + call Random + ld c, 2 + call ChallengeMachine_CheckIfOpponentAlreadySelected + jr c, .pick_third_opponent + ld [sChallengeMachineOpponents + 2], a + +; pick fourth opponent + ld a, GRAND_MASTERS_START - CLUB_MASTERS_START + call Random + add CLUB_MASTERS_START + ld [sChallengeMachineOpponents + 3], a + +; pick fifth opponent + call UpdateRNGSources + ld hl, ChallengeMachine_FinalOpponentProbabilities +.next + sub [hl] + jr c, .got_opponent + inc hl + inc hl + jr .next +.got_opponent + inc hl + ld a, [hl] + ld [sChallengeMachineOpponents + 4], a + + xor a + ld [sChallengeMachineOpponentNumber], a + ld [sConsecutiveWinRecordIncreased], a + ld hl, sChallengeMachineDuelResults + ld c, NUM_CHALLENGE_MACHINE_OPPONENTS +.clear_results + ld [hli], a + dec c + jr nz, .clear_results + ld a, [sPresentConsecutiveWinsBackup] + ld [sPresentConsecutiveWins], a + ld a, [sPresentConsecutiveWinsBackup + 1] + ld [sPresentConsecutiveWins + 1], a + call DisableSRAM + ret + +ChallengeMachine_FinalOpponentProbabilities: + db 56, GRAND_MASTERS_START + 0 ; 56/256, courtney + db 56, GRAND_MASTERS_START + 1 ; 56/256, steve + db 56, GRAND_MASTERS_START + 2 ; 56/256, jack + db 56, GRAND_MASTERS_START + 3 ; 56/256, rod + db 8, GRAND_MASTERS_START + 4 ; 8/256, aaron + db 8, GRAND_MASTERS_START + 5 ; 8/256, aaron + db 8, GRAND_MASTERS_START + 6 ; 8/256, aaron + db 255, GRAND_MASTERS_START + 7 ; 8/256, imakuni (catch-all) + +; return carry if the opponent in a is already among +; the first c opponents in sChallengeMachineOpponents +ChallengeMachine_CheckIfOpponentAlreadySelected: + ld hl, sChallengeMachineOpponents +.loop + cp [hl] + jr z, .found + inc hl + dec c + jr nz, .loop +; not found + or a + ret +.found + scf + ret + +ChallengeMachine_OpponentDeckIDs: +.club_members + db MUSCLES_FOR_BRAINS_DECK_ID + db HEATED_BATTLE_DECK_ID + db LOVE_TO_BATTLE_DECK_ID + db EXCAVATION_DECK_ID + db BLISTERING_POKEMON_DECK_ID + db HARD_POKEMON_DECK_ID + db WATERFRONT_POKEMON_DECK_ID + db LONELY_FRIENDS_DECK_ID + db SOUND_OF_THE_WAVES_DECK_ID + db PIKACHU_DECK_ID + db BOOM_BOOM_SELFDESTRUCT_DECK_ID + db POWER_GENERATOR_DECK_ID + db ETCETERA_DECK_ID + db FLOWER_GARDEN_DECK_ID + db KALEIDOSCOPE_DECK_ID + db GHOST_DECK_ID + db NAP_TIME_DECK_ID + db STRANGE_POWER_DECK_ID + db FLYIN_POKEMON_DECK_ID + db LOVELY_NIDORAN_DECK_ID + db POISON_DECK_ID + db ANGER_DECK_ID + db FLAMETHROWER_DECK_ID + db RESHUFFLE_DECK_ID +.club_masters + db FIRST_STRIKE_DECK_ID + db ROCK_CRUSHER_DECK_ID + db GO_GO_RAIN_DANCE_DECK_ID + db ZAPPING_SELFDESTRUCT_DECK_ID + db FLOWER_POWER_DECK_ID + db STRANGE_PSYSHOCK_DECK_ID + db WONDERS_OF_SCIENCE_DECK_ID + db FIRE_CHARGE_DECK_ID +.grand_masters + db LEGENDARY_MOLTRES_DECK_ID + db LEGENDARY_ZAPDOS_DECK_ID + db LEGENDARY_ARTICUNO_DECK_ID + db LEGENDARY_DRAGONITE_DECK_ID + db LIGHTNING_AND_FIRE_DECK_ID + db WATER_AND_FIGHTING_DECK_ID + db GRASS_AND_PSYCHIC_DECK_ID + db IMAKUNI_DECK_ID + +CLUB_MASTERS_START EQU ChallengeMachine_OpponentDeckIDs.club_masters - ChallengeMachine_OpponentDeckIDs.club_members +GRAND_MASTERS_START EQU ChallengeMachine_OpponentDeckIDs.grand_masters - ChallengeMachine_OpponentDeckIDs.club_members diff --git a/src/engine/duel/animations/core.asm b/src/engine/duel/animations/core.asm index 5da9a0a..89d072c 100644 --- a/src/engine/duel/animations/core.asm +++ b/src/engine/duel/animations/core.asm @@ -102,7 +102,7 @@ PlayLoadedDuelAnimation: .address dw .handler_func -.handler_func ; 1c94a (7:494a) +.handler_func ; if any of ANIM_SPRITE_ID, ANIM_PALETTE_ID and ANIM_SPRITE_ANIM_ID ; are 0, then return ld e, l diff --git a/src/engine/link/printer.asm b/src/engine/link/printer.asm index 110fde4..9e36649 100644 --- a/src/engine/link/printer.asm +++ b/src/engine/link/printer.asm @@ -401,7 +401,7 @@ Func_1a0cc: ; copies 20 tiles given by hl to de ; then adds 2 tiles to hl -.Copy20Tiles ; 1a0e0 (6:60e0) +.Copy20Tiles push hl ld c, 20 .loop_tiles @@ -416,7 +416,7 @@ Func_1a0cc: ; copies a tile to de ; a = tile to get from sGfxBuffer1 -.CopyTile ; 1a0f0 (6:60f0) +.CopyTile push hl push bc ld l, a diff --git a/src/engine/menus/duel.asm b/src/engine/menus/duel.asm index 672bd73..36f6647 100644 --- a/src/engine/menus/duel.asm +++ b/src/engine/menus/duel.asm @@ -1470,12 +1470,12 @@ endr dw .SelectedOppsHand dw .SelectedDeck -.YourOrOppPlayAreaData ; 8808 (2:4808) +.YourOrOppPlayAreaData textitem 2, 14, YourPlayAreaText textitem 2, 16, OppPlayAreaText db $ff -.PlayAreaMenuParameters ; 8811 (2:4811) +.PlayAreaMenuParameters db 1, 14 ; cursor x, cursor y db 2 ; y displacement between items db 2 ; number of items @@ -1483,7 +1483,7 @@ endr db SYM_SPACE ; tile behind cursor dw NULL ; function pointer if non-0 -.SelectedPrize ; 8819 (2:4819) +.SelectedPrize ld a, [wYourOrOppPlayAreaCurPosition] ld c, a ld b, $1 @@ -1511,7 +1511,7 @@ endr call GetTurnDuelistVariable jr .ShowSelectedCard -.SelectedOppsHand ; 883c (2:483c) +.SelectedOppsHand call CreateHandCardList ret c ld hl, wDuelTempList @@ -1519,7 +1519,7 @@ endr ld a, [hl] jr .ShowSelectedCard -.SelectedDeck ; 8849 (2:4849) +.SelectedDeck call CreateDeckCardList ret c ld a, %01111111 @@ -1532,7 +1532,7 @@ endr ; output: ; a = wce5c ; with upper bit set if turn was swapped -.ShowSelectedCard ; 8855 (2:4855) +.ShowSelectedCard ld b, a ld a, [wce5c] or a diff --git a/src/engine/menus/glossary.asm b/src/engine/menus/glossary.asm index 78f44dd..aa42851 100644 --- a/src/engine/menus/glossary.asm +++ b/src/engine/menus/glossary.asm @@ -56,7 +56,7 @@ OpenGlossaryScreen: jr .next ; display glossary menu. -.display_menu ; 1852b (6:452b) +.display_menu xor a ld [wTileMapFill], a call ZeroObjectPositions @@ -77,7 +77,7 @@ OpenGlossaryScreen: ret ; print texts in glossary menu. -.print_menu ; 1855a (6:455a) +.print_menu ld hl, wDefaultText ld a, TX_SYMBOL @@ -122,7 +122,7 @@ OpenGlossaryScreen: ret ; display glossary description. -.print_description ; 18598 (6:4598) +.print_description push af xor a ld [wTileMapFill], a diff --git a/src/engine/menus/play_area.asm b/src/engine/menus/play_area.asm index 047d24f..0a09953 100644 --- a/src/engine/menus/play_area.asm +++ b/src/engine/menus/play_area.asm @@ -93,7 +93,7 @@ OpenInPlayAreaScreen: jp .start -.print_associated_text ; 18171 (6:4171) +.print_associated_text ; each position has a text associated to it, ; which is printed at the bottom of the screen push af @@ -541,7 +541,7 @@ OpenInPlayAreaScreen_HandleInput: bit 4, [hl] ; = and $10 jr nz, ZeroObjectPositionsAndToggleOAMCopy_Bank6 -.draw_cursor ; 184a0 (6:44a0) +.draw_cursor call ZeroObjectPositions ld hl, wMenuInputTablePointer ld e, [hl] diff --git a/src/engine/menus/unknown.asm b/src/engine/menus/unknown.asm index c6f04fa..95865de 100644 --- a/src/engine/menus/unknown.asm +++ b/src/engine/menus/unknown.asm @@ -76,7 +76,7 @@ Func_18661: ; unreferenced ld a, SYM_CURSOR_R bit D_RIGHT_F, [hl] jr z, .draw_tile -.draw_blank_cursor ; 186d4 (6:46d4) +.draw_blank_cursor ld a, SYM_SPACE .draw_tile ld e, a @@ -98,6 +98,6 @@ Func_18661: ; unreferenced call WriteByteToBGMap0 or a ret -.draw_cursor ; 186f3 (6:46f3) +.draw_cursor ld a, SYM_CURSOR_R jr .draw_tile diff --git a/src/engine/overworld/overworld.asm b/src/engine/overworld/overworld.asm index 3ff69c3..273f275 100644 --- a/src/engine/overworld/overworld.asm +++ b/src/engine/overworld/overworld.asm @@ -242,7 +242,7 @@ Func_c1b1: call DetermineImakuniAndChallengeHall farcall Func_80b7a farcall ClearMasterBeatenList - farcall Func_131b3 + farcall ChallengeMachine_Reset xor a ld [wPlayTimeCounter + 0], a ld [wPlayTimeCounter + 1], a diff --git a/src/engine/overworld/scripting.asm b/src/engine/overworld/scripting.asm index 9150585..442bb7b 100644 --- a/src/engine/overworld/scripting.asm +++ b/src/engine/overworld/scripting.asm @@ -1575,7 +1575,7 @@ ScriptCommand_ChooseDeckToDuelAgainstMultichoice: set_event_value EVENT_AARON_DECK_MENU_CHOICE jp IncreaseScriptPointerBy1 -.multichoice_menu_args ; d25e +.multichoice_menu_args dw NULL ; NPC title for textbox under menu tx SelectDeckToDuelText ; text for textbox under menu dw MultichoiceTextbox_ConfigTable_ChooseDeckToDuelAgainst ; location of table configuration in bank 4 @@ -1583,7 +1583,7 @@ ScriptCommand_ChooseDeckToDuelAgainstMultichoice: dw wMultichoiceTextboxResult_ChooseDeckToDuelAgainst ; ram location to return result into dw .text_entries ; location of table containing text entries -.text_entries ; d269 +.text_entries tx LightningAndFireDeckChoiceText tx WaterAndFightingDeckChoiceText tx GrassAndPsychicDeckChoiceText @@ -1596,7 +1596,7 @@ ScriptCommand_ChooseStarterDeckMultichoice: call ShowMultichoiceTextbox jp IncreaseScriptPointerBy1 -.multichoice_menu_args ; d27b +.multichoice_menu_args dw NULL ; NPC title for textbox under menu tx SelectDeckToTakeText ; text for textbox under menu dw MultichoiceTextbox_ConfigTable_ChooseDeckStarterDeck ; location of table configuration in bank 4 @@ -1703,7 +1703,7 @@ ScriptCommand_ShowSamNormalMultichoice: ld [wMultichoiceTextboxResult_Sam], a jp IncreaseScriptPointerBy1 -.multichoice_menu_args ; d30c +.multichoice_menu_args tx SamNPCName ; NPC title for textbox under menu tx HowCanIHelpText ; text for textbox under menu dw SamNormalMultichoice_ConfigurationTable ; location of table configuration in bank 4 diff --git a/src/engine/overworld_map.asm b/src/engine/overworld_map.asm new file mode 100644 index 0000000..6f83ecb --- /dev/null +++ b/src/engine/overworld_map.asm @@ -0,0 +1,566 @@ +; refresh the cursor's position based on the currently selected map +; and refresh the player's position based on the starting map +; but only if the player is not being animated across the overworld +OverworldMap_UpdatePlayerAndCursorSprites: + push hl + push bc + push de + ld a, [wOverworldMapCursorSprite] + ld [wWhichSprite], a + ld a, [wOverworldMapSelection] + ld d, 0 + ld e, -12 + call OverworldMap_SetSpritePosition + ld a, [wOverworldMapPlayerAnimationState] + or a + jr nz, .player_walking + ld a, [wPlayerSpriteIndex] + ld [wWhichSprite], a + ld a, [wOverworldMapStartingPosition] + ld d, 0 + ld e, 0 + call OverworldMap_SetSpritePosition +.player_walking + pop de + pop bc + pop hl + ret + +; if no selection has been made yet, call OverworldMap_HandleKeyPress +; if the player is being animated across the screen, call OverworldMap_UpdatePlayerWalkingAnimation +; if the player has finished walking, call OverworldMap_LoadSelectedMap +OverworldMap_Update: + ld a, [wPlayerSpriteIndex] + ld [wWhichSprite], a + ld a, [wOverworldMapPlayerAnimationState] + or a + jr nz, .player_walking + call OverworldMap_HandleKeyPress + ret +.player_walking + cp 2 + jr z, .player_finished_walking + call OverworldMap_UpdatePlayerWalkingAnimation + ret +.player_finished_walking + call OverworldMap_LoadSelectedMap + ret + +; update the map selection if the DPad is pressed +; or finalize the selection if the A button is pressed +OverworldMap_HandleKeyPress: + ldh a, [hKeysPressed] + and D_PAD + jr z, .no_d_pad + farcall GetDirectionFromDPad + ld [wPlayerDirection], a + call OverworldMap_HandleDPad + jr .done +.no_d_pad + ldh a, [hKeysPressed] + and A_BUTTON + jr z, .done + ld a, SFX_02 + call PlaySFX + call OverworldMap_UpdateCursorAnimation + call OverworldMap_BeginPlayerMovement + jr .done +.done + ret + +; update wOverworldMapSelection based on the pressed direction in wPlayerDirection +OverworldMap_HandleDPad: + push hl + pop hl + ld a, [wOverworldMapSelection] + rlca + rlca + ld c, a + ld a, [wPlayerDirection] + add c + ld c, a + ld b, 0 + ld hl, OverworldMap_CursorTransitions + add hl, bc + ld a, [hl] + or a + jr z, .no_transition + ld [wOverworldMapSelection], a + call OverworldMap_PrintMapName + ld a, SFX_01 + call PlaySFX +.no_transition + pop bc + pop hl + ret + +INCLUDE "data/overworld_map/cursor_transitions.asm" + +; set the active sprite (player or cursor) at the appropriate map position +; input: +; a = OWMAP_* value +; d = x offset +; e = y offset +OverworldMap_SetSpritePosition: + call OverworldMap_GetMapPosition + ld c, SPRITE_ANIM_COORD_X + call GetSpriteAnimBufferProperty + ld a, d + ld [hli], a + ld a, e + ld [hl], a + ret + +; input: +; a = OWMAP_* value +; d = x offset +; e = y offset +; output: +; d = x position +; e = y position +OverworldMap_GetMapPosition: + push hl + push de + rlca + ld e, a + ld d, 0 + ld hl, OverworldMap_MapPositions + add hl, de + pop de + ld a, [hli] + add $8 + add d + ld d, a + ld a, [hl] + add $10 + add e + ld e, a + pop hl + ret + +INCLUDE "data/overworld_map/map_positions.asm" + +OverworldMap_PrintMapName: + push hl + push de + lb de, 1, 1 + call InitTextPrinting + call OverworldMap_GetOWMapID + rlca + ld e, a + ld d, 0 + ld hl, OverworldMapNames + add hl, de + ld a, [hli] + ld h, [hl] + ld l, a + call ProcessTextFromID + pop de + pop hl + ret + +; returns [wOverworldMapSelection] in a +; or OWMAP_MYSTERY_HOUSE if [wOverworldMapSelection] == OWMAP_ISHIHARAS_HOUSE +; and EVENT_ISHIHARAS_HOUSE_MENTIONED == FALSE +OverworldMap_GetOWMapID: + push bc + ld a, [wOverworldMapSelection] + cp OWMAP_ISHIHARAS_HOUSE + jr nz, .got_map + ld c, a + ld a, EVENT_ISHIHARAS_HOUSE_MENTIONED + farcall GetEventValue + or a + ld a, c + jr nz, .got_map + ld a, OWMAP_MYSTERY_HOUSE +.got_map + pop bc + ret + +OverworldMap_LoadSelectedMap: + push hl + push bc + ld a, [wOverworldMapSelection] + rlca + rlca + ld c, a + ld b, 0 + ld hl, OverworldMapWarps + add hl, bc + ld a, [hli] + ld [wTempMap], a + ld a, [hli] + ld [wTempPlayerXCoord], a + ld a, [hli] + ld [wTempPlayerYCoord], a + ld a, NORTH + ld [wTempPlayerDirection], a + ld hl, wOverworldTransition + set 4, [hl] + pop bc + pop hl + ret + +INCLUDE "data/overworld_map/overworld_warps.asm" + +OverworldMap_InitVolcanoSprite: + ld a, SPRITE_OW_MAP_OAM + farcall CreateSpriteAndAnimBufferEntry + ld c, SPRITE_ANIM_COORD_X + call GetSpriteAnimBufferProperty + ld a, $80 + ld [hli], a ; x + ld a, $10 + ld [hl], a ; y + ld b, SPRITE_ANIM_SGB_VOLCANO_SMOKE + ld a, [wConsole] + cp CONSOLE_CGB + jr nz, .not_cgb + ld b, SPRITE_ANIM_CGB_VOLCANO_SMOKE +.not_cgb + ld a, b + farcall StartNewSpriteAnimation + ret + +OverworldMap_InitCursorSprite: + ld a, [wOverworldMapSelection] + ld [wOverworldMapStartingPosition], a + xor a + ld [wOverworldMapPlayerAnimationState], a + ld a, SPRITE_OW_MAP_OAM + call CreateSpriteAndAnimBufferEntry + ld a, [wWhichSprite] + ld [wOverworldMapCursorSprite], a + ld b, SPRITE_ANIM_SGB_OWMAP_CURSOR + ld a, [wConsole] + cp CONSOLE_CGB + jr nz, .not_cgb + ld b, SPRITE_ANIM_CGB_OWMAP_CURSOR +.not_cgb + ld a, b + ld [wOverworldMapCursorAnimation], a + call StartNewSpriteAnimation + ld a, EVENT_MASON_LAB_STATE + farcall GetEventValue + or a + jr nz, .visited_lab + ld c, SPRITE_ANIM_FLAGS + call GetSpriteAnimBufferProperty + set SPRITE_ANIM_FLAG_UNSKIPPABLE, [hl] +.visited_lab + ret + +; play animation SPRITE_ANIM_SGB_OWMAP_CURSOR_FAST (non-cgb) or SPRITE_ANIM_CGB_OWMAP_CURSOR_FAST (cgb) +; to make the cursor blink faster after a selection is made +OverworldMap_UpdateCursorAnimation: + ld a, [wOverworldMapCursorSprite] + ld [wWhichSprite], a + ld a, [wOverworldMapCursorAnimation] + inc a + call StartNewSpriteAnimation + ret + +; begin walking the player across the overworld +; from wOverworldMapStartingPosition to wOverworldMapSelection +OverworldMap_BeginPlayerMovement: + ld a, SFX_57 + call PlaySFX + ld a, [wPlayerSpriteIndex] + ld [wWhichSprite], a + ld c, SPRITE_ANIM_FLAGS + call GetSpriteAnimBufferProperty + set SPRITE_ANIM_FLAG_SPEED, [hl] + +; get pointer table for starting map + ld hl, OverworldMap_PlayerMovementPaths + ld a, [wOverworldMapStartingPosition] + dec a + add a + ld c, a + ld b, 0 + add hl, bc + ld a, [hli] + ld h, [hl] + ld l, a + +; get path sequence for selected map + ld a, [wOverworldMapSelection] + dec a + add a + ld c, a + ld b, 0 + add hl, bc + ld a, [hli] + ld [wOverworldMapPlayerMovementPtr], a + ld a, [hl] + ld [wOverworldMapPlayerMovementPtr + 1], a + + ld a, 1 + ld [wOverworldMapPlayerAnimationState], a + xor a + ld [wOverworldMapPlayerMovementCounter], a + ret + +; update the player walking across the overworld +; either by advancing along the current path +; or determining the next direction to move along the path +OverworldMap_UpdatePlayerWalkingAnimation: + ld a, [wPlayerSpriteIndex] + ld [wWhichSprite], a + ld a, [wOverworldMapPlayerMovementCounter] + or a + jp nz, OverworldMap_ContinuePlayerWalkingAnimation + +; get next x,y on the path + ld a, [wOverworldMapPlayerMovementPtr] + ld l, a + ld a, [wOverworldMapPlayerMovementPtr + 1] + ld h, a + ld a, [hli] + ld b, a + ld a, [hli] + ld c, a + and b + cp $ff + jr z, .player_finished_walking + ld a, c + or b + jr nz, .next_point + +; point 0,0 means walk straight towards [wOverworldMapSelection] + ld a, [wOverworldMapStartingPosition] + ld e, a + ld a, [wOverworldMapSelection] + cp e + jr z, .player_finished_walking + lb de, 0, 0 + call OverworldMap_GetMapPosition + ld b, d + ld c, e + +.next_point + ld a, l + ld [wOverworldMapPlayerMovementPtr], a + ld a, h + ld [wOverworldMapPlayerMovementPtr + 1], a + call OverworldMap_InitNextPlayerVelocity + ret + +.player_finished_walking + ld a, 2 + ld [wOverworldMapPlayerAnimationState], a + ret + +; input: +; b = target x position +; c = target y position +OverworldMap_InitNextPlayerVelocity: + push hl + push bc + ld c, SPRITE_ANIM_COORD_X + call GetSpriteAnimBufferProperty + + pop bc + ld a, b + sub [hl] ; a = target x - current x + ld [wOverworldMapPlayerPathHorizontalMovement], a + ld a, 0 + sbc 0 + ld [wOverworldMapPlayerPathHorizontalMovement + 1], a + + inc hl + ld a, c + sub [hl] ; a = target y - current y + ld [wOverworldMapPlayerPathVerticalMovement], a + ld a, 0 + sbc 0 + ld [wOverworldMapPlayerPathVerticalMovement + 1], a + + ld a, [wOverworldMapPlayerPathHorizontalMovement] + ld b, a + ld a, [wOverworldMapPlayerPathHorizontalMovement + 1] + bit 7, a + jr z, .positive +; absolute value + ld a, [wOverworldMapPlayerPathHorizontalMovement] + cpl + inc a + ld b, a + +.positive + ld a, [wOverworldMapPlayerPathVerticalMovement] + ld c, a + ld a, [wOverworldMapPlayerPathVerticalMovement + 1] + bit 7, a + jr z, .positive2 +; absolute value + ld a, [wOverworldMapPlayerPathVerticalMovement] + cpl + inc a + ld c, a + +.positive2 +; if the absolute value of wOverworldMapPlayerPathVerticalMovement is larger than +; the absolute value of wOverworldMapPlayerPathHorizontalMovement, this is dominantly +; a north/south movement. otherwise, an east/west movement + ld a, b + cp c + jr c, .north_south + call OverworldMap_InitPlayerEastWestMovement + jr .done +.north_south + call OverworldMap_InitPlayerNorthSouthMovement +.done + xor a + ld [wOverworldMapPlayerHorizontalSubPixelPosition], a + ld [wOverworldMapPlayerVerticalSubPixelPosition], a + farcall UpdatePlayerSprite + pop hl + ret + +; input: +; b = absolute value of horizontal movement distance +; c = absolute value of vertical movement distance +OverworldMap_InitPlayerEastWestMovement: +; use horizontal distance for counter + ld a, b + ld [wOverworldMapPlayerMovementCounter], a + +; de = absolute horizontal distance, for later + ld e, a + ld d, 0 + +; overwrite wOverworldMapPlayerPathHorizontalMovement with either -1.0 or +1.0 +; always move east/west by 1 pixel per frame + ld hl, wOverworldMapPlayerPathHorizontalMovement + xor a + ld [hli], a + bit 7, [hl] + jr z, .east + dec a + jr .west +.east + inc a +.west + ld [hl], a + +; divide (total vertical distance * $100) by total horizontal distance + ld b, c ; vertical distance in high byte + ld c, 0 + call DivideBCbyDE + ld a, [wOverworldMapPlayerPathVerticalMovement + 1] + bit 7, a + jr z, .positive +; restore negative sign + call OverworldMap_NegateBC +.positive + ld a, c + ld [wOverworldMapPlayerPathVerticalMovement], a + ld a, b + ld [wOverworldMapPlayerPathVerticalMovement + 1], a + +; set player direction + ld hl, wOverworldMapPlayerPathHorizontalMovement + 1 + ld a, EAST + bit 7, [hl] + jr z, .east2 + ld a, WEST +.east2 + ld [wPlayerDirection], a + ret + +; input: +; b = absolute value of horizontal movement distance +; c = absolute value of vertical movement distance +OverworldMap_InitPlayerNorthSouthMovement: +; use vertical distance for counter + ld a, c + ld [wOverworldMapPlayerMovementCounter], a + +; de = absolute vertical distance, for later + ld e, a + ld d, 0 + +; overwrite wOverworldMapPlayerPathVerticalMovement with either -1.0 or +1.0 +; always move north/south by 1 pixel per frame + ld hl, wOverworldMapPlayerPathVerticalMovement + xor a + ld [hli], a + bit 7, [hl] + jr z, .south + dec a + jr .north +.south + inc a +.north + ld [hl], a + +; divide (total horizontal distance * $100) by total vertical distance +; horizontal distance in high byte + ld c, 0 + call DivideBCbyDE + ld a, [wOverworldMapPlayerPathHorizontalMovement + 1] + bit 7, a + jr z, .positive +; restore negative sign + call OverworldMap_NegateBC +.positive + ld a, c + ld [wOverworldMapPlayerPathHorizontalMovement], a + ld a, b + ld [wOverworldMapPlayerPathHorizontalMovement + 1], a + +; set player direction + ld hl, wOverworldMapPlayerPathVerticalMovement + 1 + ld a, SOUTH + bit 7, [hl] + jr z, .south2 + ld a, NORTH +.south2 + ld [wPlayerDirection], a + ret + +; output: +; bc = bc * -1 +OverworldMap_NegateBC: + ld a, c + cpl + add 1 + ld c, a + ld a, b + cpl + adc 0 + ld b, a + ret + +; add the x/y speed to the current sprite position, +; accounting for sub-pixel position +; and decrement [wOverworldMapPlayerMovementCounter] +OverworldMap_ContinuePlayerWalkingAnimation: + ld a, [wOverworldMapPlayerHorizontalSubPixelPosition] + ld d, a + ld a, [wOverworldMapPlayerVerticalSubPixelPosition] + ld e, a + ld c, SPRITE_ANIM_COORD_X + call GetSpriteAnimBufferProperty + ld a, [wOverworldMapPlayerPathHorizontalMovement] + add d + ld d, a + ld a, [wOverworldMapPlayerPathHorizontalMovement + 1] + adc [hl] ; add carry from sub-pixel movement + ld [hl], a + inc hl + ld a, [wOverworldMapPlayerPathVerticalMovement] + add e + ld e, a + ld a, [wOverworldMapPlayerPathVerticalMovement + 1] + adc [hl] ; add carry from sub-pixel movement + ld [hl], a + ld a, d + ld [wOverworldMapPlayerHorizontalSubPixelPosition], a + ld a, e + ld [wOverworldMapPlayerVerticalSubPixelPosition], a + ld hl, wOverworldMapPlayerMovementCounter + dec [hl] + ret diff --git a/src/home/bg_map.asm b/src/home/bg_map.asm index 43dfe7b..c88d5de 100644 --- a/src/home/bg_map.asm +++ b/src/home/bg_map.asm @@ -71,7 +71,7 @@ WriteByteToBGMap0: ; fallthrough ; writes a to [v*BGMap0 + BG_MAP_WIDTH * c + b] during hblank -HblankWriteByteToBGMap0: ; 06d9 +HblankWriteByteToBGMap0: push hl push de push bc diff --git a/src/home/scroll.asm b/src/home/scroll.asm index 94896cf..bb0cdb6 100644 --- a/src/home/scroll.asm +++ b/src/home/scroll.asm @@ -114,7 +114,6 @@ BGScrollData: db 4, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 1, 1, 1, 0, 0 db 0, -1, -1, -1, -2, -2, -2, -3, -3, -3, -4, -4, -4, -4, -4, -4 db -5, -4, -4, -4, -4, -4, -4, -3, -3, -3, -2, -2, -2, -1, -1, -1 -; 3f38 ; x = BGScrollData[(wVBlankCounter + a) & $3f] ; return, in register a, x rotated right [wBGScrollMod]-1 times (max 3 times) |