%OP%JUY
%OP%PL66
%OP%PS1
%OP%RCR
%OP%TM0
%OP%HM2
%OP%FM2
%OP%BM4
%OP%LM8
%OP%HE 
%OP%FO/Z88PATCH/RTR 27-03-88/Sheet @P@ of 4/
%CO:A,5,74%                              %H1%Z88 BASIC Patch%H1%

%JR%The version of BBC BASIC resident in the Cambridge Computer Z88 is 
%JL%deficient in a few respects, especially in the lack of any editing 
%JR%facilities or support for graphics operations.  The purpose of the BASIC 
Patch program is to provide some of these capabilities.

%JL%The patch program is installed with a simple CHAIN command, and 
%JR%thereafter remains resident until the machine is reset or BASIC is 
%JL%KILLed.  It occupies two kilobytes of memory, and results in the value of 
%JR%PAGE being raised to &2B00; when the graphics operations are used a 
further 2K is used for the display buffer.

%JL%The patch will work only on an expanded machine (at least 128 Kbytes of 
%JR%RAM installed in slot 1).  If this is not the case, or if the available 
%JL%memory has been deliberately reduced by changing HIMEM, the message "No 
RAM" will be displayed when the program is CHAINed.

The new features provided by the patch program are as follows:

%H2%*EDIT line number%H2%




































%H2%MODE n%H2%




























%H2%CLG%H2%






%H2%DRAW x,y%H2%








%H2%MOVE x,y%H2%











%H2%PLOT n,x,y%H2%
















































%H2%POINT(x,y)%H2%






The graphics statements COLOUR and GCOL are not implemented.

%JR%Installation of the BASIC patch has a number of "side effects" of which 
you should be aware:

1.








2.


3.


4.












5.















%JR%The patch has been tested only with EPROM Operating System version 2.2, 
%JL%although it should also work with ROM version 3.0.  Since it of necessity 
%JR%depends on certain specific features of the Operating System remaining 
%JL%unchanged, I cannot guarantee that it will operate correctly (or at all) 
%JR%with other versions.  (Note: to discover the version of your machine when 
in BASIC, press HELP than the left-arrow key).


Richard Russell, 27th March 1988.
The version of PATCH included on this Eprom includes the screen dump 
code, which may be called at any time with the command%H2% CALL 11011


%CO:B,5,69%





















%JL%This command allows you to edit a specified program line.  It 
%JR%results in the line being displayed (after a short delay) with the 
%JL%cursor positioned at the end, and you can then edit the line using 
any of the usual line-editing features, as follows:

     left           Move cursor left one character
     right          Move cursor right one character
     SHIFT left     Move cursor left one word
     SHIFT right    Move cursor right one word
     <> left        Move cursor to start of line
     <> right       Move cursor to end of line
     DEL            Backspace and delete
     SHIFT DEL      Delete character under cursor
     <> DEL         Delete entire line
     <> D           Delete from cursor to end of line
     <> G           Delete character under cursor
     <> S           Swap case
     <> T           Delete up to next space
     <> U           Insert space at cursor position
     <> V           Toggle between insert and overtype

%JR%To enter the edited line into the program press ENTER; to abandon 
the edit and leave the line unchanged press ESC.

%JR%You can also use *EDIT to concatenate two or more program lines, by 
%JL%specifying the first line and last line separated by commas (e.g. 
%JL%*EDIT 10,30).  In this case you will have to edit out the line 
%JR%numbers of the second and subsequent lines (and delete the old lines 
afterwards).

*EDIT may be abbreviated to *E. (the dot is required).






%JR%The MODE statement allows selection of the normal text-only mode 
%JL%(MODE 0) or a text-and-graphics mode (MODE 1).  In MODE 1 the 
%JR%display is split into two parts: a text-window on the left and a 
%JL%graphics-window on the right.  The text window consists of 8 rows of 
%JR%50 characters, and the graphics window is 64 pixels high by 256 
%JR%pixels wide; you cannot (normally) mix text and graphics in the same 
window.

%JR%Points in the graphics window are addressed as x,y coordinates from 
%JL%0,0 (the bottom-left corner) to 255,63 (the top-right corner), 
although the origin can be moved using the PLOT -1 statement (q.v.).

%JL%Although MODE 1 sets up the window positions and sizes as described, 
%JR%it is possible to change these using the VDU statement.  However the 
%JL%method of doing this is outside the scope of this document.  It is 
%JR%not advisable to cause the text and graphics windows to overlap, 
although this may occasionally be useful.

%JR%MODE clears the display (both text and graphics windows), moves the 
%JL%text cursor to 0,0 (the top left of the text window), resets the 
%JL%graphics origin and moves the graphics cursor to 0,0 (the bottom 
left of the graphics window).

%JL%In MODE 0 (the normal 94-column text mode) the other graphics 
statements have no effect.




%JR%This clears the graphics window (only); it does not affect the 
%JL%position of the graphics cursor.  Note that CLS can be used to clear 
the text window and leave the graphics window unchanged.




%JL%Draws a straight line (in black) between the current position of the 
%JL%graphics cursor and the specified coordinates, then moves the 
graphics cursor to the specified position.

This statement is identical to PLOT 5.




%JL%Moves the graphics cursor to the specified coordinates, but does not 
affect what is displayed.

This statement is identical to PLOT 4.








%JL%A multi-purpose plotting statement, whose effect is controlled by 
the first parameter n:

     %H1%n%H1%              %H1%action%H1%













































%JR%This function returns the state of the pixel at the specified 
%JL%location, as 0 (unlit) or 1 (lit).  If the specified point is 
%JR%outside the graphics window (taking into account the position of the 
origin), or if MODE 0 is selected, the value -1 is returned.






%JL%Changing HIMEM will have the effect of disabling the patch.  If 
%JR%HIMEM has been changed it must be set back to &C000 before 
%JL%re-CHAINing the patch program (or alternatively KILL and re-start 
BASIC from the INDEX).

%JL%Changing HIMEM is not recommended in any case, since setting it to 
%JR%an unsuitable value will "crash" the machine (even without the 
patch).

%JR%The "Silly", "RENUMBER space" and "LINE space" errors will not 
appear; instead the "No room" message will be produced in each case.

%JR%You are advised to select MODE 0 before entering Pipedream, since it 
seems to get confused by the presence of the graphics window.

%JR%Since Cambridge Computer provided no "legal" method of installing a 
%JL%patch such as this (indeed, for a long time I thought it would be 
%JR%impossible!), a rather "dirty" method has had to be adopted.  This 
has some unfortunate, but unavoidable, consequences:

(a)



(b)



%JL%Using graphics statements in an ON ERROR routine may give anomalous 
results.  For example:







%JR%The above program can be exited only by pressing ESCape.  The 
%JL%intention is that this will cause the display to clear and the 
%JR%message "Escape" to be displayed.  In practice, the message actually 
%JL%displayed will be "Sorry, not implemented" since, although the Patch 
is active, the MODE statement still affects REPORT, ERR and ERL.
%CO:C,10,64%
























































































































-1

0

1

2

3

4

5

6

7

8-15


16-31

32-63


64-71

72-79



80-87


88-95



96-103


































%JR%The RUN and CHAIN commands may occasionally fail to work 
%JL%properly (on average fewer than 1 in 1000 times).  If this 
happens no harm will be done; simply issue the command again.

%JL%If you reply to the INPUT statement with a very long string 
%JR%(more than 252 characters) the machine will crash, so you must 
avoid doing so.




10 ON ERROR MODE 0 : REPORT : END
20 MODE 1
30 REPEAT
40   DRAW RND(256)-1,RND(64)-1
50 UNTIL FALSE
%CO:D,54,55%
























































































































Move the graphics origin to x,y

Move the graphics cursor relative to the last point

Draw a line, in "black", relative to the last point

Draw a line, in "inverse", relative to the last point

Draw a line, in "white", relative to the last point

Move the graphics cursor to the absolute position x,y

Draw a line, in "black", to the absolute position x,y

Draw a line, in "inverse", to the absolute position x,y

Draw a line, in "white", to the absolute position x,y

%JL%As 0-7, but plot the last point on the line twice 
(i.e. in the "inverting" modes omit the last point).

As 0-15, but draw the line dotted.

%JR%As 0-31, but plot the first point on the line twice 
(i.e. in the "inverting" modes omit the first point).

As 0-7, but plot a single point at x,y

%JR%Draw a horizontal line left and right from the point 
%JL%x,y until the first "lit" pixel is encountered, or the 
edge of the window.  This can be used to fill shapes.

%JL%Plot and fill a triangle defined by the two previously 
visited points and the point x,y.

%JR%Draw a horizontal line to the right of the point x,y 
%JL%until the first "unlit" pixel is encountered, or the 
edge of the window.  This can be used to "undraw".

%JL%Plot and fill a rectangle whose opposite corners are 
defined by the last visited point and the point x,y.
