Blame 0057-Significantly-faster-rand-implementation.patch

073ecbe
From 3994fee595605c5981d023c29b5d9d8e170d9adc Mon Sep 17 00:00:00 2001
073ecbe
From: LRFLEW <LRFLEW@aol.com>
073ecbe
Date: Mon, 7 Oct 2019 22:37:34 -0500
a4f04fe
Subject: [PATCH 057/170] Significantly faster rand() implementation
073ecbe
073ecbe
---
073ecbe
 libsrc/common/rand.s | 22 ++++++----------------
073ecbe
 1 file changed, 6 insertions(+), 16 deletions(-)
073ecbe
073ecbe
diff --git a/libsrc/common/rand.s b/libsrc/common/rand.s
073ecbe
index 102dd5be..fc23b6ee 100644
073ecbe
--- a/libsrc/common/rand.s
073ecbe
+++ b/libsrc/common/rand.s
073ecbe
@@ -35,27 +35,17 @@ rand:   .dword   1
073ecbe
 .code
073ecbe
 
073ecbe
 _rand:  clc
073ecbe
-        lda     rand+0          ; SEED *= $01010101
073ecbe
-        adc     rand+1
073ecbe
-        sta     rand+1
073ecbe
-        adc     rand+2
073ecbe
-        sta     rand+2
073ecbe
-        adc     rand+3
073ecbe
-        sta     rand+3
073ecbe
-        clc
073ecbe
-        lda     rand+0          ; SEED += $31415927
073ecbe
-        adc     #$27
073ecbe
+        lda     rand+0          ; SEED += $B3
073ecbe
+        adc     #$B3
073ecbe
         sta     rand+0
073ecbe
-        lda     rand+1
073ecbe
-        adc     #$59
073ecbe
+        adc     rand+1          ; SEED *= $01010101
073ecbe
         sta     rand+1
073ecbe
-        lda     rand+2
073ecbe
-        adc     #$41
073ecbe
+        adc     rand+2
073ecbe
         sta     rand+2
073ecbe
         and     #$7f            ; Suppress sign bit (make it positive)
073ecbe
         tax
073ecbe
-        lda     rand+3
073ecbe
-        adc     #$31
073ecbe
+        lda     rand+2
073ecbe
+        adc     rand+3
073ecbe
         sta     rand+3
073ecbe
         rts                     ; return bit (16-22,24-31) in (X,A)
073ecbe
 
073ecbe
-- 
a4f04fe
2.26.0
073ecbe