Documentation ¶
Overview ¶
Package ports represents the input/output parts of the VCS (the IO in RIOT).
Implementations of the Peripheral interface can be attached with the AttachPlayer() functions.
Index ¶
- Constants
- type Event
- type EventData
- type EventPlayback
- type EventRecorder
- type NewPeripheral
- type Panel
- type Peripheral
- type PeripheralBus
- type PortID
- type Ports
- func (p *Ports) AttachEventRecorder(r EventRecorder)
- func (p *Ports) AttachPlayback(b EventPlayback)
- func (p *Ports) AttachPlayer(id PortID, c NewPeripheral) error
- func (p *Ports) GetPlayback() error
- func (p *Ports) HandleEvent(id PortID, ev Event, d EventData) error
- func (p *Ports) Plumb(riotMem bus.ChipBus, tiaMem bus.ChipBus)
- func (p *Ports) Reset()
- func (p *Ports) Snapshot() *Ports
- func (p *Ports) Step()
- func (p *Ports) String() string
- func (p *Ports) Update(data bus.ChipData) bool
- func (p *Ports) WriteINPTx(inptx addresses.ChipRegister, data uint8)
- func (p *Ports) WriteSWCHx(id PortID, data uint8)
Constants ¶
const (
PowerOff = "emulated machine has been powered off"
)
Sentinal error returned by Panel.HandleEvent() if power button is pressed.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Event ¶
type Event string
Event represents the actions that can be performed at one of the VCS ports, either the panel or one of the two player ports.
const ( NoEvent Event = "NoEvent" // nil // joystick. Fire Event = "Fire" // bool Up Event = "Up" // bool Down Event = "Down" // bool Left Event = "Left" // bool Right Event = "Right" // bool // paddles. PaddleFire Event = "PaddleFire" // bool PaddleSet Event = "PaddleSet" // float64 // keyboard. KeyboardDown Event = "KeyboardDown" // rune KeyboardUp Event = "KeyboardUp" // nil // panel. PanelSelect Event = "PanelSelect" // bool PanelReset Event = "PanelReset" // bool PanelSetColor Event = "PanelSetColor" // bool PanelSetPlayer0Pro Event = "PanelSetPlayer0Pro" // bool PanelSetPlayer1Pro Event = "PanelSetPlayer1Pro" // bool PanelToggleColor Event = "PanelToggleColor" // nil PanelTogglePlayer0Pro Event = "PanelTogglePlayer0Pro" // nil PanelTogglePlayer1Pro Event = "PanelTogglePlayer1Pro" // nil PanelPowerOff Event = "PanelPowerOff" // nil )
List of defined events.
type EventData ¶
type EventData interface{}
EventData is the value associated with the event. The underlying type should be restricted to bool, float32, or int. string is also acceptable but for simplicity of playback parsers, the strings "true" or "false" should not be used and numbers should be represented by float32 or int never as a string.
type EventPlayback ¶
type EventPlayback interface { // note the type restrictions on EventData in the type definition's // commentary GetPlayback() (PortID, Event, EventData, error) }
Playback implementations feed controller Events to the device on request with the CheckInput() function.
Intended for playback of controller events previously recorded to a file on disk but usable for many purposes I suspect. For example, AI control.
type EventRecorder ¶
EventRecorder implementations mirror an incoming event.
Implementations should be able to handle being attached to more than one peripheral at once. The ID parameter of the EventRecord() function will help to differentiate between multiple devices.
type NewPeripheral ¶
type NewPeripheral func(PortID, PeripheralBus) Peripheral
NewPeripheral defines the function signature for a creating a new peripheral, suitable for use with AttachPloyer0() and AttachPlayer1().
type Panel ¶
type Panel struct {
// contains filtered or unexported fields
}
Panel represents the console's front control panel.
func (*Panel) HandleEvent ¶
HandleEvent implements Peripheral interface.
func (*Panel) Plumb ¶
func (pan *Panel) Plumb(bus PeripheralBus)
Plumb implements the Peripheral interface.
type Peripheral ¶
type Peripheral interface { // String should return information about the state of the peripheral String() string // Plumb a new PeripheralBus into the Peripheral Plumb(PeripheralBus) // Name should return the canonical name for the peripheral (eg. "Paddle" // for the paddle peripheral). It shouldn't include information about which // port the peripheral is attached to. Name() string // handle an incoming input event HandleEvent(Event, EventData) error // memory has been updated. peripherals are notified. Update(bus.ChipData) bool // step is called every CPU clock. important for paddle devices Step() // reset state of peripheral. this has nothing to do with the reset switch // on the VCS panel Reset() }
Peripheral represents a (input or output) device that can attached to the VCS ports.
func NewPanel ¶
func NewPanel(bus PeripheralBus) Peripheral
NewPanel is the preferred method of initialisation for the Panel type.
type PeripheralBus ¶
type PeripheralBus interface { WriteINPTx(inptx addresses.ChipRegister, data uint8) // the SWCHA register is logically divided into two nibbles. player 0 // uses the upper nibble and player 1 uses the lower nibble. peripherals // attached to either player port *must* only use the upper nibble. this // write function will transparently shift the data into the lower nibble // for peripherals attached to the player 1 port. // // also note that peripherals do not need to worry about preserving bits // in the opposite nibble. the WriteSWCHx implementation will do that // transparently according to which port the peripheral is attached // // Peripherals attached to the panel port can use the entire byte of the // SWCHB register WriteSWCHx(id PortID, data uint8) }
PeripheralBus defines the memory operations required by peripherals. We keep this bus definition here rather than the Bus package because it is very specific to this package and sub-packages.
type PortID ¶
type PortID int
PortID differentiates the different ports peripherals can be attached to.
type Ports ¶
type Ports struct { Panel Peripheral Player0 Peripheral Player1 Peripheral // contains filtered or unexported fields }
Input implements the input/output part of the RIOT (the IO in RIOT).
func (*Ports) AttachEventRecorder ¶
func (p *Ports) AttachEventRecorder(r EventRecorder)
AttachEventRecorder attaches an EventRecorder implementation to all ports that implement RecordablePort.
func (*Ports) AttachPlayback ¶
func (p *Ports) AttachPlayback(b EventPlayback)
AttachPlayback attaches an EventPlayback implementation to all ports that implement RecordablePort.
func (*Ports) AttachPlayer ¶
func (p *Ports) AttachPlayer(id PortID, c NewPeripheral) error
AttachPlayer attaches a peripheral (represented by a PeripheralConstructor) to a port.
func (*Ports) GetPlayback ¶
GetPlayback requests playback events from all attached and eligible peripherals.
func (*Ports) Update ¶
Update checks to see if ChipData applies to the Input type and updates the internal controller/panel states accordingly. Returns true if ChipData requires more attention.
func (*Ports) WriteINPTx ¶
func (p *Ports) WriteINPTx(inptx addresses.ChipRegister, data uint8)
WriteINPTx implements the MemoryAccess interface.
func (*Ports) WriteSWCHx ¶
WriteSWCHx implements the MemoryAccess interface.
Directories ¶
Path | Synopsis |
---|---|
Package controllers contains the implementations for all the emulated controllers for the VCS.
|
Package controllers contains the implementations for all the emulated controllers for the VCS. |
Package savekey implements the SaveKey external memory card.
|
Package savekey implements the SaveKey external memory card. |