2018-06-24 14:09:41 +00:00
|
|
|
HandleNewMap:
|
2019-04-19 15:35:27 +00:00
|
|
|
call ClearUnusedMapBuffer
|
2015-11-30 02:34:59 +00:00
|
|
|
call ResetMapBufferEventFlags
|
|
|
|
call ResetFlashIfOutOfCave
|
2017-12-24 18:46:34 +00:00
|
|
|
call GetCurrentMapSceneID
|
2015-11-30 02:34:59 +00:00
|
|
|
call ResetBikeFlags
|
2016-01-06 12:44:50 +00:00
|
|
|
ld a, MAPCALLBACK_NEWMAP
|
2015-11-30 02:34:59 +00:00
|
|
|
call RunMapCallback
|
2019-11-18 17:16:50 +00:00
|
|
|
HandleContinueMap:
|
2017-12-24 17:47:30 +00:00
|
|
|
farcall ClearCmdQueue
|
2016-01-06 21:59:56 +00:00
|
|
|
ld a, MAPCALLBACK_CMDQUEUE
|
2015-11-30 02:34:59 +00:00
|
|
|
call RunMapCallback
|
2018-01-17 03:57:19 +00:00
|
|
|
call GetMapTimeOfDay
|
2015-12-15 01:06:41 +00:00
|
|
|
ld [wMapTimeOfDay], a
|
2015-11-30 02:34:59 +00:00
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
EnterMapConnection:
|
2015-11-30 02:34:59 +00:00
|
|
|
; Return carry if a connection has been entered.
|
|
|
|
ld a, [wPlayerStepDirection]
|
2018-11-10 13:27:46 +00:00
|
|
|
and a ; DOWN
|
2016-05-17 12:40:42 +00:00
|
|
|
jp z, .south
|
|
|
|
cp UP
|
|
|
|
jp z, .north
|
|
|
|
cp LEFT
|
|
|
|
jp z, .west
|
|
|
|
cp RIGHT
|
|
|
|
jp z, .east
|
2015-11-30 02:34:59 +00:00
|
|
|
ret
|
|
|
|
|
2016-05-17 12:40:42 +00:00
|
|
|
.west
|
2018-01-23 22:39:09 +00:00
|
|
|
ld a, [wWestConnectedMapGroup]
|
|
|
|
ld [wMapGroup], a
|
|
|
|
ld a, [wWestConnectedMapNumber]
|
|
|
|
ld [wMapNumber], a
|
|
|
|
ld a, [wWestConnectionStripXOffset]
|
|
|
|
ld [wXCoord], a
|
|
|
|
ld a, [wWestConnectionStripYOffset]
|
|
|
|
ld hl, wYCoord
|
2015-11-30 02:34:59 +00:00
|
|
|
add [hl]
|
|
|
|
ld [hl], a
|
|
|
|
ld c, a
|
2018-01-23 22:39:09 +00:00
|
|
|
ld hl, wWestConnectionWindow
|
2015-11-30 02:34:59 +00:00
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
|
|
|
srl c
|
|
|
|
jr z, .skip_to_load
|
2018-01-23 22:39:09 +00:00
|
|
|
ld a, [wWestConnectedMapWidth]
|
2015-11-30 02:34:59 +00:00
|
|
|
add 6
|
|
|
|
ld e, a
|
|
|
|
ld d, 0
|
|
|
|
|
|
|
|
.loop
|
|
|
|
add hl, de
|
|
|
|
dec c
|
|
|
|
jr nz, .loop
|
|
|
|
|
|
|
|
.skip_to_load
|
|
|
|
ld a, l
|
2015-12-14 01:33:56 +00:00
|
|
|
ld [wOverworldMapAnchor], a
|
2015-11-30 02:34:59 +00:00
|
|
|
ld a, h
|
2015-12-14 01:33:56 +00:00
|
|
|
ld [wOverworldMapAnchor + 1], a
|
2016-05-17 12:40:42 +00:00
|
|
|
jp .done
|
2015-11-30 02:34:59 +00:00
|
|
|
|
2016-05-17 12:40:42 +00:00
|
|
|
.east
|
2018-01-23 22:39:09 +00:00
|
|
|
ld a, [wEastConnectedMapGroup]
|
|
|
|
ld [wMapGroup], a
|
|
|
|
ld a, [wEastConnectedMapNumber]
|
|
|
|
ld [wMapNumber], a
|
|
|
|
ld a, [wEastConnectionStripXOffset]
|
|
|
|
ld [wXCoord], a
|
|
|
|
ld a, [wEastConnectionStripYOffset]
|
|
|
|
ld hl, wYCoord
|
2015-11-30 02:34:59 +00:00
|
|
|
add [hl]
|
|
|
|
ld [hl], a
|
|
|
|
ld c, a
|
2018-01-23 22:39:09 +00:00
|
|
|
ld hl, wEastConnectionWindow
|
2015-11-30 02:34:59 +00:00
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
|
|
|
srl c
|
2016-05-17 12:40:42 +00:00
|
|
|
jr z, .skip_to_load2
|
2018-01-23 22:39:09 +00:00
|
|
|
ld a, [wEastConnectedMapWidth]
|
2015-11-30 02:34:59 +00:00
|
|
|
add 6
|
|
|
|
ld e, a
|
|
|
|
ld d, 0
|
|
|
|
|
2016-05-17 12:40:42 +00:00
|
|
|
.loop2
|
2015-11-30 02:34:59 +00:00
|
|
|
add hl, de
|
|
|
|
dec c
|
2016-05-17 12:40:42 +00:00
|
|
|
jr nz, .loop2
|
2015-11-30 02:34:59 +00:00
|
|
|
|
2016-05-17 12:40:42 +00:00
|
|
|
.skip_to_load2
|
2015-11-30 02:34:59 +00:00
|
|
|
ld a, l
|
2015-12-14 01:33:56 +00:00
|
|
|
ld [wOverworldMapAnchor], a
|
2015-11-30 02:34:59 +00:00
|
|
|
ld a, h
|
2015-12-14 01:33:56 +00:00
|
|
|
ld [wOverworldMapAnchor + 1], a
|
2016-05-17 12:40:42 +00:00
|
|
|
jp .done
|
2015-11-30 02:34:59 +00:00
|
|
|
|
2016-05-17 12:40:42 +00:00
|
|
|
.north
|
2018-01-23 22:39:09 +00:00
|
|
|
ld a, [wNorthConnectedMapGroup]
|
|
|
|
ld [wMapGroup], a
|
|
|
|
ld a, [wNorthConnectedMapNumber]
|
|
|
|
ld [wMapNumber], a
|
|
|
|
ld a, [wNorthConnectionStripYOffset]
|
|
|
|
ld [wYCoord], a
|
|
|
|
ld a, [wNorthConnectionStripXOffset]
|
|
|
|
ld hl, wXCoord
|
2015-11-30 02:34:59 +00:00
|
|
|
add [hl]
|
|
|
|
ld [hl], a
|
|
|
|
ld c, a
|
2018-01-23 22:39:09 +00:00
|
|
|
ld hl, wNorthConnectionWindow
|
2015-11-30 02:34:59 +00:00
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
|
|
|
ld b, 0
|
|
|
|
srl c
|
|
|
|
add hl, bc
|
|
|
|
ld a, l
|
2015-12-14 01:33:56 +00:00
|
|
|
ld [wOverworldMapAnchor], a
|
2015-11-30 02:34:59 +00:00
|
|
|
ld a, h
|
2015-12-14 01:33:56 +00:00
|
|
|
ld [wOverworldMapAnchor + 1], a
|
2016-05-17 12:40:42 +00:00
|
|
|
jp .done
|
2015-11-30 02:34:59 +00:00
|
|
|
|
2016-05-17 12:40:42 +00:00
|
|
|
.south
|
2018-01-23 22:39:09 +00:00
|
|
|
ld a, [wSouthConnectedMapGroup]
|
|
|
|
ld [wMapGroup], a
|
|
|
|
ld a, [wSouthConnectedMapNumber]
|
|
|
|
ld [wMapNumber], a
|
|
|
|
ld a, [wSouthConnectionStripYOffset]
|
|
|
|
ld [wYCoord], a
|
|
|
|
ld a, [wSouthConnectionStripXOffset]
|
|
|
|
ld hl, wXCoord
|
2015-11-30 02:34:59 +00:00
|
|
|
add [hl]
|
|
|
|
ld [hl], a
|
|
|
|
ld c, a
|
2018-01-23 22:39:09 +00:00
|
|
|
ld hl, wSouthConnectionWindow
|
2015-11-30 02:34:59 +00:00
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
|
|
|
ld b, 0
|
|
|
|
srl c
|
|
|
|
add hl, bc
|
|
|
|
ld a, l
|
2015-12-14 01:33:56 +00:00
|
|
|
ld [wOverworldMapAnchor], a
|
2015-11-30 02:34:59 +00:00
|
|
|
ld a, h
|
2015-12-14 01:33:56 +00:00
|
|
|
ld [wOverworldMapAnchor + 1], a
|
2016-05-17 12:40:42 +00:00
|
|
|
.done
|
2015-11-30 02:34:59 +00:00
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2019-11-18 17:16:50 +00:00
|
|
|
EnterMapWarp:
|
2015-11-30 02:34:59 +00:00
|
|
|
call .SaveDigWarp
|
|
|
|
call .SetSpawn
|
|
|
|
ld a, [wNextWarp]
|
2018-01-23 22:39:09 +00:00
|
|
|
ld [wWarpNumber], a
|
2015-11-30 02:34:59 +00:00
|
|
|
ld a, [wNextMapGroup]
|
2018-01-23 22:39:09 +00:00
|
|
|
ld [wMapGroup], a
|
2015-11-30 02:34:59 +00:00
|
|
|
ld a, [wNextMapNumber]
|
2018-01-23 22:39:09 +00:00
|
|
|
ld [wMapNumber], a
|
2015-11-30 02:34:59 +00:00
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
.SaveDigWarp:
|
2017-12-24 18:08:38 +00:00
|
|
|
call GetMapEnvironment
|
2015-11-30 02:34:59 +00:00
|
|
|
call CheckOutdoorMap
|
|
|
|
ret nz
|
|
|
|
ld a, [wNextMapGroup]
|
|
|
|
ld b, a
|
|
|
|
ld a, [wNextMapNumber]
|
|
|
|
ld c, a
|
2017-12-24 18:08:38 +00:00
|
|
|
call GetAnyMapEnvironment
|
2015-11-30 02:34:59 +00:00
|
|
|
call CheckIndoorMap
|
|
|
|
ret nz
|
2018-01-10 22:30:27 +00:00
|
|
|
|
|
|
|
; MOUNT_MOON_SQUARE and TIN_TOWER_ROOF are outdoor maps within indoor maps.
|
|
|
|
; Dig and Escape Rope should not take you to them.
|
2015-11-30 02:34:59 +00:00
|
|
|
ld a, [wPrevMapGroup]
|
2020-10-27 02:24:38 +00:00
|
|
|
cp GROUP_MOUNT_MOON_SQUARE
|
2021-03-11 02:06:06 +00:00
|
|
|
jr nz, .not_mt_moon_square_or_tin_tower_roof
|
2020-10-27 02:24:38 +00:00
|
|
|
assert GROUP_MOUNT_MOON_SQUARE == GROUP_TIN_TOWER_ROOF
|
2015-11-30 02:34:59 +00:00
|
|
|
ld a, [wPrevMapNumber]
|
|
|
|
cp MAP_MOUNT_MOON_SQUARE
|
|
|
|
ret z
|
|
|
|
cp MAP_TIN_TOWER_ROOF
|
|
|
|
ret z
|
2021-03-11 02:06:06 +00:00
|
|
|
.not_mt_moon_square_or_tin_tower_roof
|
2018-01-10 22:30:27 +00:00
|
|
|
|
2015-11-30 02:34:59 +00:00
|
|
|
ld a, [wPrevWarp]
|
2017-12-10 00:41:03 +00:00
|
|
|
ld [wDigWarpNumber], a
|
2015-11-30 02:34:59 +00:00
|
|
|
ld a, [wPrevMapGroup]
|
|
|
|
ld [wDigMapGroup], a
|
|
|
|
ld a, [wPrevMapNumber]
|
|
|
|
ld [wDigMapNumber], a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
.SetSpawn:
|
2017-12-24 18:08:38 +00:00
|
|
|
call GetMapEnvironment
|
2015-11-30 02:34:59 +00:00
|
|
|
call CheckOutdoorMap
|
|
|
|
ret nz
|
|
|
|
ld a, [wNextMapGroup]
|
|
|
|
ld b, a
|
|
|
|
ld a, [wNextMapNumber]
|
|
|
|
ld c, a
|
2017-12-24 18:08:38 +00:00
|
|
|
call GetAnyMapEnvironment
|
2015-11-30 02:34:59 +00:00
|
|
|
call CheckIndoorMap
|
|
|
|
ret nz
|
|
|
|
ld a, [wNextMapGroup]
|
|
|
|
ld b, a
|
|
|
|
ld a, [wNextMapNumber]
|
|
|
|
ld c, a
|
2018-01-10 22:30:27 +00:00
|
|
|
|
|
|
|
; Respawn in Pokémon Centers.
|
2015-11-30 02:34:59 +00:00
|
|
|
call GetAnyMapTileset
|
|
|
|
ld a, c
|
|
|
|
cp TILESET_POKECENTER
|
|
|
|
jr z, .pokecenter_pokecom
|
|
|
|
cp TILESET_POKECOM_CENTER
|
|
|
|
jr z, .pokecenter_pokecom
|
|
|
|
ret
|
|
|
|
.pokecenter_pokecom
|
2018-01-10 22:30:27 +00:00
|
|
|
|
2015-11-30 02:34:59 +00:00
|
|
|
ld a, [wPrevMapGroup]
|
|
|
|
ld [wLastSpawnMapGroup], a
|
|
|
|
ld a, [wPrevMapNumber]
|
|
|
|
ld [wLastSpawnMapNumber], a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
LoadMapTimeOfDay:
|
2018-01-23 22:39:09 +00:00
|
|
|
ld hl, wVramState
|
2015-11-30 02:34:59 +00:00
|
|
|
res 6, [hl]
|
|
|
|
ld a, $1
|
|
|
|
ld [wSpriteUpdatesEnabled], a
|
2017-12-24 17:47:30 +00:00
|
|
|
farcall ReplaceTimeOfDayPals
|
|
|
|
farcall UpdateTimeOfDayPal
|
2024-01-07 11:38:00 +00:00
|
|
|
call LoadOverworldTilemapAndAttrmapPals
|
2016-05-17 12:40:42 +00:00
|
|
|
call .ClearBGMap
|
2020-02-13 17:30:13 +00:00
|
|
|
call .PushAttrmap
|
2015-11-30 02:34:59 +00:00
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
.ClearBGMap:
|
2017-12-28 12:32:33 +00:00
|
|
|
ld a, HIGH(vBGMap0)
|
2015-11-30 02:34:59 +00:00
|
|
|
ld [wBGMapAnchor + 1], a
|
2017-12-28 12:32:33 +00:00
|
|
|
xor a ; LOW(vBGMap0)
|
2015-11-30 02:34:59 +00:00
|
|
|
ld [wBGMapAnchor], a
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh [hSCY], a
|
|
|
|
ldh [hSCX], a
|
2017-12-24 17:47:30 +00:00
|
|
|
farcall ApplyBGMapAnchorToObjects
|
2016-05-17 12:40:42 +00:00
|
|
|
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh a, [rVBK]
|
2015-11-30 02:34:59 +00:00
|
|
|
push af
|
|
|
|
ld a, $1
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh [rVBK], a
|
2016-05-17 12:40:42 +00:00
|
|
|
|
2015-11-30 02:34:59 +00:00
|
|
|
xor a
|
2017-12-28 12:32:33 +00:00
|
|
|
ld bc, vBGMap1 - vBGMap0
|
2015-11-30 02:34:59 +00:00
|
|
|
hlbgcoord 0, 0
|
|
|
|
call ByteFill
|
2016-05-17 12:40:42 +00:00
|
|
|
|
2015-11-30 02:34:59 +00:00
|
|
|
pop af
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh [rVBK], a
|
2016-05-17 12:40:42 +00:00
|
|
|
|
2018-01-19 07:30:19 +00:00
|
|
|
ld a, "■"
|
2017-12-28 12:32:33 +00:00
|
|
|
ld bc, vBGMap1 - vBGMap0
|
2015-11-30 02:34:59 +00:00
|
|
|
hlbgcoord 0, 0
|
|
|
|
call ByteFill
|
|
|
|
ret
|
|
|
|
|
2020-02-13 17:30:13 +00:00
|
|
|
.PushAttrmap:
|
2015-11-30 02:34:59 +00:00
|
|
|
decoord 0, 0
|
|
|
|
call .copy
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh a, [hCGB]
|
2015-11-30 02:34:59 +00:00
|
|
|
and a
|
|
|
|
ret z
|
|
|
|
|
2020-02-13 17:30:13 +00:00
|
|
|
decoord 0, 0, wAttrmap
|
2015-11-30 02:34:59 +00:00
|
|
|
ld a, $1
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh [rVBK], a
|
2016-04-10 19:01:49 +00:00
|
|
|
.copy
|
2015-11-30 02:34:59 +00:00
|
|
|
hlbgcoord 0, 0
|
|
|
|
ld c, SCREEN_WIDTH
|
|
|
|
ld b, SCREEN_HEIGHT
|
|
|
|
.row
|
|
|
|
push bc
|
|
|
|
.column
|
|
|
|
ld a, [de]
|
|
|
|
inc de
|
|
|
|
ld [hli], a
|
|
|
|
dec c
|
|
|
|
jr nz, .column
|
2015-12-22 23:03:00 +00:00
|
|
|
ld bc, BG_MAP_WIDTH - SCREEN_WIDTH
|
2015-11-30 02:34:59 +00:00
|
|
|
add hl, bc
|
|
|
|
pop bc
|
|
|
|
dec b
|
|
|
|
jr nz, .row
|
|
|
|
ld a, $0
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh [rVBK], a
|
2015-11-30 02:34:59 +00:00
|
|
|
ret
|
|
|
|
|
2019-11-18 17:16:50 +00:00
|
|
|
LoadMapGraphics:
|
|
|
|
call LoadMapTileset
|
2017-12-26 17:50:32 +00:00
|
|
|
call LoadTilesetGFX
|
2015-11-30 02:34:59 +00:00
|
|
|
xor a
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh [hMapAnims], a
|
2015-11-30 02:34:59 +00:00
|
|
|
xor a
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh [hTileAnimFrame], a
|
2018-01-24 16:17:05 +00:00
|
|
|
farcall RefreshSprites
|
2015-11-30 02:34:59 +00:00
|
|
|
call LoadFontsExtra
|
2017-12-24 17:47:30 +00:00
|
|
|
farcall LoadOverworldFont
|
2015-11-30 02:34:59 +00:00
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
LoadMapPalettes:
|
2015-12-22 23:03:00 +00:00
|
|
|
ld b, SCGB_MAPPALS
|
2015-11-30 02:34:59 +00:00
|
|
|
jp GetSGBLayout
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
RefreshMapSprites:
|
2015-11-30 02:34:59 +00:00
|
|
|
call ClearSprites
|
2019-11-18 17:16:50 +00:00
|
|
|
farcall InitMapNameSign
|
2015-11-30 02:34:59 +00:00
|
|
|
call GetMovementPermissions
|
2017-12-24 17:47:30 +00:00
|
|
|
farcall RefreshPlayerSprite
|
2020-06-16 23:38:00 +00:00
|
|
|
farcall CheckUpdatePlayerSprite
|
2015-11-30 02:34:59 +00:00
|
|
|
ld hl, wPlayerSpriteSetupFlags
|
2018-01-22 19:34:55 +00:00
|
|
|
bit PLAYERSPRITESETUP_SKIP_RELOAD_GFX_F, [hl]
|
2015-11-30 02:34:59 +00:00
|
|
|
jr nz, .skip
|
2018-01-23 22:39:09 +00:00
|
|
|
ld hl, wVramState
|
2015-11-30 02:34:59 +00:00
|
|
|
set 0, [hl]
|
2016-05-10 16:31:49 +00:00
|
|
|
call SafeUpdateSprites
|
2015-11-30 02:34:59 +00:00
|
|
|
.skip
|
|
|
|
ld a, [wPlayerSpriteSetupFlags]
|
2019-11-18 17:16:50 +00:00
|
|
|
and (1 << PLAYERSPRITESETUP_FEMALE_TO_MALE_F) | (1 << 3) | (1 << 4)
|
2015-11-30 02:34:59 +00:00
|
|
|
ld [wPlayerSpriteSetupFlags], a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
CheckMovingOffEdgeOfMap::
|
2015-11-30 02:34:59 +00:00
|
|
|
ld a, [wPlayerStepDirection]
|
|
|
|
cp STANDING
|
|
|
|
ret z
|
|
|
|
and a ; DOWN
|
|
|
|
jr z, .down
|
|
|
|
cp UP
|
|
|
|
jr z, .up
|
|
|
|
cp LEFT
|
|
|
|
jr z, .left
|
|
|
|
cp RIGHT
|
|
|
|
jr z, .right
|
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
|
|
|
.down
|
2022-09-12 13:15:44 +00:00
|
|
|
ld a, [wPlayerMapY]
|
2015-11-30 02:34:59 +00:00
|
|
|
sub 4
|
|
|
|
ld b, a
|
2018-01-23 22:39:09 +00:00
|
|
|
ld a, [wMapHeight]
|
2015-11-30 02:34:59 +00:00
|
|
|
add a
|
|
|
|
cp b
|
|
|
|
jr z, .ok
|
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
|
|
|
.up
|
2022-09-12 13:15:44 +00:00
|
|
|
ld a, [wPlayerMapY]
|
2015-11-30 02:34:59 +00:00
|
|
|
sub 4
|
|
|
|
cp -1
|
|
|
|
jr z, .ok
|
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
|
|
|
.left
|
2022-09-12 13:15:44 +00:00
|
|
|
ld a, [wPlayerMapX]
|
2016-05-04 15:46:23 +00:00
|
|
|
sub 4
|
2015-11-30 02:34:59 +00:00
|
|
|
cp -1
|
|
|
|
jr z, .ok
|
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
|
|
|
.right
|
2022-09-12 13:15:44 +00:00
|
|
|
ld a, [wPlayerMapX]
|
2015-11-30 02:34:59 +00:00
|
|
|
sub 4
|
|
|
|
ld b, a
|
2018-01-23 22:39:09 +00:00
|
|
|
ld a, [wMapWidth]
|
2015-11-30 02:34:59 +00:00
|
|
|
add a
|
|
|
|
cp b
|
|
|
|
jr z, .ok
|
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
|
|
|
.ok
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2019-11-18 17:16:50 +00:00
|
|
|
GetMapScreenCoords::
|
2018-03-19 15:36:14 +00:00
|
|
|
ld hl, wOverworldMapBlocks
|
2018-01-23 22:39:09 +00:00
|
|
|
ld a, [wXCoord]
|
2015-11-30 02:34:59 +00:00
|
|
|
bit 0, a
|
2020-10-30 03:23:57 +00:00
|
|
|
jr nz, .odd_x
|
|
|
|
; even x
|
2015-11-30 02:34:59 +00:00
|
|
|
srl a
|
2020-10-30 03:23:57 +00:00
|
|
|
add 1
|
|
|
|
jr .got_block_x
|
|
|
|
.odd_x
|
|
|
|
add 1
|
2015-11-30 02:34:59 +00:00
|
|
|
srl a
|
2020-10-30 03:23:57 +00:00
|
|
|
.got_block_x
|
2015-11-30 02:34:59 +00:00
|
|
|
ld c, a
|
2020-10-30 03:23:57 +00:00
|
|
|
ld b, 0
|
2015-11-30 02:34:59 +00:00
|
|
|
add hl, bc
|
2018-01-23 22:39:09 +00:00
|
|
|
ld a, [wMapWidth]
|
2020-10-30 03:23:57 +00:00
|
|
|
add MAP_CONNECTION_PADDING_WIDTH * 2
|
2015-11-30 02:34:59 +00:00
|
|
|
ld c, a
|
2020-10-30 03:23:57 +00:00
|
|
|
ld b, 0
|
2018-01-23 22:39:09 +00:00
|
|
|
ld a, [wYCoord]
|
2015-11-30 02:34:59 +00:00
|
|
|
bit 0, a
|
2020-10-30 03:23:57 +00:00
|
|
|
jr nz, .odd_y
|
|
|
|
; even y
|
2015-11-30 02:34:59 +00:00
|
|
|
srl a
|
2020-10-30 03:23:57 +00:00
|
|
|
add 1
|
|
|
|
jr .got_block_y
|
|
|
|
.odd_y
|
|
|
|
add 1
|
2015-11-30 02:34:59 +00:00
|
|
|
srl a
|
2020-10-30 03:23:57 +00:00
|
|
|
.got_block_y
|
2015-11-30 02:34:59 +00:00
|
|
|
call AddNTimes
|
|
|
|
ld a, l
|
2015-12-14 01:33:56 +00:00
|
|
|
ld [wOverworldMapAnchor], a
|
2015-11-30 02:34:59 +00:00
|
|
|
ld a, h
|
2015-12-14 01:33:56 +00:00
|
|
|
ld [wOverworldMapAnchor + 1], a
|
2018-01-23 22:39:09 +00:00
|
|
|
ld a, [wYCoord]
|
2020-10-30 03:23:57 +00:00
|
|
|
and 1
|
2022-09-12 13:15:44 +00:00
|
|
|
ld [wPlayerMetatileY], a
|
2018-01-23 22:39:09 +00:00
|
|
|
ld a, [wXCoord]
|
2020-10-30 03:23:57 +00:00
|
|
|
and 1
|
2022-09-12 13:15:44 +00:00
|
|
|
ld [wPlayerMetatileX], a
|
2015-11-30 02:34:59 +00:00
|
|
|
ret
|