Code: Select all
PRG-ROM: 512 kB (hovewer A19 is wired to the EPROM)
CHR-RAM: 8 kB
[mvPP .P..] 74*174: $8000-$bfff
|||| |
||++--+--- outer PRG (high to low: D0, D5, D4)
|+-------- mode (0=16kB, 1=32kB)
+--------- mirroring (0=V, 1=H)
[.... uppp] 74*161: $8000-$9fff and $c000-$dfff
||||
|+++- inner PRG
+---- mode (0=UNROM,1=NROM)
yes, it overlaps partially with previous reg, so when wring at $8000-$9fff, botch registers are updated
Power up: both registers set to 0
Reset: no change
PRG Modes:
uv $8000 $bfff
----------------
00 PPPppp PPP111
01 PPPpp0 PPP111
10 PPPppp PPPppp
11 PPPpp0 PPPpp1
------------------------------------
#include "mapinc.h"
static uint8 reg174, reg161;
//shifts bit at position `from` to position `to` in expression
#define shi(exp, from, to) ((((exp) >> (from)) & 1) << (to))
static SFORMAT StateRegs[] =
{
{ 0 }
};
static void Sync(void) {
int uv = shi(reg161, 3, 1) | shi(reg174, 6, 0);
int PPP = shi(reg174, 0, 2) | shi(reg174, 5, 1) | shi(reg174, 4, 0);
int ppp = reg161 & 0x7;
switch (uv) {
case 0: setprg16(0x8000, (PPP << 3) | ppp); setprg16(0xc000, (PPP << 3) | 7); break;
case 1: setprg16(0x8000, ((PPP << 3) | ppp) & (~1)); setprg16(0xc000, (PPP << 3) | 7); break;
case 2: setprg16(0x8000, (PPP << 3) | ppp); setprg16(0xc000, (PPP << 3) | ppp); break;
case 3: setprg32(0x8000, ((PPP << 3) | ppp) >> 1); break;
}
setmirror(((reg174 >> 7) & 1) == 0 ? MI_V : MI_H);
}
static DECLFW(M281Write) {
if ((A >= 0x8000) && (A <= 0xBFFF)) {
reg174 = V;
}
if (((A >= 0x8000) && (A <= 0x9FFF)) || ((A >= 0xC000) && (A <= 0xFFFF))) {
reg161 = V;
}
Sync();
}
static void M281Power(void) {
setchr8(0);
reg174 = reg161 = 0;
SetWriteHandler(0x8000, 0xffff, M281Write);
SetReadHandler(0x8000, 0xFFFF, CartBR);
Sync();
}
static void M281Reset(void) {
Sync();
}
static void StateRestore(int version) {
Sync();
}
void Mapper281_Init(CartInfo *info) {
info->Power = M281Power;
info->Reset = M281Reset;
GameStateRestore = StateRestore;
AddExState(&StateRegs, ~0, 0, 0);
}
first pulic:
http://nestopia.gamemw.com/index.php/20 ... 5-01-16-54
ROM: