From: <fr...@us...> - 2009-06-07 14:38:57
|
Revision: 4030 http://fuse-emulator.svn.sourceforge.net/fuse-emulator/?rev=4030&view=rev Author: fredm Date: 2009-06-07 14:38:38 +0000 (Sun, 07 Jun 2009) Log Message: ----------- Add emulation of the Fuller Box and support for the Fuller Box in snapshots (feature request #1764994) (Stuart & Fred). Modified Paths: -------------- trunk/fuse/Makefile.am trunk/fuse/ay.c trunk/fuse/ay.h trunk/fuse/fuse.c trunk/fuse/hacking/ChangeLog trunk/fuse/joystick.c trunk/fuse/joystick.h trunk/fuse/kempmouse.c trunk/fuse/machines/spec16.c trunk/fuse/machines/spec48.c trunk/fuse/machines/tc2048.c trunk/fuse/man/fuse.1 trunk/fuse/periph.c trunk/fuse/periph.h trunk/fuse/settings.dat trunk/fuse/sound.cpp trunk/fuse/ui/options.dat trunk/libspectrum/accessor.pl trunk/libspectrum/doc/libspectrum.txt trunk/libspectrum/hacking/ChangeLog trunk/libspectrum/libspectrum.c trunk/libspectrum/snap_accessors.txt trunk/libspectrum/snapshot.c trunk/libspectrum/szx.c trunk/libspectrum/z80.c Added Paths: ----------- trunk/fuse/fuller.c trunk/fuse/fuller.h Modified: trunk/fuse/Makefile.am =================================================================== --- trunk/fuse/Makefile.am 2009-06-05 13:50:55 UTC (rev 4029) +++ trunk/fuse/Makefile.am 2009-06-07 14:38:38 UTC (rev 4030) @@ -1,5 +1,5 @@ # Process this file with automake to produce Makefile.in -## Copyright (c) 1999-2008 Philip Kendall +## Copyright (c) 1999-2009 Philip Kendall ## $Id$ @@ -62,6 +62,7 @@ dck.c \ display.c \ event.c \ + fuller.c \ fuse.c \ if1.c \ if2.c \ @@ -173,6 +174,7 @@ dck.h \ display.h \ event.h \ + fuller.h \ fuse.h \ if1.h \ if2.h \ Modified: trunk/fuse/ay.c =================================================================== --- trunk/fuse/ay.c 2009-06-05 13:50:55 UTC (rev 4029) +++ trunk/fuse/ay.c 2009-06-07 14:38:38 UTC (rev 4030) @@ -1,5 +1,5 @@ /* ay.c: AY-8-3912 routines - Copyright (c) 1999-2004 Philip Kendall + Copyright (c) 1999-2009 Philip Kendall $Id$ @@ -131,22 +131,26 @@ if( current == 14 ) printer_serial_write( b ); } -static void -ay_from_snapshot( libspectrum_snap *snap ) +void +ay_state_from_snapshot( libspectrum_snap *snap ) { size_t i; - if( machine_current->capabilities & LIBSPECTRUM_MACHINE_CAPABILITY_AY ) { + ay_registerport_write( 0xfffd, + libspectrum_snap_out_ay_registerport( snap ) ); - ay_registerport_write( 0xfffd, - libspectrum_snap_out_ay_registerport( snap ) ); + for( i = 0; i < AY_REGISTERS; i++ ) { + machine_current->ay.registers[i] = + libspectrum_snap_ay_registers( snap, i ); + sound_ay_write( i, machine_current->ay.registers[i], 0 ); + } +} - for( i = 0; i < AY_REGISTERS; i++ ) { - machine_current->ay.registers[i] = - libspectrum_snap_ay_registers( snap, i ); - sound_ay_write( i, machine_current->ay.registers[i], 0 ); - } - +static void +ay_from_snapshot( libspectrum_snap *snap ) +{ + if( machine_current->capabilities & LIBSPECTRUM_MACHINE_CAPABILITY_AY ) { + ay_state_from_snapshot( snap ); } } Modified: trunk/fuse/ay.h =================================================================== --- trunk/fuse/ay.h 2009-06-05 13:50:55 UTC (rev 4029) +++ trunk/fuse/ay.h 2009-06-07 14:38:38 UTC (rev 4030) @@ -1,5 +1,5 @@ /* ay.h: AY-8-3912 routines - Copyright (c) 1999-2004 Philip Kendall + Copyright (c) 1999-2009 Philip Kendall $Id$ @@ -42,4 +42,6 @@ void ay_dataport_write( libspectrum_word port, libspectrum_byte b ); +void ay_state_from_snapshot( libspectrum_snap *snap ); + #endif /* #ifndef FUSE_AY_H */ Added: trunk/fuse/fuller.c =================================================================== --- trunk/fuse/fuller.c (rev 0) +++ trunk/fuse/fuller.c 2009-06-07 14:38:38 UTC (rev 4030) @@ -0,0 +1,92 @@ +/* fuller.c: Routines for handling the Fuller Box + Copyright (c) 2007-2009 Stuart Brady, Fredrick Meunier + + $Id$ + + 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: + + Philip: phi...@sh... + + Stuart: sd...@nt... + +*/ + +#include <config.h> + +#include <libspectrum.h> + +#include "ay.h" +#include "compat.h" +#include "fuller.h" +#include "joystick.h" +#include "machine.h" +#include "memory.h" +#include "module.h" +#include "periph.h" +#include "settings.h" + +static void fuller_enabled_snapshot( libspectrum_snap *snap ); +static void fuller_from_snapshot( libspectrum_snap *snap ); +static void fuller_to_snapshot( libspectrum_snap *snap ); + +static module_info_t fuller_module_info = { + + NULL, + NULL, + fuller_enabled_snapshot, + fuller_from_snapshot, + fuller_to_snapshot, + +}; + +const periph_t fuller_peripherals[] = { + { 0x00ff, 0x003f, ay_registerport_read, ay_registerport_write }, + { 0x00ff, 0x005f, NULL, ay_dataport_write }, + { 0x00ff, 0x007f, joystick_fuller_read, NULL }, +}; + +const size_t fuller_peripherals_count = + sizeof( fuller_peripherals ) / sizeof( periph_t ); + +static void +fuller_enabled_snapshot( libspectrum_snap *snap ) +{ + if( libspectrum_snap_fuller_box_active( snap ) ) + settings_current.fuller = 1; +} + +static void +fuller_from_snapshot( libspectrum_snap *snap ) +{ + if( periph_fuller_active ) { + ay_state_from_snapshot( snap ); + } +} + +static void +fuller_to_snapshot( libspectrum_snap *snap ) +{ + libspectrum_snap_set_fuller_box_active( snap, periph_fuller_active ); +} + +int +fuller_init( void ) +{ + module_register( &fuller_module_info ); + + return 0; +} Property changes on: trunk/fuse/fuller.c ___________________________________________________________________ Added: svn:keywords + Id Added: trunk/fuse/fuller.h =================================================================== --- trunk/fuse/fuller.h (rev 0) +++ trunk/fuse/fuller.h 2009-06-07 14:38:38 UTC (rev 4030) @@ -0,0 +1,40 @@ +/* fuller.h: Routines for handling the Fuller Box + Copyright (c) 2007-2009 Stuart Brady, Fredrick Meunier + + $Id$ + + 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: + + Philip: phi...@sh... + + Stuart: sd...@nt... + +*/ + +#ifndef FUSE_FULLER_H +#define FUSE_FULLER_H + +#include <libspectrum.h> + +#include "periph.h" + +extern const periph_t fuller_peripherals[]; +extern const size_t fuller_peripherals_count; + +int fuller_init( void ); + +#endif /* #ifndef FUSE_FULLER_H */ Property changes on: trunk/fuse/fuller.h ___________________________________________________________________ Added: svn:keywords + Id Modified: trunk/fuse/fuse.c =================================================================== --- trunk/fuse/fuse.c 2009-06-05 13:50:55 UTC (rev 4029) +++ trunk/fuse/fuse.c 2009-06-07 14:38:38 UTC (rev 4030) @@ -50,6 +50,7 @@ #include "disk/fdd.h" #include "display.h" #include "event.h" +#include "fuller.h" #include "fuse.h" #include "ide/divide.h" #include "ide/simpleide.h" @@ -290,6 +291,7 @@ if( slt_init() ) return 1; if( profile_init() ) return 1; if( kempmouse_init() ) return 1; + if( fuller_init() ) return 1; error = pokefinder_clear(); if( error ) return error; Modified: trunk/fuse/hacking/ChangeLog =================================================================== --- trunk/fuse/hacking/ChangeLog 2009-06-05 13:50:55 UTC (rev 4029) +++ trunk/fuse/hacking/ChangeLog 2009-06-07 14:38:38 UTC (rev 4030) @@ -3137,3 +3137,7 @@ 20090605 disk/{beta.[ch]},machines/{spec48.c,tc2048.c},man/fuse.1, z80/{coretest.c,z80.c,z80_ops.c}: enable Beta 128 interface in 48K and TC2048 machines (thanks, Omikron) (Fred). +20090608 Makefile.am,ay.[ch],fuller.[ch],fuse.c,joystick.[ch],kempmouse.c, + machines/{spec16.c,spec48.c,tc2048.c},man/fuse.1,periph.[ch], + settings.dat,sound.cpp,ui/options.dat: add emulation of the Fuller Box + (feature request #1764994) (Stuart & Fred). Modified: trunk/fuse/joystick.c =================================================================== --- trunk/fuse/joystick.c 2009-06-05 13:50:55 UTC (rev 4029) +++ trunk/fuse/joystick.c 2009-06-07 14:38:38 UTC (rev 4030) @@ -65,6 +65,7 @@ static libspectrum_byte kempston_value; static libspectrum_byte timex1_value; static libspectrum_byte timex2_value; +static libspectrum_byte fuller_value; /* The names of the joysticks we can emulate. Order must correspond to that of joystick.h:joystick_type_t */ @@ -73,7 +74,8 @@ "Cursor", "Kempston", "Sinclair 1", "Sinclair 2", - "Timex 1", "Timex 2" + "Timex 1", "Timex 2", + "Fuller" }; const char *joystick_connection[ JOYSTICK_CONN_COUNT ] = { @@ -103,6 +105,7 @@ { joysticks_supported = ui_joystick_init(); kempston_value = timex1_value = timex2_value = 0x00; + fuller_value = 0xff; module_register( &joystick_module_info ); } @@ -179,6 +182,14 @@ } return 1; + case JOYSTICK_TYPE_FULLER: + if( press ) { + fuller_value &= ~timex_mask[ button ]; + } else { + fuller_value |= timex_mask[ button ]; + } + return 1; + case JOYSTICK_TYPE_NONE: return 0; } @@ -205,6 +216,16 @@ return which ? timex2_value : timex1_value; } +libspectrum_byte +joystick_fuller_read( libspectrum_word port GCC_UNUSED, int *attached ) +{ + if( !periph_fuller_active ) return 0xff; + + *attached = 1; + + return fuller_value; +} + static void joystick_from_snapshot( libspectrum_snap *snap ) { @@ -233,6 +254,8 @@ fuse_type = JOYSTICK_TYPE_TIMEX_2; break; case LIBSPECTRUM_JOYSTICK_FULLER: + fuse_type = JOYSTICK_TYPE_FULLER; + break; default: ui_error( UI_ERROR_INFO, "Ignoring unsupported joystick in snapshot %s", libspectrum_joystick_name( libspectrum_snap_joystick_list( snap, i ) )); @@ -293,6 +316,9 @@ case JOYSTICK_TYPE_TIMEX_2: libspectrum_type = LIBSPECTRUM_JOYSTICK_TIMEX_2; break; + case JOYSTICK_TYPE_FULLER: + libspectrum_type = LIBSPECTRUM_JOYSTICK_FULLER; + break; case JOYSTICK_TYPE_NONE: default: Modified: trunk/fuse/joystick.h =================================================================== --- trunk/fuse/joystick.h 2009-06-05 13:50:55 UTC (rev 4029) +++ trunk/fuse/joystick.h 2009-06-07 14:38:38 UTC (rev 4030) @@ -49,10 +49,11 @@ JOYSTICK_TYPE_SINCLAIR_2, JOYSTICK_TYPE_TIMEX_1, JOYSTICK_TYPE_TIMEX_2, + JOYSTICK_TYPE_FULLER, } joystick_type_t; -#define JOYSTICK_TYPE_COUNT 7 +#define JOYSTICK_TYPE_COUNT 8 extern const char *joystick_name[]; extern const char *joystick_connection[]; @@ -77,5 +78,7 @@ int *attached ); libspectrum_byte joystick_timex_read ( libspectrum_word port, libspectrum_byte which ); +libspectrum_byte joystick_fuller_read ( libspectrum_word port, + int *attached ); #endif /* #ifndef FUSE_JOYSTICK_H */ Modified: trunk/fuse/kempmouse.c =================================================================== --- trunk/fuse/kempmouse.c 2009-06-05 13:50:55 UTC (rev 4029) +++ trunk/fuse/kempmouse.c 2009-06-07 14:38:38 UTC (rev 4030) @@ -82,7 +82,6 @@ return 0; } - void kempmouse_update( int dx, int dy, int btn, int down ) { Modified: trunk/fuse/machines/spec16.c =================================================================== --- trunk/fuse/machines/spec16.c 2009-06-05 13:50:55 UTC (rev 4029) +++ trunk/fuse/machines/spec16.c 2009-06-07 14:38:38 UTC (rev 4030) @@ -1,5 +1,5 @@ /* spec16.c: Spectrum 16K specific routines - Copyright (c) 1999-2007 Philip Kendall + Copyright (c) 1999-2009 Philip Kendall $Id$ @@ -101,6 +101,7 @@ periph_setup_interface1( PERIPH_PRESENT_OPTIONAL ); periph_setup_interface2( PERIPH_PRESENT_OPTIONAL ); periph_setup_plusd( PERIPH_PRESENT_OPTIONAL ); + periph_setup_fuller( PERIPH_PRESENT_OPTIONAL ); periph_update(); /* ROM 0, RAM 5, nothing, nothing */ Modified: trunk/fuse/machines/spec48.c =================================================================== --- trunk/fuse/machines/spec48.c 2009-06-05 13:50:55 UTC (rev 4029) +++ trunk/fuse/machines/spec48.c 2009-06-07 14:38:38 UTC (rev 4030) @@ -1,5 +1,5 @@ /* spec48.c: Spectrum 48K specific routines - Copyright (c) 1999-2007 Philip Kendall + Copyright (c) 1999-2009 Philip Kendall $Id$ @@ -97,6 +97,7 @@ periph_setup_interface2( PERIPH_PRESENT_OPTIONAL ); periph_setup_plusd( PERIPH_PRESENT_OPTIONAL ); periph_setup_beta128( PERIPH_PRESENT_OPTIONAL ); + periph_setup_fuller( PERIPH_PRESENT_OPTIONAL ); periph_update(); periph_register_beta128(); Modified: trunk/fuse/machines/tc2048.c =================================================================== --- trunk/fuse/machines/tc2048.c 2009-06-05 13:50:55 UTC (rev 4029) +++ trunk/fuse/machines/tc2048.c 2009-06-07 14:38:38 UTC (rev 4030) @@ -1,6 +1,6 @@ /* tc2048.c: Timex TC2048 specific routines Copyright (c) 1999-2005 Philip Kendall - Copyright (c) 2002-2004 Fredrick Meunier + Copyright (c) 2002-2009 Fredrick Meunier $Id$ @@ -117,6 +117,7 @@ periph_setup_interface2( PERIPH_PRESENT_OPTIONAL ); periph_setup_plusd( PERIPH_PRESENT_OPTIONAL ); periph_setup_beta128( PERIPH_PRESENT_OPTIONAL ); + periph_setup_fuller( PERIPH_PRESENT_OPTIONAL ); periph_update(); periph_register_beta128(); Modified: trunk/fuse/man/fuse.1 =================================================================== --- trunk/fuse/man/fuse.1 2009-06-05 13:50:55 UTC (rev 4029) +++ trunk/fuse/man/fuse.1 2009-06-07 14:38:38 UTC (rev 4030) @@ -273,6 +273,13 @@ 48\ kHz or up to 22\ kHz). .RE .PP +.I "\-\-fuller" +.RS +Emulate a Fuller Box interface. Same as the Peripherals Options dialog's +.I "Fuller Box" +option. +.RE +.PP .I "\-\-full\-screen" .RS Specify whether Fuse should run in full screen mode. @@ -1678,6 +1685,13 @@ connected mouse may be used. .RE .PP +.I "Fuller Box" +.RS +If this option is selected, Fuse will emulate a Fuller Box AY sound and +joystick interface. This emulation is only available for the 16k, 48k and +TC2048 machines. +.RE +.PP .I "Interface I" .RS If this option is selected, Fuse will emulate the simple Sinclair Modified: trunk/fuse/periph.c =================================================================== --- trunk/fuse/periph.c 2009-06-05 13:50:55 UTC (rev 4029) +++ trunk/fuse/periph.c 2009-06-07 14:38:38 UTC (rev 4030) @@ -1,5 +1,5 @@ /* periph.c: code for handling peripherals - Copyright (c) 2005-2007 Philip Kendall + Copyright (c) 2005-2009 Philip Kendall $Id$ @@ -29,6 +29,7 @@ #include "debugger/debugger.h" #include "event.h" +#include "fuller.h" #include "ide/divide.h" #include "ide/simpleide.h" #include "ide/zxatasp.h" @@ -322,6 +323,12 @@ /* Is the Beta 128 currently active */ int periph_beta128_active; +/* What sort of Fuller Box does the current machine have */ +periph_present fuller_present; + +/* Is the Fuller Box currently active */ +int periph_fuller_active; + int periph_setup( const periph_t *peripherals_list, size_t n ) { @@ -348,6 +355,7 @@ interface2_present = PERIPH_PRESENT_NEVER; plusd_present = PERIPH_PRESENT_NEVER; beta128_present = PERIPH_PRESENT_NEVER; + fuller_present = PERIPH_PRESENT_NEVER; return 0; } @@ -382,6 +390,11 @@ periph_register_n( beta_peripherals, beta_peripherals_count ); } +void +periph_setup_fuller( periph_present present ) { + fuller_present = present; +} + static void update_cartridge_menu( void ) { @@ -475,6 +488,17 @@ } } + switch( fuller_present ) { + case PERIPH_PRESENT_NEVER: periph_fuller_active = 0; break; + case PERIPH_PRESENT_OPTIONAL: + periph_fuller_active = settings_current.fuller; break; + case PERIPH_PRESENT_ALWAYS: periph_fuller_active = 1; break; + } + + if( periph_fuller_active ) { + periph_register_n( fuller_peripherals, fuller_peripherals_count ); + } + update_cartridge_menu(); update_ide_menu(); if1_update_menu(); Modified: trunk/fuse/periph.h =================================================================== --- trunk/fuse/periph.h 2009-06-05 13:50:55 UTC (rev 4029) +++ trunk/fuse/periph.h 2009-06-07 14:38:38 UTC (rev 4030) @@ -1,5 +1,5 @@ /* periph.h: code for handling peripherals - Copyright (c) 2004 Philip Kendall + Copyright (c) 2004-2009 Philip Kendall $Id$ @@ -98,12 +98,16 @@ /* Is the Beta 128 active */ extern int periph_beta128_active; +/* Is the Fuller Box active */ +extern int periph_fuller_active; + int periph_setup( const periph_t *peripherals_list, size_t n ); void periph_setup_kempston( periph_present present ); void periph_setup_interface1( periph_present present ); void periph_setup_interface2( periph_present present ); void periph_setup_plusd( periph_present present ); void periph_setup_beta128( periph_present present ); +void periph_setup_fuller( periph_present present ); void periph_update( void ); void periph_register_beta128( void ); Modified: trunk/fuse/settings.dat =================================================================== --- trunk/fuse/settings.dat 2009-06-05 13:50:55 UTC (rev 4029) +++ trunk/fuse/settings.dat 2009-06-07 14:38:38 UTC (rev 4030) @@ -1,5 +1,5 @@ # settings.dat: configuration options for Fuse -# Copyright (c) 2002-2008 Philip Kendall +# Copyright (c) 2002-2009 Philip Kendall # $Id$ @@ -68,6 +68,7 @@ beta128, boolean, 0 late_timings, boolean, 0 unittests, boolean, 0 +fuller, boolean, 0 sound_device, string, NULL, 'd' sound, boolean, 1 Modified: trunk/fuse/sound.cpp =================================================================== --- trunk/fuse/sound.cpp 2009-06-05 13:50:55 UTC (rev 4029) +++ trunk/fuse/sound.cpp 2009-06-07 14:38:38 UTC (rev 4030) @@ -360,7 +360,8 @@ unsigned int tone_count, noise_count; /* If no AY chip, don't produce any AY sound (!) */ - if( !machine_current->capabilities & LIBSPECTRUM_MACHINE_CAPABILITY_AY ) + if( !periph_fuller_active && + ( !machine_current->capabilities & LIBSPECTRUM_MACHINE_CAPABILITY_AY ) ) return; for( f = 0; f < machine_current->timings.tstates_per_frame; Modified: trunk/fuse/ui/options.dat =================================================================== --- trunk/fuse/ui/options.dat 2009-06-05 13:50:55 UTC (rev 4029) +++ trunk/fuse/ui/options.dat 2009-06-07 14:38:38 UTC (rev 4030) @@ -32,6 +32,7 @@ Checkbox, (K)empston joystick, joy_kempston, INPUT_KEY_k Checkbox, Kempston (m)ouse, kempston_mouse, INPUT_KEY_m Checkbox, (S)wap mouse buttons, mouse_swap_buttons, INPUT_KEY_s +Checkbox, Full(e)r Box, fuller, INPUT_KEY_e Checkbox, Inter(f)ace I, interface1, INPUT_KEY_f Checkbox, (I)nterface II, interface2, INPUT_KEY_i Checkbox, Emulate (p)rinters, printer, INPUT_KEY_p Modified: trunk/libspectrum/accessor.pl =================================================================== --- trunk/libspectrum/accessor.pl 2009-06-05 13:50:55 UTC (rev 4029) +++ trunk/libspectrum/accessor.pl 2009-06-07 14:38:38 UTC (rev 4030) @@ -1,7 +1,7 @@ #!/usr/bin/perl -w # accessor.pl: generate accessor functions -# Copyright (c) 2003-2008 Philip Kendall +# Copyright (c) 2003-2009 Philip Kendall # $Id$ @@ -27,7 +27,7 @@ print << "CODE"; /* snap_accessors.c: simple accessor functions for libspectrum_snap - Copyright (c) 2003-2008 Philip Kendall + Copyright (c) 2003-2009 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 @@ -189,6 +189,9 @@ size_t divide_pages; libspectrum_byte* divide_eprom[ 1 ]; libspectrum_byte* divide_ram[ SNAPSHOT_DIVIDE_PAGES ]; + + /* Fuller box status */ + int fuller_box_active; }; /* Initialise a libspectrum_snap structure */ Modified: trunk/libspectrum/doc/libspectrum.txt =================================================================== --- trunk/libspectrum/doc/libspectrum.txt 2009-06-05 13:50:55 UTC (rev 4029) +++ trunk/libspectrum/doc/libspectrum.txt 2009-06-07 14:38:38 UTC (rev 4030) @@ -627,6 +627,8 @@ * libspectrum_byte* divide_eprom[1] * libspectrum_byte* divide_ram[4] +* int fuller_box_active + Most of those should be fairly self-explanatory; those which may not be are: Modified: trunk/libspectrum/hacking/ChangeLog =================================================================== --- trunk/libspectrum/hacking/ChangeLog 2009-06-05 13:50:55 UTC (rev 4029) +++ trunk/libspectrum/hacking/ChangeLog 2009-06-07 14:38:38 UTC (rev 4030) @@ -721,3 +721,6 @@ 20090411 libspectrum.h.in: export new end of tape flag. 20090509 tape_block.c: handle querying the block length for turbo and pure data blocks with 0 length (Fred). +20090608 accessor.pl,doc/libspectrum.txt,libspectrum.c,snap_accessors.txt, + snapshot.c,szx.c,z80.c: add support for the Fuller Box in snapshots + (Fred). Modified: trunk/libspectrum/libspectrum.c =================================================================== --- trunk/libspectrum/libspectrum.c 2009-06-05 13:50:55 UTC (rev 4029) +++ trunk/libspectrum/libspectrum.c 2009-06-07 14:38:38 UTC (rev 4030) @@ -1,5 +1,5 @@ /* libspectrum.c: Some general routines - Copyright (c) 2001-2004 Philip Kendall, Darren Salt, Fredrick Meunier + Copyright (c) 2001-2009 Philip Kendall, Darren Salt, Fredrick Meunier $Id$ @@ -347,7 +347,7 @@ break; } - /* TRDOS-style disk */ + /* Built-in TRDOS-style disk */ switch( type ) { case LIBSPECTRUM_MACHINE_PENT: case LIBSPECTRUM_MACHINE_PENT512: case LIBSPECTRUM_MACHINE_PENT1024: Modified: trunk/libspectrum/snap_accessors.txt =================================================================== --- trunk/libspectrum/snap_accessors.txt 2009-06-05 13:50:55 UTC (rev 4029) +++ trunk/libspectrum/snap_accessors.txt 2009-06-07 14:38:38 UTC (rev 4030) @@ -1,5 +1,5 @@ # snap_accessors.txt: simple accessors for libspectrum_snap -# Copyright (c) 2003-2008 Philip Kendall +# Copyright (c) 2003-2009 Philip Kendall # $Id$ @@ -144,3 +144,5 @@ size_t divide_pages libspectrum_byte* divide_eprom 1 libspectrum_byte* divide_ram 1 + +int fuller_box_active Modified: trunk/libspectrum/snapshot.c =================================================================== --- trunk/libspectrum/snapshot.c 2009-06-05 13:50:55 UTC (rev 4029) +++ trunk/libspectrum/snapshot.c 2009-06-07 14:38:38 UTC (rev 4030) @@ -1,5 +1,5 @@ /* snapshot.c: Snapshot handling routines - Copyright (c) 2001-2008 Philip Kendall, Darren Salt + Copyright (c) 2001-2009 Philip Kendall, Darren Salt $Id$ @@ -182,6 +182,8 @@ libspectrum_snap_set_divide_ram( snap, i, NULL ); } + libspectrum_snap_set_fuller_box_active( snap, 0 ); + return snap; } Modified: trunk/libspectrum/szx.c =================================================================== --- trunk/libspectrum/szx.c 2009-06-05 13:50:55 UTC (rev 4029) +++ trunk/libspectrum/szx.c 2009-06-07 14:38:38 UTC (rev 4030) @@ -1,5 +1,5 @@ /* szx.c: Routines for .szx snapshots - Copyright (c) 1998-2008 Philip Kendall, Fredrick Meunier, Stuart Brady + Copyright (c) 1998-2009 Philip Kendall, Fredrick Meunier, Stuart Brady $Id$ @@ -71,6 +71,9 @@ static const libspectrum_word ZXSTRF_COMPRESSED = 1; #define ZXSTBID_AY "AY\0\0" +static const libspectrum_byte ZXSTAYF_FULLERBOX = 1; +static const libspectrum_byte ZXSTAYF_128AY = 2; + #define ZXSTBID_MULTIFACE "MFCE" #define ZXSTBID_USPEECH "USPE" #define ZXSTBID_SPECDRUM "DRUM" @@ -367,6 +370,7 @@ const libspectrum_byte *end GCC_UNUSED, size_t data_length ) { size_t i; + libspectrum_byte flags; if( data_length != 18 ) { libspectrum_print_error( LIBSPECTRUM_ERROR_UNKNOWN, @@ -375,7 +379,8 @@ return LIBSPECTRUM_ERROR_UNKNOWN; } - (*buffer)++; /* Skip the flags */ + flags = **buffer; (*buffer)++; + libspectrum_snap_set_fuller_box_active( snap, flags & ZXSTAYF_FULLERBOX ); libspectrum_snap_set_out_ay_registerport( snap, **buffer ); (*buffer)++; @@ -1841,7 +1846,8 @@ error = write_ram_pages( buffer, &ptr, length, snap, compress ); if( error ) return error; - if( capabilities & LIBSPECTRUM_MACHINE_CAPABILITY_AY ) { + if( libspectrum_snap_fuller_box_active( snap ) || + capabilities & LIBSPECTRUM_MACHINE_CAPABILITY_AY ) { error = write_ay_chunk( buffer, &ptr, length, snap ); if( error ) return error; } @@ -2486,10 +2492,14 @@ size_t *length, libspectrum_snap *snap ) { size_t i; + libspectrum_byte flags; write_chunk_header( buffer, ptr, length, ZXSTBID_AY, 18 ); - *(*ptr)++ = '\0'; /* Flags */ + flags = 0; + if( libspectrum_snap_fuller_box_active( snap ) ) flags |= ZXSTAYF_FULLERBOX; + *(*ptr)++ = flags; + *(*ptr)++ = libspectrum_snap_out_ay_registerport( snap ); for( i = 0; i < 16; i++ ) Modified: trunk/libspectrum/z80.c =================================================================== --- trunk/libspectrum/z80.c 2009-06-05 13:50:55 UTC (rev 4029) +++ trunk/libspectrum/z80.c 2009-06-07 14:38:38 UTC (rev 4030) @@ -1,5 +1,5 @@ /* z80.c: Routines for handling .z80 snapshots - Copyright (c) 2001-2004 Philip Kendall, Darren Salt, Fredrick Meunier + Copyright (c) 2001-2009 Philip Kendall, Darren Salt, Fredrick Meunier $Id$ @@ -110,6 +110,9 @@ static libspectrum_byte slt_signature[] = "\0\0\0SLT"; static size_t slt_signature_length = 6; +/* Bits used in extended header to flag that a Fuller Box is in use */ +static const libspectrum_byte fuller_box_flags = 0x44; + static libspectrum_error read_header( const libspectrum_byte *buffer, libspectrum_snap *snap, const libspectrum_byte **data, int *version, int *compressed ); @@ -353,6 +356,10 @@ } } + if( ( extra_header[5] & fuller_box_flags ) == fuller_box_flags ) { + libspectrum_snap_set_fuller_box_active( snap, 1 ); + } + capabilities = libspectrum_machine_capabilities( libspectrum_snap_machine( snap ) ); @@ -366,7 +373,8 @@ libspectrum_snap_set_out_scld_dec( snap, extra_header[4] ); } - if( capabilities & LIBSPECTRUM_MACHINE_CAPABILITY_AY ) { + if( libspectrum_snap_fuller_box_active( snap ) || + capabilities & LIBSPECTRUM_MACHINE_CAPABILITY_AY ) { libspectrum_snap_set_out_ay_registerport( snap, extra_header[ 6] ); for( i = 0; i < 16; i++ ) { libspectrum_snap_set_ay_registers( snap, i, extra_header[ 7 + i ] ); @@ -1250,6 +1258,7 @@ size_t *length, int *flags, libspectrum_snap *snap ) { int i, bottom_16kb_ram; + libspectrum_byte hardware_flag = 0; /* No special emulation features */ libspectrum_dword quarter_states; @@ -1344,11 +1353,18 @@ /* Support 16K snapshots via Spectaculator's extension; see the comment in read_header for details */ if( libspectrum_snap_machine( snap ) == LIBSPECTRUM_MACHINE_16 ) { - *(*ptr)++ = 0x80; - } else { - *(*ptr)++ = '\0'; /* No special emulation features */ + hardware_flag |= 0x80; } + /* Support Fuller Box in snapshots via Spectaculator's extension; see the + comment in read_header for details */ + if( libspectrum_snap_fuller_box_active( snap ) ) { + /* Fuller is set by having bit 2 and 6 on */ + hardware_flag |= fuller_box_flags; + } + + *(*ptr)++ = hardware_flag; + *(*ptr)++ = libspectrum_snap_out_ay_registerport( snap ); for( i = 0; i < 16; i++ ) *(*ptr)++ = libspectrum_snap_ay_registers( snap, i ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |