From 95d46a7e003685ede758199638c42296512ed2ef Mon Sep 17 00:00:00 2001 From: nino-porcino Date: Tue, 18 Jan 2022 15:15:48 +0100 Subject: [PATCH] add line_input routine --- lib/apple1.h | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/lib/apple1.h b/lib/apple1.h index d9dc25e..e27d59d 100644 --- a/lib/apple1.h +++ b/lib/apple1.h @@ -123,6 +123,39 @@ byte apple1_readkey() { #endif } +void apple1_input_line(byte *buffer, byte max) { + byte x=0; + + while(1) { + byte c = apple1_getkey(); + buffer[x] = c; + if(c==13) { + // RETURN ends input + break; + } + else if(c==27) { + // ESC clears the string + x=0; + break; + } + else if(c==8 || c=='_') { + // BACKSPACE + if(x != 0) { + woz_putc('_'); + x--; + } + } + else { + // character input + if(x // for memcpy