2002-05-13 19:14:17 +00:00
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// SSSS tt lll lll
|
|
|
|
// SS SS tt ll ll
|
|
|
|
// SS tttttt eeee ll ll aaaa
|
|
|
|
// SSSS tt ee ee ll ll aa
|
|
|
|
// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
|
|
|
|
// SS SS tt ee ll ll aa aa
|
|
|
|
// SSSS ttt eeeee llll llll aaaaa
|
|
|
|
//
|
2009-01-01 18:13:40 +00:00
|
|
|
// Copyright (c) 1995-2009 by Bradford W. Mott and the Stella team
|
2002-05-13 19:14:17 +00:00
|
|
|
//
|
|
|
|
// See the file "license" for information on usage and redistribution of
|
|
|
|
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
|
|
|
//
|
2009-05-13 13:55:40 +00:00
|
|
|
// $Id$
|
2002-05-13 19:14:17 +00:00
|
|
|
//============================================================================
|
|
|
|
|
|
|
|
#include "Serializer.hxx"
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
Serializer::Serializer(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
Serializer::~Serializer(void)
|
|
|
|
{
|
|
|
|
close();
|
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2005-05-25 17:17:38 +00:00
|
|
|
bool Serializer::open(const string& fileName)
|
2002-05-13 19:14:17 +00:00
|
|
|
{
|
|
|
|
close();
|
2005-12-17 22:48:24 +00:00
|
|
|
myStream.open(fileName.c_str(), ios::out | ios::binary);
|
2002-05-13 19:14:17 +00:00
|
|
|
|
2005-12-09 19:09:49 +00:00
|
|
|
return isOpen();
|
2002-05-13 19:14:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
void Serializer::close(void)
|
|
|
|
{
|
2005-12-17 22:48:24 +00:00
|
|
|
myStream.close();
|
2005-12-29 21:16:28 +00:00
|
|
|
myStream.clear();
|
2002-05-13 19:14:17 +00:00
|
|
|
}
|
|
|
|
|
2005-12-09 19:09:49 +00:00
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
bool Serializer::isOpen(void)
|
|
|
|
{
|
2005-12-17 22:48:24 +00:00
|
|
|
return myStream.is_open();
|
2005-12-09 19:09:49 +00:00
|
|
|
}
|
|
|
|
|
OK, another huge commit. I need to commit this now, because things are
starting to go out of sync on my development machines. OK, where to
begin ...
Changed state file format, so older state files will no longer work. The
changes aren't finalized yet, so expect more breakage.
Added getByte() and putByte() methods to serialized data, resulting in
smaller state files (previously, 1-byte values were stored as 4-byte ints).
Totally reworked controller handling code. Controller state is now
explicitly set with an ::update() method, making it easier to serialize.
Some work is still required on the serialization stuff for more advanced
controllers.
Added a 'Serializable' interface to all carts, device, controllers, etc
that can be (de)serialized. This fixes a long-standing design issue
which I personally caused many years ago.
Console switches state (SWCHB register) is now saved to state files.
Added beginnings of movie support. Basically, this saves an initial
state file, and thereafter continuously saves controller and console
switches state. Support is still somewhat rough and there's no UI for
it, but it does successfully save and later load/play state movies.
Removed specific events for driving controllers, and have them use
joystick events instead. This has the nice side effect that
joystick direction remapping 'just works' for driving controllers too.
Fixed issues with paddle emulation seen in 'Night Driver' ROM. Related
to this, removed a hack wrt paddles when grabmouse is enabled. There's
still some work to do when using the mouse to emulate paddles, but the
Stelladaptor and real paddles work fine.
Added beginnings of TrackBall CX-22 controller emulation. It doesn't
actually do anything yet, but the class is there :)
Probably some other stuff that I'm forgetting ...
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1385 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2007-10-03 21:41:19 +00:00
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
void Serializer::putByte(char value)
|
|
|
|
{
|
|
|
|
char buf[1];
|
|
|
|
buf[0] = value;
|
|
|
|
myStream.write(buf, 1);
|
|
|
|
if(myStream.bad())
|
|
|
|
throw "Serializer: file write failed";
|
|
|
|
}
|
|
|
|
|
2002-05-13 19:14:17 +00:00
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2005-12-17 01:23:07 +00:00
|
|
|
void Serializer::putInt(int value)
|
2002-05-13 19:14:17 +00:00
|
|
|
{
|
2005-12-17 01:23:07 +00:00
|
|
|
unsigned char buf[4];
|
|
|
|
for(int i = 0; i < 4; ++i)
|
|
|
|
buf[i] = (value >> (i<<3)) & 0xff;
|
|
|
|
|
2005-12-17 22:48:24 +00:00
|
|
|
myStream.write((char*)buf, 4);
|
|
|
|
if(myStream.bad())
|
2002-05-13 19:14:17 +00:00
|
|
|
throw "Serializer: file write failed";
|
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
- Major changes across the board with respect to sound. The sound code
has basically been reverted to 1.2 functionality. The good news is that
the video and audio are always in sync, even in Windows. The bad news
is that we've lost advanced sound in Pitfall2. I know what's required to
fix it, but I'm seriously considering doing a new release and waiting
until the release after that to fix it. Right now (with release 1.3),
most games have laggy sound, even under Linux, but the background music
in Pitfall2 is there. I'd rather do a new release with Pitfall2 not
completely working, but having everything else working great, than wait
another month or two. I'm sure most people will agree ...
- The Windows port has some slight popping every now and then. Damn, I
really hate Windows sound programming. It just can't handle low-latency
sound generation as well as Linux (shameless plug).
- Added options '-fragsize' and '-bufsize', which set the sound fragment
and buffer sizes, respectively. They're currently set to 512 and 1536,
and this seems to work best.
- Fixed an error in calling 'putenv' in mainSDL. Now the Windows port
actually starts with the game window centered.
- Finally, IMHO (baring Pitfall2) Stella now works better wrt A/V sync
on Linux than z26 does on Windows (a bit of friendly competition :)
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@232 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2004-04-04 02:03:15 +00:00
|
|
|
void Serializer::putString(const string& str)
|
2002-05-13 19:14:17 +00:00
|
|
|
{
|
|
|
|
int len = str.length();
|
2005-12-17 01:23:07 +00:00
|
|
|
putInt(len);
|
2005-12-17 22:48:24 +00:00
|
|
|
myStream.write(str.data(), (streamsize)len);
|
2002-05-13 19:14:17 +00:00
|
|
|
|
2005-12-17 22:48:24 +00:00
|
|
|
if(myStream.bad())
|
2002-05-13 19:14:17 +00:00
|
|
|
throw "Serializer: file write failed";
|
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
void Serializer::putBool(bool b)
|
|
|
|
{
|
OK, another huge commit. I need to commit this now, because things are
starting to go out of sync on my development machines. OK, where to
begin ...
Changed state file format, so older state files will no longer work. The
changes aren't finalized yet, so expect more breakage.
Added getByte() and putByte() methods to serialized data, resulting in
smaller state files (previously, 1-byte values were stored as 4-byte ints).
Totally reworked controller handling code. Controller state is now
explicitly set with an ::update() method, making it easier to serialize.
Some work is still required on the serialization stuff for more advanced
controllers.
Added a 'Serializable' interface to all carts, device, controllers, etc
that can be (de)serialized. This fixes a long-standing design issue
which I personally caused many years ago.
Console switches state (SWCHB register) is now saved to state files.
Added beginnings of movie support. Basically, this saves an initial
state file, and thereafter continuously saves controller and console
switches state. Support is still somewhat rough and there's no UI for
it, but it does successfully save and later load/play state movies.
Removed specific events for driving controllers, and have them use
joystick events instead. This has the nice side effect that
joystick direction remapping 'just works' for driving controllers too.
Fixed issues with paddle emulation seen in 'Night Driver' ROM. Related
to this, removed a hack wrt paddles when grabmouse is enabled. There's
still some work to do when using the mouse to emulate paddles, but the
Stelladaptor and real paddles work fine.
Added beginnings of TrackBall CX-22 controller emulation. It doesn't
actually do anything yet, but the class is there :)
Probably some other stuff that I'm forgetting ...
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1385 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2007-10-03 21:41:19 +00:00
|
|
|
putByte(b ? TruePattern: FalsePattern);
|
2002-05-13 19:14:17 +00:00
|
|
|
}
|