mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 10:12:06 +00:00
2eca43cd2da5a4be21cada359bd5e152f1896453
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.
This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
RGBDS ===== RGBDS (Rednex Game Boy Development System) is a free assembler/linker package for the Game Boy and Game Boy Color. It consists of: - rgbasm (assembler) - rgblink (linker) - rgbfix (checksum/header fixer) - rgbgfx (PNG‐to‐Game Boy graphics converter) This is a fork of the original RGBDS which aims to make the programs more like other UNIX tools. This toolchain is maintained on `GitHub <https://github.com/rednex/rgbds>`__. The documentation of this toolchain can be viewed online `here <https://rgbds.gbdev.io/docs/>`__, it is generated from the man pages found in this repository. 1. Installing RGBDS ------------------- The `installation procedure <https://rgbds.gbdev.io/install>`__ is available online for various platforms. `Building from source <https://rgbds.gbdev.io/install/source>`__ is possible using ``make`` or ``cmake``; follow the link for more detailed instructions. .. code:: sh make sudo make install .. code:: sh cmake -S . -B build cmake --build build cmake --install build 2. History --------- - Around 1997, Carsten Sørensen (AKA SurfSmurf) writes ASMotor as a general-purpose assembler/linker system for DOS/Win32 - Around 1999, Justin Lloyd (AKA Otaku no Zoku) adapts ASMotor to read and produce GBZ80 assembly/machine code, and releases this version as RGBDS. - 2009, Vegard Nossum adapts the code to be more UNIX-like and releases this version as rgbds-linux on `GitHub <https://github.com/vegard/rgbds-linux>`__. - 2010, Anthony J. Bentley forks that repository. The fork becomes the reference implementation of rgbds. - 2017, Bentley's repository is moved to a neutral name. - 2018, codebase relicensed under the MIT license. - 2020, repository is moved to the `gbdev <https://github.com/gbdev>`__ organisation. The `rgbds.gbdev.io <https://rgbds.gbdev.io>`__ website serving documentation and downloads is created.
Description
Rednex Game Boy Development System - An assembly toolchain for the Nintendo Game Boy and Game Boy Color
asmassemblyassembly-languageassembly-sm83cplusplusgame-boygame-developmentgameboygamedevgbdevgbz80sm83
Readme
MIT
18 MiB
Languages
C++
68%
Assembly
18%
Shell
6.8%
Yacc
5%
CMake
1%
Other
1%