public abstract class Screen
extends javax.swing.JPanel
The methods herein convert from the emulated machine's screen data to java screen data.
If we're not in QL compatible mode (screen located at 0x20000 and 0x8000 bytes long), then the CPU passes a vrambase parameter to indicate at what address it thinks the videoram starts (generally above the "ROM"). This will be address 0 if this object's vramBuffer.
This now (as of 1.08) handles keypresses and mouse movements/buttons on the emulated screen. Screen redrawing should be kicked off by the "50 Hz" QL50HzInterrupt object only.
javax.swing.JPanel.AccessibleJPanel
javax.swing.JComponent.AccessibleJComponent
Modifier and Type | Field and Description |
---|---|
protected int |
black |
protected int |
blue |
protected int |
copyMode |
protected int |
cyan |
protected java.awt.image.DataBufferInt |
dataBuffer |
protected int |
divisior |
protected int |
green |
boolean |
isDirty |
protected boolean |
isDouble |
protected boolean |
isMac |
protected int |
magenta |
protected int |
mode |
protected Monitor |
monitor |
protected int |
nbrOfBytesPerLine |
protected int |
orange |
protected int[] |
pixelmask4 |
protected int[] |
pixelmask8 |
protected int |
QLmode |
protected java.awt.image.WritableRaster |
raster |
protected int |
red |
protected java.awt.image.BufferedImage |
screenImage |
protected int |
startAddress |
protected int |
stopAddress |
protected boolean |
vibrantColours |
protected int |
white |
protected int |
xsize |
protected int |
yellow |
protected int |
ysize |
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
Constructor and Description |
---|
Screen(int xsize,
int ysize,
Monitor monitor,
boolean isMac)
Creates the object.
|
Modifier and Type | Method and Description |
---|---|
abstract void |
clearScreen()
Clears the entire screen, on screen as well as in VramBuffer.
|
abstract void |
combineBlocks(MC68000Cpu cpu)
This combines two blocks (source 1, source2) with alpha blending and puts the result into the screen.
|
void |
copyScreen(MC68000Cpu cpu,
int addr,
int value)
Copies a word's worth of pixels from the original QL screen to this screen.
|
abstract void |
displayRegion(MC68000Cpu cpu,
int start,
int nbrOfBytes)
Displays a region if bytes were loaded directly to the screen memory.
|
abstract void |
fillBlock(MC68000Cpu cpu,
boolean resolveStipple)
Fills a block with colour : this updates the "screen memory" (vrambuffer) AND the underlying image.
|
void |
fillScreen(java.awt.Color c)
Fills the screen with a certain colour.
|
void |
fillScreen(int newRGB)
Fills the visible screen with a certain colour.
|
int |
getDivisor()
Gets the divisor necessary for moving memory about.
|
java.awt.Dimension |
getImageSize()
Gets the SMSQE pixel size of the screen, which is that of the underlying image.
|
int |
getLineSize()
Gets the number of bytes per line in high colour mode.
|
int |
getMode()
Gets the current screen mode.
|
Monitor |
getMonitor()
Gets the monitor this screen is attached to.
|
java.awt.Dimension |
getPreferredSize()
Gets the preferred size of this object, which is that of the underlying image.
|
int |
getScreenBase()
Gets the first address of screen memory.
|
abstract int |
getScreenSizeInBytes()
Gets size, in bytes, of the vram.
|
int |
getScreenTop()
Gets the last address of screen memory.
|
int |
getXSize()
Gets the x resolution in pixels.
|
int |
getYSize()
Gets the y resolution in pixels.
|
abstract boolean |
isQLScreen()
Checks whether this is a QL type screen
|
boolean |
isVibrantColours()
Shows whether "vibrant colours" were turned on or not.
|
boolean |
mouseInScreen()
Gets whether mouse is in this screen.
|
abstract void |
moveBlock(MC68000Cpu cpu,
boolean copyFromScreen)
This is called when a block of memory was copied to the vram..
|
void |
paintComponent(java.awt.Graphics g)
Paints the component.
|
void |
screenPanelKeyPressed(java.awt.event.KeyEvent evt)
Input some keys that aren't caught via the keyTyped method:
Cursor keys
function keys
home, end page up page down
ESC key (not caught under osx)
|
void |
screenPanelKeyReleased(java.awt.event.KeyEvent evt)
When key is released, remove it from keyrow array.
|
void |
screenPanelKeyTyped(java.awt.event.KeyEvent evt)
Gets the key typed in the
Screen object into the monitor (and thus the emulation). |
void |
screenPanelMouseEntered(java.awt.event.MouseEvent evt)
When mouse enters the emulated screen, this makes normal mouse cursor "disappear".
|
void |
screenPanelMouseExited(java.awt.event.MouseEvent evt)
Sets the mouse cursor back to normal when mouse leaves the emulated screen.
|
void |
screenPanelMouseMoved(java.awt.event.MouseEvent evt)
This is the method that catches the mouse movement and sends it to the emulator via the monitor.
|
void |
screenPanelMousePressed(java.awt.event.MouseEvent evt)
Handles mouse presses on the emulated screen - send mouse button pressed to SMSQE.
|
void |
screenPanelMouseReleased(java.awt.event.MouseEvent evt)
Handles mouse releases on the emulated screen - send mouse button released to SMSQE.
|
void |
setDisplayRegion(int address,
int nbrOfBytes,
short[] mem)
Copies a block of screen memory from an original QL screen to this screen, converting the colours.
|
void |
setDoubleSize(boolean d)
Sets the double sized status of this screen (a pixel is doubled in every dimension).
|
void |
setEmuMode(int mode)
Sets the screen emulation mode.
|
void |
setFullSize(boolean full)
Sets whether screen should be full size.
|
void |
setIsMac(boolean im)
Sets whether this screen is run under a mac.
|
void |
setMode(int mode)
Sets the screen mode when in Ql compatible mode.
|
void |
setMonitor(Monitor m)
Sets the Monitor object for this.
|
void |
setMouseClickDelay(int delay)
sets the delay after a mouse click.
|
boolean |
setMousePosition(int x,
int y)
Sets a new mouse position if that has changed from within SMSQ/E.
|
protected void |
setPixels(int x,
int y,
int value,
int Qlmode)
Sets the colours of a QL screen mode word's worth of pixels..
|
void |
setQLEmulationMode(int mode)
Sets the mode the emulated QL screen is supposed to be in when copying it in higher screen modes.
|
abstract void |
setVibrantColours(boolean bright,
short[] vram)
Sets whether brighter colours should be used.
|
abstract void |
setVramBase(int vrambase)
Sets the new Vrambase or the screen buffer if we are in QL compatible mode (this implies that the CPU or its memory changed).
|
abstract void |
writeByteToScreen(int address,
int value,
int wordValue)
Writes a byte to the "screen memory" and paints the corresponding pixel on the screen.
|
abstract void |
writeLongToScreen(int addr,
int value)
Writes a long word to the java screen.
|
abstract void |
writeWordToScreen(int addr,
int value)
Writes a word to screen memory, and paints the corresponding pixel on the screen.
|
abstract void |
xorBlock(MC68000Cpu cpu,
boolean resolveStipple)
Xors a block with colour : this updates the "screen memory" (vrambuffer) AND the underlying image.
|
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTree
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
protected int startAddress
protected int stopAddress
protected int xsize
protected int ysize
protected int mode
public volatile boolean isDirty
protected boolean isDouble
protected java.awt.image.BufferedImage screenImage
protected java.awt.image.WritableRaster raster
protected java.awt.image.DataBufferInt dataBuffer
protected int nbrOfBytesPerLine
protected boolean vibrantColours
protected int divisior
protected Monitor monitor
protected boolean isMac
protected final int[] pixelmask4
protected final int[] pixelmask8
protected final int black
protected final int blue
protected final int red
protected final int green
protected final int magenta
protected final int yellow
protected final int orange
protected final int white
protected final int cyan
protected int copyMode
protected int QLmode
public Screen(int xsize, int ysize, Monitor monitor, boolean isMac)
xsize
- screen x size in pixels.ysize
- screen y size in pixels.monitor
- the monitor running the emulation.isMac
- true
if we are running on a mac.public void screenPanelKeyTyped(java.awt.event.KeyEvent evt)
Screen
object into the monitor (and thus the emulation).evt
- the key typed
NOTE this needs more key translations.public void screenPanelKeyPressed(java.awt.event.KeyEvent evt)
evt
- ignored.public void screenPanelKeyReleased(java.awt.event.KeyEvent evt)
evt
- the key vent of the key released.public void screenPanelMouseMoved(java.awt.event.MouseEvent evt)
evt
- the mouse eventpublic boolean setMousePosition(int x, int y)
x
- the new x position, relative to the screen object.y
- same for y.public void screenPanelMouseEntered(java.awt.event.MouseEvent evt)
evt
- ignoredpublic void screenPanelMouseExited(java.awt.event.MouseEvent evt)
evt
- ignoredpublic void screenPanelMousePressed(java.awt.event.MouseEvent evt)
evt
- ignoredpublic void screenPanelMouseReleased(java.awt.event.MouseEvent evt)
evt
- ignoredpublic void setIsMac(boolean im)
im
- true
if this is run under a mac.public void setMonitor(Monitor m)
m
- the new Monitor.public void setMouseClickDelay(int delay)
delay
- delay in milliseconds.public abstract void writeByteToScreen(int address, int value, int wordValue)
address
- where to write to. This is the SMSQE address, where it thinks video memory lies.
It has already been checked that the address is in my memory space.value
- the value to write.wordValue
- the value to write into the word this byte is part ofpublic abstract void writeWordToScreen(int addr, int value)
addr
- the address where to write to. It is presumed that it has been checked that this is in screen mem.value
- the value to write to screen mem.public abstract void writeLongToScreen(int addr, int value)
addr
- where to write to.value
- the value.public void setMode(int mode)
mode
- 0 for mode 4 ,8 for mode 8public void setEmuMode(int mode)
mode
- 0 for mode 4 ,8 for mode 8public abstract void clearScreen()
public abstract void xorBlock(MC68000Cpu cpu, boolean resolveStipple)
cpu
- the CPu used.resolveStipple
- true if colours must be derived from stipple.public abstract void fillBlock(MC68000Cpu cpu, boolean resolveStipple)
cpu
- the CPU used.resolveStipple
- true if colours must be derived from stipple.public abstract void moveBlock(MC68000Cpu cpu, boolean copyFromScreen)
cpu
- the CPU used.copyFromScreen
- = true if the source is also the screen.
d1 c s size of section to move (x :pixels | y :lines) a pixel may take a variable amount of bytes
d2 c s old origin in source area
d3 c s new origin in destination area
d4 s scratch
d5 s scratch
d6/d7 preserved
a0/a1 preserved
a2 c row increment of source area
a3 c row increment of destination area
a4 c base address of source area
a5 c base address of destination area
a6/a7 preservedpublic abstract void combineBlocks(MC68000Cpu cpu)
cpu
- the CPU used.
d0 s ? / some arbitrary value
d1 c s size of section to move / scratch
d2 c s old origin in source area1 / scratch
d3 c s new origin in destination area / scratch
d4 c s
d5 s scratch
d6 c alpha / preserved
d7 preserved
a1 c s base address of source area2 / scratch
a2 c s row increment of source area1 / scratch
a3 c s row increment of destination area / scratch
a4 c s base address of source area1 / scratch
a5 c s base address of destination area / scratch
a6/a7 preservedpublic abstract void displayRegion(MC68000Cpu cpu, int start, int nbrOfBytes)
cpu
- .start
- where the bytes were loaded to.nbrOfBytes
- how many bytes were loaded.public abstract void setVramBase(int vrambase)
vrambase
- the "video ram" base.public abstract void setVibrantColours(boolean bright, short[] vram)
bright
- true
if brighter colours should be used.vram
- te array containing the "vram".public abstract int getScreenSizeInBytes()
public abstract boolean isQLScreen()
public final void setQLEmulationMode(int mode)
mode
- the QL mode (mode 4 = 0 or mode 8=8)public int getDivisor()
public boolean isVibrantColours()
true
if yes.public final int getScreenBase()
public final int getScreenTop()
public final int getXSize()
public final int getYSize()
public final int getLineSize()
public final int getMode()
public final java.awt.Dimension getPreferredSize()
getPreferredSize
in class javax.swing.JComponent
public final java.awt.Dimension getImageSize()
public final void setDoubleSize(boolean d)
d
- true
if pixels should be doubled.public boolean mouseInScreen()
public Monitor getMonitor()
public void paintComponent(java.awt.Graphics g)
paintComponent
in class javax.swing.JComponent
g
- the java.awt.Graphics
object to draw on.public final void fillScreen(java.awt.Color c)
c
- the java.awt.Color
to fill the screen with.public final void fillScreen(int newRGB)
newRGB
- the int (RGB) to fill the screen with.public final void setFullSize(boolean full)
full
- true if screen should be fullsize.public void copyScreen(MC68000Cpu cpu, int addr, int value)
cpu
- the CPU from which to get the data.addr
- where in QL screen the pixels go.value
- the colour of the pixels.protected void setPixels(int x, int y, int value, int Qlmode)
x
- x coordinate of pixel.y
- y coordinate of pixel.value
- the word containing the colours to set the pixels to, in QL mode 8 or 4.Qlmode
- the QL colour mode (must be 4 or 8).public final void setDisplayRegion(int address, int nbrOfBytes, short[] mem)
address
- start address of block in the screen memory.nbrOfBytes
- nbr of bytes to treat.mem
- the array with the "vram". the values in there correspond to QL mode colours.