Open RSDuck opened 1 year ago
There are a few issues here:
[x] const int SwanOffset[NUM_SWANS] = {0, 8, 16, 48, 10};
- ELF relocator bug, Wonderful issue, fixed in wf-tools 0.1.0-r61+.
[ ] const int __wf_rom SwanOffset[NUM_SWANS] = {0, 8, 16, 48, 10};
In Wonderful-generated code, after the first loop, the data segment DS
is clobbered with the ROM segment for the table, and never restored, leading subsequent sprites to be written to ROM.
https://github.com/tkchia/gcc-ia16/issues/142
.palette/.tile
In Wonderful-generated code, the sprite table (relocated to 0x200) is written to location 0x600 instead. This is because, for whatever reason, the offset of the SwanOffset
array is written to DS
????
3b: ba 00 00 mov $0x0,%dx
3c: R_386_16 SwanOffset
3c: R_386_SUB16 SwanOffset!
3e: 8e da mov %dx,%ds
There are probably multiple bugs contained here, but they all together create a wonderful mess.
sprites.zip
See src/main.c. In line 25 there are three different ways for defining the array SwanOffset.
What happens when bitfields are used with the two preceeding ones:
In line 79 it is accessed, but independently from that the behaviour changes based on whether the attr field of the sprite struct is set using bitfields or manually.