memory

package
v0.31.0 Latest Latest
Warning

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

Go to latest
Published: May 5, 2024 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package memory implements the Atari VCS memory model. The addresses and memory sub-packages help with this.

It is important to understand that memory is viewed differently by different parts of the VCS system. To help with this, the emulation uses what we call memory buses. These buses have nothing to do with the real hardware; they are purely conceptual and are implemented through Go interfaces.

The following ASCII diagram tries to show how the different components of the VCS are connected to the memory. What may not be clear from this diagram is that the peripheral bus only ever writes to memory. The other buses are bidirectional.

                    PERIPHERALS

                         |
                         |
                         \/

                     periph bus

                         |
                         |
                         \/

CPU ---- cpu bus ---- MEMORY ---- chip bus ---- TIA
                                            \
                         |                   \
                         |                    \---- RIOT

                    debugger bus

                         |
                         |

                      DEBUGGER

The memory itself is divided into areas, defined in the memorymap package. Removing the periph bus and debugger bus from the picture, the above diagram with memory areas added is as follows:

                       ===* TIA ---- chip bus ---- TIA
                      |
                      |===* RIOT ---- chip bus ---- RIOT
CPU ---- cpu bus -----
                      |===* PIA RAM
                      |
                       ==== Cartridge

The asterisk indicates that addresses used by the CPU are mapped to the primary mirror address. The memorymap package contains more detail on this.

Cartridge memory is accessed by whatever mirror address the CPU wants. This is because some cartridge formats might be sensitive to which mirror is being used (eg. Supercharger). Cartridges also implement a Listen() function. This is a special function outside of the bussing system. See cartridge package for details.

Note that the RIOT registers and PIA RAM are all part of the same hardware package, the PIA 6532. However, for our purposes the two memory areas are considered to be entirely separate.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DebugBus added in v0.16.0

type DebugBus interface {
	Read(address uint16) (uint8, uint8, error)
	Write(address uint16, data uint8) error
	Peek(address uint16) (uint8, error)
	Poke(address uint16, value uint8) error
}

DebugBus defines the meta-operations for all memory areas. Think of these functions as "debugging" functions, that is operations outside of the normal operation of the machine.

type FieldBus added in v0.16.0

type FieldBus interface {
	PeekField(field string) interface{}
	PokeField(field string, value interface{})
}

Note that in many cases poking a register will not have the effect you might imagine. It is often better, therefore, to affect a "field" rather than a single address. This is because poking doesn't change the state of the hardware that leads to the value that is eventually put into the register.

For hardware components where this is important the functions PeekField() and PokeField() are provided.

The field argument and value type is component specific. The allowed values and types for each field will be provided in the documentation of the DebugFieldBus implemention.

Note that unlike the functions in the DebugBus interface, these functions will not return an error. The functions should panic on any unexpected error.

type Memory added in v0.7.1

type Memory struct {
	RIOT *vcs.RIOTMemory
	TIA  *vcs.TIAMemory
	RAM  *vcs.RAM
	Cart *cartridge.Cartridge

	// the following are only used by the debugging interface
	//
	//  . a note of the last literal memory address to be accessed
	//  . as above but the mapped address
	//  . the value that was written/read from the last address accessed
	//  . whether the last address accessed was written or read
	//
	// * the literal address is the address as it appears in the 6507 program.
	// and therefore it might be more than 13 bits wide. as such it is not
	// representative of what happens on the address bus
	//
	// it is sometimes useful to know what the literal address is, distinct
	// from the mapped address, for debugging purposes.
	LastCPUAddressLiteral uint16
	LastCPUAddressMapped  uint16
	LastCPUData           uint8
	LastCPUWrite          bool

	// the actual values that have been put on the address and data buses.
	AddressBus uint16
	DataBus    uint8

	// not all pins of the databus are driven at all times. bits set in
	// the DataBusDriven field indicate the pins that are being driven
	DataBusDriven uint8
	// contains filtered or unexported fields
}

Memory is the monolithic representation of the memory in 2600.

func NewMemory added in v0.7.1

func NewMemory(env *environment.Environment) *Memory

NewMemory is the preferred method of initialisation for Memory.

func (*Memory) GetArea added in v0.7.1

func (mem *Memory) GetArea(area memorymap.Area) DebugBus

GetArea returns the actual memory of the specified area type.

func (*Memory) Peek added in v0.7.1

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

Peek implements the DebugBus interface.

func (*Memory) Plumb added in v0.8.0

func (mem *Memory) Plumb(env *environment.Environment, fromDifferentEmulation bool)

Plumb makes sure everything is ship-shape after a rewind event.

The fromDifferentEmulation indicates that the State has been created by a different VCS emulation than the one being plumbed into.

func (*Memory) Poke added in v0.7.1

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

Poke implements the DebugBus interface.

func (*Memory) Read added in v0.7.1

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

Readt is an implementation of CPUBus. Address will be normalised and processed by the correct memory areas.

func (*Memory) Reset added in v0.7.1

func (mem *Memory) Reset()

Reset contents of memory.

func (*Memory) Snapshot added in v0.7.1

func (mem *Memory) Snapshot() *Memory

Snapshot creates a copy of the current memory state.

func (*Memory) String added in v0.20.0

func (mem *Memory) String() string

func (*Memory) Write added in v0.7.1

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

Write is an implementation of CPUBus. Address will be normalised and processed by the correct memory areas.

Directories

Path Synopsis
Package cartridge fully implements loading of mapping of cartridge memory.
Package cartridge fully implements loading of mapping of cartridge memory.
ace
Package ace implements the ACE cartridge mapper.
Package ace implements the ACE cartridge mapper.
arm
Package arm imlplements the ARM7TDMI instruction set as defined in the ARM7TDMI Instruction Set Reference:
Package arm imlplements the ARM7TDMI instruction set as defined in the ARM7TDMI Instruction Set Reference:
arm/architecture
Package architecture defines the Map type that is used to specify the differences in cartridge and ARM archtectures.
Package architecture defines the Map type that is used to specify the differences in cartridge and ARM archtectures.
arm/callfn
Package Callfn facilitates the ARM CALLFN process common to both DPC+ and CDF* cartridge mappers.
Package Callfn facilitates the ARM CALLFN process common to both DPC+ and CDF* cartridge mappers.
arm/peripherals
Package peripherals implements the optional modules that can make up the ARM processor.
Package peripherals implements the optional modules that can make up the ARM processor.
cdf
Package cdf implemnents the various CDF type cartridge mappers including CDFJ.
Package cdf implemnents the various CDF type cartridge mappers including CDFJ.
dpcplus
Package dpcplus implements the DPC+ cartridge mapper.
Package dpcplus implements the DPC+ cartridge mapper.
elf
Package ace implements the ELF cartridge mapper.
Package ace implements the ELF cartridge mapper.
mapper
Package mapper contains the CartMapper interface.
Package mapper contains the CartMapper interface.
moviecart
Package moviecart implements the Movie Cart special cartridge type.
Package moviecart implements the Movie Cart special cartridge type.
plusrom
Package plusrom implements the PlusROM cartridge as developed by Wolfgang Stubig.
Package plusrom implements the PlusROM cartridge as developed by Wolfgang Stubig.
plusrom/plusnet
Package plusnet contains details of the PlusNET protocol.
Package plusnet contains details of the PlusNET protocol.
supercharger
Package supercharger implements the tape based cartridge format.
Package supercharger implements the tape based cartridge format.
Package chipbus defines the operations, addresses and symbols that are required by the TIA and RIOT chips when updated values in memory.
Package chipbus defines the operations, addresses and symbols that are required by the TIA and RIOT chips when updated values in memory.
Package cpubus defines the operations, addresses and symbols that are required by the CPU when reading/writing to memory.
Package cpubus defines the operations, addresses and symbols that are required by the CPU when reading/writing to memory.
Package memorymap facilitates the translation of addresses to primary address equivalents.
Package memorymap facilitates the translation of addresses to primary address equivalents.
Package vcs represents the areas of memory that are internal to the VCS hardware.
Package vcs represents the areas of memory that are internal to the VCS hardware.

Jump to

Keyboard shortcuts

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