fucked it up again, need to sleep
[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 extern void (*blit_frame)(void *pixels, int vsync);
43
44 #ifdef __WATCOMC__
45 void wait_vsync(void);
46 #pragma aux wait_vsync = \
47         "mov dx, 0x3da" \
48         "l1:" \
49         "in al, dx" \
50         "and al, 0x8" \
51         "jnz l1" \
52         "l2:" \
53         "in al, dx" \
54         "and al, 0x8" \
55         "jz l2" \
56         modify[al dx];
57 #endif
58
59 #ifdef __DJGPP__
60 #define wait_vsync()  asm volatile ( \
61         "mov $0x3da, %%dx\n\t" \
62         "0:\n\t" \
63         "in %%dx, %%al\n\t" \
64         "and $8, %%al\n\t" \
65         "jnz 0b\n\t" \
66         "0:\n\t" \
67         "in %%dx, %%al\n\t" \
68         "and $8, %%al\n\t" \
69         "jz 0b\n\t" \
70         :::"%eax","%edx")
71 #endif
72
73
74 #ifdef __cplusplus
75 }
76 #endif
77
78 #endif  /* GFX_H_ */