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.
0218 F229
021A D455
021C 6603
021E F618
0220 6620
0222 F615
0224 F607
0226 3600
0228 1224
022A 7301
022C 00E0
022E 1202
I =V2 (LSDP)
SHOW 5MI@V4V5
V6=03
TONE=V6
V6=20
TIME=V6
V6=TIME
SKIP;V6 EQ 00
GO 0224
V3+01
ERASE
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.
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.
4.
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
0206 F265
0208 6400
020A 6500
020C F029
020E D455
0210 7405
0212 F129
0214 D455
0216 7405
MI=V3 (3DD)
VO:V2=MI
V4=00
V5=00
I =VO (LSDP)
SHOW 5MI@V4V5
V4+05
I=Vl(LSDP)
SHOW 5MI@V4V5
V4+05
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.
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
Содержание CDP18S711
Страница 1: ......
Страница 36: ...Appendix C CHIP 8 Interpreter 37 CHIP 8 Operating System Standard Digit Display Format ...
Страница 42: ...68 RCA COSMAC VIP Instruction Manual Fig E 1 Microprocessor and Display Interface Circuits ...
Страница 43: ...Fig E 2 ROM Circuits and Expansion Interface Appendix E Logic Diagrams 69 ...
Страница 45: ...Appendix E Logic Diagram s 71 Fig E 4 RAM Circuits ...
Страница 46: ...Fig E 5 Power Supply Circuit and Byte Input Output Interface 72 RCA COSMAC VIP Instruction Manuel ...
Страница 47: ...Fig E 5 Power Supply Circult and Byte Input Output Interface 72 RCA COSMAC VIP Instruction Manual ...
Страница 49: ...74 RCA COSMAC VIP Instruction Manual ...
Страница 50: ......
Страница 52: ......
Страница 54: ......