Subversion Repositories Kolibri OS

Rev

Rev 131 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
31 halyavin 1
;
2
;    NetSend(Server)
3
;
4
;    Автор: Hex
5
;    Сайт: www.mestack.narod.ru
6
;
7
;    Описание:
8
;    Программа для обмена сообщениями в сети.Серверная часть.
9
;
10
;    Compile with FASM for Menuet
11
;    Компилируется FASM'ом для Менуэт ОС
12
;
13
 
14
use32
485 heavyiron 15
 org	0x0
16
 db	'MENUET01'    ; header
17
 dd	0x01	      ; header version
18
 dd	START	      ; entry point
19
 dd	I_END	      ; image size
20
 dd	I_END+0x10000 ; required memory
21
 dd	I_END+0x10000 ; esp
22
 dd	0x0 , 0x0     ; I_Param , I_Path
31 halyavin 23
 
24
include 'lang.inc'
485 heavyiron 25
include '..\..\..\macros.inc'
31 halyavin 26
remote_ip  db  192,168,0,1
27
 
28
 
29
START:                      ; start of execution
30
 
31
    mov  eax, 53                  ; open receiver socket
32
    mov  ebx, 0
33
    mov  ecx, 0x5000              ; local port
34
    mov  edx, 0xffff              ; remote port
35
    mov  esi, dword [remote_ip]   ; remote IP
485 heavyiron 36
    mcall
31 halyavin 37
    mov  [socketNum],eax
38
    mov  [0],eax                  ; save for remote code
485 heavyiron 39
 
40
red:
31 halyavin 41
    call draw_window            ; at first, draw the window
42
 
43
still:
44
 
45
    mov  eax,23                 ; wait here for event
46
    mov  ebx,1
485 heavyiron 47
    mcall
31 halyavin 48
 
49
    cmp  eax,1                  ; redraw request ?
50
    jz   red
51
    cmp  eax,2                  ; key in buffer ?
52
    jz   key
53
    cmp  eax,3                  ; button in buffer ?
54
    jz   button
55
 
56
    mov  eax,53                 ; data from cluster terminal ?
57
    mov  ebx,2
58
    mov  ecx,[socketNum]
485 heavyiron 59
    mcall
31 halyavin 60
 
61
    cmp  eax,0
62
    jne  data_arrived
63
 
64
    jmp  still
65
 
66
key:
67
    mov  eax,2
485 heavyiron 68
    mcall
31 halyavin 69
    jmp  still
70
 
71
button:
72
 
73
    mov  eax,53
74
    mov  ebx,1
75
    mov  ecx,[socketNum]
485 heavyiron 76
    mcall
77
    or  eax,-1
78
    mcall
31 halyavin 79
 
80
 
81
data_arrived:
82
 
83
    mov  eax,5                 ; wait a second for everything to arrive
84
    mov  ebx,10
485 heavyiron 85
    mcall
31 halyavin 86
 
87
    mov  edi,I_END
88
 
89
  get_data:
90
 
91
    mov  eax,53
92
    mov  ebx,3
93
    mov  ecx,[socketNum]
485 heavyiron 94
    mcall
31 halyavin 95
 
96
    mov  [edi],bl
97
    inc  edi
98
 
99
    mov  eax,53
100
    mov  ebx,2
101
    mov  ecx,[socketNum]
485 heavyiron 102
    mcall
31 halyavin 103
 
104
    cmp  eax,0
105
    jne  get_data
106
 
107
    mov  eax,4
108
    mov  ebx,10*65536+60
109
    add  ebx,[y]
110
    mov  ecx,0x000000
111
    mov  edx,I_END
112
    mov  esi,100
485 heavyiron 113
    mcall
31 halyavin 114
 
115
    add  [y],10
116
 
117
    jmp  still
118
 
119
y   dd   0x10
120
 
121
 
122
 
123
;   *********************************************
124
;   *******  WINDOW DEFINITIONS AND DRAW ********
125
;   *********************************************
126
 
127
 
128
draw_window:
129
 
130
    mov  eax,12                    ; function 12:tell os about windowdraw
131
    mov  ebx,1                     ; 1, start of draw
485 heavyiron 132
    mcall
31 halyavin 133
 
134
                                   ; DRAW WINDOW
135
    mov  eax,0                     ; function 0 : define and draw window
136
    mov  ebx,100*65536+300         ; [x start] *65536 + [x size]
137
    mov  ecx,100*65536+330         ; [y start] *65536 + [y size]
485 heavyiron 138
    mov  edx,0x13ffffff            ; color of work area RRGGBB
139
    mov  edi,title                 ; WINDOW LABEL
140
    mcall
31 halyavin 141
 
485 heavyiron 142
 
31 halyavin 143
    ; Re-draw the screen text
144
    cld
485 heavyiron 145
    mov  eax,4
31 halyavin 146
    mov  ebx,10*65536+30           ; draw info text with function 4
147
    mov  ecx,0x000000
148
    mov  edx,text
149
    mov  esi,40
150
  newline:
485 heavyiron 151
    mcall
31 halyavin 152
    add  ebx,16
153
    add  edx,40
154
    cmp  [edx],byte 'x'
155
    jnz  newline
156
 
157
 
158
    mov  eax,12                    ; function 12:tell os about windowdraw
159
    mov  ebx,2                     ; 2, end of draw
485 heavyiron 160
    mcall
31 halyavin 161
 
162
    ret
163
 
164
 
165
; DATA AREA
166
 
131 diamond 167
if lang eq ru
31 halyavin 168
text:
169
    db 'Данный адрес        : 192.168.0.2       '
170
    db 'Прослушиваемый порт : 0x5000            '
171
    db 'Присланные сообщения:                   '
131 diamond 172
    db 'x' ; <- END MARKER, DONT DELETE
173
else
174
text:
175
    db 'This address     : 192.168.0.2          '
176
    db 'Used port        : 0x5000               '
177
    db 'Received messages:                      '
178
    db 'x' ; <- END MARKER, DONT DELETE
179
end if
31 halyavin 180
 
485 heavyiron 181
title  db  'NetSend(Server)',0
31 halyavin 182
 
183
socketNum   dd  0x0
184
 
185
 
186
I_END: