GPL-2 Syntax

Information

I can't be sure this pseudo command syntax is indeed called GPL-2, however I do expect GPL was used for all language variants for the RCA Video Coin Arcade machine and FPL for the FRED 1.5. Mainly based on the FPL-4 and GPL-4 which both are running the Coin and Computer bowling games on both the Arcade and FRED machine. As this version is running the 'Swords' games and FPL-2 is running 'Curses Foiled Again', i.e. the Swords game I have taken the liberty to call this GPL-2. If you have any proof that this is incorrect please let me know.

GPL-2 is used in the games 'Swords', 'Touche !!', 'En Garde !!', 'Chase', 'Mines 1', 'Mines 2' and 'Kaleidoscope'. All running on the RCA Video Coin Arcade machine.

V0-F are stored on memory locations 0800-080F.

This info is also available online on the Emma 02 site.

Definitions

aaa 12 bit address
kk 8 bit constant
n 4 bit constant
o 4 bit constant with value 8-F
p 4 bit constant with value 0-7
x Register number Vx (x = 0 to F)
y Register number Vy (y = 0 to F)
z Register number Vz (y = 0 to F)
. Not used, value doesn't matter
1..9, A..F Hexadecimal digits

Syntax

5xyz ADD Vz, Vx+Vy Vz = Vx + Vy, V0 = carry
5xyx ADD Vx, Vy Vx = Vx + Vy, V0 = carry
9xyz AND Vz, Vx&Vy Vz = Vx AND Vy
9xyx AND Vx, Vy Vx = Vx AND Vy
2aaa CALL aaa Call subroutine at aaa. The subroutine must end in 30 (which is the 'GPL-2' equivalent of RETURN). Note only 1 level call is allowed as return address is stored in R9
A0 CLS Clear display
80kk DELAY kk Delay of value kk
A1yz DRW Vx, Vz Draw 4*8 pattern in Vy on screen position Vz. Shapes of pattern fetched from shape table at 0423.
A2yz DRW Vx/Vy, Vz Draw 4*8 patterns from the pattern table starting at location VxVy (Vy=Vx+1), end of pattern table should be hex ff, drawing on screen position Vz.
A3yz DRW B, Vy, Vz Draw 4*8 BCD value of Vy to screen. If Vz contains hex A draw on bottom left otherwise draw on right of the screen. Value is extended with two zeros, i.e. 5 digits.
Cxkk DRW D, Vx, kk Used in Chase only, x != 0. Draw 5 dots on screen position kk+y, value y is added from table on 44D, dots are drawn based on if bit 0 to 4 in Vx are 0 or 1. Note bit 4 should always be '1'. This is used to draw the cursor keys at the start with fire flashing
0aaa JZ V0, aaa Jump to aaa if V0 = 0
1aaa JNZ V0, aaa Jump to aaa if V0 != 0
31kk JP FIREA, kk
'EF1', kk
If EF1 jump to address kk in current page (i.e JP on FIRE A)
32kk JP 'EF2', kk If EF2 jump to address kk in current page
33kk JP FIREB, kk
'EF3', kk
If EF3 jump to address kk in current page (i.e JP on FIRE B)
34kk JP COIN, kk
'EF4', kk
If EF4 jump to address kk in current page (i.e JP on COIN).
C.yz KEY Vy, Vz Vy = direction key pad A, Vz = direction key pad B. If RF = 0, jump to 'end game'
8aaa LD RE, aaa RE = 0aaa, except for 80kk instruction
5xyz LD Vz, Vx+Vy Same as ADD: Vz = Vx + Vy, V0 = carry
6xyz LD Vz, Vx-Vy Same as SUB: Vz = Vx - Vy, V0 = carry
30 RETURN Return from CALL by restoring R9 to PC (R5)
Fxkk RND Vx, kk Vx = random AND kk
A0 SCR CLS Clear display
AF SCR XOR XOR screen content with hex FF
Expq SP C, n, z Copy sprite table from n to z, first two and last byte are fetched from 7C0 table (p=n, q=z, both 0-7). Code for this command is available in all games but the table at 7C0 is only defined for the Chase and Mines 1/2 games, command is not actually used or working in the other games.
Sprite commands use a sprite definition table with 5 locations per sprites and 8 sprites (0-7). Starting at address 840.
Pos 0: not sure what this is for
Pos 1: Vertical offset
Pos 2: Horizontal offset
Pos 3: Start position last sprite
Pos 4: Sprite pattern location; i.e. reference to sprite pattern table on 7kk. First byte on that table: low nibble is number of lines, high byte is width in bytes
Dokk SP D, n, kk DRW sprite n from 7kk (o=n+8)
Dpkk SP D, n, Vy, Vz Draw sprite n, Vy will be stored on first location of sprite definition table, Vz on the vertical offset. Meaning the sprite will be drawn Vz lines lower than the last sprite n. The next instruction will be skipped if there is no sprite collision (p=n)
Bokk SP O, n, kk SPrite Offset for sprite n (0-7): vertical = 0 and horizontal = kk (o=n+8)
Bpkk SP P, n, kk SPrite Patern location for sprite n (0-7) = 7kk (p=n)
E0pz SP Vz, P, n Vz = Sprite pattern location (p=n)
6xyz SUB Vz, Vx-Vy Vz = Vx - Vy, V0 = carry
6xyx SUB Vx, Vy Vx = Vx - Vy, V0 = carry
7aaa SYS aaa Call CDP1801 code at aaa. The subroutine must end in a RET (D4). Most games include 2 routines. One to check bit 0/1 from PAR and return value in RF which is likely used for game end score check (the higher RF the higher the end score). A second routine will skip next instruction if test mode is not active (INP5 != 8), the next instruction is a jump to address hex A00, this will cause a crash as no 'test ROM' is loaded at that location!