AxibugEmuOnline/virtuanessrc097-master/NES/Mapper/Mapper050.cpp

61 lines
2.6 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.

//////////////////////////////////////////////////////////////////////////
// Mapper050 SMB2J //
//////////////////////////////////////////////////////////////////////////
void Mapper050::Reset()
{
irq_enable = 0;
SetPROM_8K_Bank( 3, 15 );
SetPROM_8K_Bank( 4, 8 );
SetPROM_8K_Bank( 5, 9 );
SetPROM_8K_Bank( 6, 0 );
SetPROM_8K_Bank( 7, 11 );
if( VROM_1K_SIZE ) {
SetVROM_8K_Bank( 0 );
}
}
void Mapper050::ExWrite( WORD addr, BYTE data )
{
if( (addr & 0xE060) == 0x4020 ) {
if( addr & 0x0100 ) {
irq_enable = data & 0x01;
nes->cpu->ClrIRQ( IRQ_MAPPER );
} else {
SetPROM_8K_Bank( 6, (data&0x08)|((data&0x01)<<2)|((data&0x06)>>1) );
}
}
}
void Mapper050::WriteLow( WORD addr, BYTE data )
{
if( (addr & 0xE060) == 0x4020 ) {
if( addr & 0x0100 ) {
irq_enable = data & 0x01;
nes->cpu->ClrIRQ( IRQ_MAPPER );
} else {
SetPROM_8K_Bank( 6, (data&0x08)|((data&0x01)<<2)|((data&0x06)>>1) );
}
}
}
void Mapper050::HSync( INT scanline )
{
if( irq_enable ) {
if( scanline == 21 ) {
// nes->cpu->IRQ();
nes->cpu->SetIRQ( IRQ_MAPPER );
}
}
}
void Mapper050::SaveState( LPBYTE p )
{
p[0] = irq_enable;
}
void Mapper050::LoadState( LPBYTE p )
{
irq_enable = p[0];
}