Compare commits
35 Commits
Author | SHA1 | Date |
---|---|---|
Denis Molony | 2bc330e377 | |
Denis Molony | 6c81bcc93b | |
Denis Molony | 171fd66ba1 | |
Denis Molony | aa77ec1cd4 | |
Denis Molony | 8f95988596 | |
Denis Molony | 8cb682f068 | |
Denis Molony | dfc7a68580 | |
Denis Molony | 4b476457d3 | |
Denis Molony | 3bf972a761 | |
Denis Molony | fd5bee6e5c | |
Denis Molony | 0af6714119 | |
Denis Molony | 22dfaf65c6 | |
Denis Molony | f4a6465b04 | |
Denis Molony | 64d5ce9ee2 | |
Denis Molony | 4e48437adc | |
Denis Molony | e2abdcabc9 | |
Denis Molony | bc0993e9d3 | |
Denis Molony | 9fba3893ba | |
Denis Molony | 09c4542118 | |
Denis Molony | af3ead0441 | |
Denis Molony | c12392200b | |
frankmilliron | 794fef8610 | |
frankmilliron | 2ec0e10c5e | |
Denis Molony | 668ed719fa | |
Denis Molony | 23b95675cf | |
Denis Molony | b98ecbed8d | |
Denis Molony | 82381a6a47 | |
Denis Molony | 3f2f1bfbca | |
Denis Molony | a7119528a6 | |
Denis Molony | 6f943ae8c2 | |
Denis Molony | 5add6c0729 | |
Denis Molony | 921c946ab5 | |
Denis Molony | 898587b23b | |
Denis Molony | 37c489f252 | |
Denis Molony | 036e47b9b1 |
|
@ -1,4 +0,0 @@
|
|||
/bin/
|
||||
.project
|
||||
.classpath
|
||||
build.xml
|
|
@ -1,5 +1,6 @@
|
|||
# Apple II Disk Browser
|
||||
|
||||
### Alternative
|
||||
There is a new release of [DiskBrowser2](https://github.com/dmolony/diskbrowser2) available.
|
||||
### Features
|
||||
- Cross-platform (Windows, MacOS, Linux)
|
||||
- Disk formats
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<project name="DiskBrowser" default="jar" basedir=".">
|
||||
|
||||
<property name="srcDir" location="src" />
|
||||
<property name="binDir" location="bin" />
|
||||
<property name="jarDir" location="${user.home}/Dropbox/Java" />
|
||||
<property name="jarFile" location="${jarDir}/DiskBrowser.jar" />
|
||||
|
||||
<target name="version">
|
||||
<echo>DiskBrowser.jar</echo>
|
||||
<echo>${ant.version}</echo>
|
||||
<echo>Java/JVM version: ${ant.java.version}</echo>
|
||||
<echo>Java/JVM detail version: ${java.version}</echo>
|
||||
</target>
|
||||
|
||||
<target name="init" depends="version">
|
||||
<delete file="${binDir}/*.class" />
|
||||
<delete file="${jarFile}" />
|
||||
</target>
|
||||
|
||||
<target name="compile" depends="init">
|
||||
<javac debug="on" srcdir="${srcDir}" destdir="${binDir}" includeantruntime="false">
|
||||
<classpath>
|
||||
<pathelement location="." />
|
||||
</classpath>
|
||||
</javac>
|
||||
</target>
|
||||
|
||||
<target name="jar" depends="compile">
|
||||
<jar destfile="${jarFile}">
|
||||
<fileset dir="${binDir}" />
|
||||
<zipfileset src="${jarDir}/InputPanel.jar" />
|
||||
<manifest>
|
||||
<attribute name="Main-Class" value="com.bytezone.diskbrowser.gui.DiskBrowser" />
|
||||
</manifest>
|
||||
</jar>
|
||||
</target>
|
||||
|
||||
</project>
|
|
@ -10,7 +10,7 @@ public class ApplesoftBasicProgram extends BasicProgram implements ApplesoftCons
|
|||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
private final List<SourceLine> sourceLines = new ArrayList<> ();
|
||||
private int ptr; // end-of-program marker
|
||||
private int ptr = 0; // end-of-program marker
|
||||
|
||||
private final UserBasicFormatter userBasicFormatter;
|
||||
private final AppleBasicFormatter appleBasicFormatter;
|
||||
|
|
|
@ -8,8 +8,8 @@ import com.bytezone.diskbrowser.utilities.HexFormatter;
|
|||
public class BasicTextFile extends TextFile
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
private static String underline = "------------------------------------------"
|
||||
+ "------------------------------------\n";
|
||||
private static String underline =
|
||||
"------------------------------------------" + "------------------------------------\n";
|
||||
private static String fullUnderline = "---------- ------- " + underline;
|
||||
private int recordLength; // prodos aux
|
||||
private List<TextBuffer> buffers; // only used if it is a Prodos text file
|
||||
|
@ -30,6 +30,7 @@ public class BasicTextFile extends TextFile
|
|||
super (name, buffer);
|
||||
|
||||
this.eof = eof;
|
||||
|
||||
recordLength = auxType;
|
||||
prodosFile = true;
|
||||
}
|
||||
|
@ -42,6 +43,7 @@ public class BasicTextFile extends TextFile
|
|||
|
||||
this.buffers = buffers;
|
||||
this.eof = eof;
|
||||
|
||||
recordLength = auxType;
|
||||
prodosFile = true;
|
||||
}
|
||||
|
@ -167,8 +169,7 @@ public class BasicTextFile extends TextFile
|
|||
if (textPreferences.showTextOffsets)
|
||||
{
|
||||
line = line.replaceAll ("\\n", "\n ");
|
||||
text.append (
|
||||
String.format ("%,10d %,8d %s%n", recNo * recordLength, recNo, line));
|
||||
text.append (String.format ("%,10d %,8d %s%n", recNo * recordLength, recNo, line));
|
||||
}
|
||||
else
|
||||
text.append (String.format ("%s%n", line));
|
||||
|
|
|
@ -16,9 +16,10 @@ import com.bytezone.diskbrowser.utilities.Utility;
|
|||
public abstract class HiResImage extends AbstractFile
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
static final String[] auxTypes = { "Paintworks Packed SHR Image", "Packed Super Hi-Res Image",
|
||||
"Super Hi-Res Image (Apple Preferred Format)", "Packed QuickDraw II PICT File",
|
||||
"Packed Super Hi-Res 3200 color image", "DreamGraphix" };
|
||||
static final String[] auxTypes =
|
||||
{ "Paintworks Packed SHR Image", "Packed Super Hi-Res Image",
|
||||
"Super Hi-Res Image (Apple Preferred Format)", "Packed QuickDraw II PICT File",
|
||||
"Packed Super Hi-Res 3200 color image", "DreamGraphix" };
|
||||
|
||||
static final int COLOR_TABLE_SIZE = 32;
|
||||
static final int COLOR_TABLE_OFFSET_AUX_0 = 32_256;
|
||||
|
@ -115,7 +116,8 @@ public abstract class HiResImage extends AbstractFile
|
|||
|
||||
static PaletteFactory paletteFactory = new PaletteFactory ();
|
||||
|
||||
static final byte[] pngHeader = { (byte) 0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A };
|
||||
static final byte[] pngHeader =
|
||||
{ (byte) 0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A };
|
||||
|
||||
static boolean colourQuirks;
|
||||
static boolean monochrome;
|
||||
|
@ -275,8 +277,8 @@ public abstract class HiResImage extends AbstractFile
|
|||
{
|
||||
String auxText = "";
|
||||
StringBuilder text = new StringBuilder ();
|
||||
text.append (String.format ("Image File : %s%nFile type : $%02X %s%n", name, fileType,
|
||||
ProdosConstants.fileTypes[fileType]));
|
||||
text.append (String.format ("Image File : %s%nFile type : $%02X %s%n", name,
|
||||
fileType, ProdosConstants.fileTypes[fileType]));
|
||||
|
||||
switch (fileType)
|
||||
{
|
||||
|
@ -393,7 +395,8 @@ public abstract class HiResImage extends AbstractFile
|
|||
{
|
||||
if (dataBuffer.getSize () < rgbList.length + element)
|
||||
{
|
||||
System.out.printf ("Bollocks: %d %d %d%n", dataBuffer.getSize (), rgbList.length, element);
|
||||
System.out.printf ("Bollocks: %d %d %d%n", dataBuffer.getSize (), rgbList.length,
|
||||
element);
|
||||
return element;
|
||||
}
|
||||
|
||||
|
@ -462,12 +465,13 @@ public abstract class HiResImage extends AbstractFile
|
|||
int type = (buffer[ptr] & 0xC0) >>> 6; // 0-3
|
||||
int count = (buffer[ptr++] & 0x3F) + 1; // 1-64
|
||||
|
||||
text.append (String.format ("%04X/%04d: %02X (%d,%2d) ", ptr - 1, size, buffer[ptr - 1],
|
||||
type, count));
|
||||
text.append (String.format ("%04X/%04d: %02X (%d,%2d) ", ptr - 1, size,
|
||||
buffer[ptr - 1], type, count));
|
||||
|
||||
if (type == 0)
|
||||
{
|
||||
text.append (String.format ("%s%n", HexFormatter.getHexString (buffer, ptr, count)));
|
||||
text.append (
|
||||
String.format ("%s%n", HexFormatter.getHexString (buffer, ptr, count)));
|
||||
ptr += count;
|
||||
size += count;
|
||||
}
|
||||
|
@ -651,8 +655,8 @@ public abstract class HiResImage extends AbstractFile
|
|||
if (buffer.length < 4)
|
||||
return false;
|
||||
|
||||
return buffer[0] == (byte) 0xC1 && buffer[1] == (byte) 0xD0 && buffer[2] == (byte) 0xD0
|
||||
&& buffer[3] == 0;
|
||||
return buffer[0] == (byte) 0xC1 && buffer[1] == (byte) 0xD0
|
||||
&& buffer[2] == (byte) 0xD0 && buffer[3] == 0;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
|
|
|
@ -4,6 +4,8 @@ package com.bytezone.diskbrowser.applefile;
|
|||
public class PascalText extends TextFile
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
private final static int PAGE_SIZE = 1024;
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public PascalText (String name, byte[] buffer)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
|
@ -16,28 +18,34 @@ public class PascalText extends TextFile
|
|||
public String getText ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
// Text files are broken up into 1024-byte pages.
|
||||
// [DLE] [indent] [text] [CR] ... [nulls]
|
||||
|
||||
StringBuilder text = new StringBuilder (getHeader ());
|
||||
|
||||
int ptr = 0x400;
|
||||
int ptr = PAGE_SIZE; // skip text editor header
|
||||
|
||||
while (ptr < buffer.length)
|
||||
{
|
||||
if (buffer[ptr] == 0x00)
|
||||
if (buffer[ptr] == 0x00) // padding to page boundary
|
||||
{
|
||||
++ptr;
|
||||
ptr = (ptr / PAGE_SIZE + 1) * PAGE_SIZE; // skip to next page
|
||||
continue;
|
||||
}
|
||||
|
||||
if (buffer[ptr] == 0x10)
|
||||
if (buffer[ptr] == 0x10) // Data Link Escape code
|
||||
{
|
||||
int tab = buffer[ptr + 1] - 0x20;
|
||||
int tab = (buffer[ptr + 1] & 0xFF) - 32; // indent amaount
|
||||
while (tab-- > 0)
|
||||
text.append (" ");
|
||||
ptr += 2;
|
||||
}
|
||||
|
||||
String line = getLine (ptr);
|
||||
text.append (line + "\n");
|
||||
ptr += line.length () + 1;
|
||||
while (buffer[ptr] != 0x0D)
|
||||
text.append ((char) buffer[ptr++]);
|
||||
|
||||
text.append ("\n");
|
||||
ptr++;
|
||||
}
|
||||
|
||||
if (text.length () > 0)
|
||||
|
@ -45,16 +53,4 @@ public class PascalText extends TextFile
|
|||
|
||||
return text.toString ();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
private String getLine (int ptr)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
StringBuilder line = new StringBuilder ();
|
||||
|
||||
while (buffer[ptr] != 0x0D)
|
||||
line.append ((char) buffer[ptr++]);
|
||||
|
||||
return line.toString ();
|
||||
}
|
||||
}
|
|
@ -3,6 +3,7 @@ package com.bytezone.diskbrowser.applefile;
|
|||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import com.bytezone.diskbrowser.disk.FormattedDisk;
|
||||
import com.bytezone.diskbrowser.prodos.DirectoryHeader;
|
||||
|
@ -15,7 +16,8 @@ import com.bytezone.diskbrowser.utilities.Utility;
|
|||
public class ProdosDirectory extends AbstractFile implements ProdosConstants
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
static final DateTimeFormatter df = DateTimeFormatter.ofPattern ("d-LLL-yy");
|
||||
private static Locale US = Locale.US; // to force 3 character months
|
||||
static final DateTimeFormatter df = DateTimeFormatter.ofPattern ("d-LLL-yy", US);
|
||||
static final DateTimeFormatter tf = DateTimeFormatter.ofPattern ("H:mm");
|
||||
static final String UNDERLINE =
|
||||
"----------------------------------------------------\n";
|
||||
|
@ -86,7 +88,6 @@ public class ProdosDirectory extends AbstractFile implements ProdosConstants
|
|||
int nameLength = buffer[i] & 0x0F;
|
||||
String filename = HexFormatter.getString (buffer, i + 1, nameLength);
|
||||
String subType = "";
|
||||
String locked;
|
||||
|
||||
switch (storageType)
|
||||
{
|
||||
|
@ -121,12 +122,12 @@ public class ProdosDirectory extends AbstractFile implements ProdosConstants
|
|||
|
||||
int eof = Utility.intValue (buffer[i + 21], buffer[i + 22], buffer[i + 23]);
|
||||
int fileType = buffer[i + 16] & 0xFF;
|
||||
locked = (buffer[i + 30] & 0xE0) == 0xE0 ? " " : "*";
|
||||
String locked = (buffer[i + 30] & 0xE0) == 0xE0 ? " " : "*";
|
||||
int aux = Utility.getShort (buffer, i + 31);
|
||||
|
||||
switch (fileType)
|
||||
{
|
||||
case FILE_TYPE_TEXT:
|
||||
int aux = Utility.getShort (buffer, i + 31);
|
||||
subType = String.format ("R=%5d", aux);
|
||||
break;
|
||||
|
||||
|
@ -134,14 +135,13 @@ public class ProdosDirectory extends AbstractFile implements ProdosConstants
|
|||
case FILE_TYPE_PNT:
|
||||
case FILE_TYPE_PIC:
|
||||
case FILE_TYPE_FOT:
|
||||
aux = Utility.getShort (buffer, i + 31);
|
||||
subType = String.format ("A=$%4X", aux);
|
||||
break;
|
||||
|
||||
case FILE_TYPE_AWP:
|
||||
aux = Utility.intValue (buffer[i + 32], buffer[i + 31]); // backwards!
|
||||
if (aux != 0)
|
||||
filename = convert (filename, aux);
|
||||
int flags = Utility.intValue (buffer[i + 32], buffer[i + 31]); // aux backwards!
|
||||
if (flags != 0)
|
||||
filename = convert (filename, flags);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -149,9 +149,10 @@ public class ProdosDirectory extends AbstractFile implements ProdosConstants
|
|||
}
|
||||
|
||||
String forkFlag = storageType == 5 ? "+" : " ";
|
||||
text.append (String.format ("%s%-15s %3s%s %5d %9s %5s %9s %5s %8d %7s%n",
|
||||
locked, filename, ProdosConstants.fileTypes[type], forkFlag, blocks, dateM,
|
||||
timeM, dateC, timeC, eof, subType));
|
||||
text.append (
|
||||
String.format ("%s%-15s %3s%s %5d %9s %5s %9s %5s %8d %7s %04X%n",
|
||||
locked, filename, ProdosConstants.fileTypes[type], forkFlag, blocks,
|
||||
dateM, timeM, dateC, timeC, eof, subType, aux));
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
|
@ -243,7 +243,7 @@ public class SHRPictureFile1 extends HiResImage
|
|||
colorTables[i] = new ColorTable (i, data, ptr);
|
||||
else
|
||||
colorTables[i] = new ColorTable (i, 0x00); // default empty table !! not
|
||||
// finished
|
||||
// finished
|
||||
ptr += 32;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -202,7 +202,7 @@ public class SubLine implements ApplesoftConstants
|
|||
private void checkFunction (String var, byte terminator)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
assert terminator == ASCII_LEFT_BRACKET;
|
||||
// assert terminator == ASCII_LEFT_BRACKET;
|
||||
|
||||
if (!functions.contains (var))
|
||||
functions.add (var);
|
||||
|
|
|
@ -22,10 +22,19 @@
|
|||
0035 YSAV1
|
||||
0036 CSWL
|
||||
0037 CSHW
|
||||
0044 A5L - volume number?
|
||||
003D A1H
|
||||
003C A1L
|
||||
003F A2H
|
||||
003E A2L
|
||||
0041 A3H
|
||||
0040 A3L
|
||||
0043 A4H
|
||||
0042 A4L
|
||||
0045 A5H
|
||||
0044 A5L
|
||||
004E RND-LO
|
||||
004F RND-HI
|
||||
0050 LINNUM
|
||||
0050 LINNUM line number, unsigned word
|
||||
0067 Basic program address LO
|
||||
0068 Basic program address HI
|
||||
0069 Basic variables address LO
|
||||
|
@ -52,8 +61,48 @@
|
|||
0200 Input buffer
|
||||
|
||||
03D0 Applesoft warm start
|
||||
03EA VECT
|
||||
A56E catalog routine
|
||||
|
||||
03F2 RST: Control-reset vector
|
||||
03F3 RST: Control-reset vector
|
||||
03F4 RST: Control-reset checksum (EOR #$A5)
|
||||
03FB NMI: Non-Maskable Interrupt vector
|
||||
03FC NMI: Non-Maskable Interrupt vector
|
||||
03F8 USR: user vector (Control-Y)
|
||||
03F9 USR: user vector (Control-Y)
|
||||
03FE IRQ: Interrupt Request/BRK vector
|
||||
03FF IRQ: Interrupt Request/BRK vector
|
||||
|
||||
A54F DOS 3.3 INIT
|
||||
A413 DOS 3.3 LOAD
|
||||
A397 DOS 3.3 SAVE
|
||||
A4D1 DOS 3.3 RUN
|
||||
A4F0 DOS 3.3 CHAIN
|
||||
A263 DOS 3.3 DELETE
|
||||
A271 DOS 3.3 LOCK
|
||||
A275 DOS 3.3 UNLOCK
|
||||
A2EA DOS 3.3 CLOSE
|
||||
A51B DOS 3.3 READ
|
||||
A5C6 DOS 3.3 EXEC
|
||||
A510 DOS 3.3 WRITE
|
||||
A5DD DOS 3.3 POSITION
|
||||
A2A3 DOS 3.3 OPEN
|
||||
A298 DOS 3.3 APPEND
|
||||
A281 DOS 3.3 RENAME
|
||||
A56E DOS 3.3 CATALOG
|
||||
A233 DOS 3.3 MON
|
||||
A23D DOS 3.3 NOMON
|
||||
A229 DOS 3.3 PR#
|
||||
A22E DOS 3.3 IN#
|
||||
A251 DOS 3.3 MAXFILES
|
||||
A57A DOS 3.3 FP
|
||||
A59E DOS 3.3 INT
|
||||
A331 DOS 3.3 BSAVE
|
||||
A35D DOS 3.3 BLOAD
|
||||
A38E DOS 3.3 BRUN
|
||||
A27D DOS 3.3 VERIFY
|
||||
|
||||
BF00 ProDOS MLI entry point
|
||||
BF98 ProDOS Machine ID Byte
|
||||
|
||||
* C000 80STOREOFF Allow page2 to switch video page1 page2
|
||||
C001 80STOREON Allow page2 to switch main & aux video memory
|
||||
|
@ -68,8 +117,12 @@ C009 ALTZPON Enable aux memory from $0000-$01FF & avl BSR
|
|||
C00A SLOTC3ROMOFF Enable main ROM from $C300-$C3FF
|
||||
C00B SLOTC3ROMON Enable slot ROM from $C300-$C3FF
|
||||
|
||||
C000 KYBD - last key pressed
|
||||
C010 STROBE - Clear KYBD
|
||||
C000 KBD - Last key pressed
|
||||
C010 KBDSTRB - Clear KYBD
|
||||
C019 VBL - Vertical Blank
|
||||
C020 TAPEOUT - Toggle cassette output
|
||||
C030 SPKR - Toggle speaker
|
||||
C040 STROBE - Output strobe pulse to game I/O connector
|
||||
C050 TXTCLR - Display Graphics
|
||||
C051 TXTSET - Display Text
|
||||
C052 MIXCLR - Display Full Screen
|
||||
|
@ -78,6 +131,15 @@ C054 TXTPAGE1 - Display Page 1
|
|||
C055 TXTPAGE2 - If 80STORE Off: Display Page 2, If 80STORE On: Read/Write Aux Display Mem
|
||||
C056 LORES - Display LoRes Graphics
|
||||
C057 HIRES - Display HiRes Graphics
|
||||
C060 TAPEIN - Read audio from cassette input
|
||||
C061 PB0 - Read joystick button 0/Open-Apple key
|
||||
C062 PB1 - Read joystick button 1/Closed-Apple key
|
||||
C063 PB2 - Read joystick button 2
|
||||
C064 PADDL0 - Read paddle/joystick 0
|
||||
C065 PADDL1 - Read paddle/joystick 1
|
||||
C066 PADDL2 - Read paddle/joystick 2
|
||||
C067 PADDL3 - Read paddle/joystick 3
|
||||
C070 PTRIG - Clear paddle/joystick timer
|
||||
|
||||
C080 Read RAM bank 2; no write
|
||||
C081 ROMIN - Read ROM; write RAM bank 2
|
||||
|
@ -96,6 +158,9 @@ C08D Read ROM; write RAM bank 1
|
|||
C08E Read ROM; no write
|
||||
C08F Read/write RAM bank 1
|
||||
|
||||
C600 BOOT0 - Disk II controller ROM
|
||||
0801 BOOT1 - Disk II bootstrap RAM
|
||||
|
||||
D52C INLIN numeric input
|
||||
DB3A STROUT - output a string
|
||||
DB5C output a character
|
||||
|
@ -106,6 +171,7 @@ DEC0 SYNCHR
|
|||
DEC9 syntax error
|
||||
DFE3 PTRGET
|
||||
|
||||
E000 Applesoft BASIC entry
|
||||
E053 find a variable
|
||||
E10C convert FP to INT
|
||||
E2F2 GIVAYF - convert (A,Y) to FP
|
||||
|
@ -177,15 +243,16 @@ F941 PRINTAX - print AX registers in hex
|
|||
F948 PRBLNK - print 3 spaces
|
||||
F94A PRBL2 - print X blank spaces
|
||||
|
||||
FAA6 reboot DOS
|
||||
FAA6 PWRUP - reboot
|
||||
FAFF 0 = Autostart ROM, 1 = Old Monitor
|
||||
|
||||
FB1E PREAD - read game paddle
|
||||
FB2F initialise text screen
|
||||
FB2F INIT - initialise text screen
|
||||
FB39 text mode - SETTXT
|
||||
FB40 SETGR
|
||||
FB5B TABV - monitor tab routine
|
||||
FB6F set powerup checksum
|
||||
FB6F SETPWRC - set powerup checksum
|
||||
FBB3 VERSION - monitor ROM ID byte
|
||||
FBC1 BASCALC - calculate video address
|
||||
FBDD BELL1 - beep speaker
|
||||
FBF4 CURSRIT - move cursor right
|
||||
|
@ -193,6 +260,7 @@ FBF4 CURSRIT - move cursor right
|
|||
FC10 CURSLFT - move cursor left
|
||||
FC1A CURSUP - move cursor up
|
||||
FC22 VTAB
|
||||
FC24 VTABZ
|
||||
FC42 CLREOP - clear to end of page
|
||||
FC58 HOME - clear screen
|
||||
FC62 CR
|
||||
|
@ -215,12 +283,13 @@ FDE3 PRHEX - print a hex digit
|
|||
FDED COUT - print a character (in Acc)
|
||||
FDF0 COUT1 - print character to screen
|
||||
|
||||
FE2C move a block of memory
|
||||
FE1F IDROUTINE - detect //gs
|
||||
FE2C MOVE - move a block of memory
|
||||
FE80 SETINV - set inverse mode
|
||||
FE84 SETNORM - set normal mode
|
||||
FE89 disconnect DOS from I/O links
|
||||
FE89 SETKBD - disconnect DOS from I/O links
|
||||
FE8B INPORT
|
||||
FE93 disconnect DOS from I/O links
|
||||
FE93 SETVID - disconnect DOS from I/O links
|
||||
FE95 OUTPORT
|
||||
FECD WRITE
|
||||
FEFD READ
|
||||
|
@ -231,6 +300,14 @@ FF3A BELL
|
|||
FF3F IOREST - restore all registers
|
||||
FF4A IOSAVE - save all registers
|
||||
FF58 RTS - jump to <address on stack> + 1
|
||||
FF59 Monitor cold entry point
|
||||
FF59 MON - Monitor cold entry point (w/BELL)
|
||||
FF69 MONZ - Monitor entry point from BASIC (CALL -151)
|
||||
FFA7 GETNUM - move num to A2L.A2H
|
||||
FFC7 ZMODE - monitor get ASCII return
|
||||
|
||||
FFFA NMI_VECTOR
|
||||
FFFB NMI_VECTOR
|
||||
FFFC RESET_VECTOR
|
||||
FFFD RESET_VECTOR
|
||||
FFFE IRQ_VECTOR
|
||||
FFFF IRQ_VECTOR
|
||||
|
|
|
@ -16,6 +16,7 @@ import com.bytezone.diskbrowser.disk.SectorType;
|
|||
import com.bytezone.diskbrowser.gui.DataSource;
|
||||
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||
|
||||
// https://www.retrotechnology.com/dri/howto_cpm.html
|
||||
// -----------------------------------------------------------------------------------//
|
||||
public class CPMDisk extends AbstractFormattedDisk
|
||||
// -----------------------------------------------------------------------------------//
|
||||
|
@ -88,7 +89,7 @@ public class CPMDisk extends AbstractFormattedDisk
|
|||
if (b1 > 31 && b1 != EMPTY_BYTE_VALUE)
|
||||
break;
|
||||
|
||||
if (b2 < 32 || (b2 > 126 && b2 != EMPTY_BYTE_VALUE))
|
||||
if (b2 <= 32 || (b2 > 126 && b2 != EMPTY_BYTE_VALUE))
|
||||
break;
|
||||
|
||||
for (int i = 0; i < buffer.length; i += 32)
|
||||
|
@ -99,7 +100,7 @@ public class CPMDisk extends AbstractFormattedDisk
|
|||
if (b1 == EMPTY_BYTE_VALUE) // deleted file??
|
||||
continue;
|
||||
|
||||
if (b2 < 32 || (b2 > 126 && b2 != EMPTY_BYTE_VALUE))
|
||||
if (b2 <= 32 || (b2 > 126 && b2 != EMPTY_BYTE_VALUE))
|
||||
break;
|
||||
|
||||
DirectoryEntry entry = new DirectoryEntry (this, buffer, i);
|
||||
|
@ -188,9 +189,8 @@ public class CPMDisk extends AbstractFormattedDisk
|
|||
public AppleFileSource getCatalog ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
String line =
|
||||
"---- --------- --- - - -- -- -- -- ----------------------------"
|
||||
+ "-------------------\n";
|
||||
String line = "---- --------- --- - - -- -- -- -- ----------------------------"
|
||||
+ "-------------------\n";
|
||||
StringBuilder text = new StringBuilder ();
|
||||
text.append (String.format ("File : %s%n%n", getDisplayPath ()));
|
||||
text.append ("User Name Typ R S Ex S2 S1 RC Blocks\n");
|
||||
|
|
|
@ -139,9 +139,8 @@ class DirectoryEntry implements AppleFileSource
|
|||
char ro = readOnly ? '*' : ' ';
|
||||
char sf = systemFile ? '*' : ' ';
|
||||
|
||||
String text =
|
||||
String.format ("%3d %-8s %-3s %s %s %02X %02X %02X %02X %s",
|
||||
userNumber, name, type, ro, sf, extent, s2, s1, recordsUsed, bytes);
|
||||
String text = String.format ("%3d %-8s %-3s %s %s %02X %02X %02X %02X %s",
|
||||
userNumber, name, type, ro, sf, extent, s2, s1, recordsUsed, bytes);
|
||||
for (DirectoryEntry entry : entries)
|
||||
text = text + "\n" + entry.line ();
|
||||
|
||||
|
@ -218,14 +217,13 @@ class DirectoryEntry implements AppleFileSource
|
|||
else if ("DVR".equals (type))
|
||||
appleFile = new DefaultAppleFile (name, exactBuffer, "DVR File");
|
||||
else if ("ASM".equals (type) || "DOC".equals (type) || "COB".equals (type)
|
||||
|| "HLP".equals (type) || "TXT".equals (type) || "LET".equals (type)
|
||||
|| "ALX".equals (type) || "SRC".equals (type) || "H".equals (type)
|
||||
|| exactBuffer[len - 1] == 0x1A)
|
||||
|| "HLP".equals (type) || "TXT".equals (type) || "LET".equals (type) || "ALX".equals (type)
|
||||
|| "SRC".equals (type) || "H".equals (type) || exactBuffer[len - 1] == 0x1A)
|
||||
appleFile = new CPMTextFile (name, exactBuffer);
|
||||
else if ("BAS".equals (type))
|
||||
appleFile = new CPMBasicFile (name, exactBuffer);
|
||||
else
|
||||
appleFile = new DefaultAppleFile (name, exactBuffer, "CPM File : " + type);
|
||||
appleFile = new DefaultAppleFile (name, exactBuffer, "CPM File : " + name + "." + type);
|
||||
|
||||
return appleFile;
|
||||
}
|
||||
|
|
|
@ -206,8 +206,7 @@ public abstract class AbstractFormattedDisk implements FormattedDisk
|
|||
|
||||
DefaultMutableTreeNode root = getCatalogTreeRoot ();
|
||||
if (root.getUserObject () == null)
|
||||
root.setUserObject (
|
||||
new DefaultAppleFileSource (getName (), disk.toString (), this));
|
||||
root.setUserObject (new DefaultAppleFileSource (getName (), disk.toString (), this));
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
|
@ -234,15 +233,15 @@ public abstract class AbstractFormattedDisk implements FormattedDisk
|
|||
public String getDisplayPath ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
// if (originalPath != null)
|
||||
// return originalPath.toString ();
|
||||
|
||||
String home = System.getProperty ("user.home");
|
||||
|
||||
String path = originalPath != null ? originalPath.toString ()
|
||||
: disk.getFile ().getAbsolutePath ();
|
||||
if (path.startsWith (home))
|
||||
return "~" + path.substring (home.length ());
|
||||
String path =
|
||||
originalPath != null ? originalPath.toString () : disk.getFile ().getAbsolutePath ();
|
||||
|
||||
int pos = path.indexOf (home);
|
||||
|
||||
if (pos == 0 || (path.startsWith ("/Volumes/") && pos > 0))
|
||||
return "~" + path.substring (home.length () + pos);
|
||||
|
||||
return disk.getFile ().getAbsolutePath ();
|
||||
}
|
||||
|
@ -327,8 +326,7 @@ public abstract class AbstractFormattedDisk implements FormattedDisk
|
|||
if (children != null)
|
||||
while (children.hasMoreElements ())
|
||||
{
|
||||
DefaultMutableTreeNode childNode =
|
||||
(DefaultMutableTreeNode) children.nextElement ();
|
||||
DefaultMutableTreeNode childNode = (DefaultMutableTreeNode) children.nextElement ();
|
||||
if (childNode.getUserObject ().toString ().indexOf (name) > 0)
|
||||
return childNode;
|
||||
}
|
||||
|
|
|
@ -733,12 +733,8 @@ public class AppleDisk implements Disk
|
|||
{
|
||||
StringBuilder text = new StringBuilder ();
|
||||
|
||||
String path = file.getAbsolutePath ();
|
||||
String home = System.getProperty ("user.home");
|
||||
if (path.startsWith (home))
|
||||
path = "~" + path.substring (home.length ());
|
||||
|
||||
text.append (String.format ("Path ......... %s%n", path));
|
||||
text.append (
|
||||
String.format ("Path ......... %s%n", Utility.getShortPath (file.getAbsolutePath ())));
|
||||
text.append (String.format ("File name .... %s%n", file.getName ()));
|
||||
text.append (String.format ("File size .... %,d%n", file.length ()));
|
||||
text.append (String.format ("Tracks ....... %d%n", tracks));
|
||||
|
|
|
@ -148,7 +148,7 @@ public class DiskFactory
|
|||
|
||||
if ("sdk".equals (suffix) // NuFX disk
|
||||
|| "shk".equals (suffix) // NuFX files or disk
|
||||
|| "bxy".equals (suffix)) // NuFX in Binary2
|
||||
|| "bxy".equals (suffix)) // NuFX in Bin2
|
||||
{
|
||||
if (debug)
|
||||
System.out.println (" ** sdk/shk/bxy **");
|
||||
|
@ -156,7 +156,11 @@ public class DiskFactory
|
|||
{
|
||||
nuFX = new NuFX (file.toPath ());
|
||||
if (nuFX.getTotalDisks () == 0 && nuFX.getTotalFiles () == 0)
|
||||
{
|
||||
if (debug)
|
||||
System.out.println ("Empty NuFX file");
|
||||
return null;
|
||||
}
|
||||
|
||||
byte[] diskBuffer = nuFX.getDiskBuffer ();
|
||||
if (diskBuffer == null)
|
||||
|
@ -173,7 +177,7 @@ public class DiskFactory
|
|||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
// e.printStackTrace ();
|
||||
// e.printStackTrace ();
|
||||
if (e.getMessage () == null)
|
||||
System.out.println (e);
|
||||
else
|
||||
|
@ -183,10 +187,10 @@ public class DiskFactory
|
|||
return null;
|
||||
}
|
||||
}
|
||||
else if ("bny".equals (suffix)) // Binary2 uncompressed files
|
||||
else if ("bny".equals (suffix) || "bqy".equals (suffix)) // Binary2 uncompressed files
|
||||
{
|
||||
if (debug)
|
||||
System.out.println (" ** bny **");
|
||||
System.out.println (" ** bny/bqy **");
|
||||
try
|
||||
{
|
||||
binary2 = new Binary2 (file.toPath ());
|
||||
|
@ -414,7 +418,8 @@ public class DiskFactory
|
|||
|
||||
if (length != DISK_143K) // 16 sector floppy disk
|
||||
{
|
||||
System.out.printf ("%s: invalid file length : %,d%n", file.getName (), file.length ());
|
||||
System.out.printf ("%s: invalid file length : %,d%n", file.getName (),
|
||||
file.length ());
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -574,8 +579,8 @@ public class DiskFactory
|
|||
disk = new DataDisk (appleDisk256);
|
||||
|
||||
if (debug)
|
||||
System.out
|
||||
.println ("Factory creating disk : " + disk.getDisk ().getFile ().getAbsolutePath ());
|
||||
System.out.println (
|
||||
"Factory creating disk : " + disk.getDisk ().getFile ().getAbsolutePath ());
|
||||
|
||||
if (disk != null && compressed)
|
||||
disk.setOriginalPath (originalPath);
|
||||
|
|
|
@ -51,6 +51,9 @@ public class Prefix2mg
|
|||
if (format == 0 && flagsVolume == 0)
|
||||
flagsVolume = 254;
|
||||
|
||||
if (length == 0)
|
||||
length = 512 * blocks;
|
||||
|
||||
// see /Asimov disks/images/gs/os/prodos16/ProDOS 16v1_3.2mg
|
||||
// System.out.println (this);
|
||||
}
|
||||
|
|
|
@ -89,8 +89,8 @@ abstract class AbstractCatalogEntry implements AppleFileSource
|
|||
lastModified = Utility.getDateTime (entryBuffer, 0x1B);
|
||||
|
||||
// CATALOG command only formats the LO byte - see Beneath Apple DOS pp4-6
|
||||
String base = String.format ("%s%s %03d ", locked ? "*" : " ", getFileType (),
|
||||
reportedSize & 0xFF);
|
||||
String base =
|
||||
String.format ("%s%s %03d ", locked ? "*" : " ", getFileType (), reportedSize & 0xFF);
|
||||
catalogName = getName (base, entryBuffer);
|
||||
displayName = getDisplayName (entryBuffer);
|
||||
}
|
||||
|
@ -235,18 +235,28 @@ abstract class AbstractCatalogEntry implements AppleFileSource
|
|||
|
||||
case IntegerBasic:
|
||||
reportedLength = Utility.getShort (buffer, 0);
|
||||
exactBuffer = new byte[reportedLength];
|
||||
System.arraycopy (buffer, 2, exactBuffer, 0, reportedLength);
|
||||
appleFile = new IntegerBasicProgram (name, exactBuffer);
|
||||
if (reportedLength > 0)
|
||||
{
|
||||
exactBuffer = new byte[reportedLength];
|
||||
System.arraycopy (buffer, 2, exactBuffer, 0, reportedLength);
|
||||
appleFile = new IntegerBasicProgram (name, exactBuffer);
|
||||
}
|
||||
else
|
||||
appleFile = new DefaultAppleFile (name, buffer);
|
||||
break;
|
||||
|
||||
case ApplesoftBasic:
|
||||
reportedLength = Utility.getShort (buffer, 0);
|
||||
exactBuffer = new byte[reportedLength];
|
||||
if (reportedLength > buffer.length)
|
||||
reportedLength = buffer.length - 2;
|
||||
System.arraycopy (buffer, 2, exactBuffer, 0, reportedLength);
|
||||
appleFile = new ApplesoftBasicProgram (name, exactBuffer);
|
||||
if (reportedLength > 0)
|
||||
{
|
||||
exactBuffer = new byte[reportedLength];
|
||||
if (reportedLength > buffer.length)
|
||||
reportedLength = buffer.length - 2;
|
||||
System.arraycopy (buffer, 2, exactBuffer, 0, reportedLength);
|
||||
appleFile = new ApplesoftBasicProgram (name, exactBuffer);
|
||||
}
|
||||
else
|
||||
appleFile = new DefaultAppleFile (name, buffer);
|
||||
break;
|
||||
|
||||
case Binary: // binary file
|
||||
|
@ -256,8 +266,8 @@ abstract class AbstractCatalogEntry implements AppleFileSource
|
|||
reportedLength = Utility.getShort (buffer, 2);
|
||||
if (reportedLength == 0)
|
||||
{
|
||||
System.out.println (name.trim () + " reported length : 0 - reverting to "
|
||||
+ (buffer.length - 4));
|
||||
System.out.println (
|
||||
name.trim () + " reported length : 0 - reverting to " + (buffer.length - 4));
|
||||
reportedLength = buffer.length - 4;
|
||||
}
|
||||
|
||||
|
@ -268,9 +278,8 @@ abstract class AbstractCatalogEntry implements AppleFileSource
|
|||
exactBuffer = new byte[buffer.length - 4]; // reported length is too long
|
||||
System.arraycopy (buffer, 4, exactBuffer, 0, exactBuffer.length);
|
||||
|
||||
if ((name.endsWith (".FONT") || name.endsWith (" FONT")
|
||||
|| name.endsWith (".SET") || name.startsWith ("ASCII."))
|
||||
&& FontFile.isFont (exactBuffer))
|
||||
if ((name.endsWith (".FONT") || name.endsWith (" FONT") || name.endsWith (".SET")
|
||||
|| name.startsWith ("ASCII.")) && FontFile.isFont (exactBuffer))
|
||||
appleFile = new FontFile (name, exactBuffer, loadAddress);
|
||||
else if (name.endsWith (".MW"))
|
||||
appleFile = new MagicWindowText (name, exactBuffer);
|
||||
|
@ -305,8 +314,7 @@ abstract class AbstractCatalogEntry implements AppleFileSource
|
|||
appleFile = new AssemblerProgram (name, exactBuffer, loadAddress);
|
||||
}
|
||||
else if (reportedLength == 0x240 //
|
||||
&& (loadAddress == 0x5800 || loadAddress == 0x6000
|
||||
|| loadAddress == 0x7800))
|
||||
&& (loadAddress == 0x5800 || loadAddress == 0x6000 || loadAddress == 0x7800))
|
||||
appleFile = new PrintShopGraphic (name, exactBuffer);
|
||||
else if (isRunCommand (exactBuffer))
|
||||
{
|
||||
|
@ -319,8 +327,8 @@ abstract class AbstractCatalogEntry implements AppleFileSource
|
|||
{
|
||||
appleFile = new AssemblerProgram (name, exactBuffer, loadAddress);
|
||||
if ((exactBuffer.length + 4) < buffer.length)
|
||||
((AssemblerProgram) appleFile).setExtraBuffer (buffer,
|
||||
exactBuffer.length + 4, buffer.length - (exactBuffer.length + 4));
|
||||
((AssemblerProgram) appleFile).setExtraBuffer (buffer, exactBuffer.length + 4,
|
||||
buffer.length - (exactBuffer.length + 4));
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -362,8 +370,8 @@ abstract class AbstractCatalogEntry implements AppleFileSource
|
|||
int reportedLength = Utility.getShort (buffer, 2);
|
||||
if (reportedLength == 0)
|
||||
{
|
||||
System.out.println (
|
||||
name.trim () + " reported length : 0 - reverting to " + (buffer.length - 4));
|
||||
System.out
|
||||
.println (name.trim () + " reported length : 0 - reverting to " + (buffer.length - 4));
|
||||
reportedLength = buffer.length - 4;
|
||||
}
|
||||
|
||||
|
|
|
@ -326,6 +326,8 @@ public class DosDisk extends AbstractFormattedDisk
|
|||
return "4.2";
|
||||
case 0x43:
|
||||
return "4.3";
|
||||
case 0x45:
|
||||
return "4.5";
|
||||
default:
|
||||
return "??";
|
||||
}
|
||||
|
@ -376,7 +378,7 @@ public class DosDisk extends AbstractFormattedDisk
|
|||
int version = buffer[3] & 0xFF;
|
||||
if (debug)
|
||||
System.out.printf ("Version: %02X%n", buffer[3]);
|
||||
if (version == 0 || (version > 0x43 && version != 0xFF))
|
||||
if (version == 0 || (version > 0x45 && version != 0xFF))
|
||||
{
|
||||
if (debug)
|
||||
System.out.printf ("Bad version : %02X%n", version);
|
||||
|
|
|
@ -15,27 +15,21 @@ import com.bytezone.diskbrowser.utilities.DefaultAction;
|
|||
public abstract class AbstractSaveAction extends DefaultAction
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
private JFileChooser fileChooser;
|
||||
private String dialogTitle;
|
||||
protected JFileChooser fileChooser = new JFileChooser ();
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public AbstractSaveAction (String menuText, String tip, String dialogTitle)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
super (menuText, tip);
|
||||
this.dialogTitle = dialogTitle;
|
||||
|
||||
fileChooser.setDialogTitle (dialogTitle);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
void setSelectedFile (File file)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
if (fileChooser == null)
|
||||
{
|
||||
fileChooser = new JFileChooser ();
|
||||
fileChooser.setDialogTitle (dialogTitle);
|
||||
}
|
||||
|
||||
fileChooser.setSelectedFile (file);
|
||||
}
|
||||
|
||||
|
@ -43,26 +37,22 @@ public abstract class AbstractSaveAction extends DefaultAction
|
|||
void saveBuffer (byte[] buffer)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
if (fileChooser.showSaveDialog (null) != JFileChooser.APPROVE_OPTION)
|
||||
return;
|
||||
|
||||
File file = fileChooser.getSelectedFile ();
|
||||
try
|
||||
{
|
||||
Files.write (file.toPath (), buffer, StandardOpenOption.CREATE_NEW);
|
||||
JOptionPane.showMessageDialog (null,
|
||||
String.format ("File %s saved", file.getName ()));
|
||||
JOptionPane.showMessageDialog (null, String.format ("File %s saved", file.getName ()));
|
||||
}
|
||||
catch (FileAlreadyExistsException e)
|
||||
{
|
||||
JOptionPane.showMessageDialog (null, "File " + file.getName () + " already exists",
|
||||
"Failed", JOptionPane.ERROR_MESSAGE);
|
||||
JOptionPane.showMessageDialog (null, "File " + file.getName () + " already exists", "Failed",
|
||||
JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace ();
|
||||
JOptionPane.showMessageDialog (null, "File failed to save - " + e.getMessage (),
|
||||
"Failed", JOptionPane.ERROR_MESSAGE);
|
||||
JOptionPane.showMessageDialog (null, "File failed to save - " + e.getMessage (), "Failed",
|
||||
JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,6 +36,7 @@ public class FontAction extends DefaultAction implements QuitListener
|
|||
{
|
||||
super ("Set Font...", "Set display to a different font or font size",
|
||||
"/com/bytezone/loadlister/");
|
||||
|
||||
int mask = Toolkit.getDefaultToolkit ().getMenuShortcutKeyMaskEx ();
|
||||
putValue (Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke (KeyEvent.VK_F, mask));
|
||||
}
|
||||
|
@ -146,8 +147,7 @@ public class FontAction extends DefaultAction implements QuitListener
|
|||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
FontChangeEvent fontChangeEvent = new FontChangeEvent (font);
|
||||
FontChangeListener[] listeners =
|
||||
(listenerList.getListeners (FontChangeListener.class));
|
||||
FontChangeListener[] listeners = (listenerList.getListeners (FontChangeListener.class));
|
||||
for (FontChangeListener listener : listeners)
|
||||
listener.changeFont (fontChangeEvent);
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.bytezone.diskbrowser.gui;
|
|||
import java.awt.event.ActionEvent;
|
||||
import java.io.File;
|
||||
|
||||
import javax.swing.JFileChooser;
|
||||
import javax.swing.JOptionPane;
|
||||
|
||||
import com.bytezone.diskbrowser.disk.AppleDisk;
|
||||
|
@ -40,7 +41,9 @@ class SaveDiskAction extends AbstractSaveAction implements DiskSelectionListener
|
|||
String suffix = blocks <= 560 ? ".dsk" : ".hdv";
|
||||
|
||||
setSelectedFile (new File (formattedDisk.getName () + suffix));
|
||||
saveBuffer (appleDisk.getBuffer ());
|
||||
|
||||
if (fileChooser.showSaveDialog (null) == JFileChooser.APPROVE_OPTION)
|
||||
saveBuffer (appleDisk.getBuffer ());
|
||||
}
|
||||
else
|
||||
System.out.println ("Not an AppleDisk"); // impossible
|
||||
|
|
|
@ -1,9 +1,15 @@
|
|||
package com.bytezone.diskbrowser.gui;
|
||||
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.io.File;
|
||||
|
||||
import javax.swing.Action;
|
||||
import javax.swing.JCheckBox;
|
||||
import javax.swing.JFileChooser;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.KeyStroke;
|
||||
|
||||
import com.bytezone.diskbrowser.applefile.AppleFileSource;
|
||||
|
||||
|
@ -12,12 +18,17 @@ class SaveFileAction extends AbstractSaveAction implements FileSelectionListener
|
|||
//-----------------------------------------------------------------------------------//
|
||||
{
|
||||
AppleFileSource appleFileSource;
|
||||
private JCheckBox formatted = new JCheckBox ("Formatted");
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
SaveFileAction ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
super ("Save file...", "Save currently selected file", "Save File");
|
||||
|
||||
fileChooser.setAccessory (formatted);
|
||||
int mask = Toolkit.getDefaultToolkit ().getMenuShortcutKeyMaskEx ();
|
||||
putValue (Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke (KeyEvent.VK_S, mask));
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
|
@ -31,8 +42,18 @@ class SaveFileAction extends AbstractSaveAction implements FileSelectionListener
|
|||
return;
|
||||
}
|
||||
|
||||
setSelectedFile (new File (appleFileSource.getUniqueName () + ".bin"));
|
||||
saveBuffer (appleFileSource.getDataSource ().getBuffer ());
|
||||
if (formatted.isSelected ())
|
||||
setSelectedFile (new File (appleFileSource.getUniqueName () + ".txt"));
|
||||
else
|
||||
setSelectedFile (new File (appleFileSource.getUniqueName () + ".bin"));
|
||||
|
||||
if (fileChooser.showSaveDialog (null) != JFileChooser.APPROVE_OPTION)
|
||||
return;
|
||||
|
||||
if (formatted.isSelected ())
|
||||
saveBuffer (appleFileSource.getDataSource ().getText ().getBytes ());
|
||||
else
|
||||
saveBuffer (appleFileSource.getDataSource ().getBuffer ());
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
|
@ -41,8 +62,8 @@ class SaveFileAction extends AbstractSaveAction implements FileSelectionListener
|
|||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
this.appleFileSource = event.appleFileSource;
|
||||
setEnabled (
|
||||
event.appleFileSource != null && event.appleFileSource.getDataSource () != null
|
||||
&& event.appleFileSource.getDataSource ().getBuffer () != null);
|
||||
|
||||
setEnabled (appleFileSource != null && appleFileSource.getDataSource () != null
|
||||
&& appleFileSource.getDataSource ().getBuffer () != null);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import java.awt.event.ActionEvent;
|
|||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.JFileChooser;
|
||||
import javax.swing.JOptionPane;
|
||||
|
||||
import com.bytezone.diskbrowser.disk.Disk;
|
||||
|
@ -41,7 +42,9 @@ class SaveSectorsAction extends AbstractSaveAction implements SectorSelectionLis
|
|||
blocks.size () == 1 ? disk.readBlock (blocks.get (0)) : disk.readBlocks (blocks);
|
||||
|
||||
setSelectedFile (new File ("SavedSectors.bin"));
|
||||
saveBuffer (buffer);
|
||||
|
||||
if (fileChooser.showSaveDialog (null) == JFileChooser.APPROVE_OPTION)
|
||||
saveBuffer (buffer);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
|
|
|
@ -10,6 +10,7 @@ import com.bytezone.diskbrowser.prodos.write.DiskFullException;
|
|||
import com.bytezone.diskbrowser.prodos.write.FileAlreadyExistsException;
|
||||
import com.bytezone.diskbrowser.prodos.write.ProdosDisk;
|
||||
import com.bytezone.diskbrowser.prodos.write.VolumeCatalogFullException;
|
||||
import com.bytezone.diskbrowser.utilities.Utility;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
public class Binary2
|
||||
|
@ -19,11 +20,11 @@ public class Binary2
|
|||
"------------------------------------------------------"
|
||||
+ "-----------------------";
|
||||
|
||||
Binary2Header binary2Header;
|
||||
byte[] buffer;
|
||||
List<Binary2Header> headers = new ArrayList<> ();
|
||||
int totalBlocks;
|
||||
String fileName;
|
||||
private Binary2Header binary2Header;
|
||||
private byte[] buffer;
|
||||
private List<Binary2Header> headers = new ArrayList<> ();
|
||||
private int totalBlocks;
|
||||
private String fileName;
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public Binary2 (Path path) throws IOException
|
||||
|
@ -43,13 +44,14 @@ public class Binary2
|
|||
do
|
||||
{
|
||||
binary2Header = new Binary2Header (buffer, ptr);
|
||||
System.out.println (binary2Header);
|
||||
headers.add (binary2Header);
|
||||
|
||||
ptr += ((binary2Header.eof - 1) / 128 + 2) * 128;
|
||||
if (ptr > buffer.length) // not enough blocks for this file
|
||||
break;
|
||||
|
||||
totalBlocks += binary2Header.totalBlocks;
|
||||
ptr += ((binary2Header.eof - 1) / 128 + 1) * 128 + 128;
|
||||
headers.add (binary2Header);
|
||||
} while (binary2Header.filesToFollow > 0);
|
||||
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
|
@ -64,9 +66,19 @@ public class Binary2
|
|||
byte[] dataBuffer = new byte[header.eof]; // this sux
|
||||
System.arraycopy (buffer, header.ptr + 128, dataBuffer, 0, dataBuffer.length);
|
||||
|
||||
disk.addFile (header.fileName, header.fileType, header.auxType, header.created,
|
||||
header.modified, dataBuffer, header.eof);
|
||||
if (header.compressed && dataBuffer[0] == 0x76 && dataBuffer[1] == (byte) 0xFF)
|
||||
{
|
||||
String name = Utility.getCString (dataBuffer, 4);
|
||||
|
||||
Squeeze squeeze = new Squeeze ();
|
||||
byte[] tmp = squeeze.unSqueeze (dataBuffer);
|
||||
|
||||
disk.addFile (name, header.fileType, header.auxType, header.created,
|
||||
header.modified, tmp, tmp.length);
|
||||
}
|
||||
else
|
||||
disk.addFile (header.fileName, header.fileType, header.auxType, header.created,
|
||||
header.modified, dataBuffer, header.eof);
|
||||
}
|
||||
disk.close ();
|
||||
|
||||
|
|
|
@ -14,10 +14,9 @@ public class Binary2Header
|
|||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
static DateTimeFormatter formatter = DateTimeFormatter.ofPattern ("dd-LLL-yy HH:mm");
|
||||
static String[] osTypes =
|
||||
{ "Prodos", "DOS 3.3", "Reserved", "DOS 3.2 or 3.1", "Pascal", "Macintosh MFS",
|
||||
"Macintosh HFS", "Lisa", "CPM", "Reserved", "MS-DOS", "High Sierra (CD-ROM)",
|
||||
"ISO 9660 (CD-ROM)", "AppleShare" };
|
||||
static String[] osTypes = { "Prodos", "DOS 3.3", "Reserved", "DOS 3.2 or 3.1", "Pascal",
|
||||
"Macintosh MFS", "Macintosh HFS", "Lisa", "CPM", "Reserved", "MS-DOS", "High Sierra (CD-ROM)",
|
||||
"ISO 9660 (CD-ROM)", "AppleShare" };
|
||||
|
||||
int ptr;
|
||||
byte[] buffer;
|
||||
|
@ -89,8 +88,8 @@ public class Binary2Header
|
|||
public String getLine ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
return String.format (" %-33s %3s $%04X %s unc %7d", fileName,
|
||||
fileTypes[fileType], auxType, modified.format (formatter), eof);
|
||||
return String.format (" %-33s %3s $%04X %s unc %7d", fileName, fileTypes[fileType],
|
||||
auxType, modified.format (formatter), eof);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
|
@ -117,12 +116,13 @@ public class Binary2Header
|
|||
text.append (String.format ("Prodos storage type ... %02X%n", prodos16storageType));
|
||||
text.append (String.format ("Prodos total blocks ... %02X%n", prodos16totalBlocks));
|
||||
text.append (String.format ("Prodos eof ............ %06X %<,d%n", prodos16eof));
|
||||
text.append (
|
||||
String.format ("Disk space needed ..... %08X %<,d%n", diskSpaceRequired));
|
||||
text.append (
|
||||
String.format ("OS type ............... %02X %s%n", osType, osTypes[osType]));
|
||||
text.append (String.format ("Disk space needed ..... %08X %<,d%n", diskSpaceRequired));
|
||||
text.append (String.format ("OS type ............... %02X %s%n", osType, osTypes[osType]));
|
||||
text.append (String.format ("Native file type ...... %02X%n", nativeFileType));
|
||||
text.append (String.format ("Data flags ............ %02X%n", dataFlags));
|
||||
text.append (String.format (" compressed .......... %s%n", compressed));
|
||||
text.append (String.format (" encrypted ........... %s%n", encrypted));
|
||||
text.append (String.format (" sparse .............. %s%n", sparsePacked));
|
||||
text.append (String.format ("Version ............... %02X%n", version));
|
||||
text.append (String.format ("Following files ....... %02X%n", filesToFollow));
|
||||
|
||||
|
|
|
@ -9,8 +9,7 @@ import com.bytezone.diskbrowser.utilities.Utility;
|
|||
public class MasterHeader
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
private static final byte[] NuFile =
|
||||
{ 0x4E, (byte) 0xF5, 0x46, (byte) 0xE9, 0x6C, (byte) 0xE5 };
|
||||
private static final byte[] NuFile = { 0x4E, (byte) 0xF5, 0x46, (byte) 0xE9, 0x6C, (byte) 0xE5 };
|
||||
private static final byte[] BIN2 = { 0x0A, 0x47, 0x4C };
|
||||
|
||||
private final int crc;
|
||||
|
@ -35,15 +34,6 @@ public class MasterHeader
|
|||
if (Utility.isMagic (buffer, ptr, NuFile))
|
||||
break;
|
||||
|
||||
// internet.shk has 0x2000 bytes of text at the start
|
||||
// if (Utility.isMagic (buffer, 0x2000, NuFile))
|
||||
// {
|
||||
// System.out.println ("found it");
|
||||
// ptr = 0x2000;
|
||||
// bin2 = true;
|
||||
// break;
|
||||
// }
|
||||
|
||||
if (isBin2 (buffer, ptr))
|
||||
{
|
||||
binary2Header = new Binary2Header (buffer, 0);
|
||||
|
|
|
@ -40,6 +40,7 @@ public class NuFX
|
|||
{
|
||||
buffer = Files.readAllBytes (path);
|
||||
volumeName = new VolumeName (path.getFileName ().toString ());
|
||||
|
||||
read (buffer);
|
||||
}
|
||||
|
||||
|
@ -95,6 +96,7 @@ public class NuFX
|
|||
if (record.hasDisk ())
|
||||
++totalDisks;
|
||||
}
|
||||
// System.out.println (toString ());
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
|
|
|
@ -15,13 +15,12 @@ class Record
|
|||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
private static final byte[] NuFX = { 0x4E, (byte) 0xF5, 0x46, (byte) 0xD8 };
|
||||
private static String[] fileSystems =
|
||||
{ "", "ProDOS/SOS", "DOS 3.3", "DOS 3.2", "Apple II Pascal", "Macintosh HFS",
|
||||
"Macintosh MFS", "Lisa File System", "Apple CP/M", "", "MS-DOS", "High Sierra",
|
||||
"ISO 9660", "AppleShare" };
|
||||
private static String[] fileSystems = { "", "ProDOS/SOS", "DOS 3.3", "DOS 3.2",
|
||||
"Apple II Pascal", "Macintosh HFS", "Macintosh MFS", "Lisa File System",
|
||||
"Apple CP/M", "", "MS-DOS", "High Sierra", "ISO 9660", "AppleShare" };
|
||||
|
||||
private static String[] storage = { "", "Seedling", "Sapling", "Tree", "", "Extended",
|
||||
"", "", "", "", "", "", "", "Subdirectory" };
|
||||
"", "", "", "", "", "", "", "Subdirectory" };
|
||||
|
||||
private static String[] accessChars = { "D", "R", "B", "", "", "I", "W", "R" };
|
||||
private static String threadFormats[] = { "unc", "sq ", "lz1", "lz2", "", "" };
|
||||
|
@ -254,6 +253,13 @@ class Record
|
|||
return 0;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
String getThreadFormatText ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
return threadFormats[getThreadFormat ()];
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
int getUncompressedSize ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
|
@ -283,6 +289,17 @@ class Record
|
|||
return size;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public float getCompressedPct ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
float pct = 100;
|
||||
if (getUncompressedSize () > 0)
|
||||
pct = getCompressedSize () * 100 / getUncompressedSize ();
|
||||
|
||||
return pct;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
byte[] getData ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
|
@ -313,9 +330,9 @@ class Record
|
|||
if (name.length () > 27)
|
||||
name = ".." + name.substring (name.length () - 25);
|
||||
|
||||
float pct = 100;
|
||||
if (getUncompressedSize () > 0)
|
||||
pct = getCompressedSize () * 100 / getUncompressedSize ();
|
||||
// float pct = 100;
|
||||
// if (getUncompressedSize () > 0)
|
||||
// pct = getCompressedSize () * 100 / getUncompressedSize ();
|
||||
|
||||
String lockedFlag = (access | 0xC3) == 1 ? "+" : " ";
|
||||
String forkedFlag = hasResource () ? "+" : " ";
|
||||
|
@ -323,11 +340,11 @@ class Record
|
|||
if (hasDisk ())
|
||||
return String.format ("%s%-27.27s %-4s %-6s %-15s %s %3.0f%% %7d", lockedFlag,
|
||||
name, "Disk", (getUncompressedSize () / 1024) + "k", archived.format2 (),
|
||||
threadFormats[getThreadFormat ()], pct, getUncompressedSize ());
|
||||
getThreadFormatText (), getCompressedPct (), getUncompressedSize ());
|
||||
|
||||
return String.format ("%s%-27.27s %s%s $%04X %-15s %s %3.0f%% %7d", lockedFlag,
|
||||
name, fileTypes[fileType], forkedFlag, auxType, archived.format2 (),
|
||||
threadFormats[getThreadFormat ()], pct, getUncompressedSize ());
|
||||
getThreadFormatText (), getCompressedPct (), getUncompressedSize ());
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
|
|
|
@ -0,0 +1,125 @@
|
|||
package com.bytezone.diskbrowser.nufx;
|
||||
|
||||
import com.bytezone.diskbrowser.utilities.FileFormatException;
|
||||
import com.bytezone.diskbrowser.utilities.Utility;
|
||||
|
||||
// see http://fileformats.archiveteam.org/wiki/Squeeze
|
||||
// see http://fileformats.archiveteam.org/wiki/RLE90
|
||||
// -----------------------------------------------------------------------------------//
|
||||
public class Squeeze
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
private static final byte[] Squeeze = { 0x76, (byte) 0xFF };
|
||||
private static int RLE_DELIMITER = 0x90;
|
||||
private static int EOF_TOKEN = 0x100;
|
||||
|
||||
private int bits;
|
||||
private int bitPos = 7; // trigger the first read
|
||||
private int ptr;
|
||||
private byte[] buffer;
|
||||
private Node[] nodes;
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public byte[] unSqueeze (byte[] buffer)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
if (!Utility.isMagic (buffer, 0, Squeeze))
|
||||
throw new FileFormatException ("Not Squeeze format");
|
||||
|
||||
byte[] uncompressed = new byte[buffer.length * 3];
|
||||
int uncPtr = 0;
|
||||
|
||||
int fileChecksum = Utility.getShort (buffer, 2);
|
||||
String fileName = Utility.getCString (buffer, 4);
|
||||
|
||||
ptr = fileName.length () + 5;
|
||||
int nodeCount = Utility.getShort (buffer, ptr);
|
||||
ptr += 2;
|
||||
|
||||
nodes = new Node[nodeCount];
|
||||
this.buffer = buffer;
|
||||
|
||||
for (int i = 0; i < nodes.length; i++)
|
||||
{
|
||||
int left = Utility.getSignedShort (buffer, ptr);
|
||||
int right = Utility.getSignedShort (buffer, ptr + 2);
|
||||
nodes[i] = new Node (left, right);
|
||||
ptr += 4;
|
||||
}
|
||||
|
||||
boolean repeating = false;
|
||||
int lastVal = 0;
|
||||
int sum = 0;
|
||||
|
||||
while (true)
|
||||
{
|
||||
int val = decodeSymbol ();
|
||||
if (val == EOF_TOKEN)
|
||||
break;
|
||||
|
||||
if (repeating)
|
||||
{
|
||||
repeating = false;
|
||||
|
||||
if (val == 0) // flag indicating a single RLE_DELIMITER
|
||||
{
|
||||
lastVal = RLE_DELIMITER;
|
||||
val = 2;
|
||||
}
|
||||
|
||||
while (--val != 0)
|
||||
{
|
||||
sum += lastVal;
|
||||
uncompressed[uncPtr++] = (byte) lastVal;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (val == RLE_DELIMITER)
|
||||
repeating = true;
|
||||
else
|
||||
{
|
||||
lastVal = val;
|
||||
sum += lastVal;
|
||||
uncompressed[uncPtr++] = (byte) lastVal;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((sum & 0xFFFF) != fileChecksum)
|
||||
System.out.printf ("Checksum mismatch : %04X %04X%n", fileChecksum, sum & 0xFFFF);
|
||||
|
||||
byte[] uncompressedBuffer = new byte[uncPtr];
|
||||
System.arraycopy (uncompressed, 0, uncompressedBuffer, 0, uncompressedBuffer.length);
|
||||
|
||||
return uncompressedBuffer;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
private int decodeSymbol ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
int val = 0;
|
||||
|
||||
while (true)
|
||||
{
|
||||
if (++bitPos > 7)
|
||||
{
|
||||
bits = buffer[ptr++];
|
||||
bitPos = 0;
|
||||
}
|
||||
|
||||
val = (bits & 1) == 0 ? nodes[val].left : nodes[val].right;
|
||||
bits >>>= 1;
|
||||
|
||||
if (val < 0)
|
||||
return -++val; // increment and make positive
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
record Node (int left, int right)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
};
|
||||
}
|
|
@ -28,4 +28,6 @@ Compress . . . . . . . . . . . | .Z | U | Unix Systems
|
|||
|
||||
|
||||
see also:
|
||||
http://fileformats.archiveteam.org/wiki/Squeeze
|
||||
http://fileformats.archiveteam.org/wiki/Squeeze
|
||||
http://fileformats.archiveteam.org/wiki/LBR
|
||||
http://www.seasip.info/Cpm/ludef5.html
|
|
@ -1,7 +1,6 @@
|
|||
package com.bytezone.diskbrowser.pascal;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.text.DateFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.format.FormatStyle;
|
||||
|
@ -30,8 +29,8 @@ public class PascalDisk extends AbstractFormattedDisk
|
|||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
static final int CATALOG_ENTRY_SIZE = 26;
|
||||
private final DateFormat df = DateFormat.getDateInstance (DateFormat.SHORT);
|
||||
private final DateTimeFormatter dtf = DateTimeFormatter.ofLocalizedDate (FormatStyle.SHORT);
|
||||
private final DateTimeFormatter dtf =
|
||||
DateTimeFormatter.ofLocalizedDate (FormatStyle.SHORT);
|
||||
private final VolumeEntry volumeEntry;
|
||||
private final PascalCatalogSector diskCatalogSector;
|
||||
|
||||
|
@ -50,8 +49,8 @@ public class PascalDisk extends AbstractFormattedDisk
|
|||
SectorType fotoSector = new SectorType ("Foto", Color.gray);
|
||||
SectorType badSector = new SectorType ("Bad", Color.darkGray);
|
||||
|
||||
SectorType[] sectors = { catalogSector, badSector, codeSector, textSector, infoSector, dataSector,
|
||||
grafSector, fotoSector };
|
||||
SectorType[] sectors = { catalogSector, badSector, codeSector, textSector, infoSector,
|
||||
dataSector, grafSector, fotoSector };
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public PascalDisk (Disk disk)
|
||||
|
@ -102,7 +101,8 @@ public class PascalDisk extends AbstractFormattedDisk
|
|||
freeBlocks.set (i, false);
|
||||
}
|
||||
|
||||
diskCatalogSector = new PascalCatalogSector (disk, disk.readBlocks (sectors), sectors);
|
||||
diskCatalogSector =
|
||||
new PascalCatalogSector (disk, disk.readBlocks (sectors), sectors);
|
||||
|
||||
// read the catalog
|
||||
List<DiskAddress> addresses = new ArrayList<> ();
|
||||
|
@ -235,7 +235,6 @@ public class PascalDisk extends AbstractFormattedDisk
|
|||
}
|
||||
|
||||
int lastByte = Utility.getShort (buffer, ptr + 22);
|
||||
// GregorianCalendar date = Utility.getPascalDate (buffer, 24);
|
||||
LocalDate localDate = Utility.getPascalLocalDate (buffer, 24);
|
||||
String dateString = localDate == null ? ""
|
||||
: localDate.format (DateTimeFormatter.ofLocalizedDate (FormatStyle.SHORT));
|
||||
|
@ -300,16 +299,18 @@ public class PascalDisk extends AbstractFormattedDisk
|
|||
{
|
||||
String newLine = String.format ("%n");
|
||||
String newLine2 = newLine + newLine;
|
||||
String line =
|
||||
"---- --------------- ---- -------- ------- ---- ---- ----" + newLine;
|
||||
String line = "---- --------------- ---- -------- ------- ---- ---- ----"
|
||||
+ newLine;
|
||||
|
||||
String date = volumeEntry.localDate == null ? "--" : volumeEntry.localDate.format (dtf);
|
||||
String date =
|
||||
volumeEntry.localDate == null ? "--" : volumeEntry.localDate.format (dtf);
|
||||
|
||||
StringBuilder text = new StringBuilder ();
|
||||
text.append ("File : " + getDisplayPath () + newLine2);
|
||||
text.append ("Volume : " + volumeEntry.name + newLine);
|
||||
text.append ("Date : " + date + newLine2);
|
||||
text.append ("Blks Name Type Date Length Frst Last Blks\n");
|
||||
text.append (
|
||||
"Blks Name Type Date Length Frst Last Blks\n");
|
||||
text.append (line);
|
||||
|
||||
int usedBlocks = 6;
|
||||
|
@ -322,15 +323,16 @@ public class PascalDisk extends AbstractFormattedDisk
|
|||
date = ce.localDate == null ? "--" : ce.localDate.format (dtf);
|
||||
|
||||
int bytes = (size - 1) * 512 + ce.bytesUsedInLastBlock;
|
||||
String fileType =
|
||||
ce.fileType < 0 || ce.fileType >= fileTypes.length ? "????" : fileTypes[ce.fileType];
|
||||
text.append (String.format ("%4d %-15s %-6s %8s %,8d $%03X $%03X $%03X%n", size,
|
||||
ce.name, fileType, date, bytes, ce.firstBlock, ce.lastBlock, size));
|
||||
String fileType = ce.fileType < 0 || ce.fileType >= fileTypes.length ? "????"
|
||||
: fileTypes[ce.fileType];
|
||||
text.append (String.format ("%4d %-15s %-6s %8s %,8d $%03X $%03X $%03X%n",
|
||||
size, ce.name, fileType, date, bytes, ce.firstBlock, ce.lastBlock, size));
|
||||
}
|
||||
|
||||
text.append (line);
|
||||
text.append (String.format ("Blocks free : %3d Blocks used : %3d Total blocks : %3d%n",
|
||||
(volumeEntry.totalBlocks - usedBlocks), usedBlocks, volumeEntry.totalBlocks));
|
||||
text.append (
|
||||
String.format ("Blocks free : %3d Blocks used : %3d Total blocks : %3d%n",
|
||||
(volumeEntry.totalBlocks - usedBlocks), usedBlocks, volumeEntry.totalBlocks));
|
||||
|
||||
return new DefaultAppleFileSource (volumeEntry.name, text.toString (), this);
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ abstract class CatalogEntry implements AppleFileSource
|
|||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
static String[] storageTypes = { "Del", "Sdl", "Sap", "Tre", "Pas", "Ext", "", "", "",
|
||||
"", "", "", "", "DIR", "SDH", "VDH" };
|
||||
"", "", "", "", "DIR", "SDH", "VDH" };
|
||||
Disk disk;
|
||||
ProdosDisk parentDisk;
|
||||
|
||||
|
@ -111,6 +111,7 @@ abstract class CatalogEntry implements AppleFileSource
|
|||
StringBuilder text = new StringBuilder ();
|
||||
|
||||
text.append (String.format ("Name .......... %s%n", name));
|
||||
text.append (String.format ("Access ........ %02X%n", access));
|
||||
text.append (String.format ("Storage type... %02X%n", storageType));
|
||||
text.append (String.format ("Created ....... %s%n",
|
||||
created == null ? "" : created.format (ProdosDisk.df)));
|
||||
|
|
|
@ -72,8 +72,8 @@ class FileEntry extends CatalogEntry implements ProdosConstants
|
|||
private FileEntry link;
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
FileEntry (ProdosDisk fDisk, byte[] entryBuffer, DirectoryHeader parent, int parentBlock,
|
||||
int entryNo)
|
||||
FileEntry (ProdosDisk fDisk, byte[] entryBuffer, DirectoryHeader parent,
|
||||
int parentBlock, int entryNo)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
super (fDisk, entryBuffer, parentBlock, entryNo);
|
||||
|
@ -143,7 +143,8 @@ class FileEntry extends CatalogEntry implements ProdosConstants
|
|||
{
|
||||
int storageType = buffer2[i] & 0x0F;
|
||||
int keyBlock = Utility.getShort (buffer2, i + 1);
|
||||
int eof = Utility.readTriple (buffer2, i + 3);
|
||||
int size = Utility.getShort (buffer2, i + 3);
|
||||
int eof = Utility.readTriple (buffer2, i + 5);
|
||||
|
||||
if (i < 256)
|
||||
addDataBlocks (storageType, keyBlock, dataBlocks);
|
||||
|
@ -162,40 +163,40 @@ class FileEntry extends CatalogEntry implements ProdosConstants
|
|||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
DiskAddress emptyDiskAddress = disk.getDiskAddress (0);
|
||||
List<Integer> blocks = new ArrayList<> ();
|
||||
List<Integer> blockNos = new ArrayList<> ();
|
||||
|
||||
switch (storageType)
|
||||
{
|
||||
case SEEDLING:
|
||||
if (isValid (keyPtr))
|
||||
blocks.add (keyPtr);
|
||||
blockNos.add (keyPtr);
|
||||
break;
|
||||
|
||||
case SAPLING:
|
||||
if (isValid (keyPtr))
|
||||
blocks.addAll (readIndex (keyPtr));
|
||||
blockNos.addAll (readIndex (keyPtr));
|
||||
break;
|
||||
|
||||
case TREE:
|
||||
if (isValid (keyPtr))
|
||||
for (Integer indexBlock : readMasterIndex (keyPtr))
|
||||
if (isValid (indexBlock))
|
||||
blocks.addAll (readIndex (indexBlock));
|
||||
blockNos.addAll (readIndex (indexBlock));
|
||||
break;
|
||||
}
|
||||
|
||||
// remove trailing empty blocks
|
||||
while (blocks.size () > 0 && blocks.get (blocks.size () - 1) == 0)
|
||||
blocks.remove (blocks.size () - 1);
|
||||
while (blockNos.size () > 0 && blockNos.get (blockNos.size () - 1) == 0)
|
||||
blockNos.remove (blockNos.size () - 1);
|
||||
|
||||
for (Integer block : blocks)
|
||||
for (Integer blockNo : blockNos)
|
||||
{
|
||||
if (block == 0)
|
||||
if (blockNo == 0)
|
||||
dataBlocks.add (emptyDiskAddress);
|
||||
else
|
||||
{
|
||||
parentDisk.setSectorType (block, parentDisk.dataSector);
|
||||
dataBlocks.add (disk.getDiskAddress (block));
|
||||
parentDisk.setSectorType (blockNo, parentDisk.dataSector);
|
||||
dataBlocks.add (disk.getDiskAddress (blockNo));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -349,7 +350,8 @@ class FileEntry extends CatalogEntry implements ProdosConstants
|
|||
file = new DoubleHiResImage (name, outBuffer);
|
||||
break;
|
||||
case 0x8000:
|
||||
file = new SHRPictureFile2 (name, outBuffer, FILE_TYPE_PIC, 0x2000, 0x8000);
|
||||
file =
|
||||
new SHRPictureFile2 (name, outBuffer, FILE_TYPE_PIC, 0x2000, 0x8000);
|
||||
break;
|
||||
default:
|
||||
file = new AssemblerProgram (name, exactBuffer, auxType);
|
||||
|
@ -369,8 +371,8 @@ class FileEntry extends CatalogEntry implements ProdosConstants
|
|||
}
|
||||
// else if (name.endsWith (".PIC")) // 0091 X-BASIC../../XBASIC.PIC
|
||||
// file = new SHRPictureFile2 (name, exactBuffer, fileType, auxType, endOfFile);
|
||||
else if ((name.equals ("DOS.3.3") || name.equals ("DDOS.3.3")) && endOfFile == 0x2800
|
||||
&& DosMasterFile.isDos33 (parentDisk, exactBuffer))
|
||||
else if ((name.equals ("DOS.3.3") || name.equals ("DDOS.3.3"))
|
||||
&& endOfFile == 0x2800 && DosMasterFile.isDos33 (parentDisk, exactBuffer))
|
||||
{
|
||||
file = new DosMasterFile (name, exactBuffer);
|
||||
}
|
||||
|
@ -413,8 +415,8 @@ class FileEntry extends CatalogEntry implements ProdosConstants
|
|||
|
||||
case FILE_TYPE_DIRECTORY:
|
||||
VolumeDirectoryHeader vdh = parentDisk.getVolumeDirectoryHeader ();
|
||||
file = new ProdosDirectory (parentDisk, name, buffer, vdh.totalBlocks, vdh.freeBlocks,
|
||||
vdh.usedBlocks);
|
||||
file = new ProdosDirectory (parentDisk, name, buffer, vdh.totalBlocks,
|
||||
vdh.freeBlocks, vdh.usedBlocks);
|
||||
break;
|
||||
|
||||
case FILE_TYPE_APPLESOFT_BASIC_VARS:
|
||||
|
@ -547,6 +549,8 @@ class FileEntry extends CatalogEntry implements ProdosConstants
|
|||
case FILE_TYPE_NON:
|
||||
if (name.endsWith (".TIFF") && HiResImage.isTiff (exactBuffer))
|
||||
file = new OriginalHiResImage (name, exactBuffer, auxType);
|
||||
else if (name.endsWith (".JAVA"))
|
||||
file = new BasicTextFile (name, exactBuffer, auxType, endOfFile);
|
||||
else
|
||||
file = new DefaultAppleFile (name, exactBuffer);
|
||||
break;
|
||||
|
@ -623,7 +627,8 @@ class FileEntry extends CatalogEntry implements ProdosConstants
|
|||
if (addresses.size () > 0)
|
||||
{
|
||||
byte[] tempBuffer = disk.readBlocks (addresses);
|
||||
buffers.add (new TextBuffer (tempBuffer, auxType, logicalBlock - addresses.size ()));
|
||||
buffers.add (
|
||||
new TextBuffer (tempBuffer, auxType, logicalBlock - addresses.size ()));
|
||||
addresses.clear ();
|
||||
}
|
||||
logicalBlock += 256;
|
||||
|
@ -723,8 +728,8 @@ class FileEntry extends CatalogEntry implements ProdosConstants
|
|||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
private int readIndexBlock (int indexBlock, List<DiskAddress> addresses, List<TextBuffer> buffers,
|
||||
int logicalBlock)
|
||||
private int readIndexBlock (int indexBlock, List<DiskAddress> addresses,
|
||||
List<TextBuffer> buffers, int logicalBlock)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
byte[] indexBuffer = disk.readBlock (indexBlock);
|
||||
|
@ -736,7 +741,8 @@ class FileEntry extends CatalogEntry implements ProdosConstants
|
|||
else if (addresses.size () > 0)
|
||||
{
|
||||
byte[] tempBuffer = disk.readBlocks (addresses);
|
||||
buffers.add (new TextBuffer (tempBuffer, auxType, logicalBlock - addresses.size ()));
|
||||
buffers
|
||||
.add (new TextBuffer (tempBuffer, auxType, logicalBlock - addresses.size ()));
|
||||
addresses.clear ();
|
||||
}
|
||||
logicalBlock++;
|
||||
|
@ -807,13 +813,14 @@ class FileEntry extends CatalogEntry implements ProdosConstants
|
|||
String locked = (access == 0x00) ? "*" : " ";
|
||||
|
||||
if (true)
|
||||
return String.format ("%s %03d %s", ProdosConstants.fileTypes[fileType], blocksUsed, locked)
|
||||
+ name;
|
||||
return String.format ("%s %03d %s", ProdosConstants.fileTypes[fileType],
|
||||
blocksUsed, locked) + name;
|
||||
|
||||
String timeC = created == null ? "" : created.format (ProdosDisk.df);
|
||||
String timeF = modified == null ? "" : modified.format (ProdosDisk.df);
|
||||
|
||||
return String.format ("%s %s%-30s %3d %,10d %15s %15s", ProdosConstants.fileTypes[fileType],
|
||||
locked, parentDirectory.name + "/" + name, blocksUsed, endOfFile, timeC, timeF);
|
||||
return String.format ("%s %s%-30s %3d %,10d %15s %15s",
|
||||
ProdosConstants.fileTypes[fileType], locked, parentDirectory.name + "/" + name,
|
||||
blocksUsed, endOfFile, timeC, timeF);
|
||||
}
|
||||
}
|
|
@ -7,6 +7,7 @@ import java.time.format.DateTimeFormatter;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import javax.swing.tree.DefaultMutableTreeNode;
|
||||
import javax.swing.tree.DefaultTreeModel;
|
||||
|
@ -31,7 +32,8 @@ public class ProdosDisk extends AbstractFormattedDisk
|
|||
{
|
||||
static ProdosPreferences prodosPreferences; // set by MenuHandler
|
||||
|
||||
static final DateTimeFormatter df = DateTimeFormatter.ofPattern ("d-LLL-yy");
|
||||
private static Locale US = Locale.US; // to force 3 character months
|
||||
static final DateTimeFormatter df = DateTimeFormatter.ofPattern ("d-LLL-yy", US);
|
||||
static final DateTimeFormatter tf = DateTimeFormatter.ofPattern ("H:mm");
|
||||
|
||||
final SectorType dosSector = new SectorType ("Bootstrap Loader", Color.lightGray);
|
||||
|
|
|
@ -5,6 +5,10 @@ import static com.bytezone.diskbrowser.prodos.ProdosConstants.SAPLING;
|
|||
import static com.bytezone.diskbrowser.prodos.ProdosConstants.SEEDLING;
|
||||
import static com.bytezone.diskbrowser.prodos.ProdosConstants.TREE;
|
||||
|
||||
// Assumptions:
|
||||
// - file does not already exist
|
||||
// - disk is not interleaved
|
||||
// - blocks are 512 contiguous bytes
|
||||
// -----------------------------------------------------------------------------------//
|
||||
public class FileWriter
|
||||
// -----------------------------------------------------------------------------------//
|
||||
|
@ -37,8 +41,7 @@ public class FileWriter
|
|||
|
||||
while (dataPtr < this.eof)
|
||||
{
|
||||
int actualBlockNo = allocateNextBlock ();
|
||||
map (dataPtr / BLOCK_SIZE, actualBlockNo);
|
||||
int actualBlockNo = register (dataPtr / BLOCK_SIZE);
|
||||
|
||||
int bufferPtr = actualBlockNo * BLOCK_SIZE;
|
||||
int transfer = Math.min (remaining, BLOCK_SIZE);
|
||||
|
@ -53,8 +56,7 @@ public class FileWriter
|
|||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
void writeRecord (int recordNo, byte[] dataBuffer, int recordLength)
|
||||
throws DiskFullException
|
||||
void writeRecord (int recordNo, byte[] dataBuffer, int recordLength) throws DiskFullException
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
assert recordLength > 0;
|
||||
|
@ -98,33 +100,23 @@ public class FileWriter
|
|||
private int getActualBlockNo (int logicalBlockNo) throws DiskFullException
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
int actualBlockNo = 0;
|
||||
|
||||
switch (storageType)
|
||||
{
|
||||
case TREE:
|
||||
actualBlockNo = masterIndexBlock.get (logicalBlockNo / 0x100)
|
||||
.getPosition (logicalBlockNo % 0x100);
|
||||
break;
|
||||
return masterIndexBlock.get (logicalBlockNo / 0x100).getPosition (logicalBlockNo % 0x100);
|
||||
|
||||
case SAPLING:
|
||||
if (logicalBlockNo < 0x100)
|
||||
actualBlockNo = indexBlock.getPosition (logicalBlockNo);
|
||||
return indexBlock.getPosition (logicalBlockNo);
|
||||
break;
|
||||
|
||||
case SEEDLING:
|
||||
if (logicalBlockNo == 0)
|
||||
actualBlockNo = keyPointer;
|
||||
return keyPointer;
|
||||
break;
|
||||
}
|
||||
|
||||
if (actualBlockNo == 0)
|
||||
{
|
||||
actualBlockNo = allocateNextBlock ();
|
||||
map (logicalBlockNo, actualBlockNo);
|
||||
}
|
||||
|
||||
return actualBlockNo;
|
||||
return register (logicalBlockNo);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
|
@ -138,14 +130,17 @@ public class FileWriter
|
|||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
private void map (int logicalBlockNo, int actualBlockNo) throws DiskFullException
|
||||
private int register (int logicalBlockNo) throws DiskFullException
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
int nextBlockNo = allocateNextBlock ();
|
||||
|
||||
if (logicalBlockNo >= 0x100) // potential TREE
|
||||
{
|
||||
if (storageType != TREE)
|
||||
{
|
||||
masterIndexBlock = new MasterIndexBlock (allocateNextBlock ());
|
||||
masterIndexBlock = new MasterIndexBlock (nextBlockNo);
|
||||
nextBlockNo = allocateNextBlock ();
|
||||
|
||||
if (storageType == SAPLING) // sapling -> tree
|
||||
{
|
||||
|
@ -153,7 +148,9 @@ public class FileWriter
|
|||
}
|
||||
else if (storageType == SEEDLING) // seedling -> sapling -> tree
|
||||
{
|
||||
indexBlock = new IndexBlock (allocateNextBlock ());
|
||||
indexBlock = new IndexBlock (nextBlockNo);
|
||||
nextBlockNo = allocateNextBlock ();
|
||||
|
||||
indexBlock.setPosition (0, keyPointer);
|
||||
masterIndexBlock.set (0, indexBlock);
|
||||
}
|
||||
|
@ -163,48 +160,51 @@ public class FileWriter
|
|||
indexBlock = null;
|
||||
}
|
||||
|
||||
getIndexBlock (logicalBlockNo / 0x100).setPosition (logicalBlockNo % 0x100,
|
||||
actualBlockNo);
|
||||
getIndexBlock (logicalBlockNo / 0x100).setPosition (logicalBlockNo % 0x100, nextBlockNo);
|
||||
}
|
||||
else if (logicalBlockNo > 0) // potential SAPLING
|
||||
{
|
||||
if (storageType == TREE) // already a tree
|
||||
{
|
||||
getIndexBlock (0).setPosition (logicalBlockNo, actualBlockNo);
|
||||
getIndexBlock (0).setPosition (logicalBlockNo, nextBlockNo);
|
||||
}
|
||||
else if (storageType == SAPLING) // already a sapling
|
||||
{
|
||||
indexBlock.setPosition (logicalBlockNo, actualBlockNo);
|
||||
indexBlock.setPosition (logicalBlockNo, nextBlockNo);
|
||||
}
|
||||
else // new file or already a seedling
|
||||
{
|
||||
indexBlock = new IndexBlock (allocateNextBlock ());
|
||||
indexBlock = new IndexBlock (nextBlockNo);
|
||||
nextBlockNo = allocateNextBlock ();
|
||||
|
||||
if (storageType == SEEDLING) // seedling -> sapling
|
||||
indexBlock.setPosition (0, keyPointer);
|
||||
|
||||
keyPointer = indexBlock.blockNo;
|
||||
storageType = SAPLING;
|
||||
indexBlock.setPosition (logicalBlockNo, actualBlockNo);
|
||||
indexBlock.setPosition (logicalBlockNo, nextBlockNo);
|
||||
}
|
||||
}
|
||||
else if (logicalBlockNo == 0) // potential SEEDLING
|
||||
{
|
||||
if (storageType == TREE) // already a tree
|
||||
{
|
||||
getIndexBlock (0).setPosition (0, actualBlockNo);
|
||||
getIndexBlock (0).setPosition (0, nextBlockNo);
|
||||
}
|
||||
else if (storageType == SAPLING) // already a sapling
|
||||
{
|
||||
indexBlock.setPosition (0, actualBlockNo);
|
||||
indexBlock.setPosition (0, nextBlockNo);
|
||||
}
|
||||
else
|
||||
{
|
||||
keyPointer = actualBlockNo;
|
||||
keyPointer = nextBlockNo;
|
||||
storageType = SEEDLING;
|
||||
}
|
||||
}
|
||||
else
|
||||
System.out.println ("Error: " + logicalBlockNo);
|
||||
|
||||
return nextBlockNo;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.bytezone.diskbrowser.utilities;
|
||||
|
||||
import java.time.DateTimeException;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
|
@ -7,12 +8,11 @@ import java.time.format.DateTimeFormatter;
|
|||
public class DateTime
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
private static String[] months = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul",
|
||||
"Aug", "Sep", "Oct", "Nov", "Dec" };
|
||||
private static String[] days = { "", "Sunday", "Monday", "Tuesday", "Wednesday",
|
||||
"Thursday", "Friday", "Saturday" };
|
||||
private static final DateTimeFormatter dtf =
|
||||
DateTimeFormatter.ofPattern ("dd-LLL-yy HH:mm");
|
||||
private static String[] months =
|
||||
{ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
|
||||
private static String[] days =
|
||||
{ "", "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" };
|
||||
private static final DateTimeFormatter dtf = DateTimeFormatter.ofPattern ("dd-LLL-yy HH:mm");
|
||||
|
||||
private final int second;
|
||||
private final int minute;
|
||||
|
@ -40,8 +40,8 @@ public class DateTime
|
|||
public String format ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
return String.format ("%02d:%02d:%02d %s %d %s %d", hour, minute, second,
|
||||
days[weekDay], day, months[month], year);
|
||||
return String.format ("%02d:%02d:%02d %s %d %s %d", hour, minute, second, days[weekDay], day,
|
||||
months[month], year);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
|
@ -56,10 +56,15 @@ public class DateTime
|
|||
public LocalDateTime getLocalDateTime ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
int adjustedYear = year + (year > 70 ? 1900 : 2000);
|
||||
if (day < 0 || day > 30)
|
||||
try
|
||||
{
|
||||
int adjustedYear = year + (year > 70 ? 1900 : 2000);
|
||||
return LocalDateTime.of (adjustedYear, month + 1, day + 1, hour, minute);
|
||||
}
|
||||
catch (DateTimeException e)
|
||||
{
|
||||
return null;
|
||||
return LocalDateTime.of (adjustedYear, month + 1, day + 1, hour, minute);
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
|
@ -67,8 +72,7 @@ public class DateTime
|
|||
public String toString ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
return "DateTime [second=" + second + ", minute=" + minute + ", hour=" + hour
|
||||
+ ", year=" + year + ", day=" + day + ", month=" + month + ", weekDay=" + weekDay
|
||||
+ "]";
|
||||
return "DateTime [second=" + second + ", minute=" + minute + ", hour=" + hour + ", year=" + year
|
||||
+ ", day=" + day + ", month=" + month + ", weekDay=" + weekDay + "]";
|
||||
}
|
||||
}
|
|
@ -17,6 +17,7 @@ public abstract class DefaultAction extends AbstractAction
|
|||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
super (text);
|
||||
|
||||
this.baseURL = null;
|
||||
putValue (Action.SHORT_DESCRIPTION, tip);
|
||||
}
|
||||
|
@ -26,6 +27,7 @@ public abstract class DefaultAction extends AbstractAction
|
|||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
super (text);
|
||||
|
||||
this.baseURL = baseURL;
|
||||
putValue (Action.SHORT_DESCRIPTION, tip);
|
||||
}
|
||||
|
@ -39,6 +41,7 @@ public abstract class DefaultAction extends AbstractAction
|
|||
System.out.println ("Base URL not set");
|
||||
return;
|
||||
}
|
||||
|
||||
URL url = this.getClass ().getResource (baseURL + iconName);
|
||||
if (url != null)
|
||||
putValue (iconType, new ImageIcon (url));
|
||||
|
|
|
@ -40,8 +40,8 @@ public final class Utility
|
|||
private static MathContext mathContext4 = new MathContext (6);
|
||||
private static MathContext mathContext8 = new MathContext (15);
|
||||
|
||||
private static final List<String> suffixes = Arrays.asList ("po", "dsk", "do", "hdv", "2mg",
|
||||
"d13", "sdk", "shk", "bxy", "bny", "woz", "img", "dimg");
|
||||
private static final List<String> suffixes = Arrays.asList ("po", "dsk", "do", "hdv",
|
||||
"2mg", "d13", "sdk", "shk", "bxy", "bny", "bqy", "woz", "img", "dimg");
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
private Utility ()
|
||||
|
@ -255,7 +255,8 @@ public final class Utility
|
|||
}
|
||||
catch (DateTimeException e)
|
||||
{
|
||||
System.out.printf ("Bad date/time: %d %d %d %d %d %n", year, month, day, hour, minute);
|
||||
System.out.printf ("Bad date/time: %d %d %d %d %d %n", year, month, day, hour,
|
||||
minute);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -315,7 +316,8 @@ public final class Utility
|
|||
public static int readTriple (byte[] buffer, int ptr)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
return (buffer[ptr] & 0xFF) | (buffer[ptr + 1] & 0xFF) << 8 | (buffer[ptr + 2] & 0xFF) << 16;
|
||||
return (buffer[ptr] & 0xFF) | (buffer[ptr + 1] & 0xFF) << 8
|
||||
| (buffer[ptr + 2] & 0xFF) << 16;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
|
@ -384,8 +386,8 @@ public final class Utility
|
|||
if (exponent == 0)
|
||||
return 0.0;
|
||||
|
||||
int mantissa =
|
||||
(buffer[ptr + 2] & 0x7F) << 16 | (buffer[ptr + 1] & 0xFF) << 8 | (buffer[ptr] & 0xFF);
|
||||
int mantissa = (buffer[ptr + 2] & 0x7F) << 16 | (buffer[ptr + 1] & 0xFF) << 8
|
||||
| (buffer[ptr] & 0xFF);
|
||||
boolean negative = (buffer[ptr + 2] & 0x80) != 0;
|
||||
double value = 0.5;
|
||||
|
||||
|
@ -408,9 +410,10 @@ public final class Utility
|
|||
if (exponent == 0)
|
||||
return 0.0;
|
||||
|
||||
long mantissa = (long) (buffer[ptr + 6] & 0x7F) << 48 | (long) (buffer[ptr + 5] & 0xFF) << 40
|
||||
| (long) (buffer[ptr + 4] & 0xFF) << 32 | (long) (buffer[ptr + 3] & 0xFF) << 24
|
||||
| (buffer[ptr + 2] & 0xFF) << 16 | (buffer[ptr + 1] & 0xFF) << 8 | (buffer[ptr] & 0xFF);
|
||||
long mantissa = (long) (buffer[ptr + 6] & 0x7F) << 48
|
||||
| (long) (buffer[ptr + 5] & 0xFF) << 40 | (long) (buffer[ptr + 4] & 0xFF) << 32
|
||||
| (long) (buffer[ptr + 3] & 0xFF) << 24 | (buffer[ptr + 2] & 0xFF) << 16
|
||||
| (buffer[ptr + 1] & 0xFF) << 8 | (buffer[ptr] & 0xFF);
|
||||
boolean negative = (buffer[ptr + 6] & 0x80) != 0;
|
||||
double value = 0.5;
|
||||
|
||||
|
@ -444,7 +447,27 @@ public final class Utility
|
|||
else
|
||||
year += 1900;
|
||||
|
||||
return LocalDate.of (year, month, day);
|
||||
try
|
||||
{
|
||||
return LocalDate.of (year, month, day);
|
||||
}
|
||||
catch (DateTimeException e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public static String getCString (byte[] buffer, int offset)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
int length = 0;
|
||||
int ptr = offset;
|
||||
|
||||
while (buffer[ptr++] != 0)
|
||||
++length;
|
||||
|
||||
return new String (buffer, offset, length);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
|
@ -500,11 +523,13 @@ public final class Utility
|
|||
int[] val = new int[6];
|
||||
for (int i = 0; i < 6; i++)
|
||||
val[i] = Integer.parseInt (String.format ("%02X", buffer[ptr + i] & 0xFF));
|
||||
// val[i] = buffer[ptr + i] & 0xFF;
|
||||
|
||||
LocalDateTime date = LocalDateTime.of (val[3] + 2000, val[5], val[4], val[2], val[1], val[0]);
|
||||
LocalDateTime date =
|
||||
LocalDateTime.of (val[3] + 2000, val[5], val[4], val[2], val[1], val[0]);
|
||||
return date;
|
||||
}
|
||||
catch (DateTimeException | NumberFormatException e)
|
||||
catch (DateTimeException e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
@ -544,6 +569,23 @@ public final class Utility
|
|||
return suffixes.contains (getSuffix (filename));
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public static String getShortPath (String path)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
String home = System.getProperty ("user.home");
|
||||
if (path.startsWith (home))
|
||||
path = "~" + path.substring (home.length ());
|
||||
else if (path.startsWith ("/Volumes/"))
|
||||
{
|
||||
int pos = path.indexOf (home);
|
||||
if (pos > 0)
|
||||
path = "~" + path.substring (home.length () + pos);
|
||||
}
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public static void reverse (byte[] buffer)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
|
@ -592,7 +634,8 @@ public final class Utility
|
|||
public static boolean isPossibleVariable (byte value)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
return isDigit (value) || isLetter (value) || value == ASCII_DOLLAR || value == ASCII_PERCENT;
|
||||
return isDigit (value) || isLetter (value) || value == ASCII_DOLLAR
|
||||
|| value == ASCII_PERCENT;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
|
@ -672,41 +715,42 @@ public final class Utility
|
|||
return ~crc; // one's complement
|
||||
}
|
||||
|
||||
static int[] crc32_tab = { 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f,
|
||||
0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b,
|
||||
0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de,
|
||||
0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0x136c9856, 0x646ba8c0, 0xfd62f97a,
|
||||
0x8a65c9ec, 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e,
|
||||
0xd56041e4, 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa,
|
||||
0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59,
|
||||
0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599,
|
||||
0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, 0x2f6f7c87, 0x58684c11,
|
||||
0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589,
|
||||
0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433, 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818,
|
||||
0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8,
|
||||
0xf262004e, 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950,
|
||||
0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, 0x4db26158,
|
||||
0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb,
|
||||
0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5, 0xaa0a4c5f,
|
||||
0xdd0d7cc9, 0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3,
|
||||
0xb966d409, 0xce61e49f, 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17,
|
||||
0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a,
|
||||
0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84, 0x0d6d6a3e,
|
||||
0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, 0xf00f9344, 0x8708a3d2,
|
||||
0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7, 0xfed41b76,
|
||||
0x89d32be0, 0x10da7a5a, 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5,
|
||||
0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd,
|
||||
0x48b2364b, 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55,
|
||||
0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, 0xcc0c7795,
|
||||
0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04,
|
||||
0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d, 0x9b64c2b0, 0xec63f226, 0x756aa39c,
|
||||
0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14,
|
||||
0x7bb12bae, 0x0cb61b38, 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4,
|
||||
0xf1d4e242, 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777,
|
||||
0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, 0x616bffd3,
|
||||
0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7,
|
||||
0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0, 0xa9bcae53,
|
||||
0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6,
|
||||
0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02,
|
||||
0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d };
|
||||
static int[] crc32_tab = { //
|
||||
0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535,
|
||||
0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd,
|
||||
0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, 0x1adad47d,
|
||||
0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec,
|
||||
0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4,
|
||||
0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c,
|
||||
0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, 0x26d930ac,
|
||||
0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f,
|
||||
0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, 0x2f6f7c87, 0x58684c11, 0xc1611dab,
|
||||
0xb6662d3d, 0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f,
|
||||
0x9fbfe4a5, 0xe8b8d433, 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb,
|
||||
0x086d3d2d, 0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e,
|
||||
0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea,
|
||||
0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, 0x4db26158, 0x3ab551ce,
|
||||
0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a,
|
||||
0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9,
|
||||
0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409,
|
||||
0xce61e49f, 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81,
|
||||
0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, 0xead54739,
|
||||
0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8,
|
||||
0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, 0xf00f9344, 0x8708a3d2, 0x1e01f268,
|
||||
0x6906c2fe, 0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0,
|
||||
0x10da7a5a, 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8,
|
||||
0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b,
|
||||
0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef,
|
||||
0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, 0xcc0c7795, 0xbb0b4703,
|
||||
0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7,
|
||||
0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d, 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a,
|
||||
0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae,
|
||||
0x0cb61b38, 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242,
|
||||
0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, 0x88085ae6,
|
||||
0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45,
|
||||
0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7, 0x4969474d,
|
||||
0x3e6e77db, 0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5,
|
||||
0x47b2cf7f, 0x30b5ffe9, 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605,
|
||||
0xcdd70693, 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94,
|
||||
0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d };
|
||||
}
|
Loading…
Reference in New Issue