Skip to content

Commit

Permalink
uae: eject when inserting
Browse files Browse the repository at this point in the history
less repeated magic
  • Loading branch information
vadosnaprimer committed Jun 14, 2024
1 parent f54faf4 commit d3c560b
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 34 deletions.
Binary file modified Assets/dll/puae.wbx.zst
Binary file not shown.
28 changes: 18 additions & 10 deletions src/BizHawk.Emulation.Cores/Computers/Amiga/LibPUAE.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ public abstract class LibPUAE : LibWaterboxCore
public const int MAX_FLOPPIES = 4;
public const int FILENAME_MAXLENGTH = 64;
public const int KEY_COUNT = 0x68;
public const byte b00000001 = 1 << 0;
public const byte b00000010 = 1 << 1;
public const byte b00000100 = 1 << 2;
public const byte b00001000 = 1 << 3;
public const byte b00010000 = 1 << 4;
public const byte b00100000 = 1 << 5;
public const byte b01000000 = 1 << 6;
public const byte b10000000 = 1 << 7;

[BizImport(CC, Compatibility = true)]
public abstract bool Init(int argc, string[] argv);
Expand Down Expand Up @@ -43,21 +51,21 @@ public struct FileName

public enum DriveAction : int
{
NONE,
EJECT,
INSERT
None,
Eject,
Insert
}

[Flags]
public enum PUAEJoystick : byte
{
Joystick_Up = 1 << 0,
Joystick_Down = 1 << 1,
Joystick_Left = 1 << 2,
Joystick_Right = 1 << 3,
Joystick_Button_1 = 1 << 4,
Joystick_Button_2 = 1 << 5,
Joystick_Button_3 = 1 << 6
Joystick_Up = b00000001,
Joystick_Down = b00000010,
Joystick_Left = b00000100,
Joystick_Right = b00001000,
Joystick_Button_1 = b00010000,
Joystick_Button_2 = b00100000,
Joystick_Button_3 = b01000000
}

// https://wiki.amigaos.net/wiki/Keymap_Library
Expand Down
46 changes: 22 additions & 24 deletions src/BizHawk.Emulation.Cores/Computers/Amiga/PUAE.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,12 @@ private static ControllerDefinition InitInput()

controller.BoolButtons.AddRange(
[
Inputs.MLB, Inputs.MMB, Inputs.MRB
Inputs.MouseLeftButton, Inputs.MouseMIddleButton, Inputs.MouseRightButton
]);

controller
.AddAxis(Inputs.X, (0).RangeTo(LibPUAE.PAL_WIDTH), LibPUAE.PAL_WIDTH / 2)
.AddAxis(Inputs.Y, (0).RangeTo(LibPUAE.PAL_HEIGHT), LibPUAE.PAL_HEIGHT / 2);
.AddAxis(Inputs.MouseX, (0).RangeTo(LibPUAE.PAL_WIDTH), LibPUAE.PAL_WIDTH / 2)
.AddAxis(Inputs.MouseY, (0).RangeTo(LibPUAE.PAL_HEIGHT), LibPUAE.PAL_HEIGHT / 2);

foreach (var b in controller.BoolButtons)
{
Expand All @@ -129,7 +129,7 @@ private static ControllerDefinition InitInput()

controller.BoolButtons.AddRange(
[
Inputs.Eject, Inputs.Insert, Inputs.NextDrive, Inputs.NextSlot
Inputs.NextDrive, Inputs.NextSlot, Inputs.Insert, Inputs.Eject
]);

foreach (var b in Enum.GetValues(typeof(LibPUAE.PUAEKeyboard)))
Expand All @@ -147,7 +147,7 @@ protected override LibWaterboxCore.FrameInfo FrameAdvancePrep(IController contro
var fi = new LibPUAE.FrameInfo
{
MouseButtons = 0,
Action = LibPUAE.DriveAction.NONE
Action = LibPUAE.DriveAction.None
};

foreach (var b in Enum.GetValues(typeof(LibPUAE.PUAEJoystick)))
Expand All @@ -158,31 +158,33 @@ protected override LibWaterboxCore.FrameInfo FrameAdvancePrep(IController contro
}
}

if (controller.IsPressed(Inputs.MLB))
if (controller.IsPressed(Inputs.MouseLeftButton))
{
fi.MouseButtons |= 1 << 0;
fi.MouseButtons |= LibPUAE.b00000001;
}
if (controller.IsPressed(Inputs.MRB))
if (controller.IsPressed(Inputs.MouseRightButton))
{
fi.MouseButtons |= 1 << 1;
fi.MouseButtons |= LibPUAE.b00000010;
}
if (controller.IsPressed(Inputs.MMB))
if (controller.IsPressed(Inputs.MouseMIddleButton))
{
fi.MouseButtons |= 1 << 2;
fi.MouseButtons |= LibPUAE.b00000100;
}
fi.MouseX = controller.AxisValue(Inputs.MouseX);
fi.MouseY = controller.AxisValue(Inputs.MouseY);

if (controller.IsPressed(Inputs.Eject))
{
if (!_ejectPressed)
{
fi.Action = LibPUAE.DriveAction.EJECT;
fi.Action = LibPUAE.DriveAction.Eject;
}
}
else if (controller.IsPressed(Inputs.Insert))
{
if (!_insertPressed)
{
fi.Action = LibPUAE.DriveAction.INSERT;
fi.Action = LibPUAE.DriveAction.Insert;
unsafe
{
string str = FileNames.FD + _currentSlot;
Expand Down Expand Up @@ -211,18 +213,14 @@ protected override LibWaterboxCore.FrameInfo FrameAdvancePrep(IController contro
{
_currentDrive++;
_currentDrive %= _syncSettings.FloppyDrives;
_comm.Notify($"Selected FD{ _currentDrive } Drive", null);
_comm.Notify($"Selected FD{ _currentDrive }: Drive", null);
}
}
_ejectPressed = controller.IsPressed(Inputs.Eject);
_insertPressed = controller.IsPressed(Inputs.Insert);
_nextSlotPressed = controller.IsPressed(Inputs.NextSlot);
_nextDrivePressed = controller.IsPressed(Inputs.NextDrive);

_nextDrivePressed = controller.IsPressed(Inputs.NextDrive);
fi.CurrentDrive = _currentDrive;

fi.MouseX = controller.AxisValue(Inputs.X);
fi.MouseY = controller.AxisValue(Inputs.Y);

foreach (var b in Enum.GetValues(typeof(LibPUAE.PUAEKeyboard)))
{
Expand Down Expand Up @@ -265,11 +263,11 @@ private static class FileNames

private static class Inputs
{
public const string MLB = "Mouse Left Button";
public const string MRB = "Mouse Right Button";
public const string MMB = "Mouse Middle Button";
public const string X = "Mouse X";
public const string Y = "Mouse Y";
public const string MouseLeftButton = "Mouse Left Button";
public const string MouseRightButton = "Mouse Right Button";
public const string MouseMIddleButton = "Mouse Middle Button";
public const string MouseX = "Mouse X";
public const string MouseY = "Mouse Y";
public const string Eject = "Eject";
public const string Insert = "Insert";
public const string NextDrive = "Next Drive";
Expand Down
1 change: 1 addition & 0 deletions waterbox/uae/bizhawk.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ ECL_EXPORT void FrameAdvance(MyFrameInfo* f)
}
else if (f->Action == ACTION_INSERT)
{
disk_eject(f->CurrentDrive);
disk_insert_force(f->CurrentDrive, f->FileName, true);
log_cb(RETRO_LOG_INFO, "INSERTED FD%d: \"%s\"\n", f->CurrentDrive, f->FileName);
}
Expand Down

0 comments on commit d3c560b

Please sign in to comment.