X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=bootcensus;a=blobdiff_plain;f=src%2Ftest%2Fvbetest.c;h=1133decb769ddbb18a778d3c32691efc9326b295;hp=91a8c8cd44ddec153c0d15e6e78e786c8726fd68;hb=5e8cc93aaf1173688852acaa0825698c2dc0cb3f;hpb=91253d061647c194cdc8c16c9ae85eccdf942139 diff --git a/src/test/vbetest.c b/src/test/vbetest.c index 91a8c8c..1133dec 100644 --- a/src/test/vbetest.c +++ b/src/test/vbetest.c @@ -3,13 +3,38 @@ #include "video.h" #include "asmops.h" #include "keyb.h" +#include "psaux.h" #include "contty.h" +static void draw_cursor(int x, int y, uint16_t col); + static uint16_t *framebuf; +#define CURSOR_XSZ 12 +#define CURSOR_YSZ 16 +static uint16_t cursor[] = { + 0xffff, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0xffff, 0xffff, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0xffff, 0x0001, 0xffff, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0xffff, 0x0001, 0x0001, 0xffff, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0xffff, 0x0001, 0x0001, 0x0001, 0xffff, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0xffff, 0x0001, 0x0001, 0x0001, 0x0001, 0xffff, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0xffff, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0xffff, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0xffff, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0xffff, 0x0000, 0x0000, 0x0000, 0x0000, + 0xffff, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0xffff, 0x0000, 0x0000, 0x0000, + 0xffff, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0xffff, 0xffff, 0xffff, 0xffff, 0x0000, 0x0000, + 0xffff, 0x0001, 0x0001, 0x0001, 0x0001, 0xffff, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0xffff, 0x0001, 0x0001, 0xffff, 0x0001, 0x0001, 0xffff, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0xffff, 0x0001, 0xffff, 0xffff, 0x0001, 0x0001, 0xffff, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0xffff, 0xffff, 0x0000, 0x0000, 0xffff, 0x0001, 0x0001, 0xffff, 0x0000, 0x0000, 0x0000, 0x0000, + 0xffff, 0x0000, 0x0000, 0x0000, 0xffff, 0x0001, 0x0001, 0xffff, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xffff, 0xffff, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 +}; + int vbetest(void) { - int i, j, nmodes; + int i, j, nmodes, mx, my; + unsigned int st; struct video_mode vi; uint16_t *fbptr; @@ -51,8 +76,19 @@ int vbetest(void) } } + set_mouse_bounds(0, 0, 639, 479); + + /* empty the kb queue */ while(kb_getkey() != -1); - while(kb_getkey() == -1) { + + for(;;) { + if(kb_getkey() != -1) { + break; + } + + st = mouse_state(&mx, &my); + draw_cursor(mx, my, st & 1 ? 0xf800 : (st & 2 ? 0x7e0 : (st & 4 ? 0x00ff : 0))); + halt_cpu(); } @@ -60,3 +96,54 @@ int vbetest(void) con_clear(); return 0; } + +static void draw_cursor(int x, int y, uint16_t col) +{ + static uint16_t saved[CURSOR_XSZ * CURSOR_YSZ]; + static int saved_x = -1, saved_y, saved_w, saved_h; + + int i, j, w, h; + uint16_t *dest, *src, *savp; + + if(saved_x >= 0) { + dest = framebuf + saved_y * 640 + saved_x; + src = saved; + + for(i=0; i CURSOR_XSZ) w = CURSOR_XSZ; + h = 480 - y; + if(h > CURSOR_YSZ) h = CURSOR_YSZ; + + saved_x = x; + saved_y = y; + saved_w = w; + saved_h = h; + + for(i=0; i