As mentioned in http://www.vpforums....showtopic=34959 it will be possible with the next VP and VPM builds/scripts to fetch data from the NVRAM of the machine, here already some sample code:
Const UseVPMNVRAM = true
at the beginning of the table to enable a dynamic callback (NVRAMCallback). Then to display some NVRAM stuff, for example the number of left flipper buttons pressed (for dm_h6):
Sub OutputLeftFlipper(VPMNVRAM)
Dim I,S
For I = 0 To UBound(VPMNVRAM) 'go over all changed NVRAM locations
If(VPMNVRAM(I,0) = CInt("&h19FF")) Then 'position of left flipper counter, but actually its a 3byte integer at 19FD, 19FE and 19FF
S = "LeftFlipper: " & VPMNVRAM(I,0) & " : " & VPMNVRAM(I,1) & " (" & VPMNVRAM(I,2) & ")" & Chr(13) 'three dimensional array: location, new value, old value
TextBox1.text = S 'output to textbox
End If
Next
End Sub
Set NVRAMCallback = GetRef("OutputLeftFlipper") 'attach above sub routine to the NVRAM callback
(all the NVRAM locations in here are from https://github.com/t.../dm_h6.nv.json)
or some static stuff (-can- be more costly to fetch, so called in table init for example), again for dm_h6, getting the Grand Champion initials and score:
Function ConvertBCD(v) 'converts an 8bit number in BCD format to string (for example 12 in hexadecimal format to "12")
ConvertBCD = "" & ((v AND &hF0) / 16) & (v AND &hF)
End Function
Sub OutputGC
Dim NVRAM
NVRAM = Controller.NVRAM 'read full NVRAM from VPM as array
TextBox2.text = "GC: " & Chr(NVRAM(CInt("&h1CAF"))) & Chr(NVRAM(CInt("&h1CB0"))) & Chr(NVRAM(CInt("&h1CB1"))) & " " & ConvertBCD(NVRAM(CInt("&h1CB2"))) & ConvertBCD(NVRAM(CInt("&h1CB3"))) & ConvertBCD(NVRAM(CInt("&h1CB4"))) & ConvertBCD(NVRAM(CInt("&h1CB5"))) & ConvertBCD(NVRAM(CInt("&h1CB6"))) & ConvertBCD(NVRAM(CInt("&h1CB7")))
End Sub
Edited by toxie, 06 June 2016 - 08:20 AM.