mirror of
https://gitlab.com/xCrystal/pokecrystal-board.git
synced 2024-09-09 09:51:34 -07: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_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)
|
||||
rsreset
|
||||
DEF SPRITEMOVEATTR_MOVEMENT rb ; 0
|
||||
|
@ -225,7 +225,7 @@ CopyMapObjectToObjectStruct:
|
||||
ret
|
||||
|
||||
InitializeVisibleSprites:
|
||||
ld bc, wMap1Object
|
||||
ld bc, wMapObject1
|
||||
ld a, 1
|
||||
.loop
|
||||
ldh [hMapObjectIndex], a
|
||||
@ -312,7 +312,7 @@ CheckObjectEnteringVisibleRange::
|
||||
ld d, a
|
||||
ld a, [wXCoord]
|
||||
ld e, a
|
||||
ld bc, wMap1Object
|
||||
ld bc, wMapObject1
|
||||
ld a, 1
|
||||
.loop_v
|
||||
ldh [hMapObjectIndex], a
|
||||
@ -368,7 +368,7 @@ CheckObjectEnteringVisibleRange::
|
||||
ld e, a
|
||||
ld a, [wYCoord]
|
||||
ld d, a
|
||||
ld bc, wMap1Object
|
||||
ld bc, wMapObject1
|
||||
ld a, 1
|
||||
.loop_h
|
||||
ldh [hMapObjectIndex], a
|
||||
@ -861,7 +861,7 @@ MockPlayerObject::
|
||||
farcall RefreshPlayerCoords
|
||||
; copy default sprite object to the last object struct
|
||||
ld hl, .DefaultPlayerObject
|
||||
ld de, wMap{d:LAST_OBJECT}Object
|
||||
ld de, wMapObject{d:LAST_OBJECT}
|
||||
ld bc, OBJECT_EVENT_SIZE + 1
|
||||
call CopyBytes
|
||||
|
||||
@ -878,9 +878,9 @@ MockPlayerObject::
|
||||
jr nz, .next2
|
||||
; found a match
|
||||
ld a, [hli] ; sprite
|
||||
ld [wMap{d:LAST_OBJECT}ObjectSprite], a
|
||||
ld [wMapObject{d:LAST_OBJECT}Sprite], a
|
||||
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
|
||||
.next1
|
||||
inc hl
|
||||
@ -894,12 +894,12 @@ MockPlayerObject::
|
||||
.copy_player_coords
|
||||
; copy player's coordinates
|
||||
ld hl, wPlayerObjectYCoord
|
||||
ld de, wMap{d:LAST_OBJECT}ObjectYCoord
|
||||
ld de, wMapObject{d:LAST_OBJECT}YCoord
|
||||
ld a, [hli]
|
||||
ld [de], a
|
||||
inc de
|
||||
ld a, [hl] ; wPlayerObjectXCoord
|
||||
ld [de], a ; wMap{d:LAST_OBJECT}ObjectXCoord
|
||||
ld [de], a ; wMapObject{d:LAST_OBJECT}XCoord
|
||||
; set facing direction
|
||||
ld a, [wPlayerDirection]
|
||||
srl a
|
||||
@ -907,7 +907,7 @@ MockPlayerObject::
|
||||
maskbits NUM_DIRECTIONS
|
||||
ld b, SPRITEMOVEDATA_STANDING_DOWN
|
||||
add b
|
||||
ld [wMap{d:LAST_OBJECT}ObjectMovement], a
|
||||
ld [wMapObject{d:LAST_OBJECT}Movement], a
|
||||
|
||||
; display mocked player object
|
||||
; 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]
|
||||
ld hl, wPlayerSpriteSetupFlags
|
||||
; 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
|
||||
ld [hl], a
|
||||
set PLAYERSPRITESETUP_CUSTOM_FACING_F, [hl]
|
||||
|
@ -571,7 +571,7 @@ ReadObjectEvents::
|
||||
push hl
|
||||
call ClearNonPlayerObjectStructs
|
||||
pop de
|
||||
ld hl, wMap1Object
|
||||
ld hl, wMapObject1
|
||||
ld a, [de]
|
||||
inc de
|
||||
ld [wCurMapObjectEventCount], a
|
||||
|
@ -15,7 +15,7 @@ _CheckTrainerBattleOrTalkerPrompt::
|
||||
|
||||
; Skip the player object.
|
||||
ld a, 1
|
||||
ld de, wMap1Object
|
||||
ld de, wMapObject1
|
||||
|
||||
.loop
|
||||
|
||||
|
@ -263,6 +263,8 @@ WRAMX 1
|
||||
"Party"
|
||||
WRAMX 2
|
||||
"Pic Animations"
|
||||
WRAMX 3
|
||||
"Map Objects Backups"
|
||||
WRAMX 5
|
||||
align 8
|
||||
"GBC Video"
|
||||
@ -291,6 +293,8 @@ SRAM $02
|
||||
"Boxes 1-7"
|
||||
SRAM $03
|
||||
"Boxes 8-14"
|
||||
SRAM $04
|
||||
"SRAM Map Objects Backups"
|
||||
HRAM
|
||||
"OAM DMA"
|
||||
"HRAM"
|
||||
|
@ -330,20 +330,20 @@ MACRO object_struct
|
||||
ENDM
|
||||
|
||||
MACRO map_object
|
||||
\1ObjectStructID:: db
|
||||
\1ObjectSprite:: db
|
||||
\1ObjectYCoord:: db
|
||||
\1ObjectXCoord:: db
|
||||
\1ObjectMovement:: db
|
||||
\1ObjectRadius:: db
|
||||
\1ObjectHour1:: db
|
||||
\1ObjectHour2::
|
||||
\1ObjectTimeOfDay:: db
|
||||
\1ObjectPalette::
|
||||
\1ObjectType:: db
|
||||
\1ObjectSightRange:: db
|
||||
\1ObjectScript:: dw
|
||||
\1ObjectEventFlag:: dw
|
||||
\1StructID:: db
|
||||
\1Sprite:: db
|
||||
\1YCoord:: db
|
||||
\1XCoord:: db
|
||||
\1Movement:: db
|
||||
\1Radius:: db
|
||||
\1Hour1:: db
|
||||
\1Hour2::
|
||||
\1TimeOfDay:: db
|
||||
\1Palette::
|
||||
\1Type:: db
|
||||
\1SightRange:: db
|
||||
\1Script:: dw
|
||||
\1EventFlag:: dw
|
||||
ds 2
|
||||
ENDM
|
||||
|
||||
|
@ -135,3 +135,8 @@ SECTION "Boxes 8-14", SRAM
|
||||
; All 14 boxes fit exactly within 2 SRAM banks
|
||||
assert box_n == NUM_BOXES, \
|
||||
"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
|
||||
wPrevDexEntry:: db
|
||||
wDisableTextAcceleration:: db
|
||||
wPrevLandmark:: db
|
||||
wCurLandmark:: db
|
||||
|
||||
wLinkMode::
|
||||
; a LINK_* value for the link type
|
||||
@ -2340,10 +2338,10 @@ endr
|
||||
wCmdQueue:: ds CMDQUEUE_CAPACITY * CMDQUEUE_ENTRY_SIZE
|
||||
|
||||
wMapObjects::
|
||||
wPlayerObject:: map_object wPlayer ; player is map object 0
|
||||
; wMap1Object - wMap15Object
|
||||
wPlayerObject:: map_object wPlayerObject ; player is map object 0
|
||||
; wMapObject1 - wMapObject15
|
||||
for n, 1, NUM_OBJECTS
|
||||
wMap{d:n}Object:: map_object wMap{d:n}
|
||||
wMapObject{d:n}:: map_object wMapObject{d:n}
|
||||
endr
|
||||
|
||||
wObjectMasks:: ds NUM_OBJECTS
|
||||
@ -2689,6 +2687,22 @@ wPokeAnimBitmaskBuffer:: ds 7
|
||||
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]
|
||||
|
||||
; eight 4-color palettes each
|
||||
|
Loading…
Reference in New Issue
Block a user