started backporting the eradicate code
[dosdemo] / 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 #define VMODE_CURRENT   (-1)
28 struct video_mode *get_video_mode(int idx);
29
30 int match_video_mode(int xsz, int ysz, int bpp);
31 int find_video_mode(int mode);
32
33 /* argument is the mode list index [0, nmodes-1] */
34 void *set_video_mode(int idx, int nbuf);
35 int set_text_mode(void);
36
37 void set_palette(int idx, int r, int g, int b);
38
39 enum {
40         FLIP_NOW,
41         FLIP_VBLANK
42 };
43 /* page flip and return pointer to the start of the display area (front buffer) */
44 void *page_flip(int vsync);
45 extern void (*blit_frame)(void *pixels, int vsync);
46
47 #ifdef __WATCOMC__
48 void wait_vsync(void);
49 #pragma aux wait_vsync = \
50         "mov dx, 0x3da" \
51         "l1:" \
52         "in al, dx" \
53         "and al, 0x8" \
54         "jnz l1" \
55         "l2:" \
56         "in al, dx" \
57         "and al, 0x8" \
58         "jz l2" \
59         modify[al dx];
60 #endif
61
62 #ifdef __DJGPP__
63 #define wait_vsync()  asm volatile ( \
64         "mov $0x3da, %%dx\n\t" \
65         "0:\n\t" \
66         "in %%dx, %%al\n\t" \
67         "and $8, %%al\n\t" \
68         "jnz 0b\n\t" \
69         "0:\n\t" \
70         "in %%dx, %%al\n\t" \
71         "and $8, %%al\n\t" \
72         "jz 0b\n\t" \
73         :::"%eax","%edx")
74 #endif
75
76
77 #ifdef __cplusplus
78 }
79 #endif
80
81 #endif  /* GFX_H_ */