This extension helps you to write Commodore 64 basic v2 programs (.prg or .bas extension). It provides you: syntax highlighting, snippets, file icons, a theme, tasks, rulers, commands, different views in the Primary Sidebar, and a simple preview.
Rules for snippets come from the following pages of C64-Wiki:
You might follow this process to develop your program:
-
create a folder structure like this:
\ -> root dir \bin -> converted programs \src -> source programs
-
write the program;
-
test it with Vice using the "Convert and Run" (F5) command;
-
create a d64 image using the "created64.sh" script (see Other usefull info and script sections of this README);
-
use this d64 image with a sd2iec device;
-
run it on the real c64 hardware.
You can create the folder structure using Yeoman:
npm install -g generator-c64basicv2
mkdir myC64Project
cd myC64Project
npx yo c64basicv2
The provided features are:
- Syntax highlighting
- Snippets for the main commands
- Snippets for control characters
- File icons
- Theme
- Rulers: 40th and 80th column
- Tasks: suggested in this README
- Keyboard Shortcuts
- Command: Automatic Proofreader, Convert, Convert and Run
- Control character view in the Primary Sidebar
- Sid info view (address, ADSR calculator and notes) in the Primary Sidebar
- Code preview
An example of syntax highlighting is:
Snippets suggest to you the syntax of the commands:
Control characters in c64 basic are special characters like this:
Books and old magazines represent special characters using a symbolic syntax: {ctrl character name}. For example, the previous character is written with this syntax: {clr}.
If you use this control character in a print statement (print "{clr}"), C64 clears the screen.
You can find the list of control characters on this page: Control character.
Snippets for Control character suggest a symbolic character or the corresponding chr$(xxx). In our example: chr$(147).
If you use the chr$ mode, pay attention: Inside a print statement, you have to remove the double apex, print "{clr}" become print {clr} and then print chr$(147).
The best option is using the symbolic representation, petcat will convert the symbol for you. petcat recognize the following symbols:
{CTRL-A} {CTRL-B} {stop} {CTRL-D} {wht} {CTRL-F} {CTRL-G}
{dish} {ensh} {CTRL-K} {CTRL-L} {swlc} {CTRL-O}
{CTRL-P} {down} {rvon} {home} {del} {CTRL-U} {CTRL-V} {CTRL-W}
{CTRL-X} {CTRL-Y} {CTRL-Z} {esc} {red} {rght} {grn} {blu}
{orng} {f1} {f3} {f5}
{f7} {f2} {f4} {f6} {f8} {sret} {swuc}
{blk} {up} {rvof} {clr} {inst} {brn} {lred} {gry1}
{gry2} {lgrn} {lblu} {gry} {pur} {left} {yel} {cyn}
Other details: petcat src
Automatic Proofreader is an error-checking command that helps you to type program listings without mistakes.
This command emulates (I hope) the original "The Automatic Proofreader" program published on COMPUTE!'s Gazette.
An example:
Hit "F1", search "Automatic Proofreader" and press "enter": a popup shows the checksum for the current line.
Since version 0.5.0, "Automatic Proofreader" is displayed on each row after the 80th column.
For others info on "The Automatic Proofreader" original program see Wikipedia.
Use this command to convert the current program to tokenized BASIC using the Vice petcat command. Needed settings:
- c64basicv2.petcat - default value: /usr/bin/petcat
- c64basicv2.convertOutputDir - default value: bin
Hit "F1", search "Convert" and press "enter".
Convert and run the current program using the Vice x64sc command. Needed settings:
- c64basicv2.x64sc - default value: /usr/bin/x64sc
Hit F1, search "Convert and Run" then hit enter.
Using the Control characters view, you can visually add a control character:
Click on the character to add the corresponding symbol in the code, or click on the number to add the chr$ command.
The font is "Pet Me 64", released by Kreative Korporation.
Using this view, you can
- (first section) show Sid registries and add the poke command directly in the code:
- (section ADSR) select the desired envelope and add the calculated value in the code:
- (section Notes) generate data for a melody:
Using the preview button on the editor Toolbar, you can show a panel containing your code formatted like the C64 screen. This view is good for checking control characters.
The preview uses the "Pet Me 64" font, released by Kreative Korporation.
Check lines for errors and warnings.
Checks implemented:
Code | Description | Type |
---|---|---|
OVER80 |
Warns that lines with more than 80 characters cannot be edited in c64, but the program will run | warning |
LINENUN |
Warns that the missing line number will be entered by petcat | warning |
Name | Description | Default value |
---|---|---|
c64basicv2.petcat |
Vice petcat command path | /usr/bin/petcat |
c64basicv2.convertOutputDir |
output dir | bin |
c64basicv2.x64sc |
Vice x64sc command path | /usr/bin/x64sc |
c64basicv2.showCommandLogs |
Enable log diagnostics for commands (OUTPUT Window) | true |
c64basicv2.showInlineAutomaticProofreader |
Enable inline Automatic Proofreader | false |
c64basicv2.enableDiagnostics |
Enable diagnostics for c64 basic v2 text files | false |
c64basicv2.showCtrlCharacterInfo |
Enable control character info on mouse hover | false |
Commands "Convert" and "Convert and Run" replace task settings.
Configure tasks.json
and hit Crtl+Shift+B to convert/run the currently open basic program file to a C64 program with the same name.
Install vice to use petcat and x64sc.
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "Convert between ASCII, PETSCII and tokenized BASIC",
"type": "shell",
"linux": {
"command": "/usr/bin/petcat -w2 -o ./bin/${fileBasename} -- ${file}"
},
"group": {
"kind": "build",
"isDefault": true
},
"options": {
"cwd": "${config:c64basic.vice}"
}
},
{
"label": "Run C64_BASIC prg",
"type": "shell",
"linux": {
"command": "/usr/bin/petcat -w2 -o ./bin/${fileBasename} -- ${file} & /usr/bin/x64sc ./bin/${fileBasename}"
},
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
Folder structure
\ -> root dir
\bin -> converted programs
\src -> source programs
convertAll.sh: to convert all the programs (src folder) between ASCII, PETSCII, and tokenized BASIC.
#!/bin/bash
for filename in ./src/*.prg; do
SOURCE=$(echo $filename)
echo $SOURCE
DEST=$(echo ${SOURCE##*/})
echo $DEST
petcat -w2 -o ./bin/$DEST -- $SOURCE
done
created64.sh: to create a d64 image disk containing all the converted prg
#!/bin/bash
c1541 -format "diskname,1" d64 ./d64/diskname.d64
for filename in ./bin/*.prg; do
SOURCE=$(echo $filename)
echo $SOURCE
DEST=$(echo ${SOURCE##*/})
echo $DEST
c1541 ./d64/diskname.d64 -write $filename $DEST
done
To extract a prg from a d64 image disk and convert it to a text file:
c1541 diskname.d64 -read "file name" filename.prg
petcat -2 -o filename.prg.txt -- filename.prg
Install vice to use petcat, x64sc and c1541.
IMPORTANT If you use vice on Ubuntu remenber to install bin files (kernal, basic, etc.):
- download the zip for Window
- extract files
- copy all folders to /usr/share/vice (leaving out bin)