Define more struct offset constants with rsreset instead of const_def

This was discussed in #739
This commit is contained in:
Rangi 2021-03-04 18:13:33 -05:00
parent ef20126fe5
commit 98da09b3e9
9 changed files with 148 additions and 136 deletions

View File

@ -37,7 +37,8 @@ CHANNEL_FLAGS1 rb
CHANNEL_FLAGS2 rb
CHANNEL_FLAGS3 rb
CHANNEL_MUSIC_ADDRESS rw
CHANNEL_LAST_MUSIC_ADDRESS rw 2
CHANNEL_LAST_MUSIC_ADDRESS rw
rb_skip 2
CHANNEL_NOTE_FLAGS rb
CHANNEL_CONDITION rb
CHANNEL_DUTY_CYCLE rb
@ -47,7 +48,8 @@ CHANNEL_PITCH rb
CHANNEL_OCTAVE rb
CHANNEL_TRANSPOSITION rb
CHANNEL_NOTE_DURATION rb
CHANNEL_FIELD16 rb 2
CHANNEL_FIELD16 rb
rb_skip
CHANNEL_LOOP_COUNT rb
CHANNEL_TEMPO rw
CHANNEL_TRACKS rb
@ -59,7 +61,8 @@ CHANNEL_VIBRATO_RATE rb
CHANNEL_PITCH_SLIDE_TARGET rw
CHANNEL_PITCH_SLIDE_AMOUNT rb
CHANNEL_PITCH_SLIDE_AMOUNT_FRACTION rb
CHANNEL_FIELD25 rb 2
CHANNEL_FIELD25 rb
rb_skip
CHANNEL_PITCH_OFFSET rw
CHANNEL_FIELD29 rb
CHANNEL_FIELD2A rw
@ -67,7 +70,8 @@ CHANNEL_FIELD2C rb
CHANNEL_NOTE_LENGTH rb
CHANNEL_FIELD2E rb
CHANNEL_FIELD2F rb
CHANNEL_FIELD30 rb 2
CHANNEL_FIELD30 rb
rb_skip
CHANNEL_STRUCT_LENGTH EQU _RS
NOISE_CHAN_F EQU 2 ; bit set in CHAN5-CHAN7

View File

@ -1,25 +1,25 @@
; battle_anim_struct members (see macros/wram.asm)
const_def
const BATTLEANIMSTRUCT_INDEX
const BATTLEANIMSTRUCT_OAMFLAGS
const BATTLEANIMSTRUCT_FIX_Y
const BATTLEANIMSTRUCT_FRAMESET_ID
const BATTLEANIMSTRUCT_FUNCTION
const BATTLEANIMSTRUCT_PALETTE
const BATTLEANIMSTRUCT_TILEID
BATTLEANIMOBJ_LENGTH EQU const_value - 1 ; discount BATTLEANIMSTRUCT_INDEX
const BATTLEANIMSTRUCT_XCOORD
const BATTLEANIMSTRUCT_YCOORD
const BATTLEANIMSTRUCT_XOFFSET
const BATTLEANIMSTRUCT_YOFFSET
const BATTLEANIMSTRUCT_PARAM
const BATTLEANIMSTRUCT_DURATION
const BATTLEANIMSTRUCT_FRAME
const BATTLEANIMSTRUCT_JUMPTABLE_INDEX
const BATTLEANIMSTRUCT_VAR1
const BATTLEANIMSTRUCT_VAR2
const_skip 7
BATTLEANIMSTRUCT_LENGTH EQU const_value
rsreset
BATTLEANIMSTRUCT_INDEX rb
BATTLEANIMSTRUCT_OAMFLAGS rb
BATTLEANIMSTRUCT_FIX_Y rb
BATTLEANIMSTRUCT_FRAMESET_ID rb
BATTLEANIMSTRUCT_FUNCTION rb
BATTLEANIMSTRUCT_PALETTE rb
BATTLEANIMSTRUCT_TILEID rb
BATTLEANIMOBJ_LENGTH EQU _RS - 1 ; discount BATTLEANIMSTRUCT_INDEX
BATTLEANIMSTRUCT_XCOORD rb
BATTLEANIMSTRUCT_YCOORD rb
BATTLEANIMSTRUCT_XOFFSET rb
BATTLEANIMSTRUCT_YOFFSET rb
BATTLEANIMSTRUCT_PARAM rb
BATTLEANIMSTRUCT_DURATION rb
BATTLEANIMSTRUCT_FRAME rb
BATTLEANIMSTRUCT_JUMPTABLE_INDEX rb
BATTLEANIMSTRUCT_VAR1 rb
BATTLEANIMSTRUCT_VAR2 rb
rb_skip 7
BATTLEANIMSTRUCT_LENGTH EQU _RS
NUM_ANIM_OBJECTS EQU 10 ; see wActiveAnimObjects
; wBattleAnimTileDict size (see wram.asm)
@ -817,12 +817,12 @@ NUM_ANIM_BGS EQU const_value - 1
NUM_ANIM_GFX EQU const_value - 1
; battle_bg_effect struct members (see macros/wram.asm)
const_def
const BG_EFFECT_STRUCT_FUNCTION
const BG_EFFECT_STRUCT_JT_INDEX
const BG_EFFECT_STRUCT_BATTLE_TURN
const BG_EFFECT_STRUCT_PARAM
BG_EFFECT_STRUCT_LENGTH EQU const_value
rsreset
BG_EFFECT_STRUCT_FUNCTION rb
BG_EFFECT_STRUCT_JT_INDEX rb
BG_EFFECT_STRUCT_BATTLE_TURN rb
BG_EFFECT_STRUCT_PARAM rb
BG_EFFECT_STRUCT_LENGTH EQU _RS
NUM_BG_EFFECTS EQU 5 ; see wActiveBGEffects
; anim_bgeffect battle turn values for some effects

View File

@ -1,12 +1,11 @@
; decoration attributes
const_def
const DECOATTR_TYPE
const DECOATTR_NAME
const DECOATTR_ACTION
const DECOATTR_EVENT_FLAG
const_skip ; high DECOATTR_EVENT_FLAG byte
const DECOATTR_SPRITE
DECOATTR_STRUCT_LENGTH EQU const_value
rsreset
DECOATTR_TYPE rb
DECOATTR_NAME rb
DECOATTR_ACTION rb
DECOATTR_EVENT_FLAG rw
DECOATTR_SPRITE rb
DECOATTR_STRUCT_LENGTH EQU _RS
; decoration types
const_def 1

View File

@ -34,12 +34,12 @@ HP_YELLOW EQU 1
HP_RED EQU 2
; sprite_oam_struct members (see macros/wram.asm)
const_def
const SPRITEOAMSTRUCT_YCOORD ; 0
const SPRITEOAMSTRUCT_XCOORD ; 1
const SPRITEOAMSTRUCT_TILE_ID ; 2
const SPRITEOAMSTRUCT_ATTRIBUTES ; 3
SPRITEOAMSTRUCT_LENGTH EQU const_value
rsreset
SPRITEOAMSTRUCT_YCOORD rb ; 0
SPRITEOAMSTRUCT_XCOORD rb ; 1
SPRITEOAMSTRUCT_TILE_ID rb ; 2
SPRITEOAMSTRUCT_ATTRIBUTES rb ; 3
SPRITEOAMSTRUCT_LENGTH EQU _RS
NUM_SPRITE_OAM_STRUCTS EQU 40 ; see wVirtualOAM
SPRITE_GFX_LIST_CAPACITY EQU 32 ; see wUsedSprites

View File

@ -1,13 +1,15 @@
; item_attributes struct members (see data/items/attributes.asm)
const_def
const ITEMATTR_PRICE_LO
const ITEMATTR_PRICE_HI
const ITEMATTR_EFFECT
const ITEMATTR_PARAM
const ITEMATTR_PERMISSIONS
const ITEMATTR_POCKET
const ITEMATTR_HELP
ITEMATTR_STRUCT_LENGTH EQU const_value
rsreset
ITEMATTR_PRICE rw
rsset ITEMATTR_PRICE
ITEMATTR_PRICE_LO rb
ITEMATTR_PRICE_HI rb
ITEMATTR_EFFECT rb
ITEMATTR_PARAM rb
ITEMATTR_PERMISSIONS rb
ITEMATTR_POCKET rb
ITEMATTR_HELP rb
ITEMATTR_STRUCT_LENGTH EQU _RS
; item types
const_def 1

View File

@ -1,40 +1,40 @@
; object_struct members (see macros/wram.asm)
const_def
const OBJECT_SPRITE ; 00
const OBJECT_MAP_OBJECT_INDEX ; 01
const OBJECT_SPRITE_TILE ; 02
const OBJECT_MOVEMENTTYPE ; 03
const OBJECT_FLAGS1 ; 04
const OBJECT_FLAGS2 ; 05
const OBJECT_PALETTE ; 06
const OBJECT_DIRECTION_WALKING ; 07
const OBJECT_FACING ; 08
const OBJECT_STEP_TYPE ; 09
const OBJECT_STEP_DURATION ; 0a
const OBJECT_ACTION ; 0b
const OBJECT_STEP_FRAME ; 0c
const OBJECT_FACING_STEP ; 0d
const OBJECT_NEXT_TILE ; 0e
const OBJECT_STANDING_TILE ; 0f
const OBJECT_NEXT_MAP_X ; 10
const OBJECT_NEXT_MAP_Y ; 11
const OBJECT_MAP_X ; 12
const OBJECT_MAP_Y ; 13
const OBJECT_INIT_X ; 14
const OBJECT_INIT_Y ; 15
const OBJECT_RADIUS ; 16
const OBJECT_SPRITE_X ; 17
const OBJECT_SPRITE_Y ; 18
const OBJECT_SPRITE_X_OFFSET ; 19
const OBJECT_SPRITE_Y_OFFSET ; 1a
const OBJECT_MOVEMENT_BYTE_INDEX ; 1b
const OBJECT_1C ; 1c
const OBJECT_1D ; 1d
const OBJECT_1E ; 1e
const OBJECT_1F ; 1f
const OBJECT_RANGE ; 20
const_skip 7
OBJECT_LENGTH EQU const_value
rsreset
OBJECT_SPRITE rb ; 00
OBJECT_MAP_OBJECT_INDEX rb ; 01
OBJECT_SPRITE_TILE rb ; 02
OBJECT_MOVEMENTTYPE rb ; 03
OBJECT_FLAGS1 rb ; 04
OBJECT_FLAGS2 rb ; 05
OBJECT_PALETTE rb ; 06
OBJECT_DIRECTION_WALKING rb ; 07
OBJECT_FACING rb ; 08
OBJECT_STEP_TYPE rb ; 09
OBJECT_STEP_DURATION rb ; 0a
OBJECT_ACTION rb ; 0b
OBJECT_STEP_FRAME rb ; 0c
OBJECT_FACING_STEP rb ; 0d
OBJECT_NEXT_TILE rb ; 0e
OBJECT_STANDING_TILE rb ; 0f
OBJECT_NEXT_MAP_X rb ; 10
OBJECT_NEXT_MAP_Y rb ; 11
OBJECT_MAP_X rb ; 12
OBJECT_MAP_Y rb ; 13
OBJECT_INIT_X rb ; 14
OBJECT_INIT_Y rb ; 15
OBJECT_RADIUS rb ; 16
OBJECT_SPRITE_X rb ; 17
OBJECT_SPRITE_Y rb ; 18
OBJECT_SPRITE_X_OFFSET rb ; 19
OBJECT_SPRITE_Y_OFFSET rb ; 1a
OBJECT_MOVEMENT_BYTE_INDEX rb ; 1b
OBJECT_1C rb ; 1c
OBJECT_1D rb ; 1d
OBJECT_1E rb ; 1e
OBJECT_1F rb ; 1f
OBJECT_RANGE rb ; 20
rb_skip 7
OBJECT_LENGTH EQU _RS
NUM_OBJECT_STRUCTS EQU 13 ; see wObjectStructs
; object_struct OBJECT_FACING values
@ -97,33 +97,31 @@ RELATIVE_ATTRIBUTES EQU 1 << RELATIVE_ATTRIBUTES_F
ABSOLUTE_TILE_ID EQU 1 << ABSOLUTE_TILE_ID_F
; map_object struct members (see macros/wram.asm)
const_def
const MAPOBJECT_OBJECT_STRUCT_ID ; 0
const MAPOBJECT_SPRITE ; 1
const MAPOBJECT_Y_COORD ; 2
const MAPOBJECT_X_COORD ; 3
const MAPOBJECT_MOVEMENT ; 4
const MAPOBJECT_RADIUS ; 5
const MAPOBJECT_HOUR ; 6
const MAPOBJECT_TIMEOFDAY ; 7
const MAPOBJECT_COLOR ; 8
const MAPOBJECT_RANGE ; 9
const MAPOBJECT_SCRIPT_POINTER ; a
const_skip ; high MAPOBJECT_SCRIPT_POINTER byte
const MAPOBJECT_EVENT_FLAG ; c
const_skip ; high MAPOBJECT_EVENT_FLAG byte
const_skip 2 ; unused
MAPOBJECT_LENGTH EQU const_value
rsreset
MAPOBJECT_OBJECT_STRUCT_ID rb ; 0
MAPOBJECT_SPRITE rb ; 1
MAPOBJECT_Y_COORD rb ; 2
MAPOBJECT_X_COORD rb ; 3
MAPOBJECT_MOVEMENT rb ; 4
MAPOBJECT_RADIUS rb ; 5
MAPOBJECT_HOUR rb ; 6
MAPOBJECT_TIMEOFDAY rb ; 7
MAPOBJECT_COLOR rb ; 8
MAPOBJECT_RANGE rb ; 9
MAPOBJECT_SCRIPT_POINTER rw ; a
MAPOBJECT_EVENT_FLAG rw ; c
rb_skip 2
MAPOBJECT_LENGTH EQU _RS
; SpriteMovementData struct members (see data/sprites/map_objects.asm)
const_def
const SPRITEMOVEATTR_MOVEMENT ; 0
const SPRITEMOVEATTR_FACING ; 1
const SPRITEMOVEATTR_ACTION ; 2
const SPRITEMOVEATTR_FLAGS1 ; 3
const SPRITEMOVEATTR_FLAGS2 ; 4
const SPRITEMOVEATTR_PALFLAGS ; 5
NUM_SPRITEMOVEDATA_FIELDS EQU const_value
rsreset
SPRITEMOVEATTR_MOVEMENT rb ; 0
SPRITEMOVEATTR_FACING rb ; 1
SPRITEMOVEATTR_ACTION rb ; 2
SPRITEMOVEATTR_FLAGS1 rb ; 3
SPRITEMOVEATTR_FLAGS2 rb ; 4
SPRITEMOVEATTR_PALFLAGS rb ; 5
NUM_SPRITEMOVEDATA_FIELDS EQU _RS
MAPOBJECT_SCREEN_WIDTH EQU (SCREEN_WIDTH / 2) + 2
MAPOBJECT_SCREEN_HEIGHT EQU (SCREEN_HEIGHT / 2) + 2

View File

@ -20,9 +20,9 @@ rsset BASE_ITEMS
BASE_ITEM_1 rb
BASE_ITEM_2 rb
BASE_GENDER rb
BASE_UNKNOWN_1 rb
rb_skip
BASE_EGG_STEPS rb
BASE_UNKNOWN_2 rb
rb_skip
BASE_PIC_SIZE rb
BASE_FRONTPIC rw
BASE_BACKPIC rw
@ -98,7 +98,8 @@ MON_CAUGHTLEVEL rb
MON_CAUGHTLOCATION rb
MON_LEVEL rb
BOXMON_STRUCT_LENGTH EQU _RS
MON_STATUS rb 2
MON_STATUS rb
rb_skip
MON_HP rw
MON_MAXHP rw
MON_ATK rw

View File

@ -1,22 +1,22 @@
; sprite_anim_struct members (see macros/wram.asm)
const_def
const SPRITEANIMSTRUCT_INDEX ; 0
const SPRITEANIMSTRUCT_FRAMESET_ID ; 1
const SPRITEANIMSTRUCT_ANIM_SEQ_ID ; 2
const SPRITEANIMSTRUCT_TILE_ID ; 3
const SPRITEANIMSTRUCT_XCOORD ; 4
const SPRITEANIMSTRUCT_YCOORD ; 5
const SPRITEANIMSTRUCT_XOFFSET ; 6
const SPRITEANIMSTRUCT_YOFFSET ; 7
const SPRITEANIMSTRUCT_DURATION ; 8
const SPRITEANIMSTRUCT_DURATIONOFFSET ; 9
const SPRITEANIMSTRUCT_FRAME ; a
const SPRITEANIMSTRUCT_JUMPTABLE_INDEX ; b
const SPRITEANIMSTRUCT_VAR1 ; c
const SPRITEANIMSTRUCT_VAR2 ; d
const SPRITEANIMSTRUCT_VAR3 ; e
const SPRITEANIMSTRUCT_VAR4 ; f
SPRITEANIMSTRUCT_LENGTH EQU const_value
rsreset
SPRITEANIMSTRUCT_INDEX rb ; 0
SPRITEANIMSTRUCT_FRAMESET_ID rb ; 1
SPRITEANIMSTRUCT_ANIM_SEQ_ID rb ; 2
SPRITEANIMSTRUCT_TILE_ID rb ; 3
SPRITEANIMSTRUCT_XCOORD rb ; 4
SPRITEANIMSTRUCT_YCOORD rb ; 5
SPRITEANIMSTRUCT_XOFFSET rb ; 6
SPRITEANIMSTRUCT_YOFFSET rb ; 7
SPRITEANIMSTRUCT_DURATION rb ; 8
SPRITEANIMSTRUCT_DURATIONOFFSET rb ; 9
SPRITEANIMSTRUCT_FRAME rb ; a
SPRITEANIMSTRUCT_JUMPTABLE_INDEX rb ; b
SPRITEANIMSTRUCT_VAR1 rb ; c
SPRITEANIMSTRUCT_VAR2 rb ; d
SPRITEANIMSTRUCT_VAR3 rb ; e
SPRITEANIMSTRUCT_VAR4 rb ; f
SPRITEANIMSTRUCT_LENGTH EQU _RS
NUM_SPRITE_ANIM_STRUCTS EQU 10 ; see wSpriteAnimationStructs
; wSpriteAnimDict keys (see wram.asm)

View File

@ -38,3 +38,11 @@ else
const_value = \1
endc
ENDM
rb_skip: MACRO
if _NARG == 1
rsset _RS + \1
else
rsset _RS + 1
endc
ENDM