added two new global pointers in demo.h: vmem_back and vmem_front, and
[dosdemo] / src / sdl / main.c
index 0abb3e3..e5eda65 100644 (file)
@@ -32,6 +32,7 @@ int main(int argc, char **argv)
                fprintf(stderr, "failed to allocate virtual framebuffer\n");
                return 1;
        }
+       vmem_front = vmem_back = fb_pixels;
 
        SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER);
        if(!(fbsurf = SDL_SetVideoMode(xsz, ysz, fb_bpp, sdl_flags))) {
@@ -98,6 +99,11 @@ void demo_quit(void)
        quit = 1;
 }
 
+void swap_buffers(void *pixels)
+{
+       /* do nothing, all pointers point to the same buffer */
+}
+
 static void handle_event(SDL_Event *ev)
 {
        switch(ev->type) {
@@ -110,6 +116,21 @@ static void handle_event(SDL_Event *ev)
                demo_keyboard(ev->key.keysym.sym, ev->key.state == SDL_PRESSED ? 1 : 0);
                break;
 
+       case SDL_MOUSEMOTION:
+               mouse_x = ev->motion.x / fbscale;
+               mouse_y = ev->motion.y / fbscale;
+               break;
+
+       case SDL_MOUSEBUTTONDOWN:
+               mouse_bmask |= 1 << ev->button.button;
+               if(0) {
+       case SDL_MOUSEBUTTONUP:
+                       mouse_bmask &= ~(1 << ev->button.button);
+               }
+               mouse_x = ev->button.x / fbscale;
+               mouse_y = ev->button.y / fbscale;
+               break;
+
        default:
                break;
        }