Subversion Repositories pentevo

Rev

Rev 798 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed | ?url?

  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. #include "sndrender/sndcounter.h"
  11. #include "sound.h"
  12.  
  13. namespace z80fast
  14. {
  15. #include "z80_main.h"
  16. }
  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 = -1U; // ─шёъютюф яю єьюыўрэш■ т ъюЄюЁ√щ уЁєч Єё  юсЁрч√ фшёъют яЁш ёЄрЁЄх
  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.    { "KFIRE1", &input.kjoy, u8(~16U) },
  335.    { "KFIRE2", &input.kjoy, u8(~32U) },
  336.    { "KFIRE3", &input.kjoy, u8(~64U) },
  337.  
  338.    // fuller joystick
  339.    { "FRIGHT", &input.fjoy, u8(~8U) },
  340.    { "FLEFT",  &input.fjoy, u8(~4U) },
  341.    { "FDOWN",  &input.fjoy, u8(~2U) },
  342.    { "FUP",    &input.fjoy, u8(~1U) },
  343.    { "FFIRE",  &input.fjoy, u8(~128U)},
  344.    { "FFIRE1", &input.fjoy, u8(~128U) },
  345.    { "FFIRE2", &input.fjoy, u8(~64U) },
  346.    { "FFIRE3", &input.fjoy, u8(~32U) },
  347.  
  348.    { "ENT", input.kbd+6, u8(~0x01U) },
  349.    { "SPC", input.kbd+7, u8(~0x01U) },
  350.    { "SYM", input.kbd+7, u8(~0x02U) },
  351.  
  352.    { "CAP", input.kbd+0, u8(~0x01U) },
  353.    { "Z",   input.kbd+0, u8(~0x02U) },
  354.    { "X",   input.kbd+0, u8(~0x04U) },
  355.    { "C",   input.kbd+0, u8(~0x08U) },
  356.    { "V",   input.kbd+0, u8(~0x10U) },
  357.  
  358.    { "A",   input.kbd+1, u8(~0x01U) },
  359.    { "S",   input.kbd+1, u8(~0x02U) },
  360.    { "D",   input.kbd+1, u8(~0x04U) },
  361.    { "F",   input.kbd+1, u8(~0x08U) },
  362.    { "G",   input.kbd+1, u8(~0x10U) },
  363.  
  364.    { "Q",   input.kbd+2, u8(~0x01U) },
  365.    { "W",   input.kbd+2, u8(~0x02U) },
  366.    { "E",   input.kbd+2, u8(~0x04U) },
  367.    { "R",   input.kbd+2, u8(~0x08U) },
  368.    { "T",   input.kbd+2, u8(~0x10U) },
  369.  
  370.    { "1",   input.kbd+3, u8(~0x01U) },
  371.    { "2",   input.kbd+3, u8(~0x02U) },
  372.    { "3",   input.kbd+3, u8(~0x04U) },
  373.    { "4",   input.kbd+3, u8(~0x08U) },
  374.    { "5",   input.kbd+3, u8(~0x10U) },
  375.  
  376.    { "0",   input.kbd+4, u8(~0x01U) },
  377.    { "9",   input.kbd+4, u8(~0x02U) },
  378.    { "8",   input.kbd+4, u8(~0x04U) },
  379.    { "7",   input.kbd+4, u8(~0x08U) },
  380.    { "6",   input.kbd+4, u8(~0x10U) },
  381.  
  382.    { "P",   input.kbd+5, u8(~0x01U) },
  383.    { "O",   input.kbd+5, u8(~0x02U) },
  384.    { "I",   input.kbd+5, u8(~0x04U) },
  385.    { "U",   input.kbd+5, u8(~0x08U) },
  386.    { "Y",   input.kbd+5, u8(~0x10U) },
  387.  
  388.    { "L",   input.kbd+6, u8(~0x02U) },
  389.    { "K",   input.kbd+6, u8(~0x04U) },
  390.    { "J",   input.kbd+6, u8(~0x08U) },
  391.    { "H",   input.kbd+6, u8(~0x10U) },
  392.  
  393.    { "M",   input.kbd+7, u8(~0x04U) },
  394.    { "N",   input.kbd+7, u8(~0x08U) },
  395.    { "B",   input.kbd+7, u8(~0x10U) },
  396. };
  397.  
  398. static zxkey zxk_bk08[] =
  399. {
  400.    { "KRIGHT", &input.kjoy, u8(~1U) },
  401.    { "KLEFT",  &input.kjoy, u8(~2U) },
  402.    { "KDOWN",  &input.kjoy, u8(~4U) },
  403.    { "KUP",    &input.kjoy, u8(~8U) },
  404.    { "KFIRE",  &input.kjoy, u8(~16U)},
  405.    { "KFIRE1", &input.kjoy, u8(~16U) },
  406.    { "KFIRE2", &input.kjoy, u8(~32U) },
  407.    { "KFIRE3", &input.kjoy, u8(~64U) },
  408.  
  409.    // fuller joystick
  410.    { "FRIGHT", &input.fjoy, u8(~8U) },
  411.    { "FLEFT",  &input.fjoy, u8(~4U) },
  412.    { "FDOWN",  &input.fjoy, u8(~2U) },
  413.    { "FUP",    &input.fjoy, u8(~1U) },
  414.    { "FFIRE",  &input.fjoy, u8(~128U)},
  415.    { "FFIRE1", &input.fjoy, u8(~128U) },
  416.    { "FFIRE2", &input.fjoy, u8(~64U) },
  417.    { "FFIRE3", &input.fjoy, u8(~32U) },
  418.  
  419.    { "ALT", input.kbd+0, u8(~0x01U) },
  420.    { "Z",   input.kbd+0, u8(~0x02U) },
  421.    { "X",   input.kbd+0, u8(~0x04U) },
  422.    { "C",   input.kbd+0, u8(~0x08U) },
  423.    { "V",   input.kbd+0, u8(~0x10U) },
  424.    { "RUS", input.kbd+0, u8(~0x20U) },
  425.    { "SHF", input.kbd+0, u8( 0x7FU) },
  426.  
  427.    { "A",   input.kbd+1, u8(~0x01U) },
  428.    { "S",   input.kbd+1, u8(~0x02U) },
  429.    { "D",   input.kbd+1, u8(~0x04U) },
  430.    { "F",   input.kbd+1, u8(~0x08U) },
  431.    { "G",   input.kbd+1, u8(~0x10U) },
  432.    { "BSL", input.kbd+1, u8(~0x20U) },
  433.    { "SL",  input.kbd+1, u8( 0x7FU) },
  434.  
  435.    { "Q",   input.kbd+2, u8(~0x01U) },
  436.    { "W",   input.kbd+2, u8(~0x02U) },
  437.    { "E",   input.kbd+2, u8(~0x04U) },
  438.    { "R",   input.kbd+2, u8(~0x08U) },
  439.    { "T",   input.kbd+2, u8(~0x10U) },
  440.    { "CMA", input.kbd+2, u8(~0x20U) },
  441.    { "PNT", input.kbd+2, u8( 0x7FU) },
  442.  
  443.    { "1",   input.kbd+3, u8(~0x01U) },
  444.    { "2",   input.kbd+3, u8(~0x02U) },
  445.    { "3",   input.kbd+3, u8(~0x04U) },
  446.    { "4",   input.kbd+3, u8(~0x08U) },
  447.    { "5",   input.kbd+3, u8(~0x10U) },
  448.    { "TIL", input.kbd+3, u8(~0x20U) },
  449.    { "TAB", input.kbd+3, u8( 0x7FU) },
  450.  
  451.    { "0",   input.kbd+4, u8(~0x01U) },
  452.    { "9",   input.kbd+4, u8(~0x02U) },
  453.    { "8",   input.kbd+4, u8(~0x04U) },
  454.    { "7",   input.kbd+4, u8(~0x08U) },
  455.    { "6",   input.kbd+4, u8(~0x10U) },
  456.    { "MNS", input.kbd+4, u8(~0x20U) },
  457.    { "PLS", input.kbd+4, u8( 0x7FU) },
  458.  
  459.    { "P",   input.kbd+5, u8(~0x01U) },
  460.    { "O",   input.kbd+5, u8(~0x02U) },
  461.    { "I",   input.kbd+5, u8(~0x04U) },
  462.    { "U",   input.kbd+5, u8(~0x08U) },
  463.    { "Y",   input.kbd+5, u8(~0x10U) },
  464.    { "LB",  input.kbd+5, u8(~0x20U) },
  465.    { "RB",  input.kbd+5, u8( 0x7FU) },
  466.  
  467.    { "ENT", input.kbd+6, u8(~0x01U) },
  468.    { "L",   input.kbd+6, u8(~0x02U) },
  469.    { "K",   input.kbd+6, u8(~0x04U) },
  470.    { "J",   input.kbd+6, u8(~0x08U) },
  471.    { "H",   input.kbd+6, u8(~0x10U) },
  472.    { "COL", input.kbd+6, u8(~0x20U) },
  473.    { "QUO", input.kbd+6, u8( 0x7FU) },
  474.  
  475.    { "SPC", input.kbd+7, u8(~0x01U) },
  476.    { "CTL", input.kbd+7, u8(~0x02U) },
  477.    { "M",   input.kbd+7, u8(~0x04U) },
  478.    { "N",   input.kbd+7, u8(~0x08U) },
  479.    { "B",   input.kbd+7, u8(~0x10U) },
  480.    { "R/A", input.kbd+7, u8(~0x20U) },
  481.    { "CPS", input.kbd+7, u8( 0x7FU) }
  482. };
  483.  
  484. static zxkey zxk_quorum[] =
  485. {
  486.    { "KRIGHT", &input.kjoy, u8(~1U) },
  487.    { "KLEFT",  &input.kjoy, u8(~2U) },
  488.    { "KDOWN",  &input.kjoy, u8(~4U) },
  489.    { "KUP",    &input.kjoy, u8(~8U) },
  490.    { "KFIRE",  &input.kjoy, u8(~16U)},
  491.    { "KFIRE1", &input.kjoy, u8(~16U) },
  492.    { "KFIRE2", &input.kjoy, u8(~32U) },
  493.    { "KFIRE3", &input.kjoy, u8(~64U) },
  494.  
  495.    // fuller joystick
  496.    { "FRIGHT", &input.fjoy, u8(~8U) },
  497.    { "FLEFT",  &input.fjoy, u8(~4U) },
  498.    { "FDOWN",  &input.fjoy, u8(~2U) },
  499.    { "FUP",    &input.fjoy, u8(~1U) },
  500.    { "FFIRE",  &input.fjoy, u8(~128U)},
  501.    { "FFIRE1", &input.fjoy, u8(~128U) },
  502.    { "FFIRE2", &input.fjoy, u8(~64U) },
  503.    { "FFIRE3", &input.fjoy, u8(~32U) },
  504.  
  505.  
  506.    { "ENT", input.kbd+6, u8(~0x01U) },
  507.    { "SPC", input.kbd+7, u8(~0x01U) },
  508.    { "SYM", input.kbd+7, u8(~0x02U) },
  509.  
  510.    { "CAP", input.kbd+0, u8(~0x01U) },
  511.    { "Z",   input.kbd+0, u8(~0x02U) },
  512.    { "X",   input.kbd+0, u8(~0x04U) },
  513.    { "C",   input.kbd+0, u8(~0x08U) },
  514.    { "V",   input.kbd+0, u8(~0x10U) },
  515.  
  516.    { "A",   input.kbd+1, u8(~0x01U) },
  517.    { "S",   input.kbd+1, u8(~0x02U) },
  518.    { "D",   input.kbd+1, u8(~0x04U) },
  519.    { "F",   input.kbd+1, u8(~0x08U) },
  520.    { "G",   input.kbd+1, u8(~0x10U) },
  521.  
  522.    { "Q",   input.kbd+2, u8(~0x01U) },
  523.    { "W",   input.kbd+2, u8(~0x02U) },
  524.    { "E",   input.kbd+2, u8(~0x04U) },
  525.    { "R",   input.kbd+2, u8(~0x08U) },
  526.    { "T",   input.kbd+2, u8(~0x10U) },
  527.  
  528.    { "1",   input.kbd+3, u8(~0x01U) },
  529.    { "2",   input.kbd+3, u8(~0x02U) },
  530.    { "3",   input.kbd+3, u8(~0x04U) },
  531.    { "4",   input.kbd+3, u8(~0x08U) },
  532.    { "5",   input.kbd+3, u8(~0x10U) },
  533.  
  534.    { "0",   input.kbd+4, u8(~0x01U) },
  535.    { "9",   input.kbd+4, u8(~0x02U) },
  536.    { "8",   input.kbd+4, u8(~0x04U) },
  537.    { "7",   input.kbd+4, u8(~0x08U) },
  538.    { "6",   input.kbd+4, u8(~0x10U) },
  539.  
  540.    { "P",   input.kbd+5, u8(~0x01U) },
  541.    { "O",   input.kbd+5, u8(~0x02U) },
  542.    { "I",   input.kbd+5, u8(~0x04U) },
  543.    { "U",   input.kbd+5, u8(~0x08U) },
  544.    { "Y",   input.kbd+5, u8(~0x10U) },
  545.  
  546.    { "L",   input.kbd+6, u8(~0x02U) },
  547.    { "K",   input.kbd+6, u8(~0x04U) },
  548.    { "J",   input.kbd+6, u8(~0x08U) },
  549.    { "H",   input.kbd+6, u8(~0x10U) },
  550.  
  551.    { "M",   input.kbd+7, u8(~0x04U) },
  552.    { "N",   input.kbd+7, u8(~0x08U) },
  553.    { "B",   input.kbd+7, u8(~0x10U) },
  554.  
  555.    // quorum additional keys
  556.    { "RUS",    input.kbd+8, u8(~0x01U) },
  557.    { "LAT",    input.kbd+8, u8(~0x02U) },
  558.    { "N1",     input.kbd+8, u8(~0x08U) },
  559.    { "N2",     input.kbd+8, u8(~0x10U) },
  560.    { ".",      input.kbd+8, u8(~0x20U) },
  561.  
  562.    { "CAPS",   input.kbd+9, u8(~0x01U) },
  563.    { "F2",     input.kbd+9, u8(~0x02U) },
  564.    { "TILDA",  input.kbd+9, u8(~0x04U) },
  565.    { "N4",     input.kbd+9, u8(~0x08U) },
  566.    { "QUOTE",  input.kbd+9, u8(~0x10U) },
  567.    { "N6",     input.kbd+9, u8(~0x20U) },
  568.  
  569.    { "TAB",    input.kbd+10, u8(~0x01U) },
  570.    { "F4",     input.kbd+10, u8(~0x02U) },
  571.    { "N7",     input.kbd+10, u8(~0x08U) },
  572.    { "N5",     input.kbd+10, u8(~0x10U) },
  573.    { "N9",     input.kbd+10, u8(~0x20U) },
  574.  
  575.    { "EBOX",   input.kbd+11, u8(~0x01U) },
  576.    { "F5",     input.kbd+11, u8(~0x02U) },
  577.    { "BS",     input.kbd+11, u8(~0x04U) },
  578.    { "NSLASH", input.kbd+11, u8(~0x08U) },
  579.    { "N8",     input.kbd+11, u8(~0x10U) },
  580.    { "NMINUS", input.kbd+11, u8(~0x20U) },
  581.  
  582.    { "-",      input.kbd+12, u8(~0x01U) },
  583.    { "+",      input.kbd+12, u8(~0x04U) },
  584.    { "DEL",    input.kbd+12, u8(~0x08U) },
  585.    { "NSTAR",  input.kbd+12, u8(~0x10U) },
  586.    { "GBOX",   input.kbd+12, u8(~0x20U) },
  587.  
  588.    { "COLON",  input.kbd+13, u8(~0x01U) },
  589.    { "F3",     input.kbd+13, u8(~0x02U) },
  590.    { "\\",     input.kbd+13, u8(~0x04U) },
  591.    { "]",      input.kbd+13, u8(~0x10U) },
  592.    { "[",      input.kbd+13, u8(~0x20U) },
  593.  
  594.    { ",",      input.kbd+14, u8(~0x01U) },
  595.    { "/",      input.kbd+14, u8(~0x10U) },
  596.    { "N3",     input.kbd+14, u8(~0x20U) },
  597.  
  598.    { "F1",     input.kbd+15, u8(~0x02U) },
  599.    { "N0",     input.kbd+15, u8(~0x08U) },
  600.    { "NPOINT", input.kbd+15, u8(~0x10U) },
  601.    { "NPLUS",  input.kbd+15, u8(~0x20U) },
  602. };
  603.  
  604. zxkeymap zxk_maps[] =
  605. {
  606.    { "default", zxk_default, _countof(zxk_default) },
  607.    { "BK08", zxk_bk08, _countof(zxk_bk08) },
  608.    { "quorum", zxk_quorum, _countof(zxk_quorum) },
  609. };
  610.  
  611. const size_t zxk_maps_count = _countof(zxk_maps);
  612.  
  613. PALETTEENTRY syspalette[0x100];
  614.  
  615. GDIBMP gdibmp = { { { sizeof(BITMAPINFOHEADER), 320, -240, 1, 8, BI_RGB, 0 } } };
  616.  
  617. PALETTE_OPTIONS pals[32] = {{"default",0x00,0x80,0xC0,0xE0,0xFF,0xC8,0xFF,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,0xFF}};
  618.  
  619. #pragma pack()
  620.  
  621. unsigned char snbuf[4*1048576]; // large temporary buffer (for reading snapshots)
  622. unsigned char gdibuf[2*1048576];
  623.  
  624. // on-screen watches block
  625. uintptr_t watch_script[4][64];
  626. unsigned char watch_enabled[4];
  627. unsigned char used_banks[MAX_PAGES];
  628. unsigned char trace_rom=1, trace_ram=1;
  629.  
  630. DWORD WinVerMajor;
  631. DWORD WinVerMinor;
  632. HWND dlg; // used in setcheck/getcheck: gui settings, monitor dialogs
  633.  
  634. HBITMAP hbm;  // bitmap for repaint background
  635. DWORD bm_dx, bm_dy;
  636. DWORD mousepos;  // left-clicked point in monitor
  637. unsigned nowait; // don't close console window after error if started from GUI
  638. bool normal_exit = false; // true on correct exit, false on failure exit
  639.  
  640. char *ayvols[64]; unsigned num_ayvols;
  641. char *aystereo[64]; unsigned num_aystereo;
  642. char *ulapreset[64]; unsigned num_ula;
  643. static char presetbuf[0x4000];
  644. char *setptr = presetbuf;
  645.  
  646. /*
  647. #include "fontdata.cpp"
  648. #include "font8.cpp"
  649. #include "font14.cpp"
  650. #include "font16.cpp"
  651. #include "fontatm2.cpp"
  652. */
  653.  
  654. // ╧юЁ фюъ ёЄЁюъ т ¤Єюь ьрёёштх фюыцхэ ёююЄтхЄёЄтютрЄ№ enum AY_SCHEME
  655. const char * const ay_schemes[] =
  656. {
  657.     "no soundchip",
  658.     "fuller box",
  659.     "single chip",
  660.     "pseudo-turbo",
  661.     "quadro-AY",
  662.     "turbo-AY // POS",
  663.     "turbo-sound // NedoPC"
  664. };
  665.