PAGE 1 LARGE DISK FMS 05 .SET 3,0 10 ; SAVE#D:MDOS.M65 20 ; 30 ; .OPT NO LIST 40 ; .OPT NO EJECT 50 .TITLE "LARGE DISK FMS" 60 ; 70 ; 80 ; 90 ; 0100 ; 0110 ; Copyright 1984 0120 ; Charles Marslett 0130 ; Wordmark Systems 0140 ; 0150 ; Permission is granted by the 0160 ; author for any use whatsoever 0170 ; of this code, so long as this 0180 ; notice remains in the source 0190 ; code, and so long as the 0200 ; source code of this routine, 0210 ; however modified or 0220 ; unmodified, is made available 0230 ; for a nominal cost. 0240 ; 0250 ; 0260 ; LIST C,G,I 0270 ; 0280 ;*DISK I/O EQUATES 0290 ; =0031 0300 DKADDR = $31 0310 ; ; SIO NUMBER OF 0320 ; ; FIRST DISK DRIVE (D1:) =0080 0330 TODK = $80 0340 ; ; STATUS BYTE 0350 ; ; FOR DATA WRITE TO THE DISK =0040 0360 FROMDK = $40 0370 ; ; STATUS BYTE 0380 ; ; FOR DATA READ FROM THE DISK 0390 ; =0052 0400 READ = 'R 0410 ; ; SIO COMMAND 0420 ; ; EQUATE FOR READING A DISK =0050 0430 WRITE = 'P 0440 ; ; SIO COMMAND 0450 ; ; EQUATE FOR WRITING A DISK =0053 0460 RDSTAT = 'S 0470 ; ; SIO COMMAND 0480 ; ; EQUATE FOR READING 0490 ; ; THE DRIVE STATUS =0057 0500 WRITEV = 'W 0510 ; ; SIO COMMAND 0520 ; ; EQUATE FOR WRITING 0530 ; ; WITH VERIFY =0021 0540 FMTCMD = '! 0550 ; ; SIO COMMAND 0560 ; ; TO FORMAT A DISKETTE PAGE 2 LARGE DISK FMS 0570 ; =007D 0580 LK128 = 125 0590 ; ; LOCATION OF 0600 ; ; 128 BYTE SECTOR LINK =00FD 0610 LK256 = 253 0620 ; ; LOCATION OF 0630 ; ; 256 BYTE SECTOR LINK 0640 ; =0008 0650 WARMST = $08 =000A 0660 DOSVEC = $0A =000C 0670 DOSINI = $0C 0680 ; 0000 0690 *= $20 0020 0700 ICHIDZ *= *+1 0021 0710 ICDNOZ *= *+1 0022 0720 ICCOMZ *= *+1 0023 0730 ICSTAZ *= *+1 0024 0740 ICBALZ *= *+1 0025 0750 ICBAHZ *= *+1 0026 0760 ICPTLZ *= *+2 0028 0770 ICBLLZ *= *+1 0029 0780 ICBLHZ *= *+1 002A 0790 ICAX1Z *= *+1 002B 0800 ICAX2Z *= *+1 002C 0810 *= *+2 002E 0820 CURFCB *= *+1 002F 0830 DATBYT *= *+1 0840 ; 0030 0850 *= $31 0031 0860 CHKSUM *= *+1 0032 0870 BUFR *= *+2 0880 ; 0034 0890 *= $43 0043 0900 FMSZPG *= *+2 =0043 0910 DIRDSP = FMSZPG =0044 0920 DIRSEC = FMSZPG+1 0045 0930 CURFNO *= *+1 0046 0940 FMSBPT *= *+2 0048 0950 TMP1 *= *+1 0049 0960 TMP2 *= *+1 0970 ; 0980 ;*DEFINITIONS FOR THE ATARI ROM 0990 ; EXECUTIVE 1000 ; =0246 1010 DSKTIM = $0246 =02E0 1020 RUNADR = $02E0 =02E2 1030 INIADR = $02E2 =02E7 1040 MEMTOP = $02E7 =02EA 1050 DVSTAT = $02EA 1060 ; 1070 ;*SIO COMMAND BUFFER DEFINITION 1080 ; 004A 1090 *= $0300 0300 1100 DDEVIC *= *+1 0301 1110 DUNIT *= *+1 0302 1120 DCOMND *= *+1 0303 1130 DSTATS *= *+1 0304 1140 DBUFLO *= *+1 PAGE 3 LARGE DISK FMS 0305 1150 DBUFHI *= *+1 0306 1160 DTIMLO *= *+2 0308 1170 DBYTLO *= *+1 0309 1180 DBYTHI *= *+1 030A 1190 DAUX1 *= *+1 030B 1200 DAUX2 *= *+1 1210 ; 1220 ;*I/O SYSTEM DEFINITIONS 1230 ; =031A 1240 HATABS = $031A 1250 ; ; BASE OF THE 1260 ; ; DYNAMIC HANDLER TABLE 1270 ; 1280 ; 1290 ;*CIO COMMAND TABLE BASE 1300 ; DEFINITIONS (FOR IOCB #00) 1310 ; 030C 1320 *= $0340 0340 1330 ICHID *= *+1 0341 1340 ICDNO *= *+1 0342 1350 ICCOM *= *+1 0343 1360 ICSTA *= *+1 0344 1370 ICBAL *= *+1 0345 1380 ICBAH *= *+1 0346 1390 ICPTL *= *+1 0347 1400 ICPTH *= *+1 0348 1410 ICBLL *= *+1 0349 1420 ICBLH *= *+1 034A 1430 ICAX1 *= *+1 034B 1440 ICAX2 *= *+1 034C 1450 ICSPR *= *+4 1460 ; 1470 ;*CARTRIDGE SUBSYSTEM EQUATES 1480 ; =BFFE 1490 CARINIT = $BFFE 1500 ; ; LOCATION OF 1510 ; ; INITIALIZATION VECTOR =BFFC 1520 CARTEST = $BFFC 1530 ; ; LOCATION OF 1540 ; ; CART? FLAG =BFFA 1550 CARRUN = $BFFA 1560 ; ; LOCATION OF 1570 ; ; CART RUN VECTOR 1580 ; 1590 ;*800XL MAP CONTROL 1600 ; =D301 1610 MAPREG = $D301 1620 ; 1630 ;*OTHER I/O PORT DEFINITIONS 1640 ; =D40E 1650 NMIEN = $D40E 1660 ; 1670 ;*ROM VECTORS 1680 ; =E453 1690 DSKINV = $E453 1700 ; ; SINGLE DENSITY 1710 ; ; DISK I/O ENTRY POINT =E459 1720 SIOV = $E459 PAGE 4 LARGE DISK FMS 1730 ; ; SERIAL I/O OS 1740 ; ; ENTRY POINT 1750 ; 1760 ; ; DATA AND CODE 1770 ; ; THAT REMAINS FIXED 1780 .INCLUDE #D:MDOS1.M65 10 ; SAVE#D:MDOS1.M65 20 ; 30 ;================================ 40 ;= MYDOS BOOT CODE == 50 ;================================ 60 ; 70 ;*DISK BOOT SECTORS (3) 80 ; 90 ; 0100 ; 0350 0110 *= $0700 0120 ; ; DOS BOOTS TO 0130 ; ; (LOADS AT) 0700 0140 ; 0150 ; 0700 0160 BOOTFL 0170 ; ; INDICATE MYDOS 0700 4D 0180 .BYTE 'M ; 4.50 OR LATER 0190 ; 0200 ;*BEGIN OS REQUIRED DATA FOR 0210 ; BOOTING ANY DISK 0220 ; 0701 0230 BOOTL 0240 ; ; # OF SECTORS 0701 03 0250 .BYTE 3 ; TO BOOT IN 0260 ; 0702 0270 BOOTAD 0280 ; ; ADDRESS TO 0702 0007 0290 .WORD BOOTFL ; LOAD BOOT 0300 ; ; CODE TO IN RAM 0704 0310 BOOTIN 0704 E007 0320 .WORD INIT ; DOSINI 0330 ; 0706 4C1407 0340 JMP INBOOT ; JUMP TO BOOT 0350 ; ; CONTINUATION CODE AFTER OS 0360 ; ; BOOTUP ROUTINES RUN 0370 ; 0380 ;*END OF OS REQUIRED BOOT DATA 0390 ; 0400 ; 0709 0410 FILES 0420 ; ; NUMBER OF 0709 03 0430 .BYTE 3 ; FILES THAT MAY 0440 ; ; BE OPEN AT ONCE 0450 ; 070A 0460 RAMDKU 0470 ; ; RAM DISK #, IT 070A 09 0480 .BYTE $09 ; USED TO BE BIT 0490 ; ; PATTERN FOR DRIVES 0500 ; ; AS USED BY DOS 2.0 0510 ; 070B 0520 DEFAULT PAGE 5 LARGE DISK FMS D:MDOS1.M65 0530 ; ; DEFAULT DRIVE 070B 01 0540 .BYTE 1 ; NUMBER, USED 0550 ; ; TO BE BUFFER 0560 ; ; ALLOCATION DIR. 0570 ; 070C 0580 DOSEND 0590 ; ; ADDRESS OF THE 070C E41A 0600 .WORD BOOTND ; FIRST BYTE 0610 ; ; OF FREE MEMORY 0620 ; ; eg - FILE BUFFERS 0630 ; 070E 0640 SECDAT 0650 ; ; 1=128 BYTE 070E 01 0660 .BYTE 1 ; 2=256 BYTE 0670 ; ; SECTORS 0680 ; 070F 0690 DOSLOC 0700 ; ; SECTOR # OF 070F 0400 0710 .WORD 4 ; DOS.SYS FILE 0720 ; 0711 0730 DLINK 0740 ; ; OFFSET TO 0711 7D 0750 .BYTE LK128 ; SECTOR LINK 0760 ; ; FIELD 0770 ; 0712 0780 DOSAD 0790 ; ; ADDRESS TO 0712 150B 0800 .WORD BASE ; LOAD DOS.SYS 0810 ; ; FILE TO 0820 ; 0830 ;*BOOT CONTINUATION CODE 0840 ; 0714 0850 INBOOT 0860 ; ; SET UP START 0714 AC1207 0870 LDY DOSAD ; OF DOS AS 0880 ; ; BUFFER ADDRESS 0717 AD1307 0890 LDA DOSAD+1 ; LOW ADDR IN Y, 071A 205807 0900 JSR BTSET ; HIGH IN A 0910 ; 071D AD1007 0920 LDA DOSLOC+1 ; PUT DOS DISK 0720 AC0F07 0930 LDY DOSLOC ; ADDR INTO A,Y 0940 ; 0950 ;*DOS.SYS INPUT LOOP 0960 ; 0723 0970 INITLP 0723 18 0980 CLC ; CY=0=READ 0724 AE0E07 0990 LDX SECDAT ; GET SEC SIZE 0727 F01D 1000 BEQ NODOS ; ZERO=NO DOS 0729 206307 1010 JSR DKIO ; DOS'S DISK I/O 072C 3018 1020 BMI NODOS ; ERROR=RETURN/W 1030 ; ; NO-DOS ERROR 072E AC1107 1040 LDY DLINK ; POINT TO LINK 0731 B143 1050 LDA (FMSZPG),Y ; CHECK FOR 1060 ; ; NEXT LINK (10-BITS) 0733 1070 ANDCD 0733 2903 1080 AND #$03 ; BEING ZERO 0735 48 1090 PHA ; SAVE UPPER 1100 ; ; BYTE OF ADDRESS PAGE 6 LARGE DISK FMS D:MDOS1.M65 0736 C8 1110 INY 0737 1143 1120 ORA (FMSZPG),Y ; 0=LOADING 0739 F00E 1130 BEQ BOOTXT ; IS COMPLETE 073B B143 1140 LDA (FMSZPG),Y ; ELSE, IT'S 1150 ; ; THE ADDRESS OF 1160 ; ; NEXT SECTOR 073D 48 1170 PHA ; LOWER BYTE 073E 204D07 1180 JSR MVBUFR ; INC DCB BUFF 0741 68 1190 PLA 0742 A8 1200 TAY ; LOW BYTE IN Y 0743 68 1210 PLA ; HI BYTE ADDR 0744 90DD 1220 BCC INITLP ; CLEAR CY=READ 1230 ; 0746 1240 NODOS 0746 A9C0 1250 LDA #$C0 ; NO DOS TO BOOT 1260 ; ; ERROR CODE 0748 A0 1270 .BYTE $A0 ; TRICKY LDY $68 1280 ; ; INSTEAD OF PLA 1290 ; 0749 1300 BOOTXT 0749 68 1310 PLA 074A 1320 DOSXIT 1330 ; ; SET CARRY AND 074A 0A 1340 ASL A ; CONVERT CODE 1350 ; ; TO FINAL VALUE 1360 ; ; AT SAME TIME 1370 ; ; CY SET=SIO ERROR 1380 ; 074B A8 1390 TAY ; Y IS SIO ERROR 1400 ; ; # RETURN 1410 ; ; REGISTER 074C 60 1420 RTS ; AND EXIT 1430 ; 1440 ;*MOVE BUFFER POINTERS TO NEXT 1450 ; AREA TO BE LOADED 1460 ; 074D 1470 MVBUFR 074D AD1107 1480 LDA DLINK ; DATA BYTES 0750 18 1490 CLC ; IN EACH SECTOR 0751 6543 1500 ADC FMSZPG ; ADDED TO THE 1510 ; CURRENT BUFFER ADDRESS 0753 A8 1520 TAY ; SAVE LO BYTE 0754 A544 1530 LDA FMSZPG+1 0756 6900 1540 ADC #0 ; NOW ADD HI 0758 1550 BTSET 0758 8443 1560 STY FMSZPG ; SAVE IT TO 075A 8544 1570 STA FMSZPG+1 ; ZPAGE DCB 075C 1580 BUFSET 075C 8C0403 1590 STY DBUFLO ; SAVE IT TO 075F 8D0503 1600 STA DBUFHI ; SIO DCB 0762 60 1610 RTS 1620 ; 1630 ; 1640 ;*PERFORM DISK 1650 ; READ(CY=0) OR 1660 ; WRITE (CY=1) 1670 ; 1680 ; PAGE 7 LARGE DISK FMS D:MDOS1.M65 1690 ; 0763 1700 DKIO 1710 ; ; STORE HI-LO 0763 8D0B03 1720 STA DAUX2 ; BYTES OF SEC # 0766 8C0A03 1730 STY DAUX1 ; TO SIO DCB 0769 1740 DKIO2 0769 A003 1750 LDY #3 ; 3 RETRIES 076B A952 1760 LDA #READ 076D 9003 1770 BCC SETRTY ; CY=0=READ 076F AD7907 1780 LDA WRCMDB ; CY=1=WRITE 1790 ; 0772 1800 SETRTY 0772 8448 1810 STY TMP1 ; # OF RETRIES 0774 1820 DKFME 0774 8D0203 1830 STA DCOMND 0777 18 1840 CLC 0778 A957 1850 LDA #WRITEV ; ADDRESS 0779 = 1860 ; DOS 2.0 WRITE OR WRITE WITH 1870 ; VERIFY ADDRESS - SOME APPS 1880 ; MAY POKE ON THEIR OWN =0779 1890 WRCMDB = *-1 1900 ; 077A 8C0603 1910 STY DTIMLO 077D A980 1920 LDA #128 ; ASSUME SD 077F CA 1930 DEX 0780 F00D 1940 BEQ STBUFL 0782 AE0B03 1950 LDX DAUX2 ; 1=256SEC=DD 0785 D007 1960 BNE SET256 0787 AE0A03 1970 LDX DAUX1 078A E004 1980 CPX #4 ; SEC<=3 R/W 078C 9001 1990 BCC STBUFL ; SD ONLY 078E 2000 SET256 078E 0A 2010 ASL A ; MAKE IT DD 078F 2020 STBUFL 078F 8D0803 2030 STA DBYTLO ; STORE SEC SIZE 0792 2A 2040 ROL A ; INTO SIO DCB 0793 8D0903 2050 STA DBYTHI 0796 A031 2060 LDY #DKADDR ; D1:# INTO SIO 0798 8C0003 2070 STY DDEVIC ; DCB 079B 2080 IORTRY 079B C648 2090 DEC TMP1 ; # OF RETRIES 079D 3016 2100 BMI DIOXIT ; ALL USED UP 079F AE0203 2110 LDX DCOMND 07A2 E8 2120 INX 07A3 8A 2130 TXA 07A4 A240 2140 LDX #FROMDK ; ASSUME READ 07A6 2906 2150 AND #$06 ; 00000110 07A8 D002 2160 BNE ISREAD ; IF NOT X0,X7, 2170 ; ; X8 OR XF, OK 07AA A280 2180 LDX #TODK ; ELSE, WRITE 07AC 2190 ISREAD 2200 ; ; RESTORE STATUS 07AC 8E0303 2210 STX DSTATS ; TO DCB 07AF 2059E4 2220 JSR SIOV ; DO I/O THRU OS 07B2 88 2230 DEY 07B3 30E6 2240 BMI IORTRY ; IF BAD, RETRY 2250 ; 07B5 2260 DIOXIT PAGE 8 LARGE DISK FMS D:MDOS1.M65 2270 ; ; ELSE, LOAD FCB 07B5 A62E 2280 LDX CURFCB ; OFFSET 07B7 C8 2290 INY ; SIO ERROR # 07B8 98 2300 TYA ; DO CY FLAG 07B9 60 2310 RTS ; 2320 ; 2330 ;*FIXED RAM DEFINITIONS IN BOOT 2340 ; SECTORS 2350 ; 07BA 2360 DIUNIT 2370 ; ; UNIT # OF 07BA 2380 *= *+1 ; CURRENT DIR 07BB 2390 CDIREC 2400 ; ; SEC # OF 07BB 2410 *= *+2 ; CURRENT DIR 07BD 2420 HOLFN 2430 ; 07BD 2440 *= *+1 07BE 2450 STATE 07BE 70 2460 .BYTE $70 ; 01110000 2470 ; DUP loaded, MEM.SAV inactive 2480 ; Warmstart 2490 ; 2500 ; bit 7 -- MEM.SAV in use 2510 ; bit 6 -- DUP.SYS loaded 2520 ; bit 5 -- AUTORUN.SYS ran 2530 ; bit 4 -- Initial BUILD active 2540 ; 07BF 2550 STKPSV 2560 ; ; SAVED STACK 07BF 2570 *= *+1 ; POINTER 2580 ; 07C0 2590 *= $07C0 ; MUST MATCH DUP 2600 ; ; LOCATION 2610 ; 07C0 2620 TRACKS 2630 ; ; TRACKS IN EACH 07C0 2328504D 2640 .BYTE 35,40,80,77 ; DISK 2650 ; ; FORMAT 2660 ; 07C4 2670 SECSIZ 2680 ; ; BUFFER SIZE 07C4 00000000 2690 .BYTE 0,0,0,0 ; TABLE 07C8 00000000 2700 .BYTE 0,0,0,0 2710 ; 2720 ; 2730 ;*DRIVE CONFIGURATION TABLE 2740 ; 2750 ; 07CC 2760 DRVDEF 07CC 5252D2D2 2770 .BYTE $52,$52,$D2,$D2 07D0 D2D2D2D2 2780 .BYTE $D2,$D2,$D2,$D2 2790 ; 2800 ; BIT 7=1 => NO DRIVE 2810 ; BIT 6=1 => ATARI 810 DRIVE 2820 ; BIT 5-4 IS (0=35, 1=40, 2830 ; 2=80, 3=77 TRACKS(8") 2840 ; BIT 3=1 => DOUBLE DENSITY PAGE 9 LARGE DISK FMS D:MDOS1.M65 2850 ; BIT 2-1 IS DRIVE STEP RATE 2860 ; BIT 0=1 => DOUBLE SIDED 2870 ; 2880 ; 2890 ;*DOS HATAB VECTOR TABLE 2900 ; 2910 ; 07D4 2920 DKEPT 07D4 6D0C 2930 .WORD DKOPEN-1 07D6 6D0E 2940 .WORD DKCLOS-1 07D8 730D 2950 .WORD DKREAD-1 07DA D70D 2960 .WORD DKWRIT-1 07DC 610E 2970 .WORD DKSTAT-1 07DE 9710 2980 .WORD DKXIO-1 2990 ; 3000 ; 07E0 3010 *= $07E0 ; DOSINI 3020 ; 3030 ;*INIT DRIVE TYPES 3040 ; 07E0 3050 INIT 07E0 A969 3060 LDA # <361 07E2 8DBB07 3070 STA CDIREC 07E5 A901 3080 LDA # >361 07E7 8DBC07 3090 STA CDIREC+1 3100 ; 3110 ;*IDENTIFY DRIVE TYPES 3120 ; 07EA A208 3130 LDX #8 07EC 3140 IDRVLP 07EC 8E0103 3150 STX DUNIT 07EF 20B60B 3160 JSR ZERDVS ; ASSUME THE 3170 ; ; DRIVE IS NOT PRESENT 07F2 BDCB07 3180 LDA DRVDEF-1,X 07F5 301D 3190 BMI NXTDRV ; IF NOT 3200 ; ; DECLARED, WE ARE DONE 3210 ; 07F7 209A0B 3220 JSR JSTRD ; ELSE, READ ITS 3230 ; ; STATUS 07FA F018 3240 BEQ NXTDRV ; IF ABSENT, GO 3250 ; ; ON TO THE NEXT ONE 07FC A009 3260 LDY #9 07FE 3270 WOTCPY 07FE B9250B 3280 LDA WOTDCB,Y 0801 990203 3290 STA DDEVIC+2,Y 0804 88 3300 DEY 0805 10F7 3310 BPL WOTCPY 0807 BDCB07 3320 LDA DRVDEF-1,X 080A C940 3330 CMP #$40 080C B006 3340 BCS NXTDRV ; IF NOT 3350 ; ; CONFIGURABLE, CONTINUE 080E BCC307 3360 LDY SECSIZ-1,X 0811 202F0B 3370 JSR SETDRV ; TELL IT ABOUT 3380 ; ; MY CONFIGURATION 3390 ; 0814 3400 NXTDRV 3410 ; ; STEP TO NEXT 0814 CA 3420 DEX ; DRIVE NUMBER PAGE 10 LARGE DISK FMS D:MDOS1.M65 0815 D0D5 3430 BNE IDRVLP ; DO 'EM ALL 3440 ; 3450 ;*ZERO INITIALIZED MEMORY 3460 ; 0817 A0AE 3470 LDY #MAPBUF+7-CHGMAP 0819 8A 3480 TXA ; NOTE X=0 HERE 081A 3490 ZERLP1 081A 996008 3500 STA CHGMAP-1,Y 081D 88 3510 DEY 081E D0FA 3520 BNE ZERLP1 0820 EE6408 3530 INC MAP2MOD 3540 ; 3550 ;*DEFINE TOP OF FMS FOR USER 3560 ; PROGRAM 3570 ; 0823 AD0C07 3580 LDA DOSEND 0826 8DE702 3590 STA MEMTOP 0829 AC0D07 3600 LDY DOSEND+1 3610 ; 3620 ;*ALLOCATE FILE SECTOR BUFFERS 3630 ; 082C A20F 3640 LDX #15 ; MAX OF 16 3650 ; ; SECTOR BUFFERS 082E 3660 DKBFLP 3670 ; ; EMPTY BUFFERS 082E EC0907 3680 CPX FILES ; DONE? 0831 9005 3690 BCC ALCBUF 0833 DEE808 3700 DEC BUFFLG,X 0836 3005 3710 BMI DKBFSQ 0838 3720 ALCBUF 0838 98 3730 TYA 0839 9DF808 3740 STA SBTABU,X 083C C8 3750 INY 083D 3760 DKBFSQ 3770 ; ; BUMP BUFFER 083D CA 3780 DEX ; COUNTER 083E 10EE 3790 BPL DKBFLP ; DO 'EM ALL 0840 8CE802 3800 STY MEMTOP+1 ; SAVE MEMTOP 3810 ; 3820 ;*SET UP HANDLER VECTOR 3830 ; 0843 3840 FNDHND 3850 ; ; LOOK FOR 'D' 0843 E8 3860 INX ; IN HANDLER 0844 E8 3870 INX ; TABLE 0845 E8 3880 INX 0846 BD1803 3890 LDA HATABS-2,X 0849 F004 3900 BEQ NOHAND ; FOUND EOT - SO 3910 ; ; INSTALL 'D' 084B C944 3920 CMP #$44 ; 'D' ALREADY 3930 ; ; PRESENT? 084D D0F4 3940 BNE FNDHND ; NO, GET NEXT 3950 ; ; ENTRY 3960 ; 084F 3970 NOHAND 3980 ; ; WRITE OVER 'D' 084F A944 3990 LDA #$44 ; OR AT END OF 4000 ; ; TABLE PAGE 11 LARGE DISK FMS D:MDOS1.M65 0851 9D1803 4010 STA HATABS-2,X 0854 A9D4 4020 LDA # DKEPT ; THIS MAKES 085B 9D1A03 4050 STA HATABS,X ; IT ALL WORK 085E 4C0000 4060 JMP DUPINV ; GO DUP INIT }ERROR - 5,UNDEF 4070 ; ; [overwritten by MDUP] 4080 ; 4090 ;*DOS NON-ZERO PAGE RAM 4100 ; ALLOCATIONS 4110 ; 0861 4120 CHGMAP 0861 4130 *= *+1 0862 4140 CURMAP 0862 4150 *= *+1 0863 4160 MAP2 0863 4170 *= *+1 0864 4180 MAP2MOD 0864 4190 *= *+1 0865 4200 LSTSEC 0865 4210 *= *+2 0867 4220 LSTIOCB 0867 4230 *= *+1 4240 ; 4250 ;*MYDOS FCB STRUCTURE (ALMOST 4260 ; THE SAME AS ATARI DOS 2.0) 4270 ; 0868 4280 FCBFNO 0868 4290 *= *+1 0869 4300 FCBOTC 0869 4310 *= *+1 4320 ; ;OPEN TYPE CODE 086A 4330 FCBFLG 086A 4340 *= *+1 086B 4350 MAXLEN 086B 4360 *= *+1 086C 4370 CURLEN 086C 4380 *= *+1 086D 4390 BUFNO 086D 4400 *= *+1 086E 4410 CURSEC 086E 4420 *= *+2 0870 4430 LNKSEC 0870 4440 *= *+2 0872 4450 SECCNT 0872 4460 *= *+2 0874 4470 DIRBAS 0874 4480 *= *+2 4490 ; ; BASE ADDRESS 4500 ; ; OF CUR. SECTOR 0876 4510 SAVSEC 0876 4520 *= *+2 =0010 4530 FCBLEN = 16 0878 4540 *= *+7*FCBLEN ; SPACE FOR 4550 ; ; THE REMAINING 7 IOCBs 4560 ; 08E8 4570 BUFFLG PAGE 12 LARGE DISK FMS D:MDOS1.M65 4580 ; ; IF 0, BUFFER 08E8 4590 *= *+16 ; NOT IN USE 4600 ; 08F8 4610 SBTABU 4620 ; ; UPPER BYTE OF 08F8 4630 *= *+16 ; THE SECTOR 4640 ; ; BUFFER ADDRESS 4650 ; 0908 4660 MAPBUF 4670 ; ; SPACE FOR 0908 4680 *= *+512 ; VTOCs AND DIRs =0908 4690 DIRBUF = MAPBUF 4700 ; 0B08 4710 FNAME 0B08 4720 *= *+12 0B14 4730 CURMP 0B14 4740 *= *+1 4750 ; =0B15 4760 BASE = * 4770 ; 0B15 4780 HDTAB 4790 ; ; 8 LOGICAL HARD 0B15 0000 4800 .WORD 0,0,0,0 ; DRIVES OF 0B17 0000 0B19 0000 0B1B 0000 0B1D 0000 4810 .WORD 0,0,0,0 ; UP TO 65535 0B1F 0000 0B21 0000 0B23 0000 4820 ; ; SECTORS EACH 4830 ; 4840 ;***** 4850 ;NOTE: this table is referenced 4860 ; by DUP.SYS, and should not be 4870 ; moved! 4880 ; 4890 ;*DOS CONFIGURATION CODE 4900 ; 4910 ;*CONTROL BLOCK TO BE WRITTEN TO 4920 ; A DRIVE TO CONFIGURE IT 4930 ; 0B25 4940 WOTDCB 0B25 4E40 4950 .BYTE $4E,$40 0B27 0809 4960 .WORD DIRBUF,1 0B29 0100 0B2B 0C00 4970 .WORD 12,4 0B2D 0400 4980 ; 4990 ;*THE CONFIGURATION CODE, FORCES 5000 ; A DRIVE INTO THE APPROPRIATE 5010 ; CONFIGURATION 5020 ; 0B2F 5030 SETDRV 0B2F 293F 5040 AND #$3F ; EXTRACT CONFIG 5050 ; ; BITS 0B31 8548 5060 STA TMP1 0B33 8449 5070 STY TMP2 PAGE 13 LARGE DISK FMS D:MDOS1.M65 0B35 2059E4 5080 JSR SIOV ; READ CURRENT 5090 ; ; CONFIGURATION 0B38 3060 5100 BMI JSTRD 0B3A A548 5110 LDA TMP1 0B3C A449 5120 LDY TMP2 0B3E 4A 5130 LSR A 0B3F 48 5140 PHA ; SAVE FOR LATER 0B40 2903 5150 AND #3 ; GET STEP RATE 0B42 8D0909 5160 STA DIRBUF+1 0B45 A900 5170 LDA #0 0B47 8D0A09 5180 STA DIRBUF+2 0B4A 2A 5190 ROL A 0B4B 8D0C09 5200 STA DIRBUF+4 ; 2 SIDED FLAG 0B4E 98 5210 TYA ; GET DENSITY 0B4F 4A 5220 LSR A 0B50 8D0E09 5230 STA DIRBUF+6 ; HI SEC SIZE 0B53 6A 5240 ROR A 0B54 8D0F09 5250 STA DIRBUF+7 ; LO SEC SIZE 0B57 2A 5260 ROL A 0B58 0A 5270 ASL A 0B59 0A 5280 ASL A 0B5A 8D0D09 5290 STA DIRBUF+5 0B5D 68 5300 PLA ; BEATS REREAD 0B5E 4A 5310 LSR A 0B5F 4A 5320 LSR A 0B60 4A 5330 LSR A 0B61 A8 5340 TAY 0B62 B9C007 5350 LDA TRACKS,Y ; GET NUMBER OF 0B65 8D0809 5360 STA DIRBUF ; TRACKS 0B68 2904 5370 AND #$04 ; 77 TRACK=8" 0B6A 48 5380 PHA 0B6B 4A 5390 LSR A 0B6C 0D0D09 5400 ORA DIRBUF+5 ; MERGE DD & 8" 0B6F 8D0D09 5410 STA DIRBUF+5 ; FLAGS 0B72 68 5420 PLA 0B73 0A 5430 ASL A ; MAKE 0 OR 8 0B74 6912 5440 ADC #18 ; SECs=18 OR 26 0B76 8D0B09 5450 STA DIRBUF+3 0B79 AC0103 5460 LDY DUNIT 0B7C B91C0B 5470 LDA HDTAB-1+8,Y 0B7F F00E 5480 BEQ TOSIOV 0B81 8D0A09 5490 STA DIRBUF+2 ; SIZE=SECs/TK 0B84 B9140B 5500 LDA HDTAB-1,Y 0B87 8D0B09 5510 STA DIRBUF+3 ; LO SIZE 0B8A A901 5520 LDA #1 0B8C 8D0809 5530 STA DIRBUF ; 1 TRACK/DRIVE 0B8F 5540 TOSIOV 5550 ; ; CHANGE COMMAND 0B8F EE0203 5560 INC DCOMND ; TO WRITE 0B92 A980 5570 LDA #$80 0B94 8D0303 5580 STA DSTATS ; WRITE CONFIG 0B97 2059E4 5590 JSR SIOV ; TO DRIVE 5600 ; 0B9A 5610 JSTRD 0B9A A953 5620 LDA #RDSTAT 0B9C 8D0203 5630 STA DCOMND 0B9F 2053E4 5640 JSR DSKINV 0BA2 AE0103 5650 LDX DUNIT PAGE 14 LARGE DISK FMS D:MDOS1.M65 0BA5 98 5660 TYA 0BA6 300E 5670 BMI ZERDVS 0BA8 ADEA02 5680 LDA DVSTAT 0BAB 0A 5690 ASL A 0BAC 0A 5700 ASL A 0BAD 0A 5710 ASL A ; SEC SIZE INTO 0BAE A901 5720 LDA #1 ; CY 0BB0 6900 5730 ADC #0 0BB2 5740 SETSIZ 0BB2 9DC307 5750 STA SECSIZ-1,X ; STORE IT 0BB5 60 5760 RTS 5770 ; 0BB6 5780 ZERDVS 0BB6 A900 5790 LDA #0 0BB8 F0F8 5800 BEQ SETSIZ ; BR ALWAYS 5810 ; 5820 ;*DOS RAMDISK CODE (moved here 5830 ; starting with version 4.5) 5840 ; 5850 ;*RAM DISK I/O HANDLER 5860 ; 0BBA 5870 MAPAGE 0BBA E3E7EBEF 5880 .BYTE $E3,$E7,$EB,$EF 0BBE 83878B8F 5890 .BYTE $83,$87,$8B,$8F 0BC2 C3C7CBCF 5900 .BYTE $C3,$C7,$CB,$CF 0BC6 A3A7ABAF 5910 .BYTE $A3,$A7,$AB,$AF 5920 ; 0BCA 93979B9F 5930 .BYTE $93,$97,$9B,$9F 0BCE D3D7DBDF 5940 .BYTE $D3,$D7,$DB,$DF 0BD2 B3B7BBBF 5950 .BYTE $B3,$B7,$BB,$BF 0BD6 F3F7FBFF 5960 .BYTE $F3,$F7,$FB,$FF 5970 ; 0BDA E3E7EBEF 5980 .BYTE $E3,$E7,$EB,$EF 0BDE 83878B8F 5990 .BYTE $83,$87,$8B,$8F 0BE2 C3C7CBCF 6000 .BYTE $C3,$C7,$CB,$CF 0BE6 A3A7ABAF 6010 .BYTE $A3,$A7,$AB,$AF 6020 ; 0BEA 93979B9F 6030 .BYTE $93,$97,$9B,$9F 0BEE D3D7DBDF 6040 .BYTE $D3,$D7,$DB,$DF 0BF2 B3B7BBBF 6050 .BYTE $B3,$B7,$BB,$BF 0BF6 F3F7FBFF 6060 .BYTE $F3,$F7,$FB,$FF 6070 ; 0BFA 6080 VALSEC 0BFA 48 6090 PHA ; CALC OFFSET 0BFB 98 6100 TYA ; INTO 16K 0BFC 0980 6110 ORA #$80 ; BANK 0BFE 4A 6120 LSR A 0BFF 8533 6130 STA BUFR+1 0C01 78 6140 SEI ; DISABLE INT-S 0C02 A900 6150 LDA #0 0C04 8D0ED4 6160 STA NMIEN ; DISABLE NMI-S 0C07 6A 6170 ROR A 0C08 8532 6180 STA BUFR 0C0A 68 6190 PLA 0C0B A8 6200 TAY 0C0C AD01D3 6210 LDA MAPREG 6220 ;*L ORA #$1C ; applied Basic 0C0F EA 6221 NOP ; patch to work PAGE 15 LARGE DISK FMS D:MDOS1.M65 0C10 EA 6222 NOP ; with large & 0C11 8531 6230 STA CHKSUM 6240 ;*L ORA #$7C ; unique RD 0C13 EA 6241 NOP ; add filler nop 0C14 EA 6242 NOP ; to remain 6250 ;*L AND MAPAGE,Y ; usable... 0C15 B9BA0B 6251 LDA MAPAGE,Y ; Lee 0C18 8D01D3 6260 STA MAPREG ; SELECT RAMDISK 6270 ; ; BANK 6280 ; 0C1B AD0403 6290 LDA DBUFLO ; US SIO ADD IN 0C1E 8534 6300 STA BUFR+2 ; ZPAGE 0C20 AD0503 6310 LDA DBUFLO+1 0C23 8535 6320 STA BUFR+3 0C25 A000 6330 LDY #0 0C27 28 6340 PLP ; CY=0=READ 0C28 9018 6350 BCC RREADL ; CY=1=WRITE 0C2A 6360 RWRITL 0C2A B134 6370 LDA (BUFR+2),Y 0C2C 9132 6380 STA (BUFR),Y 0C2E C8 6390 INY 0C2F 10F9 6400 BPL RWRITL 0C31 3016 6410 BMI RIOX 6420 ; 0C33 6430 RDKIO 6440 ; ; ENTRY POINT 0C33 8C0A03 6450 STY DAUX1 ; DAUX2 IN A 0C36 C080 6460 CPY #$80 ; SET CY TO TEST 0C38 2A 6470 ROL A ; SHIFT FOR TEST 0C39 C904 6480 CMP #4 =0C3A 6490 RDKLMT = *-1 6500 ; ; NUMBER OF 16K 6510 ; ; BANKS IN RAMDISK 0C3B 90BD 6520 BCC VALSEC ; PASSED >MAX 0C3D 28 6530 PLP 0C3E A98B 6540 LDA #139 ; ALL RD ERRORS 0C40 3014 6550 BMI RERROR 6560 ; 0C42 6570 RREADL 0C42 B132 6580 LDA (BUFR),Y 0C44 9134 6590 STA (BUFR+2),Y 0C46 C8 6600 INY 0C47 10F9 6610 BPL RREADL 6620 ; 0C49 6630 RIOX 6640 ; ; GET HOME BANK 0C49 A531 6650 LDA CHKSUM ; BACK BEFORE 0C4B 8D01D3 6660 STA MAPREG ; EXITING 0C4E A9C0 6670 LDA #$C0 0C50 8D0ED4 6680 STA NMIEN ; ALLOW NMI 0C53 58 6690 CLI ; ALLOW INTs 0C54 A901 6700 LDA #1 ; SIO 'GOOD' 0C56 6710 RERROR 6720 ; ; PUT A IN 0C56 8D0303 6730 STA DSTATS ; SIO STATUS 0C59 A62E 6740 LDX CURFCB ; GET FCB # 0C5B A8 6750 TAY ; DO FLAGS REG 0C5C 60 6760 RTS ; THEN EXIT PAGE 16 LARGE DISK FMS D:MDOS1.M65 6770 ; 6780 ; 0C5D 6790 STEPBP 0C5D AD0403 6800 LDA DBUFLO 0C60 4980 6810 EOR #$80 0C62 8D0403 6820 STA DBUFLO 0C65 3003 6830 BMI TSTEOD 0C67 EE0503 6840 INC DBUFHI 6850 ; 0C6A 6860 TSTEOD 0C6A AC0A03 6870 LDY DAUX1 0C6D 60 6880 RTS 1790 ; 1800 ; ; FILE SYSTEM 1810 ; ; FUNCTIONS 1820 .INCLUDE #D:MDOS2.M65 10 ; SAVE#D:MDOS2.M65 20 ; 30 ; 40 ;*DISK OPEN ROUTINE 50 ; 0C6E 60 DKOPEN 70 ; ; Fix nasty bug! 0C6E 20E817 80 JSR WBITMP ; [Bob Puff] 0C71 20B619 90 JSR SETUP ; BUF PTRS, ETC. 0C74 202615 0100 JSR GETFNM ; GET DRIVE ID 0110 ; ; OR FILE NAME 0120 ; ; FROM BUFFER 0C77 A52A 0130 LDA ICAX1Z ; GET TYPE OF 0140 ; ; OPEN FROM IOCB 0C79 9D6908 0150 STA FCBOTC,X 0C7C 2902 0160 AND #$02 ; DIR READ? 0C7E F003 0170 BEQ DKOPN1 0C80 4CFB13 0180 JMP LSTDIR ;IF SET, GO 0190 ; ; HANDLE DIR LIST 0200 ; 0C83 0210 DKOPN1 0C83 9D7608 0220 STA SAVSEC,X 0C86 9D7708 0230 STA SAVSEC+1,X ; CLR SAVSEC 0C89 20F915 0240 JSR SFDIR 0C8C 08 0250 PHP ; SAVE STATUS 0C8D B007 0260 BCS OPNEW 0C8F A910 0270 LDA #$10 ; MAKE SURE THIS 0280 ; ; IS NOT A DIR 0C91 20D61A 0290 JSR GETFLAG 0C94 D012 0300 BNE DIROPN ; IF A DIR 0310 ; ; GO HANDLE IT 0C96 0320 OPNEW 0C96 A42A 0330 LDY ICAX1Z 0C98 C008 0340 CPY #8 0C9A F050 0350 BEQ OPNOP ; OPEN > OUTPUT 0C9C C004 0360 CPY #4 0C9E F045 0370 BEQ OPNIN ; OPEN > INPUT 0CA0 C00C 0380 CPY #12 0CA2 F035 0390 BEQ OPNUP ; OPEN > UPDATE 0CA4 C009 0400 CPY #9 0CA6 F003 0410 BEQ OPNAP ; OPEN > APPEND 0CA8 0420 DIROPN PAGE 17 LARGE DISK FMS D:MDOS2.M65 0430 ; ; IF NONE OF THE 0CA8 4C7E10 0440 JMP ERRCMD ; ABOVE - ERROR! 0450 ; 0CAB 0460 OPNAP 0CAB 28 0470 PLP ; OPEN APPEND 0CAC B047 0480 BCS OPNCR0 0CAE 20A51A 0490 JSR TSTLOK 0CB1 20EE0E 0500 JSR INITYP ; READ ALL THE 0510 ; ; SECTORS IN THE FILE 0CB4 B90909 0520 LDA DIRBUF+1,Y 0CB7 9D7208 0530 STA SECCNT,X 0CBA B90A09 0540 LDA DIRBUF+2,Y 0CBD 9D7308 0550 STA SECCNT+1,X 0CC0 0560 APPRD 0CC0 20E116 0570 JSR RDNXTS 0CC3 90FB 0580 BCC APPRD ; IF NOT EOF, 0590 ; ; READ ANOTHER 0CC5 BD6B08 0600 LDA MAXLEN,X 0CC8 20D616 0610 JSR LENSET ; SET LENGTH FOR 0620 ; ; OUTPUT 0CCB BD7208 0630 LDA SECCNT,X 0CCE D003 0640 BNE SGLDEC 0CD0 DE7308 0650 DEC SECCNT+1,X 0CD3 0660 SGLDEC 0670 ; ; ALLOW FOR 0CD3 DE7208 0680 DEC SECCNT,X ; SECT REWRITE 0CD6 4C2F0D 0690 JMP OPOUTX 0700 ; 0CD9 0710 OPNUP 0720 ; ; OPEN UPDATE 0CD9 28 0730 PLP 0CDA B00C 0740 BCS OPNER1 0CDC 20A51A 0750 JSR TSTLOK 0CDF 0760 OPNOWR 0CDF 203D17 0770 JSR INSTRT 0CE2 4CAF1A 0780 JMP DONE 0790 ; 0CE5 0800 OPNIN 0810 ; ; OPEN INPUT 0CE5 28 0820 PLP 0CE6 90F7 0830 BCC OPNOWR 0CE8 0840 OPNER1 0CE8 A9AA 0850 LDA #170 ; FILE NOT FOUND 0CEA 3064 0860 BMI EROXIT 0870 ; 0CEC 0880 OPNOP 0890 ; ; OPEN OUTPUT 0CEC 28 0900 PLP 0CED B009 0910 BCS OPNCR 0CEF 20E00F 0920 JSR REMOVE 0CF2 4CFF0C 0930 JMP GET1ST 0940 ; 0CF5 0950 OPNCR0 0CF5 DE6908 0960 DEC FCBOTC,X 0CF8 0970 OPNCR 0CF8 ADBD07 0980 LDA HOLFN 0CFB 8545 0990 STA CURFNO 0CFD 304F 1000 BMI OPDIRF PAGE 18 LARGE DISK FMS D:MDOS2.M65 0CFF 1010 GET1ST 0CFF 20EE18 1020 JSR ALLOC 1030 ; 0D02 A52B 1040 LDA ICAX2Z ; TYPE OF FILE 0D04 2924 1050 AND #$24 ; SAVE LOCKED & 1060 ; ; FORMAT BITS 1070 ; ; (with 4.5, DOS I no-more) 1080 ; 0D06 4943 1090 EOR #$43 ; MERGE IN 1100 ; ; DEFAULT CODE 1110 ; ; (DOS II, UNLOCKED) 0D08 AC0809 1120 LDY MAPBUF ; DISK TYPE? 0D0B C003 1130 CPY #3 ; >2=MYDOS(3) 0D0D 9002 1140 BCC LLINKS 0D0F 0904 1150 ORA #$04 1160 ; 0D11 1170 LLINKS 0D11 48 1180 PHA 0D12 208617 1190 JSR RDCFNO ; GET DIR SEC 0D15 38 1200 SEC 0D16 20DA15 1210 JSR ENTNAME ; PUT NAME IN IT 0D19 BD7108 1220 LDA LNKSEC+1,X 0D1C 990C09 1230 STA DIRBUF+4,Y 0D1F BD7008 1240 LDA LNKSEC,X 0D22 990B09 1250 STA DIRBUF+3,Y 0D25 68 1260 PLA 0D26 20DC1A 1270 JSR SAVFLAG 0D29 20EE0E 1280 JSR INITYP 0D2C 20C216 1290 JSR TONXT 0D2F 1300 OPOUTX 0D2F A980 1310 LDA #$80 0D31 9D6A08 1320 STA FCBFLG,X 0D34 20791A 1330 JSR TSTDOS ; DOS.SYS? 0D37 D038 1340 BNE JDONE 0D39 BC6E08 1350 LDY CURSEC,X 0D3C BD6F08 1360 LDA CURSEC+1,X 0D3F 20171A 1370 JSR SETDOS ; YES, UPDATE 1380 ; ; BOOT SECTORS 0D42 AD1207 1390 LDA DOSAD 0D45 8543 1400 STA FMSZPG 0D47 AD1307 1410 LDA DOSAD+1 0D4A 8544 1420 STA FMSZPG+1 0D4C D008 1430 BNE OWTDOS ; DOS CAN'T 1440 ; ; START ON ZERO-PAGE 1450 ; 0D4E 1460 OPDIRF 0D4E A9A9 1470 LDA #169 0D50 1480 EROXIT 0D50 4CB11A 1490 JMP AEXIT 1500 ; 1510 ; AUTOMATICALLY WRITE DOS OUT 1520 ; IF WE OPEN "DOS.SYS" FOR A 1530 ; WRITE (THIS IS BECAUSE DOS 2.0 1540 ; WOULD BLOW ITSELF AWAY IF A 1550 ; REAL WRITE FROM THE DOS AREA 1560 ; WAS ATTEMPTED, AND WE HAVE TO 1570 ; TO REMAIN COMPATIBLE). 1580 ; PAGE 19 LARGE DISK FMS D:MDOS2.M65 0D53 1590 LWTDOS 0D53 20E616 1600 JSR WRNXTS 0D56 1610 OWTDOS 0D56 A000 1620 LDY #0 0D58 1630 CDOSBF 0D58 B143 1640 LDA (FMSZPG),Y 0D5A 9146 1650 STA (FMSBPT),Y 0D5C C8 1660 INY 0D5D CC1107 1670 CPY DLINK 0D60 90F6 1680 BCC CDOSBF 0D62 98 1690 TYA 0D63 9D6C08 1700 STA CURLEN,X 0D66 204D07 1710 JSR MVBUFR 0D69 CC0C07 1720 CPY DOSEND 0D6C ED0D07 1730 SBC DOSEND+1 0D6F 90E2 1740 BCC LWTDOS 0D71 1750 JDONE 0D71 4CAF1A 1760 JMP DONE 1770 ; 1780 ;*READ DATA FROM A FILE 1790 ; 0D74 1800 DKREAD 0D74 20B619 1810 JSR SETUP ; SETUP BUFFS 0D77 BD6908 1820 LDA FCBOTC,X 0D7A 2902 1830 AND #$02 ; TEST DIR I/O 0D7C F003 1840 BEQ RDFILE 0D7E 4C1C14 1850 JMP DIRRD ; JUMP DIR READ 1860 ; 0D81 1870 RDFILE 0D81 BD6C08 1880 LDA CURLEN,X 0D84 DD6B08 1890 CMP MAXLEN,X 0D87 9032 1900 BCC RDSGBT ; GET ONE BYTE 1910 ; ; IF NOT AT END 0D89 B027 1920 BCS RDASNT ; OR GET MORE 1930 ; 0D8B 1940 RDASLP 0D8B A522 1950 LDA ICCOMZ 0D8D 2902 1960 AND #$02 ; BINARY I/O? 0D8F F02A 1970 BEQ RDSGBT ; GET ONE BYTE 0D91 AC1107 1980 LDY DLINK 0D94 88 1990 DEY 0D95 2000 RDSCLP 2010 ; ; SIMULATED 2020 ; ; BURST I/O 2030 ; ; (with unrolled loop) 0D95 B146 2040 LDA (FMSBPT),Y 0D97 9124 2050 STA (ICBALZ),Y 0D99 88 2060 DEY 0D9A B146 2070 LDA (FMSBPT),Y 0D9C 9124 2080 STA (ICBALZ),Y 0D9E 88 2090 DEY 0D9F B146 2100 LDA (FMSBPT),Y 0DA1 9124 2110 STA (ICBALZ),Y 0DA3 88 2120 DEY 0DA4 B146 2130 LDA (FMSBPT),Y 0DA6 9124 2140 STA (ICBALZ),Y 0DA8 88 2150 DEY 0DA9 D0EA 2160 BNE RDSCLP PAGE 20 LARGE DISK FMS D:MDOS2.M65 0DAB B146 2170 LDA (FMSBPT),Y ; NUM OF DATA 2180 ; ; BYTES IS MULTIPLE 2190 ; ; OF 4 + 1 0DAD 9124 2200 STA (ICBALZ),Y 0DAF 20460E 2210 JSR BUFADJ ; ADJUST BUFFER 2220 ; ; PTR BY 125 OR 253 0DB2 2230 RDASNT 2240 ; ; READ IN THE 0DB2 20E116 2250 JSR RDNXTS ; NEXT SECTOR 0DB5 B01C 2260 BCS RETEOF ; EOF-ERROR 0DB7 A529 2270 LDA ICBLLZ+1 0DB9 D0D0 2280 BNE RDASLP ; AND REPEAT THE 2290 ; ; LOOP IF > 256 2300 ; ; BYTES LEFT 2310 ; 0DBB 2320 RDSGBT 0DBB A8 2330 TAY 0DBC B146 2340 LDA (FMSBPT),Y ; FETCH A 2350 ; ; DATA BYTE FROM 2360 ; ; THE BUFFER 0DBE 852F 2370 STA DATBYT ; STORE IT CIO 0DC0 C8 2380 INY 0DC1 98 2390 TYA 0DC2 9D6C08 2400 STA CURLEN,X ; BUMP LENGTH 0DC5 5D6B08 2410 EOR MAXLEN,X 0DC8 1D7008 2420 ORA LNKSEC,X 0DCB 1D7108 2430 ORA LNKSEC+1,X ; LAST BYTE? 0DCE D0A1 2440 BNE JDONE 0DD0 A903 2450 LDA #3 ; YES, SAY SO 0DD2 2C 2460 .BYTE $2C ; FAKE BIT OP 2470 ; 0DD3 2480 RETEOF 0DD3 A988 2490 LDA #136 ; EOF STATUS 0DD5 4CB11A 2500 JMP AEXIT 2510 ; 2520 ;*WRITE DATA TO A FILE 2530 ; 0DD8 2540 DKWRIT 0DD8 852F 2550 STA DATBYT ; SAVE THE DATA 2560 ; ; BYTE (IF IT IS IN ACC) 0DDA BC4103 2570 LDY ICDNO,X 0DDD 8421 2580 STY ICDNOZ ; INSURE ICDNOZ 2590 ; ; IS SET UP 2600 ; ; (BASIC DOESN'T!) 0DDF 20B819 2610 JSR SETUPW 0DE2 BD6908 2620 LDA FCBOTC,X 0DE5 2908 2630 AND #$08 0DE7 F05A 2640 BEQ CANTWR ; ERROR OUT IF 2650 ; ; ILLEGAL TO WRITE 2660 ; ; (BASIC AGAIN!) 0DE9 BD6C08 2670 LDA CURLEN,X 0DEC A8 2680 TAY 0DED DD6B08 2690 CMP MAXLEN,X 0DF0 9040 2700 BCC SKBURST ; SKIP AROUND IF 2710 ; ; NOT THE END OF 2720 ; ; THE SECTOR 0DF2 2730 WRASLP 0DF2 20E616 2740 JSR WRNXTS ; WRITE A SECTOR PAGE 21 LARGE DISK FMS D:MDOS2.M65 2750 ; ; OF DATA 0DF5 B0DC 2760 BCS RETEOF ; ERROR OUT IF 2770 ; ; NO MORE SPACE 0DF7 ACBF07 2780 LDY STKPSV 0DFA B90201 2790 LDA $0102,Y 0DFD C9C0 2800 CMP #$C0 ; IF FROM BASIC 2810 ; ; RETURN ADDRESS 2820 ; ; < $C000 0DFF 902F 2830 BCC BASWRT ; SINGLE BYTES 0E01 BD6908 2840 LDA FCBOTC,X ; Fix bug in 2850 ; ; open/update vs 2860 ; ; burst I/O [Bob 0E04 2904 2870 AND #$04 ; Puff, again!] 0E06 D028 2880 BNE BASWRT 0E08 A522 2890 LDA ICCOMZ ; IF RECORD I/O, 2900 ; ; PASS SINGLE 2910 ; ; BYTES ALSO 0E0A 2902 2920 AND #$02 0E0C F022 2930 BEQ BASWRT 0E0E A429 2940 LDY ICBLLZ+1 ; AND IF THE 2950 ; ; BUFFER HOLDS 2960 ; ; FEWER THAN 256 2970 ; ; BYTES 0E10 F01E 2980 BEQ BASWRT ; PASS SINGLE 2990 ; ; BYTES AS WELL 0E12 BC6B08 3000 LDY MAXLEN,X 0E15 88 3010 DEY 0E16 3020 WRSCLP 0E16 B124 3030 LDA (ICBALZ),Y ; ELSE, DO 3040 ; ; SIMULATED BURST 3050 ; ; I/O 0E18 9146 3060 STA (FMSBPT),Y 0E1A 88 3070 DEY 0E1B B124 3080 LDA (ICBALZ),Y 0E1D 9146 3090 STA (FMSBPT),Y ; BUT ONLY 3100 ; ; UNROLL 2 ENTRIES 3110 ; ; FOR WRITES! 0E1F 88 3120 DEY ; (WE GOT VERY 3130 ; ; LITTLE RAM TO WASTE!) 0E20 D0F4 3140 BNE WRSCLP 0E22 B124 3150 LDA (ICBALZ),Y 0E24 9146 3160 STA (FMSBPT),Y 0E26 20460E 3170 JSR BUFADJ 0E29 B124 3180 LDA (ICBALZ),Y 0E2B 852F 3190 STA DATBYT 0E2D 4CF20D 3200 JMP WRASLP 3210 ; 0E30 3220 BASWRT 0E30 A000 3230 LDY #0 0E32 3240 SKBURST 0E32 A52F 3250 LDA DATBYT 0E34 FE6C08 3260 INC CURLEN,X 0E37 9146 3270 STA (FMSBPT),Y 0E39 A940 3280 LDA #$40 0E3B 1D6A08 3290 ORA FCBFLG,X ; FOR UPDATE 3300 ; ; MODE, SAY THE 3310 ; ; SECTOR WAS MODIFIED 0E3E 9D6A08 3320 STA FCBFLG,X PAGE 22 LARGE DISK FMS D:MDOS2.M65 0E41 D028 3330 BNE TODONE ; BRANCH ALWAYS! 3340 ; 0E43 3350 CANTWR 0E43 4C7E10 3360 JMP ERRCMD 3370 ; 0E46 3380 BUFADJ 0E46 18 3390 CLC 0E47 BD6B08 3400 LDA MAXLEN,X 0E4A 9D6C08 3410 STA CURLEN,X 0E4D 6524 3420 ADC ICBALZ 0E4F 8524 3430 STA ICBALZ 0E51 9002 3440 BCC RBAOK 0E53 E625 3450 INC ICBALZ+1 0E55 3460 RBAOK 0E55 38 3470 SEC 0E56 A528 3480 LDA ICBLLZ 0E58 FD6B08 3490 SBC MAXLEN,X 0E5B 8528 3500 STA ICBLLZ 0E5D B002 3510 BCS RBLOK 0E5F C629 3520 DEC ICBLLZ+1 0E61 3530 RBLOK 0E61 60 3540 RTS 3550 ; 3560 ;*RETURN FILE STATUS 3570 ; 0E62 3580 DKSTAT 0E62 20B619 3590 JSR SETUP ; SET UP RETURN 3600 ; ; ADDRESS, ETC. 0E65 20981A 3610 JSR LFFILE ; FIND IF FILE 3620 ; ; IS THERE, ETC. 0E68 20A51A 3630 JSR TSTLOK ; IS IT LOCKED? 0E6B 3640 TODONE 0E6B 4CAF1A 3650 JMP DONE ; RET TO CALLER 3660 ; 3670 ;*CLOSE FILE (WRITING ANY 3680 ; PENDING SECTOR) 3690 ; 0E6E 3700 DKCLOS 0E6E 20B619 3710 JSR SETUP 0E71 BD6908 3720 LDA FCBOTC,X 0E74 2908 3730 AND #$08 ; OUTPUT LEGAL? 0E76 F05E 3740 BEQ CLROTC ; NO, JUST EXIT 0E78 3E6A08 3750 ROL FCBFLG,X 0E7B 9066 3760 BCC CKFLSC 0E7D 20AF16 3770 JSR REWRIT ; REWRITE THE 3780 ; ; LAST SECTOR 0E80 208117 3790 JSR RRDIR 0E83 BD7208 3800 LDA SECCNT,X 0E86 A443 3810 LDY DIRDSP 0E88 990909 3820 STA DIRBUF+1,Y 0E8B BD7308 3830 LDA SECCNT+1,X 0E8E 990A09 3840 STA DIRBUF+2,Y 0E91 B90809 3850 LDA DIRBUF,Y 0E94 29FE 3860 AND #$FE ; NOT OPEN FOR 3870 ; ; OUTPUT ANY MORE 0E96 20DC1A 3880 JSR SAVFLAG 0E99 BD7608 3890 LDA SAVSEC,X 0E9C 1D7708 3900 ORA SAVSEC+1,X PAGE 23 LARGE DISK FMS D:MDOS2.M65 0E9F F035 3910 BEQ CLROTC 0EA1 EC6708 3920 CPX LSTIOCB 0EA4 F00A 3930 BEQ FAPPD 0EA6 20EE0E 3940 JSR INITYP ; READ ALL THE 3950 ; ; SECTORS AGAIN 0EA9 3960 APPLP 0EA9 20E116 3970 JSR RDNXTS 0EAC 90FB 3980 BCC APPLP ; NOT EOF YET 0EAE B00C 3990 BCS TIELNK 0EB0 4000 FAPPD 0EB0 AD6508 4010 LDA LSTSEC 0EB3 9D6E08 4020 STA CURSEC,X 0EB6 AD6608 4030 LDA LSTSEC+1 0EB9 9D6F08 4040 STA CURSEC+1,X 0EBC 4050 TIELNK 0EBC 18 4060 CLC 0EBD 207A16 4070 JSR RWDISK 0EC0 AD1107 4080 LDA DLINK 0EC3 9D6C08 4090 STA CURLEN,X 0EC6 BD7608 4100 LDA SAVSEC,X 0EC9 BC7708 4110 LDY SAVSEC+1,X 0ECC 20FA16 4120 JSR SAVLNK 0ECF 4130 CLROTE 0ECF 1005 4140 BPL CLROTC 0ED1 A9A3 4150 LDA #163 ; FAILURE IS A 4160 ; ; SYSTEM ERROR 0ED3 4CB11A 4170 JMP AEXIT 0ED6 4180 CLROTC 0ED6 A9FF 4190 LDA #$FF 0ED8 9D4003 4200 STA ICHID,X 0EDB A900 4210 LDA #0 0EDD 9D6908 4220 STA FCBOTC,X 0EE0 4CC51A 4230 JMP FREDON 4240 ; 0EE3 4250 CKFLSC 0EE3 3E6A08 4260 ROL FCBFLG,X 0EE6 90EE 4270 BCC CLROTC 0EE8 207916 4280 JSR WRDISK 0EEB 4CCF0E 4290 JMP CLROTE 4300 ; 0EEE 4310 INITYP 0EEE A906 4320 LDA #$06 0EF0 20D61A 4330 JSR GETFLAG 0EF3 4A 4340 LSR A 0EF4 6A 4350 ROR A 0EF5 6A 4360 ROR A 0EF6 6A 4370 ROR A 0EF7 1D6908 4380 ORA FCBOTC,X 0EFA 9D6908 4390 STA FCBOTC,X 0EFD B90B09 4400 LDA DIRBUF+3,Y 0F00 9D7008 4410 STA LNKSEC,X 0F03 B90C09 4420 LDA DIRBUF+4,Y 0F06 9D7108 4430 STA LNKSEC+1,X 0F09 A545 4440 LDA CURFNO 0F0B 9D6808 4450 STA FCBFNO,X 0F0E A900 4460 LDA #0 0F10 9D6A08 4470 STA FCBFLG,X 0F13 9D6C08 4480 STA CURLEN,X PAGE 24 LARGE DISK FMS D:MDOS2.M65 0F16 9D7208 4490 STA SECCNT,X 0F19 9D7308 4500 STA SECCNT+1,X 0F1C 60 4510 RTS 4520 ; 4530 ;*DOS XIO ROUTINES 4540 ; 4550 ; Sorry about the lack of 4560 ; comments in some parts of this 4570 ; file, I just never had to 4580 ; figure this code out after I 4590 ; wrote it (:-)! 4600 ; 0F1D 4610 NODIRF 0F1D A9B0 4620 LDA #176 ; FILE NOT A 4630 ; ; DIRECTORY 0F1F 4CB11A 4640 JMP AEXIT 4650 ; 0F22 4660 PIKDIR 0F22 A000 4670 LDY #0 0F24 A93A 4680 LDA #': 0F26 4690 FDVND 0F26 C8 4700 INY 0F27 D124 4710 CMP (ICBALZ),Y 0F29 D0FB 4720 BNE FDVND 0F2B C8 4730 INY 0F2C B124 4740 LDA (ICBALZ),Y 0F2E C940 4750 CMP #'@ 0F30 902B 4760 BCC SETRDIR 0F32 C95B 4770 CMP #'Z+1 0F34 9008 4780 BCC GFNDIR 0F36 C920 4790 CMP #' 0F38 9023 4800 BCC SETRDIR 0F3A C97B 4810 CMP #'z+1 0F3C B01F 4820 BCS SETRDIR 0F3E 4830 GFNDIR 0F3E 20981A 4840 JSR LFFILE ; FIND NEW 4850 ; ; DEFAULT DIR 0F41 20EE0E 4860 JSR INITYP 0F44 20C415 4870 JSR TONXDR 0F47 F0D4 4880 BEQ NODIRF ; IF NOT DIR 0F49 BD7508 4890 LDA DIRBAS+1,X 0F4C A8 4900 TAY 0F4D BD7408 4910 LDA DIRBAS,X 0F50 4920 SAVDEF 0F50 8CBC07 4930 STY CDIREC+1 ; UPDATE 4940 ; ; DIR ADDRESS 0F53 8DBB07 4950 STA CDIREC 0F56 A521 4960 LDA ICDNOZ 0F58 8D0B07 4970 STA DEFAULT ; UPDATE UNIT # 0F5B 1068 4980 BPL TOFDN 4990 ; 0F5D 5000 SETRDIR 0F5D A969 5010 LDA # <361 0F5F A001 5020 LDY # >361 0F61 10ED 5030 BPL SAVDEF 5040 ; 0F63 5050 RENAME 0F63 20981A 5060 JSR LFFILE ; GET OLD NAME, PAGE 25 LARGE DISK FMS D:MDOS2.M65 5070 ; ; DRIVE, VALIDATE 0F66 A00B 5080 LDY #11 0F68 5090 STEMPL 0F68 B9070B 5100 LDA FNAME-1,Y 0F6B 99080A 5110 STA MAPBUF+256,Y 0F6E 88 5120 DEY 0F6F D0F7 5130 BNE STEMPL 0F71 5140 RNLOOP 0F71 20A51A 5150 JSR TSTLOK ; CANNOT RENAME 5160 ; ; IF LOCKED 0F74 200E1A 5170 JSR TDDOS ; TEST FOR DOS 5180 ; ; GONE! 0F77 A449 5190 LDY TMP2 0F79 205115 5200 JSR GETNAM ; GET NEW NAME 0F7C 18 5210 CLC 0F7D 20DA15 5220 JSR ENTNAME ; OVERWRITE NAME 5230 ; ; IN DIR 0F80 209017 5240 JSR WDIRBK ; REWRITE DIR 5250 ; 0F83 20791A 5260 JSR TSTDOS ; DOS.SYS? 0F86 D02D 5270 BNE REPLDS ; NO, NEXT? 0F88 A443 5280 LDY DIRDSP 0F8A B90C09 5290 LDA DIRBUF+4,Y ; SAVE FILE 5300 ; ; LOCATION ON THE 5310 ; ; STACK 0F8D 48 5320 PHA 0F8E B90B09 5330 LDA DIRBUF+3,Y 0F91 48 5340 PHA 5350 ; 5360 ;;; JSR SYSSET ;Use the MAP 5370 ; buffer [IS THIS NECESSARY??? 5380 ; 0F92 18 5390 CLC ; == READ 0F93 A201 5400 LDX #1 ; == SECTOR SIZE 5410 ; ; CODE (1=128, 2=256) 0F95 A900 5420 LDA #0 0F97 A001 5430 LDY #1 ; == SECTOR #1 0F99 206307 5440 JSR DKIO ; Read it 5450 ; 0F9C AD0E07 5460 LDA SECDAT 0F9F 8D1609 5470 STA MAPBUF+SECDAT-$0700 0FA2 68 5480 PLA 0FA3 8D1709 5490 STA MAPBUF+DOSLOC-$0700 0FA6 68 5500 PLA 0FA7 8D1809 5510 STA MAPBUF+DOSLOC+1-$0700 5520 ; 5530 ;; LDA #$00 ;[AND IS THIS REALLY 5540 ;; NECESSARY??? 5550 ;;; STA MAPBUF+STATE-$0700 5560 ; 0FAA 38 5570 SEC ; == WRITE 0FAB A201 5580 LDX #1 ; == SECTOR SIZE 5590 ; ; CODE (1=128, 2=256) 0FAD 206907 5600 JSR DKIO2 ; Write it (same 5610 ; ; sector as I 5620 ; ; read before) 5630 ; 0FB0 A9FF 5640 LDA #$FF ; Then make sure PAGE 26 LARGE DISK FMS D:MDOS2.M65 5650 ; ; we reread the 5660 ; ; dir buffer 0FB2 8DBA07 5670 STA DIUNIT 5680 ; 0FB5 5690 REPLDS 0FB5 A00B 5700 LDY #11 0FB7 5710 RTEMPL 0FB7 B9080A 5720 LDA MAPBUF+256,Y 0FBA 99070B 5730 STA FNAME-1,Y 0FBD 88 5740 DEY 0FBE D0F7 5750 BNE RTEMPL 0FC0 202B16 5760 JSR CSFDIR ;TO RENAME 0FC3 90AC 5770 BCC RNLOOP 0FC5 5780 TOFDN 0FC5 4CC51A 5790 JMP FREDON 5800 ; 0FC8 5810 DELETE 0FC8 20981A 5820 JSR LFFILE 0FCB 5830 DELLP 0FCB 20E00F 5840 JSR REMOVE ; FLUSH SECS 0FCE 208117 5850 JSR RRDIR ; REREAD DIR 0FD1 200E1A 5860 JSR TDDOS ; DELETED DOS? 0FD4 A980 5870 LDA #$80 0FD6 20DC1A 5880 JSR SAVFLAG ; REWRITE DIR 0FD9 202B16 5890 JSR CSFDIR 0FDC 90ED 5900 BCC DELLP ; IF ANOTHER 5910 ; ; FOUND, 0FDE B0E5 5920 BCS TOFDN ; ELSE, WRAP UP 5930 ; ; AND EXIT 5940 ; 0FE0 5950 REMOVE 0FE0 20A51A 5960 JSR TSTLOK ; ONCE HAD 5970 ; ; 'OPVTOC' CALL 5980 ; ; FIRST 0FE3 20EE0E 5990 JSR INITYP 0FE6 20C415 6000 JSR TONXDR 0FE9 D02C 6010 BNE DELDIR 0FEB 204017 6020 JSR CHASE 6030 ; 0FEE 6040 FREELP 0FEE 208E18 6050 JSR FREE 0FF1 20E116 6060 JSR RDNXTS 0FF4 90F8 6070 BCC FREELP 0FF6 60 6080 RTS 6090 ; 0FF7 6100 INVDEL 0FF7 A9AF 6110 LDA #175 ; DIRECTORY NOT 6120 ; ; DELETABLE 0FF9 4CB11A 6130 JMP AEXIT 6140 ; 0FFC 6150 LOCK 0FFC A920 6160 LDA #$20 0FFE 2C 6170 .BYTE $2C ; BIT ABS (SKIP 6180 ; ; 2 BYTES) 6190 ; 0FFF 6200 UNLOCK 0FFF A900 6210 LDA #$00 1001 852F 6220 STA DATBYT PAGE 27 LARGE DISK FMS D:MDOS2.M65 1003 20981A 6230 JSR LFFILE ; FIND FILE AND 6240 ; ; VERIFY WRITABLE 1006 6250 LKULKL 1006 A9DF 6260 LDA #$DF ; STRIP OFF OLD 6270 ; ; BIT 5 1008 20D61A 6280 JSR GETFLAG 100B 052F 6290 ORA DATBYT ; AND REPLACE 6300 ; ; WITH NEW 100D 20DC1A 6310 JSR SAVFLAG 1010 202B16 6320 JSR CSFDIR 1013 90F1 6330 BCC LKULKL 1015 B0AE 6340 BCS TOFDN 6350 ; 1017 6360 DELDIR 1017 A0F5 6370 LDY #-11 1019 A93F 6380 LDA #'? 101B 6390 DELSET 101B 99130A 6400 STA FNAME+11-256,Y 101E C8 6410 INY 101F D0FA 6420 BNE DELSET 1021 20F915 6430 JSR SFDIR 1024 90D1 6440 BCC INVDEL 6450 ; 1026 A908 6460 LDA #8 1028 852F 6470 STA DATBYT 102A 20C216 6480 JSR TONXT 102D 6490 DELDRL 102D 208E18 6500 JSR FREE 1030 20AD19 6510 JSR INCCSEC 1033 C62F 6520 DEC DATBYT 1035 D0F6 6530 BNE DELDRL 1037 4C2615 6540 JMP GETFNM 6550 ; 103A 6560 POINT 103A BC6A08 6570 LDY FCBFLG,X 103D 303F 6580 BMI ERRCMD 6590 ; 103F BD4D03 6600 LDA ICSPR+1,X 1042 DD6F08 6610 CMP CURSEC+1,X 1045 D008 6620 BNE PNTREAD 1047 BD4C03 6630 LDA ICSPR,X 104A DD6E08 6640 CMP CURSEC,X 104D F01C 6650 BEQ PNTSME 104F 6660 PNTREAD 104F 98 6670 TYA 1050 F008 6680 BEQ PNTCLN ; IF SECTOR 6690 ; ; UNMODIFIED 1052 207916 6700 JSR WRDISK 1055 A900 6710 LDA #0 1057 9D6A08 6720 STA FCBFLG,X 105A 6730 PNTCLN 105A BD4D03 6740 LDA ICSPR+1,X 105D 9D7108 6750 STA LNKSEC+1,X 1060 BD4C03 6760 LDA ICSPR,X 1063 9D7008 6770 STA LNKSEC,X 1066 204017 6780 JSR CHASE ; READ SECTOR 6790 ; ; POINTED TO 1069 B010 6800 BCS BADPNT PAGE 28 LARGE DISK FMS D:MDOS2.M65 6810 ; 106B 6820 PNTSME 106B BD4E03 6830 LDA ICSPR+2,X 106E DD6B08 6840 CMP MAXLEN,X 1071 B006 6850 BCS PNTEQL 1073 6860 PNTLST 1073 9D6C08 6870 STA CURLEN,X 1076 4CAF1A 6880 JMP DONE 6890 ; 1079 6900 PNTEQL 1079 F0F8 6910 BEQ PNTLST ; IF POINTING 6920 ; ; AT LAST BYTE 107B 6930 BADPNT 107B A9A6 6940 LDA #166 ; INVALID POINT 6950 ; ; LOCATION ERR 107D AE 6960 .BYTE $AE ; FAKE LDX 6970 ; 107E 6980 ERRCMD 107E A9A8 6990 LDA #168 ; INVALID IOCB 7000 ; ; PARAMETER 1080 4CB11A 7010 JMP AEXIT 7020 ; 1083 7030 NOTE 1083 BD6E08 7040 LDA CURSEC,X 1086 9D4C03 7050 STA ICSPR,X 1089 BD6F08 7060 LDA CURSEC+1,X 108C 9D4D03 7070 STA ICSPR+1,X 108F BD6C08 7080 LDA CURLEN,X 1092 9D4E03 7090 STA ICSPR+2,X 1095 4CAF1A 7100 JMP DONE 7110 ; 1098 7120 DKXIO 1098 20B619 7130 JSR SETUP 109B A522 7140 LDA ICCOMZ ; GET COMMAND 7150 ; ; BYTE 109D C9FE 7160 CMP #254 109F F028 7170 BEQ FORMAT 10A1 C92B 7180 CMP #43 ; ADD "MKDIR" 7190 ; ; CODE FOR SpartaDOS? 7200 ; ; [Bob Puff] 10A3 B0D9 7210 BCS ERRCMD ; IF INVALID 7220 ; ; COMMAND 10A5 E91F 7230 SBC #32-1 10A7 90D5 7240 BCC ERRCMD 10A9 A8 7250 TAY 10AA B9B310 7260 LDA VECTBH,Y 10AD 48 7270 PHA 10AE B9BE10 7280 LDA VECTBL,Y 10B1 48 7290 PHA 10B2 60 7300 RTS ; VECTOR TO 7310 ; ; PROPER ROUTINE 7320 ; 10B3 7330 VECTBH 10B3 0F0F 7340 .BYTE >RENAME-1, >DELETE-1 10B5 130F 7350 .BYTE >MKDIR-1, >LOCK-1 10B7 0F10 7360 .BYTE >UNLOCK-1, >POINT-1 10B9 1012 7370 .BYTE >NOTE-1, >DKLOAD-1 7380 ;* .BYTE >ERRCMD-1, >PIKDIR-1 PAGE 29 LARGE DISK FMS D:MDOS2.M65 10BB 120F 7390 .BYTE >DKLOAD-1, >PIKDIR-1 10BD 13 7400 .BYTE >MKDIR-1 7410 ; ; extra vector to 7420 ; ; to MKDIR [Bob Puff] 7430 ; 10BE 7440 VECTBL 10BE 62C7 7450 .BYTE 3 112C AC4602 8310 LDY DSKTIM ; DISK TIMEOUT 8320 ; ; VALUE (RET IN STATUS) 112F 207407 8330 JSR DKFME ; ENTER DKIO AT 8340 ; ; FORMAT ENTRY 1132 1010 8350 BPL FMTOK ; Accepting 144 8360 ; ; errors here removed 8370 ; ; [Bob Puff] 1134 4CB11A 8380 JMP AEXIT ; RETURN ERROR 8390 ; ; CODE IF ANY 8400 ; 1137 8410 RAMFMT 1137 9D6E08 8420 STA CURSEC,X ; STUFF PROPER 8430 ; ; # OF SECTORS 8440 ; ; INTO CURSEC 113A 18 8450 CLC ; 256-BYTE PAGES 8460 ; ; * 2 SINCE SECTOR 8470 ; ; SIZE IS 128 113B 6D3A0C 8480 ADC RDKLMT 113E 4A 8490 LSR A 113F 7E6E08 8500 ROR CURSEC,X 1142 D046 8510 BNE NOTDEF ; FAIL IF NOT 8520 ; ; 256 SECTORS OR 8530 ; ; MORE (need 370) 8540 ; PAGE 31 LARGE DISK FMS D:MDOS2.M65 8550 ;*SUCCESSFUL FORMAT, CREATE VTOC 8560 ; AND EMPTY DIRECTORY 8570 ; 1144 8580 FMTOK 8590 ; [Bob Puff] disabled the 8600 ; marginal format code 8610 ; ldy #0 ; check for bad format 8620 ; lda (FMSBPT),y 8630 ; and (FMSBPT),y ; 1st 2 $FF? 8640 ; cmp #$FF 8650 ; beq FMTOK2 ; yep, continue 8660 ; lda #173 ; format error 8670 ; bne FMEXIT 8680 ; 1144 8690 FMTOK2 1144 20011A 8700 JSR INVUNIT ; Can we do this 8710 ; ; (asks Bob Puff) 1147 20131A 8720 JSR DELDOS 114A A52A 8730 LDA ICAX1Z 114C 9D6E08 8740 STA CURSEC,X 114F A52B 8750 LDA ICAX2Z 1151 297F 8760 AND #$7F ; DISK MUST HAVE 8770 ; ; 256 SECTORS 1153 D035 8780 BNE NOTDEF ; IF SIZE 8790 ; ; SPECIFIED, USE IT 1155 A421 8800 LDY ICDNOZ 1157 B9140B 8810 LDA HDTAB-1,Y ; IF NOT AND 8820 ; ; THIS IS A HARD DISK 115A 9D6E08 8830 STA CURSEC,X ; USE THE 8840 ; ; SYSTEM DEFINED SIZE 115D B91C0B 8850 LDA HDTAB+8-1,Y 1160 D028 8860 BNE NOTDEF 1162 2CEA02 8870 BIT DVSTAT ; 1050 DRIVE? 1165 1009 8880 BPL FIGSIZ ; FIGURE SIZE 1167 A910 8890 LDA # <1040 ; YES, FORCE TO 8900 ; ; 1040 SECTORS 1169 9D6E08 8910 STA CURSEC,X 116C A904 8920 LDA # >1040 116E D01A 8930 BNE NOTDEF 8940 ; 1170 8950 FIGSIZ 1170 B9CB07 8960 LDA DRVDEF-1,Y 1173 2931 8970 AND #$31 ; EXTRACT TRACK 8980 ; ; COUNT FLAGS 1175 4A 8990 LSR A 1176 08 9000 PHP 1177 4A 9010 LSR A 1178 4A 9020 LSR A 1179 A8 9030 TAY 117A B96912 9040 LDA NOSECS,Y ; AND USE DRIVE 9050 ; ; DEFAULT SECTOR COUNT 117D 9D6E08 9060 STA CURSEC,X 1180 B96A12 9070 LDA NOSECS+1,Y 1183 28 9080 PLP 1184 9004 9090 BCC NOTDEF ; IF NOT DOUBLE 9100 ; ; SIDED, THIS IS IT 1186 1E6E08 9110 ASL CURSEC,X 1189 2A 9120 ROL A ; ELSE DOUBLE IT PAGE 32 LARGE DISK FMS D:MDOS2.M65 9130 ; 118A 9140 NOTDEF 118A 9D6F08 9150 STA CURSEC+1,X 118D C904 9160 CMP #4 ; NEED 16 BIT 9170 ; ; LINKS? 118F 9003 9180 BCC SHORTS ; NO, SHORT DOS2 9190 ; ; FORMAT OK 1191 EE0809 9200 INC MAPBUF ; YES, FORCE 9210 ; ; LONG FORMAT 9220 ; ; MYDOS(3) 1194 9230 SHORTS 1194 20C618 9240 JSR FNDBIT ; FIND LAST BIT 9250 ; ; MAP SECTOR 1197 A549 9260 LDA TMP2 1199 D009 9270 BNE GT246 ; IF PAST 256TH 9280 ; ; MAP BYTE 119B 2C1107 9290 BIT DLINK ; SD? 119E 300D 9300 BMI FDBDEN 11A0 C000 9310 CPY #0 11A2 1009 9320 BPL FDBDEN 11A4 9330 GT246 11A4 8D6308 9340 STA MAP2 11A7 18 9350 CLC 11A8 6903 9360 ADC #3 11AA 8D0809 9370 STA MAPBUF 11AD 9380 FDBDEN 11AD A9FF 9390 LDA # >-9 11AF 8D0C09 9400 STA MAPBUF+4 11B2 A9F7 9410 LDA # <-9 11B4 8D0B09 9420 STA MAPBUF+3 ; START WITH 9 9430 ; ; FREE SECTORS 9440 ; ; UN-FREE! 11B7 9450 FLOOP 11B7 209418 9460 JSR FMTFRE 11BA 20A119 9470 JSR DECCSEC 11BD C904 9480 CMP #4 ; BOOT SECTORS 9490 ; ; YET? 11BF D0F6 9500 BNE FLOOP ; IF NOT, 9510 ; ; CONTINUE DEALLOCATING 11C1 BD6F08 9520 LDA CURSEC+1,X 11C4 D0F1 9530 BNE FLOOP 9540 ; 9550 ;*ALLOCATE BAD SECTORS 9560 ; [Bob Puff] replaced this with 9570 ; code to set FMSBPT to 1, since 9580 ; he disallows bad sectors 9590 ; 11C6 A000 9600 LDY #0 11C8 9610 CLRBDLP 11C8 B146 9620 LDA (FMSBPT),Y 11CA 9D6E08 9630 STA CURSEC,X 11CD C8 9640 INY 11CE B146 9650 LDA (FMSBPT),Y 11D0 9D6F08 9660 STA CURSEC+1,X 11D3 C8 9670 INY 11D4 3D6E08 9680 AND CURSEC,X 11D7 C9FF 9690 CMP #$FF 11D9 18 9700 CLC PAGE 33 LARGE DISK FMS D:MDOS2.M65 11DA F021 9710 BEQ MAPDONE 11DC 8448 9720 STY TMP1 11DE 207819 9730 JSR DECCNT 11E1 208519 9740 JSR FNDLBIT 11E4 49FF 9750 EOR #$FF 11E6 9008 9760 BCC CLRBD1 11E8 39080A 9770 AND MAPBUF+256,Y 11EB 99080A 9780 STA MAPBUF+256,Y 11EE B006 9790 BCS CLRBD2 11F0 9800 CLRBD1 11F0 390809 9810 AND MAPBUF,Y 11F3 990809 9820 STA MAPBUF,Y 11F6 9830 CLRBD2 11F6 A448 9840 LDY TMP1 11F8 D0CE 9850 BNE CLRBDLP 11FA 38 9860 SEC 11FB A05A 9870 LDY #173*2-256 ; NO $FFFF => 9880 ; ; BAD FORMAT 11FD 9890 MAPDONE 11FD 98 9900 TYA 11FE 6A 9910 ROR A 11FF 8546 9920 STA FMSBPT ; POSITIVE VALUE 9930 ; ; = # OF BAD 9940 ; ; SECTORS 9950 ; 9960 ;*[End of code that can be 9970 ; optionally deleted] 9980 ; 1201 A900 9990 LDA #$00 1203 8D3F09 010000 STA MAPBUF+55 1206 A97F 010010 LDA #$7F 1208 8D4009 010020 STA MAPBUF+56 120B A02C 010030 LDY #44 ; START ALLOC. 010040 ; ; OF VTOC HERE 120D AD0809 010050 LDA MAPBUF 1210 38 010060 SEC 1211 E902 010070 SBC #2 ; GET # OF SECS 1213 2C1107 010080 BIT DLINK ; SD? 1216 3001 010090 BMI MPNSD ; IF NOT, M-3 1218 0A 010100 ASL A ; IF SO, M*2-5 1219 010110 MPNSD 1219 AA 010120 TAX ; COUNT TO X 121A CA 010130 DEX 010140 ; 121B 010150 ALCMPL 121B A9FF 010160 LDA #$FF 121D 010170 ALCMAP 121D CA 010180 DEX 121E 300E 010190 BMI SMBSIZ 1220 48 010200 PHA 1221 207819 010210 JSR DECCNT 1224 68 010220 PLA 1225 0A 010230 ASL A 1226 D0F5 010240 BNE ALCMAP 1228 991209 010250 STA MAPBUF+10,Y 122B 88 010260 DEY 122C 10ED 010270 BPL ALCMPL ; BR ALWAYS! 010280 ; PAGE 34 LARGE DISK FMS D:MDOS2.M65 122E 010290 SMBSIZ 122E 991209 010300 STA MAPBUF+10,Y 1231 AD0B09 010310 LDA MAPBUF+3 ; MARK EMPTY 1234 8D0909 010320 STA MAPBUF+1 ; SIZE TOO 1237 AD0C09 010330 LDA MAPBUF+4 123A 8D0A09 010340 STA MAPBUF+2 123D 20F017 010350 JSR FMTMAP ; WRITE OUT MAP 010360 ; 010370 ;*CREATE AN EMPTY DIRECTORY 010380 ; 1240 A969 010390 LDA # <361 1242 A001 010400 LDY # >361 1244 010410 CLRDIR 1244 207112 010420 JSR SETDIR ; RESET THE 010430 ; ; DIRECTORY BASE 010440 ; ; SECTOR 1247 98 010450 TYA 1248 010460 CLRDLP 1248 990809 010470 STA DIRBUF,Y ; ZERO THE 010480 ; ; DIRECTORY BUFFER 124B C8 010490 INY 124C D0FA 010500 BNE CLRDLP 010510 ; 124E A907 010520 LDA #7 1250 8544 010530 STA DIRSEC 1252 010540 CLRDL2 1252 209017 010550 JSR WDIRBK ; THEN WRITE ALL 010560 ; ; 8 SECTORS OUT 1255 C644 010570 DEC DIRSEC 1257 10F9 010580 BPL CLRDL2 1259 BC6D08 010590 LDY BUFNO,X 125C A900 010600 LDA #0 125E 9D6D08 010610 STA BUFNO,X 1261 99E708 010620 STA BUFFLG-1,Y ; FORMAT DONE 010630 ; ; FREE THE 010640 ; ; INTERNAL BUFFER 1264 A546 010650 LDA FMSBPT 1266 4CB11A 010660 JMP AEXIT 010670 ; 1269 010680 NOSECS 1269 7602 010690 .WORD 35*18,40*18 126B D002 126D A005 010700 .WORD 80*18,77*26 126F D207 010710 ; 1271 010720 SETDIR 1271 9D7408 010730 STA DIRBAS,X 1274 98 010740 TYA 1275 9D7508 010750 STA DIRBAS+1,X 1278 A000 010760 LDY #0 127A 60 010770 RTS 010780 ; 010790 ;*DOS BINARY LOAD CODE (LOAD 010800 ; AND OPTIONALLY EXECUTE A 010810 ; PROGRAM) 010820 ; 127B 010830 DKLOAD 127B A52A 010840 LDA ICAX1Z PAGE 35 LARGE DISK FMS D:MDOS2.M65 127D 8526 010850 STA ICPTLZ ; SAVE PROGRAM 010860 ; ; NAME BUFFER POINTER 127F C908 010870 CMP #$08 1281 B021 010880 BCS TOERRC ; IF WRITE, 010890 ; ; REPORT ERROR 010900 ; 1283 A943 010910 LDA # TORTS ; ASSUME RUNN 010940 ; ; ADDRESS IS ABSENT 128A 8DE102 010950 STA RUNADR+1 128D A904 010960 LDA #4 128F 852A 010970 STA ICAX1Z 1291 BD4003 010980 LDA ICHID,X ; IOCB OPEN? 1294 1068 010990 BPL CCFILE 1296 206E0C 011000 JSR DKOPEN ; NO, OPEN IT 1299 3019 011010 BMI DKLERV 129B 202A13 011020 JSR WDREAD ; READ ONE WORD 011030 ; ; OF THE HEADER 129E F05E 011040 BEQ CCFILE 12A0 A0B4 011050 LDY #180 ; NO $FFFF, 011060 ; ; HEADER ERROR CODE 12A2 3010 011070 BMI DKLERV 011080 ; 12A4 011090 TOERRC 12A4 A0A8 011100 LDY #168 ; INVALID IOCB 12A6 60 011110 RTS 011120 ; 12A7 011130 GETTXT 12A7 A943 011140 LDA # TORTS ; FOR EACH 011170 ; ; SEGMENT, RECLEAR 011180 ; ; THE INIT VECTOR 12AE 8DE302 011190 STA INIADR+1 12B1 011200 TXTLP 12B1 20740D 011210 JSR DKREAD 12B4 011220 DKLERV 12B4 306C 011230 BMI DKLERR 12B6 A000 011240 LDY #0 12B8 9124 011250 STA (ICBALZ),Y 12BA E624 011260 INC ICBALZ 12BC D002 011270 BNE DECLEN 12BE E625 011280 INC ICBAHZ 12C0 011290 DECLEN 12C0 A528 011300 LDA ICBLLZ 12C2 D002 011310 BNE DECLOW 12C4 C629 011320 DEC ICBLHZ 12C6 011330 DECLOW 12C6 C628 011340 DEC ICBLLZ 12C8 D0E7 011350 BNE TXTLP 12CA A529 011360 LDA ICBLHZ 12CC D0E3 011370 BNE TXTLP 12CE A525 011380 LDA ICBAHZ 12D0 C902 011390 CMP # >INIADR 12D2 D02A 011400 BNE CCFILE 011410 ; 12D4 A526 011420 LDA ICPTLZ ; IF NO INITS, PAGE 36 LARGE DISK FMS D:MDOS2.M65 12D6 4A 011430 LSR A 12D7 B025 011440 BCS CCFILE ; SKIP TO NEXT 011450 ; ; PAGE 12D9 8A 011460 TXA ; ELSE SAVE IOCB 12DA 48 011470 PHA 12DB A0F4 011480 LDY #256-12 12DD 011490 CPSICB 12DD B92CFF 011500 LDA ICHIDZ-256+12,Y 12E0 9D4003 011510 STA ICHID,X ; SAVE THE 011520 ; ; 12-BYTE IOCB ENTRY 12E3 E8 011530 INX 12E4 C8 011540 INY 12E5 D0F6 011550 BNE CPSICB 12E7 68 011560 PLA 12E8 AA 011570 TAX 12E9 48 011580 PHA 12EA 205913 011590 JSR DOINIT ; AND CALL INIT 011600 ; ; FUNCTION 12ED 68 011610 PLA 12EE AA 011620 TAX 12EF 48 011630 PHA 12F0 A0F4 011640 LDY #256-12 12F2 011650 CPRICB 12F2 BD4003 011660 LDA ICHID,X ; THEN RESTORE 011670 ; ; THE 12-BYTE IOCB 12F5 992CFF 011680 STA ICHIDZ-256+12,Y 12F8 E8 011690 INX 12F9 C8 011700 INY 12FA D0F6 011710 BNE CPRICB 12FC 68 011720 PLA 12FD AA 011730 TAX 011740 ; 12FE 011750 CCFILE 12FE 202A13 011760 JSR WDREAD ; READ THE 011770 ; ; SEGMENT START ADDRESS 1301 F0FB 011780 BEQ CCFILE 1303 8524 011790 STA ICBALZ 1305 8425 011800 STY ICBAHZ 1307 202A13 011810 JSR WDREAD ; READ THE 011820 ; ; SEGMENT END ADDRESS 130A 38 011830 SEC 130B 6900 011840 ADC #0 130D 9001 011850 BCC CCSUBT 130F C8 011860 INY 1310 011870 CCSUBT 1310 38 011880 SEC 1311 E524 011890 SBC ICBALZ ; CALCULATE THE 011900 ; ; LENGTH TO LOAD 011910 ; ; INTO RAM 1313 8528 011920 STA ICBLLZ 1315 98 011930 TYA 1316 E525 011940 SBC ICBAHZ 1318 8529 011950 STA ICBLHZ 131A B08B 011960 BCS GETTXT ; BRANCH IF 011970 ; ; VALID LENGTH 011980 ; ; (GET DATA BYTES) 131C A0B5 011990 LDY #181 ; ELSE, MEMORY 012000 ; ; WRAP ERROR PAGE 37 LARGE DISK FMS D:MDOS2.M65 131E 3002 012010 BMI DKLERR 012020 ; 1320 012030 WDXIT 1320 68 012040 PLA 1321 68 012050 PLA 1322 012060 DKLERR 1322 98 012070 TYA 1323 48 012080 PHA 1324 206E0E 012090 JSR DKCLOS ; CLOSE THE 012100 ; ; PROGRAM FILE 1327 68 012110 PLA 1328 A8 012120 TAY ; AND RETURN ANY 012130 ; ; ERROR CODE 1329 60 012140 RTS 012150 ; 012160 ;*READ A WORD FROM THE PROGRAM 012170 ; FILE AND COMPARE IT WITH 012180 ; $FFFF 012190 ; 132A 012200 WDREAD 132A A900 012210 LDA #0 132C 8528 012220 STA ICBLLZ 132E 8529 012230 STA ICBLHZ ; SET LENGTH TO 012240 ; ; ZERO 1330 20740D 012250 JSR DKREAD ; READ A BYTE 1333 3010 012260 BMI WDEOF 1335 48 012270 PHA 1336 20740D 012280 JSR DKREAD ; READ THE 012290 ; ; SECOND BYTE 1339 3009 012300 BMI WDEOF1 133B A8 012310 TAY 133C 68 012320 PLA 133D C0FF 012330 CPY #$FF ; HI BYTE $FF? 133F D002 012340 BNE TORTS ; NO, THEN WORD 012350 ; ; IS NOT $FFFF 1341 C9FF 012360 CMP #$FF ; YES, IS LOWER 012370 ; ; BYTE $FF? 1343 012380 TORTS 1343 60 012390 RTS ; IF BOTH $FF, 012400 ; ; RETURN ZERO FLAG 012410 ; 1344 012420 WDEOF1 1344 68 012430 PLA 1345 012440 WDEOF 1345 C088 012450 CPY #136 ; IS THIS END OF 012460 ; ; FILE? 1347 D0D7 012470 BNE WDXIT ; IF NOT, RETURN 012480 ; ; ERROR CODE 1349 68 012490 PLA 134A 68 012500 PLA ; ELSE, GET RID 012510 ; ; OF RETURN ADDR 134B A526 012520 LDA ICPTLZ 134D 4A 012530 LSR A 134E 4A 012540 LSR A 134F 08 012550 PHP 1350 206E0E 012560 JSR DKCLOS ; CLOSE FILE AND 012570 ; ; SET Y=1 1353 28 012580 PLP PAGE 38 LARGE DISK FMS D:MDOS2.M65 1354 B0ED 012590 BCS TORTS ; EXIT IF NO-RUN 012600 ; ; SPECIFIED 1356 6CE002 012610 JMP (RUNADR) ; THEN GO TO 012620 ; ; RUN ADDRESS 012630 ; 012640 ;*INVOKE INIT FOR EVERY BLOCK 012650 ; OF INPUT CODE (USUALLY JUST 012660 ; AN RTS) 012670 ; 1359 012680 DOINIT 1359 6CE202 012690 JMP (INIADR) ; CALL INDIRECT 012700 ; XIO FUNCTION TO CREATE A NEW 012710 ; DIRECTORY PARSE DIR NAME 012720 ; 012730 ; 135C 012740 MKDIR 135C 202615 012750 JSR GETFNM 135F 20F915 012760 JSR SFDIR ; FIND FILE IN 012770 ; ; DIRECTORY 1362 B008 012780 BCS MKDMRD 1364 A9AC 012790 LDA #172 ;FILE ALREADY 012800 ; ; EXISTS 1366 AE 012810 .BYTE $AE ; FAKE LDX #169 1367 012820 DISFUL 1367 A9A9 012830 LDA #169 ; DIR FULL ERR 1369 4CB11A 012840 JMP AEXIT 012850 ; 012860 ;*READ IN BIT MAP 012870 ; 136C 012880 MKDMRD 136C ADBD07 012890 LDA HOLFN 136F 30F6 012900 BMI DISFUL 1371 20B717 012910 JSR RBITMP 1374 AC0809 012920 LDY MAPBUF 1377 88 012930 DEY 1378 88 012940 DEY 1379 842F 012950 STY DATBYT 012960 ; 012970 ;*FIND EIGHT SECTORS FOR 012980 ; DIRECTORY 012990 ; 137B A971 013000 LDA # <369 ; FIRST 013010 ; ; AVAILABLE SECTOR 013020 ; ; AFTER ROOT DIR 137D 9D6E08 013030 STA CURSEC,X 1380 A901 013040 LDA # >369 1382 9D6F08 013050 STA CURSEC+1,X 1385 A900 013060 LDA #0 1387 8548 013070 STA TMP1 1389 013080 FDIRLP 1389 E648 013090 INC TMP1 138B 208519 013100 JSR FNDLBIT ; IS THIS SECTOR 013110 ; ; FREE? 138E B005 013120 BCS FDIR2 1390 390809 013130 AND MAPBUF,Y 1393 9003 013140 BCC FDIR1 1395 013150 FDIR2 1395 39080A 013160 AND MAPBUF+256,Y PAGE 39 LARGE DISK FMS D:MDOS2.M65 1398 013170 FDIR1 1398 D002 013180 BNE FDIR3 139A 8548 013190 STA TMP1 139C 013200 FDIR3 139C 20AD19 013210 JSR INCCSEC 139F A548 013220 LDA TMP1 13A1 C908 013230 CMP #8 13A3 D0E4 013240 BNE FDIRLP 013250 ; 013260 ;*ALLOCATE THE SECTORS USED 013270 ; 13A5 013280 ALCDLP 13A5 20A119 013290 JSR DECCSEC 13A8 208519 013300 JSR FNDLBIT 13AB 49FF 013310 EOR #$FF 13AD B008 013320 BCS ALCPG2 13AF 390809 013330 AND MAPBUF,Y 13B2 990809 013340 STA MAPBUF,Y 13B5 9009 013350 BCC ALCPG1 13B7 013360 ALCPG2 13B7 39080A 013370 AND MAPBUF+256,Y 13BA 99080A 013380 STA MAPBUF+256,Y 13BD 4E6408 013390 LSR MAP2MOD 13C0 013400 ALCPG1 13C0 207819 013410 JSR DECCNT 13C3 C648 013420 DEC TMP1 13C5 D0DE 013430 BNE ALCDLP 013440 ; 013450 ;*WRITE ALLOCATION MAP BACK TO 013460 ; DISK 013470 ; 13C7 20F017 013480 JSR FMTMAP 013490 ; 013500 ;*ENTER NAME AND TYPE INFO 013510 ; INTO PARENT DIRECTORY 013520 ; 13CA ADBD07 013530 LDA HOLFN 13CD 208417 013540 JSR SDIRBK 13D0 38 013550 SEC 13D1 20DA15 013560 JSR ENTNAME 13D4 BD6F08 013570 LDA CURSEC+1,X 13D7 990C09 013580 STA DIRBUF+4,Y 13DA BD6E08 013590 LDA CURSEC,X 13DD 990B09 013600 STA DIRBUF+3,Y 13E0 A900 013610 LDA #0 13E2 990A09 013620 STA DIRBUF+2,Y 13E5 A908 013630 LDA #8 13E7 990909 013640 STA DIRBUF+1,Y 13EA 0A 013650 ASL A 13EB 20DC1A 013660 JSR SAVFLAG 013670 ; 013680 ;*THEN CLEAR NEW DIRECTORY 013690 ; 13EE A901 013700 LDA #1 13F0 8546 013710 STA FMSBPT 13F2 BD6E08 013720 LDA CURSEC,X 13F5 BC6F08 013730 LDY CURSEC+1,X 13F8 4C4412 013740 JMP CLRDIR PAGE 40 LARGE DISK FMS 1830 ; 1840 ; ; INTERNAL DISK I/O ROUTINES 1850 .INCLUDE #D:MDOS3.M65 10 ; SAVE#D:MDOS3.M65 20 ; 30 ; 40 ;*DOS DIRECTORY ROUTINES 50 ; 60 ;*OPEN A DIRECTORY (FOR USER) 70 ; 13FB 80 LSTDIR 13FB A075 90 LDY #$80-11 13FD 0100 SAVFNB 13FD B9930A 0110 LDA FNAME-$80+11,Y 1400 9146 0120 STA (FMSBPT),Y 1402 C8 0130 INY 1403 10F8 0140 BPL SAVFNB 1405 20F915 0150 JSR SFDIR ; FIND A MATCH 0160 ; ; IN THE DIR 1408 B045 0170 BCS ENDDIR ; IF NO MORE 0180 ; ; MATCHES, REPORT 0190 ; ; FREE SPACE 140A 0200 NXTDIR 140A 207E14 0210 JSR FMTDIR ; ENTRY FOUND, 0220 ; ; FORMAT INTO A 0230 ; ; TEXT STRING 140D A545 0240 LDA CURFNO 140F 9D6808 0250 STA FCBFNO,X ; SAVE THE FILE 0260 ; ; NUMBER OF THE 0270 ; ; ENTRY FOUND 1412 0280 GODONE 1412 4CAF1A 0290 JMP DONE ; AND RETURN 0300 ; 1415 0310 GOTEOD 1415 C62F 0320 DEC DATBYT ; CONVERT EOL TO 0330 ; ; $9B (REAL EOL) 1417 9D6C08 0340 STA CURLEN,X ; AND FINISH UP 141A D0F6 0350 BNE GODONE 0360 ; 141C 0370 DIRRD 141C A075 0380 LDY #$80-11 141E 0390 RSTFNB 141E B146 0400 LDA (FMSBPT),Y ; FETCH BYTES 0410 ; ; OF PREVIOUSLY 0420 ; ; PARSED DIR ENTRY 1420 99930A 0430 STA FNAME-$80+11,Y 1423 C8 0440 INY 1424 10F8 0450 BPL RSTFNB 1426 BD6C08 0460 LDA CURLEN,X 1429 3042 0470 BMI DIREOF ; EOF IF WE 0480 ; ; ALREADY REPORTED 0490 ; ; FREE SPACE 142B A8 0500 TAY 142C B146 0510 LDA (FMSBPT),Y 142E 852F 0520 STA DATBYT 1430 FE6C08 0530 INC CURLEN,X 1433 C99C 0540 CMP #$9C 1435 F0DE 0550 BEQ GOTEOD PAGE 41 LARGE DISK FMS D:MDOS3.M65 1437 C99B 0560 CMP #$9B ; IS THIS EOL? 1439 D0D7 0570 BNE GODONE ; IF NOT, 0580 ; ; CONTINUE FETCHING 0590 ; ; OLD BYTES 143B BD6808 0600 LDA FCBFNO,X 143E C545 0610 CMP CURFNO 1440 D005 0620 BNE DMSTRD 1442 ECBA07 0630 CPX DIUNIT 1445 F003 0640 BEQ DRDNRQ 1447 0650 DMSTRD 1447 208117 0660 JSR RRDIR ; IF SO, INSURE 0670 ; ; DIR BLOCK IS 0680 ; ; IN MEMORY 144A 0690 DRDNRQ 144A 202B16 0700 JSR CSFDIR ; AND FIND THE 0710 ; ; NEXT ENTRY 144D 90BB 0720 BCC NXTDIR ; IF FOUND, LOOP 0730 ; ; BACK AND FORMAT IT 0740 ; 0750 ;*NO MORE ENTRIES, REPORT FREE 0760 ; SECTORS LAST 0770 ; 144F 0780 ENDDIR 144F 20B717 0790 JSR RBITMP ; READ THE VTOC 1452 A000 0800 LDY #0 1454 8C6208 0810 STY CURMAP ; FORCE A REREAD 0820 ; ; NEXT TIME 1457 AD0B09 0830 LDA MAPBUF+3 145A AE0C09 0840 LDX MAPBUF+4 ; AND STUFF THE 0850 ; ; BUFFER WITH # 0860 ; ; OF FREE SECTORS 145D 20B814 0870 JSR CVTDEC 1460 A2F2 0880 LDX #-14 1462 0890 FSECL 1462 BD7E13 0900 LDA FSECM+14-256,X 0910 ; ; FOLLOWED BY THE 0920 ; ; "FREE SECTORS" TEXT 1465 9146 0930 STA (FMSBPT),Y 1467 C8 0940 INY 1468 E8 0950 INX 1469 D0F7 0960 BNE FSECL 146B F0A5 0970 BEQ GODONE 0980 ; 146D 0990 DIREOF 146D 4CD30D 1000 JMP RETEOF ; NO MORE LINES, 1010 ; ; RETURN EOF 1020 ; ; INDICATION 1030 ; 1470 1040 FSECM 1470 20465245 1050 .BYTE " FREE SECTORS",$9C 1474 45205345 1478 43544F52 147C 539C 1060 ; 1070 ;*FORMAT A DIRECTORY ENTRY FOR 1080 ; BASIC, ETC. 1090 ; 147E 1100 FMTDIR PAGE 42 LARGE DISK FMS D:MDOS3.M65 147E A020 1110 LDY #$20 1480 A643 1120 LDX DIRDSP 1482 BD0809 1130 LDA DIRBUF,X 1485 48 1140 PHA 1486 2920 1150 AND #$20 1488 F002 1160 BEQ D0E35 148A A02A 1170 LDY #'* ; IF SO, MARK AS 1180 ; ; LOCKED 148C 1190 D0E35 148C 98 1200 TYA 148D A000 1210 LDY #0 148F 9146 1220 STA (FMSBPT),Y 1491 68 1230 PLA 1492 A020 1240 LDY #' 1494 2910 1250 AND #$10 1496 F002 1260 BEQ NOTDIR 1498 A03A 1270 LDY #': 149A 1280 NOTDIR 149A 98 1290 TYA 149B A001 1300 LDY #1 149D 9146 1310 STA (FMSBPT),Y 149F 1320 CPYNAML 149F C8 1330 INY 14A0 BD0D09 1340 LDA DIRBUF+5,X 14A3 9146 1350 STA (FMSBPT),Y 14A5 E8 1360 INX 14A6 C00D 1370 CPY #13 14A8 90F5 1380 BCC CPYNAML 1390 ; 14AA A920 1400 LDA #' 14AC 9146 1410 STA (FMSBPT),Y 14AE A443 1420 LDY DIRDSP 14B0 B90909 1430 LDA DIRBUF+1,Y 14B3 BE0A09 1440 LDX DIRBUF+2,Y 14B6 A00E 1450 LDY #14 ; SECTOR COUNT 1460 ; ; STARTS HERE 1470 ; 1480 ;*CONVERT A 16-BIT INTEGER TO A 1490 ; 4 OR 5 DIGIT NUMBER 1500 ; 14B8 1510 CVTDEC 14B8 8649 1520 STX TMP2 14BA 8548 1530 STA TMP1 14BC A227 1540 LDX # >10000 14BE A910 1550 LDA # <10000 14C0 20FA14 1560 JSR MKDGT2 14C3 48 1570 PHA ;* [D] 14C4 C930 1580 CMP #'0 14C6 D001 1590 BNE SKIP5 14C8 88 1600 DEY 14C9 1610 SKIP5 14C9 A203 1620 LDX # >1000 14CB A9E8 1630 LDA # <1000 14CD 20FA14 1640 JSR MKDGT2 14D0 C931 1650 CMP #'0+1 ;* [D] 14D2 68 1660 PLA ;* [D] 14D3 B005 1670 BCS SKIP4 ;* [D] 14D5 C930 1680 CMP #'0 ;* [D] PAGE 43 LARGE DISK FMS D:MDOS3.M65 14D7 D001 1690 BNE SKIP4 ;* [D] 14D9 88 1700 DEY ;* [D] 14DA 1710 SKIP4 1720 ; ;* [D] Skip4 1730 ; [D] is David's code 1740 ; transplanted from 4.53 to 1750 ; 4.51 by Lee 1760 ; 14DA A964 1770 LDA #100 ; FOR THE SHORT 1780 ; ; STUFF 14DC 20F814 1790 JSR MAKDGT 14DF A90A 1800 LDA #10 14E1 20F814 1810 JSR MAKDGT 14E4 8A 1820 TXA 14E5 693A 1830 ADC #'0+10 14E7 9146 1840 STA (FMSBPT),Y 14E9 C8 1850 INY 14EA A99B 1860 LDA #$9B ; TERMINATE LINE 14EC 852F 1870 STA DATBYT 14EE 9146 1880 STA (FMSBPT),Y 14F0 A900 1890 LDA #0 14F2 A62E 1900 LDX CURFCB 14F4 9D6C08 1910 STA CURLEN,X 14F7 60 1920 RTS 1930 ; 1940 ;*CREATE A DIGIT AND STORE IT 1950 ; INTO THE DIRECTORY BUFFER 1960 ; 14F8 1970 MAKDGT 14F8 A200 1980 LDX #0 ; IF SUBTRAHEND 1990 ; ; < 256, ZERO HI 14FA 2000 MKDGT2 14FA 8643 2010 STX DIRDSP 14FC 8544 2020 STA DIRSEC 14FE 842F 2030 STY DATBYT 1500 A030 2040 LDY #'0 1502 38 2050 SEC 1503 2060 DGTLP2 1503 A548 2070 LDA TMP1 1505 E544 2080 SBC DIRSEC 1507 AA 2090 TAX 1508 A549 2100 LDA TMP2 150A E543 2110 SBC DIRDSP 150C 9007 2120 BCC DGTXIT 150E 8549 2130 STA TMP2 1510 8648 2140 STX TMP1 1512 C8 2150 INY 1513 B0EE 2160 BCS DGTLP2 2170 ; 1515 2180 DGTXIT 1515 98 2190 TYA 1516 A42F 2200 LDY DATBYT 1518 9146 2210 STA (FMSBPT),Y 151A C8 2220 INY 151B 60 2230 RTS 2240 ; 2250 ;*PARSE A FILE NAME WITH WILD 2260 ; CARD CHARACTERS ('*' AND '?') PAGE 44 LARGE DISK FMS D:MDOS3.M65 2270 ; 151C 2280 GETNM2 151C C8 2290 INY ; look for > in 151D B124 2300 LDA (ICBALZ),Y ; the start 151F C93E 2310 CMP #'> ; of the fname 1521 F02E 2320 BEQ GETNAM ; (for SpartaDOS 2330 ; ; Compatabiliy) 1523 88 2340 DEY ; [Bob Puff] 1524 D02B 2350 BNE GETNAM ; branch always 2360 ; 1526 2370 GETFNM 1526 A62E 2380 LDX CURFCB 1528 A001 2390 LDY # >361 152A A969 2400 LDA # <361 152C 207112 2410 JSR SETDIR 152F C8 2420 INY 1530 B124 2430 LDA (ICBALZ),Y 1532 C8 2440 INY 1533 C93A 2450 CMP #': ; DEFAULT 2460 ; ; DIRECTORY? 1535 D0E5 2470 BNE GETNM2 ; IF NOT, CHECK 2480 ; ; FOR SPARTA ">" 1537 88 2490 DEY 1538 8448 2500 STY TMP1 153A AC0B07 2510 LDY DEFAULT 153D 8421 2520 STY ICDNOZ 153F 98 2530 TYA 1540 9D4103 2540 STA ICDNO,X 1543 20C019 2550 JSR SETUPD 1546 ADBB07 2560 LDA CDIREC 1549 ACBC07 2570 LDY CDIREC+1 154C 207112 2580 JSR SETDIR 154F A448 2590 LDY TMP1 2600 ; 1551 2610 GETNAM 1551 A2F5 2620 LDX #-11 1553 C8 2630 INY 1554 2640 AFTSTR 1554 B124 2650 LDA (ICBALZ),Y 1556 C92A 2660 CMP #'* 1558 D00F 2670 BNE TSTPER 155A A93F 2680 LDA #'? 155C C8 2690 INY 155D 2700 QLOOP 155D 9D130A 2710 STA FNAME+11-256,X 1560 E8 2720 INX 1561 1032 2730 BPL TOXITC ; END OF 2740 ; ; EXTENSION? 1563 2750 PERFND 1563 E0FD 2760 CPX #-3 ; END OF FILE 2770 ; ; NAME? 1565 D0F6 2780 BNE QLOOP ; NO MORE -?-S 1567 F0EB 2790 BEQ AFTSTR 2800 ; 1569 2810 TSTPER 1569 C92E 2820 CMP #'. ; A PERIOD? 156B D005 2830 BNE TSTCHR ; IF NOT, CHECK 2840 ; ; FOR INDIVIDUAL PAGE 45 LARGE DISK FMS D:MDOS3.M65 2850 ; ; CHARACTERS 156D A920 2860 LDA #' ; IF SO, FILL 2870 ; ; WITH SPACES 156F C8 2880 INY 1570 D0F1 2890 BNE PERFND 2900 ; 1572 2910 TSTCHR 1572 C93F 2920 CMP #'? 1574 900C 2930 BCC ENDCHR ; IF < '?', 2940 ; ; CHECK FOR DIGIT 1576 C95B 2950 CMP #'Z+1 ; ELSE, UPPER 2960 ; ; CASE LETTER, 2970 ; ; '?', OR '@'? 1578 9014 2980 BCC GOTCHR 157A C95F 2990 CMP #'_ 157C 9004 3000 BCC ENDCHR ; IF CARET, 3010 ; ; BACKSL. OR 3020 ; ; BRACKETS 157E C97B 3030 CMP #'z+1 ; LOWER CASE, 3040 ; ; ACCENT OR 3050 ; ; UNDERSCORE? 1580 900C 3060 BCC GOTCHR 1582 3070 ENDCHR 1582 E0F5 3080 CPX #-11 ; IF FIRST CHAR, 1584 F02C 3090 BEQ ERRCHR ; NO BYTES IN 3100 ; ; FILE NAME 1586 C930 3110 CMP #'0 ; ELSE, A DIGIT? 1588 902D 3120 BCC FILLNM ; IF NOT, THIS 3130 ; ; IS END OF NAME 158A C93A 3140 CMP #': 158C B029 3150 BCS FILLNM 3160 ; 158E 3170 GOTCHR 158E 9D130A 3180 STA FNAME+11-256,X 1591 C8 3190 INY 1592 E8 3200 INX 1593 30BF 3210 BMI AFTSTR 3220 ; 1595 3230 TOXITC 1595 B124 3240 LDA (ICBALZ),Y 1597 3250 TSTDIR 1597 C93A 3260 CMP #': ; LOOK FOR 3270 ; ; SUBDIRECTORY 1599 F004 3280 BEQ MYDIR ; IF MYDOS 159B C93E 3290 CMP #'> ; OR SPARTA 159D D057 3300 BNE XITCHR ; IF FINISHED, 3310 ; ; RESTORE FCB PTR 3320 ; ; TO X AND EXIT 159F 3330 MYDIR 159F 8449 3340 STY TMP2 15A1 20F915 3350 JSR SFDIR ; ELSE, FIND 3360 ; ; FILE 15A4 B009 3370 BCS FNER1 ; NO SUCH FILE 15A6 20C415 3380 JSR TONXDR 15A9 F004 3390 BEQ FNER1 15AB A449 3400 LDY TMP2 15AD D0A2 3410 BNE GETNAM 15AF 3420 FNER1 PAGE 46 LARGE DISK FMS D:MDOS3.M65 15AF A9AE 3430 LDA #174 ; RETURN ERROR 3440 ; ; DUP FNAME ERR 15B1 2C 3450 .BYTE $2C ; FAKE BIT 3460 ; 15B2 3470 ERRCHR 15B2 A9A5 3480 LDA #165 ; FILE NAME ERR 15B4 4CB11A 3490 JMP AEXIT 3500 ; 15B7 3510 FILLNM 15B7 48 3520 PHA 15B8 A920 3530 LDA #' 15BA 3540 FILLLP 15BA 9D130A 3550 STA FNAME+11-256,X 15BD E8 3560 INX 15BE 30FA 3570 BMI FILLLP 15C0 68 3580 PLA 15C1 4C9715 3590 JMP TSTDIR 3600 ; 3610 ;*RETURN WITH NON-ZERO FLAG IF 3620 ; FILE IS A DIRECTORY 3630 ; 15C4 3640 TONXDR 15C4 A910 3650 LDA #$10 ; FILE FOUND, A 3660 ; ; DIRECTORY? 15C6 20D61A 3670 JSR GETFLAG 15C9 F00E 3680 BEQ TONXIT ; IF NOT, SET 3690 ; ; ZERO FLAG 15CB B90B09 3700 LDA DIRBUF+3,Y ; IF SO, MOVE 3710 ; ; POINTERS TO THE 3720 ; ; NEW LEVEL 15CE 9D7408 3730 STA DIRBAS,X 15D1 B90C09 3740 LDA DIRBUF+4,Y 15D4 9D7508 3750 STA DIRBAS+1,X 15D7 A910 3760 LDA #$10 ; AND CLEAR THE 3770 ; ; ZERO FLAG 15D9 3780 TONXIT 15D9 60 3790 RTS 3800 ; 3810 ;*ENTER A NAME INTO THE 3820 ; DIRECTORY AT DIRBUF[DIRDSP 3830 ; 15DA 3840 ENTNAME 15DA 08 3850 PHP 15DB A2F5 3860 LDX #-11 15DD A443 3870 LDY DIRDSP 15DF 3880 NAMELP 15DF BD130A 3890 LDA FNAME+11-256,X ; LOAD 3900 ; ; THE MASK CHARACTER 15E2 C93F 3910 CMP #'? 15E4 D006 3920 BNE STORIT ; IF NOT '?', 3930 ; ; SAVE IT AS IT 3940 ; ; APPEARS 15E6 28 3950 PLP 15E7 08 3960 PHP 15E8 9005 3970 BCC NOSTOR ; IF CY CLEAR, 3980 ; ; LEAVE THE 3990 ; ; CHARACTERS UNCHANGED 15EA A920 4000 LDA #' ; IF CY SET, PAGE 47 LARGE DISK FMS D:MDOS3.M65 4010 ; ; CONVERT '?'S TO 4020 ; ; SPACES 15EC 4030 STORIT 15EC 990D09 4040 STA DIRBUF+5,Y 15EF 4050 NOSTOR 15EF C8 4060 INY 15F0 E8 4070 INX 15F1 30EC 4080 BMI NAMELP 15F3 28 4090 PLP 15F4 A443 4100 LDY DIRDSP 15F6 4110 XITCHR 15F6 A62E 4120 LDX CURFCB 15F8 60 4130 RTS 4140 ; 15F9 4150 SFDIR 15F9 20E817 4160 JSR WBITMP ; INSURE BIT MAP 4170 ; ; IS SAFE 15FC A2FF 4180 LDX #255 15FE 8EBD07 4190 STX HOLFN 1601 8645 4200 STX CURFNO 1603 E8 4210 INX 1604 8E0B03 4220 STX DAUX2 1607 E8 4230 INX 1608 8E0A03 4240 STX DAUX1 160B A252 4250 LDX #READ 160D 8E0203 4260 STX DCOMND 1610 207018 4270 JSR SYSSET ; SET UP 4280 ; ; POINTERS FOR 4290 ; ; SYSTEM BUFFER I/O 4300 ; 1613 A521 4310 LDA ICDNOZ 1615 CD0A07 4320 CMP RAMDKU 1618 F011 4330 BEQ CSFDIR ; IF RAMDISK, 4340 ; ; FORGET DENSITY 4350 ; ; CHECK 161A A62E 4360 LDX CURFCB ; IF A ROOT 4370 ; ; DIRECTORY ACCESS, 4380 ; ; READ BOOT SEC 161C BD7408 4390 LDA DIRBAS,X ; IF IN A 4400 ; ; SUBDIRECTORY, 4410 ; ; ASSUME DENSITY 4420 ; ; IS OK 161F C969 4430 CMP # <361 ; [Bob Puff] 1621 D008 4440 BNE CSFDIR 4450 ;;; lda DIRBAS+1,X ; Only 4460 ;;; ; occasionally 4470 ;;; ; will we get an 4480 ;;; ; extra read! 4490 ;;; cmp # >361 4500 ;;; bne CSFDIR 4510 ; 1623 2053E4 4520 JSR DSKINV ; ELSE, READ THE 4530 ; ; FIRST BOOT SECTOR 1626 304E 4540 BMI ERRX 1628 20011A 4550 JSR INVUNIT ; UPDATE DRIVE 4560 ; ; CONFIGURATION 4570 ; 162B 4580 CSFDIR PAGE 48 LARGE DISK FMS D:MDOS3.M65 162B E645 4590 INC CURFNO ; READ NEXT 4600 ; ; 16-BYTE DIR ENTRY 162D A545 4610 LDA CURFNO 162F 207718 4620 JSR BSECDS ; CONVERT TO 4630 ; ; SECTOR AND 4640 ; ; DISPLACEMENT 1632 4650 XITCH1 1632 B0C2 4660 BCS XITCHR 1634 D003 4670 BNE NOREAD ; IF DISP>0, 4680 ; ; PROCESS ENTRY 1636 208B17 4690 JSR RDIRBK ; IF DISP=0, 4700 ; ; READ SECTOR 4710 ; 1639 4720 NOREAD 1639 A443 4730 LDY DIRDSP 163B B90809 4740 LDA DIRBUF,Y 163E F029 4750 BEQ FNDOLD ; ZERO IS END OF 4760 ; ; DIRECTORY (NO 4770 ; ; MORE ENTRIES) 1640 3027 4780 BMI FNDOLD ; NEGATIVE IS 4790 ; ; EMPTY SLOT 4800 ; ; (MAY HAVE MORE 4810 ; ; ENTRIES) 4820 ; 4830 ;*HANDLE DOS 2.5 FILES 4840 ; 1642 29DF 4850 AND #$DF ; preserve lock 4860 ; ; flag 1644 C903 4870 CMP #3 ; is this DOS 4880 ; ; 2.5 + file? 1646 D008 4890 BNE NOD25 ; nope 1648 A941 4900 LDA #$41 ; otherwise, 4910 ; ; kludge the 164A 590809 4920 EOR DIRBUF,Y ; flag to make 4930 ; ; $42 164D 990809 4940 STA DIRBUF,Y ; and save lock 4950 ; 1650 4960 NOD25 1650 2901 4970 AND #$01 ; IGNORE ANY 4980 ; ; FILE THAT IS 4990 ; ; MARKED "OPEN" 1652 D0D7 5000 BNE CSFDIR 1654 A2F5 5010 LDX #-11 1656 5020 CPNXCH 1656 BD130A 5030 LDA FNAME+11-256,X 1659 C93F 5040 CMP #'? 165B F005 5050 BEQ WCMTCH ; EVERYTHING 5060 ; ; MATCHES "?" 165D D90D09 5070 CMP DIRBUF+5,Y 1660 D0C9 5080 BNE CSFDIR ; NO MATCH, LOOK 5090 ; ; AT THE NEXT 5100 ; ; DIRECTORY ENTRY 1662 5110 WCMTCH 1662 C8 5120 INY 1663 E8 5130 INX 1664 30F0 5140 BMI CPNXCH 1666 18 5150 CLC 1667 908D 5160 BCC XITCHR ; ENTRY FOUND, PAGE 49 LARGE DISK FMS D:MDOS3.M65 5170 ; ; RETURN WITH CY=0 5180 ; 1669 5190 FNDOLD 1669 AEBD07 5200 LDX HOLFN 166C 1005 5210 BPL KPOLD ; IF AN EMPTY 5220 ; ; SLOT IS ALREADY 5230 ; ; FOUND, DO NOTHING 166E A645 5240 LDX CURFNO 1670 8EBD07 5250 STX HOLFN ; ELSE SAVE THIS 5260 ; ; ONE, ITS THE 5270 ; ; FIRST! 1673 5280 KPOLD 1673 AA 5290 TAX 1674 30B5 5300 BMI CSFDIR ; IF NOT END OF 5310 ; ; THE DIRECTORY, 5320 ; ; KEEP LOOKING 1676 5330 ERRX 1676 38 5340 SEC 1677 B0B9 5350 BCS XITCH1 ; ELSE, ENTRY 5360 ; ; NOT FOUND, 5370 ; ; RETURN WITH CY=1 5380 ; 5390 ;*DOS I/O ROUTINES 5400 ; 5410 ;*DISK SECTOR I/O ROUTINES 5420 ; 1679 5430 WRDISK 1679 38 5440 SEC ; FMS DISK WRITE 5450 ; ; ENTRY 167A 5460 RWDISK 167A A446 5470 LDY FMSBPT ; DATA SECTOR 5480 ; ; READ/WRITE ENTRY 167C A547 5490 LDA FMSBPT+1 167E 205C07 5500 JSR BUFSET 1681 BD6F08 5510 LDA CURSEC+1,X 1684 BC6E08 5520 LDY CURSEC,X 1687 5530 FMDKIO 1687 08 5540 PHP 1688 AE0103 5550 LDX DUNIT 168B EC0A07 5560 CPX RAMDKU 168E F00A 5570 BEQ RDKIO1 1690 28 5580 PLP 1691 48 5590 PHA ; ALLOW FOR 5600 ; ; DENSITY CHANGE 5610 ; ; IN FORMAT, ETC. 1692 BDC307 5620 LDA SECSIZ-1,X ; [Bob Puff] 1695 AA 5630 TAX 1696 68 5640 PLA 1697 4C6307 5650 JMP DKIO 5660 ; 169A 5670 RDKIO1 169A 4C330C 5680 JMP RDKIO ; ABSOLUTE DISK 5690 ; ; I/O ROUTINE WAS 5700 ; ; MOVED TO LOW RAM 5710 ; 169D 5720 EXTEND 169D 20EE18 5730 JSR ALLOC 16A0 BD6908 5740 LDA FCBOTC,X PAGE 50 LARGE DISK FMS D:MDOS3.M65 16A3 4A 5750 LSR A 16A4 9009 5760 BCC REWRIT 16A6 DE6908 5770 DEC FCBOTC,X 16A9 201F17 5780 JSR WTRICK 16AC 4CB816 5790 JMP WRTTST 5800 ; 16AF 5810 REWRIT 16AF BC7108 5820 LDY LNKSEC+1,X 16B2 BD7008 5830 LDA LNKSEC,X 16B5 20FA16 5840 JSR SAVLNK 16B8 5850 WRTTST 16B8 303D 5860 BMI RTBADF 16BA FE7208 5870 INC SECCNT,X 16BD D003 5880 BNE TONXT 16BF FE7308 5890 INC SECCNT+1,X 5900 ; 16C2 5910 TONXT 16C2 BD7008 5920 LDA LNKSEC,X ; MAKE NEXT 5930 ; ; SECTOR 16C5 9D6E08 5940 STA CURSEC,X ; NEW CURRENT 5950 ; ; SECTOR 16C8 BD7108 5960 LDA LNKSEC+1,X 16CB 9D6F08 5970 STA CURSEC+1,X 16CE A900 5980 LDA #0 16D0 9D7008 5990 STA LNKSEC,X ; ZERO LINK 16D3 9D7108 6000 STA LNKSEC+1,X 16D6 6010 LENSET 16D6 9D6C08 6020 STA CURLEN,X ; ZERO CURRENT 6030 ; ; OFFSET 16D9 AD1107 6040 LDA DLINK ; GET THE LINK 16DC 9D6B08 6050 STA MAXLEN,X ; NEW MAXLEN 16DF 18 6060 CLC ; CLEAR CY FOR 6070 ; ; LATER READ 16E0 60 6080 RTS 6090 ; 16E1 6100 RDNXTS 16E1 BD6A08 6110 LDA FCBFLG,X 16E4 F05A 6120 BEQ CHASE 6130 ; 16E6 6140 WRNXTS 16E6 BD6A08 6150 LDA FCBFLG,X 16E9 30B2 6160 BMI EXTEND 16EB 0A 6170 ASL A 16EC 10F3 6180 BPL RDNXTS 16EE 0A 6190 ASL A 16EF 9D6A08 6200 STA FCBFLG,X 16F2 207916 6210 JSR WRDISK 16F5 10EA 6220 BPL RDNXTS 6230 ; 16F7 6240 RTBADF 16F7 4CC01A 6250 JMP HWERR ; RETURN HARDW 6260 ; ; ERROR CODE IF 6270 ; ; PRESENT 6280 ; 16FA 6290 SAVLNK 16FA 48 6300 PHA 16FB 98 6310 TYA 16FC AC1107 6320 LDY DLINK PAGE 51 LARGE DISK FMS D:MDOS3.M65 16FF 9146 6330 STA (FMSBPT),Y 1701 68 6340 PLA 1702 C8 6350 INY 1703 9146 6360 STA (FMSBPT),Y 1705 C8 6370 INY 1706 BD6C08 6380 LDA CURLEN,X 1709 6390 NOBIT 1709 9146 6400 STA (FMSBPT),Y 170B BC6908 6410 LDY FCBOTC,X 170E 300C 6420 BMI LEN16 ; 16-BIT LENGTH? 1710 BD6808 6430 LDA FCBFNO,X 1713 0A 6440 ASL A 1714 0A 6450 ASL A 1715 AC1107 6460 LDY DLINK 1718 1146 6470 ORA (FMSBPT),Y 171A 9146 6480 STA (FMSBPT),Y 171C 6490 LEN16 171C 4C7916 6500 JMP WRDISK 6510 ; 171F 6520 WTRICK 171F BD7008 6530 LDA LNKSEC,X 1722 9D7608 6540 STA SAVSEC,X 1725 BD7108 6550 LDA LNKSEC+1,X 1728 9D7708 6560 STA SAVSEC+1,X 172B 8E6708 6570 STX LSTIOCB 172E BD6E08 6580 LDA CURSEC,X 1731 8D6508 6590 STA LSTSEC 1734 BD6F08 6600 LDA CURSEC+1,X 1737 8D6608 6610 STA LSTSEC+1 173A 4C7916 6620 JMP WRDISK 6630 ; 173D 6640 INSTRT 173D 20EE0E 6650 JSR INITYP 6660 ; 1740 6670 CHASE 1740 BD7008 6680 LDA LNKSEC,X 1743 1D7108 6690 ORA LNKSEC+1,X 1746 F037 6700 BEQ NOLINK 1748 20C216 6710 JSR TONXT ; CY=0=READ 174B 207A16 6720 JSR RWDISK 174E 30A7 6730 BMI RTBADF ;CANNOT READ SO 6740 ; ; BAD FILE NUMBER 6750 ; ; (ERR=164) 1750 AC1107 6760 LDY DLINK 1753 BD6908 6770 LDA FCBOTC,X ; 16-BIT LINK? 1756 097F 6780 ORA #$7F 1758 300B 6790 BMI LNGLNK 175A B146 6800 LDA (FMSBPT),Y 175C 4A 6810 LSR A 175D 4A 6820 LSR A 175E DD6808 6830 CMP FCBFNO,X 1761 D015 6840 BNE XLINKED 1763 A903 6850 LDA #$03 1765 6860 LNGLNK 1765 3146 6870 AND (FMSBPT),Y 1767 9D7108 6880 STA LNKSEC+1,X 176A C8 6890 INY 176B B146 6900 LDA (FMSBPT),Y PAGE 52 LARGE DISK FMS D:MDOS3.M65 176D 9D7008 6910 STA LNKSEC,X 1770 C8 6920 INY 1771 B146 6930 LDA (FMSBPT),Y 1773 9D6B08 6940 STA MAXLEN,X 1776 6950 DRDXIT 1776 18 6960 CLC 1777 60 6970 RTS 6980 ; 1778 6990 XLINKED 1778 BD4203 7000 LDA ICCOM,X 177B C921 7010 CMP #FMTCMD ; IS THIS A 7020 ; ; FORMAT? 177D D030 7030 BNE FNOERR 177F 7040 NOLINK 177F 38 7050 SEC 1780 60 7060 RTS 7070 ; 7080 ;*READ OR WRITE A DIRECTORY 7090 ; BLOCK 7100 ; 1781 7110 RRDIR 1781 BD6808 7120 LDA FCBFNO,X 7130 ; 1784 7140 SDIRBK 1784 8545 7150 STA CURFNO 1786 7160 RDCFNO 1786 A545 7170 LDA CURFNO 1788 207718 7180 JSR BSECDS 7190 ; 178B 7200 RDIRBK 178B 20E817 7210 JSR WBITMP ; TAKE CONTROL 7220 ; ; OF SYSTEM BUFFER 178E 18 7230 CLC 178F A9 7240 .BYTE $A9 ; FAKE LDA $38 1790 7250 WDIRBK 1790 38 7260 SEC 1791 7270 RWDBK 1791 08 7280 PHP 1792 A62E 7290 LDX CURFCB ; PUT FCB # IN X 1794 8EBA07 7300 STX DIUNIT ; SAVE THE DIR 7310 ; ; BUFFER IOCB 1797 207018 7320 JSR SYSSET 179A 18 7330 CLC 179B A544 7340 LDA DIRSEC 179D 7D7408 7350 ADC DIRBAS,X 17A0 A8 7360 TAY 17A1 BD7508 7370 LDA DIRBAS+1,X 17A4 6900 7380 ADC #0 ; MULTIPLE DIRS 7390 ; ; REQ THIS [ChasM] 17A6 28 7400 PLP 17A7 7410 SYSRW 17A7 208716 7420 JSR FMDKIO 17AA 10CA 7430 BPL DRDXIT 17AC A9A3 7440 LDA #163 ; BIT MAP R/W 7450 ; ; ERROR, RETURN 7460 ; ; SYSTEM ERR CODE 17AE AE 7470 .BYTE $AE ; FAKE LDX 7480 ; PAGE 53 LARGE DISK FMS D:MDOS3.M65 17AF 7490 FNOERR 17AF A9A4 7500 LDA #164 ; BAD LINKS ERR 17B1 8D0303 7510 STA DSTATS 17B4 4CC01A 7520 JMP HWERR ; FILE NUMBER 7530 ; ; MISMATCH 7540 ; 7550 ;*READ OR WRITE THE DISK VTOC 7560 ; (BIT MAP) 7570 ; 17B7 7580 RBITMP 17B7 AD6208 7590 LDA CURMAP 17BA C521 7600 CMP ICDNOZ 17BC F029 7610 BEQ MAPXIT ; SKIP READ IF 7620 ; ; WHAT WE WANT 7630 ; ; IS ALREADY THERE 17BE 20E817 7640 JSR WBITMP ; ELSE, REAL 7650 ; ; I/O, SAVE CURRENT 7660 ; ; BUFFER CONTENTS 7670 ; 17C1 A900 7680 LDA #0 17C3 A8 7690 TAY 17C4 7700 ZMAP 17C4 990809 7710 STA MAPBUF,Y ; ZERO ENTIRE 7720 ; ; 512 17C7 99080A 7730 STA MAPBUF+256,Y ;BYTES OF 7740 ; ; MAP BUFFFER 17CA 88 7750 DEY 17CB D0F7 7760 BNE ZMAP 17CD 18 7770 CLC 17CE 203218 7780 JSR RWBMAP ; THEN READ 128 7790 ; ; OR 256 BYTES OF 7800 ; ; VTOC DATA 7810 ; 17D1 A0FF 7820 LDY #$FF 17D3 8CBA07 7830 STY DIUNIT ; INDICATE MAP 7840 ; ; (NOT DIR) IS LOADED 17D6 8C6308 7850 STY MAP2 ; INDICATE 7860 ; ; SECOND PAGE OF 7870 ; ; MAP IS UNLOADED 17D9 C8 7880 INY 17DA 8C6108 7890 STY CHGMAP ; INDICATE MAP 7900 ; ; IS UNCHANGED 17DD C8 7910 INY 17DE 8C6408 7920 STY MAP2MOD 17E1 8C140B 7930 STY CURMP 7940 ; 17E4 7950 MAPCLR 17E4 8D6208 7960 STA CURMAP ; AND SAVE DRIVE 7970 ; ; # MAP APPLIES TO 17E7 7980 MAPXIT 17E7 60 7990 RTS 8000 ; 17E8 8010 WBITMP 17E8 AD6108 8020 LDA CHGMAP 17EB F0F7 8030 BEQ MAPCLR ; IF MAP NOT 8040 ; ; CHANGED, SKIP 8050 ; ; WRITING IT 17ED 8D0103 8060 STA DUNIT PAGE 54 LARGE DISK FMS D:MDOS3.M65 17F0 8070 FMTMAP 17F0 A900 8080 LDA #0 17F2 8D6108 8090 STA CHGMAP ; ELSE MARK IT 8100 ; ; UNUSED 17F5 8D6208 8110 STA CURMAP 17F8 AD0103 8120 LDA DUNIT ; save drive # 8130 ; ; [Bob Puff] 17FB 48 8140 PHA 17FC 38 8150 SEC 17FD 203218 8160 JSR RWBMAP 1800 68 8170 PLA ; then restore 8180 ; ; it [Bob Puff] 1801 8D0103 8190 STA DUNIT 8200 ; 1804 8210 WRNXTM 1804 AD6408 8220 LDA MAP2MOD 1807 D061 8230 BNE NOMPI2 ; IF THE PAGE 8240 ; ; BUFFER IS 8250 ; ; CLEAN, JUST EXIT 1809 A9FF 8260 LDA #$FF ; ELSE, WRITE IT 8270 ; ; TO DISK 180B 48 8280 PHA 180C AD6308 8290 LDA MAP2 180F EE6408 8300 INC MAP2MOD 1812 38 8310 SEC 1813 B00C 8320 BCS MUSTWM 8330 ; 1815 8340 RDNXTM 1815 CD6308 8350 CMP MAP2 ; READ A PAGE 8360 ; ; INTO THE SECOND 8370 ; ; PAGE BUFFER 1818 F017 8380 BEQ NOMAPI ; IF IT IS 8390 ; ; ALREADY THERE, 8400 ; ; JUST EXIT 181A 48 8410 PHA 181B 200418 8420 JSR WRNXTM ; ELSE, WRITE 8430 ; ; THE CURRENT 8440 ; ; PAGE (IF NECESSARY) 181E 68 8450 PLA ; AND READ THE 8460 ; ; NEW ONE 181F 48 8470 PHA 1820 18 8480 CLC ; BY FALLING 8490 ; ; INTO MUSTWM 8500 ; ; WITH CY=0 8510 ; 1821 8520 MUSTWM 1821 48 8530 PHA 1822 A90A 8540 LDA # >MAPBUF+256 1824 A008 8550 LDY # 360 1852 28 9000 PLP 1853 08 9010 PHP 1854 20A717 9020 JSR SYSRW ; READ OR WRITE 9030 ; ; THE FIRST SECTOR 1857 AD0809 9040 LDA MAPBUF 185A C903 9050 CMP #3 ; IF DOS 2.0 9060 ; ; DISK, READ ONE 9070 ; ; SECTOR 185C 900B 9080 BCC XITMBF ; EVEN IN SINGLE 9090 ; ; DENSITY 185E 205D0C 9100 JSR STEPBP 1861 88 9110 DEY 1862 9120 DDMAPX 1862 A901 9130 LDA # >360 1864 28 9140 PLP 1865 08 9150 PHP 1866 20A717 9160 JSR SYSRW ; READ OR WRITE 9170 ; ; THE SECOND (OR 9180 ; ; ONLY) SECTOR 1869 9190 XITMBF 1869 28 9200 PLP 186A 9210 NOMPI2 186A A521 9220 LDA ICDNOZ PAGE 56 LARGE DISK FMS D:MDOS3.M65 186C 8D0103 9230 STA DUNIT ; RESTORE THE 9240 ; ; USER DRIVE 9250 ; ; NUMBER TO DUNIT, 186F 60 9260 RTS ; SINCE I/O MAY 9270 ; ; HAVE BEEN TO 9280 ; ; ANOTHER DRIVE 9290 ; 1870 9300 SYSSET 1870 A909 9310 LDA # >MAPBUF 1872 A008 9320 LDY # BOOTFL 1A46 A000 3520 LDY #