The following is a patch that I thought as a workaround for the missing ball issue for the Taito's Shark table.
At any game session beginning this patch makes a backup of the NVram file or replace it with the
previous game session backup file.
For doing that, the backup file is deleted at the exit of the game session but only if the game-over lamp is active.
This way, every time the simulator is exited while a game is still running, on the next session the NVram file is substituted with the previous NVram backup executed after a correct game-over exited session.
In case the NVram and/or the NVram backup file became corrupt anyway and the missing ball issue returns, an emergency procedure to delete those files without the keyboard is provided too.
In that case, you just have to press the Start button and holding it pressed you must put two coins into the first coin slit. This resets the Hi-scores and the credits counter of-course, but you don't need to install the keyboard in your cabinet. Note that after this emergency procedure the session is ended and VPX returns the control to its caller, you must re-enter the session after that.
This patch also fixes the NVram clearing that zeroes the hi-score and the credits counter in case the table was exited after a game-over but before the match procedure had ended.
This last bug happened only when the table was called outside the Pinball-X front-end.
Using Pinball-X instead and exiting before the match procedure had ended, the pinball still lose the last session hi-score and the last session credits counter value (in this case the VpinMAME controller just has no time to write the new NVram file), this issue can't be fixed because Pinball-X forces the VPX to exit anyway after a certain time.
Here are the 4 parts of code to add to the table script:
################################################################################################################################################
1) Put this code somewhere at the beginning of the table script
################################################################################################################################################
' =============================================================================================================
' Subs and Functions for NVram patch
' =============================================================================================================
Const GameOverLampID = 149 ' set this constant to the ID number of the game over lamp defined in the B2S file
Dim NVramPatchCoinCnt
Function GetNVramPath()
Dim WshShell
Set WshShell = CreateObject("WScript.Shell")
GetNVramPath = WshShell.RegRead ("HKCU\Software\Freeware\Visual PinMame\globals\nvram_directory")
End function
Function FileExists(FileName)
DIM FSO
FileExists = False
On Error Resume Next
Set FSO = CreateObject("Scripting.FileSystemObject")
FileExists =FSO.FileExists(FileName)
On Error Goto 0
Set FSO = Nothing
End Function
Sub Kill(FileName)
Dim ObjFile,FSO
On Error Resume Next
Set FSO = CreateObject("Scripting.FileSystemObject")
Set ObjFile = FSO.GetFile (FileName)
ObjFile.Delete
On Error Goto 0
Set FSO = Nothing
End Sub
Sub Copy(SourceFileName,DestFileName)
Dim FSO
On Error Resume Next
Set FSO = CreateObject("Scripting.FileSystemObject")
FSO.CopyFile SourceFileName,DestFileName,True
On Error Goto 0
Set FSO = Nothing
End Sub
Sub NVramPatchLoad
NVramPatchCoinCnt = 0
If FileExists(GetNVramPath + "\" + cGameName + ".nvb") Then
Copy GetNVramPath + "\" + cGameName + ".nvb",GetNVramPath + "\" + cGameName + ".nv"
Else
Copy GetNVramPath + "\" + cGameName + ".nv",GetNVramPath + "\" + cGameName + ".nvb"
End If
End Sub
Sub NVramPatchExit
If LampState(GameOverLampID) Then
Kill GetNVramPath + "\" + cGameName + ".nvb"
Do
LampTimer_Timer ' This loop is need to avoid the NVram reset (losing the hi-score and credits)
Loop Until l20.State = 1 ' when the game is over but the match procedure isn't still ended
' (l20 in this table is just the first lamp that light on after the match procedure has ended)
End If
End Sub
' NOTE:
' The following sub must exist otherwise it must be added with The LampTimer placed somewhere on the table
' Lamptimer.TimerInterval must be set not greater than 40ms
'Sub LampTimer_Timer()
' Dim chgLamp, num, chg, ii
' chgLamp = Controller.ChangedLamps
' If Not IsEmpty(chgLamp) Then
' For ii = 0 To UBound(chgLamp)
' LampState(chgLamp(ii, 0) ) = chgLamp(ii, 1) 'keep the real state in an array
' FadingLevel(chgLamp(ii, 0) ) = chgLamp(ii, 1) + 4 'actual fading step
' Next
' End If
' " " " " " " " " " "
' " " " " " " " " " "
' " " " " " " " " " "
'End Sub
' =============================================================================================================
' =============================================================================================================
################################################################################################################################################
2) Put this statement into the table initialization subroutine (named table1_init), place it at the very first line of the routine
################################################################################################################################################
' =============================================================================================================
' =============================================================================================================
NVramPatchLoad ' Must be placed before te VPinMAME controller initialization
' =============================================================================================================
' =============================================================================================================
################################################################################################################################################
3) Put this statement into the table exit subroutine (named table1_exit) just before the Controller.Stop statement
################################################################################################################################################
' =============================================================================================================
' =============================================================================================================
NVramPatchExit ' Must be placed before the Controler.Stop statement into the Table_Exit Sub
' =============================================================================================================
' =============================================================================================================
################################################################################################################################################
4) Put this code into the LampTimer_Timer subroutine or any other subroutine called at least every 50ms
################################################################################################################################################
' =============================================================================================================
' NVram patch to completely erase the NVram files keeping the Start Game button pushed while inserting
' two coins into the first coin slit (this resets the high scores too)
' =============================================================================================================
If Controller.Switch(swStartButton) then
If Controller.Switch(swCoin1) then
If NVramPatchCoinCnt = 2 Then
Controller.Stop
Kill GetNVramPath + "\" + cGameName + ".nv"
Kill GetNVramPath + "\" + cGameName + ".nvb"
QuitPlayer 2
Else
NVramPatchCoinCnt = 1
End If
Else
If NVramPatchCoinCnt = 1 Then
NVramPatchCoinCnt = 2
End If
End If
Else
NVramPatchCoinCnt = 0
End If
' =============================================================================================================
' =============================================================================================================
This patch should be work on any other Taito's table with similar issues, but I still haven't check it.
To use this patch for other tables you must discover the game-over lamp ID and put it into the GameOverLampID constant definition line (I used B2S Backglass designer V1.2 with the Shark (Taito 1982).directb2s file to discover the ID).
I'm a newbie in this, I just started my home-brewed cabinet last July and finished last week to tune-up its table collection, so maybe the code is not written the best way (it's the first time I use VBscript).
BTW, if someone knows a best way to know when the game is over I'll be glad to know.
Have a great day.
Massimo
Edited by Pmax65, 12 February 2019 - 08:37 AM.



Top














are all trademarks of VPFORUMS.