 
*  INSTALL/S                  Apr / 08 / 95
*------------------------------------------
*  For CONFIGURING EVRAM 80Z Editor ED file
*------------------------------------------
*  Must be used in Funnelweb environment
 
       AORG >A050             Sit above FW mailbox
 
PABV   EQU  >F80
PBVI   EQU  >1000
PBFV   EQU  >1100
EDVLEN EQU  PBFV+2
VBLOCK EQU  PBFV+10
 
DSRLNK EQU  >FFD4
KSCANA EQU  >FFD0
FILENT EQU  >FFCC
VMBWD  EQU  >FFBA
VMBRD  EQU  >FFB6
VSBRD  EQU  >FFB2
RDDEV  EQU  >FFA0
LDR11  EQU  >FF9C
FWREG  EQU  >FF7C
ESFLAG EQU  >FF60
CMSRET EQU  >FF5C
HXTAB  EQU  >FEA4
 
LLL    EQU  40
 
EILIN  EQU  5*LLL
ECLIN  EQU  12*LLL
EOLIN  EQU  12*LLL
ERLIN  EQU  20*LLL
ERLINM EQU  21*LLL
 
VMBW   EQU  >FED4
VMBR   EQU  >FED0
VSBW   EQU  >FECC
VSBR   EQU  >FEC8
VDPRD  EQU  >8800
VDPWD  EQU  >8C00
VDPWA  EQU  >8C02
KSCAN  EQU  >E
 
 
       DEF  SFIRST,SLAST      For FSAVE
 
*  Check for FWB program load
 
SFIRST EQU  $
CONFIG EQU  $
       C    R11,@LDR11
       JEQ  FWLDD
       BLWP @>0
 
*  OK to proceed - set text-mode
 
FWLDD  LWPI FWREG
       BL   @SETVT1
       DATA >F081
 
*  Clear screen with top & bottom box
 
       LI   R0,>D50
       BLWP @UNPACV
       DATA OUTLTB
       BL   @BOX
       DATA 0,>2601
       BL   @BOX
       DATA 3*LLL,>2613
       BLWP *R9               VMBWD
       DATA >C08,ULDAT,8
 
*  Write up page header
 
       BLWP *R9
       DATA LLL+2
       DATA SLMS10,SLML10
       LI   R0,>8181
       BLWP *R8
       DATA 2*LLL+2,SLML10
 
*  Write up for ED file request
 
       BL   @BOX
       DATA EILIN+8,>1405
       BLWP *R9
       DATA LLL+EILIN+10
       DATA IPMSG,IPMSL
       LI   R0,>8100
       BLWP *R8
       DATA 2*LLL+EILIN+10,IPMSL
       BLWP *R9
       DATA 4*LLL+EILIN+10
       DATA FLNAME,15
 
*  Establish <esc> path, take name, and load file
 
       LI   R11,RET2FW
       MOV  R11,@ESFLAG
       BLWP @FILENT
       DATA 4*LLL++EILIN+10,15
       MOVB @LOAD,@PABDAT
       MOV  @RDDEV,R11
       BL   *R11
       DATA 4*LLL+EILIN+10,EDPNAM
       DATA PABV,PABDAT
       BL   @FILOP
       JMP  JERR
       JMP  ECFILE
JERR   B    @ERROR
 
*  Process ED entry for exit
 
ECFILE LWPI FWREG             In case of <esc>
       BLWP @VMBRD
       DATA EDVLEN
       DATA FWREG,2           Allow for header
       AI   R0,6
       MOV  R0,@EDFILN
 
*  Open EDCONFIG file
 
       BL   @BOX
       DATA ECLIN+8,>1405
       BLWP *R9
       DATA LLL+ECLIN+10
       DATA ECMSG,ECMSL
       LI   R0,>8100
       BLWP *R8
       DATA 2*LLL+ECLIN+10,ECMSL
       BLWP *R9
       DATA 4*LLL+ECLIN+10
       DATA PBINAM+1,15
       LI   R11,CONFIG
       MOV  R11,@ESFLAG
       BLWP @FILENT
       DATA 4*LLL++ECLIN+10,18
       MOVB @OPEN,@PBIDAT
       MOV  @RDDEV,R11
       BL   *R11
       DATA 4*LLL+ECLIN+10,PBINAM
       DATA PABV,PBIDAT
       BL   @FILOP
       JMP  JERR
 
*  Read in file records from config file
 
RDCONF BL   @BOX
       DATA ERLIN+7,>1601
       BLWP *R9
       DATA ERLINM+10
       DATA RDMS,RDML
       LI   R11,OBLOCK        Initialize data block
       CLR  *R11+             sel/ld
       LI   R10,>0004
       MOV  R10,*R11+         lng/hlp
       LI   R10,>8000
       MOV  R10,*R11+         N-P in/out
       CLR  *R11+             P-Q lens
       SETO *R11+             ERAM
       CLR  *R11+             dummy
       CLR  *R11              dummy
       CLR  R14               Initialize count
 
RDCF10 CI   R14,CETBLL
       JHE  EDOUTJ
 
       MOVB @READ,@PBIDAT
       LI   R0,>2020
       BLWP *R8               Clear buffer
       DATA PBVI,80
       BL   @FILDVR           Read dv record
       JMP  JERR
 
       BLWP @VSBRD
       DATA PBVI
       CB   R0,@H20           Count line ?
       JEQ  RDCF10
       CB   R0,@ASTRIX
       JEQ  RDCF10
       CB   R0,@LCA           Upcase then
       JL   RDCF20
       CB   R0,@LCZ
       JH   RDCF20
       SB   @H20,R0
 
*  Process acceptable record
 
RDCF20 MOVB @HXTAB+1(R14),@BDCLIN
       LI   R11,>0010          Construct JMP
       MOVB @CETBL(R14),R11
       SWPB R11
       INC  R14
LDJMP  X    R11
 
BADDAT B    @BADATA           Make sure no null jump data
EDOUTJ JMP  EDOUT
 
*  Process various load instructions
*-----------------------------------
*  Set user selection screen flag
 
SELTY  CB   R0,@ASCN
       JEQ  SELTYX
       CB   R0,@ASCY
       JNE  BADDAT
       MOVB @BFF,@LDIMM
SELTYX JMP  RDCF10
 
*  Load type for Ed
 
LDTYY  MOVB  @TWO,R3
       LI    R4,LDTYP
LDTYY1 BL    @LTYPE
       JMP   BADDAT
       JMP   RDCF10
 
*  Language tyoe
 
LNGTY  MOVB  @EIGHT,R3
       LI    R4,LNGTYP
       JMP   LDTYY1
 
*  # of help files
 
HELPY  SB   @AZERO,R0
       JLT  BADDAT
       CB   R0,@FOUR
       JH   BADDAT
       MOVB R0,@HELPLD
       JMP  RDCF10
 
*  NTSC/PAL on way out/in
 
NTSEX  LI   R2,PALNTS
       JMP  NTSCYX
 
NTSCY  LI   R2,PLNTEX
NTSCYX MOVB *R2,R1
       SB   @AONE,R0
       JLT  BADDAT
       CB   R0,@ONE
       JH   BADDAT
       JL   NTSC10
       ORI  R1,>0200
NTSC10 MOVB R1,*R2
       JMP  RDCF10
 
*  ERAM present
 
ERAMY  MOVB @THREE,R3
       LI   R4,ERAMF
       BL   @VTYPE
       JMP  BADDAT
ERAMYX JMP  RDCF10
 
*  Hard path-name entry for SD
 
HDDSY  LI   R3,HDPGET
       CB   R0,@AZERO
       JEQ  HDD10
 
       BL   @GETHDP
       JMP  ERAMYX
 
HDD10  SB   *R3,*R3
       JMP  ERAMYX
 
*  Dummy entries - now tab type
 
DUM2Y  EQU  $                 ERAMYX
       SB   @AZERO,R0
       JLT  BADDAT
       CB   R0,@ONE
       JH   BADDAT
       MOVB R0,@TABSPC
       JMP  ERAMYX
 
*  Printer entry code
 
PMSGY  LI   R2,PCEDAT
       LI   R3,PCENT
       CB   R0,@ASCP
       JNE  BADDAT
       JMP  PQMSG
 
 
QMSGY  LI   R2,PCXDAT
       LI   R3,PCEXT
       CB   R0,@ASCQ
       JNE  BADDAT
 
*  Common printer code extraction
 
PQMSG  BLWP @VMBRD
       DATA PBVI,CPBUF,27
       LI   R1,25
       CB   @CPBUF+1(R1),@H20
       JNE  BADDAT
 
PQMS10 DEC  R1
       JLT  PQMS30
       CB   @CPBUF+1(R1),@H20
       JEQ  PQMS10
 
       INC  R1
       STWP R5
       MOVB @3(R5),*R3
       LI   R3,CPBUF+1
PQMS20 MOVB *R3+,*R2+
       DEC  R1
       JGT  PQMS20
PQMS30 JMP  ERAMYX
 
*  Output file details
 
EDOUT  BL   @CLOSIT           Close config file
       NOP
       LI   R0,>2020          Erase message box
       BLWP *R8
       DATA ERLIN+7,24
       BLWP *R8
       DATA LLL+ERLIN+7,24
       BLWP *R8
       DATA 2*LLL+ERLIN+7,24
       BLWP *R9               Write new data into ED
       DATA PBFV+10
       DATA OBLOCK,OBLLEN
       BL   @BOX              Get output file name
       DATA EOLIN+8,>1405
       BLWP *R9
       DATA LLL++EOLIN+10
       DATA OPMSG,OPMSL
       LI   R0,>8100
       BLWP *R8
       DATA 2*LLL+EOLIN+10,OPMSL
       BLWP *R9
       DATA 4*LLL+EOLIN+10
       DATA FLNAME,15
 
*  Take down out file name
 
       LI   R11,ECFILE
       MOV  R11,@ESFLAG
       BLWP @FILENT
       DATA 4*LLL+EOLIN+10,15
       LI   R11,CONFIG
       MOV  R11,@ESFLAG
 
*  Write file back to disk
 
       MOVB @SAVE,@PABDAT
       MOV  @RDDEV,R11
       BL   *R11
       DATA 4*LLL+EOLIN+10,EDPNAM
       DATA PABV,PABDAT
       BL   @FILOP
       JMP  ERROR
       JMP  EXITEM
 
*  Error exits
 
BADATA BL   @CLOSIT           Close CONFIG file
       NOP
       BL   @BOX
       DATA ERLIN+7,>1601
       BLWP *R9
       DATA ERLINM+10
       DATA ERMS2,ERMS2L
       BLWP @KSCANA
       JEQ  $-4
       JMP  KEY
 
*  File error
 
ERROR  BL   @BOX
       DATA ERLIN+7,>1601
       BLWP *R9
       DATA ERLINM+10
       DATA ERMS1,ERMS1L
       BLWP @KSCANA
       JEQ  $-4
       JMP  KEY
 
*  Exit
 
EXITEM BL   @BOX
       DATA ERLIN+7,>1601
       BLWP *R9
       DATA ERLINM+10
       DATA KEYMS,KEYML
KEY    BLWP @KSCANA
       JOP  KEY
       JH   RESTRT
 
RET2FW LWPI FWREG
       SETO R4
       CLR  R13
       MOV  @CMSRET,R11
       RT
 
RESTRT B    @CONFIG
 
*  Check and enter type and language
*-----------------------------------
 
VTYPE  EQU  $
       SB   @AZERO,R0         Zero base and check
       JLT  BADVTP
       JEQ  VTYP30            0 -> null for no ERAM
       CB   R0,R3             Upper limit check
       JH   BADVTP
       SB   @ONE,R0           1 for 128 k  (1-4) -> (0-3)
       JNE  VTYP30
       SETO R0                1 -> >FF
VTYP30 MOVB R0,*R4            To target byte for Wd/Pr entry
       SWPB *R4               Expose byte for Pr/Ed
       MOVB @VDPRD,R1         Next byte
       CB   R1,@H20           How many entries ?
       JNE  VTYP40            More than one
       MOVB R0,R1             Copy
       JMP  VTYP60
 
VTYP40 SB   @AZERO,R1         Zero base and check
       JLT  BADVTP
       JEQ  VTYP60
       CB   R1,R3             Upper limit check
       JH   BADVTP
       SB   @ONE,R1           1 for 128 k
       JNE  VTYP60
       SETO R1                1 -> >FF
VTYP60 MOVB R1,*R4            To target byte for Pr/Ed entry
       SWPB *R4               Back to normal order
       INCT R11
BADVTP RT
 
 
LTYPE  EQU   $
       SB    @AONE,R0         Zero base and check
       JLT   BADLTP
       CB    R0,R3            Upper limit check
       JH    BADLTP
 
       MOVB  R0,*R4           To target byte for Wd/Pr entry
       MOVB  @VDPRD,R1        Next byte
       CB    R1,@H20          How many entries ?
       JNE   LTYP10           More than one
 
       MOVB  R0,R1            Copy
       JMP   LTYP20
 
LTYP10 SB    @AONE,R1         Zero base and check
       JLT   BADLTP
       CB    R1,R3            Upper limit check
       JH    BADLTP
 
LTYP20 SLA   R1,4             Shift to MSNibble
       AB    R1,R0
       MOVB  R0,*R4
       INCT  R11
BADLTP RT
 
*  ED to & from disk
*-------------------
 
CLOSIT EQU  $
       MOVB @CLOSE,@PBIDAT
 
FILDVR EQU  $
       BLWP *R9
       DATA PABV,PBIDAT,>28
 
FILOP  EQU  $
       LI   R3,PABV+9
       MOV  R3,@>8356
       BLWP @DSRLNK
       JEQ  EXERR
       LI   R0,PABV+1
       BLWP @VSBR
       SRL  R1,13
       JNE  EXERR
       INCT R11
EXERR  RT
 
*  Set VDP routines
 
SETWDA EQU  $                 Do not use in FWREG
       ORI  R9,>4000
       SWPB R9
       MOVB R9,@VDPWA
       SWPB R9
       MOVB R9,@VDPWA
       RT
 
SETVT1 EQU  $
       MOVB *R11,@>83D4
SETVTR MOVB *R11,@VDPWA
       INC  R11
       MOVB *R11+,@VDPWA
       RT
 
*  Get hard-path name
*--------------------
 
BADGET B    @BADATA
 
GETHDP EQU  $
       BLWP @VMBRD
       DATA PBVI,CPBUF,44
       LI   R2,HDPNAM
       LI   R1,43
       CB   @CPBUF(R1),@H20
       JNE  BADGET
 
GETH10 DEC  R1
       JLT  BADGET
       CB   @CPBUF(R1),@H20
       JEQ  GETH10
 
       CB   @CPBUF(R1),@PERIOD
       JNE  BADGET
 
       INC  R1
       STWP R5
       MOVB @3(R5),*R3
       LI   R3,CPBUF
GETH20 MOVB *R3+,*R2+
       DEC  R1
       JGT  GETH20
       RT
 
*  Box outline data
*-------------------
 
BOXTD  DATA 6,>AC00,>AA11,>AF00
BOXBD  DATA 6,>AE00,>AB11,>B100
BOXTPW EQU  BOXTD+5
BOXBTW EQU  BOXBD+5
 
*  UNPACV for RLE data to VDP
*----------------------------
*  Call as LI   R0,VDPtr
*          BLWP @UNPACV
*          DATA Data-list  starting with # bytes (2 x entries)
 
UNPAC1 EQU  $                 16 w -----
       MOV  *R13,R9           Fetch screen address
       MOV  *R14+,R0          Fetch list pointer
       BL   *R10              SETWDA from R9
       MOV  *R0+,R11          First word is count of bytes in list
       JEQ  UNPAC5            Null - quit while ahead
 
UNPAC2 MOVB *R0+,R2           First byte of word is byte for VDP
       MOVB R2,*R12           Write it
       MOVB *R0+,R1           Second is # of repetitions
       SRL  R1,8              Word adjust
       JEQ  UNPAC4            No repeats - count off entry
 
UNPAC3 MOVB R2,*R12           Write to VDP again
       DEC  R1                Count off
       JGT  UNPAC3            More left
 
UNPAC4 DECT R11               Count off entry
       JNE  UNPAC2            Not done yet
UNPAC5 RTWP                   ALL done
 
*  Workspace for UNPACV
*----------------------
 
UNPAWS EQU  $                 16 w -----
       DATA >0                R0   Uesd by UNPACV
       DATA >0                R1   "
       DATA >0                R2   "
 
BOXSD  DATA 6                 R3   Side data
       DATA >AD00             R4
       DATA >2011             R5
       DATA >B000             R6
BOXSDW EQU  BOXSD+5
 
UNPACV DATA UNPAWS            R7   BLWP vector
       DATA UNPAC1            R8   "
       DATA >0                R9   for SETWDA
       DATA SETWDA            R10  byte saver
       DATA >0                R11  for BL return
       DATA VDPWD             R12  byte saver
       DATA >0                R13
       DATA >0                R14
       DATA >0                R15
 
*  BOX Drawing routine
* --------------------
*  Call as  BL   @BOX
*           DATA VDPtr
*           DATA <horiz,vert>  as inner size
*  Uses     R0,R1
 
BOX    EQU   $                25 w -----
       MOV   *R11+,R0         Fetch VDP pointer for UR corner
       MOV   *R11+,R1         Horiz/Vert inner size
       SB    @ONE,R1          Count is # repetitions horizontally
       MOVB  R1,@BOXTPW       Write in (inner width - 1)
       MOVB  R1,@BOXSDW       For sides
       MOVB  R1,@BOXBTW       For bottom also
       ANDI  R1,>007F         Mask to vertical count only
       BLWP  @UNPACV          Decompress top line data
       DATA  BOXTD            Top line data
BOX10  AI    R0,LLL           Next line indexed by global pointer
       BLWP  @UNPACV          UNPACV sides one line at a time
       DATA  BOXSD            Side data
       DEC   R1               Count off
       JGT   BOX10            Do another
       AI    R0,LLL           Now for the bottom line
       BLWP  @UNPACV          Decompress bottom line
       DATA  BOXBD            Data pointer
       RT                     RETURN
 
*  Character patterns
 
*  >AA Top, >AB Btm
*  >AC LTC, >AD LSd, >AE LBC
*  >AF RTC, >B0 RSd, >B1 RBC
 
OUTLTB DATA OUTLLN
       DATA >FF00,>000D,>FF01,>8015
       DATA >FF01,>0415,>FF00
       DATA >0002,>FF01,>0002
 
       DATA >8002,>FF00,>8003
       DATA >0402,>FF00,>0403
OUTLLN EQU  $-OUTLTB-2
 
FILLN  DATA 2,>AB01         >85
 
 
*  Underline data
 
ULDAT  DATA >0000,>00FF,>0,>0
 
*  Branch table for entries
 
CETBL  EQU  $
       BYTE SELTY-LDJMP-2/2   #1  Select Immediate   Y/N
       BYTE LDTYY-LDJMP-2/2   #2  Load type          1-4
       BYTE LNGTY-LDJMP-2/2   #3  Language           1-8
       BYTE HELPY-LDJMP-2/2   #4  Help screens       0-4
       BYTE NTSCY-LDJMP-2/2   #5  NTSC/PAL in        1/2
 
       BYTE NTSEX-LDJMP-2/2   #6  NTSC/PAL out       1/2
       BYTE ERAMY-LDJMP-2/2   #7  ERAM oresent       Y/N
       BYTE HDDSY-LDJMP-2/2   #8  Hard path flag     0 or name
       BYTE DUM2Y-LDJMP-2/2   #9  Tab type           0
       BYTE PMSGY-LDJMP-2/2   #10 Printer set codes  P~~~~~~~~~~~
       BYTE QMSGY-LDJMP-2/2   #11 Printer reset      Q~~~~~~~~~~~
 
CETBLL EQU  $-CETBL
 
       EVEN
 
*  PAB opcodes
 
OPEN   EQU  $
NUL    BYTE >00
CLOSE  EQU  $
ONE    BYTE >01
READ   BYTE >02
TWO    EQU  READ
THREE  BYTE >03
FOUR   BYTE >04
LOAD   BYTE >05
SAVE   BYTE >06
SEVEN  BYTE >07
EIGHT  BYTE >08
BFF    BYTE >FF
H20    BYTE >20
ASTRIX BYTE '*'
LCA    BYTE 'a'
LCZ    BYTE 'z'
ASCY   BYTE 'Y'
ASCN   BYTE 'N'
ASCP   BYTE 'P'
ASCQ   BYTE 'Q'
AZERO  BYTE '0'
AONE   BYTE '1'
AFOUR  BYTE '4'
AEIGHT BYTE '8'
PERIOD BYTE '.'
 
       EVEN
 
PQMAX  DATA 24
 
*  In/Output PAB data for ED
 
PABDAT DATA >0500,PBFV,>0
EDFILN DATA >2100
       BYTE >00
EDPNAM BYTE >07
FLNAME TEXT 'DSK'
DSKNO  TEXT '5.ED           '
LNFILE EQU  $-1
PABLEN EQU  $-PABDAT
 
*  Input PAB data for Edconfig file
 
PBIDAT DATA >0014
PBIBUF DATA PBVI,>5050,>0
       BYTE >0
PBINAM BYTE >0E
       TEXT 'DSK5.CONFIG/ED             '
PBILEN EQU  $-PBIDAT
       EVEN
 
*  Messages
 
SLMS10 TEXT 'FWB ED V 5.20 CONFIGURATION - Apr/95'
SLML10 EQU  $-SLMS10
 
IPMSG  TEXT 'Input ED file as :'
IPMSL  EQU  $-IPMSG
 
ECMSG  TEXT 'Input EDCONFIG as :'
ECMSL  EQU  $-ECMSG
 
OPMSG  TEXT 'Resave ED file as :'
OPMSL  EQU  $-OPMSG
 
       EVEN
 
RDMS   TEXT ' Read Config data '
RDML   EQU  $-RDMS
 
KEYMS  TEXT ' ** Key to exit **'
KEYML  EQU  $-KEYMS
 
ERMS1  TEXT 'Disk/File problem '
ERMS1L EQU  $-ERMS1
 
ERMS2  TEXT 'Bad Data Item # > '
BDCLIN EQU  $-1
ERMS2L EQU  $-ERMS2
 
       EVEN
 
*  Entry code and parameter block
*--------------------------------
*  Starts at >2004
 
OBLOCK EQU  $
LDIMM  BYTE >0                SETO => halt for choice screen
LDTYP  BYTE >0                0 -> USA, 1 AllCh, 2 TIEW
LNGTYP BYTE >0                0 - 8
HELPLD BYTE >04               Load up to 4 help screens
PALNTS BYTE >80               NTSC/PAL & IL at entry
PLNTEX BYTE >00               Exit
PCENT  BYTE >00               Printer control - entry length
PCEXT  BYTE >00               Exit codes length
ERAMF  DATA >FFFF             ERAM present flag
HDPGET BYTE >0                Hard path entry flag/length for SD
       BYTE >0                Spare
TABSPC BYTE >0                Tab record type
       BYTE >0                Spare
       DATA '52'
 
*  Printer codes, 24 bytes each
*------------------------------
*  24 w
 
PCEDAT BYTE >20,>20,>20,>20,>20,>20,>20,>20
       BYTE >20,>20,>20,>20,>20,>20,>20,>20
       BYTE >20,>20,>20,>20,>20,>20,>20,>20
 
PCXDAT BYTE >20,>20,>20,>20,>20,>20,>20,>20
       BYTE >20,>20,>20,>20,>20,>20,>20,>20
       BYTE >20,>20,>20,>20,>20,>20,>20,>20
 
*  Hard path name data
*---------------------
 
DISNAM TEXT 'DSK5. '
HDPNAM TEXT 'DSK2.           '
       TEXT '                '
       TEXT '          '
       EVEN
 
OBLLEN EQU  $-OBLOCK
 
SLAST  EQU  $
CPBUF  BSS  >50
 
       END
 
