lidnariq wrote:
Unfortunately, if this language is low enough level to describe ASIC mappers, now you have a problem even worse than bad headers: bad descriptions. If the language isn't low enough, it's almost useless, because the effort to provide the abstraction of MMC5-the-IC is not really different from the effort to implement mapper 5, and the effort to implement 005-00002-010 is not really different from the effort to implement mappers 36, 132, and 173. And that's ignoring things where there just isn't good reference information, like chips-on-board, which basically have to be reverse-engineered entirely as black boxes.
Hello all. I'm just starting out with the NES, but I've done some rather interesting things on the Atari 2600.
For mappers of a complexity that would fit in an low-to-mid-level CPLD chip like the XC9572XL (and that covers a *lot* of ground), I would think a relatively simple language could be sufficient while being easy to process efficiently in code that wouldn't need to care about most details of the underlying emulator.
If I were designing such a language, I'd probably use a virtual machine with 256 registers of 32 bits each, the first two of which would be initialized with CPU address/data bus contents, the next two of which would be PPU address/data, and the next ones some control signals like IRQ. The primary instructions would be:
- Set/clear bit A of register B based upon whether a register C, masked with bit pattern D, matches E, or else do nothing/do the opposite.
- Read A bits starting at bit B of register C, and copy/mask/or/bic/xor/add/multiply them with bits starting at bit D of register E.
- Take 1/2/4 bits starting at bit A of register B and do a 2/4/8-way branch
- Read memory at address given in register A (upper bits select a device; lower bits select an address within it) into register B
- Write memory at address given in register A (as above) with lower 8 bits of register B
Something with the complexity of the DPC chip used on the Atari 2600 Pitfall II cartridge would need a fair number of instructions, and wouldn't be processed as quickly as would be possible with purpose-written C code, but a if the byte-code engine were written in engine-agnostic fashion and the NES format included a mapper number which indicated that the necessary byte-code would be embedded in the NES file, any emulator that supports the byte-code format would be able to handle such cartridges, at least on a fast enough computer, without needing to be customized for that banking scheme.
I've designed banking schemes for the Atari 2600 and implemented them in hardware and emulators. Since some NES homebrew cartridges have CPLDs on them, it would seem like the potential benefits of having one-off banking schemes designed for particular games could be even more significant on the NES than the 2600, but only if there's an easy way to make the custom schemes usable in emulators.
Incidentally, adding a means of including a mapper description within an NES file could also be useful for developers who wish to allow people to freely share the game for use on emulation but require that people wanting to use actual systems buy cartridges. If the bytecode within a .NES file included all the features needed for a game, including a few that are *very rarely* used, along with many other features that would never get exercised at all, anyone wanting to fit a working mapper into an inexpensive CPLD would need to know what features were actually needed. A programmer who was so inclined could punish users of unauthorized cartridges by e.g. arranging things so that code to register damage on the final boss monster could only be activated as a consequence of the cartridge recognizing a particular sequence of memory accesses and doing a seemingly-oddball bank-switch to land in the "damage boss monster" code.