PROGRAM PITSTOP
from Your Sinclair #21 (September 1987)

Improve your games programming! Take a stop in the Pitstop routine shop!
Each month we're featuring routines from the top programmers, Task Force
tips, plus all the best of your games and utility programs.


Having knocked you stone dead with last month's super first edition of
Program Pitstop, we're all set to finish you off with this month's
bumper, fun-packed and corky blend of routines, tips, plus the
inimitable Ian Hoare. This time around we have Monty Mole trainers Peter
Harrap and Shaun Hollingsworth of Gremlin. We've persuaded them to part
with their deepest, darkest programming secrets which, in the right
light and with a tailwind, could turn you into a programming superstar!
Well, okay, so you'd have to have a modicum of talent too, but everyone
needs a little help to be a genius, eh? You can use all this stuff in
your own programs for free, and remember ... these routines are
exclusive to Your Sinclair!! (Toot!) And on top of all this, we've got
the very best in reader's programs, this month featuring a wacky text
routine from Simon Hobbs called Megatext, and a tuneful offering for 128
owners from Lloyd Russell called, appropriately enough, Jukebox.

Pitstop is fast becoming the indispensable programmer's guide, and what
we need are contributions from you. Provided it's quite short, you're in
with a chance to be included in the next YS Program Pitstop. If you're a
professional programmer, then please write in with a mugshot and some
personal details - you know, the last game you wrote, shoe size, length
of nose ... If you're just a talented amateur, then let the rest of the
world see how brill you can be - and who knows? You might find yourself
being snapped up by a software house to write its next smash hit game!


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


Mega-Text
by Simon Hobbs
from Your Sinclair #21 (Sep.1987
[files MEGATEXT.*]


Routines which print text up on your screen in a variety of
different sizes are many, whereas programs which handle text
in a variety of special effects are few. One such program is
this small, but perfectly formed, cluster of routines from
Simon Hobbs. In this program, with its attendant demo, you
can print text onto the screen in a number of special styles
- right slant, left slant, fuzzy, bold, thick, faded, double
image and curved.


Method

Load in the Mega-Text Demo with LOAD "". This will load the
demo program, in Basic, which will auto-run and load the
machine code. You'll then be presented with an example of
each of the various styles available using the Mega text
code. You can break into the Basic and examine the listing,
which'll tell you most of the information you wish to know
about the program.

The code is specially sited at 64000 in memory to allow use
of UDGs in your programs which use Mega-text. To activate
the various functions, you must POKE the following
addresses:

	64394 = x co-ordinate of text
	64395 = y co-ordinate of text
	64396 = style of text
	64397 = height of text

and then you RANDOMIZE USR 64000. To work out the value you
have to POKE into the style of text address (64396) this is
what you do: Set the appropriate bit of the byte to activate
the associated function, and reset it to deactivate the
function. The bits for each function are:

BIT	FUNCTION
0	Right slant italics
1	Fuzzy text
2	Bold text
3	Thick text
4	Faded text
5	Left slant italics
6	Double image text
7	Curved text

Bits go from right to left. So if you wanted left slanting,
double image text (eur!) you must POKE 64396, BIN 01100000
or in decimal, 96. Or if you wanted fuzzy, curved text,
(hooargh!) you'd need to POKE 64396, BIN 10000010 or 130.
The text co-ordinate system is the same as a normal PRINT AT
statement. If you don't put in any co-ordinates, the
program, being foolproof and crash-proof, will simply start
where it left off.


Basic Program

Here's the Basic demo program. Type it in and save it with
SAVE "TEXT DEMO" LINE 10, saving it on the front end of a
blank tape.


Hex Loader

Type in this Hex Loader and save it to a separate tape for
future use, then run it and type the following Hex Dumps
into it. Just type in the figures between the ":" sign and
the "=" sign. The figure after the "=" sign is the Checksum.
At the beginning you'll be asked for the Start Address and
Length. This is the address in memory where the code will be
loaded, and the length is how many addresses after that the
program takes up. These figures are given at the beginning
of the dumps. To stop typing input an 'S'.


Hex Dump

Here's the machine code, listed here as a hex dump. The
start address = 64000 and the length = 398. Save it as SAVE
"TEXTCODE" CODE 64000, 398, making sure it follows the Basic
program on tape.


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


Jukebox
by Lloyd Russell
from Your Sinclair #21 (Sep.1987
[files JUKEBOX.*]


Here's a tricky program for all of you who love the tunes
you get on 128 games, but can't program a tune yourself.
This delightful selection of popular tunes (sounds like an
advert for a K-Tel record!) can be played from the main menu
at will. Although it falls partway between game and utility,
it's probably of more use as a utility; even if it merely
demonstrates how to program realistic and musical tunes on
the Speccy 128. It's a long program, but so enjoyable you
won't regret it.


Method

Using Jukebox is simplicity itself. Just type in the number
corresponding to the tune you'd like to dance to and before
you can say Beastie Boys, the music starts


Basic Listing 1

The program is listed in two parts. This part loads in the
UDGs (there's a DATA check). This must be SAVEd by using the
save line at the end of this listing. Just RUN 18, and the
program will be saved and verified automatically. With a
little help from you, of course.


Basic Listing 2

This is the main program. Once again save it using the SAVE
line at the end of the program at line 103. Note that
there's a PLAY command in this line. The tune that it plays
must be recorded before the rest of the listing, so press
PLAY and RECORD and type RUN 103 and then ENTER.


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


Star Tip 4
Block Store Screen Editor
by Shaun Hollingworth & Peter Harrap
from Your Sinclair #21/22 (Sep/Oct.1987)
[files STARTIP4.*]


Gremlin Graphics is really making a name for itself as an
arcade specialist with titles like Thing Bounces Back,
Future Knight and the Monty series topping the charts. It's
clear that the firm knows what the people want and is geared
to letting them have it (thwoom!) Dead good, complex, fast
arcade adventures with a sprinkling of senseless violence is
the name of the game, and this success is due in no small
way to Gremlin programmers Shaun Hollingworth and Peter
Harrap, as it's mainly their programming skills that have
created these megagames.

We were fascinated to discover that for each game they
write, they write a custom game editor/development system to
construct and link all the screens within the game, allowing
them to concentrate on the gameplay while bolting on screen
after screen of fast arcade action. Now you too can benefit
from this technique with a version of the Future Knight
Block Store game Screen Editor, which the lads have kindly
allowed us to print in this month's Program Pitstop.

Shaun and Peter have been with Gremlin for about three
years. Peter wrote all the Monty games, except Auf
Wiedersehen, which he co-wrote with Shaun. Between them
they've written Way Of The Tiger, Bounder, Future Knight,
and Trailblazer. They're presently working on this autumn's
smash from Gremlin, Death Wish III.

Shaun tells me that he has a copy of the Editor that was
used on the Monty games, and we'll be featuring it in a
future edition of the Pitstop. We only bring you the best!


Method

Using the Editor you can edit Blocks, Characters and Screens
and link them together in preparation for making your own
arcade adventure. The full scope of the program is far too
lengthy to mention in too much detail in these pages, so
we'll give you the basic commands and enough technical
colour to get you going, but from then on I'm afraid it's a
voyage of discovery.


Basic Program

Here's a little Basic loader, which loads the Editor Code
and fills the character set with some meaningful
information. Save it as SAVE "An editor" LINE 20.


Hex Dump 1

Here's the main program: load the Hex Loader program from
the Mega-text program. The start address of this chunk is
63488 and the length is 1999.


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


So you've been waiting with bated breath for the second half
of your Future Knight-style Editor program, from the makers
of the Monty games, huh? Okay, space is at a premium, so
let's get cracking...

continued

In case you missed last issue, we began by giving you the
Basic loader and Hex Dump 1 for the Editor program, with
which you can edit Blocks, Characters and Screens, and link
them to make the bare bones of an arcade adventure. Now
follows the remaining bits of code you need to get the
program working, and full instructions on how to use and
enjoy your Editor. (Gerrof! Ed)

There are three levels to the Editor, and at the top you
have the Main Screen Designer. To save anything from this
level you must break out into Basic. You can return to it by
RANDOMIZE USR 63488. On the screen you should have a white
rectangle with a crosshair cursor in it and a number under
it. This is the current screen number you're editing, which
when you first start is screen 91. The range of screens you
can have is 0-120. The entry screen can be set by POKEing
23681 with the screen number. The smaller white square is
the current block, which can be placed on the screen with
the cursor. These can number between 0-255.

To enter the next level of the Editor press 'C' and you'll
enter the Block Editor. You should have a smaller white
rectangle at the top of the screen marked 'chrno: 000',
containing the Select Char cursor and two small squares at
the bottom. The one on the left is the current block,
containing the Destination Block cursor, and the one marked
'copych' on the right is the copy character. The 'copych'
can be copied to the current block with CAPS+C, which is
helpful when creating a number of similar blocks, you can
just copy them over and alter them.

You have no chars in memory at this point, so to get to the
third and final level press 'E'. This puts you into the Char
Editor, and you're presented with 'chrno' at the bottom of
the screen and a grid and cursor. When you've finished
editing, press 'X' to return to the Block Editor.

The final short program which prints up the screens when you
want them is called "screen-PRINT". In order to use it you
need to decide where you're going to store your chars,
screens, blocks, colour map and background chars. To allow
the "screen-PRINT" program to display your screens you must
put these addresses into the following registers:

BC  = address of chr map
DE  = address of screen data
A   = screen no. to print
IX  = address of block data
HL  = address of colour data
DE' = address of background chars

(NOTE: HL' register not used!)
Then the program knows what to print and where to get all
the data for it. All you have to do is call the print
routine with RANDOMIZE USR (address you located
screen-PRINT) and off it goes. Although you can't build a
game without writing a lot of other stuff like sprites,
collision and puzzles yourself, Editor certainly takes the
headache out of building the world your sprites will
inhabit! Have fun!


Saving Data

Block Shapes: The data for the block shapes is at address
49152 and is a maximum of 256*16 (4096) bytes long.

Screen Layouts: The data for the screen layouts is at
address 53248 and is a maximum of 120*32 (3840) bytes long.

Colour: The colour data is at address 57088 and is 256 bytes
long.

Charset: The graphics character set is at address 61440 and
is 2048 bytes long.


Options

MAIN SCREEN EDITOR
F move to next screen
B move to last screen
Q crosshair left
W crosshair right
P crosshair up
L crosshair down
U move current block up one
D move current block down one
S set current block at cursor
C enter Block Editor mode
BREAK return to Basic

BLOCK EDITOR
Q Char Select cursor left
W Char Select cursor right
P Char Select cursor up
L Char Select cursor down
CAPS SHIFT advance bottom cursor
S set char in current block at bottom cursor position
U advance current block no.
D retard current block no.
CAPS+C copy the copych block to current
CAPS+U advance copych block no.
CAPS+D retard copych block no.
F select ink colour
B select paper colour
A sets the colour of char at Char Select cursor
X returns to Main Screen Editor
E enters Char Editor

CHAR EDITOR
Q move cursor left
W move cursor right
P move cursor up
L move cursor down
ENTER to set pixel
SPACE to reset pixel
I to invert whole char
X to return to Block Editor


Hex Dump 2

Next we have some sample characters for you to try. Once
again you have to type them into the Hex Loader from
Mega-Text. The start address of this bit is 61440 and the
length is 2048. Save it as SAVE "sum chars" CODE 61440,2048.


Hex Dump 3

And finally, that naughty bit of code which prints up the
screens when you want them. As we mentioned earlier, this
chunk of code is relocatable to anywhere that's convenient
for you. For the sake of argument we've set the start
address to 30000 and the length to 172. Save as SAVE
"screen-Print" CODE 30000,172.


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


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