A2osX/FSE/FSE.S.2.txt
2024-02-16 18:51:17 +01:00

523 lines
14 KiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

NEW
AUTO 3,1
*--------------------------------
HINIT LDA SP.BEG KILL SYMBOL TABLE
STA SP.END EDIT USES IT FOR
LDA SP.BEG+1 SCROLL LINE STACK
STA SP.END+1
LDY #VAR.BEG ZERO DATA AREA
LDA #0
.1 STA $300,Y
INY
CPY #VAR.END
BCC .1
LDA #START.COL START IN THIS COLUMN
STA LEFT.MARGIN
STA POSH CURSOR IN COLUMN 1
CLC
ADC SCREEN.WIDTH
STA RIGHT.MARGIN
LDA #23
STA LAST.LINE OF SCROLL
LDX #0
STX NO.SHOW.FLAG
STX RM.ADJUST NO LINE NUMBERS
STX LN.FLAG
STX FIRST.LINE OF SCROLL
STX POSV CURSOR ON LINE 0
INX X=1
.2 LDA M.RESET,X SAVE RESET VECTOR
STA SAVE.RSTV,X
LDA $3D1,X SAVE 3D1.3D2
STA SAVE.3D1,X
LDA $3D4,X SAVE 3D4.3D5
STA SAVE.3D4,X
LDA $36,X SAVE 36.37
STA SAVE.36,X
LDA $38,X SAVE 38.39
STA SAVE.38,X
LDA MY.VECTOR,X
STA M.RESET,X RESET TO ME
STA $3D1,X 3D0G TO ME
STA $3D4,X 3D3G TO ME
DEX
BPL .2
TXS
JSR FIXRST FIX POWER UP BYTE
BCC DO.GOTO.LINE BA, BUT WATCH IT!!! $#*
*--------------------------------
GOTO.LINE LDX #1
.1 STX LNO
JSR READ.KEY.CODE
LDX LNO
STA WBUF,X
INX
CMP #'0'
BCC DO.GOTO.LINE
CMP #'9'+1
BCC .1
DO.GOTO.LINE
LDA #0
STA LNO
STA LNO+1
LDY #1
.10 LDA WBUF,Y GET NEXT CHAR
INY
EOR #'0' MASK ASCII DIGIT
CMP #9+1 IS IT GOOD DIGIT
BCS .11 NO, USE LNO AS LINE TO GOTO
PHA SAVE DIGIT
LDA LNO MDIST=LNO
STA MDIST LNO=DIGIT
PLA
STA LNO
LDA LNO+1
STA MDIST+1
LDA #0
STA LNO+1
LDX #10
.12 LDA LNO ADD MDIST TO LNO 10 TIMES
CLC
ADC MDIST
STA LNO
LDA LNO+1
ADC MDIST+1
STA LNO+1
DEX
BNE .12
BEQ .10 ...ALWAYS
.11 JSR SHOW.BEGIN
.1 JSR P1.INIT START LINE # SEARCH
LDA PTR1
CMP PP.END
BNE .20
LDA PTR1+1
CMP PP.END+1
BEQ .4 STOP AT EOF
.20 LDA LNO
LDY #1
SEC
SBC (PTR1),Y COMPARE LINE LO
STA ED.KEY
LDA LNO+1
INY
SBC (PTR1),Y COMPARE LINE HI
BCC .4 IF LNO<LINE THEN FOUND
BEQ .3 IF EQUAL CK LO
.2 JSR POP.LINE POP OFF LINE
JMP .1 CK THIS LINE
.3 LDA ED.KEY WAS LO LINE EQUAL?
BNE .2 NO
.4
*--------------------------------
SOFT LDX #$FF INIT STACK PTR
TXS
LDA NO.SHOW.FLAG DO WE NEED TO SHOW SCRN
BNE .1 NO
JSR SHOW.SCREEN PLOP UP THE SCRN
.1 LDA #0 ZERO FLAG
STA NO.SHOW.FLAG
.2 JSR EDIT.LINE GET A KEY OR EDIT THE LINE
LDY #0 KEY IN A REG
* allow lowercase too!!!
CMP #$60
BCC .3
SBC #$20
.3 CMP FTBL,Y HUNT FOR KEY CODE
BEQ .4 FOUND IT
INY NEXT ENTRY
INY
INY
CPY #FTBL.Z
BCC .3
JSR M.BELL BAD KEY CODE
JMP .2
.4 JSR TOSUB PROCESS KEY
JMP SOFT
TOSUB LDA FTBL+2,Y
PHA
LDA FTBL+1,Y
PHA
RTS
*--------------------------------
FIXRST LDA M.RESET+1
EOR #$A5 MAKE SURE WE DONE
STA M.RESET+2 BOOT DISK UP
RTS
*--------------------------------
ESCAPE LDA #$FF
STA ESC.FLAG PUT INTO EDIT MODE
BNE SET.NS DONT SHOW SCRN
*--------------------------------
COMPOSE LDA COMPOSE.FLG TOGGLE COMPOSE MODE FLAG
EOR #1
STA COMPOSE.FLG
SET.NS LDA #1 DONT SHOW SCRN
STA NO.SHOW.FLAG
RTS ON RETURN TO MAIN LOOP
*--------------------------------
SPECIAL LDA #1
STA SPECIAL.FLG SPECIAL KEY JUST FOR EDIT
BNE SET.NS DONT SHOW SCRN
*--------------------------------
SET.LMARGIN LDA POSH CUR POSH IS LEFT MARGIN
PHA
LDA RT.FENCEL
CLC
ADC SCREEN.WIDTH
SEC
SBC #START.COL
STA ED.KEY
PLA
CMP ED.KEY POSH< (RT.FENCEL+SCREEN.WIDTH-START.COL)
BCS .1 NO, SO CANT SET MARGIN
STA L.MARGIN
.1 JMP SET.NS
*--------------------------------
RETURN JSR SET.NS ASSUME WE DO NOT SHOW SCREEN
LDA L.MARGIN BEGINNING OF LINE
STA POSH NEW COLUMN POSN
PHA
LDA SCREEN.WIDTH
LSR
STA ED.KEY SAVE SW/2
PLA
SEC
SBC ED.KEY LM-(SW/2)
BCC .20 TOO FAR
CMP #START.COL MUST BE > START.COL
BCS .30 YES SO SET NEW MARGIN
.20 LDA #START.COL START.COL IS GOOD MARGIN
.30 CMP LEFT.MARGIN SEE IF ALREADY THERE
BEQ .1 YES
CMP RT.FENCEL MARGIN NOT PAST FENCE
BCC .0
CMP RT.FENCER
BEQ .0
BCC .0
LDA RT.FENCEL
.0 JSR SET.MARGIN
JSR .4
.1 LDA POSV
CMP MAXV WAS *EOF* HIT?
BCS .3 YES
CMP LAST.LINE WAS HE ON LAST LINE?
BCC .2 NO
JSR POP.LINE YES, MOVE SCREEN DOWN 1 LINE
JSR .4 MAKE SURE WE SHOW SCREEN
.HS 2C BIT abs opcode skips 2 .3
.2 INC POSV
.3 LDA COMPOSE.FLG IF COMPOSE TOGGLE ON
BEQ .5 NO
JSR INSERT YES, INSERT NEW LINE
.4 LDA #0 MAKE SURE WE SHOW
STA NO.SHOW.FLAG SCREEN IF NEW LINE ADDED
.5 RTS
*--------------------------------
SET.MARGIN STA LEFT.MARGIN
CLC
ADC SCREEN.WIDTH
SEC
SBC RM.ADJUST
STA RIGHT.MARGIN
RTS
*--------------------------------
* RESET VECTOR IS SAVED SO WE CAN INTERCEPT IT.
* 3D0G AND 3D3G VECTORS SAVED FOR SOME PEOPLE
* WITH OLD NON AUTO-START ROMS THEY GO TO MONITOR
* AND WE CANT STOP IT. BUT WE CAN MODIFY DOS
* HARD AND SOFT RESTART VECTORS TO CATCH HIS RETURN.
* IN AND OUT HOOKS SAVED BECAUSE RESET CLOBERS
* THEM AND VIDEX, STB80 PATCHES SET THEM UP
* IT IS CRITICAL TO CATCH RESET BECAUSE THE PROGRAM MAY BE
* SPLIT UP IF USER IS NOT AT BEGINING OF FILE AND SCROLLED
* OFF SECTION CANT BE RECOVERED IF ASSEMBLER RESTARTS ON
* US WITHOUT OUR KNOWLEDGE.
*--------------------------------
MY.VECTOR .DA EXIT ADRS OF EDIT RESET HANDLER
*--------------------------------
EXIT LDX #1
.1 LDA SAVE.RSTV,X RESORE RESET VECTOR
STA M.RESET,X
LDA SAVE.3D1,X 3D1.3D2 ALSO
STA $3D1,X
LDA SAVE.3D4,X 3D4.3D5 ALSO
STA $3D4,X
LDA SAVE.36,X 36.37 ALSO
STA $36,X
LDA SAVE.38,X 38.39 ALSO
STA $38,X
DEX
BPL .1
TXS save dem bytes!
JSR FIXRST FIX POWER UP BYTE
* only clear $130 - $16F!!!
LDX #$130
LDA #0 thanxs Bill
.2 STA $100,X CLEAR HASH TABLE FOR
INX ASSEMBLER SYMBOL TABLE
CPX #$170
BNE .2
*--------------------------------
EXIT2 JSR SHOW.BEGIN GO TO BEGINING OF FILE
LDA #23
JSR MY.VTAB BOTTOM LINE
INC CH MAKE SURE ASM DOES CRLF
JSR P1.INIT
LDA AUTO.REN CK FOR AUTO RENUMBER
BEQ .1 NONE WANTED
LDA AUTO.BASE RENUMBER THE PROGRAM
STA PTR2
LDA AUTO.BASE+1
STA PTR2+1
.0 JSR P1.ENDCK
BEQ EXIT3 END OF PROGRAM
LDA PTR2
LDY #1
STA (PTR1),Y
INY
LDA PTR2+1
STA (PTR1),Y
LDA PTR2
CLC
ADC AUTO.INC
STA PTR2
LDA PTR2+1
ADC AUTO.INC+1
STA PTR2+1
BCS .3 ERROR IF OVERFLOW
JSR P1.ADD
JMP .0
.1 JSR P1.ENDCK CK PROG LINE NUM=0
BEQ EXIT3 END OF PROGRAM
LDY #1
LDA (PTR1),Y
BNE .2
INY
LDA (PTR1),Y
BEQ .3 YES MUST RENUMBER
.2 JSR P1.ADD
JMP .1
.3 LDY #0 GIVE RENUMBER WARNING
.4 LDA MESG,Y
BEQ EXIT3
JSR M.COUT
INY
BNE .4
EXIT3 JMP $3D0 NON LANG CARD EXIT
*--------------------------------
MESG .HS 8D8D8D87
.AS -/*** PLEASE RENUMBER!/
.HS 8D8700
*--------------------------------
FORM.GUIDE LDA FORM.FLG TOGGLE FORM GUIDE
EOR #1
STA FORM.FLG
BEQ .1 OFF NOW
* suspect that something is wrong here...
* Mike's comment adds 2,
* but code adds 1
LDA POSV ON NOW SO ADD 2 TO POSV
CLC MAKE SURE POSV
ADC #1 STAYS ON SCREEN
STA POSV
LDA #1
LDY #22
BNE .2
.1 LDA POSV
SEC
SBC #1
STA POSV
LDA #0
LDY #23
.2 STA FIRST.LINE
STY LAST.LINE
CPY POSV
BCS .3
STY POSV
.3 CMP POSV
BCC .4
STA POSV
.4 RTS
*--------------------------------
SHOW.BEGIN JSR FIND.LAST.PAGE GET LAST 32 LINES
LDA #32
STA CTR
.1 JSR GET.LINE GET THEM BACK FROM
JSR CK.SPEND SCROLL LINE STACK
BNE .2 GO GET MORE
LDA LEFT.MARGIN RESET POSH, POSV
STA POSH
LDA FIRST.LINE
STA POSV
RTS
.2 DEC CTR MORE LINES IN LN.TBL
BNE .1 YES
BEQ SHOW.BEGIN NO, FIND 32 MORE LINES
*--------------------------------
CK.SPEND LDA SP.BEG SEE IF END OF SCROLL
CMP SP.END LINE STACK
BNE .1
LDA SP.BEG+1
CMP SP.END+1
.1 RTS
*--------------------------------
SHOW.END JSR POP.LINE POP ALL LINES OFF
LDA PP.BEG FROM PROG AREA ONTO
CMP PP.END SCROLL LINE STACK
BNE SHOW.END
LDA PP.BEG+1
CMP PP.END+1
BNE SHOW.END
* AT *EOF* NOW, BACK UP LAST.LINE-FIRST.LINE LINES
JSR FIND.LAST.PAGE
LDA LAST.LINE
STA POSV INSURE THAT POSV IS ON *EOF*
SEC
SBC FIRST.LINE
STA CTR NUM LINES TO BACK UP
.1 JSR GET.LINE BACK UP SO *EOF* IS ON
JSR CK.SPEND BOTTOM OF PAGE
BEQ .2 EXIT IF END SCROLL LINE STACK
DEC CTR COUNT LINE PULLED
BNE .1 GO PULL MORE LINES
.2 JSR SHOW.SCREEN DISPLAY SCREEN
INC NO.SHOW.FLAG PREVENT ANOTHER DISPLAY
RTS
*--------------------------------
DELETE JSR LSTRIP STRIP OFF LINES TO CUR LINE
LDA PP.BEG AT END OF PROG?
CMP PP.END
BNE .1
LDA PP.BEG+1
CMP PP.END+1
BNE .1
INC NO.SHOW.FLAG YES DONT SHOW SCRN
BNE .2 ...ALWAYS
.1 LDY #0 DEL CUR LINE
LDA (PP.BEG),Y
CLC
ADC PP.BEG
STA PP.BEG
BCC .2
INC PP.BEG+1
.2 JMP LGRAB GRAB BACK PREV LINES
*--------------------------------
; added $81 (1 space) to blank line for EDITing
INS.TBL
* better blank line
BL .DA #BLEN
.DA $0000
.DA #$81 (see...)
.HS 00
BLEN .EQ *-BL
* DASHED COMMENT LINE
* used RPT symbols! (for assembling)
DCL .DA #DCLEN
.DA $0000
.AS ';' $#*
.DA #$C0,#RPT.LENG,#RPT.CHAR
.HS 00
DCLEN .EQ *-DCL
*--------------------------------
DINSERT LDY #DCL-INS.TBL DASHED commment LINE INSERT
.HS 2C BIT abs opcode skips 2 DINS.1
INSERT LDY #BL-INS.TBL BLANK LINE INSERT
DINS.1 LDA INS.TBL,Y GET LINE BYTE COUNT
STA WBUF
LDX #1
.1 CPX WBUF
BEQ .2
INY
LDA INS.TBL,Y COPY INTO WBUF
STA WBUF,X
INX
BNE .1
.2 LDA PP.BEG CK FOR ENOUGH SPACE
SEC
SBC SP.END
STA PTR1
LDA PP.BEG+1
SBC SP.END+1
BNE .3
LDA PTR1
CMP WBUF
BCS .3
JMP M.BELL NOT ENOUGH FREE MEMORY
.3 JSR LSTRIP GET DOWN TO CUR LINE
LDA PP.BEG
SEC
SBC WBUF ALLOCATE BYTES BEFORE
STA PP.BEG CUR LINE
LDA PP.BEG+1
SBC #0
STA PP.BEG+1
LDA RPT.CHAR SET REPEAT CHAR
STA WBUF+6
LDA RPT.LENG AND LENGTH
STA WBUF+5
LDY #0
LDX WBUF BYTE COUNT
.4 LDA WBUF,Y
STA (PP.BEG),Y PUT IN LINE DATA
INY
DEX
BNE .4
**** FALL INTO LGRAB ****
*--------------------------------
LGRAB LDA POSV GET BACK POSV-FIRST.LINE LINES
SEC
SBC FIRST.LINE
BEQ .1
STA CTR
JSR FIND.LAST.PAGE
.0 JSR GET.LINE
DEC CTR
BNE .0
.1 RTS
*--------------------------------
LSTRIP LDA POSV POP DOWN TO POSV-FIRST.LINE LINES
SEC
SBC FIRST.LINE
BEQ .1
STA CTR
.0 JSR POP.LINE
DEC CTR
BNE .0
.1 RTS
*--------------------------------
MAN
SAVE usr/src/fse/fse.s.2
LOAD usr/src/fse/fse.s
ASM