From 0f4cb443b4d34dfceef35c0f9b31abcf69d00c67 Mon Sep 17 00:00:00 2001
From: Oliver Schmidt
Date: Sat, 19 Dec 2020 19:54:12 +0100
Subject: [PATCH] Improved device I/O under DOS 3.3
Certain scenarios (e.g. not running any Applesoft program at all since booting DOS 3.3) can make DOS 3.3 consider cc65 device input (e.g. getchar()) that reads a CR interpreting the command in the keyboard buffer. Setting the hibyte of the Applesoft currently executed line number to some value <> $FF (beside setting the input prompt to some value <> ']') makes DOS 3.3 understand that we're not in intermediate mode and that therefore I/O not preceded with ctrl-d mustn't be fiddled with (see DOS 3.3 routine at $A65E).
---
asminc/apple2.inc | 1 +
libsrc/apple2/read.s | 9 ++++++---
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/asminc/apple2.inc b/asminc/apple2.inc
index 5ebf73164..528c463a1 100644
--- a/asminc/apple2.inc
+++ b/asminc/apple2.inc
@@ -15,6 +15,7 @@ PROMPT := $33 ; Used by GETLN
RNDL := $4E ; Random counter low
RNDH := $4F ; Random counter high
HIMEM := $73 ; Highest available memory address+1
+CURLIN := $75 ; Current line number being executed
;-----------------------------------------------------------------------------
; Vectors
diff --git a/libsrc/apple2/read.s b/libsrc/apple2/read.s
index 14c80b7e2..99c189cbd 100644
--- a/libsrc/apple2/read.s
+++ b/libsrc/apple2/read.s
@@ -19,11 +19,14 @@
.segment "ONCE"
initprompt:
- ; Set prompt <> ']' to let DOS 3.3 know that we're
- ; not in Applesoft immediate mode and thus keep it
- ; from scanning our device I/O for DOS commands.
+ ; Set prompt <> ']' and currently executed Applesoft
+ ; line number hibyte <> $FF to let DOS 3.3 (at $A65E)
+ ; know that we're not in Applesoft immediate mode and
+ ; thus keep it from scanning our device I/O for DOS
+ ; commands.
lda #$80 ; Same value used at $D52C
sta PROMPT
+ sta CURLIN+1 ; Any value <> $FF will do
rts
.code