Subversion Repositories pentevo

Rev

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

  1. #pragma once
  2.  
  3. class TKeyboardBuffer // thims zxevo_ps/2
  4. {
  5.     unsigned char buffer[256];
  6.     unsigned char push;
  7.     unsigned char pop;
  8.     bool full;
  9.  
  10. public:
  11.     TKeyboardBuffer() { Empty(); }
  12.    
  13.     void Empty()
  14.     {
  15.         push = pop = 0;
  16.         full = false;
  17.     }
  18.  
  19.     void Push(unsigned char key)
  20.     {
  21.         if (!full)
  22.         {
  23.             buffer[push++] = key;
  24.             if (push == sizeof(buffer)) push = 0;
  25.             if (push == pop) full = true;
  26.         }        
  27.     }
  28.  
  29.     unsigned char Pop()
  30.     {
  31.         if (!full)
  32.         {
  33.             if (push != pop)
  34.             {
  35.                 unsigned char key = buffer[pop++];
  36.                 if (pop == sizeof(buffer)) pop = 0;
  37.                 return key;
  38.             }
  39.             return 0;
  40.         }
  41.         return 0xFF;
  42.     }
  43. };
  44. struct ATM_KBD
  45. {
  46.    union {
  47.       unsigned char zxkeys[8];
  48.       unsigned zxdata[2];
  49.    };
  50.    unsigned char mode, R7, lastscan, cmd;
  51.    unsigned char kR1, kR2, kR3, kR4, kR5;
  52.  
  53.    void processzx(unsigned scancode, unsigned char pressed);
  54.    unsigned char read(unsigned char scan, unsigned char zxdata);
  55.    void setkey(unsigned scancode, unsigned char pressed);
  56.    void reset();
  57.    void clear();
  58. };
  59.  
  60. struct K_INPUT
  61. {
  62. #pragma pack(push, 1)
  63.    union
  64.    {
  65.       volatile unsigned char kbd[16];
  66.       volatile unsigned kbd_x4[4];
  67.    };
  68.  
  69.    union
  70.    { // without keymatrix effect
  71.       volatile unsigned char rkbd[16];
  72.       volatile unsigned rkbd_x4[4];
  73.    };
  74. #pragma pack(pop)
  75.  
  76.    unsigned lastkey, nokb, nomouse;
  77.  
  78.    enum { KM_DEFAULT, KM_KEYSTICK, KM_PASTE_HOLD, KM_PASTE_RELEASE } keymode;
  79.  
  80.    int msx, msy, msx_prev, msy_prev, ay_x0, ay_y0;
  81.    unsigned ay_reset_t;
  82.    unsigned char mbuttons, ayR14;
  83.  
  84.    volatile unsigned char kjoy;
  85.    unsigned char mousejoy;
  86.    unsigned char kbdled, mouse_joy_led;
  87.    unsigned char firedelay, firestate; // autofire vars
  88.    volatile u8 fjoy; // fuller joystick
  89.  
  90.    ATM_KBD atm51;
  91.    TKeyboardBuffer buffer;
  92.    bool buffer_enabled;
  93.  
  94.    unsigned stick_delay;
  95.    int prev_wheel;
  96.  
  97.    unsigned char *textbuffer;
  98.    unsigned textoffset, textsize;
  99.    unsigned char tdelay, tdata, wheel; //0.36.6 from 0.35b2
  100.  
  101.    unsigned char kempston_mx();
  102.    unsigned char kempston_my();
  103.  
  104.    unsigned char aymouse_rd();
  105.    void aymouse_wr(unsigned char val);
  106.  
  107.    void clear_zx();
  108.    inline void press_zx(unsigned char key);
  109.    bool process_pc_layout();
  110.    void make_matrix();
  111.    char readdevices();
  112.    unsigned char read(unsigned char scan);
  113.    u8 read_quorum(u8 scan);
  114.    void paste();
  115.  
  116.    K_INPUT()
  117.    {
  118.       textbuffer = nullptr;
  119.       // random data on coords -> some programs detects mouse by this
  120.       ay_x0 = msx = 31;
  121.       ay_y0 = msy = 85;
  122.  
  123.       nokb = nomouse = 0;
  124.    }
  125. };
  126.