 
*  EE4/ENTRY                 May / 13 / 95
 
*  2,4,8 files in 128 Kb V/ERAM Buffer version
*---------------------------------------------
*  Entry routine at end of existing SD code
*  May be overwritten after execution
*  Turn off screen and test for ERAM - kill ERAMF if none
*  ERAMF  byte choices as configured - shift to MSB
*  W/P value in MSByte, P/E value in LSByte
*  >00  ERAM absent  -  64 Kb single buffer only
*  >FF  ERAM present - 128 Kb single buffer
*  >01  ERAM present - dual 64 Kb buffers
*  >02  ERAM present - quad 32 Kb buffers
*  >03  ERAM present - eight 16 Kb buffers
 
HIBUF  EQU  $
       LWPI >E000             Use any old clear WS for now
       BL   @SETVR1           VWTR + pad load
       DATA >3081             Turn TM1 screen off
       MOV  @ERAMF,R4         Collect preset Edit flag
       SETO R3                Presume no ERAM
       BL   @SETVRG           Set ERAM if present
       DATA >40AD             VR #45
       BL   @SETVRG           Set bank #0
       DATA >008E             VR #14
       CLR  R9                Point to first byte
       BLWP @SETVDR           Set for read
       MOVB @VDPRD,R1         Read the byte
       MOVB R1,R2             Save copy
       INV  R1                Invert bits
       BLWP @SETVDW           Set VDP write
       MOVB R1,@VDPWD         Write back inverted byte
       BLWP @SETVDR           Set for read again
       CB   @VDPRD,R1         Is it what we just wrote ?
       JNE  C9938             No - presumably no ERAM
       CLR  R3                Clear no-ERAM warning flag
       BLWP @SETVDW           Set write again
       MOVB R2,@VDPWD         Restore original byte
C9938  BL   @SETVRG           Cancel ERAM access
       DATA >00AD             Reset VRAM
       SZC  R3,R4             Clears ERAMF flag -> single 64 KB only
       MOV  R4,@FWREG+6       Make copy in R3 of FWREG
 
*  Resume normal entry - warn if EVRAM not found
 
       LWPI FWREG             Use FW Regs for now
       MOV  R3,R3             Collect EVRAM absent flag
       JNE  HIBUG             No special warning needed
       LI   R0,MSG26          Original 128K msg
       LI   R11,MSERA         Replace with 64 K
       MOV  *R0+,*R11+        Word aligned
       MOV  *R0+,*R11+        2 more
       MOV  *R0,*R11          Last
 
*  Continue normal entry
 
HIBUG  SOCB @MASK10,@>83C2    Set flag bit to turn off Quit
       S    @LNTSAV,@LNTLEN   Avoids REF/DEF problems
       SLA  R13,3
       MOVB @LDTYPB,R10       Copy load types
       MOVB @LNGTYP,R11       Copy language types
       MOV  R4,R4             Check implicit load setting
       JNE  NTR10             Pr/Ed
       SWPB R3                EVRAMF for W/P to LSB
       SLA  R10,4             Clear off Pr/Ed entry
       SLA  R11,4             Also
NTR10  SRL  R10,4             Make LS nibble of MS byte
       SRL  R11,4             Also
       SLA  R3,8              Single/double to MSB
       MOV  R3,@EVRAMF        Save more permanently
       JLT  NTR20             Single file only allowed
       JEQ  NTR20             No ERAM
       AB   @ONE,@SLMS18      Adjust default for 2
NTR20  MOVB R10,@LDTYPB       Copy back result
       MOVB R11,@LNGTYP       Also
       AB   R10,@SLMS23       Set default to configured choice
       AB   R11,@SLMS41       For language choice also
       MOV  @CPUDEL,@DELVAL   Set sound/delay duration
       MOV  @>0CFC,R11        ROM table #2 pointer
       MOV  @4(R11),@CFIAD    Write CFI routine pointer to code
       MOV  @INCOL,R1         Fetch FW color index
       MOV  R1,@COLCH         Color pointer
       INC  R1                Use next one for CMD line
       CI   R1,>A             Off end of table
       JL   EDENU             No
       CLR  R1                Reset to first entry
EDENU  MOV  R1,@BCOLC         Save as back color index
       MOV  @COLRS,R1         Color pointer in FW
       LI   R2,TWCOLS         Pointer to color choices in ED
EDNT1  MOV  *R1+,*R2+         R1 preloaded to FWB color list
       CI   R2,TWCOLT
       JL   EDNT1
       MOV  @BCOLC,R1         Secondary color choice
       MOVB @TWCOLS(R1),@BCB  Fill in the color byte
 
*  Move fast code to PAD
 
       LI   R1,PAD01
       LI   R2,FASTVW         Fast code data
MVFS10 MOV  *R1,*R2+
       CI   R2,FASTVW+38      Expand loop
       JL   MVFS10
MVFS20 MOV  *R1+,*R2+         Continue with next bit
       CI   R1,FCEND
       JL   MVFS20
 
*  Fetch user defined VDP values
 
       LI   R1,PALNTS         Point to 4 byte block
       MOVB *R1,@BCA          Entry value VR9
       MOVB *R1+,@V9SAV       Toggle start
       MOVB *R1+,@V9EXIT      Exit value
       MOVB *R1+,@PCCENT      Printer entry control
       MOVB *R1,@PCCEXT       Printer exit control
       MOVB @TABSPC,R11       Fetch TAB spec byte
       ANDI R11,>0100         Isolate the relevant bit
       MOV  R11,@TABTYP       Null is USA tabs
 
*  Set TM2 registers
 
       LI   R2,SETVRG         Byte saver
       BL   *R2
       DATA >0480             Set TM 2 mode
       BL   *R2
       DATA >0382             Needed for TM2 screen table @>0
       BL   *R2
       DATA COLTM1            Sets VR #3
       BL   *R2
       DATA SDPATT            Pattern table at VB1Store >0C84
       BL   *R2
BCA    DATA >8089             PAL/NTSC
       BL   *R2
       DATA >018A             All color tables in VB #1
       BL   *R2
BCB    DATA >008C             Color byte for blink color
       BL   *R2
       DATA >F08D             Jam blink on fulltime
 
*  Load pattern table with FW box chars
 
       BLWP @VMBRF            Fetch from VDP
       DATA >800              Normal E/A
       DATA PSTORE,PTTBLN     Move to RAM below FWB
       BLWP *R9               Write to new TM2 pattern table
       DATA >1000
       DATA PSTORE,PTTBLN     Stuff just read to CPU mem
       BL   @MKRPTS           Write in >1F,>7F,>FF
       BLWP @VMBRF            Now read back to CPU
       DATA >1000
       DATA PSTORE,PTTBLN
       BL   @BANK1
       MOV  @CMRET,R11        Establish for return in FW
       BLWP *R9
       DATA VB1STO            Store at >2000 in VB #1
       DATA PSTORE,FSTLEN     Save Ptl+FW on VRAM page #1
       LI   R0,8*>AA+VB1STO   Start at >AA char
       BLWP @UNPACV           @UNPACV
       DATA OUTLTB            Box outline chars
       CLR  R0                For primary color set
       BLWP *R8               VFill
       DATA COLTB1,>30E       Normal & command edit screens
       BL   @BANK0
 
*  Check User screens on way in
*------------------------------
*  Spacebar forces user config
*  LDIMM set -> user config anyway
 
       MOVB  @LDIMM,R11       Check user config also
       JNE   WPEDCH
       BLWP  @KSCANF          Do a keyscan
       CB    @KEYRT,@DSPACE   Check return for space-bar
       JNE   NOSLCT           Go to language screen
 
*  Editor / Language selection
 
WPEDCH LWPI FWREG             In case of <esc> to here
       BL   @WPEDSC           Various choices
       CLR  @ESFLAG           Reset FW <esc> flag
       BL   @SETVR1           Turn screen off again
       DATA >3081
 
*  Process selections - all look same now
*----------------------------------------
*  Set EUROWR is default, CHAR@<x> only
*  FIXPBS loads R1,R2 pointers
 
NOSLCT EQU  $
       BL   @FIXPBS           Set up PABs ( help files also )
       LI   R0,>201F          Clear screen for ED
       BLWP *R8               VFILF
       DATA >780,3*LLL        Last 3 lines worth
       MOVB @LDTYPB,R15       Fetch load type byte
       MOVB @LNGTYP,R14       Fetch language byte
       CLR  R5                Flag no char-file loaded
       SRL  R15,8             Make index (0 - 2)
       JEQ  LOCHRF            This is default 8-bit
       DEC  R15               Test next - now -1,0,1
       JEQ  NATL7             Must be Lang Select (all/char)
       DEC  R1                Point to CHAR<A>1 for E/W
NATL7  AB   R14,*R1           Adjust command text
       AB   R14,*R2           Adjust character file
 
*  Load character file
 
LOCHRF BLWP *R9               PAB data to VDP
       DATA VDPPAB
       DATA PABCHD,>20        Char file PAB data
       BL   @LOADCT           Program file loader
       JMP  NOCHRF            Char file not found
       SETO R5                Flag it was loaded
       BL   @CLRCHF           Found - clear warning
       BL   @MKRPTS           Reset special chars for display
NOCHRF SRL  R14,8             Make index of LNGTYP
       DECT R14               USA or Britain ?
       JLT  EUWFIX            No text change needed
       BLWP *R9               PAB data to VDP
       DATA VDPPAB            Usual PAB location
       DATA PABFWD,>20        Big enough
       BL   @LOADCT           Load language program file
       JMP  VB2CON            FAIL - results will be obvious
       BLWP @VMBRF            Copy over program default
       DATA CATBF             Not being used yet
       DATA TEXT,>500         Some length to spare
 
*  Revert to most basic if no char loaded
 
EUWFIX EQU  $
       MOV  R5,R5             Were any 8-bit chars loaded ?
       JNE  EUWF30            Yes - proceed as normal
       CLR  @EUROWR           Clear special tab flag
       CLR  R0                Blanks in pattern table
       BLWP *R8               VFILL
       DATA >1400,>3F8        Clear hi-bit patterns
       JMP  EUWF50            Also clear hi-bit control
 
*  Write in vowel modifier keys for E/W and cancel hi-bits
 
EUWF30 DEC  R15               All-Chars mode ?
       JLT  VB2CON            Yes - hibits only
       LI   R0,VOWEL          Pointer to routine
       LI   R1,VWLCOM         In edit mode table
       LI   R2,VWLCMD         In command mode table
       LI   R11,4             Only 4 of
EUWF40 MOV  R0,*R1+           Write in
       MOV  R0,*R2+           Two places
       DEC  R11
       JGT  EUWF40
       CLR  R0
       BLWP *R8               Clear pattern table above Euro-chrs
       DATA 8*>A8+>1000
       DATA 8*>58
EUWF50 LI   R0,START          Void hi-bit entry pointer
       MOV  R0,@HBKEYE        Write into command tables
       MOV  R0,@HBKEYC        Command as well as edit mode
 
*  Continue after any language
*-------------------------------------------
*  Use space below FW/USL as temp CPU buffer
 
VB2CON EQU  $
       MOV  @FILCLN,R11       Cleanup routine pointer
       CLR  R0                Turn off EDBUF load
       BL   *R11              Execute it
       MOV  @CFILE#,R11       Fetch FILES entry pointer
       BL   *R11              Execute it
       DATA >0100             Only 1 needed at a time
 
*  SD color tables and screen
 
       BL   @BANK1            VBank #1
       BL   @FILCLT           Fill in SD color tables
 
*  Save command and switch tables in VDP
 
       MOV  R4,R4             Need to change <fctn-2> entry ?
       JEQ  WCTABL            No
       MOVB @MS28A,@MS27A     Initial screen message details
       MOVB @MS28B,@MS27B     Convert W/P to P/E
       SWPB @HTYPE            Set to do HELP8P first
       LI   R10,PRETTY        Aligned new-line
       MOV  R10,@FCTINS       Write to command table  <c-M>
       LI   R10,PREDEL        Delete blank lines only
       MOV  R10,@FCTDEL       Write to command table  <c-2>
WCTABL BL   @SDFBBS           Write up SD screen items
       BL   @BANK0            Base bank again
       BLWP *R9               VMBWF
       DATA COMVE             VDP storage
       DATA CTBL,TABLEN       Consecutive tables
 
*  Clear storage buffers - RSMSV, TMPBF, DEV, RSF, SDL
*-------------------------------------------------------
*  Fetch FW items & use FW routines while FW still valid
 
       LI   R0,>2020          Load with blank
       BLWP *R8               VFILL
       DATA RSMSV             Buffer area
       DATA DSKLIM-RSMSV      Clean out in one go
       BLWP *R9               Store printer codes
       DATA PCEBUV            In VB0 ready for PF
       DATA PCEDAT,48         Hard pathname also, if any
       BLWP *R9               VMBWD
       DATA DSKBUV,DISNAM,6   Set standard "DSKx." form
       BLWP *R8               @VFILF
       DATA >780,3*LLL        Lines 25-27 all at once
       BLWP *R9               @VMBWF
       DATA >7D0,NBLINE,LLL   Tab line template
       LI   R11,FTLNAM        Temp file name
CLRTLN MOV  R0,*R11+          Blank out initially
       CI   R11,FTLNAM+LLL    Done ?
       JL   CLRTLN            No
 
*  Fetch printer name from FW
 
       MOV  @EDPRNT,R0        Get name pointer
       BLWP @VSTRWF           Write to VDP
       DATA PRDBUV
       MOV  @EDPRNT,R0        Copy for SD Printer also
       BLWP @VSTRWF
       DATA PSDBUV
 
*  Initialize buffer and clear lo-mem flag area
*  Check for user flagged hard pathname
 
       MOVB @HDPGET,R11       Check user flag
       JEQ  USEUTL            Yes - in place already
       BLWP *R9               VMBWDF
       DATA HDPBUV,HDPNAM,42  Write in user supplied path
       JMP  NEWCOM
 
USEUTL MOV  @BTLN,R0          Put FW Util pathname instead
       AI   R0,BL2UT          Offset to Util pathname
       BLWP @VSTRWF           Use FW string write
       DATA HDPBUV            Load up VDP storage
       MOVB @DSPACE,@VDPWD    Make sure of following space
 
*  Write in new commands
 
NEWCOM MOV  @TEXT+CMLPT,R1    Point into offset table
       AI   R1,TEXT           Construct memory pointer
       LI   R0,CMDTBL         Start of command table
NXCOMD MOV  *R1+,*R0          Copy command as a word
       AI   R0,CMDTE          Advance to next entry
       CI   R0,CMDTND         Done ?
       JL   NXCOMD            No
       MOV  *R1+,*R0+         Fill out secondary response table
       MOV  *R1+,*R0+         8 byte entries on word bdy
       MOV  *R1+,*R0+
       MOV  *R1+,*R0
       LI   R0,EOFLIN         For EoF indicator
       MOV  *R1+,*R0+         Assumed consecutive
       MOVB *R1,*R0
 
*  Set up RS Verify message in VDP first
 
       LI   R0,RSMSV          RS verify message
       MOV  @TEXT+RSMSP,R1    Get offset in message file
       AI   R1,TEXT           Make absolute address
       MOVB *R1+,R2           Length byte
       SRL  R2,8              Make count
       BLWP @VMBWR            FW's standard VMBW
       BL   @TABEXP           Expand tab data - overwrite rest of data
 
*  Text messages to VDP
 
       BLWP *R9
       DATA FFSCOD            Fast find string code
       DATA FFS24,FFSLEN
       LI   R0,TEXTV          Storage for command text
       LI   R1,TEXT           It is here now
       MOV  @TEXT+TXTRAN,R2   Get total length from table
       BLWP @VMBWR            Copy to VDP - FW register VMBW
 
*---------------------------------------
*  Last use of valid FW area now done
*---------------------------------------
 
*  Switch tabs and screen message
*--------------------------------
 
       LI   R0,22             Size of Tab table
       LI   R1,FORMO          Target address in hi-mem
       LI   R2,FRMWP          Initialize data pointer
       MOV  R4,R4             Pr/Ed ?
       JEQ  WNOTAB            No - skip changes for P/E
       LI   R2,FRMPE          Adjust TAB table pointer
       SZCB @H0F,@NOTABS      Make the JNE a JMP - kill TAB write
       JMP  PETAB
 
*  Load default tab table
 
WNOTAB EQU  $
       LI   R2,FRMPE          Adjust TAB table pointer
PETAB  MOV  *R2+,*R1+         Write in appropriate default Tab table
       DECT R0
       JGT  PETAB
 
*  Fill out inline block code
 
       LI   R0,INBLEN         # words in each in-line block >1FF
       LI   R1,RDBLOK
       LI   R2,WRBLOK
       LI   R3,LTBLOK
VINL10 MOV  @VINST1,*R1+      MOVB *R15,*R0+ instruction
       MOV  @VINST2,*R2+      MOVB *R0+,*R15
       MOV  @CINST5,*R3+      MOV  *R8+,*R9+
       DEC  R0
       JGT  VINL10
       LI   R0,LLL            Display line worth of inline code
       LI   R5,FVBLOK
       LI   R6,CVBLOK
VINL20 MOV  @VINST3,*R5+      MOVB R12,*R10  instruction
       MOV  @VINST4,*R6+      MOVB *R8+,*R9
       DEC  R0
       JGT VINL20
       LI   R0,>045B          Finish each with an RT
       MOV  R0,*R1
       MOV  R0,*R2
       MOV  R0,*R3
       MOV  R0,*R5
       MOV  R0,*R6
 
*  Change to TI-Wr Edit workspace
*  Clear out command table area
*------------------------------------------
*  All data must have been retrieved by now
*  Load help file as DV/80
*  Store header and last >20 bytes of each screen in HLPBUV
 
       LWPI SCNWS             FW past history now
       MOV  @HELPLD,R5        Check Help flag
       JEQ  NOHLPS            Do not bother
       LI   R1,PABHLN         Length byte
       LI   R2,MFBUF          Usual buffer in screen area
       MOVB *R1+,R0           Fetch length byte
       SRL  R0,8              Make count
HLPL10 MOVB *R1+,*R2+         Fetch name
       DEC  R0                Count
       JGT  HLPL10            Not done yet
       MOV  R2,R3             Save pointer
       DEC  R3                Last character
HLPL20 MOVB @DSPACE,*R2+      Fill rest with blanks
       CI   R2,MFBUF+>4F      Usual length
       JL   HLPL20
 
*  Open DV/80 Help file
 
       CLR  R7                Start counter
       MOVB @HTYPE,*R3        Force "W" or "P" as appropriate
       BL   @FILPRO           Open file
       DATA >0014             DV/80
       DATA MFBUF             Name loaded
       JMP  NOHLPW            Not found
       JMP  HLPL25            Proceed normally
NOHLPW MOVB @HTYPE+1,*R3      Interchange W and P
       BL   @FILPRO           Open file 2nd attempt
       DATA >0014             DV/80
       DATA MFBUF             Name loaded
       JMP  NOHLPS            Not found
 
*  Read header
 
HLPL25 CLR  R2                Start of VBank #2
       LI   R3,HLPBUV         Header line storage pointer
HLPL30 BL   @IORCRD           Go read a record
       JMP  NOHLPS            Load error, code in R9
       BL   @MOVE             Move buffer to CPU
       DATA PABBUF            Standard buffer
       DATA LINBUF,>30        Only part line for header
       INC  R7                Count one header
       MOV  R3,R9             Copy VB #0 target
       AI   R3,>30            Advance pointer past it
       BL   @VMBWE            Store header
       DATA LINBUF,>30        Only so much
       LI   R5,26             Lines per screen
 
*  Now for lines
 
HLPL40 BL   @IORCRD           Go read a record
       JMP  NOHLPS            Load error, code in R9
       BL   @MOVE             Move buffer to CPU
       DATA PABBUF            Standard buffer
       DATA LINBUF,LLL        Full line
       BL   @BANK2            VB #2 storage for whole or part line
       MOV  R2,R9             Copy VB #2 pointer for use
       DEC  R5                Count off line
       JEQ  HLPL50            This is last line
 
*  Store full lines up to penultimate
 
       BL   @VMBWE            Copy to VB #2
       DATA LINBUF,LLL        Full line
       AI   R2,LLL            Advance pointer
       BL   @BANK0            Back to normal bank
       JMP  HLPL40            Get next line
 
*  Split last line to fit and continue to next screen
 
HLPL50 BL   @VMBWE            Copy part line to VB #2
       DATA LINBUF,>30        Makes >800 worth per screen
       AI   R2,>30            Advance pointer - total of >800
       MOV  R3,R9             Copy pointer after header
       BL   @BANK0            Restore DSR bank
       BL   @VMBWE            Get rest of line
       DATA LINBUF+>30,>20    Place after header entry
       AI   R3,>20            Advance pointer
       CI   R7,8              8 screens max
       JL   HLPL30            Next help screen worth
NOHLPS BL   @CLOSE            Close file anyway
       NOP                    ; Who cares now
       MOV  R7,@ENTCTB        Load counter
 
*  Initial clear of parameter area
 
HLPL80 BL   @BANK0            Restore normal bank
       LI   R2,SCLR
COCT   CLR  *R2+              Clear for first entry
       CI   R2,PARBLK         TWO now shifted out of road
       JL   COCT
 
*  Set up screen messages
 
       LI   R10,MSG24         Message pointer
       LI   R11,LINT34        Table pointer
       MOV  R10,*R11+         Line 17
       AI   R10,80            Underline
       MOV  R10,*R11+         Line 18
       AI   R10,80            Underline
       MOV  R10,*R11+         Line 19
       AI   R10,80            Char file error
       MOV  R10,*R11          Line 20
 
*  Set up blanked area in hi-mem
 
       LI   R0,>2020          Word of spaces
       LI   R1,MSG24          Blank area for initial messages
EDNT3  MOV  R0,*R1+           Write blanks
       CI   R1,4*86+MSG24     Enough for 4 display lines
       JL   EDNT3
 
*  Move common message text into blanked area
 
       MOVB @UDLINE,R2                Underline char
       LI   R1,MSL26                  FW ident message for length
EDNT4  MOVB @MSGFW-1(R1),@MSG24+24(R1)
       MOVB R2,@MSG24+24+LLL(R1)
       MOVB @MSG26-1(R1),@2*LLL+MSG24+24(R1)
       MOVB @CFALM1(R1),@3*LLL+MSG24+24(R1)
       DEC  R1
       JGT  EDNT4
 
*  Variations for Wd/Pc or Pr/Ed
*-----------------------------------------
*  Replace wordwrap cursor & reformat code
 
       SETO @WDPROC           Initialize for W/P
       MOV  @FWREG+8,R4       TI-Wr or Pr/Ed  ?
       JEQ  MCP20             Wd/Pr
 
*  Program Editor entry details
 
       LI   R1,8              1 pattern worth
EIGHT  EQU  $-1
NWCS10 MOVB @ACSR-1(R1),@WCSR(R1)  Allow for len byte @WCSR
       DEC  R1
       JGT  NWCS10
       CLR  @WDPROC           Disallow wrap
       SETO @LINF             Set line # mode
       LI   R15,WORDW         Editor entry - force switch
       LI   R1,ASPARS         Allow ASMode
       JMP  MCP30
 
*  Word processor entry details
 
MCP20  LI   R1,WDWRAP         To set wordwrap
       LI   R15,START         WP entry
       SETO @CRFLAG           Initialize
       CLR  @LINF             No line # mode
 
*  Common continuation of entry details
 
MCP30  SETO *R1               Set appropriate flag
       MOV  R1,@WPMODE        Set WP/PE flag
       LI   R14,TABBUV        Start of TAB storage
WRMPLT MOV  R14,R9            Running pointer
       LI   R8,FORMO          Current tabset
       BL   @VMBWL            Write a copy to VDP
       DATA 22                One of 9 copies
       AI   R14,22            Advance VDP pointer
       CI   R14,9*22+TABBUV   Check all done
       JL   WRMPLT            Not yet
FORMDT LI   R1,FORMO          Format table pointer
       MOV  *R1,@LMRG         Set left margin
       MOV  *R1+,R2           Set initial cursor there
       MOV  *R1,@RMRG         Right Margin
       MOV  @SSNLEN,@SCNLEN   Screen length default
       MOV  @CPUADR,@TOPSCN
       BLWP @MAKSEG           Initialize segment data
       BL   @PURGF            Initialize - 1 blank line
       LI   R0,>820           Moving pointer line
       MOV  R0,@LASTCR        Initialize pointer
       BL   @WINDOW           Set window parameters
       BL   @BUMPC            Set cursor parameters
       BL   @VMBWD            Write to VDP
       DATA WFLBUV            Workfile list
       DATA FILNAM,LLL        First entry from mailbox
 
*  Initialize for multiple buffer operation
 
       MOV  @EVRAMF,R5        Check for multi-file
       JLT  GO2ED             Single large
       JEQ  GO2ED             Single small
       LI   R0,EDWBUV         Name storage area
       MOV  @ENTCRF,R5        Max # to do
       DEC  R5                One already done
       CLR  R13               Initialize
NONAMG INC  R13               Next in ring
       AI   R0,LLL            Next entry position
       MOV  R0,R9             Copy for use
       BL   @VMBWE            Write in again
       DATA NONAME,6          "noname" again
       BL   @SWRINI           Store initialized buffer data
       DEC  R5                Count off
       JGT  NONAMG            More to do
       CLR  @EDWIDN           Reset file ring ID
       JMP  GO2EDT            Leave <E > set for multi
 
GO2ED  LI   R11,CMDXIT        Force single file only
       MOV  R11,@ECOMD        Patch command table
GO2EDT CLR  R5                Initialize key save
       B    *R15              Preloaded entry
 
*  Reset path first time round main loop
*---------------------------------------
 
SECOND MOV  @LASTCR,R9        Replacement inst'n data
 
FIRST  EQU  $
       LI   R11,RWBRN         Point to first-time branch
       MOV  @SECOND,*R11+     Replace with new instruction
       MOV  @SECOND+2,*R11    And the next word
       BL   @SETVRG           Set pattern table
       DATA EDPATT            >0284
       BL   @SETVR1
       DATA >7081             VReg 1 value to turn on screen
BRINS  B    @COMAND           Set command mode
 
*  Data for in/line block code
 
VINST1 MOVB *R15,*R0+         VDPRD preloaded
VINST2 MOVB *R0+,*R15         VDPWD preloaded
VINST3 MOVB R12,*R10          VDPWD preloaded   For FVLFIL
VINST4 MOVB *R8+,*R9          VDPWD preloaded   For CVBLOK
CINST5 MOV  *R8+,*R9+         For line table insert
 
*  Load time data and routines
*-----------------------------
*  Makseg,Unpacv, Box, Filclt, Sdfbbs
*  Mkrpts, Tabexp
 
LSTB   DATA LTABM2,LTABM4,LTABM8   Multifile line table ends
LLTB   DATA LTABL2,LTABL4,LTABL8   Multifile save lengths
 
* Initialize text buffer segment structure
*-----------------------------------------
* R0 loaded with bit-width of segment
* Preserve R0 for use by FNDSEG
* R1,R2 loaded with pointers for single or lower
 
MAKSEG DATA SEGWSP,MAKS00     BLWP vector
 
MAKS00 EQU  $
       MOV  R0,R1             Save value
       LI   R0,16             Initialize for V + E double size
       S    R1,R0             Construct shift count
       SETO R10               Initialize mask
       SRL  R10,0             Clear MSbits of mask for word index
       LI   R12,2             Word index
       SLA  R12,0             Construct max index in table
       MOV  R1,R0             For FNDSEG
       MOV  R3,R3             Is EVRAM absent ?
       JNE  INIS30            It is there OK
       SRL  R12,1             Absent - use lower half only
INIS30 MOV  R10,R1            Copy segment mask
       INC  R1                Make it the segment size in words
       MOV  R12,R2            Copy segment count (max 32 entries)
       DECT R2                Do only enough
       LI   R11,TXSEGS        Point at segment table area
       CLR  *R11              Start at first
INIS40 MOV  *R11+,*R11        Copy to next
       A    R1,*R11           Add segment size
       DECT R2                Count off
       JGT  INIS40            Not done
       CLR  R1                Set initial lowest segment
       MOV  R12,R2            Upper comparison limit
       MOV  R3,R6             Check buffer mode
       JLT  INIS99            Single large buffer
       JEQ  INIS99            Single small buffer
 
*  Construct 8-file limit table
 
       MOV  R12,R7            Copy all/seg max index limit
       SRL  R7,3              #x2 segments each in 8 file ring
       LI   R8,LIMTAB         Limit pair table
       LI   R9,8              Copy count + 1 for top comparison
       CLR  *R8               Should be CLRed in data
INIS50 MOV  *R8+,*R8          Each to next
       A    R7,*R8            Add # segments
       DEC  R9                Count
       JGT  INIS50            More
 
*  Contract predefined reference tables for 4- and 2-file
 
       SRL  R6,8                 Make word
       A    R6,R6                Word index  2,4,6  for 2/4/8
       MOV  @LSTB-2(R6),@LNTSAV  Line table start
       MOV  @LLTB-2(R6),@LNTLEN  Line table length
       LI   R8,LTSTOR            Load up table pointers
       LI   R9,LIMTAB           Limit pair table
       LI   R11,6              3 possibilities
       S    R6,R11            2,4,6 -> 0,2,4  for 8/4/2
       JEQ  INIS70            Leave alone if 8 file ring
INIS60 MOV  @>04(R8),@>02(R8) Shuffle line store table down
       MOV  @>08(R8),@>04(R8) 1 pass for quad
       MOV  @>0C(R8),@>06(R8) 2 for dual
       MOV  @>04(R9),@>02(R9) Shuffle segment limits down
       MOV  @>08(R9),@>04(R9)
       MOV  @>0C(R9),@>06(R9)
       MOV  @>10(R9),@>08(R9)
       MOV  @ENTCRF,R6        Adjust # files down
       SRL  R6,1              /2
       MOV  R6,@ENTCRF        Write back
       DECT R11               Count off
       JGT  INIS60            Another
INIS70 MOV  @>02(R9),R2       Load first file limit
INIS99 RTWP
 
*  Initial messages
*------------------
 
MSG26  TEXT '128K EV-RAM Vn 5.21 - W/P'
MSL26  EQU  $-MSG26
MS27A  EQU  $-3
MS27B  EQU  $-1
       EVEN
HTYPE  DATA 'WP'              Word aligned for SWPB
MS28A  BYTE 'P'
MS28B  BYTE 'E'
MSERA  TEXT '64 Kb '
MSDUAL TEXT '2x64K '
MSQUAD TEXT '4x32K '
MSOCTL TEXT '8x16K '
CFAILM TEXT 'Character File NOT Loaded'
CFAILE EQU  $
CFALM1 EQU  CFAILM-1
MS26M1 EQU  MSG26-1
NONAME TEXT 'noname'
 
*  Command advice entries
 
CTADVC TEXT 'DIR<1-9>'
       TEXT '<c-P>Dir'
       TEXT 'CURSOR -'
       TEXT '(f)<E/X>'
       TEXT ' <c~E/X>'
       TEXT 'FILES --'
       TEXT 'Mrk< ,T>'
       TEXT '<D>elete'
       TEXT '<Un>Prct'
       TEXT '<O>ldnms'
       TEXT '<V>iew  '
       TEXT ' by line'
       TEXT ' <X,c-X>'
       TEXT 'EXIT -- '
       TEXT ' <ctl =>'
CTADND EQU  $
 
*  Default TAB table data
*----------------------------------------
*  Primary format table  - Word processor
 
FRMWP  DATA 6,85
       BYTE 11,16,21,31,41,51,61,71
       BYTE 85,85,85,85,85,85,85,85
       DATA 6
 
*  Alternate Tab table  - Program editor
 
FRMPE  DATA 6,85
       BYTE 6,13,18,36,85,85,85,85
       BYTE 85,85,85,85,85,85,85,85
       DATA 6
 
*---------------
*  TAB line data
*---------------
 
INTGRS TEXT ' 123456789'
 
*  SD messages
 
FLHDRR TEXT ' Filename  Size  Type   Rec P'
WFILNM TEXT 'WF:'
TFILNM TEXT 'TF:'
BFILNM TEXT 'DP:'
SCUSAV TEXT 'Sectors Used ='
SCUSAW TEXT 'Free ='
FLCNTT TEXT 'Filecount    ='
PAGDSP TEXT 'Page         of'
BUFRMG TEXT 'Text size free : '
BUFRE# EQU  $-BUFRMG
LINSMG TEXT 'Lines now free : '
LINSE# EQU  $-LINSMG
EDWRMG TEXT 'Edit Ring file : '
EDWRE# EQU  $-EDWRMG
B81    BYTE 81
       EVEN
 
*  Screen pointers in first box
 
SDOTL  EQU  13+LLL
SDBOX  EQU  LLL+16       2*LLL+16
SDNAM  EQU  LLL+SDBOX+3
SDNUM  EQU  SDNAM+3
SDULN  EQU  LLL+SDNAM
SDRNM  EQU  LLL+SDULN
SUNAM  EQU  3*LLL+SDULN
SUNUM  EQU  SUNAM+15
SANAM  EQU  LLL+SUNAM+8
SANUM  EQU  SANAM+15-8
FLCOT  EQU  2*LLL+SANAM-8
FLCNR  EQU  FLCOT+15
PAGOF  EQU  LLL+FLCOT
PAGNA  EQU  PAGOF+10
PAGNB  EQU  PAGOF+18
BFREM  EQU  12*LLL+SDOTL+2
LNREM  EQU  BFREM+LLL
EDCLM  EQU  LNREM+LLL
SDWFM  EQU  18*LLL+2
SDWFN  EQU  SDWFM+4
SDTFM  EQU  19*LLL+2
SDTFN  EQU  SDTFM+4
SDBFM  EQU  20*LLL+2
SDBFN  EQU  SDBFM+4
 
EFRED  EQU  EDCLM+BUFRE#           For Ed ring #
BFRED  EQU  BFREM+BUFRE#           For buffer bytes free
LNRED  EQU  LNREM+LINSE#           For lines free
 
*  Screen pointers in filename box
 
FLBOX  EQU  45
FLHNM  EQU  1*LLL+FLBOX+3
FLHUL  EQU  2*LLL+FLBOX+3
FLSTT  EQU  4*LLL+FLBOX+2
FLHCM  EQU  10*LLL+FLSTT-4
FWMSG  EQU  25*LLL+FLBOX+8-3
FLEND  EQU  20*LLL+FLSTT
 
*  Screen pointers in key advice box
 
KABOX  EQU  0
KAMS1  EQU  1*LLL+2+KABOX
 
*  Message line pointers
 
MSLN1  EQU  23*LLL  19        Equates for screen positions
MSLN2  EQU  24*LLL  21        Info and error messages
 
*  Special char data
 
ACSR   DATA >2020,>5088,>8850,>2020
UDDAT  DATA >0000,>00FF,>0000,>0000
LOBDAT DATA >2070,>F8FF,>FF20,>2020
HIBDAT DATA >2050,>8888,>2020,>2020
 
*  Load marker characters into place
 
MKRPTS EQU  $
       BLWP *R9
       DATA >10F8             Edge chr to mid-underline
       DATA UDDAT,8
       BLWP *R9
       DATA >13F8             Normal marker at >7F
       DATA LOBDAT,8
       BLWP *R9
       DATA >17F8             Hi-bit marker at >FF
       DATA HIBDAT,8
       RT
 
*  Clear char-file load fail message
 
CLRCHF EQU  $
       LI   R1,CFAILM         Failure message
CLRCHG MOVB @DSPACE,*R1+      Blank it out
       CI   R1,CFAILE         Done ?
       JL   CLRCHG            Not yet
       RT
 
*  Squeeze tables
*---------------------
*  Colors on SD screen
 
BLCTAB DATA 4,>0004,>0700
WINTAB DATA 4,>FF05,>F000
 
*  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
FLHDRU DATA 18,>2D09,>2000,>2D03,>2000
       DATA >2D06,>2000,>2D02,>2000,>2D00
DSKNUL DATA 4,>2D09,>8108
 
*---------------------------------
*  Prepare SD screen for later use
*---------------------------------
 
SDFBBS EQU  $
       MOV  R11,R10
       LI   R0,>2020          Clear bottom half line
       BLWP *R8               VFILL
       DATA >820,>50          Last line
 
* Draw boxes
 
       LI   R6,BOX            Byte saaver
       BLWP *R6               @BOX
       DATA >0,>4E18          Whole screen
       BLWP *R6               @BOX
       DATA 17*LLL,>2B04      Message box
       BLWP *R6               @BOX
       DATA 22*LLL,>2B02      Message box
       BLWP *R6               @BOX
       DATA FLBOX,>2118       File display box
       BLWP *R6               @BOX
       DATA >0,>2B0F          Upper left KA/SD
       BLWP *R6               @BOX
       DATA 12,>1F0F          Central upper for SD
H0F    EQU  $-1
       BLWP *R6               @BOX
       DATA SDOTL,>1D09       Outliner
 
*  Fileblock headers for SD
 
       BLWP *R9               VMBWDF
       DATA FLHNM,FLHDRR,29   File header line
       LI   R0,FLHUL          VDP target
       BLWP @UNPACV           Expand it
       DATA FLHDRU            Data pointer
       BLWP *R9
       DATA FWMSG,MSG26,25    FW footer
 
*  Title block in upper left for SD
 
       LI   R0,SDULN
       BLWP @UNPACV
       DATA DSKNUL
       BLWP *R9
       DATA SDWFM,WFILNM,3
       BLWP *R9
       DATA SDTFM,TFILNM,3
       BLWP *R9
       DATA SDBFM,BFILNM,3
       BLWP *R9
       DATA SUNAM,SCUSAV,14
       BLWP *R9
       DATA SANAM,SCUSAW,6
       BLWP *R9
       DATA FLCOT,FLCNTT,14
       BLWP *R9
       DATA PAGOF,PAGDSP,15
       BLWP *R9
       DATA BFREM,BUFRMG,BUFRE#-1
       BLWP *R9
       DATA LNREM,LINSMG,LINSE#-1
 
*  Adjust display for dual buffer case
 
       MOV  @EVRAMF,R11
       JLT  CTKINF
       JEQ  CTKINF
       BLWP *R9
       DATA EDCLM,EDWRMG,BUFRE#-1
       BLWP *R9               Assume 2-file ring
       DATA FWMSG,MSDUAL,6
       CB   R11,@ONE          Check that
       JEQ  QUDAL             Fine, that's enough
       BLWP *R9               Write for 4-file ring
       DATA FWMSG,MSQUAD,6
       CB   R11,@TWO          Was that OK
       JEQ  QUDAL             Yes
       BLWP *R9               Must be 8-file ring then
       DATA FWMSG,MSOCTL,6
QUDAL  BLWP @VMBRF            Write back to load screen message
       DATA FWMSG,MSG26,6
 
*  Control key info for SD
 
CTKINF LI   R0,KAMS1          Point to data list
       LI   R1,CTADVC         VDP target
       LI   R2,8              8 chars each
CKINF0 BLWP @VMBWR            Write
       AI   R0,LLL            Next line
       A    R2,R1             Next entry
       CI   R1,CTADND         Done ?
       JL   CKINF0            No
       B    *R10
 
*  Fill SD color tables
*----------------------
 
FILCLT EQU  $
       CLR  R0                For primary color set
       BLWP *R8               VFill
       DATA COLTB3+>104,>A    Last line of SD screen
       BLWP *R8               VFill
       DATA COLTB4,>10E       Table for help screen
       BLWP *R8               VFill
       DATA COLTB5,>10E       Win/Info table
       SETO R0                For secondary color set
       BLWP *R8               VFill
       DATA COLTB1+>FA,>A     Tab line on edit screen
       BLWP *R8               VFill
       DATA COLTB2,>A         Top line on command screen
       BLWP *R8               VFill
       DATA COLTB2+>FA,>A     Tab line on command screen
       BLWP *R8               VFill
       DATA COLTB3,>104       SD page
       BLWP *R8               VFill
       DATA COLTB5,>A         Top line of box page
       BLWP *R8               VFill
       DATA COLTB5+>FA,>A     Tab line on box page
 
*  Instruction block to secondary color
 
       LI   R0,22*10+COLTB3   Address preset for write
SDC20  BLWP @UNPACV           Decompress data to VDP
       DATA BLCTAB
       AI   R0,10             Next line below
       CI   R0,26*10+COLTB3   Fill a block
       JL   SDC20
       LI   R0,4*10+1+COLTB5  Pop-up box coloring
SDC30  BLWP @UNPACV           Expand compressed data
       DATA WINTAB            Data pointer
       AI   R0,10             Next line of color table
       CI   R0,14*10+1+COLTB5 Done ?
       JL   SDC30             No
       RT
 
*  Expand tab lines in CPU buffer - write over following items
*-------------------------------------------------------------
 
TABEXP EQU  $
       MOV  @TEXT+MMTPT,R1    Get offset from index table
       AI   R1,TEXT+7         Correct to CPU RAM pointer
       MOV  R1,R3             Copy
       AI   R3,LLL            Construct end pointer
NXDECA LI   R2,INTGRS         Integer block
NXDECB MOVB *R2+,*R1+         Copy it
       CI   R2,INTGRS+10      Done ?
       JL   NXDECB            Not yet
       C    R1,R3             Whole line done ?
       JL   NXDECA            No
       LI   R0,>2000          For writing blanks
       MOVB R0,*R1+           Write in blanks
       MOVB R0,*R1+           Word align not guaranteed
       MOVB R0,*R1+
       LI   R2,NBLNM3         Bare tab line
NXDECC MOVB *R2+,*R1+         Write it in
       CI   R2,NBLEND         Done ?
       JL   NXDECC            No
       RT
 
*  Fast code to move to PAD
*--------------------------
*  Expand inline code
 
*  For fast screen paint
 
PAD01  MOVB *R10+,*R14        Will be replicated inline
       DEC  R9                R14 has VDPWD
       JGT  PAD01-38          Loop over 20 of them
       RT
       DATA >2020             Fast space data
 
*  For faster end to VMBW codes
 
PAD02  MOVB *R8+,@VDPWD
       DEC  R9
       JGT  PAD02
       RT
FCEND  EQU  $
 
*  Fast code to go in PAD for RS/FS
*----------------------------------
 
FFS24  MOV  R4,R10            Refresh R10 to position in the line
       MOV  R12,R9            Restart reference string
FFS30  C    R9,R8             End of string ?
       JEQ  FFS40             Yes - found a match
       C    R10,R6            No - end of text comparison limit ?
       JH   FFS50             Yes - go get next line
       MOVB *R9+,R14          Fetch comparison byte
       CB   R14,R13           Check for wildcard
       JNE  FFS35             No
       INC  R10               Step over text char then
       JMP  FFS30             Resume loop
 
FFS35  CB   R14,*R10+         Byte match ?
       JEQ  FFS30             Yes - check next one
FFS37  INC  R4                No, bump start of text string
       JMP  FFS24             Start comparison loop again
FFS40  INCT R11               Leave with match
FFS50  B    *R11              Back for next line
FFSLEN EQU  $-FFS24
 
*------------------------------------------------*
*  User/Language selection screen messages block *
*------------------------------------------------*
 
MSGFW  TEXT ' '
SLMS10 TEXT 'FUNNELWEB SYSTEM EDITOR '
SLML10 EQU  $-SLMS10
SLMS12 EQU  MSG26
SLML12 EQU  MSL26-6
 
SLMS15 TEXT 'Select Text Editor Mode'
SLML15 EQU  $-SLMS15
SLMS16 TEXT '1   1  Word Processing'
SLML16 EQU  $-SLMS16
SLMS17 TEXT '2  Program Editor'
SLML17 EQU  $-SLMS17
 
SLMS20 TEXT 'Select Text Buffer Model'
SLML20 EQU  $-SLMS20
SLMS18 TEXT '1   1  Single 128 Kb  '
SLML18 EQU  $-SLMS18
SLMS19 TEXT '2  Dual 64 Kb Ring'
SLML19 EQU  $-SLMS19
SLMS21 TEXT '3  Quad 32 Kb Ring'
SLML21 EQU  $-SLMS21
 
SLMS23 TEXT '1   1  Default 8-bit'
SLML23 EQU  $-SLMS23
SLMS25 TEXT '2  Select Language'
SLML25 EQU  $-SLMS25
SLMS26 TEXT '3  TI Euro-Writer'
SLML26 EQU  $-SLMS26
 
SLMS40 TEXT 'COMMANDS / '
       TEXT 'CHARACTER SET'
SLML40 EQU  $-SLMS40
 
SLMS41 TEXT '1   1  USA'
SLML41 EQU  $-SLMS41
SLMS42 TEXT '2  BRITAIN'
SLML42 EQU  $-SLMS42
SLMS43 TEXT '3  FRANCE'
SLML43 EQU  $-SLMS43
SLMS44 TEXT '4  DEUTSCHLAND'
SLML44 EQU  $-SLMS44
SLMS45 TEXT '5  ITALIA'
SLML45 EQU  $-SLMS45
SLMS46 TEXT '6  SVERIGE'
SLML46 EQU  $-SLMS46
SLMS47 TEXT '7  NEDERLAND'
SLML47 EQU  $-SLMS47
SLMS48 TEXT '8  ESPANA'
SLML48 EQU  $-SLMS48
 
ASCCA  TEXT 'A'
ASCCE  TEXT 'E'
THREE  BYTE >03               Comparison limit
       EVEN
 
*----------------------------
*  Details of language screen
*----------------------------
 
ECS1   EQU  LLL+1             Corner of UL box
ECS2   EQU  14*LLL+1          Corner of LL box
ECS3   EQU  LLL+40            Corner of R  box
WPC12  EQU  6*LLL+5+ECS1
WPC24  EQU  3*LLL+5+ECS2
WPC38  EQU  5*LLL+5+ECS3
 
WPEDSC EQU  $
       MOV  R11,R10
       LI   R0,ELDCON         Back to Funnelweb
       MOV  R0,@ESFLAG        Load <esc> pointer
       MOVB @LDTYPB,R0        Configured load type
       AB   @INTGRS+1,R0      Adjust for display
       MOVB R0,@SLMS23        Write as default
       MOVB @LNGTYP,R0        Configured language
       AB   @INTGRS+1,R0      Adjust
       MOVB R0,@SLMS41        Write as default
       LI   R0,>2000          Load with blanks
       BLWP *R8               VFILF
       DATA 0,>870            TM2 screen worth
       LI   R6,BOX            Byte saver
       BLWP *R6               @BOX
       DATA ECS1,>250B        Upper left box
       BLWP *R6               @BOX
       DATA ECS2,>250A        Lower left
       BLWP *R6               @BOX
       DATA ECS3,>2517        Right half
 
*  Write up W/P // P/E choice
 
BYT4   BLWP *R9               Cheap data byte
       DATA 3*LLL+1+WPC38
       DATA SLMS10,SLML10
       MOVB @UDLINE,R0
       BLWP *R8
       DATA 5*LLL+1+WPC38,SLML10
       BLWP *R9
       DATA 8*LLL+2+WPC38
       DATA SLMS12,SLML12
       BLWP *R9
       DATA 3*LLL+5+ECS1
       DATA SLMS15,SLML15
       BLWP *R8
       DATA 4*LLL+5+ECS1,SLML15
       BLWP *R9
       DATA WPC12
       DATA SLMS16,SLML16
       BLWP *R9
       DATA 2*LLL+4+WPC12
       DATA SLMS17,SLML17
       BL   @SETVR1           Turn screen on again
       DATA >7081
       BL   @WENUMS           Get 1/2 choice as 0/1 byte
       DATA WPC12,>0100
       CLR  R4                Flag Wd/Pc then
       SRL  R1,8              Choice as 0/1 word
       S    R1,R4             Make CLR (W/P) or SETO (P/E)
       LI   R11,WPEDCH        Back to first screen
       MOV  R11,@ESFLAG       Load <esc> pointer
 
*  Single / Dual /Quad /Octet buffer choice
 
SIDUCH MOV  @EVRAMF,R2        Check EVRAM presence
       JEQ  NTL78C            None so skip single /dual
       BLWP *R9               Single/Dual/Quad choice
       DATA 3*LLL+5+ECS1      Over-write previous
       DATA SLMS20,SLML20
       BLWP *R8
       DATA 4*LLL+5+ECS1,SLML20
       BLWP *R9
       DATA WPC12
       DATA SLMS18,SLML18
       BLWP *R9
       DATA 2*LLL+4+WPC12
       DATA SLMS19,SLML19
       BLWP *R9
       DATA 4*LLL+4+WPC12
       DATA SLMS21,SLML21
       BL   @WENUMS           1/2/3/4 choice -> 0/1/2/3 byte
       DATA WPC12,>0300
       LI   R3,>FF00          Assume single buffer
       MOVB R1,R1             Check choice
       JEQ  SIDUCK            Was single 128 kb
       AB   R1,R3             Make 0/1/2 byte
       AB   @ONE,R3           Make 1/2/3 byte
SIDUCK MOV  R3,@EVRAMF        Rewrite flag
 
*  Choices for 7 or 8 bit
 
NTL78C EQU  $
       SB   @LNGTYP,@LNGTYP   Initialize in case no entry
       LI   R0,WPEDCH         Back to first screen
       MOV  R0,@ESFLAG        Load <esc> pointer
       BLWP *R9
       DATA WPC24
       DATA SLMS23,SLML23     Default
       BLWP *R9
       DATA 2*LLL+WPC24+4
       DATA SLMS25,SLML25     All-Chars
       BLWP *R9
       DATA 4*LLL+WPC24+4
       DATA SLMS26,SLML26     TI EW
CH78C1 BL   @WENUMS
       DATA WPC24,>0300
       MOVB R1,@LDTYPB        Set up LoaDTYPeByte
       JEQ  NATLEX
       BLWP *R6               @BOX
       DATA ECS3,>2517        Right half
 
*  Set national language choice
 
       BLWP *R9               Header
       DATA 2*LLL+5+ECS3
       DATA SLMS40,SLML40
       MOVB @UDLINE,R0        Underline
       BLWP *R8
       DATA 3*LLL+5+ECS3,SLML40
       BLWP *R9
       DATA WPC38
       DATA SLMS41,SLML41     Base Mode
       BLWP *R9
       DATA 2*LLL+4+WPC38
       DATA SLMS42,SLML42     Britain
       BLWP *R9
       DATA 4*LLL+4+WPC38
       DATA SLMS43,SLML43     France
       BLWP *R9
       DATA 6*LLL+4+WPC38
       DATA SLMS44,SLML44     Germany
       BLWP *R9
       DATA 8*LLL+4+WPC38
       DATA SLMS45,SLML45     Italy
       BLWP *R9
       DATA 10*LLL+4+WPC38
       DATA SLMS46,SLML46     Sweden
       BLWP *R9
       DATA 12*LLL+4+WPC38
       DATA SLMS47,SLML47     Holland
       BLWP *R9
       DATA 14*LLL+4+WPC38
       DATA SLMS48,SLML48     Spain
 
*  Select 1 to 8 in RH box
 
SEL128 BL   @WENUMS
       DATA WPC38,>0800
       MOVB R1,@LNGTYP        Save as language type
NATLEX B    *R10
 
*  Make 1/2 choice in first box
 
WENUMS MOV  *R11+,@WPDC20
       MOV  *R11+,R5
WPDC10 BLWP @FILENT           Wait for response
WPDC20 DATA WPC12,1
       MOVB @FLNBFF,R1        Fetch return
       SB   @INTGRS+1,R1      Is it < "1" ?
       JLT  WPDC10            No
       CB   R1,R5             Is it > "upper"
       JH   WPDC10            No - loop on it
       RT
 
*  Fix up PABdata for char and text file loads
*---------------------------------------------
 
FIXPBS EQU  $
       LI   R10,NAMBUF        FW name buffer
       LI   R1,PABCHN         PAB data at length byte
       LI   R2,PABFWN         For textfile name also
       LI   R3,PABHLN         Help file
       MOVB *R10,R0           Fetch it - includes 2 letter filename
       SRL  R0,8              Make index
       DEC  R0                Includes len byte and "."
       AB   @BYT4,*R10        Adjust for 6 char filename
CFT10  MOVB *R10,*R1+
       MOVB *R10,*R2+         Transfer pathname
       MOVB *R10+,*R3+
       DEC  R0
       JGT  CFT10
       LI   R0,6              Move filenames into place
       LI   R5,CHRFLD         Charfile name pointer
       LI   R12,FWTFLD        Command text
       LI   R7,HLPFLD         Helpfile
CFT20  MOVB *R5+,*R1+
       MOVB *R12+,*R2+        Shift along
       MOVB *R7+,*R3+
       DEC  R0
       JGT  CFT20
       DEC  R1                Back off to CHAR@<1>
       DECT R2                Back off to F8TX<A>E
       RT
 
*  Load routine for char and text files
*--------------------------------------
 
LOADCT EQU  $
       LI   R0,VDPPAB+9       Length byte pointer
       MOV  R0,@SCNAME        Load for DSR
       SB   @GPLST,@GPLST     Just in case
       BLWP @TWDSLK           Call DSR
       DATA 8                 File type
       JEQ  BADLD             Not found
       BLWP @VSBRF            Fetch error byte
       DATA VDPPAB+1          Byte 1 of PAB
       SRL  R0,13             Isolate error flags
       JNE  BADLD             Something is wrong
       MOVB @GPLST,R0         Could still be bad device name
       SLA  R0,3              Check COND bit
       JOC  BADLD             No good if set
       INCT R11               Step over error branch
BADLD  RT
 
*  CTBL & COMTBL extended to give room for Vn 2.0
*------------------------------------------------
*  CMTL =  >76+4
 
*  Key code table for control keys >80 - >98
*-------------------------------------------
 
CTBL   EQU  $                 Control keys -key-unit 5
HBKEYE DATA HIBIT             (80) c-,  High-bit chrs in AllChar mode
       DATA ROLLUP            (81) c-A  Roll up
       DATA INSCH1            (82) c-B  Roll down - now SPLIT  only
       DATA COMAND            (83) c-c  Command mode
       DATA RGTAR             (84) c-D  Right ->
       DATA UPAR              (85) c-E  Up arrow
       DATA FREEZE            (86) c-F  Freeze lower screen
       DATA INSCHR            (87) c-G  Insert character
       DATA HOMFIL            (88) c-H  Start of file
       DATA TABF              (89) c-I  Tab
       DATA ENDFIL            (8A) c-J  End of file
       DATA CTOEOL            (8B) c-K  Clear to end of line
       DATA HOMCSR            (8C) c-L  Home cursor
FCTINS DATA INDENT or PRETTY  (8D) c-M  <cr> & Goto Indent
       DATA INSERT            (8E) c-N  Insert line
       DATA GO2ORG            (8F) c-O  Back where we were
       DATA PAGE              (90) c-P  Page feed char
       DATA ROLDWN            (91) c-Q  Page up
       DATA RMADJ             (92) c-R  Right -->
       DATA LFTAR             (93) c-S  Left  -->
       DATA BTAB              (94) c-T  Back tab
       DATA CMODE             (95) c-U  Control char mode
       DATA GOTO1             (96) c-V  Goto col 1
       DATA TABWD             (97) c-W  Word tab
       DATA DWNAR             (98) c-X  Down arrow
       DATA MRREL             (99) c-Y  Release margins
       DATA GO2END            (9A) c-Z  Tab across
       DATA DNCAS             (9B) c-.  Downcase
       DATA UPCAS             (9C) c-;  Upcase
       DATA PLAINT            (9D) c-=  Restore plain ruler line
       DATA INDENT            (9E) c-8  New paragraph
       DATA PAGE              (9F) c-9  New page
CTBLND EQU  $
 
CTBL2  EQU  $                 Control keys.
       DATA WORDW             (B0) c-0  Word wrap mode
       DATA OOPS              (B1) c-1  Oops key
FCTDEL DATA REFRMT or PREDEL  (B2) c-2  Reformat or del blanks
       DATA COLORC            (B3) c-3  Change color
       DATA NEXTP             (B4) c-4  Find next paragraph
       DATA DUPLIC            (B5) c-5  Duplicate previous line
       DATA LASTP             (B6) c-6  Find last paragraph
       DATA TABWD             (B7) c-7  Tab to next word
 
*  Vowel modifier keys (Eu/Wr
 
VWLCOM DATA START             (B8) f-,  Circumflex
       DATA START             (B9) f-.  Umlaut
       DATA START             (BA) f-/  Grave
       DATA START             (BB) c-/  Acute
       DATA LMODE             (BC) f-0  Line # toggle
       DATA MARKIT            (BD) f-;  Line marker
BTBL   EQU  $-2
CTBL2L EQU  $
 
*  KeyCode table for function keys >00->0F
 
       DATA TABF              (01) f-7  Tab forward
       DATA ROLLUP            (02) f-4  Scroll up page
       DATA DELCHR            (03) f-1  Delete char
       DATA INSCHR            (04) f-2  Insert mode set
       DATA GO2MRK            (05) f-=  Go to marked line
       DATA INSERT            (06) f-8  Insert blank line
       DATA DELLIN            (07) f-3  Delete current line
       DATA LFTAR             (08) f-S  Cursor left
       DATA RGTAR             (09) f-D  Cursor right
       DATA DWNAR             (0A) f-X  Cursor down
       DATA UPAR              (0B) f-E  Cursor up
       DATA ROLDWN            (0C) f-6  Scroll down page
       DATA ENTKEY            (0D) Ent  Start next line
       DATA NXTSCN            (0E) f-5  Window across
       DATA COMAND            (0F) f-9  Command mode
BTBLND EQU  $
 
*----------------------------------------------------*
*  Command mode key table to be downloaded from VDP  *
*----------------------------------------------------*
 
COMTBL EQU  $
HBKEYC DATA HIBIT             (80) c-,  Set hi-bit chars
       DATA CMRLUP            (81) c-A  Scroll text up
       DATA START             (82) c-B  No effect
       DATA COMAND            (83) c-C  Command line
       DATA RGTAR             (84) c-D  Right cursor
       DATA CUPAR             (85) c-E  Ignore
       DATA DELCHR            (86) c-F  Delete char (original usage still)
       DATA INSC40            (87) c-G  Insert character
       DATA START             (88) c-H  Ignore
       DATA TABF              (89) c-I  Tab
       DATA START             (8A) c-J  Ignore
       DATA CTOEOL            (8B) c-K  Clear to end of line
       DATA START             (8C) c-L  Ignore
       DATA MARKLN            (8D) c-M  Mark line #
       DATA TOGLNP            (8E) c-N  NTSC/PAl toggle
       DATA START             (8F) c-O  Ignore
       DATA CHR0C             (90) c-P  New Page code
       DATA CMRLDN            (91) c-Q  Scroll text down a line
       DATA START             (92) c-R  Ignore
       DATA LFTAR             (93  c-S  Left cursor
       DATA BTAB              (94) c-T  Back Tab
       DATA CMODE             (95) c-U  Control key mode
       DATA GOTO1             (96) c-V  Goto column one
       DATA TABWD             (97) c-W  Tab right by word
       DATA CDNAR             (98) c-X  Scroll text up a line
       DATA START             (99) c-Y  Ignore
       DATA GO2END            (9A) c-Z  Nop
       DATA DNCAS             (9B) c-.  Down-case
       DATA UPCAS             (9C) c-;  Up-case
       DATA PLAINT            (9D) c-=  Clean ruler line
       DATA CHR0A             (9E) c-8  New Para
       DATA CHR0C             (9F) c-9  New Page
 
COMTND EQU  $
       DATA WORDW             (B0) c-0  Mode toggle
       DATA CTOPL             (B1) c-1  Also - to current top of page
       DATA CMDXIT            (B2) c-2  Leave Command mode
       DATA COLORC            (B3) c-3  Color change
       DATA TOGBCL            (B4) c-4  Back color change
       DATA TOGLBL            (B5) c-5  Toggle tabline
       DATA TOGLIL            (B6) c-6  Toggle interlace
       DATA TABWD             (B7) c-7  Tab by word
 
*  Vowel modifier keys (Eu/Wr
 
VWLCMD DATA START             (B8) f-,  Circumflex
       DATA START             (B9) f-.  Umlaut
       DATA START             (BA) f-/  Grave
       DATA START             (BB) c-/  Acute
       DATA START             (BC) f-0  Ignore
       DATA START             (BD) f-;  Ignore
 
*  Key code table for function keys 0->F
 
       DATA TABF              (01) f-7  Tab forward
       DATA CMRLUP            (02) f-4  Scroll text up a page
       DATA DELCHR            (03) f-1  Delete char
       DATA INSC40            (04) f-2  Insert mode on
       DATA START             (05) f-=  Ignore
       DATA START             (06) f-8  Ignore
       DATA START             (07) f-3  Ignore
       DATA LFTAR             (08) f-S  Cursor left
       DATA RGTAR             (09) f-D  Cursor right
       DATA CDNAR             (0A) f-X  Text up a line
       DATA CUPAR             (0B) f-E  Text down a line
       DATA CMRLDN            (0C) f-6  Scroll text down a page
       DATA ENTKEY            (0D) Ent  Command/return edit
       DATA NXTSCN            (0E) f-5  Window across
       DATA COMAND            (0F) f-9  Restart command mode
COMTL  EQU  $-COMTBL
 
TABLEN EQU  $-CTBL
 
 
*  Text for Command Mode headlines
*  Response tables, RS verify msg
*-----------------------------------------
*  Expands TAB assist in CPU after loading
 
*  Message pointer table offsets
*-----------------------------------------
*  Referred to by EQUates in main program
*  Assume same order as here - DO NOT ALTER
 
 
TEXT   EQU  $
 
*  Pointer table to VDP address offsets of data items
 
       DATA '52'              Version #
       DATA TXTVDL            Text length to VDP
       DATA MODE              Edit...
       DATA MSV               Save File
       DATA MLF               Load File
       DATA MPF               Print file
       DATA MLT               Load temp
       DATA MST               Save temp
       DATA MDP               SDir print
       DATA MQE               Quit
       DATA MODF              LF,...
       DATA MODL              Move,..
       DATA MODS              Find,Repl
       DATA MFS               Find
       DATA MRS               Replace
       DATA MML               Move
       DATA MCL               Copy
       DATA MSL               Show
       DATA MDL               Delete
       DATA MPG               Purge
       DATA IOER              IO error
       DATA TBF               TB full
       DATA MTS               Tab select
       DATA EML               Marker set
       DATA MMT               Tabs
       DATA CMLLT             Command line entries & responses
       DATA RSMS              RS verify
       DATA HPT               Hard path name
       DATA WLD               Wildcard entry
       DATA PST               Paste
       DATA EDT               Edit ring
       DATA PLW               Please wait
 
*  Text messages
*---------------
*  All messages must be 80 chr or less
*            -  preferably 74 at most
 
MODEX  BYTE  MODEL
       TEXT 'Edit,'
       TEXT 'Files,Lines,SearcH,'
       TEXT 'Tabs,View,Help,'
       TEXT 'COpy,PAste,'
       TEXT 'Quit:'
MODEL  EQU  $-MODEX-1
MODE   EQU  MODEX-TEXT
 
MSVX   BYTE MSVL
       TEXT 'SAVE FILE, enter filename:'          SF
MSVL   EQU  $-MSVX-1
MSV    EQU  MSVX-TEXT
 
MLFX   BYTE MLFL
       TEXT 'LOAD FILE, enter filename:'          LF
MLFL   EQU  $-MLFX-1
MLF    EQU  MLFX-TEXT
 
MPFX   BYTE  MPFL
       TEXT 'PRINT FILE, enter devicename:'       PF
MPFL   EQU  $-MPFX-1
MPF    EQU  MPFX-TEXT
 
MLTX   BYTE MLTL
       TEXT 'LOAD TEMP, filename:'      LT
MLTL   EQU  $-MLTX-1
MLT    EQU  MLTX-TEXT
 
MSTX   BYTE MSTL
       TEXT 'SAVE TEMP, filename:'      LT
MSTL   EQU  $-MSTX-1
MST    EQU  MSTX-TEXT
 
MDPX   BYTE  MDPL
       TEXT 'SD Printer, enter devicename:'       DP
MDPL   EQU  $-MDPX-1
MDP    EQU  MDPX-TEXT
 
MQEX   BYTE MQEL
       TEXT 'QUIT, enter Purge or Exit:'          Q
MQEL   EQU  $-MQEX-1
MQE    EQU  MQEX-TEXT
 
MODFX  BYTE MODFL
       TEXT 'LoadF,SaveF,PrintF,'                 F
       TEXT 'LTemp,STemp,'
       TEXT 'ShowDir,'
       TEXT 'HardDisk,'
       TEXT 'sDPrinter,'
       TEXT 'Purge:'
MODFL  EQU  $-MODFX-1
MODF   EQU  MODFX-TEXT
 
HPTX   BYTE HPTL
       TEXT 'HARD-DISK, enter path:'
HPTL   EQU  $-HPTX-1
HPT    EQU  HPTX-TEXT
 
MODLX  BYTE MODLL
       TEXT 'Move,Copy,Delete,Show,'              L
       TEXT 'MarK lines:'
MODLL  EQU  $-MODLX-1
MODL   EQU  MODLX-TEXT
 
MODSX  BYTE MODSL
       TEXT 'FindString,ReplaceString,'        SH
       TEXT 'WildCard:'
MODSL  EQU  $-MODSX-1
MODS   EQU  MODSX-TEXT
 
MFSX   BYTE MFSL
       TEXT 'FIND, enter /string/:'               FS
MFSL   EQU  $-MFSX-1
MFS    EQU  MFSX-TEXT
 
MRSX   BYTE MRSL
       TEXT 'REPLACE, enter '                      RS
       TEXT '/old string/new string/:'
MRSL   EQU  $-MRSX-1
MRS    EQU  MRSX-TEXT
 
MMLX   BYTE MMLL
       TEXT 'MOVE, start line, '                   M
       TEXT 'stop line, after line:'
MMLL   EQU  $-MMLX-1
MML    EQU  MMLX-TEXT
 
MCLX   BYTE MCLL
       TEXT 'COPY, start line, '                   C
       TEXT 'stop line, after line:'
MCLL   EQU  $-MCLX-1
MCL    EQU  MCLX-TEXT
 
MSLX   BYTE MSLL
       TEXT 'SHOW, enter line number:'             S
MSLL   EQU  $-MSLX-1
MSL    EQU  MSLX-TEXT
 
MDLX   BYTE MDLL
       TEXT 'DELETE, enter start line, stop line:' D
MDLL   EQU  $-MDLX-1
MDL    EQU  MDLX-TEXT
 
MPGX   BYTE MPGL
       TEXT 'SaveFile first (No or Yes)?'
MPGL   EQU  $-MPGX-1
MPG    EQU  MPGX-TEXT
 
IOERX  BYTE IOERL
       TEXT 'IO ERROR CODE = '
IOERL  EQU  $-IOERX-1
IOER   EQU  IOERX-TEXT
 
TBFX   BYTE TBFLN
TBF1   TEXT 'TEXT BUFFER FULL'
       TEXT ', save or purge!'
TBFLN  EQU  $-TBF1
TBF    EQU  TBFX-TEXT
 
MTSX   BYTE MTSLL
       TEXT 'TABSET (1-9)?'
MTSLL  EQU  $-MTSX-1
MTS    EQU  MTSX-TEXT
 
EMLX   BYTE EMLL
       TEXT 'MARK, enter line number:'
EMLL   EQU  $-EMLX-1
EML    EQU  EMLX-TEXT
 
WLDX   BYTE WLDL
       TEXT 'Enter Wildcard:'
WLDL   EQU  $-WLDX-1
WLD    EQU  WLDX-TEXT
 
PSTX   BYTE PSTL
       TEXT 'Paste after line:'
PSTL   EQU  $-PSTX-1
PST    EQU  PSTX-TEXT
 
EDRX   BYTE EDRL
       TEXT 'Ring File:'
EDRL   EQU  $-EDRX-1
EDT    EQU  EDRX-TEXT
 
PLWX   BYTE PLWL
       TEXT 'Please wait'
PLWL   EQU  $-PLWX-1
PLW    EQU  PLWX-TEXT
 
*  This entry must be the last text entry
*-----------------------------------------------------------
*  After reading subsequent data, the program
*  expands this data out in CPU RAM.
*  Actual length loaded to VDP includes this expanded length
 
MMTX   BYTE >AC
       TEXT ' TABS  '         7 bytes only
MMT    EQU  MMTX-TEXT
 
TXTVDL EQU  $+>AC-TEXT
       EVEN
 
*  Command line 2 char entries
*----------------------------------------------
*  Each entry must have a unique 2 letter command
*  No length byte here
 
CMLCDS EQU  $
CMLLT  EQU  CMLCDS-TEXT
       TEXT 'SF'              Save File
       TEXT 'LF'              Load File
       TEXT 'PF'              Print File
       TEXT 'LT'              Load Temp
       TEXT 'ST'              Save Temp
       TEXT 'DP'              Dir Printer device
       TEXT 'SD'              Show directory
       TEXT 'P '              Purge               <P>urge
       TEXT 'E '              Edit
       TEXT 'F '              Files
       TEXT 'L '              Lines
       TEXT 'SH'              SearcH
       TEXT 'T '              Tabs                <T>ab
       TEXT 'Q '              Quit
       TEXT 'QQ'              Quit Immediate
       TEXT 'FS'              Find String
       TEXT 'RS'              Replace String
       TEXT 'M '              Move
       TEXT 'C '              Copy
       TEXT 'S '              Show
       TEXT 'D '              Delete
       TEXT 'MK'              MarK
       TEXT 'CO'              Copy  text
       TEXT 'PA'              Paste text
       TEXT 'H '              Help
       TEXT 'V '              View
       TEXT 'HD'              HardDisk path
       TEXT 'WC'              Wildcard
 
*  Response table used for various entries
*-----------------------------------------
 
       TEXT 'Y'               <Y>es
       TEXT 'N'               <N>o
       TEXT 'E'               <E>xit
       TEXT 'A'               <A>ll
       TEXT 'S'               <S>top
       TEXT 'I'               <I>ndent
       TEXT 'L'               <L>eft
       TEXT 'R'               <R>ight
       TEXT 'EoF'             3 chars only  <E>nd
 
*  Special message for RS continuation
*-------------------------------------
 
RSMSX  BYTE RSLEN
       TEXT 'REPLACE STRING ('
       TEXT 'Yes,No,All,Stop)'
       TEXT '? '
RSLEN  EQU  $-RSMSX-1
RSMS   EQU  RSMSX-TEXT
       EVEN
 
TXTLEN EQU  $-TEXT
 
*---------------------------------------
 
