Subversion Repositories pentevo

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
716 lvd 1
#include "std.h"
2
 
3
#include "emul.h"
4
#include "vars.h"
5
#include "debug.h"
6
#include "memory.h"
7
#include "gsz80.h"
8
#include "z80.h"
9
#include "util.h"
10
 
11
namespace z80fast
12
{
13
#include "z80_main.h"
14
}
15
 
16
#include "sndrender/sndcounter.h"
17
 
18
int fmsoundon0=4; //Alone Coder
19
int tfmstatuson0=2; //Alone Coder
20
char pressedit = 0; //Alone Coder
21
 
22
void __fastcall wmdbg(u32 addr, u8 val);
23
u8 __fastcall rmdbg(u32 addr);
24
u8 *__fastcall MemDbg(u32 addr);
25
void __cdecl BankNames(int i, char *Name);
26
namespace z80dbg
27
{
28
void Z80FAST step();
29
__int64 __cdecl delta();
30
void __cdecl SetLastT();
31
}
32
 
33
#pragma pack(8)
34
 
35
void out(unsigned port, unsigned char val);
36
unsigned char in(unsigned port);
37
 
38
Z80INLINE unsigned char m1_cycle(Z80 *cpu)
39
{
40
   cpu->r_low++; cpu->t += 4;
41
   return cpu->MemIf->xm(cpu->pc++);
42
}
43
 
44
/*
45
unsigned char TMainZ80::rm(unsigned addr) { return z80fast::rm(addr); }
46
 
47
unsigned char TMainZ80::dbgrm(unsigned addr) { return ::rmdbg(addr); }
48
 
49
void TMainZ80::wm(unsigned addr, unsigned char val) { z80fast::wm(addr, val); }
50
 
51
void TMainZ80::dbgwm(unsigned addr, unsigned char val) { ::wmdbg(addr, val); }
52
*/
53
u8 *TMainZ80::DirectMem(unsigned addr) const
54
{
55
    return am_r(addr);
56
}
57
 
58
unsigned char TMainZ80::m1_cycle() { return ::m1_cycle(this); }
59
 
60
unsigned char TMainZ80::in(unsigned port) { return ::in(port); }
61
 
62
void TMainZ80::out(unsigned port, unsigned char val) { ::out(port, val); }
63
 
64
u8 TMainZ80::IntVec()
65
{
66
    return (comp.flags & CF_Z80FBUS)? u8(rdtsc() & 0xFF) : 0xFF;
67
}
68
 
69
void TMainZ80::CheckNextFrame()
70
{
71
   if(t >= conf.frame)
72
   {
73
       comp.t_states += conf.frame;
74
       t -= conf.frame;
75
       eipos -= conf.frame;
76
       comp.frame_counter++;
77
       int_pend = true;
78
   }
79
}
80
 
81
void TMainZ80::retn()
82
{
83
    nmi_in_progress = false;
84
    set_banks();
85
}
86
 
87
static const TMemIf FastMemIf = { Xm, Rm, Wm };
88
static const TMemIf DbgMemIf = { DbgXm, DbgRm, DbgWm };
89
 
90
 
91
TMainZ80 cpu(0, BankNames, z80dbg::step, z80dbg::delta, z80dbg::SetLastT, membits, &FastMemIf, &DbgMemIf);
92
 
93
 
94
#ifdef MOD_GSZ80
95
namespace z80gs
96
{
97
    u8 __fastcall dbgrm(u32 addr);
98
    void __fastcall dbgwm(u32 addr, u8 val);
99
    u8 *__fastcall MemDbg(u32 addr);
100
    void __cdecl BankNames(int i, char *Name);
101
    void Z80FAST step();
102
    __int64 __cdecl delta();
103
    void __cdecl SetLastT();
104
    u8 membits[0x10000];
105
 
106
    SNDRENDER sound;
107
    static const TMemIf FastMemIf = { z80gs::Xm, z80gs::Rm, z80gs::Wm };
108
    static const TMemIf DbgMemIf = { z80gs::DbgXm, z80gs::DbgRm, z80gs::DbgWm };
109
 
110
}
111
 
112
u8 TGsZ80::IntVec()
113
{
114
    return 0xFF;
115
}
116
 
117
void TGsZ80::CheckNextFrame()
118
{
119
   if(t >= z80gs::GSCPUINT)
120
   {
121
      t -= z80gs::GSCPUINT;
122
      eipos -= z80gs::GSCPUINT;
123
      z80gs::gs_t_states += z80gs::GSCPUINT;
124
      int_pend = true;
125
   }
126
}
127
 
128
TGsZ80 gscpu(1, z80gs::BankNames, z80gs::step, z80gs::delta,
129
    z80gs::SetLastT, z80gs::membits, &z80gs::FastMemIf, &z80gs::DbgMemIf);
130
#endif
131
 
132
TCpuMgr CpuMgr;
133
 
134
void TCpuMgr::SwitchCpu()
135
{
136
    CurrentCpu++;
137
    CurrentCpu %= Count;
138
}
139
 
140
Z80 *TCpuMgr::Cpus[] =
141
{
142
  &cpu,
143
#ifdef MOD_GSZ80
144
  &gscpu
145
#endif
146
};
147
 
148
 
149
const unsigned TCpuMgr::Count = _countof(Cpus);
150
TZ80State TCpuMgr::PrevCpus[TCpuMgr::Count];
151
unsigned TCpuMgr::CurrentCpu = 0;
152
 
153
#ifdef MOD_GSBASS
154
GSHLE gs;
155
#endif
156
 
157
unsigned char dbgbreak = 0;
158
 
159
 
160
CONFIG conf;
161
COMPUTER comp;
162
TEMP temp;
163
ATA_PORT hdd;   // not in `comp' - not cleared in reset()
164
K_INPUT input;
165
ISA_MODEM modem;
166
 
167
SNDRENDER sound;
168
SNDCHIP ay[2];
169
SNDCOUNTER sndcounter;
170
 
171
 
172
unsigned char *base_sos_rom, *base_dos_rom, *base_128_rom, *base_sys_rom;
173
 
174
#ifdef CACHE_ALIGNED
175
ATTR_ALIGN(4096)
176
unsigned char memory[PAGE*MAX_PAGES];
177
#else // __declspec(align) not available, force QWORD align with old method
178
__int64 memory__[PAGE*MAX_PAGES/sizeof(__int64)];
179
unsigned char * const memory = (unsigned char*)memory__;
180
#endif
181
 
182
#ifdef MOD_VID_VD
183
CACHE_ALIGNED unsigned char vdmem[4][0x2000];
184
#endif
185
 
186
unsigned char membits[0x10000];
187
unsigned char *bankr[4];
188
unsigned char *bankw[4];
189
unsigned char cmos[0x100];
190
unsigned char nvram[0x800];
191
 
192
unsigned sndplaybuf[PLAYBUFSIZE];
193
unsigned spbsize;
194
 
195
FILE *savesnd;
196
unsigned char savesndtype; // 0-none,1-wave,2-vtx
197
unsigned char *vtxbuf; unsigned vtxbufsize, vtxbuffilled;
198
 
199
unsigned char trdos_load, trdos_save, trdos_format, trdos_seek; // for leds
200
unsigned char needclr; // clear screenbuffer before rendering
201
 
202
HWND wnd; HINSTANCE hIn;
203
 
204
char droppedFile[512];
205
 
206
const TMemModel mem_model[N_MM_MODELS] =
207
{
208
    { "PENTAGON", "PENTAGON",                MM_PENTAGON, 128,  RAM_128 | RAM_256 | RAM_512 | RAM_1024 },
209
    { "ZS SCORPION", "SCORPION",             MM_SCORP, 256,  RAM_256 | RAM_1024 },
210
    { "ZS SCORPION + PROF ROM", "PROFSCORP", MM_PROFSCORP, 256,  RAM_256 | RAM_1024 },
211
    { "PROFI", "PROFI",                      MM_PROFI, 1024, RAM_1024 },
212
    { "ATM-TURBO v4.50", "ATM450",           MM_ATM450, 512,  RAM_512 | RAM_1024 },
213
    { "ATM-TURBO 2+ v7.10", "ATM710",        MM_ATM710, 1024, RAM_128 | RAM_256 | RAM_512 | RAM_1024 },
214
    { "ATM-TURBO 3", "ATM3",                 MM_ATM3, 4096, RAM_4096 },
215
    { "Nemo's KAY", "KAY",                   MM_KAY, 256,  RAM_256 | RAM_1024 },
216
    { "ZX-Spectrum +3", "PLUS3",             MM_PLUS3, 128,  RAM_128 },
217
    { "QUORUM", "QUORUM",                    MM_QUORUM, 1024, RAM_128 | RAM_1024 },
218
};
219
 
220
unsigned char kbdpc[VK_MAX]; // add cells for mouse & joystick
221
unsigned char kbdpcEX[6]; //Dexus
222
keyports inports[VK_MAX];
223
 
224
char statusline[128];
225
unsigned statcnt;
226
 
227
char arcbuffer[0x2000]; // extensions and command lines for archivers
228
char skiparc[0x400]; // ignore this files in archive
229
 
230
unsigned char exitflag = 0; // avoid call exit() twice
231
 
232
// beta128 vars
233
unsigned trd_toload = 0; // drive to load
234
unsigned DefaultDrive = -1; // „¨áª®¢®¤ ¯® 㬮«ç ­¨î ¢ ª®â®àë© £àã§ïâáï ®¡à §ë ¤¨áª®¢ ¯à¨ áâ àâ¥
235
 
236
char trd_loaded[4]; // used to get first free drive with no account of autoloaded images
237
char ininame[0x200];
238
char helpname[0x200];
239
unsigned snapsize;
240
 
241
// conditional breakpoints support
242
unsigned brk_port_in, brk_port_out;
243
unsigned char brk_port_val;
244
 
245
virtkeyt pckeys[] =
246
{
247
   { "ESC", DIK_ESCAPE },
248
   { "F1", DIK_F1 }, { "F2", DIK_F2 }, { "F3", DIK_F3 },
249
   { "F4", DIK_F4 }, { "F5", DIK_F5 }, { "F6", DIK_F6 },
250
   { "F7", DIK_F7 }, { "F8", DIK_F8 }, { "F9", DIK_F9 },
251
   { "F10", DIK_F10 }, { "F11", DIK_F11 }, { "F12", DIK_F12 },
252
   { "PRSCR", DIK_SYSRQ }, { "SCLOCK", DIK_SCROLL }, { "PAUSE", DIK_PAUSE },
253
 
254
   { "1", DIK_1 }, { "2", DIK_2 }, { "3", DIK_3 }, { "4", DIK_4 }, { "5", DIK_5 },
255
   { "6", DIK_6 }, { "7", DIK_7 }, { "8", DIK_8 }, { "9", DIK_9 }, { "0", DIK_0 },
256
 
257
   { "Q", DIK_Q }, { "W", DIK_W }, { "E", DIK_E }, { "R", DIK_R }, { "T", DIK_T },
258
   { "Y", DIK_Y }, { "U", DIK_U }, { "I", DIK_I }, { "O", DIK_O }, { "P", DIK_P },
259
   { "A", DIK_A }, { "S", DIK_S }, { "D", DIK_D }, { "F", DIK_F }, { "G", DIK_G },
260
   { "H", DIK_H }, { "J", DIK_J }, { "K", DIK_K }, { "L", DIK_L },
261
   { "Z", DIK_Z }, { "X", DIK_X }, { "C", DIK_C }, { "V", DIK_V }, { "B", DIK_B },
262
   { "N", DIK_N }, { "M", DIK_M },
263
 
264
   { "MINUS", DIK_MINUS }, { "PLUS", DIK_EQUALS }, { "BACK", DIK_BACK },
265
   { "TAB", DIK_TAB }, { "LB", DIK_LBRACKET }, { "RB", DIK_RBRACKET },
266
   { "CAPS", DIK_CAPITAL }, { "TIL", DIK_GRAVE }, { "SPACE", DIK_SPACE },
267
   { "COL", DIK_SEMICOLON }, { "QUOTE", DIK_APOSTROPHE }, { "ENTER", DIK_RETURN },
268
   { "COMMA", DIK_COMMA }, { "POINT", DIK_PERIOD }, { "SLASH", DIK_SLASH }, { "BACKSL", DIK_BACKSLASH },
269
   { "SHIFT", DIK_SHIFT }, { "ALT", DIK_MENU }, { "CONTROL", DIK_CONTROL },
270
   { "LSHIFT", DIK_LSHIFT }, { "LALT", DIK_LMENU }, { "LCONTROL", DIK_LCONTROL },
271
   { "RSHIFT", DIK_RSHIFT }, { "RALT", DIK_RMENU }, { "RCONTROL", DIK_RCONTROL },
272
 
273
   { "INS", DIK_INSERT }, { "HOME", DIK_HOME }, { "PGUP", DIK_PRIOR },
274
   { "DEL", DIK_DELETE }, { "END", DIK_END },   { "PGDN", DIK_NEXT },
275
 
276
   { "UP", DIK_UP }, { "DOWN", DIK_DOWN }, { "LEFT", DIK_LEFT }, { "RIGHT", DIK_RIGHT },
277
 
278
   { "NUMLOCK", DIK_NUMLOCK }, { "GRDIV", DIK_DIVIDE },
279
   { "GRMUL", DIK_MULTIPLY }, { "GRSUB", DIK_SUBTRACT }, { "GRADD", DIK_ADD },
280
   { "GRENTER", DIK_NUMPADENTER },
281
 
282
   { "N0", DIK_NUMPAD0 }, { "N1", DIK_NUMPAD1 }, { "N2", DIK_NUMPAD2 },
283
   { "N3", DIK_NUMPAD3 }, { "N4", DIK_NUMPAD4 }, { "N5", DIK_NUMPAD5 },
284
   { "N6", DIK_NUMPAD6 }, { "N7", DIK_NUMPAD7 }, { "N8", DIK_NUMPAD8 },
285
   { "N9", DIK_NUMPAD9 }, { "NP", DIK_DECIMAL },
286
 
287
   { "LMB", VK_LMB }, { "RMB", VK_RMB }, { "MMB", VK_MMB },
288
   { "MWU", VK_MWU }, { "MWD", VK_MWD },
289
 
290
   { "JLEFT", VK_JLEFT }, { "JRIGHT", VK_JRIGHT },
291
   { "JUP", VK_JUP }, { "JDOWN", VK_JDOWN }, { "JFIRE", VK_JFIRE },
292
   { "JB0", VK_JB0 },
293
   { "JB1", VK_JB1 },
294
   { "JB2", VK_JB2 },
295
   { "JB3", VK_JB3 },
296
   { "JB4", VK_JB4 },
297
   { "JB5", VK_JB5 },
298
   { "JB6", VK_JB6 },
299
   { "JB7", VK_JB7 },
300
   { "JB8", VK_JB8 },
301
   { "JB9", VK_JB9 },
302
   { "JB10", VK_JB10 },
303
   { "JB11", VK_JB11 },
304
   { "JB12", VK_JB12 },
305
   { "JB13", VK_JB13 },
306
   { "JB14", VK_JB14 },
307
   { "JB15", VK_JB15 },
308
   { "JB16", VK_JB16 },
309
   { "JB17", VK_JB17 },
310
   { "JB18", VK_JB18 },
311
   { "JB19", VK_JB19 },
312
   { "JB20", VK_JB20 },
313
   { "JB21", VK_JB21 },
314
   { "JB22", VK_JB22 },
315
   { "JB23", VK_JB23 },
316
   { "JB24", VK_JB24 },
317
   { "JB25", VK_JB25 },
318
   { "JB26", VK_JB26 },
319
   { "JB27", VK_JB27 },
320
   { "JB28", VK_JB28 },
321
   { "JB29", VK_JB29 },
322
   { "JB30", VK_JB30 },
323
   { "JB31", VK_JB31 },
324
};
325
const size_t pckeys_count = _countof(pckeys);
326
 
327
static zxkey zxk_default[] =
328
{
329
   { "KRIGHT", &input.kjoy, u8(~1U) },
330
   { "KLEFT",  &input.kjoy, u8(~2U) },
331
   { "KDOWN",  &input.kjoy, u8(~4U) },
332
   { "KUP",    &input.kjoy, u8(~8U) },
333
   { "KFIRE",  &input.kjoy, u8(~16U)},
334
 
335
   { "ENT", input.kbd+6, u8(~0x01U) },
336
   { "SPC", input.kbd+7, u8(~0x01U) },
337
   { "SYM", input.kbd+7, u8(~0x02U) },
338
 
339
   { "CAP", input.kbd+0, u8(~0x01U) },
340
   { "Z",   input.kbd+0, u8(~0x02U) },
341
   { "X",   input.kbd+0, u8(~0x04U) },
342
   { "C",   input.kbd+0, u8(~0x08U) },
343
   { "V",   input.kbd+0, u8(~0x10U) },
344
 
345
   { "A",   input.kbd+1, u8(~0x01U) },
346
   { "S",   input.kbd+1, u8(~0x02U) },
347
   { "D",   input.kbd+1, u8(~0x04U) },
348
   { "F",   input.kbd+1, u8(~0x08U) },
349
   { "G",   input.kbd+1, u8(~0x10U) },
350
 
351
   { "Q",   input.kbd+2, u8(~0x01U) },
352
   { "W",   input.kbd+2, u8(~0x02U) },
353
   { "E",   input.kbd+2, u8(~0x04U) },
354
   { "R",   input.kbd+2, u8(~0x08U) },
355
   { "T",   input.kbd+2, u8(~0x10U) },
356
 
357
   { "1",   input.kbd+3, u8(~0x01U) },
358
   { "2",   input.kbd+3, u8(~0x02U) },
359
   { "3",   input.kbd+3, u8(~0x04U) },
360
   { "4",   input.kbd+3, u8(~0x08U) },
361
   { "5",   input.kbd+3, u8(~0x10U) },
362
 
363
   { "0",   input.kbd+4, u8(~0x01U) },
364
   { "9",   input.kbd+4, u8(~0x02U) },
365
   { "8",   input.kbd+4, u8(~0x04U) },
366
   { "7",   input.kbd+4, u8(~0x08U) },
367
   { "6",   input.kbd+4, u8(~0x10U) },
368
 
369
   { "P",   input.kbd+5, u8(~0x01U) },
370
   { "O",   input.kbd+5, u8(~0x02U) },
371
   { "I",   input.kbd+5, u8(~0x04U) },
372
   { "U",   input.kbd+5, u8(~0x08U) },
373
   { "Y",   input.kbd+5, u8(~0x10U) },
374
 
375
   { "L",   input.kbd+6, u8(~0x02U) },
376
   { "K",   input.kbd+6, u8(~0x04U) },
377
   { "J",   input.kbd+6, u8(~0x08U) },
378
   { "H",   input.kbd+6, u8(~0x10U) },
379
 
380
   { "M",   input.kbd+7, u8(~0x04U) },
381
   { "N",   input.kbd+7, u8(~0x08U) },
382
   { "B",   input.kbd+7, u8(~0x10U) },
383
};
384
 
385
static zxkey zxk_bk08[] =
386
{
387
   { "KRIGHT", &input.kjoy, u8(~1U) },
388
   { "KLEFT",  &input.kjoy, u8(~2U) },
389
   { "KDOWN",  &input.kjoy, u8(~4U) },
390
   { "KUP",    &input.kjoy, u8(~8U) },
391
   { "KFIRE",  &input.kjoy, u8(~16U)},
392
 
393
   { "ALT", input.kbd+0, u8(~0x01U) },
394
   { "Z",   input.kbd+0, u8(~0x02U) },
395
   { "X",   input.kbd+0, u8(~0x04U) },
396
   { "C",   input.kbd+0, u8(~0x08U) },
397
   { "V",   input.kbd+0, u8(~0x10U) },
398
   { "RUS", input.kbd+0, u8(~0x20U) },
399
   { "SHF", input.kbd+0, u8( 0x7FU) },
400
 
401
   { "A",   input.kbd+1, u8(~0x01U) },
402
   { "S",   input.kbd+1, u8(~0x02U) },
403
   { "D",   input.kbd+1, u8(~0x04U) },
404
   { "F",   input.kbd+1, u8(~0x08U) },
405
   { "G",   input.kbd+1, u8(~0x10U) },
406
   { "BSL", input.kbd+1, u8(~0x20U) },
407
   { "SL",  input.kbd+1, u8( 0x7FU) },
408
 
409
   { "Q",   input.kbd+2, u8(~0x01U) },
410
   { "W",   input.kbd+2, u8(~0x02U) },
411
   { "E",   input.kbd+2, u8(~0x04U) },
412
   { "R",   input.kbd+2, u8(~0x08U) },
413
   { "T",   input.kbd+2, u8(~0x10U) },
414
   { "CMA", input.kbd+2, u8(~0x20U) },
415
   { "PNT", input.kbd+2, u8( 0x7FU) },
416
 
417
   { "1",   input.kbd+3, u8(~0x01U) },
418
   { "2",   input.kbd+3, u8(~0x02U) },
419
   { "3",   input.kbd+3, u8(~0x04U) },
420
   { "4",   input.kbd+3, u8(~0x08U) },
421
   { "5",   input.kbd+3, u8(~0x10U) },
422
   { "TIL", input.kbd+3, u8(~0x20U) },
423
   { "TAB", input.kbd+3, u8( 0x7FU) },
424
 
425
   { "0",   input.kbd+4, u8(~0x01U) },
426
   { "9",   input.kbd+4, u8(~0x02U) },
427
   { "8",   input.kbd+4, u8(~0x04U) },
428
   { "7",   input.kbd+4, u8(~0x08U) },
429
   { "6",   input.kbd+4, u8(~0x10U) },
430
   { "MNS", input.kbd+4, u8(~0x20U) },
431
   { "PLS", input.kbd+4, u8( 0x7FU) },
432
 
433
   { "P",   input.kbd+5, u8(~0x01U) },
434
   { "O",   input.kbd+5, u8(~0x02U) },
435
   { "I",   input.kbd+5, u8(~0x04U) },
436
   { "U",   input.kbd+5, u8(~0x08U) },
437
   { "Y",   input.kbd+5, u8(~0x10U) },
438
   { "LB",  input.kbd+5, u8(~0x20U) },
439
   { "RB",  input.kbd+5, u8( 0x7FU) },
440
 
441
   { "ENT", input.kbd+6, u8(~0x01U) },
442
   { "L",   input.kbd+6, u8(~0x02U) },
443
   { "K",   input.kbd+6, u8(~0x04U) },
444
   { "J",   input.kbd+6, u8(~0x08U) },
445
   { "H",   input.kbd+6, u8(~0x10U) },
446
   { "COL", input.kbd+6, u8(~0x20U) },
447
   { "QUO", input.kbd+6, u8( 0x7FU) },
448
 
449
   { "SPC", input.kbd+7, u8(~0x01U) },
450
   { "CTL", input.kbd+7, u8(~0x02U) },
451
   { "M",   input.kbd+7, u8(~0x04U) },
452
   { "N",   input.kbd+7, u8(~0x08U) },
453
   { "B",   input.kbd+7, u8(~0x10U) },
454
   { "R/A", input.kbd+7, u8(~0x20U) },
455
   { "CPS", input.kbd+7, u8( 0x7FU) }
456
};
457
 
458
static zxkey zxk_quorum[] =
459
{
460
   { "KRIGHT", &input.kjoy, u8(~1U) },
461
   { "KLEFT",  &input.kjoy, u8(~2U) },
462
   { "KDOWN",  &input.kjoy, u8(~4U) },
463
   { "KUP",    &input.kjoy, u8(~8U) },
464
   { "KFIRE",  &input.kjoy, u8(~16U)},
465
 
466
   { "ENT", input.kbd+6, u8(~0x01U) },
467
   { "SPC", input.kbd+7, u8(~0x01U) },
468
   { "SYM", input.kbd+7, u8(~0x02U) },
469
 
470
   { "CAP", input.kbd+0, u8(~0x01U) },
471
   { "Z",   input.kbd+0, u8(~0x02U) },
472
   { "X",   input.kbd+0, u8(~0x04U) },
473
   { "C",   input.kbd+0, u8(~0x08U) },
474
   { "V",   input.kbd+0, u8(~0x10U) },
475
 
476
   { "A",   input.kbd+1, u8(~0x01U) },
477
   { "S",   input.kbd+1, u8(~0x02U) },
478
   { "D",   input.kbd+1, u8(~0x04U) },
479
   { "F",   input.kbd+1, u8(~0x08U) },
480
   { "G",   input.kbd+1, u8(~0x10U) },
481
 
482
   { "Q",   input.kbd+2, u8(~0x01U) },
483
   { "W",   input.kbd+2, u8(~0x02U) },
484
   { "E",   input.kbd+2, u8(~0x04U) },
485
   { "R",   input.kbd+2, u8(~0x08U) },
486
   { "T",   input.kbd+2, u8(~0x10U) },
487
 
488
   { "1",   input.kbd+3, u8(~0x01U) },
489
   { "2",   input.kbd+3, u8(~0x02U) },
490
   { "3",   input.kbd+3, u8(~0x04U) },
491
   { "4",   input.kbd+3, u8(~0x08U) },
492
   { "5",   input.kbd+3, u8(~0x10U) },
493
 
494
   { "0",   input.kbd+4, u8(~0x01U) },
495
   { "9",   input.kbd+4, u8(~0x02U) },
496
   { "8",   input.kbd+4, u8(~0x04U) },
497
   { "7",   input.kbd+4, u8(~0x08U) },
498
   { "6",   input.kbd+4, u8(~0x10U) },
499
 
500
   { "P",   input.kbd+5, u8(~0x01U) },
501
   { "O",   input.kbd+5, u8(~0x02U) },
502
   { "I",   input.kbd+5, u8(~0x04U) },
503
   { "U",   input.kbd+5, u8(~0x08U) },
504
   { "Y",   input.kbd+5, u8(~0x10U) },
505
 
506
   { "L",   input.kbd+6, u8(~0x02U) },
507
   { "K",   input.kbd+6, u8(~0x04U) },
508
   { "J",   input.kbd+6, u8(~0x08U) },
509
   { "H",   input.kbd+6, u8(~0x10U) },
510
 
511
   { "M",   input.kbd+7, u8(~0x04U) },
512
   { "N",   input.kbd+7, u8(~0x08U) },
513
   { "B",   input.kbd+7, u8(~0x10U) },
514
 
515
   // quorum additional keys
516
   { "RUS",    input.kbd+8, u8(~0x01U) },
517
   { "LAT",    input.kbd+8, u8(~0x02U) },
518
   { "N1",     input.kbd+8, u8(~0x08U) },
519
   { "N2",     input.kbd+8, u8(~0x10U) },
520
   { ".",      input.kbd+8, u8(~0x20U) },
521
 
522
   { "CAPS",   input.kbd+9, u8(~0x01U) },
523
   { "F2",     input.kbd+9, u8(~0x02U) },
524
   { "TILDA",  input.kbd+9, u8(~0x04U) },
525
   { "N4",     input.kbd+9, u8(~0x08U) },
526
   { "QUOTE",  input.kbd+9, u8(~0x10U) },
527
   { "N6",     input.kbd+9, u8(~0x20U) },
528
 
529
   { "TAB",    input.kbd+10, u8(~0x01U) },
530
   { "F4",     input.kbd+10, u8(~0x02U) },
531
   { "N7",     input.kbd+10, u8(~0x08U) },
532
   { "N5",     input.kbd+10, u8(~0x10U) },
533
   { "N9",     input.kbd+10, u8(~0x20U) },
534
 
535
   { "EBOX",   input.kbd+11, u8(~0x01U) },
536
   { "F5",     input.kbd+11, u8(~0x02U) },
537
   { "BS",     input.kbd+11, u8(~0x04U) },
538
   { "NSLASH", input.kbd+11, u8(~0x08U) },
539
   { "N8",     input.kbd+11, u8(~0x10U) },
540
   { "NMINUS", input.kbd+11, u8(~0x20U) },
541
 
542
   { "-",      input.kbd+12, u8(~0x01U) },
543
   { "+",      input.kbd+12, u8(~0x04U) },
544
   { "DEL",    input.kbd+12, u8(~0x08U) },
545
   { "NSTAR",  input.kbd+12, u8(~0x10U) },
546
   { "GBOX",   input.kbd+12, u8(~0x20U) },
547
 
548
   { "COLON",  input.kbd+13, u8(~0x01U) },
549
   { "F3",     input.kbd+13, u8(~0x02U) },
550
   { "\\",     input.kbd+13, u8(~0x04U) },
551
   { "]",      input.kbd+13, u8(~0x10U) },
552
   { "[",      input.kbd+13, u8(~0x20U) },
553
 
554
   { ",",      input.kbd+14, u8(~0x01U) },
555
   { "/",      input.kbd+14, u8(~0x10U) },
556
   { "N3",     input.kbd+14, u8(~0x20U) },
557
 
558
   { "F1",     input.kbd+15, u8(~0x02U) },
559
   { "N0",     input.kbd+15, u8(~0x08U) },
560
   { "NPOINT", input.kbd+15, u8(~0x10U) },
561
   { "NPLUS",  input.kbd+15, u8(~0x20U) },
562
};
563
 
564
zxkeymap zxk_maps[] =
565
{
566
   { "default", zxk_default, _countof(zxk_default) },
567
   { "BK08", zxk_bk08, _countof(zxk_bk08) },
568
   { "quorum", zxk_quorum, _countof(zxk_quorum) },
569
};
570
 
571
const size_t zxk_maps_count = _countof(zxk_maps);
572
 
573
PALETTEENTRY syspalette[0x100];
574
 
575
GDIBMP gdibmp = { { { sizeof(BITMAPINFOHEADER), 320, -240, 1, 8, BI_RGB, 0 } } };
576
 
577
PALETTE_OPTIONS pals[32] = {{"default",0x00,0x80,0xC0,0xE0,0xFF,0xC8,0xFF,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,0xFF}};
578
 
579
#pragma pack()
580
 
581
unsigned char snbuf[4*1048576]; // large temporary buffer (for reading snapshots)
582
unsigned char gdibuf[2*1048576];
583
 
584
// on-screen watches block
585
uintptr_t watch_script[4][64];
586
unsigned char watch_enabled[4];
587
unsigned char used_banks[MAX_PAGES];
588
unsigned char trace_rom=1, trace_ram=1;
589
 
590
DWORD WinVerMajor;
591
DWORD WinVerMinor;
592
HWND dlg; // used in setcheck/getcheck: gui settings, monitor dialogs
593
 
594
HBITMAP hbm;  // bitmap for repaint background
595
DWORD bm_dx, bm_dy;
596
DWORD mousepos;  // left-clicked point in monitor
597
unsigned nowait; // don't close console window after error if started from GUI
598
bool normal_exit = false; // true on correct exit, false on failure exit
599
 
600
char *ayvols[64]; unsigned num_ayvols;
601
char *aystereo[64]; unsigned num_aystereo;
602
char *ulapreset[64]; unsigned num_ula;
603
char presetbuf[0x4000], *setptr = presetbuf;
604
 
605
/*
606
#include "fontdata.cpp"
607
#include "font8.cpp"
608
#include "font14.cpp"
609
#include "font16.cpp"
610
#include "fontatm2.cpp"
611
*/
612
 
613
const char * const ay_schemes[] = { "no soundchip", "single chip", "pseudo-turbo", "quadro-AY", "turbo-AY // POS", "turbo-sound // NedoPC" };