Final Fight AE CPS2 Sprite Based Layers!
As discussed in our previous posts, the lack of palette masking on CPS2 is one of the trickier hurdles of porting a CPS1 game to CPS2, and one where others have failed. When we started this project we determined that we would use additional sprites to make up for the missing "layer" created by palette masking. Since it's possible for the CPS2 to display nearly ten times the sprite count of the CPS1, this seemed like an appropriate solution. We realized that this would require a significant amount of new tile data to be created, either by copying the tiles data and manually erasing the needed transparent areas, or by somehow automating this process.
After pondering the available options, we decided to take the automation route, potentially saving us countless hours on this project. Furthermore, having such an automated process would be invaluable for future CPS1 to CPS2 ports.
Looking through MAME's source code it became apparent that having MAME render the "palette mask layer" to its own bitmap was trivial. Working backward from a non-transparent pixel, the palette masked pixels could be determined and extracted. This method requires scanning a 1024 x 1024 image every frame, checking for tile ids, and comparing them to a list of handled IDs. We are happy to announce this method not only works, but allows us to run the algorithm at nearly 10x speed while capturing tile data. That's 629,145,600 pixels analyzed per second!
After using this new tool to extract the tile data, it was now up to Gnawtor to create appropriate tile layouts and insert the new layers into the game. Using numerous tricks he was easily able to recreate the tile layout data, but having it play nicely within the restrictions of Final Fight's systems proved to be an interesting problem to solve. Sprites that are used as layers should obey the laws of objects within the Final Fight entity system. They need to be spawned by the level script or from other entities, draw their sprites to the render region using one of the render methods, and remove themselves from the active entity pool when they are sufficiently off screen. Using the Final Fight level script editor that he wrote, his knowledge of the various entity handlers, demo sequences and other nuances of the Final Fight code base, Gnawtor was able to add these new layers to the game in a elegant and non-intrusive manner.
Notice the trash can on the entrance to the slums, and Damnd's head when heading down to the subway. In the original CPS1 version of the game, the palette masked parts of the background would draw on top of all sprites indiscriminately, noticeably hiding sprites that ought to be rendered in the foreground. However, the new sprite overlays obey the object layering system, resulting in more impressive layering results than what was possible on the CPS1.
The slums level is by far the most difficult area for replicating the palette masking functionality, especially due to the way the game handles flickering lights in the basement. It should be smooth sailing to implement the rest of the overlays from here.
As a reminder, the alpha test is coming in a few short weeks, and as of this post there are still 8/10 spots open. Reserve your spot to play the first new CPS2 game in 20 years today, and don't forget this tier also gets you the boss tier benefits and access to behind the scenes developments happening nearly daily!
Comments (2)
Looking great guys. Thank you for adding new life into the daddy of all beat em ups
Really looking forward to this. Thanks for the hard work!
