lynx: saveram. unfortunately, handy gives every cart with only a single ROM bank a saveram, whether or not it's needed or used. perhaps a future gamedb project, perhaps not...
This commit is contained in:
parent
d46ca2357e
commit
d9258cc4b9
|
@ -24,6 +24,9 @@ namespace BizHawk.Emulation.Cores.Atari.Lynx
|
||||||
[DllImport(dllname, CallingConvention = cc)]
|
[DllImport(dllname, CallingConvention = cc)]
|
||||||
public static extern void Advance(IntPtr s, Buttons buttons, int[] vbuff, short[] sbuff, ref int sbuffsize);
|
public static extern void Advance(IntPtr s, Buttons buttons, int[] vbuff, short[] sbuff, ref int sbuffsize);
|
||||||
|
|
||||||
|
[DllImport(dllname, CallingConvention = cc)]
|
||||||
|
public static extern bool GetSaveRamPtr(IntPtr s, out int size, out IntPtr data);
|
||||||
|
|
||||||
[Flags]
|
[Flags]
|
||||||
public enum Buttons : ushort
|
public enum Buttons : ushort
|
||||||
{
|
{
|
||||||
|
|
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
using BizHawk.Common;
|
using BizHawk.Common;
|
||||||
using BizHawk.Emulation.Common;
|
using BizHawk.Emulation.Common;
|
||||||
|
@ -218,22 +219,38 @@ namespace BizHawk.Emulation.Cores.Atari.Lynx
|
||||||
|
|
||||||
public byte[] CloneSaveRam()
|
public byte[] CloneSaveRam()
|
||||||
{
|
{
|
||||||
return new byte[0];
|
int size;
|
||||||
|
IntPtr data;
|
||||||
|
if (!LibLynx.GetSaveRamPtr(Core, out size, out data))
|
||||||
|
return null;
|
||||||
|
byte[] ret = new byte[size];
|
||||||
|
Marshal.Copy(data, ret, 0, size);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void StoreSaveRam(byte[] data)
|
public void StoreSaveRam(byte[] srcdata)
|
||||||
{
|
{
|
||||||
|
int size;
|
||||||
|
IntPtr data;
|
||||||
|
if (!LibLynx.GetSaveRamPtr(Core, out size, out data))
|
||||||
|
throw new InvalidOperationException();
|
||||||
|
if (size != srcdata.Length)
|
||||||
|
throw new ArgumentOutOfRangeException();
|
||||||
|
Marshal.Copy(srcdata, 0, data, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ClearSaveRam()
|
public void ClearSaveRam()
|
||||||
{
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool SaveRamModified
|
public bool SaveRamModified
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return false;
|
int unused;
|
||||||
|
IntPtr unused2;
|
||||||
|
return LibLynx.GetSaveRamPtr(Core, out unused, out unused2);
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
|
|
|
@ -207,12 +207,12 @@ INLINE void CCart::Poke(uint32 addr, uint8 data)
|
||||||
{
|
{
|
||||||
if(mBank==bank0)
|
if(mBank==bank0)
|
||||||
{
|
{
|
||||||
if(mWriteEnableBank0)
|
if(mWriteEnableBank0 && false) // can never write as there is no ram
|
||||||
mCartBank0[addr&mMaskBank0]=data;
|
mCartBank0[addr&mMaskBank0]=data;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(mWriteEnableBank1)
|
if(mWriteEnableBank1 && mCartRAM) // can only write if it's actually ram
|
||||||
mCartBank1[addr&mMaskBank1]=data;
|
mCartBank1[addr&mMaskBank1]=data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -260,7 +260,7 @@ void CCart::CartAddressData(bool data)
|
||||||
|
|
||||||
void CCart::Poke0(uint8 data)
|
void CCart::Poke0(uint8 data)
|
||||||
{
|
{
|
||||||
if(mWriteEnableBank0)
|
if(mWriteEnableBank0 && false) // can never write as there is no ram
|
||||||
{
|
{
|
||||||
uint32 address=(mShifter<<mShiftCount0)+(mCounter&mCountMask0);
|
uint32 address=(mShifter<<mShiftCount0)+(mCounter&mCountMask0);
|
||||||
mCartBank0[address&mMaskBank0]=data;
|
mCartBank0[address&mMaskBank0]=data;
|
||||||
|
@ -274,7 +274,7 @@ void CCart::Poke0(uint8 data)
|
||||||
|
|
||||||
void CCart::Poke1(uint8 data)
|
void CCart::Poke1(uint8 data)
|
||||||
{
|
{
|
||||||
if(mWriteEnableBank1)
|
if(mWriteEnableBank1 && mCartRAM) // can only write if it's actually ram
|
||||||
{
|
{
|
||||||
uint32 address=(mShifter<<mShiftCount1)+(mCounter&mCountMask1);
|
uint32 address=(mShifter<<mShiftCount1)+(mCounter&mCountMask1);
|
||||||
mCartBank1[address&mMaskBank1]=data;
|
mCartBank1[address&mMaskBank1]=data;
|
||||||
|
@ -314,3 +314,19 @@ uint8 CCart::Peek1(void)
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
bool CCart::GetSaveRamPtr(int &size, uint8 *&data)
|
||||||
|
{
|
||||||
|
if (mCartRAM)
|
||||||
|
{
|
||||||
|
size = mMaskBank1 + 1;
|
||||||
|
data = mCartBank1;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -102,9 +102,12 @@ public:
|
||||||
// Data members
|
// Data members
|
||||||
|
|
||||||
public:
|
public:
|
||||||
uint32 mWriteEnableBank0;
|
bool mWriteEnableBank0; // always false, as all carts have rom here
|
||||||
uint32 mWriteEnableBank1;
|
bool mWriteEnableBank1;
|
||||||
uint32 mCartRAM;
|
bool mCartRAM; // always true if there is no second rom segment; probably providing saveram in many cases
|
||||||
|
// when the original cart did not have it
|
||||||
|
|
||||||
|
bool GetSaveRamPtr(int &size, uint8 *&data);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
EMMODE mBank;
|
EMMODE mBank;
|
||||||
|
|
|
@ -36,3 +36,8 @@ EXPORT void Advance(CSystem *s, int buttons, uint32 *vbuff, int16 *sbuff, int *s
|
||||||
{
|
{
|
||||||
s->Advance(buttons, vbuff, sbuff, *sbuffsize);
|
s->Advance(buttons, vbuff, sbuff, *sbuffsize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EXPORT int GetSaveRamPtr(CSystem *s, int *size, uint8 **data)
|
||||||
|
{
|
||||||
|
return s->GetSaveRamPtr(*size, *data);
|
||||||
|
}
|
||||||
|
|
|
@ -892,7 +892,7 @@ void CMikie::Poke(uint32 addr,uint8 data)
|
||||||
mIODAT=data;
|
mIODAT=data;
|
||||||
mSystem.CartAddressData((mIODAT&0x02)?TRUE:FALSE);
|
mSystem.CartAddressData((mIODAT&0x02)?TRUE:FALSE);
|
||||||
// Enable cart writes to BANK1 on AUDIN if AUDIN is set to output
|
// Enable cart writes to BANK1 on AUDIN if AUDIN is set to output
|
||||||
if(mIODIR&0x10) mSystem.mCart->mWriteEnableBank1=(mIODAT&0x10)?TRUE:FALSE;
|
if(mIODIR&0x10) mSystem.mCart->mWriteEnableBank1=(mIODAT&0x10)?true:false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case (SERCTL&0xff):
|
case (SERCTL&0xff):
|
||||||
|
|
|
@ -163,6 +163,7 @@ enum
|
||||||
MIKIE_ROTATE_R
|
MIKIE_ROTATE_R
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
MIKIE_PIXEL_FORMAT_8BPP=0,
|
MIKIE_PIXEL_FORMAT_8BPP=0,
|
||||||
|
@ -171,6 +172,7 @@ enum
|
||||||
MIKIE_PIXEL_FORMAT_24BPP,
|
MIKIE_PIXEL_FORMAT_24BPP,
|
||||||
MIKIE_PIXEL_FORMAT_32BPP,
|
MIKIE_PIXEL_FORMAT_32BPP,
|
||||||
};
|
};
|
||||||
|
*/
|
||||||
|
|
||||||
#include "sound/Stereo_Buffer.h"
|
#include "sound/Stereo_Buffer.h"
|
||||||
|
|
||||||
|
|
|
@ -49,6 +49,7 @@
|
||||||
#define RAM_ADDR_MASK 0xffff
|
#define RAM_ADDR_MASK 0xffff
|
||||||
#define DEFAULT_RAM_CONTENTS 0xff
|
#define DEFAULT_RAM_CONTENTS 0xff
|
||||||
|
|
||||||
|
/*
|
||||||
struct HOME_HEADER
|
struct HOME_HEADER
|
||||||
{
|
{
|
||||||
uint16 jump;
|
uint16 jump;
|
||||||
|
@ -56,6 +57,7 @@ struct HOME_HEADER
|
||||||
uint16 size;
|
uint16 size;
|
||||||
uint8 magic[4];
|
uint8 magic[4];
|
||||||
};
|
};
|
||||||
|
*/
|
||||||
|
|
||||||
class CRam : public CLynxBase
|
class CRam : public CLynxBase
|
||||||
{
|
{
|
||||||
|
|
|
@ -140,6 +140,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
void Advance(int buttons, uint32 *vbuff, int16 *sbuff, int &sbuffsize);
|
void Advance(int buttons, uint32 *vbuff, int16 *sbuff, int &sbuffsize);
|
||||||
|
bool GetSaveRamPtr(int &size, uint8 *&data) { return mCart->GetSaveRamPtr(size, data); }
|
||||||
|
|
||||||
//
|
//
|
||||||
// We MUST have separate CPU & RAM peek & poke handlers as all CPU accesses must
|
// We MUST have separate CPU & RAM peek & poke handlers as all CPU accesses must
|
||||||
|
@ -211,7 +212,7 @@ public:
|
||||||
uint32 gSystemIRQ;
|
uint32 gSystemIRQ;
|
||||||
uint32 gSystemNMI;
|
uint32 gSystemNMI;
|
||||||
uint32 gSystemCPUSleep;
|
uint32 gSystemCPUSleep;
|
||||||
uint32 gSystemHalt;
|
uint32 gSystemHalt; // this is set in various places, but never tested, anywhere?
|
||||||
|
|
||||||
// frame overflow detection
|
// frame overflow detection
|
||||||
int frameoverflow;
|
int frameoverflow;
|
||||||
|
|
Binary file not shown.
Loading…
Reference in New Issue