Use and define more WRAM constants

This commit is contained in:
Rangi
2019-01-24 21:41:14 -05:00
parent 68d4a53483
commit 79ea091ff6
7 changed files with 85 additions and 67 deletions

View File

@@ -70,6 +70,9 @@ EMOTE_OBJECT EQU 1 << EMOTE_OBJECT_F
const OBJ_FLAGS2_2 ; 2 const OBJ_FLAGS2_2 ; 2
const OVERHEAD_F ; 3 const OVERHEAD_F ; 3
const USE_OBP1_F ; 4 const USE_OBP1_F ; 4
const OBJ_FLAGS2_5 ; 5
const OBJ_FLAGS2_6 ; 6
const OBJ_FLAGS2_7 ; 7
LOW_PRIORITY EQU 1 << LOW_PRIORITY_F LOW_PRIORITY EQU 1 << LOW_PRIORITY_F
HIGH_PRIORITY EQU 1 << HIGH_PRIORITY_F HIGH_PRIORITY EQU 1 << HIGH_PRIORITY_F

View File

@@ -94,6 +94,13 @@ REMOVE_BOX EQU 1
DAY_CARE_WITHDRAW EQU 2 DAY_CARE_WITHDRAW EQU 2
DAY_CARE_DEPOSIT EQU 3 DAY_CARE_DEPOSIT EQU 3
; wPlayerStepFlags:: ; d150
const_def 4
const PLAYERSTEP_MIDAIR_F ; 4
const PLAYERSTEP_CONTINUE_F ; 5
const PLAYERSTEP_STOP_F ; 6
const PLAYERSTEP_START_F ; 7
; wInitListType:: ; d263 ; wInitListType:: ; d263
INIT_ENEMYOT_LIST EQU 1 INIT_ENEMYOT_LIST EQU 1
INIT_BAG_ITEM_LIST EQU 2 INIT_BAG_ITEM_LIST EQU 2
@@ -126,14 +133,27 @@ PLAYERSPRITESETUP_RESET_ACTION_F EQU 7
; wPlayerGender:: ; d472 ; wPlayerGender:: ; d472
PLAYERGENDER_FEMALE_F EQU 0 PLAYERGENDER_FEMALE_F EQU 0
; wMapStatus:: ; d432
const_def
const MAPSTATUS_START ; 0
const MAPSTATUS_ENTER ; 1
const MAPSTATUS_HANDLE ; 2
const MAPSTATUS_DONE ; 3
; wMapEventStatus:: ; d433
const_def
const MAPEVENTS_ON ; 0
const MAPEVENTS_OFF ; 1
; wScriptFlags:: ; d434 ; wScriptFlags:: ; d434
SCRIPT_RUNNING EQU 2 SCRIPT_RUNNING EQU 2
; wScriptMode:: ; d437 ; wScriptMode:: ; d437
SCRIPT_OFF EQU 0 const_def
SCRIPT_READ EQU 1 const SCRIPT_OFF
SCRIPT_WAIT_MOVEMENT EQU 2 const SCRIPT_READ
SCRIPT_WAIT EQU 3 const SCRIPT_WAIT_MOVEMENT
const SCRIPT_WAIT
; wSpawnAfterChampion:: ; d4b5 ; wSpawnAfterChampion:: ; d4b5
SPAWN_LANCE EQU 1 SPAWN_LANCE EQU 1

View File

@@ -4,19 +4,20 @@ INCLUDE "constants.asm"
SECTION "Events", ROMX SECTION "Events", ROMX
OverworldLoop:: OverworldLoop::
xor a xor a ; MAPSTATUS_START
ld [wMapStatus], a ld [wMapStatus], a
.loop .loop
ld a, [wMapStatus] ld a, [wMapStatus]
ld hl, .jumps ld hl, .jumps
rst JumpTable rst JumpTable
ld a, [wMapStatus] ld a, [wMapStatus]
cp 3 ; done cp MAPSTATUS_DONE
jr nz, .loop jr nz, .loop
.done .done
ret ret
.jumps .jumps
; entries correspond to MAPSTATUS_* constants
dw StartMap dw StartMap
dw EnterMap dw EnterMap
dw HandleMap dw HandleMap
@@ -130,7 +131,7 @@ EnterMap:
xor a ; end map entry xor a ; end map entry
ldh [hMapEntryMethod], a ldh [hMapEntryMethod], a
ld a, 2 ; HandleMap ld a, MAPSTATUS_HANDLE
ld [wMapStatus], a ld [wMapStatus], a
ret ret
@@ -147,7 +148,7 @@ HandleMap:
; Not immediately entering a connected map will cause problems. ; Not immediately entering a connected map will cause problems.
ld a, [wMapStatus] ld a, [wMapStatus]
cp 2 ; HandleMap cp MAPSTATUS_HANDLE
ret nz ret nz
call HandleMapObjects call HandleMapObjects
@@ -163,6 +164,7 @@ MapEvents:
ret ret
.jumps .jumps
; entries correspond to MAPEVENTS_* constants
dw .events dw .events
dw .no_events dw .no_events
@@ -193,7 +195,7 @@ NextOverworldFrame:
HandleMapTimeAndJoypad: HandleMapTimeAndJoypad:
ld a, [wMapEventStatus] ld a, [wMapEventStatus]
cp 1 ; no events cp MAPEVENTS_OFF
ret z ret z
call UpdateTime call UpdateTime
@@ -215,26 +217,26 @@ HandleMapBackground:
CheckPlayerState: CheckPlayerState:
ld a, [wPlayerStepFlags] ld a, [wPlayerStepFlags]
bit 5, a ; in the middle of step bit PLAYERSTEP_CONTINUE_F, a
jr z, .events jr z, .events
bit 6, a ; stopping step bit PLAYERSTEP_STOP_F, a
jr z, .noevents jr z, .noevents
bit 4, a ; in midair bit PLAYERSTEP_MIDAIR_F, a
jr nz, .noevents jr nz, .noevents
call EnableEvents call EnableEvents
.events .events
ld a, 0 ; events ld a, MAPEVENTS_ON
ld [wMapEventStatus], a ld [wMapEventStatus], a
ret ret
.noevents .noevents
ld a, 1 ; no events ld a, MAPEVENTS_OFF
ld [wMapEventStatus], a ld [wMapEventStatus], a
ret ret
_CheckObjectEnteringVisibleRange: _CheckObjectEnteringVisibleRange:
ld hl, wPlayerStepFlags ld hl, wPlayerStepFlags
bit 6, [hl] bit PLAYERSTEP_STOP_F, [hl]
ret z ret z
farcall CheckObjectEnteringVisibleRange farcall CheckObjectEnteringVisibleRange
ret ret

View File

@@ -36,7 +36,7 @@ Function437b:
.CheckObjectStillVisible: .CheckObjectStillVisible:
ld hl, OBJECT_FLAGS2 ld hl, OBJECT_FLAGS2
add hl, bc add hl, bc
res 6, [hl] res OBJ_FLAGS2_6, [hl]
ld a, [wXCoord] ld a, [wXCoord]
ld e, a ld e, a
ld hl, OBJECT_NEXT_MAP_X ld hl, OBJECT_NEXT_MAP_X
@@ -62,7 +62,7 @@ Function437b:
.ok .ok
ld hl, OBJECT_FLAGS2 ld hl, OBJECT_FLAGS2
add hl, bc add hl, bc
set 6, [hl] set OBJ_FLAGS2_6, [hl]
ld a, [wXCoord] ld a, [wXCoord]
ld e, a ld e, a
ld hl, OBJECT_INIT_X ld hl, OBJECT_INIT_X
@@ -99,7 +99,7 @@ Function437b:
.yes2 .yes2
ld hl, OBJECT_FLAGS2 ld hl, OBJECT_FLAGS2
add hl, bc add hl, bc
set 6, [hl] set OBJ_FLAGS2_6, [hl]
and a and a
ret ret
@@ -111,7 +111,7 @@ Function437b:
jr z, .zero jr z, .zero
ld hl, OBJECT_FLAGS2 ld hl, OBJECT_FLAGS2
add hl, bc add hl, bc
bit 5, [hl] bit OBJ_FLAGS2_5, [hl]
jr nz, .bit5 jr nz, .bit5
cp STEP_TYPE_SLEEP cp STEP_TYPE_SLEEP
jr z, .one jr z, .one
@@ -121,7 +121,7 @@ Function437b:
call ObjectMovementReset call ObjectMovementReset
ld hl, OBJECT_FLAGS2 ld hl, OBJECT_FLAGS2
add hl, bc add hl, bc
bit 5, [hl] bit OBJ_FLAGS2_5, [hl]
jr nz, .bit5 jr nz, .bit5
.one .one
call MapObjectMovementPattern call MapObjectMovementPattern
@@ -147,9 +147,9 @@ Function437b:
jr nz, SetFacingStanding jr nz, SetFacingStanding
ld hl, OBJECT_FLAGS2 ld hl, OBJECT_FLAGS2
add hl, bc add hl, bc
bit 6, [hl] bit OBJ_FLAGS2_6, [hl]
jr nz, SetFacingStanding jr nz, SetFacingStanding
bit 5, [hl] bit OBJ_FLAGS2_5, [hl]
jr nz, asm_4448 jr nz, asm_4448
ld de, ObjectActionPairPointers ; use first column ld de, ObjectActionPairPointers ; use first column
jr _HandleObjectAction jr _HandleObjectAction
@@ -399,7 +399,7 @@ UpdatePlayerStep:
add e add e
ld [wPlayerStepVectorY], a ld [wPlayerStepVectorY], a
ld hl, wPlayerStepFlags ld hl, wPlayerStepFlags
set 5, [hl] set PLAYERSTEP_CONTINUE_F, [hl]
ret ret
Unreferenced_Function4759: Unreferenced_Function4759:
@@ -657,8 +657,8 @@ MapObjectMovementPattern:
jr z, .on_pit jr z, .on_pit
ld hl, OBJECT_FLAGS2 ld hl, OBJECT_FLAGS2
add hl, bc add hl, bc
bit 2, [hl] bit OBJ_FLAGS2_2, [hl]
res 2, [hl] res OBJ_FLAGS2_2, [hl]
jr z, .ok jr z, .ok
ld hl, OBJECT_RANGE ld hl, OBJECT_RANGE
add hl, bc add hl, bc
@@ -1124,7 +1124,7 @@ NPCJump:
call GetNextTile call GetNextTile
ld hl, OBJECT_FLAGS2 ld hl, OBJECT_FLAGS2
add hl, bc add hl, bc
res 3, [hl] res OVERHEAD_F, [hl]
call IncrementObjectStructField1c call IncrementObjectStructField1c
ret ret
@@ -1151,7 +1151,7 @@ PlayerJump:
.initjump .initjump
ld hl, wPlayerStepFlags ld hl, wPlayerStepFlags
set 7, [hl] set PLAYERSTEP_START_F, [hl]
call IncrementObjectStructField1c call IncrementObjectStructField1c
.stepjump .stepjump
call UpdateJumpPosition call UpdateJumpPosition
@@ -1163,17 +1163,17 @@ PlayerJump:
call CopyNextCoordsTileToStandingCoordsTile call CopyNextCoordsTileToStandingCoordsTile
ld hl, OBJECT_FLAGS2 ld hl, OBJECT_FLAGS2
add hl, bc add hl, bc
res 3, [hl] res OVERHEAD_F, [hl]
ld hl, wPlayerStepFlags ld hl, wPlayerStepFlags
set 6, [hl] set PLAYERSTEP_STOP_F, [hl]
set 4, [hl] set PLAYERSTEP_MIDAIR_F, [hl]
call IncrementObjectStructField1c call IncrementObjectStructField1c
ret ret
.initland .initland
call GetNextTile call GetNextTile
ld hl, wPlayerStepFlags ld hl, wPlayerStepFlags
set 7, [hl] set PLAYERSTEP_START_F, [hl]
call IncrementObjectStructField1c call IncrementObjectStructField1c
.stepland .stepland
call UpdateJumpPosition call UpdateJumpPosition
@@ -1183,7 +1183,7 @@ PlayerJump:
dec [hl] dec [hl]
ret nz ret nz
ld hl, wPlayerStepFlags ld hl, wPlayerStepFlags
set 6, [hl] set PLAYERSTEP_STOP_F, [hl]
call CopyNextCoordsTileToStandingCoordsTile call CopyNextCoordsTileToStandingCoordsTile
ld hl, OBJECT_STEP_TYPE ld hl, OBJECT_STEP_TYPE
add hl, bc add hl, bc
@@ -1229,7 +1229,7 @@ TeleportFrom:
ld [hl], 16 ld [hl], 16
ld hl, OBJECT_FLAGS2 ld hl, OBJECT_FLAGS2
add hl, bc add hl, bc
res 3, [hl] res OVERHEAD_F, [hl]
call IncrementObjectStructField1c call IncrementObjectStructField1c
.DoSpinRise: .DoSpinRise:
ld hl, OBJECT_ACTION ld hl, OBJECT_ACTION
@@ -1559,7 +1559,7 @@ PlayerStep:
.init .init
ld hl, wPlayerStepFlags ld hl, wPlayerStepFlags
set 7, [hl] set PLAYERSTEP_START_F, [hl]
call IncrementObjectStructField1c call IncrementObjectStructField1c
.step .step
call UpdatePlayerStep call UpdatePlayerStep
@@ -1568,7 +1568,7 @@ PlayerStep:
dec [hl] dec [hl]
ret nz ret nz
ld hl, wPlayerStepFlags ld hl, wPlayerStepFlags
set 6, [hl] set PLAYERSTEP_STOP_F, [hl]
call CopyNextCoordsTileToStandingCoordsTile call CopyNextCoordsTileToStandingCoordsTile
ld hl, OBJECT_DIRECTION_WALKING ld hl, OBJECT_DIRECTION_WALKING
add hl, bc add hl, bc
@@ -1646,7 +1646,7 @@ StepType0f:
pop bc pop bc
ld hl, OBJECT_FLAGS2 ld hl, OBJECT_FLAGS2
add hl, bc add hl, bc
res 2, [hl] res OBJ_FLAGS2_2, [hl]
call CopyNextCoordsTileToStandingCoordsTile call CopyNextCoordsTileToStandingCoordsTile
ld hl, OBJECT_DIRECTION_WALKING ld hl, OBJECT_DIRECTION_WALKING
add hl, bc add hl, bc
@@ -2408,7 +2408,7 @@ HandleNPCStep::
ld [wPlayerStepVectorX], a ld [wPlayerStepVectorX], a
ld [wPlayerStepVectorY], a ld [wPlayerStepVectorY], a
ld [wPlayerStepFlags], a ld [wPlayerStepFlags], a
ld a, -1 ld a, STANDING
ld [wPlayerStepDirection], a ld [wPlayerStepDirection], a
ret ret
@@ -2558,7 +2558,7 @@ SetFlagsForMovement_1::
pop bc pop bc
ld hl, OBJECT_FLAGS2 ld hl, OBJECT_FLAGS2
add hl, bc add hl, bc
res 5, [hl] res OBJ_FLAGS2_5, [hl]
xor a xor a
ret ret
@@ -2567,7 +2567,7 @@ Function586e:
ret c ret c
ld hl, OBJECT_FLAGS2 ld hl, OBJECT_FLAGS2
add hl, bc add hl, bc
set 5, [hl] set OBJ_FLAGS2_5, [hl]
xor a xor a
ret ret
@@ -2580,7 +2580,7 @@ Function587a:
jr z, .next jr z, .next
ld hl, OBJECT_FLAGS2 ld hl, OBJECT_FLAGS2
add hl, bc add hl, bc
set 5, [hl] set OBJ_FLAGS2_5, [hl]
.next .next
ld hl, OBJECT_STRUCT_LENGTH ld hl, OBJECT_STRUCT_LENGTH
add hl, bc add hl, bc
@@ -2610,7 +2610,7 @@ _SetFlagsForMovement_2::
call GetObjectStruct call GetObjectStruct
ld hl, OBJECT_FLAGS2 ld hl, OBJECT_FLAGS2
add hl, bc add hl, bc
res 5, [hl] res OBJ_FLAGS2_5, [hl]
ret ret
Function58b9:: Function58b9::
@@ -2623,7 +2623,7 @@ Function58b9::
jr z, .next jr z, .next
ld hl, OBJECT_FLAGS2 ld hl, OBJECT_FLAGS2
add hl, bc add hl, bc
res 5, [hl] res OBJ_FLAGS2_5, [hl]
.next .next
ld hl, OBJECT_STRUCT_LENGTH ld hl, OBJECT_STRUCT_LENGTH
add hl, bc add hl, bc
@@ -2641,7 +2641,7 @@ Function58d8:
ret c ret c
ld hl, OBJECT_FLAGS2 ld hl, OBJECT_FLAGS2
add hl, bc add hl, bc
res 5, [hl] res OBJ_FLAGS2_5, [hl]
ret ret
Function58e3: Function58e3:
@@ -2865,7 +2865,7 @@ InitSprites:
ld hl, OBJECT_FLAGS2 ld hl, OBJECT_FLAGS2
add hl, bc add hl, bc
ld e, [hl] ld e, [hl]
bit 7, e bit OBJ_FLAGS2_7, e
jr z, .skip2 jr z, .skip2
or PRIORITY or PRIORITY
.skip2 .skip2

View File

@@ -2,11 +2,11 @@ _HandlePlayerStep::
ld a, [wPlayerStepFlags] ld a, [wPlayerStepFlags]
and a and a
ret z ret z
bit 7, a ; starting step bit PLAYERSTEP_START_F, a
jr nz, .update_overworld_map jr nz, .update_overworld_map
bit 6, a ; finishing step bit PLAYERSTEP_STOP_F, a
jr nz, .update_player_coords jr nz, .update_player_coords
bit 5, a ; ongoing step bit PLAYERSTEP_CONTINUE_F, a
jr nz, .finish jr nz, .finish
ret ret

View File

@@ -1399,7 +1399,7 @@ Script_reloadmap:
ld [wBattleScriptFlags], a ld [wBattleScriptFlags], a
ld a, MAPSETUP_RELOADMAP ld a, MAPSETUP_RELOADMAP
ldh [hMapEntryMethod], a ldh [hMapEntryMethod], a
ld a, $1 ld a, MAPSTATUS_ENTER
call LoadMapStatus call LoadMapStatus
call StopScript call StopScript
ret ret
@@ -2473,11 +2473,11 @@ Script_warp:
ld [wXCoord], a ld [wXCoord], a
call GetScriptByte call GetScriptByte
ld [wYCoord], a ld [wYCoord], a
ld a, -1 ld a, SPAWN_N_A
ld [wDefaultSpawnpoint], a ld [wDefaultSpawnpoint], a
ld a, MAPSETUP_WARP ld a, MAPSETUP_WARP
ldh [hMapEntryMethod], a ldh [hMapEntryMethod], a
ld a, 1 ld a, MAPSTATUS_ENTER
call LoadMapStatus call LoadMapStatus
call StopScript call StopScript
ret ret
@@ -2486,11 +2486,11 @@ Script_warp:
call GetScriptByte call GetScriptByte
call GetScriptByte call GetScriptByte
call GetScriptByte call GetScriptByte
ld a, -1 ld a, SPAWN_N_A
ld [wDefaultSpawnpoint], a ld [wDefaultSpawnpoint], a
ld a, MAPSETUP_BADWARP ld a, MAPSETUP_BADWARP
ldh [hMapEntryMethod], a ldh [hMapEntryMethod], a
ld a, 1 ld a, MAPSTATUS_ENTER
call LoadMapStatus call LoadMapStatus
call StopScript call StopScript
ret ret
@@ -2611,7 +2611,7 @@ Script_newloadmap:
call GetScriptByte call GetScriptByte
ldh [hMapEntryMethod], a ldh [hMapEntryMethod], a
ld a, 1 ld a, MAPSTATUS_ENTER
call LoadMapStatus call LoadMapStatus
call StopScript call StopScript
ret ret
@@ -2793,7 +2793,7 @@ Script_credits:
farcall RedCredits farcall RedCredits
ReturnFromCredits: ReturnFromCredits:
call Script_endall call Script_endall
ld a, $3 ld a, MAPSTATUS_DONE
call LoadMapStatus call LoadMapStatus
call StopScript call StopScript
ret ret

View File

@@ -1966,7 +1966,9 @@ wTempMon:: party_struct wTempMon ; d10e
wSpriteFlags:: db ; d13e wSpriteFlags:: db ; d13e
wHandlePlayerStep:: dw ; d13f wHandlePlayerStep:: db ; d13f
ds 1
wPartyMenuActionText:: db ; d141 wPartyMenuActionText:: db ; d141
@@ -1992,14 +1994,8 @@ wPlayerBGMapOffsetY:: db ; used in FollowNotExact; unit is pixels
; Player movement ; Player movement
wPlayerStepVectorX:: db ; d14e wPlayerStepVectorX:: db ; d14e
wPlayerStepVectorY:: db ; d14f wPlayerStepVectorY:: db ; d14f
wPlayerStepFlags:: db ; d150 wPlayerStepFlags:: db ; d150
wPlayerStepDirection:: ; d151 wPlayerStepDirection:: db ; d151
; bit 7: Start step
; bit 6: Stop step
; bit 5: Doing step
; bit 4: In midair
; bits 0-3: unused
db
wBGMapAnchor:: dw ; d152 wBGMapAnchor:: dw ; d152
@@ -2278,10 +2274,7 @@ wBattleAction:: db ; d430
wd431:: db wd431:: db
wMapStatus:: db ; d432 wMapStatus:: db ; d432
wMapEventStatus:: ; d433 wMapEventStatus:: db ; d433
; 0: do map events
; 1: do background events
db
wScriptFlags:: ; d434 wScriptFlags:: ; d434
; bit 3: priority jump ; bit 3: priority jump