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)]
|
||||
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]
|
||||
public enum Buttons : ushort
|
||||
{
|
||||
|
|
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
using BizHawk.Common;
|
||||
using BizHawk.Emulation.Common;
|
||||
|
@ -218,22 +219,38 @@ namespace BizHawk.Emulation.Cores.Atari.Lynx
|
|||
|
||||
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()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool SaveRamModified
|
||||
{
|
||||
get
|
||||
{
|
||||
return false;
|
||||
int unused;
|
||||
IntPtr unused2;
|
||||
return LibLynx.GetSaveRamPtr(Core, out unused, out unused2);
|
||||
}
|
||||
set
|
||||
{
|
||||
|
|
|
@ -207,12 +207,12 @@ INLINE void CCart::Poke(uint32 addr, uint8 data)
|
|||
{
|
||||
if(mBank==bank0)
|
||||
{
|
||||
if(mWriteEnableBank0)
|
||||
if(mWriteEnableBank0 && false) // can never write as there is no ram
|
||||
mCartBank0[addr&mMaskBank0]=data;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(mWriteEnableBank1)
|
||||
if(mWriteEnableBank1 && mCartRAM) // can only write if it's actually ram
|
||||
mCartBank1[addr&mMaskBank1]=data;
|
||||
}
|
||||
}
|
||||
|
@ -260,7 +260,7 @@ void CCart::CartAddressData(bool 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);
|
||||
mCartBank0[address&mMaskBank0]=data;
|
||||
|
@ -274,7 +274,7 @@ void CCart::Poke0(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);
|
||||
mCartBank1[address&mMaskBank1]=data;
|
||||
|
@ -314,3 +314,19 @@ uint8 CCart::Peek1(void)
|
|||
|
||||
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
|
||||
|
||||
public:
|
||||
uint32 mWriteEnableBank0;
|
||||
uint32 mWriteEnableBank1;
|
||||
uint32 mCartRAM;
|
||||
bool mWriteEnableBank0; // always false, as all carts have rom here
|
||||
bool mWriteEnableBank1;
|
||||
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:
|
||||
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);
|
||||
}
|
||||
|
||||
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;
|
||||
mSystem.CartAddressData((mIODAT&0x02)?TRUE:FALSE);
|
||||
// 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;
|
||||
|
||||
case (SERCTL&0xff):
|
||||
|
|
|
@ -163,6 +163,7 @@ enum
|
|||
MIKIE_ROTATE_R
|
||||
};
|
||||
|
||||
/*
|
||||
enum
|
||||
{
|
||||
MIKIE_PIXEL_FORMAT_8BPP=0,
|
||||
|
@ -171,6 +172,7 @@ enum
|
|||
MIKIE_PIXEL_FORMAT_24BPP,
|
||||
MIKIE_PIXEL_FORMAT_32BPP,
|
||||
};
|
||||
*/
|
||||
|
||||
#include "sound/Stereo_Buffer.h"
|
||||
|
||||
|
|
|
@ -49,6 +49,7 @@
|
|||
#define RAM_ADDR_MASK 0xffff
|
||||
#define DEFAULT_RAM_CONTENTS 0xff
|
||||
|
||||
/*
|
||||
struct HOME_HEADER
|
||||
{
|
||||
uint16 jump;
|
||||
|
@ -56,6 +57,7 @@ struct HOME_HEADER
|
|||
uint16 size;
|
||||
uint8 magic[4];
|
||||
};
|
||||
*/
|
||||
|
||||
class CRam : public CLynxBase
|
||||
{
|
||||
|
|
|
@ -140,6 +140,7 @@ public:
|
|||
}
|
||||
|
||||
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
|
||||
|
@ -211,7 +212,7 @@ public:
|
|||
uint32 gSystemIRQ;
|
||||
uint32 gSystemNMI;
|
||||
uint32 gSystemCPUSleep;
|
||||
uint32 gSystemHalt;
|
||||
uint32 gSystemHalt; // this is set in various places, but never tested, anywhere?
|
||||
|
||||
// frame overflow detection
|
||||
int frameoverflow;
|
||||
|
|
Binary file not shown.
Loading…
Reference in New Issue