Table of Contents

Class ZXSpectrum48ImageHelper

Namespace
RetroEditor.Plugins
Assembly
RetroEditor.dll

Helper class for rendering a ZX Spectrum 48K screen, this will probably be abstracted out to a more generic class in the future.

public class ZXSpectrum48ImageHelper
Inheritance
ZXSpectrum48ImageHelper
Inherited Members

Remarks

This is not stored in specutrm screen order, but is a high res bitmap with low res colour.

Constructors

ZXSpectrum48ImageHelper(uint, uint)

Create a new ZX Spectrum 48K image helper.

public ZXSpectrum48ImageHelper(uint widthPixels, uint heightPixels)

Parameters

widthPixels uint

width of image in pixels

heightPixels uint

height of image in pixels

Methods

Clear(byte)

Clear the image to a specific attribute.

public void Clear(byte attribute)

Parameters

attribute byte

attribute byte

ConvertXBitmapPosToYAttribute(uint)

Helper function to convert from a pixel x position to an attribute x position.

public uint ConvertXBitmapPosToYAttribute(uint x)

Parameters

x uint

x position in pixels

Returns

uint

x position in attribute cells

ConvertYBitmapPosToYAttribute(uint)

Helper function to convert from a pixel y position to an attribute y position.

public uint ConvertYBitmapPosToYAttribute(uint y)

Parameters

y uint

y position in pixels

Returns

uint

y position in attribute cells

CopyBitmapFrom(ZXSpectrum48ImageHelper)

Copy the contents of specified image to this image. At present images should be the same size!

public void CopyBitmapFrom(ZXSpectrum48ImageHelper source)

Parameters

source ZXSpectrum48ImageHelper

Source image to copy from

Draw8Bits(uint, uint, byte, byte, bool)

Draws a set of 8 pixels horizontally to the screen. Bits set will be ink, bits not set will be paper. Attribute will be updated for the 8 pixels drawn.

public void Draw8Bits(uint x, uint y, byte bits, byte attribute, bool flipX)

Parameters

x uint

x position in pixels

y uint

y position in pixels

bits byte

byte representing 8 pixels

attribute byte

attribute byte

flipX bool

if true bits are drawn from right to left.

Draw8BitsInkOnly(uint, uint, byte, byte, bool)

Draws a set of 8 pixels horizontally to the screen ignores paper bits. Updates ink attribute only

public void Draw8BitsInkOnly(uint x, uint y, byte bits, byte attribute, bool flipX)

Parameters

x uint

x position in pixels

y uint

y position in pixels

bits byte

byte representing 8 pixels, only set bits will update the image

attribute byte

attribute byte (only ink colour used)

flipX bool

if true bits are drawn from right to left.

Draw8BitsNoAttribute(uint, uint, byte, bool)

Draws a set of 8 pixels horizontally to the screen. Bits set will be ink, bits not set will be paper.

public void Draw8BitsNoAttribute(uint x, uint y, byte bits, bool flipX)

Parameters

x uint

x position in pixels

y uint

y position in pixels

bits byte

byte representing 8 pixels

flipX bool

if true bits are drawn from right to left.

Draw8BitsNoAttributeInkOnly(uint, uint, byte, bool)

Draws a set of 8 pixels horizontally to the screen ignores paper bits.

public void Draw8BitsNoAttributeInkOnly(uint x, uint y, byte bits, bool flipX)

Parameters

x uint

x position in pixels

y uint

y position in pixels

bits byte

byte representing 8 pixels, only set bits will update the image

flipX bool

if true bits are drawn from right to left.

Draw8x8(uint, uint, ReadOnlySpan<byte>, byte)

Draw an 8x8 tile to the screen, this will update the attribute map. The tile should be an array of 8 bytes. The first byte represents the first row.. etc.

public void Draw8x8(uint x, uint y, ReadOnlySpan<byte> tile, byte attribute)

Parameters

x uint

x position to draw tile in pixels

y uint

y position to draw tile in pixels

tile ReadOnlySpan<byte>

array of 8 bytes representing the tile to draw

attribute byte

attribute byte

Draw8x8InkOnly(uint, uint, ReadOnlySpan<byte>, byte)

Draw an 8x8 tile to the screen, ignores paper bits. The attribute map will be updated with the ink colour only.

public void Draw8x8InkOnly(uint x, uint y, ReadOnlySpan<byte> tile, byte attribute)

Parameters

x uint

x position to draw tile in pixels

y uint

y position to draw tile in pixels

tile ReadOnlySpan<byte>

array of 8 bytes representing the tile to draw, only set bits are transferred

attribute byte

DrawBit(uint, uint, bool, byte)

Plot a single pixel onto the screen and update the attribute map.

public void DrawBit(uint x, uint y, bool ink, byte attribute)

Parameters

x uint

x position in pixels

y uint

y position in pixels

ink bool

If true plots in ink colour, otherwise paper

attribute byte

DrawBitNoAttribute(uint, uint, bool)

Plot a single pixel onto the screen.

public void DrawBitNoAttribute(uint x, uint y, bool ink)

Parameters

x uint

x position in pixels

y uint

y position in pixels

ink bool

If true plots in ink colour, otherwise paper

FlipVertical()

Flip the current image vertically in place. Only affects bitmap.

public void FlipVertical()

GetAttribute(uint, uint)

Get the attribute at a specific location.

public byte GetAttribute(uint ax, uint ay)

Parameters

ax uint

x position in attribute cells

ay uint

y position in attribute cells

Returns

byte

attribute byte

GetBit(uint, uint)

Get the value of a pixel at a specific location.

public bool GetBit(uint x, uint y)

Parameters

x uint

x position in pixels

y uint

y position in pixels

Returns

bool

True if the pixel is ink, false if it is paper

Render(float)

Render the image to a pixel array.

public Pixel[] Render(float seconds)

Parameters

seconds float

Used to handle the flash attribute

Returns

Pixel[]

a Pixel array representing the spectrum image at the time indicated

SetAttribute(uint, uint, byte)

Set the attribute at a specific location.

public void SetAttribute(uint ax, uint ay, byte attribute)

Parameters

ax uint

x position in attribute cells

ay uint

y position in attribute cells

attribute byte

attribute byte

Xor8Bits(uint, uint, byte, byte, bool)

Xor a set of 8 pixels horizontally to the screen. Performs an xor between the screen pixel and the bit in the bits byte. Attribute will be updated for the 8 pixels touched.

public void Xor8Bits(uint x, uint y, byte bits, byte attribute, bool flipX)

Parameters

x uint

x position in pixels

y uint

y position in pixels

bits byte

byte representing a set of 8 pixels

attribute byte

attribute byte

flipX bool

if true bits are drawn from right to left.

Xor8BitsNoAttribute(uint, uint, byte, bool)

Xor a set of 8 pixels horizontally to the screen. Performs an xor between the screen pixel and the bit in the bits byte.

public void Xor8BitsNoAttribute(uint x, uint y, byte bits, bool flipX)

Parameters

x uint

x position in pixels

y uint

y position in pixels

bits byte

byte representing a set of 8 pixels

flipX bool

if true bits are drawn from right to left.