Move commented-out code blocks to #if false
CBB doing Cores or Bizware
This commit is contained in:
parent
a8170ca183
commit
126bb4736b
|
@ -380,15 +380,17 @@ namespace BizHawk.Client.ApiHawk
|
|||
}
|
||||
|
||||
//Using this break joypad usage (even in UI); have to figure out why
|
||||
/*if ((RunningSystem.AvailableButtons & JoypadButton.AnalogStick) == JoypadButton.AnalogStick)
|
||||
#if false
|
||||
if ((RunningSystem.AvailableButtons & JoypadButton.AnalogStick) == JoypadButton.AnalogStick)
|
||||
{
|
||||
AutoFireStickyXorAdapter joypadAdaptor = Global.AutofireStickyXORAdapter;
|
||||
for (int i = 1; i <= RunningSystem.MaxControllers; i++)
|
||||
var joypadAdaptor = Global.AutofireStickyXORAdapter;
|
||||
for (var i = 1; i <= RunningSystem.MaxControllers; i++)
|
||||
{
|
||||
joypadAdaptor.SetFloat($"P{i} X Axis", allJoypads[i - 1].AnalogX);
|
||||
joypadAdaptor.SetFloat($"P{i} Y Axis", allJoypads[i - 1].AnalogY);
|
||||
joypadAdaptor.SetFloat($"P{i} X Axis", _allJoyPads[i - 1].AnalogX);
|
||||
joypadAdaptor.SetFloat($"P{i} Y Axis", _allJoyPads[i - 1].AnalogY);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -497,86 +497,92 @@ namespace BizHawk.Client.DiscoHawk
|
|||
|
||||
} //class DiscoHawk
|
||||
|
||||
}
|
||||
#if false
|
||||
/// <summary>code to test ECM</summary>
|
||||
static class Test
|
||||
{
|
||||
public static void Shuffle<T>(this IList<T> list, Random rng)
|
||||
{
|
||||
int n = list.Count;
|
||||
while (n > 1)
|
||||
{
|
||||
n--;
|
||||
int k = rng.Next(n + 1);
|
||||
T value = list[k];
|
||||
list[k] = list[n];
|
||||
list[n] = value;
|
||||
}
|
||||
}
|
||||
|
||||
//code to test ECM:
|
||||
//static class test
|
||||
//{
|
||||
// public static void Shuffle<T>(this IList<T> list, Random rng)
|
||||
// {
|
||||
// int n = list.Count;
|
||||
// while (n > 1)
|
||||
// {
|
||||
// n--;
|
||||
// int k = rng.Next(n + 1);
|
||||
// T value = list[k];
|
||||
// list[k] = list[n];
|
||||
// list[n] = value;
|
||||
// }
|
||||
// }
|
||||
public static void TestMain()
|
||||
{
|
||||
var plaindisc = Disc.LoadAutomagic("d:\\ecmtest\\test.cue");
|
||||
var ecmdisc = Disc.LoadAutomagic("d:\\ecmtest\\ecmtest.cue");
|
||||
|
||||
// public static void Test()
|
||||
// {
|
||||
// var plaindisc = BizHawk.DiscSystem.Disc.FromCuePath("d:\\ecmtest\\test.cue", BizHawk.MainDiscoForm.GetCuePrefs());
|
||||
// var ecmdisc = BizHawk.DiscSystem.Disc.FromCuePath("d:\\ecmtest\\ecmtest.cue", BizHawk.MainDiscoForm.GetCuePrefs());
|
||||
// var prefs = new CueBinPrefs
|
||||
// {
|
||||
// AnnotateCue = false,
|
||||
// OneBlobPerTrack = false,
|
||||
// ReallyDumpBin = true,
|
||||
// SingleSession = true,
|
||||
// DumpToBitbucket = true
|
||||
// };
|
||||
// var dump = ecmdisc.DumpCueBin("test", prefs);
|
||||
// dump.Dump("test", prefs);
|
||||
|
||||
// //var prefs = new BizHawk.DiscSystem.CueBinPrefs();
|
||||
// //prefs.AnnotateCue = false;
|
||||
// //prefs.OneBlobPerTrack = false;
|
||||
// //prefs.ReallyDumpBin = true;
|
||||
// //prefs.SingleSession = true;
|
||||
// //prefs.DumpToBitbucket = true;
|
||||
// //var dump = ecmdisc.DumpCueBin("test", prefs);
|
||||
// //dump.Dump("test", prefs);
|
||||
// var prefs = new CueBinPrefs
|
||||
// {
|
||||
// AnnotateCue = false,
|
||||
// OneBlobPerTrack = false,
|
||||
// ReallyDumpBin = true,
|
||||
// SingleSession = true
|
||||
// };
|
||||
// var dump = ecmdisc.DumpCueBin("test", prefs);
|
||||
// dump.Dump(@"D:\ecmtest\myout", prefs);
|
||||
|
||||
// //var prefs = new BizHawk.DiscSystem.CueBinPrefs();
|
||||
// //prefs.AnnotateCue = false;
|
||||
// //prefs.OneBlobPerTrack = false;
|
||||
// //prefs.ReallyDumpBin = true;
|
||||
// //prefs.SingleSession = true;
|
||||
// //var dump = ecmdisc.DumpCueBin("test", prefs);
|
||||
// //dump.Dump(@"D:\ecmtest\myout", prefs);
|
||||
int seed = 102;
|
||||
|
||||
// int seed = 102;
|
||||
for (; ; )
|
||||
{
|
||||
Console.WriteLine("running seed {0}", seed);
|
||||
Random r = new Random(seed);
|
||||
seed++;
|
||||
|
||||
// for (; ; )
|
||||
// {
|
||||
// Console.WriteLine("running seed {0}", seed);
|
||||
// Random r = new Random(seed);
|
||||
// seed++;
|
||||
byte[] chunkbuf_corlet = new byte[2352 * 20];
|
||||
byte[] chunkbuf_mine = new byte[2352 * 20];
|
||||
// int length = (ecmdisc._Sectors.Count - 150) * 2352; // API has changed
|
||||
var length = 0;
|
||||
int counter = 0;
|
||||
List<Tuple<int, int>> testChunks = new List<Tuple<int, int>>();
|
||||
while (counter < length)
|
||||
{
|
||||
int chunk = r.Next(1, 2352 * 20);
|
||||
if (r.Next(20) == 0)
|
||||
chunk /= 100;
|
||||
if (r.Next(40) == 0)
|
||||
chunk = 0;
|
||||
if (counter + chunk > length)
|
||||
chunk = length - counter;
|
||||
testChunks.Add(new Tuple<int, int>(counter, chunk));
|
||||
counter += chunk;
|
||||
}
|
||||
testChunks.Shuffle(r);
|
||||
|
||||
// byte[] chunkbuf_corlet = new byte[2352 * 20];
|
||||
// byte[] chunkbuf_mine = new byte[2352 * 20];
|
||||
// int length = ecmdisc.LBACount * 2352;
|
||||
// int counter = 0;
|
||||
// List<Tuple<int, int>> testChunks = new List<Tuple<int, int>>();
|
||||
// while (counter < length)
|
||||
// {
|
||||
// int chunk = r.Next(1, 2352 * 20);
|
||||
// if (r.Next(20) == 0)
|
||||
// chunk /= 100;
|
||||
// if (r.Next(40) == 0)
|
||||
// chunk = 0;
|
||||
// if (counter + chunk > length)
|
||||
// chunk = length - counter;
|
||||
// testChunks.Add(new Tuple<int, int>(counter, chunk));
|
||||
// counter += chunk;
|
||||
// }
|
||||
// testChunks.Shuffle(r);
|
||||
|
||||
// for (int t = 0; t < testChunks.Count; t++)
|
||||
// {
|
||||
// //Console.WriteLine("skank");
|
||||
// var item = testChunks[t];
|
||||
// //Console.WriteLine("chunk {0} of {3} is {1} bytes @ {2:X8}", t, item.Item2, item.Item1, testChunks.Count);
|
||||
// plaindisc.ReadLBA_2352_Flat(item.Item1, chunkbuf_corlet, 0, item.Item2);
|
||||
// ecmdisc.ReadLBA_2352_Flat(item.Item1, chunkbuf_mine, 0, item.Item2);
|
||||
// for (int i = 0; i < item.Item2; i++)
|
||||
// if (chunkbuf_corlet[i] != chunkbuf_mine[i])
|
||||
// {
|
||||
// Debug.Assert(false);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
for (int t = 0; t < testChunks.Count; t++)
|
||||
{
|
||||
//Console.WriteLine("skank");
|
||||
var item = testChunks[t];
|
||||
//Console.WriteLine("chunk {0} of {3} is {1} bytes @ {2:X8}", t, item.Item2, item.Item1, testChunks.Count);
|
||||
// plaindisc.ReadLBA_2352_Flat(item.Item1, chunkbuf_corlet, 0, item.Item2); // API has changed
|
||||
// ecmdisc.ReadLBA_2352_Flat(item.Item1, chunkbuf_mine, 0, item.Item2); // API has changed
|
||||
for (int i = 0; i < item.Item2; i++)
|
||||
if (chunkbuf_corlet[i] != chunkbuf_mine[i])
|
||||
{
|
||||
Debug.Assert(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
|
@ -70,30 +70,32 @@ namespace BizHawk.Client.DiscoHawk
|
|||
}
|
||||
}
|
||||
|
||||
//bool Dump(CueBin cueBin, string directoryTo, CueBinPrefs prefs)
|
||||
//{
|
||||
// ProgressReport pr = new ProgressReport();
|
||||
// Thread workThread = new Thread(() =>
|
||||
// {
|
||||
// cueBin.Dump(directoryTo, prefs, pr);
|
||||
// });
|
||||
#if false // API has changed
|
||||
bool Dump(CueBin cueBin, string directoryTo, CueBinPrefs prefs)
|
||||
{
|
||||
ProgressReport pr = new ProgressReport();
|
||||
Thread workThread = new Thread(() =>
|
||||
{
|
||||
cueBin.Dump(directoryTo, prefs, pr);
|
||||
});
|
||||
|
||||
// ProgressDialog pd = new ProgressDialog(pr);
|
||||
// pd.Show(this);
|
||||
// this.Enabled = false;
|
||||
// workThread.Start();
|
||||
// for (; ; )
|
||||
// {
|
||||
// Application.DoEvents();
|
||||
// Thread.Sleep(10);
|
||||
// if (workThread.ThreadState != ThreadState.Running)
|
||||
// break;
|
||||
// pd.Update();
|
||||
// }
|
||||
// this.Enabled = true;
|
||||
// pd.Dispose();
|
||||
// return !pr.CancelSignal;
|
||||
//}
|
||||
ProgressDialog pd = new ProgressDialog(pr);
|
||||
pd.Show(this);
|
||||
this.Enabled = false;
|
||||
workThread.Start();
|
||||
for (; ; )
|
||||
{
|
||||
Application.DoEvents();
|
||||
Thread.Sleep(10);
|
||||
if (workThread.ThreadState != ThreadState.Running)
|
||||
break;
|
||||
pd.Update();
|
||||
}
|
||||
this.Enabled = true;
|
||||
pd.Dispose();
|
||||
return !pr.CancelSignal;
|
||||
}
|
||||
#endif
|
||||
|
||||
private void lblMagicDragArea_DragEnter(object sender, DragEventArgs e)
|
||||
{
|
||||
|
|
|
@ -987,35 +987,38 @@ namespace BizHawk.Client.EmuHawk
|
|||
public bool UsesAudio => parameters.has_audio;
|
||||
|
||||
public bool UsesVideo => true;
|
||||
|
||||
#if false // API has changed
|
||||
private static void TestAVI()
|
||||
{
|
||||
AviWriter aw = new AviWriter();
|
||||
aw.SetVideoParameters(256, 256);
|
||||
aw.SetMovieParameters(60, 1);
|
||||
aw.OpenFile("d:\\bizhawk.avi");
|
||||
CreateHandle();
|
||||
var token = aw.AcquireVideoCodecToken(Handle);
|
||||
aw.SetVideoCodecToken(token);
|
||||
aw.OpenStreams();
|
||||
|
||||
for (int i = 0; i < 100; i++)
|
||||
{
|
||||
TestVideoProvider video = new TestVideoProvider();
|
||||
Bitmap bmp = new Bitmap(256, 256, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
|
||||
using (Graphics g = Graphics.FromImage(bmp))
|
||||
{
|
||||
g.Clear(Color.Red);
|
||||
using (Font f = new Font(FontFamily.GenericMonospace, 10))
|
||||
g.DrawString(i.ToString(), f, Brushes.Black, 0, 0);
|
||||
}
|
||||
// bmp.Save($"c:\\dump\\{i}.bmp", ImageFormat.Bmp);
|
||||
for (int y = 0, idx = 0; y < 256; y++)
|
||||
for (int x = 0; x < 256; x++)
|
||||
video.buffer[idx++] = bmp.GetPixel(x, y).ToArgb();
|
||||
aw.AddFrame(video);
|
||||
}
|
||||
aw.CloseStreams();
|
||||
aw.CloseFile();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
////TEST AVI
|
||||
//AviWriter aw = new AviWriter();
|
||||
//aw.SetVideoParameters(256, 256);
|
||||
//aw.SetMovieParameters(60, 1);
|
||||
//aw.OpenFile("d:\\bizhawk.avi");
|
||||
//CreateHandle();
|
||||
//var token = aw.AcquireVideoCodecToken(Handle);
|
||||
//aw.SetVideoCodecToken(token);
|
||||
//aw.OpenStreams();
|
||||
|
||||
//for (int i = 0; i < 100; i++)
|
||||
//{
|
||||
// TestVideoProvider video = new TestVideoProvider();
|
||||
// Bitmap bmp = new Bitmap(256, 256, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
|
||||
// using (Graphics g = Graphics.FromImage(bmp))
|
||||
// {
|
||||
// g.Clear(Color.Red);
|
||||
// using (Font f = new Font(FontFamily.GenericMonospace, 10))
|
||||
// g.DrawString(i.ToString(), f, Brushes.Black, 0, 0);
|
||||
// }
|
||||
// //bmp.Save($"c:\\dump\\{i}.bmp", ImageFormat.Bmp);
|
||||
// for (int y = 0, idx = 0; y < 256; y++)
|
||||
// for (int x = 0; x < 256; x++)
|
||||
// video.buffer[idx++] = bmp.GetPixel(x, y).ToArgb();
|
||||
// aw.AddFrame(video);
|
||||
//}
|
||||
//aw.CloseStreams();
|
||||
//aw.CloseFile();
|
||||
////-----
|
||||
|
|
|
@ -146,20 +146,20 @@ namespace BizHawk.Client.EmuHawk.ToolExtensions
|
|||
};
|
||||
tsdd.Items.Add(tsmiRemovePath);
|
||||
|
||||
////experiment of popping open a submenu. doesnt work well.
|
||||
//item.MouseDown += (o, mev) =>
|
||||
//{
|
||||
// if (mev.Button != MouseButtons.Right) return;
|
||||
// //location of the menu containing this item that was just rightclicked
|
||||
// var pos = item.Owner.Bounds.Location;
|
||||
// //the offset within that menu of this item
|
||||
// var tsddi = item as ToolStripDropDownItem;
|
||||
// pos.Offset(tsddi.Bounds.Location);
|
||||
// //the offset of the click
|
||||
// pos.Offset(mev.Location);
|
||||
// //tsdd.OwnerItem = item; //has interesting promise, but breaks things otherwise
|
||||
// tsdd.Show(pos);
|
||||
//};
|
||||
#if false //experiment of popping open a submenu. doesn't work well.
|
||||
item.MouseDown += (o, mev) =>
|
||||
{
|
||||
if (mev.Button != MouseButtons.Right) return;
|
||||
//location of the menu containing this item that was just right-clicked
|
||||
var pos = item.Owner.Bounds.Location;
|
||||
//the offset within that menu of this item
|
||||
pos.Offset(item.Bounds.Location);
|
||||
//the offset of the click
|
||||
pos.Offset(mev.Location);
|
||||
// tsdd.OwnerItem = item; //has interesting promise, but breaks things otherwise
|
||||
tsdd.Show(pos);
|
||||
};
|
||||
#endif
|
||||
|
||||
//just add it to the submenu for now. seems to work well enough, even though its a bit odd
|
||||
item.MouseDown += (o, mev) =>
|
||||
|
|
|
@ -460,13 +460,14 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
else
|
||||
{
|
||||
// don't do this: for now, it will interfere with the virtualpad. don't do something similar for the mouse position either
|
||||
#if false // don't do this: for now, it will interfere with the virtualpad. don't do something similar for the mouse position either
|
||||
// unpress all buttons
|
||||
//HandleButton("WMouse L", false);
|
||||
//HandleButton("WMouse C", false);
|
||||
//HandleButton("WMouse R", false);
|
||||
//HandleButton("WMouse 1", false);
|
||||
//HandleButton("WMouse 2", false);
|
||||
HandleButton("WMouse L", false, InputFocus.Mouse);
|
||||
HandleButton("WMouse C", false, InputFocus.Mouse);
|
||||
HandleButton("WMouse R", false, InputFocus.Mouse);
|
||||
HandleButton("WMouse 1", false, InputFocus.Mouse);
|
||||
HandleButton("WMouse 2", false, InputFocus.Mouse);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -195,6 +195,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
sortedFiles[LoadOrdering.Rom].Add(fileInformation);
|
||||
}
|
||||
|
||||
#if false
|
||||
/*
|
||||
* This is where handling archives would go.
|
||||
* Right now, that's going to be a HUGE hassle, because of the problem with
|
||||
|
@ -202,26 +203,16 @@ namespace BizHawk.Client.EmuHawk
|
|||
* and not streams (also no), so for the purposes of making drag/drop more robust,
|
||||
* I am not building this out just yet.
|
||||
* -- Adam Michaud (Invariel)
|
||||
|
||||
int offset = 0;
|
||||
bool executable = false;
|
||||
var archiveHandler = new SevenZipSharpArchiveHandler();
|
||||
*/
|
||||
|
||||
// Not going to process nested archives at the moment.
|
||||
if (String.IsNullOrEmpty (archive) && archiveHandler.CheckSignature(file, out offset, out executable))
|
||||
if (string.IsNullOrEmpty(archive) && archiveHandler.CheckSignature(file, out _, out _))
|
||||
{
|
||||
List<string> fileNames = new List<string>();
|
||||
var openedArchive = archiveHandler.Construct (file);
|
||||
|
||||
foreach (BizHawk.Common.HawkFileArchiveItem item in openedArchive.Scan ())
|
||||
fileNames.Add(item.Name);
|
||||
|
||||
ProcessFileList(fileNames.ToArray(), ref sortedFiles, file);
|
||||
|
||||
openedArchive.Dispose();
|
||||
using var openedArchive = archiveHandler.Construct(file);
|
||||
ProcessFileList(openedArchive.Scan().Select(item => item.Name), ref sortedFiles, file);
|
||||
}
|
||||
archiveHandler.Dispose();
|
||||
*/
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -44,7 +44,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
return;
|
||||
}
|
||||
|
||||
//heres some ideas for how to begin cleaning this up
|
||||
#if false
|
||||
//here's some ideas for how to begin cleaning this up
|
||||
////at this point, its assumed that we're running.
|
||||
////this could be a free run, an unthrottled run, or a 'continuous frame advance' (aka continuous) run
|
||||
////free run: affected by frameskips and throttles
|
||||
|
@ -52,16 +53,15 @@ namespace BizHawk.Client.EmuHawk
|
|||
////continuous run: affected by frameskips and throttles
|
||||
////so continuous and free are the same?
|
||||
|
||||
//bool continuous_run = signal_continuousFrameAdvancing;
|
||||
//bool unthrottled_run = signal_unthrottle;
|
||||
//bool free_run = !continuous_run && !unthrottled_run;
|
||||
bool continuous_run = signal_continuousFrameAdvancing;
|
||||
bool unthrottled_run = signal_unthrottle;
|
||||
bool free_run = !continuous_run && !unthrottled_run;
|
||||
|
||||
//bool do_throttle, do_skip;
|
||||
//if (continuous_run || free_run)
|
||||
// do_throttle = do_skip = true;
|
||||
//else if (unthrottled_run)
|
||||
// do_skip = true;
|
||||
//else throw new InvalidOperationException();
|
||||
bool do_throttle, do_skip;
|
||||
if (continuous_run || free_run) do_throttle = do_skip = true;
|
||||
else if (unthrottled_run) do_skip = true;
|
||||
else throw new InvalidOperationException();
|
||||
#endif
|
||||
|
||||
int skipRate = (forceFrameSkip < 0) ? Global.Config.FrameSkip : forceFrameSkip;
|
||||
int ffSkipRate = (forceFrameSkip < 0) ? 3 : forceFrameSkip;
|
||||
|
|
|
@ -371,8 +371,9 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
_lcdc = lcdc;
|
||||
// set alpha on all pixels
|
||||
#if false
|
||||
// TODO: RE: Spriteback, you can't muck with Sameboy in this way due to how SGB reads stuff...?
|
||||
/*unsafe
|
||||
unsafe
|
||||
{
|
||||
int* p = (int*)_bgpal;
|
||||
for (int i = 0; i < 32; i++)
|
||||
|
@ -383,7 +384,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
int c = Spriteback.ToArgb();
|
||||
for (int i = 0; i < 32; i += 4)
|
||||
p[i] = c;
|
||||
}*/
|
||||
}
|
||||
#endif
|
||||
|
||||
// bg maps
|
||||
if (!_cgb)
|
||||
|
|
|
@ -513,6 +513,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
MessageBox.Show("Codebreaker/GameShark SP/Xploder codes are not supported by this tool.", "Tool error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
|
||||
return;
|
||||
|
||||
#if false
|
||||
//WARNING!!
|
||||
//This code is NOT ready yet.
|
||||
//The GameShark Key
|
||||
|
@ -534,54 +535,55 @@ namespace BizHawk.Client.EmuHawk
|
|||
//Decrypted: 82028048 FFFFFFFF
|
||||
//GBACodeBreaker();
|
||||
|
||||
//if (blnCodeBreaker == false)
|
||||
//{
|
||||
// parseString = SingleCheat;
|
||||
// UInt32 op1 = 0;
|
||||
// UInt32 op2 = 0;
|
||||
// UInt32 sum = 0xC6EF3720;
|
||||
// string test1;
|
||||
// string test2;
|
||||
// test1 = parseString.Remove(5, 6);
|
||||
// test2 = parseString.Remove(0, 6);
|
||||
// MessageBox.Show(test1.ToString());
|
||||
// MessageBox.Show(test2.ToString());
|
||||
// op1 = UInt32.Parse(parseString.Remove(5, 6), NumberStyles.HexNumber);
|
||||
// op2 = UInt32.Parse(parseString.Remove(0, 6), NumberStyles.HexNumber);
|
||||
if (blnCodeBreaker == false)
|
||||
{
|
||||
parseString = SingleCheat;
|
||||
UInt32 op1 = 0;
|
||||
UInt32 op2 = 0;
|
||||
UInt32 sum = 0xC6EF3720;
|
||||
string test1;
|
||||
string test2;
|
||||
test1 = parseString.Remove(5, 6);
|
||||
test2 = parseString.Remove(0, 6);
|
||||
MessageBox.Show(test1.ToString());
|
||||
MessageBox.Show(test2.ToString());
|
||||
op1 = UInt32.Parse(parseString.Remove(5, 6), NumberStyles.HexNumber);
|
||||
op2 = UInt32.Parse(parseString.Remove(0, 6), NumberStyles.HexNumber);
|
||||
|
||||
// //Tiny Encryption Algorithm
|
||||
// int i;
|
||||
// for (i = 0; i < 32; ++i)
|
||||
// {
|
||||
// op2 -= ((op1 << 4) + GBAGameSharkSeeds[2]) ^ (op1 + sum) ^ ((op1 >> 5) + GBAGameSharkSeeds[3]);
|
||||
// op1 -= ((op2 << 4) + GBAGameSharkSeeds[0]) ^ (op2 + sum) ^ ((op2 >> 5) + GBAGameSharkSeeds[1]);
|
||||
// sum -= 0x9E3779B9;
|
||||
// }
|
||||
// //op1 has the Address
|
||||
// //op2 has the Value
|
||||
// //Sum, is pointless?
|
||||
// RAMAddress = $"{op1:X8}";
|
||||
// //RAMAddress = RAMAddress.Remove(0, 1);
|
||||
// RAMValue = $"{op2:X8}";
|
||||
// // && RAMAddress[6] == '0'
|
||||
//}
|
||||
//Tiny Encryption Algorithm
|
||||
int i;
|
||||
for (i = 0; i < 32; ++i)
|
||||
{
|
||||
op2 -= ((op1 << 4) + GBAGameSharkSeeds[2]) ^ (op1 + sum) ^ ((op1 >> 5) + GBAGameSharkSeeds[3]);
|
||||
op1 -= ((op2 << 4) + GBAGameSharkSeeds[0]) ^ (op2 + sum) ^ ((op2 >> 5) + GBAGameSharkSeeds[1]);
|
||||
sum -= 0x9E3779B9;
|
||||
}
|
||||
//op1 has the Address
|
||||
//op2 has the Value
|
||||
//Sum, is pointless?
|
||||
RAMAddress = $"{op1:X8}";
|
||||
//RAMAddress = RAMAddress.Remove(0, 1);
|
||||
RAMValue = $"{op2:X8}";
|
||||
// && RAMAddress[6] == '0'
|
||||
}
|
||||
|
||||
//if (blnCodeBreaker == true)
|
||||
//{
|
||||
// //We got a Valid Code Breaker Code. Hopefully.
|
||||
// AddGBA();
|
||||
// return;
|
||||
//}
|
||||
if (blnCodeBreaker == true)
|
||||
{
|
||||
//We got a Valid Code Breaker Code. Hopefully.
|
||||
AddGBA();
|
||||
return;
|
||||
}
|
||||
|
||||
//if (SingleCheat.IndexOf(" ") != 8 && SingleCheat.Length != 12)
|
||||
//{
|
||||
// MessageBox.Show("ALL Codes for Action Replay, Action Replay MAX, Codebreaker, GameShark Advance, GameShark SP, Xploder have a Space after the 8th character.", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
// return;
|
||||
//}
|
||||
////We have a code
|
||||
//if (blnNoCode == false)
|
||||
//{
|
||||
//}
|
||||
if (SingleCheat.IndexOf(" ") != 8 && SingleCheat.Length != 12)
|
||||
{
|
||||
MessageBox.Show("ALL Codes for Action Replay, Action Replay MAX, Codebreaker, GameShark Advance, GameShark SP, Xploder have a Space after the 8th character.", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
//We have a code
|
||||
if (blnNoCode == false)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2257,13 +2257,14 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
}
|
||||
|
||||
// if needed
|
||||
////var mat = new SlimDX.Matrix();
|
||||
////mat.M11 = matVals[0, 0]; mat.M12 = matVals[0, 1]; mat.M13 = matVals[0, 2]; mat.M14 = matVals[0, 3];
|
||||
////mat.M21 = matVals[1, 0]; mat.M22 = matVals[1, 1]; mat.M23 = matVals[1, 2]; mat.M24 = matVals[1, 3];
|
||||
////mat.M31 = matVals[2, 0]; mat.M32 = matVals[2, 1]; mat.M33 = matVals[2, 2]; mat.M34 = matVals[2, 3];
|
||||
////mat.M41 = matVals[3, 0]; mat.M42 = matVals[3, 1]; mat.M43 = matVals[3, 2]; mat.M44 = matVals[3, 3];
|
||||
////MessageBox.Show(mat.ToString());
|
||||
#if false // if needed
|
||||
MessageBox.Show(new SlimDX.Matrix {
|
||||
M11 = matVals[0, 0], M12 = matVals[0, 1], M13 = matVals[0, 2], M14 = matVals[0, 3],
|
||||
M21 = matVals[1, 0], M22 = matVals[1, 1], M23 = matVals[1, 2], M24 = matVals[1, 3],
|
||||
M31 = matVals[2, 0], M32 = matVals[2, 1], M33 = matVals[2, 2], M34 = matVals[2, 3],
|
||||
M41 = matVals[3, 0], M42 = matVals[3, 1], M43 = matVals[3, 2], M44 = matVals[3, 3]
|
||||
}.ToString());
|
||||
#endif
|
||||
|
||||
using var sw = new StringWriter();
|
||||
for (int i = 0; i < 4; i++)
|
||||
|
|
|
@ -1205,16 +1205,11 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void SyncBackdropColor()
|
||||
{
|
||||
#if false
|
||||
//TODO
|
||||
//if (checkBackdropColor.Checked)
|
||||
//{
|
||||
// int col = DecodeWinformsColorToSNES(pnBackdropColor.BackColor);
|
||||
// LibsnesDll.snes_set_backdropColor(col);
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// LibsnesDll.snes_set_backdropColor(-1);
|
||||
//}
|
||||
LibsnesApi dll = TODO;
|
||||
dll.QUERY_set_backdropColor(DecodeWinformsColorToSNES(checkBackdropColor.Checked ? pnBackdropColor.BackColor : Color.FromArgb(-1)));
|
||||
#endif
|
||||
}
|
||||
|
||||
private void checkBackdropColor_CheckedChanged(object sender, EventArgs e)
|
||||
|
|
|
@ -139,10 +139,10 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void lvDiscs_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
//not a valid way to fight unselection, it results in craptons of ping-ponging logic and eventual malfunction
|
||||
//if (lvDiscs.SelectedIndices.Count == 0)
|
||||
// lvDiscs.SelectedIndices.Add(0);
|
||||
//Global.StickyXORAdapter.SetFloat(_discSelectName, lvDiscs.SelectedIndices[0]);
|
||||
#if false // not a valid way to fight unselection, it results in craptons of ping-ponging logic and eventual malfunction
|
||||
if (lvDiscs.SelectedIndices.Count == 0) lvDiscs.SelectedIndices.Add(0);
|
||||
Global.StickyXORAdapter.SetFloat(_discSelectName, lvDiscs.SelectedIndices[0]);
|
||||
#endif
|
||||
|
||||
//emergency measure: if no selection, set no disc
|
||||
if (lvDiscs.SelectedIndices.Count == 0)
|
||||
|
|
|
@ -34,7 +34,8 @@
|
|||
}
|
||||
}
|
||||
|
||||
/*TriangleWave = new short[512];
|
||||
#if false
|
||||
TriangleWave = new short[512];
|
||||
for (int i = 0; i < 256; i++)
|
||||
TriangleWave[i] = (short)((ushort.MaxValue*i/256)-short.MinValue);
|
||||
for (int i = 0; i < 256; i++)
|
||||
|
@ -49,7 +50,8 @@
|
|||
for (int i=0; i<1024; i++)
|
||||
{
|
||||
SineWave[i] = (short) (Math.Sin(i*Math.PI*2/1024d)*32767);
|
||||
}*/
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
|
@ -51,47 +51,49 @@ namespace BizHawk.Emulation.DiscSystem
|
|||
mednadisc_ReadSector(handle, LBA, pBuffer + offset);
|
||||
}
|
||||
|
||||
//public void ReadSubcodeDeinterleaved(int LBA, byte[] buffer, int offset)
|
||||
//{
|
||||
// fixed (byte* pBuffer = buf2442)
|
||||
// mednadisc_ReadSector(handle, LBA, pBuffer);
|
||||
// SubcodeUtils.Deinterleave(buf2442, 2352, buffer, offset);
|
||||
//}
|
||||
#if false
|
||||
public void ReadSubcodeDeinterleaved(int LBA, byte[] buffer, int offset)
|
||||
{
|
||||
fixed (byte* pBuffer = buf2442)
|
||||
mednadisc_ReadSector(handle, LBA, pBuffer);
|
||||
SynthUtils.DeinterleaveSubcode(buf2442, 2352, buffer, offset);
|
||||
}
|
||||
|
||||
//public void ReadSubcodeChannel(int LBA, int number, byte[] buffer, int offset)
|
||||
//{
|
||||
// fixed (byte* pBuffer = buf2442)
|
||||
// mednadisc_ReadSector(handle, LBA, pBuffer);
|
||||
// SubcodeUtils.Deinterleave(buf2442, 2352, buf96, 0);
|
||||
// for (int i = 0; i < 12; i++)
|
||||
// buffer[offset + i] = buf96[number * 12 + i];
|
||||
//}
|
||||
public void ReadSubcodeChannel(int LBA, int number, byte[] buffer, int offset)
|
||||
{
|
||||
fixed (byte* pBuffer = buf2442)
|
||||
mednadisc_ReadSector(handle, LBA, pBuffer);
|
||||
SynthUtils.DeinterleaveSubcode(buf2442, 2352, buf96, 0);
|
||||
for (int i = 0; i < 12; i++)
|
||||
buffer[offset + i] = buf96[number * 12 + i];
|
||||
}
|
||||
|
||||
//public void Read_2352(int LBA, byte[] buffer, int offset)
|
||||
//{
|
||||
// fixed (byte* pBuffer = buf2442)
|
||||
// mednadisc_ReadSector(handle, LBA, pBuffer);
|
||||
// Buffer.BlockCopy(buf2442, 0, buffer, offset, 2352);
|
||||
//}
|
||||
public void Read_2352(int LBA, byte[] buffer, int offset)
|
||||
{
|
||||
fixed (byte* pBuffer = buf2442)
|
||||
mednadisc_ReadSector(handle, LBA, pBuffer);
|
||||
Buffer.BlockCopy(buf2442, 0, buffer, offset, 2352);
|
||||
}
|
||||
|
||||
//public void Read_2048(int LBA, byte[] buffer, int offset)
|
||||
//{
|
||||
// //this depends on CD-XA mode and such. so we need to read the mode bytes
|
||||
// //HEY!!!!!! SHOULD THIS BE DONE BASED ON THE CLAIMED TRACK TYPE, OR ON WHATS IN THE SECTOR?
|
||||
// //this is kind of a function of the CD reader.. it's not clear how this function should work.
|
||||
// //YIKES!!!!!!!!!!!!!!
|
||||
// //well, we need to scrutinize it for CCD files anyway, so...
|
||||
// //this sucks.
|
||||
public void Read_2048(int LBA, byte[] buffer, int offset)
|
||||
{
|
||||
//this depends on CD-XA mode and such. so we need to read the mode bytes
|
||||
//HEY!!!!!! SHOULD THIS BE DONE BASED ON THE CLAIMED TRACK TYPE, OR ON WHATS IN THE SECTOR?
|
||||
//this is kind of a function of the CD reader.. it's not clear how this function should work.
|
||||
//YIKES!!!!!!!!!!!!!!
|
||||
//well, we need to scrutinize it for CCD files anyway, so...
|
||||
//this sucks.
|
||||
|
||||
// fixed (byte* pBuffer = buf2442)
|
||||
// mednadisc_ReadSector(handle, LBA, pBuffer);
|
||||
fixed (byte* pBuffer = buf2442)
|
||||
mednadisc_ReadSector(handle, LBA, pBuffer);
|
||||
|
||||
// byte mode = buf2442[15];
|
||||
// if (mode == 1)
|
||||
// Buffer.BlockCopy(buf2442, 16, buffer, offset, 2048);
|
||||
// else
|
||||
// Buffer.BlockCopy(buf2442, 24, buffer, offset, 2048); //PSX assumptions about CD-XA.. BAD BAD BAD
|
||||
//}
|
||||
byte mode = buf2442[15];
|
||||
if (mode == 1)
|
||||
Buffer.BlockCopy(buf2442, 16, buffer, offset, 2048);
|
||||
else
|
||||
Buffer.BlockCopy(buf2442, 24, buffer, offset, 2048); //PSX assumptions about CD-XA.. BAD BAD BAD
|
||||
}
|
||||
#endif
|
||||
|
||||
static void CheckLibrary()
|
||||
{
|
||||
|
|
|
@ -287,51 +287,51 @@ namespace BizHawk.Emulation.DiscSystem
|
|||
SetSectorAddress(src, src_offset, address);
|
||||
}
|
||||
|
||||
#if false
|
||||
/// <summary>
|
||||
/// Finite Field math helpers. Adapted from: http://en.wikiversity.org/wiki/Reed%E2%80%93Solomon_codes_for_coders
|
||||
/// Only used by alternative implementations of ECM techniques
|
||||
/// </summary>
|
||||
static class FFUtil
|
||||
{
|
||||
public static byte gf_div(byte x, byte y)
|
||||
{
|
||||
if (y == 0)
|
||||
return 0; //? error ?
|
||||
if (x == 0)
|
||||
return 0;
|
||||
int q = gf_log[x] + 255 - gf_log[y];
|
||||
return gf_exp[q];
|
||||
}
|
||||
|
||||
///// <summary>
|
||||
///// Finite Field math helpers. Adapted from: http://en.wikiversity.org/wiki/Reed%E2%80%93Solomon_codes_for_coders
|
||||
///// Only used by alternative implementations of ECM techniques
|
||||
///// </summary>
|
||||
//static class FFUtil
|
||||
//{
|
||||
// public static byte gf_div(byte x, byte y)
|
||||
// {
|
||||
// if (y == 0)
|
||||
// return 0; //? error ?
|
||||
// if (x == 0)
|
||||
// return 0;
|
||||
// int q = gf_log[x] + 255 - gf_log[y];
|
||||
// return gf_exp[q];
|
||||
// }
|
||||
public static byte gf_mul(byte x, byte y)
|
||||
{
|
||||
if (x == 0 || y == 0)
|
||||
return 0;
|
||||
return gf_exp[gf_log[x] + gf_log[y]];
|
||||
}
|
||||
|
||||
// public static byte gf_mul(byte x, byte y)
|
||||
// {
|
||||
// if (x == 0 || y == 0)
|
||||
// return 0;
|
||||
// return gf_exp[gf_log[x] + gf_log[y]];
|
||||
// }
|
||||
|
||||
// static byte[] gf_exp = new byte[512];
|
||||
// static byte[] gf_log = new byte[256];
|
||||
// static FFUtil()
|
||||
// {
|
||||
// for (int i = 0; i < 512; i++) gf_exp[i] = 1;
|
||||
// for (int i = 0; i < 256; i++) gf_log[i] = 0;
|
||||
// int x = 1;
|
||||
// for (int i = 1; i < 255; i++)
|
||||
// {
|
||||
// x <<= 1;
|
||||
// if ((x & 0x100) != 0)
|
||||
// x ^= 0x11d; //yellowbook specified primitive polynomial
|
||||
// gf_exp[i] = (byte)x;
|
||||
// gf_log[x] = (byte)i;
|
||||
// }
|
||||
// for (int i = 255; i < 512; i++)
|
||||
// gf_exp[i] = gf_exp[(byte)(i - 255)];
|
||||
// }
|
||||
|
||||
//} //static class FFUtil
|
||||
static byte[] gf_exp = new byte[512];
|
||||
static byte[] gf_log = new byte[256];
|
||||
static FFUtil()
|
||||
{
|
||||
for (int i = 0; i < 512; i++) gf_exp[i] = 1;
|
||||
for (int i = 0; i < 256; i++) gf_log[i] = 0;
|
||||
int x = 1;
|
||||
for (int i = 1; i < 255; i++)
|
||||
{
|
||||
x <<= 1;
|
||||
if ((x & 0x100) != 0)
|
||||
x ^= 0x11d; //yellowbook specified primitive polynomial
|
||||
gf_exp[i] = (byte)x;
|
||||
gf_log[x] = (byte)i;
|
||||
}
|
||||
for (int i = 255; i < 512; i++)
|
||||
gf_exp[i] = gf_exp[(byte)(i - 255)];
|
||||
}
|
||||
|
||||
} //static class FFUtil
|
||||
#endif
|
||||
} //static class ECM
|
||||
|
||||
}
|
||||
|
|
|
@ -1,116 +1,116 @@
|
|||
////-------------------
|
||||
////WARNING GPL CODE
|
||||
////-------------------
|
||||
////
|
||||
////this is stolen somewhat from neill corlett's code. almost certainly some kind of GPL. originally it came from mednafen, and then I think mednafen may have changed to use another. sorry for the confusion!
|
||||
////
|
||||
////it's kept in this project so that we can readily a/b test it against new algorithms
|
||||
//-------------------
|
||||
//WARNING GPL CODE
|
||||
//-------------------
|
||||
//
|
||||
//this is stolen somewhat from neill corlett's code. almost certainly some kind of GPL. originally it came from mednafen, and then I think mednafen may have changed to use another. sorry for the confusion!
|
||||
//
|
||||
//it's kept in this project so that we can readily a/b test it against new algorithms
|
||||
|
||||
//using System.Diagnostics;
|
||||
#if false
|
||||
using System.Diagnostics;
|
||||
|
||||
//namespace BizHawk.DiscSystem
|
||||
//{
|
||||
// public static class GPL_ECM
|
||||
// {
|
||||
// static byte[] ecc_f_lut = new byte[256];
|
||||
// static byte[] ecc_b_lut = new byte[256];
|
||||
// static uint[] edc_lut = new uint[256];
|
||||
namespace BizHawk.DiscSystem
|
||||
{
|
||||
public static class GPL_ECM
|
||||
{
|
||||
static byte[] ecc_f_lut = new byte[256];
|
||||
static byte[] ecc_b_lut = new byte[256];
|
||||
static uint[] edc_lut = new uint[256];
|
||||
|
||||
// static GPL_ECM()
|
||||
// {
|
||||
// uint i, j, edc;
|
||||
// for (i = 0; i < 256; i++)
|
||||
// {
|
||||
// j = (uint)((i << 1) ^ (((i & 0x80) != 0) ? 0x11D : 0));
|
||||
// ecc_f_lut[i] = (byte)j;
|
||||
// ecc_b_lut[i ^ j] = (byte)i;
|
||||
// edc = i;
|
||||
// for (j = 0; j < 8; j++)
|
||||
// edc = (edc >> 1) ^ (((edc & 1) != 0) ? 0xD8018001 : 0);
|
||||
// edc_lut[i] = edc;
|
||||
// }
|
||||
// }
|
||||
static GPL_ECM()
|
||||
{
|
||||
uint i, j, edc;
|
||||
for (i = 0; i < 256; i++)
|
||||
{
|
||||
j = (uint)((i << 1) ^ (((i & 0x80) != 0) ? 0x11D : 0));
|
||||
ecc_f_lut[i] = (byte)j;
|
||||
ecc_b_lut[i ^ j] = (byte)i;
|
||||
edc = i;
|
||||
for (j = 0; j < 8; j++)
|
||||
edc = (edc >> 1) ^ (((edc & 1) != 0) ? 0xD8018001 : 0);
|
||||
edc_lut[i] = edc;
|
||||
}
|
||||
}
|
||||
|
||||
// public static uint edc_partial_computeblock(uint edc, byte[] src, int count)
|
||||
// {
|
||||
// int i = 0;
|
||||
// while (count-- != 0) edc = (edc >> 8) ^ edc_lut[(edc ^ (src[i++])) & 0xFF];
|
||||
// return edc;
|
||||
// }
|
||||
public static uint edc_partial_computeblock(uint edc, byte[] src, int count)
|
||||
{
|
||||
int i = 0;
|
||||
while (count-- != 0) edc = (edc >> 8) ^ edc_lut[(edc ^ (src[i++])) & 0xFF];
|
||||
return edc;
|
||||
}
|
||||
|
||||
// public static void edc_computeblock(byte[] src, int count, byte[] dest, int dest_offset)
|
||||
// {
|
||||
// uint edc = edc_partial_computeblock(0, src, count);
|
||||
// dest[dest_offset + 0] = (byte)((edc >> 0) & 0xFF);
|
||||
// dest[dest_offset + 1] = (byte)((edc >> 8) & 0xFF);
|
||||
// dest[dest_offset + 2] = (byte)((edc >> 16) & 0xFF);
|
||||
// dest[dest_offset + 3] = (byte)((edc >> 24) & 0xFF);
|
||||
// }
|
||||
public static void edc_computeblock(byte[] src, int count, byte[] dest, int dest_offset)
|
||||
{
|
||||
uint edc = edc_partial_computeblock(0, src, count);
|
||||
dest[dest_offset + 0] = (byte)((edc >> 0) & 0xFF);
|
||||
dest[dest_offset + 1] = (byte)((edc >> 8) & 0xFF);
|
||||
dest[dest_offset + 2] = (byte)((edc >> 16) & 0xFF);
|
||||
dest[dest_offset + 3] = (byte)((edc >> 24) & 0xFF);
|
||||
}
|
||||
|
||||
// public static void edc_validateblock(byte[] src, int count, byte[] dest, int dest_offset)
|
||||
// {
|
||||
// uint edc = edc_partial_computeblock(0, src, count);
|
||||
// Debug.Assert(dest[dest_offset + 0] == (byte)((edc >> 0) & 0xFF));
|
||||
// Debug.Assert(dest[dest_offset + 1] == (byte)((edc >> 8) & 0xFF));
|
||||
// Debug.Assert(dest[dest_offset + 2] == (byte)((edc >> 16) & 0xFF));
|
||||
// Debug.Assert(dest[dest_offset + 3] == (byte)((edc >> 24) & 0xFF));
|
||||
// }
|
||||
public static void edc_validateblock(byte[] src, int count, byte[] dest, int dest_offset)
|
||||
{
|
||||
uint edc = edc_partial_computeblock(0, src, count);
|
||||
Debug.Assert(dest[dest_offset + 0] == (byte)((edc >> 0) & 0xFF));
|
||||
Debug.Assert(dest[dest_offset + 1] == (byte)((edc >> 8) & 0xFF));
|
||||
Debug.Assert(dest[dest_offset + 2] == (byte)((edc >> 16) & 0xFF));
|
||||
Debug.Assert(dest[dest_offset + 3] == (byte)((edc >> 24) & 0xFF));
|
||||
}
|
||||
|
||||
// public static void ecc_validateblock(byte[] src, int src_offset, uint major_count, uint minor_count, uint major_mult, uint minor_inc, byte[] dest, int dest_offset)
|
||||
// {
|
||||
// uint size = major_count * minor_count;
|
||||
// uint major, minor;
|
||||
// for (major = 0; major < major_count; major++)
|
||||
// {
|
||||
// uint index = (major >> 1) * major_mult + (major & 1);
|
||||
// byte ecc_a = 0;
|
||||
// byte ecc_b = 0;
|
||||
// for (minor = 0; minor < minor_count; minor++)
|
||||
// {
|
||||
// byte temp = src[src_offset + index];
|
||||
// if ((major >> 1) * major_mult + (major & 1) == 12 && minor_inc == 86)
|
||||
// System.Console.WriteLine(temp);
|
||||
// index += minor_inc;
|
||||
// if (index >= size) index -= size;
|
||||
// ecc_a ^= temp;
|
||||
// ecc_b ^= temp;
|
||||
// ecc_a = ecc_f_lut[ecc_a];
|
||||
// }
|
||||
// ecc_a = ecc_b_lut[ecc_f_lut[ecc_a] ^ ecc_b];
|
||||
// Debug.Assert(dest[dest_offset + major] == ecc_a);
|
||||
// Debug.Assert(dest[dest_offset + major + major_count] == (byte)(ecc_a ^ ecc_b));
|
||||
// }
|
||||
// }
|
||||
public static void ecc_validateblock(byte[] src, int src_offset, uint major_count, uint minor_count, uint major_mult, uint minor_inc, byte[] dest, int dest_offset)
|
||||
{
|
||||
uint size = major_count * minor_count;
|
||||
uint major, minor;
|
||||
for (major = 0; major < major_count; major++)
|
||||
{
|
||||
uint index = (major >> 1) * major_mult + (major & 1);
|
||||
byte ecc_a = 0;
|
||||
byte ecc_b = 0;
|
||||
for (minor = 0; minor < minor_count; minor++)
|
||||
{
|
||||
byte temp = src[src_offset + index];
|
||||
if ((major >> 1) * major_mult + (major & 1) == 12 && minor_inc == 86)
|
||||
System.Console.WriteLine(temp);
|
||||
index += minor_inc;
|
||||
if (index >= size) index -= size;
|
||||
ecc_a ^= temp;
|
||||
ecc_b ^= temp;
|
||||
ecc_a = ecc_f_lut[ecc_a];
|
||||
}
|
||||
ecc_a = ecc_b_lut[ecc_f_lut[ecc_a] ^ ecc_b];
|
||||
Debug.Assert(dest[dest_offset + major] == ecc_a);
|
||||
Debug.Assert(dest[dest_offset + major + major_count] == (byte)(ecc_a ^ ecc_b));
|
||||
}
|
||||
}
|
||||
|
||||
// public unsafe static void ecc_validate(byte[] sector, int sector_offset, bool zeroaddress)
|
||||
// {
|
||||
// byte[] dest = sector;
|
||||
// int dest_offset = sector_offset+2076;
|
||||
|
||||
// byte address0 = 0, address1 = 0, address2 = 0, address3 = 0;
|
||||
// //byte i;
|
||||
// /* Save the address and zero it out */
|
||||
// if (zeroaddress)
|
||||
// {
|
||||
// address0 = sector[sector_offset + 12 + 0]; sector[sector_offset + 12 + 0] = 0;
|
||||
// address1 = sector[sector_offset + 12 + 1]; sector[sector_offset + 12 + 1] = 0;
|
||||
// address2 = sector[sector_offset + 12 + 2]; sector[sector_offset + 12 + 2] = 0;
|
||||
// address3 = sector[sector_offset + 12 + 3]; sector[sector_offset + 12 + 3] = 0;
|
||||
// }
|
||||
// /* Compute ECC P code */
|
||||
// ecc_validateblock(sector, sector_offset + 0xC, 86, 24, 2, 86, dest, dest_offset);
|
||||
// /* Compute ECC Q code */
|
||||
// ecc_validateblock(sector, sector_offset + 0xC, 52, 43, 86, 88, dest, dest_offset + 172);
|
||||
// /* Restore the address */
|
||||
// if (zeroaddress)
|
||||
// {
|
||||
// sector[sector_offset + 12 + 0] = address0;
|
||||
// sector[sector_offset + 12 + 3] = address1;
|
||||
// sector[sector_offset + 12 + 2] = address2;
|
||||
// sector[sector_offset + 12 + 1] = address3;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
//}
|
||||
public unsafe static void ecc_validate(byte[] sector, int sector_offset, bool zeroaddress)
|
||||
{
|
||||
byte[] dest = sector;
|
||||
int dest_offset = sector_offset+2076;
|
||||
|
||||
byte address0 = 0, address1 = 0, address2 = 0, address3 = 0;
|
||||
//byte i;
|
||||
/* Save the address and zero it out */
|
||||
if (zeroaddress)
|
||||
{
|
||||
address0 = sector[sector_offset + 12 + 0]; sector[sector_offset + 12 + 0] = 0;
|
||||
address1 = sector[sector_offset + 12 + 1]; sector[sector_offset + 12 + 1] = 0;
|
||||
address2 = sector[sector_offset + 12 + 2]; sector[sector_offset + 12 + 2] = 0;
|
||||
address3 = sector[sector_offset + 12 + 3]; sector[sector_offset + 12 + 3] = 0;
|
||||
}
|
||||
/* Compute ECC P code */
|
||||
ecc_validateblock(sector, sector_offset + 0xC, 86, 24, 2, 86, dest, dest_offset);
|
||||
/* Compute ECC Q code */
|
||||
ecc_validateblock(sector, sector_offset + 0xC, 52, 43, 86, 88, dest, dest_offset + 172);
|
||||
/* Restore the address */
|
||||
if (zeroaddress)
|
||||
{
|
||||
sector[sector_offset + 12 + 0] = address0;
|
||||
sector[sector_offset + 12 + 3] = address1;
|
||||
sector[sector_offset + 12 + 2] = address2;
|
||||
sector[sector_offset + 12 + 1] = address3;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue