Commodore PET User Manual page 313

Table of Contents

Advertisement

300 N1=N1-1
305 REM
IF
EMPTY. GO Ta ANOTHER TABLE
310
IF
N1<0 THEN ON INT(3*RND(1)+1) GOTO 400.500.600
320 AX=(N1+1).RND(1) :REM PICK AN ELEM
330 A=T1(A%)+32768 :REM FORM POKE ADDR
340 TP=T1(A%):T1(A%)=T1(N1):T1(N1)=TP :REM SWAP ELEMENTS
350
RETUF.:~~
399 F:Et1 *lIESU:E:F.:OUT 1NE FOI': TABLE T2l1Ei+i
4t10
~~2=~~2-1
410
IF
N2<0 THEN ON INT(3.RND(1)+1) GOTO 300.500.600
420 A%=(N2+1)*RND(I)
430 A=T2(A%)+32768
440 TP=T2(A%)T2(A%)=T2(N2):T2(N2)=TP
45t1 RETURN
499 REM **SUBROUTINE FOR TABLE'T3••
500
t'B=t'~:3-1
510 IF N3<0 THEN ON INT(3*RND(I)+I) GOTO 300.400.600
520 AX=(N3+1).RND(I)
530 A=T3(A%)+32768
540 TP=T3(A%):T3(A%)=T3(N3):T3(N3)=TP
550 F.:ETUF.:N
599 REM ••SUBROUTINE FOR TABLE
T4••
6~:::10
N4=t-l4-1
610
IF
N4<0 THEN ON INT(3*RND(1)+1) GOTO 300.400.500
620 A%=(N4+1)*RND(I)
630 A=T4(AX)+32768
640 TP=T4(AX):T4(AX)=T4(N4):T4(N4)=TP
650
F:ETUF.:~~
This program is not much longer than the first version. yet it is a good deal
faster, It fills the screen in approximately 45 seconds (compared to a minimum of
three minutes for the first version).
A remaining difficulty. which vou will have already noticed if vou ran the
program. is that there is a noticeable wait while the initialization subroutine runs.
before the HIT A KEY message is displayed,
300

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Cbm

Table of Contents