pokecrystal-board/engine/pokegear/pokegear.asm

2923 lines
48 KiB
NASM
Raw Normal View History

2018-01-11 09:00:01 -08:00
; Pokégear cards
const_def
const POKEGEARCARD_CLOCK ; 0
const POKEGEARCARD_MAP ; 1
const POKEGEARCARD_PHONE ; 2
const POKEGEARCARD_RADIO ; 3
NUM_POKEGEAR_CARDS EQU const_value
PHONE_DISPLAY_HEIGHT EQU 4
2018-01-11 09:00:01 -08:00
; PokegearJumptable.Jumptable indexes
const_def
const POKEGEARSTATE_CLOCKINIT ; 0
const POKEGEARSTATE_CLOCKJOYPAD ; 1
const POKEGEARSTATE_MAPCHECKREGION ; 2
const POKEGEARSTATE_JOHTOMAPINIT ; 3
const POKEGEARSTATE_JOHTOMAPJOYPAD ; 4
const POKEGEARSTATE_KANTOMAPINIT ; 5
const POKEGEARSTATE_KANTOMAPJOYPAD ; 6
const POKEGEARSTATE_PHONEINIT ; 7
const POKEGEARSTATE_PHONEJOYPAD ; 8
const POKEGEARSTATE_MAKEPHONECALL ; 9
const POKEGEARSTATE_FINISHPHONECALL ; a
const POKEGEARSTATE_RADIOINIT ; b
const POKEGEARSTATE_RADIOJOYPAD ; c
2018-06-24 07:09:41 -07:00
PokeGear:
2018-01-23 14:39:09 -08:00
ld hl, wOptions
2015-11-16 18:07:26 -08:00
ld a, [hl]
push af
set NO_TEXT_SCROLL, [hl]
ldh a, [hInMenu]
2015-11-16 18:07:26 -08:00
push af
ld a, $1
ldh [hInMenu], a
2018-01-23 14:39:09 -08:00
ld a, [wVramState]
2015-11-16 18:07:26 -08:00
push af
xor a
2018-01-23 14:39:09 -08:00
ld [wVramState], a
2016-01-10 14:44:09 -08:00
call .InitTilemap
2015-11-16 18:07:26 -08:00
call DelayFrame
.loop
call UpdateTime
call JoyTextDelay
ld a, [wJumptableIndex]
bit 7, a
jr nz, .done
2016-01-09 20:41:03 -08:00
call PokegearJumptable
2017-12-24 09:47:30 -08:00
farcall PlaySpriteAnimations
2015-11-16 18:07:26 -08:00
call DelayFrame
jr .loop
.done
ld de, SFX_READ_TEXT_2
call PlaySFX
call WaitSFX
pop af
2018-01-23 14:39:09 -08:00
ld [wVramState], a
2015-11-16 18:07:26 -08:00
pop af
ldh [hInMenu], a
2015-11-16 18:07:26 -08:00
pop af
2018-01-23 14:39:09 -08:00
ld [wOptions], a
2015-11-16 18:07:26 -08:00
call ClearBGPalettes
2017-12-28 04:32:33 -08:00
xor a ; LOW(vBGMap0)
ldh [hBGMapAddress], a
2017-12-28 04:32:33 -08:00
ld a, HIGH(vBGMap0)
ldh [hBGMapAddress + 1], a
2020-07-21 08:48:39 -07:00
ld a, SCREEN_HEIGHT_PX
ldh [hWY], a
2016-01-10 14:44:09 -08:00
call ExitPokegearRadio_HandleMusic
2015-11-16 18:07:26 -08:00
ret
2018-06-24 07:09:41 -07:00
.InitTilemap:
2015-11-16 18:07:26 -08:00
call ClearBGPalettes
call ClearTilemap
2015-11-16 18:07:26 -08:00
call ClearSprites
call DisableLCD
xor a
ldh [hSCY], a
ldh [hSCX], a
2015-11-16 18:07:26 -08:00
ld a, $7
ldh [hWX], a
2016-01-10 14:44:09 -08:00
call Pokegear_LoadGFX
2017-12-24 09:47:30 -08:00
farcall ClearSpriteAnims
2015-12-09 08:38:40 -08:00
call InitPokegearModeIndicatorArrow
2015-11-16 18:07:26 -08:00
ld a, 8
call SkipMusic
2017-12-29 10:22:33 -08:00
ld a, LCDC_DEFAULT
ldh [rLCDC], a
2016-01-10 14:44:09 -08:00
call TownMap_InitCursorAndPlayerIconPositions
2015-11-16 18:07:26 -08:00
xor a
2018-01-11 12:36:11 -08:00
ld [wJumptableIndex], a ; POKEGEARSTATE_CLOCKINIT
ld [wPokegearCard], a ; POKEGEARCARD_CLOCK
ld [wPokegearMapRegion], a ; JOHTO_REGION
ld [wUnusedPokegearByte], a
2016-01-09 20:41:03 -08:00
ld [wPokegearPhoneScrollPosition], a
ld [wPokegearPhoneCursorPosition], a
ld [wPokegearPhoneSelectedPerson], a
ld [wPokegearRadioChannelBank], a
ld [wPokegearRadioChannelAddr], a
ld [wPokegearRadioChannelAddr + 1], a
call Pokegear_InitJumptableIndices
call InitPokegearTilemap
2015-12-28 07:57:04 -08:00
ld b, SCGB_POKEGEAR_PALS
2015-11-16 18:07:26 -08:00
call GetSGBLayout
call SetPalettes
ldh a, [hCGB]
2015-11-16 18:07:26 -08:00
and a
ret z
2015-12-09 08:38:40 -08:00
ld a, %11100100
call DmgToCgbObjPal0
2015-11-16 18:07:26 -08:00
ret
2018-06-24 07:09:41 -07:00
Pokegear_LoadGFX:
2015-11-16 18:07:26 -08:00
call ClearVBank1
ld hl, TownMapGFX
2017-12-28 04:32:33 -08:00
ld de, vTiles2
2015-11-16 18:07:26 -08:00
ld a, BANK(TownMapGFX)
call FarDecompress
ld hl, PokegearGFX
2018-01-14 16:43:35 -08:00
ld de, vTiles2 tile $30
2015-11-16 18:07:26 -08:00
ld a, BANK(PokegearGFX)
call FarDecompress
ld hl, PokegearSpritesGFX
2017-12-28 04:32:33 -08:00
ld de, vTiles0
2015-11-16 18:07:26 -08:00
ld a, BANK(PokegearSpritesGFX)
call Decompress
2018-01-23 14:39:09 -08:00
ld a, [wMapGroup]
2015-11-16 18:07:26 -08:00
ld b, a
2018-01-23 14:39:09 -08:00
ld a, [wMapNumber]
2015-11-16 18:07:26 -08:00
ld c, a
call GetWorldMapLocation
cp LANDMARK_FAST_SHIP
2015-11-16 18:07:26 -08:00
jr z, .ssaqua
2017-12-24 09:47:30 -08:00
farcall GetPlayerIcon
2015-11-16 18:07:26 -08:00
push de
ld h, d
ld l, e
ld a, b
2015-12-09 08:38:40 -08:00
; standing sprite
2015-11-16 18:07:26 -08:00
push af
2017-12-28 04:32:33 -08:00
ld de, vTiles0 tile $10
2015-11-16 18:07:26 -08:00
ld bc, 4 tiles
call FarCopyBytes
pop af
pop hl
2015-12-09 08:38:40 -08:00
; walking sprite
ld de, 12 tiles
2015-11-16 18:07:26 -08:00
add hl, de
2017-12-28 04:32:33 -08:00
ld de, vTiles0 tile $14
2015-11-16 18:07:26 -08:00
ld bc, 4 tiles
call FarCopyBytes
ret
.ssaqua
ld hl, FastShipGFX
2017-12-28 04:32:33 -08:00
ld de, vTiles0 tile $10
2015-11-16 18:07:26 -08:00
ld bc, 8 tiles
call CopyBytes
ret
2016-01-09 20:41:03 -08:00
2018-06-24 07:09:41 -07:00
FastShipGFX:
INCBIN "gfx/pokegear/fast_ship.2bpp"
2015-11-16 18:07:26 -08:00
2018-06-24 07:09:41 -07:00
InitPokegearModeIndicatorArrow:
2015-11-18 10:01:55 -08:00
depixel 4, 2, 4, 0
ld a, SPRITE_ANIM_INDEX_POKEGEAR_ARROW
call InitSpriteAnimStruct
2015-12-09 08:38:40 -08:00
ld hl, SPRITEANIMSTRUCT_TILE_ID
2015-11-16 18:07:26 -08:00
add hl, bc
ld [hl], $0
ret
2018-06-24 07:09:41 -07:00
AnimatePokegearModeIndicatorArrow:
2018-01-11 12:36:11 -08:00
ld hl, wPokegearCard
2015-11-16 18:07:26 -08:00
ld e, [hl]
ld d, 0
2016-01-10 14:44:09 -08:00
ld hl, .XCoords
2015-11-16 18:07:26 -08:00
add hl, de
ld a, [hl]
2016-01-10 14:44:09 -08:00
ld hl, SPRITEANIMSTRUCT_XOFFSET
2015-11-16 18:07:26 -08:00
add hl, bc
ld [hl], a
ret
2016-01-09 20:41:03 -08:00
2018-06-24 07:09:41 -07:00
.XCoords:
2018-01-11 09:00:01 -08:00
db $00 ; POKEGEARCARD_CLOCK
db $10 ; POKEGEARCARD_MAP
db $20 ; POKEGEARCARD_PHONE
db $30 ; POKEGEARCARD_RADIO
2015-11-16 18:07:26 -08:00
2018-06-24 07:09:41 -07:00
TownMap_GetCurrentLandmark:
2018-01-23 14:39:09 -08:00
ld a, [wMapGroup]
2015-11-16 18:07:26 -08:00
ld b, a
2018-01-23 14:39:09 -08:00
ld a, [wMapNumber]
2015-11-16 18:07:26 -08:00
ld c, a
call GetWorldMapLocation
cp LANDMARK_SPECIAL
2015-11-16 18:07:26 -08:00
ret nz
2018-01-23 14:39:09 -08:00
ld a, [wBackupMapGroup]
2015-11-16 18:07:26 -08:00
ld b, a
2018-01-23 14:39:09 -08:00
ld a, [wBackupMapNumber]
2015-11-16 18:07:26 -08:00
ld c, a
call GetWorldMapLocation
ret
2018-06-24 07:09:41 -07:00
TownMap_InitCursorAndPlayerIconPositions:
2018-01-23 14:39:09 -08:00
ld a, [wMapGroup]
2015-11-16 18:07:26 -08:00
ld b, a
2018-01-23 14:39:09 -08:00
ld a, [wMapNumber]
2015-11-16 18:07:26 -08:00
ld c, a
call GetWorldMapLocation
cp LANDMARK_FAST_SHIP
2015-12-09 08:38:40 -08:00
jr z, .FastShip
cp LANDMARK_SPECIAL
2015-12-09 08:38:40 -08:00
jr nz, .LoadLandmark
2018-01-23 14:39:09 -08:00
ld a, [wBackupMapGroup]
2015-11-16 18:07:26 -08:00
ld b, a
2018-01-23 14:39:09 -08:00
ld a, [wBackupMapNumber]
2015-11-16 18:07:26 -08:00
ld c, a
call GetWorldMapLocation
.LoadLandmark:
2016-01-12 09:46:18 -08:00
ld [wPokegearMapPlayerIconLandmark], a
ld [wPokegearMapCursorLandmark], a
2015-11-16 18:07:26 -08:00
ret
.FastShip:
2016-01-12 09:46:18 -08:00
ld [wPokegearMapPlayerIconLandmark], a
ld a, LANDMARK_NEW_BARK_TOWN
2016-01-12 09:46:18 -08:00
ld [wPokegearMapCursorLandmark], a
2015-11-16 18:07:26 -08:00
ret
2018-06-24 07:09:41 -07:00
Pokegear_InitJumptableIndices:
2018-01-11 09:00:01 -08:00
ld a, POKEGEARSTATE_CLOCKINIT
2015-11-16 18:07:26 -08:00
ld [wJumptableIndex], a
2018-01-11 12:36:11 -08:00
xor a ; POKEGEARCARD_CLOCK
ld [wPokegearCard], a
2015-11-16 18:07:26 -08:00
ret
2018-06-24 07:09:41 -07:00
InitPokegearTilemap:
2015-11-16 18:07:26 -08:00
xor a
ldh [hBGMapMode], a
2015-11-16 18:07:26 -08:00
hlcoord 0, 0
ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
2015-11-16 18:07:26 -08:00
ld a, $4f
call ByteFill
2018-01-11 12:36:11 -08:00
ld a, [wPokegearCard]
2018-01-16 14:27:50 -08:00
maskbits NUM_POKEGEAR_CARDS
2015-11-16 18:07:26 -08:00
add a
ld e, a
ld d, 0
2016-01-09 20:41:03 -08:00
ld hl, .Jumptable
2015-11-16 18:07:26 -08:00
add hl, de
ld a, [hli]
ld h, [hl]
ld l, a
2016-01-09 20:41:03 -08:00
ld de, .return_from_jumptable
2015-11-16 18:07:26 -08:00
push de
jp hl
2015-11-16 18:07:26 -08:00
2016-01-09 20:41:03 -08:00
.return_from_jumptable
2016-01-10 14:44:09 -08:00
call Pokegear_FinishTilemap
2017-12-24 09:47:30 -08:00
farcall TownMapPals
2018-01-11 12:36:11 -08:00
ld a, [wPokegearMapRegion]
2015-11-16 18:07:26 -08:00
and a
2016-01-09 20:41:03 -08:00
jr nz, .kanto_0
2017-12-28 04:32:33 -08:00
xor a ; LOW(vBGMap0)
ldh [hBGMapAddress], a
2017-12-28 04:32:33 -08:00
ld a, HIGH(vBGMap0)
ldh [hBGMapAddress + 1], a
2016-01-09 20:41:03 -08:00
call .UpdateBGMap
2020-07-21 08:48:39 -07:00
ld a, SCREEN_HEIGHT_PX
2016-01-09 20:41:03 -08:00
jr .finish
2015-11-16 18:07:26 -08:00
2016-01-09 20:41:03 -08:00
.kanto_0
2017-12-28 04:32:33 -08:00
xor a ; LOW(vBGMap1)
ldh [hBGMapAddress], a
2017-12-28 04:32:33 -08:00
ld a, HIGH(vBGMap1)
ldh [hBGMapAddress + 1], a
2016-01-09 20:41:03 -08:00
call .UpdateBGMap
2015-11-16 18:07:26 -08:00
xor a
2016-01-09 20:41:03 -08:00
.finish
ldh [hWY], a
2018-01-11 09:00:01 -08:00
; swap region maps
2018-01-11 12:36:11 -08:00
ld a, [wPokegearMapRegion]
2018-01-16 14:27:50 -08:00
maskbits NUM_REGIONS
2015-11-16 18:07:26 -08:00
xor 1
2018-01-11 12:36:11 -08:00
ld [wPokegearMapRegion], a
2015-11-16 18:07:26 -08:00
ret
2018-06-24 07:09:41 -07:00
.UpdateBGMap:
ldh a, [hCGB]
2015-11-16 18:07:26 -08:00
and a
2016-01-10 14:44:09 -08:00
jr z, .dmg
2015-11-16 18:07:26 -08:00
ld a, $2
ldh [hBGMapMode], a
2015-11-16 18:07:26 -08:00
ld c, 3
call DelayFrames
2016-01-10 14:44:09 -08:00
.dmg
2015-11-16 18:07:26 -08:00
call WaitBGMap
ret
2016-01-09 20:41:03 -08:00
2018-06-24 07:09:41 -07:00
.Jumptable:
2018-01-11 09:00:01 -08:00
; entries correspond to POKEGEARCARD_* constants
2016-01-09 20:41:03 -08:00
dw .Clock
dw .Map
dw .Phone
dw .Radio
2015-11-16 18:07:26 -08:00
2018-06-24 07:09:41 -07:00
.Clock:
2015-11-16 18:07:26 -08:00
ld de, ClockTilemapRLE
2016-01-09 20:41:03 -08:00
call Pokegear_LoadTilemapRLE
2015-11-16 18:07:26 -08:00
hlcoord 12, 1
ld de, .switch
call PlaceString
hlcoord 0, 12
lb bc, 4, 18
2019-04-08 05:15:10 -07:00
call Textbox
2016-01-09 20:41:03 -08:00
call Pokegear_UpdateClock
2015-11-16 18:07:26 -08:00
ret
2016-01-09 20:41:03 -08:00
2015-11-16 18:07:26 -08:00
.switch
db " SWITCH▶@"
2018-06-24 07:09:41 -07:00
.Map:
2016-01-12 09:46:18 -08:00
ld a, [wPokegearMapPlayerIconLandmark]
cp LANDMARK_FAST_SHIP
2015-11-16 18:07:26 -08:00
jr z, .johto
cp KANTO_LANDMARK
jr nc, .kanto
.johto
ld e, 0
jr .ok
2016-01-09 20:41:03 -08:00
2015-11-16 18:07:26 -08:00
.kanto
ld e, 1
.ok
2017-12-24 09:47:30 -08:00
farcall PokegearMap
2018-01-11 09:00:01 -08:00
ld a, $07
2019-06-09 16:52:46 -07:00
ld bc, SCREEN_WIDTH - 2
2015-11-16 18:07:26 -08:00
hlcoord 1, 2
call ByteFill
hlcoord 0, 2
2018-01-11 09:00:01 -08:00
ld [hl], $06
2015-11-16 18:07:26 -08:00
hlcoord 19, 2
ld [hl], $17
2016-01-12 09:46:18 -08:00
ld a, [wPokegearMapCursorLandmark]
2016-01-10 14:44:09 -08:00
call PokegearMap_UpdateLandmarkName
2015-11-16 18:07:26 -08:00
ret
2016-01-09 20:41:03 -08:00
2018-06-24 07:09:41 -07:00
.Radio:
2015-11-16 18:07:26 -08:00
ld de, RadioTilemapRLE
2016-01-09 20:41:03 -08:00
call Pokegear_LoadTilemapRLE
2015-11-16 18:07:26 -08:00
hlcoord 0, 12
lb bc, 4, 18
2019-04-08 05:15:10 -07:00
call Textbox
2015-11-16 18:07:26 -08:00
ret
2016-01-09 20:41:03 -08:00
2018-06-24 07:09:41 -07:00
.Phone:
2015-11-16 18:07:26 -08:00
ld de, PhoneTilemapRLE
2016-01-09 20:41:03 -08:00
call Pokegear_LoadTilemapRLE
2015-11-16 18:07:26 -08:00
hlcoord 0, 12
lb bc, 4, 18
2019-04-08 05:15:10 -07:00
call Textbox
2016-01-10 14:44:09 -08:00
call .PlacePhoneBars
2016-01-09 20:41:03 -08:00
call PokegearPhone_UpdateDisplayList
2015-11-16 18:07:26 -08:00
ret
2016-01-09 20:41:03 -08:00
2018-06-24 07:09:41 -07:00
.PlacePhoneBars:
2015-11-16 18:07:26 -08:00
hlcoord 17, 1
ld a, $3c
ld [hli], a
inc a
ld [hl], a
hlcoord 17, 2
inc a
ld [hli], a
call GetMapPhoneService
2015-11-16 18:07:26 -08:00
and a
ret nz
hlcoord 18, 2
ld [hl], $3f
ret
2018-06-24 07:09:41 -07:00
Pokegear_FinishTilemap:
2015-11-16 18:07:26 -08:00
hlcoord 0, 0
ld bc, $8
ld a, $4f
call ByteFill
hlcoord 0, 1
ld bc, $8
ld a, $4f
call ByteFill
ld de, wPokegearFlags
ld a, [de]
bit POKEGEAR_MAP_CARD_F, a
2016-01-10 14:44:09 -08:00
call nz, .PlaceMapIcon
2015-11-16 18:07:26 -08:00
ld a, [de]
bit POKEGEAR_PHONE_CARD_F, a
2016-01-10 14:44:09 -08:00
call nz, .PlacePhoneIcon
2015-11-16 18:07:26 -08:00
ld a, [de]
bit POKEGEAR_RADIO_CARD_F, a
2016-01-10 14:44:09 -08:00
call nz, .PlaceRadioIcon
2015-11-16 18:07:26 -08:00
hlcoord 0, 0
ld a, $46
2016-01-10 14:44:09 -08:00
call .PlacePokegearCardIcon
2015-11-16 18:07:26 -08:00
ret
2018-06-24 07:09:41 -07:00
.PlaceMapIcon:
2015-11-16 18:07:26 -08:00
hlcoord 2, 0
ld a, $40
2016-01-10 14:44:09 -08:00
jr .PlacePokegearCardIcon
2015-11-16 18:07:26 -08:00
2018-06-24 07:09:41 -07:00
.PlacePhoneIcon:
2015-11-16 18:07:26 -08:00
hlcoord 4, 0
ld a, $44
2016-01-10 14:44:09 -08:00
jr .PlacePokegearCardIcon
2015-11-16 18:07:26 -08:00
2018-06-24 07:09:41 -07:00
.PlaceRadioIcon:
2015-11-16 18:07:26 -08:00
hlcoord 6, 0
ld a, $42
2018-06-24 07:09:41 -07:00
.PlacePokegearCardIcon:
2015-11-16 18:07:26 -08:00
ld [hli], a
inc a
ld [hld], a
ld bc, $14
add hl, bc
add $f
ld [hli], a
inc a
ld [hld], a
ret
2018-06-24 07:09:41 -07:00
PokegearJumptable:
jumptable .Jumptable, wJumptableIndex
2015-11-16 18:07:26 -08:00
2018-06-24 07:09:41 -07:00
.Jumptable:
2018-01-11 09:00:01 -08:00
; entries correspond to POKEGEARSTATE_* constants
2016-01-09 20:41:03 -08:00
dw PokegearClock_Init
dw PokegearClock_Joypad
dw PokegearMap_CheckRegion
dw PokegearMap_Init
dw PokegearMap_JohtoMap
dw PokegearMap_Init
dw PokegearMap_KantoMap
dw PokegearPhone_Init
dw PokegearPhone_Joypad
dw PokegearPhone_MakePhoneCall
dw PokegearPhone_FinishPhoneCall
dw PokegearRadio_Init
dw PokegearRadio_Joypad
2018-06-24 07:09:41 -07:00
PokegearClock_Init:
2016-01-09 20:41:03 -08:00
call InitPokegearTilemap
ld hl, PokegearPressButtonText
2015-11-16 18:07:26 -08:00
call PrintText
ld hl, wJumptableIndex
inc [hl]
2016-01-10 14:44:09 -08:00
call ExitPokegearRadio_HandleMusic
2015-11-16 18:07:26 -08:00
ret
2018-06-24 07:09:41 -07:00
PokegearClock_Joypad:
2016-01-09 20:41:03 -08:00
call .UpdateClock
2015-11-16 18:07:26 -08:00
ld hl, hJoyLast
ld a, [hl]
2018-01-11 09:00:01 -08:00
and A_BUTTON | B_BUTTON | START | SELECT
2016-01-09 20:41:03 -08:00
jr nz, .quit
2015-11-16 18:07:26 -08:00
ld a, [hl]
and D_RIGHT
ret z
ld a, [wPokegearFlags]
bit POKEGEAR_MAP_CARD_F, a
2016-01-09 20:41:03 -08:00
jr z, .no_map_card
2018-01-11 09:00:01 -08:00
ld c, POKEGEARSTATE_MAPCHECKREGION
ld b, POKEGEARCARD_MAP
2016-01-09 20:41:03 -08:00
jr .done
2015-11-16 18:07:26 -08:00
2016-01-09 20:41:03 -08:00
.no_map_card
2015-11-16 18:07:26 -08:00
ld a, [wPokegearFlags]
bit POKEGEAR_PHONE_CARD_F, a
2016-01-09 20:41:03 -08:00
jr z, .no_phone_card
2018-01-11 09:00:01 -08:00
ld c, POKEGEARSTATE_PHONEINIT
ld b, POKEGEARCARD_PHONE
2016-01-09 20:41:03 -08:00
jr .done
2015-11-16 18:07:26 -08:00
2016-01-09 20:41:03 -08:00
.no_phone_card
2015-11-16 18:07:26 -08:00
ld a, [wPokegearFlags]
bit POKEGEAR_RADIO_CARD_F, a
2015-11-16 18:07:26 -08:00
ret z
2018-01-11 09:00:01 -08:00
ld c, POKEGEARSTATE_RADIOINIT
ld b, POKEGEARCARD_RADIO
2016-01-09 20:41:03 -08:00
.done
call Pokegear_SwitchPage
2015-11-16 18:07:26 -08:00
ret
2016-01-09 20:41:03 -08:00
.quit
2015-11-16 18:07:26 -08:00
ld hl, wJumptableIndex
set 7, [hl]
ret
2018-06-24 07:09:41 -07:00
.UpdateClock:
2015-11-16 18:07:26 -08:00
xor a
ldh [hBGMapMode], a
2016-01-09 20:41:03 -08:00
call Pokegear_UpdateClock
2015-11-16 18:07:26 -08:00
ld a, $1
ldh [hBGMapMode], a
2015-11-16 18:07:26 -08:00
ret
2018-06-24 07:09:41 -07:00
Pokegear_UpdateClock:
2015-11-16 18:07:26 -08:00
hlcoord 3, 5
lb bc, 5, 14
call ClearBox
ldh a, [hHours]
2015-11-16 18:07:26 -08:00
ld b, a
ldh a, [hMinutes]
2015-11-16 18:07:26 -08:00
ld c, a
decoord 6, 8
2017-12-24 09:47:30 -08:00
farcall PrintHoursMins
ld hl, .GearTodayText
2015-11-16 18:07:26 -08:00
bccoord 6, 6
call PlaceHLTextAtBC
2015-11-16 18:07:26 -08:00
ret
2016-01-09 20:41:03 -08:00
db "ごぜん@"
db "ごご@"
2015-11-16 18:07:26 -08:00
.GearTodayText:
text_far _GearTodayText
text_end
2016-01-09 20:41:03 -08:00
2018-06-24 07:09:41 -07:00
PokegearMap_CheckRegion:
2016-01-12 09:46:18 -08:00
ld a, [wPokegearMapPlayerIconLandmark]
cp LANDMARK_FAST_SHIP
2015-11-16 18:07:26 -08:00
jr z, .johto
cp KANTO_LANDMARK
jr nc, .kanto
.johto
2018-01-11 09:00:01 -08:00
ld a, POKEGEARSTATE_JOHTOMAPINIT
2015-11-16 18:07:26 -08:00
jr .done
ret
.kanto
2018-01-11 09:00:01 -08:00
ld a, POKEGEARSTATE_KANTOMAPINIT
2015-11-16 18:07:26 -08:00
.done
ld [wJumptableIndex], a
2016-01-10 14:44:09 -08:00
call ExitPokegearRadio_HandleMusic
2015-11-16 18:07:26 -08:00
ret
2018-06-24 07:09:41 -07:00
PokegearMap_Init:
2016-01-09 20:41:03 -08:00
call InitPokegearTilemap
2016-01-12 09:46:18 -08:00
ld a, [wPokegearMapPlayerIconLandmark]
2016-01-09 20:41:03 -08:00
call PokegearMap_InitPlayerIcon
2016-01-12 09:46:18 -08:00
ld a, [wPokegearMapCursorLandmark]
2016-01-09 20:41:03 -08:00
call PokegearMap_InitCursor
2015-11-16 18:07:26 -08:00
ld a, c
2016-01-09 20:41:03 -08:00
ld [wPokegearMapCursorObjectPointer], a
2015-11-16 18:07:26 -08:00
ld a, b
2016-01-09 20:41:03 -08:00
ld [wPokegearMapCursorObjectPointer + 1], a
2015-11-16 18:07:26 -08:00
ld hl, wJumptableIndex
inc [hl]
ret
2018-06-24 07:09:41 -07:00
PokegearMap_KantoMap:
2016-01-05 05:46:37 -08:00
call TownMap_GetKantoLandmarkLimits
2016-01-09 20:41:03 -08:00
jr PokegearMap_ContinueMap
2015-11-16 18:07:26 -08:00
2018-06-24 07:09:41 -07:00
PokegearMap_JohtoMap:
ld d, LANDMARK_SILVER_CAVE
ld e, LANDMARK_NEW_BARK_TOWN
2018-06-24 07:09:41 -07:00
PokegearMap_ContinueMap:
2015-11-16 18:07:26 -08:00
ld hl, hJoyLast
ld a, [hl]
and B_BUTTON
jr nz, .cancel
ld a, [hl]
and D_RIGHT
jr nz, .right
ld a, [hl]
and D_LEFT
jr nz, .left
2016-01-09 20:41:03 -08:00
call .DPad
2015-11-16 18:07:26 -08:00
ret
.right
ld a, [wPokegearFlags]
bit POKEGEAR_PHONE_CARD_F, a
2016-01-09 20:41:03 -08:00
jr z, .no_phone
2018-01-11 09:00:01 -08:00
ld c, POKEGEARSTATE_PHONEINIT
ld b, POKEGEARCARD_PHONE
2015-11-16 18:07:26 -08:00
jr .done
2016-01-09 20:41:03 -08:00
.no_phone
2015-11-16 18:07:26 -08:00
ld a, [wPokegearFlags]
bit POKEGEAR_RADIO_CARD_F, a
2015-11-16 18:07:26 -08:00
ret z
2018-01-11 09:00:01 -08:00
ld c, POKEGEARSTATE_RADIOINIT
ld b, POKEGEARCARD_RADIO
2015-11-16 18:07:26 -08:00
jr .done
.left
2018-01-11 09:00:01 -08:00
ld c, POKEGEARSTATE_CLOCKINIT
ld b, POKEGEARCARD_CLOCK
2015-11-16 18:07:26 -08:00
.done
2016-01-09 20:41:03 -08:00
call Pokegear_SwitchPage
2015-11-16 18:07:26 -08:00
ret
2016-01-09 20:41:03 -08:00
2015-11-16 18:07:26 -08:00
.cancel
ld hl, wJumptableIndex
set 7, [hl]
ret
2018-06-24 07:09:41 -07:00
.DPad:
2015-11-16 18:07:26 -08:00
ld hl, hJoyLast
ld a, [hl]
and D_UP
jr nz, .up
ld a, [hl]
and D_DOWN
jr nz, .down
ret
2016-01-09 20:41:03 -08:00
2015-11-16 18:07:26 -08:00
.up
2016-01-12 09:46:18 -08:00
ld hl, wPokegearMapCursorLandmark
2015-11-16 18:07:26 -08:00
ld a, [hl]
cp d
2016-01-09 20:41:03 -08:00
jr c, .wrap_around_up
2015-11-16 18:07:26 -08:00
ld a, e
dec a
ld [hl], a
2016-01-09 20:41:03 -08:00
.wrap_around_up
2015-11-16 18:07:26 -08:00
inc [hl]
2016-01-09 20:41:03 -08:00
jr .done_dpad
2015-11-16 18:07:26 -08:00
.down
2016-01-12 09:46:18 -08:00
ld hl, wPokegearMapCursorLandmark
2015-11-16 18:07:26 -08:00
ld a, [hl]
cp e
2016-01-09 20:41:03 -08:00
jr nz, .wrap_around_down
2015-11-16 18:07:26 -08:00
ld a, d
inc a
ld [hl], a
2016-01-09 20:41:03 -08:00
.wrap_around_down
2015-11-16 18:07:26 -08:00
dec [hl]
2016-01-09 20:41:03 -08:00
.done_dpad
2016-01-12 09:46:18 -08:00
ld a, [wPokegearMapCursorLandmark]
2016-01-10 14:44:09 -08:00
call PokegearMap_UpdateLandmarkName
2016-01-09 20:41:03 -08:00
ld a, [wPokegearMapCursorObjectPointer]
2015-11-16 18:07:26 -08:00
ld c, a
2016-01-09 20:41:03 -08:00
ld a, [wPokegearMapCursorObjectPointer + 1]
2015-11-16 18:07:26 -08:00
ld b, a
2016-01-12 09:46:18 -08:00
ld a, [wPokegearMapCursorLandmark]
2016-01-10 14:44:09 -08:00
call PokegearMap_UpdateCursorPosition
2015-11-16 18:07:26 -08:00
ret
2018-06-24 07:09:41 -07:00
PokegearMap_InitPlayerIcon:
2015-11-16 18:07:26 -08:00
push af
2015-12-09 08:38:40 -08:00
depixel 0, 0
2016-01-09 20:41:03 -08:00
ld b, SPRITE_ANIM_INDEX_RED_WALK
ld a, [wPlayerGender]
2018-01-22 11:34:55 -08:00
bit PLAYERGENDER_FEMALE_F, a
2016-01-09 20:41:03 -08:00
jr z, .got_gender
ld b, SPRITE_ANIM_INDEX_BLUE_WALK
.got_gender
2015-11-16 18:07:26 -08:00
ld a, b
call InitSpriteAnimStruct
2015-12-09 08:38:40 -08:00
ld hl, SPRITEANIMSTRUCT_TILE_ID
2015-11-16 18:07:26 -08:00
add hl, bc
ld [hl], $10
pop af
ld e, a
push bc
2017-12-24 09:47:30 -08:00
farcall GetLandmarkCoords
2015-11-16 18:07:26 -08:00
pop bc
2015-12-09 08:38:40 -08:00
ld hl, SPRITEANIMSTRUCT_XCOORD
2015-11-16 18:07:26 -08:00
add hl, bc
ld [hl], e
2015-12-09 08:38:40 -08:00
ld hl, SPRITEANIMSTRUCT_YCOORD
2015-11-16 18:07:26 -08:00
add hl, bc
ld [hl], d
ret
2016-01-09 20:41:03 -08:00
2018-06-24 07:09:41 -07:00
PokegearMap_InitCursor:
2015-11-16 18:07:26 -08:00
push af
2015-12-09 08:38:40 -08:00
depixel 0, 0
ld a, SPRITE_ANIM_INDEX_POKEGEAR_ARROW
call InitSpriteAnimStruct
2015-12-09 08:38:40 -08:00
ld hl, SPRITEANIMSTRUCT_TILE_ID
2015-11-16 18:07:26 -08:00
add hl, bc
2018-01-11 09:00:01 -08:00
ld [hl], $04
2015-12-09 08:38:40 -08:00
ld hl, SPRITEANIMSTRUCT_ANIM_SEQ_ID
2015-11-16 18:07:26 -08:00
add hl, bc
2015-12-18 17:07:09 -08:00
ld [hl], SPRITE_ANIM_SEQ_NULL
2015-11-16 18:07:26 -08:00
pop af
push bc
2016-01-10 14:44:09 -08:00
call PokegearMap_UpdateCursorPosition
2015-11-16 18:07:26 -08:00
pop bc
ret
2016-01-09 20:41:03 -08:00
2018-06-24 07:09:41 -07:00
PokegearMap_UpdateLandmarkName:
2015-11-16 18:07:26 -08:00
push af
hlcoord 8, 0
lb bc, 2, 12
call ClearBox
pop af
ld e, a
push de
2017-12-24 09:47:30 -08:00
farcall GetLandmarkName
2015-11-16 18:07:26 -08:00
pop de
2017-12-24 09:47:30 -08:00
farcall TownMap_ConvertLineBreakCharacters
2015-11-16 18:07:26 -08:00
hlcoord 8, 0
ld [hl], $34
ret
2016-01-09 20:41:03 -08:00
2018-06-24 07:09:41 -07:00
PokegearMap_UpdateCursorPosition:
2015-11-16 18:07:26 -08:00
push bc
ld e, a
2017-12-24 09:47:30 -08:00
farcall GetLandmarkCoords
2015-11-16 18:07:26 -08:00
pop bc
2015-12-09 08:38:40 -08:00
ld hl, SPRITEANIMSTRUCT_XCOORD
2015-11-16 18:07:26 -08:00
add hl, bc
ld [hl], e
2015-12-09 08:38:40 -08:00
ld hl, SPRITEANIMSTRUCT_YCOORD
2015-11-16 18:07:26 -08:00
add hl, bc
ld [hl], d
ret
2016-01-09 20:41:03 -08:00
2018-06-24 07:09:41 -07:00
TownMap_GetKantoLandmarkLimits:
ld a, [wStatusFlags]
2018-01-22 12:40:43 -08:00
bit STATUSFLAGS_HALL_OF_FAME_F, a
2016-01-05 05:46:37 -08:00
jr z, .not_hof
ld d, LANDMARK_ROUTE_28
ld e, LANDMARK_PALLET_TOWN
2015-11-16 18:07:26 -08:00
ret
2016-01-05 05:46:37 -08:00
.not_hof
ld d, LANDMARK_ROUTE_28
ld e, LANDMARK_VICTORY_ROAD
2015-11-16 18:07:26 -08:00
ret
2018-06-24 07:09:41 -07:00
PokegearRadio_Init:
2016-01-09 20:41:03 -08:00
call InitPokegearTilemap
2015-11-18 10:01:55 -08:00
depixel 4, 10, 4, 4
ld a, SPRITE_ANIM_INDEX_RADIO_TUNING_KNOB
call InitSpriteAnimStruct
2015-12-09 08:38:40 -08:00
ld hl, SPRITEANIMSTRUCT_TILE_ID
2015-11-16 18:07:26 -08:00
add hl, bc
2018-01-11 09:00:01 -08:00
ld [hl], $08
2015-11-16 18:07:26 -08:00
call _UpdateRadioStation
ld hl, wJumptableIndex
inc [hl]
ret
2018-06-24 07:09:41 -07:00
PokegearRadio_Joypad:
2015-11-16 18:07:26 -08:00
ld hl, hJoyLast
ld a, [hl]
and B_BUTTON
jr nz, .cancel
ld a, [hl]
and D_LEFT
jr nz, .left
2016-01-09 20:41:03 -08:00
ld a, [wPokegearRadioChannelAddr]
2015-11-16 18:07:26 -08:00
ld l, a
2016-01-09 20:41:03 -08:00
ld a, [wPokegearRadioChannelAddr + 1]
2015-11-16 18:07:26 -08:00
ld h, a
2016-01-09 20:41:03 -08:00
ld a, [wPokegearRadioChannelBank]
2015-11-16 18:07:26 -08:00
and a
ret z
rst FarCall
ret
.left
ld a, [wPokegearFlags]
bit POKEGEAR_PHONE_CARD_F, a
2016-01-10 14:44:09 -08:00
jr z, .no_phone
2018-01-11 09:00:01 -08:00
ld c, POKEGEARSTATE_PHONEINIT
ld b, POKEGEARCARD_PHONE
2016-01-10 14:44:09 -08:00
jr .switch_page
2015-11-16 18:07:26 -08:00
2016-01-10 14:44:09 -08:00
.no_phone
2015-11-16 18:07:26 -08:00
ld a, [wPokegearFlags]
bit POKEGEAR_MAP_CARD_F, a
2016-01-10 14:44:09 -08:00
jr z, .no_map
2018-01-11 09:00:01 -08:00
ld c, POKEGEARSTATE_MAPCHECKREGION
ld b, POKEGEARCARD_MAP
2016-01-10 14:44:09 -08:00
jr .switch_page
2015-11-16 18:07:26 -08:00
2016-01-10 14:44:09 -08:00
.no_map
2018-01-11 09:00:01 -08:00
ld c, POKEGEARSTATE_CLOCKINIT
ld b, POKEGEARCARD_CLOCK
2016-01-10 14:44:09 -08:00
.switch_page
2016-01-09 20:41:03 -08:00
call Pokegear_SwitchPage
2015-11-16 18:07:26 -08:00
ret
.cancel
ld hl, wJumptableIndex
set 7, [hl]
ret
2018-06-24 07:09:41 -07:00
PokegearPhone_Init:
2015-11-16 18:07:26 -08:00
ld hl, wJumptableIndex
inc [hl]
xor a
2016-01-09 20:41:03 -08:00
ld [wPokegearPhoneScrollPosition], a
ld [wPokegearPhoneCursorPosition], a
ld [wPokegearPhoneSelectedPerson], a
call InitPokegearTilemap
2016-01-10 14:44:09 -08:00
call ExitPokegearRadio_HandleMusic
ld hl, PokegearAskWhoCallText
2015-11-16 18:07:26 -08:00
call PrintText
ret
2018-06-24 07:09:41 -07:00
PokegearPhone_Joypad:
2015-11-16 18:07:26 -08:00
ld hl, hJoyPressed
ld a, [hl]
and B_BUTTON
jr nz, .b
ld a, [hl]
and A_BUTTON
jr nz, .a
ld hl, hJoyLast
ld a, [hl]
and D_LEFT
jr nz, .left
ld a, [hl]
and D_RIGHT
jr nz, .right
2016-01-09 20:41:03 -08:00
call PokegearPhone_GetDPad
2015-11-16 18:07:26 -08:00
ret
.left
ld a, [wPokegearFlags]
bit POKEGEAR_MAP_CARD_F, a
2016-01-10 14:44:09 -08:00
jr z, .no_map
2018-01-11 09:00:01 -08:00
ld c, POKEGEARSTATE_MAPCHECKREGION
ld b, POKEGEARCARD_MAP
2016-01-10 14:44:09 -08:00
jr .switch_page
2016-01-09 20:41:03 -08:00
2016-01-10 14:44:09 -08:00
.no_map
2018-01-11 09:00:01 -08:00
ld c, POKEGEARSTATE_CLOCKINIT
ld b, POKEGEARCARD_CLOCK
2016-01-10 14:44:09 -08:00
jr .switch_page
2015-11-16 18:07:26 -08:00
.right
ld a, [wPokegearFlags]
bit POKEGEAR_RADIO_CARD_F, a
2015-11-16 18:07:26 -08:00
ret z
2018-01-11 09:00:01 -08:00
ld c, POKEGEARSTATE_RADIOINIT
ld b, POKEGEARCARD_RADIO
2016-01-10 14:44:09 -08:00
.switch_page
2016-01-09 20:41:03 -08:00
call Pokegear_SwitchPage
2015-11-16 18:07:26 -08:00
ret
.b
ld hl, wJumptableIndex
set 7, [hl]
ret
.a
ld hl, wPhoneList
2016-01-09 20:41:03 -08:00
ld a, [wPokegearPhoneScrollPosition]
2015-11-16 18:07:26 -08:00
ld e, a
ld d, 0
add hl, de
2016-01-09 20:41:03 -08:00
ld a, [wPokegearPhoneCursorPosition]
2015-11-16 18:07:26 -08:00
ld e, a
ld d, 0
add hl, de
ld a, [hl]
and a
ret z
2016-01-09 20:41:03 -08:00
ld [wPokegearPhoneSelectedPerson], a
2015-11-16 18:07:26 -08:00
hlcoord 1, 4
2016-01-09 20:41:03 -08:00
ld a, [wPokegearPhoneCursorPosition]
ld bc, SCREEN_WIDTH * 2
2015-11-16 18:07:26 -08:00
call AddNTimes
ld [hl], "▷"
2016-01-09 20:41:03 -08:00
call PokegearPhoneContactSubmenu
2016-01-10 14:44:09 -08:00
jr c, .quit_submenu
2015-11-16 18:07:26 -08:00
ld hl, wJumptableIndex
inc [hl]
ret
2016-01-10 14:44:09 -08:00
.quit_submenu
2018-01-11 09:00:01 -08:00
ld a, POKEGEARSTATE_PHONEJOYPAD
2015-11-16 18:07:26 -08:00
ld [wJumptableIndex], a
ret
2018-06-24 07:09:41 -07:00
PokegearPhone_MakePhoneCall:
call GetMapPhoneService
2015-11-16 18:07:26 -08:00
and a
2016-01-10 14:44:09 -08:00
jr nz, .no_service
2018-01-23 14:39:09 -08:00
ld hl, wOptions
2015-11-16 18:07:26 -08:00
res NO_TEXT_SCROLL, [hl]
xor a
ldh [hInMenu], a
2015-11-16 18:07:26 -08:00
ld de, SFX_CALL
call PlaySFX
ld hl, .GearEllipseText
2015-11-16 18:07:26 -08:00
call PrintText
call WaitSFX
ld de, SFX_CALL
call PlaySFX
ld hl, .GearEllipseText
2015-11-16 18:07:26 -08:00
call PrintText
call WaitSFX
2016-01-09 20:41:03 -08:00
ld a, [wPokegearPhoneSelectedPerson]
2015-11-16 18:07:26 -08:00
ld b, a
2020-10-04 19:34:50 -07:00
call MakePhoneCallFromPokegear
2015-11-16 18:07:26 -08:00
ld c, 10
call DelayFrames
2018-01-23 14:39:09 -08:00
ld hl, wOptions
2015-11-16 18:07:26 -08:00
set NO_TEXT_SCROLL, [hl]
ld a, $1
ldh [hInMenu], a
2016-01-09 20:41:03 -08:00
call PokegearPhone_UpdateCursor
2015-11-16 18:07:26 -08:00
ld hl, wJumptableIndex
inc [hl]
ret
2016-01-09 20:41:03 -08:00
2016-01-10 14:44:09 -08:00
.no_service
2017-12-24 09:47:30 -08:00
farcall Phone_NoSignal
ld hl, .GearOutOfServiceText
2015-11-16 18:07:26 -08:00
call PrintText
2018-01-11 09:00:01 -08:00
ld a, POKEGEARSTATE_PHONEJOYPAD
2015-11-16 18:07:26 -08:00
ld [wJumptableIndex], a
ld hl, PokegearAskWhoCallText
2015-11-16 18:07:26 -08:00
call PrintText
ret
2016-01-09 20:41:03 -08:00
.GearEllipseText:
text_far _GearEllipseText
text_end
2016-01-09 20:41:03 -08:00
.GearOutOfServiceText:
text_far _GearOutOfServiceText
text_end
2016-01-09 20:41:03 -08:00
2018-06-24 07:09:41 -07:00
PokegearPhone_FinishPhoneCall:
ldh a, [hJoyPressed]
2015-11-16 18:07:26 -08:00
and A_BUTTON | B_BUTTON
ret z
2017-12-24 09:47:30 -08:00
farcall HangUp
2018-01-11 09:00:01 -08:00
ld a, POKEGEARSTATE_PHONEJOYPAD
2015-11-16 18:07:26 -08:00
ld [wJumptableIndex], a
ld hl, PokegearAskWhoCallText
2015-11-16 18:07:26 -08:00
call PrintText
ret
2018-06-24 07:09:41 -07:00
PokegearPhone_GetDPad:
2015-11-16 18:07:26 -08:00
ld hl, hJoyLast
ld a, [hl]
and D_UP
jr nz, .up
ld a, [hl]
and D_DOWN
jr nz, .down
ret
.up
2016-01-09 20:41:03 -08:00
ld hl, wPokegearPhoneCursorPosition
2015-11-16 18:07:26 -08:00
ld a, [hl]
and a
2016-01-09 20:41:03 -08:00
jr z, .scroll_page_up
2015-11-16 18:07:26 -08:00
dec [hl]
2016-01-09 20:41:03 -08:00
jr .done_joypad_same_page
2015-11-16 18:07:26 -08:00
2016-01-09 20:41:03 -08:00
.scroll_page_up
ld hl, wPokegearPhoneScrollPosition
2015-11-16 18:07:26 -08:00
ld a, [hl]
and a
ret z
dec [hl]
2016-01-09 20:41:03 -08:00
jr .done_joypad_update_page
2015-11-16 18:07:26 -08:00
.down
2016-01-09 20:41:03 -08:00
ld hl, wPokegearPhoneCursorPosition
2015-11-16 18:07:26 -08:00
ld a, [hl]
cp PHONE_DISPLAY_HEIGHT - 1
2016-01-09 20:41:03 -08:00
jr nc, .scroll_page_down
2015-11-16 18:07:26 -08:00
inc [hl]
2016-01-09 20:41:03 -08:00
jr .done_joypad_same_page
2015-11-16 18:07:26 -08:00
2016-01-09 20:41:03 -08:00
.scroll_page_down
ld hl, wPokegearPhoneScrollPosition
2015-11-16 18:07:26 -08:00
ld a, [hl]
cp CONTACT_LIST_SIZE - PHONE_DISPLAY_HEIGHT
2015-11-16 18:07:26 -08:00
ret nc
inc [hl]
2016-01-09 20:41:03 -08:00
jr .done_joypad_update_page
2015-11-16 18:07:26 -08:00
2016-01-09 20:41:03 -08:00
.done_joypad_same_page
2015-11-16 18:07:26 -08:00
xor a
ldh [hBGMapMode], a
2016-01-09 20:41:03 -08:00
call PokegearPhone_UpdateCursor
2015-11-16 18:07:26 -08:00
call WaitBGMap
ret
2016-01-09 20:41:03 -08:00
.done_joypad_update_page
2015-11-16 18:07:26 -08:00
xor a
ldh [hBGMapMode], a
2016-01-09 20:41:03 -08:00
call PokegearPhone_UpdateDisplayList
2015-11-16 18:07:26 -08:00
call WaitBGMap
ret
2018-06-24 07:09:41 -07:00
PokegearPhone_UpdateCursor:
2015-11-16 18:07:26 -08:00
ld a, " "
2021-04-19 13:31:37 -07:00
for y, PHONE_DISPLAY_HEIGHT
hlcoord 1, 4 + y * 2
2015-11-16 18:07:26 -08:00
ld [hl], a
endr
2015-11-16 18:07:26 -08:00
hlcoord 1, 4
2016-01-09 20:41:03 -08:00
ld a, [wPokegearPhoneCursorPosition]
ld bc, 2 * SCREEN_WIDTH
2015-11-16 18:07:26 -08:00
call AddNTimes
ld [hl], "▶"
ret
2018-06-24 07:09:41 -07:00
PokegearPhone_UpdateDisplayList:
2015-11-16 18:07:26 -08:00
hlcoord 1, 3
ld b, PHONE_DISPLAY_HEIGHT * 2 + 1
2016-01-09 20:41:03 -08:00
ld a, " "
.row
ld c, SCREEN_WIDTH - 2
2016-01-09 20:41:03 -08:00
.col
2015-11-16 18:07:26 -08:00
ld [hli], a
dec c
2016-01-09 20:41:03 -08:00
jr nz, .col
inc hl
2015-11-16 18:07:26 -08:00
inc hl
dec b
2016-01-09 20:41:03 -08:00
jr nz, .row
ld a, [wPokegearPhoneScrollPosition]
2015-11-16 18:07:26 -08:00
ld e, a
ld d, 0
2015-11-16 18:07:26 -08:00
ld hl, wPhoneList
add hl, de
xor a
ld [wPokegearPhoneDisplayPosition], a
2016-01-09 20:41:03 -08:00
.loop
2015-11-16 18:07:26 -08:00
ld a, [hli]
push hl
push af
hlcoord 2, 4
ld a, [wPokegearPhoneDisplayPosition]
2016-01-09 20:41:03 -08:00
ld bc, 2 * SCREEN_WIDTH
2015-11-16 18:07:26 -08:00
call AddNTimes
ld d, h
ld e, l
pop af
ld b, a
2020-10-04 19:34:50 -07:00
call GetCallerClassAndName
2015-11-16 18:07:26 -08:00
pop hl
ld a, [wPokegearPhoneDisplayPosition]
2015-11-16 18:07:26 -08:00
inc a
ld [wPokegearPhoneDisplayPosition], a
cp PHONE_DISPLAY_HEIGHT
2016-01-09 20:41:03 -08:00
jr c, .loop
call PokegearPhone_UpdateCursor
2015-11-16 18:07:26 -08:00
ret
2016-01-09 20:41:03 -08:00
2018-06-24 07:09:41 -07:00
PokegearPhone_DeletePhoneNumber:
2015-11-16 18:07:26 -08:00
ld hl, wPhoneList
2016-01-09 20:41:03 -08:00
ld a, [wPokegearPhoneScrollPosition]
2015-11-16 18:07:26 -08:00
ld e, a
ld d, 0
add hl, de
2016-01-09 20:41:03 -08:00
ld a, [wPokegearPhoneCursorPosition]
2015-11-16 18:07:26 -08:00
ld e, a
ld d, 0
add hl, de
ld [hl], 0
ld hl, wPhoneList
2016-01-09 20:41:03 -08:00
ld c, CONTACT_LIST_SIZE
.loop
2015-11-16 18:07:26 -08:00
ld a, [hli]
and a
2016-01-09 20:41:03 -08:00
jr nz, .skip
2015-11-16 18:07:26 -08:00
ld a, [hld]
ld [hli], a
ld [hl], 0
2016-01-09 20:41:03 -08:00
.skip
2015-11-16 18:07:26 -08:00
dec c
2016-01-09 20:41:03 -08:00
jr nz, .loop
2015-11-16 18:07:26 -08:00
ret
2016-01-09 20:41:03 -08:00
2018-06-24 07:09:41 -07:00
PokegearPhoneContactSubmenu:
2015-11-16 18:07:26 -08:00
ld hl, wPhoneList
2016-01-09 20:41:03 -08:00
ld a, [wPokegearPhoneScrollPosition]
2015-11-16 18:07:26 -08:00
ld e, a
ld d, 0
add hl, de
2016-01-09 20:41:03 -08:00
ld a, [wPokegearPhoneCursorPosition]
2015-11-16 18:07:26 -08:00
ld e, a
ld d, 0
add hl, de
ld c, [hl]
2017-12-24 09:47:30 -08:00
farcall CheckCanDeletePhoneNumber
2015-11-16 18:07:26 -08:00
ld a, c
and a
2016-01-09 20:41:03 -08:00
jr z, .cant_delete
ld hl, .CallDeleteCancelJumptable
ld de, .CallDeleteCancelStrings
jr .got_menu_data
.cant_delete
ld hl, .CallCancelJumptable
ld de, .CallCancelStrings
.got_menu_data
2015-11-16 18:07:26 -08:00
xor a
ldh [hBGMapMode], a
2015-11-16 18:07:26 -08:00
push hl
push de
ld a, [de]
ld l, a
inc de
ld a, [de]
ld h, a
inc de
push hl
bccoord -1, -2, 0
2015-11-16 18:07:26 -08:00
add hl, bc
ld a, [de]
inc de
sla a
ld b, a
ld c, 8
push de
2019-04-08 05:15:10 -07:00
call Textbox
2015-11-16 18:07:26 -08:00
pop de
pop hl
inc hl
call PlaceString
pop de
xor a
2016-01-09 20:41:03 -08:00
ld [wPokegearPhoneSubmenuCursor], a
call .UpdateCursor
2015-11-16 18:07:26 -08:00
call WaitBGMap
2016-01-09 20:41:03 -08:00
.loop
2015-11-16 18:07:26 -08:00
push de
call JoyTextDelay
pop de
ld hl, hJoyPressed
ld a, [hl]
and D_UP
2016-01-09 20:41:03 -08:00
jr nz, .d_up
2015-11-16 18:07:26 -08:00
ld a, [hl]
and D_DOWN
2016-01-09 20:41:03 -08:00
jr nz, .d_down
2015-11-16 18:07:26 -08:00
ld a, [hl]
and A_BUTTON | B_BUTTON
2016-01-09 20:41:03 -08:00
jr nz, .a_b
2015-11-16 18:07:26 -08:00
call DelayFrame
2016-01-09 20:41:03 -08:00
jr .loop
2015-11-16 18:07:26 -08:00
2016-01-09 20:41:03 -08:00
.d_up
ld hl, wPokegearPhoneSubmenuCursor
2015-11-16 18:07:26 -08:00
ld a, [hl]
and a
2016-01-09 20:41:03 -08:00
jr z, .loop
2015-11-16 18:07:26 -08:00
dec [hl]
2016-01-09 20:41:03 -08:00
call .UpdateCursor
jr .loop
2015-11-16 18:07:26 -08:00
2016-01-09 20:41:03 -08:00
.d_down
2015-11-16 18:07:26 -08:00
ld hl, 2
add hl, de
2016-01-09 20:41:03 -08:00
ld a, [wPokegearPhoneSubmenuCursor]
2015-11-16 18:07:26 -08:00
inc a
cp [hl]
2016-01-09 20:41:03 -08:00
jr nc, .loop
ld [wPokegearPhoneSubmenuCursor], a
call .UpdateCursor
jr .loop
2015-11-16 18:07:26 -08:00
2016-01-09 20:41:03 -08:00
.a_b
2015-11-16 18:07:26 -08:00
xor a
ldh [hBGMapMode], a
2016-01-09 20:41:03 -08:00
call PokegearPhone_UpdateDisplayList
2015-11-16 18:07:26 -08:00
ld a, $1
ldh [hBGMapMode], a
2015-11-16 18:07:26 -08:00
pop hl
ldh a, [hJoyPressed]
2015-11-16 18:07:26 -08:00
and B_BUTTON
2016-01-09 20:41:03 -08:00
jr nz, .Cancel
ld a, [wPokegearPhoneSubmenuCursor]
2015-11-16 18:07:26 -08:00
ld e, a
ld d, 0
add hl, de
2016-01-09 20:41:03 -08:00
add hl, de
2015-11-16 18:07:26 -08:00
ld a, [hli]
ld h, [hl]
ld l, a
jp hl
2015-11-16 18:07:26 -08:00
2018-06-24 07:09:41 -07:00
.Cancel:
ld hl, PokegearAskWhoCallText
2015-11-16 18:07:26 -08:00
call PrintText
scf
ret
2016-01-09 20:41:03 -08:00
2018-06-24 07:09:41 -07:00
.Delete:
ld hl, PokegearAskDeleteText
2019-04-08 05:15:10 -07:00
call MenuTextbox
2015-11-16 18:07:26 -08:00
call YesNoBox
call ExitMenu
2016-01-09 20:41:03 -08:00
jr c, .CancelDelete
call PokegearPhone_DeletePhoneNumber
2015-11-16 18:07:26 -08:00
xor a
ldh [hBGMapMode], a
2016-01-09 20:41:03 -08:00
call PokegearPhone_UpdateDisplayList
ld hl, PokegearAskWhoCallText
2015-11-16 18:07:26 -08:00
call PrintText
call WaitBGMap
.CancelDelete:
2015-11-16 18:07:26 -08:00
scf
ret
2016-01-09 20:41:03 -08:00
2018-06-24 07:09:41 -07:00
.Call:
2015-11-16 18:07:26 -08:00
and a
ret
2016-01-09 20:41:03 -08:00
2018-06-24 07:09:41 -07:00
.UpdateCursor:
2015-11-16 18:07:26 -08:00
push de
ld a, [de]
inc de
ld l, a
ld a, [de]
inc de
ld h, a
ld a, [de]
ld c, a
push hl
ld a, " "
2016-01-09 20:41:03 -08:00
ld de, SCREEN_WIDTH * 2
.clear_column
2015-11-16 18:07:26 -08:00
ld [hl], a
add hl, de
dec c
2016-01-09 20:41:03 -08:00
jr nz, .clear_column
2015-11-16 18:07:26 -08:00
pop hl
2016-01-09 20:41:03 -08:00
ld a, [wPokegearPhoneSubmenuCursor]
ld bc, SCREEN_WIDTH * 2
2015-11-16 18:07:26 -08:00
call AddNTimes
ld [hl], "▶"
pop de
ret
2016-01-09 20:41:03 -08:00
2018-06-24 07:09:41 -07:00
.CallDeleteCancelStrings:
2015-11-16 18:07:26 -08:00
dwcoord 10, 6
db 3
db "CALL"
next "DELETE"
next "CANCEL"
db "@"
2018-06-24 07:09:41 -07:00
.CallDeleteCancelJumptable:
2016-01-09 20:41:03 -08:00
dw .Call
dw .Delete
dw .Cancel
2018-06-24 07:09:41 -07:00
.CallCancelStrings:
2015-11-16 18:07:26 -08:00
dwcoord 10, 8
db 2
db "CALL"
next "CANCEL"
db "@"
2018-06-24 07:09:41 -07:00
.CallCancelJumptable:
2016-01-09 20:41:03 -08:00
dw .Call
dw .Cancel
2015-11-16 18:07:26 -08:00
GetAMPMHours: ; unreferenced
ldh a, [hHours]
2022-01-10 17:57:40 -08:00
cp NOON_HOUR
2016-01-09 20:41:03 -08:00
jr c, .am
2022-01-10 17:57:40 -08:00
sub NOON_HOUR
ld [wTempByteValue], a
2015-11-16 18:07:26 -08:00
scf
ret
2016-01-09 20:41:03 -08:00
.am
ld [wTempByteValue], a
2015-11-16 18:07:26 -08:00
and a
ret
2018-06-24 07:09:41 -07:00
Pokegear_SwitchPage:
2015-11-16 18:07:26 -08:00
ld de, SFX_READ_TEXT_2
call PlaySFX
ld a, c
ld [wJumptableIndex], a
ld a, b
2018-01-11 12:36:11 -08:00
ld [wPokegearCard], a
2015-11-16 18:07:26 -08:00
call DeleteSpriteAnimStruct2ToEnd
ret
2018-06-24 07:09:41 -07:00
ExitPokegearRadio_HandleMusic:
2016-01-09 20:41:03 -08:00
ld a, [wPokegearRadioMusicPlaying]
2018-01-11 09:00:01 -08:00
cp RESTART_MAP_MUSIC
2016-01-10 14:44:09 -08:00
jr z, .restart_map_music
2018-01-11 09:00:01 -08:00
cp ENTER_MAP_MUSIC
call z, PlayMapMusicBike
2015-11-16 18:07:26 -08:00
xor a
2016-01-09 20:41:03 -08:00
ld [wPokegearRadioMusicPlaying], a
2015-11-16 18:07:26 -08:00
ret
2016-01-10 14:44:09 -08:00
.restart_map_music
2015-11-16 18:07:26 -08:00
call RestartMapMusic
xor a
2016-01-09 20:41:03 -08:00
ld [wPokegearRadioMusicPlaying], a
2015-11-16 18:07:26 -08:00
ret
2018-06-24 07:09:41 -07:00
DeleteSpriteAnimStruct2ToEnd:
2018-01-23 14:39:09 -08:00
ld hl, wSpriteAnim2
ld bc, wSpriteAnimationStructsEnd - wSpriteAnim2
2015-11-16 18:07:26 -08:00
xor a
call ByteFill
ld a, 2
ld [wSpriteAnimCount], a
ret
2018-06-24 07:09:41 -07:00
Pokegear_LoadTilemapRLE:
2016-01-10 14:44:09 -08:00
; Format: repeat count, tile ID
2018-01-11 09:00:01 -08:00
; Terminated with -1
2015-11-16 18:07:26 -08:00
hlcoord 0, 0
2016-01-10 14:44:09 -08:00
.loop
2015-11-16 18:07:26 -08:00
ld a, [de]
2018-01-11 09:00:01 -08:00
cp -1
2015-11-16 18:07:26 -08:00
ret z
ld b, a
inc de
ld a, [de]
ld c, a
inc de
ld a, b
2016-01-10 14:44:09 -08:00
.load
2015-11-16 18:07:26 -08:00
ld [hli], a
dec c
2016-01-10 14:44:09 -08:00
jr nz, .load
jr .loop
2016-01-09 20:41:03 -08:00
PokegearAskWhoCallText:
text_far _PokegearAskWhoCallText
text_end
2016-01-09 20:41:03 -08:00
PokegearPressButtonText:
text_far _PokegearPressButtonText
text_end
2016-01-09 20:41:03 -08:00
PokegearAskDeleteText:
text_far _PokegearAskDeleteText
text_end
2015-11-16 18:07:26 -08:00
2018-06-24 07:09:41 -07:00
PokegearSpritesGFX:
INCBIN "gfx/pokegear/pokegear_sprites.2bpp.lz"
2015-11-16 18:07:26 -08:00
2018-06-24 07:09:41 -07:00
RadioTilemapRLE:
2016-01-10 14:44:09 -08:00
INCBIN "gfx/pokegear/radio.tilemap.rle"
2018-06-24 07:09:41 -07:00
PhoneTilemapRLE:
2016-01-10 14:44:09 -08:00
INCBIN "gfx/pokegear/phone.tilemap.rle"
2018-06-24 07:09:41 -07:00
ClockTilemapRLE:
2016-01-10 14:44:09 -08:00
INCBIN "gfx/pokegear/clock.tilemap.rle"
2016-01-09 20:41:03 -08:00
2018-06-24 07:09:41 -07:00
_UpdateRadioStation:
2015-11-16 18:07:26 -08:00
jr UpdateRadioStation
2020-11-17 08:12:21 -08:00
; called from engine/gfx/sprite_anims.asm
2016-01-09 20:41:03 -08:00
2018-06-24 07:09:41 -07:00
AnimateTuningKnob:
2015-11-16 18:07:26 -08:00
push bc
call .TuningKnob
pop bc
ld a, [wRadioTuningKnob]
2015-12-04 05:46:11 -08:00
ld hl, SPRITEANIMSTRUCT_XOFFSET
2015-11-16 18:07:26 -08:00
add hl, bc
ld [hl], a
ret
2018-06-24 07:09:41 -07:00
.TuningKnob:
2015-11-16 18:07:26 -08:00
ld hl, hJoyLast
ld a, [hl]
and D_DOWN
jr nz, .down
ld a, [hl]
and D_UP
jr nz, .up
ret
.down
ld hl, wRadioTuningKnob
ld a, [hl]
and a
ret z
dec [hl]
2016-01-09 20:41:03 -08:00
dec [hl]
2015-11-16 18:07:26 -08:00
jr .update
.up
ld hl, wRadioTuningKnob
ld a, [hl]
cp 80
ret nc
inc [hl]
2016-01-09 20:41:03 -08:00
inc [hl]
2015-11-16 18:07:26 -08:00
.update
2018-06-24 07:09:41 -07:00
UpdateRadioStation:
2015-11-16 18:07:26 -08:00
ld hl, wRadioTuningKnob
ld d, [hl]
ld hl, RadioChannels
.loop
ld a, [hli]
cp -1
jr z, .nostation
cp d
jr z, .foundstation
inc hl
2016-01-09 20:41:03 -08:00
inc hl
2015-11-16 18:07:26 -08:00
jr .loop
.nostation
call NoRadioStation
ret
.foundstation
ld a, [hli]
ld h, [hl]
ld l, a
ld de, .returnafterstation
push de
jp hl
2016-01-09 20:41:03 -08:00
2015-11-16 18:07:26 -08:00
.returnafterstation
2016-01-09 20:41:03 -08:00
ld a, [wPokegearRadioChannelBank]
2015-11-16 18:07:26 -08:00
and a
ret z
xor a
ldh [hBGMapMode], a
2015-11-16 18:07:26 -08:00
hlcoord 2, 9
call PlaceString
ld a, $1
ldh [hBGMapMode], a
2015-11-16 18:07:26 -08:00
ret
2016-01-09 20:41:03 -08:00
LoadPokegearRadioChannelPointer: ; unreferenced
2016-01-09 20:41:03 -08:00
ld [wPokegearRadioChannelBank], a
2015-11-16 18:07:26 -08:00
ld a, [hli]
2016-01-09 20:41:03 -08:00
ld [wPokegearRadioChannelAddr], a
2015-11-16 18:07:26 -08:00
ld a, [hli]
2016-01-09 20:41:03 -08:00
ld [wPokegearRadioChannelAddr + 1], a
2015-11-16 18:07:26 -08:00
ret
RadioChannels:
2018-01-10 22:45:27 -08:00
; entries correspond to constants/radio_constants.asm
2015-11-16 18:07:26 -08:00
; frequency value given here = 4 × ingame_frequency 2
dbw 16, .PKMNTalkAndPokedexShow ; 04.5
dbw 28, .PokemonMusic ; 07.5
dbw 32, .LuckyChannel ; 08.5
dbw 40, .BuenasPassword ; 10.5
dbw 52, .RuinsOfAlphRadio ; 13.5
dbw 64, .PlacesAndPeople ; 16.5
dbw 72, .LetsAllSing ; 18.5
dbw 78, .PokeFluteRadio ; 20.0
dbw 80, .EvolutionRadio ; 20.5
2016-01-28 21:57:06 -08:00
db -1
2015-11-16 18:07:26 -08:00
.PKMNTalkAndPokedexShow:
2015-11-16 18:07:26 -08:00
; Pokédex Show in the morning
; Oak's Pokémon Talk in the afternoon and evening
call .InJohto
jr nc, .NoSignal
2018-01-23 14:39:09 -08:00
ld a, [wTimeOfDay]
2015-11-16 18:07:26 -08:00
and a
jp z, LoadStation_PokedexShow
jp LoadStation_OaksPokemonTalk
.PokemonMusic:
2015-11-16 18:07:26 -08:00
call .InJohto
jr nc, .NoSignal
jp LoadStation_PokemonMusic
.LuckyChannel:
2015-11-16 18:07:26 -08:00
call .InJohto
jr nc, .NoSignal
jp LoadStation_LuckyChannel
.BuenasPassword:
2015-11-16 18:07:26 -08:00
call .InJohto
jr nc, .NoSignal
jp LoadStation_BuenasPassword
.RuinsOfAlphRadio:
2016-01-12 09:46:18 -08:00
ld a, [wPokegearMapPlayerIconLandmark]
cp LANDMARK_RUINS_OF_ALPH
2015-11-16 18:07:26 -08:00
jr nz, .NoSignal
jp LoadStation_UnownRadio
.PlacesAndPeople:
2015-11-16 18:07:26 -08:00
call .InJohto
jr c, .NoSignal
ld a, [wPokegearFlags]
bit POKEGEAR_EXPN_CARD_F, a
2015-11-16 18:07:26 -08:00
jr z, .NoSignal
jp LoadStation_PlacesAndPeople
.LetsAllSing:
2015-11-16 18:07:26 -08:00
call .InJohto
jr c, .NoSignal
ld a, [wPokegearFlags]
bit POKEGEAR_EXPN_CARD_F, a
2015-11-16 18:07:26 -08:00
jr z, .NoSignal
jp LoadStation_LetsAllSing
.PokeFluteRadio:
2015-11-16 18:07:26 -08:00
call .InJohto
jr c, .NoSignal
ld a, [wPokegearFlags]
bit POKEGEAR_EXPN_CARD_F, a
2015-11-16 18:07:26 -08:00
jr z, .NoSignal
jp LoadStation_PokeFluteRadio
.EvolutionRadio:
; This station airs in the Lake of Rage area when Team Rocket is still in Mahogany.
ld a, [wStatusFlags]
2018-01-22 12:40:43 -08:00
bit STATUSFLAGS_ROCKET_SIGNAL_F, a
2015-11-16 18:07:26 -08:00
jr z, .NoSignal
2016-01-12 09:46:18 -08:00
ld a, [wPokegearMapPlayerIconLandmark]
cp LANDMARK_MAHOGANY_TOWN
2015-11-16 18:07:26 -08:00
jr z, .ok
cp LANDMARK_ROUTE_43
2015-11-16 18:07:26 -08:00
jr z, .ok
cp LANDMARK_LAKE_OF_RAGE
2015-11-16 18:07:26 -08:00
jr nz, .NoSignal
.ok
jp LoadStation_EvolutionRadio
.NoSignal:
2015-11-16 18:07:26 -08:00
call NoRadioStation
ret
.InJohto:
2015-11-16 18:07:26 -08:00
; if in Johto or on the S.S. Aqua, set carry
; otherwise clear carry
2016-01-12 09:46:18 -08:00
ld a, [wPokegearMapPlayerIconLandmark]
cp LANDMARK_FAST_SHIP
2015-11-16 18:07:26 -08:00
jr z, .johto
cp KANTO_LANDMARK
jr c, .johto
; kanto
2015-11-16 18:07:26 -08:00
and a
ret
2016-01-09 20:41:03 -08:00
2015-11-16 18:07:26 -08:00
.johto
scf
ret
2018-06-24 07:09:41 -07:00
LoadStation_OaksPokemonTalk:
2015-11-16 18:07:26 -08:00
xor a ; OAKS_POKEMON_TALK
2018-09-09 12:09:51 -07:00
ld [wCurRadioLine], a
2017-12-09 16:41:03 -08:00
ld [wNumRadioLinesPrinted], a
2015-11-16 18:07:26 -08:00
ld a, BANK(PlayRadioShow)
ld hl, PlayRadioShow
call Radio_BackUpFarCallParams
ld de, OaksPKMNTalkName
2015-11-16 18:07:26 -08:00
ret
2018-06-24 07:09:41 -07:00
LoadStation_PokedexShow:
2015-11-16 18:07:26 -08:00
ld a, POKEDEX_SHOW
2018-09-09 12:09:51 -07:00
ld [wCurRadioLine], a
2015-11-16 18:07:26 -08:00
xor a
2017-12-09 16:41:03 -08:00
ld [wNumRadioLinesPrinted], a
2015-11-16 18:07:26 -08:00
ld a, BANK(PlayRadioShow)
ld hl, PlayRadioShow
call Radio_BackUpFarCallParams
ld de, PokedexShowName
ret
2018-06-24 07:09:41 -07:00
LoadStation_PokemonMusic:
2015-11-16 18:07:26 -08:00
ld a, POKEMON_MUSIC
2018-09-09 12:09:51 -07:00
ld [wCurRadioLine], a
2015-11-16 18:07:26 -08:00
xor a
2017-12-09 16:41:03 -08:00
ld [wNumRadioLinesPrinted], a
2015-11-16 18:07:26 -08:00
ld a, BANK(PlayRadioShow)
ld hl, PlayRadioShow
call Radio_BackUpFarCallParams
ld de, PokemonMusicName
ret
2018-06-24 07:09:41 -07:00
LoadStation_LuckyChannel:
2015-11-16 18:07:26 -08:00
ld a, LUCKY_CHANNEL
2018-09-09 12:09:51 -07:00
ld [wCurRadioLine], a
2015-11-16 18:07:26 -08:00
xor a
2017-12-09 16:41:03 -08:00
ld [wNumRadioLinesPrinted], a
2015-11-16 18:07:26 -08:00
ld a, BANK(PlayRadioShow)
ld hl, PlayRadioShow
call Radio_BackUpFarCallParams
ld de, LuckyChannelName
ret
2018-06-24 07:09:41 -07:00
LoadStation_BuenasPassword:
2015-11-16 18:07:26 -08:00
ld a, BUENAS_PASSWORD
2018-09-09 12:09:51 -07:00
ld [wCurRadioLine], a
2015-11-16 18:07:26 -08:00
xor a
2017-12-09 16:41:03 -08:00
ld [wNumRadioLinesPrinted], a
2015-11-16 18:07:26 -08:00
ld a, BANK(PlayRadioShow)
ld hl, PlayRadioShow
call Radio_BackUpFarCallParams
ld de, NotBuenasPasswordName
ld a, [wStatusFlags2]
2018-01-22 12:40:43 -08:00
bit STATUSFLAGS2_ROCKETS_IN_RADIO_TOWER_F, a
2015-11-16 18:07:26 -08:00
ret z
ld de, BuenasPasswordName
ret
2016-01-09 20:41:03 -08:00
2015-11-16 18:07:26 -08:00
BuenasPasswordName: db "BUENA'S PASSWORD@"
NotBuenasPasswordName: db "@"
2018-06-24 07:09:41 -07:00
LoadStation_UnownRadio:
2015-11-16 18:07:26 -08:00
ld a, UNOWN_RADIO
2018-09-09 12:09:51 -07:00
ld [wCurRadioLine], a
2015-11-16 18:07:26 -08:00
xor a
2017-12-09 16:41:03 -08:00
ld [wNumRadioLinesPrinted], a
2015-11-16 18:07:26 -08:00
ld a, BANK(PlayRadioShow)
ld hl, PlayRadioShow
call Radio_BackUpFarCallParams
2017-12-24 17:07:23 -08:00
ld de, UnownStationName
2015-11-16 18:07:26 -08:00
ret
2018-06-24 07:09:41 -07:00
LoadStation_PlacesAndPeople:
2015-11-16 18:07:26 -08:00
ld a, PLACES_AND_PEOPLE
2018-09-09 12:09:51 -07:00
ld [wCurRadioLine], a
2015-11-16 18:07:26 -08:00
xor a
2017-12-09 16:41:03 -08:00
ld [wNumRadioLinesPrinted], a
2015-11-16 18:07:26 -08:00
ld a, BANK(PlayRadioShow)
ld hl, PlayRadioShow
call Radio_BackUpFarCallParams
ld de, PlacesAndPeopleName
ret
2018-06-24 07:09:41 -07:00
LoadStation_LetsAllSing:
2015-11-16 18:07:26 -08:00
ld a, LETS_ALL_SING
2018-09-09 12:09:51 -07:00
ld [wCurRadioLine], a
2015-11-16 18:07:26 -08:00
xor a
2017-12-09 16:41:03 -08:00
ld [wNumRadioLinesPrinted], a
2015-11-16 18:07:26 -08:00
ld a, BANK(PlayRadioShow)
ld hl, PlayRadioShow
call Radio_BackUpFarCallParams
ld de, LetsAllSingName
ret
2016-01-09 20:41:03 -08:00
2018-06-24 07:09:41 -07:00
LoadStation_RocketRadio:
2015-11-16 18:07:26 -08:00
ld a, ROCKET_RADIO
2018-09-09 12:09:51 -07:00
ld [wCurRadioLine], a
2015-11-16 18:07:26 -08:00
xor a
2017-12-09 16:41:03 -08:00
ld [wNumRadioLinesPrinted], a
2015-11-16 18:07:26 -08:00
ld a, BANK(PlayRadioShow)
ld hl, PlayRadioShow
call Radio_BackUpFarCallParams
ld de, LetsAllSingName
ret
2016-01-09 20:41:03 -08:00
2018-06-24 07:09:41 -07:00
LoadStation_PokeFluteRadio:
2015-11-16 18:07:26 -08:00
ld a, POKE_FLUTE_RADIO
2018-09-09 12:09:51 -07:00
ld [wCurRadioLine], a
2015-11-16 18:07:26 -08:00
xor a
2017-12-09 16:41:03 -08:00
ld [wNumRadioLinesPrinted], a
2015-11-16 18:07:26 -08:00
ld a, BANK(PlayRadioShow)
ld hl, PlayRadioShow
call Radio_BackUpFarCallParams
ld de, PokeFluteStationName
ret
2018-06-24 07:09:41 -07:00
LoadStation_EvolutionRadio:
2015-11-16 18:07:26 -08:00
ld a, EVOLUTION_RADIO
2018-09-09 12:09:51 -07:00
ld [wCurRadioLine], a
2015-11-16 18:07:26 -08:00
xor a
2017-12-09 16:41:03 -08:00
ld [wNumRadioLinesPrinted], a
2015-11-16 18:07:26 -08:00
ld a, BANK(PlayRadioShow)
ld hl, PlayRadioShow
call Radio_BackUpFarCallParams
2017-12-24 17:07:23 -08:00
ld de, UnownStationName
2015-11-16 18:07:26 -08:00
ret
2016-01-09 20:41:03 -08:00
DummyLoadStation: ; unreferenced
2015-11-16 18:07:26 -08:00
ret
2018-06-24 07:09:41 -07:00
RadioMusicRestartDE:
2015-11-16 18:07:26 -08:00
push de
ld a, e
2016-01-09 20:41:03 -08:00
ld [wPokegearRadioMusicPlaying], a
2015-11-16 18:07:26 -08:00
ld de, MUSIC_NONE
call PlayMusic
pop de
ld a, e
ld [wMapMusic], a
call PlayMusic
ret
2018-06-24 07:09:41 -07:00
RadioMusicRestartPokemonChannel:
2015-11-16 18:07:26 -08:00
push de
2018-01-11 09:00:01 -08:00
ld a, RESTART_MAP_MUSIC
2016-01-09 20:41:03 -08:00
ld [wPokegearRadioMusicPlaying], a
2015-11-16 18:07:26 -08:00
ld de, MUSIC_NONE
call PlayMusic
pop de
ld de, MUSIC_POKEMON_CHANNEL
call PlayMusic
ret
2018-06-24 07:09:41 -07:00
Radio_BackUpFarCallParams:
2016-01-09 20:41:03 -08:00
ld [wPokegearRadioChannelBank], a
2015-11-16 18:07:26 -08:00
ld a, l
2016-01-09 20:41:03 -08:00
ld [wPokegearRadioChannelAddr], a
2015-11-16 18:07:26 -08:00
ld a, h
2016-01-09 20:41:03 -08:00
ld [wPokegearRadioChannelAddr + 1], a
2015-11-16 18:07:26 -08:00
ret
2018-06-24 07:09:41 -07:00
NoRadioStation:
2015-11-16 18:07:26 -08:00
call NoRadioMusic
call NoRadioName
2021-03-24 07:24:52 -07:00
; no radio channel
2015-11-16 18:07:26 -08:00
xor a
2016-01-09 20:41:03 -08:00
ld [wPokegearRadioChannelBank], a
ld [wPokegearRadioChannelAddr], a
ld [wPokegearRadioChannelAddr + 1], a
2015-11-16 18:07:26 -08:00
ld a, $1
ldh [hBGMapMode], a
2015-11-16 18:07:26 -08:00
ret
2018-06-24 07:09:41 -07:00
NoRadioMusic:
2015-11-16 18:07:26 -08:00
ld de, MUSIC_NONE
call PlayMusic
2018-01-11 09:00:01 -08:00
ld a, ENTER_MAP_MUSIC
2016-01-09 20:41:03 -08:00
ld [wPokegearRadioMusicPlaying], a
2015-11-16 18:07:26 -08:00
ret
2018-06-24 07:09:41 -07:00
NoRadioName:
2015-11-16 18:07:26 -08:00
xor a
ldh [hBGMapMode], a
2015-11-16 18:07:26 -08:00
hlcoord 1, 8
lb bc, 3, 18
call ClearBox
hlcoord 0, 12
2018-01-11 09:00:01 -08:00
lb bc, 4, 18
2019-04-08 05:15:10 -07:00
call Textbox
2015-11-16 18:07:26 -08:00
ret
2016-01-09 20:41:03 -08:00
OaksPKMNTalkName: db "OAK's <PK><MN> Talk@"
2015-11-16 18:07:26 -08:00
PokedexShowName: db "#DEX Show@"
PokemonMusicName: db "#MON Music@"
LuckyChannelName: db "Lucky Channel@"
2017-12-24 17:07:23 -08:00
UnownStationName: db "?????@"
2016-01-09 20:41:03 -08:00
2015-11-16 18:07:26 -08:00
PlacesAndPeopleName: db "Places & People@"
LetsAllSingName: db "Let's All Sing!@"
PokeFluteStationName: db "# FLUTE@"
2018-06-24 07:09:41 -07:00
_TownMap:
2018-01-23 14:39:09 -08:00
ld hl, wOptions
2016-01-09 20:41:03 -08:00
ld a, [hl]
push af
set NO_TEXT_SCROLL, [hl]
ldh a, [hInMenu]
2016-01-09 20:41:03 -08:00
push af
ld a, $1
ldh [hInMenu], a
2016-01-09 20:41:03 -08:00
2018-01-23 14:39:09 -08:00
ld a, [wVramState]
2016-01-09 20:41:03 -08:00
push af
xor a
2018-01-23 14:39:09 -08:00
ld [wVramState], a
2016-01-09 20:41:03 -08:00
call ClearBGPalettes
call ClearTilemap
2016-01-09 20:41:03 -08:00
call ClearSprites
call DisableLCD
2016-01-10 14:44:09 -08:00
call Pokegear_LoadGFX
2017-12-24 09:47:30 -08:00
farcall ClearSpriteAnims
2016-01-09 20:41:03 -08:00
ld a, 8
call SkipMusic
2017-12-29 10:22:33 -08:00
ld a, LCDC_DEFAULT
ldh [rLCDC], a
2016-01-10 14:44:09 -08:00
call TownMap_GetCurrentLandmark
2017-12-09 16:41:03 -08:00
ld [wTownMapPlayerIconLandmark], a
ld [wTownMapCursorLandmark], a
2016-01-09 20:41:03 -08:00
xor a
ldh [hBGMapMode], a
2016-01-09 20:41:03 -08:00
call .InitTilemap
call WaitBGMap2
2017-12-09 16:41:03 -08:00
ld a, [wTownMapPlayerIconLandmark]
2016-01-09 20:41:03 -08:00
call PokegearMap_InitPlayerIcon
2017-12-09 16:41:03 -08:00
ld a, [wTownMapCursorLandmark]
2016-01-09 20:41:03 -08:00
call PokegearMap_InitCursor
ld a, c
2017-12-09 16:41:03 -08:00
ld [wTownMapCursorObjectPointer], a
2016-01-09 20:41:03 -08:00
ld a, b
2017-12-09 16:41:03 -08:00
ld [wTownMapCursorObjectPointer + 1], a
2016-01-09 20:41:03 -08:00
ld b, SCGB_POKEGEAR_PALS
call GetSGBLayout
call SetPalettes
ldh a, [hCGB]
2016-01-09 20:41:03 -08:00
and a
jr z, .dmg
ld a, %11100100
call DmgToCgbObjPal0
call DelayFrame
.dmg
2017-12-09 16:41:03 -08:00
ld a, [wTownMapPlayerIconLandmark]
2016-01-09 20:41:03 -08:00
cp KANTO_LANDMARK
jr nc, .kanto
ld d, KANTO_LANDMARK - 1
ld e, 1
call .loop
jr .resume
.kanto
call TownMap_GetKantoLandmarkLimits
call .loop
.resume
pop af
2018-01-23 14:39:09 -08:00
ld [wVramState], a
2016-01-09 20:41:03 -08:00
pop af
ldh [hInMenu], a
2016-01-09 20:41:03 -08:00
pop af
2018-01-23 14:39:09 -08:00
ld [wOptions], a
2016-01-09 20:41:03 -08:00
call ClearBGPalettes
ret
.loop
call JoyTextDelay
ld hl, hJoyPressed
ld a, [hl]
and B_BUTTON
ret nz
ld hl, hJoyLast
ld a, [hl]
and D_UP
jr nz, .pressed_up
ld a, [hl]
and D_DOWN
jr nz, .pressed_down
.loop2
push de
2017-12-24 09:47:30 -08:00
farcall PlaySpriteAnimations
2016-01-09 20:41:03 -08:00
pop de
call DelayFrame
jr .loop
.pressed_up
2017-12-09 16:41:03 -08:00
ld hl, wTownMapCursorLandmark
2016-01-09 20:41:03 -08:00
ld a, [hl]
cp d
jr c, .okay
ld a, e
dec a
ld [hl], a
.okay
inc [hl]
jr .next
.pressed_down
2017-12-09 16:41:03 -08:00
ld hl, wTownMapCursorLandmark
2016-01-09 20:41:03 -08:00
ld a, [hl]
cp e
jr nz, .okay2
ld a, d
inc a
ld [hl], a
.okay2
dec [hl]
.next
push de
2017-12-09 16:41:03 -08:00
ld a, [wTownMapCursorLandmark]
2016-01-10 14:44:09 -08:00
call PokegearMap_UpdateLandmarkName
2017-12-09 16:41:03 -08:00
ld a, [wTownMapCursorObjectPointer]
2016-01-09 20:41:03 -08:00
ld c, a
2017-12-09 16:41:03 -08:00
ld a, [wTownMapCursorObjectPointer + 1]
2016-01-09 20:41:03 -08:00
ld b, a
2017-12-09 16:41:03 -08:00
ld a, [wTownMapCursorLandmark]
2016-01-10 14:44:09 -08:00
call PokegearMap_UpdateCursorPosition
2016-01-09 20:41:03 -08:00
pop de
jr .loop2
2018-06-24 07:09:41 -07:00
.InitTilemap:
2017-12-09 16:41:03 -08:00
ld a, [wTownMapPlayerIconLandmark]
2016-01-09 20:41:03 -08:00
cp KANTO_LANDMARK
2016-01-10 14:44:09 -08:00
jr nc, .kanto2
2018-01-11 09:00:01 -08:00
ld e, JOHTO_REGION
2016-01-10 14:44:09 -08:00
jr .okay_tilemap
2016-01-09 20:41:03 -08:00
2016-01-10 14:44:09 -08:00
.kanto2
2018-01-11 09:00:01 -08:00
ld e, KANTO_REGION
2016-01-10 14:44:09 -08:00
.okay_tilemap
2017-12-24 09:47:30 -08:00
farcall PokegearMap
2018-01-11 09:00:01 -08:00
ld a, $07
2016-01-09 20:41:03 -08:00
ld bc, 6
hlcoord 1, 0
call ByteFill
hlcoord 0, 0
2018-01-11 09:00:01 -08:00
ld [hl], $06
2016-01-09 20:41:03 -08:00
hlcoord 7, 0
ld [hl], $17
hlcoord 7, 1
ld [hl], $16
hlcoord 7, 2
ld [hl], $26
2018-01-11 09:00:01 -08:00
ld a, $07
2016-01-09 20:41:03 -08:00
ld bc, NAME_LENGTH
hlcoord 8, 2
call ByteFill
hlcoord 19, 2
ld [hl], $17
2017-12-09 16:41:03 -08:00
ld a, [wTownMapCursorLandmark]
2016-01-10 14:44:09 -08:00
call PokegearMap_UpdateLandmarkName
2017-12-24 09:47:30 -08:00
farcall TownMapPals
2016-01-09 20:41:03 -08:00
ret
2015-11-16 18:07:26 -08:00
2018-06-24 07:09:41 -07:00
PlayRadio:
2018-01-23 14:39:09 -08:00
ld hl, wOptions
2015-11-16 18:07:26 -08:00
ld a, [hl]
push af
2018-01-11 09:00:01 -08:00
set NO_TEXT_SCROLL, [hl]
2015-11-16 18:07:26 -08:00
call .PlayStation
ld c, 100
call DelayFrames
.loop
call JoyTextDelay
ldh a, [hJoyPressed]
2015-11-16 18:07:26 -08:00
and A_BUTTON | B_BUTTON
jr nz, .stop
2016-01-09 20:41:03 -08:00
ld a, [wPokegearRadioChannelAddr]
2015-11-16 18:07:26 -08:00
ld l, a
2016-01-09 20:41:03 -08:00
ld a, [wPokegearRadioChannelAddr + 1]
2015-11-16 18:07:26 -08:00
ld h, a
2016-01-09 20:41:03 -08:00
ld a, [wPokegearRadioChannelBank]
2015-11-16 18:07:26 -08:00
and a
jr z, .zero
rst FarCall
.zero
call DelayFrame
jr .loop
.stop
pop af
2018-01-23 14:39:09 -08:00
ld [wOptions], a
2016-01-10 14:44:09 -08:00
call ExitPokegearRadio_HandleMusic
2015-11-16 18:07:26 -08:00
ret
2016-01-09 20:41:03 -08:00
2018-06-24 07:09:41 -07:00
.PlayStation:
2018-01-11 09:00:01 -08:00
ld a, ENTER_MAP_MUSIC
ld [wPokegearRadioMusicPlaying], a
2021-03-16 14:53:42 -07:00
ld hl, PlayRadioStationPointers
2018-01-11 09:00:01 -08:00
ld d, 0
2015-11-16 18:07:26 -08:00
add hl, de
2016-01-09 20:41:03 -08:00
add hl, de
2015-11-16 18:07:26 -08:00
ld a, [hli]
ld h, [hl]
ld l, a
ld de, .jump_return
push de
jp hl
2015-11-16 18:07:26 -08:00
.jump_return
push de
hlcoord 0, 12
lb bc, 4, 18
2019-04-08 05:15:10 -07:00
call Textbox
2015-11-16 18:07:26 -08:00
hlcoord 1, 14
2018-06-25 10:54:30 -07:00
ld [hl], "“"
2015-11-16 18:07:26 -08:00
pop de
hlcoord 2, 14
call PlaceString
ld h, b
ld l, c
2018-06-25 10:54:30 -07:00
ld [hl], "”"
2015-11-16 18:07:26 -08:00
call WaitBGMap
ret
2016-01-09 20:41:03 -08:00
2021-03-16 14:53:42 -07:00
PlayRadioStationPointers:
2018-01-20 09:25:55 -08:00
; entries correspond to MAPRADIO_* constants
2021-03-16 14:53:42 -07:00
table_width 2, PlayRadioStationPointers
dw LoadStation_PokemonChannel
2015-11-16 18:07:26 -08:00
dw LoadStation_OaksPokemonTalk
dw LoadStation_PokedexShow
dw LoadStation_PokemonMusic
dw LoadStation_LuckyChannel
dw LoadStation_UnownRadio
dw LoadStation_PlacesAndPeople
dw LoadStation_LetsAllSing
dw LoadStation_RocketRadio
2021-03-16 14:53:42 -07:00
assert_table_length NUM_MAP_RADIO_STATIONS
2016-01-09 20:41:03 -08:00
2021-03-16 14:53:42 -07:00
LoadStation_PokemonChannel:
2015-11-16 18:07:26 -08:00
call IsInJohto
and a
jr nz, .kanto
call UpdateTime
2018-01-23 14:39:09 -08:00
ld a, [wTimeOfDay]
2015-11-16 18:07:26 -08:00
and a
jp z, LoadStation_PokedexShow
jp LoadStation_OaksPokemonTalk
2021-03-16 14:53:42 -07:00
.kanto:
2015-11-16 18:07:26 -08:00
jp LoadStation_PlacesAndPeople
2016-01-09 20:41:03 -08:00
2018-06-24 07:09:41 -07:00
PokegearMap:
2015-11-16 18:07:26 -08:00
ld a, e
and a
jr nz, .kanto
2015-12-09 08:38:40 -08:00
call LoadTownMapGFX
2015-11-16 18:07:26 -08:00
call FillJohtoMap
ret
.kanto
2015-12-09 08:38:40 -08:00
call LoadTownMapGFX
2015-11-16 18:07:26 -08:00
call FillKantoMap
ret
2016-01-09 20:41:03 -08:00
2018-06-24 07:09:41 -07:00
_FlyMap:
2015-11-16 18:07:26 -08:00
call ClearBGPalettes
call ClearTilemap
2015-11-16 18:07:26 -08:00
call ClearSprites
ld hl, hInMenu
ld a, [hl]
push af
ld [hl], $1
xor a
ldh [hBGMapMode], a
2017-12-24 09:47:30 -08:00
farcall ClearSpriteAnims
2015-12-09 08:38:40 -08:00
call LoadTownMapGFX
ld de, FlyMapLabelBorderGFX
2017-12-28 04:32:33 -08:00
ld hl, vTiles2 tile $30
2015-12-09 08:38:40 -08:00
lb bc, BANK(FlyMapLabelBorderGFX), 6
2015-11-16 18:07:26 -08:00
call Request1bpp
call FlyMap
call Pokegear_DummyFunction
2015-12-28 07:57:04 -08:00
ld b, SCGB_POKEGEAR_PALS
2015-11-16 18:07:26 -08:00
call GetSGBLayout
call SetPalettes
.loop
call JoyTextDelay
ld hl, hJoyPressed
ld a, [hl]
and B_BUTTON
jr nz, .pressedB
ld a, [hl]
and A_BUTTON
jr nz, .pressedA
call .HandleDPad
2015-11-16 18:07:26 -08:00
call GetMapCursorCoordinates
2017-12-24 09:47:30 -08:00
farcall PlaySpriteAnimations
2015-11-16 18:07:26 -08:00
call DelayFrame
jr .loop
.pressedB
ld a, -1
jr .exit
.pressedA
2017-12-09 16:41:03 -08:00
ld a, [wTownMapPlayerIconLandmark]
2015-11-16 18:07:26 -08:00
ld l, a
ld h, 0
add hl, hl
ld de, Flypoints + 1
add hl, de
ld a, [hl]
.exit
2017-12-09 16:41:03 -08:00
ld [wTownMapPlayerIconLandmark], a
2015-11-16 18:07:26 -08:00
pop af
ldh [hInMenu], a
2015-11-16 18:07:26 -08:00
call ClearBGPalettes
2020-07-21 08:48:39 -07:00
ld a, SCREEN_HEIGHT_PX
ldh [hWY], a
2017-12-28 04:32:33 -08:00
xor a ; LOW(vBGMap0)
ldh [hBGMapAddress], a
2017-12-28 04:32:33 -08:00
ld a, HIGH(vBGMap0)
ldh [hBGMapAddress + 1], a
2017-12-09 16:41:03 -08:00
ld a, [wTownMapPlayerIconLandmark]
2015-11-16 18:07:26 -08:00
ld e, a
ret
2016-01-09 20:41:03 -08:00
.HandleDPad:
2018-01-23 14:39:09 -08:00
ld a, [wStartFlypoint]
2015-11-16 18:07:26 -08:00
ld e, a
2018-01-23 14:39:09 -08:00
ld a, [wEndFlypoint]
2015-11-16 18:07:26 -08:00
ld d, a
ld hl, hJoyLast
ld a, [hl]
and D_UP
jr nz, .ScrollNext
ld a, [hl]
and D_DOWN
jr nz, .ScrollPrev
ret
.ScrollNext:
2017-12-09 16:41:03 -08:00
ld hl, wTownMapPlayerIconLandmark
2015-11-16 18:07:26 -08:00
ld a, [hl]
cp d
jr nz, .NotAtEndYet
ld a, e
dec a
ld [hl], a
.NotAtEndYet:
2015-11-16 18:07:26 -08:00
inc [hl]
call CheckIfVisitedFlypoint
jr z, .ScrollNext
jr .Finally
.ScrollPrev:
2017-12-09 16:41:03 -08:00
ld hl, wTownMapPlayerIconLandmark
2015-11-16 18:07:26 -08:00
ld a, [hl]
cp e
jr nz, .NotAtStartYet
ld a, d
inc a
ld [hl], a
.NotAtStartYet:
2015-11-16 18:07:26 -08:00
dec [hl]
call CheckIfVisitedFlypoint
jr z, .ScrollPrev
.Finally:
2015-11-16 18:07:26 -08:00
call TownMapBubble
call WaitBGMap
xor a
ldh [hBGMapMode], a
2015-11-16 18:07:26 -08:00
ret
2016-01-09 20:41:03 -08:00
2018-06-24 07:09:41 -07:00
TownMapBubble:
2015-11-16 18:07:26 -08:00
; Draw the bubble containing the location text in the town map HUD
; Top-left corner
hlcoord 1, 0
ld a, $30
ld [hli], a
; Top row
ld bc, 16
ld a, " "
call ByteFill
; Top-right corner
ld a, $31
ld [hl], a
hlcoord 1, 1
; Middle row
2019-06-09 16:52:46 -07:00
ld bc, SCREEN_WIDTH - 2
2015-11-16 18:07:26 -08:00
ld a, " "
call ByteFill
; Bottom-left corner
hlcoord 1, 2
ld a, $32
ld [hli], a
; Bottom row
ld bc, 16
ld a, " "
call ByteFill
; Bottom-right corner
ld a, $33
ld [hl], a
; Print "Where?"
hlcoord 2, 0
ld de, .Where
call PlaceString
; Print the name of the default flypoint
call .Name
; Up/down arrows
hlcoord 18, 1
ld [hl], $34
2015-11-16 18:07:26 -08:00
ret
.Where:
2015-11-16 18:07:26 -08:00
db "Where?@"
.Name:
2015-11-16 18:07:26 -08:00
; We need the map location of the default flypoint
2017-12-09 16:41:03 -08:00
ld a, [wTownMapPlayerIconLandmark]
2015-11-16 18:07:26 -08:00
ld l, a
ld h, 0
add hl, hl ; two bytes per flypoint
ld de, Flypoints
add hl, de
ld e, [hl]
2017-12-24 09:47:30 -08:00
farcall GetLandmarkName
2015-11-16 18:07:26 -08:00
hlcoord 2, 1
2018-01-23 14:39:09 -08:00
ld de, wStringBuffer1
2015-11-16 18:07:26 -08:00
call PlaceString
ret
2016-01-09 20:41:03 -08:00
2018-06-24 07:09:41 -07:00
GetMapCursorCoordinates:
2017-12-09 16:41:03 -08:00
ld a, [wTownMapPlayerIconLandmark]
2015-11-16 18:07:26 -08:00
ld l, a
2018-01-11 09:00:01 -08:00
ld h, 0
2015-11-16 18:07:26 -08:00
add hl, hl
ld de, Flypoints
add hl, de
ld e, [hl]
2017-12-24 09:47:30 -08:00
farcall GetLandmarkCoords
2017-12-09 16:41:03 -08:00
ld a, [wTownMapCursorCoordinates]
2015-11-16 18:07:26 -08:00
ld c, a
2017-12-09 16:41:03 -08:00
ld a, [wTownMapCursorCoordinates + 1]
2015-11-16 18:07:26 -08:00
ld b, a
2018-01-11 09:00:01 -08:00
ld hl, 4
2015-11-16 18:07:26 -08:00
add hl, bc
ld [hl], e
2018-01-11 09:00:01 -08:00
ld hl, 5
2015-11-16 18:07:26 -08:00
add hl, bc
ld [hl], d
ret
2016-01-09 20:41:03 -08:00
2018-06-24 07:09:41 -07:00
CheckIfVisitedFlypoint:
2015-11-16 18:07:26 -08:00
; Check if the flypoint loaded in [hl] has been visited yet.
push bc
push de
push hl
ld l, [hl]
ld h, 0
add hl, hl
ld de, Flypoints + 1
add hl, de
ld c, [hl]
call HasVisitedSpawn
pop hl
pop de
pop bc
and a
ret
2016-01-09 20:41:03 -08:00
2018-06-24 07:09:41 -07:00
HasVisitedSpawn:
2015-11-16 18:07:26 -08:00
; Check if spawn point c has been visited.
ld hl, wVisitedSpawns
2015-11-16 18:07:26 -08:00
ld b, CHECK_FLAG
ld d, 0
predef SmallFarFlagAction
2015-11-16 18:07:26 -08:00
ld a, c
ret
2016-01-09 20:41:03 -08:00
INCLUDE "data/maps/flypoints.asm"
2015-11-16 18:07:26 -08:00
Pokegear_DummyFunction:
2015-11-16 18:07:26 -08:00
ret
2016-01-09 20:41:03 -08:00
2018-06-24 07:09:41 -07:00
FlyMap:
2018-01-23 14:39:09 -08:00
ld a, [wMapGroup]
2015-11-16 18:07:26 -08:00
ld b, a
2018-01-23 14:39:09 -08:00
ld a, [wMapNumber]
2015-11-16 18:07:26 -08:00
ld c, a
call GetWorldMapLocation
; If we're not in a valid location, i.e. Pokecenter floor 2F,
2017-12-09 16:41:03 -08:00
; the backup map information is used.
cp LANDMARK_SPECIAL
2015-11-16 18:07:26 -08:00
jr nz, .CheckRegion
2018-01-23 14:39:09 -08:00
ld a, [wBackupMapGroup]
2015-11-16 18:07:26 -08:00
ld b, a
2018-01-23 14:39:09 -08:00
ld a, [wBackupMapNumber]
2015-11-16 18:07:26 -08:00
ld c, a
call GetWorldMapLocation
.CheckRegion:
2017-12-09 16:41:03 -08:00
; The first 46 locations are part of Johto. The rest are in Kanto.
2015-11-16 18:07:26 -08:00
cp KANTO_LANDMARK
jr nc, .KantoFlyMap
; Johto fly map
2015-11-16 18:07:26 -08:00
; Note that .NoKanto should be modified in tandem with this branch
push af
ld a, JOHTO_FLYPOINT ; first Johto flypoint
ld [wTownMapPlayerIconLandmark], a ; first one is default (New Bark Town)
2018-01-23 14:39:09 -08:00
ld [wStartFlypoint], a
ld a, KANTO_FLYPOINT - 1 ; last Johto flypoint
2018-01-23 14:39:09 -08:00
ld [wEndFlypoint], a
2015-11-16 18:07:26 -08:00
; Fill out the map
call FillJohtoMap
call .MapHud
pop af
call TownMapPlayerIcon
ret
.KantoFlyMap:
2015-11-16 18:07:26 -08:00
; The event that there are no flypoints enabled in a map is not
; accounted for. As a result, if you attempt to select a flypoint
; when there are none enabled, the game will crash. Additionally,
; the flypoint selection has a default starting point that
2017-12-09 16:41:03 -08:00
; can be flown to even if none are enabled.
2015-11-16 18:07:26 -08:00
; To prevent both of these things from happening when the player
; enters Kanto, fly access is restricted until Indigo Plateau is
2017-12-09 16:41:03 -08:00
; visited and its flypoint enabled.
2015-11-16 18:07:26 -08:00
push af
ld c, SPAWN_INDIGO
call HasVisitedSpawn
and a
jr z, .NoKanto
; Kanto's map is only loaded if we've visited Indigo Plateau
ld a, KANTO_FLYPOINT ; first Kanto flypoint
2018-01-23 14:39:09 -08:00
ld [wStartFlypoint], a
ld a, NUM_FLYPOINTS - 1 ; last Kanto flypoint
2018-01-23 14:39:09 -08:00
ld [wEndFlypoint], a
ld [wTownMapPlayerIconLandmark], a ; last one is default (Indigo Plateau)
2015-11-16 18:07:26 -08:00
; Fill out the map
call FillKantoMap
call .MapHud
pop af
call TownMapPlayerIcon
ret
.NoKanto:
2015-11-16 18:07:26 -08:00
; If Indigo Plateau hasn't been visited, we use Johto's map instead
ld a, JOHTO_FLYPOINT ; first Johto flypoint
ld [wTownMapPlayerIconLandmark], a ; first one is default (New Bark Town)
2018-01-23 14:39:09 -08:00
ld [wStartFlypoint], a
ld a, KANTO_FLYPOINT - 1 ; last Johto flypoint
2018-01-23 14:39:09 -08:00
ld [wEndFlypoint], a
2015-11-16 18:07:26 -08:00
call FillJohtoMap
pop af
.MapHud:
2015-11-16 18:07:26 -08:00
call TownMapBubble
call TownMapPals
2015-11-20 08:47:52 -08:00
hlbgcoord 0, 0 ; BG Map 0
2015-11-16 18:07:26 -08:00
call TownMapBGUpdate
call TownMapMon
ld a, c
2017-12-09 16:41:03 -08:00
ld [wTownMapCursorCoordinates], a
2015-11-16 18:07:26 -08:00
ld a, b
2017-12-09 16:41:03 -08:00
ld [wTownMapCursorCoordinates + 1], a
2015-11-16 18:07:26 -08:00
ret
2016-01-09 20:41:03 -08:00
2018-06-24 07:09:41 -07:00
Pokedex_GetArea:
2015-12-09 08:38:40 -08:00
; e: Current landmark
2017-12-09 16:41:03 -08:00
ld a, [wTownMapPlayerIconLandmark]
2015-11-16 18:07:26 -08:00
push af
2017-12-09 16:41:03 -08:00
ld a, [wTownMapCursorLandmark]
2015-11-16 18:07:26 -08:00
push af
ld a, e
2017-12-09 16:41:03 -08:00
ld [wTownMapPlayerIconLandmark], a
2015-11-16 18:07:26 -08:00
call ClearSprites
xor a
ldh [hBGMapMode], a
2015-11-16 18:07:26 -08:00
ld a, $1
ldh [hInMenu], a
2015-12-09 08:38:40 -08:00
ld de, PokedexNestIconGFX
2017-12-28 04:32:33 -08:00
ld hl, vTiles0 tile $7f
2015-12-09 08:38:40 -08:00
lb bc, BANK(PokedexNestIconGFX), 1
call Request2bpp
call .GetPlayerOrFastShipIcon
2017-12-28 04:32:33 -08:00
ld hl, vTiles0 tile $78
2015-12-09 08:38:40 -08:00
ld c, 4
2015-11-16 18:07:26 -08:00
call Request2bpp
2015-12-09 08:38:40 -08:00
call LoadTownMapGFX
2015-11-16 18:07:26 -08:00
call FillKantoMap
2015-12-09 08:38:40 -08:00
call .PlaceString_MonsNest
2015-11-16 18:07:26 -08:00
call TownMapPals
2017-12-28 04:32:33 -08:00
hlbgcoord 0, 0, vBGMap1
2015-11-16 18:07:26 -08:00
call TownMapBGUpdate
call FillJohtoMap
2015-12-09 08:38:40 -08:00
call .PlaceString_MonsNest
2015-11-16 18:07:26 -08:00
call TownMapPals
2015-11-20 08:47:52 -08:00
hlbgcoord 0, 0
2015-11-16 18:07:26 -08:00
call TownMapBGUpdate
2015-12-28 07:57:04 -08:00
ld b, SCGB_POKEGEAR_PALS
2015-11-16 18:07:26 -08:00
call GetSGBLayout
call SetPalettes
xor a
ldh [hBGMapMode], a
2018-01-11 09:00:01 -08:00
xor a ; JOHTO_REGION
2015-12-09 08:38:40 -08:00
call .GetAndPlaceNest
2015-11-16 18:07:26 -08:00
.loop
call JoyTextDelay
ld hl, hJoyPressed
ld a, [hl]
and A_BUTTON | B_BUTTON
jr nz, .a_b
ldh a, [hJoypadDown]
2015-11-16 18:07:26 -08:00
and SELECT
jr nz, .select
2015-12-09 08:38:40 -08:00
call .LeftRightInput
call .BlinkNestIcons
2015-11-16 18:07:26 -08:00
jr .next
.select
2015-12-09 08:38:40 -08:00
call .HideNestsShowPlayer
2015-11-16 18:07:26 -08:00
.next
call DelayFrame
jr .loop
.a_b
call ClearSprites
pop af
2017-12-09 16:41:03 -08:00
ld [wTownMapCursorLandmark], a
2015-11-16 18:07:26 -08:00
pop af
2017-12-09 16:41:03 -08:00
ld [wTownMapPlayerIconLandmark], a
2015-11-16 18:07:26 -08:00
ret
2016-01-09 20:41:03 -08:00
2018-06-24 07:09:41 -07:00
.LeftRightInput:
2015-11-16 18:07:26 -08:00
ld a, [hl]
2015-12-09 08:38:40 -08:00
and D_LEFT
jr nz, .left
2015-11-16 18:07:26 -08:00
ld a, [hl]
2015-12-09 08:38:40 -08:00
and D_RIGHT
jr nz, .right
2015-11-16 18:07:26 -08:00
ret
2015-12-09 08:38:40 -08:00
.left
ldh a, [hWY]
2020-07-21 08:48:39 -07:00
cp SCREEN_HEIGHT_PX
2015-11-16 18:07:26 -08:00
ret z
call ClearSprites
2020-07-21 08:48:39 -07:00
ld a, SCREEN_HEIGHT_PX
ldh [hWY], a
2018-01-11 09:00:01 -08:00
xor a ; JOHTO_REGION
2015-12-09 08:38:40 -08:00
call .GetAndPlaceNest
2015-11-16 18:07:26 -08:00
ret
2015-12-09 08:38:40 -08:00
.right
ld a, [wStatusFlags]
2018-01-22 12:40:43 -08:00
bit STATUSFLAGS_HALL_OF_FAME_F, a
2015-11-16 18:07:26 -08:00
ret z
ldh a, [hWY]
2015-11-16 18:07:26 -08:00
and a
ret z
call ClearSprites
xor a
ldh [hWY], a
2018-01-11 09:00:01 -08:00
ld a, KANTO_REGION
2015-12-09 08:38:40 -08:00
call .GetAndPlaceNest
2015-11-16 18:07:26 -08:00
ret
2016-01-09 20:41:03 -08:00
2018-06-24 07:09:41 -07:00
.BlinkNestIcons:
ldh a, [hVBlankCounter]
2015-11-16 18:07:26 -08:00
ld e, a
and $f
ret nz
ld a, e
and $10
2015-12-09 08:38:40 -08:00
jr nz, .copy_sprites
2015-11-16 18:07:26 -08:00
call ClearSprites
ret
2015-12-09 08:38:40 -08:00
.copy_sprites
2015-11-16 18:07:26 -08:00
hlcoord 0, 0
ld de, wVirtualOAM
2018-01-30 11:55:20 -08:00
ld bc, wVirtualOAMEnd - wVirtualOAM
2015-11-16 18:07:26 -08:00
call CopyBytes
ret
2016-01-09 20:41:03 -08:00
2018-06-24 07:09:41 -07:00
.PlaceString_MonsNest:
2015-11-16 18:07:26 -08:00
hlcoord 0, 0
ld bc, SCREEN_WIDTH
2015-12-09 08:38:40 -08:00
ld a, " "
2015-11-16 18:07:26 -08:00
call ByteFill
hlcoord 0, 1
2019-06-09 16:52:46 -07:00
ld a, $06
2015-11-16 18:07:26 -08:00
ld [hli], a
2015-12-09 08:38:40 -08:00
ld bc, SCREEN_WIDTH - 2
2019-06-09 16:52:46 -07:00
ld a, $07
2015-11-16 18:07:26 -08:00
call ByteFill
ld [hl], $17
call GetPokemonName
hlcoord 2, 0
call PlaceString
ld h, b
ld l, c
2015-12-09 08:38:40 -08:00
ld de, .String_SNest
2015-11-16 18:07:26 -08:00
call PlaceString
ret
2016-01-09 20:41:03 -08:00
2015-12-09 08:38:40 -08:00
.String_SNest:
2015-11-16 18:07:26 -08:00
db "'S NEST@"
2018-06-24 07:09:41 -07:00
.GetAndPlaceNest:
2017-12-09 16:41:03 -08:00
ld [wTownMapCursorLandmark], a
2015-11-16 18:07:26 -08:00
ld e, a
farcall FindNest ; load nest landmarks into wTilemap[0,0]
2015-11-16 18:07:26 -08:00
decoord 0, 0
2018-01-30 11:52:46 -08:00
ld hl, wVirtualOAMSprite00
2015-12-09 08:38:40 -08:00
.nestloop
2015-11-16 18:07:26 -08:00
ld a, [de]
and a
2015-12-09 08:38:40 -08:00
jr z, .done_nest
2015-11-16 18:07:26 -08:00
push de
ld e, a
push hl
2017-12-24 09:47:30 -08:00
farcall GetLandmarkCoords
2015-11-16 18:07:26 -08:00
pop hl
2015-12-09 08:38:40 -08:00
; load into OAM
2015-11-16 18:07:26 -08:00
ld a, d
2015-12-09 08:38:40 -08:00
sub 4
2018-01-10 10:47:57 -08:00
ld [hli], a ; y
2015-11-16 18:07:26 -08:00
ld a, e
2015-12-09 08:38:40 -08:00
sub 4
2018-01-10 10:47:57 -08:00
ld [hli], a ; x
ld a, $7f ; nest icon
ld [hli], a ; tile id
2015-11-16 18:07:26 -08:00
xor a
2018-01-10 10:47:57 -08:00
ld [hli], a ; attributes
2015-12-09 08:38:40 -08:00
; next
2015-11-16 18:07:26 -08:00
pop de
inc de
2015-12-09 08:38:40 -08:00
jr .nestloop
2015-11-16 18:07:26 -08:00
2015-12-09 08:38:40 -08:00
.done_nest
ld hl, wVirtualOAM
2015-11-16 18:07:26 -08:00
decoord 0, 0
2018-01-30 11:55:20 -08:00
ld bc, wVirtualOAMEnd - wVirtualOAM
2015-11-16 18:07:26 -08:00
call CopyBytes
ret
2016-01-09 20:41:03 -08:00
2018-06-24 07:09:41 -07:00
.HideNestsShowPlayer:
2015-12-09 08:38:40 -08:00
call .CheckPlayerLocation
2015-11-16 18:07:26 -08:00
ret c
2017-12-09 16:41:03 -08:00
ld a, [wTownMapPlayerIconLandmark]
2015-11-16 18:07:26 -08:00
ld e, a
2017-12-24 09:47:30 -08:00
farcall GetLandmarkCoords
2015-11-16 18:07:26 -08:00
ld c, e
ld b, d
2015-12-09 08:38:40 -08:00
ld de, .PlayerOAM
2018-01-30 11:52:46 -08:00
ld hl, wVirtualOAMSprite00
.ShowPlayerLoop:
2015-11-16 18:07:26 -08:00
ld a, [de]
cp $80
2016-01-10 14:44:09 -08:00
jr z, .clear_oam
2015-11-16 18:07:26 -08:00
add b
2018-01-10 10:47:57 -08:00
ld [hli], a ; y
2015-11-16 18:07:26 -08:00
inc de
ld a, [de]
add c
2018-01-10 10:47:57 -08:00
ld [hli], a ; x
2015-11-16 18:07:26 -08:00
inc de
ld a, [de]
2015-12-09 08:38:40 -08:00
add $78 ; where the player's sprite is loaded
2018-01-10 10:47:57 -08:00
ld [hli], a ; tile id
2015-11-16 18:07:26 -08:00
inc de
push bc
2018-01-10 10:47:57 -08:00
ld c, PAL_OW_RED
ld a, [wPlayerGender]
2018-01-22 11:34:55 -08:00
bit PLAYERGENDER_FEMALE_F, a
2018-01-10 10:47:57 -08:00
jr z, .male
inc c ; PAL_OW_BLUE
.male
2015-11-16 18:07:26 -08:00
ld a, c
2018-01-10 10:47:57 -08:00
ld [hli], a ; attributes
2015-11-16 18:07:26 -08:00
pop bc
2015-12-09 08:38:40 -08:00
jr .ShowPlayerLoop
2015-11-16 18:07:26 -08:00
2016-01-10 14:44:09 -08:00
.clear_oam
2018-01-30 11:52:46 -08:00
ld hl, wVirtualOAMSprite04
2018-01-30 11:55:20 -08:00
ld bc, wVirtualOAMEnd - wVirtualOAMSprite04
2015-11-16 18:07:26 -08:00
xor a
call ByteFill
ret
2016-01-09 20:41:03 -08:00
2018-06-24 07:09:41 -07:00
.PlayerOAM:
2018-01-10 10:47:57 -08:00
; y pxl, x pxl, tile offset
db -1 * 8, -1 * 8, 0 ; top left
db -1 * 8, 0 * 8, 1 ; top right
db 0 * 8, -1 * 8, 2 ; bottom left
db 0 * 8, 0 * 8, 3 ; bottom right
2015-11-16 18:07:26 -08:00
db $80 ; terminator
2018-06-24 07:09:41 -07:00
.CheckPlayerLocation:
2015-12-09 08:38:40 -08:00
; Don't show the player's sprite if you're
; not in the same region as what's currently
; on the screen.
2017-12-09 16:41:03 -08:00
ld a, [wTownMapPlayerIconLandmark]
cp LANDMARK_FAST_SHIP
2015-11-16 18:07:26 -08:00
jr z, .johto
cp KANTO_LANDMARK
jr c, .johto
; kanto
2017-12-09 16:41:03 -08:00
ld a, [wTownMapCursorLandmark]
2015-11-16 18:07:26 -08:00
and a
jr z, .clear
jr .ok
.johto
2017-12-09 16:41:03 -08:00
ld a, [wTownMapCursorLandmark]
2015-11-16 18:07:26 -08:00
and a
jr nz, .clear
.ok
and a
ret
.clear
ld hl, wVirtualOAM
2018-01-30 11:55:20 -08:00
ld bc, wVirtualOAMEnd - wVirtualOAM
2015-11-16 18:07:26 -08:00
xor a
call ByteFill
scf
ret
2016-01-09 20:41:03 -08:00
2018-06-24 07:09:41 -07:00
.GetPlayerOrFastShipIcon:
2017-12-09 16:41:03 -08:00
ld a, [wTownMapPlayerIconLandmark]
cp LANDMARK_FAST_SHIP
2015-12-09 08:38:40 -08:00
jr z, .FastShip
2017-12-24 09:47:30 -08:00
farcall GetPlayerIcon
2015-11-16 18:07:26 -08:00
ret
.FastShip:
2015-11-16 18:07:26 -08:00
ld de, FastShipGFX
ld b, BANK(FastShipGFX)
ret
2016-01-09 20:41:03 -08:00
2018-06-24 07:09:41 -07:00
TownMapBGUpdate:
2015-11-16 18:07:26 -08:00
; Update BG Map tiles and attributes
; BG Map address
ld a, l
ldh [hBGMapAddress], a
2015-11-16 18:07:26 -08:00
ld a, h
ldh [hBGMapAddress + 1], a
2015-11-16 18:07:26 -08:00
; Only update palettes on CGB
ldh a, [hCGB]
2015-11-16 18:07:26 -08:00
and a
jr z, .tiles
; BG Map mode 2 (palettes)
ld a, 2
ldh [hBGMapMode], a
2015-11-16 18:07:26 -08:00
; The BG Map is updated in thirds, so we wait
2016-01-09 20:41:03 -08:00
2015-11-16 18:07:26 -08:00
; 3 frames to update the whole screen's palettes.
ld c, 3
call DelayFrames
.tiles
; Update BG Map tiles
call WaitBGMap
; Turn off BG Map update
xor a
ldh [hBGMapMode], a
2015-11-16 18:07:26 -08:00
ret
2016-01-09 20:41:03 -08:00
2018-06-24 07:09:41 -07:00
FillJohtoMap:
2015-11-16 18:07:26 -08:00
ld de, JohtoMap
jr FillTownMap
2018-06-24 07:09:41 -07:00
FillKantoMap:
2015-11-16 18:07:26 -08:00
ld de, KantoMap
2018-06-24 07:09:41 -07:00
FillTownMap:
2015-11-16 18:07:26 -08:00
hlcoord 0, 0
.loop
ld a, [de]
2015-12-09 08:38:40 -08:00
cp -1
2015-11-16 18:07:26 -08:00
ret z
ld a, [de]
ld [hli], a
inc de
jr .loop
2016-01-09 20:41:03 -08:00
2018-06-24 07:09:41 -07:00
TownMapPals:
2015-11-16 18:07:26 -08:00
; Assign palettes based on tile ids
hlcoord 0, 0
decoord 0, 0, wAttrmap
2015-12-09 08:38:40 -08:00
ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
2015-11-16 18:07:26 -08:00
.loop
; Current tile
ld a, [hli]
push hl
2018-01-11 09:00:01 -08:00
; The palette map covers tiles $00 to $5f; $60 and above use palette 0
2015-11-16 18:07:26 -08:00
cp $60
jr nc, .pal0
2016-01-09 20:41:03 -08:00
2018-01-11 09:00:01 -08:00
; The palette data is condensed to nybbles, least-significant first.
ld hl, .PalMap
2015-11-16 18:07:26 -08:00
srl a
jr c, .odd
; Even-numbered tile ids take the bottom nybble...
add l
ld l, a
ld a, h
adc 0
ld h, a
ld a, [hl]
2018-01-11 09:00:01 -08:00
and PALETTE_MASK
2015-11-16 18:07:26 -08:00
jr .update
.odd
; ...and odd ids take the top.
add l
ld l, a
ld a, h
adc 0
ld h, a
ld a, [hl]
swap a
2018-01-11 09:00:01 -08:00
and PALETTE_MASK
2015-11-16 18:07:26 -08:00
jr .update
.pal0
xor a
.update
pop hl
ld [de], a
inc de
dec bc
ld a, b
or c
jr nz, .loop
ret
.PalMap:
INCLUDE "gfx/pokegear/town_map_palette_map.asm"
2015-11-16 18:07:26 -08:00
2018-06-24 07:09:41 -07:00
TownMapMon:
2018-01-11 09:00:01 -08:00
; Draw the FlyMon icon at town map location
2015-11-16 18:07:26 -08:00
; Get FlyMon species
2018-01-23 14:39:09 -08:00
ld a, [wCurPartyMon]
ld hl, wPartySpecies
2015-11-16 18:07:26 -08:00
ld e, a
ld d, 0
2015-11-16 18:07:26 -08:00
add hl, de
ld a, [hl]
ld [wTempIconSpecies], a
2015-11-16 18:07:26 -08:00
; Get FlyMon icon
2018-01-11 09:00:01 -08:00
ld e, $08 ; starting tile in VRAM
2017-12-24 09:47:30 -08:00
farcall GetSpeciesIcon
2015-11-16 18:07:26 -08:00
; Animation/palette
2015-12-09 08:38:40 -08:00
depixel 0, 0
ld a, SPRITE_ANIM_INDEX_PARTY_MON
call InitSpriteAnimStruct
2015-12-09 08:38:40 -08:00
ld hl, SPRITEANIMSTRUCT_TILE_ID
2015-11-16 18:07:26 -08:00
add hl, bc
2018-01-11 09:00:01 -08:00
ld [hl], $08
2015-12-09 08:38:40 -08:00
ld hl, SPRITEANIMSTRUCT_ANIM_SEQ_ID
2015-11-16 18:07:26 -08:00
add hl, bc
2015-12-18 17:07:09 -08:00
ld [hl], SPRITE_ANIM_SEQ_NULL
2015-11-16 18:07:26 -08:00
ret
2016-01-09 20:41:03 -08:00
2018-06-24 07:09:41 -07:00
TownMapPlayerIcon:
2015-11-16 18:07:26 -08:00
; Draw the player icon at town map location in a
push af
2017-12-24 09:47:30 -08:00
farcall GetPlayerIcon
2015-11-16 18:07:26 -08:00
; Standing icon
2017-12-28 04:32:33 -08:00
ld hl, vTiles0 tile $10
2015-11-16 18:07:26 -08:00
ld c, 4 ; # tiles
call Request2bpp
; Walking icon
2021-03-24 07:24:52 -07:00
ld hl, 12 tiles
2015-11-16 18:07:26 -08:00
add hl, de
ld d, h
ld e, l
2017-12-28 04:32:33 -08:00
ld hl, vTiles0 tile $14
2015-11-16 18:07:26 -08:00
ld c, 4 ; # tiles
ld a, BANK(ChrisSpriteGFX) ; does nothing
call Request2bpp
; Animation/palette
2015-12-09 08:38:40 -08:00
depixel 0, 0
2016-01-09 20:41:03 -08:00
ld b, SPRITE_ANIM_INDEX_RED_WALK ; Male
ld a, [wPlayerGender]
2018-01-22 11:34:55 -08:00
bit PLAYERGENDER_FEMALE_F, a
2015-12-09 08:38:40 -08:00
jr z, .got_gender
2016-01-09 20:41:03 -08:00
ld b, SPRITE_ANIM_INDEX_BLUE_WALK ; Female
2015-12-09 08:38:40 -08:00
.got_gender
2015-11-16 18:07:26 -08:00
ld a, b
call InitSpriteAnimStruct
2015-12-09 08:38:40 -08:00
ld hl, SPRITEANIMSTRUCT_TILE_ID
2015-11-16 18:07:26 -08:00
add hl, bc
ld [hl], $10
pop af
ld e, a
push bc
2017-12-24 09:47:30 -08:00
farcall GetLandmarkCoords
2015-11-16 18:07:26 -08:00
pop bc
2015-12-09 08:38:40 -08:00
ld hl, SPRITEANIMSTRUCT_XCOORD
2015-11-16 18:07:26 -08:00
add hl, bc
ld [hl], e
2015-12-09 08:38:40 -08:00
ld hl, SPRITEANIMSTRUCT_YCOORD
2015-11-16 18:07:26 -08:00
add hl, bc
ld [hl], d
ret
2016-01-09 20:41:03 -08:00
2018-06-24 07:09:41 -07:00
LoadTownMapGFX:
2015-11-16 18:07:26 -08:00
ld hl, TownMapGFX
2017-12-28 04:32:33 -08:00
ld de, vTiles2
2018-01-14 16:43:35 -08:00
lb bc, BANK(TownMapGFX), 48
2015-11-16 18:07:26 -08:00
call DecompressRequest2bpp
ret
2018-06-24 07:09:41 -07:00
JohtoMap:
INCBIN "gfx/pokegear/johto.bin"
2015-11-16 18:07:26 -08:00
2018-06-24 07:09:41 -07:00
KantoMap:
INCBIN "gfx/pokegear/kanto.bin"
2015-11-16 18:07:26 -08:00
2018-06-24 07:09:41 -07:00
PokedexNestIconGFX:
2015-12-09 08:38:40 -08:00
INCBIN "gfx/pokegear/dexmap_nest_icon.2bpp"
2018-06-24 07:09:41 -07:00
FlyMapLabelBorderGFX:
INCBIN "gfx/pokegear/flymap_label_border.1bpp"
2016-01-10 14:44:09 -08:00
EntireFlyMap: ; unreferenced
; Similar to _FlyMap, but scrolls through the entire
; Flypoints data of both regions. A debug function?
2015-11-16 18:07:26 -08:00
xor a
2017-12-09 16:41:03 -08:00
ld [wTownMapPlayerIconLandmark], a
2015-11-16 18:07:26 -08:00
call ClearBGPalettes
call ClearTilemap
2015-11-16 18:07:26 -08:00
call ClearSprites
ld hl, hInMenu
ld a, [hl]
push af
ld [hl], $1
xor a
ldh [hBGMapMode], a
2017-12-24 09:47:30 -08:00
farcall ClearSpriteAnims
2015-12-09 08:38:40 -08:00
call LoadTownMapGFX
ld de, FlyMapLabelBorderGFX
2017-12-28 04:32:33 -08:00
ld hl, vTiles2 tile $30
2015-12-09 08:38:40 -08:00
lb bc, BANK(FlyMapLabelBorderGFX), 6
2015-11-16 18:07:26 -08:00
call Request1bpp
call FillKantoMap
call TownMapBubble
call TownMapPals
2017-12-28 04:32:33 -08:00
hlbgcoord 0, 0, vBGMap1
2015-11-16 18:07:26 -08:00
call TownMapBGUpdate
call FillJohtoMap
call TownMapBubble
call TownMapPals
2015-11-20 08:47:52 -08:00
hlbgcoord 0, 0
2015-11-16 18:07:26 -08:00
call TownMapBGUpdate
call TownMapMon
ld a, c
2017-12-09 16:41:03 -08:00
ld [wTownMapCursorCoordinates], a
2015-11-16 18:07:26 -08:00
ld a, b
2017-12-09 16:41:03 -08:00
ld [wTownMapCursorCoordinates + 1], a
2015-12-28 07:57:04 -08:00
ld b, SCGB_POKEGEAR_PALS
2015-11-16 18:07:26 -08:00
call GetSGBLayout
call SetPalettes
.loop
call JoyTextDelay
ld hl, hJoyPressed
ld a, [hl]
and B_BUTTON
jr nz, .pressedB
ld a, [hl]
and A_BUTTON
jr nz, .pressedA
2015-12-09 08:38:40 -08:00
call .HandleDPad
2015-11-16 18:07:26 -08:00
call GetMapCursorCoordinates
2017-12-24 09:47:30 -08:00
farcall PlaySpriteAnimations
2015-11-16 18:07:26 -08:00
call DelayFrame
jr .loop
.pressedB
ld a, -1
jr .exit
2015-11-16 18:07:26 -08:00
.pressedA
2017-12-09 16:41:03 -08:00
ld a, [wTownMapPlayerIconLandmark]
2015-11-16 18:07:26 -08:00
ld l, a
ld h, 0
add hl, hl
ld de, Flypoints + 1
add hl, de
ld a, [hl]
.exit
2017-12-09 16:41:03 -08:00
ld [wTownMapPlayerIconLandmark], a
2015-11-16 18:07:26 -08:00
pop af
ldh [hInMenu], a
2015-11-16 18:07:26 -08:00
call ClearBGPalettes
2020-07-21 08:48:39 -07:00
ld a, SCREEN_HEIGHT_PX
ldh [hWY], a
2017-12-28 04:32:33 -08:00
xor a ; LOW(vBGMap0)
ldh [hBGMapAddress], a
2017-12-28 04:32:33 -08:00
ld a, HIGH(vBGMap0)
ldh [hBGMapAddress + 1], a
2017-12-09 16:41:03 -08:00
ld a, [wTownMapPlayerIconLandmark]
2015-11-16 18:07:26 -08:00
ld e, a
ret
2016-01-09 20:41:03 -08:00
2018-06-24 07:09:41 -07:00
.HandleDPad:
2015-11-16 18:07:26 -08:00
ld hl, hJoyLast
ld a, [hl]
and D_DOWN | D_RIGHT
jr nz, .ScrollNext
2015-11-16 18:07:26 -08:00
ld a, [hl]
and D_UP | D_LEFT
jr nz, .ScrollPrev
2015-11-16 18:07:26 -08:00
ret
.ScrollNext:
2017-12-09 16:41:03 -08:00
ld hl, wTownMapPlayerIconLandmark
2015-11-16 18:07:26 -08:00
ld a, [hl]
2020-07-21 08:48:39 -07:00
cp NUM_FLYPOINTS - 1
jr c, .NotAtEndYet
2015-11-16 18:07:26 -08:00
ld [hl], -1
.NotAtEndYet:
2015-11-16 18:07:26 -08:00
inc [hl]
jr .FillMap
2015-11-16 18:07:26 -08:00
.ScrollPrev:
2017-12-09 16:41:03 -08:00
ld hl, wTownMapPlayerIconLandmark
2015-11-16 18:07:26 -08:00
ld a, [hl]
and a
jr nz, .NotAtStartYet
2020-07-21 08:48:39 -07:00
ld [hl], NUM_FLYPOINTS
.NotAtStartYet:
2015-11-16 18:07:26 -08:00
dec [hl]
.FillMap:
2017-12-09 16:41:03 -08:00
ld a, [wTownMapPlayerIconLandmark]
2015-11-16 18:07:26 -08:00
cp KANTO_FLYPOINT
jr c, .InJohto
2015-11-16 18:07:26 -08:00
call FillKantoMap
xor a
2020-07-21 08:48:39 -07:00
ld b, HIGH(vBGMap1)
jr .Finally
2015-11-16 18:07:26 -08:00
.InJohto:
2015-11-16 18:07:26 -08:00
call FillJohtoMap
2020-07-21 08:48:39 -07:00
ld a, SCREEN_HEIGHT_PX
ld b, HIGH(vBGMap0)
.Finally:
ldh [hWY], a
2015-11-16 18:07:26 -08:00
ld a, b
ldh [hBGMapAddress + 1], a
2015-11-16 18:07:26 -08:00
call TownMapBubble
call WaitBGMap
xor a
ldh [hBGMapMode], a
2015-11-16 18:07:26 -08:00
ret