diff --git a/bochs/Makefile.in b/bochs/Makefile.in index f5e576b62..e5768cce4 100644 --- a/bochs/Makefile.in +++ b/bochs/Makefile.in @@ -99,6 +99,7 @@ X_LIBS = @X_LIBS@ X_PRE_LIBS = @X_PRE_LIBS@ GUI_LINK_OPTS_X = $(X_LIBS) $(X_PRE_LIBS) -lX11 GUI_LINK_OPTS_SDL = `sdl-config --cflags --libs` +GUI_LINK_OPTS_SVGA = -lvga -lvgagl GUI_LINK_OPTS_BEOS = -lbe GUI_LINK_OPTS_RFB = @RFB_LIBS@ GUI_LINK_OPTS_AMIGAOS = @@ -235,7 +236,7 @@ $(BX_OBJS): $(BX_INCLUDES) bxversion.h: $(RM) -f bxversion.h echo '/////////////////////////////////////////////////////////////////////////' > bxversion.h - echo '// $$Id: Makefile.in,v 1.114 2002-11-21 17:52:59 bdenney Exp $$' >> bxversion.h + echo '// $$Id: Makefile.in,v 1.115 2002-11-21 19:25:57 bdenney Exp $$' >> bxversion.h echo '/////////////////////////////////////////////////////////////////////////' >> bxversion.h echo '// This file is generated by "make bxversion.h"' >> bxversion.h echo "#define VER_STRING \"$(VER_STRING)\"" >> bxversion.h diff --git a/bochs/config.h.in b/bochs/config.h.in index 3972f8678..7245bfb78 100644 --- a/bochs/config.h.in +++ b/bochs/config.h.in @@ -370,6 +370,7 @@ #define BX_WITH_RFB 0 #define BX_WITH_AMIGAOS 0 #define BX_WITH_SDL 0 +#define BX_WITH_SVGA 0 #define BX_WITH_WX 0 // add special export symbols for win32 DLL building. The main code must diff --git a/bochs/configure b/bochs/configure index 2b4092672..1d5fde21b 100755 --- a/bochs/configure +++ b/bochs/configure @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in Id: configure.in,v 1.174 2002/11/21 03:50:59 bdenney Exp . +# From configure.in Id: configure.in,v 1.175 2002/11/21 17:40:14 bdenney Exp . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.53. # @@ -1066,6 +1066,7 @@ Optional Packages: --with-rfb use RFB protocol, works with VNC viewer --with-amigaos use MorphOS (Amiga) --with-sdl use SDL libraries + --with-svga use SVGALib libraries --with-wx use wxWindows libraries --with-all-libs compile all guis that Bochs supports @@ -1618,6 +1619,7 @@ echo "$as_me:$LINENO: result: $ADD_FLAGS" >&5 echo "${ECHO_T}$ADD_FLAGS" >&6 if (test "$with_sdl" != yes) && \ + (test "$with_svga" != yes) && \ (test "$with_x11" != yes) && \ (test "$with_beos" != yes) && \ (test "$with_win32" != yes) && \ @@ -4202,7 +4204,7 @@ test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes case $host in *-*-irix6*) # Find out which ABI we are using. - echo '#line 4205 "configure"' > conftest.$ac_ext + echo '#line 4207 "configure"' > conftest.$ac_ext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? @@ -4752,7 +4754,7 @@ chmod -w . save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -o out/conftest2.$ac_objext" compiler_c_o=no -if { (eval echo configure:4755: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>out/conftest.err; } && test -s out/conftest2.$ac_objext; then +if { (eval echo configure:4757: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>out/conftest.err; } && test -s out/conftest2.$ac_objext; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings if test -s out/conftest.err; then @@ -6583,7 +6585,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext < conftest.$ac_ext < conftest.$ac_ext <&5 +echo $ECHO_N "checking for vga.h... $ECHO_C" >&6 +if test "${ac_cv_header_vga_h+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +echo "$as_me:$LINENO: result: $ac_cv_header_vga_h" >&5 +echo "${ECHO_T}$ac_cv_header_vga_h" >&6 +else + # Is the header compilable? +echo "$as_me:$LINENO: checking vga.h usability" >&5 +echo $ECHO_N "checking vga.h usability... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" +$ac_includes_default +#include +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_header_compiler=yes +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +ac_header_compiler=no +fi +rm -f conftest.$ac_objext conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6 + +# Is the header present? +echo "$as_me:$LINENO: checking vga.h presence" >&5 +echo $ECHO_N "checking vga.h presence... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" +#include +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + egrep -v '^ *\+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + ac_header_preproc=yes +else + echo "$as_me: failed program was:" >&5 + cat conftest.$ac_ext >&5 + ac_header_preproc=no +fi +rm -f conftest.err conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6 + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc in + yes:no ) + { echo "$as_me:$LINENO: WARNING: vga.h: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: vga.h: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: vga.h: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: vga.h: proceeding with the preprocessor's result" >&2;};; + no:yes ) + { echo "$as_me:$LINENO: WARNING: vga.h: present but cannot be compiled" >&5 +echo "$as_me: WARNING: vga.h: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: vga.h: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: vga.h: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: vga.h: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: vga.h: proceeding with the preprocessor's result" >&2;};; +esac +echo "$as_me:$LINENO: checking for vga.h" >&5 +echo $ECHO_N "checking for vga.h... $ECHO_C" >&6 +if test "${ac_cv_header_vga_h+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_cv_header_vga_h=$ac_header_preproc +fi +echo "$as_me:$LINENO: result: $ac_cv_header_vga_h" >&5 +echo "${ECHO_T}$ac_cv_header_vga_h" >&6 + +fi +if test $ac_cv_header_vga_h = yes; then + : +else + can_compile_svga=0 +fi + + + if test "${ac_cv_header_vgagl_h+set}" = set; then + echo "$as_me:$LINENO: checking for vgagl.h" >&5 +echo $ECHO_N "checking for vgagl.h... $ECHO_C" >&6 +if test "${ac_cv_header_vgagl_h+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +echo "$as_me:$LINENO: result: $ac_cv_header_vgagl_h" >&5 +echo "${ECHO_T}$ac_cv_header_vgagl_h" >&6 +else + # Is the header compilable? +echo "$as_me:$LINENO: checking vgagl.h usability" >&5 +echo $ECHO_N "checking vgagl.h usability... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" +$ac_includes_default +#include +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_header_compiler=yes +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +ac_header_compiler=no +fi +rm -f conftest.$ac_objext conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6 + +# Is the header present? +echo "$as_me:$LINENO: checking vgagl.h presence" >&5 +echo $ECHO_N "checking vgagl.h presence... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" +#include +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + egrep -v '^ *\+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + ac_header_preproc=yes +else + echo "$as_me: failed program was:" >&5 + cat conftest.$ac_ext >&5 + ac_header_preproc=no +fi +rm -f conftest.err conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6 + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc in + yes:no ) + { echo "$as_me:$LINENO: WARNING: vgagl.h: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: vgagl.h: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: vgagl.h: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: vgagl.h: proceeding with the preprocessor's result" >&2;};; + no:yes ) + { echo "$as_me:$LINENO: WARNING: vgagl.h: present but cannot be compiled" >&5 +echo "$as_me: WARNING: vgagl.h: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: vgagl.h: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: vgagl.h: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: vgagl.h: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: vgagl.h: proceeding with the preprocessor's result" >&2;};; +esac +echo "$as_me:$LINENO: checking for vgagl.h" >&5 +echo $ECHO_N "checking for vgagl.h... $ECHO_C" >&6 +if test "${ac_cv_header_vgagl_h+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_cv_header_vgagl_h=$ac_header_preproc +fi +echo "$as_me:$LINENO: result: $ac_cv_header_vgagl_h" >&5 +echo "${ECHO_T}$ac_cv_header_vgagl_h" >&6 + +fi +if test $ac_cv_header_vgagl_h = yes; then + : +else + can_compile_svga=0 +fi + + + if test $can_compile_svga = 1; then + with_svga=yes + fi + fi + if test "$with_x11" != yes; then can_compile_x11=1 if test "${ac_cv_header_X11_Xlib_h+set}" = set; then @@ -20400,6 +20625,13 @@ if test "${with_sdl+set}" = set; then fi; +# Check whether --with-svga or --without-svga was given. +if test "${with_svga+set}" = set; then + withval="$with_svga" + +fi; + + # Check whether --with-wx or --without-wx was given. if test "${with_wx+set}" = set; then withval="$with_wx" @@ -20560,6 +20792,20 @@ _ACEOF GUI_LINK_OPTS="$GUI_LINK_OPTS \$(GUI_LINK_OPTS_SDL)" fi +if test "$with_svga" = yes; then + display_libs="$display_libs svga" + cat >>confdefs.h <<\_ACEOF +#define BX_WITH_SVGA 1 +_ACEOF + + SPECIFIC_GUI_OBJS="$SPECIFIC_GUI_OBJS \$(GUI_OBJS_SVGA)" + # GUI_*FLAGS are added to the compilation of every bochs file, not just + # the files in gui/*.cc. + GUI_CFLAGS="$GUI_CFLAGS" + GUI_CXXFLAGS="$GUI_CXXFLAGS" + GUI_LINK_OPTS="$GUI_LINK_OPTS \$(GUI_LINK_OPTS_SVGA)" +fi + if test "$with_rfb" = yes; then display_libs="$display_libs rfb" cat >>confdefs.h <<\_ACEOF diff --git a/bochs/configure.in b/bochs/configure.in index 8b7782cad..de436bb20 100644 --- a/bochs/configure.in +++ b/bochs/configure.in @@ -2,7 +2,7 @@ dnl // Process this file with autoconf to produce a configure script. AC_PREREQ(2.50) AC_INIT(bochs.h) -AC_REVISION([[$Id: configure.in,v 1.175 2002-11-21 17:40:14 bdenney Exp $]]) +AC_REVISION([[$Id: configure.in,v 1.176 2002-11-21 19:26:06 bdenney Exp $]]) AC_CONFIG_HEADER(config.h) AC_CONFIG_HEADER(ltdlconf.h) @@ -84,6 +84,7 @@ AC_MSG_RESULT($ADD_FLAGS) dnl // make sure X Windows is default if no other chosen if (test "$with_sdl" != yes) && \ + (test "$with_svga" != yes) && \ (test "$with_x11" != yes) && \ (test "$with_beos" != yes) && \ (test "$with_win32" != yes) && \ @@ -269,6 +270,15 @@ if test "$with_all_libs" = yes; then fi fi + if test "$with_svga" != yes; then + can_compile_svga=1 + AC_CHECK_HEADER([vga.h], [], [ can_compile_svga=0 ]) + AC_CHECK_HEADER([vgagl.h], [], [ can_compile_svga=0 ]) + if test $can_compile_svga = 1; then + with_svga=yes + fi + fi + if test "$with_x11" != yes; then can_compile_x11=1 AC_CHECK_HEADER([X11/Xlib.h], [], [ can_compile_x11=0 ]) @@ -1548,6 +1558,10 @@ AC_ARG_WITH(sdl, [ --with-sdl use SDL libraries], ) +AC_ARG_WITH(svga, + [ --with-svga use SVGALib libraries], + ) + AC_ARG_WITH(wx, [ --with-wx use wxWindows libraries], ) @@ -1660,6 +1674,17 @@ if test "$with_sdl" = yes; then GUI_LINK_OPTS="$GUI_LINK_OPTS \$(GUI_LINK_OPTS_SDL)" fi +if test "$with_svga" = yes; then + display_libs="$display_libs svga" + AC_DEFINE(BX_WITH_SVGA, 1) + SPECIFIC_GUI_OBJS="$SPECIFIC_GUI_OBJS \$(GUI_OBJS_SVGA)" + # GUI_*FLAGS are added to the compilation of every bochs file, not just + # the files in gui/*.cc. + GUI_CFLAGS="$GUI_CFLAGS" + GUI_CXXFLAGS="$GUI_CXXFLAGS" + GUI_LINK_OPTS="$GUI_LINK_OPTS \$(GUI_LINK_OPTS_SVGA)" +fi + if test "$with_rfb" = yes; then display_libs="$display_libs rfb" AC_DEFINE(BX_WITH_RFB, 1) diff --git a/bochs/gui/Makefile.in b/bochs/gui/Makefile.in index 20f45317c..3b827fa27 100644 --- a/bochs/gui/Makefile.in +++ b/bochs/gui/Makefile.in @@ -58,6 +58,7 @@ BX_INCDIRS = -I.. -I$(srcdir)/.. -I../iodev -I$(srcdir)/../iodev -I../@INSTRUMEN GUI_OBJS_X11 = x.o GUI_OBJS_SDL = sdl.o +GUI_OBJS_SVGA = svga.o GUI_OBJS_BEOS = beos.o GUI_OBJS_WIN32 = win32.o GUI_OBJS_MACOS = macintosh.o @@ -235,6 +236,17 @@ sdl.lo: sdl.@CPP_SUFFIX@ ../bochs.h ../config.h ../osdep.h ../debug/debug.h \ ../iodev/serial.h ../iodev/unmapped.h ../iodev/eth.h ../iodev/ne2k.h \ ../iodev/guest2host.h ../iodev/slowdown_timer.h ../plugin.h \ ../instrument/stubs/instrument.h icon_bochs.h sdl.h +svga.lo: svga.@CPP_SUFFIX@ ../bochs.h ../config.h ../osdep.h ../debug/debug.h \ + ../bxversion.h ../gui/siminterface.h ../state_file.h ../cpu/cpu.h \ + ../cpu/lazy_flags.h ../cpu/i387.h ../memory/memory.h ../pc_system.h \ + ../gui/gui.h ../gui/textconfig.h ../gui/keymap.h ../iodev/iodev.h \ + ../iodev/pci.h ../iodev/pci2isa.h ../iodev/vga.h ../iodev/biosdev.h \ + ../iodev/cmos.h ../iodev/dma.h ../iodev/floppy.h ../iodev/harddrv.h \ + ../iodev/cdrom.h ../iodev/keyboard.h ../iodev/parallel.h \ + ../iodev/pic.h ../iodev/pit.h ../iodev/pit_wrap.h ../iodev/pit82c54.h \ + ../iodev/serial.h ../iodev/unmapped.h ../iodev/eth.h ../iodev/ne2k.h \ + ../iodev/guest2host.h ../iodev/slowdown_timer.h ../plugin.h \ + ../instrument/stubs/instrument.h icon_bochs.h siminterface.lo: siminterface.@CPP_SUFFIX@ ../bochs.h ../config.h ../osdep.h \ ../debug/debug.h ../bxversion.h ../gui/siminterface.h ../state_file.h \ ../cpu/cpu.h ../cpu/lazy_flags.h ../cpu/i387.h ../memory/memory.h \ diff --git a/bochs/gui/svga.cc b/bochs/gui/svga.cc new file mode 100644 index 000000000..f7fdac50f --- /dev/null +++ b/bochs/gui/svga.cc @@ -0,0 +1,486 @@ +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +#define _MULTI_THREAD + +// Define BX_PLUGGABLE in files that can be compiled into plugins. For +// platforms that require a special tag on exported symbols, BX_PLUGGABLE +// is used to know when we are exporting symbols and when we are importing. +#define BX_PLUGGABLE + +#include +#include "/usr/include/vga.h" +#include +#include +#include + +#include "font/vga.bitmap.h" +#include "bochs.h" +#include "icon_bochs.h" + +class bx_svga_gui_c : public bx_gui_c { +public: + bx_svga_gui_c (void); + DECLARE_GUI_VIRTUAL_METHODS() +}; + +// declare one instance of the gui object and call macro to insert the +// plugin code +static bx_svga_gui_c *theGui = NULL; + +IMPLEMENT_GUI_PLUGIN_CODE(svga) + +#define LOG_THIS theGui-> + +static unsigned res_x, res_y; +static int fontwidth = 8, fontheight = 16; +static unsigned tilewidth, tileheight; +static unsigned char vgafont[256 * 16]; +static int clut8 = 0; +GraphicsContext *screen = NULL; + +void keyboard_handler(int scancode, int press); +void mouse_handler(int button, int dx, int dy, int dz, + int drx, int dry, int drz); + +unsigned char reverse_byteorder(unsigned char b) +{ + unsigned char ret = 0; + + for (unsigned i=0;i<8;i++){ + ret |= (b & 0x01) << (7 - i); + b >>= 1; + } + return ret; +} + +void create_vga_font() +{ + memcpy(vgafont, bx_vgafont, sizeof(bx_vgafont)); + + for (unsigned i=0;i< sizeof(bx_vgafont);i++) { + vgafont[i] = reverse_byteorder(vgafont[i]); + } +} + +bx_svga_gui_c::bx_svga_gui_c () +{ + put("SVGA"); +} + +void bx_svga_gui_c::specific_init( + int argc, + char **argv, + unsigned x_tilesize, + unsigned y_tilesize, + unsigned header_bar_y) +{ + tilewidth = x_tilesize; + tileheight = y_tilesize; + + if(vga_init() != 0 ) + { + LOG_THIS setonoff(LOGLEV_PANIC, ACT_FATAL); + BX_PANIC (("Unable to initialize SVGAlib")); + return; + } + + screen = gl_allocatecontext(); + + dimension_update(640,400); + create_vga_font(); + gl_setfont(8, 16, (void *)vgafont); + gl_setwritemode(FONT_COMPRESSED); + + keyboard_init(); + keyboard_seteventhandler((__keyboard_handler) keyboard_handler); + + vga_setmousesupport(1); + mouse_seteventhandler((__mouse_handler) mouse_handler); + if (vga_ext_set(VGA_EXT_AVAILABLE, VGA_AVAIL_FLAGS) & VGA_CLUT8) { + vga_ext_set(VGA_EXT_SET, VGA_CLUT8); + clut8 = 1; + } +} + +void bx_svga_gui_c::text_update( + Bit8u *old_text, + Bit8u *new_text, + unsigned long cursor_x, + unsigned long cursor_y, + Bit16u cursor_state, + unsigned rows) +{ + unsigned x, y, i; + unsigned char achar; + unsigned chars, cols; + char s[] = " "; + static int previ; + int cursori; + + cols = res_x/fontwidth; + + cursori = (cursor_y*cols + cursor_x) * 2; + + chars = cols*rows; + + for (i=0; i> 4); + } else { + gl_setfontcolors((new_text[i+1] & 0xF0) >> 4, new_text[i+1] & 0x0F); + } + gl_write(x * fontwidth, y * fontheight, s); + } + } + previ = cursori; +} + + int +bx_svga_gui_c::get_clipboard_text(Bit8u **bytes, Bit32s *nbytes) +{ + return 0; +} + + int +bx_svga_gui_c::set_clipboard_text(char *text_snapshot, Bit32u len) +{ + return 0; +} + + +void bx_svga_gui_c::graphics_tile_update( + Bit8u *snapshot, + unsigned x, + unsigned y) +{ + gl_putbox(x, y, tilewidth, tileheight, snapshot); +} + +static Bit32u vga_to_bx_key(int key) +{ + switch (key) { + case SCANCODE_ESCAPE: return BX_KEY_ESC; + case SCANCODE_1: return BX_KEY_1; + case SCANCODE_2: return BX_KEY_2; + case SCANCODE_3: return BX_KEY_3; + case SCANCODE_4: return BX_KEY_4; + case SCANCODE_5: return BX_KEY_5; + case SCANCODE_6: return BX_KEY_6; + case SCANCODE_7: return BX_KEY_7; + case SCANCODE_8: return BX_KEY_8; + case SCANCODE_9: return BX_KEY_9; + case SCANCODE_0: return BX_KEY_0; + + case SCANCODE_MINUS: return BX_KEY_MINUS; + case SCANCODE_EQUAL: return BX_KEY_EQUALS; + case SCANCODE_TAB: return BX_KEY_TAB; + case SCANCODE_BACKSPACE: return BX_KEY_BACKSPACE; + + case SCANCODE_Q: return BX_KEY_Q; + case SCANCODE_W: return BX_KEY_W; + case SCANCODE_E: return BX_KEY_E; + case SCANCODE_R: return BX_KEY_R; + case SCANCODE_T: return BX_KEY_T; + case SCANCODE_Y: return BX_KEY_Y; + case SCANCODE_U: return BX_KEY_U; + case SCANCODE_I: return BX_KEY_I; + case SCANCODE_O: return BX_KEY_O; + case SCANCODE_P: return BX_KEY_P; + + case SCANCODE_BRACKET_LEFT: return BX_KEY_LEFT_BRACKET; + case SCANCODE_BRACKET_RIGHT: return BX_KEY_RIGHT_BRACKET; + + case SCANCODE_ENTER: return BX_KEY_ENTER; + case SCANCODE_LEFTCONTROL: return BX_KEY_CTRL_L; + + case SCANCODE_A: return BX_KEY_A; + case SCANCODE_S: return BX_KEY_S; + case SCANCODE_D: return BX_KEY_D; + case SCANCODE_F: return BX_KEY_F; + case SCANCODE_G: return BX_KEY_G; + case SCANCODE_H: return BX_KEY_H; + case SCANCODE_J: return BX_KEY_J; + case SCANCODE_K: return BX_KEY_K; + case SCANCODE_L: return BX_KEY_L; + + case SCANCODE_SEMICOLON: return BX_KEY_SEMICOLON; + case SCANCODE_APOSTROPHE: return BX_KEY_SINGLE_QUOTE; + case SCANCODE_GRAVE: return BX_KEY_GRAVE; + + case SCANCODE_LEFTSHIFT: return BX_KEY_SHIFT_L; + case SCANCODE_BACKSLASH: return BX_KEY_BACKSLASH; + + case SCANCODE_Z: return BX_KEY_Z; + case SCANCODE_X: return BX_KEY_X; + case SCANCODE_C: return BX_KEY_C; + case SCANCODE_V: return BX_KEY_V; + case SCANCODE_B: return BX_KEY_B; + case SCANCODE_N: return BX_KEY_N; + case SCANCODE_M: return BX_KEY_M; + + case SCANCODE_COMMA: return BX_KEY_COMMA; + case SCANCODE_PERIOD: return BX_KEY_PERIOD; + case SCANCODE_SLASH: return BX_KEY_SLASH; + + case SCANCODE_RIGHTSHIFT: return BX_KEY_SHIFT_R; + case SCANCODE_KEYPADMULTIPLY: return BX_KEY_KP_MULTIPLY; + + case SCANCODE_LEFTALT: return BX_KEY_ALT_L; + case SCANCODE_SPACE: return BX_KEY_SPACE; + case SCANCODE_CAPSLOCK: return BX_KEY_CAPS_LOCK; + + case SCANCODE_F1: return BX_KEY_F1; + case SCANCODE_F2: return BX_KEY_F2; + case SCANCODE_F3: return BX_KEY_F3; + case SCANCODE_F4: return BX_KEY_F4; + case SCANCODE_F5: return BX_KEY_F5; + case SCANCODE_F6: return BX_KEY_F6; + case SCANCODE_F7: return BX_KEY_F7; + case SCANCODE_F8: return BX_KEY_F8; + case SCANCODE_F9: return BX_KEY_F9; + case SCANCODE_F10: return BX_KEY_F10; + + case SCANCODE_NUMLOCK: return BX_KEY_NUM_LOCK; + case SCANCODE_SCROLLLOCK: return BX_KEY_SCRL_LOCK; + + case SCANCODE_KEYPAD7: return BX_KEY_KP_HOME; + case SCANCODE_KEYPAD8: return BX_KEY_KP_UP; + case SCANCODE_KEYPAD9: return BX_KEY_KP_PAGE_UP; + case SCANCODE_KEYPADMINUS: return BX_KEY_KP_SUBTRACT; + case SCANCODE_KEYPAD4: return BX_KEY_KP_LEFT; + case SCANCODE_KEYPAD5: return BX_KEY_KP_5; + case SCANCODE_KEYPAD6: return BX_KEY_KP_RIGHT; + case SCANCODE_KEYPADPLUS: return BX_KEY_KP_ADD; + case SCANCODE_KEYPAD1: return BX_KEY_KP_END; + case SCANCODE_KEYPAD2: return BX_KEY_KP_DOWN; + case SCANCODE_KEYPAD3: return BX_KEY_KP_PAGE_DOWN; + case SCANCODE_KEYPAD0: return BX_KEY_KP_INSERT; +// case SCANCODE_KEYPADPERIOD: return BX_KEY_KP_; /* ??? */ + +// case SCANCODE_LESS: return BX_KEY_KP_LESS; /* ??? */ + + case SCANCODE_F11: return BX_KEY_F11; + case SCANCODE_F12: return BX_KEY_F12; + + case SCANCODE_KEYPADENTER: return BX_KEY_KP_ENTER; + case SCANCODE_RIGHTCONTROL: return BX_KEY_CTRL_R; + case SCANCODE_KEYPADDIVIDE: return BX_KEY_KP_DIVIDE; + case SCANCODE_PRINTSCREEN: return BX_KEY_PRINT; + case SCANCODE_RIGHTALT: return BX_KEY_ALT_R; + case SCANCODE_BREAK: return BX_KEY_PAUSE; + + case SCANCODE_HOME: return BX_KEY_HOME; + case SCANCODE_CURSORBLOCKUP: return BX_KEY_UP; + case SCANCODE_PAGEUP: return BX_KEY_PAGE_UP; + case SCANCODE_CURSORBLOCKLEFT: return BX_KEY_LEFT; + case SCANCODE_CURSORBLOCKRIGHT: return BX_KEY_RIGHT; + case SCANCODE_END: return BX_KEY_END; + case SCANCODE_CURSORBLOCKDOWN: return BX_KEY_DOWN; + case SCANCODE_PAGEDOWN: return BX_KEY_PAGE_DOWN; + case SCANCODE_INSERT: return BX_KEY_INSERT; + case SCANCODE_REMOVE: return BX_KEY_DELETE; + + case SCANCODE_RIGHTWIN: return BX_KEY_WIN_R; + case SCANCODE_LEFTWIN: return BX_KEY_WIN_L; + + default: return 0; + } +} + +void keyboard_handler(int scancode, int press) +{ + if (scancode != SCANCODE_F12) { + int bx_key = vga_to_bx_key(scancode); + Bit32u key_state; + + if (press) { + key_state = BX_KEY_PRESSED; + } else { + key_state = BX_KEY_RELEASED; + } + + DEV_kbd_gen_scancode(bx_key | key_state); + } else { + int mode; + int pal[256 * 3]; + + BX_INFO(("F12 pressed")); + // remember old values and switch to text mode + mode = vga_getcurrentmode(); + vga_getpalvec(0, 256, pal); + keyboard_close(); + vga_setmode(TEXT); + // show runtime options menu, which uses stdin/stdout + SIM->configuration_interface (NULL, CI_RUNTIME_CONFIG); + // restore to previous state + keyboard_init(); + keyboard_seteventhandler((__keyboard_handler) keyboard_handler); + vga_setmode(mode); + vga_setpalvec(0, 256, pal); + } +} + +void mouse_handler(int button, int dx, int dy, int dz, + int drx, int dry, int drz) +{ + char a[100]; + int buttons = 0; + + if (button & MOUSE_LEFTBUTTON) { + buttons |= 0x01; + } + + if (button & MOUSE_RIGHTBUTTON) { + buttons |= 0x02; + } + DEV_mouse_motion((int) (0.25 * dx), (int) -(0.25 * dy), buttons); +} + +void bx_svga_gui_c::handle_events(void) +{ + keyboard_update(); + keyboard_clearstate(); + mouse_update(); +} + +void bx_svga_gui_c::flush(void) +{ + gl_copyscreen(screen); +} + +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) +{ + 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; + } + + vga_setpalette(index, red, green, blue); + + return 1; +} + + +void bx_svga_gui_c::dimension_update( + unsigned x, + unsigned y, + unsigned fheight) +{ + int mode; + + // TODO: remove this stupid check whenever the vga driver is fixed + if( y == 208 ) y = 200; + + if( fheight > 0 ) + { + fontheight = fheight; + fontwidth = 8; + } + + if( (x == res_x) && (y == res_y )) return; + + if (x == 640 && y == 480) { + mode = G640x480x256; + } else if (x == 640 && y == 400) { + mode = G640x400x256; + } else if (x == 320 && y == 200) { + mode = G320x200x256; + } + + if (!vga_hasmode(mode)) { + mode = G640x480x256; // trying "default" mode... + } + + if (vga_setmode(mode) != 0) + { + LOG_THIS setonoff(LOGLEV_PANIC, ACT_FATAL); + BX_PANIC (("Unable to set requested videomode: %ix%i", x, y)); + } + + gl_setcontextvga(mode); + gl_getcontext(screen); + gl_setcontextvgavirtual(mode); + + res_x = x; + res_y = y; +} + + +unsigned bx_svga_gui_c::create_bitmap( + const unsigned char *bmap, + unsigned xdim, + unsigned ydim) +{ + return 0; +} + + +unsigned bx_svga_gui_c::headerbar_bitmap( + unsigned bmap_id, + unsigned alignment, + void (*f)(void)) +{ + return 0; +} + + +void bx_svga_gui_c::replace_bitmap( + unsigned hbar_id, + unsigned bmap_id) +{ +} + + +void bx_svga_gui_c::show_headerbar(void) +{ +} + + +void bx_svga_gui_c::mouse_enabled_changed_specific (bx_bool val) +{ +} + + +void headerbar_click(int x) +{ +} + +void bx_svga_gui_c::exit(void) +{ + vga_setmode(TEXT); + keyboard_close(); + mouse_close(); +} diff --git a/bochs/main.cc b/bochs/main.cc index 11c2ed589..fc3c0bd70 100644 --- a/bochs/main.cc +++ b/bochs/main.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: main.cc,v 1.188 2002-11-20 19:34:50 bdenney Exp $ +// $Id: main.cc,v 1.189 2002-11-21 19:26:06 bdenney Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2002 MandrakeSoft S.A. @@ -966,6 +966,9 @@ void bx_init_options () #if BX_WITH_SDL "sdl", #endif +#if BX_WITH_SVGA + "svga", +#endif #if BX_WITH_TERM "term", #endif @@ -1821,6 +1824,10 @@ bx_bool load_and_init_display_lib () { if (!strcmp (gui_name, "sdl")) PLUG_load_plugin (sdl, PLUGTYPE_OPTIONAL); #endif +#if BX_WITH_SVGA + if (!strcmp (gui_name, "svga")) + PLUG_load_plugin (svga, PLUGTYPE_OPTIONAL); +#endif #if BX_WITH_TERM if (!strcmp (gui_name, "term")) PLUG_load_plugin (term, PLUGTYPE_OPTIONAL); diff --git a/bochs/patches/patch.svgalib-gui b/bochs/patches/patch.svgalib-gui deleted file mode 100644 index 5ba2f4270..000000000 --- a/bochs/patches/patch.svgalib-gui +++ /dev/null @@ -1,656 +0,0 @@ ----------------------------------------------------------------------- -Patch name: patch.svgalib-gui -Author: Igor Popik -Date: 21 Nov 2002 01:33:56 +0100 - -Detailed description: -I have been playing bochs for a while and I have decided to create my -own gui plugin. This gui plugin uses svgalib (linux, x86 only - i -guess), runs on fullscreen without X11. It was tested quite hard and i -guess that there are no major bugs in it ;-P, but is one major problem: -svgalib in 256 color modes can set up palette with r,g,b values from -range 0 to 63 (6 bits)... so some colors are broken unless you have -mach32 graphic card (normal 8 bits). Some colors look ugly, but i'm -working on an improved version which will make use of 32K color modes... -The plugin itself is heavily based on other gui plugins, it can change -resolution upon dimension_update request: 320x200, 640x400 and 640x480 -modes are supported. -There was a header filename conflict, svgalib also uses header file -named vga.h so i had to include svgalib's vga.h with full path: -#include "/usr/include/vga.h" - -If anybody is interested in developement of this gui, has suggestions -please mail me. Maybe someone will find this useful or maybe it will be -included in some future realease of bochs. - -Path is created against cvs version (one of the latest 2.0pre1 or -something) of bochs. - -Patch was created with: - cvs diff -u -Apply patch to what version: - cvs checked out on DATE, release version VER -Instructions: - To patch, go to main bochs directory. - Type "patch -p1 < THIS_PATCH_FILE". ----------------------------------------------------------------------- -diff -ur bochs/config.h.in bochs-svga/config.h.in ---- bochs/config.h.in Sat Nov 16 16:08:16 2002 -+++ bochs-svga/config.h.in Tue Nov 12 21:56:50 2002 -@@ -370,6 +370,7 @@ - #define BX_WITH_RFB 0 - #define BX_WITH_AMIGAOS 0 - #define BX_WITH_SDL 0 -+#define BX_WITH_SVGA 0 - #define BX_WITH_WX 0 - - // add special export symbols for win32 DLL building. The main code must -diff -ur bochs/main.cc bochs-svga/main.cc ---- bochs/main.cc Sat Nov 16 16:08:46 2002 -+++ bochs-svga/main.cc Tue Nov 12 21:58:19 2002 -@@ -966,6 +966,9 @@ - #if BX_WITH_SDL - "sdl", - #endif -+#if BX_WITH_SVGA -+ "svga", -+#endif - #if BX_WITH_TERM - "term", - #endif -@@ -1799,6 +1693,10 @@ - #if BX_WITH_SDL - if (!strcmp (gui_name, "sdl")) - PLUG_load_plugin (sdl, PLUGTYPE_OPTIONAL); -+#endif -+#if BX_WITH_SVGA -+ if (!strcmp (gui_name, "svga")) -+ PLUG_load_plugin (svga, PLUGTYPE_OPTIONAL); - #endif - #if BX_WITH_TERM - if (!strcmp (gui_name, "term")) -diff -ur bochs/plugin.h bochs-svga/plugin.h ---- bochs/plugin.h Sat Nov 16 16:08:46 2002 -+++ bochs-svga/plugin.h Tue Nov 12 22:14:22 2002 -@@ -299,6 +296,7 @@ - DECLARE_PLUGIN_INIT_FINI_FOR_MODULE(nogui) - DECLARE_PLUGIN_INIT_FINI_FOR_MODULE(rfb) - DECLARE_PLUGIN_INIT_FINI_FOR_MODULE(sdl) -+DECLARE_PLUGIN_INIT_FINI_FOR_MODULE(svga) - DECLARE_PLUGIN_INIT_FINI_FOR_MODULE(term) - DECLARE_PLUGIN_INIT_FINI_FOR_MODULE(win32) - DECLARE_PLUGIN_INIT_FINI_FOR_MODULE(wx) -diff -ur bochs/configure.in bochs-svga/configure.in ---- bochs/configure.in Sat Nov 16 16:08:46 2002 -+++ bochs-svga/configure.in Tue Nov 12 21:42:28 2002 -@@ -84,6 +84,7 @@ - - dnl // make sure X Windows is default if no other chosen - if (test "$with_sdl" != yes) && \ -+ (test "$with_svga" != yes) && \ - (test "$with_x11" != yes) && \ - (test "$with_beos" != yes) && \ - (test "$with_win32" != yes) && \ -@@ -268,6 +269,15 @@ - fi - fi - -+ if test "$with_svga" != yes; then -+ can_compile_svga=1 -+ AC_CHECK_HEADER([vga.h], [], [ can_compile_svga=0 ]) -+ AC_CHECK_HEADER([vgagl.h], [], [ can_compile_svga=0 ]) -+ if test $can_compile_svga = 1; then -+ with_svga=yes -+ fi -+ fi -+ - if test "$with_x11" != yes; then - can_compile_x11=1 - AC_CHECK_HEADER([X11/Xlib.h], [], [ can_compile_x11=0 ]) -@@ -1541,6 +1550,10 @@ - [ --with-sdl use SDL libraries], - ) - -+AC_ARG_WITH(svga, -+ [ --with-svga use SVGALib libraries], -+ ) -+ - AC_ARG_WITH(wx, - [ --with-wx use wxWindows libraries], - ) -@@ -1653,6 +1666,17 @@ - GUI_LINK_OPTS="$GUI_LINK_OPTS \$(GUI_LINK_OPTS_SDL)" - fi - -+if test "$with_svga" = yes; then -+ display_libs="$display_libs svga" -+ AC_DEFINE(BX_WITH_SVGA, 1) -+ SPECIFIC_GUI_OBJS="$SPECIFIC_GUI_OBJS \$(GUI_OBJS_SVGA)" -+ # GUI_*FLAGS are added to the compilation of every bochs file, not just -+ # the files in gui/*.cc. -+ GUI_CFLAGS="$GUI_CFLAGS" -+ GUI_CXXFLAGS="$GUI_CXXFLAGS" -+ GUI_LINK_OPTS="$GUI_LINK_OPTS \$(GUI_LINK_OPTS_SVGA)" -+fi -+ - if test "$with_rfb" = yes; then - display_libs="$display_libs rfb" - AC_DEFINE(BX_WITH_RFB, 1) -diff -ur bochs/gui/Makefile.in bochs-svga/gui/Makefile.in ---- bochs/gui/Makefile.in Sat Nov 16 16:11:08 2002 -+++ bochs-svga/gui/Makefile.in Tue Nov 12 21:40:19 2002 -@@ -58,6 +58,7 @@ - - GUI_OBJS_X11 = x.o - GUI_OBJS_SDL = sdl.o -+GUI_OBJS_SVGA = svga.o - GUI_OBJS_BEOS = beos.o - GUI_OBJS_WIN32 = win32.o - GUI_OBJS_MACOS = macintosh.o -@@ -235,6 +236,17 @@ - ../iodev/serial.h ../iodev/unmapped.h ../iodev/eth.h ../iodev/ne2k.h \ - ../iodev/guest2host.h ../iodev/slowdown_timer.h ../plugin.h \ - ../instrument/stubs/instrument.h icon_bochs.h sdl.h -+svga.lo: svga.@CPP_SUFFIX@ ../bochs.h ../config.h ../osdep.h ../debug/debug.h \ -+ ../bxversion.h ../gui/siminterface.h ../state_file.h ../cpu/cpu.h \ -+ ../cpu/lazy_flags.h ../cpu/i387.h ../memory/memory.h ../pc_system.h \ -+ ../gui/gui.h ../gui/textconfig.h ../gui/keymap.h ../iodev/iodev.h \ -+ ../iodev/pci.h ../iodev/pci2isa.h ../iodev/vga.h ../iodev/biosdev.h \ -+ ../iodev/cmos.h ../iodev/dma.h ../iodev/floppy.h ../iodev/harddrv.h \ -+ ../iodev/cdrom.h ../iodev/keyboard.h ../iodev/parallel.h \ -+ ../iodev/pic.h ../iodev/pit.h ../iodev/pit_wrap.h ../iodev/pit82c54.h \ -+ ../iodev/serial.h ../iodev/unmapped.h ../iodev/eth.h ../iodev/ne2k.h \ -+ ../iodev/guest2host.h ../iodev/slowdown_timer.h ../plugin.h \ -+ ../instrument/stubs/instrument.h icon_bochs.h - siminterface.lo: siminterface.@CPP_SUFFIX@ ../bochs.h ../config.h ../osdep.h \ - ../debug/debug.h ../bxversion.h ../gui/siminterface.h ../state_file.h \ - ../cpu/cpu.h ../cpu/lazy_flags.h ../cpu/i387.h ../memory/memory.h \ -diff -urN bochs/gui/CVS/Entries bochs-svga/gui/CVS/Entries -diff -urN bochs/gui/svga.cc bochs-svga/gui/svga.cc ---- bochs/gui/svga.cc Thu Jan 1 01:00:00 1970 -+++ bochs-svga/gui/svga.cc Thu Nov 21 00:25:27 2002 -@@ -0,0 +1,473 @@ -+// -+// This library is free software; you can redistribute it and/or -+// modify it under the terms of the GNU Lesser General Public -+// License as published by the Free Software Foundation; either -+// version 2 of the License, or (at your option) any later version. -+// -+// This library is distributed in the hope that it will be useful, -+// but WITHOUT ANY WARRANTY; without even the implied warranty of -+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -+// Lesser General Public License for more details. -+// -+// You should have received a copy of the GNU Lesser General Public -+// License along with this library; if not, write to the Free Software -+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -+ -+#define _MULTI_THREAD -+ -+// Define BX_PLUGGABLE in files that can be compiled into plugins. For -+// platforms that require a special tag on exported symbols, BX_PLUGGABLE -+// is used to know when we are exporting symbols and when we are importing. -+#define BX_PLUGGABLE -+ -+#include -+#include "/usr/include/vga.h" -+#include -+#include -+#include -+ -+#include "font/vga.bitmap.h" -+#include "bochs.h" -+#include "icon_bochs.h" -+ -+class bx_svga_gui_c : public bx_gui_c { -+public: -+ bx_svga_gui_c (void); -+ DECLARE_GUI_VIRTUAL_METHODS() -+}; -+ -+// declare one instance of the gui object and call macro to insert the -+// plugin code -+static bx_svga_gui_c *theGui = NULL; -+ -+IMPLEMENT_GUI_PLUGIN_CODE(svga) -+ -+#define LOG_THIS theGui-> -+ -+static unsigned res_x, res_y; -+static int fontwidth = 8, fontheight = 16; -+static unsigned tilewidth, tileheight; -+static unsigned char vgafont[256 * 16]; -+static int clut8 = 0; -+GraphicsContext *screen = NULL; -+ -+void keyboard_handler(int scancode, int press); -+void mouse_handler(int button, int dx, int dy, int dz, -+ int drx, int dry, int drz); -+ -+unsigned char reverse_byteorder(unsigned char b) -+{ -+ unsigned char ret = 0; -+ -+ for (unsigned i=0;i<8;i++){ -+ ret |= (b & 0x01) << (7 - i); -+ b >>= 1; -+ } -+ return ret; -+} -+ -+void create_vga_font() -+{ -+ memcpy(vgafont, bx_vgafont, sizeof(bx_vgafont)); -+ -+ for (unsigned i=0;i< sizeof(bx_vgafont);i++) { -+ vgafont[i] = reverse_byteorder(vgafont[i]); -+ } -+} -+ -+bx_svga_gui_c::bx_svga_gui_c () -+{ -+ put("SVGA"); -+} -+ -+void bx_svga_gui_c::specific_init( -+ int argc, -+ char **argv, -+ unsigned x_tilesize, -+ unsigned y_tilesize, -+ unsigned header_bar_y) -+{ -+ tilewidth = x_tilesize; -+ tileheight = y_tilesize; -+ -+ if(vga_init() != 0 ) -+ { -+ LOG_THIS setonoff(LOGLEV_PANIC, ACT_FATAL); -+ BX_PANIC (("Unable to initialize SVGAlib")); -+ return; -+ } -+ -+ screen = gl_allocatecontext(); -+ -+ dimension_update(640,400); -+ create_vga_font(); -+ gl_setfont(8, 16, (void *)vgafont); -+ gl_setwritemode(FONT_COMPRESSED); -+ -+ keyboard_init(); -+ keyboard_translatekeys(DONT_CATCH_CTRLC); -+ keyboard_seteventhandler((__keyboard_handler) keyboard_handler); -+ -+ vga_setmousesupport(1); -+ mouse_seteventhandler((__mouse_handler) mouse_handler); -+ if (vga_ext_set(VGA_EXT_AVAILABLE, VGA_AVAIL_FLAGS) & VGA_CLUT8) { -+ vga_ext_set(VGA_EXT_SET, VGA_CLUT8); -+ clut8 = 1; -+ } -+} -+ -+void bx_svga_gui_c::text_update( -+ Bit8u *old_text, -+ Bit8u *new_text, -+ unsigned long cursor_x, -+ unsigned long cursor_y, -+ Bit16u cursor_state, -+ unsigned rows) -+{ -+ unsigned x, y, i; -+ unsigned char achar; -+ unsigned chars, cols; -+ char s[] = " "; -+ static int previ; -+ int cursori; -+ -+ cols = res_x/fontwidth; -+ -+ cursori = (cursor_y*cols + cursor_x) * 2; -+ -+ chars = cols*rows; -+ -+ for (i=0; i> 4); -+ } else { -+ gl_setfontcolors((new_text[i+1] & 0xF0) >> 4, new_text[i+1] & 0x0F); -+ } -+ gl_write(x * fontwidth, y * fontheight, s); -+ } -+ } -+ previ = cursori; -+} -+ -+ int -+bx_svga_gui_c::get_clipboard_text(Bit8u **bytes, Bit32s *nbytes) -+{ -+ return 0; -+} -+ -+ int -+bx_svga_gui_c::set_clipboard_text(char *text_snapshot, Bit32u len) -+{ -+ return 0; -+} -+ -+ -+void bx_svga_gui_c::graphics_tile_update( -+ Bit8u *snapshot, -+ unsigned x, -+ unsigned y) -+{ -+ gl_putbox(x, y, tilewidth, tileheight, snapshot); -+} -+ -+static Bit32u vga_to_bx_key(int key) -+{ -+ switch (key) { -+ case SCANCODE_ESCAPE: return BX_KEY_ESC; -+ case SCANCODE_1: return BX_KEY_1; -+ case SCANCODE_2: return BX_KEY_2; -+ case SCANCODE_3: return BX_KEY_3; -+ case SCANCODE_4: return BX_KEY_4; -+ case SCANCODE_5: return BX_KEY_5; -+ case SCANCODE_6: return BX_KEY_6; -+ case SCANCODE_7: return BX_KEY_7; -+ case SCANCODE_8: return BX_KEY_8; -+ case SCANCODE_9: return BX_KEY_9; -+ case SCANCODE_0: return BX_KEY_0; -+ -+ case SCANCODE_MINUS: return BX_KEY_MINUS; -+ case SCANCODE_EQUAL: return BX_KEY_EQUALS; -+ case SCANCODE_TAB: return BX_KEY_TAB; -+ case SCANCODE_BACKSPACE: return BX_KEY_BACKSPACE; -+ -+ case SCANCODE_Q: return BX_KEY_Q; -+ case SCANCODE_W: return BX_KEY_W; -+ case SCANCODE_E: return BX_KEY_E; -+ case SCANCODE_R: return BX_KEY_R; -+ case SCANCODE_T: return BX_KEY_T; -+ case SCANCODE_Y: return BX_KEY_Y; -+ case SCANCODE_U: return BX_KEY_U; -+ case SCANCODE_I: return BX_KEY_I; -+ case SCANCODE_O: return BX_KEY_O; -+ case SCANCODE_P: return BX_KEY_P; -+ -+ case SCANCODE_BRACKET_LEFT: return BX_KEY_LEFT_BRACKET; -+ case SCANCODE_BRACKET_RIGHT: return BX_KEY_RIGHT_BRACKET; -+ -+ case SCANCODE_ENTER: return BX_KEY_ENTER; -+ case SCANCODE_LEFTCONTROL: return BX_KEY_CTRL_L; -+ -+ case SCANCODE_A: return BX_KEY_A; -+ case SCANCODE_S: return BX_KEY_S; -+ case SCANCODE_D: return BX_KEY_D; -+ case SCANCODE_F: return BX_KEY_F; -+ case SCANCODE_G: return BX_KEY_G; -+ case SCANCODE_H: return BX_KEY_H; -+ case SCANCODE_J: return BX_KEY_J; -+ case SCANCODE_K: return BX_KEY_K; -+ case SCANCODE_L: return BX_KEY_L; -+ -+ case SCANCODE_SEMICOLON: return BX_KEY_SEMICOLON; -+ case SCANCODE_APOSTROPHE: return BX_KEY_SINGLE_QUOTE; -+ case SCANCODE_GRAVE: return BX_KEY_GRAVE; -+ -+ case SCANCODE_LEFTSHIFT: return BX_KEY_SHIFT_L; -+ case SCANCODE_BACKSLASH: return BX_KEY_BACKSLASH; -+ -+ case SCANCODE_Z: return BX_KEY_Z; -+ case SCANCODE_X: return BX_KEY_X; -+ case SCANCODE_C: return BX_KEY_C; -+ case SCANCODE_V: return BX_KEY_V; -+ case SCANCODE_B: return BX_KEY_B; -+ case SCANCODE_N: return BX_KEY_N; -+ case SCANCODE_M: return BX_KEY_M; -+ -+ case SCANCODE_COMMA: return BX_KEY_COMMA; -+ case SCANCODE_PERIOD: return BX_KEY_PERIOD; -+ case SCANCODE_SLASH: return BX_KEY_SLASH; -+ -+ case SCANCODE_RIGHTSHIFT: return BX_KEY_SHIFT_R; -+ case SCANCODE_KEYPADMULTIPLY: return BX_KEY_KP_MULTIPLY; -+ -+ case SCANCODE_LEFTALT: return BX_KEY_ALT_L; -+ case SCANCODE_SPACE: return BX_KEY_SPACE; -+ case SCANCODE_CAPSLOCK: return BX_KEY_CAPS_LOCK; -+ -+ case SCANCODE_F1: return BX_KEY_F1; -+ case SCANCODE_F2: return BX_KEY_F2; -+ case SCANCODE_F3: return BX_KEY_F3; -+ case SCANCODE_F4: return BX_KEY_F4; -+ case SCANCODE_F5: return BX_KEY_F5; -+ case SCANCODE_F6: return BX_KEY_F6; -+ case SCANCODE_F7: return BX_KEY_F7; -+ case SCANCODE_F8: return BX_KEY_F8; -+ case SCANCODE_F9: return BX_KEY_F9; -+ case SCANCODE_F10: return BX_KEY_F10; -+ -+ case SCANCODE_NUMLOCK: return BX_KEY_NUM_LOCK; -+ case SCANCODE_SCROLLLOCK: return BX_KEY_SCRL_LOCK; -+ -+ case SCANCODE_KEYPAD7: return BX_KEY_KP_HOME; -+ case SCANCODE_KEYPAD8: return BX_KEY_KP_UP; -+ case SCANCODE_KEYPAD9: return BX_KEY_KP_PAGE_UP; -+ case SCANCODE_KEYPADMINUS: return BX_KEY_KP_SUBTRACT; -+ case SCANCODE_KEYPAD4: return BX_KEY_KP_LEFT; -+ case SCANCODE_KEYPAD5: return BX_KEY_KP_5; -+ case SCANCODE_KEYPAD6: return BX_KEY_KP_RIGHT; -+ case SCANCODE_KEYPADPLUS: return BX_KEY_KP_ADD; -+ case SCANCODE_KEYPAD1: return BX_KEY_KP_END; -+ case SCANCODE_KEYPAD2: return BX_KEY_KP_DOWN; -+ case SCANCODE_KEYPAD3: return BX_KEY_KP_PAGE_DOWN; -+ case SCANCODE_KEYPAD0: return BX_KEY_KP_INSERT; -+// case SCANCODE_KEYPADPERIOD: return BX_KEY_KP_; /* ??? */ -+ -+// case SCANCODE_LESS: return BX_KEY_KP_LESS; /* ??? */ -+ -+ case SCANCODE_F11: return BX_KEY_F11; -+ case SCANCODE_F12: return BX_KEY_F12; -+ -+ case SCANCODE_KEYPADENTER: return BX_KEY_KP_ENTER; -+ case SCANCODE_RIGHTCONTROL: return BX_KEY_CTRL_R; -+ case SCANCODE_KEYPADDIVIDE: return BX_KEY_KP_DIVIDE; -+ case SCANCODE_PRINTSCREEN: return BX_KEY_PRINT; -+ case SCANCODE_RIGHTALT: return BX_KEY_ALT_R; -+ case SCANCODE_BREAK: return BX_KEY_PAUSE; -+ -+ case SCANCODE_HOME: return BX_KEY_HOME; -+ case SCANCODE_CURSORBLOCKUP: return BX_KEY_UP; -+ case SCANCODE_PAGEUP: return BX_KEY_PAGE_UP; -+ case SCANCODE_CURSORBLOCKLEFT: return BX_KEY_LEFT; -+ case SCANCODE_CURSORBLOCKRIGHT: return BX_KEY_RIGHT; -+ case SCANCODE_END: return BX_KEY_END; -+ case SCANCODE_CURSORBLOCKDOWN: return BX_KEY_DOWN; -+ case SCANCODE_PAGEDOWN: return BX_KEY_PAGE_DOWN; -+ case SCANCODE_INSERT: return BX_KEY_INSERT; -+ case SCANCODE_REMOVE: return BX_KEY_DELETE; -+ -+ case SCANCODE_RIGHTWIN: return BX_KEY_WIN_R; -+ case SCANCODE_LEFTWIN: return BX_KEY_WIN_L; -+ -+ default: return 0; -+ } -+} -+ -+void keyboard_handler(int scancode, int press) -+{ -+ if (scancode == SCANCODE_F12) { -+ keyboard_close(); -+ vga_setmode(TEXT); -+ } else { -+ int bx_key = vga_to_bx_key(scancode); -+ Bit32u key_state; -+ -+ if (press) { -+ key_state = BX_KEY_PRESSED; -+ } else { -+ key_state = BX_KEY_RELEASED; -+ } -+ -+ DEV_kbd_gen_scancode(bx_key | key_state); -+ } -+} -+ -+void mouse_handler(int button, int dx, int dy, int dz, -+ int drx, int dry, int drz) -+{ -+ char a[100]; -+ int buttons = 0; -+ -+ if (button & MOUSE_LEFTBUTTON) { -+ buttons |= 0x01; -+ } -+ -+ if (button & MOUSE_RIGHTBUTTON) { -+ buttons |= 0x02; -+ } -+ DEV_mouse_motion((int) (0.25 * dx), (int) -(0.25 * dy), buttons); -+} -+ -+void bx_svga_gui_c::handle_events(void) -+{ -+ keyboard_update(); -+ keyboard_clearstate(); -+ mouse_update(); -+} -+ -+void bx_svga_gui_c::flush(void) -+{ -+ gl_copyscreen(screen); -+} -+ -+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) -+{ -+ 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; -+ } -+ -+ vga_setpalette(index, red, green, blue); -+ -+ return 1; -+} -+ -+ -+void bx_svga_gui_c::dimension_update( -+ unsigned x, -+ unsigned y, -+ unsigned fheight) -+{ -+ int mode; -+ -+ // TODO: remove this stupid check whenever the vga driver is fixed -+ if( y == 208 ) y = 200; -+ -+ if( fheight > 0 ) -+ { -+ fontheight = fheight; -+ fontwidth = 8; -+ } -+ -+ if( (x == res_x) && (y == res_y )) return; -+ -+ if (x == 640 && y == 480) { -+ mode = G640x480x256; -+ } else if (x == 640 && y == 400) { -+ mode = G640x400x256; -+ } else if (x == 320 && y == 200) { -+ mode = G320x200x256; -+ } -+ -+ if (!vga_hasmode(mode)) { -+ mode = G640x480x256; // trying "default" mode... -+ } -+ -+ if (vga_setmode(mode) != 0) -+ { -+ LOG_THIS setonoff(LOGLEV_PANIC, ACT_FATAL); -+ BX_PANIC (("Unable to set requested videomode: %ix%i", x, y)); -+ } -+ -+ gl_setcontextvga(mode); -+ gl_getcontext(screen); -+ gl_setcontextvgavirtual(mode); -+ -+ res_x = x; -+ res_y = y; -+} -+ -+ -+unsigned bx_svga_gui_c::create_bitmap( -+ const unsigned char *bmap, -+ unsigned xdim, -+ unsigned ydim) -+{ -+ return 0; -+} -+ -+ -+unsigned bx_svga_gui_c::headerbar_bitmap( -+ unsigned bmap_id, -+ unsigned alignment, -+ void (*f)(void)) -+{ -+ return 0; -+} -+ -+ -+void bx_svga_gui_c::replace_bitmap( -+ unsigned hbar_id, -+ unsigned bmap_id) -+{ -+} -+ -+ -+void bx_svga_gui_c::show_headerbar(void) -+{ -+} -+ -+ -+void bx_svga_gui_c::mouse_enabled_changed_specific (bx_bool val) -+{ -+} -+ -+ -+void headerbar_click(int x) -+{ -+} -+ -+void bx_svga_gui_c::exit(void) -+{ -+ vga_setmode(TEXT); -+ keyboard_close(); -+ mouse_close(); -+} -diff -ur bochs/Makefile.in bochs-svga/Makefile.in ---- bochs/Makefile.in Sat Nov 16 16:08:16 2002 -+++ bochs-svga/Makefile.in Tue Nov 12 21:58:44 2002 -@@ -99,6 +98,7 @@ - X_PRE_LIBS = @X_PRE_LIBS@ - GUI_LINK_OPTS_X = $(X_LIBS) $(X_PRE_LIBS) -lX11 - GUI_LINK_OPTS_SDL = `sdl-config --cflags --libs` -+GUI_LINK_OPTS_SVGA = -lvga -lvgagl - GUI_LINK_OPTS_BEOS = -lbe - GUI_LINK_OPTS_RFB = @RFB_LIBS@ - GUI_LINK_OPTS_AMIGAOS = diff --git a/bochs/patches/patch.svgalib-gui-f12 b/bochs/patches/patch.svgalib-gui-f12 deleted file mode 100644 index 83d5ae137..000000000 --- a/bochs/patches/patch.svgalib-gui-f12 +++ /dev/null @@ -1,47 +0,0 @@ -diff -ur bochs/gui/svga.cc bochs-svga/gui/svga.cc ---- bochs/gui/svga.cc Thu Nov 21 01:05:52 2002 -+++ bochs-svga/gui/svga.cc Thu Nov 21 19:10:26 2002 -@@ -105,7 +105,6 @@ - gl_setwritemode(FONT_COMPRESSED); - - keyboard_init(); -- keyboard_translatekeys(DONT_CATCH_CTRLC); - keyboard_seteventhandler((__keyboard_handler) keyboard_handler); - - vga_setmousesupport(1); -@@ -310,10 +309,7 @@ - - void keyboard_handler(int scancode, int press) - { -- if (scancode == SCANCODE_F12) { -- keyboard_close(); -- vga_setmode(TEXT); -- } else { -+ if (scancode != SCANCODE_F12) { - int bx_key = vga_to_bx_key(scancode); - Bit32u key_state; - -@@ -324,6 +320,23 @@ - } - - DEV_kbd_gen_scancode(bx_key | key_state); -+ } else { -+ int mode; -+ int pal[256 * 3]; -+ -+ BX_INFO(("F12 pressed")); -+ // remember old values and switch to text mode -+ mode = vga_getcurrentmode(); -+ vga_getpalvec(0, 256, pal); -+ keyboard_close(); -+ vga_setmode(TEXT); -+ // show runtime options menu, which uses stdin/stdout -+ SIM->configuration_interface (NULL, CI_RUNTIME_CONFIG); -+ // restore to previous state -+ keyboard_init(); -+ keyboard_seteventhandler((__keyboard_handler) keyboard_handler); -+ vga_setmode(mode); -+ vga_setpalvec(0, 256, pal); - } - } - diff --git a/bochs/plugin.h b/bochs/plugin.h index 01c1902c3..97e9afb47 100644 --- a/bochs/plugin.h +++ b/bochs/plugin.h @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: plugin.h,v 1.9 2002-11-20 19:44:05 bdenney Exp $ +// $Id: plugin.h,v 1.10 2002-11-21 19:26:06 bdenney Exp $ ///////////////////////////////////////////////////////////////////////// // // This file provides macros and types needed for plugins. It is based on @@ -305,6 +305,7 @@ DECLARE_PLUGIN_INIT_FINI_FOR_MODULE(macintosh) DECLARE_PLUGIN_INIT_FINI_FOR_MODULE(nogui) DECLARE_PLUGIN_INIT_FINI_FOR_MODULE(rfb) DECLARE_PLUGIN_INIT_FINI_FOR_MODULE(sdl) +DECLARE_PLUGIN_INIT_FINI_FOR_MODULE(svga) DECLARE_PLUGIN_INIT_FINI_FOR_MODULE(term) DECLARE_PLUGIN_INIT_FINI_FOR_MODULE(win32) DECLARE_PLUGIN_INIT_FINI_FOR_MODULE(wx)