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
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
1.Wait for a key to be pressed and show it on the display in decimal form.
2.Show an
Show an
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
If you are unsure of the operation of any