Added support for alternative memory locations of Apple-1 Serial Interface Card

This commit is contained in:
flowenol 2023-01-15 02:40:58 +01:00
parent 943d2298f4
commit db624e519d
2 changed files with 97 additions and 18 deletions

View File

@ -1,5 +1,5 @@
MEMORY {
BASROM: start = $6000, size = $2000, fill = yes, file = %O;
BASROM: start = $6000, size = $203F, fill = yes, file = %O;
}
SEGMENTS {

View File

@ -7,11 +7,26 @@
.import ERROR, FIX_LINKS, OUTDO
.export SerialLoad, SerialSave, SerialMenu
SERIAL_MONITOR := $C100
SERIAL_READY := $C000
SERIAL_ID := $C0FC
SERIAL_API_READ := $C1EC
SERIAL_API_WRITE := $C213
SERIAL_MONITOR_C000 := $C100
SERIAL_READY_C000 := $C000
SERIAL_ID_C000 := $C0FC
SERIAL_API_READ_C000 := $C1EC
SERIAL_API_WRITE_C000 := $C213
SERIAL_MONITOR_C300 := $C400
SERIAL_READY_C300 := $C300
SERIAL_ID_C300 := $C3FC
SERIAL_API_READ_C300 := $C4EC
SERIAL_API_WRITE_C300 := $C513
SERIAL_MONITOR_C600 := $C700
SERIAL_READY_C600 := $C600
SERIAL_ID_C600 := $C6FC
SERIAL_API_READ_C600 := $C7EC
SERIAL_API_WRITE_C600 := $C813
; 0 - $C000, 1 - $C300, 2 - $C600
SERIAL_VARIANT := $40
; ZP locations get backed up here
ZPTemp := $0380
@ -34,18 +49,54 @@ STR2INT_END := $0A
; See if Apple-1 Serial Interface card is present and display error if not
; ----------------------------------------------------------------------------
CheckSerial:
ldy SERIAL_ID
ldy SERIAL_ID_C000
cpy #'A'
bne @1
ldy SERIAL_ID_C000 + 1
cpy #'1'
bne @1
ldy SERIAL_ID_C000 + 2
cpy #'S'
bne @1
ldy SERIAL_ID_C000 + 3
cpy #'I'
bne @1
lda #$00
sta SERIAL_VARIANT
rts
@1:
ldy SERIAL_ID_C300
cpy #'A'
bne @2
ldy SERIAL_ID_C300 + 1
cpy #'1'
bne @2
ldy SERIAL_ID_C300 + 2
cpy #'S'
bne @2
ldy SERIAL_ID_C300 + 3
cpy #'I'
bne @2
lda #$01
sta SERIAL_VARIANT
rts
@2:
ldy SERIAL_ID_C600
cpy #'A'
bne SerialErr
ldy SERIAL_ID + 1
ldy SERIAL_ID_C600 + 1
cpy #'1'
bne SerialErr
ldy SERIAL_ID + 2
ldy SERIAL_ID_C600 + 2
cpy #'S'
bne SerialErr
ldy SERIAL_ID + 3
ldy SERIAL_ID_C600 + 3
cpy #'I'
bne SerialErr
lda #$02
sta SERIAL_VARIANT
rts
SerialErr:
@ -61,8 +112,13 @@ SynErr:
; ----------------------------------------------------------------------------
SerialMenu:
jsr CheckSerial
jsr SERIAL_MONITOR
lda SERIAL_VARIANT
bne @1
jsr SERIAL_MONITOR_C000
rts
@1:
jsr SERIAL_MONITOR_C300
rts
; ----------------------------------------------------------------------------
; Save program via the Apple-1 Serial Interface
@ -87,10 +143,20 @@ SerialSave:
lda TXTTAB+1
sta BEG_ADDR_H
jsr SERIAL_API_WRITE
lda SERIAL_VARIANT
bne @2
jsr SERIAL_API_WRITE_C000
jmp @4
@2:
cmp #$01
bne @3
jsr SERIAL_API_WRITE_C300
jmp @4
@3:
jsr SERIAL_API_WRITE_C600
@4:
jsr RestoreZPForSave ; Put the zero page back
rts
; ----------------------------------------------------------------------------
; Restores the 4 bytes of the ZP which were saved during SerialSave
; ----------------------------------------------------------------------------
@ -137,15 +203,17 @@ GetLength: ; Get file name from input line
@2:
cpy #0 ; Read 6 chars or EOL, did we get anything?
beq SynErr
bne @3
jmp SynErr
@3:
lda #STR2INT_END ; append integer string end marker
sta STR2INT_BUF,y
jsr String2Int
lda STR2INT_INT
bne @3
bne @4
dec STR2INT_INT+1
@3:
@4:
dec STR2INT_INT
clc
SetLoadAddresses:
@ -164,7 +232,18 @@ SetLoadAddresses:
lda TXTTAB+1
sta BEG_ADDR_H
jsr SERIAL_API_READ
lda SERIAL_VARIANT
bne @1
jsr SERIAL_API_READ_C000
jmp @3
@1:
cmp #$01
bne @2
jsr SERIAL_API_READ_C300
jmp @3
@2:
jsr SERIAL_API_READ_C600
@3:
jsr RestoreZPForLoad ; Put the zero page back
jmp FIX_LINKS