Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RGBDS syntax updates #905

Merged
merged 13 commits into from
Jun 6, 2022
24 changes: 12 additions & 12 deletions STYLE.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,19 +79,19 @@ hPascalCase: ; hram
PascalCase: ; rom

; Some constants are also prefixed
rBGP EQU $ff47 ; hardware register
DEF rBGP EQU $ff47 ; hardware register

; Most other constants should be upper case
UPPER_CASE EQU 1
DEF UPPER_CASE EQU 1


; Long lists of constants should be aligned
SHORT_CONSTANT EQU 1
LONGER_CONSTANT EQU 2
PRETTY_LONG_CONSTANT EQU 3
TINY EQU 4
DEF SHORT_CONSTANT EQU 1
DEF LONGER_CONSTANT EQU 2
DEF PRETTY_LONG_CONSTANT EQU 3
DEF TINY EQU 4

BUT_ONLY_RELATED_CONSTANTS EQU 5
DEF BUT_ONLY_RELATED_CONSTANTS EQU 5

```

Expand All @@ -103,12 +103,12 @@ BUT_ONLY_RELATED_CONSTANTS EQU 5
SECTION "section", ROMX
INCLUDE "filename"
INCBIN "filename"
my_macro: MACRO
MACRO my_macro
nop
ENDM
TEST EQUS "test"
DEF TEST EQUS "test"
PURGE TEST
TEST EQU 2
DEF TEST EQU 2

; data macros should be lowercase
db 1
Expand All @@ -135,7 +135,7 @@ endr

```asm

when_in_doubt_lowercase: MACRO
MACRO when_in_doubt_lowercase

; only shift if it's required or more readable

Expand All @@ -158,7 +158,7 @@ endr
ENDM


UPPER_CASE_IS_OK_SOMETIMES: MACRO
MACRO UPPER_CASE_IS_OK_SOMETIMES

; but I can't think of any examples besides ACRONYMS

Expand Down
120 changes: 60 additions & 60 deletions constants/audio_constants.asm
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
const A_ ; a
const A# ; b
const B_ ; c
NUM_NOTES EQU const_value - 1
DEF NUM_NOTES EQU const_value - 1

; channel
; ChannelPointers indexes (see audio/engine.asm)
Expand All @@ -22,60 +22,60 @@ NUM_NOTES EQU const_value - 1
const CHAN2 ; 1
const CHAN3 ; 2
const CHAN4 ; 3
NUM_MUSIC_CHANS EQU const_value
DEF NUM_MUSIC_CHANS EQU const_value
const CHAN5 ; 4
const CHAN6 ; 5
const CHAN7 ; 6
const CHAN8 ; 7
NUM_NOISE_CHANS EQU const_value - NUM_MUSIC_CHANS
NUM_CHANNELS EQU const_value
DEF NUM_NOISE_CHANS EQU const_value - NUM_MUSIC_CHANS
DEF NUM_CHANNELS EQU const_value

; channel_struct members (see macros/wram.asm)
rsreset
CHANNEL_MUSIC_ID rw
CHANNEL_MUSIC_BANK rb
CHANNEL_FLAGS1 rb
CHANNEL_FLAGS2 rb
CHANNEL_FLAGS3 rb
CHANNEL_MUSIC_ADDRESS rw
CHANNEL_LAST_MUSIC_ADDRESS rw
rb_skip 2
CHANNEL_NOTE_FLAGS rb
CHANNEL_CONDITION rb
CHANNEL_DUTY_CYCLE rb
CHANNEL_VOLUME_ENVELOPE rb
CHANNEL_FREQUENCY rw
CHANNEL_PITCH rb
CHANNEL_OCTAVE rb
CHANNEL_TRANSPOSITION rb
CHANNEL_NOTE_DURATION rb
CHANNEL_FIELD16 rb
rb_skip
CHANNEL_LOOP_COUNT rb
CHANNEL_TEMPO rw
CHANNEL_TRACKS rb
CHANNEL_DUTY_CYCLE_PATTERN rb
CHANNEL_VIBRATO_DELAY_COUNT rb
CHANNEL_VIBRATO_DELAY rb
CHANNEL_VIBRATO_EXTENT rb
CHANNEL_VIBRATO_RATE rb
CHANNEL_PITCH_SLIDE_TARGET rw
CHANNEL_PITCH_SLIDE_AMOUNT rb
CHANNEL_PITCH_SLIDE_AMOUNT_FRACTION rb
CHANNEL_FIELD25 rb
rb_skip
CHANNEL_PITCH_OFFSET rw
CHANNEL_FIELD29 rb
CHANNEL_FIELD2A rw
CHANNEL_FIELD2C rb
CHANNEL_NOTE_LENGTH rb
CHANNEL_FIELD2E rb
CHANNEL_FIELD2F rb
CHANNEL_FIELD30 rb
rb_skip
CHANNEL_STRUCT_LENGTH EQU _RS
DEF CHANNEL_MUSIC_ID rw
DEF CHANNEL_MUSIC_BANK rb
DEF CHANNEL_FLAGS1 rb
DEF CHANNEL_FLAGS2 rb
DEF CHANNEL_FLAGS3 rb
DEF CHANNEL_MUSIC_ADDRESS rw
DEF CHANNEL_LAST_MUSIC_ADDRESS rw
rb_skip 2
DEF CHANNEL_NOTE_FLAGS rb
DEF CHANNEL_CONDITION rb
DEF CHANNEL_DUTY_CYCLE rb
DEF CHANNEL_VOLUME_ENVELOPE rb
DEF CHANNEL_FREQUENCY rw
DEF CHANNEL_PITCH rb
DEF CHANNEL_OCTAVE rb
DEF CHANNEL_TRANSPOSITION rb
DEF CHANNEL_NOTE_DURATION rb
DEF CHANNEL_FIELD16 rb
rb_skip
DEF CHANNEL_LOOP_COUNT rb
DEF CHANNEL_TEMPO rw
DEF CHANNEL_TRACKS rb
DEF CHANNEL_DUTY_CYCLE_PATTERN rb
DEF CHANNEL_VIBRATO_DELAY_COUNT rb
DEF CHANNEL_VIBRATO_DELAY rb
DEF CHANNEL_VIBRATO_EXTENT rb
DEF CHANNEL_VIBRATO_RATE rb
DEF CHANNEL_PITCH_SLIDE_TARGET rw
DEF CHANNEL_PITCH_SLIDE_AMOUNT rb
DEF CHANNEL_PITCH_SLIDE_AMOUNT_FRACTION rb
DEF CHANNEL_FIELD25 rb
rb_skip
DEF CHANNEL_PITCH_OFFSET rw
DEF CHANNEL_FIELD29 rb
DEF CHANNEL_FIELD2A rw
DEF CHANNEL_FIELD2C rb
DEF CHANNEL_NOTE_LENGTH rb
DEF CHANNEL_FIELD2E rb
DEF CHANNEL_FIELD2F rb
DEF CHANNEL_FIELD30 rb
rb_skip
DEF CHANNEL_STRUCT_LENGTH EQU _RS

NOISE_CHAN_F EQU 2 ; bit set in CHAN5-CHAN7
DEF NOISE_CHAN_F EQU 2 ; bit set in CHAN5-CHAN7

; Flags1
const_def
Expand Down Expand Up @@ -113,22 +113,22 @@ NOISE_CHAN_F EQU 2 ; bit set in CHAN5-CHAN7
const NOTE_VIBRATO_OVERRIDE ; 6

; wVolume
VOLUME_SO1_F EQU 3
VOLUME_SO2_F EQU 7
VOLUME_SO1_LEVEL EQU %00000111
VOLUME_SO2_LEVEL EQU %01110000
MAX_VOLUME EQU $77
DEF VOLUME_SO1_F EQU 3
DEF VOLUME_SO2_F EQU 7
DEF VOLUME_SO1_LEVEL EQU %00000111
DEF VOLUME_SO2_LEVEL EQU %01110000
DEF MAX_VOLUME EQU $77

; wSoundInput
SOUND_INPUT_CH1_F EQU 0
SOUND_INPUT_CH2_F EQU 1
SOUND_INPUT_CH3_F EQU 2
SOUND_INPUT_CH4_F EQU 3
SOUND_INPUT_GLOBAL_F EQU 7
DEF SOUND_INPUT_CH1_F EQU 0
DEF SOUND_INPUT_CH2_F EQU 1
DEF SOUND_INPUT_CH3_F EQU 2
DEF SOUND_INPUT_CH4_F EQU 3
DEF SOUND_INPUT_GLOBAL_F EQU 7

; wLowHealthAlarm
DANGER_PITCH_F EQU 4
DANGER_ON_F EQU 7
DEF DANGER_PITCH_F EQU 4
DEF DANGER_ON_F EQU 7

; wMusicFade
MUSIC_FADE_IN_F EQU 7
DEF MUSIC_FADE_IN_F EQU 7
70 changes: 35 additions & 35 deletions constants/battle_anim_constants.asm
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
; battle_anim_struct members (see macros/wram.asm)
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
DEF BATTLEANIMSTRUCT_INDEX rb
DEF BATTLEANIMSTRUCT_OAMFLAGS rb
DEF BATTLEANIMSTRUCT_FIX_Y rb
DEF BATTLEANIMSTRUCT_FRAMESET_ID rb
DEF BATTLEANIMSTRUCT_FUNCTION rb
DEF BATTLEANIMSTRUCT_PALETTE rb
DEF BATTLEANIMSTRUCT_TILEID rb
DEF BATTLEANIMOBJ_LENGTH EQU _RS - 1 ; discount BATTLEANIMSTRUCT_INDEX
DEF BATTLEANIMSTRUCT_XCOORD rb
DEF BATTLEANIMSTRUCT_YCOORD rb
DEF BATTLEANIMSTRUCT_XOFFSET rb
DEF BATTLEANIMSTRUCT_YOFFSET rb
DEF BATTLEANIMSTRUCT_PARAM rb
DEF BATTLEANIMSTRUCT_DURATION rb
DEF BATTLEANIMSTRUCT_FRAME rb
DEF BATTLEANIMSTRUCT_JUMPTABLE_INDEX rb
DEF BATTLEANIMSTRUCT_VAR1 rb
DEF BATTLEANIMSTRUCT_VAR2 rb
rb_skip 7
DEF BATTLEANIMSTRUCT_LENGTH EQU _RS
DEF NUM_ANIM_OBJECTS EQU 10 ; see wActiveAnimObjects

; wBattleAnimTileDict size (see wram.asm)
NUM_BATTLEANIMTILEDICT_ENTRIES EQU 5
DEF NUM_BATTLEANIMTILEDICT_ENTRIES EQU 5

; Start tile for battle animation graphics
BATTLEANIM_BASE_TILE EQU 7 * 7 ; Maximum size of a pokemon picture
DEF BATTLEANIM_BASE_TILE EQU 7 * 7 ; Maximum size of a pokemon picture

; BattleAnimObjects indexes (see data/battle_anims/objects.asm)
const_def
Expand Down Expand Up @@ -218,7 +218,7 @@ BATTLEANIM_BASE_TILE EQU 7 * 7 ; Maximum size of a pokemon picture
const ANIM_OBJ_PLAYERHEAD_1ROW
const ANIM_OBJ_ENEMYFEET_2ROW
const ANIM_OBJ_PLAYERHEAD_2ROW
NUM_ANIM_OBJS EQU const_value
DEF NUM_ANIM_OBJS EQU const_value

; DoBattleAnimFrame arguments (see engine/battle_anims/functions.asm)
const_def
Expand Down Expand Up @@ -302,7 +302,7 @@ NUM_ANIM_OBJS EQU const_value
const BATTLEANIMFUNC_ANCIENT_POWER
const BATTLEANIMFUNC_ROCK_SMASH
const BATTLEANIMFUNC_COTTON
NUM_BATTLEANIMFUNCS EQU const_value
DEF NUM_BATTLEANIMFUNCS EQU const_value

; BattleAnimFrameData indexes (see data/battle_anims/framesets.asm)
const_def
Expand Down Expand Up @@ -491,7 +491,7 @@ NUM_BATTLEANIMFUNCS EQU const_value
const BATTLEANIMFRAMESET_B6
const BATTLEANIMFRAMESET_B7
const BATTLEANIMFRAMESET_B8
NUM_BATTLEANIMFRAMESETS EQU const_value
DEF NUM_BATTLEANIMFRAMESETS EQU const_value

; BattleAnimOAMData indexes (see data/battle_anims/oam.asm)
const_def
Expand Down Expand Up @@ -711,7 +711,7 @@ NUM_BATTLEANIMFRAMESETS EQU const_value
const BATTLEANIMOAMSET_D5
const BATTLEANIMOAMSET_D6
const BATTLEANIMOAMSET_D7
NUM_BATTLEANIMOAMSETS EQU const_value
DEF NUM_BATTLEANIMOAMSETS EQU const_value

; BattleBGEffects indexes (see engine/battle_anims/bg_effects.asm)
const_def 1
Expand Down Expand Up @@ -768,7 +768,7 @@ NUM_BATTLEANIMOAMSETS EQU const_value
const ANIM_BG_VIBRATE_MON
const ANIM_BG_WOBBLE_PLAYER
const ANIM_BG_WOBBLE_SCREEN
NUM_ANIM_BGS EQU const_value - 1
DEF NUM_ANIM_BGS EQU const_value - 1

; wBattleAnimTileDict keys (see wram.asm)
; AnimObjGFX indexes (see data/battle_anims/object_gfx.asm)
Expand Down Expand Up @@ -814,16 +814,16 @@ NUM_ANIM_BGS EQU const_value - 1
const ANIM_GFX_AEROBLAST
const ANIM_GFX_PLAYERHEAD
const ANIM_GFX_ENEMYFEET
NUM_ANIM_GFX EQU const_value - 1
DEF NUM_ANIM_GFX EQU const_value - 1

; battle_bg_effect struct members (see macros/wram.asm)
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
DEF BG_EFFECT_STRUCT_FUNCTION rb
DEF BG_EFFECT_STRUCT_JT_INDEX rb
DEF BG_EFFECT_STRUCT_BATTLE_TURN rb
DEF BG_EFFECT_STRUCT_PARAM rb
DEF BG_EFFECT_STRUCT_LENGTH EQU _RS
DEF NUM_BG_EFFECTS EQU 5 ; see wActiveBGEffects

; anim_bgeffect battle turn values for some effects
const_def
Expand Down
Loading