Simon (Amstrad CPC) by Copper France
About
SIMON
This is very simple Simon game for the Amstrad CPC.
Keyboard arrows are used to repeat the sequence of tones and lights.
TECHNICAL PART
The game works on all Amstrad CPC (using only BASIC 1.0)
1) Control Characters
The game use a lot of Control characters to replace MODE, PAPER, CLS, BORDER, INK in only one PRINT in the first line :
MODE is CHR$(4)+"0" FOR MODE 0
PAPER is CHR$(14)+"1" FOR PAPER 1
CLS is CHR$(12)
INK is CHR$(18)+CHR$(16+i)+CHR$(64+v)+CHR$(64+v) for INK i,v,v (16+i to avoid \0 and 64+v to avoid \0 and ")
BORDER is CHR$(29)+CHR$(64+13) for BORDER 13,13 (At the end so last CHR$(13) done by PRINT)
Graphics Or Mode CHR$(23)+CHR$(3) is used to draw color keys behind black circles and background color.
CHR$(30) is used to replace LOCATE 1,1 and CHR$(14) for PEN before printing score
CHR$(31) is used to replace LOCATE before printing high-score
2) Graphics Or Mode
Colors 2,4,6,8 are used for color keys
Color 1 is used for background
Color 15 is used for black discs
With Or Mode color keys (2,4,6,8) become (3,5,7,9) when drawn above background that's why they use same INK as the background
With Or Mode anything drawn above color 15 is not visible (x Or 15 = 15)
3) Listing description
Line 1: Graphics initialization in one PRINT / DEFINT for speed / DATAs for radius of 3 discs
Line 2: ORIGIN in center of screen / Loop for drawing discs / DATAs for color keys (INK value / SOUND period, INKEY value)
Line 3: Radius square / Loop for drawing disc / Graphics Or Mode
Line 4: Loop for drawing keys
Line 5: Loop for drawing X above keys / Array initialization
Line 6: Simon initialization or loose
Line 7: New tone light checking it's different of the previous one / Sequence play
Line 8: Sequence repeat and check
Line 9: Sequence repeat and check / High-score
Line 10 : Sub routine to light up and play a tone
5) Variables
s,t : Coordonnate for X drawn above keys
i : Loops
p : Graphics pen of disc (15 / 0 / 15) / Key number
r : Radius of disc
a : Radius square of disc
x : Loop for abscissa between -r and r
y : Ordinate / Loop for keys
p() : Array of keys
d : Duration of sound
n : Number of tones in the sequence
m : High-score
c() : Array of INK values
s() : Array of SOUND periods
k() : Array of INKEY values