Using petcat for cross-developing BASIC programs
The VICE emulator for Commodore computers includes a command-line tool called petcat that can convert between ASCII text files and Commodore BASIC PRG files. It is useful for writing BASIC programs on a modern computer in a text editor, among other things. While VICE does not yet include a MEGA65 emulator, the petcat tool does support creating and reading MEGA65 BASIC programs.
For example, you can write this temperature conversion program in an ASCII text file, like so:
100 print "enter a temperature in degrees fahrenheit:"
110 input f
120 c=(f-32)*5/9
130 print
140 print f;" degrees fahrenheit is ";c;" degrees celsius."
To convert this to a MEGA65 PRG file, use this command:
petcat -w65 -o tempconv.prg -- tempconv.bas
To convert a BASIC PRG back to text:
petcat -65 -o myprog.bas -- myprog.prg
petcat syntax
petcat text files are ASCII text. To fully represent all of the Commodore PETSCII characters that can appear in a BASIC program, including “quoted” control codes in strings, petcat uses a text-based syntax.
Letters, numbers, and punctuation common to both PETSCII and ASCII appear as ASCII. Letters are lowercase.
PETSCII | petcat | Notes |
---|---|---|
|
|
|
|
|
|
|
|
|
Several PETSCII-specific punctuation characters have similar codes as ASCII characters. These appear in petcat listings as their ASCII equivalents.
PETSCII | petcat | Notes |
---|---|---|
|
| See exceptions below for Shift and Mega variants. |
Left arrow |
|
|
Up arrow |
|
|
|
|
|
Graphics characters formed by pressing Shift and a letter are represented by uppercase letters.
PETSCII | petcat | Notes |
---|---|---|
Spade |
| Shift + A |
Heart |
| Shift + S |
Diamond |
| Shift + Z |
Club |
| Shift + X |
All other PETSCII codes use a label syntax in petcat, surrounded by curly brackets: {...}
Shifted non-letter characters are labels with the prefix SHIFT-
. A shifted pound spells out POUND
.
PETSCII | petcat |
---|