diff --git a/BizHawk.Emulation.Cores/Consoles/WonderSwan/BizSwan.cs b/BizHawk.Emulation.Cores/Consoles/WonderSwan/BizSwan.cs
index fed2f217f6..1b568e68f8 100644
--- a/BizHawk.Emulation.Cores/Consoles/WonderSwan/BizSwan.cs
+++ b/BizHawk.Emulation.Cores/Consoles/WonderSwan/BizSwan.cs
@@ -93,6 +93,48 @@ namespace BizHawk.Emulation.Cores.WonderSwan
[DllImport(dd, CallingConvention = cc)]
public static extern void bizswan_putsettings(IntPtr core, [In] ref Settings settings);
+ ///
+ /// get a memory area
+ ///
+ ///
+ /// start at 0, increment until return is false
+ ///
+ ///
+ ///
+ ///
+ [DllImport(dd, CallingConvention = cc)]
+ public static extern bool bizswan_getmemoryarea(IntPtr core, int index, out IntPtr name, out int size, out IntPtr data);
+
+
+ ///
+ /// return a CPU register
+ ///
+ ///
+ ///
+ ///
+ [DllImport(dd, CallingConvention = cc)]
+ public static extern uint bizswan_getnecreg(IntPtr core, NecRegs which);
+
+ public const NecRegs NecRegsMin = NecRegs.PC;
+ public const NecRegs NecRegsMax = NecRegs.DS0;
+
+ public enum NecRegs : int
+ {
+ PC = 1,
+ AW = 2,
+ CW = 3,
+ DW = 4,
+ BW = 5,
+ SP = 6,
+ BP = 7,
+ IX = 8,
+ IY = 9,
+ FLAGS = 10,
+ DS1 = 11,
+ PS = 12,
+ SS = 13,
+ DS0 = 14
+ };
[Flags]
public enum Buttons : ushort
diff --git a/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.cs b/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.cs
index 16e733f0ab..6e96a33899 100644
--- a/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.cs
+++ b/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.cs
@@ -7,6 +7,7 @@ using BizHawk.Emulation.Common;
using System.IO;
using System.ComponentModel;
using Newtonsoft.Json;
+using System.Runtime.InteropServices;
namespace BizHawk.Emulation.Cores.WonderSwan
{
@@ -68,6 +69,7 @@ namespace BizHawk.Emulation.Cores.WonderSwan
InitVideo(rotate);
PutSettings(_Settings);
+ SetMemoryDomains();
}
catch
{
@@ -185,14 +187,52 @@ namespace BizHawk.Emulation.Cores.WonderSwan
#region Debugging
- public MemoryDomainList MemoryDomains
+ unsafe void SetMemoryDomains()
{
- get { throw new NotImplementedException(); }
+ var mmd = new List();
+ for (int i = 0; ; i++)
+ {
+ IntPtr name;
+ int size;
+ IntPtr data;
+ if (!BizSwan.bizswan_getmemoryarea(Core, i, out name, out size, out data))
+ break;
+ if (size == 0)
+ continue;
+ string sname = Marshal.PtrToStringAnsi(name);
+ byte *p = (byte*)data;
+ mmd.Add(new MemoryDomain(
+ sname,
+ size,
+ MemoryDomain.Endian.Little,
+ delegate(int addr)
+ {
+ if (addr < 0 || addr >= size)
+ throw new ArgumentOutOfRangeException();
+ return p[addr];
+ },
+ delegate(int addr, byte value)
+ {
+ if (addr < 0 || addr >= size)
+ throw new ArgumentOutOfRangeException();
+ p[addr] = value;
+ }));
+ }
+ MemoryDomains = new MemoryDomainList(mmd, 0);
}
+ public MemoryDomainList MemoryDomains { get; private set; }
+
public Dictionary GetCpuFlagsAndRegisters()
{
- throw new NotImplementedException();
+ var ret = new Dictionary();
+ for (int i = (int)BizSwan.NecRegsMin; i <= (int)BizSwan.NecRegsMax; i++)
+ {
+ BizSwan.NecRegs en = (BizSwan.NecRegs)i;
+ uint val = BizSwan.bizswan_getnecreg(Core, en);
+ ret[Enum.GetName(typeof(BizSwan.NecRegs), en)] = (int)val;
+ }
+ return ret;
}
#endregion
diff --git a/output/dll/bizswan.dll b/output/dll/bizswan.dll
index bef04339c7..a067a401b9 100644
Binary files a/output/dll/bizswan.dll and b/output/dll/bizswan.dll differ
diff --git a/wonderswan/bizswan/bizswan.vcxproj b/wonderswan/bizswan/bizswan.vcxproj
index 024581e651..792093a0e5 100644
--- a/wonderswan/bizswan/bizswan.vcxproj
+++ b/wonderswan/bizswan/bizswan.vcxproj
@@ -74,7 +74,6 @@
-
diff --git a/wonderswan/bizswan/bizswan.vcxproj.filters b/wonderswan/bizswan/bizswan.vcxproj.filters
index cc5152ee26..a021bd15b7 100644
--- a/wonderswan/bizswan/bizswan.vcxproj.filters
+++ b/wonderswan/bizswan/bizswan.vcxproj.filters
@@ -36,9 +36,6 @@
Source Files
-
- Source Files
-
Source Files
diff --git a/wonderswan/main.cpp b/wonderswan/main.cpp
deleted file mode 100644
index e36fa1b575..0000000000
--- a/wonderswan/main.cpp
+++ /dev/null
@@ -1,94 +0,0 @@
-/* Cygne
- *
- * Copyright notice for this file:
- * Copyright (C) 2002 Dox dox@space.pl
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include "system.h"
-//#include
-//#include
-//#include
-
-//#include
-//#include
-//#include
-#include
-//#include
-
-namespace MDFN_IEN_WSWAN
-{
-#if 0
-
-
-
-
-
-#endif
-
-}
-
-/*
-using namespace MDFN_IEN_WSWAN;
-
-MDFNGI EmulatedWSwan =
-{
- "wswan",
- "WonderSwan",
- KnownExtensions,
- MODPRIO_INTERNAL_HIGH,
- #ifdef WANT_DEBUGGER
- &DBGInfo,
- #else
- NULL,
- #endif
- &InputInfo,
- Load,
- TestMagic,
- NULL,
- NULL,
- CloseGame,
- WSwan_SetLayerEnableMask,
- "Background\0Foreground\0Sprites\0",
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- false,
- StateAction,
- Emulate,
- SetInput,
- DoSimpleCommand,
- WSwanSettings,
- MDFN_MASTERCLOCK_FIXED(3072000),
- 0,
- FALSE, // Multires possible?
-
- 224, // lcm_width
- 144, // lcm_height
- NULL, // Dummy
-
- 224, // Nominal width
- 144, // Nominal height
-
- 224, // Framebuffer width
- 144, // Framebuffer height
-
- 2, // Number of output sound channels
-};
-*/
diff --git a/wonderswan/memory.cpp b/wonderswan/memory.cpp
index 5389f90209..30feaabf6d 100644
--- a/wonderswan/memory.cpp
+++ b/wonderswan/memory.cpp
@@ -20,7 +20,6 @@
#include "system.h"
-#include
#include
#include
#include
diff --git a/wonderswan/system.cpp b/wonderswan/system.cpp
index bae0eaac43..3cfb0e63bb 100644
--- a/wonderswan/system.cpp
+++ b/wonderswan/system.cpp
@@ -274,6 +274,26 @@ namespace MDFN_IEN_WSWAN
gfx.SetLayerEnableMask(s.LayerMask);
}
+ uint32 System::GetNECReg(int which) const
+ {
+ return cpu.get_reg(which);
+ }
+
+ bool System::GetMemoryArea(int index, const char *&name, int &size, uint8 *&data)
+ {
+ bool ret = true;
+ switch (index)
+ {
+ case 0: name = "RAM"; size = 65536; data = memory.wsRAM; break;
+ case 1: name = "ROM"; size = memory.rom_size; data = memory.wsCartROM; break;
+ case 2: name = "SRAM"; size = memory.sram_size; data = memory.wsSRAM; break;
+ case 3: name = "iEEPROM"; size = eeprom.ieeprom_size; data = eeprom.iEEPROM; break;
+ case 4: name = "EEPROM"; size = eeprom.eeprom_size; data = eeprom.wsEEPROM; break;
+ default: ret = false; break;
+ }
+ return ret;
+ }
+
EXPORT System *bizswan_new()
{
@@ -322,4 +342,14 @@ namespace MDFN_IEN_WSWAN
s->PutSettings(*settings);
}
+ EXPORT uint32 bizswan_getnecreg(System *s, int which)
+ {
+ return s->GetNECReg(which);
+ }
+
+ EXPORT int bizswan_getmemoryarea(System *s, int index, const char **name, int *size, uint8 **data)
+ {
+ return s->GetMemoryArea(index, *name, *size, *data);
+ }
+
}
diff --git a/wonderswan/system.h b/wonderswan/system.h
index 3eaea20425..bbccb45c7f 100644
--- a/wonderswan/system.h
+++ b/wonderswan/system.h
@@ -38,6 +38,10 @@ public:
bool SaveRamLoad(const uint8 *data, int size);
bool SaveRamSave(uint8 *dest, int maxsize) const;
+ uint32 GetNECReg(int which) const;
+
+ bool GetMemoryArea(int index, const char *&name, int &size, uint8 *&data);
+
public:
GFX gfx;
Memory memory;
diff --git a/wonderswan/v30mz.cpp b/wonderswan/v30mz.cpp
index 6eff7e3a78..70e1f71e24 100644
--- a/wonderswan/v30mz.cpp
+++ b/wonderswan/v30mz.cpp
@@ -957,7 +957,7 @@ namespace MDFN_IEN_WSWAN
/*****************************************************************************/
- unsigned V30MZ::get_reg(int regnum)
+ unsigned V30MZ::get_reg(int regnum) const
{
switch( regnum )
{
diff --git a/wonderswan/v30mz.h b/wonderswan/v30mz.h
index 400a4d0cf5..622257cc70 100644
--- a/wonderswan/v30mz.h
+++ b/wonderswan/v30mz.h
@@ -44,7 +44,7 @@ public:
void execute(int cycles);
void set_reg(int, unsigned);
- unsigned get_reg(int regnum);
+ unsigned get_reg(int regnum) const;
void reset();
void interrupt(uint32 vector, bool IgnoreIF = FALSE);
@@ -81,10 +81,6 @@ private:
} Mod_RM;
private:
- //void (*cpu_writemem20)(uint32,uint8);// = NULL;
- //uint8 (*cpu_readport)(uint32);// = NULL;
- //void (*cpu_writeport)(uint32, uint8);// = NULL;
- //uint8 (*cpu_readmem20)(uint32);// = NULL;
private:
void nec_interrupt(unsigned int_num);
@@ -153,13 +149,6 @@ enum {
NEC_FLAGS, NEC_DS1, NEC_PS, NEC_SS, NEC_DS0
};
-/* Public variables */
-//extern int v30mz_ICount;
-//extern uint32 v30mz_timestamp;
-
-
-/* Public functions */
-
}
#endif
diff --git a/wonderswan/wswan.h b/wonderswan/wswan.h
index 331f1466b8..9e99ce8397 100644
--- a/wonderswan/wswan.h
+++ b/wonderswan/wswan.h
@@ -10,24 +10,6 @@ namespace MDFN_IEN_WSWAN
#define mBCD(value) (((value)/10)<<4)|((value)%10)
-//extern uint32 rom_size;
-//extern int wsc;
-
-/*
-enum
-{
- WSWAN_SEX_MALE = 1,
- WSWAN_SEX_FEMALE = 2
-};
-
-enum
-{
- WSWAN_BLOOD_A = 1,
- WSWAN_BLOOD_B = 2,
- WSWAN_BLOOD_O = 3,
- WSWAN_BLOOD_AB = 4
-};
-*/
}
#endif