cmv

package
v0.0.0-...-a0f82c1 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2017 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCompression1Reader

func NewCompression1Reader(r io.Reader) io.Reader

NewCompression1Reader wraps an io.Reader to decode Dwarf Fortress's chunked zlib format. The format consists of a stream of a uint32 length followed by that many bytes of compressed data.

func NewCompression1Writer

func NewCompression1Writer(w io.Writer) io.Writer

NewCompression1Writer wraps an io.Writer to output Dwarf Fortress's chunked zlib format. Each call to Write outputs its own frame, so the returned io.Writer should be wrapped in bufio.NewWriter if there will be many small writes.

func ReadHeader

func ReadHeader(r io.Reader, header *Header, sounds **Sounds) error

ReadHeader reads a CMV header from a file.

func ReadStringList

func ReadStringList(r io.Reader) ([]string, error)

ReadStringList reads the format used by Dwarf Fortress's announcement, dipscript, and help files.

func ReadStringList40d

func ReadStringList40d(r io.Reader) ([]string, error)

ReadStringList40d reads the format used by Dwarf Fortress 40d.

func ReadStringListIndex

func ReadStringListIndex(r io.Reader) ([]string, error)

ReadStringListIndex reads the format used by Dwarf Fortress's index file.

func ReadStringListIndex40d

func ReadStringListIndex40d(r io.Reader) ([]string, error)

ReadStringListIndex40d reads the format used by Dwarf Fortress 40d.

func ReadStringListWTF23a

func ReadStringListWTF23a(r io.Reader) ([]string, error)

ReadStringListWTF23a reads the format used by Dwarf Fortress 23a.

func WriteStringList

func WriteStringList(w io.Writer, l []string) error

WriteStringList writes the format used by Dwarf Fortress's announcement, dipscript, and help files.

func WriteStringList40d

func WriteStringList40d(w io.Writer, l []string) error

WriteStringList40d writes the format used by Dwarf Fortress 40d.

func WriteStringListIndex

func WriteStringListIndex(w io.Writer, l []string) error

WriteStringListIndex writes the format used by Dwarf Fortress's index file.

func WriteStringListIndex40d

func WriteStringListIndex40d(w io.Writer, l []string) error

WriteStringListIndex40d writes the format used by Dwarf Fortress 40d.

func WriteStringListWTF23a

func WriteStringListWTF23a(w io.Writer, l []string, header func() wtf23a.Header) error

WriteStringListWTF23a writes the format used by Dwarf Fortress 23a.

Types

type Frame

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

Frame represents a single frame of a CMV.

func (*Frame) Bg

func (f *Frame) Bg(x, y int) termbox.Attribute

Bg returns the background color on tile (x, y), where 0≤x<Width and 0≤y<Height. It is guaranteed to be one of the termbox.Color* constants.

func (*Frame) Byte

func (f *Frame) Byte(x, y int) byte

Byte returns the CP437-encoded character on tile (x, y), where 0≤x<Width and 0≤y<Height.

func (*Frame) Equal

func (f *Frame) Equal(o *Frame) bool

Equal returns true if f and o are from the same reader and have the same characters and colors for each tile.

func (*Frame) Fg

func (f *Frame) Fg(x, y int) termbox.Attribute

Fg returns the foreground color on tile (x, y), where 0≤x<Width and 0≤y<Height. It is guaranteed to be one of the termbox.Color* constants or one of the termbox.Color* constants ORed with termbox.AttrBold.

func (*Frame) Height

func (f *Frame) Height() int

Height returns the Height field of the Reader that created this Frame.

func (*Frame) Rune

func (f *Frame) Rune(x, y int) rune

Rune returns the character on tile (x, y), where 0≤x<Width and 0≤y<Height.

func (*Frame) Width

func (f *Frame) Width() int

Width returns the Width field of the Reader that created this Frame.

type Header struct {
	// Version is either 10000 (0x2710) or 10001 (0x2711). The latter
	// includes Sounds.
	Version uint32
	// Width is the number of columns in each frame of the CMV.
	Width uint32
	// Height is the number of rows in each frame of the CMV.
	Height uint32
	// FrameTicks is the frame rate in hundredths of a second per frame.
	// It can be 0, in which case the default frame rate is used.
	FrameTicks uint32
}

Header is the CMV header.

func (*Header) FrameTime

func (h *Header) FrameTime() time.Duration

FrameTime converts FrameTicks to a duration. It uses a default of 50 fps if FrameTicks is zero.

type Reader

type Reader struct {
	Header
	*Sounds
	// contains filtered or unexported fields
}

Reader reads CMV files.

func NewReader

func NewReader(r io.Reader) (*Reader, error)

NewReader returns a Reader that reads CMV files. If there is an error parsing the header, the error will be returned instead.

func (*Reader) Frame

func (r *Reader) Frame() (*Frame, error)

Frame reads and returns the next frame. Either the Frame or the error will be non-nil. io.EOF signals the end of the CMV.

type Sounds

type Sounds struct {
	Files  []string
	Timing [200][16]uint32
}

Sounds is the CMV 10001 sounds header, used by the intro videos for Dwarf Fortress.

Jump to

Keyboard shortcuts

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