10 ;BINARY LOAD MENU PROGRAM
20 ;NAME OBJECT FILE D:AUTORUN.SYS
30 ;
40 ; RICHARD J. KALAGHER
50 ;
60 ;ANALOG #17  MARCH 1984
70 ;
80 SL    =   $C0
90 SH    =   $C1
0100 STL =   $C2
0110 STH =   $C3
0120 ENL =   $C4
0130 ENH =   $C5
0140 BLL =   $C6
0150 BLH =   $C7
0160 CIO =   $E456
0170 ICCMD = $0342
0180 ICBAL = $0344
0190 ICBAH = $0345
0200 ICAX1 = $034A
0210 ICAX2 = $034B
0220 ICBLL = $0348
0230 ICBLH = $0349
0240 ROWCRS = 84
0250 COLCRS = 85
0260 CRSINH = $02F0
0270     *=  $1D7C
0280 MENU JSR OPENSC
0290     JSR HEADER
0300     JSR OPEDIR
0310 GG  JSR GETDIR
0320     BMI FOOT
0330     JSR DIRSCN
0340     JMP GG
0350 FOOT JSR FOOTER
0360     JSR CLOSE2
0370     JSR CLOSE3
0380     JSR SETUP
0390     JSR OPENK
0400     JSR GETLET
0410     JSR CLOSE3
0420     JSR FINDNA
0430     JSR OPEFIL
0440 GETFIL JSR READ2
0450     JSR INIT
0460     JSR CHKFF
0470     JSR STRAD
0480     JSR READ2
0490     JSR ENDAD
0500     JSR BUFLEN
0510     JSR GETDAT
0520     BMI JSTART
0530     JSR JINIT
0540     JMP GETFIL
0550 JINIT JMP ($02E2)
0560 JSTART JSR CLOSE2
0570     JMP ($02E0)
0580 R   RTS 
0590 INIT LDA #R&$FF
0600     STA $02E2
0610     LDA #R/256
0620     STA $02E3
0630     RTS 
0640 OPEDIR LDX #$20
0650     LDA #3
0660     STA ICCMD,X
0670     LDA #6
0680     STA ICAX1,X
0690     LDA #B1&$FF
0700     STA ICBAL,X
0710     LDA #B1/256
0720     STA ICBAH,X
0730     JSR CIO
0740     RTS 
0750 B1  .BYTE "D1:*.*"
0760 FNAME *= *+18
0770     .BYTE $9B
0780 BAL .BYTE 0
0790 BAH .BYTE 0
0800 OPEFIL LDX #$20
0810     LDA #3
0820     STA ICCMD,X
0830     LDA #FNAME&$FF
0840     STA ICBAL,X
0850     LDA #FNAME/256
0860     STA ICBAH,X
0870     LDA #4
0880     STA ICAX1,X
0890     JSR CIO
0900     RTS 
0910 GETREC LDX #$20
0920     LDA #7
0930     STA ICCMD,X
0940     LDA SL
0950     STA ICBAL,X
0960     LDA SH
0970     STA ICBAH,X
0980     LDA BLL
0990     STA ICBLL,X
1000     LDA BLH
1010     STA ICBLH,X
1020     JSR CIO
1030     RTS 
1040 READ2 LDA #BAL&$FF
1050     STA SL
1060     LDA #BAL/256
1070     STA SH
1080     LDA #2
1090     STA BLL
1100     LDA #0
1110     STA BLH
1120     JSR GETREC
1130     RTS 
1140 BUFLEN LDA ENL
1150     SEC 
1160     SBC STL
1170     STA BLL
1180     LDA ENH
1190     SBC STH
1200     STA BLH
1210     CLC 
1220     LDA BLL
1230     ADC #1
1240     STA BLL
1250     LDA BLH
1260     ADC #0
1270     STA BLH
1280     RTS 
1290 STRAD LDA BAL
1300     STA STL
1310     LDA BAH
1320     STA STH
1330     RTS 
1340 ENDAD LDA BAL
1350     STA ENL
1360     LDA BAH
1370     STA ENH
1380     RTS 
1390 CHKFF LDX BAL
1400     INX 
1410     BEQ TEST2
1420     RTS 
1430 TEST2 LDX BAH
1440     INX 
1450     BEQ ITSFF
1460     RTS 
1470 ITSFF JSR READ2
1480     RTS 
1490 GETDAT LDA STL
1500     STA SL
1510     LDA STH
1520     STA SH
1530     JSR GETREC
1540     RTS 
1550 CLOSE3 LDX #$30
1560     JMP CLB
1570 CLOSE2 LDX #$20
1580 CLB LDA #$0C
1590     STA ICCMD,X
1600     JSR CIO
1610     RTS 
1620 GETDIR LDX #$20
1630     LDA #5
1640     STA ICCMD,X
1650     LDA #FNAME&$FF
1660     STA ICBAL,X
1670     LDA #FNAME/256
1680     STA ICBAH,X
1690     LDA #18
1700     STA ICBLL,X
1710     LDA #0
1720     STA ICBLH,X
1730     JSR CIO
1740     RTS 
1750 OPENSC LDX #$30
1760     LDA #3
1770     STA ICCMD,X
1780     LDA #B4&$FF
1790     STA ICBAL,X
1800     LDA #B4/256
1810     STA ICBAH,X
1820     LDA #8
1830     STA ICAX1,X
1840     LDA #0
1850     STA ICAX2,X
1860     JSR CIO
1870     LDA #1
1880     STA CRSINH
1890     RTS 
1900 B4  .BYTE "E:"
1910 WRITES LDX #$30
1920     LDA #$0B
1930     STA ICCMD,X
1940     LDA STL
1950     STA ICBAL,X
1960     LDA STH
1970     STA ICBAH,X
1980     LDA BLL
1990     STA ICBLL,X
2000     LDA BLH
2010     STA ICBLH,X
2020     JSR CIO
2030     RTS 
2040 HEADER LDA #1
2050     STA ROWCRS
2060     LDA #10
2070     STA COLCRS
2080     LDA #B5&$FF
2090     STA STL
2100     LDA #B5/256
2110     STA STH
2120     LDA #16
2130     STA BLL
2140     LDA #0
2150     STA BLH
2160     JSR WRITES
2170     INC ROWCRS
2180     RTS 
2190 B5  .BYTE "    Disk Menu   "
2200 NUMKEY .BYTE "A"
2210 OFFSET .BYTE 0
2220 DIRSCN JSR CHKSYS
2230     JSR CHKFRE
2240     LDA #FNAME&$FF
2250     STA STL
2260     LDA #FNAME/256
2270     STA STH
2280     LDA #10
2290     STA BLL
2300     LDA #0
2310     STA BLH
2320     INC ROWCRS
2330     LDY #6
2340     LDA NUMKEY
2350     CMP #78
2360     BCC FIRCOL
2370     LDY #24
2380     LDA ROWCRS
2390     CMP #16
2400     BNE FIRCOL
2410     LDA #3
2420     STA ROWCRS
2430 FIRCOL STY COLCRS
2440     LDA NUMKEY
2450     STA FNAME
2460     LDA #45
2470     STA FNAME+1
2480     JSR PUTBUF
2490     JSR WRITES
2500     INC NUMKEY
2510     RTS 
2520 CHKSYS LDA FNAME+10
2530     CMP #83
2540     BNE NOTSYS
2550     LDA FNAME+11
2560     CMP #89
2570     BNE NOTSYS
2580     LDA FNAME+12
2590     CMP #83
2600     BNE NOTSYS
2610     PLA 
2620     PLA 
2630 NOTSYS RTS 
2640 CHKFRE LDA FNAME+1
2650     CMP #$20
2660     BEQ NOTFRE
2670     PLA 
2680     PLA 
2690 NOTFRE RTS 
2700 FOOTER LDA #20
2710     STA ROWCRS
2720     LDA #4
2730     STA COLCRS
2740     LDA #B6&$FF
2750     STA STL
2760     LDA #B6/256
2770     STA STH
2780     LDA #31
2790     STA BLL
2800     LDA #0
2810     STA BLH
2820     JSR WRITES
2830     RTS 
2840 B6  .BYTE "Press the letter"
2850     .BYTE " of your choice"
2860 OPENK LDX #$30
2870     LDA #3
2880     STA ICCMD,X
2890     LDA #B7&$FF
2900     STA ICBAL,X
2910     LDA #B7/256
2920     STA ICBAH,X
2930     LDA #4
2940     STA ICAX1,X
2950     JSR CIO
2960     RTS 
2970 B7  .BYTE "K:"
2980 PUTBUF LDY #0
2990     LDX OFFSET
3000     LDA (STL),Y
3010     ORA #$80
3020     STA NBUFF,X
3030     INX 
3040     INY 
3050     INY 
3060 P1  LDA (STL),Y
3070     STA NBUFF,X
3080     CMP #32
3090     BEQ P2
3100     INX 
3110     INY 
3120     CPY #10
3130     BCC P1
3140     LDA #32
3150     STA NBUFF,X
3160 P2  STX OFFSET
3170     INC OFFSET
3180     RTS 
3190 LETTER .BYTE 0
3200 FINDNA LDX #0
3210 L1  LDA NBUFF,X
3220     INX 
3230     CMP LETTER
3240     BNE L1
3250     LDA #68
3260     STA FNAME
3270     LDA #58
3280     STA FNAME+1
3290     LDY #0
3300 L2  LDA NBUFF,X
3310     STA FNAME+2,Y
3320     INX 
3330     INY 
3340     CMP #$20
3350     BNE L2
3360     DEY 
3370     LDA #46
3380     STA FNAME+2,Y
3390     INY 
3400     LDA #42
3410     STA FNAME+2,Y
3420     INY 
3430     LDA #$20
3440     STA FNAME+2,Y
3450     RTS 
3460 GETLET LDX #$30
3470     LDA #7
3480     STA ICCMD,X
3490     LDA #0
3500     STA ICBLL,X
3510     STA ICBLH,X
3520     JSR CIO
3530     CMP #65
3540     BCC GETLET
3550     CMP NUMKEY
3560     BCS GETLET
3570     ORA #$80
3580     STA LETTER
3590     RTS 
3600 SETUP LDA #R&$FF
3610     STA $02E0
3620     LDA #R/256
3630     STA $02E1
3640     RTS 
3650 NBUFF = *
3660     *=  $02E2
3670     .WORD MENU
3680     .END 
