Fast rnd ported to DurexForth #369
Replies: 4 comments 7 replies
-
Hi Joanna, welcome!
Thank you for sharing!
…On Sun, 24 Oct 2021 at 13:49, JoannaK ***@***.***> wrote:
And hi, new here. Simple and fast RND routine utilizing Sid chip.
\ Ref: https://www.atarimagazines.com/compute/issue72/random_numbers.php
\ sidrnd uses voice 3 noise generator,
\ may conflict with music playing routines
\ code sidini
\ $ff lda,# ( maximum frequency )
\ $d40e sta, ( v3 frequency low byte )
\ $d40f sta, ( v3 frequency high byte )
\ $80 lda,# ( noise wavef, gate off )
\ $d412 sta, ( voice 3 control register )
\ ;code
: sidini ( -- ) ( voice 3 max freq noise )
$ffff $d40e !
$80 $d412 c! ;
: sidrnd ( -- c ) ( return random byte )
$D41B c@ ;
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#369>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAY34O256FGDIJEWTRDGXK3UIPXC3ANCNFSM5GTL2LZA>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
|
Beta Was this translation helpful? Give feedback.
-
Question: Is there need for 16 bit random numbers with 6502 based systeem? Asking cause lfsr takes closely N time for N-bits bit, so 8 bit routine is almost twice as fast as 16. I did some testing on rnd results and the lowest bits of brodie-rnd are definitely not random at all. hex Also did some visualization, only at text screen. This will be quite slow on real hw as is since test generates plenty random numbers. Two bytes of screen memory is used as a counter for each 8.bit random value. Good routine to compare speed of various routines. : testy2 page |
Beta Was this translation helpful? Give feedback.
-
These should speed things up a bit. FAST blanks the screen and stops keyboard scan- untested, but correct I think. : irqpeek $dc0e c@ ;
: irqpoke $dc0e c! ;
: blvic $d011 dup c@ ;
: irqoff irqpeek $fe and irqpoke ;
: irqon irqpeek 1 or irqpoke ;
: blank blvic $ef and swap c! ;
: unblank blvic $10 or swap c! ;
: fast irqoff blank ;
: slow irqon unblank ;
|
Beta Was this translation helpful? Give feedback.
-
Here's an exceptionally fast 10 print in forth with your RND routines. : sidini ( -- )
$ffff $d40e !
$80 $d412 c! ;
\ JoannaK
: sidrnd ( -- c )
$D41B c@ ;
: doit do sidrnd 1 and if $4d i c!
else $4e i c! then loop ; \ poke screen codes
: 10print 142 emit sidini \ change case
2024 1024 doit \ whole screen
begin
1064 1024 960 move \ scroll screen
2024 1984 doit \ last line
key? until
key drop page 14 emit ; \ cls, change case |
Beta Was this translation helpful? Give feedback.
-
And hi, new here. Simple and fast RND routine utilizing Sid chip.
\ Ref: https://www.atarimagazines.com/compute/issue72/random_numbers.php
\ sidrnd uses voice 3 noise generator,
\ may conflict with music playing routines
\ code sidini
\ $ff lda,# ( maximum frequency )
\ $d40e sta, ( v3 frequency low byte )
\ $d40f sta, ( v3 frequency high byte )
\ $80 lda,# ( noise wavef, gate off )
\ $d412 sta, ( voice 3 control register )
\ ;code
: sidini ( -- ) ( voice 3 max freq noise )
$ffff $d40e !
$80 $d412 c! ;
: sidrnd ( -- c ) ( return random byte )
$D41B c@ ;
Beta Was this translation helpful? Give feedback.
All reactions