Skip to content

Commit

Permalink
RGBDS syntax updates (#86)
Browse files Browse the repository at this point in the history
New MACRO and DEF syntax
  • Loading branch information
vulcandth authored Jun 6, 2022
1 parent 85c9739 commit c1ef7b7
Show file tree
Hide file tree
Showing 110 changed files with 1,073 additions and 1,073 deletions.
2 changes: 1 addition & 1 deletion audio/low_health_alarm.asm
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ Music_DoLowHealthAlarm::
jr nz, .copyLoop
ret

alarm_tone: MACRO
MACRO alarm_tone
db \1 ; length
db \2 ; envelope
dw \3 ; frequency
Expand Down
4 changes: 2 additions & 2 deletions audio/pikachu_cries.asm
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
pcm: MACRO
MACRO pcm
; All of the pcm data has one trailing byte that is never processed.
dw .End - .Start - 1
.Start
\1
\1
.End
ENDM

Expand Down
34 changes: 17 additions & 17 deletions constants/audio_constants.asm
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
const A_ ; 9
const A# ; A
const B_ ; B
NUM_NOTES EQU const_value
DEF NUM_NOTES EQU const_value

; channel
; Audio[1|2|3]_HWChannelBaseAddresses, Audio[1|2|3]_HWChannelDisableMasks,
Expand All @@ -23,31 +23,31 @@ NUM_NOTES EQU const_value
const Ch2 ; 1
const Ch3 ; 2
const Ch4 ; 3
NUM_MUSIC_CHANS EQU const_value
DEF NUM_MUSIC_CHANS EQU const_value
const Ch5 ; 4
const Ch6 ; 5
const Ch7 ; 6
const Ch8 ; 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

; HW sound channel register base addresses
HW_CH1_BASE EQU LOW(rNR10)
HW_CH2_BASE EQU LOW(rNR21) - 1
HW_CH3_BASE EQU LOW(rNR30)
HW_CH4_BASE EQU LOW(rNR41) - 1
DEF HW_CH1_BASE EQU LOW(rNR10)
DEF HW_CH2_BASE EQU LOW(rNR21) - 1
DEF HW_CH3_BASE EQU LOW(rNR30)
DEF HW_CH4_BASE EQU LOW(rNR41) - 1

; HW sound channel enable bit masks
HW_CH1_ENABLE_MASK EQU %00010001
HW_CH2_ENABLE_MASK EQU %00100010
HW_CH3_ENABLE_MASK EQU %01000100
HW_CH4_ENABLE_MASK EQU %10001000
DEF HW_CH1_ENABLE_MASK EQU %00010001
DEF HW_CH2_ENABLE_MASK EQU %00100010
DEF HW_CH3_ENABLE_MASK EQU %01000100
DEF HW_CH4_ENABLE_MASK EQU %10001000

; HW sound channel disable bit masks
HW_CH1_DISABLE_MASK EQU (~HW_CH1_ENABLE_MASK & $ff)
HW_CH2_DISABLE_MASK EQU (~HW_CH2_ENABLE_MASK & $ff)
HW_CH3_DISABLE_MASK EQU (~HW_CH3_ENABLE_MASK & $ff)
HW_CH4_DISABLE_MASK EQU (~HW_CH4_ENABLE_MASK & $ff)
DEF HW_CH1_DISABLE_MASK EQU (~HW_CH1_ENABLE_MASK & $ff)
DEF HW_CH2_DISABLE_MASK EQU (~HW_CH2_ENABLE_MASK & $ff)
DEF HW_CH3_DISABLE_MASK EQU (~HW_CH3_ENABLE_MASK & $ff)
DEF HW_CH4_DISABLE_MASK EQU (~HW_CH4_ENABLE_MASK & $ff)

const_def 1
const REG_DUTY_SOUND_LEN ; 1
Expand All @@ -65,4 +65,4 @@ HW_CH4_DISABLE_MASK EQU (~HW_CH4_ENABLE_MASK & $ff)
const BIT_ROTATE_DUTY_CYCLE ; 6 ; if rotating duty cycle

; wChannelFlags2 constant (only has one flag)
BIT_EXECUTE_MUSIC EQU 0 ; if in execute music
DEF BIT_EXECUTE_MUSIC EQU 0 ; if in execute music
50 changes: 25 additions & 25 deletions constants/battle_constants.asm
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MAX_LEVEL EQU 100
DEF MAX_LEVEL EQU 100

NUM_MOVES EQU 4
DEF NUM_MOVES EQU 4

; VitaminStats indexes (see data/battle/stat_names.asm)
const_def
Expand All @@ -9,7 +9,7 @@ NUM_MOVES EQU 4
const STAT_DEFENSE
const STAT_SPEED
const STAT_SPECIAL
NUM_STATS EQU const_value
DEF NUM_STATS EQU const_value

; StatModTextStrings indexes (see data/battle/stat_mod_names.asm)
const_def
Expand All @@ -20,20 +20,20 @@ NUM_STATS EQU const_value
const MOD_ACCURACY
const MOD_EVASION
const_skip 2
NUM_STAT_MODS EQU const_value
DEF NUM_STAT_MODS EQU const_value

; Moves struct fields (see data/moves/moves.asm)
rsreset
MOVE_ANIM rb
MOVE_EFFECT rb
MOVE_POWER rb
MOVE_TYPE rb
MOVE_ACC rb
MOVE_PP rb
MOVE_LENGTH EQU _RS
DEF MOVE_ANIM rb
DEF MOVE_EFFECT rb
DEF MOVE_POWER rb
DEF MOVE_TYPE rb
DEF MOVE_ACC rb
DEF MOVE_PP rb
DEF MOVE_LENGTH EQU _RS

; D733 flags
BIT_TEST_BATTLE EQU 0
DEF BIT_TEST_BATTLE EQU 0

; battle type constants (wBattleType values)
const_def
Expand All @@ -44,33 +44,33 @@ BIT_TEST_BATTLE EQU 0
const BATTLE_TYPE_PIKACHU ; 4

; damage limits before type effectiveness
MIN_NEUTRAL_DAMAGE EQU 2
MAX_NEUTRAL_DAMAGE EQU 999
DEF MIN_NEUTRAL_DAMAGE EQU 2
DEF MAX_NEUTRAL_DAMAGE EQU 999

; fixed damage constants
SONICBOOM_DAMAGE EQU 20
DRAGON_RAGE_DAMAGE EQU 40
DEF SONICBOOM_DAMAGE EQU 20
DEF DRAGON_RAGE_DAMAGE EQU 40

; type effectiveness factors, scaled by 10
SUPER_EFFECTIVE EQU 20
MORE_EFFECTIVE EQU 15
EFFECTIVE EQU 10
NOT_VERY_EFFECTIVE EQU 05
NO_EFFECT EQU 00
DEF SUPER_EFFECTIVE EQU 20
DEF MORE_EFFECTIVE EQU 15
DEF EFFECTIVE EQU 10
DEF NOT_VERY_EFFECTIVE EQU 05
DEF NO_EFFECT EQU 00

; non-volatile statuses
SLP EQU %111 ; sleep counter
DEF SLP EQU %111 ; sleep counter
const_def 3
const PSN ; 3
const BRN ; 4
const FRZ ; 5
const PAR ; 6

MAX_STAT_VALUE EQU 999
DEF MAX_STAT_VALUE EQU 999

; trainer dvs
ATKDEFDV_TRAINER EQU $98
SPDSPCDV_TRAINER EQU $88
DEF ATKDEFDV_TRAINER EQU $98
DEF SPDSPCDV_TRAINER EQU $88

; wPlayerBattleStatus1 or wEnemyBattleStatus1 bit flags
const_def
Expand Down
2 changes: 1 addition & 1 deletion constants/credits_constants.asm
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
const CRED_NAKAMICHI ; 53
const CRED_YOSHIMURA ; 54
const CRED_YAMAZAKI ; 55
NUM_CRED_STRINGS EQU const_value
DEF NUM_CRED_STRINGS EQU const_value

const_def -1, -1
const CRED_TEXT_FADE_MON ; $FF
Expand Down
2 changes: 1 addition & 1 deletion constants/event_constants.asm
Original file line number Diff line number Diff line change
Expand Up @@ -791,4 +791,4 @@

; End of events
const_next $A00
NUM_EVENTS EQU const_value
DEF NUM_EVENTS EQU const_value
46 changes: 23 additions & 23 deletions constants/gfx_constants.asm
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
TILE_WIDTH EQU 8 ; pixels
LEN_1BPP_TILE EQU 1 * TILE_WIDTH ; bytes
LEN_2BPP_TILE EQU 2 * TILE_WIDTH ; bytes
DEF TILE_WIDTH EQU 8 ; pixels
DEF LEN_1BPP_TILE EQU 1 * TILE_WIDTH ; bytes
DEF LEN_2BPP_TILE EQU 2 * TILE_WIDTH ; bytes

SCREEN_WIDTH EQU 20
SCREEN_HEIGHT EQU 18
SCREEN_WIDTH_PX EQU SCREEN_WIDTH * TILE_WIDTH ; pixels
SCREEN_HEIGHT_PX EQU SCREEN_HEIGHT * TILE_WIDTH ; pixels
DEF SCREEN_WIDTH EQU 20
DEF SCREEN_HEIGHT EQU 18
DEF SCREEN_WIDTH_PX EQU SCREEN_WIDTH * TILE_WIDTH ; pixels
DEF SCREEN_HEIGHT_PX EQU SCREEN_HEIGHT * TILE_WIDTH ; pixels

BG_MAP_WIDTH EQU 32 ; tiles
BG_MAP_HEIGHT EQU 32 ; tiles
DEF BG_MAP_WIDTH EQU 32 ; tiles
DEF BG_MAP_HEIGHT EQU 32 ; tiles

SPRITEBUFFERSIZE EQU 7 * 7 * LEN_1BPP_TILE
DEF SPRITEBUFFERSIZE EQU 7 * 7 * LEN_1BPP_TILE

; DMGPalToGBCPal
CONVERT_BGP EQU 0
CONVERT_OBP0 EQU 1
CONVERT_OBP1 EQU 2
DEF CONVERT_BGP EQU 0
DEF CONVERT_OBP0 EQU 1
DEF CONVERT_OBP1 EQU 2

; HP bar
HP_BAR_GREEN EQU 0
HP_BAR_YELLOW EQU 1
HP_BAR_RED EQU 2
DEF HP_BAR_GREEN EQU 0
DEF HP_BAR_YELLOW EQU 1
DEF HP_BAR_RED EQU 2

; wOAMBuffer
NUM_SPRITE_OAM_STRUCTS EQU 40
DEF NUM_SPRITE_OAM_STRUCTS EQU 40

; hAutoBGTransferEnabled
TRANSFERTOP EQU 0
TRANSFERMIDDLE EQU 1
TRANSFERBOTTOM EQU 2
DEF TRANSFERTOP EQU 0
DEF TRANSFERMIDDLE EQU 1
DEF TRANSFERBOTTOM EQU 2

; hRedrawRowOrColumnMode
REDRAW_COL EQU 1
REDRAW_ROW EQU 2
DEF REDRAW_COL EQU 1
DEF REDRAW_ROW EQU 2

; tile list ids
; TileIDListPointerTable indexes (see data/tilemaps.asm)
Expand All @@ -45,4 +45,4 @@ REDRAW_ROW EQU 2
const TILEMAP_GENGAR_INTRO_3
const TILEMAP_GAME_BOY
const TILEMAP_LINK_CABLE
NUM_TILEMAPS EQU const_value
DEF NUM_TILEMAPS EQU const_value
Loading

0 comments on commit c1ef7b7

Please sign in to comment.