From 3f115624e6659ea6095c558abe91747beaabfc20 Mon Sep 17 00:00:00 2001 From: Brendan Robert Date: Sun, 21 Feb 2016 02:22:47 -0600 Subject: [PATCH] Issue #13: Added monochrome modes and ctrl+shift+g switches between various display modes. --- src/main/java/jace/EmulatorUILogic.java | 7 +++ src/main/java/jace/JaceUIController.java | 25 +++++++++ src/main/java/jace/apple2e/VideoDHGR.java | 2 +- src/main/java/jace/apple2e/VideoNTSC.java | 68 ++++++++++++++++++++++- src/main/java/jace/core/Video.java | 13 +++-- 5 files changed, 108 insertions(+), 7 deletions(-) diff --git a/src/main/java/jace/EmulatorUILogic.java b/src/main/java/jace/EmulatorUILogic.java index 645f4b6..c44e853 100644 --- a/src/main/java/jace/EmulatorUILogic.java +++ b/src/main/java/jace/EmulatorUILogic.java @@ -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"; diff --git a/src/main/java/jace/JaceUIController.java b/src/main/java/jace/JaceUIController.java index 778b64c..48f47da 100644 --- a/src/main/java/jace/JaceUIController.java +++ b/src/main/java/jace/JaceUIController.java @@ -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 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); + } } diff --git a/src/main/java/jace/apple2e/VideoDHGR.java b/src/main/java/jace/apple2e/VideoDHGR.java index 0619382..b99f064 100644 --- a/src/main/java/jace/apple2e/VideoDHGR.java +++ b/src/main/java/jace/apple2e/VideoDHGR.java @@ -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 { diff --git a/src/main/java/jace/apple2e/VideoNTSC.java b/src/main/java/jace/apple2e/VideoNTSC.java index 75622c7..37c651f 100644 --- a/src/main/java/jace/apple2e/VideoNTSC.java +++ b/src/main/java/jace/apple2e/VideoNTSC.java @@ -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) { diff --git a/src/main/java/jace/core/Video.java b/src/main/java/jace/core/Video.java index 19c6912..45f90e0 100644 --- a/src/main/java/jace/core/Video.java +++ b/src/main/java/jace/core/Video.java @@ -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