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