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

« back to all changes in this revision

Viewing changes to src/emucore/CartF6SC.cxx

  • Committer: Bazaar Package Importer
  • Author(s): Luca Falavigna, Franczen Attila, Luca Falavigna
  • Date: 2008-11-08 12:04:12 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20081108120412-w6xq87vzgokstfey
Tags: 2.6.1-0ubuntu1
[ Franczen Attila ]
* New upstream release (LP: #183571).
* Updated policy to 3.8.0.

[ Luca Falavigna ]
* debian/patches/gcc-4.3: fix FTBFS with gcc-4.3 compiler.

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-2005 by Bradford W. Mott and the Stella team
 
11
// Copyright (c) 1995-2008 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: CartF6SC.cxx,v 1.10 2005/12/17 01:23:07 stephena Exp $
 
16
// $Id: CartF6SC.cxx,v 1.16 2008/03/28 23:29:13 stephena Exp $
17
17
//============================================================================
18
18
 
19
 
#include <assert.h>
20
 
#include "CartF6SC.hxx"
 
19
#include <cassert>
 
20
 
21
21
#include "Random.hxx"
22
22
#include "System.hxx"
23
 
#include "Serializer.hxx"
24
 
#include "Deserializer.hxx"
25
 
#include <iostream>
 
23
#include "CartF6SC.hxx"
26
24
 
27
25
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
28
26
CartridgeF6SC::CartridgeF6SC(const uInt8* image)
47
45
}
48
46
 
49
47
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
50
 
const char* CartridgeF6SC::name() const
51
 
{
52
 
  return "CartridgeF6SC";
53
 
}
54
 
 
55
 
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
56
48
void CartridgeF6SC::reset()
57
49
{
58
50
  // Upon reset we switch to bank 0
177
169
}
178
170
 
179
171
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
180
 
bool CartridgeF6SC::patch(uInt16 address, uInt8 value)
181
 
{
182
 
        address = address & 0x0FFF;
183
 
        myImage[myCurrentBank * 4096 + address] = value;
184
 
        return true;
185
 
186
 
 
187
 
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
188
172
void CartridgeF6SC::bank(uInt16 bank)
189
173
190
 
  if(bankLocked) return;
 
174
  if(myBankLocked) return;
191
175
 
192
176
  // Remember what bank we're in
193
177
  myCurrentBank = bank;
210
194
}
211
195
 
212
196
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
213
 
int CartridgeF6SC::bank() {
 
197
int CartridgeF6SC::bank()
 
198
{
214
199
  return myCurrentBank;
215
200
}
216
201
 
217
202
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
218
 
int CartridgeF6SC::bankCount() {
 
203
int CartridgeF6SC::bankCount()
 
204
{
219
205
  return 4;
220
206
}
221
207
 
222
208
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
223
 
bool CartridgeF6SC::save(Serializer& out)
 
209
bool CartridgeF6SC::patch(uInt16 address, uInt8 value)
 
210
{
 
211
  address = address & 0x0FFF;
 
212
  myImage[myCurrentBank * 4096 + address] = value;
 
213
  return true;
 
214
 
215
 
 
216
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
217
uInt8* CartridgeF6SC::getImage(int& size)
 
218
{
 
219
  size = 16384;
 
220
  return &myImage[0];
 
221
}
 
222
 
 
223
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
224
bool CartridgeF6SC::save(Serializer& out) const
224
225
{
225
226
  string cart = name();
226
227
 
233
234
    // The 128 bytes of RAM
234
235
    out.putInt(128);
235
236
    for(uInt32 i = 0; i < 128; ++i)
236
 
      out.putInt(myRAM[i]);
 
237
      out.putByte((char)myRAM[i]);
237
238
 
238
239
  }
239
 
  catch(char *msg)
 
240
  catch(const char* msg)
240
241
  {
241
242
    cerr << msg << endl;
242
243
    return false;
265
266
    // The 128 bytes of RAM
266
267
    uInt32 limit = (uInt32) in.getInt();
267
268
    for(uInt32 i = 0; i < limit; ++i)
268
 
      myRAM[i] = (uInt8) in.getInt();
 
269
      myRAM[i] = (uInt8) in.getByte();
269
270
  }
270
 
  catch(char *msg)
 
271
  catch(const char* msg)
271
272
  {
272
273
    cerr << msg << endl;
273
274
    return false;
283
284
 
284
285
  return true;
285
286
}
286
 
 
287
 
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
288
 
uInt8* CartridgeF6SC::getImage(int& size) {
289
 
  size = 16384;
290
 
  return &myImage[0];
291
 
}