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.
This commit is contained in:
Oliver Schmidt 2022-08-18 17:53:01 +02:00 committed by Terence Boldt
parent 7f74c733d8
commit 0ef9d567aa
6 changed files with 75 additions and 3 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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:

View File

@ -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

View File

@ -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