CSL Language Reference
CSL (CPC Script Language) is a domain-specific language for scripting CPC emulator interactions and automating testing scenarios.
Overview
CSL scripts consist of commands that control emulator behavior, simulate user input, and verify program state. Scripts are executed sequentially.
Basic Syntax
Comments
Commands
Commands are typically one per line:
Common Commands
LOAD
Load a program or disk image.
WAIT
Pause execution for a specified duration.
KEYPRESS
Simulate a key press.
TYPE
Type a string of characters.
CHECK
Verify screen content or memory state.
SCREENSHOT
Capture a screenshot.
RESET
Reset the emulated CPC.
Data Types
Strings
Enclosed in double quotes, with escape sequences:
Numbers
Decimal, hexadecimal, or binary:
Time Durations
With unit suffixes:
Key Names
Special key identifiers:
SPACE, RETURN, ESC, TAB
F1, F2, ..., F9
UP, DOWN, LEFT, RIGHT
CTRL, SHIFT, ALT
A, B, C, ..., Z
0, 1, ..., 9
Control Flow
Labels
GOTO
IF/ENDIF
Advanced Features
Variables
Loops
Assertions
Best Practices
- Use Comments: Document script purpose and complex sections
- Meaningful Waits: Allow sufficient time for program reactions
- Incremental Testing: Test scripts step-by-step
- Error Handling: Use CHECK/ASSERT for validation
- Modular Scripts: Break complex automation into smaller files
Example Script
Complete example for automated game testing:
# Load game disk
LOAD "mygame.dsk"
# Wait for BASIC prompt
WAIT 1s
# Type and run loader
TYPE "RUN\"LOADER"
KEYPRESS RETURN
# Wait for title screen
WAIT 5s
CHECK SCREEN "PRESS SPACE"
# Start game
KEYPRESS SPACE
WAIT 2s
# Verify game started
CHECK SCREEN "LEVEL 1"
# Take screenshot
SCREENSHOT "level1_start.png"
# Play sequence
KEYPRESS RIGHT
WAIT 500ms
KEYPRESS SPACE
WAIT 500ms
# Verify score increase
CHECK SCREEN "SCORE:"
# Success
Error Messages
Common CSL parsing errors:
- Unexpected token: Invalid syntax
- Unknown command: Unrecognized command name
- Invalid argument: Wrong argument type or format
- Unterminated string: Missing closing quote
- Undefined label: GOTO to non-existent label
See Also
- CSLCLI Command Reference
- Examples
- CPC demo-scene scripting guides