Register    Login    Forum    FAQ    PinSimDB.org

Board index » Future Pinball » BAM corner




Post new topic Reply to topic  [ 16 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: How to use Score / High Score with 15 digits and BAM.
 Post Posted: Sun Sep 10, 2017 2:49 pm 
Offline

Joined: Mon Mar 25, 2013 4:02 pm
Posts: 820
If you don't have problem with score too high (overflow error in script) and table works fine with results limited to 9 digits (exactly 2 147 483 647 max), when don't do anything.

With new BAM version (v1.4-183) max score may be: 922 337 203 685 477, but you will need to change few things in script. Sometimes it will be easy, sometimes not.

How to enable support for 15 digit score.
Support for big score is not enabled by default. To enable it you need to add one line in script:
Code:
' xBAM.FixScore

Please note comment char (apostrophe) at line begin. This line will not be executed, but it is enought to let BAM know, that we want to enable support for big scores.

How it works and what are limitations.
Here is list of nvRAM registers with support for biger than 32 bit numbers:
nvScore1, ... , nvScore4, nvScore(i),
nvHighScore1, ... , nvHighScore4, nvHighScore(i),
nvSpecialScore1, ... , nvSpecialScore4, nvSpecialScore(i),
nvSpecialHighScore.

All that registers are now CURRENCY type.
See: https://msdn.microsoft.com/en-us/vba/la ... -data-type

So, max value is 922 337 203 685 477.

Because this data type need more "bits" to store vaule than normal 32-bit integer, when BAM will use nvS14, nvS15, nvS16 to store only few vaules between FP table reload/restart.
Stored are: nvHighScore(i), where i = <1, ..., 10> and nvSpecialScore1.
(Why nvSpecialScore1? because "Bride of Pinbot" use it).
All other values are stored as maximum int (2 147 483 647) between FP table restart.

Please remember. Do not use nvS14, nvS15, nvS16 if you want to use big score numbers.

.... and that is only beginning. Some scripts need special modification to work correctly.
Here is list of error/problems and solutions.

1. Overflow error with modulo operator.
In script you can find line like this:
LastDigit = nvScore(i) mod 10
Problem is in modulo division in vbscipt. It converts first arg (nvScore(i)) to 32-bit integer and if you have bigger value store in it you will get overflow error.
See: https://www.promotic.eu/en/pmdoc/Script ... at/Mod.htm

Solution:
We need to use own "smarter" modulo function (add it to script):
Code:
Function Modulo(ByVal a, ByVal b)
    a = Fix(CDbl(a))
    b = Fix(CDbl(b))
    Modulo = a - Fix(a/b) * b
End Function

... and replace line from example above to:
LastDigit = Modulo(nvScore(i),10)

2. Overflow error with integer division operator.
In script you can find line like this:
thousands = nvScore(i) \ 1000
Problem is in integer division operator (\). It converts first arg (nvScore(i)) to 32-bit integer and if you have bigger value store in it you will get overflow error.
See: https://www.promotic.eu/en/pmdoc/Script ... vision.htm

Solution:
Replace division with something like this:
thousands = Fix(CDbl(( nvScore(i) / 1000))

3. Overflow error when you assign score to hud display / gas discharge segment displays / DMD displays.
In script lines like this:
SigDisp1.SetValue(nvScore1)
SigDisp1.Value = nvScore1

Source of problem is in function SetValue or type of Value variable for that objects.
In both case it is limited to 32-bit integer.

Solution:
If object (like gas discharge segment display) can display text, when .... display text. Like this:
SigDisp1.Text = nvScore1

If object can't display text, when use Modulo function (defined above).
SigDisp1.Value = Modulo(nvScore1, 1000000000)
In this example you will get last 9 digist of result diplayed.
If you need more digits (all 15?) when you will need 2 SigDisp and code like this:
SigDisp1Low.Value = Modulo( nvScore1, 1000000000)
SigDisp1Hi.Value = Fix(CDbl(( nvScore1 / 1000000000))

_________________
http://www.ravarcade.pl
Better Arcade Mode
current BAM version: v1.4-185, released: Sep 17, 2017


Top 
 Profile  
 
 Post subject: Re: How to use Score / High Score with 15 digits and BAM.
 Post Posted: Sun Sep 10, 2017 4:53 pm 
Offline

Joined: Mon Jan 27, 2014 12:36 pm
Posts: 1677
Location: Ontario, Canada
Absolutely brilliant work again Rav!!


Top 
 Profile  
 
 Post subject: Re: How to use Score / High Score with 15 digits and BAM.
 Post Posted: Sun Sep 10, 2017 5:02 pm 
Offline

Joined: Thu Aug 16, 2012 11:12 pm
Posts: 1146
Location: Arkansas, USA
Guys,

This is a great enhancement for FP. At least some of you have experienced problems with high scores causing an error. It's pretty disappointing when are playing your best game ever and then have it produce an error. The limit occurs when the score reaches about 2 billion. Rav's enhancement increases it to 922 trillion! Although 2 billion points may seem like a lot, it doesn't take all that long on quite a few solid state tables where you can be awarded several million points at one time.

Don't let Rav's requirements for making changes scare you off. I am a novice at scripting but I can fix many tables because no changes are required other than adding Rav's FixScore code. This is a list of tables I have tested and verified that the only change you need to make is adding this code below the line near the top of the script below the line that says that says "Option Explicit". You should be aware that the display may not be able to show the full score because there is not enough space for all the digits, but the fix will still work and it will add the full score to the high score list even if the in-game display doesn't show all of it.

Code:
' xBAM.FixScore


There is an easy line of code you can add to test it. Just add the following line of code below the line that says "Sub FuturePinball_KeyPressed(ByVal KeyCode)". After you add it, you just type the letter V to add 900 trillion points to the score. In fact, you can test tables not on the list this way and see what happens or you can do searches for the script that Rav talks about in the previous posting.

Code:
If keycode = 47 then ' V key
      AddScore(900000000000001)
End if


This is the list of tables that I have found so far that do not require any change to the script other than adding Rav's fix score code. Two of them have ways of limiting high scores that I explain how to fix:

24 CE (Original Playfield) 1.01 x64 Zed Physics 1.0
AC DC 1.21 Zed Physics 1.11
Addams Family ULTIMATE 1.10
Aliens Legacy ULTIMATE 1.12
Apollo 13 1.0a
Astrohits, Tribute to the 80's RC2
* Attack From Mars ULTIMATE 1.02
Avatar ULTIMATE 1.01
Back to the Future (DE) ULTIMATE 1.04
Battle of Britain 1.0
Big Bang Bar 2015 2.0 HQ
Big Guns ULTIMATE 1.01 Physics 2.6
Blue Vs Pink v 1.0
Classic Panic 1.0
Dead Hunters ULTRA 1.01
Elvis 1.1 Night Zed Physics 1.0
Genie 1.0 Night Mod
Iron Man ULTIMATE 1.06
Junkyard Cats 1.0 Zed Physics 1.1
Knight Rider 2.0 Zed Physics 1.0
Lord of the Rings ULTIMATE 1.06
Masters of the Universe MASTERED Edition
Medieval Madness ULTIMATE 1.02
Pirates Of The Caribbean 1.0 Zed Physics 1.0
Robocop ULTIMATE 1.05
Scared Stiff 1.1a Normal Ledwiz HD Zed Physics 1.0
Shadow, The 1.0 Zed Physics 1.1
Spider-Man ULTRA 1.09 Physics 2.5
Three Angels ULTIMATE 1.02 Physics 2.6
TutenKham, Tribute to the 80's 1.0
** World Cup Soccer 1.31

* Attack From Mars has a line of code that divides the score by 100 to prevent the high score overflow. You will want to change this as I describe below because you won't need it anymore.

Change this line of code:
Code:
nvScore(CurrentPlayer) = nvScore(CurrentPlayer) + (points/100)

to this:
Code:
nvScore(CurrentPlayer) = nvScore(CurrentPlayer) + (points)


** World Cup Soccer has some script that limits all scores to 1,499,999,990 points in order to prevent high score overflow. You won't need this anymore so you should find the following script and delete it or add an apostrophe to the beginning of each of the three lines.

Code:
      if (nvScore(CurrentPlayer)>1500000000) then
         nvScore(CurrentPlayer)=1499999990
      end if


As part of the testing phase, Rav sent me some tables that he fixed. I will post the script of them so you can see how to change the ones that need changing a little better.

George


Top 
 Profile  
 
 Post subject: Re: How to use Score / High Score with 15 digits and BAM.
 Post Posted: Tue Sep 12, 2017 6:11 pm 
Offline

Joined: Thu Aug 16, 2012 11:12 pm
Posts: 1146
Location: Arkansas, USA
This is the first of the examples of Rav's fixes to some of the tables he sent me. This first one is an example of "1. Overflow error with modulo operator." You can search the script for "High Score Fix" and you will see the changes that were made.

Bride of Pinbot ULTIMATE 1.02

Add this section of script below the constants:

Code:
' Beginning of section added for High Score Fix
Function Modulo(ByVal a, ByVal b)
    a = Fix(CDbl(a))
    b = Fix(CDbl(b))
    Modulo = a - Fix(a/b) * b
End Function
' End of section added for High Score Fix


Replace this section of script:

Code:
   'Since using FormatNumber() to turn numbers into formatted strings doesn't work
   'right for all region settings, we need a custom function for formatting numbers.
   Public Function NumberToString(inputNumber)
      Dim number
      Dim digitCounter
      Dim digit
      If (constLeadingZero) and (inputNumber<10) then
         NumberToString="0" & inputNumber
'         objDebugText.DebugLine "NumberToString leadingzero = " & NumberToString, 57, priMed
      Elseif (FormatChar="") or (inputNumber<1000) then
         NumberToString=FormatNumber(inputNumber,0,-1,0,0)
      Else
         If (ExtraLargeValues=true) then
            'The last digit is discarded and taken to be a zero, in order to extend
            'the size of numbers this method can handle. The mod operation of integers
            'can't handle numbers above 2.x billions, so this extends the range up to
            '20-something billions.
            ' number=int(inputNumber/10) ' Old line of script
            number=Fix(CDbl(inputNumber)/10)        ' <- High Score Fix, now number is double type (but this part of code will probably not used
            NumberToString="0"
            digitCounter=0
         Else
            'number=inputNumber ' Old line of script
            number=Fix(CDbl(inputNumber))           ' <- High Score Fix, now number is double type (64 bit float point)
            NumberToString=""
            digitCounter=-1
         End if
         Do
            ' digit=number mod 10  ' Old line of script
            digit=Modulo(number, 10)                ' <- High Score Fix, we use my own Modulo subroutine see top of script
            digitCounter=digitCounter+1
            ' number=int(number/10)  ' Old line of script
            number=Fix(CDbl(number/10))             ' <- High Score Fix, we div by 10 and use Fix function to convert number to integer value (but still 64 bit float = double type)
            If (digitCounter=3) then
               NumberToString=digit & FormatChar & NumberToString
               digitCounter=0
            Else
               NumberToString=digit & NumberToString
            End if
         Loop While (number>0)
      End if
   End Function


Top 
 Profile  
 
 Post subject: Re: How to use Score / High Score with 15 digits and BAM.
 Post Posted: Thu Sep 14, 2017 3:15 pm 
Offline

Joined: Thu Aug 16, 2012 11:12 pm
Posts: 1146
Location: Arkansas, USA
The script below is taken from "Bubble Bobble 1.0". It is an example of "3. Overflow error when you assign score to hud display / gas discharge segment displays / DMD displays" in Rav's first posting. It is not too difficult to fix.

When you find script like this:
Player1seg.AddValue(points)

it needs to be changed like this:
Player1seg.Text = nvScore(CurrentPlayer)

Likewise script like this:
DispSegPlayer1.SetValue(nvScore1)

needs to be changed like this:
DispSegPlayer1.Text = nvScore1

Code:
      ' add the points to the correct display and light the current players display
      Select Case (CurrentPlayer)
'         Case 1:   Player1seg.AddValue(points) ' Old line of script
'         HudSeg1.addvalue(points) ' Old line of script
         Case 1:   Player1seg.Text = nvScore(CurrentPlayer) :HudSeg1.Text = nvScore(CurrentPlayer) ' <- High Score Fix
      End Select
   End if


Top 
 Profile  
 
 Post subject: Re: How to use Score / High Score with 15 digits and BAM.
 Post Posted: Fri Sep 15, 2017 4:40 pm 
Offline

Joined: Thu Aug 16, 2012 11:12 pm
Posts: 1146
Location: Arkansas, USA
Galaxia 1.0 has 2 problems. It has examples of "1. Overflow error with modulo operator." and "3. Overflow error when you assign score to hud display / gas discharge segment displays / DMD displays". Rav also found a few errors in the script that I have included his fix.

Example of "3. Overflow error when you assign score to hud display / gas discharge segment displays / DMD displays"
Code:
'   DispSegPlayer1.SetValue(nvScore1):DispPlayer1.SetValue(nvScore1) ' Old line of script
'   DispSegPlayer2.SetValue(nvScore2) ' Old line of script
'   DispSegPlayer3.SetValue(nvScore3) ' Old line of script
'   DispSegPlayer4.SetValue(nvScore3)  ' <-- Typo? it should be nvScore4 ? ' Old line of script

   DispSegPlayer1.Text = nvScore1 : DispPlayer1.Text = nvScore1 ' <- High Score Fix
   DispSegPlayer2.Text = nvScore2 ' <- High Score Fix
   DispSegPlayer3.Text = nvScore3 ' <- High Score Fix
   DispSegPlayer4.Text = nvScore4 ' <-- High Score Fix. I switched it to nvScore4


Example of "3. Overflow error when you assign score to hud display / gas discharge segment displays / DMD displays"
Code:
'   DispSegPlayer1.SetValue (nvHighScore1):DispPlayer1.SetValue (nvHighScore1) ' <--  ' Old line of script, Why DispSegPlayer1 
'   is set to display nvHighScore1 if it is set to display nvScore1 few lines above?
   DispSegPlayer1.Text = nvHighScore1 : DispPlayer1.Text = nvHighScore1 ' <- High Score Fix (I remarked out this line but you can use your own judgement)


Example of "1. Overflow error with modulo operator."
Code:
' Beginning of section added for High Score Fix (Add this above the line that says "Sub EndOfBallComplete()")
Function MyMod(ByVal a, ByVal b)
    a = Fix(CDbl(a))
    b = Fix(CDbl(b))
    MyMod = a - Fix(a/b) * b
End Function
' End of section added for High Score Fix


Continuation of example of "1. Overflow error with modulo operator."
Code:
            ' Last2Digits = nvScore(i) mod 10 ' Old line of script
            Last2Digits = MyMod(nvScore(i), 10) ' <- High Score Fix


Example of "3. Overflow error when you assign score to hud display / gas discharge segment displays / DMD displays"
Code:
'         Case 1:   DispSegPlayer1.AddValue(points):DispPlayer1.AddValue(points) ' Old line of script
'         Case 2:   DispSegPlayer2.AddValue(points) ' Old line of script
'         Case 3:   DispSegPlayer3.AddValue(points) ' Old line of script
'        Case 4:   DispSegPlayer4.AddValue(points) ' Old line of script
         Case 1:   DispSegPlayer1.Text = nvScore(CurrentPlayer):DispPlayer1.Text = nvScore(CurrentPlayer) ' <- High Score Fix
         Case 2:   DispSegPlayer2.Text = nvScore(CurrentPlayer) ' <- High Score Fix
         Case 3:   DispSegPlayer3.Text = nvScore(CurrentPlayer) ' <- High Score Fix
         Case 4:   DispSegPlayer4.Text = nvScore(CurrentPlayer) ' <- High Score Fix


Last edited by GeorgeH on Fri Sep 15, 2017 11:55 pm, edited 4 times in total.

Top 
 Profile  
 
 Post subject: Re: How to use Score / High Score with 15 digits and BAM.
 Post Posted: Fri Sep 15, 2017 5:01 pm 
Offline

Joined: Mon Jan 27, 2014 12:36 pm
Posts: 1677
Location: Ontario, Canada
ravarcade wrote:
If you don't have problem with score too high (overflow error in script) and table works fine with results limited to 9 digits (exactly 2 147 483 647 max), then don't do anything.


George , so you and Rav don't blow a gasket, I wouldn't worry about all the tables?
No one has complained so it is likely no one had reached the crash point....in most tables anyways?


Top 
 Profile  
 
 Post subject: Re: How to use Score / High Score with 15 digits and BAM.
 Post Posted: Fri Sep 15, 2017 5:15 pm 
Offline

Joined: Thu Aug 16, 2012 11:12 pm
Posts: 1146
Location: Arkansas, USA
The Walking Dead (S3) 1.2 has examples of all 3 problems.

Example of "3. Overflow error when you assign score to hud display / gas discharge segment displays / DMD displays"
Code:
'   DispSegPlayer1.SetValue(nvScore1) ' Old line of script
'  DispSeg1.SetValue(nvScore1) ' Old line of script
'   DispSegPlayer2.SetValue(nvScore2) ' Old line of script
'   DispSegPlayer3.SetValue(nvScore3) ' Old line of script
'  DispSegPlayer4.SetValue(nvScore3) ' Old line of script

   DispSegPlayer1.Text = nvScore1 ' <- High Score Fix
   DispSeg1.Text = nvScore1 ' <- High Score Fix
   DispSegPlayer2.Text = nvScore2 ' <- High Score Fix
   DispSegPlayer3.Text = nvScore3 ' <- High Score Fix
   DispSegPlayer4.Text = nvScore4 ' <- High Score Fix


Example of "3. Overflow error when you assign score to hud display / gas discharge segment displays / DMD displays"
Code:
'   dispsegplayer1.setvalue (nvHighScore1):sz=nvHighScore1:numout ' Old line of script
'  dispseg1.setvalue (nvHighScore1):sz=nvHighScore1:numout ' Old line of script

   dispsegplayer1.Text = nvHighScore1:sz = nvHighScore1:numout ' <- High Score Fix
   dispseg1.Text = nvHighScore1:sz = nvHighScore1:numout ' <- High Score Fix


Example of "1. Overflow error with modulo operator."
Code:
' Beginning of section added for High Score Fix (Add this above the line that says "Sub EndOfBallComplete()")
Function MyMod(ByVal a, ByVal b)
    a = Fix(CDbl(a))
    b = Fix(CDbl(b))
    MyMod = a - Fix(a/b) * b
End Function
' End of section added for High Score Fix


Continuation of example of "1. Overflow error with modulo operator."
Code:
            'Last2Digits = nvScore(i) mod 10 ' Old line of script
            Last2Digits = MyMod( nvScore(i), 10) ' <- High Score Fix


Example of "3. Overflow error when you assign score to hud display / gas discharge segment displays / DMD displays"
Code:
'         Case 1:   DispSegPlayer1.AddValue(points):sz=DispSegPlayer1.value:numout ' Old line of script
'                  DispSeg1.AddValue(points):sz=DispSeg1.value:numout' ' Old line of script
'         Case 2:   DispSegPlayer2.AddValue(points) ' Old line of script
'         Case 3:   DispSegPlayer3.AddValue(points) ' Old line of script
'         Case 4:   DispSegPlayer4.AddValue(points) ' Old line of script

         Case 1:   DispSegPlayer1.Text = nvScore(CurrentPlayer):sz= nvScore(CurrentPlayer):numout ' <- High Score Fix
                  DispSeg1.Text = nvScore(CurrentPlayer):sz= nvScore(CurrentPlayer):numout ' <- High Score Fix
         Case 2:   DispSegPlayer2.Text = nvScore(CurrentPlayer) ' <- High Score Fix
         Case 3:   DispSegPlayer3.Text = nvScore(CurrentPlayer) ' <- High Score Fix
         Case 4:   DispSegPlayer4.Text = nvScore(CurrentPlayer) ' <- High Score Fix


Example of "2. Overflow error with integer division operator."
Code:
' Beginning of old subroutine
'Sub Numout
'    zep=0
'    ads=sz
'    num=ads\1000000
'    ads=ads-(num*1000000)
'    if num=0 then num=10
'    overlay8.frame num
'    num=ads\100000
'    ads=ads-(num*100000)
'    if num=0 then num=10
'    overlay7.frame num
'    num=ads\10000
'    ads=ads-(num*10000)
'    if num=0 then num=10
'    overlay6.frame num 
'    num=ads\1000
'    ads=ads-(num*1000)
'    if num=0 then num=10
'    overlay5.frame num 
'    num=ads\100
'    ads=ads-(num*100)
'    if num=0 then num=10
'    overlay4.frame num
'    num=ads\10
'    ads=ads-(num*10)
'    if num=0 then num=10
'    overlay3.frame num
'    num=ads\1
'    ads=ads-(num*1)
'    if num=0 then num=10
'    overlay2.frame num
'End Sub
' End of old subroutine

' Beginning of new subroutine and dim for High Score Fix
Dim LettersToFrame(128)
LettersToFrame(Asc("1")) = 1
LettersToFrame(Asc("2")) = 2
LettersToFrame(Asc("3")) = 3
LettersToFrame(Asc("4")) = 4
LettersToFrame(Asc("5")) = 5
LettersToFrame(Asc("6")) = 6
LettersToFrame(Asc("7")) = 7
LettersToFrame(Asc("8")) = 8
LettersToFrame(Asc("9")) = 9
LettersToFrame(Asc("0")) = 10
   
Sub Numout
AddDebugText "sc: "&nvScore1
AddDebugText "sz: "&sz
   Dim tmp
   Dim ln
   tmp = "000000000000" & sz ' <-- convert integer or currency value to string. We add few 0 at begin.
   ln = Len(tmp)
   overlay2.frame LettersToFrame(Asc(Mid(tmp,ln-0,1)))
   overlay3.frame LettersToFrame(Asc(Mid(tmp,ln-1,1)))
   overlay4.frame LettersToFrame(Asc(Mid(tmp,ln-2,1)))
   overlay5.frame LettersToFrame(Asc(Mid(tmp,ln-3,1)))
   overlay6.frame LettersToFrame(Asc(Mid(tmp,ln-4,1)))
   overlay7.frame LettersToFrame(Asc(Mid(tmp,ln-5,1)))
   overlay8.frame LettersToFrame(Asc(Mid(tmp,ln-6,1)))
End Sub
' End of New subroutine for High Score Fix


George


Last edited by GeorgeH on Fri Sep 15, 2017 11:53 pm, edited 4 times in total.

Top 
 Profile  
 
 Post subject: Re: How to use Score / High Score with 15 digits and BAM.
 Post Posted: Fri Sep 15, 2017 11:01 pm 
Offline

Joined: Thu Aug 16, 2012 11:12 pm
Posts: 1146
Location: Arkansas, USA
Gimli wrote:
ravarcade wrote:
If you don't have problem with score too high (overflow error in script) and table works fine with results limited to 9 digits (exactly 2 147 483 647 max), then don't do anything.


George , so you and Rav don't blow a gasket, I wouldn't worry about all the tables?
No one has complained so it is likely no one had reached the crash point....in most tables anyways?


I tested all the tables I discussed here to 900 trillion points. Of course, I used the cheat code. I didn't have any problems.

But then Rav has a point. Why change something that is not needed? The old EM tables would probably never need this change. But if you are creating a new solid state table, why not write the script to allow it to achieve 900 trillion points?

I am not sure all the tables I tested really need the change. Personally, I will definitely fix "Attack From Mars" and "World Cup Soccer" for my own use because I don't like the way the script changes the score. But then, I would definitely not tackle "The Walking Dead" (see the above posting) if there was not a real need for the change.

To my thinking, what is the harm if there is no change needed to fix the table other than adding the fix score code? If there are problems, we can fix them as they occur.

I suppose Rav may have a different opinion.

George


Top 
 Profile  
 
 Post subject: Re: How to use Score / High Score with 15 digits and BAM.
 Post Posted: Sat Sep 16, 2017 8:19 am 
Offline

Joined: Mon Jan 27, 2014 12:36 pm
Posts: 1677
Location: Ontario, Canada
In my tweaking adventures, I believe
Slam, Francisco, Rom, Glxb,Polygame,Wild, Franzleo all use standard scoring routines (occasionally will use nvscore/10) so I think the simple xBAM.FixScore will suffice for most people
Code:
'xBAM.FixScore


And I agree EM reel tables are designed for low scores, so they are not even a concern here (so that includes many Popotte tables)


Top 
 Profile  
 
Display posts from previous:  Sort by  
 
Post new topic Reply to topic  [ 16 posts ]  Go to page 1, 2  Next

Board index » Future Pinball » BAM corner


Who is online

Users browsing this forum: No registered users and 4 guests

 
 

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to: