<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://air.imag.fr/index.php?action=history&amp;feed=atom&amp;title=D%C3%A9veloppement_BasicCard%2FGamblingCard%2FGAMBLING.BAS</id>
	<title>Développement BasicCard/GamblingCard/GAMBLING.BAS - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://air.imag.fr/index.php?action=history&amp;feed=atom&amp;title=D%C3%A9veloppement_BasicCard%2FGamblingCard%2FGAMBLING.BAS"/>
	<link rel="alternate" type="text/html" href="https://air.imag.fr/index.php?title=D%C3%A9veloppement_BasicCard/GamblingCard/GAMBLING.BAS&amp;action=history"/>
	<updated>2026-06-19T13:03:31Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.39.17</generator>
	<entry>
		<id>https://air.imag.fr/index.php?title=D%C3%A9veloppement_BasicCard/GamblingCard/GAMBLING.BAS&amp;diff=19748&amp;oldid=prev</id>
		<title>Donsez at 07:13, 3 December 2014</title>
		<link rel="alternate" type="text/html" href="https://air.imag.fr/index.php?title=D%C3%A9veloppement_BasicCard/GamblingCard/GAMBLING.BAS&amp;diff=19748&amp;oldid=prev"/>
		<updated>2014-12-03T07:13:20Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 07:13, 3 December 2014&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;source lang=&quot;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;basic&lt;/del&gt;&quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;source lang=&quot;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;blitzbasic&lt;/ins&gt;&quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Rem Gambling BasicCard Source Code&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Rem Gambling BasicCard Source Code&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Rem ------------------------------------------------------------------&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Rem ------------------------------------------------------------------&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Donsez</name></author>
	</entry>
	<entry>
		<id>https://air.imag.fr/index.php?title=D%C3%A9veloppement_BasicCard/GamblingCard/GAMBLING.BAS&amp;diff=19747&amp;oldid=prev</id>
		<title>Donsez: Created page with &quot; &lt;source lang=&quot;basic&quot;&gt; Rem Gambling BasicCard Source Code Rem ------------------------------------------------------------------ Rem Copyright (C) 2002 Didier DONSEZ Rem -----...&quot;</title>
		<link rel="alternate" type="text/html" href="https://air.imag.fr/index.php?title=D%C3%A9veloppement_BasicCard/GamblingCard/GAMBLING.BAS&amp;diff=19747&amp;oldid=prev"/>
		<updated>2014-12-03T07:12:21Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot; &amp;lt;source lang=&amp;quot;basic&amp;quot;&amp;gt; Rem Gambling BasicCard Source Code Rem ------------------------------------------------------------------ Rem Copyright (C) 2002 Didier DONSEZ Rem -----...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
Rem Gambling BasicCard Source Code&lt;br /&gt;
Rem ------------------------------------------------------------------&lt;br /&gt;
Rem Copyright (C) 2002 Didier DONSEZ&lt;br /&gt;
Rem ------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
Rem  GAMBLING CARD&lt;br /&gt;
&lt;br /&gt;
Rem This file system could be use to store a history file&lt;br /&gt;
Dir &amp;quot;\&amp;quot; &amp;#039; Set the access conditions on the root directory&lt;br /&gt;
  Write Unlock&lt;br /&gt;
End Dir&lt;br /&gt;
&lt;br /&gt;
Option Explicit &amp;#039; Disable use of undefined variable names&lt;br /&gt;
Option Base 0   &amp;#039; Arrays start at 0&lt;br /&gt;
&lt;br /&gt;
#Include GAMBLING.DEF &amp;#039; Declarations common to BasicCard and Terminal programs&lt;br /&gt;
rem #Include DEALER.KEY&lt;br /&gt;
rem #Include ISSUER.KEY&lt;br /&gt;
&lt;br /&gt;
#Include COMMANDS.DEF&lt;br /&gt;
#include PReader.def&lt;br /&gt;
&lt;br /&gt;
Declare ApplicationID = ApplicationName$&lt;br /&gt;
Disable Encryption &amp;amp;H11&lt;br /&gt;
&lt;br /&gt;
Rem  Permanent data&lt;br /&gt;
&lt;br /&gt;
Eeprom Personalised = False&lt;br /&gt;
Eeprom Balance As Long&lt;br /&gt;
Eeprom PIN As String*4&lt;br /&gt;
&amp;#039; Change following line to set your initial master PIN&lt;br /&gt;
Eeprom MasterPIN As String*6 = &amp;quot;123456&amp;quot;&lt;br /&gt;
Eeprom CustomerName$&lt;br /&gt;
Eeprom PINErrors&lt;br /&gt;
&lt;br /&gt;
Eeprom WinningRatio As Long&lt;br /&gt;
&lt;br /&gt;
Rem  EEPROM shadow data, to ensure that Balance is always valid&lt;br /&gt;
Rem&lt;br /&gt;
Rem  See &amp;quot;1.4.4 Permanent Data&amp;quot; in the BasicCard manual.&lt;br /&gt;
&lt;br /&gt;
Eeprom ShadowBalance As Long&lt;br /&gt;
Eeprom Committed = False&lt;br /&gt;
&lt;br /&gt;
Rem  Public data (re-initialised when card is reset)&lt;br /&gt;
&lt;br /&gt;
Public PINVerified = False&lt;br /&gt;
Public MasterPINVerified = False&lt;br /&gt;
&lt;br /&gt;
Public Bounds(7) As Long&lt;br /&gt;
Public Winnings(7) As Long&lt;br /&gt;
Public NumberOfBounds As Byte = 0&lt;br /&gt;
Public NumberOfWinnings As Byte = 0&lt;br /&gt;
Public isConsistent@ = False&lt;br /&gt;
&lt;br /&gt;
Rem  Subroutine declaration&lt;br /&gt;
&lt;br /&gt;
Declare Sub ChangeBalance (NewBalance As Long)&lt;br /&gt;
Declare Sub CheckConsistency()&lt;br /&gt;
Declare Sub CheckAlgorithm()&lt;br /&gt;
&lt;br /&gt;
Rem  Start-up code: clean up if an EEPROM write was interrupted&lt;br /&gt;
Rem&lt;br /&gt;
Rem  See &amp;quot;1.4.4 Permanent Data&amp;quot; in the BasicCard manual.&lt;br /&gt;
&lt;br /&gt;
If Committed Then&lt;br /&gt;
  Balance = ShadowBalance&lt;br /&gt;
  Committed = False&lt;br /&gt;
End If&lt;br /&gt;
&lt;br /&gt;
Command &amp;amp;H80 &amp;amp;H00 PersonaliseCard (Amount As Long, NewPIN As String*4, Name$)&lt;br /&gt;
rem  Call CheckAlgorithm()&lt;br /&gt;
rem   If KeyNumber &amp;lt;&amp;gt; 0 Then SW1SW2 = swIssuingKeyRequired : Exit&lt;br /&gt;
  Personalised = False &amp;#039; In case power is lost in the next three statements&lt;br /&gt;
  Balance = Amount&lt;br /&gt;
  CustomerName$ = Name$&lt;br /&gt;
  PIN = NewPIN&lt;br /&gt;
  Personalised = True&lt;br /&gt;
End Command&lt;br /&gt;
&lt;br /&gt;
Command &amp;amp;H80 &amp;amp;H02 VerifyPIN (TestPIN As String*4)&lt;br /&gt;
  If Not Personalised Then SW1SW2 = swNotPersonalised : Exit&lt;br /&gt;
rem  Call CheckAlgorithm()&lt;br /&gt;
rem  If KeyNumber &amp;lt;&amp;gt; 0 And PINErrors &amp;gt; MaxPINErrors Then _&lt;br /&gt;
  If PINErrors &amp;gt; MaxPINErrors Then SW1SW2 = swPINErrorsExceeded : Exit&lt;br /&gt;
  If TestPIN = PIN Then PINErrors = 0 : PINVerified = True : Exit&lt;br /&gt;
  PINErrors = PINErrors + 1&lt;br /&gt;
  SW1SW2 = swInvalidPIN&lt;br /&gt;
  PINVerified = False&lt;br /&gt;
End Command&lt;br /&gt;
&lt;br /&gt;
Command &amp;amp;H80 &amp;amp;H04 IncreaseAmount (Diff As Long)&lt;br /&gt;
  If Not Personalised Then SW1SW2 = swNotPersonalised : Exit&lt;br /&gt;
rem  Call CheckAlgorithm()&lt;br /&gt;
  If Not (PINVerified OR MasterPINVerified) Then SW1SW2 = swPINRequired : Exit&lt;br /&gt;
  Call ChangeBalance (Balance + Diff)&lt;br /&gt;
End Command&lt;br /&gt;
&lt;br /&gt;
Command &amp;amp;H80 &amp;amp;H06 DecreaseAmount (Diff As Long)&lt;br /&gt;
  If Not Personalised Then SW1SW2 = swNotPersonalised : Exit&lt;br /&gt;
rem  Call CheckAlgorithm()&lt;br /&gt;
  If Not (PINVerified OR MasterPINVerified) Then SW1SW2 = swPINRequired : Exit&lt;br /&gt;
  If Diff &amp;gt; Balance Then SW1SW2 = swInsufficientFunds : Exit&lt;br /&gt;
  Call ChangeBalance (Balance - Diff)&lt;br /&gt;
End Command&lt;br /&gt;
&lt;br /&gt;
Command &amp;amp;H80 &amp;amp;H08 ChangePIN (NewPIN As String*4)&lt;br /&gt;
  If Not Personalised Then SW1SW2 = swNotPersonalised : Exit&lt;br /&gt;
rem  Call CheckAlgorithm()&lt;br /&gt;
  If Not (PINVerified OR MasterPINVerified) Then SW1SW2 = swPINRequired : Exit&lt;br /&gt;
  PIN = NewPIN&lt;br /&gt;
End Command&lt;br /&gt;
&lt;br /&gt;
Command &amp;amp;H80 &amp;amp;H0A GetCardData (Amount As Long, PINCount, Name$)&lt;br /&gt;
  If Not Personalised Then SW1SW2 = swNotPersonalised : Exit&lt;br /&gt;
  Amount = Balance&lt;br /&gt;
  PINCount = MaxPINErrors - PINErrors&lt;br /&gt;
  Name$ = CustomerName$&lt;br /&gt;
End Command&lt;br /&gt;
&lt;br /&gt;
Command &amp;amp;H80 &amp;amp;H20 GetBalance (Amount As Long)&lt;br /&gt;
  If Not Personalised Then SW1SW2 = swNotPersonalised : Exit&lt;br /&gt;
  Amount = Balance&lt;br /&gt;
End Command&lt;br /&gt;
&lt;br /&gt;
Command &amp;amp;H80 &amp;amp;H22 Debit (Amount As Long)&lt;br /&gt;
  If Not Personalised Then SW1SW2 = swNotPersonalised : Exit&lt;br /&gt;
rem  Call CheckAlgorithm()&lt;br /&gt;
  If Not (PINVerified OR MasterPINVerified) Then SW1SW2 = swPINRequired : Exit&lt;br /&gt;
  If Amount &amp;gt; Balance Then SW1SW2 = swInsufficientFunds : Exit&lt;br /&gt;
  Call ChangeBalance (Balance - Amount)&lt;br /&gt;
  Amount=Balance &amp;#039; new balance is returned in amount param&lt;br /&gt;
End Command&lt;br /&gt;
&lt;br /&gt;
Command &amp;amp;H80 &amp;amp;H24 Credit (Amount As Long)&lt;br /&gt;
  If Not Personalised Then SW1SW2 = swNotPersonalised : Exit&lt;br /&gt;
rem  Call CheckAlgorithm()&lt;br /&gt;
  If Not (PINVerified OR MasterPINVerified) Then SW1SW2 = swPINRequired : Exit&lt;br /&gt;
  Call ChangeBalance (Balance + Amount)&lt;br /&gt;
  Amount=Balance &amp;#039; new balance is returned in amount param&lt;br /&gt;
End Command&lt;br /&gt;
&lt;br /&gt;
Command &amp;amp;H80 &amp;amp;H26 Bet(betAmount As Long)&lt;br /&gt;
  Private b As Byte&lt;br /&gt;
  Private r As Long&lt;br /&gt;
  Private winning As Long&lt;br /&gt;
&lt;br /&gt;
  If Not Personalised Then SW1SW2 = swNotPersonalised : Exit&lt;br /&gt;
rem  Call CheckAlgorithm()&lt;br /&gt;
  If Not (PINVerified OR MasterPINVerified) Then SW1SW2 = swPINRequired : Exit&lt;br /&gt;
  If betAmount &amp;gt; Balance Then SW1SW2 = swInsufficientFunds : Exit&lt;br /&gt;
&lt;br /&gt;
  rem check if Bounds and Winnings are consistent&lt;br /&gt;
  Call CheckConsistency()&lt;br /&gt;
    &lt;br /&gt;
  rem next random to decide between bank and (win or loss)&lt;br /&gt;
  r=Abs(Rnd) Mod 100&lt;br /&gt;
  if r&amp;lt;WinningRatio then&lt;br /&gt;
        rem next random to decide between win and loss&lt;br /&gt;
        r=Abs(Rnd) Mod Bounds(NumberOfBounds-1)&lt;br /&gt;
&lt;br /&gt;
    rem win or lost in the winnings/bounds&lt;br /&gt;
    rem b is the bound&lt;br /&gt;
    for b=0 to (NumberOfBounds-1)&lt;br /&gt;
        If r&amp;lt;Bounds(b) Then&lt;br /&gt;
            Exit For&lt;br /&gt;
        End If&lt;br /&gt;
    Next b&lt;br /&gt;
&lt;br /&gt;
    winning=Winnings(b)*betAmount&lt;br /&gt;
        rem winning may zero or positive (even negative)&lt;br /&gt;
  Else&lt;br /&gt;
    rem for the bank&lt;br /&gt;
    winning=0&lt;br /&gt;
  End If&lt;br /&gt;
&lt;br /&gt;
  Call ChangeBalance (Balance - betAmount + winning)&lt;br /&gt;
&lt;br /&gt;
  rem return the winning&lt;br /&gt;
  betAmount=winning&lt;br /&gt;
&lt;br /&gt;
End Command&lt;br /&gt;
&lt;br /&gt;
Command &amp;amp;H80 &amp;amp;H30 SetWinRatio(wr As Long)&lt;br /&gt;
  If Not Personalised Then SW1SW2 = swNotPersonalised : Exit&lt;br /&gt;
rem  Call CheckAlgorithm()&lt;br /&gt;
    if wr&amp;gt;100 Then SW1SW2 = swInconsistentWinningRatio : Exit&lt;br /&gt;
    WinningRatio=wr&lt;br /&gt;
End Command&lt;br /&gt;
&lt;br /&gt;
Command &amp;amp;H80 &amp;amp;H32 GetWinRatio(wr As Long)&lt;br /&gt;
  If Not Personalised Then SW1SW2 = swNotPersonalised : Exit&lt;br /&gt;
rem  Call CheckAlgorithm()&lt;br /&gt;
    wr=WinningRatio&lt;br /&gt;
End Command&lt;br /&gt;
&lt;br /&gt;
Command &amp;amp;H80 &amp;amp;H34 GetBounds(numbounds@, bound0&amp;amp;,bound1&amp;amp;,bound2&amp;amp;,bound3&amp;amp;,bound4&amp;amp;,bound5&amp;amp;,bound6&amp;amp;,bound7&amp;amp;,bound8&amp;amp;,bound9&amp;amp;)&lt;br /&gt;
  If Not Personalised Then SW1SW2 = swNotPersonalised : Exit&lt;br /&gt;
rem  Call CheckAlgorithm()&lt;br /&gt;
&lt;br /&gt;
    numbounds@=NumberOfBounds&lt;br /&gt;
    bound0&amp;amp; = Bounds(0)&lt;br /&gt;
    bound1&amp;amp; = Bounds(1)&lt;br /&gt;
    bound2&amp;amp; = Bounds(2)&lt;br /&gt;
    bound3&amp;amp; = Bounds(3)&lt;br /&gt;
    bound4&amp;amp; = Bounds(4)&lt;br /&gt;
    bound5&amp;amp; = Bounds(5)&lt;br /&gt;
    bound6&amp;amp; = Bounds(6)&lt;br /&gt;
End Command&lt;br /&gt;
&lt;br /&gt;
Command &amp;amp;H80 &amp;amp;H36 SetBounds(numbounds@, bound0&amp;amp;,bound1&amp;amp;,bound2&amp;amp;,bound3&amp;amp;,bound4&amp;amp;,bound5&amp;amp;,bound6&amp;amp;,bound7&amp;amp;,bound8&amp;amp;,bound9&amp;amp;)&lt;br /&gt;
  If Not Personalised Then SW1SW2 = swNotPersonalised : Exit&lt;br /&gt;
rem  Call CheckAlgorithm()&lt;br /&gt;
&lt;br /&gt;
    isConsistent@ = False           &amp;#039; Bounds and Winnings must be checked before betting&lt;br /&gt;
    NumberOfBounds = numbounds@&lt;br /&gt;
    Bounds(0) = bound0&amp;amp;&lt;br /&gt;
    Bounds(1) = bound1&amp;amp;&lt;br /&gt;
    Bounds(2) = bound2&amp;amp;&lt;br /&gt;
    Bounds(3) = bound3&amp;amp;&lt;br /&gt;
    Bounds(4) = bound4&amp;amp;&lt;br /&gt;
    Bounds(5) = bound5&amp;amp;&lt;br /&gt;
    Bounds(6) = bound6&amp;amp;&lt;br /&gt;
End Command&lt;br /&gt;
&lt;br /&gt;
Command &amp;amp;H80 &amp;amp;H38 GetWinnings(numwinnings@, winning0&amp;amp;,winning1&amp;amp;,winning2&amp;amp;,winning3&amp;amp;,winning4&amp;amp;,winning5&amp;amp;,winning6&amp;amp;,winning7&amp;amp;,winning8&amp;amp;,winning9&amp;amp;)&lt;br /&gt;
  If Not Personalised Then SW1SW2 = swNotPersonalised : Exit&lt;br /&gt;
rem  Call CheckAlgorithm()&lt;br /&gt;
&lt;br /&gt;
    numwinnings@=NumberOfWinnings&lt;br /&gt;
    winning0&amp;amp; = Winnings(0)&lt;br /&gt;
    winning1&amp;amp; = Winnings(1)&lt;br /&gt;
    winning2&amp;amp; = Winnings(2)&lt;br /&gt;
    winning3&amp;amp; = Winnings(3)&lt;br /&gt;
    winning4&amp;amp; = Winnings(4)&lt;br /&gt;
    winning5&amp;amp; = Winnings(5)&lt;br /&gt;
    winning6&amp;amp; = Winnings(6)&lt;br /&gt;
End Command&lt;br /&gt;
&lt;br /&gt;
Command &amp;amp;H80 &amp;amp;H3A SetWinnings(numwinnings@, winning0&amp;amp;,winning1&amp;amp;,winning2&amp;amp;,winning3&amp;amp;,winning4&amp;amp;,winning5&amp;amp;,winning6&amp;amp;,winning7&amp;amp;,winning8&amp;amp;,winning9&amp;amp;)&lt;br /&gt;
  If Not Personalised Then SW1SW2 = swNotPersonalised : Exit&lt;br /&gt;
rem  Call CheckAlgorithm()&lt;br /&gt;
&lt;br /&gt;
    isConsistent@ = False           &amp;#039; Bounds and Winnings must be checked before betting&lt;br /&gt;
    NumberOfWinnings = numwinnings@&lt;br /&gt;
    Winnings(0) = winning0&amp;amp;&lt;br /&gt;
    Winnings(1) = winning1&amp;amp;&lt;br /&gt;
    Winnings(2) = winning2&amp;amp;&lt;br /&gt;
    Winnings(3) = winning3&amp;amp;&lt;br /&gt;
    Winnings(4) = winning4&amp;amp;&lt;br /&gt;
    Winnings(5) = winning5&amp;amp;&lt;br /&gt;
    Winnings(6) = winning6&amp;amp;&lt;br /&gt;
End Command&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Rem  Sub CheckAlgorithm()&lt;br /&gt;
Rem&lt;br /&gt;
Rem  Check that the appropriate encryption algorithm is enabled (&amp;amp;H12&lt;br /&gt;
Rem  in the Compact BasicCard, &amp;amp;H21 in the Enhanced BasicCard)&lt;br /&gt;
&lt;br /&gt;
Sub CheckAlgorithm()&lt;br /&gt;
&lt;br /&gt;
#IfDef CompactBasicCard&lt;br /&gt;
  If Algorithm &amp;lt;&amp;gt; &amp;amp;H12 Then SW1SW2 = swEncryptionRequired : Exit&lt;br /&gt;
#ElseIfDef EnhancedBasicCard&lt;br /&gt;
  If Algorithm &amp;lt;&amp;gt; &amp;amp;H21 Then SW1SW2 = swEncryptionRequired : Exit&lt;br /&gt;
#Else&lt;br /&gt;
  If Algorithm &amp;lt;&amp;gt; &amp;amp;H23 Then SW1SW2 = swEncryptionRequired : Exit&lt;br /&gt;
#EndIf&lt;br /&gt;
&lt;br /&gt;
End Sub&lt;br /&gt;
 &lt;br /&gt;
Rem  Sub ChangeBalance (NewBalance As Long)&lt;br /&gt;
Rem&lt;br /&gt;
Rem  Change the Balance variable, guarding against the possibility that&lt;br /&gt;
Rem  it is left in an inconsistent state by a sudden loss of power.&lt;br /&gt;
Rem&lt;br /&gt;
Rem  See &amp;quot;1.4.3 Permanent Data&amp;quot; in the BasicCard manual.&lt;br /&gt;
&lt;br /&gt;
Sub ChangeBalance (NewBalance As Long)&lt;br /&gt;
  ShadowBalance = NewBalance&lt;br /&gt;
  Committed = True&lt;br /&gt;
  Balance = ShadowBalance&lt;br /&gt;
  Committed = False&lt;br /&gt;
End Sub&lt;br /&gt;
&lt;br /&gt;
Sub CheckConsistency()&lt;br /&gt;
  Rem check values of Bounds() and Winnings()&lt;br /&gt;
  Private total&amp;amp;&lt;br /&gt;
  Private b As Byte&lt;br /&gt;
&lt;br /&gt;
  If isConsistent@ = True Then Exit Sub       &amp;#039; check during a previous call&lt;br /&gt;
&lt;br /&gt;
  If NumberOfBounds &amp;lt; 2 Then GoTo Problem&lt;br /&gt;
&lt;br /&gt;
  If NumberOfWinnings &amp;lt; 2 Then GoTo Problem&lt;br /&gt;
&lt;br /&gt;
  If NumberOfWinnings &amp;lt;&amp;gt; NumberOfBounds Then GoTo Problem&lt;br /&gt;
&lt;br /&gt;
  For b=0 To (NumberOfBounds-1)&lt;br /&gt;
        if Bounds(b) &amp;lt; 0 Then GoTo Problem&lt;br /&gt;
        if Winnings(b) &amp;lt; 0 Then GoTo Problem&lt;br /&gt;
  Next b&lt;br /&gt;
&lt;br /&gt;
  For b=1 To (NumberOfBounds-1)&lt;br /&gt;
        if Bounds(b) &amp;lt;= Bounds(b-1) Then GoTo Problem&lt;br /&gt;
  Next b&lt;br /&gt;
&lt;br /&gt;
  total&amp;amp;=Bounds(0)*Winnings(0)&lt;br /&gt;
  For b=1 To (NumberOfBounds-1)&lt;br /&gt;
        total&amp;amp;= total&amp;amp; + ((Bounds(b)-Bounds(b-1))*Winnings(b))&lt;br /&gt;
  Next b&lt;br /&gt;
  If total&amp;amp; &amp;gt; Bounds(NumberOfBounds-1) Then GoTo Problem&lt;br /&gt;
&lt;br /&gt;
  rem All checks are passed&lt;br /&gt;
  isConsistent@ = True&lt;br /&gt;
  Exit Sub&lt;br /&gt;
   &lt;br /&gt;
  Problem:&lt;br /&gt;
  rem isConsistent@ = False&lt;br /&gt;
  SW1SW2 = swInconsistentBoundsAndWinnings&lt;br /&gt;
  Exit&lt;br /&gt;
End Sub&lt;br /&gt;
&lt;br /&gt;
Command &amp;amp;H80 &amp;amp;H0E ChangeMasterPIN (NewPIN As String*6)&lt;br /&gt;
  If Not Personalised Then SW1SW2 = swNotPersonalised : Exit&lt;br /&gt;
rem   Call CheckAlgorithm()&lt;br /&gt;
  If Not MasterPINVerified Then SW1SW2 = swPINRequired : Exit&lt;br /&gt;
  MasterPIN = NewPIN&lt;br /&gt;
End Command&lt;br /&gt;
&lt;br /&gt;
REM In opposition to normal PIN we use no PIN count, but&lt;br /&gt;
REM issuer key is required instead.&lt;br /&gt;
Command &amp;amp;H80 &amp;amp;H0C VerifyMasterPIN (TestPIN As String*6)&lt;br /&gt;
  If Not Personalised Then SW1SW2 = swNotPersonalised : Exit&lt;br /&gt;
rem   Call CheckAlgorithm()&lt;br /&gt;
rem  If KeyNumber &amp;lt;&amp;gt; 0 Then _&lt;br /&gt;
rem     SW1SW2 = swIssuingKeyRequired : Exit&lt;br /&gt;
  If TestPIN = MasterPIN Then MasterPINVerified = True : Exit&lt;br /&gt;
  SW1SW2 = swInvalidPIN&lt;br /&gt;
  MasterPINVerified = False&lt;br /&gt;
End Command&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Donsez</name></author>
	</entry>
</feed>