KENBAK-1 Dice Roller program

54 views
Skip to first unread message

Ardunaut

unread,
Sep 29, 2021, 3:59:39 PMSep 29
to uKenbak-1
Two Dice Roller for the KENBAK-1
Dice_Roller_generric.png
Program start:
  -The first dice is "running" while the OUTPUT shows the led b-7 waiting the press of the [ROLL] button.
  - When the "ROLL" button is pressed the first dice value is captured and saved in the B register.
    Then the second dice is "rolling" waiting for the "STOP" button.
  - When the "STOP" button is pressed the second dice value is captured, is multiplyed by 8 and ored
              with the first dice value to show both in the OUTPUT. Then the first dice is "rolling" again
              waiting for the "ROLL" button to start the next play.

 Each dice "running" spend equal time on each value to garantee true random distribution.

 The random behavior is achieved using the asynchronous input of the user.
============================================================================================================
ORG 002
002: DB  000         ; X= 000 (used to clear the INPUT)
003: DB  004         ; P= 004 (The program counter)
004: LOAD A, C=000
;NEXT:
006: OR   A, C=200   ; Or (bit-7 ON) with Last dice values
010: STORE A, 200    ; Update OUTPUT  with "waiting ROLL key"  
012: STORE X, 377    ; Clear the INPUT  
;--- Rolling until [ROLL] is pressed ---
;ROLL1:      (1 to 6) random generator.         
014: LOAD  A, C=001
016: SKIP 0  b7,377
020: JPD UNC 074    ; jump to OUT1
022: JPD UNC 024    ;same delay than "JPD UNC ROLL1"
024: LOAD  A, C=002
026: SKIP 0  b7,377
030: JPD UNC 074    ; jump to OUT1
032: JPD UNC 034    ;delay
034: LOAD  A, C=003
036: SKIP 0  b7,377
040: JPD UNC 074    ; jump to OUT1
042: JPD UNC 044    ;delay
044: LOAD  A, C=004
046: SKIP 0  b7,377
050: JPD UNC 074    ; jump to OUT1
052: JPD UNC 054    ;delay
054: LOAD  A, C=005
056: SKIP 0  b7,377
060: JPD UNC 074    ; jump to OUT1
062: JPD UNC 064    ;delay
064: LOAD  A, C=006
066: SKIP 0  b7,377
070: JPD UNC 074    ; jump to OUT1
072: JPD UNC 014    ; jump to ROLL1
;OUT1:
074: STORE A, 001   ; Save the value of the first dice in B.
;
076: LOAD A, C=100
100: STORE A, 200   ; Signals "waiting STOP" key"  (bit-6 ON)
102: STORE X, 377   ; Clear the INPUT    
;--- Rolling until [STOP] is pressed ---
;ROLL2:      (1 to 6) random generator.         
104: LOAD  A, C=001
106: SKIP 0  b6,377
110: JPD UNC 164    ; jump to OUT2
112: JPD UNC 114    ;same delay than "JPD UNC ROLL2"
114: LOAD  A, C=002
116: SKIP 0  b6,377
120: JPD UNC 164    ; jump to OUT2
122: JPD UNC 124    ;delay
124: LOAD  A, C=003
126: SKIP 0  b6,377
130: JPD UNC 164    ; jump to OUT2
132: JPD UNC 134    ;delay
134: LOAD  A, C=004
136: SKIP 0  b6,377
140: JPD UNC 164    ; jump to OUT2
142: JPD UNC 144    ;delay
144: LOAD  A, C=005
146: SKIP 0  b6,377
150: JPD UNC 164    ; jump to OUT2
152: JPD UNC 154    ;delay
154: LOAD  A, C=006
156: SKIP 0  b6,377
160: JPD UNC 164    ; jump to OUT2
162: JPD UNC 104    ; jump to ROLL2
;
;OUT2:
164: SFTL A,3
165: OR A, 001      ; A <- A or B
167: JPD UNC 006    ; jump to NEXT


Octal file:
000,000,000,004,023,000,303,200,034,200,234,377,023,001,272,377,
343,074,343,024,023,002,272,377,343,074,343,034,023,003,272,377,
343,074,343,044,023,004,272,377,343,074,343,054,023,005,272,377,
343,074,343,064,023,006,272,377,343,074,343,014,034,001,023,100,
034,200,234,377,023,001,262,377,343,164,343,114,023,002,262,377,
343,164,343,124,023,003,262,377,343,164,343,134,023,004,262,377,
343,164,343,144,023,005,262,377,343,164,343,154,023,006,262,377,
343,164,343,104,231,304,001,343,006,e

Using a spreadsheet for testing the randomness, fair enough ...
Dice_Roller_balanced_txt_Test_01_a2.png
Reply all
Reply to author
Forward
0 new messages