ugBasic – A BASIC compiler for Commodore, … and Atari, …and CoCo, … and …

ugBasic – A BASIC compiler for Commodore, … and Atari, …and
CoCo, … and …

Recently I learned about an exciting project that started a couple of years ago: ugBasic.

ugBasic is a cross compiler of BASIC dialect specialized in programs that are very efficient by design on various 8-bit platforms built on top of 6502, Z80 and 6809. This is a tall order, but ugBasic seems to pull it off very well.

ugBasic comprises several compilers, one for each platform, and an IDE where you can code your BASIC programs and deploy them to the specific platform of your choice. The BASIC can use or not line numbers and offers modern features like subroutines using labels and functions, for example. There are keywords to manipulate sounds and graphics as well.

The IDE is very powerful, and setting up your target platforms, and the emulators is very simple. After you are all set up, you will see a menu option to compile your program for each platform, and another one to bring up the emulator and load the program there to be executed.

The language managed to group the commands very well, covering the most common characteristics of the 8-bit machines that it supports. The example below clear the screen to Black sets the colour to yellow and draws a few circles on the screen.

CLIP 20,20 TO 50,50
r = (POSITION) 0
FOR r=4 TO 96 STEP 4
    GR LOCATE 10, r
    CIRCLE ,,r+9



The project’s page on GitHub has many examples, and the online documentation is excellent (My pet peeve: Google Ads all over the place makes it a bit annoying to read it on mobile devices, like any website that displays this type of advert).

I’ve tried many of the examples, and although they all compiled and ran on all my targets (Plus/4, Atari, CoCo), I’ve got different results. This shows that, even with a powerful tool like ugBasic, writing for different platforms still requires you to know how the specific target works and adjust your program accordingly – for example, all machines have different address maps, and if you need to resort to POKING data directly to memory, no magic will make it work in all targets. This is not a flaw with ugBasic, but the expected behaviour when dealing with so many radically different machines. Remember that there is no 100% “write once, run everywhere”!

If you want to see ugBasic in action, you can check Soko64, a Sokoban game made for the Commodore 64, and 4 Gravity, a Connect 4 clone. The latter is probably a more suitable game to compare different platforms since it is available for the C64, Dragon, Atari, Olivetti PC128, and the VIC-20.

ugBasic is a Windows-only application, so if you are a MacOS user like me, you will need to resort to Parallels or another method to run Windows applications.

Link: ugBASIC

Share Tweet Share

* This article was originally published here


Popular Posts