diff --git a/src/conio/bitmap_con.c b/src/conio/bitmap_con.c index 5117a4d1416e12560afc659f536188db4e5ee5ce..6a18d9bd6c17fa045de614fabd0c1d3899a0bebb 100644 --- a/src/conio/bitmap_con.c +++ b/src/conio/bitmap_con.c @@ -35,7 +35,7 @@ pthread_mutex_t vmem_lock; struct video_stats vstat; struct bitmap_callbacks { - void (*drawrect) (int xpos, int ypos, int width, int height, unsigned char *data); + void (*drawrect) (int xpos, int ypos, int width, int height, uint32_t *data); void (*flush) (void); }; @@ -122,7 +122,7 @@ static void blinker_thread(void *data) /* * MUST be called only once and before any other bitmap functions */ -int bitmap_init(void (*drawrect_cb) (int xpos, int ypos, int width, int height, unsigned char *data) +int bitmap_init(void (*drawrect_cb) (int xpos, int ypos, int width, int height, uint32_t *data) ,void (*flush_cb) (void)) { if(bitmap_initialized) @@ -179,6 +179,7 @@ int bitmap_init_mode(int mode, int *width, int *height) if(height) *height=screenheight; newscreen=realloc(screen, screenwidth*screenheight*sizeof(screen[0])); + if(!newscreen) { pthread_mutex_unlock(&vstatlock); pthread_mutex_unlock(&screenlock); @@ -223,7 +224,7 @@ int bitmap_init_mode(int mode, int *width, int *height) */ void send_rectangle(struct video_stats *vs, int xoffset, int yoffset, int width, int height, int force) { - unsigned char *rect; + uint32_t *rect; int pixel=0; int inpixel; int x,y; @@ -235,14 +236,14 @@ void send_rectangle(struct video_stats *vs, int xoffset, int yoffset, int width, if(xoffset < 0 || xoffset >= screenwidth || yoffset < 0 || yoffset >= screenheight || width <= 0 || width > screenwidth || height <=0 || height >screenheight) goto end; - rect=(unsigned char *)malloc(width*height*sizeof(unsigned char)); + rect=(uint32_t *)malloc(width*height*sizeof(rect[0])); if(!rect) goto end; for(y=0; y<height; y++) { inpixel=PIXEL_OFFSET(xoffset, yoffset+y); for(x=0; x<width; x++) - rect[pixel++]=vs->palette[screen[inpixel++]]; + rect[pixel++]=screen[inpixel++]; } pthread_mutex_unlock(&screenlock); callbacks.drawrect(xoffset,yoffset,width,height,rect); @@ -783,7 +784,6 @@ error_return: static void bitmap_draw_cursor(struct video_stats *vs) { - int x; int y; char attr; int pixel; @@ -805,9 +805,7 @@ static void bitmap_draw_cursor(struct video_stats *vs) for(y=vs->curs_start; y<=vs->curs_end; y++) { if(xoffset < screenwidth && (yoffset+y) < screenheight) { pixel=PIXEL_OFFSET(xoffset, yoffset+y); - for(x=0;x<vs->charwidth;x++) - screen[pixel++]=attr; - //memset(screen+pixel,attr,vs->charwidth); + memset_u32(screen+pixel,vs->palette[attr],vs->charwidth); } } pthread_mutex_unlock(&screenlock); @@ -901,10 +899,10 @@ static int bitmap_draw_one_char(struct video_stats *vs, unsigned int xpos, unsig fontoffset=(sch&0xff)*vs->charheight; for(y=0; y<vs->charheight; y++) { - memset_u32(&screen[PIXEL_OFFSET(xoffset, yoffset+y)],bg,vs->charwidth); + memset_u32(&screen[PIXEL_OFFSET(xoffset, yoffset+y)],vs->palette[bg],vs->charwidth); for(x=0; x<vs->charwidth; x++) { if(this_font[fontoffset] & (0x80 >> x)) - screen[PIXEL_OFFSET(xoffset+x, yoffset+y)]=fg; + screen[PIXEL_OFFSET(xoffset+x, yoffset+y)]=vs->palette[fg]; } fontoffset++; } diff --git a/src/conio/bitmap_con.h b/src/conio/bitmap_con.h index ee6345b9a94ab4a2eec9290c51ac8fb03434766b..cb48a29deebdf803d82913a7d09297560cb3e4bc 100644 --- a/src/conio/bitmap_con.h +++ b/src/conio/bitmap_con.h @@ -19,7 +19,7 @@ int bitmap_loadfont(char *filename); void send_rectangle(struct video_stats *vs, int xoffset, int yoffset, int width, int height, int force); int bitmap_init_mode(int mode, int *width, int *height); -int bitmap_init(void (*drawrect_cb) (int xpos, int ypos, int width, int height, unsigned char *data) +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); diff --git a/src/conio/sdl_con.c b/src/conio/sdl_con.c index 9e95ea890c84aadac345beb3947b689a3fa1d030..41f8b87f20db92e1d4184c449ed12c4319ddbf67 100644 --- a/src/conio/sdl_con.c +++ b/src/conio/sdl_con.c @@ -105,7 +105,7 @@ struct update_rect { int y; int width; int height; - unsigned char *data; + uint32_t *data; }; struct sdl_palette { @@ -621,7 +621,7 @@ char *sdl_getcliptext(void) return(ret); } -void sdl_drawrect(int xoffset,int yoffset,int width,int height,unsigned char *data) +void sdl_drawrect(int xoffset,int yoffset,int width,int height,uint32_t *data) { struct update_rect *rect; diff --git a/src/conio/vidmodes.c b/src/conio/vidmodes.c index cc853d1429eed01dac887caf70caef7bbc72f526..dde06277cda037cce4f8676aea2c71df10b1a87f 100644 --- a/src/conio/vidmodes.c +++ b/src/conio/vidmodes.c @@ -108,7 +108,7 @@ struct video_params vparams[49] = { {VESA_132X60, COLOUR_PALETTE, 132, 60, 7, 7, 8, 8, 1}, }; -unsigned char palettes[5][16] = { +uint32_t palettes[5][16] = { /* Mono */ { 0x00, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07 @@ -118,33 +118,121 @@ unsigned char palettes[5][16] = { 0x08, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f }, /* Colour */ - { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f + { 0x00, 0x04, 0x02, 0x06, 0x01, 0x05, 0x03, 0x07, + 0x08, 0x0c, 0x0a, 0x0e, 0x09, 0x0d, 0x0b, 0x0f }, /* C64 */ - { 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f + { 0x100, 0x101, 0x102, 0x103, 0x104, 0x105, 0x106, 0x107, + 0x108, 0x109, 0x10a, 0x10b, 0x10c, 0x10d, 0x10e, 0x10f }, /* Atari */ - { 0x20, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, - 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21 + { 0x110, 0x111, 0x111, 0x111, 0x111, 0x111, 0x111, 0x111, + 0x111, 0x111, 0x111, 0x111, 0x111, 0x111, 0x111, 0x111 }, }; struct dac_colors dac_default[TOTAL_DAC_SIZE] = { - {0, 0, 0}, {0, 0, 168}, {0, 168, 0}, {0, 168, 168}, - {168, 0, 0}, {168, 0, 168}, {168, 84, 0}, {168, 168, 168}, - {84, 84, 84}, {84, 84, 255}, {84, 255, 84}, {84, 255, 255}, - {255, 84, 84}, {255, 84, 255}, {255, 255, 84}, {255, 255, 255}, + /* "System" colours */ + {0, 0, 0}, // Black + {168, 0, 0}, // Red + {0, 168, 0}, // Green + {168, 84, 0}, // Brown + {0, 0, 168}, // Blue + {168, 0, 168}, // Magenta + {0, 168, 168}, // Cyan + {168, 168, 168}, // Light Gray + + {84, 84, 84}, // Dark Gray + {255, 84, 84}, // Light Red + {84, 255, 84}, // Light Green + {255, 255, 84}, // Yellow + {84, 84, 255}, // Light Blue + {255, 84, 255}, // Light Magenta + {84, 255, 255}, // Light Cyan + {255, 255, 255}, // White + + /* XTerm 256 colour palette */ + {0, 0, 0}, {0, 0, 95}, {0, 0, 135}, {0, 0, 175}, + {0, 0, 215}, {0, 0, 255}, {0, 95, 0}, {0, 95, 95}, + {0, 95, 135}, {0, 95, 175}, {0, 95, 215}, {0, 95, 255}, + {0, 135, 0}, {0, 135, 95}, {0, 135, 135}, {0, 135, 175}, + {0, 135, 215}, {0, 135, 255}, {0, 175, 0}, {0, 175, 95}, + {0, 175, 135}, {0, 175, 175}, {0, 175, 215}, {0, 175, 255}, + {0, 215, 0}, {0, 215, 95}, {0, 215, 135}, {0, 215, 175}, + {0, 215, 215}, {0, 215, 255}, {0, 255, 0}, {0, 255, 95}, + {0, 255, 135}, {0, 255, 175}, {0, 255, 215}, {0, 255, 255}, + {95, 0, 0}, {95, 0, 95}, {95, 0, 135}, {95, 0, 175}, + {95, 0, 215}, {95, 0, 255}, {95, 95, 0}, {95, 95, 95}, + {95, 95, 135}, {95, 95, 175}, {95, 95, 215}, {95, 95, 255}, + {95, 135, 0}, {95, 135, 95}, {95, 135, 135}, {95, 135, 175}, + {95, 135, 215}, {95, 135, 255}, {95, 175, 0}, {95, 175, 95}, + {95, 175, 135}, {95, 175, 175}, {95, 175, 215}, {95, 175, 255}, + {95, 215, 0}, {95, 215, 95}, {95, 215, 135}, {95, 215, 175}, + {95, 215, 215}, {95, 215, 255}, {95, 255, 0}, {95, 255, 95}, + {95, 255, 135}, {95, 255, 175}, {95, 255, 215}, {95, 255, 255}, + {135, 0, 0}, {135, 0, 95}, {135, 0, 135}, {135, 0, 175}, + {135, 0, 215}, {135, 0, 255}, {135, 95, 0}, {135, 95, 95}, + {135, 95, 135}, {135, 95, 175}, {135, 95, 215}, {135, 95, 255}, + {135, 135, 0}, {135, 135, 95}, {135, 135, 135}, {135, 135, 175}, + {135, 135, 215}, {135, 135, 255}, {135, 175, 0}, {135, 175, 95}, + {135, 175, 135}, {135, 175, 175}, {135, 175, 215}, {135, 175, 255}, + {135, 215, 0}, {135, 215, 95}, {135, 215, 135}, {135, 215, 175}, + {135, 215, 215}, {135, 215, 255}, {135, 255, 0}, {135, 255, 95}, + {135, 255, 135}, {135, 255, 175}, {135, 255, 215}, {135, 255, 255}, + {175, 0, 0}, {175, 0, 95}, {175, 0, 135}, {175, 0, 175}, + {175, 0, 215}, {175, 0, 255}, {175, 95, 0}, {175, 95, 95}, + {175, 95, 135}, {175, 95, 175}, {175, 95, 215}, {175, 95, 255}, + {175, 135, 0}, {175, 135, 95}, {175, 135, 135}, {175, 135, 175}, + {175, 135, 215}, {175, 135, 255}, {175, 175, 0}, {175, 175, 95}, + {175, 175, 135}, {175, 175, 175}, {175, 175, 215}, {175, 175, 255}, + {175, 215, 0}, {175, 215, 95}, {175, 215, 135}, {175, 215, 175}, + {175, 215, 215}, {175, 215, 255}, {175, 255, 0}, {175, 255, 95}, + {175, 255, 135}, {175, 255, 175}, {175, 255, 215}, {175, 255, 255}, + {215, 0, 0}, {215, 0, 95}, {215, 0, 135}, {215, 0, 175}, + {215, 0, 215}, {215, 0, 255}, {215, 95, 0}, {215, 95, 95}, + {215, 95, 135}, {215, 95, 175}, {215, 95, 215}, {215, 95, 255}, + {215, 135, 0}, {215, 135, 95}, {215, 135, 135}, {215, 135, 175}, + {215, 135, 215}, {215, 135, 255}, {215, 175, 0}, {215, 175, 95}, + {215, 175, 135}, {215, 175, 175}, {215, 175, 215}, {215, 175, 255}, + {215, 215, 0}, {215, 215, 95}, {215, 215, 135}, {215, 215, 175}, + {215, 215, 215}, {215, 215, 255}, {215, 255, 0}, {215, 255, 95}, + {215, 255, 135}, {215, 255, 175}, {215, 255, 215}, {215, 255, 255}, + {255, 0, 0}, {255, 0, 95}, {255, 0, 135}, {255, 0, 175}, + {255, 0, 215}, {255, 0, 255}, {255, 95, 0}, {255, 95, 95}, + {255, 95, 135}, {255, 95, 175}, {255, 95, 215}, {255, 95, 255}, + {255, 135, 0}, {255, 135, 95}, {255, 135, 135}, {255, 135, 175}, + {255, 135, 215}, {255, 135, 255}, {255, 175, 0}, {255, 175, 95}, + {255, 175, 135}, {255, 175, 175}, {255, 175, 215}, {255, 175, 255}, + {255, 215, 0}, {255, 215, 95}, {255, 215, 135}, {255, 215, 175}, + {255, 215, 215}, {255, 215, 255}, {255, 255, 0}, {255, 255, 95}, + {255, 255, 135}, {255, 255, 175}, {255, 255, 215}, {255, 255, 255}, + {8, 8, 8}, {18, 18, 18}, {28, 28, 28}, {38, 38, 38}, + {48, 48, 48}, {58, 58, 58}, {68, 68, 68}, {78, 78, 78}, + {88, 88, 88}, {98, 98, 98}, {108, 108, 108}, {118, 118, 118}, + {128, 128, 128}, {138, 138, 138}, {148, 148, 148}, {158, 158, 158}, + {168, 168, 168}, {178, 178, 178}, {188, 188, 188}, {198, 198, 198}, + {208, 208, 208}, {218, 218, 218}, {228, 228, 228}, {238, 238, 238}, + /* C64 colours */ /* Black, White, Red, Cyan, Purple, Green, Blue, Yellow */ /* Orange, Brown, Lt Red, Dk Grey, Grey, Lt Green, Lt Blue, Lt Grey */ - {0x00, 0x00, 0x00}, {0xff, 0xff, 0xff}, {0x68, 0x37, 0x2b}, - {0x70, 0xa4, 0xb2}, {0x6f, 0x3d, 0x86}, {0x58, 0x8d, 0x43}, - {0x35, 0x29, 0x79}, {0xb8, 0xc7, 0x6f}, {0x6f, 0x4f, 0x25}, - {0x43, 0x39, 0x00}, {0x9a, 0x67, 0x59}, {0x44, 0x44, 0x44}, - {0x6c, 0x6c, 0x6c}, {0x9a, 0xd2, 0x84}, {0x6c, 0x5e, 0xb5}, - {0x95, 0x95, 0x95}, + /* Taken from CTerm source */ + {0x00, 0x00, 0x00}, // Black + {0xFD, 0xFE, 0xFC}, // White + {0xBE, 0x1A, 0x24}, // Red + {0x30, 0xE6, 0xC6}, // Cyan + {0xB4, 0x1A, 0xE2}, // Purple + {0x1F, 0xD2, 0x1E}, // Green + {0x21, 0x1B, 0xAE}, // Blue + {0xDF, 0xF6, 0x0A}, // Yellow + {0xB8, 0x41, 0x04}, // Orange + {0x6A, 0x33, 0x04}, // Brown + {0xFE, 0x4A, 0x57}, // Light Red + {0x42, 0x45, 0x40}, // Dark Grey + {0x70, 0x74, 0x6F}, // Grey + {0x59, 0xFE, 0x59}, // Light Green + {0x5F, 0x53, 0xFE}, // Light Blue + {0xA4, 0xA7, 0xA2}, // Light Grey /* Atari Colours */ /* BG, FG */ {0, 81, 129}, {96, 183, 231}, @@ -226,7 +314,6 @@ int load_vmode(struct video_stats *vs, int mode) if(vs->curs_col >= vparams[i].cols) vs->curs_col=vparams[i].cols-1; memcpy(vs->palette, palettes[vparams[i].palette], sizeof(vs->palette)); - memcpy(vs->dac_colors, dac_default, sizeof(dac_default)); vs->charheight=vparams[i].charheight; vs->charwidth=vparams[i].charwidth; vs->mode=mode; diff --git a/src/conio/vidmodes.h b/src/conio/vidmodes.h index 0d6425308460ba54c2518a5f29eebd8fc9ecbf6e..f46c38eefba8b451563ba4e80c7067f1b3891d07 100644 --- a/src/conio/vidmodes.h +++ b/src/conio/vidmodes.h @@ -43,7 +43,7 @@ #include "ciolib.h" -#define TOTAL_DAC_SIZE 34 +#define TOTAL_DAC_SIZE 274 /* Entry type for the DAC table. */ struct dac_colors { @@ -92,8 +92,7 @@ struct video_stats { int currattr; int scaling; int vmultiplier; - struct dac_colors dac_colors[256]; - unsigned char palette[16]; + uint32_t palette[16]; struct vstat_vmem *vmem; }; @@ -107,7 +106,7 @@ enum { extern struct video_params vparams[49]; #define NUMMODES (sizeof(vparams) / sizeof(struct video_params)) -extern unsigned char palettes[5][16]; +extern uint32_t palettes[5][16]; extern struct dac_colors dac_default[TOTAL_DAC_SIZE]; extern char vga_font_bitmap[4096]; extern char vga_font_bitmap14[3584]; diff --git a/src/conio/x_cio.c b/src/conio/x_cio.c index b95dd6fd2fa8bee7c8802898f13e78afa3320330..bca8bff37ed232e0b8da0327832c35f6081c31fb 100644 --- a/src/conio/x_cio.c +++ b/src/conio/x_cio.c @@ -425,7 +425,7 @@ int x_init(void) return(0); } -void x11_drawrect(int xoffset,int yoffset,int width,int height,unsigned char *data) +void x11_drawrect(int xoffset,int yoffset,int width,int height,uint32_t *data) { struct x11_local_event ev; diff --git a/src/conio/x_cio.h b/src/conio/x_cio.h index af328d7a681e97d8d1e8cb329b2cd5bc1bb465ae..2f75c7a61cd115b7af26f36ab7074c58f73fa7ab 100644 --- a/src/conio/x_cio.h +++ b/src/conio/x_cio.h @@ -71,7 +71,7 @@ int x_getfont(void); int x_loadfont(char *filename); 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,unsigned char *data); +void x11_drawrect(int xoffset,int yoffset,int width,int height,uint32_t *data); void x11_flush(void); #ifdef __cplusplus } diff --git a/src/conio/x_events.h b/src/conio/x_events.h index 1a83ea385ece3949699faf9cb669b24a24636381..4fa78f4f1227024df0d1b9ca42d24d8dc0e233f2 100644 --- a/src/conio/x_events.h +++ b/src/conio/x_events.h @@ -11,7 +11,7 @@ struct update_rect { int y; int width; int height; - unsigned char *data; + uint32_t *data; }; enum x11_local_events {