Example: bachelor of science

Commodore 64 Programmers Reference Manual

GRAPHICSOVERVIEWA llofthegraphicsabilitiesoftheCommodore64 comefromthe6567 VideoInterfaceChip(alsoknownastheVIC-IIc hip).Thischipgivesavarietyofgraphicsmode s,includinga 40columnby25linetextdisplay,a320by200dot highresolutiondisplay,andSPRITES, thisweren'tenough, ,forexample,todefinethetophalfofthescree ntobeinhighresolutionmode, ! :A)CHARACTERDISPLAYMODES1)StandardCharac terModea)ROMcharactersb)RAMprogrammablec haracters2)Multi-ColorCharacterModea)ROM charactersb)RAMprogrammablecharacters3)E xtendedBackgroundColorModea)ROMcharacter sb)RAMprogrammablecharactersB)BITMAPMODE S1)StandardBitMapMode2)Multi-ColorBitMap ModeC)SPRITES1)StandardSprites2) ,thescreenstartsatlocation1024($0400inHE Xadecimalnotation) ($D800inHEX) ,whichmeansthatit canholdanyintegernumberfrom0 , , ,eachofthe1000locationsinscreenmemorycon tainsa ($DOOOinHEX)through53294($D02 EinHEX).VIDEOBANKSELECTIONTheVIC-IIchipc anaccess("see") , (orsections) neededis ,thechipcan"see" #2(CIA#2).ThePOKEandPEEKBASIC statements(ortheirmachinelanguageversion s)areusedtoselectabankbycontrollingbits0 and1 ofPORTAofCIA#2(location56576(or$DDOOHEX.

GRAPHICS LOCATIONS Some general information first. There are 1000 possible locations on the Commodore 64 screen. Normally, the screen starts at location 1024

Tags:

  Programmer

Information

Domain:

Source:

Link to this page:

Please notify us if you found a problem with this document:

Other abuse

Transcription of Commodore 64 Programmers Reference Manual

1 GRAPHICSOVERVIEWA llofthegraphicsabilitiesoftheCommodore64 comefromthe6567 VideoInterfaceChip(alsoknownastheVIC-IIc hip).Thischipgivesavarietyofgraphicsmode s,includinga 40columnby25linetextdisplay,a320by200dot highresolutiondisplay,andSPRITES, thisweren'tenough, ,forexample,todefinethetophalfofthescree ntobeinhighresolutionmode, ! :A)CHARACTERDISPLAYMODES1)StandardCharac terModea)ROMcharactersb)RAMprogrammablec haracters2)Multi-ColorCharacterModea)ROM charactersb)RAMprogrammablecharacters3)E xtendedBackgroundColorModea)ROMcharacter sb)RAMprogrammablecharactersB)BITMAPMODE S1)StandardBitMapMode2)Multi-ColorBitMap ModeC)SPRITES1)StandardSprites2) ,thescreenstartsatlocation1024($0400inHE Xadecimalnotation) ($D800inHEX) ,whichmeansthatit canholdanyintegernumberfrom0 , , ,eachofthe1000locationsinscreenmemorycon tainsa ($DOOOinHEX)through53294($D02 EinHEX).VIDEOBANKSELECTIONTheVIC-IIchipc anaccess("see") , (orsections) neededis ,thechipcan"see" #2(CIA#2).ThePOKEandPEEKBASIC statements(ortheirmachinelanguageversion s)areusedtoselectabankbycontrollingbits0 and1 ofPORTAofCIA#2(location56576(or$DDOOHEX.

2 These2 bitsmustbesettooutputsbysettingbits0 and1 oflocation56578($ ) :POKE56578,PEEK(56578)OR3:REMMAKESUREBIT S0 AND1 ARESETTOOUTPUTSPOKE56576,(PEEK(56576)AND 252)ORA:REMCHANGEBANKS"A" ,sincethiswillaffectwherecharacterdatapa tternscomefrom,wherethescreenis,wherespr itescomefrom, ,bits0 and1 oflocation56576areauto-maticallysettoBAN K0($0000-$3 FFF) :TheCommodore64charactersetisnotavailabl etotheVIC-IIchipinBANKS1 and3.(Seecharactermemorysection.)SCREENM EMORYT helocationofscreenmemorycanbechangedeasi lybyaPOKE tocontrolregister53272($DOI8 HEX).However,thisregisterisalsousedtocon trolwhichcharactersetisused, ,thefollowingstatementshouldbeused:POKE5 3272,(PEEK(53272)AND15)ORA102 PROGRAMMINGGRAPHICSVALUEBITSBANKSTARTING VIC-IICHIPRANGEOFALOCATION000349152($COO O-$FFFF)*101232768($8000-$BFFF)210116384 ($4000-$7 FFF)*31100($0000-$3 FFF)(DEFAULTVALUE)Where"A"hasoneofthefol lowingvalues:' 'Sscreeneditorwherethescreenisasfollows: POKE648,page(wherepage=address/256, ,1024/256=4,soPOKE648,4). is alwayslocatedatlocations55296($D800)thro ugh56295($DBE7).

3 Screenmemory(the1000locationsstartingat1 024) , ,numbers,punctuationsymbols,andtheothert hingsthatyouseePROGRAMMINGGRAPHICS103 LOCATION*ABITSDECIMALHEX0 OOOOXXXX0$0000160001 XXXX1024$0400(DEFAULT)320010 XXXX2048$0800480011 XXXX3072$OCOO640100 XXXX4096$1000800101 XXXX5120$1400960110 XXXX6144$18001120111 XXXX7168$lCOO1281000 XXXX8192$20001441001 XXXX9216$24001601010 XXXX10240$28001761011 XXXX11264$2 COO1921100 XXXX12288$30002081101 XXXX13312$34002241110 XXXX14336$38002401111 XXXX15360$ ,andthatmeansthatyoucanhaveanalmostinfin itesetofsymbolsfor"games,businessapplica tions, fullcharactersetis 256*8= , ,youarefreetouselessthana ,it muststillstartatoneofthe8 bitsoftheVIC-IIcontrolregisterlocatedat5 3272($DOI8inHEXnotation).Bits3,2,and1 controlwherethecharacters' {T1ory,thefollowingBASIC state-mentcanbeused:POKE53272,(PEEK(5327 2)AND240)ORAW hereAisoneofthefollowingvalues:' *BITSofADECIMALHEX0 XXXXOOOX0$0000-$07FF2 XXXXOOIX2048$0800-$OFFF4 XXXXOI0X4096$1000-$17 FFROMIMAGEinBANKo &2(default)6 XXXXOIIX6144$1800-$1 FFFROMIMAGEinBANK0&28 XXXX1 OOX8192$2000-$27FF10 XXXXI0IX10240$2800-$2 FFF12 XXXXII0X12288$3000-$37FF14 XXXXIIIX14336$3800-$ ($9000-$9 FFF) , ,thesystemwasdesignedtomaketheVIC-IIchip thinkthattheROMcharactersareat4096-8191( $1000-$1 FFF)whenyourdataisinbank0,and36864-40959 ($9000-$9 FFF)whenyourdataisinbank2,eventhoughthec haracterROMisactuallyatlocation53248-573 43($DOOO-$DFFF).}

4 Canbeusedforprograms,otherdata,etc., :IftheseROMimagesgetinthewayofyourowngra phics,thensettheBANKSELECTBITS tooneoftheBANKS withouttheimages(BANKS1or3).TheROMpatter nswon' ' ,theareais occupiedbytheI/Ocontrolregisters, ,youmayneedtogettothecharacterROMif ,switchinthecharacterROM, 'refinished, (whenI/Oisswitchedout) youforgetandperformaninterrupt, ,thefollowingPOKE shouldbeused:POKE56334,PEEK(56334)AND254 (TURNSINTERRUPTSOFF)Afteryouarefinishedg ettingcharactersfromthecharacterROM,anda rereadytocontinuewithyourprogram,youmust turnthekeyboardscanbackonbythefollowingP OKE:POKE56334,PEEK(56334)ORI(TURNSINTERR UPTSON)ThefollowingPOKE willswitchoutI/OandswitchtheCHARACTERROM in:POKEl,PEEK(1)AND251 ThecharacterROMisnowinthelocationsfrom53 248-57343($DOOO-$DFFF).ToswitchI/Obackin to$DOOO fornormaloperationusethefollowingPOKE:PO KEl,PEEK(l)OR4106 PROGRAMMINGGRAPHICSSTANDARDCHARACTERMODE S tandardcharactermodeisthemodetheCommodor e64isinwhenyoufirstturnit , ,allyouhavetodoisdefinethenewcharactersh apesinRAM, , ,it 'ttoocomplicated,buta (seeCHARACTERMEMORY section).

5 ThentheBankSelectBitsaretakenintoaccount byaddinginthebaseaddress(seeVIDEOBANKSEL ECTION section).Belowisasimpleformulatoillustra tewhathappens:CHARACTERADDRESS=SCREENCOD E*8+(CHARACTERS ET*2048)+(BANK* 16384)CHARACTERDEFINITIONSE achcharacterisformedinan8 by8 gridofdots, bytesforeachcharacter,witheachbyterepres entingthedotpatternofarowinthecharacter, , (whentheI/Oisswitchedoff).Thefirst8bytes fromlocation53248($DOOO)to53255($D007)co ntainthepatternforthe@sign,whichhasa ,fromlocationPROGRAMMINGGRAPHICS10753256 ($D008)to 53263($DOOF), 2K(2048bits)of memory, ,oneforuppercaseandgraphicsandtheotherwi thupperandlowercase,thecharactergenerato rROMtakesup a totalof 4K ROM,it wouldseemthatthereis nowayto changethemfor ,the memorylocationthattellstheVIC-IIchipwher eto findthecharactersis a pro-grammableregisterwhichcanbe changedto pointto pointto RAM,thecharactersetmaybe youwantyourcharacterset to be locatedin RAM,therearea fewVERYIMPORTANT thingsto takeintoaccountwhenyoudecideto addition,therearetwootherimportantpoints youmustknowto createyourownspecialcharacters.

6 1) Itisan allor ,ifyouuse yourownchar-actersetbytellingtheVlt-IIch ipto getthecharacterinformationfromthe areayouhavepreparedin RAM,the standardCommo-dore64charactersareunavail ableto solvethis,youmustcopyanyletters,numbers, or standardCommodore64 graphicsyouintendto use intoyourowncharactermemoryin ,takeonlytheonesyouwant,anddon'tevenhave to keepthemin order!108 PROGRAMMINGGRAPHICSIMAGEBINARYPEEK**0001 100024**0011110060** **01100110102**01111110126** **01100110102** **01100110102** **011001101020000000002) ,with38 KavailableforaBASIC program,mostapplicationswon' :Youmustbecarefultoprotectthecharacterse tfrombeingoverwrittenbyyourBASIC program, 'tbeusedbecausethatiswhereyourBASIC programstarts!However,thereare6 ($3000inHEX).ThisisdonebyPOKE ingthelow4 ,likethis:POKE53272,(PEEK(53272)AND240)+ 12 Immediately,allthelettersonthescreenturn togarbage, . :mlr~'111111keyand"thenthe.~j:l-'1(oI~ ' , . it'sjustthatyou' :PRINTFRE(O)-(SGN(FRE(O <O)* :POKE52,48:POKE56,48:CLRN owtype:PRINTFRE(O)-(SGN(FRE(O <0)*65535 PROGRAMMINGGRAPHICS109 Seethechange?)))

7 BASIC nowthinksit , ,thereisrandomdatabeginningat12288($3000 HEX).YoumustputcharacterpatternsinRAM(in thesamestyleastheonesinROM) :5 PRINTCHR$(142):REMSWITCHTOUPPERCASE10 POKE52,48:POKE56,48:CLR:REMRESERVEMEMORY FORCHARACTERS20 POKE56334,PEEK(56334) :REt1 TURt.~OFFKEYSCANINTERRUPTTIMER30 POKE1,PEEK(1)AND251:REMSWITCHINCHARACTER 4121 FORI=0T0511:POKEI+ 12288.,PEEK( 1+53248): t~E:":T50 POKE1,PEEK(1)OR4:REMSWITCHIN I/O60 POKE56334,PEEK(56334)OR1:REMRESTARTKEYSC ANINTERRUPTTIMER70Et~DNowPOKE location53272with(PEEK(53272)AND240)+ ,right?Well, 'scharacterinformationfromyourRAM, , .. =12288TO12288+7:POKEI,255-PEEK(I): ).Bylookingatthetableofscreendisplaycode s, ' youwantedcharacternumber154,areversedZ?W ell,youcouldmakeit yourself,byreversingaZ,oryoucouldcopythe setofreversedcharactersfromtheROM, ' 'tneedthe> 'sreplacethe> :FOR1=0TO7:POKE12784+I,255-PEEK(I+12496) :NEXTN owtypea> >,it comesoutasareversedZ.( >signlookslikea reversedZ,it stillactslikea> > willstillworkfine,onlyit willlookstrange.

8 'sonlyonestepleftinprogrammablecharacter s(thebeststep!).. ,oneontopofanother,andwriteouteachbyteas eightbinarydigits,it formsaneightbyeightmatrix, bitis a one,thereisa , , :10 FORI =12448TO12455: witha ' **00111100601**01000010662**101001011653 **100000011294**101001011655**1001100115 36**0100001066 ROW7**001111:0060 TheProgrammableCharacterWorksheet(Figure 3-1) by8 matrixonthesheet,withrownumbers,andnumbe rsatthetopofeachcolumn.(Ifyouvieweachrow asabinaryword, tothe7thpower,thenextisequalto64or2 tothe6th,andsoon,untilyoureachtherightmo stbit(bit0)whichisequalto1 or2 tothe0power.)PlaceanXonthematrixateveryl ocationwhereyouwanta ,takethenumberatthetopofthecolumn(thepow er-of-2number,asexplainedabove)andwritei t , , (I -7).Whenyouarefinishedyoushouldhave8 numbersbetween0 , !Ifyouhavelessthan8numbers, 'sOKif , ,you'llseeyourowncharacter!Ifyoudon'tlik ethewaythecharacterturnedout, 'sallthereistoit!HINT:Forbestresults,alw aysmakeanyverticallinesinyourcharactersa tleast2dots(bits) (colordistortion) :10 REM*EXAMPLE1* (56334)AND254:POKE1,PEEK(I)AND251:REMTUR NOFFKBAND11035 FORI=0T063:REMCHARACTERRANGETOBECOPIEDFR Ot1 ROM36 FORJ=0T07:REMCOPYALL8 BYTESPERCHARACTER37 POKEI2288+I~8+J,PEEK(53248+I*8+J);REMCOp yAB'r'TE38 NEXTJ:NEXTI:REMGOTONEXTBYTEORCHARACTER39 POKE1,PEEK(I)OR4:POKE56334,PEEK(56334)OR 1;REMTURNON1/0 ANDKB40 POKE532?

9 2,(PEEK(53272)AND240)+12 :REMPROGRAMCHARACTERS6121 THRU638121 FORBYTE=I21TO?;REMDOALL8 BYTESOFACHARACTER10121 READNUMBER:REMREADIN1/8 THOFCHARACTERDATA12121 POKE12288+(S*-CHAR)+B'r' :REMSTORETHEDATAI t.~t1 EMOR'T'14121 NEXTBYTE:NEXTCHAR;REMALSOCOULDBENEXTBYTE ,CHAR15121 PRINTCHR$(147)TAB(255)CHR$(60);155 PRINTCHR$(61)TAB(55)CHR$(62)CHR$(63)160 REMLINE150 PUTSTHENEWLYDEFINEDCHARACTERSOt~THESCREE N170 GETA$:REMWAITFORUSERTOPRESSAKEY18121I FA$=""THE~~GOTO171.::1: REMI F~mKE'r'S~.jEREPRESSED,TR'T'AGAIN!19121 POKE53272,21 ,?,5,7,?3,3:REMDATAFORCHARACTER612121121 DATA32,96,224,16121,224,224,192,192;REMD ATAFORCHARACTER6122121 DATA?,7, ,31,95,143,127:REMDATAFORCHARACTER622312 1 DATA224, ,248,248,248,24121,224 ,1 foronand0 dotisoff, , 'reusingstandardhigh-resolutiongraphics, allthedotswithineach8 X 8 , colors:screencolor(backgroundcolorregist er#0),thecolorinbackgroundregister#1,the colorinback-groundcolorregister#2, , ,setbit4 oftheVIC-IIcontrolregisterat53270($D016) toa1 byusingthefollowingPOKE:POKE53270,PEEK(5 3270)OR16 Toturnoffmulti-colorcharactermode,setbit 4 oflocation53270toaobythefollowingPOKE:PO KE53270,PEEK(53270)AND239 Multi-colormodeissetonoroffforeachspaceo nthescreen,sothatmulti-colorgraphicscanb emixedwithhigh-resolution(hi-res) ($D800inHEX).

10 Ifthenumberincolormemoryislessthan8(0-7) thecorrespondingspaceonthevideoscreenwil lbestandardhi-res,inthecolor(0-7)you' thenumberlocatedincolormemoryisgreateror equalto8 (from8 to15), numberintocolormemory, numberfrom0 to7 numberbetween8 ,turningBIT3 ONincolormemory, ,setsthenormal, , ,hereisapictureoftheletterA,anditsbitpat tern:Innormalorhigh-resolutionmode,thesc reencolorisdisplayedeverywherethereisa 0 bit, ,likeso:IMAGEAABBCCCCAABBAABBAACCCCBBAAB BAABBAABBAABBAABBAABBBITPATTERN000110000 0111100011001100111111001100110011001100 110011000000000 Intheimageareaabove,thespacesmarkedAAare drawninthebackground#1color,thespacesmar kedBBusethebackground#2color, ,accordingtothefollowingchart;116 PROGRAMMINGGRAPHICSIMAGEBITPATTERN**0001 1000**00111100**01100110**01111110**0110 0110**01100110**0110011000000000 NOTE:Thespriteforegroundcoloris :leePOKE53281,I:REMSETBACKGROUNDCOLORi0T O~IHITE110 POKE53282,3:REMSETBACKGROUNDCOLORilTOCYA N1213 POKE53283,8:REMSETBACKGROUNDCOLORi2 TOORANGE1313 POKE5327ehPEEK(53270)OR16: REt1 TURr~Ot~t'1 ULTICOLORt10DE1413C=13*4096+8*256:REMSET CTOPOINTTOCOLORt1Et10RY1513 PRItHCHR$(147)"AAAAAAAAAA".


Related search queries