From 1fd6745aea5391634439c9b9cc9682ea83d56884 Mon Sep 17 00:00:00 2001 From: Volker Ruppert Date: Sun, 14 Oct 2012 18:29:44 +0000 Subject: [PATCH] Started rewrite of the gui code to make the graphics snapshot independent from the display adapter code. When ready, the common gui code should handle it completely. The snapshot handler should set a flag 'snapshot_mode' and then it should force a display update. The graphics update code should be redirected to some code that 'draws' to a snapshot buffer. These first steps are done: - store some guest display settings in the gui code (text / graphics switch, x / y resolution and bpp) - split 8 bpp palette update code in a common and a specific part and store the palette values in the gui code --- bochs/gui/amigaos.cc | 8 ++- bochs/gui/carbon.cc | 43 ++++++++-------- bochs/gui/gui.cc | 79 ++++++++++++++++-------------- bochs/gui/gui.h | 45 +++++++++++------ bochs/gui/macintosh.cc | 43 ++++++++-------- bochs/gui/nogui.cc | 10 ++-- bochs/gui/rfb.cc | 8 ++- bochs/gui/sdl.cc | 57 +++++++++------------ bochs/gui/svga.cc | 21 ++++---- bochs/gui/term.cc | 8 ++- bochs/gui/win32.cc | 30 +++++------- bochs/gui/wx.cc | 19 +++---- bochs/gui/x.cc | 14 +++--- bochs/iodev/display/svga_cirrus.cc | 26 ++-------- bochs/iodev/display/svga_cirrus.h | 4 +- bochs/iodev/display/vga.cc | 25 +--------- bochs/iodev/display/vga.h | 4 +- bochs/iodev/display/vgacore.cc | 50 ++----------------- bochs/iodev/display/vgacore.h | 5 +- bochs/iodev/iodev.h | 7 +-- bochs/plugin.h | 5 +- 21 files changed, 219 insertions(+), 292 deletions(-) diff --git a/bochs/gui/amigaos.cc b/bochs/gui/amigaos.cc index 3ccfd0fdd..046d30ce2 100644 --- a/bochs/gui/amigaos.cc +++ b/bochs/gui/amigaos.cc @@ -585,7 +585,7 @@ int bx_amigaos_gui_c::set_clipboard_text(char *text_snapshot, Bit32u len) return 1; } -bx_bool bx_amigaos_gui_c::palette_change(unsigned index, unsigned red, unsigned green, unsigned blue) +bx_bool bx_amigaos_gui_c::palette_change(Bit8u index, Bit8u red, Bit8u green, Bit8u blue) { Bit8u *ptr = (Bit8u *)(cmap+index); @@ -625,10 +625,14 @@ void bx_amigaos_gui_c::dimension_update(unsigned x, unsigned y, unsigned fheight if (bpp > 8) { BX_PANIC(("%d bpp graphics mode not supported yet", bpp)); } + guest_textmode = (fheight > 0); + guest_xres = x; + guest_yres = y; + guest_bpp = bpp; int xdiff = w - x; - if (fheight > 0) { + if (guest_textmode) { text_cols = x / fwidth; text_rows = y / fheight; if (fwidth != 8) { diff --git a/bochs/gui/carbon.cc b/bochs/gui/carbon.cc index af7769d45..31690c5a5 100644 --- a/bochs/gui/carbon.cc +++ b/bochs/gui/carbon.cc @@ -136,7 +136,7 @@ unsigned width, height, gMinTop, gMaxTop, gLeft; GWorldPtr gOffWorld; Ptr gMyBuffer; ProcessSerialNumber gProcessSerNum; -static unsigned vga_bpp=8; +static unsigned disp_bpp=8; static EventModifiers oldMods = 0; static unsigned int text_rows=25, text_cols=80; @@ -569,13 +569,12 @@ void CreateTile(void) CGrafPtr savePort; OSErr err; unsigned long p_f; - long theRowBytes = ((((long) (vga_bpp==24?32:(((vga_bpp+1)>>1)<<1)) * ((long) (srcTileRect.right-srcTileRect.left)) + 31) >> 5) << 2); + long theRowBytes = ((((long) (disp_bpp==24?32:(((disp_bpp+1)>>1)<<1)) * ((long) (srcTileRect.right-srcTileRect.left)) + 31) >> 5) << 2); // if (SIM->get_param_bool(BXPN_PRIVATE_COLORMAP)->get()) // { GetGWorld(&savePort, &saveDevice); - switch(vga_bpp) - { + switch (disp_bpp) { case 1: p_f = k1MonochromePixelFormat; break; @@ -604,7 +603,7 @@ void CreateTile(void) BX_ASSERT((gMyBuffer = (Ptr)malloc(theRowBytes * (srcTileRect.bottom - srcTileRect.top))) != NULL); err = NewGWorldFromPtr(&gOffWorld, p_f, - &srcTileRect, vga_bpp>8 ? NULL : gCTable, NULL, keepLocal, gMyBuffer, theRowBytes); + &srcTileRect, disp_bpp>8 ? NULL : gCTable, NULL, keepLocal, gMyBuffer, theRowBytes); if (err != noErr || gOffWorld == NULL) BX_PANIC(("mac: can't create gOffWorld; err=%hd", err)); @@ -1314,7 +1313,7 @@ int bx_carbon_gui_c::set_clipboard_text(char *text_snapshot, Bit32u len) // returns: 0=no screen update needed (color map change has direct effect) // 1=screen updated needed (redraw using current colormap) -bx_bool bx_carbon_gui_c::palette_change(unsigned index, unsigned red, unsigned green, unsigned blue) +bx_bool bx_carbon_gui_c::palette_change(Bit8u index, Bit8u red, Bit8u green, Bit8u blue) { PaletteHandle thePal, oldpal; GDHandle saveDevice; @@ -1405,22 +1404,19 @@ void bx_carbon_gui_c::graphics_tile_update(Bit8u *tile, unsigned x0, unsigned y0 BX_PANIC(("mac: LockPortBits returned %hd", theError)); if ((theBaseAddr = GetPixBaseAddr(gTile)) == NULL) BX_PANIC(("mac: gTile has NULL baseAddr (offscreen buffer purged)")); - else if (vga_bpp == 24 || vga_bpp == 32) - { - for (unsigned iY = 0; iY < (srcTileRect.bottom-srcTileRect.top); iY++) - { + else if (disp_bpp == 24 || disp_bpp == 32) { + for (unsigned iY = 0; iY < (srcTileRect.bottom-srcTileRect.top); iY++) { Bit8u *iA = ((Bit8u *)theBaseAddr) + iY * GetPixRowBytes(gTile); - for (unsigned iX = 0; iX < (srcTileRect.right-srcTileRect.left); iX++) - { - iA[iX*4 + 3] = tile[((srcTileRect.right-srcTileRect.left)*iY+iX)*(vga_bpp>>3)]; - iA[iX*4 + 2] = tile[((srcTileRect.right-srcTileRect.left)*iY+iX)*(vga_bpp>>3) + 1]; - iA[iX*4 + 1] = tile[((srcTileRect.right-srcTileRect.left)*iY+iX)*(vga_bpp>>3) + 2]; - iA[iX*4] = vga_bpp == 24 ? 0 : tile[((srcTileRect.right-srcTileRect.left)*iY+iX)*4 + 3]; + for (unsigned iX = 0; iX < (srcTileRect.right-srcTileRect.left); iX++) { + iA[iX*4 + 3] = tile[((srcTileRect.right-srcTileRect.left)*iY+iX)*(disp_bpp>>3)]; + iA[iX*4 + 2] = tile[((srcTileRect.right-srcTileRect.left)*iY+iX)*(disp_bpp>>3) + 1]; + iA[iX*4 + 1] = tile[((srcTileRect.right-srcTileRect.left)*iY+iX)*(disp_bpp>>3) + 2]; + iA[iX*4] = disp_bpp == 24 ? 0 : tile[((srcTileRect.right-srcTileRect.left)*iY+iX)*4 + 3]; } } - } - else + } else { BlockMoveData(tile, theBaseAddr, (srcTileRect.bottom-srcTileRect.top) * GetPixRowBytes(gTile)); + } if ((theError = UnlockPortBits(gOffWorld)) != noErr) BX_ERROR(("mac: UnlockPortBits returned %hd", theError)); RGBForeColor(&black); @@ -1454,17 +1450,20 @@ void bx_carbon_gui_c::dimension_update(unsigned x, unsigned y, unsigned fheight, if ((bpp != 1) && (bpp != 2) && (bpp != 4) && (bpp != 8) && (bpp != 15) && (bpp != 16) && (bpp != 24) && (bpp != 32)) { BX_PANIC(("%d bpp graphics mode not supported yet", bpp)); } - if (bpp != vga_bpp) - { + guest_textmode = (fheight > 0); + guest_xres = x; + guest_yres = y; + guest_bpp = bpp; + if (bpp != disp_bpp) { free(gMyBuffer); DisposeGWorld(gOffWorld); if ((gCTable == NULL) || (*gCTable == NULL) || (*gCTable == (void *)-1)) gCTable = GetCTable(128); - vga_bpp = bpp; + disp_bpp = bpp; CreateTile(); } - if (fheight > 0) { + if (guest_textmode) { text_cols = x / fwidth; text_rows = y / fheight; if(fwidth != font_width || fheight != font_height) { diff --git a/bochs/gui/gui.cc b/bochs/gui/gui.cc index 0d9bc60e0..7de18146b 100644 --- a/bochs/gui/gui.cc +++ b/bochs/gui/gui.cc @@ -99,6 +99,11 @@ bx_gui_c::bx_gui_c(void): disp_mode(DISP_MODE_SIM) statusitem_count = 0; led_timer_index = BX_NULL_TIMER_HANDLE; framebuffer = NULL; + guest_textmode = 1; + guest_xres = 640; + guest_yres = 480; + guest_bpp = 8; + memset(palette, 0, sizeof(palette)); } bx_gui_c::~bx_gui_c() @@ -410,8 +415,8 @@ void bx_gui_c::copy_handler(void) Bit32u len; char *text_snapshot; - if (DEV_vga_get_snapshot_mode() == BX_GUI_SNAPSHOT_TXT) { - make_text_snapshot (&text_snapshot, &len); + if (BX_GUI_THIS guest_textmode) { + make_text_snapshot(&text_snapshot, &len); if (!BX_GUI_THIS set_clipboard_text(text_snapshot, len)) { // platform specific code failed, use portable code instead FILE *fp = fopen("copy.txt", "w"); @@ -420,7 +425,7 @@ void bx_gui_c::copy_handler(void) } free(text_snapshot); } else { - BX_ERROR(("copy button failed, mode not implemented")); + BX_ERROR(("copy button failed, graphics mode not implemented")); } } @@ -428,16 +433,14 @@ void bx_gui_c::copy_handler(void) void bx_gui_c::snapshot_handler(void) { int fd, i, j, mode, pitch; - Bit8u *snapshot_ptr = NULL, *palette_ptr = NULL; + Bit8u *snapshot_ptr = NULL; Bit8u *row_buffer, *pixel_ptr, *row_ptr; Bit8u bmp_header[54], iBits, b1, b2; Bit32u ilen, len, rlen; char filename[BX_PATHNAME_LEN]; - unsigned iHeight, iWidth, iDepth; - mode = DEV_vga_get_snapshot_mode(); - if (mode == BX_GUI_SNAPSHOT_TXT) { - make_text_snapshot ((char**)&snapshot_ptr, &len); + if (BX_GUI_THIS guest_textmode) { + make_text_snapshot((char**)&snapshot_ptr, &len); if (BX_GUI_THIS dialog_caps & BX_GUI_DLG_SNAPSHOT) { int ret = SIM->ask_filename (filename, sizeof(filename), "Save snapshot as...", "snapshot.txt", @@ -458,10 +461,11 @@ void bx_gui_c::snapshot_handler(void) fwrite(snapshot_ptr, 1, len, fp); fclose(fp); free(snapshot_ptr); - } else if (mode == BX_GUI_SNAPSHOT_GFX) { - ilen = DEV_vga_get_gfx_snapshot(&snapshot_ptr, &palette_ptr, &iHeight, &iWidth, &iDepth); + } else { + ilen = DEV_vga_get_gfx_snapshot(&snapshot_ptr); if (ilen > 0) { - BX_INFO(("GFX snapshot: %u x %u x %u bpp (%u bytes)", iWidth, iHeight, iDepth, ilen)); + BX_INFO(("GFX snapshot: %u x %u x %u bpp (%u bytes)", BX_GUI_THIS guest_xres, + BX_GUI_THIS guest_yres, BX_GUI_THIS guest_bpp, ilen)); } else { BX_ERROR(("snapshot button failed: cannot allocate memory")); return; @@ -471,7 +475,6 @@ void bx_gui_c::snapshot_handler(void) "Save snapshot as...", "snapshot.bmp", bx_param_string_c::SAVE_FILE_DIALOG); if (ret < 0) { // cancelled - if (palette_ptr != NULL) free(palette_ptr); free(snapshot_ptr); return; } @@ -486,14 +489,13 @@ void bx_gui_c::snapshot_handler(void) ); if (fd < 0) { BX_ERROR(("snapshot button failed: cannot create BMP file")); - if (palette_ptr != NULL) free(palette_ptr); free(snapshot_ptr); return; } - iBits = (iDepth == 8) ? 8 : 24; - rlen = (iWidth * (iBits >> 3) + 3) & ~3; - len = rlen * iHeight + 54; - if ((iDepth == 8) && (palette_ptr != NULL)) { + iBits = (BX_GUI_THIS guest_bpp == 8) ? 8 : 24; + rlen = (BX_GUI_THIS guest_xres * (iBits >> 3) + 3) & ~3; + len = rlen * BX_GUI_THIS guest_yres + 54; + if (BX_GUI_THIS guest_bpp == 8) { len += (256 * 4); } memset(bmp_header, 0, 54); @@ -504,34 +506,34 @@ void bx_gui_c::snapshot_handler(void) bmp_header[4] = (len >> 16) & 0xff; bmp_header[5] = (len >> 24) & 0xff; bmp_header[10] = 54; - if ((iDepth == 8) && (palette_ptr != NULL)) { + if (BX_GUI_THIS guest_bpp == 8) { bmp_header[11] = 4; } bmp_header[14] = 40; - bmp_header[18] = iWidth & 0xff; - bmp_header[19] = (iWidth >> 8) & 0xff; - bmp_header[22] = iHeight & 0xff; - bmp_header[23] = (iHeight >> 8) & 0xff; + bmp_header[18] = BX_GUI_THIS guest_xres & 0xff; + bmp_header[19] = (BX_GUI_THIS guest_xres >> 8) & 0xff; + bmp_header[22] = BX_GUI_THIS guest_yres & 0xff; + bmp_header[23] = (BX_GUI_THIS guest_yres >> 8) & 0xff; bmp_header[26] = 1; bmp_header[28] = iBits; write(fd, bmp_header, 54); - if ((iDepth == 8) && (palette_ptr != NULL)) { - write(fd, palette_ptr, 256 * 4); + if (BX_GUI_THIS guest_bpp == 8) { + write(fd, bx_gui->palette, 256 * 4); } - pitch = iWidth * ((iDepth + 1) >> 3); + pitch = BX_GUI_THIS guest_xres * ((BX_GUI_THIS guest_bpp + 1) >> 3); row_buffer = (Bit8u*)malloc(rlen); - row_ptr = snapshot_ptr + ((iHeight - 1) * pitch); - for (i = iHeight; i > 0; i--) { + row_ptr = snapshot_ptr + ((BX_GUI_THIS guest_yres - 1) * pitch); + for (i = BX_GUI_THIS guest_yres; i > 0; i--) { memset(row_buffer, 0, rlen); - if ((iDepth == 8) || (iDepth == 24)) { + if ((BX_GUI_THIS guest_bpp == 8) || (BX_GUI_THIS guest_bpp == 24)) { memcpy(row_buffer, row_ptr, pitch); - } else if ((iDepth == 15) || (iDepth == 16)) { + } else if ((BX_GUI_THIS guest_bpp == 15) || (BX_GUI_THIS guest_bpp == 16)) { pixel_ptr = row_ptr; - for (j = 0; j < (int)(iWidth * 3); j+=3) { + for (j = 0; j < (int)(BX_GUI_THIS guest_xres * 3); j+=3) { b1 = *(pixel_ptr++); b2 = *(pixel_ptr++); *(row_buffer+j) = (b1 << 3); - if (iDepth == 15) { + if (BX_GUI_THIS guest_bpp == 15) { *(row_buffer+j+1) = ((b1 & 0xe0) >> 2) | (b2 << 6); *(row_buffer+j+2) = (b2 & 0x7c) << 1; } else { @@ -539,9 +541,9 @@ void bx_gui_c::snapshot_handler(void) *(row_buffer+j+2) = (b2 & 0xf8); } } - } else if (iDepth == 32) { + } else if (BX_GUI_THIS guest_bpp == 32) { pixel_ptr = row_ptr; - for (j = 0; j < (int)(iWidth * 3); j+=3) { + for (j = 0; j < (int)(BX_GUI_THIS guest_xres * 3); j+=3) { *(row_buffer+j) = *(pixel_ptr++); *(row_buffer+j+1) = *(pixel_ptr++); *(row_buffer+j+2) = *(pixel_ptr++); @@ -553,10 +555,7 @@ void bx_gui_c::snapshot_handler(void) } free(row_buffer); close(fd); - if (palette_ptr != NULL) free(palette_ptr); free(snapshot_ptr); - } else { - BX_ERROR(("snapshot button failed: unsupported VGA mode")); } } @@ -926,6 +925,14 @@ void bx_gui_c::graphics_tile_update_in_place(unsigned x0, unsigned y0, delete [] tile; } +bx_bool bx_gui_c::palette_change_common(Bit8u index, Bit8u red, Bit8u green, Bit8u blue) +{ + palette[index].red = red; + palette[index].green = green; + palette[index].blue = blue; + return palette_change(index, red, green, blue); +} + void bx_gui_c::show_ips(Bit32u ips_count) { #if BX_SHOW_IPS diff --git a/bochs/gui/gui.h b/bochs/gui/gui.h index e5f985389..8fd34d011 100644 --- a/bochs/gui/gui.h +++ b/bochs/gui/gui.h @@ -48,11 +48,6 @@ #define BX_GUI_MT_F12 (BX_MT_KEY_F12) #define BX_GUI_MT_CTRL_ALT (BX_MT_KEY_CTRL | BX_MT_KEY_ALT) -// snapshot feature -#define BX_GUI_SNAPSHOT_UNSUP 0 -#define BX_GUI_SNAPSHOT_TXT 1 -#define BX_GUI_SNAPSHOT_GFX 2 - typedef struct { Bit16u start_address; Bit8u cs_start; @@ -102,7 +97,7 @@ public: virtual void handle_events(void) = 0; virtual void flush(void) = 0; virtual void clear_screen(void) = 0; - virtual bx_bool palette_change(unsigned index, unsigned red, unsigned green, unsigned blue) = 0; + virtual bx_bool palette_change(Bit8u index, Bit8u red, Bit8u green, Bit8u blue) = 0; virtual void dimension_update(unsigned x, unsigned y, unsigned fheight=0, unsigned fwidth=0, unsigned bpp=8) = 0; virtual unsigned create_bitmap(const unsigned char *bmap, unsigned xdim, unsigned ydim) = 0; virtual unsigned headerbar_bitmap(unsigned bmap_id, unsigned alignment, void (*f)(void)) = 0; @@ -148,6 +143,7 @@ public: void init(int argc, char **argv, unsigned max_xres, unsigned max_yres, unsigned x_tilesize, unsigned y_tilesize); void cleanup(void); + bx_bool palette_change_common(Bit8u index, Bit8u red, Bit8u green, Bit8u blue); void update_drive_status_buttons(void); static void mouse_enabled_changed(bx_bool val); int register_statusitem(const char *text, bx_bool auto_off=0); @@ -162,7 +158,7 @@ public: protected: // And these are defined and used privately in gui.cc - static void make_text_snapshot (char **snapshot, Bit32u *length); + // header bar button handers static void floppyA_handler(void); static void floppyB_handler(void); static void cdrom1_handler(void); @@ -174,10 +170,13 @@ protected: static void config_handler(void); static void userbutton_handler(void); static void save_restore_handler(void); - + // text snapshot helper function + static void make_text_snapshot(char **snapshot, Bit32u *length); + // status bar LED timer static void led_timer_handler(void *); void led_timer(void); + // header bar buttons bx_bool floppyA_status; bx_bool floppyB_status; bx_bool cdrom1_status; @@ -193,11 +192,11 @@ protected: unsigned mouse_bmap_id, nomouse_bmap_id, mouse_hbar_id; unsigned user_bmap_id, user_hbar_id; unsigned save_restore_bmap_id, save_restore_hbar_id; - + // text charmap unsigned char vga_charmap[0x2000]; bx_bool charmap_updated; bx_bool char_changed[256]; - + // status bar items unsigned statusitem_count; int led_timer_index; struct { @@ -207,22 +206,38 @@ protected: bx_bool auto_off; Bit8u counter; } statusitem[BX_MAX_STATUSITEMS]; - + // display mode disp_mode_t disp_mode; + // new graphics API (with compatibility mode) bx_bool new_gfx_api; Bit16u host_xres; Bit16u host_yres; Bit16u host_pitch; Bit8u host_bpp; + Bit8u *framebuffer; + // maximum guest display size and tile size unsigned max_xres; unsigned max_yres; unsigned x_tilesize; unsigned y_tilesize; - Bit8u *framebuffer; - Bit32u dialog_caps; + // current guest display settings + bx_bool guest_textmode; + unsigned guest_xres; + unsigned guest_yres; + unsigned guest_bpp; + // current palette (for graphics snapshot + struct { + Bit8u red; + Bit8u green; + Bit8u blue; + Bit8u reserved; + } palette[256]; + // mouse toggle setup Bit8u toggle_method; Bit32u toggle_keystate; char mouse_toggle_text[20]; + // gui dialog capabilities + Bit32u dialog_caps; }; @@ -245,8 +260,8 @@ virtual void graphics_tile_update(Bit8u *snapshot, unsigned x, unsigned y); \ virtual void handle_events(void); \ virtual void flush(void); \ virtual void clear_screen(void); \ -virtual bx_bool palette_change(unsigned index, \ -unsigned red, unsigned green, unsigned blue); \ +virtual bx_bool palette_change(Bit8u index, Bit8u red, Bit8u green, \ + Bit8u blue); \ virtual void dimension_update(unsigned x, unsigned y, unsigned fheight=0, \ unsigned fwidth=0, unsigned bpp=8); \ virtual unsigned create_bitmap(const unsigned char *bmap, \ diff --git a/bochs/gui/macintosh.cc b/bochs/gui/macintosh.cc index 7fdb2999e..cddb77dc4 100644 --- a/bochs/gui/macintosh.cc +++ b/bochs/gui/macintosh.cc @@ -129,7 +129,7 @@ Point prevPt; unsigned width, height, gMinTop, gMaxTop, gLeft; GWorldPtr gOffWorld; Ptr gMyBuffer; -static unsigned vga_bpp=8; +static unsigned disp_bpp=8; static EventModifiers oldMods = 0; static unsigned int text_rows=25, text_cols=80; @@ -247,14 +247,13 @@ void CreateTile(void) CGrafPtr savePort; OSErr err; unsigned long p_f; - long theRowBytes = ((((long) (vga_bpp==24?32:(((vga_bpp+1)>>1)<<1)) * ((long) (srcTileRect.right-srcTileRect.left)) + 31) >> 5) << 2); + long theRowBytes = ((((long) (disp_bpp==24?32:(((disp_bpp+1)>>1)<<1)) * ((long) (srcTileRect.right-srcTileRect.left)) + 31) >> 5) << 2); //if (SIM->get_param_bool(BXPN_PRIVATE_COLORMAP)->get()) //{ GetGWorld(&savePort, &saveDevice); - switch(vga_bpp) - { + switch (disp_bpp) { case 1: p_f = k1MonochromePixelFormat; break; @@ -283,7 +282,7 @@ void CreateTile(void) BX_ASSERT((gMyBuffer = (Ptr)malloc(theRowBytes * (srcTileRect.bottom - srcTileRect.top))) != NULL); err = QTNewGWorldFromPtr(&gOffWorld, p_f, - &srcTileRect, vga_bpp>8 ? NULL : gCTable, NULL, keepLocal, gMyBuffer, theRowBytes); + &srcTileRect, disp_bpp>8 ? NULL : gCTable, NULL, keepLocal, gMyBuffer, theRowBytes); if (err != noErr || gOffWorld == NULL) BX_PANIC(("mac: can't create gOffWorld; err=%hd", err)); @@ -967,7 +966,7 @@ int bx_macintosh_gui_c::set_clipboard_text(char *text_snapshot, Bit32u len) // returns: 0=no screen update needed (color map change has direct effect) // 1=screen updated needed (redraw using current colormap) -bx_bool bx_macintosh_gui_c::palette_change(unsigned index, unsigned red, unsigned green, unsigned blue) +bx_bool bx_macintosh_gui_c::palette_change(Bit8u index, Bit8u red, Bit8u green, Bit8u blue) { PaletteHandle thePal, oldpal; GDHandle saveDevice; @@ -1051,22 +1050,19 @@ void bx_macintosh_gui_c::graphics_tile_update(Bit8u *tile, unsigned x0, unsigned //(**gTile).baseAddr = (Ptr)tile; if ((theBaseAddr = GetPixBaseAddr(gTile)) == NULL) BX_PANIC(("mac: gTile has NULL baseAddr (offscreen buffer purged)")); - else if (vga_bpp == 24 || vga_bpp == 32) - { - for (unsigned iY = 0; iY < (srcTileRect.bottom-srcTileRect.top); iY++) - { + else if (disp_bpp == 24 || disp_bpp == 32) { + for (unsigned iY = 0; iY < (srcTileRect.bottom-srcTileRect.top); iY++) { Bit8u *iA = ((Bit8u *)theBaseAddr) + iY * GetPixRowBytes(gTile); - for (unsigned iX = 0; iX < (srcTileRect.right-srcTileRect.left); iX++) - { - iA[iX*4 + 3] = tile[((srcTileRect.right-srcTileRect.left)*iY+iX)*(vga_bpp>>3)]; - iA[iX*4 + 2] = tile[((srcTileRect.right-srcTileRect.left)*iY+iX)*(vga_bpp>>3) + 1]; - iA[iX*4 + 1] = tile[((srcTileRect.right-srcTileRect.left)*iY+iX)*(vga_bpp>>3) + 2]; - iA[iX*4] = vga_bpp == 24 ? 0 : tile[((srcTileRect.right-srcTileRect.left)*iY+iX)*4 + 3]; + for (unsigned iX = 0; iX < (srcTileRect.right-srcTileRect.left); iX++) { + iA[iX*4 + 3] = tile[((srcTileRect.right-srcTileRect.left)*iY+iX)*(disp_bpp>>3)]; + iA[iX*4 + 2] = tile[((srcTileRect.right-srcTileRect.left)*iY+iX)*(disp_bpp>>3) + 1]; + iA[iX*4 + 1] = tile[((srcTileRect.right-srcTileRect.left)*iY+iX)*(disp_bpp>>3) + 2]; + iA[iX*4] = disp_bpp == 24 ? 0 : tile[((srcTileRect.right-srcTileRect.left)*iY+iX)*4 + 3]; } } - } - else + } else { BlockMoveData(tile, theBaseAddr, (srcTileRect.bottom-srcTileRect.top) * GetPixRowBytes(gTile)); + } RGBForeColor(&black); RGBBackColor(&white); CopyBits(GetPortBitMapForCopyBits(gOffWorld), &WINBITMAP(win), @@ -1095,16 +1091,19 @@ void bx_macintosh_gui_c::dimension_update(unsigned x, unsigned y, unsigned fheig if ((bpp != 1) && (bpp != 2) && (bpp != 4) && (bpp != 8) && (bpp != 15) && (bpp != 16) && (bpp != 24) && (bpp != 32)) { BX_PANIC(("%d bpp graphics mode not supported yet", bpp)); } - if (bpp != vga_bpp) - { + guest_textmode = (fheight > 0); + guest_xres = x; + guest_yres = y; + guest_bpp = bpp; + if (bpp != disp_bpp) { free(gMyBuffer); if ((**gTile).pixelType == RGBDirect) gCTable = GetCTable(128); DisposeGWorld(gOffWorld); - vga_bpp = bpp; + disp_bpp = bpp; CreateTile(); } - if (fheight > 0) { + if (guest_textmode) { text_cols = x / fwidth; text_rows = y / fheight; if (fwidth != 8) { diff --git a/bochs/gui/nogui.cc b/bochs/gui/nogui.cc index fdf68d349..ef7bbec22 100644 --- a/bochs/gui/nogui.cc +++ b/bochs/gui/nogui.cc @@ -177,7 +177,7 @@ int bx_nogui_gui_c::set_clipboard_text(char *text_snapshot, Bit32u len) // returns: 0=no screen update needed (color map change has direct effect) // 1=screen updated needed (redraw using current colormap) -bx_bool bx_nogui_gui_c::palette_change(unsigned index, unsigned red, unsigned green, unsigned blue) +bx_bool bx_nogui_gui_c::palette_change(Bit8u index, Bit8u red, Bit8u green, Bit8u blue) { UNUSED(index); UNUSED(red); @@ -224,11 +224,11 @@ void bx_nogui_gui_c::graphics_tile_update(Bit8u *tile, unsigned x0, unsigned y0) void bx_nogui_gui_c::dimension_update(unsigned x, unsigned y, unsigned fheight, unsigned fwidth, unsigned bpp) { - UNUSED(x); - UNUSED(y); - UNUSED(fheight); + guest_textmode = (fheight > 0); + guest_xres = x; + guest_yres = y; + guest_bpp = bpp; UNUSED(fwidth); - UNUSED(bpp); } diff --git a/bochs/gui/rfb.cc b/bochs/gui/rfb.cc index b1f31e125..4f6549563 100644 --- a/bochs/gui/rfb.cc +++ b/bochs/gui/rfb.cc @@ -857,7 +857,7 @@ int bx_rfb_gui_c::set_clipboard_text(char *text_snapshot, Bit32u len) // returns: 0=no screen update needed (color map change has direct effect) // 1=screen updated needed (redraw using current colormap) -bx_bool bx_rfb_gui_c::palette_change(unsigned index, unsigned red, unsigned green, unsigned blue) +bx_bool bx_rfb_gui_c::palette_change(Bit8u index, Bit8u red, Bit8u green, Bit8u blue) { rfbPalette[index] = (((red * 7 + 127) / 255) << 0) | (((green * 7 + 127) / 255) << 3) | (((blue * 3 + 127) / 255) << 6); return(1); @@ -968,7 +968,11 @@ void bx_rfb_gui_c::dimension_update(unsigned x, unsigned y, unsigned fheight, un if (bpp > 8) { BX_ERROR(("%d bpp graphics mode not supported yet", bpp)); } - if (fheight > 0) { + guest_textmode = (fheight > 0); + guest_xres = x; + guest_yres = y; + guest_bpp = bpp; + if (guest_textmode) { font_height = fheight; font_width = fwidth; text_cols = x / fwidth; diff --git a/bochs/gui/sdl.cc b/bochs/gui/sdl.cc index 492f63036..77aa425a9 100644 --- a/bochs/gui/sdl.cc +++ b/bochs/gui/sdl.cc @@ -108,9 +108,9 @@ static unsigned int text_rows = 25, text_cols = 80; Bit8u h_panning = 0, v_panning = 0; Bit16u line_compare = 1023; int fontwidth = 8, fontheight = 16; -static unsigned vga_bpp=8; +static unsigned disp_bpp=8; unsigned char menufont[256][8]; -Uint32 palette[256]; +Uint32 sdl_palette[256]; Uint32 headerbar_fg, headerbar_bg; Bit8u old_mousebuttons=0, new_mousebuttons=0; int old_mousex=0, new_mousex=0; @@ -483,7 +483,7 @@ void bx_sdl_gui_c::text_update(Bit8u *old_text, Bit8u *new_text, charmap_updated = 0; } for (i=0; i<16; i++) { - text_palette[i] = palette[tm_info->actl_palette[i]]; + text_palette[i] = sdl_palette[tm_info->actl_palette[i]]; } if ((tm_info->h_panning != h_panning) || (tm_info->v_panning != v_panning)) { forceUpdate = 1; @@ -581,11 +581,9 @@ void bx_sdl_gui_c::text_update(Bit8u *old_text, Bit8u *new_text, } // check if char needs to be updated if(forceUpdate || (old_text[0] != new_text[0]) - || (old_text[1] != new_text[1])) - { - - // Get Foreground/Background pixel colors - fgcolor = text_palette[new_text[1] & 0x0F]; + || (old_text[1] != new_text[1])) { + // Get Foreground/Background pixel colors + fgcolor = text_palette[new_text[1] & 0x0F]; if (blink_mode) { bgcolor = text_palette[(new_text[1] >> 4) & 0x07]; if (!blink_state && (new_text[1] & 0x80)) @@ -712,24 +710,21 @@ void bx_sdl_gui_c::graphics_tile_update(Bit8u *snapshot, unsigned x, unsigned y) if(i + y > res_y) i = res_y - y; // FIXME - if(i<=0) return; + if (i<=0) return; - switch (vga_bpp) - { + switch (disp_bpp) { case 8: /* 8 bpp */ - do - { + do { buf_row = buf; j = x_tilesize; - do - { - *buf++ = palette[*snapshot++]; + do { + *buf++ = sdl_palette[*snapshot++]; } while(--j); buf = buf_row + disp; } while(--i); break; default: - BX_PANIC(("%u bpp modes handled by new graphics API", vga_bpp)); + BX_PANIC(("%u bpp modes handled by new graphics API", disp_bpp)); return; } } @@ -1233,18 +1228,12 @@ void bx_sdl_gui_c::clear_screen(void) SDL_UpdateRect(sdl_fullscreen,0,0,res_x,res_y); } -bx_bool bx_sdl_gui_c::palette_change(unsigned index, unsigned red, unsigned green, unsigned blue) +bx_bool bx_sdl_gui_c::palette_change(Bit8u index, Bit8u red, Bit8u green, Bit8u blue) { - unsigned char palred = red & 0xFF; - unsigned char palgreen = green & 0xFF; - unsigned char palblue = blue & 0xFF; - - if(index > 255) return 0; - - if(sdl_screen) - palette[index] = SDL_MapRGB(sdl_screen->format, palred, palgreen, palblue); - else if(sdl_fullscreen) - palette[index] = SDL_MapRGB(sdl_fullscreen->format, palred, palgreen, palblue); + if (sdl_screen) + sdl_palette[index] = SDL_MapRGB(sdl_screen->format, red, green, blue); + else if (sdl_fullscreen) + sdl_palette[index] = SDL_MapRGB(sdl_fullscreen->format, red, green, blue); return 1; } @@ -1253,14 +1242,14 @@ void bx_sdl_gui_c::dimension_update(unsigned x, unsigned y, unsigned fheight, unsigned fwidth, unsigned bpp) { if (bpp == 8 || bpp == 15 || bpp == 16 || bpp == 24 || bpp == 32) { - vga_bpp = bpp; - } - else - { + disp_bpp = guest_bpp = bpp; + } else { BX_PANIC(("%d bpp graphics mode not supported", bpp)); } - if(fheight > 0) - { + guest_textmode = (fheight > 0); + guest_xres = x; + guest_yres = y; + if (guest_textmode) { fontheight = fheight; fontwidth = fwidth; text_cols = x / fontwidth; diff --git a/bochs/gui/svga.cc b/bochs/gui/svga.cc index 8a179eb88..f6600f4d3 100644 --- a/bochs/gui/svga.cc +++ b/bochs/gui/svga.cc @@ -438,19 +438,13 @@ void bx_svga_gui_c::clear_screen(void) gl_clearscreen(0); } -bx_bool bx_svga_gui_c::palette_change( - unsigned index, - unsigned red, - unsigned green, - unsigned blue) +bx_bool bx_svga_gui_c::palette_change(Bit8u index, Bit8u red, Bit8u green, Bit8u blue) { - if(index > 255) return 0; - // without VGA_CLUT8 extension we have only 6 bits for each r,g,b value if (!clut8 && (red > 63 || green > 63 || blue > 63)) { - red = red >> 2; - green = green >> 2; - blue = blue >> 2; + red = red >> 2; + green = green >> 2; + blue = blue >> 2; } vga_setpalette(index, red, green, blue); @@ -471,8 +465,11 @@ void bx_svga_gui_c::dimension_update( if (bpp > 8) { BX_PANIC(("%d bpp graphics mode not supported yet", bpp)); } - if(fheight > 0) - { + guest_textmode = (fheight > 0); + guest_xres = x; + guest_yres = y; + guest_bpp = bpp; + if (guest_textmode) { text_cols = x / fwidth; text_rows = y / fheight; fontheight = fheight; diff --git a/bochs/gui/term.cc b/bochs/gui/term.cc index df1e7cdba..5ad2db649 100644 --- a/bochs/gui/term.cc +++ b/bochs/gui/term.cc @@ -637,7 +637,7 @@ int bx_term_gui_c::set_clipboard_text(char *text_snapshot, Bit32u len) // returns: 0=no screen update needed (color map change has direct effect) // 1=screen updated needed (redraw using current colormap) -bx_bool bx_term_gui_c::palette_change(unsigned index, unsigned red, unsigned green, unsigned blue) +bx_bool bx_term_gui_c::palette_change(Bit8u index, Bit8u red, Bit8u green, Bit8u blue) { BX_DEBUG(("color pallete request (%d,%d,%d,%d) ignored", index,red,green,blue)); return(0); @@ -680,7 +680,11 @@ void bx_term_gui_c::dimension_update(unsigned x, unsigned y, unsigned fheight, u if (bpp > 8) { BX_PANIC(("%d bpp graphics mode not supported", bpp)); } - if (fheight > 0) { + guest_textmode = (fheight > 0); + guest_xres = x; + guest_yres = y; + guest_bpp = bpp; + if (guest_textmode) { text_cols = x / fwidth; text_rows = y / fheight; #if BX_HAVE_COLOR_SET diff --git a/bochs/gui/win32.cc b/bochs/gui/win32.cc index f4390172a..dcfd0ead8 100644 --- a/bochs/gui/win32.cc +++ b/bochs/gui/win32.cc @@ -166,7 +166,6 @@ bx_bool SB_ActiveW[BX_MAX_STATUSITEMS]; static unsigned dimension_x, dimension_y, current_bpp; static unsigned stretched_x, stretched_y; static unsigned stretch_factor=1; -static BOOL BxTextMode = TRUE; static BOOL fix_size = FALSE; #if BX_DEBUGGER && BX_DEBUGGER_GUI static BOOL gui_debug = FALSE; @@ -1789,8 +1788,8 @@ int bx_win32_gui_c::set_clipboard_text(char *text_snapshot, Bit32u len) // returns: 0=no screen update needed (color map change has direct effect) // 1=screen updated needed (redraw using current colormap) -bx_bool bx_win32_gui_c::palette_change(unsigned index, unsigned red, - unsigned green, unsigned blue) { +bx_bool bx_win32_gui_c::palette_change(Bit8u index, Bit8u red, Bit8u green, + Bit8u blue) { if ((current_bpp == 16) && (index < 3)) { cmap_index[256+index].rgbRed = red; cmap_index[256+index].rgbBlue = blue; @@ -1857,29 +1856,30 @@ void bx_win32_gui_c::graphics_tile_update(Bit8u *tile, unsigned x0, unsigned y0) void bx_win32_gui_c::dimension_update(unsigned x, unsigned y, unsigned fheight, unsigned fwidth, unsigned bpp) { - BxTextMode = (fheight > 0); - if (BxTextMode) { + guest_textmode = (fheight > 0); + guest_xres = x; + guest_yres = y; + if (guest_textmode) { text_cols = x / fwidth; text_rows = y / fheight; xChar = fwidth; yChar = fheight; } - if (x==dimension_x && y==dimension_y && bpp==current_bpp) + if (x == dimension_x && y == dimension_y && bpp == current_bpp) return; dimension_x = x; dimension_y = y; stretched_x = dimension_x; stretched_y = dimension_y; stretch_factor = 1; - if (BxTextMode && (stretched_x<400)) { + if (guest_textmode && (stretched_x<400)) { stretched_x *= 2; stretch_factor *= 2; } bitmap_info->bmiHeader.biBitCount = bpp; - if (bpp == 16) - { + if (bpp == 16) { bitmap_info->bmiHeader.biCompression = BI_BITFIELDS; static RGBQUAD red_mask = {0x00, 0xF8, 0x00, 0x00}; static RGBQUAD green_mask = {0xE0, 0x07, 0x00, 0x00}; @@ -1890,22 +1890,18 @@ void bx_win32_gui_c::dimension_update(unsigned x, unsigned y, unsigned fheight, bitmap_info->bmiColors[0] = red_mask; bitmap_info->bmiColors[1] = green_mask; bitmap_info->bmiColors[2] = blue_mask; - } - else - { - if (current_bpp == 16) - { + } else { + if (current_bpp == 16) { bitmap_info->bmiColors[0] = bitmap_info->bmiColors[256]; bitmap_info->bmiColors[1] = bitmap_info->bmiColors[257]; bitmap_info->bmiColors[2] = bitmap_info->bmiColors[258]; } bitmap_info->bmiHeader.biCompression = BI_RGB; - if (bpp == 15) - { + if (bpp == 15) { bitmap_info->bmiHeader.biBitCount = 16; } } - current_bpp = bpp; + current_bpp = guest_bpp = bpp; resize_main_window(); diff --git a/bochs/gui/wx.cc b/bochs/gui/wx.cc index 962e372da..8da7f6bdf 100644 --- a/bochs/gui/wx.cc +++ b/bochs/gui/wx.cc @@ -106,7 +106,7 @@ static unsigned long wxFontY = 0; static unsigned int text_rows=25, text_cols=80; static Bit8u h_panning = 0, v_panning = 0; static Bit16u line_compare = 1023; -static unsigned vga_bpp=8; +static unsigned disp_bpp = 8; static struct { unsigned char red; unsigned char green; @@ -1160,7 +1160,7 @@ static void UpdateScreen(unsigned char *newBits, int x, int y, int width, int he wxCriticalSectionLocker lock(wxScreen_lock); IFDBG_VGA(wxLogDebug (wxT ("MyPanel::UpdateScreen got lock. wxScreen=%p", wxScreen))); if(wxScreen != NULL) { - switch (vga_bpp) { + switch (disp_bpp) { case 8: /* 8 bpp */ for(int i = 0; i < height; i++) { char *pwxScreen = &wxScreen[(y * wxScreenX * 3) + (x * 3)]; @@ -1176,7 +1176,7 @@ static void UpdateScreen(unsigned char *newBits, int x, int y, int width, int he } break; default: - BX_PANIC(("%u bpp modes handled by new graphics API", vga_bpp)); + BX_PANIC(("%u bpp modes handled by new graphics API", disp_bpp)); return; } } else { @@ -1423,7 +1423,7 @@ void bx_wx_gui_c::text_update(Bit8u *old_text, Bit8u *new_text, // returns: 0=no screen update needed (color map change has direct effect) // 1=screen update needed (redraw using current colormap) -bx_bool bx_wx_gui_c::palette_change(unsigned index, unsigned red, unsigned green, unsigned blue) +bx_bool bx_wx_gui_c::palette_change(Bit8u index, Bit8u red, Bit8u green, Bit8u blue) { IFDBG_VGA(wxLogDebug (wxT ("palette_change"))); wxBochsPalette[index].red = red; @@ -1528,13 +1528,14 @@ void bx_wx_gui_c::dimension_update(unsigned x, unsigned y, unsigned fheight, uns BX_INFO (("dimension update x=%d y=%d fontheight=%d fontwidth=%d bpp=%d", x, y, fheight, fwidth, bpp)); if ((bpp == 8) || (bpp == 15) || (bpp == 16) || (bpp == 24) || (bpp == 32)) { if (bpp == 32) BX_INFO(("wxWidgets ignores bit 24..31 in 32bpp mode")); - vga_bpp = bpp; - } - else - { + disp_bpp = guest_bpp = bpp; + } else { BX_PANIC(("%d bpp graphics mode not supported", bpp)); } - if (fheight > 0) { + guest_textmode = (fheight > 0); + guest_xres = x; + guest_yres = y; + if (guest_textmode) { wxFontX = fwidth; wxFontY = fheight; text_cols = x / wxFontX; diff --git a/bochs/gui/x.cc b/bochs/gui/x.cc index e9b0f5cf5..48e5958c6 100644 --- a/bochs/gui/x.cc +++ b/bochs/gui/x.cc @@ -104,7 +104,6 @@ static unsigned prev_cursor_y=0; static Window win; static GC gc, gc_inv, gc_headerbar, gc_headerbar_inv; static unsigned dimension_x=0, dimension_y=0; -static unsigned vga_bpp=8; static XImage *ximage = NULL; static unsigned imDepth, imWide, imBPP; @@ -1490,7 +1489,7 @@ void bx_x_gui_c::graphics_tile_update(Bit8u *tile, unsigned x0, unsigned y0) } else { y_size = y_tilesize; } - switch (vga_bpp) { + switch (guest_bpp) { case 8: // 8 bits per pixel for (y=0; y 0) { + guest_textmode = (fheight > 0); + guest_xres = x; + guest_yres = y; + if (guest_textmode) { font_height = fheight; font_width = fwidth; text_cols = x / font_width; diff --git a/bochs/iodev/display/svga_cirrus.cc b/bochs/iodev/display/svga_cirrus.cc index 743e5dca3..7ca4c8221 100644 --- a/bochs/iodev/display/svga_cirrus.cc +++ b/bochs/iodev/display/svga_cirrus.cc @@ -464,9 +464,9 @@ void bx_svga_cirrus_c::after_restore_state(void) } #endif for (unsigned i=0; i<256; i++) { - bx_gui->palette_change(i, BX_CIRRUS_THIS s.pel.data[i].red<<2, - BX_CIRRUS_THIS s.pel.data[i].green<<2, - BX_CIRRUS_THIS s.pel.data[i].blue<<2); + bx_gui->palette_change_common(i, BX_CIRRUS_THIS s.pel.data[i].red<<2, + BX_CIRRUS_THIS s.pel.data[i].green<<2, + BX_CIRRUS_THIS s.pel.data[i].blue<<2); } BX_CIRRUS_THIS svga_needs_update_mode = 1; BX_CIRRUS_THIS svga_update(); @@ -825,32 +825,19 @@ void bx_svga_cirrus_c::mem_write(bx_phy_address addr, Bit8u value) } } -int bx_svga_cirrus_c::get_snapshot_mode() -{ - if ((BX_CIRRUS_THIS sequencer.reg[0x07] & 0x01) == CIRRUS_SR7_BPP_VGA) { - return BX_CIRRUS_THIS bx_vgacore_c::get_snapshot_mode(); - } else { - return BX_GUI_SNAPSHOT_GFX; - } -} - void bx_svga_cirrus_c::get_text_snapshot(Bit8u **text_snapshot, unsigned *txHeight, unsigned *txWidth) { BX_CIRRUS_THIS bx_vgacore_c::get_text_snapshot(text_snapshot,txHeight,txWidth); } -Bit32u bx_svga_cirrus_c::get_gfx_snapshot(Bit8u **snapshot_ptr, Bit8u **palette_ptr, - unsigned *iHeight, unsigned *iWidth, unsigned *iDepth) +Bit32u bx_svga_cirrus_c::get_gfx_snapshot(Bit8u **snapshot_ptr) { Bit32u len, len1; unsigned i; Bit8u *dst_ptr, *src_ptr; if ((BX_CIRRUS_THIS sequencer.reg[0x07] & 0x01) != CIRRUS_SR7_BPP_VGA) { - *iHeight = BX_CIRRUS_THIS svga_yres; - *iWidth = BX_CIRRUS_THIS svga_xres; - *iDepth = BX_CIRRUS_THIS svga_dispbpp; len1 = BX_CIRRUS_THIS svga_xres * (BX_CIRRUS_THIS svga_bpp >> 3); len = len1 * BX_CIRRUS_THIS svga_yres; *snapshot_ptr = (Bit8u*)malloc(len); @@ -863,12 +850,9 @@ Bit32u bx_svga_cirrus_c::get_gfx_snapshot(Bit8u **snapshot_ptr, Bit8u **palette_ src_ptr += BX_CIRRUS_THIS svga_pitch; dst_ptr += len1; } - if (*iDepth == 8) { - BX_CIRRUS_THIS get_dac_palette(palette_ptr, 2); - } return len; } else { - return BX_CIRRUS_THIS bx_vgacore_c::get_gfx_snapshot(snapshot_ptr, palette_ptr, iHeight, iWidth, iDepth); + return BX_CIRRUS_THIS bx_vgacore_c::get_gfx_snapshot(snapshot_ptr); } } diff --git a/bochs/iodev/display/svga_cirrus.h b/bochs/iodev/display/svga_cirrus.h index 44c532475..4ae13a438 100644 --- a/bochs/iodev/display/svga_cirrus.h +++ b/bochs/iodev/display/svga_cirrus.h @@ -73,11 +73,9 @@ public: unsigned width, unsigned height); virtual Bit8u mem_read(bx_phy_address addr); virtual void mem_write(bx_phy_address addr, Bit8u value); - virtual int get_snapshot_mode(void); virtual void get_text_snapshot(Bit8u **text_snapshot, unsigned *txHeight, unsigned *txWidth); - virtual Bit32u get_gfx_snapshot(Bit8u **snapshot_ptr, Bit8u **palette_ptr, - unsigned *iHeight, unsigned *iWidth, unsigned *iDepth); + virtual Bit32u get_gfx_snapshot(Bit8u **snapshot_ptr); virtual void register_state(void); virtual void after_restore_state(void); diff --git a/bochs/iodev/display/vga.cc b/bochs/iodev/display/vga.cc index 04cd279a9..7fdd39053 100644 --- a/bochs/iodev/display/vga.cc +++ b/bochs/iodev/display/vga.cc @@ -764,26 +764,13 @@ void bx_vga_c::mem_write(bx_phy_address addr, Bit8u value) bx_vgacore_c::mem_write(addr, value); } -int bx_vga_c::get_snapshot_mode() -{ - if ((BX_VGA_THIS vbe.enabled) && (BX_VGA_THIS vbe.bpp >= 8)) { - return BX_GUI_SNAPSHOT_GFX; - } else { - return bx_vgacore_c::get_snapshot_mode(); - } -} - -Bit32u bx_vga_c::get_gfx_snapshot(Bit8u **snapshot_ptr, Bit8u **palette_ptr, - unsigned *iHeight, unsigned *iWidth, unsigned *iDepth) +Bit32u bx_vga_c::get_gfx_snapshot(Bit8u **snapshot_ptr) { Bit32u len, len1; unsigned i, shift; Bit8u *dst_ptr, *src_ptr; if ((BX_VGA_THIS vbe.enabled) && (BX_VGA_THIS vbe.bpp >= 8)) { - *iHeight = BX_VGA_THIS vbe.yres; - *iWidth = BX_VGA_THIS vbe.xres; - *iDepth = BX_VGA_THIS vbe.bpp; len1 = BX_VGA_THIS vbe.xres * BX_VGA_THIS vbe.bpp_multiplier; len = len1 * BX_VGA_THIS vbe.yres; *snapshot_ptr = (Bit8u*)malloc(len); @@ -796,17 +783,9 @@ Bit32u bx_vga_c::get_gfx_snapshot(Bit8u **snapshot_ptr, Bit8u **palette_ptr, src_ptr += BX_VGA_THIS s.line_offset; dst_ptr += len1; } - if (*iDepth == 8) { - if (BX_VGA_THIS vbe.dac_8bit) { - shift = 0; - } else { - shift = 2; - } - BX_VGA_THIS get_dac_palette(palette_ptr, shift); - } return len; } else { - return bx_vgacore_c::get_gfx_snapshot(snapshot_ptr, palette_ptr, iHeight, iWidth, iDepth); + return bx_vgacore_c::get_gfx_snapshot(snapshot_ptr); } } diff --git a/bochs/iodev/display/vga.h b/bochs/iodev/display/vga.h index 71ab5f5d1..32de7e255 100644 --- a/bochs/iodev/display/vga.h +++ b/bochs/iodev/display/vga.h @@ -104,9 +104,7 @@ public: virtual void redraw_area(unsigned x0, unsigned y0, unsigned width, unsigned height); - virtual int get_snapshot_mode(void); - virtual Bit32u get_gfx_snapshot(Bit8u **snapshot_ptr, Bit8u **palette_ptr, - unsigned *iHeight, unsigned *iWidth, unsigned *iDepth); + virtual Bit32u get_gfx_snapshot(Bit8u **snapshot_ptr); virtual void init_vga_extension(void); static void timer_handler(void *); diff --git a/bochs/iodev/display/vgacore.cc b/bochs/iodev/display/vgacore.cc index 6a5c12ad3..8ae63f78e 100644 --- a/bochs/iodev/display/vgacore.cc +++ b/bochs/iodev/display/vgacore.cc @@ -376,9 +376,9 @@ void bx_vgacore_c::register_state(bx_list_c *parent) void bx_vgacore_c::after_restore_state(void) { for (unsigned i=0; i<256; i++) { - bx_gui->palette_change(i, BX_VGA_THIS s.pel.data[i].red << BX_VGA_THIS s.dac_shift, - BX_VGA_THIS s.pel.data[i].green << BX_VGA_THIS s.dac_shift, - BX_VGA_THIS s.pel.data[i].blue << BX_VGA_THIS s.dac_shift); + bx_gui->palette_change_common(i, BX_VGA_THIS s.pel.data[i].red << BX_VGA_THIS s.dac_shift, + BX_VGA_THIS s.pel.data[i].green << BX_VGA_THIS s.dac_shift, + BX_VGA_THIS s.pel.data[i].blue << BX_VGA_THIS s.dac_shift); } bx_gui->set_text_charmap(&BX_VGA_THIS s.memory[0x20000 + BX_VGA_THIS s.charmap_address]); BX_VGA_THIS calculate_retrace_timing(); @@ -1074,7 +1074,7 @@ void bx_vgacore_c::write(Bit32u address, Bit32u value, unsigned io_len, bx_bool case 2: BX_VGA_THIS s.pel.data[BX_VGA_THIS s.pel.write_data_register].blue = value; - needs_update |= bx_gui->palette_change(BX_VGA_THIS s.pel.write_data_register, + needs_update |= bx_gui->palette_change_common(BX_VGA_THIS s.pel.write_data_register, BX_VGA_THIS s.pel.data[BX_VGA_THIS s.pel.write_data_register].red << BX_VGA_THIS s.dac_shift, BX_VGA_THIS s.pel.data[BX_VGA_THIS s.pel.write_data_register].green << BX_VGA_THIS s.dac_shift, BX_VGA_THIS s.pel.data[BX_VGA_THIS s.pel.write_data_register].blue << BX_VGA_THIS s.dac_shift); @@ -2283,20 +2283,6 @@ void bx_vgacore_c::mem_write(bx_phy_address addr, Bit8u value) } } -int bx_vgacore_c::get_snapshot_mode() -{ - if (!BX_VGA_THIS s.graphics_ctrl.graphics_alpha) { - return BX_GUI_SNAPSHOT_TXT; - } else if ((BX_VGA_THIS s.graphics_ctrl.shift_reg == 0) && - ((BX_VGA_THIS s.CRTC.reg[0x17] & 1) != 0)) { - return BX_GUI_SNAPSHOT_GFX; - } else if (BX_VGA_THIS s.graphics_ctrl.shift_reg == 2) { - return BX_GUI_SNAPSHOT_GFX; - } else { - return BX_GUI_SNAPSHOT_UNSUP; - } -} - void bx_vgacore_c::get_text_snapshot(Bit8u **text_snapshot, unsigned *txHeight, unsigned *txWidth) { @@ -2314,34 +2300,13 @@ void bx_vgacore_c::get_text_snapshot(Bit8u **text_snapshot, unsigned *txHeight, } } -bx_bool bx_vgacore_c::get_dac_palette(Bit8u **palette_ptr, Bit8u shift) -{ - unsigned i; - Bit8u *dst_ptr; - - *palette_ptr = (Bit8u*)malloc(256 * 4); - if (palette_ptr == NULL) return 0; - dst_ptr = *palette_ptr; - for (i = 0; i < 256; i++) { - *(dst_ptr++) = (BX_VGA_THIS s.pel.data[i].blue << shift); - *(dst_ptr++) = (BX_VGA_THIS s.pel.data[i].green << shift); - *(dst_ptr++) = (BX_VGA_THIS s.pel.data[i].red << shift); - *(dst_ptr++) = 0; - } - return 1; -} - -Bit32u bx_vgacore_c::get_gfx_snapshot(Bit8u **snapshot_ptr, Bit8u **palette_ptr, - unsigned *iHeight, unsigned *iWidth, unsigned *iDepth) +Bit32u bx_vgacore_c::get_gfx_snapshot(Bit8u **snapshot_ptr) { Bit32u len; unsigned line_compare, start_addr, x, y; unsigned byte_offset, px, py; Bit8u *dst_ptr, *plane[4]; - *iHeight = BX_VGA_THIS s.last_yres; - *iWidth = BX_VGA_THIS s.last_xres; - *iDepth = 8; len = (BX_VGA_THIS s.last_xres * BX_VGA_THIS s.last_yres); *snapshot_ptr = (Bit8u*)malloc(len); if (snapshot_ptr == NULL) @@ -2361,7 +2326,6 @@ Bit32u bx_vgacore_c::get_gfx_snapshot(Bit8u **snapshot_ptr, Bit8u **palette_ptr, *(dst_ptr++) = BX_VGA_THIS get_vga_pixel(x, y, start_addr, line_compare, 0, plane); } } - BX_VGA_THIS get_dac_palette(palette_ptr, BX_VGA_THIS s.dac_shift); return len; } else if (BX_VGA_THIS s.graphics_ctrl.shift_reg == 2) { for (y = 0; y < BX_VGA_THIS s.last_yres; y++) { @@ -2379,12 +2343,8 @@ Bit32u bx_vgacore_c::get_gfx_snapshot(Bit8u **snapshot_ptr, Bit8u **palette_ptr, *(dst_ptr++) = plane[px % 4][byte_offset]; } } - BX_VGA_THIS get_dac_palette(palette_ptr, 2); return len; } else { - *iHeight = 0; - *iWidth = 0; - *iDepth = 0; return 0; } } diff --git a/bochs/iodev/display/vgacore.h b/bochs/iodev/display/vgacore.h index 274202055..63e8fd071 100644 --- a/bochs/iodev/display/vgacore.h +++ b/bochs/iodev/display/vgacore.h @@ -70,11 +70,9 @@ public: virtual void redraw_area(unsigned x0, unsigned y0, unsigned width, unsigned height); - virtual int get_snapshot_mode(void); virtual void get_text_snapshot(Bit8u **text_snapshot, unsigned *txHeight, unsigned *txWidth); - virtual Bit32u get_gfx_snapshot(Bit8u **snapshot_ptr, Bit8u **palette_ptr, - unsigned *iHeight, unsigned *iWidth, unsigned *iDepth); + virtual Bit32u get_gfx_snapshot(Bit8u **snapshot_ptr); virtual void init_vga_extension(void) {} static void timer_handler(void *); @@ -93,7 +91,6 @@ protected: void write(Bit32u address, Bit32u value, unsigned io_len, bx_bool no_log); Bit8u get_vga_pixel(Bit16u x, Bit16u y, Bit16u saddr, Bit16u lc, bx_bool bs, Bit8u **plane); - bx_bool get_dac_palette(Bit8u **palette_ptr, Bit8u shift); void update(void); void determine_screen_dimensions(unsigned *piHeight, unsigned *piWidth); void calculate_retrace_timing(void); diff --git a/bochs/iodev/iodev.h b/bochs/iodev/iodev.h index c6099992a..7989bfcce 100644 --- a/bochs/iodev/iodev.h +++ b/bochs/iodev/iodev.h @@ -251,16 +251,11 @@ public: virtual void mem_write(bx_phy_address addr, Bit8u value) { STUBFUNC(vga, mem_write); } - virtual int get_snapshot_mode(void) { - STUBFUNC(vga, get_snapshot_mode); - return 0; - } virtual void get_text_snapshot(Bit8u **text_snapshot, unsigned *txHeight, unsigned *txWidth) { STUBFUNC(vga, get_text_snapshot); } - virtual Bit32u get_gfx_snapshot(Bit8u **snapshot_ptr, Bit8u **palette_ptr, - unsigned *iHeight, unsigned *iWidth, unsigned *iDepth) { + virtual Bit32u get_gfx_snapshot(Bit8u **snapshot_ptr) { STUBFUNC(vga, get_gfx_snapshot); return 0; } diff --git a/bochs/plugin.h b/bochs/plugin.h index 7607cdc13..44399a7eb 100644 --- a/bochs/plugin.h +++ b/bochs/plugin.h @@ -214,11 +214,10 @@ extern "C" { #define DEV_vga_mem_write(addr, val) (bx_devices.pluginVgaDevice->mem_write(addr, val)) #define DEV_vga_redraw_area(left, top, right, bottom) \ (bx_devices.pluginVgaDevice->redraw_area(left, top, right, bottom)) -#define DEV_vga_get_snapshot_mode() bx_devices.pluginVgaDevice->get_snapshot_mode() #define DEV_vga_get_text_snapshot(rawsnap, height, width) \ (bx_devices.pluginVgaDevice->get_text_snapshot(rawsnap, height, width)) -#define DEV_vga_get_gfx_snapshot(rawsnap, palette, height, width, depth) \ - (bx_devices.pluginVgaDevice->get_gfx_snapshot(rawsnap, palette, height, width, depth)) +#define DEV_vga_get_gfx_snapshot(rawsnap) \ + (bx_devices.pluginVgaDevice->get_gfx_snapshot(rawsnap)) #define DEV_vga_refresh() \ (bx_devices.pluginVgaDevice->trigger_timer(bx_devices.pluginVgaDevice)) #define DEV_vga_set_override(a) (bx_devices.pluginVgaDevice->set_override(a))