Skip to content

Commit 60ea289

Browse files
Add crappy os_GetStringInput
People should really write their own input routines. But this will be fine for fast testing and simple programs.
1 parent 9294665 commit 60ea289

File tree

1 file changed

+112
-36
lines changed

1 file changed

+112
-36
lines changed

src/ce/getstringinput.src

Lines changed: 112 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,31 @@
11
; ---
2-
; void os_GetStringInput(char *string, char *buf, size_t bufsize)
2+
; void os_GetStringInput(char *string, char *buf, size_t size)
33
; ---
44

55
.def _os_GetStringInput
66
.assume adl=1
77

8+
kUp := 3
9+
kLeft := 2
10+
kDown := 4
11+
kEnter := 5
12+
kClear := 9
13+
kRight := 1
14+
curLock := 4
15+
flags := $D00080
16+
curRow := $D00595
17+
curUnder := $D00599
18+
_PutS := $207C0
19+
_PutC := $207B8
20+
_PutPS := $207C8
21+
_GetKey := $20D8C
22+
_CursorOn := $208B0
23+
_CursorOff := $208A8
24+
_PullDownChk := $208BC
25+
_ConvKeyToTok := $20E40
26+
_GetTokString := $20874
27+
_PutTokString := $20D74
28+
829
_os_GetStringInput:
930
push ix
1031
ld ix,0
@@ -13,46 +34,101 @@ _os_GetStringInput:
1334
add hl,de
1435
xor a,a
1536
sbc hl,de
16-
ld de,0D00879h ; ioPrompt
17-
jr z,donecopy
18-
copyloop:
37+
jr z,__nodisp
38+
ld iy,flags
39+
call _PutS
40+
__nodisp:
41+
ld hl,(curRow)
42+
ld (__savecur),hl
43+
ld a,(ix+12)
44+
dec a
45+
ld (ix+12),a
46+
ld (ix+6),a
47+
__start:
48+
ld de,(ix+9)
49+
__loop:
50+
ld a,' '
51+
ld (curUnder),a
52+
push de
53+
push ix
54+
call _CursorOn
55+
__getkey:
56+
call _GetKey
57+
call _CursorOff
58+
call _PullDownChk
59+
call _CursorOn
60+
jr c,__getkey
61+
cp a,kLeft
62+
jr z,__loop
63+
cp a,kDown
64+
jr z,__loop
65+
cp a,kRight
66+
jr z,__loop
67+
cp a,kUp
68+
jr z,__loop
69+
cp a,kClear
70+
jr z,__clearpop
71+
cp a,kEnter
72+
jr z,__done
73+
call _ConvKeyToTok
74+
call _GetTokString
75+
pop ix
76+
pop de
77+
ld b,(hl)
78+
inc hl
79+
ld a,(ix+12)
80+
sub a,b
81+
jr nc,__notfull
82+
ld b,(ix+12)
83+
xor a,a
84+
__notfull:
85+
ld (ix+12),a
86+
__draw:
1987
ld a,(hl)
20-
or a,a
21-
jr z,donecopy
2288
ld (de),a
2389
inc hl
2490
inc de
25-
jr copyloop ; copy the input prompt here
26-
donecopy:
27-
ld (de),a
28-
ld (0D00599h),a ; curUnder
29-
ld iy,0D00080h
30-
ld b,(iy+9)
31-
ld c,(iy+28) ; back up old flag values
32-
res 6,(iy+28)
33-
set 7,(iy+9)
34-
push ix
35-
push bc
36-
call 021320h ; _GetStringInput, get the input from the user
37-
pop bc
38-
res 4,b ; restore old flag values
39-
ld (iy+9),b
40-
ld (iy+28),c
41-
ld hl,(0D0244Eh) ; editSym
42-
call 020AE8h ; _VarNameToOP1HL, lookup the temporary input symbol
43-
call 02050Ch ; _ChkFindSym
91+
call _PutC
92+
djnz __draw
93+
ld a,(ix+12)
94+
or a,a
95+
jr nz,__loop
96+
__full:
97+
ld a,' '
98+
ld (curUnder),a
99+
call _GetKey
100+
cp a,kClear
101+
jr z,__clear
102+
cp a,kEnter
103+
jr z,__exit
104+
jr __full
105+
__clearpop:
44106
pop ix
45-
jr c,SomeError
46-
ex de,hl
47-
inc hl
48-
inc hl
49-
ld de,(ix+9) ; hl -> input string prompt
50-
ld bc,(ix+12) ; bc = input string length
51-
dec bc
52-
ldir
107+
pop de
108+
__clear:
109+
__savecur := $+1
110+
ld hl,0
111+
ld (curRow),hl
112+
ld a,(ix+6)
113+
ld b,(ix+12)
114+
ld (ix+12),a
115+
sub a,b
116+
ld b,a
117+
inc b
118+
__clearloop:
119+
ld a,' '
120+
call _PutC
121+
djnz __clearloop
122+
ld hl,(__savecur)
123+
ld (curRow),hl
124+
jr __start
125+
__done:
126+
pop ix
127+
pop de
128+
__exit:
129+
ld a,' '
130+
ld (curUnder),a
53131
xor a,a
54-
ld (de),a ; null terminate the string
55-
SomeError:
56-
call 021578h ; DeleteTempEditEqu, delete the temporary input
132+
ld (de),a
57133
pop ix
58134
ret

0 commit comments

Comments
 (0)