mirror of
https://github.com/dmolony/DiskBrowser.git
synced 2024-12-25 14:32:15 +00:00
Palettes
This commit is contained in:
parent
ee3b38094b
commit
152ac38ac8
@ -44,9 +44,9 @@ public class DoubleHiResImage extends HiResImage
|
||||
private static final int AQUA = 0x44FF99;
|
||||
private static final int WHITE = 0xFFFFFF;
|
||||
|
||||
private static int[] palette =
|
||||
{ BLACK, MAGENTA, DARK_BLUE, PURPLE, DARK_GREEN, GRAY1, MEDIUM_BLUE, LIGHT_BLUE,
|
||||
BROWN, ORANGE, GRAY2, PINK, GREEN, YELLOW, AQUA, WHITE };
|
||||
// private static int[] palette =
|
||||
// { BLACK, MAGENTA, DARK_BLUE, PURPLE, DARK_GREEN, GRAY1, MEDIUM_BLUE, LIGHT_BLUE,
|
||||
// BROWN, ORANGE, GRAY2, PINK, GREEN, YELLOW, AQUA, WHITE };
|
||||
|
||||
// private static final int BLACK = 0x000000;
|
||||
// private static final int MAGENTA = 0x722640;
|
||||
@ -68,9 +68,64 @@ public class DoubleHiResImage extends HiResImage
|
||||
// { BLACK, MAGENTA, DARK_BLUE, PURPLE, DARK_GREEN, GRAY, MEDIUM_BLUE, LIGHT_BLUE,
|
||||
// BROWN, ORANGE, GRAY, PINK, GREEN, YELLOW, AQUA, WHITE };
|
||||
|
||||
private static int[][] palette2 =
|
||||
{ { 0x000000, 0xDD0033, 0x885500, 0xFF6600, 0x007722, 0x555555, 0x11DD00, 0xFFFF00,
|
||||
0x000099, 0xDD22DD, 0xAAAAAA, 0xFF9988, 0x2222FF, 0x66AAFF, 0x44FF99,
|
||||
0xFFFFFF },
|
||||
{//
|
||||
rgb (0, 0, 0), // black
|
||||
rgb (157, 9, 102), // red
|
||||
rgb (42, 42, 229), // dk blue
|
||||
rgb (199, 52, 255), // purple
|
||||
rgb (0, 118, 26), // dk green
|
||||
rgb (128, 128, 128), // gray
|
||||
rgb (13, 161, 255), // med blue
|
||||
rgb (170, 170, 255), // lt blue
|
||||
rgb (85, 85, 0), // brown
|
||||
rgb (242, 94, 0), // orange
|
||||
rgb (192, 192, 192), // grey
|
||||
rgb (255, 137, 229), // pink
|
||||
rgb (56, 203, 0), // lt green
|
||||
rgb (213, 213, 26), // yellow
|
||||
rgb (98, 246, 153), // aqua
|
||||
rgb (255, 255, 255) // white
|
||||
}, //
|
||||
{ 0x000000, 0x722640, 0x40337F, 0xE434FE, 0x0E5940, 0x808080, 0x1B9AEF, 0xBFB3FF,
|
||||
0x404C00, 0xE46501, 0x808080, 0xF1A6BF, 0x1BCB01, 0xBFCC80, 0x8DD9BF,
|
||||
0xFFFFFF } };
|
||||
|
||||
/*-
|
||||
* Michael Pohoreski - The Apple II Forever Anthology
|
||||
|
||||
@reference: Technote tn-iigs-063 “Master Color Values”
|
||||
Color Register Values
|
||||
Color Reg LR HR DHR Master Authentic Tweaked NTSC
|
||||
Name # # # Value Corrected
|
||||
-----------------------------------------------------------------------------
|
||||
Black 0 0 0,4 0 $0000 (00,00,00) (00,00,00) 00,00,00
|
||||
(Magenta) Deep Red 1 1 1 $0D03 (D0,00,30) (D0,00,30) 90,17,40
|
||||
Dark Blue 2 2 8 $0009 (00,00,90) (00,00,80) 40,2C,A5
|
||||
(Violet) Purple 3 3 2 9 $0D2D (D0,20,D0) (FF,00,FF) D0,43,E5
|
||||
Dark Green 4 4 4 $0072 (00,70,20) (00,80,00) 00,69,40
|
||||
(Gray 1) Dark Gray 5 5 5 $0555 (50,50,50) (80,80,80) 80,80,80
|
||||
(Blue) Medium Blue 6 6 6 C $022F (20,20,F0) (00,00,FF) 2F,95,E5
|
||||
(Cyan) Light Blue 7 7 D $06AF (60,A0,F0) (60,A0,FF) BF,AB,FF
|
||||
Brown 8 8 2 $0850 (80,50,00) (80,50,00) 40,54,00
|
||||
Orange 9 9 5 3 $0F60 (F0,60,00) (FF,80,00) D0,6A,1A
|
||||
(Gray 2) Light Gray A A A $0AAA (A0,A0,A0) (C0,C0,C0) 80,80,80
|
||||
Pink B B B $0F98 (F0,90,80) (FF,90,80) FF,96,BF
|
||||
(Green) Light Green C C 1 6 $01D0 (10,D0,00) (00,FF,00) 2F,BC,1A
|
||||
Yellow D D 7 $0FF0 (F0,F0,00) (FF,FF,00) BF,D3,5A
|
||||
(Aqua) Aquamarine E E E $04F9 (40,F0,90) (40,FF,90) 6F,E8,BF
|
||||
White F F 3,7 F $0FFF (F0,F0,F0) (FF,FF,FF) FF,FF,FF
|
||||
Legend:
|
||||
LR: Lo-Res HR: Hi-Res DHR: Double Hi-Res
|
||||
*/
|
||||
|
||||
private final byte[] auxBuffer;
|
||||
private DoubleScrunch doubleScrunch;
|
||||
byte[] packedBuffer;
|
||||
private final int paletteIndex = 2;
|
||||
|
||||
public DoubleHiResImage (String name, byte[] buffer, byte[] auxBuffer)
|
||||
{
|
||||
@ -84,13 +139,27 @@ public class DoubleHiResImage extends HiResImage
|
||||
{
|
||||
super (name, buffer);
|
||||
|
||||
assert name.endsWith (".PAC");
|
||||
assert name.endsWith (".PAC") || name.endsWith ("A2FC");
|
||||
|
||||
if (name.endsWith (".PAC"))
|
||||
{
|
||||
packedBuffer = buffer;
|
||||
doubleScrunch = new DoubleScrunch ();
|
||||
doubleScrunch.unscrunch (buffer);
|
||||
auxBuffer = doubleScrunch.memory[0];
|
||||
this.buffer = doubleScrunch.memory[1];
|
||||
}
|
||||
else if (name.endsWith (".A2FC"))
|
||||
{
|
||||
auxBuffer = new byte[0x2000];
|
||||
this.buffer = new byte[0x2000];
|
||||
System.arraycopy (buffer, 0, auxBuffer, 0, 0x2000);
|
||||
System.arraycopy (buffer, 0x2000, this.buffer, 0, 0x2000);
|
||||
}
|
||||
else
|
||||
{
|
||||
auxBuffer = null;
|
||||
}
|
||||
|
||||
createImage ();
|
||||
}
|
||||
@ -101,7 +170,7 @@ public class DoubleHiResImage extends HiResImage
|
||||
// image will be doubled vertically
|
||||
image = new BufferedImage (560, 192 * 2, BufferedImage.TYPE_BYTE_GRAY);
|
||||
DataBuffer dataBuffer = image.getRaster ().getDataBuffer ();
|
||||
int element = 0;
|
||||
int ndx = 0;
|
||||
|
||||
for (int i = 0; i < 3; i++)
|
||||
for (int j = 0; j < 8; j++)
|
||||
@ -117,12 +186,12 @@ public class DoubleHiResImage extends HiResImage
|
||||
{
|
||||
int val = (value >> px) & 0x01;
|
||||
int pixel = val == 0 ? 0 : 255;
|
||||
dataBuffer.setElem (element, pixel);
|
||||
dataBuffer.setElem (element + 560, pixel); // repeat pixel one line on
|
||||
++element;
|
||||
dataBuffer.setElem (ndx, pixel);
|
||||
dataBuffer.setElem (ndx + 560, pixel); // repeat pixel one line on
|
||||
++ndx;
|
||||
}
|
||||
}
|
||||
element += 560; // skip past repeated line
|
||||
ndx += 560; // skip past repeated line
|
||||
}
|
||||
}
|
||||
|
||||
@ -132,7 +201,7 @@ public class DoubleHiResImage extends HiResImage
|
||||
// image will be doubled horizontally
|
||||
image = new BufferedImage (140 * 2, 192, BufferedImage.TYPE_INT_RGB);
|
||||
DataBuffer dataBuffer = image.getRaster ().getDataBuffer ();
|
||||
int element = 0;
|
||||
int ndx = 0;
|
||||
|
||||
for (int i = 0; i < 3; i++)
|
||||
for (int j = 0; j < 8; j++)
|
||||
@ -148,8 +217,8 @@ public class DoubleHiResImage extends HiResImage
|
||||
for (int px = 0; px < 28; px += 4)
|
||||
{
|
||||
int val = (value >> px) & 0x0F;
|
||||
dataBuffer.setElem (element++, palette[val]);
|
||||
dataBuffer.setElem (element++, palette[val]); // repeat pixel
|
||||
dataBuffer.setElem (ndx++, palette2[paletteIndex][val]);
|
||||
dataBuffer.setElem (ndx++, palette2[paletteIndex][val]); // repeat pixel
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -174,4 +243,9 @@ public class DoubleHiResImage extends HiResImage
|
||||
|
||||
return text.toString ();
|
||||
}
|
||||
|
||||
private static int rgb (int red, int green, int blue)
|
||||
{
|
||||
return red << 16 | green << 8 | blue;
|
||||
}
|
||||
}
|
@ -275,7 +275,7 @@ class FileEntry extends CatalogEntry implements ProdosConstants
|
||||
else
|
||||
file = new DoubleHiResImage (name, exactBuffer, link.getBuffer ());
|
||||
}
|
||||
else if (name.endsWith (".PAC"))
|
||||
else if (name.endsWith (".PAC") || name.endsWith (".A2FC"))
|
||||
file = new DoubleHiResImage (name, exactBuffer);
|
||||
else if ((endOfFile == 0x1FF8 || endOfFile == 0x1FFF || endOfFile == 0x2000
|
||||
|| endOfFile == 0x4000)
|
||||
|
Loading…
Reference in New Issue
Block a user