2013-11-22 09:33:56 +00:00
|
|
|
|
using System;
|
|
|
|
|
|
|
|
|
|
using BizHawk.Common;
|
|
|
|
|
|
|
|
|
|
namespace BizHawk.Emulation.Cores.Nintendo.SNES
|
|
|
|
|
{
|
|
|
|
|
unsafe partial class LibsnesApi
|
|
|
|
|
{
|
|
|
|
|
public bool CMD_serialize(IntPtr data, int size)
|
|
|
|
|
{
|
2017-04-19 03:09:04 +00:00
|
|
|
|
comm->buf[0] = (uint)data.ToInt32();
|
|
|
|
|
comm->buf_size[0] = size;
|
2017-03-06 09:21:10 +00:00
|
|
|
|
Message(eMessage.eMessage_CMD_serialize);
|
|
|
|
|
WaitForCMD();
|
|
|
|
|
bool ret = comm->GetBool();
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void WaitForCMD()
|
|
|
|
|
{
|
|
|
|
|
for (; ; )
|
2013-11-22 09:33:56 +00:00
|
|
|
|
{
|
2017-03-06 09:21:10 +00:00
|
|
|
|
if (comm->status == eStatus.eStatus_Idle)
|
|
|
|
|
break;
|
|
|
|
|
if (Handle_SIG(comm->reason)) continue;
|
|
|
|
|
if (Handle_BRK(comm->reason)) continue;
|
2013-11-22 09:33:56 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool CMD_unserialize(IntPtr data, int size)
|
|
|
|
|
{
|
2017-04-19 03:09:04 +00:00
|
|
|
|
comm->buf[0] = (uint)data.ToInt32();
|
|
|
|
|
comm->buf_size[0] = size;
|
2017-03-06 09:21:10 +00:00
|
|
|
|
Message(eMessage.eMessage_CMD_unserialize);
|
|
|
|
|
WaitForCMD();
|
|
|
|
|
bool ret = comm->GetBool();
|
2013-11-22 09:33:56 +00:00
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void CMD_init()
|
|
|
|
|
{
|
2017-03-06 09:21:10 +00:00
|
|
|
|
Message(eMessage.eMessage_CMD_init);
|
|
|
|
|
WaitForCMD();
|
2013-11-22 09:33:56 +00:00
|
|
|
|
}
|
|
|
|
|
public void CMD_power()
|
|
|
|
|
{
|
2017-03-06 09:21:10 +00:00
|
|
|
|
Message(eMessage.eMessage_CMD_power);
|
|
|
|
|
WaitForCMD();
|
2013-11-22 09:33:56 +00:00
|
|
|
|
}
|
|
|
|
|
public void CMD_reset()
|
|
|
|
|
{
|
2017-03-06 09:21:10 +00:00
|
|
|
|
Message(eMessage.eMessage_CMD_reset);
|
|
|
|
|
WaitForCMD();
|
2013-11-22 09:33:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void CMD_run()
|
|
|
|
|
{
|
2017-03-06 09:21:10 +00:00
|
|
|
|
Message(eMessage.eMessage_CMD_run);
|
|
|
|
|
WaitForCMD();
|
2013-11-22 09:33:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-03-06 09:21:10 +00:00
|
|
|
|
public bool CMD_load_cartridge_super_game_boy(string rom_xml, byte[] rom_data, uint rom_size, byte[] dmg_data)
|
2013-11-22 09:33:56 +00:00
|
|
|
|
{
|
2017-05-06 21:23:26 +00:00
|
|
|
|
SetAscii(0, rom_xml ?? "", () =>
|
2017-05-03 03:09:50 +00:00
|
|
|
|
SetBytes(1, rom_data, () =>
|
|
|
|
|
SetBytes(2, dmg_data, () =>
|
|
|
|
|
{
|
|
|
|
|
Message(eMessage.eMessage_CMD_load_cartridge_sgb);
|
|
|
|
|
WaitForCMD();
|
|
|
|
|
})
|
|
|
|
|
)
|
2017-04-19 03:09:04 +00:00
|
|
|
|
);
|
|
|
|
|
return comm->GetBool();
|
2013-11-22 09:33:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool CMD_load_cartridge_normal(byte[] rom_xml, byte[] rom_data)
|
|
|
|
|
{
|
2017-05-06 21:23:26 +00:00
|
|
|
|
//why don't we need this for the other loads? I dont know, our XML handling is really confusing
|
2017-05-03 03:09:50 +00:00
|
|
|
|
string xml = rom_xml == null ? null : System.Text.Encoding.ASCII.GetString(rom_xml);
|
2017-05-06 21:23:26 +00:00
|
|
|
|
|
2017-05-03 03:09:50 +00:00
|
|
|
|
SetAscii(0, xml ?? "", () =>
|
|
|
|
|
SetBytes(1, rom_data, () =>
|
|
|
|
|
{
|
2017-04-19 03:09:04 +00:00
|
|
|
|
Message(eMessage.eMessage_CMD_load_cartridge_normal);
|
|
|
|
|
WaitForCMD();
|
|
|
|
|
})
|
|
|
|
|
);
|
|
|
|
|
return comm->GetBool();
|
2013-11-22 09:33:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void CMD_term()
|
|
|
|
|
{
|
2017-03-06 09:21:10 +00:00
|
|
|
|
Message(eMessage.eMessage_CMD_term);
|
|
|
|
|
WaitForCMD();
|
2013-11-22 09:33:56 +00:00
|
|
|
|
}
|
|
|
|
|
public void CMD_unload_cartridge()
|
|
|
|
|
{
|
2017-03-06 09:21:10 +00:00
|
|
|
|
Message(eMessage.eMessage_CMD_unload_cartridge);
|
|
|
|
|
WaitForCMD();
|
2013-11-22 09:33:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|