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).
2 VIDEOBANKSELECTIONTheVIC-IIchipcanaccess ("see") , (orsections) neededis ,thechipcan"see" #2(CIA#2).ThePOKEandPEEKBASIC statements(ortheirmachinelanguageversion s)areusedtoselectabankbycontrollingbits0 and1 ofPORTAofCIA#2(location56576(or$DDOOHEX .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.))
3 (Seecharactermemorysection.)SCREENMEMORY T 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).
4 Is alwayslocatedatlocations55296($D800)thro ugh56295($DBE7).Screenmemory(the1000loca tionsstartingat1024) , ,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).
5 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).}
6 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.
7 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).ThentheBankSelectBitsaretakenin toaccountbyaddinginthebaseaddress(seeVID EOBANKSELECTION section).Belowisasimpleformulatoillustra tewhathappens:CHARACTERADDRESS=SCREENCOD E*8+(CHARACTERS ET*2048)+(BANK* 16384)CHARACTERDEFINITIONSE achcharacterisformedinan8 by8 gridofdots, bytesforeachcharacter,witheachbyterepres entingthedotpatternofarowinthecharacter, , (whentheI/Oisswitchedoff).
8 Thefirst8bytesfromlocation53248($DOOO)to 53255($D007)containthepatternforthe@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.
9 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!
10 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?BASIC nowthinksit , ,thereisrandomdatabeginningat12288($3000 HEX).YoumustputcharacterpatternsinRAM(in thesamestyleastheonesinROM) :5 PRINTCHR$(142):REMSWITCHTOUPPERCASE10 POKE52,48:POKE56,48:CLR:REMRESERVEMEMORY FORCHARACTERS20 POKE56334,PEEK(56334) :REt1 TURt.)))))