c80machine

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 31, 2020 License: MIT Imports: 23 Imported by: 0

Documentation

Overview

Package c80machine provides a type that represents a fantasy virtual machine inspired by arcade game machines, home video game consoles, handheld game consoles, and (other) computers from the 1980s.

Index

Examples

Constants

View Source
const (
	PTR_PALETTE = 0
	LEN_PALETTE = palette2048.ByteSize

	PTR_FRAME = PTR_PALETTE + LEN_PALETTE
	LEN_FRAME = frame256x288.ByteSize

	PTR_TILEMAP = PTR_FRAME + LEN_FRAME
	LEN_TILEMAP = tilemap8x8x256x256.ByteSize

	PTR_TILES = PTR_TILEMAP + LEN_TILEMAP
	LEN_TILES = spritesheet8x8x256.ByteSize

	PTR_SPRITES8x8 = PTR_TILES + LEN_TILES
	LEN_SPRITES8x8 = spritesheet8x8x256.ByteSize

	PTR_SPRITES32x32 = PTR_SPRITES8x8 + LEN_SPRITES8x8
	LEN_SPRITES32x32 = spritesheet32x32x256.ByteSize

	PTR_TEXTMATRIX = PTR_SPRITES32x32 + LEN_SPRITES32x32
	LEN_TEXTMATRIX = text32x36.ByteSize
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Terminator

type Terminator interface {
	image.Image

	Clear()
	Height() int
	LineFeed()
	Publish(s string)
	Runes() []rune
	String() string
	Width() int
}

type Type

type Type struct {
	// contains filtered or unexported fields
}

Type represents a fantasy virtual machine.

func (*Type) At

func (receiver *Type) At(x, y int) color.Color

func (*Type) Bounds

func (receiver *Type) Bounds() image.Rectangle

func (*Type) ColorIndex

func (receiver *Type) ColorIndex(c color.Color) uint8

func (*Type) ColorModel

func (receiver *Type) ColorModel() color.Model

func (*Type) Colorize

func (receiver *Type) Colorize(a ...interface{}) error

Colorize sets the color palette.

Example

Here are some examples of Colorize being used:

err := machine.Colorize("tia")

func (*Type) Draw

func (receiver *Type) Draw(img image.Image) error

func (*Type) DrawDye

func (receiver *Type) DrawDye(color color.Color) error

func (*Type) DrawPixel

func (receiver *Type) DrawPixel(x int, y int, color color.Color) error

func (*Type) Frame

func (receiver *Type) Frame() []uint8

func (*Type) Image

func (receiver *Type) Image() draw.Image

func (*Type) Map

func (receiver *Type) Map() image.Image

func (*Type) Memory

func (receiver *Type) Memory() []uint8

func (*Type) Palette

func (receiver *Type) Palette() palette2048.Slice

Palette provides access to the machines palette.

Example
var machine c80machine.Type

// We set the RGBA values of each of the colors in the palette.
//
// (“RGBA” = Red, Green, Blue, Alpha.)
//
// The colors in the palette are indexed from 0 to 15.
//
// So, here, color №5 is rgba(118,38,113,255).
//
// And, also here, color №0 is rgba(1,1,1,255).
machine.Palette().SetColorRGB(0, 1, 1, 1)
machine.Palette().SetColorRGB(1, 222, 56, 43)
machine.Palette().SetColorRGB(2, 57, 181, 74)
machine.Palette().SetColorRGB(3, 255, 199, 6)
machine.Palette().SetColorRGB(4, 0, 111, 184)
machine.Palette().SetColorRGB(5, 118, 38, 113)
machine.Palette().SetColorRGB(6, 44, 181, 233)
machine.Palette().SetColorRGB(7, 204, 204, 204)
machine.Palette().SetColorRGB(8, 128, 128, 128)
machine.Palette().SetColorRGB(9, 255, 0, 0)
machine.Palette().SetColorRGB(10, 0, 255, 0)
machine.Palette().SetColorRGB(11, 255, 255, 0)
machine.Palette().SetColorRGB(12, 0, 0, 255)
machine.Palette().SetColorRGB(13, 255, 0, 255)
machine.Palette().SetColorRGB(14, 0, 255, 255)
machine.Palette().SetColorRGB(15, 255, 255, 255)

fmt.Println(machine.Palette().Color(0))
fmt.Println(machine.Palette().Color(1))
fmt.Println(machine.Palette().Color(2))
fmt.Println(machine.Palette().Color(3))
fmt.Println(machine.Palette().Color(4))
fmt.Println(machine.Palette().Color(5))
fmt.Println(machine.Palette().Color(6))
fmt.Println(machine.Palette().Color(7))
fmt.Println(machine.Palette().Color(8))
fmt.Println(machine.Palette().Color(9))
fmt.Println(machine.Palette().Color(10))
fmt.Println(machine.Palette().Color(11))
fmt.Println(machine.Palette().Color(12))
fmt.Println(machine.Palette().Color(13))
fmt.Println(machine.Palette().Color(14))
fmt.Println(machine.Palette().Color(15))
Output:

rgba(1,1,1,255)
rgba(222,56,43,255)
rgba(57,181,74,255)
rgba(255,199,6,255)
rgba(0,111,184,255)
rgba(118,38,113,255)
rgba(44,181,233,255)
rgba(204,204,204,255)
rgba(128,128,128,255)
rgba(255,0,0,255)
rgba(0,255,0,255)
rgba(255,255,0,255)
rgba(0,0,255,255)
rgba(255,0,255,255)
rgba(0,255,255,255)
rgba(255,255,255,255)

func (*Type) Rectangle

func (receiver *Type) Rectangle(x, y int, width, height int, index uint8) image.Image

func (*Type) Reveal

func (receiver *Type) Reveal()

func (*Type) Serialize

func (receiver *Type) Serialize() string

func (*Type) Set

func (receiver *Type) Set(x, y int, c color.Color)

func (*Type) SetSprite

func (receiver *Type) SetSprite(kind string, id uint8, img image.Image) error

SetSprite sets the value of a sprite to the built-in image.Image.

There are 3 kinds of sprites:

• 8x8 • 32x32 • tile

For each fo these, the id runs from 0 to 255.

func (*Type) Sprite

func (receiver *Type) Sprite(kind string, id uint8) image.Image

Sprite returns a sprite as a Go built-in image.Image.

There are 3 kinds of sprites:

• 8x8 • 32x32 • tile

For each fo these, the id runs from 0 to 255.

func (*Type) Terminal

func (receiver *Type) Terminal() Terminator

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL