Slight optimizations, more centered center

main
Astoria 7 months ago
parent 4435e0a790
commit c981206adf

@ -13,6 +13,7 @@ import java.awt.image.BufferedImage;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import java.util.Arrays;
import java.util.Objects; import java.util.Objects;
import static com.simon816.j65el02.device.RPMonitor.HEIGHT; import static com.simon816.j65el02.device.RPMonitor.HEIGHT;
@ -21,15 +22,12 @@ import static com.simon816.j65el02.device.RPMonitor.WIDTH;
public class BasicMonitorDriver implements MonitorDriver, KeyListener { public class BasicMonitorDriver implements MonitorDriver, KeyListener {
BufferedImage display; BufferedImage display;
final int width = 8;
final int height = 8;
int rows = 16;
int cols = 16;
JLabel[] lines = new JLabel[HEIGHT]; JLabel[] lines = new JLabel[HEIGHT];
Machine emu; Machine emu;
byte[][] windowDataOld = new byte[HEIGHT][WIDTH];
int xoffset = 32; int xoffset = 30;
int yoffset = 27; int yoffset = 26;
public BasicMonitorDriver(Machine emu) { public BasicMonitorDriver(Machine emu) {
this.emu = emu; this.emu = emu;
try{ try{
@ -102,11 +100,14 @@ public class BasicMonitorDriver implements MonitorDriver, KeyListener {
public void update(byte[][] windowData) { public void update(byte[][] windowData) {
for(int y = windowData.length - 1; y >= 0; y--){ for(int y = windowData.length - 1; y >= 0; y--){
String text = ""; String text = "";
for(int x = 0; x<windowData[y].length; x++){ if(!Arrays.equals(windowData[y], windowDataOld[y])) {
int temp = Math.floorMod(windowData[y][x] , 256); for (int x = 0; x < windowData[y].length; x++) {
text += (char)((temp + 0xDED0)); int temp = Math.floorMod(windowData[y][x], 256);
text += (char) ((temp + 0xDED0));
} }
lines[y].setText(text); lines[y].setText(text);
System.arraycopy(windowData[y], 0, windowDataOld[y], 0, windowData[y].length);
}
} }
} }

Loading…
Cancel
Save