From: <pa...@us...> - 2003-10-07 13:49:09
|
Update of /cvsroot/fuse-emulator/fuse In directory sc8-pr-cvs1:/tmp/cvs-serv31876 Modified Files: acconfig.h configure.in fuse.c joystick.c joystick.h Log Message: Real joystick support (Darren/Fred) Index: acconfig.h =================================================================== RCS file: /cvsroot/fuse-emulator/fuse/acconfig.h,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** acconfig.h 23 Jun 2003 16:17:18 -0000 1.21 --- acconfig.h 7 Oct 2003 13:49:00 -0000 1.22 *************** *** 66,69 **** --- 66,72 ---- #undef UI_X + /* Defined if we're using hardware joysticks */ + #undef USE_JOYSTICK + /* Defined if we're going to be using the installed libpng */ #undef USE_LIBPNG Index: configure.in =================================================================== RCS file: /cvsroot/fuse-emulator/fuse/configure.in,v retrieving revision 1.118 retrieving revision 1.119 diff -C2 -d -r1.118 -r1.119 *** configure.in 3 Oct 2003 18:03:08 -0000 1.118 --- configure.in 7 Oct 2003 13:49:00 -0000 1.119 *************** *** 288,295 **** AC_SUBST(PNG_LIBS) dnl See if libxml2 is available (for the config file handling) AM_PATH_XML2(2.0.0,AC_DEFINE(HAVE_LIB_XML2), AC_WARN(libxml2 not found - config file use disabled)) ! dnl Do we want the low memory compile? AC_MSG_CHECKING(whether low memory compile requested) --- 288,333 ---- AC_SUBST(PNG_LIBS) + AC_MSG_CHECKING(whether hardware joystick support requested) + AC_ARG_WITH(joystick, + [ --with-joystick use a real joystick for Kempston emulation etc.], + if test "$withval" = no; then stick=no; else stick=yes; fi, + stick=yes) + 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...) + AC_DEFINE(USE_JOYSTICK) + case "$ui" in + svga) + dnl Libraries such as svgalib provide their own joystick code. + AC_MSG_CHECKING([whether to use $UI's joystick support]) + AC_ARG_ENABLE(ui-joystick, + [ --enable-ui-joystick use UI-specific joystick code (where supported)], + if test "$enableval" = no; then libjsw=yes; else libjsw=no; fi, + libjsw=no) + if test "$libjsw" = yes; then + AC_MSG_RESULT([no, use libjsw]) + else + AC_MSG_RESULT(yes) + fi + ;; + *) + dnl Our only option is libjsw. + libjsw=yes + ;; + esac + if test "$libjsw" = yes; then + dnl Look for libjsw. If missing, use QAOP<space>. + AC_CHECK_HEADERS(jsw.h, + LIBS="$LIBS -ljsw", + AC_MSG_WARN(jsw.h not found - joystick support disabled)) + fi + fi + dnl See if libxml2 is available (for the config file handling) AM_PATH_XML2(2.0.0,AC_DEFINE(HAVE_LIB_XML2), AC_WARN(libxml2 not found - config file use disabled)) ! dnl Do we want the low memory compile? AC_MSG_CHECKING(whether low memory compile requested) Index: fuse.c =================================================================== RCS file: /cvsroot/fuse-emulator/fuse/fuse.c,v retrieving revision 1.85 retrieving revision 1.86 diff -C2 -d -r1.85 -r1.86 *** fuse.c 23 Sep 2003 12:10:10 -0000 1.85 --- fuse.c 7 Oct 2003 13:49:00 -0000 1.86 *************** *** 42,45 **** --- 42,46 ---- #include "event.h" #include "fuse.h" + #include "joystick.h" #include "keyboard.h" #include "machine.h" *************** *** 148,151 **** --- 149,153 ---- /* FIXME FIXME 20030407: really do this soon. This is getting *far* too hairy */ + fuse_joystick_init (); fuse_keyboard_init(); *************** *** 459,462 **** --- 461,465 ---- sound_end(); event_end(); + fuse_joystick_end (); ui_end(); Index: joystick.c =================================================================== RCS file: /cvsroot/fuse-emulator/fuse/joystick.c,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** joystick.c 17 Aug 2003 20:40:03 -0000 1.8 --- joystick.c 7 Oct 2003 13:49:00 -0000 1.9 *************** *** 36,50 **** #include "spectrum.h" #include "machine.h" libspectrum_byte ! joystick_kempston_read( libspectrum_word port ) { /* Offset/mask in keyboard_return_values[] for joystick keys, in order right, left, down, up, fire. These are p/o/a/q/Space */ ! static int offset[5] = { 5, 5, 1, 2, 7 }; ! static int mask[5] = { 0x01, 0x02, 0x01, 0x01, 0x01 }; libspectrum_byte return_value = 0, jmask = 1; int i; if( !settings_current.joy_kempston ) { /* Some machines have a built-in Kempston interface */ --- 36,75 ---- #include "spectrum.h" #include "machine.h" + #include "ui/ui.h" + #include "ui/uijoystick.h" + + /* Number of joysticks known about & initialised */ + int joysticks_supported = 0; + + /* Init/shutdown functions. Errors aren't important here */ + + void + fuse_joystick_init (void) + { + joysticks_supported = ui_joystick_init(); + } + + void + fuse_joystick_end (void) + { + ui_joystick_end(); + } + + /* Returns joystick direction/button state in Kempston format. + This is used if no (hardware) joysticks are found. */ libspectrum_byte ! joystick_default_read( libspectrum_word port, libspectrum_byte which ) { /* Offset/mask in keyboard_return_values[] for joystick keys, in order right, left, down, up, fire. These are p/o/a/q/Space */ ! static const int offset[5] = { 5, 5, 1, 2, 7 }; ! static const int mask[5] = { 0x01, 0x02, 0x01, 0x01, 0x01 }; libspectrum_byte return_value = 0, jmask = 1; int i; + /* We only support one "joystick" */ + if( which ) return 0; + if( !settings_current.joy_kempston ) { /* Some machines have a built-in Kempston interface */ *************** *** 65,70 **** } libspectrum_byte ! joystick_timex_read( libspectrum_word port, int which ) { static const libspectrum_byte translate[] = { --- 90,110 ---- } + /* Read functions for specific interfaces */ + libspectrum_byte ! joystick_kempston_read( libspectrum_word port ) ! { ! /* If joysticks are disabled, return the floating bus value */ ! if( !settings_current.joy_kempston ) return spectrum_port_noread( port ); ! ! /* If we have no real joysticks, return the QAOP<space>-emulated value */ ! if( joysticks_supported == 0 ) return joystick_default_read( port, 0 ); ! ! /* Return the value from the actual joystick */ ! return ui_joystick_read( port, 0 ); ! } ! ! libspectrum_byte ! joystick_timex_read( libspectrum_word port, libspectrum_byte which ) { static const libspectrum_byte translate[] = { *************** *** 75,81 **** }; ! if( which == 0 ) ! return translate[ joystick_kempston_read( port ) ]; ! return 0; } --- 115,124 ---- }; ! /* If we don't have a real joystick for this, use the QAOP<space>-emulated ! value */ ! if( joysticks_supported <= which ) ! return translate[ joystick_default_read( port, which ) ]; ! /* If we do have a real joystick, read it */ ! return translate[ ui_joystick_read( port, which ) ]; } Index: joystick.h =================================================================== RCS file: /cvsroot/fuse-emulator/fuse/joystick.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** joystick.h 11 Jul 2003 11:03:25 -0000 1.3 --- joystick.h 7 Oct 2003 13:49:00 -0000 1.4 *************** *** 1,4 **** --- 1,5 ---- /* joystick.h: Joystick emulation support Copyright (c) 2001-2003 Russell Marks, Philip Kendall + Copyright (c) 2003 Darren Salt $Id$ *************** *** 30,36 **** #include <libspectrum.h> ! libspectrum_byte joystick_kempston_read( libspectrum_word port ); ! void joystick_kempston_write( libspectrum_word port, libspectrum_byte b ); ! libspectrum_byte joystick_timex_read( libspectrum_word port, int which ); #endif /* #ifndef FUSE_JOYSTICK_H */ --- 31,49 ---- #include <libspectrum.h> ! /* Number of joysticks known about & initialised */ ! extern int joysticks_supported; ! ! /* Init/shutdown functions. Errors aren't important here */ ! void fuse_joystick_init( void ); ! void fuse_joystick_end( void ); ! ! /* Default read function (returns data in Kempston format) */ ! libspectrum_byte joystick_default_read( libspectrum_word port, ! libspectrum_byte which ); ! ! /* Interface-specific read functions */ ! libspectrum_byte joystick_kempston_read ( libspectrum_word port ); ! libspectrum_byte joystick_timex_read ( libspectrum_word port, ! libspectrum_byte which ); #endif /* #ifndef FUSE_JOYSTICK_H */ |