10 PROTECT = 0
20 ATASIO =  $0F
30 ;ATARI DRIVE'S SIO VALUE
40 ; SAVE#D:HEADER.M65
50       .OPT NO LIST
60       *=  $3600
70 CURLOC =  $80
80 MAXLOC =  $82
90 EXLEN =   $84
0100 LSTBNK = $87
0110 XEUSED = $88
0120 CURBNK = $89
0130 SAVEPAS = $8A
0140 SECTOR = $8B
0150 ERRORS = $8D
0160 DRIVE = $8F
0170 DRIVDEN = $90
0180 NUMSECS = $91
0190 COMMAND = $92
0200 TSTART = $93
0210 TLEN =  $95
0220 CSECTOR = $97
0230 PASTYP = $99
0240 PASS =  $9A
0250 OFFSET = $9B
0260 LEFTOFF = $9C
0270 UNTIL = $9D
0280 BLEN =  $9E
0290 YTEMP = $A0
0300 DATA =  $A1
0310 MAXCHR = $A2
0320 INCCHR = $A3
0330 COMMAFLG = $A4
0340 DSPTMP = $A5
0350 TBUFADR = $A7
0360 SLOC =  $A9
0370 BCUR =  $AB
0380 BLOC =  $AD
0390 EXTMP = $AF
0400 EXPRT = $B1
0410 EOFFLG = $B3
0420 LASTFLG = $B4
0430 OFSET = $B5
0440 DNSTMP = $B7
0450 DNSBUF = $B8
0460 DNSB2 = $C4
0470 MAXBNK = $C8
0480 SAVBYTS = $E0
0490 ;
0500 INIT LDX #$2C
0510     LDY #0
0520     STY $CB
0530     LDA #$90
0540     STA $CC
0550     STA $CD
0560 INTM1 LDA ($CB),Y
0570     SEC 
0580     SBC $CD
0590     EOR $CD
0600       .IF PROTECT=1
0610       STA ($CB),Y
0620       .ENDIF 
0630     INC $CD
0640     INC $CD
0650     INY 
0660     BNE INTM1
0670     INC $CC
0680     DEX 
0690     BNE INTM1
0700     LDX #1904&255
0710     LDY #1904/256
0720     JSR INIT2
0730     BCC INIT3
0740     LDX #1913&255
0750     LDY #1913/256
0760     JSR INIT2
0770     BCC INIT3
0780     LDX #1921&255
0790     LDY #1921/256
0800     JSR INIT2
0810     BCC INIT3
0820     LDA 10
0830     SEC 
0840     SBC #2
0850     TAX 
0860     LDA 11
0870     SBC #0
0880     TAY 
0890     JSR INIT2
0900 INIT3 JMP START2
0910 ;
0920 INIT2 STX $CB
0930     STY $CC
0940     LDY #0
0950     LDA ($CB),Y
0960     CMP #'P
0970     BEQ INIT4
0980     CMP #'W
0990     BEQ INIT4
1000     SEC 
1010     RTS 
1020 ;
1030 INIT4 LDA $CB
1040     STA DOSVER1+1
1050     LDA $CC
1060     STA DOSVER1+2
1070     LDA VERIFY
1080     STA ($CB),Y
1090     CLC 
1100     RTS 
1110 ;
1120 TABLE .BYTE $E0,$E4,$E8,$EC,$C0,$C4,$C8,$CC,$A0,$A4,$A8,$AC,$80,$84,$88,$8C
1130 START2 LDY #$FF
1140     LDX $4000
1150     LDA $D301
1160     EOR #$10    ;TEST FOR XE
1170     STY $4000   ;MEMORY...
1180     INY 
1190     STA $D301
1200     EOR #$10
1210     STY $4000
1220     STA $D301
1230     DEY 
1240     CPY $4000
1250     STX $4000
1260     BEQ STR2A
1270     LDA #0      ;NOPE, NONE
1280     STA XERAM
1290     JMP START
1300 STR2A LDX #$0F  ;YES, FIND HOW
1310     LDY #$FF    ;MANY BANKS...
1320 BANKLP LDA $D301
1330     AND #3
1340     ORA TABLE,X
1350     STA $D301
1360     LDA $4000
1370     STA SAVBYTS,X
1380     STY $4000
1390     DEX         ;SAVE THE BYTES,
1400     BPL BANKLP  ;$FF THE FIRST
1410     LDA $D301
1420     ORA #$F0
1430     STA $D301
1440     LDA #0
1450     STA $4000
1460     LDY #0
1470     LDX #0
1480 MORELP LDA $D301
1490     AND #3
1500     ORA TABLE,X
1510     STA $D301
1520     LDA $4000
1530     CMP #$FF
1540     BNE NOTBANK
1550     LDA #0
1560     STA $4000
1570     LDA TABLE,X
1580     STA PAGESEQ,Y
1590     INY 
1600 NOTBANK INX 
1610     CPX #$10
1620     BNE MORELP
1630     LDX #$0F
1640 RESTORE LDA $D301
1650     AND #3
1660     ORA TABLE,X
1670     STA $D301   ;THE BYTES BACK
1680     LDA SAVBYTS,X
1690     STA $4000
1700     DEX 
1710     BPL RESTORE
1720     LDA $D301
1730     ORA #$F0
1740     STA $D301
1750     TYA 
1760     AND #$FC
1770     TAY 
1780     INY 
1790     STY MAXBNK
1800     LSR A
1810     LSR A
1820     STA EXFLEN
1830     JMP START
1840 EXMC1 .BYTE 125,155,155,"Use your extra 130XE RAM?",0
1850 EXMC2 .BYTE 155,"Use ALL extra RAM (a 'N' will only",155
1860     .BYTE "use the 130XE banks)?",0
1870 ;
1880 START
1890     LDA 88
1900     STA OLDWIN
1910     LDA 89
1920     STA OLDWIN+1
1930     LDA #$92
1940     STA 710
1950     LDA #12
1960     STA 709
1970     LDA #2
1980     STA 82
1990     LDA #DLIST&255
2000     STA $0230
2010     LDA #DLIST/256
2020     STA $0231
2030     JSR CLRWIND
2040     JSR SETVBL
2050     LDA #$FF
2060     STA 8
2070     LDA XERAM
2080     BEQ PRE1
2090     LDX #EXMC1&255
2100     LDY #EXMC1/256
2110     JSR PRINT
2120     JSR KGETCH
2130     JSR UPPER
2140     CMP #'Y
2150     BEQ PRE2
2160     LDA #'N
2170 PRE2 PHA 
2180     JSR OUTCHR
2190     LDA #$9B
2200     JSR OUTCHR
2210     PLA 
2220     CMP #'N
2230     BNE PRE3
2240     LDA #0
2250     STA XERAM
2260     JMP PRE1
2270 PRE3 LDA MAXBNK
2280     CMP #5
2290     BEQ PRE1
2300     LDX #EXMC2&255
2310     LDY #EXMC2/256
2320     JSR PRINT
2330     JSR KGETCH
2340     JSR UPPER
2350     CMP #'Y
2360     BEQ PRE1
2370     LDA #5
2380     STA MAXBNK
2390     LDA #1
2400     STA EXFLEN
2410 PRE1
2420     JMP NEXT1
2430 ;
2440 ;
2450     .INCLUDE #D1:DISK.M65
2460     .INCLUDE #D1:DISK2.M65
2470 ;
2480     *=  $02E0
2490     .WORD INIT
