mirror of
https://github.com/dmolony/DiskBrowser.git
synced 2024-12-24 08:29:20 +00:00
More v2d code
This commit is contained in:
parent
d1ceac22ac
commit
681b33df4f
@ -59,7 +59,7 @@ public class AssemblerProgram extends AbstractFile
|
|||||||
return text;
|
return text;
|
||||||
|
|
||||||
return text + "\n\n" + HexFormatter.format (extraBuffer, 0, extraBuffer.length,
|
return text + "\n\n" + HexFormatter.format (extraBuffer, 0, extraBuffer.length,
|
||||||
loadAddress + buffer.length);
|
loadAddress + buffer.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -180,8 +180,8 @@ public class AssemblerProgram extends AbstractFile
|
|||||||
{
|
{
|
||||||
StringBuilder line = new StringBuilder ();
|
StringBuilder line = new StringBuilder ();
|
||||||
|
|
||||||
line.append (String.format ("%3.3s %04X: %02X ", getArrow (cmd), cmd.address,
|
line.append (
|
||||||
cmd.value));
|
String.format ("%3.3s %04X: %02X ", getArrow (cmd), cmd.address, cmd.value));
|
||||||
|
|
||||||
if (cmd.size > 1)
|
if (cmd.size > 1)
|
||||||
line.append (String.format ("%02X ", cmd.operand1));
|
line.append (String.format ("%02X ", cmd.operand1));
|
||||||
@ -306,7 +306,7 @@ public class AssemblerProgram extends AbstractFile
|
|||||||
{
|
{
|
||||||
int address = Integer.parseInt (line.substring (0, 4), 16);
|
int address = Integer.parseInt (line.substring (0, 4), 16);
|
||||||
if (equates.containsKey (address))
|
if (equates.containsKey (address))
|
||||||
System.out.println ("Duplicate equate entry : " + address);
|
System.out.printf ("Duplicate equate entry : %04X%n" + address);
|
||||||
else
|
else
|
||||||
equates.put (address, line.substring (6));
|
equates.put (address, line.substring (6));
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
03EA VECT
|
03EA VECT
|
||||||
A56E catalog routine
|
A56E catalog routine
|
||||||
|
|
||||||
C000 80STOREOFF Allow page2 to switch video page1 page2
|
* C000 80STOREOFF Allow page2 to switch video page1 page2
|
||||||
C001 80STOREON Allow page2 to switch main & aux video memory
|
C001 80STOREON Allow page2 to switch main & aux video memory
|
||||||
C002 RAMRDOFF Read enable main memory from $0200-$BFFF
|
C002 RAMRDOFF Read enable main memory from $0200-$BFFF
|
||||||
C003 RAMDRON Read enable aux memory from $0200-$BFFF
|
C003 RAMDRON Read enable aux memory from $0200-$BFFF
|
||||||
|
@ -221,18 +221,27 @@ public class AppleDisk implements Disk
|
|||||||
|
|
||||||
public AppleDisk (V2dDisk disk)
|
public AppleDisk (V2dDisk disk)
|
||||||
{
|
{
|
||||||
tracks = disk.actualTracks;
|
tracks = 35;
|
||||||
trackSize = 4096;
|
trackSize = 4096;
|
||||||
|
file = disk.file;
|
||||||
|
diskBuffer = disk.buffer;
|
||||||
|
|
||||||
sectorSize = 256;
|
sectorSize = 256;
|
||||||
sectors = 16;
|
sectors = 16;
|
||||||
blocks = tracks * sectors;
|
blocks = tracks * sectors;
|
||||||
file = disk.file;
|
|
||||||
diskBuffer = disk.buffer;
|
|
||||||
hasData = new boolean[blocks];
|
hasData = new boolean[blocks];
|
||||||
|
|
||||||
checkSectorsForData ();
|
checkSectorsForData ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public AppleDisk (NibDisk disk) // not used yet
|
||||||
|
{
|
||||||
|
tracks = 35;
|
||||||
|
trackSize = 4096;
|
||||||
|
file = disk.file;
|
||||||
|
diskBuffer = disk.buffer;
|
||||||
|
}
|
||||||
|
|
||||||
private byte[] getPrefix (File path)
|
private byte[] getPrefix (File path)
|
||||||
{
|
{
|
||||||
byte[] buffer = new byte[64];
|
byte[] buffer = new byte[64];
|
||||||
@ -463,9 +472,12 @@ public class AppleDisk implements Disk
|
|||||||
@Override
|
@Override
|
||||||
public DiskAddress getDiskAddress (int track, int sector)
|
public DiskAddress getDiskAddress (int track, int sector)
|
||||||
{
|
{
|
||||||
// should this return null for invalid addresses?
|
if (!isValidAddress (track, sector))
|
||||||
assert (isValidAddress (track, sector)) : "Invalid address : " + track + ", "
|
{
|
||||||
+ sector;
|
System.out.println ("Invalid block : " + track + "/" + sector);
|
||||||
|
return null;
|
||||||
|
// return new AppleDiskAddress (this, 0); this was looping 26/07/2016
|
||||||
|
}
|
||||||
return new AppleDiskAddress (this, track, sector);
|
return new AppleDiskAddress (this, track, sector);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,7 +44,6 @@ public class DiskFactory
|
|||||||
String suffix = path.substring (path.lastIndexOf (".") + 1).toLowerCase ();
|
String suffix = path.substring (path.lastIndexOf (".") + 1).toLowerCase ();
|
||||||
Boolean compressed = false;
|
Boolean compressed = false;
|
||||||
Path p = Paths.get (path);
|
Path p = Paths.get (path);
|
||||||
V2dDisk v2dDisk = null;
|
|
||||||
|
|
||||||
if (suffix.equals ("sdk"))
|
if (suffix.equals ("sdk"))
|
||||||
{
|
{
|
||||||
@ -157,16 +156,20 @@ public class DiskFactory
|
|||||||
|
|
||||||
if (suffix.equals ("v2d"))
|
if (suffix.equals ("v2d"))
|
||||||
{
|
{
|
||||||
// Disk disk = checkV2DDisk (file);
|
V2dDisk v2dDisk = new V2dDisk (file);
|
||||||
// return disk2;
|
|
||||||
// checkV2DDisk (file);
|
|
||||||
// return null;
|
|
||||||
v2dDisk = new V2dDisk (file);
|
|
||||||
AppleDisk appleDisk16 = new AppleDisk (v2dDisk);
|
AppleDisk appleDisk16 = new AppleDisk (v2dDisk);
|
||||||
disk = checkDos (appleDisk16);
|
disk = checkDos (appleDisk16);
|
||||||
return disk;
|
return disk;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (suffix.equals ("nib"))
|
||||||
|
{
|
||||||
|
NibDisk nibDisk = new NibDisk (file);
|
||||||
|
AppleDisk appleDisk16 = new AppleDisk (nibDisk);
|
||||||
|
disk = checkDos (appleDisk16);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
long length = file.length ();
|
long length = file.length ();
|
||||||
|
|
||||||
if (length == 116480) // 13 sector disk
|
if (length == 116480) // 13 sector disk
|
||||||
|
43
src/com/bytezone/diskbrowser/disk/NibDisk.java
Normal file
43
src/com/bytezone/diskbrowser/disk/NibDisk.java
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
package com.bytezone.diskbrowser.disk;
|
||||||
|
|
||||||
|
import java.io.BufferedInputStream;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public class NibDisk
|
||||||
|
{
|
||||||
|
private final Nibblizer nibbler = new Nibblizer ();
|
||||||
|
|
||||||
|
final File file;
|
||||||
|
int tracks;
|
||||||
|
int actualTracks;
|
||||||
|
|
||||||
|
final byte[] buffer = new byte[4096 * 35];
|
||||||
|
|
||||||
|
// .nib files are 232,960 bytes
|
||||||
|
// 6,656 bytes x 35 tracks (0x1A00)
|
||||||
|
|
||||||
|
public NibDisk (File file)
|
||||||
|
{
|
||||||
|
this.file = file;
|
||||||
|
byte[] buffer = new byte[6656];
|
||||||
|
try
|
||||||
|
{
|
||||||
|
byte[] diskBuffer = new byte[10];
|
||||||
|
BufferedInputStream in = new BufferedInputStream (new FileInputStream (file));
|
||||||
|
|
||||||
|
for (int i = 0; i < 35; i++)
|
||||||
|
{
|
||||||
|
in.read (buffer);
|
||||||
|
// System.out.println (HexFormatter.format (buffer));
|
||||||
|
}
|
||||||
|
|
||||||
|
in.close ();
|
||||||
|
}
|
||||||
|
catch (IOException e)
|
||||||
|
{
|
||||||
|
e.printStackTrace ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -275,7 +275,7 @@ public class Nibblizer
|
|||||||
System.out.printf ("%02X ", buffer[offset++]);
|
System.out.printf ("%02X ", buffer[offset++]);
|
||||||
++count;
|
++count;
|
||||||
}
|
}
|
||||||
System.out.println ();
|
// System.out.println ();
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -316,6 +316,11 @@ public class Nibblizer
|
|||||||
checksum = decode4and4 (buffer, offset + 9);
|
checksum = decode4and4 (buffer, offset + 9);
|
||||||
valid = true;
|
valid = true;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
listBytes (buffer, offset, 14);
|
||||||
|
System.out.println ();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -331,10 +336,21 @@ public class Nibblizer
|
|||||||
{
|
{
|
||||||
super (buffer, offset);
|
super (buffer, offset);
|
||||||
|
|
||||||
if (matchBytes (buffer, offset, dataPrologue)
|
if (matchBytes (buffer, offset, dataPrologue))
|
||||||
&& matchBytes (buffer, offset + 346, epilogue))
|
|
||||||
{
|
{
|
||||||
valid = true;
|
valid = true;
|
||||||
|
if (!matchBytes (buffer, offset + 346, epilogue))
|
||||||
|
{
|
||||||
|
System.out.print (" bad data epilogue: ");
|
||||||
|
listBytes (buffer, offset + 346, 3);
|
||||||
|
System.out.println ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
System.out.print (" bad data prologue: ");
|
||||||
|
listBytes (buffer, offset, 3);
|
||||||
|
System.out.println ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ public class V2dDisk
|
|||||||
|
|
||||||
final File file;
|
final File file;
|
||||||
final int tracks;
|
final int tracks;
|
||||||
int actualTracks;
|
// int actualTracks;
|
||||||
|
|
||||||
final byte[] buffer = new byte[4096 * 35];
|
final byte[] buffer = new byte[4096 * 35];
|
||||||
|
|
||||||
@ -62,6 +62,7 @@ public class V2dDisk
|
|||||||
String id = HexFormatter.getString (diskBuffer, 4, 4); // 4 bytes
|
String id = HexFormatter.getString (diskBuffer, 4, 4); // 4 bytes
|
||||||
tracks = HexFormatter.getShortBigEndian (diskBuffer, 8); // 2 bytes
|
tracks = HexFormatter.getShortBigEndian (diskBuffer, 8); // 2 bytes
|
||||||
|
|
||||||
|
assert diskLength + 8 == file.length ();
|
||||||
assert "D5NI".equals (id);
|
assert "D5NI".equals (id);
|
||||||
|
|
||||||
for (int i = 0; i < tracks; i++)
|
for (int i = 0; i < tracks; i++)
|
||||||
@ -69,18 +70,20 @@ public class V2dDisk
|
|||||||
byte[] trackHeader = new byte[4];
|
byte[] trackHeader = new byte[4];
|
||||||
in.read (trackHeader);
|
in.read (trackHeader);
|
||||||
int trackNumber = HexFormatter.getShortBigEndian (trackHeader, 0);
|
int trackNumber = HexFormatter.getShortBigEndian (trackHeader, 0);
|
||||||
int trackLength = HexFormatter.getShortBigEndian (trackHeader, 2);
|
int trackLength = HexFormatter.getShortBigEndian (trackHeader, 2); // 6304
|
||||||
|
|
||||||
int fullTrackNo = trackNumber / 4;
|
int fullTrackNo = trackNumber / 4;
|
||||||
int halfTrackNo = trackNumber % 4;
|
int halfTrackNo = trackNumber % 4;
|
||||||
// System.out.printf ("%3d %3d%n", fullTrackNo, halfTrackNo);
|
|
||||||
|
|
||||||
byte[] trackData = new byte[trackLength];
|
byte[] trackData = new byte[trackLength];
|
||||||
in.read (trackData);
|
in.read (trackData);
|
||||||
|
|
||||||
// only process full tracks
|
// only process full tracks
|
||||||
if (halfTrackNo == 0 && processTrack (fullTrackNo, trackData, buffer))
|
if (halfTrackNo == 0)
|
||||||
actualTracks++;
|
processTrack (fullTrackNo, trackData, buffer);
|
||||||
|
else
|
||||||
|
System.out.printf ("%s skipping half track %02X / %02X%n", file.getName (),
|
||||||
|
fullTrackNo, halfTrackNo);
|
||||||
}
|
}
|
||||||
|
|
||||||
in.close ();
|
in.close ();
|
||||||
@ -99,7 +102,8 @@ public class V2dDisk
|
|||||||
|
|
||||||
while (buffer[ptr] == (byte) 0xEB)
|
while (buffer[ptr] == (byte) 0xEB)
|
||||||
{
|
{
|
||||||
System.out.println ("overrun: " + ptr + " in track " + trackNo);
|
System.out.printf ("%s overrun 0xEB offset %d in track %02X%n", file.getName (),
|
||||||
|
ptr, trackNo);
|
||||||
++ptr;
|
++ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -116,8 +120,14 @@ public class V2dDisk
|
|||||||
|
|
||||||
DataField dataField = nibbler.getDataField (buffer, ptr);
|
DataField dataField = nibbler.getDataField (buffer, ptr);
|
||||||
if (!dataField.isValid ())
|
if (!dataField.isValid ())
|
||||||
|
{
|
||||||
|
System.out.printf ("skipping data %02X / %02X%n", addressField.track,
|
||||||
|
addressField.sector);
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// System.out.printf ("decoding track %02X / %02X%n", addressField.track,
|
||||||
|
// addressField.sector);
|
||||||
byte[] decodedBuffer = nibbler.decode6and2 (buffer, ptr + 3);
|
byte[] decodedBuffer = nibbler.decode6and2 (buffer, ptr + 3);
|
||||||
|
|
||||||
int offset = addressField.track * 4096 + interleave[DOS][addressField.sector] * 256;
|
int offset = addressField.track * 4096 + interleave[DOS][addressField.sector] * 256;
|
||||||
|
Loading…
Reference in New Issue
Block a user