diff --git a/RaspberryPi/apple2driver/a2io/communication.go b/RaspberryPi/apple2driver/a2io/communication.go index bfb3118..3badabc 100644 --- a/RaspberryPi/apple2driver/a2io/communication.go +++ b/RaspberryPi/apple2driver/a2io/communication.go @@ -1,3 +1,10 @@ +// Copyright Terence J. Boldt (c)2021 +// Use of this source code is governed by an MIT +// license that can be found in the LICENSE file. + +// This file defines the interface for communicating with the Apple II via +// the Raspberry Pi GPIO ports but can also be mocked out for tests or +// passed input to the user for interactive testing package a2io type A2Io interface { diff --git a/RaspberryPi/apple2driver/a2io/gpio.go b/RaspberryPi/apple2driver/a2io/gpio.go index d0fed12..ae0a959 100644 --- a/RaspberryPi/apple2driver/a2io/gpio.go +++ b/RaspberryPi/apple2driver/a2io/gpio.go @@ -1,3 +1,9 @@ +// Copyright Terence J. Boldt (c)2020-2021 +// Use of this source code is governed by an MIT +// license that can be found in the LICENSE file. + +// This file is used for communicating with the Apple II data bus via the +// GPIO ports on the Raspberry Pi package a2io import ( diff --git a/RaspberryPi/apple2driver/a2io/mockio.go b/RaspberryPi/apple2driver/a2io/mockio.go index 0b93ee4..25ac3f7 100644 --- a/RaspberryPi/apple2driver/a2io/mockio.go +++ b/RaspberryPi/apple2driver/a2io/mockio.go @@ -1,3 +1,9 @@ +// Copyright Terence J. Boldt (c)2021 +// Use of this source code is governed by an MIT +// license that can be found in the LICENSE file. + +// This file is used for mocking the GPIO code so that unit tests can be run +// on any machine and not just a Raspberry Pi package a2io import ( diff --git a/RaspberryPi/apple2driver/a2io/userio.go b/RaspberryPi/apple2driver/a2io/userio.go new file mode 100644 index 0000000..589f15c --- /dev/null +++ b/RaspberryPi/apple2driver/a2io/userio.go @@ -0,0 +1,69 @@ +// Copyright Terence J. Boldt (c)2021 +// Use of this source code is governed by an MIT +// license that can be found in the LICENSE file. + +// This file is only used during development for interactive testing of the +// driver code. Simply replace `comm := a2io.A2Gpio{}` with +// `comm := a2io.UserIo{}` in the driver.go file to allow local testing +package a2io + +import ( + "errors" + "fmt" + "strings" +) + +type UserIo struct { +} + +func (userIo UserIo) Init() { + +} + +func (userIo UserIo) WriteByte(data byte) error { + fmt.Printf("WriteByte: %02X\n", data) + return nil +} + +func (userIo UserIo) WriteString(outString string) error { + fmt.Printf("WriteString: %s\n", strings.ReplaceAll(outString, "\r", "\n")) + return nil +} + +func (userIo UserIo) WriteBlock(buffer []byte) error { + fmt.Printf("WriteBlock:\n") + return userIo.WriteBuffer(buffer) +} + +func (userIo UserIo) WriteBuffer(buffer []byte) error { + fmt.Printf("WriteBuffer:\n") + for i, b := range buffer { + if i%16 == 0 { + fmt.Printf("\n%04X:", i) + } + fmt.Printf(" %02X", b) + } + fmt.Printf("\n") + return nil +} + +func (userIo UserIo) ReadByte() (byte, error) { + fmt.Printf("ReadByte: ") + var b byte + fmt.Scanf("%x", &b) + fmt.Printf("\n") + return b, nil +} + +func (userIo UserIo) ReadString() (string, error) { + fmt.Printf("ReadString: ") + var s string + fmt.Scanf("%s", &s) + fmt.Printf("\n") + return s, nil +} + +func (userIo UserIo) ReadBlock(buffer []byte) error { + fmt.Printf("ReadBlock: (Not supported)") + return errors.New("ReadBlock not supported") +} diff --git a/RaspberryPi/apple2driver/driver.go b/RaspberryPi/apple2driver/driver.go index beac08c..8f2f71c 100644 --- a/RaspberryPi/apple2driver/driver.go +++ b/RaspberryPi/apple2driver/driver.go @@ -1,3 +1,10 @@ +// Copyright Terence J. Boldt (c)2020-2021 +// Use of this source code is governed by an MIT +// license that can be found in the LICENSE file. + +// This file is contains the main driver code for the Raspberry Pi side of +// the Apple2-IO-RPi hardware. Commands are sent from the Apple II and +// responses are sent back from the Raspberry Pi. package main import ( diff --git a/RaspberryPi/apple2driver/handlers/block.go b/RaspberryPi/apple2driver/handlers/block.go index 77d2c5d..c612464 100644 --- a/RaspberryPi/apple2driver/handlers/block.go +++ b/RaspberryPi/apple2driver/handlers/block.go @@ -1,3 +1,8 @@ +// Copyright Terence J. Boldt (c)2020-2021 +// Use of this source code is governed by an MIT +// license that can be found in the LICENSE file. + +// This file is used for handling ProDOS image block reading and writing package handlers import ( diff --git a/RaspberryPi/apple2driver/handlers/communication.go b/RaspberryPi/apple2driver/handlers/communication.go index f19b248..e789326 100644 --- a/RaspberryPi/apple2driver/handlers/communication.go +++ b/RaspberryPi/apple2driver/handlers/communication.go @@ -1,3 +1,8 @@ +// Copyright Terence J. Boldt (c)2021 +// Use of this source code is governed by an MIT +// license that can be found in the LICENSE file. + +// This file is used for setting up the communications for the handlers package handlers import ( diff --git a/RaspberryPi/apple2driver/handlers/exec.go b/RaspberryPi/apple2driver/handlers/exec.go index 9a8a997..9bff724 100644 --- a/RaspberryPi/apple2driver/handlers/exec.go +++ b/RaspberryPi/apple2driver/handlers/exec.go @@ -1,3 +1,9 @@ +// Copyright Terence J. Boldt (c)2020-2021 +// Use of this source code is governed by an MIT +// license that can be found in the LICENSE file. + +// This file is contains the handler for executing Linux and internal +// commands package handlers import ( diff --git a/RaspberryPi/apple2driver/handlers/getTime.go b/RaspberryPi/apple2driver/handlers/getTime.go index bd62193..5502c6a 100644 --- a/RaspberryPi/apple2driver/handlers/getTime.go +++ b/RaspberryPi/apple2driver/handlers/getTime.go @@ -1,3 +1,9 @@ +// Copyright Terence J. Boldt (c)2020-2021 +// Use of this source code is governed by an MIT +// license that can be found in the LICENSE file. + +// This file is contains the handler for retrieving the ProDOS timestamp +// based on the current time package handlers import ( diff --git a/RaspberryPi/apple2driver/handlers/loadFile.go b/RaspberryPi/apple2driver/handlers/loadFile.go index 8686d41..8de84e4 100644 --- a/RaspberryPi/apple2driver/handlers/loadFile.go +++ b/RaspberryPi/apple2driver/handlers/loadFile.go @@ -1,3 +1,9 @@ +// Copyright Terence J. Boldt (c)2020-2021 +// Use of this source code is governed by an MIT +// license that can be found in the LICENSE file. + +// This file is contains the handler for loading files directly from the +// Raspberry Pi onto the Apple II package handlers import ( diff --git a/RaspberryPi/apple2driver/handlers/menu.go b/RaspberryPi/apple2driver/handlers/menu.go index afe1262..8931225 100755 --- a/RaspberryPi/apple2driver/handlers/menu.go +++ b/RaspberryPi/apple2driver/handlers/menu.go @@ -1,3 +1,9 @@ +// Copyright Terence J. Boldt (c)2020-2021 +// Use of this source code is governed by an MIT +// license that can be found in the LICENSE file. + +// This file is contains the handler for displaying the menu of choices on +// the Apple II package handlers import (