Skip to content

Commit 514e736

Browse files
authored
Merge pull request #434 from boriel/bugfix/input_breaks_pause
Fix PAUSE not working after using INPUT
2 parents 3fa7da0 + 3aa6e12 commit 514e736

2 files changed

Lines changed: 88 additions & 84 deletions

File tree

src/arch/zx48k/library/input.bas

Lines changed: 44 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
' ----------------------------------------------------------------
22
' This file is released under the MIT License
3-
'
3+
'
44
' Copyleft (k) 2008
55
' by Jose Rodriguez-Rosa (a.k.a. Boriel) <http://www.boriel.com>
66
'
@@ -24,43 +24,45 @@ REM Uses ZX SPECTRUM ROM
2424
#pragma case_insensitive = True
2525

2626
FUNCTION input(MaxLen AS UINTEGER) AS STRING
27-
DIM LastK AS UBYTE AT 23560: REM LAST_K System VAR
28-
DIM result$ AS STRING
29-
DIM i as UINTEGER
30-
31-
result$ = ""
32-
POKE 23611, PEEK 23611 bOR 8
33-
34-
DO
35-
PRIVATEInputShowCursor()
36-
37-
REM Wait for a Key Press
38-
LastK = 0
39-
DO LOOP UNTIL LastK <> 0
40-
41-
PRIVATEInputHideCursor()
42-
43-
IF LastK = 12 THEN
44-
IF LEN(result$) THEN REM "Del" key code is 12
45-
IF LEN(result$) = 1 THEN
46-
LET result$ = ""
47-
ELSE
48-
LET result$ = result$( TO LEN(result$) - 2)
49-
END IF
50-
PRINT CHR$(8);
51-
END IF
52-
ELSEIF LastK >= CODE(" ") AND LEN(result$) < MaxLen THEN
53-
LET result$ = result$ + CHR$(LastK)
54-
PRINT CHR$(LastK);
55-
END IF
56-
57-
LOOP UNTIL LastK = 13 : REM "Enter" key code is 13
58-
59-
FOR i = 1 TO LEN(result$):
60-
PRINT OVER 0; CHR$(8) + " " + chr$(8);
61-
NEXT
62-
63-
RETURN result$
27+
DIM LastK AS UBYTE AT 23560: REM LAST_K System VAR
28+
DIM result$ AS STRING
29+
DIM i as UINTEGER
30+
31+
result$ = ""
32+
POKE 23611, PEEK 23611 bOR 8 : REM sets FLAGS var to L mode
33+
34+
DO
35+
PRIVATEInputShowCursor()
36+
37+
REM Wait for a Key Press
38+
LastK = 0
39+
DO LOOP UNTIL LastK <> 0
40+
41+
PRIVATEInputHideCursor()
42+
43+
IF LastK = 12 THEN
44+
IF LEN(result$) THEN REM "Del" key code is 12
45+
IF LEN(result$) = 1 THEN
46+
LET result$ = ""
47+
ELSE
48+
LET result$ = result$( TO LEN(result$) - 2)
49+
END IF
50+
PRINT CHR$(8);
51+
END IF
52+
ELSEIF LastK >= CODE(" ") AND LEN(result$) < MaxLen THEN
53+
LET result$ = result$ + CHR$(LastK)
54+
PRINT CHR$(LastK);
55+
END IF
56+
57+
LOOP UNTIL LastK = 13 : REM "Enter" key code is 13
58+
59+
POKE 23611, PEEK 23611 bAND 0xEF : REM resets FLAGS var
60+
61+
FOR i = 1 TO LEN(result$):
62+
PRINT OVER 0; CHR$(8) + " " + chr$(8);
63+
NEXT
64+
65+
RETURN result$
6466

6567
END FUNCTION
6668

@@ -71,8 +73,8 @@ END FUNCTION
7173
' Shows a flashing cursor
7274
' ------------------------------------------------------------------
7375
SUB FASTCALL PRIVATEInputShowCursor
74-
REM Print a Flashing cursor at current print position
75-
PRINT AT csrlin(), pos(); OVER 0; FLASH 1; " " + CHR$(8);
76+
REM Print a Flashing cursor at current print position
77+
PRINT AT csrlin(), pos(); OVER 0; FLASH 1; " " + CHR$(8);
7678
END SUB
7779

7880

@@ -81,8 +83,8 @@ END SUB
8183
' Hides the flashing cursor
8284
' ------------------------------------------------------------------
8385
SUB FASTCALL PRIVATEInputHideCursor
84-
REM Print a Flashing cursor at current print position
85-
PRINT AT csrlin(), pos(); OVER 0; FLASH 0; " " + CHR$(8);
86+
REM Print a Flashing cursor at current print position
87+
PRINT AT csrlin(), pos(); OVER 0; FLASH 0; " " + CHR$(8);
8688
END SUB
8789

8890
#endif

src/arch/zxnext/library/input.bas

Lines changed: 44 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
' ----------------------------------------------------------------
22
' This file is released under the MIT License
3-
'
3+
'
44
' Copyleft (k) 2008
55
' by Jose Rodriguez-Rosa (a.k.a. Boriel) <http://www.boriel.com>
66
'
@@ -24,43 +24,45 @@ REM Uses ZX SPECTRUM ROM
2424
#pragma case_insensitive = True
2525

2626
FUNCTION input(MaxLen AS UINTEGER) AS STRING
27-
DIM LastK AS UBYTE AT 23560: REM LAST_K System VAR
28-
DIM result$ AS STRING
29-
DIM i as UINTEGER
30-
31-
result$ = ""
32-
POKE 23611, PEEK 23611 bOR 8
33-
34-
DO
35-
PRIVATEInputShowCursor()
36-
37-
REM Wait for a Key Press
38-
LastK = 0
39-
DO LOOP UNTIL LastK <> 0
40-
41-
PRIVATEInputHideCursor()
42-
43-
IF LastK = 12 THEN
44-
IF LEN(result$) THEN REM "Del" key code is 12
45-
IF LEN(result$) = 1 THEN
46-
LET result$ = ""
47-
ELSE
48-
LET result$ = result$( TO LEN(result$) - 2)
49-
END IF
50-
PRINT CHR$(8);
51-
END IF
52-
ELSEIF LastK >= CODE(" ") AND LEN(result$) < MaxLen THEN
53-
LET result$ = result$ + CHR$(LastK)
54-
PRINT CHR$(LastK);
55-
END IF
56-
57-
LOOP UNTIL LastK = 13 : REM "Enter" key code is 13
58-
59-
FOR i = 1 TO LEN(result$):
60-
PRINT OVER 0; CHR$(8) + " " + chr$(8);
61-
NEXT
62-
63-
RETURN result$
27+
DIM LastK AS UBYTE AT 23560: REM LAST_K System VAR
28+
DIM result$ AS STRING
29+
DIM i as UINTEGER
30+
31+
result$ = ""
32+
POKE 23611, PEEK 23611 bOR 8 : REM sets FLAGS var to L mode
33+
34+
DO
35+
PRIVATEInputShowCursor()
36+
37+
REM Wait for a Key Press
38+
LastK = 0
39+
DO LOOP UNTIL LastK <> 0
40+
41+
PRIVATEInputHideCursor()
42+
43+
IF LastK = 12 THEN
44+
IF LEN(result$) THEN REM "Del" key code is 12
45+
IF LEN(result$) = 1 THEN
46+
LET result$ = ""
47+
ELSE
48+
LET result$ = result$( TO LEN(result$) - 2)
49+
END IF
50+
PRINT CHR$(8);
51+
END IF
52+
ELSEIF LastK >= CODE(" ") AND LEN(result$) < MaxLen THEN
53+
LET result$ = result$ + CHR$(LastK)
54+
PRINT CHR$(LastK);
55+
END IF
56+
57+
LOOP UNTIL LastK = 13 : REM "Enter" key code is 13
58+
59+
POKE 23611, PEEK 23611 bAND 0xEF : REM resets FLAGS var
60+
61+
FOR i = 1 TO LEN(result$):
62+
PRINT OVER 0; CHR$(8) + " " + chr$(8);
63+
NEXT
64+
65+
RETURN result$
6466

6567
END FUNCTION
6668

@@ -71,8 +73,8 @@ END FUNCTION
7173
' Shows a flashing cursor
7274
' ------------------------------------------------------------------
7375
SUB FASTCALL PRIVATEInputShowCursor
74-
REM Print a Flashing cursor at current print position
75-
PRINT AT csrlin(), pos(); OVER 0; FLASH 1; " " + CHR$(8);
76+
REM Print a Flashing cursor at current print position
77+
PRINT AT csrlin(), pos(); OVER 0; FLASH 1; " " + CHR$(8);
7678
END SUB
7779

7880

@@ -81,8 +83,8 @@ END SUB
8183
' Hides the flashing cursor
8284
' ------------------------------------------------------------------
8385
SUB FASTCALL PRIVATEInputHideCursor
84-
REM Print a Flashing cursor at current print position
85-
PRINT AT csrlin(), pos(); OVER 0; FLASH 0; " " + CHR$(8);
86+
REM Print a Flashing cursor at current print position
87+
PRINT AT csrlin(), pos(); OVER 0; FLASH 0; " " + CHR$(8);
8688
END SUB
8789

8890
#endif

0 commit comments

Comments
 (0)