# High Scores

PinballY automatically displays the "live" high score information for the currently selected game. The high scores are displayed in the video DMD window and on the real DMD device, if you have one.

Scores are displayed in rotation with the game's regular background media for the DMD window or device. If you've supplied a static image for the DMD, the image will be displayed for about 7 seconds at a time, and then the high scores will be displayed, then the image will be displayed again, etc. If the game has a DMD video, the video will be displayed all the way through, then the scores will be displayed, then the video will play again, and so on.

## How PinballY reads high scores, part I: PINemHI

For most games, PinballY uses a separate program called PINemHi, written by vpforums member DnaDisturber. (PINemHi is included in the PinballY distribution with the author's permission, so there's no need to install it separately.)

PINemHi reads special files known as NVRAM (for Non-Volatile RAM) files. These are created by Visual Pinball (more technically, by VPinMAME) and by Future Pinball when you play games through those systems, and they store information that the simulated pinball machines would have stored in real life in their on-board memory chips. The stored information includes things like operator settings (for example, whether or not the game is in Free Play mode, how many balls per game it's configured to use, and so on) and audit counts (how many times the game has been played, how many coins it's collected), as well as the latest high scores. PINemHi is programmed to parse the NVRAM files for almost all of the VPinMAME and Future Pinball games in existence to pick out the high score information and format it for display.

PINemHi works with almost all games that use VPinMAME to play back original ROMs, and with almost all Future Pinball games. PINemHi doesn't work with Visual Pinball games that don't use ROMs, such as original VP creations, and VP re-creations of games from the electromechanical (EM) era. PINemHi also doesn't work for games based on other player systems, such as commercial games.

## How PinballY reads high scores, part II: ad hoc score files

For games that PINemHi doesn't work with, PinballY provides its own supplemental way to provide the high scores, using ad hoc score files. This requires specific code to be added to each table to write the ad hoc file, so it will only work with tables that have been specifically programmed to support it.

Here's how this works:

- PinballY always starts by trying PINemHi. If that works, the PINemHi results are used, skipping the rest of the steps below.
- If PINemHi can't retrieve high scores for the game, PinballY looks for a file that has the exact same name and location as the table file for the game (for example, the .vpx file for a Visual Pinball X game), but with the filename extension replaced with .pinballyHighScores. For example, if the table file is `c:\VisualPinball\Tables\Fireball_v2_7.vpx`, PinballY will look for the scores in a file called `c:\VisualPinball\Tables\Fireball_v2_7.pinballyHighScores`.
- If the high scores file exists, PinballY reads it into memory as a plain ASCII text file. Each line in the file corresponds to one line on the DMD high score display. Blank lines separate groups of messages that are shown together on one screen.

## Display styles

For the video DMD window, PinballY offers three display styles for generated high score graphics, to cover the three main display styles used in real pinball machines over the decades:

- DMD style. This simulates the 128x32 dot matrix display used in most machines from the 1990s onwards. By default, the dots are displayed in an amber color simulating the original plasma displays in the 1990s machines. For games with VPinMAME ROMs, however, any color customizations you've made in the VPinMAME settings will be respected and used instead. This should make the generated high-score screens harmonize with captured DMD video.
- Alphanumeric style. This simulates the 16-segment plasma LED displays used in most games from the late 1980s.
- Typewriter style. This simulates a paper note card printed with the high score information. This is meant to provide something appropriate to the era for electromechanical tables, which didn't (usually) have any way to record the high scores themselves. The closest equivalent of a high score display for those old machines was for someone to stick a paper note to the machine commemorating champion scores. This format is designed to simulate that approach.

By default, the program picks the display style for each game automatically based on the table's metadata, as stored in the XML table database. (You can edit this information via the Game Details dialog.)

- Any table with a release year before 1978 uses the Typewriter style, since virtually all known games up to that point were EM tables
- A machine with a release year from 1978 to 1990 uses the Alphanumeric style, since almost all of the real machines produced during these years used either 7-segment numeric displays or 16-segment alphanumeric displays
- Any machine with a release year of 1990 or earlier that's set to table type "SS" (solid state) in its metadata uses the Alphanumeric style
- A table whose release year is 1991 and whose title is "Funhouse", "Harley-Davidson", or "The Machine: Bride of Pinbot" uses the Alphanumeric style. We have to treat these three machines as special cases, because 1991 was a transition year that included both Alphanumeric and DMD-based machines, so we can't tell which it is based on the year alone. The IPDB table type doesn't help either, since both Alphanumeric and DMD games are considered "Solid State". (In contrast, the transitional years in the late 1970s between mechanical score-reel games and digital displays are distinguishable by the IPDB table types "EM" and "SS", so those years don't need any special title-by-title cases - which is nice, because that transition covered several years.) Fortunately, these three titles are the only Alphanumeric games released in 1991 (as far as I know), so we don't need a gigantic list of special cases to settle the question, just this short list.
- Anything else uses the DMD style

You can override the default style on a game-by-game basis in the Edit Game Details dialog. That lets you fix any games that the rules above classify in the wrong category, or any that you just want to change for other reasons.

The display styles only apply to a video DMD window - that is, a regular video monitor that's showing a simulated DMD image in a window. If you're using a real DMD device (a physical DMD, such as a PinDMD or a Pin2DMD), PinballY just uses a plain "dots" font for high score displays, since the dot resolution on those devices is too low to simulate the other styles effectively.

## Customizing the "Typewriter" display style

The Typewriter style normally uses an image of an index card as the background, with black text in the Courier New font to display the score information. You can customize both of these aspects of the display:

- See "TT" High Score Backgrounds to find out how to change the background image
- The font and text color can be customized using the Fonts & Colors section in the Settings dialog

## Editing captured DMD video

If you're creating your own DMD video for a game based on captured video from the game's "live" DMD, you can get the best effect in PinballY by editing the captured video to clip out the portion that shows the high scores.

Most electronic games from the late 1980s onward display a series of "attract mode" messages between games, and these usually include the high scores. So if you capture video from the DMD during the game's attract mode, it will probably include the high scores. Those high scores will be the ones that were current at the time you captured the video, though! If you leave them in the video, the video playback will forever show those same scores, even if you beat them on later games. That's why it's best to edit them out.

Since PinballY automatically generates graphics with the latest high scores from the NVRAM files, and interleaves them with the captured DMD video, you can create an almost seamless effect showing the live scores. The trick is to edit the captured video so that it starts just after the high scores are displayed in the video, and ends just before the high scores are displayed again on the next cycle. That way, PinballY will insert the live high score screens at just the right point in the video, simulating the original rotation, but always up to date with the latest high scores saved on disk.

## Customizing high scores through Javascript

The Javascript system includes an event class, HighScoresEvent, that lets you intercept PinballY's communications with PINemHi to supplement or replace the high scores that PINemHi provides. This could be used to change the format of the high scores for certain games, for example, or to provide your own external source of high scores for games that PINemHi doesn't work with. See the event class documentation for more details.

Javascript can also access the high score information that the system has retrieved for a game, via gameInfo.getHighScores(). For example, you could use that to create custom graphics that incorporate a list of high scores.