 
*  DSK5.FWEDMAKE/S     Apr / 27 / 92
*-------------------------------------
*  For assembling components of Editor
*  Saves low-mem to top of Load/Save
*  Saves files as EX & EY
*  Displays on screen values for labels
*  -----
*  LLAST  - End of Low-mem block
*  EDITBF - Start of Edit Buffer
*  SLAST  - End of HI-mem block
*  GAPLEN - Remaining space for fixed code
*  LSLEN  - Length of Load/Save module
*  SDLEN  - Length of Show-Dir module
 
 
       AORG >C900             Overlay FSAVE
 
 
PABV   EQU  >F80
PBFV   EQU  >1000
 
DSRLNK EQU  >FFD4
KSCANA EQU  >FFD0
DELSPR EQU  >FFC8
VMBWD  EQU  >FFBA
CMSRET EQU  >FF5C
HEXDGS EQU  >FEA4
 
 
 
       REF  VMBR,VMBW
       REF  VSBW,VDPWD,KSCAN
 
       REF  LLAST,SLAST,EDITBF,TOPOV
       REF  GAPLEN,SDLEN,LSLEN
       REF  TXTVDL,HFIRST
 
 
       DEF  SAVE
 
 
SAVE   EQU  $
       LIMI 0
       LWPI OUREG
 
*  Clear screen
 
       CLR  R0
       LI   R1,>2001
ONE    EQU  $-1
       LI   R2,>300-1
       BLWP @VSBW
CLRS1  MOVB R1,@VDPWD
       DEC  R2
       JNE  CLRS1
 
*  Write up size/gap data
 
       LI   R10,I2H
       LI   R4,>20
       LI   R3,>24
       LI   R0,LLAST
       BL   *R10
       A    R4,R3
       LI   R0,EDITBF
       BL   *R10
       A    R4,R3
       LI   R0,SLAST
       BL   *R10
       A    R4,R3
       LI   R0,GAPLEN
       BL   *R10
       A    R4,R3
       LI   R0,LSLEN
       BL   *R10
       A    R4,R3
       LI   R0,SDLEN
       BL   *R10
       A    R4,R3
       A    R4,R3
       LI   R0,TXTVDL
       BL   *R10
       LI   R0,>0D40+>69A+>1410
       AI   R0,LSLEN
       AI   R0,SDLEN
       AI   R0,TXTVDL
       AI   R0,>30            P,Q data
       A    R4,R3
       BL   *R10
       LI   R0,TOPOV
       A    R4,R3
       BL   *R10
 
 
*  EX to disk
 
       LI   R0,PBFV+6
       LI   R1,>2000
       LI   R2,LLAST
       S    R1,R2
       BLWP @VMBW
       MOV  R2,@EDHDR+2
       LI   R1,EDHDR
       BL   @FILOP
 
*  EY back to disk
 
       LI   R0,PBFV+6
       LI   R1,HFIRST
       LI   R2,SLAST
       S    R1,R2
       BLWP @VMBW
       MOV  R2,@EEHDR+2
       LI   R1,EEHDR
       AB   @ONE,@NXFILE
       BL   @FILOP
 
 
*  Exit
 
EXITEM LI   R0,>2E8
       LI   R1,KEYMS
       LI   R2,KEYML
       BLWP @VMBW
KEY    BLWP @KSCANA
       JOP  KEY
 
       LWPI >FF7C
       MOV  @CMSRET,R11
       RT
 
*  Program file handler
 
FILOP  EQU  $
       AI   R2,6              File length
       MOV  R2,@FILLEN
       LI   R0,PBFV           Finish file header
       LI   R2,6
       BLWP @VMBW
       BLWP @VMBWD            PAB to VDP
       DATA PABV
       DATA PABDAT,PABLEN
       LI   R3,PABV+9
       MOV  R3,@>8356
       BLWP @DSRLNK
       JEQ  ERROR
       RT
 
ERROR  LI   R0,>207
       LI   R1,ERMS1
       LI   R2,ERMS1L
       BLWP @VMBW
       JMP  EXITEM
 
*  Convert to hex
 
I2H    EQU  $
       LI   R2,HEXNO+1
       MOV  R0,R1
       SRL  R1,12
       MOVB @HEXDGS(R1),*R2+
       MOV  R0,R1
       SLA  R1,4
       SRL  R1,12
       MOVB @HEXDGS(R1),*R2+
 
       MOV  R0,R1
       SLA  R1,8
       SRL  R1,12
       MOVB @HEXDGS(R1),*R2+
 
       MOV  R0,R1
       SLA  R1,12
       SRL  R1,12
       MOVB @HEXDGS(R1),*R2
 
       LI   R1,HEXNO
       LI   R2,5
       MOV  R3,R0
       BLWP @VMBW
       RT
 
 
*  FW Header
 
EDHDR  DATA >FFFF,>1FFA,>2000
EEHDR  DATA >0000,>1FFA,HFIRST
 
*  Various PAB data
 
PABDAT DATA >0600,PBFV,>0
FILLEN DATA >0
       DATA >07
       TEXT 'DSK5.EX'
NXFILE EQU  $-1
PABLEN EQU  $-PABDAT
 
HEXNO  TEXT '>    '
 
KEYMS  TEXT 'Key to exit'
KEYML  EQU  $-KEYMS
 
ERMS1  TEXT 'File-save problem'
ERMS1L EQU  $-ERMS1
 
       EVEN
 
OUREG  BSS >20
 
 
       END  SAVE
 
