memorymap

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2020 License: GPL-3.0, GPL-3.0 Imports: 2 Imported by: 0

Documentation

Overview

Package memorymap facilitates the translation of addresses to primary address equivalents.

Because of the limited number of address lines used by the 6507 in the VCS the number of addressable locations is a lot less than the 16bit suggested by the addressing model of the CPU. The MapAddress() functions should be used to produce a "mapped address" whenever an address is being used from the viewport of the CPU. (Writing to memory from the viewpoint of TIA & RIOT is completely different)

ma, _ := memorymap.MapAddress(address, true)

The second argument indicates if the address is being read or being written to. Some addresses require an additional transformation if they are being read. Again, the details are handled by the function.

During development an internal alternative to the CPUBus was considered (see bus package). The idea was to force use of mapped address when required. This would require new type, MappedAddr, which MapAddress() would return a value of. The MappedCPUBus in turn would expect address values of that type. However, after some experimentation the idea was deemed to be too clumsy and didn't help in clarification. If the memory implementation was required to be more general then it would be a good idea but as it is, it is not necessary.

Index

Constants

View Source
const (
	OriginTIA  = uint16(0x0000)
	MemtopTIA  = uint16(0x003f)
	OriginRAM  = uint16(0x0080)
	MemtopRAM  = uint16(0x00ff)
	OriginRIOT = uint16(0x0280)
	MemtopRIOT = uint16(0x0297)
	OriginCart = uint16(0x1000)
	MemtopCart = uint16(0x1fff)
)

The origin and memory top for each area of memory. Checking which area an address falls within and forcing the address into the normalised range is all handled by the MapAddress() function.

Implementations of the different memory areas may need to drag the address down into the the range of an array. This can be done by with elegantly with (address^origin) rather than subtraction.

View Source
const (
	AddressMaskRIOT = uint16(0x02f7)
	AddressMaskTIA  = uint16(0x000f)
)

Adressess in the RIOT and TIA areas that are being used to read from from memory require an additional transformation

View Source
const (
	AddressMaskCart = MemtopCart ^ OriginCart
)

The top nibble of a cartridge address can be anything. AddressMaskCart takes away the uninteresting bits

Good way of normalising cartridge addresses to start from 0x000 (useful for arrays) *if* you know that the address is for certain a cartridge address

View Source
const Memtop = uint16(0x1fff)

Memtop is the top most address of memory in the VCS. It is the same as the cartridge memtop.

Variables

This section is empty.

Functions

func IsArea

func IsArea(address uint16, area Area) bool

IsArea returns true if the address is in the specificied area

func Summary

func Summary() string

Summary returns a single multiline string detailing all the areas in memory. Useful for reference.

Types

type Area

type Area int

Area represents the different areas of memory

const (
	Undefined Area = iota
	TIA
	RAM
	RIOT
	Cartridge
)

The different memory areas in the VCS

func MapAddress

func MapAddress(address uint16, read bool) (uint16, Area)

MapAddress translates the address argument from mirror space to primary space. Generally, an address should be passed through this function before accessing memory.

func (Area) String

func (a Area) String() string

Jump to

Keyboard shortcuts

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