eobish
diff src/fblibdos.c @ 7:6a350c554e46
started DOS port
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Mon, 19 Jan 2015 15:49:14 +0200 |
parents | |
children |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/fblibdos.c Mon Jan 19 15:49:14 2015 +0200 1.3 @@ -0,0 +1,62 @@ 1.4 +#ifdef FBLIB_DOS 1.5 +#include "vbegfx.h" 1.6 + 1.7 +static unsigned char *framebuf; 1.8 + 1.9 +int fb_init(int width, int height, int bpp) 1.10 +{ 1.11 + init_timer(128); 1.12 + if(kb_init(32) == -1) { 1.13 + fprintf(stderr, "failed to initialize keyboard driver\n"); 1.14 + return false; 1.15 + } 1.16 + 1.17 + if(!(framebuf = set_video_mode(width, height, bpp))) { 1.18 + return -1; 1.19 + } 1.20 + fb_width = width; 1.21 + fb_height = height; 1.22 + fb_bpp = get_color_depth(); 1.23 + 1.24 + 1.25 + return 0; 1.26 +} 1.27 + 1.28 +void fb_shutdown(void) 1.29 +{ 1.30 + framebuf = 0; 1.31 + set_text_mode(); 1.32 +} 1.33 + 1.34 +void *fb_begin_frame(void) 1.35 +{ 1.36 + return framebuf; 1.37 +} 1.38 + 1.39 +void fb_end_frame(void) 1.40 +{ 1.41 + wait_vsync(void); 1.42 +} 1.43 + 1.44 +void fb_set_palette_range(int start, int count, int *colors) 1.45 +{ 1.46 + /* TODO: add a range-palette setter in vbegfx.c */ 1.47 + int i; 1.48 + for(i=0; i<count; i++) { 1.49 + set_palette(start + i, colors[0], colors[1], colors[2]); 1.50 + colors += 3; 1.51 + } 1.52 +} 1.53 + 1.54 +int fb_process_events(void) 1.55 +{ 1.56 + if(handle_keyboard() == -1) { 1.57 + return -1; 1.58 + } 1.59 + if(handle_mouse() == -1) { 1.60 + return -1; 1.61 + } 1.62 + return 0; 1.63 +} 1.64 + 1.65 +#endif /* FBLIB_DOS */