memory

package
v0.0.0-...-60dbe6b Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2018 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package memory implements access to 16-bit address space.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Blank

type Blank uint8

Blank memory always returns the same value

func (Blank) Fetch

func (mem Blank) Fetch(_ uint16) uint8

func (Blank) Store

func (Blank) Store(_ uint16, _ uint8)

func (Blank) String

func (mem Blank) String() string

type Mapper

type Mapper struct {
	// Zero value for unmapped areas.
	Zero uint8
	// contains filtered or unexported fields
}

Mapper for bank switched memory access.

func NewMapper

func NewMapper() *Mapper

NewMapper creates a new mapper with 0xff as the zero value.

func (Mapper) Fetch

func (m Mapper) Fetch(addr uint16) uint8

Fetch a byte

func (*Mapper) Map

func (m *Mapper) Map(addr, stop uint16, memory Memory)

Map memory starting at addr; the memory implementation is expected to do the address translation for the specified addr.

func (*Mapper) Reset

func (m *Mapper) Reset() *Mapper

Reset the mappings

func (Mapper) Store

func (m Mapper) Store(addr uint16, value uint8)

Store a byte

func (Mapper) String

func (m Mapper) String() string

func (*Mapper) Unmap

func (m *Mapper) Unmap(memory Memory) (found bool)

Unmap a memory area; returns true if the memory was found. Returns at the first hit.

type Masked

type Masked struct {
	Memory

	// Mask is the memory mask. To limit memory access to 1k for example, use
	// a mask of 2^10-1 (0x3ff).
	Mask uint16
}

Masked memory access allows one to restrict and/or translate 16-bit memory to a smaller range.

func (Masked) Fetch

func (m Masked) Fetch(addr uint16) uint8

Fetch a byte

func (Masked) Store

func (m Masked) Store(addr uint16, value uint8)

Store a byte

type Memory

type Memory interface {
	// Fetch a byte
	Fetch(addr uint16) (value uint8)

	// Store a byte
	Store(addr uint16, value uint8)
}

Memory implements a 16-bit address bus.

type RAM

type RAM []uint8

RAM is Rendom Access Memory.

func New

func New(size int) *RAM

New creates new RAM.

func (RAM) Fetch

func (mem RAM) Fetch(addr uint16) uint8

Fetch a byte at addr.

func (*RAM) Reset

func (mem *RAM) Reset(zero uint8) *RAM

Reset RAM with the provided zero value overwriting the current memory.

func (*RAM) Store

func (mem *RAM) Store(addr uint16, value uint8)

Store a byte at addr.

func (RAM) String

func (mem RAM) String() string

type ROM

type ROM []uint8

ROM is Read-Only Memory.

func Load

func Load(name string) (ROM, error)

Load a new ROM.

func (ROM) Fetch

func (mem ROM) Fetch(addr uint16) uint8

Fetch a byte at addr.

func (ROM) Store

func (ROM) Store(_ uint16, _ uint8)

Store is a no-op.

func (ROM) String

func (mem ROM) String() string

type ReaderAt

type ReaderAt struct {
	Memory
}

ReaderAt implements io.ReaderAt on Memory.

func (ReaderAt) ReadAt

func (bus ReaderAt) ReadAt(p []byte, off int64) (n int, err error)

ReadAt reads len(p) bytes into p starting at offset off in the underlying input source. It returns the number of bytes read (0 <= n <= len(p)) and any error encountered.

Jump to

Keyboard shortcuts

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