Documentation
¶
Index ¶
- func Create(ctx Context) (*Memory, AddChips)
- func Read(area Area, address uint16) (uint8, error)
- func Write(area Area, address uint16, data uint8) error
- type AddChips
- type Area
- type Context
- type Memory
- func (mem *Memory) HLT(halt bool)
- func (mem *Memory) IsSlowAddressBus() bool
- func (mem *Memory) LastReadIsRIOT() bool
- func (mem *Memory) MapAddress(address uint16, read bool) (uint16, Area)
- func (mem *Memory) Read(address uint16) (uint8, error)
- func (mem *Memory) Reset(random bool)
- func (mem *Memory) Write(address uint16, data uint8) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Read ¶
Read memory of the specified area. This method of reading memory is for more direct uses (eg. a debugger PEEK command) and does not effect the general state of memory
The area and address parameters should be acquired from the MapAddress() function
Types ¶
type AddChips ¶
AddChips is returned by the Create() function and should be called to finalise the memory creation process
type Area ¶
type Area interface {
Label() string
// all valid memory areas must have an implementation of the Access()
// function
//
// the write parameter represents the stats of the R/W line in the console.
// individual memory areas can ignore this if it is not required or not
// connected (2600 cartridge types)
//
// the address_or_idx parameter is either the raw unmapped address or an
// index relative to the origin of the memory area. implementations of the
// Area interface should make this clear by appropriate naming of the parameter.
// more practically, the value of address_or_idx can be obtained through the
// MapAddress() function
//
// the data parameter is the state of the data bus at the time of the call.
// the write parameter indicates if the bus is being driven by the CPU at
// the time of access (write will be true)
//
// the state of the data bus is returned along with an error. if the memory
// area is not driving the data bus then the supplied data bus value should
// be returned unchanged
//
// in rare cases where a memory area drives the data bus while the write
// parameter is true (ie. the CPU is also driving the data bus) the conflict
// should be resolved in the area implementation
//
// NOTE: the Access() function is provided instead of a separate Read/Write
// functions. individual areas may have Read/Write functions for other
// purposes (eg. the PEEK and POKE commands in a debugger) but these are not
// necessary for emulation of memory
//
// for the more direct type of access the package level Read() and Write()
// functions are provided
Access(write bool, address_or_idx uint16, data uint8) (uint8, error)
}
type Memory ¶
type Memory struct {
BIOS *bios.BIOS
INPTCTRL *inptctrl.INPTCTRL
RAM7800 *ram.RAM
RAMRIOT *ram.RAM
External *external.Device
MARIA Area
TIA Area
RIOT Area
// the last Area that was read from and written to
LastRead Area
LastWrite Area
// the following are only used by the debugger
LastCPUAddress uint16
LastCPUData uint8
LastCPUWrite bool
// contains filtered or unexported fields
}
func (*Memory) IsSlowAddressBus ¶ added in v0.2.0
func (*Memory) LastReadIsRIOT ¶ added in v0.7.3
LastReadIsRIOT is used by the trakball peripheral
func (*Memory) MapAddress ¶
MapAddress returns the memory "area" and a "mapped" address for the area corresponding to the address. the "mapped" address can either be a normalised address relative to $0000 or an index relative to the origin of the area.
The result partially depends on the state of INPTCTRL. It will always return INPTCTRL, MARIA, etc. unless the Lock() is true and TIA() is true, in which case it may return TIA, INPTCTRL or MARIA depending on the address.
It is possible for a nil Area to be returned. In which case, the index value will be zero.
func (*Memory) Read ¶
Read memory address as viewed by the CPU. This method of reading creates side-effects to the memory system. For reading of memory without side-effects use the package level Read() function