Subversion Repositories Kolibri OS

Rev

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

Rev 485 Rev 551
1
;
1
;
2
;    Remote processing example (local node)                                     
2
;    Remote processing example (local node)                                     
3
;
3
;
4
;    Compile with FASM for Menuet
4
;    Compile with FASM for Menuet
5
;
5
;
6
   
6
   
7
   
7
   
8
use32
8
use32
9
 org	0x0
9
 org	0x0
10
 db	'MENUET01'    ; header
10
 db	'MENUET01'    ; header
11
 dd	0x01	      ; header version
11
 dd	0x01	      ; header version
12
 dd	START	      ; entry point
12
 dd	START	      ; entry point
13
 dd	I_END	      ; image size
13
 dd	I_END	      ; image size
14
 dd	I_END+0x10000 ; required memory
14
 dd	I_END+0x10000 ; required memory
15
 dd	I_END+0x10000 ; esp
15
 dd	I_END+0x10000 ; esp
16
 dd	0x0 , 0x0     ; I_Param , I_Path
16
 dd	0x0 , 0x0     ; I_Param , I_Path
17
 
17
 
18
   
18
   
19
include 'lang.inc'
19
include 'lang.inc'
20
include '..\..\..\macros.inc'
20
include '..\..\..\macros.inc'
21
   
21
   
22
START:                                  ; start of execution
22
START:                                  ; start of execution
23
   
23
   
24
    mov  eax,53                ; open socket
24
    mov  eax,53                ; open socket
25
    mov  ebx,0
25
    mov  ebx,0
26
    mov  ecx,0x2000            ; local port
26
    mov  ecx,0x2000            ; local port
27
    mov  edx,0x3000            ; remote port
27
    mov  edx,0x3000            ; remote port
28
    mov  esi,dword [host_ip]   ; node IP
28
    mov  esi,dword [host_ip]   ; node IP
29
    mcall
29
    mcall
30
   
30
   
31
    mov  [socketNum], eax
31
    mov  [socketNum], eax
32
 
32
 
33
red:   
33
red:   
34
    call draw_window            ; at first, draw the window
34
    call draw_window            ; at first, draw the window
35
   
35
   
36
still:
36
still:
37
   
37
   
38
    mov  eax,23                 ; wait here for event
38
    mov  eax,23                 ; wait here for event
39
    mov  ebx,1
39
    mov  ebx,1
40
    mcall
40
    mcall
41
   
41
   
42
    cmp  eax,1                  ; redraw request ?
42
    cmp  eax,1                  ; redraw request ?
43
    jz   red
43
    jz   red
44
    cmp  eax,2                  ; key in buffer ?
44
    cmp  eax,2                  ; key in buffer ?
45
    jz   key
45
    jz   key
46
    cmp  eax,3                  ; button in buffer ?
46
    cmp  eax,3                  ; button in buffer ?
47
    jz   button
47
    jz   button
48
   
48
   
49
    mov  eax, 53                ; get data
49
    mov  eax, 53                ; get data
50
    mov  ebx, 2
50
    mov  ebx, 2
51
    mov  ecx, [socketNum]
51
    mov  ecx, [socketNum]
52
    mcall
52
    mcall
53
    cmp  eax, 0
53
    cmp  eax, 0
54
    jne  read
54
    jne  read
55
   
55
   
56
    jmp  still
56
    jmp  still
57
   
57
   
58
key:
58
key:
59
    mov  eax,2
59
    mov  eax,2
60
    mcall
60
    mcall
61
    jmp  still
61
    jmp  still
62
   
62
   
63
button:
63
button:
64
    mov  eax,17
64
    mov  eax,17
65
    mcall
65
    mcall
66
   
66
   
67
    cmp  ah,1                  ; button id=1 ?
67
    cmp  ah,1                  ; button id=1 ?
68
    jnz  noclose
68
    jnz  noclose
69
    mov  eax, 53
69
    mov  eax, 53
70
    mov  ebx, 1
70
    mov  ebx, 1
71
    mov  ecx, [socketNum]
71
    mov  ecx, [socketNum]
72
    mcall
72
    mcall
73
    mov  eax,-1
73
    mov  eax,-1
74
    mcall
74
    mcall
75
  noclose:
75
  noclose:
76
   
76
   
77
    cmp  ah,2                  ; SEND CODE ?
77
    cmp  ah,2                  ; SEND CODE ?
78
    je   send_xcode
78
    je   send_xcode
79
   
79
   
80
    cmp  ah,3                  ; LEFT COORDINATES ?
80
    cmp  ah,3                  ; LEFT COORDINATES ?
81
    jne  no_left
81
    jne  no_left
82
    mov  [picture_position],0
82
    mov  [picture_position],0
83
    mov  dword [send_data+15],dword STARTX
83
    mov  dword [send_data+15],dword STARTX
84
    mov  dword [send_data+19],dword 4
84
    mov  dword [send_data+19],dword 4
85
    mov  esi,send_data
85
    mov  esi,send_data
86
    mov  edi,I_END
86
    mov  edi,I_END
87
    mov  ecx,23
87
    mov  ecx,23
88
    cld
88
    cld
89
    rep  movsb
89
    rep  movsb
90
    mov  [I_END+23],dword -20
90
    mov  [I_END+23],dword -20
91
    mov  eax,53
91
    mov  eax,53
92
    mov  ebx,4
92
    mov  ebx,4
93
    mov  ecx,[socketNum]
93
    mov  ecx,[socketNum]
94
    mov  edx,23 + 4
94
    mov  edx,23 + 4
95
    mov  esi,I_END
95
    mov  esi,I_END
96
    mcall
96
    mcall
97
    jmp  still
97
    jmp  still
98
  no_left:
98
  no_left:
99
   
99
   
100
    cmp  ah,4                  ; RIGHT COORDINATES ?
100
    cmp  ah,4                  ; RIGHT COORDINATES ?
101
    jne  no_right
101
    jne  no_right
102
    mov  [picture_position],128
102
    mov  [picture_position],128
103
    mov  dword [send_data+15],dword STARTX
103
    mov  dword [send_data+15],dword STARTX
104
    mov  dword [send_data+19],dword 4
104
    mov  dword [send_data+19],dword 4
105
    mov  esi,send_data
105
    mov  esi,send_data
106
    mov  edi,I_END
106
    mov  edi,I_END
107
    mov  ecx,23
107
    mov  ecx,23
108
    cld
108
    cld
109
    rep  movsb
109
    rep  movsb
110
    mov  [I_END+23],dword -20 + 128
110
    mov  [I_END+23],dword -20 + 128
111
    mov  eax,53
111
    mov  eax,53
112
    mov  ebx,4
112
    mov  ebx,4
113
    mov  ecx,[socketNum]
113
    mov  ecx,[socketNum]
114
    mov  edx,23 + 4
114
    mov  edx,23 + 4
115
    mov  esi,I_END
115
    mov  esi,I_END
116
    mcall
116
    mcall
117
    jmp  still
117
    jmp  still
118
  no_right:
118
  no_right:
119
   
119
   
120
    cmp  ah,5                  ; SEND EXECUTE ?
120
    cmp  ah,5                  ; SEND EXECUTE ?
121
    je   send_execute
121
    je   send_execute
122
   
122
   
123
    jmp  still
123
    jmp  still
124
   
124
   
125
   
125
   
126
xx  dd  0
126
xx  dd  0
127
yy  dd  0
127
yy  dd  0
128
   
128
   
129
   
129
   
130
   
130
   
131
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
131
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
132
;;                                              ;;
132
;;                                              ;;
133
;;           SEND CODE TO REMOTE                ;;
133
;;           SEND CODE TO REMOTE                ;;
134
;;                                              ;;
134
;;                                              ;;
135
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
135
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
136
   
136
   
137
send_xcode:
137
send_xcode:
138
   
138
   
139
  mov  dword [send_data+15],dword 0x80000
139
  mov  dword [send_data+15],dword 0x80000
140
  mov  dword [send_data+19],dword remote_code_end - remote_code_start
140
  mov  dword [send_data+19],dword remote_code_end - remote_code_start
141
   
141
   
142
  mov  esi,send_data              ; header
142
  mov  esi,send_data              ; header
143
  mov  edi,I_END
143
  mov  edi,I_END
144
  mov  ecx,23
144
  mov  ecx,23
145
  cld
145
  cld
146
  rep  movsb
146
  rep  movsb
147
   
147
   
148
  mov  esi,remote_code  ;  remote_code_start      ; data
148
  mov  esi,remote_code  ;  remote_code_start      ; data
149
  mov  edi,I_END+23
149
  mov  edi,I_END+23
150
  mov  ecx,remote_code_end - remote_code_start
150
  mov  ecx,remote_code_end - remote_code_start
151
  cld
151
  cld
152
  rep  movsb
152
  rep  movsb
153
   
153
   
154
  mov  eax,53                     ; SEND CODE TO REMOTE
154
  mov  eax,53                     ; SEND CODE TO REMOTE
155
  mov  ebx,4
155
  mov  ebx,4
156
  mov  ecx,[socketNum]
156
  mov  ecx,[socketNum]
157
  mov  edx,23 + remote_code_end - remote_code_start
157
  mov  edx,23 + remote_code_end - remote_code_start
158
  mov  esi,I_END
158
  mov  esi,I_END
159
  mcall
159
  mcall
160
   
160
   
161
  jmp  still
161
  jmp  still
162
   
162
   
163
   
163
   
164
send_execute:
164
send_execute:
165
   
165
   
166
  mov  dword [execute+15],dword draw_fractal
166
  mov  dword [execute+15],dword draw_fractal
167
   
167
   
168
  mov  eax,53                     ; START EXECUTE AT REMOTE
168
  mov  eax,53                     ; START EXECUTE AT REMOTE
169
  mov  ebx,4
169
  mov  ebx,4
170
  mov  ecx,[socketNum]
170
  mov  ecx,[socketNum]
171
  mov  edx,19
171
  mov  edx,19
172
  mov  esi,execute
172
  mov  esi,execute
173
  mcall
173
  mcall
174
   
174
   
175
  mov  edi,3
175
  mov  edi,3
176
   
176
   
177
  jmp  still
177
  jmp  still
178
   
178
   
179
   
179
   
180
   
180
   
181
;;;;;;;;;;;;;;;;;;;;;;;;;;
181
;;;;;;;;;;;;;;;;;;;;;;;;;;
182
;;                      ;;
182
;;                      ;;
183
;;       READ           ;;
183
;;       READ           ;;
184
;;                      ;;
184
;;                      ;;
185
;;;;;;;;;;;;;;;;;;;;;;;;;;
185
;;;;;;;;;;;;;;;;;;;;;;;;;;
186
   
186
   
187
   
187
   
188
read:
188
read:
189
   
189
   
190
   
190
   
191
cfr007:
191
cfr007:
192
   
192
   
193
 mov  eax, 53
193
 mov  eax, 53
194
 mov  ebx, 3
194
 mov  ebx, 3
195
 mov  ecx, [socketNum]
195
 mov  ecx, [socketNum]
196
 mcall   ; read byte
196
 mcall   ; read byte
197
   
197
   
198
 shl  edx,8
198
 shl  edx,8
199
 mov  dl,bl
199
 mov  dl,bl
200
   
200
   
201
 dec  edi
201
 dec  edi
202
 jnz  cok
202
 jnz  cok
203
   
203
   
204
 mov  edi,3
204
 mov  edi,3
205
   
205
   
206
 and  edx,0xffffff
206
 and  edx,0xffffff
207
 mov  eax,1
207
 mov  eax,1
208
 mov  ebx,[xx]
208
 mov  ebx,[xx]
209
 mov  ecx,[yy]
209
 mov  ecx,[yy]
210
 add  ebx,15
210
 add  ebx,15
211
 add  ecx,35
211
 add  ecx,35
212
 add  ebx,[picture_position]
212
 add  ebx,[picture_position]
213
 mcall
213
 mcall
214
   
214
   
215
 inc  [xx]
215
 inc  [xx]
216
 cmp  [xx],dword 128
216
 cmp  [xx],dword 128
217
 jb   cok
217
 jb   cok
218
 mov  [xx],0
218
 mov  [xx],0
219
   
219
   
220
 inc  [yy]
220
 inc  [yy]
221
 cmp  [yy],dword 128
221
 cmp  [yy],dword 128
222
 jb   cok
222
 jb   cok
223
 mov  [yy],0
223
 mov  [yy],0
224
   
224
   
225
cok:
225
cok:
226
   
226
   
227
 mov  eax, 53
227
 mov  eax, 53
228
 mov  ebx, 2
228
 mov  ebx, 2
229
 mov  ecx, [socketNum]
229
 mov  ecx, [socketNum]
230
 mcall   ; any more data?
230
 mcall   ; any more data?
231
   
231
   
232
 cmp  eax, 0
232
 cmp  eax, 0
233
 jne  cfr007  ; yes, so get it
233
 jne  cfr007  ; yes, so get it
234
   
234
   
235
 jmp  still
235
 jmp  still
236
   
236
   
237
   
237
   
238
   
238
   
239
   
239
   
240
;   *********************************************
240
;   *********************************************
241
;   *******  WINDOW DEFINITIONS AND DRAW ********
241
;   *******  WINDOW DEFINITIONS AND DRAW ********
242
;   *********************************************
242
;   *********************************************
243
   
243
   
244
   
244
   
245
draw_window:
245
draw_window:
246
   
246
   
247
    mov  eax,12                    ; function 12:tell os about windowdraw
247
    mov  eax,12                    ; function 12:tell os about windowdraw
248
    mov  ebx,1                     ; 1, start of draw
248
    mov  ebx,1                     ; 1, start of draw
249
    mcall
249
    mcall
250
   
250
   
251
                                   ; DRAW WINDOW
251
                                   ; DRAW WINDOW
252
    mov  eax,0                     ; function 0 : define and draw window
252
    mov  eax,0                     ; function 0 : define and draw window
253
    mov  ebx,100*65536+286         ; [x start] *65536 + [x size]
253
    mov  ebx,100*65536+286         ; [x start] *65536 + [x size]
254
    mov  ecx,60*65536+330          ; [y start] *65536 + [y size]
254
    mov  ecx,60*65536+330          ; [y start] *65536 + [y size]
255
    mov  edx,0x03ffffff            ; color of work area RRGGBB
255
    mov  edx,0x04ffffff            ; color of work area RRGGBB
256
    mov  edi,title                 ; WINDOW LABEL
256
    mov  edi,title                 ; WINDOW LABEL
257
    mcall
257
    mcall
258
   
258
   
259
                                   
259
                                   
260
    mov  eax,8                     ; SEND CODE
260
    mov  eax,8                     ; SEND CODE
261
    mov  ebx,60*65536+160
261
    mov  ebx,60*65536+160
262
    mov  ecx,181*65536+13
262
    mov  ecx,181*65536+13
263
    mov  edx,2
263
    mov  edx,2
264
    mov  esi,0x667788
264
    mov  esi,0x667788
265
    mcall
265
    mcall
266
   
266
   
267
    ;mov  eax,8                     ; LEFT
267
    ;mov  eax,8                     ; LEFT
268
    mov  ebx,60*65536+75
268
    mov  ebx,60*65536+75
269
    mov  ecx,197*65536+13
269
    mov  ecx,197*65536+13
270
    mov  edx,3
270
    mov  edx,3
271
    mcall
271
    mcall
272
   
272
   
273
    ;mov  eax,8                     ; RIGHT
273
    ;mov  eax,8                     ; RIGHT
274
    mov  ebx,148*65536+72
274
    mov  ebx,148*65536+72
275
    mov  ecx,197*65536+13
275
    mov  ecx,197*65536+13
276
    mov  edx,4
276
    mov  edx,4
277
    mcall
277
    mcall
278
   
278
   
279
    ;mov  eax,8                     ; SEND EXECUTE
279
    ;mov  eax,8                     ; SEND EXECUTE
280
    mov  ebx,60*65536+160
280
    mov  ebx,60*65536+160
281
    mov  ecx,213*65536+13
281
    mov  ecx,213*65536+13
282
    mov  edx,5
282
    mov  edx,5
283
    mcall
283
    mcall
284
   
284
   
285
   
285
   
286
    cld
286
    cld
287
    mov  eax,4
287
    mov  eax,4
288
    mov  ebx,25*65536+185           ; draw info text with function 4
288
    mov  ebx,25*65536+185           ; draw info text with function 4
289
    mov  ecx,0x000000
289
    mov  ecx,0x000000
290
    mov  edx,text
290
    mov  edx,text
291
    mov  esi,40
291
    mov  esi,40
292
  newline:
292
  newline:
293
    mcall
293
    mcall
294
    add  ebx,16
294
    add  ebx,16
295
    add  edx,40
295
    add  edx,40
296
    cmp  [edx],byte 'x'
296
    cmp  [edx],byte 'x'
297
    jnz  newline
297
    jnz  newline
298
   
298
   
299
    mov  eax,12                    ; function 12:tell os about windowdraw
299
    mov  eax,12                    ; function 12:tell os about windowdraw
300
    mov  ebx,2                     ; 2, end of draw
300
    mov  ebx,2                     ; 2, end of draw
301
    mcall
301
    mcall
302
   
302
   
303
    ret
303
    ret
304
   
304
   
305
   
305
   
306
; DATA AREA
306
; DATA AREA
307
   
307
   
308
   
308
   
309
text:
309
text:
310
    db ' 1)            SEND CODE                '
310
    db ' 1)            SEND CODE                '
311
    db ' 2)       LEFT          RIGHT           '
311
    db ' 2)       LEFT          RIGHT           '
312
    db " 3)         SEND 'EXECUTE'              "
312
    db " 3)         SEND 'EXECUTE'              "
313
    db '                                        '
313
    db '                                        '
314
    db ' LOCAL   : 192.168.1.26                 '
314
    db ' LOCAL   : 192.168.1.26                 '
315
    db ' REMOTE  : 192.168.1.22                 '
315
    db ' REMOTE  : 192.168.1.22                 '
316
    db ' REMOTE CODE AT THE END OF THIS FILE    '
316
    db ' REMOTE CODE AT THE END OF THIS FILE    '
317
    db 'x' ;<- END MARKER, DONT DELETE
317
    db 'x' ;<- END MARKER, DONT DELETE
318
   
318
   
319
   
319
   
320
title  db  'CLUSTER LOCAL',0
320
title  db  'CLUSTER LOCAL',0
321
   
321
   
322
socketNum   dd  0x0
322
socketNum   dd  0x0
323
   
323
   
324
host_ip  db  192,168,1,22
324
host_ip  db  192,168,1,22
325
   
325
   
326
picture_position dd 0x0
326
picture_position dd 0x0
327
   
327
   
328
send_data   db  'MenuetRemote00'  ; 00  header      ; -> remote port 0x3000
328
send_data   db  'MenuetRemote00'  ; 00  header      ; -> remote port 0x3000
329
            db  1                 ; 14  send
329
            db  1                 ; 14  send
330
            dd  0x0               ; 15  position
330
            dd  0x0               ; 15  position
331
            dd  0x0               ; 19  size
331
            dd  0x0               ; 19  size
332
                                  ; 23
332
                                  ; 23
333
   
333
   
334
execute     db  'MenuetRemote00'  ; 00  header      ; -> remote port 0x3000
334
execute     db  'MenuetRemote00'  ; 00  header      ; -> remote port 0x3000
335
            db  2                 ; 14  execute
335
            db  2                 ; 14  execute
336
            dd  0x0               ; 15  position
336
            dd  0x0               ; 15  position
337
                                  ; 19
337
                                  ; 19
338
   
338
   
339
   
339
   
340
   
340
   
341
   
341
   
342
   
342
   
343
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
343
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
344
;;                                                             ;;
344
;;                                                             ;;
345
;;                       REMOTE CODE                           ;;
345
;;                       REMOTE CODE                           ;;
346
;;                                                             ;;
346
;;                                                             ;;
347
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
347
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
348
   
348
   
349
   
349
   
350
   
350
   
351
remote_code:
351
remote_code:
352
   
352
   
353
   
353
   
354
org 0x80000
354
org 0x80000
355
   
355
   
356
remote_code_start:
356
remote_code_start:
357
   
357
   
358
   
358
   
359
PIXWIDTH    equ   129
359
PIXWIDTH    equ   129
360
PIXHEIGHT   equ   129
360
PIXHEIGHT   equ   129
361
ZOOMLIMIT   equ    13
361
ZOOMLIMIT   equ    13
362
DELTA       equ   200
362
DELTA       equ   200
363
THRESHOLD   equ     7
363
THRESHOLD   equ     7
364
STARTSCALE  equ     6
364
STARTSCALE  equ     6
365
CHAR_COLOR  equ   0fh
365
CHAR_COLOR  equ   0fh
366
   
366
   
367
STARTX       dd   -20
367
STARTX       dd   -20
368
STARTY       dd    10
368
STARTY       dd    10
369
scaleaddy    dd    60
369
scaleaddy    dd    60
370
scaleaddx    dd   100
370
scaleaddx    dd   100
371
   
371
   
372
   
372
   
373
   
373
   
374
draw_fractal:
374
draw_fractal:
375
   
375
   
376
        pusha
376
        pusha
377
   
377
   
378
        movzx   ebp,word [STARTX]
378
        movzx   ebp,word [STARTX]
379
        movzx   edi,word [STARTY]
379
        movzx   edi,word [STARTY]
380
        mov     cx, PIXHEIGHT   ; height of screen in pixels
380
        mov     cx, PIXHEIGHT   ; height of screen in pixels
381
   
381
   
382
        sub     di,cx           ; adjust our Y offset
382
        sub     di,cx           ; adjust our Y offset
383
@@CalcRow:
383
@@CalcRow:
384
   
384
   
385
        push    cx
385
        push    cx
386
        mov     cx, PIXWIDTH -1  ; width of screen in pixels
386
        mov     cx, PIXWIDTH -1  ; width of screen in pixels
387
   
387
   
388
        sub     bp,cx           ;
388
        sub     bp,cx           ;
389
@@CalcPixel:
389
@@CalcPixel:
390
        push    cx              ; save the column counter on stack
390
        push    cx              ; save the column counter on stack
391
        xor     cx, cx          ; clear out color loop counter
391
        xor     cx, cx          ; clear out color loop counter
392
        xor     bx, bx          ; zero i coefficient
392
        xor     bx, bx          ; zero i coefficient
393
        xor     dx, dx          ; zero j coefficient
393
        xor     dx, dx          ; zero j coefficient
394
@@CycleColors:
394
@@CycleColors:
395
        push    dx              ; save j value for later
395
        push    dx              ; save j value for later
396
        mov     ax, bx          ; ax = i
396
        mov     ax, bx          ; ax = i
397
        sub     ax, dx          ; ax = i - j
397
        sub     ax, dx          ; ax = i - j
398
        add     dx, bx          ; dx = i + j
398
        add     dx, bx          ; dx = i + j
399
        stc                     ; one additional shift, please
399
        stc                     ; one additional shift, please
400
        call    Shifty          ; ax = ((i+j)*(i-j)) shifted right
400
        call    Shifty          ; ax = ((i+j)*(i-j)) shifted right
401
        pop     dx              ; retrieve our saved value for j
401
        pop     dx              ; retrieve our saved value for j
402
        add     ax,bp           ; account for base offset...
402
        add     ax,bp           ; account for base offset...
403
        cmp     ah,THRESHOLD    ; Q: is i > THRESHOLD * 256?
403
        cmp     ah,THRESHOLD    ; Q: is i > THRESHOLD * 256?
404
        xchg    bx,ax           ; now swap new i with old i
404
        xchg    bx,ax           ; now swap new i with old i
405
        jg      @@draw          ; Y: draw this pixel
405
        jg      @@draw          ; Y: draw this pixel
406
        clc                     ; no additional shifts here, please
406
        clc                     ; no additional shifts here, please
407
        call    Shifty          ; now dx:ax = old i * j
407
        call    Shifty          ; now dx:ax = old i * j
408
        xchg    dx,ax           ;
408
        xchg    dx,ax           ;
409
        add     dx,di           ; account for base offset...
409
        add     dx,di           ; account for base offset...
410
        inc     cl              ; increment color
410
        inc     cl              ; increment color
411
        jnz     @@CycleColors   ; keep going until we're done
411
        jnz     @@CycleColors   ; keep going until we're done
412
@@draw:
412
@@draw:
413
        xchg    ax, cx          ; mov color into al
413
        xchg    ax, cx          ; mov color into al
414
        pop     cx              ; retrieve our column counter
414
        pop     cx              ; retrieve our column counter
415
        pop     dx              ; fetch row (column already in cx)
415
        pop     dx              ; fetch row (column already in cx)
416
        push    dx              ; must leave a copy on the stack
416
        push    dx              ; must leave a copy on the stack
417
        xor     bx,bx           ; write to video page zero
417
        xor     bx,bx           ; write to video page zero
418
   
418
   
419
        call    store_pixel
419
        call    store_pixel
420
   
420
   
421
        inc     bp
421
        inc     bp
422
        loop    @@CalcPixel
422
        loop    @@CalcPixel
423
        inc     di
423
        inc     di
424
        pop     cx
424
        pop     cx
425
        loop    @@CalcRow
425
        loop    @@CalcRow
426
   
426
   
427
        call   return_data
427
        call   return_data
428
   
428
   
429
        popa
429
        popa
430
   
430
   
431
        ret
431
        ret
432
   
432
   
433
   
433
   
434
Shifty:
434
Shifty:
435
   
435
   
436
        push    cx
436
        push    cx
437
        db      0b1h
437
        db      0b1h
438
scale   db      STARTSCALE
438
scale   db      STARTSCALE
439
        adc     cl,0
439
        adc     cl,0
440
        imul    dx
440
        imul    dx
441
   
441
   
442
        xchg    ax,dx
442
        xchg    ax,dx
443
        shl     eax,16
443
        shl     eax,16
444
        xchg    ax,dx
444
        xchg    ax,dx
445
        shr     eax,cl
445
        shr     eax,cl
446
   
446
   
447
        pop     cx
447
        pop     cx
448
        ret
448
        ret
449
   
449
   
450
   
450
   
451
pixel_pos: dd  data_area
451
pixel_pos: dd  data_area
452
   
452
   
453
store_pixel:
453
store_pixel:
454
   
454
   
455
      pusha
455
      pusha
456
   
456
   
457
      mov  ebx,[pixel_pos]
457
      mov  ebx,[pixel_pos]
458
      shl  eax,3
458
      shl  eax,3
459
      and  eax,0xff
459
      and  eax,0xff
460
      mov  [ebx],eax
460
      mov  [ebx],eax
461
      add  dword [pixel_pos],dword 3
461
      add  dword [pixel_pos],dword 3
462
   
462
   
463
      popa
463
      popa
464
      ret
464
      ret
465
   
465
   
466
   
466
   
467
return_data:
467
return_data:
468
   
468
   
469
      mov  ecx,128 * 128/16
469
      mov  ecx,128 * 128/16
470
      mov  esi,data_area
470
      mov  esi,data_area
471
   
471
   
472
    sd:
472
    sd:
473
   
473
   
474
      pusha
474
      pusha
475
   
475
   
476
      mov  eax,53              ; use the socket provided by host
476
      mov  eax,53              ; use the socket provided by host
477
      mov  ebx,4
477
      mov  ebx,4
478
      mov  ecx,[0]
478
      mov  ecx,[0]
479
      mov  edx,3*16
479
      mov  edx,3*16
480
      mcall
480
      mcall
481
   
481
   
482
      mov  eax,5
482
      mov  eax,5
483
      mov  ebx,1
483
      mov  ebx,1
484
      mcall
484
      mcall
485
   
485
   
486
      popa
486
      popa
487
   
487
   
488
      add  esi,3*16
488
      add  esi,3*16
489
   
489
   
490
      loop sd
490
      loop sd
491
   
491
   
492
      ret
492
      ret
493
   
493
   
494
   
494
   
495
data_area:
495
data_area:
496
   
496
   
497
remote_code_end:
497
remote_code_end:
498
   
498
   
499
   
499
   
500
I_END:
500
I_END: