I couldn't find anything that looked wrong with the rendering code, so I tried switching from drawing each tile as a pair of triangles to a single PVR sprite and switching to using the punch-through list instead of the transparent list, and the changes reduced GPU load enough to hit 60 FPS.
#Ristar rom hacks Ps4#
When PS4 was having slowdown, the PVR was taking about ~20 ms to render the frame. This seemed like an issue with the PVR rendering code, like something invalid up was being sent to the PVR and it was choking on it. Eventually, I noticed in one place the slowdown would occur only when the press-button-for-more-text arrow was not visible (?!). It didn't seem like the SH4 was overloaded, but it ran at half speed. Phantasy Star 4 had slowdown in certain areas.
#Ristar rom hacks code#
The correct thing to do would be to find where in the Z80 code the error is, but these hacks should work for now. There's likely an error in the timing emulation somewhere. I noticed this hack would cause Streets of Rage 2 to freeze on certain music tracks, like Ristar did, so the hack is only enabled on Sonic SMPS Z80 games.Īll these problems probably originate with the Z80 emulation. I found a workaround when fixing the Z80 table problem by changing it so that the Z80 does not lose time when the 68000 accesses Z80 RAM, the music timing was fixed. It was like the Z80 was slightly drunk, and had trouble keeping to the beat. It's enough for Ristar to be playable, but there are occasional incorrect or missed notes and sound effects.Īnother issue is that the Sonic SMPS Z80 games had music tempo issues. For Ristar, I added a hack that causes 68K reads from that byte to always return 0.
#Ristar rom hacks free#
I guess a nonzero byte indicates that the Z80 is busy, so the 68K was waiitng for the Z80 to free up, but the Z80 wasn't clearing it. If that byte was nonzero, it would resume the Z80, wait a bit, then try again. It looks like the 68000 was stopping the Z80 and reading a byte from Z80 RAM. Ristar (using a modified SMPS 68K driver) would freeze during the Sega logo. So when it was reading past the end of the table, it was reading from Genesis main RAM and using that as timing information. (Also, I noticed that main RAM is allocated after the cycle table.
#Ristar rom hacks Pc#
There's still the question of why PC Gens was able to get away with the size of the table it had, and Gens4All couldn't.
I increased the size of Z80_M68K_Cycle_Tab, and, as an extra measure, modified the table look up to wrap around instead of reading past the end of the array, which should prevent these freezes. I figured out the large cycle time was coming from reading past the end of a lookup table, Z80_M68K_Cycle_Tab, used when calculating how many Z80 cycles are lost when the Z80 gets disabled by the 68000 (so that the 68000 can access Z80 RAM). The Z80 was set to run for over a billion of cycles in once shot, when it shouldn't run for more than a couple thousand before Gens gives the 68000 a chance to run. I modified the watchdog to print information about the state of the 68000 and Z80. I already had added a watchdog thread to return to dcload if the main thread seemed to freeze. This was especially common with the Sonic SMPS Z80 games (Sonic 2, 3, &K, 3D Blast) but I had it happen to me once in Vectorman (GEMS). In Thunder Force 2, during the "Good Luck" screen when starting the game, there's heavy slow down for some reason. (Running the profiler added to Gens4All took more time than emulating the Z80) I was targeting 22khz sound at 60 FPS without frame skip, but with some games you can almost do 44khz.
After disabling the Gens4All profiler, the speed was actually better than before.
With the overhead of Z80 emulation, games had more trouble staying at 60 FPS. I was expecting to have to do more than that, but I'm not complaining. Games that used the Z80 for sound now had working sound. I replaced Gens4All Z80 core with Neo4All's and changed the options back the Gens4All's settings then tried out the result. I noticed right away that some compile options were different between them. I decided to try to look through the differences between Gens4All and Neo4All's Z80 code to see if there was anything that might help. I tried using Neo4All's Z80 core in Gens4All, but it didn't work. I recently went back to try to get it working again. I wasn't able to get Z80 emulation to work, so most games had problems with sound. Earlier I posted a version of Gens4All with PVR accelerated VDP emulation.