Commodore 64 Uživatelský manuál

Procházejte online nebo si stáhněte Uživatelský manuál pro Barebones pro PC / pracovní stanice Commodore 64. C64 Programmers Reference Uživatelská příručka

  • Stažení
  • Přidat do mých příruček
  • Tisk
  • Strana
    / 83
  • Tabulka s obsahem
  • KNIHY
  • Hodnocené. / 5. Na základě hodnocení zákazníků

Shrnutí obsahu

Strany 2 - GRAPHICS OVERVIEW

53256 ($D008) to 53263 ($DOOF), contain the information for forming theletter A.Each complete character set takes up 2K (2048 bits) of memory, 8bytes

Strany 3 - GRAPHICS LOCATIONS

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

Strany 4 - SCREEN MEMORY

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

Strany 5 - COLOR MEMORY

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

Strany 6 - 104 PROGRAMMING GRAPHICS

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

Strany 7 - 1EOO- 1FFF

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

Strany 8 - (TURNS INTERRUPTS ON)

Here is an example of a program using standard programmablecharacters:10 REM* EXAMPLE1 *2121REM CREATING PROGRAMMABLE CHARACTERS31 POKE56334.PEEK(5633

Strany 9 - = SCREEN CODE*8+(CHARACTER

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

Strany 10 - PROGRAMMABLE CHARACTERS

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

Strany 11 - PROGRAMMINGGRAPHICS 109

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

Strany 12 - - PEEK(I): NEXT

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

Strany 13 - . . . making your

background colors can be changed on the whole screen instantly. Hereis an example of changing background color register #1:10121POKE53270.PEEK(5327e)O

Strany 14 - 112 PROGRAMMING GRAPHICS

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

Strany 15 - PROGRAMMING GRAPHICS 113

EXTENDED BACKGROUND COLOR MODEExtended background color mode gives you control over the back-ground color of each individual character, as well as ove

Strany 16 - 10 REM* EXAMPLE1 *

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

Strany 17 - MULTI-COLOR MODE GRAPHICS

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

Strany 18 - BIT PATTERN

entire screen is filled with programmable characters, and you makeyour changes directly into the memory that the programmable char-acters get their pa

Strany 19

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

Strany 20 - II ";: REM LT.RED/

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

Strany 21 - COLOR #0 TO BLACK

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

Strany 22 - 120 PROGRAMMING GRAPHICS

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

Strany 23 - BIT MAPPED GRAPHICS

GRAPHICS LOCATIONSSome general information first. There are 1000 possible locations onthe Commodore 64 screen. Normally, the screen starts at location

Strany 24 - CHARACTERSsection you will

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

Strany 25 - MAP AT 8192

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)

Strany 26 - 124 PROGRAMMING GRAPHICS

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

Strany 27 - = Y AND 7

SPRITESA SPRITE is a special type of user definable character which can bedisplayed anywhere on the screen. Sprites are maintained directly bythe VIC-

Strany 28 - = BASE+ ROW*320+ CHAR*8+ LINE

-Co)..,""00Z"'II010.0ciiJ..,Co)J:n.to.)en.VI"U...:;:CDCCD:!):;:irD:J0-nCOLUMN0001 02 0304 05060708 0910 11 12131415 16 171819

Strany 29 - MULTI-COLORBIT MAP MODE

bits) needed to define a sprite. The 63 bytes are arranged in 21 rows of3 bytes each. A sprite definition looks like this:BYTE0BYTE3BYTE6BYTE1BYTE4BYT

Strany 30 - = 1/2 byte = 4 bits)

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

Strany 31 - PROGRAMMINGGRAPHICS 129

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

Strany 32 - PRItHII HELLOII;

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

Strany 33 - DEFINING A SPRITE

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

Strany 34 - ""

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

Strany 35 - POINTERS

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

Strany 36 - TURNING SPRITES ON

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

Strany 37 - MULTI-COLOR MODE

-".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 ($

Strany 38 - EXPANDED SPRITES

~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

Strany 39 - POSITIONING

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

Strany 40 - POKEstatements:

SPRITE POSITIONING SUMMARYUnexpanded sprites are at least partially visible in the 40 column, by25 row mode within the following parameters:1 < = X

Strany 41 - SET BEGINNING

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

Strany 42 - --- 229 ($E5)

SPRITE TO SPRITE COLLISIONSSprite to sprite collisions are recognized by the computer, or flagged,in the spite to sprite collision register at locatio

Strany 43 - - - 54($36)

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

Strany 44 - ,ABI"

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

Strany 45 - = y < = 249

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

Strany 46 - COLLISION DETECTS

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

Strany 47 - SPRITE TO DATA COLLISIONS

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

Strany 48 - SPRITE DATA *****

OTHER GRAPHICS FEATURESSCREEN BLANKINGBit 4 of the VIC-II control register controls the screen blanking func-tion. It is found in the control register

Strany 49 - 'mil"

INTERRUPT STATUS REGISTERThe interrupt status register shows the current status of any interruptsource. The current status of bit 2 of the interrupt r

Strany 50 - =1THE~m>,;=- Dr.:: REt1 IF

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

Strany 51 - POSITImJ

PROGRAMMING SPRITES-ANOTHER LOOKFor those of you having trouble with graphics, this section has beendesigned as a more elementary tutorial approach to

Strany 52 - OTHER GRAPHICS FEATURES

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

Strany 53 - = stored raster count

LINE 70 determines the HORIZONTALor "X" POSITION of the spriteon the screen. This number represents the location of the UPPER LEFTCORNER of

Strany 54 - . = EXCELLENT

CRUNCHING YOUR SPRITE PROGRAMSHere's a helpful "crunching" tip: The program described above is already short, but itcan be made even sh

Strany 55 - AllDramE

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

Strany 56 - . . . but V+21 requires less

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

Strany 57 - PROGRAMMING GRAPHICS 155

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

Strany 58 - TV SCREEN

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

Strany 59 - =229 X =229, Y =231 I

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

Strany 60

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

Strany 61 - . . . POKEthe X POSI

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

Strany 62 - ...raI!tJ!n

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

Strany 63 - PROGRAMMING GRAPHICS 161

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

Strany 64 - 4 2 6 842 1 8 4 2 6 842 1

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

Strany 65 - . . . STEP BY STEP

,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

Strany 66 - 164 PROGRAMMING GRAPHICS

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.~.":

Strany 67 - POKEs the sprite

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

Strany 68 - VERTICAL SCROLLING

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

Strany 69 - ,,&lIB

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

Strany 70 - Emil'

LINE 25:FORS2 =12352TO 12414READQ2POKES2,Q2NEXTLINE30:FORS3= 12416TO 12478READQ3POKES3,Q3NEXTLINE 35:POKEV+39,15POKEV+ 1,68The second shape of sprite

Strany 71 - PROGRAMMINGGRAPHICS 169

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

Strany 72 - TO 12414

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

Strany 73 - B8 key and press the key

LINE 75:IFP=193THENGOSUB300UNE 80:POKE2040,PFORT= lT060:NEXTLINE85:P=P+1IFP>194THENP= 192If the sprite pointer is set to '193 (the secondsprit

Strany 74 - - (0 times 256) or o. When

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

Strany 75 - PROGRAMMING GRAPHICS 173

LINE 200:POKES+4,129POKES+4,128RETURNLINE 300:POKES+11,129POKES+ll,128RETURNWaveform control set to 129 turns on the soundeffect.Waveform control set

Strany 76 - LINES100-109

EASY SPR1TEMAKING CHART176 PROGRAMMING' GRAPHICSSPRITE SPRITE SPRITE SPRITESPRITE SPRITESPRITE SPRITE0 1 2 3 ..5 67Turn on SpriteV+21,r V+21,2 V+

Strany 77 - LINE 300:

SPRITEMAKING NOTESAlternative Sprite Memory Pointers and Memory LocationsUsing Cassette BufferTURNING ON SPRITES:You can turn on any individual sprite

Strany 78 - EASY SPR1TEMAKING CHART

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

Strany 79 - SPRITEMAKING NOTES

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

Strany 80 - MEMORY LOCATION:

PRIORITY:Priority means one sprite will appear to move "in front of" or "behind"another sprite on the display screen. Sprites with

Strany 81 - PROGRAMMING GRAPHICS 179

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

Strany 82 - I 8 I 4 I 2 I 1 I

USING GRAPHIC CHARACTERS IN DATA STATEMENTSThe following program allows you to .create Q.sprite using blanks andsolid circles ( ').in DATAstateme

Strany 83 - "

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

Žádné komentáře