8
8
// SS SS tt ee ll ll aa aa
9
9
// SSSS ttt eeeee llll llll aaaaa
11
// Copyright (c) 1995-2008 by Bradford W. Mott and the Stella team
11
// Copyright (c) 1995-2010 by Bradford W. Mott, Stephen Anthony
12
// and the Stella Team
13
// See the file "license" for information on usage and redistribution of
14
// See the file "License.txt" for information on usage and redistribution of
14
15
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
16
// $Id: M6532.cxx,v 1.27 2008/05/22 17:54:54 stephena Exp $
17
// $Id: M6532.cxx 2012 2010-04-14 22:35:46Z stephena $
17
18
//============================================================================
20
23
#include "Console.hxx"
23
24
#include "Switches.hxx"
24
25
#include "System.hxx"
25
#include "Serializer.hxx"
26
#include "Deserializer.hxx"
29
29
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
30
30
M6532::M6532(const Console& console)
31
31
: myConsole(console)
35
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
40
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
33
43
// Randomize the 128 bytes of memory
36
44
for(uInt32 t = 0; t < 128; ++t)
38
myRAM[t] = random.next();
41
// Initialize other data members
45
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
50
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
45
myRAM[t] = mySystem->randGenerator().next();
55
47
// The timer absolutely cannot be initialized to zero; some games will
56
48
// loop or hang (notably Solaris and H.E.R.O.)
57
myTimer = (0xff - (random.next() % 0xfe)) << 10;
49
myTimer = (0xff - (mySystem->randGenerator().next() % 0xfe)) << 10;
58
50
myIntervalShift = 10;
59
51
myCyclesWhenTimerSet = 0;
60
52
myInterruptEnabled = false;
100
92
// All accesses are to the given device
101
93
System::PageAccess access;
94
access.directPeekBase = 0;
95
access.directPokeBase = 0;
102
96
access.device = &device;
97
access.type = System::PA_READWRITE;
104
99
// We're installing in a 2600 system
105
100
for(int address = 0; address < 8192; address += (1 << shift))
107
101
if((address & 0x1080) == 0x0080)
109
access.directPeekBase = 0;
110
access.directPokeBase = 0;
111
102
mySystem->setPageAccess(address >> shift, access);
116
105
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
215
204
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
216
void M6532::poke(uInt16 addr, uInt8 value)
205
bool M6532::poke(uInt16 addr, uInt8 value)
218
207
// Access RAM directly. Originally, accesses to RAM could bypass
219
208
// this method and its pages could be installed directly into the
255
244
default: // Port B I/O & DDR Registers (Console switches)
256
break; // hardwired as read-only
245
return false; // hardwired as read-only
261
251
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -