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