Main Page | Class Hierarchy | Compound List | File List | Compound Members | File Members | Related Pages

C64 Class Reference

#include <C64.h>

Collaboration diagram for C64:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 C64 (Frodo *aFrodoPtr)
 ~C64 ()
void Run (void)
void Quit (void)
bool TogglePause (void)
bool Paused (void)
void Reset (void)
void NMI (void)
void VBlank (bool draw_frame)
void NewPrefs (Prefs *prefs)
void PatchKernal (bool fast_reset, bool emul_1541_proc)
void SaveRAM (char *filename)
void SaveSnapshot (char *filename)
bool LoadSnapshot (char *filename)
int SaveCPUState (FILE *f)
int Save1541State (FILE *f)
bool Save1541JobState (FILE *f)
bool SaveVICState (FILE *f)
bool SaveSIDState (FILE *f)
bool SaveCIAState (FILE *f)
bool LoadCPUState (FILE *f)
bool Load1541State (FILE *f)
bool Load1541JobState (FILE *f)
bool LoadVICState (FILE *f)
bool LoadSIDState (FILE *f)
bool LoadCIAState (FILE *f)
void thread_func ()

Public Attributes

uint8RAM
uint8Basic
uint8Kernal
uint8Char
uint8Color
uint8RAM1541
uint8ROM1541
C64DisplayTheDisplay
MOS6510TheCPU
MOS6569TheVIC
MOS6581TheSID
MOS6526_1TheCIA1
MOS6526_2TheCIA2
IECTheIEC
REUTheREU
MOS6502_1541TheCPU1541
Job1541TheJob1541
TBool iIsAudioPending
TBool iSoundHaveBeenPaused
bool have_a_break
 Emulation thread shall pause.

FrodoiFrodoPtr
int joyfd [2]
double speed_index
timeval tv_start
CJoyPadObserveriJoyPadObserver
PrefsThePrefs
PrefsThePrefsOnDisk

Private Member Functions

void c64_ctor1 (void)
void c64_ctor2 (void)
void c64_dtor (void)
void open_close_joysticks (bool oldjoy1, bool oldjoy2, bool newjoy1, bool newjoy2)
uint8 poll_joystick (int port)

Private Attributes

bool thread_running
bool quit_thyself
int joy_minx
int joy_maxx
int joy_miny
int joy_maxy
uint8 joykey
uint8 orig_kernal_1d84
uint8 orig_kernal_1d85

Detailed Description

The main C64 class.

Definition at line 88 of file C64.h.


Constructor & Destructor Documentation

C64::C64 Frodo aFrodoPtr  ) 
 

Constructor: Allocate objects and memory

Definition at line 63 of file C64.cpp.

References __CHECK_NULL, Basic, c64_ctor1(), c64_ctor2(), Char, Color, CTOR, have_a_break, iIsAudioPending, iJoyPadObserver, joykey, Kernal, Prefs::LimitSpeed, Prefs::Load(), MakePath(), memset, open_close_joysticks(), quit_thyself, RAM, RAM1541, rand, ROM1541, MOS6510::TheCIA1, TheCIA1, MOS6502_1541::TheCIA2, MOS6510::TheCIA2, TheCIA2, TheCPU, TheCPU1541, TheDisplay, MOS6510::TheIEC, TheIEC, TheJob1541, ThePrefs, ThePrefs, ThePrefsOnDisk, MOS6510::TheREU, TheREU, MOS6510::TheSID, TheSID, MOS6510::TheVIC, TheVIC, thread_running, and uint8.

C64::~C64  ) 
 

Destructor: Delete all objects

Todo:

Definition at line 171 of file C64.cpp.

References Basic, c64_dtor(), Char, Color, DTOR, ELOG1, ELOG2, iJoyPadObserver, Prefs::Joystick1On, Prefs::Joystick2On, Kernal, MakePath(), open_close_joysticks(), RAM, RAM1541, ROM1541, Prefs::Save(), TheCIA1, TheCIA2, TheCPU, TheCPU1541, TheDisplay, TheIEC, TheJob1541, ThePrefs, ThePrefsOnDisk, TheREU, TheSID, and TheVIC.


Member Function Documentation

void C64::c64_ctor1 void   )  [private]
 

Constructor, system-dependent things

Definition at line 119 of file C64_Acorn.i.

References MaximumVolume, and Sound_Volume().

Referenced by C64().

void C64::c64_ctor2 void   )  [private]
 

Definition at line 134 of file C64_Acorn.i.

References DEFAULT_SYSCONF, and ReadKeyboardStatus().

Referenced by C64().

void C64::c64_dtor void   )  [private]
 

Definition at line 143 of file C64_Acorn.i.

Referenced by ~C64().

bool C64::Load1541JobState FILE *  f  ) 
 

Load 1541 GCR state from snapshot

Definition at line 571 of file C64.cpp.

References fread, Job1541::SetState(), and TheJob1541.

Referenced by LoadSnapshot().

bool C64::Load1541State FILE *  f  ) 
 

Load 1541 state from snapshot

Definition at line 454 of file C64.cpp.

References fread, RAM1541, MOS6502_1541::SetState(), and TheCPU1541.

Referenced by LoadSnapshot().

bool C64::LoadCIAState FILE *  f  ) 
 

Load CIA states from snapshot

Definition at line 541 of file C64.cpp.

References fread, MOS6526::SetState(), TheCIA1, and TheCIA2.

Referenced by LoadSnapshot().

bool C64::LoadCPUState FILE *  f  ) 
 

Definition at line 413 of file C64.cpp.

References Color, fread, RAM, MOS6510::SetState(), and TheCPU.

Referenced by LoadSnapshot().

bool C64::LoadSIDState FILE *  f  ) 
 

Load SID state from snapshot

Definition at line 510 of file C64.cpp.

References fread, MOS6581::SetState(), and TheSID.

Referenced by LoadSnapshot().

bool C64::LoadSnapshot char *  filename  ) 
 

Load snapshot (emulation must be paused and in VBlank)

Definition at line 674 of file C64.cpp.

References Prefs::DrivePath, Prefs::Emul1541Proc, fclose, fgetc, FILE, fopen, fread, fseek, ftell, Load1541JobState(), Load1541State(), LoadCIAState(), LoadCPUState(), LoadSIDState(), LoadVICState(), NewPrefs(), Reset(), ShowRequester(), SNAPSHOT_1541, SNAPSHOT_HEADER, TheCIA1, TheCIA2, TheCPU, ThePrefs, TheVIC, and uint8.

bool C64::LoadVICState FILE *  f  ) 
 

Load VIC state from snapshot

Definition at line 483 of file C64.cpp.

References fread, MOS6569::SetState(), and TheVIC.

Referenced by LoadSnapshot().

void C64::NewPrefs Prefs prefs  ) 
 

The preferences have changed. prefs is a pointer to the new preferences, ThePrefs still holds the previous ones. The emulation must be in the paused state!

Definition at line 262 of file C64.cpp.

References MOS6502_1541::AsyncReset(), ELOG1, Prefs::Emul1541Proc, Prefs::FastReset, Prefs::Joystick1On, Prefs::Joystick2On, MOS6581::NewPrefs(), REU::NewPrefs(), Job1541::NewPrefs(), IEC::NewPrefs(), C64Display::NewPrefs(), open_close_joysticks(), PatchKernal(), TheCPU1541, TheDisplay, TheIEC, TheJob1541, ThePrefs, TheREU, and TheSID.

Referenced by LoadSnapshot(), and CPrefsDialog::OkToExitL().

void C64::NMI void   ) 
 

NMI C64

Definition at line 253 of file C64.cpp.

References MOS6510::AsyncNMI(), and TheCPU.

void C64::open_close_joysticks bool  oldjoy1,
bool  oldjoy2,
bool  newjoy1,
bool  newjoy2
[private]
 

Definition at line 149 of file C64_Acorn.i.

References Joystick_Read().

Referenced by C64(), NewPrefs(), and ~C64().

void C64::PatchKernal bool  fast_reset,
bool  emul_1541_proc
 

Patch kernal IEC routines

Definition at line 304 of file C64.cpp.

References Kernal, orig_kernal_1d84, orig_kernal_1d85, and ROM1541.

Referenced by NewPrefs(), and Run().

bool C64::Paused void   ) 
 

Return ETrue if the emulator is paused

Definition at line 316 of file c64_epoc32.i.

References have_a_break.

Referenced by CPrefsDialog::OkToExitL(), and CE32FrodoAppUi::SetPauseState().

uint8 C64::poll_joystick int  port  )  [private]
 

Definition at line 158 of file C64_Acorn.i.

References JoyButton1, JoyButton2, JoyDir_Thresh, Joystick_Read(), and uint8.

Referenced by VBlank().

void C64::Quit void   ) 
 

Stop emulation

Definition at line 319 of file C64_Acorn.i.

References quit_thyself, and thread_running.

Referenced by CE32FrodoAppUi::HandleCommandL().

void C64::Reset void   ) 
 

Definition at line 232 of file C64.cpp.

References MOS6502_1541::AsyncReset(), MOS6510::AsyncReset(), ELOG1, IEC::Reset(), MOS6526_2::Reset(), MOS6526_1::Reset(), MOS6581::Reset(), C64Display::ResetKeyboardState(), TheCIA1, TheCIA2, TheCPU, TheCPU1541, TheDisplay, TheIEC, and TheSID.

Referenced by CE32FrodoAppUi::HandleCommandL(), MOS6510::illegal_jump(), MOS6502_1541::illegal_jump(), MOS6510::illegal_op(), MOS6502_1541::illegal_op(), and LoadSnapshot().

void C64::Run void   ) 
 

Start emulation

Todo:
enable SID

Definition at line 299 of file C64_Acorn.i.

References Prefs::Emul1541Proc, Prefs::FastReset, have_a_break, Kernal, orig_kernal_1d84, orig_kernal_1d85, PatchKernal(), quit_thyself, MOS6502_1541::Reset(), MOS6526_2::Reset(), MOS6526_1::Reset(), MOS6581::Reset(), MOS6510::Reset(), TheCIA1, TheCIA2, TheCPU, TheCPU1541, ThePrefs, TheSID, thread_func(), and thread_running.

Referenced by Frodo::ReadyToRun().

bool C64::Save1541JobState FILE *  f  ) 
 

Save 1541 GCR state to snapshot

Definition at line 560 of file C64.cpp.

References fwrite, Job1541::GetState(), and TheJob1541.

Referenced by SaveSnapshot().

int C64::Save1541State FILE *  f  ) 
 

Definition at line 432 of file C64.cpp.

References fwrite, MOS6502_1541::GetState(), MOS6502State::idle, MOS6502State::instruction_complete, RAM1541, and TheCPU1541.

Referenced by SaveSnapshot().

bool C64::SaveCIAState FILE *  f  ) 
 

Save CIA states to snapshot

Definition at line 525 of file C64.cpp.

References fwrite, MOS6526::GetState(), TheCIA1, and TheCIA2.

Referenced by SaveSnapshot().

int C64::SaveCPUState FILE *  f  ) 
 

Save CPU state to snapshot

0: Error 1: OK -1: Instruction not completed

Definition at line 390 of file C64.cpp.

References Color, fwrite, MOS6510::GetState(), MOS6510State::instruction_complete, RAM, and TheCPU.

Referenced by SaveSnapshot().

void C64::SaveRAM char *  filename  ) 
 

Save RAM contents

Definition at line 370 of file C64.cpp.

References Color, Prefs::Emul1541Proc, fclose, FILE, fopen, fwrite, RAM, RAM1541, ShowRequester(), and ThePrefs.

bool C64::SaveSIDState FILE *  f  ) 
 

Save SID state to snapshot

Definition at line 498 of file C64.cpp.

References fwrite, MOS6581::GetState(), and TheSID.

Referenced by SaveSnapshot().

void C64::SaveSnapshot char *  filename  ) 
 

Save snapshot (emulation must be paused and in VBlank)

To be able to use SC snapshots with SL, SC snapshots are made thus that no partially dealt with instructions are saved. Instead all devices are advanced cycle by cycle until the current instruction has been finished. The number of cycles this takes is saved in the snapshot and will be reconstructed if the snapshot is loaded into FrodoSC again.

Definition at line 601 of file C64.cpp.

References ADVANCE_CYCLES, Prefs::DrivePath, Prefs::Emul1541Proc, fclose, FILE, fopen, fprintf, fputc, fwrite, Save1541JobState(), Save1541State(), SaveCIAState(), SaveCPUState(), SaveSIDState(), SaveVICState(), ShowRequester(), SNAPSHOT_1541, SNAPSHOT_HEADER, stat, ThePrefs, and uint8.

Referenced by VBlank().

bool C64::SaveVICState FILE *  f  ) 
 

Save VIC state to snapshot

Definition at line 472 of file C64.cpp.

References fwrite, MOS6569::GetState(), and TheVIC.

Referenced by SaveSnapshot().

void C64::thread_func  ) 
 

Definition at line 340 of file C64_Acorn.i.

References Prefs::CIACycles, MOS6502_1541::CountVIATimers(), Prefs::Emul1541Proc, MOS6502_1541::EmulateLine(), MOS6510::EmulateLine(), MOS6526::EmulateLine(), MOS6569::EmulateLine(), MOS6581::EmulateLine(), Prefs::FloppyCycles, have_a_break, MOS6502_1541::Idle, OS_FlushBuffer(), OS_ReadMonotonicTime(), quit_thyself, ReadKeyboardStatus(), SetMousePointer(), TheCIA1, TheCIA2, TheCPU, TheCPU1541, TheDisplay, ThePrefs, TheSID, and TheVIC.

Referenced by Run(), and RunThreadFunc().

bool C64::TogglePause void   ) 
 

The emulation's main loop

Definition at line 303 of file c64_epoc32.i.

References have_a_break, iFrodoPtr, iSoundHaveBeenPaused, and Frodo::StartC64().

Referenced by CPrefsDialog::OkToExitL(), and CE32FrodoAppUi::SetPauseState().

void C64::VBlank bool  draw_frame  ) 
 

Vertical blank: Poll keyboard and joysticks, update window

Todo:
saving snapshots on 9210 takes 9 seconds (!) this is too slow. Considering using Store here instead of FS directly.

Definition at line 196 of file C64_Acorn.i.

References Icon_Pane_Speed, joykey, MOS6526_1::Joystick1, Prefs::Joystick1On, MOS6526_1::Joystick2, Prefs::Joystick2On, MOS6526_1::KeyMatrix, Prefs::LimitSpeed, OS_FlushBuffer(), OS_ReadMonotonicTime(), poll_joystick(), C64Display::PollKeyboard(), ReadKeyboardStatus(), MOS6526_1::RevMatrix, SaveSnapshot(), SetMousePointer(), sprintf, TheCIA1, TheDisplay, ThePrefs, uint8, and C64Display::Update().

Referenced by MOS6569::vblank().


Member Data Documentation

uint8 * C64::Basic
 

Definition at line 118 of file C64.h.

Referenced by C64(), Frodo::load_rom_files(), and ~C64().

uint8 * C64::Char
 

Definition at line 118 of file C64.h.

Referenced by C64(), Frodo::load_rom_files(), and ~C64().

uint8 * C64::Color
 

Definition at line 118 of file C64.h.

Referenced by C64(), LoadCPUState(), SaveCPUState(), SaveRAM(), and ~C64().

bool C64::have_a_break
 

Emulation thread shall pause.

Definition at line 138 of file C64.h.

Referenced by C64(), Paused(), Run(), RunThreadFunc(), thread_func(), and TogglePause().

Frodo* C64::iFrodoPtr
 

Definition at line 194 of file C64.h.

Referenced by DigitalRenderer::reset_sync(), C64Display::ResetKeyboardState(), and TogglePause().

TBool C64::iIsAudioPending
 

Definition at line 136 of file C64.h.

Referenced by C64(), and RunThreadFunc().

CJoyPadObserver* C64::iJoyPadObserver
 

Definition at line 200 of file C64.h.

Referenced by C64(), and ~C64().

TBool C64::iSoundHaveBeenPaused
 

Definition at line 137 of file C64.h.

Referenced by TogglePause().

int C64::joy_maxx [private]
 

Definition at line 154 of file C64.h.

int C64::joy_maxy [private]
 

Definition at line 154 of file C64.h.

int C64::joy_minx [private]
 

Definition at line 154 of file C64.h.

int C64::joy_miny [private]
 

Definition at line 154 of file C64.h.

int C64::joyfd[2]
 

Definition at line 197 of file C64.h.

uint8 C64::joykey [private]
 

Definition at line 155 of file C64.h.

Referenced by C64(), and VBlank().

uint8 * C64::Kernal
 

Definition at line 118 of file C64.h.

Referenced by C64(), Frodo::load_rom_files(), PatchKernal(), Run(), and ~C64().

uint8 C64::orig_kernal_1d84 [private]
 

Definition at line 157 of file C64.h.

Referenced by PatchKernal(), and Run().

uint8 C64::orig_kernal_1d85 [private]
 

Definition at line 157 of file C64.h.

Referenced by PatchKernal(), and Run().

bool C64::quit_thyself [private]
 

Definition at line 152 of file C64.h.

Referenced by C64(), Quit(), Run(), and thread_func().

uint8* C64::RAM
 

Definition at line 118 of file C64.h.

Referenced by C64(), LoadCPUState(), SaveCPUState(), SaveRAM(), and ~C64().

uint8* C64::RAM1541
 

Definition at line 120 of file C64.h.

Referenced by C64(), Load1541State(), Save1541State(), SaveRAM(), and ~C64().

uint8 * C64::ROM1541
 

Definition at line 120 of file C64.h.

Referenced by C64(), Frodo::load_rom_files(), PatchKernal(), and ~C64().

double C64::speed_index
 

Definition at line 198 of file C64.h.

MOS6526_1* C64::TheCIA1
 

Definition at line 127 of file C64.h.

Referenced by C64(), LoadCIAState(), LoadSnapshot(), Reset(), Run(), SAM(), SaveCIAState(), thread_func(), VBlank(), and ~C64().

MOS6526_2* C64::TheCIA2
 

Definition at line 128 of file C64.h.

Referenced by C64(), LoadCIAState(), LoadSnapshot(), Reset(), Run(), SAM(), SaveCIAState(), thread_func(), and ~C64().

MOS6510* C64::TheCPU
 

Definition at line 124 of file C64.h.

Referenced by C64(), LoadCPUState(), LoadSnapshot(), NMI(), Reset(), Run(), SAM(), SaveCPUState(), thread_func(), and ~C64().

MOS6502_1541* C64::TheCPU1541
 

Definition at line 132 of file C64.h.

Referenced by C64(), Load1541State(), NewPrefs(), Reset(), Run(), SAM(), Save1541State(), thread_func(), and ~C64().

C64Display* C64::TheDisplay
 

Definition at line 122 of file C64.h.

Referenced by C64(), NewPrefs(), Reset(), thread_func(), VBlank(), and ~C64().

IEC* C64::TheIEC
 

Definition at line 129 of file C64.h.

Referenced by C64(), NewPrefs(), Reset(), and ~C64().

Job1541* C64::TheJob1541
 

Definition at line 133 of file C64.h.

Referenced by C64(), Load1541JobState(), NewPrefs(), Save1541JobState(), and ~C64().

Prefs& C64::ThePrefs
 

Definition at line 217 of file C64.h.

Referenced by C64Display::BuildColorTable(), C64(), CE32FrodoAppUi::ConstructL(), CE32FrodoAppUi::HandleCommandL(), LoadSnapshot(), NewPrefs(), Run(), SaveRAM(), SaveSnapshot(), CE32FrodoAppUi::SetFullScreenModeL(), thread_func(), VBlank(), and ~C64().

Prefs& C64::ThePrefsOnDisk
 

Definition at line 218 of file C64.h.

Referenced by C64(), and ~C64().

REU* C64::TheREU
 

Definition at line 130 of file C64.h.

Referenced by C64(), NewPrefs(), and ~C64().

MOS6581* C64::TheSID
 

Definition at line 126 of file C64.h.

Referenced by C64(), LoadSIDState(), NewPrefs(), Reset(), Run(), SAM(), SaveSIDState(), thread_func(), and ~C64().

MOS6569* C64::TheVIC
 

Definition at line 125 of file C64.h.

Referenced by C64Display::BuildColorTable(), C64(), LoadSnapshot(), LoadVICState(), SAM(), SaveVICState(), thread_func(), and ~C64().

bool C64::thread_running [private]
 

Definition at line 151 of file C64.h.

Referenced by C64(), Quit(), and Run().

struct timeval C64::tv_start
 

Definition at line 199 of file C64.h.


The documentation for this class was generated from the following files:
Generated on Tue Feb 8 04:11:35 2005 for E32frodo by doxygen 1.3.3