SHORTCUTS ZX Computing, March 1987 Ray Elder presents more programming gems from ZX readers. - - - - - - - - - - M/C BREAK [file: M/C Break] First up this month is a program from Andrew Vellacott of Essex who got so fed up with his machine code programs getting stuck in infinite loops during development that he wrote this short routine which makes use of the Spectrum interrupt mode two to scan for the BREAK key being pressed. Two minor points to note: First you will have to reinitialise the routine each time after BREAK is pressed with RANDOMIZE USR 32377; and secondly, machine code or BASIC loader programs must not occupy the addresses from 32348 to 32375. [Actually ends at 32383. The READ loop in the listing was wrong as well, although the DATA statement was correct. JimG] A useful aid for machine code programmers. - - - - - - - - - - FONT [file: Font] R. Glavas has been a regular contributor from the start. His offering this month is a variation on a frequently used theme, that of a redesigned character set. What we liked about this set was that it was changed subtly, giving a more square effect. Simply enter the program and RUN it, the character set resides at address 55000. - - - - - - - - - - SCROLL RELOCATE [files: Relocate (PROG) + Textmc (CODE)] One of the things I like about this column is the way readers often send in and share modifications of previous programs. R. Dorsett of Middlesex sent us a short cut which solves a problem he found with Leif Kvernhusvik's Scroll program in the Dec'86 issue. The original program is located in the printer buffer, not good news for printer owners, so Mr. Dorsett's program will relocate it to anywhere in memory that you may desire. First (providing you have a M/C copy of the program on tape) CLEAR ramtop to the new start address-1. As an example we will imagine that we are going to move the routine to address 60000, therefore CLEAR 59999. Now LOAD "SCROLL" CODE newaddress (EG. LOAD "SCROLL" CODE 60000). Type in the RELOCATE program and RUN it. Finally SAVE "SCROLL" CODE newaddress, 159. (EG. SAVE "SCROLL" CODE 60000,159). Don't forget to change the line in your program which defines the function to call the new address (EG. DEF FN x(a$,l,w,a)=USR newaddress. Some alterations to the way in which the program works can also be made: POKE start+125,201 will return the program to BASIC if a key is pressed or when the scrolling is finished. POKE start+118,0: POKE start+125,201 prevents the program from being interrupted and returns to BASIC when finished. POKE start+118,192: POKE start+125,195 and the program will only return to BASIC when a key is pressed. - - - - - - - - - - MIRROR [file: Mirror] S. Neill of Angus, Scotland, provides us with a means of turning the screen image in a mere 19 bytes of machine code. Enter the program MIRROR 1 and RUN it. Type NEW and enter MIRROR 2 which will demonstrate the effect. Note that the Machine code is located at address 30000 and can be saved by SAVE "MIRROR" CODE 30000,19. Specific sections of the screen can be mirrored by POKING the following values to the addresses shown. x=start address Whole screen - POKE x+2,64: POKE x+15,88 Top third - POKE x+2,64: POKE x+15,72 Middle third - POKE x+2,72: POKE x+15,80 Bottom third - POKE x+2,80: POKE x+15,88 Top two thirds - POKE x+2,64: POKE x+15,80 Bottom two thirds - POKE x+2,72: POKE x+15,88 - - - - - - - - - - PERSPECTIVE [file: Perspectiv] Mark Batts who resides in Watford sent us this little program which could enhance title screens or messages. - - - - - - - - - - REFLECTIONS [file: Reflection] The above mentioned Mr. Batts supplied us with a program in a previous issue called Reflections which reader Stephen Carr has modified and improved. Another attractive way of presenting short text messages. - - - - - - - - - - VERSATILE INPUT [file: Input] Being able to position an input prompt and then accept characters and display them immediately after the prompt ANYWHERE on screen and not just at the bottom of the screen can give your program a professional touch. Andrew Smith of Cleveland provides us with a means of doing just that. The subroutine is located at lines 9000 plus but can be renumbered to suit your own needs. To use it set the screen position and provide a prompt (ensure you end with a semicolon else the input will be on the wrong line) and GO SUB the routine, for example: 100 PRINT AT 5,10;"ENTER YOUR NAME": GO SUB 9000 The resultant entry will be returned in variable i$. The variable z$ is used by the routine to act as a temporary input string, the DELETE key will delete a character and the ENTER key terminates the input. A nice bit of well error trapped BASIC. And so once again we reach the end of another collection of small, but beautifully formed, programs. All that remains is to nominate our Short Cut of the month. The prize goes to Mr. Neill for his Mirror program.