PROGRAM PITSTOP
from Your Sinclair #22 (October 1987)

Flippin' 'eck! This month we've got even more routines from top
programmers, plus all your best utilities and games. Need we say more?
Thought not!


After the mindfudging success of the first two Program Pitstops, we
bring you once again the very best in programming. This month we have
Part Two of the amazing Editor from Gremlin's Montyologists Shaun
Hollingworth and Peter Harrap, a quickie (oo-er) from David 'Magic
Knight' Jones, plus a super little thing from the write of Tau Ceti,
Academy and the recent Micronaut One, Pete Cooke. As well as all this
stupendiferous megastar tippery, we've also got a Fancy Loader from YS
reader Tom Baker, allowing you to add professional looking loaders to
your own programs.

So, if you'd like to join the happy band of megaprogrammers in the
Pitstop, send us your gems of programming skill, and who knows, you
might find yourself snapped up by a software house to write its latest
megagame. But don't hold your breath. You'll just have to be patient,
waiting for those cheques to roll in ...

And speaking of being patient, we've been getting a lot of phone calls
lately about programs you've sent in for the old Program Power section.
Please bear with us! You should hear one way or the other very soon, so
please refrain from phoning up every ten minutes to find out where your
program is. We've got ringing in our ears. Ta!


= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =


Fastape
by Tom Baker
from Your Sinclair #22 (Oct.1987)
[files FAST*.*]


In the first Program Pitstop we said that we'd like you to
send in your routines for making fancy loaders, and sure
enough you did. Over twenty programmers sent in their fancy
load routines, and for the most part they were pretty good.
Most relied quite heavily on people knowing a little about
machine code, and had instructions that would give a PhD
student a migraine. But fortunately a small proportion were
interesting, menu-driven beasts which even T'zer could
understand. (Huh? Wassat? T'zer) And it's these that
provided the most elegant solutions to the problem.

Tom Baker's Fastape routine is small, full featured and
allows even the most fumble fingered among us to put fancy
professional loaders on our programs. The instructions were
comprehensive, and the techniques employed easy to
understand. So thank you, Tom, and it's over to Fastape to
provide your programs with the ride of a lifetime!


METHOD

The program takes the form of a little chunk of code which
you load into memory at the same time as your own program,
and activate it with a few simple POKEs. The Fastape
routines take up a mere 715 bytes, and reside above RAMTOP
at address 60000.

Saving: To save a block of code using Fastape, the routine
must first be given info on the address of the code, how
many bytes it occupies, and which of the Fastape features
you want. These features are a Multicoloured border, Blank
or Masked border, Error trapping and Crash On Error,and a
Countdown Timer anywhere on screen. These features are all
available, depending on certain parameters which you must
set with POKEs. With Fastape in memory all you have to do to
save is use the command LET SAVE=USR 60003. Incidentally,
there'll be no Start Tape message, so get the tape going
before you press Enter.

The info is given to the routines as follows:

Address of code	- POKE 60011,address-(256*INT (address/256))
		- POKE 60012,INT (address/256)
Length of code	- POKE 60013,length-(256*INT (length/256))
		- POKE 60014,INT (length/256)
All features	- POKE 60015,f

Calculate the value of f from this table:

F Table
-------
Value F  Crash on error     Coloured border    Countdown
-------  --------------     ---------------    ---------
0        NO (error message) NO (masked border) NO
1        YES                NO (masked border) NO
2        NO (error message) YES                NO
3        YES                YES                NO
4        NO (error message) NO (masked border) YES
5        YES                NO (masked border) YES
6        NO (error message) YES                YES
7        YES                YES                YES

Timer co-ordinates - POKE 60007, x co-ordinate
                     POKE 60008, y co-ordinate
(where x is between 0-29 and y is between 0-23)

Loading: Loading is very simple as, like the Speccy's own
commands, a header is saved with each block of code which is
automatically loaded by the routines. The command RANDOMIZE
U6R 60000 will load in the next block of code. All the other
feature POKEs still apply. An extra feature which has been
added is the Security option. The contents of address 60006
must be the same as when it was originally saved. If not the
routines will respond with an error message or crash (as
selected). This means that if you save a code block with
60006 POKEd with 100, say, someone cannot load it in who
doesn't know the number!


Basic Listing

This month's program is a piece of cake. Simply type in the
program and save it with SAVE "FASTAPE". Don't bother with
an autostart LINE number as this program merely creates and
saves the FASTAPE code block for you. Just RUN it, and the
program will POKE all the code into memory. Once it has
saved it to tape, set the Basic bit aside, in case you lose
the code block, and use the code in your own programs.


= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =


Fastape
by Tom Baker
from Your Sinclair #92 (Aug.1993)


Bit of a blast from the past, this one (YS October 1987
actually). It's a fast loader with some groovy features,
such as security, flashy borders and a loading countdown.
Basically, find the start address and length of your code
and POKE 60011, address-256*INT (address/256): POKE 60012,
INT (address/256): POKE 60013, length-256*INT (length/256):
POKE 60014, INT (length/256). POKE 60007, x-coordinate of
countdown (0-29): POKE 60008, y co-ord (0-23): POKE 60015, f
to set up the features and LET fast=USR 60003 to save. RAND
USR 60000 to reload. Oh, and if you POKE 60006 number, that
number must be present for the prog to reload. Here's how to
work out the value of f.

 F   Error bomb  Border  Count
 -   ----------  ------  -----
 0       No        No     No
 1       Yes       No     No
 2       No        Yes    No
 3       Yes       Yes    No
 4       No        No     Yes
 5       Yes       No     Yes
 6       No        Yes    Yes
 7       Yes       Yes    Yes


= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =


STAR TIP 4 part 2
[see YS8709PP.TXT for details. JimG]


= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =


Star Tip 5 (Keyboard Scanning)
by Pete Cooke
from Your Sinclair #22 (Oct.1987)
[files STARTIP5.*]


It's an astounding thought, but true, that three of the most
original and best selling games of the last 12 months, Tau
Ceti, Room Ten and Micronaut One were all programmed by the
same bloke. This talented 3Dologist is none other than Pete
Cooke, our Pitstop special guest. Pete has spent a lot of
time programming computer games, his first products coming
out on the Richard Shepherd Software label between 1983-85.
First Invincible Island, then Urban Upstart, Inferno and
finally Ski Star 2000. Moving over to CRL in 1985, he
produced Juggernaut, and the Tau Ceti range of games
(applause). Pete now works for Nexus and, having recently
wowed us all with the excellent Micronaut One, is currently
working on a top secret project. Coo-er-gosh.

The routine Pete has contributed to Pitstop is the fab
keyboard scanning routine from both the Tau Ceti games and
Micronaut One. It is an assembly routine, printed as such
because it's easier to make out whats happening that way. So
now you will be able to incorporate Pete's routines into
your games, as the first step to implementing the sort of
Windows, Icons, Mouse and Pointer type controls. This is
just the first step, the rest is up to you.


Method

To substitute different key combinations in the routine,
simply copy new values into the 5-byte table KEYTAB. The
assembly listing is pretty self- explanatory, having piles
of comment lines with details of how to use the program.

  10        org  60000
  20        ent  60000
  30 ;
  40 ;
  50 ;      YS_KEYS
  60 ;
  70 ;prog for Your Sinclair
  80 ;
  90 ;file for Hisoft GENS
 100 ;assembler but should
 110 ;be suitable for most
 120 ;assemblers on the market
 130 ;
 140 ;Reads the keyboard
 150 ;Returns with C
 160 ;holding L/R/U/D/F
 170 ;
 180 ;bit 4,C left
 190 ;bit 3,C right
 200 ;bit 2,C up
 210 ;bit 1,C down
 220 ;bit 0,C fire
 230 ;
 240 ;bit set to 1 if pressed
 250 ;
 260 ;keys are chosen by
 270 ;values in KEYTAB
 280 ;
 290 readke ld   hl,keytab
 300        ld   bc,#0500
 310 ;
 320 ;5 keys to read
 330 ;
 340 read_1 ld   a,(hl)
 350        rra
 360        rra
 370        and  #1e
 380        ld   e,a
 390        ld   d,0
 400 ;
 410 ;2*the row number
 420 ;
 430        ld   a,(hl)
 440        inc  hl
 450        push hl
 460 ;
 470 ;save place in KEYTAB
 480 ;
 490        ld   hl,keyadd
 500        add  hl,de
 510        ld   d,a
 520 ;
 530 ;index port addresses
 540 ;
 550        push bc
 560        ld   c,(hl)
 570        inc  hl
 580        ld   b,(hl)
 590        in   a,(c)
 600        inc  b
 610        dec  b
 620        jr   z,read_2
 630        cpl
 640 read_2 ld   e,a
 650 ;
 660 ;read the port
 670 ;and flip bits if not
 680 ;Kempston
 690 ;
 700        pop  bc
 710        pop  hl
 720 ;
 730 ;and get back BC+HL
 740 ;
 750        ld   a,d
 760        and  #07
 770        jr   z,read_4
 780 ;
 790 read_3 rr   e
 800        dec  a
 810        jr   nz,read_3
 820 ;
 830 ;rotate L so bit needed
 840 ;is in bit 0
 850 ;
 860 read_4 rr   e
 870        rl   c
 880 ;
 890 ;rotate the bit into C
 900 ;
 910        djnz read_1
 920        ret
 930 ;
 940 ;exit B=0
 950 ;     C=keys
 960 ;
 970 ;A,HL,DE corrupt
 980 ;
 990 ;
1000 ;port addresses of
1010 ;the keyboard rows
1020 ;
1030 keyadd defw 63486,64510,65022,65278,61438,57342,49150,32766
1040        defw 31 ;*Kempston*
1050 ;
1060 ;
1070 ;KEYTAB holds the position
1080 ;of each key as
1090 ;1/2 row number*8 plus
1100 ;distance from the edge
1110 ;eg. P = 5*8+0
1120 ;    O = 5*8+1
1130 ;    Q = 1*8+0
1140 ;    4 = 0*8+3
1150 ;
1160 keytab defb 5*8+1,5*8+0,2*8+1,3*8+2,7*8+0
1170 ;
1180 ;set for O,P,S,X,space
1190 ;
1200 ;for a Kempston joystick
1210 ;substitute
1220 ;
1230        defb 8*8+1,8*8+0,8*8+3,8*8+2,8*8+4
1240 ;


= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =


Star Tip 6 (Invisible Loader)
by David Jones
from Your Sinclair #22 (Oct.1987) - "Program Pitstop"
[files STARTIP6.*]

The Magic Knight series from MAD Games, a Mastertronic
label, has been going on for years. This popular series
began with Finders Keepers, was quickly followed by the big
hits Spellbound and Knight Tyme until finally this year we
saw Stormbringer. All four games are arcade adventures,
featuring a unique system of pull-down windows called
Windimation. This system has been much copied, and with good
reason, the Magic Knight games are exceedingly popular!

The man behind these triffic games is David Jones. David,
being an amenable sort of chap, has given us this
interesting tip on how to finish your games professionally.
We haven't seen this printed anywhere before, which is
strange because it's so simple.

You remember when you draw a nice loading screen for your
game or utility and put it on a cassette with your program?
Don't you find it irritating when the filename of the
program overwrites the picture, spoiling the effect? Well,
now it can be told. The solution is in the way you save your
programs to tape.

Method

Imagine we have a game which has a Basic loader called
"MEGAZAP", followed by the loading screen "S", and finally
the game, a code block 15000 bytes long starting at address
32000. To save your game to tape from your working copy,
proceed as follows:

LOAD "MEGAZAP"
SAVE "MEGAZAP" LINE 10

CLEAR 26200
LOAD "" CODE 32768
SAVE "S" CODE 32768,6912

CLEAR 31999
LOAD "" CODE 32000
SAVE CHR$ 22+CHR$ 1+CHR$ 0+"Bytes:" CODE 32000,15000

How this all works is really very simple. The CHR$ coded
save instruction performs the function of (1) giving your
code block the filename "Bytes:" and (2) backspacing the
filename and OVERing it over the prompt on-screen, fitting
exactly over it and rendering it invisible! See, we said it
was simple.

Many thanks to David for this important tip, and we look
forward to seeing more from him later in the year.


= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =


--
Another Fine Product transcribed by:
Jim Grimwood, Weardale, England (http://www.users.globalnet.co.uk/~jimg/)
--
