~ubuntu-branches/debian/squeeze/stella/squeeze

« back to all changes in this revision

Viewing changes to src/emucore/m6502/src/System.hxx

  • Committer: Bazaar Package Importer
  • Author(s): Mario Iseli
  • Date: 2006-04-08 18:38:25 UTC
  • mfrom: (1.1.2 upstream) (2.1.1 etch)
  • Revision ID: james.westby@ubuntu.com-20060408183825-vu1jk57rk929derx
* New Maintainer (Closes: #361345)
* New upstream release (Closes: #349725)
* Build-Depend now on libslang2-dev (Closes: #325577)
* Complete rebuild of debian/, upgraded to policy-standards
  3.6.2 and compat-level 5.
* Removed stellarc since stella only reads ~/.stellarc and even
  works without a first config.
* New debian/watch file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
8
8
// MM     MM 66  66 55  55 00  00 22
9
9
// MM     MM  6666   5555   0000  222222
10
10
//
11
 
// Copyright (c) 1995-2002 by Bradford W. Mott
 
11
// Copyright (c) 1995-2005 by Bradford W. Mott and the Stella team
12
12
//
13
13
// See the file "license" for information on usage and redistribution of
14
14
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
15
15
//
16
 
// $Id: System.hxx,v 1.3 2002/05/13 19:10:25 stephena Exp $
 
16
// $Id: System.hxx,v 1.14 2006/02/10 13:14:20 stephena Exp $
17
17
//============================================================================
18
18
 
19
19
#ifndef SYSTEM_HXX
21
21
 
22
22
class Device;
23
23
class M6502;
 
24
class TIA;
24
25
class NullDevice;
25
26
class Serializer;
26
27
class Deserializer;
46
47
        dynamic code for that page of memory.
47
48
 
48
49
  @author  Bradford W. Mott
49
 
  @version $Id: System.hxx,v 1.3 2002/05/13 19:10:25 stephena Exp $
 
50
  @version $Id: System.hxx,v 1.14 2006/02/10 13:14:20 stephena Exp $
50
51
*/
51
52
class System
52
53
{
106
107
    void attach(M6502* m6502);
107
108
 
108
109
    /**
 
110
      Attach the specified TIA device and claim ownership of it.  The device 
 
111
      will be asked to install itself.
 
112
 
 
113
      @param tia The TIA device to attach to the system
 
114
    */
 
115
    void attach(TIA* tia);
 
116
 
 
117
    /**
109
118
      Saves the current state of Stella to the given file.  Calls
110
119
      save on every device and CPU attached to this system.
111
120
 
112
 
      @param out The serializer device to save to.
113
 
      @return The result of the save.  Error codes as follows:
114
 
              1  success
115
 
              2  file could not be opened for read/write
116
 
              3  invalid state file
 
121
      @param md5sum   MD5 of the current ROM
 
122
      @param out      The serializer device to save to
 
123
 
 
124
      @return  False on any errors, else true
117
125
    */
118
 
    int saveState(string& fileName, string& md5sum);
 
126
    bool saveState(const string& md5sum, Serializer& out);
119
127
 
120
128
    /**
121
129
      Loads the current state of Stella from the given file.  Calls
122
130
      load on every device and CPU attached to this system.
123
131
 
124
 
      @param in The deserializer device to load from.
125
 
      @return The result of the load.  Error codes as follows:
126
 
              1  success
127
 
              2  file could not be opened for read/write
128
 
              3  invalid state file
 
132
      @param md5sum   MD5 of the current ROM
 
133
      @param in       The deserializer device to load from
 
134
 
 
135
      @return  False on any errors, else true
129
136
    */
130
 
    int loadState(string& fileName, string& md5sum);
 
137
    bool loadState(const string& md5sum, Deserializer& in);
131
138
 
132
139
  public:
133
140
    /**
142
149
    }
143
150
 
144
151
    /**
 
152
      Answer the TIA device attached to the system.
 
153
 
 
154
      @return The attached TIA device
 
155
    */
 
156
    TIA& tia()
 
157
    {
 
158
      return *myTIA;
 
159
    }
 
160
 
 
161
    /**
145
162
      Get the null device associated with the system.  Every system 
146
163
      has a null device associated with it that's used by pages which 
147
164
      aren't mapped to "real" devices.
241
258
    */
242
259
    void poke(uInt16 address, uInt8 value);
243
260
 
 
261
    /**
 
262
      Lock/unlock the data bus. When the bus is locked, peek() and
 
263
      poke() don't update the bus state. The bus should be unlocked
 
264
      while the CPU is running (normal emulation, or when the debugger
 
265
      is stepping/advancing). It should be locked while the debugger
 
266
      is active but not running the CPU. This is so the debugger can
 
267
      use System.peek() to examine memory/registers without changing
 
268
      the state of the system.
 
269
    */
 
270
    void lockDataBus();
 
271
    void unlockDataBus();
 
272
 
244
273
  public:
245
274
    /**
246
275
      Structure used to specify access methods for a page
311
340
    // 6502 processor attached to the system or the null pointer
312
341
    M6502* myM6502;
313
342
 
 
343
    // TIA device attached to the system or the null pointer
 
344
    TIA* myTIA;
 
345
 
314
346
    // Number of system cycles executed since the last reset
315
347
    uInt32 myCycles;
316
348
 
320
352
    // The current state of the Data Bus
321
353
    uInt8 myDataBusState;
322
354
 
323
 
    // The serializer for the system.  Used to save state.
324
 
    Serializer* serializer;
325
 
 
326
 
    // The deserializer for the system.  Used to load state.
327
 
    Deserializer* deserializer;
 
355
    // Whether or not peek() updates the data bus state. This
 
356
    // is true during normal emulation, and false when the
 
357
    // debugger is active.
 
358
    bool myDataBusLocked;
328
359
 
329
360
  private:
330
361
    // Copy constructor isn't supported by this class so make it private
340
371
  return myDataBusState;
341
372
}
342
373
 
343
 
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
344
 
inline uInt8 System::peek(uInt16 addr)
345
 
{
346
 
  PageAccess& access = myPageAccessTable[(addr & myAddressMask) >> myPageShift];
347
 
 
348
 
  uInt8 result;
349
 
 
350
 
  // See if this page uses direct accessing or not 
351
 
  if(access.directPeekBase != 0)
352
 
  {
353
 
    result = *(access.directPeekBase + (addr & myPageMask));
354
 
  }
355
 
  else
356
 
  {
357
 
    result = access.device->peek(addr);
358
 
  }
359
 
 
360
 
  myDataBusState = result;
361
 
 
362
 
  return result;
363
 
}
364
 
 
365
 
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
366
 
inline void System::poke(uInt16 addr, uInt8 value)
367
 
{
368
 
  PageAccess& access = myPageAccessTable[(addr & myAddressMask) >> myPageShift];
369
 
  
370
 
  // See if this page uses direct accessing or not 
371
 
  if(access.directPokeBase != 0)
372
 
  {
373
 
    *(access.directPokeBase + (addr & myPageMask)) = value;
374
 
  }
375
 
  else
376
 
  {
377
 
    access.device->poke(addr, value);
378
 
  }
379
 
 
380
 
  myDataBusState = value;
381
 
}
382
374
#endif