commodore64: change from uint to int, seems to speed things up a little with no side effects

This commit is contained in:
saxxonpike 2012-12-11 06:27:00 +00:00
parent 5a8ce4000b
commit 31fba1ec2b
6 changed files with 228 additions and 230 deletions

View File

@ -8,7 +8,7 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
// vic ntsc // vic ntsc
public class MOS6567 : Vic public class MOS6567 : Vic
{ {
static uint[][] pipeline = new uint[5][]; static int[][] pipeline = new int[5][];
public MOS6567() public MOS6567()
: base(65, 263, pipeline, 14318181 / 14) : base(65, 263, pipeline, 14318181 / 14)

View File

@ -8,9 +8,9 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
// vic pal // vic pal
public class MOS6569 : Vic public class MOS6569 : Vic
{ {
static uint[][] pipeline = new uint[][] static int[][] pipeline = new int[][]
{ {
new uint[] // xposition new int[] // xposition
{ {
0x0194, 0x0198, 0x0194, 0x0198,
0x019C, 0x01A0, 0x019C, 0x01A0,
@ -88,7 +88,7 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
0x0184, 0x0188, 0x0184, 0x0188,
0x018C, 0x0190 0x018C, 0x0190
}, },
new uint[] // fetch (100=ref 200=c 300=g 400=i 500=none) new int[] // fetch (100=ref 200=c 300=g 400=i 500=none)
{ {
0x0003, 0x0013, 0x0003, 0x0013,
0x0023, 0x0033, 0x0023, 0x0033,
@ -166,7 +166,7 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
0x0002, 0x0012, 0x0002, 0x0012,
0x0022, 0x0032 0x0022, 0x0032
}, },
new uint[] // BA new int[] // BA
{ {
0x0843, 0x0843, 0x0843, 0x0843,
0x0543, 0x0543, 0x0543, 0x0543,
@ -244,7 +244,7 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
0x0283, 0x0283, 0x0283, 0x0283,
0x0243, 0x0243 0x0243, 0x0243
}, },
new uint[] // actions new int[] // actions
{ {
0, 0, 0, 0,
0, 0, 0, 0,

View File

@ -8,9 +8,9 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
// sid // sid
public class MOS6581 : Sid public class MOS6581 : Sid
{ {
static uint[][] waveTable = new uint[][] static int[][] waveTable = new int[][]
{ {
new uint[] { new int[] {
0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF,
0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF,
0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF,
@ -524,7 +524,7 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF,
0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF
}, },
new uint[] { new int[] {
0x000, 0x002, 0x004, 0x006, 0x008, 0x00A, 0x00C, 0x00E, 0x000, 0x002, 0x004, 0x006, 0x008, 0x00A, 0x00C, 0x00E,
0x010, 0x012, 0x014, 0x016, 0x018, 0x01A, 0x01C, 0x01E, 0x010, 0x012, 0x014, 0x016, 0x018, 0x01A, 0x01C, 0x01E,
0x020, 0x022, 0x024, 0x026, 0x028, 0x02A, 0x02C, 0x02E, 0x020, 0x022, 0x024, 0x026, 0x028, 0x02A, 0x02C, 0x02E,
@ -1038,7 +1038,7 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
0x01E, 0x01C, 0x01A, 0x018, 0x016, 0x014, 0x012, 0x010, 0x01E, 0x01C, 0x01A, 0x018, 0x016, 0x014, 0x012, 0x010,
0x00E, 0x00C, 0x00A, 0x008, 0x006, 0x004, 0x002, 0x000 0x00E, 0x00C, 0x00A, 0x008, 0x006, 0x004, 0x002, 0x000
}, },
new uint[] { new int[] {
0x000, 0x001, 0x002, 0x003, 0x004, 0x005, 0x006, 0x007, 0x000, 0x001, 0x002, 0x003, 0x004, 0x005, 0x006, 0x007,
0x008, 0x009, 0x00A, 0x00B, 0x00C, 0x00D, 0x00E, 0x00F, 0x008, 0x009, 0x00A, 0x00B, 0x00C, 0x00D, 0x00E, 0x00F,
0x010, 0x011, 0x012, 0x013, 0x014, 0x015, 0x016, 0x017, 0x010, 0x011, 0x012, 0x013, 0x014, 0x015, 0x016, 0x017,
@ -1552,7 +1552,7 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
0xFF0, 0xFF1, 0xFF2, 0xFF3, 0xFF4, 0xFF5, 0xFF6, 0xFF7, 0xFF0, 0xFF1, 0xFF2, 0xFF3, 0xFF4, 0xFF5, 0xFF6, 0xFF7,
0xFF8, 0xFF9, 0xFFA, 0xFFB, 0xFFC, 0xFFD, 0xFFE, 0xFFF 0xFF8, 0xFF9, 0xFFA, 0xFFB, 0xFFC, 0xFFD, 0xFFE, 0xFFF
}, },
new uint[] { new int[] {
0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000,
0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000,
0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000,
@ -2066,7 +2066,7 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
0x380, 0x380, 0x380, 0x3C0, 0x3C0, 0x3C0, 0x3C0, 0x7C0, 0x380, 0x380, 0x380, 0x3C0, 0x3C0, 0x3C0, 0x3C0, 0x7C0,
0x3C0, 0x7C0, 0x7E0, 0x7E0, 0x7E0, 0x7F0, 0x7F8, 0x7FC 0x3C0, 0x7C0, 0x7E0, 0x7E0, 0x7E0, 0x7F0, 0x7F8, 0x7FC
}, },
new uint[] { new int[] {
0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF,
0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF,
0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF,
@ -2580,7 +2580,7 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF,
0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF
}, },
new uint[] { new int[] {
0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000,
0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000,
0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000,
@ -3094,7 +3094,7 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000,
0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000
}, },
new uint[] { new int[] {
0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000,
0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000,
0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000,
@ -3608,7 +3608,7 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
0xFE0, 0xFF0, 0xFF0, 0xFF3, 0xFF0, 0xFF5, 0xFF6, 0xFF7, 0xFE0, 0xFF0, 0xFF0, 0xFF3, 0xFF0, 0xFF5, 0xFF6, 0xFF7,
0xFF8, 0xFF9, 0xFFA, 0xFFB, 0xFFC, 0xFFD, 0xFFE, 0xFFF 0xFF8, 0xFF9, 0xFFA, 0xFFB, 0xFFC, 0xFFD, 0xFFE, 0xFFF
}, },
new uint[] { new int[] {
0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000,
0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000,
0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000,
@ -4124,7 +4124,7 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
} }
}; };
public MOS6581(uint newSampleRate, Region newRegion) : base(waveTable, newSampleRate, newRegion) public MOS6581(int newSampleRate, Region newRegion) : base(waveTable, newSampleRate, newRegion)
{ {
} }
} }

View File

@ -11,25 +11,25 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
private class Envelope private class Envelope
{ {
private const uint stateAttack = 0; private const int stateAttack = 0;
private const uint stateDecay = 1; private const int stateDecay = 1;
private const uint stateRelease = 2; private const int stateRelease = 2;
private uint attack; private int attack;
private uint decay; private int decay;
private bool delay; private bool delay;
private uint envCounter; private int envCounter;
private uint expCounter; private int expCounter;
private uint expPeriod; private int expPeriod;
private bool freeze; private bool freeze;
private uint lfsr; private int lfsr;
private bool gate; private bool gate;
private uint rate; private int rate;
private uint release; private int release;
private uint state; private int state;
private uint sustain; private int sustain;
private static uint[] adsrTable = new uint[] private static int[] adsrTable = new int[]
{ {
0x7F00, 0x0006, 0x003C, 0x0330, 0x7F00, 0x0006, 0x003C, 0x0330,
0x20C0, 0x6755, 0x3800, 0x500E, 0x20C0, 0x6755, 0x3800, 0x500E,
@ -37,17 +37,17 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
0x3840, 0x77E2, 0x7625, 0x0A93 0x3840, 0x77E2, 0x7625, 0x0A93
}; };
private static uint[] expCounterTable = new uint[] private static int[] expCounterTable = new int[]
{ {
0xFF, 0x5D, 0x36, 0x1A, 0x0E, 0x06, 0x00 0xFF, 0x5D, 0x36, 0x1A, 0x0E, 0x06, 0x00
}; };
private static uint[] expPeriodTable = new uint[] private static int[] expPeriodTable = new int[]
{ {
0x01, 0x02, 0x04, 0x08, 0x10, 0x1E, 0x01 0x01, 0x02, 0x04, 0x08, 0x10, 0x1E, 0x01
}; };
private static uint[] sustainTable = new uint[] private static int[] sustainTable = new int[]
{ {
0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF
@ -76,7 +76,7 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
if (lfsr != rate) if (lfsr != rate)
{ {
uint feedback = ((lfsr >> 14) ^ (lfsr >> 13)) & 0x1; int feedback = ((lfsr >> 14) ^ (lfsr >> 13)) & 0x1;
lfsr = ((lfsr << 1) & 0x7FFF) | feedback; lfsr = ((lfsr << 1) & 0x7FFF) | feedback;
return; return;
} }
@ -146,7 +146,7 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
{ {
{ {
for (uint i = 0; i < 7; i++) for (int i = 0; i < 7; i++)
{ {
if (envCounter == expCounterTable[i]) if (envCounter == expCounterTable[i])
expPeriod = expPeriodTable[i]; expPeriod = expPeriodTable[i];
@ -158,7 +158,7 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
// ------------------------------------ // ------------------------------------
public uint Attack public int Attack
{ {
get get
{ {
@ -172,7 +172,7 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
} }
} }
public uint Decay public int Decay
{ {
get get
{ {
@ -211,7 +211,7 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
} }
} }
public uint Level public int Level
{ {
get get
{ {
@ -219,7 +219,7 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
} }
} }
public uint Release public int Release
{ {
get get
{ {
@ -233,7 +233,7 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
} }
} }
public uint Sustain public int Sustain
{ {
get get
{ {
@ -269,29 +269,29 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
private class Voice private class Voice
{ {
private uint accumulator; private int accumulator;
private uint delay; private int delay;
private uint floatOutputTTL; private int floatOutputTTL;
private uint frequency; private int frequency;
private bool msbRising; private bool msbRising;
private uint noise; private int noise;
private uint noNoise; private int noNoise;
private uint noNoiseOrNoise; private int noNoiseOrNoise;
private uint noPulse; private int noPulse;
private uint output; private int output;
private uint pulse; private int pulse;
private uint pulseWidth; private int pulseWidth;
private bool ringMod; private bool ringMod;
private uint ringMsbMask; private int ringMsbMask;
private uint shiftRegister; private int shiftRegister;
private uint shiftRegisterReset; private int shiftRegisterReset;
private bool sync; private bool sync;
private bool test; private bool test;
private uint[] wave; private int[] wave;
private uint waveform; private int waveform;
private uint[][] waveTable; private int[][] waveTable;
public Voice(uint[][] newWaveTable) public Voice(int[][] newWaveTable)
{ {
waveTable = newWaveTable; waveTable = newWaveTable;
HardReset(); HardReset();
@ -337,8 +337,8 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
} }
else else
{ {
uint accNext = (accumulator + frequency) & 0xFFFFFF; int accNext = (accumulator + frequency) & 0xFFFFFF;
uint accBits = ~accumulator & accNext; int accBits = ~accumulator & accNext;
accumulator = accNext; accumulator = accNext;
msbRising = ((accBits & 0x800000) != 0); msbRising = ((accBits & 0x800000) != 0);
@ -356,7 +356,7 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
{ {
{ {
uint bit0 = ((shiftRegister >> 22) ^ (shiftRegister >> 17)) & 0x1; int bit0 = ((shiftRegister >> 22) ^ (shiftRegister >> 17)) & 0x1;
shiftRegister = ((shiftRegister << 1) | bit0) & 0x7FFFFF; shiftRegister = ((shiftRegister << 1) | bit0) & 0x7FFFFF;
SetNoise(); SetNoise();
} }
@ -409,11 +409,11 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
// ------------------------------------ // ------------------------------------
public uint Control public int Control
{ {
set set
{ {
uint wavePrev = waveform; int wavePrev = waveform;
bool testPrev = test; bool testPrev = test;
sync = ((value & 0x02) != 0); sync = ((value & 0x02) != 0);
@ -422,9 +422,9 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
waveform = (value >> 4) & 0x0F; waveform = (value >> 4) & 0x0F;
wave = waveTable[waveform & 0x07]; wave = waveTable[waveform & 0x07];
ringMsbMask = ((~value >> 5) & (value >> 2) & 0x1) << 23; ringMsbMask = ((~value >> 5) & (value >> 2) & 0x1) << 23;
noNoise = ((waveform & 0x8) != 0) ? (uint)0x000 : (uint)0xFFF; noNoise = ((waveform & 0x8) != 0) ? (int)0x000 : (int)0xFFF;
noNoiseOrNoise = noNoise | noise; noNoiseOrNoise = noNoise | noise;
noPulse = ((waveform & 0x4) != 0) ? (uint)0x000 : (uint)0xFFF; noPulse = ((waveform & 0x4) != 0) ? (int)0x000 : (int)0xFFF;
if (!testPrev && test) if (!testPrev && test)
{ {
@ -434,7 +434,7 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
} }
else if (testPrev && !test) else if (testPrev && !test)
{ {
uint bit0 = (~shiftRegister >> 17) & 0x1; int bit0 = (~shiftRegister >> 17) & 0x1;
shiftRegister = ((shiftRegister << 1) | bit0) & 0x7FFFFF; shiftRegister = ((shiftRegister << 1) | bit0) & 0x7FFFFF;
SetNoise(); SetNoise();
} }
@ -444,7 +444,7 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
} }
} }
public uint Frequency public int Frequency
{ {
get get
{ {
@ -456,7 +456,7 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
} }
} }
public uint FrequencyLo public int FrequencyLo
{ {
get get
{ {
@ -469,7 +469,7 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
} }
} }
public uint FrequencyHi public int FrequencyHi
{ {
get get
{ {
@ -482,7 +482,7 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
} }
} }
public uint Oscillator public int Oscillator
{ {
get get
{ {
@ -490,13 +490,13 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
} }
} }
public uint Output(Voice ringModSource) public int Output(Voice ringModSource)
{ {
{ {
if (waveform != 0) if (waveform != 0)
{ {
uint index = (accumulator ^ (ringModSource.accumulator & ringMsbMask)) >> 12; int index = (accumulator ^ (ringModSource.accumulator & ringMsbMask)) >> 12;
output = wave[index] & (noPulse | pulse) & noNoiseOrNoise; output = wave[index] & (noPulse | pulse) & noNoiseOrNoise;
if (waveform > 8) if (waveform > 8)
WriteShiftReg(); WriteShiftReg();
@ -506,12 +506,12 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
if (floatOutputTTL != 0 && --floatOutputTTL == 0) if (floatOutputTTL != 0 && --floatOutputTTL == 0)
output = 0x000; output = 0x000;
} }
pulse = ((accumulator >> 12) >= pulseWidth) ? (uint)0xFFF : (uint)0x000; pulse = ((accumulator >> 12) >= pulseWidth) ? (int)0xFFF : (int)0x000;
return output; return output;
} }
} }
public uint PulseWidth public int PulseWidth
{ {
get get
{ {
@ -523,7 +523,7 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
} }
} }
public uint PulseWidthLo public int PulseWidthLo
{ {
get get
{ {
@ -536,7 +536,7 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
} }
} }
public uint PulseWidthHi public int PulseWidthHi
{ {
get get
{ {
@ -579,7 +579,7 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
} }
} }
public uint Waveform public int Waveform
{ {
get get
{ {
@ -620,52 +620,50 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
public Sound.Utilities.SpeexResampler resampler; public Sound.Utilities.SpeexResampler resampler;
private static uint[] syncNextTable = new uint[] { 1, 2, 0 }; private static int[] syncNextTable = new int[] { 1, 2, 0 };
private static uint[] syncPrevTable = new uint[] { 2, 0, 1 }; private static int[] syncPrevTable = new int[] { 2, 0, 1 };
private bool disableVoice3; private bool disableVoice3;
private uint[] envelopeOutput; private int[] envelopeOutput;
private Envelope[] envelopes; private Envelope[] envelopes;
private bool[] filterEnable; private bool[] filterEnable;
private uint filterFrequency; private int filterFrequency;
private uint filterResonance; private int filterResonance;
private bool filterSelectBandPass; private bool filterSelectBandPass;
private bool filterSelectLoPass; private bool filterSelectLoPass;
private bool filterSelectHiPass; private bool filterSelectHiPass;
private uint potCounter; private int potCounter;
private byte potX; private byte potX;
private byte potY; private byte potY;
private uint[] voiceOutput; private int[] voiceOutput;
private Voice[] voices; private Voice[] voices;
private uint volume; private int volume;
private uint[][] waveformTable; private int[][] waveformTable;
public Func<byte> ReadPotX; public Func<byte> ReadPotX;
public Func<byte> ReadPotY; public Func<byte> ReadPotY;
public Sid(uint[][] newWaveformTable, uint newSampleRate, Region newRegion) public Sid(int[][] newWaveformTable, int newSampleRate, Region newRegion)
{ {
uint cyclesPerSec = 0; uint cyclesPerSec = 0;
switch (newRegion) switch (newRegion)
{ {
case Region.NTSC: cyclesPerSec = 14318181 / 14; /*bufferLength = (newSampleRate / 60) * 4;*/ break; case Region.NTSC: cyclesPerSec = 14318181 / 14; break;
case Region.PAL: cyclesPerSec = 17734472 / 18; /*bufferLength = (newSampleRate / 50) * 4;*/ break; case Region.PAL: cyclesPerSec = 17734472 / 18; break;
} }
//bufferFrequency = cyclesPerSec / newSampleRate;
//buffer = new short[bufferLength];
waveformTable = newWaveformTable; waveformTable = newWaveformTable;
envelopes = new Envelope[3]; envelopes = new Envelope[3];
for (int i = 0; i < 3; i++) for (int i = 0; i < 3; i++)
envelopes[i] = new Envelope(); envelopes[i] = new Envelope();
envelopeOutput = new uint[3]; envelopeOutput = new int[3];
voices = new Voice[3]; voices = new Voice[3];
for (int i = 0; i < 3; i++) for (int i = 0; i < 3; i++)
voices[i] = new Voice(newWaveformTable); voices[i] = new Voice(newWaveformTable);
voiceOutput = new uint[3]; voiceOutput = new int[3];
filterEnable = new bool[3]; filterEnable = new bool[3];
for (int i = 0; i < 3; i++) for (int i = 0; i < 3; i++)
@ -725,7 +723,7 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
envelopes[2].ExecutePhase2(); envelopes[2].ExecutePhase2();
// process sync // process sync
for (uint i = 0; i < 3; i++) for (int i = 0; i < 3; i++)
voices[i].Synchronize(voices[syncNextTable[i]], voices[syncPrevTable[i]]); voices[i].Synchronize(voices[syncNextTable[i]], voices[syncPrevTable[i]]);
// get output // get output
@ -739,7 +737,7 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
// process output // process output
//if (bufferCounter == 0) //if (bufferCounter == 0)
//{ //{
uint mixer; int mixer;
short sample; short sample;
//bufferCounter = bufferFrequency; //bufferCounter = bufferFrequency;
@ -926,32 +924,32 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
case 0x02: voices[0].PulseWidthLo = val; break; case 0x02: voices[0].PulseWidthLo = val; break;
case 0x03: voices[0].PulseWidthHi = val; break; case 0x03: voices[0].PulseWidthHi = val; break;
case 0x04: voices[0].Control = val; envelopes[0].Gate = ((val & 0x01) != 0); break; case 0x04: voices[0].Control = val; envelopes[0].Gate = ((val & 0x01) != 0); break;
case 0x05: envelopes[0].Attack = (uint)(val >> 4); envelopes[0].Decay = (uint)(val & 0xF); break; case 0x05: envelopes[0].Attack = (val >> 4); envelopes[0].Decay = (val & 0xF); break;
case 0x06: envelopes[0].Sustain = (uint)(val >> 4); envelopes[0].Release = (uint)(val & 0xF); break; case 0x06: envelopes[0].Sustain = (val >> 4); envelopes[0].Release = (val & 0xF); break;
case 0x07: voices[1].FrequencyLo = val; break; case 0x07: voices[1].FrequencyLo = val; break;
case 0x08: voices[1].FrequencyHi = val; break; case 0x08: voices[1].FrequencyHi = val; break;
case 0x09: voices[1].PulseWidthLo = val; break; case 0x09: voices[1].PulseWidthLo = val; break;
case 0x0A: voices[1].PulseWidthHi = val; break; case 0x0A: voices[1].PulseWidthHi = val; break;
case 0x0B: voices[1].Control = val; envelopes[1].Gate = ((val & 0x01) != 0); break; case 0x0B: voices[1].Control = val; envelopes[1].Gate = ((val & 0x01) != 0); break;
case 0x0C: envelopes[1].Attack = (uint)(val >> 4); envelopes[1].Decay = (uint)(val & 0xF); break; case 0x0C: envelopes[1].Attack = (val >> 4); envelopes[1].Decay = (val & 0xF); break;
case 0x0D: envelopes[1].Sustain = (uint)(val >> 4); envelopes[1].Release = (uint)(val & 0xF); break; case 0x0D: envelopes[1].Sustain = (val >> 4); envelopes[1].Release = (val & 0xF); break;
case 0x0E: voices[2].FrequencyLo = val; break; case 0x0E: voices[2].FrequencyLo = val; break;
case 0x0F: voices[2].FrequencyHi = val; break; case 0x0F: voices[2].FrequencyHi = val; break;
case 0x10: voices[2].PulseWidthLo = val; break; case 0x10: voices[2].PulseWidthLo = val; break;
case 0x11: voices[2].PulseWidthHi = val; break; case 0x11: voices[2].PulseWidthHi = val; break;
case 0x12: voices[2].Control = val; envelopes[2].Gate = ((val & 0x01) != 0); break; case 0x12: voices[2].Control = val; envelopes[2].Gate = ((val & 0x01) != 0); break;
case 0x13: envelopes[2].Attack = (uint)(val >> 4); envelopes[2].Decay = (uint)(val & 0xF); break; case 0x13: envelopes[2].Attack = (val >> 4); envelopes[2].Decay = (val & 0xF); break;
case 0x14: envelopes[2].Sustain = (uint)(val >> 4); envelopes[2].Release = (uint)(val & 0xF); break; case 0x14: envelopes[2].Sustain = (val >> 4); envelopes[2].Release = (val & 0xF); break;
case 0x15: filterFrequency &= 0x3FF; filterFrequency |= (uint)(val & 0x7); break; case 0x15: filterFrequency &= 0x3FF; filterFrequency |= (val & 0x7); break;
case 0x16: filterFrequency &= 0x7; filterFrequency |= (uint)val << 3; break; case 0x16: filterFrequency &= 0x7; filterFrequency |= val << 3; break;
case 0x17: case 0x17:
filterEnable[0] = ((val & 0x1) != 0); filterEnable[0] = ((val & 0x1) != 0);
filterEnable[1] = ((val & 0x2) != 0); filterEnable[1] = ((val & 0x2) != 0);
filterEnable[2] = ((val & 0x4) != 0); filterEnable[2] = ((val & 0x4) != 0);
filterResonance = (uint)val >> 4; filterResonance = val >> 4;
break; break;
case 0x18: case 0x18:
volume = (uint)(val & 0xF); volume = (val & 0xF);
filterSelectLoPass = ((val & 0x10) != 0); filterSelectLoPass = ((val & 0x10) != 0);
filterSelectBandPass = ((val & 0x20) != 0); filterSelectBandPass = ((val & 0x20) != 0);
filterSelectHiPass = ((val & 0x40) != 0); filterSelectHiPass = ((val & 0x40) != 0);

View File

@ -10,8 +10,8 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
{ {
private int[] buf; private int[] buf;
private int bufHeight; private int bufHeight;
private uint bufLength; private int bufLength;
private uint bufOffset; private int bufOffset;
private Point bufPoint; private Point bufPoint;
private Rectangle bufRect; private Rectangle bufRect;
private int bufWidth; private int bufWidth;

View File

@ -14,22 +14,22 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
{ {
public bool collideData; public bool collideData;
public bool collideSprite; public bool collideSprite;
public uint color; public int color;
public bool display; public bool display;
public bool dma; public bool dma;
public bool enable; public bool enable;
public uint mc; public int mc;
public uint mcbase; public int mcbase;
public bool multicolor; public bool multicolor;
public bool multicolorCrunch; public bool multicolorCrunch;
public uint pointer; public int pointer;
public bool priority; public bool priority;
public bool shiftEnable; public bool shiftEnable;
public uint sr; public int sr;
public uint x; public int x;
public bool xCrunch; public bool xCrunch;
public bool xExpand; public bool xExpand;
public uint y; public int y;
public bool yCrunch; public bool yCrunch;
public bool yExpand; public bool yExpand;
@ -83,34 +83,34 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
} }
private Sprite[] sprites; private Sprite[] sprites;
private uint backgroundColor0; private int backgroundColor0;
private uint backgroundColor1; private int backgroundColor1;
private uint backgroundColor2; private int backgroundColor2;
private uint backgroundColor3; private int backgroundColor3;
private uint baCount; private int baCount;
private bool badline; private bool badline;
private bool badlineEnable; private bool badlineEnable;
private uint bitmapColumn; private int bitmapColumn;
private bool bitmapMode; private bool bitmapMode;
private uint borderB; private int borderB;
private bool borderCheckLEnable; private bool borderCheckLEnable;
private bool borderCheckREnable; private bool borderCheckREnable;
private uint borderColor; private int borderColor;
private uint borderL; private int borderL;
private bool borderOnMain; private bool borderOnMain;
private bool borderOnVertical; private bool borderOnVertical;
private uint borderR; private int borderR;
private uint borderT; private int borderT;
private uint[] bufferC; private int[] bufferC;
private uint[] bufferG; private int[] bufferG;
private bool columnSelect; private bool columnSelect;
private uint cycle; private int cycle;
private uint cycleIndex; private int cycleIndex;
private uint dataC; private int dataC;
private uint dataG; private int dataG;
private uint displayC; private int displayC;
private bool displayEnable; private bool displayEnable;
private uint displayIndex; private int displayIndex;
private bool enableIntLightPen; private bool enableIntLightPen;
private bool enableIntRaster; private bool enableIntRaster;
private bool enableIntSpriteCollision; private bool enableIntSpriteCollision;
@ -121,34 +121,34 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
private bool intRaster; private bool intRaster;
private bool intSpriteCollision; private bool intSpriteCollision;
private bool intSpriteDataCollision; private bool intSpriteDataCollision;
private uint lastRasterLine; private int lastRasterLine;
private uint lightPenX; private int lightPenX;
private uint lightPenY; private int lightPenY;
private bool multicolorMode; private bool multicolorMode;
private uint[] pixelBackgroundBuffer; private int[] pixelBackgroundBuffer;
private uint pixelBackgroundBufferDelay; private int pixelBackgroundBufferDelay;
private uint pixelBackgroundBufferIndex; private int pixelBackgroundBufferIndex;
private uint[] pixelBuffer; private int[] pixelBuffer;
private uint pixelBufferDelay; private int pixelBufferDelay;
private uint pixelBufferIndex; private int pixelBufferIndex;
private uint[] pixelDataBuffer; private int[] pixelDataBuffer;
private uint pointerCB; private int pointerCB;
private uint pointerVM; private int pointerVM;
private uint rasterInterruptLine; private int rasterInterruptLine;
private uint rasterLine; private int rasterLine;
private uint rasterX; private int rasterX;
private uint rc; private int rc;
private uint refreshCounter; private int refreshCounter;
private bool rowSelect; private bool rowSelect;
private uint spriteMulticolor0; private int spriteMulticolor0;
private uint spriteMulticolor1; private int spriteMulticolor1;
private uint sr; private int sr;
private uint vc; private int vc;
private uint vcbase; private int vcbase;
private uint vmli; private int vmli;
private uint xOffset; private int xOffset;
private uint xScroll; private int xScroll;
private uint yScroll; private int yScroll;
// ------------------------------------ // ------------------------------------
@ -156,9 +156,9 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
private bool pinAEC; private bool pinAEC;
private bool pinBA; private bool pinBA;
private bool pinIRQ; private bool pinIRQ;
private uint[][] pipeline; private int[][] pipeline;
private uint totalCycles; private int totalCycles;
private uint totalLines; private int totalLines;
// ------------------------------------ // ------------------------------------
@ -167,7 +167,7 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
// ------------------------------------ // ------------------------------------
public Vic(uint newCycles, uint newLines, uint[][] newPipeline, int newCyclesPerSec) public Vic(int newCycles, int newLines, int[][] newPipeline, int newCyclesPerSec)
{ {
{ {
@ -180,19 +180,19 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
bufRect = new Rectangle(136 - 24, 51 - 24, 320 + 48, 200 + 48); bufRect = new Rectangle(136 - 24, 51 - 24, 320 + 48, 200 + 48);
buf = new int[bufRect.Width * bufRect.Height]; buf = new int[bufRect.Width * bufRect.Height];
bufLength = (uint)buf.Length; bufLength = buf.Length;
bufWidth = (int)(totalCycles * 8); bufWidth = (totalCycles * 8);
bufHeight = (int)(totalLines); bufHeight = (totalLines);
sprites = new Sprite[8]; sprites = new Sprite[8];
for (uint i = 0; i < 8; i++) for (int i = 0; i < 8; i++)
sprites[i] = new Sprite(); sprites[i] = new Sprite();
bufferC = new uint[40]; bufferC = new int[40];
bufferG = new uint[40]; bufferG = new int[40];
pixelBuffer = new uint[pixelBufferDelay]; pixelBuffer = new int[pixelBufferDelay];
pixelDataBuffer = new uint[pixelBufferDelay]; pixelDataBuffer = new int[pixelBufferDelay];
pixelBackgroundBuffer = new uint[pixelBackgroundBufferDelay]; pixelBackgroundBuffer = new int[pixelBackgroundBufferDelay];
} }
} }
@ -255,23 +255,23 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
yScroll = 0; yScroll = 0;
// reset sprites // reset sprites
for (uint i = 0; i < 8; i++) for (int i = 0; i < 8; i++)
sprites[i].HardReset(); sprites[i].HardReset();
// clear C buffer // clear C buffer
for (uint i = 0; i < 40; i++) for (int i = 0; i < 40; i++)
{ {
bufferC[i] = 0; bufferC[i] = 0;
bufferG[i] = 0; bufferG[i] = 0;
} }
// clear pixel buffer // clear pixel buffer
for (uint i = 0; i < pixelBufferDelay; i++) for (int i = 0; i < pixelBufferDelay; i++)
{ {
pixelBuffer[i] = 0; pixelBuffer[i] = 0;
pixelDataBuffer[i] = 0; pixelDataBuffer[i] = 0;
} }
for (uint i = 0; i < pixelBackgroundBufferDelay; i++) for (int i = 0; i < pixelBackgroundBufferDelay; i++)
pixelBackgroundBuffer[i] = 0; pixelBackgroundBuffer[i] = 0;
UpdateBorder(); UpdateBorder();
@ -293,10 +293,10 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
{ {
{ {
borderL = columnSelect ? (uint)0x018 : (uint)0x01F; borderL = columnSelect ? 0x018 : 0x01F;
borderR = columnSelect ? (uint)0x158 : (uint)0x14F; borderR = columnSelect ? 0x158 : 0x14F;
borderT = rowSelect ? (uint)0x033 : (uint)0x037; borderT = rowSelect ? 0x033 : 0x037;
borderB = rowSelect ? (uint)0x0FB : (uint)0x0F7; borderB = rowSelect ? 0x0FB : 0x0F7;
} }
} }
@ -314,22 +314,22 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
// ------------------------------------ // ------------------------------------
protected const uint pipelineUpdateVc = 1; protected const int pipelineUpdateVc = 1;
protected const uint pipelineChkSprChunch = 2; protected const int pipelineChkSprChunch = 2;
protected const uint pipelineUpdateMcBase = 4; protected const int pipelineUpdateMcBase = 4;
protected const uint pipelineChkBrdL1 = 8; protected const int pipelineChkBrdL1 = 8;
protected const uint pipelineChkBrdL0 = 16; protected const int pipelineChkBrdL0 = 16;
protected const uint pipelineChkSprDma = 32; protected const int pipelineChkSprDma = 32;
protected const uint pipelineChkBrdR0 = 64; protected const int pipelineChkBrdR0 = 64;
protected const uint pipelineChkSprExp = 128; protected const int pipelineChkSprExp = 128;
protected const uint pipelineChkBrdR1 = 256; protected const int pipelineChkBrdR1 = 256;
protected const uint pipelineChkSprDisp = 512; protected const int pipelineChkSprDisp = 512;
protected const uint pipelineUpdateRc = 1024; protected const int pipelineUpdateRc = 1024;
protected const uint rasterIrqLine0Cycle = 1; protected const int rasterIrqLine0Cycle = 1;
protected const uint rasterIrqLineXCycle = 0; protected const int rasterIrqLineXCycle = 0;
protected const uint baResetCounter = 4; protected const int baResetCounter = 4;
// ------------------------------------ // ------------------------------------
@ -427,13 +427,13 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
{ {
ushort addr = 0x3FFF; ushort addr = 0x3FFF;
uint cycleBAsprite0; int cycleBAsprite0;
uint cycleBAsprite1; int cycleBAsprite1;
uint cycleBAsprite2; int cycleBAsprite2;
uint cycleFetchSpriteIndex; int cycleFetchSpriteIndex;
uint fetch = pipeline[1][cycleIndex]; int fetch = pipeline[1][cycleIndex];
uint ba = pipeline[2][cycleIndex]; int ba = pipeline[2][cycleIndex];
uint act = pipeline[3][cycleIndex]; int act = pipeline[3][cycleIndex];
// apply X location // apply X location
rasterX = pipeline[0][cycleIndex]; rasterX = pipeline[0][cycleIndex];
@ -455,7 +455,7 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
{ {
addr = (ushort)((pointerVM << 10) | vc); addr = (ushort)((pointerVM << 10) | vc);
dataC = ReadMemory(addr); dataC = ReadMemory(addr);
dataC |= ((uint)ReadColorRam(addr) & 0xF) << 8; dataC |= ((int)ReadColorRam(addr) & 0xF) << 8;
bufferC[vmli] = dataC; bufferC[vmli] = dataC;
} }
else else
@ -642,8 +642,8 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
{ {
{ {
uint pixel; int pixel;
uint pixelData; int pixelData;
bool renderEnabled = bufRect.Contains(bufPoint); bool renderEnabled = bufRect.Contains(bufPoint);
for (int i = 0; i < 4; i++) for (int i = 0; i < 4; i++)
@ -686,11 +686,11 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
pixel = pixelBackgroundBuffer[pixelBackgroundBufferIndex]; pixel = pixelBackgroundBuffer[pixelBackgroundBufferIndex];
// render sprite // render sprite
uint pixelOwner = 8; int pixelOwner = 8;
for (uint j = 0; j < 8; j++) for (int j = 0; j < 8; j++)
{ {
uint sprData; int sprData;
uint sprPixel = pixel; int sprPixel = pixel;
Sprite spr = sprites[j]; Sprite spr = sprites[j];
@ -1230,23 +1230,23 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
sprites[addr >> 1].y = val; sprites[addr >> 1].y = val;
break; break;
case 0x10: case 0x10:
sprites[0].x = (sprites[0].x & 0xFF) | ((uint)(val & 0x01) << 8); sprites[0].x = (sprites[0].x & 0xFF) | ((val & 0x01) << 8);
sprites[1].x = (sprites[1].x & 0xFF) | ((uint)(val & 0x02) << 7); sprites[1].x = (sprites[1].x & 0xFF) | ((val & 0x02) << 7);
sprites[2].x = (sprites[2].x & 0xFF) | ((uint)(val & 0x04) << 6); sprites[2].x = (sprites[2].x & 0xFF) | ((val & 0x04) << 6);
sprites[3].x = (sprites[3].x & 0xFF) | ((uint)(val & 0x08) << 5); sprites[3].x = (sprites[3].x & 0xFF) | ((val & 0x08) << 5);
sprites[4].x = (sprites[4].x & 0xFF) | ((uint)(val & 0x10) << 4); sprites[4].x = (sprites[4].x & 0xFF) | ((val & 0x10) << 4);
sprites[5].x = (sprites[5].x & 0xFF) | ((uint)(val & 0x20) << 3); sprites[5].x = (sprites[5].x & 0xFF) | ((val & 0x20) << 3);
sprites[6].x = (sprites[6].x & 0xFF) | ((uint)(val & 0x40) << 2); sprites[6].x = (sprites[6].x & 0xFF) | ((val & 0x40) << 2);
sprites[7].x = (sprites[7].x & 0xFF) | ((uint)(val & 0x80) << 1); sprites[7].x = (sprites[7].x & 0xFF) | ((val & 0x80) << 1);
break; break;
case 0x11: case 0x11:
yScroll = (val & (uint)0x07); yScroll = (val & 0x07);
rowSelect = ((val & 0x08) != 0); rowSelect = ((val & 0x08) != 0);
displayEnable = ((val & 0x10) != 0); displayEnable = ((val & 0x10) != 0);
bitmapMode = ((val & 0x20) != 0); bitmapMode = ((val & 0x20) != 0);
extraColorMode = ((val & 0x40) != 0); extraColorMode = ((val & 0x40) != 0);
rasterInterruptLine &= 0xFF; rasterInterruptLine &= 0xFF;
rasterInterruptLine |= (uint)(val & 0x80) << 1; rasterInterruptLine |= (val & 0x80) << 1;
UpdateBorder(); UpdateBorder();
break; break;
case 0x12: case 0x12:
@ -1270,7 +1270,7 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
sprites[7].enable = ((val & 0x80) != 0); sprites[7].enable = ((val & 0x80) != 0);
break; break;
case 0x16: case 0x16:
xScroll = (val & (uint)0x07); xScroll = (val & 0x07);
columnSelect = ((val & 0x08) != 0); columnSelect = ((val & 0x08) != 0);
multicolorMode = ((val & 0x10) != 0); multicolorMode = ((val & 0x10) != 0);
UpdateBorder(); UpdateBorder();
@ -1286,8 +1286,8 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
sprites[7].yExpand = ((val & 0x80) != 0); sprites[7].yExpand = ((val & 0x80) != 0);
break; break;
case 0x18: case 0x18:
pointerVM = (uint)((val >> 4) & 0xF); pointerVM = ((val >> 4) & 0xF);
pointerCB = (uint)((val >> 1) & 0x7); pointerCB = ((val >> 1) & 0x7);
break; break;
case 0x19: case 0x19:
intRaster = ((val & 0x01) != 0); intRaster = ((val & 0x01) != 0);
@ -1354,25 +1354,25 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
sprites[7].collideData = ((val & 0x80) != 0); sprites[7].collideData = ((val & 0x80) != 0);
break; break;
case 0x20: case 0x20:
borderColor = (uint)(val & 0xF); borderColor = (val & 0xF);
break; break;
case 0x21: case 0x21:
backgroundColor0 = (uint)(val & 0xF); backgroundColor0 = (val & 0xF);
break; break;
case 0x22: case 0x22:
backgroundColor1 = (uint)(val & 0xF); backgroundColor1 = (val & 0xF);
break; break;
case 0x23: case 0x23:
backgroundColor2 = (uint)(val & 0xF); backgroundColor2 = (val & 0xF);
break; break;
case 0x24: case 0x24:
backgroundColor3 = (uint)(val & 0xF); backgroundColor3 = (val & 0xF);
break; break;
case 0x25: case 0x25:
spriteMulticolor0 = (uint)(val & 0xF); spriteMulticolor0 = (val & 0xF);
break; break;
case 0x26: case 0x26:
spriteMulticolor1 = (uint)(val & 0xF); spriteMulticolor1 = (val & 0xF);
break; break;
case 0x27: case 0x27:
case 0x28: case 0x28:
@ -1382,7 +1382,7 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
case 0x2C: case 0x2C:
case 0x2D: case 0x2D:
case 0x2E: case 0x2E:
sprites[addr - 0x27].color = (uint)(val & 0xF); sprites[addr - 0x27].color = (val & 0xF);
break; break;
default: default:
break; break;
@ -1393,7 +1393,7 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
public void SyncState(Serializer ser) public void SyncState(Serializer ser)
{ {
for (uint i = 0; i < 8; i++) for (int i = 0; i < 8; i++)
{ {
ser.BeginSection("sprite" + i.ToString()); ser.BeginSection("sprite" + i.ToString());
sprites[i].SyncState(ser); sprites[i].SyncState(ser);