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

« back to all changes in this revision

Viewing changes to src/emucore/M6532.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: M6532.cxx 2412 2012-03-14 01:19:23Z stephena $
 
17
// $Id: M6532.cxx 2499 2012-05-25 12:41:19Z stephena $
18
18
//============================================================================
19
19
 
20
20
#include <cassert>
272
272
      if(DDR bit is input)       set output as 1
273
273
      else if(DDR bit is output) set output as bit in ORA
274
274
  */
275
 
  uInt8 a = myOutA | ~myDDRA;
276
 
 
277
275
  Controller& port0 = myConsole.controller(Controller::Left);
278
 
  port0.write(Controller::One, a & 0x10);
279
 
  port0.write(Controller::Two, a & 0x20);
280
 
  port0.write(Controller::Three, a & 0x40);
281
 
  port0.write(Controller::Four, a & 0x80);
282
 
 
283
276
  Controller& port1 = myConsole.controller(Controller::Right);
284
 
  port1.write(Controller::One, a & 0x01);
285
 
  port1.write(Controller::Two, a & 0x02);
286
 
  port1.write(Controller::Three, a & 0x04);
287
 
  port1.write(Controller::Four, a & 0x08);
 
277
 
 
278
  uInt8 ioport = myOutA | ~myDDRA;
 
279
 
 
280
  port0.write(Controller::One,   ioport & 0x10);
 
281
  port0.write(Controller::Two,   ioport & 0x20);
 
282
  port0.write(Controller::Three, ioport & 0x40);
 
283
  port0.write(Controller::Four,  ioport & 0x80);
 
284
  port1.write(Controller::One,   ioport & 0x01);
 
285
  port1.write(Controller::Two,   ioport & 0x02);
 
286
  port1.write(Controller::Three, ioport & 0x04);
 
287
  port1.write(Controller::Four,  ioport & 0x08);
288
288
 
289
289
  if(swcha)
290
290
  {
291
 
    port0.controlWrite();
292
 
    port1.controlWrite();
 
291
    port0.controlWrite(ioport);
 
292
    port1.controlWrite(ioport);
293
293
  }
294
294
}
295
295
 
301
301
    out.putString(name());
302
302
 
303
303
    // Output the RAM
304
 
    out.putInt(128);
305
 
    for(uInt32 t = 0; t < 128; ++t)
306
 
      out.putByte((char)myRAM[t]);
 
304
    out.putByteArray(myRAM, 128);
307
305
 
308
306
    out.putInt(myTimer);
309
307
    out.putInt(myIntervalShift);
311
309
    out.putBool(myInterruptEnabled);
312
310
    out.putBool(myInterruptTriggered);
313
311
 
314
 
    out.putByte((char)myDDRA);
315
 
    out.putByte((char)myDDRB);
316
 
    out.putByte((char)myOutA);
317
 
    out.putByte((char)myOutB);
318
 
    out.putByte((char)myOutTimer[0]);
319
 
    out.putByte((char)myOutTimer[1]);
320
 
    out.putByte((char)myOutTimer[2]);
321
 
    out.putByte((char)myOutTimer[3]);
 
312
    out.putByte(myDDRA);
 
313
    out.putByte(myDDRB);
 
314
    out.putByte(myOutA);
 
315
    out.putByte(myOutB);
 
316
    out.putByteArray(myOutTimer, 4);
322
317
  }
323
 
  catch(const char* msg)
 
318
  catch(...)
324
319
  {
325
 
    cerr << "ERROR: M6532::save" << endl << "  " << msg << endl;
 
320
    cerr << "ERROR: M6532::save" << endl;
326
321
    return false;
327
322
  }
328
323
 
338
333
      return false;
339
334
 
340
335
    // Input the RAM
341
 
    uInt32 limit = (uInt32) in.getInt();
342
 
    for(uInt32 t = 0; t < limit; ++t)
343
 
      myRAM[t] = (uInt8) in.getByte();
 
336
    in.getByteArray(myRAM, 128);
344
337
 
345
 
    myTimer = (uInt32) in.getInt();
346
 
    myIntervalShift = (uInt32) in.getInt();
347
 
    myCyclesWhenTimerSet = (uInt32) in.getInt();
 
338
    myTimer = in.getInt();
 
339
    myIntervalShift = in.getInt();
 
340
    myCyclesWhenTimerSet = in.getInt();
348
341
    myInterruptEnabled = in.getBool();
349
342
    myInterruptTriggered = in.getBool();
350
343
 
351
 
    myDDRA = (uInt8) in.getByte();
352
 
    myDDRB = (uInt8) in.getByte();
353
 
    myOutA = (uInt8) in.getByte();
354
 
    myOutB = (uInt8) in.getByte();
355
 
    myOutTimer[0] = (uInt8) in.getByte();
356
 
    myOutTimer[1] = (uInt8) in.getByte();
357
 
    myOutTimer[2] = (uInt8) in.getByte();
358
 
    myOutTimer[3] = (uInt8) in.getByte();
 
344
    myDDRA = in.getByte();
 
345
    myDDRB = in.getByte();
 
346
    myOutA = in.getByte();
 
347
    myOutB = in.getByte();
 
348
    in.getByteArray(myOutTimer, 4);
359
349
  }
360
 
  catch(const char* msg)
 
350
  catch(...)
361
351
  {
362
 
    cerr << "ERROR: M6532::load" << endl << "  " << msg << endl;
 
352
    cerr << "ERROR: M6532::load" << endl;
363
353
    return false;
364
354
  }
365
355