ISSOtm / fortISSimO

A speed-and size-focused Game Boy music driver, drop-in replacement for hUGEDriver ~ Try the demo!
http://eldred.fr/fortISSimO/
Other
20 stars 3 forks source link

Unmuting a channel may still yield a corrupted sound #6

Closed ISSOtm closed 1 year ago

ISSOtm commented 2 years ago

When a channel is unmuted, the driver refrains from using it until a note is next played. The reason is that FX might write to the channel while NRxy still contain leftover values, but not the song's; this would produce corrupt sounds. When a note is played, all NRxy registers are initialised, avoiding the issue.

However, the current condition is wrong: all registers may not be written if a note is played, only if an instrument is specified on that cell as well.

https://github.com/ISSOtm/fortISSimO/blob/91287deb393ff70f75d6ff93a9d8f2d33e82852f/fortISSimO.asm#L530-L541

https://github.com/ISSOtm/fortISSimO/blob/91287deb393ff70f75d6ff93a9d8f2d33e82852f/fortISSimO.asm#L629-L637

https://github.com/ISSOtm/fortISSimO/blob/91287deb393ff70f75d6ff93a9d8f2d33e82852f/fortISSimO.asm#L715-L723

This would require moving the AllowedChannels write inside of the "instrument writes" block. Preferably early, as e (the channel mask) eventually gets overwritten from register pressure.