MiSTer-devel / NES_MiSTer

GNU General Public License v3.0
174 stars 75 forks source link

Ballblazer: odd audio behavior influenced by a previously loaded game #341

Closed Thelypody closed 1 year ago

Thelypody commented 1 year ago

NES core: 20221002, Main: 20230122.

Ballblazer (Japan) (NES 2.0 header, CRC32: EC846C33) Lot Lot (Japan) (NES 2.0 header, CRC32: 1662089B)

I've encountered a strange sound bug while switching between two roms mentioned above. Ballblazer was quite famous on Atari platforms for featuring a randomly generated main theme consisting of a fixed main riff and random background melodies generated by POKEY on the fly. The Japan-only Famicom port retains this theme and plays it on a brand new isometric demonstration screen. It plays fine when the game is loaded by the core as a first game during session, but it seems like switching between games can corrupt its music playback. The game which led me to encounter this bug happened to be Lot Lot. It has a completely silent title screen, and to reproduce the bug just load Ballblazer after Lot Lot without interacting with the game beforehand. The Lucasfilm Games logo will display fine, but right after it the game will loudly beep for 2 and a half bars instead of playing its main riff. After this bug the game continues to act normally. The issue does not appear after resetting Ballblazer. It is extra strange to me that it distorts the main riff which is supposed to be fixed and not randomly generated. Other games can also distort Ballblazer theme. Binary Land has an identical effect as Lot Lot, while Arkanoid and Archon cause a more pleasant wrong note to play for the same period of time.

Kitrinx commented 1 year ago

After some testing, it seems that this game does indeed randomly generate its music, just like the 7800 version. It's seeding its random values based on the state of the ram, which is "undefined" on system power up for the NES. The NES core does not clear RAM by default between games loaded to somewhat emulate that Z-state ram on startup, and this is what you are seeing here. Lot Lot is initialing the part of ram it uses to a fixed value when you load it, then when you switch bad, ballblazer is creating a pretty unappealing but deterministic melody from it :)

NES.zip

To see for yourself, try this build, and use the "ram clear" value under advanced. This isn't really a bug but just amusing original behavior.

Thelypody commented 1 year ago

I see, with your build it does indeed play music cleanly. I assume that these advanced options are going to appear in the future core release or they are just there for debugging purposes? I feel like it is not really possible to achieve the same behavior in real life with a Famicom and two game cartridges to load Ballblazer with Lot Lot's RAM state, so a RAM clear option could be useful in such edge cases.

Kitrinx commented 1 year ago

they will eventually make their way into the main build, as they are useful for a lot of RNG manipulation type of things that speedrunner types love.

Thelypody commented 1 year ago

Okay, if that's the case then I will close this issue as the culprit and solution are already known. Thank you very much for quick response.