ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/Frodo4/Src/C64.h
Revision: 1.8
Committed: 2010-04-21T21:59:11Z (13 years, 11 months ago) by cebix
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Changes since 1.7: +2 -6 lines
Log Message:
keep object size the same whether FRODO_SC is defined or not

File Contents

# Content
1 /*
2 * C64.h - Put the pieces together
3 *
4 * Frodo Copyright (C) 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 uint32 CycleCounter; // Cycle counter for Frodo SC
114
115 private:
116 void c64_ctor1(void);
117 void c64_ctor2(void);
118 void c64_dtor(void);
119 void open_close_joysticks(int oldjoy1, int oldjoy2, int newjoy1, int newjoy2);
120 uint8 poll_joystick(int port);
121 void thread_func(void);
122
123 bool thread_running; // Emulation thread is running
124 bool quit_thyself; // Emulation thread shall quit
125 bool have_a_break; // Emulation thread shall pause
126
127 int joy_minx[2], joy_maxx[2], joy_miny[2], joy_maxy[2]; // For dynamic joystick calibration
128 uint8 joykey; // Joystick keyboard emulation mask value
129
130 uint8 orig_kernal_1d84, // Original contents of kernal locations $1d84 and $1d85
131 orig_kernal_1d85; // (for undoing the Fast Reset patch)
132
133 #ifdef __BEOS__
134 public:
135 void SoundSync(void);
136
137 private:
138 static long thread_invoc(void *obj);
139 void open_close_joystick(int port, int oldjoy, int newjoy);
140
141 void *joy[2]; // Joystick objects (BJoystick or BDigitalPort)
142 bool joy_geek_port[2]; // Flag: joystick on GeekPort?
143 thread_id the_thread;
144 sem_id pause_sem;
145 sem_id sound_sync_sem;
146 bigtime_t start_time;
147 #endif
148
149 #ifdef AMIGA
150 struct MsgPort *timer_port; // For speed limiter
151 struct timerequest *timer_io;
152 struct timeval start_time;
153 struct MsgPort *game_port; // For joystick
154 struct IOStdReq *game_io;
155 struct GamePortTrigger game_trigger;
156 struct InputEvent game_event;
157 UBYTE joy_state; // Current state of joystick
158 bool game_open, port_allocated; // Flags: gameport.device opened, game port allocated
159 #endif
160
161 #ifdef __unix
162 void open_close_joystick(int port, int oldjoy, int newjoy);
163 double speed_index;
164 #endif
165
166 #ifdef WIN32
167 private:
168 void CheckTimerChange();
169 void StartTimer();
170 void StopTimer();
171 static void CALLBACK StaticTimeProc(UINT uID, UINT uMsg, DWORD dwUser, DWORD dw1, DWORD dw2);
172 void TimeProc(UINT id);
173 #ifdef FRODO_SC
174 void EmulateCyclesWith1541();
175 void EmulateCyclesWithout1541();
176 #endif
177
178 DWORD ref_time; // when frame count was reset
179 int skipped_frames; // number of skipped frames
180 int timer_every; // frequency of timer in frames
181 HANDLE timer_semaphore; // Timer semaphore for synch
182 MMRESULT timer_id; // Timer identifier
183 int frame; // current frame number
184 uint8 joy_state; // Current state of joystick
185 bool state_change;
186 #endif
187
188 #ifdef __riscos__
189 public:
190 void RequestSnapshot(void);
191 bool LoadOldSnapshot(FILE *f);
192 void LoadSystemConfig(const char *filename); // loads timing vals and keyboard joys
193 void SaveSystemConfig(const char *filename); // saves timing vals and keyboard joys
194 void ReadTimings(int *poll_after, int *speed_after, int *sound_after);
195 void WriteTimings(int poll_after, int speed_after, int sound_after);
196
197 WIMP *TheWIMP;
198 int PollAfter; // centiseconds before polling
199 int SpeedAfter; // centiseconds before updating speedometer
200 int PollSoundAfter; // *rasterlines* after which DigitalRenderer is polled
201 int HostVolume; // sound volume of host machine
202
203 private:
204 bool make_a_snapshot;
205
206 uint8 joykey2; // two keyboard joysticks possible here
207
208 uint8 joystate[2]; // Joystick state
209 bool Poll; // TRUE if polling should take place
210 int LastPoll, LastFrame, LastSpeed; // time of last poll / last frame / speedom (cs)
211 int FramesSince;
212 int laststate; // last keyboard state (-> scroll lock)
213 int lastptr; // last mouse pointer shape
214 bool SingleTasking;
215 #endif
216 };
217
218
219 #endif