~ubuntu-branches/debian/sid/stella/sid

« back to all changes in this revision

Viewing changes to src/emucore/CartDPCPlus.cxx

  • Committer: Package Import Robot
  • Author(s): Stephen Kitt
  • Date: 2012-06-02 07:33:16 UTC
  • mfrom: (1.1.15)
  • Revision ID: package-import@ubuntu.com-20120602073316-20r4hr32t4oj36u9
Tags: 3.7-1
* New upstream version.
* Update description and documentation with new features in 3.7, notably
  Blargg TV filters (replacing the filters available in versions 3.4.1
  and earlier).
* Switch to debhelper compatibility level 9.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
// See the file "License.txt" for information on usage and redistribution of
15
15
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
16
16
//
17
 
// $Id: CartDPCPlus.cxx 2318 2011-12-31 21:56:36Z stephena $
 
17
// $Id: CartDPCPlus.cxx 2499 2012-05-25 12:41:19Z stephena $
18
18
//============================================================================
19
19
 
20
20
#include <cassert>
41
41
  uInt32 minsize = 4096 * 6 + 4096 + 1024 + 255;
42
42
  mySize = BSPF_max(minsize, size);
43
43
  myImage = new uInt8[mySize];
44
 
  myDPCRAM = new uInt8[8192];
45
44
  memcpy(myImage, image, size);
46
45
  createCodeAccessBase(4096 * 6);
47
46
 
94
93
CartridgeDPCPlus::~CartridgeDPCPlus()
95
94
{
96
95
  delete[] myImage;
97
 
  delete[] myDPCRAM;
98
96
 
99
97
#ifdef THUMB_SUPPORT
100
98
  delete myThumbEmulator;
658
656
{
659
657
  try
660
658
  {
661
 
    uInt32 i;
662
 
 
663
659
    out.putString(name());
664
660
 
665
661
    // Indicates which bank is currently active
666
 
    out.putInt(myCurrentBank);
 
662
    out.putShort(myCurrentBank);
667
663
 
668
664
    // The top registers for the data fetchers
669
 
    out.putInt(8);
670
 
    for(i = 0; i < 8; ++i)
671
 
      out.putByte((char)myTops[i]);
 
665
    out.putByteArray(myTops, 8);
672
666
 
673
667
    // The bottom registers for the data fetchers
674
 
    out.putInt(8);
675
 
    for(i = 0; i < 8; ++i)
676
 
      out.putByte((char)myBottoms[i]);
 
668
    out.putByteArray(myBottoms, 8);
677
669
 
678
670
    // The counter registers for the data fetchers
679
 
    out.putInt(8);
680
 
    for(i = 0; i < 8; ++i)
681
 
      out.putInt(myCounters[i]);
 
671
    out.putShortArray(myCounters, 8);
682
672
 
683
673
    // The counter registers for the fractional data fetchers
684
 
    out.putInt(8);
685
 
    for(i = 0; i < 8; ++i)
686
 
      out.putInt(myFractionalCounters[i]);
 
674
    out.putIntArray(myFractionalCounters, 8);
687
675
 
688
676
    // The fractional registers for the data fetchers
689
 
    out.putInt(8);
690
 
    for(i = 0; i < 8; ++i)
691
 
      out.putByte((char)myFractionalIncrements[i]);
 
677
    out.putByteArray(myFractionalIncrements, 8);
692
678
 
693
679
    // The Fast Fetcher Enabled flag
694
680
    out.putBool(myFastFetch);
695
681
    out.putBool(myLDAimmediate);
696
682
 
697
683
    // Control Byte to update
698
 
    out.putInt(8);
699
 
    for(i = 0; i < 8; ++i)
700
 
      out.putByte((char)myParameter[i]);
 
684
    out.putByteArray(myParameter, 8);
701
685
 
702
686
    // The music counters
703
 
    out.putInt(3);
704
 
    for(i = 0; i < 3; ++i)
705
 
      out.putInt(myMusicCounters[i]);
 
687
    out.putIntArray(myMusicCounters, 3);
706
688
 
707
689
    // The music frequencies
708
 
    out.putInt(3);
709
 
    for(i = 0; i < 3; ++i)
710
 
      out.putInt(myMusicFrequencies[i]);
 
690
    out.putIntArray(myMusicFrequencies, 3);
711
691
 
712
692
    // The music waveforms
713
 
    out.putInt(3);
714
 
    for(i = 0; i < 3; ++i)
715
 
      out.putInt(myMusicWaveforms[i]);
 
693
    out.putShortArray(myMusicWaveforms, 3);
716
694
 
717
695
    // The random number generator register
718
696
    out.putInt(myRandomNumber);
720
698
    out.putInt(mySystemCycles);
721
699
    out.putInt((uInt32)(myFractionalClocks * 100000000.0));
722
700
  }
723
 
  catch(const char* msg)
 
701
  catch(...)
724
702
  {
725
 
    cerr << "ERROR: CartridgeDPCPlus::save" << endl << "  " << msg << endl;
 
703
    cerr << "ERROR: CartridgeDPCPlus::save" << endl;
726
704
    return false;
727
705
  }
728
706
 
737
715
    if(in.getString() != name())
738
716
      return false;
739
717
 
740
 
    uInt32 i, limit;
741
 
 
742
718
    // Indicates which bank is currently active
743
 
    myCurrentBank = (uInt16) in.getInt();
 
719
    myCurrentBank = in.getShort();
744
720
 
745
721
    // The top registers for the data fetchers
746
 
    limit = (uInt32) in.getInt();
747
 
    for(i = 0; i < limit; ++i)
748
 
      myTops[i] = (uInt8) in.getByte();
 
722
    in.getByteArray(myTops, 8);
749
723
 
750
724
    // The bottom registers for the data fetchers
751
 
    limit = (uInt32) in.getInt();
752
 
    for(i = 0; i < limit; ++i)
753
 
      myBottoms[i] = (uInt8) in.getByte();
 
725
    in.getByteArray(myBottoms, 8);
754
726
 
755
727
    // The counter registers for the data fetchers
756
 
    limit = (uInt32) in.getInt();
757
 
    for(i = 0; i < limit; ++i)
758
 
      myCounters[i] = (uInt16) in.getInt();
 
728
    in.getShortArray(myCounters, 8);
759
729
 
760
730
    // The counter registers for the fractional data fetchers
761
 
    limit = (uInt32) in.getInt();
762
 
    for(i = 0; i < limit; ++i)
763
 
      myFractionalCounters[i] = (uInt32) in.getInt();
 
731
    in.getIntArray(myFractionalCounters, 8);
764
732
 
765
733
    // The fractional registers for the data fetchers
766
 
    limit = (uInt32) in.getInt();
767
 
    for(i = 0; i < limit; ++i)
768
 
      myFractionalIncrements[i] = (uInt8) in.getByte();
 
734
    in.getByteArray(myFractionalIncrements, 8);
769
735
 
770
736
    // The Fast Fetcher Enabled flag
771
737
    myFastFetch = in.getBool();
772
738
    myLDAimmediate = in.getBool();
773
739
 
774
740
    // Control Byte to update
775
 
    limit = (uInt32) in.getInt();
776
 
    for(i = 0; i < limit; ++i)
777
 
      myParameter[i] = (uInt8) in.getByte();
 
741
    in.getByteArray(myParameter, 8);
778
742
 
779
743
    // The music mode counters for the data fetchers
780
 
    limit = (uInt32) in.getInt();
781
 
    for(i = 0; i < limit; ++i)
782
 
      myMusicCounters[i] = (uInt32) in.getInt();
 
744
    in.getIntArray(myMusicCounters, 3);
783
745
 
784
746
    // The music mode frequency addends for the data fetchers
785
 
    limit = (uInt32) in.getInt();
786
 
    for(i = 0; i < limit; ++i)
787
 
      myMusicFrequencies[i] = (uInt32) in.getInt();
 
747
    in.getIntArray(myMusicFrequencies, 3);
788
748
 
789
749
    // The music waveforms
790
 
    limit = (uInt32) in.getInt();
791
 
    for(i = 0; i < limit; ++i)
792
 
      myMusicWaveforms[i] = (uInt16) in.getInt();
 
750
    in.getShortArray(myMusicWaveforms, 3);
793
751
 
794
752
    // The random number generator register
795
 
    myRandomNumber = (uInt32) in.getInt();
 
753
    myRandomNumber = in.getInt();
796
754
 
797
755
    // Get system cycles and fractional clocks
798
 
    mySystemCycles = in.getInt();
 
756
    mySystemCycles = (Int32)in.getInt();
799
757
    myFractionalClocks = (double)in.getInt() / 100000000.0;
800
758
  }
801
 
  catch(const char* msg)
 
759
  catch(...)
802
760
  {
803
 
    cerr << "ERROR: CartridgeDPCPlus::load" << endl << "  " << msg << endl;
 
761
    cerr << "ERROR: CartridgeDPCPlus::load" << endl;
804
762
    return false;
805
763
  }
806
764