From: <sba...@us...> - 2021-03-15 23:49:10
|
This is an automated email from the git hooks/post-receive-user script. sbaldovi pushed a commit to branch master in repository fuse. View the commit online: https://sourceforge.net/p/fuse-emulator/fuse/ci/3ee2bf8dc731f72230e5c3d3227ad2a7a265ee7c/ The following commit(s) were added to refs/heads/master by this push: new 3ee2bf8d Remove SVGAlib UI 3ee2bf8d is described below commit 3ee2bf8dc731f72230e5c3d3227ad2a7a265ee7c Author: Sergio Baldoví <ser...@gm...> AuthorDate: Tue Mar 16 00:44:54 2021 +0100 Remove SVGAlib UI Last SVGAlib release dates from 2001 and is not available in major Linux distributions. --- .gitignore | 1 - INSTALL | 1 - Makefile.am | 1 - README | 2 +- configure.ac | 27 +- data/shell-completion/bash/fuse | 4 +- hacking/ui.txt | 2 +- keysyms.pl | 48 +-- man/fuse.1 | 50 +-- settings.dat | 2 +- ui.c | 6 +- ui/svga/Makefile.am | 47 --- ui/svga/svgadisplay.c | 822 ---------------------------------------- ui/svga/svgadisplay.h | 30 -- ui/svga/svgajoystick.c | 159 -------- ui/svga/svgakeyboard.c | 99 ----- ui/svga/svgakeyboard.h | 30 -- ui/svga/svgaui.c | 124 ------ 18 files changed, 21 insertions(+), 1434 deletions(-) diff --git a/.gitignore b/.gitignore index a60502f6..b321f4a0 100644 --- a/.gitignore +++ b/.gitignore @@ -79,7 +79,6 @@ tags /ui/gtk/options_internals.h /ui/null/options.c /ui/sdl/keysyms.c -/ui/svga/keysyms.c /ui/widget/fuse.font /ui/widget/menu_data.c /ui/widget/options.c diff --git a/INSTALL b/INSTALL index f517a058..56464b56 100644 --- a/INSTALL +++ b/INSTALL @@ -10,7 +10,6 @@ There are now some options you can give to configure; `configure --with-fb Use the framebuffer interface, rather than GTK. --with-sdl Use the SDL interface, rather than GTK. ---with-svgalib Use the SVGAlib interface. --without-gtk Use the plain Xlib interface. If glib is installed on your system, Fuse will use this for a couple diff --git a/Makefile.am b/Makefile.am index 6fdb3454..0e13e4f8 100644 --- a/Makefile.am +++ b/Makefile.am @@ -191,7 +191,6 @@ include ui/gtk/Makefile.am include ui/null/Makefile.am include ui/scaler/Makefile.am include ui/sdl/Makefile.am -include ui/svga/Makefile.am include ui/widget/Makefile.am include ui/wii/Makefile.am include ui/win32/Makefile.am diff --git a/README b/README index 5f7181e2..5193c1ae 100644 --- a/README +++ b/README @@ -51,7 +51,7 @@ Unix, Linux, BSD, etc. Required: -* X, SDL, svgalib or framebuffer support. If you have GTK, you'll get +* X, SDL or framebuffer support. If you have GTK, you'll get a (much) nicer user interface under X. * libspectrum: this is available from http://fuse-emulator.sourceforge.net/libspectrum.php diff --git a/configure.ac b/configure.ac index d6323c18..30645db3 100644 --- a/configure.ac +++ b/configure.ac @@ -198,25 +198,6 @@ if test "$win32" = yes; then AC_MSG_ERROR([Win32 UI not found])) fi -dnl Look for svgalib (default=no) -if test -z "$UI"; then - AC_MSG_CHECKING(whether svgalib UI requested) - AC_ARG_WITH(svgalib, - [ --with-svgalib use svgalib for user interface], - if test "$withval" = no; then svgalib=no; else svgalib=yes; fi, - svgalib=no) - AC_MSG_RESULT($svgalib) - if test "$svgalib" = yes; then - AC_CHECK_HEADER(vga.h, - LIBS="$LIBS -lvga"; - AC_DEFINE([UI_SVGA], 1, [Defined if svgalib UI in use]) - AC_DEFINE([USE_WIDGET], 1, - [Defined if we're using a widget-based UI]) - UI=svga; WIDGET=widget, - AC_MSG_ERROR([svgalib not found])) - fi -fi - dnl Look for framebuffer interface for SA1110 (default=no) if test -z "$UI"; then AC_MSG_CHECKING(whether framebuffer UI requested) @@ -424,7 +405,7 @@ fi dnl Look for Xlib UI (default=yes) if test -z "$UI"; then if test "$with_x" = no; then - AC_MSG_ERROR([Please specify --with-svgalib or --with-fb, not --without-x.]) + AC_MSG_ERROR([Please specify --with-fb, not --without-x.]) fi AC_PATH_XTRA CFLAGS="$CFLAGS $X_CFLAGS"; @@ -462,7 +443,6 @@ AM_CONDITIONAL(UI_FB, test "$UI" = fb) AM_CONDITIONAL(UI_GTK, test "$UI" = gtk) AM_CONDITIONAL(UI_NULL, test "$UI" = null) AM_CONDITIONAL(UI_SDL, test "$UI" = sdl) -AM_CONDITIONAL(UI_SVGA, test "$UI" = svga) AM_CONDITIONAL(UI_WII, test "$UI" = wii) AM_CONDITIONAL(UI_WIN32, test "$UI" = win32) AM_CONDITIONAL(UI_X, test "$UI" = xlib) @@ -756,10 +736,9 @@ AC_MSG_RESULT($stick) if test "$stick" = yes; then dnl We prefer to use UI-specific joystick code. (Default.) dnl If there is none, or you override this here, we use libjsw. - dnl (svgalib appears to dislike switched joysticks on the parallel port...) case "$UI" in - svga|sdl|win32) - dnl Libraries such as svgalib provide their own joystick code. + sdl|win32) + dnl Libraries provide their own joystick code AC_MSG_CHECKING([whether to use $UI's joystick support]) AC_ARG_ENABLE(ui-joystick, AS_HELP_STRING([--disable-ui-joystick], [use libjsw joystick code (where supported)]), diff --git a/data/shell-completion/bash/fuse b/data/shell-completion/bash/fuse index 36b5daed..4b5d73c7 100644 --- a/data/shell-completion/bash/fuse +++ b/data/shell-completion/bash/fuse @@ -170,7 +170,7 @@ _fuse() --joystick-keyboard-output|--joystick-keyboard-right| \ --joystick-keyboard-up|--mdr-len|--rate| \ --sdl-fullscreen-mode|--snet|--sound-device|-d| \ - --sound-freq|-f|--speccyboot-tap|--speed|--svga-modes| \ + --sound-freq|-f|--speccyboot-tap|--speed| \ --teletext-addr-[1-4]|--teletext-port-[1-4]|--volume-ay| \ --volume-beeper|--volume-covox|--volume-specdrum) # argument required but no completions available @@ -271,7 +271,7 @@ _fuse() --snapshot --snet --sound --sound-device --sound-force-8bit --sound-freq --speaker-type --speccyboot --speccyboot-tap --specdrum --spectranet --spectranet-disable --speed - --statusbar --strict-aspect-hint --svga-modes --tape + --statusbar --strict-aspect-hint --tape --teletext-addr-1 --teletext-addr-2 --teletext-addr-3 --teletext-addr-4 --teletext-port-1 --teletext-port-2 --teletext-port-3 --teletext-port-4 --textfile --traps --ttx2000s diff --git a/hacking/ui.txt b/hacking/ui.txt index 77809df6..3a7e8f5f 100644 --- a/hacking/ui.txt +++ b/hacking/ui.txt @@ -29,7 +29,7 @@ Initialise all of the UI-specific bits except the display (keyboard, etc). and is the opportunity for the UI actions to happen. Some of the current UIs, for example the GTK UI use this to do most of their processing such as reading the keyboard and the like, whilst others, -for example the SVGAlib UI do much less here. +for example the framebuffer UI do much less here. * int ui_verror( ui_error_level severity, const char *format, va_list ap ) diff --git a/keysyms.pl b/keysyms.pl index 8acf5422..7359e1a1 100755 --- a/keysyms.pl +++ b/keysyms.pl @@ -33,7 +33,7 @@ my $ui = shift; $ui = 'gtk' unless defined $ui; die "$0: unrecognised user interface: $ui\n" - unless 0 < grep { $ui eq $_ } ( 'gtk', 'x', 'svga', 'fb', 'sdl', 'win32', 'wii' ); + unless 0 < grep { $ui eq $_ } ( 'gtk', 'x', 'fb', 'sdl', 'win32', 'wii' ); sub fb_keysym ($) { @@ -80,25 +80,6 @@ sub sdl_unicode_keysym ($) { return $keysym; } -sub svga_keysym ($) { - - my $keysym = shift; - - $keysym =~ tr/a-z/A-Z/; - $keysym =~ s/(.*)_L$/LEFT$1/; - $keysym =~ s/(.*)_R$/RIGHT$1/; - $keysym =~ s/META$/WIN/; # Fairly sensible mapping - $keysym =~ s/^PAGE_/PAGE/; - - # All the magic #defines start with `SCANCODE_' - $keysym = "SCANCODE_$keysym"; - - # Apart from this one :-) - $keysym = "127" if $keysym eq 'SCANCODE_MODE_SWITCH'; - - return $keysym; -} - sub win32_keysym ($) { my $keysym = shift; @@ -220,25 +201,6 @@ my %ui_data = ( unicode_function => \&sdl_unicode_keysym, }, - svga => { headers => [ 'vgakeyboard.h' ], - max_length => 26, - skips => { map { $_ => 1 } qw( Hyper_L Hyper_R Super_L Super_R - dollar less greater exclam ampersand parenleft parenright - asterisk plus colon asciicircum dead_circumflex bar ) }, - translations => { - Caps_Lock => 'CAPSLOCK', - numbersign => 'BACKSLASH', - Return => 'ENTER', - Delete => 'REMOVE', - Left => 'CURSORBLOCKLEFT', - Down => 'CURSORBLOCKDOWN', - Up => 'CURSORBLOCKUP', - Right => 'CURSORBLOCKRIGHT', - KP_Enter => 'KEYPADENTER', - }, - function => \&svga_keysym, - }, - x => { headers => [ 'X11/keysym.h' ], max_length => 15, skips => { }, @@ -361,10 +323,6 @@ foreach( @keys ) { $ui_keysym = $ui_data{$ui}{function}->( $ui_keysym ); - if( $ui eq 'svga' and $ui_keysym =~ /WIN$/ ) { - print "#ifdef $ui_keysym\n"; - } - if( $ui eq 'fb' ) { for( my $i = 0; $i <= $#cooked_keysyms; $i++ ) { @@ -381,10 +339,6 @@ foreach( @keys ) { } - if( $ui eq 'svga' and $ui_keysym =~ /WIN$/ ) { - print "#endif /* #ifdef $keysym */\n"; - } - } print << "CODE"; diff --git a/man/fuse.1 b/man/fuse.1 index c8b948a1..1b5fbab9 100644 --- a/man/fuse.1 +++ b/man/fuse.1 @@ -1834,25 +1834,6 @@ prevent others (for example, from being able resize the window away from square. .RE .PP -.B \-\-svga\-modes -.I mode1,mode2,mode3 -.RS -Specify which SVGA mode to use for the SVGAlib UI at different screen -sizes. Available values for -.IR mode1 ", " mode2 " and " mode3 -are listed in a table, when Fuse called with -.B \-\-svga\-modes -.I list -command line option. -When user select a not available mode for a size, Fuse just ignore -and try to find the best mode for it. e.g. with -.B "\-\-svga\-modes 0,0,12" -Fuse use the specified 1024\(mu768\(mu256 SVGA mode for triple size filters, -but select SVGA modes automatically for normal or double size filters. -The above mode number is just an example, and mode numbers and their -meanings may vary graphics card by graphics card. -.RE -.PP .B \-t .I file .br @@ -2089,7 +2070,7 @@ section for details. .\" .SH "THE VARIOUS FRONT-ENDS" Fuse supports various front-ends, or UIs (user interfaces). The usual -one is GTK-based, but there are also SDL, Win32, Xlib, SVGAlib and +one is GTK-based, but there are also SDL, Win32, Xlib and framebuffer ones. .PP The important difference to note is that GTK and Win32 versions uses @@ -4162,7 +4143,7 @@ emulating machine's monitor. These filters can be used to do various forms of smoothing, emulation of TV scanlines and various other possibilities. Support for graphics filters varies between the different user interfaces, but there are two general classes: the GTK, -Win32, Xlib, SVGAlib and SDL user interfaces (and the saving of .png +Win32, Xlib and SDL user interfaces (and the saving of .png screenshots) support `interpolating' filters which use a palette larger than the Spectrum's 16\ colours, while the framebuffer user interface currently does not support filters at all. @@ -4205,15 +4186,13 @@ Scale the displayed screen up to double size. .PP .IR "Triple size " ( 3x ) .RS -Scale the displayed screen up to triple size. Available only with the -GTK, Win32, Xlib and SDL user interfaces or when saving screenshots of -non-Timex machines. +Scale the displayed screen up to triple size. Available when saving +screenshots of non-Timex machines. .RE .PP .IR "Quadruple size " ( 4x ) .RS -Scale the displayed screen up to quadruple size. Available only with the -GTK, Win32 and SDL user interfaces. +Scale the displayed screen up to quadruple size. .RE .PP .IR "2xSaI " ( 2xsai ) @@ -4236,9 +4215,8 @@ diagonal lines. .RS Very similar to .IR AdvMAME2x , -except that it triples the size of the displayed screen. Available -only with the GTK, Win32, Xlib and SDL user interfaces or when saving -screenshots of non-Timex machines. +except that it triples the size of the displayed screen. Available when +saving screenshots of non-Timex machines. .RE .PP .IR "TV\ 2x " ( tv2x ) @@ -4281,16 +4259,14 @@ display. .RS An interpolating Timex-specific filter which scales the Timex screen up to 1.5\(mu its usual size (which is therefore 3\(mu the size of a -`normal' Spectrum screen). Available only for the GTK, Win32 and SDL -user interfaces or when saving screenshots. +`normal' Spectrum screen). .RE .PP .IR "Timex\ 2x " ( timex2x ) .RS A non-interpolating Timex-specific filter which scales the Timex screen up to 2\(mu its usual size (which is therefore 4\(mu the size of a -`normal' Spectrum screen). Available only for the GTK, Win32 and SDL -user interfaces or when saving screenshots. +`normal' Spectrum screen). .RE .PP .IR "HQ\ 2x " ( hq2x ) @@ -5675,14 +5651,6 @@ or Beta disk images. .\"------------------------------------------------------------------ .\" .SH BUGS -Selecting a startup filter doesn't work properly with user interfaces -other than SDL, Win32 and GTK. -.PP -Changing virtual consoles when using SVGAlib for joystick support -causes Fuse to exit. If this is a problem, compile Fuse with the -.RB ` \-\-disable\-ui\-joystick ' -option. -.PP The poke finder can't search outside `normal' RAM. .PP The libao file output devices not work properly with the GTK UI. diff --git a/settings.dat b/settings.dat index 7c2382df..d400cef0 100644 --- a/settings.dat +++ b/settings.dat @@ -201,7 +201,7 @@ printer_text_filename, string, "printout.txt",, textfile aspect_hint, boolean, 1 strict_aspect_hint, boolean, 0 fb_mode, numeric, 320, 'v', fbmode -svga_modes, string, NULL +svga_modes, null, 0 sdl_fullscreen_mode, string, NULL doublescan_mode, numeric, 1, 'D', doublescan-mode diff --git a/ui.c b/ui.c index a72e5f64..9356a1ba 100644 --- a/ui.c +++ b/ui.c @@ -113,13 +113,13 @@ print_error_to_stderr( ui_error_level severity, const char *message ) informational */ if( severity > UI_ERROR_INFO ) { - /* For the fb and svgalib UIs, we don't want to write to stderr if + /* For the fb UI, we don't want to write to stderr if it's a terminal, as it's then likely to be what we're currently using for graphics output, and writing text to it isn't a good idea. Things are OK if we're exiting though */ -#if defined( UI_FB ) || defined( UI_SVGA ) +#ifdef UI_FB if( isatty( STDERR_FILENO ) && !fuse_exiting ) return 1; -#endif /* #if defined( UI_FB ) || defined( UI_SVGA ) */ +#endif /* #ifdef UI_FB */ fprintf( stderr, "%s: ", fuse_progname ); diff --git a/ui/svga/Makefile.am b/ui/svga/Makefile.am deleted file mode 100644 index cd037e18..00000000 --- a/ui/svga/Makefile.am +++ /dev/null @@ -1,47 +0,0 @@ -## Process this file with automake to produce Makefile.in -## Copyright (c) 2001-2004 Philip Kendall -## Copyright (c) 2015 Sergio Baldoví - -## This program is free software; you can redistribute it and/or modify -## it under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 2 of the License, or -## (at your option) any later version. -## -## This program 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 General Public License for more details. -## -## You should have received a copy of the GNU General Public License along -## with this program; if not, write to the Free Software Foundation, Inc., -## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -## -## Author contact information: -## -## E-mail: phi...@sh... - -if UI_SVGA - -fuse_SOURCES += $(ui_svga_files) - -BUILT_SOURCES += $(ui_svga_built) - -endif - - -CLEANFILES += $(ui_svga_built) - -ui_svga_files = \ - ui/svga/keysyms.c \ - ui/svga/svgadisplay.c \ - ui/svga/svgadisplay.h \ - ui/svga/svgajoystick.c \ - ui/svga/svgakeyboard.c \ - ui/svga/svgakeyboard.h \ - ui/svga/svgaui.c - -ui_svga_built = ui/svga/keysyms.c - -ui/svga/keysyms.c: $(srcdir)/keysyms.pl $(srcdir)/keysyms.dat - @$(MKDIR_P) ui/svga - $(AM_V_GEN)$(PERL) -I$(srcdir)/perl $(srcdir)/keysyms.pl svga $(srcdir)/keysyms.dat > $@.tmp && mv $@.tmp $@ diff --git a/ui/svga/svgadisplay.c b/ui/svga/svgadisplay.c deleted file mode 100644 index c093b0f2..00000000 --- a/ui/svga/svgadisplay.c +++ /dev/null @@ -1,822 +0,0 @@ -/* svgadisplay.c: Routines for dealing with the svgalib display - Copyright (c) 2000-2003 Philip Kendall, Matan Ziv-Av, Witold Filipczyk, - Russell Marks - Copyright (c) 2015 Stuart Brady - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program 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 General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: phi...@sh... - -*/ - -#include "config.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <vga.h> -#include <vgakeyboard.h> - -#include "fuse.h" -#include "display.h" -#include "screenshot.h" -#include "settings.h" -#include "ui/ui.h" -#include "ui/uidisplay.h" - -/* The size of a 1x1 image in units of - DISPLAY_ASPECT WIDTH x DISPLAY_SCREEN_HEIGHT - scale * 4, so 2 => 0.5, 6 => 1.5, 4 => 1.0 */ -static int image_scale = 1; - -/* The height and width of a 1x1 image in pixels */ -static int image_width, image_height, scaled_image_w, scaled_image_h; - -/* A copy of every pixel on the screen */ -static libspectrum_word - rgb_image[2 * ( DISPLAY_SCREEN_HEIGHT + 4 )][2 * ( DISPLAY_SCREEN_WIDTH + 3 )]; -static const int rgb_pitch = 2 * ( DISPLAY_SCREEN_WIDTH + 3 ); - -/* A scaled copy of the image displayed on the Spectrum's screen */ -static libspectrum_word - scaled_image[3*DISPLAY_SCREEN_HEIGHT][3*DISPLAY_SCREEN_WIDTH]; -static const ptrdiff_t scaled_pitch = - 3 * DISPLAY_SCREEN_WIDTH * sizeof( libspectrum_word ); - -/* The line buffer for svga_putpixel ...*/ -static libspectrum_byte - line_buff[3*4*DISPLAY_SCREEN_WIDTH]; -static libspectrum_byte *line_buff_ptr; -static int bytesperpixel = 0; -static int xoffs, yoffs, xclip, yclip; - -static int svgadisplay_current_size = 0; -static int svgadisplay_depth = -1; -static int svgadisplay_bw = -1; -static int rShift = 16, gShift = 8, bShift = 0; - -/* This is a rule of thumb for the maximum number of rects that can be updated - each frame. If more are generated we just update the whole screen */ -typedef struct { - int x; int y; int w; int h; -} SVGA_Rect; -#define MAX_UPDATE_RECT 300 -static SVGA_Rect updated_rects[MAX_UPDATE_RECT]; -static int num_rects = 0; -static libspectrum_byte svgadisplay_force_full_refresh = 1; - -typedef void svgadisplay_update_rect_t( int x, int y, int w, int h ); - -static svgadisplay_update_rect_t *svgadisplay_update_rect; -static svgadisplay_update_rect_t svgadisplay_update_rect_noscale; -static svgadisplay_update_rect_t svgadisplay_update_rect_scale; - -typedef void svgadisplay_putpixel_t( int x, int y, libspectrum_word *color ); - -static svgadisplay_putpixel_t *svgadisplay_putpixel; - -static svgadisplay_putpixel_t svgadisplay_putpixel_4; -static svgadisplay_putpixel_t svgadisplay_putpixel_8; -static svgadisplay_putpixel_t svgadisplay_putpixel_15; -static svgadisplay_putpixel_t svgadisplay_putpixel_16; -static svgadisplay_putpixel_t svgadisplay_putpixel_24; - -static int svgadisplay_allocate_colours4( void ); -static int svgadisplay_allocate_colours8( void ); - - -static libspectrum_word pal_colour[16] = { - 0x0000, 0x0017, 0xb800, 0xb817, 0x05e0, 0x05f7, 0xbde0, 0xbdf7, - 0x0000, 0x001f, 0xf800, 0xf81f, 0x07e0, 0x07ff, 0xffe0, 0xffff, -}; - -static libspectrum_word pal_grey[16] = { - 0x0000, 0x39c7, 0x18a3, 0x526a, 0x738e, 0xad55, 0x8430, 0xbdf7, - 0x0000, 0x4a69, 0x20e4, 0x6b4d, 0x94b2, 0xdf1b, 0xb596, 0xffff, -}; - -static int rgb_for_4[] = { - 0x00, 0x00, 0x00, - 0x00, 0x00, 0xBF, - 0xBF, 0x00, 0x00, - 0xBF, 0x00, 0xBF, - 0x00, 0xBF, 0x00, - 0x00, 0xBF, 0xBF, - 0xBF, 0xBF, 0x00, - 0xBF, 0xBF, 0xBF, - 0x00, 0x00, 0x00, - 0x00, 0x00, 0xFF, - 0xFF, 0x00, 0x00, - 0xFF, 0x00, 0xFF, - 0x00, 0xFF, 0x00, - 0x00, 0xFF, 0xFF, - 0xFF, 0xFF, 0x00, - 0xFF, 0xFF, 0xFF -}; - -static void register_scalers( void ); - -typedef struct svga_mode_t { - int n; - /* vga_modeinfo *inf; */ - int width, height, bytesperpixel, colors; - int depth; -} svga_mode_t; - -#define SIZE_1x_REGISTER(p,s) if( modes[0].n != -1 && ( p || modes[0].depth > 4 ) ) scaler_register( s ) -#define SIZE_2x_REGISTER(p,s) if( modes[1].n != -1 && ( p || modes[1].depth > 4 ) ) scaler_register( s ) -#define SIZE_3x_REGISTER(p,s) if( modes[2].n != -1 && ( p || modes[2].depth > 4 ) ) scaler_register( s ) - -svga_mode_t modes[] = { - { -1, 0, 0, 0, 0, 0, }, /* 320x240 */ - { -1, 0, 0, 0, 0, 0, }, /* 640x480 */ - { -1, 0, 0, 0, 0, 0, }, /* 960x720 */ -}; - -void -set_mode( int i, int n, vga_modeinfo *inf ) -{ - if( inf->colors >= 16 && !( inf->flags & IS_MODEX ) && - inf->width >= 256 * ( i + 1 ) && - inf->height >= 192 * ( i + 1 ) ) { - modes[i].n = n; - modes[i].width = inf->width; - modes[i].height = inf->height; - modes[i].colors = inf->colors; - modes[i].bytesperpixel = inf->bytesperpixel ? inf->bytesperpixel : 1; - modes[i].depth = inf->colors == 16 ? 4 : - ( inf->colors == 256 ? 8 : - ( inf->colors == 32768 ? 15 : - ( inf->colors == 65536 ? 16 : - inf->bytesperpixel == 3 ? 24 : 32 ) ) ); - } -} - -void -find_mode( int exact ) -{ - vga_modeinfo *inf; - int i, j, w, h; - - for( i = 0; i <= vga_lastmodenumber(); i++ ) { - if( vga_hasmode( i ) ) { - inf = vga_getmodeinfo( i ); - if( inf->colors >= 16 && !( inf->flags & IS_MODEX ) && - inf->width >= 320 && inf->height >= 240 && - inf->width <= 1280 && inf->height <= 1024 ) { - /* try exact match */ - for( j = 0; j < 3; j++ ) { - w = DISPLAY_ASPECT_WIDTH * ( j + 1 ); - h = DISPLAY_SCREEN_HEIGHT * ( j + 1 ); - if( exact == 0 && inf->width == w && inf->height == h && - ( modes[j].n == -1 || - ( ( modes[j].width != w || modes[j].height != h || - modes[j].depth != 16 ) && ( - inf->colors == 65536 || - inf->colors > modes[j].colors ) ) ) ) { - set_mode( j, i, inf ); - } - - if( exact == 1 && inf->width >= w && inf->height >= h && - inf->width < w * 5 / 4 && inf->height < h * 5 / 4 && - ( modes[j].n == -1 || - ( ( modes[j].width > inf->width || - modes[j].height > inf->height || - modes[j].depth != 16 ) && ( - inf->colors == 65536 || - inf->colors > modes[j].colors ) ) ) ) { - set_mode( j, i, inf ); - } - - if( exact == -1 && inf->width <= w && inf->height <= h && - inf->width > w * 3 / 4 && inf->height > h * 3 / 4 && - ( modes[j].n == -1 || - ( ( modes[j].width < inf->width || - modes[j].height < inf->height || - modes[j].depth != 16 ) && ( - inf->colors == 65536 || - inf->colors > modes[j].colors ) ) ) ) { - set_mode( j, i, inf ); - } - } - } - } - } -} - -static void -svgadisplay_setmode( int i ) -{ - int w, h; - w = DISPLAY_ASPECT_WIDTH * ( i + 1 ); - h = DISPLAY_SCREEN_HEIGHT * ( i + 1 ); - vga_setmode( modes[i].n ); - svgadisplay_depth = modes[i].depth; - bytesperpixel = modes[i].bytesperpixel; - xoffs = xclip = 0; - if( modes[i].width > w ) { - xoffs = ( modes[i].width - w ) >> 1; - } else if( modes[i].width < w ) { - xclip = ( w - modes[i].width ) >> 1; - } - yoffs = yclip = 0; - if( modes[i].height > h ) { - yoffs = ( modes[i].height - h ) >> 1; - } else if( modes[i].height < h ) { - yclip = ( h - modes[i].height ) >> 1; - } - if( svgadisplay_depth == 4 ) - svgadisplay_allocate_colours4(); - if( svgadisplay_depth == 8 ) - svgadisplay_allocate_colours8(); -} - -int -svgadisplay_init( void ) -{ - int i, j, found_mode = 0; - int n0 = -1, n1 = -1, n2 = -1; - vga_modeinfo *inf; - vga_init(); - - if( settings_current.svga_modes && - strcmp( settings_current.svga_modes, "list" ) == 0 ) { - fprintf( stderr, - "=====================================================================\n" - " List of available SVGA modes:\n" - "---------------------------------------------------------------------\n" - " No. width height colors Normal Double Triple\n" - "---------------------------------------------------------------------\n" - ); - for( j = 0; j <= vga_lastmodenumber(); j++ ) { - if( vga_hasmode( j ) ) { - inf = vga_getmodeinfo( j ); - if( inf->colors >= 16 && !( inf->flags & IS_MODEX ) && - inf->width >= 256 && - inf->height >= 192 ) { - fprintf( stderr, "% 4d % 5d% 5d %s % 4d%%% 4d%%", j, inf->width, inf->height, - ( inf->colors == 16 ? " 16 " : - ( inf->colors == 256 ? "256 " : - ( inf->colors == 32768 ? " 32k" : - ( inf->colors == 65536 ? " 64k" : " 16M" ) ) ) ), - inf->width * 100 / DISPLAY_ASPECT_WIDTH, - inf->height * 100 / DISPLAY_SCREEN_HEIGHT ); - if( inf->width >= 512 && inf->height >= 384 ) { - fprintf( stderr, " % 4d%%% 4d%%", - inf->width * 50 / DISPLAY_ASPECT_WIDTH, - inf->height * 50 / DISPLAY_SCREEN_HEIGHT ); - } else { - fprintf( stderr, " N/A " ); - } - if( inf->width >= 768 && inf->height >= 576 ) { - fprintf( stderr, " % 4d%%% 4d%%\n", - inf->width * 100 / DISPLAY_ASPECT_WIDTH / 3, - inf->height * 100 / DISPLAY_SCREEN_HEIGHT / 3 ); - } else { - fprintf( stderr, " N/A\n" ); - } - } - } - } - return 1; - } - - find_mode( 0 ); - find_mode( 1 ); - find_mode( -1 ); - - - if( settings_current.svga_modes ) { - sscanf( settings_current.svga_modes, " %i%*[ ,;/|] %i%*[ ,;/|] %i", &n0, &n1, &n2 ); - if( n0 > 0 && vga_hasmode( n0 ) ) set_mode( 0, n0, vga_getmodeinfo( n0 ) ); - if( n1 > 0 && vga_hasmode( n1 ) ) set_mode( 1, n1, vga_getmodeinfo( n1 ) ); - if( n2 > 0 && vga_hasmode( n2 ) ) set_mode( 2, n2, vga_getmodeinfo( n2 ) ); - } - -#if 0 /* for debugging */ - for( i = 0; i < 3; i++ ) { - fprintf( stderr, "svgadisplay_size: %d:", i ); - if( modes[i].n != -1 ) { - fprintf( stderr, " %d %dx%d %s (%d)", modes[i].n, modes[i].width, modes[i].height, - vga_getmodename( modes[i].n ), modes[i].depth ); - } - fprintf( stderr, "\n" ); - } -#endif - - for( i = 0; i < 3; i++ ) { - if( modes[i].n != -1 ) { - svgadisplay_current_size = i + 1; - svgadisplay_setmode( i ); - found_mode = 1; - break; - } - } - - /* Error out if we couldn't find a VGA mode */ - if( !found_mode ) { - ui_error( UI_ERROR_ERROR, "couldn't find a mode to start in" ); - return 1; - } - - return 0; -} - -static void -svgadisplay_putpixel_4( int x, int y, libspectrum_word *colour) -{ - *line_buff_ptr++ = *colour; -} - -static void -svgadisplay_putpixel_8( int x, int y, libspectrum_word *colour) -{ - libspectrum_word c = *colour; - - c = ( c & 0x1f ) * 3 / 31 + - ( ( ( ( c >> 5 ) & 0x3f ) * 7 / 63 ) << 2 ) + - ( ( ( c >> 11 ) * 3 / 31 ) << 5 ); - *line_buff_ptr++ = c; -} - -static void -svgadisplay_putpixel_15( int x, int y, libspectrum_word *colour ) -{ - libspectrum_word c = *colour; - - *(libspectrum_word *)line_buff_ptr = - ( c & 0x1f ) + ( ( c >> 1 ) & 0xffe0 ); - line_buff_ptr += 2; -} - -static void -svgadisplay_putpixel_16( int x, int y, libspectrum_word *colour ) -{ - libspectrum_word c = *colour; - - *(libspectrum_word *)line_buff_ptr = c; - line_buff_ptr += 2; -} - -static void -svgadisplay_putpixel_24( int x, int y, libspectrum_word *colour ) -{ - libspectrum_dword c = *colour; - - c = ( ( ( c >> 11 ) * 255 / 31 ) << rShift ) + - ( ( ( ( c >> 5 ) & 0x3f ) * 255 / 63 ) << gShift ) + - ( ( ( c & 0x1f ) * 255 / 31 ) << bShift ); - *(libspectrum_dword *)line_buff_ptr = c; - line_buff_ptr += 3; -} - -static void -svgadisplay_putpixel_32( int x, int y, libspectrum_word *colour ) -{ - libspectrum_dword c = *colour; - - c = ( ( ( c >> 11 ) * 255 / 31 ) << rShift ) + - ( ( ( ( c >> 5 ) & 0x3f ) * 255 / 63 ) << gShift ) + - ( ( ( c & 0x1f ) * 255 / 31 ) << bShift ); - *(libspectrum_dword *)line_buff_ptr = c; - line_buff_ptr += 4; -} - -static int -svgadisplay_allocate_colours4( void ) -{ - int i; - int red, green, blue; - -/* Y = 0.29900 * R + 0.58700 * G + 0.11400 * B */ - - if( settings_current.bw_tv ) { - for( i=0; i<16; i++ ) { /* grey */ - red = green = blue = ( - rgb_for_4[i * 3 ] * 4822 / 255 + - rgb_for_4[i * 3 + 1] * 9467 / 255 + - rgb_for_4[i * 3 + 2] * 1839 / 255 ) >> 8; - vga_setpalette( i, red, green, blue ); - } - } else { - for( i=0; i<16; i++ ) { /* rgb */ - red = rgb_for_4[i * 3 ] * 63 / 255; - green = rgb_for_4[i * 3 + 1] * 63 / 255; - blue = rgb_for_4[i * 3 + 2] * 63 / 255; - vga_setpalette( i, red, green, blue ); - } - } - - return 0; -} - -static int -svgadisplay_allocate_colours8( void ) -{ - int i, r, g, b; - int red, green, blue; - - i = 0; - for( r=0; r<4; r++ ) /* rgb232 => 128 */ - for( g=0; g<8; g++ ) - for( b=0; b<4; b++ ) { - if( settings_current.bw_tv ) { - red = green = blue = ( - r * 4822 / 3 + - g * 9467 / 7 + - b * 1839 / 3 ) >> 8; - } else { - red = r * 63 / 3; - green = g * 63 / 7; - blue = b * 63 / 3; - } - vga_setpalette( i, red, green, blue ); - i++; - } - - return 0; -} - - -int -uidisplay_init( int width, int height ) -{ - image_width = width; - image_height = height; - if( !scaler_is_supported( current_scaler ) ) { - if( machine_current->timex ) - scaler_select_scaler( SCALER_HALFSKIP ); - else - scaler_select_scaler( SCALER_NORMAL ); - } - register_scalers(); - display_ui_initialised = 1; - - display_refresh_all(); - - return 0; -} - -static void -register_scalers( void ) -{ - int f = -1; - - scaler_register_clear(); - scaler_select_bitformat( 565 ); /* 16bit always */ - - if( machine_current->timex ) { - SIZE_1x_REGISTER( 0, SCALER_HALF ); - SIZE_1x_REGISTER( 1, SCALER_HALFSKIP ); - SIZE_2x_REGISTER( 1, SCALER_NORMAL ); - SIZE_2x_REGISTER( 0, SCALER_PALTV ); - SIZE_3x_REGISTER( 0, SCALER_TIMEXTV ); - SIZE_3x_REGISTER( 1, SCALER_TIMEX1_5X ); - } else { - SIZE_1x_REGISTER( 1, SCALER_NORMAL ); - SIZE_1x_REGISTER( 0, SCALER_PALTV ); - - SIZE_2x_REGISTER( 1, SCALER_DOUBLESIZE ); - SIZE_2x_REGISTER( 0, SCALER_2XSAI ); - SIZE_2x_REGISTER( 0, SCALER_SUPER2XSAI ); - SIZE_2x_REGISTER( 0, SCALER_SUPEREAGLE ); - SIZE_2x_REGISTER( 1, SCALER_ADVMAME2X ); - SIZE_2x_REGISTER( 0, SCALER_TV2X ); - SIZE_2x_REGISTER( 0, SCALER_DOTMATRIX ); - SIZE_2x_REGISTER( 0, SCALER_PALTV2X ); - SIZE_2x_REGISTER( 0, SCALER_HQ2X ); - - SIZE_3x_REGISTER( 1, SCALER_TRIPLESIZE ); - SIZE_3x_REGISTER( 1, SCALER_ADVMAME3X ); - SIZE_3x_REGISTER( 0, SCALER_TV3X ); - SIZE_3x_REGISTER( 0, SCALER_PALTV3X ); - SIZE_3x_REGISTER( 0, SCALER_HQ3X ); - } - if( current_scaler != SCALER_NUM ) - f = 4.0 * scaler_get_scaling_factor( current_scaler ) * - ( machine_current->timex ? 2 : 1 ); - if( scaler_is_supported( current_scaler ) && - ( svgadisplay_current_size * 4 == f ) ) { - uidisplay_hotswap_gfx_mode(); - } else { - switch( svgadisplay_current_size ) { - case 1: - scaler_select_scaler( machine_current->timex ? SCALER_HALF : SCALER_NORMAL ); - break; - case 2: - scaler_select_scaler( machine_current->timex ? SCALER_NORMAL : SCALER_DOUBLESIZE ); - break; - case 3: - scaler_select_scaler( machine_current->timex ? SCALER_TIMEX1_5X : SCALER_TRIPLESIZE ); - break; - } - } -} - -static void -svgadisplay_setup_rgb_putpixel( void ) -{ - switch( svgadisplay_depth ) { - case 4: - svgadisplay_putpixel = svgadisplay_putpixel_4; - break; - case 8: - svgadisplay_putpixel = svgadisplay_putpixel_8; - break; - case 15: - svgadisplay_putpixel = svgadisplay_putpixel_15; - break; - case 16: - svgadisplay_putpixel = svgadisplay_putpixel_16; - break; - case 24: - svgadisplay_putpixel = svgadisplay_putpixel_24; - break; - case 32: - svgadisplay_putpixel = svgadisplay_putpixel_32; - break; - } -/* resize_window( scaled_image_w, scaled_image_h ); */ -} - -int -uidisplay_hotswap_gfx_mode( void ) -{ - image_scale = 4.0 * scaler_get_scaling_factor( current_scaler ); - scaled_image_w = image_width * image_scale >> 2; - scaled_image_h = image_height * image_scale >> 2; - - if( svgadisplay_current_size * 4 != - image_scale * ( machine_current->timex ? 2 : 1 ) ) { - svgadisplay_current_size = ( image_scale * ( machine_current->timex ? 2 : 1 ) ) >> 2; - svgadisplay_setmode( svgadisplay_current_size - 1 ); - } - - if( current_scaler == SCALER_NORMAL ) - svgadisplay_update_rect = svgadisplay_update_rect_noscale; - else - svgadisplay_update_rect = svgadisplay_update_rect_scale; - - svgadisplay_force_full_refresh = 1; - - svgadisplay_setup_rgb_putpixel(); - - if( settings_current.bw_tv != svgadisplay_bw ) { - svgadisplay_bw = settings_current.bw_tv; - if( svgadisplay_depth == 4 ) - svgadisplay_allocate_colours4(); - else if( svgadisplay_depth == 8 ) - svgadisplay_allocate_colours8(); - } - display_refresh_all(); - return 0; -} - -static void -svgadisplay_update_rect_noscale( int x, int y, int w, int h ) -{ - int yy, xx; - - if( xclip || yclip ) { - if( x < xclip ) w -= xclip - x, x = xclip; - if( y < yclip ) h -= yclip - y, y = yclip; - if( x + w > scaled_image_w - xclip ) w = scaled_image_w - xclip - x; - if( y + h > scaled_image_h - yclip ) h = scaled_image_h - yclip - y; - } - /* Call putpixel multiple times */ - for( yy = y; yy < y + h; yy++ ) { - line_buff_ptr = line_buff; - for( xx = x; xx < x + w; xx++ ) - svgadisplay_putpixel( xx, yy, &rgb_image[yy + 2][xx + 1] ); - if( w > 0 ) - vga_drawscansegment( line_buff, x + xoffs - xclip, yy + yoffs - yclip, w * bytesperpixel ); - } -} - -static void -svgadisplay_update_rect_scale( int x, int y, int w, int h ) -{ - int yy = y, xx = x; - - y = y * image_scale >> 2; - x = x * image_scale >> 2; - scaler_proc16( - (libspectrum_byte *)&(rgb_image[yy + 2][xx + 1]), - rgb_pitch * sizeof(rgb_image[0][0]), - (libspectrum_byte *)&(scaled_image[y][x]), - scaled_pitch, - w, h - ); - - w = w * image_scale >> 2; - h = h * image_scale >> 2; - - if( xclip || yclip ) { - if( x < xclip ) w -= xclip - x, x = xclip; - if( y < yclip ) h -= yclip - y, y = yclip; - if( x + w > scaled_image_w - xclip ) w = scaled_image_w - xclip - x; - if( y + h > scaled_image_h - yclip ) h = scaled_image_h - yclip - y; - } - /* Call putpixel multiple times */ - for( yy = y; yy < y + h; yy++ ) { - line_buff_ptr = line_buff; - for( xx = x; xx < x + w; xx++ ) - svgadisplay_putpixel( xx, yy, &scaled_image[yy][xx] ); - if( w > 0 ) - vga_drawscansegment( line_buff, x + xoffs - xclip, yy + yoffs - yclip, w * bytesperpixel ); - } -} - -void -uidisplay_frame_end( void ) -{ - SVGA_Rect *r, *last_rect; - - /* Force a full redraw if requested */ - if ( svgadisplay_force_full_refresh ) { - num_rects = 1; - - updated_rects[0].x = 0; - updated_rects[0].y = 0; - updated_rects[0].w = image_width; - updated_rects[0].h = image_height; - } - - if ( !( ui_widget_level >= 0 ) && num_rects == 0 ) return; - - last_rect = updated_rects + num_rects; - - for( r = updated_rects; r != last_rect; r++ ) - svgadisplay_update_rect( r->x, r->y, r->w, r->h ); - num_rects = 0; - svgadisplay_force_full_refresh = 0; -} - -void -uidisplay_area( int x, int y, int w, int h ) -{ - if ( svgadisplay_force_full_refresh ) - return; - - if( num_rects == MAX_UPDATE_RECT ) { - svgadisplay_force_full_refresh = 1; - return; - } - - /* Extend the dirty region by 1 pixel for scalers - that "smear" the screen, e.g. 2xSAI */ - if( scaler_flags & SCALER_FLAGS_EXPAND ) - scaler_expander( &x, &y, &w, &h, image_width, image_height ); - - updated_rects[num_rects].x = x; - updated_rects[num_rects].y = y; - updated_rects[num_rects].w = w; - updated_rects[num_rects].h = h; - num_rects++; -} - -int -uidisplay_end( void ) -{ - display_ui_initialised = 0; - return 0; -} - -/* Set one pixel in the display */ -void -uidisplay_putpixel( int x, int y, int colour ) -{ - libspectrum_word pc = svgadisplay_depth == 4 ? colour : - ( settings_current.bw_tv ? pal_grey[ colour ] : - pal_colour[ colour ] ); - - if( machine_current->timex ) { - x <<= 1; y <<= 1; - rgb_image[y + 2][x + 1] = pc; - rgb_image[y + 2][x + 2] = pc; - rgb_image[y + 3][x + 1] = pc; - rgb_image[y + 3][x + 2] = pc; - } else { - rgb_image[y + 2][x + 1] = pc; - } -} - -/* Print the 8 pixels in `data' using ink colour `ink' and paper - colour `paper' to the screen at ( (8*x) , y ) */ -void -uidisplay_plot8( int x, int y, libspectrum_byte data, - libspectrum_byte ink, libspectrum_byte paper ) -{ - libspectrum_word *dest; - libspectrum_word pi = svgadisplay_depth == 4 ? ink : - ( settings_current.bw_tv ? pal_grey[ ink ] : - pal_colour[ ink ] ); - libspectrum_word pp = svgadisplay_depth == 4 ? paper : - ( settings_current.bw_tv ? pal_grey[ paper ] : - pal_colour[ paper ] ); - - if( machine_current->timex ) { - - x <<= 4; y <<= 1; - - dest = &(rgb_image[y + 2][x + 1]); - - *(dest + rgb_pitch) = *dest = ( data & 0x80 ) ? pi : pp; dest++; - *(dest + rgb_pitch) = *dest = ( data & 0x80 ) ? pi : pp; dest++; - *(dest + rgb_pitch) = *dest = ( data & 0x40 ) ? pi : pp; dest++; - *(dest + rgb_pitch) = *dest = ( data & 0x40 ) ? pi : pp; dest++; - *(dest + rgb_pitch) = *dest = ( data & 0x20 ) ? pi : pp; dest++; - *(dest + rgb_pitch) = *dest = ( data & 0x20 ) ? pi : pp; dest++; - *(dest + rgb_pitch) = *dest = ( data & 0x10 ) ? pi : pp; dest++; - *(dest + rgb_pitch) = *dest = ( data & 0x10 ) ? pi : pp; dest++; - *(dest + rgb_pitch) = *dest = ( data & 0x08 ) ? pi : pp; dest++; - *(dest + rgb_pitch) = *dest = ( data & 0x08 ) ? pi : pp; dest++; - *(dest + rgb_pitch) = *dest = ( data & 0x04 ) ? pi : pp; dest++; - *(dest + rgb_pitch) = *dest = ( data & 0x04 ) ? pi : pp; dest++; - *(dest + rgb_pitch) = *dest = ( data & 0x02 ) ? pi : pp; dest++; - *(dest + rgb_pitch) = *dest = ( data & 0x02 ) ? pi : pp; dest++; - *(dest + rgb_pitch) = *dest = ( data & 0x01 ) ? pi : pp; dest++; - *(dest + rgb_pitch) = *dest = ( data & 0x01 ) ? pi : pp; - } else { - x <<= 3; - - dest = &(rgb_image[y + 2][x + 1]); - - *(dest++) = ( data & 0x80 ) ? pi : pp; - *(dest++) = ( data & 0x40 ) ? pi : pp; - *(dest++) = ( data & 0x20 ) ? pi : pp; - *(dest++) = ( data & 0x10 ) ? pi : pp; - *(dest++) = ( data & 0x08 ) ? pi : pp; - *(dest++) = ( data & 0x04 ) ? pi : pp; - *(dest++) = ( data & 0x02 ) ? pi : pp; - *dest = ( data & 0x01 ) ? pi : pp; - } -} - -/* Print the 16 pixels in `data' using ink colour `ink' and paper - colour `paper' to the screen at ( (16*x) , y ) */ -void -uidisplay_plot16( int x, int y, libspectrum_word data, - libspectrum_byte ink, libspectrum_byte paper ) -{ - libspectrum_word *dest; - libspectrum_word pi = svgadisplay_depth == 4 ? ink : - ( settings_current.bw_tv ? pal_grey[ ink ] : - pal_colour[ ink ] ); - libspectrum_word pp = svgadisplay_depth == 4 ? paper : - ( settings_current.bw_tv ? pal_grey[ paper ] : - pal_colour[ paper ] ); - x <<= 4; y <<= 1; - - dest = &(rgb_image[y + 2][x + 1]); - *(dest + rgb_pitch) = *dest = ( data & 0x8000 ) ? pi : pp; dest++; - *(dest + rgb_pitch) = *dest = ( data & 0x4000 ) ? pi : pp; dest++; - *(dest + rgb_pitch) = *dest = ( data & 0x2000 ) ? pi : pp; dest++; - *(dest + rgb_pitch) = *dest = ( data & 0x1000 ) ? pi : pp; dest++; - *(dest + rgb_pitch) = *dest = ( data & 0x0800 ) ? pi : pp; dest++; - *(dest + rgb_pitch) = *dest = ( data & 0x0400 ) ? pi : pp; dest++; - *(dest + rgb_pitch) = *dest = ( data & 0x0200 ) ? pi : pp; dest++; - *(dest + rgb_pitch) = *dest = ( data & 0x0100 ) ? pi : pp; dest++; - *(dest + rgb_pitch) = *dest = ( data & 0x0080 ) ? pi : pp; dest++; - *(dest + rgb_pitch) = *dest = ( data & 0x0040 ) ? pi : pp; dest++; - *(dest + rgb_pitch) = *dest = ( data & 0x0020 ) ? pi : pp; dest++; - *(dest + rgb_pitch) = *dest = ( data & 0x0010 ) ? pi : pp; dest++; - *(dest + rgb_pitch) = *dest = ( data & 0x0008 ) ? pi : pp; dest++; - *(dest + rgb_pitch) = *dest = ( data & 0x0004 ) ? pi : pp; dest++; - *(dest + rgb_pitch) = *dest = ( data & 0x0002 ) ? pi : pp; dest++; - *(dest + rgb_pitch) = *dest = ( data & 0x0001 ) ? pi : pp; -} - -int svgadisplay_end( void ) -{ - vga_setmode( TEXT ); - return 0; -} - -void -uidisplay_frame_save( void ) -{ - /* FIXME: Save current framebuffer state as the widget UI wants to scribble - in here */ -} - -void -uidisplay_frame_restore( void ) -{ - /* FIXME: Restore saved framebuffer state as the widget UI wants to draw a - new menu */ -} diff --git a/ui/svga/svgadisplay.h b/ui/svga/svgadisplay.h deleted file mode 100644 index 7293ae44..00000000 --- a/ui/svga/svgadisplay.h +++ /dev/null @@ -1,30 +0,0 @@ -/* svgadisplay.h: Routines for dealing with the svgalib display - Copyright (c) 2003 Philip Kendall - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program 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 General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: phi...@sh... - -*/ - -#ifndef FUSE_SVGADISPLAY_H -#define FUSE_SVGADISPLAY_H - -int svgadisplay_init( void ); -int svgadisplay_end( void ); - -#endif /* #ifndef FUSE_SVGADISPLAY_H */ diff --git a/ui/svga/svgajoystick.c b/ui/svga/svgajoystick.c deleted file mode 100644 index 0195b425..00000000 --- a/ui/svga/svgajoystick.c +++ /dev/null @@ -1,159 +0,0 @@ -/* svgajoystick.c: Joystick emulation (using svgalib) - Copyright (c) 2003-4 Darren Salt - Copyright (c) 2015 UB880D - Copyright (c) 2015 Sergio Baldoví - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program 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 General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: phi...@sh... - - Darren: li...@yo... - -*/ - -#include "config.h" -#include "peripherals/joystick.h" - -#if !defined USE_JOYSTICK || defined HAVE_JSW_H - -/* Fake joystick, or override UI-specific handling */ -#include "../uijoystick.c" - -#else /* #if !defined USE_JOYSTICK || defined HAVE_JSW_H */ - -/* Use the svgalib joystick support */ - -#include <string.h> -#include <errno.h> - -#include "libspectrum.h" -#include <vgajoystick.h> - -#include "fuse.h" -#include "keyboard.h" -#include "settings.h" -#include "spectrum.h" -#include "machine.h" -#include "ui/ui.h" -#include "ui/uijoystick.h" - -static int sticks = 0; -static int buttons[2]; - -static void joy_handler( int ev, int number, char value, int which ); - -static int -init_stick( int which ) -{ - if( !joystick_init( which, JOY_CALIB_STDOUT ) ) { - ui_error( UI_ERROR_ERROR, "failed to initialise joystick %i: %s", - which + 1, errno ? strerror (errno) : "not configured?" ); - return 1; - } - - if( joystick_getnumaxes( which ) < 2 || - joystick_getnumbuttons( which ) < 1 ) { - joystick_close( which ); - ui_error( UI_ERROR_ERROR, "sorry, joystick %i is inadequate!", which + 1 ); - return 1; - } - - buttons[which] = joystick_getnumbuttons( which ); - if( buttons[which] > NUM_JOY_BUTTONS ) buttons[which] = NUM_JOY_BUTTONS; - - return 0; -} - -int -ui_joystick_init( void ) -{ - int i; - - /* If we can't init the first, don't try the second */ - if( init_stick( 0 ) ) { - sticks = 0; - } else if( init_stick( 1 ) ) { - sticks = 1; - } else { - sticks = 2; - } - - for( i = 0; i < sticks; i++ ) { - joystick_sethandler( i, joy_handler ); - } - - return sticks; -} - -void -ui_joystick_end( void ) -{ - joystick_close( -1 ); -} - -static void -do_axis( int which, int position, input_key negative, input_key positive ) -{ - input_event_t event1, event2; - - event1.types.joystick.which = event2.types.joystick.which = which; - - event1.types.joystick.button = positive; - event2.types.joystick.button = negative; - - event1.type = position > 0 ? INPUT_EVENT_JOYSTICK_PRESS : - INPUT_EVENT_JOYSTICK_RELEASE; - event2.type = position < 0 ? INPUT_EVENT_JOYSTICK_PRESS : - INPUT_EVENT_JOYSTICK_RELEASE; - - input_event( &event1 ); - input_event( &event2 ); -} - -static void -joy_handler( int ev, int number, char value, int which ) -{ - input_event_t event; - - switch ( ev ) { - case JOY_EVENTAXIS: - if( number == 0 ) - do_axis( which, value, INPUT_JOYSTICK_LEFT, INPUT_JOYSTICK_RIGHT ); - else if( number == 1 ) - do_axis( which, value, INPUT_JOYSTICK_UP, INPUT_JOYSTICK_DOWN ); - break; - case JOY_EVENTBUTTONDOWN: - case JOY_EVENTBUTTONUP: - if( number >= buttons[which] ) return; - event.types.joystick.which = which; - event.types.joystick.button = INPUT_JOYSTICK_FIRE_1 + number; - event.type = ( ev == JOY_EVENTBUTTONDOWN ) - ? INPUT_EVENT_JOYSTICK_PRESS - : INPUT_EVENT_JOYSTICK_RELEASE; - input_event( &event ); - break; - default: - break; - } -} - -void -ui_joystick_poll( void ) -{ -} - -#endif /* #if !defined USE_JOYSTICK || defined HAVE_JSW_H */ diff --git a/ui/svga/svgakeyboard.c b/ui/svga/svgakeyboard.c deleted file mode 100644 index 8da76fdc..00000000 --- a/ui/svga/svgakeyboard.c +++ /dev/null @@ -1,99 +0,0 @@ -/* svgakeyboard.c: svgalib routines for dealing with the keyboard - Copyright (c) 2000-2004 Philip Kendall, Matan Ziv-Av - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program 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 General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: phi...@sh... - -*/ - -#include "config.h" - -#include <stdio.h> - -#include <vga.h> -#include <vgakeyboard.h> - -#include "display.h" -#include "fuse.h" -#include "keyboard.h" -#include "machine.h" -#include "settings.h" -#include "snapshot.h" -#include "spectrum.h" -#include "tape.h" -#include "ui/ui.h" -#include "utils.h" - -static void svgakeyboard_keystroke(int scancode, int press); -static int svgakeyboard_keypress( int keysym ); -static int svgakeyboard_keyrelease( int keysym ); - -int svgakeyboard_init(void) -{ - keyboard_init(); - keyboard_seteventhandler(svgakeyboard_keystroke); - return 0; -} - -static void svgakeyboard_keystroke(int scancode, int press) { - if(press) { - svgakeyboard_keypress(scancode); - } else { - svgakeyboard_keyrelease(scancode); - } -} - -static int -svgakeyboard_keypress( int keysym ) -{ - input_key fuse_keysym; - input_event_t fuse_event; - - fuse_keysym = keysyms_remap( keysym ); - - if( fuse_keysym == INPUT_KEY_NONE ) return 0; - - fuse_event.type = INPUT_EVENT_KEYPRESS; - fuse_event.types.key.native_key = fuse_keysym; - fuse_event.types.key.spectrum_key = fuse_keysym; - - return input_event( &fuse_event ); -} - -static int -svgakeyboard_keyrelease( int keysym ) -{ - input_key fuse_keysym; - input_event_t fuse_event; - - fuse_keysym = keysyms_remap( keysym ); - - if( fuse_keysym == INPUT_KEY_NONE ) return 0; - - fuse_event.type = INPUT_EVENT_KEYRELEASE; - fuse_event.types.key.native_key = fuse_keysym; - fuse_event.types.key.spectrum_key = fuse_keysym; - - return input_event( &fuse_event ); -} - -int svgakeyboard_end(void) -{ - keyboard_close(); - return 0; -} diff --git a/ui/svga/svgakeyboard.h b/ui/svga/svgakeyboard.h deleted file mode 100644 index 834c1690..00000000 --- a/ui/svga/svgakeyboard.h +++ /dev/null @@ -1,30 +0,0 @@ -/* svgakeyboard.h: svgalib routines for dealing with the keyboard - Copyright (c) 2000-2002 Philip Kendall, Matan Ziv-Av - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program 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 General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: phi...@sh... - -*/ - -#ifndef FUSE_SVGAKEYBOARD_H -#define FUSE_SVGAKEYBOARD_H - -int svgakeyboard_init(void); -int svgakeyboard_end(void); - -#endif /* #ifndef FUSE_SVGAKEYBOARD_H */ diff --git a/ui/svga/svgaui.c b/ui/svga/svgaui.c deleted file mode 100644 index aebfd1e5..00000000 --- a/ui/svga/svgaui.c +++ /dev/null @@ -1,124 +0,0 @@ -/* svgaui.c: Routines for dealing with the svgalib user interface - Copyright (c) 2000-2003 Philip Kendall, Matan Ziv-Av, Russell Marks - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program 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 General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: phi...@sh... - -*/ - -#include "config.h" - -#include <stdio.h> - -#include <vga.h> - -#if defined USE_JOYSTICK && !defined HAVE_JSW_H -#include <vgajoystick.h> -#endif - -#include <vgakeyboard.h> -#include <vgamouse.h> - -#include "display.h" -#include "fuse.h" -#include "svgadisplay.h" -#include "svgakeyboard.h" -#include "ui/ui.h" -#include "ui/uidisplay.h" - -static int oldbutton = 0, oldx = 0, oldy = 0; - -int ui_init(int *argc, char ***argv) -{ - int error; - - if( ui_widget_init() ) return 1; - - error = svgadisplay_init(); - if(error) return error; - - error = svgakeyboard_init(); - if(error) return error; - - vga_setmousesupport( 1 ); - mouse_setxrange( 0, 255); - mouse_setyrange( 0, 255); - mouse_setscale( 64 ); - mouse_setwrap( MOUSE_WRAPX | MOUSE_WRAPY ); - mouse_setposition( 128, 128 ); - - ui_mouse_present = 1; - - return 0; -} - -int -ui_event( void ) -{ - int x, y, b, bd; - - keyboard_update(); - mouse_update(); -#if defined USE_JOYSTICK && !defined HAVE_JSW_H - joystick_update(); -#endif - - x = mouse_getx(); - y = mouse_gety(); - b = mouse_getbutton(); - - bd = b ^ oldbutton; - if( bd & MOUSE_LEFTBUTTON ) ui_mouse_button( 1, b & MOUSE_LEFTBUTTON ); - if( bd & MOUSE_MIDDLEBUTTON ) ui_mouse_button( 2, b & MOUSE_MIDDLEBUTTON ); - if( bd & MOUSE_RIGHTBUTTON ) ui_mouse_button( 3, b & MOUSE_RIGHTBUTTON ); - oldbutton = b; - - if( x != oldx || y != oldy ) { - ui_mouse_motion( x - oldx, y - oldy ); - oldx = x; oldy = y; - } - - return 0; -} - -int ui_end(void) -{ - int error; - - error = svgakeyboard_end(); - if(error) return error; - - error = svgadisplay_end(); - if(error) return error; - - ui_widget_end(); - - return 0; -} - -int -ui_mouse_grab( int startup GCC_UNUSED ) -{ - return 1; -} - -int -ui_mouse_release( int suspend ) -{ - return !suspend; -} |