15 static unsigned char *vmem;
16 static int quit, dirty_valid;
17 static rtk_rect dirty;
18 static int mx, my, prev_mx, prev_my, use_mouse;
21 int main(int argc, char **argv)
25 int mdx, mdy, bnstate, bndiff;
26 static int prev_bnstate;
30 __djgpp_nearptr_enable();
34 if((env = getenv("MENULOG"))) {
35 if(tolower(env[0]) == 'c' && tolower(env[1]) == 'o' && tolower(env[2]) == 'm'
43 if(!(use_mouse = have_mouse())) {
44 infomsg("no mouse detected\n");
49 if(vid_init() == -1) {
55 if((vmidx = vid_findmode(scr_width, scr_height, 8)) == -1) {
58 if(!(vmem = vid_setmode(vmidx))) {
62 if(app_init() == -1) {
65 app_invalidate(0, 0, 0, 0);
67 app_reshape(scr_width, scr_height);
70 prev_mx = prev_my = -1;
76 if(kb_isdown(KEY_ALT)) {
77 modkeys |= KEY_MOD_ALT;
79 if(kb_isdown(KEY_CTRL)) {
80 modkeys |= KEY_MOD_CTRL;
82 if(kb_isdown(KEY_SHIFT)) {
83 modkeys |= KEY_MOD_SHIFT;
86 while((key = kb_getkey()) != -1) {
87 if(key == 'r' && (modkeys & KEY_MOD_CTRL)) {
88 app_invalidate(0, 0, 0, 0);
92 if(quit) goto break_evloop;
96 bnstate = read_mouse_bn();
97 bndiff = bnstate ^ prev_bnstate;
98 prev_bnstate = bnstate;
100 read_mouse_rel(&mdx, &mdy);
103 if(mx >= scr_width) mx = scr_width - 1;
106 if(my >= scr_height) my = scr_height - 1;
110 if(bndiff & 1) app_mouse(0, bnstate & 1, mx, my);
111 if(bndiff & 2) app_mouse(1, bnstate & 2, mx, my);
112 if(bndiff & 4) app_mouse(3, bnstate & 4, mx, my);
114 if((mdx | mdy) != 0) {
130 void app_invalidate(int x, int y, int w, int h)
137 r.height = scr_height;
146 rtk_rect_union(&dirty, &r);
153 void app_swap_buffers(void)
160 if(dirty.width < scr_width || dirty.height < scr_height) {
161 src = framebuf + dirty.y * scr_width + dirty.x;
162 vid_blit8(dirty.x, dirty.y, dirty.width, dirty.height, src, 0);
164 vid_blitfb8(framebuf, 0);
175 void app_resize(int x, int y)
179 void app_fullscreen(int fs)
183 void app_vsync(int vsync)