Class EndDoom

java.lang.Object
net.mtrop.doom.graphics.EndDoom
All Implemented Interfaces:
BinaryObject

public class EndDoom extends Object implements BinaryObject
Abstraction of the ENDOOM and other similarly-formatted lumps for the Doom Engine. An example of this would be the screen that is dumped to DOS after the player quits or the loading screen for Heretic.

All characters are converted using the CP437 charset (TextUtils.CP437), a.k.a. the MS-DOS encoding for extended ASCII.

Author:
Matthew Tropiano
  • Field Details

  • Constructor Details

    • EndDoom

      public EndDoom()
      Creates a new, blank ENDOOM-type screen.
  • Method Details

    • getVGAShort

      public short getVGAShort(int row, int col)
      Returns the VGA-formatted screen data for a particular ENDOOM screen coordinate.

      The short contains the font character in the lower byte and the color info in the higher one. Should be exported in little-endian order to retain VGA spec ordering.

      Parameters:
      row - the desired row (0 to 24).
      col - the desired column (0 to 79).
      Returns:
      the VGA short value.
    • getCharAt

      public char getCharAt(int row, int col)
      Returns the Unicode character at the desired position.
      Parameters:
      row - the desired row (0 to 24).
      col - the desired column (0 to 79).
      Returns:
      the corresponding character.
    • setCharAt

      public void setCharAt(int row, int col, char c)
      Sets the Unicode character at the desired position. Keep in mind that some characters not present the CP437 charset will not encode properly.
      Parameters:
      row - the desired row (0 to 24).
      col - the desired column (0 to 79).
      c - the character to set.
    • getForegroundColor

      public int getForegroundColor(int row, int col)
      Gets the ANSI color to use for the foreground color for the desired position.
      Parameters:
      row - the desired row (0 to 24).
      col - the desired column (0 to 79).
      Returns:
      the corresponding ANSI color.
    • setForegroundColor

      public void setForegroundColor(int row, int col, int color)
      Sets the ANSI color to use for the foreground color for the desired position.
      Parameters:
      row - the desired row (0 to 24).
      col - the desired column (0 to 79).
      color - the ANSI color to use for the foreground color (0 to 15).
    • getBackgroundColor

      public int getBackgroundColor(int row, int col)
      Gets the ANSI color to use for the background color for the desired position.
      Parameters:
      row - the desired row (0 to 24).
      col - the desired column (0 to 79).
      Returns:
      the corresponding ANSI color.
    • setBackgroundColor

      public void setBackgroundColor(int row, int col, int color)
      Sets the ANSI color to use for the background color for the desired position.
      Parameters:
      row - the desired row (0 to 24).
      col - the desired column (0 to 79).
      color - the ANSI color to use for the background color (0 to 7).
    • getBlinking

      public boolean getBlinking(int row, int col)
      Gets if the foreground character is blinking for the desired position.
      Parameters:
      row - the desired row (0 to 24).
      col - the desired column (0 to 79).
      Returns:
      true if so, false if not.
    • setBlinking

      public void setBlinking(int row, int col, boolean blink)
      Sets if the foreground character is blinking for the desired position.
      Parameters:
      row - the desired row (0 to 24).
      col - the desired column (0 to 79).
      blink - true for blinking, false otherwise.
    • setVGAShort

      protected void setVGAShort(int row, int col, short s)
      Sets the VGA-formatted screen data for a particular ENDOOM screen coordinate using a little-endian short int containing the VGA screen code.

      The short contains the font character in the lower byte and the color info in the higher one. Should be exported in little-endian order to retain VGA spec ordering.

      Parameters:
      row - the desired row (0 to 24).
      col - the desired column (0 to 79).
      s - the short.
    • byteToUnicode

      protected char byteToUnicode(byte vgaByte)
      Parameters:
      vgaByte - the input VGA byte.
      Returns:
      a converted VGA (or IBM) byte to Unicode.
    • unicodeToByte

      protected byte unicodeToByte(char c)
      Parameters:
      c - the input unicode character.
      Returns:
      a converted Unicode character to VGA byte.
    • getIndex

      protected int getIndex(int row, int col)
      Returns the correct array index for a specific row/column.
      Parameters:
      row - the desired row (0 to 24).
      col - the desired column (0 to 79).
      Returns:
      the correct array index for a specific row/column.
    • readBytes

      public void readBytes(InputStream in) throws IOException
      Description copied from interface: BinaryObject
      Reads from an InputStream and sets this object's fields. Only reads the amount of bytes that it takes to read a single instance of the object. Note that not every object may have a consistent length!
      Specified by:
      readBytes in interface BinaryObject
      Parameters:
      in - the InputStream to read from.
      Throws:
      IOException - if a read error occurs.
    • writeBytes

      public void writeBytes(OutputStream out) throws IOException
      Description copied from interface: BinaryObject
      Writes this object to an OutputStream.
      Specified by:
      writeBytes in interface BinaryObject
      Parameters:
      out - the OutputStream to write to.
      Throws:
      IOException - if a write error occurs.
    • toString

      public String toString()
      Overrides:
      toString in class Object