Latest update (Oct 2017) - Improvements to dflat
I thought I had made a more recent post than last December - time flies! So I haven't been able to spend as much time as I would have liked, but in the last few weeks have built a few improvements to dflat:
- Better handling of parameters. Until now, a parameter passed to a procedure would change the global value of the variable. For example a procedure called _def which takes a parameter %x, i.e. def_sub(%x). When _sub is invoked, the value of %x is overwritten with the parameter, i.e. _sub(1) loads %x with 1. However this is undesirable as it creates side-effects which must be carefully avoided by the programmer. So I have corrected that now - every variable in a definition used to pass parameters is now automatically a local unless preceded by '&' in the definition, which reverts to the previous behaviour and allows procedures to pass back values through shared variables.
- Enabling procedures to act as 'true' functions. Until now, passing back values from a procedure is through parameters as described above. This means a procedure doesn't actually return a value like a real function. I have now added this feature. A procedure can use the 'return' keyword to return an integer value, and the rest of dflat allows this procedure to be used as a true function in expressions.
- Added high resolution drawing. I wasn't sure there was enough room in the 16KB ROM, but I have also added the ability to set the Graphics Mode II (256x192 pixel screen), be able to address individual pixels (using the 'point' command) and draw lines (using the 'line') command. This makes possible games like (for example) missile command and lunar lander in dflat! :-)
- Removed the basic monitor, as I always found myself going straight in to dflat. If I need to check memory I can always use peek! This freed up around 750 bytes of valuable ROM space. Now I can think of even more stuff to put in to dflat! :-)
Update (Dec 2016) - Tetris game in dflat!
I felt the need to do something more sophisticated than the Invaders game in dflat, so have attempted a decent implementation of Tetris. The screenshot below shows the game - I am quite pleased with it, as it uses only my custom dflat interpreter. I am using sprites, sound, user defined graphics and a multi-colour palette to give the game a nice look and feel. In addition, to optimise for performance of scrolling the game map when a line is completed, I am using fairly intense string handling to maintain the game map rather than the original 20x10 integer array. Whilst developing this game, I decided to add timer functions to dflat, to help with timing various animations in the game loop - a beneft to building one's own computer language!
Invaders retro game done!
I've been a bit busy with work, but have managed to create a small and simple space invaders type game entirely in dflat. It takes me right back to around 1984 when I learnt to program from magazine listings! Also, I have added a couple of videos with commentary on youtube - one on the hardware (see below) and one on dflat (see dflat log).
First for a bit of context (back to around late 2014)
I guess I have always been interested in the lower level details of computers and their operations. As a kid of the 80s in the UK, getting to know the inner workings of my old Oric-1 and Atari 800XL entailed learning 6502 assembly and the I/O chips (including sound and video).
Then I had to grow up. I went to University, and went in to the world of work. My first couple of jobs were low-level (sort of), building software for embedded systems using a mixture of C, C++ and Assembly.
But for almost 20 years, I have been designing, architecting and consulting around distributed business systems. So I went completely away from the low level, working at the business outcome level -...Read more »