SupportIf you like the "ZX81 BASIC to P-File Converter" please consider supporting it. ZX81 BASIC to P-File ConverterThis extension can do two things:
During conversion, REM lines are fully restored. This means all machine code will remain intact and survive back-and-forth conversion. You can use this tool for:
There is also a viewer for P-Files included that shows the system variables, the BASIC code (in both hex and BASIC text), the DFILE (screen) area, and the BASIC variables area. InstallationInstall through the Visual Studio Code Marketplace. The extension is called "ZX81 BASIC to P-File Converter" (zx81-bastop). UsageP-FilesRight-click on a .p file in the explorer area. Choose:
BASIC FilesRight-click on a .bas file in the explorer area or in an opened editor. Choose "Convert ZX81 BASIC to P-File." This will open a file selector that asks for a file name for the P-File. If you have DeZog installed you can also directly run the BASIC program on a ZX81 emulator inside vscode. In the upper right you find a "run" icon (the triangle). Click to run: You can also select the memory configuration: More Info
The BASIC Text FormatThe generated BASIC text format is mainly similar to the zxtext2p format. The main difference is that labelled code is not supported. However, this extension uses the same escape codes and graphic codes. Additionally, a "bracketized tokens" mode is supported. Each command token can be enclosed in square brackets (e.g. "[PRINT]") to clearly differentiate it from single characters (e.g. "P," "R," "I," "N," "T"). Furthermore, it is possible to add more information into the comment lines. Normal comment lines (like in zxtext2p) start with a '#'. If a line starts with '#!', it is a special comment that can define additional properties for the P-File generation. If you don't use any '#!' in your BASIC program, a P-File is created that contains the BASIC program, but an empty DFILE (blank screen) and no BASIC variables section. When you load the P-File, it is loaded but not started. To make the program automatically start, you need to add a special comment like:
which will start the BASIC program at line 100 after loading. With lines like:
you would create a DFILE with the text "HELLO" "WORLD" spanning over two lines, starting at the second line and the third column. You can omit the trailing (unused) DFILE lines. When converting, they are appended automatically. By default, an expanded DFILE is created. If you want to use a collapsed DFILE, you can add:
For completeness, here is also the BASIC variables section, e.g.:
This will hold the data for the BASIC variables used. It is not something you should normally edit yourself. It is generated by the P-File conversion to allow converting the BASIC program back to a P-File while maintaining the variables section. Upper/Lower CaseThe P-File to BASIC conversion always uses uppercase. However, the BASIC to P-File conversion is case insensitive. If you want to turn a P-File to BASIC converted file into lowercase, you can use VSCode's built-in functionality: Select all text, then choose the command palette option "Transform to lowercase." tasks.jsonConversion of the *.bas file to a P-File can be put in tasks.json for automation. Just like a compiler/build. E.g. use:
to convert Recommended Other Extensions
|