On Fri, 29 Aug 2003 20:39:22 GMT, "John B. Matthews" wrote: >Rob, Chris & Co: > >I'm starting a new thread in case others are working with >AppleCommander. I found a few problems with Pascal dates in >v1.2.3. > (SNIP) >John >---- >jmatthews at wright dot edu >www dot wright dot edu/~john.matthews/ Welp, I've been playing around with it a little. I've got DOS 3.3 "dir" and "get" and "export" working. I'm trying to implement the "put" command. It seems to be working, but not quite. I'm putting a binary file called "HELLO.BIN" onto a DOS 3.3 disk and when I BRUN it, it craps out. In fact, if I just BLOAD it, it craps out. I checked the data on the DSK image, and it looks correct - with the first two bytes being the load address (A$0800) and the next two bytes being the file length (A$0B4A) I was looking in the "DosFileEntry" function "setAddress()" which is supposed to set the address of a binary-type file. I wasn't calling it, as the file already had the address/length embedded in it. But looking at the function, it's implemented like this: /** * Set the address that this file loads at. */ public void setAddress(int address) { // FIXME - need to implement } Ooops! Not sure what to do here. I'll have to look through my Beneath Apple DOS to investigate, but does the CATALOG info for a binary file include the address information? I thought the first four bytes of a "B" type file would be all that was needed -- the load address and length. Apparently not, though, because it's not working. Of course, unlesss I did something else wrong! This is the meat of the PUT routine: byte[] theLocalFileData = new byte[nBytesLocalFile]; theInputFile.read(theLocalFileData, 0, nBytesLocalFile); theFileEntry.setFileData(theLocalFileData); DSK.save(); // CHRIS On Mon, 01 Sep 2003 15:30:54 -0400, Chris Morse wrote: (SNIP) >This is the meat of the PUT routine: > > byte[] theLocalFileData = new byte[nBytesLocalFile]; > theInputFile.read(theLocalFileData, 0, nBytesLocalFile); > theFileEntry.setFileData(theLocalFileData); > DSK.save(); > >// CHRIS Welp, just dug out my copy of Beneath Apple DOS, and added a new command to my program to "hex dump" an entire disk image so I could check out the catalog tracks easily. The CATALOG sector has all the right info; nothing to do with file lengths in there. But after tracking down the file at Track 5 Sector 1, I saw this: Track: 5 Sector: 1 Offset Hex Data Characters ======= ================================================ ================= $000000 00 00 4E 0B 00 08 4A 0B A2 19 B5 00 9D 1E 13 CA ..N...J. ".5....J $000010 10 F8 20 83 0F BA 8E 4A 13 A5 73 85 00 A5 74 85 .x ..:.J .%s..%t. $000020 01 20 D7 0F A9 FF 85 32 20 16 11 20 16 11 A0 04 . W.).2 .. .. . $000030 20 C8 08 20 E0 0F A9 FF 85 32 AE 4A 13 9A A2 19 H. `.) .2.J..". (Sorry for the wrap-around..) The first four bytes were stuffed in - with the LOAD address being $A0000 (definite problem!) and the length set to the original file length + 4. Will have to check into the Java code to see what I can do about fixing that. // CHRIS On Mon, 01 Sep 2003 22:58:46 GMT, "John B. Matthews" wrote: (SNIP) > >It looks like you're hammering on the DOS branch; I've been >sending Rob updates that affect ProDOS and Pascal. You're >working in .net? Can you share your hex dump code? Would it do >me any good, working in Java:-) > >I see that TextFileFilter ignores Apple2 line endings. Does this >work on Windows? I've temporarily translated CR to LF for >testing. I'm thinking about revising TextFileFilter to use a >PrintWriter, as it works well in ApplesoftFileFilter. Would this >be the correct cross-platform choice? > >John >---- >jmatthews at wright dot edu >www dot wright dot edu/~john.matthews/ Yeah, I've just finished the DOS 3.3 side. For ProDOS disks, only the "dir" command works right now. But I'm working on fixing that now. My Java is pretty rusty, so I am probably being a little verbose in my statements.. But it should be easy to read and modify. Can't recall if there's an easy formatting function in java like C/C++'s printf() function. Or is it all stream-based with stream modifiers? I'm probably doing it the hard way. For the dump routine, I really just lifted the filter() function code from HexDumpFileFilter and slapped a couple for() loops for going over each track/sector, and had everything output through System.out ; The code is below. Hopefully everything I'm doing, though done in J# is still all regular Java code. I haven't taken advantage of any .NET stuff. But J# does use Java 1.1 and not the more up-to-date Java 1.4, so I did have to modify the save() routine in the Disk class. That's the only change I had to make. If you want to send me an e-mail (or give me yours) I can send you what I've got so far. I've marked any changes in Rob's code with "// CMS" comments and left the original code in comments too. My e-mail address is chris -=:(@):=- cosmicwolf.com // CHRIS ("a2dt" is the program name in this example) C:\WORK-CWOLF\JSHARP\A2DT\bin\Debug>a2dt A2DT: Apple ][ Disk Tools [v1.0] 96% Copyright (C) 2002-2003 by Robert Greene 4% Slapped together by Chris Morse Sebrell usage: a2dt dir a2dt get <[/path/image-filename> a2dt exp <[/path/image-filename> a2dt put -t [A$0000] <[/path/]dest-file> a2dt put -t [A$0000] <[/path/]dest-file> a2dt del <[/path/image-filename> a2dt dump where 'get' will extract a file 'exp' will extract a file with file-type filtering 'del' will delete a file 'put' will insert a file Options in <> are required, options in [] are optional. See documentation for complete information. ----------------------------------- // DOS 3.3 DUMP public static void HandleTask_DUMP(DosFormatDisk DSK) { int nBytesPerLine = 16; byte bytAppleSpace = 0x20; int nT, nS; int nTracks = DSK.getTracks(); int nSectors = DSK.getSectors(); byte[] sector_data; for(nT = 0; nT < nTracks; nT++) { for(nS = 0; nS < nSectors; nS++) { System.out.println(""); System.out.print(" Track: $"); System.out.print(AppleUtil.getFormattedByte(nT)); System.out.print(" ("); System.out.print(nT); System.out.println(")"); System.out.print("Sector: $"); System.out.print(AppleUtil.getFormattedByte(nS)); System.out.print(" ("); System.out.print(nS); System.out.println(")"); System.out.println(""); sector_data = DSK.readSector(nT, nS); System.out.print(" Offset "); System.out.print("Hex Data "); System.out.println("Characters"); System.out.print("======= "); System.out.print("================================================ "); System.out.println("================="); for (int offset=0; offset < sector_data.length; offset+= nBytesPerLine) { System.out.print("$"); System.out.print(AppleUtil.getFormatted3ByteAddress(offset)); System.out.print(" "); for (int b=0; b= (byte) bytAppleSpace) { System.out.print(ch); } else { System.out.print('.'); } } else { System.out.print(' '); } } System.out.println(); } } } } ---------------------------------------------------------- On Mon, 01 Sep 2003 15:30:54 -0400, Chris Morse wrote: (SNIP) > /** > * Set the address that this file loads at. > */ > public void setAddress(int address) { > // FIXME - need to implement > } > > (SNIP) Well, I added a DosFileEntry class member called "nBinaryStartAddress" and set the following function above to be: /** * Set the address that this file loads at. */ public void setAddress(int address) { nBinaryStartAddress = address; } In the DosFileEntry constructor, I added the line: this.nBinaryStartAddress = -1; // -1 means don't include header for binary files, otherwise add it Then, in the "setFileData" function I implemented it this way: if (isBinaryFile()) { // CMS : Added bBinaryHeader and nBinaryStartAddress to parameters // Original code in comments below if(nBinaryStartAddress != -1) { byte[] filedata = new byte[data.length + 4]; AppleUtil.setWordValue(filedata, 0, nBinaryStartAddress); AppleUtil.setWordValue(filedata, 2, data.length); System.arraycopy(data, 0, filedata, 4, data.length); disk.setFileData(this, filedata); } else { // Assume header info is already in data bytes disk.setFileData(this, data); } That fixes it! So you can set optionally the binary start address. The CC65 compiler output already has the start address and file length in the output, so there's no need to use the "setAddress" function for that file. But my "put" function parameters let you specify "A$xxxx" and if it sees that, it will call the setAddress() function and pre-pend the data stream with the 4 required header bytes. // CHRIS