Updates and Bug Fixes

Sets stack pointer to FD on initialization (see visual 6502)
Adds portA write state to 6532
This commit is contained in:
alyosha-tas 2016-05-31 09:11:57 -04:00
parent 24b0ebb924
commit d0c7d81de5
2 changed files with 26 additions and 7 deletions

View File

@ -323,6 +323,12 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
Rom.HashSHA1(),
Rom.HashMD5(),
_mapper.GetType());
// as it turns out, the stack pointer cannot be set to 0 for some games as they do not initilize it themselves.
// some documentation seems to indicate it should beset to FD, but currently there is no documentation of the 6532
// executing a reset sequence at power on, but it's needed so let's hard code it for now
Cpu.S = 0xFD;
}
private bool _pal;
@ -345,6 +351,11 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
M6532 = new M6532(this);
Cpu.PC = (ushort)(ReadMemory(0x1FFC) + (ReadMemory(0x1FFD) << 8)); // set the initial PC
// as it turns out, the stack pointer cannot be set to 0 for some games as they do not initilize it themselves.
// some documentation seems to indicate it should beset to FD, but currently there is no documentation of the 6532
// executing a reset sequence at power on, but it's needed so let's hard code it for now
Cpu.S = 0xFD;
}
public void FrameAdvance(bool render, bool rendersound)

View File

@ -9,6 +9,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
public byte DDRa = 0x00;
public byte DDRb = 0x00;
public byte outputA = 0x00;
public TimerData Timer;
@ -35,9 +36,13 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
{
// Read Output reg A
// Combine readings from player 1 and player 2
// actually depends on setting in SWCHCNTA (aka DDRa)
var temp = (byte)(_core.ReadControls1(peek) & 0xF0 | ((_core.ReadControls2(peek) >> 4) & 0x0F));
temp = (byte)(temp & ~DDRa);
temp = (byte)(temp + (outputA & DDRa));
return temp;
}
if (registerAddr == 0x01)
@ -151,6 +156,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
if (registerAddr == 0x00)
{
// Write Output reg A
outputA = value;
}
else if (registerAddr == 0x01)
{
@ -160,6 +166,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
else if (registerAddr == 0x02)
{
// Write Output reg B
// But is read only
}
else if (registerAddr == 0x03)
{
@ -175,6 +182,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
ser.BeginSection("M6532");
ser.Sync("ddra", ref DDRa);
ser.Sync("ddrb", ref DDRb);
ser.Sync("OutputA", ref outputA);
Timer.SyncState(ser);
ser.EndSection();
}