- added arguments for x/y resolution to the gui init() and store x/y tilesize

in the gui object. Now the gui doesn't need to include vga.h.
- TODO #1: win32.cc also shouldn't include vga.h
- TODO #2: replace BX_MAX_XRES / BX_MAX_YRES by variables that can be set
  depending on the configuration
This commit is contained in:
Volker Ruppert 2012-01-21 12:15:10 +00:00
parent 3ec77e9372
commit 500ad37191
4 changed files with 29 additions and 27 deletions

View File

@ -195,7 +195,7 @@ gui.o: gui.@CPP_SUFFIX@ ../iodev/iodev.h ../bochs.h ../config.h ../osdep.h \
../bx_debug/debug.h ../config.h ../osdep.h ../bxversion.h \
../gui/siminterface.h ../gui/paramtree.h ../memory/memory.h \
../pc_system.h ../plugin.h ../extplugin.h ../ltdl.h ../gui/gui.h \
../instrument/stubs/instrument.h ../param_names.h ../iodev/vga.h \
../instrument/stubs/instrument.h ../param_names.h \
keymap.h ../gui/bitmaps/floppya.h ../gui/bitmaps/floppyb.h \
../gui/bitmaps/mouse.h ../gui/bitmaps/reset.h ../gui/bitmaps/power.h \
../gui/bitmaps/snapshot.h ../gui/bitmaps/copy.h ../gui/bitmaps/paste.h \
@ -293,7 +293,7 @@ gui.lo: gui.@CPP_SUFFIX@ ../iodev/iodev.h ../bochs.h ../config.h ../osdep.h \
../bx_debug/debug.h ../config.h ../osdep.h ../bxversion.h \
../gui/siminterface.h ../gui/paramtree.h ../memory/memory.h \
../pc_system.h ../plugin.h ../extplugin.h ../ltdl.h ../gui/gui.h \
../instrument/stubs/instrument.h ../param_names.h ../iodev/vga.h \
../instrument/stubs/instrument.h ../param_names.h \
keymap.h ../gui/bitmaps/floppya.h ../gui/bitmaps/floppyb.h \
../gui/bitmaps/mouse.h ../gui/bitmaps/reset.h ../gui/bitmaps/power.h \
../gui/bitmaps/snapshot.h ../gui/bitmaps/copy.h ../gui/bitmaps/paste.h \

View File

@ -21,7 +21,6 @@
#include <signal.h>
#include "iodev.h"
#include "vga.h"
#include "keymap.h"
#include "gui/bitmaps/floppya.h"
#include "gui/bitmaps/floppyb.h"
@ -109,12 +108,15 @@ bx_gui_c::~bx_gui_c()
}
}
void bx_gui_c::init(int argc, char **argv, unsigned tilewidth, unsigned tileheight)
void bx_gui_c::init(int argc, char **argv, unsigned max_xres, unsigned max_yres,
unsigned tilewidth, unsigned tileheight)
{
BX_GUI_THIS new_gfx_api = 0;
BX_GUI_THIS host_xres = 640;
BX_GUI_THIS host_yres = 480;
BX_GUI_THIS host_bpp = 8;
BX_GUI_THIS x_tilesize = tilewidth;
BX_GUI_THIS y_tilesize = tileheight;
BX_GUI_THIS dialog_caps = BX_GUI_DLG_RUNTIME | BX_GUI_DLG_SAVE_RESTORE;
BX_GUI_THIS toggle_method = SIM->get_param_enum(BXPN_MOUSE_TOGGLE)->get();
@ -242,7 +244,7 @@ void bx_gui_c::init(int argc, char **argv, unsigned tilewidth, unsigned tileheig
BX_GUI_THIS charmap_updated = 0;
if (!BX_GUI_THIS new_gfx_api && (BX_GUI_THIS framebuffer == NULL)) {
BX_GUI_THIS framebuffer = new Bit8u[BX_MAX_XRES * BX_MAX_YRES * 4];
BX_GUI_THIS framebuffer = new Bit8u[max_xres * max_yres * 4];
}
show_headerbar();
@ -865,18 +867,16 @@ bx_svga_tileinfo_t *bx_gui_c::graphics_tile_info(bx_svga_tileinfo_t *info)
Bit8u *bx_gui_c::graphics_tile_get(unsigned x0, unsigned y0,
unsigned *w, unsigned *h)
{
if (x0+X_TILESIZE > BX_GUI_THIS host_xres) {
if (x0+BX_GUI_THIS x_tilesize > BX_GUI_THIS host_xres) {
*w = BX_GUI_THIS host_xres - x0;
}
else {
*w = X_TILESIZE;
} else {
*w = BX_GUI_THIS x_tilesize;
}
if (y0+Y_TILESIZE > BX_GUI_THIS host_yres) {
if (y0+BX_GUI_THIS y_tilesize > BX_GUI_THIS host_yres) {
*h = BX_GUI_THIS host_yres - y0;
}
else {
*h = Y_TILESIZE;
} else {
*h = BX_GUI_THIS y_tilesize;
}
return (Bit8u *)framebuffer + y0 * BX_GUI_THIS host_pitch +
@ -886,13 +886,14 @@ Bit8u *bx_gui_c::graphics_tile_get(unsigned x0, unsigned y0,
void bx_gui_c::graphics_tile_update_in_place(unsigned x0, unsigned y0,
unsigned w, unsigned h)
{
Bit8u tile[X_TILESIZE * Y_TILESIZE * 4];
Bit8u *tile;
Bit8u *tile_ptr, *fb_ptr;
Bit16u xc, yc, fb_pitch, tile_pitch;
Bit8u r, diffx, diffy;
diffx = (x0 % X_TILESIZE);
diffy = (y0 % Y_TILESIZE);
tile = new Bit8u[BX_GUI_THIS x_tilesize * BX_GUI_THIS y_tilesize * 4];
diffx = (x0 % BX_GUI_THIS x_tilesize);
diffy = (y0 % BX_GUI_THIS y_tilesize);
if (diffx > 0) {
x0 -= diffx;
w += diffx;
@ -902,9 +903,9 @@ void bx_gui_c::graphics_tile_update_in_place(unsigned x0, unsigned y0,
h += diffy;
}
fb_pitch = BX_GUI_THIS host_pitch;
tile_pitch = X_TILESIZE * ((BX_GUI_THIS host_bpp + 1) >> 3);
for (yc=y0; yc<(y0+h); yc+=Y_TILESIZE) {
for (xc=x0; xc<(x0+w); xc+=X_TILESIZE) {
tile_pitch = BX_GUI_THIS x_tilesize * ((BX_GUI_THIS host_bpp + 1) >> 3);
for (yc=y0; yc<(y0+h); yc+=BX_GUI_THIS y_tilesize) {
for (xc=x0; xc<(x0+w); xc+=BX_GUI_THIS x_tilesize) {
fb_ptr = BX_GUI_THIS framebuffer + (yc * fb_pitch + xc * ((BX_GUI_THIS host_bpp + 1) >> 3));
tile_ptr = &tile[0];
for (r=0; r<h; r++) {
@ -915,6 +916,7 @@ void bx_gui_c::graphics_tile_update_in_place(unsigned x0, unsigned y0,
BX_GUI_THIS graphics_tile_update(tile, xc, yc);
}
}
delete [] tile;
}
void bx_gui_c::show_ips(Bit32u ips_count)

View File

@ -144,7 +144,7 @@ public:
static void set_text_charbyte(Bit16u address, Bit8u data);
static Bit8u get_mouse_headerbar_id();
void init(int argc, char **argv,
void init(int argc, char **argv, unsigned max_xres, unsigned max_yres,
unsigned x_tilesize, unsigned y_tilesize);
void cleanup(void);
void update_drive_status_buttons(void);
@ -210,6 +210,8 @@ protected:
Bit16u host_yres;
Bit16u host_pitch;
Bit8u host_bpp;
unsigned x_tilesize;
unsigned y_tilesize;
Bit8u *framebuffer;
Bit32u dialog_caps;
Bit8u toggle_method;

View File

@ -282,16 +282,14 @@ void bx_vga_c::init_standard_vga(void)
}
delete [] options;
}
bx_gui->init(argc, argv, BX_VGA_THIS s.x_tilesize, BX_VGA_THIS s.y_tilesize);
for (i = 1; i < (unsigned)argc; i++)
{
if (argv[i] != NULL)
{
bx_gui->init(argc, argv, BX_MAX_XRES, BX_MAX_YRES, BX_VGA_THIS s.x_tilesize,
BX_VGA_THIS s.y_tilesize);
for (i = 1; i < (unsigned)argc; i++) {
if (argv[i] != NULL) {
free(argv[i]);
argv[i] = NULL;
}
}
}
void bx_vga_c::init_vga_extension(void)