BBC BASIC: The Porting of my Adventure Kernel
Most people may not be aware of a program I created back in the mid-2000s called Adventure Kernel. It was an interesting take on the Interactive Fiction game engine, whereas most Interactive Fiction engines and games expect the player to enter in a swath of verbs and nouns, I sought to make the genre more accessible to newcomers who may not have the typing skills of an Executive Assistant. Rather than the player needing to type in any words whatsoever, the game engine instead provided the player with various options via a menu, and the ability to move in each of the cordial compass directions by using a single key press of N, S, E, and W. A menu of 3 different actions would also be available in most areas where the player can choose unique actions to perform given the situation. It also had an basic inventory system, where items would be automatically picked up if the player comes across them, and could be used either automatically for story-based interactions, such as a character noticing the player is carrying something, or the player can use the U hotkey if an item in their inventory can be used. It is a rather simple engine, but also reasonably capable at some decently complex narratives. It did not include any sort of scripting or event system, and was driven entirely through a basic data record of only 440 bytes. The original version made in QuickBASIC as linked above also contains a built-in editor which when compiled into a stand-alone EXE can be accessed via a simple /EDITOR command-line parameter. The Editor itself was primitive, and allowed you to add and edit locations as needed.
Back in 2020 as I was becoming better at using the Pascal programming language, I decided to try making a port to Turbo Pascal 4.0. It kept the exact same look and feel of the original, and supported the original game file format as well. The only part that it lacked was the editor from the QuickBASIC version, but that was shortly remedied by the creation of a full Lazarus/Delphi version, which now had the game run in a standard desktop window, and included a game editor which also ran as a standard desktop application. Being written in Lazarus, it is fully cross-platform with Linux, macOS, and Windows. Although... It couldn't run on RISC-OS, which was a shame... Until Today!
Porting a full-screen DOS app to BBC BASIC
I created this port in a single evening, and then updated it to work on the BBC Micro just this morning before writing this post. I learned quite a bit more about programming in BBC BASIC, for RISC-OS, and some of the differences in BBC BASIC from the BBC Micro to BASIC V on RISC-OS, so let's dive in to discuss the porting.
As I was writing the RISC-OS version, I made sure not to use many multi-line IF-statements, as these were not compatible with BBC BASIC on the BBC Micro, but I was unaware of other differences until I decided to run it in BeebIt using the nice BeebItFS ROM. If Michael Foot ever reads this by chance, the ArcDFS ZIP file seems to be corrupted whenever I try to open it, either on my Linux host, or via SparkFS, and I'd absolutely love to use this program, and it's a shame that I cannot currently.
When running my program on the BBC Micro, there was quite a few corrections that I needed to make, as it did not have some of the newer features available in BASIC V, here is a list of what I needed to change:
- Change
WHILE/ENDWHILEtoREPEAT/UNTIL - Functions cannot return anywhere in the function via
=... - The
RIGHT$andLEFT$functions require the second parameter. - Cannot use the Bit Shift Left operator,
<<- This currently limits the BBC Micro to only 255 locations.
Other than those issues, all the other BBC BASIC code worked fine. I did however need to add a Loading Screen as it loaded the location from disc much much slower than the RISC-OS version.
Probably the most annoying part of programming directly in RISC-OS using it's editors, namely StrongEd is that the HOME and END keys do not function as they do in editors found on Linux or Windows, where I can move to either the start or end of a line. In RISC-OS if I use these keys, I am placed either at the top or the bottom of the document. Since using these keys during programming is a very second nature to me to move around my source efficiently, it became rather frustrating when I hit one and completely lost my position in the file. As a result, I found myself using the mouse to move around the source more, which was tedious. I checked the options in StringEd and there isn't anything there to change how these keys function during editing either, I'll keep doing some research, as I am sure there is a way to change how HOME and END works in RISC-OS, right?
What's Next?
Well, now that I've been able to port my Adventure Kernel to RISC-OS in BBC BASIC, I feel the next logical step is to first add a simple multitasking wrapper, and the ability to load other game files without modifying the source code. The next version I create will include Icon Bar integration, which will enable basic multitasking, and allow the game to be suspended and resumed via the Icon Bar as with any other RISC-OS application. The Icon Bar will also support hopefully dragging a game icon into it, if I can work out how that works as well. The game will still go into full-screen when clicked, and a hotkey, F12 will be used, as with all other full-screen RISC-OS applications to effortless suspend the application and return to the desktop.
The ultimate goal will be to have a fully native RISC-OS Wimp application done as well, which will more or less mimic the existing GUI I created in Lazarus, and include the ability to launch a game editor, which will also be a Wimp application.
Happy RISCing!