Previous Next Contents Index
The PUPIL control routines

THE 'PUPIL COMMANDS' ROUTINE
This routine handles the 'new' commands supported by the 'PUPIL system'.

2315 PUPIL      LD   HL,#1DF4            Reset some DISCiPLE variables and work
2318            LD   BC,60               areas.
231B PUP_CLRV   LD   (HL),255
231D            INC  HL
231E            DEC  BC
231F            LD   A,B
2320            OR   C
2321            JR   NZ,#231B,PUP_CLRV
2323            LD   (#1DDA),A           Reset control port state.
2326            LD   (#1ACF),A           Clear FLAGS3.
2329            LD   (23729),A           Clear an unused Spectrum system variable.
232C            CALL #002C,GET_C_RAM     Fetch the command.
232F            LD   (#1DFF),A
2332            CP   207                 Is it 'CAT' ?
2334            JP   Z,#083C,CAT         Jump to the CAT routine if so.
2337            CP   239                 Also for 'LOAD',...
2339            JP   Z,#06A5,LOAD
233C            CP   248                 ...'SAVE',...
233E            JP   Z,#0672,SAVE
2341            CP   213                 ...'MERGE',...
2343            JP   Z,#06AF,MERGE
2346            CP   214                 ...'VERIFY',...
2348            JP   Z,#06AA,VERIFY
234B            CP   208                 ...'FORMAT',...
234D            JP   Z,#080C,FORMAT
2350            CP   210                 ...'ERASE',...
2352            JP   Z,#086D,ERASE
2355            CP   255                 ...'COPY',...
2357            JP   Z,#089C,COPY
235A            JP   #0146,SPEC_ERR      If non of the above, the Spectrum has
                                         to handle the error.

THE 'NETWORK SERVER' ROUTINE
This routine checks if a 'command block' is send over the network. In a master/pupil
network (Shared Access Network) the master can 'steal' a file from or 'force' a file
upon a pupil station. Whenever the master does this the pupil executes the command and
loads from or saves to the master station.

235D NET_SERVER CALL #036E,NET_ACTIVE    Test network activity.
2360            CALL NZ,#038A,GET_COMBLK Fetch the command block if the network
                                         was active.
2363            LD   L,#2F               Restore registers for 'KEY_SCAN'
2365            LD   DE,#FFFF            routine in 'main' ROM.
2368            LD   BC,#FEFE
236B            JP   #021F,TAKE_PRTR     Exit via 'TAKE_PRTR'.

THE 'TEST NETWORK ACTIVITY' SUBROUTINE
Before a command block can be received the network has to be active for about 10400 T
cycles and then has to go inactive in less than 52000 T states. Whenever one of both
requirements isn't fulfilled a return is made with the Zero flag set indicating
'no command block to be received'.

236E NET_ACTIVE LD   HL,200              This counter allows the network to be
                                         tested for 10395 T cycles.
2371 NET_ACT1   IN   A,(31)
2373            CPL
2374            BIT  7,A
2376            RET  Z                   Exit if the network is inactive.
2377            DEC  HL
2378            LD   A,H
2379            OR   L
237A            JR   NZ,#2371,NET_ACT1   Repeat activity-test until time out.

Now the network has to go inactive within about 52000 T cycles.

237C            LD   HL,1000
237F NET_ACT2   DEC  HL                  Decrease counter.
2380            LD   A,H
2381            OR   L
2382            RET  Z                   Exit if network isn't inactive within
2383            IN   A,(31)              the right time.
2385            BIT  7,A
2387            JR   Z,#237F,NET_ACT2    Repeat until network is inactive.
2389            RET                      Return so the command block can be
                                         fetched.

THE 'GET COMMAND BLOCK' SUBROUTINE
This routine fetches the command block from the network and executes the command.

238A GET_COMBLK LD   HL,#1DFD            Point to the data buffer.
238D            LD   E,29
238F            CALL #3A87,INPAK         Read 29 bytes from the network.
2392            RET  NZ                  Return if no bytes received.
2393            LD   HL,#1DFD            Restore the pointer.
2396            XOR  A                   Clear checksum.
2397            LD   B,28                Calculate checksum for 28 bytes.
2399 GET_C_CHKS ADD  A,(HL)              Add this byte.
239A            INC  HL
239B            DJNZ #2399,GET_C_CHKS    Repeat for all command block bytes.
239D            CP   (HL)                Compare with received checksum.
239E            RET  NZ                  Exit if they don't match.
239F            LD   HL,#1DFD            Restore the pointer again.
23A2            LD   A,(#029C)           Fetch own station number.
23A5            CP   (HL)                Return if the command block isn't for
23A6            RET  NZ                  this station.
23A7            INC  HL
23A8            LD   A,(HL)
23A9            CP   1                   Return also if the command block isn't
23AB            RET  NZ                  from the master station.
23AC            INC  HL                  Point to the command.
23AD            PUSH HL
23AE            CALL #3AB5,SEND_RESP     Send response code.
23B1            CALL #03DB,SIGN_SERV     Signal 'serving the master'.
23B4            LD   A,(#1DFE)           Fetch the destination station number
23B7            LD   (#1E01),A           (which is always 1).
23BA            POP  HL
23BB            LD   A,(HL)              Fetch the command.

NOTE: The commands are the commands used by the master so when the master states 'LOAD',
the pupil has to 'SAVE'.

23BC            CP   245
23BE            JR   Z,#23CF,PRINT       Jump with 'PRINT'.
23C0            CP   248                 This is 'SAVE'.
23C2            CALL Z,#06A5,LOAD        Call the 'LOAD' routine.
23C5            CP   239                 This is 'LOAD'.
23C7            CALL Z,#0672,SAVE        Call the 'SAVE' routine.
23CA GET_EXIT   XOR  A
23CB            LD   (#1ACF),A           Clear FLAGS3.
23CE            RET

THE 'PRINT CHAR. FROM MASTER' SUBROUTINE
This subroutine prints the character send by the master on the current stream.

23CF PRINT      INC  HL                  Fetch character.
23D0            LD   A,(HL)
23D1            RST  #10,CALBAS          Print it.
23D2            DEFW #0010,PRINT_A_1
23D4            JR   #23CA,GET_EXIT
Previous Next Contents Index