EVAS10N.RAS.DOT: my entry to the DotJam


EVAS10N.RAS.DOT is an extremely simple breakout-like game for the Sinclair ZX Spectrum Next, coded for the DotJam using TRSE (Turbo Rascal Syntax Error).

Important note: EVAS10N.RAS.DOT currently supports only 32 columns mode!

TL;DR

I’m a Sinclair ZX Spectrum user since 1988 and a ZX Spectrum Next enthusiast since I first heard about it in 2017. I love (retro)computers and most of all I love to develop apps (mainly games) for them. I started coding in BASIC as a kid and then studied Pascal, C, Java, C++ and C#, among others. Currently, my programming language of choice for retro development is C and my favourite toolchain is z88dk. One of the first programs I coded for the ZX Spectrum Next is the more dot command (formerly known as readme), which is included in the official software distribution. I also ported a simple version of the cowsay joke program to the ZX Spectrum Next.

In 2019, I coded Breakin, a small clone of the Breakout arcade game written in 20 lines of BASIC language for the Breakout Basic Challenge. The next year, I wrote an even smaller version, called Evas10n, for the 2020 edition of the BASIC 10Liner Contest. In April 2020, the long awaited ZX Spectrum Next was finally delivered, and I immediately set up the CP/M environment and installed the Turbo Pascal 3 compiler. Then, I has some fun rewriting Evas10n in Pascal; the result is EVAS10N.PAS. Recently, EVAS10N.PAS was improved and optimized for CRISS CP/M, a nice computer kit.

In the last years, I often heard about TRSE (Turbo Rascal Syntax Error), a complete suite including a modern IDE and a Pascal cross-compiler, targeting many 8 and 16-bit computers based on microprocessors like the MOS 6502, the Zilog Z80, the Motorola 6800 or the X86 line. I think it’s an excellent suite and was looking forward to trying it!

Some days ago, the DotJam was announced. The purpose is to try to create an interesting game, demo or tool in the form of a .dot file. I wanted to join the jam, but could not find the time to think about something new and code it. Since, technically speaking, any 8K machine code binary that can run from address $2000 (8192 in decimal) with the extension “.dot” can be a dot file and TRSE allows to specify the program start address (Project menu => Project Settings => Target Settings tab), I immediately though of converting EVAS10N.PAS from Turbo Pascal to TRSE!

Being the port of a CP/M program, EVAS10N.RAS.DOT does not (yet?) make use of any of the ZX Spectrum/Next features, such as colours, sound, high resolution graphics, sprites, etc. It would be nice to enhance it on order to fully exploit the ZX Spectrum Next capabilities, maybe through a dedicated unit (see file: next.tru).

Conversion notes

The conversion to TRSE was not as straightforward as I initially imagined, due to some differences between TRSE and the Pascal dialect I am familiar with, so I will jot down some notes. You might have a look at the TRSE syntax reference.

Since I’ve just started using TRSE, some of my assumptions and consideration might be wrong!

For loops

The final value in a for loop is not included.

So, for example, this loop:

for i := 0 to 10 do 
begin     
   txt::put_ch(48 + i); 
end;

produces the following result: 0123456789 and this loop:

for i := 2 to 5 do 
begin     
   txt::put_ch(48 + i); 
end;

produces this output: 234.

No two-dimensional arrays

Arrays of arrays are not allowed.

So I simply replaced:

var bricks: array[1..6] of array[1..32] of Boolean; 
... 
bricks[r, c] := true;

with:

var bricks: array[6*32] of Boolean; 
... 
bricks[(r * 32) + c] := True;

Nested conditionals

Nested conditionals must be enclosed with parentheses, otherwise bad things will happen! see TRSE syntax reference for details.

Local variable names

The compiler does not allow the same name for multiple variables, even if their scope is different. Maybe this can be solved with the global modifier… I need to investigate further!

Here’s an example in which the compiler will report errors:

program Test;  
function Square(val: Integer): Integer; // Fatal error: Variable 'val' is already defined!  
var newval: Integer; // Fatal error: variable 'newval' is already defined!  
begin 	
   newval := val * val;
   Square := newval; 
end;  
var val, newval: Integer;  
begin  	
  val := 5; 	
   newval := Square(val);  
end.

Other notes

  • Pay attention to funcions/procedures parameter types and passed variables: passing an Integer where a Byte is expected or vice-versa apparently can cause troubles.
  • Integer and Byte are unsigned types!

Final considerations

EVAS10N.RAS.DOT is a quick and dirty hack; the program surely contains some bugs and can be improved in many ways! Anyway, I’m happy with it because it gave me the chance to get acquainted with TRSE, a great development tool.

Files

evas10n_ras_dot.zip 23 kB
Jun 10, 2022

Get EVAS10N.RAS.DOT (ZX Spectrum Next)

Leave a comment

Log in with itch.io to leave a comment.