jsm174 / pinmame-dotnet

Add PinMAME support to any .NET application

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PinMAME for .NET

CI status (x64 Linux, macOS and Windows) NuGet

Add PinMAME support to any .NET application

This NuGet package provides a .NET binding for PinMAME, an emulator for solid state pinball machines. It uses the cross-platform LibPinMAME.

This package is automatically built and published when the main project, PinMAME, is updated.

Supported Platforms

  • .NET Framework (4.5 and higher)
  • .NET Core (.NETStandard 2.0 and higher on Windows, Linux and macOS)
  • Mono

Setup

The native wrapper is a different package and contains pre-compiled binaries of LibPinMAME.

NuGet Package
Windows 64-bit PinMame.Native.win-x64-badge
Windows 32-bit PinMame.Native.win-x86-badge
Linux x64 PinMame.Native.linux-x64-badge
macOS x64 PinMame.Native.osx-x64-badge

To install this package with the native dependency of your current platform, run:

Install-Package PinMame
Install-Package PinMame-Native

Usage

Create a PinMame instance, and then start a game.

using PinMame;
var _pinMame = PinMame.PinMame.Instance();

_pinMame.StartGame("t2_l8");

You can add event handlers for:

  • OnGameStarted
  • OnDisplayAvailable
  • OnDisplayUpdated
  • OnAudioAvailable
  • OnAudioUpdated
  • OnMechAvailable
  • OnMechUpdated
  • OnSolenoidUpdated
  • OnConsoleDataUpdated
  • OnGameEnded
  • IsKeyPressed

To process display data, in your OnDisplayUpdated callback:

void OnDisplayUpdated(int index, IntPtr framePtr, PinMameDisplayLayout displayLayout) 
{
    if (displayLayout.IsDmd)
    {
        // Handle DMD displays (framePtr is byte*)
    }
    else
    {
        // Handle Alphanumeric displays (framePtr is ushort*)
    }
};

To add or update a mech:

_pinMame.SetHandleMechanics(0);

PinMameMechConfig mechConfig = new PinMameMechConfig(
   (uint)(PinMameMechFlag.NonLinear | PinMameMechFlag.Reverse | PinMameMechFlag.OneSol),
   11,
   240,
   240,
   0,
   0,
   0);
mechConfig.AddSwitch(new PinMameMechSwitchConfig(33, 0, 5));
mechConfig.AddSwitch(new PinMameMechSwitchConfig(32, 98, 105));

_pinMame.SetMech(0, mechConfig);

To remove a mech:

_pinMame.SetMech(0, null);

See the example project for more information.

License

MAME/BSD-3-Clause

About

Add PinMAME support to any .NET application

License:Other


Languages

Language:C# 100.0%