示例#1
0
void C64::SaveSnapshot(char *filename)
{
    FILE *f;
    uint8 flags;
    uint8 delay;
    int stat;

    if ((f = fopen(filename, "wb")) == NULL) {
        ShowRequester("Unable to open snapshot file", "OK", NULL);
        return;
    }

    fprintf(f, "%s%c", SNAPSHOT_HEADER, 10);
    fputc(0, f);	// Version number 0
    flags = 0;
    if (ThePrefs.Emul1541Proc)
        flags |= SNAPSHOT_1541;
    fputc(flags, f);
    SaveVICState(f);
    SaveSIDState(f);
    SaveCIAState(f);

#ifdef FRODO_SC
    delay = 0;
    do {
        if ((stat = SaveCPUState(f)) == -1) {	// -1 -> Instruction not finished yet
            ADVANCE_CYCLES;	// Advance everything by one cycle
            delay++;
        }
    } while (stat == -1);
    fputc(delay, f);	// Number of cycles the saved CPUC64 lags behind the previous chips
#else
    SaveCPUState(f);
    fputc(0, f);		// No delay
#endif

    if (ThePrefs.Emul1541Proc) {
        fwrite(ThePrefs.DrivePath[0], 256, 1, f);
#ifdef FRODO_SC
        delay = 0;
        do {
            if ((stat = Save1541State(f)) == -1) {
                ADVANCE_CYCLES;
                delay++;
            }
        } while (stat == -1);
        fputc(delay, f);
#else
        Save1541State(f);
        fputc(0, f);	// No delay
#endif
        Save1541JobState(f);
    }
    fclose(f);

}
示例#2
0
void C64::SaveRAM(char *filename)
{
    FILE *f;

    if ((f = fopen(filename, "wb")) == NULL)
        ShowRequester("RAM save failed.", "OK", NULL);
    else {
        fwrite((void*)RAM, 1, 0x10000, f);
        fwrite((void*)Color, 1, 0x400, f);
        if (ThePrefs.Emul1541Proc)
            fwrite((void*)RAM1541, 1, 0x800, f);
        fclose(f);
    }
}
示例#3
0
int blacklistClicked( void )
{
	/* routine when gadget "App's Blacklist" is clicked. */
	
	/**
	 * First of all, make sure the external program exists..
	 * NOTE: if someone would like to implement it on the GadTools
	 * program as well it'll be nice!..
	 */
	BPTR lock;
	UBYTE MUI_Prog[] = "SYS:Prefs/ixbl_MUI";
	UBYTE Runner_WB[] = "C:WBRun";
	UBYTE Runner_CLI[] = "C:Run <>NIL:";
	
	if(!(lock = Lock( MUI_Prog, SHARED_LOCK )))
	{
		ShowRequester("Couldn't found \"%s\"",(int)MUI_Prog,NULL);
	}
	else
	{
		char *runner, cmd[64];
		
		UnLock( lock );
		
		if(!(lock = Lock( Runner_WB, SHARED_LOCK )))
		{
			runner = Runner_CLI;
		}
		else
		{
			UnLock( lock );
			runner = Runner_WB;
		}
		
		sprintf( cmd, "%s \"%s\"", runner, MUI_Prog );
		
		Execute( cmd, NULL, NULL );
	}
	
	return RUNNING;
}
示例#4
0
bool C64::LoadSnapshot(char *filename)
{
    FILE *f;

    if ((f = fopen(filename, "rb")) != NULL) {
        char Header[] = SNAPSHOT_HEADER;
        char *b = Header, c = 0;
        uint8 delay, i;

        // For some reason memcmp()/strcmp() and so forth utterly fail here.
        while (*b > 32) {
            if ((c = fgetc(f)) != *b++) {
                b = NULL;
                break;
            }
        }
        if (b != NULL) {
            uint8 flags;
            bool error = false;
#ifndef FRODO_SC
            long vicptr;	// File offset of VIC data
#endif

            while (c != 10)
                c = fgetc(f);	// Shouldn't be necessary
            if (fgetc(f) != 0) {
                ShowRequester("Unknown snapshot format", "OK", NULL);
                fclose(f);
                return false;
            }
            flags = fgetc(f);
#ifndef FRODO_SC
            vicptr = ftell(f);
#endif

            error |= !LoadVICState(f);
            error |= !LoadSIDState(f);
            error |= !LoadCIAState(f);
            error |= !LoadCPUState(f);

            delay = fgetc(f);	// Number of cycles the 6510 is ahead of the previous chips
#ifdef FRODO_SC
            // Make the other chips "catch up" with the 6510
            for (i=0; i<delay; i++) {
                TheVIC->EmulateCycle();
                TheCIA1->EmulateCycle();
                TheCIA2->EmulateCycle();
            }
#endif
            if ((flags & SNAPSHOT_1541) != 0) {
                Prefs *prefs = new Prefs(ThePrefs);

                // First switch on emulation
                error |= (fread(prefs->DrivePath[0], 256, 1, f) != 1);
                prefs->Emul1541Proc = true;
                NewPrefs(prefs);
                ThePrefs = *prefs;
                delete prefs;

                // Then read the context
                error |= !Load1541State(f);

                delay = fgetc(f);	// Number of cycles the 6502 is ahead of the previous chips
#ifdef FRODO_SC
                // Make the other chips "catch up" with the 6502
                for (i=0; i<delay; i++) {
                    TheVIC->EmulateCycle();
                    TheCIA1->EmulateCycle();
                    TheCIA2->EmulateCycle();
                    TheCPU->EmulateCycle();
                }
#endif
                Load1541JobState(f);
            } else if (ThePrefs.Emul1541Proc) {	// No emulation in snapshot, but currently active?
                Prefs *prefs = new Prefs(ThePrefs);
                prefs->Emul1541Proc = false;
                NewPrefs(prefs);
                ThePrefs = *prefs;
                delete prefs;
            }

#ifndef FRODO_SC
            fseek(f, vicptr, SEEK_SET);
            LoadVICState(f);	// Load VIC data twice in SL (is REALLY necessary sometimes!)
#endif
            fclose(f);

            if (error) {
                ShowRequester("Error reading snapshot file", "OK", NULL);
                Reset();
                return false;
            } else
                return true;
        } else {
            fclose(f);
            ShowRequester("Not a Frodo snapshot file", "OK", NULL);
            return false;
        }
    } else {
        ShowRequester("Can't open snapshot file", "OK", NULL);
        return false;
    }
}