Issue #13: Added monochrome modes and ctrl+shift+g switches between various display modes.

This commit is contained in:
Brendan Robert 2016-02-21 02:22:47 -06:00
parent 3123ee1eec
commit 3f115624e6
5 changed files with 108 additions and 7 deletions

View File

@ -18,6 +18,7 @@
*/
package jace;
import com.sun.javafx.tk.quantum.OverlayWarning;
import jace.apple2e.MOS65C02;
import jace.apple2e.RAM128k;
import jace.apple2e.SoftSwitches;
@ -497,6 +498,12 @@ public class EmulatorUILogic implements Reconfigurable {
});
}
public static void notify(String message) {
if (JaceApplication.singleton != null) {
JaceApplication.singleton.controller.displayNotification(message);
}
}
@Override
public String getName() {
return "Jace User Interface";

View File

@ -34,6 +34,7 @@ import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.geometry.Insets;
import javafx.scene.control.Label;
import javafx.scene.effect.DropShadow;
import javafx.scene.image.ImageView;
import javafx.scene.input.DragEvent;
import javafx.scene.input.KeyEvent;
@ -241,4 +242,28 @@ public class JaceUIController {
public void removeMouseListener(EventHandler<MouseEvent> handler) {
appleScreen.removeEventHandler(MouseEvent.ANY, handler);
}
Label currentNotification = null;
public void displayNotification(String message) {
if (currentNotification != null) {
Label remove = currentNotification;
Application.invokeLater(() -> {
stackPane.getChildren().remove(remove);
});
}
Label notification = new Label(message);
notification.setEffect(new DropShadow(1.0, Color.DARKGREY));
notification.setTextFill(Color.WHITE);
Application.invokeLater(() -> {
stackPane.getChildren().add(notification);
});
currentNotification = notification;
notificationExecutor.schedule(()->{
Application.invokeLater(() -> {
stackPane.getChildren().remove(notification);
currentNotification = null;
});
}, 4, TimeUnit.SECONDS);
}
}

View File

@ -635,7 +635,7 @@ public class VideoDHGR extends Video {
}
}
static final Color BLACK = Color.BLACK;
static final Color WHITE = Color.WHITE;
static Color WHITE = Color.WHITE;
static final int[][] XY_OFFSET;
static {

View File

@ -18,8 +18,11 @@
*/
package jace.apple2e;
import jace.Emulator;
import jace.EmulatorUILogic;
import static jace.apple2e.VideoDHGR.BLACK;
import jace.config.ConfigurableField;
import jace.config.InvokableAction;
import jace.core.Computer;
import jace.core.RAM;
import jace.core.RAMEvent;
@ -29,6 +32,7 @@ import java.util.HashSet;
import java.util.Set;
import javafx.scene.image.PixelWriter;
import javafx.scene.image.WritableImage;
import javafx.scene.paint.Color;
/**
* Provides a clean color monitor simulation, complete with text-friendly
@ -68,6 +72,67 @@ public class VideoNTSC extends VideoDHGR {
registerStateListeners();
}
public static enum VideoMode {
Color("Color"),
TextFriendly("Text-friendly color"),
Mode7("Mode7 Mixed RGB"),
Mode7TextFriendly("Mode7 with Text-friendly palette"),
Monochrome("Mono"),
Greenscreen("Green"),
Amber("Amber");
String name;
VideoMode(String n) {
name = n;
}
}
static int currentMode = -1;
@InvokableAction(name = "Toggle video mode",
category = "video",
alternatives = "mode,color,b&w,monochrome",
defaultKeyMapping = {"ctrl+shift+g"})
public static void changeVideoMode() {
VideoNTSC thiss = (VideoNTSC) Emulator.computer.video;
currentMode++;
if (currentMode >= VideoMode.values().length) {
currentMode = 0;
}
thiss.monochomeMode = false;
WHITE = Color.WHITE;
switch (VideoMode.values()[currentMode]) {
case Amber:
thiss.monochomeMode = true;
WHITE = Color.web("ff8000");
break;
case Greenscreen:
thiss.monochomeMode = true;
WHITE = Color.web("0ccc68");
break;
case Monochrome:
thiss.monochomeMode = true;
break;
case Color:
thiss.useTextPalette = false;
thiss.enableVideo7 = false;
break;
case Mode7:
thiss.useTextPalette = false;
thiss.enableVideo7 = true;
break;
case Mode7TextFriendly:
thiss.useTextPalette = true;
thiss.enableVideo7 = true;
break;
case TextFriendly:
thiss.useTextPalette = true;
thiss.enableVideo7 = false;
break;
}
thiss.activePalette = thiss.useTextPalette ? TEXT_PALETTE : SOLID_PALETTE;
EmulatorUILogic.notify("Video mode: "+VideoMode.values()[currentMode].name);
forceRefresh();
}
@Override
protected void showBW(WritableImage screen, int x, int y, int dhgrWord) {
int pos = divBy28[x];
@ -169,6 +234,7 @@ public class VideoNTSC extends VideoDHGR {
}
}
boolean monochomeMode = false;
private void renderScanline(WritableImage screen, int y) {
int p = 0;
if (rowStart != 0) {
@ -202,7 +268,7 @@ public class VideoNTSC extends VideoDHGR {
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]);
isBW = monochomeMode || !colorActive[byteCounter] || (mixed && !hiresMode && !useColor[byteCounter]);
byteCounter++;
}
if (isBW) {

View File

@ -18,6 +18,7 @@
*/
package jace.core;
import jace.Emulator;
import jace.state.Stateful;
import jace.config.ConfigurableField;
import jace.config.InvokableAction;
@ -273,11 +274,13 @@ public abstract class Video extends Device {
category = "display",
description = "Marks screen contents as changed, forcing full screen redraw",
alternatives = "redraw",
defaultKeyMapping = "ctrl+shift+r")
public final void forceRefresh() {
lineDirty = true;
screenDirty = true;
forceRedrawRowCount = APPLE_SCREEN_LINES + 1;
defaultKeyMapping = {"ctrl+shift+r"})
public static final void forceRefresh() {
if (Emulator.computer != null && Emulator.computer.video != null) {
Emulator.computer.video.lineDirty = true;
Emulator.computer.video.screenDirty = true;
Emulator.computer.video.forceRedrawRowCount = APPLE_SCREEN_LINES + 1;
}
}
@Override