+Rick Reynolds Posted May 9, 2021 Share Posted May 9, 2021 Hi again everyone. Thanks to the community for the help in this other thread where I had asked about cross-assemblers for 6502 code targeting the PET: I have a sort-of-related question. Let's say I want to write a program in BASIC targeting the PET. Can I write the code on a modern computer and then somehow generate a .prg that has that BASIC program on it which could then be read by the PET? I understand that I could write the BASIC code right on the PET in vice and then figure out how to create a blank .d64 and save the program, so that's a technique that is available. But do folks write BASIC programs for these older computers using modern editors, saving to plain ASCII, and then somehow producing a valid BASIC saved program file in a sort-of-cross-compiling kind of way? Thanks again! Rick Quote Link to comment Share on other sites More sharing options...
brain Posted May 9, 2021 Share Posted May 9, 2021 petcat in the VICE bundle. Usage: petcat [-c | -nc] [-h | -nh] [-text | -<version> | -w<version>] [-skip <bytes>] [-l <hex>] [--] [file list] [-k[<version>]] -help Output this help screen here -v Same as above -c controls (interpret also control codes) <default if textmode> -nc no controls (suppress control codes in printout) <default if non-textmode> -ic interpret control codes case-insensitive -h write header <default if output is stdout> -nh no header <default if output is a file> -skip <n> Skip <n> bytes in the beginning of input file. Ignored on P00. -text Force text mode -<version> use keywords for <version> instead of the v7.0 ones -w<version> tokenize using keywords on specified Basic version. -k<version> list all keywords for the specified Basic version -k list all Basic versions available. -l Specify load address for program (in hex, no loading chars!). -o <name> Specify the output file name -f Force overwritten the output file The default depends on the BASIC version. Versions: 1 PET Basic V1.0 2 Basic v2.0 super Basic v2.0 with Super Expander (VIC) turtle Basic v2.0 with Turtle Basic by Craig Bruce (VIC) mighty Basic v2.0 with Mighty Basic by Craig Bruce (VIC) a Basic v2.0 with AtBasic (C64) simon Basic v2.0 with Simon's Basic extension (C64) speech Basic v2.0 with Speech Basic v2.7 (C64) F Basic v2.0 with Final Cartridge III (C64) ultra Basic v2.0 with Ultrabasic-64 (C64) graph Basic v2.0 with Graphics basic (C64) WSB Basic v2.0 with WS basic (C64) WSBF Basic v2.0 with WS basic final (C64) Pegasus Basic v2.0 with Pegasus basic 4.0 (C64) Xbasic Basic v2.0 with Xbasic (C64) Drago Basic v2.0 with Drago basic 2.2 (C64) REU Basic v2.0 with REU-basic (C64) Lightning Basic v2.0 with Basic Lightning (C64) magic Basic v2.0 with Magic Basic (C64) easy Basic v2.0 with Easy Basic (VIC20) blarg Basic v2.0 with Blarg (C64) Game Basic v2.0 with Game Basic (C64) 4 -w4e PET Basic v4.0 program (PET/C64) 3 Basic v3.5 program (C16) 4v Basic 2.0 with Basic 4.0 extensions (VIC20) 5 Basic 2.0 with Basic 5.0 extensions (VIC20) 70 Basic v7.0 program (C128) 71 Basic v7.1 program (C128) 10 Basic v10.0 program (C64DX) Usage examples: petcat -2 -o outputfile.txt -- inputfile.prg Convert inputfile.prg to a text file in outputfile.txt, using BASIC V2 only petcat -wsimon -o outputfile.prg -- inputfile.txt Convert inputfile.txt to a PRG file in outputfile.prg, using Simon's BASIC 1 Quote Link to comment Share on other sites More sharing options...
+Rick Reynolds Posted May 9, 2021 Author Share Posted May 9, 2021 Wow, thanks brain! Looks like I asked a very newbie question! I appreciate the complete answer and the fact that such a tool already exists. Quote Link to comment Share on other sites More sharing options...
Pokeypy Posted May 10, 2021 Share Posted May 10, 2021 For C64, I use: Alternatively, you can write a text file "program.txt" with the BASIC code on the PC. Use lower case letters (!) and line numbers for the C64 commands and the rest of the code. Like this: 5 rem program.txt 10 print "commodore 64 basic" 20 goto 10 Then you can use the "petcat" command, that again comes with VICE, to convert your program into C64 BASIC code: petcat -w2 -o program.bas -- program.txt This can then again be written onto a newly created disk-file "mydisk.d64": c1541 -format diskname,id d64 mydisk.d64 -attach mydisk.d64 -write program.bas program.prg Where "program.prg" is the file-name on the ".d64"-disk. It has to be in lower-case letters, or the C64 will mess up the characters. You can then launch VICE with "x64 mydisk.d64" to run and watch your program. 1 Quote Link to comment Share on other sites More sharing options...
jrhodes Posted May 10, 2021 Share Posted May 10, 2021 5 hours ago, Pokeypy said: For C64, I use: Alternatively, you can write a text file "program.txt" with the BASIC code on the PC. Use lower case letters (!) and line numbers for the C64 commands and the rest of the code. Like this: 5 rem program.txt 10 print "commodore 64 basic" 20 goto 10 Then you can use the "petcat" command, that again comes with VICE, to convert your program into C64 BASIC code: petcat -w2 -o program.bas -- program.txt This can then again be written onto a newly created disk-file "mydisk.d64": c1541 -format diskname,id d64 mydisk.d64 -attach mydisk.d64 -write program.bas program.prg Where "program.prg" is the file-name on the ".d64"-disk. It has to be in lower-case letters, or the C64 will mess up the characters. You can then launch VICE with "x64 mydisk.d64" to run and watch your program. Using that method, how do you insert special symbols like Clear Home or cursor control characters in print lines? Is there special escape sequences that petcat recognizes? Still at work so I can't look it up myself right now. Quote Link to comment Share on other sites More sharing options...
Pokeypy Posted May 10, 2021 Share Posted May 10, 2021 1 hour ago, jrhodes said: Using that method, how do you insert special symbols like Clear Home or cursor control characters in print lines? Is there special escape sequences that petcat recognizes? Yes, on this site https://www.c64-wiki.com/wiki/PETSCII_Codes_in_Listings there's a special column for petcat in the table. For example "{$61}" can be used, to get the "spades" symbol. 1 1 Quote Link to comment Share on other sites More sharing options...
carlsson Posted May 10, 2021 Share Posted May 10, 2021 (edited) In the 1990's there were several competing tokenizers, like tok64, bastext and then petcat which came with VICE. Nowadays I think something like CBM prg studio has built-in tokenization, but I don't know if it uses its own engine or simply plugs in petcat. While you're at it, there is something called MOSpeed which is a homage to the old Petspeed compiler. I'm not sure how complete it is, and currently it may not target the PET line but truly is a cross compiler for BASIC as opposed to "only" a tokenizer. Actually, I found something more in form of XC=BASIC but I have no idea how it works. Apparently also the Basic Boss Compiler also is runnable as a Windows executable next to native C64 program if you want to try something different. [ Plus of course you have C compilers like cc65 as you already noticed, but C ain't BASIC ] Edited May 10, 2021 by carlsson 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.