saturnus: support 8mbit/32mbit dram cart as a syncsetting. this inflates your savestate size heavily, of course...

This commit is contained in:
goyuken 2014-02-23 17:06:24 +00:00
parent 17f64cf8f5
commit d7371fcf42
7 changed files with 240 additions and 181 deletions

View File

@ -40,11 +40,14 @@
this.radioButtonFactor = new System.Windows.Forms.RadioButton(); this.radioButtonFactor = new System.Windows.Forms.RadioButton();
this.buttonOK = new System.Windows.Forms.Button(); this.buttonOK = new System.Windows.Forms.Button();
this.buttonCancel = new System.Windows.Forms.Button(); this.buttonCancel = new System.Windows.Forms.Button();
this.groupBox3 = new System.Windows.Forms.GroupBox();
this.comboBoxCartType = new System.Windows.Forms.ComboBox();
this.groupBox1.SuspendLayout(); this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout(); this.groupBox2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownFactor)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDownFactor)).BeginInit();
this.groupBox3.SuspendLayout();
this.SuspendLayout(); this.SuspendLayout();
// //
// groupBox1 // groupBox1
@ -208,7 +211,7 @@
// //
this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonOK.DialogResult = System.Windows.Forms.DialogResult.OK; this.buttonOK.DialogResult = System.Windows.Forms.DialogResult.OK;
this.buttonOK.Location = new System.Drawing.Point(187, 122); this.buttonOK.Location = new System.Drawing.Point(188, 178);
this.buttonOK.Name = "buttonOK"; this.buttonOK.Name = "buttonOK";
this.buttonOK.Size = new System.Drawing.Size(75, 23); this.buttonOK.Size = new System.Drawing.Size(75, 23);
this.buttonOK.TabIndex = 2; this.buttonOK.TabIndex = 2;
@ -220,18 +223,37 @@
// //
this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.buttonCancel.Location = new System.Drawing.Point(268, 122); this.buttonCancel.Location = new System.Drawing.Point(269, 178);
this.buttonCancel.Name = "buttonCancel"; this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(75, 23); this.buttonCancel.Size = new System.Drawing.Size(75, 23);
this.buttonCancel.TabIndex = 3; this.buttonCancel.TabIndex = 3;
this.buttonCancel.Text = "Cancel"; this.buttonCancel.Text = "Cancel";
this.buttonCancel.UseVisualStyleBackColor = true; this.buttonCancel.UseVisualStyleBackColor = true;
// //
// groupBox3
//
this.groupBox3.Controls.Add(this.comboBoxCartType);
this.groupBox3.Location = new System.Drawing.Point(12, 118);
this.groupBox3.Name = "groupBox3";
this.groupBox3.Size = new System.Drawing.Size(332, 54);
this.groupBox3.TabIndex = 4;
this.groupBox3.TabStop = false;
this.groupBox3.Text = "Cartridge Type";
//
// comboBoxCartType
//
this.comboBoxCartType.FormattingEnabled = true;
this.comboBoxCartType.Location = new System.Drawing.Point(6, 19);
this.comboBoxCartType.Name = "comboBoxCartType";
this.comboBoxCartType.Size = new System.Drawing.Size(320, 21);
this.comboBoxCartType.TabIndex = 0;
//
// SaturnPrefs // SaturnPrefs
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(355, 155); this.ClientSize = new System.Drawing.Size(356, 213);
this.Controls.Add(this.groupBox3);
this.Controls.Add(this.buttonCancel); this.Controls.Add(this.buttonCancel);
this.Controls.Add(this.buttonOK); this.Controls.Add(this.buttonOK);
this.Controls.Add(this.groupBox2); this.Controls.Add(this.groupBox2);
@ -247,6 +269,7 @@
((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownFactor)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDownFactor)).EndInit();
this.groupBox3.ResumeLayout(false);
this.ResumeLayout(false); this.ResumeLayout(false);
} }
@ -265,5 +288,7 @@
private System.Windows.Forms.RadioButton radioButtonFactor; private System.Windows.Forms.RadioButton radioButtonFactor;
private System.Windows.Forms.Button buttonOK; private System.Windows.Forms.Button buttonOK;
private System.Windows.Forms.Button buttonCancel; private System.Windows.Forms.Button buttonCancel;
private System.Windows.Forms.GroupBox groupBox3;
private System.Windows.Forms.ComboBox comboBoxCartType;
} }
} }

View File

@ -17,6 +17,7 @@ namespace BizHawk.Client.EmuHawk
public SaturnPrefs() public SaturnPrefs()
{ {
InitializeComponent(); InitializeComponent();
comboBoxCartType.Items.AddRange(Enum.GetNames(typeof(LibYabause.CartType)));
try try
{ {
var ss = (Yabause.SaturnSyncSettings)Global.Emulator.GetSyncSettings(); var ss = (Yabause.SaturnSyncSettings)Global.Emulator.GetSyncSettings();
@ -28,6 +29,7 @@ namespace BizHawk.Client.EmuHawk
numericUpDownFactor.Value = ss.DispFactor; numericUpDownFactor.Value = ss.DispFactor;
numericUpDown1.Value = ss.GLW; numericUpDown1.Value = ss.GLW;
numericUpDown2.Value = ss.GLH; numericUpDown2.Value = ss.GLH;
comboBoxCartType.SelectedItem = Enum.GetName(typeof(LibYabause.CartType), ss.CartType);
} }
catch (ArgumentOutOfRangeException) catch (ArgumentOutOfRangeException)
{ {
@ -53,6 +55,7 @@ namespace BizHawk.Client.EmuHawk
ss.DispFactor = (int)numericUpDownFactor.Value; ss.DispFactor = (int)numericUpDownFactor.Value;
ss.GLW = (int)numericUpDown1.Value; ss.GLW = (int)numericUpDown1.Value;
ss.GLH = (int)numericUpDown2.Value; ss.GLH = (int)numericUpDown2.Value;
ss.CartType = (LibYabause.CartType)Enum.Parse(typeof(LibYabause.CartType), (string)comboBoxCartType.SelectedItem);
GlobalWin.MainForm.PutCoreSyncSettings(ss); GlobalWin.MainForm.PutCoreSyncSettings(ss);
} }
} }

View File

@ -163,6 +163,14 @@ namespace BizHawk.Emulation.Cores.Sega.Saturn
[DllImport("libyabause.dll", CallingConvention = CallingConvention.Cdecl)] [DllImport("libyabause.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern void libyabause_glsetnativefactor(int n); public static extern void libyabause_glsetnativefactor(int n);
public enum CartType : int
{
NONE = 0,
DRAM8MBIT = 6,
DRAM32MBIT = 7
}
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
@ -171,7 +179,7 @@ namespace BizHawk.Emulation.Cores.Sega.Saturn
/// <param name="usegl">true for opengl</param> /// <param name="usegl">true for opengl</param>
/// <returns></returns> /// <returns></returns>
[DllImport("libyabause.dll", CallingConvention = CallingConvention.Cdecl)] [DllImport("libyabause.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern bool libyabause_init(ref CDInterface intf, string biosfn, bool usegl); public static extern bool libyabause_init(ref CDInterface intf, string biosfn, bool usegl, CartType carttype);
public struct CDInterface public struct CDInterface
{ {

View File

@ -82,7 +82,7 @@ namespace BizHawk.Emulation.Cores.Sega.Saturn
string BiosPipe = fp.GetPipeNameNative(); string BiosPipe = fp.GetPipeNameNative();
fp.Offer(bios); fp.Offer(bios);
if (!LibYabause.libyabause_init(ref CDInt, BiosPipe, GL)) if (!LibYabause.libyabause_init(ref CDInt, BiosPipe, GL, SyncSettings.CartType))
throw new Exception("libyabause_init() failed!"); throw new Exception("libyabause_init() failed!");
fp.Finish(); fp.Finish();
@ -670,10 +670,11 @@ namespace BizHawk.Emulation.Cores.Sega.Saturn
public bool DispFree = false; public bool DispFree = false;
public int GLW = 640; public int GLW = 640;
public int GLH = 480; public int GLH = 480;
public LibYabause.CartType CartType = LibYabause.CartType.NONE;
public static bool NeedsReboot(SaturnSyncSettings x, SaturnSyncSettings y) public static bool NeedsReboot(SaturnSyncSettings x, SaturnSyncSettings y)
{ {
return x.UseGL != y.UseGL; return x.UseGL != y.UseGL || x.CartType != y.CartType;
} }
public SaturnSyncSettings Clone() public SaturnSyncSettings Clone()
{ {

Binary file not shown.

View File

@ -1479,6 +1479,15 @@ int CartSaveState(FILE * fp)
fwrite((void *)&CartridgeArea->carttype, 4, 1, fp); fwrite((void *)&CartridgeArea->carttype, 4, 1, fp);
// Write the areas associated with the cart type here // Write the areas associated with the cart type here
switch (CartridgeArea->carttype)
{
case CART_DRAM8MBIT:
fwrite(CartridgeArea->dram, 1, 0x100000, fp);
break;
case CART_DRAM32MBIT:
fwrite(CartridgeArea->dram, 1, 0x400000, fp);
break;
}
return StateFinishHeader(fp, offset); return StateFinishHeader(fp, offset);
} }
@ -1494,6 +1503,19 @@ int CartLoadState(FILE * fp, UNUSED int version, int size)
// Check to see if old cart type and new cart type match, if they don't, // Check to see if old cart type and new cart type match, if they don't,
// reallocate memory areas // reallocate memory areas
if (CartridgeArea->carttype != newtype)
{
// ...
}
switch (CartridgeArea->carttype)
{
case CART_DRAM8MBIT:
fread(CartridgeArea->dram, 1, 0x100000, fp);
break;
case CART_DRAM32MBIT:
fread(CartridgeArea->dram, 1, 0x400000, fp);
break;
}
// Read the areas associated with the cart type here // Read the areas associated with the cart type here

View File

@ -507,7 +507,7 @@ void vdp2newhook(u16 v)
} }
} }
extern "C" __declspec(dllexport) int libyabause_init(CDInterface *_CD, const char *biosfn, int usegl) extern "C" __declspec(dllexport) int libyabause_init(CDInterface *_CD, const char *biosfn, int usegl, int carttype)
{ {
usinggl = usegl; usinggl = usegl;
if (usegl && (!StartGLContext() || !LoadExtensions())) if (usegl && (!StartGLContext() || !LoadExtensions()))
@ -544,7 +544,7 @@ extern "C" __declspec(dllexport) int libyabause_init(CDInterface *_CD, const cha
yinit.cdpath = "Saturnus"; //NULL; yinit.cdpath = "Saturnus"; //NULL;
yinit.buppath = NULL; yinit.buppath = NULL;
yinit.mpegpath = NULL; yinit.mpegpath = NULL;
yinit.cartpath = NULL; yinit.carttype = carttype;
yinit.netlinksetting = NULL; yinit.netlinksetting = NULL;
yinit.videoformattype = VIDEOFORMATTYPE_NTSC; yinit.videoformattype = VIDEOFORMATTYPE_NTSC;