mirror of
https://gitlab.com/xCrystal/pokecrystal-board.git
synced 2024-11-16 11:27:33 -08:00
Rename Map<N>Object addresses to MapObject<N>; create wMapObjectsBackups and sMapObjectsBackups in respective WRAM/SRAM sections (#32)
This commit is contained in:
parent
7ede3d1357
commit
2bca51eb09
@ -124,6 +124,12 @@ DEF PLAYER_OBJECT EQU 0
|
|||||||
DEF MAPOBJECT_PALETTE_MASK EQU %11110000
|
DEF MAPOBJECT_PALETTE_MASK EQU %11110000
|
||||||
DEF MAPOBJECT_TYPE_MASK EQU %00001111
|
DEF MAPOBJECT_TYPE_MASK EQU %00001111
|
||||||
|
|
||||||
|
; number of entries in MapObjectsBackups.
|
||||||
|
; this sets a limit to the maximum number of different maps that can be reentered during a level.
|
||||||
|
; map groups with more than NUM_MAP_OBJECTS_BACKUPS maps are only ok if no more than
|
||||||
|
; NUM_MAP_OBJECTS_BACKUPS can be possibly accesed during the same level play.
|
||||||
|
DEF NUM_MAP_OBJECTS_BACKUPS EQU 10
|
||||||
|
|
||||||
; SpriteMovementData struct members (see data/sprites/map_objects.asm)
|
; SpriteMovementData struct members (see data/sprites/map_objects.asm)
|
||||||
rsreset
|
rsreset
|
||||||
DEF SPRITEMOVEATTR_MOVEMENT rb ; 0
|
DEF SPRITEMOVEATTR_MOVEMENT rb ; 0
|
||||||
|
@ -225,7 +225,7 @@ CopyMapObjectToObjectStruct:
|
|||||||
ret
|
ret
|
||||||
|
|
||||||
InitializeVisibleSprites:
|
InitializeVisibleSprites:
|
||||||
ld bc, wMap1Object
|
ld bc, wMapObject1
|
||||||
ld a, 1
|
ld a, 1
|
||||||
.loop
|
.loop
|
||||||
ldh [hMapObjectIndex], a
|
ldh [hMapObjectIndex], a
|
||||||
@ -312,7 +312,7 @@ CheckObjectEnteringVisibleRange::
|
|||||||
ld d, a
|
ld d, a
|
||||||
ld a, [wXCoord]
|
ld a, [wXCoord]
|
||||||
ld e, a
|
ld e, a
|
||||||
ld bc, wMap1Object
|
ld bc, wMapObject1
|
||||||
ld a, 1
|
ld a, 1
|
||||||
.loop_v
|
.loop_v
|
||||||
ldh [hMapObjectIndex], a
|
ldh [hMapObjectIndex], a
|
||||||
@ -368,7 +368,7 @@ CheckObjectEnteringVisibleRange::
|
|||||||
ld e, a
|
ld e, a
|
||||||
ld a, [wYCoord]
|
ld a, [wYCoord]
|
||||||
ld d, a
|
ld d, a
|
||||||
ld bc, wMap1Object
|
ld bc, wMapObject1
|
||||||
ld a, 1
|
ld a, 1
|
||||||
.loop_h
|
.loop_h
|
||||||
ldh [hMapObjectIndex], a
|
ldh [hMapObjectIndex], a
|
||||||
@ -861,7 +861,7 @@ MockPlayerObject::
|
|||||||
farcall RefreshPlayerCoords
|
farcall RefreshPlayerCoords
|
||||||
; copy default sprite object to the last object struct
|
; copy default sprite object to the last object struct
|
||||||
ld hl, .DefaultPlayerObject
|
ld hl, .DefaultPlayerObject
|
||||||
ld de, wMap{d:LAST_OBJECT}Object
|
ld de, wMapObject{d:LAST_OBJECT}
|
||||||
ld bc, OBJECT_EVENT_SIZE + 1
|
ld bc, OBJECT_EVENT_SIZE + 1
|
||||||
call CopyBytes
|
call CopyBytes
|
||||||
|
|
||||||
@ -878,9 +878,9 @@ MockPlayerObject::
|
|||||||
jr nz, .next2
|
jr nz, .next2
|
||||||
; found a match
|
; found a match
|
||||||
ld a, [hli] ; sprite
|
ld a, [hli] ; sprite
|
||||||
ld [wMap{d:LAST_OBJECT}ObjectSprite], a
|
ld [wMapObject{d:LAST_OBJECT}Sprite], a
|
||||||
ld a, [hl] ; palette | objecttype
|
ld a, [hl] ; palette | objecttype
|
||||||
ld [wMap{d:LAST_OBJECT}ObjectPalette], a ; also wMap{d:LAST_OBJECT}ObjectType
|
ld [wMapObject{d:LAST_OBJECT}Palette], a ; also wMapObject{d:LAST_OBJECT}Type
|
||||||
jr .copy_player_coords
|
jr .copy_player_coords
|
||||||
.next1
|
.next1
|
||||||
inc hl
|
inc hl
|
||||||
@ -894,12 +894,12 @@ MockPlayerObject::
|
|||||||
.copy_player_coords
|
.copy_player_coords
|
||||||
; copy player's coordinates
|
; copy player's coordinates
|
||||||
ld hl, wPlayerObjectYCoord
|
ld hl, wPlayerObjectYCoord
|
||||||
ld de, wMap{d:LAST_OBJECT}ObjectYCoord
|
ld de, wMapObject{d:LAST_OBJECT}YCoord
|
||||||
ld a, [hli]
|
ld a, [hli]
|
||||||
ld [de], a
|
ld [de], a
|
||||||
inc de
|
inc de
|
||||||
ld a, [hl] ; wPlayerObjectXCoord
|
ld a, [hl] ; wPlayerObjectXCoord
|
||||||
ld [de], a ; wMap{d:LAST_OBJECT}ObjectXCoord
|
ld [de], a ; wMapObject{d:LAST_OBJECT}XCoord
|
||||||
; set facing direction
|
; set facing direction
|
||||||
ld a, [wPlayerDirection]
|
ld a, [wPlayerDirection]
|
||||||
srl a
|
srl a
|
||||||
@ -907,7 +907,7 @@ MockPlayerObject::
|
|||||||
maskbits NUM_DIRECTIONS
|
maskbits NUM_DIRECTIONS
|
||||||
ld b, SPRITEMOVEDATA_STANDING_DOWN
|
ld b, SPRITEMOVEDATA_STANDING_DOWN
|
||||||
add b
|
add b
|
||||||
ld [wMap{d:LAST_OBJECT}ObjectMovement], a
|
ld [wMapObject{d:LAST_OBJECT}Movement], a
|
||||||
|
|
||||||
; display mocked player object
|
; display mocked player object
|
||||||
; it will go to the last wMapObjects slot and to whichever wObjectStructs slot
|
; it will go to the last wMapObjects slot and to whichever wObjectStructs slot
|
||||||
|
@ -1246,7 +1246,7 @@ Script_reloadmapafterviewmapmode:
|
|||||||
set SECONDARYSPRITES_BRANCH_ARROWS_F, [hl]
|
set SECONDARYSPRITES_BRANCH_ARROWS_F, [hl]
|
||||||
ld hl, wPlayerSpriteSetupFlags
|
ld hl, wPlayerSpriteSetupFlags
|
||||||
; get the facing direction from the mocked object's facing direction
|
; get the facing direction from the mocked object's facing direction
|
||||||
ld a, [wMap{d:LAST_OBJECT}ObjectMovement]
|
ld a, [wMapObject{d:LAST_OBJECT}Movement]
|
||||||
sub SPRITEMOVEDATA_STANDING_DOWN
|
sub SPRITEMOVEDATA_STANDING_DOWN
|
||||||
ld [hl], a
|
ld [hl], a
|
||||||
set PLAYERSPRITESETUP_CUSTOM_FACING_F, [hl]
|
set PLAYERSPRITESETUP_CUSTOM_FACING_F, [hl]
|
||||||
|
@ -571,7 +571,7 @@ ReadObjectEvents::
|
|||||||
push hl
|
push hl
|
||||||
call ClearNonPlayerObjectStructs
|
call ClearNonPlayerObjectStructs
|
||||||
pop de
|
pop de
|
||||||
ld hl, wMap1Object
|
ld hl, wMapObject1
|
||||||
ld a, [de]
|
ld a, [de]
|
||||||
inc de
|
inc de
|
||||||
ld [wCurMapObjectEventCount], a
|
ld [wCurMapObjectEventCount], a
|
||||||
|
@ -15,7 +15,7 @@ _CheckTrainerBattleOrTalkerPrompt::
|
|||||||
|
|
||||||
; Skip the player object.
|
; Skip the player object.
|
||||||
ld a, 1
|
ld a, 1
|
||||||
ld de, wMap1Object
|
ld de, wMapObject1
|
||||||
|
|
||||||
.loop
|
.loop
|
||||||
|
|
||||||
|
@ -263,6 +263,8 @@ WRAMX 1
|
|||||||
"Party"
|
"Party"
|
||||||
WRAMX 2
|
WRAMX 2
|
||||||
"Pic Animations"
|
"Pic Animations"
|
||||||
|
WRAMX 3
|
||||||
|
"Map Objects Backups"
|
||||||
WRAMX 5
|
WRAMX 5
|
||||||
align 8
|
align 8
|
||||||
"GBC Video"
|
"GBC Video"
|
||||||
@ -291,6 +293,8 @@ SRAM $02
|
|||||||
"Boxes 1-7"
|
"Boxes 1-7"
|
||||||
SRAM $03
|
SRAM $03
|
||||||
"Boxes 8-14"
|
"Boxes 8-14"
|
||||||
|
SRAM $04
|
||||||
|
"SRAM Map Objects Backups"
|
||||||
HRAM
|
HRAM
|
||||||
"OAM DMA"
|
"OAM DMA"
|
||||||
"HRAM"
|
"HRAM"
|
||||||
|
@ -330,20 +330,20 @@ MACRO object_struct
|
|||||||
ENDM
|
ENDM
|
||||||
|
|
||||||
MACRO map_object
|
MACRO map_object
|
||||||
\1ObjectStructID:: db
|
\1StructID:: db
|
||||||
\1ObjectSprite:: db
|
\1Sprite:: db
|
||||||
\1ObjectYCoord:: db
|
\1YCoord:: db
|
||||||
\1ObjectXCoord:: db
|
\1XCoord:: db
|
||||||
\1ObjectMovement:: db
|
\1Movement:: db
|
||||||
\1ObjectRadius:: db
|
\1Radius:: db
|
||||||
\1ObjectHour1:: db
|
\1Hour1:: db
|
||||||
\1ObjectHour2::
|
\1Hour2::
|
||||||
\1ObjectTimeOfDay:: db
|
\1TimeOfDay:: db
|
||||||
\1ObjectPalette::
|
\1Palette::
|
||||||
\1ObjectType:: db
|
\1Type:: db
|
||||||
\1ObjectSightRange:: db
|
\1SightRange:: db
|
||||||
\1ObjectScript:: dw
|
\1Script:: dw
|
||||||
\1ObjectEventFlag:: dw
|
\1EventFlag:: dw
|
||||||
ds 2
|
ds 2
|
||||||
ENDM
|
ENDM
|
||||||
|
|
||||||
|
@ -135,3 +135,8 @@ SECTION "Boxes 8-14", SRAM
|
|||||||
; All 14 boxes fit exactly within 2 SRAM banks
|
; All 14 boxes fit exactly within 2 SRAM banks
|
||||||
assert box_n == NUM_BOXES, \
|
assert box_n == NUM_BOXES, \
|
||||||
"boxes: Expected {d:NUM_BOXES} total boxes, got {d:box_n}"
|
"boxes: Expected {d:NUM_BOXES} total boxes, got {d:box_n}"
|
||||||
|
|
||||||
|
|
||||||
|
SECTION "SRAM Map Objects Backups", SRAM
|
||||||
|
|
||||||
|
sMapObjectsBackups:: ds wMapObjectsBackupsEnd - wMapObjectsBackups
|
||||||
|
24
ram/wram.asm
24
ram/wram.asm
@ -133,8 +133,6 @@ wPrinterConnectionOpen:: db
|
|||||||
wPrinterOpcode:: db
|
wPrinterOpcode:: db
|
||||||
wPrevDexEntry:: db
|
wPrevDexEntry:: db
|
||||||
wDisableTextAcceleration:: db
|
wDisableTextAcceleration:: db
|
||||||
wPrevLandmark:: db
|
|
||||||
wCurLandmark:: db
|
|
||||||
|
|
||||||
wLinkMode::
|
wLinkMode::
|
||||||
; a LINK_* value for the link type
|
; a LINK_* value for the link type
|
||||||
@ -2340,10 +2338,10 @@ endr
|
|||||||
wCmdQueue:: ds CMDQUEUE_CAPACITY * CMDQUEUE_ENTRY_SIZE
|
wCmdQueue:: ds CMDQUEUE_CAPACITY * CMDQUEUE_ENTRY_SIZE
|
||||||
|
|
||||||
wMapObjects::
|
wMapObjects::
|
||||||
wPlayerObject:: map_object wPlayer ; player is map object 0
|
wPlayerObject:: map_object wPlayerObject ; player is map object 0
|
||||||
; wMap1Object - wMap15Object
|
; wMapObject1 - wMapObject15
|
||||||
for n, 1, NUM_OBJECTS
|
for n, 1, NUM_OBJECTS
|
||||||
wMap{d:n}Object:: map_object wMap{d:n}
|
wMapObject{d:n}:: map_object wMapObject{d:n}
|
||||||
endr
|
endr
|
||||||
|
|
||||||
wObjectMasks:: ds NUM_OBJECTS
|
wObjectMasks:: ds NUM_OBJECTS
|
||||||
@ -2689,6 +2687,22 @@ wPokeAnimBitmaskBuffer:: ds 7
|
|||||||
wPokeAnimStructEnd::
|
wPokeAnimStructEnd::
|
||||||
|
|
||||||
|
|
||||||
|
SECTION "Map Objects Backups", WRAMX
|
||||||
|
|
||||||
|
wMapObjectsBackups::
|
||||||
|
; wMap1ObjectsBackup* - wMap10ObjectsBackup*
|
||||||
|
; ds (2 + MAPOBJECT_LENGTH * (NUM_OBJECTS - 1)) * NUM_MAP_OBJECTS_BACKUPS
|
||||||
|
for n, 1, NUM_MAP_OBJECTS_BACKUPS
|
||||||
|
wMap{d:n}ObjectsBackupMapGroup:: db
|
||||||
|
wMap{d:n}ObjectsBackupMapNumber:: db
|
||||||
|
wMap{d:n}ObjectsBackupData::
|
||||||
|
for m, 1, NUM_OBJECTS
|
||||||
|
wMap{d:n}ObjectsBackupObject{d:m}:: map_object wMap{d:n}ObjectsBackupObject{d:m}
|
||||||
|
endr
|
||||||
|
endr
|
||||||
|
wMapObjectsBackupsEnd:: db ; list terminator
|
||||||
|
|
||||||
|
|
||||||
SECTION "GBC Video", WRAMX, ALIGN[8]
|
SECTION "GBC Video", WRAMX, ALIGN[8]
|
||||||
|
|
||||||
; eight 4-color palettes each
|
; eight 4-color palettes each
|
||||||
|
Loading…
Reference in New Issue
Block a user