Commit 1b34a5fa authored by deuce's avatar deuce
Browse files

Start overhaul of bitmap_con... first order of business, separate the

display driver interface from the ciolib interface.
parent 121a413a
This diff is collapsed.
......@@ -40,18 +40,16 @@ typedef pthread_mutex_t pthread_rwlock_t;
extern struct video_stats vstat;
extern pthread_rwlock_t vstatlock;
int bitmap_pgettext(int sx, int sy, int ex, int ey, void *fill, uint32_t *fg, uint32_t *bg);
#ifndef BITMAP_CIOLIB_DRIVER
/* Called from ciolib */
int bitmap_puttext(int sx, int sy, int ex, int ey, void *fill);
int bitmap_pputtext(int sx, int sy, int ex, int ey, void *fill, uint32_t *fg, uint32_t *bg);
int bitmap_pgettext(int sx, int sy, int ex, int ey, void *fill, uint32_t *fg, uint32_t *bg);
void bitmap_gotoxy(int x, int y);
void bitmap_setcursortype(int type);
int bitmap_setfont(int font, int force, int font_no);
int bitmap_getfont(void);
int bitmap_loadfont(char *filename);
int bitmap_init_mode(int mode, int *width, int *height);
int bitmap_init(void (*drawrect_cb) (int xpos, int ypos, int width, int height, uint32_t *data)
,void (*flush) (void));
int bitmap_movetext(int x, int y, int ex, int ey, int tox, int toy);
void bitmap_clreol(void);
void bitmap_clrscr(void);
......@@ -59,13 +57,19 @@ void bitmap_getcustomcursor(int *s, int *e, int *r, int *b, int *v);
void bitmap_setcustomcursor(int s, int e, int r, int b, int v);
int bitmap_getvideoflags(void);
void bitmap_setvideoflags(int flags);
void bitmap_setscaling(int new_value);
int bitmap_getscaling(void);
int bitmap_attr2palette(uint8_t attr, uint32_t *fgp, uint32_t *bgp);
int bitmap_setpixel(uint32_t x, uint32_t y, uint32_t colour);
struct ciolib_pixels *bitmap_getpixels(uint32_t sx, uint32_t sy, uint32_t ex, uint32_t ey);
int bitmap_setpixels(uint32_t sx, uint32_t sy, uint32_t ex, uint32_t ey, uint32_t x_off, uint32_t y_off, struct ciolib_pixels *, void *mask);
void bitmap_request_pixels(void);
void bitmap_request_some_pixels(int x, int y, int width, int height);
struct ciolib_pixels *bitmap_getpixels(uint32_t sx, uint32_t sy, uint32_t ex, uint32_t ey);
#endif
#ifdef BITMAP_CIOLIB_DRIVER
/* Called from drivers */
int bitmap_drv_init_mode(int mode, int *width, int *height);
int bitmap_drv_init(void (*drawrect_cb) (int xpos, int ypos, int width, int height, uint32_t *data)
,void (*flush) (void));
void bitmap_drv_request_pixels(void);
void bitmap_drv_request_some_pixels(int x, int y, int width, int height);
#endif
#endif
......@@ -230,8 +230,8 @@ int try_x_init(int mode)
cio_api.copytext=x_copytext;
cio_api.getcliptext=x_getcliptext;
cio_api.get_window_info=x_get_window_info;
cio_api.setscaling=bitmap_setscaling;
cio_api.getscaling=bitmap_getscaling;
cio_api.setscaling=x_setscaling;
cio_api.getscaling=x_getscaling;
cio_api.setpalette=x_setpalette;
cio_api.attr2palette=bitmap_attr2palette;
cio_api.setpixel=bitmap_setpixel;
......
......@@ -27,6 +27,7 @@
#include "ciolib.h"
#include "vidmodes.h"
#define BITMAP_CIOLIB_DRIVER
#include "bitmap_con.h"
#include "SDL.h"
......@@ -630,7 +631,7 @@ int sdl_setpalette(uint32_t index, uint16_t r, uint16_t g, uint16_t b)
pal->g = g>>8;
pal->b = b>>8;
sdl_user_func(SDL_USEREVENT_SETPALETTE, pal);
bitmap_request_pixels();
bitmap_drv_request_pixels();
}
}
return 0;
......@@ -652,7 +653,7 @@ int sdl_init_mode(int mode)
sdl_user_func(SDL_USEREVENT_FLUSH);
bitmap_init_mode(mode, &bitmap_width, &bitmap_height);
bitmap_drv_init_mode(mode, &bitmap_width, &bitmap_height);
/* Deal with 40 col doubling */
pthread_rwlock_wrlock(&vstatlock);
......@@ -693,7 +694,7 @@ int sdl_init(int mode)
return(-1);
}
bitmap_init(sdl_drawrect, sdl_flush);
bitmap_drv_init(sdl_drawrect, sdl_flush);
sdl.mutexP(bitmap_init_mutex);
bitmap_initialized=1;
sdl.mutexV(bitmap_init_mutex);
......@@ -775,7 +776,7 @@ void sdl_setscaling(int new_value)
{
if (yuv.enabled)
return;
bitmap_setscaling(new_value);
vstat.scaling = new_value;
}
/* Called from main thread only */
......@@ -783,7 +784,7 @@ int sdl_getscaling(void)
{
if (yuv.enabled)
return 1;
return bitmap_getscaling();
return vstat.scaling;
}
/* Called from main thread only */
......@@ -1056,7 +1057,7 @@ void setup_surfaces(void)
sdl_setup_colours(new_rect);
sdl.mutexV(newrect_mutex);
sdl_setup_colours(win);
bitmap_request_pixels();
bitmap_drv_request_pixels();
}
else if(sdl_init_good) {
ev.type=SDL_QUIT;
......@@ -1701,7 +1702,6 @@ int sdl_video_event_thread(void *data)
else {
pthread_rwlock_rdlock(&vstatlock);
new_scaling = (int)(ev.resize.w/(vstat.charwidth*vstat.cols));
fprintf(stderr, "%d/%d - New Scaling %d\n", ev.resize.w, ev.resize.h, new_scaling);
cvstat = vstat;
pthread_rwlock_unlock(&vstatlock);
}
......@@ -1710,7 +1710,7 @@ fprintf(stderr, "%d/%d - New Scaling %d\n", ev.resize.w, ev.resize.h, new_scalin
case SDL_VIDEOEXPOSE:
{
if(yuv.enabled) {
bitmap_request_pixels();
bitmap_drv_request_pixels();
}
else {
if(upd_rects) {
......
......@@ -52,6 +52,9 @@
#include "x_cio.h"
#include "x_events.h"
#define BITMAP_CIOLIB_DRIVER
#include "bitmap_con.h"
int x_kbhit(void)
{
fd_set rfd;
......@@ -467,3 +470,20 @@ void x11_flush(void)
if(x11_initialized)
write_event(&ev);
}
void x_setscaling(int newval)
{
pthread_rwlock_wrlock(&vstatlock);
vstat.scaling = newval;
pthread_rwlock_unlock(&vstatlock);
}
int x_getscaling(void)
{
int ret;
pthread_rwlock_rdlock(&vstatlock);
ret = vstat.scaling;
pthread_rwlock_unlock(&vstatlock);
return ret;
}
......@@ -73,6 +73,8 @@ int x_setpalette(uint32_t entry, uint16_t r, uint16_t g, uint16_t b);
int x_get_window_info(int *width, int *height, int *xpos, int *ypos);
void x11_drawrect(int xoffset,int yoffset,int width,int height,uint32_t *data);
void x11_flush(void);
void x_setscaling(int newval);
int x_getscaling(void);
#ifdef __cplusplus
}
#endif
......
......@@ -22,6 +22,7 @@
#include "vidmodes.h"
#include "ciolib.h"
#define BITMAP_CIOLIB_DRIVER
#include "bitmap_con.h"
#include "link_list.h"
#include "x_events.h"
......@@ -296,7 +297,7 @@ static void map_window()
x11.XFree(sh);
bitmap_request_pixels();
bitmap_drv_request_pixels();
return;
}
......@@ -318,7 +319,7 @@ static int init_mode(int mode)
oldcols=cvstat.cols;
bitmap_init_mode(mode, &bitmap_width, &bitmap_height);
bitmap_drv_init_mode(mode, &bitmap_width, &bitmap_height);
pthread_rwlock_wrlock(&vstatlock);
/* Deal with 40 col doubling */
......@@ -336,7 +337,7 @@ static int init_mode(int mode)
/* Resize window if necessary. */
if((!(bitmap_width == 0 && bitmap_height == 0)) && (oldwidth != bitmap_width || oldheight != bitmap_height))
resize_window();
bitmap_request_pixels();
bitmap_drv_request_pixels();
cvstat = vstat;
pthread_rwlock_unlock(&vstatlock);
......@@ -359,7 +360,7 @@ static int video_init()
if(init_window())
return(-1);
bitmap_init(x11_drawrect, x11_flush);
bitmap_drv_init(x11_drawrect, x11_flush);
/* Initialize mode 3 (text, 80x25, 16 colors) */
if(init_mode(3)) {
......@@ -476,7 +477,7 @@ static void handle_resize_event(int width, int height)
|| (height % (vstat.charheight * vstat.rows) != 0)) {
resize_window();
}
bitmap_request_pixels();
bitmap_drv_request_pixels();
cvstat = vstat;
pthread_rwlock_unlock(&vstatlock);
}
......@@ -499,7 +500,7 @@ static void expose_rect(int x, int y, int width, int height)
ex=ex/cvstat.scaling;
ey=ey/(cvstat.scaling*cvstat.vmultiplier);
bitmap_request_some_pixels(sx, sy, ex-sx+1, ey-sy+1);
bitmap_drv_request_some_pixels(sx, sy, ex-sx+1, ey-sy+1);
}
static int x11_event(XEvent *ev)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment