Valkyrie No Densetsu hack update (with a vengeance)

Not so long ago Hokuto left a comment on the Namco System 2 Keycus Hacks page regarding a problem with the hack for Valkyrie No Densetsu : the keycus protection chip was also used as a random number generator in the game, leading to strange behaviour alteration …

One of the baddies (Arijigoku aka Antlion) is supposed to throw round projectiles around him, in a random pattern, as you can see in the following Mame capture :

Correct random pattern in Mame with keycus emulation

My hack consisted in removing all keycus memory area calls and replacing them with the “no operation” instruction. It works well when the chip is just used as a protection (check Namco System 2 keycus hacks for more info), but it completely defeats its role as a random number generator. With my hack, the projectiles are thrown in straight lines, as you can see below :

Keycus protection removed without random number generation

In order to restore correct throw behaviour, I created a pseudo random number generation routine in 68000 assembly that I added to the program rom, and replaced previous keycus calls used to get the numbers by a call to this routine.

I had to tweak the code a few times to achieve a good enough result (ie fast and with no visible repeat pattern) as it’s not possible to have a real random number generator. It involved intensive testing in Mame as there’s no savestate available for this game, meaning that I had to speed run the first part of the game to get to the point where the problem appears at every code update …

As you can see below, it works quite well 🙂 (sorry for the animated gif size)

Random throw behaviour

You can grab the updated files in the Namco System 2 Keycus Hacks page.