Added SHR 3200 mode.

This commit is contained in:
Robert Greene 2003-12-21 06:15:15 +00:00
parent ec4a31e442
commit 93b9e41f37
2 changed files with 53 additions and 12 deletions

View File

@ -1,6 +1,6 @@
/* /*
* AppleCommander - An Apple ][ image utility. * AppleCommander - An Apple ][ image utility.
* Copyright (C) 2002 by Robert Greene * Copyright (C) 2002-3 by Robert Greene
* robgreene at users.sourceforge.net * robgreene at users.sourceforge.net
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
@ -40,6 +40,13 @@ import java.io.IOException;
* does not follow this - it uses a real 4 bit value, but the high bit is still ignored for * does not follow this - it uses a real 4 bit value, but the high bit is still ignored for
* graphics (hence, the 560 instead of 640 resolution). * graphics (hence, the 560 instead of 640 resolution).
* <p> * <p>
* SHR has been implemented in "16 color" mode as well as 3200 color mode. Note that
* 16 color mode is really 16 pallettes of 16 colors while 3200 color mode is 200
* pallettes of 16 colors (one pallette per line).
* <p>
* NOTE: The design is feeling kludgy. There are 6 distinct variations - possibly a
* subclass is needed to interpret the various graphic image or some such redesign.
* <p>
* Date created: Nov 3, 2002 12:06:36 PM * Date created: Nov 3, 2002 12:06:36 PM
* @author: Rob Greene * @author: Rob Greene
*/ */
@ -48,7 +55,8 @@ public class GraphicsFileFilter implements FileFilter {
public static final int MODE_HGR_COLOR = 2; public static final int MODE_HGR_COLOR = 2;
public static final int MODE_DHR_BLACK_AND_WHITE = 3; public static final int MODE_DHR_BLACK_AND_WHITE = 3;
public static final int MODE_DHR_COLOR = 4; public static final int MODE_DHR_COLOR = 4;
public static final int MODE_SHR = 5; public static final int MODE_SHR_16 = 5;
public static final int MODE_SHR_3200 = 6;
private int mode = MODE_HGR_COLOR; private int mode = MODE_HGR_COLOR;
private AppleImage appleImage; private AppleImage appleImage;
@ -95,13 +103,15 @@ public class GraphicsFileFilter implements FileFilter {
} }
} }
int base = 0; int base = 0;
byte[] pallettes = new byte[0x200]; int palletteOffset = isSuperHires3200Mode() ? 0x7d00 : 0x7e00;
System.arraycopy(fileData, 0x7e00, pallettes, 0, pallettes.length); byte[] pallettes;
pallettes = new byte[fileData.length - palletteOffset];
System.arraycopy(fileData, palletteOffset, pallettes, 0, pallettes.length);
for (int y=0; y<200; y++) { for (int y=0; y<200; y++) {
byte[] lineData = new byte[160]; byte[] lineData = new byte[160];
System.arraycopy(fileData, base, lineData, 0, lineData.length); System.arraycopy(fileData, base, lineData, 0, lineData.length);
processSuperHiresLine(lineData, image, y, processSuperHiresLine(lineData, image, y,
fileData[0x7d00+y], pallettes); fileData[0x7d00+y] /* N/A for 3200 mode */, pallettes);
base+= lineData.length; base+= lineData.length;
} }
} else { } else {
@ -298,7 +308,7 @@ public class GraphicsFileFilter implements FileFilter {
* mode. * mode.
* <p> * <p>
* The color map varies depending upon the SCB value(s) and the pallettes * The color map varies depending upon the SCB value(s) and the pallettes
* stored with the image. * stored with the image. The SCB does not apple to 3200 SHR mode!
* </pre> * </pre>
*/ */
protected void processSuperHiresLine(byte[] lineData, protected void processSuperHiresLine(byte[] lineData,
@ -307,6 +317,12 @@ public class GraphicsFileFilter implements FileFilter {
int palletteNumber = (scb & 0x0f); int palletteNumber = (scb & 0x0f);
boolean fillMode = (scb & 0x20) != 0; boolean fillMode = (scb & 0x20) != 0;
boolean mode320 = (scb & 0x80) == 0; boolean mode320 = (scb & 0x80) == 0;
if (isSuperHires3200Mode()) {
int numPallettes = pallettes.length / 32;
palletteNumber = y % numPallettes;
fillMode = false; // never
mode320 = true; // always
}
int width = mode320 ? 320 : 640; int width = mode320 ? 320 : 640;
int yPosition = y*2; int yPosition = y*2;
int lastColorValue = 0; int lastColorValue = 0;
@ -322,6 +338,9 @@ public class GraphicsFileFilter implements FileFilter {
} else { } else {
colorNumber = (byt & 0xf0) >> 4; colorNumber = (byt & 0xf0) >> 4;
} }
if (isSuperHires3200Mode()) {
colorNumber= 0x0f - colorNumber; // pallette entries are reversed
}
} else { } else {
int offset = (x / 4); int offset = (x / 4);
int colorBits = (x % 4); int colorBits = (x % 4);
@ -432,8 +451,15 @@ public class GraphicsFileFilter implements FileFilter {
/** /**
* Indicates if this is configured for super hires 16 color mode. * Indicates if this is configured for super hires 16 color mode.
*/ */
public boolean isSuperHiresMode() { public boolean isSuperHires16Mode() {
return mode == MODE_SHR; return mode == MODE_SHR_16;
}
/**
* Indicates if this is configured for super hires 3200 color mode.
*/
public boolean isSuperHires3200Mode() {
return mode == MODE_SHR_3200;
} }
/** /**
@ -449,4 +475,11 @@ public class GraphicsFileFilter implements FileFilter {
public boolean isDoubleHiresMode() { public boolean isDoubleHiresMode() {
return isDoubleHiresBlackAndWhiteMode() || isDoubleHiresColorMode(); return isDoubleHiresBlackAndWhiteMode() || isDoubleHiresColorMode();
} }
/**
* Indicates if this is a super-hires mode.
*/
public boolean isSuperHiresMode() {
return isSuperHires16Mode() || isSuperHires3200Mode();
}
} }

View File

@ -1,6 +1,6 @@
/* /*
* AppleCommander - An Apple ][ image utility. * AppleCommander - An Apple ][ image utility.
* Copyright (C) 2002 by Robert Greene * Copyright (C) 2002-3 by Robert Greene
* robgreene at users.sourceforge.net * robgreene at users.sourceforge.net
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
@ -113,11 +113,19 @@ public class ExportGraphicsTypePane extends WizardPane {
} }
}); });
button = new Button(graphicsModeGroup, SWT.RADIO); button = new Button(graphicsModeGroup, SWT.RADIO);
button.setText("Super hires (320x200 or 640x200)"); button.setText("Super hires 16 color mode (320x200 or 640x200)");
button.setSelection(getGraphicsFilter().isSuperHiresMode()); button.setSelection(getGraphicsFilter().isSuperHires16Mode());
button.addSelectionListener(new SelectionAdapter() { button.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) { public void widgetSelected(SelectionEvent e) {
getGraphicsFilter().setMode(GraphicsFileFilter.MODE_SHR); getGraphicsFilter().setMode(GraphicsFileFilter.MODE_SHR_16);
}
});
button = new Button(graphicsModeGroup, SWT.RADIO);
button.setText("Super hires 3200 color mode (320x200 or 640x200)");
button.setSelection(getGraphicsFilter().isSuperHires3200Mode());
button.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
getGraphicsFilter().setMode(GraphicsFileFilter.MODE_SHR_3200);
} }
}); });
label = new Label(control, SWT.WRAP); label = new Label(control, SWT.WRAP);