Skip to content

Commit

Permalink
Improved RND seeding
Browse files Browse the repository at this point in the history
  • Loading branch information
neilsf committed Jan 18, 2021
1 parent 5f4d2c1 commit 24466d2
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 21 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v2.3.08
v2.3.09
2 changes: 2 additions & 0 deletions lib/nucleus.asm
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ LOAD EQU $ffd5
SAVE EQU $ffd8
PLOT EQU $fff0

random EQU ZP_RNDSEED + 1

; Push a zero on the stack
; EXAMINE REFS BEFORE CHANGING!
MAC pzero
Expand Down
43 changes: 24 additions & 19 deletions lib/stdlib.asm
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

KERNAL_PRINTCHR EQU $e716
KERNAL_GETIN EQU $ffe4
ZP_RNDSEED EQU $8b
ZP_JIFFY EQU $a0
RESERVED_STACK_POINTER DC.B 0
FILE_ERROR_MSG DC.B 0

Expand Down Expand Up @@ -274,35 +276,38 @@ STDLIB_OUTPUT_FLOAT SUBROUTINE
ENDM
STDLIB_RND SUBROUTINE
lda random+1
sta temp1
lda random
.random EQU ZP_RNDSEED + 1
.temp1 EQU ZP_RNDSEED + 4
lda .random+1
sta .temp1
lda .random
asl
rol temp1
rol .temp1
asl
rol temp1
rol .temp1
clc
adc random
adc .random
pha
lda temp1
adc random+1
sta random+1
lda .temp1
adc .random+1
sta .random+1
pla
adc #$11
sta random
lda random+1
sta .random
lda .random+1
adc #$36
sta random+1
sta .random+1
rts

temp1: DC.B $5a
random: DC.B %10011101,%01011011

MAC seed_rnd
lda $a1
sta random
lda $a2
sta random+1
lda #$80
sta ZP_RNDSEED
lda ZP_JIFFY + 2
sta ZP_RNDSEED + 1
lda ZP_JIFFY + 1
sta ZP_RNDSEED + 2
lda ZP_JIFFY
sta ZP_RNDSEED + 3
ENDM

LIST ON
2 changes: 1 addition & 1 deletion source/app.d
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ string listfile="";
* Version
*/

string compiler_version = "v2.3.08";
string compiler_version = "v2.3.09";

/**
* Application entry point
Expand Down

0 comments on commit 24466d2

Please sign in to comment.