The BASIC command execution routines II
THE 'GET TRACK AND SECTOR' SUBROUTINE
This routine loads DE with track and sector number from the file header, where they
were stored by the 'EXPT_PARMS' subroutine. Used with LOAD/SAVE @.
0D19 GET_TR&SE LD A,(#1E11) Get track from LSB of LENGTH1_1.
0D1C LD D,A
0D1D LD A,(#1E13) Get sector from LSB of FILE_ADDR1.
0D20 LD E,A
0D21 RET
THE 'GET SECTOR LENGTH' SUBROUTINE
This subroutine returns with BC holding the length of a sector in bytes. With double
density this is 512, with single density 256. This routine is also present in ROM
(at #36B3).
0D22 GET_SECLEN LD BC,512 Length of DD sector.
0D25 LD A,(#1DDA)
0D28 AND 4
0D2A RET Z Return if using double density.
0D2B LD BC,256 Length of SD sector.
0D2E RET
THE 'SAVE HEADER 1' SUBROUTINE
This subroutine SAVEs the 9 bytes header from UFIA 1 to the file and to the catalogue
entry which is build up in the DFCA.
0D2F SAVE_HEAD1 LD HL,#1E10 Start of header 1.
0D32 LD DE,#1BA9 Address of header area of a catalogue
entry
0D35 LD B,9 The headers length.
0D37 SA_HD1 LD A,(HL)
0D38 LD (DE),A
0D39 CALL #29C3,JSBYT Save the byte to the file.
0D3C INC HL
0D3D INC DE
0D3E DJNZ #0D37,SA_HD1 Repeat for all nine bytes.
0D40 RET Finished.
THE 'SAVE' COMMAND SYNTAX ROUTINE
This routine checks that the SAVE command has the appropriate syntax.
0D41 SAVE LD IX,#1AC3 Pointer to the DFCA.
0D45 CALL #09E7,SIGN_SAVE Signal 'SAVEing'.
0D48 CALL #0AEF,EXPT_PARMS Evaluate & store all parameters.
0D4B CALL #0A00,TEST_STEAL If 'forcing' a file to a pupil, send
0D4E CALL NZ,#15CB,SEND_BLOCK the command block over the network.
0D51 CALL #0A05,TEST_NET
0D54 JR Z,#0D5C,SAVE_1 Jump if not a SAVE to the network.
0D56 CALL #0DBA,SAVE_NET
0D59 JP #0419,END Finished.
Now deal with saving to disk.
0D5C SAVE_1 CALL #2984,JTEST_DRV See if the drive is defined.
0D5F LD A,(#1E04)
0D62 CP "@"
0D64 JR NZ,#0D76,SAVE_RUN Jump if the command wasn't 'SAVE @'.
0D66 LD IX,(#1E15) Get address where sector is to be saved
0D6A CALL #0D19,GET_TR&SE from. Get track and sector number.
0D6D LD A,(#1E01) Get drive number.
0D70 CALL #15A0,HWSAD Write the sector.
0D73 JP #0419,END Finished.
THE 'SAVE A FILE' ROUTINE
This routine SAVEs the specified file on the specified drive.
0D76 SAVE_RUN CALL #29A8,JOFSM_2 Open the file for 'SAVE'.
0D79 JP NZ,#097A,EXIT_ERASE Exit if the file isn't to be
overwritten.
0D7C LD A,(#1E05)
0D7F CP 11 Pass the header to the file unless it's
0D81 CALL NZ,#0D2F,SAVE_HEAD1 an 'execute' file.
0D84 CALL #09FB,TEST_SERV
0D87 JR Z,#0DAA,SAVE_R1 Jump if not serving the network.
0D89 CALL #0924,OPEN_N_CH Otherwise open the "n" channel.
0D8C LD B,9 Length of a header.
0D8E SAVE_R_N1 CALL #06F2,N_LBYT LOAD a byte from the network.
0D91 DJNZ #0D8E,SAVE_R_N1 Repeat for all header bytes.
0D93 LD DE,(#1E11) Get the file length.
0D97 SAVE_R_N2 LD A,D
0D98 OR E
0D99 JR Z,#0DA4,SAVE_R_N3 Jump if no more bytes left.
0D9B CALL #06F2,N_LBYT Otherwise LOAD a byte from the network.
0D9E CALL #29C3,JSBYT And SAVE it to disk.
0DA1 DEC DE One less to go.
0DA2 JR #0D97,SAVE_R_N2 Repeat for all bytes.
There are no more bytes left, the file can be closed.
0DA4 SAVE_R_N3 CALL #2981,JCFSM Close the file.
0DA7 JP #0419,END Finished.
Save the whole block of bytes to disk.
0DAA SAVE_R1 LD HL,(#1E13) Fetch the start address.
0DAD LD DE,(#1E11) Fetch the length.
0DB1 CALL #29C9,JHSVBK_2 Save the block.
0DB4 CALL #2981,JCFSM Close the file.
0DB7 JP #097A,EXIT_ERASE Exit via 'EXIT_ERASE'.
THE 'SEND FILE OVER NETWORK' SUBROUTINE
This subroutine sends a file and its header over the network.
0DBA SAVE_NET CALL #0AE1,TEST_STAT Check the station number.
0DBD CALL #2960,JOPEN_N Open the "N" channel.
0DC0 CALL #0DC6,SAVE_NET1 Save the file and its header over the
network.
0DC3 JP #2975,JSEND_NEOF Send the EOF block and exit.
THE 'SEND HEADER AND FILE' SUBROUTINE
This subroutine sends the header of a file and the file itself over the network.
The End Of File block isn't send.
0DC6 SAVE_NET1 LD DE,9 Length of the header.
0DC9 LD HL,#1E10 Address of the header.
0DCC CALL #0DD6,SAVE_NET2 Send the header over the network.
0DCF LD DE,(#1E11) Fetch file length.
0DD3 LD HL,(#1E13) Fetch address.
0DD6 SAVE_NET2 LD A,D
0DD7 OR E
0DD8 RET Z Return if no bytes left.
0DD9 LD A,(HL) Fetch the byte.
0DDA CALL #06FA,N_SBYT Send the byte over the network.
0DDD INC HL Point to the next byte.
0DDE DEC DE One less.
0DDF JR #0DD6,SAVE_NET2 Repeat for all bytes.
THE 'LOAD HEADER INTO UFIA 2' SUBROUTINE
This subroutine LOADs a 9 bytes header into UFIA 2.
0DE1 LOAD_HEAD2 LD HL,#1E29 Start of HEADER 2.
0DE4 LD B,9 Length of a header.
0DE6 LOAD_H1 CALL #29A2,JLBYT Load a byte.
0DE9 LD (HL),A Store it into UFIA 2.
0DEA INC HL
0DEB DJNZ #0DE6,LOAD_H1 Repeat for all header bytes.
0DED RET
THE 'LOAD' COMMAND SYNTAX ROUTINE
The 'LOAD' flag is set and the routine continues into the 'LOAD_VERIFY_MERGE'
routine below.
0DEE LOAD CALL #09E2,SIGN_LOAD Signal 'LOADing'.
0DF1 JR #0DFB,LD_VF_MR
THE 'VERIFY' COMMAND SYNTAX ROUTINE
The 'VERIFY' flag is set and again the 'LOAD_VERIFY_MERGE' routine handles the rest.
0DF3 VERIFY CALL #09F1,SIGN_VERIF Signal 'VERIFYing'.
0DF6 JR #0DFB,LD_VF_MR
THE 'MERGE' COMMAND SYNTAX ROUTINE
The 'MERGE' flag is set and 'LOAD_VERIFY_MERGE' continues the syntax checking.
0DF8 MERGE CALL #09EC,SIGN_MERGE Signal 'MERGEing'.
THE 'LOAD_VERIFY_MERGE' COMMAND ROUTINE
This routine checks the syntax of the LOAD, VERIFY and MERGE commands and executes it.
0DFB LD_VF_MR LD IX,#1AC3 Pointer to DFCA.
0DFF CALL #0AEF,EXPT_PARMS Evaluate & store all parameters.
0E02 CALL #0A00,TEST_STEAL If 'stealing' a file from a pupil, send
0E05 CALL NZ,#15CB,SEND_BLOCK the command block over the network.
0E08 CALL #0A05,TEST_NET
0E0B JR Z,#0E28,LD_VF_MR1 Jump if not using the network.
0E0D CALL #0AE1,TEST_STAT Check station number.
0E10 CALL #2960,JOPEN_N Open the "N" channel.
0E13 LD B,9 Length of a header.
0E15 LD HL,#1E29 Start of HEADER 2.
0E18 LD_ETC_N CALL #06F2,N_LBYT LOAD a byte from the network.
0E1B LD (HL),A Store it into UFIA 2.
0E1C INC HL
0E1D DJNZ #0E18,LD_ETC_N Repeat for all header bytes.
0E1F LD HL,#06F2,N_LBYT Store address of LOAD byte routine.
0E22 LD (#1DE8),HL
0E25 JP #0EBD,LD_ETC_R6
The routine continues here if the network isn't used.
0E28 LD_VF_MR1 CALL #2984,JTEST_DRV See if the drive is defined.
0E2B LD A,(#1E04)
0E2E CP "@"
0E30 JR NZ,#0E42,LD_ETC_RUN Jump if it wasn't a '@' command.
0E32 LD IX,(#1E15) Get address where sector is to be
0E36 CALL #0D19,GET_TR&SE loaded. Get track and sector number.
0E39 LD A,(#1E01) Get drive number.
0E3C CALL #1582,HRSAD Load the sector.
0E3F JP #0419,END Finished.
The routine continues here when a file is to be LOADed from disk.
0E42 LD_ETC_RUN CALL #299C,JHGFLE_2 Open the file for loading.
0E45 LD A,(#1E05)
0E48 CP 5
0E4A JR NZ,#0E5B,LD_ETC_R1 Jump if it isn't a 'Snapshot 48K'.
0E4C LD SP,#1FEA Use internal stack.
0E4F LD HL,16384 Start address and length of a 48K Snap.
0E52 LD DE,49152
0E55 CALL #29A5,JLOAD_FILE Load the file.
0E58 JP #01EE,SNAP_EXIT Exit via 'SNAP_EXIT'.
0E5B LD_ETC_R1 CP 9
0E5D JR NZ,#0E84,LD_ETC_R3 Jump if it isn't a 'Snapshot 128K'.
0E5F LD SP,#1FEA Use internal stack.
0E62 CALL #29A2,JLBYT Get the page configuration byte.
0E65 PUSH AF
0E66 AND #F8 Keep the RAM page bits only.
0E68 LD B,8 LOAD the eight RAM-pages.
0E6A LD_ETC_R2 PUSH AF
0E6B PUSH BC
0E6C CALL #003D,RAMPAGE_A Page in RAM bank.
0E6F LD HL,49152 Start address and length of each RAM
0E72 LD DE,16384 bank.
0E75 CALL #29A5,JLOAD_FILE 'LOAD DE bytes to HL'.
0E78 POP BC
0E79 POP AF
0E7A INC A Next RAM bank.
0E7B DJNZ #0E6A,LD_ETC_R2 Repeat for each RAM bank.
0E7D POP AF Retrieve page configuration.
0E7E CALL #003D,RAMPAGE_A Page in the right RAM, ROM and SCR$
0E81 JP #01EE,SNAP_EXIT bank, exit via 'SNAP_EXIT'.
0E84 LD_ETC_R3 CP 11
0E86 JR NZ,#0E8E,LD_ETC_R4 Jump if it isn't a 'Execute' file.
0E88 CALL #1BD6 Execute (this is the address of the
0E8B JP #0419,END disk buffer). Finished.
0E8E LD_ETC_R4 CALL #0DE1,LOAD_HEAD2 Load the header into UFIA2.
0E91 CALL #09FB,TEST_SERV
0E94 JR Z,#0EB7,LD_ETC_R5 Jump if not serving the network.
0E96 CALL #0924,OPEN_N_CH Open the "N" channel.
0E99 LD HL,#1E29 Point to the header info of UFIA2.
0E9C LD B,9 Nine header bytes.
0E9E LD_ETC_N1 LD A,(HL)
0E9F CALL #06FA,N_SBYT Send a byte over the network.
0EA2 INC HL
0EA3 DJNZ #0E9E,LD_ETC_N1 Repeat for all header bytes.
0EA5 LD DE,(#1E2A) Fetch the length of the file.
0EA9 LD_ETC_N2 LD A,D
0EAA OR E Send the EOF block over the network and
0EAB JP Z,#2975,JSEND_NEOF exit when there are no more bytes left.
0EAE CALL #29A2,JLBYT LOAD a byte from disk.
0EB1 CALL #06FA,N_SBYT And SAVE it over the network.
0EB4 DEC DE One byte less.
0EB5 JR #0EA9,LD_ETC_N2 Repeat for all bytes in the file.
0EB7 LD_ETC_R5 LD HL,#29A2,JLBYT Store address of LOAD byte routine.
0EBA LD (#1DE8),HL
0EBD LD_ETC_R6 LD A,(#1E10) Fetch type of program to be LOADed. Enter
0EC0 LD B,A here when LOADing from network.
0EC1 LD A,(#1E29) Fetch type of program found.
0EC4 CP B
0EC5 JP NZ,#2930,REP_8 Give an error if they aren't equal.
NOTE: The error 'Invalid FILE NAME' is given, maybe MGT have made a typing error.
'Wrong FILE type' is the right message.
0EC8 CP 3
0ECA JR Z,#0EDA,LD_ETC_R7 Jump if it's a 'CODE' file.
0ECC JP NC,#2930,REP_8 Give error if file type >= 4.
0ECF CALL #0A14,TEST_MERGE
0ED2 JR NZ,#0F45,MERGE_CTRL Jump if 'MERGEing'.
0ED4 CALL #0A19,TEST_VERIF Jump if not 'VERIFYing' (i.e. doing a
0ED7 JP Z,#0F61,LOAD_CTRL LOAD).
Now deal with loading of all files with type 3, like 'CODE' and 'SCREEN$', or verifying
of all file types.
0EDA LD_ETC_R7 CALL #0A14,TEST_MERGE
0EDD JP NZ,#293C,REP_14 Give error if 'MERGE .. CODE' was used.
0EE0 LD HL,(#1E11) Fetch length of requested file.
0EE3 LD DE,(#1E2A) Fetch length of file found.
0EE7 LD A,H
0EE8 OR L
0EE9 JR Z,#0EF8,LD_ETC_R8 Jump if length unspecified.
0EEB SBC HL,DE Jump if file to be LOADed is shorter
0EED JR NC,#0EF8,LD_ETC_R8 than or of equal length as the
requested file.
0EEF CALL #0A0A,TEST_LOAD
0EF2 JP Z,#2938,REP_12 'VERIFY failed' if not LOADing.
0EF5 JP #293E,REP_15 'CODE error' otherwise.
0EF8 LD_ETC_R8 LD HL,(#1E13) Fetch start address from FILE_ADDR1
0EFB LD A,H
0EFC OR L
0EFD JR NZ,#0F02,LD_ETC_R9 Jump if a start address was specified.
0EFF LD HL,(#1E2C) Otherwise use the start address of the
found file.
0F02 LD_ETC_R9 LD A,(#1E29) But if the file is a BASIC program the
0F05 AND A start address is held in (PROG).
0F06 JR NZ,#0F0B,LD_ETC_R10
0F08 LD HL,(23635) Fetch 'start' from (PROG).
0F0B LD_ETC_R10 CALL #1000,LV_ANY Load the file.
0F0E CALL #0A19,TEST_VERIF
0F11 JP NZ,#0419,END Exit when 'VERIFYing'.
0F14 LD HL,(#1E17) Fetch execute address.
0F17 CALL #0F23,EXEC_CODE Use it if it was specified.
0F1A LD HL,(#1E30) Otherwise use the files execute
0F1D CALL #0F23,EXEC_CODE address.
0F20 JP #0419,END But if it hasn't one either, exit here.
THE 'EXECUTE CODE FILE' SUBROUTINE
This routine jumps to the address in the HL register pair (if it is valid) after
pushing the addresses of 'STMT_R_1' and 'STACK_BC'.
0F23 EXEC_CODE LD A,H
0F24 OR L
0F25 RET Z Return if the execute address is zero.
0F26 LD A,H
0F27 CP #FF
0F29 JR NZ,#0F2F,EXEC_CODE1
0F2B LD A,L Also return when the execute address is
0F2C CP #FF #FFFF.
0F2E RET Z
0F2F EXEC_CODE1 LD SP,(23613) Clear the stack. (ERR_SP)
0F33 LD (IY+0),255 Clear the error.
0F37 CALL #297B,JBORD_REST Restore the border colour.
0F3A LD BC,#1B7D,STMT_R_1 Return to 'STMT_R_1' in the 'main' ROM
0F3D PUSH BC when finished.
0F3E LD BC,#2D2B,STACK_BC Return to 'STMT_R_1' via 'STACK_BC'
0F41 PUSH BC also in the 'main' ROM.
0F42 JP #004F,UNPAGE_HL Jump to the execute address while
unpaging the DISCiPLE.
THE 'MERGE CONTROL' ROUTINE
This routine handles the MERGEing of a (BASIC) file. No test is made if the file is
an array when using the MERGE 'p'n syntax (see NOTE at 'LOAD CONTROL').
0F45 MERGE_CTRL LD BC,(#1E2A) Fetch the length of the program to be
0F49 PUSH BC MERGEd.
0F4A INC BC Extra location for the 'end marker'.
0F4B RST #10,CALBAS Call 'BC_SPACES' in the 'main' ROM to
0F4C DEFW #0030,BC_SPACES make the required room in workspace.
0F4E LD (HL),128 Mark the end.
0F50 EX DE,HL Move start pointer to HL.
0F51 POP DE Length to DE.
0F52 PUSH HL
0F53 CALL #1000,LV_ANY Load the file.
0F56 POP HL Fetch 'start' of new program.
0F57 LD DE,(23635) Fetch 'start' of old program (PROG).
0F5B RST #10,CALBAS Do the MERGEing by calling the 'main'
0F5C DEFW #08D2,ME_NEW_LP ROM 'MERGE' routine.
0F5E JP #0419,END Finished.
THE 'LOAD CONTROL' ROUTINE
This routine handles the LOADing of a BASIC program or an array.
NOTE: The Spectrum will crash when trying to LOAD or MERGE 'p' an array. The problem
starts in the 'HGFLE_2' ('OPEN A FILE FOR LOAD') subroutine in ROM (#358D) which is
called from the 'LD_ETC_RUN' routine at #0E42. Normally UFIA1 holds the parameters of
the existing array (if present), and UFIA2 holds the parameters of the array to be
loaded. But when the 'p' syntax is used, the 'HGFLE_2' routine makes the contents of
UFIA1 equal to UFIA2. The reclaiming at address #0F99 then fails, trying to reclaim
something which isn't there.
0F61 LOAD_CTRL LD DE,(#1E2A) Fetch 'new' length.
0F65 LD HL,(#1E13) Fetch 'old' start (=0 when loading a
0F68 PUSH HL 'new' array').
0F69 LD A,H
0F6A OR L
0F6B JR NZ,#0F73,LD_CTRL1 Jump if not a 'new' array.
0F6D INC DE Increment 'length' by 3, i.e. allows
0F6E INC DE for the insertion of array name and
0F6F INC DE two-byte length.
0F70 EX DE,HL Move 'length' to HL.
0F71 JR #0F7C,LD_CTRL2 Jump forward.
The array to be loaded replaces an existing array.
0F73 LD_CTRL1 LD HL,(#1E11) Fetch 'old' length (i.e. length of
existing program or array) from UFIA1.
0F76 EX DE,HL Move 'new' length to HL.
0F77 SCF Jump if the program or array to be
0F78 SBC HL,DE loaded isn't longer than the existing
0F7A JR C,#0F85,LD_CTRL3 one.
0F7C LD_CTRL2 LD DE,5 Otherwise a check must be made to
0F7F ADD HL,DE ensure that there is sufficient space
0F80 LD B,H in memory for the program (or array) to
0F81 LD C,L be loaded.
0F82 RST #10,CALBAS Make the check by calling the 'main'
0F83 DEFW #1F05,TEST_ROOM ROM 'TEST_ROOM' subroutine.
0F85 LD_CTRL3 POP HL Restore 'old' start (=0 when handling
0F86 LD A,(#1E29) a 'new' array).
0F89 AND A
0F8A JR Z,#0FBD,LD_PROG Jump if it's a BASIC program.
0F8C LD A,H
0F8D OR L Jump unless an 'old' array is to be
0F8E JR Z,#0F9B,LD_CTRL4 erased before loading the 'new' one.
0F90 DEC HL Points to high byte of 'array length'.
0F91 LD B,(HL) Fetch the 'length'.
0F92 DEC HL
0F93 LD C,(HL)
0F94 DEC HL Now points to the 'array name'.
0F95 INC BC Include 'length' and 'name' in the
0F96 INC BC array length.
0F97 INC BC
0F98 RST #10,CALBAS Call 'RECLAIM_2' in the 'main' ROM to
0F99 DEFW #19E8,RECLAIM_2 delete the array.
0F9B LD_CTRL4 LD HL,(23641) (E_LINE) points to the end of variables
0F9E DEC HL area+1.
0F9F LD BC,(#1E2A) Fetch length of array to be loaded.
0FA3 PUSH BC
0FA4 INC BC Include in the length one byte for the
0FA5 INC BC 'array name' and two bytes for the
0FA6 INC BC 'array length'.
0FA7 LD A,(#1E15) Fetch the array name from 'LENGTH1_2'.
0FAA PUSH AF
0FAB RST #10,CALBAS Call 'MAKE_ROOM' to create the space
0FAC DEFW #1655,MAKE_ROOM for the array.
0FAE INC HL Point to first 'new' location inserted.
0FAF POP AF
0FB0 LD (HL),A Store array name into first location.
0FB1 POP DE
0FB2 INC HL Store array length into the following
0FB3 LD (HL),E two locations.
0FB4 INC HL
0FB5 LD (HL),D
0FB6 INC HL
0FB7 CALL #1000,LV_ANY Load the file.
0FBA JP #0419,END Finished.
Now deal with the LOADing of a BASIC program and its variables.
0FBD LD_PROG LD DE,(23635) Fetch start of existing program. (PROG)
0FC1 LD HL,(23641) Fetch end of existing program. I.e.
0FC4 DEC HL (E_LINE)-1.
0FC5 RST #10,CALBAS Delete the program by calling
0FC6 DEFW #19E5,RECLAIM_1 'RECLAIM_1' in the 'main' ROM.
0FC8 LD BC,(#1E2A) Fetch length of program and variables.
0FCC LD HL,(23635) Fetch (PROG), start of a BASIC program.
0FCF RST #10,CALBAS Create the required space by calling
0FD0 DEFW #1655,MAKE_ROOM 'MAKE_ROOM'.
0FD2 INC HL Point to the first location.
0FD3 LD BC,(#1E2E) Fetch length without variables.
0FD7 ADD HL,BC Calculate and store the start of the
0FD8 LD (23627),HL variables area.
0FDB LD A,(#1E31) When no autostart is known this
0FDE LD H,A ('AUTOSTART2-hi') holds #FF.
0FDF AND #C0
0FE1 JR NZ,#0FEE,LD_PROG1 Jump with no autostart.
0FE3 LD A,(#1E30) Otherwise store the autostart line
0FE6 LD L,A number into 'NEWPPC' and clear 'NSPPC'.
0FE7 LD (23618),HL These hold the line and the statement
0FEA LD (IY+10),0 to be executed respectively.
0FEE LD_PROG1 LD HL,(23635) Fetch the start of the BASIC program.
0FF1 LD DE,(#1E2A) Fetch the length + variables.
0FF5 DEC HL Reset the DATA pointer 'DATADD' to the
0FF6 LD (23639),HL beginning of the program.
0FF9 INC HL Balance the 'DEC HL'.
0FFA CALL #1000,LV_ANY Load the file.
0FFD JP #0419,END Finished.
THE 'LOAD OR VERIFY' SUBROUTINE
This subroutine is used to LOAD or VERIFY (signalled by FLAGS3) a block of bytes.
It must be entered with HL and DE holding 'start' and 'length'.
1000 LV_ANY LD A,D
1001 OR E
1002 RET Z Return if 'length' is zero.
1003 CALL #0A19,TEST_VERIF
1006 JR NZ,#1019,LV_ANY3 Jump if 'VERIFYing'.
1008 CALL #0A05,TEST_NET
100B JR NZ,#1019,LV_ANY3 Jump if 'using the network'.
100D JP #29A5,JLOAD_FILE Otherwise load the file.
1010 LV_ANY1 CP (HL) The actual VERIFY, i.e. compare the
fetched byte with that held in memory.
1011 JP NZ,#2938,REP_12 Give an error if they don't match.
1014 LV_ANY2 INC HL Next memory address.
1015 DEC DE One byte less to go.
1016 LD A,D
1017 OR E
1018 RET Z Exit if no more bytes left.
1019 LV_ANY3 PUSH HL
101A PUSH DE
101B CALL #1028,JP_(#1DE8) Load one byte with appropriate routine.
101E POP DE
101F POP HL
1020 CALL #0A19,TEST_VERIF
1023 JR NZ,#1010,LV_ANY1 Jump if VERIFYing.
1025 LD (HL),A Otherwise store the byte.
1026 JR #1014,LV_ANY2 Repeat for all bytes.
THE 'JUMP TO (#1DE8)' SUBROUTINE
This small subroutine jumps to the routine pointed to by the contents of #1DE8. It
is used by the 'LV_ANY' routine above to fetch a byte for LOADing (from the network)
or VERIFYing.
1028 JP_(#1DE8) LD HL,(#1DE8) Fetch the jump address and jump to it.
102B JP (HL)
THE 'FORMAT' COMMAND SYNTAX ROUTINE
This routine tests if the command has the appropriate syntax.
102C FORMAT RST #28,NEXT_C_RAM Advance CH_ADD to next character.
102D AND #DF Only capitals.
102F CP "N"
1031 JR NZ,#1045,FORMAT_SD Jump if the character wasn't a "N".
1033 CALL #0A5E,EXPT_DEVN Evaluate the station number.
1036 CALL #0409,ST_END_RAM Confirm end of statement and exit
during syntax checking.
1039 CALL #0AE1,TEST_STAT Check the station number.
103C LD A,(#1E01) Fetch station number and
103F LD (#029C),A store it into the system var. 'NSTAT'.
1042 JP #0419,END Finished.
Now check if it is one of the format disk commands.
1045 FORMAT_SD CP "S"
1047 JR NZ,#105B,FORMAT_D Jump if it wasn't "S".
1049 RST #28,NEXT_C_RAM Next character.
104A AND #DF Only capitals.
104C CP "D"
104E JP NZ,#2920,REP_0 Give an error if not a "D".
1051 LD A,(#1DDA) Fetch current control port state.
1054 OR #04 Set 'Single Density'.
1056 LD (#1DDA),A
1059 JR #1068,FORMAT_1
105B FORMAT_D CP "D"
105D JP NZ,#2920,REP_0 Give an error if not a "D".
1060 LD A,(#1DDA)
1063 AND #FB Set 'Double Density'.
1065 LD (#1DDA),A
1068 FORMAT_1 RST #28,NEXT_C_RAM Next character.
1069 CP 13
106B JR NZ,#1070,FORMAT_2 Jump if it isn't a carriage return.
106D JP #0419,END Finished?
NOTE: It seems that there are two undocumented FORMAT commands, 'FORMAT sd' and
'FORMAT d' followed by 'ENTER'. They set or reset the single/double density bit of
the control port state respectively.
1070 FORMAT_2 CALL #0A76,EXPT_DEVN2 Evaluate the drive number.
1073 CP 204 Jump if the current character isn't
1075 JR NZ,#1081,FORMAT_3 'TO'.
1077 CALL #0AA2,SWAP_UFIAS Exchange UFIA1 and UFIA2.
107A RST #28,NEXT_C_RAM Update CH_ADD.
107B CALL #0A76,EXPT_DEVN2 Evaluate 2nd drive number.
107E CALL #0AA2,SWAP_UFIAS Exchange UFIA's again.
1081 FORMAT_3 CALL #0409,ST_END_RAM Confirm end of statement and exit when
syntax checking.
1084 CALL #2984,JTEST_DRV Check if the drive is defined.
1087 RST #10,CALBAS
1088 DEFW #0D6E,CLS_LOWER Clear lower screen area.
108A SET 5,(IY+2) Signal 'lower screen has to be
cleared'.
108E CALL #29AB,JSURE_MSG Print 'Are you SURE ? (y/n)' message.
1091 CALL #298A,JTEST_Y Wait for a key, Zero set means 'Y'
1094 JP NZ,#0419,END pressed. Finished when not sure.
1097 CALL #298D,JFRMT_RUN Otherwise FORMAT the disk.
109A JP #0419,END Finished.