File tree Expand file tree Collapse file tree 3 files changed +361
-84
lines changed Expand file tree Collapse file tree 3 files changed +361
-84
lines changed Original file line number Diff line number Diff line change 1
- ; ---
2
- ; void os_GetStringInput(char *string, char *buf, size_t size)
3
- ; ---
4
1
assume adl=1
5
2
6
3
kUp := 3
@@ -9,9 +6,11 @@ kDown := 4
9
6
kEnter := 5
10
7
kClear := 9
11
8
kRight := 1
9
+ kQuit := $40
10
+ kIns := $0B
12
11
curLock := 4
13
12
flags := $D00080
14
- curRow := $D00595
13
+ curRow := $D00595 ; also includes curCol
15
14
curUnder := $D00599
16
15
_PutS := $207C0
17
16
_PutC := $207B8
@@ -23,120 +22,174 @@ _PullDownChk := $208BC
23
22
_ConvKeyToTok := $20E40
24
23
_GetTokString := $20874
25
24
_PutTokString := $20D74
25
+ _ClrTxtShd := $20818
26
26
27
27
section .text
28
28
public _os_GetStringInput
29
29
_os_GetStringInput:
30
30
push ix
31
31
ld ix,0
32
32
add ix,sp
33
+ push ix
34
+ ld iy,flags
35
+ ld a,(iy + $0d)
36
+ ld (.smc.text_flag_0),a
37
+ ld a,(iy + $4c)
38
+ ld (.smc.text_flag_1),a
39
+ set 1,(iy + $0d) ; use text buffer
40
+ res 5,(iy + $4c) ; use text buffer
41
+ call _ClrTxtShd
42
+ pop ix
33
43
ld hl,(ix+6) ; hl -> input string prompt
34
44
add hl,de
35
45
xor a,a
36
46
sbc hl,de
37
- jr z,__nodisp
38
47
ld iy,flags
39
- call _PutS
40
- __nodisp:
48
+ call nz,_PutS
41
49
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
- jr __loop
50
- __skiploop:
50
+ ld (.smc.curRow),hl
51
+ ld hl,(ix+12)
52
+ add hl,de
53
+ xor a,a
54
+ sbc hl,de
55
+ jr nz,.not_empty
51
56
pop ix
52
- pop de
53
- __loop:
54
- ld a,' '
55
- ld (curUnder),a
56
- push de
57
+ ret
58
+ .not_empty:
59
+ dec hl ; subtract 1 for null pointer
60
+ ld (ix+12),hl
61
+ ld (ix+6),hl ; save initial size
62
+ .start:
63
+ ld hl,(ix+6) ; restore initial size
64
+ ld (ix+12),hl
65
+ or a,a
66
+ sbc hl,hl
67
+ ld (.smc.str_len),hl
68
+ .loop:
69
+ ld iy,flags
57
70
push ix
58
71
call _CursorOn
59
- __getkey :
72
+ .getkey :
60
73
call _GetKey
61
74
call _CursorOff
62
75
call _PullDownChk
76
+ push af
63
77
call _CursorOn
64
- jr c,__getkey
78
+ pop af
79
+ jr c,.getkey
80
+ pop ix
81
+ cp a,kQuit
82
+ jp z,.done
65
83
cp a,kLeft
66
- jr z,__skiploop
84
+ jr z,.loop
67
85
cp a,kDown
68
- jr z,__skiploop
86
+ jr z,.loop
69
87
cp a,kRight
70
- jr z,__skiploop
88
+ jr z,.loop
71
89
cp a,kUp
72
- jr z,__skiploop
90
+ jr z,.loop
73
91
cp a,kClear
74
- jr z,__clearpop
92
+ jp z,.clear
75
93
cp a,kEnter
76
- jr z,__done
94
+ jp z,.done
95
+ cp a,kIns
96
+ jr z,.loop
97
+ ld de,(ix+9)
98
+ ld hl,(.smc.str_len)
99
+ add hl,de
100
+ push hl ; save buf pointer
101
+ push ix
102
+ cp a,$F3 ; for lists? idk something is wrong with _PullDownChk
103
+ jr z,.sub_key
104
+ cp a,$F4
105
+ jr z,.sub_key
106
+ cp a,$F5
107
+ jr z,.sub_key
108
+ cp a,$F6
109
+ jr z,.sub_key
110
+ cp a,$F7
111
+ jr z,.sub_key
112
+ cp a,$F8
113
+ jr z,.sub_key
114
+ cp a,$F9
115
+ jr z,.sub_key
116
+ cp a,$FA
117
+ jr z,.sub_key
118
+ cp a,$FB
119
+ jr z,.sub_key
120
+ jr .conv_key
121
+ .sub_key:
122
+ sub a,$7C
123
+ ld ($0D0058E),a
124
+ ld a,$FE
125
+ .conv_key:
77
126
call _ConvKeyToTok
78
127
call _GetTokString
79
128
pop ix
80
- pop de
81
- ld b,(hl)
129
+ pop de ; restore buf pointer
130
+ ld b,(hl) ; token string length
82
131
inc hl
83
- ld a,(ix+12)
84
- sub a,b
85
- jr nc,__notfull
86
- ld b,(ix+12)
132
+ .draw_string:
133
+ push hl
134
+ ld hl,(ix+12)
135
+ add hl,de
87
136
xor a,a
88
- __notfull:
89
- ld (ix+12),a
90
- __draw:
137
+ sbc hl,de ; check if done
138
+ dec hl
139
+ ld (ix+12),hl
140
+ pop hl
141
+ jr z,.full
142
+ push hl
143
+ ld hl,(.smc.str_len)
144
+ inc hl
145
+ ld (.smc.str_len),hl
146
+ pop hl
91
147
ld a,(hl)
92
148
ld (de),a
93
149
inc hl
94
150
inc de
95
151
call _PutC
96
- djnz __draw
97
- ld a,(ix+12)
98
- or a,a
99
- jr nz,__loop
100
- __full:
101
- ld a,' '
102
- ld (curUnder),a
103
- push de
152
+ djnz .draw_string
153
+ jp .loop
154
+ .full:
155
+ push ix
104
156
call _GetKey
105
- pop de
106
- cp a,kClear
107
- jr z,__clear
108
- cp a,kEnter
109
- jr z,__exit
110
- jr __full
111
- __clearpop:
112
157
pop ix
113
- pop de
114
- __clear:
115
- __savecur := $+1
158
+ cp a,kEnter
159
+ jr z,.done
160
+ cp a,kClear
161
+ jr nz,.full
162
+ .clear:
163
+ .smc.curRow := $+1
116
164
ld hl,0
117
165
ld (curRow),hl
118
- ld a,(ix+6)
119
- ld b,(ix+12)
120
- ld (ix+12),a
121
- sub a,b
122
- ld b,a
123
- inc b
124
- __clearloop:
166
+ ld hl,(.smc.str_len)
167
+ inc hl
168
+ .clear_loop:
169
+ push hl
125
170
ld a,' '
126
171
call _PutC
127
- djnz __clearloop
128
- ld hl,(__savecur)
172
+ pop hl
173
+ ld bc,1
174
+ or a,a
175
+ sbc hl,bc
176
+ jr nz,.clear_loop
177
+ ld hl,(.smc.curRow)
129
178
ld (curRow),hl
130
- jp __start
131
- __done:
132
- pop ix
133
- pop de
134
- __exit:
135
- ld a,' '
136
- ld (curUnder),a
137
- xor a,a
138
- ld (de),a
179
+ jp .start
180
+ .done:
181
+ call _ClrTxtShd
139
182
call _CursorOff
140
- di
183
+ .smc.text_flag_0 := $+1
184
+ ld a,0
185
+ ld (iy + $0d),a
186
+ .smc.text_flag_1 := $+1
187
+ ld a,0
188
+ ld (iy + $4c),a
189
+ ld de,(ix+9)
190
+ .smc.str_len := $+1
191
+ ld hl,0
192
+ add hl,de
193
+ ld (hl),0
141
194
pop ix
142
195
ret
You can’t perform that action at this time.
0 commit comments