Subversion Repositories Kolibri OS

Rev

Rev 1188 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1188 Rev 1315
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                   ;;
2
;;                                                   ;;
3
;;    IRC CLIENT for KolibriOS                       ;;
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
;;    Copyright 2009 (c) CleverMouse                 ;;
8
;;                                                   ;;
8
;;                                                   ;;
9
;;    Compile with FASM for Kolibri                  ;;
9
;;    Compile with FASM for Kolibri                  ;;
10
;;                                                   ;;
10
;;                                                   ;;
11
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
11
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
12
 
12
 
13
version equ '0.6'
13
version equ '0.6'
14
 
14
 
15
 
15
 
16
;__DEBUG__ equ 1
16
;__DEBUG__ equ 1
17
;__DEBUG_LEVEL__ equ 1
17
;__DEBUG_LEVEL__ equ 1
18
 
18
 
19
use32
19
use32
20
 
20
 
21
		org	0x0
21
		org	0x0
22
 
22
 
23
		db	'MENUET01'		; 8 byte id
23
		db	'MENUET01'		; 8 byte id
24
		dd	0x01			; required os
24
		dd	0x01			; required os
25
		dd	START			; program start
25
		dd	START			; program start
26
		dd	initialized_size	; program image size
26
		dd	initialized_size	; program image size
27
		dd	0x100000		; required amount of memory
27
		dd	0x100000		; required amount of memory
28
		dd	0x100000
28
		dd	0x100000
29
		dd	0,0
29
		dd	0,0
30
 
30
 
31
include "../../../macros.inc"
31
include "../../../macros.inc"
32
include "../../../proc32.inc"
32
include "../../../proc32.inc"
33
include "../../../develop/libraries/network/network.inc"
33
include "../../../develop/libraries/network/network.inc"
34
include "dll.inc"
34
include "dll.inc"
35
;include "fdo.inc"
35
;include "fdo.inc"
36
include "eth.inc"
36
include "eth.inc"
37
;include "lang.inc"
37
;include "lang.inc"
38
 
38
 
39
; connection statuses
39
; connection statuses
40
STATUS_DISCONNECTED = 0 ; disconnected
40
STATUS_DISCONNECTED = 0 ; disconnected
41
STATUS_RESOLVING    = 1 ; resolving server name
41
STATUS_RESOLVING    = 1 ; resolving server name
42
STATUS_CONNECTING   = 2 ; connecting to server
42
STATUS_CONNECTING   = 2 ; connecting to server
43
STATUS_CONNECTED    = 3 ; connected
43
STATUS_CONNECTED    = 3 ; connected
44
; where to display status
44
; where to display status
45
STATUS_X = 25 + 22*6
45
STATUS_X = 25 + 22*6
46
STATUS_Y = 183 + 7*12
46
STATUS_Y = 183 + 7*12
47
 
47
 
48
; supported encodings
48
; supported encodings
49
CP866 = 0
49
CP866 = 0
50
CP1251 = 1
50
CP1251 = 1
51
UTF8 = 2
51
UTF8 = 2
52
; where to display encoding
52
; where to display encoding
53
ENCODING_X = 25 + 15*6
53
ENCODING_X = 25 + 15*6
54
ENCODING_Y = 183 + 3*12
54
ENCODING_Y = 183 + 3*12
55
 
55
 
56
def_server_name db      'kolibrios.org',0                 ; default server name
56
def_server_name db      'kolibrios.org',0                 ; default server name
57
 
57
 
58
user_nick	dd	12				  ; length
58
user_nick	dd	12				  ; length
59
		db	'kolibri_user           '	  ; string
59
		db	'kolibri_user           '	  ; string
60
user_nick_max = $ - user_nick - 4
60
user_nick_max = $ - user_nick - 4
61
 
61
 
62
user_real_name	dd	14				  ; length
62
user_real_name	dd	14				  ; length
63
		db	'KolibriOS User         '	  ; string
63
		db	'KolibriOS User         '	  ; string
64
user_real_name_max = $ - user_real_name - 4
64
user_real_name_max = $ - user_real_name - 4
65
 
65
 
66
 
66
 
67
START:				; start of execution
67
START:				; start of execution
68
 
68
 
69
    stdcall dll.Load, @IMPORT
69
    stdcall dll.Load, @IMPORT
70
    test eax,eax
70
    test eax,eax
71
    jnz  exit
71
    jnz  exit
72
 
72
 
73
    mov  eax,40
73
    mov  eax,40
74
    mov  ebx,11000111b
74
    mov  ebx,11000111b
75
    mcall
75
    mcall
76
    mcall 60, 1, ipcbuf, ipcbuf.size
76
    mcall 60, 1, ipcbuf, ipcbuf.size
77
    mcall 9, 0xe0000, -1
77
    mcall 9, 0xe0000, -1
78
    mov  eax,[ebx+process_information.PID]
78
    mov  eax,[ebx+process_information.PID]
79
    mov  [main_PID],eax
79
    mov  [main_PID],eax
80
 
80
 
81
	mov	esi, def_server_name
81
	mov	esi, def_server_name
82
	mov	edi, irc_server_name
82
	mov	edi, irc_server_name
83
@@:
83
@@:
84
	lodsb
84
	lodsb
85
	stosb
85
	stosb
86
	test	al, al
86
	test	al, al
87
	jnz	@b
87
	jnz	@b
88
 
88
 
89
    mov  edi,I_END
89
    mov  edi,I_END
90
    mov  ecx,60*120
90
    mov  ecx,60*120
91
    mov  al,32
91
    mov  al,32
92
    cld
92
    cld
93
    rep  stosb
93
    rep  stosb
94
 
94
 
95
    mov  eax,[rxs]
95
    mov  eax,[rxs]
96
    imul eax,11
96
    imul eax,11
97
    mov  [pos],eax
97
    mov  [pos],eax
98
 
98
 
99
    mov  ebp,0
99
    mov  ebp,0
100
    mov  edx,I_END
100
    mov  edx,I_END
101
 
101
 
102
redraw: 			; redraw
102
redraw: 			; redraw
103
    call draw_window		; at first, draw the window
103
    call draw_window		; at first, draw the window
104
 
104
 
105
still:
105
still:
106
 
106
 
107
    mov  eax,10                 ; wait here for event
107
    mov  eax,10                 ; wait here for event
108
    mcall
108
    mcall
109
 
109
 
110
    dec  eax                    ; redraw
110
    dec  eax                    ; redraw
111
    je	 redraw
111
    je	 redraw
112
    dec  eax			; key
112
    dec  eax			; key
113
    je	 main_window_key
113
    je	 main_window_key
114
    dec  eax			; button
114
    dec  eax			; button
115
    je	 button
115
    je	 button
116
    cmp  al,4
116
    cmp  al,4
117
    jz   ipc
117
    jz   ipc
118
 
118
 
119
    call process_network_event
119
    call process_network_event
120
 
120
 
121
    cmp  [I_END+120*60],byte 1
121
    cmp  [I_END+120*60],byte 1
122
    jne  no_main_update
122
    jne  no_main_update
123
    mov  [I_END+120*60],byte 0
123
    mov  [I_END+120*60],byte 0
124
    mov  edx,I_END
124
    mov  edx,I_END
125
    call draw_channel_text
125
    call draw_channel_text
126
  no_main_update:
126
  no_main_update:
127
 
127
 
128
    call print_channel_list
128
    call print_channel_list
129
 
129
 
130
    jmp  still
130
    jmp  still
131
 
131
 
132
button: 			; button
132
button: 			; button
133
 
133
 
134
    mov  eax,17 		; get id
134
    mov  eax,17 		; get id
135
    mcall
135
    mcall
136
 
136
 
137
    cmp  ah,1			; close program
137
    cmp  ah,1			; close program
138
    jne  noclose
138
    jne  noclose
139
exit:
139
exit:
140
    or   eax,-1
140
    or   eax,-1
141
    mcall
141
    mcall
142
  noclose:
142
  noclose:
143
    cmp  ah,21
143
    cmp  ah,21
144
    jne  no_change_encoding
144
    jne  no_change_encoding
145
    cmp  byte[edx-1],0
145
    cmp  byte[edx-1],0
146
    jnz  still
146
    jnz  still
147
    mov  eax,[encoding]
147
    mov  eax,[encoding]
148
    inc  eax
148
    inc  eax
149
    mov  edx,msgbox_struct
149
    mov  edx,msgbox_struct
150
    mov  byte[edx],al
150
    mov  byte[edx],al
151
    mov  byte[edx-1],1 ; msgbox is running
151
    mov  byte[edx-1],1 ; msgbox is running
152
    push mb_stack
152
    push mb_stack
153
    push edx
153
    push edx
154
    call [mb_create]
154
    call [mb_create]
155
    push msgbox_func_array
155
    push msgbox_func_array
156
    call [mb_setfunctions]
156
    call [mb_setfunctions]
157
    jmp  still
157
    jmp  still
158
  no_change_encoding:
158
  no_change_encoding:
159
 
159
 
160
    call socket_commands
160
    call socket_commands
161
 
161
 
162
    jmp  still
162
    jmp  still
163
 
163
 
164
ipc:
164
ipc:
165
    mov  edx,msgbox_struct
165
    mov  edx,msgbox_struct
166
    cmp  byte[edx-1],0
166
    cmp  byte[edx-1],0
167
    jz   @f
167
    jz   @f
168
    mov  byte[edx-1],0
168
    mov  byte[edx-1],0
169
    mov  al,[edx]
169
    mov  al,[edx]
170
    dec  eax
170
    dec  eax
171
    mov  byte[encoding],al
171
    mov  byte[encoding],al
172
    call update_encoding
172
    call update_encoding
173
    jmp  ipc_done
173
    jmp  ipc_done
174
@@:
174
@@:
175
    call process_command
175
    call process_command
176
ipc_done:
176
ipc_done:
177
    mov  dword [ipcbuf+4], 8
177
    mov  dword [ipcbuf+4], 8
178
    jmp  still
178
    jmp  still
179
 
179
 
180
main_window_key:
180
main_window_key:
181
 
181
 
182
    mov  eax,2
182
    mov  eax,2
183
    mcall
183
    mcall
184
 
184
 
185
    shr  eax,8
185
    shr  eax,8
186
 
186
 
187
    cmp  eax,8
187
    cmp  eax,8
188
    jne  no_bks2
188
    jne  no_bks2
189
    cmp  [xpos],0
189
    cmp  [xpos],0
190
    je	 still
190
    je	 still
191
    dec  [xpos]
191
    dec  [xpos]
192
    call print_entry
192
    call print_entry
193
    jmp  still
193
    jmp  still
194
   no_bks2:
194
   no_bks2:
195
 
195
 
196
    cmp  eax,20
196
    cmp  eax,20
197
    jbe  no_character2
197
    jbe  no_character2
198
    mov  ebx,[xpos]
198
    mov  ebx,[xpos]
199
    mov  [send_string+ebx],al
199
    mov  [send_string+ebx],al
200
    inc  [xpos]
200
    inc  [xpos]
201
    cmp  [xpos],80
201
    cmp  [xpos],80
202
    jb	 noxposdec
202
    jb	 noxposdec
203
    mov  [xpos],79
203
    mov  [xpos],79
204
  noxposdec:
204
  noxposdec:
205
    call print_entry
205
    call print_entry
206
    jmp  still
206
    jmp  still
207
  no_character2:
207
  no_character2:
208
 
208
 
209
    cmp  eax,13
209
    cmp  eax,13
210
    jne  no_send2
210
    jne  no_send2
211
    cmp  [xpos],0
211
    cmp  [xpos],0
212
    je	 no_send2
212
    je	 no_send2
213
    cmp  [send_string],byte '/'   ; server command
213
    cmp  [send_string],byte '/'   ; server command
214
    jne  no_send2
214
    jne  no_send2
215
    call process_command
215
    call process_command
216
    jmp  still
216
    jmp  still
217
  no_send2:
217
  no_send2:
218
 
218
 
219
    jmp  still
219
    jmp  still
220
 
220
 
221
 
221
 
222
socket_commands:
222
socket_commands:
223
 
223
 
224
    cmp  ah,22	     ; connect
224
    cmp  ah,22	     ; connect
225
    jnz  tst3
225
    jnz  tst3
226
 
226
 
227
; ignore if status is not "disconnected"
227
; ignore if status is not "disconnected"
228
	cmp	[status], STATUS_DISCONNECTED
228
	cmp	[status], STATUS_DISCONNECTED
229
	jnz	.nothing
229
	jnz	.nothing
230
 
230
 
231
; start name resolving
231
; start name resolving
232
	inc	[status]	; was STATUS_DISCONNECTED, now STATUS_RESOLVING
232
	inc	[status]	; was STATUS_DISCONNECTED, now STATUS_RESOLVING
233
	push	gai_reqdata
233
	push	gai_reqdata
234
	push	ip_list
234
	push	ip_list
235
	push	0
235
	push	0
236
	push	0
236
	push	0
237
	push	irc_server_name
237
	push	irc_server_name
238
	call	[getaddrinfo_start]
238
	call	[getaddrinfo_start]
239
	test	eax, eax
239
	test	eax, eax
240
	jns	getaddrinfo_done
240
	jns	getaddrinfo_done
241
	call	update_status
241
	call	update_status
242
.nothing:
242
.nothing:
243
	ret
243
	ret
244
 
244
 
245
  tst3:
245
  tst3:
246
 
246
 
247
 
247
 
248
    cmp  ah,23	      ; write userinfo
248
    cmp  ah,23	      ; write userinfo
249
    jnz  tst4
249
    jnz  tst4
250
 
250
 
251
; ignore if status is not "connected"
251
; ignore if status is not "connected"
252
	cmp	[status], STATUS_CONNECTED
252
	cmp	[status], STATUS_CONNECTED
253
	jnz	.nothing
253
	jnz	.nothing
254
 
254
 
255
; create packet in packetbuf
255
; create packet in packetbuf
256
	mov	edi, packetbuf
256
	mov	edi, packetbuf
257
	mov	edx, edi
257
	mov	edx, edi
258
	mov	esi, string0
258
	mov	esi, string0
259
	mov	ecx, string0l-string0
259
	mov	ecx, string0l-string0
260
	rep	movsb
260
	rep	movsb
261
	mov	esi, user_real_name+4
261
	mov	esi, user_real_name+4
262
	mov	ecx, [esi-4]
262
	mov	ecx, [esi-4]
263
	rep	movsb
263
	rep	movsb
264
	mov	al, 13
264
	mov	al, 13
265
	stosb
265
	stosb
266
	mov	al, 10
266
	mov	al, 10
267
	stosb
267
	stosb
268
	mov	esi, string1
268
	mov	esi, string1
269
	mov	ecx, string1l-string1
269
	mov	ecx, string1l-string1
270
	rep	movsb
270
	rep	movsb
271
	mov	esi, user_nick+4
271
	mov	esi, user_nick+4
272
	mov	ecx, [esi-4]
272
	mov	ecx, [esi-4]
273
	rep	movsb
273
	rep	movsb
274
	mov	al, 13
274
	mov	al, 13
275
	stosb
275
	stosb
276
	mov	al, 10
276
	mov	al, 10
277
	stosb
277
	stosb
278
; send packet
278
; send packet
279
	xchg	edx, edi
279
	xchg	edx, edi
280
	sub	edx, edi
280
	sub	edx, edi
281
	mov	esi, edi
281
	mov	esi, edi
282
	mcall	53, 7, [socket]
282
	mcall	53, 7, [socket]
283
    .nothing:
283
    .nothing:
284
	ret
284
	ret
285
 
285
 
286
  tst4:
286
  tst4:
287
 
287
 
288
 
288
 
289
    cmp  ah,24	   ; close socket
289
    cmp  ah,24	   ; close socket
290
    jz   disconnect
290
    jz   disconnect
291
  no_24:
291
  no_24:
292
 
292
 
293
 
293
 
294
    ret
294
    ret
295
 
295
 
296
getaddrinfo_done:
296
getaddrinfo_done:
297
; The address resolving is done.
297
; The address resolving is done.
298
; If eax is zero, address is resolved, otherwise there was some problems.
298
; If eax is zero, address is resolved, otherwise there was some problems.
299
	test	eax, eax
299
	test	eax, eax
300
	jz	.good
300
	jz	.good
301
.disconnect:
301
.disconnect:
302
; Change status to "disconnected" and return.
302
; Change status to "disconnected" and return.
303
	and	[status], 0
303
	and	[status], 0
304
	call	update_status
304
	call	update_status
305
	ret
305
	ret
306
.good:
306
.good:
307
; We got a list of IP addresses. Try to connect to first of them.
307
; We got a list of IP addresses. Try to connect to first of them.
308
	mov	eax, [ip_list]
308
	mov	eax, [ip_list]
309
	mov	esi, [eax + addrinfo.ai_addr]
309
	mov	esi, [eax + addrinfo.ai_addr]
310
	mov	esi, [esi + sockaddr_in.sin_addr]
310
	mov	esi, [esi + sockaddr_in.sin_addr]
311
	push	eax
311
	push	eax
312
	call	[freeaddrinfo]
312
	call	[freeaddrinfo]
313
	mcall	53, 5, 0, 6667, , 1
313
	mcall	53, 5, 0, 6667, , 1
314
	cmp	eax, -1
314
	cmp	eax, -1
315
	jz	.disconnect
315
	jz	.disconnect
316
; Socket has been opened. Save handle and change status to "connecting".
316
; Socket has been opened. Save handle and change status to "connecting".
317
	mov	[socket], eax
317
	mov	[socket], eax
318
	inc	[status]	; was STATUS_RESOLVING, now STATUS_CONNECTING
318
	inc	[status]	; was STATUS_RESOLVING, now STATUS_CONNECTING
319
	call	update_status
319
	call	update_status
320
	ret
320
	ret
321
 
321
 
322
process_network_event:
322
process_network_event:
323
; values for status: 0, 1, 2, 3
323
; values for status: 0, 1, 2, 3
324
	mov	eax, [status]
324
	mov	eax, [status]
325
	dec	eax
325
	dec	eax
326
; 0 = STATUS_DISCONNECTED - do nothing
326
; 0 = STATUS_DISCONNECTED - do nothing
327
; (ignore network events if we are disconnected from network)
327
; (ignore network events if we are disconnected from network)
328
	js	.nothing
328
	js	.nothing
329
; 1 = STATUS_RESOLVING
329
; 1 = STATUS_RESOLVING
330
	jz	.resolving
330
	jz	.resolving
331
; 2 = STATUS_CONNECTING
331
; 2 = STATUS_CONNECTING
332
	dec	eax
332
	dec	eax
333
	jz	.connecting
333
	jz	.connecting
334
; 3 = STATUS_CONNECTED
334
; 3 = STATUS_CONNECTED
335
	jmp	.connected
335
	jmp	.connected
336
.resolving:
336
.resolving:
337
; We are inside address resolving. Let the network library work.
337
; We are inside address resolving. Let the network library work.
338
	push	ip_list
338
	push	ip_list
339
	push	gai_reqdata
339
	push	gai_reqdata
340
	call	[getaddrinfo_process]
340
	call	[getaddrinfo_process]
341
; Negative returned value means that the resolving is not yet finished,
341
; Negative returned value means that the resolving is not yet finished,
342
; and we continue the loop without status change.
342
; and we continue the loop without status change.
343
; Zero and positive values are handled by getaddrinfo_done.
343
; Zero and positive values are handled by getaddrinfo_done.
344
	test	eax, eax
344
	test	eax, eax
345
	jns	getaddrinfo_done
345
	jns	getaddrinfo_done
346
.nothing:
346
.nothing:
347
	ret
347
	ret
348
.connecting:
348
.connecting:
349
; We are connecting to the server, and socket status has changed.
349
; We are connecting to the server, and socket status has changed.
350
	mcall	53, 6, [socket]
350
	mcall	53, 6, [socket]
351
; Possible values for status: SYN_SENT=2, SYN_RECEIVED=3, ESTABLISHED=4, CLOSE_WAIT=7
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
352
; First two mean that we are still connecting, and we must continue wait loop
353
; without status change.
353
; without status change.
354
; Last means that server has immediately closed the connection,
354
; Last means that server has immediately closed the connection,
355
; and status becomes "disconnected".
355
; and status becomes "disconnected".
356
	cmp	eax, 4
356
	cmp	eax, 4
357
	jb	.nothing
357
	jb	.nothing
358
	jz	.established
358
	jz	.established
359
	and	[status], 0
359
	and	[status], 0
360
	call	update_status
360
	call	update_status
361
; close socket
361
; close socket
362
	mcall	53, 8
362
	mcall	53, 8
363
	ret
363
	ret
364
.established:
364
.established:
365
; The connection has been established, change status from "connecting" to "connected".
365
; The connection has been established, change status from "connecting" to "connected".
366
	inc	[status]
366
	inc	[status]
367
	call	update_status
367
	call	update_status
368
; Fall through to .connected, because some data can be already in buffer.
368
; Fall through to .connected, because some data can be already in buffer.
369
.connected:
369
.connected:
370
	call	read_incoming_data
370
	call	read_incoming_data
371
; Handle closing socket by the server.
371
; Handle closing socket by the server.
372
	mcall	53, 6, [socket]
372
	mcall	53, 6, [socket]
373
	cmp	eax, 4
373
	cmp	eax, 4
374
	jnz	disconnect
374
	jnz	disconnect
375
	ret
375
	ret
376
 
376
 
377
disconnect:
377
disconnect:
378
; Release all allocated resources.
378
; Release all allocated resources.
379
; Exact actions depend on current status.
379
; Exact actions depend on current status.
380
	mov	eax, [status]
380
	mov	eax, [status]
381
	dec	eax
381
	dec	eax
382
; 0 = STATUS_DISCONNECTED - do nothing
382
; 0 = STATUS_DISCONNECTED - do nothing
383
	js	.nothing
383
	js	.nothing
384
; 1 = STATUS_RESOLVING
384
; 1 = STATUS_RESOLVING
385
	jz	.resolving
385
	jz	.resolving
386
; 2 = STATUS_CONNECTING, 3 = STATUS_CONNECTED
386
; 2 = STATUS_CONNECTING, 3 = STATUS_CONNECTED
387
; In both cases we should close the socket.
387
; In both cases we should close the socket.
388
	mcall	53, 8, [socket]
388
	mcall	53, 8, [socket]
389
	jmp	.disconnected
389
	jmp	.disconnected
390
.resolving:
390
.resolving:
391
; Let the network library handle abort of resolving process.
391
; Let the network library handle abort of resolving process.
392
	push	gai_reqdata
392
	push	gai_reqdata
393
	call	[getaddrinfo_abort]
393
	call	[getaddrinfo_abort]
394
.disconnected:
394
.disconnected:
395
; In all cases, set status to "disconnected".
395
; In all cases, set status to "disconnected".
396
	and	[status], 0
396
	and	[status], 0
397
	call	update_status
397
	call	update_status
398
.nothing:
398
.nothing:
399
	ret
399
	ret
400
 
400
 
401
msgbox_notify:
401
msgbox_notify:
402
	inc	byte [msgbox_running]
402
	inc	byte [msgbox_running]
403
	mcall	60,2,[main_PID],0,1
403
	mcall	60,2,[main_PID],0,1
404
	ret
404
	ret
405
 
405
 
406
print_channel_list:
406
print_channel_list:
407
 
407
 
408
    pusha
408
    pusha
409
 
409
 
410
    mov  eax,13
410
    mov  eax,13
411
    mov  ebx,415*65536+6*13
411
    mov  ebx,415*65536+6*13
412
    mov  ecx,27*65536+12*10
412
    mov  ecx,27*65536+12*10
413
    mov  edx,0xffffff
413
    mov  edx,0xffffff
414
    mcall
414
    mcall
415
 
415
 
416
    mov  eax,4
416
    mov  eax,4
417
    mov  ebx,415*65536+27
417
    mov  ebx,415*65536+27
418
    mov  ecx,[index_list_1]
418
    mov  ecx,[index_list_1]
419
    mov  edx,channel_list+32
419
    mov  edx,channel_list+32
420
  newch:
420
  newch:
421
    movzx esi,byte [edx+31]
421
    movzx esi,byte [edx+31]
422
    and  esi,0x1f
422
    and  esi,0x1f
423
    mcall
423
    mcall
424
    add  edx,32
424
    add  edx,32
425
    add  ebx,12
425
    add  ebx,12
426
    cmp  edx,channel_list+32*10
426
    cmp  edx,channel_list+32*10
427
    jbe  newch
427
    jbe  newch
428
 
428
 
429
  no_channel_list:
429
  no_channel_list:
430
 
430
 
431
    popa
431
    popa
432
 
432
 
433
    ret
433
    ret
434
 
434
 
435
 
435
 
436
print_user_list:
436
print_user_list:
437
 
437
 
438
    pusha
438
    pusha
439
 
439
 
440
  newtry:
440
  newtry:
441
 
441
 
442
    mov  edx,ebp
442
    mov  edx,ebp
443
    imul edx,120*80
443
    imul edx,120*80
444
    add  edx,120*60+8+I_END
444
    add  edx,120*60+8+I_END
445
    cmp  [edx],byte 1
445
    cmp  [edx],byte 1
446
    je	 nonp
446
    je	 nonp
447
 
447
 
448
    mov  edx,ebp
448
    mov  edx,ebp
449
    imul edx,120*80
449
    imul edx,120*80
450
    add  edx,120*70+I_END
450
    add  edx,120*70+I_END
451
    mov  edi,edx
451
    mov  edi,edx
452
 
452
 
453
    mov  eax,[edx-8]
453
    mov  eax,[edx-8]
454
    mov  ebx,[edx-4]
454
    mov  ebx,[edx-4]
455
    add  ebx,edx
455
    add  ebx,edx
456
    sub  ebx,3
456
    sub  ebx,3
457
    inc  eax
457
    inc  eax
458
    dec  edx
458
    dec  edx
459
  newnss:
459
  newnss:
460
    inc  edx
460
    inc  edx
461
    dec  eax
461
    dec  eax
462
    jz	 startuu
462
    jz	 startuu
463
  asdf:
463
  asdf:
464
    cmp  [edx],word '  '
464
    cmp  [edx],word '  '
465
    jne  nodouble
465
    jne  nodouble
466
    inc  edx
466
    inc  edx
467
  nodouble:
467
  nodouble:
468
    cmp  [edx],byte ' '
468
    cmp  [edx],byte ' '
469
    je	 newnss
469
    je	 newnss
470
    inc  edx
470
    inc  edx
471
    cmp  edx,ebx
471
    cmp  edx,ebx
472
    jbe  asdf
472
    jbe  asdf
473
    dec  dword [edi-8]
473
    dec  dword [edi-8]
474
 
474
 
475
    popa
475
    popa
476
    ret
476
    ret
477
 
477
 
478
  startuu:
478
  startuu:
479
 
479
 
480
    cmp  [edx],byte ' '
480
    cmp  [edx],byte ' '
481
    jne  startpr
481
    jne  startpr
482
    inc  edx
482
    inc  edx
483
  startpr:
483
  startpr:
484
 
484
 
485
    pusha
485
    pusha
486
    mov  eax,13
486
    mov  eax,13
487
    mov  ebx,415*65536+6*13
487
    mov  ebx,415*65536+6*13
488
    mov  ecx,27*65536+12*10
488
    mov  ecx,27*65536+12*10
489
    mov  edx,0xffffff
489
    mov  edx,0xffffff
490
    mcall
490
    mcall
491
    popa
491
    popa
492
 
492
 
493
    mov  eax,4
493
    mov  eax,4
494
    mov  ebx,415*65536+27
494
    mov  ebx,415*65536+27
495
 
495
 
496
    mov  ebp,0
496
    mov  ebp,0
497
  newuser:
497
  newuser:
498
 
498
 
499
    mov  esi,0
499
    mov  esi,0
500
  newusers:
500
  newusers:
501
    cmp  [edx+esi],byte ' '
501
    cmp  [edx+esi],byte ' '
502
    je	 do_print
502
    je	 do_print
503
    inc  esi
503
    inc  esi
504
    cmp  esi,20
504
    cmp  esi,20
505
    jbe  newusers
505
    jbe  newusers
506
  do_print:
506
  do_print:
507
 
507
 
508
    mov  ecx,[index_list_1]
508
    mov  ecx,[index_list_1]
509
    cmp  [edx],byte '@'
509
    cmp  [edx],byte '@'
510
    jne  no_op
510
    jne  no_op
511
    mov  ecx,[index_list_2]
511
    mov  ecx,[index_list_2]
512
  no_op:
512
  no_op:
513
 
513
 
514
    mcall
514
    mcall
515
 
515
 
516
    inc  ebp
516
    inc  ebp
517
    cmp  ebp,10
517
    cmp  ebp,10
518
    je	 nonp
518
    je	 nonp
519
 
519
 
520
    add  ebx,12
520
    add  ebx,12
521
 
521
 
522
    add  edx,esi
522
    add  edx,esi
523
 
523
 
524
    inc  edx
524
    inc  edx
525
    cmp  [edx],byte ' '
525
    cmp  [edx],byte ' '
526
    jne  newuser
526
    jne  newuser
527
    inc  edx
527
    inc  edx
528
    jmp  newuser
528
    jmp  newuser
529
 
529
 
530
  nonp:
530
  nonp:
531
 
531
 
532
    popa
532
    popa
533
 
533
 
534
    ret
534
    ret
535
 
535
 
536
 
536
 
537
start_user_list_at dd 0x0
537
start_user_list_at dd 0x0
538
 
538
 
539
recode_to_cp866:
539
recode_to_cp866:
540
	rep	movsb
540
	rep	movsb
541
	ret
541
	ret
542
 
542
 
543
recode_to_cp1251:
543
recode_to_cp1251:
544
	xor	eax, eax
544
	xor	eax, eax
545
	jecxz	.nothing
545
	jecxz	.nothing
546
  .loop:
546
  .loop:
547
	lodsb
547
	lodsb
548
	cmp	al,0x80
548
	cmp	al,0x80
549
	jb	@f
549
	jb	@f
550
	mov	al,[cp866_table-0x80+eax]
550
	mov	al,[cp866_table-0x80+eax]
551
    @@: stosb
551
    @@: stosb
552
	loop	.loop
552
	loop	.loop
553
  .nothing:
553
  .nothing:
554
	ret
554
	ret
555
 
555
 
556
recode_to_utf8:
556
recode_to_utf8:
557
	jecxz	.nothing
557
	jecxz	.nothing
558
  .loop:
558
  .loop:
559
	lodsb
559
	lodsb
560
	cmp	al, 0x80
560
	cmp	al, 0x80
561
	jb	.single_byte
561
	jb	.single_byte
562
	and	eax, 0x7F
562
	and	eax, 0x7F
563
	mov	ax, [utf8_table+eax*2]
563
	mov	ax, [utf8_table+eax*2]
564
	stosw
564
	stosw
565
	loop	.loop
565
	loop	.loop
566
	ret
566
	ret
567
  .single_byte:
567
  .single_byte:
568
	stosb
568
	stosb
569
	loop	.loop
569
	loop	.loop
570
  .nothing:
570
  .nothing:
571
	ret
571
	ret
572
 
572
 
573
recode:
573
recode:
574
	mov	eax, [encoding]
574
	mov	eax, [encoding]
575
	jmp	[recode_proc+eax*4]
575
	jmp	[recode_proc+eax*4]
576
 
576
 
577
process_command:
577
process_command:
578
 
578
 
579
    pusha
579
    pusha
580
 
580
 
581
    mov  eax,[xpos]
581
    mov  eax,[xpos]
582
    mov  [send_string+eax+0],byte 13
582
    mov  [send_string+eax+0],byte 13
583
    mov  [send_string+eax+1],byte 10
583
    mov  [send_string+eax+1],byte 10
584
 
584
 
585
    mov  eax,[rxs]
585
    mov  eax,[rxs]
586
    imul eax,11
586
    imul eax,11
587
    mov  [pos],eax
587
    mov  [pos],eax
588
    mov  eax,[send_to_channel]
588
    mov  eax,[send_to_channel]
589
    imul eax,120*80
589
    imul eax,120*80
590
    add  eax,I_END
590
    add  eax,I_END
591
    mov  [text_start],eax
591
    mov  [text_start],eax
592
 
592
 
593
    cmp  [send_string],byte '/'   ; server command
593
    cmp  [send_string],byte '/'   ; server command
594
    je	 server_command
594
    je	 server_command
595
 
595
 
596
; Ignore data commands when not connected.
596
; Ignore data commands when not connected.
597
	cmp	[status], STATUS_CONNECTED
597
	cmp	[status], STATUS_CONNECTED
598
	jnz	sdts_ret
598
	jnz	sdts_ret
599
 
599
 
600
    mov  bl,13
600
    mov  bl,13
601
    call print_character
601
    call print_character
602
    mov  bl,10
602
    mov  bl,10
603
    call print_character
603
    call print_character
604
    mov  bl,'<'
604
    mov  bl,'<'
605
    call print_character
605
    call print_character
606
 
606
 
607
    mov  esi,user_nick+4
607
    mov  esi,user_nick+4
608
    mov  ecx,[user_nick]
608
    mov  ecx,[user_nick]
609
  newnp:
609
  newnp:
610
    mov  bl,[esi]
610
    mov  bl,[esi]
611
    call print_character
611
    call print_character
612
    inc  esi
612
    inc  esi
613
    loop newnp
613
    loop newnp
614
 
614
 
615
    mov  bl,'>'
615
    mov  bl,'>'
616
    call print_character
616
    call print_character
617
    mov  bl,' '
617
    mov  bl,' '
618
    call print_character
618
    call print_character
619
 
619
 
620
    mov  ecx,[xpos]
620
    mov  ecx,[xpos]
621
    mov  esi,send_string
621
    mov  esi,send_string
622
  newcw:
622
  newcw:
623
    mov  bl,[esi]
623
    mov  bl,[esi]
624
    call print_character
624
    call print_character
625
    inc  esi
625
    inc  esi
626
    loop newcw
626
    loop newcw
627
 
627
 
628
    mov  eax,dword [send_to_channel]
628
    mov  eax,dword [send_to_channel]
629
    shl  eax,5
629
    shl  eax,5
630
    add  eax,channel_list
630
    add  eax,channel_list
631
    mov  esi,eax
631
    mov  esi,eax
632
 
632
 
633
    mov  edi,send_string_header+8
633
    mov  edi,send_string_header+8
634
    movzx ecx,byte [eax+31]
634
    movzx ecx,byte [eax+31]
635
    cld
635
    cld
636
    rep  movsb
636
    rep  movsb
637
 
637
 
638
    mov  [edi],word ' :'
638
    mov  [edi],word ' :'
639
 
639
 
640
    mov   esi, send_string_header
640
    mov   esi, send_string_header
641
    mov   ecx,10
641
    mov   ecx,10
642
    movzx ebx,byte [eax+31]
642
    movzx ebx,byte [eax+31]
643
    add   ecx,ebx
643
    add   ecx,ebx
644
 
644
 
645
    mov   edi, packetbuf
645
    mov   edi, packetbuf
646
    rep   movsb
646
    rep   movsb
647
 
647
 
648
    mov  esi,send_string
648
    mov  esi,send_string
649
    mov  ecx,[xpos]
649
    mov  ecx,[xpos]
650
    inc  ecx
650
    inc  ecx
651
 
651
 
652
	call	recode
652
	call	recode
653
 
653
 
654
	mov	esi, packetbuf
654
	mov	esi, packetbuf
655
	mov	edx, edi
655
	mov	edx, edi
656
	sub	edx, esi
656
	sub	edx, esi
657
	mcall	53, 7, [socket]
657
	mcall	53, 7, [socket]
658
 
658
 
659
	mov	[xpos], 0
659
	mov	[xpos], 0
660
    jmp  sdts_ret
660
    jmp  sdts_ret
661
 
661
 
662
  server_command:
662
  server_command:
663
 
663
 
664
    cmp  [send_string+1],dword 'anic'
664
    cmp  [send_string+1],dword 'anic'
665
    jne  no_set_nick
665
    jne  no_set_nick
666
 
666
 
667
    mov  ecx,[xpos]
667
    mov  ecx,[xpos]
668
    sub  ecx,7
668
    sub  ecx,7
669
    cmp  ecx,user_nick_max
669
    cmp  ecx,user_nick_max
670
    jb   @f
670
    jb   @f
671
    mov  ecx,user_nick_max
671
    mov  ecx,user_nick_max
672
  @@:
672
  @@:
673
    mov  [user_nick],ecx
673
    mov  [user_nick],ecx
674
 
674
 
675
    mov  esi,send_string+7
675
    mov  esi,send_string+7
676
    mov  edi,user_nick+4
676
    mov  edi,user_nick+4
677
    cld
677
    cld
678
    rep  movsb
678
    rep  movsb
679
 
679
 
680
    pusha
680
    pusha
681
    mov  edi,text+70*1+15
681
    mov  edi,text+70*1+15
682
    mov  al,32
682
    mov  al,32
683
    mov  ecx,15
683
    mov  ecx,15
684
    cld
684
    cld
685
    rep  stosb
685
    rep  stosb
686
    popa
686
    popa
687
 
687
 
688
    mov  esi,user_nick+4
688
    mov  esi,user_nick+4
689
    mov  edi,text+70*1+15
689
    mov  edi,text+70*1+15
690
    mov  ecx,[esi-4]
690
    mov  ecx,[esi-4]
691
    cld
691
    cld
692
    rep  movsb
692
    rep  movsb
693
 
693
 
694
    mov  [xpos],0
694
    mov  [xpos],0
695
    call draw_window
695
    call draw_window
696
 
696
 
697
    popa
697
    popa
698
    ret
698
    ret
699
 
699
 
700
  no_set_nick:
700
  no_set_nick:
701
 
701
 
702
    cmp  [send_string+1],dword 'area'
702
    cmp  [send_string+1],dword 'area'
703
    jne  no_set_real_name
703
    jne  no_set_real_name
704
 
704
 
705
    mov  ecx,[xpos]
705
    mov  ecx,[xpos]
706
    sub  ecx,7
706
    sub  ecx,7
707
    cmp  ecx,user_real_name_max
707
    cmp  ecx,user_real_name_max
708
    jb   @f
708
    jb   @f
709
    mov  ecx,user_real_name_max
709
    mov  ecx,user_real_name_max
710
  @@:
710
  @@:
711
    mov  [user_real_name],ecx
711
    mov  [user_real_name],ecx
712
 
712
 
713
    mov  esi,send_string+7
713
    mov  esi,send_string+7
714
    mov  edi,user_real_name+4
714
    mov  edi,user_real_name+4
715
    cld
715
    cld
716
    rep  movsb
716
    rep  movsb
717
 
717
 
718
    pusha
718
    pusha
719
    mov  edi,text+70*0+15
719
    mov  edi,text+70*0+15
720
    mov  al,32
720
    mov  al,32
721
    mov  ecx,15
721
    mov  ecx,15
722
    cld
722
    cld
723
    rep  stosb
723
    rep  stosb
724
    popa
724
    popa
725
 
725
 
726
    mov  esi,user_real_name+4
726
    mov  esi,user_real_name+4
727
    mov  edi,text+70*0+15
727
    mov  edi,text+70*0+15
728
    mov  ecx,[esi-4]
728
    mov  ecx,[esi-4]
729
    rep  movsb
729
    rep  movsb
730
 
730
 
731
    mov  [xpos],0
731
    mov  [xpos],0
732
    call draw_window
732
    call draw_window
733
 
733
 
734
    popa
734
    popa
735
    ret
735
    ret
736
 
736
 
737
  no_set_real_name:
737
  no_set_real_name:
738
 
738
 
739
    cmp  [send_string+1],dword 'aser'
739
    cmp  [send_string+1],dword 'aser'
740
    jne  no_set_server
740
    jne  no_set_server
741
 
741
 
742
    mov  ecx,[xpos]
742
    mov  ecx,[xpos]
743
    sub  ecx,7
743
    sub  ecx,7
744
 
744
 
745
    mov  esi,send_string+7
745
    mov  esi,send_string+7
746
    mov  edi,irc_server_name
746
    mov  edi,irc_server_name
747
    rep  movsb
747
    rep  movsb
748
    mov  al,0
748
    mov  al,0
749
    stosb
749
    stosb
750
 
750
 
751
    pusha
751
    pusha
752
    mov  edi,text+70*2+15
752
    mov  edi,text+70*2+15
753
    mov  al,32
753
    mov  al,32
754
    mov  ecx,15
754
    mov  ecx,15
755
    cld
755
    cld
756
    rep  stosb
756
    rep  stosb
757
    popa
757
    popa
758
 
758
 
759
    mov  ecx,[xpos]
759
    mov  ecx,[xpos]
760
    sub  ecx,7
760
    sub  ecx,7
761
    mov  esi,send_string+7
761
    mov  esi,send_string+7
762
    mov  edi,text+70*2+15
762
    mov  edi,text+70*2+15
763
    rep  movsb
763
    rep  movsb
764
 
764
 
765
    mov  [xpos],0
765
    mov  [xpos],0
766
    call draw_window
766
    call draw_window
767
 
767
 
768
    popa
768
    popa
769
    ret
769
    ret
770
 
770
 
771
   no_set_server:
771
   no_set_server:
772
 
772
 
773
; All other commands require a connection to the server.
773
; All other commands require a connection to the server.
774
	cmp	[status], STATUS_CONNECTED
774
	cmp	[status], STATUS_CONNECTED
775
	jnz	sdts_ret
775
	jnz	sdts_ret
776
 
776
 
777
 
777
 
778
    cmp  [send_string+1],dword 'quer'
778
    cmp  [send_string+1],dword 'quer'
779
    jne  no_query_create
779
    jne  no_query_create
780
 
780
 
781
    mov  edi,I_END+120*80
781
    mov  edi,I_END+120*80
782
    mov  eax,1 ; create channel window - search for empty slot
782
    mov  eax,1 ; create channel window - search for empty slot
783
   newse2:
783
   newse2:
784
    mov  ebx,eax
784
    mov  ebx,eax
785
    shl  ebx,5
785
    shl  ebx,5
786
    cmp  dword [channel_list+ebx],dword '    '
786
    cmp  dword [channel_list+ebx],dword '    '
787
    je	 free_found2
787
    je	 free_found2
788
    add  edi,120*80
788
    add  edi,120*80
789
    inc  eax
789
    inc  eax
790
    cmp  eax,[max_windows]
790
    cmp  eax,[max_windows]
791
    jb	 newse2
791
    jb	 newse2
792
 
792
 
793
  free_found2:
793
  free_found2:
794
 
794
 
795
    mov  edx,send_string+7
795
    mov  edx,send_string+7
796
 
796
 
797
    mov  ecx,[xpos]
797
    mov  ecx,[xpos]
798
    sub  ecx,7
798
    sub  ecx,7
799
    mov  [channel_list+ebx+31],cl
799
    mov  [channel_list+ebx+31],cl
800
 
800
 
801
    call create_channel_name
801
    call create_channel_name
802
 
802
 
803
    push edi
803
    push edi
804
    push eax
804
    push eax
805
    mov  [edi+120*60+8],byte 1 ; query window
805
    mov  [edi+120*60+8],byte 1 ; query window
806
    mov  al,32
806
    mov  al,32
807
    mov  ecx,120*60
807
    mov  ecx,120*60
808
    cld
808
    cld
809
    rep  stosb
809
    rep  stosb
810
    pop  eax
810
    pop  eax
811
    pop  edi
811
    pop  edi
812
 
812
 
813
    ; eax has the free position
813
    ; eax has the free position
814
;    mov  [thread_screen],edi
814
;    mov  [thread_screen],edi
815
    call create_channel_window
815
    call create_channel_window
816
 
816
 
817
    mov  [xpos],0
817
    mov  [xpos],0
818
 
818
 
819
    popa
819
    popa
820
    ret
820
    ret
821
 
821
 
822
  no_query_create:
822
  no_query_create:
823
 
823
 
824
 
824
 
825
    mov  esi, send_string+1
825
    mov  esi, send_string+1
826
    mov  ecx, [xpos]
826
    mov  ecx, [xpos]
827
    inc  ecx
827
    inc  ecx
828
    mov  edi, packetbuf
828
    mov  edi, packetbuf
829
    call recode
829
    call recode
830
    mov  esi, packetbuf
830
    mov  esi, packetbuf
831
    mov  edx, edi
831
    mov  edx, edi
832
    sub  edx, esi
832
    sub  edx, esi
833
 
833
 
834
    mov  eax, 53      ; write server command
834
    mov  eax, 53      ; write server command
835
    mov  ebx, 7
835
    mov  ebx, 7
836
    mov  ecx, [socket]
836
    mov  ecx, [socket]
837
    mcall
837
    mcall
838
 
838
 
839
  send_done:
839
  send_done:
840
 
840
 
841
    mov  [xpos],0
841
    mov  [xpos],0
842
 
842
 
843
    cmp  [send_string+1],dword 'quit'
843
    cmp  [send_string+1],dword 'quit'
844
    jne  no_quit_server
844
    jne  no_quit_server
845
    mov  eax,5
845
    mov  eax,5
846
    mov  ebx,200
846
    mov  ebx,200
847
    mcall
847
    mcall
848
 
848
 
849
    mov  eax, 53      ; close socket
849
    mov  eax, 53      ; close socket
850
    mov  ebx, 8
850
    mov  ebx, 8
851
    mov  ecx, [socket]
851
    mov  ecx, [socket]
852
    mcall
852
    mcall
853
 
853
 
854
    mov  ecx,[max_windows]
854
    mov  ecx,[max_windows]
855
    mov  edi,I_END
855
    mov  edi,I_END
856
  newclose:
856
  newclose:
857
    mov  [edi+120*60+4],byte  1
857
    mov  [edi+120*60+4],byte  1
858
    call notify_channel_thread
858
    call notify_channel_thread
859
    add  edi,120*80
859
    add  edi,120*80
860
    loop newclose
860
    loop newclose
861
 
861
 
862
    popa
862
    popa
863
    ret
863
    ret
864
 
864
 
865
  no_quit_server:
865
  no_quit_server:
866
 
866
 
867
  sdts_ret:
867
  sdts_ret:
868
 
868
 
869
    popa
869
    popa
870
    ret
870
    ret
871
 
871
 
872
get_next_byte:
872
get_next_byte:
873
; Load next byte from the packet, translating to cp866 if necessary
873
; Load next byte from the packet, translating to cp866 if necessary
874
; At input esi = pointer to data, edx = limit of data
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.
875
; Output is either (translated) byte in al with CF set or CF cleared.
876
	mov	eax, [encoding]
876
	mov	eax, [encoding]
877
	jmp	[get_byte_table+eax*4]
877
	jmp	[get_byte_table+eax*4]
878
 
878
 
879
get_byte_cp866:
879
get_byte_cp866:
880
	cmp	esi, edx
880
	cmp	esi, edx
881
	jae	.nothing
881
	jae	.nothing
882
	lodsb
882
	lodsb
883
.nothing:
883
.nothing:
884
	ret
884
	ret
885
 
885
 
886
get_byte_cp1251:
886
get_byte_cp1251:
887
	cmp	esi, edx
887
	cmp	esi, edx
888
	jae	.nothing
888
	jae	.nothing
889
	lodsb
889
	lodsb
890
	cmp	al, 0x80
890
	cmp	al, 0x80
891
	jb	@f
891
	jb	@f
892
	and	eax, 0x7F
892
	and	eax, 0x7F
893
	mov	al, [cp1251_table+eax]
893
	mov	al, [cp1251_table+eax]
894
@@:
894
@@:
895
	stc
895
	stc
896
.nothing:
896
.nothing:
897
	ret
897
	ret
898
 
898
 
899
get_byte_utf8:
899
get_byte_utf8:
900
; UTF8 decoding is slightly complicated.
900
; UTF8 decoding is slightly complicated.
901
; One character can occupy one or more bytes.
901
; One character can occupy one or more bytes.
902
; The boundary in packets theoretically can be anywhere in data,
902
; The boundary in packets theoretically can be anywhere in data,
903
; so this procedure keeps internal state between calls and handles
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.
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
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).
906
; and convert this unicode char to our base encoding (that is cp866).
907
; 1. Check that there are data.
907
; 1. Check that there are data.
908
	cmp	esi, edx
908
	cmp	esi, edx
909
	jae	.nothing
909
	jae	.nothing
910
; 2. Load byte.
910
; 2. Load byte.
911
	lodsb
911
	lodsb
912
	movzx	ecx, al
912
	movzx	ecx, al
913
; 3. Bytes in an UTF8 sequence can be of any of three types.
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.
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.
915
; First byte of a sequence must be 11xxxxxx, other bytes are 10yyyyyy.
916
	and	al, 0xC0
916
	and	al, 0xC0
917
	jns	.single_byte
917
	jns	.single_byte
918
	jp	.first_byte
918
	jp	.first_byte
919
; 4. This byte is not first in UTF8 sequence.
919
; 4. This byte is not first in UTF8 sequence.
920
; 4a. Check that the sequence was started. If no, it is invalid byte
920
; 4a. Check that the sequence was started. If no, it is invalid byte
921
; and we simply ignore it.
921
; and we simply ignore it.
922
	cmp	[utf8_bytes_rest], 0
922
	cmp	[utf8_bytes_rest], 0
923
	jz	get_byte_utf8
923
	jz	get_byte_utf8
924
; 4b. Otherwise, it is really next byte and it gives some more bits of char.
924
; 4b. Otherwise, it is really next byte and it gives some more bits of char.
925
	mov	eax, [utf8_char]
925
	mov	eax, [utf8_char]
926
	shl	eax, 6
926
	shl	eax, 6
927
	lea	eax, [eax+ecx-0x80]
927
	lea	eax, [eax+ecx-0x80]
928
; 4c. Decrement number of bytes rest in the sequence.
928
; 4c. Decrement number of bytes rest in the sequence.
929
; If it goes to zero, character is read, so return it.
929
; If it goes to zero, character is read, so return it.
930
	dec	[utf8_bytes_rest]
930
	dec	[utf8_bytes_rest]
931
	jz	.got_char
931
	jz	.got_char
932
	mov	[utf8_char], eax
932
	mov	[utf8_char], eax
933
	jmp	get_byte_utf8
933
	jmp	get_byte_utf8
934
; 5. If the byte is first in UTF8 sequence, calculate the number of leading 1s
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
935
; - it equals total number of bytes in the sequence; some other bits rest for
936
; leading bits in the character.
936
; leading bits in the character.
937
.first_byte:
937
.first_byte:
938
	mov	eax, -1
938
	mov	eax, -1
939
@@:
939
@@:
940
	inc	eax
940
	inc	eax
941
	add	cl, cl
941
	add	cl, cl
942
	js	@b
942
	js	@b
943
	mov	[utf8_bytes_rest], eax
943
	mov	[utf8_bytes_rest], eax
944
	xchg	eax, ecx
944
	xchg	eax, ecx
945
	inc	ecx
945
	inc	ecx
946
	shr	al, cl
946
	shr	al, cl
947
	mov	[utf8_char], eax
947
	mov	[utf8_char], eax
948
	jmp	get_byte_utf8
948
	jmp	get_byte_utf8
949
; 6. If the byte is ASCII char, it is the character.
949
; 6. If the byte is ASCII char, it is the character.
950
.single_byte:
950
.single_byte:
951
	xchg	eax, ecx
951
	xchg	eax, ecx
952
.got_char:
952
.got_char:
953
; We got the character, now abandon a possible sequence in progress.
953
; We got the character, now abandon a possible sequence in progress.
954
	and	[utf8_bytes_rest], 0
954
	and	[utf8_bytes_rest], 0
955
; Now second task. The unicode character is in eax, and now we shall convert it
955
; Now second task. The unicode character is in eax, and now we shall convert it
956
; to cp866.
956
; to cp866.
957
	cmp	eax, 0x80
957
	cmp	eax, 0x80
958
	jb	.done
958
	jb	.done
959
; 0x410-0x43F -> 0x80-0xAF, 0x440-0x44F -> 0xE0-0xEF, 0x401 -> 0xF0, 0x451 -> 0xF1
959
; 0x410-0x43F -> 0x80-0xAF, 0x440-0x44F -> 0xE0-0xEF, 0x401 -> 0xF0, 0x451 -> 0xF1
960
	cmp	eax, 0x401
960
	cmp	eax, 0x401
961
	jz	.YO
961
	jz	.YO
962
	cmp	eax, 0x451
962
	cmp	eax, 0x451
963
	jz	.yo
963
	jz	.yo
964
	cmp	eax, 0x410
964
	cmp	eax, 0x410
965
	jb	.unrecognized
965
	jb	.unrecognized
966
	cmp	eax, 0x440
966
	cmp	eax, 0x440
967
	jb	.part1
967
	jb	.part1
968
	cmp	eax, 0x450
968
	cmp	eax, 0x450
969
	jae	.unrecognized
969
	jae	.unrecognized
970
	sub	al, (0x40-0xE0) and 0xFF
970
	sub	al, (0x40-0xE0) and 0xFF
971
	ret
971
	ret
972
.part1:
972
.part1:
973
	sub	al, 0x10-0x80
973
	sub	al, 0x10-0x80
974
.nothing:
974
.nothing:
975
.done:
975
.done:
976
	ret
976
	ret
977
.unrecognized:
977
.unrecognized:
978
	mov	al, '?'
978
	mov	al, '?'
979
	stc
979
	stc
980
	ret
980
	ret
981
.YO:
981
.YO:
982
	mov	al, 0xF0
982
	mov	al, 0xF0
983
	stc
983
	stc
984
	ret
984
	ret
985
.yo:
985
.yo:
986
	mov	al, 0xF1
986
	mov	al, 0xF1
987
	stc
987
	stc
988
	ret
988
	ret
989
 
989
 
990
read_incoming_data:
990
read_incoming_data:
991
	pusha
991
	pusha
992
.packetloop:
992
.packetloop:
993
.nextpacket:
993
.nextpacket:
994
	mcall	53, 11, [socket], packetbuf, 1024
994
	mcall	53, 11, [socket], packetbuf, 1024
995
	test	eax, eax
995
	test	eax, eax
996
	jz	.nothing
996
	jz	.nothing
997
	mov	esi, edx	; esi = pointer to data
997
	mov	esi, edx	; esi = pointer to data
998
	add	edx, eax	; edx = limit of data
998
	add	edx, eax	; edx = limit of data
999
.byteloop:
999
.byteloop:
1000
	call	get_next_byte
1000
	call	get_next_byte
1001
	jnc	.nextpacket
1001
	jnc	.nextpacket
1002
	cmp	al, 10
1002
	cmp	al, 10
1003
	jne	.no_start_command
1003
	jne	.no_start_command
1004
	mov	[cmd], 1
1004
	mov	[cmd], 1
1005
.no_start_command:
1005
.no_start_command:
1006
	cmp	al, 13
1006
	cmp	al, 13
1007
	jne	.no_end_command
1007
	jne	.no_end_command
1008
	mov	ebx, [cmd]
1008
	mov	ebx, [cmd]
1009
	mov	byte [ebx+command-2], 0
1009
	mov	byte [ebx+command-2], 0
1010
	call	analyze_command
1010
	call	analyze_command
1011
	mov	edi, command
1011
	mov	edi, command
1012
	mov	ecx, 250
1012
	mov	ecx, 250
1013
	xor	eax, eax
1013
	xor	eax, eax
1014
	rep	stosb
1014
	rep	stosb
1015
	mov	[cmd], eax
1015
	mov	[cmd], eax
1016
	mov	al, 13
1016
	mov	al, 13
1017
.no_end_command:
1017
.no_end_command:
1018
	mov	ebx, [cmd]
1018
	mov	ebx, [cmd]
1019
	cmp	ebx, 512
1019
	cmp	ebx, 512
1020
	jge	@f
1020
	jge	@f
1021
	mov	[ebx+command-2], al
1021
	mov	[ebx+command-2], al
1022
	inc	[cmd]
1022
	inc	[cmd]
1023
@@:
1023
@@:
1024
	jmp	.byteloop
1024
	jmp	.byteloop
1025
.nothing:
1025
.nothing:
1026
	popa
1026
	popa
1027
	ret
1027
	ret
1028
 
1028
 
1029
 
1029
 
1030
create_channel_name:
1030
create_channel_name:
1031
 
1031
 
1032
    pusha
1032
    pusha
1033
 
1033
 
1034
  search_first_letter:
1034
  search_first_letter:
1035
    cmp  [edx],byte ' '
1035
    cmp  [edx],byte ' '
1036
    jne  first_letter_found
1036
    jne  first_letter_found
1037
    inc  edx
1037
    inc  edx
1038
    jmp  search_first_letter
1038
    jmp  search_first_letter
1039
  first_letter_found:
1039
  first_letter_found:
1040
 
1040
 
1041
    mov  esi,edx
1041
    mov  esi,edx
1042
    mov  edi,channel_list
1042
    mov  edi,channel_list
1043
    add  edi,ebx
1043
    add  edi,ebx
1044
    mov  ecx,30
1044
    mov  ecx,30
1045
    xor  eax,eax
1045
    xor  eax,eax
1046
  newcase:
1046
  newcase:
1047
    mov  al,[esi]
1047
    mov  al,[esi]
1048
    cmp  eax,'a'
1048
    cmp  eax,'a'
1049
    jb	 nocdec
1049
    jb	 nocdec
1050
    cmp  eax,'z'
1050
    cmp  eax,'z'
1051
    jg	 nocdec
1051
    jg	 nocdec
1052
    sub  al,97-65
1052
    sub  al,97-65
1053
  nocdec:
1053
  nocdec:
1054
    mov  [edi],al
1054
    mov  [edi],al
1055
    inc  esi
1055
    inc  esi
1056
    inc  edi
1056
    inc  edi
1057
    loop newcase
1057
    loop newcase
1058
 
1058
 
1059
    popa
1059
    popa
1060
 
1060
 
1061
    ret
1061
    ret
1062
 
1062
 
1063
 
1063
 
1064
create_channel_window:
1064
create_channel_window:
1065
 
1065
 
1066
    pusha
1066
    pusha
1067
 
1067
 
1068
    mov  [cursor_on_off],0
1068
    mov  [cursor_on_off],0
1069
 
1069
 
1070
;    mov  [thread_nro],eax
1070
;    mov  [thread_nro],eax
1071
 
1071
 
1072
    mov  edx,[thread_stack]
1072
    mov  edx,[thread_stack]
1073
    sub  edx,8
1073
    sub  edx,8
1074
    mov  [edx],eax
1074
    mov  [edx],eax
1075
    mov  [edx+4],edi
1075
    mov  [edx+4],edi
1076
    mov  eax,51
1076
    mov  eax,51
1077
    mov  ebx,1
1077
    mov  ebx,1
1078
    mov  ecx,channel_thread
1078
    mov  ecx,channel_thread
1079
    mcall
1079
    mcall
1080
    mov  [edi+120*60+12], eax
1080
    mov  [edi+120*60+12], eax
1081
 
1081
 
1082
    add  [thread_stack],0x4000
1082
    add  [thread_stack],0x4000
1083
;    add  [thread_screen],120*80
1083
;    add  [thread_screen],120*80
1084
 
1084
 
1085
    popa
1085
    popa
1086
 
1086
 
1087
    ret
1087
    ret
1088
 
1088
 
1089
 
1089
 
1090
print_entry:
1090
print_entry:
1091
 
1091
 
1092
    pusha
1092
    pusha
1093
 
1093
 
1094
    mov  eax,13
1094
    mov  eax,13
1095
    mov  ebx,8*65536+6*80
1095
    mov  ebx,8*65536+6*80
1096
    mov  ecx,151*65536+13
1096
    mov  ecx,151*65536+13
1097
    mov  edx,0xffffff
1097
    mov  edx,0xffffff
1098
    mcall
1098
    mcall
1099
 
1099
 
1100
    mov  eax,4
1100
    mov  eax,4
1101
    mov  ebx,8*65536+154
1101
    mov  ebx,8*65536+154
1102
    mov  ecx,0x000000
1102
    mov  ecx,0x000000
1103
    mov  edx,send_string
1103
    mov  edx,send_string
1104
    mov  esi,[xpos]
1104
    mov  esi,[xpos]
1105
    mcall
1105
    mcall
1106
 
1106
 
1107
    popa
1107
    popa
1108
 
1108
 
1109
; Fall through to draw_cursor.
1109
; Fall through to draw_cursor.
1110
;    ret
1110
;    ret
1111
 
1111
 
1112
draw_cursor:
1112
draw_cursor:
1113
 
1113
 
1114
    pusha
1114
    pusha
1115
 
1115
 
1116
    mov  eax,9
1116
    mov  eax,9
1117
    mov  ebx,0xe0000
1117
    mov  ebx,0xe0000
1118
    mov  ecx,-1
1118
    mov  ecx,-1
1119
    mcall
1119
    mcall
1120
 
1120
 
1121
    cmp  ax,word [0xe0000+4]
1121
    cmp  ax,word [0xe0000+4]
1122
    setnz dl
1122
    setnz dl
1123
    movzx edx,dl
1123
    movzx edx,dl
1124
    neg edx
1124
    neg edx
1125
    and edx,0xffffff
1125
    and edx,0xffffff
1126
;    jne  no_blink
1126
;    jne  no_blink
1127
 
1127
 
1128
;    call print_entry
1128
;    call print_entry
1129
 
1129
 
1130
    mov  ebx,[xpos]
1130
    mov  ebx,[xpos]
1131
    imul ebx,6
1131
    imul ebx,6
1132
    add  ebx,8
1132
    add  ebx,8
1133
    mov  cx,bx
1133
    mov  cx,bx
1134
    shl  ebx,16
1134
    shl  ebx,16
1135
    mov  bx,cx
1135
    mov  bx,cx
1136
    mov  ecx,151*65536+163
1136
    mov  ecx,151*65536+163
1137
    mov  eax,38
1137
    mov  eax,38
1138
    mcall
1138
    mcall
1139
 
1139
 
1140
    popa
1140
    popa
1141
 
1141
 
1142
    ret
1142
    ret
1143
 
1143
 
1144
;  no_blink:
1144
;  no_blink:
1145
;
1145
;
1146
;    mov  eax,13
1146
;    mov  eax,13
1147
;    mov  ebx,8*65536+6*60
1147
;    mov  ebx,8*65536+6*60
1148
;    mov  ecx,151*65536+13
1148
;    mov  ecx,151*65536+13
1149
;    mov  edx,0xffffff
1149
;    mov  edx,0xffffff
1150
;    mcall
1150
;    mcall
1151
 
1151
 
1152
    popa
1152
    popa
1153
 
1153
 
1154
    ret
1154
    ret
1155
 
1155
 
1156
 
1156
 
1157
 
1157
 
1158
 
1158
 
1159
 
1159
 
1160
set_channel:
1160
set_channel:
1161
 
1161
 
1162
    pusha
1162
    pusha
1163
 
1163
 
1164
    ; UPPER / LOWER CASE CHECK
1164
    ; UPPER / LOWER CASE CHECK
1165
 
1165
 
1166
    mov  esi,eax
1166
    mov  esi,eax
1167
    mov  edi,channel_temp
1167
    mov  edi,channel_temp
1168
    mov  ecx,40
1168
    mov  ecx,40
1169
    xor  eax,eax
1169
    xor  eax,eax
1170
  newcase2:
1170
  newcase2:
1171
    mov  al,[esi]
1171
    mov  al,[esi]
1172
    cmp  eax,'#'
1172
    cmp  eax,'#'
1173
    jb	 newcase_over2
1173
    jb	 newcase_over2
1174
    cmp  eax,'a'
1174
    cmp  eax,'a'
1175
    jb	 nocdec2
1175
    jb	 nocdec2
1176
    cmp  eax,'z'
1176
    cmp  eax,'z'
1177
    jg	 nocdec2
1177
    jg	 nocdec2
1178
    sub  al,97-65
1178
    sub  al,97-65
1179
  nocdec2:
1179
  nocdec2:
1180
    mov  [edi],al
1180
    mov  [edi],al
1181
    inc  esi
1181
    inc  esi
1182
    inc  edi
1182
    inc  edi
1183
    loop newcase2
1183
    loop newcase2
1184
  newcase_over2:
1184
  newcase_over2:
1185
    sub  edi,channel_temp
1185
    sub  edi,channel_temp
1186
    mov  [channel_temp_length],edi
1186
    mov  [channel_temp_length],edi
1187
 
1187
 
1188
    mov  eax,channel_temp
1188
    mov  eax,channel_temp
1189
 
1189
 
1190
    mov  [text_start],I_END+120*80
1190
    mov  [text_start],I_END+120*80
1191
    mov  ebx,channel_list+32
1191
    mov  ebx,channel_list+32
1192
    mov  eax,[eax]
1192
    mov  eax,[eax]
1193
 
1193
 
1194
    mov  edx,[channel_temp_length]
1194
    mov  edx,[channel_temp_length]
1195
 
1195
 
1196
  stcl1:
1196
  stcl1:
1197
    cmp  dl,[ebx+31]
1197
    cmp  dl,[ebx+31]
1198
    jne  notfound
1198
    jne  notfound
1199
 
1199
 
1200
    pusha
1200
    pusha
1201
    xor  eax,eax
1201
    xor  eax,eax
1202
    xor  edx,edx
1202
    xor  edx,edx
1203
    mov  ecx,0
1203
    mov  ecx,0
1204
  stc4:
1204
  stc4:
1205
    mov  dl,[ebx+ecx]
1205
    mov  dl,[ebx+ecx]
1206
    mov  al,[channel_temp+ecx]
1206
    mov  al,[channel_temp+ecx]
1207
    cmp  eax,edx
1207
    cmp  eax,edx
1208
    jne  notfound2
1208
    jne  notfound2
1209
    inc  ecx
1209
    inc  ecx
1210
    cmp  ecx,[channel_temp_length]
1210
    cmp  ecx,[channel_temp_length]
1211
    jb	 stc4
1211
    jb	 stc4
1212
    popa
1212
    popa
1213
 
1213
 
1214
    jmp  found
1214
    jmp  found
1215
 
1215
 
1216
  notfound2:
1216
  notfound2:
1217
    popa
1217
    popa
1218
 
1218
 
1219
  notfound:
1219
  notfound:
1220
    add  [text_start],120*80
1220
    add  [text_start],120*80
1221
    add  ebx,32
1221
    add  ebx,32
1222
    cmp  ebx,channel_list+19*32
1222
    cmp  ebx,channel_list+19*32
1223
    jb	 stcl1
1223
    jb	 stcl1
1224
 
1224
 
1225
    mov  [text_start],I_END
1225
    mov  [text_start],I_END
1226
 
1226
 
1227
  found:
1227
  found:
1228
 
1228
 
1229
    popa
1229
    popa
1230
 
1230
 
1231
    ret
1231
    ret
1232
 
1232
 
1233
 
1233
 
1234
channel_temp:	      times   100   db	 0
1234
channel_temp:	      times   100   db	 0
1235
channel_temp_length   dd      0x0
1235
channel_temp_length   dd      0x0
1236
 
1236
 
1237
 
1237
 
1238
 
1238
 
1239
print_nick:
1239
print_nick:
1240
 
1240
 
1241
    pusha
1241
    pusha
1242
 
1242
 
1243
    mov  eax,command+1
1243
    mov  eax,command+1
1244
    mov  dl,'!'
1244
    mov  dl,'!'
1245
    call print_text
1245
    call print_text
1246
 
1246
 
1247
    popa
1247
    popa
1248
    ret
1248
    ret
1249
 
1249
 
1250
 
1250
 
1251
analyze_command:
1251
analyze_command:
1252
 
1252
 
1253
    pusha
1253
    pusha
1254
 
1254
 
1255
    mov  [text_start],I_END
1255
    mov  [text_start],I_END
1256
    mov  ecx,[rxs]
1256
    mov  ecx,[rxs]
1257
    imul ecx,11
1257
    imul ecx,11
1258
    mov  [pos],ecx
1258
    mov  [pos],ecx
1259
 
1259
 
1260
;    mov  bl,13
1260
;    mov  bl,13
1261
;  call print_character
1261
;  call print_character
1262
;    mov  bl,10
1262
;    mov  bl,10
1263
;  call print_character
1263
;  call print_character
1264
 
1264
 
1265
;    mov  ecx,[cmd]
1265
;    mov  ecx,[cmd]
1266
;    sub  ecx,2
1266
;    sub  ecx,2
1267
;    mov  esi,command+0
1267
;    mov  esi,command+0
1268
;  newcmdc:
1268
;  newcmdc:
1269
;    mov  bl,[esi]
1269
;    mov  bl,[esi]
1270
;  call print_character
1270
;  call print_character
1271
;    inc  esi
1271
;    inc  esi
1272
;    loop newcmdc
1272
;    loop newcmdc
1273
 
1273
 
1274
    mov   edx,I_END
1274
    mov   edx,I_END
1275
;  call  draw_channel_text
1275
;  call  draw_channel_text
1276
 
1276
 
1277
;    cmp  [cmd],20
1277
;    cmp  [cmd],20
1278
;    jge  cmd_len_ok
1278
;    jge  cmd_len_ok
1279
;
1279
;
1280
;    mov  [cmd],0
1280
;    mov  [cmd],0
1281
;
1281
;
1282
;    popa
1282
;    popa
1283
;    ret
1283
;    ret
1284
 
1284
 
1285
 
1285
 
1286
  cmd_len_ok:
1286
  cmd_len_ok:
1287
 
1287
 
1288
    cmp  [command],dword 'PING'  ; ping response
1288
    cmp  [command],dword 'PING'  ; ping response
1289
    jne  no_ping_responce
1289
    jne  no_ping_responce
1290
 
1290
 
1291
    call print_command_to_main
1291
    call print_command_to_main
1292
 
1292
 
1293
    mov  [command],dword 'PONG'
1293
    mov  [command],dword 'PONG'
1294
 
1294
 
1295
    call print_command_to_main
1295
    call print_command_to_main
1296
 
1296
 
1297
    mov  eax,4
1297
    mov  eax,4
1298
    mov  ebx,100*65536+3
1298
    mov  ebx,100*65536+3
1299
    mov  ecx,0xffffff
1299
    mov  ecx,0xffffff
1300
    mov  edx,command
1300
    mov  edx,command
1301
    mov  esi,[cmd]
1301
    mov  esi,[cmd]
1302
    mov  [command+esi-1],word '**'
1302
    mov  [command+esi-1],word '**'
1303
;    mcall
1303
;    mcall
1304
 
1304
 
1305
    mov  eax,53
1305
    mov  eax,53
1306
    mov  ebx,7
1306
    mov  ebx,7
1307
    mov  ecx,[socket]
1307
    mov  ecx,[socket]
1308
    mov  edx,[cmd]
1308
    mov  edx,[cmd]
1309
    mov  esi,command
1309
    mov  esi,command
1310
    mov  word [esi+edx-2], 0x0a0d
1310
    mov  word [esi+edx-2], 0x0a0d
1311
    mcall
1311
    mcall
1312
 
1312
 
1313
    popa
1313
    popa
1314
    ret
1314
    ret
1315
 
1315
 
1316
  no_ping_responce:
1316
  no_ping_responce:
1317
 
1317
 
1318
    mov  eax,[rxs]
1318
    mov  eax,[rxs]
1319
    imul eax,11
1319
    imul eax,11
1320
    mov  [pos],eax
1320
    mov  [pos],eax
1321
 
1321
 
1322
    mov  [command],byte '<'
1322
    mov  [command],byte '<'
1323
 
1323
 
1324
    mov  eax,command
1324
    mov  eax,command
1325
    mov  ecx,100
1325
    mov  ecx,100
1326
   new_blank:
1326
   new_blank:
1327
    cmp  [eax],byte ' '
1327
    cmp  [eax],byte ' '
1328
    je	 bl_found
1328
    je	 bl_found
1329
    inc  eax
1329
    inc  eax
1330
    loop new_blank
1330
    loop new_blank
1331
    mov  eax,50
1331
    mov  eax,50
1332
  bl_found:
1332
  bl_found:
1333
 
1333
 
1334
    inc  eax
1334
    inc  eax
1335
    mov  [command_position],eax
1335
    mov  [command_position],eax
1336
 
1336
 
1337
    mov  esi,eax
1337
    mov  esi,eax
1338
    mov  edi,irc_command
1338
    mov  edi,irc_command
1339
    mov  ecx,8
1339
    mov  ecx,8
1340
    cld
1340
    cld
1341
    rep  movsb
1341
    rep  movsb
1342
 
1342
 
1343
 
1343
 
1344
    cmp  [irc_command],'PRIV'  ; message to channel
1344
    cmp  [irc_command],'PRIV'  ; message to channel
1345
    jne  no_privmsg
1345
    jne  no_privmsg
1346
 
1346
 
1347
    ; compare nick
1347
    ; compare nick
1348
 
1348
 
1349
    mov  eax,[command_position]
1349
    mov  eax,[command_position]
1350
    add  eax,8
1350
    add  eax,8
1351
    call compare_to_nick
1351
    call compare_to_nick
1352
    cmp  [cresult],0
1352
    cmp  [cresult],0
1353
    jne  no_query_msg
1353
    jne  no_query_msg
1354
    mov  eax,command+1
1354
    mov  eax,command+1
1355
  no_query_msg:
1355
  no_query_msg:
1356
    call set_channel
1356
    call set_channel
1357
 
1357
 
1358
    mov  ecx,100 ; [cmd]
1358
    mov  ecx,100 ; [cmd]
1359
    mov  eax,command+10
1359
    mov  eax,command+10
1360
  acl3:
1360
  acl3:
1361
    cmp  [eax],byte ':'
1361
    cmp  [eax],byte ':'
1362
    je	 acl4
1362
    je	 acl4
1363
    inc  eax
1363
    inc  eax
1364
    loop acl3
1364
    loop acl3
1365
    mov  eax,10
1365
    mov  eax,10
1366
  acl4:
1366
  acl4:
1367
    inc  eax
1367
    inc  eax
1368
 
1368
 
1369
    cmp  [eax+1],dword 'ACTI'
1369
    cmp  [eax+1],dword 'ACTI'
1370
    jne  no_action
1370
    jne  no_action
1371
    push eax
1371
    push eax
1372
    mov  eax,action_header_short
1372
    mov  eax,action_header_short
1373
    mov  dl,0
1373
    mov  dl,0
1374
    call print_text
1374
    call print_text
1375
    mov  eax,command+1
1375
    mov  eax,command+1
1376
    mov  dl,'!'
1376
    mov  dl,'!'
1377
    call print_text
1377
    call print_text
1378
    mov  bl,' '
1378
    mov  bl,' '
1379
    call print_character
1379
    call print_character
1380
    pop  eax
1380
    pop  eax
1381
    add  eax,8
1381
    add  eax,8
1382
    mov  dl,0
1382
    mov  dl,0
1383
    call print_text
1383
    call print_text
1384
    call notify_channel_thread
1384
    call notify_channel_thread
1385
    popa
1385
    popa
1386
    ret
1386
    ret
1387
 
1387
 
1388
  no_action:
1388
  no_action:
1389
 
1389
 
1390
    push eax
1390
    push eax
1391
    mov  bl,10
1391
    mov  bl,10
1392
    call print_character
1392
    call print_character
1393
    mov  eax,command
1393
    mov  eax,command
1394
    mov  dl,'!'
1394
    mov  dl,'!'
1395
    call print_text
1395
    call print_text
1396
    mov  bl,'>'
1396
    mov  bl,'>'
1397
    call print_character
1397
    call print_character
1398
    mov  bl,' '
1398
    mov  bl,' '
1399
    call print_character
1399
    call print_character
1400
    pop  eax
1400
    pop  eax
1401
 
1401
 
1402
    mov  dl,0
1402
    mov  dl,0
1403
    call print_text
1403
    call print_text
1404
    call notify_channel_thread
1404
    call notify_channel_thread
1405
 
1405
 
1406
    popa
1406
    popa
1407
    ret
1407
    ret
1408
 
1408
 
1409
  no_privmsg:
1409
  no_privmsg:
1410
 
1410
 
1411
 
1411
 
1412
    cmp  [irc_command],'PART'	 ; channel leave
1412
    cmp  [irc_command],'PART'	 ; channel leave
1413
    jne  no_part
1413
    jne  no_part
1414
 
1414
 
1415
    ; compare nick
1415
    ; compare nick
1416
 
1416
 
1417
    mov  eax,command+1
1417
    mov  eax,command+1
1418
    call compare_to_nick
1418
    call compare_to_nick
1419
    cmp  [cresult],0
1419
    cmp  [cresult],0
1420
    jne  no_close_window
1420
    jne  no_close_window
1421
 
1421
 
1422
    mov  eax,[command_position]
1422
    mov  eax,[command_position]
1423
    add  eax,5
1423
    add  eax,5
1424
    call set_channel
1424
    call set_channel
1425
 
1425
 
1426
    mov  edi,[text_start]
1426
    mov  edi,[text_start]
1427
    mov  [edi+120*60+4],byte 1
1427
    mov  [edi+120*60+4],byte 1
1428
    call notify_channel_thread
1428
    call notify_channel_thread
1429
 
1429
 
1430
    popa
1430
    popa
1431
    ret
1431
    ret
1432
 
1432
 
1433
  no_close_window:
1433
  no_close_window:
1434
 
1434
 
1435
    mov  eax,[command_position]
1435
    mov  eax,[command_position]
1436
    add  eax,5
1436
    add  eax,5
1437
    call set_channel
1437
    call set_channel
1438
 
1438
 
1439
    mov  eax,action_header_red
1439
    mov  eax,action_header_red
1440
    mov  dl,0
1440
    mov  dl,0
1441
    call print_text
1441
    call print_text
1442
    mov  eax,command+1
1442
    mov  eax,command+1
1443
    mov  dl,'!'
1443
    mov  dl,'!'
1444
    mov  cl,' '
1444
    mov  cl,' '
1445
    call print_text
1445
    call print_text
1446
    mov  eax,has_left_channel
1446
    mov  eax,has_left_channel
1447
    mov  dl,0
1447
    mov  dl,0
1448
    call print_text
1448
    call print_text
1449
    mov  eax,[command_position]
1449
    mov  eax,[command_position]
1450
    add  eax,5
1450
    add  eax,5
1451
    mov  dl,' '
1451
    mov  dl,' '
1452
    call print_text
1452
    call print_text
1453
    call notify_channel_thread
1453
    call notify_channel_thread
1454
 
1454
 
1455
    popa
1455
    popa
1456
    ret
1456
    ret
1457
 
1457
 
1458
  no_part:
1458
  no_part:
1459
 
1459
 
1460
 
1460
 
1461
    cmp  [irc_command],'JOIN'	 ; channel join
1461
    cmp  [irc_command],'JOIN'	 ; channel join
1462
    jne  no_join
1462
    jne  no_join
1463
 
1463
 
1464
    ; compare nick
1464
    ; compare nick
1465
 
1465
 
1466
    mov  eax,command+1
1466
    mov  eax,command+1
1467
    call compare_to_nick
1467
    call compare_to_nick
1468
    cmp  [cresult],0
1468
    cmp  [cresult],0
1469
    jne  no_new_window
1469
    jne  no_new_window
1470
 
1470
 
1471
    mov  edi,I_END+120*80
1471
    mov  edi,I_END+120*80
1472
    mov  eax,1 ; create channel window - search for empty slot
1472
    mov  eax,1 ; create channel window - search for empty slot
1473
   newse:
1473
   newse:
1474
    mov  ebx,eax
1474
    mov  ebx,eax
1475
    shl  ebx,5
1475
    shl  ebx,5
1476
    cmp  dword [channel_list+ebx],dword '    '
1476
    cmp  dword [channel_list+ebx],dword '    '
1477
    je	 free_found
1477
    je	 free_found
1478
    add  edi,120*80
1478
    add  edi,120*80
1479
    inc  eax
1479
    inc  eax
1480
    cmp  eax,[max_windows]
1480
    cmp  eax,[max_windows]
1481
    jb	 newse
1481
    jb	 newse
1482
 
1482
 
1483
  free_found:
1483
  free_found:
1484
 
1484
 
1485
    mov  edx,[command_position]
1485
    mov  edx,[command_position]
1486
    add  edx,6
1486
    add  edx,6
1487
 
1487
 
1488
    push eax
1488
    push eax
1489
    push edx
1489
    push edx
1490
    mov  ecx,0
1490
    mov  ecx,0
1491
   finde:
1491
   finde:
1492
    inc  ecx
1492
    inc  ecx
1493
    inc  edx
1493
    inc  edx
1494
    movzx eax,byte [edx]
1494
    movzx eax,byte [edx]
1495
    cmp  eax,'#'
1495
    cmp  eax,'#'
1496
    jge  finde
1496
    jge  finde
1497
    mov  [channel_list+ebx+31],cl
1497
    mov  [channel_list+ebx+31],cl
1498
    pop  edx
1498
    pop  edx
1499
    pop  eax
1499
    pop  eax
1500
 
1500
 
1501
    call create_channel_name
1501
    call create_channel_name
1502
 
1502
 
1503
    push edi
1503
    push edi
1504
    push eax
1504
    push eax
1505
    mov  [edi+120*60+8],byte 0 ; channel window
1505
    mov  [edi+120*60+8],byte 0 ; channel window
1506
    mov  al,32
1506
    mov  al,32
1507
    mov  ecx,120*60
1507
    mov  ecx,120*60
1508
    cld
1508
    cld
1509
    rep  stosb
1509
    rep  stosb
1510
    pop  eax
1510
    pop  eax
1511
    pop  edi
1511
    pop  edi
1512
 
1512
 
1513
    ; eax has the free position
1513
    ; eax has the free position
1514
;    mov  [thread_screen],edi
1514
;    mov  [thread_screen],edi
1515
    call create_channel_window
1515
    call create_channel_window
1516
 
1516
 
1517
  no_new_window:
1517
  no_new_window:
1518
 
1518
 
1519
    mov  eax,[command_position]
1519
    mov  eax,[command_position]
1520
    add  eax,6
1520
    add  eax,6
1521
    call set_channel
1521
    call set_channel
1522
 
1522
 
1523
    mov  eax,action_header_blue
1523
    mov  eax,action_header_blue
1524
    mov  dl,0
1524
    mov  dl,0
1525
    call print_text
1525
    call print_text
1526
    mov  eax,command+1
1526
    mov  eax,command+1
1527
    mov  dl,'!'
1527
    mov  dl,'!'
1528
    mov  cl,' '
1528
    mov  cl,' '
1529
    call print_text
1529
    call print_text
1530
 
1530
 
1531
    mov  eax,joins_channel
1531
    mov  eax,joins_channel
1532
    mov  dl,0
1532
    mov  dl,0
1533
    call print_text
1533
    call print_text
1534
 
1534
 
1535
    mov  eax,[command_position]
1535
    mov  eax,[command_position]
1536
    add  eax,6
1536
    add  eax,6
1537
    mov  dl,0
1537
    mov  dl,0
1538
    call print_text
1538
    call print_text
1539
    call notify_channel_thread
1539
    call notify_channel_thread
1540
 
1540
 
1541
    popa
1541
    popa
1542
    ret
1542
    ret
1543
 
1543
 
1544
  no_join:
1544
  no_join:
1545
 
1545
 
1546
 
1546
 
1547
    cmp  [irc_command],'NICK'	   ; nick change
1547
    cmp  [irc_command],'NICK'	   ; nick change
1548
    jne  no_nick_change
1548
    jne  no_nick_change
-
 
1549
 
-
 
1550
	add	[command_position], 6
-
 
1551
; test for change of my nick
-
 
1552
	mov	esi, command+1
-
 
1553
	mov	edi, user_nick+4
-
 
1554
	mov	ecx, [edi-4]
-
 
1555
	repz	cmpsb
-
 
1556
	jnz	.notmy
-
 
1557
	cmp	byte [esi], '!'
-
 
1558
	jnz	.notmy
-
 
1559
; yes, this is my nick, set to new
-
 
1560
	mov	esi, [command_position]
-
 
1561
	or	ecx, -1
-
 
1562
	mov	edi, esi
-
 
1563
	xor	eax, eax
-
 
1564
	repnz	scasb
-
 
1565
	not	ecx
-
 
1566
	dec	ecx
-
 
1567
	cmp	ecx, user_nick_max
-
 
1568
	jb	@f
-
 
1569
	mov	ecx, user_nick_max
-
 
1570
@@:
-
 
1571
	mov	edi, user_nick+4
-
 
1572
	mov	[edi-4], ecx
-
 
1573
	rep	movsb
-
 
1574
 
-
 
1575
	mov	edi, text+70*1+15
-
 
1576
	mov	al, ' '
-
 
1577
	mov	cl, 15
-
 
1578
	push	edi
-
 
1579
	rep	stosb
-
 
1580
	pop	edi
-
 
1581
	mov	esi, user_nick+4
-
 
1582
	mov	ecx, [esi-4]
-
 
1583
	cmp	ecx, 15
-
 
1584
	jb	@f
-
 
1585
	mov	ecx, 15
-
 
1586
@@:
-
 
1587
	rep	movsb
-
 
1588
	mov	[xpos], 0
-
 
1589
	call	draw_window
-
 
1590
.notmy:
-
 
1591
; replace nick in all lists of users
-
 
1592
	mov	ebx, I_END + 120*70
-
 
1593
.channels:
-
 
1594
	mov	esi, ebx
-
 
1595
	mov	edx, [esi-4]
-
 
1596
	add	edx, esi
-
 
1597
.nicks:
-
 
1598
	mov	edi, command+1
-
 
1599
	cmp	byte [esi], '@'
-
 
1600
	jnz	@f
-
 
1601
	inc	esi
-
 
1602
@@:
-
 
1603
	cmp	esi, edx
-
 
1604
	jae	.srcdone
-
 
1605
	lodsb
-
 
1606
	cmp	al, ' '
-
 
1607
	jz	.srcdone
-
 
1608
	scasb
-
 
1609
	jz	@b
-
 
1610
@@:
-
 
1611
	cmp	esi, edx
-
 
1612
	jae	.nextchannel
-
 
1613
	lodsb
-
 
1614
	cmp	al, ' '
-
 
1615
	jnz	@b
-
 
1616
.nextnick:
-
 
1617
	cmp	esi, edx
-
 
1618
	jae	.nextchannel
-
 
1619
	lodsb
-
 
1620
	cmp	al, ' '
-
 
1621
	jz	.nextnick
-
 
1622
	dec	esi
-
 
1623
	jmp	.nicks
-
 
1624
.srcdone:
-
 
1625
	cmp	byte [edi], '!'
-
 
1626
	jnz	.nextnick
-
 
1627
; here we have esi -> end of nick which must be replaced to [command_position]+6
-
 
1628
	lea	edx, [edi-command-1]
-
 
1629
	sub	esi, edx
-
 
1630
	or	ecx, -1
-
 
1631
	xor	eax, eax
-
 
1632
	mov	edi, [command_position]
-
 
1633
	repnz	scasb
-
 
1634
	not	ecx
-
 
1635
	dec	ecx
-
 
1636
	push	ecx
-
 
1637
	cmp	ecx, edx
-
 
1638
	jb	.decrease
-
 
1639
	jz	.copy
-
 
1640
.increase:
-
 
1641
; new nick is longer than the old
-
 
1642
	push	esi
-
 
1643
	lea	edi, [ebx+120*10]
-
 
1644
	lea	esi, [edi+edx]
-
 
1645
	sub	esi, ecx
-
 
1646
	mov	ecx, esi
-
 
1647
	sub	ecx, [esp]
-
 
1648
	dec	esi
-
 
1649
	dec	edi
-
 
1650
	std
-
 
1651
	rep	movsb
-
 
1652
	cld
-
 
1653
	pop	esi
-
 
1654
	jmp	.copy
-
 
1655
.decrease:
-
 
1656
; new nick is shorter than the old
-
 
1657
	push	esi
-
 
1658
	lea	edi, [esi+ecx]
-
 
1659
	add	esi, edx
-
 
1660
	lea	ecx, [ebx+120*10]
-
 
1661
	sub	ecx, edi
-
 
1662
	rep	movsb
-
 
1663
	pop	esi
-
 
1664
.copy:
-
 
1665
; copy nick
-
 
1666
	mov	edi, esi
-
 
1667
	dec	edi
-
 
1668
	mov	esi, [command_position]
-
 
1669
	pop	ecx
-
 
1670
	sub	edx, ecx
-
 
1671
	sub	[ebx-4], edx
-
 
1672
	rep	movsb
-
 
1673
	mov	al, ' '
-
 
1674
	stosb
-
 
1675
.nextchannel:
-
 
1676
	add	ebx, 120*80
-
 
1677
	cmp	ebx, I_END + 120*70 + 120*80*19
-
 
1678
	jb	.channels
1549
 
1679
 
1550
    mov  [text_start],I_END
1680
    mov  [text_start],I_END
1551
    add  [text_start],120*80
1681
    add  [text_start],120*80
1552
 
1682
 
1553
 new_all_channels3:
1683
 new_all_channels3:
1554
 
1684
 
1555
    mov  eax,action_header_short
1685
    mov  eax,action_header_short
1556
    mov  dl,0
1686
    mov  dl,0
1557
    call print_text
1687
    call print_text
1558
    mov  eax,command+1
1688
    mov  eax,command+1
1559
    mov  dl,'!'
1689
    mov  dl,'!'
1560
    call print_text
1690
    call print_text
1561
    mov  eax,is_now_known_as
1691
    mov  eax,is_now_known_as
1562
    mov  dl,0
1692
    mov  dl,0
1563
    call print_text
1693
    call print_text
1564
    mov  eax,[command_position]
1694
    mov  eax,[command_position]
1565
    add  eax,6
-
 
1566
    mov  dl,0
1695
    mov  dl,0
1567
    call print_text
1696
    call print_text
1568
    call notify_channel_thread
1697
    call notify_channel_thread
1569
 
1698
 
1570
    add  [text_start],120*80
1699
    add  [text_start],120*80
1571
    cmp  [text_start],I_END+120*80*20
1700
    cmp  [text_start],I_END+120*80*20
1572
    jb	 new_all_channels3
1701
    jb	 new_all_channels3
1573
 
1702
 
1574
    popa
1703
    popa
1575
    ret
1704
    ret
1576
 
1705
 
1577
  no_nick_change:
1706
  no_nick_change:
1578
 
1707
 
1579
 
1708
 
1580
     cmp  [irc_command],'KICK'	    ; kick
1709
     cmp  [irc_command],'KICK'	    ; kick
1581
     jne  no_kick
1710
     jne  no_kick
1582
 
1711
 
1583
    mov  [text_start],I_END
1712
    mov  [text_start],I_END
1584
    add  [text_start],120*80
1713
    add  [text_start],120*80
1585
 
1714
 
1586
    mov  eax,[command_position]
1715
    mov  eax,[command_position]
1587
    add  eax,5
1716
    add  eax,5
1588
    call set_channel
1717
    call set_channel
1589
 
1718
 
1590
; new_all_channels4:
1719
; new_all_channels4:
1591
 
1720
 
1592
    mov  eax,action_header_short
1721
    mov  eax,action_header_short
1593
    mov  dl,0
1722
    mov  dl,0
1594
    call print_text
1723
    call print_text
1595
    mov  eax,command+1
1724
    mov  eax,command+1
1596
    mov  dl,'!'
1725
    mov  dl,'!'
1597
    call print_text
1726
    call print_text
1598
     mov  eax,kicked
1727
     mov  eax,kicked
1599
     mov  dl,0
1728
     mov  dl,0
1600
    call print_text
1729
    call print_text
1601
    mov  eax,[command_position]
1730
    mov  eax,[command_position]
1602
    add  eax,5
1731
    add  eax,5
1603
    mov  dl,0
1732
    mov  dl,0
1604
    call print_text
1733
    call print_text
1605
    call notify_channel_thread
1734
    call notify_channel_thread
1606
 
1735
 
1607
;    add  [text_start],120*80
1736
;    add  [text_start],120*80
1608
;    cmp  [text_start],I_END+120*80*20
1737
;    cmp  [text_start],I_END+120*80*20
1609
;    jb   new_all_channels4
1738
;    jb   new_all_channels4
1610
 
1739
 
1611
    popa
1740
    popa
1612
    ret
1741
    ret
1613
 
1742
 
1614
  no_kick:
1743
  no_kick:
1615
 
1744
 
1616
 
1745
 
1617
 
1746
 
1618
 
1747
 
1619
    cmp  [irc_command],'QUIT'	 ; irc quit
1748
    cmp  [irc_command],'QUIT'	 ; irc quit
1620
    jne  no_quit
1749
    jne  no_quit
1621
 
1750
 
1622
    mov  [text_start],I_END
1751
    mov  [text_start],I_END
1623
    add  [text_start],120*80
1752
    add  [text_start],120*80
1624
 
1753
 
1625
 new_all_channels2:
1754
 new_all_channels2:
1626
 
1755
 
1627
    mov  eax,action_header_red
1756
    mov  eax,action_header_red
1628
    mov  dl,0
1757
    mov  dl,0
1629
    call print_text
1758
    call print_text
1630
    mov  eax,command+1
1759
    mov  eax,command+1
1631
    mov  dl,'!'
1760
    mov  dl,'!'
1632
    call print_text
1761
    call print_text
1633
    mov  eax,has_quit_irc
1762
    mov  eax,has_quit_irc
1634
    mov  dl,0
1763
    mov  dl,0
1635
    call print_text
1764
    call print_text
1636
    call notify_channel_thread
1765
    call notify_channel_thread
1637
 
1766
 
1638
    add  [text_start],120*80
1767
    add  [text_start],120*80
1639
    cmp  [text_start],I_END+120*80*20
1768
    cmp  [text_start],I_END+120*80*20
1640
    jb	 new_all_channels2
1769
    jb	 new_all_channels2
1641
 
1770
 
1642
    popa
1771
    popa
1643
    ret
1772
    ret
1644
 
1773
 
1645
  no_quit:
1774
  no_quit:
1646
 
1775
 
1647
 
1776
 
1648
    cmp  [irc_command],dword 'MODE'  ; channel mode change
1777
    cmp  [irc_command],dword 'MODE'  ; channel mode change
1649
    jne  no_mode
1778
    jne  no_mode
1650
 
1779
 
1651
    mov  [text_start],I_END
1780
    mov  [text_start],I_END
1652
    add  [text_start],120*80
1781
    add  [text_start],120*80
1653
 
1782
 
1654
    mov  eax,[command_position]
1783
    mov  eax,[command_position]
1655
    add  eax,5
1784
    add  eax,5
1656
    call set_channel
1785
    call set_channel
1657
 
1786
 
1658
 new_all_channels:
1787
 new_all_channels:
1659
 
1788
 
1660
    mov  eax,action_header_short
1789
    mov  eax,action_header_short
1661
    mov  dl,0
1790
    mov  dl,0
1662
    call print_text
1791
    call print_text
1663
 
1792
 
1664
    call print_nick
1793
    call print_nick
1665
 
1794
 
1666
    mov  eax,sets_mode
1795
    mov  eax,sets_mode
1667
    mov  dl,0
1796
    mov  dl,0
1668
    call print_text
1797
    call print_text
1669
 
1798
 
1670
    mov  eax,[command_position]
1799
    mov  eax,[command_position]
1671
    add  eax,5
1800
    add  eax,5
1672
    mov  dl,0
1801
    mov  dl,0
1673
    call print_text
1802
    call print_text
1674
    call notify_channel_thread
1803
    call notify_channel_thread
1675
 
1804
 
1676
;    add  [text_start],120*80
1805
;    add  [text_start],120*80
1677
;    cmp  [text_start],I_END+120*80*20
1806
;    cmp  [text_start],I_END+120*80*20
1678
;    jb   new_all_channels
1807
;    jb   new_all_channels
1679
 
1808
 
1680
    popa
1809
    popa
1681
    ret
1810
    ret
1682
 
1811
 
1683
  no_mode:
1812
  no_mode:
1684
 
1813
 
1685
 
1814
 
1686
    cmp  [irc_command],dword '353 '  ; channel user names
1815
    cmp  [irc_command],dword '353 '  ; channel user names
1687
    jne  no_user_list
1816
    jne  no_user_list
1688
 
1817
 
1689
    mov  eax,[command_position]
1818
    mov  eax,[command_position]
1690
   finde2:
1819
   finde2:
1691
    inc  eax
1820
    inc  eax
1692
    cmp  [eax],byte '#'
1821
    cmp  [eax],byte '#'
1693
    jne  finde2
1822
    jne  finde2
1694
    call set_channel
1823
    call set_channel
1695
 
1824
 
1696
   finde3:
1825
   finde3:
1697
    inc  eax
1826
    inc  eax
1698
    cmp  [eax],byte ':'
1827
    cmp  [eax],byte ':'
1699
    jne  finde3
1828
    jne  finde3
1700
 
1829
 
1701
    pusha
1830
    pusha
1702
    cmp  [user_list_pos],0
1831
    cmp  [user_list_pos],0
1703
    jne  no_clear_user_list
1832
    jne  no_clear_user_list
1704
    mov  edi,[text_start]
1833
    mov  edi,[text_start]
1705
    add  edi,120*70
1834
    add  edi,120*70
1706
    mov  [edi-8],dword 0
1835
    mov  [edi-8],dword 0
1707
    mov  [edi-4],dword 0
1836
    mov  [edi-4],dword 0
1708
    mov  al,32
1837
    mov  al,32
1709
    mov  ecx,1200
1838
    mov  ecx,1200
1710
    cld
1839
    cld
1711
    rep  stosb
1840
    rep  stosb
1712
  no_clear_user_list:
1841
  no_clear_user_list:
1713
    popa
1842
    popa
1714
 
1843
 
1715
    push eax
1844
    push eax
1716
 
1845
 
1717
    mov  esi,eax
1846
    mov  esi,eax
1718
    inc  esi
1847
    inc  esi
1719
    mov  edi,[text_start]
1848
    mov  edi,[text_start]
1720
    add  edi,120*70
1849
    add  edi,120*70
1721
    add  edi,[user_list_pos]
1850
    add  edi,[user_list_pos]
1722
    mov  edx,edi
1851
    mov  edx,edi
1723
    mov  ecx,command
1852
    mov  ecx,command
1724
    add  ecx,[cmd]
1853
    add  ecx,[cmd]
1725
    sub  ecx,[esp]
1854
    sub  ecx,[esp]
1726
    sub  ecx,3
1855
    sub  ecx,3
1727
    and  ecx,0xfff
1856
    and  ecx,0xfff
1728
    cld
1857
    cld
1729
    rep  movsb
1858
    rep  movsb
1730
 
1859
 
1731
    pop  eax
1860
    pop  eax
1732
    mov  ebx,command
1861
    mov  ebx,command
1733
    add  ebx,[cmd]
1862
    add  ebx,[cmd]
1734
    sub  ebx,eax
1863
    sub  ebx,eax
1735
    sub  ebx,2
1864
    sub  ebx,2
1736
    mov  [edx+ebx-1],dword '    '
1865
    mov  [edx+ebx-1],dword '    '
1737
 
1866
 
1738
    add  [user_list_pos],ebx
1867
    add  [user_list_pos],ebx
1739
 
1868
 
1740
    mov  eax,[user_list_pos]
1869
    mov  eax,[user_list_pos]
1741
    mov  ebx,[text_start]
1870
    mov  ebx,[text_start]
1742
    add  ebx,120*70
1871
    add  ebx,120*70
1743
    mov  [ebx-4],eax
1872
    mov  [ebx-4],eax
1744
    call notify_channel_thread
1873
    call notify_channel_thread
1745
 
1874
 
1746
    popa
1875
    popa
1747
    ret
1876
    ret
1748
 
1877
 
1749
  user_list_pos dd 0x0
1878
  user_list_pos dd 0x0
1750
 
1879
 
1751
  no_user_list:
1880
  no_user_list:
1752
 
1881
 
1753
 
1882
 
1754
    cmp  [irc_command],dword '366 '  ; channel user names end
1883
    cmp  [irc_command],dword '366 '  ; channel user names end
1755
    jne  no_user_list_end
1884
    jne  no_user_list_end
1756
 
1885
 
1757
    mov  [user_list_pos],0
1886
    mov  [user_list_pos],0
1758
 
1887
 
1759
    popa
1888
    popa
1760
    ret
1889
    ret
1761
 
1890
 
1762
  no_user_list_end:
1891
  no_user_list_end:
1763
 
1892
 
1764
    mov  [command],byte '-'
1893
    mov  [command],byte '-'
1765
    call print_command_to_main
1894
    call print_command_to_main
1766
 
1895
 
1767
    popa
1896
    popa
1768
 
1897
 
1769
    ret
1898
    ret
1770
 
1899
 
1771
 
1900
 
1772
cresult db 0
1901
cresult db 0
1773
 
1902
 
1774
compare_to_nick:
1903
compare_to_nick:
1775
 
1904
 
1776
; input  : eax = start of compare
1905
; input  : eax = start of compare
1777
; output : [cresult] = 0 if match, [cresult]=1 if no match
1906
; output : [cresult] = 0 if match, [cresult]=1 if no match
1778
 
1907
 
1779
 
1908
 
1780
    pusha
1909
    pusha
1781
 
1910
 
1782
    mov  esi,eax
1911
    mov  esi,eax
1783
    mov  edi,0
1912
    mov  edi,0
1784
 
1913
 
1785
  new_nick_compare:
1914
  new_nick_compare:
1786
 
1915
 
1787
    mov  bl,byte [esi]
1916
    mov  bl,byte [esi]
1788
    mov  cl,byte [user_nick+4+edi]
1917
    mov  cl,byte [user_nick+4+edi]
1789
 
1918
 
1790
    cmp  bl,cl
1919
    cmp  bl,cl
1791
    jne  nonickm
1920
    jne  nonickm
1792
 
1921
 
1793
    add  esi,1
1922
    add  esi,1
1794
    add  edi,1
1923
    add  edi,1
1795
 
1924
 
1796
    cmp  edi,[user_nick]
1925
    cmp  edi,[user_nick]
1797
    jb	 new_nick_compare
1926
    jb	 new_nick_compare
1798
 
1927
 
1799
    movzx eax,byte [esi]
1928
    movzx eax,byte [esi]
1800
    cmp  eax,40
1929
    cmp  eax,40
1801
    jge  nonickm
1930
    jge  nonickm
1802
 
1931
 
1803
    popa
1932
    popa
1804
    mov  [cresult],0
1933
    mov  [cresult],0
1805
    ret
1934
    ret
1806
 
1935
 
1807
  nonickm:
1936
  nonickm:
1808
 
1937
 
1809
    popa
1938
    popa
1810
    mov  [cresult],1
1939
    mov  [cresult],1
1811
    ret
1940
    ret
1812
 
1941
 
1813
 
1942
 
1814
 
1943
 
1815
 
1944
 
1816
 
1945
 
1817
print_command_to_main:
1946
print_command_to_main:
1818
 
1947
 
1819
    pusha
1948
    pusha
1820
 
1949
 
1821
    mov  [text_start],I_END
1950
    mov  [text_start],I_END
1822
    mov  ecx,[rxs]
1951
    mov  ecx,[rxs]
1823
    imul ecx,11
1952
    imul ecx,11
1824
    mov  [pos],ecx
1953
    mov  [pos],ecx
1825
 
1954
 
1826
    mov  bl,13
1955
    mov  bl,13
1827
    call print_character
1956
    call print_character
1828
    mov  bl,10
1957
    mov  bl,10
1829
    call print_character
1958
    call print_character
1830
 
1959
 
1831
    mov  ecx,[cmd]
1960
    mov  ecx,[cmd]
1832
    sub  ecx,2
1961
    sub  ecx,2
1833
    mov  esi,command
1962
    mov  esi,command
1834
   newcmdc2:
1963
   newcmdc2:
1835
    mov  bl,[esi]
1964
    mov  bl,[esi]
1836
    call print_character
1965
    call print_character
1837
    inc  esi
1966
    inc  esi
1838
    loop newcmdc2
1967
    loop newcmdc2
1839
 
1968
 
1840
    mov   edx,I_END
1969
    mov   edx,I_END
1841
    call  draw_channel_text
1970
    call  draw_channel_text
1842
 
1971
 
1843
    popa
1972
    popa
1844
 
1973
 
1845
    ret
1974
    ret
1846
 
1975
 
1847
 
1976
 
1848
 
1977
 
1849
 
1978
 
1850
print_text:
1979
print_text:
1851
 
1980
 
1852
    pusha
1981
    pusha
1853
 
1982
 
1854
    mov  ecx,command-2
1983
    mov  ecx,command-2
1855
    add  ecx,[cmd]
1984
    add  ecx,[cmd]
1856
 
1985
 
1857
  ptr2:
1986
  ptr2:
1858
    mov  bl,[eax]
1987
    mov  bl,[eax]
1859
    cmp  bl,dl
1988
    cmp  bl,dl
1860
    je	 ptr_ret
1989
    je	 ptr_ret
1861
    cmp  bl,0
1990
    cmp  bl,0
1862
    je	 ptr_ret
1991
    je	 ptr_ret
1863
    call print_character
1992
    call print_character
1864
    inc  eax
1993
    inc  eax
1865
    cmp  eax,ecx
1994
    cmp  eax,ecx
1866
    jbe  ptr2
1995
    jbe  ptr2
1867
 
1996
 
1868
  ptr_ret:
1997
  ptr_ret:
1869
 
1998
 
1870
    mov  eax,[text_start]
1999
    mov  eax,[text_start]
1871
    mov  [eax+120*60],byte 1
2000
    mov  [eax+120*60],byte 1
1872
 
2001
 
1873
    popa
2002
    popa
1874
    ret
2003
    ret
1875
 
2004
 
1876
 
2005
 
1877
cp1251_table:
2006
cp1251_table:
1878
  db '?','?','?','?','?','?','?','?' , '?','?','?','?','?','?','?','?' ; 8
2007
  db '?','?','?','?','?','?','?','?' , '?','?','?','?','?','?','?','?' ; 8
1879
  db '?','?','?','?','?',$F9,'?','?' , '?','?','?','?','?','?','?','?' ; 9
2008
  db '?','?','?','?','?',$F9,'?','?' , '?','?','?','?','?','?','?','?' ; 9
1880
  db '?',$F6,$F7,'?',$FD,'?','?','?' , $F0,'?',$F2,'?','?','?','?',$F4 ; A
2009
  db '?',$F6,$F7,'?',$FD,'?','?','?' , $F0,'?',$F2,'?','?','?','?',$F4 ; A
1881
  db $F8,'?','?','?','?','?','?',$FA , $F1,$FC,$F3,'?','?','?','?',$F5 ; B
2010
  db $F8,'?','?','?','?','?','?',$FA , $F1,$FC,$F3,'?','?','?','?',$F5 ; B
1882
  db $80,$81,$82,$83,$84,$85,$86,$87 , $88,$89,$8A,$8B,$8C,$8D,$8E,$8F ; C
2011
  db $80,$81,$82,$83,$84,$85,$86,$87 , $88,$89,$8A,$8B,$8C,$8D,$8E,$8F ; C
1883
  db $90,$91,$92,$93,$94,$95,$96,$97 , $98,$99,$9A,$9B,$9C,$9D,$9E,$9F ; D
2012
  db $90,$91,$92,$93,$94,$95,$96,$97 , $98,$99,$9A,$9B,$9C,$9D,$9E,$9F ; D
1884
  db $A0,$A1,$A2,$A3,$A4,$A5,$A6,$A7 , $A8,$A9,$AA,$AB,$AC,$AD,$AE,$AF ; E
2013
  db $A0,$A1,$A2,$A3,$A4,$A5,$A6,$A7 , $A8,$A9,$AA,$AB,$AC,$AD,$AE,$AF ; E
1885
  db $E0,$E1,$E2,$E3,$E4,$E5,$E6,$E7 , $E8,$E9,$EA,$EB,$EC,$ED,$EE,$EF ; F
2014
  db $E0,$E1,$E2,$E3,$E4,$E5,$E6,$E7 , $E8,$E9,$EA,$EB,$EC,$ED,$EE,$EF ; F
1886
 
2015
 
1887
;    0   1   2   3   4   5   6   7     8   9   A   B   C   D   E   F
2016
;    0   1   2   3   4   5   6   7     8   9   A   B   C   D   E   F
1888
 
2017
 
1889
utf8_table:
2018
utf8_table:
1890
	times 80h dw 0x98C3	; default placeholder
2019
	times 80h dw 0x98C3	; default placeholder
1891
; 0x80-0xAF -> 0x90D0-0xBFD0
2020
; 0x80-0xAF -> 0x90D0-0xBFD0
1892
repeat 0x30
2021
repeat 0x30
1893
store byte 0xD0 at utf8_table+2*(%-1)
2022
store byte 0xD0 at utf8_table+2*(%-1)
1894
store byte 0x90+%-1 at utf8_table+2*%-1
2023
store byte 0x90+%-1 at utf8_table+2*%-1
1895
end repeat
2024
end repeat
1896
; 0xE0-0xEF -> 0x80D1-0x8FD1
2025
; 0xE0-0xEF -> 0x80D1-0x8FD1
1897
repeat 0x10
2026
repeat 0x10
1898
store byte 0xD1 at utf8_table+2*(0xE0-0x80+%-1)
2027
store byte 0xD1 at utf8_table+2*(0xE0-0x80+%-1)
1899
store byte 0x80+%-1 at utf8_table+2*(0xE0-0x80+%)-1
2028
store byte 0x80+%-1 at utf8_table+2*(0xE0-0x80+%)-1
1900
end repeat
2029
end repeat
1901
; 0xF0 -> 0x81D0, 0xF1 -> 0x91D1
2030
; 0xF0 -> 0x81D0, 0xF1 -> 0x91D1
1902
store dword 0x91D181D0 at utf8_table+2*(0xF0-0x80)
2031
store dword 0x91D181D0 at utf8_table+2*(0xF0-0x80)
1903
 
2032
 
1904
cp866_table:
2033
cp866_table:
1905
  db $C0,$C1,$C2,$C3,$C4,$C5,$C6,$C7 , $C8,$C9,$CA,$CB,$CC,$CD,$CE,$CF ; 8
2034
  db $C0,$C1,$C2,$C3,$C4,$C5,$C6,$C7 , $C8,$C9,$CA,$CB,$CC,$CD,$CE,$CF ; 8
1906
  db $D0,$D1,$D2,$D3,$D4,$D5,$D6,$D7 , $D8,$D9,$DA,$DB,$DC,$DD,$DE,$DF ; 9
2035
  db $D0,$D1,$D2,$D3,$D4,$D5,$D6,$D7 , $D8,$D9,$DA,$DB,$DC,$DD,$DE,$DF ; 9
1907
  db $E0,$E1,$E2,$E3,$E4,$E5,$E6,$E7 , $E8,$E9,$EA,$EB,$EC,$ED,$EE,$EF ; A
2036
  db $E0,$E1,$E2,$E3,$E4,$E5,$E6,$E7 , $E8,$E9,$EA,$EB,$EC,$ED,$EE,$EF ; A
1908
  db '?','?','?','?','?','?','?','?' , '?','?','?','?','?','?','?','?' ; B
2037
  db '?','?','?','?','?','?','?','?' , '?','?','?','?','?','?','?','?' ; B
1909
  db '?','?','?','?','?','?','?','?' , '?','?','?','?','?','?','?','?' ; C
2038
  db '?','?','?','?','?','?','?','?' , '?','?','?','?','?','?','?','?' ; C
1910
  db '?','?','?','?','?','?','?','?' , '?','?','?','?','?','?','?','?' ; D
2039
  db '?','?','?','?','?','?','?','?' , '?','?','?','?','?','?','?','?' ; D
1911
  db $F0,$F1,$F2,$F3,$F4,$F5,$F6,$F7 , $F8,$F9,$FA,$FB,$FC,$FD,$FE,$FF ; E
2040
  db $F0,$F1,$F2,$F3,$F4,$F5,$F6,$F7 , $F8,$F9,$FA,$FB,$FC,$FD,$FE,$FF ; E
1912
  db $A8,$B8,$AA,$BA,$AF,$BF,$A1,$A2 , $B0,$95,$B7,'?',$B9,$A4,'?','?' ; F
2041
  db $A8,$B8,$AA,$BA,$AF,$BF,$A1,$A2 , $B0,$95,$B7,'?',$B9,$A4,'?','?' ; F
1913
 
2042
 
1914
;    0   1   2   3   4   5   6   7     8   9   A   B   C   D   E   F
2043
;    0   1   2   3   4   5   6   7     8   9   A   B   C   D   E   F
1915
 
2044
 
1916
print_character:
2045
print_character:
1917
 
2046
 
1918
    pusha
2047
    pusha
1919
 
2048
 
1920
    cmp  bl,13	   ; line beginning
2049
    cmp  bl,13	   ; line beginning
1921
    jne  nobol
2050
    jne  nobol
1922
    mov  ecx,[pos]
2051
    mov  ecx,[pos]
1923
    add  ecx,1
2052
    add  ecx,1
1924
  boll1:
2053
  boll1:
1925
    sub  ecx,1
2054
    sub  ecx,1
1926
    mov  eax,ecx
2055
    mov  eax,ecx
1927
    xor  edx,edx
2056
    xor  edx,edx
1928
    mov  ebx,[rxs]
2057
    mov  ebx,[rxs]
1929
    div  ebx
2058
    div  ebx
1930
    cmp  edx,0
2059
    cmp  edx,0
1931
    jne  boll1
2060
    jne  boll1
1932
    mov  [pos],ecx
2061
    mov  [pos],ecx
1933
    jmp  newdata
2062
    jmp  newdata
1934
  nobol:
2063
  nobol:
1935
 
2064
 
1936
    cmp  bl,10	   ; line down
2065
    cmp  bl,10	   ; line down
1937
    jne  nolf
2066
    jne  nolf
1938
   addx1:
2067
   addx1:
1939
    add  [pos],dword 1
2068
    add  [pos],dword 1
1940
    mov  eax,[pos]
2069
    mov  eax,[pos]
1941
    xor  edx,edx
2070
    xor  edx,edx
1942
    mov  ecx,[rxs]
2071
    mov  ecx,[rxs]
1943
    div  ecx
2072
    div  ecx
1944
    cmp  edx,0
2073
    cmp  edx,0
1945
    jnz  addx1
2074
    jnz  addx1
1946
    mov  eax,[pos]
2075
    mov  eax,[pos]
1947
    jmp  cm1
2076
    jmp  cm1
1948
  nolf:
2077
  nolf:
1949
  no_lf_ret:
2078
  no_lf_ret:
1950
 
2079
 
1951
 
2080
 
1952
    cmp  bl,15	  ; character
2081
    cmp  bl,15	  ; character
1953
    jbe  newdata
2082
    jbe  newdata
1954
 
2083
 
1955
    mov  eax,[irc_data]
2084
    mov  eax,[irc_data]
1956
    shl  eax,8
2085
    shl  eax,8
1957
    mov  al,bl
2086
    mov  al,bl
1958
    mov  [irc_data],eax
2087
    mov  [irc_data],eax
1959
 
2088
 
1960
    mov  eax,[pos]
2089
    mov  eax,[pos]
1961
    call draw_data
2090
    call draw_data
1962
 
2091
 
1963
    mov  eax,[pos]
2092
    mov  eax,[pos]
1964
    add  eax,1
2093
    add  eax,1
1965
  cm1:
2094
  cm1:
1966
    mov  ebx,[scroll+4]
2095
    mov  ebx,[scroll+4]
1967
    imul ebx,[rxs]
2096
    imul ebx,[rxs]
1968
    cmp  eax,ebx
2097
    cmp  eax,ebx
1969
    jb	 noeaxz
2098
    jb	 noeaxz
1970
 
2099
 
1971
    mov  esi,[text_start]
2100
    mov  esi,[text_start]
1972
    add  esi,[rxs]
2101
    add  esi,[rxs]
1973
 
2102
 
1974
    mov  edi,[text_start]
2103
    mov  edi,[text_start]
1975
    mov  ecx,ebx
2104
    mov  ecx,ebx
1976
    cld
2105
    cld
1977
    rep  movsb
2106
    rep  movsb
1978
 
2107
 
1979
    mov  esi,[text_start]
2108
    mov  esi,[text_start]
1980
    mov  ecx,[rxs]
2109
    mov  ecx,[rxs]
1981
    imul ecx,61
2110
    imul ecx,61
1982
    add  esi,ecx
2111
    add  esi,ecx
1983
 
2112
 
1984
    mov  edi,[text_start]
2113
    mov  edi,[text_start]
1985
    mov  ecx,[rxs]
2114
    mov  ecx,[rxs]
1986
    imul ecx,60
2115
    imul ecx,60
1987
    add  edi,ecx
2116
    add  edi,ecx
1988
    mov  ecx,ebx
2117
    mov  ecx,ebx
1989
    cld
2118
    cld
1990
    rep  movsb
2119
    rep  movsb
1991
 
2120
 
1992
    mov  eax,ebx
2121
    mov  eax,ebx
1993
    sub  eax,[rxs]
2122
    sub  eax,[rxs]
1994
  noeaxz:
2123
  noeaxz:
1995
    mov  [pos],eax
2124
    mov  [pos],eax
1996
 
2125
 
1997
  newdata:
2126
  newdata:
1998
 
2127
 
1999
    mov  eax,[text_start]
2128
    mov  eax,[text_start]
2000
    mov  [eax+120*60],byte 1
2129
    mov  [eax+120*60],byte 1
2001
 
2130
 
2002
    popa
2131
    popa
2003
    ret
2132
    ret
2004
 
2133
 
2005
notify_channel_thread:
2134
notify_channel_thread:
2006
	pusha
2135
	pusha
2007
	mov	eax, [text_start]
2136
	mov	eax, [text_start]
2008
	mov	ecx, [eax+120*60+12]
2137
	mov	ecx, [eax+120*60+12]
2009
	mcall	60, 2, , 0, 1
2138
	mcall	60, 2, , 0, 1
2010
	popa
2139
	popa
2011
	ret
2140
	ret
2012
 
2141
 
2013
 
2142
 
2014
draw_data:
2143
draw_data:
2015
 
2144
 
2016
    pusha
2145
    pusha
2017
 
2146
 
2018
    and  ebx,0xff
2147
    and  ebx,0xff
2019
    add  eax,[text_start]
2148
    add  eax,[text_start]
2020
    mov  [eax],bl
2149
    mov  [eax],bl
2021
 
2150
 
2022
    popa
2151
    popa
2023
    ret
2152
    ret
2024
 
2153
 
2025
 
2154
 
2026
 
2155
 
2027
draw_window:
2156
draw_window:
2028
 
2157
 
2029
    pusha
2158
    pusha
2030
 
2159
 
2031
    mov  eax,12
2160
    mov  eax,12
2032
    mov  ebx,1
2161
    mov  ebx,1
2033
    mcall
2162
    mcall
2034
 
2163
 
2035
    xor  eax,eax		   ; draw window
2164
    xor  eax,eax		   ; draw window
2036
    mov  ebx,5*65536+499
2165
    mov  ebx,5*65536+499
2037
    mov  ecx,5*65536+381
2166
    mov  ecx,5*65536+381
2038
    mov  edx,[wcolor]
2167
    mov  edx,[wcolor]
2039
    add  edx,0x14ffffff
2168
    add  edx,0x14ffffff
2040
    mov  edi,title
2169
    mov  edi,title
2041
    mcall
2170
    mcall
2042
 
2171
 
2043
    mov  eax,8                     ; button: change encoding
2172
    mov  eax,8                     ; button: change encoding
2044
    mov  ebx,(ENCODING_X-2)*65536+38
2173
    mov  ebx,(ENCODING_X-2)*65536+38
2045
    mov  ecx,(ENCODING_Y-2)*65536+12
2174
    mov  ecx,(ENCODING_Y-2)*65536+12
2046
    mov  edx,21
2175
    mov  edx,21
2047
    mov  esi,[main_button]
2176
    mov  esi,[main_button]
2048
    mcall
2177
    mcall
2049
 
2178
 
2050
;    mov  eax,8			   ; button: open socket
2179
;    mov  eax,8			   ; button: open socket
2051
    mov  ebx,43*65536+22
2180
    mov  ebx,43*65536+22
2052
    mov  ecx,241*65536+10
2181
    mov  ecx,241*65536+10
2053
;    mov  edx,22
2182
;    mov  edx,22
2054
    inc  edx
2183
    inc  edx
2055
    mcall
2184
    mcall
2056
 
2185
 
2057
    ;mov  eax,8			   ; button: send userinfo
2186
    ;mov  eax,8			   ; button: send userinfo
2058
    mov  ebx,180*65536+22
2187
    mov  ebx,180*65536+22
2059
    mov  ecx,241*65536+10
2188
    mov  ecx,241*65536+10
2060
;    mov  edx,23
2189
;    mov  edx,23
2061
    inc  edx
2190
    inc  edx
2062
    mcall
2191
    mcall
2063
 
2192
 
2064
    ;mov  eax,8			   ; button: close socket
2193
    ;mov  eax,8			   ; button: close socket
2065
    mov  ebx,317*65536+22
2194
    mov  ebx,317*65536+22
2066
    mov  ecx,241*65536+10
2195
    mov  ecx,241*65536+10
2067
;    mov  edx,24
2196
;    mov  edx,24
2068
    inc  edx
2197
    inc  edx
2069
    mcall
2198
    mcall
2070
 
2199
 
2071
    mov  eax,38 		   ; line
2200
    mov  eax,38 		   ; line
2072
    mov  ebx,5*65536+494
2201
    mov  ebx,5*65536+494
2073
    mov  ecx,148*65536+148
2202
    mov  ecx,148*65536+148
2074
    mov  edx,[main_line]
2203
    mov  edx,[main_line]
2075
    mcall
2204
    mcall
2076
    add  ecx,1*65536+1
2205
    add  ecx,1*65536+1
2077
 
2206
 
2078
    mov  eax,38 		   ; line
2207
    mov  eax,38 		   ; line
2079
    mov  ebx,5*65536+494
2208
    mov  ebx,5*65536+494
2080
    mov  ecx,166*65536+166
2209
    mov  ecx,166*65536+166
2081
    mcall
2210
    mcall
2082
    add  ecx,1*65536+1
2211
    add  ecx,1*65536+1
2083
 
2212
 
2084
    mov  eax,38 		   ; line
2213
    mov  eax,38 		   ; line
2085
    mov  ebx,410*65536+410
2214
    mov  ebx,410*65536+410
2086
    mov  ecx,22*65536+148
2215
    mov  ecx,22*65536+148
2087
    mcall
2216
    mcall
2088
    add  ebx,1*65536+1
2217
    add  ebx,1*65536+1
2089
 
2218
 
2090
    mov  ebx,25*65536+183	   ; info text
2219
    mov  ebx,25*65536+183	   ; info text
2091
    mov  ecx,0x000000
2220
    mov  ecx,0x000000
2092
    mov  edx,text
2221
    mov  edx,text
2093
    mov  esi,70
2222
    mov  esi,70
2094
  newline:
2223
  newline:
2095
    mov  eax,4
2224
    mov  eax,4
2096
    mcall
2225
    mcall
2097
    add  ebx,12
2226
    add  ebx,12
2098
    add  edx,70
2227
    add  edx,70
2099
    cmp  [edx],byte 'x'
2228
    cmp  [edx],byte 'x'
2100
    jne  newline
2229
    jne  newline
2101
 
2230
 
2102
    mov  edx,I_END		  ; text from server
2231
    mov  edx,I_END		  ; text from server
2103
    call draw_channel_text
2232
    call draw_channel_text
2104
 
2233
 
2105
    call print_entry
2234
    call print_entry
2106
 
2235
 
2107
    mov  eax,12
2236
    mov  eax,12
2108
    mov  ebx,2
2237
    mov  ebx,2
2109
    mcall
2238
    mcall
2110
 
2239
 
2111
    popa
2240
    popa
2112
 
2241
 
2113
    ret
2242
    ret
2114
 
2243
 
2115
update_status:
2244
update_status:
2116
	pusha
2245
	pusha
2117
	mov	esi, [status]
2246
	mov	esi, [status]
2118
	mov	edi, text + 7*70 + 22
2247
	mov	edi, text + 7*70 + 22
2119
	mov	ecx, status_text_len
2248
	mov	ecx, status_text_len
2120
	push	ecx
2249
	push	ecx
2121
	imul	esi, ecx
2250
	imul	esi, ecx
2122
	add	esi, status_text
2251
	add	esi, status_text
2123
	mov	edx, edi
2252
	mov	edx, edi
2124
	rep	movsb
2253
	rep	movsb
2125
	pop	esi
2254
	pop	esi
2126
	mcall	4, STATUS_X*65536+STATUS_Y, 0x40000000, , , 0xFFFFFF
2255
	mcall	4, STATUS_X*65536+STATUS_Y, 0x40000000, , , 0xFFFFFF
2127
	popa
2256
	popa
2128
	ret
2257
	ret
2129
 
2258
 
2130
update_encoding:
2259
update_encoding:
2131
	pusha
2260
	pusha
2132
	mov	edx, 21
2261
	mov	edx, 21
2133
	mcall	8	; delete button
2262
	mcall	8	; delete button
2134
	mov	esi, [main_button]
2263
	mov	esi, [main_button]
2135
	mcall	, <(ENCODING_X-2),38>, <(ENCODING_Y-2),12>	; recreate it
2264
	mcall	, <(ENCODING_X-2),38>, <(ENCODING_Y-2),12>	; recreate it
2136
	mov	esi, [encoding]
2265
	mov	esi, [encoding]
2137
	mov	edi, text + 3*70 + 15
2266
	mov	edi, text + 3*70 + 15
2138
	mov	ecx, encoding_text_len
2267
	mov	ecx, encoding_text_len
2139
	push	ecx
2268
	push	ecx
2140
	imul	esi, ecx
2269
	imul	esi, ecx
2141
	add	esi, encoding_text
2270
	add	esi, encoding_text
2142
	mov	edx, edi
2271
	mov	edx, edi
2143
	rep	movsb
2272
	rep	movsb
2144
	pop	esi
2273
	pop	esi
2145
	mcall	4, ENCODING_X*65536+ENCODING_Y, 0
2274
	mcall	4, ENCODING_X*65536+ENCODING_Y, 0
2146
	popa
2275
	popa
2147
	ret
2276
	ret
2148
 
2277
 
2149
main_line    dd 0x000000
2278
main_line    dd 0x000000
2150
main_button  dd 0x6565cc
2279
main_button  dd 0x6565cc
2151
 
2280
 
2152
 
2281
 
2153
text:
2282
text:
2154
 
2283
 
2155
db '   Real name : KolibriOS User  - change with eg /areal Jill User      '
2284
db '   Real name : KolibriOS User  - change with eg /areal Jill User      '
2156
db '   Nick      : kolibri_user    - change with eg /anick Jill           '
2285
db '   Nick      : kolibri_user    - change with eg /anick Jill           '
2157
db '   Server    : kolibrios.org   - change with eg /aserv irc.by         '
2286
db '   Server    : kolibrios.org   - change with eg /aserv irc.by         '
2158
db '   Encoding  : UTF-8                                                  '
2287
db '   Encoding  : UTF-8                                                  '
2159
db '                                                                      '
2288
db '                                                                      '
2160
db '        1) Connect             2) Send userinfo       3) Disconnect   '
2289
db '        1) Connect             2) Send userinfo       3) Disconnect   '
2161
db '                                                                      '
2290
db '                                                                      '
2162
db '   Connection status: disconnected                                    '
2291
db '   Connection status: disconnected                                    '
2163
db '                                                                      '
2292
db '                                                                      '
2164
db '   Commands after established connection:                             '
2293
db '   Commands after established connection:                             '
2165
db '                                                                      '
2294
db '                                                                      '
2166
db '   /join #ChannelName         - eg /join #general                     '
2295
db '   /join #ChannelName         - eg /join #general                     '
2167
db '   /part #ChannelName         - eg /part #windows                     '
2296
db '   /part #ChannelName         - eg /part #windows                     '
2168
db '   /query Nickname            - eg /query Mary                        '
2297
db '   /query Nickname            - eg /query Mary                        '
2169
db '   /quit                      - Quit server and Close socket          '
2298
db '   /quit                      - Quit server and Close socket          '
2170
db 'x' ; <- END MARKER, DONT DELETE
2299
db 'x' ; <- END MARKER, DONT DELETE
2171
 
2300
 
2172
status_text:
2301
status_text:
2173
db	'disconnected            '
2302
db	'disconnected            '
2174
db      'resolving server name...'
2303
db      'resolving server name...'
2175
db	'connecting...           '
2304
db	'connecting...           '
2176
db	'connected               '
2305
db	'connected               '
2177
status_text_len = 24
2306
status_text_len = 24
2178
 
2307
 
2179
encoding_text:
2308
encoding_text:
2180
db	'CP866 '
2309
db	'CP866 '
2181
db	'CP1251'
2310
db	'CP1251'
2182
db	'UTF-8 '
2311
db	'UTF-8 '
2183
encoding_text_len = 6
2312
encoding_text_len = 6
2184
 
2313
 
2185
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2314
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2186
;
2315
;
2187
;                        CHANNEL THREADS
2316
;                        CHANNEL THREADS
2188
;
2317
;
2189
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2318
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2190
 
2319
 
2191
 
2320
 
2192
 
2321
 
2193
channel_thread:
2322
channel_thread:
2194
 
2323
 
2195
;    mov   ebp,[thread_nro]
2324
;    mov   ebp,[thread_nro]
2196
    pop   ebp
2325
    pop   ebp
2197
    pop   edx
2326
    pop   edx
2198
 
2327
 
2199
    mov   eax,ebp
2328
    mov   eax,ebp
2200
    shl   eax,14
2329
    shl   eax,14
2201
    add   eax,0x80000
2330
    add   eax,0x80000
2202
    mov   esp,eax
2331
    mov   esp,eax
2203
 
2332
 
2204
;    mov   edi,ebp	 ; clear thread memory
2333
;    mov   edi,ebp	 ; clear thread memory
2205
;    imul  edi,120*80
2334
;    imul  edi,120*80
2206
;    add   edi,I_END
2335
;    add   edi,I_END
2207
;    mov   ecx,120*80
2336
;    mov   ecx,120*80
2208
;    mov   al,32
2337
;    mov   al,32
2209
;    cld
2338
;    cld
2210
;    rep   stosb
2339
;    rep   stosb
2211
 
2340
 
2212
; Create IPC buffer in the stack.
2341
; Create IPC buffer in the stack.
2213
	push	eax
2342
	push	eax
2214
	push	eax
2343
	push	eax
2215
	push	eax
2344
	push	eax
2216
	push	8
2345
	push	8
2217
	push	0
2346
	push	0
2218
	mov	ecx, esp
2347
	mov	ecx, esp
2219
	push	edx
2348
	push	edx
2220
	mcall	60, 1, , 20
2349
	mcall	60, 1, , 20
2221
	pop	edx
2350
	pop	edx
2222
	mcall	40, 1100111b
2351
	mcall	40, 1100111b
2223
 
2352
 
2224
;    mov   edx,[thread_screen]
2353
;    mov   edx,[thread_screen]
2225
 
2354
 
2226
  thread_redraw:
2355
  thread_redraw:
2227
    call  thread_draw_window
2356
    call  thread_draw_window
2228
    call  draw_channel_text
2357
    call  draw_channel_text
2229
    call  print_user_list
2358
    call  print_user_list
2230
    call  print_entry
2359
    call  print_entry
2231
 
2360
 
2232
  w_t:
2361
  w_t:
2233
 
2362
 
2234
    mov  esi,ebp
2363
    mov  esi,ebp
2235
    imul esi,120*80
2364
    imul esi,120*80
2236
    add  esi,I_END
2365
    add  esi,I_END
2237
    cmp  [esi+120*60+4],byte 1
2366
    cmp  [esi+120*60+4],byte 1
2238
    jne  no_channel_leave
2367
    jne  no_channel_leave
2239
    mov  [esi+120*60+4],byte 0
2368
    mov  [esi+120*60+4],byte 0
2240
    mov  edi,ebp
2369
    mov  edi,ebp
2241
    shl  edi,5
2370
    shl  edi,5
2242
    mov  dword [channel_list+edi],dword '    '
2371
    mov  dword [channel_list+edi],dword '    '
2243
    mov  byte  [channel_list+edi+31],byte 1
2372
    mov  byte  [channel_list+edi+31],byte 1
2244
    mov  eax,-1
2373
    mov  eax,-1
2245
    mcall
2374
    mcall
2246
  no_channel_leave:
2375
  no_channel_leave:
2247
 
2376
 
2248
    mcall 10
2377
    mcall 10
2249
    dec   eax
2378
    dec   eax
2250
    jz    thread_redraw
2379
    jz    thread_redraw
2251
    dec   eax
2380
    dec   eax
2252
    jz    thread_key
2381
    jz    thread_key
2253
    dec   eax
2382
    dec   eax
2254
    jz    thread_end
2383
    jz    thread_end
2255
    cmp   al,4
2384
    cmp   al,4
2256
    jz    thread_ipc
2385
    jz    thread_ipc
2257
    call  check_mouse
2386
    call  check_mouse
2258
    jmp   w_t
2387
    jmp   w_t
2259
  thread_end:
2388
  thread_end:
2260
    mov   eax,17
2389
    mov   eax,17
2261
    mcall
2390
    mcall
2262
    mov   eax,ebp
2391
    mov   eax,ebp
2263
    imul  eax,120*80
2392
    imul  eax,120*80
2264
    add   eax,I_END
2393
    add   eax,I_END
2265
    cmp   [eax+120*60+8],byte 0 ; channel window
2394
    cmp   [eax+120*60+8],byte 0 ; channel window
2266
    je	  not_close
2395
    je	  not_close
2267
    mov   eax,ebp
2396
    mov   eax,ebp
2268
    shl   eax,5
2397
    shl   eax,5
2269
    add   eax,channel_list
2398
    add   eax,channel_list
2270
    mov   [eax],dword '    '
2399
    mov   [eax],dword '    '
2271
    mov   [eax+31],byte 1
2400
    mov   [eax+31],byte 1
2272
    mov   eax,-1
2401
    mov   eax,-1
2273
    mcall
2402
    mcall
2274
  not_close:
2403
  not_close:
2275
    mov   [text_start],eax
2404
    mov   [text_start],eax
2276
    mov   eax,nocl
2405
    mov   eax,nocl
2277
  newcc:
2406
  newcc:
2278
    mov   bl,[eax]
2407
    mov   bl,[eax]
2279
    call  print_character
2408
    call  print_character
2280
    inc   eax
2409
    inc   eax
2281
    cmp   [eax],byte 0
2410
    cmp   [eax],byte 0
2282
    jne   newcc
2411
    jne   newcc
2283
    call  draw_channel_text
2412
    call  draw_channel_text
2284
    jmp   w_t
2413
    jmp   w_t
2285
   nocl:   db  13,10,'To exit channel, use PART or QUIT command.',0
2414
   nocl:   db  13,10,'To exit channel, use PART or QUIT command.',0
2286
  thread_ipc:
2415
  thread_ipc:
2287
    mov   byte [esp+4], 8 ; erase message from IPC buffer
2416
    mov   byte [esp+4], 8 ; erase message from IPC buffer
2288
   no_end:
2417
   no_end:
2289
 
2418
 
2290
    cmp   [edx+120*60],byte 1
2419
    cmp   [edx+120*60],byte 1
2291
    jne   no_update
2420
    jne   no_update
2292
    mov   [edx+120*60],byte 0
2421
    mov   [edx+120*60],byte 0
2293
    call  draw_channel_text
2422
    call  draw_channel_text
2294
  no_update:
2423
  no_update:
2295
 
2424
 
2296
    call  print_user_list
2425
    call  print_user_list
2297
 
2426
 
2298
  nopri2:
2427
  nopri2:
2299
 
2428
 
2300
    jmp   w_t
2429
    jmp   w_t
2301
 
2430
 
2302
 
2431
 
2303
 
2432
 
2304
check_mouse:
2433
check_mouse:
2305
 
2434
 
2306
    pusha
2435
    pusha
2307
 
2436
 
2308
    mov  eax,37
2437
    mov  eax,37
2309
    mov  ebx,1
2438
    mov  ebx,1
2310
    mcall
2439
    mcall
2311
 
2440
 
2312
    mov  ebx,eax
2441
    mov  ebx,eax
2313
    shr  eax,16
2442
    shr  eax,16
2314
    and  ebx,0xffff
2443
    and  ebx,0xffff
2315
 
2444
 
2316
    cmp  eax,420
2445
    cmp  eax,420
2317
    jb	 no_mouse
2446
    jb	 no_mouse
2318
    cmp  eax,494
2447
    cmp  eax,494
2319
    jg	 no_mouse
2448
    jg	 no_mouse
2320
 
2449
 
2321
    cmp  ebx,145
2450
    cmp  ebx,145
2322
    jg	 no_mouse
2451
    jg	 no_mouse
2323
    cmp  ebx,23
2452
    cmp  ebx,23
2324
    jb	 no_mouse
2453
    jb	 no_mouse
2325
 
2454
 
2326
 
2455
 
2327
    cmp  ebx,100
2456
    cmp  ebx,100
2328
    jb	 no_plus
2457
    jb	 no_plus
2329
    mov  eax,ebp
2458
    mov  eax,ebp
2330
    imul eax,120*80
2459
    imul eax,120*80
2331
    add  eax,120*70+I_END
2460
    add  eax,120*70+I_END
2332
    inc  dword [eax-8]
2461
    inc  dword [eax-8]
2333
    call print_user_list
2462
    call print_user_list
2334
    mov  eax,5
2463
    mov  eax,5
2335
    mov  ebx,8
2464
    mov  ebx,8
2336
    mcall
2465
    mcall
2337
    jmp  no_mouse
2466
    jmp  no_mouse
2338
  no_plus:
2467
  no_plus:
2339
 
2468
 
2340
    cmp  ebx,80
2469
    cmp  ebx,80
2341
    jg	 no_mouse
2470
    jg	 no_mouse
2342
    mov  eax,ebp
2471
    mov  eax,ebp
2343
    imul eax,120*80
2472
    imul eax,120*80
2344
    add  eax,120*70+I_END
2473
    add  eax,120*70+I_END
2345
    cmp  dword [eax-8],dword 0
2474
    cmp  dword [eax-8],dword 0
2346
    je	 no_mouse
2475
    je	 no_mouse
2347
    dec  dword [eax-8]
2476
    dec  dword [eax-8]
2348
    call print_user_list
2477
    call print_user_list
2349
    mov  eax,5
2478
    mov  eax,5
2350
    mov  ebx,8
2479
    mov  ebx,8
2351
    mcall
2480
    mcall
2352
 
2481
 
2353
  no_minus:
2482
  no_minus:
2354
 
2483
 
2355
  no_mouse:
2484
  no_mouse:
2356
 
2485
 
2357
    popa
2486
    popa
2358
 
2487
 
2359
    ret
2488
    ret
2360
 
2489
 
2361
 
2490
 
2362
 
2491
 
2363
 
2492
 
2364
thread_key:
2493
thread_key:
2365
 
2494
 
2366
    mov  eax,2
2495
    mov  eax,2
2367
    mcall
2496
    mcall
2368
 
2497
 
2369
    shr  eax,8
2498
    shr  eax,8
2370
 
2499
 
2371
    cmp  eax,8
2500
    cmp  eax,8
2372
    jne  no_bks
2501
    jne  no_bks
2373
    cmp  [xpos],0
2502
    cmp  [xpos],0
2374
    je	 w_t
2503
    je	 w_t
2375
    dec  [xpos]
2504
    dec  [xpos]
2376
    call print_entry
2505
    call print_entry
2377
    jmp  w_t
2506
    jmp  w_t
2378
   no_bks:
2507
   no_bks:
2379
 
2508
 
2380
    cmp  eax,20
2509
    cmp  eax,20
2381
    jbe  no_character
2510
    jbe  no_character
2382
    mov  ebx,[xpos]
2511
    mov  ebx,[xpos]
2383
    mov  [send_string+ebx],al
2512
    mov  [send_string+ebx],al
2384
    inc  [xpos]
2513
    inc  [xpos]
2385
    cmp  [xpos],80
2514
    cmp  [xpos],80
2386
    jb	 xpok
2515
    jb	 xpok
2387
    mov  [xpos],79
2516
    mov  [xpos],79
2388
  xpok:
2517
  xpok:
2389
    call print_entry
2518
    call print_entry
2390
    jmp  w_t
2519
    jmp  w_t
2391
  no_character:
2520
  no_character:
2392
 
2521
 
2393
    cmp  eax,13
2522
    cmp  eax,13
2394
    jne  no_send
2523
    jne  no_send
2395
    cmp  [xpos],0
2524
    cmp  [xpos],0
2396
    je	 no_send
2525
    je	 no_send
2397
    mov  dword [send_to_channel],ebp
2526
    mov  dword [send_to_channel],ebp
2398
    pusha
2527
    pusha
2399
    mcall 60,2,[main_PID],0,1
2528
    mcall 60,2,[main_PID],0,1
2400
  wait_for_sending:
2529
  wait_for_sending:
2401
    mov  eax,5
2530
    mov  eax,5
2402
    mov  ebx,1
2531
    mov  ebx,1
2403
    mcall
2532
    mcall
2404
    cmp  dword [ipcbuf+4],8
2533
    cmp  dword [ipcbuf+4],8
2405
    jne	 wait_for_sending
2534
    jne	 wait_for_sending
2406
    popa
2535
    popa
2407
    call draw_channel_text
2536
    call draw_channel_text
2408
    call print_entry
2537
    call print_entry
2409
    jmp  w_t
2538
    jmp  w_t
2410
  no_send:
2539
  no_send:
2411
 
2540
 
2412
    jmp  w_t
2541
    jmp  w_t
2413
 
2542
 
2414
 
2543
 
2415
 
2544
 
2416
 
2545
 
2417
 
2546
 
2418
 
2547
 
2419
draw_channel_text:
2548
draw_channel_text:
2420
 
2549
 
2421
    pusha
2550
    pusha
2422
 
2551
 
2423
    mov   eax,4
2552
    mov   eax,4
2424
    mov   ebx,10*65536+26
2553
    mov   ebx,10*65536+26
2425
    mov   ecx,12
2554
    mov   ecx,12
2426
    mov   esi,[rxs]
2555
    mov   esi,[rxs]
2427
  dct:
2556
  dct:
2428
    pusha
2557
    pusha
2429
    mov   cx,bx
2558
    mov   cx,bx
2430
    shl   ecx,16
2559
    shl   ecx,16
2431
    mov   cx,9
2560
    mov   cx,9
2432
    mov   eax,13
2561
    mov   eax,13
2433
    mov   ebx,10*65536
2562
    mov   ebx,10*65536
2434
    mov   bx,word [rxs]
2563
    mov   bx,word [rxs]
2435
    imul  bx,6
2564
    imul  bx,6
2436
    mov   edx,0xffffff
2565
    mov   edx,0xffffff
2437
    mcall
2566
    mcall
2438
    popa
2567
    popa
2439
    push  ecx
2568
    push  ecx
2440
    mov   eax,4
2569
    mov   eax,4
2441
    mov   ecx,0
2570
    mov   ecx,0
2442
    cmp   [edx],word '* '
2571
    cmp   [edx],word '* '
2443
    jne   no_red
2572
    jne   no_red
2444
    mov   ecx,0x0000ff
2573
    mov   ecx,0x0000ff
2445
   no_red:
2574
   no_red:
2446
    cmp   [edx],word '**'
2575
    cmp   [edx],word '**'
2447
    jne   no_light_blue
2576
    jne   no_light_blue
2448
    cmp   [edx+2],byte '*'
2577
    cmp   [edx+2],byte '*'
2449
    jne   no_light_blue
2578
    jne   no_light_blue
2450
    mov   ecx,0x0000ff
2579
    mov   ecx,0x0000ff
2451
  no_light_blue:
2580
  no_light_blue:
2452
    cmp   [edx],byte '#'
2581
    cmp   [edx],byte '#'
2453
    jne   no_blue
2582
    jne   no_blue
2454
    mov   ecx,0x0000ff
2583
    mov   ecx,0x0000ff
2455
  no_blue:
2584
  no_blue:
2456
    mcall
2585
    mcall
2457
    add   edx,[rxs]
2586
    add   edx,[rxs]
2458
    add   ebx,10
2587
    add   ebx,10
2459
    pop   ecx
2588
    pop   ecx
2460
    loop  dct
2589
    loop  dct
2461
 
2590
 
2462
    popa
2591
    popa
2463
    ret
2592
    ret
2464
 
2593
 
2465
 
2594
 
2466
 
2595
 
2467
 
2596
 
2468
 
2597
 
2469
thread_draw_window:
2598
thread_draw_window:
2470
 
2599
 
2471
    pusha
2600
    pusha
2472
 
2601
 
2473
    mov  eax,12
2602
    mov  eax,12
2474
    mov  ebx,1
2603
    mov  ebx,1
2475
    mcall
2604
    mcall
2476
 
2605
 
2477
    mov  ebx,ebp		   ; draw window
2606
    mov  ebx,ebp		   ; draw window
2478
    shl  ebx,16+4
2607
    shl  ebx,16+4
2479
    xor  eax,eax
2608
    xor  eax,eax
2480
    mov  ecx,ebx
2609
    mov  ecx,ebx
2481
    mov  bx,499
2610
    mov  bx,499
2482
    mov  cx,170
2611
    mov  cx,170
2483
 
2612
 
2484
    mov  edx,[wcolor]
2613
    mov  edx,[wcolor]
2485
    add  edx,0x03ffffff
2614
    add  edx,0x03ffffff
2486
    mov  esi,0x80555599
2615
    mov  esi,0x80555599
2487
    mov  edi,0x00ffffff
2616
    mov  edi,0x00ffffff
2488
 
2617
 
2489
    mcall
2618
    mcall
2490
 
2619
 
2491
    mov  eax,ebp		   ; label
2620
    mov  eax,ebp		   ; label
2492
    add  eax,48
2621
    add  eax,48
2493
    mov  [labelc+14],al
2622
    mov  [labelc+14],al
2494
    mov  eax,ebp
2623
    mov  eax,ebp
2495
    shl  eax,5
2624
    shl  eax,5
2496
    add  eax,channel_list
2625
    add  eax,channel_list
2497
    mov  esi,eax
2626
    mov  esi,eax
2498
    mov  edi,labelc+17
2627
    mov  edi,labelc+17
2499
    movzx ecx,byte [eax+31]
2628
    movzx ecx,byte [eax+31]
2500
    cld
2629
    cld
2501
    rep   movsb
2630
    rep   movsb
2502
 
2631
 
2503
    mov  esi,17 		   ; print label
2632
    mov  esi,17 		   ; print label
2504
    movzx ebx,byte [eax+31]
2633
    movzx ebx,byte [eax+31]
2505
    add  esi,ebx
2634
    add  esi,ebx
2506
    mov  eax,4
2635
    mov  eax,4
2507
    mov  ebx,9*65536+8
2636
    mov  ebx,9*65536+8
2508
    mov  ecx,0x00ffffff
2637
    mov  ecx,0x00ffffff
2509
    mov  edx,labelc
2638
    mov  edx,labelc
2510
    mcall
2639
    mcall
2511
 
2640
 
2512
    mov  eax,38 		   ; line
2641
    mov  eax,38 		   ; line
2513
    mov  ebx,5*65536+494
2642
    mov  ebx,5*65536+494
2514
    mov  ecx,148*65536+148
2643
    mov  ecx,148*65536+148
2515
    mov  edx,[channel_line_sun]
2644
    mov  edx,[channel_line_sun]
2516
    mcall
2645
    mcall
2517
    add  ecx,1*65536+1
2646
    add  ecx,1*65536+1
2518
    mov  edx,[channel_line_shadow]
2647
    mov  edx,[channel_line_shadow]
2519
    mcall
2648
    mcall
2520
 
2649
 
2521
 
2650
 
2522
    ;mov  eax,38 		   ; line
2651
    ;mov  eax,38 		   ; line
2523
    mov  ebx,410*65536+410
2652
    mov  ebx,410*65536+410
2524
    mov  ecx,22*65536+148
2653
    mov  ecx,22*65536+148
2525
    mov  edx,[channel_line_sun]
2654
    mov  edx,[channel_line_sun]
2526
    mcall
2655
    mcall
2527
    add  ebx,1*65536+1
2656
    add  ebx,1*65536+1
2528
    mov  edx,[channel_line_shadow]
2657
    mov  edx,[channel_line_shadow]
2529
    mcall
2658
    mcall
2530
 
2659
 
2531
    mov  eax,12
2660
    mov  eax,12
2532
    mov  ebx,2
2661
    mov  ebx,2
2533
    mcall
2662
    mcall
2534
 
2663
 
2535
    popa
2664
    popa
2536
 
2665
 
2537
    ret
2666
    ret
2538
 
2667
 
2539
 
2668
 
2540
; DATA AREA
2669
; DATA AREA
2541
 
2670
 
2542
socket	dd  0x0
2671
socket	dd  0x0
2543
 
2672
 
2544
bgc  dd  0x000000
2673
bgc  dd  0x000000
2545
     dd  0x000000
2674
     dd  0x000000
2546
     dd  0x00ff00
2675
     dd  0x00ff00
2547
     dd  0x0000ff
2676
     dd  0x0000ff
2548
     dd  0x005500
2677
     dd  0x005500
2549
     dd  0xff00ff
2678
     dd  0xff00ff
2550
     dd  0x00ffff
2679
     dd  0x00ffff
2551
     dd  0x770077
2680
     dd  0x770077
2552
 
2681
 
2553
tc   dd  0xffffff
2682
tc   dd  0xffffff
2554
     dd  0xff00ff
2683
     dd  0xff00ff
2555
     dd  0xffffff
2684
     dd  0xffffff
2556
     dd  0xffffff
2685
     dd  0xffffff
2557
     dd  0xffffff
2686
     dd  0xffffff
2558
     dd  0xffffff
2687
     dd  0xffffff
2559
     dd  0xffffff
2688
     dd  0xffffff
2560
     dd  0xffffff
2689
     dd  0xffffff
2561
 
2690
 
2562
channel_line_sun    dd 0x9999ff
2691
channel_line_sun    dd 0x9999ff
2563
channel_line_shadow dd 0x666699
2692
channel_line_shadow dd 0x666699
2564
 
2693
 
2565
cursor_on_off  dd  0x0
2694
cursor_on_off  dd  0x0
2566
 
2695
 
2567
max_windows    dd  20
2696
max_windows    dd  20
2568
 
2697
 
2569
thread_stack   dd  0x9fff0
2698
thread_stack   dd  0x9fff0
2570
;thread_nro     dd 1
2699
;thread_nro     dd 1
2571
;thread_screen  dd I_END+120*80*1
2700
;thread_screen  dd I_END+120*80*1
2572
 
2701
 
2573
action_header_blue  db	10,'*** ',0
2702
action_header_blue  db	10,'*** ',0
2574
action_header_red   db	10,'*** ',0
2703
action_header_red   db	10,'*** ',0
2575
 
2704
 
2576
action_header_short db	10,'* ',0
2705
action_header_short db	10,'* ',0
2577
 
2706
 
2578
has_left_channel db  ' has left ',0
2707
has_left_channel db  ' has left ',0
2579
joins_channel	 db  ' has joined ',0
2708
joins_channel	 db  ' has joined ',0
2580
is_now_known_as  db  ' is now known as ',0
2709
is_now_known_as  db  ' is now known as ',0
2581
has_quit_irc	 db  ' has quit IRC',0
2710
has_quit_irc	 db  ' has quit IRC',0
2582
sets_mode	 db  ' sets mode ',0
2711
sets_mode	 db  ' sets mode ',0
2583
kicked		 db  ' kicked from ',0
2712
kicked		 db  ' kicked from ',0
2584
 
2713
 
2585
index_list_1	 dd  0x0000bb
2714
index_list_1	 dd  0x0000bb
2586
index_list_2	 dd  0x0000ff
2715
index_list_2	 dd  0x0000ff
2587
 
2716
 
2588
posx		 dd  0x0
2717
posx		 dd  0x0
2589
incoming_pos	 dd  0x0
2718
incoming_pos	 dd  0x0
2590
incoming_string: times 128 db 0
2719
incoming_string: times 128 db 0
2591
 
2720
 
2592
pos	     dd  0x0
2721
pos	     dd  0x0
2593
 
2722
 
2594
text_start   dd  I_END
2723
text_start   dd  I_END
2595
irc_data     dd  0x0
2724
irc_data     dd  0x0
2596
print	     db  0x0
2725
print	     db  0x0
2597
cmd	     dd  0x0
2726
cmd	     dd  0x0
2598
rxs	     dd  66
2727
rxs	     dd  66
2599
 
2728
 
2600
res:	     db  0,0
2729
res:	     db  0,0
2601
command:     times  600  db 0x0
2730
command:     times  600  db 0x0
2602
 
2731
 
2603
nick	     dd  0,0,0
2732
nick	     dd  0,0,0
2604
irc_command  dd  0,0
2733
irc_command  dd  0,0
2605
 
2734
 
2606
command_position  dd 0x0
2735
command_position  dd 0x0
2607
counter 	  dd  0
2736
counter 	  dd  0
2608
send_to_server	  db 0
2737
send_to_server	  db 0
2609
 
2738
 
2610
channel_list:	  times 32*20 db 32
2739
channel_list:	  times 32*20 db 32
2611
send_to_channel   dd 0x0
2740
send_to_channel   dd 0x0
2612
 
2741
 
2613
send_string_header:  db     'privmsg #eax :'
2742
send_string_header:  db     'privmsg #eax :'
2614
		     times  100  db  0x0
2743
		     times  100  db  0x0
2615
 
2744
 
2616
send_string:	     times  100  db  0x0
2745
send_string:	     times  100  db  0x0
2617
xpos	     dd  0
2746
xpos	     dd  0
2618
 
2747
 
2619
string0:     db  'USER guest ser1 ser2 :'
2748
string0:     db  'USER guest ser1 ser2 :'
2620
string0l:
2749
string0l:
2621
string1:     db  'nick '
2750
string1:     db  'nick '
2622
string1l:
2751
string1l:
2623
 
2752
 
2624
attribute   dd	0
2753
attribute   dd	0
2625
scroll	    dd	1
2754
scroll	    dd	1
2626
	    dd	12
2755
	    dd	12
2627
 
2756
 
2628
numtext     db	'                     '
2757
numtext     db	'                     '
2629
 
2758
 
2630
wcolor	    dd	0x000000
2759
wcolor	    dd	0x000000
2631
 
2760
 
2632
labelc	    db	'AIRC - WINDOW X: #xxx                 '
2761
labelc	    db	'AIRC - WINDOW X: #xxx                 '
2633
title	    db	'IRC client ',version,0
2762
title	    db	'IRC client ',version,0
2634
 
2763
 
2635
ipcbuf:
2764
ipcbuf:
2636
	dd	0
2765
	dd	0
2637
	dd	8
2766
	dd	8
2638
	dd	?
2767
	dd	?
2639
	dd	?
2768
	dd	?
2640
	db	?
2769
	db	?
2641
.size = $
2770
.size = $
2642
 
2771
 
2643
align 4
2772
align 4
2644
@IMPORT:
2773
@IMPORT:
2645
 
2774
 
2646
library network, 'network.obj', msgbox, 'msgbox.obj'
2775
library network, 'network.obj', msgbox, 'msgbox.obj'
2647
import  network, \
2776
import  network, \
2648
	getaddrinfo_start,	'getaddrinfo_start',	\
2777
	getaddrinfo_start,	'getaddrinfo_start',	\
2649
	getaddrinfo_process,	'getaddrinfo_process',	\
2778
	getaddrinfo_process,	'getaddrinfo_process',	\
2650
	getaddrinfo_abort,	'getaddrinfo_abort',	\
2779
	getaddrinfo_abort,	'getaddrinfo_abort',	\
2651
	freeaddrinfo,		'freeaddrinfo'
2780
	freeaddrinfo,		'freeaddrinfo'
2652
import	msgbox, mb_create, 'mb_create', mb_setfunctions, 'mb_setfunctions'
2781
import	msgbox, mb_create, 'mb_create', mb_setfunctions, 'mb_setfunctions'
2653
 
2782
 
2654
msgbox_running	db	?	; must be the byte before msgbox_struct
2783
msgbox_running	db	?	; must be the byte before msgbox_struct
2655
				; look to the handler of button 21
2784
				; look to the handler of button 21
2656
msgbox_struct:
2785
msgbox_struct:
2657
.default:
2786
.default:
2658
	dw	?	; default button, will be filled with current encoding
2787
	dw	?	; default button, will be filled with current encoding
2659
	db	'Encoding',0
2788
	db	'Encoding',0
2660
	db	'Select encoding for all messages:',0
2789
	db	'Select encoding for all messages:',0
2661
	db	'CP866',0
2790
	db	'CP866',0
2662
	db	'CP1251',0
2791
	db	'CP1251',0
2663
	db	'UTF-8',0
2792
	db	'UTF-8',0
2664
	db	0
2793
	db	0
2665
 
2794
 
2666
align 4
2795
align 4
2667
status		dd	STATUS_DISCONNECTED
2796
status		dd	STATUS_DISCONNECTED
2668
encoding	dd	UTF8
2797
encoding	dd	UTF8
2669
recode_proc	dd	recode_to_cp866, recode_to_cp1251, recode_to_utf8
2798
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
2799
get_byte_table	dd	get_byte_cp866, get_byte_cp1251, get_byte_utf8
2671
msgbox_func_array:
2800
msgbox_func_array:
2672
times 3		dd	msgbox_notify
2801
times 3		dd	msgbox_notify
2673
initialized_size:
2802
initialized_size:
2674
 
2803
 
2675
main_PID	dd	?	; identifier of main thread
2804
main_PID	dd	?	; identifier of main thread
2676
utf8_bytes_rest	dd	?	; bytes rest in current UTF8 sequence
2805
utf8_bytes_rest	dd	?	; bytes rest in current UTF8 sequence
2677
utf8_char	dd	?	; first bits of current UTF8 character
2806
utf8_char	dd	?	; first bits of current UTF8 character
2678
gai_reqdata	rb	32	; buffer for getaddrinfo_start/process
2807
gai_reqdata	rb	32	; buffer for getaddrinfo_start/process
2679
ip_list		dd	?	; will be filled as pointer to addrinfo list
2808
ip_list		dd	?	; will be filled as pointer to addrinfo list
2680
irc_server_name	rb	256	; buffer for irc_server_name
2809
irc_server_name	rb	256	; buffer for irc_server_name
2681
packetbuf	rb	1024	; buffer for packets to server
2810
packetbuf	rb	1024	; buffer for packets to server
2682
mb_stack	rb	1024	; stack for messagebox thread
2811
mb_stack	rb	1024	; stack for messagebox thread
2683
 
2812
 
2684
;;
2813
;;
2685
;;   Channel data at I_END
2814
;;   Channel data at I_END
2686
;;
2815
;;
2687
;;   120*80 * channel window (1+)
2816
;;   120*80 * channel window (1+)
2688
;;
2817
;;
2689
;;      At         Size
2818
;;      At         Size
2690
;;
2819
;;
2691
;;      00      ,  120*60   window text 120 characters per row
2820
;;      00      ,  120*60   window text 120 characters per row
2692
;;  120*60      ,  1        text is updated
2821
;;  120*60      ,  1        text is updated
2693
;;  120*60+4    ,  1        close yourself
2822
;;  120*60+4    ,  1        close yourself
2694
;;  120*60+8    ,  1        0 = channel window  :  1 = private chat
2823
;;  120*60+8    ,  1        0 = channel window  :  1 = private chat
2695
;;  120*60+12    , 4        identifier of the thread
2824
;;  120*60+12    , 4        identifier of the thread
2696
;;  120*61      ,  256      channel name
2825
;;  120*61      ,  256      channel name
2697
;;  120*61+254  ,  254      channel entry text from user
2826
;;  120*61+254  ,  254      channel entry text from user
2698
;;  120*61+255  ,  1        length of entry text
2827
;;  120*61+255  ,  1        length of entry text
2699
;;  120*69+248  ,  4        display names from n:th name
2828
;;  120*69+248  ,  4        display names from n:th name
2700
;;  120*69+252  ,  4        length of names string
2829
;;  120*69+252  ,  4        length of names string
2701
;;  120*70      ,  1200     names separated with space
2830
;;  120*70      ,  1200     names separated with space
2702
;;
2831
;;
2703
I_END:
2832
I_END:
2704
 
2833
 
2705
>
2834
>
2706
>
2835
>