A T/S 2068 Utility to Put Basic Programs into the Larken RAMDisk Banks

See all articles from Update April 1990

DONATED TO THE PUBLIC DOMAIN BY LARRY CRAWFORD
[address omitted]
27 JAN 90

BACKGROUND

The LARKEN RAMDISK banks are all mapped into the DOCK bank of the 2068 even though the board is plugged into the back expansion slot. Consequently, it is possible to load any of the RAMDISK banks with code which simulates a BASIC cartridge (an AROS) and to run that code as a BASIC program. This suite of programs will allow you to create your own simulated cartridges in the RAMDISK memory chips. A program running from DOCK leaves the HOME bank free to hold another program and/or data. Refer to Bill Jones‘ EXTRA MEMORY PROGRAMMING article in Update Magazine for some of the implications of working in DOCK bank.

See References page 33

FEATURES

1. Allows a choice of any of the 8 RAMDISK banks.

2. SAVEs the chosen RAMDISK bank to floppy automatically.

3. Will RUN a program in DOCK or HOME bank.

4. Allows a BASIC program to be MERGED into HOME bank or a new program to be keyed in.

5. Will move a program from HOME bank into DOCK.

6. SAVEs the program in HOME as a BASIC program and the one in DOCK as cartridge code.

7. Reloads the saved RAMDISK bank after these SAVEs have been completed thus restoring the computer to its original condition.

8. Uses no variables internally except for the string variable Z$ so will not normally interfere with the operation of a BASIC program MERGEd with it.

9. All features are MENU driven for ease of use.

10. The screen and ink colours change when you change banks so that you will know which bank is active. This information is important because you cannot LIST or EDIT lines if you are in the DOCK.

GETTING STARTED

Type in listing 1 (“maker.B1”) and GO TO 9999 to save it.

GO TO 100 to create and save “move20j.C1”. This step need be done only once for each disk to be used.

Type in listing 2 (“loader.B1”) and GO TO 9999 to save it. This is the program to be RUN when a new AROS is to be created or programs are to be run in both HOME and DOCK banks.

Type in listing 3 (“PRGMV.B3”). Save as “PRGMV.B3” and as a code file: <RANDOMIZE USR 100: SAVE “CORE.C1″CODE PEEK 23635+ PEEK 23636,3000>. The two PEEKs find the beginning of the BASIC program. This is necessary since LARKEN moves (prog) up 50 bytes if the large printer is activated. The 3000 is an arbitrary number large enough to be sure that all of the program has been saved.

USING THE PROGAMS (A TUTORIAL)

1. Since the RAMDISK banks will be used, the WRITE PROTECT switch must be in the OFF position.

2. The floppy disk must have its protect sticker removed.

3. Since both the RAMDISK and floppy disks will be messed with, it is prudent to make copies of each before using the program.

4. LOAD “loader.B1”. You will be asked which bank is to be used.

Enter <1> for bank “A”, <2> for “B”, etc.

Use <1> for a trial run.

There will be a great whirring and clanking for a few seconds while it saves the RAMDISK bank you chose, loads in the matching DOCK bank and a short m/c routine.

The screen will flicker, simulating a crash, and then some more whirring while the BASIC controller program is merged into HOME bank.

Finally, a menu in black ink on cyan paper will inform you which DOCK bank you are in and give you the choice of going to HOME bank or running a program in DOCK.

The whole process is quite scary.

5. If you choose to RUN in DOCK, the same menu will appear since the only program resident is the BASIC controller program (PRGMV.B3).

6. The other option will reveal the BASIC controller listed in white ink on blue paper.

Since the program was just MERGEd into the HOME bank, it will not autorun.

Use <GOTO 9999> to bring up the menu.

7. The menu will give you 4 options: 1: RUN, 2: MERGE, 3: MOVE to DOCK, and 4: SAVE & RESTORE.

8. Try option 1. You will be asked which bank you want to RUN in. Either choice at this time will come up with the menu for the bank chosen with the appropriate ink and paper colours.

After going to DOCK and returning to HOME, use <GOTO 9999> again to return to the menu.

9. Now try the option 2 to merge a program into HOME bank.

A CAT will be performed and you will be prompted to enter the name of the program.

The program to be merged must not include lines above 9990 or it will destroy the controller program and you will lose control.

If the program uses the TIMEX printer, it should make a USR call to 2613 to clear the printer buffer before any printing is done and should reload “mov20j.C3″CODE after using the printer.

Try “test.B1”. This is a one line PRINT program at line 10.

10. Return to the menu and choose the RUN option. Choose DOCK and note that its menu comes up again because the test program has not been moved into DOCK yet.

11. Return to HOME and call up the menu.

This time choose to RUN in HOME. The test program will run and print an “OK” message.

12. Return to the menu and choose the MOVE option. A prompt will tell you to hit a key to return to menu.

13. Now RUN in DOCK and see the test program running.

Use <GOTO 9990> to get to the DOCK menu.

14. Return to HOME and delete the print line.

15. RUN in both banks and note that the test program still works in DOCK.

16. Now move the program to DOCK and RUN in both banks again.

The test program has been removed from DOCK.

(This program should be removed before using the last option of saving the DOCK program)

17. Put a line somewhere. For example, <1 REM> will do nicely.

The SAVE option deletes lines 1 to 9990 and there must be something to delete.

Choose option 4 of the HOME menu.

The program in the HOME bank will be saved as “HOMEn.B1” where n is the chosen bank.

The DOCK bank will be saved as “DOCKn.C1″CODE 32768,l. where l is the length of the file in DOCK.

The RAMDISK bank “RDBNKn.C1” will be loaded, thus restoring RAMDISK to its original state.

But the RAMDISK bank is still switched on and a program loaded in now would overwrite the data in the bank.

You will be prompted to switch off the power supply before doing anything else with the computer.

18. Now switch on and try RAMDISK. It should work normally.

USING YOUR AROS

Assume that you have moved a BASIC program “XX.B1” into bank 7 and want to keep it there to be run at any time.

Bank 7 cannot be formatted as a RAMDISK bank in drive 4.

The AROS was saved as “DOCK7.C1” when you created it. Change the name to “XXAR.C7” and put it into bank 7 as follows:

<OUT 244,240: OUT 7,68: RANDOMIZE USR 100: LOAD “XXAR.C7″CODE> <OUT 244,0: OUT7,0>

The program will stay in the bank as long as the battery backup is in place.

To run the AROS: <OUT 7,4: NEW>. It’s that simple.

The bank can be used for other programs since the code resident in bank 7 will be saved when the new BANK7.C1 is created with the package and will be restored when the process is finished.

Thus any number of programs can be run in the one bank as long as each is given a distinctive name and is loaded into the bank as required.

File “XXAR.C7” would have to reloaded if it is desired to have it resident in the bank.

LISTING 1 (maker.B1)

   5 REM        TO CREATE THE CODEUTILITY "mov20j.C3" WHICH SWITCHES FROM DOCK TO HOME BANK AND MOVES A PROGRAM FROM HOME TO DOCK,<GOTO 100>     LARRY CRAWFORD 20 JAN 90
20 PRINT AT 10,4;"THIS PROGRAM WILL FORMAT";AT 11,9;"A RAMDISK BANK";AT 13,4;"WHICH BANK WILL BE USED?";AT 14,12;"(1 TO 8)": INPUT B: LET B$="73516240": LET LKBNK=CODE B$(B)+16
30 RANDOMIZE USR 100: LOAD "CORE.C1"CODE 32780: RESTORE 30: FOR X=32768 TO 32779: READ Y: POKE X,Y: NEXT X: DATA 1,2,12,128,15,1,0,0,B,LKBNK,184,11: RANDOMIZE USR 100: SAVE "DOCK"+STR$ B+".C1"CODE 32768,3000
40 STOP
100 RESTORE 100: FOR X=23296 TO 23334: READ Y: POKE X,Y: NEXT X: DATA 175,050,198,092,195,040,014,237,091,083,092,042,089,092,205,069,023,017,012,128,175,211,244,126,245,062,240,211,244,241,018,035,019,011,120,177,032,238,201
110 RANDOMIZE USR 100: SAVE "mov20j.C3"CODE 23296,39: STOP
9999 RANDOMIZE USR 100: SAVE "maker.B1" LINE 1

LISTING 2 (loader.B1)

  10 CLEAR 65367: PRINT AT 10,0;"THIS PROGRAM WILL MOVE A BASIC"'" PROGRAM INTO A RAMDISK BANK"''"  WHICH BANK WILL BE USED?"'"            (1 TO 8)": INPUT B: LET B$="73516240": LET LKBNK=CODE B$(B)+16
20 OUT 244,240: OUT 7,LKBNK: RANDOMIZE USR 100: SAVE "RDBNK"+STR$ B+".C1"CODE 32768,32768: RANDOMIZE USR 100: LOAD "DOCK"+STR$ B+".C1"CODE : OUT 244,0: NEW
9999 RANDOMIZE USR 100: SAVE "loader.B1" LINE 1

LISTING 3 (PRGMV.B3)

  10 REM DO NOT DELETE THIS LINE
9991 POKE 26664,(PEEK 26664)+1: GO TO 9997+(PEEK 26664>1)+(PEEK 23750=0)
9992 CLS : PRINT AT 10,0;"RUN PROGRAM IN"''"1: HOME BANK"''"2:DOCK BANK"''"CHOOSE": PAUSE 0: POKE 23750,128*(INKEY$="2"): BORDER 1+(INKEY$="2")*4: PAPER 1+(INKEY$="2")*4: INK (INKEY$="1")*7: GO TO 0
9993 CLS : RANDOMIZE USR 100: CAT "",: INPUT "ENTER NAME OF PGM TO BE MERGED ";Z$: RANDOMIZE USR 100: MERGE Z$: GO TO 9999
9994 CLS : RANDOMIZE USR 100: POKE 26662,(PEEK 23641+256*PEEK 23642)-(PEEK 23635+256*PEEK 23636)+14: RANDOMIZE USR 23303: PRINT AT 10,0;"THIS PROGRAM IS NOW IN BOTH DOCKAND HOME BANKS"''"AND YOU ARE IN THE HOME BANK"''"PRESS ANY KEY FOR MENU": PAUSE 0: CLS : GO TO 9999
9995 RANDOMIZE USR 100: SAVE "HOME"+STR$ PEEK 26660+".B1": DELETE 1,9990: OUT 244,240: OUT 7,PEEK 26661: RANDOMIZE USR 100: SAVE "DOCK"+STR$ PEEK 26660+".C1"CODE 32768,PEEK 26662+256*PEEK 26663: RANDOMIZE USR 100: LOAD "RDBNK"+STR$ PEEK 26660+".C1"CODE : OUT 244,0: OUT 7,8: CLS : PRINT AT 10,0;"HOME, DOCK BANKS HAVE BEEN SAVED"''"RAMDISK BANK HAS BEEN RESTORED"''"SWITCH OFF POWER SUPPLY BEFORE"''"LOADING ANOTHER PROGRAM": STOP
9996 BORDER 1: PAPER 1: INK 7: CLS : RANDOMIZE USR 23296
9997 RANDOMIZE USR 100: LOAD "mov20j.C3"CODE : OUT 244,240: POKE 26660,PEEK 32776: POKE 26661,PEEK 32777: POKE 26662,PEEK 32778: POKE 26663,PEEK 32779: OUT 244,0: RANDOMIZE USR 100: MERGE "PRGMV.B3"
9998 BORDER 5: PAPER 5: INK 0: CLS : PRINT AT 10,0;"YOU ARE NOW IN DOCK BANK ";PEEK 26660''"YOUR CHOICES ARE"''"1: SWITCH TO HOME BANK"''"2: RUN A PROGRAM IN DOCK BANK"''"ENTER CHOICE ": PAUSE 0: GO TO 9996*(INKEY$="1")
9999 OUT 244,0: CLS : PRINT AT 9,7;"YOUR CHOICES ARE"''"1: OPERATE A PGM IN EITHER BANK"''"2: MERGE A PGM TO HOME BANK"''"3: MOVE THIS PGM TO DOCK BANK"''"4: SAVE HOME & DOCK BANKS ";PEEK 26660;" AND"'" RESTORE RAMDISK BANK"''"ENTER CHOICE": PAUSE 0: GO TO 9991+CODE INKEY$-48

DOCUMENTATION FOR THE PROGRAMS THAT MAKE UP THE T/S 2068 UTILITY TO PUT BASIC PROGRAMS INTO THE LARKEN RAMDISK BANKS

DONATED TO THE PUBLIC DOMAIN BY LARRY CRAWFORD
[address omitted]
27 JAN 90

For background and theory refer to the tutorial Tasword file “tutor.CT” on this disk.

A RAMDISK bank is one of the RAM chips on the LARKEN RAMDISK board.

A DOCK bank is one of these chips used without being fomatted into drive 4.

An AROS is a DOCK bank file that contains “overhead bytes” and a BASIC program.

“maker.B1”

This short program is really two programs in one. Lines 20 and 30 will create a code file which, when loaded into a DOCK bank, simulates a BASIC AROS cartridge. Lines 100 and 110 create the 39 byte m/c program which is called to switch from DOCK to HOME bank and to move a BASIC program from HOME to DOCK bank.

LINE 20

Prompts for the bank to be used as an AROS. This number is assigned to variable B.

RAMDISK banks are identified as A, B, C,…,H. We will use the sequence 1, 2, 3, …,8 instead.

This will help distinguish between the lettered RAMDISK banks and the numbered DOCK banks.

A string variable, B$, is assigned the set of integers which are the RAMDISK bank code numbers. The appropriate number is sliced out of the string, adjusted to turn off the write-protect feature, then assigned to the variable LKBNK.

LINE 30

Loads in a previously prepared code program. More on that later. POKES the “overhead bytes” for the AROS into the first eight addresses in the bank. Then pokes the bank number and the bank code number into the next two. The last two bytes are the number of bytes to be saved as code. The two numbers in the DATA statement represent 3000, an arbitrary number large enough to include all the data.

Then the file is saved as “DOCKb.C1”, where b is the bank number.

A file of this format must be stored on the disk before the utility can be used.

LINE 100

POKES the following m/c program into the beginning of the printer buffer:

 23296 XOR A
       LD (AROS FLAG),A  <switches to HOME bank>
       JP 3624 decimal   <the entry point to BASIC
                          in ROM>

 23303 LD DE, (prog)
       LD HL, (elin)
       CALL 5957 decimal <"difference" subroutine
                          in ROM. Loads BC with
                          difference between HL
                          and DE. Loads HL with
                          (prog)>
       LD DE,32780 dec.  <where the BASIC pgm is
                          to be moved>
  loop XOR A             <load A with zero>
       OUT (244),A       <all chunks of RAM in
                          HOME bank active>
       LD A,(HL)         <get byte of BASIC pgm>
       PUSH AF           <store byte>
       LD A,240 dec.
       OUT (244),A       <chunks 4 to 7 active in
                          DOCK bank>
       POP AF            <get byte of BASIC pgm>
       LD (DE),A         <put byte in DOCK bank>
       INC HL
       INC DE            <increase both pointers>
       DEC BC            <decrease counter>
       LD A,B
       OR C
       JR NZ,loop        <loop until counter is 0>
       RET

LINE 110

The 39 bytes are saved as “mov20j.C1” ready to be loaded later when needed.

Lines 100 and 110 need only be used once.

“loader.B1”

This is the program that is run to actually use the utility.

LINE 10

Prompts for the bank number, B, and calculates the value for RDBNK.

LINE 20

Switches on the chosen bank and saves the resident RAMDISK data.

Loads in the matching DOCK bank AROS.

Switches on all chunks of HOME bank, leaving the DOCK bank selected.

“PRGMV.B3” and “CORE.C1”

Both are the same program: one saved as BASIC and the other as a code file. Between them they are the controllers for loading and running BASIC programs in HOME and DOCK banks.

The code version is resident in the AROS and runs when the computer is NEWed by the loader program.

LINE 10

This is a dummy line needed if no other program is merged into HOME bank. The SAVE option deletes lines 1 to 9990. Therefore, there must be at least one line in that range.

LINE 9991

Address 26664 that is peeked, incremented, and poked, is located in an unused corner of RAM. It has a value of zero on startup and is used here as a flag to indicate whether or not this is the first run of the program.

If this is the first run, PEEK 26664 will not be greater than 1 and PEEK 23750 will not equal zero (we’re in DOCK now so 23750 holds 128). Thus the GOTO will be to 9997+0+0.

If this is not the first run and we’re in DOCK, the GOTO will be to 9997+1+0.

If we’re in HOME bank, GOTO 9997+1+1.

LINE 9997

This line is used only on startup. First the m/c routines are loaded into the printer buffer.

The top 4 chunks of HOME bank are switched off. Then the bank number, bank code number, and number of bytes of code in the AROS are all poked into the corner of RAM next to our flag.

These parameters must be accessible no matter which bank is in use.

Finally, the HOME bank is restored to its full size and the BASIC controller, “PRGMV.B3” is merged into place.

LINE 9998

Sets the paper and border to cyan and ink to black. These colors inform you that the computer is operating in DOCK bank.

A menu is displayed giving you the option of going to HOME bank or running a program in DOCK.

If the choice is to goto HOME then the GOTO will be to 9996*1. If not, GOTO 9996*0; thus effectively running the program in DOCK.

LINE 9996

Sets the paper and border to blue and ink to white.

These colors inform you that the computer is operating in HOME bank.

The bank-switching routine at 23296 is called and control will now be in HOME bank.

The resident program will not run automatically but must be activated with a GOTO to the appropriate line number.

GOTO 9999 will always bring up the menu in HOME.

LINE 9999

The HOME menu. First, the HOME bank is switched in and the 4 choices displayed.

PEEK 26660 in the SAVE option is the bank number.

The GOTO line is simply 9991+ the choice number.

If the first option is selected, control is passed to line 9992.

LINE 9992

A new menu is displayed giving the option of running the program in HOME or DOCK banks.

The POKE to 23750 is either 0 or 128 depending on the bank chosen. The operative bank is determined by the value stored in 23750.

Similarly, the border, paper, and ink colors are set by the Boolean logic in each of the statements.

The GOTO 0 effectively runs the program in the selected bank.

LINE 9993

Activated by the MERGE option of the menu.

It does a CAT and prompts for the name of the program to be merged.

MERGEs that program and returns to the menu.

LINE 994

Called by the MOVE option of the menu. Whatever program is resident in HOME will be placed into the AROS.

First, the number of bytes between (elin) and (prog) is found and 14 bytes added to allow for the “overhead” bytes of the AROS and our parameters. This number is double poked into 26662, replacing the previous length stored. (We had poked in 3000 originally. Remember?)

The m/c at 23303 is then called to do the actual move then a message is displayed to inform you that the move has taken place.

The menu is then called up once more.

LINE 9995

The SAVE option. Lots of activity here.

First, the program in HOME is saved under the name “HOMEb.B1” where b is the bank number.

Then lines 1 to 9990 are deleted to be sure that line 9995 is not in a chunk of RAM that will get switched off.

Next, chunks 4 to 7 are switched off for MOME bank and the write-protect turned off in DOCK.

The number of bytes to be saved is PEEKed from 26662 and 26663 and the AROS saved as “DOCKb.C1”.

The RAMDISK bank that was saved at the beginning is put back in place by LOAD “RDBNKb.C1”.

A message is displayed to be sure that the computer is completely back to normal by switching off the power supply before using it with another program.

“CORE.C1”

The controller program “PRGMV.B3” saved as code.

After PRGMV.B3 is typed in, it is saved as “CORE.C1″CODE PEEK 23635+ PEEK 23636, 3000.

VARIABLES USED BY THE UTILITY

IN AROS    IN RAM     MEANING

32776      26660      active bank number
32777      26661      LARKEN bank code
32778,9    26662,3    length of code file in AROS
  -        26664      flag for first run of pgm

REFERENCES

These two articles in this issue is the wrap-up on the subject of Extra Memory. There are many more articles in the back issues of Update and the total of these form a complete reference on Extra Memory, both from the Programming and the hardware standpoints. These articles will be referenced by Update Magazine issue dates below.

Oct 87-- Memory map
Jan 88-- Extra mem programming.
         Mod of TS-1000 Ram.
         TS-2068 whole schematic.
         Ext Buss pin diagram.
Apr 88-- System Variables.
         MOVE PROG - Program.
Jul 88-- DOS-64 + Bankswitching.
         First of Chuck Bothner's
         series on RAM EXPANSION.
Oct 88-- Larken Ram Disk.
         Extra memory recap.
         Chuck Bothner's second
         art on RAM EXTENSION.
Jan 89-- LKDOS OFF Switch.
Jul 89-- FD-68 Update (bkswitch).
Oct 89-- Larry Crawford's first
         Ex Memory article.
Jan 90-- Two articles in this
         issue.

Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.