Define constants for map event sizes

This commit is contained in:
Rangi 2019-03-03 14:19:16 -05:00
parent dc396822d7
commit 79dc22c769
7 changed files with 36 additions and 28 deletions

View File

@ -86,6 +86,14 @@ RETVAR_EXECUTE EQU (2 << 6)
const PLAYEREVENT_JOYCHANGEFACING const PLAYEREVENT_JOYCHANGEFACING
NUM_PLAYER_EVENTS EQU const_value NUM_PLAYER_EVENTS EQU const_value
; script data sizes (see macros/scripts/maps.asm)
SCENE_SCRIPT_SIZE EQU 4 ; scene_script
CALLBACK_SIZE EQU 3 ; callback
WARP_EVENT_SIZE EQU 5 ; warp_event
COORD_EVENT_SIZE EQU 8 ; coord_event
BG_EVENT_SIZE EQU 5 ; bg_event
OBJECT_EVENT_SIZE EQU 13 ; object_event
; bg_event types ; bg_event types
; TryBGEvent arguments (see engine/overworld/events.asm) ; TryBGEvent arguments (see engine/overworld/events.asm)
const_def const_def

View File

@ -84,4 +84,4 @@ MapScenes::
scene_var MOUNT_MOON_SQUARE, wMountMoonSquareSceneID scene_var MOUNT_MOON_SQUARE, wMountMoonSquareSceneID
scene_var MOBILE_TRADE_ROOM, wMobileTradeRoomSceneID scene_var MOBILE_TRADE_ROOM, wMobileTradeRoomSceneID
scene_var MOBILE_BATTLE_ROOM, wMobileBattleRoomSceneID scene_var MOBILE_BATTLE_ROOM, wMobileBattleRoomSceneID
db -1 db -1 ; end

View File

@ -60,7 +60,7 @@ CheckForHiddenItems:
.next .next
; Restore the bg_event pointer and increment it by the length of a bg_event. ; Restore the bg_event pointer and increment it by the length of a bg_event.
pop hl pop hl
ld bc, 5 ld bc, BG_EVENT_SIZE
add hl, bc add hl, bc
; Restore the BG event counter and decrement it. If it hits zero, there are no hidden items in range. ; Restore the BG event counter and decrement it. If it hits zero, there are no hidden items in range.
ld a, [wBuffer2] ld a, [wBuffer2]

View File

@ -418,7 +418,7 @@ RunSceneScript:
ld a, [hli] ld a, [hli]
ld h, [hl] ld h, [hl]
ld l, a ld l, a
rept 4 rept SCENE_SCRIPT_SIZE
add hl, de add hl, de
endr endr

View File

@ -46,8 +46,8 @@ GetCurrentMapSceneID::
ret ret
GetMapSceneID:: GetMapSceneID::
; Searches the scene script table for the map group and number loaded in bc, and returns the wram pointer in de. ; Searches the scene_var table for the map group and number loaded in bc, and returns the wram pointer in de.
; If the map is not in the scene script table, returns carry. ; If the map is not in the scene_var table, returns carry.
push bc push bc
ldh a, [hROMBank] ldh a, [hROMBank]
push af push af
@ -59,7 +59,7 @@ GetMapSceneID::
push hl push hl
ld a, [hli] ; map group, or terminator ld a, [hli] ; map group, or terminator
cp -1 cp -1
jr z, .end ; the current map is not in the scene script table jr z, .end ; the current map is not in the scene_var table
cp b cp b
jr nz, .next ; map group did not match jr nz, .next ; map group did not match
ld a, [hli] ; map number ld a, [hli] ; map number
@ -69,7 +69,7 @@ GetMapSceneID::
.next .next
pop hl pop hl
ld de, 4 ; scene_script size ld de, 4 ; scene_var size
add hl, de add hl, de
jr .loop jr .loop
@ -275,7 +275,7 @@ GetDestinationWarpNumber::
.next .next
pop hl pop hl
ld a, 5 ld a, WARP_EVENT_SIZE
add l add l
ld l, a ld l, a
jr nc, .okay jr nc, .okay
@ -325,9 +325,9 @@ CopyWarpData::
ld l, a ld l, a
ld a, c ld a, c
dec a dec a
ld bc, $5 ; warp size ld bc, WARP_EVENT_SIZE
call AddNTimes call AddNTimes
ld bc, $2 ; warp number ld bc, 2 ; warp number
add hl, bc add hl, bc
ld a, [hli] ld a, [hli]
cp $ff cp $ff
@ -487,7 +487,7 @@ GetMapConnection::
ret ret
ReadMapSceneScripts:: ReadMapSceneScripts::
ld a, [hli] ; scene script count ld a, [hli] ; scene_script count
ld c, a ld c, a
ld [wCurMapSceneScriptCount], a ld [wCurMapSceneScriptCount], a
ld a, l ld a, l
@ -498,7 +498,7 @@ ReadMapSceneScripts::
and a and a
ret z ret z
ld bc, 4 ; scene_script size ld bc, SCENE_SCRIPT_SIZE
call AddNTimes call AddNTimes
ret ret
@ -514,7 +514,7 @@ ReadMapCallbacks::
and a and a
ret z ret z
ld bc, 3 ld bc, CALLBACK_SIZE
call AddNTimes call AddNTimes
ret ret
@ -529,7 +529,7 @@ ReadWarps::
ld a, c ld a, c
and a and a
ret z ret z
ld bc, 5 ld bc, WARP_EVENT_SIZE
call AddNTimes call AddNTimes
ret ret
@ -546,7 +546,7 @@ ReadCoordEvents::
and a and a
ret z ret z
ld bc, 8 ld bc, COORD_EVENT_SIZE
call AddNTimes call AddNTimes
ret ret
@ -563,7 +563,7 @@ ReadBGEvents::
and a and a
ret z ret z
ld bc, 5 ld bc, BG_EVENT_SIZE
call AddNTimes call AddNTimes
ret ret
@ -622,7 +622,7 @@ CopyMapObjectEvents::
push hl push hl
ld a, $ff ld a, $ff
ld [hli], a ld [hli], a
ld b, MAPOBJECT_E - MAPOBJECT_SPRITE ld b, OBJECT_EVENT_SIZE
.loop2 .loop2
ld a, [de] ld a, [de]
inc de inc de
@ -664,14 +664,14 @@ RestoreFacingAfterWarp::
ld a, [hli] ld a, [hli]
ld h, [hl] ld h, [hl]
ld l, a ld l, a
inc hl ; get to the warp coords rept 3 ; get to the warp coords
inc hl ; get to the warp coords inc hl
inc hl ; get to the warp coords endr
ld a, [wWarpNumber] ld a, [wWarpNumber]
dec a dec a
ld c, a ld c, a
ld b, 0 ld b, 0
ld a, $5 ; warp size ld a, WARP_EVENT_SIZE
call AddNTimes call AddNTimes
ld a, [hli] ld a, [hli]
ld [wYCoord], a ld [wYCoord], a
@ -981,7 +981,7 @@ RunMapCallback::
ld l, a ld l, a
or h or h
ret z ret z
ld de, 3 ld de, CALLBACK_SIZE
.loop .loop
ld a, [hl] ld a, [hl]
cp b cp b
@ -1799,7 +1799,7 @@ CheckIfFacingTileCoordIsBGEvent::
.next .next
pop hl pop hl
ld a, 5 ; BG event event length ld a, BG_EVENT_SIZE
add l add l
ld l, a ld l, a
jr nc, .nocarry jr nc, .nocarry
@ -1814,7 +1814,7 @@ CheckIfFacingTileCoordIsBGEvent::
.copysign .copysign
pop hl pop hl
ld de, wCurBGEventYCoord ld de, wCurBGEventYCoord
ld bc, 5 ; BG event event length ld bc, BG_EVENT_SIZE
call CopyBytes call CopyBytes
scf scf
ret ret
@ -1871,7 +1871,7 @@ CheckCurrentMapCoordEvents::
.next .next
pop hl pop hl
ld a, $8 ; coord event size ld a, COORD_EVENT_SIZE
add l add l
ld l, a ld l, a
jr nc, .nocarry jr nc, .nocarry
@ -1886,7 +1886,7 @@ CheckCurrentMapCoordEvents::
.copy_coord_event .copy_coord_event
pop hl pop hl
ld de, wCurCoordEventSceneID ld de, wCurCoordEventSceneID
ld bc, 8 ; coord event size ld bc, COORD_EVENT_SIZE
call CopyBytes call CopyBytes
scf scf
ret ret

View File

@ -76,7 +76,7 @@ HandleStoneQueue::
jr .found_warp jr .found_warp
.not_on_warp .not_on_warp
ld a, 5 ld a, WARP_EVENT_SIZE
add l add l
ld l, a ld l, a
jr nc, .no_carry jr nc, .no_carry

View File

@ -32,7 +32,7 @@ coord_event: MACRO
db \3, \2, \1 db \3, \2, \1
db 0 ; filler db 0 ; filler
dw \4 dw \4
db 0, 0 ; filler dw 0 ; filler
ENDM ENDM
bg_event: MACRO bg_event: MACRO