backported fixes from rtxon
[dosdemo] / src / dos / gfx.h
1 #ifndef GFX_H_
2 #define GFX_H_
3
4 #ifdef __cplusplus
5 extern "C" {
6 #endif
7
8 void *set_video_mode(int xsz, int ysz, int bpp);
9 int set_text_mode(void);
10
11 int get_color_depth(void);
12 int get_color_bits(int *rbits, int *gbits, int *bbits);
13 int get_color_shift(int *rshift, int *gshift, int *bshift);
14 int get_color_mask(unsigned int *rmask, unsigned int *gmask, unsigned int *bmask);
15
16 void set_palette(int idx, int r, int g, int b);
17
18 enum {
19         FLIP_NOW,
20         FLIP_VBLANK,
21         FLIP_VBLANK_WAIT
22 };
23 /* page flip and return pointer to the start of the display area (front buffer) */
24 void *page_flip(int vsync);
25
26 #ifdef __WATCOMC__
27 void wait_vsync(void);
28 #pragma aux wait_vsync = \
29         "mov dx, 0x3da" \
30         "l1:" \
31         "in al, dx" \
32         "and al, 0x8" \
33         "jnz l1" \
34         "l2:" \
35         "in al, dx" \
36         "and al, 0x8" \
37         "jz l2" \
38         modify[al dx];
39 #endif
40
41 #ifdef __DJGPP__
42 #define wait_vsync()  asm volatile ( \
43         "mov $0x3da, %%dx\n\t" \
44         "0:\n\t" \
45         "in %%dx, %%al\n\t" \
46         "and $8, %%al\n\t" \
47         "jnz 0b\n\t" \
48         "0:\n\t" \
49         "in %%dx, %%al\n\t" \
50         "and $8, %%al\n\t" \
51         "jz 0b\n\t" \
52         :::"%eax","%edx")
53 #endif
54
55
56 #ifdef __cplusplus
57 }
58 #endif
59
60 #endif  /* GFX_H_ */