forked from Apple-2-Tools/jace
Resolved various minor warnings in the source to improve code quality and remove side-effects (unused initalized values, etc)
This commit is contained in:
parent
fb24c875fb
commit
8ac148d724
@ -49,7 +49,7 @@ public class ConvertDiskImage {
|
||||
return;
|
||||
}
|
||||
String ext = args[1].substring(args[1].length() - 3);
|
||||
boolean writeNibblized = false;
|
||||
boolean writeNibblized;
|
||||
boolean writeProdosOrdered = false;
|
||||
if (ext.equalsIgnoreCase("NIB")) {
|
||||
System.out.println("Preparing to write NIB image");
|
||||
@ -69,7 +69,7 @@ public class ConvertDiskImage {
|
||||
}
|
||||
|
||||
// First read in the disk image, this decodes the disk as necessary
|
||||
FloppyDisk theDisk = null;
|
||||
FloppyDisk theDisk;
|
||||
try {
|
||||
theDisk = new FloppyDisk(in, null);
|
||||
} catch (IOException ex) {
|
||||
@ -95,13 +95,13 @@ public class ConvertDiskImage {
|
||||
fos.close();
|
||||
} catch (IOException ex) {
|
||||
System.err.println("Error writing NIB image: " + ex.getMessage());
|
||||
ex.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
fos.close();
|
||||
if (fos != null) {
|
||||
fos.close();
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
System.err.println("Error closing NIB image: " + ex.getMessage());
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -403,18 +403,18 @@ public class EmulatorUILogic implements Reconfigurable {
|
||||
return false;
|
||||
}
|
||||
|
||||
static final Map<Object, Set<Label>> indicators = new HashMap<>();
|
||||
static final Map<Object, Set<Label>> INDICATORS = new HashMap<>();
|
||||
static public void addIndicator(Object owner, Label icon) {
|
||||
addIndicator(owner, icon, 250);
|
||||
}
|
||||
|
||||
static public void addIndicator(Object owner, Label icon, long TTL) {
|
||||
if (JaceApplication.singleton == null) return;
|
||||
synchronized (indicators) {
|
||||
Set<Label> ind = indicators.get(owner);
|
||||
synchronized (INDICATORS) {
|
||||
Set<Label> ind = INDICATORS.get(owner);
|
||||
if (ind == null) {
|
||||
ind = new HashSet<>();
|
||||
indicators.put(owner, ind);
|
||||
INDICATORS.put(owner, ind);
|
||||
}
|
||||
ind.add(icon);
|
||||
JaceApplication.singleton.controller.addIndicator(icon);
|
||||
@ -423,8 +423,8 @@ public class EmulatorUILogic implements Reconfigurable {
|
||||
|
||||
static public void removeIndicator(Object owner, Label icon) {
|
||||
if (JaceApplication.singleton == null) return;
|
||||
synchronized (indicators) {
|
||||
Set<Label> ind = indicators.get(owner);
|
||||
synchronized (INDICATORS) {
|
||||
Set<Label> ind = INDICATORS.get(owner);
|
||||
if (ind != null) {
|
||||
ind.remove(icon);
|
||||
}
|
||||
@ -434,15 +434,15 @@ public class EmulatorUILogic implements Reconfigurable {
|
||||
|
||||
static public void removeIndicators(Object owner) {
|
||||
if (JaceApplication.singleton == null) return;
|
||||
synchronized (indicators) {
|
||||
Set<Label> ind = indicators.get(owner);
|
||||
synchronized (INDICATORS) {
|
||||
Set<Label> ind = INDICATORS.get(owner);
|
||||
if (ind == null) {
|
||||
return;
|
||||
}
|
||||
ind.stream().forEach((icon) -> {
|
||||
JaceApplication.singleton.controller.removeIndicator(icon);
|
||||
});
|
||||
indicators.remove(owner);
|
||||
INDICATORS.remove(owner);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -51,14 +51,14 @@ abstract public class RAM128k extends RAM {
|
||||
|
||||
public RAM128k(Computer computer) {
|
||||
super(computer);
|
||||
mainMemory = new PagedMemory(0xc000, PagedMemory.Type.ram, computer);
|
||||
rom = new PagedMemory(0x3000, PagedMemory.Type.firmwareMain, computer);
|
||||
cPageRom = new PagedMemory(0x1000, PagedMemory.Type.slotRom, computer);
|
||||
languageCard = new PagedMemory(0x3000, PagedMemory.Type.languageCard, computer);
|
||||
languageCard2 = new PagedMemory(0x1000, PagedMemory.Type.languageCard, computer);
|
||||
activeRead = new PagedMemory(0x10000, PagedMemory.Type.ram, computer);
|
||||
activeWrite = new PagedMemory(0x10000, PagedMemory.Type.ram, computer);
|
||||
blank = new PagedMemory(0x100, PagedMemory.Type.ram, computer);
|
||||
mainMemory = new PagedMemory(0xc000, PagedMemory.Type.RAM, computer);
|
||||
rom = new PagedMemory(0x3000, PagedMemory.Type.FIRMWARE_MAIN, computer);
|
||||
cPageRom = new PagedMemory(0x1000, PagedMemory.Type.SLOW_ROM, computer);
|
||||
languageCard = new PagedMemory(0x3000, PagedMemory.Type.LANGUAGE_CARD, computer);
|
||||
languageCard2 = new PagedMemory(0x1000, PagedMemory.Type.LANGUAGE_CARD, computer);
|
||||
activeRead = new PagedMemory(0x10000, PagedMemory.Type.RAM, computer);
|
||||
activeWrite = new PagedMemory(0x10000, PagedMemory.Type.RAM, computer);
|
||||
blank = new PagedMemory(0x100, PagedMemory.Type.RAM, computer);
|
||||
|
||||
// Format memory with FF FF 00 00 pattern
|
||||
for (int i = 0; i < 0x0100; i++) {
|
||||
|
@ -23,7 +23,6 @@ import jace.apple2e.softswitch.KeyboardSoftSwitch;
|
||||
import jace.apple2e.softswitch.Memory2SoftSwitch;
|
||||
import jace.apple2e.softswitch.MemorySoftSwitch;
|
||||
import jace.apple2e.softswitch.VideoSoftSwitch;
|
||||
import jace.core.Computer;
|
||||
import jace.core.RAMEvent;
|
||||
import jace.core.SoftSwitch;
|
||||
|
||||
|
@ -158,6 +158,7 @@ public class Speaker extends Device {
|
||||
|
||||
/**
|
||||
* Creates a new instance of Speaker
|
||||
* @param computer
|
||||
*/
|
||||
public Speaker(Computer computer) {
|
||||
super(computer);
|
||||
|
@ -42,7 +42,7 @@ public class VideoDHGR extends Video {
|
||||
// Reorder bits 3,2,1,0 -> 0,3,2,1
|
||||
// Fixes double-hires color palette
|
||||
|
||||
public final static int flipNybble[] = {
|
||||
public final static int[] FLIP_NYBBLE = {
|
||||
0, 2, 4, 6,
|
||||
8, 10, 12, 14,
|
||||
1, 3, 5, 7,
|
||||
@ -63,12 +63,13 @@ public class VideoDHGR extends Video {
|
||||
private VideoWriter dhiresPage1;
|
||||
private VideoWriter dhiresPage2;
|
||||
// Mixed mode
|
||||
private VideoWriter mixed;
|
||||
private final VideoWriter mixed;
|
||||
private VideoWriter currentGraphicsWriter = null;
|
||||
private VideoWriter currentTextWriter = null;
|
||||
|
||||
/**
|
||||
* Creates a new instance of VideoDHGR
|
||||
* @param computer
|
||||
*/
|
||||
public VideoDHGR(Computer computer) {
|
||||
super(computer);
|
||||
@ -310,7 +311,7 @@ public class VideoDHGR extends Video {
|
||||
dhgrWord |= (0x07f & b2) << 7;
|
||||
dhgrWord |= (0x07f & b3) << 14;
|
||||
dhgrWord |= (0x07f & b4) << 21;
|
||||
showDhgr(screen, times14[xOffset], y, dhgrWord);
|
||||
showDhgr(screen, TIMES_14[xOffset], y, dhgrWord);
|
||||
}
|
||||
boolean extraHalfBit = false;
|
||||
|
||||
@ -321,35 +322,35 @@ public class VideoDHGR extends Video {
|
||||
}
|
||||
int b1 = 0x0ff & ((RAM128k) computer.getMemory()).getMainMemory().readByte(rowAddress + xOffset);
|
||||
int b2 = 0x0ff & ((RAM128k) computer.getMemory()).getMainMemory().readByte(rowAddress + xOffset + 1);
|
||||
int dhgrWord = hgrToDhgr[(extraHalfBit && xOffset > 0) ? b1 | 0x0100 : b1][b2];
|
||||
int dhgrWord = HGR_TO_DHGR[(extraHalfBit && xOffset > 0) ? b1 | 0x0100 : b1][b2];
|
||||
extraHalfBit = (dhgrWord & 0x10000000) != 0;
|
||||
showDhgr(screen, times14[xOffset], y, dhgrWord & 0xfffffff);
|
||||
showDhgr(screen, TIMES_14[xOffset], y, dhgrWord & 0xfffffff);
|
||||
// If you want monochrome, use this instead...
|
||||
// showBW(screen, times14[xOffset], y, dhgrWord);
|
||||
}
|
||||
// Take two consecutive bytes and double them, taking hi-bit into account
|
||||
// This should yield a 28-bit word of 7 color dhgr pixels
|
||||
// This looks like crap on text...
|
||||
static final int[][] hgrToDhgr;
|
||||
static final int[][] HGR_TO_DHGR;
|
||||
// Take two consecutive bytes and double them, disregarding hi-bit
|
||||
// Useful for text mode
|
||||
static final int[][] hgrToDhgrBW;
|
||||
static final int[] times14;
|
||||
static final int[] flipBits;
|
||||
static final int[][] HGR_TO_DHGR_BW;
|
||||
static final int[] TIMES_14;
|
||||
static final int[] FLIP_BITS;
|
||||
|
||||
static {
|
||||
// complete reverse of 8 bits
|
||||
flipBits = new int[256];
|
||||
FLIP_BITS = new int[256];
|
||||
for (int i = 0; i < 256; i++) {
|
||||
flipBits[i] = (((i * 0x0802 & 0x22110) | (i * 0x8020 & 0x88440)) * 0x10101 >> 16) & 0x0ff;
|
||||
FLIP_BITS[i] = (((i * 0x0802 & 0x22110) | (i * 0x8020 & 0x88440)) * 0x10101 >> 16) & 0x0ff;
|
||||
}
|
||||
|
||||
times14 = new int[40];
|
||||
TIMES_14 = new int[40];
|
||||
for (int i = 0; i < 40; i++) {
|
||||
times14[i] = i * 14;
|
||||
TIMES_14[i] = i * 14;
|
||||
}
|
||||
hgrToDhgr = new int[512][256];
|
||||
hgrToDhgrBW = new int[256][256];
|
||||
HGR_TO_DHGR = new int[512][256];
|
||||
HGR_TO_DHGR_BW = new int[256][256];
|
||||
for (int bb1 = 0; bb1 < 512; bb1++) {
|
||||
for (int bb2 = 0; bb2 < 256; bb2++) {
|
||||
int value = ((bb1 & 0x0181) >= 0x0101) ? 1 : 0;
|
||||
@ -368,8 +369,8 @@ public class VideoDHGR extends Video {
|
||||
if ((bb2 & 0x040) != 0) {
|
||||
value |= 0x10000000;
|
||||
}
|
||||
hgrToDhgr[bb1][bb2] = value;
|
||||
hgrToDhgrBW[bb1 & 0x0ff][bb2]
|
||||
HGR_TO_DHGR[bb1][bb2] = value;
|
||||
HGR_TO_DHGR_BW[bb1 & 0x0ff][bb2]
|
||||
= byteDoubler((byte) bb1) | (byteDoubler((byte) bb2) << 14);
|
||||
}
|
||||
}
|
||||
@ -385,21 +386,21 @@ public class VideoDHGR extends Video {
|
||||
Color color = Palette.color[c1];
|
||||
// Unrolled loop, faster
|
||||
PixelWriter writer = screen.getPixelWriter();
|
||||
int x = xOffset * 7;
|
||||
writer.setColor(x++, y, color);
|
||||
writer.setColor(x++, y, color);
|
||||
writer.setColor(x++, y, color);
|
||||
writer.setColor(x++, y, color);
|
||||
writer.setColor(x++, y, color);
|
||||
writer.setColor(x++, y, color);
|
||||
writer.setColor(x++, y, color);
|
||||
writer.setColor(x++, y, color);
|
||||
writer.setColor(x++, y, color);
|
||||
writer.setColor(x++, y, color);
|
||||
writer.setColor(x++, y, color);
|
||||
writer.setColor(x++, y, color);
|
||||
writer.setColor(x++, y, color);
|
||||
writer.setColor(x++, y, color);
|
||||
int xx = xOffset * 7;
|
||||
writer.setColor(xx++, y, color);
|
||||
writer.setColor(xx++, y, color);
|
||||
writer.setColor(xx++, y, color);
|
||||
writer.setColor(xx++, y, color);
|
||||
writer.setColor(xx++, y, color);
|
||||
writer.setColor(xx++, y, color);
|
||||
writer.setColor(xx++, y, color);
|
||||
writer.setColor(xx++, y, color);
|
||||
writer.setColor(xx++, y, color);
|
||||
writer.setColor(xx++, y, color);
|
||||
writer.setColor(xx++, y, color);
|
||||
writer.setColor(xx++, y, color);
|
||||
writer.setColor(xx++, y, color);
|
||||
writer.setColor(xx++, y, color);
|
||||
}
|
||||
|
||||
protected void displayDoubleLores(WritableImage screen, int xOffset, int y, int rowAddress) {
|
||||
@ -416,22 +417,22 @@ public class VideoDHGR extends Video {
|
||||
// int yOffset = xyOffset[y][times14[xOffset]];
|
||||
Color color = Palette.color[c1];
|
||||
// Unrolled loop, faster
|
||||
int x = xOffset * 7;
|
||||
writer.setColor(x++, y, color);
|
||||
writer.setColor(x++, y, color);
|
||||
writer.setColor(x++, y, color);
|
||||
writer.setColor(x++, y, color);
|
||||
writer.setColor(x++, y, color);
|
||||
writer.setColor(x++, y, color);
|
||||
writer.setColor(x++, y, color);
|
||||
int xx = xOffset * 7;
|
||||
writer.setColor(xx++, y, color);
|
||||
writer.setColor(xx++, y, color);
|
||||
writer.setColor(xx++, y, color);
|
||||
writer.setColor(xx++, y, color);
|
||||
writer.setColor(xx++, y, color);
|
||||
writer.setColor(xx++, y, color);
|
||||
writer.setColor(xx++, y, color);
|
||||
color = Palette.color[c2];
|
||||
writer.setColor(x++, y, color);
|
||||
writer.setColor(x++, y, color);
|
||||
writer.setColor(x++, y, color);
|
||||
writer.setColor(x++, y, color);
|
||||
writer.setColor(x++, y, color);
|
||||
writer.setColor(x++, y, color);
|
||||
writer.setColor(x++, y, color);
|
||||
writer.setColor(xx++, y, color);
|
||||
writer.setColor(xx++, y, color);
|
||||
writer.setColor(xx++, y, color);
|
||||
writer.setColor(xx++, y, color);
|
||||
writer.setColor(xx++, y, color);
|
||||
writer.setColor(xx++, y, color);
|
||||
writer.setColor(xx++, y, color);
|
||||
}
|
||||
boolean flashInverse = false;
|
||||
int flashTimer = 0;
|
||||
@ -556,8 +557,8 @@ public class VideoDHGR extends Video {
|
||||
int b2 = Font.getByte(c2, yOffset);
|
||||
// Why is this getting inversed now? Bug in hgrToDhgrBW?
|
||||
// Nick says: are you getting confused because the //e video ROM is inverted? (1=black)
|
||||
int out = hgrToDhgrBW[b1][b2];
|
||||
showBW(screen, times14[xOffset], y, out);
|
||||
int out = HGR_TO_DHGR_BW[b1][b2];
|
||||
showBW(screen, TIMES_14[xOffset], y, out);
|
||||
}
|
||||
|
||||
protected void displayText80(WritableImage screen, int xOffset, int y, int rowAddress) {
|
||||
@ -572,7 +573,7 @@ public class VideoDHGR extends Video {
|
||||
int c4 = getFontChar(((RAM128k) computer.getMemory()).getMainMemory().readByte(rowAddress + xOffset + 1));
|
||||
int bits = Font.getByte(c1, yOffset) | (Font.getByte(c2, yOffset) << 7)
|
||||
| (Font.getByte(c3, yOffset) << 14) | (Font.getByte(c4, yOffset) << 21);
|
||||
showBW(screen, times14[xOffset], y, bits);
|
||||
showBW(screen, TIMES_14[xOffset], y, bits);
|
||||
}
|
||||
|
||||
private void displayMixed(WritableImage screen, int xOffset, int y, int textOffset, int graphicsOffset) {
|
||||
@ -612,15 +613,15 @@ public class VideoDHGR extends Video {
|
||||
|
||||
protected void showDhgr(WritableImage screen, int xOffset, int y, int dhgrWord) {
|
||||
//Graphics2D g = (Graphics2D) screen.getGraphics();
|
||||
int x = xOffset * 7;
|
||||
int xx = xOffset * 7;
|
||||
PixelWriter writer = screen.getPixelWriter();
|
||||
try {
|
||||
for (int i = 0; i < 7; i++) {
|
||||
Color color = Palette.color[flipNybble[dhgrWord & 15]];
|
||||
writer.setColor(x++, y, color);
|
||||
writer.setColor(x++, y, color);
|
||||
writer.setColor(x++, y, color);
|
||||
writer.setColor(x++, y, color);
|
||||
Color color = Palette.color[FLIP_NYBBLE[dhgrWord & 15]];
|
||||
writer.setColor(xx++, y, color);
|
||||
writer.setColor(xx++, y, color);
|
||||
writer.setColor(xx++, y, color);
|
||||
writer.setColor(xx++, y, color);
|
||||
dhgrWord >>= 4;
|
||||
}
|
||||
} catch (ArrayIndexOutOfBoundsException ex) {
|
||||
@ -629,19 +630,18 @@ public class VideoDHGR extends Video {
|
||||
}
|
||||
static final Color BLACK = Color.BLACK;
|
||||
static final Color WHITE = Color.WHITE;
|
||||
static final int[][] xyOffset;
|
||||
static final int[][] XY_OFFSET;
|
||||
|
||||
static {
|
||||
xyOffset = new int[192][560];
|
||||
XY_OFFSET = new int[192][560];
|
||||
for (int y = 0; y < 192; y++) {
|
||||
for (int x = 0; x < 560; x++) {
|
||||
xyOffset[y][x] = y * 560 + x;
|
||||
XY_OFFSET[y][x] = y * 560 + x;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void showBW(WritableImage screen, int xOffset, int y, int dhgrWord) {
|
||||
int color = 0;
|
||||
// Using the data buffer directly is about 15 times faster than setRGB
|
||||
// This is because setRGB does extra (useless) color model logic
|
||||
// For that matter even Graphics.drawLine is faster than setRGB!
|
||||
@ -649,11 +649,11 @@ public class VideoDHGR extends Video {
|
||||
// Also, adding xOffset now makes it additionally 5% faster
|
||||
//int yOffset = ((y << 4) + (y << 5) + (y << 9))+xOffset;
|
||||
|
||||
int x = xOffset * 7;
|
||||
int xx = xOffset * 7;
|
||||
PixelWriter writer = screen.getPixelWriter();
|
||||
for (int i = 0; i < 28; i++) {
|
||||
// yOffset++ is used instead of yOffset+i, because it is faster
|
||||
writer.setColor(x++, y, (dhgrWord & 1) == 1 ? WHITE : BLACK);
|
||||
writer.setColor(xx++, y, (dhgrWord & 1) == 1 ? WHITE : BLACK);
|
||||
dhgrWord >>= 1;
|
||||
}
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ public class VideoNTSC extends VideoDHGR {
|
||||
|
||||
@ConfigurableField(name = "Text palette", shortName = "textPalette", defaultValue = "false", description = "Use text-friendly color palette")
|
||||
public boolean useTextPalette = true;
|
||||
int activePalette[][] = textPalette;
|
||||
int activePalette[][] = TEXT_PALETTE;
|
||||
@ConfigurableField(name = "Video 7", shortName = "video7", defaultValue = "true", description = "Enable Video 7 RGB rendering support")
|
||||
public boolean enableVideo7 = true;
|
||||
// Scanline represents 560 bits, divided up into 28-bit words
|
||||
@ -183,7 +183,7 @@ public class VideoNTSC extends VideoDHGR {
|
||||
add = (scanline[s + 1] & 7);
|
||||
}
|
||||
boolean isBW = false;
|
||||
boolean mixed = enableVideo7 && dhgrMode && graphicsMode == rgbMode.mix;
|
||||
boolean mixed = enableVideo7 && dhgrMode && graphicsMode == rgbMode.MIX;
|
||||
for (int i = 0; i < 28; i++) {
|
||||
if (i % 7 == 0) {
|
||||
isBW = !colorActive[byteCounter] || (mixed && !hiresMode && !useColor[byteCounter]);
|
||||
@ -217,9 +217,9 @@ public class VideoNTSC extends VideoDHGR {
|
||||
public static final double MAX_I = 0.5957;
|
||||
// q Range [-0.5226, 0.5226]
|
||||
public static final double MAX_Q = 0.5226;
|
||||
static final int solidPalette[][] = new int[4][128];
|
||||
static final int textPalette[][] = new int[4][128];
|
||||
static final double[][] yiq = {
|
||||
static final int SOLID_PALETTE[][] = new int[4][128];
|
||||
static final int[][] TEXT_PALETTE = new int[4][128];
|
||||
static final double[][] YIQ_VALUES = {
|
||||
{0.0, 0.0, 0.0}, //0000 0
|
||||
{0.25, 0.5, 0.5}, //0001 1
|
||||
{0.25, -0.5, 0.5}, //0010 2
|
||||
@ -253,10 +253,10 @@ public class VideoNTSC extends VideoDHGR {
|
||||
for (int rot = 0; rot < offset; rot++) {
|
||||
col = ((col & 8) >> 3) | ((col << 1) & 0x0f);
|
||||
}
|
||||
double y1 = yiq[col][0];
|
||||
double y1 = YIQ_VALUES[col][0];
|
||||
double y2 = ((double) level / (double) maxLevel);
|
||||
solidPalette[offset][pattern] = yiqToRgb(y1, yiq[col][1] * MAX_I, yiq[col][2] * MAX_Q);
|
||||
textPalette[offset][pattern] = yiqToRgb(y2, yiq[col][1] * MAX_I, yiq[col][2] * MAX_Q);
|
||||
SOLID_PALETTE[offset][pattern] = yiqToRgb(y1, YIQ_VALUES[col][1] * MAX_I, YIQ_VALUES[col][2] * MAX_Q);
|
||||
TEXT_PALETTE[offset][pattern] = yiqToRgb(y2, YIQ_VALUES[col][1] * MAX_I, YIQ_VALUES[col][2] * MAX_Q);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -280,7 +280,7 @@ public class VideoNTSC extends VideoDHGR {
|
||||
|
||||
@Override
|
||||
public void reconfigure() {
|
||||
activePalette = useTextPalette ? textPalette : solidPalette;
|
||||
activePalette = useTextPalette ? TEXT_PALETTE : SOLID_PALETTE;
|
||||
super.reconfigure();
|
||||
}
|
||||
// The following section captures changes to the RGB mode
|
||||
@ -288,11 +288,11 @@ public class VideoNTSC extends VideoDHGR {
|
||||
// http://www.freepatentsonline.com/4631692.pdf
|
||||
// as well as the AppleColor adapter card manual
|
||||
// http://apple2.info/download/Ext80ColumnAppleColorCardHR.pdf
|
||||
rgbMode graphicsMode = rgbMode.mix;
|
||||
rgbMode graphicsMode = rgbMode.MIX;
|
||||
|
||||
public static enum rgbMode {
|
||||
|
||||
color(true), mix(true), bw(false), _160col(false);
|
||||
COLOR(true), MIX(true), BW(false), COL_160(false);
|
||||
boolean colorMode = false;
|
||||
|
||||
rgbMode(boolean c) {
|
||||
@ -333,7 +333,7 @@ public class VideoNTSC extends VideoDHGR {
|
||||
// 1) 160-column mode isn't implemented so it's not worth bothering to capture that state
|
||||
// 2) A lot of programs are clueless about RGB modes so it's good to default to normal color mode
|
||||
// graphicsMode = f1 ? (f2 ? rgbMode.color : rgbMode.mix) : (f2 ? rgbMode._160col : rgbMode.bw);
|
||||
graphicsMode = f1 ? (f2 ? rgbMode.color : rgbMode.mix) : (f2 ? rgbMode.color : rgbMode.bw);
|
||||
graphicsMode = f1 ? (f2 ? rgbMode.COLOR : rgbMode.MIX) : (f2 ? rgbMode.COLOR : rgbMode.BW);
|
||||
// System.out.println(state + ": "+ graphicsMode);
|
||||
}
|
||||
// These catch changes to the RGB mode to toggle between color, BW and mixed
|
||||
@ -384,7 +384,7 @@ public class VideoNTSC extends VideoDHGR {
|
||||
((VideoNTSC) v).f1 = true;
|
||||
((VideoNTSC) v).f2 = true;
|
||||
((VideoNTSC) v).an3 = false;
|
||||
((VideoNTSC) v).graphicsMode = rgbMode.color;
|
||||
((VideoNTSC) v).graphicsMode = rgbMode.COLOR;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -19,7 +19,6 @@
|
||||
package jace.apple2e.softswitch;
|
||||
|
||||
import jace.apple2e.SoftSwitches;
|
||||
import jace.core.Computer;
|
||||
import jace.core.RAMEvent;
|
||||
import jace.core.RAMListener;
|
||||
import jace.core.SoftSwitch;
|
||||
@ -58,6 +57,7 @@ public class IntC8SoftSwitch extends SoftSwitch {
|
||||
// INTCXRom shoud deactivate whenever CFFF is accessed
|
||||
addListener(
|
||||
new RAMListener(RAMEvent.TYPE.ANY, RAMEvent.SCOPE.ADDRESS, RAMEvent.VALUE.ANY) {
|
||||
@Override
|
||||
protected void doConfig() {
|
||||
setScopeStart(0x0CFFF);
|
||||
}
|
||||
|
@ -35,6 +35,7 @@ public class KeyboardSoftSwitch extends SoftSwitch {
|
||||
super(name,offAddrs,onAddrs,queryAddrs,changeType,initalState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stateChanged() {
|
||||
Keyboard.clearStrobe();
|
||||
}
|
||||
|
@ -18,7 +18,6 @@
|
||||
*/
|
||||
package jace.cheat;
|
||||
|
||||
import jace.Emulator;
|
||||
import jace.EmulatorUILogic;
|
||||
import jace.apple2e.RAM128k;
|
||||
import jace.apple2e.SoftSwitches;
|
||||
@ -98,7 +97,7 @@ public class PrinceOfPersiaCheats extends Cheats {
|
||||
public static int InEditor = 0x0202;
|
||||
public static int MinLeft = 0x0300;
|
||||
public static int hasSword = 0x030a;
|
||||
public static final int mobtables = 0x0b600;
|
||||
public static int mobtables = 0x0b600;
|
||||
public static final int trloc = mobtables;
|
||||
public static final int trscrn = trloc + 0x020;
|
||||
public static int trdirec = trscrn + 0x020;
|
||||
|
@ -35,8 +35,8 @@ import jace.apple2e.SoftSwitches;
|
||||
*/
|
||||
public abstract class Card extends Device {
|
||||
|
||||
private PagedMemory cxRom;
|
||||
private PagedMemory c8Rom;
|
||||
private final PagedMemory cxRom;
|
||||
private final PagedMemory c8Rom;
|
||||
private int slot;
|
||||
private RAMListener ioListener;
|
||||
private RAMListener firmwareListener;
|
||||
@ -44,11 +44,12 @@ public abstract class Card extends Device {
|
||||
|
||||
/**
|
||||
* Creates a new instance of Card
|
||||
* @param computer
|
||||
*/
|
||||
public Card(Computer computer) {
|
||||
super(computer);
|
||||
cxRom = new PagedMemory(0x0100, PagedMemory.Type.cardFirmware, computer);
|
||||
c8Rom = new PagedMemory(0x0800, PagedMemory.Type.cardFirmware, computer);
|
||||
cxRom = new PagedMemory(0x0100, PagedMemory.Type.CARD_FIRMWARE, computer);
|
||||
c8Rom = new PagedMemory(0x0800, PagedMemory.Type.CARD_FIRMWARE, computer);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -43,7 +43,7 @@ public abstract class Debugger {
|
||||
public boolean isActive() {
|
||||
return active;
|
||||
}
|
||||
private List<Integer> breakpoints = new ArrayList<Integer>();
|
||||
private final List<Integer> breakpoints = new ArrayList<>();
|
||||
|
||||
public List<Integer> getBreakpoints() {
|
||||
return breakpoints;
|
||||
|
@ -25,6 +25,8 @@ import java.util.HashSet;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* Motherboard is the heart of the computer. It can have a list of cards
|
||||
@ -55,6 +57,7 @@ public class Motherboard extends TimedDevice {
|
||||
|
||||
/**
|
||||
* Creates a new instance of Motherboard
|
||||
* @param computer
|
||||
*/
|
||||
public Motherboard(Computer computer) {
|
||||
super(computer);
|
||||
@ -91,7 +94,7 @@ public class Motherboard extends TimedDevice {
|
||||
m.doTick();
|
||||
});
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, t);
|
||||
}
|
||||
}
|
||||
// From the holy word of Sather 3:5 (Table 3.1) :-)
|
||||
|
@ -35,12 +35,12 @@ public class PagedMemory {
|
||||
|
||||
public enum Type {
|
||||
|
||||
cardFirmware(0x0c800),
|
||||
languageCard(0x0d000),
|
||||
firmwareMain(0x0d000),
|
||||
firmware80column(0x0c300),
|
||||
slotRom(0x0c100),
|
||||
ram(0x0000);
|
||||
CARD_FIRMWARE(0x0c800),
|
||||
LANGUAGE_CARD(0x0d000),
|
||||
FIRMWARE_MAIN(0x0d000),
|
||||
FIRMWARE_80COL(0x0c300),
|
||||
SLOW_ROM(0x0c100),
|
||||
RAM(0x0000);
|
||||
protected int baseAddress;
|
||||
|
||||
private Type(int newBase) {
|
||||
|
@ -72,6 +72,12 @@ public class RAMEvent {
|
||||
|
||||
/**
|
||||
* Creates a new instance of RAMEvent
|
||||
* @param t
|
||||
* @param s
|
||||
* @param v
|
||||
* @param address
|
||||
* @param oldValue
|
||||
* @param newValue
|
||||
*/
|
||||
public RAMEvent(TYPE t, SCOPE s, VALUE v, int address, int oldValue, int newValue) {
|
||||
setType(t);
|
||||
|
@ -42,6 +42,9 @@ public abstract class RAMListener {
|
||||
|
||||
/**
|
||||
* Creates a new instance of RAMListener
|
||||
* @param t
|
||||
* @param s
|
||||
* @param v
|
||||
*/
|
||||
public RAMListener(RAMEvent.TYPE t, RAMEvent.SCOPE s, RAMEvent.VALUE v) {
|
||||
setType(t);
|
||||
|
@ -231,7 +231,7 @@ public class SoundMixer extends Device {
|
||||
}
|
||||
|
||||
private void initMixer() {
|
||||
Info selected = null;
|
||||
Info selected;
|
||||
Info[] mixerInfo = AudioSystem.getMixerInfo();
|
||||
|
||||
if (mixerInfo == null || mixerInfo.length == 0) {
|
||||
|
@ -30,6 +30,7 @@ public abstract class TimedDevice extends Device {
|
||||
|
||||
/**
|
||||
* Creates a new instance of TimedDevice
|
||||
* @param computer
|
||||
*/
|
||||
public TimedDevice(Computer computer) {
|
||||
super(computer);
|
||||
|
@ -288,7 +288,6 @@ public class Utility {
|
||||
public static Label loadIconLabel(String filename) {
|
||||
Image img = loadIcon(filename);
|
||||
Label label = new Label() {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof Label) {
|
||||
@ -299,6 +298,10 @@ public class Utility {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return getText().hashCode();
|
||||
}
|
||||
};
|
||||
label.setGraphic(new ImageView(img));
|
||||
label.setAlignment(Pos.CENTER);
|
||||
|
@ -89,6 +89,7 @@ public abstract class Video extends Device {
|
||||
|
||||
/**
|
||||
* Creates a new instance of Video
|
||||
* @param computer
|
||||
*/
|
||||
public Video(Computer computer) {
|
||||
super(computer);
|
||||
|
@ -48,9 +48,9 @@ public class CardExt80Col extends RAM128k {
|
||||
|
||||
public CardExt80Col(Computer computer) {
|
||||
super(computer);
|
||||
auxMemory = new PagedMemory(0xc000, PagedMemory.Type.ram, computer);
|
||||
auxLanguageCard = new PagedMemory(0x3000, PagedMemory.Type.languageCard, computer);
|
||||
auxLanguageCard2 = new PagedMemory(0x1000, PagedMemory.Type.languageCard, computer);
|
||||
auxMemory = new PagedMemory(0xc000, PagedMemory.Type.RAM, computer);
|
||||
auxLanguageCard = new PagedMemory(0x3000, PagedMemory.Type.LANGUAGE_CARD, computer);
|
||||
auxLanguageCard2 = new PagedMemory(0x1000, PagedMemory.Type.LANGUAGE_CARD, computer);
|
||||
initMemoryPattern(auxMemory);
|
||||
}
|
||||
|
||||
|
@ -54,9 +54,9 @@ public class CardRamworks extends RAM128k {
|
||||
public int maxBank = memorySize / 64;
|
||||
private Map<BankType, PagedMemory> generateBank() {
|
||||
Map<BankType, PagedMemory> memoryBank = new EnumMap<>(BankType.class);
|
||||
memoryBank.put(BankType.MAIN_MEMORY, new PagedMemory(0xc000, PagedMemory.Type.ram, computer));
|
||||
memoryBank.put(BankType.LANGUAGE_CARD_1, new PagedMemory(0x3000, PagedMemory.Type.languageCard, computer));
|
||||
memoryBank.put(BankType.LANGUAGE_CARD_2, new PagedMemory(0x1000, PagedMemory.Type.languageCard, computer));
|
||||
memoryBank.put(BankType.MAIN_MEMORY, new PagedMemory(0xc000, PagedMemory.Type.RAM, computer));
|
||||
memoryBank.put(BankType.LANGUAGE_CARD_1, new PagedMemory(0x3000, PagedMemory.Type.LANGUAGE_CARD, computer));
|
||||
memoryBank.put(BankType.LANGUAGE_CARD_2, new PagedMemory(0x1000, PagedMemory.Type.LANGUAGE_CARD, computer));
|
||||
return memoryBank;
|
||||
}
|
||||
|
||||
|
@ -55,7 +55,7 @@ public class CardSSC extends Card implements Reconfigurable {
|
||||
protected Thread listenThread;
|
||||
private int lastInputByte = 0;
|
||||
private boolean FULL_ECHO = true;
|
||||
private boolean RECV_ACTIVE = true;
|
||||
private final boolean RECV_ACTIVE = true;
|
||||
private boolean TRANS_ACTIVE = true;
|
||||
// private boolean RECV_STRIP_LF = true;
|
||||
// private boolean TRANS_ADD_LF = true;
|
||||
@ -85,7 +85,7 @@ public class CardSSC extends Card implements Reconfigurable {
|
||||
// 1 stop bit (SW2-1 on)
|
||||
// 8 data bits (SW2-2 on)
|
||||
// No parity (SW2-3 don't care, SW2-4 off)
|
||||
private int SW2_SETTING = 0x04;
|
||||
private final int SW2_SETTING = 0x04;
|
||||
public int ACIA_Data = 0x08; // Read=Receive / Write=transmit
|
||||
public int ACIA_Status = 0x09; // Read=Status / Write=Reset
|
||||
public int ACIA_Command = 0x0A;
|
||||
@ -343,7 +343,6 @@ public class CardSSC extends Card implements Reconfigurable {
|
||||
}
|
||||
if (newValue > -1) {
|
||||
e.setNewValue(newValue);
|
||||
value = newValue;
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
Logger.getLogger(CardSSC.class.getName()).log(Level.SEVERE, null, ex);
|
||||
|
@ -292,6 +292,7 @@ public class CardThunderclock extends Card {
|
||||
* Scan active memory for the Prodos clock driver and patch the internal
|
||||
* code to use a fixed value for the present year. This means Prodos will
|
||||
* always tell time correctly.
|
||||
* @param computer
|
||||
*/
|
||||
public static void performProdosPatch(Computer computer) {
|
||||
PagedMemory ram = computer.getMemory().activeRead;
|
||||
|
@ -209,7 +209,7 @@ public class DiskIIDrive implements MediaConsumer {
|
||||
lastWriteTime = System.currentTimeMillis();
|
||||
if (writerThread == null || !writerThread.isAlive()) {
|
||||
writerThread = new Thread(() -> {
|
||||
long diff = 0;
|
||||
long diff;
|
||||
// Wait until there have been no virtual writes for specified delay time
|
||||
while ((diff = System.currentTimeMillis() - lastWriteTime) < WRITE_UPDATE_DELAY) {
|
||||
// Sleep for difference of time
|
||||
|
@ -33,8 +33,8 @@ import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* Representation of a 140kb floppy disk image. This also performs conversions as
|
||||
* needed. Internally, the emulator will always use a "nibblized" disk
|
||||
* Representation of a 140kb floppy disk image. This also performs conversions
|
||||
* as needed. Internally, the emulator will always use a "nibblized" disk
|
||||
* representation during active use. So if any sort of dsk/do/po image is loaded
|
||||
* it will be converted first. If changes are made to the disk then the tracks
|
||||
* will be converted back into de-nibblized form prior to saving. The
|
||||
@ -42,7 +42,7 @@ import java.util.logging.Logger;
|
||||
* load/save various disk formats and hold the active disk image while it is in
|
||||
* use.
|
||||
*
|
||||
* @author Brendan Robert (BLuRry) brendan.robert@gmail.com
|
||||
* @author Brendan Robert (BLuRry) brendan.robert@gmail.com
|
||||
*/
|
||||
@Stateful
|
||||
public class FloppyDisk {
|
||||
@ -108,6 +108,7 @@ public class FloppyDisk {
|
||||
/**
|
||||
*
|
||||
* @param diskFile
|
||||
* @param computer
|
||||
* @throws IOException
|
||||
*/
|
||||
public FloppyDisk(File diskFile, Computer computer) throws IOException {
|
||||
@ -278,13 +279,12 @@ public class FloppyDisk {
|
||||
}
|
||||
|
||||
void updateNibblizedTrack(Integer track) {
|
||||
try {
|
||||
RandomAccessFile disk = new RandomAccessFile(diskPath, "rws");
|
||||
// Locate start of track
|
||||
try (RandomAccessFile disk = new RandomAccessFile(diskPath, "rws")) {
|
||||
// Locate start of track
|
||||
disk.seek(headerLength + track * TRACK_NIBBLE_LENGTH);
|
||||
// Update that section of the disk image
|
||||
disk.write(nibbles, track * TRACK_NIBBLE_LENGTH, TRACK_NIBBLE_LENGTH);
|
||||
disk.close();
|
||||
} catch (FileNotFoundException ex) {
|
||||
Logger.getLogger(FloppyDisk.class.getName()).log(Level.SEVERE, null, ex);
|
||||
} catch (IOException ex) {
|
||||
|
@ -55,7 +55,7 @@ public class PassportMidiInterface extends Card {
|
||||
// MIDI timing: 31250 BPS, 8-N-1 (roughly 3472k per second)
|
||||
public static enum TIMER_MODE {
|
||||
|
||||
continuous, singleShot, freqComparison, pulseComparison
|
||||
CONTINUOUS, SINGLE_SHOT, FREQ_COMPARISON, PULSE_COMPARISON
|
||||
};
|
||||
|
||||
public static class PTMTimer {
|
||||
@ -64,7 +64,7 @@ public class PassportMidiInterface extends Card {
|
||||
public boolean prescaledTimer = false; // Only available on Timer 3
|
||||
public boolean enableClock = false; // False == use CX clock input
|
||||
public boolean dual8BitMode = false;
|
||||
public TIMER_MODE mode = TIMER_MODE.continuous;
|
||||
public TIMER_MODE mode = TIMER_MODE.CONTINUOUS;
|
||||
public boolean irqEnabled = false;
|
||||
public boolean counterOutputEnable = false;
|
||||
// Set by data latches
|
||||
@ -102,12 +102,12 @@ public class PassportMidiInterface extends Card {
|
||||
public static final int PTM_SELECT_REG_1 = 1;
|
||||
public static final int PTM_SELECT_REG_3 = 0;
|
||||
// PTM select values (register 3 only)
|
||||
public static final int TIMER_3_PRESCALED = 1;
|
||||
public static final int TIMER_3_NOT_PRESCALED = 0;
|
||||
public static final int TIMER3_PRESCALED = 1;
|
||||
public static final int TIMER3_NOT_PRESCALED = 0;
|
||||
// PTM bit values
|
||||
public static final int PTM_CLOCK_SOURCE = 2; // Bit 1
|
||||
// 0 = external, 2 = internal clock
|
||||
public static final int PTM_LATCH_IS_16_BIT = 4; // Bit 2
|
||||
public static final int PTM_LATCH_IS_16BIT = 4; // Bit 2
|
||||
// 0 = 16-bit, 4 = dual 8-bit
|
||||
// Bits 3-5
|
||||
// 5 4 3
|
||||
@ -150,24 +150,24 @@ public class PassportMidiInterface extends Card {
|
||||
// PTM configuration
|
||||
private boolean ptmTimer3Selected = false; // When true, reg 1 points at timer 3
|
||||
private boolean ptmTimersActive = false; // When true, timers run constantly
|
||||
private PTMTimer[] ptmTimer = {
|
||||
private final PTMTimer[] ptmTimer = {
|
||||
new PTMTimer(),
|
||||
new PTMTimer(),
|
||||
new PTMTimer()
|
||||
};
|
||||
private boolean ptmStatusReadSinceIRQ = false;
|
||||
// ---------------------- ACIA CONFIGURATION
|
||||
private boolean aciaInterruptOnSend = false;
|
||||
private boolean aciaInterruptOnReceive = false;
|
||||
private final boolean aciaInterruptOnSend = false;
|
||||
private final boolean aciaInterruptOnReceive = false;
|
||||
// ---------------------- ACIA STATUS BITS
|
||||
// True when MIDI IN receives a byte
|
||||
private boolean receivedACIAByte = false;
|
||||
private final boolean receivedACIAByte = false;
|
||||
// True when data is not transmitting (always true because we aren't really doing wire transmission);
|
||||
private boolean transmitACIAEmpty = true;
|
||||
private final boolean transmitACIAEmpty = true;
|
||||
// True if another byte is received before the previous byte was processed
|
||||
private boolean receiverACIAOverrun = false;
|
||||
private final boolean receiverACIAOverrun = false;
|
||||
// True if ACIA generated interrupt request
|
||||
private boolean irqRequestedACIA = false;
|
||||
private final boolean irqRequestedACIA = false;
|
||||
//--- the synth
|
||||
private Synthesizer synth;
|
||||
|
||||
@ -187,7 +187,6 @@ public class PassportMidiInterface extends Card {
|
||||
@Override
|
||||
protected void handleFirmwareAccess(int register, TYPE type, int value, RAMEvent e) {
|
||||
// No firmware, so do nothing
|
||||
return;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -266,7 +265,7 @@ public class PassportMidiInterface extends Card {
|
||||
case TIMER_CONTROL_1:
|
||||
if (ptmTimer3Selected) {
|
||||
// System.out.println("Configuring timer 3");
|
||||
ptmTimer[2].prescaledTimer = ((v & TIMER_3_PRESCALED) != 0);
|
||||
ptmTimer[2].prescaledTimer = ((v & TIMER3_PRESCALED) != 0);
|
||||
processPTMConfiguration(ptmTimer[2], v);
|
||||
} else {
|
||||
// System.out.println("Configuring timer 1");
|
||||
@ -325,7 +324,7 @@ public class PassportMidiInterface extends Card {
|
||||
computer.getCpu().generateInterrupt();
|
||||
ptmStatusReadSinceIRQ = false;
|
||||
}
|
||||
if (t.mode == TIMER_MODE.continuous || t.mode == TIMER_MODE.freqComparison) {
|
||||
if (t.mode == TIMER_MODE.CONTINUOUS || t.mode == TIMER_MODE.FREQ_COMPARISON) {
|
||||
t.value = t.duration;
|
||||
}
|
||||
}
|
||||
@ -341,23 +340,23 @@ public class PassportMidiInterface extends Card {
|
||||
//------------------------------------------------------ PTM
|
||||
private void processPTMConfiguration(PTMTimer timer, int val) {
|
||||
timer.enableClock = (val & PTM_CLOCK_SOURCE) != 0;
|
||||
timer.dual8BitMode = (val & PTM_LATCH_IS_16_BIT) != 0;
|
||||
timer.dual8BitMode = (val & PTM_LATCH_IS_16BIT) != 0;
|
||||
switch (val & 56) {
|
||||
// Evaluate bits 3, 4 and 5 to determine mode
|
||||
case PTM_CONTINUOUS:
|
||||
timer.mode = TIMER_MODE.continuous;
|
||||
timer.mode = TIMER_MODE.CONTINUOUS;
|
||||
break;
|
||||
case PTM_PULSE_COMP:
|
||||
timer.mode = TIMER_MODE.pulseComparison;
|
||||
timer.mode = TIMER_MODE.PULSE_COMPARISON;
|
||||
break;
|
||||
case PTM_FREQ_COMP:
|
||||
timer.mode = TIMER_MODE.freqComparison;
|
||||
timer.mode = TIMER_MODE.FREQ_COMPARISON;
|
||||
break;
|
||||
case PTM_SINGLE_SHOT:
|
||||
timer.mode = TIMER_MODE.singleShot;
|
||||
timer.mode = TIMER_MODE.SINGLE_SHOT;
|
||||
break;
|
||||
default:
|
||||
timer.mode = TIMER_MODE.continuous;
|
||||
timer.mode = TIMER_MODE.CONTINUOUS;
|
||||
break;
|
||||
}
|
||||
timer.irqEnabled = (val & PTM_IRQ_ENABLED) != 0;
|
||||
@ -483,9 +482,7 @@ public class PassportMidiInterface extends Card {
|
||||
// System.out.println("Sending MIDI message "+currentMessageStatus+","+currentMessageData1+","+currentMessageData2);
|
||||
currentMessage.setMessage(currentMessageStatus, currentMessageData1, currentMessageData2);
|
||||
synth.getReceiver().send(currentMessage, -1L);
|
||||
} catch (InvalidMidiDataException ex) {
|
||||
Logger.getLogger(PassportMidiInterface.class.getName()).log(Level.SEVERE, null, ex);
|
||||
} catch (MidiUnavailableException ex) {
|
||||
} catch (InvalidMidiDataException | MidiUnavailableException ex) {
|
||||
Logger.getLogger(PassportMidiInterface.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
@ -540,7 +537,6 @@ public class PassportMidiInterface extends Card {
|
||||
}
|
||||
} catch (MidiUnavailableException ex) {
|
||||
System.out.println("Could not open MIDI synthesizer");
|
||||
ex.printStackTrace();
|
||||
Logger.getLogger(PassportMidiInterface.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ public abstract class SmartportDriver {
|
||||
cpu.setProgramCounter(callAddress + (extendedCall ? 5 : 3));
|
||||
|
||||
// Calculate parameter address block
|
||||
int parmAddr = 0;
|
||||
int parmAddr;
|
||||
if (!extendedCall) {
|
||||
parmAddr = ram.readWordRaw(callAddress + 1);
|
||||
} else {
|
||||
|
@ -31,7 +31,6 @@ import jace.hardware.SmartportDriver;
|
||||
import jace.library.MediaConsumer;
|
||||
import jace.library.MediaConsumerParent;
|
||||
import java.io.IOException;
|
||||
import java.util.Optional;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
|
@ -23,7 +23,6 @@ import java.io.FileFilter;
|
||||
import java.io.IOException;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.logging.Level;
|
||||
@ -70,11 +69,7 @@ public class DirectoryNode extends DiskNode implements FileFilter {
|
||||
for (File f : files) {
|
||||
addFile(f);
|
||||
}
|
||||
Collections.sort(children, new Comparator<DiskNode>() {
|
||||
public int compare(DiskNode o1, DiskNode o2) {
|
||||
return o1.getName().compareTo(o2.getName());
|
||||
}
|
||||
});
|
||||
Collections.sort(children, (DiskNode o1, DiskNode o2) -> o1.getName().compareTo(o2.getName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -90,7 +85,7 @@ public class DirectoryNode extends DiskNode implements FileFilter {
|
||||
if (!super.checkFile()) {
|
||||
return false;
|
||||
}
|
||||
HashSet<String> realFiles = new HashSet<String>();
|
||||
HashSet<String> realFiles = new HashSet<>();
|
||||
File[] realFileList = physicalFile.listFiles(this);
|
||||
for (File f : realFileList) {
|
||||
realFiles.add(f.getName());
|
||||
@ -112,9 +107,9 @@ public class DirectoryNode extends DiskNode implements FileFilter {
|
||||
if (!realFiles.isEmpty()) {
|
||||
success = false;
|
||||
// New files showed up -- deal with them!
|
||||
for (String fileName : realFiles) {
|
||||
realFiles.stream().forEach((fileName) -> {
|
||||
addFile(new File(physicalFile, fileName));
|
||||
}
|
||||
});
|
||||
}
|
||||
return success;
|
||||
}
|
||||
@ -139,16 +134,14 @@ public class DirectoryNode extends DiskNode implements FileFilter {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean accept(File file) {
|
||||
if (file.getName().endsWith("~")) return false;
|
||||
char c = file.getName().charAt(0);
|
||||
if (c == '.' || c == '~') {
|
||||
return false;
|
||||
}
|
||||
if (file.isHidden()) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return !file.isHidden();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -60,8 +60,8 @@ public abstract class DiskNode {
|
||||
private String name;
|
||||
|
||||
public DiskNode() {
|
||||
additionalNodes = new ArrayList<DiskNode>();
|
||||
children = new ArrayList<DiskNode>();
|
||||
additionalNodes = new ArrayList<>();
|
||||
children = new ArrayList<>();
|
||||
}
|
||||
|
||||
public boolean checkFile() throws IOException {
|
||||
@ -94,9 +94,9 @@ public abstract class DiskNode {
|
||||
allocated = false;
|
||||
additionalNodes.clear();
|
||||
// NOTE: This is recursive!
|
||||
for (DiskNode node : getChildren()) {
|
||||
getChildren().stream().forEach((node) -> {
|
||||
node.deallocate();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -136,14 +136,14 @@ public class FileNode extends DiskNode {
|
||||
@Override
|
||||
public void doAllocate() throws IOException {
|
||||
int dataBlocks = (int) ((getPhysicalFile().length() / ProdosVirtualDisk.BLOCK_SIZE) + 1);
|
||||
int treeBlocks = 0;
|
||||
int treeBlocks;
|
||||
if (dataBlocks > 1 && dataBlocks < 257) {
|
||||
treeBlocks = 1;
|
||||
} else {
|
||||
treeBlocks = 1 + (dataBlocks / 256);
|
||||
}
|
||||
for (int i = 1; i < dataBlocks + treeBlocks; i++) {
|
||||
new SubNode(i, this);
|
||||
SubNode subNode = new SubNode(i, this);
|
||||
}
|
||||
}
|
||||
|
||||
@ -183,10 +183,10 @@ public class FileNode extends DiskNode {
|
||||
}
|
||||
|
||||
private void readFile(byte[] buffer, int start) throws IOException {
|
||||
FileInputStream f = new FileInputStream(physicalFile);
|
||||
f.skip(start * ProdosVirtualDisk.BLOCK_SIZE);
|
||||
f.read(buffer, 0, ProdosVirtualDisk.BLOCK_SIZE);
|
||||
f.close();
|
||||
try (FileInputStream f = new FileInputStream(physicalFile)) {
|
||||
f.skip(start * ProdosVirtualDisk.BLOCK_SIZE);
|
||||
f.read(buffer, 0, ProdosVirtualDisk.BLOCK_SIZE);
|
||||
}
|
||||
}
|
||||
|
||||
private void generateIndex(byte[] buffer, int indexStart, int indexLimit) {
|
||||
|
@ -31,7 +31,7 @@ public class FreespaceBitmap extends DiskNode {
|
||||
setOwnerFilesystem(fs);
|
||||
|
||||
for (int i=1; i < size; i++) {
|
||||
new SubNode(i, this, start+i);
|
||||
SubNode subNode = new SubNode(i, this, start+i);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
|
@ -35,10 +35,16 @@ public class MassStorageDrive implements MediaConsumer {
|
||||
IDisk disk = null;
|
||||
Label icon = null;
|
||||
|
||||
@Override
|
||||
public Label getIcon() {
|
||||
return icon;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param i
|
||||
*/
|
||||
@Override
|
||||
public void setIcon(Label i) {
|
||||
icon = i;
|
||||
}
|
||||
@ -46,6 +52,13 @@ public class MassStorageDrive implements MediaConsumer {
|
||||
MediaEntry currentEntry;
|
||||
MediaFile currentFile;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param e
|
||||
* @param f
|
||||
* @throws IOException
|
||||
*/
|
||||
@Override
|
||||
public void insertMedia(MediaEntry e, MediaFile f) throws IOException {
|
||||
eject();
|
||||
currentEntry = e;
|
||||
@ -61,19 +74,39 @@ public class MassStorageDrive implements MediaConsumer {
|
||||
postInsertAction = r;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public MediaEntry getMediaEntry() {
|
||||
return currentEntry;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public MediaFile getMediaFile() {
|
||||
return currentFile;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param e
|
||||
* @param f
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean isAccepted(MediaEntry e, MediaFile f) {
|
||||
return e.type.isProdosOrdered;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public void eject() {
|
||||
if (disk != null) {
|
||||
disk.eject();
|
||||
|
@ -37,10 +37,10 @@ public class NoiseGenerator extends TimedGenerator {
|
||||
for (int i=0; i < stateChanges; i++)
|
||||
updateRng();
|
||||
}
|
||||
public static final int bit17 = 0x010000;
|
||||
public static final int BIT17 = 0x010000;
|
||||
public void updateRng() {
|
||||
// noise = (noise >> 1) ^ ((noise & 1) ? 0x14000 : 0);
|
||||
int newBit17 = (rng & 0x04) > 0 == (rng & 0x01) > 0 ? bit17 : 0;
|
||||
int newBit17 = (rng & 0x04) > 0 == (rng & 0x01) > 0 ? BIT17 : 0;
|
||||
rng = newBit17 + (rng >> 1);
|
||||
}
|
||||
public boolean isOn() {
|
||||
|
@ -60,7 +60,7 @@ public class SoundGenerator extends TimedGenerator {
|
||||
if (((stateChanges & 1) == 1)) inverted = !inverted;
|
||||
if (amplitude == 0 && !useEnvGen) return 0;
|
||||
if (!active && !noiseActive) return 0;
|
||||
boolean invert = false;
|
||||
boolean invert;
|
||||
int vol = useEnvGen ? envGen.getAmplitude() : amplitude;
|
||||
if (active) {
|
||||
invert = noiseActive && noiseGen.isOn() ? false : inverted;
|
||||
|
@ -18,7 +18,6 @@
|
||||
*/
|
||||
package jace.state;
|
||||
|
||||
import jace.Emulator;
|
||||
import java.io.Serializable;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.ArrayList;
|
||||
@ -35,6 +34,7 @@ import java.util.logging.Logger;
|
||||
* traversed cleanly and correctly.
|
||||
*
|
||||
* @author Brendan Robert (BLuRry) brendan.robert@gmail.com
|
||||
* @param <T>
|
||||
*/
|
||||
public class ObjectGraphNode<T> implements Serializable {
|
||||
|
||||
@ -55,7 +55,7 @@ public class ObjectGraphNode<T> implements Serializable {
|
||||
};
|
||||
|
||||
public ObjectGraphNode(Class<T> clazz) {
|
||||
children = new ArrayList<ObjectGraphNode>();
|
||||
children = new ArrayList<>();
|
||||
type = clazz;
|
||||
dirty = DirtyFlag.UNKNOWN;
|
||||
forceCheck = true;
|
||||
@ -70,13 +70,7 @@ public class ObjectGraphNode<T> implements Serializable {
|
||||
if (isPrimitive || type.isPrimitive()) {
|
||||
try {
|
||||
return (T) parent.type.getField(name).get(parent.getCurrentValue());
|
||||
} catch (IllegalArgumentException ex) {
|
||||
Logger.getLogger(ObjectGraphNode.class.getName()).log(Level.SEVERE, null, ex);
|
||||
} catch (IllegalAccessException ex) {
|
||||
Logger.getLogger(ObjectGraphNode.class.getName()).log(Level.SEVERE, null, ex);
|
||||
} catch (NoSuchFieldException ex) {
|
||||
Logger.getLogger(ObjectGraphNode.class.getName()).log(Level.SEVERE, null, ex);
|
||||
} catch (SecurityException ex) {
|
||||
} catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException | SecurityException ex) {
|
||||
Logger.getLogger(ObjectGraphNode.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
return null;
|
||||
@ -128,11 +122,7 @@ public class ObjectGraphNode<T> implements Serializable {
|
||||
System.out.println("this Is Array: " + type.isArray());
|
||||
System.out.println("parent Is Array: " + parent.type.isArray());
|
||||
Logger.getLogger(ObjectGraphNode.class.getName()).log(Level.SEVERE, null, ex);
|
||||
} catch (SecurityException ex) {
|
||||
Logger.getLogger(ObjectGraphNode.class.getName()).log(Level.SEVERE, null, ex);
|
||||
} catch (IllegalArgumentException ex) {
|
||||
Logger.getLogger(ObjectGraphNode.class.getName()).log(Level.SEVERE, null, ex);
|
||||
} catch (IllegalAccessException ex) {
|
||||
} catch (SecurityException | IllegalArgumentException | IllegalAccessException ex) {
|
||||
Logger.getLogger(ObjectGraphNode.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
@ -141,9 +131,9 @@ public class ObjectGraphNode<T> implements Serializable {
|
||||
public ObjectGraphNode find(String path) {
|
||||
String[] parts = path.split("\\.");
|
||||
ObjectGraphNode current = this;
|
||||
for (int i = 0; i < parts.length; i++) {
|
||||
for (String part : parts) {
|
||||
for (ObjectGraphNode child : (List<ObjectGraphNode>) current.children) {
|
||||
if (child.name.equals(parts[i])) {
|
||||
if (child.name.equals(part)) {
|
||||
current = child;
|
||||
break;
|
||||
} else {
|
||||
|
@ -78,7 +78,7 @@ public class State extends HashMap<ObjectGraphNode, StateValue> implements Seria
|
||||
}
|
||||
|
||||
public void apply() {
|
||||
Set<ObjectGraphNode> applied = new HashSet<ObjectGraphNode>();
|
||||
Set<ObjectGraphNode> applied = new HashSet<>();
|
||||
State current = this;
|
||||
while (current != null) {
|
||||
for (StateValue val : current.values()) {
|
||||
|
@ -25,8 +25,6 @@ import jace.config.Reconfigurable;
|
||||
import jace.core.Computer;
|
||||
import jace.core.PagedMemory;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.image.ColorModel;
|
||||
import java.awt.image.WritableRaster;
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Type;
|
||||
@ -98,7 +96,7 @@ public class StateManager implements Reconfigurable {
|
||||
|
||||
@Override
|
||||
public Object getCurrentValue() {
|
||||
return Boolean.valueOf(ss.getSwitch().getState());
|
||||
return ss.getSwitch().getState();
|
||||
}
|
||||
};
|
||||
switchVar.name = "switch";
|
||||
@ -138,9 +136,7 @@ public class StateManager implements Reconfigurable {
|
||||
// This is not stateful, but examine its children just in case
|
||||
buildStateMap(child, visited);
|
||||
}
|
||||
} catch (IllegalArgumentException ex) {
|
||||
Logger.getLogger(StateManager.class.getName()).log(Level.SEVERE, null, ex);
|
||||
} catch (IllegalAccessException ex) {
|
||||
} catch (IllegalArgumentException | IllegalAccessException ex) {
|
||||
Logger.getLogger(StateManager.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
@ -224,7 +220,7 @@ public class StateManager implements Reconfigurable {
|
||||
*/
|
||||
private void addMemoryPages(ObjectGraphNode<PagedMemory> node, Field f) {
|
||||
PagedMemory mem = node.getCurrentValue();
|
||||
ObjectGraphNode<byte[][]> internalmem = new ObjectGraphNode<byte[][]>(mem.internalMemory);
|
||||
ObjectGraphNode<byte[][]> internalmem = new ObjectGraphNode<>(mem.internalMemory);
|
||||
internalmem.parent = node;
|
||||
internalmem.name = "internalMemory";
|
||||
for (int i = 0; i < mem.internalMemory.length; i++) {
|
||||
@ -232,7 +228,7 @@ public class StateManager implements Reconfigurable {
|
||||
if (memPage == null) {
|
||||
continue;
|
||||
}
|
||||
ObjectGraphNode<byte[]> page = new ObjectGraphNode<byte[]>(memPage);
|
||||
ObjectGraphNode<byte[]> page = new ObjectGraphNode<>(memPage);
|
||||
page.parent = internalmem;
|
||||
page.name = String.valueOf(i);
|
||||
page.index = i;
|
||||
@ -254,10 +250,20 @@ public class StateManager implements Reconfigurable {
|
||||
node.markDirty();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String getName() {
|
||||
return "State Manager";
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String getShortName() {
|
||||
return "state";
|
||||
}
|
||||
@ -344,24 +350,25 @@ public class StateManager implements Reconfigurable {
|
||||
private State captureAlphaState() {
|
||||
State s = new State();
|
||||
s.deltaState = false;
|
||||
for (ObjectGraphNode node : allStateVariables) {
|
||||
allStateVariables.stream().map((node) -> {
|
||||
s.put(node, new StateValue(node));
|
||||
return node;
|
||||
}).forEach((node) -> {
|
||||
node.markClean();
|
||||
}
|
||||
});
|
||||
return s;
|
||||
}
|
||||
|
||||
private State captureDeltaState(State tail) {
|
||||
State s = new State();
|
||||
s.deltaState = true;
|
||||
for (ObjectGraphNode node : allStateVariables) {
|
||||
if (!node.valueChanged(tail)) {
|
||||
// If there are no changes to this node value, don't waste memory on it.
|
||||
continue;
|
||||
}
|
||||
allStateVariables.stream().filter((node) -> !(!node.valueChanged(tail))).map((node) -> {
|
||||
// If there are no changes to this node value, don't waste memory on it.
|
||||
s.put(node, new StateValue(node));
|
||||
return node;
|
||||
}).forEach((node) -> {
|
||||
node.markClean();
|
||||
}
|
||||
});
|
||||
return s;
|
||||
|
||||
}
|
||||
|
@ -24,12 +24,14 @@ import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.Serializable;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* This represents a serializable value of an object
|
||||
*
|
||||
* @author Brendan Robert (BLuRry) brendan.robert@gmail.com
|
||||
* @param <T>
|
||||
*/
|
||||
public class StateValue<T> implements Serializable {
|
||||
|
||||
@ -63,7 +65,7 @@ public class StateValue<T> implements Serializable {
|
||||
if (!type.isArray()) {
|
||||
try {
|
||||
return (T) type.getMethod("clone").invoke(currentValue);
|
||||
} catch (Exception ex) {
|
||||
} catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) {
|
||||
try {
|
||||
// Use serialization to build a deep copy
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
@ -73,9 +75,7 @@ public class StateValue<T> implements Serializable {
|
||||
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
|
||||
ObjectInputStream ois = new ObjectInputStream(bais);
|
||||
return (T) ois.readObject();
|
||||
} catch (IOException e) {
|
||||
return null;
|
||||
} catch (ClassNotFoundException e) {
|
||||
} catch (IOException | ClassNotFoundException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user