 
*  EE6/FINAL   40 col         Jul / 08 / 93
*--------------------
*  All Characters
 
*  FW Reloader PAB and data
*--------------------------
 
RLPABV EQU  >0FE0
FWRELV EQU  >1000
FWRELW EQU  FWRELV+>0BC8
 
PABRLF DATA >0500,FWRELV,0,>2100
       BYTE 0
RLDNAM BYTE >0B
       TEXT 'WDS1.FWB.'
       TEXT 'FW   '
PABRLN EQU  $-PABRLF
LODNAM TEXT 'LOAD'
BYT0A  BYTE >0A
       EVEN
 
HDREL  DATA 0                 | Keep
RLDISK DATA '11'              | this
MODFL1 DATA 0                 | in
GRMAD1 DATA 0                 | just
REPKTS DATA 0                 | this
CPUDLS DATA 0                 | very
SAVER4 DATA 0                 | same
RLNAMP DATA 0                 | order
 
*  Subroutines for reloader - dual/hard path
*-------------------------------------------
*  Assumes RLDNAM already set up
*  Step over next if not found on any path
 
RLDSUB MOV  R11,R10           For direct entry
RLDSB1 BL   @VMBWD            PAB to VDP
       DATA RLPABV,PABRLF,>18
       LI   R9,RLPABV+9       Set pointer
       BL   @LPROGR           Program file load
       JMP  RLDSB2            Failure - try alternate
       JMP  RLDSB4            Success
 
RLDSB2 CB   R3,R4             Same or hard path ?
       JEQ  RLDSB3            Yes - do not repeat
       SWPB R3                Swap drive #s
       SWPB R4                Swap comparisons to match
       MOVB R3,@RLDNAM+4      Replace drive #
       JMP  RLDSB1            Run through again
 
RLDSB3 INCT R10               Step over exit if not found
RLDSB4 B    *R10              Direct exit
 
*  No register use version of SETVR
 
SETVR1 EQU  $
       MOVB *R11,@>83D4       Load for next console keyscan
SETVRG MOVB *R11+,@VDPWA
       MOVB *R11+,@VDPWA
       RT
 
*  Data VMBWD as BL routine
*--------------------------
*  Final irrevocable exit
*------------------------
 
RELODR EQU  $
       SZCB @MASK10,@>83C2    Restore <Quit>
       BL   @SETVR1           Set VR 1
       DATA >B081             Blank screen while at it
 
*  Try FW first on primary path
 
       CLR  R3                Initialize as flag
       MOV  @HDREL,R4         Hard path ?
       JEQ  RELDR1            No
 
       MOV  @RLDISK,R3        Get drive #s then
       MOVB R3,@RLDNAM+4      Write first into name
RELDR1 MOV  R3,R4             Make copy
       SWPB R4                Switch #s
       BL   @RLDSUB           Set PAB and load
       JMP  RLDR30            Failure
 
*  Found and loaded - re-entry to bypass FW initial code
 
RLDR10 BL   @MOVE             Fetch relevant parts
       DATA FWRELW
       DATA FWPOSN,FWBLEN
       LWPI FWREG             FW standard workspace
       BLWP *R9               Restore original cursor
       DATA FCSRP,FCSR,8
       LI   R11,RLDISK        Restore parameters
       MOV  *R11+,@RDISK
       MOV  *R11+,@MODFL
       MOV  *R11+,@GRMAD
       MOV  *R11+,@REPETS
       MOV  *R11+,@CPUDEL
       MOV  *R11,R4
       MOV  @COLCH,@INCOL     Update color index
       MOV  @CMRET,R11
       SETO R13
       RT
 
*  Try for the XB LOAD program as generic program file
 
RLDR30 LI   R1,RLNAMP         Stored name pointer
       LI   R2,LODNAM         Replace FW with LOAD
       MOVB *R2+,*R1+
       MOVB *R2+,*R1+
       MOVB *R2+,*R1+
       MOVB *R2,*R1
       INCT @RLDNAM-1         Two bytes longer
       BL   @RLDSUB           Try to load again
       JMP  RLDR99            Failure - this time go <QUIT>
 
*  Check details of LOAD to find entry
*----------------------------------------------------------------
*  LOAD is shorter than FW and the imbedded assembler code is not
*  necessarily word-aligned.  31 sectors vs 32 in Vn 4.40
*  Identifying structure
*          DATA $+2,>AAAA     Pointer to IDENT >AAAA following
*          DATA >0A           Start of FW data area
*----------------------------------------------------------------
 
       LI   R9,FWRELV->200    LOAD is shorter than FW
       LI   R10,VDPRD         Byte saver
RLDR50 INC  R9                Restart as next byte
       CI   R9,FWRELV+>100    Max likely
       JHE  RLDR99            Give up then
 
       STWP R0                Set target to workspace
       INCT R0                Make it R1
       BLWP @SETVDR           Set read address
       MOVB *R10,*R0+         R1 MSB
       MOVB *R10,*R0+         R1 LSB
       MOVB *R10,*R0+         R2 MSB
       MOVB *R10,*R0+         R2 LSB
       CI   R2,>AAAA          Is it the ident word ?
       JNE  RLDR50            Restart search
       MOVB *R10,*R0          R3 MSB
       CB   R3,@BYT0A         Extra check
       JNE  RLDR99            Can't be FWeb LOAD
 
*  Fetch relevant part of LOAD
 
       LI   R6,>FFD8          Known end in CPU RAM
       S    R1,R6             Construct length
       MOV  R1,R8             CPU address for ident word
       INCT R9                Point to ident word in VDP
       BL   @MOVE05           Do the read
       JMP  RLDR10
 
RLDR99 BLWP @>0               In final desperation
 
*------------------------------------------------------
 
