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

« back to all changes in this revision

Viewing changes to src/emucore/CartF4SC.cxx

  • 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
//  SS  SS   tt   ee      ll   ll  aa  aa
9
9
//   SSSS     ttt  eeeee llll llll  aaaaa
10
10
//
11
 
// Copyright (c) 1995-1998 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: CartF4SC.cxx,v 1.3 2002/05/14 15:22:28 stephena Exp $
 
16
// $Id: CartF4SC.cxx,v 1.10 2005/12/17 01:23:07 stephena Exp $
17
17
//============================================================================
18
18
 
19
19
#include <assert.h>
34
34
  }
35
35
 
36
36
  // Initialize RAM with random values
37
 
  Random random;
 
37
  class Random random;
38
38
  for(uInt32 i = 0; i < 128; ++i)
39
39
  {
40
40
    myRAM[i] = random.next();
133
133
}
134
134
 
135
135
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
136
bool CartridgeF4SC::patch(uInt16 address, uInt8 value)
 
137
{
 
138
        address = address & 0x0FFF;
 
139
        myImage[myCurrentBank * 4096 + address] = value;
 
140
        return true;
 
141
 
142
 
 
143
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
136
144
void CartridgeF4SC::bank(uInt16 bank)
137
145
 
146
  if(bankLocked) return;
 
147
 
138
148
  // Remember what bank we're in
139
149
  myCurrentBank = bank;
140
150
  uInt16 offset = myCurrentBank * 4096;
156
166
}
157
167
 
158
168
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
169
int CartridgeF4SC::bank() {
 
170
  return myCurrentBank;
 
171
}
 
172
 
 
173
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
174
int CartridgeF4SC::bankCount() {
 
175
  return 8;
 
176
}
 
177
 
 
178
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
159
179
bool CartridgeF4SC::save(Serializer& out)
160
180
{
161
181
  string cart = name();
164
184
  {
165
185
    out.putString(cart);
166
186
 
167
 
    out.putLong(myCurrentBank);
 
187
    out.putInt(myCurrentBank);
168
188
 
169
189
    // The 128 bytes of RAM
170
 
    out.putLong(128);
 
190
    out.putInt(128);
171
191
    for(uInt32 i = 0; i < 128; ++i)
172
 
      out.putLong(myRAM[i]);
 
192
      out.putInt(myRAM[i]);
173
193
  }
174
194
  catch(char *msg)
175
195
  {
195
215
    if(in.getString() != cart)
196
216
      return false;
197
217
 
198
 
    myCurrentBank = (uInt16) in.getLong();
 
218
    myCurrentBank = (uInt16) in.getInt();
199
219
 
200
 
    uInt32 limit = (uInt32) in.getLong();
 
220
    uInt32 limit = (uInt32) in.getInt();
201
221
    for(uInt32 i = 0; i < limit; ++i)
202
 
      myRAM[i] = (uInt8) in.getLong();
 
222
      myRAM[i] = (uInt8) in.getInt();
203
223
  }
204
224
  catch(char *msg)
205
225
  {
217
237
 
218
238
  return true;
219
239
}
 
240
 
 
241
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
242
uInt8* CartridgeF4SC::getImage(int& size) {
 
243
  size = 32768;
 
244
  return &myImage[0];
 
245
}