1
0
mirror of https://github.com/ariejan/i6502.git synced 2024-05-28 07:41:32 +00:00
i6502/ram.go
Ariejan de Vroom da43c2bca1 Update Memory interface
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.
2014-08-19 16:49:48 +02:00

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
}