Graphics snapshot feature re-implemented for the new graphics API
- graphics_tile_info() split into a common and specific part - store snapshot mode in structure bx_svga_tileinfo_t - in snapshot mode, display adapters copy raw data to buffer - rewrite of the trigger_timer() code to make it work in all cases - added new class bx_nonvga_device_c to make forwarding refresh requests to the Voodoo adapter possible
This commit is contained in:
parent
d43bf74aa3
commit
4eae421272
@ -410,7 +410,7 @@ void bx_gui_c::make_text_snapshot(char **snapshot, Bit32u *length)
|
||||
*length = txt_addr;
|
||||
}
|
||||
|
||||
void bx_gui_c::set_snapshot_mode(bx_bool mode)
|
||||
Bit32u bx_gui_c::set_snapshot_mode(bx_bool mode)
|
||||
{
|
||||
unsigned pixel_bytes, bufsize;
|
||||
|
||||
@ -423,6 +423,7 @@ void bx_gui_c::set_snapshot_mode(bx_bool mode)
|
||||
memset(BX_GUI_THIS snapshot_buffer, 0, bufsize);
|
||||
DEV_vga_redraw_area(0, 0, BX_GUI_THIS guest_xres, BX_GUI_THIS guest_yres);
|
||||
DEV_vga_refresh();
|
||||
return bufsize;
|
||||
}
|
||||
} else {
|
||||
if (BX_GUI_THIS snapshot_buffer != NULL) {
|
||||
@ -431,6 +432,7 @@ void bx_gui_c::set_snapshot_mode(bx_bool mode)
|
||||
DEV_vga_redraw_area(0, 0, BX_GUI_THIS guest_xres, BX_GUI_THIS guest_yres);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// create a text snapshot and copy to the system clipboard. On guis that
|
||||
@ -487,17 +489,11 @@ void bx_gui_c::snapshot_handler(void)
|
||||
fclose(fp);
|
||||
free(snapshot_ptr);
|
||||
} else {
|
||||
ilen = DEV_vga_get_gfx_snapshot(&snapshot_ptr);
|
||||
if (ilen > 0) {
|
||||
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));
|
||||
}
|
||||
if (BX_GUI_THIS dialog_caps & BX_GUI_DLG_SNAPSHOT) {
|
||||
int ret = SIM->ask_filename (filename, sizeof(filename),
|
||||
"Save snapshot as...", "snapshot.bmp",
|
||||
bx_param_string_c::SAVE_FILE_DIALOG);
|
||||
if (ret < 0) { // cancelled
|
||||
if (snapshot_ptr != NULL) free(snapshot_ptr);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
@ -511,12 +507,15 @@ void bx_gui_c::snapshot_handler(void)
|
||||
);
|
||||
if (fd < 0) {
|
||||
BX_ERROR(("snapshot button failed: cannot create BMP file"));
|
||||
if (snapshot_ptr != NULL) free(snapshot_ptr);
|
||||
return;
|
||||
}
|
||||
if (ilen == 0) {
|
||||
BX_GUI_THIS set_snapshot_mode(1);
|
||||
snapshot_ptr = BX_GUI_THIS snapshot_buffer;
|
||||
ilen = BX_GUI_THIS set_snapshot_mode(1);
|
||||
if (ilen > 0) {
|
||||
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;
|
||||
}
|
||||
iBits = (BX_GUI_THIS guest_bpp == 8) ? 8 : 24;
|
||||
rlen = (BX_GUI_THIS guest_xres * (iBits >> 3) + 3) & ~3;
|
||||
@ -548,7 +547,7 @@ void bx_gui_c::snapshot_handler(void)
|
||||
}
|
||||
pitch = BX_GUI_THIS guest_xres * ((BX_GUI_THIS guest_bpp + 1) >> 3);
|
||||
row_buffer = (Bit8u*)malloc(rlen);
|
||||
row_ptr = snapshot_ptr + ((BX_GUI_THIS guest_yres - 1) * pitch);
|
||||
row_ptr = BX_GUI_THIS snapshot_buffer + ((BX_GUI_THIS guest_yres - 1) * pitch);
|
||||
for (i = BX_GUI_THIS guest_yres; i > 0; i--) {
|
||||
memset(row_buffer, 0, rlen);
|
||||
if ((BX_GUI_THIS guest_bpp == 8) || (BX_GUI_THIS guest_bpp == 24)) {
|
||||
@ -581,11 +580,7 @@ void bx_gui_c::snapshot_handler(void)
|
||||
}
|
||||
free(row_buffer);
|
||||
close(fd);
|
||||
if (ilen > 0) {
|
||||
free(snapshot_ptr);
|
||||
} else {
|
||||
BX_GUI_THIS set_snapshot_mode(0);
|
||||
}
|
||||
BX_GUI_THIS set_snapshot_mode(0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -852,13 +847,6 @@ void bx_gui_c::get_capabilities(Bit16u *xres, Bit16u *yres, Bit16u *bpp)
|
||||
|
||||
bx_svga_tileinfo_t *bx_gui_c::graphics_tile_info(bx_svga_tileinfo_t *info)
|
||||
{
|
||||
if (!info) {
|
||||
info = (bx_svga_tileinfo_t *)malloc(sizeof(bx_svga_tileinfo_t));
|
||||
if (!info) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
BX_GUI_THIS host_pitch = BX_GUI_THIS host_xres * ((BX_GUI_THIS host_bpp + 1) >> 3);
|
||||
|
||||
info->bpp = BX_GUI_THIS host_bpp;
|
||||
@ -984,6 +972,24 @@ void bx_gui_c::graphics_tile_update_common(Bit8u *tile, unsigned x, unsigned y)
|
||||
}
|
||||
}
|
||||
|
||||
bx_svga_tileinfo_t * bx_gui_c::graphics_tile_info_common(bx_svga_tileinfo_t *info)
|
||||
{
|
||||
if (!info) {
|
||||
info = (bx_svga_tileinfo_t *)malloc(sizeof(bx_svga_tileinfo_t));
|
||||
if (!info) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
info->snapshot_mode = BX_GUI_THIS snapshot_mode;
|
||||
if (BX_GUI_THIS snapshot_mode) {
|
||||
info->pitch = BX_GUI_THIS guest_xres * ((BX_GUI_THIS guest_bpp + 1) >> 3);
|
||||
} else {
|
||||
return graphics_tile_info(info);
|
||||
}
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
bx_bool bx_gui_c::palette_change_common(Bit8u index, Bit8u red, Bit8u green, Bit8u blue)
|
||||
{
|
||||
BX_GUI_THIS palette[index].red = red;
|
||||
|
@ -67,6 +67,7 @@ typedef struct {
|
||||
Bit8u red_shift, green_shift, blue_shift;
|
||||
Bit8u is_indexed, is_little_endian;
|
||||
unsigned long red_mask, green_mask, blue_mask;
|
||||
bx_bool snapshot_mode;
|
||||
} bx_svga_tileinfo_t;
|
||||
|
||||
|
||||
@ -144,6 +145,8 @@ public:
|
||||
unsigned x_tilesize, unsigned y_tilesize);
|
||||
void cleanup(void);
|
||||
void graphics_tile_update_common(Bit8u *tile, unsigned x, unsigned y);
|
||||
bx_svga_tileinfo_t *graphics_tile_info_common(bx_svga_tileinfo_t *info);
|
||||
Bit8u* get_snapshot_buffer(void) {return snapshot_buffer;}
|
||||
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);
|
||||
@ -173,7 +176,7 @@ protected:
|
||||
static void save_restore_handler(void);
|
||||
// snapshot helper functions
|
||||
static void make_text_snapshot(char **snapshot, Bit32u *length);
|
||||
static void set_snapshot_mode(bx_bool mode);
|
||||
static Bit32u set_snapshot_mode(bx_bool mode);
|
||||
// status bar LED timer
|
||||
static void led_timer_handler(void *);
|
||||
void led_timer(void);
|
||||
|
@ -892,13 +892,6 @@ void bx_rfb_gui_c::graphics_tile_update(Bit8u *tile, unsigned x0, unsigned y0)
|
||||
|
||||
bx_svga_tileinfo_t *bx_rfb_gui_c::graphics_tile_info(bx_svga_tileinfo_t *info)
|
||||
{
|
||||
if (!info) {
|
||||
info = (bx_svga_tileinfo_t *)malloc(sizeof(bx_svga_tileinfo_t));
|
||||
if (!info) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
info->bpp = 8;
|
||||
info->pitch = rfbWindowX;
|
||||
info->red_shift = 3;
|
||||
|
@ -731,11 +731,6 @@ void bx_sdl_gui_c::graphics_tile_update(Bit8u *snapshot, unsigned x, unsigned y)
|
||||
|
||||
bx_svga_tileinfo_t *bx_sdl_gui_c::graphics_tile_info(bx_svga_tileinfo_t *info)
|
||||
{
|
||||
if (!info) {
|
||||
info = (bx_svga_tileinfo_t *)malloc(sizeof(bx_svga_tileinfo_t));
|
||||
if (!info) return NULL;
|
||||
}
|
||||
|
||||
if (sdl_screen) {
|
||||
info->bpp = sdl_screen->format->BitsPerPixel;
|
||||
info->pitch = sdl_screen->pitch;
|
||||
@ -746,8 +741,7 @@ bx_svga_tileinfo_t *bx_sdl_gui_c::graphics_tile_info(bx_svga_tileinfo_t *info)
|
||||
info->green_mask = sdl_screen->format->Gmask;
|
||||
info->blue_mask = sdl_screen->format->Bmask;
|
||||
info->is_indexed = (sdl_screen->format->palette != NULL);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
info->bpp = sdl_fullscreen->format->BitsPerPixel;
|
||||
info->pitch = sdl_fullscreen->pitch;
|
||||
info->red_shift = sdl_fullscreen->format->Rshift + 8 - sdl_fullscreen->format->Rloss;
|
||||
|
@ -1457,13 +1457,6 @@ void bx_wx_gui_c::graphics_tile_update(Bit8u *tile, unsigned x0, unsigned y0)
|
||||
|
||||
bx_svga_tileinfo_t *bx_wx_gui_c::graphics_tile_info(bx_svga_tileinfo_t *info)
|
||||
{
|
||||
if (!info) {
|
||||
info = (bx_svga_tileinfo_t *)malloc(sizeof(bx_svga_tileinfo_t));
|
||||
if (!info) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
info->bpp = 24;
|
||||
info->pitch = wxScreenX * 3;
|
||||
info->red_shift = 8;
|
||||
|
@ -1565,13 +1565,6 @@ void bx_x_gui_c::graphics_tile_update(Bit8u *tile, unsigned x0, unsigned y0)
|
||||
|
||||
bx_svga_tileinfo_t *bx_x_gui_c::graphics_tile_info(bx_svga_tileinfo_t *info)
|
||||
{
|
||||
if (!info) {
|
||||
info = (bx_svga_tileinfo_t *)malloc(sizeof(bx_svga_tileinfo_t));
|
||||
if (!info) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
info->bpp = ximage->bits_per_pixel;
|
||||
info->pitch = ximage->bytes_per_line;
|
||||
info->red_shift = 0;
|
||||
|
@ -481,6 +481,10 @@ void bx_svga_cirrus_c::redraw_area(unsigned x0, unsigned y0,
|
||||
if ((width == 0) || (height == 0)) {
|
||||
return;
|
||||
}
|
||||
if (BX_CIRRUS_THIS s.vga_override && (BX_CIRRUS_THIS s.nvgadev != NULL)) {
|
||||
BX_CIRRUS_THIS s.nvgadev->redraw_area(x0, y0, width, height);
|
||||
return;
|
||||
}
|
||||
|
||||
if ((BX_CIRRUS_THIS sequencer.reg[0x07] & 0x01) == CIRRUS_SR7_BPP_VGA) {
|
||||
BX_CIRRUS_THIS bx_vgacore_c::redraw_area(x0,y0,width,height);
|
||||
@ -831,31 +835,6 @@ void bx_svga_cirrus_c::get_text_snapshot(Bit8u **text_snapshot,
|
||||
BX_CIRRUS_THIS bx_vgacore_c::get_text_snapshot(text_snapshot,txHeight,txWidth);
|
||||
}
|
||||
|
||||
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) {
|
||||
len1 = BX_CIRRUS_THIS svga_xres * (BX_CIRRUS_THIS svga_bpp >> 3);
|
||||
len = len1 * BX_CIRRUS_THIS svga_yres;
|
||||
*snapshot_ptr = (Bit8u*)malloc(len);
|
||||
if (snapshot_ptr == NULL)
|
||||
return 0;
|
||||
src_ptr = BX_CIRRUS_THIS disp_ptr;
|
||||
dst_ptr = *snapshot_ptr;
|
||||
for (i = 0; i < BX_CIRRUS_THIS svga_yres; i++) {
|
||||
memcpy(dst_ptr, src_ptr, len1);
|
||||
src_ptr += BX_CIRRUS_THIS svga_pitch;
|
||||
dst_ptr += len1;
|
||||
}
|
||||
return len;
|
||||
} else {
|
||||
return BX_CIRRUS_THIS bx_vgacore_c::get_gfx_snapshot(snapshot_ptr);
|
||||
}
|
||||
}
|
||||
|
||||
Bit64s bx_svga_cirrus_c::svga_param_handler(bx_param_c *param, int set, Bit64s val)
|
||||
{
|
||||
if (set) {
|
||||
@ -1050,6 +1029,15 @@ void bx_svga_cirrus_c::svga_write(Bit32u address, Bit32u value, unsigned io_len)
|
||||
VGA_WRITE(address,value,io_len);
|
||||
}
|
||||
|
||||
void bx_svga_cirrus_c::trigger_timer(void *this_ptr)
|
||||
{
|
||||
if (BX_CIRRUS_THIS s.vga_override && (BX_CIRRUS_THIS s.nvgadev != NULL)) {
|
||||
BX_CIRRUS_THIS s.nvgadev->trigger_timer(BX_CIRRUS_THIS s.nvgadev);
|
||||
} else {
|
||||
svga_timer_handler(this_ptr);
|
||||
}
|
||||
}
|
||||
|
||||
void bx_svga_cirrus_c::svga_timer_handler(void *this_ptr)
|
||||
{
|
||||
#if !BX_USE_CIRRUS_SMF
|
||||
@ -1305,8 +1293,18 @@ void bx_svga_cirrus_c::svga_update(void)
|
||||
Bit8u * tile_ptr, * tile_ptr2;
|
||||
bx_svga_tileinfo_t info;
|
||||
|
||||
if (bx_gui->graphics_tile_info(&info)) {
|
||||
if (info.is_indexed) {
|
||||
if (bx_gui->graphics_tile_info_common(&info)) {
|
||||
if (info.snapshot_mode) {
|
||||
vid_ptr = BX_CIRRUS_THIS disp_ptr;
|
||||
tile_ptr = bx_gui->get_snapshot_buffer();
|
||||
if (tile_ptr != NULL) {
|
||||
for (yc = 0; yc < height; yc++) {
|
||||
memcpy(tile_ptr, vid_ptr, info.pitch);
|
||||
vid_ptr += pitch;
|
||||
tile_ptr += info.pitch;
|
||||
}
|
||||
}
|
||||
} else if (info.is_indexed) {
|
||||
switch (BX_CIRRUS_THIS svga_dispbpp) {
|
||||
case 4:
|
||||
case 15:
|
||||
|
@ -69,13 +69,13 @@ public:
|
||||
|
||||
virtual void init_vga_extension(void);
|
||||
virtual void reset(unsigned type);
|
||||
virtual void trigger_timer(void *this_ptr);
|
||||
virtual void redraw_area(unsigned x0, unsigned y0,
|
||||
unsigned width, unsigned height);
|
||||
virtual Bit8u mem_read(bx_phy_address addr);
|
||||
virtual void mem_write(bx_phy_address addr, Bit8u value);
|
||||
virtual void get_text_snapshot(Bit8u **text_snapshot,
|
||||
unsigned *txHeight, unsigned *txWidth);
|
||||
virtual Bit32u get_gfx_snapshot(Bit8u **snapshot_ptr);
|
||||
virtual void register_state(void);
|
||||
virtual void after_restore_state(void);
|
||||
|
||||
|
@ -357,6 +357,15 @@ Bit64s bx_vga_c::vga_param_handler(bx_param_c *param, int set, Bit64s val)
|
||||
return val;
|
||||
}
|
||||
|
||||
void bx_vga_c::trigger_timer(void *this_ptr)
|
||||
{
|
||||
if (BX_VGA_THIS s.vga_override && (BX_VGA_THIS s.nvgadev != NULL)) {
|
||||
BX_VGA_THIS s.nvgadev->trigger_timer(BX_VGA_THIS s.nvgadev);
|
||||
} else {
|
||||
timer_handler(this_ptr);
|
||||
}
|
||||
}
|
||||
|
||||
void bx_vga_c::timer_handler(void *this_ptr)
|
||||
{
|
||||
#if BX_USE_VGA_SMF == 0
|
||||
@ -411,8 +420,18 @@ void bx_vga_c::update(void)
|
||||
pitch = BX_VGA_THIS s.line_offset;
|
||||
Bit8u *disp_ptr = &BX_VGA_THIS s.memory[BX_VGA_THIS vbe.virtual_start];
|
||||
|
||||
if (bx_gui->graphics_tile_info(&info)) {
|
||||
if (info.is_indexed) {
|
||||
if (bx_gui->graphics_tile_info_common(&info)) {
|
||||
if (info.snapshot_mode) {
|
||||
vid_ptr = disp_ptr;
|
||||
tile_ptr = bx_gui->get_snapshot_buffer();
|
||||
if (tile_ptr != NULL) {
|
||||
for (yc = 0; yc < iHeight; yc++) {
|
||||
memcpy(tile_ptr, vid_ptr, info.pitch);
|
||||
vid_ptr += pitch;
|
||||
tile_ptr += info.pitch;
|
||||
}
|
||||
}
|
||||
} else if (info.is_indexed) {
|
||||
switch (BX_VGA_THIS vbe.bpp) {
|
||||
case 4:
|
||||
case 15:
|
||||
@ -764,31 +783,6 @@ void bx_vga_c::mem_write(bx_phy_address addr, Bit8u value)
|
||||
bx_vgacore_c::mem_write(addr, value);
|
||||
}
|
||||
|
||||
Bit32u bx_vga_c::get_gfx_snapshot(Bit8u **snapshot_ptr)
|
||||
{
|
||||
Bit32u len, len1;
|
||||
unsigned i;
|
||||
Bit8u *dst_ptr, *src_ptr;
|
||||
|
||||
if ((BX_VGA_THIS vbe.enabled) && (BX_VGA_THIS vbe.bpp >= 8)) {
|
||||
len1 = BX_VGA_THIS vbe.xres * BX_VGA_THIS vbe.bpp_multiplier;
|
||||
len = len1 * BX_VGA_THIS vbe.yres;
|
||||
*snapshot_ptr = (Bit8u*)malloc(len);
|
||||
if (snapshot_ptr == NULL)
|
||||
return 0;
|
||||
src_ptr = BX_VGA_THIS s.memory + BX_VGA_THIS vbe.virtual_start;
|
||||
dst_ptr = *snapshot_ptr;
|
||||
for (i = 0; i < BX_VGA_THIS vbe.yres; i++) {
|
||||
memcpy(dst_ptr, src_ptr, len1);
|
||||
src_ptr += BX_VGA_THIS s.line_offset;
|
||||
dst_ptr += len1;
|
||||
}
|
||||
return len;
|
||||
} else {
|
||||
return bx_vgacore_c::get_gfx_snapshot(snapshot_ptr);
|
||||
}
|
||||
}
|
||||
|
||||
void bx_vga_c::redraw_area(unsigned x0, unsigned y0, unsigned width,
|
||||
unsigned height)
|
||||
{
|
||||
@ -797,6 +791,10 @@ void bx_vga_c::redraw_area(unsigned x0, unsigned y0, unsigned width,
|
||||
if (width == 0 || height == 0) {
|
||||
return;
|
||||
}
|
||||
if (BX_VGA_THIS s.vga_override && (BX_VGA_THIS s.nvgadev != NULL)) {
|
||||
BX_VGA_THIS s.nvgadev->redraw_area(x0, y0, width, height);
|
||||
return;
|
||||
}
|
||||
|
||||
if (BX_VGA_THIS vbe.enabled) {
|
||||
BX_VGA_THIS s.vga_mem_updated = 1;
|
||||
|
@ -104,8 +104,8 @@ public:
|
||||
virtual void redraw_area(unsigned x0, unsigned y0,
|
||||
unsigned width, unsigned height);
|
||||
|
||||
virtual Bit32u get_gfx_snapshot(Bit8u **snapshot_ptr);
|
||||
virtual void init_vga_extension(void);
|
||||
virtual void trigger_timer(void *this_ptr);
|
||||
|
||||
static void timer_handler(void *);
|
||||
#if BX_USE_VGA_SMF == 0
|
||||
|
@ -162,6 +162,8 @@ void bx_vgacore_c::init_standard_vga(void)
|
||||
BX_VGA_THIS s.max_xres = 800;
|
||||
BX_VGA_THIS s.max_yres = 600;
|
||||
|
||||
BX_VGA_THIS s.vga_override = 0;
|
||||
|
||||
// initialize memory, handlers and timer (depending on extension)
|
||||
extname = SIM->get_param_string(BXPN_VGA_EXTENSION)->getptr();
|
||||
if ((strlen(extname) == 0) || (!strcmp(extname, "none"))) {
|
||||
@ -1305,9 +1307,10 @@ void bx_vgacore_c::write(Bit32u address, Bit32u value, unsigned io_len, bx_bool
|
||||
}
|
||||
}
|
||||
|
||||
void bx_vgacore_c::set_override(bx_bool enabled)
|
||||
void bx_vgacore_c::set_override(bx_bool enabled, void *dev)
|
||||
{
|
||||
BX_VGA_THIS s.vga_override = enabled;
|
||||
BX_VGA_THIS s.nvgadev = (bx_nonvga_device_c*)dev;
|
||||
if (enabled) {
|
||||
bx_virt_timer.deactivate_timer(BX_VGA_THIS timer_id);
|
||||
} else {
|
||||
@ -1318,11 +1321,6 @@ void bx_vgacore_c::set_override(bx_bool enabled)
|
||||
}
|
||||
}
|
||||
|
||||
void bx_vgacore_c::trigger_timer(void *this_ptr)
|
||||
{
|
||||
timer_handler(this_ptr);
|
||||
}
|
||||
|
||||
void bx_vgacore_c::timer_handler(void *this_ptr)
|
||||
{
|
||||
bx_vgacore_c *class_ptr = (bx_vgacore_c *) this_ptr;
|
||||
@ -2300,13 +2298,6 @@ void bx_vgacore_c::get_text_snapshot(Bit8u **text_snapshot, unsigned *txHeight,
|
||||
}
|
||||
}
|
||||
|
||||
Bit32u bx_vgacore_c::get_gfx_snapshot(Bit8u **snapshot_ptr)
|
||||
{
|
||||
// handled in the gui code
|
||||
*snapshot_ptr = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if BX_DEBUGGER
|
||||
void bx_vgacore_c::debug_dump(void)
|
||||
{
|
||||
|
@ -45,6 +45,13 @@
|
||||
#define X_TILESIZE 16
|
||||
#define Y_TILESIZE 24
|
||||
|
||||
class bx_nonvga_device_c : public bx_devmodel_c {
|
||||
public:
|
||||
virtual void redraw_area(unsigned x0, unsigned y0,
|
||||
unsigned width, unsigned height) {}
|
||||
virtual void trigger_timer(void *this_ptr) {}
|
||||
};
|
||||
|
||||
class bx_vgacore_c : public bx_vga_stub_c
|
||||
#if BX_SUPPORT_PCI
|
||||
, public bx_pci_device_stub_c
|
||||
@ -59,8 +66,8 @@ public:
|
||||
static bx_bool mem_write_handler(bx_phy_address addr, unsigned len, void *data, void *param);
|
||||
virtual Bit8u mem_read(bx_phy_address addr);
|
||||
virtual void mem_write(bx_phy_address addr, Bit8u value);
|
||||
virtual void trigger_timer(void *this_ptr);
|
||||
virtual void set_override(bx_bool enabled);
|
||||
virtual void trigger_timer(void *this_ptr) {}
|
||||
virtual void set_override(bx_bool enabled, void *dev);
|
||||
virtual void register_state(bx_list_c *parent);
|
||||
virtual void after_restore_state(void);
|
||||
#if BX_DEBUGGER
|
||||
@ -72,7 +79,6 @@ public:
|
||||
|
||||
virtual void get_text_snapshot(Bit8u **text_snapshot, unsigned *txHeight,
|
||||
unsigned *txWidth);
|
||||
virtual Bit32u get_gfx_snapshot(Bit8u **snapshot_ptr);
|
||||
virtual void init_vga_extension(void) {}
|
||||
|
||||
static void timer_handler(void *);
|
||||
@ -228,6 +234,7 @@ protected:
|
||||
Bit16u num_y_tiles;
|
||||
// vga override mode
|
||||
bx_bool vga_override;
|
||||
bx_nonvga_device_c *nvgadev;
|
||||
} s; // state information
|
||||
|
||||
int timer_id;
|
||||
|
@ -370,7 +370,7 @@ void bx_voodoo_c::mode_change_timer_handler(void *this_ptr)
|
||||
if ((!BX_VOODOO_THIS s.vdraw.clock_enabled || !BX_VOODOO_THIS s.vdraw.output_on) && BX_VOODOO_THIS s.vdraw.override_on) {
|
||||
// switching off
|
||||
bx_virt_timer.deactivate_timer(BX_VOODOO_THIS s.update_timer_id);
|
||||
DEV_vga_set_override(0);
|
||||
DEV_vga_set_override(0, NULL);
|
||||
BX_VOODOO_THIS s.vdraw.override_on = 0;
|
||||
}
|
||||
|
||||
@ -388,7 +388,7 @@ void bx_voodoo_c::mode_change_timer_handler(void *this_ptr)
|
||||
unsigned vfreq = (unsigned)(hfreq / vtotal);
|
||||
BX_VOODOO_THIS s.vdraw.vtotal_usec = 1000000 / vfreq;
|
||||
BX_VOODOO_THIS s.vdraw.vsync_usec = vsync * (unsigned)(1000000 / hfreq);
|
||||
DEV_vga_set_override(1);
|
||||
DEV_vga_set_override(1, BX_VOODOO_THIS_PTR);
|
||||
BX_VOODOO_THIS s.vdraw.override_on = 1;
|
||||
|
||||
BX_VOODOO_THIS s.vdraw.width = v->fbi.width+1;
|
||||
@ -400,6 +400,11 @@ void bx_voodoo_c::mode_change_timer_handler(void *this_ptr)
|
||||
}
|
||||
}
|
||||
|
||||
void bx_voodoo_c::trigger_timer(void *this_ptr)
|
||||
{
|
||||
update_timer_handler(this_ptr);
|
||||
}
|
||||
|
||||
void bx_voodoo_c::update_timer_handler(void *this_ptr)
|
||||
{
|
||||
UNUSED(this_ptr);
|
||||
@ -435,8 +440,18 @@ void bx_voodoo_c::update(void)
|
||||
Bit8u *disp_ptr = (Bit8u*)(v->fbi.ram + v->fbi.rgboffs[v->fbi.frontbuf]);
|
||||
pitch = v->fbi.rowpixels * 2;
|
||||
|
||||
if (bx_gui->graphics_tile_info(&info)) {
|
||||
if (info.is_indexed) {
|
||||
if (bx_gui->graphics_tile_info_common(&info)) {
|
||||
if (info.snapshot_mode) {
|
||||
vid_ptr = disp_ptr;
|
||||
tile_ptr = bx_gui->get_snapshot_buffer();
|
||||
if (tile_ptr != NULL) {
|
||||
for (yc = 0; yc < BX_VOODOO_THIS s.vdraw.height; yc++) {
|
||||
memcpy(tile_ptr, vid_ptr, info.pitch);
|
||||
vid_ptr += pitch;
|
||||
tile_ptr += info.pitch;
|
||||
}
|
||||
}
|
||||
} else if (info.is_indexed) {
|
||||
BX_ERROR(("current guest pixel format is unsupported on indexed colour host displays"));
|
||||
} else {
|
||||
for (yc=0, yti = 0; yc<BX_VOODOO_THIS s.vdraw.height; yc+=Y_TILESIZE, yti++) {
|
||||
@ -475,6 +490,13 @@ void bx_voodoo_c::update(void)
|
||||
}
|
||||
}
|
||||
|
||||
void bx_voodoo_c::redraw_area(unsigned x0, unsigned y0, unsigned width,
|
||||
unsigned height)
|
||||
{
|
||||
// TODO: implement tile-based update mechanism
|
||||
v->fbi.video_changed = 1;
|
||||
}
|
||||
|
||||
bx_bool bx_voodoo_c::get_retrace(void)
|
||||
{
|
||||
Bit64u time_in_frame = bx_pc_system.time_usec() - BX_VOODOO_THIS s.vdraw.frame_start;
|
||||
|
@ -42,7 +42,7 @@ typedef struct {
|
||||
} bx_voodoo_t;
|
||||
|
||||
|
||||
class bx_voodoo_c : public bx_devmodel_c, bx_pci_device_stub_c {
|
||||
class bx_voodoo_c : public bx_nonvga_device_c, bx_pci_device_stub_c {
|
||||
public:
|
||||
bx_voodoo_c();
|
||||
virtual ~bx_voodoo_c();
|
||||
@ -51,6 +51,10 @@ public:
|
||||
virtual void register_state(void);
|
||||
virtual void after_restore_state(void);
|
||||
|
||||
virtual void trigger_timer(void *this_ptr);
|
||||
virtual void redraw_area(unsigned x0, unsigned y0,
|
||||
unsigned width, unsigned height);
|
||||
|
||||
virtual Bit32u pci_read_handler(Bit8u address, unsigned io_len);
|
||||
virtual void pci_write_handler(Bit8u address, Bit32u value, unsigned io_len);
|
||||
|
||||
|
@ -255,11 +255,7 @@ public:
|
||||
unsigned *txHeight, unsigned *txWidth) {
|
||||
STUBFUNC(vga, get_text_snapshot);
|
||||
}
|
||||
virtual Bit32u get_gfx_snapshot(Bit8u **snapshot_ptr) {
|
||||
STUBFUNC(vga, get_gfx_snapshot);
|
||||
return 0;
|
||||
}
|
||||
virtual void set_override(bx_bool enabled) {
|
||||
virtual void set_override(bx_bool enabled, void *dev) {
|
||||
STUBFUNC(vga, set_override);
|
||||
}
|
||||
virtual void trigger_timer(void *this_ptr) {
|
||||
|
@ -216,11 +216,9 @@ extern "C" {
|
||||
(bx_devices.pluginVgaDevice->redraw_area(left, top, right, bottom))
|
||||
#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) \
|
||||
(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))
|
||||
#define DEV_vga_set_override(a,b) (bx_devices.pluginVgaDevice->set_override(a,b))
|
||||
|
||||
///////// PCI macros
|
||||
#define DEV_register_pci_handlers(a,b,c,d) \
|
||||
|
Loading…
Reference in New Issue
Block a user