|
|
@ -6,6 +6,9 @@ SECTION "Map Data", WRAM0 |
|
|
|
PAGEX:: DB |
|
|
|
PAGEY:: DB |
|
|
|
|
|
|
|
LAST_SCX:: DB |
|
|
|
LAST_SCY:: DB |
|
|
|
|
|
|
|
CURRENT_DATA_START:: |
|
|
|
CURRENT_TILE_PTR:: DW |
|
|
|
CURRENT_TILE_SIZE:: DB |
|
|
@ -30,10 +33,6 @@ DEF STACK_OFFSET_ROW EQU 3 |
|
|
|
DEF STACK_OFFSET_MAP EQU 1 |
|
|
|
DEF STACK_OFFSET_LEFT EQU 0 |
|
|
|
|
|
|
|
; TODO: Don't hardcode |
|
|
|
DEF CAMERAX EQU 0 |
|
|
|
DEF CAMERAY EQU 14 |
|
|
|
|
|
|
|
; Increments a 16-bit value located on the stack |
|
|
|
; \1 Stack offset |
|
|
|
MACRO INC_STACK16 |
|
|
@ -62,11 +61,13 @@ Map_Load:: |
|
|
|
; Initialize scroll state |
|
|
|
ld a, INIT_SCX |
|
|
|
ld [rSCX], a |
|
|
|
ld [LAST_SCX], a |
|
|
|
|
|
|
|
ld a, INIT_SCY |
|
|
|
ld [rSCY], a |
|
|
|
ld [LAST_SCY], a |
|
|
|
|
|
|
|
xor a |
|
|
|
ld a, 8 |
|
|
|
ld [PAGEX], a |
|
|
|
ld [PAGEY], a |
|
|
|
|
|
|
@ -108,6 +109,25 @@ Map_Load:: |
|
|
|
|
|
|
|
ret |
|
|
|
|
|
|
|
; Update map state based on SCX/SCY |
|
|
|
Map_Scroll:: |
|
|
|
; Adjust CURRENT_CAMERA_X |
|
|
|
; Adjust CURRENT_CAMERA_Y |
|
|
|
|
|
|
|
; If SCY = PAGEY, write map row |
|
|
|
; map coords = CURRENT_CAMERA_X, CURRENT_CAMERA_Y - 2 |
|
|
|
; HL = _SCRN0 + 32 * (page_y - 1) |
|
|
|
|
|
|
|
; If SCY = SCRN_Y - PAGEY, write map row |
|
|
|
; map coords = CURRENT_CAMERA_X, CURRENT_CAMERA_Y + 21 |
|
|
|
; HL = _SCRN0 + 32 * ((32 - page_y) - 1) |
|
|
|
; TODO: Check math on these |
|
|
|
|
|
|
|
; If SCX = PAGEX, write map col |
|
|
|
; If SCX = SCRN_X - PAGEX, write map col |
|
|
|
|
|
|
|
ret |
|
|
|
|
|
|
|
; Write a row of map data into map RAM |
|
|
|
; @param b Map X coordinate (signed) |
|
|
|
; @param c Map Y coordinate (signed) |
|
|
|