Package net.mtrop.doom.graphics
Class EndDoom
java.lang.Object
net.mtrop.doom.graphics.EndDoom
- All Implemented Interfaces:
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
-
Nested Class Summary
Nested classes/interfaces inherited from interface net.mtrop.doom.object.BinaryObject
BinaryObject.InlineScanner<BO extends BinaryObject>, BinaryObject.Reflect, BinaryObject.Scanner<BO extends BinaryObject>, BinaryObject.Shared, BinaryObject.Transformer<BO extends BinaryObject>
-
Field Summary
Modifier and TypeFieldDescriptionstatic final byte
static final byte
static final byte
static final byte
static final byte
static final byte
static final byte
static final byte
static final byte
static final byte
static final byte
static final byte
static final byte
static final byte
static final byte
static final byte
static final byte
static final byte
static final byte
static final byte
static final byte
static final byte
static final byte
static final byte
static final int
A single colormap's length in bytes. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected char
byteToUnicode
(byte vgaByte) int
getBackgroundColor
(int row, int col) Gets the ANSI color to use for the background color for the desired position.boolean
getBlinking
(int row, int col) Gets if the foreground character is blinking for the desired position.char
getCharAt
(int row, int col) Returns the Unicode character at the desired position.int
getForegroundColor
(int row, int col) Gets the ANSI color to use for the foreground color for the desired position.protected int
getIndex
(int row, int col) Returns the correct array index for a specific row/column.short
getVGAShort
(int row, int col) Returns the VGA-formatted screen data for a particular ENDOOM screen coordinate.void
readBytes
(InputStream in) Reads from anInputStream
and sets this object's fields.void
setBackgroundColor
(int row, int col, int color) Sets the ANSI color to use for the background color for the desired position.void
setBlinking
(int row, int col, boolean blink) Sets if the foreground character is blinking for the desired position.void
setCharAt
(int row, int col, char c) Sets the Unicode character at the desired position.void
setForegroundColor
(int row, int col, int color) Sets the ANSI color to use for the foreground color for the desired position.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.toString()
protected byte
unicodeToByte
(char c) void
writeBytes
(OutputStream out) Writes this object to anOutputStream
.
-
Field Details
-
LENGTH
public static final int LENGTHA single colormap's length in bytes.- See Also:
-
BGCOLOR_BLACK
public static final byte BGCOLOR_BLACK- See Also:
-
BGCOLOR_BLUE
public static final byte BGCOLOR_BLUE- See Also:
-
BGCOLOR_GREEN
public static final byte BGCOLOR_GREEN- See Also:
-
BGCOLOR_CYAN
public static final byte BGCOLOR_CYAN- See Also:
-
BGCOLOR_RED
public static final byte BGCOLOR_RED- See Also:
-
BGCOLOR_MAGENTA
public static final byte BGCOLOR_MAGENTA- See Also:
-
BGCOLOR_BROWN
public static final byte BGCOLOR_BROWN- See Also:
-
BGCOLOR_GRAY
public static final byte BGCOLOR_GRAY- See Also:
-
FGCOLOR_BLACK
public static final byte FGCOLOR_BLACK- See Also:
-
FGCOLOR_BLUE
public static final byte FGCOLOR_BLUE- See Also:
-
FGCOLOR_GREEN
public static final byte FGCOLOR_GREEN- See Also:
-
FGCOLOR_CYAN
public static final byte FGCOLOR_CYAN- See Also:
-
FGCOLOR_RED
public static final byte FGCOLOR_RED- See Also:
-
FGCOLOR_MAGENTA
public static final byte FGCOLOR_MAGENTA- See Also:
-
FGCOLOR_BROWN
public static final byte FGCOLOR_BROWN- See Also:
-
FGCOLOR_GRAY
public static final byte FGCOLOR_GRAY- See Also:
-
FGCOLOR_DARK_GRAY
public static final byte FGCOLOR_DARK_GRAY- See Also:
-
FGCOLOR_LIGHT_BLUE
public static final byte FGCOLOR_LIGHT_BLUE- See Also:
-
FGCOLOR_LIGHT_GREEN
public static final byte FGCOLOR_LIGHT_GREEN- See Also:
-
FGCOLOR_LIGHT_CYAN
public static final byte FGCOLOR_LIGHT_CYAN- See Also:
-
FGCOLOR_LIGHT_RED
public static final byte FGCOLOR_LIGHT_RED- See Also:
-
FGCOLOR_LIGHT_MAGENTA
public static final byte FGCOLOR_LIGHT_MAGENTA- See Also:
-
FGCOLOR_YELLOW
public static final byte FGCOLOR_YELLOW- See Also:
-
FGCOLOR_WHITE
public static final byte FGCOLOR_WHITE- See Also:
-
-
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
Description copied from interface:BinaryObject
Reads from anInputStream
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 interfaceBinaryObject
- Parameters:
in
- theInputStream
to read from.- Throws:
IOException
- if a read error occurs.
-
writeBytes
Description copied from interface:BinaryObject
Writes this object to anOutputStream
.- Specified by:
writeBytes
in interfaceBinaryObject
- Parameters:
out
- theOutputStream
to write to.- Throws:
IOException
- if a write error occurs.
-
toString
-