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
|
//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;
|
var joypadAdaptor = Global.AutofireStickyXORAdapter;
|
||||||
for (int i = 1; i <= RunningSystem.MaxControllers; i++)
|
for (var i = 1; i <= RunningSystem.MaxControllers; i++)
|
||||||
{
|
{
|
||||||
joypadAdaptor.SetFloat($"P{i} X Axis", allJoypads[i - 1].AnalogX);
|
joypadAdaptor.SetFloat($"P{i} X Axis", _allJoyPads[i - 1].AnalogX);
|
||||||
joypadAdaptor.SetFloat($"P{i} Y Axis", allJoypads[i - 1].AnalogY);
|
joypadAdaptor.SetFloat($"P{i} Y Axis", _allJoyPads[i - 1].AnalogY);
|
||||||
}
|
}
|
||||||
}*/
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -497,86 +497,92 @@ namespace BizHawk.Client.DiscoHawk
|
||||||
|
|
||||||
} //class 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:
|
public static void TestMain()
|
||||||
//static class test
|
{
|
||||||
//{
|
var plaindisc = Disc.LoadAutomagic("d:\\ecmtest\\test.cue");
|
||||||
// public static void Shuffle<T>(this IList<T> list, Random rng)
|
var ecmdisc = Disc.LoadAutomagic("d:\\ecmtest\\ecmtest.cue");
|
||||||
// {
|
|
||||||
// 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 Test()
|
// var prefs = new CueBinPrefs
|
||||||
// {
|
// {
|
||||||
// var plaindisc = BizHawk.DiscSystem.Disc.FromCuePath("d:\\ecmtest\\test.cue", BizHawk.MainDiscoForm.GetCuePrefs());
|
// AnnotateCue = false,
|
||||||
// var ecmdisc = BizHawk.DiscSystem.Disc.FromCuePath("d:\\ecmtest\\ecmtest.cue", BizHawk.MainDiscoForm.GetCuePrefs());
|
// OneBlobPerTrack = false,
|
||||||
|
// ReallyDumpBin = true,
|
||||||
|
// SingleSession = true,
|
||||||
|
// DumpToBitbucket = true
|
||||||
|
// };
|
||||||
|
// var dump = ecmdisc.DumpCueBin("test", prefs);
|
||||||
|
// dump.Dump("test", prefs);
|
||||||
|
|
||||||
// //var prefs = new BizHawk.DiscSystem.CueBinPrefs();
|
// var prefs = new CueBinPrefs
|
||||||
// //prefs.AnnotateCue = false;
|
// {
|
||||||
// //prefs.OneBlobPerTrack = false;
|
// AnnotateCue = false,
|
||||||
// //prefs.ReallyDumpBin = true;
|
// OneBlobPerTrack = false,
|
||||||
// //prefs.SingleSession = true;
|
// ReallyDumpBin = true,
|
||||||
// //prefs.DumpToBitbucket = true;
|
// SingleSession = true
|
||||||
// //var dump = ecmdisc.DumpCueBin("test", prefs);
|
// };
|
||||||
// //dump.Dump("test", prefs);
|
// var dump = ecmdisc.DumpCueBin("test", prefs);
|
||||||
|
// dump.Dump(@"D:\ecmtest\myout", prefs);
|
||||||
|
|
||||||
// //var prefs = new BizHawk.DiscSystem.CueBinPrefs();
|
int seed = 102;
|
||||||
// //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;
|
for (; ; )
|
||||||
|
{
|
||||||
|
Console.WriteLine("running seed {0}", seed);
|
||||||
|
Random r = new Random(seed);
|
||||||
|
seed++;
|
||||||
|
|
||||||
// for (; ; )
|
byte[] chunkbuf_corlet = new byte[2352 * 20];
|
||||||
// {
|
byte[] chunkbuf_mine = new byte[2352 * 20];
|
||||||
// Console.WriteLine("running seed {0}", seed);
|
// int length = (ecmdisc._Sectors.Count - 150) * 2352; // API has changed
|
||||||
// Random r = new Random(seed);
|
var length = 0;
|
||||||
// seed++;
|
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];
|
for (int t = 0; t < testChunks.Count; t++)
|
||||||
// byte[] chunkbuf_mine = new byte[2352 * 20];
|
{
|
||||||
// int length = ecmdisc.LBACount * 2352;
|
//Console.WriteLine("skank");
|
||||||
// int counter = 0;
|
var item = testChunks[t];
|
||||||
// List<Tuple<int, int>> testChunks = new List<Tuple<int, int>>();
|
//Console.WriteLine("chunk {0} of {3} is {1} bytes @ {2:X8}", t, item.Item2, item.Item1, testChunks.Count);
|
||||||
// while (counter < length)
|
// 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
|
||||||
// int chunk = r.Next(1, 2352 * 20);
|
for (int i = 0; i < item.Item2; i++)
|
||||||
// if (r.Next(20) == 0)
|
if (chunkbuf_corlet[i] != chunkbuf_mine[i])
|
||||||
// chunk /= 100;
|
{
|
||||||
// if (r.Next(40) == 0)
|
Debug.Assert(false);
|
||||||
// chunk = 0;
|
}
|
||||||
// if (counter + chunk > length)
|
}
|
||||||
// chunk = length - counter;
|
}
|
||||||
// testChunks.Add(new Tuple<int, int>(counter, chunk));
|
}
|
||||||
// counter += chunk;
|
}
|
||||||
// }
|
#endif
|
||||||
// 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);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//}
|
|
|
@ -70,30 +70,32 @@ namespace BizHawk.Client.DiscoHawk
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//bool Dump(CueBin cueBin, string directoryTo, CueBinPrefs prefs)
|
#if false // API has changed
|
||||||
//{
|
bool Dump(CueBin cueBin, string directoryTo, CueBinPrefs prefs)
|
||||||
// ProgressReport pr = new ProgressReport();
|
{
|
||||||
// Thread workThread = new Thread(() =>
|
ProgressReport pr = new ProgressReport();
|
||||||
// {
|
Thread workThread = new Thread(() =>
|
||||||
// cueBin.Dump(directoryTo, prefs, pr);
|
{
|
||||||
// });
|
cueBin.Dump(directoryTo, prefs, pr);
|
||||||
|
});
|
||||||
|
|
||||||
// ProgressDialog pd = new ProgressDialog(pr);
|
ProgressDialog pd = new ProgressDialog(pr);
|
||||||
// pd.Show(this);
|
pd.Show(this);
|
||||||
// this.Enabled = false;
|
this.Enabled = false;
|
||||||
// workThread.Start();
|
workThread.Start();
|
||||||
// for (; ; )
|
for (; ; )
|
||||||
// {
|
{
|
||||||
// Application.DoEvents();
|
Application.DoEvents();
|
||||||
// Thread.Sleep(10);
|
Thread.Sleep(10);
|
||||||
// if (workThread.ThreadState != ThreadState.Running)
|
if (workThread.ThreadState != ThreadState.Running)
|
||||||
// break;
|
break;
|
||||||
// pd.Update();
|
pd.Update();
|
||||||
// }
|
}
|
||||||
// this.Enabled = true;
|
this.Enabled = true;
|
||||||
// pd.Dispose();
|
pd.Dispose();
|
||||||
// return !pr.CancelSignal;
|
return !pr.CancelSignal;
|
||||||
//}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
private void lblMagicDragArea_DragEnter(object sender, DragEventArgs e)
|
private void lblMagicDragArea_DragEnter(object sender, DragEventArgs e)
|
||||||
{
|
{
|
||||||
|
|
|
@ -987,35 +987,38 @@ namespace BizHawk.Client.EmuHawk
|
||||||
public bool UsesAudio => parameters.has_audio;
|
public bool UsesAudio => parameters.has_audio;
|
||||||
|
|
||||||
public bool UsesVideo => true;
|
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);
|
tsdd.Items.Add(tsmiRemovePath);
|
||||||
|
|
||||||
////experiment of popping open a submenu. doesnt work well.
|
#if false //experiment of popping open a submenu. doesn't work well.
|
||||||
//item.MouseDown += (o, mev) =>
|
item.MouseDown += (o, mev) =>
|
||||||
//{
|
{
|
||||||
// if (mev.Button != MouseButtons.Right) return;
|
if (mev.Button != MouseButtons.Right) return;
|
||||||
// //location of the menu containing this item that was just rightclicked
|
//location of the menu containing this item that was just right-clicked
|
||||||
// var pos = item.Owner.Bounds.Location;
|
var pos = item.Owner.Bounds.Location;
|
||||||
// //the offset within that menu of this item
|
//the offset within that menu of this item
|
||||||
// var tsddi = item as ToolStripDropDownItem;
|
pos.Offset(item.Bounds.Location);
|
||||||
// pos.Offset(tsddi.Bounds.Location);
|
//the offset of the click
|
||||||
// //the offset of the click
|
pos.Offset(mev.Location);
|
||||||
// pos.Offset(mev.Location);
|
// tsdd.OwnerItem = item; //has interesting promise, but breaks things otherwise
|
||||||
// //tsdd.OwnerItem = item; //has interesting promise, but breaks things otherwise
|
tsdd.Show(pos);
|
||||||
// tsdd.Show(pos);
|
};
|
||||||
//};
|
#endif
|
||||||
|
|
||||||
//just add it to the submenu for now. seems to work well enough, even though its a bit odd
|
//just add it to the submenu for now. seems to work well enough, even though its a bit odd
|
||||||
item.MouseDown += (o, mev) =>
|
item.MouseDown += (o, mev) =>
|
||||||
|
|
|
@ -460,13 +460,14 @@ namespace BizHawk.Client.EmuHawk
|
||||||
}
|
}
|
||||||
else
|
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
|
// unpress all buttons
|
||||||
//HandleButton("WMouse L", false);
|
HandleButton("WMouse L", false, InputFocus.Mouse);
|
||||||
//HandleButton("WMouse C", false);
|
HandleButton("WMouse C", false, InputFocus.Mouse);
|
||||||
//HandleButton("WMouse R", false);
|
HandleButton("WMouse R", false, InputFocus.Mouse);
|
||||||
//HandleButton("WMouse 1", false);
|
HandleButton("WMouse 1", false, InputFocus.Mouse);
|
||||||
//HandleButton("WMouse 2", false);
|
HandleButton("WMouse 2", false, InputFocus.Mouse);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -195,6 +195,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
sortedFiles[LoadOrdering.Rom].Add(fileInformation);
|
sortedFiles[LoadOrdering.Rom].Add(fileInformation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if false
|
||||||
/*
|
/*
|
||||||
* This is where handling archives would go.
|
* This is where handling archives would go.
|
||||||
* Right now, that's going to be a HUGE hassle, because of the problem with
|
* 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,
|
* and not streams (also no), so for the purposes of making drag/drop more robust,
|
||||||
* I am not building this out just yet.
|
* I am not building this out just yet.
|
||||||
* -- Adam Michaud (Invariel)
|
* -- Adam Michaud (Invariel)
|
||||||
|
*/
|
||||||
int offset = 0;
|
|
||||||
bool executable = false;
|
|
||||||
var archiveHandler = new SevenZipSharpArchiveHandler();
|
|
||||||
|
|
||||||
// Not going to process nested archives at the moment.
|
// 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>();
|
using var openedArchive = archiveHandler.Construct(file);
|
||||||
var openedArchive = archiveHandler.Construct (file);
|
ProcessFileList(openedArchive.Scan().Select(item => item.Name), ref sortedFiles, file);
|
||||||
|
|
||||||
foreach (BizHawk.Common.HawkFileArchiveItem item in openedArchive.Scan ())
|
|
||||||
fileNames.Add(item.Name);
|
|
||||||
|
|
||||||
ProcessFileList(fileNames.ToArray(), ref sortedFiles, file);
|
|
||||||
|
|
||||||
openedArchive.Dispose();
|
|
||||||
}
|
}
|
||||||
archiveHandler.Dispose();
|
archiveHandler.Dispose();
|
||||||
*/
|
#endif
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,8 @@ namespace BizHawk.Client.EmuHawk
|
||||||
return;
|
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.
|
////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
|
////this could be a free run, an unthrottled run, or a 'continuous frame advance' (aka continuous) run
|
||||||
////free run: affected by frameskips and throttles
|
////free run: affected by frameskips and throttles
|
||||||
|
@ -52,16 +53,15 @@ namespace BizHawk.Client.EmuHawk
|
||||||
////continuous run: affected by frameskips and throttles
|
////continuous run: affected by frameskips and throttles
|
||||||
////so continuous and free are the same?
|
////so continuous and free are the same?
|
||||||
|
|
||||||
//bool continuous_run = signal_continuousFrameAdvancing;
|
bool continuous_run = signal_continuousFrameAdvancing;
|
||||||
//bool unthrottled_run = signal_unthrottle;
|
bool unthrottled_run = signal_unthrottle;
|
||||||
//bool free_run = !continuous_run && !unthrottled_run;
|
bool free_run = !continuous_run && !unthrottled_run;
|
||||||
|
|
||||||
//bool do_throttle, do_skip;
|
bool do_throttle, do_skip;
|
||||||
//if (continuous_run || free_run)
|
if (continuous_run || free_run) do_throttle = do_skip = true;
|
||||||
// do_throttle = do_skip = true;
|
else if (unthrottled_run) do_skip = true;
|
||||||
//else if (unthrottled_run)
|
else throw new InvalidOperationException();
|
||||||
// do_skip = true;
|
#endif
|
||||||
//else throw new InvalidOperationException();
|
|
||||||
|
|
||||||
int skipRate = (forceFrameSkip < 0) ? Global.Config.FrameSkip : forceFrameSkip;
|
int skipRate = (forceFrameSkip < 0) ? Global.Config.FrameSkip : forceFrameSkip;
|
||||||
int ffSkipRate = (forceFrameSkip < 0) ? 3 : forceFrameSkip;
|
int ffSkipRate = (forceFrameSkip < 0) ? 3 : forceFrameSkip;
|
||||||
|
|
|
@ -371,8 +371,9 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
_lcdc = lcdc;
|
_lcdc = lcdc;
|
||||||
// set alpha on all pixels
|
// 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...?
|
// TODO: RE: Spriteback, you can't muck with Sameboy in this way due to how SGB reads stuff...?
|
||||||
/*unsafe
|
unsafe
|
||||||
{
|
{
|
||||||
int* p = (int*)_bgpal;
|
int* p = (int*)_bgpal;
|
||||||
for (int i = 0; i < 32; i++)
|
for (int i = 0; i < 32; i++)
|
||||||
|
@ -383,7 +384,8 @@ namespace BizHawk.Client.EmuHawk
|
||||||
int c = Spriteback.ToArgb();
|
int c = Spriteback.ToArgb();
|
||||||
for (int i = 0; i < 32; i += 4)
|
for (int i = 0; i < 32; i += 4)
|
||||||
p[i] = c;
|
p[i] = c;
|
||||||
}*/
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// bg maps
|
// bg maps
|
||||||
if (!_cgb)
|
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);
|
MessageBox.Show("Codebreaker/GameShark SP/Xploder codes are not supported by this tool.", "Tool error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
#if false
|
||||||
//WARNING!!
|
//WARNING!!
|
||||||
//This code is NOT ready yet.
|
//This code is NOT ready yet.
|
||||||
//The GameShark Key
|
//The GameShark Key
|
||||||
|
@ -534,54 +535,55 @@ namespace BizHawk.Client.EmuHawk
|
||||||
//Decrypted: 82028048 FFFFFFFF
|
//Decrypted: 82028048 FFFFFFFF
|
||||||
//GBACodeBreaker();
|
//GBACodeBreaker();
|
||||||
|
|
||||||
//if (blnCodeBreaker == false)
|
if (blnCodeBreaker == false)
|
||||||
//{
|
{
|
||||||
// parseString = SingleCheat;
|
parseString = SingleCheat;
|
||||||
// UInt32 op1 = 0;
|
UInt32 op1 = 0;
|
||||||
// UInt32 op2 = 0;
|
UInt32 op2 = 0;
|
||||||
// UInt32 sum = 0xC6EF3720;
|
UInt32 sum = 0xC6EF3720;
|
||||||
// string test1;
|
string test1;
|
||||||
// string test2;
|
string test2;
|
||||||
// test1 = parseString.Remove(5, 6);
|
test1 = parseString.Remove(5, 6);
|
||||||
// test2 = parseString.Remove(0, 6);
|
test2 = parseString.Remove(0, 6);
|
||||||
// MessageBox.Show(test1.ToString());
|
MessageBox.Show(test1.ToString());
|
||||||
// MessageBox.Show(test2.ToString());
|
MessageBox.Show(test2.ToString());
|
||||||
// op1 = UInt32.Parse(parseString.Remove(5, 6), NumberStyles.HexNumber);
|
op1 = UInt32.Parse(parseString.Remove(5, 6), NumberStyles.HexNumber);
|
||||||
// op2 = UInt32.Parse(parseString.Remove(0, 6), NumberStyles.HexNumber);
|
op2 = UInt32.Parse(parseString.Remove(0, 6), NumberStyles.HexNumber);
|
||||||
|
|
||||||
// //Tiny Encryption Algorithm
|
//Tiny Encryption Algorithm
|
||||||
// int i;
|
int i;
|
||||||
// for (i = 0; i < 32; ++i)
|
for (i = 0; i < 32; ++i)
|
||||||
// {
|
{
|
||||||
// op2 -= ((op1 << 4) + GBAGameSharkSeeds[2]) ^ (op1 + sum) ^ ((op1 >> 5) + GBAGameSharkSeeds[3]);
|
op2 -= ((op1 << 4) + GBAGameSharkSeeds[2]) ^ (op1 + sum) ^ ((op1 >> 5) + GBAGameSharkSeeds[3]);
|
||||||
// op1 -= ((op2 << 4) + GBAGameSharkSeeds[0]) ^ (op2 + sum) ^ ((op2 >> 5) + GBAGameSharkSeeds[1]);
|
op1 -= ((op2 << 4) + GBAGameSharkSeeds[0]) ^ (op2 + sum) ^ ((op2 >> 5) + GBAGameSharkSeeds[1]);
|
||||||
// sum -= 0x9E3779B9;
|
sum -= 0x9E3779B9;
|
||||||
// }
|
}
|
||||||
// //op1 has the Address
|
//op1 has the Address
|
||||||
// //op2 has the Value
|
//op2 has the Value
|
||||||
// //Sum, is pointless?
|
//Sum, is pointless?
|
||||||
// RAMAddress = $"{op1:X8}";
|
RAMAddress = $"{op1:X8}";
|
||||||
// //RAMAddress = RAMAddress.Remove(0, 1);
|
//RAMAddress = RAMAddress.Remove(0, 1);
|
||||||
// RAMValue = $"{op2:X8}";
|
RAMValue = $"{op2:X8}";
|
||||||
// // && RAMAddress[6] == '0'
|
// && RAMAddress[6] == '0'
|
||||||
//}
|
}
|
||||||
|
|
||||||
//if (blnCodeBreaker == true)
|
if (blnCodeBreaker == true)
|
||||||
//{
|
{
|
||||||
// //We got a Valid Code Breaker Code. Hopefully.
|
//We got a Valid Code Breaker Code. Hopefully.
|
||||||
// AddGBA();
|
AddGBA();
|
||||||
// return;
|
return;
|
||||||
//}
|
}
|
||||||
|
|
||||||
//if (SingleCheat.IndexOf(" ") != 8 && SingleCheat.Length != 12)
|
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);
|
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;
|
return;
|
||||||
//}
|
}
|
||||||
////We have a code
|
//We have a code
|
||||||
//if (blnNoCode == false)
|
if (blnNoCode == false)
|
||||||
//{
|
{
|
||||||
//}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2257,13 +2257,14 @@ namespace BizHawk.Client.EmuHawk
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// if needed
|
#if false // if needed
|
||||||
////var mat = new SlimDX.Matrix();
|
MessageBox.Show(new SlimDX.Matrix {
|
||||||
////mat.M11 = matVals[0, 0]; mat.M12 = matVals[0, 1]; mat.M13 = matVals[0, 2]; mat.M14 = matVals[0, 3];
|
M11 = matVals[0, 0], M12 = matVals[0, 1], M13 = matVals[0, 2], M14 = matVals[0, 3],
|
||||||
////mat.M21 = matVals[1, 0]; mat.M22 = matVals[1, 1]; mat.M23 = matVals[1, 2]; mat.M24 = matVals[1, 3];
|
M21 = matVals[1, 0], M22 = matVals[1, 1], M23 = matVals[1, 2], M24 = matVals[1, 3],
|
||||||
////mat.M31 = matVals[2, 0]; mat.M32 = matVals[2, 1]; mat.M33 = matVals[2, 2]; mat.M34 = matVals[2, 3];
|
M31 = matVals[2, 0], M32 = matVals[2, 1], M33 = matVals[2, 2], M34 = matVals[2, 3],
|
||||||
////mat.M41 = matVals[3, 0]; mat.M42 = matVals[3, 1]; mat.M43 = matVals[3, 2]; mat.M44 = matVals[3, 3];
|
M41 = matVals[3, 0], M42 = matVals[3, 1], M43 = matVals[3, 2], M44 = matVals[3, 3]
|
||||||
////MessageBox.Show(mat.ToString());
|
}.ToString());
|
||||||
|
#endif
|
||||||
|
|
||||||
using var sw = new StringWriter();
|
using var sw = new StringWriter();
|
||||||
for (int i = 0; i < 4; i++)
|
for (int i = 0; i < 4; i++)
|
||||||
|
|
|
@ -1205,16 +1205,11 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
private void SyncBackdropColor()
|
private void SyncBackdropColor()
|
||||||
{
|
{
|
||||||
|
#if false
|
||||||
//TODO
|
//TODO
|
||||||
//if (checkBackdropColor.Checked)
|
LibsnesApi dll = TODO;
|
||||||
//{
|
dll.QUERY_set_backdropColor(DecodeWinformsColorToSNES(checkBackdropColor.Checked ? pnBackdropColor.BackColor : Color.FromArgb(-1)));
|
||||||
// int col = DecodeWinformsColorToSNES(pnBackdropColor.BackColor);
|
#endif
|
||||||
// LibsnesDll.snes_set_backdropColor(col);
|
|
||||||
//}
|
|
||||||
//else
|
|
||||||
//{
|
|
||||||
// LibsnesDll.snes_set_backdropColor(-1);
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkBackdropColor_CheckedChanged(object sender, EventArgs e)
|
private void checkBackdropColor_CheckedChanged(object sender, EventArgs e)
|
||||||
|
|
|
@ -139,10 +139,10 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
private void lvDiscs_SelectedIndexChanged(object sender, EventArgs e)
|
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 false // not a valid way to fight unselection, it results in craptons of ping-ponging logic and eventual malfunction
|
||||||
//if (lvDiscs.SelectedIndices.Count == 0)
|
if (lvDiscs.SelectedIndices.Count == 0) lvDiscs.SelectedIndices.Add(0);
|
||||||
// lvDiscs.SelectedIndices.Add(0);
|
Global.StickyXORAdapter.SetFloat(_discSelectName, lvDiscs.SelectedIndices[0]);
|
||||||
//Global.StickyXORAdapter.SetFloat(_discSelectName, lvDiscs.SelectedIndices[0]);
|
#endif
|
||||||
|
|
||||||
//emergency measure: if no selection, set no disc
|
//emergency measure: if no selection, set no disc
|
||||||
if (lvDiscs.SelectedIndices.Count == 0)
|
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++)
|
for (int i = 0; i < 256; i++)
|
||||||
TriangleWave[i] = (short)((ushort.MaxValue*i/256)-short.MinValue);
|
TriangleWave[i] = (short)((ushort.MaxValue*i/256)-short.MinValue);
|
||||||
for (int i = 0; i < 256; i++)
|
for (int i = 0; i < 256; i++)
|
||||||
|
@ -49,7 +50,8 @@
|
||||||
for (int i=0; i<1024; i++)
|
for (int i=0; i<1024; i++)
|
||||||
{
|
{
|
||||||
SineWave[i] = (short) (Math.Sin(i*Math.PI*2/1024d)*32767);
|
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);
|
mednadisc_ReadSector(handle, LBA, pBuffer + offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
//public void ReadSubcodeDeinterleaved(int LBA, byte[] buffer, int offset)
|
#if false
|
||||||
//{
|
public void ReadSubcodeDeinterleaved(int LBA, byte[] buffer, int offset)
|
||||||
// fixed (byte* pBuffer = buf2442)
|
{
|
||||||
// mednadisc_ReadSector(handle, LBA, pBuffer);
|
fixed (byte* pBuffer = buf2442)
|
||||||
// SubcodeUtils.Deinterleave(buf2442, 2352, buffer, offset);
|
mednadisc_ReadSector(handle, LBA, pBuffer);
|
||||||
//}
|
SynthUtils.DeinterleaveSubcode(buf2442, 2352, buffer, offset);
|
||||||
|
}
|
||||||
|
|
||||||
//public void ReadSubcodeChannel(int LBA, int number, byte[] buffer, int offset)
|
public void ReadSubcodeChannel(int LBA, int number, byte[] buffer, int offset)
|
||||||
//{
|
{
|
||||||
// fixed (byte* pBuffer = buf2442)
|
fixed (byte* pBuffer = buf2442)
|
||||||
// mednadisc_ReadSector(handle, LBA, pBuffer);
|
mednadisc_ReadSector(handle, LBA, pBuffer);
|
||||||
// SubcodeUtils.Deinterleave(buf2442, 2352, buf96, 0);
|
SynthUtils.DeinterleaveSubcode(buf2442, 2352, buf96, 0);
|
||||||
// for (int i = 0; i < 12; i++)
|
for (int i = 0; i < 12; i++)
|
||||||
// buffer[offset + i] = buf96[number * 12 + i];
|
buffer[offset + i] = buf96[number * 12 + i];
|
||||||
//}
|
}
|
||||||
|
|
||||||
//public void Read_2352(int LBA, byte[] buffer, int offset)
|
public void Read_2352(int LBA, byte[] buffer, int offset)
|
||||||
//{
|
{
|
||||||
// fixed (byte* pBuffer = buf2442)
|
fixed (byte* pBuffer = buf2442)
|
||||||
// mednadisc_ReadSector(handle, LBA, pBuffer);
|
mednadisc_ReadSector(handle, LBA, pBuffer);
|
||||||
// Buffer.BlockCopy(buf2442, 0, buffer, offset, 2352);
|
Buffer.BlockCopy(buf2442, 0, buffer, offset, 2352);
|
||||||
//}
|
}
|
||||||
|
|
||||||
//public void Read_2048(int LBA, byte[] buffer, int offset)
|
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
|
//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?
|
//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.
|
//this is kind of a function of the CD reader.. it's not clear how this function should work.
|
||||||
// //YIKES!!!!!!!!!!!!!!
|
//YIKES!!!!!!!!!!!!!!
|
||||||
// //well, we need to scrutinize it for CCD files anyway, so...
|
//well, we need to scrutinize it for CCD files anyway, so...
|
||||||
// //this sucks.
|
//this sucks.
|
||||||
|
|
||||||
// fixed (byte* pBuffer = buf2442)
|
fixed (byte* pBuffer = buf2442)
|
||||||
// mednadisc_ReadSector(handle, LBA, pBuffer);
|
mednadisc_ReadSector(handle, LBA, pBuffer);
|
||||||
|
|
||||||
// byte mode = buf2442[15];
|
byte mode = buf2442[15];
|
||||||
// if (mode == 1)
|
if (mode == 1)
|
||||||
// Buffer.BlockCopy(buf2442, 16, buffer, offset, 2048);
|
Buffer.BlockCopy(buf2442, 16, buffer, offset, 2048);
|
||||||
// else
|
else
|
||||||
// Buffer.BlockCopy(buf2442, 24, buffer, offset, 2048); //PSX assumptions about CD-XA.. BAD BAD BAD
|
Buffer.BlockCopy(buf2442, 24, buffer, offset, 2048); //PSX assumptions about CD-XA.. BAD BAD BAD
|
||||||
//}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static void CheckLibrary()
|
static void CheckLibrary()
|
||||||
{
|
{
|
||||||
|
|
|
@ -287,51 +287,51 @@ namespace BizHawk.Emulation.DiscSystem
|
||||||
SetSectorAddress(src, src_offset, address);
|
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>
|
public static byte gf_mul(byte x, byte y)
|
||||||
///// 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
|
if (x == 0 || y == 0)
|
||||||
///// </summary>
|
return 0;
|
||||||
//static class FFUtil
|
return gf_exp[gf_log[x] + gf_log[y]];
|
||||||
//{
|
}
|
||||||
// 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)
|
static byte[] gf_exp = new byte[512];
|
||||||
// {
|
static byte[] gf_log = new byte[256];
|
||||||
// if (x == 0 || y == 0)
|
static FFUtil()
|
||||||
// return 0;
|
{
|
||||||
// return gf_exp[gf_log[x] + gf_log[y]];
|
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;
|
||||||
// static byte[] gf_exp = new byte[512];
|
for (int i = 1; i < 255; i++)
|
||||||
// static byte[] gf_log = new byte[256];
|
{
|
||||||
// static FFUtil()
|
x <<= 1;
|
||||||
// {
|
if ((x & 0x100) != 0)
|
||||||
// for (int i = 0; i < 512; i++) gf_exp[i] = 1;
|
x ^= 0x11d; //yellowbook specified primitive polynomial
|
||||||
// for (int i = 0; i < 256; i++) gf_log[i] = 0;
|
gf_exp[i] = (byte)x;
|
||||||
// int x = 1;
|
gf_log[x] = (byte)i;
|
||||||
// for (int i = 1; i < 255; i++)
|
}
|
||||||
// {
|
for (int i = 255; i < 512; i++)
|
||||||
// x <<= 1;
|
gf_exp[i] = gf_exp[(byte)(i - 255)];
|
||||||
// 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 class FFUtil
|
||||||
|
#endif
|
||||||
} //static class ECM
|
} //static class ECM
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,116 +1,116 @@
|
||||||
////-------------------
|
//-------------------
|
||||||
////WARNING GPL CODE
|
//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!
|
//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
|
//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
|
namespace BizHawk.DiscSystem
|
||||||
//{
|
{
|
||||||
// public static class GPL_ECM
|
public static class GPL_ECM
|
||||||
// {
|
{
|
||||||
// static byte[] ecc_f_lut = new byte[256];
|
static byte[] ecc_f_lut = new byte[256];
|
||||||
// static byte[] ecc_b_lut = new byte[256];
|
static byte[] ecc_b_lut = new byte[256];
|
||||||
// static uint[] edc_lut = new uint[256];
|
static uint[] edc_lut = new uint[256];
|
||||||
|
|
||||||
// static GPL_ECM()
|
static GPL_ECM()
|
||||||
// {
|
{
|
||||||
// uint i, j, edc;
|
uint i, j, edc;
|
||||||
// for (i = 0; i < 256; i++)
|
for (i = 0; i < 256; i++)
|
||||||
// {
|
{
|
||||||
// j = (uint)((i << 1) ^ (((i & 0x80) != 0) ? 0x11D : 0));
|
j = (uint)((i << 1) ^ (((i & 0x80) != 0) ? 0x11D : 0));
|
||||||
// ecc_f_lut[i] = (byte)j;
|
ecc_f_lut[i] = (byte)j;
|
||||||
// ecc_b_lut[i ^ j] = (byte)i;
|
ecc_b_lut[i ^ j] = (byte)i;
|
||||||
// edc = i;
|
edc = i;
|
||||||
// for (j = 0; j < 8; j++)
|
for (j = 0; j < 8; j++)
|
||||||
// edc = (edc >> 1) ^ (((edc & 1) != 0) ? 0xD8018001 : 0);
|
edc = (edc >> 1) ^ (((edc & 1) != 0) ? 0xD8018001 : 0);
|
||||||
// edc_lut[i] = edc;
|
edc_lut[i] = edc;
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
// public static uint edc_partial_computeblock(uint edc, byte[] src, int count)
|
public static uint edc_partial_computeblock(uint edc, byte[] src, int count)
|
||||||
// {
|
{
|
||||||
// int i = 0;
|
int i = 0;
|
||||||
// while (count-- != 0) edc = (edc >> 8) ^ edc_lut[(edc ^ (src[i++])) & 0xFF];
|
while (count-- != 0) edc = (edc >> 8) ^ edc_lut[(edc ^ (src[i++])) & 0xFF];
|
||||||
// return edc;
|
return edc;
|
||||||
// }
|
}
|
||||||
|
|
||||||
// public static void edc_computeblock(byte[] src, int count, byte[] dest, int dest_offset)
|
public static void edc_computeblock(byte[] src, int count, byte[] dest, int dest_offset)
|
||||||
// {
|
{
|
||||||
// uint edc = edc_partial_computeblock(0, src, count);
|
uint edc = edc_partial_computeblock(0, src, count);
|
||||||
// dest[dest_offset + 0] = (byte)((edc >> 0) & 0xFF);
|
dest[dest_offset + 0] = (byte)((edc >> 0) & 0xFF);
|
||||||
// dest[dest_offset + 1] = (byte)((edc >> 8) & 0xFF);
|
dest[dest_offset + 1] = (byte)((edc >> 8) & 0xFF);
|
||||||
// dest[dest_offset + 2] = (byte)((edc >> 16) & 0xFF);
|
dest[dest_offset + 2] = (byte)((edc >> 16) & 0xFF);
|
||||||
// dest[dest_offset + 3] = (byte)((edc >> 24) & 0xFF);
|
dest[dest_offset + 3] = (byte)((edc >> 24) & 0xFF);
|
||||||
// }
|
}
|
||||||
|
|
||||||
// public static void edc_validateblock(byte[] src, int count, byte[] dest, int dest_offset)
|
public static void edc_validateblock(byte[] src, int count, byte[] dest, int dest_offset)
|
||||||
// {
|
{
|
||||||
// uint edc = edc_partial_computeblock(0, src, count);
|
uint edc = edc_partial_computeblock(0, src, count);
|
||||||
// Debug.Assert(dest[dest_offset + 0] == (byte)((edc >> 0) & 0xFF));
|
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 + 1] == (byte)((edc >> 8) & 0xFF));
|
||||||
// Debug.Assert(dest[dest_offset + 2] == (byte)((edc >> 16) & 0xFF));
|
Debug.Assert(dest[dest_offset + 2] == (byte)((edc >> 16) & 0xFF));
|
||||||
// Debug.Assert(dest[dest_offset + 3] == (byte)((edc >> 24) & 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)
|
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 size = major_count * minor_count;
|
||||||
// uint major, minor;
|
uint major, minor;
|
||||||
// for (major = 0; major < major_count; major++)
|
for (major = 0; major < major_count; major++)
|
||||||
// {
|
{
|
||||||
// uint index = (major >> 1) * major_mult + (major & 1);
|
uint index = (major >> 1) * major_mult + (major & 1);
|
||||||
// byte ecc_a = 0;
|
byte ecc_a = 0;
|
||||||
// byte ecc_b = 0;
|
byte ecc_b = 0;
|
||||||
// for (minor = 0; minor < minor_count; minor++)
|
for (minor = 0; minor < minor_count; minor++)
|
||||||
// {
|
{
|
||||||
// byte temp = src[src_offset + index];
|
byte temp = src[src_offset + index];
|
||||||
// if ((major >> 1) * major_mult + (major & 1) == 12 && minor_inc == 86)
|
if ((major >> 1) * major_mult + (major & 1) == 12 && minor_inc == 86)
|
||||||
// System.Console.WriteLine(temp);
|
System.Console.WriteLine(temp);
|
||||||
// index += minor_inc;
|
index += minor_inc;
|
||||||
// if (index >= size) index -= size;
|
if (index >= size) index -= size;
|
||||||
// ecc_a ^= temp;
|
ecc_a ^= temp;
|
||||||
// ecc_b ^= temp;
|
ecc_b ^= temp;
|
||||||
// ecc_a = ecc_f_lut[ecc_a];
|
ecc_a = ecc_f_lut[ecc_a];
|
||||||
// }
|
}
|
||||||
// ecc_a = ecc_b_lut[ecc_f_lut[ecc_a] ^ ecc_b];
|
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] == ecc_a);
|
||||||
// Debug.Assert(dest[dest_offset + major + major_count] == (byte)(ecc_a ^ ecc_b));
|
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)
|
public unsafe static void ecc_validate(byte[] sector, int sector_offset, bool zeroaddress)
|
||||||
// {
|
{
|
||||||
// byte[] dest = sector;
|
byte[] dest = sector;
|
||||||
// int dest_offset = sector_offset+2076;
|
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;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
//}
|
|
||||||
|
|
||||||
|
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