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

48 lines
2.0 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.

//////////////////////////////////////////////////////////////////////////
// Mapper041 Caltron 6-in-1 //
//////////////////////////////////////////////////////////////////////////
void Mapper041::Reset()
{
reg[0] = reg[1] = 0;
SetPROM_32K_Bank( 0, 1, 2, 3 );
if( VROM_1K_SIZE ) {
SetVROM_8K_Bank( 0 );
}
}
void Mapper041::WriteLow( WORD addr, BYTE data )
{
if( addr >= 0x6000 && addr < 0x6800 ) {
SetPROM_32K_Bank( addr&0x07 );
reg[0] = addr & 0x04;
reg[1] &= 0x03;
reg[1] |= (addr>>1)&0x0C;
SetVROM_8K_Bank( reg[1] );
if( addr&0x20 ) SetVRAM_Mirror( VRAM_HMIRROR );
else SetVRAM_Mirror( VRAM_VMIRROR );
}
}
void Mapper041::Write( WORD addr, BYTE data )
{
if( reg[0] ) {
reg[1] &= 0x0C;
reg[1] |= addr & 0x03;
SetVROM_8K_Bank( reg[1] );
}
}
void Mapper041::SaveState( LPBYTE p )
{
p[0] = reg[0];
p[1] = reg[1];
}
void Mapper041::LoadState( LPBYTE p )
{
reg[0] = p[0];
reg[1] = p[1];
}