igwgames / create-nes-game

Create and build NES games using ca65/cc65
http://create-nes-game.nes.science/
MIT License
31 stars 2 forks source link

Restoring missing neslib palette initialization code #3

Closed mpdunlop closed 1 year ago

mpdunlop commented 1 year ago

create-nes-game's initialize_library function appears to be based on clearRAM crt0.s in neslib but is missing some initialisation code which sets a pointer to colours which is required for pal_bg() to work. This pull request attempts to restore this functionality.

A diff between crt0.s and a generated neslib-system.asm:

Screenshot of a Winmerge window highlighting code differences.

One thing I'm unsure of is if this change was intentional or not - a method named clearRAM has a more specific meaning that initialize_library and it's quite possible I'm missing some of the details behind this decision.

potatolain commented 1 year ago

Good catch! You're pretty close with this fix.

The one problem is that memory clearing was removed intentionally - this is done in main.asm (main.template.asm) so we don't need that bit. The calls to neslib were definitely wiped out in error however, so we'll want those back.

mpdunlop commented 1 year ago

Thanks for the clarification and pointing me in the right direction. After locating the memory initialization code in main.template.asm and system-runtime.template.asm I could identify what needed to be removed and have updated accordingly.

potatolain commented 1 year ago

Looks great, thanks for doing this! I'll try to publish a new version with this and the other change discussed in #4 later today, or tomorrow worst case.