Re: RND function on B series vs C64/C128

From: Ullrich von Bassewitz <uz_at_musoftware.de>
Date: Sun, 19 Feb 2023 17:41:04 +0100
Message-ID: <20230219164104.GA314959_at_trixie.musoftware.de>
This is the RND routine (grabbed from the BASIC sources):

;   PSEUDO-RANDOM NUMBER GENERATOR.
RND
 JSR SIGN
 BMI RND1
 LDX SEEDPT
 LDY SEEDPT+1
 INX
 BNE RND10
 INY
RND10
 TXA
 LDX #STRBNK ;ALWAYS IN STR BANK
 JSR MOVFUM
 LDA #<RMULC
 LDY #>RMULC
 JSR FMULT
 LDA #<RADDC
 LDY #>RADDC
 JSR FADD
RND1 LDX FACLO
 LDA FACHO
 STA FACLO
 STX FACHO
 LDX FACMOH
 LDA FACMO
 STA FACMOH
 STX FACMO
STRNEX LDA #0
 STA FACSGN
 LDA FACEXP
 STA FACOV
 LDA #$80
 STA FACEXP
 JSR NORMAL
 LDX SEEDPT
 LDY SEEDPT+1
 LDA #STRBNK
 INX
 BNE RND20     ;IF NO CARRY
 INY
RND20 JMP MOVUMF

If I interpret the code correctly, the description from the Reference Guide
seems to be correct.

Regards


        Uz


On Sun, Feb 19, 2023 at 09:39:11AM -0600, Micah Bly wrote:
> I’m working on a documentation project for the CBM II series.
>
> In comparing the descriptions of RND() for C64, C128, and B series, and in some light testing, I think the function may behave differently. Before I write that down, I wanted to check if that made sense. I could just be misinterpreting what I’m seeing.
>
> C128 system guide says X in RND(X) can be 0 for clock-based number, negative to pick a new see, and positive to use a random number from the RNG (not from clock).  Page 325.
> C64 wiki describes the same behavior as C128 system guide, in more detail, with a sample program to show difference between RND(0) and RND(pos).
> https://www.c64-wiki.com/wiki/RND
> “CBM 700 Reference Guide” (the thing CBM UK wrote that Protecto distributed) says only this:
> =====
>
> expression < 0
>
> The algorithm uses the expression number to calculate the random number ("seed").
>
> expression >= 0
>
> The algorithm uses the last previously formed random number to calculate the new random number ("series").
>
> =====
>
> I ran the test program from the 64 wiki on the B128 (vice), and I can’t see a difference really. Certainly not the pattern you see in the pic on c64 wiki. Timer is very different on B series… is it possible they just decided not to offer that option?
>
> Thanks,
>
> Micah Bly
>

-- 
Ullrich von Bassewitz                                  uz_at_musoftware.de
Encrypted email preferred                          PGP Key-Id: 29D93B10
Received on 2023-02-19 18:00:03

Archive generated by hypermail 2.3.0.