From fe3939e09a4662d9c67bcf0f371a1ee44f89a3e6 Mon Sep 17 00:00:00 2001 From: vulcandth Date: Wed, 11 May 2022 21:54:45 -0500 Subject: [PATCH] MACRO RGBDS Syntax/Indent Updates --- data/billboard/billboard_pic_pointers.asm | 2 +- data/unused/unused_9800.asm | 22 ++-- macros.asm | 142 +++++++++++----------- macros/pokedex.asm | 68 +++++------ macros/scrolling_text.asm | 16 +-- macros/sound.asm | 102 ++++++++-------- sram.asm | 2 +- wram.asm | 8 +- 8 files changed, 181 insertions(+), 181 deletions(-) diff --git a/data/billboard/billboard_pic_pointers.asm b/data/billboard/billboard_pic_pointers.asm index 128b65c..a163a33 100644 --- a/data/billboard/billboard_pic_pointers.asm +++ b/data/billboard/billboard_pic_pointers.asm @@ -1,5 +1,5 @@ BillboardPicturePointers: ; 0xf1b8 -BillboardPicturePointer: MACRO +MACRO BillboardPicturePointer \1_Pointer: dab \1 ENDM BillboardPicturePointer BallSaver30SecondsOnPic diff --git a/data/unused/unused_9800.asm b/data/unused/unused_9800.asm index f87722a..0f56497 100755 --- a/data/unused/unused_9800.asm +++ b/data/unused/unused_9800.asm @@ -1,13 +1,13 @@ -macro_9800: MACRO -x = 0 -rept \1 -y = 0 -rept $100 / \1 - db (x + y) & $ff -y = y + \1 -endr -x = x + 1 -endr +MACRO macro_9800 + DEF x = 0 + rept \1 + DEF y = 0 + rept $100 / \1 + db (x + y) & $ff + DEF y = y + \1 + endr + DEF x = x + 1 + endr endm Data_9800: @@ -15,5 +15,5 @@ Data_9800: w = $100 rept 8 macro_9800 w -w = w >> 1 + DEF w = w >> 1 endr diff --git a/macros.asm b/macros.asm index 633d6eb..c662cbb 100644 --- a/macros.asm +++ b/macros.asm @@ -1,20 +1,20 @@ ; Constant enumeration is useful for mons, maps, etc. -const_def: MACRO -if _NARG >= 1 -const_value = \1 -else -const_value = 0 -endc -if _NARG >= 2 -const_inc = \2 -else -const_inc = 1 -endc +MACRO const_def + if _NARG >= 1 + DEF const_value = \1 + else + DEF const_value = 0 + endc + if _NARG >= 2 + DEF const_inc = \2 + else + DEF const_inc = 1 + endc ENDM -const: MACRO -\1 EQU const_value -const_value = const_value + const_inc +MACRO const + DEF \1 EQU const_value + DEF const_value = const_value + const_inc ENDM INCLUDE "macros/pokedex.asm" @@ -29,67 +29,67 @@ dex_text EQUS "db " ; Start beginning of pokedex description dex_line EQUS "db $0d," ; Start new line in pokedex description dex_end EQUS "db $00" ; Terminate the pokedex description -dbw: MACRO +MACRO dbw db \1 dw \2 - ENDM +ENDM -dwb: MACRO +MACRO dwb dw \1 db \2 - ENDM +ENDM -dba: MACRO +MACRO dba dbw BANK(\1), \1 - ENDM +ENDM -dab: MACRO +MACRO dab dwb \1, BANK(\1) - ENDM +ENDM -lb: MACRO +MACRO lb ld \1, (\2 << 8) | \3 - ENDM +ENDM -padded_dab: MACRO +MACRO padded_dab dab \1 db $00 - ENDM +ENDM -dn: MACRO +MACRO dn rept _NARG / 2 - db (\1) << 4 + (\2) - shift - shift + db (\1) << 4 + (\2) + shift + shift endr - ENDM +ENDM -dx: MACRO -x = 8 * ((\1) - 1) +MACRO dx + DEF x = 8 * ((\1) - 1) rept \1 - db ((\2) >> x) & $ff -x = x + -8 + db ((\2) >> x) & $ff + DEF x = x + -8 endr - ENDM +ENDM -bigdw: MACRO ; big-endian word +MACRO bigdw ; big-endian word dx 2, \1 - ENDM +ENDM -callba: MACRO +MACRO callba ld [hFarCallTempA], a IF _NARG > 1 - ld a, BANK(\2) - ld hl, \2 - call \1, BankSwitch + ld a, BANK(\2) + ld hl, \2 + call \1, BankSwitch ELSE - ld a, BANK(\1) - ld hl, \1 - call BankSwitch + ld a, BANK(\1) + ld hl, \1 + call BankSwitch ENDC - ENDM +ENDM -bigBCD6: MACRO +MACRO bigBCD6 ; There is probably a better name for this macro. ; It write a BCD in big-endian form. dn ((\1) / 10) % 10, (\1) % 10 @@ -98,14 +98,14 @@ bigBCD6: MACRO dn ((\1) / 10000000) % 10, ((\1) / 1000000) % 10 dn ((\1) / 1000000000) % 10, ((\1) / 100000000) % 10 dn ((\1) / 100000000000) % 10, ((\1) / 10000000000) % 10 - ENDM +ENDM ;\1 = X ;\2 = Y ;\3 = Reference Background Map (e.g. vBGMap or vBGWin) -coord: MACRO +MACRO coord ld \1, \4 + $20 * \3 + \2 - ENDM +ENDM hlCoord EQUS "coord hl," deCoord EQUS "coord de," @@ -116,67 +116,67 @@ tile EQUS "+ $10 *" ;\1 = 5-bit Blue value ;\2 = 5-bit Green value ;\3 = 5-bit Red value -RGB: MACRO +MACRO RGB dw (\3 << 10 | \2 << 5 | \1) - ENDM +ENDM ;\1 = pointer to 2bpp tile data ;\2 = destination for tile data in VRAM ;\3 = size of 2bpp tile data to copy -VIDEO_DATA_TILES: MACRO +MACRO VIDEO_DATA_TILES dw \1 db Bank(\1) dw \2 dw (\3 << 2) - ENDM +ENDM ;\1 = pointer to 2bpp tile data ;\2 = bank of data ;\3 = destination for tile data in VRAM ;\4 = size of 2bpp tile data to copy -VIDEO_DATA_TILES_BANK: MACRO +MACRO VIDEO_DATA_TILES_BANK dw \1 db \2 dw \3 dw (\4 << 2) - ENDM +ENDM ;\1 = pointer to 2bpp tile data ;\2 = destination for tile data in VRAM ;\3 = size of 2bpp tile data to copy -VIDEO_DATA_TILES_BANK2: MACRO +MACRO VIDEO_DATA_TILES_BANK2 dw \1 db Bank(\1) dw \2 dw (\3 << 2) | $2 - ENDM - -;\1 = pointer to tilemap data -;\2 = destination for tilemap data in VRAM -;\3 = size of tilemap to copy -VIDEO_DATA_TILEMAP: MACRO - VIDEO_DATA_TILES \1, \2, \3 - ENDM +ENDM ;\1 = pointer to tilemap data ;\2 = destination for tilemap data in VRAM ;\3 = size of tilemap to copy -VIDEO_DATA_TILEMAP_BANK2: MACRO +MACRO VIDEO_DATA_TILEMAP + VIDEO_DATA_TILES \1, \2, \3 +ENDM + +;\1 = pointer to tilemap data +;\2 = destination for tilemap data in VRAM +;\3 = size of tilemap to copy +MACRO VIDEO_DATA_TILEMAP_BANK2 VIDEO_DATA_TILES_BANK2 \1, \2, \3 - ENDM +ENDM ;\1 = pointer to background attribute data ;\2 = destination for background attribute data in VRAM ;\3 = size of background attribute data to copy -VIDEO_DATA_BGATTR: MACRO +MACRO VIDEO_DATA_BGATTR VIDEO_DATA_TILES_BANK2 \1, \2, \3 - ENDM +ENDM ;\1 = pointer to palette data ;\2 = size of palette data -VIDEO_DATA_PALETTES: MACRO +MACRO VIDEO_DATA_PALETTES dw \1 db Bank(\1) dw $0000 dw (\2 << 1) | $1 - ENDM +ENDM diff --git a/macros/pokedex.asm b/macros/pokedex.asm index 76e34c0..e15a48b 100755 --- a/macros/pokedex.asm +++ b/macros/pokedex.asm @@ -1,81 +1,81 @@ -dex_number: MACRO +MACRO dex_number db ((\1 / 100) % 10) + "0" db ((\1 / 10) % 10) + "0" db ((\1 / 1) % 10) + "0" db "@" - ENDM +ENDM ; \1 = feet ; \2 = inches -dex_height: MACRO -feet_tens_digit = (\1 / 10) % 10 +MACRO dex_height + DEF feet_tens_digit = (\1 / 10) % 10 IF feet_tens_digit == 0 - db " " + db " " ELSE - db feet_tens_digit + "0" + db feet_tens_digit + "0" ENDC -feet_ones_digit = \1 % 10 + DEF feet_ones_digit = \1 % 10 db feet_ones_digit + "0" -inches_tens_digit = (\2 / 10) % 10 + DEF inches_tens_digit = (\2 / 10) % 10 IF inches_tens_digit > 0 - db $70 + db $70 ELSE - db $72 + db $72 ENDC -inches_ones_digit = \2 % 10 + DEF inches_ones_digit = \2 % 10 db inches_ones_digit + "0" db "@" - ENDM +ENDM -dex_weight: MACRO +MACRO dex_weight IF \1 >= 1000 - db ((\1 / 1000) % 10) + "0" + db ((\1 / 1000) % 10) + "0" ELSE - db " " + db " " ENDC IF \1 >= 100 - db ((\1 / 100) % 10) + "0" + db ((\1 / 100) % 10) + "0" ELSE - db " " + db " " ENDC IF \1 >= 10 - db ((\1 / 10) % 10) + "0" + db ((\1 / 10) % 10) + "0" ELSE - db " " + db " " ENDC db (\1 % 10) + "0" db $00, $83 - ENDM +ENDM -dex_weight_decimal: MACRO -x = \1 * 10 +MACRO dex_weight_decimal + DEF x = \1 * 10 IF x >= 100 - db ((x / 100) % 10) + "0" + db ((x / 100) % 10) + "0" ELSE - db " " + db " " ENDC IF x >= 10 - db ((x / 100) % 10) + "0" + db ((x / 100) % 10) + "0" ELSE - db " " + db " " ENDC db (x % 10) + "0" db (\2 % 10) + "0" db $00, $FC - ENDM +ENDM ; \1 = species string -dex_species: MACRO +MACRO dex_species ; Add right padding to format to 11 characters, define 2 bytes ; for each character (using dex_species_char below) -I = 0 + DEF I = 0 REPT STRLEN(\1) -I = I + 1 + DEF I = I + 1 dex_species_char STRSUB(\1\, I\, 1) ENDR REPT 11 - STRLEN(\1) @@ -84,10 +84,10 @@ I = I + 1 db "@" ENDM -dex_species_char: MACRO +MACRO dex_species_char IF \1 == " " - db $81, $40 + db $81, $40 ELSE - db $82, \1 + $1F + db $82, \1 + $1F ENDC - ENDM +ENDM diff --git a/macros/scrolling_text.asm b/macros/scrolling_text.asm index db5ec54..89b8562 100755 --- a/macros/scrolling_text.asm +++ b/macros/scrolling_text.asm @@ -4,9 +4,9 @@ ; \2: Number of steps to pause ; \3: Text index the bottom text buffer (wBottomMessageText) ; \4: Number of steps after the Pause (text disappears after these number of steps) -scrolling_text_normal: MACRO +MACRO scrolling_text_normal scrolling_text 5, 20, \1, \2, \3, \4 - ENDM +ENDM ; \1: Step delay (in frames) ; \2: Starting offset (number of tiles from the left of the screen) @@ -14,29 +14,29 @@ scrolling_text_normal: MACRO ; \4: Number of steps to pause ; \5: Text index the bottom text buffer (wBottomMessageText) ; \6: Number of steps after the Pause (text disappears after these number of steps) -scrolling_text: MACRO +MACRO scrolling_text db \1 db \2 + $40 db \3 + $40 db \4 db \5 * $10 db \6 + \4 + (\2 - \3) - ENDM +ENDM ; \1: Step delay (in frames) ; \2: Total number of steps before disappearing. -scrolling_text_nopause: MACRO +MACRO scrolling_text_nopause db \1 db 20 + $40 db 0, 0, 0 db \2 - ENDM +ENDM ; \1: Offset (number of tiles from the left of the screen) ; \2: Raw text index the bottom text buffer (wBottomMessageText) ; \3: Number of frames to display the text. -stationary_text: MACRO +MACRO stationary_text db \1 + $40 db \2 * $10 dw \3 - ENDM +ENDM diff --git a/macros/sound.asm b/macros/sound.asm index 42dd18c..1278459 100644 --- a/macros/sound.asm +++ b/macros/sound.asm @@ -1,26 +1,26 @@ -channel_count: MACRO -_num_channels = \1 - 1 +MACRO channel_count + DEF _num_channels = \1 - 1 ENDM -channel: MACRO +MACRO channel dn (_num_channels << 2), \1 - 1 ; channel id dw \2 ; address -_num_channels = 0 + DEF _num_channels = 0 ENDM -note: MACRO +MACRO note dn (\1), (\2) - 1 ; pitch, length ENDM -drum_note: MACRO +MACRO drum_note note \1, \2 ; drum instrument, length ENDM -rest: MACRO +MACRO rest note 0, \1 ; length ENDM -square_note: MACRO +MACRO square_note db \1 ; length IF \3 < 0 dn \2, %1000 | (\3 * -1) ; volume envelope @@ -30,7 +30,7 @@ square_note: MACRO dw \4 ; frequency ENDM -noise_note: MACRO +MACRO noise_note db \1 ; length IF \3 < 0 dn \2, %1000 | (\3 * -1) ; volume envelope @@ -44,7 +44,7 @@ ENDM FIRST_MUSIC_CMD EQU const_value const octave_cmd ; $d0 -octave: MACRO +MACRO octave assert 0 < (\1) && (\1) <= 8, "octave must be 1-8" db octave_cmd | 8 - (\1) ; octave ENDM @@ -52,7 +52,7 @@ ENDM const_def $d8 const note_type_cmd ; $d8 -note_type: MACRO +MACRO note_type db note_type_cmd db \1 ; note length IF _NARG >= 2 @@ -65,30 +65,30 @@ note_type: MACRO ENDM ; only valid on the noise channel -drum_speed: MACRO +MACRO drum_speed note_type \1 ; note length ENDM const transpose_cmd ; $d9 -transpose: MACRO +MACRO transpose db transpose_cmd dn \1, \2 ; num octaves, num pitches ENDM const tempo_cmd ; $da -tempo: MACRO +MACRO tempo db tempo_cmd bigdw \1 ; tempo ENDM const duty_cycle_cmd ; $db -duty_cycle: MACRO +MACRO duty_cycle db duty_cycle_cmd db \1 ; duty cycle ENDM const volume_envelope_cmd ; $dc -volume_envelope: MACRO +MACRO volume_envelope db volume_envelope_cmd IF \2 < 0 dn \1, %1000 | (\2 * -1) ; volume envelope @@ -98,7 +98,7 @@ volume_envelope: MACRO ENDM const pitch_sweep_cmd ; $dd -pitch_sweep: MACRO +MACRO pitch_sweep db pitch_sweep_cmd IF \2 < 0 dn \1, %1000 | (\2 * -1) ; pitch sweep @@ -108,25 +108,25 @@ pitch_sweep: MACRO ENDM const duty_cycle_pattern_cmd ; $de -duty_cycle_pattern: MACRO +MACRO duty_cycle_pattern db duty_cycle_pattern_cmd db (\1 << 6) | (\2 << 4) | (\3 << 2) | (\4 << 0) ; duty cycle pattern ENDM const toggle_sfx_cmd ; $df -toggle_sfx: MACRO +MACRO toggle_sfx db toggle_sfx_cmd ENDM const pitch_slide_cmd ; $e0 -pitch_slide: MACRO +MACRO pitch_slide db pitch_slide_cmd db \1 - 1 ; duration dn 8 - \2, \3 % 12 ; octave, pitch ENDM const vibrato_cmd ; $e1 -vibrato: MACRO +MACRO vibrato db vibrato_cmd db \1 ; delay IF _NARG > 2 @@ -137,13 +137,13 @@ vibrato: MACRO ENDM const unknownmusic0xe2_cmd ; $e2 -unknownmusic0xe2: MACRO +MACRO unknownmusic0xe2 db unknownmusic0xe2_cmd db \1 ; unknown ENDM const toggle_noise_cmd ; $e3 -toggle_noise: MACRO +MACRO toggle_noise db toggle_noise_cmd IF _NARG > 0 db \1 ; drum kit @@ -151,13 +151,13 @@ toggle_noise: MACRO ENDM const force_stereo_panning_cmd ; $e4 -force_stereo_panning: MACRO +MACRO force_stereo_panning db force_stereo_panning_cmd dn %1111 * (1 && \1), %1111 * (1 && \2) ; left enable, right enable ENDM const volume_cmd ; $e5 -volume: MACRO +MACRO volume db volume_cmd IF _NARG > 1 dn \1, \2 ; left volume, right volume @@ -167,65 +167,65 @@ volume: MACRO ENDM const pitch_offset_cmd ; $e6 -pitch_offset: MACRO +MACRO pitch_offset db pitch_offset_cmd bigdw \1 ; pitch offset ENDM const unknownmusic0xe7_cmd ; $e7 -unknownmusic0xe7: MACRO +MACRO unknownmusic0xe7 db unknownmusic0xe7_cmd db \1 ; unknown ENDM const unknownmusic0xe8_cmd ; $e8 -unknownmusic0xe8: MACRO +MACRO unknownmusic0xe8 db unknownmusic0xe8_cmd db \1 ; unknown ENDM const tempo_relative_cmd ; $e9 -tempo_relative: MACRO +MACRO tempo_relative db tempo_relative_cmd bigdw \1 ; tempo adjustment ENDM const restart_channel_cmd ; $ea -restart_channel: MACRO +MACRO restart_channel db restart_channel_cmd dw \1 ; address ENDM const new_song_cmd ; $eb -new_song: MACRO +MACRO new_song db new_song_cmd bigdw \1 ; id ENDM const sfx_priority_on_cmd ; $ec -sfx_priority_on: MACRO +MACRO sfx_priority_on db sfx_priority_on_cmd ENDM const sfx_priority_off_cmd ; $ed -sfx_priority_off: MACRO +MACRO sfx_priority_off db sfx_priority_off_cmd ENDM const unknownmusic0xee_cmd ; $ee -unknownmusic0xee: MACRO +MACRO unknownmusic0xee db unknownmusic0xee_cmd dw \1 ; address ENDM const stereo_panning_cmd ; $ef -stereo_panning: MACRO +MACRO stereo_panning db stereo_panning_cmd dn %1111 * (1 && \1), %1111 * (1 && \2) ; left enable, right enable ENDM const sfx_toggle_noise_cmd ; $f0 -sfx_toggle_noise: MACRO +MACRO sfx_toggle_noise db sfx_toggle_noise_cmd IF _NARG > 0 db \1 ; drum kit @@ -233,83 +233,83 @@ sfx_toggle_noise: MACRO ENDM const music0xf1_cmd ; $f1 -music0xf1: MACRO +MACRO music0xf1 db music0xf1_cmd ENDM const music0xf2_cmd ; $f2 -music0xf2: MACRO +MACRO music0xf2 db music0xf2_cmd ENDM const music0xf3_cmd ; $f3 -music0xf3: MACRO +MACRO music0xf3 db music0xf3_cmd ENDM const music0xf4_cmd ; $f4 -music0xf4: MACRO +MACRO music0xf4 db music0xf4_cmd ENDM const music0xf5_cmd ; $f5 -music0xf5: MACRO +MACRO music0xf5 db music0xf5_cmd ENDM const music0xf6_cmd ; $f6 -music0xf6: MACRO +MACRO music0xf6 db music0xf6_cmd ENDM const music0xf7_cmd ; $f7 -music0xf7: MACRO +MACRO music0xf7 db music0xf7_cmd ENDM const music0xf8_cmd ; $f8 -music0xf8: MACRO +MACRO music0xf8 db music0xf8_cmd ENDM const unknownmusic0xf9_cmd ; $f9 -unknownmusic0xf9: MACRO +MACRO unknownmusic0xf9 db unknownmusic0xf9_cmd ENDM const set_condition_cmd ; $fa -set_condition: MACRO +MACRO set_condition db set_condition_cmd db \1 ; condition ENDM const sound_jump_if_cmd ; $fb -sound_jump_if: MACRO +MACRO sound_jump_if db sound_jump_if_cmd db \1 ; condition dw \2 ; address ENDM const sound_jump_cmd ; $fc -sound_jump: MACRO +MACRO sound_jump db sound_jump_cmd dw \1 ; address ENDM const sound_loop_cmd ; $fd -sound_loop: MACRO +MACRO sound_loop db sound_loop_cmd db \1 ; count dw \2 ; address ENDM const sound_call_cmd ; $fe -sound_call: MACRO +MACRO sound_call db sound_call_cmd dw \1 ; address ENDM const sound_ret_cmd ; $ff -sound_ret: MACRO +MACRO sound_ret db sound_ret_cmd ENDM diff --git a/sram.asm b/sram.asm index 4586a34..f5d1432 100644 --- a/sram.asm +++ b/sram.asm @@ -1,6 +1,6 @@ SECTION "SRAM 0", SRAM -saved_data: MACRO +MACRO saved_data \1:: ds \2 \1Signature:: ds 2 \1Checksum:: dw diff --git a/wram.asm b/wram.asm index fc20d3f..ca94a65 100644 --- a/wram.asm +++ b/wram.asm @@ -1,5 +1,5 @@ ; OAM Animations use this 3-byte struct. -animation: MACRO +MACRO animation \1FrameCounter:: ds 1 \1Frame:: ds 1 \1Index:: ds 1 @@ -781,7 +781,7 @@ wDisableDrawScoreboardInfo:: ; 0xd5cb ; 0 = Draw them. ds $1 -scrolling_text: MACRO +MACRO scrolling_text \1Enabled:: ds 1 ; Toggles if enabled. 0 is off, non-0 is on \1ScrollDelayCounter:: ds 1 ; Number of frames remaining until the next scroll step \1ScrollDelay:: ds 1 ; Number of frames between each scroll step @@ -799,7 +799,7 @@ wScrollingText2:: ; 0xd5d4 wScrollingText3:: ; 0xd5dc scrolling_text wScrollingText3 -stationary_text: MACRO +MACRO stationary_text \1Enabled::ds 1 ; Toggles if enabled. 0 is off, non-0 is on \1MessageBoxOffset:: ds 1 ; Offset in wBottomMessageBuffer to place first character of text \1SourceTextOffset:: ds 1 ; Offset in wBottomMessageText for the text to be displayed @@ -2421,7 +2421,7 @@ wNumPokemonSeen:: ; 0xd9f9 wNumPokemonOwned:: ; 0xd9fb ds $2 -high_scores: MACRO +MACRO high_scores \1Points:: ds 6 \1Name:: ds 3 \1Id:: ds 4