src: use newer macro syntax

Fixes warnings on rgbds 0.6
This commit is contained in:
Pierre de La Morinerie 2022-09-13 07:20:44 +00:00
parent 260823a58c
commit 1dc84e92ec
7 changed files with 45 additions and 45 deletions

View File

@ -1,45 +1,45 @@
end_def: macro
macro end_def
db $00
endm
rest: macro
macro rest
db $01
endm
; Sets [wActiveMusicTableIndex] to 1.
unknownop_94: macro
macro unknownop_94
db $94
endm
; Sets [wD3CD] to 0.
disable_unknown1: macro
macro disable_unknown1
db $95
endm
; Sets [wD3CD] to 1.
enable_unknown1: macro
macro enable_unknown1
db $96
endm
; Sets [wD3B6 + channelIndex] to 1.
enable_unknown2: macro
macro enable_unknown2
db $97
endm
; Sets [wD3B6 + channelIndex] to 0.
disable_unknown2: macro
macro disable_unknown2
db $98
endm
; This seems to enable some kind of mode that controls the volume, similar to
; the hardware envelope? (This name is just a guess and may need to be changed.)
; Sets [wD39E] to 1.
enable_software_envelope: macro
macro enable_software_envelope
db $99
endm
; Ses [wD39E] to 0.
disable_software_envelope: macro
macro disable_software_envelope
db $9a
endm
@ -48,17 +48,17 @@ endm
; Arg1: Number of times to loop. (NEXT_LOOP macro will jump back that many
; times.) If bit 7 is set, this causes some special-case code in the Noise
; channel when note NOISE_FF is played?
begin_loop: macro
macro begin_loop
db $9b, \1
endm
; Loops back to begin_loop, or continues on if it's looped enough times already.
next_loop: macro
macro next_loop
db $9c
endm
; Set waveform data for channel 3 ONLY.
set_waveform: macro
macro set_waveform
db $9d
dw \1
db \2
@ -74,31 +74,31 @@ endm
; Arg 4: Note length; bits 0-5 or NRx1
;
; The opcode's 3 bytes are written to D3x6, D3x7, D3x8 (x = channel number).
set_envelope_duty: macro
macro set_envelope_duty
ASSERT \3 < 4, "set_envelope_duty: Invalid duty cycle value \3"
ASSERT \4 < $40, "set_envelope_duty: Note length must be less than 0x40, got \4"
db $9d, \1, \2, ((\3<<6) | \4)
endm
; Takes a pointer to some data which determines the music speed.
set_speed: macro
macro set_speed
db $9e
dw \1
endm
; Set the transpose value to transpose all subsequent notes.
set_transpose: macro
macro set_transpose
db $9f, \1 * 2
endm
; Sets the length of subsequent notes.
notelen: macro
macro notelen
ASSERT \1 <= $f, "notelen: Length must be less than or equal to $f, got \1"
db $a0 + \1
endm
; Play a note. Can pass multiple notes to this.
note: macro
macro note
REPT _NARG
ASSERT (\1 >= $1 && \1 <= $90) || \1 == $ff, "note: Invalid note value \1"
db \1

View File

@ -2,12 +2,12 @@
; This file was created with mgbdis v1.3 - Game Boy ROM disassembler by Matt Currie.
; https://github.com/mattcurrie/mgbdis
CREDITS_MACRO: macro
macro CREDITS_MACRO
CREDITS_MACRO_LDH_AND_ADD
CREDITS_MACRO_LD
endm
CREDITS_MACRO_LDH_AND_ADD: macro
macro CREDITS_MACRO_LDH_AND_ADD
IF !__PATCH_0__
ldh a, [hFrameCounter]
and $03
@ -15,7 +15,7 @@ IF !__PATCH_0__
ENDC
endm
CREDITS_MACRO_LDH_AND_LD: macro
macro CREDITS_MACRO_LDH_AND_LD
mask = $03
IF _NARG == 1
mask = \1
@ -28,13 +28,13 @@ IF !__PATCH_0__
ENDC
endm
CREDITS_MACRO_LD: macro
macro CREDITS_MACRO_LD
IF !__PATCH_0__
ld e, a
ENDC
endm
CREDITS_MACRO_ADD: macro
macro CREDITS_MACRO_ADD
IF !__PATCH_0__
add e
ENDC
@ -1112,7 +1112,7 @@ Data_017_4B3A::
db $01, $01, $00, $01, $01, $01, $01, $01, $01, $00, $01, $00, $00, $00, $00, $00
db $01, $01, $00, $00, $00, $00, $00, $00, $00, $00, $01, $00, $00, $00, $00, $00
CREDITS_FADE: macro
macro CREDITS_FADE
IF !__PATCH_0__
db \1, \1, \1, \1
db \2, \2, \2, \2

View File

@ -602,7 +602,7 @@ SaveSlotNameAddresses::
._02 db wSaveSlot2Name - wSaveSlotNames
._03 db wSaveSlot3Name - wSaveSlotNames ; $4A98
CHECKNAME: macro
macro CHECKNAME
ld hl, wSaveSlotNames
add hl, de
I = 0

View File

@ -2,40 +2,40 @@
; GBC palette entry
; RGB r, g, b
; values: 0 ~ 31
RGB: macro
macro RGB
db (\1) + (\2) << 5 + (\3) << 10
endm
; Farcall using direct bank selection
callsb: macro
macro callsb
ld a, BANK(\1)
ld [MBC3SelectBank], a
call \1
endm
; Farcall using direct bank selection with hl
callhl: macro
macro callhl
ld hl, MBC3SelectBank
ld [hl], BANK(\1)
call \1
endm
; Farcall using SwitchBank
callsw: macro
macro callsw
ld a, BANK(\1)
call SwitchBank
call \1
endm
; Jump using SwitchBank
jpsb: macro
macro jpsb
ld a, BANK(\1)
ld [MBC3SelectBank], a
jp \1
endm
; Jump using SwitchBank
jpsw: macro
macro jpsw
ld a, BANK(\1)
call SwitchBank
jp \1
@ -45,28 +45,28 @@ endm
; which means reseting the PC to 0 activates the jump table.
;
; See the JumpTable function for details and usage.
JP_TABLE: macro
macro JP_TABLE
rst 0
endm
; Store an address and the associated bank.
; First 2 bytes: memory address; third byte: bank id
far_pointer: macro
macro far_pointer
db LOW(\1), HIGH(\1), BANK(\1)
endm
far_pointer_null: macro
macro far_pointer_null
db $00, $00, $00
endm
; Define an entity in an entities list
; Usage:
; entity <vertical-position>, <horizontal-position>, <type>
entity: macro
macro entity
db \1 * $10 + \2, \3
endm
entities_end: macro
macro entities_end
db ENTITIES_END
endm
@ -78,7 +78,7 @@ endm
;
; Usage:
; dialog_pointer Dialog123 ; Emits: "Dialog123_IdxOffset: dw Dialog123"
dialog_pointer: macro
macro dialog_pointer
\1_IdxOffset:
dw \1
endm
@ -89,7 +89,7 @@ endm
;
; NB: if rgbasm ever supports user-defined functions, then we'll replace this by:
; ld a, DIALOG_ID_LOW(Dialog123)
ld_dialog_low: macro
macro ld_dialog_low
ld \1, LOW((\2_IdxOffset - DialogPointerTable) / 2)
endm
@ -99,7 +99,7 @@ endm
;
; NB: if rgbasm ever supports user-defined functions, then we'll replace this by:
; db DIALOG_ID_LOW(Dialog123)
db_dialog_low: macro
macro db_dialog_low
db LOW((\1_IdxOffset - DialogPointerTable) / 2)
endm
@ -109,14 +109,14 @@ endm
;
; NB: if rgbasm ever supports user-defined functions, then we'll replace this by:
; cp DIALOG_ID_LOW(Dialog123)
cp_dialog_low: macro
macro cp_dialog_low
cp LOW((\1_IdxOffset - DialogPointerTable) / 2)
endm
; Open a dialog in the correct dialogs table (using a `call` instruction)
; Usage:
; call_open_dialog Dialog123 ; Emits "ld a, $23 \n call OpenDialogInTable1"
call_open_dialog: macro
macro call_open_dialog
ld a, LOW((\1_IdxOffset - DialogPointerTable) / 2)
; Ihe code needs to call the correct function, but the exact dialog index isn't available at compile-time
; (only at link-time), so we can't use IF().
@ -129,7 +129,7 @@ endm
; Open a dialog in the correct dialogs table (using a `jp` instruction)
; Usage:
; jp_open_dialog Dialog123 ; emits "ld a, $23 \n jp OpenDialogInTable1"
jp_open_dialog: macro
macro jp_open_dialog
ld a, LOW((\1_IdxOffset - DialogPointerTable) / 2)
jp (OpenDialogInTable0 * (HIGH((\1_IdxOffset - DialogPointerTable) / 2) == 0)) \
| (OpenDialogInTable1 * (HIGH((\1_IdxOffset - DialogPointerTable) / 2) == 1)) \

View File

@ -2103,7 +2103,7 @@ PhotoAlbumStartPrint5Handler:
.return_4CDF_28:
ret ; $4CDF: PhotoAlbumStartPrint5Handler $C9
MAKE_PRINT_ERROR: macro
macro MAKE_PRINT_ERROR
; oam data, terminated with $FF
IF __PATCH_1__
db $50, $38, $1E, $00

View File

@ -9,14 +9,14 @@
; Defines a Super Game Boy command.
; Usage:
; sgb_cmd <command code>, <length>
sgb_cmd: macro
macro sgb_cmd
db (\1) << 3 + (\2)
endm
; Defines a Super Game Boy 'Data Send' command.
; Usage:
; sgb_data_snd <SNES destination address>, <SNES destination bank>, <data length>
sgb_data_send_cmd: macro
macro sgb_data_send_cmd
sgb_cmd SGB_DATA_SND, 1
dw \1 ; SNES destination address
db \2 ; SNES destination bank

View File

@ -245,7 +245,7 @@ IF !DEF(DEBUG_SAVE_FILE_NAME)
DEBUG_SAVE_FILE_NAME equs "ZELDA"
ENDC
SET_DEFAULT: macro
macro SET_DEFAULT
IF !DEF(\1)
\1 equ \2
ENDC