!0.......^.........^.........^..

!B

\H11\H07\H10\H00          THROUGH THE           

\H11\H07\H10\H02          S Q U A R E           

\H11\H07\H10\H00          W I N D O W           



!2.......^.........^.........^.........^.........^.........^....

  Lose yourself in machine code with the maestro herself. Toni

Baker takes you one step nearer creating the perfect arcade game

                 with another riotous routine.

!0.......^.........^.........^..



NOTE

!1.......^.........^.........^.........^........

>See  also the letter "Short Cut to Amaze"  from

>issue #6, after the main article.





This month I'm presenting an interesting  little

routine  that  fits  happily  into many a  video

game.  The gist of it is really very simple -  a

'window' appears in the top right-hand corner of

the screen and on it you can see part of a maze.

The cursor keys: '5', '6', '7' and '8' - without

shift - will scroll the window over the maze  in

all  four directions (actually eight  directions

because  you  can go diagonally by pressing  two

keys at once). In other words, the window allows

you to see a smaller part of a much larger  maze

-  by moving the window you can cover the  whole

maze, but you can never see all of it at once.

  So,  what  can  you  do  with it? Well, as  it

stands you can probably have a bit of fun trying

to find your way out of the maze - you start  at

the  'S'  character  and finish at the 'F'.  The

fact that you can only ever see part of the maze

doesn't  spoil the game - it just makes it  that

much  harder!  But  if you wanted to, you  could

adapt  the routine (or add more Basic) and  make

quite a comprehensive game. The window is always

printed in the same place in black INK on  white

PAPER,  but note that the normal PRINT  position

(as  well  as PAPER and INK colours) is  totally

unaffected by the machine code.

  The  Basic  is  completely  separate from  the

machine  code. By calling the machine code  from

Basic  you will scroll the window either not  at

all or by just one square; thus, if you want  to

move continuously, all you have to do is repeat-

edly  call  the  machine code routine, over  and

over again. Of course, any number of Basic lines

may be placed between these calls.



!0.......^.........^.........^..

!B

SERIOUSLY NOW

!1.......^.........^.........^.........^........

Just  on  the  off  chance  that  there are  any

serious  machine code programmers reading  this,

you  may  be  interested in the 'CALL  HL=HL*DE'

instruction used in the program. This is a  sub-

routine  in the ROM which, as its name  implies,

multiplies  HL by DE, leaving the result in  HL.

The BC and DE registers are unaffected, but  the

A register is corrupted.

  Once  again,  I've  put question marks in  the

listing  of  the Hex codes, instead of  absolute

addresses  - so you can locate the machine  code

anywhere you want to. Once you've decided  where

to put it you have to replace the question marks

by the address of the instruction which has  the

label  that  I've  specified.  In other words  -

where it says 'CD???? CALL INC_COORD', you  must

replace  the question marks with the address  of

the   instruction   labelled  'INC_COORD'.  This

address  must  be  in Hex and with the bytes  in

reverse order.

  There  are  two variables used by the  program

which  you  can POKE from Basic if you want  to.

These  are  X_COORD and Y_COORD which store  re-

spectively  the  X  and Y coordinate of the  top

left-hand corner of the window (relative to  the

top  left-hand  corner of the maze). X_COORD  is

stored in address 23728, and Y_COORD in 23729.

  So there you have it! No longer need you spend

tiresome hours running round Hampton Court - now

you  can spend those tiresome hours wearing  out

your fingers instead. Happy head scratching!



!2.......^.........^.........^.........^.........^.........^....

!B

Machine code       Assembler          Comments

---------.---------.------------------.-------------------------

7E       INC_COORD LD   A,(HL)        A:=coordinate to change

FE18               CP   Length-8

C8                 RET  Z             Return if coordinate is at

                                      the maximum

34                 INC  (HL)          Increment coordinate

C9                 RET

---------.---------.------------------.-------------------------

7E       DEC_COORD LD   A,(HL)        A:=coordinate to change

A7                 AND  A

C8                 RET  Z             Return if coordinate is at

                                      the minimum (zero)

35                 DEC  (HL)          Decrement coordinate

C9                 RET

---------.---------.------------------.-------------------------

3EF7     START     LD   A,#F7

DBFE               IN   A,(#FE)       Scan segment 3 of the k/bd

E610               AND  #10           A:=10 if '5' pressed,

                                      00 otherwise

47                 LD   B,A

3EEF               LD   A,#EF

DBFE               IN   A,(#FE)       Scan segment 4 of the k/bd

E604               AND  #04           A:=04 if '8' pressed,

                                      00 otherwise

B0                 OR   B

21B05C             LD   HL,X_COORD    Prepare to adjust the X

                                      coordinate

FE04               CP   #04

2809               JR   Z,RIGHT       Jump if '8' pressed,

                                      but not '5'

FE10               CP   #10

2008               JR   NZ,UP/DOWN    Jump unless '5' pressed

                                      without '8'

---------.---------.------------------.-------------------------

CD????   LEFT      CALL INC_COORD     Increment the X coordinate

                                      (Note window moves right,

                                      hence maze moves left.)

1803               JR   UP/DOWN

---------.---------.------------------.-------------------------

CD????   RIGHT     CALL DEC_COORD     Decrement the X coordinate

---------.---------.------------------.-------------------------

3EEF     UP/DOWN   LD   A,#EF

DBFE               IN   A,(#FE)       Scan segment 4 of the k/bd

E618               AND  #18           A:=08 if '7' pressed,

                                      10 if '6' pressed,

                                      18 if both '7'&'6' pressed

                                      or 00 if neither pressed

21B15C             LD   HL,Y_COORD    Prepare to adjust the Y

                                      coordinate

FE10               CP   #10

2809               JR   Z,DOWN        Jump if '6' pressed,

                                      but not '7'

FE08               CP   #08

2008               JR   NZ,WINDOW     Jump unless '7' pressed

                                      without 6

---------.---------.------------------.-------------------------

CD????    UP       CALL INC_COORD     Increment the Y coordinate

1803               JR   WINDOW

---------.---------.------------------.-------------------------

CD????    DOWN     CALL DEC_COORD     Decrement the Y coordinate

---------.---------.------------------.-------------------------

2A845C    WINDOW   LD   HL,(DF_CC)

E5                 PUSH HL            Stack PRINT position

2A885C             LD   HL,(S_POSN)

E5                 PUSH HL            Stack PRINT coordinates

AF                 XOR  A             A:=00

323C5C             LD   (TVFLAG),A    Print to the upper part

                                      of the screen

FD365538           LD   (ATTR_T),#38  Set colours to black on

                                      white

2AB15C             LD   HL,(Y_COORD)  L:=Y coordinate of the

                                      window

67                 LD   H,A           HL:=Y coordinate of the

                                      window

112000             LD   DE,Length     DE:=size of the maze

CDA930             CALL #30A9,HL=HL*DEHL:=(Y coordinate)

                                      * (size of maze)

ED5BB05C           LD   DE,(X_COORD)  E:=X coordinate of the

                                      window

57                 LD   D,A           DE:=X coordinate of the

                                      window

19                 ADD  HL,DE         HL:=square number of the

                                      window position

11????             LD   DE,MAZE       Point DE to the start of

                                      the maze

19                 ADD  HL,DE         Point HL to the

                                      appropriate square

110108             LD   DE,#0801      D:=count (number of rows

                                      to print, E:= PRINT AT

                                      coordinate required

---------.---------.------------------.-------------------------

3E16     LOOP_1    LD   A,"at_ctrl"

D7                 RST  #10           PRINT AT

7B                 LD   A,E

D7                 RST  #10           required row,

3E17               LD   A,#17

D7                 RST  #10           17h;

0608               LD   B,#08         B:=number of columns in

                                      the window

---------.---------.------------------.-------------------------

7E       LOOP_2    LD   A,(HL)        A:=next character from the

                                      maze

23                 INC  HL            Point to next character

D7                 RST  #10           Print this character in

                                      window

10FB               DJNZ LOOP_2        Print the whole row

0E18               LD   C,Length-8    BC:=displacement to the

                                      next row of the window

09                 ADD  HL,BC         Point HL to the next row

1C                 INC  E             Increment PRINT AT pos'n

15                 DEC  D

20EA               JR   NZ,LOOP_1     Repeat for all rows

E1                 POP  HL

22885C             LD   (S_POSN),HL   Restore PRINT coordinates

E1                 POP  HL

22845C             LD   (DF_CC),HL    Restore PRINT position

C9                 RET

!0.......^.........^.........^..



!2.......^.........^.........^.........^.........^.........^....

!B

10 PLOT 183,103     Construct a frame for the window

20 DRAW 0,65

30 DRAW 65,0

40 DRAW 0,-65

50 DRAW -65,0

60 LET l=USR ?????  This refers to the label START

70 GO TO 60



!0.......^.........^.........^..

!B

\H11\H07\H10\H00USER DEFINED GRAPHICS           

!2.......^.........^.........^.........^.........^.........^....

Type this Hex into the User Defined Graphics area of your m/c.

!0.......^.........^.........^..

Graphc A 00 00 00 00 00 00 00 00

Graphc B 01 01 01 01 01 01 01 01

Graphc C 80 80 80 80 80 80 80 80

Graphc D 81 81 81 81 81 81 81 81

Graphc E FF 00 00 00 00 00 00 00

Graphc F FF 01 01 01 01 01 01 01

Graphc G FF 80 80 80 80 80 80 80

Graphc H FF 81 81 81 81 81 81 81

Graphc I 00 00 00 00 00 00 00 FF

Graphc J 01 01 01 01 01 01 01 FF

Graphc K 80 80 80 80 80 80 80 FF

Graphc L 81 81 81 81 81 81 81 FF

Graphc M FF 00 00 00 00 00 00 FF

Graphc N FF 01 01 01 01 01 01 FF

Graphc O FF 80 80 80 80 80 80 FF

Graphc P FF 81 81 81 81 81 81 FF



!B

\H11\H07\H10\H00DATA FOR MAZE                   

!2.......^.........^.........^.........^.........^.........^....

It's worth getting a friend to help you type this lot in!

!0.......^.........^.........^..

53 9C 94 9C 94 9C 9C 9C

9C 9C 9C 9C 9C 9C 94 94

9C 9C 9C 9D 96 9C 9C 9C

9C 9C 9C 9C 9C 9C 9C 9D

93 97 93 97 92 9C 9C 9C

9C 9C 9C 9C 9C 95 93 93

9C 9C 9C 9C 98 9C 9C 9C

9C 9C 9C 9C 9C 9C 9C 95

92 98 99 93 9A 9C 9C 9C

9C 9C 9C 9C 95 93 93 93

93 96 9C 9C 9C 9C 9C 9C

9C 9C 9C 9C 9C 9C 95 93

93 9E 9C 98 9C 9C 94 9C

9C 9C 9C 9D 93 93 93 93

93 93 96 9C 9C 94 9C 94

9C 9C 9C 9C 9C 95 93 93

92 9C 9C 9C 9C 9D 93 9E

9C 9C 9C 9C 99 93 93 93

93 93 9A 9C 95 93 97 93

96 9C 9C 9C 95 93 93 93

93 9E 9C 9C 9C 9C 98 9C

9C 9C 9C 9C 9C 91 93 93

93 9A 9C 95 93 93 93 93

93 96 9C 95 93 93 93 93

92 9C 9C 9C 9C 9C 9C 9C

9C 9C 94 9C 95 93 93 93

92 9C 9C 99 93 93 93 93

93 93 97 93 93 93 93 93

93 9E 9C 9C 9C 9C 94 9C

9C 9D 93 97 93 93 93 93

93 9E 9C 9C 99 93 93 93

93 93 93 93 93 93 93 93

92 9C 9C 9C 9C 95 93 9E

9C 9C 99 93 93 93 93 93

9A 9C 9C 9C 9C 99 93 93

93 93 93 93 93 93 93 93

9A 9C 9C 9C 9D 93 93 96

9C 9C 9C 99 93 93 93 92

9C 9C 9C 9C 9C 9C 99 93

93 93 93 93 93 93 9B 93

9E 9C 9C 9C 9C 91 9A 91

96 9C 9C 9C 99 99 93 9B

96 9C 9C 9C 9C 9C 9C 99

93 93 93 93 93 92 9C 99

96 9C 9C 9C 9D 9A 95 93

93 96 9C 9C 9C 99 9A 9C

99 96 9C 9C 9C 9C 9C 9C

99 93 93 93 93 93 96 95

93 96 9C 9C 95 97 93 93

93 9A 9C 9C 9C 9C 9C 9C

9C 91 96 9C 9C 9C 9C 9C

9C 99 93 93 93 93 9B 93

93 93 9E 9C 99 93 93 93

92 9C 9C 9D 96 9C 9C 9C

9D 93 93 96 9C 9C 9C 9C

9C 9C 91 93 93 92 9C 91

93 93 96 9C 9C 99 93 93

9A 9C 9C 9C 91 9E 9C 9C

95 93 93 93 96 9C 9C 9C

9C 95 93 93 93 93 97 93

93 93 93 9E 9C 9C 99 9A

9C 9C 9C 95 9A 9C 9C 95

9A 99 93 93 93 9E 9C 9C

95 93 93 93 93 93 93 93

93 93 92 9C 9C 9C 9C 9C

9C 9C 9C 98 9C 9C 95 9A

9C 94 99 93 9A 9C 9C 9D

93 93 93 93 93 93 93 93

93 93 93 96 9C 9C 9C 9C

9C 9C 9C 9C 9C 95 92 9C

9D 93 9E 98 95 96 9C 9C

99 93 93 93 93 93 93 93

93 93 93 93 96 9C 9C 9C

9C 9C 9C 9C 95 93 93 9E

9C 98 9C 95 93 93 96 9C

9C 99 93 93 93 93 93 93

93 93 93 93 93 96 9C 9C

9C 9C 9C 95 93 93 9A 9C

9C 9C 95 93 93 93 93 96

9C 9C 99 93 93 93 93 93

93 93 93 93 93 93 96 9C

9C 9C 95 93 93 92 9C 9C

9C 95 93 93 9A 99 93 93

96 9C 9C 99 93 93 93 93

93 93 93 93 93 93 93 96

9C 95 93 93 93 93 96 9C

95 93 93 9A 9C 9C 99 93

93 96 9C 9C 99 93 93 93

93 93 93 93 93 93 93 93

97 93 93 93 93 93 93 97

93 93 9A 9C 9C 9C 9C 99

93 93 96 9C 9C 99 93 93

93 93 93 93 93 9A 98 99

93 93 93 93 93 9B 93 93

93 9A 9C 9C 94 9C 9C 9C

99 93 9B 96 9C 9C 99 93

93 93 93 93 9A 9C 9C 9C

99 93 93 93 92 9C 91 93

9B 96 9C 9C 99 9E 9C 9C

9C 98 9C 91 96 9C 94 99

93 93 93 9A 9C 9C 9C 9C

9C 99 93 93 93 97 93 92

9C 99 9E 9C 9C 9C 9C 9C

9C 9C 95 93 93 97 93 96

93 93 9A 9C 9C 9C 9C 9C

9C 9C 99 93 9B 93 93 93

96 95 96 9C 95 9E 9C 9C

9C 95 93 9B 93 93 92 91

93 92 94 94 9C 9C 9C 9C

9C 9C 9C 98 9C 99 93 93

93 9B 93 97 92 9C 9C 9C

95 93 9A 9C 99 93 93 9B

9C 9C 9A 91 9C 9C 9C 9C

9C 9C 9C 9C 9C 9C 99 93

93 96 99 92 90 9C 9C 95

93 9A 9C 9C 9C 98 98 9D

93 93 97 93 93 9E 9C 9C

9C 9C 9C 9C 9C 9C 9C 99

93 93 96 99 92 9C 95 93

9A 9C 9C 9C 9C 9C 9C 95

93 9A 99 93 9A 9C 9C 94

9C 9C 9C 9C 9C 9C 9C 9C

99 93 93 9E 99 97 93 9A

9C 9C 9C 9C 9C 9C 95 93

9A 9C 9C 98 9C 9C 9C 98

9C 9C 9C 9C 9C 9C 9C 9C

9C 99 9A 9C 9C 99 9A 9C

9C 9C 9C 9C 9C 9D 9B 46

!1.......^.........^.........^.........^........



!B

--

from Your Spectrum #4 (Jun.1984)

--







!0.......^.........^.........^..

!B

SHORT CUT TO AMAZE

!1.......^.........^.........^.........^........

Toni  Baker has a marvellous knack of coming  up

with  something  fresh  and her Maze program  in

issue  4 of Your Spectrum is no exception.  How-

ever,  those  of  us  (like  me) who were a  bit

daunted by the idea of correctly keying in  1024

Hex  pairs might revive their spirits with  this

little routine, which automates the operation as

much as possible.

  Looking at the ranks of numbers - like  Napol-

eon's army on the march - I thought "I'll  never

do  it". "It's worth getting a friend to  help",

she says; so why not use our friendly Speccy?

  Look  carefully at it. First, all the  numbers

start  with a '9', so that's something the  com-

puter  can look after; there's no point  wearing

your  own fingers out doing the same thing  over

and  over  again. That's one of the things  com-

puters are for!

  Secondly,  it's  much  easier  to keep in  the

correct  place  if  you  arrange  to  enter  the

numbers  in  rows of eight, to match the  print-

out in Your Spectrum.

  Thirdly, it would be nice to have the computer

keep  the score, by getting it to print out  the

line  and  column  numbers  as  it goes along  -

another thing it's good at.

  So here's the result of a short session at the

keyboard. It enabled me to key in all 1024 bytes

in  about  half  an  hour.  You can go back  and

correct  a  section  by entering GO TO 200 as  a

direct  command  and  then  INPUTting  the  line

number  on  cue.  I'm  confident  enough of  the

result  to think there are some glitches in  the

listing in the last few lines, but I don't  know

exactly  what  they should be to get a  properly

drawn  pattern. Also, there's a misprint in  the

code listing: 'ED 5B B1 5C', half-way down  page

22,  should  be 'ED 5B B0 5C', in order to  load

the x coordinate.

  Anyhow, all mazes baffle me, even when printed

out  in full - let alone seen in bits through  a

square keyhole!



John Durst, Swerford, Oxon



--

letter from Your Spectrum #6 (Aug.1984)

--



!0.......^.........^.........^..

!B

  1 POKE 23658,8: CLEAR 57340

  5 LET col=0: LET lin=1

 10 LET col=col+1: IF col=9 THEN

 LET col=1: LET lin=lin+1: CLS

 15 PRINT AT 10,0;"MAZE DATA -"'

"next entry: Line ";lin;" Entry

";col

 20 IF INKEY$="" THEN GO TO 15

 30 LET n=CODE INKEY$

 40 IF n=13 THEN STOP

 50 IF n=45 THEN LET col=col-(co

l>0): PRINT OVER 1;AT 13,0;TAB 4

+3*col;OVER 0;"   ": GO TO 110

 60 IF NOT ((n>=48 AND n<=57) OR

 (n>=65 AND n<=70)) THEN GO TO 1

0

 70 LET n=n-48-7*(n>=65)

 80 PRINT AT 13,0;"Entry:";OVER

1;TAB 4+3*col;OVER 0;" 9";INKEY$

 90 POKE 57343+col+8*(lin-1),n+1

6*9

110 IF INKEY$<>"" THEN GO TO 110

120 GO TO 10

199 STOP

200 INPUT "lin";lin: LET col=0

210 PAUSE 10: GO TO 10



!2.......^.........^.........^.........^.........^.........^....

Make the Spectrum do the work when keying in lots of Hex pairs.

!0.......^.........^.........^..



--

!$

