partial Dos 4.3

This commit is contained in:
Denis Molony 2019-08-11 14:12:32 +10:00
parent e84c86c90f
commit 3482347c8d
11 changed files with 126 additions and 124 deletions

View File

@ -8,45 +8,45 @@ import com.bytezone.diskbrowser.utilities.HexFormatter;
public class BasicProgramGS extends BasicProgram
{
private static String[] //
tokens = { " AUTO ", " DEL ", " EDIT ", " HLIST ", // 0x80 - 0x83
" LIST ", " RENUM ", " BREAK ", " FN ", // 0x84 - 0x87
" PROC ", " GOSUB ", " GOTO ", " FOR ", // 0x88 - 0x8B
" THEN ", " ELSE ", " NEXT ", " OFF ", // 0x8C - 0x8F
" ON ", " INPUT ", " OUTPUT ", " TEXT ", // 0x90 - 0x93
" TIMER ", " EXCEPTION ", " CAT ", " 97 ", // 0x94 - 0x97
" INIT ", " INVOKE ", " LIBRARY ", " PREFIX ", // 0x98 - 0x9B
" TYPE ", " LOAD ", " SAVE ", " DELETE ", // 0x9C - 0x9F
" RUN ", " RENAME ", " CREATE ", " LOCK ", // 0xA0 - 0xA3
" UNLOCK ", " EXEC ", " CHAIN ", " CATALOG ", // 0xA4 - 0xA7
" OPEN ", " QUIT ", " DIR ", " DIM ", // 0xA8 - 0xAB
" READ ", " WRITE ", " CLOSE ", " TASKPOLL ", // 0xAC - 0xAF
" LOCATE ", " EVENTDEF ", " MENUDEF ", " VOLUMES ", // 0xB0 - 0xB3
" CALL% ", " CALL ", " _", " TEXTPORT ", // 0xB4 - 0xB7
" PERFORM ", " GRAF ", " DBUG ", " POP ", // 0xB8 - 0xBB
" HOME ", " SUB$( ", " TRACE ", " NOTRACE ", // 0xBC - 0xBF
" NORMAL ", " INVERSE ", " RESUME ", " LET ", // 0xC0 - 0xC3
" IF ", " RESTORE ", " SWAP ", " RETURN ", // 0xC4 - 0xC7
" REM ", " STOP ", " DATA ", " IMAGE ", // 0xC8 - 0xCB
" LIBFIND ", " DEF ", " PRINT ", " CLEAR ", // 0xCC - 0xCF
" RANDOMIZE ", " NEW ", " POKE ", " ASSIGN ", // 0xD0 - 0xD3
" GET ", " PUT ", " SET ", " ERROR ", // 0xD4 - 0xD7
" ERASE ", " LOCAL ", " WHILE ", " CONT ", // 0xD8 - 0xDB
" DO ", " UNTIL ", " END ", " DF ", // 0xDC - 0xDF
" E0 ", " E1 ", " E2 ", " E3 ", // 0xE0 - 0xE3
" E4 ", " E5 ", " E6 ", " E7 ", // 0xE4 - 0xE7
" E8 ", " E9 ", " EA ", " EB ", // 0xE8 - 0xEB
" EC ", " ED ", " EE ", " EF ", // 0xEC - 0xEF
" F0 ", " F1 ", " F2 ", " F3 ", // 0xF0 - 0xF3
" F4 ", " F5 ", " F6 ", " F7 ", // 0xF4 - 0xF7
" F8 ", " F9 ", " FA ", " FB ", // 0xF8 - 0xFB
" FC ", " FD ", " FE ", " FF ", // 0xFC - 0xFF
tokens = { "AUTO", "DEL", "EDI", "HLIST ", // 0x80 - 0x83
"LIST", "RENUM", "BREAK", "FN", // 0x84 - 0x87
"PROC", "GOSUB", " GOTO ", "FOR ", // 0x88 - 0x8B
" THEN ", "ELSE ", "NEXT ", "OFF ", // 0x8C - 0x8F
"ON ", "INPUT ", "OUTPUT ", "TEXT ", // 0x90 - 0x93
"TIMER ", "EXCEPTION ", "CAT ", " 97 ", // 0x94 - 0x97
"INIT ", "INVOKE ", "LIBRARY ", "PREFIX ", // 0x98 - 0x9B
"TYPE ", "LOAD ", "SAVE ", "DELETE ", // 0x9C - 0x9F
"RUN ", "RENAME ", "CREATE ", "LOCK ", // 0xA0 - 0xA3
"UNLOCK ", "EXEC ", "CHAIN ", "CATALOG ", // 0xA4 - 0xA7
"OPEN ", "QUIT ", "DIR ", "DIM ", // 0xA8 - 0xAB
"READ ", "WRITE ", "CLOSE ", "TASKPOLL ", // 0xAC - 0xAF
"LOCATE ", "EVENTDEF ", "MENUDEF ", "VOLUMES ", // 0xB0 - 0xB3
"CALL% ", "CALL ", "_", "TEXTPORT ", // 0xB4 - 0xB7
"PERFORM ", "GRAF ", "DBUG ", "POP ", // 0xB8 - 0xBB
"HOME ", "SUB$(", "TRACE ", "NOTRACE ", // 0xBC - 0xBF
"NORMAL ", "INVERSE ", "RESUME ", "LET ", // 0xC0 - 0xC3
"IF ", "RESTORE ", "SWAP ", "RETURN ", // 0xC4 - 0xC7
"REM ", "STOP ", "DATA ", "IMAGE ", // 0xC8 - 0xCB
"LIBFIND ", "DEF ", "PRINT ", "CLEAR ", // 0xCC - 0xCF
"RANDOMIZE ", "NEW ", "POKE ", "ASSIGN ", // 0xD0 - 0xD3
"GET ", "PUT ", "SET ", "ERROR ", // 0xD4 - 0xD7
"ERASE ", "LOCAL ", "WHILE ", "CONT ", // 0xD8 - 0xDB
"DO ", "UNTIL ", "END ", " DF ", // 0xDC - 0xDF
" E0 ", " E1 ", " E2 ", " E3 ", // 0xE0 - 0xE3
" E4 ", " E5 ", " E6 ", " E7 ", // 0xE4 - 0xE7
" E8 ", " E9 ", " EA ", " EB ", // 0xE8 - 0xEB
" EC ", " ED ", " EE ", " EF ", // 0xEC - 0xEF
" F0 ", " F1 ", " F2 ", " F3 ", // 0xF0 - 0xF3
" F4 ", " F5 ", " F6 ", " F7 ", // 0xF4 - 0xF7
" F8 ", " F9 ", " FA ", " FB ", // 0xF8 - 0xFB
" FC ", " FD ", " FE ", " FF ", // 0xFC - 0xFF
};
private static String[] //
tokensDF = { " TAB(", " TO ", " SPC(", " USING ", // 0x80 - 0x83
" APPEND ", " MOD ", " REMDR ", " STEP ", // 0x84 - 0x87
"APPEND ", " MOD ", " REMDR ", " STEP ", // 0x84 - 0x87
" AND ", " OR ", " XOR ", " DIV ", // 0x88 - 0x8B
" SRC ", " NOT ", " 8E ", " UPDATE ", // 0x8C - 0x8F
" SRC ", " NOT ", " 8E ", " UPDATE ", // 0x8C - 0x8F
" TXT ", " BDF ", " FILTYPE= ", " AS ", // 0x90 - 0x93
" 94 ", " 95 ", " SGN(", " INT ", // 0x94 - 0x97
" ABS(", " TYP(", " REC(", " JOYX(", // 0x98 - 0x9B
@ -61,16 +61,16 @@ public class BasicProgramGS extends BasicProgram
" HEX$(", " PFX$(", " SPACE$(", " ERRTXT$(", // 0xBC - 0xBF
" CHR$(", " RELATION(", " ANU(", " COMPI(", // 0xC0 - 0xC3
" SCALB(", " SCALE(", " LEN(", " VAL(", // 0xC4 - 0xC7
" ASC(", " UCASE$(", " TEN(", " CONV#(", // 0xC8 - 0xCB
" ASC(", " UCASE$(", "TEN(", " CONV#(", // 0xC8 - 0xCB
" CONV@(", " CONV(", " CONV&(", " CONV$", // 0xCC - 0xCF
" CONV%(", " LEFT$(", " RIGHT$(", " REP$(", // 0xD0 - 0xD3
" MID$(", " INSTR(", " VARPTR(", " VARPTR$(", // 0xD4 - 0xD7
" VAR$(", " VAR(", " UBOUND(", " FILE(", // 0xD8 - 0xDB
" MID$(", " INSTR(", "VARPTR(", "VARPTR$(", // 0xD4 - 0xD7
"VAR$(", "VAR(", " UBOUND(", " FILE(", // 0xD8 - 0xDB
" EXEVENT@(", " DD ", " DE ", " DF ", // 0xDC - 0xDF
" HPOS ", " VPOS ", " TIME$ ", " DATE$ ", // 0xE0 - 0xE3
" PREFIX$ ", " E5 ", " OUTREC ", " INDENT ", // 0xE4 - 0xE7
" SHOWDIGITS ", " LISTTAB ", " AUXID@ ", " EXFN ", // 0xE8 - 0xEB
" SECONDS@ ", " FRE ", " ERRLIN ", " ERR ", // 0xEC - 0xEF
" SECONDS@ ", " FRE ", " ERRLIN ", "ERR ", // 0xEC - 0xEF
" KBD ", " EOF ", " JOYY ", " PDL9 ", // 0xF0 - 0xF3
" PI ", " ERRTOOL ", " F6 ", " F7 ", // 0xF4 - 0xF7
" F8 ", " F9 ", " FA ", " FB ", // 0xF8 - 0xFB
@ -131,59 +131,74 @@ public class BasicProgramGS extends BasicProgram
ptr += 3;
int max = ptr + lineLength - 4;
StringBuilder text = new StringBuilder (String.format ("%-12s :", label));
StringBuilder text = new StringBuilder ();
while (ptr < max)
{
byte b1 = buffer[ptr++];
if (isToken (b1))
{
if (b1 == (byte) 0xDF)
{
byte b2 = buffer[ptr++];
text.append (tokensDF[(b2 & 0x7F)]);
}
else if (b1 >= (byte) 0xE0)
{
// show (ptr - 1, 5);
if (b1 == (byte) 0xFC) // 3 bytes
{
text.append (String.format (" %d ", get (ptr, 3)));
ptr += 4; // skip trailing zero
}
else if (b1 == (byte) 0xFA) // 2 bytes
{
text.append (String.format (" %d ", get (ptr, 2)));
ptr += 2;
}
else if (b1 == (byte) 0xFB)
{
ptr += 3; // ignore 3 bytes (why?)
}
else if ((b1 & 0xF0) == 0xF0) // F0:F9 = 0:9
{
text.append (b1 & 0x0F);
}
else if ((b1 & 0xE0) == 0xE0) // 3 nybbles
{
int val = ((b1 & 0x0F) << 8) | (buffer[ptr++] & 0xFF);
text.append (String.format (" %d ", val));
}
}
else
text.append (tokens[(b1 & 0x7F)]);
}
ptr = tokenOrNumber (b1, text, ptr);
else
{
if ((b1 & 0xFF) < 32)
text.append ('.');
else
text.append ((char) b1);
}
text.append ((b1 & 0xFF) < 32 ? '.' : (char) b1);
}
line = text.toString ();
}
private int tokenOrNumber (byte b1, StringBuilder text, int ptr)
{
if (b1 == (byte) 0xDF)
{
append (tokensDF[(buffer[ptr++] & 0x7F)], text);
return ptr;
}
if (b1 < (byte) 0xE0)
{
append (tokens[(b1 & 0x7F)], text);
return ptr;
}
if (b1 == (byte) 0xFC) // 3 bytes
{
text.append (get (ptr, 3));
return ptr + 4; // skip trailing zero
}
if (b1 == (byte) 0xFA) // 2 bytes
{
text.append (get (ptr, 2));
return ptr + 2;
}
if (b1 == (byte) 0xFB)
{
return ptr + 3; // ignore next 3 bytes (why?)
}
if ((b1 & 0xF0) == 0xF0) // F0:F9 = 0:9
{
text.append (b1 & 0x0F);
return ptr;
}
if ((b1 & 0xE0) == 0xE0) // 3 nybbles
{
text.append (((b1 & 0x0F) << 8) | (buffer[ptr++] & 0xFF));
return ptr;
}
System.out.printf ("not handled: %02X%n", b1);
return ptr;
}
private void append (String word, StringBuilder text)
{
if (word.startsWith (" ") && text.length () > 0
&& text.charAt (text.length () - 1) == ' ')
text.deleteCharAt (text.length () - 1);
text.append (word);
}
private int get (int ptr, int size)
{
int val = 0;
@ -202,7 +217,7 @@ public class BasicProgramGS extends BasicProgram
@Override
public String toString ()
{
return String.format ("%5d %s", lineNumber, line);
return String.format ("%5d %-12s %s", lineNumber, label, line);
}
}
}

View File

@ -127,6 +127,10 @@ public abstract class AbstractFormattedDisk implements FormattedDisk
gridLayout = new Dimension (16, 35);
break;
case 768:
gridLayout = new Dimension (16, 48);
break;
case 1600:
gridLayout = new Dimension (16, 100);
break;

View File

@ -76,7 +76,6 @@ public class AppleDisk implements Disk
// DFB 06,04,02,15 ;12->06,13->04,14->02,15->15
private boolean[] hasData;
// private boolean[] isMissing;
private byte emptyByte = 0;
private ActionListener actionListenerList;
@ -230,7 +229,6 @@ public class AppleDisk implements Disk
sectorSize = trackSize / sectors;
blocks = tracks * sectors;
hasData = new boolean[blocks];
// isMissing = new boolean[blocks];
checkSectorsForData ();
}
@ -263,12 +261,8 @@ public class AppleDisk implements Disk
blocks = tracks * sectors;
hasData = new boolean[blocks];
// isMissing = new boolean[blocks];
checkSectorsForData ();
// for (Sector sector : wozFile.getBadSectors ())
// isMissing[sector.trackNo * sectors + sector.sectorNo] = true;
}
private byte[] getPrefix (File path)

View File

@ -48,12 +48,6 @@ public interface Disk extends Iterable<DiskAddress>
public boolean isSectorEmpty (DiskAddress da);
// public boolean isSectorMissing (int block);
// public boolean isSectorMissing (int track, int sector);
// public boolean isSectorMissing (DiskAddress da);
public boolean isValidAddress (int block);
public boolean isValidAddress (int track, int sector);

View File

@ -232,10 +232,14 @@ public class DiskFactory
if (suffix.equals ("woz"))
{
if (debug)
System.out.println ("Checking woz");
try
{
// WozFileOld wozDisk = new WozFileOld (file);
WozFile wozFile = new WozFile (file);
if (debug)
System.out.println (" Woz read");
if (wozFile.getSectorsPerTrack () == 13)
{
AppleDisk appleDisk = new AppleDisk (wozFile, 35, 13);
@ -245,7 +249,7 @@ public class DiskFactory
if (wozFile.getSectorsPerTrack () == 16)
{
AppleDisk appleDisk256 = new AppleDisk (wozFile, 35, 16);
AppleDisk appleDisk256 = new AppleDisk (wozFile, wozFile.getTracks (), 16);
disk = checkDos (appleDisk256);
if (disk == null)
disk = checkProdos (new AppleDisk (wozFile, 35, 8));

View File

@ -271,6 +271,10 @@ public class DosDisk extends AbstractFormattedDisk
return "3.3";
case 0x41:
return "4.1";
case 0x42:
return "4.2";
case 0x43:
return "4.3";
default:
return "??";
}
@ -302,7 +306,7 @@ public class DosDisk extends AbstractFormattedDisk
// }
int version = buffer[3] & 0xFF;
if (version > 0x42 && version != 0xFF)
if (version > 0x43 && version != 0xFF)
{
System.out.printf ("Bad version : %02X%n", version);
return 0;

View File

@ -81,14 +81,16 @@ class DosVTOCSector extends AbstractSector
addTextAndDecimal (text, buffer, 0x36, 2, "Bytes per sector");
boolean bootSectorEmpty = parentDisk.getDisk ().isSectorEmpty (0);
for (int i = 0x38; i <= 0xC3; i += 4)
int base = 0x38;
int max = maxTracks * 4 + base;
for (int i = base; i < max; i += 4)
{
String extra = "";
if (i == 0x38 && bootSectorEmpty)
if (i == base && bootSectorEmpty)
extra = "(unusable)";
else if (i == 124)
extra = "(VTOC and Catalog)";
addText (text, buffer, i, 4, String.format ("Track %02X %s %s", (i - 56) / 4,
addText (text, buffer, i, 4, String.format ("Track %02X %s %s", (i - base) / 4,
getBitmap (buffer[i], buffer[i + 1]), extra));
}

View File

@ -24,8 +24,6 @@ class DiskLayoutImage extends DiskPanel implements Scrollable, RedoListener
private static final Cursor crosshairCursor = new Cursor (Cursor.CROSSHAIR_CURSOR);
private static final Color[] lightColors =
{ Color.WHITE, Color.YELLOW, Color.PINK, Color.CYAN, Color.ORANGE, Color.GREEN };
private static Stroke missingStroke =
new BasicStroke ((float) 3.0, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND);
private boolean showFreeSectors;
private final DiskLayoutSelection selectionHandler = new DiskLayoutSelection ();
@ -126,7 +124,6 @@ class DiskLayoutImage extends DiskPanel implements Scrollable, RedoListener
DiskAddress da = d.getDiskAddress (blockNo);
boolean free = showFreeSectors && formattedDisk.isSectorFree (da);
boolean selected = selectionHandler.isSelected (da);
// boolean missing = d.isSectorMissing (da);
drawBlock ((Graphics2D) g, type, x, y, free, selected);
}
}
@ -149,14 +146,6 @@ class DiskLayoutImage extends DiskPanel implements Scrollable, RedoListener
if (selected)
g.fillOval (x + centerOffset, y + 6, 3, 3);
}
// if (missing)
// {
// g.setColor (Color.darkGray);
// g.setStroke (missingStroke);
// g.drawLine (x + 5, y + 5, x + 11, y + 11);
// g.drawLine (x + 5, y + 11, x + 11, y + 5);
// }
}
private Color getContrastColor (SectorType type)

View File

@ -75,7 +75,7 @@ class DiskLayoutPanel extends JPanel
sp.setViewportView (diskLayoutImage);
setLayout (new BorderLayout ());
if (disk.getGridLayout ().height == 35)
if (disk.getGridLayout ().height == 35) // what about 48?
{
add (sp, BorderLayout.NORTH);
add (legendPanel, BorderLayout.CENTER);

View File

@ -11,10 +11,8 @@ public class DiskPanel extends JPanel
{
FormattedDisk formattedDisk;
LayoutDetails layoutDetails;
// boolean isRetina;
int blockWidth = 30; // default
int blockHeight = 15; // default
// int offset;
int centerOffset;
Color backgroundColor = new Color (0xE0, 0xE0, 0xE0);
@ -27,13 +25,5 @@ public class DiskPanel extends JPanel
blockWidth = layoutDetails.block.width;
blockHeight = layoutDetails.block.height;
centerOffset = (blockWidth - 4) / 2 + 1;
// Graphics2D g = (Graphics2D) this.getGraphics ();
// if (g != null) // panel might not be showing
// isRetina = g.getFontRenderContext ().getTransform ()
// .equals (AffineTransform.getScaleInstance (2.0, 2.0));
// offset = isRetina ? 1 : 2;
// centerOffset = (blockWidth - 4) / 2 + 1;
}
}

View File

@ -40,6 +40,7 @@ public class WozFile
private byte[] addressPrologue;
private byte[] diskBuffer;
private List<Track> tracks;
private final boolean debug1 = false;
private final boolean debug2 = false;
@ -64,8 +65,6 @@ public class WozFile
throw new DiskNibbleException ("Checksum error");
}
List<Track> tracks = null;
int ptr = 12;
while (ptr < buffer.length)
{
@ -100,7 +99,7 @@ public class WozFile
if (info.diskType == 1) // 5.25"
{
diskBuffer = new byte[35 * diskSectors * SECTOR_SIZE];
diskBuffer = new byte[tracks.size () * diskSectors * SECTOR_SIZE];
for (Track track : tracks)
track.pack (diskBuffer);
@ -114,6 +113,13 @@ public class WozFile
return diskBuffer;
}
// ---------------------------------------------------------------------------------//
public int getTracks ()
// ---------------------------------------------------------------------------------//
{
return tracks.size ();
}
// ---------------------------------------------------------------------------------//
public int getSectorsPerTrack ()
// ---------------------------------------------------------------------------------//