Skip to content

Including binary files larger than a bank #1694

Open
@aaaaaa123456789

Description

@aaaaaa123456789

A recent discussion in gbdev's #asm-rgbds made me realise that this request has come up enough times by now to warrant a discussion. I have no need for it, but I know many others have, so I figured throwing it here in the tracker would enable a better discussion.

Some projects, for many reasons, end up with quite large binary files that they want to include in their ROMs. These files have the following characteristics in common:

  • They are very large, almost always larger than a bank;
  • They must be allocated contiguously in the ROM, automatically split at bank boundaries; and
  • They can start and end anywhere in the ROM: the game will locate them as needed.

The only way to do this right now is via some sort of preprocessing script. It would be useful for those projects to have a way to do this from source directly.

The best way I can think of is some new sort of section:

SECTION "Big binary files", ROMX[$4000], MULTIBANK
BinaryFile::
  incbin "stuff.bin"
.end::

The way this could work is:

  • The section can be placed anywhere (up to usual bank, alignment and address constraints), but it's not limited in size by the size of the bank
  • If the section reaches the end of the bank, it automatically continues at the beginning of the next bank; this constrains placement to a location where enough empty banks are available
  • BANK("section") should return the first bank of the section
  • All labels inside such a section should be resolved at link time, for simplicity
  • A label at the end of a bank could have an ambiguous placement (at the end of that bank or the beginning of the next bank); this should always point to the beginning of the next bank, unless (1) there is no data in the section after the label or (2) the label is local and the parent global label is at a different address (i.e., there is some data between the global and the local)

This is just a simple proposal; I expect it to mutate a lot before it's even considered. But I'd like to hear from people who would actually use such a feature. Thoughts?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementTypically new features; lesser priority than bugsrgbasmThis affects RGBASMrgblinkThis affects RGBLINK

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions