forked from pete-gordon/oricutron
-
Notifications
You must be signed in to change notification settings - Fork 0
/
machine.h
282 lines (239 loc) · 6.82 KB
/
machine.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
/*
** Oricutron
** Copyright (C) 2009-2014 Peter Gordon
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
** as published by the Free Software Foundation, version 2
** of the License.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**
** Oric machine stuff
*/
#include <stdio.h>
#include "keyboard.h"
enum
{
DRV_NONE = 0,
DRV_JASMIN,
DRV_MICRODISC,
DRV_PRAVETZ
};
enum
{
MACH_ORIC1 = 0,
MACH_ORIC1_16K,
MACH_ATMOS,
MACH_TELESTRAT,
MACH_PRAVETZ,
MACH_LAST
};
enum
{
EM_PAUSED = 0,
EM_RUNNING,
EM_DEBUG,
EM_MENU,
EM_PLEASEQUIT
};
enum
{
TELEBANK_RAM,
TELEBANK_ROM,
TELEBANK_HALFNHALF
};
enum
{
KMAP_QWERTY = 0,
KMAP_AZERTY,
KMAP_QWERTZ
};
/* Return values from detect_image_type */
enum
{
IMG_I_DUNNO = 0,
IMG_ATMOS_MICRODISC,
IMG_ATMOS_JASMIN,
IMG_TELESTRAT_DISK,
IMG_PRAVETZ_DISK,
IMG_GUESS_MICRODISC,
IMG_SNAPSHOT,
IMG_TAPE
};
struct telebankinfo
{
unsigned char type;
unsigned char *ptr;
};
struct machine
{
Uint8 type;
struct m6502 cpu;
struct via via;
struct ay8912 ay;
unsigned int memsize;
unsigned char *mem;
unsigned char *rom;
int emu_mode;
struct symboltable romsyms;
struct symboltable usersyms;
struct symboltable *disksyms;
struct telebankinfo tele_bank[8];
struct symboltable tele_banksyms[8];
struct via tele_via;
struct acia tele_acia;
struct ch376 *ch376;
SDL_bool ch376_activated;
int tele_currbank;
unsigned char tele_banktype;
// Video
int vid_start; // Start drawing video
int vid_end; // Stop drawing video
int vid_maxrast; // Number of raster lines
int vid_raster; // Current rasterline
int vid_offset; // Current T1 counter position
int vid_fg_col;
int vid_bg_col;
Uint16 *vid_bitptr;
Uint16 *vid_inv_bitptr;
int vid_mode;
int vid_freq;
int vid_textattrs;
int vid_blinkmask;
int vid_chline;
int frames;
SDL_bool vid_dirty[224];
void (*vid_block_func)( struct machine *, SDL_bool, int, int );
int overclockmult, overclockshift;
int cyclesperraster;
int vsync;
SDL_bool vid_double;
SDL_bool romdis, romon;
SDL_bool vsynchack;
unsigned short vid_addr;
unsigned char *vid_ch_data;
unsigned char *vid_ch_base;
Uint8 *scrpt;
Uint8 *scr;
Uint16 vidbases[4];
int drivetype;
struct wd17xx wddisk;
struct microdisc md;
struct jasmin jasmin;
struct pravetz pravetz;
char diskname[MAX_DRIVES][32];
SDL_bool diskautosave;
SDL_bool auto_jasmin_reset;
FILE *prf;
int prclose, prclock;
unsigned char tapebit, tapeout, tapeparity;
int tapelen, tapeoffs, tapecount, tapetime, tapedupbytes, tapehdrend, tapedelay;
unsigned char *tapebuf;
SDL_bool tapemotor, tapenoise, tapeturbo, autorewind, autoinsert;
SDL_bool tapeturbo_forceoff;
SDL_bool symbolsautoload, symbolscase;
SDL_bool rawtape;
int nonrawend, tapehitend;
char lasttapefile[20];
char tapename[32];
int tapeturbo_syncstack;
FILE *tapecap;
int tapecapcount;
int tapecaplastbit;
int tapecapsavbytes;
int tapecapsavoffs;
// Filename decoding patch addresses
int pch_fd_cload_getname_pc;
int pch_fd_csave_getname_pc;
int pch_fd_store_getname_pc;
int pch_fd_recall_getname_pc;
int pch_fd_getname_addr;
SDL_bool pch_fd_available;
// Turbo tape patch addresses
int pch_tt_getsync_pc;
int pch_tt_getsync_end_pc;
int pch_tt_getsync_loop_pc;
int pch_tt_readbyte_pc;
int pch_tt_readbyte_end_pc;
int pch_tt_readbyte_storebyte_addr;
int pch_tt_readbyte_storezero_addr;
int pch_tt_putbyte_pc;
int pch_tt_putbyte_end_pc;
int pch_tt_csave_end_pc;
int pch_tt_store_end_pc;
int pch_tt_writeleader_pc;
int pch_tt_writeleader_end_pc;
SDL_bool pch_tt_readbyte_setcarry;
SDL_bool pch_tt_available;
SDL_bool pch_tt_save_available;
FILE *tsavf;
Sint32 keymap;
SDL_bool aratio, hstretch, scanlines, palghost, pravdiskautoboot;
Sint32 sw_depth; // Bit depth of the emulator video mode
int rendermode;
void (*render_begin)(struct machine *);
void (*render_end)(struct machine *);
void (*render_textzone_alloc)(struct machine *, int);
void (*render_textzone_free)(struct machine *, int);
void (*render_textzone)(struct machine *, int);
void (*render_clear_area)( int, int, int, int );
void (*render_gimg)(int, Sint32, Sint32);
void (*render_gimgpart)(int, Sint32, Sint32, Sint32, Sint32, Sint32, Sint32);
void (*render_alloc_textzone)(struct machine *, struct textzone *);
void (*render_free_textzone)(struct machine *, struct textzone *);
void (*render_video)(struct machine *, SDL_bool);
SDL_bool (*render_togglefullscreen)(struct machine *oric);
SDL_bool (*init_render)(struct machine *);
void (*shut_render)(struct machine *);
char popupstr[40];
int popuptime;
SDL_bool newpopupstr;
char statusstr[40];
SDL_bool newstatusstr;
int statusbar_mode;
int rampattern;
Sint32 joy_iface;
Sint32 joymode_a, joymode_b;
Sint32 telejoymode_a, telejoymode_b;
SDL_COMPAT_KEY kbjoy1[7], kbjoy2[7];
SDL_bool printenable;
SDL_bool printfilter;
SDL_bool lightpen;
Uint8 lightpenx, lightpeny;
unsigned char (*read_not_lightpen)(struct m6502 *,Uint16);
Uint8 porta_joy, porta_ay;
SDL_bool porta_is_ay;
SDL_Joystick *sdljoy_a, *sdljoy_b;
struct keyboard_mapping keyboard_mapping;
SDL_bool show_keyboard;
SDL_bool define_mapping;
SDL_bool sticky_mod_keys;
int aciaoffset;
int aciabackend;
int aciabackendcfg;
int aciabackendcfgport;
int aciabackendcfgdomain;
char aciabackendname[ACIA_BACKEND_NAME_LEN];
};
void setromon( struct machine *oric );
void setemumode( struct machine *oric, struct osdmenuitem *mitem, int mode );
void video_show( struct machine *oric );
SDL_bool emu_event( SDL_Event *ev, struct machine *oric, SDL_bool *needrender );
void preinit_machine( struct machine *oric );
void load_diskroms( struct machine *oric );
SDL_bool init_machine( struct machine *oric, int type, SDL_bool nukebreakpoints );
void shut_machine( struct machine *oric );
void setdrivetype( struct machine *oric, struct osdmenuitem *mitem, int type );
void swapmach( struct machine *oric, struct osdmenuitem *mitem, int which );
SDL_bool isram( struct machine *oric, unsigned short addr );
void clear_patches( struct machine *oric );
unsigned char lightpen_read( struct m6502 *cpu, unsigned short addr );
int detect_image_type(char *filename);