Package screens

Class Screen

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible
Direct Known Subclasses:
Screen0, Screen16, Screen32

public abstract class Screen extends JPanel
The emulated machine's screen, to be subclassed. This object contains abstract methods and MUST be subclassed for each type of screen.

The methods herein convert from the emulated machine's screen data to java screen data.

The CPU object creates the videoram memory automatically, this lies above RAMTOP. This will be "address 0" in 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. This (and thus the subclasses) is not thread safe.

See Also:
  • Field Details

    • startAddress

      protected int startAddress
    • stopAddress

      protected int stopAddress
    • xsize

      public int xsize
    • ysize

      public int ysize
    • colourMode

      protected int colourMode
    • isDirty

      public volatile boolean isDirty
    • isDouble

      public boolean isDouble
    • screenImage

      protected transient BufferedImage screenImage
    • raster

      protected transient WritableRaster raster
    • dataBuffer

      protected transient DataBufferInt dataBuffer
    • nbrOfBytesPerLine

      protected int nbrOfBytesPerLine
    • vibrantColours

      protected boolean vibrantColours
    • divisior

      protected int divisior
    • monitor

      protected Monitor monitor
    • isMac

      protected boolean isMac
    • isWindows

      protected boolean isWindows
    • pixelmask4

      protected final int[] pixelmask4
    • pixelmask8

      protected final int[] pixelmask8
    • copyMode

      protected int copyMode
    • QLmode

      protected int QLmode
    • xEnd

      protected int xEnd
    • yEnd

      protected int yEnd
  • Constructor Details

    • Screen

      public Screen(int xsize, int ysize, Monitor monitor, boolean isMac, boolean ddouble, int windowMode, boolean keyType)
      Creates the object - subclasses should always call this.
      Parameters:
      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.
      ddouble - true if double sized pixels
      windowMode - mode of window 0 = window , 1 = full size, 2 = special fullsize
      keyType - true if standard home etc keys
  • Method Details

    • screenPanelKeyTyped

      public void screenPanelKeyTyped(KeyEvent evt)
      Gets the key typed in the Screen object to the Monitor object (and thus the emulation).
      Parameters:
      evt - the key typed
    • screenPanelKeyPressed

      public void screenPanelKeyPressed(KeyEvent evt)
      Input some keys that aren't caught via the keyTyped method:
      • Cursor keys
      • Function keys
      • home, end, page up, page down
      • pause, syst, stop
      • ESC key (not caught under osx)
      This here method has several premature exits.
      Parameters:
      evt - the key event generated by the key typed.
    • screenPanelKeyReleased

      public void screenPanelKeyReleased(KeyEvent evt)
      When key is released, tell SMSQE via monitor object.
      Parameters:
      evt - the key event of the key released.
    • screenPanelMouseMoved

      public void screenPanelMouseMoved(MouseEvent evt)
      This is the method that catches the mouse movement and sends it to the emulator via the monitor object.
      Parameters:
      evt - the mouse event
    • setMousePosition

      public boolean setMousePosition(int x, int y)
      Sets a new mouse position if that has changed from within SMSQ/E.
      Parameters:
      x - the new x position, relative to the screen object.
      y - same for y.
      Returns:
      true if the screen is in double sized mode.
    • getMyMousePosition

      public Point getMyMousePosition()
      Get the last recorded mouse position.
      Returns:
      the last recorded mouse position.
    • screenPanelMouseEntered

      public void screenPanelMouseEntered(MouseEvent evt)
      When mouse enters the emulated screen, this makes normal host OS mouse cursor "disappear". The cursor is replaced by an invisible one.
      Parameters:
      evt - ignored
    • screenPanelMouseExited

      public void screenPanelMouseExited(MouseEvent evt)
      Sets the mouse cursor back to normal when mouse leaves the emulated screen. (So that it can be seen on the menubar).
      Parameters:
      evt - ignored
    • resetMouseButtons

      public void resetMouseButtons()
      Resets the mouse buttons, as if no mouse button was pressed.
    • screenPanelMousePressed

      public void screenPanelMousePressed(MouseEvent evt)
      Handles mouse presses on the emulated screen - send mouse button pressed to SMSQ/E.
      Parameters:
      evt - ignored
    • screenPanelMouseReleased

      public void screenPanelMouseReleased(MouseEvent evt)
      Handles mouse button releases on the emulated screen - send mouse button released to SMSQE.
      Parameters:
      evt - ignored
    • setIsMac

      public void setIsMac(boolean im)
      Sets whether this screen is run under a mac.
      Parameters:
      im - true if this is run under a mac.
    • setIsWindows

      public void setIsWindows(boolean im)
      Sets whether this screen is run under windows
      Parameters:
      im - true if this is run under windows.
    • setMonitor

      public void setMonitor(Monitor m)
      Sets the Monitor object for this.
      Parameters:
      m - the new Monitor.
    • setMouseClickDelay

      public void setMouseClickDelay(int delay)
      Sets the delay after a mouse click.
      Parameters:
      delay - delay in milliseconds.
    • writeByteToScreen

      public abstract void writeByteToScreen(int address, int value, int wordValue)
      Writes a byte to the screen, and paints the corresponding pixel on the screen.
      Parameters:
      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 of
    • writeWordToScreen

      public abstract void writeWordToScreen(int addr, int value)
      Writes a word to the screen, and paints the corresponding pixel on the screen.
      Parameters:
      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.
    • writeLongToScreen

      public abstract void writeLongToScreen(int addr, int value)
      Writes a long word to the screen, and paints the corresponding pixel on the screen.
      Parameters:
      addr - where to write to.
      value - the value.
    • xorBlock

      public abstract void xorBlock(MC68000Cpu cpu, boolean resolveStipple)
      Xors a block with colour : this updates the "screen memory" (vrambuffer) AND the underlying image. Implemented in modes 16 and 32.
      Parameters:
      cpu - the CPu used.
      resolveStipple - true if colours must be derived from stipple.
    • fillBlock

      public abstract void fillBlock(MC68000Cpu cpu, boolean resolveStipple)
      Fills a block with colour : this updates the "screen memory" (vrambuffer) AND the underlying image. Implemented in modes 16 and 32.
      Parameters:
      cpu - the CPU used.
      resolveStipple - true if colours must be derived from stipple.
    • moveBlock

      public abstract void moveBlock(MC68000Cpu cpu, boolean copyFromScreen)
      This is called when a block of memory was copied to the vram.. It must copy the data from the vram into the image.
      Parameters:
      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 preserved
    • combineBlocks

      public abstract void combineBlocks(MC68000Cpu cpu)
      This combines two blocks (source 1, source2) with alpha blending and puts the result into the screen. The destination must be the screen: this MUST have been checked before this method is called. Source2 must have a row increment of destination row increment + 4.
      Parameters:
      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 preserved
    • displayRegion

      public abstract void displayRegion(MC68000Cpu cpu, int start, int nbrOfBytes)
      Displays a region if bytes were loaded directly to the screen memory. Used from CPU.
      Parameters:
      cpu - .
      start - where the bytes were loaded to.
      nbrOfBytes - how many bytes were loaded.
    • setVramBase

      public 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). Adjust vramtop accordingly. If this is a Ql screen, sets the vram object
      Parameters:
      vrambase - the "video ram" base.
    • setVibrantColours

      public abstract void setVibrantColours(boolean bright, char[] vram)
      Sets whether brighter colours should be used.
      Parameters:
      bright - true if brighter colours should be used.
      vram - te array containing the "vram".
    • getScreenSizeInBytes

      public abstract int getScreenSizeInBytes()
      Gets size, in bytes, of the vram.
      Returns:
      screen size, in number of bytes.
    • isQLScreen

      public abstract boolean isQLScreen()
      Checks whether this is a QL type screen
      Returns:
      true if this is a QL screen (512*256 i mode 4, 256*256 in mode 8), else false
    • setColourMode

      public void setColourMode(int mode)
      Sets the screen mode when in Ql compatible mode. Is only overriden by screen0.
      Parameters:
      mode - 0 for mode 4 ,8 for mode 8,
    • setEmuColourMode

      public void setEmuColourMode(int mode)
      Sets the screen mode for a QL emulated screen (subtly different from the above). ATM only modes 4 and 8 are supported.
      Parameters:
      mode - 0 for mode 4 ,8 for mode 8
    • setQLEmulationMode

      public final void setQLEmulationMode(int mode)
      Sets the mode the emulated QL screen is supposed to be in when copying it in higher screen modes.
      Parameters:
      mode - the QL mode (mode 4 = 0 or mode 8=8)
    • getDivisor

      public int getDivisor()
      Gets the divisor necessary for moving memory about.
      Returns:
      the divisor.
    • isVibrantColours

      public boolean isVibrantColours()
      Shows whether "vibrant colours" were turned on or not.
      Returns:
      true if yes.
    • getScreenBase

      public final int getScreenBase()
      Gets the first address of screen memory.
      Returns:
      the first address of screen memory.
    • getScreenTop

      public final int getScreenTop()
      Gets the last address of screen memory.
      Returns:
      the last address of screen memory.
    • getXSize

      public final int getXSize()
      Gets the x resolution in pixels.
      Returns:
      the x resolution (width) in pixels.
    • getYSize

      public final int getYSize()
      Gets the y resolution in pixels.
      Returns:
      the y resolution (height) in pixels.
    • getLineSize

      public final int getLineSize()
      Gets the number of bytes per line in high colour mode.
      Returns:
      the size of the line in number of bytes per line (this obny makes sens for high colour modes)
    • getColourMode

      public final int getColourMode()
      Gets the current screen mode.
      Returns:
      the current screen colour mode 0, 8 or 32
    • getPreferredSize

      public final Dimension getPreferredSize()
      Gets the preferred size of this object, which is that of the underlying image.
      Overrides:
      getPreferredSize in class JComponent
      Returns:
      the java.awt.Dimension with the size.
    • getImageSize

      public final Dimension getImageSize()
      Gets the SMSQE pixel size of the screen, which is that of the underlying image.
      Returns:
      the java.awt.Dimension with the size.
    • changeDoubleSize

      public final void changeDoubleSize()
      Changes the double sized status of this screen (a pixel is doubled in every dimension).
    • mouseInScreen

      public boolean mouseInScreen()
      Gets whether mouse is in this screen.
      Returns:
      true only if mouse is in this screen.
    • getMonitor

      public Monitor getMonitor()
      Gets the monitor this screen is attached to.
      Returns:
      the monitor this screen is attached to.
    • paintComponent

      public void paintComponent(Graphics g)
      Paints the component. This refills the screen with the image. The data for the image will have been changed by the writeXxxToScreen and move block routines above.
      Overrides:
      paintComponent in class JComponent
      Parameters:
      g - the java.awt.Graphics object to draw on.
    • fillScreen

      public final void fillScreen(Color c)
      Fills the screen with a certain colour. Note this doesn't set the "screen memory" to that colour!
      Parameters:
      c - the java.awt.Color to fill the screen with.
    • fillScreen

      public final void fillScreen(int newRGB)
      Fills the visible screen with a certain colour. Note this doesn't set the "screen memory" to that colour!
      Parameters:
      newRGB - the int (RGB) to fill the screen with.
    • setFullSize

      public final void setFullSize(boolean full)
      Sets whether screen should be full size. If yes, it also covers the task bar.
      Parameters:
      full - true if screen should be fullsize.
    • copyScreen

      public void copyScreen(MC68000Cpu cpu, int addr, int value)
      Copies a word's worth of pixels from the original QL screen to this screen. These will be either 8 pixels (in mode 4) or 4 pixels (in mode 8).
      Parameters:
      cpu - the CPU from which to get the data.
      addr - where in QL screen the pixels go.
      value - the colour of the pixels.
    • setPixels

      protected void setPixels(int x, int y, int value, int Qlmode)
      Sets the colours of a QL screen mode word's worth of pixels. This sets either 8 pixels (QL mode 4) or 4 pixels (Ql mode 8).
      Parameters:
      x - x coordinate of 1st pixel.
      y - y coordinate of 1st 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 0 or 8).
    • setDisplayRegion

      public final void setDisplayRegion(int address, int nbrOfBytes, char[] mem)
      Copies a block of screen memory from an original QL screen to this screen, converting the colours. Used by CPUforScreenEmulation.
      Parameters:
      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.
    • setMousewheelAccel

      public void setMousewheelAccel(int mse)
      Sets the mousewheel acceleration, ie how many arrow key chars are input for one mouse wheel movement.
      Parameters:
      mse - the mousewheel acceleration,
    • getKeysType

      public boolean getKeysType()
      Returns:
      the isPCType
    • setKeysType

      public void setKeysType(boolean keyType)
      Parameters:
      keyType - whether home etc keys are standard or not
    • getSizeInBytes

      public static int getSizeInBytes(int xsize, int ysize, int colourMode)
      Gets the number of bytes in each screen mode (except for mode 0 where it's false).
      Parameters:
      xsize -
      ysize -
      colourMode -
      Returns:
    • isDoubleSize

      public final boolean isDoubleSize()
    • setEndPositions

      public void setEndPositions(Point p)
      Set where the window ends, in screen pixels.
      Parameters:
      p - x and y end position