mirror of
https://github.com/ariejan/i6502.git
synced 2025-07-12 04:24:09 +00:00
Because io.Reader and io.Writer already claim the functions Read and Write it was necessary to rename the Memory interface methods Read and Write to ReadByte and WriteByte.
26 lines
456 B
Go
26 lines
456 B
Go
package i6502
|
|
|
|
/*
|
|
Random Access Memory, read/write, can be of any size.
|
|
*/
|
|
type Ram struct {
|
|
data []byte
|
|
}
|
|
|
|
// Create a new Ram component of the given size.
|
|
func NewRam(size int) (*Ram, error) {
|
|
return &Ram{data: make([]byte, size)}, nil
|
|
}
|
|
|
|
func (r *Ram) Size() uint16 {
|
|
return uint16(len(r.data))
|
|
}
|
|
|
|
func (r *Ram) ReadByte(address uint16) byte {
|
|
return r.data[address]
|
|
}
|
|
|
|
func (r *Ram) WriteByte(address uint16, data byte) {
|
|
r.data[address] = data
|
|
}
|