Subversion Repositories Kolibri OS

Rev

Rev 556 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 556 Rev 1188
Line 1... Line 1...
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                   ;;
2
;;                                                   ;;
3
;;    IRC CLIENT for MenuetOS                        ;;
3
;;    IRC CLIENT for KolibriOS                       ;;
4
;;                                                   ;;
4
;;                                                   ;;
5
;;    License: GPL / See file COPYING for details    ;;
5
;;    License: GPL / See file COPYING for details    ;;
6
;;    Copyright 2004 (c) Ville Turjanmaa             ;;
6
;;    Copyright 2004 (c) Ville Turjanmaa             ;;
-
 
7
;;    Copyright 2009 (c) CleverMouse                 ;;
7
;;                                                   ;;
8
;;                                                   ;;
8
;;    Compile with FASM for Menuet                   ;;
9
;;    Compile with FASM for Kolibri                  ;;
9
;;                                                   ;;
10
;;                                                   ;;
10
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
11
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Line 11... Line 12...
11
 
12
 
Line 12... Line 13...
12
version equ '0.51'
13
version equ '0.6'
13
 
14
 
Line 20... Line 21...
20
		org	0x0
21
		org	0x0
Line 21... Line 22...
21
 
22
 
22
		db	'MENUET01'		; 8 byte id
23
		db	'MENUET01'		; 8 byte id
23
		dd	0x01			; required os
24
		dd	0x01			; required os
24
		dd	START			; program start
25
		dd	START			; program start
25
		dd	I_END			; program image size
26
		dd	initialized_size	; program image size
26
		dd	0x100000		; required amount of memory
27
		dd	0x100000		; required amount of memory
27
		dd	0x100000
28
		dd	0x100000
Line 28... Line 29...
28
		dd	0,0
29
		dd	0,0
-
 
30
 
-
 
31
include "../../../macros.inc"
-
 
32
include "../../../proc32.inc"
29
 
33
include "../../../develop/libraries/network/network.inc"
30
include "..\..\..\macros.inc"
34
include "dll.inc"
31
;include "fdo.inc"
35
;include "fdo.inc"
Line -... Line 36...
-
 
36
include "eth.inc"
-
 
37
;include "lang.inc"
-
 
38
 
-
 
39
; connection statuses
-
 
40
STATUS_DISCONNECTED = 0 ; disconnected
-
 
41
STATUS_RESOLVING    = 1 ; resolving server name
-
 
42
STATUS_CONNECTING   = 2 ; connecting to server
-
 
43
STATUS_CONNECTED    = 3 ; connected
-
 
44
; where to display status
-
 
45
STATUS_X = 25 + 22*6
-
 
46
STATUS_Y = 183 + 7*12
-
 
47
 
-
 
48
; supported encodings
-
 
49
CP866 = 0
-
 
50
CP1251 = 1
-
 
51
UTF8 = 2
-
 
52
; where to display encoding
32
include "eth.inc"
53
ENCODING_X = 25 + 15*6
Line 33... Line 54...
33
;include "lang.inc"
54
ENCODING_Y = 183 + 3*12
34
 
55
 
-
 
56
def_server_name db      'kolibrios.org',0                 ; default server name
Line 35... Line 57...
35
irc_server_name db      'kolibrios.org',0                 ; default server name
57
 
36
 
58
user_nick	dd	12				  ; length
-
 
59
		db	'kolibri_user           '	  ; string
Line 37... Line 60...
37
user_nick	dd	12				  ; length
60
user_nick_max = $ - user_nick - 4
Line -... Line 61...
-
 
61
 
-
 
62
user_real_name	dd	14				  ; length
-
 
63
		db	'KolibriOS User         '	  ; string
-
 
64
user_real_name_max = $ - user_real_name - 4
38
		db	'kolibri_user           '	  ; string
65
 
39
 
66
 
40
user_real_name	dd	14				  ; length
67
START:				; start of execution
-
 
68
 
-
 
69
    stdcall dll.Load, @IMPORT
-
 
70
    test eax,eax
-
 
71
    jnz  exit
-
 
72
 
-
 
73
    mov  eax,40
-
 
74
    mov  ebx,11000111b
-
 
75
    mcall
-
 
76
    mcall 60, 1, ipcbuf, ipcbuf.size
-
 
77
    mcall 9, 0xe0000, -1
-
 
78
    mov  eax,[ebx+process_information.PID]
-
 
79
    mov  [main_PID],eax
Line 41... Line 80...
41
		db	'KolibriOS User         '	  ; string
80
 
42
 
81
	mov	esi, def_server_name
43
 
82
	mov	edi, irc_server_name
44
START:				; start of execution
83
@@:
45
 
84
	lodsb
Line 46... Line 85...
46
    mov  eax,40
85
	stosb
47
    mov  ebx,10000111b
86
	test	al, al
Line 63... Line 102...
63
redraw: 			; redraw
102
redraw: 			; redraw
64
    call draw_window		; at first, draw the window
103
    call draw_window		; at first, draw the window
Line 65... Line 104...
65
 
104
 
Line 66... Line -...
66
still:
-
 
67
 
-
 
68
    inc  [cursor_on_off]
-
 
69
 
-
 
70
    mov  eax,5
-
 
71
    mov  ebx,1
-
 
72
    mcall
105
still:
73
 
106
 
Line 74... Line -...
74
    mov  eax,11 		; wait here for event
-
 
75
    mcall
-
 
76
 
107
    mov  eax,10                 ; wait here for event
77
    call print_status
108
    mcall
78
 
109
 
79
    cmp  eax,1			; redraw
110
    dec  eax                    ; redraw
80
    je	 redraw
111
    je	 redraw
81
    cmp  eax,2			; key
112
    dec  eax			; key
-
 
113
    je	 main_window_key
-
 
114
    dec  eax			; button
-
 
115
    je	 button
-
 
116
    cmp  al,4
Line 82... Line 117...
82
    je	 main_window_key
117
    jz   ipc
83
    cmp  eax,3			; button
118
 
84
    je	 button
119
    call process_network_event
85
 
120
 
86
    cmp  [I_END+120*60],byte 1
121
    cmp  [I_END+120*60],byte 1
87
    jne  no_main_update
122
    jne  no_main_update
Line 88... Line -...
88
    mov  [I_END+120*60],byte 0
-
 
89
    mov  edx,I_END
-
 
90
    call draw_channel_text
-
 
91
  no_main_update:
-
 
92
 
-
 
93
    call read_incoming_data
-
 
94
 
-
 
95
    call send_data_to_server
-
 
96
 
123
    mov  [I_END+120*60],byte 0
97
    test [cursor_on_off],0x3f
-
 
Line 98... Line 124...
98
    jnz  nopri
124
    mov  edx,I_END
Line 99... Line 125...
99
    inc  [blink]
125
    call draw_channel_text
Line 100... Line 126...
100
    call blink_cursor
126
  no_main_update:
101
    call print_channel_list
127
 
Line 102... Line 128...
102
  nopri:
128
    call print_channel_list
103
 
129
 
-
 
130
    jmp  still
104
    jmp  still
131
 
105
 
132
button: 			; button
106
button: 			; button
133
 
-
 
134
    mov  eax,17 		; get id
-
 
135
    mcall
-
 
136
 
-
 
137
    cmp  ah,1			; close program
-
 
138
    jne  noclose
-
 
139
exit:
-
 
140
    or   eax,-1
-
 
141
    mcall
-
 
142
  noclose:
-
 
143
    cmp  ah,21
-
 
144
    jne  no_change_encoding
-
 
145
    cmp  byte[edx-1],0
-
 
146
    jnz  still
-
 
147
    mov  eax,[encoding]
-
 
148
    inc  eax
-
 
149
    mov  edx,msgbox_struct
Line 107... Line 150...
107
 
150
    mov  byte[edx],al
Line 108... Line 151...
108
    mov  eax,17 		; get id
151
    mov  byte[edx-1],1 ; msgbox is running
Line 109... Line -...
109
    mcall
-
 
110
 
-
 
111
    cmp  ah,1			; close program
-
 
112
    jne  noclose
-
 
113
    or   eax,-1
-
 
114
    mcall
-
 
115
  noclose:
-
 
116
 
-
 
117
    call socket_commands
-
 
118
 
-
 
119
    jmp  still
-
 
120
 
-
 
121
 
-
 
122
print_status:
-
 
123
 
-
 
124
    pusha
-
 
125
 
-
 
126
    mov  eax,53
-
 
127
    mov  ebx,6
-
 
128
    mov  ecx,[socket]
-
 
129
    mcall
-
 
130
 
-
 
131
    mov  [status],eax
-
 
132
 
-
 
133
    cmp  [old_status],eax
-
 
134
    je	 nopr
-
 
135
 
-
 
136
    mov  [old_status],eax
-
 
137
 
-
 
138
    push eax
-
 
139
 
-
 
140
    mov  eax,13
-
 
141
    mov  ebx,450*65536+30
152
    push mb_stack
142
    mov  ecx,231*65536+10
-
 
143
    mov  edx,0xffffff
-
 
144
    mcall
-
 
145
 
-
 
146
    pop  ecx
-
 
147
    mov  eax,47
-
 
148
    mov  ebx,2*65536
-
 
149
    mov  edx,450*65536+231
-
 
150
    mov  esi,0x000000
-
 
151
    mcall
-
 
152
 
-
 
153
  nopr:
-
 
154
 
-
 
155
    popa
-
 
156
 
-
 
157
    ret
153
    push edx
158
 
-
 
159
status dd 0
-
 
160
old_status dd 0
-
 
161
 
-
 
162
 
-
 
163
socket_commands:
-
 
164
 
-
 
165
    cmp  ah,22	     ; open socket
-
 
166
    jnz  tst3
-
 
167
    mov  eax,3
154
    call [mb_create]
168
    mcall
-
 
169
    mov  ecx,eax
-
 
170
 
-
 
171
pusha
-
 
172
    mov     eax,irc_server_name
-
 
173
    resolve irc_server_name,dword[irc_server_ip]
-
 
174
    ;DEBUGF 1,'%u.%u.%u.%u\n',1[irc_server_ip],1[irc_server_ip+1],1[irc_server_ip+2],1[irc_server_ip+3]
-
 
175
popa
-
 
176
 
-
 
177
    mov  eax,53
155
    push msgbox_func_array
178
    mov  ebx,5
-
 
179
    mov  edx,6667
-
 
180
    mov  esi,dword [irc_server_ip]
-
 
181
    mov  edi,1
-
 
182
    mcall
-
 
183
    mov  [socket], eax
-
 
184
    ret
-
 
185
  tst3:
-
 
186
 
-
 
187
 
-
 
188
    cmp  ah,23	      ; write userinfo
-
 
189
    jnz  tst4
-
 
190
 
-
 
191
    mov  eax,53  ; user
-
 
192
    mov  ebx,7
-
 
193
    mov  ecx,[socket]
-
 
194
    mov  edx,string0l-string0
156
    call [mb_setfunctions]
195
    mov  esi,string0
-
 
196
    mcall
157
    jmp  still
197
 
-
 
198
    mov  eax,53  ;
-
 
199
    mov  ebx,7
-
 
200
    mov  ecx,[socket]
-
 
201
    mov  edx,[user_real_name]
158
  no_change_encoding:
202
    mov  esi,user_real_name+4
-
 
203
    mcall
-
 
204
 
-
 
205
    mov  eax,53  ;
-
 
206
    mov  ebx,7
-
 
207
    mov  ecx,[socket]
159
 
208
    mov  edx,2
160
    call socket_commands
209
    mov  esi,line_feed
161
 
210
    mcall
-
 
211
 
162
    jmp  still
212
 
-
 
213
    mov  eax,5
-
 
214
    mov  ebx,10
-
 
215
    mcall
-
 
216
 
163
 
217
    mov  eax,53  ; nick
164
ipc:
218
    mov  ebx,7
-
 
219
    mov  ecx,[socket]
-
 
220
    mov  edx,string1l-string1
-
 
221
    mov  esi,string1
165
    mov  edx,msgbox_struct
222
    mcall
-
 
223
 
-
 
224
    mov  eax,53  ;
-
 
225
    mov  ebx,7
-
 
226
    mov  ecx,[socket]
-
 
227
    mov  edx,[user_nick]
-
 
228
    mov  esi,user_nick+4
-
 
229
    mcall
-
 
230
 
-
 
231
    mov  eax,53  ;
-
 
232
    mov  ebx,7
-
 
233
    mov  ecx,[socket]
-
 
234
    mov  edx,2
-
 
235
    mov  esi,line_feed
166
    cmp  byte[edx-1],0
236
    mcall
-
 
237
 
-
 
238
 
-
 
239
    ret
-
 
240
 
-
 
241
  line_feed:  db  13,10
-
 
242
 
-
 
243
  tst4:
-
 
244
 
-
 
245
 
-
 
Line 246... Line 167...
246
    cmp  ah,24	   ; close socket
167
    jz   @f
Line 247... Line 168...
247
    jnz  no_24
168
    mov  byte[edx-1],0
248
    mov  eax,53
169
    mov  al,[edx]
Line 284... Line 205...
284
    call print_entry
205
    call print_entry
285
    jmp  still
206
    jmp  still
286
  no_character2:
207
  no_character2:
Line 287... Line 208...
287
 
208
 
288
    cmp  eax,13
209
    cmp  eax,13
289
    jne  no_send
210
    jne  no_send2
290
    cmp  [xpos],0
211
    cmp  [xpos],0
291
    je	 no_send2
212
    je	 no_send2
292
    cmp  [send_string],byte '/'   ; server command
213
    cmp  [send_string],byte '/'   ; server command
293
    jne  no_send2
214
    jne  no_send2
294
    mov  [send_to_server],1
215
    call process_command
295
    jmp  still
216
    jmp  still
Line 296... Line 217...
296
  no_send2:
217
  no_send2:
Line -... Line 218...
-
 
218
 
-
 
219
    jmp  still
-
 
220
 
-
 
221
 
-
 
222
socket_commands:
-
 
223
 
-
 
224
    cmp  ah,22	     ; connect
-
 
225
    jnz  tst3
-
 
226
 
-
 
227
; ignore if status is not "disconnected"
-
 
228
	cmp	[status], STATUS_DISCONNECTED
-
 
229
	jnz	.nothing
-
 
230
 
-
 
231
; start name resolving
-
 
232
	inc	[status]	; was STATUS_DISCONNECTED, now STATUS_RESOLVING
-
 
233
	push	gai_reqdata
-
 
234
	push	ip_list
-
 
235
	push	0
-
 
236
	push	0
-
 
237
	push	irc_server_name
-
 
238
	call	[getaddrinfo_start]
-
 
239
	test	eax, eax
-
 
240
	jns	getaddrinfo_done
-
 
241
	call	update_status
-
 
242
.nothing:
-
 
243
	ret
-
 
244
 
-
 
245
  tst3:
-
 
246
 
-
 
247
 
-
 
248
    cmp  ah,23	      ; write userinfo
-
 
249
    jnz  tst4
-
 
250
 
-
 
251
; ignore if status is not "connected"
-
 
252
	cmp	[status], STATUS_CONNECTED
-
 
253
	jnz	.nothing
-
 
254
 
-
 
255
; create packet in packetbuf
-
 
256
	mov	edi, packetbuf
-
 
257
	mov	edx, edi
-
 
258
	mov	esi, string0
-
 
259
	mov	ecx, string0l-string0
-
 
260
	rep	movsb
-
 
261
	mov	esi, user_real_name+4
-
 
262
	mov	ecx, [esi-4]
-
 
263
	rep	movsb
-
 
264
	mov	al, 13
-
 
265
	stosb
-
 
266
	mov	al, 10
-
 
267
	stosb
-
 
268
	mov	esi, string1
-
 
269
	mov	ecx, string1l-string1
-
 
270
	rep	movsb
-
 
271
	mov	esi, user_nick+4
-
 
272
	mov	ecx, [esi-4]
-
 
273
	rep	movsb
-
 
274
	mov	al, 13
-
 
275
	stosb
-
 
276
	mov	al, 10
-
 
277
	stosb
-
 
278
; send packet
-
 
279
	xchg	edx, edi
-
 
280
	sub	edx, edi
-
 
281
	mov	esi, edi
-
 
282
	mcall	53, 7, [socket]
-
 
283
    .nothing:
-
 
284
	ret
-
 
285
 
-
 
286
  tst4:
-
 
287
 
-
 
288
 
-
 
289
    cmp  ah,24	   ; close socket
-
 
290
    jz   disconnect
-
 
291
  no_24:
-
 
292
 
-
 
293
 
-
 
294
    ret
-
 
295
 
-
 
296
getaddrinfo_done:
-
 
297
; The address resolving is done.
-
 
298
; If eax is zero, address is resolved, otherwise there was some problems.
-
 
299
	test	eax, eax
-
 
300
	jz	.good
-
 
301
.disconnect:
-
 
302
; Change status to "disconnected" and return.
-
 
303
	and	[status], 0
-
 
304
	call	update_status
-
 
305
	ret
-
 
306
.good:
-
 
307
; We got a list of IP addresses. Try to connect to first of them.
-
 
308
	mov	eax, [ip_list]
-
 
309
	mov	esi, [eax + addrinfo.ai_addr]
-
 
310
	mov	esi, [esi + sockaddr_in.sin_addr]
-
 
311
	push	eax
-
 
312
	call	[freeaddrinfo]
-
 
313
	mcall	53, 5, 0, 6667, , 1
-
 
314
	cmp	eax, -1
-
 
315
	jz	.disconnect
-
 
316
; Socket has been opened. Save handle and change status to "connecting".
-
 
317
	mov	[socket], eax
-
 
318
	inc	[status]	; was STATUS_RESOLVING, now STATUS_CONNECTING
-
 
319
	call	update_status
-
 
320
	ret
-
 
321
 
-
 
322
process_network_event:
-
 
323
; values for status: 0, 1, 2, 3
-
 
324
	mov	eax, [status]
-
 
325
	dec	eax
-
 
326
; 0 = STATUS_DISCONNECTED - do nothing
-
 
327
; (ignore network events if we are disconnected from network)
-
 
328
	js	.nothing
-
 
329
; 1 = STATUS_RESOLVING
-
 
330
	jz	.resolving
-
 
331
; 2 = STATUS_CONNECTING
-
 
332
	dec	eax
-
 
333
	jz	.connecting
-
 
334
; 3 = STATUS_CONNECTED
-
 
335
	jmp	.connected
-
 
336
.resolving:
-
 
337
; We are inside address resolving. Let the network library work.
-
 
338
	push	ip_list
-
 
339
	push	gai_reqdata
-
 
340
	call	[getaddrinfo_process]
-
 
341
; Negative returned value means that the resolving is not yet finished,
-
 
342
; and we continue the loop without status change.
-
 
343
; Zero and positive values are handled by getaddrinfo_done.
-
 
344
	test	eax, eax
-
 
345
	jns	getaddrinfo_done
-
 
346
.nothing:
-
 
347
	ret
-
 
348
.connecting:
-
 
349
; We are connecting to the server, and socket status has changed.
-
 
350
	mcall	53, 6, [socket]
-
 
351
; Possible values for status: SYN_SENT=2, SYN_RECEIVED=3, ESTABLISHED=4, CLOSE_WAIT=7
-
 
352
; First two mean that we are still connecting, and we must continue wait loop
-
 
353
; without status change.
-
 
354
; Last means that server has immediately closed the connection,
-
 
355
; and status becomes "disconnected".
-
 
356
	cmp	eax, 4
-
 
357
	jb	.nothing
-
 
358
	jz	.established
-
 
359
	and	[status], 0
-
 
360
	call	update_status
-
 
361
; close socket
-
 
362
	mcall	53, 8
-
 
363
	ret
-
 
364
.established:
-
 
365
; The connection has been established, change status from "connecting" to "connected".
-
 
366
	inc	[status]
-
 
367
	call	update_status
-
 
368
; Fall through to .connected, because some data can be already in buffer.
-
 
369
.connected:
-
 
370
	call	read_incoming_data
-
 
371
; Handle closing socket by the server.
-
 
372
	mcall	53, 6, [socket]
-
 
373
	cmp	eax, 4
-
 
374
	jnz	disconnect
-
 
375
	ret
-
 
376
 
-
 
377
disconnect:
-
 
378
; Release all allocated resources.
-
 
379
; Exact actions depend on current status.
-
 
380
	mov	eax, [status]
-
 
381
	dec	eax
-
 
382
; 0 = STATUS_DISCONNECTED - do nothing
-
 
383
	js	.nothing
-
 
384
; 1 = STATUS_RESOLVING
-
 
385
	jz	.resolving
-
 
386
; 2 = STATUS_CONNECTING, 3 = STATUS_CONNECTED
-
 
387
; In both cases we should close the socket.
-
 
388
	mcall	53, 8, [socket]
-
 
389
	jmp	.disconnected
-
 
390
.resolving:
-
 
391
; Let the network library handle abort of resolving process.
-
 
392
	push	gai_reqdata
-
 
393
	call	[getaddrinfo_abort]
-
 
394
.disconnected:
-
 
395
; In all cases, set status to "disconnected".
-
 
396
	and	[status], 0
-
 
397
	call	update_status
-
 
398
.nothing:
-
 
399
	ret
-
 
400
 
-
 
401
msgbox_notify:
297
 
402
	inc	byte [msgbox_running]
Line 298... Line 403...
298
    jmp  still
403
	mcall	60,2,[main_PID],0,1
Line 299... Line 404...
299
 
404
	ret
Line 429... Line 534...
429
    ret
534
    ret
Line 430... Line 535...
430
 
535
 
Line -... Line 536...
-
 
536
 
-
 
537
start_user_list_at dd 0x0
-
 
538
 
Line 431... Line 539...
431
 
539
recode_to_cp866:
432
start_user_list_at dd 0x0
540
	rep	movsb
-
 
541
	ret
433
 
542
 
434
 
543
recode_to_cp1251:
435
recode_to_cp1251:
544
	xor	eax, eax
436
	push	esi edx
545
	jecxz	.nothing
-
 
546
  .loop:
-
 
547
	lodsb
-
 
548
	cmp	al,0x80
-
 
549
	jb	@f
-
 
550
	mov	al,[cp866_table-0x80+eax]
-
 
551
    @@: stosb
-
 
552
	loop	.loop
-
 
553
  .nothing:
-
 
554
	ret
-
 
555
 
-
 
556
recode_to_utf8:
-
 
557
	jecxz	.nothing
437
  .loop:
558
  .loop:
438
	lodsb
559
	lodsb
-
 
560
	cmp	al, 0x80
-
 
561
	jb	.single_byte
-
 
562
	and	eax, 0x7F
439
	cmp	al,0x80
563
	mov	ax, [utf8_table+eax*2]
440
	jb	@f
564
	stosw
441
	and	eax,0x7F
565
	loop	.loop
442
	mov	al,[cp866_table+eax]
566
	ret
443
    @@: mov	[esi-1],al
567
  .single_byte:
Line -... Line 568...
-
 
568
	stosb
-
 
569
	loop	.loop
-
 
570
  .nothing:
Line 444... Line 571...
444
	dec	edx
571
	ret
Line 445... Line 572...
445
	jnz	.loop
572
 
Line 446... Line -...
446
	pop	edx esi
-
 
447
	ret
-
 
448
 
-
 
449
 
573
recode:
450
send_data_to_server:
574
	mov	eax, [encoding]
451
 
575
	jmp	[recode_proc+eax*4]
Line 452... Line 576...
452
    pusha
576
 
Line 467... Line 591...
467
    mov  [text_start],eax
591
    mov  [text_start],eax
Line 468... Line 592...
468
 
592
 
469
    cmp  [send_string],byte '/'   ; server command
593
    cmp  [send_string],byte '/'   ; server command
Line -... Line 594...
-
 
594
    je	 server_command
-
 
595
 
-
 
596
; Ignore data commands when not connected.
-
 
597
	cmp	[status], STATUS_CONNECTED
470
    je	 server_command
598
	jnz	sdts_ret
471
 
599
 
472
    mov  bl,13
600
    mov  bl,13
473
    call print_character
601
    call print_character
474
    mov  bl,10
602
    mov  bl,10
Line 508... Line 636...
508
    rep  movsb
636
    rep  movsb
Line 509... Line 637...
509
 
637
 
Line 510... Line 638...
510
    mov  [edi],word ' :'
638
    mov  [edi],word ' :'
511
 
639
 
512
    mov   esi, send_string_header
640
    mov   esi, send_string_header
513
    mov   edx,10
641
    mov   ecx,10
Line 514... Line -...
514
    movzx ebx,byte [eax+31]
-
 
515
    add   edx,ebx
-
 
516
 
642
    movzx ebx,byte [eax+31]
517
    mov  eax, 53      ; write channel
643
    add   ecx,ebx
Line 518... Line 644...
518
    mov  ebx, 7
644
 
519
    mov  ecx, [socket]
645
    mov   edi, packetbuf
520
    mcall
646
    rep   movsb
Line 521... Line 647...
521
 
647
 
Line 522... Line 648...
522
    mov  esi,send_string
648
    mov  esi,send_string
523
    mov  edx,[xpos]
649
    mov  ecx,[xpos]
524
    inc  edx
650
    inc  ecx
525
 
651
 
Line -... Line 652...
-
 
652
	call	recode
526
	call	recode_to_cp1251
653
 
Line 527... Line 654...
527
 
654
	mov	esi, packetbuf
Line 528... Line 655...
528
    mov  eax, 53      ; write message
655
	mov	edx, edi
529
    mov  ebx, 7
656
	sub	edx, esi
Line 530... Line 657...
530
    mov  ecx, [socket]
657
	mcall	53, 7, [socket]
531
    mcall
658
 
-
 
659
	mov	[xpos], 0
-
 
660
    jmp  sdts_ret
-
 
661
 
-
 
662
  server_command:
532
 
663
 
Line 533... Line 664...
533
    jmp  send_done
664
    cmp  [send_string+1],dword 'anic'
534
 
665
    jne  no_set_nick
535
  server_command:
666
 
536
 
667
    mov  ecx,[xpos]
Line 537... Line 668...
537
    cmp  [send_string+1],dword 'anic'
668
    sub  ecx,7
538
    jne  no_set_nick
669
    cmp  ecx,user_nick_max
539
 
670
    jb   @f
540
    mov  ecx,[xpos]
671
    mov  ecx,user_nick_max
541
    sub  ecx,7
672
  @@:
542
    mov  [user_nick],ecx
673
    mov  [user_nick],ecx
543
 
674
 
Line 544... Line 675...
544
    mov  esi,send_string+7
675
    mov  esi,send_string+7
545
    mov  edi,user_nick+4
676
    mov  edi,user_nick+4
546
    cld
677
    cld
547
    rep  movsb
678
    rep  movsb
548
 
679
 
Line 549... Line -...
549
    pusha
-
 
550
    mov  edi,text+70*1+15
-
 
551
    mov  eax,32
680
    pusha
552
    mov  ecx,15
681
    mov  edi,text+70*1+15
Line 553... Line 682...
553
    cld
682
    mov  al,32
554
    rep  stosb
683
    mov  ecx,15
Line 555... Line 684...
555
    popa
684
    cld
Line 573... Line 702...
573
    cmp  [send_string+1],dword 'area'
702
    cmp  [send_string+1],dword 'area'
574
    jne  no_set_real_name
703
    jne  no_set_real_name
Line 575... Line 704...
575
 
704
 
576
    mov  ecx,[xpos]
705
    mov  ecx,[xpos]
-
 
706
    sub  ecx,7
-
 
707
    cmp  ecx,user_real_name_max
-
 
708
    jb   @f
-
 
709
    mov  ecx,user_real_name_max
577
    sub  ecx,7
710
  @@:
Line 578... Line 711...
578
    mov  [user_real_name],ecx
711
    mov  [user_real_name],ecx
579
 
712
 
580
    mov  esi,send_string+7
713
    mov  esi,send_string+7
581
    mov  edi,user_real_name+4
714
    mov  edi,user_real_name+4
Line 582... Line 715...
582
    cld
715
    cld
583
    rep  movsb
716
    rep  movsb
584
 
717
 
585
    pusha
718
    pusha
586
    mov  edi,text+70*0+15
719
    mov  edi,text+70*0+15
587
    mov  eax,32
720
    mov  al,32
588
    mov  ecx,15
721
    mov  ecx,15
Line 589... Line 722...
589
    cld
722
    cld
590
    rep  stosb
723
    rep  stosb
591
    popa
724
    popa
592
 
-
 
593
    mov  esi,user_real_name+4
-
 
594
    mov  edi,text+70*0+15
725
 
Line 595... Line -...
595
    mov  ecx,[xpos]
-
 
596
    sub  ecx,7
-
 
597
    cld
726
    mov  esi,user_real_name+4
598
    rep  movsb
727
    mov  edi,text+70*0+15
Line 599... Line 728...
599
 
728
    mov  ecx,[esi-4]
600
    call draw_window
729
    rep  movsb
Line 601... Line 730...
601
 
730
 
Line 602... Line 731...
602
    mov  [xpos],0
731
    mov  [xpos],0
603
    mov  [send_to_server],0
732
    call draw_window
Line 604... Line -...
604
 
-
 
605
    popa
-
 
606
    ret
-
 
607
 
-
 
608
  no_set_real_name:
-
 
609
 
-
 
610
    cmp  [send_string+1],dword 'aser'
-
 
611
    jne  no_set_server
-
 
612
 
733
 
613
pusha
734
    popa
Line -... Line 735...
-
 
735
    ret
-
 
736
 
-
 
737
  no_set_real_name:
-
 
738
 
-
 
739
    cmp  [send_string+1],dword 'aser'
-
 
740
    jne  no_set_server
614
    mov     eax,send_string
741
 
615
    add     eax,[xpos]
742
    mov  ecx,[xpos]
616
    mov     dword[eax],0
743
    sub  ecx,7
617
    resolve send_string+7,dword[irc_server_ip]
744
 
618
    ;DEBUGF 1,'%u.%u.%u.%u\n',1[irc_server_ip],1[irc_server_ip+1],1[irc_server_ip+2],1[irc_server_ip+3]
745
    mov  esi,send_string+7
619
popa
746
    mov  edi,irc_server_name
620
 
747
    rep  movsb
Line -... Line 748...
-
 
748
    mov  al,0
-
 
749
    stosb
621
    mov  ecx,[xpos]
750
 
622
    sub  ecx,7
751
    pusha
623
 
-
 
624
    pusha
752
    mov  edi,text+70*2+15
Line 625... Line -...
625
    mov  edi,text+70*2+15
-
 
626
    mov  eax,32
-
 
627
    mov  ecx,15
753
    mov  al,32
628
    cld
754
    mov  ecx,15
Line 629... Line 755...
629
    rep  stosb
755
    cld
630
    popa
756
    rep  stosb
Line 631... Line 757...
631
 
757
    popa
Line -... Line 758...
-
 
758
 
-
 
759
    mov  ecx,[xpos]
632
    mov  esi,send_string+7
760
    sub  ecx,7
Line 633... Line 761...
633
    mov  edi,text+70*2+15
761
    mov  esi,send_string+7
634
    cld
762
    mov  edi,text+70*2+15
Line 673... Line 801...
673
    call create_channel_name
801
    call create_channel_name
Line 674... Line 802...
674
 
802
 
675
    push edi
803
    push edi
676
    push eax
804
    push eax
677
    mov  [edi+120*60+8],byte 1 ; query window
805
    mov  [edi+120*60+8],byte 1 ; query window
678
    mov  eax,32
806
    mov  al,32
679
    mov  ecx,120*60
807
    mov  ecx,120*60
680
    cld
808
    cld
681
    rep  stosb
809
    rep  stosb
682
    pop  eax
810
    pop  eax
Line 683... Line 811...
683
    pop  edi
811
    pop  edi
684
 
812
 
685
    ; eax has the free position
813
    ; eax has the free position
Line 686... Line 814...
686
    mov  [thread_screen],edi
814
;    mov  [thread_screen],edi
687
    call create_channel_window
-
 
Line 688... Line 815...
688
 
815
    call create_channel_window
689
    mov  [xpos],0
816
 
Line 690... Line 817...
690
    mov  [send_to_server],0
817
    mov  [xpos],0
Line 691... Line 818...
691
 
818
 
692
    popa
819
    popa
-
 
820
    ret
-
 
821
 
-
 
822
  no_query_create:
-
 
823
 
-
 
824
 
693
    ret
825
    mov  esi, send_string+1
Line 694... Line 826...
694
 
826
    mov  ecx, [xpos]
695
  no_query_create:
827
    inc  ecx
696
 
828
    mov  edi, packetbuf
697
 
829
    call recode
Line 698... Line 830...
698
    mov  esi, send_string+1
830
    mov  esi, packetbuf
Line 699... Line 831...
699
    mov  edx, [xpos]
831
    mov  edx, edi
700
    add  edx,1
-
 
Line 701... Line 832...
701
 
832
    sub  edx, esi
702
    mov  eax, 53      ; write server command
833
 
703
    mov  ebx, 7
834
    mov  eax, 53      ; write server command
704
    mov  ecx, [socket]
835
    mov  ebx, 7
Line 722... Line 853...
722
 
853
 
723
    mov  ecx,[max_windows]
854
    mov  ecx,[max_windows]
724
    mov  edi,I_END
855
    mov  edi,I_END
725
  newclose:
856
  newclose:
-
 
857
    mov  [edi+120*60+4],byte  1
726
    mov  [edi+120*60+4],byte  1
858
    call notify_channel_thread
727
    add  edi,120*80
859
    add  edi,120*80
Line 728... Line 860...
728
    loop newclose
860
    loop newclose
729
 
861
 
Line 735... Line 867...
735
  sdts_ret:
867
  sdts_ret:
Line 736... Line 868...
736
 
868
 
737
    popa
869
    popa
Line -... Line 870...
-
 
870
    ret
-
 
871
 
-
 
872
get_next_byte:
-
 
873
; Load next byte from the packet, translating to cp866 if necessary
-
 
874
; At input esi = pointer to data, edx = limit of data
-
 
875
; Output is either (translated) byte in al with CF set or CF cleared.
-
 
876
	mov	eax, [encoding]
-
 
877
	jmp	[get_byte_table+eax*4]
-
 
878
 
-
 
879
get_byte_cp866:
-
 
880
	cmp	esi, edx
-
 
881
	jae	.nothing
-
 
882
	lodsb
Line -... Line 883...
-
 
883
.nothing:
-
 
884
	ret
-
 
885
 
-
 
886
get_byte_cp1251:
-
 
887
	cmp	esi, edx
-
 
888
	jae	.nothing
-
 
889
	lodsb
-
 
890
	cmp	al, 0x80
-
 
891
	jb	@f
-
 
892
	and	eax, 0x7F
-
 
893
	mov	al, [cp1251_table+eax]
-
 
894
@@:
Line -... Line 895...
-
 
895
	stc
-
 
896
.nothing:
-
 
897
	ret
-
 
898
 
-
 
899
get_byte_utf8:
-
 
900
; UTF8 decoding is slightly complicated.
-
 
901
; One character can occupy one or more bytes.
-
 
902
; The boundary in packets theoretically can be anywhere in data,
-
 
903
; so this procedure keeps internal state between calls and handles
-
 
904
; one byte at a time, looping until character is read or packet is over.
-
 
905
; Globally, there are two distinct tasks: decode byte sequence to unicode char
-
 
906
; and convert this unicode char to our base encoding (that is cp866).
-
 
907
; 1. Check that there are data.
-
 
908
	cmp	esi, edx
-
 
909
	jae	.nothing
-
 
910
; 2. Load byte.
-
 
911
	lodsb
-
 
912
	movzx	ecx, al
-
 
913
; 3. Bytes in an UTF8 sequence can be of any of three types.
-
 
914
; If most significant bit is cleared, sequence is one byte and usual ASCII char.
-
 
915
; First byte of a sequence must be 11xxxxxx, other bytes are 10yyyyyy.
-
 
916
	and	al, 0xC0
-
 
917
	jns	.single_byte
-
 
918
	jp	.first_byte
-
 
919
; 4. This byte is not first in UTF8 sequence.
-
 
920
; 4a. Check that the sequence was started. If no, it is invalid byte
-
 
921
; and we simply ignore it.
-
 
922
	cmp	[utf8_bytes_rest], 0
-
 
923
	jz	get_byte_utf8
-
 
924
; 4b. Otherwise, it is really next byte and it gives some more bits of char.
-
 
925
	mov	eax, [utf8_char]
-
 
926
	shl	eax, 6
-
 
927
	lea	eax, [eax+ecx-0x80]
-
 
928
; 4c. Decrement number of bytes rest in the sequence.
-
 
929
; If it goes to zero, character is read, so return it.
-
 
930
	dec	[utf8_bytes_rest]
-
 
931
	jz	.got_char
-
 
932
	mov	[utf8_char], eax
-
 
933
	jmp	get_byte_utf8
-
 
934
; 5. If the byte is first in UTF8 sequence, calculate the number of leading 1s
-
 
935
; - it equals total number of bytes in the sequence; some other bits rest for
-
 
936
; leading bits in the character.
-
 
937
.first_byte:
-
 
938
	mov	eax, -1
-
 
939
@@:
-
 
940
	inc	eax
-
 
941
	add	cl, cl
-
 
942
	js	@b
-
 
943
	mov	[utf8_bytes_rest], eax
-
 
944
	xchg	eax, ecx
-
 
945
	inc	ecx
738
    ret
946
	shr	al, cl
-
 
947
	mov	[utf8_char], eax
-
 
948
	jmp	get_byte_utf8
-
 
949
; 6. If the byte is ASCII char, it is the character.
-
 
950
.single_byte:
-
 
951
	xchg	eax, ecx
-
 
952
.got_char:
-
 
953
; We got the character, now abandon a possible sequence in progress.
-
 
954
	and	[utf8_bytes_rest], 0
-
 
955
; Now second task. The unicode character is in eax, and now we shall convert it
-
 
956
; to cp866.
-
 
957
	cmp	eax, 0x80
-
 
958
	jb	.done
-
 
959
; 0x410-0x43F -> 0x80-0xAF, 0x440-0x44F -> 0xE0-0xEF, 0x401 -> 0xF0, 0x451 -> 0xF1
-
 
960
	cmp	eax, 0x401
-
 
961
	jz	.YO
-
 
962
	cmp	eax, 0x451
-
 
963
	jz	.yo
-
 
964
	cmp	eax, 0x410
-
 
965
	jb	.unrecognized
-
 
966
	cmp	eax, 0x440
-
 
967
	jb	.part1
-
 
968
	cmp	eax, 0x450
-
 
969
	jae	.unrecognized
-
 
970
	sub	al, (0x40-0xE0) and 0xFF
-
 
971
	ret
-
 
972
.part1:
-
 
973
	sub	al, 0x10-0x80
-
 
974
.nothing:
-
 
975
.done:
-
 
976
	ret
-
 
977
.unrecognized:
-
 
978
	mov	al, '?'
-
 
979
	stc
-
 
980
	ret
-
 
981
.YO:
-
 
982
	mov	al, 0xF0
-
 
983
	stc
-
 
984
	ret
Line -... Line 985...
-
 
985
.yo:
739
 
986
	mov	al, 0xF1
740
 
-
 
741
 
987
	stc
742
read_incoming_data:
988
	ret
743
 
989
 
744
    pusha
990
read_incoming_data:
745
 
991
	pusha
-
 
992
.packetloop:
-
 
993
.nextpacket:
746
  read_new_byte:
994
	mcall	53, 11, [socket], packetbuf, 1024
-
 
995
	test	eax, eax
-
 
996
	jz	.nothing
747
 
997
	mov	esi, edx	; esi = pointer to data
748
    call read_incoming_byte
998
	add	edx, eax	; edx = limit of data
749
    cmp  ecx,-1
999
.byteloop:
750
    je	 no_data_in_buffer
1000
	call	get_next_byte
751
 
-
 
752
    cmp  bl,10
1001
	jnc	.nextpacket
753
    jne  no_start_command
1002
	cmp	al, 10
754
    mov  [cmd],1
1003
	jne	.no_start_command
755
  no_start_command:
1004
	mov	[cmd], 1
756
 
1005
.no_start_command:
757
    cmp  bl,13
1006
	cmp	al, 13
758
    jne  no_end_command
1007
	jne	.no_end_command
759
    mov  eax,[cmd]
1008
	mov	ebx, [cmd]
760
    mov  [eax+command-2],byte 0
-
 
761
    call analyze_command
1009
	mov	byte [ebx+command-2], 0
762
    mov  edi,command
1010
	call	analyze_command
-
 
1011
	mov	edi, command
763
    mov  ecx,250
1012
	mov	ecx, 250
764
    mov  eax,0
-
 
765
    cld
1013
	xor	eax, eax
766
    rep  stosb
1014
	rep	stosb
767
    mov  [cmd],0
1015
	mov	[cmd], eax
768
  no_end_command:
-
 
769
 
1016
	mov	al, 13
770
    mov  eax,[cmd]
1017
.no_end_command:
771
    cmp  eax,512
1018
	mov	ebx, [cmd]
772
    jge  still
1019
	cmp	ebx, 512
773
 
-
 
774
    mov  [eax+command-2],bl
1020
	jge	@f
775
    inc  [cmd]
-
 
776
 
1021
	mov	[ebx+command-2], al
777
    jmp  read_new_byte
-
 
778
 
1022
	inc	[cmd]
Line 779... Line 1023...
779
  no_data_in_buffer:
1023
@@:
Line 821... Line 1065...
821
 
1065
 
Line 822... Line 1066...
822
    pusha
1066
    pusha
Line 823... Line 1067...
823
 
1067
 
Line -... Line 1068...
-
 
1068
    mov  [cursor_on_off],0
-
 
1069
 
-
 
1070
;    mov  [thread_nro],eax
-
 
1071
 
824
    mov  [cursor_on_off],0
1072
    mov  edx,[thread_stack]
825
 
1073
    sub  edx,8
826
    mov  [thread_nro],eax
1074
    mov  [edx],eax
827
 
-
 
828
    mov  eax,51
-
 
829
    mov  ebx,1
-
 
830
    mov  ecx,channel_thread
-
 
831
    mov  edx,[thread_stack]
-
 
832
    mcall
1075
    mov  [edx+4],edi
-
 
1076
    mov  eax,51
Line 833... Line 1077...
833
 
1077
    mov  ebx,1
834
    mov  eax,5
1078
    mov  ecx,channel_thread
Line 835... Line 1079...
835
    mov  ebx,10
1079
    mcall
Line 836... Line 1080...
836
    mcall
1080
    mov  [edi+120*60+12], eax
Line 860... Line 1104...
860
    mov  esi,[xpos]
1104
    mov  esi,[xpos]
861
    mcall
1105
    mcall
Line 862... Line 1106...
862
 
1106
 
Line -... Line 1107...
-
 
1107
    popa
863
    popa
1108
 
864
 
-
 
865
    ret
-
 
Line 866... Line 1109...
866
 
1109
; Fall through to draw_cursor.
Line 867... Line 1110...
867
blink dd 0x0
1110
;    ret
Line 868... Line 1111...
868
 
1111
 
869
blink_cursor:
1112
draw_cursor:
870
 
1113
 
871
    pusha
1114
    pusha
Line 872... Line -...
872
 
-
 
873
    mov  eax,9
-
 
874
    mov  ebx,0xe0000
-
 
875
    mov  ecx,-1
-
 
876
    mcall
-
 
877
 
-
 
878
    mov  edx,[blink]
1115
 
-
 
1116
    mov  eax,9
-
 
1117
    mov  ebx,0xe0000
-
 
1118
    mov  ecx,-1
-
 
1119
    mcall
879
    and  edx,1
1120
 
Line 880... Line 1121...
880
    sub  edx,1
1121
    cmp  ax,word [0xe0000+4]
Line 881... Line 1122...
881
    and  edx,0xffffff
1122
    setnz dl
882
;    mov  edx,0
1123
    movzx edx,dl
883
 
1124
    neg edx
884
    cmp  ax,word [0xe0000+4]
1125
    and edx,0xffffff
Line 898... Line 1139...
898
 
1139
 
Line 899... Line 1140...
899
    popa
1140
    popa
Line 900... Line 1141...
900
 
1141
 
901
    ret
1142
    ret
902
 
1143
 
903
  no_blink:
1144
;  no_blink:
904
 
1145
;
905
    mov  eax,13
1146
;    mov  eax,13
906
    mov  ebx,8*65536+6*60
1147
;    mov  ebx,8*65536+6*60
Line 907... Line 1148...
907
    mov  ecx,151*65536+13
1148
;    mov  ecx,151*65536+13
Line 908... Line 1149...
908
    mov  edx,0xffffff
1149
;    mov  edx,0xffffff
Line 1014... Line 1255...
1014
    mov  [text_start],I_END
1255
    mov  [text_start],I_END
1015
    mov  ecx,[rxs]
1256
    mov  ecx,[rxs]
1016
    imul ecx,11
1257
    imul ecx,11
1017
    mov  [pos],ecx
1258
    mov  [pos],ecx
Line 1018... Line 1259...
1018
 
1259
 
1019
    mov  bl,13
1260
;    mov  bl,13
1020
;  call print_character
1261
;  call print_character
1021
    mov  bl,10
1262
;    mov  bl,10
Line 1022... Line 1263...
1022
;  call print_character
1263
;  call print_character
1023
 
1264
 
1024
    mov  ecx,[cmd]
1265
;    mov  ecx,[cmd]
1025
    sub  ecx,2
1266
;    sub  ecx,2
1026
    mov  esi,command+0
1267
;    mov  esi,command+0
1027
  newcmdc:
1268
;  newcmdc:
1028
    mov  bl,[esi]
1269
;    mov  bl,[esi]
1029
;  call print_character
1270
;  call print_character
Line 1030... Line 1271...
1030
    inc  esi
1271
;    inc  esi
1031
    loop newcmdc
1272
;    loop newcmdc
Line 1032... Line 1273...
1032
 
1273
 
1033
    mov   edx,I_END
1274
    mov   edx,I_END
1034
;  call  draw_channel_text
1275
;  call  draw_channel_text
1035
 
1276
 
1036
    cmp  [cmd],20
1277
;    cmp  [cmd],20
1037
    jge  cmd_len_ok
1278
;    jge  cmd_len_ok
1038
 
1279
;
Line 1039... Line 1280...
1039
    mov  [cmd],0
1280
;    mov  [cmd],0
Line 1040... Line 1281...
1040
 
1281
;
Line 1063... Line 1304...
1063
 
1304
 
1064
    mov  eax,53
1305
    mov  eax,53
1065
    mov  ebx,7
1306
    mov  ebx,7
1066
    mov  ecx,[socket]
1307
    mov  ecx,[socket]
1067
    mov  edx,[cmd]
-
 
1068
    sub  edx,2
-
 
1069
    and  edx,255
1308
    mov  edx,[cmd]
1070
    mov  esi,command
-
 
1071
    mcall
-
 
1072
 
-
 
1073
    mov  eax,53
-
 
1074
    mov  ebx,7
1309
    mov  esi,command
1075
    mov  ecx,[socket]
-
 
1076
    mov  edx,2
-
 
1077
    mov  esi,linef
1310
    mov  word [esi+edx-2], 0x0a0d
Line 1078... Line 1311...
1078
    mcall
1311
    mcall
1079
 
1312
 
Line 1080... Line -...
1080
    popa
-
 
1081
    ret
-
 
1082
 
1313
    popa
Line 1083... Line 1314...
1083
  linef  db  13,10
1314
    ret
1084
 
1315
 
1085
  no_ping_responce:
1316
  no_ping_responce:
Line 1148... Line 1379...
1148
    call print_character
1379
    call print_character
1149
    pop  eax
1380
    pop  eax
1150
    add  eax,8
1381
    add  eax,8
1151
    mov  dl,0
1382
    mov  dl,0
1152
    call print_text
1383
    call print_text
-
 
1384
    call notify_channel_thread
1153
    popa
1385
    popa
1154
    ret
1386
    ret
Line 1155... Line 1387...
1155
 
1387
 
Line 1167... Line 1399...
1167
    call print_character
1399
    call print_character
1168
    pop  eax
1400
    pop  eax
Line 1169... Line 1401...
1169
 
1401
 
1170
    mov  dl,0
1402
    mov  dl,0
-
 
1403
    call print_text
Line 1171... Line 1404...
1171
    call print_text
1404
    call notify_channel_thread
1172
 
1405
 
Line 1173... Line 1406...
1173
    popa
1406
    popa
Line 1188... Line 1421...
1188
 
1421
 
1189
    mov  eax,[command_position]
1422
    mov  eax,[command_position]
1190
    add  eax,5
1423
    add  eax,5
Line 1191... Line 1424...
1191
    call set_channel
1424
    call set_channel
1192
 
1425
 
-
 
1426
    mov  edi,[text_start]
Line 1193... Line 1427...
1193
    mov  eax,[text_start]
1427
    mov  [edi+120*60+4],byte 1
1194
    mov  [eax+120*60+4],byte 1
1428
    call notify_channel_thread
Line 1195... Line 1429...
1195
 
1429
 
Line 1214... Line 1448...
1214
    call print_text
1448
    call print_text
1215
    mov  eax,[command_position]
1449
    mov  eax,[command_position]
1216
    add  eax,5
1450
    add  eax,5
1217
    mov  dl,' '
1451
    mov  dl,' '
1218
    call print_text
1452
    call print_text
-
 
1453
    call notify_channel_thread
Line 1219... Line 1454...
1219
 
1454
 
1220
    popa
1455
    popa
Line 1221... Line 1456...
1221
    ret
1456
    ret
Line 1266... Line 1501...
1266
    call create_channel_name
1501
    call create_channel_name
Line 1267... Line 1502...
1267
 
1502
 
1268
    push edi
1503
    push edi
1269
    push eax
1504
    push eax
1270
    mov  [edi+120*60+8],byte 0 ; channel window
1505
    mov  [edi+120*60+8],byte 0 ; channel window
1271
    mov  eax,32
1506
    mov  al,32
1272
    mov  ecx,120*60
1507
    mov  ecx,120*60
1273
    cld
1508
    cld
1274
    rep  stosb
1509
    rep  stosb
1275
    pop  eax
1510
    pop  eax
Line 1276... Line 1511...
1276
    pop  edi
1511
    pop  edi
1277
 
1512
 
1278
    ; eax has the free position
1513
    ; eax has the free position
Line 1279... Line 1514...
1279
    mov  [thread_screen],edi
1514
;    mov  [thread_screen],edi
Line 1280... Line 1515...
1280
    call create_channel_window
1515
    call create_channel_window
Line 1299... Line 1534...
1299
 
1534
 
1300
    mov  eax,[command_position]
1535
    mov  eax,[command_position]
1301
    add  eax,6
1536
    add  eax,6
1302
    mov  dl,0
1537
    mov  dl,0
-
 
1538
    call print_text
Line 1303... Line 1539...
1303
    call print_text
1539
    call notify_channel_thread
1304
 
1540
 
Line 1305... Line 1541...
1305
    popa
1541
    popa
Line 1327... Line 1563...
1327
    call print_text
1563
    call print_text
1328
    mov  eax,[command_position]
1564
    mov  eax,[command_position]
1329
    add  eax,6
1565
    add  eax,6
1330
    mov  dl,0
1566
    mov  dl,0
1331
    call print_text
1567
    call print_text
-
 
1568
    call notify_channel_thread
Line 1332... Line 1569...
1332
 
1569
 
1333
    add  [text_start],120*80
1570
    add  [text_start],120*80
1334
    cmp  [text_start],I_END+120*80*20
1571
    cmp  [text_start],I_END+120*80*20
Line 1363... Line 1600...
1363
    call print_text
1600
    call print_text
1364
    mov  eax,[command_position]
1601
    mov  eax,[command_position]
1365
    add  eax,5
1602
    add  eax,5
1366
    mov  dl,0
1603
    mov  dl,0
1367
    call print_text
1604
    call print_text
-
 
1605
    call notify_channel_thread
Line 1368... Line 1606...
1368
 
1606
 
1369
;    add  [text_start],120*80
1607
;    add  [text_start],120*80
1370
;    cmp  [text_start],I_END+120*80*20
1608
;    cmp  [text_start],I_END+120*80*20
Line 1393... Line 1631...
1393
    mov  dl,'!'
1631
    mov  dl,'!'
1394
    call print_text
1632
    call print_text
1395
    mov  eax,has_quit_irc
1633
    mov  eax,has_quit_irc
1396
    mov  dl,0
1634
    mov  dl,0
1397
    call print_text
1635
    call print_text
-
 
1636
    call notify_channel_thread
Line 1398... Line 1637...
1398
 
1637
 
1399
    add  [text_start],120*80
1638
    add  [text_start],120*80
1400
    cmp  [text_start],I_END+120*80*20
1639
    cmp  [text_start],I_END+120*80*20
Line 1430... Line 1669...
1430
 
1669
 
1431
    mov  eax,[command_position]
1670
    mov  eax,[command_position]
1432
    add  eax,5
1671
    add  eax,5
1433
    mov  dl,0
1672
    mov  dl,0
-
 
1673
    call print_text
Line 1434... Line 1674...
1434
    call print_text
1674
    call notify_channel_thread
1435
 
1675
 
1436
;    add  [text_start],120*80
1676
;    add  [text_start],120*80
Line 1463... Line 1703...
1463
    jne  no_clear_user_list
1703
    jne  no_clear_user_list
1464
    mov  edi,[text_start]
1704
    mov  edi,[text_start]
1465
    add  edi,120*70
1705
    add  edi,120*70
1466
    mov  [edi-8],dword 0
1706
    mov  [edi-8],dword 0
1467
    mov  [edi-4],dword 0
1707
    mov  [edi-4],dword 0
1468
    mov  eax,32
1708
    mov  al,32
1469
    mov  ecx,1200
1709
    mov  ecx,1200
1470
    cld
1710
    cld
1471
    rep  stosb
1711
    rep  stosb
1472
  no_clear_user_list:
1712
  no_clear_user_list:
1473
    popa
1713
    popa
Line 1499... Line 1739...
1499
 
1739
 
1500
    mov  eax,[user_list_pos]
1740
    mov  eax,[user_list_pos]
1501
    mov  ebx,[text_start]
1741
    mov  ebx,[text_start]
1502
    add  ebx,120*70
1742
    add  ebx,120*70
-
 
1743
    mov  [ebx-4],eax
Line 1503... Line 1744...
1503
    mov  [ebx-4],eax
1744
    call notify_channel_thread
1504
 
1745
 
Line 1505... Line 1746...
1505
    popa
1746
    popa
Line 1643... Line 1884...
1643
  db $A0,$A1,$A2,$A3,$A4,$A5,$A6,$A7 , $A8,$A9,$AA,$AB,$AC,$AD,$AE,$AF ; E
1884
  db $A0,$A1,$A2,$A3,$A4,$A5,$A6,$A7 , $A8,$A9,$AA,$AB,$AC,$AD,$AE,$AF ; E
1644
  db $E0,$E1,$E2,$E3,$E4,$E5,$E6,$E7 , $E8,$E9,$EA,$EB,$EC,$ED,$EE,$EF ; F
1885
  db $E0,$E1,$E2,$E3,$E4,$E5,$E6,$E7 , $E8,$E9,$EA,$EB,$EC,$ED,$EE,$EF ; F
Line 1645... Line 1886...
1645
 
1886
 
Line -... Line 1887...
-
 
1887
;    0   1   2   3   4   5   6   7     8   9   A   B   C   D   E   F
-
 
1888
 
-
 
1889
utf8_table:
-
 
1890
	times 80h dw 0x98C3	; default placeholder
-
 
1891
; 0x80-0xAF -> 0x90D0-0xBFD0
-
 
1892
repeat 0x30
-
 
1893
store byte 0xD0 at utf8_table+2*(%-1)
-
 
1894
store byte 0x90+%-1 at utf8_table+2*%-1
-
 
1895
end repeat
-
 
1896
; 0xE0-0xEF -> 0x80D1-0x8FD1
-
 
1897
repeat 0x10
-
 
1898
store byte 0xD1 at utf8_table+2*(0xE0-0x80+%-1)
-
 
1899
store byte 0x80+%-1 at utf8_table+2*(0xE0-0x80+%)-1
-
 
1900
end repeat
-
 
1901
; 0xF0 -> 0x81D0, 0xF1 -> 0x91D1
1646
;    0   1   2   3   4   5   6   7     8   9   A   B   C   D   E   F
1902
store dword 0x91D181D0 at utf8_table+2*(0xF0-0x80)
1647
 
1903
 
1648
cp866_table:
1904
cp866_table:
1649
  db $C0,$C1,$C2,$C3,$C4,$C5,$C6,$C7 , $C8,$C9,$CA,$CB,$CC,$CD,$CE,$CF ; 8
1905
  db $C0,$C1,$C2,$C3,$C4,$C5,$C6,$C7 , $C8,$C9,$CA,$CB,$CC,$CD,$CE,$CF ; 8
1650
  db $D0,$D1,$D2,$D3,$D4,$D5,$D6,$D7 , $D8,$D9,$DA,$DB,$DC,$DD,$DE,$DF ; 9
1906
  db $D0,$D1,$D2,$D3,$D4,$D5,$D6,$D7 , $D8,$D9,$DA,$DB,$DC,$DD,$DE,$DF ; 9
Line 1744... Line 2000...
1744
    mov  [eax+120*60],byte 1
2000
    mov  [eax+120*60],byte 1
Line 1745... Line 2001...
1745
 
2001
 
1746
    popa
2002
    popa
Line -... Line 2003...
-
 
2003
    ret
-
 
2004
 
-
 
2005
notify_channel_thread:
-
 
2006
	pusha
-
 
2007
	mov	eax, [text_start]
-
 
2008
	mov	ecx, [eax+120*60+12]
-
 
2009
	mcall	60, 2, , 0, 1
Line 1747... Line 2010...
1747
    ret
2010
	popa
Line 1748... Line 2011...
1748
 
2011
	ret
Line 1758... Line 2021...
1758
 
2021
 
1759
    popa
2022
    popa
Line 1760... Line -...
1760
    ret
-
 
1761
 
-
 
1762
 
-
 
1763
read_incoming_byte:
-
 
1764
 
-
 
1765
    mov  eax, 53
-
 
1766
    mov  ebx, 2
-
 
1767
    mov  ecx, [socket]
-
 
1768
    mcall
-
 
1769
 
-
 
1770
    mov  ecx,-1
-
 
1771
 
-
 
1772
    cmp  eax,0
-
 
1773
    je	 no_more_data
-
 
1774
 
-
 
1775
    mov  eax, 53
-
 
1776
    mov  ebx, 3
-
 
1777
    mov  ecx, [socket]
-
 
1778
    mcall
-
 
1779
 
-
 
1780
	cmp	bl,0x80
-
 
1781
	jb	@f
-
 
1782
	and	ebx,0x7F
-
 
1783
	mov	bl,[cp1251_table+ebx]
-
 
1784
    @@:
-
 
1785
 
-
 
1786
    mov  ecx,0
-
 
1787
 
-
 
1788
  no_more_data:
-
 
1789
 
-
 
Line 1790... Line 2023...
1790
    ret
2023
    ret
Line 1791... Line 2024...
1791
 
2024
 
Line 1792... Line 2025...
1792
 
2025
 
1793
 
2026
 
1794
draw_window:
2027
draw_window:
Line 1795... Line -...
1795
 
-
 
1796
    pusha
-
 
1797
 
2028
 
1798
    mov  eax,12
2029
    pusha
1799
    mov  ebx,1
2030
 
1800
    mcall
2031
    mov  eax,12
1801
 
2032
    mov  ebx,1
1802
    mov  [old_status],300
2033
    mcall
1803
 
2034
 
Line 1804... Line 2035...
1804
    xor  eax,eax		   ; draw window
2035
    xor  eax,eax		   ; draw window
1805
    mov  ebx,5*65536+499
2036
    mov  ebx,5*65536+499
1806
    mov  ecx,5*65536+345
2037
    mov  ecx,5*65536+381
1807
    mov  edx,[wcolor]
2038
    mov  edx,[wcolor]
1808
    add  edx,0x14ffffff
2039
    add  edx,0x14ffffff
1809
    mov  edi,title
2040
    mov  edi,title
Line -... Line 2041...
-
 
2041
    mcall
-
 
2042
 
-
 
2043
    mov  eax,8                     ; button: change encoding
-
 
2044
    mov  ebx,(ENCODING_X-2)*65536+38
-
 
2045
    mov  ecx,(ENCODING_Y-2)*65536+12
-
 
2046
    mov  edx,21
-
 
2047
    mov  esi,[main_button]
1810
    mcall
2048
    mcall
1811
 
2049
 
1812
    mov  eax,8			   ; button: open socket
2050
;    mov  eax,8			   ; button: open socket
1813
    mov  ebx,43*65536+22
2051
    mov  ebx,43*65536+22
-
 
2052
    mov  ecx,241*65536+10
1814
    mov  ecx,229*65536+10
2053
;    mov  edx,22
Line 1815... Line 2054...
1815
    mov  edx,22
2054
    inc  edx
1816
    mov  esi,[main_button]
2055
    mcall
1817
    mcall
2056
 
1818
 
2057
    ;mov  eax,8			   ; button: send userinfo
-
 
2058
    mov  ebx,180*65536+22
1819
    ;mov  eax,8			   ; button: send userinfo
2059
    mov  ecx,241*65536+10
Line 1820... Line 2060...
1820
    mov  ebx,180*65536+22
2060
;    mov  edx,23
1821
    mov  ecx,229*65536+10
2061
    inc  edx
1822
    mov  edx,23
2062
    mcall
Line 1860... Line 2100...
1860
    jne  newline
2100
    jne  newline
Line 1861... Line 2101...
1861
 
2101
 
1862
    mov  edx,I_END		  ; text from server
2102
    mov  edx,I_END		  ; text from server
Line -... Line 2103...
-
 
2103
    call draw_channel_text
-
 
2104
 
1863
    call draw_channel_text
2105
    call print_entry
1864
 
2106
 
1865
    mov  eax,12
2107
    mov  eax,12
Line 1866... Line 2108...
1866
    mov  ebx,2
2108
    mov  ebx,2
Line 1867... Line 2109...
1867
    mcall
2109
    mcall
Line -... Line 2110...
-
 
2110
 
-
 
2111
    popa
-
 
2112
 
-
 
2113
    ret
-
 
2114
 
-
 
2115
update_status:
-
 
2116
	pusha
-
 
2117
	mov	esi, [status]
-
 
2118
	mov	edi, text + 7*70 + 22
-
 
2119
	mov	ecx, status_text_len
-
 
2120
	push	ecx
-
 
2121
	imul	esi, ecx
-
 
2122
	add	esi, status_text
-
 
2123
	mov	edx, edi
-
 
2124
	rep	movsb
-
 
2125
	pop	esi
-
 
2126
	mcall	4, STATUS_X*65536+STATUS_Y, 0x40000000, , , 0xFFFFFF
-
 
2127
	popa
-
 
2128
	ret
-
 
2129
 
-
 
2130
update_encoding:
-
 
2131
	pusha
-
 
2132
	mov	edx, 21
-
 
2133
	mcall	8	; delete button
-
 
2134
	mov	esi, [main_button]
-
 
2135
	mcall	, <(ENCODING_X-2),38>, <(ENCODING_Y-2),12>	; recreate it
-
 
2136
	mov	esi, [encoding]
-
 
2137
	mov	edi, text + 3*70 + 15
-
 
2138
	mov	ecx, encoding_text_len
-
 
2139
	push	ecx
-
 
2140
	imul	esi, ecx
-
 
2141
	add	esi, encoding_text
-
 
2142
	mov	edx, edi
-
 
2143
	rep	movsb
1868
 
2144
	pop	esi
1869
    popa
2145
	mcall	4, ENCODING_X*65536+ENCODING_Y, 0
Line 1870... Line 2146...
1870
 
2146
	popa
Line 1871... Line 2147...
1871
    ret
2147
	ret
1872
 
2148
 
1873
main_line    dd 0x000000
2149
main_line    dd 0x000000
-
 
2150
main_button  dd 0x6565cc
1874
main_button  dd 0x6565cc
2151
 
1875
 
2152
 
-
 
2153
text:
-
 
2154
 
1876
 
2155
db '   Real name : KolibriOS User  - change with eg /areal Jill User      '
1877
text:
2156
db '   Nick      : kolibri_user    - change with eg /anick Jill           '
1878
 
2157
db '   Server    : kolibrios.org   - change with eg /aserv irc.by         '
1879
db '   Real name : KolibriOS User  - change with eg /areal Jill User      '
2158
db '   Encoding  : UTF-8                                                  '
1880
db '   Nick      : kolibri_user    - change with eg /anick Jill           '
2159
db '                                                                      '
1881
db '   Server    : kolibrios.org   - change with eg /aserv irc.by         '
2160
db '        1) Connect             2) Send userinfo       3) Disconnect   '
1882
db '                                                                      '
2161
db '                                                                      '
1883
db '        1) Open socket         2) Send userinfo       Close socket    '
2162
db '   Connection status: disconnected                                    '
Line -... Line 2163...
-
 
2163
db '                                                                      '
-
 
2164
db '   Commands after established connection:                             '
-
 
2165
db '                                                                      '
-
 
2166
db '   /join #ChannelName         - eg /join #general                     '
-
 
2167
db '   /part #ChannelName         - eg /part #windows                     '
-
 
2168
db '   /query Nickname            - eg /query Mary                        '
1884
db '                                                                      '
2169
db '   /quit                      - Quit server and Close socket          '
-
 
2170
db 'x' ; <- END MARKER, DONT DELETE
-
 
2171
 
-
 
2172
status_text:
1885
db '   Commands after established connection:                             '
2173
db	'disconnected            '
-
 
2174
db      'resolving server name...'
Line 1886... Line 2175...
1886
db '                                                                      '
2175
db	'connecting...           '
1887
db '   /join #ChannelName         - eg /join #general                     '
2176
db	'connected               '
1888
db '   /part #ChannelName         - eg /part #windows                     '
2177
status_text_len = 24
1889
db '   /query Nickname            - eg /query Mary                        '
2178
 
Line 1901... Line 2190...
1901
 
2190
 
Line 1902... Line 2191...
1902
 
2191
 
-
 
2192
 
-
 
2193
channel_thread:
-
 
2194
 
1903
 
2195
;    mov   ebp,[thread_nro]
1904
channel_thread:
2196
    pop   ebp
1905
 
2197
    pop   edx
1906
    mov   ebp,[thread_nro]
2198
 
Line 1907... Line 2199...
1907
    mov   eax,ebp
2199
    mov   eax,ebp
1908
    shl   eax,14
2200
    shl   eax,14
1909
    add   eax,0x80000
2201
    add   eax,0x80000
1910
    mov   esp,eax
2202
    mov   esp,eax
1911
 
2203
 
1912
    mov   edi,ebp	 ; clear thread memory
2204
;    mov   edi,ebp	 ; clear thread memory
1913
    imul  edi,120*80
2205
;    imul  edi,120*80
Line -... Line 2206...
-
 
2206
;    add   edi,I_END
-
 
2207
;    mov   ecx,120*80
-
 
2208
;    mov   al,32
-
 
2209
;    cld
-
 
2210
;    rep   stosb
-
 
2211
 
-
 
2212
; Create IPC buffer in the stack.
-
 
2213
	push	eax
-
 
2214
	push	eax
-
 
2215
	push	eax
-
 
2216
	push	8
-
 
2217
	push	0
1914
    add   edi,I_END
2218
	mov	ecx, esp
Line -... Line 2219...
-
 
2219
	push	edx
1915
    mov   ecx,120*80
2220
	mcall	60, 1, , 20
-
 
2221
	pop	edx
-
 
2222
	mcall	40, 1100111b
-
 
2223
 
Line 1916... Line 2224...
1916
    mov   eax,32
2224
;    mov   edx,[thread_screen]
Line 1917... Line 2225...
1917
    cld
2225
 
1918
;    rep   stosb
2226
  thread_redraw:
Line 1935... Line 2243...
1935
    mov  byte  [channel_list+edi+31],byte 1
2243
    mov  byte  [channel_list+edi+31],byte 1
1936
    mov  eax,-1
2244
    mov  eax,-1
1937
    mcall
2245
    mcall
1938
  no_channel_leave:
2246
  no_channel_leave:
Line -... Line 2247...
-
 
2247
 
-
 
2248
    mcall 10
-
 
2249
    dec   eax
-
 
2250
    jz    thread_redraw
-
 
2251
    dec   eax
-
 
2252
    jz    thread_key
-
 
2253
    dec   eax
-
 
2254
    jz    thread_end
-
 
2255
    cmp   al,4
1939
 
2256
    jz    thread_ipc
1940
    call  check_mouse
-
 
1941
 
-
 
1942
    mov   eax,23
-
 
1943
    mov   ebx,1
-
 
1944
    mcall
-
 
1945
 
2257
    call  check_mouse
1946
    cmp   eax,1
-
 
1947
    jne   no_draw_window
-
 
1948
    call  thread_draw_window
-
 
1949
    call  draw_channel_text
-
 
1950
    call  print_user_list
2258
    jmp   w_t
1951
  no_draw_window:
-
 
1952
 
-
 
1953
    cmp   eax,2
-
 
1954
    je	  thread_key
-
 
1955
 
-
 
1956
    cmp   eax,3
-
 
1957
    jne   no_end
2259
  thread_end:
1958
    mov   eax,17
2260
    mov   eax,17
1959
    mcall
2261
    mcall
1960
    mov   eax,ebp
2262
    mov   eax,ebp
1961
    imul  eax,120*80
2263
    imul  eax,120*80
Line 1979... Line 2281...
1979
    cmp   [eax],byte 0
2281
    cmp   [eax],byte 0
1980
    jne   newcc
2282
    jne   newcc
1981
    call  draw_channel_text
2283
    call  draw_channel_text
1982
    jmp   w_t
2284
    jmp   w_t
1983
   nocl:   db  13,10,'To exit channel, use PART or QUIT command.',0
2285
   nocl:   db  13,10,'To exit channel, use PART or QUIT command.',0
-
 
2286
  thread_ipc:
-
 
2287
    mov   byte [esp+4], 8 ; erase message from IPC buffer
1984
   no_end:
2288
   no_end:
Line 1985... Line 2289...
1985
 
2289
 
1986
    cmp   [edx+120*60],byte 1
2290
    cmp   [edx+120*60],byte 1
1987
    jne   no_update
2291
    jne   no_update
1988
    mov   [edx+120*60],byte 0
2292
    mov   [edx+120*60],byte 0
1989
    call  draw_channel_text
2293
    call  draw_channel_text
Line 1990... Line -...
1990
  no_update:
-
 
1991
 
-
 
1992
    test [cursor_on_off],0x3f
-
 
1993
    jnz   nopri2
-
 
1994
 
2294
  no_update:
Line 1995... Line 2295...
1995
    call  blink_cursor
2295
 
Line 1996... Line 2296...
1996
    call  print_user_list
2296
    call  print_user_list
Line 2093... Line 2393...
2093
    cmp  eax,13
2393
    cmp  eax,13
2094
    jne  no_send
2394
    jne  no_send
2095
    cmp  [xpos],0
2395
    cmp  [xpos],0
2096
    je	 no_send
2396
    je	 no_send
2097
    mov  dword [send_to_channel],ebp
2397
    mov  dword [send_to_channel],ebp
-
 
2398
    pusha
2098
    mov  [send_to_server],1
2399
    mcall 60,2,[main_PID],0,1
2099
  wait_for_sending:
2400
  wait_for_sending:
2100
    mov  eax,5
2401
    mov  eax,5
2101
    mov  ebx,1
2402
    mov  ebx,1
2102
    mcall
2403
    mcall
2103
    cmp  [send_to_server],1
2404
    cmp  dword [ipcbuf+4],8
2104
    je	 wait_for_sending
2405
    jne	 wait_for_sending
-
 
2406
    popa
2105
    call draw_channel_text
2407
    call draw_channel_text
2106
    call print_entry
2408
    call print_entry
2107
    jmp  w_t
2409
    jmp  w_t
2108
  no_send:
2410
  no_send:
Line 2263... Line 2565...
2263
cursor_on_off  dd  0x0
2565
cursor_on_off  dd  0x0
Line 2264... Line 2566...
2264
 
2566
 
Line 2265... Line 2567...
2265
max_windows    dd  20
2567
max_windows    dd  20
2266
 
2568
 
2267
thread_stack   dd  0x9fff0
2569
thread_stack   dd  0x9fff0
Line 2268... Line 2570...
2268
thread_nro     dd 1
2570
;thread_nro     dd 1
2269
thread_screen  dd I_END+120*80*1
2571
;thread_screen  dd I_END+120*80*1
Line 2270... Line 2572...
2270
 
2572
 
Line 2328... Line 2630...
2328
wcolor	    dd	0x000000
2630
wcolor	    dd	0x000000
Line 2329... Line 2631...
2329
 
2631
 
2330
labelc	    db	'AIRC - WINDOW X: #xxx                 '
2632
labelc	    db	'AIRC - WINDOW X: #xxx                 '
Line -... Line 2633...
-
 
2633
title	    db	'IRC client ',version,0
-
 
2634
 
-
 
2635
ipcbuf:
-
 
2636
	dd	0
-
 
2637
	dd	8
-
 
2638
	dd	?
-
 
2639
	dd	?
-
 
2640
	db	?
-
 
2641
.size = $
-
 
2642
 
-
 
2643
align 4
-
 
2644
@IMPORT:
-
 
2645
 
-
 
2646
library network, 'network.obj', msgbox, 'msgbox.obj'
-
 
2647
import  network, \
-
 
2648
	getaddrinfo_start,	'getaddrinfo_start',	\
-
 
2649
	getaddrinfo_process,	'getaddrinfo_process',	\
2331
title	    db	'IRC client ',version,0
2650
	getaddrinfo_abort,	'getaddrinfo_abort',	\
2332
 
2651
	freeaddrinfo,		'freeaddrinfo'
-
 
2652
import	msgbox, mb_create, 'mb_create', mb_setfunctions, 'mb_setfunctions'
2333
;include_debug_strings  ; ALWAYS present in data section
2653
 
-
 
2654
msgbox_running	db	?	; must be the byte before msgbox_struct
-
 
2655
				; look to the handler of button 21
-
 
2656
msgbox_struct:
-
 
2657
.default:
-
 
2658
	dw	?	; default button, will be filled with current encoding
-
 
2659
	db	'Encoding',0
-
 
2660
	db	'Select encoding for all messages:',0
-
 
2661
	db	'CP866',0
-
 
2662
	db	'CP1251',0
2334
 
2663
	db	'UTF-8',0
-
 
2664
	db	0
-
 
2665
 
-
 
2666
align 4
-
 
2667
status		dd	STATUS_DISCONNECTED
2335
irc_server_ip db ?  ; bufer for server_IP
2668
encoding	dd	UTF8
-
 
2669
recode_proc	dd	recode_to_cp866, recode_to_cp1251, recode_to_utf8
-
 
2670
get_byte_table	dd	get_byte_cp866, get_byte_cp1251, get_byte_utf8
-
 
2671
msgbox_func_array:
2336
 
2672
times 3		dd	msgbox_notify
-
 
2673
initialized_size:
-
 
2674
 
-
 
2675
main_PID	dd	?	; identifier of main thread
-
 
2676
utf8_bytes_rest	dd	?	; bytes rest in current UTF8 sequence
-
 
2677
utf8_char	dd	?	; first bits of current UTF8 character
-
 
2678
gai_reqdata	rb	32	; buffer for getaddrinfo_start/process
-
 
2679
ip_list		dd	?	; will be filled as pointer to addrinfo list
-
 
2680
irc_server_name	rb	256	; buffer for irc_server_name
Line 2337... Line 2681...
2337
dnsMsg:  rb 512     ; buffer used by DNS client
2681
packetbuf	rb	1024	; buffer for packets to server
2338
 
2682
mb_stack	rb	1024	; stack for messagebox thread
2339
 
2683
 
2340
;;
2684
;;
Line 2346... Line 2690...
2346
;;
2690
;;
2347
;;      00      ,  120*60   window text 120 characters per row
2691
;;      00      ,  120*60   window text 120 characters per row
2348
;;  120*60      ,  1        text is updated
2692
;;  120*60      ,  1        text is updated
2349
;;  120*60+4    ,  1        close yourself
2693
;;  120*60+4    ,  1        close yourself
2350
;;  120*60+8    ,  1        0 = channel window  :  1 = private chat
2694
;;  120*60+8    ,  1        0 = channel window  :  1 = private chat
-
 
2695
;;  120*60+12    , 4        identifier of the thread
2351
;;  120*61      ,  256      channel name
2696
;;  120*61      ,  256      channel name
2352
;;  120*61+254  ,  254      channel entry text from user
2697
;;  120*61+254  ,  254      channel entry text from user
2353
;;  120*61+255  ,  1        length of entry text
2698
;;  120*61+255  ,  1        length of entry text
2354
;;  120*69+248  ,  4        display names from n:th name
2699
;;  120*69+248  ,  4        display names from n:th name
2355
;;  120*69+252  ,  4        length of names string
2700
;;  120*69+252  ,  4        length of names string