FreeBASIC  0.91.0
fb_gfx_dos.h
Go to the documentation of this file.
1 /* DOS gfxlib include file */
2 
3 #include <dpmi.h>
4 #include "vesa.h"
5 
6 /* macros */
7 
8 #define MASK_LINEAR(addr) ((addr) & 0x000FFFFF)
9 #define RM_TO_LINEAR(addr) ((((addr) & 0xFFFF0000) >> 12) + ((addr) & 0xFFFF))
10 #define RM_OFFSET(addr) ((addr) & 0xF)
11 #define RM_SEGMENT(addr) (((addr) >> 4) & 0xFFFF)
12 #define SEGOFF_TO_RM(s, o) (((s) << 4) + (o))
13 
14 #define SCREENLIST(w, h) ((h) | (w) << 16)
15 
16 
17 /* globals */
18 
19 typedef struct fb_dos_pal_t {
20  unsigned char b;
21  unsigned char g;
22  unsigned char r;
23  unsigned char pad;
24 } fb_dos_pal_t;
25 
26 typedef struct fb_dos_t {
27 
28  int w;
29  int h;
30  int depth;
31  int refresh;
32 
34  int pal_dirty;
35  int pal_first;
36  int pal_last;
37 
38  int inited;
39  int detected;
40  int locked;
42 
43  int old_rows;
44  int old_cols;
45 
46  int mouse_ok;
50 
51  int bios_mode;
52 
53  void (*update)(void);
54  unsigned int update_len;
55 
56  void (*draw_mouse)(void);
57  void (*undraw_mouse)(void);
58  void (*set_palette)(void);
59 
60  __dpmi_regs regs;
61 
62  unsigned timer_ticks;
63  unsigned timer_step;
64 
66 
67  int Bpp; /* **bytes** per pixel */
68  unsigned int w_bytes; /* bytes per scanline */
69  size_t size;
70 
71  int vesa_ok;
77  unsigned long vesa_mmio_linear;
78  unsigned int vesa_mmio_sel;
79 
84  char key_old[128];
85 
86  int palbuf_sel; /* real-mode palette transfer buffer for VESA VBE modes */
88 
89 } fb_dos_t;
90 
91 extern fb_dos_t fb_dos;
92 
93 /* mouse */
94 
95 extern int fb_dos_get_mouse(int *x, int *y, int *z, int *buttons, int *clip);
96 extern void fb_dos_set_mouse(int x, int y, int cursor, int clip);
97 extern int fb_dos_update_mouse(void);
98 
99 /* VGA */
100 
101 extern void fb_dos_vga_wait_vsync(void);
102 extern void fb_dos_vga_set_palette(void);
103 
104 /* VESA */
105 
106 extern void fb_dos_vesa_detect(void);
107 extern int fb_dos_vesa_set_mode(int w, int h, int depth, int linear);
108 extern int *fb_dos_vesa_fetch_modes(int depth, int *size);
109 extern void vesa_get_pm_functions(void);
110 extern void fb_dos_vesa_set_palette(void);
111 extern void fb_dos_vesa_set_palette_end(void);
112 
114 extern intptr_t fb_dos_vesa_pm_bank_switcher;
115 extern intptr_t fb_dos_vesa_pm_set_palette;
116 
117 /* shared */
118 
119 extern void fb_dos_set_palette(int idx, int r, int g, int b);
120 extern void fb_dos_detect(void);
121 extern int fb_dos_init(char *title, int w, int h, int depth, int refresh_rate, int flags);
122 extern void fb_dos_exit(void);
123 extern void fb_dos_set_window_title(char *title);
124 extern void fb_dos_lock(void);
125 extern void fb_dos_unlock(void);