Subversion Repositories Kolibri OS

Rev

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 661
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;
2
;
3
;    TERMINAL
3
;    TERMINAL
4
;
4
;
5
;    Compile with FASM for Menuet
5
;    Compile with FASM for Menuet
6
;
6
;
7
 
7
 
8
use32
8
use32
9
 org	0x0
9
 org    0x0
10
 db	'MENUET01'    ; header
10
 db     'MENUET01'    ; header
11
 dd	0x01	      ; header version
11
 dd     0x01          ; header version
12
 dd	START	      ; entry point
12
 dd     START         ; entry point
13
 dd	I_END	      ; image size
13
 dd     I_END         ; image size
14
 dd	I_END+0x10000 ; required memory
14
 dd     I_END+0x10000 ; required memory
15
 dd	I_END+0x10000 ; esp
15
 dd     I_END+0x10000 ; esp
16
 dd	0x0 , 0x0     ; I_Param , I_Path
16
 dd     0x0 , 0x0     ; I_Param , I_Path
17
 
17
 
18
 
18
 
19
include 'lang.inc'
19
include 'lang.inc'
20
include '..\..\..\macros.inc'
20
include 'macros.inc'
21
 
21
 
22
START:				; start of execution
22
START:                          ; start of execution
23
 
23
 
24
    ; Clear the screen memory
24
    ; Clear the screen memory
25
    mov     eax, '    '
25
    mov     eax, '    '
26
    mov     edi,text
26
    mov     edi,text
27
    mov     ecx,80*30 /4
27
    mov     ecx,80*30 /4
28
    cld
28
    cld
29
    rep     stosd
29
    rep     stosd
30
 
30
 
31
 
31
 
32
    call draw_window
32
    call draw_window
33
 
33
 
34
 
34
 
35
still:
35
still:
36
    ; check connection status
36
    ; check connection status
37
    mov  eax,53
37
    mov  eax,53
38
    mov  ebx,6
38
    mov  ebx,6
39
    mov  ecx,[socket]
39
    mov  ecx,[socket]
40
    mcall
40
    mcall
41
 
41
 
42
    mov     ebx, [socket_status]
42
    mov     ebx, [socket_status]
43
    mov     [socket_status], eax
43
    mov     [socket_status], eax
44
 
44
 
45
    cmp     eax, ebx
45
    cmp     eax, ebx
46
    je	    waitev
46
    je      waitev
47
 
47
 
48
red:
48
red:
49
    call    draw_window
49
    call    draw_window
50
 
50
 
51
waitev:
51
waitev:
52
    mov  eax,23 		; wait here for event
52
    mov  eax,23                 ; wait here for event
53
    mov  ebx,20
53
    mov  ebx,20
54
    mcall
54
    mcall
55
 
55
 
56
    cmp  eax,1			; redraw request ?
56
    cmp  eax,1                  ; redraw request ?
57
    je	 red
57
    je   red
58
    cmp  eax,2			; key in buffer ?
58
    cmp  eax,2                  ; key in buffer ?
59
    je	 key
59
    je   key
60
    cmp  eax,3			; button in buffer ?
60
    cmp  eax,3                  ; button in buffer ?
61
    je	 button
61
    je   button
62
 
62
 
63
    ; any data from the socket?
63
    ; any data from the socket?
64
 
64
 
65
    mov     eax, 53
65
    mov     eax, 53
66
    mov     ebx, 2
66
    mov     ebx, 2
67
    mov     ecx, [socket]
67
    mov     ecx, [socket]
68
    mcall
68
    mcall
69
    cmp     eax, 0
69
    cmp     eax, 0
70
    jne      read_input
70
    jne      read_input
71
 
71
 
72
    jmp  still
72
    jmp  still
73
 
73
 
74
 
74
 
75
read_input:
75
read_input:
76
 
76
 
77
    push ecx
77
    push ecx
78
    mov     eax, 53
78
    mov     eax, 53
79
    mov     ebx, 3
79
    mov     ebx, 3
80
    mov     ecx, [socket]
80
    mov     ecx, [socket]
81
    mcall
81
    mcall
82
    pop  ecx
82
    pop  ecx
83
 
83
 
84
    call    handle_data
84
    call    handle_data
85
 
85
 
86
    push    ecx
86
    push    ecx
87
    mov     eax, 53
87
    mov     eax, 53
88
    mov     ebx, 2
88
    mov     ebx, 2
89
    mov     ecx, [socket]
89
    mov     ecx, [socket]
90
    mcall
90
    mcall
91
    pop     ecx
91
    pop     ecx
92
    cmp     eax, 0
92
    cmp     eax, 0
93
 
93
 
94
 
94
 
95
    jne   read_input
95
    jne   read_input
96
    call draw_text
96
    call draw_text
97
    jmp  still
97
    jmp  still
98
 
98
 
99
 
99
 
100
 
100
 
101
handle_data:
101
handle_data:
102
    ; Telnet servers will want to negotiate options about our terminal window
102
    ; Telnet servers will want to negotiate options about our terminal window
103
    ; just reject them all.
103
    ; just reject them all.
104
    ; Telnet options start with the byte 0xff and are 3 bytes long.
104
    ; Telnet options start with the byte 0xff and are 3 bytes long.
105
 
105
 
106
    mov     al, [telnetstate]
106
    mov     al, [telnetstate]
107
    cmp     al, 0
107
    cmp     al, 0
108
    je	    state0
108
    je      state0
109
    cmp     al, 1
109
    cmp     al, 1
110
    je	    state1
110
    je      state1
111
    cmp     al, 2
111
    cmp     al, 2
112
    je	    state2
112
    je      state2
113
    jmp     hd001
113
    jmp     hd001
114
 
114
 
115
state0:
115
state0:
116
    cmp     bl, 255
116
    cmp     bl, 255
117
    jne     hd001
117
    jne     hd001
118
    mov     al, 1
118
    mov     al, 1
119
    mov     [telnetstate], al
119
    mov     [telnetstate], al
120
    ret
120
    ret
121
 
121
 
122
state1:
122
state1:
123
    mov     al, 2
123
    mov     al, 2
124
    mov     [telnetstate], al
124
    mov     [telnetstate], al
125
    ret
125
    ret
126
 
126
 
127
state2:
127
state2:
128
    mov     al, 0
128
    mov     al, 0
129
    mov     [telnetstate], al
129
    mov     [telnetstate], al
130
    mov     [telnetrep+2], bl
130
    mov     [telnetrep+2], bl
131
 
131
 
132
    mov     edx, 3
132
    mov     edx, 3
133
    mov     eax,53
133
    mov     eax,53
134
    mov     ebx,7
134
    mov     ebx,7
135
    mov     ecx,[socket]
135
    mov     ecx,[socket]
136
    mov     esi, telnetrep
136
    mov     esi, telnetrep
137
    mcall
137
    mcall
138
    ret
138
    ret
139
 
139
 
140
hd001:
140
hd001:
141
    cmp  bl,13				; BEGINNING OF LINE
141
    cmp  bl,13                          ; BEGINNING OF LINE
142
    jne  nobol
142
    jne  nobol
143
    mov  ecx,[pos]
143
    mov  ecx,[pos]
144
    add  ecx,1
144
    add  ecx,1
145
  boll1:
145
  boll1:
146
    sub  ecx,1
146
    sub  ecx,1
147
    mov  eax,ecx
147
    mov  eax,ecx
148
    xor  edx,edx
148
    xor  edx,edx
149
    mov  ebx,80
149
    mov  ebx,80
150
    div  ebx
150
    div  ebx
151
    cmp  edx,0
151
    cmp  edx,0
152
    jne  boll1
152
    jne  boll1
153
    mov  [pos],ecx
153
    mov  [pos],ecx
154
    jmp  newdata
154
    jmp  newdata
155
  nobol:
155
  nobol:
156
 
156
 
157
    cmp  bl,10				  ; LINE DOWN
157
    cmp  bl,10                            ; LINE DOWN
158
    jne  nolf
158
    jne  nolf
159
   addx1:
159
   addx1:
160
    add  [pos],dword 1
160
    add  [pos],dword 1
161
    mov  eax,[pos]
161
    mov  eax,[pos]
162
    xor  edx,edx
162
    xor  edx,edx
163
    mov  ecx,80
163
    mov  ecx,80
164
    div  ecx
164
    div  ecx
165
    cmp  edx,0
165
    cmp  edx,0
166
    jnz  addx1
166
    jnz  addx1
167
    mov  eax,[pos]
167
    mov  eax,[pos]
168
    jmp  cm1
168
    jmp  cm1
169
  nolf:
169
  nolf:
170
 
170
 
171
    cmp  bl,8				 ; BACKSPACE
171
    cmp  bl,8                            ; BACKSPACE
172
    jne  nobasp
172
    jne  nobasp
173
    mov  eax,[pos]
173
    mov  eax,[pos]
174
    dec  eax
174
    dec  eax
175
    mov  [pos],eax
175
    mov  [pos],eax
176
    mov  [eax+text],byte 32
176
    mov  [eax+text],byte 32
177
    mov  [eax+text+60*80],byte 0
177
    mov  [eax+text+60*80],byte 0
178
    jmp  newdata
178
    jmp  newdata
179
   nobasp:
179
   nobasp:
180
 
180
 
181
    cmp  bl,15				 ; CHARACTER
181
    cmp  bl,15                           ; CHARACTER
182
    jbe  newdata
182
    jbe  newdata
183
    mov  eax,[pos]
183
    mov  eax,[pos]
184
    mov  [eax+text],bl
184
    mov  [eax+text],bl
185
    mov  eax,[pos]
185
    mov  eax,[pos]
186
    add  eax,1
186
    add  eax,1
187
  cm1:
187
  cm1:
188
    mov  ebx,[scroll+4]
188
    mov  ebx,[scroll+4]
189
    imul ebx,80
189
    imul ebx,80
190
    cmp  eax,ebx
190
    cmp  eax,ebx
191
    jb	 noeaxz
191
    jb   noeaxz
192
    mov  esi,text+80
192
    mov  esi,text+80
193
    mov  edi,text
193
    mov  edi,text
194
    mov  ecx,ebx
194
    mov  ecx,ebx
195
    cld
195
    cld
196
    rep  movsb
196
    rep  movsb
197
    mov  eax,ebx
197
    mov  eax,ebx
198
    sub  eax,80
198
    sub  eax,80
199
  noeaxz:
199
  noeaxz:
200
    mov  [pos],eax
200
    mov  [pos],eax
201
  newdata:
201
  newdata:
202
    ret
202
    ret
203
 
203
 
204
  key:				; KEY
204
  key:                          ; KEY
205
    mov  eax,2			; send to modem
205
    mov  eax,2                  ; send to modem
206
    mcall
206
    mcall
207
 
207
 
208
    mov     ebx, [socket_status]
208
    mov     ebx, [socket_status]
209
    cmp     ebx, 4		; connection open?
209
    cmp     ebx, 4              ; connection open?
210
    jne     still		; no, so ignore key
210
    jne     still               ; no, so ignore key
211
 
211
 
212
    shr  eax,8
212
    shr  eax,8
213
    cmp  eax,178		; ARROW KEYS
213
    cmp  eax,178                ; ARROW KEYS
214
    jne  noaup
214
    jne  noaup
215
    mov  al,'A'
215
    mov  al,'A'
216
    call arrow
216
    call arrow
217
    jmp  still
217
    jmp  still
218
  noaup:
218
  noaup:
219
    cmp  eax,177
219
    cmp  eax,177
220
    jne  noadown
220
    jne  noadown
221
    mov  al,'B'
221
    mov  al,'B'
222
    call arrow
222
    call arrow
223
    jmp  still
223
    jmp  still
224
  noadown:
224
  noadown:
225
    cmp  eax,179
225
    cmp  eax,179
226
    jne  noaright
226
    jne  noaright
227
    mov  al,'C'
227
    mov  al,'C'
228
    call arrow
228
    call arrow
229
    jmp  still
229
    jmp  still
230
  noaright:
230
  noaright:
231
    cmp  eax,176
231
    cmp  eax,176
232
    jne  noaleft
232
    jne  noaleft
233
    mov  al,'D'
233
    mov  al,'D'
234
    call arrow
234
    call arrow
235
    jmp  still
235
    jmp  still
236
  noaleft:
236
  noaleft:
237
  modem_out:
237
  modem_out:
238
 
238
 
239
    call    to_modem
239
    call    to_modem
240
 
240
 
241
    jmp  still
241
    jmp  still
242
 
242
 
243
  button:			; BUTTON
243
  button:                       ; BUTTON
244
    mov  eax,17
244
    mov  eax,17
245
    mcall
245
    mcall
246
    cmp  ah,1			; CLOSE PROGRAM
246
    cmp  ah,1                   ; CLOSE PROGRAM
247
    jne  noclose
247
    jne  noclose
248
 
248
 
249
    mov  eax,53
249
    mov  eax,53
250
    mov  ebx,8
250
    mov  ebx,8
251
    mov  ecx,[socket]
251
    mov  ecx,[socket]
252
    mcall
252
    mcall
253
 
253
 
254
     or   eax,-1
254
     or   eax,-1
255
     mcall
255
     mcall
256
  noclose:
256
  noclose:
257
    cmp     ah, 2		; Set IP
257
    cmp     ah, 2               ; Set IP
258
    jne     notip
258
    jne     notip
259
 
259
 
260
    mov  [string_x], dword 78
260
    mov  [string_x], dword 78
261
    mov  [string_y], dword 276
261
    mov  [string_y], dword 276
262
    mov  [string_length], dword 15
262
    mov  [string_length], dword 15
263
    call read_string
263
    call read_string
264
    mov   esi,string-1
264
    mov   esi,string-1
265
    mov   edi,ip_address
265
    mov   edi,ip_address
266
    xor   eax,eax
266
    xor   eax,eax
267
   ip1:
267
   ip1:
268
    inc   esi
268
    inc   esi
269
    cmp   [esi],byte '0'
269
    cmp   [esi],byte '0'
270
    jb	  ip2
270
    jb    ip2
271
    cmp   [esi],byte '9'
271
    cmp   [esi],byte '9'
272
    jg	  ip2
272
    jg    ip2
273
    imul  eax,10
273
    imul  eax,10
274
    movzx ebx,byte [esi]
274
    movzx ebx,byte [esi]
275
    sub   ebx,48
275
    sub   ebx,48
276
    add   eax,ebx
276
    add   eax,ebx
277
    jmp   ip1
277
    jmp   ip1
278
   ip2:
278
   ip2:
279
    mov   [edi],al
279
    mov   [edi],al
280
    xor   eax,eax
280
    xor   eax,eax
281
    inc   edi
281
    inc   edi
282
    cmp   edi,ip_address+3
282
    cmp   edi,ip_address+3
283
    jbe   ip1
283
    jbe   ip1
284
    call draw_window
284
    call draw_window
285
 
285
 
286
 
286
 
287
    jmp     still
287
    jmp     still
288
 
288
 
289
notip:
289
notip:
290
    cmp     ah, 3		; set port
290
    cmp     ah, 3               ; set port
291
    jne     notport
291
    jne     notport
292
 
292
 
293
    mov  [string_x], dword 215
293
    mov  [string_x], dword 215
294
    mov  [string_y], dword 276
294
    mov  [string_y], dword 276
295
    mov  [string_length], dword 4
295
    mov  [string_length], dword 4
296
    call read_string
296
    call read_string
297
    mov   esi,string-1
297
    mov   esi,string-1
298
    mov   edi,port
298
    mov   edi,port
299
    xor   eax,eax
299
    xor   eax,eax
300
   ip11:
300
   ip11:
301
    inc   esi
301
    inc   esi
302
    cmp   [esi],byte '0'
302
    cmp   [esi],byte '0'
303
    jb	  ip21
303
    jb    ip21
304
    cmp   [esi],byte '9'
304
    cmp   [esi],byte '9'
305
    jg	  ip21
305
    jg    ip21
306
    imul  eax,10
306
    imul  eax,10
307
    movzx ebx,byte [esi]
307
    movzx ebx,byte [esi]
308
    sub   ebx,48
308
    sub   ebx,48
309
    add   eax,ebx
309
    add   eax,ebx
310
    jmp   ip11
310
    jmp   ip11
311
   ip21:
311
   ip21:
312
    mov   [edi],al
312
    mov   [edi],al
313
    inc   edi
313
    inc   edi
314
    mov   [edi],ah
314
    mov   [edi],ah
315
    call draw_window
315
    call draw_window
316
 
316
 
317
 
317
 
318
    jmp     still
318
    jmp     still
319
 
319
 
320
notport:
320
notport:
321
    cmp     ah, 4		; connect
321
    cmp     ah, 4               ; connect
322
    jne     notcon
322
    jne     notcon
323
 
323
 
324
    mov     eax, [socket_status]
324
    mov     eax, [socket_status]
325
    cmp     eax, 4
325
    cmp     eax, 4
326
    je	   still
326
    je     still
327
    call    connect
327
    call    connect
328
 
328
 
329
    jmp     still
329
    jmp     still
330
 
330
 
331
notcon:
331
notcon:
332
    cmp     ah,5		; disconnect
332
    cmp     ah,5                ; disconnect
333
    jne     notdiscon
333
    jne     notdiscon
334
 
334
 
335
    call    disconnect
335
    call    disconnect
336
    jmp  still
336
    jmp  still
337
 
337
 
338
notdiscon:			; Echo Toggle
338
notdiscon:                      ; Echo Toggle
339
    cmp     ah, 6
339
    cmp     ah, 6
340
    jne     still
340
    jne     still
341
 
341
 
342
    mov     al, [echo]
342
    mov     al, [echo]
343
    not     al
343
    not     al
344
    mov     [echo], al
344
    mov     [echo], al
345
 
345
 
346
    call    draw_window
346
    call    draw_window
347
    jmp     still
347
    jmp     still
348
 
348
 
349
arrow:
349
arrow:
350
 
350
 
351
    push eax
351
    push eax
352
    mov  al,27
352
    mov  al,27
353
    call to_modem
353
    call to_modem
354
    mov  al,'['
354
    mov  al,'['
355
    call to_modem
355
    call to_modem
356
    pop  eax
356
    pop  eax
357
    call to_modem
357
    call to_modem
358
 
358
 
359
    ret
359
    ret
360
 
360
 
361
 
361
 
362
to_modem:
362
to_modem:
363
    pusha
363
    pusha
364
    push    ax
364
    push    ax
365
    mov     [tx_buff], al
365
    mov     [tx_buff], al
366
    mov     edx, 1
366
    mov     edx, 1
367
    cmp     al, 13
367
    cmp     al, 13
368
    jne     tm_000
368
    jne     tm_000
369
    mov     edx, 2
369
    mov     edx, 2
370
tm_000:
370
tm_000:
371
    mov     eax,53
371
    mov     eax,53
372
    mov     ebx,7
372
    mov     ebx,7
373
    mov     ecx,[socket]
373
    mov     ecx,[socket]
374
    mov     esi, tx_buff
374
    mov     esi, tx_buff
375
    mcall
375
    mcall
376
    pop     bx
376
    pop     bx
377
    mov     al, [echo]
377
    mov     al, [echo]
378
    cmp     al, 0
378
    cmp     al, 0
379
    je	    tm_001
379
    je      tm_001
380
 
380
 
381
    push    bx
381
    push    bx
382
    call    handle_data
382
    call    handle_data
383
    pop     bx
383
    pop     bx
384
 
384
 
385
    cmp     bl, 13
385
    cmp     bl, 13
386
    jne     tm_002
386
    jne     tm_002
387
 
387
 
388
    mov     bl, 10
388
    mov     bl, 10
389
    call    handle_data
389
    call    handle_data
390
 
390
 
391
tm_002:
391
tm_002:
392
    call    draw_text
392
    call    draw_text
393
 
393
 
394
tm_001:
394
tm_001:
395
    popa
395
    popa
396
    ret
396
    ret
397
 
397
 
398
 
398
 
399
 
399
 
400
disconnect:
400
disconnect:
401
    mov  eax,53
401
    mov  eax,53
402
    mov  ebx,8
402
    mov  ebx,8
403
    mov  ecx,[socket]
403
    mov  ecx,[socket]
404
    mcall
404
    mcall
405
    ret
405
    ret
406
 
406
 
407
 
407
 
408
 
408
 
409
connect:
409
connect:
410
    pusha
410
    pusha
411
 
411
 
412
 mov	 ecx, 1000  ; local port starting at 1000
412
 mov     ecx, 1000  ; local port starting at 1000
413
 
413
 
414
getlp:
414
getlp:
415
 inc	 ecx
415
 inc     ecx
416
 push ecx
416
 push ecx
417
 mov	 eax, 53
417
 mov     eax, 53
418
 mov	 ebx, 9
418
 mov     ebx, 9
419
 mcall
419
 mcall
420
 pop	 ecx
420
 pop     ecx
421
 cmp	 eax, 0   ; is this local port in use?
421
 cmp     eax, 0   ; is this local port in use?
422
 jz  getlp	; yes - so try next
422
 jz  getlp      ; yes - so try next
423
 
423
 
424
    mov     eax,53
424
    mov     eax,53
425
    mov     ebx,5
425
    mov     ebx,5
426
    mov     dl, [ip_address + 3]
426
    mov     dl, [ip_address + 3]
427
    shl     edx, 8
427
    shl     edx, 8
428
    mov     dl, [ip_address + 2]
428
    mov     dl, [ip_address + 2]
429
    shl     edx, 8
429
    shl     edx, 8
430
    mov     dl, [ip_address + 1]
430
    mov     dl, [ip_address + 1]
431
    shl     edx, 8
431
    shl     edx, 8
432
    mov     dl, [ip_address]
432
    mov     dl, [ip_address]
433
    mov     esi, edx
433
    mov     esi, edx
434
    movzx   edx, word [port]	  ; telnet port id
434
    movzx   edx, word [port]      ; telnet port id
435
    mov     edi,1      ; active open
435
    mov     edi,1      ; active open
436
    mcall
436
    mcall
437
    mov     [socket], eax
437
    mov     [socket], eax
438
 
438
 
439
    popa
439
    popa
440
 
440
 
441
    ret
441
    ret
442
 
442
 
443
 
443
 
444
 
444
 
445
;   *********************************************
445
;   *********************************************
446
;   *******  WINDOW DEFINITIONS AND DRAW ********
446
;   *******  WINDOW DEFINITIONS AND DRAW ********
447
;   *********************************************
447
;   *********************************************
448
 
448
 
449
 
449
 
450
draw_window:
450
draw_window:
451
 
451
 
452
    pusha
452
    pusha
453
 
453
 
454
    mov  eax,12
454
    mov  eax,12
455
    mov  ebx,1
455
    mov  ebx,1
456
    mcall
456
    mcall
457
 
457
 
458
    xor  eax,eax		     ; DRAW WINDOW
458
    xor  eax,eax                     ; DRAW WINDOW
459
    mov  ebx,100*65536+491 + 8 +15
459
    mov  ebx,100*65536+491 + 8 +15
460
    mov  ecx,100*65536+270 + 20     ; 20 for status bar
460
    mov  ecx,100*65536+270 + 20     ; 20 for status bar
461
    mov  edx,0x13000000
461
    mov  edx,0x14000000
462
    mov  edi,title
462
    mov  edi,title
463
    mcall
463
    mcall
464
 
464
 
465
    ; draw status bar
465
    ; draw status bar
466
    mov     eax, 13
466
    mov     eax, 13
467
    mov     ebx, 4*65536+484 + 8 +15
467
    mov     ebx, 4*65536+484 + 8 +15
468
    mov     ecx, 270*65536 + 3
468
    mov     ecx, 270*65536 + 3
469
    mov     edx, 0x00557799
469
    mov     edx, 0x00557799
470
    mcall
470
    mcall
471
 
471
 
472
    mov  eax,8			   ; BUTTON 2: SET IP
472
    mov  eax,8                     ; BUTTON 2: SET IP
473
    mov  ebx,4*65536+70
473
    mov  ebx,4*65536+70
474
    mov  ecx,273*65536+12
474
    mov  ecx,273*65536+12
475
    mov     esi, 0x00557799
475
    mov     esi, 0x00557799
476
    mov  edx,2
476
    mov  edx,2
477
    mcall
477
    mcall
478
 
478
 
479
    mov  eax,4			   ; Button text
479
    mov  eax,4                     ; Button text
480
    mov  ebx,6*65536+276
480
    mov  ebx,6*65536+276
481
    mov  ecx,0x00ffffff
481
    mov  ecx,0x00ffffff
482
    mov  edx,setipt
482
    mov  edx,setipt
483
    mov  esi,setiplen-setipt
483
    mov  esi,setiplen-setipt
484
    mcall
484
    mcall
485
 
485
 
486
 
486
 
487
    mov  eax,47
487
    mov  eax,47
488
    mov  edi,ip_address 	    ; display IP address
488
    mov  edi,ip_address             ; display IP address
489
    mov  edx,78*65536+276
489
    mov  edx,78*65536+276
490
    mov  esi,0x00ffffff
490
    mov  esi,0x00ffffff
491
    mov  ebx,3*65536
491
    mov  ebx,3*65536
492
  ipdisplay:
492
  ipdisplay:
493
    movzx ecx,byte [edi]
493
    movzx ecx,byte [edi]
494
    mcall
494
    mcall
495
    add  edx,6*4*65536
495
    add  edx,6*4*65536
496
    inc  edi
496
    inc  edi
497
    cmp  edi,ip_address+4
497
    cmp  edi,ip_address+4
498
    jb	 ipdisplay
498
    jb   ipdisplay
499
 
499
 
500
    mov  eax,8			   ; BUTTON 3: SET PORT
500
    mov  eax,8                     ; BUTTON 3: SET PORT
501
    mov  ebx,173*65536+38
501
    mov  ebx,173*65536+38
502
    mov  ecx,273*65536+12
502
    mov  ecx,273*65536+12
503
    mov  edx,3
503
    mov  edx,3
504
    mov     esi, 0x00557799
504
    mov     esi, 0x00557799
505
    mcall
505
    mcall
506
 
506
 
507
    mov  eax,4			   ; Button text
507
    mov  eax,4                     ; Button text
508
    mov  ebx,178*65536+276
508
    mov  ebx,178*65536+276
509
    mov  ecx,0x00ffffff
509
    mov  ecx,0x00ffffff
510
    mov  edx,setportt
510
    mov  edx,setportt
511
    mov  esi,setportlen-setportt
511
    mov  esi,setportlen-setportt
512
    mcall
512
    mcall
513
 
513
 
514
 
514
 
515
    mov  edx,216*65536+276	     ; display port
515
    mov  edx,216*65536+276           ; display port
516
    mov  esi,0x00ffffff
516
    mov  esi,0x00ffffff
517
    mov  ebx,4*65536
517
    mov  ebx,4*65536
518
    mov  eax,47
518
    mov  eax,47
519
    movzx  ecx,word [port]
519
    movzx  ecx,word [port]
520
    mcall
520
    mcall
521
 
521
 
522
    mov  eax,8			   ; BUTTON 4: Connect
522
    mov  eax,8                     ; BUTTON 4: Connect
523
    mov  ebx,250*65536+50
523
    mov  ebx,250*65536+50
524
    mov  ecx,273*65536+12
524
    mov  ecx,273*65536+12
525
    mov     esi, 0x00557799
525
    mov     esi, 0x00557799
526
    mov  edx,4
526
    mov  edx,4
527
    mcall
527
    mcall
528
 
528
 
529
    mov  eax,4			   ; Button text
529
    mov  eax,4                     ; Button text
530
    mov  ebx,255*65536+276
530
    mov  ebx,255*65536+276
531
    mov  ecx,0x00ffffff
531
    mov  ecx,0x00ffffff
532
    mov  edx,cont
532
    mov  edx,cont
533
    mov  esi,conlen-cont
533
    mov  esi,conlen-cont
534
    mcall
534
    mcall
535
 
535
 
536
 
536
 
537
    mov  eax,8			   ; BUTTON 5: disconnect
537
    mov  eax,8                     ; BUTTON 5: disconnect
538
    mov  ebx,303*65536+70
538
    mov  ebx,303*65536+70
539
    mov  ecx,273*65536+12
539
    mov  ecx,273*65536+12
540
    mov  edx,5
540
    mov  edx,5
541
    mov     esi, 0x00557799
541
    mov     esi, 0x00557799
542
    mcall
542
    mcall
543
 
543
 
544
 
544
 
545
    mov  eax,4			   ; Button text
545
    mov  eax,4                     ; Button text
546
    mov  ebx,307*65536+276
546
    mov  ebx,307*65536+276
547
    mov  ecx,0x00ffffff
547
    mov  ecx,0x00ffffff
548
    mov  edx,dist
548
    mov  edx,dist
549
    mov  esi,dislen-dist
549
    mov  esi,dislen-dist
550
    mcall
550
    mcall
551
 
551
 
552
 
552
 
553
    mov  esi,contlen-contt	    ; display connected status
553
    mov  esi,contlen-contt          ; display connected status
554
    mov     edx, contt
554
    mov     edx, contt
555
    mov     eax, [socket_status]
555
    mov     eax, [socket_status]
556
    cmp     eax, 4		    ; 4 is connected
556
    cmp     eax, 4                  ; 4 is connected
557
    je	    pcon
557
    je      pcon
558
    mov     esi,discontlen-discontt
558
    mov     esi,discontlen-discontt
559
    mov     edx, discontt
559
    mov     edx, discontt
560
pcon:
560
pcon:
561
 
561
 
562
    mov  eax,4			   ; status text
562
    mov  eax,4                     ; status text
563
    mov  ebx,380*65536+276
563
    mov  ebx,380*65536+276
564
    mov  ecx,0x00ffffff
564
    mov  ecx,0x00ffffff
565
    mcall
565
    mcall
566
 
566
 
567
 
567
 
568
    mov  eax,8			   ; BUTTON 6: echo
568
    mov  eax,8                     ; BUTTON 6: echo
569
    mov  ebx,460*65536+50
569
    mov  ebx,460*65536+50
570
    mov  ecx,273*65536+12
570
    mov  ecx,273*65536+12
571
    mov  edx,6
571
    mov  edx,6
572
    mov     esi, 0x00557799
572
    mov     esi, 0x00557799
573
    mcall
573
    mcall
574
 
574
 
575
    mov  edx,echot
575
    mov  edx,echot
576
    mov  esi,echolen-echot
576
    mov  esi,echolen-echot
577
    mov     al, [echo]
577
    mov     al, [echo]
578
    cmp     al, 0
578
    cmp     al, 0
579
    jne     peo
579
    jne     peo
580
    mov  edx,echoot
580
    mov  edx,echoot
581
    mov  esi,echoolen-echoot
581
    mov  esi,echoolen-echoot
582
 
582
 
583
peo:
583
peo:
584
    mov  eax,4			   ; Button text
584
    mov  eax,4                     ; Button text
585
    mov  ebx,463*65536+276
585
    mov  ebx,463*65536+276
586
    mov  ecx,0x00ffffff
586
    mov  ecx,0x00ffffff
587
    mcall
587
    mcall
588
 
588
 
589
 
589
 
590
    xor  eax,eax
590
    xor  eax,eax
591
    mov  edi,text+80*30
591
    mov  edi,text+80*30
592
    mov  ecx,80*30 /4
592
    mov  ecx,80*30 /4
593
    cld
593
    cld
594
    rep  stosd
594
    rep  stosd
595
 
595
 
596
    call draw_text
596
    call draw_text
597
 
597
 
598
    mov  eax,12
598
    mov  eax,12
599
    mov  ebx,2
599
    mov  ebx,2
600
    mcall
600
    mcall
601
 
601
 
602
    popa
602
    popa
603
 
603
 
604
    ret
604
    ret
605
 
605
 
606
 
606
 
607
draw_text:
607
draw_text:
608
 
608
 
609
    pusha
609
    pusha
610
 
610
 
611
    mov  esi,text
611
    mov  esi,text
612
    mov  eax,0
612
    mov  eax,0
613
    mov  ebx,0
613
    mov  ebx,0
614
  newletter:
614
  newletter:
615
    mov  cl,[esi]
615
    mov  cl,[esi]
616
    cmp  cl,[esi+30*80]
616
    cmp  cl,[esi+30*80]
617
    jne  yesletter
617
    jne  yesletter
618
    jmp  noletter
618
    jmp  noletter
619
  yesletter:
619
  yesletter:
620
    mov  [esi+30*80],cl
620
    mov  [esi+30*80],cl
621
 
621
 
622
    ; erase character
622
    ; erase character
623
 
623
 
624
    pusha
624
    pusha
625
    mov     edx, 0		    ; bg colour
625
    mov     edx, 0                  ; bg colour
626
    mov     ecx, ebx
626
    mov     ecx, ebx
627
    add     ecx, 26
627
    add     ecx, 26
628
    shl     ecx, 16
628
    shl     ecx, 16
629
    mov     cx, 9
629
    mov     cx, 9
630
    mov     ebx, eax
630
    mov     ebx, eax
631
    add     ebx, 6
631
    add     ebx, 6
632
    shl     ebx, 16
632
    shl     ebx, 16
633
    mov     bx, 6
633
    mov     bx, 6
634
    mov     eax, 13
634
    mov     eax, 13
635
    mcall
635
    mcall
636
    popa
636
    popa
637
 
637
 
638
    ; draw character
638
    ; draw character
639
 
639
 
640
    pusha
640
    pusha
641
    mov     ecx, 0x00ffffff
641
    mov     ecx, 0x00ffffff
642
    push bx
642
    push bx
643
    mov  ebx,eax
643
    mov  ebx,eax
644
    add  ebx,6
644
    add  ebx,6
645
    shl  ebx,16
645
    shl  ebx,16
646
    pop  bx
646
    pop  bx
647
    add  bx,26
647
    add  bx,26
648
    mov  eax,4
648
    mov  eax,4
649
    mov  edx,esi
649
    mov  edx,esi
650
    mov  esi,1
650
    mov  esi,1
651
    mcall
651
    mcall
652
    popa
652
    popa
653
 
653
 
654
  noletter:
654
  noletter:
655
 
655
 
656
    add  esi,1
656
    add  esi,1
657
    add  eax,6
657
    add  eax,6
658
    cmp  eax,80*6
658
    cmp  eax,80*6
659
    jb	 newletter
659
    jb   newletter
660
    mov  eax,0
660
    mov  eax,0
661
    add  ebx,10
661
    add  ebx,10
662
    cmp  ebx,24*10
662
    cmp  ebx,24*10
663
    jb	 newletter
663
    jb   newletter
664
 
664
 
665
    popa
665
    popa
666
    ret
666
    ret
667
 
667
 
668
 
668
 
669
read_string:
669
read_string:
670
 
670
 
671
    mov  edi,string
671
    mov  edi,string
672
    mov  eax,'_'
672
    mov  eax,'_'
673
    mov  ecx,[string_length]
673
    mov  ecx,[string_length]
674
    inc     ecx
674
    inc     ecx
675
    cld
675
    cld
676
    rep  stosb
676
    rep  stosb
677
    call print_text
677
    call print_text
678
 
678
 
679
    mov  edi,string
679
    mov  edi,string
680
  f11:
680
  f11:
681
    mov  eax,10
681
    mov  eax,10
682
    mcall
682
    mcall
683
    cmp  eax,2
683
    cmp  eax,2
684
    jne  read_done
684
    jne  read_done
685
    mov  eax,2
685
    mov  eax,2
686
    mcall
686
    mcall
687
    shr  eax,8
687
    shr  eax,8
688
    cmp  eax,13
688
    cmp  eax,13
689
    je	 read_done
689
    je   read_done
690
    cmp  eax,8
690
    cmp  eax,8
691
    jnz  nobsl
691
    jnz  nobsl
692
    cmp  edi,string
692
    cmp  edi,string
693
    jz	 f11
693
    jz   f11
694
    sub  edi,1
694
    sub  edi,1
695
    mov  [edi],byte '_'
695
    mov  [edi],byte '_'
696
    call print_text
696
    call print_text
697
    jmp  f11
697
    jmp  f11
698
  nobsl:
698
  nobsl:
699
    cmp  eax,dword 31
699
    cmp  eax,dword 31
700
    jbe  f11
700
    jbe  f11
701
    cmp  eax,dword 95
701
    cmp  eax,dword 95
702
    jb	 keyok
702
    jb   keyok
703
    sub  eax,32
703
    sub  eax,32
704
  keyok:
704
  keyok:
705
    mov  [edi],al
705
    mov  [edi],al
706
    call print_text
706
    call print_text
707
 
707
 
708
    inc  edi
708
    inc  edi
709
    mov  esi,string
709
    mov  esi,string
710
    add  esi,[string_length]
710
    add  esi,[string_length]
711
    cmp  esi,edi
711
    cmp  esi,edi
712
    jnz  f11
712
    jnz  f11
713
 
713
 
714
  read_done:
714
  read_done:
715
 
715
 
716
    call print_text
716
    call print_text
717
 
717
 
718
    ret
718
    ret
719
 
719
 
720
 
720
 
721
print_text:
721
print_text:
722
 
722
 
723
    pusha
723
    pusha
724
 
724
 
725
    mov  eax,13
725
    mov  eax,13
726
    mov  ebx,[string_x]
726
    mov  ebx,[string_x]
727
    shl  ebx,16
727
    shl  ebx,16
728
    add  ebx,[string_length]
728
    add  ebx,[string_length]
729
    imul bx,6
729
    imul bx,6
730
    mov  ecx,[string_y]
730
    mov  ecx,[string_y]
731
    shl  ecx,16
731
    shl  ecx,16
732
    mov  cx,8
732
    mov  cx,8
733
    mov  edx,0x00000000
733
    mov  edx,0x00000000
734
    mcall
734
    mcall
735
 
735
 
736
    mov  eax,4
736
    mov  eax,4
737
    mov  ebx,[string_x]
737
    mov  ebx,[string_x]
738
    shl  ebx,16
738
    shl  ebx,16
739
    add  ebx,[string_y]
739
    add  ebx,[string_y]
740
    mov  ecx,0x00ffffff
740
    mov  ecx,0x00ffffff
741
    mov  edx,string
741
    mov  edx,string
742
    mov  esi,[string_length]
742
    mov  esi,[string_length]
743
    mcall
743
    mcall
744
 
744
 
745
    popa
745
    popa
746
    ret
746
    ret
747
 
747
 
748
 
748
 
749
 
749
 
750
 
750
 
751
; DATA AREA
751
; DATA AREA
752
 
752
 
753
telnetrep	db 0xff,0xfc,0x00
753
telnetrep       db 0xff,0xfc,0x00
754
telnetstate	db 0
754
telnetstate     db 0
755
 
755
 
756
string_length  dd    16
756
string_length  dd    16
757
string_x       dd    200
757
string_x       dd    200
758
string_y       dd    60
758
string_y       dd    60
759
 
759
 
760
string	       db    '________________'
760
string         db    '________________'
761
 
761
 
762
tx_buff 	db  0, 10
762
tx_buff         db  0, 10
763
ip_address	db  001,002,003,004
763
ip_address      db  001,002,003,004
764
port		db  0,0
764
port            db  0,0
765
echo		db  0
765
echo            db  0
766
socket		dd  0x0
766
socket          dd  0x0
767
socket_status	dd  0x0
767
socket_status   dd  0x0
768
pos		dd  80 * 1
768
pos             dd  80 * 1
769
scroll		dd  1
769
scroll          dd  1
770
		dd  24
770
                dd  24
771
wcolor		dd  0x000000
771
wcolor          dd  0x000000
772
title		db  'Telnet v0.1',0
772
title           db  'Telnet v0.1',0
773
setipt		db  'IP Address:    .   .   .'
773
setipt          db  'IP Address:    .   .   .'
774
setiplen:
774
setiplen:
775
setportt	db  'Port:'
775
setportt        db  'Port:'
776
setportlen:
776
setportlen:
777
cont		db  'Connect'
777
cont            db  'Connect'
778
conlen:
778
conlen:
779
dist		db  'Disconnect'
779
dist            db  'Disconnect'
780
dislen:
780
dislen:
781
contt		db  'Connected'
781
contt           db  'Connected'
782
contlen:
782
contlen:
783
discontt	db  'Disconnected'
783
discontt        db  'Disconnected'
784
discontlen:
784
discontlen:
785
echot	     db  'Echo On'
785
echot        db  'Echo On'
786
echolen:
786
echolen:
787
echoot	      db  'Echo Off'
787
echoot        db  'Echo Off'
788
echoolen:
788
echoolen:
789
 
789
 
790
 
790
 
791
 
791
 
792
text:
792
text:
793
I_END:
793
I_END: