X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Fdos%2Fmain.c;h=ecbba9f74b4784e62c329d7e853ade0a8a0bc388;hb=b4512666bb27febff4a3e17d1f1dd06a9f2168a9;hp=b353f3336b8512c765c7bc53bc523da8847ea2f2;hpb=86ea36402d2ba296db0950d85e18c50f7ee7006b;p=retroray diff --git a/src/dos/main.c b/src/dos/main.c index b353f33..ecbba9f 100644 --- a/src/dos/main.c +++ b/src/dos/main.c @@ -24,7 +24,11 @@ along with this program. If not, see . #include "gfx.h" #include "cdpmi.h" #include "mouse.h" +#include "logger.h" #include "options.h" +#include "cpuid.h" + +static void draw_cursor(int x, int y); static uint32_t *vmem; static int quit, disp_pending; @@ -34,20 +38,30 @@ int main(int argc, char **argv) int i; int vmidx; int mx, my, bnstate, bndiff; - static int prev_mx, prev_my, prev_bnstate; + static int prev_mx = -1, prev_my, prev_bnstate; #ifdef __DJGPP__ __djgpp_nearptr_enable(); #endif - kb_init(32); + init_logger(); + + if(read_cpuid(&cpuid) == 0) { + print_cpuid(&cpuid); + } + + kb_init(); if(!have_mouse()) { fprintf(stderr, "No mouse detected. Make sure the mouse driver is installed\n"); return 1; } set_mouse_limits(0, 0, 639, 479); - set_mouse(320, 240); + mx = 320; + my = 240; + set_mouse(mx, my); + + add_log_file("retroray.log"); if(init_video() == -1) { return 1; @@ -69,8 +83,25 @@ int main(int argc, char **argv) } disp_pending = 1; + app_reshape(win_width, win_height); + mx = win_width / 2; + my = win_height / 2; + set_mouse(mx, my); + for(;;) { int key; + + modkeys = 0; + if(kb_isdown(KEY_ALT)) { + modkeys |= KEY_MOD_ALT; + } + if(kb_isdown(KEY_CTRL)) { + modkeys |= KEY_MOD_CTRL; + } + if(kb_isdown(KEY_SHIFT)) { + modkeys |= KEY_MOD_SHIFT; + } + while((key = kb_getkey()) != -1) { app_keyboard(key, 1); if(quit) goto break_evloop; @@ -78,15 +109,35 @@ int main(int argc, char **argv) bnstate = read_mouse(&mx, &my); bndiff = bnstate ^ prev_bnstate; + prev_bnstate = bnstate; + + if(bndiff) { + dbgmsg("bndiff: %04x\n", bndiff); + } if(bndiff & 1) app_mouse(0, bnstate & 1, mx, my); if(bndiff & 2) app_mouse(1, bnstate & 2, mx, my); if(bndiff & 4) app_mouse(3, bnstate & 4, mx, my); + if(prev_my == -1) { + prev_mx = mx; + prev_my = my; + } else { + draw_cursor(prev_mx, prev_my); + } + if((mx ^ prev_mx) | (my ^ prev_my)) { + app_motion(mx, my); + } + if(disp_pending) { disp_pending = 0; app_display(); } + + draw_cursor(mx, my); + prev_mx = mx; + prev_my = my; + app_swap_buffers(); } break_evloop: @@ -128,3 +179,17 @@ void app_fullscreen(int fs) void app_vsync(int vsync) { } + +static void draw_cursor(int x, int y) +{ + int i; + uint32_t *fbptr = framebuf + y * win_width + x; + + for(i=0; i<3; i++) { + int offs = i + 1; + if(y > offs) fbptr[-win_width * offs] ^= 0xffffff; + if(y < win_height - offs - 1) fbptr[win_width * offs] ^= 0xffffff; + if(x > offs) fbptr[-offs] ^= 0xffffff; + if(x < win_width - offs - 1) fbptr[offs] ^= 0xffffff; + } +}