RCA CDP18S711 manual Applying CHIP-8

Models: CDP18S711

1 55
Download 55 pages 39.85 Kb
Page 15
Image 15

16

RCA COSMAC VIP Instruction Manual

touched any part of a previously displayed pattern. This feature permits programming video games which require knowing if one moving pattern touches or hits another pattern.

Because trying to display two I spots at the same position on the screen results in a 0 spot, you can use the DXYN instruction to erase a previously displayed pattern by displaying it a second time in the same position. (The entire screen can be erased with a single 00E0 instruction.) The following program shows the "8" pattern, shows it again to erase it, and then changes VX and VY coordinates to create a moving pattern:

0200 A210 I=0210

0202 6100 V1=00

0204 6200 V2=00

0206 D125 SHOW 5MI@VlV2

0208 D125 SHOW 5MI@VlV2

020A 7101 V1+01

020C 7201 V2+01

020E 1206 GO 0206

0210 F090

0212 F090

0214 F000

The "8" pattern byte list was moved to 0210 to make room for the other instructions. Try changing the values that VI and V2 are incremented by for different movement speeds and angles. A delay could be inserted between the two DXYN instructions for slower motion.

The FX29 instruction sets I to the RAM address of a five-byte pattern representing the least significant hex digit of VX. If VX =07, then I would be set to the address of a "7" pattern which could then be shown on the screen with a DXYN instruction. N should always be 5 for these built-in hex-digit patterns. Appendix C shows the format for these standard hex patterns. The following program illustrates the use of the FX29 and FX33 instructions:

0200

6300

V3=00

 

0202 A300 I=0300

 

0204

F333

MI=V3

(3DD)

0206

F265

VO:V2=MI

0208

6400

V4=00

 

020A

6500

V5=00

(LSDP)

020C

F029

I =VO

020E

D455

SHOW 5MI@V4V5

0210

7405

V4+05

 

0212

F129

I=Vl(LSDP)

0214

D455

SHOW 5MI@V4V5

0216

7405

V4+05

 

0218 F229 I =V2 (LSDP)

021A D455 SHOW 5MI@V4V5

021C 6603 V6=03

021E F618 TONE=V6

0220 6620 V6=20

0222 F615 TIME=V6

0224 F607 V6=TIME

0226 3600 SKIP;V6 EQ 00

0228 1224 GO 0224

022A 7301 V3+01

022C 00E0 ERASE

022E 1202 GO 0202

This program continuously increments V3, converts it to decimal form, and displays it on the screen.

The FX0A instruction waits for a hex key to he pressed, VX is then set to the value of the pressed key, and program execution continues when the key is released. (If key 3 is pressed, VX=03). A tone is heard while the key is pressed. This instruction is used to wait for keyboard input.

Applying CHIP-8

You should now be able to write some simple CHIP-8 programs of your own. Here are some things to try:

1.Wait for a key to be pressed and show it on the display in decimal form.

2.Show an 8-bit by 8-bit square on the screen and make it move left or right when keys 4 or 6 are held down.

Show an 8-bit square on the screen. Make it move randomly around the screen.

4.Show a single bit and make it move randomly around the screen leaving a trail.

Program a simple number game. Show 100 (decimal) on the screen. Take turns with another player. On each turn you can subtract 1-9 from the number by pressing key 1-9. The first player to reach 000 wins. The game is more interesting if you are only allowed to press a key which is horizontally or vertically adjacent to the last key pressed.

If you are unsure of the operation of any CHIP-8 instruction, just write a short program using it. This step should clear up any questions regarding its operation. In your CHIP-8 programs be careful not to write into memory locations 0000-01FF or you will

Page 15
Image 15
RCA CDP18S711 manual Applying CHIP-8