Compare commits

..

No commits in common. "82e0275b5ea386710eeb82996921821179432591" and "c7f32874ae8f451853458a8794777529dfa4a8b9" have entirely different histories.

6 changed files with 471 additions and 656 deletions

View File

@ -11,229 +11,229 @@ using Codice.CM.Client.Differences;
namespace VirtualNes.Core namespace VirtualNes.Core
{ {
public class Mapper163 : Mapper public class Mapper163 : Mapper
{ {
//BYTE strobe; //BYTE strobe;
//BYTE security; //BYTE security;
//BYTE trigger; //BYTE trigger;
//BYTE rom_type; //BYTE rom_type;
//BYTE reg[2];
BYTE laststrobe, trigger;
BYTE[] reg = new byte[8];
public Mapper163(NES parent) : base(parent)
{
/*
reg[1] = 0xFF;
strobe = 1;
security = trigger = reg[0] = 0x00;
rom_type = 0;
SetPROM_32K_Bank(15);
DWORD crc = nes.rom.GetPROM_CRC();
if( crc == 0xb6a10d5d ) { // Hu Lu Jin Gang (NJ039) (Ch) [dump]
SetPROM_32K_Bank(0);
}
if( crc == 0xf52468e7 ) { // San Guo Wu Shuang - Meng Jiang Zhuan (NJ047) (Ch) [dump]
rom_type = 1;
}
*/
//BYTE reg[2]; MemoryUtility.ZEROMEMORY(reg, reg.Length);
BYTE[] reg = new byte[3]; laststrobe = 1;
BYTE strobe, trigger; SetPROM_32K_Bank((reg[0] << 4) | (reg[1] & 0xF));
ushort security; //SetPROM_32K_Bank(0);
BYTE rom_type; SetCRAM_8K_Bank(0);
}
INT www, index;
public Mapper163(NES parent) : base(parent) //BYTE Mapper163::ReadLow(WORD A)
{ public override byte ReadLow(ushort A)
} {
/*
static Int32[] index_adjust = new Int32[]{ -1, -1, -1, -1, 2, 4, 6, 8 }; if((addr>=0x5000 && addr<0x6000))
static Int16[] step_table = new Int16[] { {
7,8,9,10,11,12,13,14,16,17,19,21,23,25,28,31,34,37,41,45,50,55, switch (addr & 0x7700)
60,66,73,80,88,97,107,118,130,143,157,173,190,209,230,253,279, {
307,337,371,408,449,494,544,598,658,724,796,876,963,1060, case 0x5100:
1166,1282,1411,1552,1707,1878,2066,2272,2499,2749,3024,3327, return security;
3660,4026,4428,4871,5358,5894,6484,7132,7845,8630,9493,10442, break;
11487,12635,13899,15289,16818,18500,20350,22385,24623,27086,29794,32767 case 0x5500:
}; if(trigger)
return security;
BYTE adpcm_decoder(BYTE data) else
{ return 0;
int sb, delta; break;
int cur_sample = 0; }
if ((data & 8) != 0) sb = 1; else sb = 0; return 4;
data &= 7; }
delta = (step_table[index] * data) / 4 + step_table[index] / 8; else if( addr>=0x6000 ) {
if (sb == 1) delta = -delta; return CPU_MEM_BANK[addr>>13][addr&0x1FFF];
cur_sample += delta; }
if (cur_sample > 32767) cur_sample = 32767; return Mapper::ReadLow( addr );
else if (cur_sample < -32768) cur_sample = -32768; */
else cur_sample = cur_sample; if ((A < 0x6000) && (A >= 0x5000))
index += index_adjust[data]; {
if (index < 0) index = 0; switch (A & 0x7700)
if (index > 88) index = 88; {
return (byte)(cur_sample & 0xff); case 0x5100: return (byte)(reg[2] | reg[0] | reg[1] | reg[3] ^ 0xff); break;
} case 0x5500:
if (trigger != 0)
//void Mapper163::Reset() return (byte)(reg[2] | reg[1]); // Lei Dian Huang Bi Ka Qiu Chuan Shuo (NJ046) may broke other games
public override void Reset() else
{ return 0;
}
index = 0; return 4;
}
reg[1] = 0xFF; else
strobe = 1; return base.ReadLow(A);
security = trigger = reg[0] = 0x00; }
rom_type = 0;
SetPROM_32K_Bank(15); //void Mapper163::WriteLow(WORD A, BYTE V)
public override void WriteLow(ushort A, byte V)
// jedi_table_init(); {
/*
uint crc = nes.rom.GetPROM_CRC(); if((addr>=0x4020 && addr<0x6000))
if (crc == 0xb6a10d5d) {
{ // Hu Lu Jin Gang (NJ039) (Ch) [dump] DEBUGOUT("W %.4X %.2X\n",addr,data);
SetPROM_32K_Bank(0); if(addr==0x5101){
} if(strobe && !data){
if (crc == 0xf52468e7 // San Guo Wu Shuang - Meng Jiang Zhuan (NJ047) (Ch) [dump] trigger ^= 1;
|| crc == 0x696D98E3) // trigger ^= 0xFF;
{ // San Guo Zhi Lv Bu Zhuan (NJ040) (Ch) [dump] }
rom_type = 1; strobe = data;
} }else if(addr==0x5100 && data==6){
if (crc == 0xEFF96E8A) SetPROM_32K_Bank(3);
{ // Mo Shou Shi Jie E Mo Lie Ren (NJ097) (Ch) [dump] }
rom_type = 2; else{
} switch (addr & 0x7300)
{
www = 0; case 0x5000:
} reg[1]=data;
SetPROM_32K_Bank( (reg[1] & 0xF) | (reg[0] << 4) );
///BYTE Mapper163::ReadLow(WORD addr) if(!(reg[1]&0x80)&&(nes.ppu.GetScanlineNo()<128))
public override byte ReadLow(ushort addr) SetCRAM_8K_Bank(0);
{ if(rom_type==1) SetCRAM_8K_Bank(0);
// DEBUGOUT( "ReadLow - addr= %04x\n", addr ); break;
case 0x5200:
if ((addr >= 0x5000 && addr < 0x6000)) reg[0]=data;
{ SetPROM_32K_Bank( (reg[1] & 0xF) | (reg[0] << 4) );
switch (addr & 0x7700) break;
{ case 0x5300:
case 0x5100: security=data;
return (byte)security; break;
break; }
case 0x5500: }
if (trigger!=0) }
return (byte)security; else if( addr>=0x6000 ) {
else CPU_MEM_BANK[addr>>13][addr&0x1FFF] = data;
return 0; }
break; */
} if ((A < 0x6000) && (A >= 0x5000))
return 4; {
} if (A == 0x5300)
else if (addr >= 0x6000) {
{ A = (ushort)(A + 1 - 1);
return CPU_MEM_BANK[addr >> 13][addr & 0x1FFF]; }
}
return base.ReadLow(addr); if (A == 0x5101)
} {
if (laststrobe != 0 && V == 0)
//void Mapper163::WriteLow(WORD addr, BYTE data) {
public override void WriteLow(ushort addr, byte data) trigger ^= 1;
{ }
// if(addr==0x5200) DEBUGOUT( "WriteLow - addr= %04x ; dat= %03x\n", addr, data ); laststrobe = V;
}
if ((addr >= 0x4020 && addr < 0x6000)) else if (A == 0x5100 && V == 6) //damn thoose protected games
{ SetPROM_32K_Bank(3);
if (addr == 0x5101) else
{ {
if (strobe !=0 && data == 0) switch (A & 0x7300)
{ {
trigger ^= 1; case 0x5200: reg[0] = V; SetPROM_32K_Bank((reg[0] << 4) | reg[1] & 0xF); SetCRAM_8K_Bank(0); break;
// trigger ^= 0xFF; case 0x5000: reg[1] = V; SetPROM_32K_Bank((reg[0] << 4) | reg[1] & 0xF); SetCRAM_8K_Bank(0); if ((reg[1] & 0x80) == 0 && (nes.GetScanline() < 128)) SetCRAM_8K_Bank(0); break;
} case 0x5300: reg[2] = V; break;
strobe = data; case 0x5100: reg[3] = V; SetPROM_32K_Bank((reg[0] << 4) | reg[1] & 0xF); SetCRAM_8K_Bank(0); break;
} }
else if (addr == 0x5100 && data == 6) }
{ }
SetPROM_32K_Bank(3); //071
} else if ((A & 0xFF00) == 0x4800)
else {
{ //512KרÓÃ
switch (addr & 0x7300) if (PROM_8K_SIZE == 64)
{ {
case 0x5000: reg[A & 3] = V;
reg[1] = data; if (A == 0x4802)
SetPROM_32K_Bank((reg[1] & 0xF) | (reg[0] << 4)); SetPROM_32K_Bank(((reg[1] >> 1) & 3) | (reg[2] << 2));
if ((reg[1] & 0x80) == 0 && (nes.ppu.GetScanlineNo() < 128)) }
SetCRAM_8K_Bank(0); }
if (rom_type == 1) SetCRAM_8K_Bank(0); else
break; base.WriteLow(A, V);
case 0x5100: }
reg[2] = data;
// nes.apu.Write(0x4011,(decode(reg[0]&0xf)<<3)); //void Mapper163::HSync(int scanline)
break; public override void HSync(int scanline)
case 0x5200: {
reg[0] = data; //sline = scanline;
SetPROM_32K_Bank((reg[1] & 0xF) | (reg[0] << 4)); /*
break; if( (reg[1]&0x80) && nes.ppu.IsDispON() ) {
case 0x5300: if(scanline==127){
security = data; SetCRAM_4K_Bank(0, 1);
break; SetCRAM_4K_Bank(4, 1);
} }
} if (rom_type==1){
} if(scanline<127){
else if (addr >= 0x6000) SetCRAM_4K_Bank(0, 0);
{ SetCRAM_4K_Bank(4, 0);
CPU_MEM_BANK[addr >> 13][addr & 0x1FFF] = data; }
if ((addr >= 0x7900 && addr <= 0x79FF)) }else{
{ if(scanline==239){
// WAVRAM[addr&0xFF] = data; SetCRAM_4K_Bank(0, 0);
// if(addr==0x79FF){ SetCRAM_4K_Bank(4, 0);
// memcpy( YWRAM+(www*256), WAVRAM, 256); }
// www++; }
// } }
// nes.apu.Write(0x4011,(adpcm_decoder(data))); */
nes.apu.Write(0x4011, data); if ((reg[1] & 0x80) != 0)
} {
} if (scanline == 239)
} {
SetCRAM_4K_Bank(0, 0);
//void Mapper163::Write(WORD addr, BYTE data) SetCRAM_4K_Bank(4, 0);
public override void Write(ushort addr, byte data) }
{ else if (scanline == 127)
// DEBUGOUT( "Write - addr= %04x ; dat= %03x\n", addr, data ); {
} SetCRAM_4K_Bank(0, 1);
SetCRAM_4K_Bank(4, 1);
//void Mapper163::HSync(int scanline) }
public override void HSync(int scanline) }
{ }
if ((reg[1] & 0x80) !=0 && nes.ppu.IsDispON())
{ //void Mapper163::SaveState(LPBYTE p)
if (scanline == 127) public override void SaveState(byte[] p)
{ {
SetCRAM_4K_Bank(0, 1); //p[0] = reg[0];
SetCRAM_4K_Bank(4, 1); //p[1] = reg[1];
} for (byte i = 0; i < 8; i++)
if (rom_type == 1) p[i] = reg[i];
{ p[8] = laststrobe;
if (scanline < 127) p[9] = trigger;
{ }
SetCRAM_4K_Bank(0, 0);
SetCRAM_4K_Bank(4, 0); //void Mapper163::LoadState(LPBYTE p)
} public override void LoadState(byte[] p)
} {
else
{ //reg[0] = p[0];
if (scanline == 239) //reg[1] = p[1];
{ for (byte i = 0; i < 8; i++)
SetCRAM_4K_Bank(0, 0); reg[i] = p[i];
SetCRAM_4K_Bank(4, 0); laststrobe = p[8];
if (rom_type == 2) SetCRAM_4K_Bank(4, 1); trigger = p[9];
} }
}
} public override void Reset()
} {
}
///void Mapper163::PPU_Latch(WORD addr)
//{ }
// if (DirectInput.m_Sw[DIK_PAUSE])
// {
// nes.Dump_YWRAM();
// }
//}
//void Mapper163::SaveState(LPBYTE p)
public override void SaveState(byte[] p)
{
p[0] = reg[0];
p[1] = reg[1];
}
//void Mapper163::LoadState(LPBYTE p)
public override void LoadState(byte[] p)
{
reg[0] = p[0];
reg[1] = p[1];
}
}
} }

View File

@ -18,51 +18,51 @@ namespace VirtualNes.Core
} }
public override void Reset() public override void Reset()
{ {
SetPROM_16K_Bank(4, 0); SetPROM_16K_Bank(4, 0);
SetPROM_16K_Bank(6, 0); SetPROM_16K_Bank(6, 0);
reg_dat = 0; reg_dat = 0;
if (VROM_1K_SIZE != 0) if (VROM_1K_SIZE != 0)
{ {
SetVROM_8K_Bank(0); SetVROM_8K_Bank(0);
} }
} }
//BYTE Mapper175::Read(WORD addr) //void Mapper175::Read(WORD addr, BYTE data)
public override void Read(ushort addr, byte data) public override void Read(ushort addr, byte data)
{ {
if (addr == 0xFFFC) if (addr == 0xFFFC)
{ {
SetPROM_16K_Bank(4, reg_dat & 0x0F); SetPROM_16K_Bank(4, reg_dat & 0x0F);
SetPROM_8K_Bank(6, (reg_dat & 0x0F) * 2); SetPROM_8K_Bank(6, (reg_dat & 0x0F) * 2);
} }
} }
//void Mapper175::Write(WORD addr, BYTE data) //void Mapper175::Write(WORD addr, BYTE data)
public override void Write(ushort addr, byte data) public override void Write(ushort addr, byte data)
{ {
switch (addr) switch (addr)
{ {
case 0x8000: case 0x8000:
if ((data & 0x04)!=0) if ((data & 0x04) != 0)
{ {
SetVRAM_Mirror(VRAM_HMIRROR); SetVRAM_Mirror(VRAM_HMIRROR);
} }
else else
{ {
SetVRAM_Mirror(VRAM_VMIRROR); SetVRAM_Mirror(VRAM_VMIRROR);
} }
break; break;
case 0xA000: case 0xA000:
reg_dat = data; reg_dat = data;
SetPROM_8K_Bank(7, (reg_dat & 0x0F) * 2 + 1); SetPROM_8K_Bank(7, (reg_dat & 0x0F) * 2 + 1);
SetVROM_8K_Bank(reg_dat & 0x0F); SetVROM_8K_Bank(reg_dat & 0x0F);
break; break;
} }
} }
public override bool IsStateSave() public override bool IsStateSave()
{ {
return true; return true;
} }

View File

@ -1,233 +1,53 @@
////////////////////////////////////////////////////////////////////////// using static VirtualNes.MMU;
// Mapper176 ShuQiYu / HengGe / WaiXing //
//////////////////////////////////////////////////////////////////////////
using static VirtualNes.MMU;
using static VirtualNes.Core.CPU; using static VirtualNes.Core.CPU;
using INT = System.Int32; using INT = System.Int32;
using BYTE = System.Byte; using BYTE = System.Byte;
using System; using System;
using Codice.CM.Client.Differences;
using System.Runtime.ConstrainedExecution;
namespace VirtualNes.Core namespace VirtualNes.Core
{ {
public class Mapper176 : Mapper public class Mapper176 : Mapper
{ {
BYTE reg5000; BYTE prg, chr;
BYTE reg5001;
BYTE reg5010;
BYTE reg5011;
BYTE reg5013;
BYTE reg5FF1;
BYTE reg5FF2;
BYTE we_sram;
BYTE SBW, sp_rom;
public Mapper176(NES parent) : base(parent) public Mapper176(NES parent) : base(parent)
{ {
} }
public override void Reset() public override void Reset()
{ {
if (PROM_16K_SIZE > 32) //prg = ~0;
{ prg = unchecked((byte)(~0));
SetPROM_32K_Bank(0, 1, (PROM_8K_SIZE / 2) - 2, (PROM_8K_SIZE / 2) - 1); //For 1M byte Cartridge chr = 0;
} Sync();
else
{
SetPROM_32K_Bank(0, 1, PROM_8K_SIZE - 2, PROM_8K_SIZE - 1);
}
// SetPROM_32K_Bank( PROM_8K_SIZE-4, PROM_8K_SIZE-3, PROM_8K_SIZE-2, PROM_8K_SIZE-1 );
if (VROM_1K_SIZE!=0) SetVROM_8K_Bank(0);
reg5000 = 0;
reg5001 = 0;
reg5010 = 0;
reg5011 = 0;
reg5013 = 0;
reg5FF1 = 0;
reg5FF2 = 0;
we_sram = 0;
SBW = 0;
sp_rom = 0;
uint crc = nes.rom.GetPROM_CRC();
if (crc == 0x095D8678 //[ES-0122] Shuang Yue Zhuan (C)
|| crc == 0xD5F7AAEF)
{ //[ES-XXXX] Shen Feng Jian (C)
sp_rom = 1;
nes.SetSAVERAM_SIZE(32 * 1024);
}
/*
crc == 0x416C07A1 //[ES-1006] Meng Huan Zhi Xing IV (C) & WXN-梦幻之星 √
crc == 0x94782FBD //[ES-1057] San Guo Zhi - Xiong Ba Tian Xia (C)
crc == 0xF9863ADF //[ES-1066] Xi Chu Ba Wang (C)
crc == 0xB511C04B //[ES-1071] San Xia Wu Yi (C)
crc == 0x1923A8C5 //[ES-1087] Shui Hu Shen Shou (C) & WXN-水浒神兽(fix) √
crc == 0x095D8678 //[ES-0122] Shuang Yue Zhuan (C)
crc == 0x8f6ab5ac //WXN-三国忠烈传 √
crc == 0x99051cb5 //WXN-雄霸天下 √
crc == 0xf29c8186 //WXN-大富翁2-上海大亨 √
crc == 0xc768098b //WXN-三侠五义 √
crc == 0x49f22159 //WXN-超级大富翁 √
crc == 0xf354d847 //WXN-格兰帝亚 √
crc == 0x5ee2ef97 //WXN-帝国时代(fix) √
crc == 0x977d22c3 //WXN-破釜沉舟(fix) √
crc == 0xf1d803f3 //WXN-西楚霸王(fix) √
crc == 0x85dd49b6 //WXN-口袋金(fix) √
crc == 0x97b82f53 //WXN-爆笑三国(fix) √
crc == 0xce2ea530 //WXN-宠物翡翠(fix) √
*/
} }
//BYTE Mapper176::ReadLow(WORD addr) void Sync()
public override byte ReadLow(ushort addr)
{ {
if (sp_rom == 1) //setprg8r(0x10,0x6000,0);
{ SetPROM_32K_Bank(prg >> 1);
if (addr >= 0x6000) SetVROM_8K_Bank(chr);
{
switch (we_sram)
{
case 0xE4:
case 0xEC: return WRAM[(addr & 0x1FFF) + 0x0000];
case 0xE5:
case 0xED: return WRAM[(addr & 0x1FFF) + 0x2000];
case 0xE6:
case 0xEE: return WRAM[(addr & 0x1FFF) + 0x4000];
case 0xE7:
case 0xEF: return WRAM[(addr & 0x1FFF) + 0x6000];
default: return CPU_MEM_BANK[addr >> 13][addr & 0x1FFF];
}
}
}
return base.ReadLow(addr);
} }
//void Mapper176::WriteLow(WORD addr, BYTE data) //void Mapper176::WriteLow(WORD addr, BYTE data)
public override void WriteLow(ushort addr, byte data) public override void WriteLow(ushort addr, byte data)
{ {
// DEBUGOUT("Address=%04X Data=%02X\n", addr&0xFFFF, data&0xFF );
switch (addr) switch (addr)
{ {
case 0x5000:
reg5000 = data;
break;
case 0x5001: //[ES-1006] Meng Huan Zhi Xing IV (C)
reg5001 = data;
if (SBW!=0) SetPROM_32K_Bank(reg5001);
break;
case 0x5010:
reg5010 = data;
if (reg5010 == 0x24) SBW = 1;
break;
case 0x5011:
reg5011 = (byte)(data >> 1);
if (SBW!=0) SetPROM_32K_Bank(reg5011);
break;
case 0x5013:
reg5013 = data;
break;
case 0x5ff1: case 0x5ff1:
reg5FF1 = (byte)(data >> 1); prg = data; Sync();
SetPROM_32K_Bank(reg5FF1);
break; break;
case 0x5ff2: case 0x5ff2:
reg5FF2 = data; chr = data; Sync();
SetVROM_8K_Bank(reg5FF2); break;
default:
break; break;
} }
if (addr >= 0x6000)
if (sp_rom == 1)
{ {
if (addr >= 0x6000) CPU_MEM_BANK[addr >> 13][addr & 0x1FFF] = data;
{
switch (we_sram)
{
case 0xE4: //CPU_MEM_BANK
case 0xEC: //CPU_MEM_BANK
WRAM[(addr & 0x1FFF) + 0x0000] = data;
CPU_MEM_BANK[addr >> 13][addr & 0x1FFF] = data;
break;
case 0xE5: //SRAM
case 0xED: //SRAM
WRAM[(addr & 0x1FFF) + 0x2000] = data;
break;
case 0xE6:
case 0xEE:
WRAM[(addr & 0x1FFF) + 0x4000] = data;
break;
case 0xE7:
case 0xEF:
WRAM[(addr & 0x1FFF) + 0x6000] = data;
break;
default:
CPU_MEM_BANK[addr >> 13][addr & 0x1FFF] = data;
break;
}
}
} }
else
{
if (addr >= 0x6000)
{
// if ( we_sram == 0 ){
CPU_MEM_BANK[addr >> 13][addr & 0x1FFF] = data;
// }
}
}
}
//void Mapper176::Write(WORD addr, BYTE data)
public override void Write(ushort addr, byte data)
{
// DEBUGOUT("Address=%04X Data=%02X\n", addr&0xFFFF, data&0xFF );
if (addr == 0xa000)
{
data &= 0x03;
if (data == 0) SetVRAM_Mirror(VRAM_VMIRROR);
else if (data == 1) SetVRAM_Mirror(VRAM_HMIRROR);
else if (data == 2) SetVRAM_Mirror(VRAM_MIRROR4L);
else SetVRAM_Mirror(VRAM_MIRROR4H);
}
if (addr == 0xa001)
{
// we_sram = data & 0x03;
we_sram = data;
}
}
//void Mapper176::SaveState(LPBYTE p)
public override void SaveState(byte[] p)
{
p[0] = reg5000;
p[1] = reg5001;
p[2] = reg5010;
p[3] = reg5011;
p[4] = reg5013;
p[5] = reg5FF1;
p[6] = reg5FF2;
p[7] = we_sram;
p[8] = SBW;
p[9] = sp_rom;
}
//void Mapper176::LoadState(LPBYTE p)
public override void LoadState(byte[] p)
{
reg5000 = p[0];
reg5001 = p[1];
reg5010 = p[2];
reg5011 = p[3];
reg5013 = p[4];
reg5FF1 = p[5];
reg5FF2 = p[6];
we_sram = p[7];
SBW = p[8];
sp_rom = p[9];
} }
public override bool IsStateSave() public override bool IsStateSave()

View File

@ -1,10 +1,8 @@
////////////////////////////////////////////////////////////////////////// using static VirtualNes.MMU;
// Mapper178 Education / WaiXing_FS305 //
//////////////////////////////////////////////////////////////////////////
using static VirtualNes.MMU;
using static VirtualNes.Core.CPU; using static VirtualNes.Core.CPU;
using INT = System.Int32; using INT = System.Int32;
using BYTE = System.Byte; using BYTE = System.Byte;
using System;
using Codice.CM.Client.Differences; using Codice.CM.Client.Differences;
namespace VirtualNes.Core namespace VirtualNes.Core
@ -12,66 +10,63 @@ namespace VirtualNes.Core
public class Mapper178 : Mapper public class Mapper178 : Mapper
{ {
BYTE[] reg = new byte[3]; BYTE[] reg = new byte[3];
BYTE banknum; BYTE banknum;
BYTE OP_rom; public Mapper178(NES parent) : base(parent)
public Mapper178(NES parent) : base(parent)
{ {
} }
public override void Reset() public override void Reset()
{ {
reg[0] = 0; reg[0] = 0;
reg[1] = 0; reg[1] = 0;
reg[2] = 0; reg[2] = 0;
banknum = 0; banknum = 0;
SetBank_CPU(); SetBank_CPU();
OP_rom = 0; }
uint crc = nes.rom.GetPROM_CRC(); //void Mapper178::WriteLow(WORD addr, BYTE data)
if (crc == 0x925926BC //[ES-XXXX] Kou Dai Zuan Shi Zhi Chong Wu Xiao Jing Ling 2 (C) public override void WriteLow(ushort addr, byte data)
|| crc == 0xB0B13DBD) //[ES-XXXX] Chong Wu Fei Cui Zhi Chong Wu Xiao Jing Ling IV (C) {
{ if (addr == 0x4800)
OP_rom = 1; {
} if ((data & 0x01) != 0) SetVRAM_Mirror(VRAM_HMIRROR);
} else SetVRAM_Mirror(VRAM_VMIRROR);
}
else if (addr == 0x4801)
{
reg[0] = (byte)((data >> 1) & 0x0f);
SetBank_CPU();
}
else if (addr == 0x4802)
{
reg[1] = (byte)((data << 2) & 0x0f);
// SetBank_CPU();
}
else if (addr == 0x4803)
{
//unknown
}
else if (addr >= 0x6000)
{
CPU_MEM_BANK[addr >> 13][addr & 0x1FFF] = data;
}
}
//void Mapper178::WriteLow(WORD addr, BYTE data) //void Write(WORD addr, BYTE data)
public override void WriteLow(ushort addr, byte data) public override void Write(ushort addr, byte data)
{ {
// if( addr >= 0x4000 && addr <= 0x5FFF ) DEBUGOUT("Address=%04X Data=%02X\n", addr&0xFFFF, data&0xFF ); // SetPROM_32K_Bank( data );
if (addr == 0x4800) }
{
if ((data & 0x01) != 0) SetVRAM_Mirror(VRAM_HMIRROR);
else SetVRAM_Mirror(VRAM_VMIRROR);
}
else if (addr == 0x4801)
{
reg[0] = (byte)((data >> 1) & 0x0F);
if (OP_rom!=0) reg[0] = (byte)(data << 2);
SetBank_CPU();
}
else if (addr == 0x4802)
{
reg[1] = (byte)(data << 2);
if (OP_rom!=0) reg[1] = data;
SetBank_CPU();
}
else if (addr == 0x4803)
{
//unknown
reg[2] = data;
}
else if (addr >= 0x6000)
{
CPU_MEM_BANK[addr >> 13][addr & 0x1FFF] = data;
}
}
void SetBank_CPU() void SetBank_CPU()
{ {
banknum = (byte)(reg[0] | reg[1]); banknum = (byte)((reg[0] + reg[1]) & 0x0f);
// DEBUGOUT("Bank=%02X\n", banknum&0xFF ); SetPROM_32K_Bank(banknum);
SetPROM_32K_Bank(banknum); }
}
} public override bool IsStateSave()
{
return true;
}
}
} }

View File

@ -13,43 +13,43 @@ namespace VirtualNes.Core
public class Mapper192 : Mapper public class Mapper192 : Mapper
{ {
BYTE[] reg = new byte[8]; BYTE[] reg = new byte[8];
BYTE prg0, prg1; BYTE prg0, prg1;
BYTE chr01, chr23, chr4, chr5, chr6, chr7; BYTE chr01, chr23, chr4, chr5, chr6, chr7;
BYTE we_sram; BYTE we_sram;
BYTE irq_type; BYTE irq_type;
BYTE irq_enable; BYTE irq_enable;
BYTE irq_counter; BYTE irq_counter;
BYTE irq_latch; BYTE irq_latch;
BYTE irq_request; BYTE irq_request;
public Mapper192(NES parent) : base(parent) public Mapper192(NES parent) : base(parent)
{ {
} }
public override void Reset() public override void Reset()
{ {
for (byte i = 0; i < 8; i++) for (INT i = 0; i < 8; i++)
{ {
reg[i] = 0x00; reg[i] = 0x00;
} }
prg0 = 0; prg0 = 0;
prg1 = 1; prg1 = 1;
SetBank_CPU(); SetBank_CPU();
chr01 = 0; chr01 = 0;
chr23 = 2; chr23 = 2;
chr4 = 4; chr4 = 4;
chr5 = 5; chr5 = 5;
chr6 = 6; chr6 = 6;
chr7 = 7; chr7 = 7;
SetBank_PPU(); SetBank_PPU();
we_sram = 0; // Disable we_sram = 0; // Disable
irq_enable = 0; // Disable irq_enable = 0; // Disable
irq_counter = 0; irq_counter = 0;
irq_latch = 0; irq_latch = 0;
irq_request = 0; irq_request = 0;
} }
//BYTE Mapper192::ReadLow(WORD addr) //BYTE Mapper192::ReadLow(WORD addr)
@ -81,116 +81,116 @@ namespace VirtualNes.Core
//void Mapper192::Write(WORD addr, BYTE data) //void Mapper192::Write(WORD addr, BYTE data)
public override void Write(ushort addr, byte data) public override void Write(ushort addr, byte data)
{ {
//DEBUGOUT( "MPRWR A=%04X D=%02X L=%3d CYC=%d\n", addr&0xFFFF, data&0xFF, nes.GetScanline(), nes.cpu.GetTotalCycles() ); //DEBUGOUT( "MPRWR A=%04X D=%02X L=%3d CYC=%d\n", addr&0xFFFF, data&0xFF, nes.GetScanline(), nes.cpu.GetTotalCycles() );
switch (addr & 0xE001) switch (addr & 0xE001)
{ {
case 0x8000: case 0x8000:
reg[0] = data; reg[0] = data;
SetBank_CPU(); SetBank_CPU();
SetBank_PPU(); SetBank_PPU();
break; break;
case 0x8001: case 0x8001:
reg[1] = data; reg[1] = data;
switch (reg[0] & 0x07) switch (reg[0] & 0x07)
{ {
case 0x00: case 0x00:
chr01 = data; chr01 = data;
SetBank_PPU(); SetBank_PPU();
break; break;
case 0x01: case 0x01:
chr23 = data; chr23 = data;
SetBank_PPU(); SetBank_PPU();
break; break;
case 0x02: case 0x02:
chr4 = data; chr4 = data;
SetBank_PPU(); SetBank_PPU();
break; break;
case 0x03: case 0x03:
chr5 = data; chr5 = data;
SetBank_PPU(); SetBank_PPU();
break; break;
case 0x04: case 0x04:
chr6 = data; chr6 = data;
SetBank_PPU(); SetBank_PPU();
break; break;
case 0x05: case 0x05:
chr7 = data; chr7 = data;
SetBank_PPU(); SetBank_PPU();
break; break;
case 0x06: case 0x06:
prg0 = data; prg0 = data;
SetBank_CPU(); SetBank_CPU();
break; break;
case 0x07: case 0x07:
prg1 = data; prg1 = data;
SetBank_CPU(); SetBank_CPU();
break; break;
} }
break; break;
case 0xA000: case 0xA000:
reg[2] = data; reg[2] = data;
if (!nes.rom.Is4SCREEN()) if (!nes.rom.Is4SCREEN())
{ {
if ((data & 0x01)!=0) SetVRAM_Mirror(VRAM_HMIRROR); if ((data & 0x01) != 0) SetVRAM_Mirror(VRAM_HMIRROR);
else SetVRAM_Mirror(VRAM_VMIRROR); else SetVRAM_Mirror(VRAM_VMIRROR);
} }
break; break;
case 0xA001: case 0xA001:
reg[3] = data; reg[3] = data;
break; break;
case 0xC000: case 0xC000:
reg[4] = data; reg[4] = data;
irq_counter = data; irq_counter = data;
irq_request = 0; irq_request = 0;
break; break;
case 0xC001: case 0xC001:
reg[5] = data; reg[5] = data;
irq_latch = data; irq_latch = data;
irq_request = 0; irq_request = 0;
break; break;
case 0xE000: case 0xE000:
reg[6] = data; reg[6] = data;
irq_enable = 0; irq_enable = 0;
irq_request = 0; irq_request = 0;
nes.cpu.ClrIRQ(IRQ_MAPPER); nes.cpu.ClrIRQ(IRQ_MAPPER);
break; break;
case 0xE001: case 0xE001:
reg[7] = data; reg[7] = data;
irq_enable = 1; irq_enable = 1;
irq_request = 0; irq_request = 0;
break; break;
} }
} }
//void Mapper192::HSync(INT scanline) //void Mapper192::HSync(INT scanline)
public override void HSync(int scanline) public override void HSync(int scanline)
{ {
if ((scanline >= 0 && scanline <= 239)) if ((scanline >= 0 && scanline <= 239))
{ {
if (nes.ppu.IsDispON()) if (nes.ppu.IsDispON())
{ {
if (irq_enable!=0 && irq_request == 0) if (irq_enable != 0 && irq_request == 0)
{ {
if (scanline == 0) if (scanline == 0)
{ {
if (irq_counter!=0) if (irq_counter != 0)
{ {
irq_counter--; irq_counter--;
} }
} }
if ((irq_counter--)==0) if ((irq_counter--) == 0)
{ {
irq_request = 0xFF; irq_request = 0xFF;
irq_counter = irq_latch; irq_counter = irq_latch;
nes.cpu.SetIRQ(IRQ_MAPPER); nes.cpu.SetIRQ(IRQ_MAPPER);
} }
} }
} }
} }
} }
void SetBank_CPU() void SetBank_CPU()
{ {
@ -298,7 +298,7 @@ namespace VirtualNes.Core
//void Mapper192::LoadState(LPBYTE p) //void Mapper192::LoadState(LPBYTE p)
public override void LoadState(byte[] p) public override void LoadState(byte[] p)
{ {
for (byte i = 0; i < 8; i++) for (INT i = 0; i < 8; i++)
{ {
reg[i] = p[i]; reg[i] = p[i];
} }

View File

@ -1353,7 +1353,7 @@ namespace VirtualNes.Core
return; return;
m_TapeCycles += (nescfg.CpuClock / 32000.0); m_TapeCycles += (nescfg.CpuClock / 32000.0);
// m_TapeCycles += (nescfg.CpuClock / 22050.0); // 遅すぎてダメっぽい // m_TapeCycles += (nescfg->CpuClock / 22050.0); // 遅すぎてダメっぽい
if (m_bTapePlay) if (m_bTapePlay)
{ {