video

package
v0.20.0 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2020 License: GPL-3.0 Imports: 1 Imported by: 0

Documentation

Overview

Package video contains video components and devices

Index

Constants

View Source
const (
	MC6845HorizontalTotal = iota
	MC6845HorizontalDisplayed
	MC6845HorizontalSyncPosition
	MC6845SyncWidths
	MC6845VerticalTotal
	MC6845VerticalTotalAdjust
	MC6845VerticalDisplayed
	MC6845VerticalSyncPosition
	MC6845InterlaceAndSkew
	MC6845MaxScanlineAddress
	MC6845CursorStart
	MC6845CursorEnd
	MC6845StartAddressHigh
	MC6845StartAddressLow
	MC6845CursorHigh
	MC6845CursorLow
	MC6845LightPenHigh
	MC6845LightPenLow
)

MC6845 register constants

View Source
const (
	MC6845Nreg = 0x12 // 18 registers
)

MC6845 constants

Variables

View Source
var (
	MC6845Defaults = [MC6845Nreg]byte{
		0x3f, 0x28, 0x2e, 0x8e, 0x26, 0x00, 0x19, 0x1e, 0x00,
		0x07, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00}
	MC6845Masks = [MC6845Nreg]byte{
		0xff, 0xff, 0xff, 0xff, 0x7f, 0x1f, 0x7f, 0x7f, 0x03,
		0x1f, 0x1f, 0x1f, 0x3f, 0xff, 0x3f, 0xff, 0x3f, 0xff}
)

MC6845 register data

Functions

This section is empty.

Types

type MC6845

type MC6845 struct {

	// registers
	HorizontalTotal        byte
	HorizontalDisplayed    byte
	HorizontalSyncPosition byte
	SyncWidths             byte
	VerticalTotal          byte
	VerticalTotalAdjust    byte
	VerticalDisplayed      byte
	VerticalSyncPosition   byte
	InterlaceAndSkew       byte
	MaxScanlineAddress     byte
	CursorStart            byte
	CursorEnd              byte
	StartAddressHigh       byte
	StartAddressLow        byte
	CursorHigh             byte
	CursorLow              byte
	LightPenHigh           byte
	LightPenLow            byte

	// callbacks
	OnHSync device.Callback
	OnVSync device.Callback
	// contains filtered or unexported fields
}

MC6845 Crtc Device

func NewMC6845

func NewMC6845() *MC6845

NewMC6845 creates new CRTC

func (*MC6845) CurrentCol

func (mc *MC6845) CurrentCol() byte

CurrentCol current row column

func (*MC6845) CurrentLine

func (mc *MC6845) CurrentLine() byte

CurrentLine current line in row

func (*MC6845) CurrentRow

func (mc *MC6845) CurrentRow() byte

CurrentRow current row

func (*MC6845) Emulate

func (mc *MC6845) Emulate(tstates int)

Emulate emulates Tstates

func (*MC6845) InHSync

func (mc *MC6845) InHSync() bool

InHSync in HSync

func (*MC6845) InVSync

func (mc *MC6845) InVSync() bool

InVSync in VSync

func (*MC6845) Init

func (mc *MC6845) Init()

Init the CRTC

func (*MC6845) OnClock

func (mc *MC6845) OnClock()

OnClock emulates one clock cycle (1MHz)

func (*MC6845) Read

func (mc *MC6845) Read(port byte) byte

Read reads data

func (*MC6845) ReadRegister

func (mc *MC6845) ReadRegister(register byte) byte

ReadRegister returns register value

func (*MC6845) Register

func (mc *MC6845) Register(index byte) byte

Register gets register value at index

func (*MC6845) Reset

func (mc *MC6845) Reset()

Reset the CRTC

func (*MC6845) SelectRegister

func (mc *MC6845) SelectRegister(selected byte)

SelectRegister selects current register

func (*MC6845) Selected

func (mc *MC6845) Selected() byte

Selected selected register

func (*MC6845) SetDefaults

func (mc *MC6845) SetDefaults(defaults [MC6845Nreg]byte)

SetDefaults sets default register values

func (*MC6845) Write

func (mc *MC6845) Write(port byte, data byte)

Write writes data

func (*MC6845) WriteRegister

func (mc *MC6845) WriteRegister(register, data byte)

WriteRegister writes value to register

type Rect

type Rect struct {
	X, Y, W, H int
}

Rect is a screen region

func (*Rect) Crop

func (r *Rect) Crop(or *Rect)

Crop crops the rect by other intersection

func (*Rect) Intersect

func (r *Rect) Intersect(o *Rect) Rect

Intersect calculates the intersection with another rect

func (*Rect) IsEmpty

func (r *Rect) IsEmpty() bool

IsEmpty indicates if the rect is empty

func (*Rect) Resize

func (r *Rect) Resize(w, h int)

Resize resizes the rect

func (*Rect) Scale

func (r *Rect) Scale(sx, sy float32)

Scale scales the rect by horizontal and vertical factors

func (*Rect) Translate

func (r *Rect) Translate(dx, dy int)

Translate translates the rect by horizontal and vertical distances

type Renderer added in v0.20.0

type Renderer interface {
	// Render renders screen
	Render(screen *Screen)
}

Renderer is the video screen renderer

type Screen

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

Screen represents a video screen with a pixel buffer of width x height size. Each pixel represents an int32 color, no specific format (RGBA, BGRA,...) Coordinates starts at upper left corner.

func NewScreen

func NewScreen(width, height int, palette []uint32) *Screen

NewScreen creates a screen of size width x height and palette

func (*Screen) Clear

func (screen *Screen) Clear(index int)

Clear clears the screen

func (*Screen) Data

func (screen *Screen) Data() []uint32

Data is the pixel data buffer

func (*Screen) DirtyRects

func (screen *Screen) DirtyRects() []*Rect

DirtyRects returns the regions to refresh

func (*Screen) Display added in v0.20.0

func (screen *Screen) Display() Rect

Display is the display rect

func (*Screen) GetColour

func (screen *Screen) GetColour(index int) uint32

GetColour gets colour from palette index

func (*Screen) GetPixel

func (screen *Screen) GetPixel(x, y int) uint32

GetPixel gets colour from pixel coordinates

func (*Screen) Height

func (screen *Screen) Height() int

Height gets screen Height

func (*Screen) IsDirty

func (screen *Screen) IsDirty() bool

IsDirty true if screen is dirty

func (*Screen) Palette

func (screen *Screen) Palette() []uint32

Palette returns the colour palette

func (*Screen) Rects

func (screen *Screen) Rects() []Rect

Rects returns all screen regions

func (*Screen) ScaleX

func (screen *Screen) ScaleX() float32

ScaleX gets screen horizontal scale

func (*Screen) ScaleY

func (screen *Screen) ScaleY() float32

ScaleY gets screen vertical scale

func (*Screen) SetDirty

func (screen *Screen) SetDirty(dirty bool)

SetDirty sets if screen is dirty

func (*Screen) SetDisplay added in v0.20.0

func (screen *Screen) SetDisplay(X, Y, W, H int)

SetDisplay sets screen display

func (*Screen) SetPixel

func (screen *Screen) SetPixel(x, y int, colour uint32)

SetPixel sets colour at pixel coordinates

func (*Screen) SetPixelIndex

func (screen *Screen) SetPixelIndex(x, y int, index int)

SetPixelIndex sets colour index at pixel coordinates

func (*Screen) SetScaleX

func (screen *Screen) SetScaleX(scale float32)

SetScaleX sets screen horizontal scale

func (*Screen) SetScaleY

func (screen *Screen) SetScaleY(scale float32)

SetScaleY sets screen vertical scale

func (*Screen) Width

func (screen *Screen) Width() int

Width gets screen Width

type Video

type Video interface {
	device.Device // Is a device
	// EndFrame updates screen video frame
	EndFrame()
	// The video screen
	Screen() *Screen
}

Video is a video device

Jump to

Keyboard shortcuts

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