Rev 485 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 485 | Rev 551 | ||
---|---|---|---|
1 | ; |
1 | ; |
2 | ; TFTP Client |
2 | ; TFTP Client |
3 | 3 | ||
4 | use32 |
4 | use32 |
5 | org 0x0 |
5 | org 0x0 |
6 | db 'MENUET01' ; header |
6 | db 'MENUET01' ; header |
7 | dd 0x01 ; header version |
7 | dd 0x01 ; header version |
8 | dd START ; entry point |
8 | dd START ; entry point |
9 | dd I_END ; image size |
9 | dd I_END ; image size |
10 | dd I_END+0x10000 ; required memory |
10 | dd I_END+0x10000 ; required memory |
11 | dd I_END+0x10000 ; esp |
11 | dd I_END+0x10000 ; esp |
12 | dd 0x0 , 0x0 ; I_Param , I_Path |
12 | dd 0x0 , 0x0 ; I_Param , I_Path |
13 | 13 | ||
14 | include 'lang.inc' |
14 | include 'lang.inc' |
15 | include '..\..\..\macros.inc' |
15 | include '..\..\..\macros.inc' |
16 | 16 | ||
17 | START: ; start of execution |
17 | START: ; start of execution |
18 | mov eax,40 ; Report events |
18 | mov eax,40 ; Report events |
19 | mov ebx,10000111b ; Stack 8 + defaults |
19 | mov ebx,10000111b ; Stack 8 + defaults |
20 | mcall |
20 | mcall |
21 | 21 | ||
22 | mov dword [prompt], p1 |
22 | mov dword [prompt], p1 |
23 | mov dword [promptlen], p1len - p1 |
23 | mov dword [promptlen], p1len - p1 |
24 | 24 | ||
25 | red: |
25 | red: |
26 | call draw_window ; at first, draw the window |
26 | call draw_window ; at first, draw the window |
27 | 27 | ||
28 | still: |
28 | still: |
29 | mov eax,10 ; wait here for event |
29 | mov eax,10 ; wait here for event |
30 | mcall |
30 | mcall |
31 | 31 | ||
32 | cmp eax,1 ; redraw request ? |
32 | cmp eax,1 ; redraw request ? |
33 | jz red |
33 | jz red |
34 | cmp eax,2 ; key in buffer ? |
34 | cmp eax,2 ; key in buffer ? |
35 | jz key |
35 | jz key |
36 | cmp eax,3 ; button in buffer ? |
36 | cmp eax,3 ; button in buffer ? |
37 | jz button |
37 | jz button |
38 | 38 | ||
39 | jmp still |
39 | jmp still |
40 | 40 | ||
41 | key: ; Keys are not valid at this part of the |
41 | key: ; Keys are not valid at this part of the |
42 | mov eax,2 ; loop. Just read it and ignore |
42 | mov eax,2 ; loop. Just read it and ignore |
43 | mcall |
43 | mcall |
44 | jmp still |
44 | jmp still |
45 | 45 | ||
46 | button: ; button |
46 | button: ; button |
47 | mov eax,17 ; get id |
47 | mov eax,17 ; get id |
48 | mcall |
48 | mcall |
49 | 49 | ||
50 | cmp ah,1 ; button id=1 ? |
50 | cmp ah,1 ; button id=1 ? |
51 | jnz noclose |
51 | jnz noclose |
52 | 52 | ||
53 | 53 | ||
54 | ; close socket before exiting |
54 | ; close socket before exiting |
55 | mov eax, 53 |
55 | mov eax, 53 |
56 | mov ebx, 1 |
56 | mov ebx, 1 |
57 | mov ecx, [socketNum] |
57 | mov ecx, [socketNum] |
58 | int 0x40 |
58 | int 0x40 |
59 | 59 | ||
60 | mov [socketNum], dword 0 |
60 | mov [socketNum], dword 0 |
61 | 61 | ||
62 | 62 | ||
63 | or eax,-1 ; close this program |
63 | or eax,-1 ; close this program |
64 | mcall |
64 | mcall |
65 | 65 | ||
66 | noclose: |
66 | noclose: |
67 | cmp ah,2 ; copy file to local machine? |
67 | cmp ah,2 ; copy file to local machine? |
68 | jnz nocopyl |
68 | jnz nocopyl |
69 | 69 | ||
70 | mov dword [prompt], p5 |
70 | mov dword [prompt], p5 |
71 | mov dword [promptlen], p5len - p5 |
71 | mov dword [promptlen], p5len - p5 |
72 | call draw_window ; |
72 | call draw_window ; |
73 | 73 | ||
74 | ; Copy File from Remote Host to this machine |
74 | ; Copy File from Remote Host to this machine |
75 | call translateData ; Convert Filename & IP address |
75 | call translateData ; Convert Filename & IP address |
76 | mov edi, tftp_filename + 1 |
76 | mov edi, tftp_filename + 1 |
77 | mov [edi], byte 0x01 ; setup tftp msg |
77 | mov [edi], byte 0x01 ; setup tftp msg |
78 | call copyFromRemote |
78 | call copyFromRemote |
79 | 79 | ||
80 | jmp still |
80 | jmp still |
81 | 81 | ||
82 | nocopyl: |
82 | nocopyl: |
83 | 83 | ||
84 | cmp ah,3 ; Copy file to host? |
84 | cmp ah,3 ; Copy file to host? |
85 | jnz nocopyh |
85 | jnz nocopyh |
86 | 86 | ||
87 | mov dword [prompt], p5 |
87 | mov dword [prompt], p5 |
88 | mov dword [promptlen], p5len - p5 |
88 | mov dword [promptlen], p5len - p5 |
89 | call draw_window ; |
89 | call draw_window ; |
90 | 90 | ||
91 | ; Copy File from this machine to Remote Host |
91 | ; Copy File from this machine to Remote Host |
92 | call translateData ; Convert Filename & IP address |
92 | call translateData ; Convert Filename & IP address |
93 | mov edi, tftp_filename + 1 |
93 | mov edi, tftp_filename + 1 |
94 | mov [edi], byte 0x02 ; setup tftp msg |
94 | mov [edi], byte 0x02 ; setup tftp msg |
95 | call copyToRemote |
95 | call copyToRemote |
96 | 96 | ||
97 | jmp still |
97 | jmp still |
98 | 98 | ||
99 | nocopyh: |
99 | nocopyh: |
100 | cmp ah,4 |
100 | cmp ah,4 |
101 | jz f1 |
101 | jz f1 |
102 | cmp ah,5 |
102 | cmp ah,5 |
103 | jz f2 |
103 | jz f2 |
104 | jmp nof12 |
104 | jmp nof12 |
105 | 105 | ||
106 | f1: |
106 | f1: |
107 | mov [addr],dword source |
107 | mov [addr],dword source |
108 | mov [ya],dword 35 |
108 | mov [ya],dword 35 |
109 | jmp rk |
109 | jmp rk |
110 | 110 | ||
111 | f2: |
111 | f2: |
112 | mov [addr],dword destination |
112 | mov [addr],dword destination |
113 | mov [ya],dword 35+16 |
113 | mov [ya],dword 35+16 |
114 | 114 | ||
115 | rk: |
115 | rk: |
116 | mov ecx,15 |
116 | mov ecx,15 |
117 | mov edi,[addr] |
117 | mov edi,[addr] |
118 | mov al,' ' |
118 | mov al,' ' |
119 | rep stosb |
119 | rep stosb |
120 | 120 | ||
121 | call print_text |
121 | call print_text |
122 | 122 | ||
123 | mov edi,[addr] |
123 | mov edi,[addr] |
124 | 124 | ||
125 | f11: |
125 | f11: |
126 | mov eax,10 |
126 | mov eax,10 |
127 | mcall |
127 | mcall |
128 | cmp eax,2 |
128 | cmp eax,2 |
129 | jz fbu |
129 | jz fbu |
130 | jmp still |
130 | jmp still |
131 | fbu: |
131 | fbu: |
132 | mov eax,2 |
132 | mov eax,2 |
133 | mcall ; get key |
133 | mcall ; get key |
134 | shr eax,8 |
134 | shr eax,8 |
135 | cmp eax,8 |
135 | cmp eax,8 |
136 | jnz nobs |
136 | jnz nobs |
137 | cmp edi,[addr] |
137 | cmp edi,[addr] |
138 | jz f11 |
138 | jz f11 |
139 | sub edi,1 |
139 | sub edi,1 |
140 | mov [edi],byte ' ' |
140 | mov [edi],byte ' ' |
141 | call print_text |
141 | call print_text |
142 | jmp f11 |
142 | jmp f11 |
143 | nobs: |
143 | nobs: |
144 | cmp eax,dword 31 |
144 | cmp eax,dword 31 |
145 | jbe f11 |
145 | jbe f11 |
146 | cmp eax,dword 95 |
146 | cmp eax,dword 95 |
147 | jb keyok |
147 | jb keyok |
148 | sub eax,32 |
148 | sub eax,32 |
149 | keyok: |
149 | keyok: |
150 | mov [edi],al |
150 | mov [edi],al |
151 | 151 | ||
152 | call print_text |
152 | call print_text |
153 | 153 | ||
154 | add edi,1 |
154 | add edi,1 |
155 | mov esi,[addr] |
155 | mov esi,[addr] |
156 | add esi,15 |
156 | add esi,15 |
157 | cmp esi,edi |
157 | cmp esi,edi |
158 | jnz f11 |
158 | jnz f11 |
159 | 159 | ||
160 | jmp still |
160 | jmp still |
161 | 161 | ||
162 | print_text: |
162 | print_text: |
163 | 163 | ||
164 | mov eax,13 |
164 | mov eax,13 |
165 | mov ebx,103*65536+15*6 |
165 | mov ebx,103*65536+15*6 |
166 | mov ecx,[ya] |
166 | mov ecx,[ya] |
167 | shl ecx,16 |
167 | shl ecx,16 |
168 | mov cx,8 |
168 | mov cx,8 |
169 | mov edx,0x224466 |
169 | mov edx,0x224466 |
170 | mcall |
170 | mcall |
171 | 171 | ||
172 | mov eax,4 |
172 | mov eax,4 |
173 | mov ebx,103*65536 |
173 | mov ebx,103*65536 |
174 | add ebx,[ya] |
174 | add ebx,[ya] |
175 | mov ecx,0xffffff |
175 | mov ecx,0xffffff |
176 | mov edx,[addr] |
176 | mov edx,[addr] |
177 | mov esi,15 |
177 | mov esi,15 |
178 | mcall |
178 | mcall |
179 | 179 | ||
180 | ret |
180 | ret |
181 | 181 | ||
182 | 182 | ||
183 | nof12: |
183 | nof12: |
184 | jmp still |
184 | jmp still |
185 | 185 | ||
186 | 186 | ||
187 | ;*************************************************************************** |
187 | ;*************************************************************************** |
188 | ; Function |
188 | ; Function |
189 | ; translateData |
189 | ; translateData |
190 | ; |
190 | ; |
191 | ; Description |
191 | ; Description |
192 | ; Coverts the filename and IP address typed in by the user into |
192 | ; Coverts the filename and IP address typed in by the user into |
193 | ; a format suitable for the IP layer. |
193 | ; a format suitable for the IP layer. |
194 | ; |
194 | ; |
195 | ; The filename, in source, is converted and stored in tftp_filename |
195 | ; The filename, in source, is converted and stored in tftp_filename |
196 | ; The host ip, in destination, is converted and stored in tftp_IP |
196 | ; The host ip, in destination, is converted and stored in tftp_IP |
197 | ; |
197 | ; |
198 | ;*************************************************************************** |
198 | ;*************************************************************************** |
199 | translateData: |
199 | translateData: |
200 | 200 | ||
201 | ; first, build up the tftp command string. This includes the filename |
201 | ; first, build up the tftp command string. This includes the filename |
202 | ; and the transfer protocol |
202 | ; and the transfer protocol |
203 | 203 | ||
204 | 204 | ||
205 | ; First, write 0,0 |
205 | ; First, write 0,0 |
206 | mov al, 0 |
206 | mov al, 0 |
207 | mov edi, tftp_filename |
207 | mov edi, tftp_filename |
208 | mov [edi], al |
208 | mov [edi], al |
209 | inc edi |
209 | inc edi |
210 | mov [edi], al |
210 | mov [edi], al |
211 | inc edi |
211 | inc edi |
212 | 212 | ||
213 | ; Now, write the file name itself, and null terminate it |
213 | ; Now, write the file name itself, and null terminate it |
214 | mov ecx, 15 |
214 | mov ecx, 15 |
215 | mov ah, ' ' |
215 | mov ah, ' ' |
216 | mov esi, source |
216 | mov esi, source |
217 | 217 | ||
218 | td001: |
218 | td001: |
219 | lodsb |
219 | lodsb |
220 | stosb |
220 | stosb |
221 | cmp al, ah |
221 | cmp al, ah |
222 | loopnz td001 |
222 | loopnz td001 |
223 | 223 | ||
224 | cmp al,ah ; Was the entire buffer full of characters? |
224 | cmp al,ah ; Was the entire buffer full of characters? |
225 | jne td002 |
225 | jne td002 |
226 | dec edi ; No - so remove ' ' character |
226 | dec edi ; No - so remove ' ' character |
227 | 227 | ||
228 | td002: |
228 | td002: |
229 | mov [edi], byte 0 |
229 | mov [edi], byte 0 |
230 | inc edi |
230 | inc edi |
231 | mov [edi], byte 'O' |
231 | mov [edi], byte 'O' |
232 | inc edi |
232 | inc edi |
233 | mov [edi], byte 'C' |
233 | mov [edi], byte 'C' |
234 | inc edi |
234 | inc edi |
235 | mov [edi], byte 'T' |
235 | mov [edi], byte 'T' |
236 | inc edi |
236 | inc edi |
237 | mov [edi], byte 'E' |
237 | mov [edi], byte 'E' |
238 | inc edi |
238 | inc edi |
239 | mov [edi], byte 'T' |
239 | mov [edi], byte 'T' |
240 | inc edi |
240 | inc edi |
241 | mov [edi], byte 0 |
241 | mov [edi], byte 0 |
242 | 242 | ||
243 | mov esi, tftp_filename |
243 | mov esi, tftp_filename |
244 | sub edi, esi |
244 | sub edi, esi |
245 | mov [tftp_len], edi |
245 | mov [tftp_len], edi |
246 | 246 | ||
247 | 247 | ||
248 | ; Now, convert the typed IP address into a real address |
248 | ; Now, convert the typed IP address into a real address |
249 | ; No validation is done on the number entered |
249 | ; No validation is done on the number entered |
250 | ; ip addresses must be typed in normally, eg |
250 | ; ip addresses must be typed in normally, eg |
251 | ; 192.1.45.24 |
251 | ; 192.1.45.24 |
252 | 252 | ||
253 | xor eax, eax |
253 | xor eax, eax |
254 | mov dh, 10 |
254 | mov dh, 10 |
255 | mov dl, al |
255 | mov dl, al |
256 | mov [tftp_IP], eax |
256 | mov [tftp_IP], eax |
257 | 257 | ||
258 | ; 192.168.24.1 1.1.1.1 1. 9.2.3. |
258 | ; 192.168.24.1 1.1.1.1 1. 9.2.3. |
259 | 259 | ||
260 | mov esi, destination |
260 | mov esi, destination |
261 | mov edi, tftp_IP |
261 | mov edi, tftp_IP |
262 | 262 | ||
263 | mov ecx, 4 |
263 | mov ecx, 4 |
264 | 264 | ||
265 | td003: |
265 | td003: |
266 | lodsb |
266 | lodsb |
267 | sub al, '0' |
267 | sub al, '0' |
268 | add dl, al |
268 | add dl, al |
269 | lodsb |
269 | lodsb |
270 | cmp al, '.' |
270 | cmp al, '.' |
271 | je ipNext |
271 | je ipNext |
272 | cmp al, ' ' |
272 | cmp al, ' ' |
273 | je ipNext |
273 | je ipNext |
274 | mov dh, al |
274 | mov dh, al |
275 | sub dh, '0' |
275 | sub dh, '0' |
276 | mov al, 10 |
276 | mov al, 10 |
277 | mul dl |
277 | mul dl |
278 | add al, dh |
278 | add al, dh |
279 | mov dl, al |
279 | mov dl, al |
280 | lodsb |
280 | lodsb |
281 | cmp al, '.' |
281 | cmp al, '.' |
282 | je ipNext |
282 | je ipNext |
283 | cmp al, ' ' |
283 | cmp al, ' ' |
284 | je ipNext |
284 | je ipNext |
285 | mov dh, al |
285 | mov dh, al |
286 | sub dh, '0' |
286 | sub dh, '0' |
287 | mov al, 10 |
287 | mov al, 10 |
288 | mul dl |
288 | mul dl |
289 | add al, dh |
289 | add al, dh |
290 | mov dl, al |
290 | mov dl, al |
291 | lodsb |
291 | lodsb |
292 | 292 | ||
293 | ipNext: |
293 | ipNext: |
294 | mov [edi], dl |
294 | mov [edi], dl |
295 | inc edi |
295 | inc edi |
296 | mov dl, 0 |
296 | mov dl, 0 |
297 | loop td003 |
297 | loop td003 |
298 | 298 | ||
299 | ret |
299 | ret |
300 | 300 | ||
301 | 301 | ||
302 | 302 | ||
303 | ;*************************************************************************** |
303 | ;*************************************************************************** |
304 | ; Function |
304 | ; Function |
305 | ; copyFromRemote |
305 | ; copyFromRemote |
306 | ; |
306 | ; |
307 | ; Description |
307 | ; Description |
308 | ; |
308 | ; |
309 | ;*************************************************************************** |
309 | ;*************************************************************************** |
310 | copyFromRemote: |
310 | copyFromRemote: |
311 | xor eax, eax |
311 | xor eax, eax |
312 | mov [filesize], eax |
312 | mov [filesize], eax |
313 | mov eax, I_END + 512 ; This is the point where the file buffer is |
313 | mov eax, I_END + 512 ; This is the point where the file buffer is |
314 | mov [fileposition], eax |
314 | mov [fileposition], eax |
315 | 315 | ||
316 | ; Get a random # for the local socket port # |
316 | ; Get a random # for the local socket port # |
317 | mov eax, 3 |
317 | mov eax, 3 |
318 | int 0x40 |
318 | int 0x40 |
319 | mov ecx, eax |
319 | mov ecx, eax |
320 | shr ecx, 8 ; Set up the local port # with a random # |
320 | shr ecx, 8 ; Set up the local port # with a random # |
321 | 321 | ||
322 | ; open socket |
322 | ; open socket |
323 | mov eax, 53 |
323 | mov eax, 53 |
324 | mov ebx, 0 |
324 | mov ebx, 0 |
325 | mov edx, 69 ; remote port |
325 | mov edx, 69 ; remote port |
326 | mov esi, [tftp_IP] ; remote IP ( in intenet format ) |
326 | mov esi, [tftp_IP] ; remote IP ( in intenet format ) |
327 | int 0x40 |
327 | int 0x40 |
328 | 328 | ||
329 | mov [socketNum], eax |
329 | mov [socketNum], eax |
330 | 330 | ||
331 | ; make sure there is no data in the socket - there shouldn't be.. |
331 | ; make sure there is no data in the socket - there shouldn't be.. |
332 | 332 | ||
333 | cfr001: |
333 | cfr001: |
334 | mov eax, 53 |
334 | mov eax, 53 |
335 | mov ebx, 3 |
335 | mov ebx, 3 |
336 | mov ecx, [socketNum] |
336 | mov ecx, [socketNum] |
337 | int 0x40 ; read byte |
337 | int 0x40 ; read byte |
338 | 338 | ||
339 | mov eax, 53 |
339 | mov eax, 53 |
340 | mov ebx, 2 |
340 | mov ebx, 2 |
341 | mov ecx, [socketNum] |
341 | mov ecx, [socketNum] |
342 | int 0x40 ; any more data? |
342 | int 0x40 ; any more data? |
343 | 343 | ||
344 | cmp eax, 0 |
344 | cmp eax, 0 |
345 | jne cfr001 ; yes, so get it |
345 | jne cfr001 ; yes, so get it |
346 | 346 | ||
347 | ; Now, request the file |
347 | ; Now, request the file |
348 | mov eax, 53 |
348 | mov eax, 53 |
349 | mov ebx, 4 |
349 | mov ebx, 4 |
350 | mov ecx, [socketNum] |
350 | mov ecx, [socketNum] |
351 | mov edx, [tftp_len] |
351 | mov edx, [tftp_len] |
352 | mov esi, tftp_filename |
352 | mov esi, tftp_filename |
353 | int 0x40 |
353 | int 0x40 |
354 | 354 | ||
355 | cfr002: |
355 | cfr002: |
356 | mov eax,10 ; wait here for event |
356 | mov eax,10 ; wait here for event |
357 | mcall |
357 | mcall |
358 | 358 | ||
359 | cmp eax,1 ; redraw request ? |
359 | cmp eax,1 ; redraw request ? |
360 | je cfr003 |
360 | je cfr003 |
361 | cmp eax,2 ; key in buffer ? |
361 | cmp eax,2 ; key in buffer ? |
362 | je cfr004 |
362 | je cfr004 |
363 | cmp eax,3 ; button in buffer ? |
363 | cmp eax,3 ; button in buffer ? |
364 | je cfr005 |
364 | je cfr005 |
365 | 365 | ||
366 | ; Any data to fetch? |
366 | ; Any data to fetch? |
367 | mov eax, 53 |
367 | mov eax, 53 |
368 | mov ebx, 2 |
368 | mov ebx, 2 |
369 | mov ecx, [socketNum] |
369 | mov ecx, [socketNum] |
370 | int 0x40 |
370 | int 0x40 |
371 | 371 | ||
372 | cmp eax, 0 |
372 | cmp eax, 0 |
373 | je cfr002 |
373 | je cfr002 |
374 | 374 | ||
375 | push eax ; eax holds # chars |
375 | push eax ; eax holds # chars |
376 | 376 | ||
377 | ; Update the text on the display - once |
377 | ; Update the text on the display - once |
378 | mov eax, [prompt] |
378 | mov eax, [prompt] |
379 | cmp eax, p3 |
379 | cmp eax, p3 |
380 | je cfr008 |
380 | je cfr008 |
381 | mov dword [prompt], p3 |
381 | mov dword [prompt], p3 |
382 | mov dword [promptlen], p3len - p3 |
382 | mov dword [promptlen], p3len - p3 |
383 | call draw_window ; |
383 | call draw_window ; |
384 | 384 | ||
385 | cfr008: |
385 | cfr008: |
386 | ; we have data - this will be a tftp frame |
386 | ; we have data - this will be a tftp frame |
387 | 387 | ||
388 | ; read first two bytes - opcode |
388 | ; read first two bytes - opcode |
389 | mov eax, 53 |
389 | mov eax, 53 |
390 | mov ebx, 3 |
390 | mov ebx, 3 |
391 | mov ecx, [socketNum] |
391 | mov ecx, [socketNum] |
392 | int 0x40 ; read byte |
392 | int 0x40 ; read byte |
393 | 393 | ||
394 | mov eax, 53 |
394 | mov eax, 53 |
395 | mov ebx, 3 |
395 | mov ebx, 3 |
396 | mov ecx, [socketNum] |
396 | mov ecx, [socketNum] |
397 | int 0x40 ; read byte |
397 | int 0x40 ; read byte |
398 | 398 | ||
399 | pop eax |
399 | pop eax |
400 | ; bl holds tftp opcode. Can only be 3 (data) or 5 ( error ) |
400 | ; bl holds tftp opcode. Can only be 3 (data) or 5 ( error ) |
401 | 401 | ||
402 | cmp bl, 3 |
402 | cmp bl, 3 |
403 | jne cfrerr |
403 | jne cfrerr |
404 | 404 | ||
405 | push eax |
405 | push eax |
406 | 406 | ||
407 | ; do data stuff. Read block #. Read data. Send Ack. |
407 | ; do data stuff. Read block #. Read data. Send Ack. |
408 | mov eax, 53 |
408 | mov eax, 53 |
409 | mov ebx, 3 |
409 | mov ebx, 3 |
410 | mov ecx, [socketNum] |
410 | mov ecx, [socketNum] |
411 | int 0x40 ; read byte |
411 | int 0x40 ; read byte |
412 | 412 | ||
413 | mov [blockNumber], bl |
413 | mov [blockNumber], bl |
414 | 414 | ||
415 | mov eax, 53 |
415 | mov eax, 53 |
416 | mov ebx, 3 |
416 | mov ebx, 3 |
417 | mov ecx, [socketNum] |
417 | mov ecx, [socketNum] |
418 | int 0x40 ; read byte |
418 | int 0x40 ; read byte |
419 | 419 | ||
420 | mov [blockNumber+1], bl |
420 | mov [blockNumber+1], bl |
421 | 421 | ||
422 | cfr007: |
422 | cfr007: |
423 | 423 | ||
424 | mov eax, 53 |
424 | mov eax, 53 |
425 | mov ebx, 2 |
425 | mov ebx, 2 |
426 | mov ecx, [socketNum] |
426 | mov ecx, [socketNum] |
427 | mcall ; any more data? |
427 | mcall ; any more data? |
428 | 428 | ||
429 | cmp eax, 0 |
429 | cmp eax, 0 |
430 | je no_more_data ; no |
430 | je no_more_data ; no |
431 | 431 | ||
432 | mov eax, 53 |
432 | mov eax, 53 |
433 | mov ebx, 3 |
433 | mov ebx, 3 |
434 | mov ecx, [socketNum] |
434 | mov ecx, [socketNum] |
435 | mcall ; read byte |
435 | mcall ; read byte |
436 | 436 | ||
437 | mov esi, [fileposition] |
437 | mov esi, [fileposition] |
438 | mov [esi], bl |
438 | mov [esi], bl |
439 | inc dword [fileposition] |
439 | inc dword [fileposition] |
440 | inc dword [filesize] |
440 | inc dword [filesize] |
441 | 441 | ||
442 | jmp cfr007 |
442 | jmp cfr007 |
443 | 443 | ||
444 | no_more_data: |
444 | no_more_data: |
445 | 445 | ||
446 | ; write the block number into the ack |
446 | ; write the block number into the ack |
447 | mov al, [blockNumber] |
447 | mov al, [blockNumber] |
448 | mov [ack + 2], al |
448 | mov [ack + 2], al |
449 | 449 | ||
450 | mov al, [blockNumber+1] |
450 | mov al, [blockNumber+1] |
451 | mov [ack + 3], al |
451 | mov [ack + 3], al |
452 | 452 | ||
453 | ; send an 'ack' |
453 | ; send an 'ack' |
454 | mov eax, 53 |
454 | mov eax, 53 |
455 | mov ebx, 4 |
455 | mov ebx, 4 |
456 | mov ecx, [socketNum] |
456 | mov ecx, [socketNum] |
457 | mov edx, ackLen - ack |
457 | mov edx, ackLen - ack |
458 | mov esi, ack |
458 | mov esi, ack |
459 | int 0x40 |
459 | int 0x40 |
460 | 460 | ||
461 | ; If # of chars in the frame is less that 516, |
461 | ; If # of chars in the frame is less that 516, |
462 | ; this frame is the last |
462 | ; this frame is the last |
463 | pop eax |
463 | pop eax |
464 | cmp eax, 516 |
464 | cmp eax, 516 |
465 | je cfr002 |
465 | je cfr002 |
466 | 466 | ||
467 | ; Write the file |
467 | ; Write the file |
468 | mov eax, 33 |
468 | mov eax, 33 |
469 | mov ebx, source |
469 | mov ebx, source |
470 | mov edx, [filesize] |
470 | mov edx, [filesize] |
471 | mov ecx, I_END + 512 |
471 | mov ecx, I_END + 512 |
472 | mov esi, 0 |
472 | mov esi, 0 |
473 | mcall |
473 | mcall |
474 | 474 | ||
475 | jmp cfrexit |
475 | jmp cfrexit |
476 | 476 | ||
477 | cfrerr: |
477 | cfrerr: |
478 | ; simple implementation on error - just read all data, and return |
478 | ; simple implementation on error - just read all data, and return |
479 | mov eax, 53 |
479 | mov eax, 53 |
480 | mov ebx, 3 |
480 | mov ebx, 3 |
481 | mov ecx, [socketNum] |
481 | mov ecx, [socketNum] |
482 | int 0x40 ; read byte |
482 | int 0x40 ; read byte |
483 | 483 | ||
484 | mov eax, 53 |
484 | mov eax, 53 |
485 | mov ebx, 2 |
485 | mov ebx, 2 |
486 | mov ecx, [socketNum] |
486 | mov ecx, [socketNum] |
487 | int 0x40 ; any more data? |
487 | int 0x40 ; any more data? |
488 | 488 | ||
489 | cmp eax, 0 |
489 | cmp eax, 0 |
490 | jne cfrerr ; yes, so get it |
490 | jne cfrerr ; yes, so get it |
491 | 491 | ||
492 | jmp cfr006 ; close socket and close app |
492 | jmp cfr006 ; close socket and close app |
493 | 493 | ||
494 | cfr003: ; redraw request |
494 | cfr003: ; redraw request |
495 | call draw_window |
495 | call draw_window |
496 | jmp cfr002 |
496 | jmp cfr002 |
497 | 497 | ||
498 | cfr004: ; key pressed |
498 | cfr004: ; key pressed |
499 | mov eax,2 ; just read it and ignore |
499 | mov eax,2 ; just read it and ignore |
500 | mcall |
500 | mcall |
501 | jmp cfr002 |
501 | jmp cfr002 |
502 | 502 | ||
503 | cfr005: ; button |
503 | cfr005: ; button |
504 | mov eax,17 ; get id |
504 | mov eax,17 ; get id |
505 | mcall |
505 | mcall |
506 | 506 | ||
507 | cmp ah,1 ; button id=1 ? |
507 | cmp ah,1 ; button id=1 ? |
508 | jne cfr002 ; If not, ignore. |
508 | jne cfr002 ; If not, ignore. |
509 | 509 | ||
510 | cfr006: |
510 | cfr006: |
511 | ; close socket |
511 | ; close socket |
512 | mov eax, 53 |
512 | mov eax, 53 |
513 | mov ebx, 1 |
513 | mov ebx, 1 |
514 | mov ecx, [socketNum] |
514 | mov ecx, [socketNum] |
515 | int 0x40 |
515 | int 0x40 |
516 | 516 | ||
517 | mov [socketNum], dword 0 |
517 | mov [socketNum], dword 0 |
518 | 518 | ||
519 | mov eax,-1 ; close this program |
519 | mov eax,-1 ; close this program |
520 | mcall |
520 | mcall |
521 | 521 | ||
522 | jmp $ |
522 | jmp $ |
523 | 523 | ||
524 | cfrexit: |
524 | cfrexit: |
525 | ; close socket |
525 | ; close socket |
526 | mov eax, 53 |
526 | mov eax, 53 |
527 | mov ebx, 1 |
527 | mov ebx, 1 |
528 | mov ecx, [socketNum] |
528 | mov ecx, [socketNum] |
529 | int 0x40 |
529 | int 0x40 |
530 | 530 | ||
531 | mov [socketNum], dword 0 |
531 | mov [socketNum], dword 0 |
532 | 532 | ||
533 | mov dword [prompt], p4 |
533 | mov dword [prompt], p4 |
534 | mov dword [promptlen], p4len - p4 |
534 | mov dword [promptlen], p4len - p4 |
535 | call draw_window ; |
535 | call draw_window ; |
536 | 536 | ||
537 | ret |
537 | ret |
538 | 538 | ||
539 | 539 | ||
540 | 540 | ||
541 | ;*************************************************************************** |
541 | ;*************************************************************************** |
542 | ; Function |
542 | ; Function |
543 | ; copyToRemote |
543 | ; copyToRemote |
544 | ; |
544 | ; |
545 | ; Description |
545 | ; Description |
546 | ; |
546 | ; |
547 | ;*************************************************************************** |
547 | ;*************************************************************************** |
548 | copyToRemote: |
548 | copyToRemote: |
549 | mov eax,6 ; Read file from floppy (image) |
549 | mov eax,6 ; Read file from floppy (image) |
550 | mov ebx,source |
550 | mov ebx,source |
551 | mov ecx,0 |
551 | mov ecx,0 |
552 | mov edx,0xffffffff |
552 | mov edx,0xffffffff |
553 | mov esi,I_END + 512 |
553 | mov esi,I_END + 512 |
554 | int 0x40 |
554 | int 0x40 |
555 | 555 | ||
556 | cmp eax,0xffffffff |
556 | cmp eax,0xffffffff |
557 | jnz filefound |
557 | jnz filefound |
558 | 558 | ||
559 | mov dword [prompt], p6 |
559 | mov dword [prompt], p6 |
560 | mov dword [promptlen], p6len - p6 |
560 | mov dword [promptlen], p6len - p6 |
561 | call draw_window ; |
561 | call draw_window ; |
562 | jmp ctr_exit |
562 | jmp ctr_exit |
563 | 563 | ||
564 | filefound: |
564 | filefound: |
565 | mov [filesize], eax |
565 | mov [filesize], eax |
566 | 566 | ||
567 | ; First, set up the file pointers |
567 | ; First, set up the file pointers |
568 | mov eax, 0x01000300 |
568 | mov eax, 0x01000300 |
569 | mov [blockBuffer], eax ; This makes sure our TFTP header is valid |
569 | mov [blockBuffer], eax ; This makes sure our TFTP header is valid |
570 | 570 | ||
571 | mov eax, I_END + 512 ; This is the point where the file buffer is |
571 | mov eax, I_END + 512 ; This is the point where the file buffer is |
572 | mov [fileposition], eax |
572 | mov [fileposition], eax |
573 | 573 | ||
574 | mov eax, [filesize] |
574 | mov eax, [filesize] |
575 | cmp eax, 512 |
575 | cmp eax, 512 |
576 | jb ctr000 |
576 | jb ctr000 |
577 | mov eax, 512 |
577 | mov eax, 512 |
578 | ctr000: |
578 | ctr000: |
579 | mov [fileblocksize], ax |
579 | mov [fileblocksize], ax |
580 | 580 | ||
581 | ; Get a random # for the local socket port # |
581 | ; Get a random # for the local socket port # |
582 | mov eax, 3 |
582 | mov eax, 3 |
583 | int 0x40 |
583 | int 0x40 |
584 | mov ecx, eax |
584 | mov ecx, eax |
585 | shr ecx, 8 ; Set up the local port # with a random # |
585 | shr ecx, 8 ; Set up the local port # with a random # |
586 | 586 | ||
587 | ; First, open socket |
587 | ; First, open socket |
588 | mov eax, 53 |
588 | mov eax, 53 |
589 | mov ebx, 0 |
589 | mov ebx, 0 |
590 | mov edx, 69 ; remote port |
590 | mov edx, 69 ; remote port |
591 | mov esi, [tftp_IP] |
591 | mov esi, [tftp_IP] |
592 | int 0x40 |
592 | int 0x40 |
593 | 593 | ||
594 | mov [socketNum], eax |
594 | mov [socketNum], eax |
595 | 595 | ||
596 | ; write to socket ( request write file ) |
596 | ; write to socket ( request write file ) |
597 | mov eax, 53 |
597 | mov eax, 53 |
598 | mov ebx, 4 |
598 | mov ebx, 4 |
599 | mov ecx, [socketNum] |
599 | mov ecx, [socketNum] |
600 | mov edx, [tftp_len] |
600 | mov edx, [tftp_len] |
601 | mov esi, tftp_filename |
601 | mov esi, tftp_filename |
602 | int 0x40 |
602 | int 0x40 |
603 | 603 | ||
604 | ; now, we wait for |
604 | ; now, we wait for |
605 | ; UI redraw |
605 | ; UI redraw |
606 | ; UI close |
606 | ; UI close |
607 | ; or data from remote |
607 | ; or data from remote |
608 | 608 | ||
609 | ctr001: |
609 | ctr001: |
610 | mov eax,10 ; wait here for event |
610 | mov eax,10 ; wait here for event |
611 | int 0x40 |
611 | int 0x40 |
612 | 612 | ||
613 | cmp eax,1 ; redraw request ? |
613 | cmp eax,1 ; redraw request ? |
614 | je ctr003 |
614 | je ctr003 |
615 | cmp eax,2 ; key in buffer ? |
615 | cmp eax,2 ; key in buffer ? |
616 | je ctr004 |
616 | je ctr004 |
617 | cmp eax,3 ; button in buffer ? |
617 | cmp eax,3 ; button in buffer ? |
618 | je ctr005 |
618 | je ctr005 |
619 | 619 | ||
620 | 620 | ||
621 | ; Any data in the UDP receive buffer? |
621 | ; Any data in the UDP receive buffer? |
622 | mov eax, 53 |
622 | mov eax, 53 |
623 | mov ebx, 2 |
623 | mov ebx, 2 |
624 | mov ecx, [socketNum] |
624 | mov ecx, [socketNum] |
625 | int 0x40 |
625 | int 0x40 |
626 | 626 | ||
627 | cmp eax, 0 |
627 | cmp eax, 0 |
628 | je ctr001 |
628 | je ctr001 |
629 | 629 | ||
630 | ; Update the text on the display - once |
630 | ; Update the text on the display - once |
631 | mov eax, [prompt] |
631 | mov eax, [prompt] |
632 | cmp eax, p2 |
632 | cmp eax, p2 |
633 | je ctr002 |
633 | je ctr002 |
634 | 634 | ||
635 | mov dword [prompt], p2 |
635 | mov dword [prompt], p2 |
636 | mov dword [promptlen], p2len - p2 |
636 | mov dword [promptlen], p2len - p2 |
637 | call draw_window ; |
637 | call draw_window ; |
638 | 638 | ||
639 | ; we have data - this will be the ack |
639 | ; we have data - this will be the ack |
640 | ctr002: |
640 | ctr002: |
641 | mov eax, 53 |
641 | mov eax, 53 |
642 | mov ebx, 3 |
642 | mov ebx, 3 |
643 | mov ecx, [socketNum] |
643 | mov ecx, [socketNum] |
644 | int 0x40 ; read byte - opcode |
644 | int 0x40 ; read byte - opcode |
645 | 645 | ||
646 | mov eax, 53 |
646 | mov eax, 53 |
647 | mov ebx, 3 |
647 | mov ebx, 3 |
648 | mov ecx, [socketNum] |
648 | mov ecx, [socketNum] |
649 | int 0x40 ; read byte - opcode |
649 | int 0x40 ; read byte - opcode |
650 | 650 | ||
651 | mov eax, 53 |
651 | mov eax, 53 |
652 | mov ebx, 3 |
652 | mov ebx, 3 |
653 | mov ecx, [socketNum] |
653 | mov ecx, [socketNum] |
654 | int 0x40 ; read byte - block (high byte) |
654 | int 0x40 ; read byte - block (high byte) |
655 | 655 | ||
656 | mov [blockNumber], bl |
656 | mov [blockNumber], bl |
657 | 657 | ||
658 | mov eax, 53 |
658 | mov eax, 53 |
659 | mov ebx, 3 |
659 | mov ebx, 3 |
660 | mov ecx, [socketNum] |
660 | mov ecx, [socketNum] |
661 | int 0x40 ; read byte - block (low byte ) |
661 | int 0x40 ; read byte - block (low byte ) |
662 | 662 | ||
663 | mov [blockNumber+1], bl |
663 | mov [blockNumber+1], bl |
664 | 664 | ||
665 | ctr0022: |
665 | ctr0022: |
666 | mov eax, 53 |
666 | mov eax, 53 |
667 | mov ebx, 3 |
667 | mov ebx, 3 |
668 | mov ecx, [socketNum] |
668 | mov ecx, [socketNum] |
669 | int 0x40 ; read byte (shouldn't have worked) |
669 | int 0x40 ; read byte (shouldn't have worked) |
670 | 670 | ||
671 | 671 | ||
672 | mov eax, 53 |
672 | mov eax, 53 |
673 | mov ebx, 2 |
673 | mov ebx, 2 |
674 | mov ecx, [socketNum] |
674 | mov ecx, [socketNum] |
675 | int 0x40 ; any more data? |
675 | int 0x40 ; any more data? |
676 | 676 | ||
677 | cmp eax, 0 |
677 | cmp eax, 0 |
678 | jne ctr0022 ; yes, so get it, and dump it |
678 | jne ctr0022 ; yes, so get it, and dump it |
679 | 679 | ||
680 | ; If the ack is 0, it is to the request |
680 | ; If the ack is 0, it is to the request |
681 | 681 | ||
682 | mov bx, [blockNumber] |
682 | mov bx, [blockNumber] |
683 | cmp bx, 0 |
683 | cmp bx, 0 |
684 | je txd |
684 | je txd |
685 | 685 | ||
686 | ; now, the ack should be one more than the current field - otherwise, resend |
686 | ; now, the ack should be one more than the current field - otherwise, resend |
687 | 687 | ||
688 | cmp bx, [blockBuffer+2] |
688 | cmp bx, [blockBuffer+2] |
689 | jne txre ; not the same, so send again |
689 | jne txre ; not the same, so send again |
690 | 690 | ||
691 | ; update the block number |
691 | ; update the block number |
692 | mov esi, blockBuffer + 3 |
692 | mov esi, blockBuffer + 3 |
693 | mov al, [esi] |
693 | mov al, [esi] |
694 | inc al |
694 | inc al |
695 | mov [esi], al |
695 | mov [esi], al |
696 | cmp al, 0 |
696 | cmp al, 0 |
697 | jne ctr008 |
697 | jne ctr008 |
698 | dec esi |
698 | dec esi |
699 | inc byte [esi] |
699 | inc byte [esi] |
700 | 700 | ||
701 | ctr008: |
701 | ctr008: |
702 | ; Move forward through the file |
702 | ; Move forward through the file |
703 | mov eax, [fileposition] |
703 | mov eax, [fileposition] |
704 | movzx ebx, word [fileblocksize] |
704 | movzx ebx, word [fileblocksize] |
705 | add eax, ebx |
705 | add eax, ebx |
706 | mov [fileposition], eax |
706 | mov [fileposition], eax |
707 | 707 | ||
708 | ; new .. |
708 | ; new .. |
709 | ; fs = 0 , fbs = 512 -> send with fbs = 0 |
709 | ; fs = 0 , fbs = 512 -> send with fbs = 0 |
710 | 710 | ||
711 | cmp [filesize],0 |
711 | cmp [filesize],0 |
712 | jne no_special_end |
712 | jne no_special_end |
713 | cmp [fileblocksize],512 |
713 | cmp [fileblocksize],512 |
714 | jne no_special_end |
714 | jne no_special_end |
715 | mov ax,0 |
715 | mov ax,0 |
716 | jmp ctr006 |
716 | jmp ctr006 |
717 | no_special_end: |
717 | no_special_end: |
718 | 718 | ||
719 | mov eax, [filesize] |
719 | mov eax, [filesize] |
720 | cmp eax, 0 |
720 | cmp eax, 0 |
721 | je ctr009 |
721 | je ctr009 |
722 | cmp eax, 512 |
722 | cmp eax, 512 |
723 | jb ctr006 |
723 | jb ctr006 |
724 | mov eax, 512 |
724 | mov eax, 512 |
725 | ctr006: |
725 | ctr006: |
726 | mov [fileblocksize], ax |
726 | mov [fileblocksize], ax |
727 | 727 | ||
728 | 728 | ||
729 | txd: |
729 | txd: |
730 | ; Readjust the file size variable ( before sending ) |
730 | ; Readjust the file size variable ( before sending ) |
731 | mov eax, [filesize] |
731 | mov eax, [filesize] |
732 | movzx ebx, word [fileblocksize] |
732 | movzx ebx, word [fileblocksize] |
733 | sub eax, ebx |
733 | sub eax, ebx |
734 | mov [filesize], eax |
734 | mov [filesize], eax |
735 | 735 | ||
736 | txre: |
736 | txre: |
737 | ; Copy the fragment of the file to the block buffer |
737 | ; Copy the fragment of the file to the block buffer |
738 | movzx ecx, word [fileblocksize] |
738 | movzx ecx, word [fileblocksize] |
739 | mov esi, [fileposition] |
739 | mov esi, [fileposition] |
740 | mov edi, I_END |
740 | mov edi, I_END |
741 | cld |
741 | cld |
742 | rep movsb |
742 | rep movsb |
743 | 743 | ||
744 | ; send the file data |
744 | ; send the file data |
745 | mov eax, 53 |
745 | mov eax, 53 |
746 | mov ebx, 4 |
746 | mov ebx, 4 |
747 | mov ecx, [socketNum] |
747 | mov ecx, [socketNum] |
748 | movzx edx, word [fileblocksize] |
748 | movzx edx, word [fileblocksize] |
749 | add edx, 4 |
749 | add edx, 4 |
750 | mov esi, blockBuffer |
750 | mov esi, blockBuffer |
751 | int 0x40 |
751 | int 0x40 |
752 | 752 | ||
753 | jmp ctr001 |
753 | jmp ctr001 |
754 | 754 | ||
755 | ctr003: ; redraw |
755 | ctr003: ; redraw |
756 | call draw_window |
756 | call draw_window |
757 | jmp ctr001 |
757 | jmp ctr001 |
758 | 758 | ||
759 | ctr004: ; key |
759 | ctr004: ; key |
760 | mov eax,2 ; just read it and ignore |
760 | mov eax,2 ; just read it and ignore |
761 | int 0x40 |
761 | int 0x40 |
762 | jmp ctr001 |
762 | jmp ctr001 |
763 | 763 | ||
764 | ctr005: ; button |
764 | ctr005: ; button |
765 | mov eax,17 ; get id |
765 | mov eax,17 ; get id |
766 | int 0x40 |
766 | int 0x40 |
767 | 767 | ||
768 | cmp ah,1 ; button id=1 ? |
768 | cmp ah,1 ; button id=1 ? |
769 | jne ctr001 |
769 | jne ctr001 |
770 | 770 | ||
771 | ; close socket |
771 | ; close socket |
772 | mov eax, 53 |
772 | mov eax, 53 |
773 | mov ebx, 1 |
773 | mov ebx, 1 |
774 | mov ecx, [socketNum] |
774 | mov ecx, [socketNum] |
775 | int 0x40 |
775 | int 0x40 |
776 | 776 | ||
777 | mov [socketNum], dword 0 |
777 | mov [socketNum], dword 0 |
778 | 778 | ||
779 | mov eax,-1 ; close this program |
779 | mov eax,-1 ; close this program |
780 | int 0x40 |
780 | int 0x40 |
781 | jmp $ |
781 | jmp $ |
782 | 782 | ||
783 | ctr009: |
783 | ctr009: |
784 | ; close socket |
784 | ; close socket |
785 | mov eax, 53 |
785 | mov eax, 53 |
786 | mov ebx, 1 |
786 | mov ebx, 1 |
787 | mov ecx, [socketNum] |
787 | mov ecx, [socketNum] |
788 | int 0x40 |
788 | int 0x40 |
789 | 789 | ||
790 | mov dword [prompt], p4 |
790 | mov dword [prompt], p4 |
791 | mov dword [promptlen], p4len - p4 |
791 | mov dword [promptlen], p4len - p4 |
792 | call draw_window ; |
792 | call draw_window ; |
793 | 793 | ||
794 | ctr_exit: |
794 | ctr_exit: |
795 | ret |
795 | ret |
796 | 796 | ||
797 | 797 | ||
798 | 798 | ||
799 | 799 | ||
800 | ; ********************************************* |
800 | ; ********************************************* |
801 | ; ******* WINDOW DEFINITIONS AND DRAW ******** |
801 | ; ******* WINDOW DEFINITIONS AND DRAW ******** |
802 | ; ********************************************* |
802 | ; ********************************************* |
803 | 803 | ||
804 | 804 | ||
805 | draw_window: |
805 | draw_window: |
806 | 806 | ||
807 | mov eax,12 ; function 12:tell os about windowdraw |
807 | mov eax,12 ; function 12:tell os about windowdraw |
808 | mov ebx,1 ; 1, start of draw |
808 | mov ebx,1 ; 1, start of draw |
809 | mcall |
809 | mcall |
810 | 810 | ||
811 | ; DRAW WINDOW |
811 | ; DRAW WINDOW |
812 | mov eax,0 ; function 0 : define and draw window |
812 | mov eax,0 ; function 0 : define and draw window |
813 | mov ebx,100*65536+230 ; [x start] *65536 + [x size] |
813 | mov ebx,100*65536+230 ; [x start] *65536 + [x size] |
814 | mov ecx,100*65536+170 ; [y start] *65536 + [y size] |
814 | mov ecx,100*65536+170 ; [y start] *65536 + [y size] |
815 | mov edx,0x13224466 ; color of work area RRGGBB |
815 | mov edx,0x14224466 ; color of work area RRGGBB |
816 | mov edi,title |
816 | mov edi,title |
817 | mcall |
817 | mcall |
818 | 818 | ||
819 | mov eax,8 ; COPY BUTTON |
819 | mov eax,8 ; COPY BUTTON |
820 | mov ebx,20*65536+190 |
820 | mov ebx,20*65536+190 |
821 | mov ecx,79*65536+15 |
821 | mov ecx,79*65536+15 |
822 | mov edx,2 |
822 | mov edx,2 |
823 | mov esi,0x557799 |
823 | mov esi,0x557799 |
824 | mcall |
824 | mcall |
825 | 825 | ||
826 | ; mov eax,8 ; DELETE BUTTON |
826 | ; mov eax,8 ; DELETE BUTTON |
827 | mov ebx,20*65536+190 |
827 | mov ebx,20*65536+190 |
828 | mov ecx,111*65536+15 |
828 | mov ecx,111*65536+15 |
829 | mov edx,3 |
829 | mov edx,3 |
830 | mcall |
830 | mcall |
831 | 831 | ||
832 | ; mov eax,8 |
832 | ; mov eax,8 |
833 | ; mov ebx,200*65536+10 |
833 | ; mov ebx,200*65536+10 |
834 | mov ecx,34*65536+10 |
834 | mov ecx,34*65536+10 |
835 | mov edx,4 |
835 | mov edx,4 |
836 | mcall |
836 | mcall |
837 | 837 | ||
838 | ; mov eax,8 |
838 | ; mov eax,8 |
839 | ; mov ebx,200*65536+10 |
839 | ; mov ebx,200*65536+10 |
840 | mov ecx,50*65536+10 |
840 | mov ecx,50*65536+10 |
841 | mov edx,5 |
841 | mov edx,5 |
842 | mcall |
842 | mcall |
843 | 843 | ||
844 | 844 | ||
845 | ; Copy the file name to the screen buffer |
845 | ; Copy the file name to the screen buffer |
846 | ; file name is same length as IP address, to |
846 | ; file name is same length as IP address, to |
847 | ; make the math easier later. |
847 | ; make the math easier later. |
848 | cld |
848 | cld |
849 | mov esi,source |
849 | mov esi,source |
850 | mov edi,text+13 |
850 | mov edi,text+13 |
851 | mov ecx,15 |
851 | mov ecx,15 |
852 | rep movsb |
852 | rep movsb |
853 | 853 | ||
854 | 854 | ||
855 | ; copy the IP address to the screen buffer |
855 | ; copy the IP address to the screen buffer |
856 | mov esi,destination |
856 | mov esi,destination |
857 | mov edi,text+40+13 |
857 | mov edi,text+40+13 |
858 | mov ecx,15 |
858 | mov ecx,15 |
859 | rep movsb |
859 | rep movsb |
860 | 860 | ||
861 | ; copy the prompt to the screen buffer |
861 | ; copy the prompt to the screen buffer |
862 | mov esi,[prompt] |
862 | mov esi,[prompt] |
863 | mov edi,text+280 |
863 | mov edi,text+280 |
864 | mov ecx,[promptlen] |
864 | mov ecx,[promptlen] |
865 | rep movsb |
865 | rep movsb |
866 | 866 | ||
867 | ; Re-draw the screen text |
867 | ; Re-draw the screen text |
868 | cld |
868 | cld |
869 | mov eax,4 |
869 | mov eax,4 |
870 | mov ebx,25*65536+35 ; draw info text with function 4 |
870 | mov ebx,25*65536+35 ; draw info text with function 4 |
871 | mov ecx,0xffffff |
871 | mov ecx,0xffffff |
872 | mov edx,text |
872 | mov edx,text |
873 | mov esi,40 |
873 | mov esi,40 |
874 | newline: |
874 | newline: |
875 | mcall |
875 | mcall |
876 | add ebx,16 |
876 | add ebx,16 |
877 | add edx,40 |
877 | add edx,40 |
878 | cmp [edx],byte 'x' |
878 | cmp [edx],byte 'x' |
879 | jnz newline |
879 | jnz newline |
880 | 880 | ||
881 | 881 | ||
882 | mov eax,12 ; function 12:tell os about windowdraw |
882 | mov eax,12 ; function 12:tell os about windowdraw |
883 | mov ebx,2 ; 2, end of draw |
883 | mov ebx,2 ; 2, end of draw |
884 | mcall |
884 | mcall |
885 | 885 | ||
886 | ret |
886 | ret |
887 | 887 | ||
888 | 888 | ||
889 | ; DATA AREA |
889 | ; DATA AREA |
890 | 890 | ||
891 | source db 'KERNEL.ASM ' |
891 | source db 'KERNEL.ASM ' |
892 | destination db '192.168.1.23 ' |
892 | destination db '192.168.1.23 ' |
893 | 893 | ||
894 | 894 | ||
895 | tftp_filename: times 15 + 9 db 0 |
895 | tftp_filename: times 15 + 9 db 0 |
896 | tftp_IP: dd 0 |
896 | tftp_IP: dd 0 |
897 | tftp_len: dd 0 |
897 | tftp_len: dd 0 |
898 | 898 | ||
899 | addr dd 0x0 |
899 | addr dd 0x0 |
900 | ya dd 0x0 |
900 | ya dd 0x0 |
901 | 901 | ||
902 | fileposition dd 0 ; Points to the current point in the file |
902 | fileposition dd 0 ; Points to the current point in the file |
903 | filesize dd 0 ; The number of bytes written / left to write |
903 | filesize dd 0 ; The number of bytes written / left to write |
904 | fileblocksize dw 0 ; The number of bytes to send in this frame |
904 | fileblocksize dw 0 ; The number of bytes to send in this frame |
905 | 905 | ||
906 | text: |
906 | text: |
907 | db 'SOURCE FILE: xxxxxxxxxxxxxxx ' |
907 | db 'SOURCE FILE: xxxxxxxxxxxxxxx ' |
908 | db 'HOST IP ADD: xxx.xxx.xxx.xxx ' |
908 | db 'HOST IP ADD: xxx.xxx.xxx.xxx ' |
909 | db ' ' |
909 | db ' ' |
910 | db ' COPY HOST -> LOCAL ' |
910 | db ' COPY HOST -> LOCAL ' |
911 | db ' ' |
911 | db ' ' |
912 | db ' COPY LOCAL -> HOST ' |
912 | db ' COPY LOCAL -> HOST ' |
913 | db ' ' |
913 | db ' ' |
914 | db ' ' |
914 | db ' ' |
915 | db 'x' ; <- END MARKER, DONT DELETE |
915 | db 'x' ; <- END MARKER, DONT DELETE |
916 | 916 | ||
917 | 917 | ||
918 | title db 'TFTP Client',0 |
918 | title db 'TFTP Client',0 |
919 | 919 | ||
920 | prompt: dd 0 |
920 | prompt: dd 0 |
921 | promptlen: dd 0 |
921 | promptlen: dd 0 |
922 | 922 | ||
923 | 923 | ||
924 | p1: db 'Waiting for Command' |
924 | p1: db 'Waiting for Command' |
925 | p1len: |
925 | p1len: |
926 | 926 | ||
927 | p2: db 'Sending File ' |
927 | p2: db 'Sending File ' |
928 | p2len: |
928 | p2len: |
929 | 929 | ||
930 | p3: db 'Receiving File ' |
930 | p3: db 'Receiving File ' |
931 | p3len: |
931 | p3len: |
932 | 932 | ||
933 | p4: db 'Tranfer Complete ' |
933 | p4: db 'Tranfer Complete ' |
934 | p4len: |
934 | p4len: |
935 | 935 | ||
936 | p5: db 'Contacting Host... ' |
936 | p5: db 'Contacting Host... ' |
937 | p5len: |
937 | p5len: |
938 | 938 | ||
939 | p6: db 'File not found. ' |
939 | p6: db 'File not found. ' |
940 | p6len: |
940 | p6len: |
941 | 941 | ||
942 | ack: |
942 | ack: |
943 | db 00,04,0,1 |
943 | db 00,04,0,1 |
944 | ackLen: |
944 | ackLen: |
945 | 945 | ||
946 | socketNum: |
946 | socketNum: |
947 | dd 0 |
947 | dd 0 |
948 | 948 | ||
949 | blockNumber: |
949 | blockNumber: |
950 | dw 0 |
950 | dw 0 |
951 | 951 | ||
952 | ; This must be the last part of the file, because the blockBuffer |
952 | ; This must be the last part of the file, because the blockBuffer |
953 | ; continues at I_END. |
953 | ; continues at I_END. |
954 | blockBuffer: |
954 | blockBuffer: |
955 | db 00, 03, 00, 01 |
955 | db 00, 03, 00, 01 |
956 | I_END:-> |
956 | I_END:-> |