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