53256 ($D008) to 53263 ($DOOF), contain the information for forming theletter A.Each complete character set takes up 2K (2048 bits) of memory, 8bytes
2) Your character set takes memory space away from your BASICprogram. Of course, with 38K available for a BASIC program,most applications won't h
See the change? BASIC now thinks it has less memory to work with. Thememory you just claimed from BASICis where you are going to put yourcharacter set
Remember that we only took the first 64 characters. Something elsewill have to be done if you want one of the other characters.What if you wanted char
Now type RUN. The program will replace the letter T with a smile facecharacter. Type a few 1's to see the face. Each of the numbers in theDATA st
The Programmable Character Worksheet (Figure 3-1) will help youdesign your own characters. There is an 8 by 8 matrix on the sheet, withrow numbers, an
Here is an example of a program using standard programmablecharacters:10 REM* EXAMPLE1 *2121REM CREATING PROGRAMMABLE CHARACTERS31 POKE56334.PEEK(5633
MULTI-COLOR MODE GRAPHICSStandard high-resolution graphics give you control of very small dotson the screen. Each dot in character memory can have 2 p
By POKEing a number into color memory, you can change the color ofthe character in that position on the screen. POKEing a number from 0 to7 gives the
NOTE: The sprite foreground color is a 10. The character foreground color is a 11.Type NEW and then type this demonstration program:lee POKE53281,I:RE
GRAPHICS OVERVIEWAll of the graphics abilities of the Commodore 64 come from the 6567Video Interface Chip (also known as the VIC-II chip). This chip g
background colors can be changed on the whole screen instantly. Hereis an example of changing background color register #1:10121POKE53270.PEEK(5327e)O
Here is an example of a program using multi-color programmablecharacters:10 REM ~ EXAMPLE 2' ~2(1 REt1 CF.:EAT II.m t1ULT I COLOR PROGRAt1t1ABLE
EXTENDED BACKGROUND COLOR MODEExtended background color mode gives you control over the back-ground color of each individual character, as well as ove
Extended color mode is turned OFF by setting bit 6 of the VIC-II regis-ter to a 0 at location 53265 ($D011). The following statement will do this:POKE
8K section of memory on the TV screen. When in bit map mode, you candirectly control whether an individual dot on the screen is on or off.There are tw
entire screen is filled with programmable characters, and you makeyour changes directly into the memory that the programmable char-acters get their pa
To SET a dot (turn a dot ON) or UNSETa dot (turn a dot OFF) you mustknow how to find the correct bit in the character memory that you haveto set to a
However, what you actually have is something like this:w~Zo=;3!l.0OCr!1--~BYTE 0BYTE 1BYTE 2.BYTE 3BYTE 4BYTE 5_BYTE 6BYTE7BYTE 8BYTE 9BYTE 10BYTE 11B
The bit of that byte is:BIT= 7-(X AND 7)Now we put these formulas together. The byte in which charactermemory dot (X,Y) is located is calculated by:BY
As a further example, you can modify the sine curve program to dis-playa semicircle. Here are the lines to type to make the changes:50 FORX=0T0160:REM
GRAPHICS LOCATIONSSome general information first. There are 1000 possible locations onthe Commodore 64 screen. Normally, the screen starts at location
Multi-color bit mapped mode is turned OFF by setting bit 5 of 53265($0011) and bit 4 at location 53270 ($0016) to a O. The following POKEdoes this:POK
1) Shrink the screen (the border will expand).2) Set the scrolling register to maximum (or minimum value depend-ing upon the direction of your scroll)
ing register is set to 0, the first line is covered, ready for new data.When the Y scrolling register is set to 7 the last row is covered.For scrollin
SPRITESA SPRITE is a special type of user definable character which can bedisplayed anywhere on the screen. Sprites are maintained directly bythe VIC-
-Co)..,""00Z"'II010.0ciiJ..,Co)J:n.to.)en.VI"U...:;:CDCCD:!):;:irD:J0-nCOLUMN0001 02 0304 05060708 0910 11 12131415 16 171819
bits) needed to define a sprite. The 63 bytes are arranged in 21 rows of3 bytes each. A sprite definition looks like this:BYTE0BYTE3BYTE6BYTE1BYTE4BYT
If sprite pointer #0, at location 2040, contains the number 14, forexample, this means that sprite 0 will be displayed using the 64 bytesbeginning at
TURNING SPRITES OFFA sprite is turned off by setting its bit in the VIC-lIcontrol register at53269 ($0015 in HEX) to a O. The following POKE will do t
below gives you the bit pair values needed to turn ON each of the fourcolors you've chosen for your sprite:BIT PAIR DESCRIPTION00 TRANSPARENT,SCR
To unexpand a sprite in the horizontal direction, the corresponding bitin the VIC-II control register at location 53277 ($DOID in HEX) must beturned O
This 16K bank concept is part of everything that the VIC-II chip does.You should always be aware of which bank the VIC-II chip is pointingat, since th
comes the X register for sprite 1, the Y register for sprite 1, and so on.After all 16 X and Y registers comes the most significant bit in the Xpositi
than enough register locations to handle moving a sprite up and down.You also want to be able to smoothly move a sprite on and off thescreen. More tha
-".o...'"o~ZC>C>~...:rnC/I'ftcO.e;Co)ICo)en"U...:;:CDo (SOO) 24 (S18)I II II II I29 (S1D) -- - L _II50 (S32) ___I208 ($
~II>:;:cr~:rcon:s-a::I-!II"'"oG')~~zG')G')~"J:nVI~7 ($07) 31 ($1F)I II II 1I II 133 ($211 __ - _1__1I54 ($36) I2
256 (on the left side of the screen), then the X MSB of that sprite mustbe 0 (turned OFF). Bits 0 to 7 of the X MSB register correspond to spriteso to
SPRITE POSITIONING SUMMARYUnexpanded sprites are at least partially visible in the 40 column, by25 row mode within the following parameters:1 < = X
SPRITE DISPLAY PRIORITIESSprites have-the ability to cross each other's paths, as well as cross infront of, or behind other objects on the screen
SPRITE TO SPRITE COLLISIONSSprite to sprite collisions are recognized by the computer, or flagged,in the spite to sprite collision register at locatio
10 REM SPRITE EXAMPLE 1...20 REM THE HOT AIR BALLOON30 VIC=13~4096:REM THIS IS WHERE THE VIC REGISTERSBEGIN35 POKEVIC+21,1:REM ENABLE SPRITE036 POKEVI
10 REt'l SPRITE E:":AMPLE 2...20 REM THE HOT AIR BALLOON AGAIN30 VIC=13*4096:REM THIS IS WHERE THE VIC REGISTERSBEGIN35 POKEVIC+21,63:REM EN
Where" A" has one of the following values:'Remember that the BANK ADDRESS of the VIC-II chip must be added in.You must also tell the KE
400 I FK=40FH.m 0::PEEK 0::I.,.'I C+ 16) At.m 1) =1THE~m>,;=- Dr.:: REt1 IFSPRITE IS...410 REM TOUCHING THE RIGHT EDGE, THEN REVERSE IT420 IFX
36 POKEVIC+33, 14:REM SET BACKGROUND COLOR TO LIGHTB..LUE37 POKEVIC+23,1:REM EXPAND SPRITE 121IN ~38 POKE~IC+29,1:REM EXPAND SPRITE 121IN X40 POKE2€14
OTHER GRAPHICS FEATURESSCREEN BLANKINGBit 4 of the VIC-II control register controls the screen blanking func-tion. It is found in the control register
INTERRUPT STATUS REGISTERThe interrupt status register shows the current status of any interruptsource. The current status of bit 2 of the interrupt r
You can also display more than 8 sprites in the same way. Unfortu-nately BASIC isn't fast enough to do this very well. So if you want to startusi
PROGRAMMING SPRITES-ANOTHER LOOKFor those of you having trouble with graphics, this section has beendesigned as a more elementary tutorial approach to
LINE 40 sets the variable "V" equal to 53248, the starting address ofthe VIDEO CHIP. This entry lets us use the form (V+number) for spritese
LINE 70 determines the HORIZONTALor "X" POSITION of the spriteon the screen. This number represents the location of the UPPER LEFTCORNER of
CRUNCHING YOUR SPRITE PROGRAMSHere's a helpful "crunching" tip: The program described above is already short, but itcan be made even sh
POSITIONING SPRITES ON THE SCREENThe entire display screen is divided into a grid of X and Y coordi-nates, like a graph. The X COORDINATE is the HORIZ
on the keyboard. One of the features of the Commodore 64 is the abilityto use patterns located in RAM memory. These RAM patterns arecreated by you, an
To display a sprite in a given location, you must POKE the X and Ysettings for each SPRITE. . . remembering that every sprite has its ownunique X POKE
let's see how this X-V positioning works, using sprite 1. Type this pro-gram:-'!mil G!DD10 PRINT"~~3248:POKEV+21.2:POKE2041.13:FOP::;=8
This'POKEstarts the X numbering over again from 0 at the 256th posi-tion (Example: POKE V+16, PEEK(V+16)OR 1 and POKE V,1 must beincluded to plac
This line POKEs V+16 with the number required to "open up" the rightside of the screen. . .the new X position 24 for sprite 0 now begins 24p
DRAWING A SPRITEDrawing a Commodore sprite is like coloring the empty spaces in acoloring book. Every sprite consists of tiny dots called pixels. To d
CREATING A SPRITE . . . STEP BY STEPTo make this as easy as possible for you, we've put together thissimple step by step guide to help you draw y
puters as a special way of counting. Here's a close-up view of the firsteight pixels in the top left hand corner of the sprite:STEP4:Add up the n
STEP 8:CRUNCH YOUR PROGRAM INTO A SMALLER SPACE BY RUNNING TO-GETHER ALL THE DATA'STATEMENTS, AS SHOWN IN THE SAMPLE PRO-GRAM BELOW. Note that we
,Here's a line which moves the sprite BACKAND FORTH:50 POKE V+5,100:FOR X=24T0255:POKE V+4,X:NEXT: POKEV+16,4:FOR X=OT065: POKE V+4,X: NEXT X55 F
5 8=54272: POKES+24~, 15: POKES., 22121: POKES+ 1.-68 : POKES+5,15:POKES+6,2151121POKES+7,120:POKES+8,100:POKES+12,15:POKES+13,215'~III.~.":
The ROM IMAGE in the above table refers to the character generatorROM. It appears in place of RAM at the above locations in bank O. Italso appears in
LINE 5:5=54272POKES+24, 15'POKES,220POKES+ 1,68POKES+5,15POKES+6~215LINE' 10:POKES+7,120POKES+8,100POKES+12,15POKES'+13,2l5LINE 15:PRIN
LINE 20:FORS 1 = 12288TO 12350READ Q 1POKES1,Q1NEXTWe are going to use ONE SPRITE(sprite 0) in thisanimation, but we are going to use THREEsets ofspri
LINE 25:FORS2 =12352TO 12414READQ2POKES2,Q2NEXTLINE30:FORS3= 12416TO 12478READQ3POKES3,Q3NEXTLINE 35:POKEV+39,15POKEV+ 1,68The second shape of sprite
LINE 40:PRINTTAB(160)I AM THEDANCINGMOUSE!mil"LINE 45:P= 192LINE 50:FORX=OT0347STEP3Tabs 160 spaces from the top lefthand CHAR-ACTERSPACEon the s
LINE 55:RX=INT(X/256)LX=X-RX*256LINE 60:POKEV,LXPOKEV+16,RXLINE 70:IFP= 192THENGOSUB200RXis the integer of X/256 which means that RXisrounded off to 0
LINE 75:IFP=193THENGOSUB300UNE 80:POKE2040,PFORT= lT060:NEXTLINE85:P=P+1IFP>194THENP= 192If the sprite pointer is set to '193 (the secondsprit
LINE90:N EXTXLINE 95ENDLINES100-109DATAAfter the sprite has become one of the 3 differentshapes defined by the DATA, only then is itallowed to move ac
LINE 200:POKES+4,129POKES+4,128RETURNLINE 300:POKES+11,129POKES+ll,128RETURNWaveform control set to 129 turns on the soundeffect.Waveform control set
EASY SPR1TEMAKING CHART176 PROGRAMMING' GRAPHICSSPRITE SPRITE SPRITE SPRITESPRITE SPRITESPRITE SPRITE0 1 2 3 ..5 67Turn on SpriteV+21,r V+21,2 V+
SPRITEMAKING NOTESAlternative Sprite Memory Pointers and Memory LocationsUsing Cassette BufferTURNING ON SPRITES:You can turn on any individual sprite
access character data the ROM is switched in. It becomes an image inthe 16K bank of memory that the VIC-II chip is looking at. Otherwise,the area is o
SPRITE COLORS:To make sprite 0 WHITE, type: POKE V+39,1 (use COLOR POKE SET-TING shown in chart, and INDIVIDUALCOLOR CODES shown below):0- BLACK1-WHIT
PRIORITY:Priority means one sprite will appear to move "in front of" or "behind"another sprite on the display screen. Sprites with
Look at the horizontal 8-pixel row shown below. This block sets thefirst two pixels to background color, the second two pixels to Multi-Color1, the th
USING GRAPHIC CHARACTERS IN DATA STATEMENTSThe following program allows you to .create Q.sprite using blanks andsolid circles ( ').in DATAstateme
STANDARD CHARACTER MODEStandard character mode is the mode the Commodore 64 is in whenyou first turn it on. It is the mode you will generally program
Komentáře k této Příručce