Add some debugging info. Don't reset timer when reading $4211.

This commit is contained in:
Brandon Wright 2018-05-28 18:24:11 -05:00
parent 37be67d9ee
commit 78bc52cd8e
5 changed files with 36 additions and 9 deletions

View File

@ -257,6 +257,9 @@ void S9xMainLoop (void)
CPU.IRQPending--;
else
{
#ifdef DEBUGGER
S9xTraceMessage ("Timer triggered\n");
#endif
CPU.IRQTransition = TRUE;
}
}

View File

@ -889,7 +889,7 @@ static uint8 debug_cpu_op_print (char *Line, uint8 Bank, uint16 Address)
break;
}
sprintf(Line, "%-44s A:%04X X:%04X Y:%04X D:%04X DB:%02X S:%04X P:%c%c%c%c%c%c%c%c%c HC:%04ld VC:%03ld FC:%02d %03x %c %c%c",
sprintf(Line, "%-44s A:%04X X:%04X Y:%04X D:%04X DB:%02X S:%04X P:%c%c%c%c%c%c%c%c%c HC:%04ld VC:%03ld FC:%02d %c%c%c %c %c%c HT:%d VT:%d C:%d",
Line, Registers.A.W, Registers.X.W, Registers.Y.W,
Registers.D.W, Registers.DB, Registers.S.W,
CheckEmulation() ? 'E' : 'e',
@ -904,10 +904,11 @@ static uint8 debug_cpu_op_print (char *Line, uint8 Bank, uint16 Address)
(long) CPU.Cycles,
(long) CPU.V_Counter,
IPPU.FrameCount,
(CPU.IRQExternal ? 0x100 : 0) | (PPU.HTimerEnabled ? 0x10 : 0) | (PPU.VTimerEnabled ? 0x01 : 0),
CPU.IRQExternal ? 'E' : ' ', PPU.HTimerEnabled ? 'H' : ' ', PPU.VTimerEnabled ? 'V' : ' ',
CPU.NMIPending ? 'N' : '.',
CPU.IRQTransition ? 'T' : ' ',
CPU.IRQLine ? 'L' : ' ');
CPU.IRQLine ? 'L' : ' ',
PPU.HTimerPosition, PPU.VTimerPosition, Timings.NextIRQTimer);
return (Size);
}

15
ppu.cpp
View File

@ -333,7 +333,7 @@ void S9xUpdateIRQPositions (bool initial)
else if (PPU.HTimerEnabled && !PPU.VTimerEnabled)
{
Timings.NextIRQTimer = PPU.HTimerPosition;
if (CPU.Cycles > Timings.NextIRQTimer)
if (CPU.Cycles > Timings.NextIRQTimer - Timings.IRQTriggerCycles)
Timings.NextIRQTimer += Timings.H_Max;
}
else if (!PPU.HTimerEnabled && PPU.VTimerEnabled)
@ -349,7 +349,7 @@ void S9xUpdateIRQPositions (bool initial)
}
#ifdef DEBUGGER
S9xTraceFormattedMessage("--- IRQ Timer set %d cycles HTimer:%d Pos:%04d->%04d VTimer:%d Pos:%03d->%03d",
S9xTraceFormattedMessage("--- IRQ Timer HC:%d VC:%d %s %d cycles HTimer:%d Pos:%04d->%04d VTimer:%d Pos:%03d->%03d", CPU.Cycles, CPU.V_Counter, initial ? "set" : "recur",
Timings.NextIRQTimer, PPU.HTimerEnabled, PPU.IRQHBeamPos, PPU.HTimerPosition, PPU.VTimerEnabled, PPU.IRQVBeamPos, PPU.VTimerPosition);
#endif
}
@ -1848,10 +1848,13 @@ uint8 S9xGetCPU (uint16 Address)
return ((byte & 0x80) | (OpenBus & 0x70) | Model->_5A22);
case 0x4211: // TIMEUP
byte = CPU.IRQLine ? 0x80 : 0;
CPU.IRQLine = FALSE;
CPU.IRQTransition = FALSE;
S9xUpdateIRQPositions(false);
byte = 0;
if (CPU.IRQLine)
{
byte = 0x80;
CPU.IRQLine = FALSE;
CPU.IRQTransition = FALSE;
}
return (byte | (OpenBus & 0x7f));

View File

@ -306,6 +306,8 @@ struct SoundStatus
int32 play_position;
};
static int frame_advance = 0;
static SUnixSettings unixSettings;
static SoundStatus so;
@ -1188,6 +1190,12 @@ s9xcommand_t S9xGetPortCommandT (const char *n)
return (cmd);
}
else if (!strcmp(n, "Advance"))
{
cmd.type = S9xButtonPort;
cmd.port[1] = 3;
return (cmd);
}
return (S9xGetDisplayCommandT(n));
}
@ -1220,6 +1228,9 @@ char * S9xGetPortCommandName (s9xcommand_t cmd)
case 2:
return (strdup("Rewind"));
case 3:
return (strdup("Advance"));
}
break;
@ -1260,6 +1271,9 @@ void S9xHandlePortCommand (s9xcommand_t cmd, int16 data1, int16 data2)
case 2:
rewinding = (bool8) data1;
break;
case 3:
frame_advance = (bool8) data1;
}
break;
@ -1945,6 +1959,11 @@ int main (int argc, char **argv)
S9xMainLoop();
}
if (Settings.Paused && frame_advance)
{
S9xMainLoop();
frame_advance = 0;
}
#ifdef NETPLAY_SUPPORT
if (NP_Activated)

View File

@ -567,6 +567,7 @@ const char * S9xParseDisplayConfig (ConfigFile &conf, int pass)
keymaps.push_back(strpair_t("K00:slash", "Superscope Pause"));
keymaps.push_back(strpair_t("K00:r", "Rewind"));
keymaps.push_back(strpair_t("K00:l", "Advance"));
}
GUI.no_repeat = !conf.GetBool("Unix/X11::SetKeyRepeat", TRUE);