start tok64 d64-qyJR9y 0 REM"{delete*7} ponzo*82*waterloo 1 REM"{delete*6} 50 POKE53281,15:POKE53280,12:PRINT"{black}" 100 PRINT"{clear}{space*14}{reverse on}{blue}c64 tutor-4 101 PRINT"{red}{cm a}{sh asterisk*37}{cm s}" 102 PRINT"{sh -} {reverse on}{blue}{space*10}inside the c64{space*11}{red}{reverse off} {sh -}":ms$=" welcome! " 103 PRINT"{red}{cm z}{sh asterisk*37}{cm x}{black}" 1000 GOSUB60000:GOSUB63100:GOSUB63000 1005 PRINT"{clear}{right*12}{reverse on}c64 memory" 1010 PRINT"{down}memory runs from 0 to 65535 (decimal)" 1020 PRINT"{down}or {0*4} to {f*4} (hexadecimal)" 1030 PRINT"{down}(written ${0*4} ${f*4})" 1040 PRINT"{down}some is for you..some for me." 1050 PRINT"{down}(about half/half)" 1060 PRINT"{down}let me show you{.*3}" 1070 GOSUB63000 1080 PRINT"{clear}{right*7}{reverse on}bottom half of memory" 1090 PRINT"decimal hex" 1100 PRINT"40960=$a{0*3}-{cm +*6}{arrow left}top of basic memory" 1110 PRINT"{space*12}{cm +*6}{arrow left}I" 1120 PRINT"{space*12}- - -{space*2}+" 1125 PRINT"{space*12}{cm +*6} {sh -}" 1130 PRINT"{space*12}{cm +*6} {sh -}basic" 1140 PRINT"{space*12}{cm +*6} {sh -}programs" 1150 PRINT"{space*12}{cm +*6}{arrow left}Kin here" 1155 PRINT" 2048=$0800-{cm +*6}{arrow left}basic memory starts" 1160 PRINT" 2047=$07ff-{cm +*6}{arrow left}Iscreen memory" 1170 PRINT" 1024=$0400-{cm +*6}{arrow left}K" 1190 PRINT" 1023=$03ff {cm +*6}{arrow left}I" 1200 PRINT"{space*12}{cm +*6}{space*2}my workspace" 1210 PRINT"{space*12}{cm +*6} {sh -}" 1220 PRINT"{space*12}{cm +*6}{space*2}" 1230 PRINT"{space*12}{cm +*6}{arrow left}pointers 1240 PRINT"{space*12}{cm +*6}{arrow left}to magic 1250 PRINT"{space*12}{cm +*6}{arrow left}memory loc'ns" 1260 PRINT"{space*12}{cm +*6}{arrow left}flags,etc." 1270 PRINT"{space*12}{cm +*6}" 1280 PRINT"{space*4}0=${0*4}-{cm +*6}{arrow left}Kbottom" 1290 GOSUB63000 1300 PRINT"{clear}i store bytes read from a datasette" 1310 PRINT"{down}in 'buffers' until i get enough" 1320 PRINT"{down}to stuff into 'basic memory'" 1330 PRINT"{down}(if they're basic programs)." 1340 PRINT"{down}these are (usually) nice places to put" 1350 PRINT"{down}machine language programs." 1360 PRINT"{down}when you define variables x,y,a(i),etc." 1370 PRINT"{down}i store them after your basic program." 1380 PRINT"{down}when you define strings a$,c$(i),etc." 1390 PRINT"{down}i store them at the 'top'." 1400 PRINT"{down}to keep track of where i put things" 1410 PRINT"{down}i store pointers in low memory:" 1420 GOSUB63000 1430 PRINT"{clear}the address of"TAB(25)" is stored at" 1440 PRINT"{cm u*15}"TAB(25)"{cm u*14}" 1450 PRINT"{reverse on}start of basic"TAB(25)"43/44 =$2b/$2c" 1460 PRINT"^(usually 2049=$0801)" 1470 PRINT"{reverse on}end of program"TAB(25)"45/46 =$2d/$2e" 1480 PRINT"^(varies with program)" 1485 PRINT" (and gives start of )" 1486 PRINT" (variables too)" 1487 PRINT"{reverse on}bottom of strings"TAB(25)"51/52 =$33/$34" 1488 PRINT"^(varies with program)" 1489 PRINT" ($7{f*3} & down{arrow left}strings)" 1490 PRINT"{reverse on}top of basic ram"TAB(25)"55/56 =$37/$38" 1500 PRINT"^(usually 40960=$a{0*3})" 1501 PRINT"{down*3}note: the 'top of basic ram' may be at" 1502 PRINT"$a{0*3}..if no 'cartridge' is involved." 1505 PRINT"{down}{reverse on}we'll come back to these pointers later!" 1510 GOSUB63000 1520 PRINT"{clear}{right*10}{reverse on}top half of memory" 1530 PRINT"decimal hex" 1540 PRINT"65535=${f*4}-{cm +*6}{arrow left}top of memory" 1550 PRINT"{space*12}{cm +*6}{arrow left}I" 1560 PRINT"{space*12}{cm +*6} {sh -}ram &" 1565 PRINT"{space*12}{cm +*6} {sh -}rom" 1570 PRINT"49152=$c{0*3} {cm +*6}{arrow left}K" 1575 PRINT"{space*12}{cm +*6}{arrow left}I" 1576 PRINT"{space*12}{cm +*6} {sh -}basic" 1577 PRINT"{space*12}{cm +*6} {sh -}interpreter" 1578 PRINT"{space*12}{cm +*6} {sh -}" 1580 PRINT"40960=$a{0*3} {cm +*6}{arrow left}K" 1590 PRINT"{space*12}{cm +*6}{arrow left}I{arrow left} may be" 1595 PRINT"{space*12}{cm +*6} {sh -}used by" 1596 PRINT"{space*12}{cm +*6} {sh -}cartridge" 1600 PRINT"32768=$8{0*3} {cm +*6}{arrow left}K" 1660 GOSUB63000 1750 PRINT"{clear}{space*5}{reverse on}how basic programs are stored" 1760 PRINT"{down}recall that basic programs (normally)" 1770 PRINT"{down}go into memory starting at $0801(hex)." 1780 PRINT"{down}let's look at the bytes there for the" 1790 PRINT"{down}simple program:" 1800 PRINT"{down}{reverse on}10 fori=1to10{space*3}" 1810 PRINT"{reverse on}20 print"CHR$(34)"*"CHR$(34)":next" 1820 PRINT"{down}we'll {reverse on}sys2048{reverse off} to get to the mlm" 1830 PRINT"{down}then we'll .{reverse on}m 0800-0820{reverse off} to display" 1840 PRINT"{down}the memory holding this simple program." 1845 GOSUB63000:PRINT"{clear}for:" 1846 PRINT"{down}{reverse on}10 fori=1to10{space*3}" 1847 PRINT"{reverse on}20 print"CHR$(34)"*"CHR$(34)":next" 1848 PRINT"{down}we'll get:" 1850 PRINT"{down} .:{space*2}0800 00 0d 08 0a 00 81 49 b2 1860 PRINT" .:{space*2}0808 31 a4 31 30 00 18 08 14 1870 PRINT" .:{space*2}0810 00 99 22 2a 22 3a 82 00 1880 PRINT" .:{space*2}0818 00 00 aa aa aa aa aa aa 1890 sd$="{home}{down*18}":cl$="{reverse off}{space*38}{reverse off}" 1891 sr$="{right*40}" 1900 sd=8:sr=10:cc$="00":GOSUB55000 1910 PRINTsd$"i always have {reverse on}00{reverse off} here." 1920 PRINT"that's why 'sys2048' works!" 1930 GOSUB62000 1931 GOSUB55010 1950 sd=8:sr=13:cc$="0d 08":GOSUB55000 1960 PRINTsd$"this is the address of the {reverse on}next{reverse off}" 1970 PRINT"basic instruction." 1980 GOSUB62000 1981 GOSUB55010 1990 sd=8:sr=19:cc$="0a 00":GOSUB55000 2000 PRINTsd$"this is the line number {reverse on}10{reverse off}" 2010 PRINT" in hex." 2020 GOSUB62000 2021 GOSUB55010 2030 sd=8:sr=25:cc$="81":GOSUB55000 2040 PRINTsd$"this is the 'token' for"; 2050 PRINT" {reverse on}for{reverse off}" 2060 GOSUB62000 2061 GOSUB55010 2066 GOSUB55010 2070 sd=8:sr=28:cc$="49":GOSUB55000 2080 PRINTsd$"this is the ascii code for"; 2090 PRINT" {reverse on}i{reverse off}" 2100 GOSUB62000 2101 GOSUB55010 2110 sd=8:sr=31:cc$="b2":GOSUB55000 2120 PRINTsd$"this is the ascii code for"; 2130 PRINT" {reverse on}={reverse off}" 2140 GOSUB62000 2141 GOSUB55010 2150 sd=9:sr=10:cc$="31":GOSUB55000 2160 PRINTsd$"this is the ascii code for"; 2170 PRINT" {reverse on}1{reverse off}" 2180 GOSUB62000 2181 GOSUB55010 2190 sd=9:sr=13:cc$="a4":GOSUB55000 2200 PRINTsd$"this is the 'token' for"; 2210 PRINT" {reverse on}to{reverse off}" 2220 GOSUB62000 2221 GOSUB55010 2230 sd=9:sr=16:cc$="31":GOSUB55000 2240 PRINTsd$"this is the ascii code for"; 2250 PRINT" {reverse on}1{reverse off}(again)" 2260 GOSUB62000 2261 GOSUB55010 2270 sd=9:sr=19:cc$="30":GOSUB55000 2280 PRINTsd$"this is the ascii code for"; 2290 PRINT" {reverse on}0{reverse off}" 2300 GOSUB62000 2301 GOSUB55010 2310 sd=9:sr=22:cc$="00":GOSUB55000 2320 PRINTsd$"this is the byte meaning" 2330 PRINT"{reverse on}end of statement{reverse off}." 2340 GOSUB62000 2341 GOSUB55010 2350 sd=9:sr=25:cc$="18 08":GOSUB55000 2360 PRINTsd$"these point to address of" 2370 PRINT"the {reverse on}next{reverse off} statement" 2380 GOSUB62000 2391 GOSUB55010 2410 PRINTsd$"this 2nd statement begins" 2420 PRINT"at $080d as noted earlier." 2430 sd=8:sr=13:cc$="0d 08":GOSUB55000 2435 FORi=1TO50:NEXT 2440 GOSUB55010 2450 GETa$:IFa$=""THEN2430 2460 PRINTsd$cl$:PRINTcl$:PRINTcl$ 2465 sd=9:sr=25:cc$="18 08":GOSUB55000 2470 PRINTsd$"the address of the 'next' statement" 2480 PRINT"is given {reverse on}lo-byte{reverse off} then {reverse on}hi-byte{reverse off}." 2490 PRINT"it's (lo-byte)+256*(hi-byte)." 2500 GOSUB62000 2501 GOSUB55010 2510 PRINTsd$"..same for the 'statement number'." 2520 sd=8:sr=19:cc$="0a 00":GOSUB55000 2525 FORi=1TO50:NEXT 2530 sd=8:sr=19:cc$="0a 00":GOSUB55000 2535 GETa$:IFa$=""THEN2520 2540 GOSUB62000 2541 GOSUB55010 2550 PRINTsd$"then comes 2 bytes for the " 2560 PRINT"statement number {reverse on}20{reverse off}" 2570 PRINT"(1st byte)+256*(2nd byte)" 2575 sd=9:sr=31:cc$="14":GOSUB55000 2576 sd=10:sr=10:cc$="00":GOSUB55000 2580 GOSUB62000 2581 PRINTLEFT$(sd$,9)TAB(31)"14" 2582 PRINTLEFT$(sd$,10)TAB(10)"00" 2590 sd=10:sr=13:cc$="99":GOSUB55000 2600 PRINTsd$"this is the 'token' for {reverse on}print{reverse off}" 2610 GOSUB62000 2611 GOSUB55010 2620 sd=10:sr=16:cc$="22":GOSUB55000 2630 PRINTsd$"this is the ascii code for {reverse on}"CHR$(34) 2640 GOSUB62000 2641 GOSUB55010 2650 sd=10:sr=19:cc$="2a":GOSUB55000 2660 PRINTsd$"this is the ascii code for {reverse on}*{reverse off}" 2670 GOSUB62000 2671 GOSUB55010 2680 sd=10:sr=22:cc$="22":GOSUB55000 2690 PRINTsd$"..the ascii code for {reverse on}"CHR$(34):PRINT"{.*3}again" 2700 GOSUB62000 2701 GOSUB55010 2710 sd=10:sr=25:cc$="3a":GOSUB55000 2720 PRINTsd$"the ascii code for {reverse on}:{reverse off}" 2730 GOSUB62000 2731 GOSUB55010 2740 sd=10:sr=28:cc$="82":GOSUB55000 2750 PRINTsd$"the token for {reverse on}next{reverse off}" 2760 GOSUB62000 2761 GOSUB55010 2770 sd=10:sr=31:cc$="00":GOSUB55000 2780 sd=11:sr=10:cc$="00 00":GOSUB55000 2790 PRINTsd$"the 3 zero bytes say" 2800 PRINT"{reverse on}end of the program{reverse off}!" 2810 GOSUB62000 2811 PRINTLEFT$(sd$,10)TAB(31)"00" 2812 PRINTLEFT$(sd$,11)TAB(10)"00 00" 2820 GOSUB62000 2830 sd=10:sr=31:cc$="00":GOSUB55000 2840 PRINTsd$"this one is the normal" 2850 PRINT"{reverse on}end of statement{reverse off}" 2860 GOSUB62000 2861 GOSUB55010 2862 sd=11:sr=10:cc$="00 00":GOSUB55000 2870 PRINTsd$"these give {reverse on}00 00{reverse off} as a link" 2880 PRINT"to the 'next' statement." 2890 PRINT"meaning {reverse on}no next statement{reverse off}." 2900 GOSUB62000 2901 GOSUB55010 2902 PRINTLEFT$(sd$,11)TAB(16)"{reverse on}aa aa aa aa aa aa{reverse off}" 2910 PRINTsd$"the bunch of {reverse on}aa{reverse off}s is just{.*7}" 2920 PRINT"garbage!" 2940 GOSUB62000:PRINT"{clear}": ms$="aa aa aa":GOSUB63100 2950 PRINT"{clear}if you really{down}{left*6}{cm u*6}{up} wanted to you" 2960 PRINT"{down}could enter the mlm with {reverse on}sys2048" 2970 PRINT"{down}and write (or change) a basic program" 2980 PRINT"{down}by simply entering the appropriate" 2990 PRINT"{down}bytes (in hex!) into the right loc'ns!" 3000 PRINT"{down}..but learn your ascii code.." 3010 PRINT"{down}and the single-byte 'tokens' i use" 3020 PRINT"{down}to identify the various basic commands" 3030 PRINT"{down}like {reverse on}print{reverse off},{reverse on}for{reverse off},{reverse on}next{reverse off},{reverse on}run{reverse off},{reverse on}list{reverse off},etc." 3040 PRINT"{down}(try it after{down}{left*5}{cm u*5}{up} you end tutor)" 3050 GOSUB63000:GOSUB40000:GOSUB5000 4000 PRINT"{clear}now{.*3}{space*6}**********" 4001 PRINT"{space*12}* a test * 4002 PRINT"{space*12}**********" 4003 FORi=1TO500:NEXT:ms$=" {reverse on}a test?!{reverse off}":GOSUB63100 4010 PRINT"{home}{down*3}i'll ask you questions about myself.":ms$="good!good!" 4020 PRINT"{down}if the answer is an 'address' or" 4030 PRINT"{down}memory location give it to me as a" 4040 PRINT"{down}{reverse on}4 digit hex number with $" 4050 PRINT"{down}(like $1234)" 4060 PRINT"{down}{.*3}unless otherwise specified!" 4070 GOSUB50000:GOSUB63000 4080 FORn=1TOqq:PRINT"{clear}{down*3}"q$(n) 4085 GETa$:IFa$<>""THEN4085 4090 INPUT"{down*3}{space*3}V{left*3}";a$:PRINT"{down*4}" 4100 IFa$=a$(n)THENGOSUB63100:PRINT"{home}{down*13}":GOTO4120 4110 PRINTan$a$(n) 4120 PRINT"{down}"m$(n):GOSUB63000:NEXT 4130 PRINT"{clear}want to take the **test** again?" 4140 INPUT"{down*2}{space*3}y{left*3}";a$ 4150 IFa$="y"THENPRINT"{clear}":GOTO4080 4160 GOTO39999 5000 PRINT"{clear}after running a program like:":qt$=CHR$(34):GOSUB63900 5010 PRINT"{down} 10 ab$=str$(7)" 5020 PRINT"{down}let's see where i put the string '7'." 5030 PRINT"{down}we'll type {reverse on}sys2048{reverse off} then" 5040 PRINT"{down}.{reverse on}m 0800-0830{reverse off} to see the program" 5050 PRINT"{down}.{reverse on}m 7ff8-7{f*3}{reverse off} to see the string." 5060 GOSUB63000:PRINT"{clear}"; 6001 PRINT"{down}.:{space*2}0800 00 0e 08 0a 00 41 42 24 6002 PRINT".:{space*2}0808 b2 c4 28 37 29 00 00 00 6003 PRINT".:{space*2}0810 41 c2 02 fc 7f 00 00 aa 6004 PRINT".:{space*2}0818 aa aa aa aa aa aa aa aa 6005 PRINT"{down*2}.:{space*2}7ff8 aa aa aa aa 20 37 12 08 6100 sd=3:sr=24:cc$="00 00 00":GOSUB55000 6110 PRINTsd$"these are the 3 '00'-bytes that end" 6120 PRINT"the program." 6130 GOSUB62000:GOSUB55010 6140 sd=4:sr=9:cc$="41 c2":GOSUB55000 6150 PRINTsd$"{reverse on}41{reverse off}='a' in ascii" 6160 PRINT"{reverse on}42{reverse off}='b'..but $80 is added" 6170 PRINT"indicating a {reverse on}string{reverse off}, giving {reverse on}c2{reverse off}" 6180 GOSUB62000:GOSUB55010 6190 sd=4:sr=15:cc$="02":GOSUB55000 6200 PRINTsd$"the string ab$ is {reverse on}02{reverse off} bytes long." 6210 GOSUB62000:GOSUB55010 6220 sd=4:sr=18:cc$="fc 7f":GOSUB55000 6230 PRINTsd$"and it's located at ${reverse on}7ffc{reverse off}." 6240 GOSUB62000:GOSUB55010 6250 sd=8:sr=21:cc$="20 37":GOSUB55000 6260 PRINTsd$"here, at $7ffc, is ab$." 6270 PRINT"{down}ab$ is:{reverse on}20{reverse off}='space'+{reverse on}37{reverse off}='7'" 6280 GOSUB62000:GOSUB55010 6290 sd=8:sr=27:cc$="12 08":GOSUB55000 6300 PRINTsd$"and where does it say it's" 6310 PRINT"2 bytes long?" 6320 PRINT"..at memory loc'n ${reverse on}0812{reverse off}!" 6330 sd=4:sr=15:cc$="02":GOSUB55000 6340 GOSUB55010:GETa$:IFa$=""THEN6330 6350 PRINT"{clear}if, however, your program was:" 6360 PRINT"{down} 10 ab$="qt$"7"qt$ 6370 PRINT"{down}where do you think the pointer will" 6380 PRINT"{down}point to?" 6390 PRINT"{down}{reverse on}not{reverse off} to $7ffc, but to the location" 6400 PRINT"{down}in the basic program itself where" 6410 PRINT"{down}'7' is located." 6415 GOSUB62000 6420 PRINTsd$"that is, to ${reverse on}080a{reverse off}" 6425 PRINT"..and it will be 1 byte long!" 6430 sd=3:sr=9:cc$="7":GOSUB55000 6440 GOSUB55010:GETa$:IFa$=""THEN6430 6450 RETURN 39999 PRINT"{clear}":ms$="{reverse on}au revoir!{reverse off}":GOSUB63100:PRINT"{home}":END 40000 PRINT"{clear}let's look at some pointers.":GOSUB63900 40001 PRINT"{down}(we'll assume we've got a c-64" 40002 PRINT"{down} link so 'top of ram' is at $8{0*3}" 40003 PRINT"{down} and the 'basic' is {reverse on}basic 4.0{reverse off})":GOSUB63000 40005 PRINT"{clear}{down*2}before writing any{down}{left*3}{cm u*3}{up} program" 40006 PRINT"(after first turning on the c64)" 40010 PRINT"{down}we'll {reverse on}sys2048{reverse off} to get into the mlm.." 40020 PRINT"{down}then .{reverse on}m 002b 0033{reverse off}{.*3}" 40030 PRINT"{down}b* 40031 PRINT"{space*5}pc{space*2}sr ac xr yr sp" 40032 PRINT".;{space*2}0801 32 04 5e 00 f8" 40033 PRINT".m 002b 0033" 40034 PRINT".:{space*2}002b 01 08 03 08 03 08 03 08" 40035 PRINT".:{space*2}0033 00 80 00 00 00 80 00 ff" 40036 PRINT".x {arrow left} =exit{.*3}remember?" 40040 sd=14:sr=09:cc$="01 08":GOSUB55000 40050 PRINTsd$"this says basic programs start" 40060 PRINT"at $0801..read it backwards!" 40070 GOSUB62000:GOSUB55010 40080 sd=14:sr=15:cc$="03 08":GOSUB55000 40090 PRINTsd$"this says the nil-program ends" 40100 PRINT"at $0803..after 3 '00' bytes!" 40110 GOSUB62000:GOSUB55010 40120 sd=14:sr=21:cc$="03 08":GOSUB55000 40130 PRINTsd$"this says arrays start" 40140 PRINT"at $0803 too..no arrays yet!" 40150 GOSUB62000:GOSUB55010 40160 sd=14:sr=27:cc$="03 08":GOSUB55000 40170 PRINTsd$"this says arrays end" 40180 PRINT"at $0803 too..{reverse on}no arrays yet{reverse off}!" 40190 GOSUB62000:GOSUB55010 40200 sd=15:sr=09:cc$="00 08":GOSUB55000 40210 PRINTsd$"this says strings go down" 40220 PRINT"to $8{0*3}..{reverse on}no strings yet{reverse off}!" 40230 GOSUB62000:GOSUB55010 40240 sd=15:sr=15:cc$="00 00":GOSUB55000 40250 PRINTsd$"this pointer (to current string)" 40260 PRINT"we'll ignore." 40270 GOSUB62000:GOSUB55010 40280 sd=15:sr=21:cc$="00 80":GOSUB55000 40290 PRINTsd$"this says 'top of basic ram' is" 40300 PRINT"at $8{0*3}..of course." 40310 GOSUB62000:GOSUB55010 40320 sd=15:sr=27:cc$="14 ff":GOSUB55000 40330 PRINTsd$"this is the current basic " 40340 PRINT"line number..ignore!" 40350 GOSUB62000:GOSUB55010 40360 PRINT"{clear}ok..{reverse on}now we'll write a short program{reverse off}:":FORi=1TO500:NEXT 40370 PRINT"{down}{reverse on}10 fori=1to10:a(i)=i*i:a$(i)=str$(i)" 40380 PRINT"{reverse on}20 print"CHR$(34)"+"CHR$(34)":next{space*20}" 40390 PRINT"{down}then, before{down}{left*6}{cm u*6}{up} running it" 40400 PRINT"{down}we'll {reverse on}sys2048{reverse off}:" 40410 PRINT"{down}b* 40420 PRINT"{space*5}pc{space*2}sr ac xr yr sp" 40430 PRINT".;{space*2}0801 32 04 5e 00 f8" 40440 PRINT".m 002b 0033" 40450 PRINT".:{space*2}002b 01 08 2e 08 2e 08 2e 08" 40460 PRINT".:{space*2}0033 00 80 da 7f 00 80 14 ff" 40470 PRINT".x" 40480 sd=14:sr=09:cc$="01 08":GOSUB55000 40490 PRINTsd$"the basic program starts" 40500 PRINT"at $0801..of course!" 40510 GOSUB62000:GOSUB55010 40520 sd=14:sr=15:cc$="2e 08":GOSUB55000 40530 PRINTsd$"the basic program ends" 40540 PRINT"at $082e..after the 3 '00' bytes." 40550 GOSUB62000:GOSUB55010 40560 sd=14:sr=21:cc$="2e 08 2e 08":GOSUB55000 40570 PRINTsd$"no variables, no arrays or" 40580 PRINT"strings created yet." 40590 GOSUB62000:GOSUB55010 40600 sd=15:sr=09:cc$="00 80 da 7f 00 80 14 ff":GOSUB55000 40610 PRINTsd$"nothing worth noting (!)" 40620 PRINT"has happened yet." 40630 GOSUB62000:GOSUB55010 40640 PRINTsd$"{reverse on}now{reverse off} we'll run{down}{left*3}{cm u*3}{up} the program:" 40650 PRINT"watch{.*4}" 40655 PRINT"{home}{space*36}" 40656 PRINT"{down}{reverse on}10 fori=1to10:a(i)=i*i:a$(i)=str$(i)" 40657 PRINT"{reverse on}20 print"CHR$(34)"+"CHR$(34)":next" 40658 FORi=1TO5:PRINT"{space*37}":NEXT 40660 GOSUB62000:GOSUB55010 40670 sd=14:sr=09:cc$="01 08":GOSUB55000 40680 PRINTsd$"start of basic won't change" 40690 GOSUB62000:GOSUB55010 40700 sd=14:sr=15:cc$="2e 08":GOSUB55000 40710 PRINTsd$"end of basic won't change" 40720 PRINT"(it's also 'start of variables)" 40730 GOSUB62000:GOSUB55010 40740 sd=14:sr=21:cc$="35 08 9b 08":GOSUB55000 40750 PRINTsd$"array a(i) is stored from" 40760 PRINT"$0835 and 'up'." 40770 GOSUB62000 40771 PRINTsd$"it actually ends at $0872" 40772 PRINT"and info on where a$(i) is stored" 40773 PRINT"goes into $0873-$089b." 40774 GOSUB62000:GOSUB55010 40780 sd=15:sr=09:cc$="d7 7f":GOSUB55000 40790 PRINTsd$"array a$(i) is stored from" 40800 PRINT"$8{0*3} (really $7{f*3}) {reverse on}down{reverse off} t0 $7fd7" 40810 GOSUB62000 40820 PRINTsd$"remember..the loc'ns of a$(i)" 40830 PRINT"are kept in $0873-$089b" 40840 GOSUB62000 40850 PRINTsd$"the strings themselves='1'-'10'" 40860 PRINT"are stored in $7fd7-$7{f*3}." 40870 GOSUB62000:GOSUB55010 40875 sd=14:sr=15:cc$="2e 08 35 08":GOSUB55000 40880 PRINTsd$"{reverse on}so{reverse off}{.*3}the value of 'i' is stored" 40890 PRINT"in 7 bytes from $082e to $0834" 40900 GOSUB62000 40910 PRINTsd$"2 bytes for it's name:{reverse on}i{reverse off}" 40920 PRINT"5 bytes for it's value=1,then 2,etc." 40930 GOSUB62000:GOSUB55010 40940 sd=14:sr=21:cc$="35 08 9b 08":GOSUB55000 40950 PRINTsd$"values of{space*2}a(i) go into loc'ns" 40960 PRINT"$0835-$0872 (including 2 bytes" 40970 PRINT"for it's name {reverse on}a{reverse off})" 40980 GOSUB62000 40990 PRINTsd$"the last part of the range" 41000 PRINT"$0835-$089b is to keep track of" 41010 PRINT"where each a$(i) is stored in hi ram." 41020 GOSUB62000:GOSUB55010 41030 PRINTsd$"if you type {reverse on}clr{reverse off} after {reverse on}run{reverse off}ing" 41040 PRINT"the program,all variables,arrays and" 41050 PRINT"strings get cleared." 41060 GOSUB62000 41070 PRINTsd$"the above pointers revert to{.*3}" 41080 GOSUB62000 41090 sd=14:sr=09:cc$="01 08 2e 08 2e 08 2e 08":GOSUB55010 41100 sd=15:sr=09:cc$="00 80 da 7f 00 80 14 ff":GOSUB55010 41110 PRINTsd$"just the program..from $0801" 41120 PRINT"to $082e" 41130 GOSUB62000 41140 PRINTsd$"..and guess what happens if you" 41150 PRINT"type {reverse on}new{reverse off}!!" 41160 GOSUB62000 41180 sd=14:sr=09:cc$="01 08 03 08 03 08 03 08":GOSUB55010 41190 sd=15:sr=09:cc$="00 80 da 7f 00 80 14 ff":GOSUB55010 41200 PRINTsd$"i put 00 00 00 into $0800-$0802" 41210 PRINT"..and that's all folks!" 41220 GOSUB62000:PRINT"{clear}":ms$="that's all":GOSUB63100:RETURN 50000 qq=10:an$="{down}answer={reverse on}" 50001 a$(1)="v2":IFPEEK(32768)=9 THENa$(1)="v4" 50004 FORi=2TOqq:READa$(i):NEXT 50005 DATA $a000,$0400,$0801,3,n,y,$033c,y,y 51000 FORi=1TOqq:READq$(i):NEXT 51001 DATA "{clear}{reverse on}what brand of basic have i got{reverse off} 2.0/4.0 51002 DATA "{clear}{reverse on}where do the basic roms start" 51003 DATA "{clear}{reverse on}where does screen memory start" 51004 DATA "{clear}{reverse on}where do basic programs start{reverse off}" 51005 DATA "{clear}{reverse on}basic programs end in ? zero bytes" 51006 DATA "{clear}{reverse on}peek(2049)+256*peek(2050){reverse off}=1st statement number(y/n)" 51007 DATA "{clear}{reverse on}strings are stored at top of ram{reverse off}(y/n)" 51008 DATA "{clear}{reverse on}the cassette buffer starts where" 51009 DATA "{clear}{reverse on}$002b/$002c=pointer to start of basic{reverse off}(y/n)" 51010 DATA "{clear}{reverse on}$0037/$0038=pointer to topof ram{reverse off}(y/n)" 52000 FORq=1TOqq:READm$(q):NEXT 52001 DATA a 'standard' c-64 has basic 2.0 52002 DATA from $a000 to $bfff. 52003 DATA t0 $07ff..just before start of basic. 52004 DATA 2048=$0800 has '00' 52005 DATA the 'link' is 00 00. 52006 DATA above gives 'link' to 2nd statement 52007 DATA they're stored from $7fff down 52008 DATA dirty question!! 52009 DATA 43/44 in decimal 52010 DATA 55/56 in decimal 52999 RETURN 55000 PRINTLEFT$(sd$,sd)LEFT$(sr$,sr)"{reverse on}"cc$"{reverse off}":RETURN 55010 PRINTLEFT$(sd$,sd)LEFT$(sr$,sr)cc$"{reverse off}":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}{=*12}{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$+"{black}" 60007 ml$="{home}{down*9}{right*27}" 60008 wd=40:crt=1024:PRINTCHR$(142) 60009 w2=wd/2:w3=wd-1:w1$=MID$(STR$(wd),2):POKE53281,15:POKE53280,12:PRINT"{black}" 60010 w2$=MID$(STR$(w2),2):w3$=MID$(STR$(w3),2) 60020 RETURN 62000 GOSUB63000 62001 PRINTsd$cl$:PRINTcl$:PRINTcl$ 62003 RETURN 63000 PRINT"{home}{down*24}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:RETURN 63900 sd$="{home}{down*18}":cl$="{reverse off}{space*38}{reverse off}" 63901 sr$="{right*40}" 63902 RETURN stop tok64 (bastext 1.0)