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 ¶
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.
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
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
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 ¶
Types ¶
type Area ¶
type Area int
Area represents the different areas of memory
func MapAddress ¶
MapAddress translates the address argument from mirror space to primary space. Generally, an address should be passed through this function before accessing memory.