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