Path: news.uiowa.edu!uunet!salliemae!europa.chnt.gtegsc.com!cantaloupe.srv.cs.cmu.edu!rochester!udel!gatech!howland.reston.ans.net!news.moneng.mei.com!uwm.edu!reuter.cse.ogi.edu!cs.uoregon.edu!news.uoregon.edu!cie-2.uoregon.edu!nparker From: nparker@cie-2.uoregon.edu (Neil Parker) Newsgroups: comp.sys.apple2.programmer Subject: Re: Low-level file writes in ProDos 8 MLI? Date: 4 May 1995 06:16:33 GMT Organization: University of Oregon Campus Information Exchange Lines: 64 Message-ID: <3o9rg1$3tb@pith.uoregon.edu> References: <3o91vl$ce@nntp5.u.washington.edu> NNTP-Posting-Host: cie-2.uoregon.edu In article <3o91vl$ce@nntp5.u.washington.edu> dpeschel@u.washington.edu (Derek Peschel) writes: >I want to write a BASIC and machine-language progrma to convert 5 1/4" disks to >image files on 3 1/2" disks. I've been reading about the ProDos 8 MLI, and I >think I know how to call it from BASIC. > >The image files contain every byte on the 5 1/4" disk, in DOS 3.3 sector order. >Unfortunately, ProDos blocks are in a different order. I would like to read >eight blocks at a time into one of the hi-res pages [*] and then send various >chunks out to a file. For example, I might write bytes 257-512, then bytes >769-1024, then ..., then bytes 1-255, etc. > >[*] Cheesy, but it works. :) > >The OPEN MLI call expects (or returns?) a pointer to a buffer. The WRITE >call certainly needs to know what data to write. And there are GET_BUF and >SET_BUF calls. > >Is it possible to leave the track data in place and write it without much fuss? >(e.g., without moving the data around or calling SET_BUF sixteen times) Yes, it's possible to do the write without too much fuss. But DON'T use SET_BUF and GET_BUF. If you try to put stuff directly into the open-file buffer, you'll probably trash your disk. The necessary steps are as follows: 1. Find a 1024-byte block of memory somewhere that isn't being used by anything, and won't be tromped on by your program. Pass the address of this buffer to the OPEN call. Then leave it alone! ProDOS will manage this buffer all by itself, and if you try to put anything into it yourself, you'll cause massive confusion, and probably kill your disk. 2. Read your eight blocks of data from the DOS 3.3 disk. Don't read them into the buffer from step 1--instead, find another 4096-byte hunk of memory somewhere else to put them in. 3. Choose the desired 256-byte chunk of your eight-block buffer from step 2. Pass the address and length of this chunk to the WRITE call. Repeat this step until all sixteen chunks have been written. 4. Go back to step 2, and repeat until the entire DOS 3.3 disk has been taken care of. 5. Make the CLOSE call on the file that you opened in step 1. After this step the 1024-byte buffer from step 1 is no longer needed, and can be reused if desired. Note that SET_BUF and GET_BUF are not needed for this process. To read a DOS 3.3 track, multiply the DOS 3.3 track number by eight, and use the result as the ProDOS block number. Read this block (using READ_BLOCK) and the next seven blocks that follow it. If you read the entire track into a single 4096-byte buffer by this method, you'll find that your buffer contains the DOS 3.3 sectors in the order 0, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 15. - Neil Parker -- Neil Parker, nparker@{cie-2,cie}.uoregon.edu, http://cie-2.uoregon.edu/~nparker "Evolution is vastly overrated." -- Ambassador Delenn, _Babylon_5_