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
public class MOS6567 : Vic
{
static uint[][] pipeline = new uint[5][];
static int[][] pipeline = new int[5][];
public MOS6567()
: base(65, 263, pipeline, 14318181 / 14)

View File

@ -8,9 +8,9 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
// vic pal
public class MOS6569 : Vic
{
static uint[][] pipeline = new uint[][]
static int[][] pipeline = new int[][]
{
new uint[] // xposition
new int[] // xposition
{
0x0194, 0x0198,
0x019C, 0x01A0,
@ -88,7 +88,7 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
0x0184, 0x0188,
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,
0x0023, 0x0033,
@ -166,7 +166,7 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
0x0002, 0x0012,
0x0022, 0x0032
},
new uint[] // BA
new int[] // BA
{
0x0843, 0x0843,
0x0543, 0x0543,
@ -244,7 +244,7 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
0x0283, 0x0283,
0x0243, 0x0243
},
new uint[] // actions
new int[] // actions
{
0, 0,
0, 0,

View File

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

View File

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

View File

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