2023-01-14 15:51:39 +00:00
|
|
|
; Copyright Terence J. Boldt (c)2021-2023
|
2022-01-11 04:00:58 +00:00
|
|
|
; Use of this source code is governed by an MIT
|
|
|
|
; license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
; This file contains the source for the SHELL
|
|
|
|
; application that runs on the Apple II to talk
|
|
|
|
; to the Raspberry Pi
|
|
|
|
|
2021-11-05 19:15:54 +00:00
|
|
|
;ProDOS Zero Page
|
|
|
|
Command = $42 ;ProDOS Command
|
|
|
|
Unit = $43 ;ProDOS unit (SDDD0000)
|
|
|
|
BufferLo = $44
|
|
|
|
BufferHi = $45
|
|
|
|
BlockLo = $46
|
|
|
|
BlockHi = $47
|
|
|
|
|
|
|
|
; ProDOS Error Codes
|
|
|
|
IOError = $27
|
|
|
|
NoDevice = $28
|
|
|
|
WriteProtect = $2B
|
|
|
|
|
2021-12-31 18:09:53 +00:00
|
|
|
InputByte = $c08e
|
|
|
|
OutputByte = $c08d
|
|
|
|
InputFlags = $c08b
|
|
|
|
OutputFlags = $c087
|
2021-11-05 19:15:54 +00:00
|
|
|
|
2021-11-27 03:51:52 +00:00
|
|
|
ResetCommand = $00
|
2021-11-05 19:15:54 +00:00
|
|
|
ReadBlockCommand = $01
|
|
|
|
WriteBlockCommand = $02
|
|
|
|
GetTimeCommand = $03
|
|
|
|
ChangeDriveCommand = $04
|
|
|
|
ExecCommand = $05
|
|
|
|
LoadFileCommand = $06
|
|
|
|
SaveFileCommand = $07
|
|
|
|
MenuCommand = $08
|
2021-11-21 19:56:13 +00:00
|
|
|
ShellCommand = $09
|
2021-11-05 19:15:54 +00:00
|
|
|
|
|
|
|
InputString = $fd6a
|
|
|
|
StringBuffer = $0200
|
|
|
|
PrintChar = $fded
|
|
|
|
Keyboard = $c000
|
|
|
|
ClearKeyboard = $c010
|
2021-11-11 02:44:28 +00:00
|
|
|
Home = $fc58
|
2021-11-05 19:15:54 +00:00
|
|
|
Wait = $fca8
|
|
|
|
PromptChar = $33
|
2021-11-25 23:45:56 +00:00
|
|
|
Read80Col = $c01f
|
|
|
|
TextPage1 = $c054
|
|
|
|
TextPage2 = $c055
|
|
|
|
|
2021-11-11 02:44:28 +00:00
|
|
|
htab = $24
|
|
|
|
vtab = $25
|
2021-11-25 23:45:56 +00:00
|
|
|
BasL = $28
|
|
|
|
htab80 = $057b
|
|
|
|
BasCalc = $fbc1
|
2021-11-05 19:15:54 +00:00
|
|
|
|
2021-11-27 03:51:52 +00:00
|
|
|
LastChar = $06
|
2021-12-31 18:09:53 +00:00
|
|
|
SlotL = $fe
|
|
|
|
SlotH = $ff
|
2021-11-05 19:15:54 +00:00
|
|
|
ESC = $9b
|
|
|
|
|
|
|
|
.org $2000
|
2021-12-31 18:09:53 +00:00
|
|
|
ldx #$07 ; start at slot 7
|
|
|
|
DetectSlot:
|
|
|
|
ldy #$00
|
|
|
|
lda #$fc
|
|
|
|
sta SlotL
|
|
|
|
txa
|
|
|
|
ora #$c0
|
|
|
|
sta SlotH
|
|
|
|
lda (SlotL),y
|
|
|
|
bne nextSlot
|
|
|
|
iny
|
|
|
|
lda (SlotL),y
|
|
|
|
bne nextSlot
|
|
|
|
iny
|
|
|
|
lda (SlotL),y
|
|
|
|
cmp #$17
|
|
|
|
bne nextSlot
|
|
|
|
iny
|
|
|
|
lda (SlotL),y
|
|
|
|
cmp #$14
|
|
|
|
bne nextSlot
|
|
|
|
txa
|
|
|
|
asl
|
|
|
|
asl
|
|
|
|
asl
|
|
|
|
asl
|
|
|
|
tax
|
|
|
|
clc
|
2022-03-02 03:46:03 +00:00
|
|
|
bcc Init
|
2021-12-31 18:09:53 +00:00
|
|
|
nextSlot:
|
|
|
|
dex
|
|
|
|
bne DetectSlot
|
|
|
|
rts
|
2022-03-02 03:46:03 +00:00
|
|
|
|
|
|
|
Init:
|
2021-12-31 18:09:53 +00:00
|
|
|
lda #$8d
|
2021-11-21 19:56:13 +00:00
|
|
|
jsr $c300 ; force 80 columns
|
2022-03-02 03:46:03 +00:00
|
|
|
|
|
|
|
ldy #$00
|
|
|
|
PrintString:
|
|
|
|
lda Text,y
|
|
|
|
beq Start
|
|
|
|
ora #$80
|
|
|
|
jsr PrintChar
|
|
|
|
iny
|
|
|
|
bne PrintString
|
|
|
|
|
|
|
|
Start:
|
2021-11-27 03:51:52 +00:00
|
|
|
lda LastChar
|
|
|
|
pha
|
2021-11-05 19:15:54 +00:00
|
|
|
bit ClearKeyboard
|
2021-11-27 03:51:52 +00:00
|
|
|
lda #ResetCommand
|
|
|
|
jsr SendByte
|
2021-11-21 19:56:13 +00:00
|
|
|
lda #ShellCommand
|
2021-11-05 19:15:54 +00:00
|
|
|
jsr SendByte
|
|
|
|
jsr DumpOutput
|
2021-11-27 03:51:52 +00:00
|
|
|
pla
|
|
|
|
sta LastChar
|
2021-11-05 19:15:54 +00:00
|
|
|
rts
|
|
|
|
|
|
|
|
DumpOutput:
|
|
|
|
jsr GetByte
|
|
|
|
cmp #$00
|
|
|
|
beq endOutput
|
2021-11-25 23:45:56 +00:00
|
|
|
pha
|
2021-11-27 03:51:52 +00:00
|
|
|
jsr ClearCursor
|
2021-11-25 23:45:56 +00:00
|
|
|
pla
|
2021-11-11 02:44:28 +00:00
|
|
|
cmp #'H'
|
|
|
|
beq setColumn
|
|
|
|
cmp #'V'
|
|
|
|
beq setRow
|
|
|
|
cmp #'C'
|
|
|
|
beq clearScreen
|
|
|
|
cmp #'T'
|
|
|
|
beq setTop
|
|
|
|
cmp #'B'
|
2021-11-25 23:45:56 +00:00
|
|
|
beq setBottom
|
|
|
|
cmp #'U'
|
|
|
|
beq moveUp
|
2021-11-05 19:15:54 +00:00
|
|
|
jsr PrintChar
|
2021-11-27 03:51:52 +00:00
|
|
|
jsr SetCursor
|
2021-11-11 02:44:28 +00:00
|
|
|
jmp DumpOutput
|
2021-11-05 19:15:54 +00:00
|
|
|
endOutput:
|
|
|
|
rts
|
2021-11-11 02:44:28 +00:00
|
|
|
clearScreen:
|
|
|
|
jsr Home
|
2021-11-27 03:51:52 +00:00
|
|
|
jsr SetCursor
|
2021-11-11 02:44:28 +00:00
|
|
|
jmp DumpOutput
|
|
|
|
setColumn:
|
|
|
|
jsr GetByte
|
|
|
|
sta htab
|
2021-11-25 23:45:56 +00:00
|
|
|
sta htab80
|
2021-11-27 03:51:52 +00:00
|
|
|
jsr SetCursor
|
2021-11-11 02:44:28 +00:00
|
|
|
jmp DumpOutput
|
|
|
|
setRow:
|
|
|
|
jsr GetByte
|
|
|
|
sta vtab
|
2021-11-25 23:45:56 +00:00
|
|
|
jsr BasCalc
|
2021-11-27 03:51:52 +00:00
|
|
|
jsr SetCursor
|
2021-11-11 02:44:28 +00:00
|
|
|
jmp DumpOutput
|
|
|
|
setTop:
|
|
|
|
jsr GetByte
|
|
|
|
sta $22
|
|
|
|
jmp DumpOutput
|
|
|
|
setBottom:
|
|
|
|
jsr GetByte
|
|
|
|
sta $23
|
2021-11-25 23:45:56 +00:00
|
|
|
jmp DumpOutput
|
|
|
|
moveUp:
|
|
|
|
dec vtab
|
|
|
|
lda vtab
|
|
|
|
jsr BasCalc
|
2021-11-27 03:51:52 +00:00
|
|
|
jsr SetCursor
|
2021-11-11 02:44:28 +00:00
|
|
|
jmp DumpOutput
|
2021-11-05 19:15:54 +00:00
|
|
|
|
|
|
|
SendByte:
|
|
|
|
pha
|
|
|
|
waitWrite:
|
2021-12-31 18:09:53 +00:00
|
|
|
lda InputFlags,x
|
2021-11-05 19:15:54 +00:00
|
|
|
rol
|
|
|
|
rol
|
|
|
|
bcs waitWrite
|
|
|
|
pla
|
2021-12-31 18:09:53 +00:00
|
|
|
sta OutputByte,x
|
2021-11-05 19:15:54 +00:00
|
|
|
lda #$1e ; set bit 0 low to indicate write started
|
2021-12-31 18:09:53 +00:00
|
|
|
sta OutputFlags,x
|
2021-11-05 19:15:54 +00:00
|
|
|
finishWrite:
|
2021-12-31 18:09:53 +00:00
|
|
|
lda InputFlags,x
|
2021-11-05 19:15:54 +00:00
|
|
|
rol
|
|
|
|
rol
|
|
|
|
bcc finishWrite
|
|
|
|
lda #$1f
|
2021-12-31 18:09:53 +00:00
|
|
|
sta OutputFlags,x
|
2021-11-05 19:15:54 +00:00
|
|
|
rts
|
|
|
|
|
|
|
|
GetByte:
|
|
|
|
lda #$1d ;set read flag low
|
2021-12-31 18:09:53 +00:00
|
|
|
sta OutputFlags,x
|
2021-11-05 19:15:54 +00:00
|
|
|
waitRead:
|
2021-12-31 18:09:53 +00:00
|
|
|
lda InputFlags,x
|
2021-11-05 19:15:54 +00:00
|
|
|
rol
|
|
|
|
bcc readByte
|
|
|
|
bit Keyboard ;keypress will abort waiting to read
|
|
|
|
bpl waitRead
|
2021-11-27 03:51:52 +00:00
|
|
|
keyPressed:
|
2022-02-22 20:43:54 +00:00
|
|
|
lda Keyboard ;send keypress to RPi
|
|
|
|
and #$7f
|
|
|
|
sta OutputByte,x
|
|
|
|
bit ClearKeyboard
|
|
|
|
lda #$1c ;set write flag low too
|
2021-12-31 18:09:53 +00:00
|
|
|
sta OutputFlags,x
|
2022-02-22 20:43:54 +00:00
|
|
|
finishKeyPress:
|
|
|
|
lda InputFlags,x
|
|
|
|
rol
|
|
|
|
rol
|
|
|
|
bcc finishKeyPress
|
|
|
|
lda #$1d ;set flags back for reading
|
|
|
|
sta OutputFlags,x
|
|
|
|
jmp waitRead
|
2021-11-05 19:15:54 +00:00
|
|
|
readByte:
|
2021-12-31 18:09:53 +00:00
|
|
|
lda InputByte,x
|
2021-11-05 19:15:54 +00:00
|
|
|
pha
|
|
|
|
lda #$1f ;set all flags high
|
2021-12-31 18:09:53 +00:00
|
|
|
sta OutputFlags,x
|
2021-11-05 19:15:54 +00:00
|
|
|
finishRead:
|
2021-12-31 18:09:53 +00:00
|
|
|
lda InputFlags,x
|
2021-11-05 19:15:54 +00:00
|
|
|
rol
|
|
|
|
bcc finishRead
|
|
|
|
pla
|
|
|
|
clc ;success
|
|
|
|
end:
|
|
|
|
rts
|
|
|
|
|
2021-11-27 03:51:52 +00:00
|
|
|
SetCursor:
|
2021-11-25 23:45:56 +00:00
|
|
|
lda htab80 ;get horizontal location / 2
|
|
|
|
lsr
|
|
|
|
tay
|
|
|
|
lda TextPage2
|
2021-11-27 03:51:52 +00:00
|
|
|
bcc setChar
|
2021-11-25 23:45:56 +00:00
|
|
|
lda TextPage1
|
2021-11-27 03:51:52 +00:00
|
|
|
setChar:
|
2021-11-25 23:45:56 +00:00
|
|
|
lda (BasL),y
|
2021-11-27 03:51:52 +00:00
|
|
|
sta LastChar ; save so ClearCursor will pick it up
|
|
|
|
cmp #$e0
|
|
|
|
bpl lowerCase
|
|
|
|
cmp #$c0
|
|
|
|
bpl upperCase
|
|
|
|
cmp #$a0
|
|
|
|
bpl symbol
|
|
|
|
cmp #$80
|
|
|
|
bpl noop
|
|
|
|
symbol:
|
|
|
|
lowerCase:
|
|
|
|
invert:
|
2021-11-25 23:45:56 +00:00
|
|
|
eor #$80
|
2021-11-27 03:51:52 +00:00
|
|
|
jmp storeChar
|
|
|
|
upperCase:
|
|
|
|
and #$1f
|
|
|
|
jmp storeChar
|
|
|
|
noop:
|
|
|
|
storeChar:
|
2021-11-25 23:45:56 +00:00
|
|
|
sta (BasL),y
|
|
|
|
lda TextPage1
|
|
|
|
rts
|
|
|
|
|
2021-11-27 03:51:52 +00:00
|
|
|
ClearCursor:
|
|
|
|
lda htab80 ;get horizontal location / 2
|
|
|
|
lsr
|
|
|
|
tay
|
|
|
|
lda TextPage2
|
|
|
|
bcc restoreChar
|
|
|
|
lda TextPage1
|
|
|
|
restoreChar:
|
|
|
|
lda LastChar
|
|
|
|
sta (BasL),y
|
|
|
|
lda TextPage1
|
|
|
|
rts
|
2022-03-02 03:46:03 +00:00
|
|
|
|
|
|
|
Text:
|
2023-01-31 01:45:24 +00:00
|
|
|
.byte "Apple2-IO-RPi Shell Version 000E",$8d
|
2023-01-14 15:51:39 +00:00
|
|
|
.byte "(c)2020-2023 Terence J. Boldt",$8d
|
2022-03-02 03:46:03 +00:00
|
|
|
.byte $8d
|
|
|
|
.byte $00
|