10      REM
20      REM HIRES80 SINEWAVES
30      REM
40      REM BY JIM SATHER --- 6/21/84
50      REM

70      REM
80      REM FOR EMULATOR : DEADC0DE.ORG/apple2
90      REM

110     REM
120     REM INITIALIZE
130     REM
140     STR80 = -16383 : COL80 = -16371 : NOMIX = -16302 : MBD = -16300
150     AUX = -16299 : FRCTXT = -16290 : HCLEER = 768

170     HGR : POKE STR80,0 : POKE NOMIX,0 : POKE COL80,0
180     POKE FRCTXT,0 : HCOLOR=3
190     REM MOVE "LDA #$20, JMP $F3EA" TO HCLEER
200     POKE HCLEER,169 : POKE HCLEER+1,32 : POKE HCLEER+2,76
210     POKE HCLEER+3,234 : POKE HCLEER+4,243
220     POKE AUX,0 : CALL HCLEER : REM CLEAR AUX
230     HPLOT 140,0 TO 140,26 : HPLOT 140,167 TO 140,191 : REM DRAW VERT LINE
240     POKE MBD,0 : HPLOT 139,0 TO 139,26 : HPLOT 139,167 TO 139,191

260     REM
270     REM GENERATE 140 X 192 SINEWAVES
280     REM
290     FOR C = 1 TO 15 : CLR = C : GOSUB 600 : REM FOR COLOR = 1 TO 15; GET BINARY
300         FOR H0 = 0 TO 276 STEP 4 : REM LEFT SCREEN; 1 OF 4 POINTS
310             FOR HPART = 0 TO 2 : REM PLOT V FOR H, H+1.3, H+2.7 TO SMOOTH OUT
320                 V=24.5 + C*9 - 32 * SIN((H0 + 1.333333 * HPART) * .0224399)
330                 IF C(1) THEN H = H0   : GOSUB 500 : REM BLUE DOT
340                 IF C(2) THEN H = H0+1 : GOSUB 500 : REM BLUE-GREEN DOT
350                 IF C(3) THEN H = H0+2 : GOSUB 500 : REM BROWN DOT
360                 IF C(0) THEN H = H0+3 : GOSUB 500 : REM MAGENTA DOT
370                 NEXT HPART : NEXT H0

380         REM
390         REM GENERATE 560X192 SINEWAVES
400         REM
410         REM SIN(2*PI*H/280) ; RIGHT SIDE
420         FOR H0 = 280 TO 556 : V = 24.5 + C*9 - 32*SIN(H0 * .0224399)
430             PRT4% = (H0/4 - INT(H0/4)) * 4 + .5 : REM PRT4% = H0 MOD 4
440             IF PRT4%=0 AND C(1) OR PRT4%=1 AND C(2) OR PRT4%=2 AND C(3) OR PRT4%=3 AND C(0) THEN H = H0   : GOSUB 500 : REM PLOT POSITION+0
450             IF PRT4%=0 AND C(2) OR PRT4%=1 AND C(3) OR PRT4%=2 AND C(0) OR PRT4%=3 AND C(1) THEN H = H0+1 : GOSUB 500 : REM PLOT POSITION+0
460             IF PRT4%=0 AND C(3) OR PRT4%=1 AND C(0) OR PRT4%=2 AND C(1) OR PRT4%=3 AND C(2) THEN H = H0+2 : GOSUB 500 : REM PLOT POSITION+0
470             IF PRT4%=0 AND C(0) OR PRT4%=1 AND C(1) OR PRT4%=2 AND C(2) OR PRT4%=3 AND C(3) THEN H = H0+3 : GOSUB 500 : REM PLOT POSITION+0
480             NEXT H0 : NEXT C : END

500     REM
510     REM PLOT H,V  (H=0-559, V=0-191)
520     REM
530     MOD14 = INT(H)/14 : MOD14% = MOD14
540     PART14% = 14 * (MOD14 - MOD14%) + .5
550     POKE AUX,0 : IF PART14% > 6 THEN POKE MBD,0 : PART14% = PART14% - 7
560     HPLOT MOD14% * 7 + PART14%,V
570     RETURN

590     REM
600     REM CONVERT CLR FROM DECIMAL TO HEX
610     REM
620     CLR% = CLR : FOR A = 0 TO 3
630         C(A) = 1 : CLR = CLR% / 2 : CLR% = CLR% /2
640         IF CLR=CLR% THEN C(A) = 0
650         NEXT : RETURN

