DSK_IN 3.0 - Encapsulate an MSDOS file into Apple ][ DOS 3.3 .DSK file. NOTE: The described software is -------->"RELIEFWARE"<--------, meaning a form of shareware. If you buy this package for $10, I will donate all that money to a homeless shelter nearby. The shelter chosen is subject to change, but the one presently designated is named "Spot Pond" and provides housing on a temporary basis to displaced families, and is located in Stoneham, Massachusetts. This package is not freeware, and I hope that, after you've used it for a week, you'll decide you'll want to legally own it. In return for the money, I will place your name permanently on a mailing list connected with this product, and you'll receive future versions, and if I ever release the source code, you will get that, too. (See below for info on future features.) Tom Baker, Jan, 1993 Please send a ten dollar bill and your E-mail address (preferred) to register to: Tom Baker 237 Main Street, #A-11 Reading, MA 01867 Copyright (C) 1993 Thomas A.J.F. Baker, All Rights Reserved. WHAT IT DOES: Given a file on your MSDOS disk, you can make a .DSK file that contains that file. If the file was directly XMODEMed from the Apple, then no conversion need be done. But, if it is a text file in MSDOS text format, or a binary file, the necessary conversions can be done to make the output .DSK contain the correct Apple format text or binary file. WHAT IT DOES NOT DO: To avoid disappointment, I'll state this up front. This will not read a physical, Apple format, 5-1/4" disk in an IBM 5-1/4" drive. Invocation: (You can give it whatever name you want, but I'll assume you left it.) dsk_in mt[u] {i|b|a|r|t}[l] in out or dsk_in mb {i|b|a|r|t}[l] in out or dsk_in a {i|b|a|r|t}[l] in out FIRST ARGUMENT is what is to be imported. where "a" means it is a file directly XMODEMed or KERMITed from the Apple, and needs no conversions. "m" means it is a native MSDOS file (requiring a further qualifier). "mt" means it is a MSDOS text file and needs conversion to Apple DOS Text format. (The high bit is cleared, and end-of-line is changed from CRLF to CR. A null is appended to the file.) "mtu" Appending a 'u', that is, specifying "mtu" also means the text will be force to uppercase, good for importing IBM BASIC programs. "mb" means this is a MSDOS binary file, and needs conversion to Apple DOS binary format. (i.e., an address and length prepended. SECOND ARGUMENT is to set the file type in DOS 3.3. The types "ibart" are, respectively, Integer BASIC, Binary, AppleSoft BASIC, Relocatible, and Text. Appending "l" will "Lock" the file. (I don't know why one would want to do this, but it's there.) THIRD ARGUMENT is the MSDOS file. This file should be less than 30,700 bytes long. (Actual limits: Text "mt" or "mtu" files need to be 30,719 or less, but remember that the text will shrink as line-feeds are deleted. Binary "mb" files need to be 30,716 or less. FOURTH ARGUMENT is the .DSK file name. This file will be either 143,359 or 143,360 bytes long. And ... very important ... THE FILE SHOULD NOT EXIST! This program outputs confusing results if it writes to a pre-existing file, so remember to delete any file you are trying to overwrite. Return Value: If the program fails, it returns the value "1" which can be detected with the MSDOS batch command "IF ERRORLEVEL 1 THEN ... ". Otherwise, the program returns 0. (Trivial Note: The "R" type was not as standardized the "I", "B", "A", and "T" types. I've given it the value ($10) that Apple used in the Apple Programmer Apprentice for the "R" files. SOME Dos disks that were altered by third party vend- ors will display that type as "S". Well, so it goes...) EXAMPLE: Let's say you have an IBM GWBASIC program and you want to run it in the emulator. (The "easter.bas" program appended to this file is a great for instance.) I saved it as an ASCII text file: save "easter",a Ok Back in the MSDOS prompt, you create a disk .DSK file out of it. C> dsk_in mtu t easter.bas easter.dsk NOTICE: What we are doing is importing a *text* file, *as* a text file. Unfortunately, this program does not do the complicated task of converting IBM Basic token files into Apple Basic Token files. To store and run the program: C> rename easter.dsk, disk6b.dsk C> apple --------------> APPLE ][ <--------------- ] CATALOG,D2 T 121 FILE ] ] EXEC FILE,D2 ] ] SAVE EASTER,D1 ] RUN Ignore the indication that the file is 121 blocks long. That is really how much space I allocated for the file, but the files have their own indicators for end-of-file. And finally, remember that AppleSoft and the IBM Basics are mostly, but not totally, compatible. Some conversion may have to be done manually. END OF EXAMPLE HOW TO USE THIS (AS IN, WHAT YOU WOULD USE THIS FOR... One thing is to XMODEM the contents of an Apple disk to your MSDOS computer. Then, with DSK_IN, you import the files one at a time. Be careful about the fact that this new .DSK won't have any DOS on it but the one you put there. Another thing is to take MSDOS files, and put them into the Apple .DSK files. Especially text files, which you can create easily on MSDOS machines. You can do almost anything with a text file, on Apple II computers. AppleSoft (and Integer) BASIC programs can be stored in text files, and retrieved by EXECing the files. Binary data, and machine language programs, also can be placed in a text file and EXECed. So use this program to take an MS-DOS file (up to about 30K, Apple's limit for text files) and create a .DSK file from it. Run APPLE.EXE with this new disk as Slot 6, Drive 2. EXEC the file "FILE" you find on it, or just copy it to the .DSK you want. IMPORTANT NOTICE: I held off releasing this a day or so, until I was producing .DSKs without DOS on them. Don't want to violate copyrights. So the .DSK output is a data disk and cannot be booted. /* * Example (repeated): * I pulled a BASIC program off the net, and it runs fine on the IBM. * It is from Sky and Telescope and predicts Easter. (I left in all * attributions.) * * After converting it to uppercase, I name it EASTER.BAS * * MSDOS> dsk_in mtu t easter.bas easter.dsk * > copy useful.dsk disk6a.dsk * > copy easter.dsk disk6b.dsk * > apple * ------------------> APPLE ][ <----------------- * APPLE] CATALOG,D2 * ] MON I * ] EXEC FILE,D2 * ] SAVE EASTER,D1 * ] RUN * * The above is how I port it in and store it on a .DSK full of useful * programs. */ Negative Notes: It is painful to watch AppleSoft try to EXEC a file with lowercase text, if you have done "MON C,I,O". So far, untested on any platform besides IBM DOS 3.3. (That's right ... this is actually a DOS 3.3-DOS 3.3 text converter.) *8) It does not provide for deleting a file that is already there, and that may confuse it. MAKING TEXT FILES To port a Basic program from the Apple to the IBM emulator, you can just XMODEM or KERMIT it. However, if you want to make a text file out of it and transmit that, use the program "capture.txt" below. Leave it as a text file on the Apple disk. When you have a program in memory, EXEC the program (as in "EXEC CAPTURE") and it will load in as lines zero through 9. Running it will save the program as the text file "TEMP", which you can rename to whatever. ---------------------------8<- CUT HERE ->8--- File: capture.txt ----- 0 REM NEW CAPTURE - EXEC THIS WITH A BASIC PROGRAM IN MEMORY 1 PRINT "THE LINES 5 THROUGH 7 ARE AVAILABLE" : REM COPYRIGHT (C) 1981, 1993 2 PRINT "FOR SPECIFYING THE OUTPUT" : REM REM THOMAS A.J.F. BAKER 3 PRINT : LIST 5 - 7: PRINT : PRINT "ANY CHAR TO START, RESET TO ABORT" 4 PRINT CHR$ (4);"OPEN TEMP": PRINT CHR$ (4);"WRITE TEMP" 5 LIST 10- 8 PRINT CHR$ (4);"CLOSE TEMP" 9 END ---------------------------8<- CUT HERE ->8--- File: easter.bas ------ 1 REM ARTICLE 34300 (155 MORE) IN SCI.SPACE: 3 REM ORGANIZATION: GEORGIA TECH RESEARCH INSTITUTE 4 REM DATE: SUNDAY, 4 OCT 1992 02:33:17 EDT 5 REM FROM: 7 REM COURTESY OF SKY & TELESCOPE MAGAZINE: 10 REM EASTER 12 REM 14 INPUT "YEAR ";Y 16 IF Y<1583 THEN 14 18 Y1=Y/19 20 A=INT((Y1-INT(Y1))*19+.001) 22 B1=Y/100: B=INT(B1) 24 C=INT((B1-INT(B1))*100+.001) 26 D1=B/4: D=INT(D1) 28 E=INT((D1-INT(D1))*4+.001) 30 F=INT(((B+8)/25)+.001) 32 G=INT((B-F+1)/3) 34 H1=(19*A+B-D-G+15)/30 36 H=INT((H1-INT(H1))*30+.001) 38 C1=C/4: I=INT(C1) 40 K=INT((C1-I)*4+.001) 42 L1=(32+2*E+2*I-H-K)/7 44 L=INT((L1-INT(L1))*7+.001) 46 M=INT((A+11*H+22*L)/451) 48 N1=(H+L-7*M+114)/31: N=INT(N1) 50 P=INT((N1-N)*31+.001) 52 N$="APRIL" 54 IF N=3 THEN N$="MARCH" 56 PRINT "EASTER IS ON ";N$;P+1 58 INPUT "ANOTHER (Y OR N) ";Q$ 60 IF Q$="Y" THEN 14 62 END 70 REM LEONARD ABBEY, F.R.A.S. 71 REM GEORGIA TECH RESEARCH INSTITUTE 72 REM ATLANTA, GEORGIA, USA 73 REM LABBEY@GTRI01.GATECH.EDU 74 REM ARTICLE 34300 (OF 34357)--WHAT NEXT? [NPQ] ---------------------------------------------------------------------------- tombaker@world.std.com || tabaker@aol.com || BIX as tombaker1583>