MSXHawk: cleanup and bug fixes
This commit is contained in:
parent
cce1fb6123
commit
551a7e2893
File diff suppressed because it is too large
Load Diff
|
@ -70,7 +70,7 @@ namespace BizHawk.Emulation.Cores.Computers.MSX
|
|||
/// <param name="aud_buf">where to send left audio to</param>
|
||||
/// <param name="n_samp">number of left samples</param>
|
||||
[DllImport("MSXHawk.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern uint MSX_get_audio(IntPtr core, uint[] aud_buf, ref uint n_samp);
|
||||
public static extern uint MSX_get_audio(IntPtr core, int[] aud_buf, ref uint n_samp);
|
||||
|
||||
#endregion
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ namespace BizHawk.Emulation.Cores.Computers.MSX
|
|||
{
|
||||
get
|
||||
{
|
||||
return GGController;
|
||||
return MSXController;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,13 @@ namespace BizHawk.Emulation.Cores.Computers.MSX
|
|||
if (_controller.IsPressed("P1 B1")) ctrl1_byte -= 0x10;
|
||||
if (_controller.IsPressed("P1 B2")) ctrl1_byte -= 0x20;
|
||||
|
||||
//if (_controller.IsPressed("P1 Start")) ctrl1_byte |= 0x80;
|
||||
byte ctrl2_byte = 0xFF;
|
||||
if (_controller.IsPressed("P2 Up")) ctrl1_byte -= 0x01;
|
||||
if (_controller.IsPressed("P2 Down")) ctrl1_byte -= 0x02;
|
||||
if (_controller.IsPressed("P2 Left")) ctrl1_byte -= 0x04;
|
||||
if (_controller.IsPressed("P2 Right")) ctrl1_byte -= 0x08;
|
||||
if (_controller.IsPressed("P2 B1")) ctrl1_byte -= 0x10;
|
||||
if (_controller.IsPressed("P2 B2")) ctrl1_byte -= 0x20;
|
||||
|
||||
_frame++;
|
||||
|
||||
|
@ -42,7 +48,7 @@ namespace BizHawk.Emulation.Cores.Computers.MSX
|
|||
|
||||
LibMSX.MSX_settracecallback(MSX_Pntr, tracecb);
|
||||
|
||||
LibMSX.MSX_frame_advance(MSX_Pntr, ctrl1_byte, 0xFF, true, true);
|
||||
LibMSX.MSX_frame_advance(MSX_Pntr, ctrl1_byte, ctrl2_byte, true, true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -81,7 +87,7 @@ namespace BizHawk.Emulation.Cores.Computers.MSX
|
|||
|
||||
public BlipBuffer blip = new BlipBuffer(4500);
|
||||
|
||||
public uint[] Aud = new uint [9000];
|
||||
public int[] Aud = new int [9000];
|
||||
public uint num_samp;
|
||||
|
||||
const int blipbuffsize = 4500;
|
||||
|
@ -112,7 +118,7 @@ namespace BizHawk.Emulation.Cores.Computers.MSX
|
|||
|
||||
for (int i = 0; i < num_samp;i++)
|
||||
{
|
||||
blip.AddDelta(Aud[i * 2], (int)Aud[i * 2 + 1]);
|
||||
blip.AddDelta((uint)Aud[i * 2], Aud[i * 2 + 1]);
|
||||
}
|
||||
|
||||
blip.EndFrame(f_clock);
|
||||
|
|
|
@ -7,13 +7,14 @@ namespace BizHawk.Emulation.Cores.Computers.MSX
|
|||
public partial class MSX
|
||||
{
|
||||
|
||||
public static readonly ControllerDefinition GGController = new ControllerDefinition
|
||||
public static readonly ControllerDefinition MSXController = new ControllerDefinition
|
||||
{
|
||||
Name = "GG Controller",
|
||||
Name = "MSX Controller",
|
||||
BoolButtons =
|
||||
{
|
||||
"Reset",
|
||||
"P1 Up", "P1 Down", "P1 Left", "P1 Right", "P1 B1", "P1 B2", "P1 Start"
|
||||
"P1 Up", "P1 Down", "P1 Left", "P1 Right", "P1 B1", "P1 B2",
|
||||
"P2 Up", "P2 Down", "P2 Left", "P2 Right", "P2 B1", "P2 B2"
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ namespace BizHawk.Emulation.Cores.Computers.MSX
|
|||
CoreComm = comm;
|
||||
|
||||
RomData = rom;
|
||||
int size = RomData.Length;
|
||||
|
||||
if (RomData.Length % BankSize != 0)
|
||||
{
|
||||
|
@ -33,6 +34,30 @@ namespace BizHawk.Emulation.Cores.Computers.MSX
|
|||
Array.Resize(ref RomData, 0x10000);
|
||||
}
|
||||
|
||||
// if the original was not 64 or 48 k, move it (may need to do this case by case)
|
||||
|
||||
if (size == 0x8000)
|
||||
{
|
||||
for (int i = 0x7FFF; i >= 0; i--)
|
||||
{
|
||||
RomData[i + 0x4000] = RomData[i];
|
||||
}
|
||||
for (int i = 0; i < 0x4000; i++)
|
||||
{
|
||||
RomData[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (size == 0x4000)
|
||||
{
|
||||
for (int i = 0; i < 0x4000; i++)
|
||||
{
|
||||
RomData[i + 0x4000] = RomData[i];
|
||||
RomData[i + 0x8000] = RomData[i];
|
||||
RomData[i + 0xC000] = RomData[i];
|
||||
}
|
||||
}
|
||||
|
||||
Bios = comm.CoreFileProvider.GetFirmware("MSX", "bios", true, "BIOS Not Found, Cannot Load");
|
||||
Basic = comm.CoreFileProvider.GetFirmware("MSX", "basic", true, "BIOS Not Found, Cannot Load");
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ namespace MSXHawk
|
|||
uint32_t noise_per;
|
||||
uint32_t noise = 0x1;
|
||||
|
||||
uint32_t old_sample;
|
||||
int32_t old_sample;
|
||||
|
||||
// non stated if only on frame boundaries
|
||||
bool sound_out_A;
|
||||
|
@ -51,10 +51,10 @@ namespace MSXHawk
|
|||
|
||||
uint8_t Clock_Divider;
|
||||
|
||||
uint32_t current_sample;
|
||||
int32_t current_sample;
|
||||
uint32_t sampleclock;
|
||||
uint32_t num_samples;
|
||||
uint32_t samples[9000] = {};
|
||||
int32_t samples[9000] = {};
|
||||
|
||||
void Reset()
|
||||
{
|
||||
|
@ -280,6 +280,8 @@ namespace MSXHawk
|
|||
current_sample += (sound_out_C ? VolumeTable[vol_C] : 0);
|
||||
}
|
||||
|
||||
current_sample *= 2;
|
||||
|
||||
if ((current_sample != old_sample) && (num_samples < 4500))
|
||||
{
|
||||
samples[num_samples * 2] = sampleclock;
|
||||
|
|
|
@ -98,12 +98,12 @@ namespace MSXHawk
|
|||
std::memcpy(dst, src, sizeof uint32_t * 256 * 192);
|
||||
}
|
||||
|
||||
uint32_t GetAudio(uint32_t* dest, uint32_t* n_samp)
|
||||
uint32_t GetAudio(int32_t* dest, int32_t* n_samp)
|
||||
{
|
||||
uint32_t* src = psg.samples;
|
||||
uint32_t* dst = dest;
|
||||
int32_t* src = psg.samples;
|
||||
int32_t* dst = dest;
|
||||
|
||||
std::memcpy(dst, src, sizeof uint32_t * psg.num_samples * 2);
|
||||
std::memcpy(dst, src, sizeof int32_t * psg.num_samples * 2);
|
||||
n_samp[0] = psg.num_samples;
|
||||
|
||||
return psg.sampleclock;
|
||||
|
|
|
@ -54,7 +54,7 @@ MSXHawk_EXPORT void MSX_get_video(MSXCore* p, uint32_t* dest)
|
|||
}
|
||||
|
||||
// send audio data to external audio provider
|
||||
MSXHawk_EXPORT uint32_t MSX_get_audio(MSXCore* p, uint32_t* dest, uint32_t* n_samp)
|
||||
MSXHawk_EXPORT uint32_t MSX_get_audio(MSXCore* p, int32_t* dest, int32_t* n_samp)
|
||||
{
|
||||
return p->GetAudio(dest, n_samp);
|
||||
}
|
||||
|
|
|
@ -3879,7 +3879,7 @@ namespace MSXHawk
|
|||
bank_num = bank_offset = (uint32_t)(Regs[dest_l] | (Regs[dest_h]) << 8);
|
||||
bank_offset &= low_mask;
|
||||
bank_num = (bank_num >> bank_shift)& high_mask;
|
||||
MemoryMap[bank_num][bank_offset] = MemoryMapMask[bank_num] & (Regs[src] & 0xFF);
|
||||
MemoryMap[bank_num][bank_offset] = (MemoryMapMask[bank_num] & (Regs[src] & 0xFF)) | ((~MemoryMapMask[bank_num]) & MemoryMap[bank_num][bank_offset]);
|
||||
|
||||
Memory_Write((uint32_t)(Regs[dest_l] | (Regs[dest_h] << 8)), (uint8_t)(Regs[src] & 0xFF));
|
||||
}
|
||||
|
@ -3891,7 +3891,7 @@ namespace MSXHawk
|
|||
bank_num = bank_offset = (uint32_t)(Regs[dest_l] | (Regs[dest_h]) << 8);
|
||||
bank_offset &= low_mask;
|
||||
bank_num = (bank_num >> bank_shift)& high_mask;
|
||||
MemoryMap[bank_num][bank_offset] = MemoryMapMask[bank_num] & (Regs[src] & 0xFF);
|
||||
MemoryMap[bank_num][bank_offset] = (MemoryMapMask[bank_num] & (Regs[src] & 0xFF)) | ((~MemoryMapMask[bank_num]) & MemoryMap[bank_num][bank_offset]);
|
||||
|
||||
Memory_Write((uint32_t)(Regs[dest_l] | (Regs[dest_h] << 8)), (uint8_t)(Regs[src] & 0xFF));
|
||||
|
||||
|
@ -3905,7 +3905,7 @@ namespace MSXHawk
|
|||
bank_num = bank_offset = (uint32_t)(Regs[dest_l] | (Regs[dest_h]) << 8);
|
||||
bank_offset &= low_mask;
|
||||
bank_num = (bank_num >> bank_shift)& high_mask;
|
||||
MemoryMap[bank_num][bank_offset] = MemoryMapMask[bank_num] & (Regs[src] & 0xFF);
|
||||
MemoryMap[bank_num][bank_offset] = (MemoryMapMask[bank_num] & (Regs[src] & 0xFF)) | ((~MemoryMapMask[bank_num]) & MemoryMap[bank_num][bank_offset]);
|
||||
|
||||
Memory_Write((uint32_t)(Regs[dest_l] | (Regs[dest_h] << 8)), (uint8_t)(Regs[src] & 0xFF));
|
||||
|
||||
|
@ -3919,7 +3919,7 @@ namespace MSXHawk
|
|||
bank_num = bank_offset = (uint32_t)(Regs[dest_l] | (Regs[dest_h]) << 8);
|
||||
bank_offset &= low_mask;
|
||||
bank_num = (bank_num >> bank_shift)& high_mask;
|
||||
MemoryMap[bank_num][bank_offset] = MemoryMapMask[bank_num] & (Regs[src] & 0xFF);
|
||||
MemoryMap[bank_num][bank_offset] = (MemoryMapMask[bank_num] & (Regs[src] & 0xFF)) | ((~MemoryMapMask[bank_num]) & MemoryMap[bank_num][bank_offset]);
|
||||
|
||||
Memory_Write((uint32_t)(Regs[dest_l] | (Regs[dest_h] << 8)), (uint8_t)(Regs[src] & 0xFF));
|
||||
|
||||
|
|
Loading…
Reference in New Issue