Skip to content

vpinball/pinmame-dotnet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PinMAME for .NET

CI status (x64 Linux, Android, iOS, 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 Core (.NETStandard 2.1 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
macOS x64 PinMame.Native.osx-x64-badge
macOS arm64 PinMame.Native.osx-arm64-badge
macOS x64/arm64 PinMame.Native.osx-badge
iOS arm64 PinMame.Native.ios-arm64-badge
Linux x64 PinMame.Native.linux-x64-badge
Android arm64-v8a PinMame.Native.android-arm64-v8a-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