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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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