savekey

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2021 License: GPL-3.0, GPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package savekey implements the SaveKey external memory card. It contains 32KB of non-volatile memory. Suitable for saving high scores, game settings, etc.

The SaveKey type implements the ports.Peripheral interface and can be inserted into a VCS port like any other peripheral.

SaveKey information taken from "AtariVox Programmer's Guide" (16/11/04) by Alex Herbert

i2c information taken from https://learn.sparkfun.com/tutorials/i2c/all (13/09/2020)

allocation list at https://atariage.com/atarivox/atarivox_mem_list.html (13/09/2020).

Index

Constants

View Source
const (
	TraceHi = 1.0
	TraceLo = -1.0
)

Variables

This section is empty.

Functions

func NewSaveKey

func NewSaveKey(port plugging.PortID, bus ports.PeripheralBus) ports.Peripheral

NewSaveKey is the preferred method of initialisation for the SaveKey type.

Types

type DataDirection

type DataDirection int

DataDirection indicates the direction of data flow between the VCS and the SaveKey.

const (
	Reading DataDirection = iota
	Writing
)

Valid DataDirection values.

type EEPROM

type EEPROM struct {
	// the next address an i2c read/write operation will access
	Address uint16
	// contains filtered or unexported fields
}

EEPROM represents the non-volatile memory in the SaveKey peripheral.

func (*EEPROM) Copy

func (ee *EEPROM) Copy() ([]uint8, []uint8)

Copy EEPROM data to a new array.

func (*EEPROM) Poke

func (ee *EEPROM) Poke(address uint16, data uint8)

Poke a value into EEPROM.

func (*EEPROM) Read

func (ee *EEPROM) Read()

Read EEPROM data from disk.

func (*EEPROM) Write

func (ee *EEPROM) Write()

Write EEPROM data to disk.

type MessageState

type MessageState int

MessageState records how incoming signals to the SaveKey will be interpreted.

const (
	Stopped MessageState = iota
	Starting
	AddressHi
	AddressLo
	Data
)

List of valid MessageState values.

type SaveKey

type SaveKey struct {

	// only two bits of the SWCHA value is of interest to the i2c protocol.
	// from the perspective of the second player (in which port the SaveKey is
	// usually inserted) pin 2 is the data signal (SDA) and pin 3 is the
	// clock signal (SCL)
	SDA trace
	SCL trace

	// incoming data is interpreted depending on the state of the i2c protocol.
	// we also need to know the direction of data flow at any given time and
	// whether the next bit should be acknowledged (the Ack bool)
	State MessageState
	Dir   DataDirection
	Ack   bool

	// Data is sent by the VCS one bit at a time. see pushBits(), popBits() and
	// resetBits() for
	Bits   uint8
	BitsCt int

	// the core of the SaveKey is an EEPROM.
	EEPROM *EEPROM
	// contains filtered or unexported fields
}

SaveKey represents the SaveKey peripheral. It implements the Peripheral interface.

func (*SaveKey) HandleEvent

func (sk *SaveKey) HandleEvent(_ ports.Event, _ ports.EventData) (bool, error)

HandleEvent implements the ports.Peripheral interface.

func (*SaveKey) ID added in v0.14.0

func (sk *SaveKey) ID() plugging.PeripheralID

ID implements the ports.Peripheral interface.

func (*SaveKey) IsActive added in v0.15.0

func (sk *SaveKey) IsActive() bool

IsActive implements the ports.Peripheral interface.

func (*SaveKey) Plumb

func (sk *SaveKey) Plumb(bus ports.PeripheralBus)

Plumb implements the ports.Peripheral interface.

func (*SaveKey) PortID added in v0.10.1

func (sk *SaveKey) PortID() plugging.PortID

PortID implements the ports.Peripheral interface.

func (*SaveKey) Reset

func (sk *SaveKey) Reset()

Reset implements the ports.Peripheral interface.

func (*SaveKey) Snapshot added in v0.15.0

func (sk *SaveKey) Snapshot() ports.Peripheral

Snapshot implements the Peripheral interface.

func (*SaveKey) Step

func (sk *SaveKey) Step()

Step implements the ports.Peripheral interface.

func (*SaveKey) String

func (sk *SaveKey) String() string

func (*SaveKey) Update

func (sk *SaveKey) Update(data bus.ChipData) bool

Update implements the ports.Peripheral interface.

Jump to

Keyboard shortcuts

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