2014-05-22 22:13:20 +00:00
|
|
|
DisplayTownMap: ; 70e3e (1c:4e3e)
|
|
|
|
call LoadTownMap
|
2014-09-13 07:50:56 +00:00
|
|
|
ld hl, wUpdateSpritesEnabled
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a, [hl]
|
|
|
|
push af
|
|
|
|
ld [hl], $ff
|
|
|
|
push hl
|
|
|
|
ld a, $1
|
2014-08-31 02:48:49 +00:00
|
|
|
ld [hJoy7], a
|
2015-08-31 02:38:41 +00:00
|
|
|
ld a, [wCurMap]
|
2014-05-22 22:13:20 +00:00
|
|
|
push af
|
|
|
|
ld b, $0
|
2015-07-14 02:24:07 +00:00
|
|
|
call DrawPlayerOrBirdSprite ; player sprite
|
2015-07-18 20:52:03 +00:00
|
|
|
coord hl, 1, 0
|
2014-05-26 21:04:56 +00:00
|
|
|
ld de, wcd6d
|
2014-05-22 22:13:20 +00:00
|
|
|
call PlaceString
|
|
|
|
ld hl, wOAMBuffer
|
|
|
|
ld de, wTileMapBackup
|
|
|
|
ld bc, $10
|
|
|
|
call CopyData
|
2014-05-29 08:31:46 +00:00
|
|
|
ld hl, vSprites + $40
|
2015-07-03 19:37:53 +00:00
|
|
|
ld de, TownMapCursor
|
2015-08-10 04:56:20 +00:00
|
|
|
lb bc, BANK(TownMapCursor), (TownMapCursorEnd - TownMapCursor) / $8
|
2014-05-22 22:13:20 +00:00
|
|
|
call CopyVideoDataDouble
|
|
|
|
xor a
|
2015-07-14 02:24:07 +00:00
|
|
|
ld [wWhichTownMapLocation], a
|
2014-05-22 22:13:20 +00:00
|
|
|
pop af
|
2015-07-14 05:21:03 +00:00
|
|
|
jr .enterLoop
|
2014-05-22 22:13:20 +00:00
|
|
|
|
2015-07-14 05:21:03 +00:00
|
|
|
.townMapLoop
|
2015-07-18 20:52:03 +00:00
|
|
|
coord hl, 0, 0
|
2015-08-05 21:20:29 +00:00
|
|
|
lb bc, 1, 20
|
2014-05-22 22:13:20 +00:00
|
|
|
call ClearScreenArea
|
2015-07-03 19:37:53 +00:00
|
|
|
ld hl, TownMapOrder
|
2015-07-14 02:24:07 +00:00
|
|
|
ld a, [wWhichTownMapLocation]
|
2014-05-22 22:13:20 +00:00
|
|
|
ld c, a
|
2015-07-14 02:24:07 +00:00
|
|
|
ld b, 0
|
2014-05-22 22:13:20 +00:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
2015-07-14 05:21:03 +00:00
|
|
|
.enterLoop
|
2015-07-14 02:24:07 +00:00
|
|
|
ld de, wTownMapCoords
|
|
|
|
call LoadTownMapEntry
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a, [de]
|
|
|
|
push hl
|
2015-07-14 02:24:07 +00:00
|
|
|
call TownMapCoordsToOAMCoords
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a, $4
|
2015-07-14 02:24:07 +00:00
|
|
|
ld [wOAMBaseTile], a
|
2014-05-26 21:04:56 +00:00
|
|
|
ld hl, wOAMBuffer + $10
|
2015-07-14 02:24:07 +00:00
|
|
|
call WriteTownMapSpriteOAM ; town map cursor sprite
|
2014-05-22 22:13:20 +00:00
|
|
|
pop hl
|
2014-05-26 21:04:56 +00:00
|
|
|
ld de, wcd6d
|
2015-07-14 02:24:07 +00:00
|
|
|
.copyMapName
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a, [hli]
|
|
|
|
ld [de], a
|
|
|
|
inc de
|
|
|
|
cp $50
|
2015-07-14 02:24:07 +00:00
|
|
|
jr nz, .copyMapName
|
2015-07-18 20:52:03 +00:00
|
|
|
coord hl, 1, 0
|
2014-05-26 21:04:56 +00:00
|
|
|
ld de, wcd6d
|
2014-05-22 22:13:20 +00:00
|
|
|
call PlaceString
|
2014-05-26 21:04:56 +00:00
|
|
|
ld hl, wOAMBuffer + $10
|
|
|
|
ld de, wTileMapBackup + 16
|
2014-05-22 22:13:20 +00:00
|
|
|
ld bc, $10
|
|
|
|
call CopyData
|
2015-07-14 05:21:03 +00:00
|
|
|
.inputLoop
|
2014-09-14 18:29:18 +00:00
|
|
|
call TownMapSpriteBlinkingAnimation
|
2014-05-25 18:21:48 +00:00
|
|
|
call JoypadLowSensitivity
|
2014-08-31 02:48:49 +00:00
|
|
|
ld a, [hJoy5]
|
2014-05-22 22:13:20 +00:00
|
|
|
ld b, a
|
2015-07-14 05:21:03 +00:00
|
|
|
and A_BUTTON | B_BUTTON | D_UP | D_DOWN
|
|
|
|
jr z, .inputLoop
|
2015-07-19 08:46:12 +00:00
|
|
|
ld a, SFX_TINK
|
2014-05-22 22:13:20 +00:00
|
|
|
call PlaySound
|
|
|
|
bit 6, b
|
2015-07-14 02:24:07 +00:00
|
|
|
jr nz, .pressedUp
|
2014-05-22 22:13:20 +00:00
|
|
|
bit 7, b
|
2015-07-14 02:24:07 +00:00
|
|
|
jr nz, .pressedDown
|
2014-05-22 22:13:20 +00:00
|
|
|
xor a
|
2014-09-14 18:29:18 +00:00
|
|
|
ld [wTownMapSpriteBlinkingEnabled], a
|
2014-08-31 02:48:49 +00:00
|
|
|
ld [hJoy7], a
|
2015-07-13 20:35:35 +00:00
|
|
|
ld [wAnimCounter], a
|
2015-07-14 05:21:03 +00:00
|
|
|
call ExitTownMap
|
2014-05-22 22:13:20 +00:00
|
|
|
pop hl
|
|
|
|
pop af
|
|
|
|
ld [hl], a
|
|
|
|
ret
|
2015-07-14 02:24:07 +00:00
|
|
|
.pressedUp
|
|
|
|
ld a, [wWhichTownMapLocation]
|
2014-05-22 22:13:20 +00:00
|
|
|
inc a
|
2015-07-14 05:21:03 +00:00
|
|
|
cp TownMapOrderEnd - TownMapOrder ; number of list items + 1
|
|
|
|
jr nz, .noOverflow
|
2014-05-22 22:13:20 +00:00
|
|
|
xor a
|
2015-07-14 05:21:03 +00:00
|
|
|
.noOverflow
|
2015-07-14 02:24:07 +00:00
|
|
|
ld [wWhichTownMapLocation], a
|
2015-07-14 05:21:03 +00:00
|
|
|
jp .townMapLoop
|
2015-07-14 02:24:07 +00:00
|
|
|
.pressedDown
|
|
|
|
ld a, [wWhichTownMapLocation]
|
2014-05-22 22:13:20 +00:00
|
|
|
dec a
|
2015-07-14 02:24:07 +00:00
|
|
|
cp -1
|
2015-07-14 05:21:03 +00:00
|
|
|
jr nz, .noUnderflow
|
|
|
|
ld a, TownMapOrderEnd - TownMapOrder - 1 ; number of list items
|
|
|
|
.noUnderflow
|
2015-07-14 02:24:07 +00:00
|
|
|
ld [wWhichTownMapLocation], a
|
2015-07-14 05:21:03 +00:00
|
|
|
jp .townMapLoop
|
2014-05-22 22:13:20 +00:00
|
|
|
|
|
|
|
INCLUDE "data/town_map_order.asm"
|
|
|
|
|
|
|
|
TownMapCursor: ; 70f40 (1c:4f40)
|
|
|
|
INCBIN "gfx/town_map_cursor.1bpp"
|
2015-08-10 04:56:20 +00:00
|
|
|
TownMapCursorEnd:
|
2014-05-22 22:13:20 +00:00
|
|
|
|
|
|
|
LoadTownMap_Nest: ; 70f60 (1c:4f60)
|
|
|
|
call LoadTownMap
|
2014-09-13 07:50:56 +00:00
|
|
|
ld hl, wUpdateSpritesEnabled
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a, [hl]
|
|
|
|
push af
|
|
|
|
ld [hl], $ff
|
|
|
|
push hl
|
2015-07-14 05:21:03 +00:00
|
|
|
call DisplayWildLocations
|
2014-05-22 22:13:20 +00:00
|
|
|
call GetMonName
|
2015-07-18 20:52:03 +00:00
|
|
|
coord hl, 1, 0
|
2014-05-22 22:13:20 +00:00
|
|
|
call PlaceString
|
|
|
|
ld h, b
|
|
|
|
ld l, c
|
|
|
|
ld de, MonsNestText
|
|
|
|
call PlaceString
|
|
|
|
call WaitForTextScrollButtonPress
|
2015-07-14 05:21:03 +00:00
|
|
|
call ExitTownMap
|
2014-05-22 22:13:20 +00:00
|
|
|
pop hl
|
|
|
|
pop af
|
|
|
|
ld [hl], a
|
|
|
|
ret
|
|
|
|
|
|
|
|
MonsNestText: ; 70f89 (1c:4f89)
|
|
|
|
db "'s NEST@"
|
|
|
|
|
|
|
|
LoadTownMap_Fly: ; 70f90 (1c:4f90)
|
2014-05-23 22:34:35 +00:00
|
|
|
call ClearSprites
|
2014-05-22 22:13:20 +00:00
|
|
|
call LoadTownMap
|
|
|
|
call LoadPlayerSpriteGraphics
|
|
|
|
call LoadFontTilePatterns
|
2015-07-03 19:37:53 +00:00
|
|
|
ld de, BirdSprite
|
2014-05-29 08:31:46 +00:00
|
|
|
ld hl, vSprites + $40
|
2015-08-05 21:20:29 +00:00
|
|
|
lb bc, BANK(BirdSprite), $0c
|
2014-05-22 22:13:20 +00:00
|
|
|
call CopyVideoData
|
2015-07-03 19:37:53 +00:00
|
|
|
ld de, TownMapUpArrow
|
2014-05-29 08:31:46 +00:00
|
|
|
ld hl, vChars1 + $6d0
|
2015-08-10 04:56:20 +00:00
|
|
|
lb bc, BANK(TownMapUpArrow), (TownMapUpArrowEnd - TownMapUpArrow) / $8
|
2014-05-22 22:13:20 +00:00
|
|
|
call CopyVideoDataDouble
|
2015-07-14 02:24:07 +00:00
|
|
|
call BuildFlyLocationsList
|
2014-09-13 07:50:56 +00:00
|
|
|
ld hl, wUpdateSpritesEnabled
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a, [hl]
|
|
|
|
push af
|
|
|
|
ld [hl], $ff
|
|
|
|
push hl
|
2015-07-18 20:52:03 +00:00
|
|
|
coord hl, 0, 0
|
2014-05-22 22:13:20 +00:00
|
|
|
ld de, ToText
|
|
|
|
call PlaceString
|
2015-08-31 02:38:41 +00:00
|
|
|
ld a, [wCurMap]
|
2014-05-22 22:13:20 +00:00
|
|
|
ld b, $0
|
2015-07-14 02:24:07 +00:00
|
|
|
call DrawPlayerOrBirdSprite
|
|
|
|
ld hl, wFlyLocationsList
|
2015-07-18 20:52:03 +00:00
|
|
|
coord de, 18, 0
|
2014-05-22 22:13:20 +00:00
|
|
|
.townMapFlyLoop
|
2015-08-05 21:20:29 +00:00
|
|
|
ld a, " "
|
2014-05-22 22:13:20 +00:00
|
|
|
ld [de], a
|
|
|
|
push hl
|
|
|
|
push hl
|
2015-07-18 20:52:03 +00:00
|
|
|
coord hl, 3, 0
|
2015-08-05 21:20:29 +00:00
|
|
|
lb bc, 1, 15
|
2014-05-22 22:13:20 +00:00
|
|
|
call ClearScreenArea
|
|
|
|
pop hl
|
|
|
|
ld a, [hl]
|
|
|
|
ld b, $4
|
2015-07-14 02:24:07 +00:00
|
|
|
call DrawPlayerOrBirdSprite ; draw bird sprite
|
2015-07-18 20:52:03 +00:00
|
|
|
coord hl, 3, 0
|
2014-05-26 21:04:56 +00:00
|
|
|
ld de, wcd6d
|
2014-05-22 22:13:20 +00:00
|
|
|
call PlaceString
|
2015-07-03 19:37:53 +00:00
|
|
|
ld c, 15
|
2014-05-22 22:13:20 +00:00
|
|
|
call DelayFrames
|
2015-07-18 20:52:03 +00:00
|
|
|
coord hl, 18, 0
|
2014-05-22 22:13:20 +00:00
|
|
|
ld [hl], $ed
|
2015-07-18 20:52:03 +00:00
|
|
|
coord hl, 19, 0
|
2014-05-22 22:13:20 +00:00
|
|
|
ld [hl], $ee
|
|
|
|
pop hl
|
2015-07-14 05:21:03 +00:00
|
|
|
.inputLoop
|
2014-05-22 22:13:20 +00:00
|
|
|
push hl
|
|
|
|
call DelayFrame
|
2014-05-25 18:21:48 +00:00
|
|
|
call JoypadLowSensitivity
|
2014-08-31 02:48:49 +00:00
|
|
|
ld a, [hJoy5]
|
2014-05-22 22:13:20 +00:00
|
|
|
ld b, a
|
|
|
|
pop hl
|
2015-07-14 05:21:03 +00:00
|
|
|
and A_BUTTON | B_BUTTON | D_UP | D_DOWN
|
|
|
|
jr z, .inputLoop
|
2014-05-22 22:13:20 +00:00
|
|
|
bit 0, b
|
2015-07-14 02:24:07 +00:00
|
|
|
jr nz, .pressedA
|
2015-07-19 08:46:12 +00:00
|
|
|
ld a, SFX_TINK
|
2014-05-22 22:13:20 +00:00
|
|
|
call PlaySound
|
|
|
|
bit 6, b
|
2015-07-14 02:24:07 +00:00
|
|
|
jr nz, .pressedUp
|
2014-05-22 22:13:20 +00:00
|
|
|
bit 7, b
|
2015-07-14 02:24:07 +00:00
|
|
|
jr nz, .pressedDown
|
|
|
|
jr .pressedB
|
|
|
|
.pressedA
|
2015-07-19 08:46:12 +00:00
|
|
|
ld a, SFX_HEAL_AILMENT
|
2014-05-22 22:13:20 +00:00
|
|
|
call PlaySound
|
|
|
|
ld a, [hl]
|
2014-09-13 07:50:56 +00:00
|
|
|
ld [wDestinationMap], a
|
2014-05-26 21:04:56 +00:00
|
|
|
ld hl, wd732
|
2014-05-22 22:13:20 +00:00
|
|
|
set 3, [hl]
|
|
|
|
inc hl
|
|
|
|
set 7, [hl]
|
2015-07-14 02:24:07 +00:00
|
|
|
.pressedB
|
2014-05-22 22:13:20 +00:00
|
|
|
xor a
|
2014-09-14 18:29:18 +00:00
|
|
|
ld [wTownMapSpriteBlinkingEnabled], a
|
2014-05-22 22:13:20 +00:00
|
|
|
call GBPalWhiteOutWithDelay3
|
|
|
|
pop hl
|
|
|
|
pop af
|
|
|
|
ld [hl], a
|
|
|
|
ret
|
2015-07-14 02:24:07 +00:00
|
|
|
.pressedUp
|
2015-07-18 20:52:03 +00:00
|
|
|
coord de, 18, 0
|
2014-05-22 22:13:20 +00:00
|
|
|
inc hl
|
|
|
|
ld a, [hl]
|
|
|
|
cp $ff
|
2015-07-14 02:24:07 +00:00
|
|
|
jr z, .wrapToStartOfList
|
2014-05-22 22:13:20 +00:00
|
|
|
cp $fe
|
2015-07-14 02:24:07 +00:00
|
|
|
jr z, .pressedUp ; skip past unvisited towns
|
2014-05-22 22:13:20 +00:00
|
|
|
jp .townMapFlyLoop
|
2015-07-14 02:24:07 +00:00
|
|
|
.wrapToStartOfList
|
|
|
|
ld hl, wFlyLocationsList
|
2014-05-22 22:13:20 +00:00
|
|
|
jp .townMapFlyLoop
|
2015-07-14 02:24:07 +00:00
|
|
|
.pressedDown
|
2015-07-18 20:52:03 +00:00
|
|
|
coord de, 19, 0
|
2014-05-22 22:13:20 +00:00
|
|
|
dec hl
|
|
|
|
ld a, [hl]
|
|
|
|
cp $ff
|
2015-07-14 02:24:07 +00:00
|
|
|
jr z, .wrapToEndOfList
|
2014-05-22 22:13:20 +00:00
|
|
|
cp $fe
|
2015-07-14 02:24:07 +00:00
|
|
|
jr z, .pressedDown ; skip past unvisited towns
|
2014-05-22 22:13:20 +00:00
|
|
|
jp .townMapFlyLoop
|
2015-07-14 02:24:07 +00:00
|
|
|
.wrapToEndOfList
|
|
|
|
ld hl, wFlyLocationsList + 11
|
|
|
|
jr .pressedDown
|
2014-05-22 22:13:20 +00:00
|
|
|
|
|
|
|
ToText: ; 7106d (1c:506d)
|
|
|
|
db "To@"
|
|
|
|
|
2015-07-14 02:24:07 +00:00
|
|
|
BuildFlyLocationsList: ; 71070 (1c:5070)
|
|
|
|
ld hl, wFlyLocationsList - 1
|
2014-05-22 22:13:20 +00:00
|
|
|
ld [hl], $ff
|
|
|
|
inc hl
|
2015-08-31 02:38:41 +00:00
|
|
|
ld a, [wTownVisitedFlag]
|
2014-05-22 22:13:20 +00:00
|
|
|
ld e, a
|
2015-08-31 02:38:41 +00:00
|
|
|
ld a, [wTownVisitedFlag + 1]
|
2014-05-22 22:13:20 +00:00
|
|
|
ld d, a
|
2015-07-14 05:21:03 +00:00
|
|
|
ld bc, SAFFRON_CITY + 1
|
|
|
|
.loop
|
2014-05-22 22:13:20 +00:00
|
|
|
srl d
|
|
|
|
rr e
|
2015-07-14 02:24:07 +00:00
|
|
|
ld a, $fe ; store $fe if the town hasn't been visited
|
2015-07-14 05:21:03 +00:00
|
|
|
jr nc, .notVisited
|
2015-07-14 02:24:07 +00:00
|
|
|
ld a, b ; store the map number of the town if it has been visited
|
2015-07-14 05:21:03 +00:00
|
|
|
.notVisited
|
2014-05-22 22:13:20 +00:00
|
|
|
ld [hl], a
|
|
|
|
inc hl
|
|
|
|
inc b
|
|
|
|
dec c
|
2015-07-14 05:21:03 +00:00
|
|
|
jr nz, .loop
|
2014-05-22 22:13:20 +00:00
|
|
|
ld [hl], $ff
|
|
|
|
ret
|
|
|
|
|
|
|
|
TownMapUpArrow: ; 71093 (1c:5093)
|
|
|
|
INCBIN "gfx/up_arrow.1bpp"
|
2015-08-10 04:56:20 +00:00
|
|
|
TownMapUpArrowEnd:
|
2014-05-22 22:13:20 +00:00
|
|
|
|
|
|
|
LoadTownMap: ; 7109b (1c:509b)
|
|
|
|
call GBPalWhiteOutWithDelay3
|
|
|
|
call ClearScreen
|
|
|
|
call UpdateSprites
|
2015-07-18 20:52:03 +00:00
|
|
|
coord hl, 0, 0
|
2014-05-22 22:13:20 +00:00
|
|
|
ld b, $12
|
|
|
|
ld c, $12
|
|
|
|
call TextBoxBorder
|
|
|
|
call DisableLCD
|
2015-07-03 19:37:53 +00:00
|
|
|
ld hl, WorldMapTileGraphics
|
2014-05-29 08:31:46 +00:00
|
|
|
ld de, vChars2 + $600
|
2015-08-10 04:56:20 +00:00
|
|
|
ld bc, WorldMapTileGraphicsEnd - WorldMapTileGraphics
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a, BANK(WorldMapTileGraphics)
|
|
|
|
call FarCopyData2
|
2015-07-03 19:37:53 +00:00
|
|
|
ld hl, MonNestIcon
|
2014-05-29 08:31:46 +00:00
|
|
|
ld de, vSprites + $40
|
2015-08-10 04:56:20 +00:00
|
|
|
ld bc, MonNestIconEnd - MonNestIcon
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a, BANK(MonNestIcon)
|
|
|
|
call FarCopyDataDouble
|
2015-07-18 20:52:03 +00:00
|
|
|
coord hl, 0, 0
|
2015-07-03 19:37:53 +00:00
|
|
|
ld de, CompressedMap
|
2015-07-14 05:21:03 +00:00
|
|
|
.nextTile
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a, [de]
|
|
|
|
and a
|
2015-07-14 05:21:03 +00:00
|
|
|
jr z, .done
|
2014-05-22 22:13:20 +00:00
|
|
|
ld b, a
|
|
|
|
and $f
|
|
|
|
ld c, a
|
|
|
|
ld a, b
|
|
|
|
swap a
|
|
|
|
and $f
|
|
|
|
add $60
|
2015-07-14 05:58:09 +00:00
|
|
|
.writeRunLoop
|
2014-05-22 22:13:20 +00:00
|
|
|
ld [hli], a
|
|
|
|
dec c
|
2015-07-14 02:24:07 +00:00
|
|
|
jr nz, .writeRunLoop
|
2014-05-22 22:13:20 +00:00
|
|
|
inc de
|
2015-07-14 05:21:03 +00:00
|
|
|
jr .nextTile
|
|
|
|
.done
|
2014-05-22 22:13:20 +00:00
|
|
|
call EnableLCD
|
2015-08-12 09:16:56 +00:00
|
|
|
ld b, SET_PAL_TOWN_MAP
|
|
|
|
call RunPaletteCommand
|
2014-05-22 22:13:20 +00:00
|
|
|
call Delay3
|
|
|
|
call GBPalNormal
|
|
|
|
xor a
|
2015-07-13 20:35:35 +00:00
|
|
|
ld [wAnimCounter], a
|
2014-05-22 22:13:20 +00:00
|
|
|
inc a
|
2014-09-14 18:29:18 +00:00
|
|
|
ld [wTownMapSpriteBlinkingEnabled], a
|
2014-05-22 22:13:20 +00:00
|
|
|
ret
|
|
|
|
|
|
|
|
CompressedMap: ; 71100 (1c:5100)
|
|
|
|
; you can decompress this file with the redrle program in the extras/ dir
|
|
|
|
INCBIN "gfx/town_map.rle"
|
|
|
|
|
2015-07-14 05:21:03 +00:00
|
|
|
ExitTownMap: ; 711ab (1c:51ab)
|
2015-07-14 02:24:07 +00:00
|
|
|
; clear town map graphics data and load usual graphics data
|
2014-05-22 22:13:20 +00:00
|
|
|
xor a
|
2014-09-14 18:29:18 +00:00
|
|
|
ld [wTownMapSpriteBlinkingEnabled], a
|
2014-05-22 22:13:20 +00:00
|
|
|
call GBPalWhiteOut
|
|
|
|
call ClearScreen
|
2014-05-23 22:34:35 +00:00
|
|
|
call ClearSprites
|
2014-05-22 22:13:20 +00:00
|
|
|
call LoadPlayerSpriteGraphics
|
|
|
|
call LoadFontTilePatterns
|
|
|
|
call UpdateSprites
|
2015-08-12 09:16:56 +00:00
|
|
|
jp RunDefaultPaletteCommand
|
2014-05-22 22:13:20 +00:00
|
|
|
|
2015-07-14 02:24:07 +00:00
|
|
|
DrawPlayerOrBirdSprite: ; 711c4 (1c:51c4)
|
|
|
|
; a = map number
|
|
|
|
; b = OAM base tile
|
2014-05-22 22:13:20 +00:00
|
|
|
push af
|
|
|
|
ld a, b
|
2015-07-14 02:24:07 +00:00
|
|
|
ld [wOAMBaseTile], a
|
2014-05-22 22:13:20 +00:00
|
|
|
pop af
|
2015-07-14 02:24:07 +00:00
|
|
|
ld de, wTownMapCoords
|
|
|
|
call LoadTownMapEntry
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a, [de]
|
|
|
|
push hl
|
2015-07-14 02:24:07 +00:00
|
|
|
call TownMapCoordsToOAMCoords
|
|
|
|
call WritePlayerOrBirdSpriteOAM
|
2014-05-22 22:13:20 +00:00
|
|
|
pop hl
|
2014-05-26 21:04:56 +00:00
|
|
|
ld de, wcd6d
|
2014-05-22 22:13:20 +00:00
|
|
|
.asm_711dc
|
|
|
|
ld a, [hli]
|
|
|
|
ld [de], a
|
|
|
|
inc de
|
|
|
|
cp $50
|
|
|
|
jr nz, .asm_711dc
|
|
|
|
ld hl, wOAMBuffer
|
|
|
|
ld de, wTileMapBackup
|
|
|
|
ld bc, $a0
|
|
|
|
jp CopyData
|
|
|
|
|
2015-07-14 05:21:03 +00:00
|
|
|
DisplayWildLocations: ; 711ef (1c:51ef)
|
2015-02-08 06:18:42 +00:00
|
|
|
callba FindWildLocationsOfMon
|
2015-07-14 02:24:07 +00:00
|
|
|
call ZeroOutDuplicatesInList
|
2014-05-22 22:13:20 +00:00
|
|
|
ld hl, wOAMBuffer
|
2015-07-14 02:24:07 +00:00
|
|
|
ld de, wTownMapCoords
|
2015-07-14 05:21:03 +00:00
|
|
|
.loop
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a, [de]
|
|
|
|
cp $ff
|
2015-07-14 05:21:03 +00:00
|
|
|
jr z, .exitLoop
|
2014-05-22 22:13:20 +00:00
|
|
|
and a
|
2015-07-14 02:24:07 +00:00
|
|
|
jr z, .nextEntry
|
2014-05-22 22:13:20 +00:00
|
|
|
push hl
|
2015-07-14 02:24:07 +00:00
|
|
|
call LoadTownMapEntry
|
2014-05-22 22:13:20 +00:00
|
|
|
pop hl
|
|
|
|
ld a, [de]
|
2015-07-14 02:24:07 +00:00
|
|
|
cp $19 ; Cerulean Cave's coordinates
|
|
|
|
jr z, .nextEntry ; skip Cerulean Cave
|
|
|
|
call TownMapCoordsToOAMCoords
|
2015-07-14 05:21:03 +00:00
|
|
|
ld a, $4 ; nest icon tile no.
|
2014-05-22 22:13:20 +00:00
|
|
|
ld [hli], a
|
|
|
|
xor a
|
|
|
|
ld [hli], a
|
2015-07-14 02:24:07 +00:00
|
|
|
.nextEntry
|
2014-05-22 22:13:20 +00:00
|
|
|
inc de
|
2015-07-14 05:21:03 +00:00
|
|
|
jr .loop
|
|
|
|
.exitLoop
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a, l
|
2015-07-14 02:24:07 +00:00
|
|
|
and a ; were any OAM entries written?
|
|
|
|
jr nz, .drawPlayerSprite
|
|
|
|
; if no OAM entries were written, print area unknown text
|
2015-07-18 20:52:03 +00:00
|
|
|
coord hl, 1, 7
|
2014-05-22 22:13:20 +00:00
|
|
|
ld b, $2
|
|
|
|
ld c, $f
|
|
|
|
call TextBoxBorder
|
2015-07-18 20:52:03 +00:00
|
|
|
coord hl, 2, 9
|
2014-05-22 22:13:20 +00:00
|
|
|
ld de, AreaUnknownText
|
|
|
|
call PlaceString
|
2015-07-14 05:21:03 +00:00
|
|
|
jr .done
|
2015-07-14 02:24:07 +00:00
|
|
|
.drawPlayerSprite
|
2015-08-31 02:38:41 +00:00
|
|
|
ld a, [wCurMap]
|
2014-05-22 22:13:20 +00:00
|
|
|
ld b, $0
|
2015-07-14 02:24:07 +00:00
|
|
|
call DrawPlayerOrBirdSprite
|
2015-07-14 05:21:03 +00:00
|
|
|
.done
|
2014-05-22 22:13:20 +00:00
|
|
|
ld hl, wOAMBuffer
|
|
|
|
ld de, wTileMapBackup
|
|
|
|
ld bc, $a0
|
|
|
|
jp CopyData
|
|
|
|
|
|
|
|
AreaUnknownText: ; 7124a (1c:524a)
|
|
|
|
db " AREA UNKNOWN@"
|
|
|
|
|
2015-07-14 02:24:07 +00:00
|
|
|
TownMapCoordsToOAMCoords: ; 71258 (1c:5258)
|
|
|
|
; in: lower nybble of a = x, upper nybble of a = y
|
|
|
|
; out: b and [hl] = (y * 8) + 24, c and [hl+1] = (x * 8) + 24
|
2014-05-22 22:13:20 +00:00
|
|
|
push af
|
|
|
|
and $f0
|
|
|
|
srl a
|
2015-07-14 02:24:07 +00:00
|
|
|
add 24
|
2014-05-22 22:13:20 +00:00
|
|
|
ld b, a
|
|
|
|
ld [hli], a
|
|
|
|
pop af
|
|
|
|
and $f
|
|
|
|
swap a
|
|
|
|
srl a
|
2015-07-14 02:24:07 +00:00
|
|
|
add 24
|
2014-05-22 22:13:20 +00:00
|
|
|
ld c, a
|
|
|
|
ld [hli], a
|
|
|
|
ret
|
|
|
|
|
2015-07-14 02:24:07 +00:00
|
|
|
WritePlayerOrBirdSpriteOAM: ; 7126d (1c:526d)
|
|
|
|
ld a, [wOAMBaseTile]
|
2014-05-22 22:13:20 +00:00
|
|
|
and a
|
2015-07-14 02:24:07 +00:00
|
|
|
ld hl, wOAMBuffer + $90 ; for player sprite
|
|
|
|
jr z, WriteTownMapSpriteOAM
|
|
|
|
ld hl, wOAMBuffer + $80 ; for bird sprite
|
2014-05-22 22:13:20 +00:00
|
|
|
|
2015-07-14 02:24:07 +00:00
|
|
|
WriteTownMapSpriteOAM: ; 71279 (1c:5279)
|
2014-05-22 22:13:20 +00:00
|
|
|
push hl
|
2015-08-30 06:21:54 +00:00
|
|
|
|
|
|
|
; Subtract 4 from c (X coord) and 4 from b (Y coord). However, the carry from c
|
|
|
|
; is added to b, so the net result is that only 3 is subtracted from b.
|
2015-08-05 21:20:29 +00:00
|
|
|
lb hl, -4, -4
|
2015-08-30 06:21:54 +00:00
|
|
|
add hl, bc
|
|
|
|
|
2014-05-22 22:13:20 +00:00
|
|
|
ld b, h
|
|
|
|
ld c, l
|
|
|
|
pop hl
|
|
|
|
|
2015-03-13 12:33:16 +00:00
|
|
|
WriteAsymmetricMonPartySpriteOAM: ; 71281 (1c:5281)
|
2015-07-14 02:24:07 +00:00
|
|
|
; Writes 4 OAM blocks for a helix mon party sprite, since it does not have
|
2015-03-13 12:33:16 +00:00
|
|
|
; a vertical line of symmetry.
|
2015-08-05 21:20:29 +00:00
|
|
|
lb de, 2, 2
|
2015-03-13 12:33:16 +00:00
|
|
|
.loop
|
2014-05-22 22:13:20 +00:00
|
|
|
push de
|
|
|
|
push bc
|
2015-03-13 12:33:16 +00:00
|
|
|
.innerLoop
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a, b
|
|
|
|
ld [hli], a
|
|
|
|
ld a, c
|
|
|
|
ld [hli], a
|
2015-07-14 02:24:07 +00:00
|
|
|
ld a, [wOAMBaseTile]
|
2014-05-22 22:13:20 +00:00
|
|
|
ld [hli], a
|
|
|
|
inc a
|
2015-07-14 02:24:07 +00:00
|
|
|
ld [wOAMBaseTile], a
|
2014-05-22 22:13:20 +00:00
|
|
|
xor a
|
|
|
|
ld [hli], a
|
|
|
|
inc d
|
2015-08-30 06:21:54 +00:00
|
|
|
ld a, 8
|
2014-05-22 22:13:20 +00:00
|
|
|
add c
|
|
|
|
ld c, a
|
|
|
|
dec e
|
2015-03-13 12:33:16 +00:00
|
|
|
jr nz, .innerLoop
|
2014-05-22 22:13:20 +00:00
|
|
|
pop bc
|
|
|
|
pop de
|
2015-08-30 06:21:54 +00:00
|
|
|
ld a, 8
|
2014-05-22 22:13:20 +00:00
|
|
|
add b
|
|
|
|
ld b, a
|
|
|
|
dec d
|
2015-03-13 12:33:16 +00:00
|
|
|
jr nz, .loop
|
2014-05-22 22:13:20 +00:00
|
|
|
ret
|
|
|
|
|
2015-03-13 12:33:16 +00:00
|
|
|
WriteSymmetricMonPartySpriteOAM: ; 712a6 (1c:52a6)
|
|
|
|
; Writes 4 OAM blocks for a mon party sprite other than a helix. All the
|
|
|
|
; sprites other than the helix one have a vertical line of symmetry which allows
|
|
|
|
; the X-flip OAM bit to be used so that only 2 rather than 4 tile patterns are
|
|
|
|
; needed.
|
2014-05-22 22:13:20 +00:00
|
|
|
xor a
|
2015-07-25 03:27:59 +00:00
|
|
|
ld [wSymmetricSpriteOAMAttributes], a
|
|
|
|
lb de, 2, 2
|
2015-03-13 12:33:16 +00:00
|
|
|
.loop
|
2014-05-22 22:13:20 +00:00
|
|
|
push de
|
|
|
|
push bc
|
2015-03-13 12:33:16 +00:00
|
|
|
.innerLoop
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a, b
|
2015-07-25 03:27:59 +00:00
|
|
|
ld [hli], a ; Y
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a, c
|
2015-07-25 03:27:59 +00:00
|
|
|
ld [hli], a ; X
|
2015-07-14 02:24:07 +00:00
|
|
|
ld a, [wOAMBaseTile]
|
2015-07-25 03:27:59 +00:00
|
|
|
ld [hli], a ; tile
|
|
|
|
ld a, [wSymmetricSpriteOAMAttributes]
|
|
|
|
ld [hli], a ; attributes
|
|
|
|
xor (1 << OAM_X_FLIP)
|
|
|
|
ld [wSymmetricSpriteOAMAttributes], a
|
2014-05-22 22:13:20 +00:00
|
|
|
inc d
|
2015-07-25 03:27:59 +00:00
|
|
|
ld a, 8
|
2014-05-22 22:13:20 +00:00
|
|
|
add c
|
|
|
|
ld c, a
|
|
|
|
dec e
|
2015-03-13 12:33:16 +00:00
|
|
|
jr nz, .innerLoop
|
2014-05-22 22:13:20 +00:00
|
|
|
pop bc
|
|
|
|
pop de
|
|
|
|
push hl
|
2015-07-14 02:24:07 +00:00
|
|
|
ld hl, wOAMBaseTile
|
2014-05-22 22:13:20 +00:00
|
|
|
inc [hl]
|
|
|
|
inc [hl]
|
|
|
|
pop hl
|
2015-07-25 03:27:59 +00:00
|
|
|
ld a, 8
|
2014-05-22 22:13:20 +00:00
|
|
|
add b
|
|
|
|
ld b, a
|
|
|
|
dec d
|
2015-03-13 12:33:16 +00:00
|
|
|
jr nz, .loop
|
2014-05-22 22:13:20 +00:00
|
|
|
ret
|
|
|
|
|
2015-07-14 02:24:07 +00:00
|
|
|
ZeroOutDuplicatesInList: ; 712d9 (1c:52d9)
|
|
|
|
; replace duplicate bytes in the list of wild pokemon locations with 0
|
|
|
|
ld de, wBuffer
|
|
|
|
.loop
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a, [de]
|
|
|
|
inc de
|
|
|
|
cp $ff
|
|
|
|
ret z
|
|
|
|
ld c, a
|
|
|
|
ld l, e
|
|
|
|
ld h, d
|
2015-07-14 02:24:07 +00:00
|
|
|
.zeroDuplicatesLoop
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a, [hl]
|
|
|
|
cp $ff
|
2015-07-14 02:24:07 +00:00
|
|
|
jr z, .loop
|
2014-05-22 22:13:20 +00:00
|
|
|
cp c
|
2015-07-14 02:24:07 +00:00
|
|
|
jr nz, .skipZeroing
|
2014-05-22 22:13:20 +00:00
|
|
|
xor a
|
|
|
|
ld [hl], a
|
2015-07-14 02:24:07 +00:00
|
|
|
.skipZeroing
|
2014-05-22 22:13:20 +00:00
|
|
|
inc hl
|
2015-07-14 02:24:07 +00:00
|
|
|
jr .zeroDuplicatesLoop
|
2014-05-22 22:13:20 +00:00
|
|
|
|
2015-07-14 02:24:07 +00:00
|
|
|
LoadTownMapEntry: ; 712f1 (1c:52f1)
|
|
|
|
; in: a = map number
|
|
|
|
; out: lower nybble of [de] = x, upper nybble of [de] = y, hl = address of name
|
2014-05-22 22:13:20 +00:00
|
|
|
cp REDS_HOUSE_1F
|
2015-07-14 02:24:07 +00:00
|
|
|
jr c, .external
|
|
|
|
ld bc, 4
|
2015-07-03 19:37:53 +00:00
|
|
|
ld hl, InternalMapEntries
|
2015-07-14 05:21:03 +00:00
|
|
|
.loop
|
2014-05-22 22:13:20 +00:00
|
|
|
cp [hl]
|
2015-07-14 02:24:07 +00:00
|
|
|
jr c, .foundEntry
|
2014-05-22 22:13:20 +00:00
|
|
|
add hl, bc
|
2015-07-14 05:21:03 +00:00
|
|
|
jr .loop
|
2015-07-14 02:24:07 +00:00
|
|
|
.foundEntry
|
2014-05-22 22:13:20 +00:00
|
|
|
inc hl
|
2015-07-14 02:24:07 +00:00
|
|
|
jr .readEntry
|
|
|
|
.external
|
2015-07-03 19:37:53 +00:00
|
|
|
ld hl, ExternalMapEntries
|
2014-05-22 22:13:20 +00:00
|
|
|
ld c, a
|
2015-07-14 02:24:07 +00:00
|
|
|
ld b, 0
|
2014-05-22 22:13:20 +00:00
|
|
|
add hl, bc
|
|
|
|
add hl, bc
|
|
|
|
add hl, bc
|
2015-07-14 02:24:07 +00:00
|
|
|
.readEntry
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a, [hli]
|
|
|
|
ld [de], a
|
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
|
|
|
ret
|
|
|
|
|
|
|
|
INCLUDE "data/town_map_entries.asm"
|
|
|
|
|
|
|
|
INCLUDE "text/map_names.asm"
|
|
|
|
|
|
|
|
MonNestIcon: ; 716be (1c:56be)
|
|
|
|
INCBIN "gfx/mon_nest_icon.1bpp"
|
2015-08-10 04:56:20 +00:00
|
|
|
MonNestIconEnd:
|
2014-05-22 22:13:20 +00:00
|
|
|
|
2014-09-14 18:29:18 +00:00
|
|
|
TownMapSpriteBlinkingAnimation: ; 716c6 (1c:56c6)
|
2015-07-13 20:35:35 +00:00
|
|
|
ld a, [wAnimCounter]
|
2014-05-22 22:13:20 +00:00
|
|
|
inc a
|
2014-09-14 18:29:18 +00:00
|
|
|
cp 25
|
|
|
|
jr z, .hideSprites
|
|
|
|
cp 50
|
|
|
|
jr nz, .done
|
|
|
|
; show sprites when the counter reaches 50
|
2014-05-22 22:13:20 +00:00
|
|
|
ld hl, wTileMapBackup
|
|
|
|
ld de, wOAMBuffer
|
|
|
|
ld bc, $90
|
|
|
|
call CopyData
|
|
|
|
xor a
|
2014-09-14 18:29:18 +00:00
|
|
|
jr .done
|
|
|
|
.hideSprites
|
2014-05-22 22:13:20 +00:00
|
|
|
ld hl, wOAMBuffer
|
|
|
|
ld b, $24
|
|
|
|
ld de, $4
|
2014-09-14 18:29:18 +00:00
|
|
|
.hideSpritesLoop
|
2014-05-22 22:13:20 +00:00
|
|
|
ld [hl], $a0
|
|
|
|
add hl, de
|
|
|
|
dec b
|
2014-09-14 18:29:18 +00:00
|
|
|
jr nz, .hideSpritesLoop
|
|
|
|
ld a, 25
|
|
|
|
.done
|
2015-07-13 20:35:35 +00:00
|
|
|
ld [wAnimCounter], a
|
2014-05-22 22:13:20 +00:00
|
|
|
jp DelayFrame
|