Add constants for wMapConnections bits and group map header wram labels

* Add constants for wMapConnections bits

* Apply Vulcandth and Rangi42 feedback

---------

Co-authored-by: vulcandth <vulcandth@gmail.com>
This commit is contained in:
Linus Unnebäck 2023-11-17 19:50:27 +01:00 committed by GitHub
parent b302e93674
commit 83b373ad73
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 35 additions and 30 deletions

View file

@ -3,6 +3,13 @@
DEF MAP_BORDER EQU 3 DEF MAP_BORDER EQU 3
; connection directions ; connection directions
const_def
const EAST_F
const WEST_F
const SOUTH_F
const NORTH_F
; wCurMapConnections
const_def const_def
shift_const EAST ; 1 shift_const EAST ; 1
shift_const WEST ; 2 shift_const WEST ; 2

View file

@ -372,7 +372,7 @@ ChangeBox::
call GetBoxSRAMLocation call GetBoxSRAMLocation
ld de, wBoxDataStart ld de, wBoxDataStart
call CopyBoxToOrFromSRAM ; copy new box from SRAM to WRAM call CopyBoxToOrFromSRAM ; copy new box from SRAM to WRAM
ld hl, wMapTextPtr ld hl, wCurMapTextPtr
ld de, wChangeBoxSavedMapTextPointer ld de, wChangeBoxSavedMapTextPointer
ld a, [hli] ld a, [hli]
ld [de], a ld [de], a

View file

@ -910,9 +910,9 @@ LoadTileBlockMap::
add hl, bc add hl, bc
ld c, MAP_BORDER ld c, MAP_BORDER
add hl, bc ; this puts us past the (west) border add hl, bc ; this puts us past the (west) border
ld a, [wMapDataPtr] ; tile map pointer ld a, [wCurMapDataPtr] ; tile map pointer
ld e, a ld e, a
ld a, [wMapDataPtr + 1] ld a, [wCurMapDataPtr + 1]
ld d, a ; de = tile map pointer ld d, a ; de = tile map pointer
ld a, [wCurMapHeight] ld a, [wCurMapHeight]
ld b, a ld b, a
@ -1966,7 +1966,7 @@ RunMapScript::
call RunNPCMovementScript call RunNPCMovementScript
ld a, [wCurMap] ; current map number ld a, [wCurMap] ; current map number
call SwitchToMapRomBank ; change to the ROM bank the map's data is in call SwitchToMapRomBank ; change to the ROM bank the map's data is in
ld hl, wMapScriptPtr ld hl, wCurMapScriptPtr
ld a, [hli] ld a, [hli]
ld h, [hl] ld h, [hl]
ld l, a ld l, a
@ -2035,9 +2035,8 @@ LoadMapHeader::
ld a, [hli] ld a, [hli]
ld h, [hl] ld h, [hl]
ld l, a ; hl = base of map header ld l, a ; hl = base of map header
; copy the first 10 bytes (the fixed area) of the map data to D367-D370 ld de, wCurMapHeader
ld de, wCurMapTileset ld c, wCurMapHeaderEnd - wCurMapHeader
ld c, $0a
.copyFixedHeaderLoop .copyFixedHeaderLoop
ld a, [hli] ld a, [hli]
ld [de], a ld [de], a
@ -2051,25 +2050,25 @@ LoadMapHeader::
ld [wWestConnectedMap], a ld [wWestConnectedMap], a
ld [wEastConnectedMap], a ld [wEastConnectedMap], a
; copy connection data (if any) to WRAM ; copy connection data (if any) to WRAM
ld a, [wMapConnections] ld a, [wCurMapConnections]
ld b, a ld b, a
.checkNorth .checkNorth
bit 3, b bit NORTH_F, b
jr z, .checkSouth jr z, .checkSouth
ld de, wNorthConnectionHeader ld de, wNorthConnectionHeader
call CopyMapConnectionHeader call CopyMapConnectionHeader
.checkSouth .checkSouth
bit 2, b bit SOUTH_F, b
jr z, .checkWest jr z, .checkWest
ld de, wSouthConnectionHeader ld de, wSouthConnectionHeader
call CopyMapConnectionHeader call CopyMapConnectionHeader
.checkWest .checkWest
bit 1, b bit WEST_F, b
jr z, .checkEast jr z, .checkEast
ld de, wWestConnectionHeader ld de, wWestConnectionHeader
call CopyMapConnectionHeader call CopyMapConnectionHeader
.checkEast .checkEast
bit 0, b bit EAST_F, b
jr z, .getObjectDataPointer jr z, .getObjectDataPointer
ld de, wEastConnectionHeader ld de, wEastConnectionHeader
call CopyMapConnectionHeader call CopyMapConnectionHeader

View file

@ -7,7 +7,7 @@ PrintPredefTextID::
call DisplayTextID call DisplayTextID
RestoreMapTextPointer:: RestoreMapTextPointer::
ld hl, wMapTextPtr ld hl, wCurMapTextPtr
ldh a, [hSavedMapTextPtr] ldh a, [hSavedMapTextPtr]
ld [hli], a ld [hli], a
ldh a, [hSavedMapTextPtr + 1] ldh a, [hSavedMapTextPtr + 1]
@ -15,14 +15,14 @@ RestoreMapTextPointer::
ret ret
SetMapTextPointer:: SetMapTextPointer::
ld a, [wMapTextPtr] ld a, [wCurMapTextPtr]
ldh [hSavedMapTextPtr], a ldh [hSavedMapTextPtr], a
ld a, [wMapTextPtr + 1] ld a, [wCurMapTextPtr + 1]
ldh [hSavedMapTextPtr + 1], a ldh [hSavedMapTextPtr + 1], a
ld a, l ld a, l
ld [wMapTextPtr], a ld [wCurMapTextPtr], a
ld a, h ld a, h
ld [wMapTextPtr + 1], a ld [wCurMapTextPtr + 1], a
ret ret
INCLUDE "data/text_predef_pointers.asm" INCLUDE "data/text_predef_pointers.asm"

View file

@ -13,7 +13,7 @@ DisplayTextID::
.skipSwitchToMapBank .skipSwitchToMapBank
ld a, 30 ; half a second ld a, 30 ; half a second
ldh [hFrameCounter], a ; used as joypad poll timer ldh [hFrameCounter], a ; used as joypad poll timer
ld hl, wMapTextPtr ld hl, wCurMapTextPtr
ld a, [hli] ld a, [hli]
ld h, [hl] ld h, [hl]
ld l, a ; hl = map text pointer ld l, a ; hl = map text pointer

View file

@ -1795,17 +1795,16 @@ wLastMap:: db
wUnusedD366:: db wUnusedD366:: db
wCurMapHeader::
wCurMapTileset:: db wCurMapTileset:: db
; blocks
wCurMapHeight:: db wCurMapHeight:: db
wCurMapWidth:: db wCurMapWidth:: db
wCurMapDataPtr:: dw
wCurMapTextPtr:: dw
wCurMapScriptPtr:: dw
wCurMapConnections:: db
wCurMapHeaderEnd::
wMapDataPtr:: dw
wMapTextPtr:: dw
wMapScriptPtr:: dw
wMapConnections:: db
wNorthConnectionHeader:: map_connection_struct wNorth wNorthConnectionHeader:: map_connection_struct wNorth
wSouthConnectionHeader:: map_connection_struct wSouth wSouthConnectionHeader:: map_connection_struct wSouth
wWestConnectionHeader:: map_connection_struct wWest wWestConnectionHeader:: map_connection_struct wWest

View file

@ -715,9 +715,9 @@ OaksLabCalcRivalMovementScript:
OaksLabLoadTextPointers2Script: OaksLabLoadTextPointers2Script:
ld hl, OaksLab_TextPointers2 ld hl, OaksLab_TextPointers2
ld a, l ld a, l
ld [wMapTextPtr], a ld [wCurMapTextPtr], a
ld a, h ld a, h
ld [wMapTextPtr + 1], a ld [wCurMapTextPtr + 1], a
ret ret
OaksLab_TextPointers: OaksLab_TextPointers:

View file

@ -14,9 +14,9 @@ ViridianMartCheckParcelDeliveredScript:
ld hl, ViridianMart_TextPointers2 ld hl, ViridianMart_TextPointers2
.done .done
ld a, l ld a, l
ld [wMapTextPtr], a ld [wCurMapTextPtr], a
ld a, h ld a, h
ld [wMapTextPtr+1], a ld [wCurMapTextPtr+1], a
ret ret
ViridianMart_ScriptPointers: ViridianMart_ScriptPointers: