PROGRAM PITSTOP
Your Sinclair, December 1988

[Another selection of Pitstop listings messed up by McCandless. There were ]
[several errors in the Extra Special FX assembler listings (incorrect or   ]
[misplaced labels); half of the descriptions were printed against the wrong]
[listings; and part of the Squelch BASIC listing was missing.          JimG]

Tantaraa!!! It's time again for the Pitstop Show. Your host, as usual,
is the Man with the Most - David "if it moves POKE it" McCandless.
Tantaraa!!!

In the last Pitstop special I waffled on for aeons about how sound and
music create good atmosphere and enjoyment in a game. Now in this
month's special, I'm going to waffle on for ages about how screen
effects create an element of finesse and a more refined look.

As you may know, a snazzy clear screen routine or a swift scrolling
effect certainly sharpens the overall impact of a game. Not that I'm
saying that every time you clear the screen you should use a complex
routine involving algorithms and thirty-two bit arithmetic, but rather
that the occasional screen effect at key points in the game (such as
the beginning or the hi-score chart) often works really well. So I
thought I'd print you some simple visual machine code routines, so you
could see for yourself just how effective they are.

The following routines are plain and straightforward. They don't use
any obscure instructions or intense calculations, and if you've
already taken the first tentative step on the machine code ladder
(buying an assembler, a good book, and getting down to some serious
trying) then these routines will help you take the next few steps.
Before you know it you'll be at the top of the class and doing Star
Tips for me (I wish).

Anyway, here we have a selection of routines from excellent amateur
programmers including Michael Wilcox, Tom Baker and Giles Cartmel; as
well as an impressive screen compress routine from one Ross Holman.

Next month we'll be back to normal with all the latest from the
greatest. But I have another Pitstop special planned, this time
concerning Loaders. And in this one, apart from a standard fast
loader, we'll have a routine that mimics the Alcatraz system used on
US Gold games and also some strange and weird loaders that surprised
even me.

In the meantime, if you become inspired and feel like having your name
in print, and running the risk of earning yourself fifty
smackeroonies, then send me your programs (Basic or machine code) to
me David McCandless at Program Pitstop, YS, 14 Rathbone Place, London
W1P 1DE.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

EXTRA SPECIAL FX

[The ".s" files in EXTRASFX.TAP are the source files for these        ]
[assembler listings, created with the OCP Editor/Assembler.           ]
[All the errors in the printed listings have been corrected here. JimG]

* DISINTEGRATE *
Tom Baker, renowned for his time travelling adventures but more for
his programming prowess, has written a brilliant disintegrating screen
routine for us. The method is quite simple and well used. In layman's
terms it takes the visual garbage from the ROM and merges it with the
screen, in such a way that you get a distorted fading effect. Quite
clever really, especially when done six or seven times in succession.

0000            00000         org  60000
EA60 110A00     00000  FADE   ld   de,10
EA63 0605       00000         ld   b,5
EA65            00000  ;number of times to fade
EA65 C5         00000  LOOP   push bc
EA66 D5         00000         push de
EA67 76         00000         halt
EA68            00000  ;equivalent to PAUSE
EA68 76         00000         halt
EA69 210040     00000         ld   hl,16384
EA6C            00000  ;address of screen
EA6C 01001B     00000         ld   bc,6912
EA6F            00000  ;length of screen
EA6F 1A         00000  ILO    ld   a,(de)
EA70 A6         00000         and  (hl)
EA71 77         00000         ld   (hl),a
EA72 13         00000         inc  de
EA73            00000  ;add one to DE
EA73 23         00000         inc  hl
EA74 0B         00000         dec  bc
EA75            00000  ;take away one from BC
EA75 78         00000         ld   a,b
EA76 B1         00000         or   c
EA77            00000  ;check to see if BC=0
EA77 20F6       00000         jr   nz,ILO
EA79 D1         00000         pop  de
EA7A 13         00000         inc  de
EA7B C1         00000         pop  bc
EA7C 10E7       00000         djnz LOOP
EA7E 210040     00000         ld   hl,16384
EA81 3600       00000         ld   (hl),0
EA83 E5         00000         push hl
EA84 D1         00000         pop  de
EA85 13         00000         inc  de
EA86 01FF1A     00000         ld   bc,6911
EA89 EDB0       00000         ldir
EA8B            00000  ;clears the screen
EA8B C9         00000         ret


* MOVING BARS *
Michael Wilcox has often graced these pages with his ingenuity and now
here is the first of his instalments - a cunning little number that
prints an eldritch selection of moving bars on the screen, making an
impressive screen effect.

0000            00000         org  32768
8000 210058     00000  LP     ld   hl,22528
8003            00000  ;address of colours
8003 ED5F       00000  LP1    ld   a,r
8005            00000  ;R=refresh register
8005            00000  ;it changes all the time
8005 E620       00000         and  32
8007            00000  ;replace 32 with any
8007            00000  ;number 0-255
8007 77         00000         ld   (hl),a
8008 23         00000         inc  hl
8009 7C         00000         ld   a,h
800A FE5B       00000         cp   91
800C 20F5       00000         jr   nz,LP1
800E 76         00000         halt
800F 76         00000         halt
8010 76         00000         halt
8011 76         00000         halt
8012 76         00000         halt
8013 76         00000         halt
8014 76         00000         halt
8015 76         00000         halt
8016 3A085C     00000         ld   a,(23560)
8019 FE20       00000         cp   32
801B C8         00000         ret  z
801C            00000  ;return to BASIC
801C C30080     00000         jp   LP


* PAN IT *
Ever wanted to scroll windows or even the whole screen smoothly? I bet
you have. Well now you can do it (scroll windows that is) using this
program by Michael Wilcox and not just in a meagre single direction either.

The way it works is fairly simple. A window is specified and then the
program either rotates the eight screen elements (pixels) that make a
byte left or right to produce a scrolling effect.

0000            00000  ;Pixel Scroll Right
0000            00000         org  32768
8000 1610       00000         ld   d,16
8002            00000  ;D=height
8002 1E1F       00000         ld   e,31
8004            00000  ;E=length
8004 2600       00000         ld   h,0
8006            00000  ;H=X AT co-ord
8006 2E00       00000         ld   l,0
8008            00000  ;L=Y AT co-ord
8008 222580     00000         ld   (STORE1),hl
800B 42         00000         ld   b,d
800C C5         00000  LPR1   push bc
800D ED4B2580   00000         ld   bc,(STORE1)
8011 78         00000         ld   a,b
8012 3C         00000         inc  a
8013 322680     00000         ld   (STORE2),a
8016 3D         00000         dec  a
8017 CDB122     00000         call 8881
801A            00000  ;a ROM-based
801A            00000  ;calculation routine
801A 43         00000         ld   b,e
801B CB1E       00000  LPR2   rr   (hl)
801D 23         00000         inc  hl
801E 10FB       00000         djnz LPR2
8020 96         00000         sub  (hl)
8021 C1         00000         pop  bc
8022 10E8       00000         djnz LPR1
8024 C9         00000         ret
8025 00         00000  STORE1 defb 0
8026 00         00000  STORE2 defb 0
8027            00000  ;Use this notation in your
8027            00000  ;assembler to allow variables

0000            00000  ;Pixel Scroll Left
0000            00000         org  32768
8000            00000  ;This puts the code at
8000            00000  ;the selected address
8000 1610       00000         ld   d,16
8002 1E1F       00000         ld   e,31
8004 210000     00000         ld   hl,0
8007            00000  ;as before
8007 222880     00000         ld   (STORE1),hl
800A 42         00000         ld   b,d
800B C5         00000  LPL1   push bc
800C ED4B2880   00000         ld   bc,(STORE1)
8010 78         00000         ld   a,b
8011 3C         00000         inc  a
8012 322980     00000         ld   (STORE2),a
8015 3D         00000         dec  a
8016 CDB122     00000         call 8881
8019 7B         00000         ld   a,e
801A 85         00000         add  a,l
801B 6F         00000         ld   l,a
801C 2D         00000         dec  l
801D 43         00000         ld   b,e
801E B7         00000         or   a
801F CB16       00000  LPL2   rl   (hl)
8021 2B         00000         dec  hl
8022 10F9       00000         djnz LPL2
8024 C1         00000         pop  bc
8025 10E4       00000         djnz LPL1
8027            00000  ;This instruction takes one
8027            00000  ;from B and then jumps to the
8027            00000  ;specified address if B<>0
8027 C9         00000         ret
8028 00         00000  STORE1 defb 0
8029 00         00000  STORE2 defb 0


[All the remaining listings in this section were printed under the wrong]
[descriptions. I've rearranged them correctly here.                 JimG]


* MULTI-FX *
Giles Cartmel materialises again with a wily little generic screen FX
routine. It uses one base program which you modify slightly to provide
the required effect.

To get this to work simply replace the labels (FACTOR 1,2 etc.) in the
main program [with] the entry [in] the table. So for Routine 1 the
program reads:
	LD C,factor1
Change it to:
	LD C,8

Effect			Factor1	Factor2		Factor3		Factor4
Shutter CLS-L		8	RES 0,(HL)	ADC A,8		134
Shutter CLS-R		8	RES 7,(HL)	SBC A,8		190
Shutter FILL-L		8	SET 0,(HL)	ADC A,8		198
Shutter FILL-R		8	SET 7,(HL)	SBC A,8		254
EARTHQUAKE		6	SRA (HL)	SBC A,8		46
Thick EARTHQUAKE	6	RLC (HL)	ADC A,8		6
Shutter FILL-CLS-L	16	RES 0,(HL)	ADC A,8		134
Shutter FILL-CLS-R	16	SET 7,(HL)	SBC A,8		254

0000            00100         org  32768
8000 0E??       00110         ld   c,factor1
8002 210040     00120  LP0    ld   hl,16384
8005 16C0       00130         ld   d,192
8007 0620       00140  LP1    ld   b,32
8009 A7         00150         and  a
800A CB??       00160  LP2    factor2
800C 23         00170         inc  hl
800D 10FB       00180         djnz LP2
800F 15         00190         dec  d
8010 20F5       00200         jr   nz,LP1
8012 3A0B80     00210         ld   a,(LP2+1)
8015 ??08       00220  ADDER  factor3
8017 320B80     00230         ld   (LP2+1),a
801A 0D         00240         dec  c
801B 20E5       00250         jr   nz,LP0
801D 3E??       00260  RESTOR ld   a,factor4
801F 320B80     00270         ld   (LP2+1),a
8022 C9         00280         ret


* BLURRED 'O'EFFECT *
Yes, the routine guaranteed to give you double vision and a headache!
A brain blending routine courtesy of Giles Cartmel which scrolls the
screen both left and right to give a wavering look.

0000            00000         org  32768
8000 0E00       00000         ld   c,0
8002 210040     00000  LP0    ld   hl,16384
8005 3EC0       00000         ld   a,192
8007 0610       00000  LP1    ld   b,16
8009 A7         00000         and  a
800A CB1E       00000  LP2    rr   (hl)
800C 23         00000         inc  hl
800D CB16       00000         rl   (hl)
800F 23         00000         inc  hl
8010 10F8       00000         djnz LP2
8012 3D         00000         dec  a
8013 20F2       00000         jr   nz,LP1
8015 0D         00000         dec  c
8016 20EA       00000         jr   nz,LP0
8018 C9         00000         ret


* UP Y'KNOW *
This up scroll routine ((c) 1988 Michael Wilcox Creations) is cleverly
designed so not only can you scroll the whole screen with the ultimate
in ease and smoothness, but with windows as well. Cor! Unfortunately I
haven't a down scroll routine to couple it with. Anyone oblige?

0000            00000         org  32768
8000 210000     00000         ld   hl,0000
8003            00000  ;X & Y coords
8003 16B0       00000         ld   d,176
8005            00000  ;D=depth in pixels
8005 1E0F       00000         ld   e,15
8007            00000  ;E=width in chars
8007 24         00000         inc  h
8008 15         00000         dec  d
8009 224B80     00000         ld   (STR1),hl
800C 42         00000         ld   b,d
800D C5         00000  UPLP1  push bc
800E ED4B4B80   00000         ld   bc,(STR1)
8012 78         00000         ld   a,b
8013 3C         00000         inc  a
8014 324C80     00000         ld   (STR2),a
8017 3D         00000         dec  a
8018 CDB122     00000         call 8881
801B 224F80     00000         ld   (STR4),hl
801E 7C         00000         ld   a,h
801F 25         00000         dec  h
8020 E607       00000         and  7
8022 200A       00000         jr   nz,ENDUP
8024 7D         00000         ld   a,l
8025 D620       00000         sub  32
8027 6F         00000         ld   l,a
8028 3804       00000         jr   c,ENDUP
802A 7C         00000         ld   a,h
802B C608       00000         add  a,8
802D 67         00000         ld   h,a
802E 224D80     00000  ENDUP  ld   (STR3),hl
8031 2A4F80     00000         ld   hl,(STR4)
8034 7B         00000         ld   a,e
8035 D5         00000         push de
8036 ED5B4D80   00000         ld   de,(STR3)
803A 0600       00000         ld   b,0
803C 4F         00000         ld   c,a
803D EDB0       00000         ldir
803F D1         00000         pop  de
8040 C1         00000         pop  bc
8041 10CA       00000         djnz UPLP1
8043 2B         00000         dec  hl
8044 43         00000         ld   b,e
8045 3600       00000  UPLP2  ld   (hl),0
8047 2B         00000         dec  hl
8048 10FB       00000         djnz UPLP2
804A C9         00000         ret
804B 00         00000  STR1   defb 0
804C 00         00000  STR2   defb 0
804D 0000       00000  STR3   defb 0,0
804F 0000       00000  STR4   defb 0,0


* ENLIGHTENMENT *
Look I know you've confused. I know you don't know your bits from your
bytes, your fingers from your toes, your hexes from your decimals. But
these routines are best suited for those people hovering in the
twilight zone between total incomprehension and total understanding.
It's for those people who have an assembler, a brain, and are
interested in learning the old machine code, yet who also understand a
microbe of the logic behind computers.

And in case you don't know the terminology here's a brief breakdown
(and we are talking ultra-brief):

Byte - the basis of all computers. 1024 bytes make a kilobyte or 'K'.
The Spectrum has 49152 bytes or 48K.

Bits - each byte is made of eight bits (well technically nine but I
won't go into that). Each one can be set or reset. So your average
byte looks like this: 00000000. Each descending bit has the value
128,64,32,16,8,4,2,1 respectively. None of the above bits are set so
the value of the byte is zero. When, however you SET a bit like
10000000, the value of the byte becomes 128 (as the bit on the left
has the value 128). And if the bytes looks like this: 10000001 then
the value is 129.

Easy eh?.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

SQUELCH!
by Robin Holman

[The BASIC listing for this was chopped off in the magazine from the middle]
[of line 70. Making some deductions from comments in the description below ]
[I restored what seem to be likely versions of the missing lines to give a ]
[working demo program.                                                 JimG]

If you're one of those people who write a three line letter all the
way from Australia just to tell me that I made a spelling mistake on
page 92 of the August issue, then you'll probably complain that this
routine isn't technically a screen effect. Well it is, so shuddup.
This program squelches a screen, attributes and all, in such a way
that a cute cuddly miniature of it appears. Great eh? And it's easy to
use too!

Method
Use the Hex Loader to load the hex listing into 50000 and save it with
SAVE "squelch1" CODE 50000,218. Then type in the little Basic
controller and save it with SAVE "squelch2" LINE 90. Then RUN the
program.


SQUELCHING
Firstly the program'll ask you for Y co-ord (0-12) and then an X
co-ord (0-16), these are the co-ordinates where the compressed screen
will appear. Then you'll have to load in a screen, so have a tape on
hand; and after you've loaded in a screen - squelch! The compressed
version then appears on screen. This can be repeated again and again
simply by pressing L until the screen is full of squelched screens.
Once you've a competent number of compressed graphics bursting out all
over the TV you can save the whole lot by pressing E. Simple innit?

INDEPENDENT COMPRESSION
Should you wish to utilise the code outside normal working hours (and
Basic program) here are some details you should know.

* To compress the current screen use:
  POKE 50003, X co-ord (0-16)
  POKE 50001, y co-ord (0-12)
  RANDOMIZE USR 50000
* The compressed screens reside at 32768 to 39680
* The program uses addresses60000 to 60012 as temporary storage

A great screen clearing effect can be created if you repeatedly call
the squelch routine until the screen disappears.

SQUASH!
Well that just about wraps it up as they say. But Robin does say that
he doesn't mind people using the routine in their own programs
although he doesn't want it copied out to jam into a fanzine. Got that.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Don't forget, if you have any mind-boggling, ear flapping routines
just drop me a line (and your program) at Program Pitstop, Your
Sinclair, 14 Rathbone Place, London W1P 1DE. Best program printed gets
a #50 cash prize.
