i6502/ram.go

26 lines
456 B
Go
Raw Permalink Normal View History

2014-08-13 07:26:33 +00:00
package i6502
2014-08-17 13:53:35 +00:00
/*
Random Access Memory, read/write, can be of any size.
*/
2014-08-13 07:26:33 +00:00
type Ram struct {
data []byte
}
2014-08-17 13:53:35 +00:00
// Create a new Ram component of the given size.
2014-08-13 07:26:33 +00:00
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 {
2014-08-13 07:26:33 +00:00
return r.data[address]
}
func (r *Ram) WriteByte(address uint16, data byte) {
2014-08-13 07:26:33 +00:00
r.data[address] = data
}