jsm174 / vpx-standalone-scripts

Table patches for VPX Standalone
https://github.com/vpinball/vpinball/tree/standalone/
28 stars 14 forks source link

Getting nvram directory #89

Closed francisdb closed 5 months ago

francisdb commented 1 year ago

Looks like a few tables do this:

    Set WshShell = CreateObject("WScript.Shell")
    GetNVramPath = WshShell.RegRead("HKCU\Software\Freeware\Visual PinMame\globals\nvram_directory")

Is there no other way to get that directory or could this be implemented?

ABBAv2.0/ABBAv2.0.vbs.patch

https://github.com/jsm174/vpx-standalone-scripts/blob/7605c75d6403bcbaa112fd644ddaf5db32c94a74/Vortex%20(Taito%20do%20Brasil%20-%201981)%20v4/Vortex%20(Taito%20do%20Brasil%20-%201981)%20v4.vbs.patch

https://github.com/jsm174/vpx-standalone-scripts/blob/7605c75d6403bcbaa112fd644ddaf5db32c94a74/Last%20Starfighter%2C%20The%20(Taito%2C%201983)%20hybrid%20v1.04/Last%20Starfighter%2C%20The%20(Taito%2C%201983)%20hybrid%20v1.04.vbs.patch

And Topaz

francisdb commented 10 months ago

These nvram patches are required to reset the table when quit. If not a game stopped in the middle of a it will resume on next start.

francisdb commented 9 months ago

there seems to be a standard script for Taito: NVram patch for Taito do Brasil tables by Pmax65

Space Shuttle (Taito do Brasil - 1982) 4.0.0 used by https://www.vpforums.org/index.php?app=downloads&showfile=13644

https://www.vpforums.org/index.php?app=downloads&showfile=13430 https://www.vpforums.org/index.php?app=downloads&showfile=13422

francisdb commented 9 months ago

Might add a patch to vpxtool that resolves this to [table]/pinmame/nvram or ~/.pinmame/nvram if the former is missing.

francisdb commented 8 months ago

Zarza (Taito do Brasil - 1982) https://www.vpforums.org/index.php?app=downloads&showfile=13488

francisdb commented 7 months ago

https://www.vpforums.org/index.php?app=downloads&showfile=13284 Snake Machine (Taito do Brasil - 1981)

rh6423 commented 6 months ago

Titan (Taito do Brasil - 1981) was this issue. My workaround was to disable the whole Nvram patch in the script. Haven't encountered any issues as yet. Removing the WshShell line and setting GetNVramPath = '~/pinmame/nvram' worked as well. Not as clean, but if the script actually needs help finding the nvram directory it works.

This is from vbscript.md in the standalone source:

Issue: WScript.Shell does not work

' does not work
Dim WshShell : Set WshShell = CreateObject("WScript.Shell")
GetNVramPath = WshShell.RegRead("HKEY_CURRENT_USER\Software\Freeware\Visual PinMame\globals\nvram_directory")

' no workaround as we standalone will not support wscript.shell

You could change this logic to either source the pinmame path (VPX has to know this to find the ROMs, right?) and append /nvram, or access nvram path directly if it's stored somewhere (like one of the ini files).

PlatformOS(string) could be used to define some logic in the script to make it work for Windows (if nvram patch is still needed there).

rh6423 commented 6 months ago

It occurred to me that I rarely exit mid-game. Tested it, and it is an issue with the nvram patch disabled. Game continues with remaining balls when you start it back up rather than starting a new game. vpmPath is being set in libpinmame.h, so it's probably accessible somehow. No mention of vpmPath in CommandReference.txt, not sure where else to look yet...

francisdb commented 6 months ago

Would be nice if there was some kind of nvram api available for scripts without having to mess with the filesystem.

rh6423 commented 6 months ago

My research led me to this forum post. Taito do Brasil tables were designed to withstand power outages without interrupting the game in play. So disabling the whole nvram patch component of the .vbs is a more accurate simulation of the real thing. Since this approach also makes the tables playable on 10.8 standalone, I think it's the right solution.

Accessing the nvram path from inside a .vbs script is still an interesting question, but perhaps less urgent. I'll put in a few pull reqs for other Taito do Brasil tables this weekend. I know they're mostly clones, but Brazilian Taito machines rock! I want to live in a world where we can play them on a Mac or Linux machine just as easily as the Windows people do,

francisdb commented 6 months ago

Found a table that does this:

    Dim NVRAM : NVRAM = Controller.NVRAM
    dim str : str = _
    ConvertBCD(NVRAM(CInt("&h200"))) & _
    ConvertBCD(NVRAM(CInt("&h201"))) & _
    ConvertBCD(NVRAM(CInt("&h202"))) & _
    ConvertBCD(NVRAM(CInt("&h203")))        'sys 11 current score
    str = round(str)

Unfortunately this does not work on standalone see https://github.com/vpinball/vpinball/issues/1579

I wonder if there is an api to write to nvram and reset Taito tables

francisdb commented 5 months ago

Moved to vpinball https://github.com/vpinball/vpinball/issues/1595