From 0ef9d567aa978af463c5531964fdeebedce3a0a7 Mon Sep 17 00:00:00 2001
From: Oliver Schmidt
Date: Thu, 18 Aug 2022 17:53:01 +0200
Subject: [PATCH] Added support for an alternative hardware type.
The new hardware type has simple UART-type interface. Beside the two data registers, there are only the two bits to indicate readability and writability of the data registers.
---
Apple2/CommandFirmware.asm | 8 +++++++
Apple2/DriveFirmware.asm | 6 +++++
Apple2/FileAccessFirmware.asm | 6 +++++
Apple2/MenuFirmware.asm | 44 ++++++++++++++++++++++++++++++++---
Apple2/RPi.Command.asm | 6 +++++
Apple2/Shell.asm | 8 +++++++
6 files changed, 75 insertions(+), 3 deletions(-)
diff --git a/Apple2/CommandFirmware.asm b/Apple2/CommandFirmware.asm
index 87612be..de28952 100644
--- a/Apple2/CommandFirmware.asm
+++ b/Apple2/CommandFirmware.asm
@@ -130,6 +130,7 @@ SendByte:
bit InputFlags
bvs SendByte
sta OutputByte
+.if HW_TYPE = 0
lda #$1e ; set bit 0 low to indicate write started
sta OutputFlags
finishWrite:
@@ -137,27 +138,34 @@ finishWrite:
bvc finishWrite
lda #$1f
sta OutputFlags
+.endif
rts
GetByte:
+.if HW_TYPE = 0
ldx #$1d ;set read flag low
stx OutputFlags
+.endif
waitRead:
bit InputFlags
bpl readByte
bit Keyboard ;keypress will abort waiting to read
bpl waitRead
+.if HW_TYPE = 0
lda #$1f ;set all flags high and exit
sta OutputFlags
+.endif
sec ;failure
rts
readByte:
lda InputByte
+.if HW_TYPE = 0
ldx #$1f ;set all flags high
stx OutputFlags
finishRead:
bit InputFlags
bpl finishRead
+.endif
clc ;success
end:
rts
diff --git a/Apple2/DriveFirmware.asm b/Apple2/DriveFirmware.asm
index e480df5..087efd0 100644
--- a/Apple2/DriveFirmware.asm
+++ b/Apple2/DriveFirmware.asm
@@ -164,6 +164,7 @@ SendByte:
bit InputFlags
bvs SendByte
sta OutputByte
+.if HW_TYPE = 0
lda #$0e ; set bit 0 low to indicate write started
sta OutputFlags
finishWrite:
@@ -171,20 +172,25 @@ finishWrite:
bvc finishWrite
lda #$0f
sta OutputFlags
+.endif
rts
GetByte:
+.if HW_TYPE = 0
ldx #$0d ;set read flag low
stx OutputFlags
+.endif
waitRead:
bit InputFlags
bmi waitRead
lda InputByte
+.if HW_TYPE = 0
ldx #$0f ;set all flags high
stx OutputFlags
finishRead:
bit InputFlags
bpl finishRead
+.endif
end:
rts
diff --git a/Apple2/FileAccessFirmware.asm b/Apple2/FileAccessFirmware.asm
index 2c9229b..b82f8ef 100644
--- a/Apple2/FileAccessFirmware.asm
+++ b/Apple2/FileAccessFirmware.asm
@@ -117,6 +117,7 @@ SendByte:
bit InputFlags
bvs SendByte
sta OutputByte
+.if HW_TYPE = 0
lda #$2e ; set bit 0 low to indicate write started
sta OutputFlags
finishWrite:
@@ -124,20 +125,25 @@ finishWrite:
bvc finishWrite
lda #$2f
sta OutputFlags
+.endif
rts
GetByte:
+.if HW_TYPE = 0
ldx #$2d ;set read flag low
stx OutputFlags
+.endif
waitRead:
bit InputFlags
bmi waitRead
lda InputByte
+.if HW_TYPE = 0
ldx #$2f ;set all flags high
stx OutputFlags
finishRead:
bit InputFlags
bpl finishRead
+.endif
end:
rts
diff --git a/Apple2/MenuFirmware.asm b/Apple2/MenuFirmware.asm
index 9a36ffe..16eb39b 100644
--- a/Apple2/MenuFirmware.asm
+++ b/Apple2/MenuFirmware.asm
@@ -85,10 +85,11 @@ PrintString:
iny
bne PrintString
+.if HW_TYPE = 0
+
WaitForRPi:
- lda InputFlags
- rol
- bcs Reset
+ bit InputFlags
+ bmi Reset
lda #$ff
jsr Wait
lda #'.'+$80
@@ -108,6 +109,37 @@ Reset:
beq Ok
jmp Reset
+.else
+
+WaitForRPi:
+@1:
+ bit InputFlags
+ bmi @2
+ lda InputByte
+ jmp @1
+@2:
+ bit InputFlags
+ bpl @4
+ bvs @3
+ lda #ResetCommand
+ sta OutputByte
+@3:
+ lda #$ff
+ jsr Wait
+ lda #'.'+$80
+ jsr PrintChar
+ jmp @2
+@4:
+ lda #$ff
+ jsr Wait
+@5:
+ bit InputFlags
+ bmi Ok
+ lda InputByte
+ jmp @5
+
+.endif
+
Ok:
lda #$8D
jsr PrintChar
@@ -124,6 +156,7 @@ SendByte:
bit InputFlags
bvs SendByte
sta OutputByte
+.if HW_TYPE = 0
lda #$3e ; set bit 0 low to indicate write started
sta OutputFlags
finishWrite:
@@ -131,20 +164,25 @@ finishWrite:
bvc finishWrite
lda #$3f
sta OutputFlags
+.endif
rts
GetByte:
+.if HW_TYPE = 0
ldx #$3d ;set read flag low
stx OutputFlags
+.endif
waitRead:
bit InputFlags
bmi waitRead
lda InputByte
+.if HW_TYPE = 0
ldx #$3f ;set all flags high
stx OutputFlags
finishRead:
bit InputFlags
bpl finishRead
+.endif
rts
Text:
diff --git a/Apple2/RPi.Command.asm b/Apple2/RPi.Command.asm
index b5e1db9..bc5480d 100644
--- a/Apple2/RPi.Command.asm
+++ b/Apple2/RPi.Command.asm
@@ -228,6 +228,7 @@ waitWrite:
bcs waitWrite
pla
sta OutputByte,x
+.if HW_TYPE = 0
lda #$1e ; set bit 0 low to indicate write started
sta OutputFlags,x
finishWrite:
@@ -237,17 +238,21 @@ finishWrite:
bcc finishWrite
lda #$1f
sta OutputFlags,x
+.endif
rts
GetByte:
+.if HW_TYPE = 0
lda #$1d ;set read flag low
sta OutputFlags,x
+.endif
waitRead:
lda InputFlags,x
rol
bcs waitRead
readByte:
lda InputByte,x
+.if HW_TYPE = 0
pha
lda #$1f ;set all flags high
sta OutputFlags,x
@@ -256,6 +261,7 @@ finishRead:
rol
bcc finishRead
pla
+.endif
clc ;success
rts
diff --git a/Apple2/Shell.asm b/Apple2/Shell.asm
index 8358849..82be6db 100755
--- a/Apple2/Shell.asm
+++ b/Apple2/Shell.asm
@@ -190,6 +190,7 @@ waitWrite:
bcs waitWrite
pla
sta OutputByte,x
+.if HW_TYPE = 0
lda #$1e ; set bit 0 low to indicate write started
sta OutputFlags,x
finishWrite:
@@ -199,11 +200,14 @@ finishWrite:
bcc finishWrite
lda #$1f
sta OutputFlags,x
+.endif
rts
GetByte:
+.if HW_TYPE = 0
lda #$1d ;set read flag low
sta OutputFlags,x
+.endif
waitRead:
lda InputFlags,x
rol
@@ -219,6 +223,7 @@ keyPressed:
and #$7f
sta OutputByte,x
bit ClearKeyboard
+.if HW_TYPE = 0
lda #$1c ;set write flag low too
sta OutputFlags,x
finishKeyPress:
@@ -228,9 +233,11 @@ finishKeyPress:
bcc finishKeyPress
lda #$1d ;set flags back for reading
sta OutputFlags,x
+.endif
jmp waitRead
readByte:
lda InputByte,x
+.if HW_TYPE = 0
pha
lda #$1f ;set all flags high
sta OutputFlags,x
@@ -239,6 +246,7 @@ finishRead:
rol
bcc finishRead
pla
+.endif
clc ;success
end:
rts