mirror of
https://github.com/tjboldt/Apple2-IO-RPi.git
synced 2024-11-22 02:30:46 +00:00
Add dynamic drive support
This commit is contained in:
parent
4b7d990209
commit
91efe725b7
14
Apple2/Startup.bas
Normal file
14
Apple2/Startup.bas
Normal file
@ -0,0 +1,14 @@
|
||||
10 HOME
|
||||
11 PRINT "Apple2-IO-RPi"
|
||||
12 PRINT "(c)2021-2023 Terence J. Boldt"
|
||||
13 PRINT
|
||||
14 PRINT "This drive is dynamically generated"
|
||||
15 PRINT "from the current working directory on"
|
||||
16 PRINT "the Raspberry Pi and is in RAM only."
|
||||
17 PRINT
|
||||
18 PRINT "To start a shell to the RPi, type:"
|
||||
19 PRINT "-shell"
|
||||
20 PRINT
|
||||
21 PRINT "To add RPI command to ProDOS, type:"
|
||||
22 PRINT "-rpi.command"
|
||||
23 PRINT
|
@ -1,5 +1,5 @@
|
||||
10 HOME
|
||||
100 PRINT CHR$ (4)"BLOAD AT28C64B.BIN,A$2000"
|
||||
100 PRINT CHR$ (4)"BLOAD AT28C64B,A$2000"
|
||||
200 PRINT "Program the firmare in slot #"
|
||||
300 INPUT SL
|
||||
400 FW = 8192 + 256 * SL: REM Firmware source
|
||||
@ -15,9 +15,11 @@
|
||||
1010 POKE PS,PG * 16 + 15: REM Set firmware page
|
||||
1020 FOR X = 0 TO 255
|
||||
1030 A = PEEK (FW + PG * 2048 + X)
|
||||
1035 B = PEEK (EP + X): REM Skip if unchanged
|
||||
1037 IF (A = B) THEN GOTO 1045
|
||||
1040 POKE EP + X,A
|
||||
1041 B = PEEK (EP + X)
|
||||
1042 IF (B < > A) THEN GOTO 1041
|
||||
1042 IF (B < > A) THEN GOTO 1041: REM Wait for write
|
||||
1045 HTAB (X / 256) * 39 + 1
|
||||
1046 INVERSE : PRINT " ";: NORMAL
|
||||
1050 NEXT X
|
||||
|
@ -41,13 +41,13 @@ ld65 FileAccessSlot0.o FileAccessSlot1.o FileAccessSlot2.o FileAccessSlot3.o Fil
|
||||
|
||||
cat \
|
||||
DriveFirmware.bin CommandFirmware.bin FileAccessFirmware.bin MenuFirmware.bin \
|
||||
> AT28C64B.bin
|
||||
> ../RaspberryPi/driveimage/AT28C64B.bin
|
||||
|
||||
ca65 Shell.asm -o Shell.o --listing Shell.lst || exit 1
|
||||
ld65 Shell.o -o Shell.bin -C ../.cicd/none.cfg || exit 1
|
||||
ld65 Shell.o -o ../RaspberryPi/driveimage/Shell.bin -C ../.cicd/none.cfg || exit 1
|
||||
|
||||
ca65 RPi.Command.asm -o RPi.Command.o --listing RPi.Command.lst || exit 1
|
||||
ld65 RPi.Command.o -o RPi.Command.bin -C ../.cicd/none.cfg || exit 1
|
||||
ld65 RPi.Command.o -o ../RaspberryPi/driveimage/RPi.Command.bin -C ../.cicd/none.cfg || exit 1
|
||||
|
||||
rm ./*.o
|
||||
rm DriveFirmware.bin
|
||||
@ -55,7 +55,5 @@ rm MenuFirmware.bin
|
||||
rm CommandFirmware.bin
|
||||
rm FileAccessFirmware.bin
|
||||
|
||||
ProDOS-Utilities -d ../RaspberryPi/Apple2-IO-RPi.hdv -c put -i AT28C64B.bin -p /APPLE2.IO.RPI/AT28C64B.BIN || exit 1
|
||||
ProDOS-Utilities -d ../RaspberryPi/Apple2-IO-RPi.hdv -c put -i Shell.bin -p /APPLE2.IO.RPI/SHELL || exit 1
|
||||
ProDOS-Utilities -d ../RaspberryPi/Apple2-IO-RPi.hdv -c put -i RPi.Command.bin -p /APPLE2.IO.RPI/RPI.COMMAND -a 0x2000 || exit 1
|
||||
ProDOS-Utilities -d ../RaspberryPi/Apple2-IO-RPi.hdv -c ls
|
||||
cp Update.Firmware.bas ../RaspberryPi/driveimage/
|
||||
cp Startup.bas ../RaspberryPi/driveimage/
|
Binary file not shown.
@ -18,6 +18,7 @@ import (
|
||||
"github.com/tjboldt/Apple2-IO-RPi/RaspberryPi/apple2driver/a2io"
|
||||
"github.com/tjboldt/Apple2-IO-RPi/RaspberryPi/apple2driver/handlers"
|
||||
"github.com/tjboldt/Apple2-IO-RPi/RaspberryPi/apple2driver/info"
|
||||
"github.com/tjboldt/ProDOS-Utilities/prodos"
|
||||
)
|
||||
|
||||
const resetCommand = 0
|
||||
@ -46,6 +47,8 @@ func main() {
|
||||
// In case Apple II is waiting, send 0 byte to start
|
||||
comm.WriteByte(0)
|
||||
|
||||
cwd, _ := os.Getwd()
|
||||
|
||||
for {
|
||||
command, err := comm.ReadByte()
|
||||
if err == nil {
|
||||
@ -61,6 +64,11 @@ func main() {
|
||||
handlers.GetTimeCommand()
|
||||
case execCommand:
|
||||
handlers.ExecCommand()
|
||||
newCwd, _ := os.Getwd()
|
||||
if newCwd != cwd {
|
||||
cwd = newCwd
|
||||
generateDrive1FromCwd()
|
||||
}
|
||||
case loadFileCommand:
|
||||
handlers.LoadFileCommand()
|
||||
case menuCommand:
|
||||
@ -83,10 +91,9 @@ func getDriveFiles() (*os.File, *os.File) {
|
||||
path := filepath.Dir(execName)
|
||||
path = filepath.Join(path, "..")
|
||||
path, _ = filepath.EvalSymlinks(path)
|
||||
defaultFileName := filepath.Join(path, "Apple2-IO-RPi.hdv")
|
||||
|
||||
flag.StringVar(&drive1Name, "d1", "", "A ProDOS format drive image for drive 1")
|
||||
flag.StringVar(&drive2Name, "d2", defaultFileName, "A ProDOS format drive image for drive 2 and will be used for drive 1 if drive 1 empty")
|
||||
flag.StringVar(&drive2Name, "d2", "", "A ProDOS format drive image for drive 2 and will be used for drive 1 if drive 1 empty")
|
||||
flag.Parse()
|
||||
|
||||
var drive1 *os.File
|
||||
@ -96,34 +103,45 @@ func getDriveFiles() (*os.File, *os.File) {
|
||||
if len(drive1Name) > 0 {
|
||||
fmt.Printf("Opening Drive 1 as: %s\n", drive1Name)
|
||||
drive1, err = os.OpenFile(drive1Name, os.O_RDWR, 0755)
|
||||
logAndExitOnErr(err)
|
||||
} else {
|
||||
var exec string
|
||||
exec, err = os.Executable()
|
||||
if err != nil {
|
||||
fmt.Printf("ERROR: %s", err.Error())
|
||||
os.Exit(1)
|
||||
}
|
||||
cwd := filepath.Dir(exec)
|
||||
err = os.Chdir(filepath.Join(cwd, "../driveimage"))
|
||||
logAndExitOnErr(err)
|
||||
err = generateDrive1FromCwd()
|
||||
logAndExitOnErr(err)
|
||||
}
|
||||
|
||||
if len(drive2Name) > 0 {
|
||||
if drive1 == nil {
|
||||
fmt.Printf("Opening Drive 1 as: %s because Drive 1 was empty\n", drive2Name)
|
||||
drive1, err = os.OpenFile(drive2Name, os.O_RDWR, 0755)
|
||||
if err != nil {
|
||||
fmt.Printf("ERROR: %s", err.Error())
|
||||
os.Exit(1)
|
||||
}
|
||||
} else {
|
||||
fmt.Printf("Opening Drive 2 as: %s\n", drive2Name)
|
||||
drive2, err = os.OpenFile(drive2Name, os.O_RDWR, 0755)
|
||||
if err != nil {
|
||||
fmt.Printf("ERROR: %s", err.Error())
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if drive1 == nil {
|
||||
flag.PrintDefaults()
|
||||
os.Exit(1)
|
||||
fmt.Printf("Opening Drive 2 as: %s\n", drive2Name)
|
||||
drive2, err = os.OpenFile(drive2Name, os.O_RDWR, 0755)
|
||||
logAndExitOnErr(err)
|
||||
}
|
||||
|
||||
return drive1, drive2
|
||||
}
|
||||
|
||||
func logAndExitOnErr(err error) {
|
||||
if err != nil {
|
||||
fmt.Printf("ERROR: %s", err.Error())
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
func generateDrive1FromCwd() error {
|
||||
cwd, err := os.Getwd()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
drive1 := prodos.NewMemoryFile(0x2000000)
|
||||
fmt.Printf("Generating Drive 1 in memory from: %s\n", cwd)
|
||||
prodos.CreateVolume(drive1, "APPLE2.IO.RPI", 65535)
|
||||
err = prodos.AddFilesFromHostDirectory(drive1, cwd)
|
||||
return err
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ module github.com/tjboldt/Apple2-IO-RPi/RaspberryPi/apple2driver
|
||||
go 1.16
|
||||
|
||||
require (
|
||||
github.com/creack/pty v1.1.17
|
||||
github.com/creack/pty v1.1.18
|
||||
github.com/stianeikeland/go-rpio/v4 v4.6.0
|
||||
github.com/tjboldt/ProDOS-Utilities v0.3.0
|
||||
github.com/tjboldt/ProDOS-Utilities v0.4.1
|
||||
)
|
||||
|
@ -1,6 +1,6 @@
|
||||
github.com/creack/pty v1.1.17 h1:QeVUsEDNrLBW4tMgZHvxy18sKtr6VI492kBhUfhDJNI=
|
||||
github.com/creack/pty v1.1.17/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4=
|
||||
github.com/creack/pty v1.1.18 h1:n56/Zwd5o6whRC5PMGretI4IdRLlmBXYNjScPaBgsbY=
|
||||
github.com/creack/pty v1.1.18/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4=
|
||||
github.com/stianeikeland/go-rpio/v4 v4.6.0 h1:eAJgtw3jTtvn/CqwbC82ntcS+dtzUTgo5qlZKe677EY=
|
||||
github.com/stianeikeland/go-rpio/v4 v4.6.0/go.mod h1:A3GvHxC1Om5zaId+HqB3HKqx4K/AqeckxB7qRjxMK7o=
|
||||
github.com/tjboldt/ProDOS-Utilities v0.3.0 h1:nlBvrGtvAV7KBfxiSkXHdosmDLEYAXMq955P8NL0qiE=
|
||||
github.com/tjboldt/ProDOS-Utilities v0.3.0/go.mod h1:eBQRf0U+goRbBOxzFCwRW+FZmALC8dfYaqCwcqwzi74=
|
||||
github.com/tjboldt/ProDOS-Utilities v0.4.1 h1:tbXgLFXO4xh7t4XAuMgPwM9wXUcEAxH7/ByffjvgsPk=
|
||||
github.com/tjboldt/ProDOS-Utilities v0.4.1/go.mod h1:eBQRf0U+goRbBOxzFCwRW+FZmALC8dfYaqCwcqwzi74=
|
||||
|
BIN
RaspberryPi/driveimage/BASIC.SYSTEM.SYS
Normal file
BIN
RaspberryPi/driveimage/BASIC.SYSTEM.SYS
Normal file
Binary file not shown.
BIN
RaspberryPi/driveimage/PRODOS.SYS
Normal file
BIN
RaspberryPi/driveimage/PRODOS.SYS
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user