start tok64 d64-ECr2MU 0 REM"{delete*7} p.j.ponzo*83*waterloo/ontario 1 REM"{delete*6} 1000 GOSUB60000:PRINTCHR$(142):PRINT"{clear}{space*15}{reverse on}{blue}sprites-1" 1001 PRINT"{red}{cm a}{sh asterisk*37}{cm s}" 1002 PRINT"{sh -} {reverse on}{blue}{space*10}sprites and stuff{space*8}{red}{reverse off} {sh -}":ms$="ponzotutor" 1003 PRINT"{red}{cm z}{sh asterisk*37}{cm x}{black}":GOSUB63100:ms$=" welcome!" 1004 GOSUB63100:FORi=0TO62:READ x:POKE832+i,x:NEXT:v=53248:POKE2040,13:POKEv+21,1 1005 POKEv+39,1:POKEv+1,100:a$="{home}{down*7}{space*35}" 1006 b$="this is a sprite" 1007 POKEv+39,1:POKEv+1,100:FORx=0TO255STEP8:POKEv,x:PRINTLEFT$(a$,8+x1); 1008 PRINTRIGHT$(b$,31-x2):x2=x2-(x2<32):x1=x1+1:FORt=1TO10:NEXT:NEXT 1009 GOSUB63000:FORi=0TO15:POKEv+39,i:FORt=1TO150:NEXT:NEXT:POKEv+21,0 1010 ms$=" yum yum":GOSUB63100:PRINT"{clear}{down}it is easy to have up to 8 'sprites'" 1020 PRINT"{down}on the screen at one time." 1030 PRINT"{down}let's label the sprites 0,1,..7." 1040 PRINT"{down}pick a number n (0 to 7) and" 1050 PRINT"{down}a block of memory to hold the" 1060 PRINT"{down}information on the 'shape' of" 1065 PRINT"{down}sprite #n." 1070 ms$="nice shape":GOSUB63100:GOSUB63000 1080 PRINT"{clear}now a sprite is made up of an array" 1090 PRINT"{down}of 'pixels' or 'dots' on the screen." 1100 PRINT"{down}24 dots wide and 21 dots tall." 1110 PRINT"{down}(24*21=504 dots in total)." 1120 PRINT"{down}each dot is either 'on' or 'off'" 1125 PRINT"{down}and we can indicate this with" 1130 PRINT"{down}a '1' or '0' (1={reverse on}on{reverse off} & 0={reverse on}off{reverse off})" 1140 PRINT"{down}the 'shape' info can then be" 1150 PRINT"{down} stored as 504 binary digits" 1155 PRINT"{down}(bits),either '1' or '0'." 1160 PRINT"{down}since we store numbers in bytes" 1170 PRINT"{down}{reverse on}it will take 504/8=63 bytes!" 1180 GOSUB63000 1200 PRINT"{clear}we will reserve {reverse on}63{reverse off} bytes of memory" 1210 PRINT"{down}(let's call them 'blocks')" 1220 PRINT"{down}for each sprite 'shape'." 1230 PRINT"{down}you tell me the 'block' number" 1240 PRINT"{down}and i'll know where to look" 1250 PRINT"{down}for the sprite shape!" 1260 PRINT"{down}in fact if you say {reverse on}block 90{reverse off}" 1270 PRINT"{down}i'll go to memory location" 1280 PRINT"{down}64*90=5760 to get the first of" 1290 PRINT"{down}the 63 bytes!":ms$="63 bites?!":GOSUB63100:GOSUB63000 1300 PRINT"{clear}ok..you pick an {reverse on}n{reverse off} (the sprite #)" 1310 PRINT"{down}and a {reverse on}b{reverse off} (the block number)." 1320 PRINT"{down}hint{down}{left*4}{cm u*4}{up}:b=11,13,14 & 15" 1330 PRINT"{down}are very nice blocks 'cause" 1340 PRINT"{down}the 63 bytes of memory starting" 1350 PRINT"{down}at 64*11={reverse on}704{reverse off},64*13={reverse on}832{reverse off},64*14={reverse on}896" 1360 PRINT"{down}and 64*15={reverse on}960{reverse off} are available!" 1370 PRINT"{down}(..let's say 'reserved' for sprites)." 1380 PRINT"{down}then you must {reverse on}poke{reverse off} the {reverse on}1{reverse off}'s" 1390 PRINT"{down}and {reverse on}0{reverse off}'s into the block." 1395 PRINT"{down}{reverse on}100 fori=0to62:read x:poke64*b+i,x:next":GOSUB63000 1400 PRINT"{clear}let's say that again:" 1410 PRINT"{down}{reverse on}100 fori=0to62:read x:poke64*b+i,x:next" 1420 PRINT"{down}now you tell the c64 where" 1430 PRINT"{down}the sprite shape is stored." 1440 PRINT"{down}for sprite {reverse on}n{reverse off}, you must:" 1450 PRINT"{down}{reverse on}110 poke 2040+n,b{reverse off}:rem b=block #" 1460 PRINT"{down}now to have sprite #n displayed" 1470 PRINT"{down}on the screen you must {reverse on}enable" 1480 PRINT"{down}this sprite.":ms$="{space*2}{reverse on}2040+n{reverse off}":GOSUB63100:GOSUB63000 1485 PRINT"{clear}you'll also want to put it at" 1486 PRINT"{down}the right place on the screen," 1487 PRINT"{down}give it a nice colour, move it" 1488 PRINT"{down}around, make it bigger or smaller" 1489 PRINT"{down}and other clever things." 1490 PRINT"{down}all this information must go to" 1495 PRINT"{down}the {reverse on}video chip{reverse off}!":ms$="nice chip!":GOSUB63100:GOSUB63000 1500 PRINT"{clear}{reverse on}the video chip" 1501 PRINT"{down}this sexy chip has 47 internal" 1502 PRINT"{down}memory locations or {reverse on}registers{reverse off}." 1505 PRINT"{down}they start at {reverse on}$d{0*3}{reverse off} in hexadecimal" 1510 PRINT"{down}(nice) and {reverse on}53248{reverse off} in decimal" 1520 PRINT"{down}(not so nice). anyway let:" 1530 PRINT"{down}{reverse on}120 v=53248:rem video chip base" 1540 PRINT"{down}to 'turn on' sprite #n:" 1550 PRINT"{down}{reverse on}130 poke v+21,2^n" 1560 PRINT"{down}yes{.*4}that's 2^n." 1561 ms$="turn me on":GOSUB63100:GOSUB63000 1565 PRINT"{clear}you see, the register at v+21" 1570 PRINT"{down}which 'enables' sprites has 8 bits." 1571 PRINT"{down}we label the bits 0,1,{.*3}7" 1572 PRINT"{down}(sound familiar?)" 1575 PRINT"{down}each bit corresponds to a sprite." 1576 PRINT"{down}to 'see' sprite #5, turn on the" 1577 PRINT"{down}bit #5!" 1578 PRINT"{down}how? just {reverse on}poke v+21,32{reverse off}" 1580 PRINT"{down}note{down}{left*4}{cm u*4}{up}:{space*14}2^5=32" 1581 ms$=" 001{0*5}":GOSUB63100:GOSUB63000 1590 PRINT"{clear}for our 'sprite #n' we will:" 1595 PRINT"{down}{reverse on}130 pokev+21,2^n" 1596 PRINT"{down}(you won't be surprised to see" 1600 PRINT"{down}that any other sprites will" 1610 PRINT"{down}disappear!)" 1620 PRINT"{down}if you want sprite #0 {reverse on}and{reverse off} sprite #3" 1630 PRINT"{down}{reverse on}and{reverse off} sprite #7 {reverse on}all{reverse off} 'enabled' or 'visible'" 1640 PRINT"{down}then {reverse on}pokev+21,1+8+128{reverse off}" 1650 PRINT"{down}note:2^0+2^3+2^7=1+8+128 (nice)!" 1660 PRINT"{down}you want all 8 sprites? 1670 PRINT"{down}{reverse on}pokev+21,255":ms$=" 1{0*3}1001":GOSUB63100:GOSUB63000 1700 PRINT"{clear}so far we have:" 1710 PRINT"{down}{reverse on}100 fori=0to62:read x:poke64*b+i,x:next" 1720 PRINT"{reverse on}110 poke2040+n,b:rem where shape is{space*4}" 1730 PRINT"{reverse on}120 v=53248:{space*5}rem video chip base{space*3}" 1740 PRINT"{reverse on}130 pokev+21,2^n:rem enable sprite{space*5}" 1750 PRINT"{down}..and sprite #n is on the screen!" 1760 PRINT"{down}but where and what colour?!*+!" 1770 PRINT"{down}there are 16 colours to choose from." 1780 PRINT"{down}we label them 0,1,2,{.*3}15." 1790 PRINT"{down}to make sprite #n colour #10" 1800 PRINT"{down}(a light red) we poke another" 1810 PRINT"{down}magic register in the video chip."" 1820 PRINT"{down}{reverse on}pokev+39+n,10{reverse off}:sprite #n is red!":GOSUB63000 1830 PRINT"{clear}maybe we should have picked a" 1840 PRINT"{down}colour {reverse on}before{reverse off} we made the sprite" 1845 PRINT"{down}visible! the last thing we want" 1847 PRINT"{down}to do is to display our sprite" 1848 PRINT"{down}before it's presentable!" 1850 PRINT"{down}anyway, we'll fix that up later.":ms$=" patience":GOSUB63100 1855 GOSUB63000 1860 PRINT"{clear}how about the position on the" 1870 PRINT"{down}screen? well the c64 has 40 columns" 1880 PRINT"{down}or 'print positions'. each is" 1890 PRINT"{down}8 'dots' wide. that makes 40*8=320" " 1891 PRINT"{down}dots horizontally and we should" 1900 PRINT"{down}be able to 'position' our sprite #n" 1910 PRINT"{down}in any of 320 x-positions." 1920 PRINT"{down}also, the c64 has{space*2}25 rows, each " 1930 PRINT"{down}8 dots high and 25*8=200 so there" 1950 PRINT"{down}will be 200 possible y-positions" 1960 PRINT"{down}for our sprite.":GOSUB63000 1970 PRINT"{clear}where do we put this x-position &" 1980 PRINT"{down}y-position information?" 1990 PRINT"{down}into another {reverse on}v+something{reverse off} register." 2000 PRINT"{down}this time we:" 2010 PRINT"{down}{reverse on}poke v+2*n,x:poke v+2*n+1,y" 2020 PRINT"{down}as long as 'x' and 'y' are both" 2025 PRINT"{down}less than 256 we're in good shape!" 2040 PRINT"{down}in fact we could:" 2050 PRINT"{down}{reverse on}for t=0 to 500{space*13}" 2060 PRINT"{reverse on}x=t/2:y=t/3{space*16}" 2066 PRINT"{reverse on}poke v+2*n,x:poke v+2*n+1,y" 2070 PRINT"{reverse on}next t{space*21}":GOSUB63000 2080 PRINT"{clear}how about something cute like:" 2090 PRINT"{down}{reverse on}for t=0 to 500{space*13}" 2100 PRINT"{reverse on}x=fnx(t):y=fny(t){space*10}" 2110 PRINT"{reverse on}poke v+2*n,x:poke v+2*n+1,y" 2120 PRINT"{reverse on}next t{space*21}" 2130 PRINT"{down}then our sprite would follow" 2140 PRINT"{down}a curve given by some functions" 2150 PRINT"{down}fnx and fny, previously {reverse on}def{reverse off}ined." 2155 ms$="def fnx(t)":GOSUB63100:GOSUB63000 2160 PRINT"{clear}if you'd like to have the sprite" 2170 PRINT"{down}at the right on the screen, in" 2180 PRINT"{down}pixel positions 256 to 320," 2190 PRINT"{down}then we have to do the following:" 2210 PRINT"{down*3}{reverse on}tell it to the video chip!":ms$="nice chap!":GOSUB63100 2215 GOSUB63000 2220 PRINT"{clear}yet another register, at v+16, has" 2230 PRINT"{down}8 bits, one for each of 8 sprites," 2240 PRINT"{down}and for sprite #n we will" 2250 PRINT"{down}{reverse on}poke v+16,2^n" 2260 PRINT"{down}this turns on 'bit #n' so that" 2270 PRINT"{down}sprite #n will be able to move thru'" 2280 PRINT"{down}x-positions 256 to 320!":ms$=" 256-320!":GOSUB63100:GOSUB63000 2290 PRINT"{clear}{reverse on}note{reverse off}:poke v+16,32 will affect the" 2300 PRINT"{down}x-position of sprite #5 by {reverse on}adding 256" 2310 PRINT"{down}to the value of x {reverse on}poke{reverse off}d into v+2*5" 2320 PRINT"{down}{reverse on}poke v+2*5,50:rem x-pos'n is 50" 2330 PRINT"{down}{reverse on}poke v+16,32:rem add 256" 2340 PRINT"{down}this puts sprite #5 in x-pos'n 306" 2341 ms$="{space*3}{reverse on}v+16{reverse off}":GOSUB63100:GOSUB63000 2345 PRINT"{clear}if you want sprite #0 {reverse on}and{reverse off} sprite #3" 2350 PRINT"{down}{reverse on}and{reverse off} sprite #7 {reverse on}all{reverse off} 'at the right'" 2360 PRINT"{down}then pick an x0,x3 & x7:" 2370 PRINT"{down}{reverse on}poke v+2*0,x0:rem x-pos'n of #0" 2380 PRINT"{down}{reverse on}poke v+2*3,x3:rem x-pos'n of #3" 2390 PRINT"{down}{reverse on}poke v+2*7,x7:rem x-pos'n of #7" 2400 PRINT"{down}{reverse on}poke v+16,1+8+128:add 256 to all!" 2405 ms$="{space*3}{reverse on}v+2*n{reverse off}":GOSUB63100:GOSUB63000:PRINT"{clear}choose block 13 & sprite 3" 2406 PRINT"and make all 'shape' bytes={reverse on}240{reverse off}" 2407 PRINT"{down}{reverse on} 99 b=13:n=3{space*27}" 2410 PRINT"{reverse on}100 fori=0to62:x=240:poke64*b+i,x:next " 2420 PRINT"{reverse on}110 poke2040+3,b:{space*2}rem where shape is{space*2}" 2430 PRINT"{reverse on}120 v=53248:{space*7}rem video chip base " 2440 PRINT"{reverse on}130 poke v+39+n,10:rem red sprite{space*6}" 2450 PRINT"{reverse on}140 pokev+21,2^n:{space*2}rem enable sprite{space*3}" 2460 PRINT"{reverse on}150 for t=0 to 500 step 5{space*14}" 2470 PRINT"{reverse on}160 x=t/2:y=180+t/5{space*20}" 2475 PRINT"{reverse on}170 poke v+2*n,x:poke v+2*n+1,y{space*8}" 2480 PRINT"{reverse on}180 next t{space*29}":GOSUB4000 2485 ms$="{reverse on} yum {!*3}{space*2}{reverse off}":GOSUB63100 2490 PRINT"{up*6}that's for one sprite..n=3":POKEv+21,0 2500 PRINT"{down}let's have 3 sprites..#0, #3 and #7.":GOSUB63000 2510 PRINT"{clear}{reverse on}100 fori=0to62:read x:poke64*b+i,x:next":GOSUB2600 2520 PRINT"{home}{down}{reverse on}110 poke2040+0,b:{space*2}rem #0'shape block' ":GOSUB2610 2521 PRINT"{home}{down*2}{reverse on}{1*3} poke2040+3,b:{space*2}rem #3'shape block' ":GOSUB2620 2522 PRINT"{home}{down*3}{reverse on}112 poke2040+7,b:{space*2}rem #7'shape block' ":GOSUB2630 2530 PRINT"{home}{down*4}{reverse on}120 v=53248:{space*7}rem video chip base ":GOSUB2640 2540 PRINT"{home}{down*5}{reverse on}130 poke v+39+0,10:rem #0 is red{space*7}":GOSUB2650 2541 PRINT"{home}{down*6}{reverse on}131 poke v+39+3,12:rem #3 is white{space*5}":GOSUB2660 2542 PRINT"{home}{down*7}{reverse on}132 poke v+39+7,14:rem #7 is blue{space*6}":GOSUB2670 2550 PRINT"{home}{down*8}{reverse on}140 pokev+21,1+8+128:rem enable sprites":GOSUB2680 2560 PRINT"{home}{down*9}{reverse on}150 for t=0 to 500: tt=t/50{space*12}":GOSUB2690 2565 PRINT"{home}{down*10}{reverse on}160 x0=t/2:y0=t/3{space*22}":GOSUB2700 2566 PRINT"{home}{down*11}{reverse on}161 x3=250-t/2:y3=200-t/3{space*14}":GOSUB2710 2567 PRINT"{home}{down*12}{reverse on}162 x7=150+100*sin(tt):y7=100+50*cos(tt)":GOSUB2720 2570 PRINT"{home}{down*13}{reverse on}170 poke v+2*0,x0:poke v+2*0+1,y0{space*6}":GOSUB2730 2575 PRINT"{home}{down*14}{reverse on}171 poke v+2*3,x3:poke v+2*3+1,y3{space*6}":GOSUB2740 2576 PRINT"{home}{down*15}{reverse on}172 poke v+2*7,x7:poke v+2*7+1,y7{space*6}":GOSUB2750 2580 PRINT"{home}{down*16}{reverse on}180 next t{space*29}" 2590 GOSUB2760:GOSUB12500:ms$=" whee!!":GOSUB63100:GOSUB63000:GOTO2800 2600 PRINT"put data into block 'b'":GOSUB63000:RETURN 2610 PRINT"tell where #0 shape is ":GOSUB63000:RETURN 2620 PRINT"tell where #3 shape is ":GOSUB63000:RETURN 2630 PRINT"tell where #7 shape is ":GOSUB63000:RETURN 2640 PRINT"remember this number{!*3}":GOSUB63000:RETURN 2650 PRINT"poke v+39+n & n=0..ok? ":GOSUB63000:RETURN 2660 PRINT"poke v+39+n & n=3..ok! ":GOSUB63000:RETURN 2670 PRINT"{.*5}what else?{.*7} ":GOSUB63000:RETURN 2680 PRINT"turn them all on{!*7}":GOSUB63000:RETURN 2690 PRINT"now,for 500 steps or so":GOSUB63000:RETURN 2700 PRINT"define x- and y-pos'ns.":GOSUB63000:RETURN 2710 PRINT"for #3 too{space*13}":GOSUB63000:RETURN 2720 PRINT"and #7{.*3}!?*{space*11}":GOSUB63000:RETURN 2730 PRINT"move sprite #0{space*9}":GOSUB63000:RETURN 2740 PRINT"move sprite #3{space*9}":GOSUB63000:RETURN 2750 PRINT"move sprite #7{space*9}":GOSUB63000:RETURN 2760 PRINT"on to next t.{space*10}":GOSUB63000:RETURN 2800 PRINT"{clear}{black}of course we could have the sprites" 2810 PRINT"{down}each a different shape." 2820 PRINT"{down}we could:" 2830 PRINT"{down}{reverse on}fori=0to62:read x:poke64*b0+i,x:next" 2840 PRINT"{down}{reverse on}fori=0to62:read x:poke64*b3+i,x:next" 2850 PRINT"{down}{reverse on}fori=0to62:read x:poke64*b7+i,x:next" 2860 PRINT"{down}and have b0, b3 and b7 all different" 2870 PRINT"{down}then we'd tell the c64 where they are:" 2880 PRINT"{down}{reverse on}poke2040+0,b0" 2881 PRINT"{reverse on}poke2040+3,b3" 2882 PRINT"{reverse on}poke2040+7,b7" 2885 ms$="{space*2}{reverse on}2040+n{reverse off}":GOSUB63100 2890 GOSUB63000 2900 PRINT"{clear}let's play with the sprite created with:{down}" 2910 PRINT"{reverse on} 99 b=13:n=3{space*27}" 2920 PRINT"{reverse on}100 fori=0to62:x=240:poke64*b+i,x:next " 2930 PRINT"{reverse on}110 etc. etc. etc.{space*21}" 2940 n=3:b=13:t0=500:t1=500:GOSUB4100 2950 GOSUB63000 2955 PRINT"{home}{down*14}to change it's size" 2956 PRINT"{down}we poke another {reverse on}v+something{reverse off} register!":GOSUB63000 2960 PRINT"{clear}we'll expand the x-dimension:" 2970 PRINT"{reverse on}{space*4}poke v+29,2^n{space*22}":GOSUB63000:POKEv+29,2^n 2980 PRINT"{home}{down*2}we'll expand the y-dimension:" 2990 PRINT"{reverse on}{space*4}poke v+23,2^n{space*22}":GOSUB63000:POKEv+23,2^n 3000 PRINT"{home}{down*4}we'll shrink the x-dimension:" 3010 PRINT"{reverse on}{space*4}poke v+29,0{space*24}":GOSUB63000:POKEv+29,0 3020 PRINT"{home}{down*6}we'll shrink the y-dimension:" 3030 PRINT"{reverse on}{space*4}poke v+23,0{space*24}":GOSUB63000:POKEv+23,0 3040 GOSUB63000:POKEv+21,0 3050 PRINT"{clear}what about this {reverse on}read x:poke 832+i,x{reverse off}?" 3060 PRINT"{down}read what?" 3070 PRINT"{down}a sprite, remember, is 24 pixels wide." 3080 PRINT"{down}that's {reverse on}3{reverse off} bytes which then give the" 3090 PRINT"{down}{reverse on}first{reverse off} of 21 rows of pixel information." 3100 PRINT"{down}if the 3 bytes were 255,85 and 8" 3200 PRINT"{down}which,in binary look like a string" 3210 PRINT"{down}of 1's and 0's, namely:" 3220 PRINT"{down}{1*8} & 01010101 & {0*4}1{0*3}" 3225 PRINT"{down}or, side by side:" 3226 PRINT"{down}{1*8}01010101{0*4}1{0*3}" 3227 GOSUB63000 3228 PRINT"{clear}{1*8}01010101{0*4}1{0*3}" 3230 PRINT"{down}then the first row of pixels would be:" 3240 PRINT"{down}{Q*8} Q Q Q Q{space*4}Q{space*3}" 3250 GOSUB63000 3260 PRINT"{home}{down*6}see!":GOSUB63000 3270 PRINT"{home}{down*8}{1*8}01010101{0*4}1{0*3}" 3275 PRINT"{^*8} ^ ^ ^ ^{space*4}^{space*3}" 3280 PRINT"{Q*8} Q Q Q Q{space*4}Q{space*3}":GOSUB63000 3290 PRINT"{home}{down*12}if the next 3 bytes in the" 3300 PRINT"block of memory which has the 'shape'" 3310 PRINT"were 170,0,170 then:":GOSUB63000 3320 PRINT"{home}{down*16}1010101{0*9}10101010" 3330 PRINT"Q Q Q Q{space*9}Q Q Q Q " 3335 PRINT"{down}<{sh asterisk}170{sh asterisk*2}><{sh asterisk*2}0{sh asterisk*3}><{sh asterisk}170{sh asterisk*2}>":GOSUB63000 3340 PRINT"{clear}{down}let's make a {reverse on}pacman{reverse off}:":GOSUB63000:PRINT"{clear}":GOSUB7000:GOSUB6900 3350 GOSUB63000:PRINT"{home}{down}{right*27}now{.*3}" 3360 PRINT"{down}{right*27}in binary!":GOSUB63000:t=200 3400 PRINT"{home}{down*2}{space*2}{0*8}{1*8}{0*8} 3401 FORi=1TOt:NEXT 3410 PRINT"{space*2}{0*5}{1*12}{0*7} 3411 FORi=1TOt:NEXT 3420 PRINT"{space*2}{0*4}{1*14}{0*6} 3421 FORi=1TOt:NEXT 3430 PRINT"{space*2}{0*3}{1*16}{0*5} 3431 FORi=1TOt:NEXT 3440 PRINT"{space*2}00{1*6}{0*5}{1*7}{0*4} 3441 FORi=1TOt:NEXT 3450 PRINT"{space*2}0{1*7}{0*5}{1*8}{0*3} 3451 FORi=1TOt:NEXT 3460 PRINT"{space*2}{1*8}0{1*3}0{1*7}{0*4} 3461 FORi=1TOt:NEXT 3470 PRINT"{space*2}{1*8}0{1*3}0{1*6}{0*5} 3471 FORi=1TOt:NEXT 3480 PRINT"{space*2}{1*18}{0*6} 3481 FORi=1TOt:NEXT 3490 PRINT"{space*2}{1*17}{0*7} 3491 FORi=1TOt:NEXT 3500 PRINT"{space*2}{1*16}{0*8} 3501 FORi=1TOt:NEXT 3510 PRINT"{space*2}{1*16}{0*8} 3511 FORi=1TOt:NEXT 3520 PRINT"{space*2}0{1*16}{0*7} 3521 FORi=1TOt:NEXT 3530 PRINT"{space*2}00{1*16}{0*6} 3531 FORi=1TOt:NEXT 3540 PRINT"{space*2}{0*3}{1*16}{0*5} 3541 FORi=1TOt:NEXT 3550 PRINT"{space*2}{0*4}{1*16}{0*4} 3551 FORi=1TOt:NEXT 3560 PRINT"{space*2}{0*5}{1*16}{0*3} 3561 FORi=1TOt:NEXT 3570 PRINT"{space*2}{0*7}{1*15}00 3571 FORi=1TOt:NEXT 3580 PRINT"{space*2}{0*9}{1*12}{0*3} 3581 FORi=1TOt:NEXT 3590 PRINT"{space*2}{0*11}{1*6}{0*7} 3591 FORi=1TOt:NEXT 3600 PRINT"{space*2}{0*12}{1*3}{0*9} 3601 FORi=1TOt:NEXT 3610 GOSUB63000:PRINT"{home}{down}{right*27}pick out" 3620 PRINT"{down}{right*27}the bytes!":GOSUB63000:t=200 3630 PRINT"{home}{down*2}{space*2}<{sh asterisk*3}0{sh asterisk*2}><{sh asterisk}255{sh asterisk*2}><{sh asterisk*3}0{sh asterisk*2}> 3631 FORi=1TOt:NEXT 3640 PRINT"{space*2}<{sh asterisk*3}7{sh asterisk*2}><{sh asterisk}255{sh asterisk*2}><{sh asterisk}128{sh asterisk*2}> 3641 FORi=1TOt:NEXT 3650 PRINT"{space*2}<{sh asterisk*2}15{sh asterisk*2}><{sh asterisk}255{sh asterisk*2}><{sh asterisk}192{sh asterisk*2}> 3651 FORi=1TOt:NEXT 3660 PRINT"{space*2}<{sh asterisk*2}31{sh asterisk*2}><{sh asterisk}255{sh asterisk*2}><{sh asterisk}224{sh asterisk*2}> 3661 FORi=1TOt:NEXT 3670 PRINT"{space*2}<{sh asterisk*2}63{sh asterisk*2}><{sh asterisk*3}7{sh asterisk*2}><{sh asterisk}240{sh asterisk*2}> 3671 FORi=1TOt:NEXT 3680 PRINT"{space*2}<{sh asterisk}127{sh asterisk*2}><{sh asterisk*3}7{sh asterisk*2}><{sh asterisk}248{sh asterisk*2}> 3681 FORi=1TOt:NEXT 3690 PRINT"{space*2}<{sh asterisk}255{sh asterisk*2}><{sh asterisk}119{sh asterisk*2}><{sh asterisk}240{sh asterisk*2}> 3691 FORi=1TOt:NEXT 3700 PRINT"{space*2}<{sh asterisk}255{sh asterisk*2}><{sh asterisk}119{sh asterisk*2}><{sh asterisk}224{sh asterisk*2}> 3701 FORi=1TOt:NEXT 3710 PRINT"{space*2}<{sh asterisk}255{sh asterisk*2}><{sh asterisk}255{sh asterisk*2}><{sh asterisk}192{sh asterisk*2}> 3711 FORi=1TOt:NEXT 3720 PRINT"{space*2}<{sh asterisk}255{sh asterisk*2}><{sh asterisk}255{sh asterisk*2}><{sh asterisk}128{sh asterisk*2}> 3721 FORi=1TOt:NEXT 3730 PRINT"{space*2}<{sh asterisk}255{sh asterisk*2}><{sh asterisk}255{sh asterisk*2}><{sh asterisk*3}0{sh asterisk*2}> 3731 FORi=1TOt:NEXT 3740 PRINT"{space*2}<{sh asterisk}255{sh asterisk*2}><{sh asterisk}255{sh asterisk*2}><{sh asterisk*3}0{sh asterisk*2}> 3741 FORi=1TOt:NEXT 3750 PRINT"{space*2}<{sh asterisk}127{sh asterisk*2}><{sh asterisk}255{sh asterisk*2}><{sh asterisk}128{sh asterisk*2}> 3751 FORi=1TOt:NEXT 3760 PRINT"{space*2}<{sh asterisk*2}63{sh asterisk*2}><{sh asterisk}255{sh asterisk*2}><{sh asterisk}192{sh asterisk*2}> 3761 FORi=1TOt:NEXT 3770 PRINT"{space*2}<{sh asterisk*2}31{sh asterisk*2}><{sh asterisk}255{sh asterisk*2}><{sh asterisk}224{sh asterisk*2}> 3771 FORi=1TOt:NEXT 3780 PRINT"{space*2}<{sh asterisk*2}15{sh asterisk*2}><{sh asterisk}255{sh asterisk*2}><{sh asterisk}240{sh asterisk*2}> 3781 FORi=1TOt:NEXT 3790 PRINT"{space*2}<{sh asterisk*3}7{sh asterisk*2}><{sh asterisk}255{sh asterisk*2}><{sh asterisk}248{sh asterisk*2}> 3791 FORi=1TOt:NEXT 3800 PRINT"{space*2}<{sh asterisk*3}1{sh asterisk*2}><{sh asterisk}255{sh asterisk*2}><{sh asterisk}252{sh asterisk*2}> 3801 FORi=1TOt:NEXT 3810 PRINT"{space*2}<{sh asterisk*3}0{sh asterisk*2}><{sh asterisk}127{sh asterisk*2}><{sh asterisk}248{sh asterisk*2}> 3811 FORi=1TOt:NEXT 3820 PRINT"{space*2}<{sh asterisk*3}0{sh asterisk*2}><{sh asterisk*2}31{sh asterisk*2}><{sh asterisk}128{sh asterisk*2}> 3821 FORi=1TOt:NEXT 3830 PRINT"{space*2}<{sh asterisk*3}0{sh asterisk*2}><{sh asterisk*2}14{sh asterisk*2}><{sh asterisk*3}0{sh asterisk*2}> 3831 FORi=1TOt:NEXT 3850 GOSUB63000:PRINT"{home}{down}{right*27}now{.*3}{space*2}" 3851 PRINT"{down}{right*27}put these " 3852 PRINT"{down}{right*27}numbers{space*3}" 3853 PRINT"{down}{right*27}into data " 3854 PRINT"{down}{right*27}statements" 3855 PRINT"{down}{right*27}..then..{space*2}" 3856 PRINT"{down}{right*27}{reverse on}{space*2}read{space*3}" 3857 PRINT"{down}{right*27} and{space*6}" 3858 PRINT"{down}{right*27}{reverse on}{space*2}poke{space*3}" 3860 GOSUB63000:PRINT"{clear}" 3865 PRINT"{down*2}100 fori=0to62:read x:poke832+i,x:next " 3870 PRINT"101 data 0,255,0" 3880 PRINT"102 data 7,255,128" 3890 PRINT"103 data 15,255,192 3900 PRINT"{down}{.*3} etc. etc. etc." 3910 PRINT"{down}121 data 0,14,0" 3920 ms$=" simple!":GOSUB63100 3930 GOSUB63000:PRINT"{clear}let's do it:":q$="{reverse on}":GOSUB3931:GOTO10000 3931 PRINT"{down*2}"q$"100 fori=0to62:read x:poke832+i,x:next " 3932 PRINTq$"200 poke2040+3,13: rem where shape is{space*2}":IFgg=1THEN3934 3933 PRINTq$"300 v=53248:{space*7}rem video chip base " 3934 PRINTq$"400 poke v+39+3,10:rem red sprite #3{space*3}" 3935 PRINTq$"500 x=250:y=200:{space*3}rem pick a position " 3936 PRINTq$"600 poke v+2*3,x:poke v+2*3+1,y{space*8}":IFgg=1THENRETURN 3937 PRINTq$"700 pokev+21,2^3:{space*2}rem enable sprite #3":RETURN 3940 DATA0,255,0,7,255,128,15,255,192,31,255,224,63,7,240,127,7,248,255,119,240 3941 DATA255,119,224,255,255,192,255,255,128,255,255,0,255,255,0,127,255,128 3942 DATA63,255,192,31,255,224,15,255,240,7,255,248,1,255,252,0,127,248 3943 DATA0,31,128,0,14,0 4000 REM sprites 4010 b=13:REM block 13 4020 n=3 :REM sprite #0 4030 t0=0:t1=500:GOSUB4100:RETURN 4100 FORi=0TO62:x=240:POKE64*b+i,x:NEXT 4110 POKE2040+n,b: REM where shape is 4120 v=53248: REM video chip base 4130 POKE v+39+n,10:REM red sprite 4135 POKE v+2*n,0:POKE v+2*n+1,0 4136 POKE v+29,0:POKE v+23,0 4140 POKEv+21,2^n: REM enable sprite 4150 FOR t=t0 TO t1 STEP 5 4160 x=t/2:y=100+t/5 4170 POKE v+2*n,x:POKE v+2*n+1,y 4180 NEXT t 4190 RETURN 5000 PRINT"{clear}":ms$="au revoir!":GOSUB63100 5010 PRINT"{home}{down*3}load"CHR$(34)">sprites-2"CHR$(34)",8":PRINT"{down*4}run{home}":END 6900 PRINT"{home}{reverse on}{space*11}{1*10}{2*5} " 6901 PRINT"{reverse on}{space*2}123456789012345678901234 " 6902 PRINT"{reverse on} 1" 6903 PRINT"{reverse on} 2" 6904 PRINT"{reverse on} 3" 6905 PRINT"{reverse on} 4" 6906 PRINT"{reverse on} 5" 6907 PRINT"{reverse on} 6" 6908 PRINT"{reverse on} 7" 6909 PRINT"{reverse on} 8" 6910 PRINT"{reverse on} 9" 6911 PRINT"{reverse on}10" 6912 PRINT"{reverse on}11" 6913 PRINT"{reverse on}12" 6914 PRINT"{reverse on}13" 6915 PRINT"{reverse on}14" 6916 PRINT"{reverse on}15" 6917 PRINT"{reverse on}16" 6918 PRINT"{reverse on}17" 6919 PRINT"{reverse on}18" 6920 PRINT"{reverse on}19" 6921 PRINT"{reverse on}20" 6922 PRINT"{reverse on}21" 6923 RETURN 7000 PRINT"{home}{down*2}{space*9}{Q*8} 7001 PRINT"{space*7}{Q*12} 7002 PRINT"{space*6}{Q*14} 7003 PRINT"{space*5}{Q*16} 7004 PRINT"{space*4}{Q*6}{space*5}{Q*7} 7005 PRINT"{space*3}{Q*7}{space*5}{Q*8} 7006 PRINT"{space*2}{Q*8} {Q*3} {Q*7} 7007 PRINT"{space*2}{Q*8} {Q*3} {Q*6} 7008 PRINT"{space*2}{Q*18} 7009 PRINT"{space*2}{Q*17} 7010 PRINT"{space*2}{Q*16} 7011 PRINT"{space*2}{Q*16} 7012 PRINT"{space*3}{Q*16} 7013 PRINT"{space*4}{Q*16} 7014 PRINT"{space*5}{Q*16} 7015 PRINT"{space*6}{Q*16} 7016 PRINT"{space*7}{Q*16} 7017 PRINT"{space*9}{Q*15} 7018 PRINT"{space*11}{Q*12} 7019 PRINT"{space*13}{Q*8} 7020 PRINT"{space*14}{Q*6} 7021 RETURN 10000 GOSUB63000:PRINT"{clear}better still..let's enable" 10010 PRINT"{down}sprite #3 so we can {reverse on}see{reverse off} it happen!" 10020 PRINT"{down}we'll set {reverse on}v=53248{reverse off}" 10030 PRINT"{down}and we'll {reverse on}poke v+21,2^3" 10040 PRINT"{down}then we'll run the program:":gg=1:GOSUB3931:q$="{reverse off}" 10050 GOSUB63000:PRINT"{clear}":GOSUB3931:GOSUB63000:v=53248 10051 FORi=0TO62:POKE832+i,240:NEXT 10055 POKEv+6,250:POKEv+7,200:POKEv+29,0:POKEv+23,0:POKEv+21,8 10060 PRINT"{home}{down*3}{reverse on}100 fori=0to62:read x:poke832+i,x:next " 10065 RESTORE:FORi=0TO62:READ x:POKE832+i,x:NEXT 10070 PRINT"{home}{down*4}{reverse on}200 poke2040+3,13{reverse off}: tell where shape is" 10075 POKE2040+3,13:GOSUB10500 10080 PRINT"{home}{down*5}{reverse on}400 poke v+39+3,1{reverse off}: sprite #3 is white " 10085 POKE v+39+3,1:GOSUB10500 10090 PRINT"{home}{down*6}{reverse on}500 x=200:y=150{reverse off}:{space*3}pick a position{space*5}" 10095 x=200:y=150:GOSUB10500 10100 PRINT"{home}{down*7}{reverse on}600 poke v+2*3,x:poke v+2*3+1,y" 10105 POKE v+2*3,x:POKE v+2*3+1,y:GOSUB10500 10110 PRINT"{clear}pick a colour # (0 to 15)";:INPUT c$:c=VAL(c$) 10120 IF c<0 OR c>15 THEN10110 10130 POKEv+39+3,c:GOSUB63000:POKEv+39+3,1:PRINT"{home}{down}we did {reverse on}n=3:pokev+39+n,"c 10135 GOSUB63000 10140 PRINT"{home}{down*2}pick an x-position";:INPUT x$:x%=VAL(x$):IFx%<0ORx%>355THEN10140 10145 IFx%>255THEN xh%=8:x%=x%-256 10150 POKEv+2*3,x%:POKEv+16,xh% 10155 PRINT"{home}{down*3}we did: {reverse on}n=3:pokev+2*n,"x%":pokev+16,"xh%:GOSUB63000 10160 POKEv+16,0:POKEv+2*3,150:POKEv+39+3,1 10170 PRINT"{home}{down*4}what will {reverse on}poke v+29,2^3{reverse off} do?":GOSUB63000:POKEv+29,8 10180 PRINT"{home}{down*5}what will {reverse on}poke v+23,2^3{reverse off} do?":GOSUB63000:POKEv+23,8 10499 GOTO11000 10500 FORj=1TO3:PRINT"{home}{space*5}":FORk=1TO100:NEXT:PRINT"{home}done!" 10510 PRINT"{home}done!":FORk=1TO100:NEXT:NEXT:GOSUB63000 10520 RETURN 11000 GOSUB63000:ms$="au revoir!":PRINT"{clear}":GOSUB63100 11010 PRINT"{home}{down*3}poke 53248+21,0:rem turn off!{home}":END 12500 REM sprites 12510 FORi=0TO62:x=240:POKE832+i,x:NEXT 12520 POKE2040,13:POKE2040+3,13:POKE2040+7,13 12530 v=53248:POKE v+39,10:POKEv+39+3,1:POKEv+39+7,14 12540 POKEv+21,1+8+128 12560 FOR t=0 TO 500 STEP 5 12565 x0=t/2:y0=t/3 12566 x3=250-t/2:y3=200-t/3 12567 x7=150+100*SIN(t/50):y7=100+50*COS(t/50) 12570 POKE v+2*0,x0:POKE v+2*0+1,y0 12575 POKE v+2*3,x3:POKE v+2*3+1,y3 12576 POKE v+2*7,x7:POKE v+2*7+1,y7 12580 NEXT t:POKEv+21,0:RETURN 60000 REM initialize 60001 bt$="{home}":FORi=1TO24:bt$=bt$+"{down}":NEXT 60002 pt$="{red}{cm a}{sh asterisk*10}{cm s}{down}{left*12}{sh -}{right*10}{sh -}{down}{left*12}{cm z}{cm r}{sh asterisk*8}{cm r}{cm x}" 60003 pt$=pt$+"{down}{left*13}N{cm t*12}M{down}{left*14}{cm g}{green}{=*12}{black}{cm m}" 60004 pt$=pt$+"{down}{left*14}PO{cm t*10}PO{up*4}{left*12}" 60005 pt$=bt$+"{up*6}{right*26}"+pt$ 60007 ml$="{home}{down*9}{right*27}" 60008 wd=40:crt=1024 60009 w2=wd/2:w3=wd-1:w1$=MID$(STR$(wd),2):POKE53281,15:POKE53280,12:PRINT"{black}" 60010 v=53248:FORi=0TO16:POKEv+i,0:NEXT 60011 POKEv+23,0:POKEv+29,0:FORi=0TO7:POKEv+39+i,0:NEXT 60020 RETURN 62000 GOSUB63000 62001 PRINTsd$cl$:PRINTcl$:PRINTcl$ 62003 RETURN 63000 PRINT"{home}{down*24}{black}hit {reverse on}return{reverse off} to continue"; 63001 GETa$:IFa$<>""THEN63001 63002 GETa$:IFa$=""THEN63002 63003 RETURN 63100 FORt=1TO5:PRINTpt$ms$; 63101 PRINTpt$"{space*10}"; 63102 PRINTpt$ms$;:NEXT 63103 PRINT"{black}":RETURN 63900 sd$="{home}{down*18}":cl$="{reverse off}{space*38}{reverse off}" 63901 sr$="{right*40}" 63902 RETURN stop tok64 (bastext 1.0)