formats

package
v0.0.0-...-09ec4ce Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Decoding and encoding of ZX Spectrum emulator file formats

Index

Constants

View Source
const (
	TAP_FILE_PROGRAM         = 0
	TAP_FILE_NUMBER_ARRAY    = 1
	TAP_FILE_CHARACTER_ARRAY = 2
	TAP_FILE_CODE            = 3

	TAP_BLOCK_HEADER = 0x00
	TAP_BLOCK_DATA   = 0xff
)
View Source
const (
	TStatesPerFrame = 69888
	InterruptLength = 32
)
View Source
const (
	FORMAT_SNA = iota
	FORMAT_Z80
	FORMAT_TAP
)
View Source
const (
	ENCAPSULATION_NONE = iota
	ENCAPSULATION_ZIP
)

Variables

This section is empty.

Functions

func ReadProgram

func ReadProgram(filePath string) (interface{}, error)

Read a program from the specified file. Return the program and errors if any. The file can be compressed.

Types

type Archive

type Archive interface {
	Filenames() []string
	Read(fileIndex int) ([]byte, error)
}

type CpuState

type CpuState struct {
	A, F, B, C, D, E, H, L         byte
	A_, F_, B_, C_, D_, E_, H_, L_ byte
	IX, IY                         uint16
	I, R, IFF1, IFF2, IM           byte
	SP, PC                         uint16

	Tstate uint
}

type FormatInfo

type FormatInfo struct {
	Format        int
	Encapsulation int
}

func DetectFormat

func DetectFormat(filePath string) (*FormatInfo, error)

Determines the format of the specified file based on its name, or based on the names of embedded files in case the file is an archive. Returns an error if the format could not be detected.

type FullSnapshot

type FullSnapshot struct {
	Cpu CpuState
	Ula UlaState
	Mem [48 * 1024]byte
}

func (*FullSnapshot) CpuState

func (s *FullSnapshot) CpuState() CpuState

func (*FullSnapshot) EncodeSNA

func (s *FullSnapshot) EncodeSNA() ([]byte, error)

Turn snapshot into binary data (SNA format)

func (*FullSnapshot) Memory

func (s *FullSnapshot) Memory() *[48 * 1024]byte

func (*FullSnapshot) UlaState

func (s *FullSnapshot) UlaState() UlaState

type SNA

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

func (*SNA) CpuState

func (s *SNA) CpuState() CpuState

func (*SNA) Memory

func (s *SNA) Memory() *[48 * 1024]byte

func (*SNA) UlaState

func (s *SNA) UlaState() UlaState

type Snapshot

type Snapshot interface {
	CpuState() CpuState
	UlaState() UlaState
	Memory() *[48 * 1024]byte
}

type SnapshotData

type SnapshotData []byte

func (SnapshotData) Decode

func (data SnapshotData) Decode(format int) (Snapshot, error)

Decode a snapshot from binary data. The filename is a hint used to determine the snapshot format.

func (SnapshotData) DecodeSNA

func (data SnapshotData) DecodeSNA() (*SNA, error)

Decode SNA from binary data

func (SnapshotData) DecodeZ80

func (data SnapshotData) DecodeZ80() (*Z80, error)

Decode [Z80 snapshot] from binary data

type TAP

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

func NewTAP

func NewTAP(data []byte) (*TAP, error)

func (*TAP) At

func (tap *TAP) At(pos uint) byte

func (*TAP) GetBlock

func (tap *TAP) GetBlock(pos int) tapBlock

func (*TAP) Len

func (tap *TAP) Len() uint

type UlaState

type UlaState struct {
	// 0..7
	Border byte
}

type Z80

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

func (*Z80) CpuState

func (s *Z80) CpuState() CpuState

func (*Z80) Memory

func (s *Z80) Memory() *[48 * 1024]byte

func (*Z80) UlaState

func (s *Z80) UlaState() UlaState

type ZipArchive

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

func ReadZip

func ReadZip(r io.ReaderAt, size int64) (*ZipArchive, error)

func ReadZipFile

func ReadZipFile(filePath string) (*ZipArchive, error)

func (*ZipArchive) Filenames

func (a *ZipArchive) Filenames() []string

func (*ZipArchive) Read

func (a *ZipArchive) Read(fileIndex int) ([]byte, error)

Jump to

Keyboard shortcuts

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