Recently one of our members, Robert Shade, sent me a suite of disks. These disks had a menu routine which I thought was interesting. I could not resist re-working parts of it. It became an interesting programming exercise, which I thought I would share with other club members.
We tend to assume that everyone knows how to program, forgetting that there are many who may not be adept at it. I hope that this description may be useful to these members.
The listing is below, and following it are comments on the intent of each program line.
1 REM DISK MENU
2 GO TO 5
3 CLEAR 26000: BORDER 0: PAPE
R 0: INK 0: CLS : RANDOMIZE USR
102: GO TO 10
4 PRINT USR 64300: PRINT CHR$
2
10 CLEAR 65366: PRINT USR 100:
OPEN #4,"dd"
20 LET X=7: DIM C$(X,9)
30 DATA " HELP! HELP! HELP! ",
" "
40 DATA "LORDS OF CHAOS","LORD
CH.C1","SAMURAI","SAMURI.C1","BL
ACK LAMP","BKLAMP.C1","DAN DARE
II","DANDAR.C1","RED DOOR","RDLO
AD.B1","CHUBBY GRISTLE","CHUBBY.
C1"
50 DATA " "
60 DATA " "
80 POKE 23658,8
90 PRINT #4: POKE 8200,16350:
RANDOMIZE USR 23310
100 BORDER 1: PAPER 1: INK 6: C
LS
110 PRINT AT 1,4; INVERSE 1;"
";AT 2,4;"
SPECTRUM GAMES DISK ";AT 3,4
;"
"; INV
ERSE 0
120 RESTORE 30: PRINT AT 5,0: F
OR N=1 TO X: READ D$: PRINT TAB
2; PAPER 3; INK 7;"<";N;">"; PAP
ER 1;TAB 7; PAPER (1 AND N<>1)+(
7 AND N=1); INK (6 AND N<>1)+(2
AND N=1);D$; INK 5;(" GAME" AND
N<>1 AND N<>3 AND N<>6)+(" DEMO"
AND N=3)+(" ADVENTURE" AND N=6)
: PRINT
130 READ C$(N)
140 NEXT N
150 PRINT AT 21,8; PAPER 0; INK
6;" SELECT BY NUMBER "
160 PAUSE 0: LET JUMP=CODE INKE
Y$-48: IF JUMP>X THEN GO TO 160
170 IF JUMP=1 THEN GO TO 3000
180 IF JUMP=2 OR JUMP=6 THEN P
RINT #4: LOAD C$(JUMP)CODE
190 GO SUB 200: RANDOMIZE USR 1
00: LOAD C$(JUMP)CODE
200 BORDER 0: PAPER 0: INK 0: C
LS
210 PRINT #4: LOAD ("SAMSC1.C1"
AND JUMP=3)+("BLPSC1.C1" AND JU
MP=4)+("DANSC1.C1" AND JUMP=5)+(
"CHUBSC.C1" AND JUMP=7)SCREEN$ :
PAUSE 300
220 IF JUMP=3 THEN PRINT #4: L
OAD C$(JUMP)SCREEN$ : PAUSE 300
230 RETURN
3000 GO SUB 5000
3010 RANDOMIZE USR 100: PRINT "h
elp07.CT": PRINT CHR$ 2: PRINT '
"End of File...Press key for men
u"
3020 PAUSE 0: GO TO 1
5000 INK 0: PAPER 7: BORDER 7: C
LS
5010 IF PEEK 60900<>124 THEN RA
NDOMIZE USR 100: LOAD "taswi.Cs"
CODE
5020 RANDOMIZE USR 60826: RANDOM
IZE USR 60899: RANDOMIZE USR 643
00: PRINT CHR$ 3: RETURN
8000 INK 0: PAPER 7: BORDER 7: C
LS : LIST : STOP
9000 CLEAR 27000: RESTORE 9030:
FOR n=23300 TO 23309
9010 READ a: POKE n,a
9020 NEXT n
9030 DATA 205,102,0,62,3,211,244
,201,0,0
9040 RANDOMIZE USR 23300
9050 RUN
9994 STOP
9995 RANDOMIZE USR 100: SAVE "ME
NU.B1" LINE 10
9996 STOP
Program description
LINE 3 – This is the line used to save the program as a SPECTRUM AUTOSTART. That is to say, you must have a Spectrum ROM manually switched in when you want to use this AUTOSTART menu. If you want to use the Spectrum EPROM mounted on the Larken cartridge you would use Line 9000.
The CLEAR 26000 is used to ensure that the AUTOSTART file is less than one Larken disk track in length (5090 bytes). The SAVE starts at memory address 22490, and continues to the address 26000. We could have used a Clear 27500 (27500-22490=5010), if we had needed more room for the menu program, and still use only one track.
LINE 4 – We jump skip over Line 4 since this entry is needed only after the HELP file has been called up. If we do a USR call to 64300 without the “taswi.Cs” code in place the computer will crash. See Line 5010 description).
We clear the screen before saving the file, simply for neatness. RAND USR 102 is the Larken AUTOSTART SAVE command.
LINE 10 – Clears the computer memory to just below the User-defined graphics area of memory. Also opens the TS2068 Channel 4 to the abbreviated Larken disk command “PRINT #4:”; used instead of “PRINT USR 100:”.
LINE 20 – Sets variable “X” to the number of options to appear on the screen. Also dimensions the C$ array. The C$ array is used to hold the Larkenized program names held in the data statements of Lines 30 to 60.
LINE 30 – We have put the HELP option in a separate LINE. Line 120 could be simplified if you wish to use imbedded colour codes in this “HELP” data. Note there are two pieces of data in this line; the second being simply a space. The “space” data is stored in the first entry of the C$ array. We don’t actually make use of it; it is needed to regularize the menu display. Delete this “space” data, and you will see what I mean.
LINE 40 – This data line and Lines 50 and 60 are used to hold two sets of data. First the program name which is to appear on the menu screen, followed by it’s Larkenized loading name.
LINE 80 – Ensures we are in the “Caps” mode.
LINE 90 – This line boots some code stored at 23310 into the Larken RAM; and sets a Larken pointer toward it. This code needs to be loaded into memory before either RUNning or doing an NMI-Save. Otherwise the program will crash. See the article entitled TS2068-Larken NMI-key, in the Jan/Feb’92 Issue of Sinc-Link for a full description.
LINES 120/140 – This FOR NEXT loop gets the program names on the screen and the corresponding Larken load names into the C$ array. The Line 120 is somewhat convoluted. There are two things of interest. First, we differentiate between the paper/ink colours used in Line 1 and the remaining lines. This is done by the portion of the line which reads as follows:
...PAPER (1 AND N<>1)+(7 AND N=1); INK (6 AND N<>1)+(2 AND N=1)..
Then secondly we define the game description on each screen as GAME, ADVENTURE, or DEMO. This uses the same programming technique as above. The pertinent segment is as follows.
...(" GAME" AND N<>1 AND N<>3 AND N<>6)+(" DEMO" AND N=3)+(" ADVENTURE" AND N=6)...
LINE 160 – The “PAUSE 0” holds the program at this point until a key is pressed. We use the variable “JUMP” to hold the code of the key that is pressed. We subtract 48 from JUMP so that it corresponds exactly to the key number on the keyboard, which will be between 1 and 7 (since “x” is 7). If JUMP is greater than 7 then the line loops.
LINE 170 – If menu option 1 is selected (HELP), then we go to LINE 3000.
LINE 180 – Some of the games programs in this menu have a SCREEN which we wish to load and display for a few seconds before loading the program proper. However, there is no SCREEN$ file for the program options 1 and 6 so we proceed to load them immediately.
LINE 190 – If we selected options other than 1 or 6 this line will loop (GOSUB) to line 200 to load a SCREEN$, before returning to load the program.
LINE 210 – In this Line we load one of several screen options, depending on the value of the variable “JUMP”. Remember, the value of “JUMP” was determined by our menu selection in Line 160.
LINE 220 – Here one of the programs (menu item 3) has a second SCREEN$ to display.
LINE 230 – Returns to Line 190, to finish loading the game program.
LINE 3000 – Part of the HELP option. We GOSUB to Line 5000 to load “taswi.Cs”.
LINE 3010 – The Tasword “help07.CT” file is displayed onscreen. Pressing the no-scroll “n” key, or Breaking out of the program causes the program to GOTO Line 4, where the instruction “PRINT USR 64300: Print CHR$ 2” causes the computer to revert to the 32 chr$-per-line mode.
LINE 5010 – taswi.Cs contains two other Spectrum m/c routines, to provide the same ON ERR GOTO routine available in the TS2068.
A check is made of address 60900 to see whether the code is already in place, to avoid unnecessary reloading.
LINE 5020 – Three USR calls are made to the taswi.Cs code to activate three components of it. “RAND USR 64300: PRINT CHR$ 3” activates the 64 chars per line mode of taswi.Cs.
LINE 8000 – Doing a GOTO 8000 clears the screen of any odd colours that may be present. Useful when debugging or testing a program mod.
LINE 9000 – This is a m/c routine which is suitable when you wish to use this program as an AUTOSTART with the Spectrum EPROM on the Larken cartridge. The m/c data in Line 9030 is poked into memory, then a USR call is made to it. The code first does an AUTOSTART save, then, when the program is called up later, the remainder of the code does a bankswitching routine to switch from the TS2068 ROM to the Spectrum EPROM.
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.