New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New NMK214 device: added implementation for NMK214 descrambling GFX device and hook it up to nmk16 driver #12039
Conversation
…evice and hook it up to nmk16 driver
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you really want decoding to happen on-the-fly, you can’t use gfxdecode_device
– its purpose is to cache decoded tiles, so it works by reading tile graphics en masse and storing the bitmaps in an easy-to-use form.
The code looks like it would have issues with soft reset (F3 by default). If the user resets the system, the already decoded graphics ROM content will be decoded again. This may be masked by the caching performed by the gfxdecode_device
, as tiles decoded before the system was reset won’t be decoded again.
Also, tiles aren’t invalidated after the NMK214 is configured, so any tiles that are decoded before that (e.g. if the user manages to pause the system immediately on start and bring up the tile viewer before the game initialises the NMK214) won’t be refreshed when.
Got it. Is there any other (feasible) alternative to 'gfxdecode_device' to use in decoding gfx? Apart from that, all other fixes/suggestions are included now in the PR |
@cuavas Is any further action needed on this PR from my side? |
I tidied up the code and pushed to your branch. It still isn’t going to play nicely with save states because the content of the memory regions won’t stay in sync with the state of the decoder (memory regions aren’t added to save states because they’re intended to be used with ROM which is static). The case were I’d anticipate this causing trouble is with Solving it properly, and allowing on-the-fly changes to the unscrambling, really requires I can think of a couple of relatively easy ways to work around it:
|
I patched it up using the second approach, and added the code to force tiles to be decoded after unscrambling. This will do until |
@cuavas Thanks. I will prepare another PR to include this descrambling process to all the games using it in the nmk16 driver.
|
Added implementation for NMK214 as a new device. It's used for descrambling GFX data on some games in the nmk16 driver.
The implementation was made based on the reverse engineering work of the chip at silicon level:
https://github.com/sergiopolog/GateArray-RE/tree/master/NMK/nmk-214
Results of the descrambling GFX process for both sprites and background tiles using this implementation match exactly with the ones from previous implementation made by @mamehaze (and Antiriad) back then.
In this case, all the internal configurations that could be selected to perform it are included, even if they are never used for any game, just for documentation purposes.
Real hardware performs the descrambling process on the fly for each word/byte fetch from GFX ROMs, but due how the drawgfx system is made on MAME, I couldn't find an option to integrate it and mimic the real hw behaviour.
I simply run the decoding of the entire GFX regions just when both devices are initialized at startup, (similar to what the previous implementation did on init handler).
If there is a way to do this on real GFX fetches from 'sprites' and 'bgtiles' regions, please, let me know.
By now, the descrambling process is only hooked up for sabotenb (and clones) set.
On a later PR, I plan to apply it to the rest of games using it on nmk16 driver and split the current "tdragon_prot_state" class into two different classes: One for NMK111 and NMK113 protection (tdragon and hachamf) and another one for NMK214-215 protection, as they are completely different processes, even if they use the same MCU model (TLCS-90)