memory

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: May 7, 2026 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Create

func Create(ctx Context) (*Memory, AddChips)

func Read

func Read(area Area, address uint16) (uint8, error)

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

func Write

func Write(area Area, address uint16, data uint8) error

Write a value to the specified address of the area. This method of writing memory is for more direct uses (eg. a debugger POKE 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

type AddChips func(maria Area, tia Area, riot Area)

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 Context

type Context interface {
	ram.Context
	external.Context
	inptctrl.Context
	Spec() spec.Spec
}

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) HLT added in v0.6.0

func (mem *Memory) HLT(halt bool)

HLT should be called whenever the HLT line is changed

func (*Memory) IsSlowAddressBus added in v0.2.0

func (mem *Memory) IsSlowAddressBus() bool

func (*Memory) LastReadIsRIOT added in v0.7.3

func (mem *Memory) LastReadIsRIOT() bool

LastReadIsRIOT is used by the trakball peripheral

func (*Memory) MapAddress

func (mem *Memory) MapAddress(address uint16, read bool) (uint16, Area)

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

func (mem *Memory) Read(address uint16) (uint8, error)

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

func (*Memory) Reset

func (mem *Memory) Reset(random bool)

func (*Memory) Write

func (mem *Memory) Write(address uint16, data uint8) error

Write memory address as driven by the CPU. This method of writing produces side-effects to the memory system, in addition to the explicit writing of data. For writing to memory without side-effects use the package level Write() function

Directories

Path Synopsis
elf
Package ace implements the ELF cartridge mapper.
Package ace implements the ELF cartridge mapper.
hsc
Package hsc implements the high-score cartridge shim for the 7800.
Package hsc implements the high-score cartridge shim for the 7800.

Jump to

Keyboard shortcuts

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