A Casio Basic Project - Parser and Interpreter
This is my entry for the Retrochallenge 2022/10 Competition and probably subsequent challenges.
The Casio Pocket Computer range use a fairly standardized version of BASIC called Casio PocketPC BASIC. This project is to create a parser for BASIC using the programming language Scala and the parser library fastparse.
I have a couple of different Casio computers - I had a Casio PB-410 when I was a kid and loved it. Arguably the top-of-the-range model is the FX-850P and FX-880P. I now own one of these and have built a cable that allows me to download and upload files. This will allow me to confirm correct behaviour of the parser/interpreter.
Cosmic Fly is a machine code game written for the Casio VX-4. It can be downloaded from here and I have formatted the README in markdown format for easy reading and more information can be found here.
It is fairly normal for me to not complete my original goals for Retrochallenge. This month’s attempt has fallen right into that bracket. However, I’ve enjoyed my time delving into the Casio FX-850P manual, reproducing a fair portion of it (complete from the perspective of the BASIC programming) and implementing that all important Casio ASCII to Unicode converter. This tool in itself makes it possibly to now publish Casio BASIC programs on the internet in a form not previously possible, at least without installing a custom font.
In the past couple of days I’ve managed to create a new cable for the Casio VX-4 which is very cheap and convenient. Support for RS/232 over the 2.5mm 3-pole audio connector makes it much easier to fabricate a cable and once I got the null-modem connections on the FT232RL adapter correct it proved reliable. I even managed to get the machine code game Cosmic Fly working!
Here are some links to the code in Cosmic Fly aka Cosmic V4:
|CosmicV4.bas||CosmicV4.bas||Main Source Code|
|clr.b||clr.b||Clear memory for Machine code|
|Readme.txt||ReadmeJ.txt||Readme in English/Japanese|
See the online Readme.txt for more information and links.
So I feel like I’ve contributed by making the BASIC manual available and make look to fabricate some VX-4 RS/232 adapters for sale on eBay for those who aren’t a fan of the soldering iron.
So all the effort I’ve put into the Converter Scala code has now paid off. The converter, as well as converting between Casio Basic ASCII and Unicode can now output a useful markdown table showing the conversion mapping which can be seen on the documentation page for the converter.
I’ve also been able to convert all the BASIC applications which form the Scientific Library built into the FX-850P & FX-880P. Part 11 - Scientific Library of my online manual now has a list of all the library routines including links to both the Unicode and Casio Basic source files. Having the Unicode versions available makes reading the BASIC source code, containing all sorts of mathematical characters, really nice online.
What I didn’t realise when I set out to write a parser for Casio BASIC is that a converter is a pre-requisite in order to process text within a Scala application using Unicode, so even though I’ve not made much progress on a parser I had to go down this route anyway!
Oh… and my VX-4 arrived. It comes with 8KB RAM which is pretty useless, so I ended up ordering a modern-day replacemnt for the Casio RP-33 32KB RAM expansion module. See the developer Birt’s YouTube page which includes part 1 and part 2 of his video explaining the design of the replacement. They are currently available on eBay, his seller account is jeff_burt.
I got the module installed today and am looking forward to exploring the machine, including the enhanced version of Casio Basic when this RC entry is complete.
I’m not making progress on the parser - but I am making progress on a conversion utility to convert Casio BASIC character set pseudo-ASCII files into Unicode and back again. This is really a prerequisite to the parser, which works on the Unicode character setup. I’ve had fun-and-games with Unicode and Java/Scala because the 16-bit+ characters can’t be stored in a Java char - you must resort to converting character strings with more than one character into Unicode code points.
I also re-organised the Casio Basic documentation to mirror the standard owners manual, albeit with sections missing at the moment that don’t relate to BASIC. The new link is Casio FX-850 Owners Manual.
The Casio Basic Language Reference Manual is now fairly complete. On to the parser…
Spent an hour entering documentation pages in Markdown format, will continue to do so although this may become more of a background task moving forward, so I can make progress on the parser. As far as I know there are no machine-readable versions of the documentation, so I see this as a worthwhile endeavour.
Oh, and eBay beckoned, so I now have a Casio VX-4 being shipped from Japan. This is a very interesting pocket computer, with support for C-language programming. It was never exported, so all the documentation is in Japanese, so it might turn into a more worthwhile project when it arrives converting the documentation into English form - again, I’m unaware anyone has attempted this.
Started documenting Casio Basic.
First update! At the moment I am scouring the internet for Casio Pocket Computer resources - I’ll make a comprehensive resources list.
My first proper task will be to document the Casio Basic dialect, with all options for the FX-850P. The language evolved as new models were released.
I’ve also found some sample programs which will be really useful when testing the parser.
This project is hosted on GitHub.
Follow me on Twitter as @urbancamo.