1 REM +++++++++++++++++++++++++++++++++ 2 REM ! Program .... DRAWSPIR.BAS 3 REM ! Utg}va 1.3 85 04 11 4 REM ! av (c) Tom Sj|berg 2401 5 REM ! Minne 32 Kbytes 6 REM ! Ins{nt av 2401 7 REM +++++++++++++++++++++++++++++++++ 8 REM Ett skapande grafikprogram,som 9 REM kr{ver maskinkoden DRAW.BAC . 11 REM Delar av programmet ur CREATIV COMPUTING 12 REM --------------------------------- 104 C4%=PEEK(65052%)+SWAP%(PEEK(65053%)) : C%=C4%-324% : C1%=C4%-608% : C2%=202% : C3%=210% 106 IF PEEK(8906)<>182% POKE C4%-611%,241% : C2%=C2%-2% : C3%=C3%-2% : REM justering f|r checksumma 108 IF C4%=33390% L%=1000% ELSE L%=400% 145 L9%=L%*2%+1% : REM max linjer*2+1 / bild 150 DIM Z%(2%,L9%-1%) : REM matris h}ller upp till 3 bilder om L% linjer 151 DIM P1%(2%),L(2%),G%(2%),E(2%),K(2%),C(2%) 152 FOR P%=0% TO 2% : P1%(P%)=1% : L(P%)=.001 : G%(P%)=9% : E(P%)=.1 : K(P%)=7% : C(P%)=.4 : NEXT P% 153 P%=0% 156 GOSUB 3040 : REM r{kna ut adr Z(,) 158 REM ****************************** 159 GOTO 1004 : REM * INSTRUKTIONER * 160 ; CHR$(12)'======================================' 161 ; '# B=E+C*EXP(-L*A) #' : ; '# R=1-EXP(-L*A)+-1^(M-1)*B*SIN(K*A) #' 162 ; '======================================' : ; 163 ; 'I'TAB(13%)'Startinstruktionen' : ; 164 ; 'P ('P1%(P%)')'TAB(13%)'< 0/1 > 1=> |verlappning' 165 ; 'L ('L(P%)')';TAB(13%)'<0.001-0.002>spiralt{thet' 166 ; 'G ('G%(P%)')';TAB(13%)'<18-90> -----vinkel|kning' 167 ; 'E ('E(P%)')';TAB(13%)'<0-0.4> ---sinus-amplitud' 170 ; 'K ('K(P%)')';TAB(13%)'< 5-20> ---sinus-frekvens' 172 ; 'C ('C(P%)')';TAB(13%)'<0-0.4> d{mpning amplitud' : ; 174 ; 'B ('P%')';TAB(13%)'< 0,1,2 > byt bildnummer' 175 ; '@'TAB(13%)'Dumpa bild'P%' p} FIL:' 177 ; '^'TAB(13%)'Dumpa bild'P%' p} PR:' 178 ; 'Z'TAB(13%)'Rita bild'P%' direkt' 179 ; 'X'TAB(13%)'Ber{kna v{rden i bild'P% 180 REM ----------------------------- 190 ; CUR(22%,0%)TAB(38%)CUR(22%,12%)'V[LJ (I-X) !'; : GET V$ 195 ON INSTR(1%,'IPLGEKCB^@ZX',V$)+1% GOTO 250,1004,201,202,203,204,205,206,207,213,4000,632,302 201 GOSUB 220 : P1%(P%)=(V1 AND 1%) : GOTO 160 202 GOSUB 220 : L(P%)=V1 : GOTO 160 203 GOSUB 220 : G%(P%)=V1 : GOTO 160 204 GOSUB 220 : E(P%)=V1 : GOTO 160 205 GOSUB 220 : K(P%)=V1 : GOTO 160 206 GOSUB 220 : C(P%)=V1 : GOTO 160 207 GOSUB 220 : IF V1>-1% AND V1<3% P%=V1 : GOTO 160 ELSE 190 213 F%=1% : GOTO 632 : REM dump PR 220 ONERRORGOTO 220 : ; CUR(22%,0%)TAB(38%)CUR(22%,18%)V$+'='; : INPUT V1 : RETURN 250 ; CUR(22%,0%)'  Stora boks{ver! N}gon av I till X 'CHR$(7%); 260 FOR I=0 TO 3000 : NEXT I : GOTO 190 300 REM ========= K\R ================ 302 ; : GOSUB 530 : REM SKALNING 304 Q%=0% : M%=0% : Z%(P%,0%)=0% 306 K=K(P%) : REM *PI/180% 307 GOSUB 582 308 FOR A%=G%(P%) TO 1800% STEP G%(P%) : A1=A%*PI/180% 309 IF Z%(P%,0%)=L% 632 310 B=E(P%)+C(P%)*EXP(-L(P%)*A%) 312 R=1-EXP(-L(P%)*A%)+(-1)^M%*B*SIN(K*A1) 314 X=R*COS(A1) : Y=R*SIN(A1) 318 GOSUB 590 322 NEXT A% : ; CHR$(7); 324 REM ------------------------------- 326 Q%=Q%+1% 330 IF P1%(P%)=0% 632 : REM rita bild 340 IF Q%=2% 632 : REM rita bild 350 M%=1% 360 GOTO 308 530 REM ------ SUBR SKALNING ---------- 535 K9%=72% : R9%=72% : Z1=-1% : Z9=-Z1 540 X3=K9%/(Z9-Z1)+2% : REM skalfaktor kol 550 Y3=R9%/(Z9-Z1) : REM skalfaktor rad 555 RETURN 560 REM ------- LAGRA X/Y ------------- 582 X1%=(X-Z1)*X3 : Y1%=(Y-Z1)*Y3 583 ; X1%;Y1%;' ;'; : RETURN 590 X2%=(X-Z1)*X3 : Y2%=(Y-Z1)*Y3 : ; X2%;Y2%;' ;'; 594 GOSUB 2010 : X1%=X2% : Y1%=Y2% : RETURN 630 REM *************************** 632 ; CHR$(12%) : FOR J%=0% TO 23% : ; CUR(J%,0%)CHR$(151%); : NEXT J% 635 GOSUB 3110 : REM [1% 637 Z=CALL(C%,[1%) : ; CHR$(7%); 638 IF F% GOSUB 64000 : F%=0% : GOTO 160 640 ; CUR(23%,38%); : GET G$ : GOTO 160 1000 REM ------------------------------ 1002 REM - Instruktioner - 1003 REM ------------------------------ 1004 ; CHR$(12%)' # I N S T R U K T I O N E R #' : ; ' 'STRING$(29%,61%)CHR$(10%) 1006 ; 'OBS! Programmet kr{ver att maskinkoden' : ; ' fr}n DRAW.BAC finns i minnet.' : ; 1008 ; 'Detta pgm DRAWSPIR skapar de mest spi-' : ; 'raliska grafiska konstverk,genom att' 1010 ; 'man {ndrar variabler i komplicerade' : ; 'geometriska formler.' 1012 ; : ; 'Menyn visar nuv{rden inom ( ) och rek.' : ; 'gr{nsv{rden inom < > . Prova dig fram' 1014 ; '{ndra P-C bara lite innan resultatet' : ; 'kollas med X.Byt bildnr {ndra ochtryck X' 1016 ; 'Z ritar aktuell bild blixtsnabbt(om man' : ; 'f|rst har ber{knat den med X).' : ; 1017 ; ' OBS! X-tangenten exekverar !!!' : ; ' ==============================' 1018 ; '(vid error g|r RUN och forts{tt!)' 1019 ; 'K\R H]RT! inget kan ju g} s|nder.' : ; CUR(23%,29%)'RETURN'; : GET G$ 1100 GOTO 160 2000 REM ------------------------------ 2002 REM - Tar linjerna fr}n X1;Y1 - 2003 REM - till X2;Y2 och l{gger dem - 2004 REM - till bild P% - 2005 REM ------------------------------ 2010 IF X2%<2% X2%=2% 2011 IF Y2%<0% Y2%=0% 2015 Z%(P%,Z%(P%,0%)*2%+1%)=X2%+Y2%*256% 2020 Z%(P%,Z%(P%,0%)*2%+2%)=X1%+Y1%*256% 2030 Z%(P%,0%)=Z%(P%,0%)+1% 2040 RETURN 3000 REM ------------------------------ 3010 REM - S\K ADR TILL V[RDET P] - 3020 REM - Z%(P%,0%) - 3030 REM ------------------------------ 3040 [%=65063% : REM VARIABELROTEN 3050 [%=PEEK([%+2%)+SWAP%(PEEK([%+3%)) 3060 IF [%=0% THEN ; : ; 'DIDNOT FIND Z' : STOP 3080 IF PEEK([%)<>249% 3050 3090 IF PEEK([%+1%)<>90% 3050 3100 [%=PEEK([%+4%)+SWAP%(PEEK([%+5%)) : RETURN 3110 [1%=[%+2%*L9%*P% : RETURN 4000 REM ------------------------------ 4010 REM -Subroutin that dumps picture- 4020 REM -P% Z%( , ) on datafile - 4030 REM ------------------------------ 4040 D1$=':DRAWSPIR.' : GOSUB 4300 : ; 'Ange CAS,DR0 eller DR1'; : INPUT G$ : D1$=G$+D1$ 4050 GOSUB 4300 : ; 'Bilden sparas som 'D1$'??'; : INPUT G$ : D1$=D1$+G$ 4150 PREPARE D1$ ASFILE 1% 4160 ; #1%,Z%(P%,0%) 4170 FOR I%=0% TO Z%(P%,0%)-1% 4180 ; #1%,Z%(P%,I%*2%+1%) 4190 ; #1%,Z%(P%,I%*2%+2%) 4200 NEXT I% : CLOSE 1% : GOSUB 4300 : ; CUR(22,2%)'Bilden sparad som "'D1$'"' 4210 FOR I%=0% TO 2000% : NEXT I% : GOTO 161 4300 ; CUR(22%,0%)TAB(38%)CUR(22%,0%); : RETURN 64000 REM ============================= 64010 REM Subroutin that dumps even 64020 REM mixed grafs and ASCII to PR 64030 REM ============================= 64040 OPEN "PR:" ASFILE 1% 64050 FOR I%=884% TO 930% STEP 2% 64060 Q%=PEEK(I%)+SWAP%(PEEK(I%+1%)) 64070 S1%=0% 64080 FOR J%=0% TO 39% 64090 W%=PEEK(Q%+J%) 64100 IF W%=23% THEN S1%=1% : W%=32% 64110 IF W%=7% THEN S1%=0% : W%=32% 64120 IF S1%=0% THEN S2%=0% : GOTO 64150 64130 IF W%>63% THEN S2%=0% ELSE S2%=32% 64140 IF W%<64% OR W%>95% THEN S2%=S2%+128% 64150 ; #1%CHR$(W%+S2%); 64160 NEXT J% : ; #1% 64180 NEXT I% : CLOSE 1% 64200 RETURN