1
//============================================================================
5
// SS tttttt eeee ll ll aaaa
6
// SSSS tt ee ee ll ll aa
7
// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
8
// SS SS tt ee ll ll aa aa
9
// SSSS ttt eeeee llll llll aaaaa
11
// Copyright (c) 1995-1998 by Bradford W. Mott
13
// See the file "license" for information on usage and redistribution of
14
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
16
// $Id: CartF6SC.cxx,v 1.2 1998/07/15 20:30:48 bwmott Exp $
17
//============================================================================
20
#include "CartF6SC.hxx"
24
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
25
CartridgeF6SC::CartridgeF6SC(const uInt8* image)
27
// Copy the ROM image into my buffer
28
for(uInt32 addr = 0; addr < 16384; ++addr)
30
myImage[addr] = image[addr];
33
// Initialize RAM with random values
35
for(uInt32 i = 0; i < 128; ++i)
37
myRAM[i] = random.next();
41
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
42
CartridgeF6SC::~CartridgeF6SC()
46
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
47
const char* CartridgeF6SC::name() const
49
return "CartridgeF6SC";
52
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
53
void CartridgeF6SC::reset()
55
// Upon reset we switch to bank 0
59
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
60
void CartridgeF6SC::install(System& system)
63
uInt16 shift = mySystem->pageShift();
64
uInt16 mask = mySystem->pageMask();
66
// Make sure the system we're being installed in has a page size that'll work
67
assert(((0x1080 & mask) == 0) && ((0x1100 & mask) == 0));
69
// Set the page accessing methods for the hot spots
70
System::PageAccess access;
71
for(uInt32 i = (0x1FF6 & ~mask); i < 0x2000; i += (1 << shift))
73
access.directPeekBase = 0;
74
access.directPokeBase = 0;
76
mySystem->setPageAccess(i >> shift, access);
79
// Set the page accessing method for the RAM writing pages
80
for(uInt32 j = 0x1000; j < 0x1080; j += (1 << shift))
83
access.directPeekBase = 0;
84
access.directPokeBase = &myRAM[j & 0x007F];
85
mySystem->setPageAccess(j >> shift, access);
88
// Set the page accessing method for the RAM reading pages
89
for(uInt32 k = 0x1080; k < 0x1100; k += (1 << shift))
92
access.directPeekBase = &myRAM[k & 0x007F];
93
access.directPokeBase = 0;
94
mySystem->setPageAccess(k >> shift, access);
97
// Install pages for bank 0
101
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
102
uInt8 CartridgeF6SC::peek(uInt16 address)
104
address = address & 0x0FFF;
106
// Switch banks if necessary
110
// Set the current bank to the first 4k bank
115
// Set the current bank to the second 4k bank
120
// Set the current bank to the third 4k bank
125
// Set the current bank to the forth 4k bank
133
// NOTE: This does not handle accessing RAM, however, this function
134
// should never be called for RAM because of the way page accessing
136
return myImage[myCurrentBank * 4096 + address];
139
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
140
void CartridgeF6SC::poke(uInt16 address, uInt8)
142
address = address & 0x0FFF;
144
// Switch banks if necessary
148
// Set the current bank to the first 4k bank
153
// Set the current bank to the second 4k bank
158
// Set the current bank to the third 4k bank
163
// Set the current bank to the forth 4k bank
171
// NOTE: This does not handle accessing RAM, however, this function
172
// should never be called for RAM because of the way page accessing
176
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
177
void CartridgeF6SC::bank(uInt16 bank)
179
// Remember what bank we're in
180
myCurrentBank = bank;
181
uInt16 offset = myCurrentBank * 4096;
182
uInt16 shift = mySystem->pageShift();
183
uInt16 mask = mySystem->pageMask();
185
// Setup the page access methods for the current bank
186
System::PageAccess access;
187
access.device = this;
188
access.directPokeBase = 0;
190
// Map ROM image into the system
191
for(uInt32 address = 0x1100; address < (0x1FF6U & ~mask);
192
address += (1 << shift))
194
access.directPeekBase = &myImage[offset + (address & 0x0FFF)];
195
mySystem->setPageAccess(address >> shift, access);