From b1dbadbdd397cb8c9e85fa48d9184949c921a8f3 Mon Sep 17 00:00:00 2001 From: Rangi Date: Sun, 9 May 2021 12:26:28 -0400 Subject: [PATCH] Require rgbds 0.5.1 Use some new features: \<10> macro args, SECTION UNION, SIZEOF/STARTOF, and CHARLEN/CHARSUB --- .travis.yml | 2 +- FAQ.md | 6 +- INSTALL.md | 24 ++-- data/events/npc_trades.asm | 5 +- data/events/unown_walls.asm | 39 +++--- data/pokemon/unown_words.asm | 4 +- engine/games/unown_puzzle.asm | 4 +- home/text.asm | 14 +- layout.link | 3 + macros/legacy.asm | 7 +- macros/scripts/maps.asm | 19 +-- rgbdscheck.asm | 4 +- tools/unnamed.py | 6 +- wram.asm | 235 +++++++++++++++++++++++----------- 14 files changed, 224 insertions(+), 148 deletions(-) diff --git a/.travis.yml b/.travis.yml index bfcae2226..f7def85aa 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,7 +9,7 @@ install: HOMEBREW_NO_AUTO_UPDATE=1 brew install bison export PATH="/usr/local/opt/bison/bin:$PATH" fi - git clone -b v0.5.0 --depth=1 https://github.com/gbdev/rgbds + git clone -b v0.5.1 --depth=1 https://github.com/gbdev/rgbds sudo make -C rgbds install rm -rf rgbds ) diff --git a/FAQ.md b/FAQ.md index e7a437eb8..b6bfa7e74 100644 --- a/FAQ.md +++ b/FAQ.md @@ -41,15 +41,15 @@ You need to install `gcc`. If you're using Cygwin, re-run its setup, and at "Sel ### "ERROR: `UNION` already defined" -Download [**rgbds 0.5.0**][rgbds] or newer. Older versions will not work. +Download [**rgbds 0.5.1**][rgbds] or newer. Older versions will not work. ### "ERROR: Macro not defined" -Download [**rgbds 0.5.0**][rgbds] or newer. Older versions will not work. +Download [**rgbds 0.5.1**][rgbds] or newer. Older versions will not work. ### "Expression must be 8-bit" -Download [**rgbds 0.5.0**][rgbds] or newer. Older versions will not work. +Download [**rgbds 0.5.1**][rgbds] or newer. Older versions will not work. ### "Segmentation fault" from `rgbgfx` diff --git a/INSTALL.md b/INSTALL.md index 9bfbb8fd6..01e9f4c32 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -42,9 +42,9 @@ Run setup and leave the default settings. At the "**Select Packages**" step, cho Double click on the text that says "**Skip**" next to each package to select the most recent version to install. -Then follow the [**rgbds** instructions](https://rgbds.gbdev.io/install/windows) for Windows with Cygwin to install **rgbds 0.5.0**. +Then follow the [**rgbds** instructions](https://rgbds.gbdev.io/install/windows) for Windows with Cygwin to install **rgbds 0.5.1**. -**Note:** If you already have an older rgbds, you will need to update to 0.5.0. Ignore this if you have never installed rgbds before. If a version newer than 0.5.0 does not work, try downloading 0.5.0. +**Note:** If you already have an older rgbds, you will need to update to 0.5.1. Ignore this if you have never installed rgbds before. If a version newer than 0.5.1 does not work, try downloading 0.5.1. Now open the **Cygwin terminal** and enter the following commands. @@ -67,7 +67,7 @@ Install [**Homebrew**](https://brew.sh/). Follow the official instructions. Open **Terminal** and prepare to enter commands. -Then follow the [**rgbds** instructions](https://rgbds.gbdev.io/install/macos) for macOS to install **rgbds 0.5.0**. +Then follow the [**rgbds** instructions](https://rgbds.gbdev.io/install/macos) for macOS to install **rgbds 0.5.1**. Now you're ready to [build **pokecrystal**](#build-pokecrystal). @@ -84,7 +84,7 @@ To install the software required for **pokecrystal**: sudo apt-get install make gcc git ``` -Then follow the [**rgbds** instructions](https://rgbds.gbdev.io/install/source) to build **rgbds 0.5.0** from source. +Then follow the [**rgbds** instructions](https://rgbds.gbdev.io/install/source) to build **rgbds 0.5.1** from source. ### OpenSUSE @@ -94,7 +94,7 @@ To install the software required for **pokecrystal**: sudo zypper install make gcc git ``` -Then follow the [**rgbds** instructions](https://rgbds.gbdev.io/install/source) to build **rgbds 0.5.0** from source. +Then follow the [**rgbds** instructions](https://rgbds.gbdev.io/install/source) to build **rgbds 0.5.1** from source. ### Arch Linux @@ -104,9 +104,9 @@ To install the software required for **pokecrystal**: sudo pacman -S make gcc git rgbds ``` -Then follow the [**rgbds** instructions](https://rgbds.gbdev.io/install/arch) for Arch Linux to install **rgbds 0.5.0**. +Then follow the [**rgbds** instructions](https://rgbds.gbdev.io/install/arch) for Arch Linux to install **rgbds 0.5.1**. -If you want to compile and install **rgbds** yourself instead, then follow the [**rgbds** instructions](https://rgbds.gbdev.io/install/source) to build **rgbds 0.5.0** from source. +If you want to compile and install **rgbds** yourself instead, then follow the [**rgbds** instructions](https://rgbds.gbdev.io/install/source) to build **rgbds 0.5.1** from source. ### Termux @@ -122,7 +122,7 @@ To install **rgbds**: sudo apt install rgbds ``` -If you want to compile and install **rgbds** yourself instead, then follow the [**rgbds** instructions](https://rgbds.gbdev.io/install/source) to build **rgbds 0.5.0** from source. +If you want to compile and install **rgbds** yourself instead, then follow the [**rgbds** instructions](https://rgbds.gbdev.io/install/source) to build **rgbds 0.5.1** from source. ### Other distros @@ -133,7 +133,7 @@ If your distro is not listed here, try to find the required software in its repo - `git` - `rgbds` -If `rgbds` is not available, you'll need to follow the [**rgbds** instructions](https://rgbds.gbdev.io/install/source) to build **rgbds 0.5.0** from source. +If `rgbds` is not available, you'll need to follow the [**rgbds** instructions](https://rgbds.gbdev.io/install/source) to build **rgbds 0.5.1** from source. Now you're ready to [build **pokecrystal**](#build-pokecrystal). @@ -161,12 +161,12 @@ make crystal11 ### Build with a local rgbds version -If you have different projects that require different versions of `rgbds`, it might not be convenient to install rgbds 0.5.0 globally. Instead, you can put its files in a directory within pokecrystal, such as `pokecrystal/rgbds-0.5.0/`. Then specify it when you run `make`: +If you have different projects that require different versions of `rgbds`, it might not be convenient to install rgbds 0.5.1 globally. Instead, you can put its files in a directory within pokecrystal, such as `pokecrystal/rgbds-0.5.1/`. Then specify it when you run `make`: ```bash -make RGBDS=rgbds-0.5.0/ +make RGBDS=rgbds-0.5.1/ ``` ```bash -make RGBDS=rgbds-0.5.0/ crystal11 +make RGBDS=rgbds-0.5.1/ crystal11 ``` diff --git a/data/events/npc_trades.asm b/data/events/npc_trades.asm index 543a50b1e..c97e4ea4a 100644 --- a/data/events/npc_trades.asm +++ b/data/events/npc_trades.asm @@ -1,9 +1,8 @@ npctrade: MACRO ; dialog set, requested mon, offered mon, nickname, dvs, item, OT ID, OT name, gender requested db \1, \2, \3, \4, \5, \6, \7 - shift - dw \7 - db \8, \9, 0 + dw \8 + db \9, \<10>, 0 ENDM NPCTrades: diff --git a/data/events/unown_walls.asm b/data/events/unown_walls.asm index 624b1e678..e19765831 100644 --- a/data/events/unown_walls.asm +++ b/data/events/unown_walls.asm @@ -1,35 +1,34 @@ unownwall: MACRO -rept _NARG -if \1 == "-" -x = $64 -elif \1 >= "Y" -x = 2 * (\1 - "Y") + $60 -elif \1 >= "Q" -x = 2 * (\1 - "Q") + $40 -elif \1 >= "I" -x = 2 * (\1 - "I") + $20 +for n, CHARLEN(\1) +x = CHARSUB(\1, n + 1) +if x == "-" + db $64 +elif x >= "Y" + db 2 * (x - "Y") + $60 +elif x >= "Q" + db 2 * (x - "Q") + $40 +elif x >= "I" + db 2 * (x - "I") + $20 else -x = 2 * (\1 - "A") + db 2 * (x - "A") endc - db x - shift endr db -1 ; end ENDM UnownWalls: ; UNOWNWORDS_ESCAPE - ; db $08, $44, $04, $00, $2e, $08, -1 - unownwall "E", "S", "C", "A", "P", "E" + ; db $08, $44, $04, $00, $2e, $08, -1 + unownwall "ESCAPE" ; UNOWNWORDS_LIGHT - ; db $26, $20, $0c, $0e, $46, -1 - unownwall "L", "I", "G", "H", "T" + ; db $26, $20, $0c, $0e, $46, -1 + unownwall "LIGHT" ; UNOWNWORDS_WATER - ; db $4c, $00, $46, $08, $42, -1 - unownwall "W", "A", "T", "E", "R" + ; db $4c, $00, $46, $08, $42, -1 + unownwall "WATER" ; UNOWNWORDS_HO_OH - ; db $0e, $2c, $64, $2c, $0e, -1 - unownwall "H", "O", "-", "O", "H" + ; db $0e, $2c, $64, $2c, $0e, -1 + unownwall "HO-OH" MenuHeaders_UnownWalls: ; UNOWNWORDS_ESCAPE diff --git a/data/pokemon/unown_words.asm b/data/pokemon/unown_words.asm index 7c41e19a3..11ddd46b0 100644 --- a/data/pokemon/unown_words.asm +++ b/data/pokemon/unown_words.asm @@ -1,6 +1,6 @@ unownword: MACRO -for x, STRLEN(\1) - db STRSUB(\1, x + 1, 1) - "A" + FIRST_UNOWN_CHAR +for n, CHARLEN(\1) + db CHARSUB(\1, n + 1) - "A" + FIRST_UNOWN_CHAR endr db -1 ENDM diff --git a/engine/games/unown_puzzle.asm b/engine/games/unown_puzzle.asm index d230c5347..41b330552 100644 --- a/engine/games/unown_puzzle.asm +++ b/engine/games/unown_puzzle.asm @@ -14,8 +14,8 @@ _UnownPuzzle: xor a ldh [hBGMapMode], a call DisableLCD - ld hl, wUnownPuzzle ; includes wPuzzlePieces - ld bc, wUnownPuzzleEnd - wUnownPuzzle + ld hl, STARTOF("Miscellaneous") ; includes wPuzzlePieces + ld bc, SIZEOF("Miscellaneous") xor a call ByteFill ld hl, UnownPuzzleCursorGFX diff --git a/home/text.asm b/home/text.asm index 92cecf5b3..18eb1743c 100644 --- a/home/text.asm +++ b/home/text.asm @@ -187,24 +187,22 @@ NextChar:: CheckDict:: dict: MACRO +assert CHARLEN(\1) == 1 if \1 == 0 and a else cp \1 endc - if ISCONST(\2) -; Replace a character with another one - jr nz, ._\@ + ; Replace a character with another one + jr nz, .not\@ ld a, \2 -._\@: -else - if STRSUB("\2", 1, 1) == "." +.not\@: +elif STRSUB("\2", 1, 1) == "." ; Locals can use a short jump jr z, \2 - else +else jp z, \2 - endc endc ENDM diff --git a/layout.link b/layout.link index 315864c37..763788d5f 100644 --- a/layout.link +++ b/layout.link @@ -326,12 +326,15 @@ WRAM0 "Sprites" "Tilemap" "Miscellaneous" + "Unused Map Buffer" align 8 "Overworld Map" align 4 "Video" WRAMX 1 "WRAM 1" + "Miscellaneous WRAM 1" + "More WRAM 1" "Enemy Party" "Party" WRAMX 2 diff --git a/macros/legacy.asm b/macros/legacy.asm index 01df8e87e..68566c75e 100644 --- a/macros/legacy.asm +++ b/macros/legacy.asm @@ -224,12 +224,7 @@ signpost: MACRO ENDM person_event: MACRO -_s = \1 -_y = \2 -_x = \3 -_m = \4 - shift 4 - object_event _x, _y, _s, _m, \1, \2, \3, \4, \5, \6, \7, \8, \9 + object_event \3, \2, \1, \4, \5, \6, \7, \8, \9, \<10>, \<11>, \<12>, \<13> ENDM PERSONTYPE_SCRIPT EQUS "OBJECTTYPE_SCRIPT" diff --git a/macros/scripts/maps.asm b/macros/scripts/maps.asm index fc6d201b6..0e952c764 100644 --- a/macros/scripts/maps.asm +++ b/macros/scripts/maps.asm @@ -102,21 +102,16 @@ object_event: MACRO ; * if h1 == -1, h2 is treated as a time-of-day value: ; a combo of MORN, DAY, and/or NITE, or -1 to always appear ;\9: color: a PAL_NPC_* constant, or 0 for sprite default -;\10: function: a OBJECTTYPE_* constant -;\11: sight range: applies to OBJECTTYPE_TRAINER -;\12: script pointer -;\13: event flag: an EVENT_* constant, or -1 to always appear +;\<10>: function: a OBJECTTYPE_* constant +;\<11>: sight range: applies to OBJECTTYPE_TRAINER +;\<12>: script pointer +;\<13>: event flag: an EVENT_* constant, or -1 to always appear db \3, \2 + 4, \1 + 4, \4 dn \6, \5 db \7, \8 - shift - dn \8, \9 - shift - db \9 - shift - dw \9 - shift - dw \9 + dn \9, \<10> + db \<11> + dw \<12>, \<13> ; the dummy PlayerObjectTemplate object_event has no def_object_events if DEF(_NUM_OBJECT_EVENTS) {_NUM_OBJECT_EVENTS} = {_NUM_OBJECT_EVENTS} + 1 diff --git a/rgbdscheck.asm b/rgbdscheck.asm index f1e348a86..d32d2de15 100644 --- a/rgbdscheck.asm +++ b/rgbdscheck.asm @@ -1,9 +1,9 @@ MAJOR EQU 0 MINOR EQU 5 -PATCH EQU 0 +PATCH EQU 1 wrong_rgbds: MACRO - fail "pokecrystal requires rgbds v0.5.0 or newer." + fail "pokecrystal requires rgbds v0.5.1 or newer." ENDM IF !DEF(__RGBDS_MAJOR__) || !DEF(__RGBDS_MINOR__) || !DEF(__RGBDS_PATCH__) diff --git a/tools/unnamed.py b/tools/unnamed.py index 33177d521..c5d032083 100755 --- a/tools/unnamed.py +++ b/tools/unnamed.py @@ -82,14 +82,14 @@ for objfile in objects: elif magic == b'RGB9': obj_ver = 10 + unpack_file("