Reply 100 of 227, by tikalat
Have another patch for cdrom cdda.
Ex. Play Gobliiins 1/2 CD. Hit dosbox load state while intro playing. Wrong cdda track keeps playing as BGM in normal game.
(ykhwong svn-daum 2012-02-20)
dos/dos_mscdex.cpp
(add to end of file)
#include "../save_state.h"
//save state support
namespace
{
class SerializeCdrom : public SerializeGlobalPOD
{
public:
SerializeCdrom() : SerializeGlobalPOD("Cdrom")
{
}
private:
virtual void getBytes(std::ostream& stream)
{
//writePOD(stream, xms_callback);
SerializeGlobalPOD::getBytes(stream);
for (Bit8u drive_unit=0; drive_unit<mscdex->GetNumDrives(); drive_unit++) {
TMSF pos, start, end;
bool playing, pause;
mscdex->GetAudioStatus(drive_unit, playing, pause, start, end);
mscdex->GetCurrentPos(drive_unit,pos);
stream.write(reinterpret_cast<const char*>( &playing ), sizeof(playing) );
stream.write(reinterpret_cast<const char*>( &pause ), sizeof(pause) );
stream.write(reinterpret_cast<const char*>( &pos ), sizeof(pos) );
stream.write(reinterpret_cast<const char*>( &start ), sizeof(start) );
stream.write(reinterpret_cast<const char*>( &end ), sizeof(end) );
}
}
virtual void setBytes(std::istream& stream)
{
//readPOD(stream, xms_callback);
SerializeGlobalPOD::setBytes(stream);
for (Bit8u drive_unit=0; drive_unit<mscdex->GetNumDrives(); drive_unit++) {
TMSF pos, start, end;
Bit32u msf_time, play_len;
bool playing, pause;
mscdex->StopAudio(drive_unit);
stream.read(reinterpret_cast<char*>( &playing ), sizeof(playing) );
stream.read(reinterpret_cast<char*>( &pause ), sizeof(pause) );
stream.read(reinterpret_cast<char*>( &pos ), sizeof(pos) );
stream.read(reinterpret_cast<char*>( &start ), sizeof(start) );
stream.read(reinterpret_cast<char*>( &end ), sizeof(end) );
msf_time = ( pos.min << 16 ) + ( pos.sec << 8 ) + ( pos.fr );
// end = total play time (GetAudioStatus adds +150)
// pos = current play cursor
// start = start play cursor
play_len = end.min * 75 * 60 + ( end.sec * 75 ) + end.fr - 150;
play_len -= ( pos.min - start.min ) * 75 * 60 + ( pos.sec - start.sec ) * 75 + ( pos.fr - start.fr );
// first play, then simulate pause
if( playing ) mscdex->PlayAudioMSF(drive_unit, msf_time, play_len);
if( pause ) mscdex->PlayAudioMSF(drive_unit, msf_time, 0);
}
}
} dummy;
}
===============================
===============================
===============================
Thanks for the feedback. 😀
Currently I have this change for vga mode switching:
vga_memory.cpp
private:
virtual void getBytes(std::ostream& stream)
{
SerializeGlobalPOD::getBytes(stream);
stream.write(reinterpret_cast<const char*>(vga.mem.linear_orgptr), sizeof(Bit8u) * (std::max<Bit32u>(vga.vmemsize, 512 * 1024U) + 2048 + 16));
stream.write(reinterpret_cast<const char*>(vga.fastmem_orgptr), sizeof(Bit8u) * ((vga.vmemsize << 1) + 4096 + 16));
stream.write(reinterpret_cast<const char*>( &vga.mode ), sizeof(vga.mode) );
stream.write(reinterpret_cast<const char*>( &vga.draw.height ), sizeof(vga.draw.height) );
stream.write(reinterpret_cast<const char*>( &vga.draw.width ), sizeof(vga.draw.width) );
stream.write(reinterpret_cast<const char*>( &vga.misc_output ), sizeof(vga.misc_output) );
stream.write(reinterpret_cast<const char*>( &vga.crtc.maximum_scan_line ), sizeof(vga.crtc.maximum_scan_line) );
stream.write(reinterpret_cast<const char*>( &vga.config.scan_len ), sizeof(vga.config.scan_len) );
}
virtual void setBytes(std::istream& stream)
{
SerializeGlobalPOD::setBytes(stream);
stream.read(reinterpret_cast<char*>(vga.mem.linear_orgptr), sizeof(Bit8u) * (std::max<Bit32u>(vga.vmemsize, 512 * 1024U) + 2048 + 16));
stream.read(reinterpret_cast<char*>(vga.fastmem_orgptr), sizeof(Bit8u) * ((vga.vmemsize << 1) + 4096 + 16));
stream.read(reinterpret_cast<char*>( &vga.mode ), sizeof(vga.mode) );
stream.read(reinterpret_cast<char*>( &vga.draw.height ), sizeof(vga.draw.height) );
stream.read(reinterpret_cast<char*>( &vga.draw.width ), sizeof(vga.draw.width) );
stream.read(reinterpret_cast<char*>( &vga.misc_output ), sizeof(vga.misc_output) );
stream.read(reinterpret_cast<char*>( &vga.crtc.maximum_scan_line ), sizeof(vga.crtc.maximum_scan_line) );
stream.read(reinterpret_cast<char*>( &vga.config.scan_len ), sizeof(vga.config.scan_len) );
extern void VGA_SetupDrawing(Bitu /*val*/);
VGA_SetupDrawing(0);
}
It's not done yet because it doesn't fully work with Lemmings 2 - menus vs in-game modes not totally restored. But much better than what it used to display (no weird stripes).
Probably missing another state POD somewhere.
If you have an example game with palette load corruption, please mention the specifics. Maybe I can assist in sorting it out. 😉
(I've only tested palette with Gobliiins / Lemmings mostly)
I also have a WIP patch for dos_files (ex. saving in the middle of Syndicate Wars streaming smk movies). Need to diff it out and clean it up first though.