diff --git a/acia6551.go b/acia6551.go new file mode 100644 index 0000000..ffcbc80 --- /dev/null +++ b/acia6551.go @@ -0,0 +1,28 @@ +package i6502 + +/* +ACIA 6551 Serial IO +*/ +type Acia6551 struct { + rx chan byte // Reading (Acia Input) line + tx chan byte // Transmitting (Acia Output) line +} + +func NewAcia6551(rx chan byte, tx chan byte) (*Acia6551, error) { + return &Acia6551{tx: tx, rx: rx}, nil +} + +func (r *Acia6551) Size() uint16 { + // We have a only 4 addresses, RX, TX, Command and Control + return 0x04 +} + +/* +func (r *Rom) Read(address uint16) byte { + return r.data[address] +} + +func (r *Rom) Write(address uint16, data byte) { + panic(fmt.Errorf("Trying to write to ROM at 0x%04X", address)) +} +*/ diff --git a/acia6551_test.go b/acia6551_test.go new file mode 100644 index 0000000..9e19e15 --- /dev/null +++ b/acia6551_test.go @@ -0,0 +1,15 @@ +package i6502 + +import ( + "github.com/stretchr/testify/assert" + "testing" +) + +func TestNewAcia6551(t *testing.T) { + tx := make(chan byte) + rx := make(chan byte) + acia, err := NewAcia6551(rx, tx) + + assert.Nil(t, err) + assert.Equal(t, 0x4, acia.Size()) +}