John Allen's Z88 pages   Z88

More than Basics

This page is archived and no longer maintained


It's the remarkable compatibility between the Acorn machines, the BBC micro and the Archimedes, and the Z88 which makes the portable so popular with users of those machines. It's especially remarkable because that compatibility is not at the machine code level, since the Z88 uses the Z80 processor, but at the software level. The two major applications on the Z88 both have their equivalents on the Acorn machines. PipeDream on the Z88 is available on the Archimedes and is file compatible with View Professional on the BBC micro, and the programming language on all three machines is BBC Basic.

On the Z88, BBC Basic was implemented by Cambridge Computer, based on the BBC micro's Z80 second processor version. On the BBC micro the two Basics (for the 6502 and Z80 processors) are very nearly identical but there are some differences on the Z88. Partly this is because of the different environment but none of the graphics commands are included and, most importantly, there's no way of editing lines of a program on the Z88. This means that the Z88 is not a good machine for developing programs and that programs involving graphics, written on the BBC micro and then transferred, keep failing on the Z88 with 'Not implemented' errors.

There's now a partial answer to the problem. It's a public domain 'patch' to Z88 Basic written by the man who originally wrote the Z80 version of BBC Basic, Richard Russell. This puts back many of the missing graphics commands and contains a line editor. But you do need at least 128k of extra ram to use it.

To run the patch on your Z88 you select Basic and type

  CHAIN"PATCH"
it then stays installed until that Basic is KILLed. So what does it do? Firstly it contains an editor so to edit, say, line 120 you type
  *EDIT 120

This is much more powerful than the line editor on the BBC micro and contains many of the PipeDream editing features such as swapping case, working in insert mode, deleting up to next space, delete to end of line and so on, all using the same commands as in PipeDream. It can also be used to join lines together.

As far as graphics are concerned, the effect is not the same as on the BBC micro. The Z88 is not designed to allow easy mixing of text and graphics so this patch creates two windows, a text window on the left of 8 rows of 50 characters and a graphics window on the right 64 pixels high by 256 pixels wide. The graphics origin is at the bottom left corner. This way of operating is initiated by entering

  MODE 1
while the normal 94 character wide Z88 Basic window is restored by
  MODE 0       
Once you're in mode 1 most of the normal graphics commands can be used in the right hand window - these include CLG, DRAW, MOVE, PLOT and POINT. COLOUR and GCOL are not implemented however as all graphics are drawn as black on white.

So what are the problems? Although many of the BBC micro commands are available they don't necessarily have the same effect as they do on the BBC micro, so you still can't move programs across without modification. Also text and graphics are not easily mixed although it is possible to change the size and location of the text window. The patch also interacts strangely with PipeDream so if you've a suspended activity with mode 1 Basic you may get bits of the Basic graphics in odd places from time to time!

As the patch is not 'legal' there's no guarantee that it will work with future versions of the operating system but it's certainly something which I've found to be a welcome extension to the Z88's Basic.

Z88 Basic programming tip

Ordinarily Z88 Basic programs cannot be suspended when they are running so, for example, pressing the INDEX key will have not effect. To make your program 'suspendable' you'll need to include regular commands which temporarily return control to the operating system, INKEY is a good one to use. So periodically put in lines like

  DUMMY=INKEY(0)
This is particularly useful if you've disabled the ESCAPE key as otherwise it may be difficult to leave the program when something goes wrong.

 

New Commands

  MODE        Select text or text and graphics mode
  CLG         Clear the graphics window
  DRAW x,y    Draw a line in black from the current graphics 
              cursor to x,y then move the graphics cursor to 
              x,y
  PLOT n,x,y  Like the BBC micro PLOT command the action is 
              controlled by n, and the actions are broadly 
              similar, but more comprehensive, than on the 
              standard model B
  POINT(x,y)  This gives the state of the pixel at x,y.  
              It returns 0 for white, 1 for black

Changing the windows

To get the text and graphics windows to coincide, the text window has to be redefined using a VDU1 statement. The graphics window is in a fixed position. Text is written to window 1 so if the position of that window is changed the text will be displayed in a different position.

The simple program below illustrates how you can place text in the graphics area, in this case putting a double border round some text. Line 20 uses VDU1 to redefine window 1 to start at 57,2 with a width of 32 characters and depth of 4 lines (these values are set by the 5th, 6th, 7th and 8th parameters respectively - with 32 added to each value). The final parameter of the VDU statement gives the window type, in this case one with no border. If the CLS statement at line 30 is not included then the graphics may not stay in the correct position. Lines 40, 50 and 60 draw the border (as the patch will support drawing rectangles this could also have been done by a PLOT command). When you've finished running the program, and want to return the windows to their defaults, enter

MODE 0

© John Allen 2014