aboutsummaryrefslogtreecommitdiffstats
path: root/engine
diff options
context:
space:
mode:
Diffstat (limited to 'engine')
-rw-r--r--engine/slop_menu.asm63
1 files changed, 51 insertions, 12 deletions
diff --git a/engine/slop_menu.asm b/engine/slop_menu.asm
index 69ec2142..fcac7d10 100644
--- a/engine/slop_menu.asm
+++ b/engine/slop_menu.asm
@@ -227,21 +227,51 @@ SlopExplore:
ld b, a
ld a, [wXCoord]
ld c, a
- push bc
+ push bc ; origin Y,X
+ ld a, [wCurrentTileBlockMapViewPointer]
+ ld b, a
+ ld a, [wCurrentTileBlockMapViewPointer + 1]
+ ld c, a
+ push bc ; origin view pointer
ld a, [wCurMap]
- push af
+ push af ; origin map
.render
-; seed safe coords (0,0 is in-bounds for any map), load the map to get its real
-; dimensions + connections, then re-render centered on the map.
- xor a
- ld [wYCoord], a
- ld [wXCoord], a
+; LoadMapData loads the map header + block map into wOverworldMap, but it renders
+; using a STALE wCurrentTileBlockMapViewPointer -- the game only ever sets that
+; from warp / connection / walk data, never from wXCoord/wYCoord. So load the
+; map, then compute a centered view pointer ourselves and redraw the view.
call LoadMapData
+; stride = wCurMapWidth + MAP_BORDER*2 ; bufRow = height/2 + 1 ; bufCol = width/2
+; wCurrentTileBlockMapViewPointer = wOverworldMap + bufRow*stride + bufCol
+ ld a, [wCurMapWidth]
+ add MAP_BORDER * 2
+ ld c, a
+ ld b, 0 ; bc = row stride (blocks)
+ ld hl, 0
ld a, [wCurMapHeight]
- ld [wYCoord], a
+ srl a
+ inc a ; bufRow (>= 1)
+.viewRowLoop
+ add hl, bc
+ dec a
+ jr nz, .viewRowLoop
ld a, [wCurMapWidth]
- ld [wXCoord], a
- call LoadMapData ; render centered
+ srl a ; bufCol = width/2
+ add l
+ ld l, a
+ jr nc, .viewNoCarry
+ inc h
+.viewNoCarry
+ ld bc, wOverworldMap
+ add hl, bc
+ ld a, l
+ ld [wCurrentTileBlockMapViewPointer], a
+ ld a, h
+ ld [wCurrentTileBlockMapViewPointer + 1], a
+ xor a
+ ld [wYBlockCoord], a
+ ld [wXBlockCoord], a
+ call LoadCurrentMapView ; redraw wTileMap centered on the map
ldh a, [rLCDC] ; hide ALL sprites (player + actors) via LCDC
res B_LCDC_OBJS, a
ldh [rLCDC], a
@@ -318,12 +348,21 @@ SlopExplore:
.exit
pop af
ld [wCurMap], a ; restore origin map
- pop bc
+ pop bc ; restore origin view pointer
+ ld a, b
+ ld [wCurrentTileBlockMapViewPointer], a
+ ld a, c
+ ld [wCurrentTileBlockMapViewPointer + 1], a
+ pop bc ; restore origin Y,X
ld a, b
ld [wYCoord], a
+ and $1
+ ld [wYBlockCoord], a
ld a, c
ld [wXCoord], a
- call LoadMapData ; reload the origin map
+ and $1
+ ld [wXBlockCoord], a
+ call LoadMapData ; reload origin, rendered from the restored pointer
and a ; carry clear -> back to SL0P menu
ret