mori0091 / libmsx

C library for MSX
https://mori0091.github.io/libmsx/
MIT License
31 stars 2 forks source link

Cannot access to resources if code size was larger than 16KiB #80

Closed mori0091 closed 1 week ago

mori0091 commented 1 week ago

Describe the bug When the application code size of MegaROM was larger than 16KiB (e.g. #pragma codeseg BANK1 is used), the wrong libmsx_resources.c is generated by make command so resource_*() APIs don't work correctly.

To Reproduce

Assuming that there is only one file a.bin in the resources folder of application's source tree.

Makefile

CONFIG_ROM_TYPE = ascii16

...snip...

src/main.c

#pragma codeseg BANK1

#include <msx.h>
#include <resources.h>

#include <assert.h>

void main(void) {
    const ResourceIndex * res = resource_find("a.bin"); // search the file "resources/a.bin"
    assert(res && res->offset == 0x08000);  // This assertion fails.
    for (;;) await_vsync();
}

Expected behavior Offset of resources and/or banked memory shall start from the next 16KiB segment follows application code. For example, apllication has two 16KiB code segments CODE and BANK1, the 1st offset of resources must be 0x08000.

Development environment (please complete the following information):

Target Platform

Additional context