
 1000  *SAVE S.APPLY DOS PATCHES
 1010  *--------------------------------
 1020  PNTR       .EQ $00,01
 1030  PATCH      .EQ $02,03
 1040  SECTOR.CNT .EQ $04
 1050  *--------------------------------
 1060  DOS.IMAGE  .EQ $4000 - $64FF
 1070  DOS.9D     .EQ $9D00-DOS.IMAGE-$0C00
 1080  DOS.B6     .EQ $B600-DOS.IMAGE
 1090  *--------------------------------
 1100  GETIOB     .EQ $3E3
 1110  RWTS       .EQ $3D9
 1120  *--------------------------------
 1130  IOB        .EQ $B7E8
 1140  IOB.VOLUME .EQ IOB+3
 1150  IOB.TRACK  .EQ IOB+4
 1160  IOB.SECTOR .EQ IOB+5
 1170  IOB.BUFADR .EQ IOB+8
 1180  IOB.OPCODE .EQ IOB+12
 1190  *--------------------------------
 1200  PATCH.DOS
 1210         JSR READ.DOS.IMAGE
 1220         JSR PATCHER
 1230         JSR WRITE.DOS.IMAGE
 1240         RTS
 1250  *--------------------------------
 1260  READ.DOS.IMAGE
 1270         LDA #$01     READ OPCODE
 1280         .HS 2C
 1290  WRITE.DOS.IMAGE
 1300         LDA #$02     WRITE OPCODE
 1310         STA IOB.OPCODE
 1320         LDA #0
 1330         STA IOB.BUFADR
 1340         STA IOB.VOLUME
 1350         LDA #DOS.IMAGE/256+16+16+5-1
 1360         STA IOB.BUFADR+1
 1370         LDA #2       TRACK 2
 1380         STA IOB.TRACK
 1390         LDA #4       SECTOR 4
 1400         STA IOB.SECTOR
 1410         LDA #16+16+5
 1420         STA SECTOR.CNT
 1430  .1     LDA IOB.TRACK
 1440         LDX IOB.SECTOR
 1450         JSR $F941
 1460         JSR GETIOB
 1470         JSR RWTS
 1480         LDY IOB.SECTOR
 1490         DEY
 1500         BPL .2
 1510         LDY #15
 1520         DEC IOB.TRACK
 1530  .2     STY IOB.SECTOR
 1540         DEC IOB.BUFADR+1
 1550         DEC SECTOR.CNT
 1560         BNE .1
 1570         RTS
 1580  *--------------------------------
 1590  PATCHER
 1600         LDA #PATCHES-1
 1610         STA PNTR
 1620         LDA /PATCHES-1
 1630         STA PNTR+1
 1640         LDY #0
 1650  
 1660  .1     JSR GET.BYTE LENGTH OF NEXT PATCH
 1670         BEQ .4       FINISHED
 1680         TAX          SAVE LENGTH IN X
 1690         JSR GET.BYTE ADDRESS OF PATCH
 1700         STA PATCH
 1710         JSR GET.BYTE
 1720         STA PATCH+1
 1730  
 1740  .2     JSR GET.BYTE
 1750         STA (PATCH),Y
 1760         INC PATCH
 1770         BNE .3
 1780         INC PATCH+1
 1790  .3     DEX
 1800         BNE .2
 1810         BEQ .1       ...ALWAYS
 1820  
 1830  .4     RTS
 1840  *--------------------------------
 1850  GET.BYTE
 1860         INC PNTR
 1870         BNE .1
 1880         INC PNTR+1
 1890  .1     LDA (PNTR),Y
 1900         RTS
 1910  *--------------------------------
 1920  PATCHES
 1930  *--------------------------------
 1940  *  S.FAST LOAD
 1950  *
 1960  *      FAST "LOAD" AND "BLOAD"
 1970  *
 1980  *      INSTALLED IN UNUSED AREAS IN DOS 3.3:
 1990  *          $BA69-$BA95   (45 BYTES FREE)
 2000  *          $BCDF-$BCFF   (33 BYTES FREE)
 2010  *--------------------------------
 2020  READ.RANGE          .EQ $AC96
 2030  READ.NEXT.SECTOR    .EQ $B0B6
 2040  END.OF.DATA.ERROR   .EQ $B36F
 2050  RANGE.LENGTH        .EQ $B5C1,C2
 2060  RANGE.ADDRESS       .EQ $B5C3,C4
 2070  BUFFER.ADDRESS      .EQ $B5CB,CC
 2080  SECTOR.COUNT        .EQ $B5E4,E5
 2090  BYTE.OFFSET         .EQ $B5E6
 2100  *--------------------------------
 2110         .DA #P1.LENGTH,$BA69-DOS.B6
 2120         .PH $BA69
 2130  PATCH1 LDA BYTE.OFFSET       LAST BYTE OF
 2140         BNE GO.READ.RANGE     A SECTOR?
 2150         LDA RANGE.LENGTH+1    WHOLE SECTOR LEFT?
 2160         BEQ GO.READ.RANGE     NO.
 2170         LDA BUFFER.ADDRESS    SAVE BUFFER ADDRESS
 2180         PHA
 2190         LDA BUFFER.ADDRESS+1
 2200         PHA
 2210         LDA RANGE.ADDRESS     READ DIRECTLY
 2220         STA BUFFER.ADDRESS    INTO RANGE
 2230         LDA RANGE.ADDRESS+1
 2240         STA BUFFER.ADDRESS+1
 2250  READ.LOOP
 2260         JSR READ.NEXT.SECTOR
 2270         BCS .1
 2280         JMP PATCH2
 2290  .1     JMP END.OF.DATA.ERROR
 2300  GO.READ.RANGE
 2310         JMP READ.RANGE
 2320  P1.LENGTH .EQ *-PATCH1
 2330         .EP
 2340  *--------------------------------
 2350         .DA #P2.LENGTH,$BCDF-DOS.B6
 2360         .PH $BCDF
 2370  PATCH2 INC SECTOR.COUNT
 2380         BNE .1
 2390         INC SECTOR.COUNT+1
 2400  .1     INC RANGE.ADDRESS+1   NEXT PAGE
 2410         INC BUFFER.ADDRESS+1
 2420         DEC RANGE.LENGTH+1
 2430         BNE .2
 2440         PLA               RESTORE BUFFER
 2450         STA BUFFER.ADDRESS+1
 2460         PLA
 2470         STA BUFFER.ADDRESS
 2480         JMP READ.RANGE
 2490  
 2500  .2     JMP READ.LOOP
 2510  P2.LENGTH .EQ *-PATCH2
 2520         .EP
 2530  *--------------------------------
 2540         .DA #P3.LENGTH,$ACA5-DOS.9D
 2550         .PH $ACA5
 2560  PATCH3 JMP PATCH1
 2570  P3.LENGTH .EQ *-PATCH3
 2580         .EP
 2590  *--------------------------------
 2600         .DA #0       END OF PATCHES

