More cleanup and slight refactoring of the codebase. More debug[] registers added.

This commit is contained in:
Dave Bernazzani 2025-05-13 18:08:43 -04:00
parent 6ff8d0ec3d
commit f332319398
7 changed files with 30 additions and 32 deletions

View File

@ -232,21 +232,20 @@ void C64::LoadPRG(char *filename)
if (fp)
{
int prg_size = fread(CompressBuffer, 1, sizeof(CompressBuffer), fp);
fclose(fp);
uint8 start_hi, start_lo;
uint16 start;
int i;
u8 *prg = CompressBuffer;
start_lo=*prg++;
start_hi=*prg++;
start=(start_hi<<8)+start_lo;
for(i=0; i<(prg_size-2); i++)
for(int i=0; i<(prg_size-2); i++)
{
myRAM[start+i]=prg[i];
}
fclose(fp);
}
}
}
@ -849,7 +848,7 @@ bool C64::LoadSnapshot(char *filename)
/*
* C64_GP32.i by Mike Dawson, adapted from:
* C64_x.i - Put the pieces together, X specific stuff
*f
*
* Frodo (C) 1994-1997,2002 Christian Bauer
* Unix stuff by Bernd Schmidt/Lutz Vieweg
*/
@ -994,7 +993,7 @@ ITCM_CODE void C64::VBlank(bool draw_frame)
TheCIA2->CountTOD();
frames++;
while (GetTicks() < (((unsigned int)TICKS_PER_SEC/(unsigned int)50) * (unsigned int)frames))
while (GetTicks() < (((unsigned int)TICKS_PER_SEC/(unsigned int)SCREEN_FREQ) * (unsigned int)frames))
{
if (bTurboWarp) break;
}
@ -1009,7 +1008,7 @@ ITCM_CODE void C64::VBlank(bool draw_frame)
frames_per_sec = 0;
}
if (frames == 50)
if (frames == SCREEN_FREQ)
{
frames = 0;
StartTimers();
@ -1330,8 +1329,6 @@ void C64::RemoveCart(void)
void C64::main_loop(void)
{
int linecnt = 0;
while (!quit_thyself)
{
if(have_a_break)
@ -1374,8 +1371,6 @@ void C64::main_loop(void)
// 1541 processor disabled, only emulate 6510
TheCPU->EmulateLine(cpu_cycles_to_execute);
}
linecnt++;
}
}

View File

@ -202,8 +202,10 @@ void MOS6526::SetState(MOS6526State *cs)
uint8 MOS6526_1::ReadRegister(uint16 adr)
{
switch (adr) {
case 0x00: {
switch (adr)
{
case 0x00:
{
uint8 ret = pra | ~ddra, tst = (prb | ~ddrb) & Joystick1;
if (!(tst & 0x01)) ret &= RevMatrix[0]; // AND all active columns
if (!(tst & 0x02)) ret &= RevMatrix[1];
@ -215,7 +217,8 @@ uint8 MOS6526_1::ReadRegister(uint16 adr)
if (!(tst & 0x80)) ret &= RevMatrix[7];
return ret & Joystick2;
}
case 0x01: {
case 0x01:
{
uint8 ret = ~ddrb, tst = (pra | ~ddra) & Joystick2;
if (!(tst & 0x01)) ret &= KeyMatrix[0]; // AND all active rows
if (!(tst & 0x02)) ret &= KeyMatrix[1];
@ -258,7 +261,8 @@ uint8 MOS6526_1::ReadRegister(uint16 adr)
uint8 MOS6526_2::ReadRegister(uint16 adr)
{
switch (adr) {
switch (adr)
{
case 0x00:
return ((pra | ~ddra) & 0x3f) | (IECLines & the_cpu_1541->IECLines);
case 0x01: return prb | ~ddrb;
@ -379,8 +383,6 @@ void MOS6526_1::WriteRegister(uint16 adr, uint8 byte)
break;
case 0xd:
if (ThePrefs.CIAIRQHack) // Hack for addressing modes that read from the address
icr = 0;
if (byte & 0x80) {
int_mask |= byte & 0x1f;
if (icr & int_mask) { // Trigger IRQ if pending
@ -514,8 +516,6 @@ void MOS6526_2::WriteRegister(uint16 adr, uint8 byte)
break;
case 0xd:
if (ThePrefs.CIAIRQHack)
icr = 0;
if (byte & 0x80) {
int_mask |= byte & 0x7f;
if (icr & int_mask & 0x1f) { // Trigger NMI if pending

View File

@ -484,7 +484,6 @@ Cartridge * Cartridge::FromFile(char *filename, char *errBuffer)
uint8_t exrom = header[0x18];
uint8_t game = header[0x19];
debug[3] = type;
switch (type) {
case 0:
if (exrom != 0) // Ultimax or not a ROM cartridge

View File

@ -513,18 +513,27 @@ int getMemFree() { // returns the amount of free memory in bytes
int i = 0;
int debug[8]={0,0,0,0,0,0,0,0};
int debug[16]={0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0};
void C64Display::Speedometer(int speed)
{
char tmp[34];
if (bDebugDisplay)
{
sprintf(tmp, "%-8d", speed);
DSPrint(19, 1, 6, tmp);
sprintf(tmp, "%-8d %-8d %-6d %-6d", debug[0],debug[1],debug[2],debug[3]);
DSPrint(0, 0, 6, tmp);
sprintf(tmp, "%-8d %-8d %-6d %-6d", debug[4],debug[5],debug[6],debug[7]);
DSPrint(0, 1, 6, tmp);
sprintf(tmp, "%-8d %-8d %-6d %-6d", debug[8],debug[9],debug[10],debug[11]);
DSPrint(0, 2, 6, tmp);
sprintf(tmp, "%-8d %-8d %-6d %-3d", debug[12],debug[13],debug[14],debug[15]);
DSPrint(0, 3, 6, tmp);
sprintf(tmp, "%3d", speed);
DSPrint(29, 3, 6, tmp);
}
show_joysticks();

View File

@ -39,10 +39,7 @@ Prefs::Prefs()
strcpy(DrivePath[0], "");
strcpy(DrivePath[1], "");
SIDType = SIDTYPE_DIGITAL;
FastReset = true;
CIAIRQHack = false;
TrueDrive = false; // True Drive Emulation when TRUE (slower emulation)
}

View File

@ -43,9 +43,7 @@ public:
bool operator!=(const Prefs &rhs) const;
char DrivePath[2][256]; // Path for drive 8 and 9
int SIDType; // SID emulation type
bool FastReset; // Skip RAM test on reset
bool CIAIRQHack; // Write to CIA ICR clears IRQ
bool TrueDrive; // Enable processor-level 1541 emulation
};

View File

@ -94,7 +94,7 @@ MOS6581::MOS6581(C64 *c64) : the_c64(c64)
regs[i] = 0;
// Open the renderer
open_close_renderer(SIDTYPE_NONE, ThePrefs.SIDType);
open_close_renderer(SIDTYPE_NONE, SIDTYPE_DIGITAL);
}
@ -105,7 +105,7 @@ MOS6581::MOS6581(C64 *c64) : the_c64(c64)
MOS6581::~MOS6581()
{
// Close the renderer
open_close_renderer(ThePrefs.SIDType, SIDTYPE_NONE);
open_close_renderer(SIDTYPE_DIGITAL, SIDTYPE_NONE);
}
@ -137,7 +137,7 @@ void MOS6581::Reset(void)
void MOS6581::NewPrefs(Prefs *prefs)
{
open_close_renderer(ThePrefs.SIDType, prefs->SIDType);
open_close_renderer(SIDTYPE_DIGITAL, SIDTYPE_DIGITAL);
if (the_renderer != NULL)
{
the_renderer->NewPrefs(prefs);