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

« back to all changes in this revision

Viewing changes to src/emucore/Cart3E.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: Cart3E.cxx 2318 2011-12-31 21:56:36Z stephena $
 
17
// $Id: Cart3E.cxx 2499 2012-05-25 12:41:19Z stephena $
18
18
//============================================================================
19
19
 
20
20
#include <cassert>
58
58
  // Initialize RAM
59
59
  if(mySettings.getBool("ramrandom"))
60
60
    for(uInt32 i = 0; i < 32768; ++i)
61
 
      myRam[i] = mySystem->randGenerator().next();
 
61
      myRAM[i] = mySystem->randGenerator().next();
62
62
  else
63
 
    memset(myRam, 0, 32768);
 
63
    memset(myRAM, 0, 32768);
64
64
 
65
65
  // We'll map the startup bank into the first segment upon reset
66
66
  bank(myStartBank);
111
111
    else
112
112
    {
113
113
      if(address < 0x0400)
114
 
        return myRam[(address & 0x03FF) + ((myCurrentBank - 256) << 10)];
 
114
        return myRAM[(address & 0x03FF) + ((myCurrentBank - 256) << 10)];
115
115
      else
116
116
      {
117
117
        // Reading from the write port triggers an unwanted write
122
122
        else
123
123
        {
124
124
          triggerReadFromWritePort(peekAddress);
125
 
          return myRam[(address & 0x03FF) + ((myCurrentBank - 256) << 10)] = value;
 
125
          return myRAM[(address & 0x03FF) + ((myCurrentBank - 256) << 10)] = value;
126
126
        }
127
127
      }
128
128
    }
207
207
    // Map read-port RAM image into the system
208
208
    for(address = 0x1000; address < 0x1400; address += (1 << shift))
209
209
    {
210
 
      access.directPeekBase = &myRam[offset + (address & 0x03FF)];
 
210
      access.directPeekBase = &myRAM[offset + (address & 0x03FF)];
211
211
      access.codeAccessBase = &myCodeAccessBase[mySize + offset + (address & 0x03FF)];
212
212
      mySystem->setPageAccess(address >> shift, access);
213
213
    }
218
218
    // Map write-port RAM image into the system
219
219
    for(address = 0x1400; address < 0x1800; address += (1 << shift))
220
220
    {
221
 
      access.directPokeBase = &myRam[offset + (address & 0x03FF)];
 
221
      access.directPokeBase = &myRAM[offset + (address & 0x03FF)];
222
222
      access.codeAccessBase = &myCodeAccessBase[mySize + offset + (address & 0x03FF)];
223
223
      mySystem->setPageAccess(address >> shift, access);
224
224
    }
253
253
    if(myCurrentBank < 256)
254
254
      myImage[(address & 0x07FF) + (myCurrentBank << 11)] = value;
255
255
    else
256
 
      myRam[(address & 0x03FF) + ((myCurrentBank - 256) << 10)] = value;
 
256
      myRAM[(address & 0x03FF) + ((myCurrentBank - 256) << 10)] = value;
257
257
  }
258
258
  else
259
259
    myImage[(address & 0x07FF) + mySize - 2048] = value;
274
274
  try
275
275
  {
276
276
    out.putString(name());
277
 
    out.putInt(myCurrentBank);
278
 
 
279
 
    // Output RAM
280
 
    out.putInt(32768);
281
 
    for(uInt32 addr = 0; addr < 32768; ++addr)
282
 
      out.putByte((char)myRam[addr]);
 
277
    out.putShort(myCurrentBank);
 
278
    out.putByteArray(myRAM, 32768);
283
279
  }
284
 
  catch(const char* msg)
 
280
  catch(...)
285
281
  {
286
 
    cerr << "ERROR: Cartridge3E::save" << endl << "  " << msg << endl;
 
282
    cerr << "ERROR: Cartridge3E::save" << endl;
287
283
    return false;
288
284
  }
289
285
 
298
294
    if(in.getString() != name())
299
295
      return false;
300
296
 
301
 
    myCurrentBank = (uInt16) in.getInt();
302
 
 
303
 
    // Input RAM
304
 
    uInt32 limit = (uInt32) in.getInt();
305
 
    for(uInt32 addr = 0; addr < limit; ++addr)
306
 
      myRam[addr] = (uInt8) in.getByte();
 
297
    myCurrentBank = in.getShort();
 
298
    in.getByteArray(myRAM, 32768);
307
299
  }
308
 
  catch(const char* msg)
 
300
  catch(...)
309
301
  {
310
 
    cerr << "ERROR: Cartridge3E::load" << endl << "  " << msg << endl;
 
302
    cerr << "ERROR: Cartridge3E::load" << endl;
311
303
    return false;
312
304
  }
313
305