Skip to content

Commit 3fb8278

Browse files
committed
misc: update to latest pinmame-dotnet. Add definition for Rock
1 parent 849d54b commit 3fb8278

File tree

6 files changed

+226
-32
lines changed

6 files changed

+226
-32
lines changed

VisualPinball.Engine.PinMAME.Unity/Editor/PinMameGamelogicEngineInspector.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ private void OnEnable()
5555
new Terminator2(),
5656
new FlashGordon(),
5757
new StarTrekEnterprise(),
58+
new Rock(),
5859
};
5960
_gameNames = new[] {"-- none --"}
6061
.Concat(_games.Select(g => g.Name))

VisualPinball.Engine.PinMAME.Unity/Runtime/PinMameGamelogicEngine.cs

Lines changed: 48 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -126,19 +126,22 @@ public void OnInit(Player player, TableApi tableApi, BallManager ballManager)
126126

127127
Logger.Info($"New PinMAME instance at {(double)AudioSettings.outputSampleRate / 1000}kHz");
128128
_pinMame = PinMame.PinMame.Instance(AudioSettings.outputSampleRate);
129-
//_pinMame.SetHandleKeyboard(false);
129+
130+
_pinMame.SetHandleKeyboard(false);
131+
_pinMame.SetHandleMechanics(false);
130132

131133
_pinMame.OnGameStarted += GameStarted;
132-
_pinMame.OnGameEnded += GameEnded;
133-
_pinMame.OnDisplayUpdated += DisplayUpdated;
134-
_pinMame.OnSolenoidUpdated += SolenoidUpdated;
134+
_pinMame.OnGameEnded += GameEnded;
135135
_pinMame.OnDisplayAvailable += OnDisplayAvailable;
136+
_pinMame.OnDisplayUpdated += OnDisplayUpdated;
136137
_pinMame.OnAudioAvailable += OnAudioAvailable;
137-
_pinMame.OnAudioUpdated += OnAudioUpdated;
138+
_pinMame.OnAudioUpdated += OnAudioUpdated;
139+
_pinMame.OnMechAvailable += OnMechAvailable;
140+
_pinMame.OnMechUpdated += OnMechUpdated;
141+
_pinMame.OnSolenoidUpdated += OnSolenoidUpdated;
138142
_player = player;
139143

140144
try {
141-
//_pinMame.StartGame("fh_906h");
142145
_pinMame.StartGame(romId);
143146

144147
} catch (Exception e) {
@@ -149,8 +152,8 @@ public void OnInit(Player player, TableApi tableApi, BallManager ballManager)
149152
private void GameStarted()
150153
{
151154
Logger.Info($"[PinMAME] Game started.");
152-
_isRunning = true;
153-
155+
_isRunning = true;
156+
154157
SendInitialSwitches();
155158
}
156159

@@ -209,7 +212,7 @@ private void OnDisplayAvailable(int index, int displayCount, PinMameDisplayLayou
209212
}
210213
}
211214

212-
private void DisplayUpdated(int index, IntPtr framePtr, PinMameDisplayLayout displayLayout)
215+
private void OnDisplayUpdated(int index, IntPtr framePtr, PinMameDisplayLayout displayLayout)
213216
{
214217
if (displayLayout.IsDmd) {
215218
UpdateDmd(index, displayLayout, framePtr);
@@ -252,21 +255,6 @@ private void UpdateSegDisp(int index, PinMameDisplayLayout displayLayout, IntPtr
252255
}
253256
}
254257

255-
private void SolenoidUpdated(int internalId, bool isActive)
256-
{
257-
if (_coils.ContainsKey(internalId)) {
258-
Logger.Info($"[PinMAME] <= coil {_coils[internalId].Id} ({internalId}): {isActive} | {_coils[internalId].Description}");
259-
260-
lock (_dispatchQueue) {
261-
_dispatchQueue.Enqueue(() =>
262-
OnCoilChanged?.Invoke(this, new CoilEventArgs(_coils[internalId].Id, isActive)));
263-
}
264-
265-
} else {
266-
Logger.Warn($"[PinMAME] <= coil UNMAPPED {internalId}: {isActive}");
267-
}
268-
}
269-
270258
private int OnAudioAvailable(PinMameAudioInfo audioInfo)
271259
{
272260
Logger.Info("Game audio available: " + audioInfo);
@@ -387,6 +375,35 @@ private void OnAudioFilterRead(float[] data, int channels)
387375
}
388376
}
389377

378+
private void OnMechAvailable(int mechNo, PinMame.PinMameMechInfo mechInfo)
379+
{
380+
Logger.Info($"[PinMAME] <= mech available: mechNo={mechNo}, mechInfo={mechInfo}");
381+
}
382+
383+
private void OnMechUpdated(int mechNo, PinMame.PinMameMechInfo mechInfo)
384+
{
385+
Logger.Info($"[PinMAME] <= mech updated: mechNo={mechNo}, mechInfo={mechInfo}");
386+
}
387+
388+
private void OnSolenoidUpdated(int internalId, bool isActive)
389+
{
390+
if (_coils.ContainsKey(internalId))
391+
{
392+
Logger.Info($"[PinMAME] <= coil {_coils[internalId].Id} ({internalId}): {isActive} | {_coils[internalId].Description}");
393+
394+
lock (_dispatchQueue)
395+
{
396+
_dispatchQueue.Enqueue(() =>
397+
OnCoilChanged?.Invoke(this, new CoilEventArgs(_coils[internalId].Id, isActive)));
398+
}
399+
400+
}
401+
else
402+
{
403+
Logger.Warn($"[PinMAME] <= coil UNMAPPED {internalId}: {isActive}");
404+
}
405+
}
406+
390407
private void GameEnded()
391408
{
392409
Logger.Info($"[PinMAME] Game ended.");
@@ -439,12 +456,15 @@ public void StopGame()
439456
if (_pinMame != null) {
440457
_pinMame.StopGame();
441458
_pinMame.OnGameStarted -= GameStarted;
442-
_pinMame.OnGameEnded -= GameEnded;
443-
_pinMame.OnDisplayUpdated -= DisplayUpdated;
444-
_pinMame.OnSolenoidUpdated -= SolenoidUpdated;
459+
_pinMame.OnGameEnded -= GameEnded;
445460
_pinMame.OnDisplayAvailable -= OnDisplayAvailable;
461+
_pinMame.OnDisplayUpdated -= OnDisplayUpdated;
446462
_pinMame.OnAudioAvailable -= OnAudioAvailable;
447-
_pinMame.OnAudioUpdated -= OnAudioUpdated;
463+
_pinMame.OnAudioUpdated -= OnAudioUpdated;
464+
_pinMame.OnMechAvailable -= OnMechAvailable;
465+
_pinMame.OnMechUpdated -= OnMechUpdated;
466+
_pinMame.OnSolenoidUpdated -= OnSolenoidUpdated;
467+
448468
}
449469
_frameBuffer.Clear();
450470
_dmdLevels.Clear();
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
// Visual Pinball Engine
2+
// Copyright (C) 2021 freezy and VPE Team
3+
//
4+
// This program is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
//
9+
// This program is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU General Public License
15+
// along with this program. If not, see <https://www.gnu.org/licenses/>.
16+
17+
// ReSharper disable StringLiteralTypo
18+
19+
using System;
20+
using VisualPinball.Engine.Game.Engines;
21+
using VisualPinball.Engine.PinMAME.MPUs;
22+
23+
namespace VisualPinball.Engine.PinMAME.Games
24+
{
25+
[Serializable]
26+
public class Rock : System80
27+
{
28+
public override string Name => "Rock";
29+
public override string Id => "rock";
30+
public override int Year => 1985;
31+
public override string Manufacturer => "Premier";
32+
public override int IpdbId => 1978;
33+
34+
public override PinMameRom[] Roms { get; } = {
35+
new PinMameRom("rock"),
36+
new PinMameRom("rockfp", description: "Free Play"),
37+
new PinMameRom("rockg", language: PinMameRomLanguage.German),
38+
new PinMameRom("rockgfp", description: "Free Play", language: PinMameRomLanguage.German),
39+
};
40+
41+
protected override GamelogicEngineSwitch[] Switches { get; } = {
42+
new GamelogicEngineSwitch("40") { Description = "#1 Drop Target (Upper)" },
43+
new GamelogicEngineSwitch("41") { Description = "10 Point (2)" },
44+
new GamelogicEngineSwitch("42") { Description = "Right Flipper (Lower)" },
45+
new GamelogicEngineSwitch("43") { Description = "Rollunder" },
46+
new GamelogicEngineSwitch("44") { Description = "Right Outside Rollover" },
47+
new GamelogicEngineSwitch("45") { Description = "Right Spinner (with Bracket)" },
48+
new GamelogicEngineSwitch("46") { Description = "Right Top Rollover" },
49+
new GamelogicEngineSwitch("50") { Description = "#2 Drop Target (Upper)" },
50+
new GamelogicEngineSwitch("51") { Description = "#1 Drop Target (Lower)" },
51+
new GamelogicEngineSwitch("52") { Description = "Spot Target (with Bracket)" },
52+
new GamelogicEngineSwitch("53") { Description = "#1 Top Rollover" },
53+
new GamelogicEngineSwitch("54") { Description = "Right Return Rollover" },
54+
new GamelogicEngineSwitch("55") { Description = "Right Side Rollover" },
55+
new GamelogicEngineSwitch("57") { Description = "Tilt (with Bracket)" },
56+
new GamelogicEngineSwitch("60") { Description = "#3 Drop Targer (Upper)" },
57+
new GamelogicEngineSwitch("61") { Description = "#2 Drop Targer (Lower)" },
58+
new GamelogicEngineSwitch("62") { Description = "#4 Drop Targer (Lower)" },
59+
new GamelogicEngineSwitch("63") { Description = "#2 Top Rollover" },
60+
new GamelogicEngineSwitch("64") { Description = "Left Return Rollover" },
61+
new GamelogicEngineSwitch("65") { Description = "Left Side Rollover" },
62+
new GamelogicEngineSwitch("67") { Description = "Outhole (Assembly)", DeviceHint = "^Trough\\s*\\d?", DeviceItemHint = "drain_switch" },
63+
new GamelogicEngineSwitch("70") { Description = "#4 Drop Targer (Upper)" },
64+
new GamelogicEngineSwitch("71") { Description = "#3 Drop Targer (Lower)" },
65+
new GamelogicEngineSwitch("72") { Description = "#5 Drop Targer (Lower)" },
66+
new GamelogicEngineSwitch("73") { Description = "#3 Top Rollover" },
67+
new GamelogicEngineSwitch("74") { Description = "Left Outside Rollover" },
68+
new GamelogicEngineSwitch("75") { Description = "Left Spinner (with Bracket)" },
69+
new GamelogicEngineSwitch("76") { Description = "Left Top Rollover" },
70+
};
71+
72+
public override GamelogicEngineLamp[] AvailableLamps { get; } = {
73+
new GamelogicEngineLamp("03") { Description = "Shoot Again" },
74+
new GamelogicEngineLamp("05") { Description = "#1 Drop Target (Upper)" },
75+
new GamelogicEngineLamp("06") { Description = "#2 Drop Target (Upper)" },
76+
new GamelogicEngineLamp("07") { Description = "#3 Drop Target (Upper)" },
77+
new GamelogicEngineLamp("08") { Description = "#4 Drop Target (Upper)" },
78+
new GamelogicEngineLamp("09") { Description = "Level 1" },
79+
new GamelogicEngineLamp("10") { Description = "Level 2" },
80+
new GamelogicEngineLamp("11") { Description = "Level 3" },
81+
new GamelogicEngineLamp("14") { Description = "#1 Drop Target (Lower)" },
82+
new GamelogicEngineLamp("15") { Description = "#2 Drop Target (Lower)" },
83+
new GamelogicEngineLamp("16") { Description = "#3 Drop Target (Lower)" },
84+
new GamelogicEngineLamp("17") { Description = "#4 Drop Target (Lower)" },
85+
new GamelogicEngineLamp("18") { Description = "#5 Drop Target (Lower)" },
86+
new GamelogicEngineLamp("19") { Description = "Left Side Rollover" },
87+
new GamelogicEngineLamp("20") { Description = "Left Return Rollover" },
88+
new GamelogicEngineLamp("21") { Description = "Right Return Rollover" },
89+
new GamelogicEngineLamp("22") { Description = "Right Side Rollover" },
90+
new GamelogicEngineLamp("23") { Description = "#1 Top Rollover (\"A\")" },
91+
new GamelogicEngineLamp("24") { Description = "#2 Top Rollover (\"B\")" },
92+
new GamelogicEngineLamp("25") { Description = "#3 Top Rollover (\"C\")" },
93+
new GamelogicEngineLamp("26") { Description = "\"R\"" },
94+
new GamelogicEngineLamp("27") { Description = "\"O\"" },
95+
new GamelogicEngineLamp("28") { Description = "\"C\"" },
96+
new GamelogicEngineLamp("29") { Description = "\"K\"" },
97+
new GamelogicEngineLamp("30") { Description = "\"AND\"" },
98+
new GamelogicEngineLamp("31") { Description = "\"R\"" },
99+
new GamelogicEngineLamp("32") { Description = "\"O\"" },
100+
new GamelogicEngineLamp("33") { Description = "\"L\"" },
101+
new GamelogicEngineLamp("34") { Description = "\"L\"" },
102+
new GamelogicEngineLamp("35") { Description = "\"L\"" },
103+
new GamelogicEngineLamp("36") { Description = "\"I\"" },
104+
new GamelogicEngineLamp("37") { Description = "\"V\"" },
105+
new GamelogicEngineLamp("38") { Description = "\"E\"" },
106+
new GamelogicEngineLamp("39") { Description = "\"S\"" },
107+
new GamelogicEngineLamp("40") { Description = "\"!\"" },
108+
new GamelogicEngineLamp("41") { Description = "Double Scoring" },
109+
new GamelogicEngineLamp("42") { Description = "2X" },
110+
new GamelogicEngineLamp("43") { Description = "3X" },
111+
new GamelogicEngineLamp("44") { Description = "4X" },
112+
new GamelogicEngineLamp("45") { Description = "5X" },
113+
new GamelogicEngineLamp("46") { Description = "Spot Target" },
114+
new GamelogicEngineLamp("47") { Description = "Left Outside Rollover / Right Spinner" },
115+
new GamelogicEngineLamp("51") { Description = "Right Outisde Rollover / Left Spinner" },
116+
};
117+
118+
protected override GamelogicEngineCoil[] GameCoils { get; } = {
119+
new GamelogicEngineCoil("05", 5) { Description = "Five Pos. Bank Reset", DeviceHint = "^5PosBank\\s*" },
120+
new GamelogicEngineCoil("06", 6) { Description = "Four Pos. Bank Reset", DeviceHint = "^4PosBank\\s*" },
121+
new GamelogicEngineCoil("08", 8) { Description = "Knocker Assembly" },
122+
new GamelogicEngineCoil("09", 8) { Description = "Outhole", DeviceHint = "^Trough\\s*\\d?", DeviceItemHint = "eject_coil" },
123+
};
124+
}
125+
}

VisualPinball.Engine.PinMAME/Games/Terminator2.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ public class Terminator2 : Wpc
193193
new GamelogicEngineCoil("09") { Description = "Plunger", DeviceHint = "Plunger" },
194194
new GamelogicEngineCoil("10") { Description = "Top Lock" },
195195
new GamelogicEngineCoil("11") { Description = "Gun Motor" },
196-
new GamelogicEngineCoil("12") { Description = "Knock Down" },
196+
new GamelogicEngineCoil("12") { Description = "Knock Down", DeviceHint = "^sw77$" },
197197
new GamelogicEngineCoil("13") { Description = "Left Jet" },
198198
new GamelogicEngineCoil("14") { Description = "Right Jet" },
199199
new GamelogicEngineCoil("15") { Description = "Bottom Jet" },
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// Visual Pinball Engine
2+
// Copyright (C) 2021 freezy and VPE Team
3+
//
4+
// This program is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
//
9+
// This program is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU General Public License
15+
// along with this program. If not, see <https://www.gnu.org/licenses/>.
16+
17+
using System.Linq;
18+
using VisualPinball.Engine.Common;
19+
using VisualPinball.Engine.Game.Engines;
20+
21+
namespace VisualPinball.Engine.PinMAME.MPUs
22+
{
23+
public abstract class System80 : PinMameGame
24+
{
25+
protected override GamelogicEngineCoil[] Coils => GameCoils.Concat(_coils).ToArray();
26+
protected abstract GamelogicEngineCoil[] GameCoils { get; }
27+
28+
public override GamelogicEngineSwitch[] AvailableSwitches => Switches.Concat(_switches).ToArray();
29+
30+
protected abstract GamelogicEngineSwitch[] Switches { get; }
31+
32+
private readonly GamelogicEngineSwitch[] _switches = {
33+
new GamelogicEngineSwitch(SwSelfTest, 7) {Description = "Self Test", InputActionHint = InputConstants.ActionCoinDoorAdvance },
34+
new GamelogicEngineSwitch(SwStartButton, 47) {Description = "Start Button", InputActionHint = InputConstants.ActionStartGame, InputMapHint = InputConstants.MapCabinetSwitches },
35+
new GamelogicEngineSwitch(SwTilt, 57) {Description = "Tilt" },
36+
new GamelogicEngineSwitch(SwSlamTilt, -1) {Description = "Slam Tilt", InputActionHint = InputConstants.ActionSlamTilt, InputMapHint = InputConstants.MapCabinetSwitches },
37+
new GamelogicEngineSwitch(SwCoin1, 17) {Description = "Coin Button 1", InputActionHint = InputConstants.ActionInsertCoin1, InputMapHint = InputConstants.MapCabinetSwitches },
38+
new GamelogicEngineSwitch(SwCoin2, 27) {Description = "Coin Button 2", InputActionHint = InputConstants.ActionInsertCoin2, InputMapHint = InputConstants.MapCabinetSwitches },
39+
new GamelogicEngineSwitch(SwCoin3, 37) {Description = "Coin Button 3", InputActionHint = InputConstants.ActionInsertCoin3, InputMapHint = InputConstants.MapCabinetSwitches },
40+
new GamelogicEngineSwitch(SwFlipperLowerRight, 112) {Description = "Lower Right Flipper", InputActionHint = InputConstants.ActionRightFlipper, InputMapHint = InputConstants.MapCabinetSwitches },
41+
new GamelogicEngineSwitch(SwFlipperLowerLeft, 114) {Description = "Lower Left Flipper", InputActionHint = InputConstants.ActionLeftFlipper, InputMapHint = InputConstants.MapCabinetSwitches },
42+
};
43+
44+
private readonly GamelogicEngineCoil[] _coils = {
45+
new GamelogicEngineCoil(CoilGameOn, 10) { Description = "ROM Started" }
46+
};
47+
}
48+
}

VisualPinball.Engine.PinMAME/VisualPinball.Engine.PinMAME.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
</PropertyGroup>
1717

1818
<ItemGroup>
19-
<PackageReference Include="PinMame" Version="0.1.0-preview.42" />
20-
<PackageReference Include="PinMame.Native" Version="3.4.0-preview.299" />
21-
<PackageReference Include="VisualPinball.Engine" Version="0.0.1-preview.67" />
19+
<PackageReference Include="PinMame" Version="0.1.0-preview.43" />
20+
<PackageReference Include="PinMame.Native" Version="3.4.0-preview.303" />
21+
<PackageReference Include="VisualPinball.Engine" Version="0.0.1-preview.68" />
2222
</ItemGroup>
2323

2424
<Target Name="PluginsDeploy" AfterTargets="Build">

0 commit comments

Comments
 (0)