2013-09-07 21:14:26 -07:00
|
|
|
; Functions dealing with rendering and interacting with maps.
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
CheckScenes::
|
2018-09-09 12:09:51 -07:00
|
|
|
; Checks wCurMapSceneScriptPointer. If it's empty, returns -1 in a. Otherwise, returns the active scene ID in a.
|
2013-09-07 21:14:26 -07:00
|
|
|
push hl
|
2018-09-09 12:09:51 -07:00
|
|
|
ld hl, wCurMapSceneScriptPointer
|
2013-09-07 21:14:26 -07:00
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
|
|
|
or h
|
|
|
|
ld a, [hl]
|
2017-12-24 10:46:34 -08:00
|
|
|
jr nz, .scene_exists
|
2015-07-15 12:48:44 -07:00
|
|
|
ld a, -1
|
2013-09-07 21:14:26 -07:00
|
|
|
|
2017-12-24 10:46:34 -08:00
|
|
|
.scene_exists
|
2013-09-07 21:14:26 -07:00
|
|
|
pop hl
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
GetCurrentMapSceneID::
|
2018-09-09 12:09:51 -07:00
|
|
|
; Grabs the wram map scene script pointer for the current map and loads it into wCurMapSceneScriptPointer.
|
|
|
|
; If there is no scene, both bytes of wCurMapSceneScriptPointer are wiped clean.
|
2017-12-24 10:46:34 -08:00
|
|
|
; Copy the current map group and number into bc. This is needed for GetMapSceneID.
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wMapGroup]
|
2013-09-07 21:14:26 -07:00
|
|
|
ld b, a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wMapNumber]
|
2013-09-07 21:14:26 -07:00
|
|
|
ld c, a
|
2018-09-09 12:09:51 -07:00
|
|
|
; Blank out wCurMapSceneScriptPointer; this is the default scenario.
|
2013-09-07 21:14:26 -07:00
|
|
|
xor a
|
2018-09-09 12:09:51 -07:00
|
|
|
ld [wCurMapSceneScriptPointer], a
|
|
|
|
ld [wCurMapSceneScriptPointer + 1], a
|
2017-12-24 10:46:34 -08:00
|
|
|
call GetMapSceneID
|
|
|
|
ret c ; The map is not in the scene script table
|
2018-09-09 12:09:51 -07:00
|
|
|
; Load the scene script pointer from de into wCurMapSceneScriptPointer
|
2013-09-07 21:14:26 -07:00
|
|
|
ld a, e
|
2018-09-09 12:09:51 -07:00
|
|
|
ld [wCurMapSceneScriptPointer], a
|
2013-09-07 21:14:26 -07:00
|
|
|
ld a, d
|
2018-09-09 12:09:51 -07:00
|
|
|
ld [wCurMapSceneScriptPointer + 1], a
|
2013-09-07 21:14:26 -07:00
|
|
|
xor a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
GetMapSceneID::
|
2019-03-03 11:19:16 -08:00
|
|
|
; Searches the scene_var table for the map group and number loaded in bc, and returns the wram pointer in de.
|
|
|
|
; If the map is not in the scene_var table, returns carry.
|
2013-09-07 21:14:26 -07:00
|
|
|
push bc
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hROMBank]
|
2013-09-07 21:14:26 -07:00
|
|
|
push af
|
2017-12-24 10:46:34 -08:00
|
|
|
ld a, BANK(MapScenes)
|
2013-09-07 21:14:26 -07:00
|
|
|
rst Bankswitch
|
|
|
|
|
2017-12-24 10:46:34 -08:00
|
|
|
ld hl, MapScenes
|
2015-07-16 15:10:10 -07:00
|
|
|
.loop
|
2013-09-07 21:14:26 -07:00
|
|
|
push hl
|
2015-07-16 15:10:10 -07:00
|
|
|
ld a, [hli] ; map group, or terminator
|
|
|
|
cp -1
|
2019-03-03 11:19:16 -08:00
|
|
|
jr z, .end ; the current map is not in the scene_var table
|
2013-09-07 21:14:26 -07:00
|
|
|
cp b
|
2015-07-16 15:10:10 -07:00
|
|
|
jr nz, .next ; map group did not match
|
|
|
|
ld a, [hli] ; map number
|
2013-09-07 21:14:26 -07:00
|
|
|
cp c
|
2015-07-16 15:10:10 -07:00
|
|
|
jr nz, .next ; map number did not match
|
|
|
|
jr .found ; we found our map
|
2013-09-07 21:14:26 -07:00
|
|
|
|
2015-07-16 15:10:10 -07:00
|
|
|
.next
|
2013-09-07 21:14:26 -07:00
|
|
|
pop hl
|
2019-03-03 11:19:16 -08:00
|
|
|
ld de, 4 ; scene_var size
|
2013-09-07 21:14:26 -07:00
|
|
|
add hl, de
|
2015-07-16 15:10:10 -07:00
|
|
|
jr .loop
|
2013-09-07 21:14:26 -07:00
|
|
|
|
2015-07-16 15:10:10 -07:00
|
|
|
.end
|
2013-09-07 21:14:26 -07:00
|
|
|
scf
|
2015-07-16 15:10:10 -07:00
|
|
|
jr .done
|
2013-09-07 21:14:26 -07:00
|
|
|
|
2015-07-16 15:10:10 -07:00
|
|
|
.found
|
2013-09-07 21:14:26 -07:00
|
|
|
ld e, [hl]
|
|
|
|
inc hl
|
|
|
|
ld d, [hl]
|
|
|
|
|
2015-07-16 15:10:10 -07:00
|
|
|
.done
|
2013-09-07 21:14:26 -07:00
|
|
|
pop hl
|
|
|
|
pop bc
|
|
|
|
ld a, b
|
|
|
|
rst Bankswitch
|
|
|
|
|
|
|
|
pop bc
|
|
|
|
ret
|
|
|
|
|
2023-08-28 04:30:13 -07:00
|
|
|
LoadScreenTilemapAndAttrmapPals::
|
|
|
|
call LoadScreenTilemap
|
|
|
|
call LoadScreenAttrmapPals
|
2013-09-07 21:14:26 -07:00
|
|
|
ret
|
|
|
|
|
2023-08-28 04:30:13 -07:00
|
|
|
LoadScreenTilemap::
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hROMBank]
|
2013-09-07 21:14:26 -07:00
|
|
|
push af
|
2013-12-11 18:42:56 -08:00
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wTilesetBlocksBank]
|
2013-09-07 21:14:26 -07:00
|
|
|
rst Bankswitch
|
2015-11-05 11:06:03 -08:00
|
|
|
call LoadMetatiles
|
2019-01-24 18:10:45 -08:00
|
|
|
|
2018-03-19 08:36:14 -07:00
|
|
|
ld a, "■"
|
2015-07-22 12:57:02 -07:00
|
|
|
hlcoord 0, 0
|
2015-11-02 09:54:27 -08:00
|
|
|
ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
|
2013-09-07 21:14:26 -07:00
|
|
|
call ByteFill
|
2013-12-11 18:42:56 -08:00
|
|
|
|
2023-08-28 04:30:13 -07:00
|
|
|
ld a, BANK(_LoadScreenTilemap)
|
2013-09-07 21:14:26 -07:00
|
|
|
rst Bankswitch
|
2023-08-28 04:30:13 -07:00
|
|
|
call _LoadScreenTilemap
|
2013-12-11 18:42:56 -08:00
|
|
|
|
2013-09-07 21:14:26 -07:00
|
|
|
pop af
|
|
|
|
rst Bankswitch
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
LoadMetatiles::
|
2015-12-14 08:12:18 -08:00
|
|
|
; de <- wOverworldMapAnchor
|
2015-12-13 17:33:56 -08:00
|
|
|
ld a, [wOverworldMapAnchor]
|
2013-09-07 21:14:26 -07:00
|
|
|
ld e, a
|
2015-12-13 17:33:56 -08:00
|
|
|
ld a, [wOverworldMapAnchor + 1]
|
2013-09-07 21:14:26 -07:00
|
|
|
ld d, a
|
2018-03-19 08:36:14 -07:00
|
|
|
ld hl, wSurroundingTiles
|
2020-10-29 20:23:57 -07:00
|
|
|
ld b, SCREEN_META_HEIGHT
|
2013-09-07 21:14:26 -07:00
|
|
|
|
2015-12-14 08:12:18 -08:00
|
|
|
.row
|
2013-09-07 21:14:26 -07:00
|
|
|
push de
|
|
|
|
push hl
|
2020-10-29 20:23:57 -07:00
|
|
|
ld c, SCREEN_META_WIDTH
|
2013-09-07 21:14:26 -07:00
|
|
|
|
2015-12-14 08:12:18 -08:00
|
|
|
.col
|
2013-09-07 21:14:26 -07:00
|
|
|
push de
|
|
|
|
push hl
|
2015-12-14 08:12:18 -08:00
|
|
|
; Load the current map block.
|
|
|
|
; If the current map block is a border block, load the border block.
|
2013-09-07 21:14:26 -07:00
|
|
|
ld a, [de]
|
|
|
|
and a
|
2015-11-05 11:06:03 -08:00
|
|
|
jr nz, .ok
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wMapBorderBlock]
|
2013-09-07 21:14:26 -07:00
|
|
|
|
2015-11-05 11:06:03 -08:00
|
|
|
.ok
|
2018-03-19 08:36:14 -07:00
|
|
|
; Load the current wSurroundingTiles address into de.
|
2013-09-07 21:14:26 -07:00
|
|
|
ld e, l
|
|
|
|
ld d, h
|
2018-01-23 14:39:09 -08:00
|
|
|
; Set hl to the address of the current metatile data ([wTilesetBlocksAddress] + (a) tiles).
|
2013-09-07 21:14:26 -07:00
|
|
|
ld l, a
|
2014-12-26 20:37:18 -08:00
|
|
|
ld h, 0
|
2015-12-14 08:12:18 -08:00
|
|
|
add hl, hl
|
2016-05-10 09:31:49 -07:00
|
|
|
add hl, hl
|
|
|
|
add hl, hl
|
2023-07-24 05:05:48 -07:00
|
|
|
add hl, hl
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wTilesetBlocksAddress]
|
2013-09-07 21:14:26 -07:00
|
|
|
add l
|
|
|
|
ld l, a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wTilesetBlocksAddress + 1]
|
2013-09-07 21:14:26 -07:00
|
|
|
adc h
|
|
|
|
ld h, a
|
|
|
|
|
2015-12-14 08:12:18 -08:00
|
|
|
; copy the 4x4 metatile
|
2020-03-21 11:01:05 -07:00
|
|
|
rept METATILE_WIDTH - 1
|
2018-03-19 08:36:14 -07:00
|
|
|
rept METATILE_WIDTH
|
2013-09-07 21:14:26 -07:00
|
|
|
ld a, [hli]
|
|
|
|
ld [de], a
|
|
|
|
inc de
|
2014-12-26 20:37:18 -08:00
|
|
|
endr
|
2013-09-07 21:14:26 -07:00
|
|
|
ld a, e
|
2018-03-19 08:36:14 -07:00
|
|
|
add SURROUNDING_WIDTH - METATILE_WIDTH
|
2013-09-07 21:14:26 -07:00
|
|
|
ld e, a
|
|
|
|
jr nc, .next\@
|
|
|
|
inc d
|
|
|
|
.next\@
|
|
|
|
endr
|
2018-03-19 08:36:14 -07:00
|
|
|
rept METATILE_WIDTH
|
2013-09-07 21:14:26 -07:00
|
|
|
ld a, [hli]
|
|
|
|
ld [de], a
|
|
|
|
inc de
|
2014-12-26 20:37:18 -08:00
|
|
|
endr
|
2015-12-14 08:12:18 -08:00
|
|
|
; Next metatile
|
2013-09-07 21:14:26 -07:00
|
|
|
pop hl
|
2018-03-19 08:36:14 -07:00
|
|
|
ld de, METATILE_WIDTH
|
2013-09-07 21:14:26 -07:00
|
|
|
add hl, de
|
|
|
|
pop de
|
|
|
|
inc de
|
|
|
|
dec c
|
2015-12-14 08:12:18 -08:00
|
|
|
jp nz, .col
|
|
|
|
; Next metarow
|
2013-09-07 21:14:26 -07:00
|
|
|
pop hl
|
2018-03-19 08:36:14 -07:00
|
|
|
ld de, SURROUNDING_WIDTH * METATILE_WIDTH
|
2013-09-07 21:14:26 -07:00
|
|
|
add hl, de
|
|
|
|
pop de
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wMapWidth]
|
2020-10-29 20:23:57 -07:00
|
|
|
add MAP_CONNECTION_PADDING_WIDTH * 2
|
2013-09-07 21:14:26 -07:00
|
|
|
add e
|
|
|
|
ld e, a
|
2015-11-05 11:06:03 -08:00
|
|
|
jr nc, .ok2
|
2013-09-07 21:14:26 -07:00
|
|
|
inc d
|
2015-11-05 11:06:03 -08:00
|
|
|
.ok2
|
2013-09-07 21:14:26 -07:00
|
|
|
dec b
|
2015-12-14 08:12:18 -08:00
|
|
|
jp nz, .row
|
2013-09-07 21:14:26 -07:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
ReturnToMapFromSubmenu::
|
2015-11-11 20:38:57 -08:00
|
|
|
ld a, MAPSETUP_SUBMENU
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hMapEntryMethod], a
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall RunMapSetupScript
|
2013-09-07 21:14:26 -07:00
|
|
|
xor a
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hMapEntryMethod], a
|
2013-09-07 21:14:26 -07:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
CheckWarpTile::
|
2015-11-12 08:10:19 -08:00
|
|
|
call GetDestinationWarpNumber
|
2013-09-07 21:14:26 -07:00
|
|
|
ret nc
|
2015-11-12 08:10:19 -08:00
|
|
|
|
2013-09-07 21:14:26 -07:00
|
|
|
push bc
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall CheckDirectionalWarp
|
2013-09-07 21:14:26 -07:00
|
|
|
pop bc
|
|
|
|
ret nc
|
2015-11-12 08:10:19 -08:00
|
|
|
|
|
|
|
call CopyWarpData
|
2013-09-07 21:14:26 -07:00
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
WarpCheck::
|
2015-11-12 08:10:19 -08:00
|
|
|
call GetDestinationWarpNumber
|
2013-09-07 21:14:26 -07:00
|
|
|
ret nc
|
2015-11-12 08:10:19 -08:00
|
|
|
call CopyWarpData
|
2013-09-07 21:14:26 -07:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
GetDestinationWarpNumber::
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall CheckWarpCollision
|
2013-09-07 21:14:26 -07:00
|
|
|
ret nc
|
|
|
|
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hROMBank]
|
2013-09-07 21:14:26 -07:00
|
|
|
push af
|
|
|
|
|
2018-01-16 19:57:19 -08:00
|
|
|
call SwitchToMapScriptsBank
|
2015-11-12 08:10:19 -08:00
|
|
|
call .GetDestinationWarpNumber
|
2013-09-07 21:14:26 -07:00
|
|
|
|
|
|
|
pop de
|
|
|
|
ld a, d
|
|
|
|
rst Bankswitch
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
.GetDestinationWarpNumber:
|
2022-09-12 06:15:44 -07:00
|
|
|
ld a, [wPlayerMapY]
|
2018-03-19 08:36:14 -07:00
|
|
|
sub 4
|
2013-09-07 21:14:26 -07:00
|
|
|
ld e, a
|
2022-09-12 06:15:44 -07:00
|
|
|
ld a, [wPlayerMapX]
|
2018-03-19 08:36:14 -07:00
|
|
|
sub 4
|
2013-09-07 21:14:26 -07:00
|
|
|
ld d, a
|
2018-09-09 12:09:51 -07:00
|
|
|
ld a, [wCurMapWarpCount]
|
2013-09-07 21:14:26 -07:00
|
|
|
and a
|
|
|
|
ret z
|
2015-11-12 08:10:19 -08:00
|
|
|
|
2013-09-07 21:14:26 -07:00
|
|
|
ld c, a
|
2018-09-09 12:09:51 -07:00
|
|
|
ld hl, wCurMapWarpsPointer
|
2013-09-07 21:14:26 -07:00
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
2015-11-12 08:10:19 -08:00
|
|
|
.loop
|
2013-09-07 21:14:26 -07:00
|
|
|
push hl
|
|
|
|
ld a, [hli]
|
|
|
|
cp e
|
2015-11-12 08:10:19 -08:00
|
|
|
jr nz, .next
|
2013-09-07 21:14:26 -07:00
|
|
|
ld a, [hli]
|
|
|
|
cp d
|
2015-11-12 08:10:19 -08:00
|
|
|
jr nz, .next
|
|
|
|
jr .found_warp
|
2013-09-07 21:14:26 -07:00
|
|
|
|
2015-11-12 08:10:19 -08:00
|
|
|
.next
|
2013-09-07 21:14:26 -07:00
|
|
|
pop hl
|
2019-03-03 11:19:16 -08:00
|
|
|
ld a, WARP_EVENT_SIZE
|
2013-09-07 21:14:26 -07:00
|
|
|
add l
|
|
|
|
ld l, a
|
2015-11-12 08:10:19 -08:00
|
|
|
jr nc, .okay
|
2013-09-07 21:14:26 -07:00
|
|
|
inc h
|
|
|
|
|
2015-11-12 08:10:19 -08:00
|
|
|
.okay
|
2013-09-07 21:14:26 -07:00
|
|
|
dec c
|
2015-11-12 08:10:19 -08:00
|
|
|
jr nz, .loop
|
2013-09-07 21:14:26 -07:00
|
|
|
xor a
|
|
|
|
ret
|
|
|
|
|
2015-11-12 08:10:19 -08:00
|
|
|
.found_warp
|
2013-09-07 21:14:26 -07:00
|
|
|
pop hl
|
2015-11-12 08:10:19 -08:00
|
|
|
call .IncreaseHLTwice
|
|
|
|
ret nc ; never encountered
|
|
|
|
|
2018-09-09 12:09:51 -07:00
|
|
|
ld a, [wCurMapWarpCount]
|
2013-09-07 21:14:26 -07:00
|
|
|
inc a
|
|
|
|
sub c
|
|
|
|
ld c, a
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.IncreaseHLTwice:
|
2013-09-07 21:14:26 -07:00
|
|
|
inc hl
|
2016-01-06 04:44:50 -08:00
|
|
|
inc hl
|
2013-09-07 21:14:26 -07:00
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
CopyWarpData::
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hROMBank]
|
2013-09-07 21:14:26 -07:00
|
|
|
push af
|
|
|
|
|
2018-01-16 19:57:19 -08:00
|
|
|
call SwitchToMapScriptsBank
|
2015-11-12 08:10:19 -08:00
|
|
|
call .CopyWarpData
|
2013-09-07 21:14:26 -07:00
|
|
|
|
|
|
|
pop af
|
|
|
|
rst Bankswitch
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
.CopyWarpData:
|
2013-09-07 21:14:26 -07:00
|
|
|
push bc
|
2018-09-09 12:09:51 -07:00
|
|
|
ld hl, wCurMapWarpsPointer
|
2013-09-07 21:14:26 -07:00
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
|
|
|
ld a, c
|
|
|
|
dec a
|
2019-03-03 11:19:16 -08:00
|
|
|
ld bc, WARP_EVENT_SIZE
|
2013-09-07 21:14:26 -07:00
|
|
|
call AddNTimes
|
2019-03-03 11:19:16 -08:00
|
|
|
ld bc, 2 ; warp number
|
2013-09-07 21:14:26 -07:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hli]
|
2019-09-23 06:09:49 -07:00
|
|
|
cp -1
|
2015-11-12 08:10:19 -08:00
|
|
|
jr nz, .skip
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wBackupWarpNumber
|
2013-09-07 21:14:26 -07:00
|
|
|
ld a, [hli]
|
|
|
|
|
2015-11-12 08:10:19 -08:00
|
|
|
.skip
|
2013-09-07 21:14:26 -07:00
|
|
|
pop bc
|
2015-11-12 08:10:19 -08:00
|
|
|
ld [wNextWarp], a
|
2013-09-07 21:14:26 -07:00
|
|
|
ld a, [hli]
|
2015-11-12 08:10:19 -08:00
|
|
|
ld [wNextMapGroup], a
|
2013-09-07 21:14:26 -07:00
|
|
|
ld a, [hli]
|
2015-11-12 08:10:19 -08:00
|
|
|
ld [wNextMapNumber], a
|
|
|
|
|
2013-09-07 21:14:26 -07:00
|
|
|
ld a, c
|
2015-11-12 08:10:19 -08:00
|
|
|
ld [wPrevWarp], a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wMapGroup]
|
2015-11-12 08:10:19 -08:00
|
|
|
ld [wPrevMapGroup], a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wMapNumber]
|
2015-11-12 08:10:19 -08:00
|
|
|
ld [wPrevMapNumber], a
|
2013-09-07 21:14:26 -07:00
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
CheckOutdoorMap::
|
2023-08-04 09:45:50 -07:00
|
|
|
cp INDOOR_ENVIRONMENT
|
|
|
|
jr c, .outdoor
|
|
|
|
ret ; nz
|
|
|
|
.outdoor
|
|
|
|
xor a
|
|
|
|
ret ; z
|
2013-09-07 21:14:26 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
CheckIndoorMap::
|
2023-08-04 09:45:50 -07:00
|
|
|
cp INDOOR_ENVIRONMENT
|
|
|
|
jr nc, .indoor
|
|
|
|
ret ; nz
|
|
|
|
.indoor
|
|
|
|
xor a
|
|
|
|
ret ; z
|
2013-09-07 21:14:26 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
LoadMapAttributes::
|
2018-02-03 13:58:49 -08:00
|
|
|
call CopyMapPartialAndAttributes
|
2018-01-16 19:57:19 -08:00
|
|
|
call SwitchToMapScriptsBank
|
2015-11-12 08:10:19 -08:00
|
|
|
call ReadMapScripts
|
2019-11-18 09:16:50 -08:00
|
|
|
xor a ; do not skip object events
|
2018-01-16 19:57:19 -08:00
|
|
|
call ReadMapEvents
|
2013-09-07 21:14:26 -07:00
|
|
|
ret
|
|
|
|
|
2019-11-18 09:16:50 -08:00
|
|
|
LoadMapAttributes_SkipObjects::
|
2018-02-03 13:58:49 -08:00
|
|
|
call CopyMapPartialAndAttributes
|
2018-01-16 19:57:19 -08:00
|
|
|
call SwitchToMapScriptsBank
|
2015-11-12 08:10:19 -08:00
|
|
|
call ReadMapScripts
|
2018-01-16 19:57:19 -08:00
|
|
|
ld a, TRUE ; skip object events
|
|
|
|
call ReadMapEvents
|
2013-09-07 21:14:26 -07:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
CopyMapPartialAndAttributes::
|
2018-02-03 13:58:49 -08:00
|
|
|
call CopyMapPartial
|
|
|
|
call SwitchToMapAttributesBank
|
|
|
|
call GetMapAttributesPointer
|
|
|
|
call CopyMapAttributes
|
2015-11-12 08:10:19 -08:00
|
|
|
call GetMapConnections
|
2013-09-07 21:14:26 -07:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
ReadMapEvents::
|
2013-09-07 21:14:26 -07:00
|
|
|
push af
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wMapEventsPointer
|
2013-09-07 21:14:26 -07:00
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
|
|
|
inc hl
|
2016-01-06 04:44:50 -08:00
|
|
|
inc hl
|
2015-07-26 00:11:33 -07:00
|
|
|
call ReadWarps
|
|
|
|
call ReadCoordEvents
|
2017-12-24 10:46:34 -08:00
|
|
|
call ReadBGEvents
|
2015-11-12 08:10:19 -08:00
|
|
|
|
2013-09-07 21:14:26 -07:00
|
|
|
pop af
|
2018-01-16 19:57:19 -08:00
|
|
|
and a ; skip object events?
|
2013-09-07 21:14:26 -07:00
|
|
|
ret nz
|
2015-11-12 08:10:19 -08:00
|
|
|
|
2015-07-26 00:11:33 -07:00
|
|
|
call ReadObjectEvents
|
2013-09-07 21:14:26 -07:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
ReadMapScripts::
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wMapScriptsPointer
|
2013-09-07 21:14:26 -07:00
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
2017-12-24 10:46:34 -08:00
|
|
|
call ReadMapSceneScripts
|
2015-10-24 16:49:19 -07:00
|
|
|
call ReadMapCallbacks
|
2013-09-07 21:14:26 -07:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
CopyMapAttributes::
|
2018-02-03 13:58:49 -08:00
|
|
|
ld de, wMapAttributes
|
|
|
|
ld c, wMapAttributesEnd - wMapAttributes
|
2015-11-12 08:10:19 -08:00
|
|
|
.loop
|
2013-09-07 21:14:26 -07:00
|
|
|
ld a, [hli]
|
|
|
|
ld [de], a
|
|
|
|
inc de
|
|
|
|
dec c
|
2015-11-12 08:10:19 -08:00
|
|
|
jr nz, .loop
|
2013-09-07 21:14:26 -07:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
GetMapConnections::
|
2013-09-07 21:14:26 -07:00
|
|
|
ld a, $ff
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wNorthConnectedMapGroup], a
|
|
|
|
ld [wSouthConnectedMapGroup], a
|
|
|
|
ld [wWestConnectedMapGroup], a
|
|
|
|
ld [wEastConnectedMapGroup], a
|
2013-09-07 21:14:26 -07:00
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wMapConnections]
|
2013-09-07 21:14:26 -07:00
|
|
|
ld b, a
|
|
|
|
|
2015-11-12 08:10:19 -08:00
|
|
|
bit NORTH_F, b
|
|
|
|
jr z, .no_north
|
2018-01-23 14:39:09 -08:00
|
|
|
ld de, wNorthMapConnection
|
2013-09-07 21:14:26 -07:00
|
|
|
call GetMapConnection
|
2015-11-12 08:10:19 -08:00
|
|
|
.no_north
|
2013-12-11 18:42:56 -08:00
|
|
|
|
2015-11-12 08:10:19 -08:00
|
|
|
bit SOUTH_F, b
|
|
|
|
jr z, .no_south
|
2018-01-23 14:39:09 -08:00
|
|
|
ld de, wSouthMapConnection
|
2013-09-07 21:14:26 -07:00
|
|
|
call GetMapConnection
|
2015-11-12 08:10:19 -08:00
|
|
|
.no_south
|
2013-12-11 18:42:56 -08:00
|
|
|
|
2015-11-12 08:10:19 -08:00
|
|
|
bit WEST_F, b
|
|
|
|
jr z, .no_west
|
2018-01-23 14:39:09 -08:00
|
|
|
ld de, wWestMapConnection
|
2013-09-07 21:14:26 -07:00
|
|
|
call GetMapConnection
|
2015-11-12 08:10:19 -08:00
|
|
|
.no_west
|
2013-12-11 18:42:56 -08:00
|
|
|
|
2015-11-12 08:10:19 -08:00
|
|
|
bit EAST_F, b
|
|
|
|
jr z, .no_east
|
2018-01-23 14:39:09 -08:00
|
|
|
ld de, wEastMapConnection
|
2013-09-07 21:14:26 -07:00
|
|
|
call GetMapConnection
|
2015-11-12 08:10:19 -08:00
|
|
|
.no_east
|
2013-12-11 18:42:56 -08:00
|
|
|
|
2013-09-07 21:14:26 -07:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
GetMapConnection::
|
2013-09-07 21:14:26 -07:00
|
|
|
; Load map connection struct at hl into de.
|
2018-01-23 14:39:09 -08:00
|
|
|
ld c, wSouthMapConnection - wNorthMapConnection
|
2013-09-07 21:14:26 -07:00
|
|
|
.loop
|
|
|
|
ld a, [hli]
|
|
|
|
ld [de], a
|
|
|
|
inc de
|
|
|
|
dec c
|
|
|
|
jr nz, .loop
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
ReadMapSceneScripts::
|
2019-03-03 11:19:16 -08:00
|
|
|
ld a, [hli] ; scene_script count
|
2013-09-07 21:14:26 -07:00
|
|
|
ld c, a
|
2018-09-09 12:15:33 -07:00
|
|
|
ld [wCurMapSceneScriptCount], a
|
2013-09-07 21:14:26 -07:00
|
|
|
ld a, l
|
2018-09-09 12:15:33 -07:00
|
|
|
ld [wCurMapSceneScriptsPointer], a
|
2013-09-07 21:14:26 -07:00
|
|
|
ld a, h
|
2018-09-09 12:09:51 -07:00
|
|
|
ld [wCurMapSceneScriptsPointer + 1], a
|
2013-09-07 21:14:26 -07:00
|
|
|
ld a, c
|
|
|
|
and a
|
|
|
|
ret z
|
2015-10-24 07:34:19 -07:00
|
|
|
|
2019-03-03 11:19:16 -08:00
|
|
|
ld bc, SCENE_SCRIPT_SIZE
|
2013-09-07 21:14:26 -07:00
|
|
|
call AddNTimes
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
ReadMapCallbacks::
|
2013-09-07 21:14:26 -07:00
|
|
|
ld a, [hli]
|
|
|
|
ld c, a
|
2018-09-09 12:09:51 -07:00
|
|
|
ld [wCurMapCallbackCount], a
|
2013-09-07 21:14:26 -07:00
|
|
|
ld a, l
|
2018-09-09 12:09:51 -07:00
|
|
|
ld [wCurMapCallbacksPointer], a
|
2013-09-07 21:14:26 -07:00
|
|
|
ld a, h
|
2018-09-09 12:09:51 -07:00
|
|
|
ld [wCurMapCallbacksPointer + 1], a
|
2013-09-07 21:14:26 -07:00
|
|
|
ld a, c
|
|
|
|
and a
|
|
|
|
ret z
|
2015-10-24 07:34:19 -07:00
|
|
|
|
2019-03-03 11:19:16 -08:00
|
|
|
ld bc, CALLBACK_SIZE
|
2013-09-07 21:14:26 -07:00
|
|
|
call AddNTimes
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
ReadWarps::
|
2013-09-07 21:14:26 -07:00
|
|
|
ld a, [hli]
|
|
|
|
ld c, a
|
2018-09-09 12:09:51 -07:00
|
|
|
ld [wCurMapWarpCount], a
|
2013-09-07 21:14:26 -07:00
|
|
|
ld a, l
|
2018-09-09 12:09:51 -07:00
|
|
|
ld [wCurMapWarpsPointer], a
|
2013-09-07 21:14:26 -07:00
|
|
|
ld a, h
|
2018-09-09 12:09:51 -07:00
|
|
|
ld [wCurMapWarpsPointer + 1], a
|
2013-09-07 21:14:26 -07:00
|
|
|
ld a, c
|
|
|
|
and a
|
|
|
|
ret z
|
2019-03-03 11:19:16 -08:00
|
|
|
ld bc, WARP_EVENT_SIZE
|
2013-09-07 21:14:26 -07:00
|
|
|
call AddNTimes
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
ReadCoordEvents::
|
2013-09-07 21:14:26 -07:00
|
|
|
ld a, [hli]
|
|
|
|
ld c, a
|
2018-09-09 12:09:51 -07:00
|
|
|
ld [wCurMapCoordEventCount], a
|
2013-09-07 21:14:26 -07:00
|
|
|
ld a, l
|
2018-09-09 12:09:51 -07:00
|
|
|
ld [wCurMapCoordEventsPointer], a
|
2013-09-07 21:14:26 -07:00
|
|
|
ld a, h
|
2018-09-09 12:09:51 -07:00
|
|
|
ld [wCurMapCoordEventsPointer + 1], a
|
2015-11-12 08:10:19 -08:00
|
|
|
|
2013-09-07 21:14:26 -07:00
|
|
|
ld a, c
|
|
|
|
and a
|
|
|
|
ret z
|
2015-11-12 08:10:19 -08:00
|
|
|
|
2019-03-03 11:19:16 -08:00
|
|
|
ld bc, COORD_EVENT_SIZE
|
2013-09-07 21:14:26 -07:00
|
|
|
call AddNTimes
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
ReadBGEvents::
|
2013-09-07 21:14:26 -07:00
|
|
|
ld a, [hli]
|
|
|
|
ld c, a
|
2018-09-09 12:09:51 -07:00
|
|
|
ld [wCurMapBGEventCount], a
|
2013-09-07 21:14:26 -07:00
|
|
|
ld a, l
|
2018-09-09 12:09:51 -07:00
|
|
|
ld [wCurMapBGEventsPointer], a
|
2013-09-07 21:14:26 -07:00
|
|
|
ld a, h
|
2018-09-09 12:09:51 -07:00
|
|
|
ld [wCurMapBGEventsPointer + 1], a
|
2015-11-12 08:10:19 -08:00
|
|
|
|
2013-09-07 21:14:26 -07:00
|
|
|
ld a, c
|
|
|
|
and a
|
|
|
|
ret z
|
2015-11-12 08:10:19 -08:00
|
|
|
|
2019-03-03 11:19:16 -08:00
|
|
|
ld bc, BG_EVENT_SIZE
|
2013-09-07 21:14:26 -07:00
|
|
|
call AddNTimes
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
ReadObjectEvents::
|
2013-09-07 21:14:26 -07:00
|
|
|
push hl
|
2015-11-12 08:10:19 -08:00
|
|
|
call ClearObjectStructs
|
2013-09-07 21:14:26 -07:00
|
|
|
pop de
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wMap1Object
|
2013-09-07 21:14:26 -07:00
|
|
|
ld a, [de]
|
|
|
|
inc de
|
2018-09-09 12:09:51 -07:00
|
|
|
ld [wCurMapObjectEventCount], a
|
2013-09-07 21:14:26 -07:00
|
|
|
ld a, e
|
2018-09-09 12:09:51 -07:00
|
|
|
ld [wCurMapObjectEventsPointer], a
|
2013-09-07 21:14:26 -07:00
|
|
|
ld a, d
|
2018-09-09 12:09:51 -07:00
|
|
|
ld [wCurMapObjectEventsPointer + 1], a
|
2015-11-12 08:10:19 -08:00
|
|
|
|
2018-09-09 12:09:51 -07:00
|
|
|
ld a, [wCurMapObjectEventCount]
|
2018-01-16 19:57:19 -08:00
|
|
|
call CopyMapObjectEvents
|
2015-11-12 08:10:19 -08:00
|
|
|
|
2023-07-27 04:01:32 -07:00
|
|
|
; get NUM_OBJECTS - [wCurMapObjectEventCount] - 1
|
2018-09-09 12:09:51 -07:00
|
|
|
ld a, [wCurMapObjectEventCount]
|
2013-09-07 21:14:26 -07:00
|
|
|
ld c, a
|
2023-07-27 04:01:32 -07:00
|
|
|
ld a, NUM_OBJECTS - 1
|
2013-09-07 21:14:26 -07:00
|
|
|
sub c
|
2015-11-12 08:10:19 -08:00
|
|
|
jr z, .skip
|
2023-07-27 04:01:32 -07:00
|
|
|
jr c, .skip
|
2015-11-12 08:10:19 -08:00
|
|
|
|
2020-02-23 12:30:21 -08:00
|
|
|
; could have done "inc hl" instead
|
2015-11-12 08:10:19 -08:00
|
|
|
ld bc, 1
|
2013-09-07 21:14:26 -07:00
|
|
|
add hl, bc
|
2019-11-03 09:25:59 -08:00
|
|
|
ld bc, MAPOBJECT_LENGTH
|
2015-11-12 08:10:19 -08:00
|
|
|
.loop
|
|
|
|
ld [hl], 0
|
2013-09-07 21:14:26 -07:00
|
|
|
inc hl
|
2015-11-12 08:10:19 -08:00
|
|
|
ld [hl], -1
|
2013-09-07 21:14:26 -07:00
|
|
|
dec hl
|
|
|
|
add hl, bc
|
|
|
|
dec a
|
2015-11-12 08:10:19 -08:00
|
|
|
jr nz, .loop
|
2013-09-07 21:14:26 -07:00
|
|
|
|
2015-11-12 08:10:19 -08:00
|
|
|
.skip
|
2013-09-07 21:14:26 -07:00
|
|
|
ld h, d
|
|
|
|
ld l, e
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
CopyMapObjectEvents::
|
2013-09-07 21:14:26 -07:00
|
|
|
and a
|
|
|
|
ret z
|
2015-11-12 08:10:19 -08:00
|
|
|
|
2013-09-07 21:14:26 -07:00
|
|
|
ld c, a
|
2015-11-12 08:10:19 -08:00
|
|
|
.loop
|
2013-09-07 21:14:26 -07:00
|
|
|
push bc
|
|
|
|
push hl
|
|
|
|
ld a, $ff
|
|
|
|
ld [hli], a
|
2019-03-03 11:19:16 -08:00
|
|
|
ld b, OBJECT_EVENT_SIZE
|
2015-11-12 08:10:19 -08:00
|
|
|
.loop2
|
2013-09-07 21:14:26 -07:00
|
|
|
ld a, [de]
|
|
|
|
inc de
|
|
|
|
ld [hli], a
|
|
|
|
dec b
|
2015-11-12 08:10:19 -08:00
|
|
|
jr nz, .loop2
|
|
|
|
|
2013-09-07 21:14:26 -07:00
|
|
|
pop hl
|
2019-11-03 09:25:59 -08:00
|
|
|
ld bc, MAPOBJECT_LENGTH
|
2013-09-07 21:14:26 -07:00
|
|
|
add hl, bc
|
|
|
|
pop bc
|
|
|
|
dec c
|
2015-11-12 08:10:19 -08:00
|
|
|
jr nz, .loop
|
2013-09-07 21:14:26 -07:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
ClearObjectStructs::
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wObject1Struct
|
2019-11-03 09:25:59 -08:00
|
|
|
ld bc, OBJECT_LENGTH * (NUM_OBJECT_STRUCTS - 1)
|
2013-09-07 21:14:26 -07:00
|
|
|
xor a
|
|
|
|
call ByteFill
|
2015-11-12 08:10:19 -08:00
|
|
|
|
|
|
|
; Just to make sure (this is rather pointless)
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wObject1Struct
|
2019-11-03 09:25:59 -08:00
|
|
|
ld de, OBJECT_LENGTH
|
2015-07-26 00:11:33 -07:00
|
|
|
ld c, NUM_OBJECT_STRUCTS - 1
|
2013-09-07 21:14:26 -07:00
|
|
|
xor a
|
2015-11-12 08:10:19 -08:00
|
|
|
.loop
|
2013-09-07 21:14:26 -07:00
|
|
|
ld [hl], a
|
|
|
|
add hl, de
|
|
|
|
dec c
|
2015-11-12 08:10:19 -08:00
|
|
|
jr nz, .loop
|
2013-09-07 21:14:26 -07:00
|
|
|
ret
|
|
|
|
|
2019-11-18 09:16:50 -08:00
|
|
|
GetWarpDestCoords::
|
2018-01-16 19:57:19 -08:00
|
|
|
call GetMapScriptsBank
|
2013-09-07 21:14:26 -07:00
|
|
|
rst Bankswitch
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wMapEventsPointer
|
2013-09-07 21:14:26 -07:00
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
2019-03-03 11:19:16 -08:00
|
|
|
rept 3 ; get to the warp coords
|
|
|
|
inc hl
|
|
|
|
endr
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wWarpNumber]
|
2013-09-07 21:14:26 -07:00
|
|
|
dec a
|
|
|
|
ld c, a
|
2015-11-12 08:10:19 -08:00
|
|
|
ld b, 0
|
2019-03-03 11:19:16 -08:00
|
|
|
ld a, WARP_EVENT_SIZE
|
2013-09-07 21:14:26 -07:00
|
|
|
call AddNTimes
|
|
|
|
ld a, [hli]
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wYCoord], a
|
2013-09-07 21:14:26 -07:00
|
|
|
ld a, [hli]
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wXCoord], a
|
2015-11-12 08:10:19 -08:00
|
|
|
; destination warp number
|
2013-09-07 21:14:26 -07:00
|
|
|
ld a, [hli]
|
2019-09-23 06:09:49 -07:00
|
|
|
cp -1
|
2015-11-12 08:10:19 -08:00
|
|
|
jr nz, .skip
|
|
|
|
call .backup
|
2013-09-07 21:14:26 -07:00
|
|
|
|
2015-11-12 08:10:19 -08:00
|
|
|
.skip
|
2019-11-18 09:16:50 -08:00
|
|
|
farcall GetMapScreenCoords
|
2013-09-07 21:14:26 -07:00
|
|
|
ret
|
|
|
|
|
2015-11-12 08:10:19 -08:00
|
|
|
.backup
|
|
|
|
ld a, [wPrevWarp]
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wBackupWarpNumber], a
|
2015-11-12 08:10:19 -08:00
|
|
|
ld a, [wPrevMapGroup]
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wBackupMapGroup], a
|
2015-11-12 08:10:19 -08:00
|
|
|
ld a, [wPrevMapNumber]
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wBackupMapNumber], a
|
2013-09-07 21:14:26 -07:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
LoadBlockData::
|
2018-03-19 08:36:14 -07:00
|
|
|
ld hl, wOverworldMapBlocks
|
|
|
|
ld bc, wOverworldMapBlocksEnd - wOverworldMapBlocks
|
2013-12-11 18:42:56 -08:00
|
|
|
ld a, 0
|
2013-09-07 21:14:26 -07:00
|
|
|
call ByteFill
|
2015-07-15 12:48:44 -07:00
|
|
|
call ChangeMap
|
2013-09-07 21:14:26 -07:00
|
|
|
call FillMapConnections
|
2016-01-06 04:44:50 -08:00
|
|
|
ld a, MAPCALLBACK_TILES
|
2015-07-20 00:51:52 -07:00
|
|
|
call RunMapCallback
|
2013-09-07 21:14:26 -07:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
ChangeMap::
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hROMBank]
|
2013-09-07 21:14:26 -07:00
|
|
|
push af
|
2013-12-11 18:42:56 -08:00
|
|
|
|
2018-03-19 08:36:14 -07:00
|
|
|
ld hl, wOverworldMapBlocks
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wMapWidth]
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hConnectedMapWidth], a
|
2013-09-07 21:14:26 -07:00
|
|
|
add $6
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hConnectionStripLength], a
|
2013-09-07 21:14:26 -07:00
|
|
|
ld c, a
|
2013-12-11 18:42:56 -08:00
|
|
|
ld b, 0
|
2013-09-07 21:14:26 -07:00
|
|
|
add hl, bc
|
2016-05-10 09:31:49 -07:00
|
|
|
add hl, bc
|
|
|
|
add hl, bc
|
2013-12-11 18:42:56 -08:00
|
|
|
ld c, 3
|
2013-09-07 21:14:26 -07:00
|
|
|
add hl, bc
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wMapBlocksBank]
|
2013-09-07 21:14:26 -07:00
|
|
|
rst Bankswitch
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wMapBlocksPointer]
|
2013-09-07 21:14:26 -07:00
|
|
|
ld e, a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wMapBlocksPointer + 1]
|
2013-09-07 21:14:26 -07:00
|
|
|
ld d, a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wMapHeight]
|
2013-09-07 21:14:26 -07:00
|
|
|
ld b, a
|
2016-01-12 09:46:18 -08:00
|
|
|
.row
|
2013-09-07 21:14:26 -07:00
|
|
|
push hl
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hConnectedMapWidth]
|
2013-09-07 21:14:26 -07:00
|
|
|
ld c, a
|
2016-01-12 09:46:18 -08:00
|
|
|
.col
|
2013-09-07 21:14:26 -07:00
|
|
|
ld a, [de]
|
|
|
|
inc de
|
|
|
|
ld [hli], a
|
|
|
|
dec c
|
2016-01-12 09:46:18 -08:00
|
|
|
jr nz, .col
|
2013-09-07 21:14:26 -07:00
|
|
|
pop hl
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hConnectionStripLength]
|
2013-09-07 21:14:26 -07:00
|
|
|
add l
|
|
|
|
ld l, a
|
2016-01-12 09:46:18 -08:00
|
|
|
jr nc, .okay
|
2013-09-07 21:14:26 -07:00
|
|
|
inc h
|
2016-01-12 09:46:18 -08:00
|
|
|
.okay
|
2013-09-07 21:14:26 -07:00
|
|
|
dec b
|
2016-01-12 09:46:18 -08:00
|
|
|
jr nz, .row
|
2013-12-11 18:42:56 -08:00
|
|
|
|
2013-09-07 21:14:26 -07:00
|
|
|
pop af
|
|
|
|
rst Bankswitch
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
FillMapConnections::
|
2013-09-07 21:14:26 -07:00
|
|
|
; North
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wNorthConnectedMapGroup]
|
2013-09-07 21:14:26 -07:00
|
|
|
cp $ff
|
|
|
|
jr z, .South
|
|
|
|
ld b, a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wNorthConnectedMapNumber]
|
2013-09-07 21:14:26 -07:00
|
|
|
ld c, a
|
2018-01-16 19:57:19 -08:00
|
|
|
call GetAnyMapBlocksBank
|
2013-09-07 21:14:26 -07:00
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wNorthConnectionStripPointer]
|
2013-09-07 21:14:26 -07:00
|
|
|
ld l, a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wNorthConnectionStripPointer + 1]
|
2013-09-07 21:14:26 -07:00
|
|
|
ld h, a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wNorthConnectionStripLocation]
|
2013-09-07 21:14:26 -07:00
|
|
|
ld e, a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wNorthConnectionStripLocation + 1]
|
2013-09-07 21:14:26 -07:00
|
|
|
ld d, a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wNorthConnectionStripLength]
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hConnectionStripLength], a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wNorthConnectedMapWidth]
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hConnectedMapWidth], a
|
2013-09-07 21:14:26 -07:00
|
|
|
call FillNorthConnectionStrip
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.South:
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wSouthConnectedMapGroup]
|
2013-09-07 21:14:26 -07:00
|
|
|
cp $ff
|
|
|
|
jr z, .West
|
|
|
|
ld b, a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wSouthConnectedMapNumber]
|
2013-09-07 21:14:26 -07:00
|
|
|
ld c, a
|
2018-01-16 19:57:19 -08:00
|
|
|
call GetAnyMapBlocksBank
|
2013-09-07 21:14:26 -07:00
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wSouthConnectionStripPointer]
|
2013-09-07 21:14:26 -07:00
|
|
|
ld l, a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wSouthConnectionStripPointer + 1]
|
2013-09-07 21:14:26 -07:00
|
|
|
ld h, a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wSouthConnectionStripLocation]
|
2013-09-07 21:14:26 -07:00
|
|
|
ld e, a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wSouthConnectionStripLocation + 1]
|
2013-09-07 21:14:26 -07:00
|
|
|
ld d, a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wSouthConnectionStripLength]
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hConnectionStripLength], a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wSouthConnectedMapWidth]
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hConnectedMapWidth], a
|
2013-09-07 21:14:26 -07:00
|
|
|
call FillSouthConnectionStrip
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.West:
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wWestConnectedMapGroup]
|
2013-09-07 21:14:26 -07:00
|
|
|
cp $ff
|
|
|
|
jr z, .East
|
|
|
|
ld b, a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wWestConnectedMapNumber]
|
2013-09-07 21:14:26 -07:00
|
|
|
ld c, a
|
2018-01-16 19:57:19 -08:00
|
|
|
call GetAnyMapBlocksBank
|
2013-09-07 21:14:26 -07:00
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wWestConnectionStripPointer]
|
2013-09-07 21:14:26 -07:00
|
|
|
ld l, a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wWestConnectionStripPointer + 1]
|
2013-09-07 21:14:26 -07:00
|
|
|
ld h, a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wWestConnectionStripLocation]
|
2013-09-07 21:14:26 -07:00
|
|
|
ld e, a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wWestConnectionStripLocation + 1]
|
2013-09-07 21:14:26 -07:00
|
|
|
ld d, a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wWestConnectionStripLength]
|
2013-09-07 21:14:26 -07:00
|
|
|
ld b, a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wWestConnectedMapWidth]
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hConnectionStripLength], a
|
2013-09-07 21:14:26 -07:00
|
|
|
call FillWestConnectionStrip
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.East:
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wEastConnectedMapGroup]
|
2013-09-07 21:14:26 -07:00
|
|
|
cp $ff
|
|
|
|
jr z, .Done
|
|
|
|
ld b, a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wEastConnectedMapNumber]
|
2013-09-07 21:14:26 -07:00
|
|
|
ld c, a
|
2018-01-16 19:57:19 -08:00
|
|
|
call GetAnyMapBlocksBank
|
2013-09-07 21:14:26 -07:00
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wEastConnectionStripPointer]
|
2013-09-07 21:14:26 -07:00
|
|
|
ld l, a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wEastConnectionStripPointer + 1]
|
2013-09-07 21:14:26 -07:00
|
|
|
ld h, a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wEastConnectionStripLocation]
|
2013-09-07 21:14:26 -07:00
|
|
|
ld e, a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wEastConnectionStripLocation + 1]
|
2013-09-07 21:14:26 -07:00
|
|
|
ld d, a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wEastConnectionStripLength]
|
2013-09-07 21:14:26 -07:00
|
|
|
ld b, a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wEastConnectedMapWidth]
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hConnectionStripLength], a
|
2013-09-07 21:14:26 -07:00
|
|
|
call FillEastConnectionStrip
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.Done:
|
2013-09-07 21:14:26 -07:00
|
|
|
ret
|
|
|
|
|
2014-02-01 17:26:39 -08:00
|
|
|
FillNorthConnectionStrip::
|
2018-06-24 07:09:41 -07:00
|
|
|
FillSouthConnectionStrip::
|
2013-09-07 21:14:26 -07:00
|
|
|
ld c, 3
|
|
|
|
.y
|
|
|
|
push de
|
|
|
|
|
|
|
|
push hl
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hConnectionStripLength]
|
2013-09-07 21:14:26 -07:00
|
|
|
ld b, a
|
|
|
|
.x
|
|
|
|
ld a, [hli]
|
|
|
|
ld [de], a
|
|
|
|
inc de
|
|
|
|
dec b
|
|
|
|
jr nz, .x
|
|
|
|
pop hl
|
|
|
|
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hConnectedMapWidth]
|
2013-09-07 21:14:26 -07:00
|
|
|
ld e, a
|
|
|
|
ld d, 0
|
|
|
|
add hl, de
|
|
|
|
pop de
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wMapWidth]
|
2013-09-07 21:14:26 -07:00
|
|
|
add 6
|
|
|
|
add e
|
|
|
|
ld e, a
|
2016-01-12 09:46:18 -08:00
|
|
|
jr nc, .okay
|
2013-09-07 21:14:26 -07:00
|
|
|
inc d
|
2016-01-12 09:46:18 -08:00
|
|
|
.okay
|
2013-09-07 21:14:26 -07:00
|
|
|
dec c
|
|
|
|
jr nz, .y
|
|
|
|
ret
|
|
|
|
|
2014-02-01 17:26:39 -08:00
|
|
|
FillWestConnectionStrip::
|
2018-06-24 07:09:41 -07:00
|
|
|
FillEastConnectionStrip::
|
2016-01-12 09:46:18 -08:00
|
|
|
.loop
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wMapWidth]
|
2013-09-07 21:14:26 -07:00
|
|
|
add 6
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hConnectedMapWidth], a
|
2013-09-07 21:14:26 -07:00
|
|
|
|
|
|
|
push de
|
|
|
|
|
|
|
|
push hl
|
|
|
|
ld a, [hli]
|
|
|
|
ld [de], a
|
|
|
|
inc de
|
|
|
|
ld a, [hli]
|
|
|
|
ld [de], a
|
|
|
|
inc de
|
|
|
|
ld a, [hli]
|
|
|
|
ld [de], a
|
|
|
|
inc de
|
|
|
|
pop hl
|
|
|
|
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hConnectionStripLength]
|
2013-09-07 21:14:26 -07:00
|
|
|
ld e, a
|
|
|
|
ld d, 0
|
|
|
|
add hl, de
|
|
|
|
pop de
|
|
|
|
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hConnectedMapWidth]
|
2013-09-07 21:14:26 -07:00
|
|
|
add e
|
|
|
|
ld e, a
|
2016-01-12 09:46:18 -08:00
|
|
|
jr nc, .okay
|
2013-09-07 21:14:26 -07:00
|
|
|
inc d
|
2016-01-12 09:46:18 -08:00
|
|
|
.okay
|
2013-09-07 21:14:26 -07:00
|
|
|
dec b
|
2016-01-12 09:46:18 -08:00
|
|
|
jr nz, .loop
|
2013-09-07 21:14:26 -07:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
LoadMapStatus::
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wMapStatus], a
|
2013-09-07 21:14:26 -07:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
CallScript::
|
2013-09-07 21:14:26 -07:00
|
|
|
; Call a script at a:hl.
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wScriptBank], a
|
2013-09-07 21:14:26 -07:00
|
|
|
ld a, l
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wScriptPos], a
|
2013-09-07 21:14:26 -07:00
|
|
|
ld a, h
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wScriptPos + 1], a
|
2013-09-07 21:14:26 -07:00
|
|
|
|
2015-11-05 12:08:00 -08:00
|
|
|
ld a, PLAYEREVENT_MAPSCRIPT
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wScriptRunning], a
|
2013-09-07 21:14:26 -07:00
|
|
|
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
CallMapScript::
|
2015-11-05 12:08:00 -08:00
|
|
|
; Call a script at hl in the current bank if there isn't already a script running
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wScriptRunning]
|
2013-09-07 21:14:26 -07:00
|
|
|
and a
|
|
|
|
ret nz
|
2018-01-16 19:57:19 -08:00
|
|
|
call GetMapScriptsBank
|
2013-09-07 21:14:26 -07:00
|
|
|
jr CallScript
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
RunMapCallback::
|
2018-01-16 19:57:19 -08:00
|
|
|
; Will run the first callback found with execution index equal to a.
|
2013-09-07 21:14:26 -07:00
|
|
|
ld b, a
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hROMBank]
|
2013-09-07 21:14:26 -07:00
|
|
|
push af
|
2018-01-16 19:57:19 -08:00
|
|
|
call SwitchToMapScriptsBank
|
2015-11-05 12:08:00 -08:00
|
|
|
call .FindCallback
|
2013-09-07 21:14:26 -07:00
|
|
|
jr nc, .done
|
|
|
|
|
2018-01-16 19:57:19 -08:00
|
|
|
call GetMapScriptsBank
|
2013-09-07 21:14:26 -07:00
|
|
|
ld b, a
|
|
|
|
ld d, h
|
|
|
|
ld e, l
|
2015-07-20 00:51:52 -07:00
|
|
|
call ExecuteCallbackScript
|
2013-09-07 21:14:26 -07:00
|
|
|
|
|
|
|
.done
|
|
|
|
pop af
|
|
|
|
rst Bankswitch
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
.FindCallback:
|
2018-09-09 12:09:51 -07:00
|
|
|
ld a, [wCurMapCallbackCount]
|
2013-09-07 21:14:26 -07:00
|
|
|
ld c, a
|
|
|
|
and a
|
|
|
|
ret z
|
2018-09-09 12:09:51 -07:00
|
|
|
ld hl, wCurMapCallbacksPointer
|
2013-09-07 21:14:26 -07:00
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
|
|
|
or h
|
|
|
|
ret z
|
2019-03-03 11:19:16 -08:00
|
|
|
ld de, CALLBACK_SIZE
|
2015-07-20 00:51:52 -07:00
|
|
|
.loop
|
2013-09-07 21:14:26 -07:00
|
|
|
ld a, [hl]
|
|
|
|
cp b
|
2015-11-05 12:08:00 -08:00
|
|
|
jr z, .found
|
2013-09-07 21:14:26 -07:00
|
|
|
add hl, de
|
|
|
|
dec c
|
2015-07-20 00:51:52 -07:00
|
|
|
jr nz, .loop
|
2013-09-07 21:14:26 -07:00
|
|
|
xor a
|
|
|
|
ret
|
|
|
|
|
2015-11-05 12:08:00 -08:00
|
|
|
.found
|
2013-09-07 21:14:26 -07:00
|
|
|
inc hl
|
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
ExecuteCallbackScript::
|
2015-11-05 12:08:00 -08:00
|
|
|
; Do map callback de and return to script bank b.
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall CallCallback
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wScriptMode]
|
2013-09-07 21:14:26 -07:00
|
|
|
push af
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wScriptFlags
|
2013-09-07 21:14:26 -07:00
|
|
|
ld a, [hl]
|
|
|
|
push af
|
|
|
|
set 1, [hl]
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall EnableScriptMode
|
|
|
|
farcall ScriptEvents
|
2013-09-07 21:14:26 -07:00
|
|
|
pop af
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wScriptFlags], a
|
2013-09-07 21:14:26 -07:00
|
|
|
pop af
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wScriptMode], a
|
2013-09-07 21:14:26 -07:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
MapTextbox::
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hROMBank]
|
2013-09-07 21:14:26 -07:00
|
|
|
push af
|
2013-12-11 18:42:56 -08:00
|
|
|
|
2013-09-07 21:14:26 -07:00
|
|
|
ld a, b
|
|
|
|
rst Bankswitch
|
|
|
|
|
|
|
|
push hl
|
2023-08-11 03:28:14 -07:00
|
|
|
call ClearTextbox
|
|
|
|
lda_coord 17, 17
|
|
|
|
ldcoord_a 18, 17
|
2016-05-10 09:31:49 -07:00
|
|
|
call SafeUpdateSprites
|
2013-09-07 21:14:26 -07:00
|
|
|
ld a, 1
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hOAMUpdate], a
|
2015-11-25 07:16:29 -08:00
|
|
|
call ApplyTilemap
|
2013-09-07 21:14:26 -07:00
|
|
|
pop hl
|
2019-04-08 05:15:10 -07:00
|
|
|
call PrintTextboxText
|
2013-09-07 21:14:26 -07:00
|
|
|
xor a
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hOAMUpdate], a
|
2013-12-11 18:42:56 -08:00
|
|
|
|
2013-09-07 21:14:26 -07:00
|
|
|
pop af
|
|
|
|
rst Bankswitch
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
Call_a_de::
|
2013-09-07 21:14:26 -07:00
|
|
|
; Call a:de.
|
|
|
|
|
2020-04-06 10:02:23 -07:00
|
|
|
ldh [hTempBank], a
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hROMBank]
|
2013-09-07 21:14:26 -07:00
|
|
|
push af
|
2020-04-06 10:02:23 -07:00
|
|
|
ldh a, [hTempBank]
|
2013-09-07 21:14:26 -07:00
|
|
|
rst Bankswitch
|
|
|
|
|
|
|
|
call .de
|
|
|
|
|
|
|
|
pop af
|
|
|
|
rst Bankswitch
|
|
|
|
ret
|
|
|
|
|
|
|
|
.de
|
|
|
|
push de
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
GetMovementData::
|
2017-12-24 10:46:34 -08:00
|
|
|
; Initialize the movement data for object c at b:hl
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hROMBank]
|
2013-09-07 21:14:26 -07:00
|
|
|
push af
|
|
|
|
ld a, b
|
|
|
|
rst Bankswitch
|
|
|
|
|
|
|
|
ld a, c
|
2015-11-11 20:38:57 -08:00
|
|
|
call LoadMovementDataPointer
|
2013-09-07 21:14:26 -07:00
|
|
|
|
|
|
|
pop hl
|
|
|
|
ld a, h
|
|
|
|
rst Bankswitch
|
|
|
|
ret
|
|
|
|
|
2018-06-24 17:10:37 -07:00
|
|
|
GetScriptByte::
|
2018-01-23 14:39:09 -08:00
|
|
|
; Return byte at wScriptBank:wScriptPos in a.
|
2013-09-07 21:14:26 -07:00
|
|
|
|
|
|
|
push hl
|
|
|
|
push bc
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hROMBank]
|
2013-09-07 21:14:26 -07:00
|
|
|
push af
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wScriptBank]
|
2013-09-07 21:14:26 -07:00
|
|
|
rst Bankswitch
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wScriptPos
|
2013-09-07 21:14:26 -07:00
|
|
|
ld c, [hl]
|
|
|
|
inc hl
|
|
|
|
ld b, [hl]
|
|
|
|
|
|
|
|
ld a, [bc]
|
|
|
|
|
|
|
|
inc bc
|
|
|
|
ld [hl], b
|
|
|
|
dec hl
|
|
|
|
ld [hl], c
|
|
|
|
|
|
|
|
ld b, a
|
|
|
|
pop af
|
|
|
|
rst Bankswitch
|
|
|
|
ld a, b
|
|
|
|
pop bc
|
|
|
|
pop hl
|
|
|
|
ret
|
|
|
|
|
2018-06-24 17:10:37 -07:00
|
|
|
ObjectEvent::
|
2013-09-07 21:14:26 -07:00
|
|
|
jumptextfaceplayer ObjectEventText
|
|
|
|
|
2014-02-01 17:26:39 -08:00
|
|
|
ObjectEventText::
|
2018-10-28 09:16:55 -07:00
|
|
|
text_far _ObjectEventText
|
2018-11-17 10:33:03 -08:00
|
|
|
text_end
|
2013-09-07 21:14:26 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BGEventText::
|
2019-10-20 15:24:17 -07:00
|
|
|
text_far _BGEventText
|
2018-11-17 10:33:03 -08:00
|
|
|
text_end
|
2013-09-07 21:14:26 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
CoordinatesEventText::
|
2019-10-20 15:24:17 -07:00
|
|
|
text_far _CoordinatesEventText
|
2018-11-17 10:33:03 -08:00
|
|
|
text_end
|
2013-09-07 21:14:26 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
CheckObjectMask::
|
2020-12-23 13:54:28 -08:00
|
|
|
ldh a, [hMapObjectIndex]
|
2013-09-07 21:14:26 -07:00
|
|
|
ld e, a
|
2020-11-09 12:17:03 -08:00
|
|
|
ld d, 0
|
2015-11-01 18:17:46 -08:00
|
|
|
ld hl, wObjectMasks
|
2013-09-07 21:14:26 -07:00
|
|
|
add hl, de
|
|
|
|
ld a, [hl]
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
MaskObject::
|
2020-12-23 13:54:28 -08:00
|
|
|
ldh a, [hMapObjectIndex]
|
2013-09-07 21:14:26 -07:00
|
|
|
ld e, a
|
2020-11-09 12:17:03 -08:00
|
|
|
ld d, 0
|
2015-11-01 18:17:46 -08:00
|
|
|
ld hl, wObjectMasks
|
2013-09-07 21:14:26 -07:00
|
|
|
add hl, de
|
2020-07-13 10:05:05 -07:00
|
|
|
ld [hl], -1 ; masked
|
2013-09-07 21:14:26 -07:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
UnmaskObject::
|
2020-12-23 13:54:28 -08:00
|
|
|
ldh a, [hMapObjectIndex]
|
2013-09-07 21:14:26 -07:00
|
|
|
ld e, a
|
2020-11-09 12:17:03 -08:00
|
|
|
ld d, 0
|
2015-11-01 18:17:46 -08:00
|
|
|
ld hl, wObjectMasks
|
2013-09-07 21:14:26 -07:00
|
|
|
add hl, de
|
2015-11-01 18:17:46 -08:00
|
|
|
ld [hl], 0 ; unmasked
|
2013-09-07 21:14:26 -07:00
|
|
|
ret
|
|
|
|
|
2020-07-13 10:05:05 -07:00
|
|
|
if DEF(_DEBUG)
|
|
|
|
ComputeROMXChecksum::
|
|
|
|
ldh a, [hROMBank]
|
|
|
|
push af
|
|
|
|
ld a, c
|
|
|
|
rst Bankswitch
|
|
|
|
ld hl, $4000 ; ROMX start
|
|
|
|
.loop
|
|
|
|
ld a, [hli]
|
|
|
|
add e
|
|
|
|
ld e, a
|
|
|
|
ld a, d
|
|
|
|
adc 0
|
|
|
|
ld d, a
|
|
|
|
ld a, h
|
|
|
|
cp $80 ; HIGH(ROMX end)
|
|
|
|
jr c, .loop
|
|
|
|
pop af
|
|
|
|
rst Bankswitch
|
|
|
|
ret
|
|
|
|
endc
|
|
|
|
|
2019-06-06 14:59:13 -07:00
|
|
|
ScrollMapUp::
|
2015-07-22 12:57:02 -07:00
|
|
|
hlcoord 0, 0
|
2018-01-23 14:39:09 -08:00
|
|
|
ld de, wBGMapBuffer
|
2015-11-12 21:49:27 -08:00
|
|
|
call BackupBGMapRow
|
|
|
|
ld c, 2 * SCREEN_WIDTH
|
2020-02-12 04:15:37 -08:00
|
|
|
call ScrollBGMapPalettes
|
2015-11-14 20:02:38 -08:00
|
|
|
ld a, [wBGMapAnchor]
|
2013-09-07 21:14:26 -07:00
|
|
|
ld e, a
|
2015-11-14 20:02:38 -08:00
|
|
|
ld a, [wBGMapAnchor + 1]
|
2013-09-07 21:14:26 -07:00
|
|
|
ld d, a
|
2015-11-12 21:49:27 -08:00
|
|
|
call UpdateBGMapRow
|
2013-09-07 21:14:26 -07:00
|
|
|
ld a, $1
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hBGMapUpdate], a
|
2013-09-07 21:14:26 -07:00
|
|
|
ret
|
|
|
|
|
2019-06-06 14:59:13 -07:00
|
|
|
ScrollMapDown::
|
2015-11-12 21:49:27 -08:00
|
|
|
hlcoord 0, SCREEN_HEIGHT - 2
|
2018-01-23 14:39:09 -08:00
|
|
|
ld de, wBGMapBuffer
|
2015-11-12 21:49:27 -08:00
|
|
|
call BackupBGMapRow
|
|
|
|
ld c, 2 * SCREEN_WIDTH
|
2020-02-12 04:15:37 -08:00
|
|
|
call ScrollBGMapPalettes
|
2015-11-14 20:02:38 -08:00
|
|
|
ld a, [wBGMapAnchor]
|
2013-09-07 21:14:26 -07:00
|
|
|
ld l, a
|
2015-11-14 20:02:38 -08:00
|
|
|
ld a, [wBGMapAnchor + 1]
|
2013-09-07 21:14:26 -07:00
|
|
|
ld h, a
|
2018-07-03 23:42:11 -07:00
|
|
|
ld bc, BG_MAP_WIDTH tiles
|
2013-09-07 21:14:26 -07:00
|
|
|
add hl, bc
|
2017-12-28 04:32:33 -08:00
|
|
|
; cap d at HIGH(vBGMap0)
|
2013-09-07 21:14:26 -07:00
|
|
|
ld a, h
|
2015-11-12 21:49:27 -08:00
|
|
|
and %00000011
|
2017-12-28 04:32:33 -08:00
|
|
|
or HIGH(vBGMap0)
|
2013-09-07 21:14:26 -07:00
|
|
|
ld e, l
|
|
|
|
ld d, a
|
2015-11-12 21:49:27 -08:00
|
|
|
call UpdateBGMapRow
|
2013-09-07 21:14:26 -07:00
|
|
|
ld a, $1
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hBGMapUpdate], a
|
2013-09-07 21:14:26 -07:00
|
|
|
ret
|
|
|
|
|
2019-06-06 14:59:13 -07:00
|
|
|
ScrollMapLeft::
|
2015-07-22 12:57:02 -07:00
|
|
|
hlcoord 0, 0
|
2018-01-23 14:39:09 -08:00
|
|
|
ld de, wBGMapBuffer
|
2015-11-12 21:49:27 -08:00
|
|
|
call BackupBGMapColumn
|
|
|
|
ld c, 2 * SCREEN_HEIGHT
|
2020-02-12 04:15:37 -08:00
|
|
|
call ScrollBGMapPalettes
|
2015-11-14 20:02:38 -08:00
|
|
|
ld a, [wBGMapAnchor]
|
2013-09-07 21:14:26 -07:00
|
|
|
ld e, a
|
2015-11-14 20:02:38 -08:00
|
|
|
ld a, [wBGMapAnchor + 1]
|
2013-09-07 21:14:26 -07:00
|
|
|
ld d, a
|
2015-11-12 21:49:27 -08:00
|
|
|
call UpdateBGMapColumn
|
2013-09-07 21:14:26 -07:00
|
|
|
ld a, $1
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hBGMapUpdate], a
|
2013-09-07 21:14:26 -07:00
|
|
|
ret
|
|
|
|
|
2019-06-06 14:59:13 -07:00
|
|
|
ScrollMapRight::
|
2015-11-12 21:49:27 -08:00
|
|
|
hlcoord SCREEN_WIDTH - 2, 0
|
2018-01-23 14:39:09 -08:00
|
|
|
ld de, wBGMapBuffer
|
2015-11-12 21:49:27 -08:00
|
|
|
call BackupBGMapColumn
|
|
|
|
ld c, 2 * SCREEN_HEIGHT
|
2020-02-12 04:15:37 -08:00
|
|
|
call ScrollBGMapPalettes
|
2015-11-14 20:02:38 -08:00
|
|
|
ld a, [wBGMapAnchor]
|
2013-09-07 21:14:26 -07:00
|
|
|
ld e, a
|
2015-11-12 21:49:27 -08:00
|
|
|
and %11100000
|
2013-09-07 21:14:26 -07:00
|
|
|
ld b, a
|
|
|
|
ld a, e
|
2015-11-12 21:49:27 -08:00
|
|
|
add SCREEN_HEIGHT
|
|
|
|
and %00011111
|
2013-09-07 21:14:26 -07:00
|
|
|
or b
|
|
|
|
ld e, a
|
2015-11-14 20:02:38 -08:00
|
|
|
ld a, [wBGMapAnchor + 1]
|
2013-09-07 21:14:26 -07:00
|
|
|
ld d, a
|
2015-11-12 21:49:27 -08:00
|
|
|
call UpdateBGMapColumn
|
2013-09-07 21:14:26 -07:00
|
|
|
ld a, $1
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hBGMapUpdate], a
|
2013-09-07 21:14:26 -07:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BackupBGMapRow::
|
2015-11-12 21:49:27 -08:00
|
|
|
ld c, 2 * SCREEN_WIDTH
|
|
|
|
.loop
|
2013-09-07 21:14:26 -07:00
|
|
|
ld a, [hli]
|
|
|
|
ld [de], a
|
|
|
|
inc de
|
|
|
|
dec c
|
2015-11-12 21:49:27 -08:00
|
|
|
jr nz, .loop
|
2013-09-07 21:14:26 -07:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BackupBGMapColumn::
|
2015-11-12 21:49:27 -08:00
|
|
|
ld c, SCREEN_HEIGHT
|
|
|
|
.loop
|
2013-09-07 21:14:26 -07:00
|
|
|
ld a, [hli]
|
|
|
|
ld [de], a
|
|
|
|
inc de
|
|
|
|
ld a, [hl]
|
|
|
|
ld [de], a
|
|
|
|
inc de
|
2015-11-12 21:49:27 -08:00
|
|
|
ld a, SCREEN_WIDTH - 1
|
2013-09-07 21:14:26 -07:00
|
|
|
add l
|
|
|
|
ld l, a
|
2015-11-12 21:49:27 -08:00
|
|
|
jr nc, .skip
|
2013-09-07 21:14:26 -07:00
|
|
|
inc h
|
|
|
|
|
2015-11-12 21:49:27 -08:00
|
|
|
.skip
|
2013-09-07 21:14:26 -07:00
|
|
|
dec c
|
2015-11-12 21:49:27 -08:00
|
|
|
jr nz, .loop
|
2013-09-07 21:14:26 -07:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
UpdateBGMapRow::
|
2020-12-23 13:29:30 -08:00
|
|
|
ld hl, wBGMapBufferPointers
|
2013-09-07 21:14:26 -07:00
|
|
|
push de
|
2015-11-12 21:49:27 -08:00
|
|
|
call .iteration
|
2013-09-07 21:14:26 -07:00
|
|
|
pop de
|
2019-03-03 10:30:27 -08:00
|
|
|
ld a, BG_MAP_WIDTH
|
2013-09-07 21:14:26 -07:00
|
|
|
add e
|
|
|
|
ld e, a
|
|
|
|
|
2015-11-12 21:49:27 -08:00
|
|
|
.iteration
|
|
|
|
ld c, 10
|
|
|
|
.loop
|
2013-09-07 21:14:26 -07:00
|
|
|
ld a, e
|
|
|
|
ld [hli], a
|
|
|
|
ld a, d
|
|
|
|
ld [hli], a
|
|
|
|
ld a, e
|
|
|
|
inc a
|
2016-01-06 04:44:50 -08:00
|
|
|
inc a
|
2013-09-07 21:14:26 -07:00
|
|
|
and $1f
|
|
|
|
ld b, a
|
|
|
|
ld a, e
|
|
|
|
and $e0
|
|
|
|
or b
|
|
|
|
ld e, a
|
|
|
|
dec c
|
2015-11-12 21:49:27 -08:00
|
|
|
jr nz, .loop
|
|
|
|
ld a, SCREEN_WIDTH
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hBGMapTileCount], a
|
2013-09-07 21:14:26 -07:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
UpdateBGMapColumn::
|
2020-12-23 13:29:30 -08:00
|
|
|
ld hl, wBGMapBufferPointers
|
2015-11-12 21:49:27 -08:00
|
|
|
ld c, SCREEN_HEIGHT
|
|
|
|
.loop
|
2013-09-07 21:14:26 -07:00
|
|
|
ld a, e
|
|
|
|
ld [hli], a
|
|
|
|
ld a, d
|
|
|
|
ld [hli], a
|
2019-03-03 10:30:27 -08:00
|
|
|
ld a, BG_MAP_WIDTH
|
2013-09-07 21:14:26 -07:00
|
|
|
add e
|
|
|
|
ld e, a
|
2015-11-12 21:49:27 -08:00
|
|
|
jr nc, .skip
|
2013-09-07 21:14:26 -07:00
|
|
|
inc d
|
2017-12-28 04:32:33 -08:00
|
|
|
; cap d at HIGH(vBGMap0)
|
2013-09-07 21:14:26 -07:00
|
|
|
ld a, d
|
2018-01-11 09:00:01 -08:00
|
|
|
and %11
|
2017-12-28 04:32:33 -08:00
|
|
|
or HIGH(vBGMap0)
|
2013-09-07 21:14:26 -07:00
|
|
|
ld d, a
|
|
|
|
|
2015-11-12 21:49:27 -08:00
|
|
|
.skip
|
2013-09-07 21:14:26 -07:00
|
|
|
dec c
|
2015-11-12 21:49:27 -08:00
|
|
|
jr nz, .loop
|
|
|
|
ld a, SCREEN_HEIGHT
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hBGMapTileCount], a
|
2013-09-07 21:14:26 -07:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
LoadTilesetGFX::
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wTilesetAddress
|
2013-09-07 21:14:26 -07:00
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wTilesetBank]
|
2013-09-07 21:14:26 -07:00
|
|
|
ld e, a
|
2015-11-12 21:49:27 -08:00
|
|
|
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [rSVBK]
|
2013-09-07 21:14:26 -07:00
|
|
|
push af
|
2018-01-03 16:12:45 -08:00
|
|
|
ld a, BANK(wDecompressScratch)
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [rSVBK], a
|
2015-11-12 21:49:27 -08:00
|
|
|
|
2013-09-07 21:14:26 -07:00
|
|
|
ld a, e
|
2015-12-19 11:48:30 -08:00
|
|
|
ld de, wDecompressScratch
|
2013-09-07 21:14:26 -07:00
|
|
|
call FarDecompress
|
2015-11-12 21:49:27 -08:00
|
|
|
|
2015-12-19 11:48:30 -08:00
|
|
|
ld hl, wDecompressScratch
|
2017-12-28 04:32:33 -08:00
|
|
|
ld de, vTiles2
|
2023-08-02 10:52:51 -07:00
|
|
|
ld bc, $7f tiles
|
2013-09-07 21:14:26 -07:00
|
|
|
call CopyBytes
|
2015-11-12 21:49:27 -08:00
|
|
|
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [rVBK]
|
2013-09-07 21:14:26 -07:00
|
|
|
push af
|
2019-03-03 10:30:27 -08:00
|
|
|
ld a, BANK(vTiles5)
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [rVBK], a
|
2015-11-12 21:49:27 -08:00
|
|
|
|
2023-08-02 10:52:51 -07:00
|
|
|
ld hl, wDecompressScratch + $80 tiles
|
2019-03-03 10:30:27 -08:00
|
|
|
ld de, vTiles5
|
2023-08-02 10:52:51 -07:00
|
|
|
ld bc, $80 tiles
|
2013-09-07 21:14:26 -07:00
|
|
|
call CopyBytes
|
2015-11-12 21:49:27 -08:00
|
|
|
|
2013-09-07 21:14:26 -07:00
|
|
|
pop af
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [rVBK], a
|
2015-11-12 21:49:27 -08:00
|
|
|
|
2013-09-07 21:14:26 -07:00
|
|
|
pop af
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [rSVBK], a
|
2013-09-07 21:14:26 -07:00
|
|
|
|
2018-01-10 14:30:27 -08:00
|
|
|
; These tilesets support dynamic per-mapgroup roof tiles.
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wMapTileset]
|
2018-01-17 11:50:34 -08:00
|
|
|
cp TILESET_JOHTO
|
2015-11-12 21:49:27 -08:00
|
|
|
jr z, .load_roof
|
2018-01-17 11:50:34 -08:00
|
|
|
cp TILESET_JOHTO_MODERN
|
2015-11-12 21:49:27 -08:00
|
|
|
jr z, .load_roof
|
|
|
|
cp TILESET_BATTLE_TOWER_OUTSIDE
|
|
|
|
jr z, .load_roof
|
|
|
|
jr .skip_roof
|
|
|
|
|
|
|
|
.load_roof
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall LoadMapGroupRoof
|
2013-09-07 21:14:26 -07:00
|
|
|
|
2015-11-12 21:49:27 -08:00
|
|
|
.skip_roof
|
2013-09-07 21:14:26 -07:00
|
|
|
xor a
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hTileAnimFrame], a
|
2013-09-07 21:14:26 -07:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BufferScreen::
|
2015-12-13 17:33:56 -08:00
|
|
|
ld hl, wOverworldMapAnchor
|
2013-09-07 21:14:26 -07:00
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
2015-12-14 08:12:18 -08:00
|
|
|
ld de, wScreenSave
|
2018-04-04 13:14:48 -07:00
|
|
|
ld c, SCREEN_META_HEIGHT
|
|
|
|
ld b, SCREEN_META_WIDTH
|
2016-01-12 09:46:18 -08:00
|
|
|
.row
|
2013-09-07 21:14:26 -07:00
|
|
|
push bc
|
|
|
|
push hl
|
2016-01-12 09:46:18 -08:00
|
|
|
.col
|
2013-09-07 21:14:26 -07:00
|
|
|
ld a, [hli]
|
|
|
|
ld [de], a
|
|
|
|
inc de
|
|
|
|
dec b
|
2016-01-12 09:46:18 -08:00
|
|
|
jr nz, .col
|
2013-09-07 21:14:26 -07:00
|
|
|
pop hl
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wMapWidth]
|
2018-04-04 13:14:48 -07:00
|
|
|
add 6
|
2013-09-07 21:14:26 -07:00
|
|
|
ld c, a
|
2018-04-04 13:14:48 -07:00
|
|
|
ld b, 0
|
2013-09-07 21:14:26 -07:00
|
|
|
add hl, bc
|
|
|
|
pop bc
|
|
|
|
dec c
|
2016-01-12 09:46:18 -08:00
|
|
|
jr nz, .row
|
2013-09-07 21:14:26 -07:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
SaveScreen::
|
2015-12-13 17:33:56 -08:00
|
|
|
ld hl, wOverworldMapAnchor
|
2013-09-07 21:14:26 -07:00
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
2015-12-14 08:12:18 -08:00
|
|
|
ld de, wScreenSave
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wMapWidth]
|
2015-12-14 08:12:18 -08:00
|
|
|
add 6
|
2020-12-23 13:54:28 -08:00
|
|
|
ldh [hMapObjectIndex], a
|
2015-11-14 20:02:38 -08:00
|
|
|
ld a, [wPlayerStepDirection]
|
2013-09-07 21:14:26 -07:00
|
|
|
and a
|
2015-11-12 21:49:27 -08:00
|
|
|
jr z, .down
|
|
|
|
cp UP
|
|
|
|
jr z, .up
|
|
|
|
cp LEFT
|
|
|
|
jr z, .left
|
|
|
|
cp RIGHT
|
|
|
|
jr z, .right
|
2013-09-07 21:14:26 -07:00
|
|
|
ret
|
|
|
|
|
2015-11-12 21:49:27 -08:00
|
|
|
.up
|
2018-04-04 13:14:48 -07:00
|
|
|
ld de, wScreenSave + SCREEN_META_WIDTH
|
2020-12-23 13:54:28 -08:00
|
|
|
ldh a, [hMapObjectIndex]
|
2013-09-07 21:14:26 -07:00
|
|
|
ld c, a
|
2018-04-04 13:14:48 -07:00
|
|
|
ld b, 0
|
2013-09-07 21:14:26 -07:00
|
|
|
add hl, bc
|
2015-11-12 21:49:27 -08:00
|
|
|
jr .vertical
|
2013-09-07 21:14:26 -07:00
|
|
|
|
2015-11-12 21:49:27 -08:00
|
|
|
.down
|
2015-12-14 08:12:18 -08:00
|
|
|
ld de, wScreenSave
|
2015-11-12 21:49:27 -08:00
|
|
|
.vertical
|
2018-04-04 13:14:48 -07:00
|
|
|
ld b, SCREEN_META_WIDTH
|
|
|
|
ld c, SCREEN_META_HEIGHT - 1
|
2019-11-18 09:16:50 -08:00
|
|
|
jr SaveScreen_LoadConnection
|
2013-09-07 21:14:26 -07:00
|
|
|
|
2015-11-12 21:49:27 -08:00
|
|
|
.left
|
2015-12-14 08:12:18 -08:00
|
|
|
ld de, wScreenSave + 1
|
2013-09-07 21:14:26 -07:00
|
|
|
inc hl
|
2015-11-12 21:49:27 -08:00
|
|
|
jr .horizontal
|
2013-09-07 21:14:26 -07:00
|
|
|
|
2015-11-12 21:49:27 -08:00
|
|
|
.right
|
2015-12-14 08:12:18 -08:00
|
|
|
ld de, wScreenSave
|
2015-11-12 21:49:27 -08:00
|
|
|
.horizontal
|
2018-04-04 13:14:48 -07:00
|
|
|
ld b, SCREEN_META_WIDTH - 1
|
|
|
|
ld c, SCREEN_META_HEIGHT
|
2019-11-18 09:16:50 -08:00
|
|
|
jr SaveScreen_LoadConnection
|
2014-01-26 19:07:19 -08:00
|
|
|
|
2019-11-18 09:16:50 -08:00
|
|
|
LoadConnectionBlockData::
|
2015-12-13 17:33:56 -08:00
|
|
|
ld hl, wOverworldMapAnchor
|
2013-09-07 21:14:26 -07:00
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wMapWidth]
|
2015-12-14 08:12:18 -08:00
|
|
|
add 6
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hConnectionStripLength], a
|
2015-12-14 08:12:18 -08:00
|
|
|
ld de, wScreenSave
|
2018-04-04 13:14:48 -07:00
|
|
|
ld b, SCREEN_META_WIDTH
|
|
|
|
ld c, SCREEN_META_HEIGHT
|
2013-09-07 21:14:26 -07:00
|
|
|
|
2019-11-18 09:16:50 -08:00
|
|
|
SaveScreen_LoadConnection::
|
2015-12-14 08:12:18 -08:00
|
|
|
.row
|
2013-09-07 21:14:26 -07:00
|
|
|
push bc
|
|
|
|
push hl
|
|
|
|
push de
|
2015-12-14 08:12:18 -08:00
|
|
|
.col
|
2013-09-07 21:14:26 -07:00
|
|
|
ld a, [de]
|
|
|
|
inc de
|
|
|
|
ld [hli], a
|
|
|
|
dec b
|
2015-12-14 08:12:18 -08:00
|
|
|
jr nz, .col
|
2013-09-07 21:14:26 -07:00
|
|
|
pop de
|
|
|
|
ld a, e
|
2015-12-14 08:12:18 -08:00
|
|
|
add 6
|
2013-09-07 21:14:26 -07:00
|
|
|
ld e, a
|
2015-11-12 21:49:27 -08:00
|
|
|
jr nc, .okay
|
2013-09-07 21:14:26 -07:00
|
|
|
inc d
|
2015-11-12 21:49:27 -08:00
|
|
|
.okay
|
2013-09-07 21:14:26 -07:00
|
|
|
pop hl
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hConnectionStripLength]
|
2013-09-07 21:14:26 -07:00
|
|
|
ld c, a
|
2015-12-14 08:12:18 -08:00
|
|
|
ld b, 0
|
2013-09-07 21:14:26 -07:00
|
|
|
add hl, bc
|
|
|
|
pop bc
|
|
|
|
dec c
|
2015-12-14 08:12:18 -08:00
|
|
|
jr nz, .row
|
2013-09-07 21:14:26 -07:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
GetMovementPermissions::
|
2013-09-07 21:14:26 -07:00
|
|
|
xor a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wTilePermissions], a
|
2016-01-06 04:44:50 -08:00
|
|
|
call .LeftRight
|
|
|
|
call .UpDown
|
2015-11-12 21:49:27 -08:00
|
|
|
; get coords of current tile
|
2022-09-12 06:15:44 -07:00
|
|
|
ld a, [wPlayerMapX]
|
2013-09-07 21:14:26 -07:00
|
|
|
ld d, a
|
2022-09-12 06:15:44 -07:00
|
|
|
ld a, [wPlayerMapY]
|
2013-09-07 21:14:26 -07:00
|
|
|
ld e, a
|
2015-11-12 21:49:27 -08:00
|
|
|
call GetCoordTile
|
2022-09-12 06:15:44 -07:00
|
|
|
ld [wPlayerTile], a
|
2016-01-06 04:44:50 -08:00
|
|
|
call .CheckHiNybble
|
2013-09-07 21:14:26 -07:00
|
|
|
ret nz
|
2015-11-12 21:49:27 -08:00
|
|
|
|
2022-09-12 06:15:44 -07:00
|
|
|
ld a, [wPlayerTile]
|
2013-09-07 21:14:26 -07:00
|
|
|
and 7
|
2016-01-06 04:44:50 -08:00
|
|
|
ld hl, .MovementPermissionsData
|
2013-09-07 21:14:26 -07:00
|
|
|
add l
|
|
|
|
ld l, a
|
|
|
|
ld a, 0
|
|
|
|
adc h
|
|
|
|
ld h, a
|
|
|
|
ld a, [hl]
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wTilePermissions
|
2013-09-07 21:14:26 -07:00
|
|
|
or [hl]
|
|
|
|
ld [hl], a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
.MovementPermissionsData:
|
2017-12-11 12:20:32 -08:00
|
|
|
db DOWN_MASK
|
|
|
|
db UP_MASK
|
|
|
|
db LEFT_MASK
|
|
|
|
db RIGHT_MASK
|
|
|
|
db DOWN_MASK | RIGHT_MASK
|
|
|
|
db UP_MASK | RIGHT_MASK
|
|
|
|
db DOWN_MASK | LEFT_MASK
|
|
|
|
db UP_MASK | LEFT_MASK
|
2013-09-07 21:14:26 -07:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.UpDown:
|
2022-09-12 06:15:44 -07:00
|
|
|
ld a, [wPlayerMapX]
|
2013-09-07 21:14:26 -07:00
|
|
|
ld d, a
|
2022-09-12 06:15:44 -07:00
|
|
|
ld a, [wPlayerMapY]
|
2013-09-07 21:14:26 -07:00
|
|
|
ld e, a
|
2015-11-12 21:49:27 -08:00
|
|
|
|
2013-09-07 21:14:26 -07:00
|
|
|
push de
|
|
|
|
inc e
|
2015-11-12 21:49:27 -08:00
|
|
|
call GetCoordTile
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wTileDown], a
|
2016-01-06 04:44:50 -08:00
|
|
|
call .Down
|
2015-11-12 21:49:27 -08:00
|
|
|
|
2013-09-07 21:14:26 -07:00
|
|
|
pop de
|
|
|
|
dec e
|
2015-11-12 21:49:27 -08:00
|
|
|
call GetCoordTile
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wTileUp], a
|
2016-01-06 04:44:50 -08:00
|
|
|
call .Up
|
2013-09-07 21:14:26 -07:00
|
|
|
ret
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.LeftRight:
|
2022-09-12 06:15:44 -07:00
|
|
|
ld a, [wPlayerMapX]
|
2013-09-07 21:14:26 -07:00
|
|
|
ld d, a
|
2022-09-12 06:15:44 -07:00
|
|
|
ld a, [wPlayerMapY]
|
2013-09-07 21:14:26 -07:00
|
|
|
ld e, a
|
2015-11-12 21:49:27 -08:00
|
|
|
|
2013-09-07 21:14:26 -07:00
|
|
|
push de
|
|
|
|
dec d
|
2015-11-12 21:49:27 -08:00
|
|
|
call GetCoordTile
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wTileLeft], a
|
2016-01-06 04:44:50 -08:00
|
|
|
call .Left
|
2015-11-12 21:49:27 -08:00
|
|
|
|
2013-09-07 21:14:26 -07:00
|
|
|
pop de
|
|
|
|
inc d
|
2015-11-12 21:49:27 -08:00
|
|
|
call GetCoordTile
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wTileRight], a
|
2016-01-06 04:44:50 -08:00
|
|
|
call .Right
|
2013-09-07 21:14:26 -07:00
|
|
|
ret
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.Down:
|
2016-01-06 04:44:50 -08:00
|
|
|
call .CheckHiNybble
|
2013-09-07 21:14:26 -07:00
|
|
|
ret nz
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wTileDown]
|
2019-03-03 10:30:27 -08:00
|
|
|
and %111
|
|
|
|
cp COLL_UP_WALL & %111 ; COLL_UP_BUOY & %111
|
2016-01-06 04:44:50 -08:00
|
|
|
jr z, .ok_down
|
2019-03-03 10:30:27 -08:00
|
|
|
cp COLL_UP_RIGHT_WALL & %111 ; COLL_UP_RIGHT_BUOY & %111
|
2016-01-06 04:44:50 -08:00
|
|
|
jr z, .ok_down
|
2019-03-03 10:30:27 -08:00
|
|
|
cp COLL_UP_LEFT_WALL & %111 ; COLL_UP_LEFT_BUOY & %111
|
2013-09-07 21:14:26 -07:00
|
|
|
ret nz
|
|
|
|
|
2016-01-06 04:44:50 -08:00
|
|
|
.ok_down
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wTilePermissions]
|
2015-11-12 21:49:27 -08:00
|
|
|
or FACE_DOWN
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wTilePermissions], a
|
2013-09-07 21:14:26 -07:00
|
|
|
ret
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.Up:
|
2016-01-06 04:44:50 -08:00
|
|
|
call .CheckHiNybble
|
2013-09-07 21:14:26 -07:00
|
|
|
ret nz
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wTileUp]
|
2019-03-03 10:30:27 -08:00
|
|
|
and %111
|
|
|
|
cp COLL_DOWN_WALL & %111 ; COLL_DOWN_BUOY & %111
|
2016-01-06 04:44:50 -08:00
|
|
|
jr z, .ok_up
|
2019-03-03 10:30:27 -08:00
|
|
|
cp COLL_DOWN_RIGHT_WALL & %111 ; COLL_DOWN_RIGHT_BUOY & %111
|
2016-01-06 04:44:50 -08:00
|
|
|
jr z, .ok_up
|
2019-03-03 10:30:27 -08:00
|
|
|
cp COLL_DOWN_LEFT_WALL & %111 ; COLL_DOWN_LEFT_BUOY & %111
|
2013-09-07 21:14:26 -07:00
|
|
|
ret nz
|
|
|
|
|
2016-01-06 04:44:50 -08:00
|
|
|
.ok_up
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wTilePermissions]
|
2015-11-12 21:49:27 -08:00
|
|
|
or FACE_UP
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wTilePermissions], a
|
2013-09-07 21:14:26 -07:00
|
|
|
ret
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.Right:
|
2016-01-06 04:44:50 -08:00
|
|
|
call .CheckHiNybble
|
2013-09-07 21:14:26 -07:00
|
|
|
ret nz
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wTileRight]
|
2019-03-03 10:30:27 -08:00
|
|
|
and %111
|
|
|
|
cp COLL_LEFT_WALL & %111 ; COLL_LEFT_BUOY & %111
|
2016-01-06 04:44:50 -08:00
|
|
|
jr z, .ok_right
|
2019-03-03 10:30:27 -08:00
|
|
|
cp COLL_DOWN_LEFT_WALL & %111 ; COLL_DOWN_LEFT_BUOY & %111
|
2016-01-06 04:44:50 -08:00
|
|
|
jr z, .ok_right
|
2019-03-03 10:30:27 -08:00
|
|
|
cp COLL_UP_LEFT_WALL & %111 ; COLL_UP_LEFT_BUOY & %111
|
2013-09-07 21:14:26 -07:00
|
|
|
ret nz
|
|
|
|
|
2016-01-06 04:44:50 -08:00
|
|
|
.ok_right
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wTilePermissions]
|
2015-11-12 21:49:27 -08:00
|
|
|
or FACE_RIGHT
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wTilePermissions], a
|
2013-09-07 21:14:26 -07:00
|
|
|
ret
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.Left:
|
2016-01-06 04:44:50 -08:00
|
|
|
call .CheckHiNybble
|
2013-09-07 21:14:26 -07:00
|
|
|
ret nz
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wTileLeft]
|
2019-03-03 10:30:27 -08:00
|
|
|
and %111
|
|
|
|
cp COLL_RIGHT_WALL & %111 ; COLL_RIGHT_BUOY & %111
|
2016-01-06 04:44:50 -08:00
|
|
|
jr z, .ok_left
|
2019-03-03 10:30:27 -08:00
|
|
|
cp COLL_DOWN_RIGHT_WALL & %111 ; COLL_DOWN_RIGHT_BUOY & %111
|
2016-01-06 04:44:50 -08:00
|
|
|
jr z, .ok_left
|
2019-03-03 10:30:27 -08:00
|
|
|
cp COLL_UP_RIGHT_WALL & %111 ; COLL_UP_RIGHT_BUOY & %111
|
2013-09-07 21:14:26 -07:00
|
|
|
ret nz
|
|
|
|
|
2016-01-06 04:44:50 -08:00
|
|
|
.ok_left
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wTilePermissions]
|
2015-11-12 21:49:27 -08:00
|
|
|
or FACE_LEFT
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wTilePermissions], a
|
2013-09-07 21:14:26 -07:00
|
|
|
ret
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.CheckHiNybble:
|
2013-09-07 21:14:26 -07:00
|
|
|
and $f0
|
2018-06-28 19:35:29 -07:00
|
|
|
cp HI_NYBBLE_SIDE_WALLS
|
2013-09-07 21:14:26 -07:00
|
|
|
ret z
|
2019-03-03 10:30:27 -08:00
|
|
|
cp HI_NYBBLE_SIDE_BUOYS
|
2013-09-07 21:14:26 -07:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
GetFacingTileCoord::
|
2013-09-07 21:14:26 -07:00
|
|
|
; Return map coordinates in (d, e) and tile id in a
|
|
|
|
; of the tile the player is facing.
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPlayerDirection]
|
2013-09-07 21:14:26 -07:00
|
|
|
and %1100
|
|
|
|
srl a
|
|
|
|
srl a
|
|
|
|
ld l, a
|
|
|
|
ld h, 0
|
2016-01-06 04:44:50 -08:00
|
|
|
add hl, hl
|
|
|
|
add hl, hl
|
2013-09-07 21:14:26 -07:00
|
|
|
ld de, .Directions
|
|
|
|
add hl, de
|
|
|
|
|
|
|
|
ld d, [hl]
|
|
|
|
inc hl
|
|
|
|
ld e, [hl]
|
|
|
|
inc hl
|
|
|
|
|
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
|
|
|
|
2022-09-12 06:15:44 -07:00
|
|
|
ld a, [wPlayerMapX]
|
2013-09-07 21:14:26 -07:00
|
|
|
add d
|
|
|
|
ld d, a
|
2022-09-12 06:15:44 -07:00
|
|
|
ld a, [wPlayerMapY]
|
2013-09-07 21:14:26 -07:00
|
|
|
add e
|
|
|
|
ld e, a
|
|
|
|
ld a, [hl]
|
|
|
|
ret
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.Directions:
|
2013-09-07 21:14:26 -07:00
|
|
|
; x, y
|
|
|
|
db 0, 1
|
2018-01-23 14:39:09 -08:00
|
|
|
dw wTileDown
|
2013-09-07 21:14:26 -07:00
|
|
|
db 0, -1
|
2018-01-23 14:39:09 -08:00
|
|
|
dw wTileUp
|
2013-09-07 21:14:26 -07:00
|
|
|
db -1, 0
|
2018-01-23 14:39:09 -08:00
|
|
|
dw wTileLeft
|
2013-09-07 21:14:26 -07:00
|
|
|
db 1, 0
|
2018-01-23 14:39:09 -08:00
|
|
|
dw wTileRight
|
2013-09-07 21:14:26 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
GetCoordTile::
|
2015-11-12 21:49:27 -08:00
|
|
|
; Get the collision byte for tile d, e
|
2015-07-15 12:48:44 -07:00
|
|
|
call GetBlockLocation
|
2013-09-07 21:14:26 -07:00
|
|
|
ld a, [hl]
|
|
|
|
and a
|
2015-07-16 15:10:10 -07:00
|
|
|
jr z, .nope
|
2013-09-07 21:14:26 -07:00
|
|
|
ld l, a
|
2020-11-09 12:17:03 -08:00
|
|
|
ld h, 0
|
2016-01-06 04:44:50 -08:00
|
|
|
add hl, hl
|
|
|
|
add hl, hl
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wTilesetCollisionAddress]
|
2013-09-07 21:14:26 -07:00
|
|
|
ld c, a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wTilesetCollisionAddress + 1]
|
2013-09-07 21:14:26 -07:00
|
|
|
ld b, a
|
|
|
|
add hl, bc
|
|
|
|
rr d
|
2015-07-16 15:10:10 -07:00
|
|
|
jr nc, .nocarry
|
2013-09-07 21:14:26 -07:00
|
|
|
inc hl
|
|
|
|
|
2015-07-16 15:10:10 -07:00
|
|
|
.nocarry
|
2013-09-07 21:14:26 -07:00
|
|
|
rr e
|
2015-07-16 15:10:10 -07:00
|
|
|
jr nc, .nocarry2
|
2013-09-07 21:14:26 -07:00
|
|
|
inc hl
|
2016-01-06 04:44:50 -08:00
|
|
|
inc hl
|
2013-09-07 21:14:26 -07:00
|
|
|
|
2015-07-16 15:10:10 -07:00
|
|
|
.nocarry2
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wTilesetCollisionBank]
|
2013-09-07 21:14:26 -07:00
|
|
|
call GetFarByte
|
|
|
|
ret
|
|
|
|
|
2015-07-16 15:10:10 -07:00
|
|
|
.nope
|
|
|
|
ld a, -1
|
2013-09-07 21:14:26 -07:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
GetBlockLocation::
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wMapWidth]
|
2015-07-18 20:45:39 -07:00
|
|
|
add 6
|
2013-09-07 21:14:26 -07:00
|
|
|
ld c, a
|
2015-07-18 20:45:39 -07:00
|
|
|
ld b, 0
|
2018-03-19 08:36:14 -07:00
|
|
|
ld hl, wOverworldMapBlocks + 1
|
2013-09-07 21:14:26 -07:00
|
|
|
add hl, bc
|
|
|
|
ld a, e
|
|
|
|
srl a
|
2015-07-16 15:10:10 -07:00
|
|
|
jr z, .nope
|
2013-09-07 21:14:26 -07:00
|
|
|
and a
|
2015-07-16 15:10:10 -07:00
|
|
|
.loop
|
2013-09-07 21:14:26 -07:00
|
|
|
srl a
|
2015-07-16 15:10:10 -07:00
|
|
|
jr nc, .ok
|
2013-09-07 21:14:26 -07:00
|
|
|
add hl, bc
|
|
|
|
|
2015-07-16 15:10:10 -07:00
|
|
|
.ok
|
2013-09-07 21:14:26 -07:00
|
|
|
sla c
|
|
|
|
rl b
|
|
|
|
and a
|
2015-07-16 15:10:10 -07:00
|
|
|
jr nz, .loop
|
2013-09-07 21:14:26 -07:00
|
|
|
|
2015-07-16 15:10:10 -07:00
|
|
|
.nope
|
2013-09-07 21:14:26 -07:00
|
|
|
ld c, d
|
|
|
|
srl c
|
2015-07-18 20:45:39 -07:00
|
|
|
ld b, 0
|
2013-09-07 21:14:26 -07:00
|
|
|
add hl, bc
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
CheckFacingBGEvent::
|
2013-09-07 21:14:26 -07:00
|
|
|
call GetFacingTileCoord
|
2015-07-16 15:10:10 -07:00
|
|
|
; Load facing into b.
|
2013-09-07 21:14:26 -07:00
|
|
|
ld b, a
|
2015-07-16 15:10:10 -07:00
|
|
|
; Convert the coordinates at de to within-boundaries coordinates.
|
2013-09-07 21:14:26 -07:00
|
|
|
ld a, d
|
|
|
|
sub 4
|
|
|
|
ld d, a
|
|
|
|
ld a, e
|
|
|
|
sub 4
|
|
|
|
ld e, a
|
2017-12-24 10:46:34 -08:00
|
|
|
; If there are no BG events, we don't need to be here.
|
2018-09-09 12:09:51 -07:00
|
|
|
ld a, [wCurMapBGEventCount]
|
2013-09-07 21:14:26 -07:00
|
|
|
and a
|
|
|
|
ret z
|
2015-11-12 08:10:19 -08:00
|
|
|
|
2013-09-07 21:14:26 -07:00
|
|
|
ld c, a
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hROMBank]
|
2013-09-07 21:14:26 -07:00
|
|
|
push af
|
2018-01-16 19:57:19 -08:00
|
|
|
call SwitchToMapScriptsBank
|
2017-12-24 10:46:34 -08:00
|
|
|
call CheckIfFacingTileCoordIsBGEvent
|
2013-09-07 21:14:26 -07:00
|
|
|
pop hl
|
|
|
|
ld a, h
|
|
|
|
rst Bankswitch
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
CheckIfFacingTileCoordIsBGEvent::
|
2019-04-08 15:50:10 -07:00
|
|
|
; Checks to see if you are facing a BG event. If so, copies it into wCurBGEvent and sets carry.
|
2018-09-09 12:09:51 -07:00
|
|
|
ld hl, wCurMapBGEventsPointer
|
2013-09-07 21:14:26 -07:00
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
2015-07-16 15:10:10 -07:00
|
|
|
.loop
|
2013-09-07 21:14:26 -07:00
|
|
|
push hl
|
|
|
|
ld a, [hli]
|
|
|
|
cp e
|
2015-07-16 15:10:10 -07:00
|
|
|
jr nz, .next
|
2013-09-07 21:14:26 -07:00
|
|
|
ld a, [hli]
|
|
|
|
cp d
|
2015-07-16 15:10:10 -07:00
|
|
|
jr nz, .next
|
|
|
|
jr .copysign
|
2013-09-07 21:14:26 -07:00
|
|
|
|
2015-07-16 15:10:10 -07:00
|
|
|
.next
|
2013-09-07 21:14:26 -07:00
|
|
|
pop hl
|
2019-03-03 11:19:16 -08:00
|
|
|
ld a, BG_EVENT_SIZE
|
2013-09-07 21:14:26 -07:00
|
|
|
add l
|
|
|
|
ld l, a
|
2015-07-16 15:10:10 -07:00
|
|
|
jr nc, .nocarry
|
2013-09-07 21:14:26 -07:00
|
|
|
inc h
|
|
|
|
|
2015-07-16 15:10:10 -07:00
|
|
|
.nocarry
|
2013-09-07 21:14:26 -07:00
|
|
|
dec c
|
2015-07-16 15:10:10 -07:00
|
|
|
jr nz, .loop
|
2013-09-07 21:14:26 -07:00
|
|
|
xor a
|
|
|
|
ret
|
|
|
|
|
2015-07-16 15:10:10 -07:00
|
|
|
.copysign
|
2013-09-07 21:14:26 -07:00
|
|
|
pop hl
|
2019-04-08 15:50:10 -07:00
|
|
|
ld de, wCurBGEvent
|
2019-03-03 11:19:16 -08:00
|
|
|
ld bc, BG_EVENT_SIZE
|
2013-09-07 21:14:26 -07:00
|
|
|
call CopyBytes
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
CheckCurrentMapCoordEvents::
|
2017-12-24 10:46:34 -08:00
|
|
|
; If there are no coord events, we don't need to be here.
|
2018-09-09 12:09:51 -07:00
|
|
|
ld a, [wCurMapCoordEventCount]
|
2013-09-07 21:14:26 -07:00
|
|
|
and a
|
|
|
|
ret z
|
2017-12-24 10:46:34 -08:00
|
|
|
; Copy the coord event count into c.
|
2013-09-07 21:14:26 -07:00
|
|
|
ld c, a
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hROMBank]
|
2013-09-07 21:14:26 -07:00
|
|
|
push af
|
2018-01-16 19:57:19 -08:00
|
|
|
call SwitchToMapScriptsBank
|
2017-12-24 10:46:34 -08:00
|
|
|
call .CoordEventCheck
|
2013-09-07 21:14:26 -07:00
|
|
|
pop hl
|
|
|
|
ld a, h
|
|
|
|
rst Bankswitch
|
|
|
|
ret
|
|
|
|
|
2017-12-24 10:46:34 -08:00
|
|
|
.CoordEventCheck:
|
2019-04-08 15:50:10 -07:00
|
|
|
; Checks to see if you are standing on a coord event. If yes, copies the event to wCurCoordEvent and sets carry.
|
2018-09-09 12:09:51 -07:00
|
|
|
ld hl, wCurMapCoordEventsPointer
|
2013-09-07 21:14:26 -07:00
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
2017-12-24 10:46:34 -08:00
|
|
|
; Load the active scene ID into b
|
|
|
|
call CheckScenes
|
2013-09-07 21:14:26 -07:00
|
|
|
ld b, a
|
2017-12-24 10:46:34 -08:00
|
|
|
; Load your current coordinates into de. This will be used to check if your position is in the coord event table for the current map.
|
2022-09-12 06:15:44 -07:00
|
|
|
ld a, [wPlayerMapX]
|
2015-07-16 15:10:10 -07:00
|
|
|
sub 4
|
2013-09-07 21:14:26 -07:00
|
|
|
ld d, a
|
2022-09-12 06:15:44 -07:00
|
|
|
ld a, [wPlayerMapY]
|
2015-07-16 15:10:10 -07:00
|
|
|
sub 4
|
2013-09-07 21:14:26 -07:00
|
|
|
ld e, a
|
2015-07-16 15:10:10 -07:00
|
|
|
|
|
|
|
.loop
|
2013-09-07 21:14:26 -07:00
|
|
|
push hl
|
|
|
|
ld a, [hli]
|
|
|
|
cp b
|
2015-07-16 15:10:10 -07:00
|
|
|
jr z, .got_id
|
|
|
|
cp -1
|
|
|
|
jr nz, .next
|
2013-09-07 21:14:26 -07:00
|
|
|
|
2015-07-16 15:10:10 -07:00
|
|
|
.got_id
|
2013-09-07 21:14:26 -07:00
|
|
|
ld a, [hli]
|
|
|
|
cp e
|
2015-07-16 15:10:10 -07:00
|
|
|
jr nz, .next
|
2013-09-07 21:14:26 -07:00
|
|
|
ld a, [hli]
|
|
|
|
cp d
|
2015-07-16 15:10:10 -07:00
|
|
|
jr nz, .next
|
2017-12-24 10:46:34 -08:00
|
|
|
jr .copy_coord_event
|
2013-09-07 21:14:26 -07:00
|
|
|
|
2015-07-16 15:10:10 -07:00
|
|
|
.next
|
2013-09-07 21:14:26 -07:00
|
|
|
pop hl
|
2019-03-03 11:19:16 -08:00
|
|
|
ld a, COORD_EVENT_SIZE
|
2013-09-07 21:14:26 -07:00
|
|
|
add l
|
|
|
|
ld l, a
|
2015-07-16 15:10:10 -07:00
|
|
|
jr nc, .nocarry
|
2013-09-07 21:14:26 -07:00
|
|
|
inc h
|
|
|
|
|
2015-07-16 15:10:10 -07:00
|
|
|
.nocarry
|
2013-09-07 21:14:26 -07:00
|
|
|
dec c
|
2015-07-16 15:10:10 -07:00
|
|
|
jr nz, .loop
|
2013-09-07 21:14:26 -07:00
|
|
|
xor a
|
|
|
|
ret
|
|
|
|
|
2017-12-24 10:46:34 -08:00
|
|
|
.copy_coord_event
|
2013-09-07 21:14:26 -07:00
|
|
|
pop hl
|
2019-04-08 15:50:10 -07:00
|
|
|
ld de, wCurCoordEvent
|
2019-03-03 11:19:16 -08:00
|
|
|
ld bc, COORD_EVENT_SIZE
|
2013-09-07 21:14:26 -07:00
|
|
|
call CopyBytes
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
FadeToMenu::
|
2013-09-07 21:14:26 -07:00
|
|
|
xor a
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hBGMapMode], a
|
2018-01-23 13:08:43 -08:00
|
|
|
call LoadStandardMenuHeader
|
2023-08-04 14:54:53 -07:00
|
|
|
farcall FadeOutPalettesToWhite
|
2013-09-07 21:14:26 -07:00
|
|
|
call ClearSprites
|
2015-10-24 07:34:19 -07:00
|
|
|
call DisableSpriteUpdates
|
2013-09-07 21:14:26 -07:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
CloseSubmenu::
|
2015-11-11 20:38:57 -08:00
|
|
|
call ClearBGPalettes
|
2015-12-18 17:07:09 -08:00
|
|
|
call ReloadTilesetAndPalettes
|
2015-07-22 12:57:02 -07:00
|
|
|
call UpdateSprites
|
2015-09-09 16:27:07 -07:00
|
|
|
call Call_ExitMenu
|
2016-01-06 04:44:50 -08:00
|
|
|
jr FinishExitMenu
|
2013-09-07 21:14:26 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
ExitAllMenus::
|
2015-11-11 20:38:57 -08:00
|
|
|
call ClearBGPalettes
|
2015-09-09 16:27:07 -07:00
|
|
|
call Call_ExitMenu
|
2015-12-18 17:07:09 -08:00
|
|
|
call ReloadTilesetAndPalettes
|
2015-07-22 12:57:02 -07:00
|
|
|
call UpdateSprites
|
2018-06-24 07:09:41 -07:00
|
|
|
FinishExitMenu::
|
2023-07-26 08:01:20 -07:00
|
|
|
ld b, CGB_MAPPALS
|
|
|
|
call GetCGBLayout
|
2015-12-11 13:59:40 -08:00
|
|
|
call WaitBGMap2
|
2023-08-04 14:54:53 -07:00
|
|
|
farcall FadeInPalettesFromWhite
|
2015-10-24 07:34:19 -07:00
|
|
|
call EnableSpriteUpdates
|
2013-09-07 21:14:26 -07:00
|
|
|
ret
|
|
|
|
|
2018-06-24 17:10:37 -07:00
|
|
|
ReturnToMapWithSpeechTextbox::
|
2013-09-07 21:14:26 -07:00
|
|
|
push af
|
|
|
|
ld a, $1
|
2015-11-25 07:16:29 -08:00
|
|
|
ld [wSpriteUpdatesEnabled], a
|
2015-11-11 20:38:57 -08:00
|
|
|
call ClearBGPalettes
|
2013-09-07 21:14:26 -07:00
|
|
|
call ClearSprites
|
2015-12-18 17:07:09 -08:00
|
|
|
call ReloadTilesetAndPalettes
|
2023-09-22 14:12:05 -07:00
|
|
|
call SpeechTextbox ; 1bpp or 2bpp according to wTextboxFlags[TEXT_2BPP_F]
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wVramState
|
2013-09-07 21:14:26 -07:00
|
|
|
set 0, [hl]
|
2015-07-22 12:57:02 -07:00
|
|
|
call UpdateSprites
|
2015-12-11 13:59:40 -08:00
|
|
|
call WaitBGMap2
|
2023-07-26 08:01:20 -07:00
|
|
|
ld b, CGB_MAPPALS
|
|
|
|
call GetCGBLayout
|
2013-09-07 21:14:26 -07:00
|
|
|
call UpdateTimePals
|
|
|
|
call DelayFrame
|
|
|
|
ld a, $1
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hMapAnims], a
|
2013-09-07 21:14:26 -07:00
|
|
|
pop af
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
ReloadTilesetAndPalettes::
|
2013-09-07 21:14:26 -07:00
|
|
|
call DisableLCD
|
|
|
|
call ClearSprites
|
2018-01-24 08:17:05 -08:00
|
|
|
farcall RefreshSprites
|
2023-09-30 15:10:44 -07:00
|
|
|
ld a, [wText2bpp]
|
|
|
|
and a
|
2023-09-22 14:12:05 -07:00
|
|
|
jr nz, .2bpp
|
2015-11-04 13:14:27 -08:00
|
|
|
call LoadStandardFont
|
2023-08-02 10:52:51 -07:00
|
|
|
call LoadFrame
|
2023-09-22 14:12:05 -07:00
|
|
|
jr .font_done
|
|
|
|
.2bpp
|
|
|
|
call LoadOverworldFontAndFrame
|
|
|
|
.font_done
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hROMBank]
|
2013-09-07 21:14:26 -07:00
|
|
|
push af
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wMapGroup]
|
2013-09-07 21:14:26 -07:00
|
|
|
ld b, a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wMapNumber]
|
2013-09-07 21:14:26 -07:00
|
|
|
ld c, a
|
2018-02-03 13:58:49 -08:00
|
|
|
call SwitchToAnyMapAttributesBank
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall UpdateTimeOfDayPal
|
2023-08-28 04:30:13 -07:00
|
|
|
call LoadScreenTilemapAndAttrmapPals
|
2017-12-26 09:50:32 -08:00
|
|
|
call LoadTilesetGFX
|
2014-05-21 13:21:46 -07:00
|
|
|
ld a, 9
|
|
|
|
call SkipMusic
|
2013-09-07 21:14:26 -07:00
|
|
|
pop af
|
|
|
|
rst Bankswitch
|
|
|
|
|
|
|
|
call EnableLCD
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
GetMapPointer::
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wMapGroup]
|
2013-09-07 21:14:26 -07:00
|
|
|
ld b, a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wMapNumber]
|
2013-09-07 21:14:26 -07:00
|
|
|
ld c, a
|
2018-06-24 17:10:37 -07:00
|
|
|
GetAnyMapPointer::
|
2013-09-07 21:14:26 -07:00
|
|
|
; Prior to calling this function, you must have switched banks so that
|
|
|
|
; MapGroupPointers is visible.
|
|
|
|
|
|
|
|
; inputs:
|
|
|
|
; b = map group, c = map number
|
|
|
|
|
|
|
|
; outputs:
|
2018-02-03 13:58:49 -08:00
|
|
|
; hl points to the map within its group
|
2013-09-07 21:14:26 -07:00
|
|
|
push bc ; save map number for later
|
|
|
|
|
|
|
|
; get pointer to map group
|
|
|
|
dec b
|
|
|
|
ld c, b
|
2014-06-24 09:06:19 -07:00
|
|
|
ld b, 0
|
2013-09-07 21:14:26 -07:00
|
|
|
ld hl, MapGroupPointers
|
|
|
|
add hl, bc
|
2016-01-06 04:44:50 -08:00
|
|
|
add hl, bc
|
2013-09-07 21:14:26 -07:00
|
|
|
|
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
|
|
|
pop bc ; restore map number
|
|
|
|
|
2018-02-03 13:58:49 -08:00
|
|
|
; find the cth map within the group
|
2013-09-07 21:14:26 -07:00
|
|
|
dec c
|
2014-06-24 09:06:19 -07:00
|
|
|
ld b, 0
|
2021-12-30 15:16:22 -08:00
|
|
|
ld a, MAP_LENGTH
|
2013-09-07 21:14:26 -07:00
|
|
|
call AddNTimes
|
|
|
|
ret
|
|
|
|
|
2018-06-24 17:10:37 -07:00
|
|
|
GetMapField::
|
2018-02-03 13:58:49 -08:00
|
|
|
; Extract data from the current map's group entry.
|
2013-09-07 21:14:26 -07:00
|
|
|
|
|
|
|
; inputs:
|
2018-02-03 13:58:49 -08:00
|
|
|
; de = offset of desired data within the map (a MAP_* constant)
|
2013-09-07 21:14:26 -07:00
|
|
|
|
|
|
|
; outputs:
|
2018-02-03 13:58:49 -08:00
|
|
|
; bc = data from the current map's field
|
|
|
|
; (e.g., de = MAP_TILESET would return a pointer to the tileset id)
|
2013-09-07 21:14:26 -07:00
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wMapGroup]
|
2013-09-07 21:14:26 -07:00
|
|
|
ld b, a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wMapNumber]
|
2013-09-07 21:14:26 -07:00
|
|
|
ld c, a
|
2018-06-24 17:10:37 -07:00
|
|
|
GetAnyMapField::
|
2013-09-07 21:14:26 -07:00
|
|
|
; bankswitch
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hROMBank]
|
2013-09-07 21:14:26 -07:00
|
|
|
push af
|
|
|
|
ld a, BANK(MapGroupPointers)
|
|
|
|
rst Bankswitch
|
|
|
|
|
2018-02-03 13:58:49 -08:00
|
|
|
call GetAnyMapPointer
|
2013-09-07 21:14:26 -07:00
|
|
|
add hl, de
|
|
|
|
ld c, [hl]
|
|
|
|
inc hl
|
|
|
|
ld b, [hl]
|
|
|
|
|
|
|
|
; bankswitch back
|
|
|
|
pop af
|
|
|
|
rst Bankswitch
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
SwitchToMapAttributesBank::
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wMapGroup]
|
2013-09-07 21:14:26 -07:00
|
|
|
ld b, a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wMapNumber]
|
2013-09-07 21:14:26 -07:00
|
|
|
ld c, a
|
2018-06-24 07:09:41 -07:00
|
|
|
SwitchToAnyMapAttributesBank::
|
2018-02-03 13:58:49 -08:00
|
|
|
call GetAnyMapAttributesBank
|
2013-09-07 21:14:26 -07:00
|
|
|
rst Bankswitch
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
GetAnyMapAttributesBank::
|
2013-09-07 21:14:26 -07:00
|
|
|
push hl
|
|
|
|
push de
|
2018-02-03 13:58:49 -08:00
|
|
|
ld de, MAP_MAPATTRIBUTES_BANK
|
|
|
|
call GetAnyMapField
|
2013-09-07 21:14:26 -07:00
|
|
|
ld a, c
|
|
|
|
pop de
|
|
|
|
pop hl
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
CopyMapPartial::
|
2018-01-16 19:57:19 -08:00
|
|
|
; Copy map data bank, tileset, environment, and map data address
|
2018-02-03 13:58:49 -08:00
|
|
|
; from the current map's entry within its group.
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hROMBank]
|
2013-09-07 21:14:26 -07:00
|
|
|
push af
|
2014-12-26 15:31:48 -08:00
|
|
|
ld a, BANK(MapGroupPointers)
|
2013-09-07 21:14:26 -07:00
|
|
|
rst Bankswitch
|
2015-11-12 08:10:19 -08:00
|
|
|
|
2018-02-03 13:58:49 -08:00
|
|
|
call GetMapPointer
|
|
|
|
ld de, wMapPartial
|
|
|
|
ld bc, wMapPartialEnd - wMapPartial
|
2013-09-07 21:14:26 -07:00
|
|
|
call CopyBytes
|
2015-11-12 08:10:19 -08:00
|
|
|
|
2013-09-07 21:14:26 -07:00
|
|
|
pop af
|
|
|
|
rst Bankswitch
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
SwitchToMapScriptsBank::
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wMapScriptsBank]
|
2013-09-07 21:14:26 -07:00
|
|
|
rst Bankswitch
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
GetMapScriptsBank::
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wMapScriptsBank]
|
2013-09-07 21:14:26 -07:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
GetAnyMapBlocksBank::
|
2013-09-07 21:14:26 -07:00
|
|
|
; Return the blockdata bank for group b map c.
|
|
|
|
push hl
|
|
|
|
push de
|
|
|
|
push bc
|
|
|
|
|
|
|
|
push bc
|
2018-02-03 13:58:49 -08:00
|
|
|
ld de, MAP_MAPATTRIBUTES
|
|
|
|
call GetAnyMapField
|
2013-09-07 21:14:26 -07:00
|
|
|
ld l, c
|
|
|
|
ld h, b
|
|
|
|
pop bc
|
|
|
|
|
|
|
|
push hl
|
2018-02-03 13:58:49 -08:00
|
|
|
ld de, MAP_MAPATTRIBUTES_BANK
|
|
|
|
call GetAnyMapField
|
2013-09-07 21:14:26 -07:00
|
|
|
pop hl
|
|
|
|
|
2018-02-03 13:58:49 -08:00
|
|
|
ld de, MAP_MAPATTRIBUTES ; blockdata bank
|
2013-09-07 21:14:26 -07:00
|
|
|
add hl, de
|
|
|
|
ld a, c
|
|
|
|
call GetFarByte
|
|
|
|
rst Bankswitch
|
|
|
|
|
|
|
|
pop bc
|
|
|
|
pop de
|
|
|
|
pop hl
|
|
|
|
ret
|
|
|
|
|
2018-06-24 17:10:37 -07:00
|
|
|
GetMapAttributesPointer::
|
2018-01-16 19:57:19 -08:00
|
|
|
; returns the current map's data pointer in hl.
|
2013-09-07 21:14:26 -07:00
|
|
|
push bc
|
|
|
|
push de
|
2018-02-03 13:58:49 -08:00
|
|
|
ld de, MAP_MAPATTRIBUTES
|
|
|
|
call GetMapField
|
2013-09-07 21:14:26 -07:00
|
|
|
ld l, c
|
|
|
|
ld h, b
|
|
|
|
pop de
|
|
|
|
pop bc
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
GetMapEnvironment::
|
2013-09-07 21:14:26 -07:00
|
|
|
push hl
|
|
|
|
push de
|
|
|
|
push bc
|
2018-02-03 13:58:49 -08:00
|
|
|
ld de, MAP_ENVIRONMENT
|
|
|
|
call GetMapField
|
2013-09-07 21:14:26 -07:00
|
|
|
ld a, c
|
|
|
|
pop bc
|
|
|
|
pop de
|
|
|
|
pop hl
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
GetAnyMapEnvironment::
|
2013-09-07 21:14:26 -07:00
|
|
|
push hl
|
|
|
|
push de
|
|
|
|
push bc
|
2018-02-03 13:58:49 -08:00
|
|
|
ld de, MAP_ENVIRONMENT
|
|
|
|
call GetAnyMapField
|
2013-09-07 21:14:26 -07:00
|
|
|
ld a, c
|
|
|
|
pop bc
|
|
|
|
pop de
|
|
|
|
pop hl
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
GetAnyMapTileset::
|
2018-02-03 13:58:49 -08:00
|
|
|
ld de, MAP_TILESET
|
|
|
|
call GetAnyMapField
|
2013-09-07 21:14:26 -07:00
|
|
|
ld a, c
|
|
|
|
ret
|
|
|
|
|
2018-06-24 17:10:37 -07:00
|
|
|
GetWorldMapLocation::
|
2013-09-07 21:14:26 -07:00
|
|
|
; given a map group/id in bc, return its location on the Pokégear map.
|
|
|
|
push hl
|
|
|
|
push de
|
|
|
|
push bc
|
2015-11-12 08:10:19 -08:00
|
|
|
|
2018-02-03 13:58:49 -08:00
|
|
|
ld de, MAP_LOCATION
|
|
|
|
call GetAnyMapField
|
2013-09-07 21:14:26 -07:00
|
|
|
ld a, c
|
2015-11-12 08:10:19 -08:00
|
|
|
|
2013-09-07 21:14:26 -07:00
|
|
|
pop bc
|
|
|
|
pop de
|
|
|
|
pop hl
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
GetMapMusic::
|
2013-09-07 21:14:26 -07:00
|
|
|
push hl
|
|
|
|
push bc
|
2018-02-03 13:58:49 -08:00
|
|
|
ld de, MAP_MUSIC
|
|
|
|
call GetMapField
|
2013-09-07 21:14:26 -07:00
|
|
|
ld a, c
|
2014-05-21 13:21:46 -07:00
|
|
|
cp MUSIC_MAHOGANY_MART
|
|
|
|
jr z, .mahoganymart
|
2017-12-10 17:50:08 -08:00
|
|
|
bit RADIO_TOWER_MUSIC_F, c
|
2014-05-21 13:21:46 -07:00
|
|
|
jr nz, .radiotower
|
2013-09-07 21:14:26 -07:00
|
|
|
ld e, c
|
2014-05-21 13:21:46 -07:00
|
|
|
ld d, 0
|
|
|
|
.done
|
2013-09-07 21:14:26 -07:00
|
|
|
pop bc
|
|
|
|
pop hl
|
|
|
|
ret
|
|
|
|
|
2014-05-21 13:21:46 -07:00
|
|
|
.radiotower
|
2017-12-28 04:15:46 -08:00
|
|
|
ld a, [wStatusFlags2]
|
2018-01-22 12:40:43 -08:00
|
|
|
bit STATUSFLAGS2_ROCKETS_IN_RADIO_TOWER_F, a
|
2014-05-21 13:21:46 -07:00
|
|
|
jr z, .clearedradiotower
|
|
|
|
ld de, MUSIC_ROCKET_OVERTURE
|
|
|
|
jr .done
|
2013-09-07 21:14:26 -07:00
|
|
|
|
2014-05-21 13:21:46 -07:00
|
|
|
.clearedradiotower
|
|
|
|
; the rest of the byte
|
2013-09-07 21:14:26 -07:00
|
|
|
ld a, c
|
2017-12-10 17:50:08 -08:00
|
|
|
and RADIO_TOWER_MUSIC - 1
|
2013-09-07 21:14:26 -07:00
|
|
|
ld e, a
|
2014-05-21 13:21:46 -07:00
|
|
|
ld d, 0
|
|
|
|
jr .done
|
2013-09-07 21:14:26 -07:00
|
|
|
|
2014-05-21 13:21:46 -07:00
|
|
|
.mahoganymart
|
2017-12-28 04:15:46 -08:00
|
|
|
ld a, [wStatusFlags2]
|
2018-01-22 12:40:43 -08:00
|
|
|
bit STATUSFLAGS2_ROCKETS_IN_MAHOGANY_F, a
|
2014-05-21 13:21:46 -07:00
|
|
|
jr z, .clearedmahogany
|
|
|
|
ld de, MUSIC_ROCKET_HIDEOUT
|
|
|
|
jr .done
|
2013-09-07 21:14:26 -07:00
|
|
|
|
2014-05-21 13:21:46 -07:00
|
|
|
.clearedmahogany
|
|
|
|
ld de, MUSIC_CHERRYGROVE_CITY
|
|
|
|
jr .done
|
2013-09-07 21:14:26 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
GetMapTimeOfDay::
|
2015-07-20 00:51:52 -07:00
|
|
|
call GetPhoneServiceTimeOfDayByte
|
2013-09-07 21:14:26 -07:00
|
|
|
and $f
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
GetMapPhoneService::
|
2015-07-20 00:51:52 -07:00
|
|
|
call GetPhoneServiceTimeOfDayByte
|
2013-09-07 21:14:26 -07:00
|
|
|
and $f0
|
|
|
|
swap a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
GetPhoneServiceTimeOfDayByte::
|
2013-09-07 21:14:26 -07:00
|
|
|
push hl
|
|
|
|
push bc
|
2015-11-12 08:10:19 -08:00
|
|
|
|
2018-02-03 13:58:49 -08:00
|
|
|
ld de, MAP_PALETTE
|
|
|
|
call GetMapField
|
2013-09-07 21:14:26 -07:00
|
|
|
ld a, c
|
2015-11-12 08:10:19 -08:00
|
|
|
|
2013-09-07 21:14:26 -07:00
|
|
|
pop bc
|
|
|
|
pop hl
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
GetFishingGroup::
|
2013-09-07 21:14:26 -07:00
|
|
|
push de
|
|
|
|
push hl
|
|
|
|
push bc
|
2015-11-12 08:10:19 -08:00
|
|
|
|
2018-02-03 13:58:49 -08:00
|
|
|
ld de, MAP_FISHGROUP
|
|
|
|
call GetMapField
|
2013-09-07 21:14:26 -07:00
|
|
|
ld a, c
|
2015-11-12 08:10:19 -08:00
|
|
|
|
2013-09-07 21:14:26 -07:00
|
|
|
pop bc
|
|
|
|
pop hl
|
|
|
|
pop de
|
|
|
|
ret
|
|
|
|
|
2019-11-18 09:16:50 -08:00
|
|
|
LoadMapTileset::
|
2013-09-07 21:14:26 -07:00
|
|
|
push hl
|
|
|
|
push bc
|
2013-12-11 14:23:33 -08:00
|
|
|
|
|
|
|
ld hl, Tilesets
|
2021-03-03 19:22:41 -08:00
|
|
|
ld bc, TILESET_LENGTH
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wMapTileset]
|
2013-09-07 21:14:26 -07:00
|
|
|
call AddNTimes
|
2013-12-11 14:23:33 -08:00
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld de, wTilesetBank
|
2021-03-03 19:22:41 -08:00
|
|
|
ld bc, TILESET_LENGTH
|
2013-12-11 14:23:33 -08:00
|
|
|
|
|
|
|
ld a, BANK(Tilesets)
|
2013-09-07 21:14:26 -07:00
|
|
|
call FarCopyBytes
|
2013-12-11 14:23:33 -08:00
|
|
|
|
2013-09-07 21:14:26 -07:00
|
|
|
pop bc
|
|
|
|
pop hl
|
|
|
|
ret
|