1 |
/* |
2 |
* C64.h - Put the pieces together |
3 |
* |
4 |
* Frodo (C) 1994-1997,2002-2003 Christian Bauer |
5 |
* |
6 |
* This program is free software; you can redistribute it and/or modify |
7 |
* it under the terms of the GNU General Public License as published by |
8 |
* the Free Software Foundation; either version 2 of the License, or |
9 |
* (at your option) any later version. |
10 |
* |
11 |
* This program is distributed in the hope that it will be useful, |
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 |
* GNU General Public License for more details. |
15 |
* |
16 |
* You should have received a copy of the GNU General Public License |
17 |
* along with this program; if not, write to the Free Software |
18 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
19 |
*/ |
20 |
|
21 |
#ifndef _C64_H |
22 |
#define _C64_H |
23 |
|
24 |
#ifdef __BEOS__ |
25 |
#include <KernelKit.h> |
26 |
#endif |
27 |
|
28 |
#ifdef AMIGA |
29 |
#include <devices/timer.h> |
30 |
#include <devices/gameport.h> |
31 |
#include <devices/inputevent.h> |
32 |
#endif |
33 |
|
34 |
#ifdef __riscos__ |
35 |
#include "ROlib.h" |
36 |
#endif |
37 |
|
38 |
|
39 |
// Sizes of memory areas |
40 |
const int C64_RAM_SIZE = 0x10000; |
41 |
const int COLOR_RAM_SIZE = 0x400; |
42 |
const int BASIC_ROM_SIZE = 0x2000; |
43 |
const int KERNAL_ROM_SIZE = 0x2000; |
44 |
const int CHAR_ROM_SIZE = 0x1000; |
45 |
const int DRIVE_RAM_SIZE = 0x800; |
46 |
const int DRIVE_ROM_SIZE = 0x4000; |
47 |
|
48 |
|
49 |
// false: Frodo, true: FrodoSC |
50 |
extern bool IsFrodoSC; |
51 |
|
52 |
|
53 |
class Prefs; |
54 |
class C64Display; |
55 |
class MOS6510; |
56 |
class MOS6569; |
57 |
class MOS6581; |
58 |
class MOS6526_1; |
59 |
class MOS6526_2; |
60 |
class IEC; |
61 |
class REU; |
62 |
class MOS6502_1541; |
63 |
class Job1541; |
64 |
class CmdPipe; |
65 |
|
66 |
class C64 { |
67 |
public: |
68 |
C64(); |
69 |
~C64(); |
70 |
|
71 |
void Run(void); |
72 |
void Quit(void); |
73 |
void Pause(void); |
74 |
void Resume(void); |
75 |
void Reset(void); |
76 |
void NMI(void); |
77 |
void VBlank(bool draw_frame); |
78 |
void NewPrefs(Prefs *prefs); |
79 |
void PatchKernal(bool fast_reset, bool emul_1541_proc); |
80 |
void SaveRAM(char *filename); |
81 |
void SaveSnapshot(char *filename); |
82 |
bool LoadSnapshot(char *filename); |
83 |
int SaveCPUState(FILE *f); |
84 |
int Save1541State(FILE *f); |
85 |
bool Save1541JobState(FILE *f); |
86 |
bool SaveVICState(FILE *f); |
87 |
bool SaveSIDState(FILE *f); |
88 |
bool SaveCIAState(FILE *f); |
89 |
bool LoadCPUState(FILE *f); |
90 |
bool Load1541State(FILE *f); |
91 |
bool Load1541JobState(FILE *f); |
92 |
bool LoadVICState(FILE *f); |
93 |
bool LoadSIDState(FILE *f); |
94 |
bool LoadCIAState(FILE *f); |
95 |
|
96 |
uint8 *RAM, *Basic, *Kernal, |
97 |
*Char, *Color; // C64 |
98 |
uint8 *RAM1541, *ROM1541; // 1541 |
99 |
|
100 |
C64Display *TheDisplay; |
101 |
|
102 |
MOS6510 *TheCPU; // C64 |
103 |
MOS6569 *TheVIC; |
104 |
MOS6581 *TheSID; |
105 |
MOS6526_1 *TheCIA1; |
106 |
MOS6526_2 *TheCIA2; |
107 |
IEC *TheIEC; |
108 |
REU *TheREU; |
109 |
|
110 |
MOS6502_1541 *TheCPU1541; // 1541 |
111 |
Job1541 *TheJob1541; |
112 |
|
113 |
#ifdef FRODO_SC |
114 |
uint32 CycleCounter; |
115 |
#endif |
116 |
|
117 |
private: |
118 |
void c64_ctor1(void); |
119 |
void c64_ctor2(void); |
120 |
void c64_dtor(void); |
121 |
void open_close_joysticks(int oldjoy1, int oldjoy2, int newjoy1, int newjoy2); |
122 |
uint8 poll_joystick(int port); |
123 |
void thread_func(void); |
124 |
|
125 |
bool thread_running; // Emulation thread is running |
126 |
bool quit_thyself; // Emulation thread shall quit |
127 |
bool have_a_break; // Emulation thread shall pause |
128 |
|
129 |
int joy_minx[2], joy_maxx[2], joy_miny[2], joy_maxy[2]; // For dynamic joystick calibration |
130 |
uint8 joykey; // Joystick keyboard emulation mask value |
131 |
|
132 |
uint8 orig_kernal_1d84, // Original contents of kernal locations $1d84 and $1d85 |
133 |
orig_kernal_1d85; // (for undoing the Fast Reset patch) |
134 |
|
135 |
#ifdef __BEOS__ |
136 |
public: |
137 |
void SoundSync(void); |
138 |
|
139 |
private: |
140 |
static long thread_invoc(void *obj); |
141 |
void open_close_joystick(int port, int oldjoy, int newjoy); |
142 |
|
143 |
void *joy[2]; // Joystick objects (BJoystick or BDigitalPort) |
144 |
bool joy_geek_port[2]; // Flag: joystick on GeekPort? |
145 |
thread_id the_thread; |
146 |
sem_id pause_sem; |
147 |
sem_id sound_sync_sem; |
148 |
bigtime_t start_time; |
149 |
#endif |
150 |
|
151 |
#ifdef AMIGA |
152 |
struct MsgPort *timer_port; // For speed limiter |
153 |
struct timerequest *timer_io; |
154 |
struct timeval start_time; |
155 |
struct MsgPort *game_port; // For joystick |
156 |
struct IOStdReq *game_io; |
157 |
struct GamePortTrigger game_trigger; |
158 |
struct InputEvent game_event; |
159 |
UBYTE joy_state; // Current state of joystick |
160 |
bool game_open, port_allocated; // Flags: gameport.device opened, game port allocated |
161 |
#endif |
162 |
|
163 |
#ifdef __unix |
164 |
void open_close_joystick(int port, int oldjoy, int newjoy); |
165 |
double speed_index; |
166 |
public: |
167 |
CmdPipe *gui; |
168 |
#endif |
169 |
|
170 |
#ifdef WIN32 |
171 |
private: |
172 |
void CheckTimerChange(); |
173 |
void StartTimer(); |
174 |
void StopTimer(); |
175 |
static void CALLBACK StaticTimeProc(UINT uID, UINT uMsg, DWORD dwUser, DWORD dw1, DWORD dw2); |
176 |
void TimeProc(UINT id); |
177 |
#ifdef FRODO_SC |
178 |
void EmulateCyclesWith1541(); |
179 |
void EmulateCyclesWithout1541(); |
180 |
#endif |
181 |
|
182 |
DWORD ref_time; // when frame count was reset |
183 |
int skipped_frames; // number of skipped frames |
184 |
int timer_every; // frequency of timer in frames |
185 |
HANDLE timer_semaphore; // Timer semaphore for synch |
186 |
MMRESULT timer_id; // Timer identifier |
187 |
int frame; // current frame number |
188 |
uint8 joy_state; // Current state of joystick |
189 |
bool state_change; |
190 |
#endif |
191 |
|
192 |
#ifdef __riscos__ |
193 |
public: |
194 |
void RequestSnapshot(void); |
195 |
bool LoadOldSnapshot(FILE *f); |
196 |
void LoadSystemConfig(const char *filename); // loads timing vals and keyboard joys |
197 |
void SaveSystemConfig(const char *filename); // saves timing vals and keyboard joys |
198 |
void ReadTimings(int *poll_after, int *speed_after, int *sound_after); |
199 |
void WriteTimings(int poll_after, int speed_after, int sound_after); |
200 |
|
201 |
WIMP *TheWIMP; |
202 |
int PollAfter; // centiseconds before polling |
203 |
int SpeedAfter; // centiseconds before updating speedometer |
204 |
int PollSoundAfter; // *rasterlines* after which DigitalRenderer is polled |
205 |
int HostVolume; // sound volume of host machine |
206 |
|
207 |
private: |
208 |
bool make_a_snapshot; |
209 |
|
210 |
uint8 joykey2; // two keyboard joysticks possible here |
211 |
|
212 |
uint8 joystate[2]; // Joystick state |
213 |
bool Poll; // TRUE if polling should take place |
214 |
int LastPoll, LastFrame, LastSpeed; // time of last poll / last frame / speedom (cs) |
215 |
int FramesSince; |
216 |
int laststate; // last keyboard state (-> scroll lock) |
217 |
int lastptr; // last mouse pointer shape |
218 |
bool SingleTasking; |
219 |
#endif |
220 |
}; |
221 |
|
222 |
|
223 |
#endif |