Compare commits

...
2305 Commits
Author SHA1 Message Date
Rangi 307846b03e Release v1.0.3 2026-08-01 11:27:43 -04:00
Rangi e7e671b249 Update external test commits 2026-08-01 11:24:42 -04:00
Rangi 0c772ea049 Update external testing CI with libbet's new way of running Python
libbet now uses `py -3` if the `py` binary exists, instead of if
`COMSPEC` is defined. So we don't need to `unset COMSPEC`, we just
need to avoid Windows' `py` launcher from being in Cygwin's `PATH`.

It turns out that `C:\cygwin\bin\env.exe CYGWIN_NOWINPATH=1 ...`
was not effectively preventing Windows' `PATH` from being inherited
by Cygwin's `PATH`, because to take effect it needs to run Cygwin's
`/etc/profile` script. The simple way to do that is using a login
shell. So we don't need the `PREFIX`/`--prefix` from the previous
commit after all.
2026-08-01 04:49:43 +02:00
Rangi 6f64fd00f6 Fix CI testing of installing RGBDS on Cygwin (#2038)
We need to pass `-e` to Cygwin `bash` explicitly, since specifying
it as the non-default `shell:` no longer automatically adds `-e`
behavior to `run` blocks.

We also need to install to `/usr/bin` (which `cygwin-install-action`
automatically adds to the `PATH`), not `/usr/local/bin` (which is not
in the default `PATH`). This tests our `PREFIX`/`--prefix` handling.
2026-07-31 10:25:59 -04:00
Rangi 4384223951 CI testing in Cygwin 64-bit now uses CMake and runs external tests (#2037) 2026-07-30 12:59:53 -04:00
Rangi 4e87f61656 Edit some comments and formatting in testing.yml for consistency 2026-07-29 22:08:21 -04:00
Rangi 9d854114ea Use Ninja as the generator for CMake on FreeBSD 2026-07-30 02:33:47 +02:00
Rangi 70d8d67ffc Run external tests for FreeBSD (#2035)
This requires aliasing `make` to `gmake` and `python` to `python3`
2026-07-29 19:45:07 -04:00
Rangi ca2b8e4cde Support the COLUMNS environment variable for help/usage output 2026-07-24 14:46:05 +02:00
Rangi 80c8e77b19 Fixed-point FMOD and LOG explicitly return 0 for some invalid inputs
This is consistent with `fix_Div`'s explicit error handling,
and does not rely on subtle C/C++ `fmod` or `log` IEEE 754 behavior.
2026-07-23 00:38:44 -04:00
Rangi 604c69e048 Fix palette-packing decant logic to avoid UB from invalid iterator (#2031)
The "Iterate through the component's color sets, and transfer them"
logic shifted `from.begin()`, which would make subsequent `std::advance`
calls go past `_assigned.end()` and cause UB. This rewrite uses absolute
numeric indexes into `_assigned` to avoid that potential problem.

I haven't been able to craft a test case that actually *reaches*
that piece of logic, and I suspect that it's unreachable given how
we sort and process color sets before decanting, but cannot prove
that; so it stays in. (Maybe if we added 4bpp 16-colors-per-palette
support, it would become reachable?)
2026-07-22 23:48:02 -04:00
Rangi ec5e6cbabb Handle -Wtruncation for link-time jr values
Fixes #2028
2026-07-21 14:51:58 -04:00
Rangi 50678d0942 Use _fseeki64/_ftelli64 on Windows since fseek/fell are limited by 32-bit long 2026-07-21 14:38:14 -04:00
Rangi c691ec6607 Use std::optional<uint64_t> instead of long with a special -1 sentinel for seekSize 2026-07-21 14:31:05 -04:00
Rangi c3073f4318 Assume that InsertionOrderedMap never adds duplicate keys 2026-07-21 14:07:45 -04:00
Rangi e5b03e3cb1 Zero-initialize Png struct width and height just in case 2026-07-21 13:58:31 -04:00
Rangi 0d379e9016 Assume clz/ctz argument is nonzero in our fallback implementations 2026-07-21 13:56:57 -04:00
Rangi 9cbfec30c7 Avoid redundant "Unexpected text" error message after "Unknown" error 2026-07-21 13:54:11 -04:00
Rangi 9def9c9aa8 Fix an SDAS object error message to use the valid section name variable 2026-07-21 13:41:53 -04:00
Rangi b5681c0d34 Set binary or text mode on stdout as well as stdin 2026-07-21 13:39:28 -04:00
Rangi ec43f06bd9 Fix handling of at-files containing -- followed by positional arguments 2026-07-21 13:35:39 -04:00
Rangi 106ec399d5 Fix reading value of relocations symbol/section index from SDAS objects 2026-07-21 13:14:35 -04:00
Rangi d9c0d37fd5 Explicitly allow JR offsets to wrap around in RGBLINK
This reverts commit f27a8132d9.
2026-07-20 19:23:11 -04:00
Eldred Habert 3b1606c63c Fix typo'd APT option in release workflow
Fixing up bcff14b596
2026-07-20 21:53:43 +02:00
Rangi fa49e238a9 Release v1.0.2 2026-07-20 14:08:09 -04:00
Rangi 3426f685a0 Update libpng to 1.6.58 2026-07-20 14:08:09 -04:00
Rangi c0e2f8340b Output negative values with correct with in .sym files 2026-07-20 00:09:06 -04:00
Rangi 8883251bf9 Avoid UB from FileStackNodeType(type) on an invalid type 2026-07-20 00:06:09 -04:00
Rangi f27a8132d9 Avoid truncating too-large JR offset from an invalid object file 2026-07-20 00:02:39 -04:00
Rangi 0af28de791 Fix assertion failure on nonzero base palette ID without an attribute map or palette map
Also fix palette map IDs to wrap at 256, not at 8 like attributes
2026-07-19 23:59:38 -04:00
Rangi 8d2275dc48 Use rpnErrorAt wrapper to ensure setting isError on all RPN errors
Two possible RPN errors were missing `isError = true;`
2026-07-19 23:45:45 -04:00
Rangi 7e11ab4d8f uint16_t tileIdx type matches options.baseTileIDs
Tile IDs wrap at 8 bits, but that's handled by `uint8_t tileID`
2026-07-19 23:33:01 -04:00
Rangi e84bcf83b4 Use Procedure concept to type-check decantOn lambda 2026-07-15 23:27:08 -04:00
Rangi 57c9bab3a5 Addresses are 16-bit in .map files, consistent with .sym files 2026-07-15 22:59:50 -04:00
Rangi 4ada3e85d8 Avoid overflow for very large ROMs (e.g. TPP1) 2026-07-15 22:57:25 -04:00
Rangi ba4a7f2e6a Explicitly assume what was verified earlier by readSection 2026-07-15 22:56:43 -04:00
Rangi b0948566bb Fail-safe treat 16-bit alignment as a fixed address even in RGBLINK
RGBASM does this itself, so should not output sections with 16-bit
alignment, but an invalid object file could otherwise cause
`getPlacement` to infinitely loop.
2026-07-15 22:46:57 -04:00
Rangi 5aa7067876 Comment on how overflow to 0 is explicitly allowed for tile and palette IDs 2026-07-15 22:28:08 -04:00
Rangi dff176791c Correct grammar "is" vs "are" in RGBGFX reverse mode error messages 2026-07-14 11:29:30 -04:00
Rangi 07f5969005 Consistency check the palette map, not just the attribute map 2026-07-14 11:27:41 -04:00
Rangi d61c0561c1 Correct condition to completely print both palettes and options.palSpec 2026-07-14 11:23:03 -04:00
Rangi b13b0c8eb8 Fix the same shifting UB for SDAS objects as for RGBDS ones 2026-07-14 11:13:30 -04:00
Rangi ca2de0f429 Add issue template 2026-07-14 10:34:43 -04:00
Rangi a821badc3e Reorganize the readme
- Use sub-headings to let the reader skim more easily
- Link specifically to the Discord server before less-useful
  "other community channels"
2026-07-14 10:34:43 -04:00
Rangi cb34fe18f7 Use transparent instead of repeating 0x8000 2026-07-14 10:34:27 -04:00
Rangi 1ed22cc518 Mask blue for consistency (avoids transparent bit bugs) 2026-07-14 10:34:27 -04:00
Rangi 9a15b723f2 Format CGB colors in error/verbose messages as "GB:rr,gg,bb"
These should be more debuggable than packed "$xxxx" format.
2026-07-14 10:34:27 -04:00
Rangi 7e2a3491a5 Encapsulate fseek+ftell idiom in seekSize
This allows a single check for the return value of `seekSize`
to verify all three `fseek`+`ftell`+`fseek` calls.
2026-07-14 01:32:18 -04:00
Rangi e7855ea1b8 Fix reverse mode with -s/--palette-size too small for the tile data 2026-07-14 01:11:11 -04:00
Rangi 19e60d9864 Fix large ds in linker script overflowing the PC 2026-07-14 00:42:42 -04:00
Rangi c0ff3d92ad Fix reverse palette offsets when base palette ID wraps around to 0 2026-07-13 23:08:20 -04:00
Rangi e4583e7ac2 RGBGFX reverse mode checks for too-low palette IDs, not just too-high 2026-07-13 23:08:20 -04:00
Rangi 5869e0dc60 Fix RGBLINK scrambling algorithm to work for SRAM
Since SRAM sections start from 0, we had been using a signed
`int8_t curScrambleSRAM` counter to allow 0 as a scrambled bank,
but this actually just placed all floating SRAM sections in bank 0.
2026-07-13 22:39:41 -04:00
Rangi 196d50c1d7 Add XXX: comment tag to working but fragile test cases 2026-07-13 22:39:41 -04:00
Rangi 8b951bc047 Fix a flaky/random-seed rgbgfx_test test failure
Commit 21eaa2d2cc missed some
intentional unsigned underflow that is needed to set `nbTilesInBank`.
Without it, some of the randomly-seeded RGBGFX tests, such as
`./rgbgfx_test seed8.bin -b 207 -N 54,256`, can fail with "Color
mismatch after round-tripping" errors.
2026-07-13 21:31:05 -04:00
Rangi 59b6b15106 Run make format 2026-07-13 21:30:23 -04:00
Rangi 304cbb464f Factor out verboseDo to encapsulate magenta output color 2026-07-13 18:05:55 -04:00
Rangi ea3a8ee171 Use magenta color for some verbose output which was missing it 2026-07-13 17:47:38 -04:00
Rangi f0419eb183 More guards against invalid object file patch data 2026-07-13 17:47:38 -04:00
Rangi 4a6ea35299 Avoid overflow in counting tiles for unrealistically large images 2026-07-13 17:47:38 -04:00
Rangi 08354cf573 Explicitly encode assumption that an overlapping section exists 2026-07-13 17:47:38 -04:00
Rangi 417b5212d4 Fix OOM for too-small overlay files in 32K mode (rgblink -t) 2026-07-13 16:17:30 -04:00
Rangi 66312f55dd Avoid unsigned overflow/truncation from bad offset values in invalid object files 2026-07-13 13:17:09 -04:00
Rangi 21eaa2d2cc Fix a > to >=, and avoid underflow in some sanity checks 2026-07-13 13:14:06 -04:00
Rangi e9fa1e4e94 Avoid closing stdin/stdout/stderr standard streams 2026-07-13 13:02:46 -04:00
Rangi 8ab6190f96 Fix relative links in Markdown docs 2026-07-11 16:19:27 -04:00
Eldred Habert 22bd8a9bd5 Enable automatic generation of compile_flags.txt for clang-tidy via make tidy (#2008) 2026-07-11 16:11:14 -04:00
Rangi 96bc58b7f7 Add test case for local labels that superficially look like keywords 2026-07-11 13:51:53 -04:00
Rangi 4857ad1e00 Fix crash on image without any colors (all transparent) 2026-07-11 13:18:40 -04:00
Rangi 3b33c942ae Fix a crash and a limitation in RGBGFX unoptimized output
- If both banks 0 and 1 were completely filled, then
  `assume(bank == 0)` would false and potentially crash.
- If the input image had fully-background tiles, they would be
  incorrectly counted towards `nbTiles` and could cause the
  "Image contains N tiles, exceeding the limit" check to fail.
2026-07-11 12:32:31 -04:00
Rangi 5525dd902b Update external test commits 2026-07-10 23:29:19 -04:00
Rangi 4350a3252d Upgrade FreeBSD testing from 14.3 to 15.1 2026-07-10 23:14:39 -04:00
Rangi a8442bccc7 Group the two dep install commands together in Dockerfile 2026-07-10 23:12:49 -04:00
Rangi 00006a9d00 Use set -u too 2026-07-10 23:12:49 -04:00
Rangi a383bec96e Rename install_deps.sh to install-deps.sh for consistency 2026-07-10 23:12:49 -04:00
Rangi 226031c18b Use #!/usr/bin/env bash, not #!/bin/bash 2026-07-10 23:12:49 -04:00
Rangi 24a896f60a Move CI-only check-diff script to .github/ 2026-07-10 23:12:49 -04:00
Rangi a6f5e3efd1 Move CI-only check-format script to .github/ 2026-07-10 23:12:49 -04:00
Rangi c02b234bb1 Add CI job to check syntax of contrib scripts
Note that `zsh` is not installed in `ubuntu-slim` by default.
2026-07-10 23:12:49 -04:00
Rangi be4c1161bd Fix RGBGFX crash when trimming more tiles than exist after deduplication 2026-07-10 17:35:32 -04:00
Rangi 0e1e5e80f6 Use correct PRIu32 format spec for uint32_t usedTotal 2026-07-10 17:01:43 -04:00
Rangi 118f1f7543 Correct option letter in error message 2026-07-10 16:59:30 -04:00
Rangi eaa35ed26d Remove dead return after no-return fatal call 2026-07-10 14:36:46 -04:00
Rangi 7b39bcd412 Refactor expression for clarity
`tileData[realY + 1 % options.bitDepth]` relied on order of
operations and the fact that `1 % 1 == 0` but `1 % 2 == 1` for
correct indexing. However, it was not obvious at first glance,
and confusable with the more common `(base + offset) % size`
pattern. (And would need changing anyway if we ever support 4bpp.)
2026-07-10 14:30:25 -04:00
Rangi 255cd7f7f6 Fix a typo in a comment 2026-07-10 14:29:32 -04:00
Rangi b8011947a8 Correct assumption to avoid UB with 1 << 31 2026-07-09 21:36:34 -04:00
Rangi 39e7e064c9 Print correct color set limit value in error message 2026-07-09 21:29:02 -04:00
Rangi 7b97d7ce15 Fix RGBGFX crash on deduplicating transparent tiles 2026-07-09 21:24:59 -04:00
Rangi c667bac93a Use trailing return type for begin()/end() 2026-07-08 16:57:52 -04:00
Rangi db96144d49 Use [[nodiscard]] instead of [[gnu::warn_unused_result]] 2026-07-08 16:44:15 -04:00
Rangi 276a1a7952 Use const_cast more precisely to remove const without changing type 2026-07-08 16:42:53 -04:00
Rangi b219e03b38 Use more structured bindings 2026-07-08 16:38:32 -04:00
Rangi 824ebd80f9 Use [[fallthrough]]; attribute instead of // fallthrough comment 2026-07-08 16:30:52 -04:00
Rangi 5aedf31b46 Prevent 32-bit multiplication overflow
Basically impossible to achieve, but just in case
2026-07-07 17:02:46 -04:00
Rangi d94d0bcc2f Make explicit the assumption that targetFileName is checked before ever calling printDep 2026-07-07 17:02:46 -04:00
Rangi ed8e3e4d02 Reset errno = 0 before parseWholeNumber calls and errno == ERANGE checks 2026-07-07 17:02:46 -04:00
Rangi 30fd4514dc Add fail-safe for invalid RPN commands in bad object files 2026-07-07 17:02:46 -04:00
Rangi 08e83601f5 Fix CRLF check in parsing SDAS objects 2026-07-07 17:02:46 -04:00
Rangi e606f4e997 Fix condition for invalid bank range check (#2016) 2026-07-07 17:02:35 -04:00
Rangi 9008d8391c Consistently use sudo apt install -Uyq in workflows (two other cases) 2026-07-07 02:57:48 -04:00
Rangi 21682e8814 Consistently handle negative shifted macro args (#2014)
Negative macro arguments count from the end, i.e. `\<-1>`
is equivalent to `\<_NARG>`, even after `shift`ing them.

Negative arguments cannot be used to access shifted values.
2026-07-07 02:19:37 -04:00
Rangi f82b0838a1 Disallow minus sign before symbol name in bracketed macro arguments (#2015)
This was being silently allowed but without actually negating the symbol's value
2026-07-07 00:42:09 -04:00
Rangi dabd0a08d2 Remove impossible condition (uint64_t > UINT64_MAX) 2026-07-06 23:08:05 -04:00
Rangi c3e10dbb03 Safeguard against localtime or gmtime failure 2026-07-06 23:05:19 -04:00
Rangi 3883c2a2b8 Reuse scrambleLimit instead of its equivalent expression 2026-07-06 22:50:31 -04:00
Rangi cd0caaaceb Clarify comment about -Wno-* behavior with parametric warnings 2026-07-06 22:44:39 -04:00
Rangi 1e4a060d9e Guard against undefined behavior in double2fix
I haven't found input which triggers any, but this is more
technically correct just in case.
2026-07-06 22:38:06 -04:00
Rangi fe3b238dea Do not allow defining labels outside sections (#2013)
Creating a `Symbol` with `type = SYM_LABEL` but `section = nullptr`
is inconsistent and dangerous. I was not able to cause any buggy
behavior so far, but it's safer and reasonable to not create such
a symbol in the first place.

The main consequence is that `DEF(LabelOutsideSection)` will now
evaluate as 0.
2026-07-06 16:18:42 -04:00
Rangi 46a6966b70 Fix $8000_0000 % -1 to warn with -Wdiv like $8000_0000 / -1 does (#2012) 2026-07-06 15:08:44 -04:00
Rangi be3fc61859 Fix included linker scripts with no newline at EOF (#2011) 2026-07-06 14:01:40 -04:00
Rangi 0adbb92e50 Same-line shellcheck comment explanations
These are obvious even with `git grep shellcheck`.
2026-07-06 04:43:08 +02:00
Rangi 09da4e001a Use Bash arrays instead of POSIX splitting when possible 2026-07-06 04:43:08 +02:00
ISSOtm 3eb8c7e8f2 Let tests know they are being run under Cygwin 2026-07-05 20:58:50 -04:00
Rangi 189c679e13 Parallelize build jobs according to CPU count 2026-07-05 20:58:50 -04:00
Rangi 5d5000011a Remove CMAKE_INSTALL_PARALLEL_LEVEL
This value "has no impact unless `INSTALL_PARALLEL` is enabled",
and since our install procedure is so simple, I don't think we need
to add that. (The `make install` commands don't use `-j` either.)
2026-07-05 20:58:50 -04:00
Rangi f81f5fe63c Use git clean -fdx instead of make clean in external projects 2026-07-05 20:58:50 -04:00
Rangi 6e643406a2 Refactor warning diagnostic code to reduce repeated output logic 2026-07-04 23:02:16 -04:00
Rangi de36a11be7 Prevent rgblink -Wno-* disabled warnings from printing a location trace anyway
Fixes #2005
2026-07-04 23:02:16 -04:00
Rangi 799c55b4dd Add [[gnu::format(printf, 1, 2)]] attribute to variadic function sectError 2026-07-04 23:02:16 -04:00
Rangi ddd8f37508 Remove unnecessary default constructor for Token 2026-07-04 18:48:03 -04:00
Rangi c55dec254d Remove unnecessary const_casting methods 2026-07-04 18:45:41 -04:00
Rangi 0996a2f5ed Encapuslate UTF-8 decoder state in a struct 2026-07-03 19:35:23 -04:00
Rangi e3c594c250 Explain why we do not use file(GLOB ext_projects CONFIGURE_DEPENDS "external/*.cfg") 2026-07-03 18:38:07 -04:00
Rangi daba94b495 Remove pointless std::move from non-move constructor 2026-07-03 13:12:29 -04:00
Rangi 2f604bfa9a Fix error message when an rgbgfx output file cannot be created 2026-07-03 13:08:28 -04:00
Rangi 9bbb2247a7 Fix rgbasm -Werror=... not adding to the final error count 2026-07-03 13:05:33 -04:00
Rangi 9b4df11473 Describe how to patch external projects 2026-07-02 12:37:26 -04:00
ISSOtm 4a77c42ed7 Remove redundant labels from tests
It's possible to filter tests by name (`-R`)
2026-07-02 10:39:59 -04:00
ISSOtm b12eac356e Try to automatically determine the test OS name 2026-07-02 10:39:59 -04:00
ISSOtm 82702d8149 Point out an ordering dep isn't a success one 2026-07-02 10:39:59 -04:00
ISSOtm 1f9cc9651a Avoid fetching some repos twice
Also enables a nice bit of logic cleanup
2026-07-02 10:39:59 -04:00
ISSOtm 04b9c7fa3d Move external tests files to tests/external/ 2026-07-02 10:39:59 -04:00
ISSOtm 5e8a6cde20 Remove the need to explicitly list external tests
I like having a single source of truth!
2026-07-02 10:39:59 -04:00
ISSOtm d59081a918 Shorten external test prop names slightly
Makes the scripts a bit easier to read, I think
2026-07-02 10:39:59 -04:00
Rangi 250a94c588 Tell Dependabot to ignore minor and patch releases (#2001)
We specify major-only versions, e.g. `actions/checkout@v7`,
which automatically uses the latest minor+patch of that release.
2026-07-02 13:55:16 +02:00
dependabot[bot]dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>Rangi
37818a1847 Updates actions/checkout from 6 to 7 (#1999)
---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Rangi <[email protected]>
2026-07-01 23:06:12 -04:00
Rangi 0e3d1df129 Generate install.sh with make -n install (#1996) 2026-06-30 21:28:45 +02:00
Rangi 586c3073f9 Revert "Remove static compile flags"
This reverts commit e3fc46f933.

We need compile_flags.txt to support clang-tidy
2026-06-30 11:16:14 -04:00
ISSOtm e3fc46f933 Remove static compile flags
We support CMake now, which can generate a more accurate `compile_commands.json` database
(and our `develop` preset automatically enables them)
2026-06-30 16:52:31 +02:00
Rangi 3941a28661 Remove unused variables 2026-06-30 10:30:31 -04:00
Rangi a829e6c067 Refactor the test harness for external repo tests (#1994)
- Use CTest labels to filter tests ("internal"/"external", "free"/"nonfree",
  and individual tool+project names) instead of defining `TESTS_RUN_NONFREE`
- Allow each external test to run independently in CTest
- Remove the unused no-op `fetch-test-deps.sh --only-internal` option
2026-06-30 16:19:41 +02:00
Rangi b252877b05 Comment why we use Ninja as the generator for CMake 2026-06-28 17:38:50 -04:00
Rangi 22a3625144 Explicitly test installation with Make and CMake (#1992) 2026-06-28 17:31:24 -04:00
Eldred HabertandRangi 6cba5518e9 Install Pillow together with the rest of our CI deps (#1952)
We shouldn't assume how the user wants to install things.
In particular, `--break-system-packages` is egregious.

---------

Co-authored-by: Rangi <[email protected]>
2026-06-28 13:06:40 -04:00
Rangi caf561457d Warn about CMake <3.27 for Windows-targeted builds (#1989)
We only use `$<INSTALL_PREFIX>`` when cross-compiling for MinGW on Linux,
so the relevant block is now wrapped in `if(WIN32)`
so a user can more easily lower the `cmake_minimum_required` version.
2026-06-24 23:53:11 +02:00
Rangi fc7d9ad573 Handle more numeric literal syntax errors in linker scripts 2026-06-09 18:46:51 -04:00
Rangi 0b91bf654b Rename BaseV to ValidBaseV 2026-06-09 17:55:38 -04:00
Rangi 6b2b6e6000 Fix off-by-one error with INCLUDEd linker script line numbers 2026-06-09 16:16:21 -04:00
Rangi42 f72a4d53e2 Add -Wlarge-constant to RGBLINK as it is for RGBASM 2026-06-09 16:16:21 -04:00
vulcandth 998f636495 Fix rgbgfx -Z palette overgeneration on merged color sets (#1912)
- Fix logic for color set comparison (which affects sorting them)
- Prune color sets which are proper subsets of newly-encountered ones
  (a comment implied we were already doing this, but we weren't)
- Add more verbose logging to debug this behavior
2026-06-07 09:55:05 -04:00
Rangi 075f132d77 Use a smaller unordered_map just for looking up line-leading keywords 2026-05-27 22:01:20 -04:00
Rangi 31e1d2ec87 Do not build up a std::string when skipping leading keywords 2026-05-27 22:01:20 -04:00
Rangi 673c62414f Use std::string_view keys for UpperMap
This avoids constructing temporary `std::string` objects on lookup
2026-05-27 22:01:20 -04:00
Rangi 007672f080 Intern identifier strings only after checking for keywords 2026-05-25 23:55:57 -04:00
Rangi 7eaca1577d Update .gitattributes for test/asm/crlf.asm
A fresh clone showed a diff even without any bytes changed.
2026-05-25 22:57:52 -04:00
Rangi 996469ee28 Ensure CRLF line endings are preserved when necessary
Some test cases need CRLF line endings checked out even on Unix.
Also some source files had inadvertently contained CR bytes.
2026-05-25 22:00:45 -04:00
Rangi 55db252a8f Simplify the lexer by removing BufferedContent and inlining ViewedContent (#1981)
Instead of reading 64 characters at a time into a rolling buffer
as `shiftChar()` is called, we read 8192 characters at a time into
a complete buffer before any `peek()`/`shiftChar()` operations.
2026-05-25 21:05:59 -04:00
Rangi cfa0adf295 Intern strings used as identifiers (for labels, constants, macros, charmaps, etc) (#1980) 2026-05-25 16:22:29 -04:00
Rangi ed19806434 Don't hard-code std::string as the key type for InsertionOrderedMap 2026-05-25 14:21:18 -04:00
Rangi a0d96a0856 Factor out repeated expandedSymName logic 2026-05-25 14:21:18 -04:00
Rangi 4b992bfea5 Use the name of sym_GetPC() instead of hard-coding "@" again 2026-05-25 14:21:14 -04:00
Rangi 141a7fe22b Add assume checks for expected Token types, like RPNValue has for RPNCommands 2026-05-25 14:14:34 -04:00
Rangi 43ffc89bb4 Correct comment SIZE_MAX to UINT16_MAX 2026-05-25 13:55:12 -04:00
Rangi 72a410c007 Encapsulate charmap_Init, like sym_Init 2026-05-25 13:54:26 -04:00
Rangi 090768e2c9 Some Expansion references can be const 2026-05-23 13:06:09 -04:00
Rangi42 5f2ee530b8 Pass -Wno-unused-but-set-variable by default, not just in make develop
The Bison-generated parser skeleton otherwise triggers this warning
with Apple clang++ for `yynerrs_`.
2026-05-23 01:40:13 -04:00
Rangi 4a173130b9 Optimize skipToLeadingKeyword for the common ViewedContent case (#1968) 2026-05-22 19:06:12 -04:00
Rangi ef2f021892 Simplify sectError handling, without the need for an empty-string sentinel
The `errorNoTrace` case for the empty-string sentinel was unreachable,
so we can just have a `fatalNoTrace` error right away.
2026-05-22 18:17:25 -04:00
Rangi dce14fd4b8 Use C++20 concepts to require constraints on template parameters (#1977) 2026-05-22 17:54:34 -04:00
Rangi 728bed39d5 Do not support GCC 9 (#1978)
This will let us use C++20 features that GCC 9's experimental
C++20 support did not yet cover, such as "concepts".

This reverts some commits:
- 6bcd79b997
- d5ce5329ea
- 728d14879b
2026-05-22 16:46:46 -04:00
Rangi 48fcd9a0ca Use templates to reduce the redundant number-lexing functions (#1963) 2026-05-21 23:13:09 +02:00
Eldred Habert 1871b0a0b8 Use Windows git for checkout's post-job cleanup, not Cygwin's git (#1953)
This fixes an error from using Cygwin's git in checkout's post-job cleanup
2026-05-21 15:25:29 -04:00
Rangi d56dbbb4bf Refactor section creation errors, and simplify output for single errors (#1964) 2026-05-21 13:01:08 -04:00
Rangi 728d14879b Consistently use -std=c++2a, not -std=c++20
Commit 63a911e657 switched
to `-std=c++20` since at the time we required GCC 10 or higher.

Commit d5ce5329ea partially reverted
to `-std=c++2a` since we once again support GCC 9, which did not
yet handle `std=c++20`.
2026-05-20 17:09:23 -04:00
ISSOtm 0ed8c2f8ee Docu-comment an implicit correctness assumption 2026-05-14 14:47:23 +02:00
ISSOtm d5186b088b Link against (non-debug) MSVC runtime statically 2026-05-14 14:47:23 +02:00
ISSOtm fee177d0b9 Link zlib and libpng statically by default
Only when we are building them ourselves, that is.
2026-05-14 14:47:23 +02:00
Rangi 42e3da837c Comment the commands to use for profiling and code coverage 2026-05-09 20:52:45 -04:00
Rangi 358e8fe636 Add more tests of lexer's skipToLeadingKeyword behavior (#1971)
The character after the ending keyword gets blue-painted.
2026-05-09 15:56:17 -04:00
Rangi c50a849757 Verbose tracing shows lexed and captured values (#1969) 2026-05-09 12:01:29 -04:00
Rangi 57111b219a Describe the wine-shim Makefile target (#1967) 2026-05-09 15:27:08 +02:00
Rangi be2d028ae6 Format getopt errors more like others (sentence case, quoted options) (#1966) 2026-05-09 13:27:34 +02:00
ISSOtm 1af8bdda16 Have CMake put RGBDS executables in our own dir
Not the top-level if we are part of a larger project!
2026-05-06 18:49:19 +02:00
ISSOtm fa22b78e7d Use type instead of which in shell scripts
The latter is not a Bash built-in,
and some environments turn out to produce non-conforming
return codes.

`type` is provided by Bash itself,
so we can rely on it better.
2026-05-05 16:03:33 +02:00
Rangi42 f0161b41c8 Update readHexNumber for consistency with other routines 2026-04-29 12:31:00 +02:00
Rangi42 ca23210f18 Refactor and rename some numeric literal lexing for asm and linkerscript consistency 2026-04-29 12:15:14 +02:00
Rangi42 85e044f5be Use std::move when relevant in Token constructor 2026-04-28 13:32:45 +02:00
Rangi42 60e76b2da4 Avoid UB if new OOMs by removing std:nothrow 2026-04-28 13:28:32 +02:00
Rangi42 3c7488c131 Some refactoring, renaming, and debug assertions for clarity and safety
- Add more `assume()` checks in the lexer
- Replace double negative "`disable* = false`" with "`enable* = true`"
- Naming convention of "`std::deque<> *Stack`" when relying on
  `.push_front()` and `.pop_back()`
2026-04-27 18:47:06 +02:00
Rangi42 9fd0c0297f Fix invalid character in bracketed macro argument
The invalid character should not be consumed by `shiftChar()`.
2026-04-27 17:11:20 +02:00
Rangi42 c1c7e64249 Add two assume calls to verify lexer arguments 2026-04-27 15:35:10 +02:00
Rangi42 a18b2f1049 Consistently lex local labels after keywords, even when skipping/capturing 2026-04-27 15:28:30 +02:00
Rangi42 3f144b7713 Add test case for local labels after block-ending keywords 2026-04-27 15:04:12 +02:00
Rangi42 eeb3a73210 Small optimization to skipToLeadingKeyword 2026-04-27 14:26:47 +02:00
ISSOtm 37d39f91f6 Build using GCC 9 in CI
Checking that we don't regress this later.
Ubuntu doesn't package GCC 8, and we don't support it either,
so that is a good compromise for now.
2026-04-26 23:30:59 +02:00
ISSOtm d5ce5329ea Fix compilation with GCC 9 2026-04-26 23:30:59 +02:00
ISSOtm 6bcd79b997 Revert "Derive operator!= from operator== (#1660)"
This reverts commit 993879a2ed.
2026-04-26 23:30:59 +02:00
ISSOtm decc5f7153 Let parallelism be determined automatically
Ninja is parallel by default;
however, it is not used on FreeBSD, so we still have to specify it there.
2026-04-20 15:32:54 +02:00
ISSOtm a3c953ea46 Pass C++ compiler to CMake via env var
This is a little terser
2026-04-20 15:32:54 +02:00
ISSOtm d43049c84d Imply CMake source dir
Shortening our command lines slightly
2026-04-20 15:32:54 +02:00
ISSOtm b6ff54acc3 Avoid libpng compilation on Windows spamming the Microsoft banner 2026-04-20 15:32:54 +02:00
ISSOtm 71fc449452 Use Ninja on Unix platforms
It has nicer UX, only showing full command lines when they fail.
It could also be slightly faster, though I've seen no measurable improvement.
2026-04-20 15:32:54 +02:00
ISSOtm 59dd1fbbf8 Correct naming of MSBuild CMake presets
You can build with MSVC without MSBuild
2026-04-20 15:32:54 +02:00
ISSOtm 2502d130eb Use Ninja on Windows
MSBuild is slow, and its output is hard to parse visually
(it's all interwoven, like Make without `--output-sync`).
Since we use CMake anyway, we don't care about the build system.
2026-04-20 15:32:54 +02:00
ISSOtm a78a268cb4 Pass convenience options to Make invoked via CMake
Can't pass them to plain Make invocations,
because we try to be compatible with macOS' old Make.
2026-04-20 15:32:54 +02:00
Rangi42 0553491107 Replace a FIXME comment with an explanation of why we can't/won't "fix" it 2026-04-20 14:51:38 +02:00
Eldred Habert 6edac50cc4 Target an even older version of Mac OS X
We can, so let's not ask if we should!

More realistically, we can right now so it's nice to mark that we do, but this is subject to be re-evaluated if any later changes conflicts with this.
Note also that this only affects the binaries we distribute with our releases!
It may very well be possible to compile RGBDS on even older versions of Mac OS X if you have the appropriate compiler setup;
we're just not testing it nor offering such binaries ourselves, but third-party packagers are welcome to do so.
(Looking at you, TigerBrew! ;)
2026-04-20 14:33:59 +02:00
Rangi 77dceaf43a Update libpng to 1.6.57 (#1958) 2026-04-20 13:55:27 +02:00
Rangi cfec017fed Consolidate, refactor, and bugfix the lexer's handling of captures and skips (#1957)
- Do not error about local labels following keywords in skips or captures (fixes #1955)
- Do not incompletely attempt to handle line continuations in skips (fixes #1956)
- Rename `skipToLeadingIdentifier` to `skipToLeadingKeyword`, refactor to merge
  `skipToEOL` into it, and use it for both skips and captures
2026-04-20 13:04:20 +02:00
Rangi42 12186fdccc Keep more non-declaration initialization within the for loop clause 2026-04-19 22:01:56 +02:00
Rangi 71dfab3365 Use charmapEntry to simplify charmap_HasChar 2026-04-17 15:39:30 -04:00
Rangi 20b11039c9 Keep trie edges sorted for O(log N) lookup 2026-04-17 15:39:30 -04:00
Rangi eb9e9c0f33 Replace charmaps' fixed-size 256-value array with a vector of pairs
This should save memory at the cost of O(n) instead of O(1) access,
which should be okay because the `next` vector is generally small.
2026-04-17 15:39:30 -04:00
Rangi ac2a022124 Set the Cygwin shell once as a default for its job 2026-04-15 23:54:12 -04:00
Rangi 1249c4ef58 Revert "Set up Cygwin before cloning our repo"
This reverts commit aeedfb35a6.
2026-04-15 21:53:29 -04:00
ISSOtm aeedfb35a6 Set up Cygwin before cloning our repo
Otherwise different Gits set up and tear down the repo,
leading to issues.
2026-04-16 03:16:56 +02:00
ISSOtm 63609871f4 Cache downloaded dependencies for MinGW build also
Forgot about you!
2026-04-16 02:56:14 +02:00
ISSOtm 393eaa9dc1 Fix a Fix typo ;) 2026-04-16 02:54:40 +02:00
Rangi b3c3981a90 Use a separate CI step to install clang-format before running it
Also use short `-Yqu` flags like our other invocations
2026-04-15 20:12:48 -04:00
ISSOtm 185a5c5369 Add necessary flags to apt install for checkformat 2026-04-16 01:58:42 +02:00
ISSOtm 4ea15ed85a Touch up checkformat.bash
The logic can be slightly simplified,
and the script doesn't require Bash after all.
2026-04-16 01:05:03 +02:00
ISSOtm b218fd65a0 Install clang-format on ubuntu-slim runner
Unlike the “fat” runners, that's not installed by default.
Why that causes `find` to nonetheless exit normally, I have no idea.
2026-04-16 01:02:30 +02:00
ISSOtm 81edc27b6e Fix two warnings on MinGW 2026-04-16 00:57:33 +02:00
ISSOtm dc52487d31 Make -Wformat non-fatal on MinGW
See the comment for a rationale.
2026-04-16 00:57:33 +02:00
ISSOtm 6b994b1737 Fix some warnings raised by MSVC 2026-04-16 00:57:33 +02:00
ISSOtm 0849eb801e Decouple -Werror from MORE_WARNINGS 2026-04-16 00:57:33 +02:00
ISSOtm e6916360f4 Set some flags only for our own code 2026-04-16 00:57:33 +02:00
ISSOtm a802bcb320 Switch MinGW building to CMake
Automatically grabs and compiles libpng, and avoids having hacky lines in our Makefile
(the compiler specification *should* be orthogonal to the build target!)

Also move the MinGW package install to the `install_deps.sh` script,
to move logic off of the YAML.
2026-04-16 00:57:33 +02:00
ISSOtm 846aa975f1 Stop trying to install md5sha1sum
macOS already provides it and Homebrew doesn't override it,
so that's a no-op anyway.
2026-04-16 00:25:58 +02:00
ISSOtm b65649ca73 Tidy up system info 2026-04-16 00:25:58 +02:00
ISSOtm 62ddabb570 Avoid hardcoding Brew's prefix 2026-04-16 00:25:58 +02:00
ISSOtm d48d6fe5d9 Bump our macOS CI runners 2026-04-16 00:25:58 +02:00
Eldred Habert ac0f93ffda Delete GCC static analyzer workflow (#1950)
As for GCC 15, it is stated not to be suitable for C++ code,
and we have gotten annoyingly many false positives out of it,
so let's just disable it (as per
https://github.com/gbdev/rgbds/pull/1950#issuecomment-4243959126).
2026-04-14 22:04:20 +02:00
ISSOtm a1712cb6d9 Run patch format check on ubuntu-slim 2026-04-14 22:03:29 +02:00
Eldred Habert 2968bee86f Run macos-static tests using CTest (#1947)
We can, so why not? It has benefits.
2026-04-14 01:25:47 +02:00
ISSOtm dec7a74166 Fix macOS static build
- Turns out the variable wasn't being set, and thus the flags weren't being passed
- Passing the flags via those variables is basically a bad idea, and it
  turns out to break libpng's config script
- The flags need to be passed during link as well, otherwise the binary
  isn't linked as a fat one
2026-04-14 00:01:14 +02:00
Eldred Habert 9c4e53d1c4 Transition CI from pkg-config to pkgconf (#1942)
Upstream has changed the providing implementation,
so that package will eventually be removed.
2026-04-13 19:46:05 +02:00
Eldred HabertandRangi 463edc3c01 Enable color output in our Linux and macOS CI tests (#1939)
Co-authored-by: Rangi <[email protected]>
2026-04-13 19:31:01 +02:00
Rangi 73941c3249 Add .git-blame-ignore-revs as a blame.ignoreRevsFile 2026-04-13 13:26:29 -04:00
Rangi42 7596ae67b5 Fix internal link to docs/CONTRIBUTING.md 2026-04-13 02:34:46 -04:00
Rangi fc08ab6aee Print a GitHub Actions error annotation if install_deps.sh fails
See https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-commands#setting-an-error-message
2026-04-13 02:04:56 -04:00
Rangi c7663423d6 Update our Dockerfile to base on Debian 13 slim 2026-04-12 22:36:41 -04:00
Rangi 1ff73cd5e0 Revert "Stop trying to explicitly install pkg-config in CI (#1940)"
This reverts commit bc3572ec37.

Turns out that our Dockerfile *does* need to install `pkg-config`
on the `debian:12-slim` image.
2026-04-12 22:33:25 -04:00
Eldred Habert 65ec1af1e8 Switch macOS static build to CMake (#1938)
This moves the tortuous flags out of our CI scripts,
and allows us to benefit from the libpng download caching.
2026-04-12 22:26:15 -04:00
Eldred Habert bc3572ec37 Stop trying to explicitly install pkg-config in CI (#1940)
Turns out it's already installed by default,
but under a different name that's causing extra ops
for no real gain.
2026-04-12 22:08:38 -04:00
Eldred Habert 78281a4aaa Break down CTest cases into each test suite (#1931)
This allows parallelising the individual programs'
test suites, which can save a few minutes!
2026-04-12 21:29:12 -04:00
ISSOtm 6e51ab6f55 Remove a duplicate warning flag
We always pass this one
2026-04-13 01:52:25 +02:00
ISSOtm 52aaf7e3b3 Fix MSVC dependent option syntax
This is not how CMake works lol
2026-04-13 01:37:38 +02:00
ISSOtm 09db4f25dd Bump the maximum version of CMake tested with
Future-proofing!
This is both the version on my own machine,
and what's distributed by Homebrew (thus on GitHub's runners).
2026-04-13 00:33:31 +02:00
Eldred Habert fed5db7743 Move documentation outside of the root directory (#1936) 2026-04-12 18:09:40 -04:00
ISSOtm c6dbec7830 Stop trying to run version test on Cygwin and FreeBSD
Fixes #1934
2026-04-12 23:40:39 +02:00
Eldred Habert 017b0119e6 Overhaul checkdiff CI (#1930) 2026-04-12 16:06:28 -04:00
Eldred Habert 0e6e91d048 Avoid copying RGBFIX binary when testing it (#1933)
This is just cleaner in general,
and also avoids separating it from any DLLs it may be needing.
2026-04-12 13:23:51 -04:00
Rangi df0b557638 Don't allow invalid interpolations to occur (#1925)
Fixes #1921
2026-04-11 18:16:07 +02:00
Eldred Habert 123201ecc6 Avoid repeatedly specifying bash as the command shell in CI (#1926) 2026-04-10 22:04:16 -04:00
Eldred Habert 422e8eec20 Generate Bison output in CMake build tree (#1929)
Again, moving away from in-tree builds
2026-04-10 18:46:57 -04:00
Rangi 49a4da2235 Revert "Generate Bison output in CMake build tree"
This reverts commit 4577ff16bc.
2026-04-10 17:18:40 -04:00
ISSOtm 4577ff16bc Generate Bison output in CMake build tree
Again, moving away from in-tree builds
2026-04-10 22:56:59 +02:00
ISSOtm b430d5a8b8 Note why we are not using a CMake list to pass Bison flags 2026-04-10 22:33:54 +02:00
ISSOtmandvulcandth a5be1d886e Copy DLLs to appropriate dir for install-less Windows testing
Co-authored-by: vulcandth <[email protected]>
2026-04-10 18:01:16 +02:00
vulcandth c3b47abcc8 Use CPack for Windows packaging 2026-04-10 18:01:16 +02:00
Rangi 2cfb2b2533 Remove the claim that only exported symbols appear in sym and map files
Fixes #1916

This claim was true in v0.4.2, but intentionally changed in v0.5.0.

rgblink(1) already explains that "all visible labels and exported numeric constants"
will appear, which is a more appropriate location than rgbasm(5).
2026-04-09 21:28:07 -04:00
Rangi 187e1a55b8 Add examples for using character literals instead of strings as numbers
Fixes #1890
2026-04-08 21:42:10 -04:00
Rangi 143d503c6c Update libpng to 1.6.56 (#1922)
Fixes #1920

This also switches from Homebrew-installed `sha2`
to macOS-preinstalled `shasum`.
2026-04-08 20:58:41 -04:00
Rangi 6e13779b8b Use C++-sryle static_cast, not C-style explicit cast
`uint32_t(param)` is actually functional notation of explicit casting,
not a direct constructor call. `uint32_t{param}` would be uniform
initialization syntax for a constructor call, but would not allow
narrowing from `uint64_t`. See issue #1904 for discussion.
2026-04-08 20:05:36 -04:00
ISSOtm ace2f3e613 Document why lib src cache is cross-OS
See https://github.com/gbdev/rgbds/pull/1919#discussion_r3048475606
2026-04-08 12:25:43 +02:00
ISSOtm 8d1a60d6b5 Switch release process to a lightweight runner
Easier to provision, less concurrency overhead for us
2026-04-08 12:25:43 +02:00
ISSOtm 11ac22d8f5 Switch from an Action to gh release
Fewer supply chain risks whooooo
2026-04-08 12:25:43 +02:00
ISSOtm 812e1f6d4b Remove dead code checking for version tag
It was also vulnerable to template injection attacks.
2026-04-08 12:25:43 +02:00
ISSOtm 8dc052475b Avoid caching in our release workflow
This is a malware distrib vector,
and we run this workflow sporadically enough
that we can afford to do so uncached.
2026-04-08 12:25:43 +02:00
ISSOtm 133eaa4e92 Build Windows release in, well, Release mode 2026-04-08 12:25:43 +02:00
ISSOtm 57f1894fbd Fix installing Windows build deps on release 2026-04-08 12:25:43 +02:00
ISSOtm 021fe01eb0 Avoid CMake looking at test dir if testing is disabled
This saves building the two test support programs.
2026-04-08 12:25:43 +02:00
Rangi 9b4b4a581b Check for overflow in fixed-point precision suffix (#1918)
Fixes #1917
2026-04-07 17:06:54 -04:00
ISSOtm bcff14b596 Clean up docs workflows
Usethe `ubuntu-slim` runner to (hopefully) get faster setup times
2026-04-07 21:48:26 +02:00
Rangi 11f6278d95 Refactor lexing of fixed-point numbers (#1915)
This incidentally fixes a bug with too-long fixed-point literals
that have precision suffixes.
2026-04-06 21:45:34 -04:00
Rangi ede9405daf Fix some fixed-point literal lexing issues (#1914)
- No fractional digits are necessary after the decimal point,
  e.g. `42.` is valid instead of `42.0`
- Error messages refer to "fixed-point" not "integer" constants
- Test more carefully for lexing unrelated to underscores
2026-04-04 13:41:45 -04:00
Rangi 25bf0e9e2c SOURCE_DATE_EPOCH must be in base 10 2026-03-30 21:31:37 -04:00
dependabot[bot]anddependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> 167a7ee80c Bump the actions group with 6 updates (#1910)
- Updates `actions/checkout` from 4 to 6
- Updates `docker/login-action` from 3 to 4
- Updates `Chizkiyahu/delete-untagged-ghcr-action` from 5 to 6
- Updates `actions/upload-artifact` from 4 to 7
- Updates `actions/download-artifact` from 4 to 8
- Updates `cygwin/cygwin-install-action` from 4 to 6

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-03-30 21:28:45 -04:00
Rangi 4ce4162da4 A little .yml cleanup 2026-03-30 20:29:06 -04:00
Rangi 18b074711e Fix rgbasm -s not overriding a previous -s 2026-03-30 20:18:19 -04:00
Eldred Habert 44b6a2c453 Add a key that turns out to be required
The documentation is super flaky tbh
2026-03-31 02:14:24 +02:00
Eldred Habert 3fc3130364 Fix some YAML syntax
I prefer TOML and JSON anyway...
2026-03-31 02:12:29 +02:00
Eldred Habert 5090395ca7 Enable GH Actions to be automatically bumped
Turns out those get new major releases somewhat often, and we get deprecation warnings and brownouts and all that.
Automatic bumps should help us avoid that, though I've set a *very* large scan interval to shield us from churn.
2026-03-31 02:03:37 +02:00
Rangi efd4373a56 Check for a SDAS "Def" or "Ref" line before reading a subsequent integer
Without checking `token[0]` through `token[2], `readInt` starting at
`&token[3]` could go out of bounds on a badly-formed SDAS .rel object file
2026-03-30 19:45:44 -04:00
Rangi 92a31ff7df Correct list numbering 2026-03-30 19:23:42 -04:00
ISSOtm 8025c2ae66 Require uploaded artifacts to be non-empty
We can get silent failures otherwise
2026-03-28 11:31:49 +01:00
ISSOtm f7831ce8da Simplify CTest pre-run test command 2026-03-28 01:21:08 +01:00
ISSOtm b736fa22ff Suppress status messages when fetching test deps
Let's avoid status message spam.
2026-03-27 22:07:28 +01:00
ISSOtm 0692d1d28c Avoid passing a C++-only flag when compiling C files
Avoids compiler warnings. This can happen because zlib and libpng are both C projects,
and we build them from source if they are unavailable.
2026-03-25 17:11:46 +01:00
Eldred Habert 4b69d5cc8a Fix name of test repo cache used by macos-static (#1909) 2026-03-24 09:02:28 -04:00
Eldred Habert 52aa518e20 Enable Git colours in CI 2026-03-24 12:40:34 +01:00
Rangi42 919a5dba89 Correct CONTRIBUTING.md to accurately describe test/fetch-test-deps.sh 2026-03-23 11:13:23 -04:00
Eldred Habert d9932b9031 Always clone deps with --depth=1 (#1908) 2026-03-23 11:02:29 -04:00
Rangi 66e521e9e5 Factor out common error-handling functions for lexing numbers of different bases (#1888) 2026-03-19 15:32:25 -04:00
ISSOtm b8e425b41d Avoid passing irrelevant flags to our deps 2026-03-19 20:30:12 +01:00
ISSOtm 6b0658fb59 Cache library deps on Windows
Besides the immediate performance improvement, reducing
the frequency of downloads should make spurious
failures (network, rate-limiting...) less bothersome.
2026-03-19 20:30:12 +01:00
ISSOtm 91fdfcd179 Specify MSVC architecture using presets
Shortens CI command lines slightly,
and documents the requirement.
2026-03-19 20:30:12 +01:00
ISSOtm 5abebcf61f Specify build type implicitly
Again, shortening the CMake command line.
Unfortunately, this doesn't apply to `--install`.
2026-03-19 20:30:12 +01:00
ISSOtm 145473d9bd Use develop preset on FreeBSD
Leak detection is not supported, so we have to disable it.
2026-03-19 20:30:12 +01:00
ISSOtm 2fb64816a9 Indicate more clearly that LTO is not used in debug mode
This has made me worried once or twice
2026-03-19 20:30:12 +01:00
ISSOtm 7cf330e3f9 Enable CMake parallelism in a central place
Shortening command lines is useful
2026-03-19 20:30:12 +01:00
ISSOtm 2e66515096 Invoke CTest directly
This allows passing it arguments directly, like `--verbose` here
(which is more appropriate for CI use).
2026-03-19 20:30:12 +01:00
ISSOtm c93f377bfb Enable colour diagnostics in CI
At least for CMake.
2026-03-19 20:30:12 +01:00
ISSOtm d6d1844d60 Seek lib deps via CMake FetchContent
`FetchContent` respects existing installs, and downloads and compiles the libs
if they aren't found.
This is admittedly a little finicky, since this ignores the usual `Find*`
modules provided by CMake, requiring a bit of glue on our side.

But, one upside is that this moves that logic from our CI into the build system,
which can thus benefit other downstream users.
This also opens the door to some improvements in upcoming commits.

Doing this with Bison turned out to be much more painful, however, due to
`FindBISON` providing the specific `bison_target` command; thus, it remains
installed externally, so that it can be picked up by `FindBISON`.

This also bumps our CMake version requirement slightly, though it's
possible that older versions keep working, or could be supported with small patches;
however, our CI doesn't provide anything below 3.31, so we can't check.
2026-03-19 20:30:12 +01:00
ISSOtm fd38a3dbc4 Add CMake and YAML files to EditorConfig
Since we use a different style for those
2026-03-19 20:30:12 +01:00
ISSOtm 60d58723aa Use a modern GNU Make for CMake CI on macOS
We can assume that CMake handles old Make correctly,
but we'd like to benefit from improvements
like output batching.
2026-03-19 20:30:12 +01:00
ISSOtm a9b6cda77b Reorder CMakeLists commands by topic 2026-03-17 08:18:50 +01:00
ISSOtm 091452d591 Remove call to configuring version file
Missed in 5c4ca36c5a
2026-03-17 05:28:23 +01:00
ISSOtm df1d909853 Improve documentation of CMake bin output dir 2026-03-17 05:27:39 +01:00
ISSOtm fb4e08ce71 Tidy up CMake sanitizer flags
Set the flags in the build itself instead of trying to override the cache
(this was an artifact of when I didn't understand the CMake variable model),
which avoids them being duplicated on each re-configuration.

Also remove `-g`, since it's defined by the build type by default
(we leave it up to the user to choose Debug or RelWithDebInfo).
2026-03-16 20:23:47 -04:00
ISSOtm 7244b9d17e Silence the same warning as in the Makefile
As requested by https://github.com/gbdev/rgbds/pull/1899#discussion_r2943039607
2026-03-16 20:23:47 -04:00
ISSOtm 5c4ca36c5a Harmonise passing build version
Avoid running some configure step, instead pass it as a define like the Makefile
2026-03-16 20:23:47 -04:00
ISSOtm 292c297518 Sync Windows release steps with new CI 2026-03-16 20:23:47 -04:00
ISSOtm a5bb431d47 Fix debug-mode building on Windows
ASan seems broken, and the debug-mode DLL names are different
2026-03-16 20:23:47 -04:00
ISSOtm 10e1c9d187 Avoid passing sanitizer options to MSVC linker
Apparently it does not support them
2026-03-16 20:23:47 -04:00
ISSOtm d8722b6705 Use imported targets for linking to libpng
This massively simplifies the process lol
2026-03-16 20:23:47 -04:00
ISSOtm 2d0ac7eeb0 Disable exceptions and RTTI when building with CMake 2026-03-16 20:23:47 -04:00
ISSOtm d5033a2bd9 Handle project version better in CMake
Parse the version from `version.hpp`, and check its consistency with
the Git tag to help catch release blunders.
2026-03-16 20:23:47 -04:00
ISSOtm 45fff0fd58 Harmonise naming of CMake test knobs
Also reorganise the file a little
2026-03-16 20:23:47 -04:00
ISSOtm c963c7b1c7 Simplify include directory directive 2026-03-16 20:23:47 -04:00
ISSOtm 63c7835e71 Stop overriding the binaries' install dir
This is equivalent to the default, except the default accepts being overridden
2026-03-16 20:23:47 -04:00
ISSOtm 35af3185eb Enable LTO even for multi-config CMake generators
See https://cmake.org/cmake/help/latest/manual/cmake-buildsystem.7.html#build-configurations
for the rationale.
2026-03-16 20:23:47 -04:00
ISSOtm db9d9c7653 Install our man pages in a more standard-configurable manner 2026-03-16 20:23:47 -04:00
ISSOtm 9e5a9107f2 Remove enforced CTest verbosity
It can be controlled from the command line instead, and that's better
2026-03-16 20:23:47 -04:00
ISSOtm 275fcf8fcf Improve CMake-in-tree fatal error message 2026-03-16 20:23:47 -04:00
ISSOtm bc37b0ece6 Skip trying to link to libm explicitly
This doesn't seem to be necessary: it is automatically linked to,
at least on my machine. \*shrugs\*
2026-03-16 20:23:47 -04:00
ISSOtm e63ce24e48 Add a CMake preset for maintainer flags 2026-03-16 20:23:47 -04:00
ISSOtm d524884799 Run CI tests using CTest when possible 2026-03-16 20:23:47 -04:00
ISSOtm 34e1f8dcc5 Remove useless MSVC flag
CMake only passes a single file at a time anyway
2026-03-16 20:23:47 -04:00
ISSOtm cd64de9323 Remove a warning triggered by MSVC's own standard library
No longer triggers now, so we can remove our workaround for their breakage.
2026-03-16 20:23:47 -04:00
ISSOtm a01b805e4b Remove an outdated comment 2026-03-16 20:23:47 -04:00
ISSOtm a139cbc744 Refactor the source file listing
Make the common files into an object library, which lets them
be compiled only once (saving 41 build steps)
This also lends itself well to removing the per-program loop,
which simplifies the code somewhat.
2026-03-16 20:23:47 -04:00
ISSOtm 06e5386d93 Move FreeBSD deps install to common CI script
Making the OS filter in test driver consistent as per
https://github.com/gbdev/rgbds/pull/1899#discussion_r2942998932
2026-03-16 20:23:47 -04:00
ISSOtm 37f57a752f Print a more graceful error message for run-tests.sh --unk 2026-03-16 20:23:47 -04:00
ISSOtm 670bdf2095 Document run-tests.sh --os
Also switch to heredoc syntax for ease of editing
2026-03-16 20:23:47 -04:00
ISSOtm 6270f654a1 Make sure to init all variables involved in CMake tests 2026-03-16 20:23:47 -04:00
ISSOtm 676db46c01 Add a few details to the project() call
We can use them now that the minimum version has been bumped
2026-03-16 20:23:47 -04:00
ISSOtm 8979b54281 Ignore a CMake file that is not intended to be checked in 2026-03-16 20:23:47 -04:00
ISSOtm a6f03530ed Correct minimum CMake version required
Turns out the status messages use 3.17
2026-03-16 20:23:47 -04:00
ISSOtm b56b56a695 Reformat some long warning-flag-setting lines 2026-03-16 20:23:47 -04:00
ISSOtm dc5fc9f327 Remove obsolete CMake version comment 2026-03-16 20:23:47 -04:00
ISSOtm 3d35457eeb Avoid showing the "more warnings" option for MSVC 2026-03-16 20:23:47 -04:00
ISSOtm aea39ec8c8 Log with sanitizers are enabled under CMake
This can help bring attention to the MSVC difference (no UBSan there)
2026-03-16 20:23:47 -04:00
ISSOtm 9293068370 Properly specify our max CMake version supported
Also bump it to the version I just tested it with
2026-03-16 20:23:47 -04:00
ISSOtm d054f07703 Fix some truncation warnings
Amusingly, reported by MSVC only
2026-03-10 01:31:23 -04:00
Rangi 65b0b49720 Update zlib to 1.3.2
Note that the DLL name created by CMake with `BUILD_SHARED_LIBS`
has changed from `zlib1.dll` to `z.dll`. This was caused by the
"Continued rewrite of CMake build [Vollstrecker]" from its
changelog <https://zlib.net/ChangeLog.txt>, and has been reported
in <https://github.com/madler/zlib/issues/1181>.

The MinGW package `libz-mingw-w64-dev` still calls it `libz1.dll`.
2026-03-06 22:28:09 -05:00
Rangi 48d58ba095 Pass -Wdangling-alias to Bison 3.5 or newer
`bison -Wall` enables all diagnostics except `-Wcounterexamples`
(added in 3.7; we already pass it), `-Wyacc` (which we do not need),
and `-Wdangling-alias` (added in 3.5).
2026-03-06 22:28:09 -05:00
Rangi af0505b4cd Explicitly clarify that SECTION(@) returns the name of the current section 2026-02-06 19:37:49 -05:00
Eldred Habert 7c1e1fe515 Reference the file that actually provides the linker script lexer 2026-01-27 12:54:06 +01:00
Rangi d053025070 Avoid writing "XXX" since it's a conventional "TODO/FIXME" comment 2026-01-22 13:01:10 -05:00
Rangi ade898d815 List -B in rgbgfx options 2026-01-13 09:46:33 -05:00
Rangi e738b90c69 Refactor to combine similar functions into one 2026-01-07 16:36:04 -05:00
Rangi a91d26192d Fix SECTION UNION alignment depending on piece order 2026-01-07 16:36:04 -05:00
Rangi 92bfe5d930 Release v1.0.1 2026-01-01 00:43:43 -05:00
Rangi 41fe1d8f25 Correct error message for unconstrained sections with overlay (#1879) 2025-12-28 19:21:53 -05:00
Rangi 63a911e657 Specify -std=c++20 not c++2a (#1877) 2025-12-21 11:44:14 -05:00
Rangi a9ab248fed Improve some RGBGFX error messages (#1876)
* Improve some RGBGFX error messages

* Fix assertion failure on ambiguous transparent/opaque pixels
2025-12-19 13:00:05 -05:00
Rangi 9b22ff3491 Fix link in man page 2025-12-12 18:25:47 -05:00
Rangi a4af81f250 Fix two "Using a macro as first argument cancels effect of .Li" man page warnings
These were observed in https://udd.debian.org/lintian/?packages=rgbds
and can be reproduced by running:

    for f in man/*; do
        echo $f
        LC_ALL=C.UTF-8 MANROFFSEQ='' MANWIDTH=120 \
            man --warnings -E UTF-8 -l -Tutf8 -Z "$f" >/dev/null
    done
2025-12-12 12:31:03 -05:00
Rangi e08de399db Clarify usage versus encoding of jr and ldh (#1875) 2025-12-11 17:46:39 -05:00
Rangi d4e0ca5f90 Update libpng to 1.6.53 2025-12-11 11:48:18 -05:00
Rangi 2666dcbc26 Remove exclamation marks and periods from error messages (#1874) 2025-12-10 11:50:33 -05:00
Rangi42 27dca5680c Fix formatting typo in man/rgbasm-old.5 2025-12-09 10:33:24 -05:00
Rangi b0e0dfc56e Handle a missing -P/--preinclude file the same as an INCLUDE (#1873) 2025-12-08 14:39:34 -05:00
Rangi 33475e2c36 Factor out version-printing to usage.cpp (#1870) 2025-12-05 23:04:49 -05:00
Rangi c8161be23a Add missing SPDX-License-Identifier: MIT comments 2025-12-05 22:41:12 -05:00
Rangi 2c5c453ab8 Refactor FileStackNode::printBacktrace from recursive to iterative
This avoids a potential stack overflow for very long backtraces,
or for corrupt object files with cyclic backtraces
2025-12-05 22:41:12 -05:00
Rangi c3e245c13e Correct typo in rgbds(5) 2025-12-05 22:39:30 -05:00
Rangi 3631fab63c Fix bug where an object's invalid ROMX bank of 0 could break rgblink (#1868) 2025-12-05 11:21:00 -05:00
Rangi 1c00123b33 Add missing return 0; to rgblink main() 2025-12-04 21:06:46 -05:00
Rangi 131bb97ebc Fix some rgblink object file input bugs found via fuzzing with AFL++ (#1867)
- ID numbers (for fstack nodes, sections, symbols, patches, etc)
  might be too large for their associated collection
- Enum values might be invalid
- Bank values might be out of range for their section types
2025-12-04 20:49:16 -05:00
Rangi 8d6c617875 Use 4 spaces per tab in LCOV coverage report 2025-12-04 17:56:16 -05:00
Rangi42 752e2b3620 Symbol names with more than two '.'s could be defined as constants
Dot-only names could also trip an assertion in `make develop`
when used as labels
2025-12-04 15:15:41 -05:00
Rangi42 ad3188f038 Fix garbage characters at EOF causing an infinite loop 2025-12-04 15:15:41 -05:00
Rangi a6eb6457d8 Clarify documentation of rgbgfx -C/--color-curve (#1864) 2025-12-04 10:49:23 -05:00
Rangi 0d3276975e Update test dependencies (#1865) 2025-12-04 10:29:40 -05:00
Rangi d961c697d7 Update libpng to 1.6.51 (#1862) 2025-11-22 19:05:52 -05:00
Rangi 1eb4eb3339 Reuse the usage.name for printing version info 2025-11-18 22:32:45 -05:00
Rangi a3d3e1525a Fix RGBLINK object type detection 2025-11-18 22:01:43 -05:00
Rangi 3553c9c4da Fix RGBLINK evaluation of undefined RPN symbols
This was the only RPN case to not assign a deliberate value
in all possible branches.

Fixes #1858
2025-11-18 16:40:24 -05:00
Rangi 5c2c893ced Refactor getSectionDescription in src/link/assign.cpp 2025-11-16 17:37:01 -05:00
Rangi 0f266d1c66 Specify more ASan options (#1860) 2025-11-16 17:11:09 -05:00
Rangi 8ab4602ae5 Add -D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_DEBUG to develop builds (#1859) 2025-11-16 13:11:08 -05:00
Rangi 04e3a904c2 Avoid calling style_Set/Reset before strerror(errno),
since they may call `isatty` which can change `errno`

Fixes #1857
2025-11-08 12:06:16 -05:00
Rangi 395b03e88e Disallow SECTION UNION for ROM sections
Fixes #1855
2025-11-07 11:38:06 -05:00
Rangi42 fb9fa6038c Release version 1.0.0 2025-10-31 20:19:24 -04:00
Rangi 35e5808423 Update rgbasm(5) docs based on @nummacway's feedback (#1852) 2025-10-31 18:36:53 -04:00
Rangi42 558d3ca0fc Disallow labels before ENDC 2025-10-31 18:21:59 -04:00
Rangi42 df5162edca Use loops instead of tail calls and musttail
gcc 15.2.1 20250813 complains "address of automatic variable can
escape to `musttail` call" from `-Wmaybe-musttail-local-addr`,
and guaranteeing tail-call optimization cross-platform is more
trouble than it's worth.
2025-10-27 12:05:27 -04:00
Rangi42 2519d1e698 Mention REDEF and FOR regarding EQUS expansion
Fixes #1851
2025-10-27 10:54:16 -04:00
Rangi42 ca383c91ca Revert "More accurate 8-bit <=> 5-bit RGB color conversion (#1827)"
This reverts commit 223b3d1921.
2025-10-24 13:32:59 -04:00
Rangi 8bedd710d7 Simplify musl's getopt, including removing optind, optopt, opterr, idx, and longonly 2025-10-23 13:39:28 -04:00
Rangi efb5a88edb Show conventional colored "error:"/"FATAL:" for CLI option errors 2025-10-23 12:40:29 -04:00
Rangi f065243cd2 Enable RGBGFX's CLI "at-files" for all programs (#1848) 2025-10-22 17:05:59 -04:00
Rangi a0bb830679 More consistent man page descriptions for CLI options 2025-10-22 14:48:24 -04:00
Rangi 7654c6e27a More consistent man page descriptions for warning diagnostics 2025-10-22 14:03:34 -04:00
Rangi 400375b2e5 Share some handling between two tests of rgbasm -M - 2025-10-20 20:57:48 -04:00
Rangi 7462bccb72 Move struct Palette into its own file (#1850) 2025-10-20 16:59:24 -04:00
Rangi 2873e0b8c8 Use musttail attribute to guarantee tail recursion (#1849) 2025-10-20 15:56:22 -04:00
Rangi 1badba03d8 Clean up some #define callables
These are used where anonymous functions would not be sufficient
2025-10-13 13:14:49 -04:00
Rangi42 64bcef99bd Lower default -Wtrunction= level to 1 2025-10-13 11:48:33 -04:00
Rangi42 aa672bbec9 Rephrase PURGE documentation and raise the default level to 2
Fixes #1847
2025-10-13 11:43:29 -04:00
Rangi42 651877e094 Avoid reusing a static local variable (too fragile) 2025-10-08 21:19:23 -04:00
Rangi 26c48cc409 Add RGBGFX test for libpng warning with invalid bKGD chunk 2025-10-08 15:44:15 -04:00
Rangi 23b9039716 Give clearer names to template parameters 2025-10-08 14:55:43 -04:00
Rangi 711fba5e35 Add more tests for things that only the external tests had covered 2025-10-08 13:32:48 -04:00
Rangi 089fc11e31 A local label starting with a keyword (e.g. jr.local) is an error 2025-10-08 12:23:08 -04:00
Rangi42 837f552987 Fix bank increment never happening due to unsigned overflow 2025-10-07 16:20:24 -04:00
Rangi cb8c973453 Add test for undefined __SCOPE__ 2025-10-06 17:51:21 -04:00
Rangi cca3794dd0 Mention libpng in its internal warning and error messages 2025-10-06 17:03:51 -04:00
Rangi 02c2408f58 Implement reversed template for reversing for-each loops 2025-10-06 16:50:47 -04:00
Rangi fba0562650 Fix repeated REPT nodes in backtraces 2025-10-06 16:36:55 -04:00
Rangi 0c9920d4a6 Use C++ iterator for fragment/union "pieces" of RGBLINK sections 2025-10-05 15:07:25 -04:00
Rangi 7733ccdeb6 Implement __SCOPE__ (#1845) 2025-10-04 16:41:21 -04:00
Rangi 13e85b5151 Replace all ctype.h functions with locale-independent ones 2025-10-03 12:52:24 -04:00
Rangi 268b586c9d Release v1.0.0-rc2 2025-09-30 18:56:00 -04:00
Rangi 85d3b5df58 Add more RGBFIX tests 2025-09-30 18:20:53 -04:00
Rangi eea277ae9c Add more tests for RGBFIX 2025-09-29 22:43:16 -04:00
Rangi 538395b92c Prevent simple syntax highlighters from breaking on /* in a string 2025-09-29 11:11:40 -04:00
Rangi 3108fb5297 Rename gbz80.7 "CPU opcode reference" to "Game Boy CPU instruction reference" 2025-09-28 16:43:36 -04:00
Rangi42 f99591bf6f Link FORCE_COLOR and NO_COLOR 2025-09-25 14:06:44 -04:00
Rangi42 0297da4d4c Add more tests for RGBASM coverage 2025-09-25 13:30:30 -04:00
Rangi42 96b953fe51 Add a test case for overlapping IF/ENDC and REPT/ENDR
This trips an asserton in the Rust rewrite because of its different
conditional stack design
2025-09-25 11:57:56 -04:00
Rangi42 0670c03bc2 Add CLI tests for RGBASM 2025-09-25 11:57:56 -04:00
Rangi42 09ef5b7e06 Refactor error fix suggestions in fstk_RunMacro 2025-09-24 19:35:41 -04:00
Rangi42 d5bb462f25 Separate isLetter into isUpper and isLower 2025-09-24 19:19:50 -04:00
Rangi42 b0727e9779 Suggest removing space before colon to define a label instead of invoking a macro 2025-09-24 18:32:45 -04:00
Rangi42 ca4b890273 Consistently do & alignMask, not % alignSize
Also add more unrelated tests for coverage
2025-09-23 13:25:51 -04:00
Rangi42 96a75500d3 Test gb-starter-kit from codeberg.org, not github.com 2025-09-23 13:06:12 -04:00
Rangi 634fd853d1 Factor out a single parseNumber utility function (#1839) 2025-09-22 15:15:24 -04:00
Rangi42 c8d22d8744 Refactor some iterator template code in RGBGFX pal_packing.cpp 2025-09-21 10:59:59 -04:00
Rangi42 3ece61b103 Use fewer templates in RGBGFX pal_packing.cpp 2025-09-20 22:00:17 -04:00
Rangi42 a82fd17529 Simplify RGBGFX code by using fewer templates 2025-09-20 21:06:51 -04:00
Rangi42 e7f5ab3f55 Warn about rgbgfx -O without -o or any of -A -T -P -Q 2025-09-20 20:23:29 -04:00
Rangi42 595c87b2f8 Update test dependencies 2025-09-20 15:23:02 -04:00
Rangi c49a7d1e2f Make CLI and OPT options -p and -Q more consistent (#1834) 2025-09-20 13:54:28 -04:00
Rangi42 d8aff148bb Factor out RRANGE macro like RANGE 2025-09-19 16:53:44 -04:00
Rangi e31bcabbaa Implement === and !== string comparison operators (#1832) 2025-09-19 14:06:36 -04:00
Rangi 67741ab428 Trim left space from macro args, even past block comments (#1831) 2025-09-19 13:44:18 -04:00
Rangi e0a6199f83 Allow charmap to map 'characters' as well as "strings" (#1830) 2025-09-16 12:51:07 +02:00
Rangi42 6cffd991f7 Document rgbasm -Wempty-data-directive
Fixes #1829
2025-09-15 09:44:50 -04:00
Rangi42 1fdeb34e50 Fix too-short .out.bin expected test results
RGBASM tests now use `rgblink -x` instead of `dd` to get trimmed
test output. RGBLINK tests cannot do so because some of them
(e.g. bank-numbers.asm and sizeof-startof.asm) rely on ROMX
sections above 1, and `-x` implies `-t` which breaks that.
2025-09-15 09:25:33 -04:00
Rangi42 9f16881d64 Use for-each loop 2025-09-10 21:18:33 -04:00
Rangi 223b3d1921 More accurate 8-bit <=> 5-bit RGB color conversion (#1827) 2025-09-08 15:13:25 -04:00
Rangi 65d408eb5d Document more about the RGBDS architecture (#1809) 2025-09-07 15:34:52 -04:00
ReiquelApplegate 3677ab2ebf Correct -q's arg name in rgbgfx(1) (#1826) 2025-09-07 18:28:37 +02:00
Rangi42 d404621e0d Don't silence strings-as-numbers with OPT Wno-obsolete in tests 2025-09-07 12:17:39 -04:00
Rangi42 c8a088f281 Avoid nonessential EQUS expansion in tests 2025-09-06 13:45:12 -04:00
Rangi42 94ed28acf8 Avoid nonessential strings-as-numbers in tests 2025-09-06 12:45:01 -04:00
Rangi42 00b5077b2a Make usage info output responsive to the terminal width 2025-09-05 21:58:17 -04:00
Rangi42 024b33b63a make format should apply to all .cpp and .hpp files 2025-09-05 21:05:58 -04:00
Rangi42 dcc10cebc3 Add test for duplicate section after use of fragment literal
Verifies that #1822 was fixed (by c6997fe73c)
2025-09-05 20:14:01 -04:00
Rangi42 1fc9ba86c4 Some RGBLINK refactoring
- Consistently refer to `Section` fragments/unions as "pieces" (renaming `.nextu`)
- Remove `Symbol`'s `.label()` accessors (use `std::get<Label>`)
- Move some `Label`-related logic into `Symbol` methods
2025-09-05 16:34:51 -04:00
Rangi42 e569e0c200 Don't comment "; Next fragment/union" in .map files for empty section pieces
Fixes #1821
2025-09-05 15:31:46 -04:00
Rangi42 f7fb3af615 Run make tidy with Checks: '-*,misc-include-cleaner' in .clang-tidy (IWYU) 2025-09-04 13:39:23 -04:00
Rangi42 1dfc1d3231 Factor out isBinDigit and parseHexDigit utility functions 2025-09-04 13:23:10 -04:00
Rangi42 891e6f98df Fix formatting of very long fixed-point numbers 2025-09-04 12:54:14 -04:00
Rangi42 bdc885bd69 Avoid UB when checking truncation range
Fixes #1818
2025-09-04 12:04:10 -04:00
Rangi42 5b67dc94b6 Add more test coverage 2025-09-04 01:29:50 -04:00
Rangi42 4f702a4be8 Try to optimize RPN expressions with .emplace_back instead of .push_back 2025-09-03 23:00:06 -04:00
Rangi42 c5d437ab3c Tell people to use character literals or CHARVAL instead of strings as numbers 2025-09-03 22:46:19 -04:00
Rangi42 c5c2800f17 Move RPN buffer encoding logic into rpn.cpp 2025-09-03 22:36:00 -04:00
Rangi42 c798500563 Don't call rpn.clear() when we can safely assume it's already empty() 2025-09-03 21:02:57 -04:00
Rangi 590d113e94 Use a vector of RPN values (#1820)
This is instead of byte-encoding them in a different way than the actual object output's RPN buffer
2025-09-03 14:42:37 -04:00
Rangi ee1db0a582 Fix RPN patches for all commands (#1819) 2025-09-02 16:44:25 -04:00
Rangi42 5701d747d4 Document the stricter rules for lexing underscores in integer constants 2025-09-02 14:39:28 -04:00
Rangi42 2110aaca20 Fix RGBLINK and RGBGFX warning/error message colors 2025-09-01 20:51:33 -04:00
Rangi42 8df88f92ba Release v1.0.0-rc1 2025-09-01 18:09:42 -04:00
Rangi 534a4efee4 Add 0/1/2 warning levels to rgblink -Wtruncation (#1816) 2025-09-01 15:35:53 -04:00
Rangi42 cc96b4d517 Two small improvements
- Check whether `.read()` completed
- `.reserve()` expected space ahead of time
2025-09-01 11:46:41 -04:00
Rangi42 0ccdbf509a Simplify format specs to not use a per-character state machine 2025-08-30 12:23:01 -04:00
Rangi 531278961f Require underscores to actually be digit separators (#1812)
Multiple, trailing, or next to decimal point are errors
2025-08-30 10:44:20 -04:00
Rangi 85176ef10a Fix q format spec (#1811) 2025-08-29 14:23:49 -04:00
Rangi 02b880e1b0 Separate RGBFIX header fixing from CLI option parsing (#1808) 2025-08-28 12:28:08 -04:00
Rangi42 c6997fe73c Factor out InsertionOrderedMap to group an indexed list with a string-keyed map 2025-08-26 16:04:45 -04:00
Rangi42 c578a7b761 More specific error message when an expression is not constant because a symbol is undefined 2025-08-24 22:02:41 -04:00
Rangi42 8564df51e5 -Wexport-undefined warning for exporting undefined symbols 2025-08-24 17:36:47 -04:00
Rangi42 62d3b44768 Add test for UNION without NEXTU 2025-08-24 13:08:27 -04:00
Rangi42 ead5337fe0 Use scoped blocks for case-specific variables 2025-08-23 21:52:22 -04:00
Rangi42 0d509aa65c Suggest DEF when undefined macros look like definitions 2025-08-23 21:40:51 -04:00
Rangi42 fcfc931867 Shorten lexing of simple tokens 2025-08-20 22:37:03 -04:00
Rangi 3d155d5695 Some refactoring and cleanup (#1806)
* Use clang-tidy `misc-include-cleaner` for IWYU `#include` cleanup

* Use `std::optional<size_t>` instead of `ssize_t`

* Rename some functions in linkdefs.hpp

* Fix header order
2025-08-20 16:09:04 -04:00
Rangi42 92ed6ece53 Support 32-bit addresses ("XL4") as of SDCC 4.4.0 2025-08-20 09:17:45 -04:00
Rangi42 e0e9ef190a Clarify DAA documentation 2025-08-20 08:57:32 -04:00
Rangi42 386fb5f398 Add more character utility functions 2025-08-19 19:17:40 -04:00
Rangi42 94e9ef5213 Factor shared code out of lexer_CaptureRept and lexer_CaptureMacro 2025-08-19 18:11:50 -04:00
Rangi 0c4c25b2d2 Add a little more test coverage (#1805)
Format main.cpp files more consistently

Add `make format` to run clang-format on everything
2025-08-19 15:26:23 -04:00
Rangi42 f7167d8115 More consistent documentation for NP-complete heuristics 2025-08-18 21:45:26 -04:00
Rangi b7e0783ae7 Implement ? suffix to "quiet" a context and exclude it from backtraces (#1800) 2025-08-18 21:34:58 -04:00
Rangi42 77a105e189 Mention the "first-fit bin packing" algorithm of RGBLINK 2025-08-18 11:51:01 -04:00
Rangi42 a16dcc0ea5 Downgrade FreeBSD release used for testing from 15 to 14.3
See https://github.com/vmactions/freebsd-vm/issues/108

We get the error:

ld-elf.so.1: Shared object "libutil.so.10" not found, required by "pkg"
2025-08-17 14:09:39 -04:00
Rangi42 9f373d49ac Add more tests for edge-case macro and interpolation expansion behavior
Fixes #1803
2025-08-17 13:52:58 -04:00
Rangi 272019beb0 Fix line numbers from nested expansions (#1802) 2025-08-14 11:13:50 -04:00
Rangi db6793f444 Don't count single quote ' as garbage (#1801)
Also copy the "blank space" (space or tab) vs "whitespace" (space,
tab, or newline) convention from `<ctype.h>`
2025-08-14 10:10:59 -04:00
Rangi42 ea1358bbe6 Predef std::pair to two-element std::tuple 2025-08-13 20:48:54 -04:00
Rangi42 2bdf61da70 Increase RGBASM test coverage 2025-08-13 12:26:01 -04:00
Rangi42 92826a726a Move some static variables into the only functions that use them 2025-08-13 09:34:49 -04:00
Rangi 9c3ce69180 Factor out shared backtrace code (#1793) 2025-08-12 17:56:54 -04:00
Rangi 50d0b101c3 Format linker script error backtraces the same way as others (#1792) 2025-08-12 16:58:17 -04:00
Rangi42 1bf1219e07 Factor out shared --color-parsing code 2025-08-12 15:53:57 -04:00
Rangi 7b405513d9 Make quote marks consistent in error/warning messages (#1791)
- "Double quotes" for strings (filenames, section names, CLI option arguments, etc)
- 'Single quotes' for characters and CLI option flags
- `Backticks` for keywords and identifiers (symbol names, charmap names, etc)

CLI option flags also have their leading dashes
2025-08-12 15:24:21 -04:00
Rangi 7df9c12a6c Fix division and modulo for very large negative numbers (#1790) 2025-08-11 20:46:47 -04:00
Rangi42 30a8503dcd Format RGBFIX and RGBGFX warnings/errors the same way as RGBASM and RGBLINK 2025-08-11 15:16:00 -04:00
Rangi42 02310489c6 Suggest ld and call when failing to link ldh and rst 2025-08-11 15:02:18 -04:00
Rangi 5f8b7474b4 Add -B/--backtrace option to RGBASM and RGBLINK (#1787) 2025-08-11 14:30:14 -04:00
Rangi 92a9c73ee7 Deprecate __DATE__ and __TIME__ (#1786) 2025-08-11 09:48:18 -04:00
Rangi42 7ade3e74b3 Avoid the need to repeat -Weverything in test .flags 2025-08-11 08:11:32 -04:00
Rangi 978e832914 Allow :: to join instructions *and* data declarations (#1785) 2025-08-11 08:04:42 -04:00
Rangi42 2130a5ba1f Error messages refer to "undefined" symbols and sections 2025-08-08 19:47:42 -04:00
Rangi42 9fc83efe06 Make rgbasm -Wlarge-constant enabled by default 2025-08-08 19:00:13 -04:00
Rangi e41ce49698 Only print one warning for too-large integer constants, not one per digit (#1781)
This also makes all too-large integer constants evaluate to 0.
2025-08-08 18:58:38 -04:00
Rangi42 1574b5b1f7 Test the behavior of ds N, @ 2025-08-07 09:41:33 -04:00
Rangi42 3f6db080b4 Ensure that alignment is at most 16 and we do not cause UB 2025-08-06 15:31:30 -04:00
Rangi42 f9a55bd5cd Allow OPT to accept optional dashes before flags 2025-08-06 10:19:01 -04:00
Rangi a4a830776b Deprecate treating strings as numbers (#1780) 2025-08-06 10:13:22 -04:00
Rangi42 34d99b273c Add zsh completions for --color flag 2025-08-06 09:26:22 -04:00
Rangi42 feb8365812 Document the deprecated rgbfix -O and string functions 2025-08-06 09:07:35 -04:00
Rangi42 bf66e346f0 Add -Wobsolete to RGBFIX and RGBGFX, and deprecate rgbfix -O 2025-08-05 17:18:54 -04:00
Rangi42 3a0a4b7f90 Deprecate 1-indexed string functions 2025-08-05 16:58:06 -04:00
Rangi 39f0f9edc0 Remove previously deprecated features (#1777)
- Treating multi-unit strings as numbers
- `rgbasm -Wnumeric-string`
- `ldio [c], a` and `ldio a, [c]` (use `ldh`)
- `ld [c], a` and `ld a, [c]` (use `ldh`)
- `ldh [$xx], a` and `ldh a, [$xx]` (use `$FFxx`)
2025-08-05 16:24:10 -04:00
Rangi42 a3983b7b0f Support rgbgfx -c dmg to imply -c dmg=e4
Fixes #1776
2025-08-05 14:18:25 -04:00
Rangi42 504a45a4ed Reuse isWhitespace and isNewline, also refactoring readAtFile 2025-08-05 13:46:53 -04:00
Rangi42 98c5c7f776 Support rgbgfx -c auto for automatic palette generation 2025-08-05 13:05:21 -04:00
Rangi42 7020cf7188 Make struct Uppercase have constexpr methods 2025-08-05 12:11:23 -04:00
Rangi42 70d129fcd7 Color "warning:" yellow in warnx 2025-08-05 11:26:21 -04:00
Rangi42 2d5f4d8910 More consistent missing-input error messages 2025-08-05 11:22:58 -04:00
Rangi42 26c6911c8f More consistent man pages 2025-08-05 11:16:00 -04:00
Rangi42 f1fd3abcff Don't bother searching the keywordDict for local labels 2025-08-05 10:49:09 -04:00
Rangi42 2cae47a5a2 Color verbose output as magenta
Output RGBASM's lexed tokens at level 5 (TRACE)
2025-08-05 00:00:57 -04:00
Rangi42 ac75a085fa Refactor lexer_CaptureRept and lexer_CaptureMacro 2025-08-04 23:26:29 -04:00
Rangi42 0c1b422c36 Refactor some redundant lexer code 2025-08-04 22:43:34 -04:00
Rangi 23ce888d65 Use colored/styled text output for diagnostics and usage info (#1775) 2025-08-04 17:02:24 -04:00
Rangi42 d992b21141 Fix man page syntax for Flags 2025-08-03 13:22:22 -04:00
Rangi42 903492cce2 Fully support rgbasm -MC in Bash completion script 2025-08-03 13:08:36 -04:00
Rangi42 fc9b614225 Allow the index of CHARVAL to be optional
Fixes #1773
2025-08-03 08:44:06 -04:00
Rangi42 543b7fa6c2 Use std::nothrow for the only new expression
Ideally we'd use `std::make_shared`, but it has insufficient compiler
support for array types
2025-08-02 22:52:20 -04:00
Rangi42 5a7ffd19b0 Move or remove some redundant information from the README
* Move the folder structure to ARCHITECTURE.md (which can be
  expanded as per #707)

* Move the acknowledgements to CONTRIBUTORS.md

* Remove the history (it's a copy of man/rgbds.7)
2025-08-02 22:09:09 -04:00
Rangi42 7be7483571 Move more RGBASM parser action code out of the Bison file 2025-08-02 21:38:13 -04:00
Rangi42 2eeb333be0 Factor out more shared math operations between RGBASM and RGBLINK 2025-08-02 19:55:44 -04:00
Rangi42 fe8baaec50 Show contributors' avatars with contrib.rocks 2025-08-02 17:12:29 -04:00
Rangi 752b273aec Extend RGBASM and RGBLINK verbosity flags to have multiple levels like RGBGFX (#1772) 2025-08-02 17:10:10 -04:00
Rangi42 b51056f743 Fix "while expanding symbol" error message
Fixes #1771
2025-08-01 16:25:44 -04:00
Rangi42 ee1aed51d8 Use std::numbers::pi instead of nonstandard M_PI 2025-08-01 13:07:02 -04:00
Rangi42 db2cda790c Factor out a single consumeChar function
This and `peek` are the only functions that should call the low-level
`peekChar` and `peekCharAhead` methods.
2025-08-01 12:12:22 -04:00
Rangi42 86b43ea14f Fix interpolation after empty string literal 2025-07-31 15:17:11 -04:00
Rangi42 d1829ed923 Release v0.9.4 2025-07-31 07:41:49 -04:00
Rangi42 6d53bc4121 Simplify toggling of enabling/disabling expansions 2025-07-31 07:19:04 -04:00
Rangi42 32b5ef5095 Expand the test for {interpolation} after two double quotes 2025-07-31 07:08:05 -04:00
Rangi42 a36f2b3b7d Add test for {interpolation} after two double quotes
This is an edge case of how the lexer changes behavior when
reading string literals versus reading unquoted source code.
Three double quotes would begin a multi-line string literal,
but just two are still ambiguous, so it has to `peek()` to
see whether it's inside a multi-line string literal or
outside an empty regular string.
2025-07-31 03:31:16 -04:00
Rangi42 cd4be6aa07 Update test dependencies 2025-07-30 14:49:11 -04:00
Rangi42 499edaecd0 Exclude verboseOutputAssignments from LCOV coverage testing 2025-07-29 14:53:30 -04:00
Rangi 225490163e Fix RGBGFX "decanting" on "components" (color sets sharing colors) (#1768) 2025-07-29 14:52:20 -04:00
Rangi42 d388a60daa Reduce deep nesting in gfx/pal_packing.cpp 2025-07-29 14:02:51 -04:00
Rangi42 6d05de9d4d Remove a little no-longer-necessary header boilerplate 2025-07-29 11:22:31 -04:00
Rangi42 5d6e571338 Mention palette filenames in rgbgfx -c error messages 2025-07-29 06:44:33 -04:00
Rangi42 308d488833 Use UpperMap for rgblink -S scramble spec matching
This also makes invalid RGBLINK CLI options into fatal errors
like the other programs
2025-07-29 03:41:31 -04:00
Rangi42 cecbf0aa0e Add test case for some macro+interpolation behavior 2025-07-29 01:34:55 -04:00
Rangi42 d21e6669ce Unrefactor peek() to use tail recursion instead of a loop
Profiling RGBDS on building pret/pokecrystal reveals commit
cfe1f60e47 as a clear outlier
among the past few hundred commits for reducing performance
(an 8% increase on my machine from ~5 to ~5.4 seconds).
2025-07-29 00:24:51 -04:00
Rangi42 2341d1ee50 Replace platform-specific mmap with reading the entire .asm file 2025-07-28 20:50:48 -04:00
Rangi42 53949761a7 Factor out our manual std::filesystem::path.replace_extension replacement into its own function 2025-07-28 13:11:47 -04:00
Rangi42 f7eb986313 Encapsulate access to sectionList and currentSection 2025-07-28 11:47:37 -04:00
Rangi42 75aed1afd5 Factor out an UpperMap for case-insensitive matching 2025-07-28 00:00:24 -04:00
Rangi42 d16751f56a Avoid hard-coding a redundant "FATAL:" in RGBLINK 2025-07-27 20:07:53 -04:00
Rangi42 8b1a5244f7 Avoid hard-coding a redundant "FATAL:" in RGBFIX 2025-07-27 19:35:08 -04:00
Rangi42 b2747dfbd8 Factor out common usage-help code 2025-07-27 19:20:04 -04:00
Rangi42 16e16cdf51 Split up the linkerscript lexer and layout actions 2025-07-27 13:38:20 -04:00
Rangi42 a353637a90 Split RGBLINK linkerscript parser functions into their own file 2025-07-27 11:31:25 -04:00
Rangi42 f3cbfcecf4 Split RGBASM parser action functions into their own file 2025-07-26 16:20:25 -04:00
Rangi42 3bc8b1ff7c Handle unknown MBCs, since raw numeric values are accepted 2025-07-26 14:15:05 -04:00
Rangi42 aa46c79db6 Use unordered_map lookups instead of manual switches for MbcType data 2025-07-26 13:30:56 -04:00
Rangi42 92acb6e547 Implement a single nbErrors counter inside generic diagnostic code 2025-07-26 12:54:50 -04:00
Rangi42 ac632d9223 RGBFIX returns 1 if there was a -Werror before processing any files 2025-07-26 12:29:57 -04:00
Rangi 0df5b7b86d Implement warning diagnostic flags for RGBFIX (#1766)
* Implement warning diagnostic flags for RGBFIX

* `-m/--mbc-type help` prints to stdout

* Support `-m list` as well as `-m help`

* Make invalid `rgbfix -l` characters a fatal error, like other invalid CLI arguments

* Refactor fix/main.cpp into multiple files
2025-07-26 12:11:52 -04:00
Rangi42 87c10988ed Add test case for block comments after line continuations 2025-07-25 07:49:25 -04:00
Rangi42 d6a28a6259 Prefer pre-increment/decrement operators in for loops 2025-07-24 18:08:17 -04:00
Rangi42 c6d0e8de63 Improve some error messages 2025-07-24 11:19:04 -04:00
Rangi42 ded4ef4072 Avoid non-ASCII characters when not necessary 2025-07-23 21:18:21 -04:00
Rangi42 1849a35e61 Rename proto-palettes to color sets (copied from rsgbds) 2025-07-23 21:13:46 -04:00
Rangi42 18e35053fa Replace vectors with unordered_sets 2025-07-23 18:17:39 -04:00
Rangi 7e151f16c3 Factor out a single PNG-reading function to encapsulate the libpng API (#1765) 2025-07-23 15:53:33 -04:00
Rangi42 2ce4cdbff6 Reduce deep nesting some more, including larger refactors to assign.cpp 2025-07-22 19:38:49 -04:00
Rangi42 eea532ded1 Make sectionMap not extern 2025-07-21 20:20:04 -04:00
Rangi42 c83b87e0a0 Make all non-extern globals static 2025-07-21 20:14:09 -04:00
Rangi42 8d268e8a8a Initialize maxRecursionDepth with other options 2025-07-21 19:58:37 -04:00
Rangi42 ee0f311c10 Make nbErrors not extern 2025-07-21 19:49:08 -04:00
Rangi42 61730be6ce Make failedOnMissingInclude not extern 2025-07-21 19:40:01 -04:00
Rangi42 5f333d9753 More refactoring around extern variables 2025-07-21 19:22:10 -04:00
Rangi42 d1493a9f96 Group extern RGBASM variables in an Options struct 2025-07-21 19:02:21 -04:00
Rangi42 d652212857 Group extern RGBLINK variables in an Options struct, like RGBGFX 2025-07-21 18:12:40 -04:00
Rangi42 0cd60ea1e6 Use a patch_AddAssertion function instead of extern assertions 2025-07-21 17:49:41 -04:00
Rangi42 a0e23ee911 Remove unnecessary extern from nbSectionsToAssign 2025-07-21 17:27:43 -04:00
Rangi ad81c74cda Support PNG-format palette spec files (#1764) 2025-07-21 11:33:16 -04:00
Rangi42 9ef32e405c Combine two places that did REPT chain printing 2025-07-20 15:16:53 -04:00
Rangi42 89ca6a325c Increase parser test coverage 2025-07-20 13:52:29 -04:00
Rangi42 9e0e7ef9a1 Improve RGBASM test coverage 2025-07-20 13:13:45 -04:00
Rangi42 2dc948fefb Miscellaneous refactoring 2025-07-20 12:28:59 -04:00
Rangi42 e3a5290dad Restore blue-painting of macro arg expansions to prevent recursion 2025-07-20 11:53:36 -04:00
Rangi42 cfe1f60e47 Refactor peek() to use a loop instead of tail recursion 2025-07-20 11:38:26 -04:00
Rangi42 0eed237517 Refactor peeking at macro args to be like peeking at interpolations 2025-07-20 11:21:44 -04:00
Rangi42 68ffb01cac Use nextChar() for shiftChar() and then peek() 2025-07-20 11:15:06 -04:00
Rangi42 169ac61e14 Rename nextChar to bumpChar in the RGBASM lexer for symmetry with std::filebuf in the RGBLINK lexer 2025-07-20 11:02:02 -04:00
Rangi42 0681110647 Refactor peek() some more 2025-07-20 10:59:35 -04:00
Rangi42 8d1b111692 Small lexer refactors, commenting when tail recursion occurs 2025-07-20 00:14:13 -04:00
Rangi 2935942667 Allow multiple preinclude files (#1763) 2025-07-19 17:07:15 -04:00
Rangi42 9a4593e823 Reduce nesting depth some more 2025-07-19 16:18:35 -04:00
Rangi42 250e08043b Fix -W parameter parsing 2025-07-19 16:18:35 -04:00
Rangi42 14f5e16ae8 Prefer pre-inc/dec unless post-inc/dec are necessary 2025-07-19 16:18:35 -04:00
Rangi42 bf69043a1d Reduce deep nesting some more 2025-07-19 16:18:30 -04:00
Rangi42 7086b8aeff Document that -MG and -MC count READFILE 2025-07-18 20:32:08 -04:00
Rangi 53c39d01d4 Implement READFILE function (#1759) 2025-07-18 18:27:52 -04:00
Rangi42 4a2f9fc744 A little refactoring 2025-07-18 14:17:23 -04:00
Rangi42 e7d63f5f6b Refactor code that handles when included files are missing
- Single unified routine for erroring out or handling missing dependencies
- Single three-state enum instead of two Booleans for missing dependencies
  (this causes `-MC` to imply `-MG` instead of needing `-MG -MC`)
- Functions than can miss included files return a Boolean for whether the
  parser should `YYACCEPT` and exit
2025-07-18 14:03:23 -04:00
Rangi42 b80b30fba1 Ensure that INCBIN parameters are non-negative 2025-07-18 12:44:27 -04:00
Rangi42 8e84850679 Run clang-tidy with make tidy 2025-07-18 10:10:34 -04:00
Rangi42 e31256c0d4 Remove rgbasm-only -lm from Makefile 2025-07-18 08:22:40 -04:00
Rangi42 9a9fd6603c Replace test comments with assertions 2025-07-18 07:47:40 -04:00
Rangi42 e99ff5ac45 Use more concrete types instead of auto 2025-07-17 23:52:09 -04:00
Rangi42 60cec85638 Use separate caches for zlib and libpng on Windows 2022 vs 2025
Windows 2025 no longer has a D:/ drive
<https://github.com/actions/runner-images/issues/12416>
which affects where the cached files go.

This can result in one of two errors in the "Install zlib" step
after restoring from cache:

- file cannot create directory: D:/a/rgbds/rgbds/install_dir/lib.
  Maybe need administrative privileges.
- file INSTALL cannot find "C:/a/rgbds/rgbds/zbuild/Release/zlib1.dll":
  File exists.

Separate caches per OS should solve this problem.
2025-07-17 21:47:45 -04:00
Rangi42 39f2ed1339 Fix order of sentences 2025-07-17 20:14:50 -04:00
Rangi 4c8724899b Support SIZEOF(reg) to distinguish 8- and 16-bit registers (#1758) 2025-07-17 15:49:28 -04:00
Rangi 0c96234532 Use concrete types instead of auto when convenient and not redundant (#1757) 2025-07-17 14:59:51 -04:00
Rangi 9dddd87893 Run all CMake commands in bash (#1755) 2025-07-17 13:39:37 -04:00
Rangi 5eb093f13e Implement warning diagnostic flags for RGBLINK (#1754) 2025-07-17 12:54:29 -04:00
Rangi 529989bde5 Update libpng to 1.6.50 (#1750)
* Update libpng to 1.6.50

* Don't patch MinGW libpng APNG support

* Use current libpng repo URL
2025-07-16 19:00:51 -04:00
Rangi 776e37980b Add gb-starter-kit to test suite, excluding it on Windows, macOS, and BSD (#1753) 2025-07-16 18:17:01 -04:00
Rangi 7f24d46d44 Support more syntax in linkerscripts (#1752)
* No need to use `locale`s

* Implement octal numbers, `_` digit separators, and `0x/0b/0o` prefixes in linkerscripts

* Refactor some functions out of `yylex`

* Support `\0` in linkerscripts
2025-07-16 15:00:02 -04:00
Rangi42 cf6e5fec63 Fix unterminated strings in linkerscripts consuming their newline 2025-07-16 09:59:48 -04:00
Rangi42 d8fc25ee43 Add TODO comment for SDAS XL4 support 2025-07-15 22:07:11 -04:00
Rangi42 a0eccceb01 Remove unplanned TODO comments 2025-07-15 21:53:55 -04:00
Rangi42 2720224890 Refactor parsing of ld hl, sp + e8 2025-07-15 21:52:22 -04:00
Rangi42 8bebab1db0 Abbreviate RGBLINK errput that includes a src+lineNo 2025-07-15 18:37:28 -04:00
Rangi42 ee29579d3e Reduce some more deep nesting 2025-07-15 17:41:32 -04:00
Rangi42 5aec36350b Document more deprecated/removed features
Fixes #1748
2025-07-15 16:32:03 -04:00
Rangi 1fecf80659 Implement 'character' literals (#1747) 2025-07-15 13:08:50 -04:00
Rangi b6d77fbb9e Implement BYTELEN and STRBYTE (#1744) 2025-07-14 21:46:35 -04:00
Rangi 8a19c5c30a Fix string function behavior with NUL characters (#1746) 2025-07-14 21:43:32 -04:00
Rangi42 0149122cd0 Note how to print lexed token names for future reference 2025-07-14 10:25:47 -04:00
Rangi42 35335aadbe Add test for labels when expecting symbols 2025-07-14 00:10:14 -04:00
Rangi42 80df858ee3 Clarify comment 2025-07-14 00:02:25 -04:00
Rangi42 eafc32fd68 Simplify switch with one case to if 2025-07-13 23:48:01 -04:00
Rangi42 2adeda0318 Use std::tie for sort comparator functions 2025-07-13 14:47:10 -04:00
Rangi42 21a6d35b8b Simplify readString 2025-07-13 13:26:59 -04:00
Rangi42 ce78280af3 Simplify appendCharInLiteral 2025-07-13 13:22:40 -04:00
Rangi42 041b86b8dd Use Defer instead of relying on a "Don't return before this" comment 2025-07-13 12:52:45 -04:00
Rangi 611b0041c4 Exclude Bison-generated files from coverage report, and use dark theme (#1742) 2025-07-12 10:11:23 -04:00
Rangi42 ddb2acb652 Reduce more nesting depth, and fix an error message 2025-07-12 08:17:26 -04:00
Rangi42 da133baf17 Reduce nesting depth in lexer.cpp 2025-07-12 07:54:16 -04:00
Rangi42 d32b1912ed Use verbosePrint in rgbasm as well as rgblink 2025-07-12 01:38:19 -04:00
Rangi42 82513e5255 Simplify appendCharInLiteral 2025-07-11 23:52:52 -04:00
Rangi42 f2708ce967 Consolidate readString and appendStringLiteral 2025-07-11 23:43:36 -04:00
Rangi42 01a5c94c7e Factor out common code from readString and appendStringLiteral 2025-07-11 22:37:28 -04:00
Rangi42 e7a05b1db8 Refactor for better formatting 2025-07-11 10:59:03 -04:00
Rangi 510a4aa99d Add RGBASM -MC flag to continue -MG after missing dependency files (#1687) 2025-07-10 13:25:36 -04:00
Rangi 3f4e8396aa Implement warning diagnostic flags for RGBGFX (#1738) 2025-07-10 09:58:40 -04:00
Rangi42 276a200590 A few miscellaneous edits 2025-07-10 00:33:03 -04:00
Rangi a40109e4e4 Update the UTF-8 decoder (#1741) 2025-07-09 23:13:30 -04:00
Rangi 34cf959c9d Refactor to reduce nesting depth some more (#1740) 2025-07-09 22:46:40 -04:00
Rangi42 bf6875f160 Reduce nesting depth in diagnostics.cpp 2025-07-09 19:37:55 -04:00
Rangi 44f5b47bf0 Reduce nesting depth in some functions (#1739) 2025-07-09 16:20:33 -04:00
Rangi 41ab5dff5a Implement [[ fragment literals ]] (#1614)
This feature is referred to as "code/data literals" in ASMotor,
and simply as "literals" in some older assemblers like MIDAS
for the PDP-10. RGBASM already had the "section fragments"
feature for keeping disparate contents together when linked,
so these worked naturally as "fragment literals".
2025-07-09 12:13:01 -04:00
Rangi 5e43ece578 Remove errx and errors.hpp (#1737) 2025-07-09 11:04:23 -04:00
Rangi 9acba4b412 Generate a coverage report in CI (#1736) 2025-07-08 21:39:11 -04:00
Rangi42 8c50839109 Miscellaneous updates 2025-07-08 17:45:13 -04:00
Rangi42 6736d2ec66 Ignore errors to allow lcov 2.3 to work 2025-07-08 17:02:28 -04:00
Rangi 6869e4807c Make file.hpp independent of gfx (#1733) 2025-07-08 15:16:16 -04:00
Rangi 5de05e2e4b Replace DefaultInitVec with std::vector (#1732) 2025-07-08 14:55:28 -04:00
Rangi fda54fd0c3 Replace Either with std::variant (#1731) 2025-07-08 13:59:03 -04:00
Rangi 35962dedc4 Refactor warnings and errors (#1728)
* Remove `err` and `warn`, keep `errx` and `warnx`, using them in RGBGFX too

* Separate RGBGFX and RGBLINK warnings/errors from main options

* Separate `report` function into `error` and `fatal` messages

* Implicit newlines for most RGBASM errors
2025-07-08 12:58:23 -04:00
Rangi 991b74dd0d Fix segfault with invalid RGBLINK scramble spec (#1730) 2025-07-08 12:34:54 -04:00
Rangi 1a77667409 Fix UBSan error with overflowing exponent operator (#1727) 2025-07-07 19:08:26 -04:00
Rangi c9765ec158 Factor out program-independent warning diagnostic code (#1725) 2025-07-07 18:34:34 -04:00
Rangi42 202c91471c Fix alignment compatibility with current lower alignment 2025-07-07 22:43:19 +02:00
Rangi e14f68d1d7 Improve error message for align failure (#1721) 2025-07-06 08:36:11 -04:00
Rangi42 185a3b29e6 Implement base palette ID 2025-07-06 12:57:20 +02:00
Rangi42 d7b1569ee6 Document % changing from remainder to modulo in 0.5.0 2025-07-04 23:02:45 +02:00
Rangi42 468f1cd912 "The windows-2019 runner image is being deprecated" 2025-07-02 19:43:11 +02:00
Rangi42 965288de38 Fix out-of-bounds image slices 2025-07-02 19:43:11 +02:00
Antonio Vivace 008920f533 ci: tag rgbds:latest before pushing it 2025-07-01 01:29:57 +02:00
Rangi42 20ed6a52ee Clarify release procedure checklist 2025-06-30 15:52:42 -04:00
Rangi42 8b85875b67 Release v0.9.3 2025-06-30 15:08:04 -04:00
Rangi 7054d81650 Implement grayscale DMG palette specs (#1709) 2025-06-30 14:53:05 -04:00
Rangi 5942117ac3 Avoid generating phony dependencies for files that don't exist (#1708) 2025-06-29 16:42:24 -04:00
Rangi42 e7a3b9d90e Format rgbgfx -vvvvvv string visually 2025-06-21 14:16:48 -04:00
Rangi b13d623ad4 Encode reversed PNG images as grayscale or indexed when possible (#1703) 2025-06-19 09:48:27 -04:00
Rangi 37bf9fae01 Only define parse.lac for Bison 3.5 or greater (#1702) 2025-06-14 17:01:16 -04:00
Rangi42 612cf3b7dd Fix some formatting 2025-06-12 17:27:08 -04:00
Rangi 089e366ddc Implement CHARVAL function (#1701) 2025-06-12 17:21:12 -04:00
Rangi fa9e29e4ce Implement ++ operator for string concatenation (#1698) 2025-06-12 22:52:00 +02:00
Antonio Vivace fa3d83a3d1 ci container build: when pushing a version-tagged build, overwrite 'latest' as well 2025-06-08 18:21:58 +02:00
Rangi 804db4e073 Handle missing newline at EOF for linkerscript INCLUDEd files (#1691) 2025-05-22 10:55:58 +02:00
Rangi 5d998ef483 Restrict custom binary and graphics digits (#1693)
* Restrict custom binary and graphics digits

* Update documentation

* Fix build error
2025-05-22 10:52:51 +02:00
Rangi 126b1e5726 Reuse startsIdentifier and continuesIdentifier functions (#1695) 2025-05-19 15:31:26 -04:00
Rangi 4f2400c15b Hint to {interpolate} names when EQUS expanding does not occur (#1692) 2025-05-18 17:53:34 +02:00
Antonio Vivace 063d284cbf Dockerfile: explain commands 2025-05-16 18:48:08 +02:00
Antonio Vivace 205bf5a11d Dockerfile: install the compiled tools after the compilation (#1690) 2025-05-16 18:48:08 +02:00
Rangi 41c94aa448 Omit the version number from distrbuted release archive filenames (#1685) 2025-05-06 13:28:54 +02:00
Rangi d413870e6d .sym file sorting accounts for local labels' parents' addresses and names (#1684) 2025-05-05 13:57:25 -04:00
Rangi e95ac6fb06 Recover from errors even inside REPT/FOR loops (#1683) 2025-05-04 17:51:53 -04:00
Rangi e1ae92709c Fix STRSLICE with no stop index argument (#1682) 2025-05-04 16:56:25 -04:00
Rangi42 1715f85d50 Release v0.9.2 2025-05-04 10:04:11 -04:00
Rangi42 c2de0a991a Update test dependency 2025-05-03 12:43:57 -04:00
Rangi 2e6e1ccf06 Show specific messages for some more invalid instructions, not just "syntax error" (#1679) 2025-05-03 12:31:00 -04:00
Rangi42 081f48404c Remove a TODO comment about overlapping proto-palettes
The original algorithm makes a simplifying assumption that one
proto-palette does not fully contain another, and we have no
particular reason to violate this condition.
2025-05-03 10:19:33 -04:00
Rangi42 bdac0ce053 Remove unplanned TODO comments in src/gfx/pal_spec.cpp
ACT palette files support a transparent color index, but RGBGFX
cannot apply *one* such transparent color; it would need every
palette's first color to be transparent. Also ACT files tend to
say the first color is transparent anyway, which the user may
not have intended.

ACO palette files can specify version 2 color data, but it's
required to come after version 1 data, and the colors themselves
already exist in the earlier v1 data; v2 just adds UTF-16 names.

Thus, we do not need to be handling these data in those formats.
2025-05-02 21:29:14 -04:00
Rangi 122d91509f Clear some more TODO comments (#1677) 2025-05-02 21:06:34 -04:00
Rangi 7c6f778ae7 Take care of miscellaneous commented TODOs (#1676) 2025-05-02 16:44:12 -04:00
Eldred HabertandRangi42 8cf6c5423a Implement --background-color (#1508)
Co-authored-by: Rangi42 <[email protected]>
2025-05-01 23:39:52 -04:00
Rangi 56f7222230 Don't output anonymous labels in map files (#1674) 2025-05-01 19:19:25 +02:00
Rangi e45b9625ca Group sequences of garbage characters (#1672) 2025-04-30 23:31:41 -04:00
Rangi42 e0a8eb8aff Update test dependencies 2025-04-24 09:52:08 -04:00
RangiandEldred Habert 2a5b9b5f98 Fix two RGBGFX bugs (#1671)
* Fix two RGBGFX bugs

* Fix clang-format idempotence

* Update src/gfx/rgba.cpp

Co-authored-by: Eldred Habert <[email protected]>

---------

Co-authored-by: Eldred Habert <[email protected]>
2025-04-24 15:39:14 +02:00
Rangi42 a72843748f Avoid using indirect C++ types 2025-04-23 00:53:20 -04:00
Rangi42 762e2311d2 Add test case for FOR loop variable reusing an existing one 2025-04-22 15:10:50 -04:00
Rangi 0b7cda9e0c Allow negative values to count macro arguments from the end (#1670) 2025-04-20 00:37:50 -04:00
Rangi42 df83bc31d2 Consistently use PRId* not PRIi* 2025-04-19 23:44:34 -04:00
John Millikin bc8d99d915 Add -o / --output option to rgbfix to write separate output files (#1666) 2025-04-19 23:17:11 -04:00
Rangi42 c841672059 Don't use tabs for alignment 2025-03-31 19:13:46 -04:00
Rangi42 75b605797d Fix rgblink(5) man page syntax error
Copied from https://salsa.debian.org/twolife/rgbds/-/blob/640a5293/debian/patches/groff.patch
2025-03-07 10:37:20 -05:00
Rangi42 00d0ae840d Avoid use of goto in nextLine 2025-02-27 14:28:17 -05:00
Rangi42 2cdbb145da Avoid use of goto in shiftChar 2025-02-27 14:17:01 -05:00
Rangi42 d8192560b0 Avoid use of goto in FormatSpec::useCharacter 2025-02-27 13:45:13 -05:00
Rangi42 9b395f3bf1 Fix double negative 2025-02-23 13:36:55 -05:00
Rangi 0150eb4bf3 Exclude more lines from test coverage (#1663)
These fall into a few categories:
- `_unreachable()`
- Verbose print messages
- Errors that should never practically occur (alloc/read/write failure,
  more than UINT32_MAX anonymous labels, etc)
2025-02-17 04:56:10 -05:00
Rangi 632342b254 Use LCOV_EXCL comments to exclude some lines from test coverage (#1662) 2025-02-16 13:56:55 -05:00
Rangi c9060c7f2d Increase test coverage (#1661) 2025-02-16 09:29:16 -05:00
Rangi 993879a2ed Derive operator!= from operator== (#1660) 2025-02-15 12:37:42 +01:00
Rangi 62309d5c87 Define operator!= in terms of operator== (#1659) 2025-02-15 11:34:06 +01:00
Rangi b2e865ee2a Disable EQUS expansion for raw symbols (by parsing them as strings) (#1648) 2025-02-15 10:44:51 +01:00
Rangi 3feb75f84f Implement new string functions (#1655)
`STRFIND`, `STRRFIND`, `STRCHAR`, `STRSLICE`, `CHARCMP`, `CHARSIZE`, and `REVCHAR`
2025-02-14 23:09:45 +01:00
Rangi42 ad4d9da4cf Remove unnecessary default constructor definitions 2025-02-14 18:58:34 +01:00
Rangi42 1489854932 Use more const references when possible 2025-02-14 18:58:34 +01:00
Rangi 2aef09c8d9 Allow the bit/res/set bit index to be determined at link time (#1654)
This increments the object file revision number from 11 to 12
since it adds a new `RPN_BIT_INDEX` command.
2025-02-12 17:14:10 +01:00
Rangi42 48412e9c56 Some miscellaneous refactoring and copy-editing 2025-02-10 16:51:51 +01:00
Rangi 177a3abfac Fix bug where macro names can be treated as numeric symbols (#1653) 2025-02-08 23:03:21 +01:00
Rangi 4c916b8da8 Parser refers to "symbol"s, "label"s, and "local label"s, not "identifier"s (#1652)
This better matches how the lexed tokens are discussed in rgbasm(5)
2025-02-06 18:01:33 +01:00
Rangi42 d9d381cb62 Refactor the parser to have fewer *_no_str intermediate rules 2025-02-04 18:59:11 +01:00
Rangi fbde24ee17 Add contrib/checkformat.bash to check for clang-formatting (#1646) 2025-02-04 10:40:38 +01:00
Rangi 91310c9eb6 Update the post-release checklist to mention rgbds-live (#1647) 2025-02-04 09:59:03 +01:00
Rangi42 81ea4ee920 Release 0.9.1 2025-02-02 20:16:54 +01:00
Rangi 29ece2940d Mention ASMotor's continued development (#1643) 2025-02-01 21:39:19 +01:00
Rangi 03452c6d4f Allow git describe to get the version for FreeBSD and Cygwin in CI (#1640)
* Specify `safe.directory`
* Fetch tags
* Fetch all commits
2025-01-29 19:57:15 -05:00
Rangi b35e9d86fb Remove redundant @-style doc comment tags (#1641) 2025-01-29 19:56:28 -05:00
Rangi e20347e38c Add more RGBLINK tests (#1639) 2025-01-29 12:53:44 -05:00
Rangi f61019dd68 Add more RGBLINK test coverage (#1637) 2025-01-29 11:41:08 -05:00
Rangi c19ddc80f0 Fix failing assertion with backslash at EOF in macro arguments (#1634)
`Expansion::advance()` can increase its offset beyond the size,
so I don't think this assumption was valid in the first place;
`BufferedContent::advance()` should be able to as well.
2025-01-28 21:51:11 -05:00
Rangi a59867cd78 Consistently use LF line endings in expected .out and .err output (#1635)
Test scripts compare files as text
2025-01-28 21:24:40 -05:00
Rangi 375adc6804 Fix STRLEN and STRSUB on incomplete UTF-8 (#1633) 2025-01-28 13:13:35 -05:00
Rangi 44caffe04a Fix CHARLEN and CHARSUB on invalid UTF-8 (#1630) 2025-01-28 02:01:18 -05:00
Rangi42 d54619a453 Remove colNo column tracking from lexer
This was added as part of 71f88717 just for debug and fstack trace
output, but we no longer output it anyway.
2025-01-28 01:12:18 -05:00
Rangi42 e49291b7cf Refactor readUTF8Char into charmap_ConvertNext 2025-01-28 00:07:08 -05:00
Rangi42 34a9c8e083 Add some more string test cases 2025-01-28 00:02:25 -05:00
Rangi42 c4b456b166 Remove unused fix_PrecisionFactor function 2025-01-27 23:04:11 -05:00
Rangi42 79401cce8b Add braces inside #define macro bodies 2025-01-27 20:12:12 -05:00
Rangi42 4e44958d26 Add braces to Bison .y files 2025-01-27 20:12:12 -05:00
Rangi42 cae31005f8 Always use braces with InsertBraces: true in .clang-format 2025-01-27 20:12:12 -05:00
Rangi42 25c9f8f383 Add more rules to .clang-format 2025-01-27 20:12:12 -05:00
Rangi42 01c9106b59 Include windows.h before other Win32 header files 2025-01-27 20:12:12 -05:00
Rangi42 192fc808c8 Run clang-format on some Bison .y file contents 2025-01-27 20:12:12 -05:00
Rangi42 9c8e327ae2 Zero-initialize trimmedTile array 2025-01-27 20:12:12 -05:00
Rangi42 9ebd2a7e8e Fix clang-format of sectionTypeInfo array 2025-01-27 20:12:12 -05:00
Rangi42 b8b60207f5 Use // line comments not /* block comments 2025-01-27 20:12:12 -05:00
Rangi42 c5e59f40fd Get rid of unnecessary extern "C" blocks 2025-01-27 20:12:12 -05:00
Rangi42 a354af3d08 Reformat source files with clang-format 19.1.7 2025-01-27 20:12:12 -05:00
Rangi 20c18256ed Avoid errors after missing INCLUDE with -MG (#1627) 2025-01-25 12:38:17 -05:00
Rangi42 890528812e Prefer C++ constructs to C-style sizeof-based macros 2025-01-24 18:56:41 -05:00
Rangi42 84f59e14ed Rename Z80 prefix to SM83 2025-01-24 12:11:46 -05:00
Rangi42 91d7ce5e09 Add test case for expansions changing context 2025-01-21 21:47:22 -05:00
Rangi d9654b752f Support -h/--help for all programs (#1620) 2025-01-21 21:24:17 -05:00
Rangi42 157826bf82 Support fetch-test-deps.sh --get-deps debian
Also use `apt-get` instead of `pip` to install
Pillow for libbet
2025-01-21 14:40:09 -05:00
Rangi42 a5e36f924f Update help and error messages in run-tests.sh 2025-01-21 14:10:36 -05:00
robbi-blechdose 82f7bdb480 Allow running external tests against installed rgbds (#1621) 2025-01-21 13:43:31 -05:00
Rangi42 056190413e Add test to cover RGBLINK behavior for patch overflow 2025-01-20 14:42:58 -05:00
Rangi c2db23aef0 Run internal tests in FreeBSD (#1616) 2025-01-20 14:08:48 -05:00
Rangi 2426068409 Undeprecate ld [$ff00+c] (#1619) 2025-01-20 14:05:15 -05:00
Rangi 147a5c9bf3 Document more obsolete syntax (#1618) 2025-01-18 23:50:20 -05:00
Rangi 6ae3f040b8 Correct the DAA documentation (#1617) 2025-01-17 23:04:03 -05:00
Rangi e561f63db3 Run internal tests in Cygwin (#1592) 2025-01-17 18:31:37 -05:00
Rangi af9de812ec Update libpng to 1.6.45 (#1615) 2025-01-17 14:41:38 -05:00
Rangi42 edc9e07a2d Move all common error checks together inside mergeSections 2025-01-17 02:18:40 -05:00
Rangi 382ad17969 Don't output sections in reverse order (#1613) 2025-01-17 01:28:17 -05:00
Rangi42 fac5e35d24 Prefer empty braces to semicolons for empty loop bodies 2025-01-17 00:20:33 -05:00
Rangi42 a85d6b3b57 Remove unused readMagic function 2025-01-17 00:09:47 -05:00
Rangi42 f23a14afc7 Remove unnecessary semicolons after closing braces 2025-01-17 00:01:06 -05:00
Rangi42 f63167dd0f Use const reference 2025-01-16 23:45:43 -05:00
Rangi42 0ee4ba95b3 Replace old-style cast in Windows-only code with static_cast 2025-01-16 23:41:12 -05:00
Rangi 727c1f5b50 Update Dockerfile to use Debian 12 slim (#1599) 2025-01-04 14:54:30 -05:00
Rangi d829fd2ffe Remove the 99999 macro arg limit (#1597) 2025-01-04 04:04:12 -05:00
Rangi b13c0f2f8e Use a constant for 0x8001 (#1596) 2025-01-04 04:03:40 -05:00
Rangi42 d9773424e4 RGBDS_OBJECT_VERSION_STRING is a literal 2025-01-04 03:53:59 -05:00
Rangi42 4e2464a69d Replace some #define with constexpr 2025-01-04 03:53:59 -05:00
Rangi42 a5f12f66bb Define the default -recursion depth in main.cpp with other default values 2025-01-04 03:53:59 -05:00
Rangi 73ad431b8d Fix the node type for "file" nodes in object files (#1593) 2025-01-03 17:20:06 +01:00
Rangi42 d88feee1c0 Update test dependencies 2024-12-31 13:07:46 -05:00
Rangi42 5963dc9e0e Only define __asan_default_options in make develop builds
`NDEBUG` is not defined in `develop`, `debug`, `profile`, and `coverage`
builds.
`__SANITIZE_ADDRESS__` is defined in `develop` builds.
2024-12-31 11:01:26 -05:00
Rangi 8363f25d47 Enable more sanitizers in make develop (#1588)
- `-fsanitize=undefined` encompasses multiple checks we were specifying

- "detect_leaks=1" for `__asan_default_options` checks for memory leaks
  (except for with macOS clang++, which does not support LSan)

- `-fsanitize=float-divide-by-zero` is an extra UBSan check
  (and reveals a UB bug to fix with fixed-point `DIV` and `LOG`)
2024-12-31 10:02:20 +01:00
Rangi 72b2a4d7c0 Use if constexpr to guarantee compile-time simplification (#1590) 2024-12-30 23:44:12 -05:00
Rangi 06daf2a9b5 Include <signal.h> in rgbgfx_test.cpp (#1589) 2024-12-30 23:22:14 +01:00
Rangi ad95d2e06f Allow deduplicating tiles with neither an input nor output tileset (#1585) 2024-12-30 18:58:07 +01:00
Rangi 5197e6b79f Run gcc static analysis in CI (#1587) 2024-12-30 09:57:41 -05:00
Rangi42 b99ce3845e Fix RGBFIX writing bytes when one syscall is not sufficient 2024-12-30 11:25:20 +01:00
Rangi42 d63955eccd Release 0.9.0 2024-12-25 10:46:17 -05:00
Rangi42 2c4fc4cbe8 Update man page dates 2024-12-25 10:37:08 -05:00
Rangi42 7d3c31b6d8 Update CI test project commits
Note that libbet's latest commit updated some text, so its ROM hash changed
2024-12-25 10:29:06 -05:00
Rangi42 151f83db6d Using C++20 [[unlikely]] here would be excessive micro-optimization 2024-12-23 14:14:10 -05:00
Rangi42 22838ce2d8 Remove redundant 0xC7 masking for RST values (the parser handles it) 2024-12-23 10:10:01 -05:00
Rangi42 b058bb6e15 Sorting RGB palettes by luminance is not a "legacy" feature 2024-12-23 10:01:30 -05:00
Rangi42 36b04b5dea Rename parser value const to iconst to distinguish it from C++ keyword 2024-12-23 09:21:30 -05:00
Rangi42 a7296ecb31 Fix man page formatting 2024-12-21 00:44:33 -05:00
Rangi42 92917ceb2f List LDHL as an unsupported instruction alias 2024-12-13 11:35:59 +01:00
Sylvie c1c5b10082 Deprecate LDH with $00-$FF (#1575) 2024-12-10 21:27:37 -05:00
Sylvie f44de0c7ae Deprecate LD with [C] (#1574) 2024-12-10 21:13:09 -05:00
Rangi42 b18cfe6bdb Consistently use UINT32_MAX, not -1, for uint32_t values 2024-12-10 19:47:23 -05:00
Rangi42 a8ec9228d4 List post-release steps to take for other gbdev projects 2024-12-10 13:06:58 -05:00
Sylvie c1b85554a8 Document obsolete syntax in rgbasm-old(5) (#1571) 2024-12-10 12:34:37 -05:00
Sylvie b877c81c32 Use C++-style casts (#1576) 2024-12-09 21:56:54 -05:00
Rangi42 e66da4c8c7 Consistently capitalize C 2024-12-09 13:42:01 -05:00
Sylvie 573e044b30 Deprecate LDIO (#1567)
* Deprecate `LDIO`

* `ld [$ff00+n8], a` is not treated as `ldh [n8], a`
2024-12-05 12:49:13 -05:00
Rangi42 ceb43c7aa4 Remove sample comments in workflow 2024-12-04 15:38:49 -05:00
Antonio Vivace eae1ecb77e ci: re-trigger build-container.yml with fine-grained PAT 2024-12-04 19:05:10 +01:00
Antonio Vivace c4de6c402b ci: clean up untagged artifacts 2024-12-04 18:57:43 +01:00
Sylvie 0b147c9386 Fix ** right-associativity, and clarify docs (#1566) 2024-12-03 20:40:50 -05:00
Sylvie 6982c8a116 Improve the instruction documentation (#1561) 2024-12-02 15:41:57 -05:00
Eldred Habert d5f39c8dce Remove the use of floating-point for palette packing (#1565)
This is primarily a correctness change, *not* a performance one.
The expected performance impact is minimal anyway.

The goal is to eliminate the use of platform-inconsistent floating-point operations
for this load-bearing task.
2024-11-29 13:44:19 -05:00
Sylvie a5d18d62df Explain the DAA instruction algorithm (#1564) 2024-11-29 10:42:34 -05:00
Rangi42 a27f704c25 Implement -Wunmatched-directive 2024-11-28 20:30:38 +01:00
Rangi42 9216485bca Add TRACE-level verbose logging for efficiency calculations 2024-11-27 21:06:18 +01:00
Rangi42 c33acb905b Avoid precision loss from floating-point division in calculating efficiency
This was breaking test results on 32-bit MinGW
2024-11-27 21:06:18 +01:00
Rangi42 81c3521610 Add color_curve RGBGFX test 2024-11-27 21:06:18 +01:00
Sylvie e0ee9dc3ad Add reverse_1bit RGBGFX test (#1555)
Fixes a bug to always use 2bpp `_data` in `TileData`
2024-11-24 19:30:49 -05:00
Rangi42 cb546f0cd8 Fix rgbasm(1) formatting 2024-11-08 22:29:52 -05:00
Rangi42 a60186db2f Document the RGBGFX -X and -Y options 2024-11-03 18:54:16 +01:00
Antonio Vivace d9f87a5721 contributing: add paragraph regarding the container image 2024-10-29 00:43:48 +01:00
Sylvie a7fdb2c3d3 Add more RGBGFX test coverage (#1553) 2024-10-27 11:32:21 -04:00
Sylvie 5efd303b7f Allow LOAD FRAGMENT (#1552)
This was implemented in #736 but removed after discussion in #869.

Fixes #1537
2024-10-24 19:45:44 -04:00
Rangi42 0d3980d039 Refactor how map file sections are printed
This makes size-0 sections print as "($0000 bytes)" instead of
"(0 bytes)", which is more consistent.
2024-10-23 17:10:39 +02:00
Rangi42 ab6244d81c Escape characters in section names in map files 2024-10-23 17:10:39 +02:00
Sylvie 7fcf4ba60f Correctly recover from syntax errors at the first token of a line (#1549) 2024-10-22 21:01:44 +02:00
Sylvie f048cbbb11 Clean up some man pages (#1547) 2024-10-22 13:07:09 -04:00
Rangi42 4c495c31d9 Release 0.9.0-rc2 2024-10-21 22:52:18 -04:00
Sylvie 90286ccbbc Fix detection of tiles with too many colors (#1546) 2024-10-20 13:51:39 -04:00
Sylvie b33aa31944 LOAD FRAGMENT is not allowed (#1536) 2024-10-17 14:42:19 -04:00
Quinn dd6c741143 Swap manpage descriptions of HIGH(n) and LOW(n) (#1545) 2024-10-16 21:10:50 +02:00
Sylvie 3b3263273c Make ENDL optional like ENDSECTION (#1538)
Add warning for `LOAD` without `ENDL`
2024-10-15 21:13:50 -04:00
Sylvie bc5a71ff88 Update some RGBLINK error messages (#1544) 2024-10-16 01:42:49 +02:00
JL2210 e623aeb85d Make tests work with CTest (#1539)
Adds option to disable non-free tests
2024-10-15 19:26:17 -04:00
Sylvie a2ff653a83 Fix nested undefined interpolation segfault (#1542) 2024-10-16 00:09:47 +02:00
Sylvie a13723c523 Implement 0x/0o/0b number prefixes (#1533) 2024-10-08 15:56:00 -04:00
Sylvie cf85146353 Refactoring and enhancements to RGBASM warnings (#1526)
* Allow a `no-` prefix to negate "meta" warnings
  (`-Wno-all`, `-Wno-extra`, `-Wno-everything`)
* Allow `-Wno-error=...` to override `-Werror`
  (including for "meta" warnings)
2024-10-04 21:52:40 +02:00
Rangi42 a9e49a09fd Allow tab character after backslash line continuation 2024-10-01 22:41:55 -04:00
Antonio Vivace cbe44fed9b ci: run only the "build tagged container image" step on tag pushes 2024-10-02 00:57:44 +02:00
Antonio Vivace c439b8e27f ci: add descriptions to built container images 2024-10-01 22:57:30 +02:00
ISSOtm 86bf289452 Process the last line of textual palette specs even without a trailing newline
Fixes #1519
2024-09-30 22:26:00 +02:00
Rangi42 e1ac7f389d Correct some documentation of RGBASM warnings 2024-09-30 15:58:09 -04:00
Sylvie d5159f66be -Wall enables -Wcharmap-redef, and document -Wnested-comment (#1528) 2024-09-30 14:34:58 -04:00
Rangi42 c7a029a051 Remove duplicated condition check 2024-09-30 10:47:57 -04:00
Sylvie d5ded84501 Move definition of _POSIX_C_SOURCE to include/platform.hpp (#1524) 2024-09-29 23:53:15 +02:00
Sylvie 4cd0dd5314 Use setmode instead of fdopen (#1520) 2024-09-29 14:06:59 -04:00
Sylvie 9783671399 Simplify some C++ abstractions (#1518)
* Remove namespaces
* Prefer `bool operator==`, not `friend auto operator==`
* Prefer not to use `using`
* Use a `constexpr` function instead of a template for `flipTable`
2024-09-26 00:07:27 -04:00
Rangi42 8037b9e10a Run clang-format 2024-09-25 13:15:58 -04:00
Rangi42 7c74653aa1 Fix swapped warning comments 2024-09-25 11:25:03 -04:00
Sylvie 22767e36e2 Refer to "end of line", not "newline" (#1517) 2024-09-23 02:15:02 +02:00
Sylvie 6b89938da7 Avoid treating labels and macros differently in column 1 (#1515)
Fixes #1512
2024-09-23 01:26:25 +02:00
Sylvie 15919e550f Add test to demonstrate lack of expansions in skipIfBlock (#1516) 2024-09-22 15:31:12 -04:00
Antonio Vivace f93587c805 ci: give packages/write permission to build container image action 2024-09-22 01:14:44 +02:00
Antonio Vivace a870f7de10 ci: tag release container images 2024-09-22 01:06:33 +02:00
Antonio Vivace 6b72067387 ci: add explicit write permission to the build container image job 2024-09-22 01:05:22 +02:00
Sylvie 84c01f064f Refactor some workflows for consistency (#1510) 2024-09-21 11:12:09 -04:00
Rangi42 5d3e96662e Only publish container for gbdev 2024-09-21 10:06:23 -04:00
Rangi42 91580043e0 Use latest docker/login-action 2024-09-21 09:59:28 -04:00
Antonio Vivace 3e28e92622 ci: build "master" container image and publish it to ghcr on every push 2024-09-20 16:49:25 +02:00
ISSOtm d494f73825 Document extra pre-release updates 2024-09-18 19:38:03 +02:00
Rangi42 b03a5b13b7 Clarify when to manually publish prerelease docs 2024-09-18 12:40:08 -04:00
Eldred Habert 37b64ca51f Give release workflow permission to create a release 2024-09-18 17:00:30 +02:00
ISSOtm deb3ac3452 Update release instructions 2024-09-18 16:47:10 +02:00
Rangi42 dd20012e88 Release 0.9.0-rc1 2024-09-18 10:15:38 -04:00
Rangi42 91fbece1ad Update man page and license copyright dates 2024-09-18 10:01:39 -04:00
Rangi42 0597ff82e3 Update test dependencies 2024-09-18 09:59:00 -04:00
Sylvie 9ef2e43bf7 Track local label scope, string equated as .. (#1504) 2024-09-18 09:52:30 -04:00
Sylvie 197f6cb0ba No need for .c_str() with keywordDict lookups (#1505) 2024-09-18 12:23:05 +02:00
Rangi42 9b3d19c3f2 Prefer snprintf to sprintf
This also simplifies advancing `ptr`
2024-09-15 00:01:09 -04:00
Rangi42 02439b18c0 \# will always be defined inside macros
This lets the case structure here match the other branches
2024-09-15 00:00:00 -04:00
Sylvie 122ef95d9c Implement . string constant for the current label scope (#1499) 2024-09-13 21:20:01 +02:00
Sylvie bfb96b038d Make error messages for "undefined" built-ins more accurate (#1501) 2024-09-11 17:54:23 +02:00
Rangi42 1adf68d018 Refer to "label scope", not "symbol scope" 2024-09-10 21:38:50 +02:00
Rangi42 750e69c5a6 More asserts like the one in addLabel 2024-09-10 21:38:50 +02:00
Rangi42 6e83a14143 Consistently handle auto-scoping of local symbols 2024-09-10 21:38:50 +02:00
Rangi42 cff05435ad Remove redundant and sometimes inaccurate comments 2024-09-10 21:38:50 +02:00
Rangi42 3b59e8963e Rename variables to avoid C++ reserved "_[A-Z]" prefix 2024-09-10 21:38:50 +02:00
Rangi42 56af572bfd Refactor symbol value getters for less redundancy 2024-09-10 21:38:50 +02:00
Rangi42 6bc2446966 Rephrase error messages for consistency 2024-09-10 21:38:50 +02:00
Rangi42 155e7287db Store a pointer to the scoped label, not just its name 2024-09-10 21:38:50 +02:00
Sylvie 1dcc000572 Report locations for RGBLINK errors with conflicting objects (#1494)
This requires updating the object file format to record the
fstack context for sections themselves, not just for patches.
2024-09-10 19:23:48 +02:00
Rangi42 8cd0e66297 Revert "Implement INCLUDE_ONCE directive (#1481)"
This reverts commit 5f07095f6d.
2024-09-08 11:30:31 -04:00
sukus 5f07095f6d Implement INCLUDE_ONCE directive (#1481)
Identify files by (device, inode), not by path, so that symlinks,
relative paths, case-insensitive paths, or other edge cases
do not result in double includes.
2024-09-08 00:02:02 -04:00
Rangi42 11f0e88b30 Factor out common sanity checks for section union and fragment 2024-09-06 21:55:28 -04:00
Rangi42 d917df406d Use camelCase instead of lowercase for static functions 2024-09-06 21:48:57 -04:00
Sylvie 323028d9f2 RGBLINK lists local symbols when encountering an unknown symbol reference (#1496) 2024-09-06 21:31:13 -04:00
Rangi42 7960a10228 These extensions should be binary 2024-09-06 21:35:17 +02:00
Rangi42 068ad93427 Allow syntax cpl a 2024-09-06 21:35:17 +02:00
ISSOtm 610f04beeb Fix condition for assuming at EOF
Part of that condition's purpose is to ensure that we read the correct
lexer state; but it's possible now for the fstack to be non-empty
*before* the lexer state is registered, i.e. if there is an error
in the function that registers it.
This causes a NULL pointer deref.
2024-09-05 17:48:52 +02:00
ISSOtm e289387b09 Avoid attempting to link if assembling fails 2024-09-05 17:19:05 +02:00
Eldred Habert 80d37f9988 Implement --input-tileset (#1464)
As discussed in https://github.com/gbdev/rgbds/issues/575#issuecomment-1991456862
2024-09-04 15:20:01 -04:00
Sylvie 1283b0b6a6 Allow dollar signs in identifiers (#1493) 2024-09-03 23:09:06 +02:00
Rangi42 a098213053 Rearrange switches so default cases are last 2024-09-01 13:00:04 -04:00
Sylvie 6b8d33529e Improve string/interpolation formatting (#1491)
- The '#' component for type 's' now escapes the string characters
- The '#' component for type 'f' now prints a precision suffix
- The new 'q' component specifies a precision value
2024-09-01 12:54:26 -04:00
Sylvie 2fb76ce584 Traverse the charmap trie to reconstruct mappings instead of saving them (#1487) 2024-09-01 15:22:56 +02:00
Sylvie 7330c2c606 Replace unmangle with cygpath (#1490)
Use `-m` not `-w` so paths use forward slashes
2024-08-31 00:10:44 -04:00
Rangi42 c07371c9fc Revert "Show test issues as annotations in the GitHub Actions job summary"
This reverts commit 3a5ff35928.

Annotations were not actually appearing.
<https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions>
2024-08-27 14:07:35 -04:00
Rangi42 15f0871683 Update some names and comments 2024-08-27 14:04:52 -04:00
Rangi42 26fcff831d Run clang-format 2024-08-27 01:49:05 -04:00
Rangi42 3a5ff35928 Show test issues as annotations in the GitHub Actions job summary 2024-08-27 01:02:53 -04:00
Rangi42 38a90890fb A few more rgbasm documentation tweaks 2024-08-27 01:02:06 -04:00
Rangi42 de84e3ea8b Rewrite and rearrange some rgbasm docs 2024-08-27 00:48:49 -04:00
Rangi42 b77ba1d87d Forward declare struct Section to avoid a nested header include 2024-08-26 22:58:38 -04:00
ISSOtm 4ce6c9f4a5 Avoid bogus comparisons when linking fails
This avoids drowning RGBLINK's errors in a meaningless `diff` output
2024-08-26 22:58:38 -04:00
ISSOtm 8286d9c462 Check that there is enough room to write a patch when linking
Prevents segfaulting if a patch's offset is too large
2024-08-26 22:58:38 -04:00
Rangi42 fbe28e0def Remove outdated "absolute data" terminology in function names 2024-08-26 22:58:38 -04:00
ISSOtm 23272f028f Update the best proto-pal relative size when a new best is found
*facepalm*
2024-08-23 13:35:48 +02:00
ISSOtm 77129b9e80 Fix a false positive reported by scan-build
Arguably this also makes the logic a little clearer, so might as well
2024-08-23 01:34:36 +02:00
Sylvie 44332ff4be Charmaps cannot map an empty string (#1486) 2024-08-22 13:21:16 -04:00
Sylvie 81ab133566 Enable more testing of RGBGFX output (#1473) 2024-08-22 19:19:39 +02:00
Sylvie 0e8a17ce82 Report any section overflows at the end of assembly (#1482)
* Report any section overflows at the end of assembly

* Immediately handle overflow of the 32-bit size counter
2024-08-22 18:51:52 +02:00
Rangi42 7bc9a24bf0 Edit some documentation of unions and macros 2024-08-22 00:41:07 -04:00
Sylvie b438c83bda Implement a '#' prefix for raw identifiers that may alias keywords (#1480)
* Implement a '#' prefix for raw identifiers that may alias keywords

* Review comments

* Disallow hashless raw identifiers in interpolations

* Run clang-format
2024-08-21 19:31:44 +02:00
Sylvie 82e81ab1da Test RGBLINK on SDCC object files (#1479) 2024-08-20 17:51:01 -04:00
Sylvie 57c3d74b9e Use a custom generic tagged union Either instead of std::variant for efficiency (#1476)
* Implement custom generic tagged union `Either`

This should be more efficient than `std::variant`, while still
keeping runtime safety as it `assert`s when `get`ting values.

* Use `Either` for RPN expressions

* Use `Either` for file stack node data

* Use `Either` for `File` buffer

* Use `Either` for `STRFMT` args

* Use `Either` for RGBLINK symbol values

* Support an equivalent of `std::monostate` for `Either`

* Use `Either` for lexer tokens

* Use `Either` for symbol values

* Use `Either` for lexer mmap/buffer state
2024-08-20 21:19:11 +02:00
Sylvie 7d98b9a900 Add RGBFIX tests for MBC names (#1477)
RGBFIX tests are now based on .flags files
The .bin and .err files are optional
2024-08-20 21:15:37 +02:00
Eldred HabertandSylvie 8f47fb494b Improve some documentation (#1474)
* Delete removed symbol from PRINTLN examples

* Touch up `SHIFT` docs

Co-authored-by: Sylvie <[email protected]>
2024-08-19 20:29:20 +02:00
Sylvie 8c96293b11 Test the RGBASM state file output (#1472) 2024-08-19 20:13:27 +02:00
Sylvie 57f122a04e Document !cc support alongside HIGH(r16) and LOW(r16) support (#1475) 2024-08-19 18:56:16 +02:00
Sylvie 356367bfd3 Allow mirroring only the X or Y axes (#1468) 2024-08-18 21:47:39 -04:00
Rangi42 b7290366cb Reword some RGBASM docs 2024-08-18 21:38:45 -04:00
Rangi42 731715ff36 Refactor test.sh scripts for consistency 2024-08-18 21:38:45 -04:00
Rangi42 7cf4156003 Add some more tests, and fix some existing ones 2024-08-18 21:38:45 -04:00
Rangi42 ee3a93a442 Test macro args \0 and \<0> 2024-08-18 21:38:45 -04:00
ISSOtm 96a0481cba Pass RGBDS= to make clean as well in downstream tests
Avoids some spurious "command not found" errors when cleaning SameBoy
Fixes #1471
2024-08-18 20:11:01 +02:00
ISSOtm 86140b5b2f Correctly apply section fragment offsets to contained symbols 2024-08-18 19:44:04 +02:00
ISSOtm 369296693c Avoid softlock if linker script contains a comment but no newline 2024-08-18 19:44:04 +02:00
ISSOtm 47b2e0e912 Trap bad __at() values too
Those set the section type earlier than the linker script,
so a check needs to be performed there too
2024-08-18 19:44:04 +02:00
ISSOtm 28733fe312 Implement floating bank in linker script
Turns out that we can solve being unable to choose a bank to change
the PC of, by simply refusing to choose!
2024-08-18 19:44:04 +02:00
ISSOtm e45a422da3 Clarify error message when a section lacks a type
The previous commit has made this precision possible
2024-08-18 19:44:04 +02:00
ISSOtm 9fd4ba90cc Trap invalid section types in RGBDS objs 2024-08-18 19:44:04 +02:00
ISSOtm e548ecc6fa Report attempts to assign a SDCC area in a way inconsistent with its data
This actually avoids breaking the (segfaulting) invariant that
a section whose type "has data" has as many bytes of `->data` as
its `->size`.
2024-08-18 19:44:04 +02:00
ISSOtm 00b0914436 Reserve space to avoid file sym array realloc
This line was missing; in its absence, as soon as the array reallocs,
all registered symbol pointers are invalidated, leading to a crash
(e.g. when generating a sym file).

Made the reallocation check into a hard error, too.
Since fileSymbols gets registered with each section, we would have to
change that, and then it cascades throughout all of RGBLINK.
This will be handled correctly in the Rust port.
2024-08-18 19:44:04 +02:00
Ruben Zwietering 60c03ec1e3 Clear the old line buffer when filling the next one in nextLine 2024-08-18 19:44:04 +02:00
Ruben Zwietering 379aa8c267 Use line.reserve in sdobj_ReadFile instead of constructor
Passing a count parameter to the vector constructor does not reserve
count elements but instead fills the vector with count elements.
This caused the endianness check to fail first because the first 256
characters were null bytes.
2024-08-18 19:44:04 +02:00
ISSOtm 589cea47f6 Add a contrib script for visualising the generated palettes as a PNG 2024-08-14 17:55:39 +02:00
ISSOtm 68a6abd00e Fix ProtoPalette::compare
The function only stopped at the end of the *arrays*,
not of *their used portions*!
This could cause false negatives one way or the other.

This appears not to affect the palette packing, since the packing algorithm
deals with them efficiently; but it should speed up processing slightly,
and as the test changes show, it also improves the UX of palette packing
error messages!
2024-08-14 17:36:15 +02:00
Rangi42 c42e856efb Fix charmap state output for inherited characters 2024-08-09 22:13:43 -04:00
Sylvie b987e5669f Comment the parsers better (#1463) 2024-08-09 21:36:52 -04:00
Eldred Habert 718066c2cf Build “fat binaries” for macOS (#1461)
The same binary, both for Intel and ARM Macs!

Builds libpng manually since the lib Brew distributes only contains code for the host arch.
2024-08-09 13:18:58 -04:00
Sylvie 2d530dbcd6 Fix constant expression detection functions (#1462) 2024-08-09 09:40:53 +02:00
Eldred Habert a9140e6bb4 Fix incorrect name of macos-static artifact 2024-08-09 01:59:17 +02:00
Eldred Habert fb6f861a08 Use macOS 14 in CI (#1335) 2024-08-08 22:16:32 +02:00
Rangi42 0adff57e2c Sync warning flags between Makefile and CMakeLists.txt 2024-08-08 16:02:11 -04:00
ISSOtm 784e828219 Enforce C++ compiler when building test binaries in CI too 2024-08-08 20:45:36 +02:00
ISSOtm b20b2dd28c Pass CXX env var through when compiling RGBGFX test binaries 2024-08-08 20:45:36 +02:00
ISSOtm 2a85009b6b Be verbose about building the RGBGFX test binaries
People may not expect that to happen!
And CI would be easier to debug that way, too.
2024-08-08 20:45:36 +02:00
ISSOtm 809b364958 Be stricter in test scripts
Omitting parameters is not a good idea, but even worse if it fails
mysteriously without any error messages
2024-08-08 20:34:09 +02:00
ISSOtm 60f9e86361 Pass libpng CFLAGS when building rgbgfx_test.cpp too
Don't ask me how this hasn't broken earlier, but hey, now it's fixed
2024-08-08 20:30:31 +02:00
Eldred Habert 817dcfdc70 Improve fixed-point documentation (#1455)
* Clarify the operator relationship of ordinary and fixed-point numbers
* Attempt to clarify description of fixed-point numbers
* Note that RGBASM does not check fixed-point precisions
* Simplify sine table example a bit
* Remove misleading equations describing `DIV`, `MUL`, and `FMOD`
* Various minor style and formatting fixups
2024-08-08 13:56:08 -04:00
Sylvie a3f9952b9e Advise on how to use -x to make -r work (#1459) 2024-08-08 19:50:51 +02:00
SylvieandISSOtm 0cd79c33ef Fix RGBGFX reversal (#1425)
* Print all OoB tilemap IDs before aborting

* Rename `nbTileInstances` to `mapSize`

* Check that reversing doesn't overflow the tile array

---------

Co-authored-by: ISSOtm <[email protected]>
2024-08-08 19:40:41 +02:00
ISSOtm 747427e801 Make test/gfx/at-file-ref consistent
The generated `result.pal` can change between platforms, it turns out
(due to "unstable sort" differences), and creates additional churn if
changing anything related to palette generation.

tl;dr this makes the test less flaky in the long run.
2024-08-08 12:23:12 +02:00
ISSOtm 6b09838739 Sort proto-palettes by decreasing size when refitting overloaded palettes
Since that refitting process is a First-Fit, it benefits from that sorting step.
2024-08-08 12:12:29 +02:00
ISSOtm 0f1137c6ec Fix ineffective sorting of palettes pre-packing
We were sorting the *IDs*, not the proto-palettes...
2024-08-08 11:31:46 +02:00
ISSOtm 1ad9383042 Disable optimisations in make debug
I am starting to feel aggravated by `$1 = <optimized out>`
2024-08-08 11:15:19 +02:00
Sylvie 5b486e1d87 Document the behavior of FMOD, and other man page cleanup (#1458) 2024-08-07 19:51:35 +02:00
Sylvie e93190d491 Implement BITWIDTH and TZCOUNT functions (#1450) 2024-08-07 10:39:30 -04:00
Sylvie 7435630d6a Error messages note when a symbol has been purged (#1453) 2024-08-06 15:35:06 -04:00
Sylvie fc8707886c Output exported numeric constants to sym file (#1439) 2024-08-06 10:58:35 -04:00
Sylvie bb480b761c Rephrase numeric-string warning to not be identical to another one (#1449) 2024-08-06 13:56:09 +02:00
Sylvie 2706f94788 Multiple fixes and enhancements to RPN behavior: (#1448)
- FIX: `Label & const` was not actually doing the `& const` masking
  (fixes #1446)
- ADD: `LOW(Label)` can be constant if `Label` is aligned to 8 or more bits
  (resolves #1444)
- ADD: `!expr` can be constant 0 if `expr` has any non-zero bits
  (resolves #1447)
- `LOW()` and `HIGH()` have their own RPN operator values
  (resolves #1445)

The change to RPN values means that the object file version was incremented.

This also refactors unary operators and functions, combining their
evaluation similarly to binary ones.
2024-08-06 13:54:55 +02:00
Sylvie 2f8f99bd94 Implement -Wpurge= (#1443) 2024-08-05 12:50:48 -04:00
Sylvie f304e1dd7f Implement state file output for RGBASM (#1435) 2024-08-05 12:41:40 -04:00
Sylvie c5e6a815fa Deprecate treating multi-unit strings as numbers (#1438) 2024-08-05 16:05:50 +02:00
Sylvie d4231f9efa Remove redundant "unknown option" error messages (#1441)
`getopt` already prints "unrecognized option"
2024-08-05 16:04:53 +02:00
Rangi42 e4ffcf7153 Update the 'ucity' commit used for testing
This removes our need to patch it for compatibility
2024-08-04 21:52:57 -04:00
Sylvie 1d194b68ca Update test deps (#1440) 2024-08-04 21:49:22 -04:00
Sylvie 9a5b3f0902 Implement multi-value charmaps (#1429) 2024-08-04 23:32:08 +02:00
Rangi42 436580a649 Consistently use "palette spec" not "color spec"
Fixes #1436
2024-08-04 16:24:14 -04:00
Sylvie 8af9e9d465 Add rgbgfx -r 0 to infer a width (#1437) 2024-08-04 20:31:05 +02:00
ISSOtm 98bca79df4 Run clang-format 2024-08-02 22:36:33 -04:00
ISSOtm dae4219acd With -r, print both palettes if -c and -p mismatch 2024-08-02 22:36:33 -04:00
ISSOtm 3d1f5386c2 Fix parsing of GPL files
Can you tell this was *not* tested whatsoever?
2024-08-02 22:36:33 -04:00
ISSOtm 1f8f28cac8 Fix parsing of textual colours
`n`'s input value was not honored, and its updating logic incorrect
2024-08-02 22:36:33 -04:00
ISSOtm 8e60d1f0b8 Fix textual palettes not accepting to be filled
A weird case of off-by-one error
2024-08-02 22:36:33 -04:00
ISSOtm d8aceaea4a Ignore empty lines in HEX files
They are free-form enough that empty lines should probably be supported.
2024-08-02 22:36:33 -04:00
ISSOtm a23b4732e3 Distinguish EOF and empty lines when parsing text pal files 2024-08-02 22:36:33 -04:00
Rangi42 3bd35a8848 "Write" to files, "print" to console 2024-08-02 16:26:42 -04:00
ISSOtm 41046c287f Use appropriate format specifier for number of palettes 2024-08-02 21:59:51 +02:00
ISSOtm f4d0f01f91 Fix max number of palettes wrapping around after 255 2024-08-02 16:14:43 +02:00
Rangi42 0ed846c773 Remove outdated RGBASM options from man page 2024-07-27 09:57:52 -04:00
Rangi42 4e0f794c23 More refactoring and renaming 2024-07-26 20:12:51 -04:00
Sylvie 6a65cbc9ed Some refactoring and reformatting (#1431) 2024-07-26 11:51:27 -04:00
Sylvie 92abe24894 Implement EXPORT DEF to define and export symbols (#1422) 2024-07-25 17:40:58 -04:00
Sylvie 13a8895fca Improve the error messages for interpolating undefined or invalid symbols (#1423) 2024-07-25 17:36:02 -04:00
Sylvie e179ba5fd3 Add syntax to push and modify stacks in one line (#1421) 2024-07-25 23:14:59 +02:00
Eldred Habert 1d89d75381 Fix use-after-free when keeping pointers to args from at-files (#1426) 2024-07-25 23:00:48 +02:00
Sylvie c0904228f2 Fix bison.sh for patch-less bison versions (#1416) 2024-07-03 13:37:04 +02:00
Rangi42 556c8a968a Release 0.8.0 2024-06-28 14:53:17 -04:00
Sylvie ed5529d639 Fix generating a palette overriding a previous pal spec (#1415) 2024-06-25 18:27:01 +02:00
Sylvie 240ab8ed1c Keep the object version as RGB9; only increment the revision to 10 (#1413) 2024-06-21 16:47:49 +02:00
Sylvie 0433714d77 Allow a suffix (e.g. the version) to be added when installing (#1406) 2024-06-18 22:06:43 +02:00
Sylvie ee748cfe26 Miscellaneous refactoring of code and docs (#1411) 2024-06-18 20:47:31 +02:00
Sylvie 623c3f662c Allow NUL characters in strings (#1405) 2024-06-18 14:26:18 -04:00
Sylvie 9cc595b2cc Specify a custom logo file to use instead of the Nintendo logo (#1400)
Fixes #1398
2024-06-18 20:02:50 +02:00
Sylvie 8c3ca462fe Add more test cases (#1409) 2024-06-17 15:07:35 -04:00
Sylvie 9e1898238d Remove unsupported macOS 11 from CI (#1410) 2024-06-17 14:30:57 -04:00
Sylvie b3c94b5b87 Give names to links in man pages (#1407) 2024-06-15 13:48:37 +02:00
Sylvie 82f60e26c4 Fix reading ACO palette files (#1404) 2024-06-13 12:21:19 -04:00
Sylvie dfec7111e2 X && 0 and X & 0 are constant 0; X || 1 is constant 1 (#1399)
Fixes #977
2024-06-13 11:09:39 -04:00
Sylvie c5c6cc9794 Refactor macros for fixing/trashing header values (#1401) 2024-06-13 10:59:48 -04:00
Rangi42 39e9315e8a Use a smaller size for the lexer buffer
Large sizes are more efficient when it's actually buffered,
but most of the time `mmap` is used instead, and the extra size
just slows down allocation of lexer states.
2024-05-17 20:59:42 -04:00
Sylvie 352551d4f8 Allow padding to coexist with overlay file (#1395) 2024-05-17 11:14:44 +02:00
Sylvie e2633d5b66 Use the standard stream buffer size for the lexer buffer (#1396) 2024-05-17 11:02:36 +02:00
Sylvie 3e9d2cab12 Make some error messages more consistent (#1393)
* Update some error messages

* Make non-A destination operand syntactically invalid
2024-04-20 23:13:01 +02:00
Chris Pickel 7aecc00919 Fix rectangular rgbgfx --reverse --columns (#1392)
When width != height, the math was off, causing some tiles to be
repeated or skipped.
2024-04-20 18:20:16 +02:00
Rangi42 b8387427a6 Use consistent RGBDS_<PROG>_<NAME>_HPP header guard convention 2024-04-14 21:50:05 -04:00
Sylvie a234da42a6 Replace assert with assume for release build optimization (#1390) 2024-04-02 11:09:31 -04:00
Sylvie 1d39e5ed56 Use std::variant for RPN expression value (#1389) 2024-04-01 16:47:15 +02:00
Sylvie 9ab3446d1a Fix two bugs with RGBASM fixed-point math (#1388)
- Fixed-point formulas are implemented using IEEE-754 floating-point
  internally, which could give infinity or NaN values whose conversion
  to fixed-point integer was platform-dependent.
- Formatting fixed-point $8000_0000 (INT32_MIN, -2147483648) was
  not putting the negative sign in front.
2024-03-31 12:53:20 -04:00
Rangi42 6b5248f15b Add a build target for include-what-you-use 2024-03-29 20:49:09 -04:00
Rangi42 eb708ebee5 Rename some variables left from the C parser (e.g. yylval) 2024-03-29 19:42:23 -04:00
Rangi42 cf3e5e15f8 Update the 'ucity' commit used for testing
This reduces our need to patch it for compatibility
2024-03-29 14:42:23 -04:00
Sylvie 408a783fd8 Add more RGBLINK tests (#1386) 2024-03-29 14:30:32 -04:00
Rangi42 17afe611fd Update the 'libbet' commit used for testing
This reduces our need to patch it for compatibility
2024-03-29 13:35:12 -04:00
Sylvie 996db14ffa Make test built of 'libbet' reproducible with old Pillow versions (#1385)
The Python Pillow image library gives different output for
`Image.getcolors()` in version 9 than version 10. This causes
libbet's SGB border to be built differently, giving a different
ROM hash and technically failing the test script.

This patches libbet to only keep the known-good colors. It also
adapts the coverage script to run all the tests, including
building the third-party projects.
2024-03-29 11:59:36 -04:00
Sylvie 7326cc6875 Verify ROM hashes for all CI test projects (#1384)
Ucity and Libbet build files in a nondeterministic order, which
we have to patch to sort consistently for reproducible builds.
2024-03-28 22:37:33 -04:00
Rangi42 9dac583e45 Patch test projects so they build without deprecated features
Also ensure the test scripts pass shellcheck
2024-03-28 17:26:42 -04:00
Rangi42 ccfd3b6af8 Remove documentation of already-removed RGBGFX options 2024-03-28 17:26:42 -04:00
Rangi42 4a4656af1b Remove the deprecated RGBGFX --output-* options (use --auto-*) 2024-03-28 17:26:42 -04:00
Rangi42 b021090e7f Remove deprecated -i for --include (use -I) 2024-03-28 17:26:42 -04:00
Rangi42 230b1db438 Remove deprecated DEF-less definitions 2024-03-28 17:26:42 -04:00
Rangi42 14b72222b1 Remove the deprecated -H/-h/-L/-l options 2024-03-28 17:26:42 -04:00
Rangi42 106e516962 Split the .peek() method into its next-char and lookahead cases 2024-03-28 15:37:25 -04:00
Rangi42 6f74e4fb9c Remove the suboptimal .canPeek() and .peek() methods 2024-03-28 14:49:36 -04:00
Rangi42 83c0634f15 Refactor peekInternal to be a LexerState method 2024-03-28 13:21:28 -04:00
Rangi42 4172d330b9 Refactor BufferedContent and Expansion to have methods
Use a buffer size that is a power of two for fast modulus
2024-03-28 12:57:23 -04:00
Rangi42 cf7bdb19b6 Run clang-format 14 on everything
Later versions may need some proprties added or changed to not
format closing braces weirdly.
2024-03-28 09:17:27 -04:00
ISSOtm 20b7b591d4 Run clang-format
Fix some small style inconsistencies
2024-03-28 01:41:25 +01:00
ISSOtm d327138cd8 Report as many build errors as possible in CI
This allows debugging more problems in a single cycle
2024-03-28 01:37:10 +01:00
ISSOtm 0c0923ac16 Disable some spurious MSVC warnings
Not that it will de-clutter our CI logs very much, but eh, you know.
2024-03-28 01:33:21 +01:00
ISSOtm e5078aba3b Clean up #includes
Remove unused headers, and avoid relying on transitive inclusions

`include-what-you-use` has been very useful for this!
2024-03-28 01:25:38 +01:00
ISSOtm cae7b5dcf6 Use standard attribute syntax instead of IBM __attribute__
Move format attrs to proper standard location

For some reason, GCC 13 is more lax than earlier versions...
2024-03-27 20:01:12 -04:00
Rangi42 506911d7d0 Refactor to avoid redundant obj_CheckAssertions function 2024-03-27 16:19:01 -04:00
Rangi42 dcb4e40388 Use QUOTEDSTRLEN macro instead of sizeof or strlen 2024-03-27 11:50:48 -04:00
Rangi42 912a1504ec Defer closing of depend file 2024-03-27 11:44:26 -04:00
Rangi42 2ef5e807f8 No more memory leaks! 2024-03-27 11:27:34 -04:00
Rangi42 b6039870e5 Remove now-redundant MmappedContent struct 2024-03-27 11:27:34 -04:00
Rangi42 78801e324c Group pointer and size as a ContentSpan struct 2024-03-27 11:27:34 -04:00
Rangi42 bf0cabb3ea Use std::shared_ptr for lexer capture buffers 2024-03-27 11:27:34 -04:00
Sylvie a68bebf4a2 Use a Defer struct to close files and restore lexer state with RAII (#1379) 2024-03-27 10:42:53 -04:00
Rangi42 32db0a0f18 Rename CaptureBody to Capture, and refactor its methods 2024-03-26 12:29:59 -04:00
Rangi42 a167d23d01 Use content-specific destructors for lexer state
Also rename `LexerState` content structs from `*LexerState` to `*Content`
2024-03-26 12:29:59 -04:00
Rangi42 8b6ae994b1 Use STR and CAT macros for # and ## 2024-03-25 14:22:43 -04:00
Rangi42 2b44672873 Rename a few variables 2024-03-25 14:22:38 -04:00
Rangi42 3568418c5d Remove RGBLINK's unimplemented '-s' "smart linking" placeholder flag 2024-03-25 11:36:23 -04:00
Rangi42 cb59119881 Use automatically-allocated std::string_view for macros 2024-03-25 11:33:17 -04:00
Rangi42 d9e5e57e27 Make CaptureBufs be parser values instead of a single static global 2024-03-23 19:44:54 -04:00
Rangi42 e9e8915725 Refactor to keep lexerState and lexerStateEOL static
Also run `clang-format` on everything
2024-03-23 19:14:46 -04:00
Sylvie c075ffb570 Update test project commits (#1377) 2024-03-22 17:06:39 -04:00
Sylvie 96c808810f Remove .simple.err files, since we require Bison 3.0 (#1373) 2024-03-22 15:36:32 -04:00
Rangi42 6a5518e0c5 Use RAII to unmap or close the lexer states' files automatically 2024-03-22 14:25:36 -04:00
Rangi42 507439bc25 Refactor macro args to be owned collectively by their fstack contexts 2024-03-22 14:25:36 -04:00
Rangi42 b85c5cde8f Use std::shared_ptr for MacroArgs 2024-03-22 14:25:36 -04:00
ISSOtm e255af9e10 Do not limit strings to 255 characters 2024-03-22 14:25:36 -04:00
ISSOtm 9f239f6dcc Use std::shared_ptr<std::string> for lexed/parsed strings 2024-03-22 14:25:36 -04:00
ISSOtm 412073774c Refactor string-formatting routines to append to an existing string 2024-03-22 14:25:36 -04:00
ISSOtm 52e8e1f9fc Simplify \@ handling by using std::shared_ptr<std::string>
This has been relocated from macro.cpp to fstack.cpp, since both
MACRO and REPT/FOR nodes have their own unique `\@` values.
2024-03-22 14:25:36 -04:00
Sylvie 04405fb444 Use std::shared_ptr for fstack nodes (#1371) 2024-03-22 13:27:21 -04:00
Sylvie dd43723e20 Use methods for RPN Expression (#1372) 2024-03-22 04:41:04 -04:00
Rangi42 de667c8afb Remove unused Visitor template 2024-03-22 03:29:56 -04:00
Sylvie f792580816 Only restore parent context's \@ value if it had one defined (#1366)
This way, if a child context initializes `\@`, the parent won't
reset it. And if the child context did not initialize `\@`,
then resetting it would be redundant.
2024-03-21 19:53:49 -04:00
orbea 0f772932a5 Convert bison.sh to posix shell (#1369)
* Convert bison.sh to posix shell

* Refactor bison.sh to be more like CMakeLists.txt

No current warnings with shellcheck.net.
2024-03-21 16:06:36 -04:00
SylvieandISSOtm 0300971a17 Fix some header #includes with clangd LSP (#1370)
Co-authored-by: ISSOtm <[email protected]>
2024-03-21 15:13:10 -04:00
Rangi42 32b4a6f284 Use "snake_case" consistently in parsers 2024-03-21 11:44:07 -04:00
Rangi42 6560b7819d Add make profile, optimized for callgrind 2024-03-21 11:42:12 -04:00
Sylvie 0af1e512c2 Use std::get_if instead of std::visit (#1367)
`std::visit` is (arguably) cleaner code, but older versions of gcc
and clang (not very old; the ones packaged with Ubuntu 22.04 LTS)
compile them as tables of function pointers, instead of efficient
jump tables.
2024-03-20 22:37:54 -04:00
Sylvie 035678d250 Remove workaround for GitHub Actions issue (#1368) 2024-03-20 20:46:08 -04:00
Sylvie 554778da5b Built-in symbols are "<builtin>", not "<command-line>" (#1362) 2024-03-19 16:01:45 -04:00
Sylvie fec2266dd8 Use std::string for string-formatted values (#1360)
* Use `std::string` for string-formatted values

* Make `formatString` and `formatNumber` be `const`
2024-03-19 07:43:18 +01:00
Sylvie 33dd97b6a0 Fix CI builds for Ubuntu 22.04 (#1361)
Ubuntu 22.04 provides LLVM 14, which links an ASan version incompatible with
high-entropy ASLR in newer Linux kernels that GitHub Actions runners use.
2024-03-19 01:05:10 -04:00
Rangi42 a862c7b17b Use sed instead of awk to extract Bison version 2024-03-18 15:36:45 -04:00
Rangi42 40db9d5cef Use std::string for lexer state paths 2024-03-18 14:42:05 -04:00
Rangi42 05d79d87f6 Pass std::string references to RPN functions 2024-03-18 14:42:05 -04:00
Rangi42 e96675be03 Pass std::string references to fstack functions 2024-03-18 14:42:05 -04:00
Rangi42 472d1bde06 Pass std::string references to symbol functions 2024-03-18 14:42:05 -04:00
Rangi42 6cabb8c9af Pass std::string references to output functions 2024-03-18 14:42:05 -04:00
Rangi42 7b11c528ef Pass std::string references to section functions 2024-03-18 14:42:05 -04:00
Rangi42 91164ac1b0 Pass std::string references to charmap functions 2024-03-18 14:42:05 -04:00
Rangi42 04899a21cd Pass std::string references to parser semantic functions instead of .c_str() pointers
This also refactors some semantic functions to be more efficient
2024-03-18 14:42:05 -04:00
Rangi42 8f77518406 Use std::string for most intermediate parsed strings
This is a work in progress: its performance is unacceptably slow,
and it is obviously not a complete refactoring:

- The parser's semantic functions are still written for C-style
  strings, taking `.c_str()` pointers instead of `std::string`
  references (and using their methods, `<algorithm>`s, etc).
- Quoted string literals from the lexer still use our `String`
  struct, which wraps around a fixed-size char array.
- Symbol values, macro arguments, and so forth are still pointers
  to C-style strings with unclear ownership semantics (i.e. we
  still have "leaks as a feature").
2024-03-18 14:42:05 -04:00
Rangi42 b76e196c89 Run clang-format on everything 2024-03-18 14:08:57 -04:00
Rangi42 d06376c170 Use std::unordered_map and std::vector for sections
This allows us to control the order in which sections are iterated,
instead of it depending on the internals of `std::map`. (This order
is arbitrary, but should be deterministic regardless.)
2024-03-16 11:51:47 -04:00
Rangi42 cefc4f4aa3 Use std::unordered_map for symbols 2024-03-16 11:19:19 -04:00
Rangi42 a14de10e28 Use std::unordered_map for charmaps 2024-03-16 11:13:14 -04:00
ISSOtm e4a3509845 Fix build failure with GCC 13
It complains about *those* calls returning a dangling reference...
Unfortunately, GCC does not provide more information about what the
reference *is*. (It only mentions the temporary being destroyed at
the end of this *huge* expression.)

I am normally not one to just commit a thing that gets rid of a
warning if I can't explain why, but this eludes me.
Stubbing out the calls to only return a captured variable still
complains, which led me to test that the error wasn't stemming
from the `Visitor` itself... which it seems to?
But I don't see why a reference to the *visitor* should be kept...

Anyway, here is the obligatory part where I state my yearning for Rust :)
2024-03-15 21:40:11 +01:00
Sylvie eb99fc8681 Use a std::unordered_map for looking up sections by name (#1357) 2024-03-13 19:45:52 -04:00
Sylvie 8ec0d01fc4 Sort .sym files in ascending order, and test for it (#1355) 2024-03-13 18:32:35 -04:00
Sylvie 658286c8e4 Move a SECTION FRAGMENT test to the test/link/section-fragment folder (#1354)
Add a binary comparison for the same-label SECTION UNION test
2024-03-13 15:34:27 -04:00
Sylvie a1bbb3b3f7 Strip CI binaries built with make (#1345) 2024-03-13 14:42:11 -04:00
Sylvie 67c707739d Allow multiple identical exported numeric constants (#1341)
This still doesn't allow identical exported label constants.
That can be addressed when or if it's requested for a real use case.

Symbols only store one source filename + line number, so this
arbitrarily keeps the last read symbol as the reported one.
2024-03-13 14:06:20 -04:00
Sylvie 68f6ab5c32 Add test cases for SECTION UNION defining multiple identical labels (#1349)
Exported labels should fail to link; non-exported ones should be okay.
2024-03-13 13:34:44 -04:00
Rangi42 188fcfdd64 Add license header to test/CMakeLists.tst like the rest 2024-03-13 11:55:17 -04:00
Sylvie 4f15f07dd4 Refactor link/test.sh to avoid repeating test names (#1353) 2024-03-13 11:43:50 -04:00
Eldred Habert 08066d4692 Fix a reference being used after being invalidated (#1352)
Your classic use-after-free bug.
2024-03-12 22:19:01 -04:00
ISSOtm 42d32c72a6 Use a unique name to upload W32/W64 binaries in CI
This now breaks in CI.
2024-03-13 01:07:28 +01:00
ISSOtm 81ed5fe41e Update Actions to Node 20
There are some warnings in CI about this.
2024-03-13 00:15:43 +01:00
ISSOtm b9596890c9 Disable a Clang warning
Fixes `make develop` with Clang 17.
The warning only triggers on the auto-generated `yynerrs_` in `src/asm/parser.cpp`,
so it's not very useful to us right now.
2024-03-13 00:04:11 +01:00
Rangi42 846a9411b9 Refactor FileStackNode::dump to not need a helper function 2024-03-10 14:14:34 -04:00
Rangi42 58fdaa8747 Avoid a couple of clang-format quirks 2024-03-10 12:31:03 -04:00
Sylvie 820f6b5b3c Consistently format type qualifiers like const on the right (#1347) 2024-03-10 12:21:52 -04:00
Rangi42 d982d47c56 Use move semantics for more parsed values 2024-03-09 20:05:09 -05:00
Rangi42 569b940b82 No need to manually do the Expression destructor's job 2024-03-09 19:33:53 -05:00
Rangi42 ba104baf3e Refactor mapFile for Windows 2024-03-09 19:22:06 -05:00
Rangi42 cce7f51235 Remove RPN symbol name length limit 2024-03-09 17:56:30 -05:00
Sylvie 17444e825a Reduce the header declarations (#1342)
- Since we have style rules to include foo.hpp at the top of its
  corresponding foo.cpp, this takes any headers included by foo.hpp
  as being also guaranteed for foo.cpp.

- Use C-style <foo.h> instead of <cfoo>, since the latter only
  guarantees putting symbols in the `std` namespace, which we are
  not using for C functions (e.g. `printf` not `std::printf`).

- Remove now-unused `__PRETTY_FUNCTION__` reporting
2024-03-09 14:55:39 -05:00
Sylvie 3323cb56fe Make enum patterns more explicit (#1343) 2024-03-09 14:55:17 -05:00
Sylvie 5681be1fd8 Use automatic allocation and std::move for RPN bytes (#1336) 2024-03-09 11:12:34 -05:00
Sylvie 4a7d333891 Use std::unique_ptr for rgblink sections (#1337) 2024-03-09 11:12:01 -05:00
SnDream 9890cf25b4 Fix -O being always ignored (#1339)
The file isn't opened at this point, it's the file name that should be inspected.
2024-03-09 14:11:56 +01:00
Rangi42 9f5bf5e285 Remove an unnecessary .close() call that the destructor handles 2024-03-08 22:29:37 -05:00
Rangi42 0bfade4435 Fix enum: REG_SP == REG_AF == 3 2024-03-08 20:00:29 -05:00
Rangi42 40704b5055 Remove unused yyerror declaration
Also reformat some `enum`s
2024-03-08 19:47:57 -05:00
Sylvie 53537cf9af Remove now-unnecessary enum keyword (#1338)
C++ does not need it
2024-03-08 19:40:41 -05:00
Rangi42 1b97297d63 Fix a typo bug in sdas_obj.cpp
This was introduced in commit 447c561, PR #1330
2024-03-08 18:30:30 -05:00
Rangi42 75cc12bb3d Use std::optional for fstack paths 2024-03-07 21:41:02 -05:00
Rangi42 563d699394 Avoid an extra operation if !labelScope (thanks, ISSOtm) 2024-03-07 17:33:33 -05:00
Rangi42 e701faa1bc Print summaries at the end of test.sh scripts 2024-03-07 16:45:53 -05:00
Rangi42 aed172071b Replace some macros with static functions or constants 2024-03-07 16:10:05 -05:00
Rangi42 90356ee669 Remove unused #define 2024-03-07 15:07:16 -05:00
Rangi42 0a4a01c5e5 Ignore callgrind output files 2024-03-07 14:56:32 -05:00
Rangi42 0f52cd0bab Use std::reverse for binary digits 2024-03-07 14:48:23 -05:00
Rangi42 2fd95381a6 Get rid of some fixed-size char buffers 2024-03-07 14:36:30 -05:00
Rangi42 184957c0ed Use fwrite and fputs instead of multiple putc 2024-03-07 12:40:37 -05:00
Rangi42 7663a777d5 Remove 255-character limit on symbol names 2024-03-07 12:40:37 -05:00
Rangi42 097b7c3baf Use std::string for symbol names 2024-03-07 12:40:33 -05:00
Rangi42 bf45ebb178 Run clang-format to fix some inconsistent style 2024-03-07 11:52:53 -05:00
Rangi42 84bedc7bbe Use automatic allocation for RPN reasons 2024-03-07 09:58:45 -05:00
Rangi42 e5b7e65e91 Use std::nothrow from <new> with every new allocation 2024-03-07 09:56:15 -05:00
Rangi42 104fd6c70d Use automatic allocation for some parser values 2024-03-06 22:17:35 -05:00
ISSOtm 0ea174f0dd Stop explicitly passing zlib/libpng path to CMake in Windows CI
Turns out CMake auto-detects the libs just fine from the
`CMAKE_INSTALL_PREFIX`, and `PNG_BUILD_ZLIB` was actually breaking things.
2024-03-06 21:02:13 -05:00
Rangi42 35ec190664 Update Windows libpng to 1.6.43 2024-03-06 21:02:13 -05:00
Sylvie 292adb27a3 Adapt the RGBASM parser to C++ (#1333)
This uses variants instead of a `%union`, and "complete symbols"
that can call complex constructors.
2024-03-06 20:40:36 -05:00
Rangi42 8c173b4e95 Remove declaration for compatibility with macOS bison 2.3
We've required bision 3.0 since October 2022
2024-03-06 17:58:15 -05:00
Rangi42 94b724ae5f Update to use winflexbison 2.5.25 (bison 3.8.2) 2024-03-06 17:56:16 -05:00
Rangi42 6d4a61f51d Fix some numeric bases in RGBLINK output 2024-03-06 17:43:26 -05:00
Rangi42 75105016f7 Make sure that parsed subexpressions are fully defined
We were not initializing some expressions, and they were using
the values of the previous expressions instead. This just so
happened to not crash the tests, and to sometimes even give valid
results (although `BANK()` of a non-label symbol being $4B4E4142,
the ASCII balue of "BANK", was something we missed).
2024-03-06 16:00:55 -05:00
Rangi42 f419f206e5 Fix a latent bug with parsing macro args
This seems to only have worked by coincidence; `$$` was an
undefined value that happened to equal `$1` already.
2024-03-06 15:14:17 -05:00
Rangi42 82824a4bf2 Avoid using Bison's typed mid-rule actions
These work with `%union`, but will not work with C++ `variant`
2024-03-06 14:19:37 -05:00
Rangi42 d1652c0028 Refactor cases for simplicity, and remove redundant comments 2024-03-06 14:10:50 -05:00
Rangi42 053aa80951 Improve some const correctness in RGBASM 2024-03-06 13:53:03 -05:00
Rangi42 585c620945 Rename fail to sectError, since it increments nbSectErrors 2024-03-05 14:36:18 -05:00
Rangi42 bd88787cb3 Use FileStackNode constructor to avoid std::monostate possibility 2024-03-05 14:22:29 -05:00
Rangi42 74539f08ba Add some more trailing commas 2024-03-04 22:53:11 -05:00
Sylvie e74073e480 Run clang-format on everything (#1332) 2024-03-04 14:22:49 -05:00
Sylvie b004648a13 Use std::variant for symbol values (#1331) 2024-03-04 08:55:33 -05:00
Rangi42 f2c875e71e Avoid using std::get except in holds_alternative-asserting accessors 2024-03-03 23:33:23 -05:00
Rangi42 13904dc536 Remove EQUS callbacks for symbols
They're no longer used since `__FILE__` was removed
2024-03-03 21:26:44 -05:00
Rangi42 ba183e900b Update contributors 2024-03-03 21:17:52 -05:00
Sylvie 447c561aaa Use std::variant for symbol values (#1330) 2024-03-03 21:16:36 -05:00
Sylvie f8dab23e8f Use uncommented sizes for pointer-to-array arguments (#1329)
This is syntactically valid despite not being enforced, and
is a feature we already use elsewhere.
2024-03-03 19:43:08 -05:00
Eldred Habert 0da216897a Improve tests a little (#1324)
* Avoid redirecting error messages in RGBLINK tests

We check that RGBLINK prints nothing to stdout, so all that
would be captured on stdout is a putative failure message.

* Require each RGBLINK test to check error output

Otherwise, you can have a test that just... checks nothing!

* Document how to add tests

Fixes #1300's last remaining item.
Also add `checkdiff` rules to remind us to update that doc if
any of the test driver scripts are updated.
2024-03-03 19:12:29 -05:00
Sylvie 8cf446b14c Use std::variant for lexer mmap/buffer state (#1328) 2024-03-03 18:45:50 -05:00
Evie 6b67c82b94 Implement -c #none (#1301)
Also adds a test case for round-tripping `-r` with `-c #none`.
2024-03-03 18:45:33 -05:00
Rangi42 930a5c3e44 Replace RGBLINK non-null pointers with references 2024-03-03 00:57:03 -05:00
Rangi42 538b253dfb Replace RGBFIX non-null pointers with references 2024-03-03 00:57:03 -05:00
Rangi42 277ea9be28 Replace RGBASM non-null pointers with references 2024-03-03 00:57:03 -05:00
Rangi42 d812acff24 Check RGBGFX warning/error format strings with format_ macro 2024-03-02 23:17:54 -05:00
Rangi42 2e1b0b6421 Remove commented-out C-only macro features 2024-03-02 20:17:22 -05:00
Rangi42 52f8ecc347 We do not call malloc/free any more 2024-03-02 08:16:44 -05:00
Rangi42 19bb12754b Use new allocation for expanding \# 2024-03-02 08:04:59 -05:00
Rangi42 dbcb82799e Use std::vector for capture buffer 2024-03-02 06:46:11 -05:00
Sylvie a71e4086a2 Use std::string_view for macro bodies (#1326)
This removes the last use of `strdup`

This required making a lot of related pointers be `const`.
That in turn conflicted with the need to `munmap()` a pointer
eventually, which was similar to the need to eventually `free()`
an `Expansion`'s contents, so I used the same solution of a
`union`. That lets us normally use the `const` pointer for
`const` correctness, and the non-`const` one for the not-really-
mutating destruction cases.
2024-03-02 13:21:28 -05:00
Rangi42 2069a95e0f Use std::string for macro args 2024-03-02 05:23:15 -05:00
Rangi42 b130c2e27c Use std::string for STRFMT spec and args 2024-03-02 05:09:43 -05:00
Rangi42 ba00cf5684 Use std::string for section names 2024-03-02 04:47:02 -05:00
Rangi42 b488d3a90f Use std::optional<std::string> for lexer expansion names 2024-03-02 04:34:42 -05:00
Sylvie 701b926288 Use RAII std::string and std::vector in randtilegen (#1325) 2024-03-02 11:02:26 -05:00
Sylvie 446fb07fd5 Use std::deque<std::vector> for free space (#1323) 2024-03-01 16:21:29 -05:00
Sylvie 1ac3c0262f Refactor structs to use methods instead of functions (#1322) 2024-03-01 13:11:45 -05:00
Rangi42 e14ba664ea Remove redundant (void) parameter declarations 2024-03-01 10:41:47 -05:00
Rangi42 91d22f180e Reorganize the asm parser to be more like the linker script parser
Split the declarations into those required for the `%union` and
those only required for the `code`.
Only declare functions on top; define them at the bottom.
2024-02-29 16:23:53 -05:00
Sylvie 043db49676 Replace NULL with nullptr (#1321) 2024-02-29 15:06:33 -05:00
Sylvie eff8c324c8 Remove now-unnecessary struct keyword (#1320)
C++ acts like structs are `typedef`ed by default

We do have to keep `struct stat`, since there's ambiguity
with the function also called `stat`.
2024-02-29 14:41:58 -05:00
Rangi42 1210a7441f Use std::visit with Visitor helper instead of std::holds_alternatve 2024-02-29 13:44:08 -05:00
Rangi42 cf08fed067 Use std::vector for SDCC object section data 2024-02-29 13:44:08 -05:00
Rangi42 c44b336e1b Use std::vector for SDCC object line buffer 2024-02-29 13:44:08 -05:00
Rangi42 e90084ad06 Rename isWRA0Mode to isWRAM0Mode 2024-02-29 13:44:08 -05:00
Rangi42 cdb9315366 Use std::vector for rgbfix ROMX data
Statically links libstdc++ for 32-bit MinGW
2024-02-29 13:44:08 -05:00
Rangi42 2ff723f943 Use vec.data() instead of &vec[0]
In general `vec.data()` is always safe, whereas `&vec[0]`
may fail when `vec` is empty.
2024-02-29 13:44:08 -05:00
Rangi42 d1fa5ccd4d Rename lexer_DeleteState to lexer_CleanupState 2024-02-29 13:44:08 -05:00
Rangi42 17df94c75b Remove now-unnecessary cleanup functions 2024-02-29 13:44:08 -05:00
Rangi42 96f354026a Use automatic allocation for section data 2024-02-29 13:44:08 -05:00
Rangi42 8fe6be19f1 Use automatic allocation for tryReadstring 2024-02-29 13:44:08 -05:00
Rangi42 002eed405b Use automatic allocation for assertion error messages 2024-02-29 13:44:08 -05:00
Rangi42 ef1c1440a0 Use automatic allocation for symbol names 2024-02-29 13:44:08 -05:00
Rangi42 826512730c Use automatic allocation for section symbols 2024-02-29 13:44:08 -05:00
Rangi42 5a26a48d11 Use automatic allocation for section names 2024-02-29 13:44:08 -05:00
Rangi42 3c0af94c5c Use automatic allocation for patches 2024-02-29 13:44:08 -05:00
Rangi42 fc5ab8a14c Clarify comment explaining how referenced works 2024-02-29 13:44:08 -05:00
Rangi42 ace45bfd90 Refactor to avoid repeating rpn_isKnown(expr) 2024-02-29 13:44:08 -05:00
Rangi42 d6681d3580 struct Section's src can be const 2024-02-29 13:44:08 -05:00
Rangi42 0cc49782ab Use std::variant and automatic allocation for file stack node data 2024-02-29 13:44:08 -05:00
Rangi42 e1ac51d7da Use std::vector's .size() for SDCC sections and symbols 2024-02-29 13:44:08 -05:00
Rangi42 c3eb532439 Use copy constructor for file stack node 2024-02-29 13:44:08 -05:00
Rangi42 18d4a81954 Use move semantics for the union stacks 2024-02-29 13:44:08 -05:00
Rangi42 7daa8759c9 Use std::variant for STRFMT arguments 2024-02-29 13:44:08 -05:00
Rangi42 beb1997378 Use std::unordered_map for the keyword dict 2024-02-29 13:44:08 -05:00
Rangi42 962398969b Use std::string for PURGE args 2024-02-29 13:44:08 -05:00
Rangi42 0bed84174b Use std::string for FOR loop variables 2024-02-29 13:44:08 -05:00
Rangi42 48b2e94aa3 Use std::string for symbol/section/node names and assertion messages 2024-02-29 13:44:08 -05:00
Rangi42 a24df27cd8 Use std::vector for charmap output 2024-02-29 13:44:08 -05:00
Rangi42 52ac98c294 Use std::vector for section data 2024-02-29 13:44:08 -05:00
Rangi42 4cd88ade54 Use automatic allocation for object file symbols 2024-02-29 13:44:08 -05:00
Rangi42 dead69eb2c Use std::vector for section symbols 2024-02-29 13:44:08 -05:00
Rangi42 f47ce337bf Use std::vector for reading object file symbols 2024-02-29 13:44:08 -05:00
Rangi42 9a51fbafb3 Use std::vector for file stack nodes 2024-02-29 13:44:08 -05:00
Rangi42 3d23f5bbb3 Use std::vector for reading object file sections 2024-02-29 13:44:08 -05:00
Rangi42 af055ecd27 Use automatic allocation for IF stacks and expansions
Switch to using `std::deque` for IF stacks (supports `.clear()`)
2024-02-29 13:44:08 -05:00
Rangi42 31836967fa Use automatic allocation for lexer states
Lexer states are now owned by fstack contexts
2024-02-29 13:44:08 -05:00
Rangi42 514044496f Use std::string for RPN error reasons 2024-02-29 13:44:08 -05:00
Rangi42 cf42d035f2 Use std::variant for file stack nodes 2024-02-29 13:44:08 -05:00
Rangi42 4b2294292a Use std::string for target file name 2024-02-29 13:44:08 -05:00
Rangi42 0e19f6c0ae Use automatic allocation for fstack nodes' iters/names 2024-02-29 13:44:08 -05:00
Rangi42 5075ac8887 Use std::vector for RPN expressions 2024-02-29 13:44:08 -05:00
Rangi42 d792ee4b61 Use std::vector for section patches 2024-02-29 13:44:08 -05:00
Rangi42 b207bff157 Use std::vector for fstack REPT nodes 2024-02-29 13:44:08 -05:00
Rangi42 53343d2fa6 Use automatic allocation for symbols 2024-02-29 13:44:08 -05:00
Rangi42 e98d1efee3 Use std::vector for include paths 2024-02-29 13:44:08 -05:00
Rangi42 e4764e37b1 Use std::stack for fstack contexts 2024-02-29 13:44:08 -05:00
Rangi42 b8e267e387 Use std::vector for SDAS file sections 2024-02-29 13:44:08 -05:00
Rangi42 17861a970f Use std::vector for RPN data 2024-02-29 13:44:08 -05:00
Rangi42 a5ea25cde5 Use automatic allocation for RPN stack 2024-02-29 13:44:08 -05:00
Rangi42 843f3394c8 Use automatic allocation for DS args 2024-02-29 13:44:08 -05:00
Rangi42 b1aa98b43d Use automatic allocation for PURGE args 2024-02-29 13:44:08 -05:00
Rangi42 6a23c5fd48 Use automatic allocation for STRFMT args 2024-02-29 13:44:08 -05:00
Rangi42 6b2c6c20bc Use automatic allocation for macro args 2024-02-29 13:44:08 -05:00
Rangi42 a4ed7e1d18 Use automatic allocation for charmaps 2024-02-29 13:44:08 -05:00
Rangi42 1b8e588961 Use automatic allocation for patch RPN 2024-02-29 13:44:08 -05:00
Rangi42 dec1811d20 Use automatic allocation for section data 2024-02-29 13:44:08 -05:00
Rangi42 72e9f55368 Use automatic allocation for patches 2024-02-29 13:44:08 -05:00
Rangi42 9140180c85 Use automatic allocation for sections 2024-02-29 13:44:08 -05:00
Rangi42 e022adf4a0 Use automatic allocation for assertions 2024-02-29 13:44:08 -05:00
Rangi42 6e03504802 Use std::deque for expansions 2024-02-29 13:44:08 -05:00
Rangi42 003977a9fb Use std::deque for unassigned sections 2024-02-29 13:44:08 -05:00
Rangi42 1afc8554c0 Use std::deque for file stack nodes 2024-02-29 13:44:08 -05:00
Rangi42 26a93a530b Use std::deque for assertions
Also fix a memory leak
2024-02-29 13:44:08 -05:00
Rangi42 2df4fff6c9 Use std::vector for sorted symbols 2024-02-29 13:44:08 -05:00
Rangi42 b74b40abd2 Use std::deque for sorted sections 2024-02-29 13:44:08 -05:00
Rangi42 d53bba97e8 Remove our custom hashmap 2024-02-29 13:44:08 -05:00
Rangi42 95e7dac9a6 Use std::map for rgbasm charmaps 2024-02-29 13:44:08 -05:00
Rangi42 83d3a39dcd Use std::map for rgbasm symbols 2024-02-29 13:44:08 -05:00
Rangi42 f44701c02d Use std::map for rgblink symbols and sections 2024-02-29 13:44:08 -05:00
Rangi42 d5de3fa111 Use std::deque for symbol lists
Also fix a memory leak that this reveals
2024-02-29 13:44:08 -05:00
Rangi42 bc8cb754c0 Use std::deque for sections 2024-02-29 13:44:08 -05:00
Rangi42 2ea6de7195 Use std::stack for unions 2024-02-29 13:44:08 -05:00
Rangi42 8083ef605f Use std::deque for section patches 2024-02-29 13:44:08 -05:00
Rangi42 b87ee62e6c Use std::deque for assertions 2024-02-29 13:44:08 -05:00
Rangi42 521ca1c34a Use std::vector for symbols 2024-02-29 13:44:08 -05:00
Rangi42 a310b659cd Use std::deque (iterable) for section stack 2024-02-29 13:44:08 -05:00
Rangi42 feb342804b Use std::stack for IF stack 2024-02-29 13:44:08 -05:00
Rangi42 36cfce40ad Use std::stack for options 2024-02-29 13:44:08 -05:00
Rangi42 52c80c2740 Use std::stack for charmaps 2024-02-29 13:44:08 -05:00
ISSOtm 0e07408c63 Document how to run the test suite 2024-02-29 11:03:45 +01:00
Rangi42 3da201b26e Give explicit test output if the scramble-romx size is wrong 2024-02-26 18:26:17 -05:00
Sylvie b66212e6d6 Fix fstack traces for macro nodes (#1318)
Since the lexer rewrite, MACRO nodes' fstack traces have not
included their parent REPT nodes' names.
2024-02-24 20:23:25 -05:00
Rangi42 d87b1ed22a Refactor some redundant error/warning-printing code 2024-02-24 19:05:29 -05:00
Sylvie 595c066c2a Remove #include <stdbool.h> (#1317) 2024-02-24 10:51:46 -05:00
Sylvie 54d6a22d19 Build with pedantically standard C++ (#1309)
* Remove array designators (not standard C++)

* Build with pedantically standard C++
2024-02-23 16:46:53 -05:00
Sylvie c0d534f5ad No more flexible array members (not standard C++) (#1307)
* Replace FAMs with `std::vector`s (or one `std::string`) in four `struct`s

* Anonymous types declared in an anonymous union are also non-standard
  Only Clang complains about this (-Wnested-anon-types)
2024-02-22 16:22:37 -05:00
Sylvie 6d29d2a67e Simplify fstk_FindFile usage (#1310)
* Simplify `fstk_FindFile` usage

* Use `std::string` for `fstk_FindFile`
2024-02-22 13:14:38 +01:00
Rangi42 c70cecc24a Add missing license header 2024-02-21 19:20:10 -05:00
Rangi42 bba5b8a740 Remove unused struct definition 2024-02-21 16:42:14 -05:00
Rangi42 c0da9fa2bb Remove obsolete #undef fail 2024-02-20 20:15:34 -05:00
Rangi42 ee59f17ea1 Free all the charmaps after parsing 2024-02-19 09:00:15 -05:00
Rangi42 464000bca8 Clarify TODO comment 2024-02-19 08:49:12 -05:00
Rangi42 bc8fd8a6dc Separate union members for EQUS and MACROs 2024-02-19 08:49:04 -05:00
Sylvie 9cdd0b8a02 No more anonymous structs (not standard C++) (#1305)
This is one step to restoring `-pedantic` builds
2024-02-19 08:12:20 +01:00
Sylvie a02687a83e Fix behavior of non-ASCII bytes with INCHARMAP (#1308) 2024-02-19 08:09:55 +01:00
Rangi42 f00e57a0ed Log indiviual rgblink test variants 2024-02-18 19:37:19 -05:00
Rangi42 cd297e1f90 Remove unused rgblink function sym_ForEach 2024-02-18 18:46:07 -05:00
Rangi42 5e8c87cf82 .dockerignore is too trivial to license :P 2024-02-18 18:45:49 -05:00
ISSOtm a0ae37d580 Fix coverage script checking for .c files
This tripped `gcov`.
2024-02-19 00:30:43 +01:00
ISSOtm 18e83c17b4 Add a few more linker script tests 2024-02-19 00:23:08 +01:00
Rangi42 3860ab11c7 Reformat some deeply-indented lines 2024-02-18 18:14:13 -05:00
ISSOtm 1b08a12b26 Ensure that mid-section align 16 makes PC constant
This makes `align 16` a sort of `org`, which is *very* useful :)
2024-02-18 17:53:56 -05:00
ISSOtm 36dad4380e Honor alignment offset for ALIGN[16, N]
The *one* place where it was missed...
2024-02-18 17:53:56 -05:00
ISSOtm b100c8ebee Add several tests for linker script syntax
Fixes a slice of #1276
2024-02-18 23:25:58 +01:00
ISSOtm 0769694839 Report mismatched file better when diff fails 2024-02-18 23:25:58 +01:00
ISSOtm 4064e4a7a9 Only look for linkerscripts in the same dir as the asm file 2024-02-18 23:25:58 +01:00
Eldred Habert efaef7039e Make sure to detect Git info from *our* Git repo (#1303) 2024-02-18 17:08:30 -05:00
Rangi42 580b7ec5be Avoid links that just say "here" 2024-02-18 15:06:55 -05:00
Rangi42 bd56405aae Remove now-unnecessary indentation of code blocks 2024-02-18 15:02:17 -05:00
Rangi42 2dee0fc536 Refer to https URLs when applicable 2024-02-18 14:58:46 -05:00
Rangi42 26f150220b Update some contributors 2024-02-18 20:44:23 +01:00
Rangi42 289910fe83 Convert reStructuredText to Markdown 2024-02-18 20:44:23 +01:00
Rangi42 f1b6ef204d Fix some reStructuredText 2024-02-18 14:09:37 -05:00
Sylvie 8a49a0b714 Report "<stdin>" or "<stdout>" when using "-" as a filename placeholder (#1297)
Also fix a memory leak with `targetFileNames`
2024-02-18 17:07:25 +01:00
Sylvie c07f3da9a1 Provide guidance to remove the deprecated rgbasm flags (#1296)
* Explain to remove the deprecated rgbasm flags

* Rephrase deprecation warnings
2024-02-18 16:16:15 +01:00
Sylvie d71a161bc9 Phrase error messages as "Failed to", not "Could not" or "Couldn't" (#1298) 2024-02-18 14:52:31 +01:00
Sylvie ef0d973187 Truncate long format spec strings before using them (#1299)
Fixes #1293
2024-02-18 14:27:03 +01:00
Rangi42 a5ceaa3664 Use semicolons, not comma splices 2024-02-17 09:43:22 -05:00
Marcus Huderle a37285eae9 Fix two instances of possible infinite loops in the linker (#1292) 2024-02-08 11:46:04 +01:00
ISSOtm 8d48cc79a2 Update to Zlib 1.3.1 2024-02-08 11:08:08 +01:00
Rangi42 3741510108 Use rgbasm -I, not -i 2024-01-29 16:41:06 -05:00
Sylvie 66fd5a7062 Fix some usually disabled compiler warnings (#1286)
* Fixes from temporarily re-enabling more compiler warnings

* More edits suggested by cppcheck

* Fix hanging on append_yylval_string

* Fix FOR loop increment
2024-01-18 20:47:20 +01:00
Rangi d179f3ed28 Increment object file revision number to 10 (#1287) 2024-01-09 18:55:05 +01:00
Rangi42 eaed9eee5b Gameboy -> Game Boy 2024-01-03 11:28:02 -05:00
ISSOtm 08f3e360c9 Release v0.7.0 2023-12-31 13:18:52 +01:00
ISSOtm 0524eeb61a Remove .Tg macro
Downstream support seems to be too sparse for the time being,
not worth the tiny gain we get from it
2023-12-31 13:18:37 +01:00
Rangi b0f2f0ffd6 Allow fewer tRNS entries than PLTE colors (#1284) 2023-12-31 12:47:53 +01:00
ISSOtm 528a4c0b70 Get rid of macOS hack to try having the filesystem cake and eat it too 2023-12-30 23:20:04 -05:00
ISSOtm 6b559e99b2 Revert "Switch to using std::filesystem (#1235)"
This reverts commit cf62ff772f.
Some functions used by this break on macOS before 10.15,
which we want to keep supporting.
2023-12-30 23:20:04 -05:00
ISSOtm 93d1d85f94 Generate macOS static bins under correct name
168950855 only did one half of the job, lol.
2023-12-29 23:25:28 +01:00
Rangi 1f3985a164 Fix build compatibility for macOS 10.14 and below (#1280)
macOS 10.15 introduced full `std::filesystem::path` support.
Before that our use of it would cause the build to fail.
This was not caught because "-mmacosx-version-min=10.9" was only
being passed to clang++ for release builds.

This passes that flag in a new static CI test build, and introduces
a hack developed by @LIJI32 to silence the availability errors,
since we use features already available in macOS 10.9.

This means we are testing both "vanilla" building,
and building static binaries using the same configuration
as during release, which should help avoiding last-minute
surprises.
2023-12-29 22:47:11 +01:00
Ron Nelson dc5d3a7342 Fix "build from source" link in README (#1281) 2023-12-29 02:35:59 +01:00
Eldred Habert ccf9dcb851 Improve linker scripts a little (#1275)
* Allow for optional sections in linker scripts
  These are more useful for frameworks/toolchains.

* Check for an active mem region everywhere
  Do you like segfaults? Too bad!

* Allow the address to be floating in linker scripts
  Try and make the life of SDCC interop easier.

* Also validate alignment when floating

* Overhaul the linker script manual page
  Documenting the new features, but also restructuring the
  existing documentation to make the manual page (hopefully)
  easier to understand.
2023-12-24 23:29:11 -05:00
Rangi42 7b199d7550 Fix documentation for ATAN2's (y, x) argument order 2023-12-24 03:59:01 -05:00
ISSOtm 98cecaee9e Fix some formatting errors in man pages 2023-12-24 17:12:38 +01:00
Rangi d5cddb202c Update the man pages' dates and history (#1279) 2023-12-23 00:15:35 +01:00
Rangi42 09dbc50447 Some refactoring 2023-12-18 15:51:13 -05:00
Rangi fdd45ab1dc Improve linker script align (#1271)
An offset is now supported, and invalid values are no longer silently
truncated, aligning behaviour with other instances of the directive.
2023-12-18 07:16:48 +01:00
Rangi 39018174c5 Scramble banks from the end of the ROM (#1273)
This is more likely to test edge cases, such as having content in banks with their highest bit set.
2023-12-17 20:14:03 -05:00
RangiandISSOtm 5a3a215b0e Don't delete script.cpp after building (#1272)
Ensure consistency in linker script parser interface

Make the declaration and definition visible when compiling
so that the compiler can warn about inconsistencies.

Co-authored-by: ISSOtm <[email protected]>
2023-12-17 11:42:07 -05:00
Rangi 495d701022 Use RANGE macro to abbreviate begin/end pairs (#1269) 2023-12-11 14:10:20 -05:00
Rangi b886b7e611 Add LADX disassembly to test suite (#1265) 2023-12-11 18:21:38 +01:00
Eldred HabertandRangi42 fd78a9ae83 Port linkerscript parser to Bison (#1266)
Notable side effects:
* Use the standard-conformant MSVC preproc
* Add test for linker script INCLUDE
* Improve wording of placement conflict errors
* Fix errors from not newline-terminated files
* Teach checkdiff about the linker script doc
* Call linker script "commands" "directives" instead

---------

Co-authored-by: Rangi42 <[email protected]>
2023-12-11 02:29:37 +01:00
Antonio Vivace ab30690854 readme: improve wording on how to reach maintainers 2023-12-10 23:10:43 +01:00
RangiandEldred Habert 34b2543c8b Implement -X/--max-errors for RGBASM (#1262)
Co-authored-by: Eldred Habert <[email protected]>
2023-12-07 11:42:47 +01:00
Rangi 1fa289f2ee Add SameBoy's BootROMs to the test suite (#1264) 2023-12-06 22:37:59 +01:00
Rangi 22ff7ff101 Add PinoBatch's game Libbet to the test suite (#1260) 2023-12-06 10:30:11 +01:00
RangiandEldred Habert 1402615bc0 Refactor how Makefile invokes Bison for reusability (#1259)
Co-authored-by: Eldred Habert <[email protected]>
2023-12-01 13:29:05 -05:00
Rangi 6132b77c1e Add more tests for RGBASM code coverage (#1257)
* Add more tests for RGBASM code coverage

* Use C++ unnamed parameters, not `(void)` casting

* Fix crash in `sect_AlignPC` from #1253
2023-12-01 10:21:43 -05:00
Rangi cee3d1c859 Add more test coverage for RGBASM (#1256)
This also fixes two bugs: `-1 >>> 32` was -1 not 0, and `macro_FreeArgs` should have been called but wasn't.
2023-11-29 15:16:05 -05:00
Rangi42 b46aa0f55b colour->color, behaviour->behavior
These spellings are more common elsewhere in the codebase
2023-11-27 16:02:17 -05:00
Eldred Habert e1220d6fc6 Acknowledge Liji's contribution to RGBGFX
Make their help with #1241 more prominent, since it won't appear in the commit log
2023-11-27 18:04:30 +01:00
Rangi 2ebd7f2ea3 Allow negative alignment offsets (#1255) 2023-11-25 09:40:20 +01:00
Rangi 756f2866bb Refactor alignment spec parsing (#1253) 2023-11-25 00:06:05 +01:00
RangiandISSOtm 92836408cc Remove empty .out and .err test files (#1249)
Co-authored-by: ISSOtm <[email protected]>
2023-11-24 17:52:55 -05:00
ISSOtm c5721b749c Use proper style to document long opts
Correct mandoc style is to use `Fl \-`, not `Fl Fl`, apparently.
2023-11-24 21:41:21 +01:00
ISSOtm 6f0defbfe5 Fix shellcheck warnings in the test scripts
Making them more robust to changes.
We ought to automate this some day.

My version of ShellCheck (v0.9.0) errors on test/gfx/test.sh, though...
2023-11-24 20:54:28 +01:00
Eldred Habert f4463b1708 Honor -c with rgbgfx -r (#1254)
Fixes #1166
2023-11-24 13:19:04 -05:00
Rangi 39e85c6dec Document pre-ASMotor history and add links (#1252) 2023-11-24 18:54:33 +01:00
ISSOtm aa5b163944 Clean up RGBGFX's "SEE ALSO" section
Applying the previous fix there, plus reordering xrefs more usefully.
2023-11-23 18:10:45 +01:00
ISSOtm eb237ea4e1 Update link to Pan Docs gfx overview
"Rendering" is now a much lower-level description of the rendering
process, not exactly what we are looking for there :)
2023-11-23 18:08:18 +01:00
ISSOtm 27c1237daa Fix formatting errors in man pages
As reported by the following command:
mandoc -T lint man/* | grep -v "input text line longer than 80 bytes"
(One of them also showed up as a warning while setting up Debian packaging.)
2023-11-23 18:05:55 +01:00
RangiandEldred Habert a218622d73 Remove checkpatch, since it's tuned for C not C++ (#1250)
Co-authored-by: Eldred Habert <[email protected]>
2023-11-22 19:26:08 +01:00
Rangi 46e29de66f Implement ds align[alignment, offset] (#1181) 2023-11-21 23:57:47 +01:00
Rangi 6f0ffcf3e1 Remove deprecated RGBGFX options (#1246) 2023-11-21 23:30:34 +01:00
Rangi c7b39f094c Update the reverse color curve (#1241)
Based on SameBoy's "accurate modern" colour mapping.

Special thanks to @Rangi42 for her patience throughout development, @LIJI32 for researching the colour curve and helping with the creation of the reverse mapping (colour spaces are *fun*!), and @coffeevalenbat for testing :)
2023-11-21 19:41:18 +01:00
Rangi f5ae6a80f0 Rename the RGBGFX --output-* options to --auto-* (#1245)
Fixes #1243
2023-11-21 17:52:16 +01:00
Rangi42 482160ea04 Prefer rpn_isKnown(expr) accessor to expr->isKnown directly 2023-11-21 10:46:59 -05:00
Rangi42 ad62421264 Use rpn_isKnown wrapper outside rpn.cpp 2023-11-21 10:33:35 -05:00
Rangi 083a82f6d1 Implement rgbgfx -O (#1240) 2023-11-21 10:19:44 -05:00
Eldred Habert 99671b8eb5 Avoid building test support programs by default with CMake (#1244)
Copy CMake-built test executables to test directory

Fixes CI failures on Windows.
CI should also have failed on Unices, but it turns out
we instead merely hit the fallback that the `make` path
relies on (building those executables with `make`),
which fails on Windows since `make` is not set up to
find libpng.
2023-11-21 09:54:22 -05:00
Rangi 3c0879a3c6 Fix spurious truncation warning (#1238) 2023-11-20 22:51:51 +01:00
Rangi 232416b30d Fix the hack for File::c_str to work (#1242) 2023-11-14 13:38:18 +01:00
Rangi cf62ff772f Switch to using std::filesystem (#1235)
Allows better platform-agnostic path manipulation.
Also, using `std::optional` rather than empty strings allows
correctly handling empty arguments (treating them as such,
instead of acting as they were never passed).
2023-11-13 18:10:09 +01:00
Rangi e824e34526 Use an iterator template for enum sequence loops (#1228) 2023-11-12 09:19:19 +01:00
Eldred Habert d390db5c57 Remove references to C compiler from CI (#1234) 2023-11-11 20:50:36 -05:00
Rangi 31529524c8 Use some more C++20 features (#1231) 2023-11-11 20:47:53 -05:00
Rangi dde9f2bb79 Rename some RPN constants for consistency (#1230) 2023-11-08 21:30:27 +01:00
Rangi 5711c088e5 Add exact dates for history (#1233)
Citations (I think these would be excessive in the readme itself, but maybe the dates could have links?):

- Carsten Sørensen's ASMotor: <http://otakunozoku.com/RGBDSdocs/geninfo.htm>
- Justin Lloyd's RGBDS: <http://otakunozoku.com/rednex-gameboy-development-system/>
- Vegard Nossum's rgbds-linux: <https://github.com/vegard/rgbds-linux/commit/e895832b2b89cf341ef84ee43e70aaa41f002fed>
- Anthony J. Bentley's fork: <https://github.com/bentley/rgbds_/commits/?after=60451fd41fc6dd0446798c8598f5effaacc2d065+69> (prior to <https://gbdev.gg8.se/forums/viewtopic.php?id=81>)
- Rednex move: <https://github.com/gbdev/rgbds/commit/0588e42520c7882c27cd67fd3ac518f99fc93adf>
- MIT relicensing: <https://github.com/gbdev/rgbds/commit/1a5c423984ca6cce1cb0b6b2100836bf4aa56e84>
- Gbdev move: <https://github.com/gbdev/rgbds/commit/6eb284f99e7adb18dcad5e14bd619c08dfc864e6>

The "neutral name" is clarified as Rednex, since we still use that name elsewhere in the readme, the sidebar, etc.
2023-11-08 21:25:27 +01:00
Rangi 765ae3f484 Build a code coverage report with gcov and lcov (#1221) 2023-11-08 00:03:26 +01:00
Rangi f3dbf17b78 AUTHORS and more copyright comments are redundant with CONTRIBUTORS.rst (#1227) 2023-11-07 17:57:59 -05:00
Rangi 8eeb40cca8 Implement #"raw strings" (#1122)
Fixes #1121
2023-11-07 23:48:23 +01:00
Rangi 9fc088dcb0 Fix the FOR loop count formula (#1222) 2023-11-07 23:43:46 +01:00
Rangi 5379e51094 Make requested revisions to recent PRs (#1195) 2023-11-07 23:11:08 +01:00
Rangi 05a0905582 Fix the rgbgfx color curve (#1200) 2023-11-07 22:24:37 +01:00
Rangi 1e70e703a7 Build everything as C++ (#1176) 2023-11-07 21:45:56 +01:00
Rangi 78d83be2b2 Have the eqn preprocessor run on rgbasm(5) and rgbgfx(1) (#1225) 2023-11-07 18:08:13 +01:00
Rangi a28f32a8a0 Download libpng source from GitHub, not SourceForge (#1223) 2023-11-07 08:29:01 +01:00
Rangi42 7a1e052b58 Factor out one shared enum FileStackNodeType 2023-11-07 08:27:03 +01:00
Rangi42 02f9128d07 Make some changes noticed while porting to C++ 2023-11-07 08:27:03 +01:00
Rangi 6ac1dd8966 Fix RGBGFX -r with -d 1 (#1224) 2023-11-07 08:25:30 +01:00
Eldred HabertandRangi 968c6f7ab7 Compute height and width directly in tile units
Co-authored-by: Rangi <[email protected]>
2023-11-06 08:14:13 +01:00
ISSOtm 93285f8ea8 Fix use of input slice without dedup active 2023-11-06 08:14:13 +01:00
Rangi 28358b55fe Separate multiple instructions per line with :: (#1210) 2023-11-05 19:13:33 +01:00
Rangi 0afb6cd53c Reminder to update the Dockerfile version for a release (#1219) 2023-11-05 18:54:15 +01:00
Rangi 143e76b7e3 Output the map file summary at the top of the file (#1203) 2023-11-05 15:43:58 +01:00
Rangi f8af569680 Shorten license comments and consolidate an AUTHORS file (#1217) 2023-11-05 09:54:32 +01:00
Rangi 259ec58140 Implement ENDSECTION (#1211) 2023-11-04 23:41:17 +01:00
Rangi 99727cbe99 #!/bin/bash -> #!/usr/bin/env bash (#1216) 2023-11-04 23:37:34 +01:00
Rangi 46e67ee078 Remove deprecated RGBASM features (#1215)
- Escaped commas "\," inside strings
- `name: MACRO` syntax
- `__FILE__` and `__LINE__`
- `-H/--nop-after-halt` and `-l/--auto-ldh` on by default
2023-11-04 23:22:46 +01:00
Rangi 28d92b7be3 Update ucity for testing (#1212) 2023-11-04 10:23:27 +01:00
Rangi c869edd1d2 Implement SIZEOF and STARTOF for section types (#1205) 2023-11-03 08:50:04 +01:00
Rangi 8f3369fe29 Implement DS for linker scripts (#1206) 2023-11-03 08:47:22 +01:00
Rangi 477e9812d4 Actually use PNGCFLAGS to build rgbgfx (#1209) 2023-11-03 08:37:18 +01:00
Rangi 9e4b9e75e3 Sort symbols by address, then parentage, then index (#1186) 2023-11-02 23:58:25 +01:00
Rangi 55f946198b Update the ucity repo being tested (#1207) 2023-11-02 23:57:13 +01:00
Rangi 181512ad9d Implement INCHARMAP function (#1184) 2023-11-02 20:14:54 +01:00
Rangi 5a25c547ab Allow rgbgfx to generate a palette from a spec, without an image (#1192) 2023-11-02 20:12:48 +01:00
Rangi 0d72ba886b Consistent behavior with missing or incorrect parameters (#1179) 2023-11-02 17:40:40 +01:00
Rangi42 a64f28de5c Avoid using %# printf specifier 2023-11-02 17:38:10 +01:00
Rangi42 b4dbb5093a Warn when SGB compatibility is set without old licensee 0x33 2023-11-02 17:38:10 +01:00
Rangi e7d0428a2e Explicitly specify which files build with PNGCFLAGS (#1201) 2023-11-02 17:36:46 +01:00
Rangi bb7c34db65 Deprecate DEF-less definitions (#1193) 2023-11-02 10:18:59 +01:00
Rangi 02f06407b1 Correct documentation for rgbgfx -r (#1197) 2023-11-02 07:59:46 +01:00
Rangi 73e9aac135 Update the pret repos being tested (#1198) 2023-11-01 23:07:41 +01:00
Rangi 32bc68d06d Don't export anonymous labels (#1185) 2023-11-01 00:06:28 +01:00
Antonio Vivace a5d51b4330 readme: update email 2023-10-31 20:21:51 +01:00
Rangi 79948be3a0 Improve incorrect object file revision error (#1189)
Fixes #1118
2023-10-31 15:04:27 -04:00
Rangi42 ab42eb2c50 Document STRUPR/STRLWR as ASCII-only 2023-10-31 14:28:38 -04:00
Rangi42 45c2a5e4ec Consistently use uppercase hex digits 2023-10-31 14:28:38 -04:00
Rangi ae38ebaf6f Clarify documentation of RGBGFX deduplication (#1191)
Fixes #1169
2023-10-31 14:28:14 -04:00
Rangi 80bdc889f8 Revise documentation for rgbasm -p (#1190)
Fixes #1125
2023-10-31 14:27:59 -04:00
Rangi 84f3cb4075 ENDL restores the label scope from before LOAD (#1180) 2023-10-26 22:58:36 +02:00
Rangi 22def89760 Save and restore opt r on the stack. (#1178)
Fixes #1174
2023-10-26 22:54:42 +02:00
Rangi a15f1a52c7 contributing: update repository links (rednex -> gbdev org) (#1177) 2023-10-26 00:44:01 +02:00
QuinnandRangi42 944c5f0cd0 Implement order-independent purge (#1173)
Each symbol passed to purge is collected in a list before mass removal.
Fixes the issue described in gbdev/rgbds issue #1152.

---------

Co-authored-by: Rangi42 <[email protected]>
2023-10-25 22:34:56 +02:00
Antonio Vivace 7a39e9e569 Add dockerfile to build and run RGBDS (#1167) 2023-09-14 17:17:53 +02:00
ISSOtm cfe432ea65 Enforce that transparent colours take slot #0 in all palettes 2023-08-26 23:23:28 +02:00
ISSOtm 36bfeea8dc Silence spurious GCC warning 2023-08-26 22:57:06 +02:00
Damian Yerrick 7b3a05eea8 Add --only-free and --help options to test scripts (#1161) 2023-08-20 13:46:00 -04:00
Damian YerrickandRangi e1f0a13e5a Allow defining local labels for another scope (#1159)
fix #1157 for the following source code

```
section "hSAVE_locals",HRAM
func3.hSpam: ds 1  ; no longer produces an error
;.hEggs: ds 1      ; uncomment this to see the new error

section "demo",ROM0
func3:
  ldh a, [.hSpam]
  ret
```

Remove two errors:
- `Not currently in the scope of 'func3'`
- `Local label 'func3.hSpam' in main scope`

Add one error:
- `Relative local label '.hSpam' in main scope`

Co-authored-by: Rangi <[email protected]>
2023-08-20 02:29:53 +02:00
Eldred Habert e634888a50 Improve description of rgblink -O (#1162) 2023-08-19 11:52:09 +02:00
Eldred HabertandAntonio Vivace 168950855d Create statically-linked Linux binaries on release (#1148)
Co-authored-by: Antonio Vivace <[email protected]>
2023-07-08 22:04:00 +02:00
Robbi-Blechdose a2e0ac2872 Fix typos reported by lintian (#1147)
From https://mentors.debian.net/package/rgbds/#upload-1
2023-06-24 16:26:04 +02:00
ISSOtm 6d806238fb Improve bit rotation/shift explanations by using Unicode box diagrams
The existing explanations have proven confusing to many,
and presenting the instructions in a more visual manner should help a lot.

Additionally, the Unicode codepoints are typed as-is in the source,
because that allows much more WYSIWYG editing, and god damn it this is the year
two thousand and twenty three, if your man and/or terminal software does't
support Unicode, then what are you *doing*.
2023-06-17 12:38:52 +02:00
Evie a0dfa916e6 Fix off-by-one error in "scramble spec" validation (#1144) 2023-06-16 09:28:19 +02:00
Eldred Habert 9748524ef6 Fix incorrect options in RGBGFX zsh completions 2023-06-13 07:57:24 +02:00
Tian(Maxwell) Yang 718cfa133f Fix SRL [HL] Flags link 2023-05-23 08:29:40 +02:00
Rangi 4cadc6f0fe \en not \n is a newline in troff 2023-03-04 18:36:22 -05:00
Eldred Habert 2023d9ed99 Fix palmap option using wrong file name 2023-02-21 12:05:39 +01:00
ISSOtm 6828f7bf49 "Hook up" new releases' docs 2023-02-08 01:45:35 +01:00
ISSOtm 33a0857b8d Properly detect tiles with more than 4 colours
Fixes #1127, which was caused by a dumb logic error. Duh me.
2023-02-08 00:21:05 +01:00
Antonio Vivace 4e712807d7 funding: add GitHub sponsors 2023-01-19 22:07:14 +01:00
ISSOtm 2d15e40539 Fix WRAM0/WRAMX test
The previous test did not expect failure when trying to stuff
$3000 bytes into $2000-byte WRAM; this is now fixed, and we
also test the reverse now (that we cannot stuff more than
$1000 bytes into WRAM0 without `-d`/`-w`.
2023-01-07 22:20:42 +01:00
Eldred Habert 50aaa6524d Fix -w not coercing WRAMX sections to WRAM0
Fixes #1116
2022-12-21 23:43:57 +01:00
Rangi 01f1703dfb Preserve \@ through INCLUDE
Fixes #1112
2022-12-11 18:56:03 +01:00
Rangi 69a573923f Version 0.6.1 2022-12-02 22:48:37 -05:00
ISSOtm 7eb4ecea8b Remove use of std::filesystem
This appears to break compatibility with macOS 10.9
2022-12-03 01:51:14 +01:00
ISSOtm 599ce757a1 Force Windows builds to use our zlib and libpng
Otherwise we will have a few problems if, say, a system version was
detected and picked up instead of ours...
2022-12-03 00:58:50 +01:00
ISSOtm 75a07a90f8 Always initialise section->data to avoid an uninit read
The addition of SDCC objects required a change in the logic of
`mergeSections()` to dispatch based on `->data` instead of
`sect_HasData`, which implicitly assumes that `->data` is
always initialised (maybe NULL).
However, RGBDS sections did not do that!
2022-12-02 22:39:31 +01:00
ISSOtm ec2d1312ef Remove auto parameter to -flto
Not all supported compilers support the argument;
the move was a bit premature.
2022-11-15 19:49:04 +01:00
ISSOtm 03b6dd9321 Only cache dependency directories instead of whole test/
Otherwise, changes made to the test suite are not picked up
2022-11-15 19:49:04 +01:00
ISSOtm a16d3d6405 Fail RGBGFX test suite if support test programs fail to be built 2022-11-15 19:49:04 +01:00
ISSOtm 3e5cd8ce1a Use a special name for stdin/stdout in diagnostics 2022-11-15 19:49:04 +01:00
ISSOtm 6902387991 Allow rgbgfx - for stdin and stdout
Closes #1087
2022-11-15 19:49:04 +01:00
ISSOtm 62b4f2b264 Upgrade to checkout action v3
No code changes, just uses Node 16 instead of the
deprecated Node 12
2022-11-13 14:33:03 +01:00
Rangi 79748afdc4 Align the "; Next union/fragment" comments with their symbols 2022-11-06 23:55:15 +01:00
Rangi 32cb0558e4 Print "; Next union/fragment" between "pieces" in .map file
Resolves #1099
2022-11-06 23:55:15 +01:00
rlewicki 92b2ac3c8c Remove duplicated EMPTY label in case no bank memory is used 2022-11-03 19:54:21 +01:00
rlewicki 0e67298dff Fix indention when writing EMPTY label inside link output.c file 2022-11-03 19:54:21 +01:00
Robert Lewicki f6d218ed36 Fix regression tests failing due to invalid cache being restored (#1104) 2022-11-01 14:27:40 +01:00
1a9fc964df #1082 Add cache check for external repositories used during testing (#1100)
Co-authored-by: Rangi <[email protected]>
Co-authored-by: Eldred Habert <[email protected]>
2022-10-25 08:39:19 +02:00
ISSOtm 48248faab0 Suppress CMake project maintainer warnings in CI 2022-10-16 12:21:54 +02:00
ISSOtm 58181c2d73 Hoist common Windows dep grabbing code to a script
Function courtesy of @aaaaaa123456789
2022-10-16 12:21:54 +02:00
ISSOtm 0f86084e08 Rename actions folder as scripts
It's clearer this way.
2022-10-16 12:21:54 +02:00
ISSOtm c8e602dec1 Mangle the name of absolute sections
They are unlikely to be unique across files, actually
2022-10-15 23:16:04 +02:00
ISSOtm b168717e91 Update zlib to 1.2.13
1.2.12 is no longer provided by upstream anymore,
which fails Windows CI
2022-10-15 22:02:34 +02:00
ISSOtm 930c2ac328 Require Bison 3.0.0 in CMakeLists
We actually require that version, so be explicit about it
to provide better error messages.
2022-10-13 11:02:33 +02:00
ISSOtm 28737d5778 Enable GLIBCXX_ASSERTIONS in make develop
Not sure it's very portable, but this is only the dev config
2022-10-12 01:23:37 +02:00
ISSOtm 12ba057b4f Check that colour slot is non-empty before checking for gray-ness
This is otherwise UB, and trips a GLIBCXX assertion (when enabled).
2022-10-11 21:39:32 +02:00
ISSOtm 0e0876b17f Print addr ranges for empty blocks as well
Mirrors what sections do, for clarity & consistency
2022-10-07 16:04:02 +02:00
Eldred HabertandRangi b28eea24fc Update .github/workflows/create-release-artifacts.yaml
Co-authored-by: Rangi <[email protected]>
2022-10-04 12:50:46 -04:00
ISSOtm a1e59ddc3d Avoid -x c++ affecting ${PNGLDLIBS}
version.c doesn't link to anything from libpng, so it'll be fine
2022-10-04 12:50:46 -04:00
ISSOtm 3fbdba31bf Build macOS binaries as well for releases 2022-10-04 12:50:46 -04:00
ISSOtm d90a7e4302 Terminate RGBGFX when opening a file fails
`std::filebuf::open`'s result must be checked, though that's not obvious.
2022-10-04 13:58:05 +02:00
ISSOtm 7377a14245 Improve RGBASM's "input files" error messages slightly 2022-10-03 17:17:19 +02:00
Eldred Habert e2136d60b2 Print a more user-friendly error message for leftover diff marks (#1089) 2022-10-03 16:52:29 +02:00
ISSOtm 74e40654e6 Sync release docs CI workflow with master
We should look into reusable workflows, really.
https://docs.github.com/en/actions/using-workflows/reusing-workflows
2022-10-03 01:50:17 +02:00
Rangi f90857032c Version 0.6.0 2022-10-02 19:08:13 -04:00
Rangi 1653a9a3f2 Use -flto=auto 2022-10-02 13:50:35 -04:00
Rangi 3c049983f1 Fixed-point functions can take specific precision (#1086) 2022-10-02 16:56:08 +02:00
Rangi 8553b61a94 Fixed-point values can use all 32-Q magnitude bits (#1085) 2022-10-02 11:08:38 +02:00
ISSOtm ab12c474d2 Properly exclude GCC from macOS matrices 2022-10-02 02:50:38 -04:00
ISSOtm 8ccbd9dc36 Properly build and link against libpng
Doing it right this time.
Also bundling the newly required DLLs.
2022-10-02 02:50:38 -04:00
ISSOtm b8307432b8 Fix use of bitwise OR instead of logical
Thanks, Clang!
2022-10-02 02:50:38 -04:00
ISSOtm 80a62a8a03 Update CI target OSes
Remove platforms deprecated by GitHub Actions
Add new platforms supported by the same
2022-10-02 02:50:38 -04:00
Rangi bbe28faab4 Sort rgbgfx's -r option alphabetically 2022-10-01 21:22:39 -04:00
Rangi 106ad30e5a Allow fixed-point constants to have unsigned range (#1084)
For example with Q.4, $F0 is 15.0, which no longer warns
2022-10-01 23:32:34 +02:00
Rangi a1107fc5cf Refactor !!x to x != 0
Also limit comments and docs to single "!"s
2022-10-01 14:09:02 -04:00
Rangi 969412af24 Parse HEX palettes (#1081)
Addresses one item of #1065
2022-10-01 12:45:00 -04:00
Eldred HabertandRangi c10345f26d Comply with sym file spec (#1078)
Co-authored-by: Rangi <[email protected]>
2022-10-01 12:35:00 -04:00
ISSOtm 6fd5c94b27 Document gbc pal spec format
I *knew* I had forgotten something!
2022-10-01 10:48:40 +02:00
Rangi ddb1d0b6aa Parse GPL palettes, and fix PSP palette parsing (#1080)
Addresses one item of #1065
2022-10-01 10:46:13 +02:00
RangiandEldred Habert 08545643cf Only define @ and _NARG when they have values (#1073)
Fixes #1069

Co-authored-by: Eldred Habert <[email protected]>
2022-10-01 01:04:03 +02:00
Rangi 140c6b169e Patch pokecrystal to use embedded palettes 2022-10-01 00:51:14 +02:00
Rangi d86d24bdc1 Remove legacy support for generating a palette with unused colors
If you need an explicit set of colors, possibly including
unused ones, use `-c`.

Fixes #1062
2022-10-01 00:51:14 +02:00
Eldred Habert a1a919579c Add support for GBC palette dumps to -c (#1075)
Fixes #1063
2022-09-30 17:09:28 -04:00
Rangi a47da5f71f Deprecate __FILE__ and __LINE__ (#1072)
Unlike C, these constants are not convenient for logging in macros,
since they always report the same data (their location in the macro).

Fixes #1068
2022-09-30 19:48:30 +02:00
Rangi 68ad926279 Patch projects so CI will build (#1071)
Fixes #1070
2022-09-30 12:19:11 +02:00
RangiandEldred Habert dec4133e84 SECTION(symbol) returns the name of a symbol's section (#1066)
Fixes #963

Co-authored-by: Eldred Habert <[email protected]>
2022-09-30 01:59:33 +02:00
Rangi c35cb6ac32 Warning levels -Wunmapped-char=0/1/2 (#1061)
Fixes #1058
2022-09-29 18:14:04 -04:00
Rangi 023884d2b0 Redefine the trig functions to divide circles into 1.0 turns (#1060)
This makes their behavior consistent across Q settings

Fixes #1059
2022-09-29 10:57:29 +02:00
ISSOtm 3567faf395 Use backslash escape instead of "backwards slash" in man pages
The latter is in the "Lines" category, which seems inappropriate.
2022-09-26 09:45:25 +02:00
Eldred HabertandRangi 6502ed3919 Add -I as an alias for -i in rgbasm (#1056)
Co-authored-by: Rangi <[email protected]>
2022-09-26 03:42:30 -04:00
Rangi b1a241233e Preserve Unix line endings for .bash and .flags files (#1054)
Fixes #955
2022-09-25 11:18:44 +02:00
Rangi f88968ec20 Fix rgbasm -b and rgbasm -g (#1052)
Fixes #1051
2022-09-25 10:22:55 +02:00
Rangi 5ad8a8c958 Warn when a duplicate CLI argument overrides a previous one (#1053)
Fixes #1050
2022-09-25 10:04:30 +02:00
RangiandEldred Habert 2827374505 Use STD*_FILENO constants (#1055)
These are defined in platform.h, but not consistently used

Co-authored-by: Eldred Habert <[email protected]>
2022-09-25 10:02:53 +02:00
RangiandISSOtm b8385a50e3 Support -P/--preinclude to pre-INCLUDE a file (#1043)
Fixes #1041

Co-authored-by: ISSOtm <[email protected]>
2022-09-24 12:37:16 -04:00
ISSOtm 02923a67f3 Use tabs for indentation in map files
As requested by #1012
2022-09-24 12:58:48 +02:00
Rangi f5b1990604 Document that symbol interpolation works outside of strings too 2022-09-22 01:15:17 -04:00
ISSOtm 0794da22bc Clarify at-files documentation 2022-09-13 08:34:41 +02:00
Rangi 6df75f7af3 Summarize used and free space at the end of the .map file
Fixes #1046
2022-09-12 23:16:09 +02:00
Rangi 7ae23e6cdb Release 0.6.0-rc2 2022-09-08 17:07:47 -04:00
RangiandISSOtm 98a6dffbca Implement opt Q for fixed-point precision, and q literals (e.g. 12.34q8) (#958)
Fixes #957

Co-authored-by: ISSOtm <[email protected]>
2022-09-05 00:47:32 +02:00
Rangi 889302a9e2 Document the -H and -l flags
Fixes #1042
2022-09-02 08:43:41 +02:00
Rangi c01317e08d Only increment the unique \@ ID when it is first used per context (#1030)
This avoids changes to generated `\@` labels just by adding or
removing macros or loops which do not actually use `\@`.

Fixes #1019
2022-08-31 17:45:21 -04:00
Rangi a52a00a9ca macro_UndefUniqueID uses 0 to mean \@ is undefined 2022-08-30 16:50:34 -04:00
Rangi fa13611bbf Make comments more consistent
- Changes most `/* comments */` to `// comments`
- Changes `/**` block comments consistently to `/*`
- Adds consistent license comments to all files

Also renames `T_POP_SET` to `T_Z80_SET`
2022-08-30 07:51:32 +02:00
Rangi dca24a6d50 Test that OPT r fails immediately if the recursion depth is already exceeded
Fixes #1034
2022-08-28 22:21:24 +02:00
Rangi 4363ffcad4 Clarify the JR documentation based on its usage (#1032)
Fixes #1020
2022-08-28 15:42:04 -04:00
Rangi 14e6a79adc Deprecate the old macro syntax (#1025)
Fixes #1011
2022-08-28 15:22:21 -04:00
Rangi 7a2ee26792 rgbasm -r sets the maximum recursion depth (#1026)
Previously it set the minimum failure depth (off by one)

Fixes #978
2022-08-28 15:21:29 -04:00
Rangi 425339ccf6 Implement FMOD function for fixed-point modulo
Fixes #1021
2022-08-28 21:21:10 +02:00
RangiandEldred Habert 1a1f1365e6 Clarify the FOR loop documentation (#1031)
Clarify the FOR loop documentation

Fixes #1003

Co-authored-by: Eldred Habert <[email protected]>
2022-08-28 15:16:49 -04:00
Rangi f97139461c Clarify the linkerscript example (#1028)
* Clarify the linkerscript example

* Explain that backslash escape sequences are supported

Fixes #1006
2022-08-28 15:13:43 -04:00
Rangi 8207dc57b7 Add a -Wunmapped-char warning for characters not in the charmap (#1023)
Fixes #1022
2022-08-28 15:12:43 -04:00
Rangi d29057e747 Indent "SLACK:" to match the "SECTION" headers 2022-08-28 20:35:21 +02:00
Rangi f1b74fa610 Report empty space between sections in map file 2022-08-28 20:35:21 +02:00
Rangi c7a92d3104 rgblink -M omits symbol names from .map file 2022-08-28 20:35:21 +02:00
ISSOtm 0105779789 Fix incorrect Bash completions after --long-opt=
This is because `$COMP_CWORD` points to that `=` "word".
2022-08-10 08:44:41 +02:00
ISSOtm 9ef7954670 Fix some lint warnings in Bash completions 2022-08-10 00:16:05 +02:00
ISSOtm d7d524294b Fix shebangs in Bash completion scripts
Not that you are really supposed to run them stand-alone?
2022-08-09 22:32:18 +02:00
ISSOtm 12fed4c68e Harden Bash completion scripts against invalid states
Printing an error message is better than locking the shell up, honestly.
2022-08-09 22:30:50 +02:00
ISSOtm 3db3421f07 Correct wrong state transitions in RGBGFX Bash completion script
Isn't strinly-typed programming just lovely?
Fixes #1018
2022-08-09 22:28:12 +02:00
ISSOtm 92eb0a133b Allow rgbgfx -r to read an infinite amount of tiles without tilemap
Previously, indices would be wrapped after 256 even without a tilemap;
since RGBGFX can generate arbitrarily large tile data if `-N` is not used,
it should be possible to read those in.

Of course, this won't work if a tilemap is provided, but such "big blobs"
can't generate a meaningful tilemap anyway.
2022-08-04 20:50:08 +02:00
ISSOtm b02ccf8f4a Check before attempting to generate empty image
This causes a libpng warning then error, but print a better error message
Fixes #1016
2022-08-04 20:40:20 +02:00
ISSOtm 2e0991f32b Use proper 16-bit type for image reversing width
Fixes #1015
2022-08-04 20:40:20 +02:00
Eldred HabertandAntonio Vivace f3f2c2ca16 Improve object file format documentation (#1010)
Replacing the big pre-formatted text block with a list brings:
- Better accessibility, obviously
- Responsiveness
- Better formatting (bold, etc.)
- Sub-sections that can now be linked to
- Hyperlink cross-refs to other pages

The slight disadvantage is that `ENDC` etc. are now individual
list items, whereas they'd be better as part of the same item.
No big deal though, it was much worse before.

Some descriptions have been overhauled for clarity, and some
outright corrected (such as Assertions' "Offset" field).

Co-authored-by: Antonio Vivace <[email protected]>
2022-07-29 22:48:55 +02:00
ISSOtm 9ec8186ac6 Switch linkdefs from scattered arrays to an array of structs
The info is better organized this way
2022-07-19 19:11:02 +02:00
ISSOtm ab9945c1ee Avoid using fscanf to detect RGBDS object files
This function is made for text, e.g. accepts spaces, leading zeros, etc. before `%u`.
This way checks that the correct amount of bytes are read instead.
2022-07-19 19:10:58 +02:00
ISSOtm 18e4f132a8 Fix labels subtraction docs
Fixes #1009
2022-07-14 13:43:36 +02:00
ISSOtm 828b2adcdf Make RGBLINK able to link SDCC object files
This requires a LOT of tricky code, mostly due to the format itself being,
er, not the most straightforward.
Everything is converted to existing RGBLINK concepts (sections, patches,
etc.), so the core code is essentially unchanged.
(A couple of genuine RGBLINK bugs were uncovered along the way, so some of
the core code *is* changed, notably regarding `SECTION FRAGMENT`s.)

All of this code was clean-roomed, so SDCC's GPLv2 license does not apply.
2022-07-11 21:17:34 +02:00
ISSOtm 1c2965467d Process linker script before doing sanity checks 2022-07-11 21:17:34 +02:00
ISSOtm d243e50390 Do not perform any sanity checks for bad section types
Otherwise, the arrays get overflowed
2022-07-11 21:17:34 +02:00
ISSOtm acb33777c6 Sort RGB colors as specified in the docs 2022-07-10 12:36:10 +02:00
ISSOtm d15916b1bd Clarify sorting order of RGB colors 2022-07-10 12:32:57 +02:00
ISSOtm 28fcef0ecd Improve some wording slightly 2022-07-10 12:30:18 +02:00
ISSOtm b53c115ec2 Fix width and height being reported in wrong order 2022-07-10 12:14:24 +02:00
ISSOtm 6a51e39a5c Print error if reverse() fails to open a file 2022-07-10 11:55:56 +02:00
Antonio Vivace e348f70866 Remove funding options, leaving only OpenCollective 2022-07-08 21:22:28 +02:00
ISSOtm 43a487f0bf Fix two inverted column widths 2022-07-02 17:48:28 +02:00
ISSOtm 6b2dc37f43 Release 0.6.0-rc1 2022-07-02 17:08:54 +02:00
ISSOtm 2b83a81ceb Update completion scripts
Also correct minor blunders in the man page
2022-07-02 17:04:17 +02:00
ISSOtm ca8693690a Cancel -U option
As it turns out, it is really difficult to implement, and can be dealt with later.
2022-07-02 17:04:17 +02:00
ISSOtm 87092208bc Stop passing options.columnMajor explicitly everywhere 2022-07-02 17:04:17 +02:00
ISSOtm 0d32775a1f Add more sanity checks when reversing an image 2022-07-02 17:04:17 +02:00
ISSOtm 0df07d3688 Add note on supporting extra pal formats 2022-07-02 17:04:17 +02:00
ISSOtm 3f70372308 Implement slicing input image 2022-07-02 17:04:17 +02:00
ISSOtm 9646f15b59 Add error message for nigh-impossible proto-palette overflow 2022-07-02 17:04:17 +02:00
ISSOtm 973fbb91bc Improve error message when a tile has too many colors 2022-07-02 17:04:17 +02:00
ISSOtm 903862c451 Improve flag set generation of RGBGFX tests
Less duplication = good
2022-07-02 17:04:17 +02:00
ISSOtm 3f5983358c Add proper error message for bad manual palettes 2022-07-02 17:04:17 +02:00
ISSOtm 7a7126f3b8 Implement bit flipping with a lookup table
Should improve performance.
This version is cooler, and also does not suffer from iteration limits
2022-07-02 17:04:17 +02:00
ISSOtm b4dadd35b6 Use an iterator zip
Simplifies iterating over tiles and attributes at the same time
2022-07-02 17:04:17 +02:00
ISSOtm d9b1402ef8 Fix RGBGFX number parsing 2022-07-02 17:04:17 +02:00
ISSOtm 832e0ec972 Report position in color errors 2022-07-02 17:04:17 +02:00
ISSOtm caaf7a8444 Test VRA0 size as well in randtilegen tests 2022-07-02 17:04:17 +02:00
ISSOtm a5ed0292b1 Reject colors with ambiguous alpha channel 2022-07-02 17:04:17 +02:00
ISSOtm 05e36767b0 Implement "palette map" output 2022-07-02 17:04:17 +02:00
ISSOtm 531092f5bd Add corrupted PNGs to check error handling
This is not intended to test libpng as much as checking that
we behave correctly if libpng gives us an error
2022-07-02 17:04:17 +02:00
ISSOtm 4c51792f15 Allow testing RGBGFX with specific images as input
No such tests yet, but the infrastructure will be there.
2022-07-02 17:04:17 +02:00
ISSOtm c4359c1058 Ignore -b and -N when reversing without tilemap
These offsets should only be applied to a tile ID read as input... but this ain't one!
2022-07-02 17:04:17 +02:00
ISSOtm 159efe1257 Transfer test programs as well for cross-testing 2022-07-02 17:04:17 +02:00
ISSOtm 3cfe7800c7 Make randtilegen and rgbgfx_test compile with MSVC 2022-07-02 17:04:17 +02:00
ISSOtm 01cf0c5f98 Print RGBGFX test names 2022-07-02 17:04:17 +02:00
ISSOtm 0dbcebfeb4 Have CMake build and install steps be verbose 2022-07-02 17:04:17 +02:00
ISSOtm 491b6746ab Clean RGBGFX test programs with make clean 2022-07-02 17:04:17 +02:00
ISSOtm cbf6fadcdb Add RGBGFX tests 2022-07-02 17:04:17 +02:00
ISSOtm a77b0b396a Fix grayscale sorting not setting palette size
A black+white palette would turn into white+transparent, removing black pixels
from the palette (the third slot would be empty, and the 4th slot be set directly)
2022-07-02 17:04:17 +02:00
ISSOtm 568fb5e4c8 Only report "fusing" different colors once per pair 2022-07-02 17:04:17 +02:00
ISSOtm 82012f698e Fix alpha channel checking in RGBGFX test driver
Compare CGB colors only, including ignoring RGB components if alpha says
the color is transparent
2022-07-02 17:04:17 +02:00
ISSOtm 57ac07b03e Correctly handle fully-transparent tiles when outputting unoptimized tilemap 2022-07-02 17:04:17 +02:00
ISSOtm c521233499 Fix ProtoPalette::compare
Some disjoint sets were mistakenly reported not as such
For example, {0} was considered to include {1}.
2022-07-02 17:04:17 +02:00
ISSOtm bf869f6961 Fix memory leak in test driver program
Teeny tiny
2022-07-02 17:04:17 +02:00
ISSOtm 0f8cbb1faf Generate all necessary files for RGBGFX tests 2022-07-02 17:04:17 +02:00
ISSOtm fcce42d3d2 Avoid sorting proto-palettes breaking mappings
The sorting was performed without updating the mappings, which broke the world.
We can instead sort the IDs as they are inserted into the packing queue,
which should also be faster than moving the actual proto-pal objects around.
2022-07-02 17:04:17 +02:00
EievuiandISSOtm ed104a9f70 Add rgbgfx test program
Co-Authored-By: ISSOtm <[email protected]>
2022-07-02 17:04:17 +02:00
ISSOtm f5d4126303 Report when an input "tile" contains too many colors
Which otherwise trips a later assertion in debug mode (phew!)
and crashes in release mode (oops)
2022-07-02 17:04:17 +02:00
ISSOtm 78e751f022 Fix reading interlaced PNGs
Either we let libpng handle the transform, or we don't.
But make up your mind!
2022-07-02 17:04:17 +02:00
ISSOtm d569c6392c Avoid initializing the PNG row
It gets overwritten right after, and uncovers an error in the interlaced read
2022-07-02 17:04:17 +02:00
ISSOtm 75b9d48990 Make randtilegen report the file names it fails to open
Which of the two is erroring out can be inferred from the file name,
anyway.
2022-07-02 17:04:17 +02:00
ISSOtm 3aabe9c799 Move randtilegen to test/gfx subdir
It's tool-specific, so categorize it where it belongs
2022-07-02 17:04:17 +02:00
ISSOtm 5be2b96b40 Remove incorrect check for reversed image width
That check was when the image width was in tiles, and another check right below
is the correct equivalent for the new pixel-unit argument
2022-07-02 17:04:17 +02:00
ISSOtm 7fdfbbbbba Fix inverted condition in tile dedup warning 2022-07-02 17:04:17 +02:00
ISSOtm 7fdc6cbced Fix erroneous tabs in rgbgfx usage text
Thanks @GreenAndEievui!
2022-07-02 17:04:17 +02:00
ISSOtm 56115653ef Include cross-ref link to at-files where mentioned 2022-07-02 17:04:17 +02:00
ISSOtm 7927dfd2e3 Remove negative values in parseNumber checking
Including removal of a dead & useless check.
By the way, fuck integer promotion.
2022-07-02 17:04:17 +02:00
ISSOtm b1aec91912 Assert that row size is not null
Silences some static analysis warning
2022-07-02 17:04:17 +02:00
ISSOtm 7defaad9d2 Remove placeholder palette output format from -p
This is now described in its own section
2022-07-02 17:04:17 +02:00
ISSOtm dc9185e50b Make output format descriptions more succinct and link to Pan Docs 2022-07-02 17:04:17 +02:00
ISSOtm 02d957278d Document output formats 2022-07-02 17:04:17 +02:00
ISSOtm 6feb1fb73a Retire -f 2022-07-02 17:04:17 +02:00
ISSOtm dc67f152a9 Document accepted external palette formats 2022-07-02 17:04:17 +02:00
ISSOtm 913c3dd711 Accept both colons and semicolons in inline pal spec 2022-07-02 17:04:17 +02:00
ISSOtm 32242e0ff2 Switch from colon separators to semicolon
As documented, oops
2022-07-02 17:04:17 +02:00
ISSOtm 91071009a8 Implement some external palette specs
PSP, ACT, and ACO are complete
2022-07-02 17:04:17 +02:00
ISSOtm 1da884db15 Handle processing errors appropriately
Alter the return status accordingly, and print the error counts on exit
2022-07-02 17:04:17 +02:00
ISSOtm ef473de75a Explicitly error out if no input image is given 2022-07-02 17:04:17 +02:00
ISSOtm 6b0cab32a6 Implement inline palette spec parsing 2022-07-02 17:04:17 +02:00
ISSOtm cc27169ecd Implement preliminary version of "reverse" feature
Not hooked to all RGBGFX flags yet, but good enough for most use cases
(and as a base for future development, should I need to `reset --hard`.)

TODOs marked appropriately.
2022-07-02 17:04:17 +02:00
ISSOtm 843022772b Clean up randtilegen
Apply review comments
2022-07-02 17:04:17 +02:00
ISSOtm 75f8b16f33 Implement "at-files" for RGBGFX
Useful for persisting flags outside of the build system
2022-07-02 17:04:17 +02:00
ISSOtm 188027bccc Rename convert to process
More consistent with its "main" function's name
2022-07-02 17:04:17 +02:00
ISSOtm 79adcdb7ea Ignore tested sub-projects 2022-07-02 17:04:17 +02:00
ISSOtm 8ed65078da Import fixes to random image generator 2022-07-02 17:04:17 +02:00
ISSOtm 7311fc9ef8 Fix transparency handling
Ensure that the color count is properly used, and that
transparency is not counted as a color when packing palettes
2022-07-02 17:04:17 +02:00
ISSOtm 7d54145e56 Record "seed" when generating images as well
For reproducibility
2022-07-02 17:04:17 +02:00
ISSOtm e753b62d1a Add program by @aaaaaa123456789 to generate RGBGFX-able images 2022-07-02 17:04:17 +02:00
ISSOtmandRangi 6ed220b4c1 Make some style corrections
Co-Authored-By: Rangi <[email protected]>
2022-07-02 17:04:17 +02:00
ISSOtm e49fb457ea Factor out row bitplanes extraction into a common function 2022-07-02 17:04:17 +02:00
ISSOtm 3c9d5b05d6 Implement transparency handling
Though none of this has been tested so far...
2022-07-02 17:04:17 +02:00
ISSOtm e86eb9337a Check the range of the CLI-specified palette size 2022-07-02 17:04:17 +02:00
ISSOtm b0f8e04fb7 Do not do anything if option parsing goes wrong 2022-07-02 17:04:17 +02:00
ISSOtm 493b94919f Fix -TAP being non-functional 2022-07-02 17:04:17 +02:00
ISSOtm 71e22f3bfe Correct "is this palette empty?" function
This notably caused decantation to delete non-empty palettes, which crashes
2022-07-02 17:04:17 +02:00
ISSOtm ac02382632 Clean up palette packing a bit
Rename a poorly-named attribute, and add a bunch of debug logging
2022-07-02 17:04:17 +02:00
ISSOtm 943d631701 Implement max palette count 2022-07-02 17:04:17 +02:00
ISSOtm d2f9cc7e8c Document accepted number formats 2022-07-02 17:04:17 +02:00
ISSOtm 76bb950be5 Parse bank capacities 2022-07-02 17:04:17 +02:00
ISSOtm f29c5d81ec Provide a per-option sane default when number parsing fails 2022-07-02 17:04:17 +02:00
ISSOtm 2307981878 Parse base tile IDs 2022-07-02 17:04:17 +02:00
ISSOtm 6bab2ea5c8 Add different verbosity levels
And also some ASCII art, perhaps?
2022-07-02 17:04:17 +02:00
ISSOtm 35e57a55c9 Handle base tile IDs in "optimized" output 2022-07-02 17:04:17 +02:00
ISSOtm 21e9a65f0b Remove old C headers 2022-07-02 17:04:17 +02:00
ISSOtm 779c8c9368 Implement -m
Though none of the code involved has been tested in any capacity yet, lol
2022-07-02 17:04:17 +02:00
ISSOtm e855b6f622 Include libstdc++-6.dll in 32-bit MinGW build 2022-07-02 17:04:17 +02:00
ISSOtm 3b1808cc8f Fix Windows-breaking use of struct vs class
MSVC's (broken) ABI breaks otherwise.
What the f@!$#ck, Microsoft?
(Thank you based Clang for warning, by the way.)
2022-07-02 17:04:17 +02:00
ISSOtm 71cb2854e8 Use cinttypes instead of inttypes.h
Fixes build on some compilers for some reason I fail to understand
2022-07-02 17:04:17 +02:00
ISSOtm 2099a25ee0 Avoid using transform_reduce
Not available in libstdc++ 7, apparently
2022-07-02 17:04:17 +02:00
ISSOtm b9de65c9a2 Set C++ compiler in CI as well
Duh
2022-07-02 17:04:17 +02:00
ISSOtm c82cce6d95 Explicitly specify queue template param
GCC 7 fails to deduce the contained type
2022-07-02 17:04:17 +02:00
ISSOtm 97965c9766 Revamp number parsing and remove <charconv>
Support all intended formats and allow partial parsing
<charconv> is not available in GCC 7
2022-07-02 17:04:17 +02:00
ISSOtm 5efc49cb12 Change UseTab to ForIndentation
This fixes many whitespace issues
2022-07-02 17:04:17 +02:00
ISSOtm c4361b965c Remove <filesystem>
Should fix compilation with GCC before 9
2022-07-02 17:04:17 +02:00
ISSOtm 8d00a61602 Flesh out man page
Describe current options, and add some TODOs for functionality to be implemented
2022-07-02 17:04:17 +02:00
ISSOtm 20442c8a43 Add compatibility hack for unused colors in indexed PNGs 2022-07-02 17:04:17 +02:00
ISSOtm b95c26c886 Fully implement decanting step 2022-07-02 17:04:17 +02:00
ISSOtm a96aa1725f Optimize AssignedProtos::empty() to stop early
Also allow counting an `AssignedProtos`'s number of proto-palettes
2022-07-02 17:04:17 +02:00
ISSOtm 3d79f76e41 Avoid calling skipEmpty() for AssignedProtos::end() 2022-07-02 17:04:17 +02:00
ISSOtm fdfedc45a6 Allow computing the combined weight of any proto-palette set 2022-07-02 17:04:17 +02:00
ISSOtm c98d92a4c4 Implement -C 2022-07-02 17:04:17 +02:00
ISSOtm d438838db4 Correctly handle "multiple" overlap between proto-palettes
As explained by the comment
2022-07-02 17:04:17 +02:00
ISSOtm d675523e49 Skip initializing the PNG pixel array
We are about to set all of the pixels anyway
2022-07-02 17:04:17 +02:00
ISSOtm ad07c9deb9 Implement (stub) handling for all options 2022-07-02 17:04:17 +02:00
ISSOtm bf9f99ebf5 Reorder Options members by usage order 2022-07-02 17:04:17 +02:00
ISSOtm f0eca86c52 Update checkdiff to check for gfx/main.cpp 2022-07-02 17:04:17 +02:00
ISSOtm e8d8ae4c78 Print all configuration on verbose startup 2022-07-02 17:04:17 +02:00
ISSOtm 0cc62824b9 Use MinGW C++ compiler as well 2022-07-02 17:04:17 +02:00
ISSOtm 2fb1eb9136 Print file paths in a platform-independent way
Conversion may be unspecified, but Windows better do the right thing (or else.)
2022-07-02 17:04:17 +02:00
ISSOtm bde380f38b Fix unchecked narrowing conversion of tile IDs
The conversion is OK because of the tile amount cap
2022-07-02 17:04:17 +02:00
ISSOtm 38e8024ffa Add missing return type for unreachable_() 2022-07-02 17:04:17 +02:00
ISSOtm 3bd6078537 Tag AssignedProtos iterator as forward
That's what it actually is, oops
(Required for `minmax_element`)
2022-07-02 17:04:17 +02:00
ISSOtm 5409d0d15a Add missing header for strcasecmp 2022-07-02 17:04:17 +02:00
ISSOtm 9262fefd07 Fix compiling with Clang
Force version.c to be compiled as C++ (bodge, will need a proper fix for `version.c`)
Remove user-defined `ProtoPalette` assignment operator (same as default, anyway)
2022-07-02 17:04:17 +02:00
ISSOtm 638d024040 Update subprojects and patch pokecrystal 2022-07-02 17:04:17 +02:00
ISSOtm 3fa1854332 Implement enough functionality to compile & match pokecrystal 2022-07-02 17:04:17 +02:00
ISSOtm 6e406b22bb Implement more features and fix bugs 2022-07-02 17:04:17 +02:00
ISSOtm d30e507270 Fix duplicated CGB color calculation in pal sorting
And also the inverted alpha channel condition causing the wrong colors
to be treated as transparent
2022-07-02 17:04:17 +02:00
ISSOtm 373a22660b Switch clang-format to C++17
Be consistent with what we settled on in code
2022-07-02 17:04:17 +02:00
ISSOtm 8c62e80c18 Reimplement basic RGBGFX features in C++
Currently missing from the old version:
- `-f` ("fixing" the input image to be indexed)
- `-m` (the code for detecting mirrored tiles is missing, but all of the
        "plumbing" is otherwise there)
- `-C`
- `-d`
- `-x` (though I need to check the exact functionality the old one has)
- Also the man page is still a draft and needs to be fleshed out

More planned features are not implemented yet either:
- Explicit palette spec
- Better error messages, also error "images"
- Better 8x16 support, as well as other "dedup unit" sizes
- Support for arbitrary number of palettes & colors per palette
- Other output formats (for example, a "full" palette map for "streaming"
  use cases like gb-open-world)
- Quantization?

Some things may also be bugged:
- Transparency support
- Tile offsets (not exposed yet)
- Tile counts per bank (not exposed yet)

...and performance remains to be checked.
We need to set up some tests, honestly.
2022-07-02 17:04:17 +02:00
DaKnig 34bc650341 Fix shebangs (#992) 2022-07-01 22:59:41 +02:00
ISSOtm 43ba7d0efb Explain to static analyzer that initial symbol creation cannot fail 2022-06-12 16:49:06 +02:00
ISSOtm 685ea5feed Fix RGBLINK leaking partial string at EOF
Does not really do much, but silences some static analyzers
2022-06-12 16:39:55 +02:00
ISSOtm f5ac268989 Fix unchecked realloc in makeUnknown 2022-06-12 16:36:35 +02:00
ISSOtm d51ab35203 Trim macro arg whitespace after line continuations 2022-06-09 00:07:27 +02:00
aaaaaa123456789 3a71910312 Update link to TPP1 spec in RGBFIX man page (#1004)
To match the repo transfer from late 2021.
2022-06-05 23:02:19 +02:00
ISSOtm ec25b4ac0e Disable -Winline
<@aaaaaa123456789> I mean, `-Winline -Werror` is the "make my builds fail at random for no reason" switch
2022-06-04 11:14:07 +02:00
ISSOtm 83222a8147 Fix "building from source" link in README
Fixes #1001
2022-05-27 11:56:52 +02:00
ISSOtm 97c326942f Warn about automatic instruction alterations
Step 1 of #986
2022-05-21 21:49:07 +02:00
ISSOtm b037d54f64 Remove deprecated symbols
Fixes #896
2022-05-21 21:45:06 +02:00
ISSOtm 80df6640e3 Update checkdiff to check new man page locations 2022-05-21 11:01:32 +02:00
ISSOtm 68d3ef8e76 Only test a few random padding values each time
It's unlikely that a specific value matters, though in theory possible;
however, an exhaustive test every time is really slow, and testing a couple
random values should, over time, cover everything.

It is fine to test random values because those tested will be logged,
so the problem can be manually reproduced later.
It does make CI technically not deterministic... but that should be fine.
2022-05-19 22:47:48 +02:00
Eldred Habert 01777c96c8 Link to rgbds-www repo in README
Should make it easier to find..!
2022-05-18 19:27:55 +02:00
ISSOtm 28f9183d80 Fix formatting of rgbasm -D documentation 2022-05-17 20:11:00 +02:00
ISSOtm 74c31f7c0f Update docs CI workflows to sync with new rgbds-www repo 2022-05-17 18:36:31 +02:00
ISSOtm 7e94ecbfe6 Move all man pages to a separate directory
Simplifies processing all around, and makes more sense
2022-05-15 13:34:35 +02:00
ISSOtm 0195196425 Cache built deps in Windows CI runs 2022-05-01 16:40:11 +02:00
ISSOtm 19c85a7c2e Update uCity commit to fix deprecation warnings
Cleaning up the logs!
See #991 for context.
2022-04-30 20:42:55 +02:00
ISSOtm 59e73e64ca Unconditionally output ROM0 even without any sections
Required for example when "overlaying" over a ROM and only patching ROMX.
Fixes #993
2022-04-30 14:27:36 +02:00
ISSOtm 972d06bb41 Fix gbdiff script
Fix issues with spaces in input filenames,
as well as a bunch more lint warnings.
2022-04-30 14:27:36 +02:00
ISSOtm e27da737c6 Print name of up to 10 floating sections on overlay error 2022-04-14 23:58:32 +02:00
ISSOtm e6ae1992fe Update zlib downloaded for generating releases 2022-04-01 12:46:44 +02:00
ISSOtm d9b46cdec9 Update CI builds to zlib 1.2.12
"Due to the bug fixes, any installations of 1.2.11 should be replaced with 1.2.12."
2022-03-28 09:10:04 +02:00
ISSOtm 570cd62b81 Update subproject commits and shallow dates
Added a comment to explain what to update those to, too
2022-03-13 14:43:27 +01:00
ISSOtm a4ead0c25f Freshen version number when building with CMake
Fixes #979
2022-03-11 09:21:08 +01:00
ISSOtm da66eeb40e Clean up lint warnings in deps install script
Also use a simpler way to remove the version number, lol
2022-03-10 00:06:32 +01:00
ISSOtm 0c4f1f8334 Add a shebang to the deps install script
Duh.
2022-03-10 00:03:54 +01:00
ISSOtm af70d555fc Remove signed check on unsigned variable 2022-03-09 08:40:49 +01:00
Eldred Habert e07bd92314 Have the eqn preprocessor run on rgbasm(5)
This is required for the built-in functions (L315-337), otherwise the math syntax doesn't get processed.

This magic line is detected by most `man` impls:
https://www.gnu.org/software/groff/manual/html_node/Preprocessors-in-man-pages.html
2022-03-08 22:11:49 +01:00
ISSOtm 9169028e57 Add .clang-format
Should not be followed for C files, to avoid mucking `blame`s,
but will be applied during the gradual C++ rollout, since that
will likely touch most lines in the codebase anyway.
2022-02-28 01:52:54 +01:00
ISSOtm 7dd8ba37f1 Allow changing recursion depth limit at runtime 2022-02-05 20:32:56 +01:00
Eldred Habert 6842c831fd Allow binary AND to be sometimes constant (#976) 2022-02-05 14:17:57 -05:00
Eldred Habert 6b903059fe Document endianness of dw and dl (#972) 2022-02-05 14:12:35 -05:00
ISSOtm eb5af70d79 Add unsigned right shift operator 2022-02-05 20:12:15 +01:00
ISSOtm cf19879281 Enable make develop on all Unix platforms
We are actually already doing it, so simplify the code
2022-02-05 20:11:25 +01:00
ISSOtm ac59ecf3c0 Enable -Wsign-compare and fix the warnings 2022-02-05 20:11:25 +01:00
ISSOtm 72b677a8d7 Enable "debug" optimizations in make develop
Enhances some warnings as well as the sanitizers (Clang especially complained about it)
The `-f*` flags are to get better stack traces out of the sanitizers, as recommended
by Clang's docs: https://clang.llvm.org/docs/AddressSanitizer.html#usage

GCC's docs claim that these optimizations should not hinder the debugging
experience, and Clang's don't mention optimization flags at all.
2022-02-05 20:11:25 +01:00
ISSOtm bbae9966e9 Fix string constness issues in RGBASM 2022-02-05 20:11:25 +01:00
ISSOtm b3304ae1ac Add more warnings to develop
As suggested by #969
2022-02-05 20:11:25 +01:00
ISSOtm a48801a675 Trim down develop warning list and add comments
Remove already-enabled warnings as pointed out by #969
Comments added to the CMakeLists because the Makefile format does not really allow them
"Plain" list also sorted alphabetically, the rest (somewhat) thematically
2022-02-05 20:11:25 +01:00
ISSOtm 7dc81a64d3 Make recursive Make invocations properly recurse flags 2022-02-05 20:11:25 +01:00
ISSOtm 3afa6b5a5a Use pedantic warnings in Makefile default config as well
We aim to be standard-conformant, and the CMakeLists already does it
2022-02-05 20:11:25 +01:00
ISSOtm 9b49f788e4 Add missing header in opt.h 2022-02-05 13:37:40 +01:00
ISSOtm acc31feaa1 Fix "shift" test to actually test RGBLINK 2022-02-05 11:39:10 +01:00
Rangi 4ed5ba7508 Finish using time_utc before initializing time_local
gmtime and localtime may share the same static internal struct tm,
so they cannot both be initialized and then used.
2022-01-27 22:32:34 -05:00
Rangi 20a26599a3 Simplify allocating multiple ds args
Dealing with indexes is only necessary for `strfmt`
2021-12-01 20:24:31 -05:00
Rangi 7bdfc9da23 Really don't use new as a variable name 2021-11-30 17:06:36 -05:00
Rangi d073cffa74 Don't use new as a variable name
It conflicts with the C++ keyword
2021-11-24 22:48:28 -05:00
Rangi 8435a29c4e Turn the readChars macro into a readInternal function
This macro was only used twice, and the second usage did
some unnecessary work.
2021-11-25 00:26:23 +01:00
Eievui b7fe78cad8 Fix improperly terminated region name check (#953) 2021-11-24 16:00:54 -05:00
Rangi 9d993d84e8 Release 0.5.2 2021-11-23 17:08:03 -05:00
ISSOtm fef168b2a5 Add the new completion scripts to checkdiff 2021-11-23 22:12:57 +01:00
ISSOtm 4a4b22c78c Add Bash completion scripts for the last 3 2021-11-23 22:10:08 +01:00
Rangi db79689e81 Add -Wnumeric-string to shell autocompletion 2021-11-22 17:58:12 -05:00
Rangi c2ca46c27d Remove TRACE_PARSER support
Attempting to build with this gave an "undefined reference to `yydebug'"
error (maybe a version issue with bison?), and I don't think it's been
used for recent parser debugging either.
2021-11-22 23:49:59 +01:00
Rangi aac839f389 Remove dbgPrint and TRACE_LEXER support
I have not found `TRACE_LEXER` to be useful in debugging
actual lexer issues.
2021-11-22 23:49:59 +01:00
Rangi 9d9febe1d3 Consistent title case for rgbasm.5 headings 2021-11-22 17:12:16 -05:00
Rangi b9fd85470e Reword docs now that SET is deprecated (#946)
- '=' constants are "variables" (not "mutable constants")
- EQU constants are "numeric constants" (not "immutable constants")
- EQUS constants are "string constants" (not "string equates")
- DS declarations are "static allocations" (not "variables")
2021-11-22 17:08:29 -05:00
Rangi ec6d63bce3 Allow underscores in gfx literals (#951)
Fixes #950
2021-11-21 16:18:23 -05:00
Rangi bdcef6f252 Refactor error reporting to simplify BSD-style err (#949) 2021-11-21 16:16:54 -05:00
ISSOtm 54293a9184 Remove unused "MAX_PATH" header
The header's name was also quite misleading.
Also remove an unused define in `asm/symbol.h`.
2021-11-21 18:32:29 +01:00
ISSOtm b04e71ed34 Use correct length type for Abs*Group 2021-11-21 18:28:42 +01:00
Rangi f82603f196 Lowercase "error:" in -Werror output 2021-11-20 11:21:46 +01:00
Rangi cedfd2582a Move more statements into for loop clauses 2021-11-19 22:55:20 -05:00
Rangi c7322258fc Refactor readGfxConstant for consistency, and edit warning message 2021-11-19 21:36:56 -05:00
Rangi 036b6c1b89 Capitalize "FATAL:" in rgblink error messages
"warning:" and "error:" are lowercase
This matches rgbasm's formatting
2021-11-19 19:52:57 -05:00
Rangi 8e2a164a32 Implement compound assignment operators for mutable constants
Fixes #943
2021-11-19 08:50:00 +01:00
Rangi b76819792d Deprecate SET in favor of =
`SET` is redundant with `=`, and is already the name of an instruction.
2021-11-19 00:05:49 +01:00
Rangi 3e945679ad Standardize on "east const" (type const * not const type *)
Avoid "WARNING: Move const after static - use 'static const char'"
2021-11-18 09:12:00 +01:00
Rangi efccf6c931 A few stylistic tweaks
- `goto free_romx` -> the more typical `goto cleanup`
- `goto fail` -> the more typical `goto finish`
- Remove a redundant `todo` variable
2021-11-17 23:51:40 -05:00
Rangi e5552e27f2 strrstr can take and return char const * 2021-11-17 22:47:05 -05:00
Rangi 438963fb24 Remove unused #include "extern/utf8decoder.h" (#940)
Fixes #937
2021-11-12 23:37:19 +01:00
Rangi 0bb815edc0 Implement -Wnumeric-string[=0|1|2] (#935)
Fixes #934
2021-11-12 23:09:35 +01:00
Rangi 55a02981b5 Small updates to documentation wording (#939)
Fixes #936
2021-11-12 23:06:02 +01:00
ISSOtm b06e3b239d Clean up -MT/-MQ code
Remove unreachable argument presence check (handled by `getopt`)
Merge allocation paths into a single `realloc` call
Avoid searching for string lengths multiple times
Tiny (compatible) change: no space between last dependent and colon if
`-MT` or `-MQ` is specified
2021-11-06 13:21:39 +01:00
Rangi 47442941b6 Support ! operator for condition codes (#720)
Fixes #719
2021-11-02 00:16:52 +01:00
DaKnigandISSOtm b16d2d0695 Add Bash completion script for rgbasm (#895)
* Add Bash completion script for RGBASM

Should have large feature parity with the Zsh completion

Co-authored-by: DaKnig <[email protected]>

* Register RGBASM Bash completion in `checkdiff`

Co-authored-by: ISSOtm <[email protected]>
2021-10-31 23:44:01 +01:00
EievuiandEldred Habert 8b1cc72f09 Added scramble flags to RGBLINK. (#921)
* Add scramble flags to RGBLINK

-S and -W will scramble ROMX and WRAMX respectively.

* Modify scramble CLI

CLI now takes a list of comma-separated values.
Added arg_error to clean up messages.

Co-authored-by: Eldred Habert <[email protected]>

* Document scrambling functionality

Co-authored-by: Eldred Habert <[email protected]>
2021-10-31 22:58:26 +01:00
RangiandISSOtm 11a6a81169 Implement -Wtruncation=level (#931)
* Implement -Wtruncation=level

-Wtruncation=0 is the same as the current -Wno-truncation.
-Wtruncation=2 is the same as the current -Wtruncation.
-Wtruncation=1 is the new default; it's less strict, allowing
N-bit values to be between -2**N and 2**N (exclusive).

* Implement generic "parametrized warning" system

* Test more `Wtruncation` variants

Co-authored-by: ISSOtm <[email protected]>
2021-10-31 17:47:31 -04:00
ISSOtm 0ce66009c1 Parallelize CMake builds 2021-10-31 22:01:35 +01:00
ISSOtm 33f2f555a6 Enable sanitizers with Clang on Ubuntu as well 2021-10-31 21:41:58 +01:00
ISSOtm 0487f9f841 Enable more checks in CMake builds on macOS 2021-10-31 21:17:51 +01:00
ISSOtm 0d6bfb84ce Ignore unknown warning options
GCC and Clang do not understand the exact same warning option sets
2021-10-31 21:17:51 +01:00
ISSOtm 1e4ace8974 Update tested subproject commits 2021-10-31 20:50:26 +01:00
Eldred HabertandRangi a378d1e8cb Reword label definition docs (#887)
* Reword label definition docs

A bunch of short sentences isn't very readable, this should be better

* Use correct wording for "computing difference"

Co-authored-by: Rangi <[email protected]>

* Explain how to define a label before mentioning local ones

* Move double-colon paragraph to make the explanation flow better

* Clarify what a label's value is

Co-authored-by: Rangi <[email protected]>
2021-10-31 20:20:57 +01:00
ISSOtm 81ea39effe Add two forgotten warnings to RGBASM Zsh completion 2021-10-31 20:16:03 +01:00
ISSOtm 1a07391a97 Introduce ARRAY_SIZE macro
Checked by `checkpatch`, and you know what? Not a bad thing
See https://github.com/gbdev/rgbds/pull/931#discussion_r738856724
2021-10-31 07:53:33 +01:00
Rangi b002d95459 Fix precison of fixed-point formatting
Fixes #908
2021-10-28 23:29:16 +02:00
ISSOtm 646fc62b89 Avoid running duplicate CI on macOS
`gcc` is just an alias to `clang` on macOS, so save on CI time.
2021-10-26 01:39:05 +02:00
ISSOtm 699c00dc20 Enable MacOS Big Sur in CI 2021-10-20 23:11:19 +02:00
Eldred Habert 9b9f3ffb96 Remove Ubuntu 16.04 from CI
It's been deprecated, see https://github.com/actions/virtual-environments/issues/3287
2021-10-05 22:24:24 +02:00
Eldred HabertandRangi 00a67c3fb2 Clarify xref to fmt spec
Co-authored-by: Rangi <[email protected]>
2021-09-09 15:08:52 +02:00
ISSOtm 50d6403c72 Move section interpolation to its own section
Fixes #907
2021-09-09 15:08:52 +02:00
Eldred Habert 9111157b82 Add NieDzejkob and JL2210 to contributor list
Significant contributions all around are worth acknowledging.
2021-09-09 14:53:34 +02:00
Eldred Habert 794dd6cd7e Mark Rangi and I as main contributors
I think we've earned it, at least for being maintainers for a couple years.
I believe the work done by those before us is more important (relicensing & cleanup),
but we've both made significant changes on top of what they made possible.
2021-09-09 14:37:23 +02:00
ISSOtm ae4352c198 Fix typos in rgbasm(5) 2021-08-23 18:39:19 +02:00
Rangi 4a73eb56ea Make peek() tail recursive instead of using goto
Compilation is identical with `gcc` or `clang`, -O3` or `-O2`
2021-08-18 01:30:47 +02:00
martendoandEldred Habert 0f321bc797 Fix section merge alignment error message (#919)
Co-authored-by: Eldred Habert <[email protected]>
2021-08-17 18:03:46 -04:00
ISSOtm 94d07c78d8 Fix MBC3+TIMER + handle lack of BATTERY
`TIMER & BATTERY` is 0, but even `|` would only be checking if
*either* is set; instead, imply BATTERY as soon as TIMER is given,
printing a warning if it was not given.
2021-08-12 10:20:09 +02:00
Rangi b51e1c7c2c Compare FOR ranges to Python's range 2021-08-01 10:45:44 +02:00
Rangi 26ddf1ff4d Prevent defining invalid local labels
Fixes #913
2021-07-30 15:21:47 +02:00
ISSOtm 20fd6eabbb Fix up gitignores
Move tests gitignore into its own directory
Use stricter patterns where they make sense
2021-07-25 12:15:56 +02:00
ISSOtm fbe29006d4 Document two two .github subdirectories 2021-07-25 12:12:36 +02:00
Rangi 03bb510588 endCapture shouldn't handle lexerState->atLineStart
`startCapture` did not initialize `lexerState->atLineStart`;
its final value is a consequence of the separate but similar
behaviors within `lexer_CaptureRept` and `lexer_CaptureMacroBody`.
2021-07-04 18:31:46 -04:00
Rangi 695dfe9dbd Add missing file line-continuation-string.asm
Also make some minor formatting corrections
2021-07-04 16:12:34 -04:00
Rangi 9782f7d942 Factor out endCapture to go with startCapture (#904)
This also refactors `startCapture` to modify the
capture body as an argument.
2021-07-04 16:08:59 -04:00
Rangi 1b5648bb06 Line continuations *do* work inside strings
The rgbasm.5(5) documentation was outdated here
2021-07-01 17:56:49 -04:00
Rangi a67f5d6e01 SIZEOF("Section") and STARTOF("Section") can be known
Fixes #890
2021-06-27 21:03:06 +02:00
Rangi 06b57aa1ce Avoid unnecessary "overwriting a non-zero byte" warnings
- Don't warn if the non-zero byte being written is the same as the original byte
- Add a `-O` / `--overwrite` flag to silence all such warnings

Fixes #897
2021-06-27 19:16:11 +02:00
Rangi 6d2db2ef64 make checkdiff does CI documentation checks (#900)
Fixes #744
2021-06-24 17:49:08 -04:00
Eldred Habert 9868a01163 Format -m help better in the man page
Use semantic macros instead of plain text
2021-05-30 13:59:02 +02:00
Eldred Habert 0c8cdd92d6 Make instruction descriptions more proper English
Use articles where appropriate
Use adjectives where it makes sense
2021-05-24 22:07:36 +02:00
Rangi 80a376f045 Syntax errors resets the lexer right away
`DEF`, `REDEF`, etc disable EQUS expansion, and reading
macro or OPT arguments sets the lexer to raw mode.
Syntax errors resume normal parsing at the line's end,
but should resume normal tokenization even before that.
2021-05-22 16:08:55 -04:00
Rangi 0068c1375c Syntax error message hints to indent macro invocations
This message is only printed for identifiers parsed as
`T_LABEL` (since they're at the start of a line) but
already defined as macros. Otherwise it may not be
relevant, e.g. for `MyLabel;:` or `My Label::`.
2021-05-22 14:58:26 +02:00
ISSOtm 872af9c7ed Remove dead store in linker script CRLF handling 2021-05-21 17:20:47 -04:00
ISSOtm 06ea7b20bf Reinstate "empty filename" assertion in __FILE__ callback
This assertion was mentioned by a comment, but deleted for some reason.
2021-05-21 17:20:47 -04:00
ISSOtm a3c4652bfd Fix dead stores in charmap_ConvertNext
Also cleanup / rearrange some of the function while we're at it.
2021-05-21 17:20:47 -04:00
Rangi 5ad48851ed Allow error messages for subsequent syntax errors (#892)
Fixes #891
2021-05-21 17:04:27 -04:00
ISSOtm e3b7339dd6 Save UNION stack when using PUSHS as well
This allows using the latter within the former
2021-05-21 09:47:27 +02:00
ISSOtm 69d7f84502 Reset LOAD offset when changing SECTIONs
This would cause spurious section overflow messages, since the load offset
is added to the section's when computing its size.
2021-05-21 09:37:17 +02:00
ISSOtm e970b6d6eb Update Zsh completions with CLI changes
Also fix some misc. issues with them, and fix an incorrect reported ID for MBC1
2021-05-15 19:21:39 +02:00
ISSOtm d9cce3fa1f Update TPP1 canonical name to "TIMER", not "RTC"
See previous commit
2021-05-15 19:13:24 +02:00
Rangi 23721694ea Comment that anonymous labels internally start with '!'
`startsIdentifier` should not accept this character so
anonymous labels won't conflict with nonymous ones.
2021-05-15 12:57:22 -04:00
ISSOtm aa02958e18 Fix mandoc warnings 2021-05-15 12:23:05 +02:00
ISSOtm 011d4ec392 Use the Ad macro for RST addresses
Sy has no semantic meaning, and Ad may fix how the "x" is rendered
in the HTML export
2021-05-15 12:03:20 +02:00
ISSOtm afbaf10185 Fix MBC help string
It's called TIMER, not RTC >_<
2021-05-15 11:25:09 +02:00
Rangi 6a5e2f439e Fix the STRFMT documentation in rgbasm(5)
Fixes #886
2021-05-09 17:23:57 -04:00
Rangi fba77c4dce Specify to update the release branch in RELEASE.rst
This is done manually after publishing a release.
2021-05-08 23:44:53 -04:00
Rangi 830df360ae Specify that all .sh files need Unix line endings
The `git config --global --unset core.autocrlf` command
was failing in the "Create release artifacts" workflow,
so this is an alternate method of fixing issue #841.
2021-05-08 23:22:31 -04:00
Rangi c75551b1b3 Release 0.5.1 2021-05-08 22:38:20 -04:00
Rangi 5a38f6e148 rgbasm supports "Q16.16" fixed-point literals
"Qm.n" signifies an m-bit two's complement integer
with n fractional bits.
<https://en.wikipedia.org/wiki/Q_(number_format)>
2021-05-06 23:17:08 -04:00
Rangi 869021f47d Fix -Wformat build warnings on macOS
C arithmetic promotes certain expressions to `int`,
so formatting has to use "%d" or "%x", not inttypes.h.

Fixes #883
2021-05-04 21:28:57 -04:00
Eldred HabertandRangi c06985a7ad Fix incorrect lexing of "$ff00+c" (#882)
Fixes #881 by moving the task from the lexer to the parser.
This both alleviates the need for backtracking in the lexer,
removing what is (was) arguably a hack, and causes tokenization
boundaries to be properly respected, fixing the issue mentioned above.

Co-authored-by: Rangi <[email protected]>
2021-05-05 02:04:19 +02:00
ISSOtm c502804192 Update winflexbison to 2.5.24
Updates Bison to 3.7.4, removing support for VS2015
https://github.com/lexxmark/winflexbison/releases/tag/v2.5.24
2021-05-05 01:57:16 +02:00
ISSOtm 75f1bcde31 Make SECTION size overflow non-fatal
Fixes #538
2021-05-04 15:34:20 +02:00
ISSOtm 60b85298a9 Fix all memory leaks in RGBLINK
At least all that were reported in the tests.
Partial fix for #709, that only leaves RGBASM to be fixed... oh boy!
2021-05-03 12:50:14 +02:00
ISSOtm 8bbafb7200 Rename out_ functions in section.c to sect_
More consistent with convention used everywhere, and makes it easier to
know which file the functions come from.
2021-05-03 12:22:14 +02:00
ISSOtm 75ce230dce Make UNION-related errors non-fatal 2021-05-03 10:57:14 +02:00
ISSOtm 1d01268249 Remove LOAD FRAGMENT
It's very troublesome, with flaky semantics and a very restricted use space.
2021-05-03 10:51:55 +02:00
ISSOtm 02cb5a0526 Avoid performing invalid actions on LOAD errors
These are rejected because they could lead to incorrect behavior,
so then don't do it...
2021-05-03 10:46:52 +02:00
Rangi 8397b3d8ec .sym file sorts symbols from zero-length sections first
This will, for instance, ensure that a zero-length
`SECTION "NULL", ROM0[0] / NULL::` comes first.
2021-05-02 17:57:20 -04:00
Rangi 296e5489c9 rgblink adjusts patches' PC offsets when merging FRAGMENTs
Fixes #869
2021-05-02 23:54:42 +02:00
Rangi 9ab9d0f39c Output all SECTION UNION/FRAGMENT symbols in .sym files
Fixes #809
2021-05-02 23:51:17 +02:00
ISSOtm 6e1a5dcc9d Add TPP1 support
Fixes #846
2021-05-02 19:09:53 +02:00
Jakub KądziołkaandISSOtm d360d03403 Enable address sanitizer in develop builds (#834)
Co-authored-by: ISSOtm <[email protected]>
2021-05-02 18:08:03 +02:00
Rangi e9bfe849ad Allow OPT to toggle -h 2021-05-02 11:06:53 +02:00
Rangi 665eb916a2 OPT L acts like -L and *dis*ables optimizing LD to LDH
Fixes #867
2021-05-02 11:06:53 +02:00
Rangi 04788e15af Fix a potential out-of-bounds array access in RGBGFX
This was caught by ASAN for pokered's gfx/battle/minimize.png.
2021-05-01 22:33:54 -04:00
ISSOtm dcb8c69661 Fix UAF in lexer capture
Fixes #689
2021-05-02 03:24:18 +02:00
ISSOtm cc6b70f1d5 Add option to list accepted MBC names and clarify man page
Referring to "Pan Docs names" skims over a lot of details.
Add `-m help` to list accepted names for clarity
2021-05-02 00:39:42 +02:00
ISSOtm 38a9a613da Make data output outside of a SECTION non-fatal 2021-05-01 23:48:48 +02:00
ISSOtm ad9a766a56 Allow dollar-prefixed hex for RGBFIX -m
Fixes #872
2021-05-01 23:48:23 +02:00
Eldred Habert 21b59c4651 Reinstate PUSHS clearing the SECTION scope (#870)
* Reinstate PUSHS clearing the SECTION scope

Otherwise you can use `PUSHS` to simulate the old `ds -21`, and possibly cause bugs

* Have PUSHS push LOAD block state as well

It does not make sense not to, and coud cause bugs.
2021-05-01 23:30:09 +02:00
ISSOtm 3ffdd50909 Test that RGBFIX does nothing when given no flags 2021-05-01 14:16:45 +02:00
Rangi ca36422ac9 Parse 'ld hl, sp - <e8>' correctly
Fixes #864
2021-05-01 11:08:01 +02:00
Rangi 8e4ba8d2e4 Allow REDEF for EQU constants
Fixes #853
2021-04-29 12:24:07 +02:00
Rangi ee67f1039c Fix REDEF EQUS behavior
Redefining an EQUS constant will now update its filename,
like redefining a SET/= constant.

Attempting to redefine as EQUS a non-EQUS constant will
print an appropriate error message.

This also standardizes on `sym` versus `symbol` as a
variable name (which pairs with `symName`).
2021-04-28 12:11:26 -04:00
Rangi d37aa93a7d Port some cleanup from the WIP 'strings' branch
This is mostly variable renaming
2021-04-28 11:58:56 -04:00
Rangi bba532193b Port some cleanup from PR #847
- Update some whitespace formatting
- Factor out some functions
- Free data after outputting to an object file
2021-04-28 11:58:56 -04:00
GreenAndEievui b4814b06b9 Updated RGBFIX to report when non-zero bytes are overwritten
Also updated many .err files with the new warning.
2021-04-28 11:57:43 -04:00
Rangi 4ee2eb845b Clone test repositories with earlier --shallow-since dates
The previous dates were not reliably downloading the
necessary commit IDs for checkout to work.
2021-04-27 17:27:23 -04:00
Rangi 3fdf01c0f5 Resolve some TODO comments
- `out_PushSection` should not set `currentSection` to NULL because
  PUSHS, PUSHC, and PUSHO consistently keep the current section,
  charmap, and options, even though the stack has been pushed.

- `Callback__FILE__` does not need to assert that `fileName` is not
  empty because `__FILE__`'s value is quoted, and can safely be empty.

- `YY_FATAL_ERROR` and `YYLMAX` are not needed since the lexer is
  not generated with flex.
2021-04-26 15:52:30 -04:00
Rangi 1949a61c6f Tested the ctz and clz shim functions
Their values match the GCC builtins for all
4,294,967,295 nonzero inputs.
2021-04-26 12:17:34 -04:00
Rangi 43cf20b155 Support Mac OS classic CR line endings in linkerscripts
This also refactors `readChar(file)` to `nextChar()` to be
more like the rgbasm lexer.
2021-04-26 12:05:36 -04:00
Rangi e27a6d53a0 Support character escapes in linkerscript strings
This allows linkerscripts to refer to section names even if
they contain special characters: '\r' '\n' '\t' '"' '\\'.
2021-04-26 12:05:36 -04:00
Rangi d17e9c663e Update the tested commits of pokecrystal, pokered, and ucity (#859)
These are the latest commits as of today. The pokecrystal and
pokered commits use rgbds 0.5.0 features; ucity does not but
is compatible with it.
2021-04-26 10:47:32 -04:00
ISSOtm dd8f396227 Fix compiler warnings
As reported in #789
2021-04-25 20:40:11 +02:00
ISSOtm b60853ea21 Fix RGBFIX option parsing on platforms with unsigned char
Such as Termux, once again.
2021-04-25 11:05:34 +02:00
ISSOtm b936ca27ab Enable _ISOC11_SOURCE
See #789
2021-04-23 17:07:52 +02:00
Rangi e050803ed1 Use size_t for measuring nested depths
Multiple functions involve tracking the current depth
of a nested structure (symbol expansions, interpolations,
REPT/FOR blocks, parentheses).
2021-04-23 14:28:10 +02:00
Rangi 27f38770d4 Parentheses in macro args prevent commas from starting new arguments
This is similar to C's behavior, and convenient for passing
function calls as single values, like `MUL(3.0, 4.0)` or
`STRSUB("str", 2, 1)`.

Fixes #704
2021-04-23 14:28:10 +02:00
ISSOtm db1f77f90b Correct "| operator" line not including the pipe 2021-04-23 14:24:53 +02:00
Rangi 4d21588eb2 Make invalid UTF-8 characters in strings non-fatal
STRLEN and STRSUB report the erroneous bytes

Fixes #848
2021-04-22 09:59:02 +02:00
Rangi e596dbfc80 Make failed macro arg expansions non-fatal
Expanding empty strings is valid but pointless;
macro args already skipped doing so, now other
`beginExpansion` calls do too.

This also fixes failed interpolations (which were
already non-fatal) to continue reading characters,
not evaluate to their initial '{' character.
2021-04-22 09:59:02 +02:00
Rangi 1aeaca2af6 Add test case sort-algorithms.asm
This combines 0.5.0 and post-0.5.0 features:
print and println, strfmt, for loops,
def assignments, redef equs, {interpolation},
new macro syntax, and \<bracketed macro args>
2021-04-20 22:36:56 -04:00
Rangi 267e4bc25c rgbds.7(7) shows an example of piping rgbasm to rgblink to rgbfix
This uses one line instead of three
2021-04-20 22:06:02 -04:00
Rangi c3e27217dd More specific "Symbol name too long" error messages
Identifiers, {interpolations} and \<macroArgs> are distinct
2021-04-20 17:14:21 +02:00
Rangi fe3521c7a4 Switch from parentheses to angle brackets
`\(` is more likely to be a valid escape sequence in the
future (as is `\[`) and `\{` is already taken.
2021-04-20 17:14:21 +02:00
Rangi b0f8d75d1d Shorten quine.asm with \(parenthesized) macro args 2021-04-20 17:14:21 +02:00
Rangi 7a314e7aff Support numeric symbol names in \(parentheses)
For example, \(_NARG) will get the last argument
2021-04-20 17:14:21 +02:00
Rangi 637bbbdf43 Support multi-digit macro arguments in parentheses
This allows access to arguments past \9 without using 'shift'
2021-04-20 17:14:21 +02:00
Rangi 8230e8165c Eliminate isAtEOF by changing yylex control flow
`yylex` calls `yywrap` at the beginning of the next call, after it
has set `lexerState->lastToken` to `T_EOB`.
2021-04-20 17:10:08 +02:00
Rangi a727a0f81f Capture termination status is equivalent to not having reached EOF
This avoids the need for a separate `terminated` flag
2021-04-20 17:10:08 +02:00
Rangi 7a587eb7d6 Use midrule action values for captures' terminated status
Bison 3.1 introduces "typed midrule values", which would write
`<captureTerminated>{ ... }` and `$$` instead of `{ ... }` and
`$<captureTerminated>[1-9]`, but rgbds supports 3.0 or even lower.
2021-04-20 17:10:08 +02:00
Rangi 7ac8bd6e24 Return a marker token at the end of any buffer
Removes the lexer hack mentioned in #778
2021-04-20 17:10:08 +02:00
Rangi be2572edca Track nested interpolation depth even outside string literals
Fixes #837
2021-04-20 09:37:29 -04:00
Rangi cf2bbe6435 Position -1 is the last character of a string
Position 0 is invalid, which matches with STRIN/STRRIN
returning 0 on failure.
2021-04-20 14:27:59 +02:00
Rangi dc5b7802c8 Make the len parameter optional in STRSUB(str, pos, len)
An unspecified length will continue to the end of the string.
2021-04-20 14:27:59 +02:00
Rangi b1e6c73197 STRSUB and CHARSUB allow zero or negative positions
These are offsets from the end of the string, as if the
STRLEN or CHARLEN respectively were added to the position.

Fixes #812
2021-04-20 14:27:59 +02:00
Rangi 459773b3f0 Update some whitespace after Hungarian prefixes were removed
Keep the parameter alignment and 100-char line limit
2021-04-19 16:47:39 -04:00
ISSOtm 6d0a3c75e9 Get rid of Hungarian notation for good
Bye bye it was not nice knowing ya
2021-04-19 22:12:10 +02:00
ISSOtm e35585960c Avoid generating CRLF'd release tarballs
Fixes #841
2021-04-18 23:19:22 +02:00
Rangi 3bea7930a9 Only update documentation for gbdev/rgbds
Prevent the relevant GitHub Actions from running on forks
2021-04-18 16:16:17 -04:00
Rangi 52797b6f68 Implement SIZEOF("Section") and STARTOF("Section") (#766)
Updates the object file revision to 8

Fixes #765
2021-04-17 18:36:26 -04:00
Rangi 5108c5643c Let charmap_ConvertNext advance its output pointer 2021-04-17 18:18:34 -04:00
Rangi 2005ed1df9 Implement CHARLEN and CHARSUB
Fixes #786
2021-04-17 18:18:34 -04:00
Rangi d43408f4f3 Allow OPT to modify -W
Warning flags are processed individually;
PUSHO and POPO (re)store all the warning states.
2021-04-18 00:11:18 +02:00
Rangi 2c30ab8731 Allow OPT to modify -L
-L is a Boolean flag option, so you specify 'OPT L' or 'OPT !L'.
2021-04-18 00:11:18 +02:00
ISSOtm 432c769d60 Release v0.5.0 2021-04-17 22:53:00 +02:00
Rangi 9923fa3eee Fix expansions that start from the end of another expansion (#839)
Do not free an expansion until its offset is *past* its size.
This means potentially freeing a nested stack of expansions
all at once.

Fixes #696
2021-04-17 13:14:40 -04:00
Rangi 750e93be3d Further simplify formatting code
- Remove redundant length checks before `memcpy`
- Coerce `sign` and `prefix` to boolean for `numLen`
2021-04-17 01:11:11 -04:00
Rangi ee5da4468d Fix interpolation/STRFMT overflow issues (#838)
Widths and fractional widths greater than 255 would overflow a
uint8_t and wrap around to smaller values.

Total formatted lengths greater than the avilable buffer size
would overflow it and potentially corrupt memory.

Fixes #830
Closes #831
2021-04-17 00:52:55 -04:00
Rangi 503c3b5364 Revert "Fix interpolation/STRFMT overflow issues"
This reverts commit 992be3fd9b.
2021-04-16 22:19:37 -04:00
Rangi 992be3fd9b Fix interpolation/STRFMT overflow issues
Widths and fractional widths greater than 255 would overflow a
uint8_t and wrap around to smaller values.

Total formatted lengths greater than the avilable buffer size
would overflow it and potentially corrupt memory.

Fixes #830
Closes #831
2021-04-16 22:00:17 -04:00
Rangi c755fa3469 readIdentifier does not process characters that get truncated
Previously a '.' could be past the truncation limit but still
cause the identifier to be marked as local, violating an
assertion in `sym_AddLocalLabel`.

Fixes #832
2021-04-16 21:15:01 -04:00
Rangi e78a1d5bfd readInterpolation is limited by nMaxRecursionDepth
Fixes #837
2021-04-16 16:10:46 -04:00
Rangi d2f6def2eb Remove unused function hash_ReplaceElement 2021-04-16 12:36:45 -04:00
Jakub Kądziołka 1ffd7cb5bb Make tests work on NixOS
Some distributions, such as NixOS and Guix, only have the /bin/sh and
/usr/bin/env binaries in standard locations.
2021-04-16 16:38:04 +02:00
Jakub Kądziołka 215e26b478 charmap: Store hashmap nodes in charmap stack
This helps update all the pointers during reallocation.
2021-04-16 16:00:26 +02:00
Jakub Kądziołka 8885f7bcf6 hash_AddElement: return the new node 2021-04-16 16:00:26 +02:00
Jakub Kądziołka 5334fc334e Don't report hashmap collisions
This doesn't seem to be very useful, and keeping this "feature" is
difficult.
2021-04-16 16:00:26 +02:00
Jakub Kądziołka f97663aa37 hashmap: add hash_GetNode 2021-04-16 16:00:26 +02:00
Jakub Kądziołka 08bdbd1949 Add an .editorconfig
This automatically sets up the formatting settings in a number of
editors, regardless of the user's preferences.
2021-04-16 15:56:57 +02:00
Rangi 5c852c7651 Store the nested expansions starting from the deepest one (#829)
This shortens the lexer by 100 lines and simplifies
access to expansion contents, since it usually needs the
deepest one, not the top-level one.

Fixes #813
2021-04-16 09:54:13 -04:00
Rangi 6be3584467 LexerState's 'size' and 'offset' for mmapped files are unsigned
These were using signed 'off_t' because that is the type of
'st_size' from 'stat()', but neither one can be negative.
2021-04-16 10:23:37 +02:00
Rangi 8c90d9d2d7 Get rid of skip in struct Expansion
This was only used to skip the two macro arg characters,
but shiftChar() can skip them before the expansion.
2021-04-16 10:23:37 +02:00
Rangi f69e666b00 expansionOfs cannot be negative
lexerState->expansionOfs is always either set to 0, or updated by
adding a positive quantity:

    if (distance > lexerState->expansions->distance) {
        lexerState->expansionOfs += distance - lexerState->expansions->distance;
        ...
    }

so it will always be positive or zero.
2021-04-16 10:23:37 +02:00
Rangi eba06404f0 peek(0) => peek()
This does not completely refactor `peek` as #708 suggested,
to make it shift and cache a character itself. However it
does simplify the lexer code.
2021-04-16 10:23:37 +02:00
Rangi 9558ccea1b shiftChars(1) => shiftChar()
Only two sites were for distances greater than 1:
a `shiftChars(2)`, trivial to just do two `shiftChar()`s;
and `shiftChars(size)` in `reportGarbageChar`, which
can be a `for` loop, and should be fixed anyway to
"avoid having to peek further than 0".
2021-04-16 10:23:37 +02:00
Rangi 260d372acd Lex $ff00+c without needing large peek lookahead
This also allows arbitrary amounts of whitespace in `$ff00 + c`,
instead of needing to fit in the 42-byte LEXER_BUF_SIZE
2021-04-16 10:23:37 +02:00
Rangi 4e1b0ce793 Rephrase CONTRIBUTING.rst
Fix #729
2021-04-14 21:19:54 -04:00
Rangi 363ee9578c Document the release process in RELEASE.rst
Fix #718
2021-04-14 21:13:37 -04:00
Rangi 8fa5a4255e Mention alternative mnemonics in gbz80(7)
Fixes #819
2021-04-14 16:59:31 -04:00
Rangi b3312886fb Use a lookupExpansion, but not as an X macro
Instead of defining `LOOKUP_PRE_NEST` and `LOOKUP_POST_NEST`,
pass a variable name and a block to `lookupExpansion`; it
will assign successive looked-up expansions to the variable
and use them in the block.

The technique of using `__VA_ARGS__` to allow commas within a
block passed to a macro is not original, and should be stable.
2021-04-13 17:58:46 +02:00
Rangi 7fc8a65d0a Refactor the lexer to not use the lookupExpansion X macro
This macro was only used twice, in `beginExpansion` and
`lexer_DumpStringExpansions`, with `getExpansionAtDistance`
already containing an inlined and slightly modified version
of `lookupExpansion` (retaining the `LOOKUP_PRE_NEST` and
`LOOKUP_POST_NEST` macros, but with both of them doing nothing).

Not using an X macro here makes the actual control flow in both
places more obvious, and I think the repeated code is acceptable
for the same reasons as the similar-but-distinct implementations
of `readString`, `appendStringLiteral`, `yylex_NORMAL`, and
`yylex_RAW`.
2021-04-13 17:58:46 +02:00
Rangi c278a361da Remove the unused calchash djb2 hash function
Note that hashmap.c uses its own FNV-1a hash function
2021-04-13 17:41:12 +02:00
Rangi a2f52867ad Rename print to printChar
This clarifies its usage, for printing a single character
in error messages.
2021-04-13 17:41:12 +02:00
Rangi ab79e6bede Change how print(c) formats reported characters
Printable ASCII becomes single-quoted, using backslash
escapes if necessary. Unprintable characters use 0xNN
formatting, without quotes.
2021-04-13 17:41:12 +02:00
Rangi 850c78aaf4 Report garbage chars as their bytes; don't try decoding them as UTF-8
This decoding required high lookahead, and was not even
consistently useful (the `garbage_char` test case was not
valid UTF-8 and so did not benefit from `reportGarbageChar`).

This limits UTF-8 handling to the `STRLEN` and `STRSUB`
built-in functions, and to charmap conversion.
2021-04-13 17:41:12 +02:00
Rangi c08cf783c8 Remove 'inline' from functions not in headers 2021-04-13 10:27:08 -04:00
Rangi 25a8518fbf Remove unused function removeLeadingZeros 2021-04-13 10:12:40 -04:00
Rangi 49174f4486 Define the UTC time components as EQU, not EQUS
Fixes #827
2021-04-13 10:11:21 -04:00
Rangi 81327b0d99 Merge branch 'master' of https://github.com/gbdev/rgbds 2021-04-13 09:31:35 -04:00
Rangi c0859e64f7 fstk_FindFile checks for sprintf failure 2021-04-13 09:31:05 -04:00
Rangi 3e0b7d428f Fix an unclosed file and unfreed memory in out_BinaryFileSlice
Use 'goto cleanup' in both out_BinaryFileSlice and out_BinaryFile
2021-04-13 09:19:59 -04:00
ISSOtm ba3428314b Add contact info for potential contributors
I'm going on a break, but I'll stay available if anyone wants to contribute.
2021-04-13 00:27:49 +02:00
Rangi bcb78f5d18 Define __RGBDS_VERSION__ as the output of rgbasm --version (sans "rgbasm")
Fixes #824
2021-04-09 19:42:48 +02:00
ISSOtm de7d1facf3 Add assertion that an expansion's total len doesn't overflow
Typically not needed because the recursion depth limit should prevent it,
but it might help debug weird lexer issues.
2021-04-03 18:31:30 +02:00
Rangi 310d34c655 Comment on REG_SP and REG_AF both being 3
No instruction needs to distinguish them both
2021-03-31 18:41:42 -04:00
Rangi 39c38f9838 Add a test case for unattainable SECTION UNION alignment
This test cases used to fail an assertion in `make develop`
2021-03-31 16:09:52 -04:00
Rangi 576b063519 Fix unattainable alignments to address 0
Fixes #818
2021-03-31 16:06:15 -04:00
Rangi 596e17ee61 Factor out a common strlen into beginExpansion
This avoids the possibility of `size` not matching `str`
2021-03-31 14:41:38 -04:00
Rangi 363b3d0134 Flush stdout after PRINTLN
This allows debug PRINTLN statements to run even if
subsequent rgbasm directives cause a crash.
2021-03-31 11:22:41 -04:00
Rangi c7ed9a275e Do not expand empty strings
Fixes #813
2021-03-31 10:21:04 -04:00
Rangi 49aac2961d Warn about backwards FOR loops with -Wbackwards-for (-Wall)
Fixes #816
2021-03-31 10:00:21 -04:00
Rangi 3741bd4617 Speed up the div-mod test case
Test various explicit cases, not nested `for` loops
over thousands of cases
2021-03-31 09:37:23 -04:00
Jakub Kądziołka 937c9888a4 Robustly disallow overwriting builtin symbols (#817) 2021-03-31 09:03:57 -04:00
Rangi 61a9bfd33c Some tests use the new macro <name> syntax
This happens to make quine.asm shorter
2021-03-31 00:00:18 -04:00
Jakub Kądziołka d08bcc455d Handle errors when opening source file
Before this commit, opening a file for which the user didn't have
permission resulted in a "Bad file descriptor" error.
2021-03-30 23:35:50 +02:00
Rangi aaa92659ea Require a plus sign in ld hl, sp + <e8>
Fixes #810
2021-03-30 13:05:21 -04:00
Rangi be877134e5 Remove support for ld bc/de/hl/sp for ld hl, bc/de/hl/sp
Fixes #811
2021-03-30 13:01:49 -04:00
Rangi d05703c692 Release 0.5.0-rc2 2021-03-28 17:15:44 -04:00
Rangi 5dbfafcc55 Update man page copyrights to 2021 2021-03-28 16:37:15 -04:00
Rangi a265b85d9d Report "1 error", not "1 errors", when assembly is aborted
This matches other such pluralized error messages
2021-03-28 15:55:32 -04:00
Rangi 28abf03c0a Output USED space, not FREE space, in the .map file
Fixes #808
2021-03-28 15:49:44 -04:00
Rangi 7e7f92f18c Assign section locations to all UNIONs/FRAGMENTs
Fixes the test case from #800

The `out.gb` output was corrected, since the two "test"
fragments have a different order in ROM than in SRAM.
It is effectively:

; ROM0[$0000], fragments ordered by size
    jr Label
    dw Label
    db 0

; SRAM[$a000], fragments ordered by .o order
    ds 1  ; db 0
    ds 2  ; jr Label
Label:    ; $a003
    ds 2  ; dw Label
2021-03-28 15:21:17 -04:00
Eldred Habert 7461170956 Add LOAD FRAGMENT pc test (#800)
Reproduces a reported problem, fix pending
2021-03-28 15:11:20 -04:00
Rangi 57d966d6e0 Merge pull request #804 from Rangi42/normal-backslash
Backslash in normal lexer mode must be a line continuation
2021-03-26 13:33:11 -04:00
Rangi 17752d7094 Backslash in normal lexer mode must be a line continuation
Macro args were already handled by `peek`, and character escapes
do not exist outside of string literals.

This only affects the error message printed when a non-whitespace
character comes after the backslash. Instead of "Illegal character
escape '%s'", it will print "Begun line continuation, but
encountered character '%s'".
2021-03-26 13:23:05 -04:00
ISSOtm 4216f0a9b0 Init top-level fstack node line number
It still gets written to the object file, generating Valgrind warnings
about using uninitialized memory. To silence those errors, and make
output more reproducible, init the line no to a dummy (0) value.
2021-03-25 11:26:58 +01:00
ISSOtm e3fde986ad Remove hashmap collision warning
It was only used to check hashmap collision rate in the wild,
but it no longer has a purpose and produces spurious messages
2021-03-23 21:34:08 +01:00
Rangi aa99ed056c Do not evaluate an untaken ELIF's condition
Fixes #764
2021-03-23 16:20:24 +01:00
ISSOtm 46d6652df1 Fix missing .sym/.map symbols in SECTION UNION/FRAGMENTs
Only the first "slice"'s symbols were considered, forgetting some symbols
2021-03-22 23:23:06 +01:00
ISSOtm 5406674cdd Install groff to build PDFs correctly in CI 2021-03-20 02:09:47 +01:00
ISSOtm 5d2e2e2182 Make docs update script also produce PDFs
See rgbds-www#12
2021-03-20 01:53:26 +01:00
ISSOtm a929f36bc5 Replace UTF-8 hyphens with ASCII ones in man pages 2021-03-20 01:25:17 +01:00
ISSOtm bdb84a901f Use sub-sections for the different symbol types
This will make them appear in the ToC, and generate HTML anchors for them
2021-03-19 11:04:22 +01:00
Rangi 093631ca0b Revise rgbasm(5) string symbol documentation
Clarify the differences between EQUS expansion and {interpolation}
2021-03-19 01:48:36 +01:00
Rangi 7e127a4e52 Don't expand string symbols in MACRO and FOR symbol names
Explicit {interpolation} can still achieve this, but
to match DEF, REDEF, and PURGE, these new directives that
define symbols do not expand string EQUS.
2021-03-19 01:48:36 +01:00
Rangi b8093847dc New definition syntax with leading DEF keyword
This will enable fixing #457 later once the old
definition syntax is removed.
2021-03-19 01:48:36 +01:00
Rangi 8d1b56bcf5 rgblink identifies patches' PC sections after reading all sections
Fixes #794
2021-03-18 23:53:54 +01:00
ISSOtm 5fb7fcf461 Fix description of rgbgfx -h
The old description was backwards and mostly confusing.
2021-03-18 15:35:01 +01:00
Rangi ee900ae7a3 Add a missing newline to a verbosePrint 2021-03-17 20:53:25 -04:00
ISSOtm 3ca58e13dc Fix verbose messages claiming non-existent errors
They were confusing when trying to debug other things
2021-03-14 18:52:16 +01:00
ISSOtm aaa4e17454 Add verbose messages for early exit from -MG
Should help debugging Make invocations
2021-03-14 18:28:05 +01:00
daid a81d383f75 Alignment mask was incorrectly checked for 1 instead of 0
This caused an `ALIGN[1]` to be ignored.
2021-03-11 13:24:59 +01:00
ISSOtm 60019cf476 Fix a bunch of Clang warnings
As reported by #789
Should avoid relying on 32-bit int (for implicit conversions)
and account for more extreme uses of RGBDS.
2021-03-10 10:56:57 +01:00
ISSOtm 5a6a44cbc1 Fix master documentation updater
Its path was not synced with a recent change
2021-03-10 01:15:51 +01:00
ISSOtm b61a187b19 Add forgotten __RGBDS_RC__ symbol 2021-03-10 01:09:18 +01:00
ISSOtm 6382f13647 Release 0.5.0-rc1 2021-03-10 01:04:23 +01:00
ISSOtm 714d39c86f Make some INCBIN errors non-fatal 2021-03-10 01:02:45 +01:00
ISSOtm f11241c2ae Add INCBIN tests 2021-03-10 01:02:45 +01:00
daid cb47ac8b97 Change the start position check on INCBIN
Currently INCBIN gives an error if your start position == file size.
This means you cannot include an empty file.
It also means the text of the error message is incorrect
(as the start is not greater, but equal to the length of the file)
2021-03-10 01:02:45 +01:00
ISSOtm 028e7af7d1 Prepare release candidates
We'll use "-rcX" instead of "-pre" to allow multiple ones, jic
Additionally, they will be able to be detected using __RGBDS_RC__
Finally, adapt everything version-related to this new system
2021-03-10 00:06:32 +01:00
ISSOtm e141da1d94 Compute fallback version string at compile time 2021-03-09 23:59:34 +01:00
ISSOtm 35367282e4 Add workflow to auto-prepare a release
Just push a tag beginning with "v" and a number to trigger it
2021-03-09 22:58:42 +01:00
ISSOtm 4c0fa6732e Fix release doc creation workflow 2021-03-09 22:58:42 +01:00
ISSOtm e9d9a44687 Make release doc update also register docs 2021-03-09 22:58:42 +01:00
ISSOtm 611bd46e0b Ignore CRLF vs LF for syntax error test check 2021-03-09 22:58:32 +01:00
ISSOtm e67254093e Delete version test if stale 2021-03-09 22:58:00 +01:00
ISSOtm 3ce3d2f662 Explicitly force tested projects to use tested bins 2021-03-09 22:56:59 +01:00
ISSOtm 3da9d81071 Ignore DLLs too
Since you may want to put them next to the EXEs here
2021-03-09 22:46:17 +01:00
Rangi 88646093ca Swap the Name and Type columns in Predeclared Symbols 2021-03-05 17:00:06 -05:00
Rangi 0a0427afbb windows-xbuild CI uses ubuntu-18.04 for its gcc 7.3.0 (#784)
GitHub's ubuntu-18.04 environment installs gcc 7.3.0.
The latest ubuntu-20.04 environment installs gcc 9.3.0.
Version 9.3.0 is incompatible with building libpng 1.6.37,
as of 2021-03-04.

Fixes #783
2021-03-05 11:27:12 -05:00
Rangi 88048cdcd7 Clarify the character encoding example in rgbasm.5 2021-03-05 10:08:43 -05:00
Rangi c878ff8775 Report slack totals at the end of the .map file (#781)
Fixes #777
2021-03-05 08:53:27 -05:00
dannye a4049a3f1b rgbasm(5): Clarify charmap behavior (#558) 2021-03-05 13:16:49 +01:00
Rangi 8a75cc5051 Test an indented anonymous label 2021-03-03 12:26:35 -05:00
Rangi b674c5fcaa Comment refers to "built-in" symbols 2021-03-03 10:35:47 -05:00
daid a6d3df7ac9 Put all local symbols in object/sym/map files (#774)
* Store all the local symbols in object files, not only the ones that need linker patches.
  This generates better map/sym files, and thus allows for better debugging as well.

* Add comments explaining the ->src and the (void)arg;
2021-03-03 10:59:51 +01:00
Rangi 365484ef18 Factor out handleCRLF()
This logic repeats ten times
2021-03-03 10:03:52 +01:00
Rangi 5e2bd35239 Factor out a 'plain_directive' parser rule similar to the reverted 'last_line'
Also expand on the comment explaining how the EOF-newline hack affects the parser
2021-03-02 20:46:17 -05:00
Rangi 6655e04ef0 Restore the "EOF-newline" lexer hack
This was removed in b3c0db218d
(along with two unrelated changes).

Removing this hack introduced issue #742, whereby INCLUDing
a file without a trailing newline can cause a syntax error.

A more proper fix would involve Bison's tracking locations,
but for now the EOF-newline hack fixes the issue while only
affecting some reported errors (expecting "newline"
instead of "end of file").

Fixes #742
2021-03-02 16:53:56 -08:00
ISSOtm 40c6b840f8 Add tests for certain directives at EOF without a newline 2021-03-02 16:53:56 -08:00
daid 5d6e0677d9 Fix error-related issues (#773)
* Mark `error` as a `format` function, to properly scan its format

* Fix the call to error() from parser.y:
  - Use '%s' to avoid passing an arbitrary format
  - Simplify yyerror overall

* Fix size parameter of %.*s format being an int... bonkers standard.

* Report the number of arguments required and provided on a STRFMT mismatch

* Add an assert to check for a very unlikely bug
2021-03-02 16:34:19 +01:00
Rangi 56071599e7 Allow trailing commas in bare lists
This applies to macro arguments, DB, DW, DL, DS,
PRINT, PRINTLN, EXPORT, PURGE, and OPT.

It also removes support for empty entries in DB/DW/DL.
(Deprecating it would require keeping parser support,
which is ambiguous with trailing commas.)

Fixes #753
2021-03-02 11:48:20 +01:00
Rangi c637447d5d Make the "db/dw/dl directive without data in ROM" warning more specific
Also use uppercase for DB/DW/DL to be consistent
2021-03-02 11:48:20 +01:00
Rangi ac2cefdd87 Refactor some math functions into a shared file for rgbasm and rgblink
Fixes #769

Fixes #770
2021-03-02 11:40:03 +01:00
Rangi 0774f5eb9d Rename math.c/mymath.h to fixpoint.c/.h
This also changes the functions' prefix
from "math_" to "fix_".
2021-03-02 11:40:03 +01:00
Rangi 76d8862900 Refactor part of getSection into createSection
getSection validates its parameters and calls
either mergeSections or createSection.
2021-02-28 16:12:03 -05:00
Rangi 1dafc1c762 Allow empty macro arguments, with a warning
Fixes #739
2021-02-28 10:38:49 -08:00
Rangi 63d15ac8c9 append_yylval_tzString should always evaluate its argument
Fixes #762
2021-02-28 10:38:49 -08:00
Rangi 1f579deaff Trim right whitespace from macro args before warning about length 2021-02-28 10:38:49 -08:00
Rangi fad48326f8 Support /* block comments */ in macro arguments
Fixes #746
2021-02-28 10:38:49 -08:00
Rangi e7d6ddf593 Fix linking tiny overlay files (#755)
* Fix compatibility of rgblink -O and -t

The -t "tiny mode" option makes ROM0 cover 0x8000 bytes,
not 0x4000. The -O "overlay" option fills areas uncovered
by sections with data from an overlay file. These needed
to cooperate so that the calculated uncovered overlay size
does not exceed the actual size of the ROM.

Fixes #754

* Print link test names like asm tests do

* Make the three test.sh scripts more similar
2021-02-24 23:04:51 -05:00
Rangi 953f79c0d9 Support 'MACRO mac' as well as 'mac: MACRO' for defining macros
The new syntax is used in documentation, but
the old syntax is not yet deprecated.
2021-02-25 04:42:35 +01:00
Rangi 3c5e1caa7c Disallow "." as a local label
Fixes #760
2021-02-25 04:40:42 +01:00
Rangi d4028fff10 Prevent ELIF or ELSE after an ELSE
Fixes #749
2021-02-25 04:39:49 +01:00
Rangi dd892d61d8 Correct rgbasm(5) about whitespace before labels
Also rephrase some more label-related documentation
2021-02-23 15:31:29 -05:00
Rangi a09f2d4115 Test an indented macro label 2021-02-23 14:48:27 -05:00
Eldred Habert dafef5a953 Remove column 1 restriction for labels with colons (#635)
Partial fix for #457
2021-02-23 14:42:24 -05:00
dannye 929e2a4490 rgbasm: Report conflicting file/line number for duplicate sections 2021-02-23 20:08:59 +01:00
dannye cc1129093d Add duplicate-section test 2021-02-23 20:08:59 +01:00
ISSOtm 72911ada2d Prevent non-numeric symbol from overriding refs
Fixes #751
2021-02-22 13:00:25 +01:00
Rangi 037bc7abb3 Add an rgblink test case for an $8000-byte ROM0 section with -t 2021-02-21 16:30:02 -05:00
Rangi 5fd636ac4b Implement floored / and divisor-sign % operators (#745)
Fixes #703
2021-02-21 16:14:44 -05:00
Rangi a6d844a9a5 Add more test cases for IF, REPT, and MACRO (#748) 2021-02-19 19:34:21 -05:00
ISSOtm bee62076c6 Allow ENDC at EOF without a newline 2021-02-20 00:51:33 +01:00
ISSOtm cd072d5e6a Add assertion check for potential UAF trigger
It actually currently triggers if an INCLUDE directive is given at EOF,
but #742 will fix that.
2021-02-19 16:53:30 +01:00
ISSOtm 6ef3ee1391 Give void* ptr to %p formatter
Silences a format type mismatch warning
2021-02-19 16:53:26 +01:00
ISSOtm c29b616f93 Fix forgotten initialization of lexerState->isReferenced 2021-02-18 16:33:06 +01:00
Rangi 39c179aa32 Fix missing newline in a dbgPrint 2021-02-17 13:14:02 -05:00
Rangi 5c1ae4ce22 Shorter quine test cases 2021-02-17 11:51:21 -05:00
Rangi efbfeca292 Avoid two peek(1) calls when lexing """multi-line strings""" 2021-02-17 10:36:36 -05:00
Rangi 7dd34f1572 Format INT32_MIN as '-2147483648', not '--2147483648' 2021-02-17 09:48:40 -05:00
Rangi 748e7dd4c7 Fix calculation of 2**30
In exponent(), 'base *= base;' should not run
when base is 65536, since it overflows an int32_t.

This also optimizes exponent() based on
gcc and clang -O3 test cases in godbolt.org.
2021-02-17 09:25:02 -05:00
Rangi d049ffc0f0 Handle string literals within macro arguments (#685)
Fixes #683 and #691

The lexer's raw mode for reading macro args already attempted
to handle semicolons inside string literals, versus outside ones
which start comments. This change reuses the same function for
reading string literals in normal and raw modes, also handling:

- Commas in strings versus between macro args
- Character escapes
- {Interpolations} and \1-\9 args inside vs. outside strings
- Multi-line string literals

Macro args now allow escaping '\', '"', and '\\'.

A consistent model for expanding macro args and interpolations,
within macro args, string literals, and normal context:

- "{S}" should always equal the contents of S
- "\1" should always act like quoting the value of \1
2021-02-16 22:44:25 -05:00
Rangi 8c0275480c Allow ds to take multiple values to repeat for a count (#725)
Fixes #722
2021-02-16 22:01:23 -05:00
Rangi 76d6ef8695 Implement LOAD UNION and LOAD FRAGMENT
Fix #632
2021-02-17 03:42:06 +01:00
Rangi c67a696a87 Use macros to convert between radians and fixed-point 65536ths 2021-02-16 18:07:05 -05:00
Rangi ee20d9010e Make @ relative to the start of a ds even at link time
Fix #737
2021-02-16 22:47:07 +01:00
Rangi 2bc12447e2 Update rgbds(5) object file format documentation (#740) 2021-02-16 16:36:37 -05:00
Rangi cb61da8842 -Wmacro-shift warns about shifting macro arguments too far (#741)
Fixes #735
2021-02-16 16:31:01 -05:00
ISSOtm 122ba6eba5 Update deprecated feature examples
Those have been removed, lol
2021-02-16 22:09:31 +01:00
Rangi dddff0f450 Cannot start a new section that's already on the stack
This is only relevant for FRAGMENT or UNION sections, since
normal ones would fail with "Section already defined previously".

Fixes #730
2021-02-16 21:51:48 +01:00
Antonio Vivace a919f922a1 Add FUNDING.yml to show the Sponsor button on the repository 2021-02-16 21:23:27 +01:00
Rangi 8f20620c16 Allow shifting macro arguments by a negative amount
Fixes #733
2021-02-14 16:21:00 +01:00
Rangi 96bce05be2 Newlines in multi-line strings update the line number
This affects error and warning messages, and dbgPrint
2021-02-14 16:16:52 +01:00
Rangi fc2bf3d11d Prefer sizeof($$) to MAXSTRLEN + 1
This makes `strsubUTF8` similar to `strrpl` and `strfmt`
2021-02-14 16:16:52 +01:00
Rangi 8415ce3ed0 Correct the keywordDict size
The stale keywords XDEF and GLOBAL were removed,
so there can be fewer keyword nodes.
2021-02-14 16:16:52 +01:00
Rangi ebb5aab6db Correct some comments
nPCOffset no longer exists, and the lexer only
returns T_NEWLINE for EOF in raw mode.
2021-02-14 16:16:52 +01:00
Rangi 464a3a4892 Separate extern getopt implementation from the unistd.h one
Fixes #710
2021-02-12 00:29:21 +01:00
ISSOtm 88e1cc7302 Make EOF token name consistent across Bison versions
The "end of file" name apparently only became a default recently
2021-02-11 13:04:43 +01:00
ISSOtm b3c0db218d Remove "EOF-newline" lexer hack
In preparation for an upcoming change
Makes for nicer error messages, complaining about EOF instead of newlines
The hack had to be kept for the lexer raw mode to avoid a bug;
see the relevant code comment for more info.
2021-02-11 12:48:37 +01:00
ISSOtm 76446e6d00 Change behavior of merging FRAGMENTs to constrain each fragment individually
Additionally, remove the deprecated merging of non-fragment SECTIONs
2021-02-10 10:19:16 +01:00
ISSOtm 6623b1dc45 Fix CI on macOS
Apple supplies version 2.3 (from 2006!!), which doesn't support `%empty`.
2021-01-23 13:45:12 +01:00
ISSOtm 70bbb098d3 Remove stale keywords
They were removed from the grammar, but not the lexer
2021-01-23 00:05:56 +01:00
ISSOtm 1926065377 Enable Bison warnings
-Wall should be old enough.
Also use %empty instead of comments
2021-01-23 00:05:56 +01:00
Rangi e3d355d976 Attempt to recover from syntax errors with bison
Fixes #595
2021-01-22 15:54:24 +01:00
ISSOtm a679e02246 Get rid of asm.h and localasm.h
No need to make them global
2021-01-22 13:34:16 +01:00
ISSOtm 592e9b3725 Reorganize and comment better main() 2021-01-22 11:09:27 +01:00
ISSOtm effc58241d Rework defining variables on command-line
Avoids allocating memory
Detects CLI errors even when failing to open file
Reports symbols as defined on command-line instead of input line 0 (!?)
2021-01-22 11:03:43 +01:00
ISSOtm 3697065afc Add asm/opt.c to CMakeLists
Fixes compiling with CMake
2021-01-22 11:01:33 +01:00
ISSOtm fa0fa4d5ac Significantly overhaul OPT code
Simplify the mess that was option setting (2 redundant variables !?)
Move options to a separate file
Have "modules" own their options, and OPT only access them (less redundancy)
Simplify code, respect naming conventions better
2021-01-22 10:41:09 +01:00
ISSOtm 5acc48fa54 Error out when given several input files
Also rename tzMainFile
2021-01-22 09:44:41 +01:00
ISSOtm 1487eebe79 Remove time counter
Nobody uses that, and it requires running extra code for each line
2021-01-22 08:51:57 +01:00
ISSOtm 993c034039 Avoid using EXPAND_AND_STR with external defines
There is no guarantee that they are purely numeric, use the values instead
2021-01-22 08:51:35 +01:00
ISSOtm 09f16bda4a Use putc instead of fputc
Also rename some functions for consistency
2021-01-22 08:32:28 +01:00
ISSOtm 41d544a4eb Rewrite RGBFIX
- Make it work inside pipelines
- Add RGBFIX tests to the suite
- Be more flexible in accepted MBC names
- Add warnings for dangerous or nonsensical input params
- Improve man page
2021-01-20 21:22:55 +01:00
Rangi f28b4abafc Fix a potential buffer overflow in strrpl
This caused an error using clang with -O3 -flto
2021-01-20 10:21:53 +01:00
ISSOtm ca1c934629 Have CMake use specified compiler in CI, not system default
Otherwise it's just GCC on Linux and Clang on macOS...
2021-01-19 16:35:06 +01:00
Rangi d5a00cf634 Comment cites the string hash algorithm (djb2)
"If you just want to have a good hash function,
and cannot wait, djb2 is one of the best string
hash functions I know."
2021-01-19 15:03:22 +01:00
Rangi fb39c3a70e Consistently refer to "directives", not "pseudo-ops"
Some docs and warnings already referred to SECTION and
db/dw/dl "directives", but others used "pseudo-ops".
2021-01-19 15:03:22 +01:00
ISSOtm 15ec6efc28 Fix missing newline in charmap override warning 2021-01-17 20:13:51 +01:00
Rangi 93d83e17dc Don't override bison's internal 'yytnamerr' function
This is not used in all bison versions, which causes a
"defined but not used" warning for the 'rgbasm_yytnamerr'
replacement, treated as an error by 'make develop'.
2021-01-15 11:51:31 +01:00
Rangi df16e64fc6 Handle MACRO and REPT/FOR bodies differently
Fixes #697
2021-01-15 02:16:37 +01:00
Rangi a4ebb87858 Add Rangi to contributors 2021-01-14 18:36:10 +01:00
Rangi 5ef8e0a1f6 Use an IELR parser if available 2021-01-14 18:36:10 +01:00
Rangi eb4952c188 Use more verbose syntax error messages
Fixes #385
2021-01-14 18:36:10 +01:00
ISSOtm 57b734a7df Reinstate RL into the _RS family
Removal of colon-less labels lifted the grammar ambiguity that
prevented `RL` from being usable as a variable declarator.
Thus, reinstate its functionality.
2021-01-11 01:38:03 +01:00
ISSOtm 5be1c0da62 Fix intra-section ALIGN not computing offset correctly 2021-01-09 23:29:08 +01:00
ISSOtm b598911e96 Enable LTO in release builds
Fixes #693
2021-01-09 20:31:15 +01:00
Rangi cab9cb06a3 Store IF depth relative to each fstack context
This disallows starting/ending an IF inside an
INCLUDEd file or a macro expansion
2021-01-09 20:12:14 +01:00
Rangi 62bea23c49 Implement BREAK to exit REPT and FOR loops
Fixes #684
2021-01-08 21:13:23 +01:00
Rangi 7ce5cf1595 Convert floating to fixed point by rounding, not truncation
Fixes #678
2021-01-04 21:23:43 +01:00
Rangi 7e3fc1db03 Fix Actions CI for MSVC
Fixes #616
2021-01-04 02:01:25 +01:00
Rangi 77279984a5 Implement STRRPL
Fixes #660

STRRPL(str, "", new) does nothing
(warn about it with -Wempty-strrpl)
2021-01-04 00:20:35 +01:00
Rangi 669a392fcd Revise the rgbasm(5) docs 2021-01-02 08:29:57 +01:00
ISSOtm 51ce0b038a Remove removed features from documentation 2021-01-02 02:47:13 +01:00
ISSOtm bd244e6865 Remove deprecated features
Trimming off the fat!
- GLOBAL and XDEF keywords
- Colon-less global labels
- *-comments
2021-01-02 02:42:44 +01:00
Rangi a70ecba06f Implement PRINT and PRINTLN (#672)
Fixes #669
Closes #368
Closes #624

Deprecate PRINTT, PRINTV, PRINTI, and PRINTF

Default STRFMT("%f") to 5 fractional digits like "{f:}"
Any use of string formatting will share this default
2021-01-02 02:37:32 +01:00
Rangi 9d2d5cfcfe Implement REDEF to allow redefining EQUS string equates
Fixes #677
2021-01-02 01:49:00 +01:00
ISSOtm 18f3c8ff9a Un-document deprecated _PI 2021-01-02 01:43:49 +01:00
Rangi 895ec5564d Update mathematical functions (#675)
Document the existing `ROUND`, `CEIL`, and `FLOOR` functions
Also update the trig function docs for searchability

Implement `POW` and `LOG`
Addresses part of #675

Implement ** for integer exponents
** has higher precedence than -, like Python, so -3**4 == -(3**4) == 81
2021-01-02 01:39:20 +01:00
Rangi 7bb6f71f0b Change FOREACH to FOR (#680) 2021-01-02 00:46:26 +01:00
Rangi 10e3f1a02b Deprecate built-in _PI
Fixes #670
2021-01-01 19:18:17 +01:00
Rangi 2a9d52871b Make dbgPrint in lexer.c report the correct colNo (#676)
Fixes #656
2021-01-01 18:44:47 +01:00
ISSOtm c4fb5591ee Fix size of unterminated REPT/FOREACH blocks
Do not "uncapture" ENDR if it was not read in the first place
2020-12-30 15:52:24 +01:00
Rangi c0ce1da4c3 Implement STRFMT and more printf-like format specifiers for string interpolation (#646)
Fixes #570
Fixes #178

Use errors for inapplicable format spec flags instead of -Wstring-format
2020-12-29 22:53:15 +01:00
ISSOtm aa27e714d4 Make Bison version detection more portable
- POSIX sh actually does NOT support `+=`,
  but Bash does even in compatibility mode
- `mawk` does not fully support POSIX EREs (regexes),
  so work around its lack of brace support
Fixes building on Debian, apparently.
2020-12-29 22:31:15 +01:00
Rangi 6874f694e5 Implement FOREACH (#658)
This acts like `REPT` with a variable automatically
incremented across a range of values

Fixes #432
2020-12-29 21:30:42 +01:00
Rangi 3690546795 make checkpatch and make checkcodebase check the same files
Only check src and include (not test), and
exclude src/extern and include/extern.
2020-12-29 20:27:00 +01:00
ISSOtm 7bc42d468b Clean up temp test files even if interrupted
Avoids "tmp.*" piling up in /tmp
2020-12-26 14:38:04 +01:00
ISSOtm 097999cad3 Prevent tests from running if RGBDS hasn't been built
Prevents a *lot* of spurious errors due to files not generating
2020-12-26 14:26:50 +01:00
ISSOtm f82edaa7ec Make gbdiff.bash handle CRLF sym files gracefully
Additionally, reduce the amount of lines piped through `cut`,
improving performance
2020-12-26 02:47:04 +01:00
ISSOtm d8e8b796e7 Update tested projects to latest commits
Compatibility fixes, etc.
2020-12-26 02:02:38 +01:00
ISSOtm 900fd8cabc Improve gbdiff script
Use better constructs where possible
- <<< instead of echo|
- Parameter expansions instead of `cut`
- Etc.
Improves performance and reliability somewhat

Also, accept "d" between diff line info parts
2020-12-26 01:44:45 +01:00
ISSOtm c20ac35074 Refactor readString
Much more readable, and avoids `peek(nz)`
2020-12-19 13:02:05 +01:00
Rangi 255b8bf9ba Implement """triple-quoted""" multi-line strings
Fixes #589
2020-12-19 12:34:32 +01:00
Rangi ad6f17cd93 Support SOURCE_DATE_EPOCH for reproducible builds
See https://reproducible-builds.org/docs/source-date-epoch/

Fixes #286
2020-12-19 01:09:45 +01:00
Rangi 063a22ddf9 LOAD blocks cannot create a ROM section
Fixes #576
2020-12-19 00:58:54 +01:00
Rangi 1d9cc01ae1 Macro arguments within a string literal are read into the string, not expanded
Fixes #643
2020-12-15 21:28:15 +01:00
Rangi f31deb5010 Fix STRUPR and STRLWR after 5aabb915ec
Fixes #647
2020-12-15 20:18:45 +01:00
Rangi 0956d300c4 Document \# 2020-12-14 10:48:03 +01:00
ISSOtm 4ef490f3cb Avoid interpreting Liquid in doc pages
They are auto-generated, so they wouldn't normally contain Liquid
(The post-processor may insert some, but it has control over the `raw` tags)
Some code introduced as examples contains `{{` due to nested brace expansions,
which was interpreted as (invalid) Liquid. This fixes such problems.
Additionally, Jekyll generates warnings about excerpts being part of a Liquid
block (the `{% raw %}`). This is fine, since doc pages don't use excerpts.
2020-12-14 10:35:30 +01:00
ISSOtm 8f2a894b88 Add anonymous labels
Fix #497
2020-12-14 10:14:40 +01:00
Rangi 0e40543757 Implement \# to expand to all unshifted macro arguments
Fixes #596
2020-12-14 00:12:36 +01:00
Rangi ce58f6d6be Allow {symbol} interpolation outside of strings
Fixes #629

Closes #631
2020-12-13 23:53:16 +01:00
ISSOtm 5aabb915ec Allow STRCAT to take any number of args
Fixes bullet point 1 of #625
2020-12-12 23:46:32 +01:00
ISSOtm 0d9de01f9d Make charmap-converting a non-UTF8 string non-fatal 2020-12-12 14:16:50 +01:00
ISSOtm f5b0eae9cd Remove custom action code when equivalent to default
Enables Bison to better reason about it, and should improve performance
2020-12-12 12:22:36 +01:00
Rangi e6552064bf Specify rgbfix --mbc-type by name
This supports the names listed in Pan Docs:
https://gbdev.io/pandocs/#_0147-cartridge-type
Spaces may be replaced with underscores.

It also supports "ROM" for "ROM ONLY".
2020-12-12 01:53:42 +01:00
Rangi 861cb552c4 discardBlockComment sets lexerState->disableMacroArgs = true, like discardComment 2020-12-12 01:34:01 +01:00
ISSOtm 417cceb0de Document dw and dl with strings 2020-12-11 11:02:20 +01:00
Rangi 165bd8cb71 Allow 'dw' and 'dl' to apply to characters of strings
Fixes #568

The old behavior of `dw "string"` can be replicated with `dw ("string")`; likewise for dl
2020-12-11 11:02:20 +01:00
ISSOtm e54e02dc77 Correct underscore-in-number documentation
No radix actually allows underscores at the beginning of a literal
2020-12-10 16:01:18 +01:00
ISSOtm 2bf3b08d76 Document underscores in numeric literals 2020-12-10 15:40:59 +01:00
ISSOtm 21b58b08b8 Fix not shifting CRLF at end of raw lines
Fixes line reporting errors on Windows
2020-12-10 15:37:50 +01:00
Rangi af530859f0 Allow underscores in numeric literals
Fixes #539

Changes \@'s output to start with "_u", not "_", so it will be valid within labels but not numerics
2020-12-10 15:34:21 +01:00
Rangi 58739b0bf2 Implement STRRIN, like STRIN but searching from the right 2020-12-10 15:32:17 +01:00
ISSOtm 3e4c2fe712 Avoid error with old Bison versions
`api.token.raw` is only defined starting with Bison 3.5
Since it's not essential, define it on the command-line iff the Bison
version is sufficient.
2020-12-10 15:13:45 +01:00
ISSOtm bdfce25db0 Avoid running version test when git describe fails
Can happen when not enough history has been fetched, notably in our CI
2020-12-10 13:43:22 +01:00
ISSOtm 2b6d9cd1e0 Avoid using yytoken_kind_t
Apparently it was added in a fairly recent Bison version...
2020-12-10 13:32:18 +01:00
ISSOtm bf789dd7b3 Add automated test for version consistency
Automatically check that the version number constants
(__RGBDS_MAJOR__ etc.) match `rgbasm -V`
Should avoid the problem with 0.4.2's release...
2020-12-10 12:22:29 +01:00
ISSOtm 9b6f01047c Enable raw token types
Removes one layer of indirection for the parser, and helps remove all literals from the grammar

The latter preparing the next change
2020-12-09 21:22:05 +01:00
ISSOtm 3fe2fa43bb Switch to GNU Bison as a dependency
First step for #595
2020-12-09 20:30:31 +01:00
ISSOtm ede982b50a Bump patch level appropriately
*HEADDESK*
2020-12-09 20:30:31 +01:00
ISSOtm 319d775c13 Add CI script to create docs on new releases 2020-12-09 16:08:43 +01:00
ISSOtm 44124319a6 Work around old Bison versions not forward-declaring yyparse
Notably, macOS still ships 2.3 (from 2008)...
Should fix #214
2020-12-09 16:00:22 +01:00
ISSOtm 462fd7539c Prohibit nested macros
After discussion (starting there:
https://github.com/gbdev/rgbds/pull/594#issuecomment-706437458
), it was decided that plain nested macros should not be
allowed.
Since #590 is fixed, EQUS can be used as a workaround;
multiline strings (#589) will make that easier on the
user when implemented.
Fixes #588, supersedes and closes #594.
Additionally, closes #388.
2020-12-09 10:44:39 +01:00
ISSOtm f16e34b804 Fix captures beginning in expansions
Fixes #590
2020-12-09 09:54:55 +01:00
ISSOtm c3ccdc548e Remove unnecessary flex dep from Dockerfile 2020-12-09 09:42:19 +01:00
ISSOtm fd721ca480 Document optional RB/RW/RL argument 2020-12-09 09:39:46 +01:00
ISSOtm eac365aef0 Allow argument to rb, rw and rl to be optional
Fixes #617
2020-12-09 09:31:47 +01:00
ISSOtm 4de6266442 Add explanation of how EXPORT works
Fixes #608
2020-12-08 21:07:24 +01:00
ISSOtm 213d985e17 Fix incorrect "sliced" INCBIN causing memory leaks
Oh, how I miss RAII...
2020-11-29 12:47:53 +01:00
ISSOtm de76dcb8fb Fix possible segfault from -MT and -MQ
Happened only if `malloc` failed, so...
2020-11-29 12:47:53 +01:00
Eldred Habert 30fb6bde5e Merge pull request #615 from ISSOtm/find-sym
Create specialized symbol finder functions
2020-11-25 15:17:34 +01:00
ISSOtm 4f842a1248 Create specialized symbol finder functions
The old "find symbol with auto scope" function is now three:
- One finds the exact name passed to it, skipping any checks
  This is useful e.g. if such checks were already performed.
- One checks that the name is not scoped, and calls the first.
  This is useful for names that cannot be scoped, such as checking for EQUS.
  Doing this instead of the third should improve performance somehwat, since
  this specific case is hit by the lexer each time an identifier is read.
- The last one checks if the name should be expanded (`.loc` → `Glob.loc`),
  and that the local part is not scoped. This is essentially the old function.
2020-11-21 01:06:17 +01:00
ISSOtm cc4d455b8a Add test for empty local label component 2020-11-21 00:58:40 +01:00
Eldred Habert 0bb5efebfd Merge pull request #610 from daid/stdin
Allow rgbasm and rgblink to use stdout and stdin as input and output
2020-11-08 01:20:44 +01:00
ISSOtm b6bf7ae620 Fix RGBLINK incorrectly reading file stack nodes
This caused node IDs to mismatch, yielding possibly corrupted file stacks
Worst part is, the docs mentioned the reading order had to be reversed...
2020-11-04 02:52:06 +01:00
ISSOtm dc96cc6d1e Add zsh completion scripts
Can't get bash ones to work, but these do.
2020-11-03 23:29:47 +01:00
daid 642daf1a76 Update main.c 2020-11-03 13:33:57 +01:00
daid 84edfb3d88 Update output.c 2020-11-03 13:33:02 +01:00
Daid 7e620bff81 Allow rgbasm and rgblink to use stdout and stdin as input and output 2020-10-26 20:28:15 +01:00
ISSOtm 0c55703438 Improve helpers.h
Use C11 standard _Noreturn instead of attributes (except, of course, MSVC)
Remove unused helpers
Avoid trapping in release builds, in favor of just unreachability
Improve shim when __builtin_* are not available
2020-10-26 15:19:31 +01:00
ISSOtm 6c57ad2226 Have make clean delete parser artifacts
Forgot to update the names there
2020-10-25 16:26:58 +01:00
ISSOtm 9028fb5391 Fix mistakes in RGBDS man pages
As reported by `mandoc -Wall`
2020-10-23 01:02:59 +02:00
ISSOtm 12dc49b60a Make page processor print usage only after reporting all bad opts 2020-10-23 00:40:05 +02:00
Eldred Habert 7e1d20acdf Merge pull request #607 from anderoonies/inline-comment-#537
handle inline c-like comments in lexer
2020-10-19 19:36:49 +02:00
anderoonies 5230104852 documentation for block comments 2020-10-19 18:05:37 +02:00
anderoonies 55be77be69 discard block comments delimited with /* */ 2020-10-15 12:42:53 -04:00
Eldred Habert 42b3a17356 Merge pull request #602 from NieDzejkob/shiftstorm
Report only one error when invalid shift has argument
2020-10-13 15:48:16 +02:00
Jakub Kądziołka 4e1d79081c Improve error message for negative shift arguments 2020-10-13 15:42:16 +02:00
ISSOtm 4ce4fdec71 Mention setting CMAKE_BUILD_TYPE to Release when using CMake
Not *necessary*, but if you don't know better, you should probably use it.
Fixes rgbds-www#9
2020-10-13 11:37:25 +02:00
Eldred Habert 05256946ac Merge pull request #604 from NieDzejkob/narg-overwrite
Don't overwrite symbol when it's not allowed
2020-10-13 10:47:57 +02:00
Eldred Habert 73396166aa Merge pull request #605 from NieDzejkob/invalid-labels
Don't consider difference of invalid labels constant
2020-10-13 10:42:05 +02:00
Jakub Kądziołka 4c5d5c7085 Don't consider difference of invalid labels constant
If a label is defined outside of a section, avoid trying to obtain its
value.
2020-10-12 23:03:14 +02:00
Jakub Kądziołka 045a9e8b93 Report only one error when invalid shift has argument
Not to mention that incrementing a variable in a loop is kinda dumb.
2020-10-12 22:54:20 +02:00
Jakub Kądziołka 4419f0d54f remove dead function: sym_GetDefinedValue 2020-10-12 13:31:21 +02:00
Jakub Kądziołka b07aa00d5c Don't overwrite symbol when it's not allowed
When a user tried to overwrite a builtin symbol, it would change its
type despite the error, making the second try succeed. This is
problematic, as the location of a builtin symbol cannot be updated.
2020-10-12 12:35:49 +02:00
Eldred Habert e4f5df1306 Merge pull request #603 from NieDzejkob/rpn-realloc
reserveSpace: don't assume one doubling is enough
2020-10-12 12:26:44 +02:00
Jakub Kądziołka dc62d60e9b reserveSpace: don't assume one doubling is enough 2020-10-12 11:57:03 +02:00
ISSOtm 71d8aeb4c2 Add CMake defines to enable tracing lexer and parser 2020-10-12 09:02:21 +02:00
Eldred Habert 0836f67d42 Merge pull request #601 from NieDzejkob/utf8decoder
utf8decoder: Use byte-sized byte argument
2020-10-12 01:49:57 +02:00
Eldred Habert 176a57a1e9 Merge pull request #600 from NieDzejkob/stray-shift
Report error when shifting outside a macro
2020-10-12 01:44:10 +02:00
Eldred Habert 0d02355dbf Merge pull request #599 from NieDzejkob/stray-align
Report error when aligning outside of a section
2020-10-12 01:43:35 +02:00
Jakub Kądziołka 6767d11c23 utf8decoder: Use byte-sized byte argument
This prevents passing a negative value out of a signed char by accident.
Also renders some casts in the code superfluous.
2020-10-12 01:22:09 +02:00
ISSOtm 2dd9015dc6 Remove two stale variables from parser.y
They were made useless with the lexer rewrite
2020-10-12 00:52:12 +02:00
Jakub Kądziołka 217c10ddac Report error when shifting outside a macro 2020-10-12 00:47:01 +02:00
Jakub Kądziołka 822e4e7c44 Report error when aligning outside of a section 2020-10-12 00:27:54 +02:00
ISSOtm 0b1d01792d Indicate cur offset in linkerscript "backwards org" message 2020-10-12 00:04:08 +02:00
ISSOtm 01637768cf Rename asmy to more explicit parser
This should make the purpose of that file clearer to newcomers
2020-10-11 21:03:41 +02:00
ISSOtm 6a8ae643d5 Mention that SHIFT updates _NARG
Fixes #598
2020-10-11 02:13:30 +02:00
ISSOtm fd83d46ba0 Enable master docs update workflow always
There seems to be no way to make the check work, and Actions are disabled
in forks by default anyways.
2020-10-11 02:04:09 +02:00
ISSOtm 914856342c Fix incorrect documentation of accepted sym names
No, they cannot start with a digit!
2020-10-11 01:57:27 +02:00
Eldred Habert 91889fc14a Merge pull request #593 from Rangi42/issue586
Fix #586: Update the `charmaps` hashmap when an existing charmap is resized
2020-10-10 02:15:04 +02:00
Rangi 7c8ec5a5ed Add a test case for charmaps that segfaults prior to this fix 2020-10-09 20:06:02 -04:00
Rangi effc6788eb Fix #586 segfault: Update the charmaps hashmap when an existing charmap is resized 2020-10-07 13:21:13 -04:00
Eldred Habert f9daf27511 Merge pull request #585 from ISSOtm/msvc-ci
Add MSVC in CI
2020-10-06 17:48:13 +02:00
ISSOtm 06f7387466 Avoid using VLA in EQUS dumping
MSVC does not support those...
Also add a `develop` warning about VLAs, to avoid future incidents
2020-10-06 08:55:45 +02:00
ISSOtm 21e50eeff1 Have lexer not require <unistd.h> on MSVC
Required for `open`, `close`, `read`, and `STDIN_FILENO`,
which are defined elsewhere on MSVC.
2020-10-06 08:55:45 +02:00
ISSOtm fd4cec93cd Compile with MSVC as well in CI 2020-10-06 08:55:41 +02:00
ISSOtm 92f2055a6c Fix implicit cast between enums
This caused `make develop` to fail
2020-10-05 01:53:54 +02:00
Eldred Habert be9b1198e9 Merge pull request #584 from Xeyler/master
Add directory summary to README.rst
2020-10-04 20:20:08 +02:00
Brigham Campbell 56bea083f9 Add directory summary to README.rst 2020-10-04 12:04:59 -06:00
Eldred Habert fdfc02ab96 Merge pull request #583 from JL2210/cmake-build-type
Modularize CMake build configuration
2020-10-04 19:45:20 +02:00
Eldred Habert fc7f042ad6 Merge pull request #551 from NieDzejkob/errors-after-unknown-symbol
link: Suppress cascading errors.
2020-10-04 19:43:38 +02:00
James Larrowe 761c775043 Modularize CMake build configuration
Build type no longer defaults to Release (!)
have separate options for extra warning flags and sanitizers

toss DEVELOP macro

Fix sanitizers with CMake while I'm at it :|
2020-10-04 13:28:00 -04:00
Jakub Kądziołka b421c983d6 link: Suppress cascading errors. 2020-10-04 18:14:22 +02:00
Eldred Habert 3036b58598 Merge pull request #557 from ISSOtm/new-lexer-electric-boogaloo
New lexer 2 — Electric Boogaloo
2020-10-04 16:45:47 +02:00
ISSOtm 2eca43cd2d Fix critical oversight in lexer buffer refilling
Since the lexer buffer wraps, the refilling gets handled in two steps:
First, iff the buffer would wrap, the buffer is refilled until its end.
Then, if more characters are requested, that amount is refilled too.

An important detail is that `read()` may not return as many characters as
requested; for this reason, the first step checks if its `read()` was
"full", and skips the second step otherwise.
This is also where a bug lied.

After a *lot* of trying, I eventually managed to reproduce the bug on an
OpenBSD VM, and after adding a couple of `assert`s in `peekInternal`, this
is what happened, starting at line 724:

0. `lexerState->nbChars` is 0, `lexerState->index` is 19;
1. We end up with `target` = 42, and `writeIndex` = 19;
2. 42 + 19 is greater than `LEXER_BUF_SIZE` (= 42), so the `if` is entered;
3. Within the first `readChars`, **`read` only returns 16 bytes**,
   advancing `writeIndex` to 35 and `target` to 26;
4. Within the second `readChars`, a `read(26)` is issued, overflowing the
   buffer.

The bug should be clear now: **the check at line 750 failed to work!** Why?
Because `readChars` modifies `writeIndex`.
The fix is simply to cache the number of characters expected, and use that.
2020-10-04 16:10:32 +02:00
ISSOtm c24694233f Fix incomplete duplication of REPT nodes
"Initialization, sizeof, and the assignment operator ignore the flexible array member."
Oops!
2020-10-04 04:46:01 +02:00
ISSOtm 423a7c4899 Handle \\r better
Translate it to \\n regardless of the lexer mode
2020-10-04 04:46:01 +02:00
ISSOtm ee9e45b3d4 Change assertion condition in __FILE__ buf dumping
Removes a false positive from Clang static analysis
2020-10-04 04:46:01 +02:00
ISSOtm 5a65188ca9 Implement compact file stacks in object files
Gets rid of `open_memstream`, enabling Windows compatibility again
Also fixes #491 as a nice bonus!
2020-10-04 04:46:01 +02:00
ISSOtm 930080f556 Mark not unmapping macro-containing files as okay
There isn't really a better alternative.
Making several mappings instead requires too much bookkeeping.
2020-10-04 04:46:01 +02:00
ISSOtm 8e7afb0ab3 Move some MSVC-specific defines to platform.h 2020-10-04 04:46:01 +02:00
ISSOtm 138523570e Fix possible uninitialized read on Windows 2020-10-04 04:46:01 +02:00
ISSOtm 82469ac0fd Shim around mmap on Windows 2020-10-04 04:46:01 +02:00
ISSOtm 96cb5e10ed Fix range-dependent dead code in recursion depth check 2020-10-04 04:46:01 +02:00
ISSOtm b224cab3e0 Harmonize printing distance 2020-10-04 04:46:01 +02:00
ISSOtm 7381d7b92f Remove unnecessarily nested symbol data union 2020-10-04 04:46:01 +02:00
ISSOtm dbef51ba05 Move isWhitespace to a place where it makes more sense 2020-10-04 04:46:01 +02:00
ISSOtm c952dd8a6e Fix fixed-point constants not working correctly
And added a test to check their behavior
2020-10-04 04:46:01 +02:00
ISSOtm b65ea64a58 Add newlines to all test output
MacOS treats them differently, for some reason.
2020-10-04 04:46:01 +02:00
ISSOtm 542b5d18f1 Fix possible capture buffer size overflow
Attempt to grow it to the max size first.
Seriously, if this triggers, *how*
2020-10-04 04:46:01 +02:00
ISSOtm 71a0a42cfb Fix C2x use of static_assert 2020-10-04 04:46:01 +02:00
ISSOtm ac011fe69f Use common function to discard comments in macro args 2020-10-04 04:46:01 +02:00
ISSOtm 9e3d7a50e6 Handle comments in line continuations 2020-10-04 04:46:00 +02:00
ISSOtm e33c2ad6a2 Fix INCLUDE ignoring -MG 2020-10-04 04:46:00 +02:00
ISSOtm 615f1072d9 Fix readFractionalPart never shifting characters 2020-10-04 04:46:00 +02:00
ISSOtm f7b7a97407 Prevent expanding macro args in comments
Also use a cleaner way, instead of hardcoding to capture
2020-10-04 04:46:00 +02:00
ISSOtm ece6853e0f Implement opt b and opt g 2020-10-04 04:46:00 +02:00
ISSOtm b7b03ee451 Fix "REPT 0" not being a no-op 2020-10-04 04:45:59 +02:00
ISSOtm f9b48c0cad Fix else working incorrectly from macros
Since the "skip ELSE blocks" variable is global, it used to get carried
over from the macro's `if` to the outer's.
2020-10-04 04:45:59 +02:00
ISSOtm aa76603da9 Add line+col trace info to lexer 2020-10-04 04:45:59 +02:00
ISSOtm b83b9825f8 Fix _NARG crashing outside of macros
And add a test for it
2020-10-04 04:45:59 +02:00
ISSOtm d641972cde Fix macro args not being restored when exiting macros 2020-10-04 04:45:59 +02:00
ISSOtm 4d1333e124 Fix incorrect error reporting of INCLUDEd files 2020-10-04 04:45:59 +02:00
ISSOtm 35396e6410 Fix files being unmapped when still referenced by macros 2020-10-04 04:45:59 +02:00
ISSOtm 8d18b39eee Support missing register tokens
Made possible by #491
2020-10-04 04:45:59 +02:00
ISSOtm ae77893021 Fix file name reporting
As noted in the function's code, this is very error-prone, but
will do the job; this needs rewriting due to #491 anyways, so, temporary.
2020-10-04 04:45:59 +02:00
ISSOtm baeb180acd Apply error reporting changes to tests 2020-10-04 04:45:58 +02:00
ISSOtm fd02ffb7bd Implement __FILE__ symbol
Also clean up built-in symbol creation
This is not great, but currently okay.
Should be fixed later, like the rest...
2020-10-04 04:45:58 +02:00
ISSOtm 62ecdce0b0 Fix line-continuation-macro test 2020-10-04 04:45:58 +02:00
ISSOtm e4f2fad215 Support line continuations in main scope 2020-10-04 04:45:58 +02:00
ISSOtm 3f5f9bcaf0 Fix numeric constant overflow checks 2020-10-04 04:45:58 +02:00
ISSOtm 08867b3cec Enable catching invalid macro arg 0 2020-10-04 04:45:55 +02:00
ISSOtm 9081feab51 Reinstate macro arg scan distance
Used to be broken, so it was removed, but doing so prevents escaping them.
So it was instead put back in, but with corrected behavior
2020-10-04 04:39:27 +02:00
ISSOtm cf992164f7 Fix lexer capture sometimes not being reset 2020-10-04 04:39:27 +02:00
ISSOtm b27b821e7f Fix RAW lexer length underflow
Also added an assertion to check against more such overflows
2020-10-04 04:39:26 +02:00
ISSOtm d9ecaabac1 Add debug tracing code to lexer
Hidden behind a #define, like YYDEBUG
2020-10-04 04:39:26 +02:00
ISSOtm cd747d8175 Fix many lexer bugs
More to come...
2020-10-04 04:39:25 +02:00
ISSOtm df75fd2ec2 Fix expansion reporting being incorrect 2020-10-04 04:38:53 +02:00
ISSOtm adcaf4cd46 Fix crash when no macro args are being used 2020-10-04 04:38:53 +02:00
ISSOtm 81a77a9b88 Re-implement block copy to avoid expanding macro args
They were expanded during the capture, and there was no easy way to
avoid expanding them (believe me, after three hours and somehow an OOM, I
gave up trying).
2020-10-04 04:38:53 +02:00
ISSOtm 6e805cd318 Implement macro args
This finally allows running 90% of the test suite, debugging time!
2020-10-04 04:38:53 +02:00
ISSOtm e11f25024e Add test for built-in file symbol
It's currently defined in fstack.c, making it more prone to accidental
dropping. Let's not repeat the 0.3.9 scenario...
2020-10-04 04:38:53 +02:00
ISSOtm 7c895f8a1b Fix diagnostic formatting
Missing colon and space after the file stack
2020-10-04 04:38:53 +02:00
ISSOtm 38bda7e1bb Fix string expansion reporting
More expansions were allowed than the limit specified, and reporting code
did not account for the extra one that caused overflow
2020-10-04 04:38:52 +02:00
ISSOtm 149db9a022 Fix incorrect freeing of expansions
Freeing an expansion should free its children, not its siblings...
Fixes a use-after-free reported by scan-build. Nice catch!
2020-10-04 04:38:52 +02:00
ISSOtm fed252bc49 Fix nested expansions being incorrectly handled
The biggest problem was simply that the length of children expansions was
not accounted for when skipping over the parent... this took a lot of
arduous debugging, but it finally works!
2020-10-04 04:38:52 +02:00
ISSOtm 61b2fd9816 Add string expansion reporting
And fix line counting with expansion-made newlines.
This has the same bug as the old lexer (equs-newline's output does not
print the second warning as being part of the expansion).
Additionally, we regress equs-recursion, as we are no longer able to
catch this specific EQUS recursion. Simply enough, the new expansion
begins **after** the old one ends! I have found no way to handle that.
2020-10-04 04:38:52 +02:00
ISSOtm 5ad7a93750 Add EQUS expansion 2020-10-04 04:38:52 +02:00
ISSOtm 2ec10012b6 Fix mmap read offset not being initialized 2020-10-04 04:38:52 +02:00
ISSOtm e56c6cc291 Fix PC's name not being passed to parser 2020-10-04 04:38:52 +02:00
ISSOtm 4c9a929a14 Implement almost all functionality
Add keywords and identifiers
Add comments
Add number literals
Add strings
Add a lot of new tokens
Add (and clean up) IF etc.
Improve reporting of unexpected chars / garbage bytes
Fix bug with and improved error messages when failing to open file
Add verbose-level messages about how files are opened
Enforce that files finish with a newline
Fix chars returned not being cast to unsigned char (may conflict w/ EOF)
Return null path when no file is open, rather than crash
Unify and improve error printing slightly

Known to be missing: macro expansion, REPT blocks, EQUS expansions
2020-10-04 04:38:50 +02:00
ISSOtm 71f8871702 Implement more functionality
Macro arg detection, first emitted tokens, primitive (bad) column counting
2020-10-04 04:37:58 +02:00
ISSOtm 6dc4ce6599 Implement infrastructure around new lexer
The lexer itself is very much incomplete, but this is intended to be a
safe point to revert to should further implementation go south.
2020-10-04 04:37:58 +02:00
Eldred Habert 3a44cc7722 Merge pull request #582 from ISSOtm/rewrite-charmap
Rewrite charmap system
2020-10-04 04:37:06 +02:00
ISSOtm 4cfed3c98f Rewrite charmap system
Avoid allocating a *ton* of data per charmap
Stop relying on uninitialized data in charmap nodes
Only initialize charmap nodes lazily
2020-10-04 04:31:10 +02:00
Eldred Habert 6af57ff026 Merge pull request #581 from JL2210/cmake-docs
Install manpages with CMake
2020-10-03 22:15:17 +02:00
ISSOtm 2e3db9d56a Clean up label generation
Only check for localness when we already know we have a local
2020-10-03 21:33:30 +02:00
James Larrowe f8d9fa87ed Install manpages with CMake 2020-10-03 12:37:56 -04:00
ISSOtm f53ad359a6 Remove whoami step from Windows CI
A carry-over from testing
2020-10-03 02:17:18 +02:00
ISSOtm 84de86beb5 Enable make develop on Ubuntu 20.04 CI as well 2020-10-03 01:05:09 +02:00
Eldred Habert 04e7af2675 Merge pull request #579 from ISSOtm/cmake-ci
Enable CMake in CI
2020-10-02 23:30:26 +02:00
Eldred Habert 4f13a336b9 Merge pull request #578 from JL2210/cmake-pkgconfig
Use pkg-config to detect libpng
2020-10-02 22:30:30 +02:00
ISSOtm 03508119e5 Use CMake in CI as well 2020-10-02 22:24:02 +02:00
James Larrowe 03e20138d3 Use pkg-config to detect libpng
Only fall back to findpng
2020-10-01 18:58:36 -04:00
Antonio Niño Díaz dfcba36448 test: Update commit of uCity used for testing
This one updates the code to fix all warnings introduced in the last few
months because of updates to RGBDS.
2020-09-27 22:47:56 +01:00
ISSOtm 8e4a9a5c21 Remove assertions from release builds
I believe the CMakeLists already did that, but the Makefile did not.
2020-09-27 17:05:52 +02:00
ISSOtm a1286e6f0e Make newlines explicit in error messages
In preparation for a change a PR is about to make
2020-09-27 10:54:06 +02:00
ISSOtm c0808246e5 Silence the mingw test
Use "quiet" instead of "count"...
2020-09-27 10:51:52 +02:00
ISSOtm ba051e10fb Factor printing assert failures into functions
Saves some code duplication
2020-09-27 09:24:24 +02:00
ISSOtm 9fee0603b1 Fix typo in object file format doc
Thanks @ax6!
2020-09-24 16:43:13 +02:00
ISSOtm be8ebe6db9 Fix master docs update CI script
GitHub documentation about the syntax is unclear, this should be right
according to the examples I saw.
2020-09-24 16:41:23 +02:00
ISSOtm 548e3dc31c Correct previously-introduced test being a no-op
Forgot to invoke the macro due to a copy-paste error
2020-09-24 16:35:45 +02:00
ISSOtm 9440086d77 Add a test for purging a macro while running
This could cause a crash if the macro name is then used for error reporting
2020-09-24 16:14:18 +02:00
ISSOtm ec5a1bc71f Fix incorrect obj file documentation
Bit 7 of section types was actually documented in the symbol type
Bit 6 of section types was not documented at all
2020-09-24 10:26:02 +02:00
ISSOtm 9742fa731c Run the quote in file name except on Windows
This should make the CI function again
2020-09-22 18:13:26 +02:00
ISSOtm 91a3c538d9 Enable running regression tests on PRs as well 2020-09-22 17:27:29 +02:00
ISSOtm e98485da3f Make code style errors fail their CI job
Mimics the behavior of the old Travis script
2020-09-22 02:59:38 +02:00
ISSOtm 6528a955fe Fix checkpatch in CI 2020-09-22 02:44:24 +02:00
ISSOtm 431f77127e Also update master docs when updating script 2020-09-22 01:05:49 +02:00
ISSOtm 2cc58723cb Do not try updating docs if no key is set
This will avoid this randomly failing in forks, unless we want to run it
2020-09-22 00:56:14 +02:00
ISSOtm 268219d74e Avoid warning about /* fallthrough */ comments
We do not have `fallthrough;`, so...
2020-09-21 17:46:44 +02:00
ISSOtm d09ed3e52e Get rid of flex as a dependency in CMakeLists
It will actually not be needed for new lexer
2020-09-20 03:39:53 +02:00
ISSOtm 421d1f5490 Add regression test for #546
Check for quotes in `__FILE__`
2020-09-20 00:44:29 +02:00
ISSOtm 66784b7122 Fix documentation not mentioning SECTION FRAGMENTsyntax 2020-09-20 00:06:51 +02:00
ISSOtm 54f2d99ce7 Apply two minor fixes to rgbasm(5)
Mustn't → must not
Add a comma to INCBIN sentence to mirror INCLUDE's
2020-09-17 20:45:58 +02:00
ISSOtm 557c799ec9 Update README to point to online install instructions 2020-09-17 03:47:55 +02:00
ISSOtm d22a667095 Update help text to redirect to new online docs 2020-09-17 03:10:02 +02:00
ISSOtm 30085a5342 Update documentation link in README 2020-09-16 15:52:36 +02:00
ISSOtm 304e6c4279 Sync redirect page generation with site 2020-09-16 06:25:46 +02:00
ISSOtm 12458aae6f Fix permalinks of index pages 2020-09-16 06:04:38 +02:00
ISSOtm 7e5d9683b1 Use mandoc 1.14.5 in CI
This is the version that added -Otoc
2020-09-15 19:24:25 +02:00
ISSOtm 210a4a957a Get rid of in-repo HTML documentation
The online documentation is now managed by a CI hook
2020-09-15 18:39:22 +02:00
ISSOtm 131ad9b315 Fix GitHub link in BUGS sections 2020-09-15 18:35:04 +02:00
ISSOtm 06b4cf57ab Fix example arguments to -MT appearing as options 2020-09-15 18:32:13 +02:00
ISSOtm dbefdc923a Clean up doc post-processor
Description blurb is already inline from new stylesheet
`Xr` links are already handled by `mandoc` now
Handle spaces between both dashes in long options
Remove `<head>` modifications, as fragments are generated instead
2020-09-15 18:30:40 +02:00
ISSOtm 37e45de9c1 Improve rendering of pages
Make links to other man pages work
Add a table of contents to rgbasm(5)
Make the OS at the bottom of all pages 'Linux'
Apply post-processor that used to be used
2020-09-15 18:27:55 +02:00
ISSOtm 5e63527190 Update repo link at bottom of all man pages 2020-09-15 16:00:17 +02:00
ISSOtm 0cc9026978 Fix docs update action
Make script executable (facepalm)
Fix `run**s**-on` typo
Add key using ssh-agent
Force using SSH for pushing back
2020-09-15 15:57:20 +02:00
ISSOtm bb6a5441ed Update RGBDS history to mention org move 2020-09-15 15:02:26 +02:00
ISSOtm 0ffda1bf29 Add CI Action to update man pages from master 2020-09-15 15:00:07 +02:00
Antonio Vivace 56b5f77dc8 Mention the new website, add notice about the movement to the gbdev org 2020-09-15 14:01:38 +02:00
Antonio Vivace 6eb284f99e Update README.rst 2020-09-15 13:53:22 +02:00
Marco Spataro 34c2288fd0 Fix __FILE__ when filename contains quotes 2020-09-10 12:49:04 +02:00
ISSOtm 304bb9f902 Remove most Hungarian notation in section module
Seriously, it sucks.
2020-09-06 20:43:13 +02:00
ISSOtm 14be01880d Move UNION code inside section.c
Improves organization and locality
2020-09-06 19:18:10 +02:00
ISSOtm 12b7cf3cd4 Move curOffset into section code
Improves organization
2020-09-06 18:50:19 +02:00
ISSOtm 0d7914bff7 Fix asm/charmap.h not including required header 2020-09-06 17:16:49 +02:00
ISSOtm d2285953d7 Fix test missed by last PR
We need to fix CI
2020-09-03 14:28:28 +02:00
Eldred Habert d2801505c3 Merge pull request #562 from Rangi42/strsub-0
Resolve #554: STRSUB("<N-char string>", N, 0) will not warn "Position N is past the end of the string"
2020-09-03 12:12:03 +02:00
ISSOtm 9d62b4b9bb Fix bugs with LOAD section size
LOAD blocks did not properly update their parent's size until after closed
Additionally, section size wasn't correctly sanitized inside LOAD blocks
2020-09-03 12:07:12 +02:00
Rangi b65b723fa6 Resolve #554: STRSUB("<N-char string>", N, 0) will not warn "Position N is past the end of the string" 2020-08-31 15:40:25 -04:00
ISSOtm e05321356b Fix truncation warning when adding charmap mapping
It used to warn when mapping negative values
2020-08-31 21:33:53 +02:00
ISSOtm 0778959e98 Remove arbitrary limits on charmap
They were made irrelevant when switching to a trie
2020-08-31 21:26:21 +02:00
Eldred Habert 76331d1c4a Merge pull request #552 from mattcurrie/incbin-length-optional
Make INCBIN's length argument optional
2020-08-23 00:11:54 +02:00
Eldred Habert 9e378ec5cf Bump license year
I feel like there's a 20xx joke to be made here...
2020-08-20 23:02:25 +02:00
ISSOtm f57d33b17a Update subprojects in test suite
Especially necessary for the "new lexer" branch
2020-08-18 16:40:41 +02:00
Matt Currie c389e8dccb Fix typo
'arugment' => 'argument'
2020-08-17 13:57:58 +12:00
Matt Currie 90c64a94d1 Revert change to rgbasm.5.html
Will be rebuilt upon release
2020-08-17 13:56:29 +12:00
Eldred Habert df27af6d1c Merge pull request #553 from JL2210/cmake-develop
Add DEVELOP option to CMake
2020-08-16 22:12:47 +02:00
James Larrowe c85b48f23e Default to debug when building in develop mode 2020-08-16 13:58:02 -04:00
James Larrowe 5a9f2b7750 Add DEVELOP option to CMake
This requires CMake 3.0 so -Werror won't conflict with link tests.
Remove all version checks to improve simplicity.
2020-08-16 13:23:29 -04:00
ISSOtm fcfecc6e82 Improve description of @ symbol
As requested by someone on GBDev
2020-08-15 15:23:11 +02:00
Matt Currie f863a927c1 Make INCBIN's length argument optional
INCBIN can now be used with just a start position to include everything
from the start position until the end of the file.
2020-08-15 17:24:11 +12:00
Eldred Habert cb4fbdfcd5 Merge pull request #550 from rednex/an/array
Refactor warning array for clarity
2020-08-05 10:53:21 +02:00
Eldred Habert c6eacde55e Merge pull request #544 from ISSOtm/atomic_ind
Split register-indirect tokens
2020-08-05 10:52:18 +02:00
Antonio Niño Díaz daf780c7e6 Refactor warning array for clarity 2020-08-04 22:28:56 +01:00
Eldred Habert 613305d234 Add checkpatch link in README 2020-07-31 16:07:00 +02:00
ISSOtm 656432301d Run as many CI jobs as possible when one fails
The other matrixes should not have this problem, so only touch unix testing
2020-07-27 18:34:32 +02:00
ISSOtm 38a80f2816 Fix test failing on OS-dependent trailing newline 2020-07-27 18:30:12 +02:00
ISSOtm 6563133426 Avoid using echo -e in tests 2020-07-27 18:26:05 +02:00
ISSOtm 762474d3ac Let RGBASM write JR offsets in floating sections
This requires some special-casing for `jr @` because the `jr` opcode has
already been emitted, but not the operand, so PC points to the middle.
Moved the RGBLINK test to RGBASM's folder, and created a new RGBLINK test.
2020-07-27 18:17:29 +02:00
ISSOtm b1adbcc77c Output a non-empty RPN buffer from known expressions
The code expected to never get "known" expressions passed in, as RGBASM
otherwise patches the bytes in by itself; however, JR cannot be patched in
by RGBASM unless the section's base address is known as well!
2020-07-27 17:43:31 +02:00
Eldred Habert dda052da20 Merge pull request #545 from JL2210/consistent-versions
Use versioning consistent with the Makefile in CMake
2020-07-26 19:16:27 +02:00
James Larrowe 2d6bdbc1b1 Use versioning consistent with the Makefile in CMake
This uses git to determine the dirty version and uses a fallback
if that's not available.
2020-07-23 10:47:01 -04:00
ISSOtm 0600856167 Move incbin slice sign check
The grammar's message is pretty generic, so this one is more useful.
2020-07-23 01:06:28 +02:00
ISSOtm ce47b57b03 Document version string fallback in Makefile
For a packager just looking at the Makefile, it's not obvious that there
is one...
2020-07-22 16:21:58 +02:00
ISSOtm f3c916ab96 Allow env vars to override default CFLAGS etc.
Should make the work easier for downstream packagers
2020-07-22 16:21:21 +02:00
ISSOtm ca6fa6d1d7 Split register-indirect tokens
This allows whitespace between the brackets and the register.
This also fixes #531

Note that `$ff00 + c` is still treated as a single token, because trying to
use an expression on the left side causes a shift/reduce conflict.
This isn't great, but most people seem to be either used to it as-is, or
using the new `ldh a, [c]` syntax.
If this causes problems with a lexer rewrite, it'll be deprecated; but for
now, keep it around, as the support is clunky but bearable.
2020-07-22 15:00:39 +02:00
ISSOtm fcd37b52b6 Update pret projects to latest commits
Behind pokecrystal by 123, behind pokered by 172
2020-07-22 00:29:38 +02:00
2269 changed files with 51522 additions and 26181 deletions
-85
View File
@@ -1,85 +0,0 @@
# Configuration for checkpatch.pl
# ===============================
# Enable more tests
--strict
# Quiet
--quiet
# No per-file summary
--no-summary
# Don't expect the Linux kernel tree
--no-tree
# Show file line, not input line
--showfile
# Don't expect SPDX tag in the first line of a file
--ignore SPDX_LICENSE_TAG
# Don't expect Signed-off-by lines in commit messages
--no-signoff
# List of ignored rules
# ---------------------
# There's no BIT macro
--ignore BIT_MACRO
# Don't complain when bools are used in structs
--ignore BOOL_MEMBER
# Allow CamelCase
--ignore CAMELCASE
# Comparing to NULL explicitly isn't a bad thing
--ignore COMPARISON_TO_NULL
# Causes false positives
--ignore COMPLEX_MACRO
# Don't complain about structs not being const
--ignore CONST_STRUCT
# Don't complain about printing "warning:" without the function name, as warning
# printing is relevant to the code being parsed, not RGBDS' code
--ignore EMBEDDED_FUNCTION_NAME
# Do not check the format of commit messages
--ignore GIT_COMMIT_ID
# Do not check for global initializers (this is specific to the kernel)
--ignore GLOBAL_INITIALISERS
# Don't complain about initializing statics (this is specific to the kernel)
--ignore INITIALISED_STATIC
# We don't have a MAINTAINERS file, don't complain about it.
--ignore FILE_PATH_CHANGES
# Writing the continuation on the start of the line can make it clearer
--ignore LOGICAL_CONTINUATIONS
# Don't complain if a line that contains a string is too long. It's better to
# have a really long line that can be found with grep.
--ignore LONG_LINE_STRING
# Don't complain when files are modified in 'include/asm'
--ignore MODIFIED_INCLUDE_ASM
# Allow new typedefs
--ignore NEW_TYPEDEFS
# We allow lines ending with parentheses for the usage prints
--ignore OPEN_ENDED_LINE
# Prefer stdint.h types over kernel types
--ignore PREFER_KERNEL_TYPES
# Don't ask to replace sscanf by kstrto
--ignore SSCANF_TO_KSTRTO
# Parentheses can make the code clearer
--ignore UNNECESSARY_PARENTHESES
+106
View File
@@ -0,0 +1,106 @@
AccessModifierOffset: -4
AlignAfterOpenBracket: BlockIndent
AlignArrayOfStructures: Left
AlignConsecutiveAssignments: None
AlignConsecutiveBitFields: Consecutive
AlignConsecutiveDeclarations: None
AlignConsecutiveMacros: Consecutive
AlignEscapedNewlines: DontAlign
AlignOperands: Align
AlignTrailingComments: true
AllowShortBlocksOnASingleLine: Empty
AllowShortCaseLabelsOnASingleLine: false
AllowShortEnumsOnASingleLine: true
AllowShortFunctionsOnASingleLine: InlineOnly
AllowShortIfStatementsOnASingleLine: Never
AllowShortLambdasOnASingleLine: All
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: Yes
AttributeMacros:
- format_
- attr_
BinPackArguments: false
BinPackParameters: false
BitFieldColonSpacing: Both
BreakAfterAttributes: Always
BreakBeforeBinaryOperators: NonAssignment
BreakBeforeBraces: Attach
BreakBeforeConceptDeclarations: true
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeColon
BreakInheritanceList: AfterComma
BreakStringLiterals: true
ColumnLimit: 100
CompactNamespaces: false
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DeriveLineEnding: true
DerivePointerAlignment: false
EmptyLineBeforeAccessModifier: Leave
FixNamespaceComments: false
IncludeBlocks: Regroup
IncludeCategories:
- Regex: '^<sys/'
Priority: 0
- Regex: '^<'
Priority: 1
- Regex: '^"extern/'
Priority: 2
- Regex: '^"(asm|link|fix|gfx)/'
Priority: 3
- Regex: '^"'
Priority: 2
IndentAccessModifiers: false
IndentCaseBlocks: false
IndentCaseLabels: false
IndentExternBlock: Indent
IndentGotoLabels: false
IndentPPDirectives: BeforeHash
IndentRequires: true
IndentWidth: 4
IndentWrappedFunctionNames: true
InsertBraces: true
InsertNewlineAtEOF: true
# Only support for Javascript as of clang-format 14...
# InsertTrailingCommas: Wrapped
KeepEmptyLinesAtTheStartOfBlocks: false
LambdaBodyIndentation: Signature
Language: Cpp
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
PPIndentWidth: -1
PenaltyBreakScopeResolution: 1000
PointerAlignment: Right
QualifierAlignment: Right
ReflowComments: true
RemoveParentheses: ReturnStatement
RemoveSemicolon: true
SortIncludes: CaseSensitive
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: false
SpaceAroundPointerQualifiers: Both
SpaceBeforeAssignmentOperators: true
SpaceBeforeCaseColon: false
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceBeforeSquareBrackets: false
SpaceInEmptyBlock: false
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInCStyleCastParentheses: false
SpacesInConditionalStatement: false
SpacesInContainerLiterals: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: c++20
TabWidth: 4
UseCRLF: false
UseTab: ForIndentation
+6
View File
@@ -0,0 +1,6 @@
---
Checks: ''
WarningsAsErrors: ''
HeaderFilterRegex: ''
FormatStyle: none
SystemHeaders: false
-5
View File
@@ -1,7 +1,2 @@
# This file is part of RGBDS.
#
# Copyright (c) 2018-2019, Phil Smith and RGBDS contributors.
#
# SPDX-License-Identifier: MIT
.git
docs
+18
View File
@@ -0,0 +1,18 @@
root = true
[*]
indent_style = tab
indent_size = tab
tab_width = 4
charset = utf-8
insert_final_newline = true
trim_trailing_whitespace = true
end_of_line = lf
[{CMakeLists.txt,*.cmake}]
indent_style = space
indent_size = 2
[*.yml]
indent_style = space
indent_size = 2
+19
View File
@@ -0,0 +1,19 @@
# This file contains a list of commits that are probably not what you
# are looking for in a `git blame`, such as mass reformatting or renaming.
#
# You can set this file as a default ignore file for `git blame` by running
# the following command:
#
# $ git config blame.ignoreRevsFile .git-blame-ignore-revs
# 2024-03-04: Run `clang-format` on everything
e74073e4805fa3cce90a99946fc9994ae2970f9b
# 2009-06-11: Run `indent' on the whole tree
b6c749ffbd30138de7beef13fb9265372a461a96
# 2009-06-11: Switch line terminators from CRLF to LF
94fad97aedcd8bd85c53a505db28390e3f82577b
# 2009-06-11: Use spaces instead of tabs after CPP directives
0d9739535e313b0a2ad19c89b9c85fc7b75237a3
+19
View File
@@ -0,0 +1,19 @@
# Shell scripts need Unix line endings (see https://github.com/gbdev/rgbds/issues/841)
*.sh text eol=lf
*.bash text eol=lf
*.cfg text eol=lf
# Flags also need Unix line endings (see https://github.com/gbdev/rgbds/issues/955)
*.flags text eol=lf
# Binary files need exact bytes
*.bin binary
*.gb binary
*.1bpp binary
*.2bpp binary
*.pal binary
*.attrmap binary
*.tilemap binary
*.palmap binary
*.patch binary
*.png binary
+2
View File
@@ -0,0 +1,2 @@
open_collective: gbdev
github: gbdev
+4
View File
@@ -0,0 +1,4 @@
---
name: Update to RGBDS
about: Suggest a feature or report a bug in RGBDS.
---
+5
View File
@@ -0,0 +1,5 @@
blank_issues_enabled: false
contact_links:
- name: GBDev Discord
url: https://discord.gg/RjJKA8wrD4
about: If you have questions about the RGBDS code or its organization, join our Discord server!
-14
View File
@@ -1,14 +0,0 @@
case `echo $1 | cut -d '-' -f 1` in
ubuntu)
sudo apt-get -qq update
sudo apt-get install -yq bison libpng-dev pkg-config
;;
macos)
brew install libpng pkg-config md5sha1sum
;;
*)
echo "WARNING: Cannot install deps for OS '$1'"
;;
esac
yacc --version
-17
View File
@@ -1,17 +0,0 @@
#!/bin/bash
source mingw-env @TRIPLE@
echo LAST IS: $last
# check if last arg is a path to configure, else use parent
for last; do true; done
if test -x "${last}/configure"; then
config_path="$last"
else
config_path=".."
fi
${config_path}/configure \
--host=@TRIPLE@ --target=@TRIPLE@ --build="$CHOST" \
--prefix=/usr/@TRIPLE@ --libdir=/usr/@TRIPLE@/lib --includedir=/usr/@TRIPLE@/include \
--enable-shared --enable-static "$@"
-16
View File
@@ -1,16 +0,0 @@
#!/bin/sh
_arch=$1
default_mingw_pp_flags="-D_FORTIFY_SOURCE=2"
default_mingw_compiler_flags="$default_mingw_pp_flags -O2 -pipe -fno-plt -fexceptions --param=ssp-buffer-size=4"
default_mingw_linker_flags="-Wl,-O1,--sort-common,--as-needed -fstack-protector"
export CPPFLAGS="${MINGW_CPPFLAGS:-$default_mingw_pp_flags $CPPFLAGS}"
export CFLAGS="${MINGW_CFLAGS:-$default_mingw_compiler_flags $CFLAGS}"
export CXXFLAGS="${MINGW_CXXFLAGS:-$default_mingw_compiler_flags $CXXFLAGS}"
export LDFLAGS="${MINGW_LDFLAGS:-$default_mingw_linker_flags $LDFLAGS}"
mingw_prefix=/usr/${_arch}
export PKG_CONFIG_SYSROOT_DIR="${mingw_prefix}"
export PKG_CONFIG_LIBDIR="${mingw_prefix}/lib/pkgconfig:${mingw_prefix}/share/pkgconfig"
-44
View File
@@ -1,44 +0,0 @@
#!/bin/sh
# This script was written by ISSOtm while looking at Arch Linux's PKGBUILD for
# the corresponding package. (And its dependencies)
# https://aur.archlinux.org/packages/mingw-w64-libpng/
set -e
pngver=1.6.37
_apngver=$pngver
_arch="$1"
## Install mingw-configure and mingw-env (both build dependencies)
install -m 755 .github/actions/mingw-env.sh /usr/bin/mingw-env
sed "s|@TRIPLE@|${_arch}|g" .github/actions/mingw-configure.sh > ${_arch}-configure
install -m 755 ${_arch}-configure /usr/bin/
## Grab sources and check them
wget http://downloads.sourceforge.net/sourceforge/libpng/libpng-$pngver.tar.xz
wget http://downloads.sourceforge.net/project/apng/libpng/libpng16/libpng-$_apngver-apng.patch.gz
sha256sum -c .github/actions/mingw-w64-libpng-dev.sha256sums
## Extract sources
tar -xf libpng-$pngver.tar.xz
gunzip libpng-$_apngver-apng.patch.gz
## Start building!
cd libpng-$pngver
# Patch in apng support
patch -p0 ../libpng-$_apngver-apng.patch
mkdir -p build-${_arch}
cd build-${_arch}
${_arch}-configure LDFLAGS=-static-libgcc
make
make install
@@ -1,2 +0,0 @@
10d9e0cb60e2b387a79b355eb7527c0bee2ed8cbd12cf04417cabc4d6976683c libpng-1.6.37-apng.patch.gz
505e70834d35383537b6491e7ae8641f1a4bed1876dbfe361201fc80868d88ca libpng-1.6.37.tar.xz
+19
View File
@@ -0,0 +1,19 @@
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "quarterly" # We do not need *immediate* bumps, only frequent enough to avoid falling out of support range.
cooldown: # Avoid bumping deps immediately, to give time for security audits to be conducted
default-days: 15
include: [ "*" ]
groups:
actions:
patterns: [ "*" ]
ignore:
- dependency-name: "*"
update-types:
- "version-update:semver-minor"
- "version-update:semver-patch"
labels: [ builds ] # Since those are CI-related updates...
+8
View File
@@ -0,0 +1,8 @@
#!/usr/bin/env sh
set -eu
bash --version
zsh --version
find contrib -type f \( -name '*.sh' -o -name '*.bash' \) -exec bash --norc -n {} \;
find contrib/zsh_compl -type f -name '_rgb*' -exec zsh -n {} \;
+93
View File
@@ -0,0 +1,93 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: MIT
declare -A FILES
while IFS= read -r -d '' file; do
FILES["$file"]=true
done < <(git diff --name-only -z "$1" HEAD)
edited () {
${FILES["$1"]:-false}
}
dependency () {
if edited "$1" && ! edited "$2"; then
echo "'$1' was modified, but not '$2'! $3"
fi
}
# Pull requests that edit the first file without the second may be correct,
# but are suspicious enough to require review.
dependency include/linkdefs.hpp man/rgbds.5 \
"Was the object file format changed?"
dependency src/asm/parser.y man/rgbasm.5 \
"Was the rgbasm grammar changed?"
dependency src/asm/actions.cpp man/rgbasm.5 \
"Was the rgbasm grammar changed?"
dependency src/link/script.y man/rgblink.5 \
"Was the linker script grammar changed?"
dependency src/link/layout.cpp man/rgblink.5 \
"Was the linker script grammar changed?"
dependency include/asm/warning.hpp man/rgbasm.1 \
"Were the rgbasm warnings changed?"
dependency include/link/warning.hpp man/rgblink.1 \
"Were the rgblink warnings changed?"
dependency include/fix/warning.hpp man/rgbfix.1 \
"Were the rgbfix warnings changed?"
dependency include/gfx/warning.hpp man/rgbgfx.1 \
"Were the rgbgfx warnings changed?"
dependency src/asm/object.cpp include/linkdefs.hpp \
"Should the object file revision be bumped?"
dependency src/link/object.cpp include/linkdefs.hpp \
"Should the object file revision be bumped?"
dependency Makefile CMakeLists.txt \
"Did the build process change?"
dependency Makefile src/CMakeLists.txt \
"Did the build process change?"
dependency src/asm/main.cpp man/rgbasm.1 \
"Did the rgbasm CLI change?"
dependency src/asm/main.cpp contrib/zsh_compl/_rgbasm \
"Did the rgbasm CLI change?"
dependency src/asm/main.cpp contrib/bash_compl/_rgbasm.bash \
"Did the rgbasm CLI change?"
dependency src/link/main.cpp man/rgblink.1 \
"Did the rgblink CLI change?"
dependency src/link/main.cpp contrib/zsh_compl/_rgblink \
"Did the rgblink CLI change?"
dependency src/link/main.cpp contrib/bash_compl/_rgblink.bash \
"Did the rgblink CLI change?"
dependency src/fix/main.cpp man/rgbfix.1 \
"Did the rgbfix CLI change?"
dependency src/fix/main.cpp contrib/zsh_compl/_rgbfix \
"Did the rgbfix CLI change?"
dependency src/fix/main.cpp contrib/bash_compl/_rgbfix.bash \
"Did the rgbfix CLI change?"
dependency src/gfx/main.cpp man/rgbgfx.1 \
"Did the rgbgfx CLI change?"
dependency src/gfx/main.cpp contrib/zsh_compl/_rgbgfx \
"Did the rgbgfx CLI change?"
dependency src/gfx/main.cpp contrib/bash_compl/_rgbgfx.bash \
"Did the rgbgfx CLI change?"
dependency test/external/fetch-repos.sh docs/CONTRIBUTING.md \
"Did the test protocol change?"
dependency test/run-tests.sh docs/CONTRIBUTING.md \
"Did the test protocol change?"
dependency test/asm/test.sh docs/CONTRIBUTING.md \
"Did the RGBASM test protocol change?"
dependency test/link/test.sh docs/CONTRIBUTING.md \
"Did the RGBLINK test protocol change?"
dependency test/fix/test.sh docs/CONTRIBUTING.md \
"Did the RGBFIX test protocol change?"
dependency test/gfx/test.sh docs/CONTRIBUTING.md \
"Did the RGBGFX test protocol change?"
+15
View File
@@ -0,0 +1,15 @@
#!/usr/bin/env sh
# SPDX-License-Identifier: MIT
clang-format --version
find . -type f -iname '*.[ch]pp' -exec clang-format -i {} +
if ! git diff-index --quiet HEAD --; then
echo 'Unformatted files:'
git diff-index --name-only HEAD --
echo
git diff HEAD --
exit 1
fi
+25
View File
@@ -0,0 +1,25 @@
#!/usr/bin/env bash
set -euo pipefail
tag=$1
[ $# -eq 1 ]
flags=(--draft --fail-on-no-commits --verify-tag)
if [[ "$tag" = v*-rc* ]]; then
flags+=(--prerelease)
fi
files=(
win64/rgbds-win64.zip
win32/rgbds-win32.zip
macos/rgbds-macos.zip
linux/rgbds-linux-x86_64.tar.xz
rgbds-source.tar.gz
)
set -x
gh release create "${flags[@]}" --notes-file - "$tag" "${files[@]}" <<"EOF"
Please ensure that the packages below work properly.
Once that's done, replace this text with the changelog, un-draft the release, and update the `release` branch.
By the way, if you forgot to update `include/version.hpp`, RGBASM's version test is going to fail in the tag's regression testing! (Use `git push --delete origin <tag>` to delete it)
EOF
+11
View File
@@ -0,0 +1,11 @@
#!/usr/bin/env sh
local_bin_dir="$PWD/.local/bin"
mkdir -p "$local_bin_dir"
# Alias `make` to `gmake` and `python` to `python3` for use by external tests.
ln -s "$(which gmake)" "$local_bin_dir/make"
ln -s "$(which python3)" "$local_bin_dir/python"
export PATH="$local_bin_dir:$PATH"
+102
View File
@@ -0,0 +1,102 @@
#!/bin/sh
# This script requires `sh` instead of `bash` because the latter is not always installed on FreeBSD.
set -eu
# Python and the Pillow library are dependencies for libbet, a repo built by our external tests.
# Other dependencies are for building rgbds itself.
case $# in
1) OS="$1"; TOOLSET= ;;
2) OS="$1"; TOOLSET="$2" ;;
*) echo >&2 "Usage: $0 <os> [<toolset>]" && exit 1 ;;
esac
case "${OS%%-*}" in
ubuntu|debian)
pkgs=bison
case "$TOOLSET" in
mingw32)
pkgs="$pkgs libz-mingw-w64-dev g++-mingw-w64-i686-win32"
TOOLSET=
;;
mingw64)
pkgs="$pkgs libz-mingw-w64-dev g++-mingw-w64-x86-64-win32"
TOOLSET=
;;
g++-10 | lcov)
pkgs="$pkgs libpng-dev pkgconf python3-pil $TOOLSET"
TOOLSET=
;;
'' | g++ | clang++)
pkgs="$pkgs libpng-dev pkgconf python3-pil"
TOOLSET=
;;
esac
sudo apt-get update -qq
# shellcheck disable=SC2086 # (This word splitting is intentional.)
sudo apt-get install -yq $pkgs
;;
macos)
pkgs="bison make pillow"
case "$TOOLSET" in
lld)
pkgs="$pkgs $TOOLSET"
TOOLSET=
;;
clang++)
TOOLSET=
;;
esac
# macOS bundles GNU Make 3.81, which doesn't support synced output.
# We leave it as the default in `PATH`, to test that our Makefile works with it.
# However, CMake automatically uses Homebrew's `gmake`, so our CI has synced output.
# shellcheck disable=SC2086 # (This word splitting is intentional.)
brew install $pkgs
# Export `bison` to allow using the version we install from Homebrew,
# instead of the outdated one preinstalled on macOS (which doesn't even support `-Wall`...).
export PATH="$(brew --prefix)/opt/bison/bin:$PATH"
printf 'PATH=%s\n' "$PATH" >>"$GITHUB_ENV" # Make it available to later CI steps too.
;;
freebsd)
# GNU `gmake` and `gcc` are dependencies for most repos built by our external tests.
pkg install -y bash bison cmake ninja git png gmake lang/gcc python3 py312-pillow
;;
windows)
# GitHub Actions' hosted runners ship CMake 3.x, but versions prior to 4.0.0 ignore `CPACK_PACKAGE_FILE_NAME`.
choco install -y winflexbison3 cmake
# The version-printing code below will invoke `bison`, not the Windows-specific name `win_bison`.
bison() { win_bison "$@"; } # An alias doesn't work, so we use a function instead.
py -3 -m pip install pillow
;;
windowsmingw)
py -3 -m pip install pillow
;;
*)
echo "Cannot install deps for OS '$1'"
exit 1
;;
esac
if [ -n "$TOOLSET" ]; then
printf >&2 'Unknown toolset `%s` for OS `%s`\n' "$TOOLSET" "$OS"
exit 1
fi
# We do not build RGBDS *in* MinGW on Windows, so skip printing build tool info.
if [ "$OS" = "windowsmingw" ]; then
exit 0
fi
# Print some system info, for easier debugging.
# https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-commands#grouping-log-lines
echo ::group::PATH
echo "PATH=($PATH)" | sed 's/:/\n /g'
echo ::endgroup::
for prog in bison make cmake; do
printf '::group::' # No line terminator, the next command's first line becomes the group's title.
$prog --version
type $prog
echo ::endgroup::
done
+4
View File
@@ -0,0 +1,4 @@
@rem From https://github.com/microsoft/vswhere/wiki/Start-Developer-Command-Prompt#using-batch
for /f "delims=" %%p in ('vswhere.exe -prerelease -latest -property installationPath') do set vspath=%%p
@rem From https://learn.microsoft.com/en-us/cpp/build/building-on-the-command-line?view=msvc-170#developer_command_file_locations
call "%vspath%\VC\Auxiliary\Build\vcvars%1.bat"
+59
View File
@@ -0,0 +1,59 @@
name: Build container image
on:
push:
branches:
- master
tags:
- '*'
env:
# Force colored output (see https://bixense.com/clicolors/ and https://force-color.org/)
TERM: xterm-256color
CLICOLOR: 1
CLICOLOR_FORCE: 1
jobs:
publish-docker-image:
if: github.repository_owner == 'gbdev'
runs-on: ubuntu-latest
permissions:
packages: write
steps:
- name: Checkout repo
uses: actions/checkout@v7
- name: Login to GitHub Container Registry
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push the master container image
if: github.ref == 'refs/heads/master'
run: |
COMMIT_HASH=$(git rev-parse --short HEAD)
sed -i "2i LABEL org.opencontainers.image.description=\"RGBDS container image, containing the git version master:$COMMIT_HASH\"" Dockerfile
docker build . --tag ghcr.io/gbdev/rgbds:master
docker push ghcr.io/gbdev/rgbds:master
- name: Build and push the version-tagged container image
if: startsWith(github.ref, 'refs/tags/')
run: |
TAG_NAME=${GITHUB_REF#refs/tags/}
sed -i "2i LABEL org.opencontainers.image.description=\"RGBDS container image for the release version $TAG_NAME\"" Dockerfile
docker build . --tag ghcr.io/gbdev/rgbds:$TAG_NAME
docker tag ghcr.io/gbdev/rgbds:$TAG_NAME ghcr.io/gbdev/rgbds:latest
docker push ghcr.io/gbdev/rgbds:$TAG_NAME
docker push ghcr.io/gbdev/rgbds:latest
- name: Delete untagged container images
if: github.repository_owner == 'gbdev'
uses: Chizkiyahu/delete-untagged-ghcr-action@v6
with:
# Requires a personal access token with delete:packages permissions
token: ${{ secrets.PAT_TOKEN }}
package_name: 'rgbds'
untagged_only: true
except_untagged_multiplatform: true
owner_type: 'org'
+23
View File
@@ -0,0 +1,23 @@
name: Contrib script syntax checking
on:
- push
- pull_request
env:
# Force colored output (see https://bixense.com/clicolors/ and https://force-color.org/)
TERM: xterm-256color
CLICOLOR: 1
CLICOLOR_FORCE: 1
jobs:
check-contrib:
runs-on: ubuntu-slim
steps:
- name: Checkout repo
uses: actions/checkout@v7
- name: Install zsh
run: |
sudo apt install -Uyq zsh
- name: Check contrib scripts
run: |
.github/scripts/check-contrib.sh
+27
View File
@@ -0,0 +1,27 @@
name: Diff completeness check
on: pull_request
env:
# Force colored output (see https://bixense.com/clicolors/ and https://force-color.org/)
TERM: xterm-256color
CLICOLOR: 1
CLICOLOR_FORCE: 1
jobs:
check-diff:
runs-on: ubuntu-slim
steps:
- name: Clone repo
uses: actions/checkout@v7
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Check diff
shell: bash # Bash is the default, but specifying it explicitly enables `-o pipefail`.
run: |
MERGE_BASE=$(gh api "/repos/{owner}/{repo}/compare/$BASE_SHA...$HEAD_SHA" --jq '.merge_base_commit.sha')
git fetch origin "$MERGE_BASE"
.github/scripts/check-diff.bash "$MERGE_BASE" | sed -E 's/^/::warning::/'
env:
BASE_SHA: ${{ github.event.pull_request.base.sha }}
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
GH_TOKEN: ${{ github.token }}
+21
View File
@@ -0,0 +1,21 @@
name: Code format checking
on: pull_request
env:
# Force colored output (see https://bixense.com/clicolors/ and https://force-color.org/)
TERM: xterm-256color
CLICOLOR: 1
CLICOLOR_FORCE: 1
jobs:
check-format:
runs-on: ubuntu-slim
steps:
- name: Checkout repo
uses: actions/checkout@v7
- name: Install clang-format
run: |
sudo apt install -Uyq clang-format
- name: Check format
run: |
.github/scripts/check-format.sh
-17
View File
@@ -1,17 +0,0 @@
name: "Code style checking"
on: pull_request
jobs:
checkpatch:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up checkpatch
run: |
wget 'https://raw.githubusercontent.com/torvalds/linux/master/scripts/checkpatch.pl'
chmod +x checkpatch.pl
touch const_structs.checkpatch
touch spelling.txt
- name: Checkpatch
run: |
make checkpatch CHECKPATCH=./checkpatch.pl BASE_REF=${{ github.base_ref }} Q=
+33
View File
@@ -0,0 +1,33 @@
name: Code coverage report
on:
- push
- pull_request
env:
# Force colored output (see https://bixense.com/clicolors/ and https://force-color.org/)
TERM: xterm-256color
CLICOLOR: 1
CLICOLOR_FORCE: 1
jobs:
coverage:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v7
- name: Install deps
run: |
.github/scripts/install-deps.sh ubuntu-latest lcov
- name: Generate coverage report
run: |
contrib/coverage.bash --os ubuntu-latest --jobs "$(getconf _NPROCESSORS_ONLN)"
- name: Upload coverage report
uses: actions/upload-artifact@v7
with:
name: coverage-report
# Workaround for keeping the top-level coverage/ directory
# https://github.com/actions/upload-artifact/issues/174
path: |
coverage
dummy-file-to-keep-directory-structure.txt
if-no-files-found: error
@@ -0,0 +1,125 @@
name: Create release artifacts
on:
push:
tags:
- v[0-9]*
env:
# Force colored output (see https://bixense.com/clicolors/ and https://force-color.org/)
TERM: xterm-256color
CLICOLOR: 1
CLICOLOR_FORCE: 1
CMAKE_COLOR_DIAGNOSTICS: ON # Tells CMake-generated build systems to have colored output.
CMAKE_BUILD_TYPE: Release # `cmake -S` now implies `-DCMAKE_BUILD_TYPE=Release`.
CMAKE_CONFIG_TYPE: Release # `cmake --build` now implies `--config Release`.
# We instruct CMake to download and build third-party projects in the same place as in `testing.yml`
# to prevent divergence between testing and release workflows.
DEPS_ROOT_DIR: ~/_deps
# We use Ninja as the generator for CMake below because it provides synchronous output by default,
# and only shows full command lines when they fail.
jobs:
windows:
runs-on: windows-2022
strategy:
matrix:
bits: [32, 64]
fail-fast: false
steps:
- name: Checkout repo
uses: actions/checkout@v7
- name: Install deps
run: |
bash .github/scripts/install-deps.sh windows
- name: Build Windows binaries
shell: cmd
run: |
call .github\scripts\msvc-env.bat ${{ matrix.bits }}
cmake -B build -G Ninja -DFETCHCONTENT_BASE_DIR="${{ env.DEPS_ROOT_DIR }}" -DCMAKE_C_FLAGS="/nologo"
cmake --build build -- -k 0
- name: Package binaries
working-directory: build
run: |
cpack -DCPACK_PACKAGE_FILE_NAME=rgbds-win${{ matrix.bits }} -G ZIP --verbose
- name: Upload Windows binaries
uses: actions/upload-artifact@v7
with:
name: win${{ matrix.bits }}
path: build/rgbds-win${{ matrix.bits }}.zip
if-no-files-found: error
macos:
runs-on: macos-26
steps:
- name: Checkout repo
uses: actions/checkout@v7
- name: Install deps
run: |
./.github/scripts/install-deps.sh macos lld
- name: Build binaries
run: |
cmake -B build -G Ninja --preset macos-static -DFETCHCONTENT_BASE_DIR="${{ env.DEPS_ROOT_DIR }}"
cmake --build build -- -k 0
strip rgb{asm,link,fix,gfx}
env:
LDFLAGS: -fuse-ld=lld # cmake/macos-static.cmake comments explain why we use lld.
- name: Create install script
run: |
make install.sh
- name: Package binaries
run: |
zip --junk-paths rgbds-macos.zip rgb{asm,link,fix,gfx} man/* install.sh
- name: Upload macOS binaries
uses: actions/upload-artifact@v7
with:
name: macos
path: rgbds-macos.zip
if-no-files-found: error
linux:
runs-on: ubuntu-22.04 # Oldest supported, for best glibc compatibility.
steps:
- name: Checkout repo
uses: actions/checkout@v7
- name: Install deps
run: |
./.github/scripts/install-deps.sh ubuntu-22.04
- name: Build binaries
run: |
make -k -j "$(getconf _NPROCESSORS_ONLN)" WARNFLAGS="-Wall -Wextra -pedantic -static" PKG_CONFIG="pkg-config --static" Q=
strip rgb{asm,link,fix,gfx}
- name: Create install script
run: |
make install.sh Q=
- name: Package binaries
run: |
tar caf rgbds-linux-x86_64.tar.xz --transform='s#.*/##' rgb{asm,link,fix,gfx} man/* install.sh
- name: Upload Linux binaries
uses: actions/upload-artifact@v7
with:
name: linux
path: rgbds-linux-x86_64.tar.xz
if-no-files-found: error
release:
runs-on: ubuntu-slim
needs: [windows, macos, linux]
permissions:
contents: write
steps:
- name: Checkout repo
uses: actions/checkout@v7
- name: Package sources
run: |
make dist Q=
- name: Download all binary packages
uses: actions/download-artifact@v8
- name: Draft the release
run: |
.github/scripts/draft-release.sh "${ref#refs/tags/}"
env:
ref: ${{ github.ref_name }}
GH_TOKEN: ${{ github.token }} # Required by the `gh` command.
+48
View File
@@ -0,0 +1,48 @@
name: Create release docs
on:
release:
types:
- released # This avoids triggering on pre-releases
env:
# Force colored output (see https://bixense.com/clicolors/ and https://force-color.org/)
TERM: xterm-256color
CLICOLOR: 1
CLICOLOR_FORCE: 1
jobs:
build:
if: github.repository_owner == 'gbdev'
runs-on: ubuntu-slim
steps:
- name: Checkout rgbds@release
uses: actions/checkout@v7
with:
path: rgbds
sparse-checkout: man # Avoid checking out other files, we don't use them here.
- name: Checkout rgbds-www
uses: actions/checkout@v7
with:
path: rgbds-www
repository: ${{ github.repository_owner }}/rgbds-www
ref: master # Need to check out the branch to be able to commit on and push it.
ssh-key: !!str ${{ secrets.SSH_KEY_SECRET }}
- name: Install groff and mandoc
run: |
sudo apt install -Uyq groff mandoc -o APT::Color=yes -o Acquire::Queue-Mode=access
- name: Update pages
working-directory: rgbds/man
run: | # The ref appears to be in the format "refs/tags/<version>", so strip that
../../rgbds-www/maintainer/man_to_html.sh ${GITHUB_REF##*/} *
../../rgbds-www/maintainer/new_release.sh ${GITHUB_REF##*/}
- name: Push new pages
working-directory: rgbds-www
env:
GIT_AUTHOR_NAME: !!str ${{ github.actor }}
GIT_AUTHOR_EMAIL: !!str ${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com
GIT_COMMITTER_NAME: github-actions[bot]
GIT_COMMITTER_EMAIL: 41898282+github-actions[bot]@users.noreply.github.com
run: |
git add -A
git commit -m "Create RGBDS ${GITHUB_REF##*/} documentation"
git push
+411 -67
View File
@@ -1,107 +1,451 @@
name: "Regression testing"
on: push
name: Regression testing
on:
- push
- pull_request
env:
# Force colored output (see https://bixense.com/clicolors/ and https://force-color.org/)
TERM: xterm-256color
CLICOLOR: 1
CLICOLOR_FORCE: 1
CMAKE_COLOR_DIAGNOSTICS: ON # Tells CMake-generated build systems to have colored output.
CMAKE_CONFIG_TYPE: Debug # `cmake --build` now implies `--config Debug`.
CTEST_PARALLEL_LEVEL: "" # `ctest` now implies `--parallel` (default number of logical CPUs).
CTEST_NO_TESTS_ACTION: error # Make CTest fail if it cannot find any tests. (That should never happen.)
CTEST_OUTPUT_ON_FAILURE: ON # CTest reports test program output on failure.
GIT_CONFIG_COUNT: 1
GIT_CONFIG_KEY_0: color.ui
GIT_CONFIG_VALUE_0: always # Colorful output is helpful even though CI is not considered to be a terminal.
# We instruct CMake to download and build third-party projects outside of our source tree,
# otherwise they can trigger `-Werror=dev` (from the `develop` preset).
DEPS_ROOT_DIR: ~/_deps # Note that this needs to be used in a position where Bash will trigger tilde expansion!
# We use bash syntax across OSes for consistency unless otherwise specified
defaults:
run:
shell: bash
# We use Ninja as the generator for CMake below because it provides synchronous output by default,
# and only shows full command lines when they fail.
jobs:
unix-testing:
unix:
strategy:
matrix:
os: [ubuntu-20.04, ubuntu-18.04, ubuntu-16.04, macos-10.15]
cc: [gcc, clang]
include:
- os: ubuntu-18.04
cc: gcc
target: develop
os: [ubuntu-22.04, macos-15-intel, macos-26]
cxx: [g++, clang++]
buildsys: [make, cmake]
exclude: # Don't use `g++` on macOS; it's just an alias to `clang++`.
- { os: macos-15-intel, cxx: g++ }
- { os: macos-26, cxx: g++ }
include: # Use `g++-10`, the earliest GCC version we support, on the earliest Ubuntu runner.
- { os: ubuntu-22.04, cxx: g++-10, buildsys: make }
- { os: ubuntu-22.04, cxx: g++-10, buildsys: cmake }
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- name: Checkout repo
uses: actions/checkout@v7
- name: Install deps
shell: bash
run: |
./.github/actions/install_deps.sh ${{ matrix.os }}
- name: Build
.github/scripts/install-deps.sh ${{ matrix.os }} ${{ matrix.cxx }}
- name: Build using Make
if: matrix.buildsys == 'make'
run: |
make ${{ matrix.target }} -j Q= CC=${{ matrix.cc }}
- name: Install
make develop -k -j "$(getconf _NPROCESSORS_ONLN)" Q= CXX=${{ matrix.cxx }}
- name: Install using Make
if: matrix.buildsys == 'make'
run: |
sudo make install -j Q=
sudo make install Q=
type rgbasm rgblink rgbfix rgbgfx
man -w 1 rgbasm rgblink rgbfix rgbgfx
- name: Build using CMake
if: matrix.buildsys == 'cmake'
# Since GitHub's runners are basically kitchen sinks,
# the Mono framework exposes a libpng 1.4.x header, breaking everything.
# Searching frameworks last makes Homebrew's libpng be discovered first, which works.
# Note that since this is specific to our CI environment, the workaround is
# better applied here than in our CMakeLists, where it could affect and break someone else.
run: |
CXX=${{ matrix.cxx }} cmake -B build -G Ninja --preset develop -DCMAKE_FIND_FRAMEWORK=LAST
cmake --build build -- -k 0
- name: Install using CMake
if: matrix.buildsys == 'cmake'
run: |
sudo cmake --install build --verbose
type rgbasm rgblink rgbfix rgbgfx
man -w 1 rgbasm rgblink rgbfix rgbgfx
- name: Package binaries
run: |
mkdir bins
cp rgb{asm,link,fix,gfx} bins
- name: Upload binaries
uses: actions/upload-artifact@v1
uses: actions/upload-artifact@v7
with:
name: rgbds-canary-${{ matrix.os }}-${{ matrix.cc }}
name: rgbds-canary-${{ matrix.os }}-${{ matrix.cxx }}-${{ matrix.buildsys }}
path: bins
- name: Test
shell: bash
if-no-files-found: error
- name: Compute test dependency cache params
id: test-deps-cache-params
run: |
test/run-tests.sh
paths=$(test/external/fetch-repos.sh --get-paths)
hash=$(test/external/fetch-repos.sh --get-hash)
tee -a <<<"paths=\"${paths//,/\\n}\"" $GITHUB_OUTPUT
tee -a <<<"hash=${hash%-}" $GITHUB_OUTPUT
- name: Check test dependency repositories cache
id: test-deps-cache
uses: actions/cache@v5
with:
path: ${{ fromJSON(steps.test-deps-cache-params.outputs.paths) }}
key: ${{ matrix.os }}-${{ steps.test-deps-cache-params.outputs.hash }}
- name: Fetch test dependency repositories
if: steps.test-deps-cache.outputs.cache-hit != 'true'
continue-on-error: true
run: |
test/external/fetch-repos.sh
- name: Run tests using our script
if: matrix.buildsys == 'make'
run: |
CXX=${{ matrix.cxx }} test/run-tests.sh --os ${{ matrix.os }} --jobs "$(getconf _NPROCESSORS_ONLN)"
- name: Run tests using CTest
if: matrix.buildsys == 'cmake'
run: |
ctest --test-dir build --schedule-random
windows-build:
strategy:
matrix:
bits: [32, 64]
os: [ubuntu-latest]
include:
- bits: 32
arch: i686
triplet: i686-w64-mingw32
- bits: 64
arch: x86-64
triplet: x86_64-w64-mingw32
runs-on: ${{ matrix.os }}
env:
DIST_DIR: win${{ matrix.bits }}
macos-static:
runs-on: macos-26
steps:
- uses: actions/checkout@v2
- name: Checkout repo
uses: actions/checkout@v7
- name: Install deps
shell: bash
run: |
./.github/actions/install_deps.sh ${{ matrix.os }}
- name: Install MinGW
.github/scripts/install-deps.sh macos lld
- name: Cache library deps
uses: actions/cache@v5
with:
path: ${{ env.DEPS_ROOT_DIR }}/*-tmp/
key: dep-srcs-${{ hashFiles('cmake/deps.cmake') }}
enableCrossOsArchive: true
- name: Build
run: |
sudo apt-get install gcc-mingw-w64-${{ matrix.arch }} mingw-w64-tools libz-mingw-w64-dev
- name: Install libpng dev headers for MinGW
cmake -B build -G Ninja --preset macos-static -DFETCHCONTENT_BASE_DIR="${{ env.DEPS_ROOT_DIR }}"
cmake --build build -- -k 0
env:
LDFLAGS: -fuse-ld=lld # cmake/macos-static.cmake comments explain why we use lld.
- name: Install
run: |
sudo ./.github/actions/mingw-w64-libpng-dev.sh ${{ matrix.triplet }}
- name: Build Windows binaries
run: |
make mingw${{ matrix.bits }} -j Q=
sudo cmake --install build --verbose
type rgbasm rgblink rgbfix rgbgfx
man -w 1 rgbasm rgblink rgbfix rgbgfx
- name: Package binaries
run: |
mkdir bins
mv rgbasm bins/rgbasm.exe
mv rgblink bins/rgblink.exe
mv rgbfix bins/rgbfix.exe
mv rgbgfx bins/rgbgfx.exe
cp /usr/${{ matrix.triplet }}/lib/zlib1.dll bins
cp /usr/${{ matrix.triplet }}/bin/libpng16-16.dll bins
if [ ${{ matrix.bits }} -eq 32 ]; then cp /usr/lib/gcc/${{ matrix.triplet }}/7.3-win32/libgcc_s_sjlj-1.dll bins; fi
- name: Upload Windows binaries
uses: actions/upload-artifact@v1
cp rgb{asm,link,fix,gfx} bins
- name: Upload binaries
uses: actions/upload-artifact@v7
with:
name: rgbds-canary-win${{ matrix.bits }}
name: rgbds-canary-macos-static
path: bins
if-no-files-found: error
- name: Compute test dependency cache params
id: test-deps-cache-params
run: |
paths=$(test/external/fetch-repos.sh --get-paths)
hash=$(test/external/fetch-repos.sh --get-hash)
tee -a <<<"paths=\"${paths//,/\\n}\"" $GITHUB_OUTPUT
tee -a <<<"hash=${hash%-}" $GITHUB_OUTPUT
- name: Check test dependency repositories cache
id: test-deps-cache
uses: actions/cache@v5
with:
path: ${{ fromJSON(steps.test-deps-cache-params.outputs.paths) }}
key: macos-26-${{ steps.test-deps-cache-params.outputs.hash }}
- name: Fetch test dependency repositories
if: steps.test-deps-cache.outputs.cache-hit != 'true'
continue-on-error: true
run: |
test/external/fetch-repos.sh
- name: Run tests
run: |
ctest --test-dir build --schedule-random
windows-testing:
needs: windows-build
windows:
strategy:
matrix:
bits: [32, 64]
runs-on: windows-2019
os: [windows-2022, windows-2025]
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- name: Retrieve binaries
uses: actions/download-artifact@v1
- name: Checkout repo
uses: actions/checkout@v7
- name: Install deps
run: |
bash .github/scripts/install-deps.sh ${{ matrix.os }}
- name: Cache library deps
uses: actions/cache@v5
with:
name: rgbds-canary-win${{ matrix.bits }}
path: ${{ env.DEPS_ROOT_DIR }}/*-tmp/
key: dep-srcs-${{ hashFiles('cmake/deps.cmake') }}
enableCrossOsArchive: true
- name: Build
shell: cmd
run: | # ASan seems to be broken on Windows, so we disable it.
call .github\scripts\msvc-env.bat ${{ matrix.bits }}
cmake -B build -G Ninja --preset develop -DFETCHCONTENT_BASE_DIR="${{ env.DEPS_ROOT_DIR }}" ^
-DSANITIZERS=OFF -DCMAKE_C_FLAGS="/nologo"
cmake --build build -- -k 0
- name: Install
shell: cmd
run: |
cmake --install build --verbose
where rgbasm rgblink rgbfix rgbgfx
- name: Package binaries
working-directory: build
run: |
cpack -DCPACK_PACKAGE_FILE_NAME=rgbds-win${{ matrix.bits }} -G ZIP --verbose
- name: Upload Windows binaries
uses: actions/upload-artifact@v7
with:
name: rgbds-canary-w${{ matrix.bits }}-${{ matrix.os }}
path: build/rgbds-win${{ matrix.bits }}.zip
if-no-files-found: error
- name: Compute test dependency cache params
id: test-deps-cache-params
run: |
paths=$(test/external/fetch-repos.sh --get-paths)
hash=$(test/external/fetch-repos.sh --get-hash)
tee -a <<<"paths=\"${paths//,/\\n}\"" $GITHUB_OUTPUT
tee -a <<<"hash=${hash%-}" $GITHUB_OUTPUT
- name: Check test dependency repositories cache
id: test-deps-cache
uses: actions/cache@v5
with:
path: ${{ fromJSON(steps.test-deps-cache-params.outputs.paths) }}
key: ${{ matrix.os }}-${{ matrix.bits }}-${{ steps.test-deps-cache-params.outputs.hash }}
- name: Fetch test dependency repositories
if: steps.test-deps-cache.outputs.cache-hit != 'true'
continue-on-error: true
run: |
test/external/fetch-repos.sh
- name: Run tests using CTest
run: |
ctest --test-dir build --schedule-random
windows-mingw-build:
strategy:
matrix:
bits: [32, 64]
fail-fast: false
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v7
- name: Install deps
run: |
.github/scripts/install-deps.sh ubuntu mingw${{ matrix.bits }}
- name: Cache library deps
uses: actions/cache@v5
with:
path: ${{ env.DEPS_ROOT_DIR }}/*-tmp/
key: dep-srcs-${{ hashFiles('cmake/deps.cmake') }}
enableCrossOsArchive: true
- name: Cross-build Windows binaries
run: | # MinGW doesn't support `--preset develop` sanitizers ASan or UBSan, so we disable them.
dll_search_dir=$(printf '%s\n' /usr/lib/gcc/*-w64-mingw32/*-win32 | tee -a /dev/stderr)
cmake -B build -G Ninja --preset develop -DFETCHCONTENT_BASE_DIR="${{ env.DEPS_ROOT_DIR }}" \
-DSANITIZERS=OFF -DDLL_SEARCH_DIRS="$dll_search_dir" \
--toolchain cmake/toolchain-mingw${{ matrix.bits }}.cmake
cmake --build build -- -k 0
- name: Package Windows binaries
run: |
cmake --install build --prefix . --verbose --component binaries
cmake --install build --prefix . --verbose --component shared-libs
- name: Upload Windows binaries
uses: actions/upload-artifact@v7
with:
name: rgbds-canary-mingw-win${{ matrix.bits }}
path: bin
if-no-files-found: error
- name: Upload Windows test binaries
uses: actions/upload-artifact@v7
with:
name: testing-programs-mingw-win${{ matrix.bits }}
path: |
test/gfx/randtilegen.exe
test/gfx/rgbgfx_test.exe
if-no-files-found: error
windows-mingw-testing:
needs: windows-mingw-build
strategy:
matrix:
os: [windows-2022, windows-2025]
bits: [32, 64]
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
- name: Checkout repo
uses: actions/checkout@v7
- name: Install test deps
run: |
.github/scripts/install-deps.sh windowsmingw
- name: Retrieve binaries
uses: actions/download-artifact@v8
with:
name: rgbds-canary-mingw-win${{ matrix.bits }}
path: bins
- name: Retrieve test binaries
uses: actions/download-artifact@v8
with:
name: testing-programs-mingw-win${{ matrix.bits }}
path: test/gfx
- name: Extract binaries
shell: bash
run: |
cp bins/* .
- name: Run tests
shell: bash
cp bins/*.dll test/gfx
- name: Compute test dependency cache params
id: test-deps-cache-params
run: |
test/run-tests.sh
paths=$(test/external/fetch-repos.sh --get-paths)
hash=$(test/external/fetch-repos.sh --get-hash)
tee -a <<<"paths=\"${paths//,/\\n}\"" $GITHUB_OUTPUT
tee -a <<<"hash=${hash%-}" $GITHUB_OUTPUT
- name: Check test dependency repositories cache
id: test-deps-cache
uses: actions/cache@v5
with:
path: ${{ fromJSON(steps.test-deps-cache-params.outputs.paths) }}
key: mingw-${{ matrix.bits }}-${{ steps.test-deps-cache-params.outputs.hash }}
- name: Fetch test dependency repositories
if: steps.test-deps-cache.outputs.cache-hit != 'true'
continue-on-error: true
run: |
test/external/fetch-repos.sh
- name: Run tests
run: |
test/run-tests.sh --os ${{ matrix.os }} --jobs "$(getconf _NPROCESSORS_ONLN)"
cygwin:
strategy:
matrix:
arch: [x86, x86_64]
fail-fast: false
runs-on: windows-2022
timeout-minutes: 30
env:
CYGWIN_NOWINPATH: 1
CHERE_INVOKING: 1
defaults:
run:
shell: C:\cygwin\bin\bash.exe -leo igncr '{0}'
steps:
- name: Save Windows git location for the PATH
shell: pwsh
run: | # The `cygwin/cygwin-install-action` step will override the PATH with Cygwin's binaries
"ORIGINAL_GIT_DIR=$(Split-Path (Get-Command git).Source)" >> $env:GITHUB_ENV
- name: Checkout repo
uses: actions/checkout@v7
- name: Setup Cygwin
uses: cygwin/cygwin-install-action@v6
with:
platform: ${{ matrix.arch }}
packages: >-
bison
cmake
gcc-g++
git
libpng-devel
make
ninja
pkg-config
python3
python-imaging
- name: Build using Make
if: matrix.arch == 'x86'
run: | # Cygwin doesn't support `make develop` sanitizers ASan or UBSan, so we don't use it.
make -k -j "$(getconf _NPROCESSORS_ONLN)" Q=
- name: Install using Make
if: matrix.arch == 'x86'
run: |
make install Q=
type rgbasm rgblink rgbfix rgbgfx
man -w 1 rgbasm rgblink rgbfix rgbgfx
- name: Build using CMake
if: matrix.arch == 'x86_64'
run: | # Cygwin doesn't support `--preset develop` sanitizers ASan or UBSan, so we disable them.
cmake -B build -G Ninja --preset develop -DSANITIZERS=OFF
cmake --build build -- -k 0
- name: Install using CMake
if: matrix.arch == 'x86_64'
run: |
cmake --install build --verbose
type rgbasm rgblink rgbfix rgbgfx
man -w 1 rgbasm rgblink rgbfix rgbgfx
- name: Compute test dependency cache params
id: test-deps-cache-params
run: |
paths=$(test/external/fetch-repos.sh --get-paths)
hash=$(test/external/fetch-repos.sh --get-hash)
tee -a <<<"paths=\"${paths//,/\\n}\"" $GITHUB_OUTPUT
tee -a <<<"hash=${hash%-}" $GITHUB_OUTPUT
- name: Check test dependency repositories cache
id: test-deps-cache
uses: actions/cache@v5
with:
path: ${{ fromJSON(steps.test-deps-cache-params.outputs.paths) }}
key: cygwin-${{ matrix.bits }}-${{ steps.test-deps-cache-params.outputs.hash }}
- name: Fetch test dependency repositories
if: steps.test-deps-cache.outputs.cache-hit != 'true'
continue-on-error: true
run: |
test/external/fetch-repos.sh
- name: Run tests using our script
if: matrix.arch == 'x86'
run: | # 32-bit Cygwin's `git` 2.38 doesn't support `git clone --revision`, so we don't fetch/run external tests.
test/run-tests.sh --os cygwin --only-internal --jobs "$(getconf _NPROCESSORS_ONLN)"
- name: Run tests using CTest
if: matrix.arch == 'x86_64'
run: |
ctest --test-dir build --schedule-random
- name: Use Windows git location in the PATH
shell: pwsh
run: | # Prevents the `actions/checkout` post-job cleanup from using Cygwin's git binary
"$env:ORIGINAL_GIT_DIR" >> $env:GITHUB_PATH
freebsd:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout repo
uses: actions/checkout@v7
- name: Build & test using CMake on FreeBSD
uses: vmactions/freebsd-vm@v1
with:
envs: >-
TERM CLICOLOR CLICOLOR_FORCE
CMAKE_COLOR_DIAGNOSTICS CMAKE_CONFIG_TYPE
CTEST_PARALLEL_LEVEL
CTEST_NO_TESTS_ACTION CTEST_OUTPUT_ON_FAILURE
GIT_CONFIG_COUNT GIT_CONFIG_KEY_0 GIT_CONFIG_VALUE_0
release: "15.1"
usesh: true
copyback: false
prepare: |
.github/scripts/install-deps.sh freebsd
run: |
: # Build
cmake -B build -G Ninja --preset develop
cmake --build build -- -k 0
: # Install
cmake --install build --verbose
type rgbasm rgblink rgbfix rgbgfx
man -w 1 rgbasm rgblink rgbfix rgbgfx
: # Run tests
: # Leak detection is not supported on FreeBSD, so we disable it.
. .github/scripts/freebsd-env.sh
ASAN_OPTIONS=detect_leaks=0 ctest --test-dir build --schedule-random
+50
View File
@@ -0,0 +1,50 @@
name: Update master docs
on:
push:
branches:
- master
paths:
- man/*
workflow_dispatch:
env:
# Force colored output (see https://bixense.com/clicolors/ and https://force-color.org/)
TERM: xterm-256color
CLICOLOR: 1
CLICOLOR_FORCE: 1
jobs:
build:
if: github.repository_owner == 'gbdev'
runs-on: ubuntu-slim
steps:
- name: Checkout rgbds
uses: actions/checkout@v7
with:
path: rgbds
sparse-checkout: man # Avoid checking out other files, we don't use them here.
- name: Checkout rgbds-www
uses: actions/checkout@v7
with:
path: rgbds-www
repository: ${{ github.repository_owner }}/rgbds-www
ref: master # Need to check out the branch to be able to commit on and push it.
ssh-key: !!str ${{ secrets.SSH_KEY_SECRET }}
- name: Install groff and mandoc
run: |
sudo apt install -Uyq groff mandoc -o APT::Color=yes -o Acquire::Queue-Mode=access
- name: Update pages
working-directory: rgbds/man
run: |
../../rgbds-www/maintainer/man_to_html.sh master *
- name: Push new pages
working-directory: rgbds-www
env:
GIT_AUTHOR_NAME: !!str ${{ github.actor }}
GIT_AUTHOR_EMAIL: !!str ${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com
GIT_COMMITTER_NAME: github-actions[bot]
GIT_COMMITTER_EMAIL: 41898282+github-actions[bot]@users.noreply.github.com
run: |
git add -A
git commit -m "Update RGBDS master documentation"
git push
+17 -11
View File
@@ -1,15 +1,21 @@
rgbasm
rgblink
rgbfix
rgbgfx
rgbshim.sh
/rgbasm
/rgblink
/rgbfix
/rgbgfx
/install.sh
/rgbshim.sh
/coverage/
*.o
*.exe
.checkpatch-camelcase.*
*.dll
*.gcno
*.gcda
*.gcov
/compile_flags.txt
CMakeCache.txt
CMakeFiles
CMakeFiles/
cmake_install.cmake
test/pokecrystal
test/pokered
test/ucity
CMakeUserPresets.json
build*/
*.dSYM/
callgrind.out.*
+208 -48
View File
@@ -1,71 +1,231 @@
#
# This file is part of RGBDS.
#
# Copyright (c) 2020 RGBDS contributors.
#
# SPDX-License-Identifier: MIT
#
cmake_minimum_required(VERSION 2.8.8)
# - 3.24 is required for `FetchContent`'s `find_package` integration.
# Older versions *may* work, but we can't test them; compat patches are welcome.
# - 3.17 is required for `CHECK_*` messages to display properly, but is not essential.
# - 3.9 is required for LTO checks.
cmake_minimum_required(VERSION 3.24...4.3 FATAL_ERROR)
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
# Read the project version from the header (the canonical source of truth).
file(STRINGS "include/version.hpp" version_defines REGEX "^[ \t]*#define[ \t]+PACKAGE_VERSION_")
foreach(line IN LISTS version_defines)
# We want the `CMAKE_MATCH_n` variables, so we just need to run *some* regex op.
string(REGEX MATCH "PACKAGE_(VERSION_[^ \t]+)[ \t]+([0-9]+)" dummy "${line}")
set("${CMAKE_MATCH_1}" "${CMAKE_MATCH_2}")
endforeach()
set(RGBDS_VER 0.4.1)
set(RGBDS_DESC "Rednex Game Boy Development System")
project(rgbds
VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}"
LANGUAGES CXX
DESCRIPTION "Game Boy assembly toolchain"
HOMEPAGE_URL "https://rgbds.gbdev.io")
if(DEFINED VERSION_RC)
string(APPEND CMAKE_PROJECT_VERSION "-rc${VERSION_RC}")
endif()
if(CMAKE_VERSION VERSION_LESS 3.0)
project(rgbds C)
set(PROJECT_VERSION "${RGBDS_VER}")
else()
if(CMAKE_VERSION VERSION_LESS 3.9)
project(rgbds VERSION "${RGBDS_VER}"
LANGUAGES C)
else()
project(rgbds VERSION "${RGBDS_VER}"
DESCRIPTION "${RGBDS_DESC}"
LANGUAGES C)
# Reject in-source builds, as they may conflict with the Makefile.
get_filename_component(srcdir "${CMAKE_SOURCE_DIR}" REALPATH)
get_filename_component(bindir "${CMAKE_BINARY_DIR}" REALPATH)
if(srcdir STREQUAL bindir)
message(FATAL_ERROR "RGBDS should not be built in the source directory.
Instead, create a separate build directory and specify to CMake the path to the source directory.")
endif()
include(CTest) # Note: CTest only functions properly if included from the top-level CMakeLists.
include(GNUInstallDirs)
include(CMakeDependentOption)
## Compiler switches that should apply to our deps too.
option(SANITIZERS "Build with sanitizers enabled" OFF)
cmake_dependent_option(MORE_WARNINGS "Turn on more warnings" OFF "NOT MSVC" OFF)
if(NOT DEFINED CMAKE_MSVC_RUNTIME_LIBRARY) # Allow this to be overridden from the CLI easily.
# We link against the Microsoft C++ runtime libs statically, except the debug-mode one.
# This is because Microsoft's license terms (through some indirection) allow us to redistribute
# the runtime lib code *except* the debug-mode libs'.
# Since we want to remain able to not think too hard about debug executables, we link against
# the debug libs dynamically, shifting the burden of obtaining them onto the recipient.
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:DebugDLL>")
endif()
if(SANITIZERS)
if(MSVC)
message(STATUS "ASan enabled")
add_compile_options(/fsanitize=address) # Note that this shouldn't be passed to the linker.
else() # We assume a GNU-like compiler.
message(STATUS "ASan and UBSan enabled")
set(SAN_FLAGS -fsanitize=address -fsanitize=undefined
-fsanitize=float-divide-by-zero)
add_compile_options(${SAN_FLAGS})
add_link_options(${SAN_FLAGS})
add_definitions(-D_GLIBCXX_ASSERTIONS -D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_DEBUG)
# A non-zero optimization level is desired even in debug mode (especially for Clang),
# and the two codegen flags improve the sanitizers' backtraces, but we want the user to
# be able to override these easily so we put them first.
string(PREPEND CMAKE_CXX_FLAGS_DEBUG "-Og -fno-omit-frame-pointer -fno-optimize-sibling-calls ")
endif()
endif()
if(CMAKE_VERSION VERSION_LESS 3.9)
set(PROJECT_DESCRIPTION "${RGBDS_DESC}")
message(CHECK_START "Checking if LTO is supported")
include(CheckIPOSupported)
check_ipo_supported(RESULT enable_lto)
if(enable_lto)
message(CHECK_PASS "yes (enabled only in release modes)")
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE ON)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELWITHDEBINFO ON)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_MINSIZEREL ON)
else()
message(CHECK_FAIL "no")
endif()
set(DEFAULT_BUILD_TYPE "Release")
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "${DEFAULT_BUILD_TYPE}")
# Use versioning consistent with Makefile:
# the git revision is used but uses the fallback in an archive.
message(CHECK_START "Determining RGBDS version from Git history")
list(APPEND CMAKE_MESSAGE_INDENT " ")
set(GIT_REV "") # This fallback is important!
find_package(Git)
list(POP_BACK CMAKE_MESSAGE_INDENT)
if(NOT Git_FOUND)
message(CHECK_FAIL "Git not found")
else()
execute_process(COMMAND "${GIT_EXECUTABLE}" --git-dir=.git -c safe.directory='*'
describe --tags --dirty --always --match "v[0-9]*"
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
OUTPUT_VARIABLE GIT_REV OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_VARIABLE git_err ERROR_STRIP_TRAILING_WHITESPACE
RESULT_VARIABLE result)
if(NOT result EQUAL 0)
# Note that this happens e.g. when building from a tarball, so it shouldn't fail the build!
message(CHECK_FAIL "error ${result} from Git:")
list(APPEND CMAKE_MESSAGE_INDENT " ")
message("${git_err}")
list(POP_BACK CMAKE_MESSAGE_INDENT)
else()
message(CHECK_PASS "${GIT_REV}")
if(NOT "${GIT_REV}" MATCHES "^v[0-9]+\\.[0-9]+\\.[0-9]+(-rc[0-9]+)?")
# Can't find an ancestor tag! (That passes `--match`, anyway.)
message(WARNING "No `v*` Git tag reachable; falling back")
elseif(NOT CMAKE_MATCH_0 STREQUAL "v${CMAKE_PROJECT_VERSION}")
message(SEND_ERROR "\
Version mismatch! Git says ${CMAKE_MATCH_0},
version.hpp says v${CMAKE_PROJECT_VERSION}!")
endif()
endif()
endif()
# get real path of source and binary directories
get_filename_component(srcdir "${CMAKE_SOURCE_DIR}" REALPATH)
get_filename_component(bindir "${CMAKE_BINARY_DIR}" REALPATH)
## Dependencies.
# reject in-source builds, may conflict with Makefile
if(srcdir STREQUAL bindir)
message("RGBDS should not be built in the source directory.")
message("Instead, create a separate build directory and specify to CMake the path to the source directory.")
message(FATAL_ERROR "Terminating configuration")
include(FetchContent)
include(cmake/deps.cmake)
# Be sure to make zlib available before libpng, otherwise libpng
# will attempt to `find_package(ZLIB)` without going through `FetchContent`.
if(NOT DEFINED ZLIB_BUILD_TESTING) # Unless overridden (e.g. in the cache), we don't care about zlib's tests.
set(ZLIB_BUILD_TESTING OFF)
endif()
FetchContent_MakeAvailable(ZLIB)
if(NOT DEFINED ZLIB_INCLUDE_DIRS)
set(ZLIB_INCLUDE_DIRS "${zlib_BINARY_DIR};${zlib_SOURCE_DIR}") # libpng's `genout` script relies on this variable to be set.
endif()
# Statically building zlib (from source) generates a target named differently.
if(NOT TARGET ZLIB::ZLIB AND TARGET zlibstatic)
add_library(ZLIB::ZLIB ALIAS zlibstatic)
endif()
find_package(PNG 1.2 REQUIRED)
find_package(BISON REQUIRED)
find_package(FLEX)
if(NOT DEFINED PNG_TESTS) # Unless overridden (e.g. in the cache), we don't care about libpng's tests.
set(PNG_TESTS OFF)
endif()
FetchContent_MakeAvailable(PNG)
if(NOT TARGET PNG::PNG)
if(PNG_SHARED)
add_library(PNG::PNG ALIAS png_shared)
else()
add_library(PNG::PNG ALIAS png_static)
endif()
endif()
include_directories("${PROJECT_SOURCE_DIR}/include")
## The actual stuff.
# Any compiler options that shouldn't apply to our dependencies go here.
include_directories("include")
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED True)
if(MSVC)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W1 /MP -D_CRT_SECURE_NO_WARNINGS")
add_compile_options(
/wd5030 # Warning C5030 is about unknown attributes (`[[gnu::ATTR]]`), none of ours being load-bearing.
/wd4996 # Warning C4996 is about using POSIX names, which we want to do for portability.
/Zc:preprocessor # Opt into the C++20-conformant preprocessor.
)
add_definitions(/D_CRT_SECURE_NO_WARNINGS)
else()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -pedantic")
endif()
add_compile_options(-Wall -pedantic -Wno-unknown-warning-option -fno-exceptions -fno-rtti)
if(CMAKE_VERSION VERSION_LESS 3.12)
add_definitions(-DBUILD_VERSION_STRING="${PROJECT_VERSION}")
else()
add_compile_definitions(BUILD_VERSION_STRING="${PROJECT_VERSION}")
endif()
if(MORE_WARNINGS)
add_compile_options(-Wextra
-Walloc-zero -Wcast-align -Wcast-qual -Wduplicated-branches -Wduplicated-cond
-Wfloat-equal -Wlogical-op -Wnull-dereference -Wold-style-cast -Wshift-overflow=2
-Wstringop-overflow=4 -Wtrampolines -Wundef -Wuninitialized -Wunused -Wshadow
-Wformat=2 -Wformat-overflow=2 -Wformat-truncation=1
-Wno-format-nonliteral -Wno-strict-overflow
-Wno-type-limits -Wno-tautological-constant-out-of-range-compare
-Wvla) # MSVC does not support VLAs
endif()
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED True)
add_compile_options(-Wno-unused-but-set-variable # bison's `yynerrs_` is incremented but unused
# C++20 allows macros to take zero variadic arguments.
# Some versions of Clang don't recognize this, and treat them as a GNU extension.
-Wno-gnu-zero-variadic-macro-arguments)
if(MINGW)
# MinGW warns about format specifiers like `%z` and `%j`, which are missing on Windows XP and earlier.
# We rely on runtimes more modern than that, so we can ignore those warnings.
# If this is a problem for you: use Microsoft's equivalents, or define `__USE_MINGW_ANSI_STDIO=1`.
# https://sourceforge.net/p/mingw-w64/wiki2/gnu%20printf/
add_compile_options(-Wno-error=format -Wno-error=format-extra-args)
endif()
endif()
add_subdirectory(src)
if(BUILD_TESTING) # This option is defined implicitly by `include(CTest)`.
add_subdirectory(test)
endif()
set(man1 "man/rgbasm.1"
"man/rgbfix.1"
"man/rgbgfx.1"
"man/rgblink.1")
set(man5 "man/rgbasm.5"
"man/rgbasm-old.5"
"man/rgblink.5"
"man/rgbds.5")
set(man7 "man/gbz80.7"
"man/rgbds.7")
foreach(SECTION "man1" "man5" "man7")
install(FILES ${${SECTION}} DESTINATION "${CMAKE_INSTALL_MANDIR}/${SECTION}" COMPONENT man)
endforeach()
## Packaging.
# We only specify here the package-agnostic options;
# the rest is rather convention from our side, and thus more appropriate for presets or CLI flags.
## CPACK_PACKAGE_NAME: copied from `project()`
set(CPACK_PACKAGE_VENDOR "GBDev")
set(CPACK_PACKAGE_VERSION "${CMAKE_PROJECT_VERSION}") # The individual components are defined implicitly.
set(CPACK_PACKAGE_DESCRIPTION "An assembly toolchain for the Nintendo Game Boy and Game Boy Color") # Same as our repo's description.
## CPACK_PACKAGE_DESCRIPTION_SUMMARY: copied from `project()`
set(CPACK_PACKAGE_HOMEPAGE_URL "https://rgbds.gbdev.io")
## CPACK_PACKAGE_FILE_NAME: should be provided at runtime (`cpack -P`)
set(CPACK_PACKAGE_CHECKSUM SHA256)
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE")
set(CPACK_RESOURCE_FILE_README "${CMAKE_SOURCE_DIR}/README.md")
set(CPACK_STRIP_FILES ON) # Only applies to binary packages, not sources.
set(CPACK_VERBATIM_VARIABLES ON)
set(CPACK_THREADS 0) # Use all available CPU cores.
set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY OFF)
include(CPack)
+46
View File
@@ -0,0 +1,46 @@
{
"version": 3,
"configurePresets": [
{
"name": "develop",
"description": "Debugging config for maintainers",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"CMAKE_EXPORT_COMPILE_COMMANDS": true,
"CMAKE_COMPILE_WARNING_AS_ERROR": true,
"CMAKE_LINK_WARNING_AS_ERROR": true,
"MORE_WARNINGS": true,
"SANITIZERS": true
},
"warnings": { "uninitialized": true },
"errors": { "dev": true }
},
{
"name": "develop-msbuild32",
"inherits": ["develop", "msbuild32"]
},
{
"name": "develop-msbuild64",
"inherits": ["develop", "msbuild64"]
},
{
"name": "msbuild32",
"description": "Flags for building 32-bit executables with MSBuild",
"architecture": "Win32"
},
{
"name": "msbuild64",
"description": "Flags for building 64-bit executables with MSBuild",
"architecture": "x64"
},
{
"name": "macos-static",
"description": "Flags for building an executable compatible with old macOS",
"cacheVariables": {
"CMAKE_PROJECT_TOP_LEVEL_INCLUDES": "cmake/macos-static.cmake"
}
}
]
}
-96
View File
@@ -1,96 +0,0 @@
Contributing
============
RGBDS was created in the late 90's and has received contributions from several
developers since then. It wouldn't have been possible to get to this point
without their work and, for that reason, it is always open to the contributions
of other people.
Reporting Bugs
--------------
Bug reports are essential to improve RGBDS and they are always welcome. If you
want to report a bug:
1. Make sure that there isn't a similar issue already reported
`here <https://github.com/rednex/rgbds/issues>`__.
2. Figure out a way of reproducing it reliably.
3. If there is a piece of code that triggers the bug, try to reduce it to the
smallest file you can.
4. Create a new `issue <https://github.com/rednex/rgbds/issues>`__.
Of course, it may not always be possible to give an accurate bug report, but it
always helps to fix it.
Requesting new features
-----------------------
If you come up with a good idea that could be implemented, you can propose it to
be done.
1. Create a new `issue <https://github.com/rednex/rgbds/issues>`__.
2. Try to be as accurate as possible. Describe what you need and why you need
it, maybe with examples.
Please understand that the contributors are doing it in their free time, so
simple requests are more likely to catch the interest of a contributor than
complicated ones. If you really need something to be done, and you think you can
implement it yourself, you can always contribute to RGBDS with your own code.
Contributing code
-----------------
If you want to contribute with your own code, whether it is to fix a current
issue or to add something that nobody had requested, you should first consider
if your change is going to be small (and likely to be accepted as-is) or big
(and will have to go through some rework).
Big changes will most likely require some discussion, so open an
`issue <https://github.com/rednex/rgbds/issues>`__ and explain what you want to
do and how you intend to do it. If you already have a prototype, it's always a
good idea to show it. Tests help, too.
If you are going to work on a specific issue that involves a lot of work, it is
always a good idea to leave a message, just in case someone else is interested
but doesn't know that there's someone working on it.
Note that you must contribute all your changes under the MIT License. If you are
just modifying a file, you don't need to do anything (maybe update the copyright
years). If you are adding new files, you need to use the correct header with the
copyright and the reference to the MIT License.
1. Fork this repository.
2. Checkout the ``master`` branch.
3. Create a new branch to work on. You could still work on ``master``, but it's
easier that way.
4. Compile your changes with ``make develop`` instead of just ``make``. This
target checks for additional warnings. Your patches shouldn't introduce any
new warning (but it may be possible to remove some warning checks if it makes
the code much easier).
5. Follow the Linux kernel coding style, which can be found in the file
``Documentation/process/coding-style.rst`` in the Linux kernel repository.
Note that the coding style isn't written in stone, if there is a good reason
to deviate from it, it should be fine.
6. Download the files ``checkpatch.pl``, ``const_structs.checkpatch`` and
``spelling.txt`` from the folder ``scripts`` in the Linux kernel repository.
7. To use ``checkpatch.pl`` you can use ``make checkpatch``, which will check
the coding style of all patches between the current one and the upstream
code. By default, the Makefile expects the script (and associate files) to be
located in ``../linux/scripts/``, but you can place them anywhere you like as
long as you specify it when executing the command:
``make checkpatch CHECKPATCH=../path/to/folder``.
8. Create a pull request against the branch ``master``.
9. Be prepared to get some comments about your code and to modify it. Tip: Use
``git rebase -i origin/master`` to modify chains of commits.
-51
View File
@@ -1,51 +0,0 @@
Contributors to RGBDS
=====================
Original author
---------------
- Carsten Elton Sørensen <[email protected]>
Main contributors
-----------------
- Justin Lloyd <[email protected]>
- Vegard Nossum <[email protected]>
- Anthony J. Bentley <[email protected]>
- stag019 <[email protected]>
- Antonio Niño Díaz <[email protected]>
Other contributors
------------------
- Ben Hetherington <[email protected]>
- Björn Höhrmann <[email protected]>
- Christophe Staïesse <[email protected]>
- David Brotz <[email protected]>
- Eldred Habert <[email protected]>
- The Musl C library <http://www.musl-libc.org>
- obskyr <[email protected]>
- The OpenBSD Project <http://www.openbsd.org>
- Quint Guvernator <[email protected]>
- Sanqui <[email protected]>
- YamaArashi <[email protected]>
- yenatch <[email protected]>
- phs <[email protected]>
- jidoc01 <[email protected]>
+23 -23
View File
@@ -1,25 +1,25 @@
# This file is part of RGBDS.
#
# Copyright (c) 2018-2019, Phil Smith and RGBDS contributors.
#
# SPDX-License-Identifier: MIT
# docker build -t rgbds:vX.X.X-alpine
FROM alpine:latest
RUN apk add --update \
build-base \
byacc \
flex \
libpng-dev
COPY . /rgbds
FROM debian:13-slim
LABEL org.opencontainers.image.source=https://github.com/gbdev/rgbds
ARG version=1.0.3
WORKDIR /rgbds
RUN make Q='' all
FROM alpine:latest
RUN apk add --update \
libpng
COPY --from=0 \
/rgbds/rgbasm \
/rgbds/rgbfix \
/rgbds/rgblink \
/rgbds/rgbgfx \
/bin/
COPY . .
# Install dependencies
RUN apt-get update && \
apt-get install sudo make cmake gcc build-essential -y
RUN ./.github/scripts/install-deps.sh debian
# Build RGBDS
RUN make -j "$(getconf _NPROCESSORS_ONLN)" CXXFLAGS="-O3 -flto -DNDEBUG -static" PKG_CONFIG="pkg-config --static" Q=
# Create the install script
RUN make install.sh Q=
# Create an archive with the compiled executables, man pages, and install script,
# so it can be copied outside of the container and installed/used in another system
RUN tar caf rgbds-linux-x86_64.tar.xz --transform='s#.*/##' rgbasm rgblink rgbfix rgbgfx man/* install.sh
# Install RGBDS on the container so all the executables will be available in the PATH
RUN cp man/* .
RUN make install Q=
+1 -1
View File
@@ -1,6 +1,6 @@
The MIT License
Copyright (c) 1997-2018, Carsten Sorensen and RGBDS contributors.
Copyright (c) 1996-2025, Carsten Sørensen and RGBDS contributors.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
+185 -161
View File
@@ -1,246 +1,271 @@
#
# This file is part of RGBDS.
#
# Copyright (c) 1997-2018, Carsten Sorensen and RGBDS contributors.
#
# SPDX-License-Identifier: MIT
#
.SUFFIXES:
.SUFFIXES: .h .y .c .o
.SUFFIXES: .cpp .y .o
.PHONY: all clean install develop debug profile coverage format tidy iwyu wine-shim dist
# User-defined variables
Q := @
PREFIX := /usr/local
bindir := ${PREFIX}/bin
mandir := ${PREFIX}/share/man
STRIP := -s
BINMODE := 755
MANMODE := 644
CHECKPATCH := ../linux/scripts/checkpatch.pl
Q := @
PREFIX := /usr/local
bindir := ${PREFIX}/bin
mandir := ${PREFIX}/share/man
SUFFIX :=
STRIP := -s
BINMODE := 755
MANMODE := 644
MANSRC := man/
# Other variables
PKG_CONFIG := pkg-config
PNGCFLAGS := `${PKG_CONFIG} --cflags libpng`
PNGLDFLAGS := `${PKG_CONFIG} --libs-only-L libpng`
PNGLDLIBS := `${PKG_CONFIG} --libs-only-l libpng`
PKG_CONFIG := pkg-config
PNGCFLAGS := `${PKG_CONFIG} --cflags libpng`
PNGLDFLAGS := `${PKG_CONFIG} --libs-only-L libpng`
PNGLDLIBS := `${PKG_CONFIG} --libs-only-l libpng`
VERSION_STRING := `git describe --tags --dirty --always 2>/dev/null`
# Note: if this comes up empty, `version.cpp` will automatically fall back to last release number
VERSION_STRING := `git --git-dir=.git -c safe.directory='*' describe --tags --dirty --always 2>/dev/null`
WARNFLAGS := -Wall
WARNFLAGS := -Wall -pedantic -Wno-unknown-warning-option \
-Wno-gnu-zero-variadic-macro-arguments -Wno-unused-but-set-variable
# Overridable CFLAGS
CFLAGS := -O3
# Non-overridable CFLAGS
REALCFLAGS := ${CFLAGS} ${WARNFLAGS} -std=gnu11 -D_POSIX_C_SOURCE=200809L \
-Iinclude
# Overridable CXXFLAGS
CXXFLAGS ?= -O3 -flto -DNDEBUG
# Non-overridable CXXFLAGS
REQUIREDCXXFLAGS := -std=c++20 -I include -fno-exceptions -fno-rtti
REALCXXFLAGS := ${CXXFLAGS} ${WARNFLAGS} ${REQUIREDCXXFLAGS}
# Overridable LDFLAGS
LDFLAGS :=
LDFLAGS ?=
# Non-overridable LDFLAGS
REALLDFLAGS := ${LDFLAGS} ${WARNFLAGS} \
-DBUILD_VERSION_STRING=\"${VERSION_STRING}\"
REQUIREDLDFLAGS := -DBUILD_VERSION_STRING=\"${VERSION_STRING}\"
REALLDFLAGS := ${LDFLAGS} ${WARNFLAGS} ${REQUIREDLDFLAGS}
YFLAGS :=
# Wrapper around bison that passes flags depending on what the version supports
BISON := src/bison.sh
YACC := yacc
RM := rm -rf
RM := rm -rf
# Rules to build the RGBDS binaries
all: rgbasm rgblink rgbfix rgbgfx
common_obj := \
src/extern/getopt.o \
src/cli.o \
src/diagnostics.o \
src/style.o \
src/usage.o \
src/util.o
rgbasm_obj := \
src/asm/asmy.o \
${common_obj} \
src/asm/actions.o \
src/asm/charmap.o \
src/asm/fixpoint.o \
src/asm/format.o \
src/asm/fstack.o \
src/asm/globlex.o \
src/asm/intern.o \
src/asm/lexer.o \
src/asm/macro.o \
src/asm/main.o \
src/asm/math.o \
src/asm/opt.o \
src/asm/output.o \
src/asm/parser.o \
src/asm/rpn.o \
src/asm/section.o \
src/asm/symbol.o \
src/asm/util.o \
src/asm/warning.o \
src/extern/err.o \
src/extern/getopt.o \
src/extern/utf8decoder.o \
src/hashmap.o \
src/linkdefs.o
src/backtrace.o \
src/linkdefs.o \
src/opmath.o \
src/verbosity.o
src/asm/globlex.o src/asm/lexer.o src/asm/constexpr.o: src/asm/asmy.h
src/asm/lexer.o src/asm/main.o: src/asm/parser.hpp
rgblink_obj := \
${common_obj} \
src/link/assign.o \
src/link/fstack.o \
src/link/lexer.o \
src/link/layout.o \
src/link/main.o \
src/link/object.o \
src/link/output.o \
src/link/patch.o \
src/link/script.o \
src/link/sdas_obj.o \
src/link/section.o \
src/link/symbol.o \
src/extern/err.o \
src/extern/getopt.o \
src/hashmap.o \
src/linkdefs.o
src/link/warning.o \
src/extern/utf8decoder.o \
src/backtrace.o \
src/linkdefs.o \
src/opmath.o \
src/verbosity.o
src/link/lexer.o src/link/main.o: src/link/script.hpp
rgbfix_obj := \
${common_obj} \
src/fix/fix.o \
src/fix/main.o \
src/extern/err.o \
src/extern/getopt.o
src/fix/mbc.o \
src/fix/warning.o
rgbgfx_obj := \
src/gfx/gb.o \
${common_obj} \
src/gfx/color_set.o \
src/gfx/main.o \
src/gfx/makepng.o \
src/extern/err.o \
src/extern/getopt.o
src/gfx/pal_packing.o \
src/gfx/pal_sorting.o \
src/gfx/pal_spec.o \
src/gfx/palette.o \
src/gfx/png.o \
src/gfx/process.o \
src/gfx/reverse.o \
src/gfx/rgba.o \
src/gfx/warning.o \
src/verbosity.o
rgbasm: ${rgbasm_obj}
$Q${CC} ${REALLDFLAGS} -o $@ ${rgbasm_obj} ${REALCFLAGS} src/version.c -lm
$Q${CXX} ${REALLDFLAGS} -o $@ ${rgbasm_obj} ${REALCXXFLAGS} src/version.cpp
rgblink: ${rgblink_obj}
$Q${CC} ${REALLDFLAGS} -o $@ ${rgblink_obj} ${REALCFLAGS} src/version.c
$Q${CXX} ${REALLDFLAGS} -o $@ ${rgblink_obj} ${REALCXXFLAGS} src/version.cpp
rgbfix: ${rgbfix_obj}
$Q${CC} ${REALLDFLAGS} -o $@ ${rgbfix_obj} ${REALCFLAGS} src/version.c
$Q${CXX} ${REALLDFLAGS} -o $@ ${rgbfix_obj} ${REALCXXFLAGS} src/version.cpp
rgbgfx: ${rgbgfx_obj}
$Q${CC} ${REALLDFLAGS} ${PNGLDFLAGS} -o $@ ${rgbgfx_obj} ${REALCFLAGS} src/version.c ${PNGLDLIBS}
$Q${CXX} ${REALLDFLAGS} ${PNGLDFLAGS} -o $@ ${rgbgfx_obj} ${REALCXXFLAGS} ${PNGLDLIBS} src/version.cpp
test/gfx/randtilegen: test/gfx/randtilegen.cpp
$Q${CXX} ${REALLDFLAGS} ${PNGLDFLAGS} -o $@ $^ ${REALCXXFLAGS} ${PNGCFLAGS} ${PNGLDLIBS}
test/gfx/rgbgfx_test: test/gfx/rgbgfx_test.cpp
$Q${CXX} ${REALLDFLAGS} ${PNGLDFLAGS} -o $@ $^ ${REALCXXFLAGS} ${PNGCFLAGS} ${PNGLDLIBS}
# Rules to process files
# We want the yacc invocations to pass through our rules, not default ones
# We want the Bison invocation to pass through our rules, not default ones
.y.o:
# yacc-generated C files have an accompanying header
.c.h:
.y.cpp:
$Q${BISON} $@ $<
# Bison-generated C++ files have an accompanying header
src/asm/parser.hpp: src/asm/parser.cpp
$Qtouch $@
src/link/script.hpp: src/link/script.cpp
$Qtouch $@
.y.c:
$Q${YACC} -d ${YFLAGS} -o $@ $<
# Only RGBGFX uses libpng (POSIX make doesn't support pattern rules to cover all these)
src/gfx/color_set.o: src/gfx/color_set.cpp
$Q${CXX} ${REALCXXFLAGS} ${PNGCFLAGS} -c -o $@ $<
src/gfx/main.o: src/gfx/main.cpp
$Q${CXX} ${REALCXXFLAGS} ${PNGCFLAGS} -c -o $@ $<
src/gfx/pal_packing.o: src/gfx/pal_packing.cpp
$Q${CXX} ${REALCXXFLAGS} ${PNGCFLAGS} -c -o $@ $<
src/gfx/pal_sorting.o: src/gfx/pal_sorting.cpp
$Q${CXX} ${REALCXXFLAGS} ${PNGCFLAGS} -c -o $@ $<
src/gfx/pal_spec.o: src/gfx/pal_spec.cpp
$Q${CXX} ${REALCXXFLAGS} ${PNGCFLAGS} -c -o $@ $<
src/gfx/png.o: src/gfx/png.cpp
$Q${CXX} ${REALCXXFLAGS} ${PNGCFLAGS} -c -o $@ $<
src/gfx/process.o: src/gfx/process.cpp
$Q${CXX} ${REALCXXFLAGS} ${PNGCFLAGS} -c -o $@ $<
src/gfx/reverse.o: src/gfx/reverse.cpp
$Q${CXX} ${REALCXXFLAGS} ${PNGCFLAGS} -c -o $@ $<
src/gfx/rgba.o: src/gfx/rgba.cpp
$Q${CXX} ${REALCXXFLAGS} ${PNGCFLAGS} -c -o $@ $<
.c.o:
$Q${CC} ${REALCFLAGS} ${PNGCFLAGS} -c -o $@ $<
.cpp.o:
$Q${CXX} ${REALCXXFLAGS} -c -o $@ $<
# Target used to remove all files generated by other Makefile targets, except
# for the html documentation.
install.sh:
$Qecho '#!/usr/bin/env bash' > $@
$Q${MAKE} -s -n install MANSRC= >> $@
$Qchmod +x $@
# Target used to remove all files generated by other Makefile targets
clean:
$Q${RM} rgbasm rgbasm.exe
$Q${RM} rgblink rgblink.exe
$Q${RM} rgbfix rgbfix.exe
$Q${RM} rgbgfx rgbgfx.exe
$Qfind src/ -name "*.o" -exec rm {} \;
$Q${RM} rgbshim.sh
$Q${RM} src/asm/asmy.c src/asm/asmy.h
# Target used to remove all html files generated by the wwwman target
cleanwwwman:
$Q${RM} docs/rgbds.7.html docs/gbz80.7.html docs/rgbds.5.html
$Q${RM} docs/rgbasm.1.html docs/rgbasm.5.html
$Q${RM} docs/rgblink.1.html docs/rgblink.5.html
$Q${RM} docs/rgbfix.1.html
$Q${RM} docs/rgbgfx.1.html
$Qfind . -type f \( -name "*.gcno" -o -name "*.gcda" -o -name "*.gcov" \) -exec rm {} \;
$Q${RM} install.sh rgbshim.sh
$Q${RM} src/asm/parser.cpp src/asm/parser.hpp src/asm/stack.hh
$Q${RM} src/link/script.cpp src/link/script.hpp src/link/stack.hh
$Q${RM} test/gfx/randtilegen test/gfx/rgbgfx_test
# Target used to install the binaries and man pages.
install: all
$Qmkdir -p ${DESTDIR}${bindir}
$Qinstall ${STRIP} -m ${BINMODE} rgbasm ${DESTDIR}${bindir}/rgbasm
$Qinstall ${STRIP} -m ${BINMODE} rgbfix ${DESTDIR}${bindir}/rgbfix
$Qinstall ${STRIP} -m ${BINMODE} rgblink ${DESTDIR}${bindir}/rgblink
$Qinstall ${STRIP} -m ${BINMODE} rgbgfx ${DESTDIR}${bindir}/rgbgfx
$Qmkdir -p ${DESTDIR}${mandir}/man1 ${DESTDIR}${mandir}/man5 ${DESTDIR}${mandir}/man7
$Qinstall -m ${MANMODE} src/rgbds.7 ${DESTDIR}${mandir}/man7/rgbds.7
$Qinstall -m ${MANMODE} src/gbz80.7 ${DESTDIR}${mandir}/man7/gbz80.7
$Qinstall -m ${MANMODE} src/rgbds.5 ${DESTDIR}${mandir}/man5/rgbds.5
$Qinstall -m ${MANMODE} src/asm/rgbasm.1 ${DESTDIR}${mandir}/man1/rgbasm.1
$Qinstall -m ${MANMODE} src/asm/rgbasm.5 ${DESTDIR}${mandir}/man5/rgbasm.5
$Qinstall -m ${MANMODE} src/fix/rgbfix.1 ${DESTDIR}${mandir}/man1/rgbfix.1
$Qinstall -m ${MANMODE} src/link/rgblink.1 ${DESTDIR}${mandir}/man1/rgblink.1
$Qinstall -m ${MANMODE} src/link/rgblink.5 ${DESTDIR}${mandir}/man5/rgblink.5
$Qinstall -m ${MANMODE} src/gfx/rgbgfx.1 ${DESTDIR}${mandir}/man1/rgbgfx.1
# Target used to check the coding style of the whole codebase.
# `extern/` is excluded, as it contains external code that should not be patched
# to meet our coding style, so applying upstream patches is easier.
# `.y` files aren't checked, unfortunately...
checkcodebase:
$Qfor file in `git ls-files | grep -E '(\.c|\.h)$$' | grep -Ev '(src|include)/extern/'`; do \
${CHECKPATCH} -f "$$file"; \
done
# Target used to check the coding style of the patches from the upstream branch
# to the HEAD. Runs checkpatch once for each commit between the current HEAD and
# the first common commit between the HEAD and origin/master.
# `.y` files aren't checked, unfortunately...
BASE_REF:= origin/master
checkpatch:
$Qeval COMMON_COMMIT=$$(git merge-base HEAD ${BASE_REF}); \
for commit in `git rev-list $$COMMON_COMMIT..HEAD`; do \
echo "[*] Analyzing commit '$$commit'"; \
git format-patch --stdout "$$commit~..$$commit" \
| ${CHECKPATCH} - || true; \
done
# Target for the project maintainer to easily create web manuals.
# It relies on mandoc: http://mdocml.bsd.lv
MANDOC := -Thtml -Ios=General -Oman=%N.%S.html -Ostyle=mandoc.css
wwwman:
$Qmandoc ${MANDOC} src/rgbds.7 | src/doc_postproc.awk > docs/rgbds.7.html
$Qmandoc ${MANDOC} src/gbz80.7 | src/doc_postproc.awk > docs/gbz80.7.html
$Qmandoc ${MANDOC} src/rgbds.5 | src/doc_postproc.awk > docs/rgbds.5.html
$Qmandoc ${MANDOC} src/asm/rgbasm.1 | src/doc_postproc.awk > docs/rgbasm.1.html
$Qmandoc ${MANDOC} src/asm/rgbasm.5 | src/doc_postproc.awk > docs/rgbasm.5.html
$Qmandoc ${MANDOC} src/fix/rgbfix.1 | src/doc_postproc.awk > docs/rgbfix.1.html
$Qmandoc ${MANDOC} src/link/rgblink.1 | src/doc_postproc.awk > docs/rgblink.1.html
$Qmandoc ${MANDOC} src/link/rgblink.5 | src/doc_postproc.awk > docs/rgblink.5.html
$Qmandoc ${MANDOC} src/gfx/rgbgfx.1 | src/doc_postproc.awk > docs/rgbgfx.1.html
# This target is used during development in order to prevent adding new issues
# to the source code. All warnings are treated as errors in order to block the
# compilation and make the continous integration infrastructure return failure.
$Qinstall -d ${DESTDIR}${bindir}/ ${DESTDIR}${mandir}/man1/ ${DESTDIR}${mandir}/man5/ ${DESTDIR}${mandir}/man7/
$Qinstall ${STRIP} -m ${BINMODE} rgbasm ${DESTDIR}${bindir}/rgbasm${SUFFIX}
$Qinstall ${STRIP} -m ${BINMODE} rgblink ${DESTDIR}${bindir}/rgblink${SUFFIX}
$Qinstall ${STRIP} -m ${BINMODE} rgbfix ${DESTDIR}${bindir}/rgbfix${SUFFIX}
$Qinstall ${STRIP} -m ${BINMODE} rgbgfx ${DESTDIR}${bindir}/rgbgfx${SUFFIX}
$Qinstall -m ${MANMODE} ${MANSRC}rgbasm.1 ${MANSRC}rgblink.1 ${MANSRC}rgbfix.1 ${MANSRC}rgbgfx.1 ${DESTDIR}${mandir}/man1/
$Qinstall -m ${MANMODE} ${MANSRC}rgbds.5 ${MANSRC}rgbasm.5 ${MANSRC}rgbasm-old.5 ${MANSRC}rgblink.5 ${DESTDIR}${mandir}/man5/
$Qinstall -m ${MANMODE} ${MANSRC}rgbds.7 ${MANSRC}gbz80.7 ${DESTDIR}${mandir}/man7/
# Target used in development to prevent adding new issues to the source code.
# All warnings are treated as errors to block the compilation and make the
# continous integration infrastructure return failure.
# The rationale for some of the flags is documented in the CMakeLists.
develop:
$Qenv $(MAKE) -j WARNFLAGS="-Werror -Wall -Wextra -Wpedantic \
-Wno-sign-compare -Wformat -Wformat-security -Wformat-overflow=2 \
-Wformat-truncation=1 -Wformat-y2k -Wswitch-enum -Wunused \
-Wuninitialized -Wunknown-pragmas -Wstrict-overflow=5 \
-Wstringop-overflow=4 -Walloc-zero -Wduplicated-cond \
-Wfloat-equal -Wshadow -Wcast-qual -Wcast-align -Wlogical-op \
-Wnested-externs -Wno-aggressive-loop-optimizations -Winline \
-Wundef -Wstrict-prototypes -Wold-style-definition \
-fsanitize=shift -fsanitize=integer-divide-by-zero \
-fsanitize=unreachable -fsanitize=vla-bound \
-fsanitize=signed-integer-overflow -fsanitize=bounds \
-fsanitize=object-size -fsanitize=bool -fsanitize=enum \
-fsanitize=alignment -fsanitize=null -DDEVELOP" CFLAGS="-g -O0"
$Q${MAKE} WARNFLAGS="${WARNFLAGS} -Werror -Wextra \
-Walloc-zero -Wcast-align -Wcast-qual -Wduplicated-branches -Wduplicated-cond \
-Wfloat-equal -Wlogical-op -Wnull-dereference -Wold-style-cast -Wshift-overflow=2 \
-Wstringop-overflow=4 -Wtrampolines -Wundef -Wuninitialized -Wunused -Wshadow \
-Wformat=2 -Wformat-overflow=2 -Wformat-truncation=1 \
-Wno-format-nonliteral -Wno-strict-overflow -Wno-unused-but-set-variable \
-Wno-type-limits -Wno-tautological-constant-out-of-range-compare -Wvla \
-D_GLIBCXX_ASSERTIONS -D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_DEBUG \
-fsanitize=address -fsanitize=undefined -fsanitize=float-divide-by-zero" \
CXXFLAGS="-ggdb3 -Og -fno-omit-frame-pointer -fno-optimize-sibling-calls"
# Targets for the project maintainer to easily create Windows exes.
# This is not for Windows users!
# If you're building on Windows with Cygwin or Mingw, just follow the Unix
# install instructions instead.
# Target used in development to debug with gdb.
debug:
$Qenv ${MAKE} \
CXXFLAGS="-ggdb3 -O0 -fno-omit-frame-pointer -fno-optimize-sibling-calls"
mingw32:
$Qmake CC=i686-w64-mingw32-gcc YACC=bison \
PKG_CONFIG=i686-w64-mingw32-pkg-config -j
# Target used in development to profile with callgrind.
# Use `valgrind --tool=callgrind --dump-instr=yes --simulate-cache=yes --collect-jumps=yes ./rgbasm ...`.
profile:
$Qenv ${MAKE} \
CXXFLAGS="-ggdb3 -O3 -fno-omit-frame-pointer -fno-optimize-sibling-calls"
mingw64:
$Qmake CC=x86_64-w64-mingw32-gcc YACC=bison \
PKG_CONFIG=x86_64-w64-mingw32-pkg-config -j
# Target used in development to inspect code coverage with gcov.
# Use `./contrib/coverage.bash`.
coverage:
$Qenv ${MAKE} \
CXXFLAGS="-ggdb3 -Og --coverage -fno-omit-frame-pointer -fno-optimize-sibling-calls"
# Target used in development to format source code with clang-format.
format:
$Qclang-format -i $$(git ls-files '*.[hc]pp')
# Target used in development to check code with clang-tidy.
# Requires Bison-generated header files to exist.
tidy: src/asm/parser.hpp src/link/script.hpp compile_flags.txt
$Qclang-tidy -p . $$(git ls-files '*.[hc]pp')
compile_flags.txt:
$Qprintf '%s\n' ${REQUIREDCXXFLAGS} ${REQUIREDLDFLAGS} >$@
# Target used in development to remove unused `#include` headers.
iwyu:
$Qenv ${MAKE} \
CXX="include-what-you-use" \
REALCXXFLAGS="-std=c++20 -I include"
# Target used in development to conveniently invoke RGBDS binaries with Wine.
wine-shim:
$Qecho '#!/bin/bash' > rgbshim.sh
$Qecho '#!/usr/bin/env bash' > rgbshim.sh
$Qecho 'WINEDEBUG=-all wine $$0.exe "$${@:1}"' >> rgbshim.sh
$Qchmod +x rgbshim.sh
$Qln -s rgbshim.sh rgbasm
@@ -250,7 +275,6 @@ wine-shim:
# Target for the project maintainer to produce distributable release tarballs
# of the source code.
dist:
$Qgit ls-files | sed s~^~$${PWD##*/}/~ \
| tar -czf rgbds-`git describe --tags | cut -c 2-`.tar.gz -C .. -T -
| tar -czf rgbds-source.tar.gz -C .. -T -
+63
View File
@@ -0,0 +1,63 @@
# RGBDS
[RGBDS](https://github.com/gbdev/rgbds) (Rednex Game Boy Development System) is
a free assembler/linker package for the Game Boy and Game Boy Color.
It consists of four tools:
- **RGBASM:** assembler
- **RGBLINK:** linker
- **RGBFIX:** ROM checksum/header fixer
- **RGBGFX:** PNG-to-Game Boy graphics converter
## Documentation
The [full documentation](https://rgbds.gbdev.io/docs/) is available online,
including the [development history](https://rgbds.gbdev.io/docs/rgbds.7) and
[version history](https://rgbds.gbdev.io/versions), generated from the man pages
in this repository.
The documentation website's own source code is available in the
[rgbds-www](https://github.com/gbdev/rgbds-www) repository.
## Community
If you have questions about the RGBDS code or its organization, you can contact
the maintainers on the [GBDev Discord server](https://discord.gg/RjJKA8wrD4) or
[other community channels](https://gbdev.io/chat), or via email at
`rgbds at gbdev dot io`.
If you want to help maintain RGBDS, please read [the contribution guide](/docs/CONTRIBUTING.md).
## Installing
The [platform-specific installation instructions](https://rgbds.gbdev.io/install/)
are available online. To [build from source](https://rgbds.gbdev.io/install/source)
using `make` or `cmake`, briefly:
```sh
make
sudo make install
```
```sh
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build
cmake --install build
```
Both build systems support a prefix (e.g. to install into a specific directory)
and a suffix (e.g. to append the version number or commit ID):
```sh
make
sudo make install PREFIX=install_dir/ SUFFIX=-$(git rev-parse --short HEAD)
```
```sh
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DSUFFIX=-$(git rev-parse --short HEAD)
cmake --build build
cmake --install build --prefix install_dir
```
On Windows, any `SUFFIX` should include the `.exe` extension.
-186
View File
@@ -1,186 +0,0 @@
RGBDS
=====
RGBDS (Rednex Game Boy Development System) is a free assembler/linker package
for the Game Boy and Game Boy Color. It consists of:
- rgbasm (assembler)
- rgblink (linker)
- rgbfix (checksum/header fixer)
- rgbgfx (PNGtoGame Boy graphics converter)
This is a fork of the original RGBDS which aims to make the programs more like
other UNIX tools.
This toolchain is maintained on `GitHub <https://github.com/rednex/rgbds>`__.
The documentation of this toolchain can be viewed online
`here <https://rednex.github.io/rgbds/>`__, it is generated from the man pages
found in this repository.
1. Installing RGBDS
-------------------
1.1 Windows
~~~~~~~~~~~
Windows builds are available in the releases page on GitHub
`here <https://github.com/rednex/rgbds/releases>`__.
Extract the zip and then add the executable directory to the path. For example:
::
path %PATH%;C:\Programs\rgbds-0.3.8-win64\win64
Alternatively, the RGBDS executables can be simply dropped in the folder of the project they're used in.
If you require the latest version in development, it should be possible to
compile RGBDS with MinGW or Cygwin by following the instructions to build it on
UNIX systems.
1.2 macOS
~~~~~~~~~
You can build RGBDS by following the instructions below. However, if you would
prefer not to build RGBDS yourself, you may also install it using
`Homebrew <http://brew.sh/>`__.
To install the latest release, use:
.. code:: sh
brew install rgbds
To install RGBDS with all of the current changes in development (as seen on the
``master`` branch on GitHub), use:
.. code:: sh
brew install rgbds --HEAD
1.3 Arch Linux
~~~~~~~~~~~~~~
To install RGBDS through the AUR run
.. code:: sh
yaourt -S rgbds
1.4 Other UNIX-like systems
~~~~~~~~~~~~~~~~~~~~~~~~~~~
No official binaries of RGBDS are distributed for these systems, you must follow
the simple instructions below to compile and install it.
2. Building RGBDS from source
-----------------------------
RGBDS can be built in UNIX-like systems by following the instructions below.
2.1 Dependencies
~~~~~~~~~~~~~~~~
RGBDS requires yacc, libpng and pkg-config to be installed.
On macOS, install the latter two with `Homebrew <http://brew.sh/>`__:
.. code:: sh
brew install libpng pkg-config
On other Unixes, use the built-in package manager. For example, on Debian or
Ubuntu:
.. code:: sh
sudo apt-get install byacc flex pkg-config libpng-dev
You can test if libpng and pkg-config are installed by running ``pkg-config
--cflags libpng``: if the output is a path, then you're good, and if it outputs
an error then you need to install them via a package manager.
2.2 Build process
~~~~~~~~~~~~~~~~~
To build the programs, run in your terminal:
.. code:: sh
make
Then, to install the compiled programs and manual pages, run (with appropriate
privileges, e.g, with ``sudo``):
.. code:: sh
make install
After installation, you can read the manuals with the ``man`` command. E.g.,
.. code:: sh
man 7 rgbds
There are some variables in the Makefile that can be redefined by the user. The
variables described below can affect installation behavior when given on the
make command line. For example, to install RGBDS in your home directory instead
of systemwide, run the following:
.. code:: sh
make install PREFIX=$HOME
To do a verbose build, run:
.. code:: sh
make Q=
This is the complete list of user-defined variables:
- ``PREFIX``: Location where RGBDS will be installed. Defaults to
``/usr/local``.
- ``bindir``: Location where the binaries will be installed. Defaults to
``${PREFIX}/bin``.
- ``mandir``: Location where the manpages will be installed. Defaults to
``${PREFIX}/share/man``.
- ``DESTDIR``: This is prepended to all paths during the installation. It is
mainly used for packaging.
- ``Q``: Whether to quiet the build or not. To make the build more verbose,
clear this variable. Defaults to ``@``.
- ``STRIP``: Whether to strip the installed binaries of debug symbols or not.
Defaults to ``-s``.
- ``BINMODE``: Permissions of the installed binaries. Defaults to ``755``.
- ``MANMODE``: Permissions of the installed manpages. Defaults to ``644``.
- ``CHECKPATCH``: Path of the script ``checkpatch.pl`` of the Linux kernel.
Defaults to ``../linux/scripts/checkpatch.pl``.
3 History
---------
- Around 1997, Carsten Sorensen (AKA SurfSmurf) writes ASMotor as a
general-purpose assembler/linker system for DOS/Win32
- Around 1999, Justin Lloyd (AKA Otaku no Zoku) adapts ASMotor to read and
produce GBZ80 assembly/machine code, and releases this version as RGBDS.
- 2009, Vegard Nossum adapts the code to be more UNIX-like and releases
this version as rgbds-linux on
`GitHub <https://github.com/vegard/rgbds-linux>`__.
- 2010, Anthony J. Bentley forks that repository. The fork becomes the reference
implementation of rgbds.
- 2017, Bentley's repository is moved to a neutral name.
- 2018, codebase relicensed under the MIT license.
+25
View File
@@ -0,0 +1,25 @@
# This file declares the dependencies we use, using `FetchContent`.
# https://cmake.org/cmake.help/latest/guide/using-dependencies/index.html#downloading-and-building-from-source-with-fetchcontent
# These are kept in a separate file so that it can be hashed as a key for our CI's `actions/cache`.
FetchContent_Declare(PNG
URL https://download.sourceforge.net/libpng/libpng-1.6.58.tar.xz
URL_HASH SHA256=28eb403f51f0f7405249132cecfe82ea5c0ef97f1b32c5a65828814ae0d34775
EXCLUDE_FROM_ALL # We only install the runtime dependencies, and do so separately.
FIND_PACKAGE_ARGS 1.5.4)
set(PNG_TESTS OFF CACHE INTERNAL "") # We do not need libpng's tests or tools
set(PNG_TOOLS OFF CACHE INTERNAL "") # (and they can even cause compile errors!)
set(PNG_SHARED OFF CACHE INTERNAL "")
set(PNG_STATIC ON CACHE INTERNAL "")
FetchContent_Declare(ZLIB
URL https://www.zlib.net/zlib-1.3.2.tar.xz
URL_HASH SHA256=d7a0654783a4da529d1bb793b7ad9c3318020af77667bcae35f95d0e42a792f3
EXCLUDE_FROM_ALL # We only install the runtime dependencies, and do so separately.
# libpng documents requiring "zlib 1.0.4 or later (1.2.13 or later recommended for performance and security reasons)".
# We thus enforce 1.0.4, but note that the libpng source code mentions that "it may work with versions as old as zlib 0.95".
FIND_PACKAGE_ARGS 1.0.4)
set(ZLIB_BUILD_SHARED OFF CACHE INTERNAL "")
set(ZLIB_BUILD_STATIC ON CACHE INTERNAL "")
+33
View File
@@ -0,0 +1,33 @@
# This file is meant to be included at the project level,
# in order to generate executables compatible with old macOS versions.
# See our `macos-static` CMake preset for how it's meant to be used.
# Note that targeting old enough versions of Mac OS X on recent enough versions of macOS
# triggers some poorly-tested code paths within Apple's linker, which then crashes.
# This can be worked around by using LLVM's LLD linker and passing `-fuse-ld=lld` when linking.
# The `-mmacosx-version-min=10.4` flag ensures that the binary only uses APIs available on Mac OS X 10.4 Tiger.
# The `-arch` flags build a "fat binary" that works on both Apple architectures:
# older Intel x64 Macs and newer ARM "Apple Silicon" ones.
set(secret_sauce -mmacosx-version-min=10.4 "SHELL:-arch x86_64" "SHELL:-arch arm64") # Avoid `-arch` being dedup'd.
add_compile_options(${secret_sauce})
add_link_options(${secret_sauce})
set(PNG_HARDWARE_OPTIMIZATIONS OFF) # These do not play well with a dual-arch build.
# Mac OS X has always provided zlib, so we can safely link dynamically against it.
# However, libpng is *not* provided by default, so we link it statically, which requires downloading and building it from source.
set(PNG_SHARED OFF)
set(PNG_STATIC ON)
# If libpng is already available (e.g. via Homebrew), we ignore that and still build our own.
set(FETCHCONTENT_TRY_FIND_PACKAGE_MODE NEVER)
# But we still want to attempt linking against the system's zlib.
function(rgbds_provide_dependency method dep_name)
if(dep_name STREQUAL "ZLIB")
find_package(ZLIB)
if(ZLIB_FOUND)
FetchContent_SetPopulated(ZLIB)
endif()
endif()
endfunction(rgbds_provide_dependency)
cmake_language(SET_DEPENDENCY_PROVIDER rgbds_provide_dependency
SUPPORTED_METHODS FETCHCONTENT_MAKEAVAILABLE_SERIAL)
+22
View File
@@ -0,0 +1,22 @@
# From https://www.mingw-w64.org/build-systems/cmake/
set(CMAKE_SYSTEM_NAME Windows)
set(CMAKE_SYSTEM_PROCESSOR i686)
# Specify the cross-compiler.
set(CMAKE_C_COMPILER i686-w64-mingw32-gcc)
set(CMAKE_CXX_COMPILER i686-w64-mingw32-g++)
set(CMAKE_RC_COMPILER i686-w64-mingw32-windres)
# Specify the target environment.
set(CMAKE_FIND_ROOT_PATH /usr/i686-w64-mingw32)
# Search for programs in the build host directories.
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
# Search for libraries and headers in the target directories.
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
# CMake determines how to examine dependencies based on the *host* system, leading to
# a "file unknown error" unless the target platform is explicitly specified.
set(CMAKE_GET_RUNTIME_DEPENDENCIES_PLATFORM "windows+pe")
+22
View File
@@ -0,0 +1,22 @@
# From https://www.mingw-w64.org/build-systems/cmake/
set(CMAKE_SYSTEM_NAME Windows)
set(CMAKE_SYSTEM_PROCESSOR x86_64)
# Specify the cross-compiler.
set(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc)
set(CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++)
set(CMAKE_RC_COMPILER x86_64-w64-mingw32-windres)
# Specify the target environment.
set(CMAKE_FIND_ROOT_PATH /usr/x86_64-w64-mingw32)
# Search for programs in the build host directories.
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
# Search for libraries and headers in the target directories.
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
# CMake determines how to examine dependencies based on the *host* system, leading to
# a "file unknown error" unless the target platform is explicitly specified.
set(CMAKE_GET_RUNTIME_DEPENDENCIES_PLATFORM "windows+pe")
+228
View File
@@ -0,0 +1,228 @@
#!/usr/bin/env bash
# Known bugs:
# - Newlines in file/directory names break this script
# This is because we rely on `compgen -A`, which is broken like this.
# A fix would require implementing it ourselves, and no thanks!
# - `rgbasm --binary-digits=a` is treated the same as `rgbasm --binary-digits=` (for example)
# This is not our fault, Bash passes both of these identically.
# Maybe it could be worked around, but such a fix would likely be involved.
# The user can work around it by typing `--binary-digits ''` instead, for example.
# - Directories are not completed as such in "coalesced" short-opt arguments. For example,
# `rgbasm -M d<tab>` can autocomplete to `rgbasm -M dir/` (no space), but
# `rgbasm -Md<tab>` would autocomplete to `rgbasm -Mdir ` (trailing space) instead.
# This is because directory handling is performed by Readline, whom we can't tell about the short
# opt kerfuffle. The user can work around by separating the argument, as shown above.
# (Also, there might be more possible bugs if `-Mdir` is actually a directory. Ugh.)
# Something to note:
# `rgbasm --binary-digits=a` gets passed to us as ('rgbasm' '--binary-digits' '=' 'a')
# Thus, we don't need to do much to handle that form of argument passing: skip '=' after long opts.
_rgbasm_completions() {
# Format: "long_opt:state_after"
# Empty long opt = it doesn't exit
# See the `state` variable below for info about `state_after`
declare -A opts=(
[h]="help:normal"
[V]="version:normal"
[W]="warning:warning"
[w]=":normal"
[B]="backtrace:unk"
[b]="binary-digits:unk"
[D]="define:unk"
[E]="export-all:normal"
[g]="gfx-chars:unk"
[I]="include:dir"
[M]="dependfile:glob-*.mk *.d"
[o]="output:glob-*.o"
[P]="preinclude:glob-*.asm *.inc"
[p]="pad-value:unk"
[Q]="q-precision:unk"
[r]="recursion-depth:unk"
[s]="state:unk"
[v]="verbose:normal"
[X]="max-errors:unk"
)
# Parse command-line up to current word
local opt_ena=true
# Possible states:
# - normal = Well, normal. Options are parsed normally.
# - unk = An argument that can't be completed, and should just be skipped.
# - warning = A warning flag.
# - dir = A directory path
# - glob-* = A glob, after the dash is a whitespace-separated list of file globs to use
local state=normal
# The length of the option, used as a return value by the function below
local optlen=0
# $1: a short option word
# `state` will be set to the parsing state after the last option character in the word. If
# "normal" is not returned, `optlen` will be set to the length (dash included) of the "option"
# part of the argument.
parse_short_opt() {
# These options act like a long option (= takes up the entire word), but only use a single dash
# So, they need some special handling
if [[ "$1" = "-M"[CGP] ]]; then
state=normal
optlen=${#1}
return;
elif [[ "$1" = "-M"[QT] ]]; then
state='glob-*.d *.mk *.o'
optlen=${#1}
return;
fi
for (( i = 1; i < "${#1}"; i++ )); do
# If the option is not known, assume it doesn't take an argument
local opt="${opts["${1:$i:1}"]:-":normal"}"
state="${opt#*:}"
# If the option takes an argument, record the length and exit
if [[ "$state" != 'normal' ]]; then
let optlen="$i + 1"
return
fi
done
optlen=0
}
for (( i = 1; i < COMP_CWORD; i++ )); do
local word="${COMP_WORDS[$i]}"
# If currently processing an argument, skip this word
if [[ "$state" != 'normal' ]]; then
state=normal
continue
fi
if [[ "$word" = '--' ]]; then
# Options stop being parsed after this
opt_ena=false
break
fi
# Check if it's a long option
if [[ "$word" = '--'* ]]; then
# If the option is unknown, assume it takes no arguments: keep the state at "normal"
for long_opt in "${opts[@]}"; do
if [[ "$word" = "--${long_opt%%:*}" ]]; then
state="${long_opt#*:}"
# Check if the next word is just '='; if so, skip it, the argument must follow
# (See "known bugs" at the top of this script)
let i++
if [[ "${COMP_WORDS[$i]}" != '=' ]]; then
let i--
fi
optlen=0
break
fi
done
# Check if it's a short option
elif [[ "$word" = '-'* ]]; then
parse_short_opt "$word"
# The last option takes an argument...
if [[ "$state" != 'normal' ]]; then
if [[ "$optlen" -ne "${#word}" ]]; then
# If it's contained within the word, we won't complete it, revert to "normal"
state=normal
else
# Otherwise, complete it, but start at the beginning of *that* word
optlen=0
fi
fi
fi
done
# Parse current word
# Careful that it might look like an option, so use `--` aggressively!
local cur_word="${COMP_WORDS[$i]}"
# Process options, as short ones may change the state
if $opt_ena && [[ "$state" = 'normal' && "$cur_word" = '-'* ]]; then
# We might want to complete to an option or an arg to that option
# Parse the option word to check
# There's no whitespace in the option names, so we can ride a little dirty...
# Is this a long option?
if [[ "$cur_word" = '--'* ]]; then
# It is, try to complete one
mapfile -t COMPREPLY < <(compgen -W "${opts[*]%%:*}" -P '--' -- "${cur_word#--}")
return 0
elif [[ "$cur_word" = '-M'[CGPQT] ]]; then
# These options act like long opts with no arguments, so return them and exactly them
COMPREPLY=( "$cur_word" )
return 0
else
# Short options may be grouped, parse them to determine what to complete
parse_short_opt "$cur_word"
if [[ "$state" = 'normal' ]]; then
mapfile -t COMPREPLY < <(compgen -W "${!opts[*]}" -P "$cur_word" ''; compgen -W '-MC -MG -MP -MQ -MT' "$cur_word")
return 0
elif [[ "$optlen" = "${#cur_word}" && "$state" != "warning" ]]; then
# This short option group only awaits its argument!
# Post the option group as-is as a reply so that Readline inserts a space,
# so that the next completion request switches to the argument
# An exception is made for warnings, since it's idiomatic to stick them to the
# `-W`, and it doesn't break anything.
COMPREPLY=( "$cur_word" )
return 0
fi
fi
fi
COMPREPLY=()
case "$state" in
unk) # Return with no replies: no idea what to complete!
;;
warning)
mapfile -t COMPREPLY < <(compgen -W "
assert
backwards-for
builtin-args
charmap-redef
div
empty-data-directive
empty-macro-arg
empty-strrpl
export-undefined
large-constant
macro-shift
nested-comment
numeric-string
obsolete
purge
shift
shift-amount
truncation
unmapped-char
unmatched-directive
unterminated-load
user
all
extra
everything
error" -P "${cur_word:0:$optlen}" -- "${cur_word:$optlen}")
;;
normal) # Acts like a glob...
state="glob-*.asm *.inc *.sm83"
;&
glob-*)
while read -r word; do
COMPREPLY+=("${cur_word:0:$optlen}$word")
done < <(for glob in ${state#glob-}; do compgen -A file -X \!"$glob" -- "${cur_word:$optlen}"; done)
# Also complete directories
;&
dir)
while read -r word; do
COMPREPLY+=("${cur_word:0:$optlen}$word")
done < <(compgen -A directory -- "${cur_word:$optlen}")
compopt -o filenames
;;
*)
echo >&2 "Internal completion error: invalid state \"$state\", please report this bug"
return 1
;;
esac
}
complete -F _rgbasm_completions rgbasm
+201
View File
@@ -0,0 +1,201 @@
#!/usr/bin/env bash
# Same notes as RGBASM
_rgbfix_completions() {
# Format: "long_opt:state_after"
# Empty long opt = it doesn't exit
# See the `state` variable below for info about `state_after`
declare -A opts=(
[h]="help:normal"
[V]="version:normal"
[W]="warning:warning"
[w]=":normal"
[C]="color-only:normal"
[c]="color-compatible:normal"
[f]="fix-spec:fix-spec"
[i]="game-id:unk"
[j]="non-japanese:normal"
[k]="new-licensee:unk"
[L]="custom-logo:glob-*.1bpp"
[l]="old-licensee:unk"
[m]="mbc-type:mbc"
[n]="rom-version:unk"
[o]="output:glob-*.gb *.gbc *.sgb"
[p]="pad-value:unk"
[r]="ram-size:unk"
[s]="sgb-compatible:normal"
[t]="title:unk"
[v]="validate:normal"
)
# Parse command-line up to current word
local opt_ena=true
# Possible states:
# - normal = Well, normal. Options are parsed normally.
# - unk = An argument that can't be completed, and should just be skipped.
# - warning = A warning flag.
# - dir = A directory path
# - glob-* = A glob, after the dash is a whitespace-separated list of file globs to use
local state=normal
# The length of the option, used as a return value by the function below
local optlen=0
# $1: a short option word
# `state` will be set to the parsing state after the last option character in the word. If
# "normal" is not returned, `optlen` will be set to the length (dash included) of the "option"
# part of the argument.
parse_short_opt() {
for (( i = 1; i < "${#1}"; i++ )); do
# If the option is not known, assume it doesn't take an argument
local opt="${opts["${1:$i:1}"]:-":normal"}"
state="${opt#*:}"
# If the option takes an argument, record the length and exit
if [[ "$state" != 'normal' ]]; then
let optlen="$i + 1"
return
fi
done
optlen=0
}
for (( i = 1; i < COMP_CWORD; i++ )); do
local word="${COMP_WORDS[$i]}"
# If currently processing an argument, skip this word
if [[ "$state" != 'normal' ]]; then
state=normal
continue
fi
if [[ "$word" = '--' ]]; then
# Options stop being parsed after this
opt_ena=false
break
fi
# Check if it's a long option
if [[ "$word" = '--'* ]]; then
# If the option is unknown, assume it takes no arguments: keep the state at "normal"
for long_opt in "${opts[@]}"; do
if [[ "$word" = "--${long_opt%%:*}" ]]; then
state="${long_opt#*:}"
# Check if the next word is just '='; if so, skip it, the argument must follow
# (See "known bugs" at the top of this script)
let i++
if [[ "${COMP_WORDS[$i]}" != '=' ]]; then
let i--
fi
optlen=0
break
fi
done
# Check if it's a short option
elif [[ "$word" = '-'* ]]; then
parse_short_opt "$word"
# The last option takes an argument...
if [[ "$state" != 'normal' ]]; then
if [[ "$optlen" -ne "${#word}" ]]; then
# If it's contained within the word, we won't complete it, revert to "normal"
state=normal
else
# Otherwise, complete it, but start at the beginning of *that* word
optlen=0
fi
fi
fi
done
# Parse current word
# Careful that it might look like an option, so use `--` aggressively!
local cur_word="${COMP_WORDS[$i]}"
# Process options, as short ones may change the state
if $opt_ena && [[ "$state" = 'normal' && "$cur_word" = '-'* ]]; then
# We might want to complete to an option or an arg to that option
# Parse the option word to check
# There's no whitespace in the option names, so we can ride a little dirty...
# Is this a long option?
if [[ "$cur_word" = '--'* ]]; then
# It is, try to complete one
mapfile -t COMPREPLY < <(compgen -W "${opts[*]%%:*}" -P '--' -- "${cur_word#--}")
return 0
else
# Short options may be grouped, parse them to determine what to complete
parse_short_opt "$cur_word"
if [[ "$state" = 'normal' ]]; then
mapfile -t COMPREPLY < <(compgen -W "${!opts[*]}" -P "$cur_word" '')
return 0
elif [[ "$optlen" = "${#cur_word}" && "$state" != "warning" ]]; then
# This short option group only awaits its argument!
# Post the option group as-is as a reply so that Readline inserts a space,
# so that the next completion request switches to the argument
# An exception is made for warnings, since it's idiomatic to stick them to the
# `-W`, and it doesn't break anything.
COMPREPLY=( "$cur_word" )
return 0
fi
fi
fi
COMPREPLY=()
case "$state" in
unk) # Return with no replies: no idea what to complete!
;;
warning)
mapfile -t COMPREPLY < <(compgen -W "
mbc
obsolete
overwrite
sgb
truncation
all
everything
error" -P "${cur_word:0:$optlen}" -- "${cur_word:$optlen}")
;;
fix-spec)
COMPREPLY=( "${cur_word}"{l,h,g,L,H,G} )
;;
mbc)
local cur_arg="${cur_word:$optlen}"
cur_arg="${cur_arg@U}"
compopt -o nosort # Keep `help` first in the list, mainly
mapfile -t COMPREPLY < <(compgen -W "help" -P "${cur_word:0:$optlen}" -- "${cur_word:$optlen}")
mapfile -t COMPREPLY -O ${#COMPREPLY} < <(compgen -W "
ROM_ONLY
MBC1{,+RAM,+RAM+BATTERY}
MBC2{,+BATTERY}
MMM01{,+RAM}
MBC3{+TIMER+BATTERY,+TIMER+RAM+BATTERY,,+RAM,+RAM+BATTERY}
MBC5{,+RAM,+RAM+BATTERY,+RUMBLE,+RUMBLE+RAM,+RUMBLE+RAM+BATTERY}
MBC6
MBC7+SENSOR+RUMBLE+RAM+BATTERY
POCKET_CAMERA
BANDAI_TAMA5
HUC3
HUC1+RAM+BATTERY
TPP1_1.0{,+BATTERY}{,+RTC}{,+RUMBLE,+MULTIRUMBLE}" -P "${cur_word:0:$optlen}" -- "${cur_word/ /_}")
;;
normal) # Acts like a glob...
state="glob-*.gb *.gbc *.sgb"
;&
glob-*)
while read -r word; do
COMPREPLY+=("${cur_word:0:$optlen}$word")
done < <(for glob in ${state#glob-}; do compgen -A file -X \!"$glob" -- "${cur_word:$optlen}"; done)
# Also complete directories
;&
dir)
while read -r word; do
COMPREPLY+=("${cur_word:0:$optlen}$word")
done < <(compgen -A directory -- "${cur_word:$optlen}")
compopt -o filenames
;;
*)
echo >&2 "Internal completion error: invalid state \"$state\", please report this bug"
return 1
;;
esac
}
complete -F _rgbfix_completions rgbfix
+188
View File
@@ -0,0 +1,188 @@
#!/usr/bin/env bash
# Same notes as RGBASM
_rgbgfx_completions() {
# Format: "long_opt:state_after"
# Empty long opt = it doesn't exit
# See the `state` variable below for info about `state_after`
declare -A opts=(
[h]="help:normal"
[V]="version:normal"
[W]="warning:warning"
[w]=":normal"
[A]="auto-attr-map:normal"
[a]="attr-map:glob-*.attrmap"
[B]="background-color:unk"
[b]="base-tiles:unk"
[C]="color-curve:normal"
[c]="colors:unk"
[d]="depth:unk"
[i]="input-tileset:glob-*.2bpp"
[L]="slice:unk"
[m]="mirror-tiles:normal"
[N]="nb-tiles:unk"
[n]="nb-palettes:unk"
[O]="group-outputs:normal"
[o]="output:glob-*.2bpp"
[P]="auto-palette:normal"
[p]="palette:glob-*.pal"
[Q]="auto-palette-map:normal"
[q]="palette-map:glob-*.palmap"
[r]="reverse:unk"
[s]="palette-size:unk"
[T]="auto-tilemap:normal"
[t]="tilemap:glob-*.tilemap"
[u]="unique-tiles:normal"
[v]="verbose:normal"
[X]="mirror-x:normal"
[x]="trim-end:unk"
[Y]="mirror-y:normal"
[Z]="columns:normal"
)
# Parse command-line up to current word
local opt_ena=true
# Possible states:
# - normal = Well, normal. Options are parsed normally.
# - unk = An argument that can't be completed, and should just be skipped.
# - warning = A warning flag.
# - dir = A directory path
# - glob-* = A glob, after the dash is a whitespace-separated list of file globs to use
local state=normal
# The length of the option, used as a return value by the function below
local optlen=0
# $1: a short option word
# `state` will be set to the parsing state after the last option character in the word. If
# "normal" is not returned, `optlen` will be set to the length (dash included) of the "option"
# part of the argument.
parse_short_opt() {
for (( i = 1; i < "${#1}"; i++ )); do
# If the option is not known, assume it doesn't take an argument
local opt="${opts["${1:$i:1}"]:-":normal"}"
state="${opt#*:}"
# If the option takes an argument, record the length and exit
if [[ "$state" != 'normal' ]]; then
let optlen="$i + 1"
return
fi
done
optlen=0
}
for (( i = 1; i < COMP_CWORD; i++ )); do
local word="${COMP_WORDS[$i]}"
# If currently processing an argument, skip this word
if [[ "$state" != 'normal' ]]; then
state=normal
continue
fi
if [[ "$word" = '--' ]]; then
# Options stop being parsed after this
opt_ena=false
break
fi
# Check if it's a long option
if [[ "$word" = '--'* ]]; then
# If the option is unknown, assume it takes no arguments: keep the state at "normal"
for long_opt in "${opts[@]}"; do
if [[ "$word" = "--${long_opt%%:*}" ]]; then
state="${long_opt#*:}"
# Check if the next word is just '='; if so, skip it, the argument must follow
# (See "known bugs" at the top of this script)
let i++
if [[ "${COMP_WORDS[$i]}" != '=' ]]; then
let i--
fi
optlen=0
break
fi
done
# Check if it's a short option
elif [[ "$word" = '-'* ]]; then
parse_short_opt "$word"
# The last option takes an argument...
if [[ "$state" != 'normal' ]]; then
if [[ "$optlen" -ne "${#word}" ]]; then
# If it's contained within the word, we won't complete it, revert to "normal"
state=normal
else
# Otherwise, complete it, but start at the beginning of *that* word
optlen=0
fi
fi
fi
done
# Parse current word
# Careful that it might look like an option, so use `--` aggressively!
local cur_word="${COMP_WORDS[$i]}"
# Process options, as short ones may change the state
if $opt_ena && [[ "$state" = 'normal' && "$cur_word" = '-'* ]]; then
# We might want to complete to an option or an arg to that option
# Parse the option word to check
# There's no whitespace in the option names, so we can ride a little dirty...
# Is this a long option?
if [[ "$cur_word" = '--'* ]]; then
# It is, try to complete one
mapfile -t COMPREPLY < <(compgen -W "${opts[*]%%:*}" -P '--' -- "${cur_word#--}")
return 0
else
# Short options may be grouped, parse them to determine what to complete
parse_short_opt "$cur_word"
if [[ "$state" = 'normal' ]]; then
mapfile -t COMPREPLY < <(compgen -W "${!opts[*]}" -P "$cur_word" '')
return 0
elif [[ "$optlen" = "${#cur_word}" && "$state" != "warning" ]]; then
# This short option group only awaits its argument!
# Post the option group as-is as a reply so that Readline inserts a space,
# so that the next completion request switches to the argument
# An exception is made for warnings, since it's idiomatic to stick them to the
# `-W`, and it doesn't break anything.
COMPREPLY=( "$cur_word" )
return 0
fi
fi
fi
COMPREPLY=()
case "$state" in
unk) # Return with no replies: no idea what to complete!
;;
warning)
mapfile -t COMPREPLY < <(compgen -W "
embedded
obsolete
trim-nonempty
all
everything
error" -P "${cur_word:0:$optlen}" -- "${cur_word:$optlen}")
;;
normal) # Acts like a glob...
state="glob-*.png"
;&
glob-*)
while read -r word; do
COMPREPLY+=("${cur_word:0:$optlen}$word")
done < <(for glob in ${state#glob-}; do compgen -A file -X \!"$glob" -- "${cur_word:$optlen}"; done)
# Also complete directories
;&
dir)
while read -r word; do
COMPREPLY+=("${cur_word:0:$optlen}$word")
done < <(compgen -A directory -- "${cur_word:$optlen}")
compopt -o filenames
;;
*)
echo >&2 "Internal completion error: invalid state \"$state\", please report this bug"
return 1
;;
esac
}
complete -F _rgbgfx_completions rgbgfx
+176
View File
@@ -0,0 +1,176 @@
#!/usr/bin/env bash
# Same notes as RGBASM
_rgblink_completions() {
# Format: "long_opt:state_after"
# Empty long opt = it doesn't exit
# See the `state` variable below for info about `state_after`
declare -A opts=(
[h]="help:normal"
[V]="version:normal"
[W]="warning:warning"
[M]="no-sym-in-map:normal"
[d]="dmg:normal"
[B]="backtrace:unk"
[l]="linkerscript:glob-*"
[m]="map:glob-*.map"
[n]="sym:glob-*.sym"
[O]="overlay:glob-*.gb *.gbc *.sgb"
[o]="output:glob-*.gb *.gbc *.sgb"
[p]="pad:unk"
[t]="tiny:normal"
[v]="verbose:normal"
[w]="wramx:normal"
[x]="nopad:normal"
)
# Parse command-line up to current word
local opt_ena=true
# Possible states:
# - normal = Well, normal. Options are parsed normally.
# - unk = An argument that can't be completed, and should just be skipped.
# - warning = A warning flag.
# - dir = A directory path
# - glob-* = A glob, after the dash is a whitespace-separated list of file globs to use
local state=normal
# The length of the option, used as a return value by the function below
local optlen=0
# $1: a short option word
# `state` will be set to the parsing state after the last option character in the word. If
# "normal" is not returned, `optlen` will be set to the length (dash included) of the "option"
# part of the argument.
parse_short_opt() {
for (( i = 1; i < "${#1}"; i++ )); do
# If the option is not known, assume it doesn't take an argument
local opt="${opts["${1:$i:1}"]:-":normal"}"
state="${opt#*:}"
# If the option takes an argument, record the length and exit
if [[ "$state" != 'normal' ]]; then
let optlen="$i + 1"
return
fi
done
optlen=0
}
for (( i = 1; i < COMP_CWORD; i++ )); do
local word="${COMP_WORDS[$i]}"
# If currently processing an argument, skip this word
if [[ "$state" != 'normal' ]]; then
state=normal
continue
fi
if [[ "$word" = '--' ]]; then
# Options stop being parsed after this
opt_ena=false
break
fi
# Check if it's a long option
if [[ "$word" = '--'* ]]; then
# If the option is unknown, assume it takes no arguments: keep the state at "normal"
for long_opt in "${opts[@]}"; do
if [[ "$word" = "--${long_opt%%:*}" ]]; then
state="${long_opt#*:}"
# Check if the next word is just '='; if so, skip it, the argument must follow
# (See "known bugs" at the top of this script)
let i++
if [[ "${COMP_WORDS[$i]}" != '=' ]]; then
let i--
fi
optlen=0
break
fi
done
# Check if it's a short option
elif [[ "$word" = '-'* ]]; then
parse_short_opt "$word"
# The last option takes an argument...
if [[ "$state" != 'normal' ]]; then
if [[ "$optlen" -ne "${#word}" ]]; then
# If it's contained within the word, we won't complete it, revert to "normal"
state=normal
else
# Otherwise, complete it, but start at the beginning of *that* word
optlen=0
fi
fi
fi
done
# Parse current word
# Careful that it might look like an option, so use `--` aggressively!
local cur_word="${COMP_WORDS[$i]}"
# Process options, as short ones may change the state
if $opt_ena && [[ "$state" = 'normal' && "$cur_word" = '-'* ]]; then
# We might want to complete to an option or an arg to that option
# Parse the option word to check
# There's no whitespace in the option names, so we can ride a little dirty...
# Is this a long option?
if [[ "$cur_word" = '--'* ]]; then
# It is, try to complete one
mapfile -t COMPREPLY < <(compgen -W "${opts[*]%%:*}" -P '--' -- "${cur_word#--}")
return 0
else
# Short options may be grouped, parse them to determine what to complete
parse_short_opt "$cur_word"
if [[ "$state" = 'normal' ]]; then
mapfile -t COMPREPLY < <(compgen -W "${!opts[*]}" -P "$cur_word" '')
return 0
elif [[ "$optlen" = "${#cur_word}" && "$state" != "warning" ]]; then
# This short option group only awaits its argument!
# Post the option group as-is as a reply so that Readline inserts a space,
# so that the next completion request switches to the argument
# An exception is made for warnings, since it's idiomatic to stick them to the
# `-W`, and it doesn't break anything.
COMPREPLY=( "$cur_word" )
return 0
fi
fi
fi
COMPREPLY=()
case "$state" in
unk) # Return with no replies: no idea what to complete!
;;
warning)
mapfile -t COMPREPLY < <(compgen -W "
assert
div
large-constant
obsolete
shift
shift-amount
truncation
all
everything
error" -P "${cur_word:0:$optlen}" -- "${cur_word:$optlen}")
;;
normal) # Acts like a glob...
state="glob-*.o *.obj"
;&
glob-*)
while read -r word; do
COMPREPLY+=("${cur_word:0:$optlen}$word")
done < <(for glob in ${state#glob-}; do compgen -A file -X \!"$glob" -- "${cur_word:$optlen}"; done)
# Also complete directories
;&
dir)
while read -r word; do
COMPREPLY+=("${cur_word:0:$optlen}$word")
done < <(compgen -A directory -- "${cur_word:$optlen}")
compopt -o filenames
;;
*)
echo >&2 "Internal completion error: invalid state \"$state\", please report this bug"
return 1
;;
esac
}
complete -F _rgblink_completions rgblink
+75
View File
@@ -0,0 +1,75 @@
#!/usr/bin/env bash
set -eu
usage() {
cat <<"EOF"
Generates LCOV code coverage report for RGBDS.
Options:
-h, --help show this help message
-o, --open open the HTML report in the preferred application
--jobs <n> build RGBDS and external codebases with `make -j<n>`
--os <os> skip tests known to fail on <os> (e.g. `macos-14`)
EOF
}
# Parse options in pure Bash because macOS `getopt` is stuck
# in what util-linux `getopt` calls `GETOPT_COMPATIBLE` mode
make_args=()
runtests_args=()
open_report=false
while [[ $# -gt 0 ]]; do
case "$1" in
-h|--help)
usage
exit 0
;;
-o|--open)
open_report=true
;;
--jobs)
shift
make_args+=(-j "$1")
runtests_args+=(--jobs "$1")
;;
--os)
shift
runtests_args+=(--os "$1")
;;
*)
echo "$(basename "$0"): unknown option '$1'"
exit 1
;;
esac
shift
done
# Build RGBDS with gcov support
make coverage "${make_args[@]}"
# Run the tests
pushd test
external/fetch-repos.sh
./run-tests.sh "${runtests_args[@]}"
popd
# Generate coverage logs
gcov src/**/*.cpp
mkdir -p coverage
# Generate coverage report, excluding Bison-generated files
COVERAGE_INFO=coverage/coverage.info
lcov -c --no-external -d . -o "$COVERAGE_INFO"
lcov -r "$COVERAGE_INFO" src/asm/parser.{hpp,cpp} src/link/script.{hpp,cpp} -o "$COVERAGE_INFO"
genhtml --dark-mode --num-spaces 4 -f -s -o coverage/ "$COVERAGE_INFO"
if "$open_report"; then
# Open the report in the preferred web browser
if [ "$(uname)" == "Darwin" ]; then
open coverage/index.html
else
xdg-open coverage/index.html
fi
else
# Output the path to the report
echo "Generated LCOV report at $PWD/coverage/index.html"
fi
+27 -44
View File
@@ -1,71 +1,54 @@
#!/bin/bash
#!/usr/bin/env bash
# SPDX-License-Identifier: MIT
#
# Copyright (c) 2020 Eldred Habert
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
STATE=0
diff <(xxd $1) <(xxd $2) | while read -r LINE; do
if [ $STATE -eq 0 ]; then
diff <(xxd "$1") <(xxd "$2") | while read -r LINE; do
if [[ $STATE -eq 0 ]]; then
# Discard first line (line info)
STATE=1
elif [ "$LINE" = '---' ]; then
elif [[ "$LINE" = '---' ]]; then
# Separator between files switches states
echo $LINE
echo "$LINE"
STATE=3
elif echo $LINE | grep -Eq '^[0-9]+(,[0-9]+)?c[0-9]+(,[0-9]+)?'; then
elif grep -Eq '^[0-9]+(,[0-9]+)?[cd][0-9]+(,[0-9]+)?' <<< "$LINE"; then
# Line info resets the whole thing
STATE=1
elif [ $STATE -eq 1 -o $STATE -eq 3 ]; then
elif [[ $STATE -eq 1 || $STATE -eq 3 ]]; then
# Compute the GB address from the ROM offset
OFS=$(echo $LINE | cut -d ' ' -f 2 | tr -d ':')
OFS=$(cut -d ' ' -f 2 <<< "$LINE" | tr -d ':')
BANK=$((0x$OFS / 0x4000))
ADDR=$((0x$OFS % 0x4000 + ($BANK != 0) * 0x4000))
ADDR=$((0x$OFS % 0x4000 + (BANK != 0) * 0x4000))
# Try finding the preceding symbol closest to the diff
if [ $STATE -eq 1 ]; then
if [[ $STATE -eq 1 ]]; then
STATE=2
SYMFILE=$(echo $1 | cut -d '.' -f 1).sym
SYMFILE=${1%.*}.sym
else
STATE=4
SYMFILE=$(echo $2 | cut -d '.' -f 1).sym
SYMFILE=${2%.*}.sym
fi
EXTRA=$(if [ -f "$SYMFILE" ]; then
EXTRA=$(if [[ -f "$SYMFILE" ]]; then
# Read the sym file for such a symbol
# Ignore comment lines, only pick matching bank
grep -Fv ';' "$SYMFILE" |
grep -Ei $(printf "^%02x:" $BANK) |
# (The bank regex ignores comments already, make `cut` and `tr` process less lines)
grep -Ei "$(printf "^%02x:" $BANK)" "$SYMFILE" |
sed "s/$(printf "^%02x:" $BANK)/0x/g" |
cut -d ';' -f 1 |
tr -d "\r" |
sort -g |
while read -r SYMADDR SYM; do
SYMADDR=$((0x$(echo $SYMADDR | cut -d ':' -f 2)))
if [ $SYMADDR -le $ADDR ]; then
printf " (%s+%#x)\n" $SYM $(($ADDR - $SYMADDR))
SYMADDR=$(($SYMADDR))
if [[ $SYMADDR -le $ADDR ]]; then
printf " (%s+0x%x)\n" "$SYM" $((ADDR - SYMADDR))
fi
# TODO: assumes sorted sym files
done | tail -n 1
fi)
printf "%02x:%04x %s\n" $BANK $ADDR $EXTRA
printf "%02x:%04x %s\n" $BANK $ADDR "$EXTRA"
fi
if [ $STATE -eq 2 -o $STATE -eq 4 ]; then
OFS=$(echo $LINE | cut -d ' ' -f 2 | tr -d ':')
if [[ $STATE -eq 2 || $STATE -eq 4 ]]; then
OFS=$(cut -d ' ' -f 2 <<< "$LINE" | tr -d ':')
BANK=$((0x$OFS / 0x4000))
ADDR=$((0x$OFS % 0x4000 + ($BANK != 0) * 0x4000))
printf "%s %02x:%04x: %s\n" "$(echo $LINE | cut -d ' ' -f 1)" $BANK $ADDR "$(echo $LINE | cut -d ' ' -f 3-)"
ADDR=$((0x$OFS % 0x4000 + (BANK != 0) * 0x4000))
printf "%s %02x:%04x: %s\n" "${LINE:0:1}" $BANK $ADDR "${LINE#*: }"
fi
done
+25
View File
@@ -0,0 +1,25 @@
#!/usr/bin/env bash
set -euo pipefail
if [[ $# -ne 2 ]]; then
cat <<EOF >&2
Usage: $0 <palettes.pal> <output.png>
EOF
exit 1
fi
TMP=$(mktemp -d)
readonly TMP
trap 'rm -rf "$TMP"' EXIT
tile() { for i in {0..7}; do printf "$1"; done }
{ tile '\x00\x00' && tile '\xFF\x00' && tile '\x00\xFF' && tile '\xFF\xFF'; } >"$TMP/tmp.2bpp"
NB_BYTES=$(wc -c <"$1")
(( NB_PALS = NB_BYTES / 8 ))
for (( i = 0; i < NB_PALS; i++ )); do
printf '\0\1\2\3' >>"$TMP/tmp.tilemap"
printf $(printf '\\x%x' $i{,,,}) >> "$TMP/tmp.palmap"
done
"${RGBGFX:-${RGBDS+$RGBDS/}rgbgfx}" -r 4 "$2" -o "$TMP/tmp.2bpp" -OTQ -p "$1" -n "$NB_PALS"
+69
View File
@@ -0,0 +1,69 @@
#compdef rgbasm
_rgbasm_warnings() {
local warnings=(
'error:Turn all warnings into errors'
'all:Enable most warning messages'
'extra:Enable extra, possibly unwanted, messages'
'everything:Enable literally everything'
'assert:Warn when WARN-type asserts fail'
'backwards-for:Warn when start and stop are backwards relative to step'
'builtin-args:Report incorrect args to built-in funcs'
'charmap-redef:Warn when redefining a charmap mapping'
'div:Warn when dividing the smallest int by -1'
'empty-data-directive:Warn on arg-less d[bwl] in ROM'
'empty-macro-arg:Warn on empty macro arg'
'empty-strrpl:Warn on calling STRRPL with empty pattern'
'export-undefined:Warn on EXPORT of an undefined symbol'
'large-constant:Warn on constants too large for a signed 32-bit int'
'macro-shift:Warn when shifting macro args part their limits'
'nested-comment:Warn on "/*" inside block comments'
'numeric-string:Warn when a multi-character string is treated as a number'
'obsolete:Warn when using deprecated features'
'purge:Warn when purging exported symbols or labels'
'shift:Warn when shifting negative values'
'shift-amount:Warn when a shift'\''s operand is negative or \> 32'
'truncation:Warn when implicit truncation loses bits'
'unmapped-char:Warn on unmapped character'
'unmatched-directive:Warn on unmatched directive pair'
'unterminated-load:Warn on LOAD without ENDL'
'user:Warn when executing the WARN built-in'
)
_describe warning warnings
}
local args=(
# Arguments are listed here in the same order as in the manual, except for the version and help
'(- : * options)'{-V,--version}'[Print version number and exit]'
'(- : * options)'{-h,--help}'[Print help text and exit]'
'(-E --export-all)'{-E,--export-all}'[Export all symbols]'
'(-v --verbose)'{-v,--verbose}'[Enable verbose output]'
-w'[Disable all warnings]'
'(-B --backtrace)'{-B,--backtrace}'+[Set backtrace depth or style]:param:'
'(-b --binary-digits)'{-b,--binary-digits}'+[Change chars for binary constants]:digit spec:'
--color'[Whether to use color in output]:color:(auto always never)'
'*'{-D,--define}'+[Define a string symbol]:name + value (default 1):'
'(-g --gfx-chars)'{-g,--gfx-chars}'+[Change chars for gfx constants]:chars spec:'
'(-I --include)'{-I,--include}'+[Add an include directory]:include path:_files -/'
'(-M --dependfile)'{-M,--dependfile}"+[Write dependencies in Makefile format]:output file:_files -g '*.{d,mk}'"
-MC'[Continue after missing dependencies]'
-MG'[Assume missing dependencies should be generated]'
-MP'[Add phony targets to all dependencies]'
'*'-MT"+[Add a target to the rules]:target:_files -g '*.{d,mk,o}'"
'*'-MQ"+[Add a target to the rules]:target:_files -g '*.{d,mk,o}'"
'(-o --output)'{-o,--output}'+[Output file]:output file:_files'
'(-P --preinclude)'{-P,--preinclude}"+[Pre-include a file]:include file:_files -g '*.{asm,inc}'"
'(-p --pad-value)'{-p,--pad-value}'+[Set padding byte]:padding byte:'
'(-Q --q-precision)'{-Q,--q-precision}'+[Set fixed-point precision]:precision:'
'(-r --recursion-depth)'{-r,--recursion-depth}'+[Set maximum recursion depth]:depth:'
'(-s --state)'{-s,--state}"+[Write features of final state]:state file:_files -g '*.dump.asm'"
'(-W --warning)'{-W,--warning}'+[Toggle warning flags]:warning flag:_rgbasm_warnings'
'(-X --max-errors)'{-X,--max-errors}'+[Set maximum errors before aborting]:maximum errors:'
":assembly sources:_files -g '*.asm'"
)
_arguments -s -S : $args
+82
View File
@@ -0,0 +1,82 @@
#compdef rgbfix
_mbc_names() {
local mbc_names=(
'ROM:$00'
'MBC1:$01'
'MBC1+RAM:$02'
'MBC1+RAM+BATTERY:$03'
'MBC2:$05'
'MBC2+BATTERY:$06'
'ROM+RAM:$08'
'ROM+RAM+BATTERY:$09'
'MMM01:$0B'
'MMM01+RAM:$0C'
'MMM01+RAM+BATTERY:$0D'
'MBC3+TIMER+BATTERY:$0F'
'MBC3+TIMER+RAM+BATTERY:$10'
'MBC3:$11'
'MBC3+RAM:$12'
'MBC3+RAM+BATTERY:$13'
'MBC5:$19'
'MBC5+RAM:$1A'
'MBC5+RAM+BATTERY:$1B'
'MBC5+RUMBLE:$1C'
'MBC5+RUMBLE+RAM:$1D'
'MBC5+RUMBLE+RAM+BATTERY:$1E'
'MBC6:$20'
'MBC7+SENSOR+RUMBLE+RAM+BATTERY:$22'
'POCKET_CAMERA:$FC'
'BANDAI_TAMA5:$FD'
'HUC3:$FE'
'HUC1+RAM+BATTERY:$FF'
)
_describe "MBC name" mbc_names
}
_rgbfix_warnings() {
local warnings=(
'error:Turn all warnings into errors'
'all:Enable most warning messages'
'everything:Enable literally everything'
'mbc:Warn about issues with MBC specs'
'obsolete:Warn when using deprecated features'
'overwrite:Warn when overwriting non-zero bytes'
'sgb:Warn when SGB flag conflicts with old licensee code'
'truncation:Warn when values are truncated to fit'
)
_describe warning warnings
}
local args=(
# Arguments are listed here in the same order as in the manual, except for the version and help
'(- : * options)'{-V,--version}'[Print version number and exit]'
'(- : * options)'{-h,--help}'[Print help text and exit]'
'(-C --color-only -c --color-compatible)'{-C,--color-only}'[Mark ROM as GBC-only]'
'(-C --color-only -c --color-compatible)'{-c,--color-compatible}'[Mark ROM as GBC-compatible]'
'(-j --non-japanese)'{-j,--non-japanese}'[Set the non-Japanese region flag]'
'(-O --overwrite)'{-O,--overwrite}'[Allow overwriting non-zero bytes]'
'(-s --sgb-compatible)'{-s,--sgb-compatible}'[Set the SGB flag]'
'(-f --fix-spec -v --validate)'{-v,--validate}'[Shorthand for -f lhg]'
-w'[Disable all warnings]'
--color'[Whether to use color in output]:color:(auto always never)'
'(-f --fix-spec -v --validate)'{-f,--fix-spec}'+[Fix or trash some header values]:fix spec:'
'(-i --game-id)'{-i,--game-id}'+[Set game ID string]:4-char game ID:'
'(-k --new-licensee)'{-k,--new-licensee}'+[Set new licensee string]:2-char licensee ID:'
'(-l --old-licensee)'{-l,--old-licensee}'+[Set old licensee ID]:licensee number:'
'(-L --logo)'{-L,--logo}'+[Set custom logo]:1bpp image:'
'(-m --mbc-type)'{-m,--mbc-type}"+[Set MBC flags]:mbc name:_mbc_names"
'(-n --rom-version)'{-n,--rom-version}'+[Set ROM version]:rom version byte:'
'(-o --output)'{-o,--output}"+[Output file]:output file:_files -g '*.{gb,sgb,gbc}'"
'(-p --pad-value)'{-p,--pad-value}'+[Pad to next valid size using this byte as padding]:padding byte:'
'(-r --ram-size)'{-r,--ram-size}'+[Set RAM size]:ram size byte:'
'(-t --title)'{-t,--title}'+[Set title string]:11-char title string:'
'(-W --warning)'{-W,--warning}'+[Toggle warning flags]:warning flag:_rgbfix_warnings'
'*'":ROM files:_files -g '*.{gb,sgb,gbc}'"
)
_arguments -s -S : $args
+66
View File
@@ -0,0 +1,66 @@
#compdef rgbgfx
_depths() {
local depths=(
'1:1bpp'
'2:2bpp (native)'
)
_describe 'bit depth' depths
}
_rgbgfx_warnings() {
local warnings=(
'error:Turn all warnings into errors'
'all:Enable most warning messages'
'everything:Enable literally everything'
'embedded:Warn when using embedded PLTE without "-c embedded"'
'obsolete:Warn when using deprecated features'
'trim-nonempty:Warn when "-x" trims nonempty tiles'
)
_describe warning warnings
}
local args=(
# Arguments are listed here in the same order as in the manual, except for the version and help
'(- : * options)'{-V,--version}'[Print version number and exit]'
'(- : * options)'{-h,--help}'[Print help text and exit]'
'(-a --attr-map -A --auto-attr-map)'{-A,--auto-attr-map}'[Shortcut for -a <file>.attrmap]'
'(-C --color-curve)'{-C,--color-curve}'[Generate palettes using GBC color curve]'
'(-m --mirror-tiles)'{-m,--mirror-tiles}'[Eliminate mirrored tiles from output]'
'(-O --group-outputs)'{-O,--group-outputs}'[Base "shortcut" options on the output path, not input]'
'(-p --palette -P --auto-palette)'{-P,--auto-palette}'[Shortcut for -p <file>.pal]'
'(-q --palette-map -Q --auto-palette-map)'{-Q,--auto-palette-map}'[Shortcut for -p <file>.palmap]'
'(-t --tilemap -T --auto-tilemap)'{-T,--auto-tilemap}'[Shortcut for -t <file>.tilemap]'
'(-u --unique-tiles)'{-u,--unique-tiles}'[Eliminate redundant tiles]'
'(-v --verbose)'{-v,--verbose}'[Enable verbose output]'
-w'[Disable all warnings]'
'(-X --mirror-x)'{-X,--mirror-x}'[Eliminate horizontally mirrored tiles from output]'
'(-Y --mirror-y)'{-Y,--mirror-y}'[Eliminate vertically mirrored tiles from output]'
'(-Z --columns)'{-Z,--columns}'[Read the image in column-major order]'
'(-a --attr-map -A --auto-attr-map)'{-a,--attr-map}'+[Generate a map of tile attributes (mirroring)]:attrmap file:_files'
'(-B --background-color)'{-B,--background-color}'+[Ignore tiles containing only specified color]:color:'
'(-b --base-tiles)'{-b,--base-tiles}'+[Base tile IDs for tile map output]:base tile IDs:'
--color'[Whether to use color in output]:color:(auto always never)'
'(-c --colors)'{-c,--colors}'+[Specify color palettes]:palette spec:'
'(-d --depth)'{-d,--depth}'+[Set bit depth]:bit depth:_depths'
'(-i --input-tileset)'{-i,--input-tileset}'+[Use specific tiles]:tileset file:_files -g "*.2bpp"'
'(-L --slice)'{-L,--slice}'+[Only process a portion of the image]:input slice:'
'(-N --nb-tiles)'{-N,--nb-tiles}'+[Limit number of tiles]:tile count:'
'(-n --nb-palettes)'{-n,--nb-palettes}'+[Limit number of palettes]:palette count:'
'(-o --output)'{-o,--output}'+[Set output file]:output file:_files'
'(-p --palette -P --auto-palette)'{-p,--palette}"+[Output the image's palette in little-endian native RGB555 format]:palette file:_files"
'(-q --palette-map -Q --auto-palette-map)'{-q,--palette-map}"+[Output the image's palette map]:palette map file:_files"
'(-r --reverse)'{-r,--reverse}'+[Yield an image from binary data]:image width (in tiles):'
'(-s --palette-size)'{-s,--palette-size}'+[Limit palette size]:palette size:'
'(-t --tilemap -T --auto-tilemap)'{-t,--tilemap}'+[Generate a map of tile indices]:tilemap file:_files'
'(-W --warning)'{-W,--warning}'+[Toggle warning flags]:warning flag:_rgbgfx_warnings'
'(-x --trim-end)'{-x,--trim-end}'+[Trim end of output by this many tiles]:tile count:'
":input png file:_files -g '*.png'"
)
_arguments -s -S : $args
+46
View File
@@ -0,0 +1,46 @@
#compdef rgblink
_rgblink_warnings() {
local warnings=(
'error:Turn all warnings into errors'
'all:Enable most warning messages'
'everything:Enable literally everything'
'assert:Warn when WARN-type asserts fail'
'div:Warn when dividing the smallest int by -1'
'large-constant:Warn on constants too large for a signed 32-bit int'
'obsolete:Warn when using deprecated features'
'shift:Warn when shifting negative values'
'shift-amount:Warn when a shift'\''s operand is negative or \> 32'
'truncation:Warn when implicit truncation loses bits'
)
_describe warning warnings
}
local args=(
# Arguments are listed here in the same order as in the manual, except for the version and help
'(- : * options)'{-V,--version}'[Print version number and exit]'
'(- : * options)'{-h,--help}'[Print help text and exit]'
'(-d --dmg)'{-d,--dmg}'[Enable DMG mode (-w + no VRAM banking)]'
'(-t --tiny)'{-t,--tiny}'[Enable tiny mode, disabling ROM banking]'
'(-v --verbose)'{-v,--verbose}'[Enable verbose output]'
'(-w --wramx)'{-w,--wramx}'[Disable WRAM banking]'
'(-x --nopad)'{-x,--nopad}'[Disable padding the end of the final file]'
'(-B --backtrace)'{-B,--backtrace}'+[Set backtrace depth or style]:param:'
--color'[Whether to use color in output]:color:(auto always never)'
'(-l --linkerscript)'{-l,--linkerscript}"+[Use a linker script]:linker script:_files -g '*.link'"
'(-M --no-sym-in-map)'{-M,--no-sym-in-map}'[Do not output symbol names in map file]'
'(-m --map)'{-m,--map}"+[Produce a map file]:map file:_files -g '*.map'"
'(-n --sym)'(-n,--sym)"+[Produce a symbol file]:sym file:_files -g '*.sym'"
'(-O --overlay)'{-O,--overlay}'+[Overlay sections over on top of bin file]:base overlay:_files'
'(-o --output)'{-o,--output}"+[Write ROM image to this file]:rom file:_files -g '*.{gb,sgb,gbc}'"
'(-p --pad-value)'{-p,--pad-value}'+[Set padding byte]:padding byte:'
'(-S --scramble)'{-s,--scramble}'+[Activate scrambling]:scramble spec'
'(-W --warning)'{-W,--warning}'+[Toggle warning flags]:warning flag:_rgblink_warnings'
'*'":object files:_files -g '*.o'"
)
_arguments -s -S : $args
+301
View File
@@ -0,0 +1,301 @@
# RGBDS Architecture
The RGBDS package consists of four programs: RGBASM, RGBLINK, RGBFIX, and RGBGFX.
- RGBASM is the assembler. It takes assembly code as input, and produces an RGB object file as output (and optionally a state file, logging the final state of variables and constants).
- RGBLINK is the linker. It takes object files as input, and produces a ROM file as output (and optionally a symbol and/or map file, logging where the assembly declarations got placed in the ROM).
- RGBFIX is the checksum/header fixer. It takes a ROM file as input, and outputs the same ROM file (or modifies it in-place) with the cartridge header's checksum and other metadata fixed for consistency.
- RGBGFX is the graphics converter. It takes a PNG image file as input, and outputs the tile data, palettes, tilemap, attribute map, and/or palette map in formats that the Game Boy can use.
In the simplest case, a single pipeline can turn an assembly file into a ROM:
```console
(rgbasm -o - - | rgblink -o - - | rgbfix -v -p 0) < game.asm > game.gb
```
This document describes how these four programs are structured. It goes over each source code file, noting which data is *global* (and thus scoped in all files), *owned* by that file (i.e. that is where the data's memory is managed, via [RAII](https://en.wikipedia.org/wiki/Resource_acquisition_is_initialization)) or *referenced* by that file (i.e. there are non-owning pointers to some data, and care must be taken to not dereference those pointers after the data's owner has moved or deleted the data).
We assume that the programs are single-threaded; data structures and operations may not be thread-safe.
## Folder Organization
The RGBDS source code file structure is as follows:
```
rgbds/
├── .github/
│ ├── scripts/
│ │ └── ...
│ └── workflows/
│ └── ...
├── cmake/
│ └── ...
├── contrib/
│ ├── bash_compl/
│ ├── zsh_compl/
│ │ └── ...
│ └── ...
├── docs/
│ └── ...
├── include/
│ └── ...
├── man/
│ └── ...
├── src/
│ ├── asm/
│ │ └── ...
│ ├── extern/
│ │ └── ...
│ ├── fix/
│ │ └── ...
│ ├── gfx/
│ │ └── ...
│ ├── link/
│ │ └── ...
│ ├── CMakeLists.txt
│ ├── bison.sh
│ └── ...
├── test/
│ ├── run-tests.sh
│ ├── external/
│ │ ├── fetch-repos.sh
│ │ └── ...
│ └── ...
├── .clang-format
├── .clang-tidy
├── CMakeLists.txt
├── CMakePresets.json
├── Dockerfile
└── Makefile
```
- **`.github/`:**
Files related to the integration of the RGBDS codebase with GitHub features.
* **`scripts/`:**
Scripts used by GitHub Actions workflow files.
* **`workflows/`:**
GitHub Actions CI workflow description files. Used for automated testing, deployment, etc.
- **`cmake/`**:
Files relevant to our CMake build system that are not required to be somewhere else (e.g. `CMakePresets.json` *has* to be at the root).
- **`contrib/`:**
Scripts and other resources which may be useful to RGBDS users and developers.
* **`bash_compl/`:**
Tab completion scripts for use with `bash`. Run them with `source` somewhere in your `.bashrc`, and they should auto-load when you open a shell.
* **`zsh_compl/`:**
Tab completion scripts for use with `zsh`. Put them somewhere in your `fpath`, and they should auto-load when you open a shell.
- **`docs/`:**
Documentation related to the development and maintenance of RGBDS itself.
(The directory's name, as well as some of its file's names, are
[recognized by GitHub](https://docs.github.com/en/communities/setting-up-your-project-for-healthy-contributions/setting-guidelines-for-repository-contributors)
and linked to in parts of its UI.)
Documentation for RGBDS itself exists as manual pages in `man/`.
- **`include/`:**
Header files for the respective source files in `src`.
- **`man/`:**
Manual pages to be read with `man`, written in the [`mandoc`](https://mandoc.bsd.lv) dialect.
- **`src/`:**
Source code of RGBDS.
* **`asm/`:**
Source code of RGBASM.
* **`extern/`:**
Source code copied from external sources.
* **`fix/`:**
Source code of RGBFIX.
* **`gfx/`:**
Source code of RGBGFX.
* **`link/`:**
Source code of RGBLINK.
* **`CMakeLists.txt`:**
Defines how to build individual RGBDS programs with CMake, including the source files that each program depends on.
* **`bison.sh`:**
Script used to run the Bison parser generator with the latest flags that the user's version supports.
- **`test/`:**
Testing framework used to verify that changes to the code don't break or modify the behavior of RGBDS.
The `test.sh` scripts inside each of the subdirectories are the individual test drivers.
* **`run-tests.sh`:**
Script used to run tests, including internal test cases and external repositories. `run-tests.sh --help` describes its options.
* **`external/`:**
Directory for third-party repos making use of RGBDS, which get cloned here and built during testing.
- **`fetch-repos.sh`:**
Script used to clone the external repositories. `fetch-repos.sh --help` describes its options.
- **`*.cfg`:**
Each `.cfg` file defines the parameters to clone, build, and verify an external repository.
- **`.clang-format`:**
Code style for automated C++ formatting with [`clang-format`](https://clang.llvm.org/docs/ClangFormat.html) (for which we define the shortcut `make format`).
- **`.clang-tidy`:**
Configuration for C++ static analysis with [`clang-tidy`](https://clang.llvm.org/extra/clang-tidy/) (for which we define the shortcut `make tidy`).
- **`CMakeLists.txt`:**
Defines how to build RGBDS with CMake.
- **`CMakePresets.json`:**
Defines some [presets](https://cmake.org/cmake/help/latest/manual/cmake-presets.7.html) useful for working with our CMake.
- **`Dockerfile`:**
Defines how to build RGBDS with Docker (which we do in CI to provide a [container image](https://github.com/gbdev/rgbds/pkgs/container/rgbds)).
- **`Makefile`:**
Defines how to build RGBDS with `make`, including the source files that each program depends on.
## RGBDS
These files in the `src/` directory are shared across multiple programs: often all four (RGBASM, RGBLINK, RGBFIX, and RGBGFX), sometimes only RGBASM and RGBLINK.
- **`backtrace.cpp`:**
Generic printing of location backtraces for RGBASM and RGBLINK. Allows configuring backtrace styles with a command-line flag (conventionally `-B/--backtrace`). Renders warnings in yellow, errors in red, and locations in cyan.
- **`cli.cpp`:**
A function for parsing command-line options, including RGBDS-specific "at-files" (a filename containing more options, prepended with an "`@`").
This is the only file to use the extern/getopt.cpp variables and functions.
- **`diagnostics.cpp`:**
Generic warning/error diagnostic support for all programs. Allows command-line flags (conventionally `-W`) to have `no-`, `error=`, or `no-error=` prefixes, and `=` level suffixes; allows "meta" flags to affect groups of individual flags; and counts how many total errors there have been. Every program has its own `warning.cpp` file that uses this.
- **`linkdefs.cpp`:**
Constants, data, and functions related to RGBDS object files, which are used for RGBASM output and RGBLINK input.
This file defines two *global* variables, `sectionTypeInfo` (metadata about each section type) and `sectionModNames` (names of section modifiers, for error reporting). RGBLINK may change some values in `sectionTypeInfo` depending on its command-line options (this only affects RGBLINK; `sectionTypeInfo` is immutable in RGBASM).
- **`opmath.cpp`:**
Functions for mathematical operations in RGBASM and RGBLINK that aren't trivially equivalent to built-in C++ ones, such as division and modulo with well-defined results for negative values.
- **`style.cpp`:**
Generic printing of cross-platform colored or bold text. Obeys the [`FORCE_COLOR`](https://force-color.org/) and [`NO_COLOR`](https://no-color.org/) environment variables, and allows configuring with a command-line flag (conventionally `--color`).
- **`usage.cpp`:**
Generic printing of usage information. Renders headings in green, flags in cyan, and URLs in blue. Every program has its own `main.cpp` file that uses this.
- **`util.cpp`:**
Utility functions applicable to most programs, mostly dealing with text strings, such as locale-independent character checks.
- **`verbosity.cpp`:**
Generic printing of messages conditionally at different verbosity levels. Allows configuring with a command-line flag (conventionally `-v/--verbose`).
- **`version.cpp`:**
RGBDS version number and string for all the programs.
## External
These files have been copied ("vendored") from external authors and adapted for use with RGBDS. Both of our vendored dependencies use the same MIT license as RGBDS.
- **`getopt.cpp`:**
Functions for parsing command-line options, including conventional single-dash and double-dash options.
This file defines some *global* `musl_opt*` variables, including `musl_optarg` (the argument given after an option flag) and `musl_optind` (the index of the next option in `argv`). Copied from [musl libc](https://musl.libc.org/).
- **`utf8decoder.cpp`:**
Function for decoding UTF-8 bytes into Unicode code points. Copied from [Björn Höhrmann](https://bjoern.hoehrmann.de/utf-8/decoder/dfa/).
## RGBASM
- **`actions.cpp`:**
Actions taken by the assembly language parser, to avoid large amounts of code going in the parser.y file.
- **`charmap.cpp`:**
Functions and data related to charmaps.
This file *owns* the `Charmap`s in its `charmaps` collection. It also maintains a static `currentCharmap` pointer, and a `charmapStack` stack of pointers to `Charmap`s within `charmaps` (which is affected by `PUSHC` and `POPC` directives).
- **`fixpoint.cpp`:**
Functions for fixed-point math, with configurable [Q*m*.*n*](https://en.wikipedia.org/wiki/Q_(number_format)) precision.
- **`format.cpp`:**
`FormatSpec` methods for parsing and applying format specs, as used by `{interpolations}` and `STRFMT`.
- **`fstack.cpp`:**
Functions and data related to "fstack" nodes (the contents of top-level or `INCLUDE`d files, macro expansions, or `REPT`/`FOR` loop iterations) and their "contexts" (metadata that is only relevant while a node's content is being lexed and parsed).
This file *owns* the `Context`s in its `contextStack` collection. Each of those `Context`s *owns* its `LexerState`, and *refers* to its `FileStackNode`, `uniqueIDStr`, and `macroArgs`. Each `FileStackNode` also *references* its `parent`.
- **`intern.cpp`:**
[Interned strings](https://en.wikipedia.org/wiki/String_interning), which are used for the names of keywords, symbols (labels, constants, variables, string constants, macros, etc), and charmaps.
This file *owns* the strings in its `internedStrings` collection, which its `internedIndexes` collection *references* by view and index.
- **`lexer.cpp`:**
Functions and data related to [lexing](https://en.wikipedia.org/wiki/Lexical_analysis) assembly source code into tokens, which can then be parsed.
This file maintains static `lexerState` and `lexerStateEOL` pointers to `LexerState`s from the `Context`s in `fstack.cpp`.
Each `LexerState` *owns* its `content` and its `expansionStack`'s content. Each `Expansion` (the contents of an `{interpolation}` or macro argument) in turn *owns* its `contents`.
The lexer and parser are interdependent: when the parser reaches certain tokens, it changes the lexer's mode, which affects how characters get lexed into tokens. For example, when the parser reaches a macro name, it changes the lexer to "raw" mode, which lexes the rest of the line as a sequence of string arguments to the macro.
- **`macro.cpp`:**
`MacroArgs` methods related to macro arguments. Each `MacroArgs` *references* its arguments' contents.
- **`main.cpp`:**
The `main` function for running RGBASM, including the initial handling of command-line options.
This file defines a *global* `options` variable with the parsed CLI options.
- **`opt.cpp`:**
Functions for parsing options specified by `OPT` or by certain command-line options.
This file *owns* the `OptStackEntry`s in its `stack` collection (which is affected by `PUSHO` and `POPO` directives).
- **`output.cpp`:**
Functions and data related to outputting object files (with `-o/--output`) and state files (with `-s/--state`).
This file *owns* its `assertions` (created by `ASSERT` and `STATIC_ASSERT` directives). Every assertion gets output in the object file.
This file also *references* some `fileStackNodes`, and maintains static pointers to `Symbol`s in `objectSymbols`. Only the "registered" symbols and fstack nodes get output in the object file. The `fileStackNodes` and `objectSymbols` collections keep track of which nodes and symbols have been registered for output.
- **`parser.y`:**
Grammar for the RGBASM assembly language, which Bison preprocesses into a [LALR(1) parser](https://en.wikipedia.org/wiki/LALR_parser).
The Bison-generated parser calls `yylex` (defined in `lexer.cpp`) to get the next token, and calls `yywrap` (defined in `fstack.cpp`) when the current context is out of tokens and returns `EOF`.
- **`rpn.cpp`:**
`Expression` methods and data related to "[RPN](https://en.wikipedia.org/wiki/Reverse_Polish_notation)" expressions. When a numeric expression is parsed, if its value cannot be calculated at assembly time, it is built up into a buffer of RPN-encoded operations to do so at link time by RGBLINK. The valid RPN operations are defined in [man/rgbds.5](/man/rgbds.5).
- **`section.cpp`:**
Functions and data related to `SECTION`s.
This file *owns* the `Section`s in its `sections` collection. It also maintains various static pointers to those sections, including the `currentSection`, `currentLoadSection`, and `sectionStack` (which is affected by `PUSHS` and `POPS` directives). (Note that sections cannot be deleted.)
- **`symbol.cpp`:**
Functions and data related to symbols (labels, constants, variables, string constants, macros, etc).
This file *owns* the `Symbol`s in its `symbols` collection, and the various built-in ones outside that collection (`PCSymbol` for "`@`", `NARGSymbol` for "`_NARG`", etc). It also maintains a static `purgedSymbols` collection to remember which symbol names have been `PURGE`d from `symbols`, for error reporting purposes.
- **`warning.cpp`:**
Functions and data for warning and error output.
This file defines a *global* `warnings` variable using the `diagnostics.cpp` code for RGBASM-specific warning flags.
## RGBFIX
- **`fix.cpp`:**
Functions for fixing the ROM header.
- **`main.cpp`:**
The `main` function for running RGBFIX, including the initial handling of command-line options.
This file defines a *global* `options` variable with the parsed CLI options.
- **`mbc.cpp`:**
Functions and data related to [MBCs](https://gbdev.io/pandocs/MBCs.html), including the names of known MBC values.
- **`warning.cpp`:**
Functions and data for warning and error output.
This file defines a *global* `warnings` variable using the `diagnostics.cpp` code for RGBFIX-specific warning flags.
## RGBGFX
- **`color_set.cpp`:**
`ColorSet` methods for creating and comparing sets of colors. A color set includes the unique colors used by a single tile, and these sets are then packed into palettes.
- **`main.cpp`:**
The `main` function for running RGBGFX, including the initial handling of command-line options.
This file defines a *global* `options` variable with the parsed CLI options.
- **`pal_packing.cpp`:**
Functions for packing color sets into palettes. This is done with an ["overload-and-remove" heuristic](https://arxiv.org/abs/1605.00558) for a pagination algorithm.
- **`pal_sorting.cpp`:**
Functions for sorting colors within palettes, which works differently for grayscale, RGB, or indexed-color palettes.
- **`pal_spec.cpp`:**
Functions for parsing various formats of palette specifications (from `-c/--colors`).
- **`palette.cpp`:**
`Palette` methods for working with up to four GBC-native (RGB555) colors.
- **`png.cpp`:**
`Png` methods for reading PNG image files, standardizing them to 8-bit RGBA pixels while also reading their indexed palette if there is one.
- **`process.cpp`:**
Functions related to generating and outputting files (tile data, palettes, tilemap, attribute map, and/or palette map).
- **`reverse.cpp`:**
Functions related to reverse-generating RGBGFX outputs into a PNG file (for `-r/--reverse`).
- **`rgba.cpp`:**
`Rgba` methods related to RGBA colors and their 8-bit or 5-bit representations.
- **`warning.cpp`:**
Functions and data for warning and error output.
This file defines a *global* `warnings` variable using the `diagnostics.cpp` code for RGBGFX-specific warning flags.
## RGBLINK
- **`assign.cpp`:**
Functions and data for assigning `SECTION`s to specific banks and addresses.
This file *owns* the `memory` table of free space: each section type is associated with a list of each bank's free address ranges, which are allocated to sections using a [first-fit decreasing](https://en.wikipedia.org/wiki/Bin_packing_problem#First-fit_algorithm) bin-packing algorithm.
- **`fstack.cpp`:**
Functions related to "fstack" nodes (the contents of top-level or `INCLUDE`d files, macro expansions, or `REPT`/`FOR` loop iterations) read from the object files. At link time, these nodes are only needed for printing of location backtraces.
- **`layout.cpp`:**
Actions taken by the linker script parser, to avoid large amounts of code going in the script.y file.
This file maintains some static data about the current bank and address layout, which get checked and updated for consistency as the linker script is parsed.
- **`lexer.cpp`:**
Functions and data related to [lexing](https://en.wikipedia.org/wiki/Lexical_analysis) linker script files into tokens, which can then be parsed.
This file *owns* the `LexerStackEntry`s in its `lexerStack` collection. Each of those `LexerStackEntry`s *owns* its `file`. The stack is updated as linker scripts can `INCLUDE` other linker script pieces.
The linker script lexer is simpler than the RGBASM one, and does not have modes.
- **`main.cpp`:**
The `main` function for running RGBLINK, including the initial handling of command-line options.
This file defines a *global* `options` variable with the parsed CLI options.
- **`object.cpp`:**
Functions and data for reading object files generated by RGBASM.
This file *owns* the `Symbol`s in its `symbolLists` collection, and the `FileStackNode`s in its `nodes` collection.
- **`output.cpp`:**
Functions and data related to outputting ROM files (with `-o/--output`), symbol files (with `-n/--sym`), and map files (with `-m/--map`).
This file *references* some `Symbol`s and `Section`s, in collections that keep them sorted by address and name, which allows the symbol and map output to be in order.
- **`patch.cpp`:**
Functions and data related to "[RPN](https://en.wikipedia.org/wiki/Reverse_Polish_notation)" expression patches read from the object files, including the ones for `ASSERT` conditions. After sections have been assigned specific locations, the RPN patches can have their values calculated and applied to the ROM. The valid RPN operations are defined in [man/rgbds.5](/man/rgbds.5).
This file *owns* the `Assertion`s in its `assertions` collection, and the `RPNStackEntry`s in its `rpnStack` collection.
- **`script.y`:**
Grammar for the linker script language, which Bison preprocesses into a [LALR(1) parser](https://en.wikipedia.org/wiki/LALR_parser).
The Bison-generated parser calls `yylex` (defined in `lexer.cpp`) to get the next token, and calls `yywrap` (also defined in `lexer.cpp`) when the current context is out of tokens and returns `EOF`.
- **`sdas_obj.cpp`:**
Functions and data for reading object files generated by [GBDK with SDCC](https://gbdk.org/). RGBLINK support for these object files is incomplete.
- **`section.cpp`:**
Functions and data related to `SECTION`s read from the object files.
This file *owns* the `Section`s in its `sections` collection.
- **`symbol.cpp`:**
Functions and data related to symbols read from the object files.
This file *references* the `Symbol`s in its `symbols` and `localSymbols` collections, which allow accessing symbols by name.
- **`warning.cpp`:**
Functions and data for warning and error output.
This file defines a *global* `warnings` variable using the `diagnostics.cpp` code for RGBLINK-specific warning flags.
+271
View File
@@ -0,0 +1,271 @@
# Contributing
RGBDS was created in the late '90s and has received contributions from several
developers since then. It wouldn't have been possible to get to this point
without their work, and it is always open to the contributions of other people.
## Reporting bugs
Bug reports are essential to improve RGBDS and they are always welcome. If you
want to report a bug:
1. Make sure that there isn't a similar issue
[already reported](https://github.com/gbdev/rgbds/issues).
2. Figure out a way of reproducing it reliably.
3. If there is a piece of code that triggers the bug, try to reduce it to the
smallest file you can.
4. Create a new [issue](https://github.com/gbdev/rgbds/issues).
Of course, it may not always be possible to give an accurate bug report, but it
always helps to fix it.
## Requesting new features
If you come up with a good idea that could be implemented, you can propose it to
be done.
1. Create a new [issue](https://github.com/gbdev/rgbds/issues).
2. Try to be as accurate as possible. Describe what you need and why you need
it, maybe with examples.
Please understand that the contributors are doing it in their free time, so
simple requests are more likely to catch the interest of a contributor than
complicated ones. If you really need something to be done, and you think you can
implement it yourself, you can always contribute to RGBDS with your own code.
## Contributing code
Thank you! Code contributions are the most appreciated.
You can find a description of the project's layout in [`ARCHITECTURE.md`](/ARCHITECTURE.md).
If you want to contribute with your own code, whether it is to fix a current
issue or to add something that nobody had requested, you should first consider
if your change is going to be small (and likely to be accepted as-is) or big
(and will have to go through some rework).
Big changes will most likely require some discussion, so open an
[issue](https://github.com/gbdev/rgbds/issues) and explain what you want to
do and how you intend to do it. If you already have a prototype, it's always a
good idea to show it. Tests help, too.
If you are going to work on a specific issue that involves a lot of work, it is
always a good idea to leave a message, just in case someone else is interested
but doesn't know that there's someone working on it.
Note that you must contribute all your changes under the MIT License. If you are
just modifying a file, you don't need to do anything (maybe update the copyright
years). If you are adding new files, you need to use the
`SPDX-License-Identifier: MIT` header.
1. Fork this repository.
2. Checkout the `master` branch.
3. Create a new branch to work on. You could still work on `master`, but it's
easier that way.
4. Compile your changes with `make develop` instead of just `make`. This
target checks for additional warnings. Your patches shouldn't introduce any
new warning (but it may be possible to remove some warning checks if it makes
the code much easier).
You can also use `cmake --preset develop` if you prefer.
5. Test your changes by running `./run-tests.sh` in the `test` directory.
`./run-tests.sh --help` will print its available options. (You must run
`external/fetch-repos.sh` first; if you forget to, the test suite will fail and
remind you mid-way.)
You can also use `ctest --test-dir build` if you prefer.
`ctest --test-dir build --print-labels` will print its available
[test labels](https://cmake.org/cmake/help/latest/manual/ctest.1.html#label-matching).
6. Format your changes according to `clang-format`, which will reformat the
coding style according to our standards defined in `.clang-format`. You can
use `make format` to format all the C++ files.
7. Create a pull request against the branch `master`.
8. Check the results of the GitHub Actions CI jobs for your pull request. The
"Code format checking" and "Regression testing" jobs should all succeed.
The "Diff completeness check" job should be manually checked, as it may
output warnings which do not count as failure errors. The "Code coverage
report" provides an [LCOV](https://github.com/linux-test-project/lcov)-generated
report which can be downloaded and checked to see if your new code has full
test coverage.
9. Be prepared to get some comments about your code and to modify it. Tip: Use
`git rebase -i origin/master` to modify chains of commits.
## Adding a test
The test suite is a little ad-hoc, so the way tests work is different for each
program being tested.
Feel free to modify how the test scripts work, if the thing you want to test
doesn't fit the existing scheme(s).
### RGBASM
There are two kinds of test.
#### Simple tests
Each `.asm` file corresponds to one test.
RGBASM will be invoked on the `.asm` file with all warnings enabled.
If a `.flags` file exists, its first line contains flags to pass to RGBASM.
(There may be more lines, which will be ignored; they can serve as comments to
explain what the test is about.)
If a `.out` file exists, RGBASM's output (`print`, `println`, etc.) must match
its contents.
If a `.err` file exists, RGBASM's error output (`warn`, errors, etc.) must match
its contents.
If a `.out.bin` file exists, the object file will be linked, and the generated
ROM truncated to the length of the `.out.bin` file.
After that, the ROM must match the `.out.bin` file.
#### CLI tests
Each `.flags` file in `cli/` corresponds to one test.
RGBASM will be invoked, passing it the first line of the `.flags` file.
(There may be more lines, which will be ignored; they can serve as comments to
explain what the test is about.)
If a `.out` file exists, RGBASM's output (`print`, `println`, etc.) must match
its contents.
If a `.err` file exists, RGBASM's error output (`warn`, errors, etc.) must match
its contents.
### RGBLINK
Each `.asm` file corresponds to one test, or one *set* of tests.
All tests begin by assembling the `.asm` file into an object file, which will be
linked in various ways depending on the test.
#### Simple tests
These simply check that RGBLINK's output matches some expected output.
If a `.flags` file exists, its first line contains flags to pass to RGBLINK.
(There may be more lines, which will be ignored; they can serve as comments to
explain what the test is about.)
A `.out` file **must** exist, and RGBLINK's total output must match that file's
contents.
Additionally, if a `.out.bin` file exists, the `.gb` file generated by RGBLINK
must match it.
#### Linker script tests
These allow applying various linker scripts to the same object file.
If one or more `.link` files exist, whose names start the same as the `.asm`
file, then each of those files correspond to one test.
Each `.link` linker script **must** be accompanied by a `.out` file, and
RGBLINK's total output must match that file's contents when passed the
corresponding linker script.
#### Variant tests
These allow testing RGBLINK's `-d`, `-t`, and `-w` flags.
If one or more
<code>-<var>&lt;flag&gt;</var>.out</code> or <code>-no-<var>&lt;flag&gt;</var>.out</code>
files exist, then each of them corresponds to one test.
The object file will be linked with and without said flag, respectively; and in
each case, RGBLINK's total output must match the `.out` file's contents.
### RGBFIX
Each `.flags` file corresponds to one test.
Each one is a text file whose first line contains flags to pass to RGBFIX.
(There may be more lines, which will be ignored; they can serve as comments to
explain what the test is about.)
RGBFIX will be invoked on the `.bin` file if it exists, or else on
default-input.bin.
If no `.out` file exist, RGBFIX is not expected to output anything.
If one *does* exist, RGBFIX's output **must** match the `.out` file's contents.
If no `.err` file exists, RGBFIX is simply expected to be able to process the
file normally.
If one *does* exist, RGBFIX's return status is ignored, but its error output
**must** match the `.err` file's contents.
Additionally, if a `.gb` file exists, the output of RGBFIX must match the `.gb`.
### RGBGFX
There are three kinds of test.
#### Simple tests
Each `.png` file corresponds to one test.
RGBGFX will be invoked on the file.
If a `.flags` file exists, it will be used as part of the RGBGFX invocation
(<code>@<var>&lt;file&gt;</var>.flags</code>).
If `.out.1bpp`, `.out.2bpp`, `.out.pal`, `.out.tilemap`, `.out.attrmap`, or
`.out.palmap` files exist, RGBGFX will create the corresponding kind of output,
which must match the file's contents.
Multiple kinds of output may be tested for the same input.
If no `.err` file exists, RGBGFX is simply expected to be able to process the
file normally.
If one *does* exist, RGBGFX's return status is ignored, but its output **must**
match the `.err` file's contents.
#### Reverse tests
Each `.1bpp` or `.2bpp` file corresponds to one test.
RGBGFX will be invoked on the file with `-r 1` for reverse mode, then invoked on
the output without `-r 1`.
The round-trip output must match the input file's contents.
If a `.flags` file exists, it will be used as part of the RGBGFX invocation
(<code>@<var>&lt;file&gt;</var>.flags</code>).
#### Random seed tests
Each `seed*.bin` file corresponds to one test.
Each one is a binary RNG file which is passed to the `rgbgfx_test` program.
### External projects
Each `.cfg` file corresponds to one test.
Each one defines the parameters for a real external project that builds using RGBDS.
1. Ensure that the downstream project supports a `RGBDS` variable to build with
a non-system copy of RGBDS in some directory, i.e.
<code>make <var>&lt;target&gt;</var> RGBDS=<var>&lt;path/to/rgbds/&gt;</var></code>.
Only [GNU Make](https://www.gnu.org/software/make/) is currently supported.
2. Create the new `.cfg` file, following the existing ones.
If an external project does not support `make RGBDS=`, or otherwise fails to
build with current RGBDS, then you can edit the project to build correctly, and
create a patch with `git diff` to be committed as
<code>test/external/patches/<var>&lt;project&gt;</var>.patch</code>.
## Container images
The CI will
[take care](https://github.com/gbdev/rgbds/blob/master/.github/workflows/build-container.yml)
of updating the
[rgbds container](https://github.com/gbdev/rgbds/pkgs/container/rgbds) image
tagged `master`.
When a git tag is pushed, the image is also tagged with that tag.
The image can be built locally and pushed to the GitHub container registry by
manually running:
```bash
# e.g. to build and tag as 'master'
docker build . --tag ghcr.io/gbdev/rgbds:master
docker push ghcr.io/gbdev/rgbds:master
```
## Publishing a new release
Please refer to [`RELEASE.md`](/RELEASE.md).
## Closing remarks
Feel free to add yourself to `CREDITS.md`!
+48
View File
@@ -0,0 +1,48 @@
# Contributors to RGBDS
## Original author
- Carsten Elton Sørensen &lt;csoren@gmail.com&gt;
## Main contributors
- Justin Lloyd &lt;jlloyd@imf.la&gt;
- Vegard Nossum &lt;vegard.nossum@gmail.com&gt;
- Anthony J. Bentley &lt;anthony@anjbe.name&gt;
- stag019 &lt;stag019@gmail.com&gt;
- Antonio Niño Díaz &lt;antonio_nd@outlook.com&gt;
- Eldred "ISSOtm" Habert &lt;me@eldred.fr&gt;
- Sylvie "Rangi" Oukaour &lt;https://github.com/Rangi42&gt;
## Other contributors
- Ben Hetherington &lt;dev@ben-h.uk&gt;
- Björn Höhrmann &lt;bjoern@hoehrmann.de&gt;
- Christophe Staïesse &lt;chastai@skynet.be&gt;
- David Brotz &lt;dbrotz007@gmail.com&gt;
- Evie &lt;https://evie.gbdev.io&gt;
- James "JL2210" Larrowe &lt;https://github.com/JL2210&gt;
- Maja Kądziołka &lt;github@compilercrim.es&gt;
- The Musl C library &lt;https://musl.libc.org/&gt;
- obskyr &lt;powpowd@gmail.com&gt;
- The OpenBSD Project &lt;http://www.openbsd.org&gt;
- Quint Guvernator &lt;quint@guvernator.net&gt;
- Sanqui &lt;gsanky@gmail.com&gt;
- YamaArashi &lt;shadow962@live.com&gt;
- yenatch &lt;yenatch@gmail.com&gt;
- phs &lt;phil@philhsmith.com&gt;
- jidoc01 &lt;jidoc01@naver.com&gt;
[<img src="https://contrib.rocks/image?repo=gbdev/rgbds">](https://github.com/gbdev/rgbds/graphs/contributors)
Contributor image made with [contrib.rocks](https://contrib.rocks).
## Acknowledgements
RGBGFX generates palettes using algorithms found in the paper
["Algorithms for the Pagination Problem, a Bin Packing with Overlapping Items"](https://arxiv.org/abs/1605.00558)
([GitHub](https://github.com/pagination-problem/pagination), MIT license),
by Aristide Grange, Imed Kacem, and Sébastien Martin.
RGBGFX's color palette was taken from [SameBoy](https://sameboy.github.io), with
permission and help by [LIJI](https://github.com/LIJI32).
+84
View File
@@ -0,0 +1,84 @@
# Releasing
This describes for the maintainers of RGBDS how to publish a new release on
GitHub.
1. Update the following files, then commit and push.
You can use <code>git commit -m "Release <i>&lt;version&gt;</i>"</code> and `git push origin master`.
- [include/version.hpp](/include/version.hpp): set appropriate values for `PACKAGE_VERSION_MAJOR`,
`PACKAGE_VERSION_MINOR`, `PACKAGE_VERSION_PATCH`, and `PACKAGE_VERSION_RC`.
**Only** define `PACKAGE_VERSION_RC` if you are publishing a release candidate!
- [Dockerfile](/Dockerfile): update `ARG version`.
- [test/external/\*.cfg](/test/external): update test dependency commits
(preferably, use the latest available).
- [man/\*](/man/): update dates and authors.
2. Create a Git tag formatted as <code>v<i>&lt;MAJOR&gt;</i>.<i>&lt;MINOR&gt;</i>.<i>&lt;PATCH&gt;</i></code>,
or <code>v<i>&lt;MAJOR&gt;</i>.<i>&lt;MINOR&gt;</i>.<i>&lt;PATCH&gt;</i>-rc<i>&lt;RC&gt;</i></code>
for a release candidate. <code><i>MAJOR</i></code>, <code><i>MINOR</i></code>,
<code><i>PATCH</i></code>, and <code><i>RC</i></code> should match their values from
[include/version.hpp](/include/version.hpp). You can use <code>git tag <i>&lt;tag&gt;</i></code>.
3. Push the tag to GitHub. You can use <code>git push origin <i>&lt;tag&gt;</i></code>.
GitHub Actions will run the
[create-release-artifacts.yml](/.github/workflows/create-release-artifacts.yml)
workflow to detect the tag starting with "`v[0-9]`" and automatically do the following:
1. Build 32-bit and 64-bit RGBDS binaries for Windows with `cmake`.
2. Package the binaries into zip files.
3. Package the source code into a tar.gz file with `make dist`.
4. Create a draft GitHub release for the tag, attaching the three
packaged files. It will be a prerelease if the tag contains "`-rc`".
If an error occurred in the above steps, delete the tag and restart the
procedure. You can use <code>git push --delete origin <i>&lt;tag&gt;</i></code> and
<code>git tag --delete <i>&lt;tag&gt;</i></code>.
4. GitHub Actions will run the [create-release-docs.yml](/.github/workflows/create-release-docs.yml)
workflow to add the release documentation to [rgbds-www](https://github.com/gbdev/rgbds-www).
This is not done automatically for prereleases, since we do not normally publish documentation
for them. If you want to manually publish prerelease documentation, such as for an April Fools
joke prerelease,
1. Clone [rgbds-www](https://github.com/gbdev/rgbds-www). You can use
`git clone https://github.com/gbdev/rgbds-www.git`.
2. Make sure that you have installed `groff` and `mandoc`. You will
need `mandoc` 1.14.5 or later to support `-O toc`.
3. Inside of the `man` directory, run <code><i>&lt;path/to/rgbds-www&gt;</i>/maintainer/man_to_html.sh <i>&lt;tag&gt;</i> *</code> then <code><i>&lt;path/to/rgbds-www&gt;</i>/maintainer/new_release.sh <i>&lt;tag&gt;</i></code>.
This will render the RGBDS documentation as HTML and PDF and copy it to
`rgbds-www`.
If you do not have `groff` installed, you can change
`groff -Tpdf -mdoc -wall` to `mandoc -Tpdf -I os=Linux` in
[maintainer/man_to_html.sh](https://github.com/gbdev/rgbds-www/blob/master/maintainer/man_to_html.sh)
and it will suffice.
4. Commit and push the documentation. You can use <code>git commit -m
"Create RGBDS <i>&lt;tag&gt;</i> documentation"</code> and `git push origin master`
(within the `rgbds-www` directory, not RGBDS).
5. Write a changelog in the GitHub draft release.
6. Click the "Publish release" button to publish it!
7. Update the `release` branch. You can use `git push origin master:release`.
8. Update the following related projects.
1. [rgbds-www](https://github.com/gbdev/rgbds-www): update
[src/pages/versions.mdx](https://github.com/gbdev/rgbds-www/blob/master/src/pages/versions.mdx)
to list the new release.
2. [rgbds-live](https://github.com/gbdev/rgbds-live): update the `rgbds` submodule (and
[patches/rgbds.patch](https://github.com/gbdev/rgbds-live/blob/master/patches/rgbds.patch)
if necessary) to use the new release.
3. [rgbobj](https://github.com/gbdev/rgbobj) and [rgbds-obj](https://github.com/gbdev/rgbds-obj):
make sure that object files created by the latest RGBASM can be parsed and displayed.
If the object file revision has been updated, `rgbobj` will need a corresponding release.
-1670
View File
File diff suppressed because it is too large Load Diff
-36
View File
@@ -1,36 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>General Information</title>
<link rel="stylesheet" type="text/css" href="mandoc.css">
</head>
<body>
<h1>RGBDS — Rednex Game Boy Development System</h1>
<h2>Table of Contents</h2>
<ol>
<li>General information
<ul>
<li><a href="rgbds.7.html">RGBDS general information</a></li>
<li><a href="rgbds.5.html">RGBDS object file format</a></li>
</ul>
<li>Language description
<ul>
<li><a href="rgbasm.5.html">RGBASM language description</a></li>
<li><a href="rgblink.5.html">RGBLINK linkerscript language description</a></li>
<li><a href="gbz80.7.html">GBZ80 CPU instruction set description</a></li>
</ul>
<li>Command line usage
<ul>
<li><a href="rgbasm.1.html">RGBASM command-line usage</a></li>
<li><a href="rgblink.1.html">RGBLINK command-line usage</a></li>
<li><a href="rgbfix.1.html">RGBFIX command-line usage</a></li>
<li><a href="rgbgfx.1.html">RGBGFX command-line usage</a></li>
</ul>
</ol>
<h2 id="GitHub Repository">GitHub Repository:</h2>
<ul>
<li><a href="https://github.com/rednex/rgbds">https://github.com/rednex/rgbds</a></li>
</ul>
</body>
-347
View File
@@ -1,347 +0,0 @@
/* $Id: mandoc.css,v 1.45 2019/03/01 10:57:18 schwarze Exp $ */
/*
* Standard style sheet for mandoc(1) -Thtml and man.cgi(8).
*
* Written by Ingo Schwarze <[email protected]>.
* I place this file into the public domain.
* Permission to use, copy, modify, and distribute it for any purpose
* with or without fee is hereby granted, without any conditions.
*/
/* Global defaults. */
html { max-width: 65em; }
body { font-family: Helvetica,Arial,sans-serif; }
table { margin-top: 0em;
margin-bottom: 0em;
border-collapse: collapse; }
/* Some browsers set border-color in a browser style for tbody,
* but not for table, resulting in inconsistent border styling. */
tbody { border-color: inherit; }
tr { border-color: inherit; }
td { vertical-align: top;
padding-left: 0.2em;
padding-right: 0.2em;
border-color: inherit; }
ul, ol, dl { margin-top: 0em;
margin-bottom: 0em; }
li, dt { margin-top: 1em; }
.permalink { border-bottom: thin dotted;
color: inherit;
font: inherit;
text-decoration: inherit; }
* { clear: both }
/* Search form and search results. */
fieldset { border: thin solid silver;
border-radius: 1em;
text-align: center; }
input[name=expr] {
width: 25%; }
table.results { margin-top: 1em;
margin-left: 2em;
font-size: smaller; }
/* Header and footer lines. */
table.head { width: 100%;
border-bottom: 1px dotted #808080;
margin-bottom: 1em;
font-size: smaller; }
td.head-vol { text-align: center; }
td.head-rtitle {
text-align: right; }
table.foot { width: 100%;
border-top: 1px dotted #808080;
margin-top: 1em;
font-size: smaller; }
td.foot-os { text-align: right; }
/* Sections and paragraphs. */
.manual-text {
margin-left: 3.8em; }
.Nd { }
section.Sh { }
h1.Sh { margin-top: 1.2em;
margin-bottom: 0.6em;
margin-left: -3.2em;
font-size: 110%; }
section.Ss { }
h2.Ss { margin-top: 1.2em;
margin-bottom: 0.6em;
margin-left: -1.2em;
font-size: 105%; }
.Pp { margin: 0.6em 0em; }
.Sx { }
.Xr { }
/* Displays and lists. */
.Bd { }
.Bd-indent { margin-left: 3.8em; }
.Bl-bullet { list-style-type: disc;
padding-left: 1em; }
.Bl-bullet > li { }
.Bl-dash { list-style-type: none;
padding-left: 0em; }
.Bl-dash > li:before {
content: "\2014 "; }
.Bl-item { list-style-type: none;
padding-left: 0em; }
.Bl-item > li { }
.Bl-compact > li {
margin-top: 0em; }
.Bl-enum { padding-left: 2em; }
.Bl-enum > li { }
.Bl-compact > li {
margin-top: 0em; }
.Bl-diag { }
.Bl-diag > dt {
font-style: normal;
font-weight: bold; }
.Bl-diag > dd {
margin-left: 0em; }
.Bl-hang { }
.Bl-hang > dt { }
.Bl-hang > dd {
margin-left: 5.5em; }
.Bl-inset { }
.Bl-inset > dt { }
.Bl-inset > dd {
margin-left: 0em; }
.Bl-ohang { }
.Bl-ohang > dt { }
.Bl-ohang > dd {
margin-left: 0em; }
.Bl-tag { margin-top: 0.6em;
margin-left: 5.5em; }
.Bl-tag > dt {
float: left;
margin-top: 0em;
margin-left: -5.5em;
padding-right: 0.5em;
vertical-align: top; }
.Bl-tag > dd {
clear: right;
width: 100%;
margin-top: 0em;
margin-left: 0em;
margin-bottom: 0.6em;
vertical-align: top;
overflow: auto; }
.Bl-compact { margin-top: 0em; }
.Bl-compact > dd {
margin-bottom: 0em; }
.Bl-compact > dt {
margin-top: 0em; }
.Bl-column { }
.Bl-column > tbody > tr { }
.Bl-column > tbody > tr > td {
margin-top: 1em; }
.Bl-compact > tbody > tr > td {
margin-top: 0em; }
.Rs { font-style: normal;
font-weight: normal; }
.RsA { }
.RsB { font-style: italic;
font-weight: normal; }
.RsC { }
.RsD { }
.RsI { font-style: italic;
font-weight: normal; }
.RsJ { font-style: italic;
font-weight: normal; }
.RsN { }
.RsO { }
.RsP { }
.RsQ { }
.RsR { }
.RsT { text-decoration: underline; }
.RsU { }
.RsV { }
.eqn { }
.tbl td { vertical-align: middle; }
.HP { margin-left: 3.8em;
text-indent: -3.8em; }
/* Semantic markup for command line utilities. */
table.Nm { }
code.Nm { font-style: normal;
font-weight: bold;
font-family: inherit; }
.Fl { font-style: normal;
font-weight: bold;
font-family: inherit; }
.Cm { font-style: normal;
font-weight: bold;
font-family: inherit; }
.Ar { font-style: italic;
font-weight: normal; }
.Op { display: inline; }
.Ic { font-style: normal;
font-weight: bold;
font-family: inherit; }
.Ev { font-style: normal;
font-weight: normal;
font-family: monospace; }
.Pa { font-style: italic;
font-weight: normal; }
/* Semantic markup for function libraries. */
.Lb { }
code.In { font-style: normal;
font-weight: bold;
font-family: inherit; }
a.In { }
.Fd { font-style: normal;
font-weight: bold;
font-family: inherit; }
.Ft { font-style: italic;
font-weight: normal; }
.Fn { font-style: normal;
font-weight: bold;
font-family: inherit; }
.Fa { font-style: italic;
font-weight: normal; }
.Vt { font-style: italic;
font-weight: normal; }
.Va { font-style: italic;
font-weight: normal; }
.Dv { font-style: normal;
font-weight: normal;
font-family: monospace; }
.Er { font-style: normal;
font-weight: normal;
font-family: monospace; }
/* Various semantic markup. */
.An { }
.Lk { }
.Mt { }
.Cd { font-style: normal;
font-weight: bold;
font-family: inherit; }
.Ad { font-style: italic;
font-weight: normal; }
.Ms { font-style: normal;
font-weight: bold; }
.St { }
.Ux { }
/* Physical markup. */
.Bf { display: inline; }
.No { font-style: normal;
font-weight: normal; }
.Em { font-style: italic;
font-weight: normal; }
.Sy { font-style: normal;
font-weight: bold; }
.Li { font-style: normal;
font-weight: normal;
font-family: monospace; }
/* Tooltip support. */
h1.Sh, h2.Ss { position: relative; }
.An, .Ar, .Cd, .Cm, .Dv, .Em, .Er, .Ev, .Fa, .Fd, .Fl, .Fn, .Ft,
.Ic, code.In, .Lb, .Lk, .Ms, .Mt, .Nd, code.Nm, .Pa, .Rs,
.St, .Sx, .Sy, .Va, .Vt, .Xr {
display: inline-block;
position: relative; }
.An::before { content: "An"; }
.Ar::before { content: "Ar"; }
.Cd::before { content: "Cd"; }
.Cm::before { content: "Cm"; }
.Dv::before { content: "Dv"; }
.Em::before { content: "Em"; }
.Er::before { content: "Er"; }
.Ev::before { content: "Ev"; }
.Fa::before { content: "Fa"; }
.Fd::before { content: "Fd"; }
.Fl::before { content: "Fl"; }
.Fn::before { content: "Fn"; }
.Ft::before { content: "Ft"; }
.Ic::before { content: "Ic"; }
code.In::before { content: "In"; }
.Lb::before { content: "Lb"; }
.Lk::before { content: "Lk"; }
.Ms::before { content: "Ms"; }
.Mt::before { content: "Mt"; }
.Nd::before { content: "Nd"; }
code.Nm::before { content: "Nm"; }
.Pa::before { content: "Pa"; }
.Rs::before { content: "Rs"; }
h1.Sh::before { content: "Sh"; }
h2.Ss::before { content: "Ss"; }
.St::before { content: "St"; }
.Sx::before { content: "Sx"; }
.Sy::before { content: "Sy"; }
.Va::before { content: "Va"; }
.Vt::before { content: "Vt"; }
.Xr::before { content: "Xr"; }
.An::before, .Ar::before, .Cd::before, .Cm::before,
.Dv::before, .Em::before, .Er::before, .Ev::before,
.Fa::before, .Fd::before, .Fl::before, .Fn::before, .Ft::before,
.Ic::before, code.In::before, .Lb::before, .Lk::before,
.Ms::before, .Mt::before, .Nd::before, code.Nm::before,
.Pa::before, .Rs::before,
h1.Sh::before, h2.Ss::before, .St::before, .Sx::before, .Sy::before,
.Va::before, .Vt::before, .Xr::before {
opacity: 0;
transition: .15s ease opacity;
pointer-events: none;
position: absolute;
bottom: 100%;
box-shadow: 0 0 .35em #000;
padding: .15em .25em;
white-space: nowrap;
font-family: Helvetica,Arial,sans-serif;
font-style: normal;
font-weight: bold;
color: black;
background: #fff; }
.An:hover::before, .Ar:hover::before, .Cd:hover::before, .Cm:hover::before,
.Dv:hover::before, .Em:hover::before, .Er:hover::before, .Ev:hover::before,
.Fa:hover::before, .Fd:hover::before, .Fl:hover::before, .Fn:hover::before,
.Ft:hover::before, .Ic:hover::before, code.In:hover::before,
.Lb:hover::before, .Lk:hover::before, .Ms:hover::before, .Mt:hover::before,
.Nd:hover::before, code.Nm:hover::before, .Pa:hover::before,
.Rs:hover::before, h1.Sh:hover::before, h2.Ss:hover::before, .St:hover::before,
.Sx:hover::before, .Sy:hover::before, .Va:hover::before, .Vt:hover::before,
.Xr:hover::before {
opacity: 1;
pointer-events: inherit; }
/* Overrides to avoid excessive margins on small devices. */
@media (max-width: 37.5em) {
.manual-text {
margin-left: 0.5em; }
h1.Sh, h2.Ss { margin-left: 0em; }
.Bd-indent { margin-left: 2em; }
.Bl-hang > dd {
margin-left: 2em; }
.Bl-tag { margin-left: 2em; }
.Bl-tag > dt {
margin-left: -2em; }
.HP { margin-left: 2em;
text-indent: -2em; }
}
-295
View File
@@ -1,295 +0,0 @@
<!DOCTYPE html>
<html>
<!-- This is an automatically generated file. Do not edit.
This file is part of RGBDS.
Copyright (c) 2010-2019, Anthony J. Bentley and RGBDS contributors.
SPDX-License-Identifier: MIT
-->
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta charset="utf-8"/>
<link rel="stylesheet" href="mandoc.css" type="text/css" media="all"/>
<link rel="stylesheet" href="rgbds.css" type="text/css" media="all"/>
<title>RGBASM(1)</title>
</head>
<body>
<table class="head">
<tr>
<td class="head-ltitle">RGBASM(1)</td>
<td class="head-vol">General Commands Manual</td>
<td class="head-rtitle">RGBASM(1)</td>
</tr>
</table>
<div class="manual-text">
<section class="Sh">
<h1 class="Sh" id="NAME"><a class="permalink" href="#NAME">NAME</a></h1>
<code class="Nm">rgbasm</code> &#x2014;
<span class="Nd">Game Boy assembler</span>
</section>
<section class="Sh">
<h1 class="Sh" id="SYNOPSIS"><a class="permalink" href="#SYNOPSIS">SYNOPSIS</a></h1>
<table class="Nm">
<tr>
<td><code class="Nm">rgbasm</code></td>
<td>[<code class="Fl"><a href="#E">-E</a><a href="#h">h</a><a href="#L">L</a><a href="#V">V</a><a href="#v">v</a><a href="#w">w</a></code>] [<code class="Fl"><a href="#b">-b</a></code>
<var class="Ar">chars</var>] [<code class="Fl"><a href="#D">-D</a></code>
<var class="Ar">name</var>[=<var class="Ar">value</var>]]
[<code class="Fl"><a href="#g">-g</a></code> <var class="Ar">chars</var>]
[<code class="Fl"><a href="#i">-i</a></code> <var class="Ar">path</var>]
[<code class="Fl"><a href="#M">-M</a></code> <var class="Ar">depend_file</var>]
[<code class="Fl"><a href="#M">-M</a><a href="#G">G</a></code>] [<code class="Fl"><a href="#M">-M</a><a href="#P">P</a></code>]
[<code class="Fl"><a href="#M">-M</a><a href="#T">T</a></code> <var class="Ar">target_file</var>]
[<code class="Fl"><a href="#M">-M</a><a href="#Q">Q</a></code> <var class="Ar">target_file</var>]
[<code class="Fl"><a href="#o">-o</a></code> <var class="Ar">out_file</var>]
[<code class="Fl"><a href="#p">-p</a></code> <var class="Ar">pad_value</var>]
[<code class="Fl"><a href="#r">-r</a></code> <var class="Ar">recursion_depth</var>]
[<code class="Fl"><a href="#W">-W</a></code> <var class="Ar">warning</var>]
<var class="Ar">file ...</var></td>
</tr>
</table>
</section>
<section class="Sh">
<h1 class="Sh" id="DESCRIPTION"><a class="permalink" href="#DESCRIPTION">DESCRIPTION</a></h1>
The <code class="Nm">rgbasm</code> program creates an RGB object file from an
assembly source file. The input <var class="Ar">file</var> can be a file path,
or <code class="Cm">-</code> denoting <code class="Cm">stdin</code>.
<p class="Pp">Note that options can be abbreviated as long as the abbreviation
is unambiguous: <code class="Fl">--verb</code> is
<code class="Fl">--verbose</code>, but
<code class="Fl">--ver</code> is invalid because it
could also be <code class="Fl">--version</code>. The
arguments are as follows:</p>
<dl class="Bl-tag">
<dt><a class="permalink" href="#b"><code class="Fl" id="b">-b</code></a>
<var class="Ar">chars</var>,
<code class="Fl">--binary-digits</code>
<var class="Ar">chars</var></dt>
<dd>Change the two characters used for binary constants. The defaults are
01.</dd>
<dt><a class="permalink" href="#D"><code class="Fl" id="D">-D</code></a>
<var class="Ar">name</var>[=<var class="Ar">value</var>],
<code class="Fl">-</code> <code class="Fl">-define</code>
<var class="Ar">name</var>[=<var class="Ar">value</var>]</dt>
<dd>Add a string symbol to the compiled source code. This is equivalent to
&#x2018;<code class="Li"><var class="Ar">name</var> <code class="Ic">EQUS
&quot;</code><var class="Ar">value</var>&quot;</code>&#x2019; in code, or
&#x2018;<code class="Li"><var class="Ar">name</var> <code class="Ic">EQUS
&quot;1&quot;</code></code>&#x2019; if <var class="Ar">value</var> is not
specified.</dd>
<dt><a class="permalink" href="#E"><code class="Fl" id="E">-E</code></a>,
<code class="Fl">--export-all</code></dt>
<dd>Export all labels, including unreferenced and local labels.</dd>
<dt><a class="permalink" href="#g"><code class="Fl" id="g">-g</code></a>
<var class="Ar">chars</var>,
<code class="Fl">--gfx-chars</code>
<var class="Ar">chars</var></dt>
<dd>Change the four characters used for gfx constants. The defaults are
0123.</dd>
<dt><a class="permalink" href="#h"><code class="Fl" id="h">-h</code></a>,
<code class="Fl">--halt-without-nop</code></dt>
<dd>By default, <code class="Nm">rgbasm</code> inserts a
<code class="Ic">nop</code> instruction immediately after any
<code class="Ic">halt</code> instruction. The <code class="Fl">-h</code>
option disables this behavior.</dd>
<dt><a class="permalink" href="#i"><code class="Fl" id="i">-i</code></a>
<var class="Ar">path</var>,
<code class="Fl">--include</code>
<var class="Ar">path</var></dt>
<dd>Add an include path.</dd>
<dt><a class="permalink" href="#L"><code class="Fl" id="L">-L</code></a>,
<code class="Fl">--preserve-ld</code></dt>
<dd>Disable the optimization that turns loads of the form <code class="Ic">LD
[$FF00+n8],A</code> into the opcode <code class="Ic">LDH
[$FF00+n8],A</code> in order to have full control of the result in the
final ROM.</dd>
<dt><a class="permalink" href="#M"><code class="Fl" id="M">-M</code></a>
<var class="Ar">depend_file</var>,
<code class="Fl">--dependfile</code>
<var class="Ar">depend_file</var></dt>
<dd>Print <a class="Xr">make(1)</a> dependencies to
<var class="Ar">depend_file</var>.</dd>
<dt><a class="permalink" href="#MG"><code class="Fl" id="MG">-MG</code></a></dt>
<dd>To be used in conjunction with <code class="Fl">-M</code>. This makes
<code class="Nm">rgbasm</code> assume that missing files are
auto-generated: when <code class="Ic">INCLUDE</code> or
<code class="Ic">INCBIN</code> is attempted on a non-existent file, it is
added as a dependency, then <code class="Nm">rgbasm</code> exits normally
instead of erroring out. This feature is used in automatic updating of
makefiles.</dd>
<dt><a class="permalink" href="#MP"><code class="Fl" id="MP">-MP</code></a></dt>
<dd>When enabled, this causes a phony target to be added for each dependency
other than the main file. This prevents <a class="Xr">make(1)</a> from
erroring out when dependency files are deleted.</dd>
<dt><a class="permalink" href="#MT"><code class="Fl" id="MT">-MT</code></a>
<var class="Ar">target_file</var></dt>
<dd>Add a target to the rules emitted by <code class="Fl">-M</code>. The exact
string provided will be written, including spaces and special characters.
<div class="Bd Bd-indent"><code class="Li"><code class="Fl">-MT</code>
<code class="Fl">-fileA</code> <code class="Fl">-MT</code>
<code class="Fl">-fileB</code></code></div>
is equivalent to
<div class="Bd Bd-indent"><code class="Li"><code class="Fl">-MT</code>
<code class="Fl">-'fileA</code>
<code class="Fl">-fileB'</code>.</code></div>
If neither this nor <code class="Fl">-MQ</code> is specified, the output
file name is used.</dd>
<dt><a class="permalink" href="#MQ"><code class="Fl" id="MQ">-MQ</code></a>
<var class="Ar">target_file</var></dt>
<dd>Same as <code class="Fl">-MT</code>, but additionally escapes any special
<a class="Xr">make(1)</a> characters, essentially &#x2018;$&#x2019;.</dd>
<dt><a class="permalink" href="#o"><code class="Fl" id="o">-o</code></a>
<var class="Ar">out_file</var>,
<code class="Fl">--output</code>
<var class="Ar">out_file</var></dt>
<dd>Write an object file to the given filename.</dd>
<dt><a class="permalink" href="#p"><code class="Fl" id="p">-p</code></a>
<var class="Ar">pad_value</var>,
<code class="Fl">--pad-value</code>
<var class="Ar">pad_value</var></dt>
<dd>When padding an image, pad with this value. The default is 0x00.</dd>
<dt><a class="permalink" href="#r"><code class="Fl" id="r">-r</code></a>
<var class="Ar">recursion_depth</var>,
<code class="Fl">--recursion-depth</code>
<var class="Ar">recursion_depth</var></dt>
<dd>Specifies the recursion depth at which RGBASM will assume being in an
infinite loop.</dd>
<dt><a class="permalink" href="#V"><code class="Fl" id="V">-V</code></a>,
<code class="Fl">--version</code></dt>
<dd>Print the version of the program and exit.</dd>
<dt><a class="permalink" href="#v"><code class="Fl" id="v">-v</code></a>,
<code class="Fl">--verbose</code></dt>
<dd>Be verbose.</dd>
<dt><a class="permalink" href="#W"><code class="Fl" id="W">-W</code></a>
<var class="Ar">warning</var>,
<code class="Fl">--warning</code>
<var class="Ar">warning</var></dt>
<dd>Set warning flag <var class="Ar">warning</var>. A warning message will be
printed if <var class="Ar">warning</var> is an unknown warning flag. See
the <a class="Sx" href="#DIAGNOSTICS">DIAGNOSTICS</a> section for a list
of warnings.</dd>
<dt><a class="permalink" href="#w"><code class="Fl" id="w">-w</code></a></dt>
<dd>Disable all warning output, even when turned into errors.</dd>
</dl>
</section>
<section class="Sh">
<h1 class="Sh" id="DIAGNOSTICS"><a class="permalink" href="#DIAGNOSTICS">DIAGNOSTICS</a></h1>
Warnings are diagnostic messages that indicate possibly erroneous behavior that
does not necessarily compromise the assembling process. The following options
alter the way warnings are processed.
<dl class="Bl-tag">
<dt><a class="permalink" href="#Werror"><code class="Fl" id="Werror">-Werror</code></a></dt>
<dd>Make all warnings into errors.</dd>
<dt><a class="permalink" href="#Werror="><code class="Fl" id="Werror=">-Werror=</code></a></dt>
<dd>Make the specified warning into an error. A warning's name is appended
(example: <code class="Fl">-Werror=obsolete</code>), and this warning is
implicitly enabled and turned into an error. This is an error if used with
a meta warning, such as <code class="Fl">-Werror=all</code>.</dd>
</dl>
<p class="Pp">The following warnings are &#x201C;meta&#x201D; warnings, that
enable a collection of other warnings. If a specific warning is toggled via
a meta flag and a specific one, the more specific one takes priority. The
position on the command-line acts as a tie breaker, the last one taking
effect.</p>
<dl class="Bl-tag">
<dt><a class="permalink" href="#Wall"><code class="Fl" id="Wall">-Wall</code></a></dt>
<dd>This enables warnings that are likely to indicate an error or undesired
behavior, and that can easily be fixed.</dd>
<dt><a class="permalink" href="#Wextra"><code class="Fl" id="Wextra">-Wextra</code></a></dt>
<dd>This enables extra warnings that are less likely to pose a problem, but
that may still be wanted.</dd>
<dt><a class="permalink" href="#Weverything"><code class="Fl" id="Weverything">-Weverything</code></a></dt>
<dd>Enables literally every warning.</dd>
</dl>
<p class="Pp">The following warnings are actual warning flags; with each
description, the corresponding warning flag is included. Note that each of
these flag also has a negation (for example,
<code class="Fl">-Wempty-entry</code> enables the warning that
<code class="Fl">-Wno-empty-entry</code> disables). Only the non-default
flag is listed here. Ignoring the &#x201C;no-&#x201D; prefix, entries are
listed alphabetically.</p>
<dl class="Bl-tag">
<dt><a class="permalink" href="#Wno-assert"><code class="Fl" id="Wno-assert">-Wno-assert</code></a></dt>
<dd>Warns when <code class="Ic">WARN</code><span class="No">-type</span>
assertions fail. (See &#x201C;Aborting the assembly process&#x201D; in
<a class="Xr" href="rgbasm.5.html">rgbasm(5)</a> for <code class="Ic">ASSERT</code>).</dd>
<dt><a class="permalink" href="#Wbuiltin-args"><code class="Fl" id="Wbuiltin-args">-Wbuiltin-args</code></a></dt>
<dd>Warn about incorrect arguments to built-in functions, such as
<code class="Fn">STRSUB</code>() with indexes outside of the string's
bounds. This warning is enabled by <code class="Fl">-Wall</code>.</dd>
<dt><a class="permalink" href="#Wdiv"><code class="Fl" id="Wdiv">-Wdiv</code></a></dt>
<dd>Warn when dividing the smallest negative integer by -1, which yields
itself due to integer overflow.</dd>
<dt><a class="permalink" href="#Wempty-entry"><code class="Fl" id="Wempty-entry">-Wempty-entry</code></a></dt>
<dd>Warn when an empty entry is encountered in a <code class="Ic">db</code>,
<code class="Ic">dw</code>, <code class="Ic">dl</code> list. This warning
is enabled by <code class="Fl">-Wextra</code>.</dd>
<dt><a class="permalink" href="#Wlarge-constant"><code class="Fl" id="Wlarge-constant">-Wlarge-constant</code></a></dt>
<dd>Warn when a constant too large to fit in a signed 32-bit integer is
encountered. This warning is enabled by
<code class="Fl">-Wall</code>.</dd>
<dt><a class="permalink" href="#Wlong-string"><code class="Fl" id="Wlong-string">-Wlong-string</code></a></dt>
<dd>Warn when a string too long to fit in internal buffers is encountered.
This warning is enabled by <code class="Fl">-Wall</code>.</dd>
<dt><a class="permalink" href="#Wno-obsolete"><code class="Fl" id="Wno-obsolete">-Wno-obsolete</code></a></dt>
<dd>Warn when obsolete constructs such as the <code class="Ic">jp [hl]</code>
instruction or <code class="Ic">HOME</code> section type are
encountered.</dd>
<dt><a class="permalink" href="#Wshift"><code class="Fl" id="Wshift">-Wshift</code></a></dt>
<dd>Warn when shifting right a negative value. Use a division by 2^N
instead.</dd>
<dt><a class="permalink" href="#Wshift-amount"><code class="Fl" id="Wshift-amount">-Wshift-amount</code></a></dt>
<dd>Warn when a shift's operand is negative or greater than 32.</dd>
<dt><a class="permalink" href="#Wno-truncation"><code class="Fl" id="Wno-truncation">-Wno-truncation</code></a></dt>
<dd>Warn when an implicit truncation (for example, <code class="Ic">db</code>)
loses some bits.</dd>
<dt><a class="permalink" href="#Wno-user"><code class="Fl" id="Wno-user">-Wno-user</code></a></dt>
<dd>Warn when the <code class="Ic">WARN</code> built-in is executed. (See
&#x201C;Aborting the assembly process&#x201D; in
<a class="Xr" href="rgbasm.5.html">rgbasm(5)</a> for <code class="Ic">WARN</code>).</dd>
</dl>
</section>
<section class="Sh">
<h1 class="Sh" id="EXAMPLES"><a class="permalink" href="#EXAMPLES">EXAMPLES</a></h1>
You can assemble a source file in two ways.
<p class="Pp">Straightforward way:</p>
<div class="Bd Bd-indent"><code class="Li">$ rgbasm -o bar.o
foo.asm</code></div>
<p class="Pp">Pipes way:</p>
<div class="Bd Bd-indent"><code class="Li">$ cat foo.asm | rgbasm -o bar.o
-</code></div>
<div class="Bd Bd-indent"><code class="Li">$ rgbasm -o bar.o - &lt;
foo.asm</code></div>
<p class="Pp">The resulting object file is not yet a usable ROM image&#x2014;it
must first be run through <a class="Xr" href="rgblink.1.html">rgblink(1)</a> and then
<a class="Xr" href="rgbfix.1.html">rgbfix(1)</a>.</p>
</section>
<section class="Sh">
<h1 class="Sh" id="BUGS"><a class="permalink" href="#BUGS">BUGS</a></h1>
Please report bugs on
<a class="Lk" href="https://github.com/rednex/rgbds/issues">GitHub</a>.
</section>
<section class="Sh">
<h1 class="Sh" id="SEE_ALSO"><a class="permalink" href="#SEE_ALSO">SEE
ALSO</a></h1>
<a class="Xr" href="rgbasm.5.html">rgbasm(5)</a>, <a class="Xr" href="rgbfix.1.html">rgbfix(1)</a>,
<a class="Xr" href="rgblink.1.html">rgblink(1)</a>, <a class="Xr" href="rgbds.5.html">rgbds(5)</a>,
<a class="Xr" href="rgbds.7.html">rgbds(7)</a>, <a class="Xr" href="gbz80.7.html">gbz80(7)</a>
</section>
<section class="Sh">
<h1 class="Sh" id="HISTORY"><a class="permalink" href="#HISTORY">HISTORY</a></h1>
<code class="Nm">rgbasm</code> was originally written by Carsten S&#x00F8;rensen
as part of the ASMotor package, and was later packaged in RGBDS by Justin
Lloyd. It is now maintained by a number of contributors at
<a class="Lk" href="https://github.com/rednex/rgbds">https://github.com/rednex/rgbds</a>.
</section>
</div>
<table class="foot">
<tr>
<td class="foot-date">July 8, 2019</td>
<td class="foot-os">General</td>
</tr>
</table>
</body>
</html>
-1751
View File
File diff suppressed because it is too large Load Diff
-363
View File
@@ -1,363 +0,0 @@
<!DOCTYPE html>
<html>
<!-- This is an automatically generated file. Do not edit.
This file is part of RGBDS.
Copyright (c) 2017-2018, Antonio Nino Diaz and RGBDS contributors.
SPDX-License-Identifier: MIT
-->
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta charset="utf-8"/>
<link rel="stylesheet" href="mandoc.css" type="text/css" media="all"/>
<link rel="stylesheet" href="rgbds.css" type="text/css" media="all"/>
<title>RGBDS(5)</title>
</head>
<body>
<table class="head">
<tr>
<td class="head-ltitle">RGBDS(5)</td>
<td class="head-vol">File Formats Manual</td>
<td class="head-rtitle">RGBDS(5)</td>
</tr>
</table>
<div class="manual-text">
<section class="Sh">
<h1 class="Sh" id="NAME"><a class="permalink" href="#NAME">NAME</a></h1>
<code class="Nm">rgbds</code> &#x2014;
<span class="Nd">object file format documentation</span>
</section>
<section class="Sh">
<h1 class="Sh" id="DESCRIPTION"><a class="permalink" href="#DESCRIPTION">DESCRIPTION</a></h1>
This is the description of the object files used by <a class="Xr" href="rgbasm.1.html">rgbasm(1)</a>
and <a class="Xr" href="rgblink.1.html">rgblink(1)</a>. <i class="Em">Please note that the
specifications may change.</i> This toolchain is in development and new
features may require adding more information to the current format, or
modifying some fields, which would break compatibility with older versions.
</section>
<section class="Sh">
<h1 class="Sh" id="FILE_STRUCTURE"><a class="permalink" href="#FILE_STRUCTURE">FILE
STRUCTURE</a></h1>
The following types are used:
<p class="Pp"><var class="Ar">LONG</var> is a 32&#x2010;bit integer stored in
little&#x2010;endian format. <var class="Ar">BYTE</var> is an 8&#x2010;bit
integer. <var class="Ar">STRING</var> is a 0&#x2010;terminated string of
<var class="Ar">BYTE</var>.</p>
<div class="Bd Pp">
<pre>
; Header
BYTE ID[4] ; &quot;RGB9&quot;
LONG RevisionNumber ; The format's revision number this file uses
LONG NumberOfSymbols ; The number of symbols used in this file
LONG NumberOfSections ; The number of sections used in this file
; Symbols
REPT NumberOfSymbols ; Number of symbols defined in this object file.
STRING Name ; The name of this symbol. Local symbols are stored
; as &quot;Scope.Symbol&quot;.
BYTE Type ; 0 = LOCAL symbol only used in this file.
; 1 = IMPORT this symbol from elsewhere
; 2 = EXPORT this symbol to other objects.
; Bit 7 is independent from the above value, and
; encodes whether the section is unionized
IF (Type &amp; 0x7F) != 1 ; If symbol is defined in this object file.
STRING FileName ; File where the symbol is defined.
LONG LineNum ; Line number in the file where the symbol is defined.
LONG SectionID ; The section number (of this object file) in which
; this symbol is defined. If it doesn't belong to any
; specific section (like a constant), this field has
; the value -1.
LONG Value ; The symbols value. It's the offset into that
; symbol's section.
ENDC
ENDR
; Sections
REPT NumberOfSections
STRING Name ; Name of the section
LONG Size ; Size in bytes of this section
BYTE Type ; 0 = WRAM0
; 1 = VRAM
; 2 = ROMX
; 3 = ROM0
; 4 = HRAM
; 5 = WRAMX
; 6 = SRAM
; 7 = OAM
LONG Org ; Address to fix this section at. -1 if the linker should
; decide (floating address).
LONG Bank ; Bank to load this section into. -1 if the linker should
; decide (floating bank). This field is only valid for ROMX,
; VRAM, WRAMX and SRAM sections.
BYTE Align ; Alignment of this section, as N bits. 0 when not specified.
LONG Ofs ; Offset relative to the alignment specified above.
; Must be below 1 &lt;&lt; Align.
IF (Type == ROMX) || (Type == ROM0) ; Sections that can contain data.
BYTE Data[Size] ; Raw data of the section.
LONG NumberOfPatches ; Number of patches to apply.
REPT NumberOfPatches
STRING SourceFile ; Name of the source file (for printing error
; messages).
LONG Offset ; Offset into the section where patch should
; be applied (in bytes).
LONG PCSectionID ; Index within the file of the section in which
; PC is located.
; This is usually the same section that the
; patch should be applied into, except e.g.
; with LOAD blocks.
LONG PCOffset ; PC's offset into the above section.
; Used because the section may be floating, so
; PC's value is not known to RGBASM.
BYTE Type ; 0 = BYTE patch.
; 1 = little endian WORD patch.
; 2 = little endian LONG patch.
; 3 = JR offset value BYTE patch.
LONG RPNSize ; Size of the buffer with the RPN.
; expression.
BYTE RPN[RPNSize] ; RPN expression. Definition below.
ENDR
ENDC
ENDR
; Assertions
LONG NumberOfAssertions
REPT NumberOfAssertions
STRING SourceFile ; Name of the source file (for printing the failure).
LONG Offset ; Offset into the section where the assertion is located.
LONG SectionID ; Index within the file of the section in which PC is
; located, or -1 if defined outside a section.
LONG PCOffset ; PC's offset into the above section.
; Used because the section may be floating, so PC's value
; is not known to RGBASM.
BYTE Type ; 0 = Prints the message but allows linking to continue
; 1 = Prints the message and evaluates other assertions,
; but linking fails afterwards
; 2 = Prints the message and immediately fails linking
LONG RPNSize ; Size of the RPN expression's buffer.
BYTE RPN[RPNSize] ; RPN expression, same as patches. Assert fails if == 0.
STRING Message ; A message displayed when the assert fails. If set to
; the empty string, a generic message is printed instead.
ENDR
</pre>
</div>
<section class="Ss">
<h2 class="Ss" id="RPN_DATA"><a class="permalink" href="#RPN_DATA">RPN
DATA</a></h2>
Expressions in the object file are stored as RPN. This is an expression of the
form &#x201C;2 5 +&#x201D;. This will first push the value &#x201C;2&#x201D;
to the stack, then &#x201C;5&#x201D;. The &#x201C;+&#x201D; operator pops two
arguments from the stack, adds them, and then pushes the result on the stack,
effectively replacing the two top arguments with their sum. In the RGB format,
RPN expressions are stored as <var class="Ar">BYTE</var>s with some bytes
being special prefixes for integers and symbols.
<table class="Bl-column Bd-indent">
<tr>
<th>Value</th>
<th>Meaning</th>
</tr>
<tr>
<td><a class="permalink" href="#$00"><code class="Li" id="$00">$00</code></a></td>
<td><a class="permalink" href="#+_operator"><code class="Li" id="+_operator">+
operator</code></a></td>
</tr>
<tr>
<td><a class="permalink" href="#$01"><code class="Li" id="$01">$01</code></a></td>
<td><a class="permalink" href="#-_operator"><code class="Li" id="-_operator">-
operator</code></a></td>
</tr>
<tr>
<td><a class="permalink" href="#$02"><code class="Li" id="$02">$02</code></a></td>
<td><a class="permalink" href="#*_operator"><code class="Li" id="*_operator">*
operator</code></a></td>
</tr>
<tr>
<td><a class="permalink" href="#$03"><code class="Li" id="$03">$03</code></a></td>
<td><a class="permalink" href="#/_operator"><code class="Li" id="/_operator">/
operator</code></a></td>
</tr>
<tr>
<td><a class="permalink" href="#$04"><code class="Li" id="$04">$04</code></a></td>
<td><a class="permalink" href="#__operator"><code class="Li" id="__operator">%
operator</code></a></td>
</tr>
<tr>
<td><a class="permalink" href="#$05"><code class="Li" id="$05">$05</code></a></td>
<td><a class="permalink" href="#unary_-"><code class="Li" id="unary_-">unary
-</code></a></td>
</tr>
<tr>
<td><a class="permalink" href="#$10"><code class="Li" id="$10">$10</code></a></td>
<td>|
<a class="permalink" href="#operator"><code class="Li" id="operator">operator</code></a></td>
</tr>
<tr>
<td><a class="permalink" href="#$11"><code class="Li" id="$11">$11</code></a></td>
<td><a class="permalink" href="#&amp;_operator"><code class="Li" id="&amp;_operator">&amp;
operator</code></a></td>
</tr>
<tr>
<td><a class="permalink" href="#$12"><code class="Li" id="$12">$12</code></a></td>
<td><a class="permalink" href="#__operator_2"><code class="Li" id="__operator_2">^
operator</code></a></td>
</tr>
<tr>
<td><a class="permalink" href="#$13"><code class="Li" id="$13">$13</code></a></td>
<td><a class="permalink" href="#unary_~"><code class="Li" id="unary_~">unary
~</code></a></td>
</tr>
<tr>
<td><a class="permalink" href="#$21"><code class="Li" id="$21">$21</code></a></td>
<td><a class="permalink" href="#&amp;&amp;_comparison"><code class="Li" id="&amp;&amp;_comparison">&amp;&amp;
comparison</code></a></td>
</tr>
<tr>
<td><a class="permalink" href="#$22"><code class="Li" id="$22">$22</code></a></td>
<td><a class="permalink" href="#___comparison"><code class="Li" id="___comparison">||
comparison</code></a></td>
</tr>
<tr>
<td><a class="permalink" href="#$23"><code class="Li" id="$23">$23</code></a></td>
<td><a class="permalink" href="#unary__!"><code class="Li" id="unary__!">unary&#x00A0;!</code></a></td>
</tr>
<tr>
<td><a class="permalink" href="#$30"><code class="Li" id="$30">$30</code></a></td>
<td><a class="permalink" href="#==_comparison"><code class="Li" id="==_comparison">==
comparison</code></a></td>
</tr>
<tr>
<td><a class="permalink" href="#$31"><code class="Li" id="$31">$31</code></a></td>
<td><a class="permalink" href="#!=_comparison"><code class="Li" id="!=_comparison">!=
comparison</code></a></td>
</tr>
<tr>
<td><a class="permalink" href="#$32"><code class="Li" id="$32">$32</code></a></td>
<td><a class="permalink" href="#__comparison"><code class="Li" id="__comparison">&gt;
comparison</code></a></td>
</tr>
<tr>
<td><a class="permalink" href="#$33"><code class="Li" id="$33">$33</code></a></td>
<td><a class="permalink" href="#__comparison_2"><code class="Li" id="__comparison_2">&lt;
comparison</code></a></td>
</tr>
<tr>
<td><a class="permalink" href="#$34"><code class="Li" id="$34">$34</code></a></td>
<td><a class="permalink" href="#_=_comparison"><code class="Li" id="_=_comparison">&gt;=
comparison</code></a></td>
</tr>
<tr>
<td><a class="permalink" href="#$35"><code class="Li" id="$35">$35</code></a></td>
<td><a class="permalink" href="#_=_comparison_2"><code class="Li" id="_=_comparison_2">&lt;=
comparison</code></a></td>
</tr>
<tr>
<td><a class="permalink" href="#$40"><code class="Li" id="$40">$40</code></a></td>
<td><a class="permalink" href="#___operator"><code class="Li" id="___operator">&lt;&lt;
operator</code></a></td>
</tr>
<tr>
<td><a class="permalink" href="#$41"><code class="Li" id="$41">$41</code></a></td>
<td><a class="permalink" href="#___operator_2"><code class="Li" id="___operator_2">&gt;&gt;
operator</code></a></td>
</tr>
<tr>
<td><a class="permalink" href="#$50"><code class="Li" id="$50">$50</code></a></td>
<td><a class="permalink" href="#BANK(symbol)"><code class="Li" id="BANK(symbol)">BANK(symbol)</code></a>,
a <var class="Ar">LONG</var> Symbol ID follows.</td>
</tr>
<tr>
<td><a class="permalink" href="#$51"><code class="Li" id="$51">$51</code></a></td>
<td><a class="permalink" href="#BANK(section_name)"><code class="Li" id="BANK(section_name)">BANK(section_name)</code></a>,
a null-terminated string follows.</td>
</tr>
<tr>
<td><a class="permalink" href="#$52"><code class="Li" id="$52">$52</code></a></td>
<td><a class="permalink" href="#Current_BANK()"><code class="Li" id="Current_BANK()">Current
BANK()</code></a></td>
</tr>
<tr>
<td><a class="permalink" href="#$60"><code class="Li" id="$60">$60</code></a></td>
<td><a class="permalink" href="#HRAMCheck"><code class="Li" id="HRAMCheck">HRAMCheck</code></a>.
Checks if the value is in HRAM, ANDs it with 0xFF.</td>
</tr>
<tr>
<td><a class="permalink" href="#$61"><code class="Li" id="$61">$61</code></a></td>
<td><a class="permalink" href="#RSTCheck"><code class="Li" id="RSTCheck">RSTCheck</code></a>.
Checks if the value is a RST vector, ORs it with 0xC7.</td>
</tr>
<tr>
<td><a class="permalink" href="#$80"><code class="Li" id="$80">$80</code></a></td>
<td><var class="Ar">LONG</var> integer follows.</td>
</tr>
<tr>
<td><a class="permalink" href="#$81"><code class="Li" id="$81">$81</code></a></td>
<td><var class="Ar">LONG</var> symbol ID follows.</td>
</tr>
</table>
</section>
</section>
<section class="Sh">
<h1 class="Sh" id="SEE_ALSO"><a class="permalink" href="#SEE_ALSO">SEE
ALSO</a></h1>
<a class="Xr" href="rgbasm.1.html">rgbasm(1)</a>, <a class="Xr" href="rgblink.1.html">rgblink(1)</a>,
<a class="Xr" href="rgbds.7.html">rgbds(7)</a>, <a class="Xr" href="gbz80.7.html">gbz80(7)</a>
</section>
<section class="Sh">
<h1 class="Sh" id="HISTORY"><a class="permalink" href="#HISTORY">HISTORY</a></h1>
<code class="Nm">rgbds</code> was originally written by Carsten S&#x00F8;rensen
as part of the ASMotor package, and was later packaged in RGBDS by Justin
Lloyd. It is now maintained by a number of contributors at
<a class="Lk" href="https://github.com/rednex/rgbds">https://github.com/rednex/rgbds</a>.
</section>
</div>
<table class="foot">
<tr>
<td class="foot-date">January 26, 2018</td>
<td class="foot-os">General</td>
</tr>
</table>
</body>
</html>
-80
View File
@@ -1,80 +0,0 @@
<!DOCTYPE html>
<html>
<!-- This is an automatically generated file. Do not edit.
This file is part of RGBDS.
Copyright (c) 2010-2018, Anthony J. Bentley and RGBDS contributors.
SPDX-License-Identifier: MIT
-->
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta charset="utf-8"/>
<link rel="stylesheet" href="mandoc.css" type="text/css" media="all"/>
<link rel="stylesheet" href="rgbds.css" type="text/css" media="all"/>
<title>RGBDS(7)</title>
</head>
<body>
<table class="head">
<tr>
<td class="head-ltitle">RGBDS(7)</td>
<td class="head-vol">Miscellaneous Information Manual</td>
<td class="head-rtitle">RGBDS(7)</td>
</tr>
</table>
<div class="manual-text">
<section class="Sh">
<h1 class="Sh" id="NAME"><a class="permalink" href="#NAME">NAME</a></h1>
<code class="Nm">rgbds</code> &#x2014;
<span class="Nd">Rednex Game Boy Development System</span>
</section>
<section class="Sh">
<h1 class="Sh" id="EXAMPLES"><a class="permalink" href="#EXAMPLES">EXAMPLES</a></h1>
To get a working ROM image from a single assembly source file:
<div class="Bd Pp Bd-indent">
<pre>
$ rgbasm -o bar.o foo.asm
$ rgblink -o baz.gb bar.o
$ rgbfix -v -p 0 baz.gb
</pre>
</div>
</section>
<section class="Sh">
<h1 class="Sh" id="SEE_ALSO"><a class="permalink" href="#SEE_ALSO">SEE
ALSO</a></h1>
<a class="Xr" href="rgbasm.1.html">rgbasm(1)</a>, <a class="Xr" href="rgbfix.1.html">rgbfix(1)</a>,
<a class="Xr" href="rgblink.1.html">rgblink(1)</a>, <a class="Xr" href="rgbds.5.html">rgbds(5)</a>,
<a class="Xr" href="gbz80.7.html">gbz80(7)</a>
</section>
<section class="Sh">
<h1 class="Sh" id="HISTORY"><a class="permalink" href="#HISTORY">HISTORY</a></h1>
<dl class="Bl-ohang">
<dt></dt>
<dd>1997, Carsten S&#x00F8;rensen (AKA SurfSmurf) writes ASMotor as a
general-purpose assembler/linker system for DOS/Win32.</dd>
<dt></dt>
<dd>1999, Justin Lloyd (AKA Otaku no Zoku) adapts ASMotor to read and produce
GBZ80 assembly/machine code, and releases this version as RGBDS.</dd>
<dt></dt>
<dd>2009, Vegard Nossum adapts the code to be more UNIX-like and releases this
version as rgbds-linux on GitHub.</dd>
<dt></dt>
<dd>2010, Anthony J. Bentley forks that repository. The fork becomes the
reference implementation of rgbds.</dd>
<dt></dt>
<dd>2017, Bentley's repository is moved to a neutral name. It is now
maintained by a number of contributors at
<a class="Lk" href="https://github.com/rednex/rgbds">https://github.com/rednex/rgbds</a>.</dd>
<dt></dt>
<dd>2018, codebase relicensed under the MIT license.</dd>
</dl>
</section>
</div>
<table class="foot">
<tr>
<td class="foot-date">March 7, 2018</td>
<td class="foot-os">General</td>
</tr>
</table>
</body>
</html>
-63
View File
@@ -1,63 +0,0 @@
/* Overrides to default mandoc styling for HTML renders of RGBDS man pages */
html {
/* Reduce contrast */
background-color: #f8f8f8;
color: #222;
/* Override `mandoc.css`'s sowe can put it on <body> instead */
max-width: none;
}
body {
/* Center body horizontally (requires <html> to span full width) */
margin: 0 auto;
/* `mandoc.css`'s default, but it's applied to <html> there */
max-width: 65em;
/* Improve readability */
font-size: 16px;
line-height: 1.4;
text-align: justify;
/* Prevent text from bumping sides on mobile devices */
padding: 10px 20px 10px 10px;
}
@media print {
body {
/* Max width doesn't make sense for print */
max-width: none;
/* Make font slightly smaller for printing */
font-size: 14px;
}
}
code, pre {
font-size: smaller;
}
pre {
/* Avoid horizontal page scrolling on mobile */
overflow: auto;
}
/* Separate lines in tables */
table.Bl-column {
border-collapse: collapse;
}
table.Bl-column tr:not(:first-child) > td,
table.Bl-column tr:not(:first-child) > th {
border-top: 1px solid #aaa;
}
table.Bl-column th {
/* Apply `.Sy` style to table headers */
font-style: normal;
font-weight: bold;
}
table.Bl-column td,
table.Bl-column th {
/* Add horizontal spacing between columns */
padding: 2px 7px 0;
}
-220
View File
@@ -1,220 +0,0 @@
<!DOCTYPE html>
<html>
<!-- This is an automatically generated file. Do not edit.
This file is part of RGBDS.
Copyright (c) 2010-2017, Anthony J. Bentley and RGBDS contributors.
SPDX-License-Identifier: MIT
-->
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta charset="utf-8"/>
<link rel="stylesheet" href="mandoc.css" type="text/css" media="all"/>
<link rel="stylesheet" href="rgbds.css" type="text/css" media="all"/>
<title>RGBFIX(1)</title>
</head>
<body>
<table class="head">
<tr>
<td class="head-ltitle">RGBFIX(1)</td>
<td class="head-vol">General Commands Manual</td>
<td class="head-rtitle">RGBFIX(1)</td>
</tr>
</table>
<div class="manual-text">
<section class="Sh">
<h1 class="Sh" id="NAME"><a class="permalink" href="#NAME">NAME</a></h1>
<code class="Nm">rgbfix</code> &#x2014;
<span class="Nd">Game Boy header utility and checksum fixer</span>
</section>
<section class="Sh">
<h1 class="Sh" id="SYNOPSIS"><a class="permalink" href="#SYNOPSIS">SYNOPSIS</a></h1>
<table class="Nm">
<tr>
<td><code class="Nm">rgbfix</code></td>
<td>[<code class="Fl"><a href="#j">-j</a><a href="#s">s</a><a href="#V">V</a><a href="#v">v</a></code>] [<code class="Fl"><a href="#C">-C</a></code> |
<code class="Fl"><a href="#c">-c</a></code>] [<code class="Fl"><a href="#f">-f</a></code>
<var class="Ar">fix_spec</var>] [<code class="Fl"><a href="#i">-i</a></code>
<var class="Ar">game_id</var>] [<code class="Fl"><a href="#k">-k</a></code>
<var class="Ar">licensee_str</var>] [<code class="Fl"><a href="#l">-l</a></code>
<var class="Ar">licensee_id</var>] [<code class="Fl"><a href="#m">-m</a></code>
<var class="Ar">mbc_type</var>] [<code class="Fl"><a href="#n">-n</a></code>
<var class="Ar">rom_version</var>] [<code class="Fl"><a href="#p">-p</a></code>
<var class="Ar">pad_value</var>] [<code class="Fl"><a href="#r">-r</a></code>
<var class="Ar">ram_size</var>] [<code class="Fl"><a href="#t">-t</a></code>
<var class="Ar">title_str</var>] <var class="Ar">file</var></td>
</tr>
</table>
</section>
<section class="Sh">
<h1 class="Sh" id="DESCRIPTION"><a class="permalink" href="#DESCRIPTION">DESCRIPTION</a></h1>
The <code class="Nm">rgbfix</code> program changes headers of Game Boy ROM
images. It also performs other correctness operations, such as padding.
<p class="Pp">Note that options can be abbreviated as long as the abbreviation
is unambiguous: <code class="Fl">--verb</code> is
<code class="Fl">--verbose</code>, but
<code class="Fl">--ver</code> is invalid because it
could also be <code class="Fl">--version</code>. The
arguments are as follows:</p>
<dl class="Bl-tag">
<dt><a class="permalink" href="#C"><code class="Fl" id="C">-C</code></a>,
<code class="Fl">--color-only</code></dt>
<dd>Set the Game Boy Color&#x2013;only flag: <span class="Ad">0x143</span> =
0xC0. If both this and the <code class="Fl">-c</code> flag are set, this
takes precedence.</dd>
<dt><a class="permalink" href="#c"><code class="Fl" id="c">-c</code></a>,
<code class="Fl">--color-compatible</code></dt>
<dd>Set the Game Boy Color&#x2013;compatible flag:
<span class="Ad">0x143</span> = 0x80. If both this and the
<code class="Fl">-C</code> flag are set, <code class="Fl">-C</code> takes
precedence.</dd>
<dt><a class="permalink" href="#f"><code class="Fl" id="f">-f</code></a>
<var class="Ar">fix_spec</var>,
<code class="Fl">--fix-spec</code>
<var class="Ar">fix_spec</var></dt>
<dd>Fix certain header values that the Game Boy checks for correctness.
Alternatively, intentionally trash these values by writing their binary
inverse instead. <var class="Ar">fix_spec</var> is a string containing any
combination of the following characters:
<p class="Pp"></p>
<dl class="Bl-tag Bl-compact">
<dt><a class="permalink" href="#l"><code class="Cm" id="l">l</code></a></dt>
<dd>Fix the Nintendo logo
(<span class="Ad">0x104</span>&#x2013;<span class="Ad">0x133</span>).</dd>
<dt><a class="permalink" href="#L"><code class="Cm" id="L">L</code></a></dt>
<dd>Trash the Nintendo logo.</dd>
<dt><a class="permalink" href="#h"><code class="Cm" id="h">h</code></a></dt>
<dd>Fix the header checksum (<span class="Ad">0x14D</span>).</dd>
<dt><a class="permalink" href="#H"><code class="Cm" id="H">H</code></a></dt>
<dd>Trash the header checksum.</dd>
<dt><a class="permalink" href="#g"><code class="Cm" id="g">g</code></a></dt>
<dd>Fix the global checksum
(<span class="Ad">0x14E</span>&#x2013;<span class="Ad">0x14F</span>).</dd>
<dt><a class="permalink" href="#G"><code class="Cm" id="G">G</code></a></dt>
<dd>Trash the global checksum.</dd>
</dl>
</dd>
<dt><a class="permalink" href="#i"><code class="Fl" id="i">-i</code></a>
<var class="Ar">game_id</var>,
<code class="Fl">--game-id</code>
<var class="Ar">game_id</var></dt>
<dd>Set the game ID string
(<span class="Ad">0x13F</span>&#x2013;<span class="Ad">0x142</span>) to a
given string of exactly 4 characters. If both this and the title are set,
the game ID will overwrite the overlapping portion of the title.</dd>
<dt><a class="permalink" href="#j"><code class="Fl" id="j">-j</code></a>,
<code class="Fl">--non-japanese</code></dt>
<dd>Set the non-Japanese region flag: <span class="Ad">0x14A</span> = 1.</dd>
<dt><a class="permalink" href="#k"><code class="Fl" id="k">-k</code></a>
<var class="Ar">licensee_str</var>,
<code class="Fl">--new-licensee</code>
<var class="Ar">licensee_str</var></dt>
<dd>Set the new licensee string
(<span class="Ad">0x144</span>&#x2013;<span class="Ad">0x145</span>) to a
given string, truncated to at most two characters.</dd>
<dt><a class="permalink" href="#l_2"><code class="Fl" id="l_2">-l</code></a>
<var class="Ar">licensee_id</var>,
<code class="Fl">--old-licensee</code>
<var class="Ar">licensee_id</var></dt>
<dd>Set the old licensee code, <span class="Ad">0x14B</span>, to a given value
from 0 to 0xFF. This value is deprecated and should be set to 0x33 in all
new software.</dd>
<dt><a class="permalink" href="#m"><code class="Fl" id="m">-m</code></a>
<var class="Ar">mbc_type</var>,
<code class="Fl">--mbc-type</code>
<var class="Ar">mbc_type</var></dt>
<dd>Set the MBC type, <span class="Ad">0x147</span>, to a given value from 0
to 0xFF.</dd>
<dt><a class="permalink" href="#n"><code class="Fl" id="n">-n</code></a>
<var class="Ar">rom_version</var>,
<code class="Fl">--rom-version</code>
<var class="Ar">rom_version</var></dt>
<dd>Set the ROM version, <span class="Ad">0x14C</span>, to a given value from
0 to 0xFF.</dd>
<dt><a class="permalink" href="#p"><code class="Fl" id="p">-p</code></a>
<var class="Ar">pad_value</var>,
<code class="Fl">--pad-value</code>
<var class="Ar">pad_value</var></dt>
<dd>Pad the image to a valid size with a given pad value from 0 to 0xFF.
<code class="Nm">rgbfix</code> will automatically pick a size from 32 KiB,
64 KiB, 128 KiB, ..., 8192 KiB. The cartridge size byte
(<span class="Ad">0x148</span>) will be changed to reflect this new
size.</dd>
<dt><a class="permalink" href="#r"><code class="Fl" id="r">-r</code></a>
<var class="Ar">ram_size</var>,
<code class="Fl">--ram-size</code>
<var class="Ar">ram_size</var></dt>
<dd>Set the RAM size, <span class="Ad">0x149</span>, to a given value from 0
to 0xFF.</dd>
<dt><a class="permalink" href="#s"><code class="Fl" id="s">-s</code></a>,
<code class="Fl">--sgb-compatible</code></dt>
<dd>Set the SGB flag: <span class="Ad">0x146</span> = 3. This flag will be
ignored by the SGB unless the old licensee code is 0x33!</dd>
<dt><a class="permalink" href="#t"><code class="Fl" id="t">-t</code></a>
<var class="Ar">title</var>,
<code class="Fl">--title</code>
<var class="Ar">title</var></dt>
<dd>Set the title string
(<span class="Ad">0x134</span>&#x2013;<span class="Ad">0x143</span>) to a
given string, truncated to at most 16 characters. It is recommended to use
15 characters instead, to avoid clashing with the CGB flag
(<code class="Fl">-c</code> or <code class="Fl">-C</code>). If both this
and the game ID are set, the game ID will overwrite the overlapping
portion of the title.</dd>
<dt><a class="permalink" href="#V"><code class="Fl" id="V">-V</code></a>,
<code class="Fl">--version</code></dt>
<dd>Print the version of the program and exit.</dd>
<dt><a class="permalink" href="#v"><code class="Fl" id="v">-v</code></a>,
<code class="Fl">--validate</code></dt>
<dd>Equivalent to <code class="Fl">-f</code> <code class="Cm">lhg</code>.</dd>
</dl>
</section>
<section class="Sh">
<h1 class="Sh" id="EXAMPLES"><a class="permalink" href="#EXAMPLES">EXAMPLES</a></h1>
Most values in the ROM header are only cosmetic. The bare minimum requirements
for a workable program are the header checksum, the Nintendo logo, and (if
needed) the CGB/SGB flags. It is a good idea to pad the image to a valid size
as well (&#x201C;valid&#x201D; meaning a power of 2, times 32 KiB).
<p class="Pp">The following will make a plain, non-color Game Boy game without
checking for a valid size:</p>
<p class="Pp"></p>
<div class="Bd Bd-indent">$ rgbfix -v foo.gb</div>
<p class="Pp">The following will make a SGB-enabled, color-enabled game with a
title of &#x201C;foobar&#x201D;, and pad it to a valid size. (The Game Boy
itself does not use the title, but some emulators or ROM managers do.)</p>
<p class="Pp"></p>
<div class="Bd Bd-indent">$ rgbfix -vcs -l 0x33 -p 255 -t foobar baz.gb</div>
<p class="Pp">The following will duplicate the header (sans global checksum) of
the game &#x201C;Survival Kids&#x201D;:</p>
<p class="Pp"></p>
<div class="Bd Bd-indent">$ rgbfix -cjsv -k A4 -l 0x33 -m 0x1B -p 0xFF -r 3 -t
SURVIVALKIDAVKE SurvivalKids.gbc</div>
</section>
<section class="Sh">
<h1 class="Sh" id="BUGS"><a class="permalink" href="#BUGS">BUGS</a></h1>
Please report bugs on
<a class="Lk" href="https://github.com/rednex/rgbds/issues">GitHub</a>.
</section>
<section class="Sh">
<h1 class="Sh" id="SEE_ALSO"><a class="permalink" href="#SEE_ALSO">SEE
ALSO</a></h1>
<a class="Xr" href="rgbasm.1.html">rgbasm(1)</a>, <a class="Xr" href="rgblink.1.html">rgblink(1)</a>,
<a class="Xr" href="rgbds.7.html">rgbds(7)</a>
</section>
<section class="Sh">
<h1 class="Sh" id="HISTORY"><a class="permalink" href="#HISTORY">HISTORY</a></h1>
<code class="Nm">rgbfix</code> was originally released by Carsten
S&#x00F8;rensen as a standalone program called gbfix, and was later packaged
in RGBDS by Justin Lloyd. It is now maintained by a number of contributors at
<a class="Lk" href="https://github.com/rednex/rgbds">https://github.com/rednex/rgbds</a>.
</section>
</div>
<table class="foot">
<tr>
<td class="foot-date">December 5, 2019</td>
<td class="foot-os">General</td>
</tr>
</table>
</body>
</html>
-220
View File
@@ -1,220 +0,0 @@
<!DOCTYPE html>
<html>
<!-- This is an automatically generated file. Do not edit.
This file is part of RGBDS.
Copyright (c) 2013-2018, stag019 and RGBDS contributors.
SPDX-License-Identifier: MIT
-->
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta charset="utf-8"/>
<link rel="stylesheet" href="mandoc.css" type="text/css" media="all"/>
<link rel="stylesheet" href="rgbds.css" type="text/css" media="all"/>
<title>RGBGFX(1)</title>
</head>
<body>
<table class="head">
<tr>
<td class="head-ltitle">RGBGFX(1)</td>
<td class="head-vol">General Commands Manual</td>
<td class="head-rtitle">RGBGFX(1)</td>
</tr>
</table>
<div class="manual-text">
<section class="Sh">
<h1 class="Sh" id="NAME"><a class="permalink" href="#NAME">NAME</a></h1>
<code class="Nm">rgbgfx</code> &#x2014;
<span class="Nd">Game Boy graphics converter</span>
</section>
<section class="Sh">
<h1 class="Sh" id="SYNOPSIS"><a class="permalink" href="#SYNOPSIS">SYNOPSIS</a></h1>
<table class="Nm">
<tr>
<td><code class="Nm">rgbgfx</code></td>
<td>[<code class="Fl"><a href="#C">-C</a><a href="#D">D</a><a href="#h">h</a><a href="#m">m</a><a href="#u">u</a><a href="#V">V</a><a href="#v">v</a></code>] [<code class="Fl"><a href="#f">-f</a></code> |
<code class="Fl"><a href="#F">-F</a></code>] [<code class="Fl"><a href="#a">-a</a></code>
<var class="Ar">attrmap</var> | <code class="Fl"><a href="#A">-A</a></code>]
[<code class="Fl"><a href="#d">-d</a></code> <var class="Ar">depth</var>]
[<code class="Fl"><a href="#o">-o</a></code> <var class="Ar">out_file</var>]
[<code class="Fl"><a href="#p">-p</a></code> <var class="Ar">pal_file</var> |
<code class="Fl"><a href="#P">-P</a></code>] [<code class="Fl"><a href="#t">-t</a></code>
<var class="Ar">tilemap</var> | <code class="Fl"><a href="#T">-T</a></code>]
[<code class="Fl"><a href="#x">-x</a></code> <var class="Ar">tiles</var>]
<var class="Ar">file</var></td>
</tr>
</table>
</section>
<section class="Sh">
<h1 class="Sh" id="DESCRIPTION"><a class="permalink" href="#DESCRIPTION">DESCRIPTION</a></h1>
The <code class="Nm">rgbgfx</code> program converts PNG images into the Nintendo
Game Boy's planar tile format.
<p class="Pp">The resulting colors and their palette indices are determined
differently depending on the input PNG file:</p>
<ul class="Bl-dash">
<li>If the file has an embedded palette, that palette's color and order are
used.</li>
<li>If not, and the image only contains shades of gray, rgbgfx maps them to
the indices appropriate for each shade. Any undetermined indices are set
to respective default shades of gray. For example: if the bit depth is 2
and the image contains light gray and black, they become the second and
fourth colors, and the first and third colors get set to default white and
dark gray. If the image has multiple shades that map to the same index,
the palette is instead determined as if the image had color.</li>
<li>If the image has color (or the grayscale method failed), the colors are
sorted from lightest to darkest.</li>
</ul>
<p class="Pp">The input image may not contain more colors than the selected bit
depth allows. Transparent pixels are set to palette index 0.</p>
</section>
<section class="Sh">
<h1 class="Sh" id="ARGUMENTS"><a class="permalink" href="#ARGUMENTS">ARGUMENTS</a></h1>
Note that options can be abbreviated as long as the abbreviation is unambiguous:
<code class="Fl">--verb</code> is
<code class="Fl">-</code> <code class="Fl">-verbose</code>, but
<code class="Fl">--ver</code> is invalid because it
could also be <code class="Fl">--version</code>. The
arguments are as follows:
<dl class="Bl-tag">
<dt><a class="permalink" href="#a"><code class="Fl" id="a">-a</code></a>
<var class="Ar">attrmap,</var>
<code class="Fl">--attr-map</code>
<var class="Ar">attrmap</var></dt>
<dd>Generate a file of tile mirroring attributes for OAM or (CGB-only)
background tiles. For each tile in the input file, a byte is written
representing the dimensions that the associated tile in the output file
should be mirrored. Useful in combination with <code class="Fl">-m</code>
to keep track the mirror direction of mirrored duplicate tiles.</dd>
<dt><a class="permalink" href="#A"><code class="Fl" id="A">-A</code></a>,
<code class="Fl">--output-attr-map</code></dt>
<dd>Same as <code class="Fl">-a</code>, but the attrmap file output name is
made by taking the input filename, removing the file extension, and
appending <span class="Pa">.attrmap</span>.</dd>
<dt><a class="permalink" href="#C"><code class="Fl" id="C">-C</code></a>,
<code class="Fl">--color-curve</code></dt>
<dd>Use the color curve of the Game Boy Color when generating palettes.</dd>
<dt><a class="permalink" href="#D"><code class="Fl" id="D">-D</code></a>,
<code class="Fl">--debug</code></dt>
<dd>Debug features are enabled.</dd>
<dt><a class="permalink" href="#d"><code class="Fl" id="d">-d</code></a>
<var class="Ar">depth</var>,
<code class="Fl">--depth</code>
<var class="Ar">depth</var></dt>
<dd>The bit depth of the output image (either 1 or 2). By default, the bit
depth is 2 (two bits per pixel).</dd>
<dt><a class="permalink" href="#f"><code class="Fl" id="f">-f</code></a>,
<code class="Fl">--fix</code></dt>
<dd>Fix the input PNG file to be a correctly indexed image.</dd>
<dt><a class="permalink" href="#F"><code class="Fl" id="F">-F</code></a>,
<code class="Fl">--fix-and-save</code></dt>
<dd>Same as <code class="Fl">-f</code>, but additionally, the supplied command
line parameters are saved within the PNG and will be loaded and
automatically used next time.</dd>
<dt><a class="permalink" href="#h"><code class="Fl" id="h">-h</code></a>,
<code class="Fl">--horizontal</code></dt>
<dd>Lay out tiles horizontally rather than vertically.</dd>
<dt><a class="permalink" href="#m"><code class="Fl" id="m">-m</code></a>,
<code class="Fl">--mirror-tiles</code></dt>
<dd>Truncate tiles by checking for tiles that are mirrored versions of others
and omitting these from the output file. Useful with tilemaps and attrmaps
together to keep track of the duplicated tiles and the dimension mirrored.
Tiles are checked for horizontal, vertical, and horizontal-vertical
mirroring. Implies <code class="Fl">-u</code>.</dd>
<dt><a class="permalink" href="#o"><code class="Fl" id="o">-o</code></a>
<var class="Ar">out_file</var>,
<code class="Fl">--output</code>
<var class="Ar">out_file</var></dt>
<dd>The name of the output file.</dd>
<dt><a class="permalink" href="#p"><code class="Fl" id="p">-p</code></a>
<var class="Ar">pal_file</var>,
<code class="Fl">--palette</code>
<var class="Ar">pal_file</var></dt>
<dd>Output the image's palette in standard GBC palette format: bytes (8 bytes
for two bits per pixel, 4 bytes for one bit per pixel) containing the
RGB15 values in little-endian byte order. If the palette contains too few
colors, the remaining entries are set to black.</dd>
<dt><a class="permalink" href="#P"><code class="Fl" id="P">-P</code></a>,
<code class="Fl">--output-palette</code></dt>
<dd>Same as <code class="Fl">-p</code>, but the palette file output name is
made by taking the input PNG file's filename, removing the file extension,
and appending <span class="Pa">.pal</span>.</dd>
<dt><a class="permalink" href="#t"><code class="Fl" id="t">-t</code></a>
<var class="Ar">tilemap</var>,
<code class="Fl">--tilemap</code>
<var class="Ar">tilemap</var></dt>
<dd>Generate a file of tile indices. For each tile in the input file, a byte
is written representing the index of the associated tile in the output
file. Useful in combination with <code class="Fl">-u</code> or
<code class="Fl">-m</code> to keep track of duplicate tiles.</dd>
<dt><a class="permalink" href="#T"><code class="Fl" id="T">-T</code></a>,
<code class="Fl">--output-tilemap</code></dt>
<dd>Same as <code class="Fl">-t</code>, but the tilemap file output name is
made by taking the input filename, removing the file extension, and
appending <span class="Pa">.tilemap</span>.</dd>
<dt><a class="permalink" href="#u"><code class="Fl" id="u">-u</code></a>,
<code class="Fl">--unique-tiles</code></dt>
<dd>Truncate tiles by checking for tiles that are exact duplicates of others
and omitting these from the output file. Useful with tilemaps to keep
track of the duplicated tiles.</dd>
<dt><a class="permalink" href="#V"><code class="Fl" id="V">-V</code></a>,
<code class="Fl">--version</code></dt>
<dd>Print the version of the program and exit.</dd>
<dt><a class="permalink" href="#v"><code class="Fl" id="v">-v</code></a>,
<code class="Fl">--verbose</code></dt>
<dd>Verbose. Print errors when the command line parameters and the parameters
in the PNG file don't match.</dd>
<dt><a class="permalink" href="#x"><code class="Fl" id="x">-x</code></a>
<var class="Ar">tiles</var>,
<code class="Fl">--trim-end</code>
<var class="Ar">tiles</var></dt>
<dd>Trim the end of the output file by this many tiles.</dd>
</dl>
</section>
<section class="Sh">
<h1 class="Sh" id="EXAMPLES"><a class="permalink" href="#EXAMPLES">EXAMPLES</a></h1>
The following will take a PNG file with a bit depth of 1, 2, or 8, and output
planar 2bpp data:
<p class="Pp"></p>
<div class="Bd Bd-indent">$ rgbgfx -o out.2bpp in.png</div>
<p class="Pp">The following creates a planar 2bpp file with only unique tiles,
and its tilemap <span class="Pa">out.tilemap</span>:</p>
<p class="Pp"></p>
<div class="Bd Bd-indent">$ rgbgfx -T -u -o out.2bpp in.png</div>
<p class="Pp">The following creates a planar 2bpp file with only unique tiles
<span class="Pa">accounting for tile mirroring</span> and its associated
tilemap <span class="Pa">out.tilemap</span> and attrmap
<span class="Pa">out.attrmap</span>:</p>
<p class="Pp"></p>
<div class="Bd Bd-indent">$ rgbgfx -A -T -m -o out.2bpp in.png</div>
<p class="Pp">The following will do nothing:</p>
<p class="Pp"></p>
<div class="Bd Bd-indent">$ rgbgfx in.png</div>
</section>
<section class="Sh">
<h1 class="Sh" id="BUGS"><a class="permalink" href="#BUGS">BUGS</a></h1>
Please report bugs on
<a class="Lk" href="https://github.com/rednex/rgbds/issues">GitHub</a>.
</section>
<section class="Sh">
<h1 class="Sh" id="SEE_ALSO"><a class="permalink" href="#SEE_ALSO">SEE
ALSO</a></h1>
<a class="Xr" href="rgbds.7.html">rgbds(7)</a>, <a class="Xr" href="rgbasm.1.html">rgbasm(1)</a>,
<a class="Xr" href="rgblink.1.html">rgblink(1)</a>, <a class="Xr" href="rgbfix.1.html">rgbfix(1)</a>,
<a class="Xr" href="gbz80.7.html">gbz80(7)</a>
</section>
<section class="Sh">
<h1 class="Sh" id="HISTORY"><a class="permalink" href="#HISTORY">HISTORY</a></h1>
<code class="Nm">rgbgfx</code> was created by <span class="An">stag019</span> to
be included in RGBDS. It is now maintained by a number of contributors at
<a class="Lk" href="https://github.com/rednex/rgbds">https://github.com/rednex/rgbds</a>.
</section>
</div>
<table class="foot">
<tr>
<td class="foot-date">December 5, 2019</td>
<td class="foot-os">General</td>
</tr>
</table>
</body>
</html>
-192
View File
@@ -1,192 +0,0 @@
<!DOCTYPE html>
<html>
<!-- This is an automatically generated file. Do not edit.
This file is part of RGBDS.
Copyright (c) 2010-2019, Anthony J. Bentley and RGBDS contributors.
SPDX-License-Identifier: MIT
-->
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta charset="utf-8"/>
<link rel="stylesheet" href="mandoc.css" type="text/css" media="all"/>
<link rel="stylesheet" href="rgbds.css" type="text/css" media="all"/>
<title>RGBLINK(1)</title>
</head>
<body>
<table class="head">
<tr>
<td class="head-ltitle">RGBLINK(1)</td>
<td class="head-vol">General Commands Manual</td>
<td class="head-rtitle">RGBLINK(1)</td>
</tr>
</table>
<div class="manual-text">
<section class="Sh">
<h1 class="Sh" id="NAME"><a class="permalink" href="#NAME">NAME</a></h1>
<code class="Nm">rgblink</code> &#x2014;
<span class="Nd">Game Boy linker</span>
</section>
<section class="Sh">
<h1 class="Sh" id="SYNOPSIS"><a class="permalink" href="#SYNOPSIS">SYNOPSIS</a></h1>
<table class="Nm">
<tr>
<td><code class="Nm">rgblink</code></td>
<td>[<code class="Fl"><a href="#d">-d</a><a href="#t">t</a><a href="#V">V</a><a href="#v">v</a><a href="#w">w</a><a href="#x">x</a></code>] [<code class="Fl"><a href="#l">-l</a></code>
<var class="Ar">linker_script</var>] [<code class="Fl"><a href="#m">-m</a></code>
<var class="Ar">map_file</var>] [<code class="Fl"><a href="#n">-n</a></code>
<var class="Ar">sym_file</var>] [<code class="Fl"><a href="#O">-O</a></code>
<var class="Ar">overlay_file</var>] [<code class="Fl"><a href="#o">-o</a></code>
<var class="Ar">out_file</var>] [<code class="Fl"><a href="#p">-p</a></code>
<var class="Ar">pad_value</var>] [<code class="Fl"><a href="#s">-s</a></code>
<var class="Ar">symbol</var>] <var class="Ar">file ...</var></td>
</tr>
</table>
</section>
<section class="Sh">
<h1 class="Sh" id="DESCRIPTION"><a class="permalink" href="#DESCRIPTION">DESCRIPTION</a></h1>
The <code class="Nm">rgblink</code> program links RGB object files, typically
created by <a class="Xr" href="rgbasm.1.html">rgbasm(1)</a>, into a single Game Boy ROM file. The
format is documented in <a class="Xr" href="rgbds.5.html">rgbds(5)</a>.
<p class="Pp">ROM0 sections are placed in the first 16 KiB of the output ROM,
and ROMX sections are placed in any 16 KiB &#x201C;bank&#x201D; except the
first. If your ROM will only be 32 KiB, you can use the
<code class="Fl">-t</code> option to change this.</p>
<p class="Pp">Similarly, WRAM0 sections are placed in the first 4 KiB of WRAM
(&#x201C;bank 0&#x201D;), and WRAMX sections are placed in any bank of the
last 4 KiB. If your ROM doesn't use banked WRAM, you can use the
<code class="Fl">-w</code> option to change this.</p>
<p class="Pp">Also, if your ROM is designed for a monochrome Game Boy, you can
make sure that you don't use any incompatible section by using the
<code class="Fl">-d</code> option, which implies <code class="Fl">-w</code>
but also prohibits the use of banked VRAM.</p>
<p class="Pp">Note that options can be abbreviated as long as the abbreviation
is unambiguous: <code class="Fl">--verb</code> is
<code class="Fl">--verbose</code>, but
<code class="Fl">--ver</code> is invalid because it
could also be <code class="Fl">--version</code>. The
arguments are as follows:</p>
<dl class="Bl-tag">
<dt><a class="permalink" href="#d"><code class="Fl" id="d">-d</code></a>,
<code class="Fl">--dmg</code></dt>
<dd>Enable DMG mode. Prohibit the use of sections that doesn't exist on a DMG,
such as VRAM bank 1. This option automatically enables
<code class="Fl">-w</code>.</dd>
<dt><a class="permalink" href="#l"><code class="Fl" id="l">-l</code></a>
<var class="Ar">linker_script,</var>
<code class="Fl">--linkerscript</code>
<var class="Ar">linker_script</var></dt>
<dd>Specify a linker script file that tells the linker how sections must be
placed in the ROM. The attributes assigned in the linker script must be
consistent with any assigned in the code. See <a class="Xr" href="rgblink.5.html">rgblink(5)</a>
for more information about the linker script format.</dd>
<dt><a class="permalink" href="#m"><code class="Fl" id="m">-m</code></a>
<var class="Ar">map_file</var>,
<code class="Fl">--map</code>
<var class="Ar">map_file</var></dt>
<dd>Write a map file to the given filename, listing how sections and symbols
were assigned.</dd>
<dt><a class="permalink" href="#n"><code class="Fl" id="n">-n</code></a>
<var class="Ar">sym_file</var>,
<code class="Fl">--sym</code>
<var class="Ar">sym_file</var></dt>
<dd>Write a symbol file to the given filename, listing the address of all
exported symbols. Several external programs can use this information, for
example to help debugging ROMs.</dd>
<dt><a class="permalink" href="#O"><code class="Fl" id="O">-O</code></a>
<var class="Ar">overlay_file</var>,
<code class="Fl">--overlay</code>
<var class="Ar">overlay_file</var></dt>
<dd>If specified, sections will be overlaid &quot;on top&quot; of the provided
ROM image. In that case, all sections must be fixed. This may be used to
patch an existing binary.</dd>
<dt><a class="permalink" href="#o"><code class="Fl" id="o">-o</code></a>
<var class="Ar">out_file</var>,
<code class="Fl">--output</code>
<var class="Ar">out_file</var></dt>
<dd>Write the ROM image to the given file.</dd>
<dt><a class="permalink" href="#p"><code class="Fl" id="p">-p</code></a>
<var class="Ar">pad_value</var>,
<code class="Fl">--pad</code>
<var class="Ar">pad_value</var></dt>
<dd>When inserting padding between sections, pad with this value. Has no
effect if <code class="Fl">-O</code> is specified. The default is 0.</dd>
<dt><a class="permalink" href="#s"><code class="Fl" id="s">-s</code></a>
<var class="Ar">symbol</var>,
<code class="Fl">--smart</code>
<var class="Ar">symbol</var></dt>
<dd>This option is ignored. It was supposed to perform smart linking but fell
into disrepair, and so has been removed. It will be reimplemented at some
point.</dd>
<dt><a class="permalink" href="#t"><code class="Fl" id="t">-t</code></a>,
<code class="Fl">--tiny</code></dt>
<dd>Expand the ROM0 section size from 16 KiB to the full 32 KiB assigned to
ROM. ROMX sections that are fixed to a bank other than 1 become errors,
other ROMX sections are treated as ROM0. Useful for ROMs that fit in 32
KiB.</dd>
<dt><a class="permalink" href="#V"><code class="Fl" id="V">-V</code></a>,
<code class="Fl">--version</code></dt>
<dd>Print the version of the program and exit.</dd>
<dt><a class="permalink" href="#v"><code class="Fl" id="v">-v</code></a>,
<code class="Fl">--verbose</code></dt>
<dd>Verbose: enable printing more information to standard error.</dd>
<dt><a class="permalink" href="#w"><code class="Fl" id="w">-w</code></a>,
<code class="Fl">--wramx</code></dt>
<dd>Expand the WRAM0 section size from 4 KiB to the full 8 KiB assigned to
WRAM. WRAMX sections that are fixed to a bank other than 1 become errors,
other WRAMX sections are treated as WRAM0.</dd>
<dt><a class="permalink" href="#x"><code class="Fl" id="x">-x</code></a>,
<code class="Fl">--nopad</code></dt>
<dd>Disables padding the end of the final file. This option automatically
enables <code class="Fl">-t</code>. You can use this when not not making a
ROM. When making a ROM, be careful that not using this is not a
replacement for <a class="Xr" href="rgbfix.1.html">rgbfix(1)</a>'s <code class="Fl">-p</code>
option!</dd>
</dl>
</section>
<section class="Sh">
<h1 class="Sh" id="EXAMPLES"><a class="permalink" href="#EXAMPLES">EXAMPLES</a></h1>
All you need for a basic ROM is an object file, which can be made into a ROM
image like so:
<p class="Pp"></p>
<div class="Bd Bd-indent">$ rgblink -o bar.gb foo.o</div>
<p class="Pp">The resulting <var class="Ar">bar.gb</var> will not have correct
checksums (unless you put them in the assembly source). You should use
<a class="Xr" href="rgbfix.1.html">rgbfix(1)</a> to fix these so that the program will actually
run in a Game Boy:</p>
<p class="Pp"></p>
<div class="Bd Bd-indent"><code class="Li">$ rgbfix -v bar.gb</code></div>
<p class="Pp">Here is a more complete example:</p>
<p class="Pp"></p>
<div class="Bd Bd-indent"><code class="Li">$ rgblink -o bin/game.gb -n
bin/game.sym -p 0xFF obj/title.o obj/engine.o</code></div>
</section>
<section class="Sh">
<h1 class="Sh" id="BUGS"><a class="permalink" href="#BUGS">BUGS</a></h1>
Please report bugs on
<a class="Lk" href="https://github.com/rednex/rgbds/issues">GitHub</a>.
</section>
<section class="Sh">
<h1 class="Sh" id="SEE_ALSO"><a class="permalink" href="#SEE_ALSO">SEE
ALSO</a></h1>
<a class="Xr" href="rgbasm.1.html">rgbasm(1)</a>, <a class="Xr" href="rgblink.5.html">rgblink(5)</a>,
<a class="Xr" href="rgbfix.1.html">rgbfix(1)</a>, <a class="Xr" href="rgbds.5.html">rgbds(5)</a>,
<a class="Xr" href="rgbds.7.html">rgbds(7)</a>
</section>
<section class="Sh">
<h1 class="Sh" id="HISTORY"><a class="permalink" href="#HISTORY">HISTORY</a></h1>
<code class="Nm">rgblink</code> was originally written by Carsten
S&#x00F8;rensen as part of the ASMotor package, and was later packaged in
RGBDS by Justin Lloyd. It is now maintained by a number of contributors at
<a class="Lk" href="https://github.com/rednex/rgbds">https://github.com/rednex/rgbds</a>.
</section>
</div>
<table class="foot">
<tr>
<td class="foot-date">November 26, 2019</td>
<td class="foot-os">General</td>
</tr>
</table>
</body>
</html>
-111
View File
@@ -1,111 +0,0 @@
<!DOCTYPE html>
<html>
<!-- This is an automatically generated file. Do not edit.
This file is part of RGBDS.
Copyright (c) 2017-2018, Antonio Nino Diaz and RGBDS contributors.
SPDX-License-Identifier: MIT
-->
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta charset="utf-8"/>
<link rel="stylesheet" href="mandoc.css" type="text/css" media="all"/>
<link rel="stylesheet" href="rgbds.css" type="text/css" media="all"/>
<title>RGBLINK(5)</title>
</head>
<body>
<table class="head">
<tr>
<td class="head-ltitle">RGBLINK(5)</td>
<td class="head-vol">File Formats Manual</td>
<td class="head-rtitle">RGBLINK(5)</td>
</tr>
</table>
<div class="manual-text">
<section class="Sh">
<h1 class="Sh" id="NAME"><a class="permalink" href="#NAME">NAME</a></h1>
<code class="Nm">rgblink</code> &#x2014;
<span class="Nd">linker script file format</span>
</section>
<section class="Sh">
<h1 class="Sh" id="DESCRIPTION"><a class="permalink" href="#DESCRIPTION">DESCRIPTION</a></h1>
The linker script is an external file that allows the user to specify the order
of sections at link time and in a centralized manner.
<p class="Pp">A linker script consists on a series of banks followed by a list
of sections and, optionally, commands. They can be lowercase or uppercase,
it is ignored. Any line can contain a comment starting with
&#x2018;<code class="Li">;</code>&#x2019; that ends at the end of the
line:</p>
<div class="Bd Pp Bd-indent">
<pre>
ROMX $F ; This is a comment
&quot;Functions to read array&quot;
ALIGN 8
&quot;Array aligned to 256 bytes&quot;
WRAMX 2
&quot;Some variables&quot;
</pre>
</div>
<p class="Pp">Numbers can be in decimal or hexadecimal format (the prefix is
&#x2018;<code class="Li">$</code>&#x2019;). It is an error if any section
name or command is found before setting a bank.</p>
<p class="Pp">Files can be included by using the <code class="Ic">INCLUDE</code>
keyword, followed by a string with the path of the file that has to be
included.</p>
<p class="Pp">The possible bank types are: <code class="Cm">ROM0</code>,
<code class="Cm">ROMX</code>, <code class="Cm">VRAM</code>,
<code class="Cm">SRAM</code>, <code class="Cm">WRAM0</code>,
<code class="Cm">WRAMX</code>, <code class="Cm">OAM</code> and
<code class="Cm">HRAM</code>. Unless there is a single bank, which can occur
with types <code class="Cm">ROMX</code>, <code class="Cm">VRAM</code>,
<code class="Cm">SRAM</code> and <code class="Cm">WRAMX</code>, it is needed
to specify a bank number after the type.</p>
<p class="Pp">When a new bank statement is found, sections found after it will
be placed right from the beginning of that bank. If the linker script
switches to a different bank and then comes back to a previous one, it will
continue from the last address that was used.</p>
<p class="Pp">The only two commands are <code class="Ic">ORG</code> and
<code class="Ic">ALIGN</code>:</p>
<ul class="Bl-bullet">
<li><a class="permalink" href="#ORG"><code class="Ic" id="ORG">ORG</code></a>
sets the address in which new sections will be placed. It can not be lower
than the current address.</li>
<li><a class="permalink" href="#ALIGN"><code class="Ic" id="ALIGN">ALIGN</code></a>
will increase the address until it is aligned to the specified boundary
(it tries to set to 0 the number of bits specified after the command:
&#x2018;<code class="Li">ALIGN 8</code>&#x2019; will align to $100).</li>
</ul>
<p class="Pp"><b class="Sy">Note:</b> The bank, alignment, address and type of
sections can be specified both in the source code and in the linker script.
For a section to be able to be placed with the linker script, the bank,
address and alignment must be left unassigned in the source code or be
compatible with what is specified in the linker script. For example,
&#x2018;<code class="Li">ALIGN[8]</code>&#x2019; in the source code is
compatible with &#x2018;<code class="Li">ORG $F00</code>&#x2019; in the
linker script.</p>
</section>
<section class="Sh">
<h1 class="Sh" id="SEE_ALSO"><a class="permalink" href="#SEE_ALSO">SEE
ALSO</a></h1>
<a class="Xr" href="rgbasm.1.html">rgbasm(1)</a>, <a class="Xr" href="rgblink.1.html">rgblink(1)</a>,
<a class="Xr" href="rgbfix.1.html">rgbfix(1)</a>, <a class="Xr" href="rgbds.5.html">rgbds(5)</a>,
<a class="Xr" href="rgbds.7.html">rgbds(7)</a>
</section>
<section class="Sh">
<h1 class="Sh" id="HISTORY"><a class="permalink" href="#HISTORY">HISTORY</a></h1>
<code class="Nm">rgblink</code> was originally written by Carsten
S&#x00F8;rensen as part of the ASMotor package, and was later packaged in
RGBDS by Justin Lloyd. It is now maintained by a number of contributors at
<a class="Lk" href="https://github.com/rednex/rgbds">https://github.com/rednex/rgbds</a>.
</section>
</div>
<table class="foot">
<tr>
<td class="foot-date">November 26, 2019</td>
<td class="foot-os">General</td>
</tr>
</table>
</body>
</html>
+62
View File
@@ -0,0 +1,62 @@
// SPDX-License-Identifier: MIT
#ifndef RGBDS_ASM_ACTIONS_HPP
#define RGBDS_ASM_ACTIONS_HPP
#include <optional>
#include <stddef.h>
#include <stdint.h>
#include <string>
#include <string_view>
#include <variant>
#include <vector>
#include "linkdefs.hpp" // AssertionType, RPNCommand
#include "asm/intern.hpp" // InternedStr
#include "asm/rpn.hpp" // Expression
struct AlignmentSpec {
uint8_t alignment;
uint16_t alignOfs;
};
void act_If(int32_t condition);
void act_Elif(int32_t condition);
void act_Else();
void act_Endc();
AlignmentSpec act_Alignment(int32_t alignment, int32_t alignOfs);
void act_Assert(AssertionType type, Expression const &expr, std::string const &message);
void act_StaticAssert(AssertionType type, int32_t condition, std::string const &message);
std::optional<std::string> act_ReadFile(std::string const &name, uint32_t maxLen);
uint32_t act_CharToNum(std::string const &str);
uint32_t act_StringToNum(std::string const &str);
int32_t act_CharVal(std::string const &str);
int32_t act_CharVal(std::string const &str, int32_t negIdx);
uint8_t act_StringByte(std::string const &str, int32_t negIdx);
size_t act_StringLen(std::string const &str, bool printErrors);
std::string
act_StringSlice(std::string const &str, int32_t negStart, std::optional<int32_t> negStop);
std::string act_StringSub(std::string const &str, int32_t negPos, std::optional<uint32_t> optLen);
size_t act_CharLen(std::string const &str);
std::string act_StringChar(std::string const &str, int32_t negIdx);
std::string act_CharSub(std::string const &str, int32_t negPos);
int32_t act_CharCmp(std::string_view str1, std::string_view str2);
std::string act_StringReplace(std::string_view str, std::string const &old, std::string const &rep);
std::string act_StringFormat(
std::string const &spec, std::vector<std::variant<uint32_t, std::string>> const &args
);
std::string act_SectionName(InternedStr symName);
void act_CompoundAssignment(InternedStr symName, RPNCommand op, int32_t constValue);
#endif // RGBDS_ASM_ACTIONS_HPP
-42
View File
@@ -1,42 +0,0 @@
/*
* This file is part of RGBDS.
*
* Copyright (c) 1997-2018, Carsten Sorensen and RGBDS contributors.
*
* SPDX-License-Identifier: MIT
*/
/*
* Contains some assembler-wide defines and externs
*/
#ifndef RGBDS_ASM_ASM_H
#define RGBDS_ASM_ASM_H
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include "asm/localasm.h"
#include "asm/symbol.h"
#define MAXUNIONS 128
#define MAXMACROARGS 99999
#define MAXINCPATHS 128
extern int32_t nLineNo;
extern uint32_t nTotalLines;
extern uint32_t nIFDepth;
extern bool skipElif;
extern uint32_t nUnionDepth;
extern uint32_t unionStart[MAXUNIONS];
extern uint32_t unionSize[MAXUNIONS];
extern char tzCurrentFileName[_MAX_PATH + 1];
extern struct Section *pCurrentSection;
extern bool oDontExpandStrings;
size_t symvaluetostring(char *dest, size_t maxLength, char *sym,
const char *mode);
#endif /* RGBDS_ASM_ASM_H */
-46
View File
@@ -1,46 +0,0 @@
/*
* This file is part of RGBDS.
*
* Copyright (c) 1997-2018, Carsten Sorensen and RGBDS contributors.
*
* SPDX-License-Identifier: MIT
*/
#ifndef RGBDS_ASM_CHARMAP_H
#define RGBDS_ASM_CHARMAP_H
#include <stdint.h>
#define MAXCHARMAPS 512
#define CHARMAPLENGTH 16
#define MAXCHARNODES (MAXCHARMAPS * CHARMAPLENGTH + 1)
/*
* A node for trie structure.
*/
struct Charnode {
uint8_t code; /* the value in a key-value pair. */
uint8_t isCode; /* has 1 if it's a code node, not just a bridge node. */
struct Charnode *next[256]; /* each index representing the next possible
* character from its current state.
*/
};
struct Charmap {
char name[MAXSYMLEN + 1];
int32_t charCount; /* user-side count. */
int32_t nodeCount; /* node-side count. */
struct Charnode nodes[MAXCHARNODES]; /* first node is reserved for the
* root node in charmap.
*/
};
void charmap_InitMain(void);
struct Charmap *charmap_New(const char *name, const char *baseName);
void charmap_Set(const char *name);
void charmap_Push(void);
void charmap_Pop(void);
int32_t charmap_Add(char *input, uint8_t output);
int32_t charmap_Convert(char **input);
#endif /* RGBDS_ASM_CHARMAP_H */
+32
View File
@@ -0,0 +1,32 @@
// SPDX-License-Identifier: MIT
#ifndef RGBDS_ASM_CHARMAP_HPP
#define RGBDS_ASM_CHARMAP_HPP
#include <optional>
#include <stddef.h>
#include <stdint.h>
#include <string>
#include <string_view>
#include <vector>
#include "asm/intern.hpp"
void charmap_Init();
bool charmap_ForEach(
void (*mapFunc)(InternedStr), void (*charFunc)(std::string const &, std::vector<int32_t>)
);
void charmap_New(InternedStr name, InternedStr const *baseName);
void charmap_Set(InternedStr name);
void charmap_Push();
void charmap_Pop();
void charmap_CheckStack();
void charmap_Add(std::string const &mapping, std::vector<int32_t> &&value);
bool charmap_HasChar(std::string const &mapping);
size_t charmap_CharSize(std::string const &mapping);
std::optional<int32_t> charmap_CharValue(std::string const &mapping, size_t idx);
std::vector<int32_t> charmap_Convert(std::string const &input);
size_t charmap_ConvertNext(std::string_view &input, std::vector<int32_t> *output);
std::string charmap_Reverse(std::vector<int32_t> const &value, bool &unique);
#endif // RGBDS_ASM_CHARMAP_HPP
+24
View File
@@ -0,0 +1,24 @@
// SPDX-License-Identifier: MIT
#ifndef RGBDS_ASM_FIXPOINT_HPP
#define RGBDS_ASM_FIXPOINT_HPP
#include <stdint.h>
int32_t fix_Sin(int32_t i, int32_t q);
int32_t fix_Cos(int32_t i, int32_t q);
int32_t fix_Tan(int32_t i, int32_t q);
int32_t fix_ASin(int32_t i, int32_t q);
int32_t fix_ACos(int32_t i, int32_t q);
int32_t fix_ATan(int32_t i, int32_t q);
int32_t fix_ATan2(int32_t i, int32_t j, int32_t q);
int32_t fix_Mul(int32_t i, int32_t j, int32_t q);
int32_t fix_Mod(int32_t i, int32_t j, int32_t q);
int32_t fix_Div(int32_t i, int32_t j, int32_t q);
int32_t fix_Pow(int32_t i, int32_t j, int32_t q);
int32_t fix_Log(int32_t i, int32_t j, int32_t q);
int32_t fix_Round(int32_t i, int32_t q);
int32_t fix_Ceil(int32_t i, int32_t q);
int32_t fix_Floor(int32_t i, int32_t q);
#endif // RGBDS_ASM_FIXPOINT_HPP
+33
View File
@@ -0,0 +1,33 @@
// SPDX-License-Identifier: MIT
#ifndef RGBDS_ASM_FORMAT_HPP
#define RGBDS_ASM_FORMAT_HPP
#include <stddef.h>
#include <stdint.h>
#include <string>
class FormatSpec {
int sign;
bool exact;
bool alignLeft;
bool padZero;
size_t width;
bool hasFrac;
size_t fracWidth;
bool hasPrec;
size_t precision;
int type;
bool parsed;
public:
bool isValid() const { return !!type; }
bool isParsed() const { return parsed; }
size_t parseSpec(char const *spec);
void appendString(std::string &str, std::string const &value) const;
void appendNumber(std::string &str, uint32_t value) const;
};
#endif // RGBDS_ASM_FORMAT_HPP
-56
View File
@@ -1,56 +0,0 @@
/*
* This file is part of RGBDS.
*
* Copyright (c) 1997-2018, Carsten Sorensen and RGBDS contributors.
*
* SPDX-License-Identifier: MIT
*/
/*
* Contains some assembler-wide defines and externs
*/
#ifndef RGBDS_ASM_FSTACK_H
#define RGBDS_ASM_FSTACK_H
#include <stdint.h>
#include <stdio.h>
#include "asm/asm.h"
#include "asm/lexer.h"
#include "types.h"
struct MacroArgs;
struct sContext {
YY_BUFFER_STATE FlexHandle;
struct Symbol const *pMacro;
struct sContext *pNext;
char tzFileName[_MAX_PATH + 1];
struct MacroArgs *macroArgs;
uint32_t uniqueID;
int32_t nLine;
uint32_t nStatus;
FILE *pFile;
char *pREPTBlock;
uint32_t nREPTBlockCount;
uint32_t nREPTBlockSize;
int32_t nREPTBodyFirstLine;
int32_t nREPTBodyLastLine;
};
extern unsigned int nMaxRecursionDepth;
void fstk_RunInclude(char *tzFileName);
void fstk_Init(char *s);
void fstk_Dump(void);
void fstk_DumpToStr(char *buf, size_t len);
void fstk_DumpStringExpansions(void);
void fstk_AddIncludePath(char *s);
void fstk_RunMacro(char *s, struct MacroArgs *args);
void fstk_RunRept(uint32_t count, int32_t nReptLineNo);
FILE *fstk_FindFile(char const *fname, char **incPathUsed);
int32_t fstk_GetLine(void);
#endif /* RGBDS_ASM_FSTACK_H */
+88
View File
@@ -0,0 +1,88 @@
// SPDX-License-Identifier: MIT
// Contains some assembler-wide defines and externs
#ifndef RGBDS_ASM_FSTACK_HPP
#define RGBDS_ASM_FSTACK_HPP
#include <memory>
#include <optional>
#include <stdint.h>
#include <stdio.h>
#include <string>
#include <variant>
#include <vector>
#include "linkdefs.hpp"
#include "asm/intern.hpp"
#include "asm/lexer.hpp"
struct FileStackNode {
FileStackNodeType type;
std::variant<
std::vector<uint32_t>, // NODE_REPT
std::string // NODE_FILE, NODE_MACRO
>
data;
bool isQuiet; // Whether to omit this node from error reporting
std::shared_ptr<FileStackNode> parent; // Pointer to parent node, for error reporting
// Line at which the parent context was exited
// Meaningless at the root level, but gets written to the object file anyway, so init it
uint32_t lineNo = 0;
// Set only if referenced: ID within the object file, `UINT32_MAX` if not output yet
uint32_t ID = UINT32_MAX;
// REPT iteration counts since last named node, in reverse depth order
std::vector<uint32_t> &iters() { return std::get<std::vector<uint32_t>>(data); }
std::vector<uint32_t> const &iters() const { return std::get<std::vector<uint32_t>>(data); }
// File name for files, file::macro name for macros
std::string &name() { return std::get<std::string>(data); }
std::string const &name() const { return std::get<std::string>(data); }
FileStackNode(
FileStackNodeType type_,
std::variant<std::vector<uint32_t>, std::string> data_,
bool isQuiet_
)
: type(type_), data(data_), isQuiet(isQuiet_) {}
void printBacktrace(uint32_t curLineNo) const;
};
struct MacroArgs;
void fstk_VerboseOutputConfig();
void fstk_TraceCurrent();
std::shared_ptr<FileStackNode> fstk_GetFileStack();
std::shared_ptr<std::string> fstk_GetUniqueIDStr();
MacroArgs *fstk_GetCurrentMacroArgs();
void fstk_AddIncludePath(std::string const &path);
void fstk_AddPreIncludeFile(std::string const &path);
std::optional<std::string> fstk_FindFile(std::string const &path);
bool fstk_FileError(std::string const &path, char const *description);
bool fstk_FailedOnMissingInclude();
bool yywrap();
bool fstk_RunInclude(std::string const &path, bool isQuiet);
void fstk_RunMacro(InternedStr macroName, std::shared_ptr<MacroArgs> macroArgs, bool isQuiet);
void fstk_RunRept(uint32_t count, int32_t reptLineNo, ContentSpan const &span, bool isQuiet);
void fstk_RunFor(
InternedStr symName,
int32_t start,
int32_t stop,
int32_t step,
int32_t reptLineNo,
ContentSpan const &span,
bool isQuiet
);
bool fstk_Break();
void fstk_NewRecursionDepth(size_t newDepth);
bool fstk_Init(std::string const &mainPath);
#endif // RGBDS_ASM_FSTACK_HPP
+34
View File
@@ -0,0 +1,34 @@
// SPDX-License-Identifier: MIT
#ifndef RGBDS_ASM_INTERN_HPP
#define RGBDS_ASM_INTERN_HPP
#include <stddef.h>
#include <string>
#include <string_view>
#include <utility> // hash
class InternedStr {
size_t index;
public:
constexpr InternedStr() : index(static_cast<size_t>(-1)) {}
explicit constexpr InternedStr(size_t index_) : index(index_) {}
std::string const &str() const;
char const *c_str() const { return str().c_str(); }
bool operator==(InternedStr const &rhs) const { return index == rhs.index; }
template<typename T>
friend struct std::hash;
};
template<>
struct std::hash<InternedStr> {
size_t operator()(InternedStr const &str) const { return std::hash<size_t>{}(str.index); }
};
InternedStr intern(std::string_view str);
#endif // RGBDS_ASM_INTERN_HPP
-86
View File
@@ -1,86 +0,0 @@
/*
* This file is part of RGBDS.
*
* Copyright (c) 1997-2018, Carsten Sorensen and RGBDS contributors.
*
* SPDX-License-Identifier: MIT
*/
#ifndef RGBDS_ASM_LEXER_H
#define RGBDS_ASM_LEXER_H
#include <stdint.h>
#include <stdio.h>
#define LEXHASHSIZE (1 << 11)
#define MAXSTRLEN 255
struct sLexInitString {
char *tzName;
uint32_t nToken;
};
struct sLexFloat {
uint32_t (*Callback)(char *s, uint32_t size);
uint32_t nToken;
};
struct yy_buffer_state {
/* Actual starting address */
char *pBufferRealStart;
/* Address where the data is initially written after a safety margin */
char *pBufferStart;
char *pBuffer;
size_t nBufferSize;
uint32_t oAtLineStart;
};
enum eLexerState {
LEX_STATE_NORMAL,
LEX_STATE_MACROARGS
};
struct sStringExpansionPos {
char *tzName;
char *pBuffer;
char *pBufferPos;
struct sStringExpansionPos *pParent;
};
#define INITIAL 0
#define macroarg 3
typedef struct yy_buffer_state *YY_BUFFER_STATE;
void setup_lexer(void);
void yy_set_state(enum eLexerState i);
YY_BUFFER_STATE yy_create_buffer(FILE *f);
YY_BUFFER_STATE yy_scan_bytes(char const *mem, uint32_t size);
void yy_delete_buffer(YY_BUFFER_STATE buf);
void yy_switch_to_buffer(YY_BUFFER_STATE buf);
uint32_t lex_FloatAlloc(const struct sLexFloat *tok);
void lex_FloatAddRange(uint32_t id, uint16_t start, uint16_t end);
void lex_FloatDeleteRange(uint32_t id, uint16_t start, uint16_t end);
void lex_FloatAddFirstRange(uint32_t id, uint16_t start, uint16_t end);
void lex_FloatDeleteFirstRange(uint32_t id, uint16_t start, uint16_t end);
void lex_FloatAddSecondRange(uint32_t id, uint16_t start, uint16_t end);
void lex_FloatDeleteSecondRange(uint32_t id, uint16_t start, uint16_t end);
void lex_Init(void);
void lex_AddStrings(const struct sLexInitString *lex);
void lex_SetBuffer(char *buffer, uint32_t len);
void lex_BeginStringExpansion(const char *tzName);
int yywrap(void);
int yylex(void);
void yyunput(char c);
void yyunputstr(const char *s);
void yyskipbytes(uint32_t count);
void yyunputbytes(uint32_t count);
extern YY_BUFFER_STATE pCurrentBuffer;
extern struct sStringExpansionPos *pCurrentStringExpansion;
void upperstring(char *s);
void lowerstring(char *s);
#endif /* RGBDS_ASM_LEXER_H */
+107
View File
@@ -0,0 +1,107 @@
// SPDX-License-Identifier: MIT
#ifndef RGBDS_ASM_LEXER_HPP
#define RGBDS_ASM_LEXER_HPP
#include <deque>
#include <memory>
#include <optional>
#include <stddef.h>
#include <stdint.h>
#include <string>
#include <vector>
#include "asm/intern.hpp"
enum LexerMode {
LEXER_NORMAL,
LEXER_RAW,
LEXER_SKIP_TO_ELIF,
LEXER_SKIP_TO_ENDC,
LEXER_SKIP_TO_ENDR,
NB_LEXER_MODES
};
struct Expansion {
std::optional<InternedStr> name;
std::shared_ptr<std::string> contents;
size_t offset; // Cursor into `contents`
size_t size() const { return contents->size(); }
bool advance(); // Increment `offset`; return whether it then exceeds `contents`
};
struct ContentSpan {
std::shared_ptr<char[]> ptr;
size_t size;
};
struct IfStackEntry {
bool ranIfBlock; // Whether an IF/ELIF/ELSE block ran already
bool reachedElseBlock; // Whether an ELSE block ran already
};
struct LexerState {
std::string path;
LexerMode mode;
bool atLineStart;
uint32_t lineNo;
int lastToken;
int nextToken;
std::deque<IfStackEntry> ifStack; // Front is the innermost `IF` block
bool capturing; // Whether the text being lexed should be captured
size_t captureSize; // Amount of text captured
std::shared_ptr<std::vector<char>> captureBuf; // Buffer to send the captured text to if set
bool enableExpansions;
bool enableStringExpansions;
size_t expansionScanDistance; // Max distance already scanned for expansions
std::deque<Expansion> expansionStack; // Front is the innermost current expansion
ContentSpan content; // Span of chars
size_t offset = 0; // Cursor into `content.ptr`
~LexerState();
int peekChar();
int peekCharAhead();
void setAsCurrentState();
void setFileAsNextState(std::string const &filePath, bool updateStateNow);
void setViewAsNextState(char const *name, ContentSpan const &content_, uint32_t lineNo_);
void clear(uint32_t lineNo_);
};
void lexer_SetBinDigits(char const digits[2]);
void lexer_SetGfxDigits(char const digits[4]);
bool lexer_AtTopLevel();
void lexer_RestartRept(uint32_t lineNo);
void lexer_SetMode(LexerMode mode);
void lexer_ToggleStringExpansion(bool enable);
uint32_t lexer_GetIFDepth();
void lexer_IncIFDepth();
void lexer_DecIFDepth();
bool lexer_RanIFBlock();
bool lexer_ReachedELSEBlock();
void lexer_RunIFBlock();
void lexer_ReachELSEBlock();
void lexer_CheckRecursionDepth();
uint32_t lexer_GetLineNo();
void lexer_TraceStringExpansions();
struct Capture {
uint32_t lineNo;
ContentSpan span;
};
Capture lexer_CaptureRept();
Capture lexer_CaptureMacro();
#endif // RGBDS_ASM_LEXER_HPP
-131
View File
@@ -1,131 +0,0 @@
/*
* This file is part of RGBDS.
*
* Copyright (c) 1997-2018, Carsten Sorensen and RGBDS contributors.
*
* SPDX-License-Identifier: MIT
*/
#ifndef RGBDS_ASM_LOCALASM_H
#define RGBDS_ASM_LOCALASM_H
/*
* GB Z80 instruction groups
*
* n3 = 3-bit
* n = 8-bit
* nn = 16-bit
*
* ADC A,n : 0xCE
* ADC A,r : 0x88|r
* ADD A,n : 0xC6
* ADD A,r : 0x80|r
* ADD HL,ss : 0x09|(ss<<4)
* ADD SP,n : 0xE8
* AND A,n : 0xE6
* AND A,r : 0xA0|r
* BIT n3,r : 0xCB 0x40|(n3<<3)|r
* CALL cc,nn : 0xC4|(cc<<3)
* CALL nn : 0xCD
* CCF : 0x3F
* CP A,n : 0xFE
* CP A,r : 0xB8|r
* CPL : 0x2F
* DAA : 0x27
* DEC r : 0x05|(r<<3)
* DEC ss : 0x0B|(ss<<4)
* DI : 0xF3
* EI : 0xFB
* HALT : 0x76
* INC r : 0x04|(r<<3)
* INC ss : 0x03|(ss<<4)
* JP HL : 0xE9
* JP cc,nn : 0xC2|(cc<<3)
* JP nn : 0xC3|(cc<<3)
* JR n : 0x18
* JR cc,n : 0x20|(cc<<3)
* LD (nn),SP : 0x08
* LD ($FF00+C),A : 0xE2
* LD ($FF00+n),A : 0xE0
* LD (nn),A : 0xEA
* LD (rr),A : 0x02|(rr<<4) // HL+ and HL- included
* LD A,($FF00+C) : 0xF2
* LD A,($FF00+n) : 0xF0
* LD A,(nn) : 0xFA
* LD A,(rr) : 0x0A|(rr<<4) // HL+ and HL- included
* LD HL,SP+n : 0xF8
* LD SP,HL : 0xF9
* LD r,n : 0x06|(r<<3)
* LD r,r' : 0x40|(r<<3)|r' // NOTE: LD (HL),(HL) not allowed
* LD ss,nn : 0x01|(ss<<4)
* NOP : 0x00
* OR A,n : 0xF6
* OR A,r : 0xB0|r
* POP tt : 0xC1|(tt<<4)
* PUSH tt : 0xC5|(tt<<4)
* RES n3,r : 0xCB 0x80|(n3<<3)|r
* RET : 0xC9
* RET cc : 0xC0|(cc<<3)
* RETI : 0xD9
* RL r : 0xCB 0x10|r
* RLA : 0x17
* RLC r : 0xCB 0x00|r
* RLCA : 0x07
* RR r : 0xCB 0x18|r
* RRA : 0x1F
* RRC r : 0xCB 0x08|r
* RRCA : 0x0F
* RST n : 0xC7|n
* SBC A,n : 0xDE
* SBC A,r : 0x98|r
* SCF : 0x37
* SET n3,r : 0xCB 0xC0|(n8<<3)|r
* SLA r : 0xCB 0x20|r
* SRA r : 0xCB 0x28|r
* SRL r : 0xCB 0x38|r
* STOP : 0x10 0x00
* SUB A,n : 0xD6
* SUB A,r : 0x90|r
* SWAP r : 0xCB 0x30|r
* XOR A,n : 0xEE
* XOR A,r : 0xA8|r
*/
/* "r" defs */
enum {
REG_B = 0,
REG_C,
REG_D,
REG_E,
REG_H,
REG_L,
REG_HL_IND,
REG_A
};
/* "rr" defs */
enum {
REG_BC_IND = 0,
REG_DE_IND,
REG_HL_INDINC,
REG_HL_INDDEC,
};
/* "ss" defs (SP) and "tt" defs (AF) */
enum {
REG_BC = 0,
REG_DE = 1,
REG_HL = 2,
REG_SP = 3,
REG_AF = 3
};
/* "cc" defs */
enum {
CC_NZ = 0,
CC_Z,
CC_NC,
CC_C
};
#endif /* RGBDS_ASM_LOCALASM_H */
-34
View File
@@ -1,34 +0,0 @@
/*
* This file is part of RGBDS.
*
* Copyright (c) 2020, Carsten Sorensen and RGBDS contributors.
*
* SPDX-License-Identifier: MIT
*/
#ifndef RGBDS_MACRO_H
#define RGBDS_MACRO_H
#include <stdint.h>
#include <stdlib.h>
#include "asm/warning.h"
#include "helpers.h"
struct MacroArgs;
struct MacroArgs *macro_GetCurrentArgs(void);
struct MacroArgs *macro_NewArgs(void);
void macro_AppendArg(struct MacroArgs **args, char *s);
void macro_UseNewArgs(struct MacroArgs *args);
void macro_FreeArgs(struct MacroArgs *args);
char const *macro_GetArg(uint32_t i);
uint32_t macro_GetUniqueID(void);
char const *macro_GetUniqueIDStr(void);
void macro_SetUniqueID(uint32_t id);
void macro_ShiftCurrentArgs(void);
uint32_t macro_NbArgs(void);
#endif
+23
View File
@@ -0,0 +1,23 @@
// SPDX-License-Identifier: MIT
#ifndef RGBDS_ASM_MACRO_HPP
#define RGBDS_ASM_MACRO_HPP
#include <memory>
#include <stdint.h>
#include <string>
#include <vector>
struct MacroArgs {
uint32_t shift;
std::vector<std::shared_ptr<std::string>> args;
uint32_t nbArgs() const { return args.size() - shift; }
std::shared_ptr<std::string> getArg(int32_t num) const;
std::shared_ptr<std::string> getAllArgs() const;
void appendArg(std::shared_ptr<std::string> arg);
void shiftArgs(int32_t count);
};
#endif // RGBDS_ASM_MACRO_HPP
-55
View File
@@ -1,55 +0,0 @@
/*
* This file is part of RGBDS.
*
* Copyright (c) 1997-2018, Carsten Sorensen and RGBDS contributors.
*
* SPDX-License-Identifier: MIT
*/
#ifndef RGBDS_MAIN_H
#define RGBDS_MAIN_H
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include "helpers.h"
struct sOptions {
char binary[2];
char gbgfx[4];
int32_t fillchar;
};
extern char *tzNewMacro;
extern uint32_t ulNewMacroSize;
extern int32_t nGBGfxID;
extern int32_t nBinaryID;
extern uint32_t curOffset; /* Offset into the current section */
extern struct sOptions DefaultOptions;
extern struct sOptions CurrentOptions;
extern bool haltnop;
extern bool optimizeloads;
extern bool verbose;
extern bool warnings; /* True to enable warnings, false to disable them. */
extern FILE *dependfile;
extern char *tzTargetFileName;
extern bool oGeneratedMissingIncludes;
extern bool oFailedOnMissingInclude;
extern bool oGeneratePhonyDeps;
void opt_Push(void);
void opt_Pop(void);
void opt_Parse(char *s);
#define YY_FATAL_ERROR fatalerror
#ifdef YYLMAX
#undef YYLMAX
#endif
#define YYLMAX 65536
#endif /* RGBDS_MAIN_H */
+50
View File
@@ -0,0 +1,50 @@
// SPDX-License-Identifier: MIT
#ifndef RGBDS_ASM_MAIN_HPP
#define RGBDS_ASM_MAIN_HPP
#include <optional>
#include <stdint.h>
#include <stdio.h>
#include <string>
#include "helpers.hpp" // assume
#include "util.hpp" // xfclose
enum MissingInclude {
INC_ERROR, // A missing included file is an error that halts assembly
GEN_EXIT, // A missing included file is assumed to be generated; exit normally
GEN_CONTINUE, // A missing included file is assumed to be generated; continue assembling
};
struct Options {
bool exportAll = false; // -E
uint8_t fixPrecision = 16; // -Q
size_t maxRecursionDepth = 64; // -r
char binDigits[2] = {'0', '1'}; // -b
char gfxDigits[4] = {'0', '1', '2', '3'}; // -g
FILE *dependFile = nullptr; // -M
std::optional<std::string> targetFileName{}; // -MQ, -MT
MissingInclude missingIncludeState = INC_ERROR; // -MC, -MG
bool generatePhonyDeps = false; // -MP
std::optional<std::string> objectFileName{}; // -o
uint8_t padByte = 0; // -p
uint64_t maxErrors = 0; // -X
~Options() {
if (dependFile) {
xfclose(dependFile);
}
}
void printDep(std::string const &depName) {
if (dependFile) {
assume(targetFileName.has_value());
fprintf(dependFile, "%s: %s\n", targetFileName->c_str(), depName.c_str());
}
}
};
extern Options options;
#endif // RGBDS_ASM_MAIN_HPP
-29
View File
@@ -1,29 +0,0 @@
/*
* This file is part of RGBDS.
*
* Copyright (c) 1997-2018, Carsten Sorensen and RGBDS contributors.
*
* SPDX-License-Identifier: MIT
*/
#ifndef RGBDS_ASM_MATH_H
#define RGBDS_ASM_MATH_H
#include <stdint.h>
void math_DefinePI(void);
void math_Print(int32_t i);
int32_t math_Sin(int32_t i);
int32_t math_Cos(int32_t i);
int32_t math_Tan(int32_t i);
int32_t math_ASin(int32_t i);
int32_t math_ACos(int32_t i);
int32_t math_ATan(int32_t i);
int32_t math_ATan2(int32_t i, int32_t j);
int32_t math_Mul(int32_t i, int32_t j);
int32_t math_Div(int32_t i, int32_t j);
int32_t math_Round(int32_t i);
int32_t math_Ceil(int32_t i);
int32_t math_Floor(int32_t i);
#endif /* RGBDS_ASM_MATH_H */
+19
View File
@@ -0,0 +1,19 @@
// SPDX-License-Identifier: MIT
#ifndef RGBDS_ASM_OPT_HPP
#define RGBDS_ASM_OPT_HPP
#include <stdint.h>
void opt_B(char const binDigits[2]);
void opt_G(char const gfxDigits[4]);
void opt_P(uint8_t padByte);
void opt_Q(uint8_t fixPrecision);
void opt_W(char const *flag);
void opt_Parse(char const *option);
void opt_Push();
void opt_Pop();
void opt_CheckStack();
#endif // RGBDS_ASM_OPT_HPP
-28
View File
@@ -1,28 +0,0 @@
/*
* This file is part of RGBDS.
*
* Copyright (c) 1997-2018, Carsten Sorensen and RGBDS contributors.
*
* SPDX-License-Identifier: MIT
*/
#ifndef RGBDS_ASM_OUTPUT_H
#define RGBDS_ASM_OUTPUT_H
#include <stdint.h>
#include "linkdefs.h"
struct Expression;
extern char *tzObjectname;
extern struct Section *pSectionList, *pCurrentSection;
void out_SetFileName(char *s);
void out_CreatePatch(uint32_t type, struct Expression const *expr,
uint32_t ofs);
bool out_CreateAssert(enum AssertionType type, struct Expression const *expr,
char const *message, uint32_t ofs);
void out_WriteObject(void);
#endif /* RGBDS_ASM_OUTPUT_H */
+28
View File
@@ -0,0 +1,28 @@
// SPDX-License-Identifier: MIT
#ifndef RGBDS_ASM_OUTPUT_HPP
#define RGBDS_ASM_OUTPUT_HPP
#include <memory>
#include <stdint.h>
#include <string>
#include <vector>
#include "linkdefs.hpp"
struct Expression;
struct FileStackNode;
struct Symbol;
enum StateFeature { STATE_EQU, STATE_VAR, STATE_EQUS, STATE_CHAR, STATE_MACRO, NB_STATE_FEATURES };
void out_RegisterNode(std::shared_ptr<FileStackNode> node);
void out_RegisterSymbol(Symbol &sym);
void out_CreatePatch(uint32_t type, Expression const &expr, uint32_t ofs, uint32_t pcShift);
void out_CreateAssert(
AssertionType type, Expression const &expr, std::string const &message, uint32_t ofs
);
void out_WriteObject();
void out_WriteState(std::string name, std::vector<StateFeature> const &features);
#endif // RGBDS_ASM_OUTPUT_HPP
-67
View File
@@ -1,67 +0,0 @@
/*
* This file is part of RGBDS.
*
* Copyright (c) 1997-2018, Carsten Sorensen and RGBDS contributors.
*
* SPDX-License-Identifier: MIT
*/
#ifndef RGBDS_ASM_RPN_H
#define RGBDS_ASM_RPN_H
#include <stdint.h>
#include <stdbool.h>
#include "linkdefs.h"
#define MAXRPNLEN 1048576
struct Expression {
int32_t nVal; // If the expression's value is known, it's here
char *reason; // Why the expression is not known, if it isn't
bool isKnown; // Whether the expression's value is known
bool isSymbol; // Whether the expression represents a symbol
uint8_t *tRPN; // Array of bytes serializing the RPN expression
uint32_t nRPNCapacity; // Size of the `tRPN` buffer
uint32_t nRPNLength; // Used size of the `tRPN` buffer
uint32_t nRPNPatchSize; // Size the expression will take in the obj file
};
/* FIXME: Should be defined in `asmy.h`, but impossible with POSIX Yacc */
extern int32_t nPCOffset;
/*
* Determines if an expression is known at assembly time
*/
static inline bool rpn_isKnown(const struct Expression *expr)
{
return expr->isKnown;
}
/*
* Determines if an expression is a symbol suitable for const diffing
*/
static inline bool rpn_isSymbol(const struct Expression *expr)
{
return expr->isSymbol;
}
void rpn_Symbol(struct Expression *expr, char *tzSym);
void rpn_Number(struct Expression *expr, uint32_t i);
void rpn_LOGNOT(struct Expression *expr, const struct Expression *src);
void rpn_BinaryOp(enum RPNCommand op, struct Expression *expr,
const struct Expression *src1,
const struct Expression *src2);
void rpn_HIGH(struct Expression *expr, const struct Expression *src);
void rpn_LOW(struct Expression *expr, const struct Expression *src);
void rpn_ISCONST(struct Expression *expr, const struct Expression *src);
void rpn_UNNEG(struct Expression *expr, const struct Expression *src);
void rpn_UNNOT(struct Expression *expr, const struct Expression *src);
void rpn_BankSymbol(struct Expression *expr, char const *tzSym);
void rpn_BankSection(struct Expression *expr, char const *tzSectionName);
void rpn_BankSelf(struct Expression *expr);
void rpn_Free(struct Expression *expr);
void rpn_CheckHRAM(struct Expression *expr, const struct Expression *src);
void rpn_CheckRST(struct Expression *expr, const struct Expression *src);
#endif /* RGBDS_ASM_RPN_H */
+66
View File
@@ -0,0 +1,66 @@
// SPDX-License-Identifier: MIT
#ifndef RGBDS_ASM_RPN_HPP
#define RGBDS_ASM_RPN_HPP
#include <stdint.h>
#include <string>
#include <variant>
#include <vector>
#include "linkdefs.hpp"
#include "asm/intern.hpp"
struct Symbol;
struct RPNValue {
RPNCommand command; // The RPN_* command ID
std::variant<std::monostate, uint8_t, uint32_t, InternedStr> data; // Data after the ID, if any
RPNValue(RPNCommand cmd);
RPNValue(RPNCommand cmd, uint8_t val);
RPNValue(RPNCommand cmd, uint32_t val);
RPNValue(RPNCommand cmd, InternedStr name);
void appendEncoded(std::vector<uint8_t> &buffer) const;
};
struct Expression {
std::variant<
int32_t, // If the expression's value is known, it's here
std::string // Why the expression is not known, if it isn't
>
data = 0;
std::vector<RPNValue> rpn{}; // Values to be serialized into the RPN expression
bool isKnown() const { return std::holds_alternative<int32_t>(data); }
int32_t value() const { return std::get<int32_t>(data); }
int32_t getConstVal() const;
Symbol const *symbolOf() const;
bool isDiffConstant(Symbol const *symName) const;
void makeNumber(uint32_t value);
void makeSymbol(InternedStr symName);
void makeBankSymbol(InternedStr symName);
void makeBankSection(std::string const &sectName);
void makeSizeOfSection(std::string const &sectName);
void makeStartOfSection(std::string const &sectName);
void makeSizeOfSectionType(SectionType type);
void makeStartOfSectionType(SectionType type);
void makeUnaryOp(RPNCommand op, Expression &&src);
void makeBinaryOp(RPNCommand op, Expression &&src1, Expression const &src2);
void addCheckHRAM();
void addCheckRST();
void addCheckBitIndex(uint8_t mask);
void checkNBit(uint8_t n) const;
void encode(std::vector<uint8_t> &buffer) const;
};
bool checkNBit(int32_t v, uint8_t n, char const *name);
#endif // RGBDS_ASM_RPN_HPP
-66
View File
@@ -1,66 +0,0 @@
/*
* This file is part of RGBDS.
*
* Copyright (c) 2020, Carsten Sorensen and RGBDS contributors.
*
* SPDX-License-Identifier: MIT
*/
#ifndef RGBDS_SECTION_H
#define RGBDS_SECTION_H
#include <stdint.h>
#include <stdbool.h>
#include "linkdefs.h"
struct Expression;
struct Section {
char *pzName;
enum SectionType nType;
enum SectionModifier modifier;
uint32_t size;
uint32_t nOrg;
uint32_t nBank;
uint8_t nAlign;
uint16_t alignOfs;
struct Section *pNext;
struct Patch *pPatches;
uint8_t *tData;
};
struct SectionSpec {
uint32_t bank;
uint8_t alignment;
uint16_t alignOfs;
};
struct Section *out_FindSectionByName(const char *pzName);
void out_NewSection(char const *pzName, uint32_t secttype, uint32_t org,
struct SectionSpec const *attributes,
enum SectionModifier mod);
void out_SetLoadSection(char const *name, uint32_t secttype, uint32_t org,
struct SectionSpec const *attributes);
void out_EndLoadSection(void);
struct Section *sect_GetSymbolSection(void);
uint32_t sect_GetOutputOffset(void);
void sect_AlignPC(uint8_t alignment, uint16_t offset);
void out_AbsByte(uint8_t b);
void out_AbsByteGroup(uint8_t const *s, int32_t length);
void out_Skip(int32_t skip, bool ds);
void out_String(char const *s);
void out_RelByte(struct Expression *expr);
void out_RelBytes(struct Expression *expr, uint32_t n);
void out_RelWord(struct Expression *expr);
void out_RelLong(struct Expression *expr);
void out_PCRelByte(struct Expression *expr);
void out_BinaryFile(char const *s);
void out_BinaryFileSlice(char const *s, int32_t start_pos, int32_t length);
void out_PushSection(void);
void out_PopSection(void);
#endif
+113
View File
@@ -0,0 +1,113 @@
// SPDX-License-Identifier: MIT
#ifndef RGBDS_ASM_SECTION_HPP
#define RGBDS_ASM_SECTION_HPP
#include <deque>
#include <memory>
#include <optional>
#include <stddef.h>
#include <stdint.h>
#include <string>
#include <vector>
#include "intern.hpp"
#include "linkdefs.hpp"
struct Expression;
struct FileStackNode;
struct Section;
struct Patch {
std::shared_ptr<FileStackNode> src;
uint32_t lineNo;
uint32_t offset;
Section *pcSection;
uint32_t pcOffset;
uint8_t type;
std::vector<uint8_t> rpn;
};
struct Section {
std::string name;
SectionType type;
SectionModifier modifier;
std::shared_ptr<FileStackNode> src; // Where the section was defined
uint32_t fileLine; // Line where the section was defined
uint32_t size;
uint32_t org;
uint32_t bank;
uint8_t align; // Exactly as specified in `ALIGN[]`
uint16_t alignOfs;
std::deque<Patch> patches;
std::vector<uint8_t> data;
uint32_t getID() const; // ID of the section in the object file (`UINT32_MAX` if none)
bool isSizeKnown() const;
};
struct SectionSpec {
uint32_t bank;
uint8_t alignment;
uint16_t alignOfs;
};
size_t sect_CountSections();
void sect_ForEach(void (*callback)(Section &));
Section *sect_FindSectionByName(std::string const &name);
void sect_NewSection(
std::string const &name,
SectionType type,
uint32_t org,
SectionSpec const &attrs,
SectionModifier mod
);
void sect_SetLoadSection(
std::string const &name,
SectionType type,
uint32_t org,
SectionSpec const &attrs,
SectionModifier mod
);
void sect_EndLoadSection(char const *cause);
void sect_CheckLoadClosed();
Section *sect_GetSymbolSection();
uint32_t sect_GetSymbolOffset();
uint32_t sect_GetOutputOffset();
std::optional<uint32_t> sect_GetOutputBank();
Patch *sect_AddOutputPatch();
uint32_t sect_GetAlignBytes(uint8_t alignment, uint16_t offset);
void sect_AlignPC(uint8_t alignment, uint16_t offset);
void sect_CheckSizes();
void sect_StartUnion();
void sect_NextUnionMember();
void sect_EndUnion();
void sect_CheckUnionClosed();
void sect_ConstByte(uint8_t byte);
void sect_ByteString(std::vector<int32_t> const &str);
void sect_WordString(std::vector<int32_t> const &str);
void sect_LongString(std::vector<int32_t> const &str);
void sect_Skip(uint32_t skip, bool ds);
void sect_RelByte(Expression const &expr, uint32_t pcShift);
void sect_RelBytes(uint32_t n, std::vector<Expression> const &exprs);
void sect_RelWord(Expression const &expr, uint32_t pcShift);
void sect_RelLong(Expression const &expr, uint32_t pcShift);
void sect_PCRelByte(Expression const &expr, uint32_t pcShift);
bool sect_BinaryFile(std::string const &name, uint32_t startPos);
bool sect_BinaryFileSlice(std::string const &name, uint32_t startPos, uint32_t length);
void sect_EndSection();
void sect_PushSection();
void sect_PopSection();
void sect_CheckStack();
InternedStr sect_PushSectionFragmentLiteral();
#endif // RGBDS_ASM_SECTION_HPP
-131
View File
@@ -1,131 +0,0 @@
/*
* This file is part of RGBDS.
*
* Copyright (c) 1997-2020, Carsten Sorensen and RGBDS contributors.
*
* SPDX-License-Identifier: MIT
*/
#ifndef RGBDS_SYMBOL_H
#define RGBDS_SYMBOL_H
#include <stdbool.h>
#include <stdint.h>
#include <string.h>
#include "asm/section.h"
#include "types.h"
#define HASHSIZE (1 << 16)
#define MAXSYMLEN 256
enum SymbolType {
SYM_LABEL,
SYM_EQU,
SYM_SET,
SYM_MACRO,
SYM_EQUS,
SYM_REF // Forward reference to a label
};
struct Symbol {
char name[MAXSYMLEN + 1];
enum SymbolType type;
bool isExported; /* Whether the symbol is to be exported */
bool isBuiltin; /* Whether the symbol is a built-in */
struct Symbol const *scope;
struct Section *section;
char fileName[_MAX_PATH + 1]; /* File where the symbol was defined. */
uint32_t fileLine; /* Line where the symbol was defined. */
union {
struct { /* If sym_IsNumeric */
int32_t value;
int32_t (*callback)(void);
};
struct { /* For SYM_MACRO */
uint32_t macroSize;
char *macro;
};
};
uint32_t ID; /* ID of the symbol in the object file (-1 if none) */
struct Symbol *next; /* Next object to output in the object file */
};
bool sym_IsPC(struct Symbol const *sym);
static inline bool sym_IsDefined(struct Symbol const *sym)
{
return sym->type != SYM_REF;
}
static inline struct Section *sym_GetSection(struct Symbol const *sym)
{
return sym_IsPC(sym) ? sect_GetSymbolSection() : sym->section;
}
static inline bool sym_IsConstant(struct Symbol const *sym)
{
if (sym->type == SYM_LABEL) {
struct Section const *sect = sym_GetSection(sym);
return sect && sect->nOrg != -1;
}
return sym->type == SYM_EQU || sym->type == SYM_SET;
}
static inline bool sym_IsNumeric(struct Symbol const *sym)
{
return sym->type == SYM_LABEL || sym->type == SYM_EQU
|| sym->type == SYM_SET;
}
static inline bool sym_IsLabel(struct Symbol const *sym)
{
return sym->type == SYM_LABEL || sym->type == SYM_REF;
}
static inline bool sym_IsLocal(struct Symbol const *sym)
{
return sym_IsLabel(sym) && strchr(sym->name, '.');
}
static inline bool sym_IsExported(struct Symbol const *sym)
{
return sym->isExported;
}
/*
* Get a string equate's value
*/
static inline char const *sym_GetStringValue(struct Symbol const *sym)
{
return sym->macro;
}
void sym_ForEach(void (*func)(struct Symbol *, void *), void *arg);
int32_t sym_GetValue(struct Symbol const *sym);
void sym_SetExportAll(bool set);
struct Symbol *sym_AddLocalReloc(char const *symName);
struct Symbol *sym_AddReloc(char const *symName);
void sym_Export(char const *symName);
struct Symbol *sym_AddEqu(char const *symName, int32_t value);
struct Symbol *sym_AddSet(char const *symName, int32_t value);
uint32_t sym_GetPCValue(void);
uint32_t sym_GetConstantValue(char const *s);
struct Symbol *sym_FindSymbol(char const *symName);
struct Symbol *sym_AddMacro(char const *symName, int32_t defLineNo);
struct Symbol *sym_Ref(char const *symName);
struct Symbol *sym_AddString(char const *symName, char const *value);
uint32_t sym_GetDefinedValue(char const *s);
void sym_Purge(char const *symName);
void sym_Init(void);
/* Functions to save and restore the current symbol scope. */
struct Symbol *sym_GetCurrentSymbolScope(void);
void sym_SetCurrentSymbolScope(struct Symbol *newScope);
#endif /* RGBDS_SYMBOL_H */
+107
View File
@@ -0,0 +1,107 @@
// SPDX-License-Identifier: MIT
#ifndef RGBDS_ASM_SYMBOL_HPP
#define RGBDS_ASM_SYMBOL_HPP
#include <memory>
#include <stdint.h>
#include <string>
#include <time.h>
#include <utility>
#include <variant>
#include "asm/intern.hpp"
#include "asm/lexer.hpp"
#include "asm/section.hpp"
enum SymbolType {
SYM_LABEL,
SYM_EQU,
SYM_VAR,
SYM_MACRO,
SYM_EQUS,
SYM_REF // Forward reference to a label
};
struct Symbol; // Forward declaration for `sym_IsPC`
bool sym_IsPC(Symbol const *sym); // Forward declaration for `getSection`
struct Symbol {
InternedStr name;
SymbolType type;
bool isBuiltin;
bool isExported; // Not relevant for SYM_MACRO or SYM_EQUS
bool isQuiet; // Only relevant for SYM_MACRO
Section *section;
std::shared_ptr<FileStackNode> src; // Where the symbol was defined
uint32_t fileLine; // Line where the symbol was defined
std::variant<
int32_t, // If isNumeric()
int32_t (*)(), // If isNumeric() via a callback
ContentSpan, // For SYM_MACRO
std::shared_ptr<std::string>, // For SYM_EQUS
std::shared_ptr<std::string> (*)() // For SYM_EQUS via a callback
>
data;
uint32_t ID; // ID of the symbol in the object file (`UINT32_MAX` if none)
uint32_t defIndex; // Ordering of the symbol in the state file
bool isDefined() const { return type != SYM_REF; }
bool isNumeric() const { return type == SYM_LABEL || type == SYM_EQU || type == SYM_VAR; }
bool isLabel() const { return type == SYM_LABEL || type == SYM_REF; }
bool isConstant() const {
if (type == SYM_LABEL) {
Section const *sect = getSection();
return sect && sect->org != UINT32_MAX;
}
return type == SYM_EQU || type == SYM_VAR;
}
Section *getSection() const { return sym_IsPC(this) ? sect_GetSymbolSection() : section; }
int32_t getValue() const;
int32_t getOutputValue() const;
ContentSpan const &getMacro() const;
std::shared_ptr<std::string> getEqus() const;
uint32_t getConstantValue() const;
};
bool sym_IsDotScope(InternedStr symName);
void sym_ForEach(void (*callback)(Symbol &));
Symbol *sym_AddLocalLabel(InternedStr symName);
Symbol *sym_AddLabel(InternedStr symName);
Symbol *sym_AddAnonLabel();
InternedStr sym_MakeAnonLabelName(uint32_t ofs, bool neg);
void sym_Export(InternedStr symName);
Symbol *sym_AddEqu(InternedStr symName, int32_t value);
Symbol *sym_RedefEqu(InternedStr symName, int32_t value);
Symbol *sym_AddVar(InternedStr symName, int32_t value);
int32_t sym_GetRSValue();
void sym_SetRSValue(int32_t value);
// Find a symbol by exact name, bypassing expansion checks
Symbol *sym_FindExactSymbol(InternedStr symName);
// Find a symbol, possibly scoped, by name
Symbol *sym_FindScopedSymbol(InternedStr symName);
// Find a scoped symbol by name; do not return `@` or `_NARG` when they have no value
Symbol *sym_FindScopedValidSymbol(InternedStr symName);
Symbol const *sym_GetPC();
Symbol *sym_AddMacro(InternedStr symName, int32_t defLineNo, ContentSpan const &span, bool isQuiet);
Symbol *sym_Ref(InternedStr symName);
Symbol *sym_AddString(InternedStr symName, std::shared_ptr<std::string> value);
Symbol *sym_RedefString(InternedStr symName, std::shared_ptr<std::string> value);
void sym_Purge(InternedStr symName);
bool sym_IsPurgedExact(InternedStr symName);
bool sym_IsPurgedScoped(InternedStr symName);
void sym_Init(time_t now);
// Functions to save and restore the current label scopes.
std::pair<Symbol const *, Symbol const *> sym_GetCurrentLabelScopes();
void sym_SetCurrentLabelScopes(std::pair<Symbol const *, Symbol const *> newScopes);
void sym_ResetCurrentLabelScopes();
#endif // RGBDS_ASM_SYMBOL_HPP

Some files were not shown because too many files have changed in this diff Show More