Subversion Repositories Kolibri OS

Rev

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

Rev 109 Rev 485
Line 2... Line 2...
2
;   Example for Inter Process Communication
2
;   Example for Inter Process Communication
3
;
3
;
4
;   Compile with FASM for Menuet
4
;   Compile with FASM for Menuet
5
;
5
;
6
include 'lang.inc'
6
include 'lang.inc'
7
include 'macros.inc'
7
include '..\..\..\macros.inc'
Line 8... Line 8...
8
 
8
 
9
  use32
9
  use32
Line 10... Line 10...
10
  org    0x0
10
  org    0x0
Line 22... Line 22...
22
 
22
 
23
    mov  eax,60                 ; IPC
23
    mov  eax,60                 ; IPC
24
    mov  ebx,1                  ; define receive area
24
    mov  ebx,1                  ; define receive area
25
    mov  ecx,received_messages  ; pointer to start
25
    mov  ecx,received_messages  ; pointer to start
26
    mov  edx,1000               ; size of area
26
    mov  edx,1000               ; size of area
Line 27... Line 27...
27
    int  0x40
27
    mcall
28
 
28
 
29
    mov  eax,40                 ; WANTED EVENTS
29
    mov  eax,40                 ; WANTED EVENTS
Line 30... Line 30...
30
    mov  ebx,01000111b          ; IPC 7 + defaults
30
    mov  ebx,01000111b          ; IPC 7 + defaults
31
    int  0x40
31
    mcall
Line -... Line 32...
-
 
32
 
32
 
33
    mov  [received_messages+8],dword 0*256+0
Line 33... Line 34...
33
    mov  [received_messages+8],dword 0*256+0
34
    mov  [received_messages+12],dword 0
Line 34... Line 35...
34
    mov  [received_messages+12],dword 0
35
 
35
 
36
  red:
36
    call draw_window            ; at first, draw the window
37
    call draw_window            ; at first, draw the window
Line 37... Line 38...
37
 
38
 
38
still:
39
still:
39
 
40
 
40
    mov  eax,23                 ; wait here for event
41
    mov  eax,23                 ; wait here for event
Line 54... Line 55...
54
    jmp  still
55
    jmp  still
55
  no_ipc:
56
  no_ipc:
Line 56... Line 57...
56
 
57
 
Line 57... Line -...
57
    jmp  still
-
 
58
 
-
 
59
  red:                          ; redraw
-
 
60
    call draw_window
-
 
61
    jmp  still
58
    jmp  still
62
 
59
 
63
  key:                          ; key
60
  key:                          ; key
64
    mov  eax,2                  ; just read it and ignore
61
    mov  eax,2                  ; just read it and ignore
Line 65... Line 62...
65
    int  0x40
62
    mcall
66
    jmp  still
63
    jmp  still
67
 
64
 
Line 68... Line 65...
68
  button:                       ; button
65
  button:                       ; button
69
    mov  eax,17                 ; get id
66
    mov  eax,17                 ; get id
70
    int  0x40
67
    mcall
71
 
68
 
72
    cmp  ah,1                   ; button id=1 ?
69
    cmp  ah,1                   ; button id=1 ?
Line 73... Line 70...
73
    jne  noclose
70
    jne  noclose
74
    mov  eax,-1                 ; close this program
71
    mov  eax,-1                 ; close this program
75
    int  0x40
72
    mcall
Line 99... Line 96...
99
    mov  eax,60                 ; IPC
96
    mov  eax,60                 ; IPC
100
    mov  ebx,2                  ; send message
97
    mov  ebx,2                  ; send message
101
    mov  ecx,[PID]
98
    mov  ecx,[PID]
102
    mov  edx,message+4
99
    mov  edx,message+4
103
    mov  esi,20;[message_size]
100
    mov  esi,20;[message_size]
104
    int  0x40
101
    mcall
Line 105... Line 102...
105
 
102
 
106
    jmp  still
103
    jmp  still
Line 159... Line 156...
159
 
156
 
160
    mov  eax,13
157
    mov  eax,13
161
    mov  ebx,25*65536+245
158
    mov  ebx,25*65536+245
162
    mov  ecx,105*65536+90
159
    mov  ecx,105*65536+90
163
    mov  edx,0xdddddd
160
    mov  edx,0xdddddd
Line 164... Line 161...
164
    int  0x40
161
    mcall
165
 
162
 
Line 166... Line 163...
166
    cmp  [received_messages+4],dword 8  ; empty list
163
    cmp  [received_messages+4],dword 8  ; empty list
Line 177... Line 174...
177
    and  ecx,0xfff
174
    and  ecx,0xfff
178
    mov  edx,ebx
175
    mov  edx,ebx
179
    mov  eax,47
176
    mov  eax,47
180
    mov  ebx,4*65536
177
    mov  ebx,4*65536
181
    mov  esi,0xff0000
178
    mov  esi,0xff0000
182
    int  0x40
179
    mcall
183
    popa
180
    popa
184
    pusha
181
    pusha
185
    mov  esi,20
182
    mov  esi,20
186
    add  edx,8
183
    add  edx,8
187
    add  ebx,30*65536
184
    add  ebx,30*65536
188
    mov  eax,4
185
    mov  eax,4
189
    int  0x40
186
    mcall
190
    popa
187
    popa
Line 191... Line 188...
191
 
188
 
192
    add  ebx,10
189
    add  ebx,10
193
    mov  edi,[edx+4]
190
    mov  edi,[edx+4]
Line 220... Line 217...
220
 
217
 
Line 221... Line 218...
221
draw_window:
218
draw_window:
222
 
219
 
223
    mov  eax,12                    ; function 12:tell os about windowdraw
220
    mov  eax,12                    ; function 12:tell os about windowdraw
Line 224... Line 221...
224
    mov  ebx,1                     ; 1, start of draw
221
    mov  ebx,1                     ; 1, start of draw
225
    int  0x40
222
    mcall
226
 
223
 
227
                                   ; DRAW WINDOW
224
                                   ; DRAW WINDOW
228
    mov  eax,0                     ; function 0 : define and draw window
225
    mov  eax,0                     ; function 0 : define and draw window
-
 
226
    mov  ebx,100*65536+290         ; [x start] *65536 + [x size]
229
    mov  ebx,100*65536+290         ; [x start] *65536 + [x size]
227
    mov  ecx,100*65536+220         ; [y start] *65536 + [y size]
Line 230... Line -...
230
    mov  ecx,100*65536+220         ; [y start] *65536 + [y size]
-
 
231
    mov  edx,0x03ffffff            ; color of work area RRGGBB,8->color gl
-
 
232
    int  0x40
-
 
233
 
-
 
234
                                   ; WINDOW LABEL
-
 
235
    mov  eax,4                     ; function 4 : write text to window
-
 
236
    mov  ebx,8*65536+8             ; [x start] *65536 + [y start]
-
 
Line 237... Line 228...
237
    mov  ecx,0x10ffffff            ; color of text RRGGBB
228
    mov  edx,0x13ffffff            ; color of work area RRGGBB,8->color gl
238
    mov  edx,labelt                ; pointer to text beginning
229
    mov  edi,title                 ; WINDOW LABEL
239
    mov  esi,labellen-labelt       ; text length
230
    mcall
240
    int  0x40
231
 
Line 241... Line 232...
241
 
232
                                   
242
    mov  eax,9
233
    mov  eax,9
243
    mov  ebx,process_info
234
    mov  ebx,process_info
244
    mov  ecx,-1
235
    mov  ecx,-1
245
    int  0x40
236
    mcall
246
 
237
 
Line 247... Line 238...
247
    mov  eax,47
238
    mov  eax,47
248
    mov  ebx,4*65536
239
    mov  ebx,4*65536
249
    mov  ecx,[process_info+30]
240
    mov  ecx,[process_info+30]
250
    mov  edx,180*65536+35
241
    mov  edx,180*65536+35
251
    mov  esi,0x000000
242
    mov  esi,0x000000
252
    int  0x40
243
    mcall
Line 253... Line 244...
253
 
244
 
254
    mov  eax,8                     ; MESSAGE
245
    mov  eax,8                     ; MESSAGE
255
    mov  ebx,25*65536+87
246
    mov  ebx,25*65536+87
256
    mov  ecx,50*65536+16
247
    mov  ecx,50*65536+16
257
    mov  edx,2
-
 
258
    mov  esi,0x5588dd
248
    mov  edx,2
Line -... Line 249...
-
 
249
    mov  esi,0x5588dd
259
    int  0x40
250
    mcall
260
 
251
 
261
    mov  eax,8                     ; POP
252
    ;mov  eax,8                     ; POP
262
    mov  ebx,216*65536+53
253
    mov  ebx,216*65536+53
263
    mov  ecx,80*65536+16
254
    mov  ecx,80*65536+16
264
    mov  edx,3
255
    mov  edx,3
265
    mov  esi,0x5588dd
-
 
266
    int  0x40
256
    mcall
267
 
257
 
268
    mov  ebx,25*65536+35           ; draw info text with function 4
258
    mov  eax,4
269
    mov  ecx,0x224466
259
    mov  ebx,25*65536+35           ; draw info text with function 4
Line 270... Line 260...
270
    mov  edx,text
260
    mov  ecx,0x224466
Line 271... Line 261...
271
    mov  esi,40
261
    mov  edx,text
272
  newline:
262
    mov  esi,40
273
    mov  eax,4
263
  newline:
Line 274... Line 264...
274
    int  0x40
264
    mcall
Line 306... Line 296...
306
 
296
 
Line 307... Line 297...
307
    mov  edi,[addr]
297
    mov  edi,[addr]
308
 
298
 
309
  f11:
299
  f11:
310
    mov  eax,10
300
    mov  eax,10
311
    int  0x40
301
    mcall
Line 312... Line 302...
312
    cmp  eax,2
302
    cmp  eax,2
Line 313... Line 303...
313
    jz   fbu
303
    jz   fbu
314
 
304
 
Line 315... Line 305...
315
  exit_readkey:
305
  exit_readkey:
316
 
306
 
317
    popa
307
    popa
318
    ret
308
    ret
Line 319... Line 309...
319
 
309
 
320
  fbu:
310
  fbu:
Line 364... Line 354...
364
    add  ebx,25*6
354
    add  ebx,25*6
365
    mov  ecx,[ya]
355
    mov  ecx,[ya]
366
    shl  ecx,16
356
    shl  ecx,16
367
    mov  cx,8
357
    mov  cx,8
368
    mov  edx,0xffffff
358
    mov  edx,0xffffff
369
    int  0x40
359
    mcall
Line 370... Line 360...
370
 
360
 
371
    mov  eax,4
361
    mov  eax,4
372
    mov  ebx,[xa]
362
    mov  ebx,[xa]
373
    shl  ebx,16
363
    shl  ebx,16
374
    add  ebx,[ya]
364
    add  ebx,[ya]
375
    mov  ecx,0x000000
365
    mov  ecx,0x000000
376
    mov  edx,[addr]
366
    mov  edx,[addr]
377
    mov  esi,25
367
    mov  esi,25
Line 378... Line 368...
378
    int  0x40
368
    mcall
Line 398... Line 388...
398
    db '                                        '
388
    db '                                        '
399
    db 'RECEIVED:                          POP  '
389
    db 'RECEIVED:                          POP  '
400
    db 'x' ; <- END MARKER, DONT DELETE
390
    db 'x' ; <- END MARKER, DONT DELETE
Line 401... Line -...
401
 
-
 
402
 
391
 
403
labelt:
-
 
Line 404... Line 392...
404
       db   'IPC - START AT LEAST 2'
392
 
Line 405... Line 393...
405
labellen:
393
title      db   'IPC - START AT LEAST 2',0
406
 
394