puae: wip
This commit is contained in:
parent
9fd58a766a
commit
a2d401d670
Binary file not shown.
|
@ -1,4 +1,5 @@
|
|||
using System.Runtime.InteropServices;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
using BizHawk.BizInvoke;
|
||||
using BizHawk.Emulation.Cores.Waterbox;
|
||||
|
@ -66,11 +67,27 @@ namespace BizHawk.Emulation.Cores.Computers.Amiga
|
|||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct ControllerState
|
||||
{
|
||||
public ControllerType Type;
|
||||
public AllButtons Buttons;
|
||||
public int MouseX;
|
||||
public int MouseY;
|
||||
}
|
||||
|
||||
public enum ControllerType : int
|
||||
{
|
||||
Joystick,
|
||||
Mouse,
|
||||
[Display(Name = "CD32 pad")]
|
||||
CD32_pad
|
||||
}
|
||||
|
||||
public enum DriveAction : int
|
||||
{
|
||||
None,
|
||||
Eject,
|
||||
Insert
|
||||
}
|
||||
|
||||
[Flags]
|
||||
public enum AllButtons : short
|
||||
{
|
||||
|
@ -198,12 +215,5 @@ namespace BizHawk.Emulation.Cores.Computers.Amiga
|
|||
Key_Left_Amiga = 0x66,
|
||||
Key_Right_Amiga = 0x67,
|
||||
}
|
||||
|
||||
public enum DriveAction : int
|
||||
{
|
||||
None,
|
||||
Eject,
|
||||
Insert
|
||||
}
|
||||
}
|
||||
}
|
|
@ -8,7 +8,7 @@ namespace BizHawk.Emulation.Cores.Computers.Amiga
|
|||
{
|
||||
public partial class PUAE
|
||||
{
|
||||
private ControllerType[] _ports { get; set; }
|
||||
private LibPUAE.ControllerType[] _ports { get; set; }
|
||||
private static readonly (string Name, LibPUAE.AllButtons Button)[] _joystickMap = CreateJoystickMap();
|
||||
private static readonly (string Name, LibPUAE.AllButtons Button)[] _cd32padMap = CreateCd32padMap();
|
||||
private static readonly (string Name, LibPUAE.PUAEKeyboard Key)[] _keyboardMap = CreateKeyboardMap();
|
||||
|
@ -62,13 +62,13 @@ namespace BizHawk.Emulation.Cores.Computers.Amiga
|
|||
|
||||
for (int port = 1; port <= 2; port++)
|
||||
{
|
||||
ControllerType type = port == 1
|
||||
LibPUAE.ControllerType type = port == 1
|
||||
? settings.ControllerPort1
|
||||
: settings.ControllerPort2;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case ControllerType.Joystick:
|
||||
case LibPUAE.ControllerType.Joystick:
|
||||
{
|
||||
foreach (var (name, _) in _joystickMap)
|
||||
{
|
||||
|
@ -76,7 +76,7 @@ namespace BizHawk.Emulation.Cores.Computers.Amiga
|
|||
}
|
||||
break;
|
||||
}
|
||||
case ControllerType.CD32_pad:
|
||||
case LibPUAE.ControllerType.CD32_pad:
|
||||
{
|
||||
foreach (var (name, _) in _cd32padMap)
|
||||
{
|
||||
|
@ -84,7 +84,7 @@ namespace BizHawk.Emulation.Cores.Computers.Amiga
|
|||
}
|
||||
break;
|
||||
}
|
||||
case ControllerType.Mouse:
|
||||
case LibPUAE.ControllerType.Mouse:
|
||||
{
|
||||
controller.BoolButtons.AddRange(
|
||||
[
|
||||
|
|
|
@ -130,14 +130,6 @@ namespace BizHawk.Emulation.Cores.Computers.Amiga
|
|||
DRV_FB
|
||||
}
|
||||
|
||||
public enum ControllerType
|
||||
{
|
||||
Joystick,
|
||||
Mouse,
|
||||
[Display(Name = "CD32 pad")]
|
||||
CD32_pad
|
||||
}
|
||||
|
||||
private void CreateArguments(PUAESyncSettings settings)
|
||||
{
|
||||
_args = new List<string>
|
||||
|
@ -336,15 +328,15 @@ namespace BizHawk.Emulation.Cores.Computers.Amiga
|
|||
|
||||
[DisplayName("Controller port 1")]
|
||||
[Description("")]
|
||||
[DefaultValue(ControllerType.Joystick)]
|
||||
[DefaultValue(LibPUAE.ControllerType.Joystick)]
|
||||
[TypeConverter(typeof(DescribableEnumConverter))]
|
||||
public ControllerType ControllerPort1 { get; set; }
|
||||
public LibPUAE.ControllerType ControllerPort1 { get; set; }
|
||||
|
||||
[DisplayName("Controller port 2")]
|
||||
[Description("")]
|
||||
[DefaultValue(ControllerType.Mouse)]
|
||||
[DefaultValue(LibPUAE.ControllerType.Mouse)]
|
||||
[TypeConverter(typeof(DescribableEnumConverter))]
|
||||
public ControllerType ControllerPort2 { get; set; }
|
||||
public LibPUAE.ControllerType ControllerPort2 { get; set; }
|
||||
|
||||
[DisplayName("Mouse speed")]
|
||||
[Description("Mouse speed in percents (1% - 1000%). Adjust if there's mismatch between emulated and host mouse movement. Note that maximum mouse movement is still 127 pixels due to Amiga hardware limitations.")]
|
||||
|
|
|
@ -149,10 +149,12 @@ namespace BizHawk.Emulation.Cores.Computers.Amiga
|
|||
{
|
||||
Port1 = new LibPUAE.ControllerState
|
||||
{
|
||||
Type = _ports[0],
|
||||
Buttons = 0
|
||||
},
|
||||
Port2 = new LibPUAE.ControllerState
|
||||
{
|
||||
Type = _ports[1],
|
||||
Buttons = 0
|
||||
},
|
||||
Action = LibPUAE.DriveAction.None
|
||||
|
@ -164,7 +166,7 @@ namespace BizHawk.Emulation.Cores.Computers.Amiga
|
|||
|
||||
switch (_ports[port - 1])
|
||||
{
|
||||
case ControllerType.Joystick:
|
||||
case LibPUAE.ControllerType.Joystick:
|
||||
{
|
||||
foreach (var (name, button) in _joystickMap)
|
||||
{
|
||||
|
@ -175,7 +177,7 @@ namespace BizHawk.Emulation.Cores.Computers.Amiga
|
|||
}
|
||||
break;
|
||||
}
|
||||
case ControllerType.CD32_pad:
|
||||
case LibPUAE.ControllerType.CD32_pad:
|
||||
{
|
||||
foreach (var (name, button) in _cd32padMap)
|
||||
{
|
||||
|
@ -186,7 +188,7 @@ namespace BizHawk.Emulation.Cores.Computers.Amiga
|
|||
}
|
||||
break;
|
||||
}
|
||||
case ControllerType.Mouse:
|
||||
case LibPUAE.ControllerType.Mouse:
|
||||
{
|
||||
if (controller.IsPressed($"P{port} {Inputs.MouseLeftButton}"))
|
||||
{
|
||||
|
|
|
@ -2,16 +2,15 @@
|
|||
|
||||
ECL_EXPORT bool Init(int argc, char **argv)
|
||||
{
|
||||
last_mouse_x = 0;
|
||||
last_mouse_y = 0;
|
||||
log_cb = biz_log_cb;
|
||||
libretro_runloop_active = 0;
|
||||
|
||||
pix_bytes = 4;
|
||||
defaultw = PUAE_VIDEO_WIDTH;
|
||||
defaulth = PUAE_VIDEO_HEIGHT_PAL;
|
||||
retrow = PUAE_VIDEO_WIDTH;
|
||||
retrow_crop = retrow;
|
||||
retroh_crop = retroh;
|
||||
log_cb = biz_log_cb;
|
||||
|
||||
retro_set_audio_sample_batch(biz_audio_cb);
|
||||
init_output_audio_buffer(2048);
|
||||
|
@ -33,39 +32,48 @@ void SetCD32ButtonState(int port, int button, int state)
|
|||
|
||||
ECL_EXPORT void FrameAdvance(MyFrameInfo* f)
|
||||
{
|
||||
|
||||
cd32_pad_enabled[0] = 1;
|
||||
cd32_pad_enabled[1] = 1;
|
||||
bool is_ntsc = minfirstline == VBLANK_ENDLINE_NTSC;
|
||||
f->base.Width = PUAE_VIDEO_WIDTH;
|
||||
f->base.Height = is_ntsc ? PUAE_VIDEO_HEIGHT_NTSC : PUAE_VIDEO_HEIGHT_PAL;
|
||||
sound_buffer = f->base.SoundBuffer;
|
||||
thisframe_y_adjust = minfirstline;
|
||||
visible_left_border = retro_max_diwlastword - retrow;
|
||||
|
||||
setjoystickstate(PORT_0, AXIS_VERTICAL,
|
||||
f->JoystickState.up ? JOY_MIN :
|
||||
f->JoystickState.down ? JOY_MAX : JOY_MID, 1);
|
||||
setjoystickstate(PORT_0, AXIS_HORIZONTAL,
|
||||
f->JoystickState.left ? JOY_MIN :
|
||||
f->JoystickState.right ? JOY_MAX : JOY_MID, 1);
|
||||
setjoybuttonstate(PORT_0, JOYBUTTON_1, f->JoystickState.b1);
|
||||
setjoybuttonstate(PORT_0, JOYBUTTON_2, f->JoystickState.b2);
|
||||
setjoybuttonstate(PORT_0, JOYBUTTON_3, f->JoystickState.b3);
|
||||
sound_buffer = f->base.SoundBuffer;
|
||||
|
||||
SetCD32ButtonState(PORT_0, JOYBUTTON_CD32_PLAY, f->JoystickState.b4);
|
||||
SetCD32ButtonState(PORT_0, JOYBUTTON_CD32_RWD, f->JoystickState.b5);
|
||||
SetCD32ButtonState(PORT_0, JOYBUTTON_CD32_FFW, f->JoystickState.b6);
|
||||
SetCD32ButtonState(PORT_0, JOYBUTTON_CD32_GREEN, f->JoystickState.b7);
|
||||
SetCD32ButtonState(PORT_0, JOYBUTTON_CD32_YELLOW, f->JoystickState.b8);
|
||||
SetCD32ButtonState(PORT_0, JOYBUTTON_CD32_RED, f->JoystickState.b9);
|
||||
SetCD32ButtonState(PORT_0, JOYBUTTON_CD32_BLUE, f->JoystickState.b10);
|
||||
for (int port = 0; port <= 1; port++)
|
||||
{
|
||||
Controller *controller = (port == 0) ? &f->Port1 : &f->Port2;
|
||||
cd32_pad_enabled[port] = 0;
|
||||
|
||||
setmousebuttonstate(PORT_0, MOUSE_LEFT, f->MouseButtons & 1);
|
||||
setmousebuttonstate(PORT_0, MOUSE_RIGHT, f->MouseButtons & 2);
|
||||
setmousebuttonstate(PORT_0, MOUSE_MIDDLE, f->MouseButtons & 4);
|
||||
setmousestate( PORT_0, AXIS_HORIZONTAL, f->MouseX - last_mouse_x, MOUSE_RELATIVE);
|
||||
setmousestate( PORT_0, AXIS_VERTICAL, f->MouseY - last_mouse_y, MOUSE_RELATIVE);
|
||||
// shared between mouse and joystick
|
||||
setjoybuttonstate(port, JOYBUTTON_1, controller->Buttons.b1);
|
||||
setjoybuttonstate(port, JOYBUTTON_2, controller->Buttons.b2);
|
||||
setjoybuttonstate(port, JOYBUTTON_3, controller->Buttons.b3);
|
||||
|
||||
switch (controller->Type)
|
||||
{
|
||||
case CONTROLLER_JOYSTICK:
|
||||
setjoystickstate(port, AXIS_VERTICAL, controller->Buttons.up ? JOY_MIN :
|
||||
controller->Buttons.down ? JOY_MAX : JOY_MID, 1);
|
||||
setjoystickstate(port, AXIS_HORIZONTAL, controller->Buttons.left ? JOY_MIN :
|
||||
controller->Buttons.right ? JOY_MAX : JOY_MID, 1);
|
||||
break;
|
||||
case CONTROLLER_CD32PAD:
|
||||
cd32_pad_enabled[port] = 1;
|
||||
SetCD32ButtonState(port, JOYBUTTON_CD32_PLAY, controller->Buttons.play);
|
||||
SetCD32ButtonState(port, JOYBUTTON_CD32_RWD, controller->Buttons.rewind);
|
||||
SetCD32ButtonState(port, JOYBUTTON_CD32_FFW, controller->Buttons.forward);
|
||||
SetCD32ButtonState(port, JOYBUTTON_CD32_GREEN, controller->Buttons.green);
|
||||
SetCD32ButtonState(port, JOYBUTTON_CD32_YELLOW, controller->Buttons.yellow);
|
||||
SetCD32ButtonState(port, JOYBUTTON_CD32_RED, controller->Buttons.red);
|
||||
SetCD32ButtonState(port, JOYBUTTON_CD32_BLUE, controller->Buttons.blue);
|
||||
break;
|
||||
case CONTROLLER_MOUSE:
|
||||
setmousestate(port, AXIS_HORIZONTAL, controller->MouseX - last_mouse_x[port], MOUSE_RELATIVE);
|
||||
setmousestate(port, AXIS_VERTICAL, controller->MouseY - last_mouse_y[port], MOUSE_RELATIVE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < KEY_COUNT; i++)
|
||||
if (f->Keys[i] != last_key_state[i])
|
||||
|
@ -88,9 +96,18 @@ ECL_EXPORT void FrameAdvance(MyFrameInfo* f)
|
|||
upload_output_audio_buffer();
|
||||
f->base.Samples = sound_sample_count;
|
||||
memcpy(f->base.VideoBuffer, retro_bmp, sizeof(retro_bmp) / sizeof(retro_bmp[0]));
|
||||
last_mouse_x = f->MouseX;
|
||||
last_mouse_y = f->MouseY;
|
||||
sound_buffer = NULL;
|
||||
|
||||
for (int port = 0; port <= 1; port++)
|
||||
{
|
||||
Controller *controller = (port == 0) ? &f->Port1 : &f->Port2;
|
||||
|
||||
if (controller->Type == CONTROLLER_MOUSE)
|
||||
{
|
||||
last_mouse_x[port] = controller->MouseX;
|
||||
last_mouse_y[port] = controller->MouseY;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ECL_EXPORT void GetMemoryAreas(MemoryArea *m)
|
||||
|
|
|
@ -28,9 +28,10 @@ static const int KEY_COUNT = 0x68;
|
|||
int16_t* sound_buffer = NULL;
|
||||
int sound_sample_count = 0;
|
||||
static char last_key_state[KEY_COUNT];
|
||||
static int last_mouse_x;
|
||||
static int last_mouse_y;
|
||||
static int last_mouse_x[NORMAL_JPORTS] = {0};
|
||||
static int last_mouse_y[NORMAL_JPORTS] = {0};
|
||||
|
||||
extern uint8_t libretro_runloop_active;
|
||||
extern int thisframe_y_adjust;
|
||||
extern unsigned short int defaultw;
|
||||
extern unsigned short int defaulth;
|
||||
|
@ -58,12 +59,6 @@ enum JoystickRange
|
|||
JOY_MAX
|
||||
};
|
||||
|
||||
enum ControllerPort
|
||||
{
|
||||
PORT_0,
|
||||
PORT_1
|
||||
};
|
||||
|
||||
enum MouseButtons
|
||||
{
|
||||
MOUSE_LEFT,
|
||||
|
@ -90,6 +85,13 @@ enum DriveAction
|
|||
ACTION_INSERT
|
||||
};
|
||||
|
||||
enum ControllerType
|
||||
{
|
||||
CONTROLLER_JOYSTICK,
|
||||
CONTROLLER_MOUSE,
|
||||
CONTROLLER_CD32PAD
|
||||
};
|
||||
|
||||
typedef union
|
||||
{
|
||||
struct
|
||||
|
@ -101,24 +103,30 @@ typedef union
|
|||
bool b1:1;
|
||||
bool b2:1;
|
||||
bool b3:1;
|
||||
bool b4:1;
|
||||
bool b5:1;
|
||||
bool b6:1;
|
||||
bool b7:1;
|
||||
bool b8:1;
|
||||
bool b9:1;
|
||||
bool b10:1;
|
||||
bool play:1;
|
||||
bool rewind:1;
|
||||
bool forward:1;
|
||||
bool green:1;
|
||||
bool yellow:1;
|
||||
bool red:1;
|
||||
bool blue:1;
|
||||
};
|
||||
uint16_t data;
|
||||
} PUAEJoystick;
|
||||
} AllButtons;
|
||||
|
||||
typedef struct ControllerState
|
||||
{
|
||||
int Type;
|
||||
AllButtons Buttons;
|
||||
int MouseX;
|
||||
int MouseY;
|
||||
} Controller;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
FrameInfo base;
|
||||
PUAEJoystick JoystickState;
|
||||
uint8_t MouseButtons;
|
||||
int MouseX;
|
||||
int MouseY;
|
||||
Controller Port1;
|
||||
Controller Port2;
|
||||
char Keys[KEY_COUNT];
|
||||
int CurrentDrive;
|
||||
int Action;
|
||||
|
|
Loading…
Reference in New Issue