
 1000  *SAVE S.DOS.LOAD
 1010  *--------------------------------
 1020         .OR $7400
 1030         .TF DOS.LOAD
 1040  *--------------------------------
 1050  PNTR          .EQ $00,01
 1060  CAT.INDEX     .EQ $02
 1070  MENU.LETTER   .EQ $03
 1080  LINE.COUNT    .EQ $04
 1090  TRACK         .EQ $05
 1100  SECTOR        .EQ $06
 1110  DONE.FLAG     .EQ $07
 1120  SIZE          .EQ $08,09
 1130  LIMIT         .EQ $0A
 1140  *--------------------------------
 1150  LOMEM         .EQ $67,68
 1160  HIMEM         .EQ $73,74
 1170  PP            .EQ $CA,CB
 1180  *--------------------------------
 1190  BLOCK.BUFFER  .EQ $7C00
 1200  TS.LIST       .EQ $7E00
 1210  *--------------------------------
 1220  MON.RDKEY     .EQ $FD0C
 1230  MON.CROUT     .EQ $FD8E
 1240  MON.PRHEX     .EQ $FDDA
 1250  MON.COUT      .EQ $FDED
 1260  *--------------------------------
 1270  DOS.LOAD
 1280         LDY #EM3     "SLOT:"
 1290         LDA #"8"     1...7
 1300         JSR GETNUM   00000SSS
 1310         LSR          000000SS S
 1320         ROR          S000000S S
 1330         ROR          SS000000 S
 1340         ROR          SSS00000
 1350         STA UNIT
 1360         LDY #EM4     "DRIVE:"
 1370         LDA #"3"     1...2
 1380         JSR GETNUM
 1390         LSR
 1400         LSR
 1410         ROR UNIT     DSSS0000
 1420  *--------------------------------
 1430  LOAD.MENU
 1440         JSR SETUP.SCREEN
 1450         LDA #17           TRACK 17
 1460         LDX #0            SECTOR 0
 1470         STX DONE.FLAG
 1480         STX PNTR
 1490         JSR RTS           READ DOS 3.3 VTOC
 1500         STX PNTR+1        SET POINTER
 1510  *--------------------------------
 1520  NEXT.CAT.SECTOR
 1530         JSR READ.NEXT.CATALOG.SECTOR
 1540         BCS END.OF.CATALOG
 1550         LDY #$0B
 1560  *--------------------------------
 1570  NEXT.FILE.NAME
 1580         STY CAT.INDEX
 1590         LDA (PNTR),Y      TRACK
 1600         BEQ END.OF.CATALOG
 1610         BMI GET.NEXT.FILE ...DELETED FILE
 1620         STA TRACK
 1630         INY
 1640         LDA (PNTR),Y
 1650         STA SECTOR
 1660         INY
 1670         LDA (PNTR),Y      FILE TYPE
 1680         ASL               INGORE LOCK BIT
 1690         CMP #2            MUST BE TYPE I
 1700         BNE GET.NEXT.FILE ...NOT I, SKIP OVER IT
 1710  *---DISPLAY MENU LINE------------
 1720         LDA MENU.LETTER
 1730         JSR MON.COUT      DISPLAY MENU LETTER,
 1740         INC MENU.LETTER
 1750         LDA #"-"
 1760         JSR MON.COUT      ...TWO DASHES
 1770         JSR MON.COUT
 1780         LDX #30
 1790  .1     INY
 1800         LDA (PNTR),Y
 1810         ORA #$80
 1820         JSR MON.COUT      ...AND FILENAME
 1830         DEX
 1840         BNE .1
 1850         JSR MON.CROUT
 1860  *---SAVE T/S OF TS-LIST----------
 1870         LDA MENU.LETTER
 1880         AND #$1F          CONVERT TO INDEX
 1890         TAX
 1900         DEX               ...SINCE LETTER INC'ED ALREADY
 1910         LDA TRACK
 1920         STA TRACKS,X
 1930         LDA SECTOR
 1940         STA SECTORS,X
 1950         DEC LINE.COUNT
 1960         BEQ MENU.SELECTION  BRANCH IF SCREEN FULL
 1970  *--------------------------------
 1980  GET.NEXT.FILE
 1990         CLC
 2000         LDA CAT.INDEX
 2010         ADC #35
 2020         TAY               BUMP INDEX
 2030         BCC NEXT.FILE.NAME
 2040         BCS NEXT.CAT.SECTOR
 2050  *--------------------------------
 2060  END.OF.CATALOG
 2070         LDA #1
 2080         STA DONE.FLAG
 2090  MENU.SELECTION
 2100         LDY #EM0          3-LINE PROMPT
 2110         JSR PRINT.MSG
 2120  .2     JSR MON.RDKEY
 2130         CMP #$E0          LOWER CASE?
 2140         BCC .3
 2150         AND #$DF          STRIP CASE
 2160  .3     CMP #" "          SPACE?
 2170         BEQ MENU.NEXT.SCREEN
 2180         CMP #$8D          RETURN?
 2190         BEQ ABORT
 2200         CMP #$9B          ESCAPE?
 2210         BEQ ABORT
 2220         CMP #"A"
 2230         BCC .2            NOT A-Z, SO IGNORE
 2240         CMP MENU.LETTER
 2250         BCS .2            BEYOND VALID VALUES
 2260  *---GET T/S LIST-----------------
 2270         AND #$1F          CONVERT LETTER TO INDEX
 2280         TAY
 2290         LDX SECTORS,Y
 2300         LDA TRACKS,Y
 2310         JSR RTS           READ TRACK/SECTOR LIST
 2320         STX PNTR+1        SET POINTER
 2330         LDY #0
 2340  .4     LDA (PNTR),Y      MOVE T/S LIST TO ITS BUFFER
 2350         STA TS.LIST,Y
 2360         INY
 2370         BNE .4
 2380  *---GET THE FILE SIZE------------
 2390         LDY #$0C          POINT AT FIRST T/S
 2400         STY CAT.INDEX
 2410         LDA TS.LIST,Y     TRACK
 2420         BEQ ERR.EMPTY.FILE
 2430         LDX TS.LIST+1,Y   SECTOR
 2440         JSR RTS           READ FIRST SECTOR
 2450         STX PNTR+1
 2460         LDY #0
 2470         LDA (PNTR),Y      GET FILE SIZE
 2480         STA SIZE
 2490         INY
 2500         LDA (PNTR),Y
 2510         STA SIZE+1
 2520  *---MAKE ROOM FOR FILE-----------
 2530         SEC
 2540         LDA HIMEM
 2550         SBC SIZE
 2560         STA PP            SET ASSEMBLER'S POINTER
 2570         STA LPTR+1        AND OUR LOAD POINTER
 2580         LDA HIMEM+1
 2590         SBC SIZE+1
 2600         STA PP+1
 2610         STA LPTR+2
 2620         CMP LOMEM+1
 2630         BCC ERR.TOO.BIG   ...TOO LOW
 2640  *---LOAD FROM 1ST SECTOR---------
 2650         INY               POINT AT FIRST PROGRAM BYTE
 2660  .5     JSR LOAD.FROM.SECTOR
 2670         BCS ABORT         ...END OF LOAD
 2680  *---LOAD REST OF FILE------------
 2690         LDY CAT.INDEX
 2700         INY
 2710         INY
 2720         BEQ ABORT
 2730         STY CAT.INDEX     NEXT TRACK/SECTOR
 2740         LDA TS.LIST,Y     TRACK
 2750         BEQ ABORT         ...END OF FILE
 2760         LDX TS.LIST+1,Y   SECTOR
 2770         JSR RTS           READ IT
 2780         STX PNTR+1        SET POINTER
 2790         LDY #0
 2800         BEQ .5            ...ALWAYS
 2810  *--------------------------------
 2820  ABORT  JMP $8003         WARMSTART ASSEMBLER
 2830  *--------------------------------
 2840  MENU.NEXT.SCREEN
 2850         LDA DONE.FLAG
 2860         BEQ .1
 2870         JMP LOAD.MENU     START ALL OVER
 2880  .1     JSR SETUP.SCREEN
 2890         JMP GET.NEXT.FILE
 2900  *--------------------------------
 2910  ERR.EMPTY.FILE
 2920         LDY #EM1
 2930         .HS 2C
 2940  ERR.TOO.BIG
 2950         LDY #EM2
 2960         JSR PRINT.MSG
 2970         JMP $8003
 2980  *--------------------------------
 2990  PRINT.MSG
 3000  .1     LDA EMS,Y
 3010         BEQ .2            00 IS END OF MESSAGE
 3020         JSR MON.COUT
 3030         INY
 3040         BNE .1            ...ALWAYS
 3050  .2     RTS
 3060  *--------------------------------
 3070  GETNUM
 3080         STA LIMIT
 3090         JSR PRINT.MSG     PROMPT
 3100  .1     JSR MON.RDKEY
 3110         CMP #"1"
 3120         BCC .1            GO BACK IF TOO SMALL
 3130         CMP LIMIT
 3140         BCS .1            ...OR TOO LARGE
 3150         JSR MON.COUT      ECHO CHARACTER
 3160         EOR #"0"          EXTRACT VALUE
 3170         RTS
 3180  *--------------------------------
 3190  READ.NEXT.CATALOG.SECTOR
 3200         LDA #$0B          RESTART INDEX
 3210         STA CAT.INDEX
 3220         SEC               IN CASE NO MORE SECTORS
 3230         LDY #2
 3240         LDA (PNTR),Y
 3250         TAX               SECTOR
 3260         DEY
 3270         LDA (PNTR),Y      TRACK
 3280         BEQ .1            END OF CATALOG
 3290         JSR RTS           READ IT
 3300         STX PNTR+1        PAGE IN BUFFER
 3310         CLC               SIGNAL WE GOT A SECTOR
 3320  .1     RTS
 3330  *--------------------------------
 3340  *   READ TRACK/SECTOR
 3350  *      (A)=TRACK, (X)=SECTOR
 3360  *      RETURNS (X)=PAGE OF BUFFER CONTAINING SECTOR
 3370  *              CARRY SET IF ERROR
 3380  *      CLOBBERS (A) AND (Y)
 3390  *--------------------------------
 3400  RTS
 3410         LDY #0
 3420         ASL               TRACK*8
 3430         ASL
 3440         ASL
 3450         BCC .1            BLOCK < $100
 3460         INY               BLOCK > $0FF
 3470  .1     ASL               *2, MAKE ROOM FOR H/L FLAG BIT
 3480         ORA BLKTBL,X
 3490         ROR               H/L BIT TO CARRY
 3500         STA BLOCK
 3510         STY BLOCK+1
 3520         LDX /BLOCK.BUFFER
 3530         BCC .2            LOWER HALF OF BLOCK
 3540         INX               UPPER HALF OF BLOCK
 3550  .2     JSR $BF00
 3560         .DA #$80,PARMLIST
 3570         BCS .3            ...ERROR
 3580         RTS
 3590  .3     PHA               SAVE ERROR CODE
 3600         LDY #EM5          "ERROR"
 3610         JSR PRINT.MSG
 3620         PLA
 3630         JSR MON.PRHEX     DISPLAY CODE
 3640         JMP $8003         SOFTLY BACK TO S-C MACRO
 3650  *--------------------------------
 3660  SETUP.SCREEN
 3670         LDA #20           LINES PER SCREEN
 3680         STA LINE.COUNT
 3690         LDA #"A"          START MENU WITH LETTER "A"
 3700         STA MENU.LETTER
 3710         JSR MON.CROUT     THREE BLANK LINES
 3720         JSR MON.CROUT
 3730         JMP MON.CROUT     RETURN THROUGH CROUT
 3740  *--------------------------------
 3750  *      RETURN .CS. IF END OF LOAD
 3760  *--------------------------------
 3770  LOAD.FROM.SECTOR
 3780         LDA LPTR+1        IS THERE ROOM FOR
 3790         CMP HIMEM         ANOTHER BYTE?
 3800         LDA LPTR+2
 3810         SBC HIMEM+1
 3820         BCS LFS2          NO, END OF LOAD
 3830         LDA (PNTR),Y
 3840  LPTR   STA $5555
 3850         INC LPTR+1
 3860         BNE .1
 3870         INC LPTR+2
 3880  .1     INY
 3890         BNE LOAD.FROM.SECTOR
 3900  LFS2   RTS
 3910  *--------------------------------
 3920  EMS
 3930  EM0    .EQ *-EMS
 3940         .HS 8D
 3950         .AS -/TYPE LETTER TO LOAD A FILE,/
 3960         .HS 8D
 3970         .AS -/OR <SPACE> FOR MORE FILES,/
 3980         .HS 8D
 3990         .AS -/OR <RET> OR <ESC> TO ABORT:  /
 4000         .HS 00
 4010  EM1    .EQ *-EMS
 4020         .HS 8D
 4030         .AS -/FILE IS EMPTY/
 4040         .HS 00
 4050  EM2    .EQ *-EMS
 4060         .HS 8D
 4070         .AS -/FILE IS TOO BIG/
 4080         .HS 00
 4090  EM3    .EQ *-EMS
 4100         .AS -/ SLOT: /
 4110         .HS 00
 4120  EM4    .EQ *-EMS
 4130         .HS 8D
 4140         .AS -/DRIVE: /
 4150         .HS 00
 4160  EM5    .EQ *-EMS
 4170         .HS 8D
 4180         .AS -/ERROR /
 4190         .HS 00
 4200  *--------------------------------
 4210  BLKTBL .HS 00.0E.0D.0C.0B.0A.09.08
 4220         .HS 07.06.05.04.03.02.01.0F
 4230  *--------------------------------
 4240  PARMLIST
 4250         .DA #3
 4260  UNIT   .HS 60            DRIVE-1*8+SLOT*16
 4270         .DA BLOCK.BUFFER
 4280  BLOCK  .DA 2
 4290  *--------------------------------
 4300  TRACKS  .BS 21
 4310  SECTORS .BS 21

