gui.h

Go to the documentation of this file.
00001 /* ES40 emulator.
00002  * Copyright (C) 2007-2008 by the ES40 Emulator Project
00003  *
00004  * WWW    : http://sourceforge.net/projects/es40
00005  * E-mail : camiel@camicom.com
00006  * 
00007  *  This file is based upon Bochs.
00008  *
00009  *  Copyright (C) 2002  MandrakeSoft S.A.
00010  *
00011  *    MandrakeSoft S.A.
00012  *    43, rue d'Aboukir
00013  *    75002 Paris - France
00014  *    http://www.linux-mandrake.com/
00015  *    http://www.mandrakesoft.com/
00016  *
00017  *  This library is free software; you can redistribute it and/or
00018  *  modify it under the terms of the GNU Lesser General Public
00019  *  License as published by the Free Software Foundation; either
00020  *  version 2 of the License, or (at your option) any later version.
00021  *
00022  *  This library is distributed in the hope that it will be useful,
00023  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00024  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00025  *  Lesser General Public License for more details.
00026  *
00027  *  You should have received a copy of the GNU Lesser General Public
00028  *  License along with this library; if not, write to the Free Software
00029  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00030  */
00031 
00065 #ifndef __GUI_H__
00066 #define __GUI_H__
00067 
00068 #define BX_DEBUG(a)  \
00069   {                  \
00070     printf  a;       \
00071     printf("   \n"); \
00072   }
00073 #define BX_INFO(a)  BX_DEBUG(a)
00074 #define BX_PANIC(a) BX_DEBUG(a)
00075 #define BX_ERROR(a) BX_DEBUG(a)
00076 #include "vga.h"
00077 
00079 typedef struct
00080 {
00081   u16   start_address;
00082   u8    cs_start;
00083   u8    cs_end;
00084   u16   line_offset;
00085   u16   line_compare;
00086   u8    h_panning;
00087   u8    v_panning;
00088   bool  line_graphics;
00089   bool  split_hpanning;
00090 } bx_vga_tminfo_t;
00091 
00093 typedef struct
00094 {
00095   u16           bpp, pitch;
00096   u8            red_shift, green_shift, blue_shift;
00097   u8            is_indexed, is_little_endian;
00098   unsigned long red_mask, green_mask, blue_mask;
00099 } bx_svga_tileinfo_t;
00100 
00101 extern class bx_gui_c*  bx_gui;
00102 
00106 class                   bx_gui_c
00107 {
00108   public:
00109     bx_gui_c(void);
00110     virtual                       ~bx_gui_c();
00111     virtual void                  specific_init(unsigned x_tilesize,
00112                                                 unsigned y_tilesize) = 0;
00113     virtual void                  text_update(u8*  old_text, u8*  new_text,
00114                                               unsigned long cursor_x,
00115                                               unsigned long cursor_y,
00116                                               bx_vga_tminfo_t tm_info,
00117                                               unsigned rows) = 0;
00118     virtual void                  graphics_tile_update(u8*  snapshot, unsigned x,
00119                                                        unsigned y) = 0;
00120     virtual bx_svga_tileinfo_t*   graphics_tile_info(bx_svga_tileinfo_t* info);
00121     virtual u8*                   graphics_tile_get(unsigned x, unsigned y,
00122                                                     unsigned*  w, unsigned*  h);
00123     virtual void                  graphics_tile_update_in_place(unsigned x,
00124                                                                 unsigned y,
00125                                                                 unsigned w,
00126                                                                 unsigned h);
00127     virtual void                  handle_events(void) = 0;
00128     virtual void                  flush(void) = 0;
00129     virtual void                  clear_screen(void) = 0;
00130     virtual bool                  palette_change(unsigned index, unsigned red,
00131                                                  unsigned green, unsigned blue) = 0;
00132     virtual void                  dimension_update(unsigned x, unsigned y,
00133                                                    unsigned fheight = 0,
00134                                                    unsigned fwidth = 0,
00135                                                    unsigned bpp = 8) = 0;
00136     virtual void                  mouse_enabled_changed_specific(bool val) = 0;
00137     virtual void                  exit(void) = 0;
00138 
00139     virtual u32                   get_sighandler_mask() { return 0; }
00140     virtual void                  sighandler(int sig)   { }
00141     virtual void                  beep_on(float frequency);
00142     virtual void                  beep_off();
00143     virtual void                  get_capabilities(u16*  xres, u16*  yres,
00144                                                    u16*  bpp);
00145 
00146     static void                   key_event(u32 key);
00147     static void                   set_text_charmap(u8* fbuffer);
00148     static void                   set_text_charbyte(u16 address, u8 data);
00149 
00150     void                          init(unsigned x_tilesize, unsigned y_tilesize);
00151     void                          cleanup(void);
00152     static void                   mouse_enabled_changed(bool val);
00153     static void                   init_signal_handlers();
00154 
00155     void                          lock();
00156     void                          unlock();
00157   protected:
00158     CMutex*       guiMutex;
00159     static s32    make_text_snapshot(char ** snapshot, u32* length);
00160 
00161     //  static void toggle_mouse_enable(void);
00162     unsigned char vga_charmap[0x2000];
00163     bool          charmap_updated;
00164     bool          char_changed[256];
00165     bool          new_gfx_api;
00166     u16           host_xres;
00167     u16           host_yres;
00168     u16           host_pitch;
00169     u8            host_bpp;
00170     u8*           framebuffer;
00171 };
00172 
00173 #define BX_KEY_PRESSED        0x00000000
00174 #define BX_KEY_RELEASED       0x80000000
00175 
00176 #define BX_KEY_UNHANDLED      0x10000000
00177 
00178 #define BX_KEY_CTRL_L         0
00179 #define BX_KEY_SHIFT_L        1
00180 
00181 #define BX_KEY_F1             2
00182 #define BX_KEY_F2             3
00183 #define BX_KEY_F3             4
00184 #define BX_KEY_F4             5
00185 #define BX_KEY_F5             6
00186 #define BX_KEY_F6             7
00187 #define BX_KEY_F7             8
00188 #define BX_KEY_F8             9
00189 #define BX_KEY_F9             10
00190 #define BX_KEY_F10            11
00191 #define BX_KEY_F11            12
00192 #define BX_KEY_F12            13
00193 
00194 #define BX_KEY_CTRL_R         14
00195 #define BX_KEY_SHIFT_R        15
00196 #define BX_KEY_CAPS_LOCK      16
00197 #define BX_KEY_NUM_LOCK       17
00198 #define BX_KEY_ALT_L          18
00199 #define BX_KEY_ALT_R          19
00200 
00201 #define BX_KEY_A              20
00202 #define BX_KEY_B              21
00203 #define BX_KEY_C              22
00204 #define BX_KEY_D              23
00205 #define BX_KEY_E              24
00206 #define BX_KEY_F              25
00207 #define BX_KEY_G              26
00208 #define BX_KEY_H              27
00209 #define BX_KEY_I              28
00210 #define BX_KEY_J              29
00211 #define BX_KEY_K              30
00212 #define BX_KEY_L              31
00213 #define BX_KEY_M              32
00214 #define BX_KEY_N              33
00215 #define BX_KEY_O              34
00216 #define BX_KEY_P              35
00217 #define BX_KEY_Q              36
00218 #define BX_KEY_R              37
00219 #define BX_KEY_S              38
00220 #define BX_KEY_T              39
00221 #define BX_KEY_U              40
00222 #define BX_KEY_V              41
00223 #define BX_KEY_W              42
00224 #define BX_KEY_X              43
00225 #define BX_KEY_Y              44
00226 #define BX_KEY_Z              45
00227 
00228 #define BX_KEY_0              46
00229 #define BX_KEY_1              47
00230 #define BX_KEY_2              48
00231 #define BX_KEY_3              49
00232 #define BX_KEY_4              50
00233 #define BX_KEY_5              51
00234 #define BX_KEY_6              52
00235 #define BX_KEY_7              53
00236 #define BX_KEY_8              54
00237 #define BX_KEY_9              55
00238 
00239 #define BX_KEY_ESC            56
00240 
00241 #define BX_KEY_SPACE          57
00242 #define BX_KEY_SINGLE_QUOTE   58
00243 #define BX_KEY_COMMA          59
00244 #define BX_KEY_PERIOD         60
00245 #define BX_KEY_SLASH          61
00246 
00247 #define BX_KEY_SEMICOLON      62
00248 #define BX_KEY_EQUALS         63
00249 
00250 #define BX_KEY_LEFT_BRACKET   64
00251 #define BX_KEY_BACKSLASH      65
00252 #define BX_KEY_RIGHT_BRACKET  66
00253 #define BX_KEY_MINUS          67
00254 #define BX_KEY_GRAVE          68
00255 
00256 #define BX_KEY_BACKSPACE      69
00257 #define BX_KEY_ENTER          70
00258 #define BX_KEY_TAB            71
00259 
00260 #define BX_KEY_LEFT_BACKSLASH 72
00261 #define BX_KEY_PRINT          73
00262 #define BX_KEY_SCRL_LOCK      74
00263 #define BX_KEY_PAUSE          75
00264 
00265 #define BX_KEY_INSERT         76
00266 #define BX_KEY_DELETE         77
00267 #define BX_KEY_HOME           78
00268 #define BX_KEY_END            79
00269 #define BX_KEY_PAGE_UP        80
00270 #define BX_KEY_PAGE_DOWN      81
00271 
00272 #define BX_KEY_KP_ADD         82
00273 #define BX_KEY_KP_SUBTRACT    83
00274 #define BX_KEY_KP_END         84
00275 #define BX_KEY_KP_DOWN        85
00276 #define BX_KEY_KP_PAGE_DOWN   86
00277 #define BX_KEY_KP_LEFT        87
00278 #define BX_KEY_KP_RIGHT       88
00279 #define BX_KEY_KP_HOME        89
00280 #define BX_KEY_KP_UP          90
00281 #define BX_KEY_KP_PAGE_UP     91
00282 #define BX_KEY_KP_INSERT      92
00283 #define BX_KEY_KP_DELETE      93
00284 #define BX_KEY_KP_5           94
00285 
00286 #define BX_KEY_UP             95
00287 #define BX_KEY_DOWN           96
00288 #define BX_KEY_LEFT           97
00289 #define BX_KEY_RIGHT          98
00290 
00291 #define BX_KEY_KP_ENTER       99
00292 #define BX_KEY_KP_MULTIPLY    100
00293 #define BX_KEY_KP_DIVIDE      101
00294 
00295 #define BX_KEY_WIN_L          102
00296 #define BX_KEY_WIN_R          103
00297 #define BX_KEY_MENU           104
00298 
00299 #define BX_KEY_ALT_SYSREQ     105
00300 #define BX_KEY_CTRL_BREAK     106
00301 
00302 #define BX_KEY_INT_BACK       107
00303 #define BX_KEY_INT_FORWARD    108
00304 #define BX_KEY_INT_STOP       109
00305 #define BX_KEY_INT_MAIL       110
00306 #define BX_KEY_INT_SEARCH     111
00307 #define BX_KEY_INT_FAV        112
00308 #define BX_KEY_INT_HOME       113
00309 
00310 #define BX_KEY_POWER_MYCOMP   114
00311 #define BX_KEY_POWER_CALC     115
00312 #define BX_KEY_POWER_SLEEP    116
00313 #define BX_KEY_POWER_POWER    117
00314 #define BX_KEY_POWER_WAKE     118
00315 
00316 #define BX_KEY_NBKEYS         119
00317 
00318 // If you add BX_KEYs Please update
00319 // - BX_KEY_NBKEYS
00320 // - the scancodes table in the file iodev/scancodes.cc
00321 // - the bx_key_symbol table in the file gui/keymap.cc
00322 
00323 
00325 // Define macro to supply gui plugin code.  This macro is called once in GUI to
00326 // supply the plugin initialization methods.  Since it is nearly identical for
00327 // each gui module, the macro is easier to maintain than pasting the same code
00328 // in each one.
00329 //
00330 // Each gui should declare a class pointer called "theGui" which is derived
00331 // from bx_gui_c, before calling this macro.  For example, the SDL port
00332 // says:
00333 
00334 //   static bx_sdl_gui_c *theGui;
00335 #define IMPLEMENT_GUI_PLUGIN_CODE(gui_name)                                   \
00336   int lib##gui_name##_LTX_plugin_init(CConfigurator*  cfg)                    \
00337   {                                                                           \
00338     printf("%%GUI-I-INS: Installing %s module as the ES40 GUI\n", #gui_name); \
00339     theGui = new bx_##gui_name##_gui_c(cfg);                                  \
00340     bx_gui = theGui;                                                          \
00341     return(0);  /* Success */                                                 \
00342   }                                                                           \
00343                                                                              \
00344   void lib##gui_name##_LTX_plugin_fini(void)                                  \
00345   { }
00346 #endif

SourceForge.net Logo
Project space on SourceForge.net