Code Monkey home page Code Monkey logo

gbdev / rgbds Goto Github PK

View Code? Open in Web Editor NEW
1.3K 45.0 172.0 13.07 MB

Rednex Game Boy Development System - An assembly toolchain for the Nintendo Game Boy and Game Boy Color

Home Page: https://rgbds.gbdev.io

License: MIT License

Assembly 17.31% Shell 6.23% Makefile 1.09% Yacc 8.05% Dockerfile 0.06% CMake 1.12% C++ 66.13% NASL 0.01% BitBake 0.01%
gameboy gbdev gamedev assembly asm assembly-language assembly-sm83 cplusplus game-boy game-development

rgbds's Introduction

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.

The documentation of this toolchain can be viewed online. It is generated from the man pages found in this repository. The source code of the website itself is on GitHub as well under the repo rgbds-www.

If you want to contribute or maintain RGBDS, and have questions regarding the code, its organisation, etc. you can find the maintainers on the gbdev community channels or via mail at rgbds at gbdev dot io.

1. Installing RGBDS

The installation procedure is available online for various platforms. Building from source is possible using make or cmake; follow the link for more detailed instructions.

make
sudo make install
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build
cmake --install build

2. RGBDS Folder Organization

The RGBDS source code file structure is as follows:

.
├── .github/
│   ├── scripts/
│   │   └── ...
│   └── workflows/
│       └── ...
├── contrib/
│   ├── zsh_compl/
│   │   └── ...
│   └── ...
├── include/
│   └── ...
├── man/
│   └── ...
├── src/
│   ├── asm/
│   │   └── ...
│   ├── extern/
│   │   └── ...
│   ├── fix/
│   │   └── ...
│   ├── gfx/
│   │   └── ...
│   ├── link/
│   │   └── ...
│   ├── CMakeLists.txt
│   └── ...
├── test/
│   ├── ...
│   └── run-tests.sh
├── .clang-format
├── CMakeLists.txt
├── Dockerfile
├── Makefile
└── README.md
  • .github/ - files and scripts related to the integration of the RGBDS codebase with GitHub.
    • scripts/ - scripts used by workflow files.
    • workflows/ - CI workflow description files.
  • contrib/ - scripts and other resources which may be useful to users and developers of RGBDS.
    • zsh_compl contains tab completion scripts for use with zsh. Put them somewhere in your fpath, and they should auto-load.
    • bash_compl contains tab completion scripts for use with bash. Run them with source somewhere in your .bashrc, and they should load every time you open a shell.
  • include/ - header files for the respective source files in src.
  • man/ - manual pages.
  • src/ - source code of RGBDS.
    • Note that the code unique to each RGBDS tool is stored in its respective subdirectory (rgbasm's code is in src/asm/, for example). src/extern/ contains code imported from external sources.
  • test/ - testing framework used to verify that changes to the code don't break or modify the behavior of RGBDS.
  • .clang-format - code style for automated C++ formatting with clang-format.
  • Dockerfile - defines how to build RGBDS with Docker.

3. History

  • 1996-10-01: Carsten Sørensen (a.k.a. SurfSmurf) releases xAsm, xLink, and RGBFix, a Game Boy SM83 (GBZ80) assembler/linker system for DOS/Win32.
  • 1997-07-03: Sørensen releases ASMotor, packaging the three programs together and moving towards making them a general-purpose target-independent system.
  • 1999-08-01: Justin Lloyd (a.k.a. Otaku no Zoku) adapts ASMotor to re-focus on SM83 assembly/machine code, and releases this version as RGBDS.
  • 2009-06-11: Vegard Nossum adapts the code to be more UNIX-like and releases this version as rgbds-linux.
  • 2010-01-12: Anthony J. Bentley forks Nossum's repository. The fork becomes the reference implementation of RGBDS.
  • 2015-01-18: stag019 begins implementing rgbgfx, a PNG‐to‐Game Boy graphics converter, for eventual integration into RGBDS.
  • 2016-09-05: rgbgfx is integrated into Bentley's repository.
  • 2017-02-23: Bentley's repository is moved to the rednex organization.
  • 2018-01-26: The codebase is relicensed under the MIT license.
  • 2020-09-15: The repository is moved to the gbdev organization.
  • 2022-05-17: The rgbds.gbdev.io website for RGBDS documentation and downloads is published.

4. Acknowledgements

RGBGFX generates palettes using algorithms found in the paper "Algorithms for the Pagination Problem, a Bin Packing with Overlapping Items" (GitHub, MIT license), by Aristide Grange, Imed Kacem, and Sébastien Martin.

RGBGFX's color palette was taken from SameBoy, with permission and help by LIJI.

rgbds's People

Contributors

aaaaaa123456789 avatar anderoonies avatar antoniond avatar avivace avatar ben10do avatar bentley avatar clach04 avatar daid avatar daknig avatar dannye avatar dbrotz avatar eievui5 avatar gy741 avatar huderlem avatar issotm avatar jidoc01 avatar jl2210 avatar mattcurrie avatar meithecatte avatar mid-kid avatar obskyr avatar pikalaxalt avatar pinobatch avatar qguv avatar rangi42 avatar rlewicki avatar sanqui avatar stag019 avatar vegard avatar yenatch avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rgbds's Issues

test/asm/divzero-section-bank.asm fails

The newly added test/asm/divzero-section-bank.asm crashes.

Starting program: /home/anthony/bin/rgbasm divzero-section-bank.asm

Program received signal SIGFPE, Arithmetic exception.
0x0000073742b06bc0 in yyparse () at asmy.y:995
995     asmy.y: No such file or directory.
        in asmy.y

ghost banks

portions of bss can be repurposed between program states. this generally involves overlapping sets of labels. this occurs in commercial software

wram banks can act as ghost banks for address space 0xd000-0xdfff, but 0xc000-0xcfff is mapped to one bank only. an example workaround is to define constants in place of would-be ghost labels. however, the start point must be set manually, since constants must be evaluated before linking

there is potential for a lot of unneeded complexity, so this would be a good place to hash out how it could work

section wram0
wSomething:
    ds 100
wGhostArea:
    ds 5
wGhostAreaSubset:
    ds 5

section wram0 [wGhostArea], ghost
wGhostedArea:
    ds 10

section wram0 [wGhostArea], ghost [1] ; multiple ghost banks
wAnotherGhostedArea:
    ds 20

section wram0 [wAnotherGhostedArea] ; a ghost of a ghost
    ds 30
  • there should be some way to keep track of multiple ghost banks. ghost [x] is probably not ideal
  • being able to start a section at a relocatable address is a given, but the expected behavior would be to group ghost sections based on their starting point, which runs counter to current behavior (where sections are each forced to a starting point if one is given)

what if starting from a relocatable was interpreted as a ghost section in the first place? is that too implicit? how would the linker know which ghost bank to put it in?

section wram0 [wGhostArea]

other section features to consider in the context of ghosting:

  • optional directives (i.e. start from the end of a bank, especially in rom sections)
  • nameless sections
  • custom bank definitions (maybe rom can be mapped to $8000-$bfff, like on the game gear)
  • dmg (where ghosting is actually useful, because bss is bankless)

test/asm/divzero-instr.asm fails

The newly added test/asm/divzero-instr.asm crashes.

Starting program: /home/anthony/bin/rgbasm bar.asm

Program received signal SIGFPE, Arithmetic exception.
0x00000bbb2660cd0c in rpn_DIV (expr=0xbbb26a19280, src1=Variable "src1" is not available.
) at src/asm/rpn.c:319
319             expr->nVal = (expr->nVal / src2->nVal);
(gdb) bt
#0  0x00000bbb2660cd0c in rpn_DIV (expr=0xbbb26a19280, src1=Variable "src1" is not available.
)
    at src/asm/rpn.c:319
#1  0x00000bbb26606d16 in yyparse () at asmy.y:931
#2  0x00000bbb2660aa84 in main (argc=Variable "argc" is not available.
) at src/asm/main.c:334

A section for OAM RAM

In WLA-DX I can have an enumeration where OAM RAM is defined ($FE00). RGBDS doesn't appear to have enums or a section that can reach that point. Can there be one?

test/asm/null-in-macro.asm fails

The newly added test/asm/null-in-macro.asm crashes.

The 0 byte embedded in the source code results in a zero‐length string buffer, which then gets assigned to.

Starting program: /home/anthony/bin/rgbasm null-in-macro.asm

Program received signal SIGSEGV, Segmentation fault.
0x00001112c5504427 in copymacro () at asmy.y:226
226     asmy.y: No such file or directory.
        in asmy.y
(gdb) bt
#0  0x00001112c5504427 in copymacro () at asmy.y:226
#1  0x00001112c5506e68 in yyparse () at asmy.y:643
#2  0x00001112c550aa84 in main (argc=Variable "argc" is not available.
) at src/asm/main.c:334

ld hl, [sp+$nn]

Another jp [hl] case.
ld hl, [sp+$nn] should be ld hl, sp+$nn. Support both for legacy.

Maybe warnings could be produced for old variants?

HIGH() and LOW() for 16-bit registers

Implement HIGH() and LOW() functions that take a 16-bit register and return the appropriate 8-bit register.

HIGH(hl) → h
LOW(bc) → c

This would make the creation of macros that take 16-bit registers and work with their 8-bit partitions possible.

fix dmg wram

#7 broke dmg in the process

one way to fix is to assume wram0 is 0x2000 long in the absence of wramx sections

Provide more information on bank overflow errors

RGBASM dies when an assembled portion exceeds the maximum size of a bank or section, however the message it outputs is completely uninformative. Specifically, it does not inform the user as to which line caused the overflow at compile time. This issue serves as a request to implement this information in the error message for bank/section overflows.

Compiler Failing because of implicit declarations

Getting this as an output of make

src/gfx/png.c:166:2: error: implicit declaration of function 'png_set_quantize'
      is invalid in C99 [-Werror,-Wimplicit-function-declaration]
        png_set_quantize(img->png, palette, colors, colors, NULL, 1);

More verbose redefinition error

I think it would be nice if we could have some verbose output when there is a label redefinition.

Say like

ERROR:  src/main.asm(10) -> banks/Bank3.asm(3) :
        'label_C000' already defined

Could be

ERROR:  src/main.asm(10) -> banks/Bank3.asm(3) :
        'label_C000' already defined wram.asm(33)

Macro arguments in the middle of expressions.

A__ = -1

test_1: macro
    db \1_\1_\1
endm

test_2: macro
    db \1_\2_\3
endm

section "main", rom0

    test_1 A       ; -1
    test_2 A, B, C ; -1

Numbers are weirder:

test_3: macro
    db \11
endm

test_4: macro
    db -\1
endm

test_5: macro
    db 1\12
endm

test_6: macro
    db 1\1
endm

section "main", rom0

    test_3 1       ; 11
    test_4 1       ; -1
    test_5 -       ; -1
    test_5 1       ; syntax error
    test_6 1       ; syntax error

ASMotor references shouldn't be included in source anymore, only history

Again, copy/pasting a grep.

include/link/library.h:#ifndef ASMOTOR_LINK_LIBRARY_H
include/link/library.h:#define ASMOTOR_LINK_LIBRARY_H
include/link/symbol.h:#ifndef ASMOTOR_LINK_SYMBOL_H
include/link/symbol.h:#define ASMOTOR_LINK_SYMBOL_H
include/link/main.h:#ifndef ASMOTOR_LINK_MAIN_H
include/link/main.h:#define ASMOTOR_LINK_MAIN_H
include/link/mapfile.h:#ifndef ASMOTOR_LINK_MAPFILE_H
include/link/mapfile.h:#define ASMOTOR_LINK_MAPFILE_H
include/link/output.h:#ifndef ASMOTOR_LINK_OUTPUT_H
include/link/output.h:#define ASMOTOR_LINK_OUTPUT_H
include/link/patch.h:#ifndef ASMOTOR_LINK_PATCH_H
include/link/patch.h:#define ASMOTOR_LINK_PATCH_H
include/link/assign.h:#ifndef ASMOTOR_LINK_ASSIGN_H
include/link/assign.h:#define ASMOTOR_LINK_ASSIGN_H
include/link/mylink.h:#ifndef ASMOTOR_LINK_LINK_H
include/link/mylink.h:#define ASMOTOR_LINK_LINK_H
include/link/types.h:#ifndef ASMOTOR_LINK_TYPES_H
include/link/types.h:#define ASMOTOR_LINK_TYPES_H
include/link/object.h:#ifndef ASMOTOR_LINK_OBJECT_H
include/link/object.h:#define ASMOTOR_LINK_OBJECT_H
include/asm/lexer.h:#ifndef ASMOTOR_ASM_LEXER_H
include/asm/lexer.h:#define ASMOTOR_ASM_LEXER_H
include/asm/charmap.h:#ifndef ASMOTOR_ASM_CHARMAP_H
include/asm/charmap.h:#define ASMOTOR_ASM_CHARMAP_H
include/asm/symbol.h:#ifndef ASMOTOR_SYMBOL_H
include/asm/symbol.h:#define ASMOTOR_SYMBOL_H
include/asm/main.h:#ifndef ASMOTOR_MAIN_H
include/asm/main.h:#define ASMOTOR_MAIN_H
include/asm/rpn.h:#ifndef ASMOTOR_ASM_RPN_H
include/asm/rpn.h:#define ASMOTOR_ASM_RPN_H
include/asm/output.h:#ifndef ASMOTOR_ASM_OUTPUT_H
include/asm/output.h:#define ASMOTOR_ASM_OUTPUT_H
include/asm/fstack.h:#ifndef ASMOTOR_ASM_FSTACK_H
include/asm/fstack.h:#define ASMOTOR_ASM_FSTACK_H
include/asm/mymath.h:#ifndef ASMOTOR_ASM_MATH_H
include/asm/mymath.h:#define ASMOTOR_ASM_MATH_H
include/asm/mylink.h:#ifndef ASMOTOR_ASM_LINK_H
include/asm/mylink.h:#define ASMOTOR_ASM_LINK_H
include/asm/asm.h:#ifndef ASMOTOR_ASM_ASM_H
include/asm/asm.h:#define ASMOTOR_ASM_ASM_H
include/asm/types.h:#ifndef ASMOTOR_ASM_TYPES_H
include/asm/types.h:#define ASMOTOR_ASM_TYPES_H

Tags for latest version

I'd like to make a keg for this on homebrew, but homebrew needs a version (tag) to stick to. I could fork, but I'd rather use this repo as it seems like the canonical one. Could you please add a tag to the latest commit, and continue tagging as fixes/additions are made?

Thanks!
Matt

Segmentation fault when jumping to illegal subscript reference

Example script;

Function1:
    ld a, 1
.subscript
    and a
    ret z
    scf
    ret

Function2:
    xor a
    jp .subscript

Result: Segmentation fault. No additional information is available, and it can be a struggle to try and find the offender.

What I'd like to see is: Symbol "Function2.subscript" not found. This at least tells the user where to start looking.

Inconsistent use of error functions

Just leaving my notes here, I don't care if you fix it or wait for me to get around to it, but I'd like to free up some text files from my computer and this seems like the place to put it.

This was just me greping "err" in all the files, so excuse the mistake if there's something in here that shouldn't be deleted.

include/asm/main.h:void fatalerror(const char *fmt, ...);
include/asm/main.h:void yyerror(const char *fmt, ...);
include/asm/main.h:#define YY_FATAL_ERROR fatalerror
src/link/main.c: fprintf(stderr, "Argument for option 'p' must be between 0 and 0xFF");
src/asm/gameboy/yaccprt4.y: yyerror("Address $%x not 16-bit", $6);
src/asm/gameboy/yaccprt4.y: yyerror("ROM bank value $%x out of range (1 to $1ff)", $8);
src/asm/gameboy/yaccprt4.y: yyerror("SRAM bank value $%x out of range (0 to 3)", $8);
src/asm/gameboy/yaccprt4.y: yyerror("WRAMX bank value $%x out of range (1 to 7)", $8);
src/asm/gameboy/yaccprt4.y: yyerror("VRAM bank value $%x out of range (0 to 1)", $8);
src/asm/gameboy/yaccprt4.y: yyerror("BANK only allowed for ROMX, WRAMX, SRAM, or VRAM sections");
src/asm/gameboy/yaccprt4.y: yyerror("ROM bank value $%x out of range (1 to $1ff)", $11);
src/asm/gameboy/yaccprt4.y: yyerror("Address $%x not 16-bit", $6);
src/asm/gameboy/yaccprt4.y: yyerror("SRAM bank value $%x out of range (0 to 3)", $11);
src/asm/gameboy/yaccprt4.y: yyerror("Address $%x not 16-bit", $6);
src/asm/gameboy/yaccprt4.y: yyerror("WRAMX bank value $%x out of range (1 to 7)", $11);
src/asm/gameboy/yaccprt4.y: yyerror("Address $%x not 16-bit", $6);
src/asm/gameboy/yaccprt4.y: yyerror("VRAM bank value $%x out of range (0 to 1)", $11);
src/asm/gameboy/yaccprt4.y: yyerror("Address $%x not 16-bit", $6);
src/asm/gameboy/yaccprt4.y: yyerror("BANK only allowed for ROMX, WRAMX, SRAM, or VRAM sections");
src/asm/gameboy/yaccprt4.y: yyerror("Source address $%x not in HRAM ($FF00 to $FFFE)", $4.nVal);
src/asm/gameboy/yaccprt4.y: yyerror("Destination address $%x not in HRAM ($FF00 to $FFFE)", $2.nVal);
src/asm/gameboy/yaccprt4.y: yyerror("LD [HL],[HL] not a valid instruction");
src/asm/gameboy/yaccprt4.y: yyerror("Destination operand must be A");
src/asm/gameboy/yaccprt4.y: yyerror("Destination operand must be A");
src/asm/gameboy/yaccprt4.y: yyerror("Destination operand must be A");
src/asm/gameboy/yaccprt4.y: yyerror("Address for RST must be absolute");
src/asm/gameboy/yaccprt4.y: yyerror("Invalid address $%x for RST", $2.nVal);
src/asm/rpn.c: yyerror("'%s' not defined", tzSym);
src/asm/rpn.c: yyerror("BANK argument must be a relocatable identifier");
src/asm/fstack.c: fatalerror("No memory for context");
src/asm/fstack.c: * Dump the context stack to stderr
src/asm/fstack.c: fprintf(stderr, "%s(%ld) -> ", pLastFile->tzFileName,
src/asm/fstack.c: fprintf(stderr, "%s(%ld)", tzCurrentFileName, nLineNo);
src/asm/fstack.c: fatalerror("No such macroargument");
src/asm/fstack.c: yyerror("No such string symbol '%s'", s);
src/asm/yaccprt1.y: fatalerror("Symbol value too long to fit buffer");
src/asm/yaccprt1.y: fatalerror("snprintf encoding error");
src/asm/yaccprt1.y: fatalerror("Symbol value too long to fit buffer");
src/asm/yaccprt1.y: fatalerror( "No mem for REPT block" );
src/asm/yaccprt1.y: fatalerror( "No mem for MACRO definition" );
src/asm/asmy.y: fatalerror("Symbol value too long to fit buffer");
src/asm/asmy.y: fatalerror("snprintf encoding error");
src/asm/asmy.y: fatalerror("Symbol value too long to fit buffer");
src/asm/asmy.y: fatalerror( "No mem for REPT block" );
src/asm/asmy.y: fatalerror( "No mem for MACRO definition" );
src/asm/asmy.y: yyerror("Macro '%s' not defined", $1);
src/asm/asmy.y: { fatalerror("%s", $2); }
src/asm/asmy.y: { yyerror("%s", $2); }
src/asm/asmy.y: yyerror("Immediate value must be 3-bit");
src/asm/asmy.y: yyerror("Expression must be PC-relative");
src/asm/asmy.y: yyerror("Expression must be 8-bit");
src/asm/asmy.y: yyerror("Expression must be 16-bit");
src/asm/asmy.y: yyerror("Address $%x not 16-bit", $6);
src/asm/asmy.y: yyerror("ROM bank value $%x out of range (1 to $1ff)", $8);
src/asm/asmy.y: yyerror("SRAM bank value $%x out of range (0 to 3)", $8);
src/asm/asmy.y: yyerror("WRAMX bank value $%x out of range (1 to 7)", $8);
src/asm/asmy.y: yyerror("VRAM bank value $%x out of range (0 to 1)", $8);
src/asm/asmy.y: yyerror("BANK only allowed for ROMX, WRAMX, SRAM, or VRAM sections");
src/asm/asmy.y: yyerror("ROM bank value $%x out of range (1 to $1ff)", $11);
src/asm/asmy.y: yyerror("Address $%x not 16-bit", $6);
src/asm/asmy.y: yyerror("SRAM bank value $%x out of range (0 to 3)", $11);
src/asm/asmy.y: yyerror("Address $%x not 16-bit", $6);
src/asm/asmy.y: yyerror("WRAMX bank value $%x out of range (1 to 7)", $11);
src/asm/asmy.y: yyerror("Address $%x not 16-bit", $6);
src/asm/asmy.y: yyerror("VRAM bank value $%x out of range (0 to 1)", $11);
src/asm/asmy.y: yyerror("Address $%x not 16-bit", $6);
src/asm/asmy.y: yyerror("BANK only allowed for ROMX, WRAMX, SRAM, or VRAM sections");
src/asm/asmy.y: yyerror("Source address $%x not in HRAM ($FF00 to $FFFE)", $4.nVal);
src/asm/asmy.y: yyerror("Destination address $%x not in HRAM ($FF00 to $FFFE)", $2.nVal);
src/asm/asmy.y: yyerror("LD [HL],[HL] not a valid instruction");
src/asm/asmy.y: yyerror("Destination operand must be A");
src/asm/asmy.y: yyerror("Destination operand must be A");
src/asm/asmy.y: yyerror("Destination operand must be A");
src/asm/asmy.y: yyerror("Address for RST must be absolute");
src/asm/asmy.y: yyerror("Invalid address $%x for RST", $2.nVal);
src/asm/globlex.c: fatalerror("Malformed ID");
src/asm/globlex.c: fatalerror("Symbol too long");
src/asm/globlex.c: yyerror("Macro argument not defined");
src/asm/globlex.c: yyerror("Invalid macro argument");
src/asm/globlex.c: yyerror("Macro unique label string not defined");
src/asm/output.c: fatalerror("No memory for section stack");
src/asm/output.c: fatalerror("No entries in the section stack");
src/asm/output.c: fatalerror("INTERNAL: Unknown section");
src/asm/output.c: fatalerror("No memory for patchsymbol");
src/asm/output.c: fatalerror("No memory for patch");
src/asm/output.c: fatalerror("Code generation before SECTION directive");
src/asm/output.c: fatalerror
src/asm/output.c: fatalerror
src/asm/output.c: fatalerror("Not enough memory for section");
src/asm/output.c: fatalerror("Not enough memory for sectionname");
src/asm/output.c: fatalerror("Not enough memory for section");
src/asm/output.c: yyerror("PC-relative value must be 8-bit");
src/asm/output.c: fatalerror("Start position cannot be negative");
src/asm/output.c: fatalerror("Number of bytes to read must be greater than zero");
src/asm/output.c: fatalerror("Specified start position is greater than length of file");
src/asm/output.c: fatalerror("Specified range in INCBIN is out of bounds");
src/asm/main.c: fatalerror("Unknown option");
src/asm/main.c: fatalerror("No memory for option stack");
src/asm/main.c: fatalerror("No entries in the option stack");
src/asm/main.c:verror(const char *fmt, va_list args)
src/asm/main.c: fprintf(stderr, "ERROR:\t");
src/asm/main.c: fprintf(stderr, " :\n\t");
src/asm/main.c: vfprintf(stderr, fmt, args);
src/asm/main.c: fprintf(stderr, "\n");
src/asm/main.c:yyerror(const char *fmt, ...)
src/asm/main.c: verror(fmt, args);
src/asm/main.c:fatalerror(const char *fmt, ...)
src/asm/main.c: verror(fmt, args);
src/asm/symbol.c: fatalerror("No memory for symbol");
src/asm/symbol.c: yyerror("'%s' not defined", tzName);
src/asm/symbol.c: fatalerror("'%s' is not allowed as argument to the "
src/asm/symbol.c: yyerror("Stringsymbol '%s' not defined", tzSym);
src/asm/symbol.c: fatalerror("Expression must have a constant value");
src/asm/symbol.c: yyerror("'%s' not defined", s);
src/asm/symbol.c: yyerror("'%s' is a macro or string symbol", s);
src/asm/symbol.c: yyerror("'%s' not defined", s);
src/asm/symbol.c: yyerror("'%s' is a macro or string symbol", s);
src/asm/symbol.c: yyerror("'%s' not defined", s);
src/asm/symbol.c: yyerror("'%s' not defined", s);
src/asm/symbol.c: yyerror("A maximum of 9 arguments allowed");
src/asm/symbol.c: yyerror("'%s' already defined", tzSym);
src/asm/symbol.c: yyerror("'%s' already defined", tzSym);
src/asm/symbol.c: fatalerror("No memory for stringequate");
src/asm/symbol.c: yyerror("'%s' already defined", tzSym);
src/asm/symbol.c: fatalerror("Local label in main scope");
src/asm/symbol.c: yyerror("'%s' already defined", tzSym);
src/asm/symbol.c: yyerror("'%s' not defined", tzSym);
src/asm/symbol.c: yyerror("'%s' already defined", tzSym);
src/asm/symbol.c: yyerror("'%s' already defined", tzSym);
src/asm/lexer.c: fatalerror("Buffer safety margin exceeded");
src/asm/lexer.c: fatalerror("Buffer safety margin exceeded");
src/asm/lexer.c: fatalerror("Out of memory!");
src/asm/lexer.c: fatalerror("Out of memory!");
src/asm/lexer.c: fatalerror("Internal error in lexgetfloat");
src/asm/lexer.c: fatalerror("Out of memory!");
src/asm/lexer.c: fatalerror("Out of memory!");
src/asm/lexer.c: fatalerror("Macro argument not defined");
src/asm/lexer.c: fatalerror("Macro argument too long to fit buffer");
src/asm/lexer.c: fatalerror("String too long");
src/asm/lexer.c: fatalerror("Symbol too long");
src/asm/lexer.c: fatalerror("Illegal character escape '%c'", ch);
src/asm/lexer.c: yyerror("Missing }");
src/asm/lexer.c: fatalerror("Illegal character escape '%c'", ch);
src/asm/lexer.c: yyerror("Unterminated string");
src/asm/lexer.c: fatalerror("Illegal character escape '%c'", ch);
src/asm/lexer.c: fatalerror("Internal error in yylex_MACROARGS");
src/asm/lexer.c: fatalerror("Internal error in yylex");
src/asm/yaccprt3.y: yyerror("Macro '%s' not defined", $1);
src/asm/yaccprt3.y: { fatalerror("%s", $2); }
src/asm/yaccprt3.y: { yyerror("%s", $2); }
src/asm/yaccprt3.y: yyerror("Immediate value must be 3-bit");
src/asm/yaccprt3.y: yyerror("Expression must be PC-relative");
src/asm/yaccprt3.y: yyerror("Expression must be 8-bit");
src/asm/yaccprt3.y: yyerror("Expression must be 16-bit");

rgbfix doc

There is no document for rgbfix, though other documents refers to it as "fix.htm"

Dense placement by linker

20:55 <@beware> to be clear, the linker is responsible for placing "thing with 
                symbol X", at bank Y and address Z in the rom, right?
20:56 <@beware> can you make it shuffle these "things" around to optimally 
                (maximum densely) utilize banks?

Macro already defined

I'm having trouble using macros with rgbasm. If I define a macro and call it, the assembler seems to think I'm trying to define it twice.

Foo: MACRO
ENDM

Foo

Assembling this snippet outputs the error 'Foo' already defined. Am I missing something here?

IMPORT not importing

Apologies if this is just my newbishness, but...
I have a file, screens.asm, that has two labels:

Splash_Screen:
;...
Title_Screen:

In my main file, main.asm, I have:

IMPORT Splash_Screen
IMPORT Title_Screen

When running rgblink, I get the error: rgblink: Unknown symbol 'Title_Screen'
EXPORTing Splash_Screen and Title_Screen works, as does using GLOBAL.
Am I doing something wrong, or is IMPORT really not working?

yacc conflicts

yacc warns about some conflicts and then chooses whatever default it seems was more likely intended. We should remove those conflicts.
I don't understand the yacc language that well, but here's what I was able to figure out.

1. const            :   T_ID                            { $$ = sym_GetConstantValue($1); }
                |   const T_OP_SUB const            { $$ = $1 - $3; }
                |   T_ID  T_OP_SUB T_ID             { $$ = sym_GetDefinedValue($1) - sym_GetDefinedValue($3); }

2. constlist_8bit_entry :               { out_Skip( 1 ); }
                        |   const_8bit  { out_RelByte( &$1 ); }
                        |   string      { char *s; int length; s = $1; length = charmap_Convert(&s); out_AbsByteGroup(s, length); free(s); }
    (const_8bit contains relocconst which contains string)

CGB swappable banks

Currently the BSS section type supports WRAM banks 0-1 ($c000-$dfff) which works perfectly for compiling DMG. CGB introduces WRAM banks 2-7, which the current implementation can't account for. The same complication exists with CGB's VRAM bank 1.

Since it works the same way, I'd like to request SRAM allocation as well. Maybe that should have its own issue.

rgbasm flakiness on OpenBSD

rgbasm tends to segfault on OpenBSD (not on Linux) when assembling anything non-trivial. It is inconsistent—reinvoking rgbasm five or six times generally results in at least one successful compile.

The issue seems to be with the toupper() on line 396 of src/asm/lexer.c.

GB graphic prefix bug

When you define a GB graphic constant, like DW `00133100 the resulting two bytes of planar data seem to get stored in the wrong order. It should store the least significant bits first and the most significant ones after them.

Currently DW `00133100 results in $18 $3C being stored instead of $3C $18.

Due to this bug, all pixels with ligh-gray or dark-gray shades get swapped.

Tag current HEAD for use with homebrew

Homebrew doesn't like HEAD only formulas. The current HEAD works properly with homebrew, so if you could tag it with a version, then I could get the formula accepted into the homebrew repo.

Thanks for all your help with these changes!

rgblib delete is broken on OpenBSD

$ rgblib foo add bar
Library 'foo' opened
Added module 'bar'
Library 'foo' closed
$ rgblib foo delete bar
Library 'foo' opened
Segmentation fault (core dumped)

Happens every time.

Lists/arrays

MOVES EQU [$24, $3a]

    db LENGTH(MOVES)
    db MOVES[0], MOVES[1]

Is there any chance for something like this to happen at all? Is it even a good idea?

Should be made to work for strings too.

POKEMON_NAMES EQU ["BULBASAUR", "IVYSAUR"]

    db "So you want ", POKEMON_NAMES[STARTER1], "?@"

Predefined constants do not work, like _PI

_PI is defined with sym_AddEqu during sym_Init, but that's broken for some reason.

sanky@warata:~/romhacking/rgbds_$ cat test.asm
SECTION "rst00",HOME[0]

db _PI % 256
sanky@warata:~/romhacking/rgbds_$ rgbasm test.asm
ERROR:  test.asm(3) :
    '_PI' not defined
Segmentation fault (core dumped)

Non-terminated IFs, REPTs, and MACROs should cause an error

At present, the if_skip_to_else(), if_skip_to_endc(), copymacro() and copyrept() functions in asmy.y continue to read an IF, MACRO or REPT block until they either reach their corresponding ENDC/ENDR/ENDM, or the end of the file is reached.

Such unterminated sections are likely to be erroneous, causing further headaches whilst trying to fix them down the line. Also, the copymacro() and copyrept() functions currently assume that an ENDR or ENDM is scanned, which can cause memory allocation failures and segmentation faults if the file ends shortly afterwards (this was exacerbated by the tests in #50).

As a result, I propose that an error is displayed to the user when such a circumstance arises, along the lines of No ENDM found for MACRO. This shouldn't be tricky to implement, and I'd be surprised if this caused any problems for existing projects. Any thoughts on this before I go look into implementing it?

Link file support

Are link files supported at all anymore? I'm trying to link RGBGrafx into my project, but passing the link file by calling rgblink LinkFileName outputs rgblink: 'LinkFileName' is not a valid object, as if it is expecting an object file. The command line arguments seem to have changed significantly, but the HTML documentation is not up-to-date.

`make install` fails to install man pages via homebrew

make install fails with an issue relating to copying man files. I tried to use "MANPREFIX=#{man}" (man is a variable representing "/usr/local/Cellar/rgbds/0.1.0/share/man") and it fails with the following:

==> make install MANPREFIX=/usr/local/Cellar/rgbds/0.1.0/share/man
install: /usr/local/Cellar/rgbds/0.1.0/share/man/
/usr/local/Cellar/rgbds/0.1.0/share/man/man7/rgbds.7: No such file or directory
Installing manpages to /usr/local/Cellar/rgbds/0.1.0/share/man failed.

Repeated string equate causes an infinite loop when referenced

string equs "anything"
string equs "anything"
string

rgbasm will accept the following without complaint if string is not referenced:

string equs "anything"
string equs "anything"

If the equates don't match, rgbasm will raise Buffer safety margin exceeded:

string equs "anything"
string equs "anything else"

Syntax error on ldi instruction

I have a disassembly that uses the instruction

ldi  a,[hl]

rgbasm tells me

rgbasm -i src/ -o src/main.o src/main.asm
ERROR:  src/main.asm(1644) :
        syntax error
C:\MinGW\msys\1.0\bin\rgbasm.exe: Assembly aborted in pass 1 (1 errors)!
make: *** [src/main.o] Error 1

Right now I am working past that by doing

db $2A ; ldi  a,[hl]

test/asm/bank-noexist.asm fails

The newly added test/asm/bank-noexist.asm crashes.

Starting program: /home/anthony/bin/rgbasm bank-noexist.asm
ERROR:  bank-noexist.asm(2) :
        'noexist' not defined

Program received signal SIGSEGV, Segmentation fault.
calchash (s=0x0) at src/asm/symbol.c:56
56              while (*s != 0)
(gdb) bt
#0  calchash (s=0x0) at src/asm/symbol.c:56
#1  0x0000160af950bde0 in addsymbol (pSym=0x0) at src/asm/output.c:286
#2  0x0000160af950bfaa in createpatch (type=Variable "type" is not available.
) at src/asm/output.c:400
#3  0x0000160af950c2e4 in out_RelByte (expr=0x160d070964a0)
    at src/asm/output.c:675
#4  0x0000160af950678c in yyparse () at asmy.y:839
#5  0x0000160af950aac8 in main (argc=Variable "argc" is not available.
) at src/asm/main.c:358

Widechar charmap support

Now RGBDS can only supprot

charmap "C", $01

Can RGBDS support widechar charmap like

charmap "C", $01F0

or

charmap "C", $01F0, 2

?

Smart linking

20:51 <@beware> anjbe_: is "smart linking" something you can do? smart linking means: only include things that are actually referenced
20:51 <@beware> this mostly helps with libraries
20:51 <@beware> as not all of the library has to be linked
20:51 <@beware> libraries tend to contain a lot of things a project doesn't need
20:52 <@beware> i think a linker could do this transparently
20:52 <@beware> (as in, as part of the linker)
20:53 <@beware> to resolve "is symbol X being referenced", you need to trace it from the program's entry point
20:53 <@beware> because a library can reference a symbol, but if that library is never used, then this reference doesn't mean it should be included
20:54 <@beware> anything (that has a symbol) that is never referenced is "dead" (as in, dead code, dead data)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.