RCA CDP18S711 III. CHIP-8 Language Programming, 0200 A20A I=020A 0202 6100 V1=00 0204 6200 V2=00

Models: CDP18S711

1 55
Download 55 pages 39.85 Kb
Page 14
Image 14
III. CHIP-8Language Programming

III. CHIP-8Language Programming

15

Fig. 1 - Display screen coordinate structure.

pattern for the digit "8" on the screen. First we make up a pattern of bits to form "8" as shown in Fig. 2.

Fig. 2 - Patternof bitsjorming digit 8.

In this example we made the "8" pattern five spots high by four spots wide. Patterns to be shown on the screen using the DXYN instruction must always be one byte wide and no more than fifteen bytes high. (Several small patterns can be combined to form larger ones on the screen when required). To the right of the."8" pattern in Fig. 2 are the equivalent byte values in hex form. We could now store this pattern as a list of five bytes at RAM location 020A as follows:

020A F0

020B 90

020C F0

020D 90

020E F0

Suppose we now want to show this pattern in the upper left corner of the screen. Well assign V I= VX and V2=VY. Now we let VI=V2=00 and set I=020A. If we now do a D125 instruction, the "8"

pattern will be shown on the screen in the upper left corner.

You can write a program to show the "8" pattern on the screen as follows:

0200 A20A I=020A

0202 6100 V1=00

0204 6200 V2=00

0206 D125 SHOW 5MI@VlV2

0208 1208 GO 0208

020A F090

020C F090

020E F000

The first column of this program shows the memory locations at which the instruction bytes in the second column are stored. The third column indicates the function performed by each instruction in shorthand form. Only the bytes in the second column are actually stored in memory.

With the CHIP-8 interpreter stored at 0000-OIFF, you can load the above program in memory and run it. Set VI and V2 to different values to relocate the “8" pattern on the screen. The VX-VY coordinates always specify the screen position of the upper lefthand bit of your pattern. This bit can be either 0 or 1. The last digit of the DXYN instruction specifies the height of your patterns or the number of bytes in your pattern list.

When a pattern is displayed, it is compared with any pattern already on the screen. If a 1 bit in your ,pattern matches a I bit already on the screen, then a 0 bit will be shown at this spot position and VF will be set 1,6 it value of 01. You can test VF following a DXTN instruction to determine if your pattern

Page 14
Image 14
RCA CDP18S711 III. CHIP-8 Language Programming, 0200 A20A I=020A 0202 6100 V1=00 0204 6200 V2=00, 020C F090 020E F000