From 4da89de0c535d9e728b2bb1023a8e3bb06d67795 Mon Sep 17 00:00:00 2001 From: Rangi <35663410+Rangi42@users.noreply.github.com> Date: Fri, 14 Nov 2025 00:17:30 -0500 Subject: [PATCH] Use features of RGBDS 1.0.0 (#69) --- .gitmodules | 3 - Makefile | 25 +++++-- charmap.asm | 23 ++++++ engine/pinball_game/catchem_mode.asm | 10 +-- engine/pinball_game/end_of_ball_bonus.asm | 14 ++-- engine/pinball_game/evolution_mode.asm | 10 +-- engine/pokedex.asm | 24 +++---- gfx/stage/saver_off.png | Bin 155 -> 106 bytes home/text.asm | 50 ++++++------- macros.asm | 82 +++++++++++----------- macros/pokedex.asm | 58 ++++++++------- pokemon-reverse-engineering-tools | 1 - 12 files changed, 164 insertions(+), 136 deletions(-) delete mode 100644 .gitmodules delete mode 160000 pokemon-reverse-engineering-tools diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 4c3cac8..0000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "pokemon-reverse-engineering-tools"] - path = pokemon-reverse-engineering-tools - url = https://github.com/kanzure/pokemon-reverse-engineering-tools.git diff --git a/Makefile b/Makefile index 60133ea..92bcbc1 100644 --- a/Makefile +++ b/Makefile @@ -14,6 +14,17 @@ else SHA1 := sha1sum endif +RGBDS ?= +RGBASM ?= $(RGBDS)rgbasm +RGBLINK ?= $(RGBDS)rgblink +RGBFIX ?= $(RGBDS)rgbfix +RGBGFX ?= $(RGBDS)rgbgfx + +RGBASMFLAGS ?= -Weverything -Wtruncation=1 +RGBLINKFLAGS ?= -Weverything -Wtruncation=1 +RGBFIXFLAGS ?= -Weverything +RGBGFXFLAGS ?= -Weverything + all: $(ROM) compare ifeq (,$(filter tools clean tidy,$(MAKECMDGOALS))) @@ -22,11 +33,13 @@ endif %.o: dep = $(shell tools/scan_includes $(@D)/$*.asm) %.o: %.asm $$(dep) - rgbasm -Wunmapped-char=0 -o $@ $< + $(RGBASM) $(RGBASMFLAGS) -o $@ $< +$(ROM): RGBLINKFLAGS += -l contents/contents.link -n $(ROM:.gbc=.sym) -m $(ROM:.gbc=.map) +$(ROM): RGBFIXFLAGS += -jsvc -k 01 -l 0x33 -m 0x1e -p 0 -r 02 -t "POKEPINBALL" -i VPHE $(ROM): $(OBJS) contents/contents.link - rgblink -n $(ROM:.gbc=.sym) -m $(ROM:.gbc=.map) -l contents/contents.link -o $@ $(OBJS) - rgbfix -jsvc -k 01 -l 0x33 -m 0x1e -p 0 -r 02 -t "POKEPINBALL" -i VPHE $@ + $(RGBLINK) $(RGBLINKFLAGS) -o $@ $(OBJS) + $(RGBFIX) $(RGBFIXFLAGS) $@ # For contributors to make sure a change didn't affect the contents of the rom. compare: $(ROM) @@ -43,14 +56,14 @@ clean: tidy find . \( -iname '*.1bpp' -o -iname '*.2bpp' -o -iname '*.pcm' \) -exec rm {} + %.interleave.2bpp: %.interleave.png - rgbgfx -o $@ $< + $(RGBGFX) -c dmg $(RGBGFXFLAGS) -o $@ $< tools/gfx --interleave --png $< -o $@ $@ %.2bpp: %.png - rgbgfx -o $@ $< + $(RGBGFX) -c dmg $(RGBGFXFLAGS) -o $@ $< %.1bpp: %.png - rgbgfx -d1 -o $@ $< + $(RGBGFX) -c dmg $(RGBGFXFLAGS) -d1 -o $@ $< %.pcm: %.wav tools/pcm -o $@ $< diff --git a/charmap.asm b/charmap.asm index 7754cd1..14ac183 100644 --- a/charmap.asm +++ b/charmap.asm @@ -1,4 +1,27 @@ charmap "@", $00 + charmap " ", $20 + charmap "!", $21 charmap "♂", $24 + charmap "*", $2A + charmap ",", $2C + charmap "-", $2D + charmap ".", $2E + charmap ":", $3A charmap "é", $40 charmap "♀", $5C + charmap "`", $60 + +DEF chars EQUS "0123456789" +FOR x, STRLEN(#chars) + charmap STRSLICE(#chars, x, x + 1), $30 + x +ENDR + +REDEF chars EQUS "ABCDEFGHIJKLMNOPQRSTUVWXYZ" +FOR x, STRLEN(#chars) + charmap STRSLICE(#chars, x, x + 1), $41 + x +ENDR + +REDEF chars EQUS "abcdefghijklmnopqrstuvwxyz" +FOR x, STRLEN(#chars) + charmap STRSLICE(#chars, x, x + 1), $61 + x +ENDR diff --git a/engine/pinball_game/catchem_mode.asm b/engine/pinball_game/catchem_mode.asm index 5dfb0c6..21c471f 100644 --- a/engine/pinball_game/catchem_mode.asm +++ b/engine/pinball_game/catchem_mode.asm @@ -987,15 +987,15 @@ ShowCapturedPokemonText: ; 0x106b6 ld bc, Data_2a91 ld a, [hl] ; check if mon's name starts with a vowel, so it can print "an", instead of "a" - cp "A" + cp 'A' jr z, .asm_106f1 - cp "I" + cp 'I' jr z, .asm_106f1 - cp "U" + cp 'U' jr z, .asm_106f1 - cp "E" + cp 'E' jr z, .asm_106f1 - cp "O" + cp 'O' jr z, .asm_106f1 ld de, YouGotAText ; "You got a" ld bc, Data_2a79 diff --git a/engine/pinball_game/end_of_ball_bonus.asm b/engine/pinball_game/end_of_ball_bonus.asm index 8db650d..2735b56 100644 --- a/engine/pinball_game/end_of_ball_bonus.asm +++ b/engine/pinball_game/end_of_ball_bonus.asm @@ -316,23 +316,23 @@ PlaceTextAlphanumericOnly: ; 0xf7b1 seems to filter out punctuation and other mi ld a, [hli] and a ret z ;if end of text, ret - cp "0" + cp '0' jr c, .NotADigit ;if a digit, add $56 and skip letter check - cp "9" + 1 + cp '9' + 1 jr nc, .NotADigit add $56 jr .IsValidChar .NotADigit - cp "A" + cp 'A' jr c, .NotALetter ;if a letter, add $56 and skip letter check - cp "Z" + 1 + cp 'Z' + 1 jr nc, .NotALetter add $bf jr .IsValidChar .NotALetter - cp "e" ;check if acute e + cp 'e' ;check if acute e jr nz, .NotAcuteE ld a, $83 jr .IsValidChar @@ -348,9 +348,9 @@ PlaceTextAlphanumericOnly: ; 0xf7b1 seems to filter out punctuation and other mi ld a, [hli] and a ret z - cp "0" + cp '0' jr c, .asm_f7ef - cp "9" + 1 + cp '9' + 1 jr nc, .asm_f7ef add $56 jr .asm_f809 diff --git a/engine/pinball_game/evolution_mode.asm b/engine/pinball_game/evolution_mode.asm index e535ddb..1a16da6 100644 --- a/engine/pinball_game/evolution_mode.asm +++ b/engine/pinball_game/evolution_mode.asm @@ -534,15 +534,15 @@ ShowMonEvolvedText: ; 0x10e0a ld bc, Data_2b34 ld a, [hl] ; check if mon's name starts with a vowel, so it can print "an", instead of "a" - cp "A" + cp 'A' jr z, .nameStartsWithVowel - cp "I" + cp 'I' jr z, .nameStartsWithVowel - cp "U" + cp 'U' jr z, .nameStartsWithVowel - cp "E" + cp 'E' jr z, .nameStartsWithVowel - cp "O" + cp 'O' jr z, .nameStartsWithVowel ld de, ItEvolvedIntoAText ; "It evolved into a" ld bc, Data_2b1c diff --git a/engine/pokedex.asm b/engine/pokedex.asm index 77aaa5c..232f110 100644 --- a/engine/pokedex.asm +++ b/engine/pokedex.asm @@ -2266,32 +2266,32 @@ PokedexDescriptionVWFCharacterMapping: ; 0x2957c ret .checkNumericCharacter - cp "0" + cp '0' jr c, .checkUpperCaseCharacter - cp "9" + 1 + cp '9' + 1 jr c, .asm_295be .checkUpperCaseCharacter - cp "A" + cp 'A' jr c, .checkLowerCaseCharacter - cp "Z" + 1 + cp 'Z' + 1 jr c, .asm_295c2 .checkLowerCaseCharacter - cp "a" + cp 'a' jr c, .checkSpecialCharacter - cp "z" + 1 + cp 'z' + 1 jr c, .asm_295c6 .checkSpecialCharacter - cp " " + cp ' ' jr z, .asm_295ca - cp "," + cp ',' jr z, .asm_295cd - cp "." + cp '.' jr z, .asm_295d1 - cp "`" + cp '`' jr z, .asm_295d5 - cp "-" + cp '-' jr z, .asm_295d9 - cp "é" + cp 'é' jr z, .asm_295dd and a ret diff --git a/gfx/stage/saver_off.png b/gfx/stage/saver_off.png index 166cdcdb0ada59c670324d338bb18024087d9063..61cb85a0fbc6e7fad76c59b206226d0473b000b7 100644 GIT binary patch delta 88 zcmbQum^DEnh=~CRzQ^sl1f&c-T^vIyZke7q$je~BarnTS{X+a^i#4V~E7%)}DjB3= 1 DEF const_value = \1 else @@ -12,7 +12,7 @@ MACRO const_def endc ENDM -MACRO const +MACRO? const DEF \1 EQU const_value DEF const_value = const_value + const_inc ENDM @@ -29,50 +29,49 @@ DEF dex_text EQUS "db " ; Start beginning of pokedex description DEF dex_line EQUS "db $0d," ; Start new line in pokedex description DEF dex_end EQUS "db $00" ; Terminate the pokedex description -MACRO dbw +MACRO? dbw db \1 dw \2 ENDM -MACRO dwb +MACRO? dwb dw \1 db \2 ENDM -MACRO dba +MACRO? dba dbw BANK(\1), \1 ENDM -MACRO dab +MACRO? dab dwb \1, BANK(\1) ENDM -MACRO lb - ld \1, (\2 << 8) | \3 +MACRO? lb + ld \1, ((\2) << 8) | (\3) ENDM -MACRO padded_dab +MACRO? padded_dab dab \1 db $00 ENDM -MACRO dn - rept _NARG / 2 +MACRO? dn + rept? _NARG / 2 db (\1) << 4 + (\2) - shift - shift + shift 2 endr ENDM -MACRO dx +MACRO? dx DEF x = 8 * ((\1) - 1) - rept \1 + rept? \1 db ((\2) >> x) & $ff - DEF x = x + -8 + DEF x -= 8 endr ENDM -MACRO bigdw ; big-endian word +MACRO? bigdw ; big-endian word dx 2, \1 ENDM @@ -89,22 +88,21 @@ MACRO callba ENDC ENDM -MACRO bigBCD6 +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 - dn ((\1) / 1000) % 10, ((\1) / 100) % 10 - dn ((\1) / 100000) % 10, ((\1) / 10000) % 10 - dn ((\1) / 10000000) % 10, ((\1) / 1000000) % 10 - dn ((\1) / 1000000000) % 10, ((\1) / 100000000) % 10 - dn ((\1) / 100000000000) % 10, ((\1) / 10000000000) % 10 + FOR x, 6 + ; 10**10 and 10**11 would overflow a 32-bit integer, + ; so split the division into two steps + dn ((\1) / 10**(x + 1) / 10**x) % 10, ((\1) / 10**x / 10**x) % 10 + ENDR ENDM ;\1 = X ;\2 = Y ;\3 = Reference Background Map (e.g. vBGMap or vBGWin) -MACRO coord - ld \1, \4 + $20 * \3 + \2 +MACRO? coord + ld \1, (\4) + $20 * (\3) + (\2) ENDM DEF hlCoord EQUS "coord hl," @@ -116,67 +114,67 @@ DEF tile EQUS "+ $10 *" ;\1 = 5-bit Blue value ;\2 = 5-bit Green value ;\3 = 5-bit Red value -MACRO RGB - dw (\3 << 10 | \2 << 5 | \1) +MACRO? RGB + dw (\3) << 10 | (\2) << 5 | (\1) ENDM ;\1 = pointer to 2bpp tile data ;\2 = destination for tile data in VRAM ;\3 = size of 2bpp tile data to copy -MACRO VIDEO_DATA_TILES +MACRO? VIDEO_DATA_TILES dw \1 - db Bank(\1) + db BANK(\1) dw \2 - dw (\3 << 2) + dw (\3) << 2 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 -MACRO VIDEO_DATA_TILES_BANK +MACRO? VIDEO_DATA_TILES_BANK dw \1 db \2 dw \3 - dw (\4 << 2) + dw (\4) << 2 ENDM ;\1 = pointer to 2bpp tile data ;\2 = destination for tile data in VRAM ;\3 = size of 2bpp tile data to copy -MACRO VIDEO_DATA_TILES_BANK2 +MACRO? VIDEO_DATA_TILES_BANK2 dw \1 - db Bank(\1) + db BANK(\1) dw \2 - dw (\3 << 2) | $2 + dw ((\3) << 2) | $2 ENDM ;\1 = pointer to tilemap data ;\2 = destination for tilemap data in VRAM ;\3 = size of tilemap to copy -MACRO VIDEO_DATA_TILEMAP +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 +MACRO? VIDEO_DATA_TILEMAP_BANK2 VIDEO_DATA_TILES_BANK2 \1, \2, \3 ENDM ;\1 = pointer to background attribute data ;\2 = destination for background attribute data in VRAM ;\3 = size of background attribute data to copy -MACRO VIDEO_DATA_BGATTR +MACRO? VIDEO_DATA_BGATTR VIDEO_DATA_TILES_BANK2 \1, \2, \3 ENDM ;\1 = pointer to palette data ;\2 = size of palette data -MACRO VIDEO_DATA_PALETTES +MACRO? VIDEO_DATA_PALETTES dw \1 - db Bank(\1) + db BANK(\1) dw $0000 - dw (\2 << 1) | $1 + dw ((\2) << 1) | $1 ENDM diff --git a/macros/pokedex.asm b/macros/pokedex.asm index 350aaeb..4abaf9d 100644 --- a/macros/pokedex.asm +++ b/macros/pokedex.asm @@ -1,71 +1,71 @@ MACRO dex_number - db ((\1 / 100) % 10) + "0" - db ((\1 / 10) % 10) + "0" - db ((\1 / 1) % 10) + "0" + db (((\1) / 100) % 10) + '0' + db (((\1) / 10) % 10) + '0' + db ((\1) % 10) + '0' db "@" ENDM ; \1 = feet ; \2 = inches MACRO dex_height - DEF feet_tens_digit = (\1 / 10) % 10 + DEF feet_tens_digit = ((\1) / 10) % 10 IF feet_tens_digit == 0 db " " ELSE - db feet_tens_digit + "0" + db feet_tens_digit + '0' ENDC - DEF feet_ones_digit = \1 % 10 - db feet_ones_digit + "0" - DEF inches_tens_digit = (\2 / 10) % 10 + DEF feet_ones_digit = (\1) % 10 + db feet_ones_digit + '0' + DEF inches_tens_digit = ((\2) / 10) % 10 IF inches_tens_digit > 0 db $70 ELSE db $72 ENDC - DEF inches_ones_digit = \2 % 10 - db inches_ones_digit + "0" + DEF inches_ones_digit = (\2) % 10 + db inches_ones_digit + '0' db "@" ENDM MACRO dex_weight IF \1 >= 1000 - db ((\1 / 1000) % 10) + "0" + db ((\1 / 1000) % 10) + '0' ELSE db " " ENDC IF \1 >= 100 - db ((\1 / 100) % 10) + "0" + db ((\1 / 100) % 10) + '0' ELSE db " " ENDC IF \1 >= 10 - db ((\1 / 10) % 10) + "0" + db ((\1 / 10) % 10) + '0' ELSE db " " ENDC - db (\1 % 10) + "0" + db ((\1) % 10) + '0' db $00, $83 ENDM MACRO dex_weight_decimal - DEF x = \1 * 10 + DEF x = (\1) * 10 IF x >= 100 - db ((x / 100) % 10) + "0" + db ((x / 100) % 10) + '0' ELSE db " " ENDC IF x >= 10 - db ((x / 100) % 10) + "0" + db ((x / 100) % 10) + '0' ELSE db " " ENDC - db (x % 10) + "0" - db (\2 % 10) + "0" + db (x % 10) + '0' + db ((\2) % 10) + '0' db $00, $FC ENDM @@ -73,21 +73,19 @@ ENDM MACRO dex_species ; Add right padding to format to 11 characters, define 2 bytes ; for each character (using dex_species_char below) - DEF I = 0 - REPT STRLEN(\1) - DEF I = I + 1 - dex_species_char STRSUB(\1\, I\, 1) - ENDR - REPT 11 - STRLEN(\1) - dex_species_char " " - ENDR - db "@" + FOR I, STRLEN(\1) + dex_species_char CHARVAL(STRSLICE(\1, I, I + 1)) + ENDR + REPT 11 - STRLEN(\1) + dex_species_char ' ' + ENDR + db "@" ENDM MACRO dex_species_char - IF \1 == " " + IF (\1) == ' ' db $81, $40 ELSE - db $82, \1 + $1F + db $82, (\1) + $1F ENDC ENDM diff --git a/pokemon-reverse-engineering-tools b/pokemon-reverse-engineering-tools deleted file mode 160000 index 979c98a..0000000 --- a/pokemon-reverse-engineering-tools +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 979c98a7c0f67ad6b9685b2d532c66a1f76ffb22