Merge branch 'dosbox' of github.com:SergioMartin86/BizHawk into dosbox
This commit is contained in:
commit
e5b16a6307
Binary file not shown.
|
@ -9,14 +9,14 @@ namespace BizHawk.Emulation.Cores.Computers.DOS
|
|||
// A class to store the current state of the mouse for delta and button activation calculation
|
||||
private class MouseState
|
||||
{
|
||||
public int posX = 0;
|
||||
public int posY = 0;
|
||||
public bool leftButtonHeld = false;
|
||||
public bool middleButtonHeld = false;
|
||||
public bool rightButtonHeld = false;
|
||||
public int PosX = 0;
|
||||
public int PosY = 0;
|
||||
public bool LeftButtonHeld = false;
|
||||
public bool MiddleButtonHeld = false;
|
||||
public bool RightButtonHeld = false;
|
||||
}
|
||||
|
||||
private MouseState _mouseState = new MouseState();
|
||||
private MouseState _lastMouseState = new MouseState();
|
||||
|
||||
private static readonly (string Name, LibDOSBox.DOSBoxKeyboard Key)[] _keyboardMap = CreateKeyboardMap();
|
||||
|
||||
|
@ -68,10 +68,10 @@ namespace BizHawk.Emulation.Cores.Computers.DOS
|
|||
controller.AddAxis(Inputs.Mouse + " " + MouseInputs.PosX, (0).RangeTo(LibDOSBox.SVGA_MAX_WIDTH), LibDOSBox.SVGA_MAX_WIDTH / 2);
|
||||
controller.AddAxis(Inputs.Mouse + " " + MouseInputs.PosY, (0).RangeTo(LibDOSBox.SVGA_MAX_HEIGHT), LibDOSBox.SVGA_MAX_HEIGHT / 2);
|
||||
|
||||
// Mouse speed needs to also be adjusted to bk's window size to capture the exact movement and not amplify/shrink it.
|
||||
// To adjust sensitivity, use the corresponding sync setting; these values here is the basis value
|
||||
controller.AddAxis(Inputs.Mouse + " " + MouseInputs.SpeedX, (-LibDOSBox.SVGA_MAX_WIDTH / 2).RangeTo(LibDOSBox.SVGA_MAX_WIDTH / 2), 0);
|
||||
controller.AddAxis(Inputs.Mouse + " " + MouseInputs.SpeedY, (-LibDOSBox.SVGA_MAX_HEIGHT / 2).RangeTo(LibDOSBox.SVGA_MAX_HEIGHT / 2), 0);
|
||||
// Range above 180 results in minimal mouse movement values bigger than 1, and we need 1 as a basis before sensitivity is applied
|
||||
// To adjust sensitivity, use the corresponding sync setting (global sensitivity for raw deltas is a TODO)
|
||||
controller.AddAxis(Inputs.Mouse + " " + MouseInputs.SpeedX, (-180).RangeTo(180), 0);
|
||||
controller.AddAxis(Inputs.Mouse + " " + MouseInputs.SpeedY, (-180).RangeTo(180), 0);
|
||||
}
|
||||
|
||||
// Adding drive management buttons
|
||||
|
|
|
@ -225,17 +225,17 @@ namespace BizHawk.Emulation.Cores.Computers.DOS
|
|||
|
||||
[DisplayName("Mouse Sensitivity")]
|
||||
[Description("Adjusts the mouse relative speed (mickey) multiplier.")]
|
||||
[DefaultValue(1.0)]
|
||||
[DefaultValue(3.0)]
|
||||
public float MouseSensitivity { get; set; }
|
||||
|
||||
[DisplayName("Writeable Hard Disk Drive")]
|
||||
[Description("Determines whether to mount an empty writable formatted hard disk in drive C:. This hard disk will be fully located in memory so make sure you have enough RAM available. Its contents can be saved and loaded as SaveRAM.")]
|
||||
[DisplayName("Mount Writeable Hard Disk Drive")]
|
||||
[Description("Determines whether to mount an empty writable formatted hard disk in drive C:. This hard disk will be fully located in memory so make sure you have enough RAM available. Its contents can be saved and loaded as SaveRAM (can be slow).")]
|
||||
[DefaultValue(WriteableHardDiskOptions.FAT16_241Mb)]
|
||||
[TypeConverter(typeof(DescribableEnumConverter))]
|
||||
public WriteableHardDiskOptions WriteableHardDisk { get; set; }
|
||||
|
||||
[DisplayName("Preserve Hard Disk Contents")]
|
||||
[Description("Determines whether to store the contents of the writeable hard disk as SaveRAM to be reloaded on the next start. Enabling this option may cause the core to take some seconds to store and load the SRAM upon restart.")]
|
||||
[Description("Determines whether to store the contents of the writeable hard disk as SaveRAM to be reloaded on the next start. Enabling this option may cause the core to take some seconds to store and load the SRAM upon restart, depending on the size of the hard disk. If it is disabled, previous SaveRAM will not be loaded.")]
|
||||
[DefaultValue(false)]
|
||||
public bool PreserveHardDiskContents { get; set; }
|
||||
|
||||
|
@ -249,7 +249,6 @@ namespace BizHawk.Emulation.Cores.Computers.DOS
|
|||
[DefaultValue(LibDOSBox.VIDEO_DENOMINATOR_DOS)]
|
||||
public ulong FPSDenominator { get; set; }
|
||||
|
||||
|
||||
[DisplayName("CPU Cycles")]
|
||||
[Description("How many CPU cycles to emulate per ms. Default: -1, to keep the one included in the configuration preset.")]
|
||||
[DefaultValue(-1)]
|
||||
|
|
|
@ -32,8 +32,10 @@ namespace BizHawk.Emulation.Cores.Computers.DOS
|
|||
DefaultFpsDenominator = LibDOSBox.VIDEO_DENOMINATOR_DOS
|
||||
};
|
||||
|
||||
private LibDOSBox _libDOSBox;
|
||||
private readonly List<IRomAsset> _floppyDiskAssets;
|
||||
private readonly List<IDiscAsset> _discAssets;
|
||||
private const int _messageDuration = 4;
|
||||
|
||||
// Drive management variables
|
||||
private bool _nextFloppyDiskPressed = false;
|
||||
|
@ -49,8 +51,13 @@ namespace BizHawk.Emulation.Cores.Computers.DOS
|
|||
|
||||
private string GetFullName(IRomAsset rom) => rom.Game.Name + rom.Extension;
|
||||
|
||||
// CD Handling logic
|
||||
private List<string> _cdRomFileNames = new List<string>();
|
||||
private Dictionary<string, DiscSectorReader> _cdRomFileToReaderMap = new Dictionary<string, DiscSectorReader>();
|
||||
private readonly LibDOSBox.CDReadCallback _CDReadCallback;
|
||||
|
||||
public long VsyncAttoseconds { get; private set; }
|
||||
public override int VirtualWidth => BufferHeight * 4 / 3;
|
||||
private LibDOSBox _libDOSBox;
|
||||
|
||||
// Image selection / swapping variables
|
||||
|
||||
|
@ -64,6 +71,7 @@ namespace BizHawk.Emulation.Cores.Computers.DOS
|
|||
|
||||
VsyncNumerator = (int) _syncSettings.FPSNumerator;
|
||||
VsyncDenominator = (int) _syncSettings.FPSDenominator;
|
||||
VsyncAttoseconds = (long)(1000000000000000000 * _syncSettings.FPSDenominator / _syncSettings.FPSNumerator);
|
||||
DriveLightEnabled = false;
|
||||
ControllerDefinition = CreateControllerDefinition(_syncSettings, _floppyDiskAssets.Count, _discAssets.Count);
|
||||
|
||||
|
@ -120,7 +128,7 @@ namespace BizHawk.Emulation.Cores.Computers.DOS
|
|||
|
||||
// Getting disc data structure
|
||||
var CDDataStruct = GetCDDataStruct(_discAssets[discIdx].DiscData);
|
||||
Console.WriteLine($"[CD] Adding Disc {discIdx}: '{_discAssets[discIdx].DiscName}' as '{cdRomFileName}' with sector count: {CDDataStruct.end}, track count: {CDDataStruct.last}.");
|
||||
Console.WriteLine($"[CD] Adding Disc {discIdx}: '{_discAssets[discIdx].DiscName}' as '{cdRomFileName}' with sector count: {CDDataStruct.End}, track count: {CDDataStruct.Last}.");
|
||||
|
||||
// Adding file name to list
|
||||
_cdRomFileNames.Add(cdRomFileName);
|
||||
|
@ -132,10 +140,10 @@ namespace BizHawk.Emulation.Cores.Computers.DOS
|
|||
_cdRomFileToReaderMap[cdRomFileName] = discSectorReader;
|
||||
|
||||
// Passing CD Data to the core
|
||||
_libDOSBox.pushCDData(curDiscIndex, CDDataStruct.end, CDDataStruct.last);
|
||||
_libDOSBox.pushCDData(curDiscIndex, CDDataStruct.End, CDDataStruct.Last);
|
||||
|
||||
// Passing track data to the core
|
||||
for (var trackIdx = 0; trackIdx < CDDataStruct.last; trackIdx++) _libDOSBox.pushTrackData(curDiscIndex, trackIdx, CDDataStruct.tracks[trackIdx]);
|
||||
for (var trackIdx = 0; trackIdx < CDDataStruct.Last; trackIdx++) _libDOSBox.pushTrackData(curDiscIndex, trackIdx, CDDataStruct.Tracks[trackIdx]);
|
||||
}
|
||||
////// CD Loading Logic End
|
||||
|
||||
|
@ -257,12 +265,12 @@ namespace BizHawk.Emulation.Cores.Computers.DOS
|
|||
|
||||
////////////// Initializing Core
|
||||
if (!_libDOSBox.Init(new LibDOSBox.InitSettings() {
|
||||
joystick1Enabled = _syncSettings.EnableJoystick1 ? 1 : 0,
|
||||
joystick2Enabled = _syncSettings.EnableJoystick2 ? 1 : 0,
|
||||
hardDiskDriveSize = writableHDDImageFileSize,
|
||||
preserveHardDiskContents = _syncSettings.PreserveHardDiskContents ? 1 : 0,
|
||||
fpsNumerator = _syncSettings.FPSNumerator,
|
||||
fpsDenominator = _syncSettings.FPSDenominator }))
|
||||
Joystick1Enabled = _syncSettings.EnableJoystick1 ? 1 : 0,
|
||||
Joystick2Enabled = _syncSettings.EnableJoystick2 ? 1 : 0,
|
||||
HardDiskDriveSize = writableHDDImageFileSize,
|
||||
PreserveHardDiskContents = _syncSettings.PreserveHardDiskContents ? 1 : 0,
|
||||
FpsNumerator = _syncSettings.FPSNumerator,
|
||||
FpsDenominator = _syncSettings.FPSDenominator }))
|
||||
{
|
||||
throw new InvalidOperationException("Core rejected the rom!");
|
||||
}
|
||||
|
@ -275,11 +283,6 @@ namespace BizHawk.Emulation.Cores.Computers.DOS
|
|||
if (_cdRomFileNames.Count > 0) DriveLightEnabled = true;
|
||||
}
|
||||
|
||||
// CD Handling logic
|
||||
private List<string> _cdRomFileNames = new List<string>();
|
||||
private Dictionary<string, DiscSectorReader> _cdRomFileToReaderMap = new Dictionary<string, DiscSectorReader>();
|
||||
private readonly LibDOSBox.CDReadCallback _CDReadCallback;
|
||||
|
||||
public static LibDOSBox.CDData GetCDDataStruct(Disc cd)
|
||||
{
|
||||
var ret = new LibDOSBox.CDData();
|
||||
|
@ -288,27 +291,27 @@ namespace BizHawk.Emulation.Cores.Computers.DOS
|
|||
|
||||
for (var i = 0; i < LibDOSBox.CD_MAX_TRACKS; i++)
|
||||
{
|
||||
ret.tracks[i] = new();
|
||||
ret.tracks[i].offset = 0;
|
||||
ret.tracks[i].loopEnabled = 0;
|
||||
ret.tracks[i].loopOffset = 0;
|
||||
ret.Tracks[i] = new();
|
||||
ret.Tracks[i].Offset = 0;
|
||||
ret.Tracks[i].LoopEnabled = 0;
|
||||
ret.Tracks[i].LoopOffset = 0;
|
||||
|
||||
if (i < ntrack)
|
||||
{
|
||||
ret.tracks[i].start = ses.Tracks[i + 1].LBA;
|
||||
ret.tracks[i].end = ses.Tracks[i + 2].LBA;
|
||||
ret.tracks[i].mode = ses.Tracks[i + 1].Mode;
|
||||
ret.Tracks[i].Start = ses.Tracks[i + 1].LBA;
|
||||
ret.Tracks[i].End = ses.Tracks[i + 2].LBA;
|
||||
ret.Tracks[i].Mode = ses.Tracks[i + 1].Mode;
|
||||
if (i == ntrack - 1)
|
||||
{
|
||||
ret.end = ret.tracks[i].end;
|
||||
ret.last = ntrack;
|
||||
ret.End = ret.Tracks[i].End;
|
||||
ret.Last = ntrack;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ret.tracks[i].start = 0;
|
||||
ret.tracks[i].end = 0;
|
||||
ret.tracks[i].mode = 0;
|
||||
ret.Tracks[i].Start = 0;
|
||||
ret.Tracks[i].End = 0;
|
||||
ret.Tracks[i].Mode = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -351,83 +354,81 @@ namespace BizHawk.Emulation.Cores.Computers.DOS
|
|||
// Setting joystick inputs
|
||||
if (_syncSettings.EnableJoystick1)
|
||||
{
|
||||
fi.joystick1.up = controller.IsPressed($"P1 {Inputs.Joystick} {JoystickButtons.Up}") ? 1 : 0;
|
||||
fi.joystick1.down = controller.IsPressed($"P1 {Inputs.Joystick} {JoystickButtons.Down}") ? 1 : 0;
|
||||
fi.joystick1.left = controller.IsPressed($"P1 {Inputs.Joystick} {JoystickButtons.Left}") ? 1 : 0;
|
||||
fi.joystick1.right = controller.IsPressed($"P1 {Inputs.Joystick} {JoystickButtons.Right}") ? 1 : 0;
|
||||
fi.joystick1.button1 = controller.IsPressed($"P1 {Inputs.Joystick} {JoystickButtons.Button1}") ? 1 : 0;
|
||||
fi.joystick1.button2 = controller.IsPressed($"P1 {Inputs.Joystick} {JoystickButtons.Button2}") ? 1 : 0;
|
||||
fi.Joystick1.Up = controller.IsPressed($"P1 {Inputs.Joystick} {JoystickButtons.Up}") ? 1 : 0;
|
||||
fi.Joystick1.Down = controller.IsPressed($"P1 {Inputs.Joystick} {JoystickButtons.Down}") ? 1 : 0;
|
||||
fi.Joystick1.Left = controller.IsPressed($"P1 {Inputs.Joystick} {JoystickButtons.Left}") ? 1 : 0;
|
||||
fi.Joystick1.Right = controller.IsPressed($"P1 {Inputs.Joystick} {JoystickButtons.Right}") ? 1 : 0;
|
||||
fi.Joystick1.Button1 = controller.IsPressed($"P1 {Inputs.Joystick} {JoystickButtons.Button1}") ? 1 : 0;
|
||||
fi.Joystick1.Button2 = controller.IsPressed($"P1 {Inputs.Joystick} {JoystickButtons.Button2}") ? 1 : 0;
|
||||
}
|
||||
|
||||
if (_syncSettings.EnableJoystick2)
|
||||
{
|
||||
fi.joystick2.up = controller.IsPressed($"P2 {Inputs.Joystick} {JoystickButtons.Up}") ? 1 : 0;
|
||||
fi.joystick2.down = controller.IsPressed($"P2 {Inputs.Joystick} {JoystickButtons.Down}") ? 1 : 0;
|
||||
fi.joystick2.left = controller.IsPressed($"P2 {Inputs.Joystick} {JoystickButtons.Left}") ? 1 : 0;
|
||||
fi.joystick2.right = controller.IsPressed($"P2 {Inputs.Joystick} {JoystickButtons.Right}") ? 1 : 0;
|
||||
fi.joystick2.button1 = controller.IsPressed($"P2 {Inputs.Joystick} {JoystickButtons.Button1}") ? 1 : 0;
|
||||
fi.joystick2.button2 = controller.IsPressed($"P2 {Inputs.Joystick} {JoystickButtons.Button2}") ? 1 : 0;
|
||||
fi.Joystick2.Up = controller.IsPressed($"P2 {Inputs.Joystick} {JoystickButtons.Up}") ? 1 : 0;
|
||||
fi.Joystick2.Down = controller.IsPressed($"P2 {Inputs.Joystick} {JoystickButtons.Down}") ? 1 : 0;
|
||||
fi.Joystick2.Left = controller.IsPressed($"P2 {Inputs.Joystick} {JoystickButtons.Left}") ? 1 : 0;
|
||||
fi.Joystick2.Right = controller.IsPressed($"P2 {Inputs.Joystick} {JoystickButtons.Right}") ? 1 : 0;
|
||||
fi.Joystick2.Button1 = controller.IsPressed($"P2 {Inputs.Joystick} {JoystickButtons.Button1}") ? 1 : 0;
|
||||
fi.Joystick2.Button2 = controller.IsPressed($"P2 {Inputs.Joystick} {JoystickButtons.Button2}") ? 1 : 0;
|
||||
}
|
||||
|
||||
// Setting mouse inputs
|
||||
if (_syncSettings.EnableMouse)
|
||||
{
|
||||
// Getting new mouse state values
|
||||
DOSBox.MouseState mouseState = new()
|
||||
{
|
||||
PosX = controller.AxisValue($"{Inputs.Mouse} {MouseInputs.PosX}"),
|
||||
PosY = controller.AxisValue($"{Inputs.Mouse} { MouseInputs.PosY}"),
|
||||
LeftButtonHeld = controller.IsPressed($"{Inputs.Mouse} {MouseInputs.LeftButton}"),
|
||||
MiddleButtonHeld = controller.IsPressed($"{Inputs.Mouse} {MouseInputs.MiddleButton}"),
|
||||
RightButtonHeld = controller.IsPressed($"{Inputs.Mouse} {MouseInputs.RightButton}"),
|
||||
};
|
||||
|
||||
var deltaX = controller.AxisValue($"{Inputs.Mouse} {MouseInputs.SpeedX}");
|
||||
var deltaY = controller.AxisValue($"{Inputs.Mouse} {MouseInputs.SpeedY}");
|
||||
fi.mouse.posX = controller.AxisValue($"{Inputs.Mouse} {MouseInputs.PosX}");
|
||||
fi.mouse.posY = controller.AxisValue($"{Inputs.Mouse} { MouseInputs.PosY}");
|
||||
fi.mouse.dX = deltaX != 0 ? deltaX : fi.mouse.posX - _mouseState.posX;
|
||||
fi.mouse.dY = deltaY != 0 ? deltaY : fi.mouse.posY - _mouseState.posY;
|
||||
fi.Mouse.PosX = mouseState.PosX;
|
||||
fi.Mouse.PosY = mouseState.PosY;
|
||||
fi.Mouse.DeltaX = deltaX != 0 ? deltaX : fi.Mouse.PosX - _lastMouseState.PosX;
|
||||
fi.Mouse.DeltaY = deltaY != 0 ? deltaY : fi.Mouse.PosY - _lastMouseState.PosY;
|
||||
|
||||
// Button pressed criteria:
|
||||
bool isMouseLeftButtonPressed = controller.IsPressed($"{Inputs.Mouse} {MouseInputs.LeftButton}");
|
||||
bool isMouseMiddleButtonPressed = controller.IsPressed($"{Inputs.Mouse} {MouseInputs.MiddleButton}");
|
||||
bool isMouseRightButtonPressed = controller.IsPressed($"{Inputs.Mouse} {MouseInputs.RightButton}");
|
||||
|
||||
// If the input is made in this frame and the button is not held from before
|
||||
fi.mouse.leftButtonPressed = isMouseLeftButtonPressed && !_mouseState.leftButtonHeld ? 1 : 0;
|
||||
fi.mouse.middleButtonPressed = isMouseMiddleButtonPressed && !_mouseState.middleButtonHeld ? 1 : 0;
|
||||
fi.mouse.rightButtonPressed = isMouseRightButtonPressed && !_mouseState.rightButtonHeld ? 1 : 0;
|
||||
fi.Mouse.LeftButtonPressed = mouseState.LeftButtonHeld && !_lastMouseState.LeftButtonHeld ? 1 : 0;
|
||||
fi.Mouse.MiddleButtonPressed = mouseState.MiddleButtonHeld && !_lastMouseState.MiddleButtonHeld ? 1 : 0;
|
||||
fi.Mouse.RightButtonPressed = mouseState.RightButtonHeld && !_lastMouseState.RightButtonHeld ? 1 : 0;
|
||||
|
||||
// Button released criteria:
|
||||
// If the input is not pressed in this frame and the button is held from before
|
||||
fi.mouse.leftButtonReleased = !isMouseLeftButtonPressed && _mouseState.leftButtonHeld ? 1 : 0;
|
||||
fi.mouse.middleButtonReleased = !isMouseMiddleButtonPressed && _mouseState.middleButtonHeld ? 1 : 0;
|
||||
fi.mouse.rightButtonReleased = !isMouseRightButtonPressed && _mouseState.rightButtonHeld ? 1 : 0;
|
||||
fi.mouse.sensitivity = _syncSettings.MouseSensitivity;
|
||||
|
||||
// Getting new mouse state values
|
||||
var nextState = new DOSBox.MouseState();
|
||||
nextState.posX = fi.mouse.posX;
|
||||
nextState.posY = fi.mouse.posY;
|
||||
nextState.leftButtonHeld = isMouseLeftButtonPressed;
|
||||
nextState.middleButtonHeld = isMouseMiddleButtonPressed;
|
||||
nextState.rightButtonHeld = isMouseRightButtonPressed;
|
||||
fi.Mouse.LeftButtonReleased = !mouseState.LeftButtonHeld && _lastMouseState.LeftButtonHeld ? 1 : 0;
|
||||
fi.Mouse.MiddleButtonReleased = !mouseState.MiddleButtonHeld && _lastMouseState.MiddleButtonHeld ? 1 : 0;
|
||||
fi.Mouse.RightButtonReleased = !mouseState.RightButtonHeld && _lastMouseState.RightButtonHeld ? 1 : 0;
|
||||
fi.Mouse.Sensitivity = _syncSettings.MouseSensitivity;
|
||||
|
||||
// Updating mouse state
|
||||
_mouseState = nextState;
|
||||
_lastMouseState = mouseState;
|
||||
}
|
||||
|
||||
// Processing floppy disks swaps
|
||||
fi.driveActions.insertFloppyDisk = -1;
|
||||
fi.DriveActions.InsertFloppyDisk = -1;
|
||||
var nextFloppyDiskWasPressed = _nextFloppyDiskPressed;
|
||||
_nextFloppyDiskPressed = controller.IsPressed(Inputs.NextFloppyDisk);
|
||||
if (!nextFloppyDiskWasPressed && _nextFloppyDiskPressed && _floppyDiskCount >= 2)
|
||||
{
|
||||
_currentFloppyDisk = (_currentFloppyDisk + 1) % _floppyDiskCount;
|
||||
fi.driveActions.insertFloppyDisk = _currentFloppyDisk;
|
||||
CoreComm.Notify($"Insterted FloppyDisk {_currentFloppyDisk}: {GetFullName(_floppyDiskImageFiles[_currentFloppyDisk])} into drive A:", null);
|
||||
fi.DriveActions.InsertFloppyDisk = _currentFloppyDisk;
|
||||
CoreComm.Notify($"Insterted {FileNames.FD}{_currentFloppyDisk}: {Path.GetFileName(_floppyDiskImageFiles[_currentFloppyDisk].RomPath)} into drive A:", _messageDuration);
|
||||
}
|
||||
|
||||
// Processing CDROM swaps
|
||||
fi.driveActions.insertCDROM = -1;
|
||||
fi.DriveActions.InsertCDROM = -1;
|
||||
var nextCDROMWasPressed = _nextCDROMPressed;
|
||||
_nextCDROMPressed = controller.IsPressed(Inputs.NextCDROM);
|
||||
if (!nextCDROMWasPressed && _nextCDROMPressed && _cdRomFileNames.Count >= 2)
|
||||
{
|
||||
_currentCDROM = (_currentCDROM + 1) % _cdRomFileNames.Count;
|
||||
fi.driveActions.insertCDROM = _currentCDROM;
|
||||
CoreComm.Notify($"Insterted CDROM {_currentCDROM}: {_cdRomFileNames[_currentCDROM]} into drive D:", null);
|
||||
fi.DriveActions.InsertCDROM = _currentCDROM;
|
||||
CoreComm.Notify($"Insterted {FileNames.CD}{_currentCDROM}: {_cdRomFileNames[_currentCDROM]} into drive D:", _messageDuration);
|
||||
}
|
||||
|
||||
// Processing keyboard inputs
|
||||
|
@ -472,11 +473,11 @@ namespace BizHawk.Emulation.Cores.Computers.DOS
|
|||
writer.Write(_currentFloppyDisk);
|
||||
writer.Write(_currentCDROM);
|
||||
|
||||
writer.Write(_mouseState.posX);
|
||||
writer.Write(_mouseState.posY);
|
||||
writer.Write(_mouseState.leftButtonHeld);
|
||||
writer.Write(_mouseState.middleButtonHeld);
|
||||
writer.Write(_mouseState.rightButtonHeld);
|
||||
writer.Write(_lastMouseState.PosX);
|
||||
writer.Write(_lastMouseState.PosY);
|
||||
writer.Write(_lastMouseState.LeftButtonHeld);
|
||||
writer.Write(_lastMouseState.MiddleButtonHeld);
|
||||
writer.Write(_lastMouseState.RightButtonHeld);
|
||||
}
|
||||
|
||||
protected override void LoadStateBinaryInternal(BinaryReader reader)
|
||||
|
@ -486,11 +487,11 @@ namespace BizHawk.Emulation.Cores.Computers.DOS
|
|||
_currentFloppyDisk = reader.ReadInt32();
|
||||
_currentCDROM = reader.ReadInt32();
|
||||
|
||||
_mouseState.posX = reader.ReadInt32();
|
||||
_mouseState.posY = reader.ReadInt32();
|
||||
_mouseState.leftButtonHeld = reader.ReadBoolean();
|
||||
_mouseState.middleButtonHeld = reader.ReadBoolean();
|
||||
_mouseState.rightButtonHeld = reader.ReadBoolean();
|
||||
_lastMouseState.PosX = reader.ReadInt32();
|
||||
_lastMouseState.PosY = reader.ReadInt32();
|
||||
_lastMouseState.LeftButtonHeld = reader.ReadBoolean();
|
||||
_lastMouseState.MiddleButtonHeld = reader.ReadBoolean();
|
||||
_lastMouseState.RightButtonHeld = reader.ReadBoolean();
|
||||
}
|
||||
|
||||
private static class FileNames
|
||||
|
|
|
@ -13,9 +13,9 @@ namespace BizHawk.Emulation.Cores.Computers.DOS
|
|||
public const int SVGA_MAX_WIDTH = 800;
|
||||
public const int SVGA_MAX_HEIGHT = 600;
|
||||
|
||||
// Default FPS: 70.086303
|
||||
public const int VIDEO_NUMERATOR_DOS = 70086303;
|
||||
public const int VIDEO_DENOMINATOR_DOS = 1000000;
|
||||
// Default FPS: 70.086592427616921
|
||||
public const int VIDEO_NUMERATOR_DOS = 3146888;
|
||||
public const int VIDEO_DENOMINATOR_DOS = 44900;
|
||||
|
||||
public const int FASTMEM_AUTO = -1;
|
||||
public const int MAX_FLOPPIES = 4;
|
||||
|
@ -28,22 +28,22 @@ namespace BizHawk.Emulation.Cores.Computers.DOS
|
|||
[StructLayout(LayoutKind.Sequential)]
|
||||
public class CDTrack
|
||||
{
|
||||
public int offset;
|
||||
public int start;
|
||||
public int end;
|
||||
public int mode;
|
||||
public int loopEnabled;
|
||||
public int loopOffset;
|
||||
public int Offset;
|
||||
public int Start;
|
||||
public int End;
|
||||
public int Mode;
|
||||
public int LoopEnabled;
|
||||
public int LoopOffset;
|
||||
}
|
||||
|
||||
public const int CD_MAX_TRACKS = 100;
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public class CDData
|
||||
{
|
||||
public int end;
|
||||
public int last;
|
||||
public int End;
|
||||
public int Last;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = CD_MAX_TRACKS)]
|
||||
public readonly CDTrack[] tracks = new CDTrack[CD_MAX_TRACKS];
|
||||
public readonly CDTrack[] Tracks = new CDTrack[CD_MAX_TRACKS];
|
||||
}
|
||||
|
||||
[UnmanagedFunctionPointer(CC)]
|
||||
|
@ -67,12 +67,12 @@ namespace BizHawk.Emulation.Cores.Computers.DOS
|
|||
[StructLayout(LayoutKind.Sequential)]
|
||||
public class InitSettings
|
||||
{
|
||||
public int joystick1Enabled;
|
||||
public int joystick2Enabled;
|
||||
public ulong hardDiskDriveSize;
|
||||
public int preserveHardDiskContents;
|
||||
public ulong fpsNumerator;
|
||||
public ulong fpsDenominator;
|
||||
public int Joystick1Enabled;
|
||||
public int Joystick2Enabled;
|
||||
public ulong HardDiskDriveSize;
|
||||
public int PreserveHardDiskContents;
|
||||
public ulong FpsNumerator;
|
||||
public ulong FpsDenominator;
|
||||
}
|
||||
|
||||
// CD Management Logic END
|
||||
|
@ -91,46 +91,44 @@ namespace BizHawk.Emulation.Cores.Computers.DOS
|
|||
{
|
||||
public unsafe fixed byte Buffer[KEY_COUNT];
|
||||
}
|
||||
public DriveActions driveActions;
|
||||
public JoystickButtons joystick1;
|
||||
public JoystickButtons joystick2;
|
||||
public MouseInput mouse;
|
||||
public ulong vgaRefreshRateNumerator;
|
||||
public ulong vgaRefreshRateDenominator;
|
||||
public DriveActions DriveActions;
|
||||
public JoystickButtons Joystick1;
|
||||
public JoystickButtons Joystick2;
|
||||
public MouseInput Mouse;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct DriveActions
|
||||
{
|
||||
public int insertFloppyDisk;
|
||||
public int insertCDROM;
|
||||
public int InsertFloppyDisk;
|
||||
public int InsertCDROM;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct JoystickButtons
|
||||
{
|
||||
public int up;
|
||||
public int down;
|
||||
public int left;
|
||||
public int right;
|
||||
public int button1;
|
||||
public int button2;
|
||||
public int Up;
|
||||
public int Down;
|
||||
public int Left;
|
||||
public int Right;
|
||||
public int Button1;
|
||||
public int Button2;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct MouseInput
|
||||
{
|
||||
public int posX;
|
||||
public int posY;
|
||||
public int dX; // Delta X
|
||||
public int dY; // Delta Y
|
||||
public int leftButtonPressed;
|
||||
public int middleButtonPressed;
|
||||
public int rightButtonPressed;
|
||||
public int leftButtonReleased;
|
||||
public int middleButtonReleased;
|
||||
public int rightButtonReleased;
|
||||
public float sensitivity;
|
||||
public int PosX;
|
||||
public int PosY;
|
||||
public int DeltaX;
|
||||
public int DeltaY;
|
||||
public int LeftButtonPressed;
|
||||
public int MiddleButtonPressed;
|
||||
public int RightButtonPressed;
|
||||
public int LeftButtonReleased;
|
||||
public int MiddleButtonReleased;
|
||||
public int RightButtonReleased;
|
||||
public float Sensitivity;
|
||||
}
|
||||
|
||||
// Follows enumeration in DOSBox-x
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 0838651ca7c06d8c236834dcf5aa307092b2a82e
|
||||
Subproject commit 0606d45caa0ab94c1ba34af4159d39e321a21036
|
|
@ -30,6 +30,10 @@ uint32_t ticksElapsed;
|
|||
uint32_t _GetTicks() { return ticksElapsed; }
|
||||
void _Delay(uint32_t ticks) { ticksElapsed += ticks; co_switch(_driverCoroutine); }
|
||||
|
||||
// VGA refresh rate information
|
||||
uint64_t _vgaRefreshRateNumerator;
|
||||
uint64_t _vgaRefreshRateDenominator;
|
||||
|
||||
// Memory file directory
|
||||
jaffarCommon::file::MemoryFileDirectory _memFileDirectory;
|
||||
|
||||
|
@ -124,6 +128,10 @@ ECL_EXPORT bool Init(InitSettings* settings)
|
|||
ticksTarget = 0.0;
|
||||
ticksElapsed = 0;
|
||||
|
||||
// Setting VGA refresh rate initial value, just in case
|
||||
_vgaRefreshRateNumerator = settings->fpsNumerator;
|
||||
_vgaRefreshRateDenominator = settings->fpsDenominator;
|
||||
|
||||
printf("Starting DOSBox-x Coroutine...\n");
|
||||
_driverCoroutine = co_active();
|
||||
constexpr size_t stackSize = 4 * 1024 * 1024;
|
||||
|
@ -304,6 +312,9 @@ ECL_EXPORT void FrameAdvance(MyFrameInfo* f)
|
|||
f->base.Samples = _audioSamples.size() / 2;
|
||||
}
|
||||
|
||||
ECL_EXPORT uint64_t getVGARefreshRateNumerator() { return _vgaRefreshRateNumerator; }
|
||||
ECL_EXPORT uint64_t getVGARefreshRateDenominator() { return _vgaRefreshRateDenominator; }
|
||||
|
||||
#define DOS_CONVENTIONAL_MEMORY_SIZE (640 * 1024)
|
||||
#define DOS_UPPER_MEMORY_SIZE (384 * 1024)
|
||||
#define DOS_LOWER_MEMORY_SIZE (DOS_CONVENTIONAL_MEMORY_SIZE + DOS_UPPER_MEMORY_SIZE)
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 3dbadebeb0e09e3fe1f8e3c1adb9f1fa8caef8d9
|
||||
Subproject commit 84bf43f79ee1e732baf4af96540c905a264af8e9
|
|
@ -1 +1 @@
|
|||
Subproject commit 256a718b96a0fb68faae5f0530e1018d19a1d770
|
||||
Subproject commit c28f4220943ecee4551dbfb5003969c8dfafdc98
|
|
@ -1 +1 @@
|
|||
Subproject commit e7aec3b9ab56cd86aff9838f56c154f1f73080f1
|
||||
Subproject commit 2063abc4e16c84218757b1db10d3cdf9f36ef3f8
|
|
@ -1 +1 @@
|
|||
Subproject commit 48734d5c38c12e3988959ebcb6efee4a570268e3
|
||||
Subproject commit 3479e040610f2370266aa153eb23989b6b439c0d
|
Loading…
Reference in New Issue