 
*  EE2/ENTHI     40 col       Jul / 16 / 93
*----------------------
*  All Chars / All Mode
 
*-------------------------------------------*
*  Entry routine at end of existing EDITOR  *
*-------------------------------------------*
 
*  Setup return code in SD
 
HIBUF  EQU  $
       C    R11,@LDR11        Is it a FW load ?
       JEQ  FROMFW            Yes
       LWPI SCNWS             Make sure no conflict
       BL   @HONK             Sound off
       BLWP @>0               Return to title screen
 
FROMFW LWPI FWREG             Use FW Regs for now
       BL   @SETVR1           VWTR + pad load
       DATA >B081             TM1 screen off
       BL   @FWCLS            Clear screen
       MOV  @>0CFC,R11        ROM table #2 pointer
       MOV  @4(R11),@CFIAD    Write CFI routine pointer to code
       SOCB @MASK10,@>83C2    Set flag bit to turn off Quit
       MOV  @CPUDEL,@DELVAL   Set sound/delay duration
       SLA  R13,3             Flag Editors for FW
 
*  Construct FW reloader path
 
       MOV  @BTLN,R1          Boot pathname
       MOVB *R1,R0            Fetch length byte
       SRL  R0,8              Make count
       DEC  R0                Allow for byte & 2 letter filename
       LI   R2,RLDNAM         Reload PAB pathname
FRFW10 MOVB *R1+,*R2+         Copy over
       DEC  R0                Count
       JGT  FRFW10
 
*  Save HDFLAG/RDISK and parameters initialized by FW/LOAD
 
       LI   R11,HDREL         Point to block of saved data
       MOV  @HDFLAG,*R11+     Collect FW hard path flag
       MOV  @RDISK,*R11+      Collect boot drive #s
       MOV  @MODFL,*R11+      Module XML
       MOV  @GRMAD,*R11+      GROM return address
       MOV  @REPETS,*R11+     Key-loop timing
       MOV  @CPUDEL,*R11+     CPU delay timing
       MOV  R4,*R11+          Load side flag
       MOV  R2,*R11           Also pointer after reload path
 
       LI   R0,'FW'           FW reload name
       MOVB R0,*R2+           R2 points after path for 'F'
       SWPB R0                'W' to fore
       MOVB R0,*R2            Write it in too
 
*  Get load type as installed
 
       MOVB @LDTYPB,R10       Copy load types
       MOVB @LNGTYP,R11       Copy language types
       MOV  R4,R4             Check implicit load setting
       JNE  NTR10             Pr/Ed
 
       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
       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
 
*  Start on
 
       MOV  @INCOL,@COLCH     Fetch FW 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
 
*  Move fast code to PAD
 
       LI   R1,PAD01          Data in program header
       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
 
       MOVB @HELPLD,@HPMAX
       LI   R1,PCENTY         Point to 2 byte block
       MOVB *R1+,@PCCENT      Printer entry control
       MOVB *R1,@PCCEXT       Printer exit control
       BLWP *R9
       DATA PCEBUV
       DATA PCEDAT,48         Entry/Exit codes to storage
       MOVB @TABSPC,R11       Fetch TAB spec byte
       ANDI R11,>0100         Isolate the relevant bit
       MOV  R11,@TABTYP       Null is USA tabs
       BL   @CLRCHH           Set underline
 
*  Check for Select screen
 
       MOVB @LDIMM,R11        Check user config also
       JNE  WPEDCH
 
       BLWP @KSCANF           Do a keyscan
       CB   @KEYRT,@DSPACE    Check return for space-bar
       JNE  NOQUIT            No - bypass selection screen
 
*  Editor / Language selection
 
WPEDCH LWPI FWREG             In case of <esc> to here
       BL   @SETVR1           Turn screen on for data entry
       DATA >F081
       BL   @WPEDSC           Set up edit choice screen
       BL   @SETVR1           Turn screen off again
       DATA >B081
 
*  Load character and language files
*-----------------------------------
 
NOQUIT BL   @FIXPBS           Set up PABs
       MOVB @LDTYPB,R15       Fetch load type byte  0-3
       MOVB @LNGTYP,R14       Fetch language byte   0-8
       SRL  R15,8             Make index
       MOV  R15,R5            Copy for use and test
       JNE  NOSLCU            Not the default
 
       BL   @CLRCHF           No question of not found
       JMP  USABUF            Skip text load also
 
NOSLCU DECT R5                Test next
       JNE  NATL7             Not All/Char
 
NATL8  INC  R1                Point to CHAR@<1> for A/C
NATL7  AB   R14,*R1           Adjust command text
       AB   R14,*R2           Adjust character file
 
*  Load character file
 
       BLWP *R9               PAB data to VDP
       DATA VDPPAB
       DATA PABCHD,>20
       BL   @LOADCT           Program file loader
       JMP  NOCHRF            Char file not found
       BL   @CLRCHF           Found - clear warning
 
*  Load command text file
 
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  USABUF            FAIL - results will be obvious
       BLWP @VMBRF            Copy over program default
       DATA CATBF             Not being used yet
       DATA TEXT,>400         Some length to spare
 
*  Eurowriter specfic code
*-------------------------
 
EUWFIX EQU  $
       DEC  R15               A 7-bit mode ?
       JGT  EUWF30            No  - leave default code in place
 
*  Write in Squish/Unsquish for USA default
 
USABUF CLR  @EUROWR           Clear special tab flag
       LI   R1,USASQL
EUWF10 MOV  @USASQU-2(R1),@SQUOVR-2(R1)
       DECT R1
       JGT  EUWF10
 
       LI   R1,USAUNL
EUWF20 MOV  @USAUNS-2(R1),@UNSOVR-2(R1)
       DECT R1
       JGT  EUWF20
       CLR  R0
       BLWP *R8               VFILL
       DATA >0C00,>3F8        Clear hi-bit patterns
       JMP  RSMSCL            No vowel modifier here
 
*  Write in vowel modifier keys for E/W
 
EUWF30 DEC  R15               All/Chars mode ?
       JEQ  EUWF50            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+>0800
       DATA 8*>58
       JMP  RSMSCL            No hi-bit direct entry now
 
*  Write in Hi-bit permission
 
EUWF50 LI   R0,HIBIT          Set hi-bit entry pointer
       MOV  R0,@HBKEYE        Write into command tables
       MOV  R0,@HBKEYC
 
*  Continue assuming text loaded
*-------------------------------
*  Clean storage buffers also
*  Get VDP set and clean up mailbox
 
RSMSCL MOV  @FILCLN,R11       Cleanup routine pointer
       CLR  R0                Turn off EDBUF load
       BL   *R11              Execute it
       MOV  @CFILE#,R11       Fetch routine entry
       BL   *R11
       DATA >0100             Only 1 needed at a time
       LI   R0,>2020
       BLWP *R8
       DATA RSMSV,LOCLRV-RSMSV
       BLWP *R8
       DATA HDPBUV,>50
 
*  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  PEMODS
 
USEUTL MOV  @BTLN,R0          Put FW Util pathname instead
       AI   R0,BL2UT          Offset to Util pathname
       BLWP @VSTRWF           Use FW string write
       DATA HDPBUV
       MOVB @DSPACE,@VDPWD    Make sure of following space
 
*  Save command and switch tables in VDP
*  Switch tabs and screen message
*--------------------------------
 
PEMODS LI   R2,FRMWP
       MOV  R4,R4             Need to change <fctn-2> entry ?
       JEQ  WCTABL            No
 
       LI   R2,FRMPE          Adjust TAb table source pointer
       MOVB @MS28A,@MS27A
       MOVB @MS28B,@MS27B
       SZCB @H0F,@NOTABS      Make the JNE a JMP
       LI   R10,REFR05        ASM code block real position
       AI   R10,PRETTY        Offset to aligned insert
       MOV  R10,@FCTINS       Write to command table  <c-M>
       AI   R10,PRDOF1        Offset to aligned insert
       MOV  R10,@FCTDEL       Write to command table  <c-2>
       AI   R10,PRDOF2        Offset to aligned insert
       MOV  R10,@PRTB10+2     Write to code block for BL @xxxx
       MOV  R10,@PRTB20+2     Write to code block
WCTABL BLWP *R9               VMBWF
       DATA COMVE             VDP storage
       DATA CTBL,TABLEN       Consecutive tables
       LI   R0,22             Size of Tab table
       LI   R1,FORMO          Target address in hi-mem
PETAB  MOV  *R2+,*R1+
       DECT R0
       JGT  PETAB
 
*  Write in new commands
 
       MOV  @TEXT+CMLPT,R1    Point into offset table
       AI   R1,TEXT           Construct memory pointer
       LI   R0,CMDTBL
NXCOMD MOV  *R1+,*R0
       AI   R0,CMDTE
       CI   R0,CMDTND
       JL   NXCOMD
 
       MOV  *R1+,*R0+         8 byte entries on word bdy
       MOV  *R1+,*R0+
       MOV  *R1+,*R0+
       MOV  *R1+,*R0
       LI   R0,EOFLIN         For EoF indicator
       MOV  *R1+,*R0+
       MOVB *R1,*R0
 
*  Set up RS Verify message in VDP first
 
RSVWRI 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
 
*  Expand tab lines in CPU buffer - write over following items
 
       MOV  @TEXT+MMTPT,R1    Get offset from index table
       AI   R1,TEXT+7         Correct to CPU RAM pointer
       MOV  R1,R11            Copy
       AI   R11,80            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,R11            Whole line done ?
       JL   NXDECA            No
 
       LI   R0,>2000          For writing spaces
       MOVB R0,*R1+           Write in blanks
       MOVB R0,*R1+           Word align not guaranteed
       MOVB R0,*R1+
 
       LI   R2,NBLNM3        More blanks and bare tab line
NXDECC MOVB *R2+,*R1+
       CI   R2,NBLEND
       JL   NXDECC
 
*  Text messages to VDP
 
       MOV  @TEXT+TXTRAN,@TXTRNL
       BLWP *R9
       DATA TEXTV
       DATA TEXT
TXTRNL DATA >0
 
*  L/S module to VDP storage
 
       BLWP *R9               Store printer codes
       DATA PCEBUV
       DATA PCEDAT,48         Include DSKBUV
       BLWP *R9               Write block to VDP
       DATA LSMODV
       DATA OVRLAY,LSLEN
 
*  Stash SD code, initialize SD screen & make cursor
 
       BLWP *R9
       DATA SDATV             SD code to VDP
       DATA SDATA,SDLEN
       BL   @ISDSCR           Set up SD screen
       BLWP @VMBRF            Set cursor pattern
       DATA FCSRP,FCSR,8
 
 
*  Change to TI-Wr Edit workspace
*  Clear out command table area
*------------------------------------------
*  All data must have been retrieved by now
 
       LWPI SCNWS             Can't use FWREG
       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
       MOV  R10,@LINT42       Line 21
       AI   R10,86            Underline
       MOV  R10,@LINT44       Line 22
       AI   R10,86
       MOV  R10,@LINT46       Line 23
 
*  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+
       CI   R1,MSG24+>F6      Enough for 2 display lines
       JL   EDNT3
 
*  Move common message text into blanked area
 
       LI   R2,>1F00
       LI   R1,MSL26
EDNT4  MOVB @MSG26-1(R1),@MSG24+8(R1)
       MOVB R2,@MSG24+8+86(R1)
       MOVB @CFALM1(R1),@MSG24+8+172(R1)
       DEC  R1
       JGT  EDNT4
 
*  Variations for side
*---------------------
 
       SETO @WDPROC           Initialize for W/P
       MOV  @FWREG+8,R4       TI-Wr or Pr/Ed  ?
       JEQ  MCP20             Wd/Pr
 
*  Program Editor entry details
*------------------------------
*  Replace wordwrap cursor & reformat code
 
 
       LI   R1,8
NWCS10 MOVB @ACSR-1(R1),@WCSR(R1)  Allow for len byte @WCSR
       DEC  R1
       JGT  NWCS10
 
       LI   R1,ASMLEN
NWCS20 MOV  @ASMCOD-2(R1),@ASMPOS(R1)
       DECT R1
       JGT  NWCS20
 
       LI   R11,UPDA12
       MOV  @BRINS,*R11+
       LI   R1,REFR05
       MOV  R1,*R11
       CLR  @WDPROC
       SETO @LINF
       LI   R15,WORDW
       LI   R1,ASPARS
       JMP  MCP30
 
*  Word processor entry details
*------------------------------
 
MCP20  LI   R1,WDWRAP         To set wordwrap
       LI   R15,START         WP entry
       SETO @CRFLAG           Initialize
       CLR  @LINF
 
*  Common continuation
 
MCP30  SETO *R1               Set appropriate flag
       MOV  R1,@WPMODE        Set WP/PE flag
 
*  Fill VDP Tab buffer with 3 copies
 
       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
       AI   R14,22            Advance VDP pointer
       CI   R14,3*22+TABBUV   Check all done
       JL   WRMPLT            Not yet
 
 
*  Fetch printer name from FW
 
       MOV  @EDPRNT,R8        Get name pointer
       BL   @VSTRV            Write to VDP
       DATA DEVBUV
       MOV  @EDPRNT,R8        Copy for SD Printer also
       BL   @VSTRV
       DATA PSDBUV
 
 
*  Further Initialization
 
       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
       BL   @PURGF            Initialize - no lines
       CLR  R5                Char
       BL   @WINDOW
       B    *R15              Preloaded
 
 
*  Reset path first time round main loop
*---------------------------------------
 
SECOND SETO @REFRSH           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   @SETVR1           Makes a VWTR
       DATA >F081
BRINS  B    @COMAND           Set command mode
 
*---------------------------------------------------------
 
