OpenCores
URL https://opencores.org/ocsvn/ao486/ao486/trunk

Subversion Repositories ao486

[/] [ao486/] [trunk/] [bochs486/] [gui/] [gui.h] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 alfik
/////////////////////////////////////////////////////////////////////////
2
// $Id: gui.h 11622 2013-02-12 21:08:35Z vruppert $
3
/////////////////////////////////////////////////////////////////////////
4
//
5
//  Copyright (C) 2002-2012  The Bochs Project
6
//
7
//  This library is free software; you can redistribute it and/or
8
//  modify it under the terms of the GNU Lesser General Public
9
//  License as published by the Free Software Foundation; either
10
//  version 2 of the License, or (at your option) any later version.
11
//
12
//  This library is distributed in the hope that it will be useful,
13
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
14
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15
//  Lesser General Public License for more details.
16
//
17
//  You should have received a copy of the GNU Lesser General Public
18
//  License along with this library; if not, write to the Free Software
19
//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
20
 
21
#define BX_MAX_STATUSITEMS 10
22
 
23
#define BX_GUI_DLG_FLOPPY       0x01
24
#define BX_GUI_DLG_CDROM        0x02
25
#define BX_GUI_DLG_SNAPSHOT     0x04
26
#define BX_GUI_DLG_RUNTIME      0x08
27
#define BX_GUI_DLG_USER         0x10
28
#define BX_GUI_DLG_SAVE_RESTORE 0x20
29
#define BX_GUI_DLG_ALL          0x3F
30
 
31
// text mode blink feature
32
#define BX_TEXT_BLINK_MODE      0x01
33
#define BX_TEXT_BLINK_TOGGLE    0x02
34
#define BX_TEXT_BLINK_STATE     0x04
35
 
36
// mouse capture toggle feature
37
#define BX_MT_KEY_CTRL          0x01
38
#define BX_MT_KEY_ALT           0x02
39
#define BX_MT_KEY_F10           0x04
40
#define BX_MT_KEY_F12           0x08
41
#define BX_MT_MBUTTON           0x10
42
#define BX_MT_LBUTTON           0x20
43
#define BX_MT_RBUTTON           0x40
44
 
45
#define BX_GUI_MT_CTRL_MB       (BX_MT_KEY_CTRL | BX_MT_MBUTTON)
46
#define BX_GUI_MT_CTRL_LRB      (BX_MT_KEY_CTRL | BX_MT_LBUTTON | BX_MT_RBUTTON)
47
#define BX_GUI_MT_CTRL_F10      (BX_MT_KEY_CTRL | BX_MT_KEY_F10)
48
#define BX_GUI_MT_F12           (BX_MT_KEY_F12)
49
#define BX_GUI_MT_CTRL_ALT      (BX_MT_KEY_CTRL | BX_MT_KEY_ALT)
50
 
51
typedef struct {
52
  Bit16u  start_address;
53
  Bit8u   cs_start;
54
  Bit8u   cs_end;
55
  Bit16u  line_offset;
56
  Bit16u  line_compare;
57
  Bit8u   h_panning;
58
  Bit8u   v_panning;
59
  bx_bool line_graphics;
60
  bx_bool split_hpanning;
61
  Bit8u   blink_flags;
62
  Bit8u   actl_palette[16];
63
} bx_vga_tminfo_t;
64
 
65
typedef struct {
66
  Bit16u bpp, pitch;
67
  Bit8u red_shift, green_shift, blue_shift;
68
  Bit8u is_indexed, is_little_endian;
69
  unsigned long red_mask, green_mask, blue_mask;
70
  bx_bool snapshot_mode;
71
} bx_svga_tileinfo_t;
72
 
73
 
74
BOCHSAPI extern class bx_gui_c *bx_gui;
75
 
76
#if BX_SUPPORT_X86_64
77
  #define BOCHS_WINDOW_NAME "Bochs x86-64 emulator, http://bochs.sourceforge.net/"
78
#else
79
  #define BOCHS_WINDOW_NAME "Bochs x86 emulator, http://bochs.sourceforge.net/"
80
#endif
81
 
82
// The bx_gui_c class provides data and behavior that is common to
83
// all guis.  Each gui implementation will override the abstract methods.
84
class BOCHSAPI bx_gui_c : public logfunctions {
85
public:
86
  bx_gui_c (void);
87
  virtual ~bx_gui_c ();
88
  // Define the following functions in the module for your particular GUI
89
  // (x.cc, win32.cc, ...)
90
  virtual void specific_init(int argc, char **argv, unsigned header_bar_y) = 0;
91
  virtual void text_update(Bit8u *old_text, Bit8u *new_text,
92
                          unsigned long cursor_x, unsigned long cursor_y,
93
                          bx_vga_tminfo_t *tm_info) = 0;
94
  virtual void graphics_tile_update(Bit8u *tile, unsigned x, unsigned y) = 0;
95
  virtual bx_svga_tileinfo_t *graphics_tile_info(bx_svga_tileinfo_t *info);
96
  virtual Bit8u *graphics_tile_get(unsigned x, unsigned y, unsigned *w, unsigned *h);
97
  virtual void graphics_tile_update_in_place(unsigned x, unsigned y, unsigned w, unsigned h);
98
  virtual void handle_events(void) = 0;
99
  virtual void flush(void) = 0;
100
  virtual void clear_screen(void) = 0;
101
  virtual bx_bool palette_change(Bit8u index, Bit8u red, Bit8u green, Bit8u blue) = 0;
102
  virtual void dimension_update(unsigned x, unsigned y, unsigned fheight=0, unsigned fwidth=0, unsigned bpp=8) = 0;
103
  virtual unsigned create_bitmap(const unsigned char *bmap, unsigned xdim, unsigned ydim) = 0;
104
  virtual unsigned headerbar_bitmap(unsigned bmap_id, unsigned alignment, void (*f)(void)) = 0;
105
  virtual void replace_bitmap(unsigned hbar_id, unsigned bmap_id) = 0;
106
  virtual void show_headerbar(void) = 0;
107
  virtual int get_clipboard_text(Bit8u **bytes, Bit32s *nbytes)  = 0;
108
  virtual int set_clipboard_text(char *snapshot, Bit32u len) = 0;
109
  virtual void mouse_enabled_changed_specific (bx_bool val) = 0;
110
  virtual void statusbar_setitem_specific(int element, bx_bool active, bx_bool w) {}
111
  virtual void set_tooltip(unsigned hbar_id, const char *tip) {}
112
  virtual void exit(void) = 0;
113
  // set_display_mode() changes the mode between the configuration interface
114
  // and the simulation.  This is primarily intended for display libraries
115
  // which have a full-screen mode such as SDL, term, and svgalib.  The display
116
  // mode is set to DISP_MODE_CONFIG before displaying any configuration menus,
117
  // for panics that requires user input, when entering the debugger, etc.  It
118
  // is set to DISP_MODE_SIM when the Bochs simulation resumes.  The
119
  // enum is defined in gui/siminterface.h.
120
  virtual void set_display_mode (disp_mode_t newmode) { /* default=no action*/ }
121
  // These are only needed for the term gui. For all other guis they will
122
  // have no effect.
123
  // returns 32-bit bitmask in which 1 means the GUI should handle that signal
124
  virtual Bit32u get_sighandler_mask () {return 0;}
125
  // called when registered signal arrives
126
  virtual void sighandler (int sig) {}
127
#if BX_USE_IDLE_HACK
128
  // this is called from the CPU model when the HLT instruction is executed.
129
  virtual void sim_is_idle(void) {}
130
#endif
131
  virtual void show_ips(Bit32u ips_count);
132
  virtual void beep_on(float frequency);
133
  virtual void beep_off();
134
  virtual void get_capabilities(Bit16u *xres, Bit16u *yres, Bit16u *bpp);
135
  virtual void set_mouse_mode_absxy(bx_bool mode) {}
136
 
137
  // The following function(s) are defined already, and your
138
  // GUI code calls them
139
  static void key_event(Bit32u key);
140
  static void set_text_charmap(Bit8u *fbuffer);
141
  static void set_text_charbyte(Bit16u address, Bit8u data);
142
  static Bit8u get_mouse_headerbar_id();
143
 
144
  void init(int argc, char **argv, unsigned max_xres, unsigned max_yres,
145
            unsigned x_tilesize, unsigned y_tilesize);
146
  void cleanup(void);
147
  void graphics_tile_update_common(Bit8u *tile, unsigned x, unsigned y);
148
  bx_svga_tileinfo_t *graphics_tile_info_common(bx_svga_tileinfo_t *info);
149
  Bit8u* get_snapshot_buffer(void) {return snapshot_buffer;}
150
  bx_bool palette_change_common(Bit8u index, Bit8u red, Bit8u green, Bit8u blue);
151
  void update_drive_status_buttons(void);
152
  static void     mouse_enabled_changed(bx_bool val);
153
  int register_statusitem(const char *text, bx_bool auto_off=0);
154
  void statusbar_setitem(int element, bx_bool active, bx_bool w=0);
155
  static void init_signal_handlers();
156
  static void toggle_mouse_enable(void);
157
  bx_bool mouse_toggle_check(Bit32u key, bx_bool pressed);
158
  const char* get_toggle_info(void);
159
#if BX_DEBUGGER && BX_DEBUGGER_GUI
160
  void init_debug_dialog(void);
161
  void close_debug_dialog(void);
162
#endif
163
 
164
protected:
165
  // And these are defined and used privately in gui.cc
166
  // header bar button handers
167
  static void floppyA_handler(void);
168
  static void floppyB_handler(void);
169
  static void cdrom1_handler(void);
170
  static void reset_handler(void);
171
  static void power_handler(void);
172
  static void copy_handler(void);
173
  static void paste_handler(void);
174
  static void snapshot_handler(void);
175
  static void config_handler(void);
176
  static void userbutton_handler(void);
177
  static void save_restore_handler(void);
178
  // snapshot helper functions
179
  static void make_text_snapshot(char **snapshot, Bit32u *length);
180
  static Bit32u set_snapshot_mode(bx_bool mode);
181
  // status bar LED timer
182
  static void led_timer_handler(void *);
183
  void led_timer(void);
184
 
185
  // header bar buttons
186
  bx_bool floppyA_status;
187
  bx_bool floppyB_status;
188
  bx_bool cdrom1_status;
189
  unsigned floppyA_bmap_id, floppyA_eject_bmap_id, floppyA_hbar_id;
190
  unsigned floppyB_bmap_id, floppyB_eject_bmap_id, floppyB_hbar_id;
191
  unsigned cdrom1_bmap_id, cdrom1_eject_bmap_id, cdrom1_hbar_id;
192
  unsigned power_bmap_id,    power_hbar_id;
193
  unsigned reset_bmap_id,    reset_hbar_id;
194
  unsigned copy_bmap_id, copy_hbar_id;
195
  unsigned paste_bmap_id, paste_hbar_id;
196
  unsigned snapshot_bmap_id, snapshot_hbar_id;
197
  unsigned config_bmap_id, config_hbar_id;
198
  unsigned mouse_bmap_id, nomouse_bmap_id, mouse_hbar_id;
199
  unsigned user_bmap_id, user_hbar_id;
200
  unsigned save_restore_bmap_id, save_restore_hbar_id;
201
  // text charmap
202
  unsigned char vga_charmap[0x2000];
203
  bx_bool charmap_updated;
204
  bx_bool char_changed[256];
205
  // status bar items
206
  unsigned statusitem_count;
207
  int led_timer_index;
208
  struct {
209
    char text[8];
210
    bx_bool active;
211
    bx_bool mode; // read/write
212
    bx_bool auto_off;
213
    Bit8u counter;
214
  } statusitem[BX_MAX_STATUSITEMS];
215
  // display mode
216
  disp_mode_t disp_mode;
217
  // new graphics API (with compatibility mode)
218
  bx_bool new_gfx_api;
219
  Bit16u host_xres;
220
  Bit16u host_yres;
221
  Bit16u host_pitch;
222
  Bit8u host_bpp;
223
  Bit8u *framebuffer;
224
  // maximum guest display size and tile size
225
  unsigned max_xres;
226
  unsigned max_yres;
227
  unsigned x_tilesize;
228
  unsigned y_tilesize;
229
  // current guest display settings
230
  bx_bool guest_textmode;
231
  unsigned guest_xres;
232
  unsigned guest_yres;
233
  unsigned guest_bpp;
234
  // graphics snapshot
235
  bx_bool snapshot_mode;
236
  Bit8u *snapshot_buffer;
237
  struct {
238
    Bit8u blue;
239
    Bit8u green;
240
    Bit8u red;
241
    Bit8u reserved;
242
  } palette[256];
243
  // mouse toggle setup
244
  Bit8u toggle_method;
245
  Bit32u toggle_keystate;
246
  char mouse_toggle_text[20];
247
  // gui dialog capabilities
248
  Bit32u dialog_caps;
249
};
250
 
251
 
252
// Add this macro in the class declaration of each GUI, to define all the
253
// required virtual methods.  Example:
254
//
255
//    class bx_rfb_gui_c : public bx_gui_c {
256
//    public:
257
//      bx_rfb_gui_c (void) {}
258
//      DECLARE_GUI_VIRTUAL_METHODS()
259
//    };
260
// Then, each method must be defined later in the file.
261
#define DECLARE_GUI_VIRTUAL_METHODS()                                       \
262
virtual void specific_init(int argc, char **argv,                           \
263
                           unsigned header_bar_y);                          \
264
virtual void text_update(Bit8u *old_text, Bit8u *new_text,                  \
265
                  unsigned long cursor_x, unsigned long cursor_y,           \
266
                  bx_vga_tminfo_t *tm_info);                                \
267
virtual void graphics_tile_update(Bit8u *tile, unsigned x, unsigned y);     \
268
virtual void handle_events(void);                                           \
269
virtual void flush(void);                                                   \
270
virtual void clear_screen(void);                                            \
271
virtual bx_bool palette_change(Bit8u index, Bit8u red, Bit8u green,         \
272
                               Bit8u blue);                                 \
273
virtual void dimension_update(unsigned x, unsigned y, unsigned fheight=0,   \
274
                          unsigned fwidth=0, unsigned bpp=8);               \
275
virtual unsigned create_bitmap(const unsigned char *bmap,                   \
276
                               unsigned xdim, unsigned ydim);               \
277
virtual unsigned headerbar_bitmap(unsigned bmap_id, unsigned alignment,     \
278
                                  void (*f)(void));                         \
279
virtual void replace_bitmap(unsigned hbar_id, unsigned bmap_id);            \
280
virtual void show_headerbar(void);                                          \
281
virtual int get_clipboard_text(Bit8u **bytes, Bit32s *nbytes);              \
282
virtual int set_clipboard_text(char *snapshot, Bit32u len);                 \
283
virtual void mouse_enabled_changed_specific (bx_bool val);                  \
284
virtual void exit(void);                                                    \
285
/* end of DECLARE_GUI_VIRTUAL_METHODS */
286
 
287
#define DECLARE_GUI_NEW_VIRTUAL_METHODS()                                   \
288
virtual bx_svga_tileinfo_t *graphics_tile_info(bx_svga_tileinfo_t *info);   \
289
virtual Bit8u *graphics_tile_get(unsigned x, unsigned y,                    \
290
                             unsigned *w, unsigned *h);                     \
291
virtual void graphics_tile_update_in_place(unsigned x, unsigned y,          \
292
                                       unsigned w, unsigned h);
293
/* end of DECLARE_GUI_NEW_VIRTUAL_METHODS */
294
 
295
#define BX_HEADER_BAR_Y 32
296
 
297
#define BX_MAX_PIXMAPS 17
298
#define BX_MAX_HEADERBAR_ENTRIES 12
299
 
300
// align pixmaps towards left or right side of header bar
301
#define BX_GRAVITY_LEFT 10
302
#define BX_GRAVITY_RIGHT 11
303
 
304
#define BX_KEY_PRESSED  0x00000000
305
#define BX_KEY_RELEASED 0x80000000
306
 
307
#define BX_KEY_UNHANDLED 0x10000000
308
 
309
#define BX_KEY_CTRL_L   0
310
#define BX_KEY_SHIFT_L  1
311
 
312
#define BX_KEY_F1     2
313
#define BX_KEY_F2     3
314
#define BX_KEY_F3     4
315
#define BX_KEY_F4     5
316
#define BX_KEY_F5     6
317
#define BX_KEY_F6     7
318
#define BX_KEY_F7     8
319
#define BX_KEY_F8     9
320
#define BX_KEY_F9    10
321
#define BX_KEY_F10   11
322
#define BX_KEY_F11   12
323
#define BX_KEY_F12   13
324
 
325
#define BX_KEY_CTRL_R    14
326
#define BX_KEY_SHIFT_R   15
327
#define BX_KEY_CAPS_LOCK 16
328
#define BX_KEY_NUM_LOCK  17
329
#define BX_KEY_ALT_L     18
330
#define BX_KEY_ALT_R     19
331
 
332
#define BX_KEY_A     20
333
#define BX_KEY_B     21
334
#define BX_KEY_C     22
335
#define BX_KEY_D     23
336
#define BX_KEY_E     24
337
#define BX_KEY_F     25
338
#define BX_KEY_G     26
339
#define BX_KEY_H     27
340
#define BX_KEY_I     28
341
#define BX_KEY_J     29
342
#define BX_KEY_K     30
343
#define BX_KEY_L     31
344
#define BX_KEY_M     32
345
#define BX_KEY_N     33
346
#define BX_KEY_O     34
347
#define BX_KEY_P     35
348
#define BX_KEY_Q     36
349
#define BX_KEY_R     37
350
#define BX_KEY_S     38
351
#define BX_KEY_T     39
352
#define BX_KEY_U     40
353
#define BX_KEY_V     41
354
#define BX_KEY_W     42
355
#define BX_KEY_X     43
356
#define BX_KEY_Y     44
357
#define BX_KEY_Z     45
358
 
359
#define BX_KEY_0     46
360
#define BX_KEY_1     47
361
#define BX_KEY_2     48
362
#define BX_KEY_3     49
363
#define BX_KEY_4     50
364
#define BX_KEY_5     51
365
#define BX_KEY_6     52
366
#define BX_KEY_7     53
367
#define BX_KEY_8     54
368
#define BX_KEY_9     55
369
 
370
#define BX_KEY_ESC    56
371
 
372
#define BX_KEY_SPACE         57
373
#define BX_KEY_SINGLE_QUOTE  58
374
#define BX_KEY_COMMA         59
375
#define BX_KEY_PERIOD        60
376
#define BX_KEY_SLASH         61
377
 
378
#define BX_KEY_SEMICOLON     62
379
#define BX_KEY_EQUALS        63
380
 
381
#define BX_KEY_LEFT_BRACKET  64
382
#define BX_KEY_BACKSLASH     65
383
#define BX_KEY_RIGHT_BRACKET 66
384
#define BX_KEY_MINUS         67
385
#define BX_KEY_GRAVE         68
386
 
387
#define BX_KEY_BACKSPACE     69
388
#define BX_KEY_ENTER         70
389
#define BX_KEY_TAB           71
390
 
391
#define BX_KEY_LEFT_BACKSLASH 72
392
#define BX_KEY_PRINT         73
393
#define BX_KEY_SCRL_LOCK     74
394
#define BX_KEY_PAUSE         75
395
 
396
#define BX_KEY_INSERT        76
397
#define BX_KEY_DELETE        77
398
#define BX_KEY_HOME          78
399
#define BX_KEY_END           79
400
#define BX_KEY_PAGE_UP       80
401
#define BX_KEY_PAGE_DOWN     81
402
 
403
#define BX_KEY_KP_ADD        82
404
#define BX_KEY_KP_SUBTRACT   83
405
#define BX_KEY_KP_END        84
406
#define BX_KEY_KP_DOWN       85
407
#define BX_KEY_KP_PAGE_DOWN  86
408
#define BX_KEY_KP_LEFT       87
409
#define BX_KEY_KP_RIGHT      88
410
#define BX_KEY_KP_HOME       89
411
#define BX_KEY_KP_UP         90
412
#define BX_KEY_KP_PAGE_UP    91
413
#define BX_KEY_KP_INSERT     92
414
#define BX_KEY_KP_DELETE     93
415
#define BX_KEY_KP_5          94
416
 
417
#define BX_KEY_UP            95
418
#define BX_KEY_DOWN          96
419
#define BX_KEY_LEFT          97
420
#define BX_KEY_RIGHT         98
421
 
422
#define BX_KEY_KP_ENTER      99
423
#define BX_KEY_KP_MULTIPLY  100
424
#define BX_KEY_KP_DIVIDE    101
425
 
426
#define BX_KEY_WIN_L        102
427
#define BX_KEY_WIN_R        103
428
#define BX_KEY_MENU         104
429
 
430
#define BX_KEY_ALT_SYSREQ   105
431
#define BX_KEY_CTRL_BREAK   106
432
 
433
#define BX_KEY_INT_BACK     107
434
#define BX_KEY_INT_FORWARD  108
435
#define BX_KEY_INT_STOP     109
436
#define BX_KEY_INT_MAIL     110
437
#define BX_KEY_INT_SEARCH   111
438
#define BX_KEY_INT_FAV      112
439
#define BX_KEY_INT_HOME     113
440
 
441
#define BX_KEY_POWER_MYCOMP 114
442
#define BX_KEY_POWER_CALC   115
443
#define BX_KEY_POWER_SLEEP  116
444
#define BX_KEY_POWER_POWER  117
445
#define BX_KEY_POWER_WAKE   118
446
 
447
#define BX_KEY_NBKEYS       119
448
// If you add BX_KEYs Please update
449
// - BX_KEY_NBKEYS
450
// - the scancodes table in the file iodev/scancodes.cc
451
// - the bx_key_symbol table in the file gui/keymap.cc
452
 
453
 
454
/////////////// GUI plugin support
455
 
456
// Define macro to supply gui plugin code.  This macro is called once in GUI to
457
// supply the plugin initialization methods.  Since it is nearly identical for
458
// each gui module, the macro is easier to maintain than pasting the same code
459
// in each one.
460
//
461
// Each gui should declare a class pointer called "theGui" which is derived
462
// from bx_gui_c, before calling this macro.  For example, the SDL port
463
// says:
464
//   static bx_sdl_gui_c *theGui;
465
 
466
#define IMPLEMENT_GUI_PLUGIN_CODE(gui_name)                           \
467
  int lib##gui_name##_LTX_plugin_init(plugin_t *plugin,               \
468
          plugintype_t type, int argc, char *argv[]) {                \
469
    genlog->info("installing %s module as the Bochs GUI", #gui_name); \
470
    theGui = new bx_##gui_name##_gui_c ();                            \
471
    bx_gui = theGui;                                                  \
472
    return(0); /* Success */                                          \
473
  }                                                                   \
474
  void lib##gui_name##_LTX_plugin_fini(void) { }

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.