2017-01-25 11:02:50 +00:00
|
|
|
package com.bytezone.diskbrowser.applefile;
|
|
|
|
|
2017-01-26 04:19:23 +00:00
|
|
|
import java.awt.image.BufferedImage;
|
|
|
|
import java.awt.image.DataBuffer;
|
|
|
|
|
|
|
|
import com.bytezone.diskbrowser.prodos.ProdosConstants;
|
2017-02-01 21:15:30 +00:00
|
|
|
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
2017-01-26 04:19:23 +00:00
|
|
|
|
2017-01-25 11:02:50 +00:00
|
|
|
public class SHRPictureFile2 extends HiResImage
|
|
|
|
{
|
2017-01-26 04:19:23 +00:00
|
|
|
ColorTable[] colorTables;
|
2017-02-01 21:15:30 +00:00
|
|
|
byte[] scb; // 0xC1 aux=0
|
2017-01-25 11:02:50 +00:00
|
|
|
|
|
|
|
public SHRPictureFile2 (String name, byte[] buffer, int fileType, int auxType, int eof)
|
|
|
|
{
|
|
|
|
super (name, buffer, fileType, auxType, eof);
|
|
|
|
|
2017-01-26 11:30:16 +00:00
|
|
|
if (fileType == ProdosConstants.FILE_TYPE_PNT) // 0xC0
|
|
|
|
{
|
|
|
|
if (auxType == 0)
|
|
|
|
{
|
|
|
|
System.out.println ("0xC0 aux 0 not written");
|
|
|
|
}
|
|
|
|
else if (auxType == 1) // Eagle/PackBytes
|
|
|
|
{
|
|
|
|
// this unpacks directly to the screen locations
|
|
|
|
System.out.println ("0xC0 aux 1 not written");
|
|
|
|
}
|
|
|
|
else
|
2017-01-27 07:11:00 +00:00
|
|
|
System.out.println ("C0 unknown aux " + auxType);
|
2017-01-26 11:30:16 +00:00
|
|
|
}
|
|
|
|
else if (fileType == ProdosConstants.FILE_TYPE_PIC) // 0xC1
|
2017-01-26 04:19:23 +00:00
|
|
|
{
|
2017-01-27 07:11:00 +00:00
|
|
|
if (auxType > 2)
|
|
|
|
{
|
|
|
|
System.out.printf ("Changing aux from %04X to 0 in %s%n", auxType, name);
|
|
|
|
auxType = 0;
|
|
|
|
}
|
|
|
|
|
2017-02-01 21:15:30 +00:00
|
|
|
if (auxType == 0) // 32,768
|
2017-01-26 04:19:23 +00:00
|
|
|
{
|
|
|
|
scb = new byte[200];
|
|
|
|
System.arraycopy (buffer, 32000, scb, 0, scb.length);
|
|
|
|
|
|
|
|
colorTables = new ColorTable[16];
|
|
|
|
for (int i = 0; i < colorTables.length; i++)
|
|
|
|
colorTables[i] = new ColorTable (i, buffer, 32256 + i * 32);
|
|
|
|
}
|
|
|
|
else if (auxType == 1)
|
|
|
|
{
|
|
|
|
System.out.println ("0xC1 aux 1 not written");
|
|
|
|
}
|
2017-02-01 21:15:30 +00:00
|
|
|
else if (auxType == 2) // Brooks 38,400
|
2017-01-26 04:19:23 +00:00
|
|
|
{
|
|
|
|
colorTables = new ColorTable[200];
|
|
|
|
for (int i = 0; i < colorTables.length; i++)
|
|
|
|
{
|
|
|
|
colorTables[i] = new ColorTable (i, buffer, 32000 + i * 32);
|
|
|
|
colorTables[i].reverse ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2017-01-27 07:11:00 +00:00
|
|
|
System.out.println ("C1 unknown aux " + auxType);
|
2017-01-26 04:19:23 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
System.out.println ("unknown filetype " + fileType);
|
|
|
|
|
2017-01-27 07:11:00 +00:00
|
|
|
if (colorTables != null)
|
|
|
|
createImage ();
|
2017-01-25 11:02:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void createMonochromeImage ()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void createColourImage ()
|
|
|
|
{
|
2017-01-26 04:19:23 +00:00
|
|
|
image = new BufferedImage (320, 200, BufferedImage.TYPE_INT_RGB);
|
|
|
|
DataBuffer dataBuffer = image.getRaster ().getDataBuffer ();
|
|
|
|
|
|
|
|
int element = 0;
|
|
|
|
int ptr = 0;
|
|
|
|
for (int row = 0; row < 200; row++)
|
|
|
|
{
|
|
|
|
ColorTable colorTable =
|
|
|
|
scb != null ? colorTables[scb[row] & 0x0F] : colorTables[row];
|
|
|
|
|
|
|
|
for (int col = 0; col < 160; col++)
|
|
|
|
{
|
|
|
|
int left = (buffer[ptr] & 0xF0) >> 4;
|
|
|
|
int right = buffer[ptr] & 0x0F;
|
|
|
|
|
|
|
|
dataBuffer.setElem (element++, colorTable.entries[left].color.getRGB ());
|
|
|
|
dataBuffer.setElem (element++, colorTable.entries[right].color.getRGB ());
|
|
|
|
|
|
|
|
ptr++;
|
|
|
|
}
|
|
|
|
}
|
2017-01-25 11:02:50 +00:00
|
|
|
}
|
|
|
|
|
2017-01-26 04:19:23 +00:00
|
|
|
@Override
|
|
|
|
public String getText ()
|
|
|
|
{
|
|
|
|
StringBuilder text = new StringBuilder (super.getText ());
|
|
|
|
text.append ("\n\n");
|
|
|
|
|
|
|
|
if (scb != null)
|
2017-01-26 11:30:16 +00:00
|
|
|
{
|
|
|
|
text.append ("SCB\n---\n");
|
|
|
|
for (int i = 0; i < scb.length; i += 8)
|
|
|
|
{
|
|
|
|
for (int j = 0; j < 8; j++)
|
|
|
|
text.append (String.format (" %3d: %02X ", i + j, scb[i + j]));
|
|
|
|
text.append ("\n");
|
|
|
|
}
|
|
|
|
text.append ("\n");
|
|
|
|
}
|
2017-01-26 04:19:23 +00:00
|
|
|
|
2017-01-27 07:11:00 +00:00
|
|
|
if (colorTables != null)
|
2017-02-01 21:15:30 +00:00
|
|
|
{
|
|
|
|
text.append ("Color Table\n\n #");
|
|
|
|
for (int i = 0; i < 16; i++)
|
|
|
|
text.append (String.format (" %02X ", i));
|
|
|
|
text.append ("\n--");
|
|
|
|
for (int i = 0; i < 16; i++)
|
|
|
|
text.append (" ----");
|
|
|
|
text.append ("\n");
|
2017-01-27 07:11:00 +00:00
|
|
|
for (ColorTable colorTable : colorTables)
|
|
|
|
{
|
2017-02-01 21:15:30 +00:00
|
|
|
text.append (colorTable.toLine ());
|
|
|
|
text.append ("\n");
|
2017-01-27 07:11:00 +00:00
|
|
|
}
|
2017-02-01 21:15:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
text.append ("\nScreen lines\n\n");
|
|
|
|
for (int i = 0; i < 200; i++)
|
|
|
|
{
|
|
|
|
text.append (HexFormatter.format (buffer, i * 160, 160));
|
|
|
|
text.append ("\n\n");
|
|
|
|
}
|
2017-01-26 04:19:23 +00:00
|
|
|
|
|
|
|
text.deleteCharAt (text.length () - 1);
|
|
|
|
text.deleteCharAt (text.length () - 1);
|
|
|
|
|
|
|
|
return text.toString ();
|
|
|
|
}
|
2017-01-25 11:02:50 +00:00
|
|
|
}
|