
 1000  *SAVE S.FAST TEXT (SCHLYTER)
 1010  *--------------------------------
 1020  *  SPEEDUP OF DOS TEXT FILE READ/WRITE
 1030  *  BY PAUL SCHLYTER, SWEDEN, MAY 1983.
 1040  *--------------------------------
 1050  PNTR   .EQ $42,43   DOS VARIABLE
 1060  *--------------------------------
 1070  GET.WRKAREA.FROM.BUFFER .EQ $AE6A
 1080  SAVE.WRKAREA.TO.BUFFER  .EQ $AE7E
 1090  SAVE.OLD.WRKAREA        .EQ $AE7E+3
 1100  POINT.TO.WRKAREA.BUFFER .EQ $AF08
 1110  FM.OPCODE               .EQ $B5BB
 1120  *--------------------------------
 1130         .OR $300
 1140         JMP INSTALL
 1150  *--------------------------------
 1160  *  PATCH EXECUTED UPON ENTRY TO FILE MANAGER:
 1170  *      1. IF READ/WRITE AND CORRECT WORK AREA, RETURN
 1180  *      2. IF WRONG WORK AREA, SAVE OLD WORK AREA
 1190  *      3. LOAD NEW WORK AREA.
 1200  *--------------------------------
 1210  PATCH1 LDA FM.OPCODE     IF NOT READ OR WRITE,
 1220         CMP #3                DO AS USUAL
 1230         BCC .1            ...LESS THAN READ/WRITE
 1240         CMP #5
 1250         BCS .1            ...HIGHER THAN READ/WRITE
 1260         JSR POINT.TO.WRKAREA.BUFFER
 1270         LDA PNTR     CHECK TO SEE IF CORRECT WORKAREA
 1280         CMP PNTR.S        ALREAD LOADED
 1290         BNE .1            NO
 1300         LDA PNTR+1
 1310         CMP PNTR.S+1
 1320         BNE .1            NO
 1330         RTS               YES, NOTHING ELSE TO DO,
 1340  *                        SO EXIT NOW AND SAVE 800 CYCLES!
 1350  *
 1360  *      OPCODE NOT READ OR WRITE, OR WRONG WORK AREA.
 1370  .1     BIT FLG      NEED TO PUT BACK THIS WORK AREA?
 1380         BPL .2       NO, JUST GET NEW ONE
 1390         CLC          YES, CLEAR FLAG
 1400         ROR FLG
 1410         LDA PNTR.S
 1420         STA PNTR
 1430         LDA PNTR.S+1
 1440         STA PNTR+1
 1450         JSR SAVE.OLD.WRKAREA
 1460  .2     JMP GET.WRKAREA.FROM.BUFFER
 1470  *--------------------------------
 1480  *  PATCH EXECUTED WHEN FILE MANAGER IS FINISHED:
 1490  *      1. IF READ/WRITE, SET FLAG AND SAVE PNTR
 1500  *      2. IF NOT R/W, CLEAR FLAG AND SAVE WORK AREA
 1510  *--------------------------------
 1520  PATCH2 LDA FM.OPCODE     R/W?
 1530         CMP #3
 1540         BCC .1            NO
 1550         CMP #5
 1560         BCS .1            NO
 1570         SEC               YES, SET FLAG
 1580         ROR FLG
 1590         JSR POINT.TO.WRKAREA.BUFFER
 1600         LDA PNTR          AND SAVE POINTER
 1610         STA PNTR.S
 1620         LDA PNTR+1
 1630         STA PNTR.S+1
 1640         RTS               SAVE ANOTHER 800 CYCLES
 1650  .1     CLC               CLEAR FLAG
 1660         ROR FLG
 1670         JMP SAVE.WRKAREA.TO.BUFFER
 1680  *
 1690  PNTR.S .HS 0000
 1700  FLG    .HS 00
 1710  *--------------------------------
 1720  *  TO INSTALL, PATCH DOS LIKE THIS:
 1730  *      .OR $AB0A
 1740  *      JSR PATCH1
 1750  *
 1760  *      .OR $B38E
 1770  *      JSR PATCH2
 1780  *
 1790  *  HERE IS ONE WAY TO DO IT:
 1800  *--------------------------------
 1810  INSTALL
 1820         LDA #$20     JSR OPCODE
 1830         STA $AB0A
 1840         STA $B38E
 1850         LDA #PATCH1
 1860         STA $AB0B
 1870         LDA /PATCH1
 1880         STA $AB0C
 1890         LDA #PATCH2
 1900         STA $B38F
 1910         LDA /PATCH2
 1920         STA $B390
 1930         RTS
 1940  *--------------------------------

