Micro­power

  

Volume 1, Number 2 – September 1981

Page 17 of 33

Using Pixel Graphics From Assembler

By G. N. Evans

The Basic ROM on the Nascom contains plenty of useful routines for the assembler programmer. The problem is finding out where they are and, more importantly, how to drive them. I have discovered most of the useful routines, and I am using many of them in a Basic Compiler which I am currently writing.

Below I have given details on how to make use of the pixel graphics routines. Should you try to access a non-existent point, then Basic would take over, issue an error message, and then remain in Basic. To prevent this I have written a routine, CHECK, which tests the validity of the co-ordinates; the carry flag is set on return if they are not valid. The routine also converts, the y co-ordinates so that y = 0 corresponds to the bottom of the screen and y = 47 to the top, which is much more logical and convenient than Microsoft’s ordering of the y axis.

Here is an example of the use of the routines to draw a vertical line through the centre of the screen:

11 00 18VERTLD DE, £1800POINT (24,0)
D5NEXTPUSH DESave current point
CD 1F 80CALL CHECKLegal co-ordinates?
38 0CJR C, ERRORIf not, jump
CD 00 80CALL SETPSet point
D1POP DERecover current point
1CINC ENext point up screen
7BLD A, ETransfer to accumulator
FE 30CP 48Has whole line been set?
20 F0JR NZ, NEXTRepeat if not
DF 5BSCAL £5BRepeat to monitor, etc.
ERRORPut error routine here

Routines To Use The Pixel Graphics

ORG £8000
ADDRESSES IN BASIC ROM
BCSPOSEQU £FF31
BSETEQU £FF43
BRESETEQU £FF58
BPOINTEQU £FFED

SET (D, E)

8000CD1680SETPCALL CSPOSCalculate screen posn.
8003CD43FFCALL BSETUse Basic ROM
8006C9RET

All register corrupted (except alternate set)
Page 17 of 33