NEW
  AUTO 3,1
*--------------------------------
* BEWARE ZP USE!!!
*--------------------------------
CH         .EQ $24                MONITOR HORIZ POSN
CV         .EQ $25                MONITOR VERT POSN
BASEL      .EQ $28                MONITOR BASE ADRS
A2L        .EQ $3E
A2H        .EQ $3F
A4L        .EQ $42
A4H        .EQ $43
*--------------------------------
SP.BEG     .EQ $52,53    Changed! PROG CODE STACK BEGIN
SP.END     .EQ $54,55             PROG CODE STACK END+1
PP.BEG     .EQ $56,57             PROG CODE BEGIN
PP.END     .EQ $58,59    Changed! PROG CODE END+1
*--------------------------------
       .DUMMY
       .OR $C0
LEFT.MARGIN    .BS 1           INIT TO 6
RIGHT.MARGIN   .BS 1           INIT TO SCR.SIZE-1
RM.ADJUST      .BS 1           INIT TO 6
POSH           .BS 1           INIT TO 6
POSV           .BS 1           INIT TO 0
ED.PTR         .BS 1         EDIT LINE CHAR PTR
ED.KEY         .BS 1         FIND CHAR KEY CODE
CTR            .BS 1         GENERAL CTR FOR SCROLL ROUTINES
MAXV           .BS 1         MAX POSV OF SCREEN SCROLL
LN.FLAG        .BS 1         INIT TO 0
FILL.TO        .BS 1         COLUMN TO BLANK FILL TO
FIRST.LINE     .BS 1         FIRST LINE OF SCRN (INIT 0)
LAST.LINE      .BS 1         LAST LINE OF SCRN (INIT 23)
BLKSIZ         .BS 1
RPTCNT         .BS 1
RPTCHR         .BS 1
PTR1           .BS 2
PTR2           .BS 2
CUR.KEY        .BS 1         CURRENT KEY
LNO            .BS 2         LINE NUMBER FOR PRNT ROUTINE
SAV.CTR        .BS 1         CTR FOR EDIT LINE
SAV.PTR1       .BS 2         PTR1 FOR EDIT LINE
SAV.LNO        .BS 2         LNO FOR EDIT LINE
CV.DIGFLG      .BS 1         FIRST NON-ZERO DIGIT FLG
NO.SHOW.FLAG   .BS 1       SET TO PREVENT SHOW SCRN
SRCP           .BS 2
       .ED
*--------------------------------
WBUF       .EQ $200
M.RESET    .EQ $3F2 THRU 3F4
*--------------------------------
M.BASCALC  .EQ $FBC1     CALC BASE ADRS
M.BELL     .EQ $FBDD     RING BELL
M.COUT     .EQ $FDED     APPLE CHAR OUTPUT
*--------------------------------
HARD   JMP HINIT         INIT SCREEN EDITOR
*--------------------------------
START.COL  .EQ 6         START OF LINE DATA IN BUFFER
*--------------------------------
*
* STANDARD PARAMETER AREA
*
* THESE PARAMETERS ALLOW CUSTOMIZATION
* OF THE SCREEN EDITOR TO SUIT INDIVIDUAL TASTE.
*--------------------------------
SCREEN.WIDTH .DA #SCR.SIZE        WIDTH OF SCREEN
ROLL.VALUE   .DA #24 (20 4 WM)    SCREEN ROLL UP/DOWN VALUE
ROLL.VALUE2  .DA #100             BIG ROLL UP/DOWN VALUE
HORT.PAGE    .DA #40              HORIZONTAL PAGE
RPT.CHAR     .DA #'-'             REPEAT CHAR FOR COMMENT LINE
RPT.LENG     .DA #32              REPEAT LENGTH FOR COMMENT LINE
SKMOD.FLG    .DA #$00 ($FF 4 WM)  SHIFT KEY MOD FLAG
AUTO.REN     .DA #$FF             AUTO RENUMBER FLAG
AUTO.BASE    .DA 1000               AUTO REN START LINE NUM
AUTO.INC     .DA 10                 AUTO REN INCREMENT LINE NUM
RT.FENCEL    .DA #248-SCR.SIZE+START.COL  RIGHTMOST HORTZ PAGE LIMIT
RT.FENCER    .DA #248+START.COL-1   RIGHTMOST COLUMN ALLOWED
L.MARGIN     .DA #START.COL       LEFT MARGIN FOR CAR RETN POSN
*  TAB TABLE 21 ENTRIES ZERO ON UNUSED ENTRIES
TAB.TBL      .DA #1,#8,#12,#21,#26,#35,#50,#0,#0,#0    ENTRIES 1-10
             .DA #0,#0,#0,#0,#0,#0,#0,#0,#0,#0         ENTRIES 11-20
             .DA #0                                    END OF TABLE
SZ.TAB.TBL   .EQ *-TAB.TBL
*--------------------------------
* VARIABLE AREA BELOW $3D0
*
* NOTE THAT WE SUBTRACT THE NEEDED SPACE
* FROM THE PREVIOUS DEFINED SYMBOL.  I.E.
* 'LN.CNT' IS 32 BYTES BEFORE $3D0.
*--------------------------------
VAR.END      .EQ $3D0
LN.CNT       .EQ VAR.END-32       BACKWARD SCROLL LENGTH TABLE
INDEX        .EQ LN.CNT-1         INDEX TO LN.CNT
COMPOSE.FLG  .EQ INDEX-1          INIT TO 0
SPECIAL.FLG  .EQ COMPOSE.FLG-1    INIT TO 0
MDIST        .EQ SPECIAL.FLG-2    MOVE DISTANCE
ESC.FLAG     .EQ MDIST-1          EDIT/SCROLL MODE FLG
ONCE.FLG     .EQ ESC.FLAG-1       SPECIAL ESCAPE FLAG
CHANGE.FLG   .EQ ONCE.FLG-1       EDIT LINE CHANGED / MUST SUBMIT
FORM.FLG     .EQ CHANGE.FLG-1     SHOW FORM GUIDE (INIT 0)
ALPHA.FLG    .EQ FORM.FLG-1       ALPHA SHIFT LOCK FLAG (INIT 0)
SAVE.RSTV    .EQ ALPHA.FLG-2      SAVE RESET VECTOR
SAVE.3D1     .EQ SAVE.RSTV-2      SAVE OS SOFT VECTOR
SAVE.3D4     .EQ SAVE.3D1-2       SAVE OS HARD VECTOR
SAVE.36      .EQ SAVE.3D4-2       SAVE OUTPUT HOOK
SAVE.38      .EQ SAVE.36-2        SAVE INPUT HOOK
VAR.BEG      .EQ save.38
  .DO VAR.BEG<$300
  *** ERROR VAR.BEG < $300
  .FIN
*--------------------------------
*
*  FUNCTION TABLE FOR SCROLL MODE
*  KEYBOARD FUNCTIONS.
*
*  BECAUSE OF KEYBOARD VARIATIONS BETWEEN APPLE II PLUS
*  AND APPLE II E AND FRANKLIN KEYBOARDS SOME KEYS ARE
*  DEFINED AS DUPLICATE FUNCTIONS TO IMPROVE THE HUMAN
*  FACTORS OF KEY PLACEMENT.
*
*  THE SHIFT 2 KEY ON AP2+ IS '"' BUT ON OTHER KEYBOARDS
*  AN '@' IS THE SHIFT 2 KEY CODE.  '"' AND '@' PERFORM
*  THE SAME FUNCTION.
*
*  THE HORIZONTAL SCROLL KEYS ':' AND '-' ON THE AP2+ KEYBOARD
*  ARE NOT IN EASY REACH ON OTHER KEYBOARDS SO THE KEYS
*  ',' AND '.' PERFORM THE SAME FUNCTION AND HAVE THE
*  NICE SUGGESTIVE PROMPT OF THEIR SHIFT CODES '<' AND '>'
*  TO POINT CORRECT SCROLL DIRECTION.
*--------------------------------
FTBL   .DA #'1,ROLL.UP-1          ROLL UP 24 LINES
       .DA #'2,ROLL.DN-1          ROLL DOWN 24 LINES
       .DA #'3,LN.TOGL-1          LINE NUMBER TOGGLE
       .DA #'4,COMPOSE-1          COMPOSE MODE TOGGLE
       .DA #'5,FORM.GUIDE-1       FORM GUIDE MODE TOGGLE
       .DA #'W-$40,SET.LMARGIN-1  SET LEFT MARGIN
       .DA #'/,GOTO.LINE-1        GOTO LINE#
       .DA #'Q-$40,EXIT-1         QUIT FROM EDITOR
       .DA #'B,SHOW.BEGIN-1       BEGINNING OF FILE
       .DA #'E,SHOW.END-1         END OF FILE
       .DA #'!,ROLL.U100-1        ROLL UP 100 LINES
       .DA #'",ROLL.D100-1  AP2+  ROLL DOWN 100 LINES
       .DA #'@,ROLL.D100-1  AP2E  ROLL DOWN 100 LINES
       .DA #':,LEFT.PAGE-1  AP2+  HORIZONTAL SCROLL LEFT
       .DA #',,LEFT.PAGE-1  AP2E  HORIZONTAL SCROLL LEFT
       .DA #'-,RIGHT.PAGE-1 AP2+  HORIZONTAL SCROLL RIGHT
       .DA #'.,RIGHT.PAGE-1 AP2E  HORIZONTAL SCROLL RIGHT
       .DA #'I,MOVE.UP-1          MOVE CRSR UP 1 LINE
       .DA #'K-$40,MOVE.UP-1      MOVE CRSR UP 1 LINE
       .DA #'M,MOVE.DN-1          MOVE CRSR DOWN 1 LINE
       .DA #'J-$40,MOVE.DN-1      MOVE CRSR DOWN 1 LINE
       .DA #'J,MOVE.LF-1          MOVE CRSR LEFT 1 CHAR
       .DA #'H-$40,MOVE.LF-1      MOVE CRSR LEFT 1 CHAR
       .DA #'K,MOVE.RT-1          MOVE CRSR RIGHT 1 CHAR
       .DA #'U-$40,MOVE.RT-1      MOVE CRSR RIGHT 1 CHAR
       .DA #'L-$40,INSERT-1       INSERT LINE
       .DA #'Z-$40,DELETE-1       DELETE LINE
       .DA #$1B,ESCAPE-1          ENTER EDIT MODE
       .DA #'M-$40,RETURN-1       RETURN TO NEXT LINE
       .DA #'P-$40,DINSERT-1      INSERT DASHED LINE COMMENT
**** SPECIAL EDIT MODE FORCING KEYS
**** THERE MUST BE NO CONFLICT WITH THE ABOVE
**** SCROLL MODE FUNCTION KEY CODES.
       .DA #'@-$40,SPECIAL-1      CLEAR TO EOL
       .DA #'A-$40,SPECIAL-1      TOGGLE ALPHA SHIFT LOCK
       .DA #'B-$40,SPECIAL-1      BEGINING OF LINE
       .DA #'C-$40,SPECIAL-1      COPY TO TAB
       .DA #'D-$40,SPECIAL-1      DELETE CHAR
       .DA #'F-$40,SPECIAL-1      FIND CHAR
       .DA #'I-$40,SPECIAL-1      INSERT CHAR
       .DA #'N-$40,SPECIAL-1      END OF LINE
       .DA #'O-$40,SPECIAL-1      INSERT CNTRL CHAR
       .DA #'S-$40,SPECIAL-1      SET/CLEAR TAB
       .DA #'T-$40,SPECIAL-1      TAB
FTBL.Z .EQ *-FTBL
  .DO FTBL.Z>256
  !!! SCROLL MODE FUNCTION TABLE TOO LARGE
  .FIN
*--------------------------------
*
* FUNCTION TABLE FOR EDIT MODE
* KEYBOARD FUNCTIONS.
*
*--------------------------------
E.TBL
  .DA #'@-$40,E.ZAP-1             CLEAR TO EOL
  .DA #'A-$40,E.SHIFT-1           TOGGLE ALPHA SHIFT LOCK
  .DA #'B-$40,E.BEG-1             BEGINNING
  .DA #'C-$40,E.COPY-1            COPY TO TAB
  .DA #'D-$40,E.DEL-1             DELETE CHAR
  .DA #'F-$40,E.FIND-1            FIND CHAR
  .DA #'H-$40,E.BKSP-1            BACKSPACE
  .DA #'I-$40,E.INS-1             INSERT CHAR
  .DA #'N-$40,E.END-1             END OF LINE
  .DA #'O-$40,E.OVR-1             INSERT CONTROL CHAR
  .DA #'R-$40,E.RESTORE-1         RESTORE LINE
  .DA #'S-$40,E.SET.TAB-1         SET/CLEAR TAB
  .DA #'T-$40,E.TAB-1             TAB TO NEXT POSN
  .DA #'U-$40,E.RIT-1             RIGHT ARROW
  .DA #$1B,E.ESC-1                ESCAPE FROM EDIT MODE
**** SCROLL MODE FUNCTIONS ****
**** THESE KEY CODES MUST NOT CONFLICT
**** WITH THE EDIT KEY CODES.
  .DA #'J-$40,E.CTRL-1            MOVE DOWN
  .DA #'K-$40,E.CTRL-1            MOVE UP
  .DA #'L-$40,E.CTRL-1            INSERT LINE
  .DA #'M-$40,E.CTRL-1            RETURN
  .DA #'P-$40,E.CTRL-1            INSERT COMMENT LINE
  .DA #'Q-$40,E.CTRL-1            QUIT
  .DA #'W-$40,E.CTRL-1            SET LEFT MARGIN
  .DA #'Z-$40,E.CTRL-1            DELETE LINE
E.TBLSZ .EQ *-E.TBL
  .DO E.TBLSZ>256
  !!! EDIT MODE FUNCTION TABLE TOO LARGE
  .FIN
*--------------------------------
MAN
SAVE usr/src/fse/fse.s.1
LOAD usr/src/fse/fse.s
ASM
