Compare commits

...
3297 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
ISSOtm 8c0adb63a1 Sync release version in CMakeLists 2020-07-21 23:54:36 +02:00
ISSOtm f5b0c701a6 Add install hint to CMakeLists 2020-07-21 23:41:56 +02:00
ISSOtm 874bd92604 Only require libpng 1.2 in CMakeLists
This version is sufficient for rgbgfx to function properly, according to testing.
The security problems are not ours to decide, however!
2020-07-21 23:23:52 +02:00
ISSOtm 69a8c62863 Add install directives to CMakeLists
Otherwise `make install` or `cmake --install` does not work
2020-07-21 23:17:33 +02:00
ISSOtm 5481af5093 Release 0.4.1 2020-07-21 23:11:06 +02:00
ISSOtm 6355d0598b Regenerate docs for 0.4.1 2020-07-21 23:10:14 +02:00
Eldred Habert 1145d10996 Merge pull request #543 from ISSOtm/ubuntu20
Add Ubuntu 20.04 to CI
2020-07-21 22:24:28 +02:00
ISSOtm 32231e3f7e Add Ubuntu 20.04 to CI 2020-07-21 22:15:56 +02:00
Eldred Habert 29314f76f7 Merge pull request #533 from JL2210/platform-fixes
Add platform-specific fixes file (only for MSVC, currently)
2020-07-21 22:11:25 +02:00
ISSOtm 8e92383fa3 Enable -Wobsolete by default
The fact that deprecations were common and quickly acted upon was raised by
some users
2020-07-21 21:06:48 +02:00
James Larrowe e51701acaa Add platform-specific fixes file
Create a new file, platform.h, for platform-specific hacks

for MSVC, this includes defining strncasecmp to _stricmp and
strdup to _strdup, among other things like defining missing
stat macros

Change some things not supported in MSVC, like _Static_assert,
to their counterparts (in this case, static_assert)

Replace usage of VLAs with malloc and free

Update getopt_long and use the getopt implementation from musl
on Windows.

Use comments to show which functions from platform.h are being used
2020-07-21 14:24:22 -04:00
ISSOtm 0793e9effe Fix develop compilation error
This bug slipped by because my pre-commit hook for testing was broken...
2020-07-21 20:10:28 +02:00
ISSOtm c25b0be085 Document that -t and -w convert section types
This is also a fairly overdue doc update
2020-07-21 20:05:26 +02:00
ISSOtm 1f2f797cb9 Add section fragments
Fixes #517, and hopefully enables RGBDS as a SDCC back-end
2020-07-21 19:56:46 +02:00
ISSOtm aca00e4fce Document MP etc. in rgbasm(1)
This is actually kind of overdue...
2020-07-21 15:55:56 +02:00
Eldred Habert cf80293d9b Merge pull request #540 from daid/patch-1
Make the local variables of getopt static.
2020-07-21 13:11:30 +02:00
daid 6d53753c66 Make the local variables of getopt static.
While compiling for empscripten there is a duplicate symbol conflict with these two variables. And as they are only used locally, and do not need a symbol exported they can just be static.
2020-07-21 10:21:33 +02:00
Eldred Habert 79f293c3d7 Merge pull request #529 from JL2210/cmake
Add CMake build system
2020-07-20 16:02:47 +02:00
Eldred Habert 8c765883fb Merge pull request #536 from braydenm303/patch-1
Fix error in documentation about unary not
2020-07-20 15:11:29 +02:00
Brayden Morris 83aa456d05 Fix error in documentation about unary not 2020-07-13 09:32:43 -06:00
James R Larrowe 819c36943e Add CMake build system
This should hopefully work torwards compatibility with more systems.
I've tried to make this as general as possible but some small assumptions
about the compiler are made. I've also tried to recreate the build process
as closely as possible, but I had to change some things slightly to work
with CMake (version strings, mainly).

For now, it doesn't allow in-source builds, as that could overwrite the
Makefile.

This adds:

- Support for more build systems
- Automatic dependency generation
- Performance gains (especially when using i.e. Ninja)

Defaults to Release build.
2020-07-03 15:10:18 -04:00
Eldred Habert 8b60efa149 Merge pull request #530 from JL2210/fix-clang
Fix Clang warning in linkdefs
2020-06-27 22:07:19 +02:00
James Larrowe 240fca0861 Fix Clang warning in linkdefs
This one's really stupid; printing an int with %hhu gives a warning
even though a regular unsigned char is promoted to an int before
printing anyway. Silence it so the build with Clang works.

This is a regression introduced in 5c24de3
2020-06-23 23:29:49 -04:00
Eldred Habert f996186fae Merge pull request #526 from JL2210/fix-bank-index
Fix indexing of banks array, fixes #525
2020-06-21 12:44:17 +02:00
James Larrowe 69a41d8ef9 Fix indexing of banks array
When ROMX bank 1 is given, the banks array is indexed with an index
of 1 rather than an index of zero.
2020-06-17 13:33:48 -04:00
Eldred Habert b958820bce Merge pull request #523 from RandomBananazz/patch-1
Fixed error in POP AF instruction reference
2020-05-27 12:45:44 +02:00
Jason Yuan 7624bd524c Fixed error in POP AF instruction reference
The "imaginary" equivalent instructions put the instructions in the wrong order (inc sp first).
2020-05-26 23:29:06 -04:00
Eldred Habert 663f0ca3b0 Merge pull request #522 from JL2210/djgpp
Fix DJGPP build
2020-05-21 22:37:24 +02:00
James Larrowe f88d9e728d Fix DJGPP build
GCC with the -std=c11 defines __STRICT_ANSI__. DJGPP checks if
__STRICT_ANSI__ is defined and if so doesn't define some things
mandated by POSIX such as struct stat, PATH_MAX, and others.
The -std=gnu11 option does not define this macro, so use it instead.

_DEFAULT_SOURCE isn't needed as no GNU nor BSD-specific functions
are used. Remove it.

Fix the last two occurrences of incorrect format specifiers for standard
fixed-width integer types.
2020-05-19 19:21:16 -04:00
ISSOtm 71fa62c9d1 Fix incorrectly spaced unary ! in RPN documentation 2020-05-13 01:20:34 +02:00
ISSOtm 5c6069dbe9 Add NULL and overflow checks to macro args 2020-05-13 01:17:58 +02:00
ISSOtm d517d2d6b4 Change macro arg allocation to geometric growth array 2020-05-13 00:22:56 +02:00
ISSOtm 80218fa109 Fix array overflow on invalid macro arg evaluation
`macro_GetArg` had not been changed after the previous commit; however,
the old code relied on the `macroArgs->args` array being at least
`MAXMACROARGS` entries large (which was the case until the last commit).
The boundary against which it checked would have better been written as
`sizeof(macroArgs->args)/sizeof(macroArgs->args[0])`, I guess, but what's
done is done.
2020-05-12 16:44:23 +02:00
Eldred Habert fee8a58b77 Merge pull request #521 from aaaaaa123456789/master
Support over 256 macro arguments
2020-05-12 15:46:42 +02:00
aaaaaa123456789 fd52a6f046 Add a test for >256 macro arguments 2020-05-12 07:22:42 -03:00
aaaaaa123456789 89fb372326 Set max macro arguments to 99,999 2020-05-12 06:46:17 -03:00
aaaaaa123456789 a828f82414 Remove fixed-size array for macro arguments 2020-05-12 06:46:07 -03:00
Eldred Habert 4d0d6664d7 Merge pull request #520 from JL2210/inttypes-stdint
Use inttypes for stdint types
2020-05-07 17:31:06 +02:00
James Larrowe 5c24de3dc4 Use inttypes for stdint types
This should help make RGBDS portable to systems with 16-bit integers,
like DOS.

For kicks, use the macros for 16-bit and 8-bit integers.

Fix other miscellaneous things, like #include ordering and other
printf-format related things.

Reduce repitition in math.c while I'm there.
2020-05-07 11:10:20 -04:00
ISSOtm 363458c3bc Fix semi-unused variable in lexer.c 2020-05-06 19:55:37 +02:00
ISSOtm b299f6fb3b Fix uninitialized memory use with -MT and -MQ
This didn't break unless the first uninitialized byte was non-zero,
which happened to be the case on someone's Windows machine.

Would it be worth it setting up Valgrind in CI?
2020-05-06 19:19:10 +02:00
Eldred Habert 645473e336 Merge pull request #518 from JL2210/warn-parameterless-dx
Add empty data directive warning
2020-05-06 16:25:03 +02:00
James Larrowe bdf397bba7 Add empty data directive warning
Fixes #516
2020-05-06 09:50:28 -04:00
ISSOtm 781a65ee49 Fix hashmap collisions sometimes hanging deletion 2020-05-03 19:13:12 +02:00
ISSOtm c135e2c6a0 Fix local sym names not being expanded by PURGE
And an additional bug that broke the attached test
2020-05-03 19:06:48 +02:00
ISSOtm 12693081c9 Use colons for hour symbols 2020-04-28 13:05:06 +02:00
Eldred Habert 7c22954fd5 Merge pull request #513 from JL2210/disable-padding-option
Add option to disable padding in rgblink
2020-04-27 11:05:55 +02:00
ISSOtm 8958e352df Update documentation for new -x option 2020-04-27 11:04:29 +02:00
ISSOtm 573003113b Fix 0-byte sections incorrectly printed in map files
Fixes #515
2020-04-17 11:38:28 +02:00
JL2210 8b1351fc3e Add option to disable padding in rgblink
Fixes #307

RGBFIX can handle padding, so there's no reason why
we can't add an option to disable padding in rgblink.

Signed-off-by: JL2210 <[email protected]>
2020-04-15 09:34:51 -04:00
Eldred Habert 106ef895ee Merge pull request #514 from JL2210/fix-gfx-gb-leak
Add error checking and fix memory leak in gfx/gb.c
2020-04-14 21:31:12 +02:00
JL2210 7f9bd12f76 Add error checking and fix memory leak in gfx/gb.c
It's possible that tile could be leaked, so free it.

Fix sizeof convention and check the result of malloc.

Signed-off-by: JL2210 <[email protected]>
2020-04-13 22:02:24 -04:00
ISSOtm 5fe3a0adb6 Remove non-OPT options from Options struct 2020-04-13 17:15:00 +02:00
Eldred Habert cdb4c5f553 Merge pull request #509 from JL2210/zero-alloc-use-fix-3
Fix use of zero-allocated memory
2020-04-13 02:50:58 +02:00
ISSOtm 57639f3765 Change comment style and use errx instead of err 2020-04-13 02:50:11 +02:00
Eldred Habert 9bec983923 Merge pull request #511 from JL2210/memory-errors
Fix memory errors in makepng
2020-04-13 02:39:17 +02:00
ISSOtm 2220f19fa7 Fix use-after-free with include in linker scripts
Fixes #510, and further proves that you *really* should not entrust memory
ownership management to humans :P
2020-04-13 02:36:19 +02:00
JL2210 2a734ecba2 Fix memory errors
This includes not checking the result of malloc and
using the wrong type in sizeof. Only the latter was
caught by scan-build.

Also use more idiomatic sizeof().

Signed-off-by: JL2210 <[email protected]>
2020-04-12 19:45:37 -04:00
JL2210 d21015e34a Fix use of zero-allocated memory
It's possible that the unsigned integer may overflow to zero,
and then we might use zero-allocated memory.

This is incredibly unlikely, and I would even go so far as to say
that this is a false positive. Fix it anyway, to silence this warning:

src/link/patch.c:92:24: warning: Use of zero-allocated memory
        stack.buf[stack.size] = value;
        ~~~~~~~~~~~~~~~~~~~~~ ^

Deal with overflow, and check for zero to get rid of the warning.

Signed-off-by: JL2210 <[email protected]>
2020-04-12 19:36:47 -04:00
ISSOtm 023a3c037f Properly handle missing symbols
Fixes #512
2020-04-12 22:52:32 +02:00
ISSOtm 828edb7403 Remove spurious error from div by zero test 2020-04-12 01:05:06 +02:00
ISSOtm a034ce0478 Deprecate '*' for comments 2020-04-09 17:57:15 +02:00
Eldred Habert d6cd5823e3 Merge pull request #508 from JL2210/mod-by-zero-fix-2
Fix modulo by zero
2020-04-09 14:52:12 +02:00
JL2210 5dd941b311 Fix modulo by zero
Yet another case caught by scan-build:

src/link/patch.c:188:21: warning: Division by zero
                        value = popRPN() % value;
                                ~~~~~~~~~^~~~~~~

Just copy over the code from the division case, with a few modifications.

Signed-off-by: JL2210 <[email protected]>
2020-04-09 08:50:23 -04:00
ISSOtm f9f27d6f5a Clean up symbol system
Get rid of Hungarian notation
Improve encapsulation (the rest of the world should not touch PC directly)
2020-04-09 10:42:37 +02:00
Eldred Habert 5ea8490e2b Merge pull request #507 from JL2210/null-pointer-fix-1
Fix possible null pointer dereference
2020-04-08 23:35:21 +02:00
JL2210 5863cd10b8 Fix possible null pointer dereference
It's possible that if the FILE passed to yy_create_buffer is at the
end-of file, there may be a null pointer dereference.

This should hopefully fix that.

Found with clang-tools' scan-build:

src/asm/lexer.c:281:25: warning: Array access (via field 'pBuffer')
 results in a null pointer dereference
        pBuffer->pBuffer[size] = 0;
                 ~~~~~~~       ^
1 warning generated.

Signed-off-by: JL2210 <[email protected]>
2020-04-08 17:30:43 -04:00
ISSOtm 40f8e33e6c Fix periods not being accepted as second char of label names 2020-04-08 15:14:07 +02:00
ISSOtm 0157ba63d3 Document whitespace before local labels 2020-04-08 15:08:29 +02:00
ISSOtm 9e3d8b22cb Document new intra-section align
Also sneak in two code style fixes forgotten in last commit
2020-04-08 15:01:36 +02:00
ISSOtm 665412c073 Implement mid-section alignment directive
Fixes #254.
2020-04-08 12:29:00 +02:00
ISSOtm 2b0c34ecb5 Fix a few code style errors 2020-04-08 00:44:41 +02:00
ISSOtm b0ec8468e6 Allow specifying offset in addition to alignment 2020-04-08 00:40:41 +02:00
ISSOtm e82ad21704 Use a single byte for alignment 2020-04-07 21:19:09 +02:00
ISSOtm e098bf47ba Allow references to be overridden by constant symbols
RGBLINK is capable of handling it now.
Though it'd be ideal for RGBASM to directly catch it.

Fixes #496.
2020-04-07 20:57:20 +02:00
ISSOtm 190678107b Prevent RGBLINK from crashing when getting the bank of a constant 2020-04-07 20:41:29 +02:00
ISSOtm 9f82fa4cf7 Fix BANK(@) outside sections causing crashes 2020-04-07 15:51:17 +02:00
Eldred Habert 562835308b Merge pull request #504 from runlevel5/gcc10-fix
Fix multiple definitions for GCC10
2020-04-07 15:18:23 +02:00
ISSOtm 927c65e863 Fix incorrect PC in LOAD blocks at link time 2020-04-07 14:44:51 +02:00
ISSOtm 5b6c1569a4 Make failure to open file a fatal error 2020-04-07 11:36:44 +02:00
Trung Lê 65121e6d5d Fix multiple definitions for GCC10 2020-04-07 14:48:30 +10:00
ISSOtm 82e0e4ffaf Make some RGBLINK errors non-fatal 2020-04-06 00:48:10 +02:00
ISSOtm ffb199a26a Avoid Useless Use of backticks in rgblink testing 2020-04-06 00:44:59 +02:00
ISSOtm 175933d2b1 Remove old scripts for updating references for tests
I much rather prefer correcting everything by hand, and gauging
whether the change is good on a case by case basis
2020-04-06 00:41:37 +02:00
Eldred Habert c86e6fef0a Merge pull request #502 from JL2210/more-conventional-permissions
Use more conventional permissions and man-page directory
2020-04-06 00:25:33 +02:00
JL2210 1e3ce2a36f Use more conventional permissions and man-page directory
As 444 and 555 seem to be used for no apparent reason, use the more
conventional 644 and 755.

/man is typically unused or a symlink to /share/man now, so just use
/share/man.

Signed-off-by: JL2210 <[email protected]>
2020-04-05 17:02:12 -04:00
ISSOtm 153915dc2f Improve portability of new make dist 2020-04-04 14:48:15 +02:00
ISSOtm ced38bc6ee Add new Makefile target for release tarballs 2020-04-04 14:23:28 +02:00
ISSOtm 4e96cf9875 Release 0.4.0 2020-04-03 12:11:50 +02:00
ISSOtm 80170eb6eb Regenerate man page HTML renders 2020-04-03 12:03:59 +02:00
ISSOtm bdad1499fe Merge branch 'release' 2020-04-03 11:58:53 +02:00
Eldred Habert 1f5ca39559 Merge pull request #494 from ISSOtm/docs
Overhaul man pages
2020-04-03 11:56:41 +02:00
ISSOtm 5013b64f55 Update disassemblies to latest commits 2020-04-02 21:26:38 +02:00
ISSOtm 7eb73d766e Make compilation optimized unless debugging
Note: I wanted to enable `-Og` on `develop`, but this generated warnings
(thus, errors) that aren't in `-O0`. Needs further investigation, but
annoyingly some of those are within `extern/` code, thus requiring
different flags, which AFAIK is only possible (sanely) with GNU Make.
2020-04-02 16:56:04 +02:00
ISSOtm bcfeb49d6b Allow labels to be passed to DEF 2020-04-02 16:54:41 +02:00
ISSOtm 702d9e0542 Fix wrong error function used in RGBGFX 2020-03-31 17:28:31 +02:00
ISSOtm c0aff678e9 Improve arg-shift test 2020-03-29 12:34:13 +02:00
ISSOtm a3d8836671 Prevent assertions outside sections from crashing 2020-03-29 12:18:24 +02:00
ISSOtm db1eb8fbcb Revert "Prevent RGBASM from outputting corrupted files"
This reverts commit 06fe27c516.

According to Microsoft's documentation
https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/tmpfile?view=vs-2019
`tmpfile` attempts to create the temporary file at the **root** folder
This seems to assume that the user has admin rights; might be a compat
thing, idk, but it breaks on people's computers.
(CI didn't catch it, annoyingly.)

Reverting to make RGBASM usable on most Windows computers.
(Sanely-configured ones, at least.)
Another solution to #446 needs to be figured out, yay...
2020-03-27 23:36:11 +01:00
ISSOtm 95f347dc6a Evaluate assertions after placing sections 2020-03-27 20:00:29 +01:00
ISSOtm 6579120d9e Simplify symbol-writing logic 2020-03-27 12:32:14 +01:00
ISSOtm 84cd9f2db9 Fix segfaults when using PC outside a section 2020-03-27 12:30:09 +01:00
ISSOtm 06fe27c516 Prevent RGBASM from outputting corrupted files
Properly fixes #451
2020-03-27 11:19:02 +01:00
ISSOtm 5039af6af1 Document new "unionized section" feature 2020-03-26 23:50:30 +01:00
ISSOtm 4df74d44ec Improve opcode reference 2020-03-26 23:11:01 +01:00
ISSOtm 9113647d41 Fix incorrect macro used for x-ref 2020-03-26 23:11:01 +01:00
ISSOtm 26af2bff5e Prevent text from bumping sides on mobile devices 2020-03-26 23:11:01 +01:00
ISSOtm 3c304f3acf Override mandoc styling without modifying the stylesheet 2020-03-26 23:11:01 +01:00
ISSOtm e308130e23 Update style overrides for new mandoc.css 2020-03-26 23:11:01 +01:00
ISSOtm 713eef9ef2 Update mandoc style sheet 2020-03-26 23:11:01 +01:00
ISSOtm 7635a2fc74 Reword and give an example of symbol interpolation 2020-03-26 23:11:01 +01:00
ISSOtm 6889334521 Add viewport tag for mobile users 2020-03-26 23:11:01 +01:00
ISSOtm d1e82e50cb Improve style of man page HTML renders
See individual comments within `rgbds.css` for more info
Not too fond of having to modify `mandoc.css`, but I did my best to
modify as little as possible
2020-03-26 23:11:01 +01:00
ISSOtm 7955447ca4 Overhaul man pages 2020-03-26 23:11:01 +01:00
ISSOtm 51e225cd75 Add post-processor for HTML renders
Adds links to argument descriptions in synopsis
Adds links to man pages in the set (not to external ones)
Removes artifact from the way long opts are encoded
Makes description blurb inline, consistently with terminal output
2020-03-26 23:11:01 +01:00
ISSOtm 187f88aa50 Only copy necessary characters for bare labels 2020-03-26 23:10:51 +01:00
ISSOtm caddd61f17 Remove "column 1" restriction for local labels
Because a local symbol is necessarily a label, the disambiguation
is not necessary. This is a first step towards fixing #457.
2020-03-26 22:36:40 +01:00
ISSOtm 29629245a4 Use new hashmap implementation for symbols 2020-03-24 12:50:53 +01:00
ISSOtm 666b9f8f7b Add tests for purging symbols 2020-03-24 10:52:45 +01:00
ISSOtm 7deb8d3e8a Allow purging exported symbols 2020-03-24 10:52:02 +01:00
ISSOtm cb0a882a31 Order warnings alphabetically 2020-03-23 16:03:36 +01:00
ISSOtm df2c0dc2f9 Check for unsatisfiable alignment constraints
Fixes #493
2020-03-22 11:54:57 +01:00
ISSOtm 062fa5392b Still override alignment even if not satisfied 2020-03-22 11:52:31 +01:00
Eldred Habert baeec2315f Merge pull request #495 from ISSOtm/sectunion
Implement unionized sections
2020-03-22 11:21:24 +01:00
ISSOtm 92134d7684 Add testing for assertions inside unionized sections 2020-03-22 11:14:04 +01:00
ISSOtm 4877bb783c Add more tests for unionized sections + fix bugs
Implementing those tests found a few bugs... oops
2020-03-22 11:14:04 +01:00
ISSOtm 275b8e15ff Document modification to object file format 2020-03-22 11:14:04 +01:00
ISSOtm e123b6dec7 Implement unionized sections in RGBLINK 2020-03-22 11:13:39 +01:00
ISSOtm cb52ae0f26 Implement unionized sections in RGBASM
This touched a lot more code than initially expected, for two reasons.

First, this broke a big RGBASM assumption: that sections are always being
written to at their end. This plus other problems required touching
basically the entirety of `section.c`.

Second, I tried different solutions to solve the above problem, and along
the way I cleaned up many things around. (I believe that keeping this to
"cleanup" commits yields subpar results, and since it's boring they get
postponed anyways.)

RGBLINK support still needs to be added, but this will come next.
2020-03-22 11:06:17 +01:00
ISSOtm 46a402f7d7 Prevent passing assertions that RGBASM passed to RGBLINK 2020-03-22 10:46:37 +01:00
ISSOtm e233c5d256 Don't drop RGBLINK output in RGBASM tests 2020-03-22 10:43:06 +01:00
Eldred Habert fe824e0068 Merge pull request #490 from ISSOtm/const
Implement `ISCONST`, reporting compile-time constness
2020-03-21 23:20:01 +01:00
Eldred Habert 66512ed8d2 Merge pull request #488 from rednex/assert
Add assertions
2020-03-21 23:06:44 +01:00
ISSOtm fb58166e5d Add assertions
Closes #292
2020-03-21 23:00:38 +01:00
ISSOtm 0759c98d91 Increase version number to 0.3.10 2020-03-21 21:18:14 +01:00
ISSOtm 402ffbf0c5 Add test for version constants 2020-03-21 21:01:25 +01:00
ISSOtm 8191e5eb27 Define version symbols
Major blunder. That warrants a new release on its own...
2020-03-21 19:26:40 +01:00
ISSOtm 03967bd623 Prevent purging referenced symbols
This is an immediate fix for #492, although #342 is needed to implement the
desired functionality.
2020-03-21 15:42:52 +01:00
ISSOtm eb445271df Remove carryover from RGBASM in RGBLINK tests 2020-03-20 21:50:38 +01:00
ISSOtm af22cf182b Simplify out_PCRelByte by using PC 2020-03-20 20:22:19 +01:00
ISSOtm 5a0fcda4c8 Prevent POPS within LOAD blocks 2020-03-20 18:57:37 +01:00
ISSOtm 29623c4146 Test generating direct bytes in LOAD blocks 2020-03-20 18:29:15 +01:00
ISSOtm ebda8255ff Improve LOAD test to also test patches inside LOAD section 2020-03-20 18:20:20 +01:00
ISSOtm deb91f679d Reset symbol scope on every section change 2020-03-20 17:59:47 +01:00
ISSOtm fb5e768142 Prevent using LOAD blocks outide code sections 2020-03-20 16:37:10 +01:00
ISSOtm ecf44c784c Reject including directories 2020-03-20 01:24:53 +01:00
ISSOtm 5bca1172ff Fix section continuation when only one bank exists 2020-03-19 23:07:07 +01:00
ISSOtm 136446fccb Improve checking of RST and LDH values at assembly time 2020-03-15 15:23:39 +01:00
ISSOtm 49bca8d588 Fix misnamed hashmap function 2020-03-15 15:23:39 +01:00
ISSOtm 7ddbe44b21 Use hashmap system for charmap 2020-03-15 15:23:32 +01:00
ISSOtm af60e7f74a Allow charmap creation even if its base doesn't exist 2020-03-15 00:40:45 +01:00
ISSOtm 2f16e82cf7 Improve PC offset management
Basically make it always point to the instruction's first byte.
This was the behavior all whom I asked to intuitively expected.
2020-03-15 00:18:10 +01:00
ISSOtm 7b54312d97 Deprecate OPT z in favor of OPT p
Fixes #298
2020-03-14 17:09:15 +01:00
ISSOtm 5b98beec8b Use left recursion instead of right
> Any kind of sequence can be defined using either left recursion or right
> recursion, but you should always use left recursion, because it can
> parse a sequence of any number of elements with bounded stack space.
https://www.gnu.org/software/bison/manual/html_node/Recursion.html
2020-03-14 16:22:33 +01:00
ISSOtm 6662c86d5e Define 3-bit value when invalid 2020-03-14 16:17:30 +01:00
ISSOtm 2f466c2939 Revamp macro arg system
This should significantly improve performance: on pokecrystal builds, perf
reported as much CPU time spent on `yyparse` as on `sym_UseNewMacroArgs`
Measurements show ~6 seconds of improvement on that codebase.

This also fixes #321, as a bonus, due to saner management!
2020-03-14 16:13:40 +01:00
ISSOtm 61897d8b52 Fix warning.h not including a required header 2020-03-14 11:33:51 +01:00
ISSOtm a259f53b52 Rename macro functions with proper prefix 2020-03-13 23:20:27 +01:00
ISSOtm ffdb1fbfe5 Split macro arg management into its own file
It has no relation to symbols, and helps a tiny bit deflate `symbol.c`
2020-03-11 02:39:36 +01:00
ISSOtm 4b33b4b387 Remove forward decl of nonexistent function
I can only assume it was for debugging? (No, I'm not looking it
up the history)
2020-03-11 02:21:30 +01:00
ISSOtm 8fcdcb1731 Implement ISCONST, reporting compile-time constness 2020-03-11 02:15:31 +01:00
ISSOtm 55b911654c Get rid of obsoleted function 2020-03-11 01:46:26 +01:00
ISSOtm 7c8eba9fd2 Remove error message causing segfault
This was utterly stupid. The check right above ensured that `sym` was NULL,
ergo that the argument to `yyerror` *would* segfault.

The only two call sites cannot pass a non-NULL pointer anyways, which I'm
betting is why this went unnoticed.
I did what an optimizing compiler would do anyways: remove the dead code.
2020-03-11 00:39:57 +01:00
ISSOtm 23effcc3f0 Fix error messages in sym_GetConstantValue 2020-03-11 00:16:35 +01:00
ISSOtm ea0c5581a5 Prevent deletion of built-in symbols 2020-03-10 23:25:33 +01:00
ISSOtm 2ea329c920 Make symbol creation funcs return ptr to symbol 2020-03-10 16:36:02 +01:00
ISSOtm 3948795d49 Remove deprecated section types 2020-03-10 16:08:09 +01:00
ISSOtm 13e4920122 Get rid of comma token 2020-03-10 16:08:09 +01:00
ISSOtm 88b1121037 Uniformize style in asmy.y 2020-03-10 16:08:02 +01:00
ISSOtm d2a97e934b Remove obsolete instruction forms 2020-03-10 15:50:11 +01:00
ISSOtm cb3997d8c9 Fix org location being undefined when incorrect 2020-03-10 15:37:33 +01:00
ISSOtm c7320a49a9 Deprecate GLOBAL and XDEF
They're basically synonyms for `EXPORT`, and the latter isn't
even documented!
2020-03-10 13:49:55 +01:00
ISSOtm 8d9a896166 Remove deprecated IMPORT symbol
It had a warning that it had no effect for a long while now; removing it so
the name can be re-used
2020-03-10 13:43:15 +01:00
ISSOtm 81a057416f Remove typing for operators that don't need it 2020-03-08 16:26:09 +01:00
ISSOtm 361326e06c Allow inlining of two simple RPN functions 2020-03-07 18:18:57 +01:00
ISSOtm 0d31afaff8 Correct four code style issues 2020-03-07 18:09:00 +01:00
ISSOtm 48ad3973a9 Tell the user about "label"s instead of "relocatable"s
That's the common term, and even the manual uses it.
2020-03-07 18:04:13 +01:00
ISSOtm f6f25296a0 Fix passing constant label to BANK() causing an error 2020-03-07 18:02:06 +01:00
ISSOtm cb62076f8c Use $(MAKE) instead of make in develop 2020-03-06 18:15:32 +01:00
ISSOtm 8034e567f1 Un-silence make checkpatch in CI 2020-03-06 02:32:46 +01:00
ISSOtm 59546c8980 Un-trivialize expression in long RPN expr test 2020-03-05 04:33:43 +01:00
ISSOtm eee0e6adc8 Simplify long-rpn-expression.asm test 2020-02-29 16:39:13 +01:00
ISSOtm fa10ee4356 Deprecate colon-less non-local labels 2020-02-29 16:30:47 +01:00
ISSOtm 5bc8d51a9e Ignore unused arguments in a more standard way 2020-02-29 16:25:54 +01:00
Eldred Habert 361d6cf517 Merge pull request #437 from rednex/locals
Prevent local symbols that are not labels
2020-02-26 02:56:35 +01:00
ISSOtm 6800609fa7 Make RGBLINK check divisions by zero 2020-02-24 17:54:55 +01:00
ISSOtm dac13ba4bb Add string format checking to err.h functions
And fix all problems this detected... oops
2020-02-24 16:58:55 +01:00
ISSOtm 702075eba6 Add forgotten file name argument to err 2020-02-24 16:58:55 +01:00
ISSOtm 3b62bd0bce Bundle GCC runtime in Win32 bin package
After discussing with some Windows user, this actually seems to be
a common thing to do (it seemed weird to me, but I know Windows' handling
of DLLs is weird anyways), so bundle that runtime and reinstate the
full test run for Win32.
2020-02-23 23:14:26 +01:00
ISSOtm 4cc24f4369 Add ds cnt, byte syntax
As suggested by https://github.com/rednex/rgbds/issues/350#issuecomment-498030458
The order `count` then `byte` was decided after some discussion:
- First argument consistent with single-arg syntax
- Intuitive at least to some people other than myself
- Consistent with other assemblers, at least ca65
2020-02-23 22:43:50 +01:00
ISSOtm cfe21876e5 Make writing patches not affect the expression
This also removes one int member from the struct that shouldn't be there
2020-02-23 22:29:01 +01:00
ISSOtm ef2bfe4ea0 Store patch file line in the file name
It's more consistent with how it's stored for all other entries in the stack
2020-02-19 09:51:40 +01:00
ISSOtm 14731c0a1d Use the GitHub-provided base ref for checkpatch testing 2020-02-19 00:56:06 +01:00
ISSOtm 93747af215 Allow overriding the base ref for checkpatch
The default is sane, but not a catch-all.
2020-02-19 00:55:00 +01:00
ISSOtm 76efd26da0 Prevent local symbols that are not labels
Fixes errors brought up in #423
2020-02-19 00:20:58 +01:00
ISSOtm cf2001de5f Allow compiling parser in debug mode with -DYYDEBUG=1 2020-02-19 00:01:51 +01:00
ISSOtm 6d00877231 Prevent infinite loop with line continuations without newlines 2020-02-18 20:58:20 +01:00
ISSOtm 6755a0912b Improve naming of CI build artifacts 2020-02-18 20:23:37 +01:00
ISSOtm b6ac23be3d Remove Travis CI files
Obsoleted by GitHub Actions since #486
2020-02-18 20:12:18 +01:00
ISSOtm e941cafedb Make locals in main scope a non-fatal error 2020-02-18 20:07:44 +01:00
ISSOtm 03fe077b41 Make locals without parent a non-fatal error 2020-02-18 20:07:44 +01:00
Eldred Habert 12ef879860 Merge pull request #486 from ISSOtm/actions
Switch CI to GitHub Actions
2020-02-18 20:04:26 +01:00
ISSOtm 179e047474 Add Windows testing 2020-02-18 02:55:38 +01:00
ISSOtm d497190aa1 Do not zip artifacts ourselves
GitHub does it, this creates zips of zips...
2020-02-17 15:04:14 +01:00
ISSOtm e078c1e793 Use develop in CI when possible 2020-02-17 15:04:14 +01:00
ISSOtm 7471f46a07 Add checkpatch testing 2020-02-17 15:04:14 +01:00
ISSOtm 8cee3c3c3e Upload binaries after compilation 2020-02-17 15:04:14 +01:00
ISSOtm 97bcbf5d84 Add GitHub Actions for regression testing 2020-02-17 15:04:14 +01:00
ISSOtm 3fce9ed9a4 Have Wine shim explicitly require bash
I didn't know the substitution was Bash-only..!
2020-02-17 15:03:46 +01:00
ISSOtm 21ffcc74db Don't use echo -e for creating the Wine shim
Apparently that's not as portable as I expected.
2020-02-17 14:32:35 +01:00
ISSOtm 9e99db9a8e Allow \r in strings
Fixes #484
2020-02-17 13:52:38 +01:00
ISSOtm 5fd38c5f67 Do not try to link libpng statically 2020-02-14 03:07:24 +01:00
ISSOtm 03ed914714 Give reason to why writing the object file fails 2020-02-14 00:29:24 +01:00
ISSOtm 42faffe6f3 Make the Wine shims a separate target 2020-02-13 23:06:05 +01:00
ISSOtm bc80e910ed Fix two code style errors 2020-02-13 20:43:47 +01:00
ISSOtm 30a95d735a Improve testing PC 2020-02-13 20:20:35 +01:00
ISSOtm f01a227470 Fix non-const labels with callbacks having incorrect values when diffed
Basically, this broke PC, which is currently the only label-typed symbol
with a callback.
2020-02-13 20:16:59 +01:00
ISSOtm 91b65c9380 Add include guards and license header to section.h 2020-02-13 15:57:27 +01:00
ISSOtm 18c47843f1 Check if sections referenced in linker script exist 2020-02-12 15:27:07 +01:00
Eldred Habert d5fe377c11 Merge pull request #482 from ISSOtm/conflict
Fix one shift/reduce and one reduce/reduce conflict
2020-02-12 01:39:18 +01:00
ISSOtm ed4a613473 Rename productions to "reloc" when not really constant 2020-02-11 19:04:35 +01:00
ISSOtm 112098514d Fix 1 s/r and 1 r/r conflict
Implements the fix suggested [here](https://github.com/rednex/rgbds/issues/44#issuecomment-69360499), which performed better than expected!
I'm not \*too\* fond of this but this seems like the right way
2020-02-11 18:59:55 +01:00
ISSOtm 31aa1ea474 Improve arg-shift test
New test case courtesy of @aaaaaa123456789
2020-02-11 11:38:57 +01:00
ISSOtm 96b6e4a76e Add forgotten semicolon in grammar 2020-02-11 11:36:50 +01:00
ISSOtm 001b95d12a Add SHIFT with numeric argument
Fixes #442.
2020-02-11 11:25:38 +01:00
ISSOtm 3b2c862320 Make more RGBASM errors print their line number
Fixes #379.
2020-02-11 09:35:19 +01:00
ISSOtm 230f849229 Fix error output slightly broken on Windows
Apparently, `perror` on Windows forces a newline before itself, which is
not the behavior intended. Instead, print the error message inline.
2020-02-11 09:06:38 +01:00
Eldred Habert c37253fe5a Merge pull request #480 from ISSOtm/section
Improve section management
2020-02-11 08:51:00 +01:00
Eldred Habert 0ed8d3859d Merge pull request #481 from rednex/revert-451-atomic_output
Revert "Make RGBASM overwrite output files atomically"
2020-02-11 08:32:27 +01:00
ISSOtm 6963d77f8a Add documentation for LOAD blocks 2020-02-10 09:30:33 +01:00
ISSOtm 02ea52f453 Add test for LOAD 2020-02-10 03:39:09 +01:00
ISSOtm cdabc057a0 Allow unseekable files with INCBIN
Go figure the use case, but the feature is there now
2020-02-10 03:39:09 +01:00
ISSOtm eb0d75711a Implement LOAD/ENDL blocks
Basically implements and closes rednex#274.
2020-02-10 03:39:09 +01:00
ISSOtm f121119283 Use section's offset instead of general one
That's more future-proof and makes more sense
2020-02-10 03:37:44 +01:00
ISSOtm d9c1b66931 Deduplicate value output function code 2020-02-10 03:37:43 +01:00
ISSOtm 2f60e0a59e Use meaningful types for byte output functions 2020-02-10 03:36:51 +01:00
ISSOtm ffe9e92b48 Skip double-checking overflow in byte output 2020-02-10 03:36:51 +01:00
ISSOtm aa90a53f34 Move 1-byte overflow check to out_AbsByte
This check is already performed in bulk by all functions calling it except
`out_AbsByte`, adding extra overhead to those.
2020-02-10 03:36:51 +01:00
ISSOtm 598c923506 Use callback for PC's value
This causes it to auto-update whenever the current section's attributes are
updated, simplifying the code and eliminating redundancy.
This should also overall reduce overhead (one extra function call on each
PC evaluation, but less bookkeeping for each byte output)
2020-02-10 03:36:51 +01:00
ISSOtm 8c4b473d6f Add more checks to section creation in RGBASM
Fixes rednex#471, but also backports a couple more checks from RGBLINK
2020-02-10 03:35:55 +01:00
ISSOtm a4fe274c25 Unify all section declarations 2020-02-10 03:35:55 +01:00
ISSOtm 34597ce6a0 Mark some section functions as const 2020-02-10 03:34:58 +01:00
ISSOtm 4a2af807b2 Remove legacy forward declaration 2020-02-10 03:34:58 +01:00
ISSOtm d0ec35628f Split section management into its own file 2020-02-10 03:34:58 +01:00
ISSOtm bfdbd00092 Do some misc cleanup of output.c 2020-02-10 03:25:03 +01:00
ISSOtm d0278d8663 Invert logic for section max sizes
Prep for the next commit
2020-02-10 03:25:03 +01:00
Eldred Habert 632bc2aaec Merge pull request #476 from ISSOtm/expr_cleanup
Clean up expression evaluation
2020-02-10 03:10:05 +01:00
Eldred Habert 1ca59f25d0 Revert "Make RGBASM overwrite output files atomically" 2020-02-10 03:08:27 +01:00
Eldred Habert 1d0c8fa113 Merge pull request #451 from rednex/atomic_output
Make RGBASM overwrite output files atomically
2020-02-10 03:08:14 +01:00
ISSOtm 1d70c989be Test one more label diff case 2020-02-10 02:55:51 +01:00
ISSOtm 818a0d0296 Test more cases in label-diff test 2020-02-10 02:51:48 +01:00
ISSOtm ab1eb146c9 Print special message when PC is not constant 2020-02-10 02:51:48 +01:00
ISSOtm 63054ae0fd Make more functions ignore the RPN buffer when constant 2020-02-10 02:51:48 +01:00
ISSOtm 155040240d Improve error message when a symbol's value is not constant 2020-02-10 02:51:48 +01:00
ISSOtm d466cab1e8 Init RPN expressions created by binary operators 2020-02-10 02:51:48 +01:00
ISSOtm 4e8b34f42e Improve error message when a symbol is not constant 2020-02-10 02:51:48 +01:00
ISSOtm 5014f55c48 Treat PC as a symbol as well 2020-02-10 02:51:48 +01:00
ISSOtm 1d78cd0f03 Axe the constexpr expression evaluator
This avoids redundancy between them (and also having to port fixes and features)
The error messages have been preserved through a string reporting mechanism
2020-02-10 02:51:48 +01:00
ISSOtm 52d62c6b21 Handle subtractions between labels 2020-02-10 02:47:50 +01:00
ISSOtm b4a73f33ce Avoid undefined behavior when shifting in RPN math 2020-02-10 02:47:50 +01:00
ISSOtm f9c25608e9 Ignore RPN strings when their value is known 2020-02-10 02:47:50 +01:00
ISSOtm 9fb9e63554 Reserve space for RPN expressions in a single call
This should mean less overhead with some commands
2020-02-10 02:47:12 +01:00
ISSOtm 9ce8a9f5f0 Add comments to RPN expr struct 2020-02-10 02:47:12 +01:00
ISSOtm cc59730c5b Cleanup the RPN evaluator somewhat
Make the bool field an actual bool
Rename `iReloc` to a more exact `isKnown` (as was already pointed out by some
comments)
Make the value of `BANK(symbol)` consistent when the argument is invalid
2020-02-10 02:47:12 +01:00
ISSOtm 0a04904b75 Refactor RPN binary expressions into a single func
This mirrors what the constexpr evaluator is doing, and removes a lot of code shared
between all of them
2020-02-10 02:47:12 +01:00
ISSOtm 9ed6e9af65 Make = a separate token from SET
This does break backwards compat, but if anyone complains I'm gonna be mad
2020-02-10 00:49:45 +01:00
ISSOtm c424a9bf5a Only output a single error with charmaps 2020-02-09 22:15:43 +01:00
ISSOtm 9d811e1267 Warn when truncating values in charmap 2020-02-09 22:13:16 +01:00
ISSOtm af6f62701c Remove ambiguous charmap syntax
The syntax was `charmap "anything", "string"`; the second string was
already handled by `const`, but to the same effect... the ambiguous
declaration has been removed, leaving us at "only" two reduce/reduce
conflicts.
2020-02-09 22:03:11 +01:00
ISSOtm 299574221e Truncate shift.out.bin
Too large a size makes diff output (when tests fail) annoying
2020-02-09 19:51:47 +01:00
ISSOtm fe0c269382 Use ++ and -- instead of [+-]= 1
Seriously...
2020-02-09 15:21:08 +01:00
ISSOtm 579a324ce7 Fix diffing bin files in RGBASM tests 2020-02-09 13:58:47 +01:00
ISSOtm 7903c14993 Fix undefined behavior when reading constant in RGBLINK 2020-02-07 14:51:26 +01:00
ISSOtm b42a04c24e Add test for jr @
Fun fact: current build *fails* this test!
2020-02-07 13:19:50 +01:00
ISSOtm ea52e45335 Fix @
The symbol's evaluation by the assembler and linker was very inconsistent
2020-02-07 13:19:50 +01:00
ISSOtm 9687e6e1dd Allow forcing the second byte of STOP
Fixes #433
2020-02-07 10:06:02 +01:00
ISSOtm ee34200e5f Output diffs when binary tests fail 2020-02-06 15:36:15 +01:00
ISSOtm 295fc6c619 Improve coverage of db-@ test 2020-02-05 13:24:50 +01:00
ISSOtm 28473d314a Make implicit truncation a warning 2020-02-05 13:20:51 +01:00
ISSOtm 35f7340dc9 Report failing test names in RGBLINK as well 2020-02-04 01:41:35 +01:00
Eldred Habert b76567e7d1 Merge pull request #470 from ISSOtm/rst
Allow using labels as argument to `rst`
2020-02-04 01:26:06 +01:00
ISSOtm 652db60ad6 Document modifications made to object file format 2020-02-03 21:10:05 +01:00
ISSOtm a7cb0a166a Inline readRGBxObject
This was made separate with the intention of supporting multiple versions,
but after some discussion this was decided against, so better improve
readability instead.
2020-02-03 21:10:05 +01:00
ISSOtm f363541611 Introduce revision number field 2020-02-03 21:10:05 +01:00
ISSOtm fa1fba7fd9 Increase object version to RGB9 2020-02-03 21:07:46 +01:00
ISSOtm d73fa09774 Remove RGB6 parsing 2020-02-03 21:07:12 +01:00
ISSOtm b1cd730db2 Add link-time RST instruction
This allows using a label as the argument to a `rst` instruction
Fixes rednex#448
2020-02-03 21:07:12 +01:00
ISSOtm 359a048b6e Bump object version number
We're about to break the format, so let's do this
2020-02-03 21:07:12 +01:00
ISSOtm f2be601a13 Check "left" boundary as well in isLocationSuitable
"fixed" and "aligned" location checking advanced the target location to places
regardless of the associated free space, potentially breaking the assumption
that the location was always further in memory than the free space's base.

Rather than adding more code to try keeping that assumption true, harden
`isLocationSuitable` and handle that case as well.
2020-02-03 20:57:12 +01:00
ISSOtm 4d2379b3df Merge both "single-side" code paths in placeSection 2020-02-03 20:19:30 +01:00
ISSOtm fd32b2252f Define additional variable when doing make develop 2020-02-03 19:58:02 +01:00
ISSOtm d15915ef14 Simplify bankrangecheck 2020-02-03 15:36:38 +01:00
ISSOtm 877e0e0b91 Get rid of BANK_COUNT_* symbols
They weren't used save for the definitions right below, so Occam's razor applies
2020-02-03 15:19:48 +01:00
ISSOtm da1d9f68c7 Remove and reorder bank counts
Why was this an enum in the first place, anyways?
2020-02-03 15:19:48 +01:00
ISSOtm 24f41ef897 Expose link def arrays to RGBASM 2020-02-03 15:19:48 +01:00
ISSOtm 09dff85d5b Merge common.h into linkdefs.h 2020-02-03 14:50:00 +01:00
Eldred Habert 20e5685c1a Merge pull request #424 from ISSOtm/better_deps
Improve dependency generation
2020-02-03 03:50:09 +01:00
Eldred Habert ac6232bc87 Merge pull request #473 from ISSOtm/shift_ub
Remove undefined behavior from shifts
2020-02-03 03:49:38 +01:00
ISSOtm b16ec83a33 Add gbdiff.bash script
This script allows diffing two Game Boy ROMs using `xxd` and `diff` and
attempts to augment the diff using information pulled from SYM files.
It's not part of RGBDS proper, but can be useful to debug tests (when ROMs fail
to match).
2020-01-30 02:43:31 +01:00
ISSOtm ed72baca2a Make more symbol functions const
Can't hurt to specify those as they are now. Perhaps it'll enable slightly more
compiler optimizations, too?
2020-01-30 02:38:33 +01:00
ISSOtm edb562d2e5 Mark a few symbol functions as static 2020-01-30 02:19:36 +01:00
ISSOtm 6d4b128611 Avoid unnecessary copies in symbol init 2020-01-30 02:15:43 +01:00
ISSOtm e2e01e84fa Fall back from failure in time a bit better 2020-01-30 02:07:55 +01:00
ISSOtm 93ee417567 Fix timestamp symbols on Windows (partially)
Windows does not honor `%F` nor `%T` in `strftime`. These are worked around
by writing the full format they serve as a short for.
However, Windows also treats `%z` and `%Z` identically, where SUS instead
requires `%z` to output a ±XXXX offset.
Since the current information is broken (no information), this isn't *breaking*
anything, but at least provides something a human will probably understand.
`__ISO_8601_UTC__` is unaffected because it hardcodes the timezone character,
only `__ISO_8601_LOCAL__` suffers from this.
2020-01-30 01:47:50 +01:00
ISSOtm 44cdcd12c3 Use tput for formatting escape sequences 2020-01-28 21:04:41 +01:00
ISSOtm ed06981f57 Add test for db X, @
It should behave identically to both of these on separate lines
2020-01-28 21:04:41 +01:00
Eldred Habert ec6c42e9d6 Merge pull request #467 from ISSOtm/report
Report failing file names in comparisons
2020-01-28 18:59:11 +01:00
ISSOtm b11d121c48 Remove undefined behavior from shifts
`asl` and `asr` in `src/link/patch.c` courtesy of @pinobatch, and rearranged in RGBASM
evaluators.
2020-01-28 12:37:38 +01:00
ISSOtm cdf6000618 Report failing file names in comparisons
The files being diffed (especially for  variants) are temp files, so their
names are pretty nondescript. This improve error output, using ANSI escape
sequences to make those lines stand out.
2020-01-28 11:44:50 +01:00
ISSOtm 2e8094b712 Allow RGBASM to overwrite object files on Windows 2020-01-28 11:08:16 +01:00
ISSOtm a9cb4f8245 Make RGBASM overwrite output files atomically
Fixes rednex/#446.
I am not sure this is the best (in cases where the target directory
is not writable but the target file is), but maybe this can be
toggled via a flag, for example.
2020-01-28 11:08:16 +01:00
ISSOtm 1bd41bf79a Don't use diff to compare bin files in tests 2020-01-26 21:10:31 +01:00
ISSOtm 08ab34cf57 Fix a few checkpatch warnings in symbol.h 2020-01-26 18:26:57 +01:00
ISSOtm 7bb55469fe Fix partial paths being output to dep files with -i 2020-01-26 15:33:36 +01:00
ISSOtm a29dd738f2 Reimplement -M variants using long options 2020-01-26 15:33:36 +01:00
ISSOtm 4a98b41d57 Fix -MG always being enabled 2020-01-26 15:33:36 +01:00
ISSOtm 6fc5097278 Allow outputting dep files to stdout using - 2020-01-26 15:33:36 +01:00
ISSOtm 12f2f654dd Add -MG
This option allows for automatic dependency detection and generation:
as soon as a missing file is found, it is output to the dep file, and
assembly immediately aborts. (No .o file is produced, even if `-o` was
speicified.) This doesn't cause an error, either; the point is that once
the file is added to the dep file, the Makefile is re-parsed, and this
time the file will be generated, so the dep list builds up automatically.
This mimicks GCC's option and behavior.
2020-01-26 15:33:36 +01:00
ISSOtm 0649b360fb Allow specifying multiple dependency targets
This is done to match GCC's behavior.
Also, this unifies the code of -MT and -MQ.
2020-01-26 15:32:45 +01:00
ISSOtm f1f314270d Add -MQ
Just like GCC's -MQ, this is basically -MT but the file name is escaped.
2020-01-26 15:32:45 +01:00
ISSOtm 1fb9f90f0f Add -MT option
Allows overriding the output file in dependencies, which also allows
outputting those without also outputting the object file.
This, again, mimicks GCC's option.
2020-01-26 15:32:45 +01:00
ISSOtm bfa8da78a6 Add -MP option
Adds a phony target to every included file, mimicking gcc's
2020-01-26 15:32:45 +01:00
Eldred Habert fb81733b2b Merge pull request #472 from ISSOtm/romx-tiny
Allow ROMX and WRAMX sections in restricted modes
2020-01-26 14:48:32 +01:00
Eldred Habert e7eac583da Merge pull request #477 from ISSOtm/sym_overhaul
Overhaul the symbol system
2020-01-26 14:30:47 +01:00
ISSOtm cd107855e7 Test new working label subtractions 2020-01-24 03:03:18 +01:00
ISSOtm ab9307ac61 Clean up symbol management
Stop using that bitfield for everything, including what can be determined otherwise
It also makes it easier to have a sane state, since some bits were (supposedly)
mutually exclusive
2020-01-24 02:51:48 +01:00
ISSOtm e3ef194b4f Remove local label error checking
This is actually not necessary, because RGBLINK would warn about missing labels.
Besides, through semi-esoteric ways, it is possible to define more labels in this scope,
and there's no reason to prevent that.
2020-01-24 02:51:48 +01:00
ISSOtm ab4ca9ad8c Make symbol ref in patch symbols constant 2020-01-24 02:51:48 +01:00
ISSOtm 3fb5648880 Actually rely on createsymbol never returning NULL
This reduces complexity, basically
2020-01-24 02:51:48 +01:00
ISSOtm a7c0616cd8 Rename export type enum to that
This prevents a conflict in the next commit
2020-01-24 02:51:48 +01:00
ISSOtm 51d5ff0567 Test subtracting labels 2020-01-24 02:50:24 +01:00
ISSOtm 0665146dcd Report line info on empty RPN stack 2020-01-21 03:12:43 +01:00
ISSOtm 1f8422575e Test that all-instructions does not error out 2020-01-21 03:05:22 +01:00
ISSOtm 61c381a62c Systemize RGBLINK testing 2020-01-21 03:01:58 +01:00
ISSOtm 56d5f1588a Do not run .pipe tests if the normal variant fails
They'll most likely fail as well, just adding redundant error output
2020-01-21 00:27:28 +01:00
ISSOtm c05334dfc1 Upgrade testing to latest disasm commits 2020-01-20 14:51:25 +01:00
Eldred Habert 09d6c7a54f Merge pull request #475 from ISSOtm/licensing
Add license headers where missing
2020-01-19 15:45:46 +01:00
ISSOtm 4fe44447a2 Add license headers where missing 2020-01-19 11:11:36 +01:00
ISSOtm 23c600eef5 Remove unnecessary gitignore file
This became unnecessary when the linker script parser was rewritten ad-hoc
2020-01-19 11:02:47 +01:00
ISSOtm 50f091ab7c Fix RGBLINK failing to read args on certain machines
`char` has implementation-defined signedness, and if it's chosen to be unsigned,
then -1 gets converted to 255, which is then promoted back to `int` as... 255,
always failing the loop condition in src/link/main.c:118
`int8_t` has the correct signedness, but considering `musl_getopt_long_only`
returns `int`, better use that so as not to lose any bits
2020-01-18 22:12:25 +01:00
ISSOtm 7437f7eb85 Clarify redefinition error message 2020-01-17 03:53:27 +01:00
ISSOtm d6a99981d6 Fix checkcodebase warnings 2020-01-16 22:31:24 +01:00
ISSOtm 71fe652556 Allow ROMX and WRAMX sections in restricted modes
Closes #462, although with this implementation `BANK("some ROMX section")` would
return 0 instead of 1, which I think is benign anyways
2020-01-16 22:24:05 +01:00
ISSOtm 89917ef688 Put semicolons before labels in test suite 2020-01-16 22:09:31 +01:00
Eldred Habert 097e4c9799 Merge pull request #468 from ISSOtm/include_stem
Enforce trailing slash in include paths
2020-01-16 19:18:00 +01:00
ISSOtm 2c37a1e971 Fix default warning states
They were in the wrong order for some reason, this especially caused user
warnings to be off by default
2020-01-16 19:16:54 +01:00
ISSOtm 2c52364978 Add test for fixed section addresses 2020-01-16 18:12:42 +01:00
ISSOtm 10140f74dc Allow RGBLINK to report multiple sanity check errors 2020-01-16 18:10:35 +01:00
ISSOtm 558e8f46ff Sanity check fixed address of sections in RGBLINK
This could otherwise cause segfaults while reporting errors (!) during placement
2020-01-16 12:41:23 +01:00
ISSOtm 9ccb71205a Remove stale clean line
Those files don't exist in RGBLINK's source anymore
2020-01-14 11:42:07 +01:00
ISSOtm e50bcaa272 Enforce trailing slash in include paths
Fixes rednex#456
2020-01-13 22:48:59 +01:00
ISSOtm 86a28e8201 Provide string arguments to errors in constexpr_BankSection
How the f did it work before
2020-01-13 15:13:19 +01:00
ISSOtm 95cd0c6e53 Add test for BANK() in constant context 2020-01-12 13:09:27 +01:00
ISSOtm 23ab245cec Return a consistent number for const BANK() when erroring out 2020-01-12 13:07:48 +01:00
ISSOtm eb82476591 Make bank of "bank 0" sections known to RGBASM
This allows `BANK("Some ROM0 section")` to be used in a constant expression
2020-01-10 14:57:39 +01:00
ISSOtm f1f70d250a Add test for DEF(@) 2020-01-09 06:10:28 +01:00
ISSOtm 98a221d6b6 Add test for DEF(@) 2020-01-09 02:10:48 +01:00
Eldred Habert fb22d12b0f Merge pull request #463 from ISSOtm/windows_test_suite
Run tests on MinGW versions
2020-01-09 01:15:47 +01:00
ISSOtm 83249ed69f Cap the number of concurrent jobs for testing
This has a serious tendency to just blow up process load (~35 here with the shim)
2020-01-09 01:10:51 +01:00
ISSOtm 1534df0b3c Use minGW's pkg-config 2020-01-09 01:10:51 +01:00
ISSOtm ece9177f5a Produce shims to run the test suite on Windows bins via Wine 2020-01-09 01:10:51 +01:00
ISSOtm 8a90d74340 Ignore line endings in test suite
This removes many false positives with Windows
2020-01-09 01:10:51 +01:00
ISSOtm 5a06fad31e Separate stdout and stderr in tests
POSIX leaves undefined the order of output if stderr is injected into stdout,
and in practice it differs on Windows (Linux buffers both streams separately,
Windows interleaves them as they arrive without buffering).
This should help testing on other platforms
2020-01-09 01:10:51 +01:00
Eldred Habert add07259f4 Merge pull request #465 from ISSOtm/rebuild_version
Always update version
2020-01-09 01:01:11 +01:00
Eldred Habert 36ca18bc7b Merge pull request #466 from AntonioND/an/warning
Fix declaration of constexpr_BankSymbol()
2020-01-09 00:46:47 +01:00
Antonio Niño Díaz 6003be3fae Fix declaration of constexpr_BankSymbol() 2020-01-08 23:33:42 +00:00
ISSOtm 6d9399e3a0 Always update version
Implements https://github.com/rednex/rgbds/pull/378#issuecomment-569836686
2020-01-09 00:27:22 +01:00
Eldred Habert 676800476d Merge pull request #430 from ISSOtm/known_selfbank
Make `BANK(@)` and `BANK("section")` known to RGBASM
2020-01-08 18:56:28 +01:00
Eldred Habert 4dfa3157e5 Merge pull request #454 from ISSOtm/unlocked_windows
Fix mingw build
2020-01-08 13:14:13 +01:00
Eldred Habert f26cfa2d94 Merge pull request #455 from ISSOtm/man
Overhaul RGBDS man pages and help messages
2020-01-07 22:44:58 +01:00
ISSOtm d3328406a2 Improve jr out-of-reach error message 2020-01-02 14:06:40 +01:00
ISSOtm 3564b3f9ea Have jr offset wrap with 16 bits
Overflow with `int16_t` is defined to two's complement so it's OK
This could trigger when jumping from the top of ROM0 to HRAM
2020-01-02 14:03:54 +01:00
ISSOtm b81faeccfa Rename rgbfix long opt verbose to validate
The previous name was probably copy-pasted, it was completely wrong
2019-12-29 17:41:19 +01:00
ISSOtm 1c4cb2cd2d Add warning option to RGBASM man synopsis 2019-12-29 17:38:46 +01:00
ISSOtm 6959b76749 Rework help/usage messages
Trimmed down the option lists as per @bentley's request;
Reinstated the man pages' synopsis
2019-12-29 17:38:08 +01:00
ISSOtm 8a1e920e23 Fix incorrect line counting when running REPT blocks.
Fixes #461
2019-12-12 23:46:16 +01:00
ISSOtm 606519c515 Touch up ds documentation as per rednex#350 2019-12-12 23:22:51 +01:00
ISSOtm 34618e0294 Overhaul RGBDS man pages and help messages 2019-12-12 23:22:51 +01:00
ISSOtm 373762dedc Fix lack of newline when passing no files to RGBLINK 2019-12-10 18:35:40 +01:00
ISSOtm b30dfb166b Fix a line over 80 chars 2019-12-08 00:08:44 +01:00
ISSOtm 36db3257f3 Align fatalerror return code with every other one 2019-12-08 00:07:48 +01:00
ISSOtm cad23465a5 Remove flex from the list of dependencies in the README 2019-12-08 00:04:15 +01:00
ISSOtm d23401316e Improve pc-bank test 2019-12-07 23:44:00 +01:00
ISSOtm b49e025703 Allow BANK() in constexpr expressions 2019-12-07 23:43:02 +01:00
ISSOtm e4f4706508 Add tests for new "known self-bank" 2019-12-07 22:15:07 +01:00
ISSOtm 02fe73d1f3 Make BANK("Section") known at assembling time when possible
If the target section is in the current file and its bank is known,
this means this value is known prior to linking.
2019-12-07 22:15:07 +01:00
ISSOtm 74f43d4e09 Add a way to seek a SECTION by name without creating one 2019-12-07 22:15:07 +01:00
ISSOtm 54ed050ecf Make BANK(@) known at assembling time when possible
If the current section's bank is fixed, this means this value is
known prior to linking.
2019-12-07 22:12:57 +01:00
ISSOtm f262d3b34b Fix undefined behavior in readlong
See the new comment for what caused the UB, and how it was fixed
2019-12-07 21:19:13 +01:00
ISSOtm 32f7860a4e Fix possible 0-length array in RGBLINK 2019-12-07 15:23:52 +01:00
ISSOtm b62832e94d Move empty entries warning to -Wextra
Since the behavior actually kinda makes sense, it's better as extra.
2019-12-07 02:48:06 +01:00
ISSOtm e5820312d4 Document actual behavior of empty entries in db and co 2019-12-07 02:46:59 +01:00
ISSOtm f710f21ad8 Reorder warnings alphabetically 2019-12-06 12:06:21 +01:00
ISSOtm 90fefb468b Remove user warnings from -Wall
It does not make sense to include it there, as it's enabled by default.
2019-12-06 12:06:21 +01:00
ISSOtm 21f4cafef5 Make -Werror= with a meta warning an error
The previous behavior was to just enable the meta warning's warnings.
This is an error now because it doesn't make sense to do that, does it?
2019-12-06 12:06:21 +01:00
ISSOtm b1d4be66e4 Remove deprecated "section charmap" feature 2019-12-04 01:56:06 +01:00
ISSOtm ef43ae0eea Add a verbose print each time a file is included 2019-12-04 01:55:01 +01:00
ISSOtm 9976a139de Update test repos to latest commits
They work, and after an upcoming change the current ones are not
going to anymore!
2019-12-04 01:54:22 +01:00
ISSOtm 5718354500 Get rid of joinexpr()
This macro hid away the arguments to the underlying call, and served
no purpose beyond saving the programmer some typing. This is 2019,
people have IDEs (even Vim!) with autocompletion.
2019-12-04 00:21:57 +01:00
ISSOtm 2d7d9eef9f Fix some make checkcodebase errors
- Reorder checkpatch ignore flags alphabetically
- Fix checkpatch WARNINGs and CHECKs when they make sense
- Add more checkpatch ignores
2019-12-04 00:16:28 +01:00
ISSOtm a290e19f46 Make make checkcodebase ignore extern/
That folder contains external code, and modifying it to conform to our
code style would make applying upstream patches, amongst others,
problematic. Therefore, skip checking it.
Ideally, the folder should also be excluded from `make checkpatch`,
but I haven't figured out a way to do that yet.
2019-12-03 23:09:07 +01:00
ISSOtm 92a2be62fe Remove lex rules from Makefile
Since the RGBLINK rewrite, there have been no .l files in the whole codebase
(RGBASM has the C file directly, for better and for worse)
Since flex isn't used anymore, it's a good idea to remove it from the Makefile
so people don't think it's a dependency.
2019-12-03 23:02:38 +01:00
ISSOtm 5410dba4f4 Do prevent using org in linker scripts to go backwards 2019-11-27 01:37:00 +01:00
ISSOtm d93ad2e650 Rename all functions imported from musl
This is to avoid conflicting with libraries, which occurred in the mingw builds
2019-11-23 23:08:44 +01:00
ISSOtm 68410d35d3 Get rid of unlocked_stdio functions
Those did not provide a significant speedup, and are not provided by mingw
2019-11-23 23:00:44 +01:00
ISSOtm ceae4a44f3 Stop using f(un)?lockfile
Those are only useful for locking file IO across threads, but RGBLINK is
single-threaded anyways, so they don't matter. Plus, they aren't provided by
mingw, so that'll remove part of the problem
2019-11-23 22:21:11 +01:00
ISSOtm ea003487aa Use trap_ instead of abort() for consistency 2019-11-23 21:59:36 +01:00
Eldred Habert 401fd8b56b Merge pull request #452 from ISSOtm/warn
Add support for toggleable warnings
2019-11-18 20:58:21 +01:00
ISSOtm 191ee4ba1f Add support for toggleable warnings 2019-11-18 20:45:21 +01:00
ISSOtm 58556f91f7 Disable chcecking for global initialisers
This is specific to the kernel and does not apply to us
2019-11-18 12:45:38 +01:00
ISSOtm faa7893761 Fix develop error in getopt_long_only
The error was due to casting `const` away for permuting argv
elements, which is necessary for a libc for compatibility with older
systems, but not for us.

Checkpatch will complain about the style not being followed, but this is not
our code, so it can be ignored.
2019-11-09 00:48:00 +01:00
Eldred Habert 648df0dc7d Merge pull request #449 from ISSOtm/better_error_msg
Report overlapping sections whenever possible
2019-11-06 09:00:11 +01:00
ISSOtm 44173dbe8b Improve error messages slightly 2019-11-06 08:48:24 +01:00
ISSOtm 7233f568a7 Report overlapping sections whenever possible 2019-11-06 08:40:13 +01:00
Eldred Habert 197f1e9b7b Merge pull request #444 from ISSOtm/fix_develop
Fix errors in `make develop`
2019-11-06 08:34:37 +01:00
Eldred Habert 7063f66b2d Merge pull request #450 from ISSOtm/labels_in_sections
Prevent creating labels outside of sections
2019-11-06 08:33:25 +01:00
Eldred Habert 6e59bcb60e Merge pull request #447 from ISSOtm/long_opts
Add long options
2019-11-06 02:34:26 +01:00
ISSOtm 0649e6d65f Add long options 2019-11-06 00:48:41 +01:00
ISSOtm 072c965ba5 Add musl's implementation of getopt_long_only
Both `getopt_long` and `getopt_long_only` are GNU-specific, so we'll be
copying musl's implementation for portability.
This was retrieved as of commit 90251cf73dfdd44e7a3f085d236e89a7dff1b00b.

musl is licensed as MIT, which is compatible (being identical...) to RGBDS'.
The file is being copied as-is, without a copyright notice or attribution,
but this is only to have a verbatim copy in the history. Those will be added
in the next commit.
2019-11-06 00:40:55 +01:00
ISSOtm 122f5fe12e Prevent creating labels outside of sections
This doesn't make sense, and causes RGBLINK to misbehave
2019-11-04 08:35:00 +01:00
ISSOtm a40d599cd7 Fix extraneous comma in error message 2019-11-04 01:20:23 +01:00
ISSOtm babf36e96e Don't forget to initialize additional banks when using an overlay 2019-11-04 01:16:08 +01:00
ISSOtm d6a43f6a53 Fix RGBGFX man page
- Add color curve option to synopsis
- Fix ordering of `-d`'d description
2019-11-03 21:21:53 +01:00
Eldred Habert ff8e38fcc6 Merge pull request #441 from ISSOtm/linker_error_stack
Make linker output error stacks instead of their top level
2019-11-03 16:41:09 +01:00
Eldred Habert 192f2de704 Merge pull request #440 from ISSOtm/nested_brackets
Allow nested bracketed symbols
2019-11-03 16:40:34 +01:00
Eldred Habert c568b3a976 Merge pull request #439 from ISSOtm/tests_locale
Run tests under a specific locale
2019-11-03 16:30:38 +01:00
Eldred Habert 9c818ef3e1 Merge pull request #438 from ISSOtm/sub_doc_fix
Fix documentation for `sub`, `sbc` and `cp`
2019-11-03 16:18:09 +01:00
Eldred Habert 5aea30f40d Merge pull request #434 from ISSOtm/rgblink_rewrite
Rewrite RGBLINK entirely
2019-11-03 16:15:37 +01:00
ISSOtm 09c9395ff8 Fix NULL deref when fetching an unknown symbol in RPN expressions
was being overwritten with the result, so
was meaningless. Using a temporary instead is better.
2019-11-02 22:37:10 +01:00
ISSOtm 81047afb4b Rework "overflow" error message 2019-11-02 22:37:10 +01:00
ISSOtm f1441cc962 Make linker script error messages more descriptive
Provide file names when appropriate, print memory locations in hex
2019-11-02 22:37:10 +01:00
ISSOtm 50804d661a Fix linkerscript not updating section categorization 2019-11-02 22:37:10 +01:00
ISSOtm 9b895e8a0a Fix bank-fixed sections going in any bank 2019-11-02 22:37:10 +01:00
ISSOtm 4600f70fef Fix address-fixed sections potentially incorrectly assigned
This happened if all space before their fixed location was taken
2019-11-02 22:37:10 +01:00
ISSOtm 9e33cc998f Implement INCLUDE keyword in linker scripts 2019-11-02 22:37:10 +01:00
ISSOtm 5496c2e76f Make linkerscript errors report file names 2019-11-02 22:37:10 +01:00
ISSOtm bf75971a3a Only open files when necessary 2019-11-02 22:37:10 +01:00
ISSOtm 8a59994c0d Fix false positives in readstr
Reading the byte `EOF & 0xFF` would cause an incorrect termination
2019-11-02 22:37:10 +01:00
ISSOtm f2e1b7d868 Add EOF checking in string reading
Fixes rednex/#422
2019-11-02 22:37:10 +01:00
ISSOtm 8c91b31ae6 Fix typo that led to segfault 2019-11-02 22:37:10 +01:00
ISSOtm 302b210470 Fix error in object file documentation 2019-11-02 22:37:10 +01:00
ISSOtm 5bd0076233 Write some doc comments 2019-11-02 22:37:10 +01:00
ISSOtm 0e24adcafd Rewrite RGBLINK entirely
The goal was to improve readability, but along the way a few things were
gained.
- Sorted sym and map files
- Infrastructure for supporting multiple .o versions
- Valgrind-proof, as far as my testing goes anyways
- Improved verbosity messages
- Added error checking
- Performance improvements, see end of commit message

The readability improvement was spurred while trying to make sense of the
old code while trying to implement features such as sorted sym and map
files.
I also did my best to remove hardcoded logic, such that modifications
should be doable; for example, "RAM loading" sections, which are linked
against a different location than the one they're stored at.

Some work remains to be done, see the "TODO:" and "FIXME:" comments.
Further, while regression tests pass, this new linker should be tested on
different codebases (ideally while instrumented with `make develop` and
under valgrind).
The few errors spotted in the man pages (alignment) need to be corrected.
Finally, documentation comments need to be written, I have written a lot of
them but not all.

This also provides a significant performance boost (benchmarked with a
51994-symbol project):

Current master RGBLINK:
2.02user 0.03system 0:02.06elapsed 99%CPU (0avgtext+0avgdata 84336maxresident)k
0inputs+11584outputs (0major+20729minor)pagefaults 0swaps

Rewritten RGBLINK:
0.19user 0.06system 0:00.63elapsed 40%CPU (0avgtext+0avgdata 32460maxresident)k
23784inputs+11576outputs (0major+7672minor)pagefaults 0swaps
2019-11-02 22:37:10 +01:00
ISSOtm 696feae32e Have RGBDS' err and warn output an error message
The stdlib functions specify the difference between `err` and `errx`
is that the former prints a message obtained with `strerror`.
However, RGBDS' implementation breaks that contract, and `warn`'s puts the
added semicolon in the wrong place.
2019-11-02 22:37:10 +01:00
ISSOtm 323738e7b8 Increase version number to 0.3.9 2019-11-01 17:38:43 +01:00
ISSOtm a1d132cd35 Regenerate wwwman 2019-11-01 17:35:46 +01:00
ISSOtm f7c2665e14 Fix errors in make develop 2019-10-30 13:34:21 +01:00
ISSOtm ae0b95ec6d Make linker output error stacks instead of their top level 2019-10-11 17:12:18 +02:00
ISSOtm cdd8200936 Add test for nested brackets 2019-10-10 15:00:59 +02:00
ISSOtm 694075e840 Allow nested bracketed symbols
Fixes #320
2019-10-10 14:58:17 +02:00
ISSOtm d76f994318 Run tests under a specific locale
Fixes #427
2019-10-10 13:23:36 +02:00
ISSOtm 11b7052f94 Fix flag documentation for sub, sbc and cp 2019-10-10 01:01:21 +02:00
Eldred Habert e93d65d736 Merge pull request #425 from ISSOtm/eexpansion_error
Add info about string expansions in error reports
2019-10-03 10:20:49 +02:00
ISSOtm 0f4d543aeb Have make clean delete all .o files in source directory
This will work better if files are rearranged in the future.
This appears to be POSIX-compliant, so why wasn't it used earlier?
2019-09-25 03:17:36 +02:00
ISSOtm dab5f59ed9 Fix location of all relevant SECTIONs in tests
If section placement is changed such that those are no longer guaranteed to be
placed at zero, tests would break when they shouldn't.
2019-09-23 01:28:48 +02:00
Eldred Habert 22a6a82642 Merge pull request #419 from dbrotz/fix-blackslash-tab-at-eof
Handle tabs after backslash at end of file
2019-09-23 00:05:21 +02:00
Eldred Habert 7b592eff8a Merge pull request #420 from dbrotz/disallow-null-char
Reject input that contains null characters
2019-09-22 02:43:06 +02:00
Eldred Habert 4be81d9ffd Merge pull request #416 from ISSOtm/makefile
Improve Makefile
2019-09-22 01:55:51 +02:00
ISSOtm 55fbecee49 Add info about string expansions in error reports
This is especially useful when an EQUS expands to another one, to help
track them.
This is done separately from the file stack as the EQUS stack is separate
(which is itself because EQUS are managed *way* differently).
2019-09-12 10:02:24 +02:00
dbrotz f36a3d5b2a Fix macro and rept buffer overflows
Macro and rept buffers were not always being terminated with newlines
and/or were vulnerable to the final newline being escaped, allowing
buffer overflows to occur. Now, they are terminated with newlines using
the same mechanism as the file buffer.
2019-09-10 03:03:04 -07:00
dbrotz c5e8e4ff83 Reject input that contains null characters
Null characters in the middle of strings interact badly with the RGBDS
codebase, which assumes null-terminated strings. There is no reason to
support null characters in input source code, so the simplest way to deal
with null characters is to reject them early.
2019-09-09 17:27:56 -07:00
Eldred Habert ccc666c1e4 Merge pull request #417 from ISSOtm/zero_sections
Allow 0-byte SECTIONs to be fixed anywhere
2019-09-09 23:32:30 +02:00
dbrotz 89eda89838 Handle tabs after backslash at end of file
Commit 6fbb25c added support for tabs between a \ and the newline it escapes,
but yy_create_buffer() was not updated to handle tabs.
2019-09-09 12:25:26 -07:00
Eldred Habert 17b9838c8f Merge pull request #418 from dbrotz/fix-symbol-macro-arg-0
Print useful error message when '\0' is used in a symbol name
2019-09-09 19:37:44 +02:00
dbrotz 889dd83798 Print useful error message when '\0' is used in a symbol name
AppendMacroArg() was passing 0 to sym_FindMacroArg(), which caused an assertion
failure. Now, AppendMacroArg() prints an error message instead.
2019-09-09 09:46:18 -07:00
ISSOtm 38a372f25f Allow 0-byte SECTIONs to be fixed anywhere
They do not take any room, so they can only be used to define symbols at
a given location. I ran into trouble with such a SECTION failing to be
placed where specified, which doesn't make sense.
This way, it also makes sense to have such a SECTION in the middle of
another one, but that should be fine, since there's no actual overlap.
2019-09-09 00:00:36 +02:00
ISSOtm 2e6f5ac679 Fix unary NOT being broken
nVal wasn't being set, this made the operator a no-op on constant expressions
2019-09-08 21:42:17 +02:00
ISSOtm 7a45fc68d9 Fix incorrect evaluation of && and ||
f29d768 forgot to switch these two `expr->nVal` to `src1->nVal`
This won't break anything, since this wasn't published yet.
I checked, and didn't see any other missed changes.

Reported by pret, I confirmed that `1 && 1` evaluated to 0.
2019-09-08 21:12:31 +02:00
ISSOtm 1288737c0d Clean up suffix rules
Generate .c files from .l files instead of directly a .o
Improve yacc and lex header generation dependency
2019-09-07 13:19:32 +00:00
ISSOtm 5902306271 Have make clean delete all generated .o files
Especially important if the file structure changes, to avoid
leaving stale object files in non-fresh repos.
2019-09-07 12:53:30 +00:00
ISSOtm 2fe4521a96 Remove locallex.o reference
The file was deleted in 8e88659, finish eliminating it
2019-09-07 12:53:30 +00:00
ISSOtm 74673436a1 Separate LDFLAGS from CFLAGS 2019-09-07 12:53:29 +00:00
ISSOtm 481748c279 Make CI output Makefile commands
This is good for debugging Makefiles on systems I don't have (eg. macOS)
End users will not be affected by this, and CI provides a persistent log
so clobbering isn't much of an issue.
2019-09-07 12:53:29 +00:00
ISSOtm 9faa5c7a9e Update docs on char escapes in macro args
Fixes #415
2019-09-05 15:40:54 +02:00
ISSOtm 6fbb25c0da Clean up lexer.c
Remove some hardcoded character values
Allow tabs to be used for line continuations
2019-09-05 15:22:24 +02:00
ISSOtm 65fc42cce5 Remove -Wchkp from develop target
This option has been removed in GCC 9, and according to GCC 8.2's man page,
only has an implementation on Intel MRX anyways.
2019-09-05 05:56:11 +02:00
Eldred Habert 736b7727b6 Merge pull request #400 from NieDzejkob/out.pipe-substitute
test/asm: Generate .out.pipe files on the fly
2019-09-04 18:43:00 +02:00
Jakub Kądziołka fa920f8449 Remove the no-longer-needed .out.pipe files 2019-09-03 23:25:27 +02:00
Jakub Kądziołka 01aa56606f test/asm: special-case include-recursion 2019-09-03 23:25:15 +02:00
Jakub Kądziołka bddd5bc678 test/asm: Generate .out.pipe files on the fly 2019-09-03 22:46:05 +02:00
Eldred Habert f6b7e39ce7 Merge pull request #405 from ISSOtm/output_errors
Make RGBDS behave identically whether writing a .o
2019-09-03 10:05:19 +02:00
clach04 1363dd8f34 Add url link to releases page to readme (#413) 2019-09-03 01:51:38 +02:00
Eldred Habert 8214f0c09d Merge pull request #412 from clach04/patch-1
Clarify install instructions on Windows
2019-09-03 00:50:43 +02:00
clach04 ff7c46f5a6 Readme windows install instructions, alternative install location 2019-09-02 10:19:22 -07:00
ISSOtm b44f5825a5 Make RGBDS behave identically whether writing a .o
Some errors are only tripped in `out_WriteObject`, which was
basically a stub when `-o` wasn't specified. Now, instead,
errors are checked in a separate function before out_WriteFile
2019-09-02 15:04:46 +02:00
Eldred Habert 631910bd67 Merge pull request #395 from ISSOtm/better_error_stack
Improve error stack
2019-09-02 14:33:06 +02:00
ISSOtm 37089ef940 Improve error stack
The old error stack was fairly obtuse and hard to use for debugging.
This improves it notably by ensuring all line numbers are relative
to the file, and not, say, the macro definition.
This is a breaking change if you were parsing the old stack, but
the change should be painless, and the new stack only brings more info.
The syntax is unchanged for files, macros see their name prefixed
with the file they're defined in and a pair of colors, REPT blocks
simply append a '::REPT~n' to the context they're in, where 'n' is
the number of iterations the REPT has done.
This is especially helpful in macro-heavy code such as rgbds-structs.
2019-09-02 14:18:29 +02:00
Eldred Habert 4ef27a0d23 Merge pull request #411 from ISSOtm/recursion_limit
Add a recursion limit
2019-09-02 02:21:16 +02:00
ISSOtm 476ccc9f6b Fix undefined behavior in yyunputstr
Refer to comment at lexer.c:100 for more info
2019-09-02 02:09:59 +02:00
Eldred Habert 89dc14fcaf Merge pull request #408 from ISSOtm/plumbing
Fix memory leaks with macro args
2019-09-01 22:16:27 +02:00
clach04 1ca2f12d24 Update README.rst
Add Windows path note, in preference from adding exes to system locations
2019-09-01 09:51:47 -07:00
ISSOtm 20b2f5ee2f Fix incorrect line numbers with some IF blocks
If a line ended with a string's closing quote, or a newline escape, then
skipping over that line via IF/ELIF/ELSE would fail to count that line,
offsetting the rest of the file.
I have no idea why but for some reason 9829be1 changed *specifically*
`if_skip_to_else` to have incorrect behavior on string endings. The incorrect
behavior on newline escapes seems to have been here since the beginning.
Also added a test to check for both of those behaviors in both functions.

Honestly, it baffles me that nobody ever noticed. I didn't until I started
working on #395.
2019-09-01 03:59:29 +02:00
ISSOtm 3cc67c48cf Add recursion limit info to man and help 2019-08-31 17:34:54 +02:00
ISSOtm f9a04696f2 Add recursion overflow tests 2019-08-31 17:22:43 +02:00
ISSOtm e0e8170fe6 Add recursion limit for string expansions
Unlike macros, REPTs and INCLUDEs, this recursion depth is independent.
This is intentional, because string expansions work very differently.

While it's easy to know when a string expansion begins, checking where it
ends is much more complicated, since the expansion's contents are simply
injected back into the lex buffer. Therefore, the depth has to be checked
after lexing took place.
Because of this, the placement of the expansion end check is somewhat
haphazard, but I think it's good. While I have no certainty, all tests
ended with all expansions properly ended, and I couldn't find any pitfalls.

Finally, `pCurrentStringExpansion` has been made global so error printing
can use it to tell the user if an error occurred inside of an expansion.
2019-08-31 15:50:08 +02:00
Eldred Habert 9b40663d54 Merge pull request #409 from rednex/dd-head
Use POSIX-compatible dd(1) instead of head -c.
2019-08-31 12:59:18 +02:00
Anthony J. Bentley a517f900e4 Use POSIX-compatible dd(1) instead of head -c. 2019-08-30 23:11:28 -06:00
Eldred Habert 350f40300c Merge pull request #403 from dbrotz/multiple-charmaps
Add support for multiple charmaps
2019-08-31 04:44:58 +02:00
dbrotz d3db5f0d76 Add pushc and popc directives 2019-08-30 19:36:23 -07:00
ISSOtm 7e3af4b3cd Make testing external projects use local RGBDS
Currently, the installed version is used instead, which isn't
consistent with the tests, which use the local version.
2019-08-31 04:17:16 +02:00
ISSOtm dfb3072381 Fix memory leaks with macro args
REPT blocks nested in macros (and possibly other cases) leaked
memory on every call. Unlike most other memory leaks, which would
be freed at the end of program execution if they were done properly,
those piled up the more compilation went on.
I believe memory usage could have started being fairly high on
large projects following the "one master file INCLUDEs all the rest"
so this may have actually been worth it.
2019-08-31 03:52:42 +02:00
ISSOtm 02191135a0 Fix possible unterminated string
sym_SetMacroArgID used a `sprintf` that could write no \0.
In practice this was benign because %u cannot print 256 chars,
but better future-proof this.
2019-08-31 03:00:26 +02:00
ISSOtm dc2c97fe0c Comment and improve ParseSymbol and AppendMacroArg 2019-08-31 02:31:46 +02:00
ISSOtm 6068b565f5 Add recursion limit for INCLUDE and macros
(And REPT.)
Not exactly a *recursion* limit, more like a *stack depth* limit,
but calling it "recursion" conveys its purpose better.
The default of 64 is super overkill: even in a a project with
what I believe to be above-average levels of nesting, the
level only peaked at 6.
Keeping in mind the purpose of this is to catch infinite
recursion, which is still caught quickly (in usual cases, anyways),
this default seems sensible.
And it passes tests. What more do you need?
2019-08-31 02:31:42 +02:00
ISSOtm a21cef7190 Say which macro argument caused an error when one does 2019-08-30 20:57:11 +02:00
dbrotz 461ef6cea5 Don't complain about initializing statics
This error is specific to the way the Linux kernel handles statics.
It does not apply to userspace programs.
2019-08-29 22:48:16 -07:00
dbrotz e05199ca1e Add support for multiple charmaps
This adds two new directives: newcharmap and setcharmap.
newcharmap creates a new charmap and switches to it.
setcharmap switches to an existing charmap.
2019-08-29 21:54:06 -07:00
Eldred Habert 12d82eb768 Remove extra entry in error stack on macro not defined (#394)
While working on #392, I noticed that the macro-@ test (as well
as the line-continuation test, but for that one see #393)
printed an additional '@(-1)' entry which doesn't make sense.
2019-08-30 02:14:21 +02:00
Eldred Habert 05becf3f4b Merge pull request #381 from NieDzejkob/rgbgfx-curve
rgbgfx: Add an option to take the CGB's color profile into account
2019-08-29 22:19:36 +02:00
Eldred Habert 3cc7981c82 Merge pull request #402 from dbrotz/fix-386
Fix nested if statements that don't have following whitespace
2019-08-29 22:06:10 +02:00
dbrotz 8f287eeef9 Fix nested if statements that don't have following whitespace
When trying to skip over nested if statements, if there was no whitespace
after an "if", then that "if" would not be recognized. That's a problem since
"if(" and "if{" are also valid ways to start an if statement. This change
will make it so that they are recognized correctly.
2019-08-29 12:37:59 -07:00
Eldred Habert ce05cb5683 Merge pull request #401 from dbrotz/line-cont-test
Get rid of error in line continuation test
2019-08-29 21:23:00 +02:00
dbrotz 17945a7377 Get rid of error in line continuation test
The purpose of the test is to ensure that rgbasm doesn't segfault in this case.
The "Macro '@' not defined" error is unnecessary.
2019-08-29 11:49:17 -07:00
Eldred Habert 3a1b47129e Merge pull request #397 from NieDzejkob/test-local-without-parent
Add a test for a defining local label without a parent
2019-08-29 20:24:36 +02:00
Eldred Habert 6ffa751090 Merge pull request #390 from ISSOtm/print_types
Add "print types" to bracketed symbols
2019-08-29 20:12:32 +02:00
Eldred Habert c3641321d7 Merge pull request #399 from ISSOtm/allow_dots
Allow periods to continue macro args
2019-08-29 20:09:32 +02:00
Eldred Habert 446173f0cb Merge pull request #387 from ISSOtm/set_doesnt_override_equ
Prevent `SET` from overriding constant symbols
2019-08-29 20:08:08 +02:00
Eldred Habert e27f381842 Merge pull request #361 from ISSOtm/better_section_overflow
Improve section overflow error message
2019-08-29 20:04:48 +02:00
ISSOtm a3ee76dddd Allow periods to continue macro args
c75a953 broke my (previously-working) project that defined, via
macros, 'sizeof_.player'.
A test was added to confirm that those are indeed accepted
outside of macros.
2019-08-29 19:51:47 +02:00
ISSOtm 995265c549 Improve testing bracketed symbols
Also test EQU and _RS constants, as well as that EQUS errors out,
and that labels don't work.
2019-08-29 19:16:28 +02:00
Jakub Kądziołka 03629b74d9 Add a test for a defining local label without a parent 2019-08-29 19:14:02 +02:00
Eldred Habert b069278e98 Merge pull request #384 from dbrotz/fix-local-label-segfault
Check if parent exists for local label reference
2019-08-29 19:05:27 +02:00
Eldred Habert 9738c88f95 Merge pull request #383 from dbrotz/fix-380
Change the precedence of == to match the documentation
2019-08-29 17:14:05 +02:00
ISSOtm a21ea30be0 Add tests for bracketed symbols 2019-08-29 17:08:54 +02:00
ISSOtm 64752da42d Add "print types" to bracketed symbols
Should partially cover #178 and close #270.
This allows printing numbers in different bases and without the dollar prefix
This is especially useful in macros because the dollar isnt a valid character
for symbol names, requiring heavy `STRSUB` usage.
2019-08-29 14:04:58 +02:00
ISSOtm e3e18063c6 Prevent SET from overriding constant symbols
Fixes #341
2019-08-27 21:23:36 +02:00
ISSOtm e400eac42b Improve section overflow error message
When trying to fix a section becoming too large, the size it reached is necessary to know whether to optimize away a few bytes or split it entirely.
This error is also commonly encountered when INCBINing too large a slice of a file, in which case the amount of bytes by which the section is too large is again an useful information
2019-08-20 19:13:01 +02:00
dbrotz a6bf77718c Check if parent exists for local label reference
If an attempt is made to reference a local label before any non-local label
is defined, raise an error instead of segfaulting.
2019-08-20 09:57:53 -07:00
dbrotz c2787a9ea9 Change the precedence of == to match the documentation
The documentation states that == has the same precedence as the other
comparison operators.
2019-08-20 08:50:18 -07:00
Antonio Niño Díaz e33e6e2413 Merge pull request #382 from NieDzejkob/checkpatch-bool-member
checkpatch.conf: Don't complain when bools are used in struct
2019-08-20 14:17:15 +01:00
Jakub Kądziołka 3cb56c5a2e checkpatch.conf: Don't complain when bools are used in struct
In RGBDS's codebase, boolean struct members aren't a problem. See
include/asm/main.h, include/gfx/main.h for examples.
2019-08-20 14:43:31 +02:00
Jakub Kądziołka 91984cb7e7 rgbgfx: Add an option to take the CGB's color profile into account 2019-08-20 14:38:17 +02:00
Antonio Niño Díaz b8d5dd1824 Merge pull request #366 from dbrotz/fix-313
Fix signed integer overflow issues
2019-08-17 16:09:09 +01:00
Antonio Niño Díaz 88b66f2941 Merge pull request #364 from dbrotz/fix-362
Don't append invalid characters to symbol name
2019-08-17 16:08:27 +01:00
Antonio Niño Díaz 3c7e59b9e1 Merge pull request #374 from Ben10do/pushs-outside-of-section
Allow PUSHS to be used before a section
2019-08-17 16:07:28 +01:00
Ben Hetherington c4471e3300 Update CONTRIBUTORS.rst
Updated to reflect my current committer identity.
2019-08-16 13:22:19 +01:00
Ben Hetherington 16111f46ef Allow PUSHS to be used before a section
Previously, a PUSHS before a SECTION directive would cause rgbasm to crash when encountering a subsequent POPS.

This is because the subsequently-called out_setCurrentSection() expected the new section to be non-null, which wasn’t the case in this situation. This has been addressed by allowing the ‘null’ section to be set in this function, and only dereferencing it (to set nPC) if a non-null section is to be set.

In practice, this means that PUSHS/POPS can now be used to push/restore a context without a section.
2019-08-16 13:22:19 +01:00
Antonio Niño Díaz b019b03946 Merge pull request #358 from dbrotz/fix-357
Fix buffer overflow when creating patches with long RPN expressions
2019-07-12 00:49:08 +01:00
Antonio Niño Díaz 605acd24ba Merge pull request #372 from jidoc01/master
Document the feature of input from stdin (resolves #371)
2019-07-12 00:48:25 +01:00
jidoc01 c8630eee95 Document the feature of input from stdin
Since #329, rgbasm can get input from stdin. I updated the manpage
file related to it, which explain the description and usages in
rgbasm.
2019-07-08 23:28:46 +09:00
Antonio Niño Díaz 4040555532 Merge pull request #365 from dbrotz/terminate-bracketed-symbol
Terminate standalone bracketed symbol strings
2019-07-07 11:46:43 +01:00
Antonio Niño Díaz defb221c98 Merge pull request #360 from jidoc01/master
Improve charmap structure with trie.
2019-07-07 11:46:08 +01:00
jidoc01 e7dc094e56 Improve charmap structure with trie
Charmap's previous structure was using brute-force comparison for
converting the strings in source files. It always compared given
strings to all of the strings in charmap, which was very costly
in huge projects.
For its improvement, I changed its structure into trie, which is
being used in many string-processing areas. It's now much faster
than before.
2019-07-06 19:25:44 +09:00
Antonio Niño Díaz dfdb107105 Merge pull request #370 from jidoc01/fix_bug
Fix comment bug
2019-07-06 11:10:17 +01:00
Antonio Niño Díaz 9f598dfdb7 Merge pull request #359 from dbrotz/fix-lexer-out-of-bounds
Fix out of bounds array access in lexer
2019-07-06 11:09:43 +01:00
jidoc01 38110a833d Fix comment bug
There is a bug in processing the comments in source files. It's
related to #326. And this bug comes out when you comment something
with the character ';', and include the quotation mark without its
pair in it.

The lastest version of rgbds compiler has a step to parse the given
source to convert its line endings to a unified one, and it
processes quotation marks even before it processes the comments.

I edited a little bit of the source, and it works fine now.
2019-07-05 13:48:24 +09:00
dbrotz 484d15dbb2 Handle unprintable characters more gracefully
* Skip UTF-8 byte order mark at beginning of file
* Error on other unexpected unprintable characters
2019-07-04 17:14:55 -07:00
dbrotz 1decf5d0d4 Fix out of bounds array access in lexer
If the type char is signed, then in the function
yylex_GetFloatMaskAndFloatLen(), *s can have a negative value and be converted
to a negative int32_t which is then used as an array index. It should be
converted to uint8_t instead to ensure that the value is in the bounds of the
tFloatingFirstChar, tFloatingSecondChar, and tFloatingChars arrays.
2019-07-04 17:01:29 -07:00
dbrotz 74e9de1b71 Check for RPN stack overflow in linker 2019-07-04 16:49:23 -07:00
dbrotz 015d2b0830 Fix buffer overflow when creating patches with long RPN expressions
The createpatch() function was using a fixed-size buffer. I've changed it
to be dynamically allocated. I saw that the RPN format used in patches is
slightly different from the one used internally in the assembler, so I
added a new member to the Expression struct to track the patch size.

I've also limited the RPN expression length to 1MB. I realized that the
patch RPN expression could potentially be longer than the internal RPN
expression, so the internal expression would need a limit smaller than
UINT32_MAX. I thought 1MB would be a reasonable limit.
2019-07-04 16:49:09 -07:00
dbrotz c75a9539ba Don't append invalid characters to symbol name
When a macro arg appears in a symbol name, the contents are appended.
However, the contents of the macro arg were not being validated.
Any character, regardless of whether it was allowed in a symbol name,
would be appended. With this change, the contents of the macro arg
are now validated character by character. The symbol name is considered
to end at the last valid character. The remainder of the macro arg is
treated as though it followed the symbol name in the asm source code.
2019-07-04 16:34:47 -07:00
dbrotz ca6149abcf Fix signed integer overflow issues
It seemed that the consensus in our discussions of signed integer
overflow, which invokes undefined behavior in C, was that integer
arithmetic should be two's complement and there should be no warning for
overflows. I have implemented that by converting values to unsigned types
when appropriate. These changes will mostly preserve existing behavior,
except for a few cases that were being handled incorrectly before.

The case of dividing INT_MIN by -1 previously resulted in a CPU
exception and program termination. Now, that case is detected and results
in a warning and a value of INT_MIN.

Similarly, INT_MIN % -1 would have resulted in a CPU exception. Since this
is a mathematically valid operation with a result of 0, it now simply
gives that result without a warning.

I noticed that in rpn.c, there were attempts in certain operation handlers
to validate the nVal members of the source expressions even when the
expressions may have been relocatable expressions with meaningless numbers
for the nVal member. This could have caused spurious errors/warnings, so I
made those handlers confirm that isReloc is false before validating nVal.

Also, integer constants that are too large now result in a warning. The
post-conversion values have not been changed, in order to preserve
backward compatibility.
2019-07-04 16:27:31 -07:00
dbrotz b3120aea25 Terminate standalone bracketed symbol strings
Standalone bracketed symbols like the following weren't being zero-terminated.

X EQUS {Y}

This doesn't apply to bracketed symbols that aren't standalone, but are
instead found in a string. For example, the following works even without this
fix.

X EQUS "{Y}"
2019-07-04 16:01:57 -07:00
Antonio Niño Díaz 54e5bf0f0c Merge pull request #343 from phs/phs/docker
Have a docker file
2019-07-04 23:07:16 +01:00
Antonio Niño Díaz 847cae5b95 Merge pull request #329 from NieDzejkob/allow-stdin-input
Allow using - to indicate input from stdin (resolves #305)
2019-07-04 23:02:42 +01:00
Jakub Kądziołka df15c97b6e Handle zero-byte files gracefully 2019-07-03 16:38:35 +02:00
Jakub Kądziołka 0d97b58265 Avoid potentially implementation-defined behavior when using a pipe as input 2019-07-03 16:38:00 +02:00
Jakub Kądziołka f7bc61e874 Automatic tests for input from stdin 2019-07-03 16:05:54 +02:00
Jakub Kądziołka 8d5a53f529 Handle non-seekable input correctly 2019-07-03 15:38:14 +02:00
Jakub Kądziołka 20f9492899 Allow using - to indicate input from stdin 2019-07-03 15:38:14 +02:00
Antonio Niño Díaz 3cd1d46a1b Merge pull request #356 from NieDzejkob/add-narg-test
Add a test for the behavior of NARG after SHIFT
2019-06-16 22:35:37 +01:00
Jakub Kądziołka 88eceec257 Add a test for the behavior of NARG after SHIFT 2019-06-09 12:58:32 +02:00
Antonio Niño Díaz d00ec024a2 Merge pull request #351 from dbrotz/fix-strsub-strlen
Use code points instead of bytes for STRSUB/STRLEN
2019-06-07 10:31:11 +01:00
Antonio Niño Díaz 0bcd53778a Merge pull request #346 from qguv/tilemap-mirrored-duplicates
gfx: Add mirrored tile check when generating tilemap
2019-06-07 10:29:15 +01:00
Antonio Niño Díaz 7592eaf42b Merge pull request #354 from NieDzejkob/test-runner-stuff
Various test running fixes
2019-06-05 23:23:57 +01:00
Antonio Niño Díaz 12ed9e044a Merge pull request #353 from qguv/checkpatch-path-override
Clarify how to override checkpatch.pl path
2019-06-05 23:15:10 +01:00
Jakub Kądziołka 0a3af87aee Ignore the .git folder of the test repositories
Before this change, doing `git add test` would also add
pokecrystal and the other test repos, even though they
didn't show up on `git status`.
2019-06-05 20:54:21 +02:00
Jakub Kądziołka 4dee999f68 Clean the test repositories before running tests 2019-06-05 20:53:32 +02:00
Jakub Kądziołka 9a4941c794 Allow running the tests from outside of the test folder 2019-06-05 20:52:35 +02:00
Quint Guvernator 2d0fd71159 Clarify how to override checkpatch.pl path 2019-06-04 15:22:45 +02:00
Quint Guvernator 327582be31 Regenerate wwwman 2019-06-04 13:23:33 +02:00
Quint Guvernator 21aea281bd gfx: Add mirrored tile check when generating tilemap 2019-06-04 13:22:59 +02:00
dbrotz 975f85260d Use code points instead of bytes for STRSUB/STRLEN 2019-06-02 16:10:34 -07:00
dbrotz f29d768989 Set all of expr struct's fields in mergetwoexpressions() 2019-05-31 08:59:50 -07:00
Phil Smith 9bd7ecad4c Have a docker file 2019-05-31 08:26:53 -07:00
Antonio Niño Díaz cc458a9693 Fix a few checkpatch issues 2019-05-31 12:34:14 +01:00
Antonio Niño Díaz d2bd9a2368 Merge pull request #337 from dbrotz/one-pass
Use only one pass
2019-05-31 12:10:46 +01:00
dbrotz b909a5063a Include symbol name in 'symbol too long' error message 2019-05-29 10:56:59 -07:00
Marcus Huderle b2c1f6122e Properly set all 16 characters in ROM header title 2019-05-18 19:43:54 -05:00
Antonio Niño Díaz a761e98e18 Run checkpatch against origin/master
The develop branch has been deleted. Remove references to it.
2019-05-10 00:16:27 +01:00
dbrotz e12e7b2acc Don't assign PC to macro symbols
Macros have nothing to do with the current PC, so this doesn't make any sense.
The value isn't ever used either.
2019-05-09 15:01:06 -07:00
dbrotz f927c41abb Add test for referencing a symbol before setting it 2019-05-09 14:46:11 -07:00
dbrotz 249acace08 Prevent non-reloc symbol from shadowing reloc symbol 2019-05-09 12:48:10 -07:00
Antonio Niño Díaz fa37922ca7 Remove develop branch from contributing guide
This branch was meant to contain changes that were considered too risky
to be in master. However, there is not enough activity in the repository
to justify its presence. Both branches are always pointing at the same
commit.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2019-05-09 18:58:25 +01:00
dbrotz 021990b8e0 Properly check if a symbol's full name is too long 2019-05-05 20:21:55 -07:00
dbrotz 540564694c Add missing space to error message 2019-05-05 18:13:10 -07:00
dbrotz 8da4feb83c Use sym_FindSymbol() where possible 2019-05-05 18:10:05 -07:00
dbrotz 23f5e9dacc Use only one pass 2019-05-05 15:50:56 -07:00
Antonio Niño Díaz 6ff9435e0a Merge pull request #335 from dbrotz/fix-334
Dynamically allocate RPN expression buffer
2019-05-05 23:33:36 +01:00
dbrotz 40006c6152 Make yylex() return int 2019-05-02 19:53:45 -07:00
dbrotz b256e4c2e3 Dynamically allocate RPN expression buffer 2019-05-02 19:31:26 -07:00
Antonio Niño Díaz a37a09c09c Merge pull request #328 from NieDzejkob/better-linker-errors
Print location information in linker errors where viable #328
2019-03-10 23:41:14 +01:00
Antonio Niño Díaz 8ece231d8b Merge pull request #327 from NieDzejkob/symbol-length-check
Fix symbol length checking
2019-03-10 23:40:03 +01:00
Jakub Kądziołka e7de0745ad Improve documentation of the object format 2019-03-04 09:45:14 +01:00
Jakub Kądziołka 7af2d5dfe1 Print location information in linker errors where viable 2019-03-03 22:55:17 +01:00
Jakub Kądziołka 2f2f14bf80 Fix symbol length checking
When the while loop in `ParseSymbol` stops because of the symbol length,
`copied` will have the value of `MAXSYMLEN`, which is obviously not
greater than `MAXSYMLEN`. Changing the condition to `>=` fixes the
issue.

As a bonus, the correct union field will now be used. It shouldn't
matter, but it's technically UB to use a wrong one.
2019-03-02 19:11:53 +01:00
jmle c59cb6a828 Increase version number to 0.3.8 2019-02-20 00:10:02 +01:00
Simon Harms 06aaf5b571 Update README.rst
Add instructions to install on Arch Linux through AUR.
2019-02-14 18:03:28 -05:00
Antonio Niño Díaz 65d7909466 Merge pull request #319 from mid-kid/patch-317
Allow linker script to consider section attributes
2019-01-19 16:15:42 +00:00
Antonio Niño Díaz 861192c332 Merge pull request #318 from mid-kid/patch-316
Update a symbol's filename and line when defined
2019-01-19 16:14:11 +00:00
mid-kid c63af05427 Allow linker script to consider section attributes
The linker script now allows you to assign a section with the same
attributes as in the source.
To do this, I've removed a check from AssignSectionAddressAndBankByName
that would never be triggered, due to that condition being checked
before. Shouldn't this and IsSectionSameTypeBankAndAttrs be condensed
into a single function?
2019-01-18 12:37:23 +01:00
mid-kid d07ba6971b Update a symbol's filename and line when defined
Currently, all symbols are assigned a filename and line when they're
first encountered and added to the internal hash table. This is often
not expected and leads to erroneous error messages.
2019-01-12 12:57:58 +01:00
Antonio Niño Díaz 4b40d63dfd Merge pull request #311 from dbrotz/fix-222
Fix #222 and #255
2018-12-10 23:17:39 +00:00
Antonio Niño Díaz a99b7f6902 Merge pull request #314 from dbrotz/fix-314
Fix #314
2018-12-10 23:09:39 +00:00
Antonio Niño Díaz b3391f699f Merge pull request #310 from dbrotz/fix-302
Fix #302
2018-12-10 23:05:22 +00:00
dbrotz 5a3c12cc6b Add test for file ending with \ 2018-12-06 23:27:41 -08:00
dbrotz a05fd9b818 Print full file path in error messages 2018-12-06 22:59:24 -08:00
dbrotz 6c1ec59a5b Use separate function to append newlines 2018-12-05 01:32:06 -08:00
Antonio Niño Díaz e25a4b0abc Merge pull request #309 from dbrotz/master
Fix #308
2018-12-04 21:07:08 +00:00
dbrotz a060f135b8 Only add newlines to file if necessary 2018-12-02 20:43:20 -08:00
dbrotz f5d3087e9b Check if integer constants only contain radix prefix 2018-12-02 16:16:41 -08:00
dbrotz 2795404cd7 Add myself to contributors 2018-12-02 16:01:08 -08:00
Antonio Niño Díaz 16fac50db4 Fix clone of external repository
Signed-off-by: Antonio Niño Díaz <[email protected]>
2018-12-02 23:39:09 +00:00
dbrotz 3806eb3139 Fix ambiguity in const parsing 2018-12-02 13:49:12 -08:00
dbrotz bad66e54fa Fix buffer overflow when file ends with \ 2018-12-01 07:21:25 -08:00
karas 5cb6c4af4b Fix typo in documentation
Signed-off-by: GwanYeong Kim <[email protected]>
2018-08-30 18:53:44 +09:00
Antonio Niño Díaz 69f79f8598 Remove unused str2int()
Signed-off-by: Antonio Niño Díaz <[email protected]>
2018-08-18 00:19:48 +01:00
karas 573011a99e Remove dead code
Fixed: #301

Signed-off-by: GwanYeong Kim <[email protected]>
2018-08-17 18:49:19 +09:00
Antonio Niño Díaz d778b8e71c Update HTML documentation 2018-07-31 20:02:06 +01:00
Anthony J. Bentley 432a7574c9 Remove alphabetical list of keywords.
The original list only existed because the documentation was split
across multiple files. When all keywords are described in a single
document, Ctrl+F suffices to find them.
2018-07-28 02:05:52 -06:00
Anthony J. Bentley 4d2598e7bf Fix Bl -column widths: the arguments are strings as wide as the column. 2018-07-28 02:02:47 -06:00
Anthony J. Bentley 2e565bcb4e Escape some operators. 2018-07-28 01:55:38 -06:00
Anthony J. Bentley 62ecb6da0b Mark up #define with Fd. 2018-07-28 01:55:38 -06:00
Anthony J. Bentley 46fcebe2b5 Use .Fn for defining functions. 2018-07-28 01:55:35 -06:00
Anthony J. Bentley ab1901eeac Remove excess tabs in column lists. 2018-07-28 01:55:35 -06:00
Anthony J. Bentley 29d2fc6ebc Cleanup "Sections" section. 2018-07-28 01:55:28 -06:00
Anthony J. Bentley efe4599bd8 New sentence, new line. 2018-07-28 00:46:16 -06:00
Anthony J. Bentley 4fc1e41b16 @, &, $, {, and } don't need to be escaped. 2018-07-28 00:46:16 -06:00
Anthony J. Bentley e771d60ec0 Eliminate \[dq] escapes and superfluous double quotes.
" can be used directly except in macro lines. Also in some situations
wrapping with a Dq or Ql macro can be more appropriate.
2018-07-28 00:45:54 -06:00
yenatch e2de106d71 Use charmaps in const expressions. 2018-07-06 22:58:58 -04:00
Antonio Niño Díaz adea89f3eb Merge pull request #294 from yenatch/utf-8
Fix UTF-8 characters with an even number of bytes.
2018-07-02 23:10:46 +01:00
yenatch 361015497c Remove signoff step from contributing guide. 2018-07-02 16:04:53 -04:00
yenatch 5e9c433a24 checkpatch: Don't expect Signed-off-by lines in commit messages 2018-07-01 00:05:11 -04:00
yenatch 587159448a Test binary output for rgbasm tests 2018-06-30 23:46:17 -04:00
yenatch 64158cf513 Run checkpatch in a separate build. 2018-06-30 21:58:05 -04:00
yenatch a567365d7c unit test for db "é" 2018-06-30 21:57:34 -04:00
yenatch 57bf220e40 Fix formatting of utf8d table. 2018-06-30 20:07:23 -04:00
yenatch e6e3cc474d Fix UTF-8 characters with an even number of bytes. 2018-06-30 19:41:46 -04:00
Antonio Niño Díaz 33c984e456 Merge pull request #287 from Ben10do/remove-dummymem
Two variables, pSection->Data and tSymbols, were previously set to
dummymem, a global variable that was otherwise not used.

As this can potentially cause alignment warnings on Clang, this commit
replaces that mechanism with a plain old NULL pointer, which is more
generally used as a dummy pointer value.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2018-06-10 22:54:16 +01:00
Antonio Niño Díaz 458f79f44f Fix test projects compilation in OS X
The tool md5sum is required by some of them.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2018-06-06 22:18:29 +01:00
Antonio Niño Díaz 34e04b0327 Re-enable OS X builds in Travis CI
Signed-off-by: Antonio Niño Díaz <[email protected]>
2018-06-06 22:10:21 +01:00
Antonio Niño Díaz cf7bb9e99f Merge pull request #285 from Ben10do/allow-test-repos-to-be-kept
We no longer assume that the test repos don’t exist when we run
run-tests.sh. This allows developers to choose to keep them, to allow
them to run the tests more quickly.

- Add the test repos to the .gitignore.
- Check if the directory for each repo already exists, before trying to
  clone it.
- Do a git pull for each repo, to ensure that existing copies of repos
  are up-to-date.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2018-06-06 22:06:04 +01:00
Ben10do 1af5343e29 Use specific commits when running tests
This ensures that build breaks to any of the test projects don’t immediately cause rgbds tests to fail.

On clone, I’ve set it up to pull the commits since the day before the desired commit. Sadly, this will clone more recent commits that we’re not testing, but at least it ensures that the desired commit can be checked out. This is hopefully a good enough replacement for —depth=1.

Signed-off-by: Ben10do <[email protected]>
2018-06-06 22:00:45 +01:00
Ben10do a5e3a7cbc9 Replace pointers to ‘dummymem’ with NULL
Two variables, pSection->Data and tSymbols, were previously set to ‘dummymem’, a global variable that was otherwise not used.

As this can potentially cause alignment warnings on Clang, this commit replaces that mechanism with a plain old NULL pointer, which is more generally used as a dummy pointer value.

Signed-off-by: Ben10do <[email protected]>
2018-06-06 21:16:53 +01:00
Antonio Niño Díaz df065dbbcb Update html documentation
Signed-off-by: Antonio Niño Díaz <[email protected]>
2018-06-06 19:21:30 +01:00
Eldred Habert fac7247483 Update descriptions of how flags are pushed/popped
Signed-off-by: ISSOtm <[email protected]>
2018-06-06 09:06:07 +02:00
Ben10do 60050af186 Allow test repos to be kept locally
We no longer assume that the test repos don’t exist when we run run-tests.sh. This allows developers to choose to keep them, to allow them to run the tests more quickly.

- Add the test repos to the .gitignore.
- Check if the directory for each repo already exists, before trying to clone it.
- Do a `git pull` for each repo, to ensure that existing copies of repos are up-to-date.

Signed-off-by: Ben10do <[email protected]>
2018-06-03 18:23:19 +01:00
Ben10do 11c47570ce Fix the global checksum calculation in rgbfix
A regression was spotted in rgbfix 0.3.7, where we would accidentally include the first byte of the existing checksum when calculating a global checksum. We now correctly ignore both of the existing checksum bytes.

This was spotted when running rgbfix on the Pokémon Gold/Silver betas, as they have a non-zero global checksum.

Fixes #280.

Signed-off-by: Ben10do <[email protected]>
2018-06-03 10:11:55 +01:00
Antonio Niño Díaz f8b4cc52f6 rgbasm: Allow variations of 'ld [$FF00+c],a'
The following mnemonics are now valid:

    - ld
    - ldh
    - ldio

The following are valid as operands:

    - [$ff00+c]
    - [$ff00 + c]
    - [c]

This is done for consistency with 'ld [$FF00+n],a' and variations of it.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2018-05-20 21:04:47 +01:00
Antonio Niño Díaz 748943f6fc Increase version number to 0.3.7
Signed-off-by: Antonio Niño Díaz <[email protected]>
2018-05-02 20:04:00 +01:00
Antonio Niño Díaz d945c5811c rgbasm: Check the values of operands in bit shifts
The tests are not exhaustive, there are some conditions that aren't
checked. The tests are based in the C standard rules about undefined
behaviour.

This is a compatibility break but, hopefully, all projects are using
sane values. If not, there is no guarantee that the projects will build
in any platform where RGBDS can be compiled, so it would be better to
fix them.

Even though, technically, the left shift of a negative value is always
undefined, some projects rely on its current behaviour. This is the
reason why this doesn't cause a fatal error.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2018-04-28 01:59:37 +01:00
Antonio Niño Díaz 6fe2741f2d Enable GCC options to detect undefined behaviour
GCC has an Undefined Behavior Sanitizer (ubsan), which enables run-time
checks of undefined behaviour. It has been enabled for the `develop`
build target.

A small bug detected with it has been fixed.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2018-04-28 00:57:25 +01:00
Antonio Niño Díaz 24d7cfe0f9 checkpatch: Ignore warnings about SPDX
The Linux kernel expects the SPDX license tag to be in the first line of
all source code files. The reason is that they have many different
license headers, and this simplifies the work for any tool that has to
determine the license of each file.

In this project, the license headers follow the same pattern, so it
isn't useful.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2018-04-27 23:00:29 +01:00
Antonio Niño Díaz 630933b148 rgbfix: Fix checkpatch issues
Signed-off-by: Antonio Niño Díaz <[email protected]>
2018-04-22 21:02:08 +01:00
Antonio Niño Díaz e8a16c6f53 Don't generate output file if overlay isn't found
Previously, the output file was opened before trying to open the
overlay. Because of this, rgblink generated an empty output file if the
overlay couldn't be opened.

Now the overlay is opened (and checked) before the output file, so the
output file is only generated if the overlay is found.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2018-04-22 20:54:48 +01:00
Antonio Niño Díaz 2cb50730a1 Document Section ID == -1 in object files
Signed-off-by: Antonio Niño Díaz <[email protected]>
2018-04-22 20:21:45 +01:00
Antonio Niño Díaz efae6c7fd2 Merge pull request #264 from inmemrgbfix
Rewrite rgbfix to perform most actions in memory.

Limit file operations to a small number that can be reasonably checked,
and do the majority of the actual work on a buffered header in memory
where operations won't fail.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2018-04-22 20:03:32 +01:00
Anthony J. Bentley 8a559beeb8 Rewrite rgbfix to perform most actions in memory.
Limit file operations to a small number that can be reasonably checked,
and do the majority of the actual work on a buffered header in memory
where operations won't fail.
2018-04-05 00:41:09 -06:00
Antonio Niño Díaz 7149fc1e39 tests: Update references
Signed-off-by: Antonio Niño Díaz <[email protected]>
2018-04-03 23:04:29 +01:00
Antonio Niño Díaz 2e695334c1 rgbfix: Add check to malloc()
Signed-off-by: Antonio Niño Díaz <[email protected]>
2018-04-03 22:41:51 +01:00
Antonio Niño Díaz e2b4554a5c Replace tabs by spaces in fprintf()
Signed-off-by: Antonio Niño Díaz <[email protected]>
2018-04-03 22:41:44 +01:00
Antonio Niño Díaz ef87dd5a6e rgbasm: Fix declaration of fatalerror()
Signed-off-by: Antonio Niño Díaz <[email protected]>
2018-04-03 22:41:37 +01:00
Antonio Niño Díaz 4f126b37d0 Merge pull request #261 from warnings
Enable a lot of GCC warnings and cleanup Makefile and compiler macros

Most of the warnings in the GCC documentation have been enabled. As the
build system was using `-Werror`, this made the new builds very
susceptible to any minor change in the compiler. To fix that, this
option has been removed from the default Makefile target and it is only
used when the code is compiled through `make develop`.

The file `stdnoreturn.h` has been modified to remove support for
compilers that aren't actually tested. It now has defines for
`__attribute__((unused))` and it has been renamed to `helpers.h`.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2018-04-03 19:57:04 +01:00
Antonio Niño Díaz 1b4187e51f Cleanup GCC compiler attributes
Added define 'unused_' for '__attribute__((unused))'. The oldest version
of GCC with online docs (GCC 2.95.3, released in March 16, 2001 [1])
already has support for this attribute, so it doesn't make sense to
check the version.

Renamed 'noreturn' to 'noreturn_' for consistency.

[1] https://gcc.gnu.org/onlinedocs/

Signed-off-by: Antonio Niño Díaz <[email protected]>
2018-04-03 19:52:50 +01:00
Antonio Niño Díaz 0daec91683 Check code style as part of the CI tests
If checkpatch.pl detects any ERROR in the new patches, the Travis CI
build will fail.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2018-04-03 00:02:17 +01:00
Antonio Niño Díaz cbaaec98ca Simplify helpers.h
`__attribute__((noreturn))` has been supported since GCC 2.5, that was
released October 22, 1993. It doesn't make sense to check if the version
is at least that one, we are compiling for C99, that is more modern. [1]

Also, remove the MSVC check. This code is never compiled with it so
there may be problems that need to be solved to make it compile. All
releases cross-compiled from linux. If there is an actual need to
support MSVC, the compiler definitions can be added again.

Also, if the compiler is not supported, the compiler helpers default to
nothing, so the code can still compile.

[1] https://gcc.gnu.org/onlinedocs/

Signed-off-by: Antonio Niño Díaz <[email protected]>
2018-04-02 22:53:48 +01:00
Antonio Niño Díaz 895d1d5813 Remove check for C11 in helpers.h
The mandatory CFLAGS in the Makefile make the compiler use C99.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2018-04-02 22:53:48 +01:00
Antonio Niño Díaz e99a651165 Create makefile target to check all warnings
Remove '-Werror' from the default make target to make it easy for
regular users of RGBDS to compile the source code. Only a few basic
warnings are left in that target.

All the warnings have been moved to a new target called 'develop'. This
target is now the one used in Travis CI to check for problems during
compilation.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2018-04-02 22:53:48 +01:00
Antonio Niño Díaz 0ae69b3114 Rename stdnoreturn.h to helpers.h
This file will contain more compiler-specific helpers.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2018-04-02 22:53:48 +01:00
Antonio Niño Díaz 95ccc48d0c Enable -Wundef
Signed-off-by: Antonio Niño Díaz <[email protected]>
2018-04-02 22:53:48 +01:00
Antonio Niño Díaz 29253046d5 Remove C++ check in stdnoreturn.h
This isn't a C++ project, only keep checks for C compilers.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2018-04-02 22:53:48 +01:00
Antonio Niño Díaz 340362d984 Enable a few warning flags
Signed-off-by: Antonio Niño Díaz <[email protected]>
2018-04-02 22:53:48 +01:00
Antonio Niño Díaz 85ece88268 Add default clauses to switch statements
Signed-off-by: Antonio Niño Díaz <[email protected]>
2018-04-02 22:53:43 +01:00
Antonio Niño Díaz 516e4578ea Enable more optional warnings
-Wformat-truncation is set to 1 instead of 2 because in some cases the
return value of snprintf is used to warn about truncations but GCC still
creates a warning for it, preventing the compilation from continuing.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2018-04-01 01:42:55 +01:00
Antonio Niño Díaz 9829be1045 Enable -Wextra
-Wsign-compare has been disabled because flex generates a comparison
that triggers a warning and cannot be fixed in the code.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2018-04-01 01:42:55 +01:00
Antonio Niño Díaz b28a16c0da Enable -Wpedantic
Fix a few warnings related needed to build the source with this option.

Add new exception to .checkpatch.conf.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2018-04-01 00:56:00 +01:00
Antonio Niño Díaz 4d13d57491 Fix behaviour of '@'
When '@' is used as argument of any instruction (LD, JR, JP, etc), the
address it refers to is the address of the first byte of the
instruction. When '@' is used with DB/DW/DL, it refers to the same
address it is being placed at. This means that instructions need an
offset of 1 byte and others need an offset of 0 bytes.

The assembler doesn't evaluate anything related to '@' because it would
only work in sections with a fixed base address. It is left to the
linker. This means that the offset needs to be added to the RPN
expression of the patch that is saved in the linker. It isn't enough by
adding an offset to the final expresion. The following value wouldn't be
calculated correctly (even if it doesn't make sense):

    JP @ * @

The correct patch is `(@ - 1) * (@ - 1)`, not `(@ * @) - 1`.

This patch introduces an offset on 1 byte by default in every line, and
sets it to 0 only if a DB/DW/DL is detected.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2018-03-31 00:43:25 +01:00
Antonio Niño Díaz be6bc7460b Don't save '@' in map and sym files
Signed-off-by: Antonio Niño Díaz <[email protected]>
2018-03-31 00:43:25 +01:00
Antonio Niño Díaz efdd42c6a8 Simplify parsing of variable-length lists
This change removes 2 reduce/reduce conflicts in the parser while
preserving the behaviour of the rules.

Note that now each list with empty elements will only print a warning
per line.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2018-03-31 00:43:02 +01:00
Antonio Niño Díaz c1a97f6541 Allow to JR to numeric constants
Previously, JR was only allowed to labels (in the same section, or
different sections). When trying to JR to an address specified as a
numeric value, rgbasm would fail to calculate the JR offset (as it
doesn't know the final address of the JR so it can't calculate the
difference).

This patch makes rgblink calculate the offset whenever there is a JR.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2018-03-29 23:38:54 +01:00
Antonio Niño Díaz ea4276c7ac Increase version number to 0.3.6
Signed-off-by: Antonio Niño Díaz <[email protected]>
2018-03-20 20:11:38 +00:00
Antonio Niño Díaz 7bce97f817 Fix crash in rgbgfx with height not multiple of 8
Images are allowed to have any arbitrary height if the width is 8. If
the height is not a multiple of 8, the number of tiles calculated won't
be an exact number and it will be rounded down. This patch increases the
number of tiles allocated in this case to prevent rgbgfx from accessing
memory that hasn't been allocated.

The buffers are now initialized to 0 with calloc instead of being
created with malloc.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2018-03-19 21:47:19 +00:00
Antonio Niño Díaz 483a63156b Document character maps
Signed-off-by: Antonio Niño Díaz <[email protected]>
2018-03-15 21:04:43 +00:00
Anthony J. Bentley 5a4bbe4985 Add a new flag, -f, which allows independently fixing or trashing checksums. 2018-03-10 21:48:23 -07:00
Antonio Niño Díaz f86dbafad0 Fix format in manpage
Signed-off-by: Antonio Niño Díaz <[email protected]>
2018-03-07 18:23:44 +00:00
Antonio Niño Díaz 8744d360a3 Fix format of manpage
Signed-off-by: Antonio Niño Díaz <[email protected]>
2018-02-27 19:42:29 +00:00
Antonio Niño Díaz b6bd57a764 Merge pull request #237 from continue-lines
Allow to continue lines

Signed-off-by: Antonio Niño Díaz <[email protected]>
2018-02-26 21:55:19 +00:00
Antonio Niño Díaz f2b55527d5 Update html manpages
Signed-off-by: Antonio Niño Díaz <[email protected]>
2018-02-26 21:49:19 +00:00
Antonio Niño Díaz 84a6899c6c Document line continuation syntax
Signed-off-by: Antonio Niño Díaz <[email protected]>
2018-02-26 21:48:28 +00:00
Antonio Niño Díaz 8cffe22295 Fix style of code sections in manpages
Signed-off-by: Antonio Niño Díaz <[email protected]>
2018-02-26 21:48:26 +00:00
Antonio Niño Díaz 0c85240b97 Allow line continuations in list of macro args
For example:

    PrintMacro : MACRO
        PRINTT \1
    ENDM

        PrintMacro STRCAT(\"Hello\"\,  \
                          \" world\\n\")

It is possible to have spaces after the '\' and before the newline
character. This is needed because Windows line endings "\r\n" are
converted to " \n" before the lexer has a chance to handle them.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2018-02-26 21:47:52 +00:00
Antonio Niño Díaz 58ab88da82 Allow to scape " in lists of macro args
For example:

    PrintMacro : MACRO
        PRINTT \1
    ENDM

        PrintMacro STRCAT(\"Hello\"\,  \" world\\n\")

Signed-off-by: Antonio Niño Díaz <[email protected]>
2018-02-26 21:47:52 +00:00
Antonio Niño Díaz 3e219dee36 Allow to continuate lines except inside macros
Lines can be continuated after a newline character ('\n'):

    DB 1, 2, 3, 4 \
       5, 6, 7, 8

This doesn't work for now in lists of arguments of macros.

It is possible to have spaces after the '\' and before the newline
character. This is needed because Windows line endings "\r\n" are
converted to " \n" before the lexer has a chance to handle them.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2018-02-26 21:47:52 +00:00
Antonio Niño Díaz 6ad5bd2325 Add flag to rgbasm to disable LD->LDH optimization
rgbasm tries to optimize any loads from/to $FF00-$FFFF and generate
LDH 2-byte opcodes instead of regular LD 3-byte opcodes. This is a bit
inconsistent as it only works for constant values. If a load is trying
to access a label in a HRAM floating section, or a section found in a
different object file, this optimization doesn't work.

This means that a simple refactor or code could allow rgbasm to perform
the optimzation or prevent it from doing so. For certain projects, like
disassemblies, this is a problem.

This patch adds flag -L to rgbasm to disable the optimization, and
doesn't change the behaviour of any other existing code.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2018-02-26 21:44:00 +00:00
Antonio Niño Díaz 2a97535e75 Add safeguards against string overflows
Use snprintf instead of other unsafe functions. That way it is possible
to limit the size of the buffer and to ensure that it never overflows.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2018-02-25 22:58:29 +00:00
Antonio Niño Díaz 0e0e12a769 Add CSS file for the html documentation
It has been obtained from here:

http://mdocml.bsd.lv/cgi-bin/cvsweb/mandoc.css

Signed-off-by: Antonio Niño Díaz <[email protected]>
2018-02-24 16:40:55 +00:00
Antonio Niño Díaz 3bebedf1f8 Handle newlines and comments correctly
Newlines have to be handled before comments or comments won't be able to
handle line endings that don't include at least one LF character.

Also, document an obscure comment syntax: Anything that follows a '*'
placed at the start of a line is also a comment until the end of the
line.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2018-02-23 19:24:18 +00:00
Antonio Niño Díaz 2ed937db2c Allow JR between sections
Previously, JR was only allowed if the destination label was in the same
section as the JR. This patch removes this restriction. The check to see
if the relative value overflows is now done when linking the ROM.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2018-02-23 19:21:44 +00:00
Antonio Niño Díaz d243bd04ef Introduce command PRINTI to print integers
PRINTV prints integers in hexadecimal, PRINTI prints them in signed
decimal. For example:

    PRINTT "Error at line "
    PRINTI __LINE__
    PRINTT "\n"

Signed-off-by: Antonio Niño Díaz <[email protected]>
2018-02-23 19:20:52 +00:00
Antonio Niño Díaz 3623638be7 Fix HIGH() and LOW() for constants
HIGH() and LOW() only worked with labels and register pairs.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2018-02-22 21:23:25 +00:00
Antonio Niño Díaz 8ea3669a64 Merge pull request #235 from obskyr/rgbgfx-color
Add color support to rgbgfx (again)!

Signed-off-by: Antonio Niño Díaz <[email protected]>
2018-02-20 19:56:39 +00:00
obskyr 8fe5293077 Allow superfluous height for 1-tile-wide images
Currently used here and there for small, icon-like tiles, it seems.

Signed-off-by: obskyr <[email protected]>
2018-02-20 10:06:33 +01:00
obskyr 825fa915ee Fix rgbgfx's code style
Signed-off-by: obskyr <[email protected]>
2018-02-20 10:06:00 +01:00
obskyr 885e8ea24a Add to contributor list
Signed-off-by: obskyr <[email protected]>
2018-02-20 09:35:07 +01:00
obskyr 898f75ce57 Clarify and update rgbgfx documentation
Signed-off-by: obskyr <[email protected]>
2018-02-20 09:35:00 +01:00
obskyr b8af100c63 Handle grayscale images as expected
Signed-off-by: obskyr <[email protected]>
2018-02-20 09:34:48 +01:00
obskyr 3075945367 Add color and transparency support to rgbgfx
In addition, fix various bugs.
Among them are minor memory issues and edge cases with certain inputs.

Signed-off-by: obskyr <[email protected]>
2018-02-20 09:33:53 +01:00
Antonio Niño Díaz d602ebfde5 Fix typo in rgblink manpage
Signed-off-by: Antonio Niño Díaz <[email protected]>
2018-02-18 19:57:02 +00:00
Antonio Niño Díaz 305512a2b7 Increase version number to 0.3.5
Signed-off-by: Antonio Niño Díaz <[email protected]>
2018-01-28 13:08:00 +00:00
Antonio Niño Díaz a6b244b12e Move version files out of extern folder
The folder extern is reserved for external contributions, not common
files.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2018-01-28 13:07:21 +00:00
Antonio Niño Díaz ceabbeaa2f Fix linkerscript man page
Signed-off-by: Antonio Niño Díaz <[email protected]>
2018-01-27 17:25:21 +00:00
Antonio Niño Díaz 3995852cc5 Fix nit in rgbasm.5 man page
Signed-off-by: Antonio Niño Díaz <[email protected]>
2018-01-27 15:19:18 +00:00
Antonio Niño Díaz 9793bcba6f Fix local execution of run-tests.sh script
Signed-off-by: Antonio Niño Díaz <[email protected]>
2018-01-27 15:04:17 +00:00
Antonio Niño Díaz 0727eb4374 Add test to verify hex codes of all instructions
Signed-off-by: Antonio Niño Díaz <[email protected]>
2018-01-27 14:38:52 +00:00
Antonio Niño Díaz f8f67fcbce Add external projects to Travis CI jobs
Small tests like the ones included in this repository are good to test
individual features, but it is also a good idea to test some real
projects.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2018-01-27 11:14:10 +00:00
Anthony J. Bentley abeca2d305 Prefer snprintf to strncpy when outputting C strings
strncpy is designed to output to fixed‐width buffers, not C strings
(hence its weird null termination behavior). In this case it happens to
work correctly due to the length check but, for style reasons, I would
rather use snprintf. Especially in this case, where it shortens the
code a bit.
2018-01-27 01:22:58 +00:00
Antonio Niño Díaz a7dc86001c Add note about the MIT License in CONTRIBUTING.rst
Also, LICENSE.rst doesn't have any special formatting now, so it has
been renamed to LICENSE.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2018-01-27 00:47:06 +00:00
Antonio Niño Díaz c071586ae5 Remove dependency of reallocarray()
By removing this dependency, all of the code of this repository is
licensed under the MIT license.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2018-01-27 00:30:13 +00:00
Antonio Niño Díaz c6187be210 Remove dependency of strlcpy()
There was only one place where `strlcpy` was still used.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2018-01-27 00:02:44 +00:00
Antonio Niño Díaz f9f3bb7761 Remove dependency of strlcat()
There was only one place where `strlcat` was used, and `snprintf`
actually does a better job at what the code was trying to achieve.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2018-01-27 00:02:26 +00:00
Antonio Niño Díaz 1a5c423984 Relicense codebase under MIT license
With permission from the main authors [1], most of the code has been
relicensed under the MIT license.

SPDX license identifiers are used so that the license headers in source
code files aren't too large.

Add CONTRIBUTORS.rst file.

[1] https://github.com/rednex/rgbds/issues/128

Signed-off-by: Antonio Niño Díaz <[email protected]>
2018-01-26 22:59:02 +00:00
Antonio Niño Díaz b382dffdec Split src/asm/charmap.c into two files
This way it is easier to identify the license of the code.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2018-01-26 22:55:13 +00:00
Antonio Niño Díaz 33e9eb098c Exclude html files from checkpatch
Also, fix 2 nits in the codebase.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2018-01-26 18:57:25 +00:00
Antonio Niño Díaz e77ebfe38a Disable OSX builds in Travis CI
Travis seems to be having some problems with OSX builds, so it's better
to disable them temporarily.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2018-01-25 22:23:43 +00:00
Antonio Niño Díaz 698ed9d5fc Don't clean html files with make clean
Added a new target to remove html files: `cleanwwwman`.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2018-01-25 22:12:31 +00:00
Antonio Niño Díaz b07a8501d6 Fix linkerscript linking errors
The problems were introduced by the following commits:

- 959bfe2a9d

- 975200834e

Signed-off-by: Antonio Niño Díaz <[email protected]>
2018-01-25 22:07:16 +00:00
Antonio Niño Díaz f779e724e2 Fix typo in manpage
Signed-off-by: Antonio Niño Díaz <[email protected]>
2018-01-24 20:29:27 +00:00
Antonio Niño Díaz 494b98e46a Fix html doc file name
Signed-off-by: Antonio Niño Díaz <[email protected]>
2018-01-24 20:29:09 +00:00
Antonio Niño Díaz d1ff057889 Make clean target of Makefile clean html files
The html files generated with `make wwwman` weren't cleaned correctly
with `clean`.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2018-01-23 22:54:37 +00:00
Antonio Niño Díaz 292302c6d1 Move documentation to this repository
Modified Makefile wwwman target to output files inside docs/.

Modified .gitignore to allow *.html files.

Update README.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2018-01-23 21:28:10 +00:00
Antonio Niño Díaz b55fead749 Fix typo in documentation
Signed-off-by: Antonio Niño Díaz <[email protected]>
2018-01-23 20:37:00 +00:00
Antonio Niño Díaz 844e027a18 Increase version number to 0.3.4
Signed-off-by: Antonio Niño Díaz <[email protected]>
2018-01-23 20:30:47 +00:00
Antonio Niño Díaz 0fb80cd7a9 Fix indentation in asmy.y
Remove extra spaces.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2018-01-21 22:51:42 +00:00
Antonio Niño Díaz 311b412f5d Improve error messages
NULL error messages have been given a description.

Messages that weren't descriptive enough now also print the name of the
function that has failed.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2018-01-16 22:39:44 +00:00
Antonio Niño Díaz 975200834e Fix WRAMX BANK offset in the right place
ROMX and WRAMX bank numers are stored in an object file as their number
minus one. This means that this offset has to be applied somewhere.

The old code applied the fix for ROMX and WRAMX in two different places.
It looks like the patch that added support for WRAMX didn't set the
offset correctly in 'src/link/assign.c'. When this was fixed, it was
done in the wrong place, in 'src/asm/asm.y'. This patch moves the fix to
'src/link/assign.c'.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2018-01-16 22:39:44 +00:00
Antonio Niño Díaz c8fa799883 Output error msg when object file can't be opened
In rgbasm, output a fatal error if the destination object file can't be
opened.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2018-01-16 22:39:44 +00:00
Antonio Niño Díaz 7f37eef218 Cleanup BANK related definitions
Simplify comparisons and remove magic numbers.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2018-01-16 00:46:29 +00:00
Antonio Niño Díaz 8521e45edc Reduce SRAM bank number to 16 in rgbasm
The limit was already 16 banks in the linker, which made the previous
limit of 511 useless.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2018-01-14 16:12:29 +00:00
Antonio Niño Díaz 7bd082563d Add CONTRIBUTING.rst file
Signed-off-by: Antonio Niño Díaz <[email protected]>
2018-01-14 14:07:22 +00:00
Antonio Niño Díaz de32e245c9 PUSHS and POPS also affect the symbol scope
Now, when POPS is executed, it restores the symbol scope of the
corresponding PUSHS. That way, the local symbols previously available
can be used again after the POPS.

This is useful in cases like this one:

```
    SECTION "Section 1", ROMX

BigFunction:

    ...

.loop:

    ...

    PUSHS

    SECTION "Section 2", ROMX

DataForBigFunction:
    DB 1, 2, 3, 4, 5

    POPS

    ld  a,BANK(DataForBigFunction)
    ld  hl,DataForBigFunction

    ...

    jr  .loop
```

Signed-off-by: Antonio Niño Díaz <[email protected]>
2018-01-07 23:05:04 +00:00
Antonio Niño Díaz f5164325d2 Convert Markdown files to reStructuredText
Signed-off-by: Antonio Niño Díaz <[email protected]>
2018-01-07 19:22:38 +00:00
Antonio Niño Díaz 959bfe2a9d Allow to request BANK() of sections and PC
The bank of a section can be requested with `BANK("Section Name")`, and
the bank of the current section with `BANK(@)`. In both cases, the bank
number is resolved by the linker.

New commands have been added to the list of RPN commands of object
files, and the rest has been moved so that new additions don't force a
new change in the number of the enumerations.

Increase object file version, as it is now incompatible with the old
format.

Update manpages to reflect the new ways of using `BANK()` and the new
format of the object files.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2018-01-07 02:05:05 +00:00
Antonio Niño Díaz d24cf11ad4 Make list of linker symbols common
That way the definitions of the assembler and the linker are always the
same.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2018-01-05 00:32:50 +00:00
Antonio Niño Díaz 8d89ba39d4 Decouple commands in checkpatch Makefile target
Signed-off-by: Antonio Niño Díaz <[email protected]>
2018-01-04 21:54:10 +00:00
Antonio Niño Díaz b04596a32b Move externs to header files
Follow Linux kernel coding style.

Remove exception from checkpatch.pl configuration file.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2018-01-04 01:28:23 +00:00
Antonio Niño Díaz 8e8865940a Join list of keywords of locallex.c and globlex.c
It made sense to have them in different files when the toolchain
targeted systems other than the GB. Now, there are no generic and
system-specific keywords because there is only one supported system.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2018-01-04 01:28:23 +00:00
Antonio Niño Díaz 3c14f9760f Fix echo command in checkpatch target in Makefile
Signed-off-by: Antonio Niño Díaz <[email protected]>
2018-01-03 19:46:48 +01:00
Antonio Niño Díaz 3c15b141e0 Add checkpatch.pl config file and Makefile targets
This is used to verify the coding style of patches.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2018-01-02 17:09:36 +01:00
Antonio Niño Díaz 72f801283d Cleanup code of rgbasm
Follow Linux kernel coding style.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2018-01-02 17:09:36 +01:00
Antonio Niño Díaz 2ffaf72e39 Cleanup code of rgbfix, rgbgfx and external libs
Follow Linux kernel coding style.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2018-01-02 13:16:53 +01:00
Antonio Niño Díaz f41c532400 Cleanup code of rbglink
Follow Linux kernel coding style.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2018-01-02 13:16:53 +01:00
Antonio Niño Díaz ec76431c51 Replace C types by stdint.h types
Not all occurrences have been replaced, in some cases they have been
left as they were before (like in rgbgfx and when they are in the
interface of a C standard library function).

Signed-off-by: Antonio Niño Díaz <[email protected]>
2017-12-31 15:46:22 +01:00
Antonio Niño Díaz 71961a88a0 Use M_PI instead of PI
Signed-off-by: Antonio Niño Díaz <[email protected]>
2017-12-31 15:16:08 +01:00
Antonio Niño Díaz ba944527ec Replace ULONG by uint32_t
All affected `printf` have been fixed.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2017-12-31 15:16:08 +01:00
Antonio Niño Díaz 87c9d819a1 Replace SLONG by int32_t
All affected `printf` have been fixed.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2017-12-31 15:16:08 +01:00
Antonio Niño Díaz 13c0684497 Replace 8 and 16 bit custom types by stdint.h types
Signed-off-by: Antonio Niño Díaz <[email protected]>
2017-12-31 15:16:08 +01:00
Antonio Niño Díaz c24cab6d1d Use NOT operator to complement bits instead of XOR
The previous way of doing it relied on the variable being 32-bit wide.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2017-12-31 15:16:08 +01:00
Antonio Niño Díaz 0cbe6abbd5 Increase package version number to 0.3.3
Signed-off-by: Antonio Niño Díaz <[email protected]>
2017-12-31 15:16:08 +01:00
Antonio Niño Díaz fe6e5e445b Remove warning on DB/DW/DL emtpy lists
This warning was added in 781c90b940 as a
way of catching the following cases, which are most likely programmer
mistakes:

    DB 1,, 2
    DB 1, 2,

However, the warning was also triggered in the following case:

    DB

It can be used as a replacement of:

    DS 1

In this case, it shouldn't output a warning.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2017-12-29 12:05:57 +01:00
Antonio Niño Díaz 781c90b940 Add warnings for empty elements in lists of consts
Even though this behaviour is documented (empty elements are treated as
0), it can be misleading. By having a warning, compatibility is
maintained and potential problems in the code can be detected.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2017-12-07 22:37:43 +00:00
Antonio Niño Díaz e7a8bb1140 Fix and document DL keyword
This keyword acts like DB or DW but for 32-bit values.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2017-12-07 22:36:50 +00:00
Antonio Niño Díaz f1c13af703 Fix warning about unused variable
Signed-off-by: Antonio Niño Díaz <[email protected]>
2017-10-27 20:21:03 +01:00
Antonio Niño Díaz 90bc8d9110 Reintroduce EQU __LINE__
It was removed in commit 6198cc185c, but
the documentation wasn't updated back then.

It makes more sense to reintroduce it now than to remove it from the
docs.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2017-10-26 23:23:22 +01:00
Antonio Niño Díaz 193cc06561 Improve error messages
Signed-off-by: Antonio Niño Díaz <[email protected]>
2017-08-21 23:48:24 +01:00
Antonio Niño Díaz f3b475453f Replace fprintf by errx for consistency
Signed-off-by: Antonio Niño Díaz <[email protected]>
2017-08-21 23:35:56 +01:00
Antonio Niño Díaz 0c71f5a4e9 Check return values of fread in rgblink
Signed-off-by: Antonio Niño Díaz <[email protected]>
2017-08-21 23:35:52 +01:00
Antonio Niño Díaz 4b0dfd4f4a Initialize variables in rgbfix
Signed-off-by: Antonio Niño Díaz <[email protected]>
2017-08-21 23:35:45 +01:00
Antonio Niño Díaz 2d117f68c9 Fix compiler warnings about unused return values
In some implementations of libc the function fread has the attribute
`warn_unused_result`, that is treated as an error by the compiler as
specified in the flags passed to it.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2017-08-17 23:03:42 +01:00
Antonio Niño Díaz 8954858bf7 Fix warning about using uninitialized variable
Signed-off-by: Antonio Niño Díaz <[email protected]>
2017-08-06 22:20:39 +01:00
Antonio Niño Díaz 4877e6dbba Merge pull request #196 from error-msgs
Print more useful error messages when redefining symbols

Signed-off-by: Antonio Niño Díaz <[email protected]>
2017-08-01 19:46:58 +01:00
Antonio Niño Díaz ec171c5f00 Make object file magic string a common define
Signed-off-by: Antonio Niño Díaz <[email protected]>
2017-07-29 13:11:26 +01:00
Antonio Niño Díaz 840ddcecd2 Update dates in manpages
Signed-off-by: Antonio Niño Díaz <[email protected]>
2017-07-22 15:34:24 +01:00
Antonio Niño Díaz c00f7409ee Improve linker symbol redefinition error messages
Now, the object file in which each definition is (as well as the source
file and line) are printed with the error message.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2017-07-22 15:27:30 +01:00
Antonio Niño Díaz 92449a4fe4 Save object file name of each symbol in linker
This is useful to generate error messages when there is a symbol that
appears in more than one object file.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2017-07-22 15:27:25 +01:00
Antonio Niño Díaz 4e2a035838 Print location of definition of redefined symbols
When trying to define a symbol with a name that is used by another one,
print the location of the first definition in the error message.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2017-07-22 15:27:22 +01:00
Antonio Niño Díaz df25fa73af Update documentation of object files
Signed-off-by: Antonio Niño Díaz <[email protected]>
2017-07-22 15:27:17 +01:00
Antonio Niño Díaz 03bb2d04c3 Increment version number of object files
The previous change has broken compatibility of object files, so it is
needed to increment the version number to make the linker reject files
generated with the old code.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2017-07-22 15:27:14 +01:00
Antonio Niño Díaz 4dc376b0ee Save location information of symbol definitions
Now, object files save the file name and line number where each global
symbol is defined.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2017-07-22 15:27:06 +01:00
Antonio Niño Díaz 3dec5698db Merge pull request #188 from version-string
Add command to print version string

Signed-off-by: Antonio Niño Díaz <[email protected]>
2017-07-22 14:10:10 +01:00
Ben10do f8bbe9be48 Add support for unions
Unions allow multiple memory allocations (using ds, etc.) to share the
same space in memory.

This allows games to use the same memory for different purposes,
depending on their state.

This also adds documentation on how to use the new UNION, NEXTU, and
ENDU keywords.
2017-07-22 14:03:17 +01:00
Antonio Niño Díaz 4d01b2d5ac Document ELIF
Signed-off-by: Antonio Niño Díaz <[email protected]>
2017-07-22 10:45:17 +01:00
Antonio Niño Díaz 086f02c1d9 Add EQUs with the version numbers of RGBDS
Document new EQUs.

Add missing EQUs to list of keywords in documentation.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2017-07-22 10:27:49 +01:00
Antonio Niño Díaz 8ed6c32ae7 Reorder getopt switch options alphabetically
Signed-off-by: Antonio Niño Díaz <[email protected]>
2017-07-22 10:14:02 +01:00
Antonio Niño Díaz d0e0525302 Add -V to all programs to show the version
This option has been added to all programs of the toolchain, and it
prints the version string of the toolchain.

Manpages and help command line output updated.

Add missing 'w' flag to the command line output of rgbasm. It was
correctly documented in the manpages.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2017-07-22 10:14:02 +01:00
Antonio Niño Díaz 318c981c00 Add code to determine a version string
If the folder where the code is compiled is a valid git repository, the
version string is generated with `git describe`. If it isn't a valid
repository, a string included in the source code is used instead. This
one must be updated regularly as the toolchain is developed.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2017-07-22 10:14:02 +01:00
YamaArashi 5c7db42fc4 Added ELIF
In addition, make some formatting changes, and add some extra error handling (for when ELIF, ELSE, or ENDC are encountered without a corresponding IF).
2017-07-21 22:32:15 +01:00
Ben10do 4be92e14e6 Add shebang to test shell scripts
This ensures that the test scripts are correctly run with the Bourne shell, regardless of the (potentially more exotic) shell that is used to invoke the script.
2017-07-20 19:21:06 +01:00
Antonio Niño Díaz 1b155d9d4c Fix typo in documentation of RSRESET
Signed-off-by: Antonio Niño Díaz <[email protected]>
2017-07-18 21:48:19 +01:00
Antonio Niño Díaz f9a1aba0d8 Allow CFLAGS to be modified from make command line
Previously, if the user wanted to modify CFLAGS, it was necessary to add
the options used in the Makefile as well, which doesn't make sense.

This patch splits CFLAGS into CFLAGS and the previously removed
REALCFLAGS so that the user can modify the arguments passed to the
compiler without having to worry about things like passing the list of
include directories.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2017-07-15 20:10:28 +01:00
Antonio Niño Díaz fe65e07cb6 Fail when using negative constants if not allowed
Some commands, such as `DS`, `BANK[n]`, etc, don't allow the use of
negative constants, but there wasn't any check to prohibit the code from
trying to do so.

This patch adds the `uconst` type to the parser to use when a constant
is expected, but it mustn't be negative.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2017-07-01 14:31:58 +01:00
Antonio Niño Díaz bb12806da1 Fix indentation
Signed-off-by: Antonio Niño Díaz <[email protected]>
2017-07-01 14:31:58 +01:00
Antonio Niño Díaz fa36042131 Add missing documentation of RL command
Signed-off-by: Antonio Niño Díaz <[email protected]>
2017-07-01 14:31:39 +01:00
Antonio Niño Díaz efaad99f25 Update manpage documentation about labels
- Local labels can now be exported.
- Local labels can be declared as Scope.Label in addition of .Label.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2017-06-13 20:16:42 +01:00
Antonio Niño Díaz 62d820c261 Merge pull request #181 from Ben10do/reference-local-symbols
Allow local labels to be referenced (and exported)

Signed-off-by: Antonio Niño Díaz <[email protected]>
2017-06-12 21:46:32 +01:00
Ben10do a53d795361 Add tests for explicit definitions of local labels
These check that “Parent.child” may be used in place of “.child”, and that “WrongParent.child” may not be used in the scope of “Parent”.
2017-06-12 19:50:02 +01:00
Sanqui 2e60c4dd2e Add tests for remote local symbols 2017-06-12 19:36:52 +01:00
Ben10do ce8a13a562 Allow local symbols to be referenced
Local symbols can now be referenced outside the scope of their parent, by using the syntax “Parent.Chlid”.

- Local symbol names are now stored internally as “Parent.Child”.
- The symbol’s scope field no longer forms a linked list of the prior local symbols; it will now always contain the parent.
- Add the ability use EXPORT and GLOBAL with local symbols.
- Reduce duplication between findsymbol() and findpsymbol(), as well as between sym_AddLocalReloc() and sym_AddReloc().
2017-06-12 19:36:46 +01:00
Antonio Niño Díaz ff2321a8ce Make fatalerror and yyerror consistent
There are two ways in which the assembly process can fail:

1. If there is a really big problem that compromises the whole process,
   the assembler has to stop right there and generate an error message.
   This happens with unterminated REPT loops, macros, etc.

2. If the problem isn't that big and the process can still continue,
   even though the final result is invalid, the assembler can try to
   continue and warn the user about all errors it finds in the code.

This patch clarifies the use of each function and replaces the function
used in two places by the correct one.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2017-04-29 15:02:57 +01:00
Antonio Niño Díaz 4228e3e890 Document dependency problem for EQUS and MACRO
This is hard to detect in MACROs, as there are legitimate uses for
MACROs that call themselves recursively.

For an EQUS, the problem is that its value may be modified at different
points in the source code, so the only way to detect a possible problem
is by doing an analysis at each usage of the EQUS.

Also, since an EQUS may expand to the name of a MACRO and a MACRO can
use an EQUS, it becomes even harder to check all possible problems that
come out of it. It's better to let this task to the programmer.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2017-04-26 22:02:47 +01:00
Antonio Niño Díaz 023b574fc5 New warning for rgbasm and fixes in error messages
Signed-off-by: Antonio Niño Díaz <[email protected]>
2017-04-26 00:57:29 +02:00
Antonio Niño Díaz a77df57f1c Merge pull request #177 from AntonioND/an/section-checks
Improve section size checks and buffer handling

Signed-off-by: Antonio Niño Díaz <[email protected]>
2017-04-25 13:31:06 +02:00
Antonio Niño Díaz 8f553e89ce Merge pull request #176 from makefile-cleanup
Cleanup Makefile

Signed-off-by: Antonio Niño Díaz <[email protected]>
2017-04-25 13:29:52 +02:00
Antonio Niño Díaz b7810ffdb3 Check for section overflows in rgbasm
When allocating a section, allocate only the max possible size for that
type (only applies to ROM0 and ROMX).

When finding an overflow, in any kind of section, output an error with
the location of the line of code that caused the overflow.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2017-04-24 14:29:27 +02:00
Antonio Niño Díaz 0d3401058d Check max section sizes in rgblink
The max size of some section types depends on the flags passed to
rgblink. Instead of doing in rgbasm some checks (for the sections with
fixed size) and others in rgblink, all checks are now done in rgblink.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2017-04-24 02:05:30 +02:00
Antonio Niño Díaz 6e123ccc36 Optimize allocation of buffers for sections
Instead of allocating 0x4000 bytes for all sections and resize them as
needed, allocate 0x8000 bytes and don't let them to be resized. This is
the max possible size (ROM0 when ROMX sections aren't present).

Buffers are not needed for RAM sections, this patch changes the code so
that it only allocates buffers for ROM sections.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2017-04-24 02:05:30 +02:00
Antonio Niño Díaz f2724df566 Fix rgblink error messages about prohibited sections
Signed-off-by: Antonio Niño Díaz <[email protected]>
2017-04-23 20:45:39 +02:00
Antonio Niño Díaz 646d71d927 Remove unused code
Signed-off-by: Antonio Niño Díaz <[email protected]>
2017-04-23 20:25:19 +02:00
Antonio Niño Díaz 9b9b41e605 Fix install instructions
It isn't needed to create the folders manually, the Makefile does it
automatically.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2017-04-23 14:34:33 +02:00
Antonio Niño Díaz 907ccfb280 Cleanup Makefile 2017-04-23 13:32:32 +02:00
Antonio Niño Díaz fcd7c117e7 Fix man page documentation for dependcy files
Signed-off-by: Antonio Niño Díaz <[email protected]>
2017-04-22 11:43:28 +02:00
Antonio Niño Díaz 323922d854 Merge pull request #174 from makedepend
Generate make-style dependency files

Signed-off-by: Antonio Niño Díaz <[email protected]>
2017-04-22 11:40:16 +02:00
Antonio Niño Díaz f97e3bad33 Merge pull request #171 from NieDzejkob/master
Implement separate time constants

Signed-off-by: Antonio Niño Díaz <[email protected]>
2017-04-22 11:36:59 +02:00
Antonio Niño Díaz 64415555f1 Merge pull request #175 from NieDzejkob/man
Fix some man installation locations

Signed-off-by: Antonio Niño Díaz <[email protected]>
2017-04-19 19:46:58 +01:00
NieDzejkob ab2aef3f2b Fix some man installation locations 2017-04-19 13:18:18 +02:00
NieDzejkob 947db1e21b Implement numeric time and date constants 2017-04-19 13:12:08 +02:00
Antonio Niño Díaz cde607c09c Deps file can only be created if object file specified
Signed-off-by: Antonio Niño Díaz <[email protected]>
2017-04-17 22:02:18 +01:00
Antonio Niño Díaz 739b113f57 Print dependencies of all included files
Files that weren't found with the absolute path weren't added as
dependencies even if they were found after considering the list of
include directories.

This patch makes rgbasm print the complete path (including the include
directory path) in these cases.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2017-04-17 20:27:58 +01:00
Antonio Niño Díaz 64585eebf6 Merge branch 'makedepend'
Signed-off-by: Antonio Niño Díaz <[email protected]>
2017-04-17 19:29:25 +01:00
Antonio Niño Díaz 1050acc290 Remove useless link in documentation
Signed-off-by: Antonio Niño Díaz <[email protected]>
2017-04-17 18:21:08 +01:00
Antonio Niño Díaz 466bb9ed0b Fix links in man pages
Signed-off-by: Antonio Niño Díaz <[email protected]>
2017-04-17 18:14:49 +01:00
Antonio Niño Díaz 83348100f3 Improve MinGW target of Makefile
It works now with an install of MinGW for both Win32 and Win64. It needs
libpng and zlib.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2017-04-17 17:28:07 +01:00
Antonio Niño Díaz 57bf32f35a Point at the documentation from README
Signed-off-by: Antonio Niño Díaz <[email protected]>
2017-04-17 14:49:57 +01:00
Antonio Niño Díaz 0030e0371a Rename object file format description man page
Signed-off-by: Antonio Niño Díaz <[email protected]>
2017-04-17 14:15:46 +01:00
Antonio Niño Díaz 42400ec6a0 Fix links in HTML documentation
Signed-off-by: Antonio Niño Díaz <[email protected]>
2017-04-16 23:08:33 +01:00
Antonio Niño Díaz 2e793fb7dc Clean wwwman target of Makefile
The substitution of OpenBSD by General is not portable.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2017-04-16 22:52:10 +01:00
Antonio Niño Díaz ac69e9863e Fix documentation in HTML format
For some reason, `No` looks weird in the HTML version of the docs.

Some other random fixes.

Tables in src/asm/rgbasm.5 are still broken in the HTML docs.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2017-04-16 22:50:54 +01:00
Antonio Niño Díaz 59c065cf31 Merge pull request #165 from AntonioND/an/rgbasm-manual
Add documentation of rgbds to man pages and cleanup code

Signed-off-by: Antonio Niño Díaz <[email protected]>
2017-04-16 20:13:49 +01:00
Antonio Niño Díaz 729683fb1f Remove RPN_RANGECHECK
Leftover code from ASMotor.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2017-04-16 19:55:00 +01:00
Antonio Niño Díaz ed6e4c4769 Clean object file format code and documentation
Remove unused code.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2017-04-16 19:54:58 +01:00
Antonio Niño Díaz d92c284b85 Add documentation about the object file format
Copied from the HTML documentation and updated.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2017-04-16 19:54:55 +01:00
Antonio Niño Díaz 26af7fcffe Add complete documentation of rgbds to man pages
Copied from the old html documentation and fixed where it was needed.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2017-04-16 19:54:50 +01:00
Antonio Niño Díaz f7f697c267 Fix parsing of first line of included linkerscripts
When including a linkerscript from a parent one, the lexer didn't
include a newline character because the INCLUDE command was handled
before reaching the newline. This behaviour is needed to parse the last
line of a linkerscript correctly (it doesn't have a newline character).

However, this meant that when the included file was being parsed, the
first line was considered a continuation of the last line of the parent
script (the INCLUDE command), which means that the first line of an
included linkerscript could only contain a comment (or nothing at all).

This patch adds a newline character to the buffer used by the lexer so
that the parser will receive a newline and it will handle the first line
of the included file as expected.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2017-04-14 17:07:01 +01:00
Antonio Niño Díaz 554b5292de Rename ISO 8601 timestamp defines
The previous names were ridiculously long.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2017-04-12 22:19:53 +01:00
Antonio Niño Díaz a7393d7e45 Merge pull request #163 from AntonioND/an/iso-8601
Add equates with ISO 8601 date and time

Signed-off-by: Antonio Niño Díaz <[email protected]>
2017-04-10 23:34:12 +01:00
Antonio Niño Díaz fe9e4f0583 Merge pull request #169 from AntonioND/an/travis-test
Add Travis CI configuration file

Signed-off-by: Antonio Niño Díaz <[email protected]>
2017-04-10 22:59:10 +01:00
Antonio Niño Díaz 362aea22bd Fix conflict in yacc
`LD HL,n16` and `LD SP,n16` are handled in a different rule as
`LD r16,n16`, but they are also part of that rule.

This patch converts the `LD r16,n16` rule into two rules, one for doing
`LD BC,n16` and other one for `LD DE,n16`.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2017-04-10 22:57:05 +01:00
Antonio Niño Díaz 9bc6083e49 Add Travis CI configuration file
Signed-off-by: Antonio Niño Díaz <[email protected]>
2017-04-10 22:10:26 +01:00
Antonio Niño Díaz 2b5ad9dc38 Make test scripts return error code
Make them executable.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2017-04-10 22:10:10 +01:00
Antonio Niño Díaz 5679c7066b Restore behaviour of option -w and add option -d
rgblink option -w has been restored to its previous behaviour: make WRAM
a continous section instead of spliting it into WRAM0 and WRAMX.

To enable DMG mode, option -d has to be used instead. This option
automatically enables -w.

Update tests.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2017-04-10 20:03:52 +01:00
Antonio Niño Díaz 4395ed893a Merge pull request #168 from Ben10do/fix-implicit-yyparse
Fix implicit declaration of yyparse()

Signed-off-by: Antonio Niño Díaz <[email protected]>
2017-04-10 19:51:28 +01:00
Ben10do 0d80f60fcc Fix implicit declaration of yyparse()
This was causing compilation errors, as yyparse() hadn’t been defined in lexer.l.
2017-04-10 10:44:31 +01:00
Antonio Niño Díaz 7097b9885e Fix clean target of the Makefile
Two html documentation files weren't cleaned as expected.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2017-04-09 22:06:49 +01:00
Antonio Niño Díaz f2c207cb44 Remove EX instruction
This is leftover code from ASMotor.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2017-04-09 21:51:30 +01:00
Antonio Niño Díaz be50f2d302 Remove unused patch enum element
If the next release is going to break compatibility with older object
file formats it doesn't make sense to keep this.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2017-04-09 21:25:20 +01:00
Antonio Niño Díaz fa767f3228 Merge pull request #161 from AntonioND/an/linkerscript-include
Add support for including files in linkerscript

Signed-off-by: Antonio Niño Díaz <[email protected]>
2017-04-09 17:19:13 +01:00
Antonio Niño Díaz 5cfa15f963 Add equates with ISO 8601 date and time
Added `__TIMESTAMP_ISO_8601_LOCAL__` and `__TIMESTAMP_ISO_8601_UTC__`,
with the correct ISO 8601 representation of time and date from years to
seconds (including local timezone in the local time string).

Also, if the current time cannot be obtained from the OS, it will output
a warning and the time strings will be filled with '?' instead of
numbers and characters.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2017-04-09 16:49:34 +01:00
Antonio Niño Díaz 23584a584f Fix __FILE__, __TIME__ and __DATE__
If they don't have quotes when passed to sym_AddString() they can't be
used at all by the assembler. I suppose nobody actually used them, they
seem to have been broken forever.

Added a comment to the function to say how to use it correctly for
strings.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2017-04-09 15:40:06 +01:00
Antonio Niño Díaz 53fa608161 Deprecate IMPORT keyword
IMPORT is simply useless, any symbol that isn't found in the current
file is automatically flagged as imported symbol.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2017-04-08 18:47:10 +01:00
Antonio Niño Díaz 1154a173cc Merge pull request #153 from AntonioND/an/opcode-ref
Add GBZ80 opcode reference man page

Signed-off-by: Antonio Niño Díaz <[email protected]>
2017-04-08 18:43:21 +01:00
Antonio Niño Díaz ca3e55cc45 Update remaining dates in man pages
Signed-off-by: Antonio Niño Díaz <[email protected]>
2017-04-08 18:18:59 +01:00
Antonio Niño Díaz 206275df57 Add support for including files in linkerscript
Files can now be included with the following syntax:

    INCLUDE "path.link"

The maximum include depth is 5.

Fixed linkerscript parser and lexer error messages so that they are more
informative (show file and line of the error).

Man page updated.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2017-04-08 18:10:24 +01:00
Antonio Niño Díaz 3d8396b86f Remove progname variable
The error message shouldn't specify the name of the binary, that's
supposed to be known by the caller.

Update test reference outputs.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2017-04-08 18:10:14 +01:00
Antonio Niño Díaz 77546e9c58 Make WARN output a warning instead of an error
This is the expected behaviour.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2017-04-08 18:09:02 +01:00
Antonio Niño Díaz 540f8597d4 Update history in man pages
Fix format in LICENSE file.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2017-04-08 18:08:57 +01:00
Antonio Niño Díaz e3109af2f8 Rename OPT_CONTWRAM to OPT_DMG_MODE
Now, it will also make sure that VRAM bank 1 isn't used.

Man page updated.

Tests added.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2017-04-08 18:08:51 +01:00
Antonio Niño Díaz cf99f33dd6 Fix reference list of hex codes
Fix tabulations.

Add missing byte to STOP.

Add comments about where HL+ and HL- are used.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2017-04-08 17:43:06 +01:00
Antonio Niño Díaz 0b6438ae0a Add GBZ80 opcode reference man page
Signed-off-by: Antonio Niño Díaz <[email protected]>
2017-04-08 17:38:04 +01:00
AntonioND 928b347dfc Merge pull request #158 from Ben10do/remove-legacy-object-files
Remove support for legacy object files
2017-04-08 13:30:15 +01:00
AntonioND ce21cfad4e Merge pull request #160 from AntonioND/an/high-low
Implement HIGH() and LOW() operators
2017-04-08 13:30:10 +01:00
Antonio Niño Díaz dda3a066be Add test for HIGH() and LOW()
It compares the results of the operators with the expected result if
doing the same thing manually.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2017-04-06 22:40:38 +01:00
Antonio Niño Díaz a6a47ff66d Implement HIGH() and LOW() operators
They work with the 16-bit registers BC, DE and HL, returning the
corresponding 8-bit register. HIGH() works with AF as well, returning A.

They also work with any kind of constant or symbol, generating a RPN
patch in the object file if the value is not defined at assembly time.

They work with macro arguments as well.

Signed-off-by: Antonio Niño Díaz <[email protected]>
2017-04-06 22:40:34 +01:00
Daniel Hauck bfcef01211 Add DESTDIR to Makefile
Allow separate definition of binary and manpage directory.

Document Makefile changes in README.
2017-04-06 20:47:14 +01:00
AntonioND 07861b3b4a Output warning with deprecated section types
Code that uses keywords HOME, DATA, CODE or BSS generates warnings.

Signed-off-by: AntonioND <[email protected]>
2017-04-06 20:30:21 +01:00
AntonioND 24439003f3 Remove newlines from warning message strings
Signed-off-by: AntonioND <[email protected]>
2017-04-06 20:30:21 +01:00
AntonioND 3c43cc14d9 Remove unused code
Signed-off-by: AntonioND <[email protected]>
2017-04-06 20:30:21 +01:00
AntonioND 52081f32f0 Add flag -w to rgbasm to disable warnings
A lot of warnings are being added (and more will come) so it makes sense
to be able to disable them in legacy source that generates warnings but
is otherwise correct.

Signed-off-by: AntonioND <[email protected]>
2017-04-06 20:30:21 +01:00
Ben10do 6e5a28226b Include object file version in error message
When an unsupported object file version is encountered, the version number is now printed in the displayed error message.
2017-04-06 08:02:28 +01:00
Antonio Niño Díaz 2783a36b17 Add missing license header to man page
Signed-off-by: Antonio Niño Díaz <[email protected]>
2017-04-06 00:00:56 +01:00
Anthony J. Bentley 2c3afc833f Add license information to manpages. 2017-04-05 23:39:42 +01:00
AntonioND 0f3b708dce Merge pull request #157 from AntonioND/an/error-undef-diff
Output error message if diff of labels not defined
2017-04-05 23:08:37 +01:00
AntonioND 7eb9101d43 Update README and LICENSE files
Add history of RGBDS and original license.

Signed-off-by: AntonioND <[email protected]>
2017-04-05 01:24:36 +01:00
Ben10do 032e698f46 Update the object file documentation
Updates the object file documentation in mylink.h to match the newest object file format.
2017-04-05 01:10:00 +01:00
Ben10do 63103c050d Remove support for old object files
Remove support for RGB0 and RGB1-2 object files, reducing the amount of duplicate work that needs doing when maintaining the linker in the future.

A new error message has also been implemented if an unsupported object file version has been encounted, which informs the user that they should reassemble.
2017-04-05 01:09:51 +01:00
AntonioND 7e107ab41a Update references of linker tests
Signed-off-by: AntonioND <[email protected]>
2017-04-04 23:13:42 +01:00
AntonioND a009a372c5 Remove noyywrap from src/link/lexer.l
Workaround for flex version 2.6.3.

Signed-off-by: AntonioND <[email protected]>
2017-04-04 23:13:36 +01:00
AntonioND 5f299bfe6c Fix whitespace
Replace spaces by tabs for consistency. The rest of the codebase uses
tabs, so the linkerscript parser has to change.

Removed trailing tabs in all codebase.

Signed-off-by: AntonioND <[email protected]>
2017-04-04 22:14:46 +01:00
AntonioND 07cc4fb8fd Remove warnings when calculating banks
getsymbank() is used for more things than just when the code explicitly
has a BANK() operator, which causes a lot of noise when building code
that has more than one object file and places variables on HRAM or OAM.

Signed-off-by: AntonioND <[email protected]>
2017-04-04 21:56:22 +01:00
AntonioND 720ae59af8 Merge pull request #154 from AntonioND/an/tiny-contwram
Make the options -t and -w of rgblink consistent
2017-04-04 21:42:20 +01:00
AntonioND e63e801e9c Output error message if diff of labels not defined
When calculating the difference of addresses between two labels, for it
to be defined, either:

- Both of them must have their absolute address defined.
- They belong to the same section, so their relative addresses are
  compatible.

This patch adds a check to make sure that any other case is detected so
that the programmer can correct the code.

This applies to rgbasm. The difference of labels can be used, for
example, as argument of DS. The linker can't resize sections, which
means that the final value must be defined when creating the object
file.

Signed-off-by: AntonioND <[email protected]>
2017-04-04 21:40:59 +01:00
AntonioND 2abdc9c59d Add whitespace to error and warning messages
Test reference output updated.

Signed-off-by: AntonioND <[email protected]>
2017-04-03 23:46:19 +01:00
AntonioND be200593d6 Fix typo in README
This is the correct name since 2016.

Signed-off-by: AntonioND <[email protected]>
2017-04-03 23:43:32 +01:00
AntonioND 43228f16f0 Improve README
Signed-off-by: AntonioND <[email protected]>
2017-04-03 22:17:20 +01:00
AntonioND f14b061ea7 Add script to update references of rgbasm tests
Update test references.

Signed-off-by: AntonioND <[email protected]>
2017-04-03 21:36:42 +01:00
AntonioND f431b384a2 Add tests for rgblink options -t and -w
Signed-off-by: AntonioND <[email protected]>
2017-04-03 21:29:22 +01:00
AntonioND 7e3720b627 Make options -t and -w consistent
Instead of converting from ROMX to ROM0 with -t and preventing the use
of WRAMX at all with -w, make each option prohibit the type of section
they affect.

This is a good idea because it can prevent a developer from making
mistakes when switching from using the options to not using them.
Generally, a change from using one single bank to multiple banks is
something that will take a lot of effort, and forgetting sections in
ROM0 or WRAM0 will only make the free space of those areas to be
reduced (and maybe prevent compilation), but it won't cause any problems
because of a forgotten bank swap in the code.

Signed-off-by: AntonioND <[email protected]>
2017-04-03 21:22:16 +01:00
AntonioND e9ed81074b Rename OPT_SMALL to OPT_TINY
This way it is easier to identify the flag passed to the binary (-t).

Signed-off-by: AntonioND <[email protected]>
2017-04-03 21:22:16 +01:00
AntonioND e16af28676 Automate and improve rgblink test
Check all sections when testing BANK().

Add scripts to verify the tests and update the reference if needed.

Signed-off-by: AntonioND <[email protected]>
2017-04-03 21:19:39 +01:00
AntonioND 25be5c6561 Improve error and warning output
Improve error messages generated by `errx()`, `warnx()` and similar.

Set `progname` to a static string with the name of the program so that
the path of the binary isn't included in error messages.

Signed-off-by: AntonioND <[email protected]>
2017-04-03 21:16:43 +01:00
AntonioND e4b4e427f1 Return bank 0 for labels in HRAM
Instead of returning the internal representation of the linker, return
0 when using BANK() on a label in HRAM.

Also, generate a warning when calculating the bank of labels in OAM
and HRAM, as there is no valid reason for doing it, so it's likely a
programming mistake.

Signed-off-by: AntonioND <[email protected]>
2017-04-03 21:15:14 +01:00
AntonioND 2138bb46fd Fix generation of html man page in Makefile
Signed-off-by: AntonioND <[email protected]>
2017-04-02 21:08:53 +01:00
AntonioND ec5eb4f9ff Merge pull request #152 from Ben10do/update-readme-for-mac
Update the README’s Mac-specific instructions
2017-04-02 18:08:47 +01:00
Ben10do b31632b51d Update the README’s Mac-specific instructions
- Rename the “Installing RGBDS (UNIX)” section to “Building RGBDS”, as that’s what we’re doing, regardless of platform.
- Update references of Mac OS X to macOS.
- State that only libpng and pkg-config need to be downloaded with Homebrew; the others are pre-installed along with Xcode.
- State that RGBDS itself is available through Homebrew.
2017-04-02 17:57:51 +01:00
AntonioND e50e3e5a23 Remove trailing whitespace
Signed-off-by: AntonioND <[email protected]>
2017-04-02 17:46:14 +01:00
AntonioND f63339472e Update reference output of tests
Due to recent changes, lots of tests generated a slightly different
error output.

- bank-noexist : This test doesn't generate any error output now as
  unknown labels are left for the linker to resolve.

- null-in-macro : This test used to crash. Now, the parser verifies that
  a MACRO ends in ENDM, generating an error message if not.

Signed-off-by: AntonioND <[email protected]>
2017-04-02 17:18:08 +01:00
AntonioND 43fd1ee024 Fix some signed/unsigned comparison warnings
Signed-off-by: AntonioND <[email protected]>
2017-04-02 17:08:12 +01:00
AntonioND d61a0a8a8f Cleanup Makefile
Signed-off-by: AntonioND <[email protected]>
2017-04-02 17:07:40 +01:00
AntonioND ec44b554e8 Merge pull request #150 from Ben10do/deprecation-positions
Add a warning() function, similiar to other error handlers
2017-04-02 17:03:03 +01:00
AntonioND 01a710a47d Remove Zero Page linker patch RPN_PCEZP
This patch isn't used because it's meant to be an optimization for
labels in the memory region 0x2000-0x20FF. That memory region doesn't
have anything special on the Game Boy, and there are no instructions
optimized to read or write from there, so it was probably meant for
another hardware that was supported by ASMotor in the past.

Signed-off-by: AntonioND <[email protected]>
2017-04-02 16:19:45 +01:00
Ben10do ff2ba7290c Add a warning() function, similiar to yyerror()
This function produces a similar output to the other error handlers, including printing to stderr, and including a stack trace. However, ‘warning’ is displayed instead of ‘ERROR’, and the compilation does not fail.

This function is now used for the deprecation warnings, ensuring that these errors can be found.
2017-04-02 13:18:29 +01:00
AntonioND 53842cd07d Create man5 folder when installing
`make install` would blindly try to copy `rgblink.5` even if the
destination folder didn't exist.

Signed-off-by: AntonioND <[email protected]>
2017-04-02 00:40:35 +01:00
AntonioND 85ff75d2d3 Merge pull request #146 from AntonioND/an/same-name
Prohibit sections from having the same name
2017-04-02 00:36:28 +01:00
AntonioND adef2e18cc Fix bank assignments from linkerscript
Even though the bank number was read from the linkerscript and the
linker verified that each section could be mapped in the final rom, the
bank number was never actually set by the linkerscript parser.

Signed-off-by: AntonioND <[email protected]>
2017-04-02 00:22:37 +01:00
AntonioND 5ba8405dfa Prohibit sections from having the same name
To make the behaviour of the linkerscript consistent, every section read
from an object file must have an unique name. This is needed as the
linkerscript uses the name of sections to place them and it expects
every section to have a different name.

This doesn't break compatibility with the old behaviour that allowed to
continue sections if they had the same name, bank number and starting
address. That's still allowed because `rgbasm` outputs a single section
if this functionality is used, it is transparent to `rgblink`.

Signed-off-by: AntonioND <[email protected]>
2017-04-01 15:33:17 +01:00
AntonioND f0d4750ebc Fix rgblink.5 man page installation path
The man page rgblink.5 was installed in the `man1` folder instead of
`man5` as expected.
2017-04-01 15:06:26 +01:00
AntonioND eed098ac8e Merge pull request #140 from AntonioND/an/linkerscript
Implement linkerscript
2017-04-01 10:33:49 +01:00
AntonioND 64dbcc0912 Update README.md
Inform about the actual dependencies.

Signed-off-by: AntonioND <[email protected]>
2017-03-28 22:19:50 +01:00
AntonioND 5947ca10dc Document linkerscript format in manpage
Signed-off-by: AntonioND <[email protected]>
2017-03-28 22:19:50 +01:00
AntonioND d1ed4fbded Use linkerscript parser in rgblink
Signed-off-by: AntonioND <[email protected]>
2017-03-28 22:19:50 +01:00
AntonioND 22d4a10cb6 Implement linkerscript parser
Signed-off-by: AntonioND <[email protected]>
2017-03-28 22:19:45 +01:00
AntonioND dfb99618f5 Document missing build options
Signed-off-by: AntonioND <[email protected]>
2017-03-28 19:37:18 +01:00
AntonioND 6b21e02c95 Merge pull request #143 from Sanqui/parametrize-makefile
Parametrize install arguments in Makefile
2017-03-28 12:49:23 +01:00
Sanqui 011c2c953b Parametrize install arguments in Makefile 2017-03-28 13:22:33 +02:00
AntonioND 8eb1a42e31 Merge pull request #141 from AntonioND/an/deprecate-jp-hl
Declare some opcodes obsolete
2017-03-24 23:23:43 +00:00
AntonioND c51aac0c20 Declare some opcodes obsolete
They are still working, they just output a warning.

`jp [hl]` is confusing as it may be thought that the CPU reads the value
pointed by hl and jumps to it.

`ldi a,hl` and `ldd a,hl` are also confusing as they load from the
address pointed by `hl`, the correct mnemonic should say `[hl]`.

Signed-off-by: AntonioND <[email protected]>
2017-03-24 23:22:30 +00:00
AntonioND 6feaba2343 Document -w option of rgblink
This option hadn't been added to the manpage.

Signed-off-by: AntonioND <[email protected]>
2017-03-23 22:12:06 +00:00
AntonioND 0867476bde Allow ',' to be escaped in string literals
It should only be needed for macro arguments, added to string parsing
function as well for consistency.
2017-03-19 00:05:50 +00:00
AntonioND fa962b9470 Merge pull request #139 from chastai/escape-cb
Allow { and } to be escaped in string literals
2017-03-18 23:54:59 +00:00
Christophe Staïesse b8642bf3af Allow { and } to be escaped in string literals
As stated in the documentation but that was not actually implemented.
2017-03-18 16:23:41 +01:00
AntonioND 317b206fa8 Improve map file output
Print the name of each section along with the size, base and end
addresses. If a section is empty, don't print the end address, as it
can overflow if the base address is 0.

Signed-off-by: AntonioND <[email protected]>
2017-03-15 23:52:56 +00:00
AntonioND 469e3e7c86 Merge branch 'contiguous-wram' of git://github.com/TwitchPlaysPokemon/rgbds into TwitchPlaysPokemon-contiguous-wram 2017-03-15 21:00:06 +00:00
AntonioND 9193710ff9 Merge pull request #131 from Sanqui/overlay
Add overlay to rgblink
2017-03-15 20:42:32 +00:00
Sanqui 263c9222ab Require all sections to be fixed when using overlay 2017-03-13 17:08:27 +01:00
AntonioND 947d767c64 Merge pull request #135 from Ben10do/improve-assign-error-messages
Improve assignment error messages
2017-03-12 17:06:54 +00:00
AntonioND 82cf3eb48f Merge pull request #134 from Ben10do/oam-sections
Add support for OAM Sections
2017-03-11 12:18:40 +00:00
Ben10do a75c15ec46 Improve assignment error messages
Make the error messages in assign.c more descriptive, including the name of the section that caused the error, and its alignment.
2017-03-10 23:21:59 +00:00
Ben10do 3dcfe2b9f6 Add support for OAM Sections
Allows sections (and labels within) to be defined that correspond to the Game Boy’s Object Attributes Memory.
2017-03-10 22:18:14 +00:00
Ben10do 523b7538f0 Replace magic numbers with BANK_COUNT_* constants
Previously, some instances of the number of banks for each section remained hardcoded. These have been replaced with BANK_COUNT_* constants.

As a side-effect, this could fix a theoretical bug when using BANK(label) when the label is in a high SRAM bank (≥ 4).
2017-03-10 19:24:54 +00:00
Sanqui bc2f885d29 Also require ROM0 sections to be fixed when using overlay 2017-03-02 23:02:56 +01:00
Sanqui bd00b9ab59 Merge branch 'master' of github.com:rednex/rgbds into overlay 2017-03-02 22:46:19 +01:00
AntonioND 4f86a12539 Merge pull request #125 from Ben10do/section-alignment
Implement byte alignment for data
2017-03-02 09:17:46 +00:00
Ben 7e2457c9be Re-allow alignment of 0 bits 2017-03-02 08:29:28 +00:00
Ben10do 7993d3455d Update alignment error handling
Ensure (in rgbasm) that the alignment value is between 1-16. Replaces the previous “alignment must not be negative” check.
2017-03-02 08:02:05 +00:00
Sanqui c9daf80f11 Merge github.com:rednex/rgbds into overlay 2017-02-28 18:58:58 +01:00
Sanqui 5a7faa7dff Add overlay to rgblink manpage 2017-02-28 18:48:09 +01:00
AntonioND 7b8d4de35c Merge pull request #16 from yenatch/eval-rpn-bank
rgbasm: Evaluate BANK() arguments to verify they exist.
2017-02-27 21:21:45 +00:00
AntonioND c7fe281c86 Merge pull request #114 from Ben10do/fix-asm-tests
Fix issues in rgbasm raised by the tests
2017-02-27 21:09:04 +00:00
AntonioND fa8f25a4de Merge pull request #123 from Ben10do/deduplicate-e-doc
Remove duplicate documentation of -E
2017-02-27 20:35:13 +00:00
AntonioND 7c2cae7a32 Merge pull request #127 from rogersachan/patch-1
Convert README to markdown
2017-02-26 22:28:10 +00:00
AntonioND 92b81b1d5a Merge pull request #79 from yenatch/longer-charmap
Increase the length of charmaps.
2017-02-26 22:04:26 +00:00
AntonioND 42b5be24b4 Merge pull request #120 from TwitchPlaysPokemon/extra-sram
16-bank SRAM
2017-02-26 21:53:57 +00:00
AntonioND 14fea5f659 Merge pull request #119 from Ben10do/add-end-checks
Verify that IFs, REPTs and MACROs are terminated
2017-02-26 21:49:22 +00:00
AntonioND 1e16a0ff85 Merge pull request #121 from TwitchPlaysPokemon/master
Fix WRAM0 symbols returning bank 512 to BANK() expression in linker
2017-02-26 21:45:53 +00:00
Roger 7adf1dd502 Convert README to markdown 2017-02-25 16:15:05 -05:00
Anthony J. Bentley 0588e42520 Link to HTML documentation from the manpage. 2017-02-23 21:09:32 -07:00
Anthony J. Bentley 2eb748278b Move HTML docs to a different repo. 2017-02-23 21:07:11 -07:00
Ben10do 1ab93a194e Implement ALIGN keyword in rgbasm
The ALIGN keyword specifies the number of bits that should be zero at the start of a section. It works in a simliar fashion to BANK.
2017-02-23 15:00:57 +00:00
Ben10do 1b05c43b97 Implement byte alignment in section assingment
Yay, more refactoring of the section assignment… This version of the linker will allocate sections by their alignment, and then by their size (largest first, in both cases).

In future, this may be improved by using dense packing (as suggested by #83).
2017-02-19 22:43:45 +00:00
Ben10do e4cbf773f6 Add alignment of sections to objects
Aligned sections can now be created with out_NewAlignedSection(). This information is stored in created object files, and read by the linker.

The names of each section are also included in the object file, enabling potential improvements to error messages in the future.
2017-02-19 22:35:32 +00:00
Ben10do b07c04cd74 Implement a malloc-based readasciiz()
Instead of reading into a pre-sized buffer, this function now uses malloc to create a buffer, and resizes it if necessary.

This reduces the risk of memory issues if a long string (< 255 chars) was encountered.
2017-02-19 22:20:21 +00:00
Ben10do 9be7c4c849 Remove duplicate documentation of -E
Remove Sanqui’s documentation of the -E argument to rgbasm, in favour of bentley’s better-worded one.
2017-02-07 11:05:35 +00:00
scnorton 6d1c60b0a6 Contiguous WRAM 2017-02-06 16:31:57 -05:00
PikalaxALT c485ad94f2 Fix WRAM0 symbols returning bank 512 to BANK() expression in linker 2017-02-06 08:38:07 -05:00
PikalaxALT 998cfe1bdd 16-bank SRAM 2017-02-06 08:27:32 -05:00
Anthony J. Bentley 5ee058f217 Merge branch 'linker-refactor-assign' of https://github.com/Ben10do/rgbds 2017-02-05 23:24:13 -07:00
Ben10do 38372c59ed Verify that IFs, REPTs and MACROs are terminated
Ensure that IF constructs, REPT blocks, and MACRO defintions are terminated with ENDC, ENDR, or ENDM respectively. If they are not, print an error and stop assembly.

As well as aiding a forgetful programmer, this reduces the risk of memory problems if the file ends less than four bytes after the block starts.
2017-02-02 16:27:53 +00:00
Ben10do 420ea638a7 Refactor section assignment in linker
Deduplicates and generalises a lot of code in assign.c:

- Replace area_AllocAbs*AnyBank() with area_AllocAbsAnyBank() function
that accepts a section type parameter
- Replace area_Alloc*AnyBank() with area_AllocAnyBank()
- Replace FindLargest*() with FindLargestSection()
- Replace Assign*Sections() with AssignBankedSections()
- Add VerifyAndSetBank(), which enables bank checks (and addition with
BANK_*) to be centralised
- Refactor the initialisation of AssignSections(), removing some magic
numbers and only setting MaxAvail[i] once
- Overhaul the duplicated cases throughout AssignSections()
2017-01-27 08:56:36 +00:00
Ben10do 951c9b66f4 Don't segfault on null bytes in REPTs and MACROs
Previously, the copyrept() and copymacro() functions would halt their
first loop (in which they determine the length of the block)
prematurely,  causing an underflow when setting len, eventually causing
memory issues.

Whilst this doesn’t solve the len underflow entirely (e.g. if the file
ends immediately without an ENDR/ENDM), it should help with this exact
scenario of null bytes (as #50).
2017-01-26 22:01:03 +00:00
Ben10do 0a66e14307 Fix division by zero crashes in instructions
Previously, rgbasm could crash with a floating point exception if an
instruction includes a division or modulo by 0. Fixes #49.
2017-01-26 21:32:06 +00:00
Ben10do b40c567aee Add ldi a, [hl] and ldd a, [hl] instructions
These are equivalent to ld a, [hl+] and ld a, [hl-] respectively.
2017-01-26 16:55:00 +00:00
Anthony J. Bentley 547abfefc1 Merge branch 'fatal-error-noreturn' of https://github.com/Ben10do/rgbds 2017-01-25 00:47:25 -07:00
Ben10do 06f0472f81 Emit a single error when using BANK incorrectly
Previously, if BANK is used when defining a section that’s not ROMX,
WRMAX, SRAM or VRAM, a second error message would appear, e.g. “(null)
bank value $1 out of range $5d to $0”.

This would appear due to the usage of uninitialised variables. This
change ensures that the uninitialised variables are not accessed when
using an invalid section.

This also silences compiler warnings about usage of uninitialised
variables.
2017-01-24 11:50:18 +00:00
Ben10do defd4f589e Add noreturn attribute to fatalerror()
Should silence compiler warnings that expect fatalerror() to return.
2017-01-24 11:38:26 +00:00
Anthony J. Bentley dc4a98048d Simplify string copy by using strlcpy(). 2017-01-24 01:26:55 -07:00
Anthony J. Bentley efaa6d9ff7 Add .gitignore. 2017-01-24 01:19:16 -07:00
Anthony J. Bentley ab19dab899 Merge branch 'include-cli' of https://github.com/AntonioND/rgbds 2017-01-24 01:18:28 -07:00
Ben10do e86a70d2cb Fix the name of the GNUmakefile
GNU make actually looks for ‘GNUmakefile’, not ‘GNUMakefile’.

Consequently, GNU make would erroneously attempt to use the standard
makefile, instead of the GNU-specific one. This would cause an error
when attempting to import png.h, due to PNGFLAGS not being correctly
set.
2017-01-23 23:46:44 +00:00
AntonioND a91187d8dc Increase number of include paths through CLI
Increase number of include paths that can be passed through the
command line interface. The previous number, 16, is only good enough
for small projects. 128 is still an arbitrary number, but it is harder
to reach.
2017-01-22 23:08:10 +00:00
AntonioND 0b5e074591 Output error messages for command line includes
The code that adds an include path to the array of paths doesn't check
the lenght of the path (which can cause overflows because of strcpy).

It doesn't check if the max number of paths has been reached, either.

This patch adds error messages for such cases, giving the user more
information than before and crashing the assembly instead of
continuing and failing when it can't find a file to include.
2017-01-22 23:04:50 +00:00
Anthony J. Bentley f8531ed410 Add a thin wrapper makefile for GNU Make.
GNU Make 3.x doesn't support the "!=" syntax for shell assignment,
although 4.x does, BSD Makes do, and it has been submitted to POSIX
for possible inclusion in the standard. Unfortunately, GNU Make 3.x
is still in common use, so provide an alternative makefile (GNU Make
reads "GNUmakefile" instead of "Makefile" by default) that sets the
variables and then reuses the rest of the default Makefile.
2016-12-16 23:23:37 -07:00
Francisco Requena 0a8401741d Fixes rgbgfx linkage issues with old libpng (pre 1.4.2) 2016-12-17 04:04:45 +01:00
Anthony J. Bentley a079a69b7c Add a note about installing libpng. 2016-10-22 14:13:19 -06:00
Anthony J. Bentley d86cb41972 Rename png.h to makepng.h, to avoid conflicts with libpng's png.h. 2016-10-22 14:03:14 -06:00
yenatch 95cd960b3b Fix the order of flags when including libpng.
This apparently does matter.
2016-10-11 21:54:18 -06:00
Anthony J. Bentley bed43d2530 Document rgbasm -E. 2016-09-05 02:46:59 -06:00
Anthony J. Bentley c02b04f7d2 Merge branch 'export-all-2' of https://github.com/Sanqui/rgbds 2016-09-05 02:43:23 -06:00
Anthony J. Bentley 2339f0fbae Merge branch 'an/fix-gfx-prefix' of https://github.com/AntonioND/rgbds 2016-09-05 02:35:24 -06:00
Anthony J. Bentley 6e0aca47d4 Declare string uppercase/lowercase functions unconditionally.
Avoid naming them str*(), because such names are reserved by ISO C.
2016-09-05 01:41:39 -06:00
Anthony J. Bentley a8c603a7e8 Removed the wrong pkg-config. 2016-09-05 01:41:39 -06:00
Anthony J. Bentley 97a31c8fc0 Remove duplicate PKG_CONFIG. 2016-09-05 01:34:17 -06:00
Anthony J. Bentley c3c31138dd Add rgbgfx. 2016-09-05 01:29:45 -06:00
AntonioND fbb825af3b Fix GB graphics prefix output
The output of using the prefix '`' was inverted: The MSB was placed
before the LSB. Now, the LSB are placed first, allowing a direct copy
to VRAM.
2016-07-01 19:54:48 +01:00
Sanqui 280ca83acd Fix opening nonexistent overlay files 2016-03-28 20:47:47 +02:00
Sanqui 2e9c68f8c3 Add overlay file option to rgblink (-O)
This option takes a file and places fixed sections on top of it.
Should prove useful for patches and partial disassemblies.
2016-03-28 01:02:05 +02:00
Anthony J. Bentley 330a39596c Instead of blindly trusting the first byte, decode UTF-8 safely. 2016-01-28 23:16:42 -07:00
Anthony J. Bentley e241137508 KNF. 2016-01-28 23:05:25 -07:00
Anthony J. Bentley 581133ecce Output make-style dependencies with -M. 2015-12-11 01:06:19 -07:00
Sanqui deb44eaeef Merge branch 'master' into HEAD 2015-10-13 22:37:25 +02:00
Sanqui 338c176b37 Add -E option to rgbds, allows exporting all labels by default 2015-10-13 22:35:02 +02:00
yenatch 1a15ee5363 Increase the length of charmaps. 2015-10-13 08:46:29 -07:00
Anthony J. Bentley 2ea2e47231 Avoid a pointless strcpy(). 2015-10-05 23:58:00 -06:00
Anthony J. Bentley 31294d6d9d rgbasm: refactor bank range checking, and bump the SRAM limit.
This doesn’t affect rgblink, which still needs work.
2015-10-05 17:14:24 -06:00
yenatch b2d523acde rgbasm: Evaluate BANK() arguments to verify they exist.
Symbols are created when using a label in the wild, even if they aren't defined. Solely using a symbol as an argument to BANK() skips this, so the symbol is never created.

This evaluates the argument instead of trying to find a symbol. This way, symbols that don't exist are created when passed into BANK().
2014-02-01 21:14:56 -05:00
2265 changed files with 55537 additions and 12628 deletions
+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
+2
View File
@@ -0,0 +1,2 @@
.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!
+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
+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
+451
View File
@@ -0,0 +1,451 @@
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:
strategy:
matrix:
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:
- name: Checkout repo
uses: actions/checkout@v7
- name: Install deps
run: |
.github/scripts/install-deps.sh ${{ matrix.os }} ${{ matrix.cxx }}
- name: Build using Make
if: matrix.buildsys == 'make'
run: |
make develop -k -j "$(getconf _NPROCESSORS_ONLN)" Q= CXX=${{ matrix.cxx }}
- name: Install using Make
if: matrix.buildsys == 'make'
run: |
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@v7
with:
name: rgbds-canary-${{ matrix.os }}-${{ matrix.cxx }}-${{ matrix.buildsys }}
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: ${{ 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
macos-static:
runs-on: macos-26
steps:
- name: Checkout repo
uses: actions/checkout@v7
- name: Install deps
run: |
.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: |
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 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@v7
with:
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:
strategy:
matrix:
bits: [32, 64]
os: [windows-2022, windows-2025]
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
- 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:
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
run: |
cp bins/* .
cp bins/*.dll test/gfx
- 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: 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
+21
View File
@@ -0,0 +1,21 @@
/rgbasm
/rgblink
/rgbfix
/rgbgfx
/install.sh
/rgbshim.sh
/coverage/
*.o
*.exe
*.dll
*.gcno
*.gcda
*.gcov
/compile_flags.txt
CMakeCache.txt
CMakeFiles/
cmake_install.cmake
CMakeUserPresets.json
build*/
*.dSYM/
callgrind.out.*
+231
View File
@@ -0,0 +1,231 @@
# SPDX-License-Identifier: MIT
# - 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)
# 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()
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()
# 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()
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()
# 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()
## Dependencies.
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()
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()
## 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)
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()
add_compile_options(-Wall -pedantic -Wno-unknown-warning-option -fno-exceptions -fno-rtti)
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()
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"
}
}
]
}
+25
View File
@@ -0,0 +1,25 @@
FROM debian:13-slim
LABEL org.opencontainers.image.source=https://github.com/gbdev/rgbds
ARG version=1.0.3
WORKDIR /rgbds
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=
+17 -24
View File
@@ -1,28 +1,21 @@
rgbasm and rgblink are derived from Justin Lloyd's RGBDS, which is The MIT License
released under the following license:
DO WHATEVER PUBLIC LICENSE* Copyright (c) 1996-2025, Carsten Sørensen and RGBDS contributors.
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. You can do whatever you want to with the work. Permission is hereby granted, free of charge, to any person obtaining a copy
1. You cannot stop anybody from doing whatever they want to with the work. of this software and associated documentation files (the "Software"), to
2. You cannot revoke anybody elses DO WHATEVER PUBLIC LICENSE in the work. 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:
This program is free software. It comes without any warranty, to The above copyright notice and this permission notice shall be included in
the extent permitted by applicable law. You can redistribute it all copies or substantial portions of the Software.
and/or modify it under the terms of the DO WHATEVER PUBLIC LICENSE
Software originally created by Justin Lloyd @ http://otakunozoku.com/ 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
rgbfix was rewritten from scratch by Anthony J. Bentley, and is released AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
under the ISC license; see the source file for the text of the license. 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
extern/err.c is derived from the Musl C library, http://www.musl-libc.org, IN THE SOFTWARE.
and is released under the MIT license.
extern/reallocarray.c is derived from the OpenBSD Project,
http://www.openbsd.org, and is released under the ISC license.
extern/strl.c is derived from the OpenBSD Project, http://www.openbsd.org,
and is released under the BSD license.
+247 -74
View File
@@ -1,107 +1,280 @@
.POSIX: # SPDX-License-Identifier: MIT
WARNFLAGS = -Wall -Werror=implicit .SUFFIXES:
REALCFLAGS = ${CFLAGS} ${WARNFLAGS} -Iinclude -g \ .SUFFIXES: .cpp .y .o
-std=c99 -D_POSIX_C_SOURCE=200809L
.PHONY: all clean install develop debug profile coverage format tidy iwyu wine-shim dist
# User-defined variables # User-defined variables
PREFIX = /usr/local
BINPREFIX = ${PREFIX}/bin
MANPREFIX = ${PREFIX}/man
Q = @
rgbasm_obj = \ Q := @
src/asm/asmy.o \ 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`
# 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 -pedantic -Wno-unknown-warning-option \
-Wno-gnu-zero-variadic-macro-arguments -Wno-unused-but-set-variable
# 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 ?=
# Non-overridable LDFLAGS
REQUIREDLDFLAGS := -DBUILD_VERSION_STRING=\"${VERSION_STRING}\"
REALLDFLAGS := ${LDFLAGS} ${WARNFLAGS} ${REQUIREDLDFLAGS}
# Wrapper around bison that passes flags depending on what the version supports
BISON := src/bison.sh
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 := \
${common_obj} \
src/asm/actions.o \
src/asm/charmap.o \ src/asm/charmap.o \
src/asm/fixpoint.o \
src/asm/format.o \
src/asm/fstack.o \ src/asm/fstack.o \
src/asm/globlex.o \ src/asm/intern.o \
src/asm/lexer.o \ src/asm/lexer.o \
src/asm/macro.o \
src/asm/main.o \ src/asm/main.o \
src/asm/math.o \ src/asm/opt.o \
src/asm/output.o \ src/asm/output.o \
src/asm/parser.o \
src/asm/rpn.o \ src/asm/rpn.o \
src/asm/section.o \
src/asm/symbol.o \ src/asm/symbol.o \
src/asm/locallex.o \ src/asm/warning.o \
src/extern/err.o \ src/extern/utf8decoder.o \
src/extern/reallocarray.o \ src/backtrace.o \
src/extern/strlcpy.o \ src/linkdefs.o \
src/extern/strlcat.o src/opmath.o \
src/verbosity.o
rgblink_obj = \ src/asm/lexer.o src/asm/main.o: src/asm/parser.hpp
rgblink_obj := \
${common_obj} \
src/link/assign.o \ src/link/assign.o \
src/link/library.o \ src/link/fstack.o \
src/link/lexer.o \
src/link/layout.o \
src/link/main.o \ src/link/main.o \
src/link/mapfile.o \
src/link/object.o \ src/link/object.o \
src/link/output.o \ src/link/output.o \
src/link/patch.o \ src/link/patch.o \
src/link/script.o \
src/link/sdas_obj.o \
src/link/section.o \
src/link/symbol.o \ src/link/symbol.o \
src/extern/err.o src/link/warning.o \
src/extern/utf8decoder.o \
src/backtrace.o \
src/linkdefs.o \
src/opmath.o \
src/verbosity.o
rgbfix_obj = \ 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/fix/main.o \
src/extern/err.o src/fix/mbc.o \
src/fix/warning.o
all: rgbasm rgblink rgbfix rgbgfx_obj := \
${common_obj} \
clean: src/gfx/color_set.o \
$Qrm -rf rgbds.html src/gfx/main.o \
$Qrm -rf rgbasm rgbasm.exe ${rgbasm_obj} rgbasm.html src/gfx/pal_packing.o \
$Qrm -rf rgblink rgblink.exe ${rgblink_obj} rgblink.html src/gfx/pal_sorting.o \
$Qrm -rf rgbfix rgbfix.exe ${rgbfix_obj} rgbfix.html src/gfx/pal_spec.o \
$Qrm -rf src/asm/asmy.c src/asm/asmy.h src/gfx/palette.o \
src/gfx/png.o \
install: all src/gfx/process.o \
$Qmkdir -p ${BINPREFIX} src/gfx/reverse.o \
$Qinstall -s -m 555 rgbasm ${BINPREFIX}/rgbasm src/gfx/rgba.o \
$Qinstall -s -m 555 rgbfix ${BINPREFIX}/rgbfix src/gfx/warning.o \
$Qinstall -s -m 555 rgblink ${BINPREFIX}/rgblink src/verbosity.o
$Qmkdir -p ${MANPREFIX}/man1 ${MANPREFIX}/man7
$Qinstall -m 444 src/rgbds.7 ${MANPREFIX}/man7/rgbds.7
$Qinstall -m 444 src/asm/rgbasm.1 ${MANPREFIX}/man1/rgbasm.1
$Qinstall -m 444 src/fix/rgbfix.1 ${MANPREFIX}/man1/rgbfix.1
$Qinstall -m 444 src/link/rgblink.1 ${MANPREFIX}/man1/rgblink.1
rgbasm: ${rgbasm_obj} rgbasm: ${rgbasm_obj}
$Q${CC} ${REALCFLAGS} -o $@ ${rgbasm_obj} -lm $Q${CXX} ${REALLDFLAGS} -o $@ ${rgbasm_obj} ${REALCXXFLAGS} src/version.cpp
rgblink: ${rgblink_obj} rgblink: ${rgblink_obj}
$Q${CC} ${REALCFLAGS} -o $@ ${rgblink_obj} $Q${CXX} ${REALLDFLAGS} -o $@ ${rgblink_obj} ${REALCXXFLAGS} src/version.cpp
rgbfix: ${rgbfix_obj} rgbfix: ${rgbfix_obj}
$Q${CC} ${REALCFLAGS} -o $@ ${rgbfix_obj} $Q${CXX} ${REALLDFLAGS} -o $@ ${rgbfix_obj} ${REALCXXFLAGS} src/version.cpp
.y.c: rgbgfx: ${rgbgfx_obj}
$Q${YACC} -d ${YFLAGS} -o $@ $< $Q${CXX} ${REALLDFLAGS} ${PNGLDFLAGS} -o $@ ${rgbgfx_obj} ${REALCXXFLAGS} ${PNGLDLIBS} src/version.cpp
.c.o: test/gfx/randtilegen: test/gfx/randtilegen.cpp
$Q${CC} ${REALCFLAGS} -c -o $@ $< $Q${CXX} ${REALLDFLAGS} ${PNGLDFLAGS} -o $@ $^ ${REALCXXFLAGS} ${PNGCFLAGS} ${PNGLDLIBS}
src/asm/locallex.o src/asm/globlex.o src/asm/lexer.o: src/asm/asmy.h test/gfx/rgbgfx_test: test/gfx/rgbgfx_test.cpp
src/asm/asmy.h: src/asm/asmy.c $Q${CXX} ${REALLDFLAGS} ${PNGLDFLAGS} -o $@ $^ ${REALCXXFLAGS} ${PNGCFLAGS} ${PNGLDLIBS}
# Below is a target for the project maintainer to easily create win32 exes. # Rules to process files
# This is not for Windows users!
# If you're building on Windows with Cygwin or Mingw, just follow the Unix
# install instructions instead.
mingw:
$Qenv PATH=/usr/local/mingw32/bin:/bin:/usr/bin:/usr/local/bin \
make WARNFLAGS= CC=gcc CFLAGS="-I/usr/local/mingw32/include \
${CFLAGS}"
$Qmv rgbasm rgbasm.exe
$Qmv rgblink rgblink.exe
$Qmv rgbfix rgbfix.exe
# Below is a target for the project maintainer to easily create web manuals. # We want the Bison invocation to pass through our rules, not default ones
# It relies on mandoc: http://mdocml.bsd.lv .y.o:
MANDOC = -Thtml -Ios=General -Oman=/rgbds/manual/%N/ \
-Ostyle=/rgbds/manual/manual.css
wwwman: .y.cpp:
$Qmandoc ${MANDOC} src/rgbds.7 | sed s/OpenBSD/General/ > rgbds.html $Q${BISON} $@ $<
$Qmandoc ${MANDOC} src/asm/rgbasm.1 | sed s/OpenBSD/General/ > \
rgbasm.html # Bison-generated C++ files have an accompanying header
$Qmandoc ${MANDOC} src/fix/rgbfix.1 | sed s/OpenBSD/General/ > \ src/asm/parser.hpp: src/asm/parser.cpp
rgbfix.html $Qtouch $@
$Qmandoc ${MANDOC} src/link/rgblink.1 | sed s/OpenBSD/General/ > \ src/link/script.hpp: src/link/script.cpp
rgblink.html $Qtouch $@
# 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 $@ $<
.cpp.o:
$Q${CXX} ${REALCXXFLAGS} -c -o $@ $<
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 {} \;
$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
$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:
$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"
# Target used in development to debug with gdb.
debug:
$Qenv ${MAKE} \
CXXFLAGS="-ggdb3 -O0 -fno-omit-frame-pointer -fno-optimize-sibling-calls"
# 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"
# 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 '#!/usr/bin/env bash' > rgbshim.sh
$Qecho 'WINEDEBUG=-all wine $$0.exe "$${@:1}"' >> rgbshim.sh
$Qchmod +x rgbshim.sh
$Qln -s rgbshim.sh rgbasm
$Qln -s rgbshim.sh rgblink
$Qln -s rgbshim.sh rgbfix
$Qln -s rgbshim.sh rgbgfx
# Target for the project maintainer to produce distributable release tarballs
# of the source code.
dist:
$Qgit ls-files | sed s~^~$${PWD##*/}/~ \
| tar -czf rgbds-source.tar.gz -C .. -T -
-58
View File
@@ -1,58 +0,0 @@
----------------
RGBDS README
----------------
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)
rgbds-linux is a fork of the original RGBDS which aims to make the programs
more like other UNIX tools.
Installing RGBDS (UNIX)
=========================
To build the programs on a UNIX or UNIX-like system, just run in your terminal:
make
Then to install the compiled programs and manual pages, run (with appropriate
privileges):
make install
After installation, you can read the manuals with the man(1) command. E.g.,
man 1 rgbasm
Note: 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:
mkdir -p $HOME/{bin,man/man1,man/man7}
make install PREFIX=$HOME
PREFIX: Location where RGBDS will be installed. Defaults to /usr/local.
BINPREFIX: Location where the RGBDS programs will be installed. Defaults
to ${PREFIX}/bin.
MANPREFIX: Location where the RGBDS man pages will be installed. Defaults
to ${PREFIX}/man.
Q: Whether to quiet the build or not. To make the build more verbose, clear
this variable. Defaults to @.
Installing RGBDS (Windows)
============================
Windows builds are available here: https://github.com/bentley/rgbds/releases
Copy the .exe files to C:\Windows\ or similar.
+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.
+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
+54
View File
@@ -0,0 +1,54 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: MIT
STATE=0
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
# Separator between files switches states
echo "$LINE"
STATE=3
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 || $STATE -eq 3 ]]; then
# Compute the GB address from the ROM offset
OFS=$(cut -d ' ' -f 2 <<< "$LINE" | tr -d ':')
BANK=$((0x$OFS / 0x4000))
ADDR=$((0x$OFS % 0x4000 + (BANK != 0) * 0x4000))
# Try finding the preceding symbol closest to the diff
if [[ $STATE -eq 1 ]]; then
STATE=2
SYMFILE=${1%.*}.sym
else
STATE=4
SYMFILE=${2%.*}.sym
fi
EXTRA=$(if [[ -f "$SYMFILE" ]]; then
# Read the sym file for such a symbol
# Ignore comment lines, only pick matching 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=$(($SYMADDR))
if [[ $SYMADDR -le $ADDR ]]; then
printf " (%s+0x%x)\n" "$SYM" $((ADDR - SYMADDR))
fi
done | tail -n 1
fi)
printf "%02x:%04x %s\n" $BANK $ADDR "$EXTRA"
fi
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" "${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
-129
View File
@@ -1,129 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>xAsm</title>
<link rel="stylesheet" type="text/css" href="./style.css">
</head>
<body>
<h1>xAsm Documentation</h1>
<h2>Table of Contents</h2>
<h3>General stuff</h3>
<ul>
<li><a href="asm/history.htm">History</a>
<li><a href="asm/usage.htm">Usage</a>
<li><a href="asm/opt.htm">Changing options while assembling</a>
<li><a href="asm/popo.htm">The option stack</a>
<li><a href="asm/syntax.htm">Syntax and comments</a>
<li><a href="asm/section.htm">Sections</a>
</ul>
<h3>Symbols</h3>
<ul>
<li><a href="asm/symbols.htm">Symbols</a>
<li><a href="asm/export.htm">Exporting and importing symbols</a>
<li><a href="asm/purge.htm">Purging symbols</a>
<li><a href="asm/presym.htm">Predeclared symbols</a>
</ul>
<h3>The macrolanguage</h3>
<ul>
<li><a href="asm/print.htm">Printing out things during assembling</a>
<li><a href="asm/rept.htm">Automatically repeating blocks of code</a>
<li><a href="asm/fail.htm">Aborting the assembly process</a>
<li><a href="asm/include.htm">Including other sourcefiles</a>
<li><a href="asm/if.htm">Conditional assembling</a>
<li><a href="asm/expr_int.htm">Integer and Boolean expressions</a>
<li><a href="asm/expr_fix.htm">Fixed-point expressions and functions</a>
<li><a href="asm/expr_str.htm">String expressions, functions and formatting</a>
<li><a href="asm/miscfunc.htm">Other functions</a>
</ul>
<h3>Other ways than mnemonics to define data</h3>
<ul>
<li><a href="asm/db.htm">Defining constant data</a>
<li><a href="asm/ds.htm">Declaring variables in a RAM section</a>
<li><a href="asm/incbin.htm">Including binary files</a>
</ul>
<h3>Target specific information</h3>
<ul>
<li><a href="asm/trg_gb.htm">The Gameboy</a>
</ul>
<h3>Alphabetical list of the macro-language instructions and functions</h3>
<ul>
<li><a href="asm/presym.htm">@</a>
<li><a href="asm/presym.htm">__DATE__</a>
<li><a href="asm/presym.htm">__LINE__</a>
<li><a href="asm/presym.htm">__TIME__</a>
<li><a href="asm/presym.htm">_NARG</a>
<li><a href="asm/presym.htm">_PI</a>
<li><a href="asm/presym.htm">_RS</a>
<li><a href="asm/expr_fix.htm">ACOS</a>
<li><a href="asm/expr_fix.htm">ASIN</a>
<li><a href="asm/expr_fix.htm">ATAN</a>
<li><a href="asm/expr_fix.htm">ATAN2</a>
<li><a href="asm/miscfunc.htm">BANK</a>
<li><a href="asm/expr_fix.htm">COS</a>
<li><a href="asm/db.htm">DB</a>
<li><a href="asm/miscfunc.htm">DEF</a>
<li><a href="asm/expr_fix.htm">DIV</a>
<li><a href="asm/ds.htm">DS</a>
<li><a href="asm/db.htm">DW</a>
<li><a href="asm/if.htm">ELSE</a>
<li><a href="asm/if.htm">ENDC</a>
<li><a href="asm/macro.htm">ENDM</a>
<li><a href="asm/rept.htm">ENDR</a>
<li><a href="asm/equ.htm">EQU</a>
<li><a href="asm/equs.htm">EQUS</a>
<li><a href="asm/export.htm">EXPORT</a>
<li><a href="asm/fail.htm">FAIL</a>
<li><a href="asm/export.htm">GLOBAL</a>
<li><a href="asm/section.htm">HRAM</a>
<li><a href="asm/if.htm">IF</a>
<li><a href="asm/export.htm">IMPORT</a>
<li><a href="asm/incbin.htm">INCBIN</a>
<li><a href="asm/include.htm">INCLUDE</a>
<li><a href="asm/macro.htm">MACRO</a>
<li><a href="asm/expr_fix.htm">MUL</a>
<li><a href="asm/opt.htm">OPT</a>
<li><a href="asm/popo.htm">POPO</a>
<li><a href="asm/pops.htm">POPS</a>
<li><a href="asm/print.htm">PRINTF</a>
<li><a href="asm/print.htm">PRINTT</a>
<li><a href="asm/print.htm">PRINTV</a>
<li><a href="asm/purge.htm">PURGE</a>
<li><a href="asm/popo.htm">PUSHO</a>
<li><a href="asm/pops.htm">PUSHS</a>
<li><a href="asm/rept.htm">REPT</a>
<li><a href="asm/rs.htm">RB</a>
<li><a href="asm/section.htm">ROM0</a>
<li><a href="asm/section.htm">ROMX</a>
<li><a href="asm/rs.htm">RSRESET</a>
<li><a href="asm/rs.htm">RSSET</a>
<li><a href="asm/rs.htm">RW</a>
<li><a href="asm/section.htm">SECTION</a>
<li><a href="asm/set.htm">SET</a>
<li><a href="asm/shift.htm">SHIFT</a>
<li><a href="asm/expr_fix.htm">SIN</a>
<li><a href="asm/section.htm">SRAM</a>
<li><a href="asm/expr_str.htm">STRCAT</a>
<li><a href="asm/expr_str.htm">STRCMP</a>
<li><a href="asm/expr_str.htm">STRIN</a>
<li><a href="asm/expr_str.htm">STRLEN</a>
<li><a href="asm/expr_str.htm">STRLWR</a>
<li><a href="asm/expr_str.htm">STRSUB</a>
<li><a href="asm/expr_str.htm">STRUPR</a>
<li><a href="asm/expr_fix.htm">TAN</a>
<li><a href="asm/section.htm">VRAM</a>
<li><a href="asm/section.htm">WRAM0</a>
<li><a href="asm/section.htm">WRAMX</a>
<li><a href="asm/fail.htm">WARN</a>
<li><a href="asm/export.htm">XDEF</a>
<li><a href="asm/export.htm">XREF</a>
</ul>
<p>Last updated 20 July 1997 by <a href="mailto:[email protected]">Carsten Sorensen</a></p>
</body>
</html>
-26
View File
@@ -1,26 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>xAsm DB, DW</title>
<link rel="stylesheet" type="text/css" href="../style.css">
</head>
<body>
<h1>DB, DW</h1>
<p><dfn>DB</dfn> defines a list of bytes that will be stored in the final image. Ideal for tables and text.</p>
<pre>DB 1,2,3,4,"This is a string"</pre>
<p>Alternatively you can use <dfn>DW</dfn> to store a list of words. Strings are not allowed as arguments to DW.</p>
<p>You can also use DB and DW without arguments. This works exactly like “DS 1” and “DS 2” respectively. Consequently DB and DW can be used in a WRAM0/WRAMX/HRAM/VRAM/SRAM section.</p>
<h1>See also:</h1>
<ul>
<li><a href="expr_int.htm">Integer and Boolean expressions</a>
<li><a href="expr_fix.htm">Fixed-point expressions and functions</a>
<li><a href="expr_str.htm">String expressions, functions and formatting</a>
<li><a href="ds.htm">Declaring variables in a RAM section</a>
<li><a href="miscfunc.htm">Other functions</a>
</ul>
<hr>
<p>Last updated 02 July 1997 by <a href="mailto:[email protected]">Carsten Sorensen</a></p>
</body>
</html>
-20
View File
@@ -1,20 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>xAsm DS</title>
<link rel="stylesheet" type="text/css" href="../style.css">
</head>
<body>
<h1>DS</h1>
<p><dfn>DS</dfn> allocates a number of bytes. The content is undefined. This is the preferred method of allocationg space in a <a href="section.htm">RAM section</a>. You can however also use DB and DW without any arguments.</p>
<pre>DS str_SIZEOF ;allocate str_SIZEOF bytes</pre>
<h1>See also:</h1>
<ul>
<li><a href="db.htm">Defining constant data (DB/DW)</a>
<li><a href="expr_int.htm">Integer and Boolean expressions</a>
</ul>
<hr>
<p>Last updated 02 July 1997 by <a href="mailto:[email protected]">Carsten Sorensen</a></p>
</body>
</html>
-21
View File
@@ -1,21 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>xAsm EQU</title>
<link rel="stylesheet" type="text/css" href="../style.css">
</head>
<body>
<h1>EQU</h1>
<p>EQUates are constant symbols. They can for example be used for things such as bit-definitions of hardware-registers.</p>
<pre>DONUT_ISGOOD EQU $01
DONUT_ISBAD EQU $02</pre>
<p>Note that a colon (:) following the label-name is not allowed. EQUates can be <a href="export.htm">exported and imported</a>. They don't change their value during the link process.</p>
<h1>See also:</h1>
<ul>
<li><a href="expr_int.htm">Integer and Boolean expressions</a>
</ul>
<hr>
<p>Last updated 21 June 1997 by <a href="mailto:[email protected]">Carsten Sorensen</a></p>
</body>
</html>
-27
View File
@@ -1,27 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>xAsm EQUS</title>
<link rel="stylesheet" type="text/css" href="../style.css">
</head>
<body>
<h1>EQUS</h1>
<p>EQUS is used to define string-symbols. Wherever the assembler meets a string symbol its name is replaced with its value. If you are familiar with C you can think of it as the same as #define.</p>
<pre>COUNTREG EQUS "[hl+]"
ld a,COUNTREG</pre>
<p>(Note that : following the label-name is not allowed.)</p>
<p>This will be interpreted as:</p>
<pre> ld a,[hl+]</pre>
<p>String-symbols can also be used to define small one-line macros:</p>
<pre>PUSHA EQUS "push af\npush bc\npush de\npush hl\n"</pre>
<p>Note that a colon (:) following the label-name is not allowed. String equates can't be exported or imported.</p>
<h1>See also:</h1>
<ul>
<li><a href="expr_str.htm">String expressions, functions and formatting</a>
</ul>
<hr>
<p>Last updated 21 June 1997 by <a href="mailto:[email protected]">Carsten Sorensen</a></p>
</body>
</html>
-35
View File
@@ -1,35 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>xAsm EXPORT/XREF, IMPORT/XDEF, GLOBAL</title>
<link rel="stylesheet" type="text/css" href="../style.css">
</head>
<body>
<h1>EXPORT/XREF, IMPORT/XDEF, GLOBAL</h1>
<p>Importing and exporting of symbols is a feature that is very useful when your project spans many source-files and for example you need to jump to a routine defined in another file.</p>
<table>
<caption>Import/export commands</caption>
<thead>
<tr>
<th scope="col">Command</th>
<th scope="col">Meaning</th>
</tr>
</thead>
<tr>
<td>IMPORT (or XREF) <i>label</i>[,<i>label</i>,...]</td>
<td>This instructs the assembler to define label as if it were present
in the current file but leave the address calculation to the linker.</td>
</tr>
<tr>
<td>EXPORT (or XDEF) <i>label</i>[,<i>label</i>,...]</td>
<td>The assembler will make <i>label</i> accessible to other files during the link process.</td>
</tr>
<tr>
<td>GLOBAL <i>label</i>[,<i>label</i>,...]</td>
<td>If <i>label</i> is defined during the assembly it will be exported, if not it will be imported. Handy (very!) for include-files.</td>
</tr>
</table>
<hr>
<p>Last updated 21 June 1997 by <a href="mailto:[email protected]">Carsten Sorensen</a></p>
</body></html>
-76
View File
@@ -1,76 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>xAsm Fixed-point expression</title>
<link rel="stylesheet" type="text/css" href="../style.css">
</head>
<body>
<h1>Fixedpoint Expressions</h1>
<p>Fixed point constants are basically normal 32-bit constants where the upper 16 bits are used for the integer part and the lower 16 bits are used for the fraction (65536ths). This means that you can use them in normal integer expression and indeed some integer operators like plus and minus don't care whether the operands are integer or fixed-point. You can easily convert a fixed-point number to an integer by shifting it right 16 bits. It follows that you can convert an integer to a fixed-point number by shifting it left.</p>
<p>Some things are different for fixed-point math though. Which is why you have the following functions to use:</p>
<table>
<thead>
<tr>
<th scope="col">Name</th>
<th scope="col">Operation</th>
</tr>
</thead>
<tr>
<td>DIV(x,y)</td>
<td>x/y</td>
</tr>
<tr>
<td>MUL(x,y)</td>
<td>x*y</td>
</tr>
<tr>
<td>SIN(x)</td>
<td>sin(x)</td>
</tr>
<tr>
<td>COS(x)</td>
<td>cos(x)</td>
</tr>
<tr>
<td>TAN(x)</td>
<td>tan(x)</td>
</tr>
<tr>
<td>ASIN(x)</td>
<td>sin<SUP>-1</SUP>(x)</td>
</tr>
<tr>
<td>ACOS(x)</td>
<td>cos<SUP>-1</SUP>(x)</td>
</tr>
<tr>
<td>ATAN(x)</td>
<td>tan<SUP>-1</SUP>(x)</td>
</tr>
<tr>
<td>ATAN2(x,y)</td>
<td>(x,y) angle</td>
</tr>
</table>
<p>These functions are extremely useful for automatic generation of various tables. A circle has 65536.0 degrees. Sine values are between [-1.0;1.0]</p>
<pre>; --
; -- Generate a 256 byte sine table with values between 0 and 128
; --
ANGLE SET 0.0
REPT 256
DB (MUL(64.0,SIN(ANGLE))+64.0)>>16
ANGLE SET ANGLE+256.0
ENDR</pre>
<h1>See also:</h1>
<ul>
<li><a href="symbols.htm">Symbols</a>
<li><a href="expr_int.htm">Integer and Boolean expressions</a>
<li><a href="expr_str.htm">String expressions, functions and formatting</a>
<li><a href="miscfunc.htm">Other functions</a>
</ul>
<hr>
<p>Last updated 21 June 1997 by <a href="mailto:[email protected]">Carsten Sorensen</a></p>
</body>
</html>
-92
View File
@@ -1,92 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>xAsm Integer/Boolean expressions</title>
<link rel="stylesheet" type="text/css" href="../style.css">
</head>
<body>
<h1>Integer and Boolean expressions</h1>
<p>An expression can be composed of many things. Expressions are always evaluated using signed 32-bit math.</p>
<p>The most basic expression is just a single number.</p>
<h2>Numeric Formats</h2>
<p>xAsm has a number of numeric formats.</p>
<ul>
<li>Hexadecimal: $0123456789ABCDEF. Case-insensitive
<li>Decimal: 0123456789
<li>Octal: &01234567
<li>Binary: %01
<li>Fixedpoint (16.16): 01234.56789
<li>Character constant: "ABYZ"
<li>Gameboy graphics: `0123
</ul>
<p>The last one, Gameboy graphics, is quite interesting and useful. The values are actually pixel values and it converts the “chunky” data to “planar” data as used in the Gameboy.</p>
<pre>DW `01012323</pre>
<p>Admittedly an expression with just a single number is quite boring. To spice things up a bit theres a few operators you can use to perform calculations between numbers.</p>
<h2>Operators</h2>
<p>A great number of operators you can use in expressions are available (listed in order of precedence):</p>
<table>
<caption>Operators</caption>
<thead>
<tr>
<th scope="col">Operator</th>
<th scope="col">Meaning</th>
</tr>
</thead>
<tr>
<td>( )</td>
<td>Precedence override</td>
</tr>
<tr>
<td>FUNC()</td>
<td>Functioncall</td>
</tr>
<tr>
<td>~ + -</td>
<td>Unary not/plus/minus</td>
</tr>
<tr>
<td>* / %</td>
<td>Multiply/divide/modulo</td>
</tr>
<tr>
<td>&lt;&lt; &gt;&gt;</td>
<td>Shift left/right</td>
</tr>
<tr>
<td>&amp; | ^</td>
<td>Binary and/or/xor</td>
</tr>
<tr>
<td>+ -</td>
<td>Add/subtract</td>
</tr>
<tr>
<td>!= == &lt;= &gt;= &lt; &gt;</td>
<td>Boolean comparison</td>
</tr>
<tr>
<td>&amp;&amp; ||</td>
<td>Boolean and/or</td>
</tr>
<tr>
<td>!</td>
<td>Unary Boolean not</td>
</tr>
</table>
<p>The result of the boolean operators is zero if when FALSE and non-zero when TRUE. Thus it is legal to use an integer as the condition for <a href="if.htm">IF</a> blocks. You can use symbols instead of numbers in your expression if you wish.</p>
<p>An expression is said to be constant when it doesn't change its value during linking. This basically means that you can't use labels in those expressions. The instructions in the macro-language all require expressions that are constant.</p>
<h1>See also:</h1>
<ul>
<li><a href="symbols.htm">Symbols</a>
<li><a href="expr_fix.htm">Fixed-point expressions and functions</a>
<li><a href="expr_str.htm">String expressions, functions and formatting</a>
<li><a href="miscfunc.htm">Other functions</a>
</ul>
<hr>
<p>Last updated 21 June 1997 by <a href="mailto:[email protected]">Carsten Sorensen</a></p>
</body>
</html>
-114
View File
@@ -1,114 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>xAsm String expressions</title>
<link rel="stylesheet" type="text/css" href="../style.css">
</head>
<body>
<h1>String Expressions</h1>
<p>The most basic string expression is any number of characters contained in double quotes ("for instance"). As in C the escape character is <b>\</b> and there is a number of commands you can use within a string:</p>
<table>
<caption>Escape characters:</caption>
<thead>
<tr>
<th scope="col">Character sequence</th>
<th scope="col">Meaning</th>
<th scope="col">Notes</th>
</tr>
</thead>
<tr>
<td>\\</td>
<td>Backslash</td>
<td></td>
</tr>
<tr>
<td>\"</td>
<td>Double-quote</td>
<td></td>
</tr>
<tr>
<td>\{</td>
<td>Curly bracket left</td>
<td></td>
</tr>
<tr>
<td>\}</td>
<td>Curly bracket right</td>
<td></td>
</tr>
<tr>
<td>\n</td>
<td>Newline ($0A)</td>
<td></td>
</tr>
<tr>
<td>\t</td>
<td>Tab ($09)</td>
<td></td>
</tr>
<tr>
<td>\1-\9</td>
<td>Macroargument</td>
<td>Only in macros</td>
</tr>
<tr>
<td>\@</td>
<td>Labelname suffix</td>
<td>Only in macros and repts</td>
</tr>
</table>
<p>A funky feature is <b>{symbol}</b> withing a string. This will examine the type of the symbol and insert its value accordingly. If symbol is a string symbol the symbols value is simply copied. If it's a numeric symbol the value is converted to hexadecimal notation and inserted as a string.</p>
<p><strong>HINT:</strong> The <b>{symbol}</b> construct can also be used outside strings. The symbols value is again inserted as a string. This is just a short way of doing &quot;{symbol}&quot;.</p>
<p>Whenever the macro-language expects a string you can actually use a string expression. This consists of one or more of these function. Yes, you can nest them. Note that some of these functions actually return an integer and can be used as part of an integer expression!</p>
<table>
<caption>String functions:</caption>
<thead>
<tr>
<th scope="col">Name</th>
<th scope="col">Operation</th>
</tr>
</thead>
<tr>
<td>STRLEN(<i>stringexpr</i>)</td>
<td>Returns the number of characters in <i>string</i></td>
</tr>
<tr>
<td>STRCAT(<i>stringexpr1,stringexpr2</i>)</td>
<td>Appends <i>stringexpr2</i> to <i>stringexpr1</i>.</td>
</tr>
<tr>
<td>STRCMP(<i>stringexpr1,stringexpr2</i>)</td>
<td>Returns negative if <i>stringexpr1</i> is alphabetically less than <i>stringexpr2</i><BR>Zero if they match<BR>Positive if greater than</td>
</tr>
<tr>
<td>STRIN(<i>haystack,needle</i>)</td>
<td>Returns <i>needle</i>s position within <i>haystack</i> or zero if it's not present</td>
</tr>
<tr>
<td>STRSUB(<i>stringexpr,pos,count</i>)</td>
<td>Returns a substring of <i>stringexpr</i> starting at <i>pos</i> (first character is position 1) and with <i>count</i> characters</td>
</tr>
<tr>
<td>STRUPR(<i>stringexpr</i>)</td>
<td>Converts all characters in <i>string</i> to capitals and returns the new string</td>
</tr>
<tr>
<td>STRLWR(<i>string</i>)</td>
<td>Converts all characters in <i>string</i> to lower case and returns the new string</td>
</tr>
</table>
<h1>See also:</h1>
<ul>
<li><a href="symbols.htm">Symbols</a>
<li><a href="expr_int.htm">Integer and Boolean expressions</a>
<li><a href="expr_fix.htm">Fixed-point expressions and functions</a>
<li><a href="miscfunc.htm">Other functions</a>
</ul>
<hr>
<p>Last updated 21 June 1997 by <a href="mailto:[email protected]">Carsten Sorensen</a></p>
</body>
</html>
-20
View File
@@ -1,20 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>xAsm FAIL, WARN</title>
<link rel="stylesheet" type="text/css" href="../style.css">
</head>
<body>
<h1>FAIL, WARN</h1>
<p>FAIL and WARN can be used to terminate the assembling process if you wish to do so. This is especially useful for macros that get an invalid argument. FAIL and WARN take a string as the only argument and they will print this string out as a normal error with a linenumber.</p>
<p>FAIL stops assembling immediately while WARN continues after printing the errormessage.</p>
<h1>See also:</h1>
<ul>
<li><a href="expr_str.htm">String expressions, functions and formatting</a>
</ul>
<hr>
<p>Last updated 21 June 1997 by <a href="mailto:[email protected]">Carsten Sorensen</a></p>
</body>
</html>
-224
View File
@@ -1,224 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>xAsm History</title>
<link rel="stylesheet" type="text/css" href="../style.css">
</head>
<body>
<h1>xAsm History</h1>
<table>
<caption>The history of xAsm</caption>
<thead>
<tr>
<th scope="col">Version</th>
<th scope="col">Dated</th>
<th scope="col">Release notes</th>
</tr>
</thead>
<tr>
<td>1.0</td>
<td>1 Oct. 96</td>
<td>First release</td>
</tr>
<tr>
<td>1.01</td>
<td>1 Dec. 96</td>
<td><ul>
<li>Fixed bug in <a href="incbin.htm">INCBIN</a> (sometimes reported the section full)</li>
<li>Added <a href="miscfunc.htm">DEF()</a> function
</ul></td>
</tr>
<tr>
<td>1.02</td>
<td>12 Feb. 97</td>
<td><ul>
<li>Added <a href="expr_str.htm">STRLEN(), STRCAT(), STRIN(), STRCMP(), STRSUB(), STRUPR() and STRLWR()</a> functions</li>
<li><a href="export.htm">IMPORT/EXPORT/GLOBAL</a> takes multiple arguments now</li>
<li><a href="section.htm">HRAM</a> sectiontype added</li>
<li>ORG like features added to <a href="section.htm">SECTION</a></li>
<li><a href="trg_gb.htm">LDIO</a> mnemonic added</li>
</ul></td>
</tr>
<tr>
<td>1.03</td>
<td>23 Mar. 97</td>
<td><ul>
<li>The <a href="section.htm">HRAM section</a> was 128 bytes long instead of 127. potentially thrashing the interrupt enable register if you filled the HRAM.</li>
<li>The <a href="miscfunc.htm">BANK() function</a>, when used on a symbol defined in the current sourcefile, returned the wrong bank ID. (reported by Harry P. Mulder)</li>
<li>The <a href="miscfunc.htm">BANK() function</a> didn't check whether the argument was a properly defined symbol. (reported by Harry P. Mulder)</li>
<li>Completely new lexical analyser module. This fixed several linenumber bugs and other macro/if/rept related bugs. Also fixed a bug which made it possible to have equated symbols with the same name as a reserved keyword (if you get a "parse error" with this release on some of your sources, this is probably what is going on)</li>
<li><a href="fail.htm">FAIL and WARN</a> commands.</li>
<li><a href="presym.htm">__LINE__, __FILE__, __TIME__, __DATE__</a> predefined symbols added.</li>
</ul>
</td>
</tr>
<tr>
<td>1.04</td>
<td>03 July 1997</td>
<td><ul><li>First ASMotor release</li>
<li><a href="presym.htm">__TIME__ and __DATE__</a> give todays date instead of when the assembler was compiled.</li>
<li>Sometimes the first line of a file wouldn't assemble correctly. Reported by Jeff Frohwein.</li>
<li>Unrolling multiline <a href="equs.htm">string symbols</a> left the linecounter in a sorry state. Jeff Frohwein again.</li>
<li><a href="db.htm">DB and DW</a> can now (officially ;-) be used in BSS/HRAM/VRAM sections without any arguments to reserve a byte or a word respectively. Reported/suggested/inspired by Mr. Frohwein.</li>
<li>The character # can now be used as part of a <a href="symbols.htm">symbol name</A>. Jeff....</li>
<li>The <a href="rs.htm">RS</a> counter "_RS" is now defined from the very start of the assembly process instead of after the first RSSET or RSRESET.</li>
<li>Bug fixed: You couldn't use \0-\9 and \@ in <a href="expr_str.htm">{} constructs</a></li>
<li><a href="purge.htm">PURGE</a> pseudo-op added. Purges a symbol from the symboltable and memory. Use with extreme caution! Inspired by Harry P. Mulder</li>
<li><a href="macro.htm">MACRO</a> parameter passing method changed drastically. Read (and re-read) the manual for details. Suggested by Harry P. Mulder.</li>
</ul>
</td>
<tr>
<td>1.05</td>
<td>20 July 1997</td>
<td><B>RGBDS fixes:</B><BR>
RGBAsm supports the LDD and LDI syntax plus [HLD] and [HLI]. LDH is
synonymous with LDIO.<BR>
<B>General fixes:</B><BR>
There was a bug in the macro parameter passing. Any whitespace after the
last parameter would be appended to the last parameter. Reported by Jeff Frohwein.<BR>
A section stack has been implemented. Look up <a href="pops.htm">POPS and PUSHS</A>. Jeff Frohweins doing again.<BR>
<a href="opt.htm">OPT</A> command added for defining and changing some options while assembling.<BR>
You can now define which characters are used for the <a href="expr_int.htm">Gameboy graphics
integer (`)</A> using the <a href="usage.htm">commandline</A> or the new <a href="opt.htm">OPT</A> command. Cool idea by (surprise surprise) Jeff Frohwein.<BR>
Also, an option stack has been added. Look up <a href="popo.htm">POPO and PUSHO</A> in the
manual.<BR>
Fixed yet another line number bug reported by Jeff Frohwein (when will this guy leave me alone? ;)<BR>
</td>
<tr>
<td>1.06</td>
<td>22 July 1997</td>
<td><B>General fixes:</B><BR>
The lamest typo bug of all time has been fixed. RGBAsm would output a word defined with DW as 4 bytes instead of 2. Jeff Frohwein reported this.<BR>
The first line of an included file didn't assemble correctly.<BR>
<a href="usage.htm">-b option</A> added for setting the characters used for binary constants.<BR>
</td>
</tr>
<tr>
<td>1.08</td>
<td>21 September 1997</td>
<td><B>General fixes:</B><BR>
A crash occured if you tried to use a macro symbol in an expression.
(Jeff Frohwein)<BR>
You couldn't use STRCMP, STRLEN and STRIN in relocatable expressions. (Harry
P. Mulder)<BR>
Relocatable symbols are no longer allowed as arguments to the DEF function.<BR>
Bug fixed in the assembler where it would sometimes write out too many bytes
for HRAM section definitions.<BR>
</td>
</tr>
<tr>
<td>1.08</td>
<td>02 July 1999</td>
<td>
<B>Feature:</B>
<BR>
DQ directive added for defining 32-bit data constants. See operation of DW &amp; DB.
<BR>
</td>
</tr>
<tr>
<td>1.08</td>
<td>05 July 1999</td>
<td>
<B>Feature:</B>
<BR>
Allow only a part of a binary file to be included instead of the whole thing.
<BR>
</td>
</tr>
<tr>
<td>1.08</td>
<td>10 June 1999</td>
<td>
<B>Feature:</B>
<BR>
Added output of file dependency information for each file included/assembled. Enabled with a command line option.
<BR>
</td>
</tr>
<tr>
<td>1.08</td>
<td>?? ???? 1999</td>
<td>
<B>Feature:</B>
<BR>
Added ORG directive to allow anonymous sections.
<BR>
</td>
</tr>
<tr>
<td>1.08</td>
<td>?? ???? 1999</td>
<td>
<B>Feature:</B>
<BR>
Added ability to output error information in either RGBDS or Microsoft Developer Studio format.
<BR>
</td>
</tr>
<tr>
<td>1.08</td>
<td>?? ???? 1999</td>
<td>
<B>Feature:</B>
<BR>
Added pseudo-instructions to handle NE (not equal), EQ (equal), and LT (less than) on JR/JP/CALL instructions
<BR>
</td>
</tr>
<tr>
<td>1.08</td>
<td>?? ???? 1999</td>
<td>
<B>Feature:</B>
<BR>
Added STRTRIM, STRLTRIM, STRRTRIM directives to allow trimming of white space from strings in macro arguments.
<BR>
</td>
</tr>
<tr>
<td>1.08</td>
<td>?? ???? 1999</td>
<td>
<B>Bug Fix:</B>
<BR>
When an "unknown symbol" error was reported during the link phase the undefined symbol was not given.
<BR>
</td>
</tr>
<tr>
<td>1.08</td>
<td>?? ???? 1999</td>
<td>
<B>Bug Fix:</B>
<BR>
Declaring a symbol as GLOBAL in a header file and then referencing it in code but never defining it would crash the linker.
<BR>
</td>
</tr>
<tr>
<td>1.09</td>
<td>08 February 2000</td>
<td>
<B>Feature:</B>
<BR>
Can now use a command line option to set the number format between a slightly tweaked Motorola/RGBDS format and Zilog.
<BR>
Hex numbers can now be represented as $FF or FFh.
<BR>
Octal as &amp;77 or 77o.
<BR>
Binary as %10010110 or 10010110b.
<BR>
Gameboy graphics numbers as `1001 or 1001g.
<BR>
Decimal numbers remain unchanged.
<BR>
</td>
</tr>
</TABLE>
<BR><HR>
<FONT SIZE="-1"><I><P ALIGN=RIGHT>Last updated 21 September 1997 by <a href="mailto:[email protected]">Carsten Sorensen</A></P></I></FONT>
-24
View File
@@ -1,24 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>xAsm IF, ELSE, ENDC</title>
<link rel="stylesheet" type="text/css" href="../style.css">
</head>
<body>
<h1>IF, ELSE, ENDC</h1>
<p>These three commands is used to conditionally assemble parts of your file. It is a powerful feature commonly used in macros.</p>
<pre>IF 2+2==4
PRINTT "2+2==4\n"
ELSE
PRINTT "2+2!=4\n"
ENDC</pre>
<p>The ELSE block is optional. IF/ELSE/ENDC-blocks can be nested.</p>
<h1>See also:</h1>
<ul>
<li><a href="expr_int.htm">Integer and Boolean expressions</a>
</ul>
<hr>
<p>Last updated 21 June 1997 by <a href="mailto:[email protected]">Carsten Sorensen</a></p>
</body>
</html>
-22
View File
@@ -1,22 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>xAsm INCBIN</title>
<link rel="stylesheet" type="text/css" href="../style.css">
</head>
<body>
<h1>INCBIN</h1>
<p>You probably have some graphics youd like to include. Use <dfn>INCBIN</dfn> to include a raw binary file as it is. If the file isnt found in the current directory the <a href="usage.htm">include-path</a> list will be searched.</p>
<pre>INCBIN "titlepic.bin"
INCBIN "sprites\\hero.bin"</pre>
<p>You can also include only part of a file with <b>INCBIN</b>. The example below includes 256 bytes from <i>data.bin</i> starting from position 78.</p>
<pre>INCBIN "data.bin",78,256</pre>
<h1>See also:</h1>
<ul>
<li><a href="expr_str.htm">String expressions, functions and formatting</a>
</ul>
<hr>
<p>Last updated 21 June 1997 by <a href="mailto:[email protected]">Carsten Sorensen</a></p>
</body>
</html>
-19
View File
@@ -1,19 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>xAsm INCLUDE</title>
<link rel="stylesheet" type="text/css" href="../style.css">
</head>
<body>
<h1>INCLUDE</h1>
<p>Use INCLUDE to process another assembler-file and then return to the current file when done. If the file isn't found in the current directory the <a href="usage.htm">include-path</a> list will be searched. You may nest <b>INCLUDE</b> calls infinitely (or until you run out of memory whichever comes first).</p>
<pre>INCLUDE "irq.inc"</pre>
<h1>See also:</h1>
<ul>
<li><a href="expr_str.htm">String expressions, functions and formatting</a>
</ul>
<hr>
<p>Last updated 21 June 1997 by <a href="mailto:[email protected]">Carsten Sorensen</a></p>
</body>
</html>
-22
View File
@@ -1,22 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>xAsm Labels</title>
<link rel="stylesheet" type="text/css" href="../style.css">
</head>
<body>
<h1>Labels</h1>
<p>One of the assemblers main tasks is to keep track of addresses for you so you dort have to remember obscure numbers but can make do with a meaningful name, a label.</p>
<p>This can be done in a number of ways:</p>
<pre>GlobalLabel
AnotherGlobal:
.locallabel
.yet_a_local:
ThisWillBeExported:: ;note the two colons</pre>
<p>This is very similar to other assemblers. Local labels are only accessible within the scope they are defined. A scope starts after a global label and ends at the next global label. You may or may not have seen the <b>::</b> feature before. It declares a normal global label but does an <a href="export.htm">EXPORT</a> at the same time.</p>
<p>Labels will normally change their value during the <a href="../link.htm">link process</a> and are thus <em>not</em> constant.</p>
<hr>
<p>Last updated 21 June 1997 by <a href="mailto:[email protected]">Carsten Sorensen</a></p>
</body>
</html>
-60
View File
@@ -1,60 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>xAsm MACRO/ENDM</title>
<link rel="stylesheet" type="text/css" href="../style.css">
</head>
<body>
<h1>MACRO, ENDM</h1>
<p>One of the best features of an assembler is the ability to write macros for it. Macros also provide a method of passing arguments to them and they can then react to the input using IF-constructs.</p>
<pre>MyMacro: MACRO
ld a,80
call MyFunc
ENDM</pre>
<p>The above example is a very simple macro. You execute the macro by typing its name.</p>
<pre> add a,b
ld sp,hl
MyMacro ;This will be expanded
sub a,87</pre>
<p>When the assembler meets MyMacro it will insert the macrodefinition (the text enclosed in <b>MACRO/ENDM</b>).</p>
<p id="labelsuffix">Suppose your macro contains a loop.</p>
<pre>LoopyMacro: MACRO
xor a,a
.loop ld [hl+],a
dec c
jr nz,.loop
ENDM</pre>
<p>This is fine. That is, if you only use the macro once per <a href="labels.htm">scope</a>. To get around this problem there is a special label string equate called <b>\@</b> that you can append to your labels and it will then expand to a unique string.</p>
<p><b>\@</b> also works in <a href="rept.htm">REPT-blocks</a> should you have any loops there.</p>
<pre>LoopyMacro: MACRO
xor a,a
.loop\@ ld [hl+],a
dec c
jr nz,.loop\@
ENDM</pre>
<h2>Arguments</h2>
<p>Id like <i>LoopyMacro</i> a lot better if I didnt have to pre-load the registers with values and <em>then</em> call it. What Id like is the ability to pass it arguments and it then loaded the registers itself.</p>
<p>And I can do that. In macros you can get the arguments by using the special macro string equates <b>\1</b> through <b>\9</b>, <b>\1</b> being the first argument specified on the calling of the macro.</p>
<pre>LoopyMacro: MACRO
ld hl,\1
ld c,\2
xor a,a
.loop\@ ld [hl+],a
dec c
jr nz,.loop\@
ENDM</pre>
<p>Now I can call the macro specifying two arguments. The first being the address and the second being a bytecount. The macro will then reset all bytes in this range.</p>
<pre> LoopyMacro MyVars,54</pre>
<p>You can specify up to nine arguments when calling a macro. Arguments are passed as string equates. Theres no need to enclose them in quotes. Parameter passing has changed a bit since v1.03 in that an expression will not be evaluated first but passed directly. This means that its probably a very good idea to use brackets around \1\9 if you perform further calculations on them. For instance if you pass 1+2 as the first argument and then do <code> PRINTV \1*2</code>
you will get the value 5 on screen and not 6 as you might have expected.</p>
<p>Note that a colon (:) following the macro-name is required. Macros can't be exported or imported. It's valid to call a macro from a macro (yes, even the same one).</p>
<h1>See also:</h1>
<ul>
<li><a href="shift.htm">SHIFT</a>
</ul>
<hr>
<p>Last updated 02 July 1997 by <a href="mailto:[email protected]">Carsten Sorensen</a></p>
</body>
</html>
-38
View File
@@ -1,38 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>xAsm Other functions</title>
<link rel="stylesheet" type="text/css" href="../style.css">
</head>
<body>
<h1>Other functions</h1>
<p>There's a few other functions that do various useful things:</p>
<table>
<caption>Other functions</caption>
<thead>
<tr>
<th scope="col">Name</th>
<th scope="col">Operation</th>
</tr>
</thead>
<tr>
<td>BANK(<i>label</i>)</td>
<td>Gameboy ONLY: Returns the bank number <i>label</i> is in. The link will have to resolve this so it can't be used when the expression has to be constant</td>
</tr>
<tr>
<td>DEF(<i>label</i>)</td>
<td>Returns TRUE if <i>label</i> has been defined</td>
</tr>
</table>
<h1>See alse:</h1>
<ul>
<li><a href="section.htm">Sections</a>
<li><a href="symbols.htm">Symbols</a>
<li><a href="presym.htm">Predeclared symbols</a>
<li><a href="if.htm">Conditional assembling</a>
</ul>
<hr>
<p>Last updated 21 June 1997 by <a href="mailto:[email protected]">Carsten Sorensen</a></p>
</body>
</html>
-27
View File
@@ -1,27 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>xAsm OPT</title>
<link rel="stylesheet" type="text/css" href="../style.css">
</head>
<body>
<h1>OPT</h1>
<p>OPT can be used to change <I>some</I> of the options during assembling you source instead of defining them on the commandline.</p>
<p>OPT takes a comma-seperated list of options as its argument:</p>
<pre> PUSHO
OPT g.oOX ;Set the GB graphics constants to use these characters
DW `..ooOOXX
POPO
DW `00112233</pre>
<p>The options that OPT can modify are currently: <b>b, e and g</b></p>
<h1>See also:</h1>
<ul>
<li><a href="usage.htm">Usage</a>
<li><a href="popo.htm">The option stack</a>
</ul>
<hr>
<p>Last updated 20 July 1997 by <a href="mailto:[email protected]">Carsten Sorensen</a></p>
</body>
</html>
-18
View File
@@ -1,18 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>xAsm POPO, PUSHO</title>
<link rel="stylesheet" type="text/css" href="../style.css">
</head>
<body>
<h1>POPO, PUSHO</h1>
<p>POPO and PUSHO provide the interface to the option stack. PUSHO will push the current set of options on the option stack. POPO can then later be used to restore them. Useful if you want to change some options in an include file and you don't want to destroy the options set by the program that included your file. The stacks number of entries is limited only by the amount of memory in your machine.</p>
<h1>See also:</h1>
<ul>
<li><a href="opt.htm">Changing options while assembling</a>
</ul>
<hr>
<p>Last updated 20 July 1997 by <a href="mailto:[email protected]">Carsten Sorensen</a></p>
</body>
</html>
-18
View File
@@ -1,18 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>xAsm POPS, PUSHS</title>
<link rel="stylesheet" type="text/css" href="../style.css">
</head>
<body>
<h1>POPS, PUSHS</h1>
<p>POPS and PUSHS provide the interface to the section stack. PUSHS will push the current section context on the section stack. POPS can then later be used to restore it. Useful for defining sections in included files when you don't want to destroy the section context for the program that included your file. The stacks number of entries is limited only by the amount of memory in your machine.</p>
<h1>See also:</h1>
<ul>
<li><a href="section.htm">Sections</a>
</ul>
<hr>
<p>Last updated 18 July 1997 by <a href="mailto:[email protected]">Carsten Sorensen</a></p>
</body>
</html>
-63
View File
@@ -1,63 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>xAsm Predeclared symbols</title>
<link rel="stylesheet" type="text/css" href="../style.css">
</head>
<body>
<h1>Predeclared symbols</h1>
<table>
<caption>Symbols</caption>
<thead>
<tr>
<th scope="col">Name</th>
<th scope="col">Contents</th>
<th scope="col">Type</th>
</tr>
</thead>
<tr>
<td>@</td>
<td>PC value</td>
<td>EQU</td>
</tr>
<tr>
<td>_PI</td>
<td>Fixed point ¶</td>
<td>EQU</td>
</tr>
<tr>
<td>_RS</td>
<td>_RS counter</td>
<td>SET</td>
</tr>
<tr>
<td>_NARG</td>
<td>Number of arguments passed to macro</td>
<td>EQU</td>
</tr>
<tr>
<td>__LINE__</td>
<td>The current linenumber</td>
<td>EQU</td>
</tr>
<tr>
<td>__FILE__</td>
<td>The current filename</td>
<td>EQUS</td>
</tr>
<tr>
<td>__DATE__</td>
<td>Todays date</td>
<td>EQUS</td>
</tr>
<tr>
<td>__TIME__</td>
<td>The current time</td>
<td>EQUS</td>
</tr>
</table>
<hr>
<p>Last updated 21 June 1997 by <a href="mailto:[email protected]">Carsten Sorensen</a></p>
</body>
</html>
-29
View File
@@ -1,29 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>xAsm PRINTT, PRINTV, PRINTF</title>
<link rel="stylesheet" type="text/css" href="../style.css">
</head>
<body>
<h1>PRINTT, PRINTV, PRINTF</h1>
<p>These three instructions type text and values to stdout. Useful for debugging macros or wherever you may feel the need to tell yourself some important information.</p>
<pre>PRINTT "I'm the greatest programmer in the whole wide world\n"
PRINTV (2+3)/5
PRINTF MUL(3.14,3987.0)</pre>
<ul>
<li><dfn>PRINTT</dfn> prints out a string</li>
<li><dfn>PRINTV</dfn> prints out an integer value or, as in the example, the result of a calculation. Unsurprisingly you can also print out a <a href="symbols.htm">constant symbols</a> value</li>
<li><dfn>PRINTF</dfn> prints out a fixed point value.</li>
</ul>
<h1>See also:</h1>
<ul>
<li><a href="asm/expr_int.htm">Integer and Boolean expressions</a>
<li><a href="asm/expr_fix.htm">Fixed-point expressions and functions</a>
<li><a href="asm/expr_str.htm">String expressions, functions and formatting</a>
</ul>
<hr>
<p>Last updated 21 June 1997 by <a href="mailto:[email protected]">Carsten Sorensen</a></p>
</body>
</html>
-18
View File
@@ -1,18 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>xAsm PURGE</title>
<link rel="stylesheet" type="text/css" href="../style.css">
</head>
<body>
<h1>PURGE</h1>
<p>The PURGE command allows you to completely remove a symbol from the symbol table as if it had never existed. USE WITH EXTREME CAUTION!!! I cant stress this enough but you <em>seriously</em> need to know what you are doing. DONT purge symbol that you use in expressions the linker needs to calculate. In fact, its probably not even safe to purge anything other than string symbols and macros.</p>
<pre>Kamikaze EQUS "I don't want to live anymore"
AOLer EQUS "Me too"
PURGE Kamikaze,AOLer</pre>
<p>Note that string symbols that are part of a PURGE command WILL NOT BE EXPANDED as the ONLY exception to this rule.</p>
<hr>
<p>Last updated 02 July 1997 by <a href="mailto:[email protected]">Carsten Sorensen</a></p>
</body>
</html>
-32
View File
@@ -1,32 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>xAsm REPT, ENDR</title>
<link rel="stylesheet" type="text/css" href="../style.css">
</head>
<body>
<h1>REPT, ENDR</h1>
<p>Suppose youre feeling lazy and you want to unroll a time consuming loop. <dfn>REPT</dfn> is here for that purpose. Everything between REPT and ENDR will be repeated a number of times just as if you done a copy/paste operation yourself</p>
<pre>REPT 4
add a,c
ENDR</pre>
<p>This will assemble <code>add a,c</code> four times.</p>
<p>You can also use REPT to generate tables on the fly:</p>
<pre>; --
; -- Generate a 256 byte sine table with values between 0 and 128
; --
ANGLE SET 0.0
REPT 256
DB (MUL(64.0,SIN(ANGLE))+64.0)>>16
ANGLE SET ANGLE+256.0
ENDR</pre>
<p>REPT is also very useful in recursive macros and as in macros you can also use the special label operator \@. REPT-blocks can be nested.<p>
<h1>See also:</h1>
<ul>
<li><a href="macro.htm#labelsuffix">\@</a>
</ul>
<hr>
<p>Last updated 21 June 1997 by <a href="mailto:[email protected]">Carsten Sorensen</a></p>
</body>
</html>
-76
View File
@@ -1,76 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>xAsm RSSET, RSRESET, RB, RW</title>
<link rel="stylesheet" type="text/css" href="../style.css">
</head>
<body>
<h1>RSSET, RERESET, RB, RW</h1>
<p>The <dfn>RS</dfn> group of commands is a handy way of defining structures:</p>
<pre> RSRESET
str_pStuff RW 1
str_tData RB 256
str_bCount RB 1
str_SIZEOF RB 0</pre>
<p>The example defines four <a href="equ.htm">equated</a> symbols:</p>
<table>
<caption>Defined symbols</caption>
<thead>
<tr>
<th scope="col">Name</th>
<th scope="col">Value</th>
</tr>
</thead>
<tr>
<td>str_pStuff</td>
<td>0</td>
</tr>
<tr>
<td>str_tData</td>
<td>2</td>
</tr>
<tr>
<td>str_bCount</td>
<td>258</td>
</tr>
<tr>
<td>str_SIZEOF</td>
<td>259</td>
</tr>
</table>
<p>There are four commands in the RS group of commands:</p>
<table>
<caption>RS related commands</caption>
<thead>
<tr>
<th scope="col">Command</th>
<th scope="col">Meaning</th>
</tr>
</thead>
<tr>
<td>RSRESET</td>
<td>Resets the <a href="presym.htm">_RS</a> counter to zero</td>
</tr>
<tr>
<td>RSSET <i>constexpr</i></td>
<td>Sets the <a href="presym.htm">_RS</a> counter to <i>constexpr</i></td>
</tr>
<tr>
<td>RB <i>constexpr</i></td>
<td>Sets the preceding symbol to <a href="presym.htm">_RS</a> and adds <i>constexpr</i> to _RS</td>
</tr>
<tr>
<td>RW <i>constexpr</i></td>
<td>Sets the preceding symbol to <a href="presym.htm">_RS</a> and adds <i>constexpr*2</i> to _RS</td>
</tr>
</table>
<p>Note that a colon (:) following the symbol-name is not allowed. RS symbols can be exported and imported. They don't change their value during the link process.</p>
<h1>See also:</h1>
<ul>
<li><a href="expr_int.htm">Integer and Boolean expressions</a>
</ul>
<hr>
<p>Last updated 21 June 1997 by <a href="mailto:[email protected]">Carsten Sorensen</a></p>
</body>
</html>
-70
View File
@@ -1,70 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>xAsm SECTION</title>
<link rel="stylesheet" type="text/css" href="../style.css">
</head>
<body>
<h1>SECTION</h1>
<p>Before you can start writing code you must define a section. This tells the assembler what kind of data follows and if it is code where to put it.</p>
<pre>SECTION "CoolStuff",ROMX</pre>
<p>This switches to the section called <b>"CoolStuff"</b> (or creates it if it doesn't already exits) and it defines it as a code section. All sections within a sourcefile must be identified by a <em>unique</em> name.</p>
<p>Possible section types are as follows:
<dl>
<dt>ROM0</dt>
<dd>A ROM section. Mapped to memory at $0000$3fff.</dd>
<dt>ROMX</dt>
<dd>A banked ROM section. Mapped to memory at $4000$7fff. Valid banks range from 1 to 511.</dd>
<dt>VRAM</dt>
<dd>A banked video RAM section. Mapped to memory at $8000$9fff. Can only allocate memory, not fill it. Valid banks range from 0 to 1.</dd>
<dt>SRAM</dt>
<dd>A banked external (save) RAM section. Mapped to memory at $a000$bfff. Can only allocate memory, not fill it. Valid banks range from 0 to 3.</dd>
<dt>WRAM0</dt>
<dd>A general-purpose RAM section. Mapped to memory at $c000$cfff. Can only allocate memory, not fill it.</dd>
<dt>WRAMX</dt>
<dd>A banked general-purpose RAM section. Mapped to memory at $d000$dfff. Can only allocate memory, not fill it. Valid banks range from 1 to 7.</dd>
<dt>HRAM</dt>
<dd>A high RAM section. Mapped to memory at $ff80$fffe. Can only allocate memory, not fill it. NOTE WELL: if you use this method of allocating HRAM the assembler will NOT choose the short addressingmode in the LD instruction because the actual address calculation is done by the linker! If you find this undesirable you can use <a href="rs.htm">RSSET/RB/RW</a> instead or use the LDIO mnemonic. The address calculation is then done by the assembler.</dd>
</dl>
<p>The following deprecated section names are aliases for some of the above sections:
<dl>
<dt>HOME</dt>
<dd>Alias for ROM0.</dd>
<dt>CODE</dt>
<dt>DATA</dt>
<dd>Alias for ROMX.</dd>
<dt>BSS</dt>
<dd>Alias for WRAM0.</dd>
</dl>
<p>Due to quite a lot of emails requesting an ORG directive you can now add an address to the sectiontype for the Gameboy:</p>
<pre>SECTION "CoolStuff",ROM0[$1234]</pre>
<p>This will force the section to address $1234. This also works with the other sectiontypes. For ROMX sections the linker will then place the section in any bank at the address you specify. If you also want to specify the bank you can do:</p>
<pre>SECTION "CoolStuff",ROMX[$4567],BANK[3]</pre>
<p>And if you only want to force the section into a certain bank, and not it's position within the bank, that's also possible:</p>
<pre>SECTION "CoolStuff",ROMX,BANK[7]</pre>
<p><strong>HINT:</strong> If you think this is a lot of typing for doing a simple ORG type thing you can quite easily write an intelligent macro (called ORG for example) that uses <a href="expr_str.htm">\@</a> for the sectionname and determines correct sectiontype etc as arguments for SECTION</p>
<h1>See also:</h1>
<ul>
<li><a href="../link.htm">xLink</a> documentation
<li><a href="expr_int.htm">Integer and Boolean expressions</a>
<li><a href="expr_str.htm">String expressions, functions and formatting</a>
<li><a href="pops.htm">POPS and PUSHS:</a> The section stack.
</ul>
<hr>
<p>Last updated 18 July 1997 by <a href="mailto:[email protected]">Carsten Sorensen</a></p>
</body>
</html>
-22
View File
@@ -1,22 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>xAsm SET</title>
<link rel="stylesheet" type="text/css" href="../style.css">
</head>
<body>
<h1>SET</h1>
<p>SETs are like <a href="equ.htm">EQUates</a> also constant symbols in the sense that their values are defined during the assembly process. These symbols are normally used in macros.</p>
<pre>KINKYCOUNT SET 2
KINKYCOUNT SET DONUT_ISGOOD+KINKYCOUNT</pre>
<p>Note that a colon (:) following the label-name is not allowed. SETs can be exported and imported but the result is undefined and might change in a later release. Alternatively you can use = as a synonym for SET.</p>
<h1>See also:</h1>
<ul>
<li><a href="expr_int.htm">Integer and Boolean expressions</a>
</ul>
<hr>
<p>Last updated 21 June 1997 by <a href="mailto:[email protected]">Carsten Sorensen</a></p>
</body>
</html>
-19
View File
@@ -1,19 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>xAsm SHIFT</title>
<link rel="stylesheet" type="text/css" href="../style.css">
</head>
<body>
<h1>SHIFT</h1>
<p><dfn>SHIFT</dfn> is a special command only available in <a href="macro.htm">macros</a>. Very useful in <a href="rept.htm">REPT-blocks</a>. It will "shift" the arguments by one "to the left". <b>\1</b> will get <b>\2</b>'s value, <b>\2</b> will get <b>\3</b>'s value and so forth.</p>
<h1>See also:</h1>
<ul>
<li><a href="macro.htm">Macros</a>
<li><a href="rept.htm">Automatically repeating blocks of code</a>
</ul>
<hr>
<p>Last updated 21 June 1997 by <a href="mailto:[email protected]">Carsten Sorensen</a></p>
</body>
</html>
-31
View File
@@ -1,31 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>xAsm Symbols</title>
<link rel="stylesheet" type="text/css" href="../style.css">
</head>
<body>
<h1>xAsm Symbols</h1>
<p>xAsm supports several types of symbols:</p>
<ul>
<li><a href="labels.htm">Label</a>. Used to assign a memory location with a name
<li><a href="equ.htm">EQUate</a>. Give a constant a name.
<li><a href="set.htm">SET</a>. Same as EQUate but with a subtle difference. You can change the value of a SET during assembling.
<li><a href="rs.htm">Structures (the RS group)</a>. Define a structure easily.
<li><a href="equs.htm">String equate (EQUS)</a>. Give an often used string a name. Can also be used as a mini-macro. Much like #define in C.
<li><a href="macro.htm">MACROs</a>. A block of code or pseudo instructions that you invoke like any other mnemonic. You can give them arguments too! Life is good.
</ul>
<p><strong>A symbol cannot have the same name as a reserved keyword.</strong></p>
<h1>See also:</h1>
<ul>
<li><a href="presym.htm">Predeclared symbols</a>
<li><a href="export.htm">Importing and exporting symbols</a>
<li><a href="purge.htm">Purging symbols</a>
</ul>
<hr>
<p>Last updated 02 July 1997 by <a href="mailto:[email protected]">Carsten Sorensen</a></p>
</body>
</html>
-23
View File
@@ -1,23 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>xAsm Syntax</title>
<link rel="stylesheet" type="text/css" href="../style.css">
</head>
<body>
<h1>xAsm Syntax</h1>
<p>The syntax linebased, just as in any other assembler. Meaning that you do one instruction or pseudoop per line:</p>
<pre>[label] [instruction] [;comment]</pre>
<p>Example:</p>
<pre>John: ld a,87 ;Weee</pre>
<p>A comment can also be an asterisk (*) followed by the comment if the asterisk is the first character on the line:</p>
<pre>********************************
* These are full line comments *
********************************</pre>
<p>All pseudoops, mnemonics and registers (reserved keywords) are <em>caseinsensitive</em> and all labels are <em>casesensitive</em>.</p>
<hr>
<p>Last updated 21 June 1997 by <a href="mailto:[email protected]">Carsten Sorensen</a></p>
</body>
</html>
-102
View File
@@ -1,102 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>xAsm Gameboy</title>
<link rel="stylesheet" type="text/css" href="../style.css">
</head>
<body>
<h1>Gameboy</h1>
<p>The full GB-Z80 instruction-set is implemented with a few modifications to the original Zilog syntax. This is due to a Bison problem but in my opinion the syntax is better than the original one.</p>
<h2>Instructions</h2>
<ul>
<li>ADC
<li>ADD
<li>AND
<li>BIT
<li>CALL
<li>CCF
<li>CP
<li>CPL
<li>DAA
<li>DEC
<li>DI
<li>EI
<li>EX
<li>HALT
<li>INC
<li>JP
<li>JR
<li>LD
<li>LDD
<li>LDI
<li>LDH/LDIO (see note below)
<li>NOP
<li>OR
<li>POP
<li>PUSH
<li>RES
<li>RET
<li>RETI
<li>RL
<li>RLA
<li>RLC
<li>RLCA
<li>RR
<li>RRA
<li>RRC
<li>RRCA
<li>RST
<li>SBC
<li>SCF
<li>SET
<li>SLA
<li>SRA
<li>SRL
<li>STOP
<li>SUB
<li>SWAP
<li>XOR
</ul>
<p>Note that you can use both
<pre> OR A,B
OR B</pre>
<h2>Addressingmodes</h2>
<p>Indirect addressing has been changed to [ ] instead of ( ):</p>
<ul>
<li> A
<li> B
<li> C
<li> D
<li> E
<li> H
<li> L
<li> AF
<li> BC
<li> DE
<li> HL
<li> SP
<li> [BC]
<li> [DE]
<li> [HL]
<li> [HL-]/[HLI]
<li> [HL+]/[HLD]
<li> [SP]
<li> n8 (8 bit expression)
<li> n16 (16 bit expression)
<li> n3 (3 bit CONSTANT expression)
<li> [n16]/[$FF00+n8]
<li> [$FF00+C]/[C]
</ul>
<p>The assembler will intelligently decide between <b>[n16]</b> and <b>[$FF00+n8]</b> in the LD instruction. Note however that if you use any <a href="symbols.htm">constant symbols</a> in the expression they had better be defined before the instruction or your symbol-table may become mangled. Also worth noting is that it will only ever select the short $FF00 mode when you use constant symbols. NOT if you use symbols defined in a <a href="section.htm">HRAM section</a>. As this defies the whole point of implementing the HRAM sectiontype I've added the LDIO mnemonic. It works like the LD instruction but it will ALWAYS generate the $FF00+ form and it will also automatically logically AND the expression with $FF if it is relocatable. Which is what you want. Trust me ;)</p>
<h2>Conditioncodes</h2>
<ul>
<li> C
<li> NC
<li> Z
<li> NZ
</ul>
<hr>
<p>Last updated 20 July 1997 by <a href="mailto:[email protected]">Carsten Sorensen</a></p>
</body>
</html>
-30
View File
@@ -1,30 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>xAsm Usage</title>
<link rel="stylesheet" type="text/css" href="../style.css">
</head>
<body>
<h1>xAsm Usage</h1>
<pre>C:\>xAsm [options] asmfile</pre>
<p>Options are preceded by a hyphen (-) and go as follows:</p>
<pre> o<b>objectfile</b> : Write an <a href="../rgb0.htm">object-file</a> for <a href="../link.htm">xLink</a>
i<b>path</b> : Add an extra include-path
h : Short help text
e<b>(l|b)</b> : Change endianness (CAUTION!)
g<b>ASCI</b> : Change the four characters used for Gameboy graphics
constants (default is <b>0123</b>)
b<b>AS</b> : Change the two characters used for binary constants
(default is <b>01</b>)
z<b>HX</b> : Set the byte value (hex format) used for uninitialised data (default is ? for random)
</pre>
<h1>See also:</h1>
<ul>
<li><a href="opt.htm">Changing options while assembling</a>
</ul>
<hr>
<p>Last updated 08 October 1997 by <a href="mailto:[email protected]">Carsten Sorensen</a></p>
</body>
</html>
-116
View File
@@ -1,116 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>General Information</title>
<link rel="stylesheet" type="text/css" href="./style.css">
</head>
<body>
<h1><abbr title="Rednex Game Boy Development System">RGBDS</abbr>—ASMotor General Information</h1>
<h2>Table of Contents</h2>
<ul>
<li><a href="#license">License</a>
<li><a href="#Author">The Author</a>
<li><a href="#Introduction">Introduction</a>
<li><a href="#Installation">Installation</a>
<li><a href="#Documentation">The Documentation</a>
<li><a href="#History">History</a>
</ul>
<h2 id="license">License</h2>
<p>The <dfn>ASMotor</dfn> package (<a href="asm.htm">xAsm</a>, <a href="link.htm">xLink</a>, <a href="fix.htm">RGBFix</a>, examples and <a href="#Documentation">documentation</a>) is freeware and distributed as is. The author retains his copyright and right to modify the specifications and operation of the software without notice.
<p>In other words this means I encourage you to…
<ul>
<li>use it for whatever purpose even professional work without me charging you a penny
<li>copy it to another person (wholly or in part, though Im sure hed appreciate the whole package) in
whatever form you find suitable
<li>mass-distribute the ASMotor package if it is complete (<a href="asm.htm">xAsm</a>, <a href="link.htm">xLink</a>, <a href="fix.htm">RGBFix</a> and documentation).
<li>contact me if you have any problems
</ul>
<p>This also means you cant…
<ul>
<li>blame me for loss of profit, data, sleep, food or other nasty things through the use or distribution of ASMotor. If
you choose to use ASMotor you do so at your own risk.
<li>expect me to be able to help you should you have a problem related or not to ASMotor.
</ul>
<h2 id="Author">The Author</h2>
<p>Any questions? Write me!
<h3>Address</h3>
<p>
Carsten Sorensen<br>
1 Spring Court<br>
Guildford<br>
Surrey GU2 6QW<br>
United Kingdom<br>
<h3 id="Email">e-mail:</h3>
<ul>
<li><a href="mailto:[email protected]">[email protected]</a> (private)
<li><a href="mailto:[email protected]">[email protected]</a> (work)
</ul>
<p>Get the latest version from my web page at <a href="http://www.matilde.demon.co.uk">http://www.matilde.demon.co.uk</a>
<h2 id="History">History</h2>
<table>
<caption>The history of ASMotor</caption>
<thead>
<tr>
<th>Version</th>
<th>Dated</th>
<th>Release notes</th>
</tr>
</thead>
<tr>
<td>1.0</td>
<td>03 July 1997</td>
<td>First release</td>
</tr>
<tr>
<td>1.01</td>
<td>20 July 1997</td>
<td><p>RGBDS fixes:</p>
<ul>
<li>RGBFix can now also truncate the ROM-images to a valid size.
<li>RGBAsm supports the LDD and LDI syntax plus [HLD] and [HLI]. LDH is synonymous with LDIO.
<li>Example filenames have been changed to adhere to Jeff Frohweins proposed standard.
</ul>
<p>General fixes:</p>
<ul>
<li>RGBLink knows about big and little endian. Plus it can do range checking on intermediate results in an expression. This is necessary to support
different types of CPUs.
<li>RGBLink <em>didnt</em> know about the special PC symbol “@” so if you used it more than once per sourcefile in an expression the linker had to resolve, things would go horribly wrong.
<li>There was a bug in the macro parameter passing. Any whitespace after the last parameter would be appended to the last parameter. Reported by Jeff Frohwein.
<li>A section stack has been implemented. Look up POPS and PUSHS in the
manual. Jeff Frohweins doing again.
<li>OPT command added for defining and changing some options while assembling.
<li>You can now define which characters are used for the Gameboy graphics integer (`) using the commandline or the new OPT command. Cool idea by (surprise surprise) Jeff Frohwein.
<li>Also, an option stack has been added. Look up POPO and PUSHO in the manual.
<li>Fixed yet another line number bug reported by Jeff Frohwein (when will this guy leave me alone? ;)
</ul>
</td>
<tr>
<td>1.02</td>
<td>22 July 1997</td>
<td><p>General fixes:</p>
<ul>
<li>The lamest typo bug of all time has been fixed. RGBAsm would output a word defined with DW as 4 bytes instead of 2. Jeff Frohwein reported this.
<li>The first line of an included file didnt assemble correctly.
<li>-b option added for setting the characters used for binary constants.
</ul>
</td>
</tr>
<tr>
<td>1.10</td>
<td>21 Sep 1997</td>
<td><p>General fixes:</p>
<ul>
<li>The assembler would crash if you tried to use a macro symbol in an expression. (Jeff Frohwein)
<li>You couldnt use STRCMP, STRLEN and STRIN in relocatable expressions. (Harry P. Mulder)
<li>Relocatable symbols are no longer allowed as arguments to the DEF function.
<li>Finally! A librarian and smart linking has been added.
<li>Bug fixed in the assembler where it would sometimes write out too many bytes for HRAM section definitions.
<li>-z options (set fill value used for uninitialised data) added to the
assembler and linker.
<li>The assembler will now read in any type of ASCII file on any type of OS.
</ul>
</table>
<p>Last updated 08 October 1997 by <a href="mailto:[email protected]">Carsten Sorensen</a></p>
</body>
</html>
-20
View File
@@ -1,20 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>RGBDS—ASMotor Documentation</title>
<link rel="stylesheet" type="text/css" href="./style.css">
</head>
<body>
<h1><abbr title="Rednex Game Boy Development System">RGBDS</abbr>—ASMotor v1.10 Documentation</h1>
<h2>Table of Contents</h2>
<ul>
<li><a href="geninfo.htm">ASMotor General Information</a>
<li><a href="asm.htm">xASM Documentation</a>
<li><a href="link.htm">xLink Documentation</a>
<li><a href="fix.htm">RGBFix Documentation</a>
<li><a href="rgb0.htm">The RGB0-2 ObjectFileFormat</a>
</ul>
<p>Last updated 21 September 1997 by <a href="mailto:[email protected]">Carsten Sorensen</a></p>
</body>
</html>
-118
View File
@@ -1,118 +0,0 @@
<!DOCTYPE HTML PUBliC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>xLink</title>
<link rel="stylesheet" type="text/css" href="./style.css">
</head>
<body>
<h1>xLink Documentation</h1>
<h2>Table of Contents</h2>
<ul>
<li><a href="#history"> History</a>
<li><a href="#usage"> Usage</a>
<li><a href="#linkfile"> The Linkfile</a>
<li><a href="#operationtg"> Operation for Gameboy</a>
<li><a href="#smallmode"> Operation for Gameboy small mode</a>
<li><a href="#psion2"> Operation for Psion2 relocatable modules</a>
</ul>
<hr>
<h2 id="history">History</h2>
<table>
<caption>The history of xLink</caption>
<thead>
<tr>
<th scope="col">Version</th>
<th scope="col">Dated</th>
<th scope="col">Release notes</th>
</tr>
</thead>
<tr>
<td>1.0</td>
<td>1 Oct. 96</td>
<td>First release (RGBDS)</td>
</tr>
<tr>
<td>1.01</td>
<td>3 Dec. 96</td>
<td>
<ul>
<li>BANK() didn't work. Fixed.</li>
<li>Sections were quite often output in the wrong order. Fixed.</li>
</ul>
</tr>
<tr>
<td>1.02</td>
<td>12 Feb. 97</td>
<td><a href="#usage">-s switch and mapfile option</A> added</td>
</tr>
<tr>
<td>1.03</td>
<td>23 Mar. 97</td>
<td>
<ul>
<li><a href="#usage">Mapfile</A> now shows BSS, VRAM and HRAM areas</li>
<li>There was a bug regarding <a href="#operation">fixed HOME sections.</a>
</ul></td>
</tr>
<tr>
<td>1.04</td>
<td>03 July 1997</td>
<td>First ASMotor release. Supports big-endian CPUs as well. <a href="#usage">Usage</a> changed to allow for different output fileformats</td>
</tr>
<tr>
<td>1.05</td>
<td>20 July 1997</td>
<td>
<ul>
<li>We can now do range checking on intermediate results in an expression. This is necessary to support different types of CPUs.</li>
<li>RGBLink DIDNT know about the special PC symbol "@" so if you used it more than once per sourcefile in an expression the linker had to resolve, things would go horribly wrong.</li>
</ul>
</td>
<tr>
<td>1.06</td>
<td>21 September 1997</td>
<td><ul><li>Smart linking and library support added
<li>Program renamed to xLink
</ul>
</td>
</table>
<h2 id="usage">Usage</h2>
<pre> xlink [options] linkfile</pre>
<p>Options are preceded by a hyphen (-) and go as follows:
<pre> h : Short help text
m<b>mapfile</b> : Write a mapfile
t : Output target:
tg : Gameboy <a href="#operationtg">ROM image</a> (default)
ts : Gameboy <a href="#smallmode">Small mode (32kB)</a> ROM image
tp : <a href="#psion2">Psion2</a> relocatable module
z<b>HX</b> : Set the byte value (hex format) used for uninitialised data (default is ? for random)
</pre>
<h2 id="linkfile">The Linkfile</h2>
<p>A linkfile is used to tell <B>xLink</B> which objects to include and what the outputname should be. It is in plain ASCII-format.
<pre> # Linkfile for foobar.gb
[Objects]
foo.obj
bar.obj
[Libraries]
mylib.lib
[Output]
foobar.gb</pre>
<p>A line starting with # is ignored.
<p>If you use libraries they will only be included if one of the objects actually reference them. This works on a SECTION level and not on a module level. This means that when you write libraries you can put each subroutine in its own SECTION so only the relevant bits are included.
<h2 id="operationtg">Operation for Gameboy (-tg)</h2>
<p><a href="asm.htm#sections">Sections</a> created with <b>ROM0</b> in the assembler are placed in the GB bank #0 (the fixed bank $0000-$3FFF) in the order they are loaded from the objectfiles specified in the linkfile. So you want the first file in the linkfile to contain your header. <b>ROMX</b> sections are placed in <em>any bank other than #0</em>. This means you have absolutely <em>no</em> control over which sections goes where. This insures minimal slack (unused bytes) at the end of each bank in the image.
<p>Currently the linker doesn't calculate the GB checksums.
You must use <a href="fix.htm">RGBFix</a> to do this.
<h3 id="smallmode">Operation for Gameboy small mode (-ts)</h3>
<p>Small mode forces all <b>ROMX</b> sections to be of type <b>ROM0</b> and increases the <b>ROM0</b> section size from 16kB to 32kB. This also means that <b>ROM0/ROMX</b> sections are written to the final image in the order you have specified on the command line.
<p>Currently the linker doesn't calculate the GB checksums. You must use <a href="fix.htm">RGBFix</a> to do this.
<hr>
<p>Last updated 08 October 1997 by <a href="mailto:[email protected]">Carsten Sorensen</a></p>
</body>
</html>
-210
View File
@@ -1,210 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>RGB? Fileformat</title>
<link rel="stylesheet" type="text/css" href="./style.css">
</head>
<body>
<h1>The RGB ObjectFileFormats</h1>
<h2>Table of Contents</h2>
<ul>
<li><a href="#background">Background</A>
<li><a href="#filestructure">FileStructure</A>
<li><a href="#rpn">Rpn Data</A>
</ul>
<h2 id="background">Background</h2>
<p>I developed the RGB0 fileformat mainly because I needed a suitable dataformat to hold the output from <a href="asm.htm">xAsm</a> that was powerful to accomodate all the features I needed and also would make it easy for me to add new ones. The reason for documenting it is so people can write converters between it and other formats. Perhaps even develop other compilers for it?</p>
<p>The RGB1 fileformat saw the light of day with the V1.02 of the old RGBDS release because of the addition of fixed sections.</p>
<p>The RGB2 fileformat emerged because I needed to add support for big endian CPUs.</p>
<h2 id="filestructure">FileStructure</h2>
<ul>
<li><dfn>LONG</dfn> is a 32bit integer stored in littleendian format (Intel)
<li><dfn>BYTE</dfn> is an 8bit integer
<li><dfn>STRING</dfn> is a 0terminated string of <b>BYTE</b>
</ul>
<p>Down to business...</p>
<pre>
; There's a header...
BYTE ID[4] ;"RGB0", "RGB1", "RGB2"
LONG NumberOfSymbols ;The number of symbols used in this file
LONG NumberOfSections ;The number of sections used in this file
; Now for some symbols
REPT NumberOfSymbols ;<b>NumberOfSymbols</b> symboldefs follow
STRING Name ;The name of this symbol
BYTE Type ;0 = LOCAL symbol only used in this file
;1 = IMPORT this symbol from elsewhere
;2 = EXPORT this symbol to other objects
IF Type != 1
LONG SectionID ;The section number in which this symbol
;is defined. If -1 this symbol is an EQUate
LONG Value ;The symbols value. If SectionID!=-1 it's the
;offset into that section
ENDC
ENDR
; And I'll be... Sections!
REPT NumberOfSections
LONG Size ;Size in bytes of this section
BYTE Type ;0 = WRAM0
;1 = VRAM
;2 = ROMX
;3 = ROM0
;4 = HRAM
LONG Org ;Only present in RGB1. Address to fix this
;section at. -1 if the linker should
;decide (normal operation)
LONG Bank ;Only present in RGB1. Bank to load this
;section into. -1 if the linker should
;decide (normal operation). This field is
;only valid for ROMX sections.
IF Type==ROMX || Type==ROM0
BYTE Data[Size]
LONG NumberOfPatches
; These types of sections may have patches
REPT NumberOfPatches
STRING SourceFile ;The name of the sourcefile (for
;printing an errormessage)
LONG Line ;The line of the sourcefile
LONG Offset ;Offset into the section where patch
;should be applied
BYTE Type ;0 = BYTE patch
;1 = little endian WORD patch
;2 = little endianLONG patch
;3 = big endian WORD patch (RGB2 and later)
;4 = big endianLONG patch (RGB2 and later)
LONG RPNSize
BYTE RPN[RPNSize] ;RPN definition below
ENDR
ENDC
ENDR</pre>
<h2 id="rpn">Rpn Data</h2>
<p>Expressions in the objectfile are stored as <abbr title="Reverse Polish Notation">RPN</abbr>. This is an expression of the form “2 5 +”. This will first push the value “2” to the stack. Then “5”. The “+” 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 <b>BYTE</b>s with some bytes being special prefixes for integers and symbols.</p>
<table>
<caption>RPN Expressions</caption>
<thead>
<tr>
<th scope="col">Byte value</th>
<th scope="col">Meaning</th>
</tr>
</thead>
<tr>
<td>$00</td>
<td>+ operator</td>
</tr>
<tr>
<td>$01</td>
<td>- operator</td>
</tr>
<tr>
<td>$02</td>
<td>* operator</td>
</tr>
<tr>
<td>$03</td>
<td>/ operator</td>
</tr>
<tr>
<td>$04</td>
<td>% operator</td>
</tr>
<tr>
<td>$05</td>
<td>unary -</td>
</tr>
<tr>
<td>$06</td>
<td>| operator</td>
</tr>
<tr>
<td>$07</td>
<td>& operator</td>
</tr>
<tr>
<td>$08</td>
<td>^ operator</td>
</tr>
<tr>
<td>$09</td>
<td>unary ~</td>
</tr>
<tr>
<td>$0A</td>
<td>&& comparison</td>
</tr>
<tr>
<td>$0B</td>
<td>|| comparison</td>
</tr>
<tr>
<td>$0C</td>
<td>unary !</td>
</tr>
<tr>
<td>$0D</td>
<td>== comparison</td>
</tr>
<tr>
<td>$0E</td>
<td>!= comparison</td>
</tr>
<tr>
<td>$0F</td>
<td>&gt comparison</td>
</tr>
<tr>
<td>$10</td>
<td>&lt comparison</td>
</tr>
<tr>
<td>$11</td>
<td>&gt= comparison</td>
</tr>
<tr>
<td>$12</td>
<td>&lt= comparison</td>
</tr>
<tr>
<td>$13</td>
<td>&lt&lt operator</td>
</tr>
<tr>
<td>$14</td>
<td>&gt&gt operator</td>
</tr>
<tr>
<td>$15</td>
<td>BANK() function for Gameboy, a symbol ID follows</td>
</tr>
<tr>
<td>$16</td>
<td>HRAMCheck for Gameboy, check if value is in HRAM and logically and it with 0xFF</td>
</tr>
<tr>
<td>$17</td>
<td>ZeroPageCheck for PC-Engine, check if value is in ZP (0x2000-0x20FF) and logically and it with 0xFF</td>
</tr>
<tr>
<td>$18</td>
<td>RangeCheck. LOW and HIGH signed LONGs follow. Checks a value to see if within the range [LOW;HIGH]. If not, generate an error.
</td>
</tr>
<tr>
<td>$80</td>
<td>LONG integer follows</td>
</tr>
<tr>
<td>$81</td>
<td>Symbol ID follows</td>
</tr>
</table>
<hr>
<p>Last updated 18 July 1997 by <a href="mailto:[email protected]">Carsten Sorensen</a></p>
</body>
</html>
+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.
+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
-35
View File
@@ -1,35 +0,0 @@
/* asm.h
*
* Contains some assembler-wide defines and externs
*
* Copyright 1997 Carsten Sorensen
*
*/
#ifndef RGBDS_ASM_ASM_H
#define RGBDS_ASM_ASM_H
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include "types.h"
#include "asm/symbol.h"
#include "asm/localasm.h"
extern SLONG nLineNo;
extern ULONG nTotalLines;
extern ULONG nPC;
extern ULONG nPass;
extern ULONG nIFDepth;
extern char tzCurrentFileName[_MAX_PATH + 1];
extern struct Section *pCurrentSection;
extern struct sSymbol *tHashedSymbols[HASHSIZE];
extern struct sSymbol *pPCSymbol;
extern bool oDontExpandStrings;
#define MAXMACROARGS 256
#define MAXINCPATHS 16
#endif /* // ASM_H */
-18
View File
@@ -1,18 +0,0 @@
#ifndef RGBDS_ASM_CHARMAP_H
#define RGBDS_ASM_CHARMAP_H
#define MAXCHARMAPS 512
#define CHARMAPLENGTH 8
struct Charmap {
int count;
char input[MAXCHARMAPS][CHARMAPLENGTH + 1];
char output[MAXCHARMAPS];
};
int readUTF8Char(char *destination, char *source);
void charmap_Sort();
int charmap_Add(char *input, UBYTE output);
int charmap_Convert(char **input);
#endif
+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
-46
View File
@@ -1,46 +0,0 @@
/* fstack.h
*
* Contains some assembler-wide defines and externs
*
* Copyright 1997 Carsten Sorensen
*
*/
#ifndef RGBDS_ASM_FSTACK_H
#define RGBDS_ASM_FSTACK_H
#include <stdio.h>
#include "asm/asm.h"
#include "types.h"
#include "asm/lexer.h"
struct sContext {
YY_BUFFER_STATE FlexHandle;
struct sSymbol *pMacro;
struct sContext *pNext;
char tzFileName[_MAX_PATH + 1];
char *tzMacroArgs[MAXMACROARGS + 1];
SLONG nLine;
ULONG nStatus;
FILE *pFile;
char *pREPTBlock;
ULONG nREPTBlockCount;
ULONG nREPTBlockSize;
};
void
fstk_RunInclude(char *);
extern void fstk_RunMacroArg(SLONG s);
void
fstk_Init(char *);
extern void fstk_Dump(void);
extern void fstk_AddIncludePath(char *s);
extern ULONG fstk_RunMacro(char *s);
extern void fstk_RunRept(ULONG count);
FILE *
fstk_FindFile(char *);
extern int yywrap(void);
#endif
+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
-67
View File
@@ -1,67 +0,0 @@
#ifndef RGBDS_ASM_LEXER_H
#define RGBDS_ASM_LEXER_H
#include <stdio.h>
#include "types.h"
#define LEXHASHSIZE (1 << 11)
#define MAXSTRLEN 255
struct sLexInitString {
char *tzName;
ULONG nToken;
};
struct sLexFloat {
ULONG(*Callback) (char *s, ULONG size);
ULONG nToken;
};
struct yy_buffer_state {
char *pBufferRealStart; // actual starting address
char *pBufferStart; // address where the data is initially written
// after the "safety margin"
char *pBuffer;
ULONG nBufferSize;
ULONG oAtLineStart;
};
enum eLexerState {
LEX_STATE_NORMAL,
LEX_STATE_MACROARGS
};
#define INITIAL 0
#define macroarg 3
typedef struct yy_buffer_state *YY_BUFFER_STATE;
extern void yy_set_state(enum eLexerState i);
extern YY_BUFFER_STATE yy_create_buffer(FILE * f);
extern YY_BUFFER_STATE yy_scan_bytes(char *mem, ULONG size);
extern void yy_delete_buffer(YY_BUFFER_STATE);
extern void yy_switch_to_buffer(YY_BUFFER_STATE);
extern ULONG lex_FloatAlloc(struct sLexFloat * tok);
extern void lex_FloatAddRange(ULONG id, UWORD start, UWORD end);
extern void lex_FloatDeleteRange(ULONG id, UWORD start, UWORD end);
extern void lex_FloatAddFirstRange(ULONG id, UWORD start, UWORD end);
extern void lex_FloatDeleteFirstRange(ULONG id, UWORD start, UWORD end);
extern void lex_FloatAddSecondRange(ULONG id, UWORD start, UWORD end);
extern void lex_FloatDeleteSecondRange(ULONG id, UWORD start, UWORD end);
extern void lex_Init(void);
extern void lex_AddStrings(struct sLexInitString * lex);
extern void lex_SetBuffer(char *buffer, ULONG len);
extern ULONG yylex(void);
extern void yyunput(char c);
extern void yyunputstr(char *s);
extern void yyskipbytes(ULONG count);
extern void yyunputbytes(ULONG count);
extern YY_BUFFER_STATE pCurrentBuffer;
#ifdef __GNUC__
extern void strupr(char *s);
extern void strlwr(char *s);
#endif
#endif
+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

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