fallback to banked modes if LFB is not available
[eradicate] / src / dos / gfx.h
1 #ifndef GFX_H_
2 #define GFX_H_
3
4 #include "inttypes.h"
5
6 struct video_mode {
7         uint16_t mode;
8         short xsz, ysz, bpp, pitch;
9         short rbits, gbits, bbits;
10         short rshift, gshift, bshift;
11         uint32_t rmask, gmask, bmask;
12         uint32_t fb_addr;
13         short max_pages;
14         uint32_t bank_size;
15 };
16
17 #ifdef __cplusplus
18 extern "C" {
19 #endif
20
21 int init_video(void);
22 void cleanup_video(void);
23
24 struct video_mode *video_modes(void);
25 int num_video_modes(void);
26
27 int match_video_mode(int xsz, int ysz, int bpp);
28 int find_video_mode(int mode);
29
30 /* argument is the mode list index [0, nmodes-1] */
31 void *set_video_mode(int idx, int nbuf);
32 int set_text_mode(void);
33
34 void set_palette(int idx, int r, int g, int b);
35
36 enum {
37         FLIP_NOW,
38         FLIP_VBLANK
39 };
40 /* page flip and return pointer to the start of the display area (front buffer) */
41 void *page_flip(int vsync);
42
43 #ifdef __WATCOMC__
44 void wait_vsync(void);
45 #pragma aux wait_vsync = \
46         "mov dx, 0x3da" \
47         "l1:" \
48         "in al, dx" \
49         "and al, 0x8" \
50         "jnz l1" \
51         "l2:" \
52         "in al, dx" \
53         "and al, 0x8" \
54         "jz l2" \
55         modify[al dx];
56 #endif
57
58 #ifdef __DJGPP__
59 #define wait_vsync()  asm volatile ( \
60         "mov $0x3da, %%dx\n\t" \
61         "0:\n\t" \
62         "in %%dx, %%al\n\t" \
63         "and $8, %%al\n\t" \
64         "jnz 0b\n\t" \
65         "0:\n\t" \
66         "in %%dx, %%al\n\t" \
67         "and $8, %%al\n\t" \
68         "jz 0b\n\t" \
69         :::"%eax","%edx")
70 #endif
71
72
73 #ifdef __cplusplus
74 }
75 #endif
76
77 #endif  /* GFX_H_ */