Subversion Repositories pentevo

Rev

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

  1. #ifndef UNREAL_EMUL_H
  2. #define UNREAL_EMUL_H
  3. #pragma once
  4. #include "sysdefs.h"
  5. #include "z80/defs.h"
  6. #include "sndrender/sndrender.h"
  7. #include "savevid.h"
  8.  
  9.  
  10.  
  11. #define EMUL_DEBUG
  12. #define TRASH_PAGE
  13.  
  14. #define PAGE 0x4000
  15. #define MAX_RAM_PAGES 256       // 4Mb RAM
  16. #define MAX_CACHE_PAGES 2       // 32K cache
  17. #define MAX_MISC_PAGES 1        // trash page
  18. #define MAX_ROM_PAGES 64        // 1Mb
  19.  
  20. #define GS4MB //0.37.0
  21. #ifdef MOD_GSZ80
  22.  #define MAX_GSROM_PAGES  32U      // 512Kb
  23.  #ifdef GS4MB
  24.   #define MAX_GSRAM_PAGES 256U     // for gs4mb
  25.  #else
  26.   #define MAX_GSRAM_PAGES 30U      // for gs512 (last 32k unusable)
  27.  #endif
  28. #else
  29.  #define MAX_GSROM_PAGES 0
  30.  #define MAX_GSRAM_PAGES 0
  31. #endif
  32.  
  33. #define MAX_PAGES (MAX_RAM_PAGES + MAX_CACHE_PAGES + MAX_MISC_PAGES + MAX_ROM_PAGES + MAX_GSROM_PAGES + MAX_GSRAM_PAGES)
  34.  
  35. #define RAM_BASE_M  memory
  36. #define CACHE_M     (RAM_BASE_M + MAX_RAM_PAGES*PAGE)
  37. #define MISC_BASE_M (CACHE_M + MAX_CACHE_PAGES*PAGE)
  38. #define ROM_BASE_M  (MISC_BASE_M + MAX_MISC_PAGES*PAGE)
  39.  
  40. #ifdef MOD_GSZ80
  41. #define ROM_GS_M    (ROM_BASE_M + MAX_ROM_PAGES*PAGE)
  42. #define GSRAM_M     (ROM_GS_M + MAX_GSROM_PAGES*PAGE)
  43. #endif
  44.  
  45. #define TRASH_M     (MISC_BASE_M+0*PAGE)
  46.  
  47.  
  48. enum IDE_SCHEME
  49. {
  50.     IDE_NONE = 0,
  51.     IDE_ATM,
  52.     IDE_NEMO, IDE_NEMO_A8, IDE_NEMO_DIVIDE,
  53.     IDE_SMUC,
  54.     IDE_PROFI,
  55.     IDE_DIVIDE
  56. };
  57.  
  58. enum MOUSE_WHEEL_MODE { MOUSE_WHEEL_NONE, MOUSE_WHEEL_KEYBOARD, MOUSE_WHEEL_KEMPSTON }; //0.36.6 from 0.35b2
  59.  
  60. enum SAA_SCHEME { SAA_NONE = 0, SAA_ZXM,SAA_TFM_PRO };
  61.  
  62. enum MEM_MODEL
  63. {
  64.    MM_PENTAGON = 0,
  65.    MM_SCORP, MM_PROFSCORP,
  66.    MM_PROFI,
  67.    MM_ATM450, MM_ATM710, MM_ATM3,
  68.    MM_KAY,
  69.    MM_PLUS3,
  70.    MM_QUORUM,
  71.    N_MM_MODELS
  72. };
  73.  
  74. enum ROM_MODE { RM_NOCHANGE=0, RM_SOS, RM_DOS, RM_SYS, RM_128, RM_CACHE };
  75.  
  76. const int RAM_128 = 128, RAM_256 = 256, RAM_512 = 512, RAM_1024 = 1024, RAM_4096 = 4096;
  77.  
  78. struct TMemModel
  79. {
  80.    const char *fullname, *shortname;
  81.    MEM_MODEL Model;
  82.    unsigned defaultRAM;
  83.    unsigned availRAMs;
  84. };
  85.  
  86. typedef void (__fastcall *VOID_FUNC)(void);
  87. typedef void (__fastcall *RENDER_FUNC)(unsigned char*,unsigned);
  88.  
  89. struct RENDER
  90. {
  91.    const char *name;
  92.    RENDER_FUNC func;
  93.    const char *nick;
  94.    unsigned flags;
  95. };
  96.  
  97. struct IDE_CONFIG
  98. {
  99.    char image[512];
  100.    unsigned c, h, s;
  101.    u64 lba;
  102.    unsigned char readonly;
  103.    u8 cd;
  104. };
  105.  
  106. enum RSM_MODE { RSM_SIMPLE, RSM_FIR0, RSM_FIR1, RSM_FIR2 };
  107.  
  108. enum SYNC_MODE { SM_SOUND, SM_TSC, SM_VIDEO };
  109.  
  110. struct zxkeymap ;
  111.  
  112. struct CONFIG
  113. {
  114.    unsigned paper;  // start of paper
  115.    unsigned t_line; // t-states per line
  116.    unsigned frame;  // t-states per frame
  117.    unsigned intfq;  // usually 50Hz
  118.    unsigned intlen; // length of INT signal (for Z80)
  119.    unsigned nopaper;// hide paper
  120.  
  121.    unsigned render, driver, fontsize;
  122.  
  123.    unsigned soundbuffer, refresh;
  124.  
  125.    unsigned char flashcolor, noflic, fast_sl, alt_nf;
  126.    unsigned char frameskip, frameskipmax;
  127.    unsigned char flip, fullscr;
  128.  
  129.    unsigned char lockmouse;
  130.    unsigned char detect_video;
  131.    unsigned char tape_traps;
  132.    unsigned char tape_autostart;
  133.    int scrshot;
  134.    char scrshot_dir[FILENAME_MAX];
  135.  
  136.    unsigned char ch_size;
  137.    unsigned char EFF7_mask;
  138.    unsigned char reset_rom;
  139.    unsigned char use_romset;
  140.  
  141.    unsigned char updateb, bordersize;
  142.    unsigned char even_M1, border_4T;
  143.  
  144.    unsigned char floatbus, floatdos;
  145.    bool portff;
  146.  
  147.    // border small
  148.    unsigned mcx_small; // ├юЁшчюэЄры№э√щ ЁрчьхЁ тшфшьюую ¤ъЁрэр (pix)
  149.    unsigned mcy_small; // ┬хЁЄшъры№э√щ ЁрчьхЁ тшфшьюую ¤ъЁрэр (lines)
  150.    unsigned b_top_small; // ╫шёыю тшфшь√ї ёЄЁюъ тхЁїэхую сюЁф■Ёр
  151.    unsigned b_left_small; // ╫шёыю тшфшь√ї яшъёхыхщ ыхтюую сюЁф■Ёр
  152.  
  153.    // border full
  154.    unsigned mcx_full; // ├юЁшчюэЄры№э√щ ЁрчьхЁ тшфшьюую ¤ъЁрэр pix
  155.    unsigned mcy_full; // ┬хЁЄшъры№э√щ ЁрчьхЁ тшфшьюую ¤ъЁрэр lines
  156.    unsigned b_top_full; // ╫шёыю тшфшь√ї ёЄЁюъ тхЁїэхую сюЁф■Ёр
  157.    unsigned b_left_full; // ╫шёыю тшфшь√ї яшъёхыхщ ыхтюую сюЁф■Ёр
  158.  
  159.  
  160.    int modem_port; //, modem_scheme;
  161.    unsigned char fdd_noise;
  162.  
  163.    unsigned char trdos_present, trdos_interleave;
  164.    unsigned char trdos_traps, wd93_nodelay;
  165.    unsigned char trdos_wp[4];
  166.    unsigned char trdos_IORam; //тЁхьхээ√щ ярЁрьхЄЁ, яюЄюь эрфю єфрышЄ№
  167.         unsigned char wiznet;
  168.         char cold_ram_pat[17];
  169.        
  170.    unsigned char cache;
  171.    unsigned char cmos;
  172.    unsigned char smuc;
  173.    unsigned char ula_preset;
  174.  
  175.    unsigned char gs_type;
  176.    unsigned char pixelscroll;
  177.    unsigned char sleepidle;
  178.    unsigned char rsrvd1_;
  179.    unsigned char ConfirmExit;
  180.  
  181.    unsigned char highpriority;
  182.    SYNC_MODE SyncMode;
  183.    bool HighResolutionTimer;
  184.    unsigned char videoscale;
  185.  
  186.    MEM_MODEL mem_model;
  187.    unsigned ramsize, romsize;
  188.    bool Sna128Lock;
  189.  
  190.    IDE_SCHEME ide_scheme;
  191.    IDE_CONFIG ide[2];
  192.    unsigned char ide_skip_real;
  193.    unsigned char cd_aspi;
  194.  
  195.    unsigned char soundfilter; //Alone Coder (IDC_SOUNDFILTER)
  196.    unsigned char RejectDC;
  197.    struct
  198.    {
  199.       unsigned fq, ayfq, saa1099fq;
  200.       int covoxFB, covoxDD, sd, saa1099, moonsound, moonsound_toc2c3;
  201.       int beeper_vol, micout_vol, micin_vol, ay_vol, aydig_vol,
  202.           covoxFB_vol, covoxDD_vol, sd_vol, gs_vol, bass_vol, moonsound_vol;
  203.       VOID_FUNC do_sound;
  204.       unsigned char enabled, gsreset, dsprimary;
  205.       unsigned char ay_chip, ay_scheme, ay_stereo, ay_vols, ay_samples;
  206.       unsigned ay_stereo_tab[6], ay_voltab[32];
  207.    } sound;
  208.  
  209.    struct {
  210.       unsigned firenum;
  211.       unsigned char altlock, fire, firedelay;
  212.       unsigned char paste_hold, paste_release, paste_newline;
  213.       unsigned char mouse, mouseswap, kjoy, keymatrix, joymouse;
  214.           bool fjoy; // fuller joystick
  215.       unsigned char keybpcmode;
  216.       signed char mousescale;
  217.       unsigned char mousewheel; // enum MOUSE_WHEEL_MODE //0.36.6 from 0.35b2
  218.       zxkeymap *active_zxk;
  219.       unsigned JoyId;
  220.    } input;
  221.  
  222.    struct {
  223.       unsigned char enabled;
  224.       unsigned char flash_ay_kbd;
  225.       unsigned char perf_t;
  226.       unsigned char reserved1;
  227.       unsigned bandBpp;
  228.       #define NUM_LEDS 8
  229.       unsigned ay;
  230.       unsigned perf;
  231.       unsigned load;
  232.       unsigned input;
  233.       unsigned time;
  234.       unsigned osw;
  235.       unsigned memband;
  236.       unsigned bkpts;
  237.    } led;
  238.  
  239.    struct {
  240.       unsigned char mem_swap;
  241.       unsigned char xt_kbd;
  242.       unsigned char reserved1;
  243.    } atm;
  244.  
  245.    unsigned char use_comp_pal;
  246.    unsigned pal, num_pals;      // selected palette and total number of pals
  247.    unsigned minres;             // min. screen x-resolution
  248.    unsigned scanbright;         // scanlines intensity
  249.  
  250.    struct {
  251.       unsigned char mix_frames;
  252.       unsigned char mode; // RSM_MODE
  253.    } rsm;
  254.  
  255.    char sos_rom_path[FILENAME_MAX];
  256.    char dos_rom_path[FILENAME_MAX];
  257.    char zx128_rom_path[FILENAME_MAX];
  258.    char sys_rom_path[FILENAME_MAX];
  259.    char atm1_rom_path[FILENAME_MAX];
  260.    char atm2_rom_path[FILENAME_MAX];
  261.    char atm3_rom_path[FILENAME_MAX];
  262.    char scorp_rom_path[FILENAME_MAX];
  263.    char prof_rom_path[FILENAME_MAX];
  264.    char profi_rom_path[FILENAME_MAX];
  265. //[vv]   char kay_rom_path[FILENAME_MAX];
  266.    char plus3_rom_path[FILENAME_MAX];
  267.    char quorum_rom_path[FILENAME_MAX];
  268.    char moonsound_rom_path[FILENAME_MAX];
  269.  
  270.    #ifdef MOD_GSZ80
  271.    unsigned gs_ramsize;
  272.    char gs_rom_path[FILENAME_MAX];
  273.    #endif
  274.  
  275.    #ifdef MOD_MONITOR
  276.    char sos_labels_path[FILENAME_MAX];
  277.    #endif
  278.  
  279.    char ngs_sd_card_path[FILENAME_MAX];
  280.  
  281.    unsigned char zc;
  282.    char zc_sd_card_path[FILENAME_MAX];
  283.    unsigned int sd_delay;
  284.  
  285.    char atariset[64]; // preset for atari mode
  286.    char zxkeymap[64]; // name of ZX keys map
  287.    char keyset[64]; // short name of keyboard layout
  288.    char appendboot[FILENAME_MAX];
  289.    char workdir[FILENAME_MAX];
  290.    u8 profi_monochrome;
  291.  
  292.    struct
  293.    {
  294.       char exec[VS_MAX_FFPATH]; // ffmpeg path/name
  295.       char parm[VS_MAX_FFPARM]; // enc. parameters for ffmpeg
  296.       char vout[VS_MAX_FFVOUT]; // output video file name
  297.       char newcons;             // open new console for ffmpeg
  298.    } ffmpeg;
  299.    bool ula_plus;
  300. };
  301.  
  302. struct TEMP
  303. {
  304.    unsigned char win9x;// if we have old OS //Dexus
  305.    unsigned rflags;    // render_func flags
  306.    unsigned border_add, border_and;   // for scorpion 4T border update
  307.    unsigned char *base, *base_2;  // pointers to Spectrum screen memory
  308.    unsigned char rom_mask, ram_mask;
  309.    unsigned char evenM1_C0; // C0 for scorpion, 00 for pentagon
  310.    unsigned char hi15; // 0 - 16bit color, 1 - 15bit color, 2 - YUY2 colorspace
  311.    unsigned snd_frame_samples;  // samples / frame
  312.    unsigned snd_frame_ticks;    // sound ticks / frame
  313.    unsigned cpu_t_at_frame_start;
  314.  
  315.    unsigned gx, gy, gdx, gdy; // updating rectangle (used by GDI renderer)
  316.    RECT client;               // updating rectangle (used by DD_blt renderer)
  317.    bool Minimized;            // window is minimized
  318.    HDC gdidc;
  319.    unsigned ox, oy, obpp, ofq; // destination video format
  320.    unsigned scx, scy; // multicolor area (320x240 or 384x300), used in MCR renderer
  321.    unsigned odx, ody; // offset to border in surface, used only in flip()
  322.    unsigned rsx, rsy; // screen resolution
  323.    unsigned b_top, b_left, b_right, b_bottom; // border frame used to setup MCR
  324.    unsigned scale; // window scale (x1, x2, x3, x4)
  325.    unsigned mon_scale; // window scale in monitor mode(debugger)
  326.  
  327.    unsigned ataricolors[0x100];
  328.    unsigned shift_mask; // for 16/32 bit modes masks low bits of color components
  329.  
  330.    struct { // led coords
  331.       unsigned char *ay;
  332.       unsigned char *perf;
  333.       unsigned char *load;
  334.       unsigned char *input;
  335.       unsigned char *time;
  336.       unsigned char *osw;
  337.       unsigned char *memband;
  338.       unsigned char *bkpts;
  339.       unsigned char *fdd;
  340.  
  341.       __int64 tape_started;
  342.    } led;
  343.    unsigned char profrom_mask;
  344.    unsigned char comp_pal_changed;
  345.  
  346.    // CPU features
  347.    unsigned char mmx, sse, sse2;
  348.    u64 cpufq;        // x86 t-states per second
  349.    unsigned ticks_frame; // x86 t-states in frame
  350.  
  351.    unsigned char vidblock, sndblock, inputblock, frameskip;
  352.    bool PngSupport;
  353.    bool ZlibSupport;
  354.    unsigned gsdmaaddr;
  355.    u8 gsdmaon;
  356.    u8 gs_ram_mask;
  357.  
  358.    u8 offset_vscroll;
  359.    u8 offset_vscroll_prev;
  360.    u8 offset_hscroll;
  361.    u8 offset_hscroll_prev;
  362.  
  363.    char RomDir[FILENAME_MAX];
  364.    char SnapDir[FILENAME_MAX];
  365.    char HddDir[FILENAME_MAX];
  366.    char SdDir[FILENAME_MAX];
  367.    char LastSnapName[FILENAME_MAX]; // ╚ь  яюёыхфэхую чруЁєцхээюую Їрщыр схч Ёрё°шЁхэш 
  368. };
  369.  
  370. extern TEMP temp;
  371. extern unsigned sb_start_frame;
  372.  
  373. // ╬Є ¤Єюую enum'р чртштшЄ яюЁ фюъ ёЄЁюъ т ьрёёштх ay_schemes
  374. enum AY_SCHEME
  375. {
  376.    AY_SCHEME_NONE = 0,
  377.    AY_SCHEME_FULLER, // fuller фюыцхэ шфЄш юс чрЄхы№эю фю single
  378.    AY_SCHEME_SINGLE,
  379.    AY_SCHEME_PSEUDO,
  380.    AY_SCHEME_QUADRO,
  381.    AY_SCHEME_POS,
  382.    AY_SCHEME_CHRV,
  383.    AY_SCHEME_MAX
  384. };
  385.  
  386. #include "wd93.h"
  387. #include "fdd.h"
  388. #include "hddio.h"
  389. #include "hdd.h"
  390. #include "input.h"
  391. #include "modem.h"
  392.  
  393. #if defined(MOD_GSZ80) || defined(MOD_GSBASS)
  394. #include "bass.h"
  395. #include "snd_bass.h"
  396. #endif
  397.  
  398. #ifdef MOD_GSBASS
  399. #include "gshlbass.h"
  400. #include "gshle.h"
  401. #endif
  402.  
  403. #define EFF7_4BPP       0x01
  404. #define EFF7_512        0x02
  405. #define EFF7_LOCKMEM    0x04
  406. #define EFF7_ROCACHE    0x08
  407. #define EFF7_GIGASCREEN 0x10
  408. #define EFF7_HWMC       0x20
  409. #define EFF7_384        0x40
  410. #define EFF7_CMOS       0x80
  411.  
  412. // ┴шЄ√ яюЁЄр 00 фы  ътюЁєьр
  413. static const u8 Q_F_RAM = 0x01;
  414. static const u8 Q_RAM_8 = 0x08;
  415. static const u8 Q_B_ROM = 0x20;
  416. static const u8 Q_BLK_WR = 0x40;
  417. static const u8 Q_TR_DOS = 0x80;
  418.  
  419. enum SNAP
  420. {
  421.    snNOFILE, snUNKNOWN, snTOOLARGE,
  422.    snSP, snZ80, snSNA_48, snSNA_128,
  423.    snTAP, snTZX, snCSW,
  424.    snPAL,
  425.    // ─шёъют√х ЇюЁьрЄ√ т ъюэЎх, фы  эшї юЄфхы№эр  яЁютхЁър яю эрышўш■ фшёъютющ яюфёшёЄхь√
  426.    snHOB, snSCL, snTRD, snFDI, snTD0, snUDI, snISD, snPRO, snDSK, snIPF
  427. };
  428.  
  429. struct NVRAM
  430. {
  431.    enum EEPROM_STATE { IDLE = 0, RCV_CMD, RCV_ADDR, RCV_DATA, SEND_DATA, RD_ACK };
  432.    unsigned address;
  433.    unsigned char datain, dataout, bitsin, bitsout;
  434.    unsigned char state;
  435.    unsigned char prev;
  436.    unsigned char out;
  437.    unsigned char out_z;
  438.  
  439.    void write(unsigned char val);
  440. };
  441.  
  442. struct COMPUTER
  443. {
  444.    unsigned char p7FFD, pFE, pEFF7, pXXXX;
  445.    unsigned char pDFFD, pFDFD, p1FFD, pFF77;
  446.    u8 p7EFD; // gmx
  447.    u8 p00, p80FD; // quorum
  448.    __int64 t_states; // inc with conf.frame by each frame
  449.    unsigned frame_counter; // inc each frame
  450.    unsigned char aFE, aFB; // ATM 4.50 system ports
  451.    unsigned pFFF7[8]; // ATM 7.10 / ATM3(4Mb) memory map
  452.    // |7ffd|rom|b7b6|b5..b0| b7b6 = 0 for atm2
  453.  
  454.    u8 wd_shadow[5]; // 2F, 4F, 6F, 8F, AF
  455.  
  456.    unsigned aFF77;
  457.    unsigned active_ay;
  458.    unsigned char tfmstat;
  459.    u8 pBF; // ATM3
  460.    u8 pBE; // ATM3
  461.    u16 brk_addr; // pentevo
  462.    u8 fddIO2Ram_mask;
  463.    u8 fddIO2Ram_wr_disable;
  464.    u8 trdos_last_ff; //тЁхьхээ√щ ярЁрьхЄЁ, яюЄюь эрфю єфрышЄ№
  465.         struct{
  466.                 u8 p83; //
  467.                 u8 p82; //
  468.                 u8 p81; //
  469.                 u8 memEna;
  470.         }wiznet;
  471.  
  472.    unsigned char flags;
  473.  
  474.    // ╓тхЄ сюЁф■Ёр (Єю, ўЄю т√тюфшЄё  т яюЁЄ сюЁф■Ёр, чэрўхэшх 0..7, шыш 0..F (фы  ATM, PROFI))
  475.    // чэрўхэшх тёхуфр фюыцэю с√Є№ < 0x10, Є.ъ. фы  Ёрчьэюцхэш  ЎтхЄр шёяюы№чєхЄё  єьэюцхэшх эр ъюэёЄрэЄє 0x11001100
  476.    unsigned char border_attr;
  477.    unsigned char cmos_addr;
  478.    unsigned char pVD;
  479.  
  480.    #ifdef MOD_VID_VD
  481.    unsigned char *vdbase;
  482.    #endif
  483.  
  484.    unsigned char pFFBA, p7FBA; // SMUC
  485.    unsigned char res1, res2;
  486.  
  487.    unsigned char p0F, p1F, p4F, p5F; // soundrive
  488.    struct WD1793 wd;
  489.    FDD fdd[4];
  490.    struct NVRAM nvram;
  491.    struct {
  492.       __int64 edge_change;
  493.       unsigned char *play_pointer; // or NULL if tape stopped
  494.       unsigned char *end_of_tape;  // where to stop tape
  495.       unsigned index;    // current tape block
  496.       unsigned tape_bit;
  497.       bool stopped;
  498.       SNDRENDER sound;
  499.    } tape;
  500.    unsigned char comp_pal[0x40]; // ╘юЁьрЄ ярышЄЁ√ GggRrrBb (ЇюЁьрЄ ULA+)
  501.    u16 atm3_pal[0x40]; // ╘юЁьрЄ ярышЄЁ√ %grbG11RB(low in HSB), %grbG11RB(high in LSB), inverted
  502.    unsigned char ide_hi_byte_r, ide_hi_byte_w, ide_hi_byte_w1, ide_read, ide_write; // high byte in IDE i/o
  503.    unsigned char profrom_bank;
  504.    
  505.    u8 ula_plus_group;
  506.    u8 ula_plus_pal_idx;
  507.    bool ula_plus_en;
  508.  
  509.    COMPUTER();
  510. };
  511.  
  512. // bits for COMPUTER::flags
  513. #define CF_DOSPORTS     0x01    // tr-dos ports are accessible
  514. #define CF_TRDOS        0x02    // DOSEN trigger
  515. #define CF_SETDOSROM    0x04    // tr-dos ROM become active at #3Dxx
  516. #define CF_LEAVEDOSRAM  0x08    // DOS ROM will be closed at executing RAM
  517. #define CF_LEAVEDOSADR  0x10    // DOS ROM will be closed at pc>#4000
  518. #define CF_CACHEON      0x20    // cache active
  519. #define CF_Z80FBUS      0x40    // unstable data bus
  520. #define CF_PROFROM      0x80    // PROF-ROM active
  521.  
  522. // bits for COMPUTER::tfmstat
  523. #define CF_TFM_REG      0x02    // YM stat reg select ( 1 - read register, 0 - read status )
  524. #define CF_TFM_FM       0x04    // YM fm part disable ( 0 - enable, 1 - disable )
  525. #define CF_TFM_SAA      0x08    // SAA enable ( 0 - enable, 1 - disable )
  526.  
  527.  
  528. #define TAPE_QUANTUM 64
  529. struct tzx_block
  530. {
  531.    unsigned char *data;
  532.    unsigned datasize;    // data size, in bytes
  533.    unsigned pause;
  534.    union {
  535.       struct {
  536.          unsigned pilot_t, s1_t, s2_t, zero_t, one_t;
  537.          unsigned pilot_len;
  538.       };
  539.       struct {
  540.          unsigned numblocks, numpulses;
  541.       };
  542.       unsigned param;
  543.    };
  544.    unsigned char type; // 0-playable, 1-pulses, 10-20 - info, etc...
  545.    unsigned char crc; // xor of all bytes
  546.    char desc[128];
  547. };
  548.  
  549. struct SNDVAL {
  550.    union {
  551.       unsigned data;
  552.       struct {
  553.          short left, right;
  554.       };
  555.    };
  556. };
  557.  
  558. struct virtkeyt {
  559.    const char *name;
  560.    unsigned short virtkey;
  561. };
  562.  
  563. struct keyports
  564. {
  565.   volatile unsigned char *port1, *port2;
  566.   unsigned char mask1, mask2;
  567. };
  568.  
  569. struct zxkey {
  570.   const char *name;
  571.   volatile unsigned char * /*const*/ port; //Alone Coder
  572.   /*const*/ unsigned char mask; //Alone Coder
  573. };
  574.  
  575. struct zxkeymap {
  576.   const char *name;
  577.   zxkey *zxk;
  578.   unsigned zxk_size ;
  579. } ;
  580.  
  581. struct action {
  582.    const char *name;
  583.    void (*func)();
  584.    unsigned short k1, k2, k3, k4;
  585. };
  586.  
  587. typedef void (*TColorConverter)(u8 *dst, u8 *scrbuf, int dx);
  588. void ConvBgr32ToBgr24(u8 *dst, u8 *scrbuf, int dx);
  589. void ConvYuy2ToBgr24(u8 *dst, u8 *scrbuf, int dx);
  590. void ConvRgb16ToBgr24(u8 *dst, u8 *scrbuf, int dx);
  591. void ConvRgb15ToBgr24(u8 *dst, u8 *scrbuf, int dx);
  592. void ConvPal8ToBgr24(u8 *dst, u8 *scrbuf, int dx);
  593. extern TColorConverter ConvBgr24;
  594. // flags for video filters
  595.                                 // misc options
  596. #define RF_BORDER   0x00000002   // no multicolor painter, read directly from spectrum memory
  597. #define RF_MON      0x00000004   // not-flippable surface, show mouse cursor
  598. #define RF_DRIVER   0x00000008   // use options from driver
  599. //#define RF_VSYNC    0x00000010   // force VSYNC
  600. #define RF_D3D      0x00000010   // use d3d for windowed mode
  601. #define RF_GDI      0x00000020   // output to window
  602. #define RF_CLIP     0x00000040   // use DirectDraw clipper for windowed mode
  603. #define RF_OVR      0x00000080   // output to overlay
  604.  
  605.                                 // main area size
  606. #define RF_1X       0x00000000   // 256x192,320x240 with border (default)
  607. #define RF_2X       0x00000100   // default x2
  608. #define RF_3X       0x00000001   // default x3
  609. #define RF_4X       0x00000200   // default x4
  610. #define RF_64x48    0x00000400U   // 64x48  (for chunky 4x4)
  611. #define RF_128x96   0x00000800U   // 128x96 (for chunky 2x2)
  612.  
  613. #define RF_8        0x00000000   // 8 bit (default)
  614. #define RF_8BPCH    0x00001000   // 8-bit per color channel. GDI mode => 32-bit surface. 8-bit mode => grayscale palette
  615. #define RF_YUY2     0x00002000   // pixel format: 16bit, YUY2
  616. #define RF_16       0x00004000   // hicolor mode (RGB555/RGB565)
  617. #define RF_32       0x00008000   // true color
  618.  
  619. #define RF_USEC32   0x00010000  // use c32tab
  620. #define RF_USE32AS16 0x0020000  // c32tab contain hi-color WORDS
  621. #define RF_USEFONT  0x00040000  // use font_tables
  622. #define RF_PALB     0x00080000  // palette for bilinear filter
  623. #define RF_COMPPAL  0x00100000  // use palette from ATM palette registers
  624. #define RF_GRAY     0x00200000  // grayscale palette
  625. #define RF_D3DE     0x00400000  // use d3d for full screen mode
  626.  
  627. #define RF_MONITOR (RF_MON | RF_GDI | RF_2X)
  628.  
  629. extern unsigned frametime;
  630. extern unsigned nmi_pending;
  631.  
  632. bool ConfirmExit();
  633. BOOL WINAPI ConsoleHandler(DWORD CtrlType);
  634. void showhelp(const char *anchor = nullptr);
  635.  
  636. #endif // UNREAL_EMUL_H
  637.