User:Zzo38/Mapper 768: Difference between revisions
No edit summary |
No edit summary |
||
Line 12: | Line 12: | ||
= Submapper 0 = | = Submapper 0 = | ||
The extra data stores the code for a virtual machine, to control the mapper. The commands are sixteen bits in small endian format, and are split into subroutine blocks. At the beginning of each block tells how many sixteen-bit commands are in this subroutine block. | |||
The first block is always the initialization block. | |||
Anything other than what is written in the codes acts like NROM (iNES mapper 0). | |||
There is sixteen registers, with sixteen bits each. R0 and R1 are local to a subroutine call, and the R2 to R15 are global registers (all general purpose). There is also two more local registers, called W (working register) and W' (shadow working register). | |||
Subroutine numbers are eight bits long. Each subroutine takes two parameters which is the initial assignment of R0 and R1 registers, and returns a sixteen bit number. | |||
== Commands == | |||
* <tt>0000 0000 xxxx yyyy</tt> = Call a subroutine indicated in the low eight bits of Rx, with this call's R0 and R1 as its parameters, and store the result in Ry (leave Ry alone if the result is open bus or CIRAM). | |||
* <tt>0000 0001 0000 xxxx</tt> = Copy W to Rx. | |||
* <tt>0000 0001 0001 xxxx</tt> = Copy Rx to W. | |||
* <tt>0000 0001 0010 xxxx</tt> = Add W to Rx. | |||
* <tt>0000 0001 0011 xxxx</tt> = Add Rx to W. | |||
* <tt>0000 0001 0100 xxxx</tt> = Subtract W from Rx. | |||
* <tt>0000 0001 0101 xxxx</tt> = Subtract Rx from W. | |||
* <tt>0000 0001 0110 xxxx</tt> = Bitwise AND W to Rx. | |||
* <tt>0000 0001 0111 xxxx</tt> = Bitwise AND Rx to W. | |||
* <tt>0000 0001 1000 xxxx</tt> = Bitwise OR W to Rx. | |||
* <tt>0000 0001 1001 xxxx</tt> = Bitwise OR Rx to W. | |||
* <tt>0000 0001 1010 xxxx</tt> = Bitwise XOR W to Rx. | |||
* <tt>0000 0001 1011 xxxx</tt> = Bitwise XOR Rx to W. | |||
* <tt>0000 0001 1100 xxxx</tt> = Bitwise NAND W to Rx. | |||
* <tt>0000 0001 1101 xxxx</tt> = Bitwise NAND Rx to W. | |||
* <tt>0000 0001 1110 xxxx</tt> = Copy NOT W to Rx. | |||
* <tt>0000 0001 1111 xxxx</tt> = Copy NOT Rx to W. | |||
* <tt>0000 0010 0000 xxxx</tt> = Return the value in Rx from this subroutine. | |||
* <tt>0000 0010 0001 0000</tt> = Return open bus from this subroutine. | |||
* <tt>0000 0010 0001 0010</tt> = Return CIRAM bank 0 from this subroutine. | |||
* <tt>0000 0010 0001 0011</tt> = Return CIRAM bank 1 from this subroutine. | |||
* <tt>0000 0010 0001 1xxx</tt> = Return the literal value x (all other bits zero) from this subroutine. | |||
* <tt>0000 0011 0000 0000</tt> = Swap W with W'. | |||
* <tt>0000 0011 0001 xxxx</tt> = Store an immediate value into Rx. | |||
* <tt>0000 0011 0011 xxxx</tt> = Add an immediate value to Rx. | |||
* <tt>0000 0011 0111 xxxx</tt> = Bitwise AND an immediate value to Rx. | |||
* <tt>0000 0011 1001 xxxx</tt> = Bitwise OR an immediate value to Rx. | |||
* <tt>0000 0011 1011 xxxx</tt> = Bitwise XOR an immediate value to Rx. | |||
* <tt>0000 0011 1101 xxxx</tt> = Bitwise NAND an immediate value to Rx. | |||
* <tt>1000 xxxx yyyy yyyy</tt> = Call subroutine y with this subroutine's W and W' as parameters, and store the result in Rx (leave Rx alone if the result is open bus or CIRAM). | |||
(TODO) | |||
== NSF Interface == | |||
(TODO) | |||
= Submapper 1 = | = Submapper 1 = |
Revision as of 01:19, 17 March 2013
I am reserving mapper 768 for my own use.
In all cases, the NES 2.0 file is arranged like (some parts may be omitted, depending on the header):
- Header
- Trainer
- PRG ROM
- CHR ROM
- INST-ROM
- PROM
- 128-byte null-terminated ASCII title
- Extra data for mapper 768 (depending on submapper number)
Submapper 0
The extra data stores the code for a virtual machine, to control the mapper. The commands are sixteen bits in small endian format, and are split into subroutine blocks. At the beginning of each block tells how many sixteen-bit commands are in this subroutine block.
The first block is always the initialization block.
Anything other than what is written in the codes acts like NROM (iNES mapper 0).
There is sixteen registers, with sixteen bits each. R0 and R1 are local to a subroutine call, and the R2 to R15 are global registers (all general purpose). There is also two more local registers, called W (working register) and W' (shadow working register).
Subroutine numbers are eight bits long. Each subroutine takes two parameters which is the initial assignment of R0 and R1 registers, and returns a sixteen bit number.
Commands
- 0000 0000 xxxx yyyy = Call a subroutine indicated in the low eight bits of Rx, with this call's R0 and R1 as its parameters, and store the result in Ry (leave Ry alone if the result is open bus or CIRAM).
- 0000 0001 0000 xxxx = Copy W to Rx.
- 0000 0001 0001 xxxx = Copy Rx to W.
- 0000 0001 0010 xxxx = Add W to Rx.
- 0000 0001 0011 xxxx = Add Rx to W.
- 0000 0001 0100 xxxx = Subtract W from Rx.
- 0000 0001 0101 xxxx = Subtract Rx from W.
- 0000 0001 0110 xxxx = Bitwise AND W to Rx.
- 0000 0001 0111 xxxx = Bitwise AND Rx to W.
- 0000 0001 1000 xxxx = Bitwise OR W to Rx.
- 0000 0001 1001 xxxx = Bitwise OR Rx to W.
- 0000 0001 1010 xxxx = Bitwise XOR W to Rx.
- 0000 0001 1011 xxxx = Bitwise XOR Rx to W.
- 0000 0001 1100 xxxx = Bitwise NAND W to Rx.
- 0000 0001 1101 xxxx = Bitwise NAND Rx to W.
- 0000 0001 1110 xxxx = Copy NOT W to Rx.
- 0000 0001 1111 xxxx = Copy NOT Rx to W.
- 0000 0010 0000 xxxx = Return the value in Rx from this subroutine.
- 0000 0010 0001 0000 = Return open bus from this subroutine.
- 0000 0010 0001 0010 = Return CIRAM bank 0 from this subroutine.
- 0000 0010 0001 0011 = Return CIRAM bank 1 from this subroutine.
- 0000 0010 0001 1xxx = Return the literal value x (all other bits zero) from this subroutine.
- 0000 0011 0000 0000 = Swap W with W'.
- 0000 0011 0001 xxxx = Store an immediate value into Rx.
- 0000 0011 0011 xxxx = Add an immediate value to Rx.
- 0000 0011 0111 xxxx = Bitwise AND an immediate value to Rx.
- 0000 0011 1001 xxxx = Bitwise OR an immediate value to Rx.
- 0000 0011 1011 xxxx = Bitwise XOR an immediate value to Rx.
- 0000 0011 1101 xxxx = Bitwise NAND an immediate value to Rx.
- 1000 xxxx yyyy yyyy = Call subroutine y with this subroutine's W and W' as parameters, and store the result in Rx (leave Rx alone if the result is open bus or CIRAM).
(TODO)
NSF Interface
(TODO)
Submapper 1
Extra data is not used. There is expected to be a file with .nes.v extension (otherwise having the same name), which contains a Verilog code for implementing the mapper.
The first sixty I/O ports of the main module of the Verilog code must correspond to the pins 01 to 60 of the 60-pin Famicom cartridge, in that order. This is followed by the pins for the PRG ROM, CHR ROM, non-battery PRG RAM, non-battery CHR RAM, battery PRG RAM, and battery CHR RAM.
The ROM/RAM pins are only for the ROM/RAM which are existing, and is as follows:
- Chip enable (low to enable)
- Write enable (low to enable; not exist for ROM)
- Address pins (the exact number of pins needed for the ROM/RAM of the size specified in the NES 2.0 header)
- Data pins (always eight)
The commands with $ at front might not be implemented, but should be safely ignored if not implemented. However, if there is a trainer ROM, there will be an additional command $trainer to access 8-bit numbers given the 9-bit address, and $battery_init which tell you if you need to initialize the battery RAM.
Analog commands may be used with the audio signals.