The bit of that byte is: BIT = 7-(X AND 7) Now we put these formulas together. The byte in which character memory dot (X,Y) is located is calculated by:
BYTE = BASE + ROW*320+ CHAR*8 + LINETo turn on any bit on the grid with coordinates (X,Y), use this line:
POKE BYTE, PEEK(BYTE) OR 2^BIT
Let's add these calculations to the program. In the following example, the COMMODORE 64 will plot a sine curve:
50 FORX=0TO319STEP.5:REM WAVE WILL FILL THE SCREEN 60 Y=INT(90+80*SIN(X/10)) 70 CH=INT(X/8) 80 RO=INT(Y/8) 85 LN=YAND7 90 BY=BASE+RO*320+8*CH+LN 100 BI=7-(XAND7) 110 POKEBY,PEEK(BY)OR(2^BI) 120 NEXTX 125 POKE1024,16 130 GOTO130
The calculation in line 60 will change the values for the sine function from a range of +1 to -1 to a range of 10 to 170. Lines 70 to 100 calculate the character, row, byte, and bit being affected, using the formulae as shown above. Line 125 signals the program is finished by changing the color of the top left corner of the screen. Line 130 freezes the program by putting it into an infinite loop. When you have finished looking at the display, just hold down <RUN/STOP> and hit <RESTORE>.
This page has been created by Sami Rautiainen. | |
Read the small print. | Last updated May 12, 2002. |