0100 ; The Atari Wedge›0110 ;›0120 *=$1F00›0130 ICCOM =$0342›0140 ICBADR =$0344›0150 ICBLEN =$0348›0160 ICAUX1 =$034A›0170 COPN =$03›0180 CPTXTR =$09›0190 CGTXTR =$05›0200 CPBINR =$0B›0210 CCLOSE =$0C›0220 CIO =$E456›0230 OPDIR =$06›0240 HATABS =$031A›0250 LBUFF =$0580›0260 LENGTH =$CB›0270 MEMLO =$02E7›0280 PARMS =$CC›0290 COM =$CD›0300 DOSINIT =$0C›0310 ENTRY PLA ;For BASIC initialization›0320 ; Make wedge "RESET-proof"›0330 INIT›0340 LDA DOSINIT ;Save DOS›0350 STA REINIT+1 ;initialization›0360 LDA DOSINIT+1 ;inside the REINIT›0370 STA REINIT+2 ;JSR call›0380 ;›0390 INIT2 LDA #REINIT&255 ;Replace DOS init›0400 STA DOSINIT ;with Wedge›0410 LDA #REINIT/256 ;init›0420 STA DOSINIT+1›0430 JSR MSG ;Print message›0440 JSR ECHANGE ; hookup new E:›0450 LDA #ENDWEDGE&255 ;Bump up›0460 STA MEMLO›0470 LDA #ENDWEDGE/256 ;low memory pointer›0480 STA MEMLO+1›0490 RTS›0500 ;›0510 REINIT JSR XXXX ;XXXX is filled in with DOSINIT›0520 JSR INIT2›0530 XXXX RTS›0540 ;›0550 ; Print "welcome" message›0560 ;›0570 MSG LDA #WMSG&255 ;Store address of›0580 STA ICBADR ;message›0590 LDA #WMSG/256›0600 STA ICBADR+1›0610 LDA #0 ;Set length›0620 STA ICBLEN+1›0630 LDA #12›0640 STA ICBLEN›0650 LDA #CPBINR ;Ignore carriage-returns›0660 STA ICCOM›0670 LDX #0 ;File 0, the editor›0680 JSR CIO ;Call CIO to print it›0690 TYA›0700 BMI ERR ;If no error, return›0710 RTS›0720 ERR JMP ERROR›0730 ;›0740 WMSG .BYTE "Atari Wedge 2.0",155›0750 ;›0760 ; Following replaces the old E:›0770 ;›0780 ECHANGE LDY #0 ;Search for E:›0790 ELOOP LDA HATABS,Y ;in handler table›0800 CMP #'E›0810 BEQ EFOUND ;Found end?›0820 INY ;no, next entry›0830 INY›0840 CPY #34 ;end of table?›0850 BNE ELOOP›0860 RTS ;return›0870 ;›0880 ; Store new handler table address›0890 ;›0900 EFOUND INY›0910 LDA #WEDGETAB&255›0920 STA HATABS,Y›0930 INY›0940 LDA #WEDGETAB/256›0950 STA HATABS,Y›0960 ; Transfer Editor table to Wedge table›0970 LDX #0›0980 XFER LDA $E400,X›0990 STA WEDGETAB,X›1000 INX›1010 CPX #16›1020 BNE XFER›1030 ; Patch in MYINPUT routine›1040 LDA #MYINPUT-1&255›1050 STA WEDGETAB+4›1060 LDA #MYINPUT-1/256›1070 STA WEDGETAB+5›1080 CLC›1090 LDA $E404 ; Get character address›1100 ADC #1 ; Actual address is +1›1110 STA MYINPUT+1 ; Egads!›1120 LDA $E405 ; Self-modifying code!›1130 ADC #0 ;(Accept any carry)›1140 STA MYINPUT+2›1150 LDA #0›1160 STA LENGTH ;Clear length initially›1170 RTS›1180 ;›1190 ; Wedge handler address table›1200 WEDGETAB *=*+16›1210 YSAVE *=*+1 ;Used to save Y register›1220 XSAVE *=*+1 ;Ditto for X›1230 JUMPADR *=*+2 ;used for indirect JMP›1240 MYINPUT›1250 ; The $F63E address is actually placed here by above code›1260 ; to permit this routine to run on the Revision B OS›1270 ; (where it wouldn't necessarily be $F63E)›1280 JSR $F63E ;Get a character from E:›1290 PHP›1300 CMP #155 ;End of line? (CR)›1310 BEQ ENDLINE ;Yes, complete line ready›1320 INC LENGTH›1330 PLP›1340 RTS ;No, let CIO have the character›1350 ENDLINE›1360 STY YSAVE ;Save Y for CIO›1370 STX XSAVE›1380 LDA LENGTH›1390 BEQ RETURN.LINE›1400 LOOKUP›1410 LDA #COMTBL&255 ;Set up indirect pointer for›1420 STA COM›1430 LDA #COMTBL/256 ;command table›1440 STA COM+1›1450 NEXTCOM LDY #0›1460 COMPLOOP›1470 LDA (COM),Y ;Compare command against line buffer›1480 CMP LBUFF,Y ;Okay so far?›1490 BNE NOTSAME ;no match›1500 INY›1510 LDA (COM), Y ;is next character null?›1520 BEQ COMFOUND ;yes, command found›1530 CPY LENGTH ;exceeded limits?›1540 BNE COMPLOOP ;if not, continue comparison›1550 JMP RETURN.LINE ;give line to language›1560 NOTSAME CMP #255 ;End of table?›1570 BEQ RETURN.LINE›1580 LDY #0 ;No, skip over command›1590 FINDEND LDA (COM),Y›1600 BEQ ENDCOM ;Hit the zero yet?›1610 INC COM ;No, next character›1620 BCC NOINC1›1630 INC COM+1›1640 NOINC1 JMP FINDEND ;continue until null byte found›1650 ENDCOM CLC ;Add 3 to skip over null byte›1660 LDA COM ;and JMP address›1670 ADC #3›1680 STA COM›1690 BCC NOINC2 ;Check for carry›1700 INC COM+1›1710 NOINC2 JMP NEXTCOM›1720 COMFOUND›1730 INY›1740 STY PARMS ;Y is index into parameters›1750 LDA (COM),Y ;Load JUMPADR with command address›1760 STA JUMPADR›1770 INY›1780 LDA (COM),Y›1790 STA JUMPADR+1›1800 JMP (JUMPADR) ;Execute'›1810 EXIT LDY #0 ;Commands return here›1820 LDA #'. ;Change first character to›1830 STA LBUFF,Y ;"." or REM›1840 ; Allows BASIC to ignore line›1850 RETURN.LINE›1860 LDA #0›1870 STA LENGTH›1880 NOAUTO›1890 LDA #155 ;Return EOL to CIO›1900 LDY YSAVE ;Restore Y›1910 LDX XSAVE ;and X›1920 PLP ;and processor status›1930 RTS ;That's it›1940 COMTBL›1950 ; Wedge commands and command table›1960 ; Format is:›1970 ; .BYTE "COMMAND",0›1980 ; .WORD COMMAND.ADDRESS›1990 ; End of table is›2000 ; .BYTE 255›2010 .BYTE "DIR",0›2020 .WORD DIR›2030 .BYTE "SCRATCH",0›2040 .WORD SCRATCH›2050 .BYTE "LOCK",0›2060 .WORD LOCK›2070 .BYTE "UNLOCK",0›2080 .WORD UNLOCK›2090 .BYTE "RENAME",0›2100 .WORD RENAME›2110 .BYTE "KILL",0›2120 .WORD KILL›2130 .BYTE 255›2140 ;›2150 DIRBUF *=*+20›2160 DIRNAME .BYTE "D:*.*"›2170 ;›2180 ; Start of commands:›2190 ;›2200 DIR›2210 LDX #$50 ; IOCB#5›2220 LDA #CCLOSE›2230 STA ICCOM,X›2240 JSR CIO ;CLOSE#5›2250 ; OPEN#5,6,0,"D:*.*"›2260 LDX #$50 ;channel#5›2270 LDA #COPN ;open command›2280 STA ICCOM,X›2290 LDA #OPDIR ;speical "directory" command›2300 STA ICAUX1,X›2310 LDA #DIRNAME&255 ;filename (wildcard)›2320 STA ICBADR,X›2330 LDA #DIRNAME/256›2340 STA ICBADR+1,X›2350 JSR CIO ;set it up!›2360 TYA›2370 BPL NOERR1›2380 JMP ERROR›2390 ; Print a line to the Editor›2400 NOERR1›2410 NEXT LDX #$50 ;#5›2420 LDA #CGTXTR ;Get a line›2430 STA ICCOM,X›2440 LDA #DIRBUF&255 ;Put it into the buffer›2450 STA ICBADR,X›2460 STA ICBADR›2470 LDA #DIRBUF/256›2480 STA ICBADR+1,X›2490 STA ICBADR+1›2500 LDA #20 ; Maximum length is 20›2510 STA ICBLEN,X ;(actually 17)›2520 STA ICBLEN›2530 JSR CIO›2540 TYA ;Check for end of file›2550 BMI ENDIR ;On error, finished directory›2560 NOERR2 LDA #CPTXTR ;Put text record (print a line)›2570 STA ICCOM›2580 LDX #0 ; Channel 0 is open to the Editor›2590 JSR CIO›2600 JMP NEXT ;Read next line›2610 ;›2620 ENDIR LDX #$50 ;CLOSE#5›2630 LDA #CCLOSE›2640 STA ICCOM,X›2650 JSR CIO›2660 JMP EXIT›2670 ;End of directory routine›2680 ;›2690 ;Following routine is used by lock›2700 ;unlock, scratch, and rename›2710 ;Filename buffer is in LBUFF›2720 ;e.g. LOCK D:TEMP›2730 ; this ^ portion is used›2740 ; to tell CIO the filename.›2750 CALLCIO›2760 LDX #$50 ;Use file 5 (XIO n,#5,etc.)›2770 STA ICCOM,X ;Store command›2780 LDA #0 ;Clear MSB›2790 STA ICBLEN+1,X ;of length›2800 LDY LENGTH›2810 STA LBUFF,Y›2820 SEC ;Get length›2830 TYA ;of filename›2840 SBC PARMS ;(skip over command name)›2850 STA ICBLEN,X›2860 CLC›2870 LDA #LBUFF&255 ;PARMS is start of parameters,›2880 ADC PARMS ;the space in LBUFF›2890 STA ICBADR,X ;after the command›2900 LDA #LBUFF/256›2910 ADC #0 ;Catch any carry›2920 STA ICBADR+1,X›2930 JSR CIO ;Do the job›2940 TYA›2950 BPL NOERR3›2960 JMP ERROR›2970 NOERR3 JMP EXIT›2980 ;›2990 SCRATCH LDA #33›3000 JMP CALLCIO›3010 LOCK LDA #35›3020 JMP CALLCIO›3030 UNLOCK LDA #36›3040 JMP CALLCIO›3050 RENAME LDA #32›3060 JMP CALLCIO›3070 ;›3080 ;Remove Wedge›3090 ;›3100 KILL LDA REINIT+1 ;Restore old DOS›3110 STA DOSINIT ;vector›3120 LDA REINIT+2›3130 STA DOSINIT+1›3140 JMP $E474 ;"Press" SYSTEM RESET›3150 ;›3160 ; End of current wedge›3170 ; (Although more commands can be added.)›3180 ; See future issues of COMPUTE'›3190 ;›3200 ERROR PHA ;Save error code›3210 LDX #$50 ;close file 5›3220 LDA #CCLOSE›3230 STA ICCOM,X›3240 JSR CIO›3250 PLA ;retrieve error code›3260 LDX #$FF ;reset stack›3270 TXS›3280 STA $B9 ;tell BASIC the error code›3290 JMP $B940 ;call the ERROR routine›3300 ; in the BASIC cartridge›3310 ;›3320 ENDWEDGE›3330 ; Autorun›3340 ;›3350 *=$02E0›3360 .WORD INIT›3370 ;›3380 .END›