From: Oliver Schmidt
Date: Sat, 8 Sep 2018 16:44:30 +0000 (+0200)
Subject: Support randomize().
X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=73faf60fe0eff3a7e0cc1f074cecbe5f4c658426;p=cc65
Support randomize().
In order to have randomize() work as expected (and the Apple II random number generation in general) it is necessary to update the random counter during keypress wait just like the ROM function does.
---
diff --git a/libsrc/apple2/cgetc.s b/libsrc/apple2/cgetc.s
index b1bda8b91..ecce9f9de 100644
--- a/libsrc/apple2/cgetc.s
+++ b/libsrc/apple2/cgetc.s
@@ -25,8 +25,11 @@ _cgetc:
jsr putchardirect ; Returns old character in X
; Wait for keyboard strobe.
+: inc RNDL ; Increment random counter low
+ bne :+
+ inc RNDH ; Increment random counter high
: lda KBD
- bpl :- ; If < 128, no key pressed
+ bpl :-- ; If < 128, no key pressed
; Cursor on ?
ldy cursor