Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
31 halyavin 1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                   ;;
3
;;    IRC CLIENT for MenuetOS                        ;;
4
;;                                                   ;;
5
;;    License: GPL / See file COPYING for details    ;;
6
;;    Copyright 2004 (c) Ville Turjanmaa             ;;
7
;;                                                   ;;
8
;;    Compile with FASM for Menuet                   ;;
9
;;                                                   ;;
10
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
11
 
12
version equ '0.3'
13
 
14
use32
15
 
16
                org     0x0
17
 
18
                db      'MENUET01'              ; 8 byte id
19
                dd      0x01                    ; required os
20
                dd      START                   ; program start
21
                dd      I_END                   ; program image size
22
                dd      0x100000                ; required amount of memory
23
                dd      0x100000
24
                dd      0,0
25
include "lang.inc"
26
include "macros.inc"
27
 
28
irc_server_ip   db      192,168,1,1
29
 
30
user_nick       dd      4                                 ; length
31
                db      'airc                   '         ; string
32
 
33
user_real_name  dd      8                                 ; length
34
                db      'Joe User               '         ; string
35
 
36
 
37
START:                          ; start of execution
38
 
39
    mov  eax,40
40
    mov  ebx,10000111b
41
    int  0x40
42
 
43
    mov  edi,I_END
44
    mov  ecx,60*120
45
    mov  eax,32
46
    cld
47
    rep  stosb
48
 
49
    mov  eax,[rxs]
50
    imul eax,11
51
    mov  [pos],eax
52
 
53
    mov  ebp,0
54
    mov  edx,I_END
55
    call draw_window            ; at first, draw the window
56
 
57
still:
58
 
59
    inc  [cursor_on_off]
60
 
61
    mov  eax,5
62
    mov  ebx,1
63
    int  0x40
64
 
65
    mov  eax,11                 ; wait here for event
66
    int  0x40
67
 
68
    call print_status
69
 
70
    cmp  eax,1                  ; redraw
71
    je   redraw
72
    cmp  eax,2                  ; key
73
    je   main_window_key
74
    cmp  eax,3                  ; button
75
    je   button
76
 
77
    cmp  [I_END+120*60],byte 1
78
    jne  no_main_update
79
    mov  [I_END+120*60],byte 0
80
    mov  edx,I_END
81
    call draw_channel_text
82
  no_main_update:
83
 
84
    call read_incoming_data
85
 
86
    call send_data_to_server
87
 
88
    test [cursor_on_off],0x3f
89
    jnz  nopri
90
    inc  [blink]
91
    call blink_cursor
92
    call print_channel_list
93
  nopri:
94
 
95
    jmp  still
96
 
97
 
98
redraw:                         ; redraw
99
 
100
    call draw_window
101
    jmp  still
102
 
103
 
104
button:                         ; button
105
 
106
    mov  eax,17                 ; get id
107
    int  0x40
108
 
109
    cmp  ah,1                   ; close program
110
    jne  noclose
111
    mov  eax,-1
112
    int  0x40
113
  noclose:
114
 
115
    call socket_commands
116
 
117
    jmp  still
118
 
119
 
120
print_status:
121
 
122
    pusha
123
 
124
    mov  eax,53
125
    mov  ebx,6
126
    mov  ecx,[socket]
127
    int  0x40
128
 
129
    mov  [status],eax
130
 
131
    cmp  [old_status],eax
132
    je   nopr
133
 
134
    mov  [old_status],eax
135
 
136
    push eax
137
 
138
    mov  eax,13
139
    mov  ebx,450*65536+30
140
    mov  ecx,231*65536+10
141
    mov  edx,0xffffff
142
    int  0x40
143
 
144
    pop  ecx
145
    mov  eax,47
146
    mov  ebx,2*65536
147
    mov  edx,450*65536+231
148
    mov  esi,0x000000
149
    int  0x40
150
 
151
  nopr:
152
 
153
    popa
154
 
155
    ret
156
 
157
status dd 0
158
old_status dd 0
159
 
160
 
161
socket_commands:
162
 
163
    cmp  ah,22       ; open socket
164
    jnz  tst3
165
    mov  eax,3
166
    int  0x40
167
    mov  ecx,eax
168
    mov  eax,53
169
    mov  ebx,5
170
    mov  edx,6667
171
    mov  esi,dword [irc_server_ip]
172
    mov  edi,1
173
    int  0x40
174
    mov  [socket], eax
175
    ret
176
  tst3:
177
 
178
 
179
    cmp  ah,23        ; write userinfo
180
    jnz  tst4
181
 
182
    mov  eax,53  ; user
183
    mov  ebx,7
184
    mov  ecx,[socket]
185
    mov  edx,string0l-string0
186
    mov  esi,string0
187
    int  0x40
188
 
189
    mov  eax,53  ;
190
    mov  ebx,7
191
    mov  ecx,[socket]
192
    mov  edx,[user_real_name]
193
    mov  esi,user_real_name+4
194
    int  0x40
195
 
196
    mov  eax,53  ;
197
    mov  ebx,7
198
    mov  ecx,[socket]
199
    mov  edx,2
200
    mov  esi,line_feed
201
    int  0x40
202
 
203
 
204
    mov  eax,5
205
    mov  ebx,10
206
    int  0x40
207
 
208
    mov  eax,53  ; nick
209
    mov  ebx,7
210
    mov  ecx,[socket]
211
    mov  edx,string1l-string1
212
    mov  esi,string1
213
    int  0x40
214
 
215
    mov  eax,53  ;
216
    mov  ebx,7
217
    mov  ecx,[socket]
218
    mov  edx,[user_nick]
219
    mov  esi,user_nick+4
220
    int  0x40
221
 
222
    mov  eax,53  ;
223
    mov  ebx,7
224
    mov  ecx,[socket]
225
    mov  edx,2
226
    mov  esi,line_feed
227
    int  0x40
228
 
229
 
230
    ret
231
 
232
  line_feed:  db  13,10
233
 
234
  tst4:
235
 
236
 
237
    cmp  ah,24     ; close socket
238
    jnz  no_24
239
    mov  eax,53
240
    mov  ebx,8
241
    mov  ecx,[socket]
242
    int  0x40
243
    ret
244
  no_24:
245
 
246
 
247
    ret
248
 
249
 
250
main_window_key:
251
 
252
    mov  eax,2
253
    int  0x40
254
 
255
    shr  eax,8
256
 
257
    cmp  eax,8
258
    jne  no_bks2
259
    cmp  [xpos],0
260
    je   still
261
    dec  [xpos]
262
    call print_entry
263
    jmp  still
264
   no_bks2:
265
 
266
    cmp  eax,20
267
    jbe  no_character2
268
    mov  ebx,[xpos]
269
    mov  [send_string+ebx],al
270
    inc  [xpos]
271
    cmp  [xpos],80
272
    jb   noxposdec
273
    mov  [xpos],79
274
  noxposdec:
275
    call print_entry
276
    jmp  still
277
  no_character2:
278
 
279
    cmp  eax,13
280
    jne  no_send
281
    cmp  [xpos],0
282
    je   no_send2
283
    cmp  [send_string],byte '/'   ; server command
284
    jne  no_send2
285
    mov  [send_to_server],1
286
    jmp  still
287
  no_send2:
288
 
289
    jmp  still
290
 
291
 
292
print_channel_list:
293
 
294
    pusha
295
 
296
    mov  eax,13
297
    mov  ebx,415*65536+6*13
298
    mov  ecx,27*65536+12*10
299
    mov  edx,0xffffff
300
    int  0x40
301
 
302
    mov  eax,4
303
    mov  ebx,415*65536+27
304
    mov  ecx,[index_list_1]
305
    mov  edx,channel_list+32
306
  newch:
307
    movzx esi,byte [edx+31]
308
    and  esi,0x1f
309
    int  0x40
310
    add  edx,32
311
    add  ebx,12
312
    cmp  edx,channel_list+32*10
313
    jbe  newch
314
 
315
  no_channel_list:
316
 
317
    popa
318
 
319
    ret
320
 
321
 
322
print_user_list:
323
 
324
    pusha
325
 
326
  newtry:
327
 
328
    mov  edx,ebp
329
    imul edx,120*80
330
    add  edx,120*60+8+I_END
331
    cmp  [edx],byte 1
332
    je   nonp
333
 
334
    mov  edx,ebp
335
    imul edx,120*80
336
    add  edx,120*70+I_END
337
    mov  edi,edx
338
 
339
    mov  eax,[edx-8]
340
    mov  ebx,[edx-4]
341
    add  ebx,edx
342
    sub  ebx,3
343
    inc  eax
344
    dec  edx
345
  newnss:
346
    inc  edx
347
    dec  eax
348
    jz   startuu
349
  asdf:
350
    cmp  [edx],word '  '
351
    jne  nodouble
352
    inc  edx
353
  nodouble:
354
    cmp  [edx],byte ' '
355
    je   newnss
356
    inc  edx
357
    cmp  edx,ebx
358
    jbe  asdf
359
    dec  dword [edi-8]
360
 
361
    popa
362
    ret
363
 
364
  startuu:
365
 
366
    cmp  [edx],byte ' '
367
    jne  startpr
368
    inc  edx
369
  startpr:
370
 
371
    pusha
372
    mov  eax,13
373
    mov  ebx,415*65536+6*13
374
    mov  ecx,27*65536+12*10
375
    mov  edx,0xffffff
376
    int  0x40
377
    popa
378
 
379
    mov  eax,4
380
    mov  ebx,415*65536+27
381
 
382
    mov  ebp,0
383
  newuser:
384
 
385
    mov  esi,0
386
  newusers:
387
    cmp  [edx+esi],byte ' '
388
    je   do_print
389
    inc  esi
390
    cmp  esi,20
391
    jbe  newusers
392
  do_print:
393
 
394
    mov  ecx,[index_list_1]
395
    cmp  [edx],byte '@'
396
    jne  no_op
397
    mov  ecx,[index_list_2]
398
  no_op:
399
 
400
    int  0x40
401
 
402
    inc  ebp
403
    cmp  ebp,10
404
    je   nonp
405
 
406
    add  ebx,12
407
 
408
    add  edx,esi
409
 
410
    inc  edx
411
    cmp  [edx],byte ' '
412
    jne  newuser
413
    inc  edx
414
    jmp  newuser
415
 
416
  nonp:
417
 
418
    popa
419
 
420
    ret
421
 
422
 
423
start_user_list_at dd 0x0
424
 
425
 
426
 
427
 
428
send_data_to_server:
429
 
430
    pusha
431
 
432
    cmp  [send_to_server],1
433
    jne  sdts_ret
434
 
435
    mov  eax,[xpos]
436
    mov  [send_string+eax+0],byte 13
437
    mov  [send_string+eax+1],byte 10
438
 
439
    mov  eax,[rxs]
440
    imul eax,11
441
    mov  [pos],eax
442
    mov  eax,[send_to_channel]
443
    imul eax,120*80
444
    add  eax,I_END
445
    mov  [text_start],eax
446
 
447
    cmp  [send_string],byte '/'   ; server command
448
    je   server_command
449
 
450
    mov  bl,13
451
    call print_character
452
    mov  bl,10
453
    call print_character
454
    mov  bl,'<'
455
    call print_character
456
 
457
    mov  esi,user_nick+4
458
    mov  ecx,[user_nick]
459
  newnp:
460
    mov  bl,[esi]
461
    call print_character
462
    inc  esi
463
    loop newnp
464
 
465
    mov  bl,'>'
466
    call print_character
467
    mov  bl,' '
468
    call print_character
469
 
470
    mov  ecx,[xpos]
471
    mov  esi,send_string
472
  newcw:
473
    mov  bl,[esi]
474
    call print_character
475
    inc  esi
476
    loop newcw
477
 
478
    mov  eax,dword [send_to_channel]
479
    shl  eax,5
480
    add  eax,channel_list
481
    mov  esi,eax
482
 
483
    mov  edi,send_string_header+8
484
    movzx ecx,byte [eax+31]
485
    cld
486
    rep  movsb
487
 
488
    mov  [edi],word ' :'
489
 
490
    mov   esi, send_string_header
491
    mov   edx,10
492
    movzx ebx,byte [eax+31]
493
    add   edx,ebx
494
 
495
    mov  eax, 53      ; write channel
496
    mov  ebx, 7
497
    mov  ecx, [socket]
498
    int  0x40
499
 
500
    mov  esi,send_string
501
    mov  edx,[xpos]
502
    inc  edx
503
 
504
    mov  eax, 53      ; write message
505
    mov  ebx, 7
506
    mov  ecx, [socket]
507
    int  0x40
508
 
509
    jmp  send_done
510
 
511
  server_command:
512
 
513
    cmp  [send_string+1],dword 'anic'
514
    jne  no_set_nick
515
 
516
    mov  ecx,[xpos]
517
    sub  ecx,7
518
    mov  [user_nick],ecx
519
 
520
    mov  esi,send_string+7
521
    mov  edi,user_nick+4
522
    cld
523
    rep  movsb
524
 
525
    pusha
526
    mov  edi,text+70*1+15
527
    mov  eax,32
528
    mov  ecx,15
529
    cld
530
    rep  stosb
531
    popa
532
 
533
    mov  esi,user_nick+4
534
    mov  edi,text+70*1+15
535
    mov  ecx,[user_nick]
536
    cld
537
    rep  movsb
538
 
539
    call draw_window
540
 
541
    mov  [xpos],0
542
    mov  [send_to_server],0
543
 
544
    popa
545
    ret
546
 
547
  no_set_nick:
548
 
549
    cmp  [send_string+1],dword 'area'
550
    jne  no_set_real_name
551
 
552
    mov  ecx,[xpos]
553
    sub  ecx,7
554
    mov  [user_real_name],ecx
555
 
556
    mov  esi,send_string+7
557
    mov  edi,user_real_name+4
558
    cld
559
    rep  movsb
560
 
561
    pusha
562
    mov  edi,text+70*0+15
563
    mov  eax,32
564
    mov  ecx,15
565
    cld
566
    rep  stosb
567
    popa
568
 
569
    mov  esi,user_real_name+4
570
    mov  edi,text+70*0+15
571
    mov  ecx,[xpos]
572
    sub  ecx,7
573
    cld
574
    rep  movsb
575
 
576
    call draw_window
577
 
578
    mov  [xpos],0
579
    mov  [send_to_server],0
580
 
581
    popa
582
    ret
583
 
584
  no_set_real_name:
585
 
586
    cmp  [send_string+1],dword 'aser'
587
    jne  no_set_server
588
 
589
    pusha
590
    mov   edi,irc_server_ip
591
    mov   esi,send_string+7
592
    mov   eax,0
593
    mov   edx,[xpos]
594
    add   edx,send_string-1
595
  newsip:
596
    cmp   [esi],byte '.'
597
    je    sipn
598
    cmp   esi,edx
599
    jg    sipn
600
    movzx ebx,byte [esi]
601
    inc   esi
602
    imul  eax,10
603
    sub   ebx,48
604
    add   eax,ebx
605
    jmp   newsip
606
  sipn:
607
    mov   [edi],al
608
    xor   eax,eax
609
    inc   esi
610
    cmp   esi,send_string+30
611
    jg    sipnn
612
    inc   edi
613
    cmp   edi,irc_server_ip+3
614
    jbe   newsip
615
  sipnn:
616
    popa
617
 
618
    mov  ecx,[xpos]
619
    sub  ecx,7
620
 
621
    pusha
622
    mov  edi,text+70*2+15
623
    mov  eax,32
624
    mov  ecx,15
625
    cld
626
    rep  stosb
627
    popa
628
 
629
    mov  esi,send_string+7
630
    mov  edi,text+70*2+15
631
    cld
632
    rep  movsb
633
 
634
    call draw_window
635
 
636
    mov  [xpos],0
637
    mov  [send_to_server],0
638
 
639
    popa
640
    ret
641
 
642
   no_set_server:
643
 
644
 
645
 
646
 
647
    cmp  [send_string+1],dword 'quer'
648
    jne  no_query_create
649
 
650
    mov  edi,I_END+120*80
651
    mov  eax,1 ; create channel window - search for empty slot
652
   newse2:
653
    mov  ebx,eax
654
    shl  ebx,5
655
    cmp  dword [channel_list+ebx],dword '    '
656
    je   free_found2
657
    add  edi,120*80
658
    inc  eax
659
    cmp  eax,[max_windows]
660
    jb   newse2
661
 
662
  free_found2:
663
 
664
    mov  edx,send_string+7
665
 
666
    mov  ecx,[xpos]
667
    sub  ecx,7
668
    mov  [channel_list+ebx+31],cl
669
 
670
    call create_channel_name
671
 
672
    push edi
673
    push eax
674
    mov  [edi+120*60+8],byte 1 ; query window
675
    mov  eax,32
676
    mov  ecx,120*60
677
    cld
678
    rep  stosb
679
    pop  eax
680
    pop  edi
681
 
682
    ; eax has the free position
683
    mov  [thread_screen],edi
684
    call create_channel_window
685
 
686
    mov  [xpos],0
687
    mov  [send_to_server],0
688
 
689
    popa
690
    ret
691
 
692
  no_query_create:
693
 
694
 
695
    mov  esi, send_string+1
696
    mov  edx, [xpos]
697
    add  edx,1
698
 
699
    mov  eax, 53      ; write server command
700
    mov  ebx, 7
701
    mov  ecx, [socket]
702
    int  0x40
703
 
704
  send_done:
705
 
706
    mov  [xpos],0
707
    mov  [send_to_server],0
708
 
709
    cmp  [send_string+1],dword 'quit'
710
    jne  no_quit_server
711
    mov  eax,5
712
    mov  ebx,200
713
    int  0x40
714
 
715
    mov  eax, 53      ; close socket
716
    mov  ebx, 8
717
    mov  ecx, [socket]
718
    int  0x40
719
 
720
    mov  ecx,[max_windows]
721
    mov  edi,I_END
722
  newclose:
723
    mov  [edi+120*60+4],byte  1
724
    add  edi,120*80
725
    loop newclose
726
 
727
    popa
728
    ret
729
 
730
  no_quit_server:
731
 
732
  sdts_ret:
733
 
734
    popa
735
    ret
736
 
737
 
738
 
739
read_incoming_data:
740
 
741
    pusha
742
 
743
  read_new_byte:
744
 
745
    call read_incoming_byte
746
    cmp  ecx,-1
747
    je   no_data_in_buffer
748
 
749
    cmp  bl,10
750
    jne  no_start_command
751
    mov  [cmd],1
752
  no_start_command:
753
 
754
    cmp  bl,13
755
    jne  no_end_command
756
    mov  eax,[cmd]
757
    mov  [eax+command-2],byte 0
758
    call analyze_command
759
    mov  edi,command
760
    mov  ecx,250
761
    mov  eax,0
762
    cld
763
    rep  stosb
764
    mov  [cmd],0
765
  no_end_command:
766
 
767
    mov  eax,[cmd]
768
    cmp  eax,512
769
    jge  still
770
 
771
    mov  [eax+command-2],bl
772
    inc  [cmd]
773
 
774
    jmp  read_new_byte
775
 
776
  no_data_in_buffer:
777
 
778
    popa
779
 
780
    ret
781
 
782
 
783
create_channel_name:
784
 
785
    pusha
786
 
787
  search_first_letter:
788
    cmp  [edx],byte ' '
789
    jne  first_letter_found
790
    inc  edx
791
    jmp  search_first_letter
792
  first_letter_found:
793
 
794
    mov  esi,edx
795
    mov  edi,channel_list
796
    add  edi,ebx
797
    mov  ecx,30
798
    xor  eax,eax
799
  newcase:
800
    mov  al,[esi]
801
    cmp  eax,'a'
802
    jb   nocdec
803
    cmp  eax,'z'
804
    jg   nocdec
805
    sub  al,97-65
806
  nocdec:
807
    mov  [edi],al
808
    inc  esi
809
    inc  edi
810
    loop newcase
811
 
812
    popa
813
 
814
    ret
815
 
816
 
817
create_channel_window:
818
 
819
    pusha
820
 
821
    mov  [cursor_on_off],0
822
 
823
    mov  [thread_nro],eax
824
 
825
    mov  eax,51
826
    mov  ebx,1
827
    mov  ecx,channel_thread
828
    mov  edx,[thread_stack]
829
    int  0x40
830
 
831
    mov  eax,5
832
    mov  ebx,10
833
    int  0x40
834
 
835
    add  [thread_stack],0x4000
836
    add  [thread_screen],120*80
837
 
838
    popa
839
 
840
    ret
841
 
842
 
843
print_entry:
844
 
845
    pusha
846
 
847
    mov  eax,13
848
    mov  ebx,8*65536+6*80
849
    mov  ecx,151*65536+13
850
    mov  edx,0xffffff
851
    int  0x40
852
 
853
    mov  eax,4
854
    mov  ebx,8*65536+154
855
    mov  ecx,0x000000
856
    mov  edx,send_string
857
    mov  esi,[xpos]
858
    int  0x40
859
 
860
    popa
861
 
862
    ret
863
 
864
blink dd 0x0
865
 
866
blink_cursor:
867
 
868
    pusha
869
 
870
    mov  eax,9
871
    mov  ebx,0xe0000
872
    mov  ecx,-1
873
    int  0x40
874
 
875
    mov  edx,[blink]
876
    and  edx,1
877
    sub  edx,1
878
    and  edx,0xffffff
879
;    mov  edx,0
880
 
881
    cmp  ax,word [0xe0000+4]
882
    jne  no_blink
883
 
884
    call print_entry
885
 
886
    mov  ebx,[xpos]
887
    imul ebx,6
888
    add  ebx,8
889
    mov  cx,bx
890
    shl  ebx,16
891
    mov  bx,cx
892
    mov  ecx,151*65536+163
893
    mov  eax,38
894
    int  0x40
895
 
896
    popa
897
 
898
    ret
899
 
900
  no_blink:
901
 
902
    mov  eax,13
903
    mov  ebx,8*65536+6*60
904
    mov  ecx,151*65536+13
905
    mov  edx,0xffffff
906
    int  0x40
907
 
908
    popa
909
 
910
    ret
911
 
912
 
913
 
914
 
915
 
916
set_channel:
917
 
918
    pusha
919
 
920
    ; UPPER / LOWER CASE CHECK
921
 
922
    mov  esi,eax
923
    mov  edi,channel_temp
924
    mov  ecx,40
925
    xor  eax,eax
926
  newcase2:
927
    mov  al,[esi]
928
    cmp  eax,'#'
929
    jb   newcase_over2
930
    cmp  eax,'a'
931
    jb   nocdec2
932
    cmp  eax,'z'
933
    jg   nocdec2
934
    sub  al,97-65
935
  nocdec2:
936
    mov  [edi],al
937
    inc  esi
938
    inc  edi
939
    loop newcase2
940
  newcase_over2:
941
    sub  edi,channel_temp
942
    mov  [channel_temp_length],edi
943
 
944
    mov  eax,channel_temp
945
 
946
    mov  [text_start],I_END+120*80
947
    mov  ebx,channel_list+32
948
    mov  eax,[eax]
949
 
950
    mov  edx,[channel_temp_length]
951
 
952
  stcl1:
953
    cmp  dl,[ebx+31]
954
    jne  notfound
955
 
956
    pusha
957
    xor  eax,eax
958
    xor  edx,edx
959
    mov  ecx,0
960
  stc4:
961
    mov  dl,[ebx+ecx]
962
    mov  al,[channel_temp+ecx]
963
    cmp  eax,edx
964
    jne  notfound2
965
    inc  ecx
966
    cmp  ecx,[channel_temp_length]
967
    jb   stc4
968
    popa
969
 
970
    jmp  found
971
 
972
  notfound2:
973
    popa
974
 
975
  notfound:
976
    add  [text_start],120*80
977
    add  ebx,32
978
    cmp  ebx,channel_list+19*32
979
    jb   stcl1
980
 
981
    mov  [text_start],I_END
982
 
983
  found:
984
 
985
    popa
986
 
987
    ret
988
 
989
 
990
channel_temp:         times   100   db   0
991
channel_temp_length   dd      0x0
992
 
993
 
994
 
995
print_nick:
996
 
997
    pusha
998
 
999
    mov  eax,command+1
1000
    mov  dl,'!'
1001
    call print_text
1002
 
1003
    popa
1004
    ret
1005
 
1006
 
1007
analyze_command:
1008
 
1009
    pusha
1010
 
1011
    mov  [text_start],I_END
1012
    mov  ecx,[rxs]
1013
    imul ecx,11
1014
    mov  [pos],ecx
1015
 
1016
    mov  bl,13
1017
;  call print_character
1018
    mov  bl,10
1019
;  call print_character
1020
 
1021
    mov  ecx,[cmd]
1022
    sub  ecx,2
1023
    mov  esi,command+0
1024
  newcmdc:
1025
    mov  bl,[esi]
1026
;  call print_character
1027
    inc  esi
1028
    loop newcmdc
1029
 
1030
    mov   edx,I_END
1031
;  call  draw_channel_text
1032
 
1033
    cmp  [cmd],20
1034
    jge  cmd_len_ok
1035
 
1036
    mov  [cmd],0
1037
 
1038
    popa
1039
    ret
1040
 
1041
 
1042
  cmd_len_ok:
1043
 
1044
    cmp  [command],dword 'PING'  ; ping response
1045
    jne  no_ping_responce
1046
 
1047
    call print_command_to_main
1048
 
1049
    mov  [command],dword 'PONG'
1050
 
1051
    call print_command_to_main
1052
 
1053
    mov  eax,4
1054
    mov  ebx,100*65536+3
1055
    mov  ecx,0xffffff
1056
    mov  edx,command
1057
    mov  esi,[cmd]
1058
    mov  [command+esi-1],word '**'
1059
;    int  0x40
1060
 
1061
    mov  eax,53
1062
    mov  ebx,7
1063
    mov  ecx,[socket]
1064
    mov  edx,[cmd]
1065
    sub  edx,2
1066
    and  edx,255
1067
    mov  esi,command
1068
    int  0x40
1069
 
1070
    mov  eax,53
1071
    mov  ebx,7
1072
    mov  ecx,[socket]
1073
    mov  edx,2
1074
    mov  esi,linef
1075
    int  0x40
1076
 
1077
    popa
1078
    ret
1079
 
1080
  linef  db  13,10
1081
 
1082
  no_ping_responce:
1083
 
1084
    mov  eax,[rxs]
1085
    imul eax,11
1086
    mov  [pos],eax
1087
 
1088
    mov  [command],byte '<'
1089
 
1090
    mov  eax,command
1091
    mov  ecx,100
1092
   new_blank:
1093
    cmp  [eax],byte ' '
1094
    je   bl_found
1095
    inc  eax
1096
    loop new_blank
1097
    mov  eax,50
1098
  bl_found:
1099
 
1100
    inc  eax
1101
    mov  [command_position],eax
1102
 
1103
    mov  esi,eax
1104
    mov  edi,irc_command
1105
    mov  ecx,8
1106
    cld
1107
    rep  movsb
1108
 
1109
 
1110
    cmp  [irc_command],'PRIV'  ; message to channel
1111
    jne  no_privmsg
1112
 
1113
    ; compare nick
1114
 
1115
    mov  eax,[command_position]
1116
    add  eax,8
1117
    call compare_to_nick
1118
    cmp  [cresult],0
1119
    jne  no_query_msg
1120
    mov  eax,command+1
1121
  no_query_msg:
1122
    call set_channel
1123
 
1124
    mov  ecx,100 ; [cmd]
1125
    mov  eax,command+10
1126
  acl3:
1127
    cmp  [eax],byte ':'
1128
    je   acl4
1129
    inc  eax
1130
    loop acl3
1131
    mov  eax,10
1132
  acl4:
1133
    inc  eax
1134
 
1135
    cmp  [eax+1],dword 'ACTI'
1136
    jne  no_action
1137
    push eax
1138
    mov  eax,action_header_short
1139
    mov  dl,0
1140
    call print_text
1141
    mov  eax,command+1
1142
    mov  dl,'!'
1143
    call print_text
1144
    mov  bl,' '
1145
    call print_character
1146
    pop  eax
1147
    add  eax,8
1148
    mov  dl,0
1149
    call print_text
1150
    popa
1151
    ret
1152
 
1153
  no_action:
1154
 
1155
    push eax
1156
    mov  bl,10
1157
    call print_character
1158
    mov  eax,command
1159
    mov  dl,'!'
1160
    call print_text
1161
    mov  bl,'>'
1162
    call print_character
1163
    mov  bl,' '
1164
    call print_character
1165
    pop  eax
1166
 
1167
    mov  dl,0
1168
    call print_text
1169
 
1170
    popa
1171
    ret
1172
 
1173
  no_privmsg:
1174
 
1175
 
1176
    cmp  [irc_command],'PART'    ; channel leave
1177
    jne  no_part
1178
 
1179
    ; compare nick
1180
 
1181
    mov  eax,command+1
1182
    call compare_to_nick
1183
    cmp  [cresult],0
1184
    jne  no_close_window
1185
 
1186
    mov  eax,[command_position]
1187
    add  eax,5
1188
    call set_channel
1189
 
1190
    mov  eax,[text_start]
1191
    mov  [eax+120*60+4],byte 1
1192
 
1193
    popa
1194
    ret
1195
 
1196
  no_close_window:
1197
 
1198
    mov  eax,[command_position]
1199
    add  eax,5
1200
    call set_channel
1201
 
1202
    mov  eax,action_header_red
1203
    mov  dl,0
1204
    call print_text
1205
    mov  eax,command+1
1206
    mov  dl,'!'
1207
    mov  cl,' '
1208
    call print_text
1209
    mov  eax,has_left_channel
1210
    mov  dl,0
1211
    call print_text
1212
    mov  eax,[command_position]
1213
    add  eax,5
1214
    mov  dl,' '
1215
    call print_text
1216
 
1217
    popa
1218
    ret
1219
 
1220
  no_part:
1221
 
1222
 
1223
    cmp  [irc_command],'JOIN'    ; channel join
1224
    jne  no_join
1225
 
1226
    ; compare nick
1227
 
1228
    mov  eax,command+1
1229
    call compare_to_nick
1230
    cmp  [cresult],0
1231
    jne  no_new_window
1232
 
1233
    mov  edi,I_END+120*80
1234
    mov  eax,1 ; create channel window - search for empty slot
1235
   newse:
1236
    mov  ebx,eax
1237
    shl  ebx,5
1238
    cmp  dword [channel_list+ebx],dword '    '
1239
    je   free_found
1240
    add  edi,120*80
1241
    inc  eax
1242
    cmp  eax,[max_windows]
1243
    jb   newse
1244
 
1245
  free_found:
1246
 
1247
    mov  edx,[command_position]
1248
    add  edx,6
1249
 
1250
    push eax
1251
    push edx
1252
    mov  ecx,0
1253
   finde:
1254
    inc  ecx
1255
    inc  edx
1256
    movzx eax,byte [edx]
1257
    cmp  eax,'#'
1258
    jge  finde
1259
    mov  [channel_list+ebx+31],cl
1260
    pop  edx
1261
    pop  eax
1262
 
1263
    call create_channel_name
1264
 
1265
    push edi
1266
    push eax
1267
    mov  [edi+120*60+8],byte 0 ; channel window
1268
    mov  eax,32
1269
    mov  ecx,120*60
1270
    cld
1271
    rep  stosb
1272
    pop  eax
1273
    pop  edi
1274
 
1275
    ; eax has the free position
1276
    mov  [thread_screen],edi
1277
    call create_channel_window
1278
 
1279
  no_new_window:
1280
 
1281
    mov  eax,[command_position]
1282
    add  eax,6
1283
    call set_channel
1284
 
1285
    mov  eax,action_header_blue
1286
    mov  dl,0
1287
    call print_text
1288
    mov  eax,command+1
1289
    mov  dl,'!'
1290
    mov  cl,' '
1291
    call print_text
1292
 
1293
    mov  eax,joins_channel
1294
    mov  dl,0
1295
    call print_text
1296
 
1297
    mov  eax,[command_position]
1298
    add  eax,6
1299
    mov  dl,0
1300
    call print_text
1301
 
1302
    popa
1303
    ret
1304
 
1305
  no_join:
1306
 
1307
 
1308
    cmp  [irc_command],'NICK'      ; nick change
1309
    jne  no_nick_change
1310
 
1311
    mov  [text_start],I_END
1312
    add  [text_start],120*80
1313
 
1314
 new_all_channels3:
1315
 
1316
    mov  eax,action_header_short
1317
    mov  dl,0
1318
    call print_text
1319
    mov  eax,command+1
1320
    mov  dl,'!'
1321
    call print_text
1322
    mov  eax,is_now_known_as
1323
    mov  dl,0
1324
    call print_text
1325
    mov  eax,[command_position]
1326
    add  eax,6
1327
    mov  dl,0
1328
    call print_text
1329
 
1330
    add  [text_start],120*80
1331
    cmp  [text_start],I_END+120*80*20
1332
    jb   new_all_channels3
1333
 
1334
    popa
1335
    ret
1336
 
1337
  no_nick_change:
1338
 
1339
 
1340
     cmp  [irc_command],'KICK'      ; kick
1341
     jne  no_kick
1342
 
1343
    mov  [text_start],I_END
1344
    add  [text_start],120*80
1345
 
1346
    mov  eax,[command_position]
1347
    add  eax,5
1348
    call set_channel
1349
 
1350
; new_all_channels4:
1351
 
1352
    mov  eax,action_header_short
1353
    mov  dl,0
1354
    call print_text
1355
    mov  eax,command+1
1356
    mov  dl,'!'
1357
    call print_text
1358
     mov  eax,kicked
1359
     mov  dl,0
1360
    call print_text
1361
    mov  eax,[command_position]
1362
    add  eax,5
1363
    mov  dl,0
1364
    call print_text
1365
 
1366
;    add  [text_start],120*80
1367
;    cmp  [text_start],I_END+120*80*20
1368
;    jb   new_all_channels4
1369
 
1370
    popa
1371
    ret
1372
 
1373
  no_kick:
1374
 
1375
 
1376
 
1377
 
1378
    cmp  [irc_command],'QUIT'    ; irc quit
1379
    jne  no_quit
1380
 
1381
    mov  [text_start],I_END
1382
    add  [text_start],120*80
1383
 
1384
 new_all_channels2:
1385
 
1386
    mov  eax,action_header_red
1387
    mov  dl,0
1388
    call print_text
1389
    mov  eax,command+1
1390
    mov  dl,'!'
1391
    call print_text
1392
    mov  eax,has_quit_irc
1393
    mov  dl,0
1394
    call print_text
1395
 
1396
    add  [text_start],120*80
1397
    cmp  [text_start],I_END+120*80*20
1398
    jb   new_all_channels2
1399
 
1400
    popa
1401
    ret
1402
 
1403
  no_quit:
1404
 
1405
 
1406
    cmp  [irc_command],dword 'MODE'  ; channel mode change
1407
    jne  no_mode
1408
 
1409
    mov  [text_start],I_END
1410
    add  [text_start],120*80
1411
 
1412
    mov  eax,[command_position]
1413
    add  eax,5
1414
    call set_channel
1415
 
1416
 new_all_channels:
1417
 
1418
    mov  eax,action_header_short
1419
    mov  dl,0
1420
    call print_text
1421
 
1422
    call print_nick
1423
 
1424
    mov  eax,sets_mode
1425
    mov  dl,0
1426
    call print_text
1427
 
1428
    mov  eax,[command_position]
1429
    add  eax,5
1430
    mov  dl,0
1431
    call print_text
1432
 
1433
;    add  [text_start],120*80
1434
;    cmp  [text_start],I_END+120*80*20
1435
;    jb   new_all_channels
1436
 
1437
    popa
1438
    ret
1439
 
1440
  no_mode:
1441
 
1442
 
1443
    cmp  [irc_command],dword '353 '  ; channel user names
1444
    jne  no_user_list
1445
 
1446
    mov  eax,[command_position]
1447
   finde2:
1448
    inc  eax
1449
    cmp  [eax],byte '#'
1450
    jne  finde2
1451
    call set_channel
1452
 
1453
   finde3:
1454
    inc  eax
1455
    cmp  [eax],byte ':'
1456
    jne  finde3
1457
 
1458
    pusha
1459
    cmp  [user_list_pos],0
1460
    jne  no_clear_user_list
1461
    mov  edi,[text_start]
1462
    add  edi,120*70
1463
    mov  [edi-8],dword 0
1464
    mov  [edi-4],dword 0
1465
    mov  eax,32
1466
    mov  ecx,1200
1467
    cld
1468
    rep  stosb
1469
  no_clear_user_list:
1470
    popa
1471
 
1472
    push eax
1473
 
1474
    mov  esi,eax
1475
    inc  esi
1476
    mov  edi,[text_start]
1477
    add  edi,120*70
1478
    add  edi,[user_list_pos]
1479
    mov  edx,edi
1480
    mov  ecx,command
1481
    add  ecx,[cmd]
1482
    sub  ecx,[esp]
1483
    sub  ecx,3
1484
    and  ecx,0xfff
1485
    cld
1486
    rep  movsb
1487
 
1488
    pop  eax
1489
    mov  ebx,command
1490
    add  ebx,[cmd]
1491
    sub  ebx,eax
1492
    sub  ebx,2
1493
    mov  [edx+ebx-1],dword '    '
1494
 
1495
    add  [user_list_pos],ebx
1496
 
1497
    mov  eax,[user_list_pos]
1498
    mov  ebx,[text_start]
1499
    add  ebx,120*70
1500
    mov  [ebx-4],eax
1501
 
1502
    popa
1503
    ret
1504
 
1505
  user_list_pos dd 0x0
1506
 
1507
  no_user_list:
1508
 
1509
 
1510
    cmp  [irc_command],dword '366 '  ; channel user names end
1511
    jne  no_user_list_end
1512
 
1513
    mov  [user_list_pos],0
1514
 
1515
    popa
1516
    ret
1517
 
1518
  no_user_list_end:
1519
 
1520
    mov  [command],byte '-'
1521
    call print_command_to_main
1522
 
1523
    popa
1524
 
1525
    ret
1526
 
1527
 
1528
cresult db 0
1529
 
1530
compare_to_nick:
1531
 
1532
; input  : eax = start of compare
1533
; output : [cresult] = 0 if match, [cresult]=1 if no match
1534
 
1535
 
1536
    pusha
1537
 
1538
    mov  esi,eax
1539
    mov  edi,0
1540
 
1541
  new_nick_compare:
1542
 
1543
    mov  bl,byte [esi]
1544
    mov  cl,byte [user_nick+4+edi]
1545
 
1546
    cmp  bl,cl
1547
    jne  nonickm
1548
 
1549
    add  esi,1
1550
    add  edi,1
1551
 
1552
    cmp  edi,[user_nick]
1553
    jb   new_nick_compare
1554
 
1555
    movzx eax,byte [esi]
1556
    cmp  eax,40
1557
    jge  nonickm
1558
 
1559
    popa
1560
    mov  [cresult],0
1561
    ret
1562
 
1563
  nonickm:
1564
 
1565
    popa
1566
    mov  [cresult],1
1567
    ret
1568
 
1569
 
1570
 
1571
 
1572
 
1573
print_command_to_main:
1574
 
1575
    pusha
1576
 
1577
    mov  [text_start],I_END
1578
    mov  ecx,[rxs]
1579
    imul ecx,11
1580
    mov  [pos],ecx
1581
 
1582
    mov  bl,13
1583
    call print_character
1584
    mov  bl,10
1585
    call print_character
1586
 
1587
    mov  ecx,[cmd]
1588
    sub  ecx,2
1589
    mov  esi,command
1590
   newcmdc2:
1591
    mov  bl,[esi]
1592
    call print_character
1593
    inc  esi
1594
    loop newcmdc2
1595
 
1596
    mov   edx,I_END
1597
    call  draw_channel_text
1598
 
1599
    popa
1600
 
1601
    ret
1602
 
1603
 
1604
 
1605
 
1606
print_text:
1607
 
1608
    pusha
1609
 
1610
    mov  ecx,command-2
1611
    add  ecx,[cmd]
1612
 
1613
  ptr2:
1614
    mov  bl,[eax]
1615
    cmp  bl,dl
1616
    je   ptr_ret
1617
    cmp  bl,0
1618
    je   ptr_ret
1619
    call print_character
1620
    inc  eax
1621
    cmp  eax,ecx
1622
    jbe  ptr2
1623
 
1624
  ptr_ret:
1625
 
1626
    mov  eax,[text_start]
1627
    mov  [eax+120*60],byte 1
1628
 
1629
    popa
1630
    ret
1631
 
1632
 
1633
 
1634
print_character:
1635
 
1636
    pusha
1637
 
1638
    cmp  bl,13     ; line beginning
1639
    jne  nobol
1640
    mov  ecx,[pos]
1641
    add  ecx,1
1642
  boll1:
1643
    sub  ecx,1
1644
    mov  eax,ecx
1645
    xor  edx,edx
1646
    mov  ebx,[rxs]
1647
    div  ebx
1648
    cmp  edx,0
1649
    jne  boll1
1650
    mov  [pos],ecx
1651
    jmp  newdata
1652
  nobol:
1653
 
1654
    cmp  bl,10     ; line down
1655
    jne  nolf
1656
   addx1:
1657
    add  [pos],dword 1
1658
    mov  eax,[pos]
1659
    xor  edx,edx
1660
    mov  ecx,[rxs]
1661
    div  ecx
1662
    cmp  edx,0
1663
    jnz  addx1
1664
    mov  eax,[pos]
1665
    jmp  cm1
1666
  nolf:
1667
  no_lf_ret:
1668
 
1669
 
1670
    cmp  bl,15    ; character
1671
    jbe  newdata
1672
 
1673
    mov  eax,[irc_data]
1674
    shl  eax,8
1675
    mov  al,bl
1676
    mov  [irc_data],eax
1677
 
1678
    mov  eax,[pos]
1679
    call draw_data
1680
 
1681
    mov  eax,[pos]
1682
    add  eax,1
1683
  cm1:
1684
    mov  ebx,[scroll+4]
1685
    imul ebx,[rxs]
1686
    cmp  eax,ebx
1687
    jb   noeaxz
1688
 
1689
    mov  esi,[text_start]
1690
    add  esi,[rxs]
1691
 
1692
    mov  edi,[text_start]
1693
    mov  ecx,ebx
1694
    cld
1695
    rep  movsb
1696
 
1697
    mov  esi,[text_start]
1698
    mov  ecx,[rxs]
1699
    imul ecx,61
1700
    add  esi,ecx
1701
 
1702
    mov  edi,[text_start]
1703
    mov  ecx,[rxs]
1704
    imul ecx,60
1705
    add  edi,ecx
1706
    mov  ecx,ebx
1707
    cld
1708
    rep  movsb
1709
 
1710
    mov  eax,ebx
1711
    sub  eax,[rxs]
1712
  noeaxz:
1713
    mov  [pos],eax
1714
 
1715
  newdata:
1716
 
1717
    mov  eax,[text_start]
1718
    mov  [eax+120*60],byte 1
1719
 
1720
    popa
1721
    ret
1722
 
1723
 
1724
 
1725
draw_data:
1726
 
1727
    pusha
1728
 
1729
    and  ebx,0xff
1730
 
1731
    cmp  bl,0xe4   ; finnish a
1732
    jne  noe4
1733
    mov  bl,0xc1
1734
  noe4:
1735
    cmp  bl,0xc4   ; ?
1736
    jne  noc4
1737
    mov  bl,0xc9
1738
  noc4:
1739
 
1740
    cmp  ebx,229   ; swedish a
1741
    jne  no_swedish_a
1742
    mov  bl,192
1743
  no_swedish_a:
1744
 
1745
    add  eax,[text_start]
1746
    mov  [eax],bl
1747
 
1748
    popa
1749
    ret
1750
 
1751
 
1752
 
1753
read_incoming_byte:
1754
 
1755
    mov  eax, 53
1756
    mov  ebx, 2
1757
    mov  ecx, [socket]
1758
    int  0x40
1759
 
1760
    mov  ecx,-1
1761
 
1762
    cmp  eax,0
1763
    je   no_more_data
1764
 
1765
    mov  eax, 53
1766
    mov  ebx, 3
1767
    mov  ecx, [socket]
1768
    int  0x40
1769
 
1770
    mov  ecx,0
1771
 
1772
  no_more_data:
1773
 
1774
    ret
1775
 
1776
 
1777
 
1778
draw_window:
1779
 
1780
    pusha
1781
 
1782
    mov  eax,12
1783
    mov  ebx,1
1784
    int  0x40
1785
 
1786
    mov  [old_status],300
1787
 
1788
    mov  eax,0                     ; draw window
1789
    mov  ebx,5*65536+499
1790
    mov  ecx,5*65536+345
1791
    mov  edx,[wcolor]
1792
    add  edx,0x03ffffff
1793
    mov  esi,0x80555599
1794
    mov  edi,0x00ffffff
1795
    int  0x40
1796
 
1797
    mov  eax,4                     ; label
1798
    mov  ebx,9*65536+8
1799
    mov  ecx,0x10ffffff
1800
    mov  edx,labelt
1801
    mov  esi,labellen-labelt
1802
    int  0x40
1803
 
1804
    mov  eax,8                     ; button: open socket
1805
    mov  ebx,43*65536+22
1806
    mov  ecx,229*65536+10
1807
    mov  edx,22
1808
    mov  esi,[main_button]
1809
    int  0x40
1810
 
1811
    mov  eax,8                     ; button: send userinfo
1812
    mov  ebx,180*65536+22
1813
    mov  ecx,229*65536+10
1814
    mov  edx,23
1815
    int  0x40
1816
 
1817
    mov  eax,8                     ; button: close socket
1818
    mov  ebx,317*65536+22
1819
    mov  ecx,229*65536+10
1820
    mov  edx,24
1821
    int  0x40
1822
 
1823
    mov  eax,38                    ; line
1824
    mov  ebx,5*65536+494
1825
    mov  ecx,148*65536+148
1826
    mov  edx,[main_line]
1827
    int  0x40
1828
    add  ecx,1*65536+1
1829
;    mov  edx,0x5555cc
1830
;    int  0x40
1831
 
1832
    mov  eax,38                    ; line
1833
    mov  ebx,5*65536+494
1834
    mov  ecx,166*65536+166
1835
    int  0x40
1836
    add  ecx,1*65536+1
1837
;    mov  edx,0x5555cc
1838
;    int  0x40
1839
 
1840
    mov  eax,38                    ; line
1841
    mov  ebx,410*65536+410
1842
    mov  ecx,22*65536+148
1843
    int  0x40
1844
    add  ebx,1*65536+1
1845
;    mov  edx,0x5555cc
1846
;    int  0x40
1847
 
1848
    mov  ebx,25*65536+183          ; info text
1849
    mov  ecx,0x000000
1850
    mov  edx,text
1851
    mov  esi,70
1852
  newline:
1853
    mov  eax,4
1854
    int  0x40
1855
    add  ebx,12
1856
    add  edx,70
1857
    cmp  [edx],byte 'x'
1858
    jne  newline
1859
 
1860
    mov  edx,I_END                ; text from server
1861
    call draw_channel_text
1862
 
1863
    mov  eax,12
1864
    mov  ebx,2
1865
    int  0x40
1866
 
1867
    popa
1868
 
1869
    ret
1870
 
1871
main_line    dd 0x000000
1872
main_button  dd 0x6565cc
1873
 
1874
 
1875
text:
1876
 
1877
db '   Real name : Joe User        - change with eg /areal Jill User      '
1878
db '   Nick      : AIRC            - change with eg /anick Jill           '
1879
db '   Server    : 192.168.1.1     - change with eg /aserv 192.168.1.24   '
1880
db '                                                                      '
1881
db '        1) Open socket         2) Send userinfo       Close socket    '
1882
db '                                                                      '
1883
db '   Commands after established connection:                             '
1884
db '                                                                      '
1885
db '   /join #ChannelName         - eg /join #menuet                      '
1886
db '   /part #ChannelName         - eg /part #linux                       '
1887
db '   /query Nickname            - eg /query Mary                        '
1888
db '   /quit                      - Quit server and Close socket          '
1889
 
1890
db 'x <- END MARKER, DONT DELETE            '
1891
 
1892
 
1893
 
1894
 
1895
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1896
;
1897
;                        CHANNEL THREADS
1898
;
1899
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1900
 
1901
 
1902
 
1903
channel_thread:
1904
 
1905
    mov   ebp,[thread_nro]
1906
    mov   eax,ebp
1907
    shl   eax,14
1908
    add   eax,0x80000
1909
    mov   esp,eax
1910
 
1911
    mov   edi,ebp        ; clear thread memory
1912
    imul  edi,120*80
1913
    add   edi,I_END
1914
    mov   ecx,120*80
1915
    mov   eax,32
1916
    cld
1917
;    rep   stosb
1918
 
1919
    mov   edx,[thread_screen]
1920
 
1921
    call  thread_draw_window
1922
 
1923
  w_t:
1924
 
1925
    mov  esi,ebp
1926
    imul esi,120*80
1927
    add  esi,I_END
1928
    cmp  [esi+120*60+4],byte 1
1929
    jne  no_channel_leave
1930
    mov  [esi+120*60+4],byte 0
1931
    mov  edi,ebp
1932
    shl  edi,5
1933
    mov  dword [channel_list+edi],dword '    '
1934
    mov  byte  [channel_list+edi+31],byte 1
1935
    mov  eax,-1
1936
    int  0x40
1937
  no_channel_leave:
1938
 
1939
    call  check_mouse
1940
 
1941
    mov   eax,23
1942
    mov   ebx,1
1943
    int   0x40
1944
 
1945
    cmp   eax,1
1946
    jne   no_draw_window
1947
    call  thread_draw_window
1948
    call  draw_channel_text
1949
    call  print_user_list
1950
  no_draw_window:
1951
 
1952
    cmp   eax,2
1953
    je    thread_key
1954
 
1955
    cmp   eax,3
1956
    jne   no_end
1957
    mov   eax,17
1958
    int   0x40
1959
    mov   eax,ebp
1960
    imul  eax,120*80
1961
    add   eax,I_END
1962
    cmp   [eax+120*60+8],byte 0 ; channel window
1963
    je    not_close
1964
    mov   eax,ebp
1965
    shl   eax,5
1966
    add   eax,channel_list
1967
    mov   [eax],dword '    '
1968
    mov   [eax+31],byte 1
1969
    mov   eax,-1
1970
    int   0x40
1971
  not_close:
1972
    mov   [text_start],eax
1973
    mov   eax,nocl
1974
  newcc:
1975
    mov   bl,[eax]
1976
    call  print_character
1977
    inc   eax
1978
    cmp   [eax],byte 0
1979
    jne   newcc
1980
    call  draw_channel_text
1981
    jmp   w_t
1982
   nocl:   db  13,10,'To exit channel, use PART or QUIT command.',0
1983
   no_end:
1984
 
1985
    cmp   [edx+120*60],byte 1
1986
    jne   no_update
1987
    mov   [edx+120*60],byte 0
1988
    call  draw_channel_text
1989
  no_update:
1990
 
1991
    test [cursor_on_off],0x3f
1992
    jnz   nopri2
1993
 
1994
    call  blink_cursor
1995
    call  print_user_list
1996
 
1997
  nopri2:
1998
 
1999
    jmp   w_t
2000
 
2001
 
2002
 
2003
check_mouse:
2004
 
2005
    pusha
2006
 
2007
    mov  eax,37
2008
    mov  ebx,1
2009
    int  0x40
2010
 
2011
    mov  ebx,eax
2012
    shr  eax,16
2013
    and  ebx,0xffff
2014
 
2015
    cmp  eax,420
2016
    jb   no_mouse
2017
    cmp  eax,494
2018
    jg   no_mouse
2019
 
2020
    cmp  ebx,145
2021
    jg   no_mouse
2022
    cmp  ebx,23
2023
    jb   no_mouse
2024
 
2025
 
2026
    cmp  ebx,100
2027
    jb   no_plus
2028
    mov  eax,ebp
2029
    imul eax,120*80
2030
    add  eax,120*70+I_END
2031
    inc  dword [eax-8]
2032
    call print_user_list
2033
    mov  eax,5
2034
    mov  ebx,8
2035
    int  0x40
2036
    jmp  no_mouse
2037
  no_plus:
2038
 
2039
    cmp  ebx,80
2040
    jg   no_mouse
2041
    mov  eax,ebp
2042
    imul eax,120*80
2043
    add  eax,120*70+I_END
2044
    cmp  dword [eax-8],dword 0
2045
    je   no_mouse
2046
    dec  dword [eax-8]
2047
    call print_user_list
2048
    mov  eax,5
2049
    mov  ebx,8
2050
    int  0x40
2051
 
2052
  no_minus:
2053
 
2054
  no_mouse:
2055
 
2056
    popa
2057
 
2058
    ret
2059
 
2060
 
2061
 
2062
 
2063
thread_key:
2064
 
2065
    mov  eax,2
2066
    int  0x40
2067
 
2068
    shr  eax,8
2069
 
2070
    cmp  eax,8
2071
    jne  no_bks
2072
    cmp  [xpos],0
2073
    je   w_t
2074
    dec  [xpos]
2075
    call print_entry
2076
    jmp  w_t
2077
   no_bks:
2078
 
2079
    cmp  eax,20
2080
    jbe  no_character
2081
    mov  ebx,[xpos]
2082
    mov  [send_string+ebx],al
2083
    inc  [xpos]
2084
    cmp  [xpos],80
2085
    jb   xpok
2086
    mov  [xpos],79
2087
  xpok:
2088
    call print_entry
2089
    jmp  w_t
2090
  no_character:
2091
 
2092
    cmp  eax,13
2093
    jne  no_send
2094
    cmp  [xpos],0
2095
    je   no_send
2096
    mov  dword [send_to_channel],ebp
2097
    mov  [send_to_server],1
2098
  wait_for_sending:
2099
    mov  eax,5
2100
    mov  ebx,1
2101
    int  0x40
2102
    cmp  [send_to_server],1
2103
    je   wait_for_sending
2104
    call draw_channel_text
2105
    call print_entry
2106
    jmp  w_t
2107
  no_send:
2108
 
2109
    jmp  w_t
2110
 
2111
 
2112
 
2113
 
2114
 
2115
 
2116
draw_channel_text:
2117
 
2118
    pusha
2119
 
2120
    mov   eax,4
2121
    mov   ebx,10*65536+26
2122
    mov   ecx,12
2123
    mov   esi,[rxs]
2124
  dct:
2125
    pusha
2126
    mov   cx,bx
2127
    shl   ecx,16
2128
    mov   cx,9
2129
    mov   eax,13
2130
    mov   ebx,10*65536
2131
    mov   bx,word [rxs]
2132
    imul  bx,6
2133
    mov   edx,0xffffff
2134
    int   0x40
2135
    popa
2136
    push  ecx
2137
    mov   eax,4
2138
    mov   ecx,0
2139
    cmp   [edx],word '* '
2140
    jne   no_red
2141
    mov   ecx,0x0000ff
2142
   no_red:
2143
    cmp   [edx],word '**'
2144
    jne   no_light_blue
2145
    cmp   [edx+2],byte '*'
2146
    jne   no_light_blue
2147
    mov   ecx,0x0000ff
2148
  no_light_blue:
2149
    cmp   [edx],byte '#'
2150
    jne   no_blue
2151
    mov   ecx,0x0000ff
2152
  no_blue:
2153
    int   0x40
2154
    add   edx,[rxs]
2155
    add   ebx,10
2156
    pop   ecx
2157
    loop  dct
2158
 
2159
    popa
2160
    ret
2161
 
2162
 
2163
 
2164
 
2165
 
2166
thread_draw_window:
2167
 
2168
    pusha
2169
 
2170
    mov  eax,12
2171
    mov  ebx,1
2172
    int  0x40
2173
 
2174
    mov  ebx,ebp                   ; draw window
2175
    shl  ebx,16+4
2176
    mov  eax,0
2177
    mov  ecx,ebx
2178
    mov  bx,499
2179
    mov  cx,170
2180
 
2181
;    mov  edx,ebp                   ; draw window
2182
;    imul edx,120*80
2183
;    add  edx,I_END+120*60+8
2184
;    movzx edx,byte [edx]
2185
;    imul edx,88
2186
;    sub  bx,dx
2187
 
2188
    mov  edx,[wcolor]
2189
    add  edx,0x03ffffff
2190
    mov  esi,0x80555599
2191
    mov  edi,0x00ffffff
2192
 
2193
    int  0x40
2194
 
2195
    mov  eax,ebp                   ; label
2196
    add  eax,48
2197
    mov  [labelc+14],al
2198
    mov  eax,ebp
2199
    shl  eax,5
2200
    add  eax,channel_list
2201
    mov  esi,eax
2202
    mov  edi,labelc+17
2203
    movzx ecx,byte [eax+31]
2204
    cld
2205
    rep   movsb
2206
 
2207
    mov  esi,17                    ; print label
2208
    movzx ebx,byte [eax+31]
2209
    add  esi,ebx
2210
    mov  eax,4
2211
    mov  ebx,9*65536+8
2212
    mov  ecx,0x00ffffff
2213
    mov  edx,labelc
2214
    int  0x40
2215
 
2216
    mov  eax,38                    ; line
2217
    mov  ebx,5*65536+494
2218
    mov  ecx,148*65536+148
2219
    mov  edx,[channel_line_sun]
2220
    int  0x40
2221
    add  ecx,1*65536+1
2222
    mov  edx,[channel_line_shadow]
2223
    int  0x40
2224
 
2225
 
2226
    mov  eax,38                    ; line
2227
    mov  ebx,410*65536+410
2228
    mov  ecx,22*65536+148
2229
    mov  edx,[channel_line_sun]
2230
    int  0x40
2231
    add  ebx,1*65536+1
2232
    mov  edx,[channel_line_shadow]
2233
    int  0x40
2234
 
2235
    mov  eax,12
2236
    mov  ebx,2
2237
    int  0x40
2238
 
2239
    popa
2240
 
2241
    ret
2242
 
2243
 
2244
 
2245
; DATA AREA
2246
 
2247
socket  dd  0x0
2248
 
2249
bgc  dd  0x000000
2250
     dd  0x000000
2251
     dd  0x00ff00
2252
     dd  0x0000ff
2253
     dd  0x005500
2254
     dd  0xff00ff
2255
     dd  0x00ffff
2256
     dd  0x770077
2257
 
2258
tc   dd  0xffffff
2259
     dd  0xff00ff
2260
     dd  0xffffff
2261
     dd  0xffffff
2262
     dd  0xffffff
2263
     dd  0xffffff
2264
     dd  0xffffff
2265
     dd  0xffffff
2266
 
2267
channel_line_sun    dd 0x9999ff
2268
channel_line_shadow dd 0x666699
2269
 
2270
cursor_on_off  dd  0x0
2271
 
2272
max_windows    dd  20
2273
 
2274
thread_stack   dd  0x9fff0
2275
thread_nro     dd 1
2276
thread_screen  dd I_END+120*80*1
2277
 
2278
action_header_blue  db  10,'*** ',0
2279
action_header_red   db  10,'*** ',0
2280
 
2281
action_header_short db  10,'* ',0
2282
 
2283
has_left_channel db  ' left channel ',0
2284
joins_channel    db  ' joined channel ',0
2285
is_now_known_as  db  ' is now known as ',0
2286
has_quit_irc     db  ' has quit irc',0
2287
sets_mode        db  ' sets mode ',0
2288
kicked           db  ' kicked from ',0
2289
 
2290
index_list_1     dd  0x0000bb
2291
index_list_2     dd  0x0000ff
2292
 
2293
posx             dd  0x0
2294
incoming_pos     dd  0x0
2295
incoming_string: times 128 db 0
2296
 
2297
pos          dd  0x0
2298
 
2299
text_start   dd  I_END
2300
irc_data     dd  0x0
2301
print        db  0x0
2302
cmd          dd  0x0
2303
rxs          dd  66
2304
 
2305
res:         db  0,0
2306
command:     times  600  db 0x0
2307
 
2308
nick         dd  0,0,0
2309
irc_command  dd  0,0
2310
 
2311
command_position  dd 0x0
2312
counter           dd  0
2313
send_to_server    db 0
2314
 
2315
channel_list:     times 32*20 db 32
2316
send_to_channel   dd 0x0
2317
 
2318
send_string_header:  db     'privmsg #eax :'
2319
                     times  100  db  0x0
2320
 
2321
send_string:         times  100  db  0x0
2322
xpos         dd  0
2323
 
2324
string0:     db  'USER guest ser1 ser2 :'
2325
string0l:
2326
string1:     db  'nick '
2327
string1l:
2328
 
2329
attribute   dd  0
2330
scroll      dd  1
2331
            dd  12
2332
 
2333
numtext     db  '                     '
2334
 
2335
wcolor      dd  0x000000
2336
 
2337
labelc      db  'AIRC - WINDOW X: #xxx                 '
2338
labelt      db  'IRC client ',version
2339
labellen:
2340
 
2341
;;
2342
;;   Channel data at I_END
2343
;;
2344
;;   120*80 * channel window (1+)
2345
;;
2346
;;      At         Size
2347
;;
2348
;;      00      ,  120*60   window text 120 characters per row
2349
;;  120*60      ,  1        text is updated
2350
;;  120*60+4    ,  1        close yourself
2351
;;  120*60+8    ,  1        0 = channel window  :  1 = private chat
2352
;;  120*61      ,  256      channel name
2353
;;  120*61+254  ,  254      channel entry text from user
2354
;;  120*61+255  ,  1        length of entry text
2355
;;  120*69+248  ,  4        display names from n:th name
2356
;;  120*69+252  ,  4        length of names string
2357
;;  120*70      ,  1200     names separated with space
2358
;;
2359
I_END: ;;