/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
- * Copyright (C) 2002 Xodnizel
+ * Copyright (C) 2005 CaH4e3
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
#include "mapinc.h"
-static DECLFW(Mapper235_write)
-{
- uint32 m;
- int z;
+static uint16 addrlatche;
- if(A&0x400)
- onemir(0);
+static void Sync(void)
+{
+ if(addrlatche&0x40)
+ {
+ setprg16(0x8000,addrlatche&7);
+ setprg16(0xC000,addrlatche&7);
+ }
else
- setmirror(((A>>13)&1)^1);
- m=A&0x1f;
+ setprg32(0x8000,(addrlatche>>1)&3);
+ setchr8((addrlatche>>3)&7);
+ setmirror(((addrlatche&0x80)>>7)^1);
+}
- z=(A>>8)&3;
+static DECLFW(BMCGK192Write)
+{
+ addrlatche=A;
+ Sync();
+}
- if(A&0x800)
- {
- setprg16r(0x10|z,0x8000,(m<<1)|((A>>12)&1));
- setprg16r(0x10|z,0xC000,(m<<1)|((A>>12)&1));
+static void BMCGK192Reset(void)
+{
+ setprg32(0x8000,0);
+}
- }
- else
- setprg32r(0x10|z,0x8000,m);
+static void BMCGK192Power(void)
+{
+ setprg32(0x8000,0);
+ SetReadHandler(0x8000,0xFFFF,CartBR);
+ SetWriteHandler(0x8000,0xffff,BMCGK192Write);
+}
+
+static void StateRestore(int version)
+{
+ Sync();
}
-void Mapper235_init(void)
+void Mapper58_Init(CartInfo *info)
{
- /* Fixme: Possible crashy bug if header is bad. */
- SetupCartPRGMapping(0x10,PRGptr[0],1024*1024,0);
- SetupCartPRGMapping(0x12,PRGptr[0]+1024*1024,1024,0);
- setprg32r(0x10,0x8000,0);
- SetReadHandler(0x8000,0xffff,CartBROB);
- SetWriteHandler(0x8000,0xffff,Mapper235_write);
+ info->Power=BMCGK192Power;
+ info->Reset=BMCGK192Reset;
+ GameStateRestore=StateRestore;
+ AddExState(&addrlatche, 2, 0, "ALATC");
}