                        Grandstand



      The Middlesex master ZX80 programmer Mike Hyams

            strikes again with a Strategy game!



[ Ok, this one needs explaining. What is a ZX80 game doing

  on a Spectrum? Well, it's like this. In June 1985, this

  game was published by ZX Computing, and at that time it

  was indeed a ZX80 game. But in next year's February

  edition, the Problem Page was taken over by a project to

  port this (evidently quite popular) program to the newer

  machine. This text contains both the original program's

  text, and the conversion notes. The accompanying TZX

  contains the resulting Spectrum game.

  All text below between square brackets is my own, not

  part of the publlished articles. The part after this up

  to the first line is the original, ZX80 article; the bit

  after that, to the second line, is the conversion Problem

  Page; at the end, there are some final notes of my own. ]



ZX80 owners of the world arise. At last you can join the

massses with a football management simulation. No longer

will you have to endure the seven day wait between editions

of "Match of the Day". [And remember, these were the days

when viewers didn't even have Gary Lineker's aerofoil ears

to keep them amused!] Grandstand, a game of strategy, takes

you into the world of football wheeling and dealing.

   Don't be fooled into thinking that because it's for a

ZX80 it must be a poor version. Grandstand takes up over

15K when running and pulls no punches when it comes to

detail. At the start of the game you can choose from any

team in the four divisions plus a large selection of non-

league clubs. Once you have chosen your team they are

placed at the bottom of division four.

   At the beginning of each session there is a pause of

about a minute [about half a minute, or less, on the rather

faster Spectrum, or a few seconds under emulation...] while

the F.A. Cup first round draw is made. Each season is a

major undertaking as full league tables are supported. This

means 46 games in Division 4, plus any cup games played. As

it will take quite some time to play even one season, now

is a good time to explain saving to tape. At the beginning

of each week, option 4 allows you to save the game so far

to tape. After you have acknowledged that you really do

want to save, place a blank tape in the cassette player

(not the master copy) and start recording. Then press NEW-

LINE anm wait about six minutes while it saves. It is ad-

visable to save again if you are not too confident of your

recorder. As the SAVE command returns the computer to com-

mand mode the program automatically stops. To restart the

game, and to start a game that has been loaded from a pre-

vious session, type GO TO 600. [As explained below, this is

not necessary on the Spectrum. If you happen to break out

of the game, though, this is the way to restart the Speccy

version as well.]

   The F.A. Cup is present in all its glory, showing all

the results even when you are no longer in the cup. At the

end of each season the promotions and relegations are cal-

culated, and if you are lucky enough to gain promotion you

will find life harder the further up the divisions you go.

   One last note: keep a careful eye on your bank balance.

As there are no facilities for bank loans, the Board of

Directors will take a very dim view of going into the red,

and will not hesitate to show you the door.



___________________________________________________________



                       Problem Page



This issue I [no name given; from other issues, I believe

"I" may be David Nowotnik] had an offer I couldn't refuse,

Ray the Ed asked me to give some advice on how GRANDSTAND,

which we published a couple of months back for the ZX80,

could be converted for the Spectrum. Apparently he has been

inundated with pleas for help!



 Data



The first thing is that DATA is simulated in lines 1 to 7

[using a series of REM statements which are peeked into],

so change lines 1 to 7 to DATA lines so that each follows

the format:



    1 DATA "Liverpool","[Red Scum]","Nottm. F.","Q. P. R.",

           and so on



until all the names are entered. There is no need to be

precise with each name being nine characters long, but a

maximum length of nine characters is wise.

   The main use of this data is made in lines 22 to 38, so

remove all these lines and replace them with



    22 RESTORE a

    23 FOR c=1 TO b: READ o$: NEXT c

    24 FOR c=1 TO LEN o$

    25 PRINT o$(c);: PAUSE 25

    26 NEXT c

    28 RETURN



Briefly, the subroutine at line 31 does the same as the

RESTORE (now in line 22). Line 23 reads the DATA until the

required name is in o$ and the loop from 24 to 26 prints

out each letter of the name. PAUSE 25 causes a slight delay

to imitate the TV teletype style printing [which I've left

out, as I found it needlessly annoying].

   Lines 9952 and 9955 need to be changed to RESTORE a to

allow for the removal of the subroutine at 31. If you find

any GO SUB 30 lines which I've missed then don't forget to

change them yourself to RESTORE a. [There weren't any.]

   The random number routine is different in the ZX80 and

ALL occurrences of RND(number) should be replaced by:



    INT (RND*number+1)



So the line 120 should read:



    120 LET c(a)=INT (RND*10+1)+10



[ At this point it is worth noting that the author has

failed to mention some specifics of the ZX80 which are

absent or different on the Spectrum and must be changed for

the program to work. The first, trivial, is that in two

lines the program prints lines of the raster graphics which

are built into the ZX80/81 character set, but absent from

the Speccy. To retaliate against this ignominy, I have re-

placed these with solid, but coloured lines, something the

ZX80 doesn't have. Which is the better computer now, hey?

Also, the comma separator on the ZX80 jumps to the next

multiple of 8 columns, rather than to 16 and 0. This can

easily be replicated using TAB, though, and was only a

problem in a few spots anyway.

   More serious is that the ZX80, unlike the Spectrum and

even the ZX81, only has integer, i.e. whole, numbers. This

means, most importantly, that divisions are always rounded

down. If this is not emulated on the newer machines by

always wrapping divisions in INT, you get weird numbers on

screen which wrap around due to all the decimals. More

importantly, though, multiple unrounded numbers can add

(or multiply) up to an index which can cause an Subscript

Wrong error. I believe I've taken care of all of these, but

I may have missed one. I have tested the whole program for

an entire season, but there are random branches and in any

case I'm not very good at this kind of program, so if you

run into such errors, this is probably the cause. ]



 Save



The Save routine is pretty straightforward, but I would

change it to 1550 SAVE "grandstand" LINE 1010, and line

1560 to GO TO 1010.

   The PEEK 16421 in line 3490 is a way of checking for a

full screen. The Spectrum does not need this line as it

will offer a scroll when the screen is full. [In fact, it

won't even need to do that, as you've just pressed ENTER on

INPUT to get there.] Therefore leave out line 3490. However

it appears again in line 8342 where its purpose is diffe-

rent, so to get the same result change the 16421 to the

Spectrum address 23689 (this can also be done [to no effect

- v.s.] in line 3490 if you wish), also the same appears in

line 8515 and 8516.

   The lines from 9960 to 9988 print the title screen. Re-

place all these with artwork of your own or, if you do not

want to go to the trouble, simply omit them except for

9988 RETURN. Leave this last line in because at some points

the program will jump to this routine and it is best to

keep it in case you fail to find all the GO SUB 9960 state-

ments. [I'm puzzled by this. There are no such GO SUBs

except for the one at game start-up, and the one at line

600. The latter is never called by the program itself but,

as explained in the first article, is intended to be the

re-entry point for saved games. In fact, I've taken the

liberty of changing line 1550, referred to above, to save

to re-start from there.] I would put some simple title in

anyway, even if it is only to print the name of the game.

[I have, in fact, copied the ZX80 title page, as accurately

as I could.]

   Now for the hardest bit of all; lines 9952 to 9959 deal

with movement of teams by poking information around the

REMs. We have to find another waty, so perhaps it is worth

going back to standard principles, and writing the program

in a more structured way. Add lines:



    9019 DIM o$(149,9): REM I counted 149 data items.

    9020 RESTORE: FOR i=1 TO 149

    9021 READ o$(i): NEXT i



Now all the data is held in the elements of array o$() and

so lines 22 to 28 can be further modified to:



    22 GO SUB 26

    23 FOR c=1 TO 9

    24 PRINT o$(b+x,c);: PAUSE 25

    25 NEXT c

    26 LET x=VAL "000022044068092124125"(((a-1)*3+1)

  TO ((a-1)*3+3))

    27 RETURN



Apart from line 22, which gosubs to 26 to get the position

in o$() that the name now occupies and then returns to the

same routine (recursive), the lines are straightforward.

   Making the transfers also becomes simple, replace lines

9952 to 9959 with:



    9952 GO SUB 26: LET aa=x

    9953 LET a=c: GO SUB 26

    9954 [ LET v$=o$(d+x) - this line was missing from the

  article, but clearly so intended - after all, v$ must

  have come from somewhere, and this is the standard swap.

    9955 ] LET o$(d+x)=o$(b+aa)

    9956 LET o$(b+aa)=v$

    9957 RETURN



Now, the reason we had the funny recursive positioning of

line 26 becomes clear, we can use it from this routine to

determine the x value. Once the two positions of the teams

have been determined then they are swapped.

   Finally, I have written this as I developed the conver-

sions deliberately in an attempt to demonstrate how a

problem may be solved and then resolved as a conversion

progresses. Structured programming is great, providing you

have all the functions you require available. The ZX80 and

81 do not have data capabilities and the ways of emulating

it are many and varied, this was a clever but fairly

straightforward method.

   Of course, there are other ways, looking at it in retro-

spect I would probably use a three dimensional array DIM

o$(32,7,9) and read each of the seven REM/DATA separately,

then the awkward line 26 could be left out as the 'a' value

becomes the second element - i.e. line 24 would become

PRINT o$(b,a,c) and lines 22 and 26 would be redundant.

Many lines could also be compressed into multi-line state-

ments, and by using the DEF FN function several of the

calculations could be speeded up and performed more effi-

ciently.

   I hope this has given you all some ideas, personally I

find converting programs second only to creating an origi-

nal for giving satisfaction, and as always, if you have a

problem drop me a line, and I'll do my best to help.



___________________________________________________________





[ Take care that, though this game takes only 15K on the

ZX80, it will not run on the 16K Spectrum. For one, the

screen on the Speccy takes 6K all on its todd, while on the

ZX80 it takes at most* 726 bytes. To make matters worse,

numbers on the ZX80 take 2 bytes (they are 15-bit-plus-sign

integers) while on the Spectrum, they all take 5 bytes,

integral or no. Finally, in accordance to the notes above,

the Spectrum conversion adds a rather large array. The

result is a game which takes some 22 kilobytes to run - and

that's free memory, not total RAM.

(*Yes, at most. Sometimes it takes less. The ZX80 was an odd

beast, in many ways. The ZX81 inherited this oddity - be

grateful that the Spectrum didn't.) 



Note also that the above is all the hints you got about the

game mechanics, external as well as internal, even with the

original game. You were expected to figure out which stats

are good and which are bad from playing the game. And no,

I'm not going to explain in any more detail, either.

                              Richard Bos, February 2012. ]