Added acanline rendering. Fixed interrupts. Added XInput support
This commit is contained in:
@@ -100,7 +100,23 @@ namespace Desktop
|
||||
// Mark exactly when the emulator starts thinking
|
||||
double frameStartTime = _stopwatch.Elapsed.TotalMilliseconds;
|
||||
|
||||
// 1. Do the heavy lifting (Z80 and VDP)
|
||||
// --- POLL PHYSICAL CONTROLLER ---
|
||||
if (XInput.XInputGetState(0, out XInput.XINPUT_STATE state) == 0)
|
||||
{
|
||||
ushort btns = state.Gamepad.wButtons;
|
||||
byte padState = 0xFF;
|
||||
|
||||
if ((btns & 0x0001) != 0) padState &= 0xFE; // Up
|
||||
if ((btns & 0x0002) != 0) padState &= 0xFD; // Down
|
||||
if ((btns & 0x0004) != 0) padState &= 0xFB; // Left
|
||||
if ((btns & 0x0008) != 0) padState &= 0xF7; // Right
|
||||
if ((btns & 0x1000) != 0) padState &= 0xEF; // Button 1
|
||||
if ((btns & 0x2000) != 0) padState &= 0xDF; // Button 2
|
||||
|
||||
// THE FIX: Constantly update the gamepad state, even when it's 0xFF!
|
||||
_machine.IoBus.Joypad1Gamepad = padState;
|
||||
}
|
||||
// --------------------------------
|
||||
_machine.RunFrame();
|
||||
|
||||
// 2. FIRE AND FORGET! Tell Windows to draw, but DO NOT WAIT for it to finish!
|
||||
@@ -161,12 +177,6 @@ namespace Desktop
|
||||
IsRunning = false;
|
||||
}
|
||||
|
||||
|
||||
public void StepEmulator()
|
||||
{
|
||||
_machine.StepMachine();
|
||||
}
|
||||
|
||||
private async void LoadRomAndStart(string filePath)
|
||||
{
|
||||
StopEmulator();
|
||||
@@ -282,13 +292,11 @@ namespace Desktop
|
||||
|
||||
if (isPressed)
|
||||
{
|
||||
// Active-Low: Clear the specific bit to 0 using a bitwise AND with a NOT mask
|
||||
_machine.IoBus.Joypad1State &= (byte)~bitMask;
|
||||
_machine.IoBus.Joypad1Keyboard &= (byte)~bitMask; // Target Keyboard!
|
||||
}
|
||||
else
|
||||
{
|
||||
// Active-Low: Reset the specific bit to 1 using a bitwise OR mask
|
||||
_machine.IoBus.Joypad1State |= bitMask;
|
||||
_machine.IoBus.Joypad1Keyboard |= bitMask; // Target Keyboard!
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user