AxibugEmuOnline/References/virtuanessrc097-master/NES/Mapper/Mapper135.cpp
2024-08-05 17:58:53 +08:00

88 lines
3.7 KiB
C++
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//////////////////////////////////////////////////////////////////////////
// Mapper135 SACHEN CHEN //
//////////////////////////////////////////////////////////////////////////
void Mapper135::Reset()
{
cmd = 0;
chr0l = chr1l = chr0h = chr1h = chrch = 0;
SetPROM_32K_Bank( 0 );
SetBank_PPU();
}
void Mapper135::WriteLow( WORD addr, BYTE data )
{
switch( addr & 0x4101 ) {
case 0x4100:
cmd = data & 0x07;
break;
case 0x4101:
switch( cmd ) {
case 0:
chr0l = data & 0x07;
SetBank_PPU();
break;
case 1:
chr0h = data & 0x07;
SetBank_PPU();
break;
case 2:
chr1l = data & 0x07;
SetBank_PPU();
break;
case 3:
chr1h = data & 0x07;
SetBank_PPU();
break;
case 4:
chrch = data & 0x07;
SetBank_PPU();
break;
case 5:
SetPROM_32K_Bank( data&0x07 );
break;
case 6:
break;
case 7:
switch( (data>>1)&0x03 ) {
case 0: SetVRAM_Mirror( VRAM_MIRROR4L ); break;
case 1: SetVRAM_Mirror( VRAM_HMIRROR ); break;
case 2: SetVRAM_Mirror( VRAM_VMIRROR ); break;
case 3: SetVRAM_Mirror( VRAM_MIRROR4L ); break;
}
break;
}
break;
}
CPU_MEM_BANK[addr>>13][addr&0x1FFF] = data;
}
void Mapper135::SetBank_PPU()
{
SetVROM_2K_Bank( 0, 0|(chr0l<<1)|(chrch<<4) );
SetVROM_2K_Bank( 2, 1|(chr0h<<1)|(chrch<<4) );
SetVROM_2K_Bank( 4, 0|(chr1l<<1)|(chrch<<4) );
SetVROM_2K_Bank( 6, 1|(chr1h<<1)|(chrch<<4) );
}
void Mapper135::SaveState( LPBYTE p )
{
p[ 0] = cmd;
p[ 1] = chr0l;
p[ 2] = chr0h;
p[ 3] = chr1l;
p[ 4] = chr1h;
p[ 5] = chrch;
}
void Mapper135::LoadState( LPBYTE p )
{
cmd = p[ 0];
chr0l = p[ 1];
chr0h = p[ 2];
chr0l = p[ 3];
chr0h = p[ 4];
chrch = p[ 5];
}