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

« back to all changes in this revision

Viewing changes to src/emucore/CartF8SC.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: CartF8SC.cxx,v 1.3 2002/05/14 15:22:28 stephena Exp $
 
16
// $Id: CartF8SC.cxx,v 1.9 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();
106
106
{
107
107
  address = address & 0x0FFF;
108
108
 
109
 
  // Switch banks if necessary
110
 
  switch(address)
111
 
  {
112
 
    case 0x0FF8:
113
 
      // Set the current bank to the lower 4k bank
114
 
      bank(0);
115
 
      break;
116
 
 
117
 
    case 0x0FF9:
118
 
      // Set the current bank to the upper 4k bank
119
 
      bank(1);
120
 
      break;
121
 
 
122
 
    default:
123
 
      break;
 
109
  if(!bankLocked) {
 
110
    // Switch banks if necessary
 
111
    switch(address)
 
112
    {
 
113
      case 0x0FF8:
 
114
        // Set the current bank to the lower 4k bank
 
115
        bank(0);
 
116
        break;
 
117
  
 
118
      case 0x0FF9:
 
119
        // Set the current bank to the upper 4k bank
 
120
        bank(1);
 
121
        break;
 
122
  
 
123
      default:
 
124
        break;
 
125
    }
124
126
  }
125
127
 
126
128
  // NOTE: This does not handle accessing RAM, however, this function
134
136
{
135
137
  address = address & 0x0FFF;
136
138
 
137
 
  // Switch banks if necessary
138
 
  switch(address)
139
 
  {
140
 
    case 0x0FF8:
141
 
      // Set the current bank to the lower 4k bank
142
 
      bank(0);
143
 
      break;
144
 
 
145
 
    case 0x0FF9:
146
 
      // Set the current bank to the upper 4k bank
147
 
      bank(1);
148
 
      break;
149
 
 
150
 
    default:
151
 
      break;
 
139
  if(!bankLocked) {
 
140
    // Switch banks if necessary
 
141
    switch(address)
 
142
    {
 
143
      case 0x0FF8:
 
144
        // Set the current bank to the lower 4k bank
 
145
        bank(0);
 
146
        break;
 
147
  
 
148
      case 0x0FF9:
 
149
        // Set the current bank to the upper 4k bank
 
150
        bank(1);
 
151
        break;
 
152
  
 
153
      default:
 
154
        break;
 
155
    }
152
156
  }
153
157
 
154
158
  // NOTE: This does not handle accessing RAM, however, this function
157
161
}
158
162
 
159
163
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
164
int CartridgeF8SC::bank() {
 
165
  return myCurrentBank;
 
166
}
 
167
 
 
168
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
169
int CartridgeF8SC::bankCount() {
 
170
  return 2;
 
171
}
 
172
 
 
173
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
174
bool CartridgeF8SC::patch(uInt16 address, uInt8 value)
 
175
{
 
176
        address = address & 0x0FFF;
 
177
        myImage[myCurrentBank * 4096 + address] = value;
 
178
        return true;
 
179
 
180
 
 
181
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
160
182
void CartridgeF8SC::bank(uInt16 bank)
161
183
162
184
  // Remember what bank we're in
188
210
  {
189
211
    out.putString(cart);
190
212
 
191
 
    out.putLong(myCurrentBank);
 
213
    out.putInt(myCurrentBank);
192
214
 
193
215
    // The 128 bytes of RAM
194
 
    out.putLong(128);
 
216
    out.putInt(128);
195
217
    for(uInt32 i = 0; i < 128; ++i)
196
 
      out.putLong(myRAM[i]);
 
218
      out.putInt(myRAM[i]);
197
219
  }
198
220
  catch(char *msg)
199
221
  {
219
241
    if(in.getString() != cart)
220
242
      return false;
221
243
 
222
 
    myCurrentBank = (uInt16) in.getLong();
 
244
    myCurrentBank = (uInt16) in.getInt();
223
245
 
224
 
    uInt32 limit = (uInt32) in.getLong();
 
246
    uInt32 limit = (uInt32) in.getInt();
225
247
    for(uInt32 i = 0; i < limit; ++i)
226
 
      myRAM[i] = (uInt8) in.getLong();
 
248
      myRAM[i] = (uInt8) in.getInt();
227
249
  }
228
250
  catch(char *msg)
229
251
  {
241
263
 
242
264
  return true;
243
265
}
 
266
 
 
267
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
268
uInt8* CartridgeF8SC::getImage(int& size) {
 
269
  size = 8192;
 
270
  return &myImage[0];
 
271
}