Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
2288 clevermous 1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                              ;;
5363 yogev_ezra 3
;; Copyright (C) KolibriOS team 2004-2015. All rights reserved. ;;
2288 clevermous 4
;; Distributed under terms of the GNU General Public License    ;;
5
;;                                                              ;;
6
;;  VESA20.INC                                                  ;;
7
;;                                                              ;;
8
;;  Vesa 2.0 functions for MenuetOS                             ;;
9
;;                                                              ;;
10
;;  Copyright 2002 Ville Turjanmaa                              ;;
11
;;  Alexey, kgaz@crosswindws.net                                ;;
12
;;  - Voodoo compatible graphics                                ;;
13
;;  Juan M. Caravaca                                            ;;
14
;;  - Graphics optimimizations eg. drawline                     ;;
15
;;                                                              ;;
16
;;  See file COPYING for details                                ;;
17
;;                                                              ;;
18
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
19
 
20
$Revision: 9679 $
21
 
5154 hidnplayr 22
uglobal
23
align 4
7522 dunkaist 24
        bgr_cur_line    rd MAX_SCREEN_WIDTH
25
        bgr_next_line   rd MAX_SCREEN_WIDTH
5154 hidnplayr 26
endg
2288 clevermous 27
 
5154 hidnplayr 28
iglobal
29
align 4
30
        overlapping_of_points_ptr       dd overlapping_of_points
31
endg
2288 clevermous 32
 
33
 
5154 hidnplayr 34
;-----------------------------------------------------------------------------
35
; eax = x
36
; ebx = y
2288 clevermous 37
 
5154 hidnplayr 38
align 4
39
Vesa20_getpixel16:
2288 clevermous 40
 
5154 hidnplayr 41
        ; check for hardware cursor
42
        cmp     [_display.select_cursor], select_cursor
43
        je      @f
44
        cmp     [_display.select_cursor], 0
45
        jne     .no_mouseunder
46
  @@:
47
 
48
        ; check mouse area for putpixel
49
        test    ecx, 0x04000000         ; don't load to mouseunder area
50
        jnz     .no_mouseunder
51
        call    [_display.check_m_pixel]
52
        test    ecx, ecx                ; 0xff000000
53
        jnz     @f
54
 
55
  .no_mouseunder:
56
;        imul    ebx, [BytesPerScanLine] ; ebx = y * y multiplier
57
        mov     ebx, [BPSLine_calc_area+ebx*4]
58
        lea     edi, [eax*2]            ; edi = x*2
59
        add     edi, ebx                ; edi = x*2+(y*y multiplier)
60
 
61
        movzx   ecx, word[LFB_BASE+edi]
62
        shl     ecx, 3
63
        ror     ecx, 8
64
        shl     cx, 2
65
        ror     ecx, 8
66
        shl     cl, 3
67
        rol     ecx, 16
68
  @@:
69
        and     ecx, 0x00ffffff
2288 clevermous 70
        ret
5154 hidnplayr 71
 
2430 mario79 72
;-----------------------------------------------------------------------------
5154 hidnplayr 73
; eax = x
74
; ebx = y
75
 
2430 mario79 76
align 4
2288 clevermous 77
Vesa20_getpixel24:
5154 hidnplayr 78
 
79
        ; check for hardware cursor
2451 mario79 80
        cmp     [_display.select_cursor], select_cursor
81
        je      @f
2448 mario79 82
        cmp     [_display.select_cursor], 0
83
        jne     .no_mouseunder
5154 hidnplayr 84
  @@:
85
 
86
        ; check mouse area for putpixel
87
        test    ecx, 0x04000000         ; don't load to mouseunder area
2430 mario79 88
        jnz     .no_mouseunder
89
        call    [_display.check_m_pixel]
5154 hidnplayr 90
        test    ecx, ecx                ; 0xff000000
2430 mario79 91
        jnz     @f
5154 hidnplayr 92
 
93
  .no_mouseunder:
2446 mario79 94
;        imul    ebx, [BytesPerScanLine] ; ebx = y * y multiplier
2480 mario79 95
        mov     ebx, [BPSLine_calc_area+ebx*4]
5154 hidnplayr 96
        lea     edi, [eax+eax*2]        ; edi = x*3
97
        add     edi, ebx                ; edi = x*3+(y*y multiplier)
98
 
2288 clevermous 99
        mov     ecx, [LFB_BASE+edi]
5154 hidnplayr 100
  @@:
101
        and     ecx, 0x00ffffff
2288 clevermous 102
        ret
5154 hidnplayr 103
 
2430 mario79 104
;-----------------------------------------------------------------------------
5154 hidnplayr 105
; eax = x
106
; ebx = y
107
 
2430 mario79 108
align 4
2288 clevermous 109
Vesa20_getpixel32:
5154 hidnplayr 110
 
111
        ; check for hardware cursor
2451 mario79 112
        cmp     [_display.select_cursor], select_cursor
113
        je      @f
2448 mario79 114
        cmp     [_display.select_cursor], 0
115
        jne     .no_mouseunder
5154 hidnplayr 116
  @@:
117
 
118
        ; check mouse area for putpixel
119
        test    ecx, 0x04000000         ; don't load to mouseunder area
2430 mario79 120
        jnz     .no_mouseunder
121
        call    [_display.check_m_pixel]
5154 hidnplayr 122
        test    ecx, ecx                ; 0xff000000
2430 mario79 123
        jnz     @f
5154 hidnplayr 124
 
125
  .no_mouseunder:
2446 mario79 126
;        imul    ebx, [BytesPerScanLine] ; ebx = y * y multiplier
2480 mario79 127
        mov     ebx, [BPSLine_calc_area+ebx*4]
5154 hidnplayr 128
        lea     edi, [ebx+eax*4]        ; edi = x*4+(y*y multiplier)
129
 
2288 clevermous 130
        mov     ecx, [LFB_BASE+edi]
5154 hidnplayr 131
  @@:
132
        and     ecx, 0x00ffffff
2288 clevermous 133
        ret
5154 hidnplayr 134
 
2430 mario79 135
;-----------------------------------------------------------------------------
5154 hidnplayr 136
; ebx = pointer
137
; ecx = size [x|y]
138
; edx = coordinates [x|y]
139
; ebp = pointer to 'get' function
140
; esi = pointer to 'init' function
141
; edi = parameter for 'get' function
142
 
143
align 16
144
vesa20_putimage:
145
 
2288 clevermous 146
virtual at esp
147
 putimg:
148
   .real_sx        dd ?
149
   .real_sy        dd ?
150
   .image_sx       dd ?
151
   .image_sy       dd ?
152
   .image_cx       dd ?
153
   .image_cy       dd ?
154
   .pti            dd ?
155
   .abs_cx         dd ?
156
   .abs_cy         dd ?
157
   .line_increment dd ?
158
   .winmap_newline dd ?
159
   .screen_newline dd ?
2430 mario79 160
   .real_sx_and_abs_cx dd ?
161
   .real_sy_and_abs_cy dd ?
162
   .stack_data = 4*14
2288 clevermous 163
   .edi         dd      ?
164
   .esi         dd      ?
165
   .ebp         dd      ?
166
   .esp         dd      ?
167
   .ebx         dd      ?
168
   .edx         dd      ?
169
   .ecx         dd      ?
170
   .eax         dd      ?
171
   .ret_addr    dd      ?
172
   .arg_0       dd      ?
173
end virtual
5154 hidnplayr 174
 
2288 clevermous 175
        pushad
176
        sub     esp, putimg.stack_data
177
; save pointer to image
178
        mov     [putimg.pti], ebx
179
; unpack the size
180
        mov     eax, ecx
181
        and     ecx, 0xFFFF
182
        shr     eax, 16
183
        mov     [putimg.image_sx], eax
184
        mov     [putimg.image_sy], ecx
185
; unpack the coordinates
186
        mov     eax, edx
187
        and     edx, 0xFFFF
188
        shr     eax, 16
189
        mov     [putimg.image_cx], eax
190
        mov     [putimg.image_cy], edx
191
; calculate absolute (i.e. screen) coordinates
9679 Doczom 192
        ;mov     eax, [TASK_BASE]
193
        mov     eax, [current_slot_idx]
194
        shl     eax, 5 ; sizeof.WDATA
195
        mov     ebx, [eax + window_data + WDATA.box.left]
2288 clevermous 196
        add     ebx, [putimg.image_cx]
197
        mov     [putimg.abs_cx], ebx
9679 Doczom 198
        mov     ebx, [eax +window_data + WDATA.box.top]
2288 clevermous 199
        add     ebx, [putimg.image_cy]
200
        mov     [putimg.abs_cy], ebx
201
; real_sx = MIN(wnd_sx-image_cx, image_sx);
9679 Doczom 202
        mov     ebx, [eax + window_data + WDATA.box.width]       ; ebx = wnd_sx
5154 hidnplayr 203
        inc     ebx                                     ; WDATA.box.width is one pixel less than real window x-size
2288 clevermous 204
        sub     ebx, [putimg.image_cx]
205
        ja      @f
206
        add     esp, putimg.stack_data
207
        popad
208
        ret
5154 hidnplayr 209
 
210
  @@:
2288 clevermous 211
        cmp     ebx, [putimg.image_sx]
212
        jbe     .end_x
213
        mov     ebx, [putimg.image_sx]
5154 hidnplayr 214
  .end_x:
2288 clevermous 215
        mov     [putimg.real_sx], ebx
216
; init real_sy
9679 Doczom 217
        mov     ebx, [eax + window_data + WDATA.box.height]      ; ebx = wnd_sy
2288 clevermous 218
        inc     ebx
219
        sub     ebx, [putimg.image_cy]
220
        ja      @f
221
        add     esp, putimg.stack_data
222
        popad
223
        ret
5154 hidnplayr 224
 
225
  @@:
2288 clevermous 226
        cmp     ebx, [putimg.image_sy]
227
        jbe     .end_y
228
        mov     ebx, [putimg.image_sy]
5154 hidnplayr 229
  .end_y:
2288 clevermous 230
        mov     [putimg.real_sy], ebx
231
; line increment
232
        mov     eax, [putimg.image_sx]
233
        mov     ecx, [putimg.real_sx]
234
        sub     eax, ecx
235
;;     imul    eax, [putimg.source_bpp]
236
;     lea     eax, [eax + eax * 2]
237
        call    esi
238
        add     eax, [putimg.arg_0]
239
        mov     [putimg.line_increment], eax
240
; winmap new line increment
5350 serge 241
        mov     eax, [_display.width]
2288 clevermous 242
        sub     eax, [putimg.real_sx]
243
        mov     [putimg.winmap_newline], eax
244
; screen new line increment
5351 serge 245
        mov     eax, [_display.lfb_pitch]
5154 hidnplayr 246
        mov     ebx, [_display.bytes_per_pixel]
2288 clevermous 247
        imul    ecx, ebx
248
        sub     eax, ecx
249
        mov     [putimg.screen_newline], eax
250
; pointer to image
251
        mov     esi, [putimg.pti]
252
; pointer to screen
253
        mov     edx, [putimg.abs_cy]
2446 mario79 254
;        imul    edx, [BytesPerScanLine]
2480 mario79 255
        mov     edx, [BPSLine_calc_area+edx*4]
2288 clevermous 256
        mov     eax, [putimg.abs_cx]
257
        imul    eax, ebx
258
        add     edx, eax
259
; pointer to pixel map
260
        mov     eax, [putimg.abs_cy]
2446 mario79 261
;        imul    eax, [Screen_Max_X]
262
;        add     eax, [putimg.abs_cy]
263
        mov     eax, [d_width_calc_area + eax*4]
264
 
2288 clevermous 265
        add     eax, [putimg.abs_cx]
5351 serge 266
        add     eax, [_display.win_map]
2288 clevermous 267
        xchg    eax, ebp
5154 hidnplayr 268
 
2430 mario79 269
        mov     ecx, [putimg.real_sx]
270
        add     ecx, [putimg.abs_cx]
271
        mov     [putimg.real_sx_and_abs_cx], ecx
272
        mov     ecx, [putimg.real_sy]
273
        add     ecx, [putimg.abs_cy]
274
        mov     [putimg.real_sy_and_abs_cy], ecx
5154 hidnplayr 275
 
2288 clevermous 276
; get process number
8869 rgimad 277
        mov     ebx, [current_slot_idx]
5154 hidnplayr 278
 
279
        cmp     byte [_display.bits_per_pixel], 16
280
        je      put_image_end_16
281
        cmp     byte [_display.bits_per_pixel], 24
282
        je      put_image_end_24
283
        cmp     byte [_display.bits_per_pixel], 32
2288 clevermous 284
        je      put_image_end_32
5154 hidnplayr 285
 
286
;------------------------------------------------------------------------------
287
 
288
put_image_end_16:
289
 
290
        mov     edi, [putimg.real_sy]
291
 
292
; check for hardware cursor
293
        mov     ecx, [_display.select_cursor]
294
        cmp     ecx, select_cursor
295
        je      put_image_end_16_new
296
        cmp     ecx, 0
297
        je      put_image_end_16_old
298
  .new_line:
299
        mov     ecx, [putimg.real_sx]
300
  .new_x:
301
        push    [putimg.edi]
302
        mov     eax, [putimg.ebp+4]
303
        call    eax
304
        cmp     [ebp], bl
305
        jne     .skip
306
; convert to 16 bpp and store to LFB
307
        and     eax, 00000000111110001111110011111000b
308
        shr     ah, 2
309
        shr     ax, 3
310
        ror     eax, 8
311
        add     al, ah
312
        rol     eax, 8
313
        mov     [LFB_BASE+edx], ax
314
  .skip:
315
        add     edx, 2
316
        inc     ebp
317
        dec     ecx
318
        jnz     .new_x
319
 
320
        add     esi, [putimg.line_increment]
321
        add     edx, [putimg.screen_newline]
322
        add     ebp, [putimg.winmap_newline]
323
 
324
        cmp     [putimg.ebp], putimage_get1bpp
325
        jz      .correct
326
        cmp     [putimg.ebp], putimage_get2bpp
327
        jz      .correct
328
        cmp     [putimg.ebp], putimage_get4bpp
329
        jnz     @f
330
  .correct:
331
        mov     eax, [putimg.edi]
332
        mov     byte [eax], 80h
333
  @@:
334
        dec     edi
335
        jnz     .new_line
336
  .finish:
337
        add     esp, putimg.stack_data
338
        popad
339
        ret
340
 
341
;------------------------------------------------------------------------------
342
 
343
align 4
344
put_image_end_16_old:
345
 
346
  .new_line:
347
        mov     ecx, [putimg.real_sx]
348
  .new_x:
349
        push    [putimg.edi]
350
        mov     eax, [putimg.ebp+4]
351
        call    eax
352
        cmp     [ebp], bl
353
        jne     .skip
354
 
355
        push    ecx
356
        neg     ecx
357
        add     ecx, [putimg.real_sx_and_abs_cx + 4]
358
        shl     ecx, 16
359
        add     ecx, [putimg.real_sy_and_abs_cy + 4]
360
        sub     ecx, edi
361
 
362
; check mouse area for putpixel
363
        call    check_mouse_area_for_putpixel
364
        pop     ecx
365
 
366
; convert to 16 bpp and store to LFB
367
;;        and     eax, 00000000111110001111110011111000b
368
;;        shr     ah, 2
369
;;        shr     ax, 3
370
;;        ror     eax, 8
371
;;        add     al, ah
372
;;        rol     eax, 8
373
        mov     [LFB_BASE+edx], ax
374
  .skip:
375
        inc     edx
376
        inc     edx
377
        inc     ebp
378
        dec     ecx
379
        jnz     .new_x
380
 
381
        add     esi, [putimg.line_increment]
382
        add     edx, [putimg.screen_newline]
383
        add     ebp, [putimg.winmap_newline]
384
 
385
        cmp     [putimg.ebp], putimage_get1bpp
386
        jz      .correct
387
        cmp     [putimg.ebp], putimage_get2bpp
388
        jz      .correct
389
        cmp     [putimg.ebp], putimage_get4bpp
390
        jnz     @f
391
  .correct:
392
        mov     eax, [putimg.edi]
393
        mov     byte [eax], 80h
394
  @@:
395
        dec     edi
396
        jnz     .new_line
397
        jmp     put_image_end_16.finish
398
 
399
;------------------------------------------------------------------------------
400
 
401
align 4
402
put_image_end_16_new:
403
 
404
  .new_line:
405
        mov     ecx, [putimg.real_sx]
406
 
407
  .new_x:
408
        push    [putimg.edi]
409
        mov     eax, [putimg.ebp+4]
410
        call    eax
411
 
412
        cmp     [ebp], bl
413
        jne     .skip
414
 
415
        push    ecx
416
  .sh:
417
        neg     ecx
418
        add     ecx, [putimg.real_sx_and_abs_cx + 4]
419
 
420
; check for X
421
        cmp     cx, [X_UNDER_sub_CUR_hot_x_add_curh]
422
        jae     .no_mouse_area
423
 
424
        sub     cx, [X_UNDER_subtraction_CUR_hot_x]
425
        jb      .no_mouse_area
426
 
427
        shl     ecx, 16
428
        add     ecx, [putimg.real_sy_and_abs_cy + 4]
429
        sub     ecx, edi
430
 
431
; check for Y
432
        cmp     cx, [Y_UNDER_sub_CUR_hot_y_add_curh]
433
        jae     .no_mouse_area
434
 
435
        sub     cx, [Y_UNDER_subtraction_CUR_hot_y]
436
        jb      .no_mouse_area
437
 
438
; check mouse area for putpixel
439
        call    check_mouse_area_for_putpixel_new.1
440
        cmp     ecx, -1                 ; SHIT HAPPENS?
441
        jne     .no_mouse_area
442
 
443
        mov     ecx, [esp]
444
        jmp     .sh
445
 
446
  .no_mouse_area:
447
        pop     ecx
448
; convert to 16 bpp and store to LFB
449
        and     eax, 00000000111110001111110011111000b
450
        shr     ah, 2
451
        shr     ax, 3
452
        ror     eax, 8
453
        add     al, ah
454
        rol     eax, 8
455
        mov     [LFB_BASE+edx], ax
456
 
457
  .skip:
458
        add     edx, 2
459
        inc     ebp
460
        dec     ecx
461
        jnz     .new_x
462
 
463
        add     esi, [putimg.line_increment]
464
        add     edx, [putimg.screen_newline]
465
        add     ebp, [putimg.winmap_newline]
466
 
467
        cmp     [putimg.ebp], putimage_get1bpp
468
        jz      .correct
469
        cmp     [putimg.ebp], putimage_get2bpp
470
        jz      .correct
471
        cmp     [putimg.ebp], putimage_get4bpp
472
        jnz     @f
473
 
474
  .correct:
475
        mov     eax, [putimg.edi]
476
        mov     byte [eax], 80h
477
 
478
  @@:
479
        dec     edi
480
        jnz     .new_line
481
        jmp     put_image_end_16.finish
482
 
483
;------------------------------------------------------------------------------
484
 
485
align 4
2435 mario79 486
put_image_end_24:
5154 hidnplayr 487
 
2288 clevermous 488
        mov     edi, [putimg.real_sy]
5154 hidnplayr 489
 
2453 mario79 490
; check for hardware cursor
2455 mario79 491
        mov     ecx, [_display.select_cursor]
492
        cmp     ecx, select_cursor
493
        je      put_image_end_24_new
494
        cmp     ecx, 0
2453 mario79 495
        je      put_image_end_24_old
5154 hidnplayr 496
  .new_line:
2288 clevermous 497
        mov     ecx, [putimg.real_sx]
5154 hidnplayr 498
  .new_x:
2288 clevermous 499
        push    [putimg.edi]
500
        mov     eax, [putimg.ebp+4]
501
        call    eax
502
        cmp     [ebp], bl
503
        jne     .skip
5154 hidnplayr 504
 
505
; store to LFB
2453 mario79 506
        mov     [LFB_BASE+edx], ax
507
        shr     eax, 16
508
        mov     [LFB_BASE+edx+2], al
5154 hidnplayr 509
 
510
  .skip:
2453 mario79 511
        add     edx, 3
512
        inc     ebp
513
        dec     ecx
514
        jnz     .new_x
515
 
516
        add     esi, [putimg.line_increment]
5154 hidnplayr 517
        add     edx, [putimg.screen_newline]
518
        add     ebp, [putimg.winmap_newline]
2453 mario79 519
 
520
        cmp     [putimg.ebp], putimage_get1bpp
521
        jz      .correct
522
        cmp     [putimg.ebp], putimage_get2bpp
523
        jz      .correct
524
        cmp     [putimg.ebp], putimage_get4bpp
525
        jnz     @f
5154 hidnplayr 526
  .correct:
2453 mario79 527
        mov     eax, [putimg.edi]
528
        mov     byte [eax], 80h
5154 hidnplayr 529
  @@:
2453 mario79 530
        dec     edi
531
        jnz     .new_line
5154 hidnplayr 532
  .finish:
2453 mario79 533
        add     esp, putimg.stack_data
534
        popad
535
        ret
5154 hidnplayr 536
 
2453 mario79 537
;------------------------------------------------------------------------------
5154 hidnplayr 538
 
2453 mario79 539
align 4
540
put_image_end_24_old:
5154 hidnplayr 541
 
542
  .new_line:
2453 mario79 543
        mov     ecx, [putimg.real_sx]
544
;--------------------------------------
545
align 4
546
.new_x:
547
        push    [putimg.edi]
548
        mov     eax, [putimg.ebp+4]
549
        call    eax
550
        cmp     [ebp], bl
551
        jne     .skip
5154 hidnplayr 552
 
2430 mario79 553
        push    ecx
554
        neg     ecx
555
        add     ecx, [putimg.real_sx_and_abs_cx + 4]
556
        shl     ecx, 16
557
        add     ecx, [putimg.real_sy_and_abs_cy + 4]
558
        sub     ecx, edi
559
 
560
; check mouse area for putpixel
2435 mario79 561
        call    check_mouse_area_for_putpixel
2430 mario79 562
        pop     ecx
5154 hidnplayr 563
; store to LFB
2288 clevermous 564
        mov     [LFB_BASE+edx], ax
565
        shr     eax, 16
566
        mov     [LFB_BASE+edx+2], al
5154 hidnplayr 567
 
568
  .skip:
2288 clevermous 569
        add     edx, 3
570
        inc     ebp
571
        dec     ecx
572
        jnz     .new_x
2435 mario79 573
 
2288 clevermous 574
        add     esi, [putimg.line_increment]
5154 hidnplayr 575
        add     edx, [putimg.screen_newline]
576
        add     ebp, [putimg.winmap_newline]
2435 mario79 577
 
2288 clevermous 578
        cmp     [putimg.ebp], putimage_get1bpp
579
        jz      .correct
580
        cmp     [putimg.ebp], putimage_get2bpp
581
        jz      .correct
582
        cmp     [putimg.ebp], putimage_get4bpp
583
        jnz     @f
5154 hidnplayr 584
 
585
  .correct:
2288 clevermous 586
        mov     eax, [putimg.edi]
587
        mov     byte [eax], 80h
5154 hidnplayr 588
 
589
  @@:
2288 clevermous 590
        dec     edi
591
        jnz     .new_line
2453 mario79 592
        jmp     put_image_end_24.finish
5154 hidnplayr 593
 
2453 mario79 594
;------------------------------------------------------------------------------
5154 hidnplayr 595
 
2430 mario79 596
align 4
2435 mario79 597
put_image_end_24_new:
5154 hidnplayr 598
 
599
  .new_line:
2435 mario79 600
        mov     ecx, [putimg.real_sx]
5154 hidnplayr 601
 
602
  .new_x:
2435 mario79 603
        push    [putimg.edi]
604
        mov     eax, [putimg.ebp+4]
605
        call    eax
606
        cmp     [ebp], bl
607
        jne     .skip
5154 hidnplayr 608
 
2435 mario79 609
        push    ecx
5154 hidnplayr 610
  .sh:
2575 mario79 611
        neg     ecx
612
        add     ecx, [putimg.real_sx_and_abs_cx + 4]
5154 hidnplayr 613
 
2575 mario79 614
; check for X
615
        cmp     cx, [X_UNDER_sub_CUR_hot_x_add_curh]
616
        jae     .no_mouse_area
617
 
618
        sub     cx, [X_UNDER_subtraction_CUR_hot_x]
619
        jb      .no_mouse_area
620
 
621
        shl     ecx, 16
622
 
623
        add     ecx, [putimg.real_sy_and_abs_cy + 4]
2435 mario79 624
        sub     ecx, edi
5154 hidnplayr 625
 
2435 mario79 626
; check for Y
627
        cmp     cx, [Y_UNDER_sub_CUR_hot_y_add_curh]
628
        jae     .no_mouse_area
629
 
2575 mario79 630
        sub     cx, [Y_UNDER_subtraction_CUR_hot_y]
2435 mario79 631
        jb      .no_mouse_area
5154 hidnplayr 632
 
2435 mario79 633
; check mouse area for putpixel
634
        call    check_mouse_area_for_putpixel_new.1
5154 hidnplayr 635
        cmp     ecx, -1         ; SHIT HAPPENS?
2575 mario79 636
        jne     .no_mouse_area
637
 
638
        mov     ecx, [esp]
639
        jmp     .sh
5154 hidnplayr 640
 
641
  .no_mouse_area:
2435 mario79 642
        pop     ecx
5154 hidnplayr 643
 
644
; store to LFB
2435 mario79 645
        mov     [LFB_BASE+edx], ax
646
        shr     eax, 16
647
        mov     [LFB_BASE+edx+2], al
5154 hidnplayr 648
 
649
  .skip:
2435 mario79 650
        add     edx, 3
651
        inc     ebp
652
        dec     ecx
653
        jnz     .new_x
654
 
655
        add     esi, [putimg.line_increment]
5154 hidnplayr 656
        add     edx, [putimg.screen_newline]
657
        add     ebp, [putimg.winmap_newline]
2435 mario79 658
 
659
        cmp     [putimg.ebp], putimage_get1bpp
660
        jz      .correct
661
        cmp     [putimg.ebp], putimage_get2bpp
662
        jz      .correct
663
        cmp     [putimg.ebp], putimage_get4bpp
664
        jnz     @f
5154 hidnplayr 665
 
666
  .correct:
2435 mario79 667
        mov     eax, [putimg.edi]
668
        mov     byte [eax], 80h
5154 hidnplayr 669
 
670
  @@:
2435 mario79 671
        dec     edi
672
        jnz     .new_line
673
        jmp     put_image_end_24.finish
5154 hidnplayr 674
 
2430 mario79 675
;------------------------------------------------------------------------------
5154 hidnplayr 676
 
2430 mario79 677
align 4
2288 clevermous 678
put_image_end_32:
5154 hidnplayr 679
 
2288 clevermous 680
        mov     edi, [putimg.real_sy]
5154 hidnplayr 681
 
2453 mario79 682
; check for hardware cursor
2455 mario79 683
        mov     ecx, [_display.select_cursor]
684
        cmp     ecx, select_cursor
685
        je      put_image_end_32_new
686
        cmp     ecx, 0
2453 mario79 687
        je      put_image_end_32_old
5154 hidnplayr 688
 
689
  .new_line:
2288 clevermous 690
        mov     ecx, [putimg.real_sx]
5154 hidnplayr 691
 
692
  .new_x:
2288 clevermous 693
        push    [putimg.edi]
694
        mov     eax, [putimg.ebp+4]
695
        call    eax
696
        cmp     [ebp], bl
697
        jne     .skip
5154 hidnplayr 698
 
699
; store to LFB
2288 clevermous 700
        mov     [LFB_BASE+edx], eax
5154 hidnplayr 701
 
702
  .skip:
2288 clevermous 703
        add     edx, 4
704
        inc     ebp
705
        dec     ecx
706
        jnz     .new_x
2435 mario79 707
 
2288 clevermous 708
        add     esi, [putimg.line_increment]
5154 hidnplayr 709
        add     edx, [putimg.screen_newline]
710
        add     ebp, [putimg.winmap_newline]
2435 mario79 711
 
2288 clevermous 712
        cmp     [putimg.ebp], putimage_get1bpp
713
        jz      .correct
714
        cmp     [putimg.ebp], putimage_get2bpp
715
        jz      .correct
716
        cmp     [putimg.ebp], putimage_get4bpp
717
        jnz     @f
5154 hidnplayr 718
 
719
  .correct:
2288 clevermous 720
        mov     eax, [putimg.edi]
721
        mov     byte [eax], 80h
5154 hidnplayr 722
 
723
  @@:
2288 clevermous 724
        dec     edi
725
        jnz     .new_line
5154 hidnplayr 726
 
727
  .finish:
2288 clevermous 728
        add     esp, putimg.stack_data
729
        popad
3606 Serge 730
        cmp     [SCR_MODE], 0x12
2436 mario79 731
        jne     @f
2288 clevermous 732
        call    VGA__putimage
5154 hidnplayr 733
  @@:
2288 clevermous 734
        mov     [EGA_counter], 1
735
        ret
5154 hidnplayr 736
 
2453 mario79 737
;------------------------------------------------------------------------------
5154 hidnplayr 738
 
2453 mario79 739
align 4
740
put_image_end_32_old:
5154 hidnplayr 741
 
742
  .new_line:
2453 mario79 743
        mov     ecx, [putimg.real_sx]
5154 hidnplayr 744
  .new_x:
2453 mario79 745
        push    [putimg.edi]
746
        mov     eax, [putimg.ebp+4]
747
        call    eax
748
        cmp     [ebp], bl
749
        jne     .skip
5154 hidnplayr 750
 
2453 mario79 751
        push    ecx
752
        neg     ecx
753
        add     ecx, [putimg.real_sx_and_abs_cx + 4]
754
        shl     ecx, 16
755
        add     ecx, [putimg.real_sy_and_abs_cy + 4]
756
        sub     ecx, edi
757
 
758
; check mouse area for putpixel
759
        call    check_mouse_area_for_putpixel
760
        pop     ecx
5154 hidnplayr 761
; store to LFB
2453 mario79 762
        mov     [LFB_BASE+edx], eax
5154 hidnplayr 763
 
764
  .skip:
2453 mario79 765
        add     edx, 4
766
        inc     ebp
767
        dec     ecx
768
        jnz     .new_x
769
 
770
        add     esi, [putimg.line_increment]
5154 hidnplayr 771
        add     edx, [putimg.screen_newline]
772
        add     ebp, [putimg.winmap_newline]
2453 mario79 773
 
774
        cmp     [putimg.ebp], putimage_get1bpp
775
        jz      .correct
776
        cmp     [putimg.ebp], putimage_get2bpp
777
        jz      .correct
778
        cmp     [putimg.ebp], putimage_get4bpp
779
        jnz     @f
5154 hidnplayr 780
 
781
  .correct:
2453 mario79 782
        mov     eax, [putimg.edi]
783
        mov     byte [eax], 80h
5154 hidnplayr 784
 
785
  @@:
2453 mario79 786
        dec     edi
787
        jnz     .new_line
788
        jmp     put_image_end_32.finish
5154 hidnplayr 789
 
2453 mario79 790
;------------------------------------------------------------------------------
5154 hidnplayr 791
 
2453 mario79 792
align 4
2435 mario79 793
put_image_end_32_new:
5154 hidnplayr 794
 
795
  .new_line:
2435 mario79 796
        mov     ecx, [putimg.real_sx]
5154 hidnplayr 797
 
798
  .new_x:
2435 mario79 799
        push    [putimg.edi]
800
        mov     eax, [putimg.ebp+4]
801
        call    eax
802
        cmp     [ebp], bl
803
        jne     .skip
5154 hidnplayr 804
 
2435 mario79 805
        push    ecx
5154 hidnplayr 806
 
807
  .sh:
2575 mario79 808
        neg     ecx
809
        add     ecx, [putimg.real_sx_and_abs_cx + 4]
5154 hidnplayr 810
 
2575 mario79 811
; check for X
812
        cmp     cx, [X_UNDER_sub_CUR_hot_x_add_curh]
813
        jae     .no_mouse_area
814
        sub     cx, [X_UNDER_subtraction_CUR_hot_x]
815
        jb      .no_mouse_area
816
        shl     ecx, 16
817
 
818
        add     ecx, [putimg.real_sy_and_abs_cy + 4]
2435 mario79 819
        sub     ecx, edi
5154 hidnplayr 820
 
2435 mario79 821
; check for Y
822
        cmp     cx, [Y_UNDER_sub_CUR_hot_y_add_curh]
823
        jae     .no_mouse_area
2575 mario79 824
        sub     cx, [Y_UNDER_subtraction_CUR_hot_y]
2435 mario79 825
        jb      .no_mouse_area
5154 hidnplayr 826
 
2435 mario79 827
; check mouse area for putpixel
828
        call    check_mouse_area_for_putpixel_new.1
5154 hidnplayr 829
        cmp     ecx, -1         ; SHIT HAPPENS?
2575 mario79 830
        jne     .no_mouse_area
831
 
832
        mov     ecx, [esp]
833
        jmp     .sh
5154 hidnplayr 834
 
835
  .no_mouse_area:
2435 mario79 836
        pop     ecx
5154 hidnplayr 837
 
838
; store to LFB
2435 mario79 839
        mov     [LFB_BASE+edx], eax
5154 hidnplayr 840
 
841
  .skip:
2435 mario79 842
        add     edx, 4
843
        inc     ebp
844
        dec     ecx
845
        jnz     .new_x
846
 
847
        add     esi, [putimg.line_increment]
5154 hidnplayr 848
        add     edx, [putimg.screen_newline]
849
        add     ebp, [putimg.winmap_newline]
2435 mario79 850
 
851
        cmp     [putimg.ebp], putimage_get1bpp
852
        jz      .correct
853
        cmp     [putimg.ebp], putimage_get2bpp
854
        jz      .correct
855
        cmp     [putimg.ebp], putimage_get4bpp
856
        jnz     @f
5154 hidnplayr 857
 
858
  .correct:
2435 mario79 859
        mov     eax, [putimg.edi]
860
        mov     byte [eax], 80h
5154 hidnplayr 861
 
862
  @@:
2435 mario79 863
        dec     edi
864
        jnz     .new_line
865
        jmp     put_image_end_32.finish
5154 hidnplayr 866
 
2430 mario79 867
;------------------------------------------------------------------------------
2288 clevermous 868
; eax = x coordinate
869
; ebx = y coordinate
5154 hidnplayr 870
; ecx = xx RR GG BB
871
; xx flags:
872
; 0x01000000 color inversion
873
; 0x02000000 used for draw_rectangle without top line (for drawwindow_III and drawwindow_IV)
2288 clevermous 874
; edi = 0x00000001 force
875
 
5154 hidnplayr 876
align 4
877
__sys_putpixel:
878
 
2288 clevermous 879
        pushad
5350 serge 880
        cmp     eax, [_display.width]
881
        jge     .exit
882
        cmp     ebx, [_display.height]
883
        jge     .exit
5154 hidnplayr 884
        test    edi, 1          ; force ?
2288 clevermous 885
        jnz     .forced
886
 
5154 hidnplayr 887
; not forced
2438 mario79 888
        mov     edx, [d_width_calc_area + ebx*4]
5351 serge 889
        add     edx, [_display.win_map]
2288 clevermous 890
        movzx   edx, byte [eax+edx]
8869 rgimad 891
        cmp     edx, [current_slot_idx]
2288 clevermous 892
        jne     .exit
5154 hidnplayr 893
 
894
  .forced:
895
; check for color inversion
2288 clevermous 896
        test    ecx, 0x01000000
5154 hidnplayr 897
        jz      .no_inv
2430 mario79 898
 
5154 hidnplayr 899
        push    eax ebx edx edi
900
        call    [GETPIXEL]
901
        pop     edi edx ebx eax
902
 
2288 clevermous 903
        not     ecx
2430 mario79 904
        rol     ecx, 8
905
        mov     cl, [esp+32-8+3]
906
        ror     ecx, 8
2288 clevermous 907
        mov     [esp+32-8], ecx
5154 hidnplayr 908
  .no_inv:
909
        call    [PUTPIXEL]      ; call the real put_pixel function
910
  .exit:
2288 clevermous 911
        popad
912
        ret
5154 hidnplayr 913
 
2430 mario79 914
;-----------------------------------------------------------------------------
5154 hidnplayr 915
; eax = x
916
; ebx = y
917
 
2288 clevermous 918
align 4
5154 hidnplayr 919
Vesa20_putpixel16:
920
 
921
        mov     ecx, eax
922
        shl     ecx, 16
923
        mov     cx, bx
924
 
925
;        imul    ebx, [BytesPerScanLine]  ; ebx = y * y multiplier
926
        mov     ebx, [BPSLine_calc_area+ebx*4]
927
        lea     edi, [eax*2]; edi = x*2
928
        mov     eax, [esp+32-8+4]
929
 
930
; check for hardware cursor
931
        cmp     [_display.select_cursor], 0
932
        jne     @f
933
; check mouse area for putpixel
934
        test    eax, 0x04000000
935
        jnz     @f
936
        call    check_mouse_area_for_putpixel
937
  @@:
938
; store to LFB
939
        and     eax, 00000000111110001111110011111000b
940
        shr     ah, 2
941
        shr     ax, 3
942
        ror     eax, 8
943
        add     al, ah
944
        rol     eax, 8
945
 
946
        mov     [LFB_BASE+ebx+edi], ax
947
        ret
948
 
949
;-----------------------------------------------------------------------------
2288 clevermous 950
; eax = x
951
; ebx = y
5154 hidnplayr 952
 
953
align 4
954
Vesa20_putpixel16_new:
955
 
2430 mario79 956
        mov     ecx, eax
957
        shl     ecx, 16
958
        mov     cx, bx
959
 
2446 mario79 960
;        imul    ebx, [BytesPerScanLine]  ; ebx = y * y multiplier
2480 mario79 961
        mov     ebx, [BPSLine_calc_area+ebx*4]
5154 hidnplayr 962
        lea     edi, [eax*2]; edi = x*2
963
        mov     eax, [esp+32-8+4]
964
 
965
; check for hardware cursor
966
        cmp     [_display.select_cursor], select_cursor
967
        jne     @f
968
; check mouse area for putpixel
969
        test    eax, 0x04000000
970
        jnz     @f
971
 
972
; check for Y
973
        cmp     cx, [Y_UNDER_sub_CUR_hot_y_add_curh]
974
        jae     @f
975
        sub     cx, [Y_UNDER_subtraction_CUR_hot_y]
976
        jb      @f
977
        rol     ecx, 16
978
 
979
; check for X
980
        cmp     cx, [X_UNDER_sub_CUR_hot_x_add_curh]
981
        jae     @f
982
        sub     cx, [X_UNDER_subtraction_CUR_hot_x]
983
        jb      @f
984
        ror     ecx, 16
985
 
986
        call    check_mouse_area_for_putpixel_new.1
987
  @@:
988
; store to LFB
989
        and     eax, 00000000111110001111110011111000b
990
        shr     ah, 2
991
        shr     ax, 3
992
        ror     eax, 8
993
        add     al, ah
994
        rol     eax, 8
995
 
996
        mov     [LFB_BASE+ebx+edi], ax
997
        ret
998
 
999
;-----------------------------------------------------------------------------
1000
; eax = x
1001
; ebx = y
1002
 
1003
align 4
1004
Vesa20_putpixel24:
1005
 
1006
        mov     ecx, eax
1007
        shl     ecx, 16
1008
        mov     cx, bx
1009
 
1010
;        imul    ebx, [BytesPerScanLine]  ; ebx = y * y multiplier
1011
        mov     ebx, [BPSLine_calc_area+ebx*4]
2288 clevermous 1012
        lea     edi, [eax+eax*2]; edi = x*3
1013
        mov     eax, [esp+32-8+4]
5154 hidnplayr 1014
 
2448 mario79 1015
; check for hardware cursor
1016
        cmp     [_display.select_cursor], 0
1017
        jne     @f
2430 mario79 1018
; check mouse area for putpixel
1019
        test    eax, 0x04000000
1020
        jnz     @f
2436 mario79 1021
        call    check_mouse_area_for_putpixel
5154 hidnplayr 1022
  @@:
1023
 
1024
; store to LFB
2288 clevermous 1025
        mov     [LFB_BASE+ebx+edi], ax
1026
        shr     eax, 16
1027
        mov     [LFB_BASE+ebx+edi+2], al
2436 mario79 1028
        ret
5154 hidnplayr 1029
 
2436 mario79 1030
;-----------------------------------------------------------------------------
5154 hidnplayr 1031
; eax = x
1032
; ebx = y
1033
 
2436 mario79 1034
align 4
1035
Vesa20_putpixel24_new:
5154 hidnplayr 1036
 
2436 mario79 1037
        mov     ecx, eax
1038
        shl     ecx, 16
1039
        mov     cx, bx
1040
 
2446 mario79 1041
;        imul    ebx, [BytesPerScanLine]  ; ebx = y * y multiplier
2480 mario79 1042
        mov     ebx, [BPSLine_calc_area+ebx*4]
2436 mario79 1043
        lea     edi, [eax+eax*2]; edi = x*3
1044
        mov     eax, [esp+32-8+4]
5154 hidnplayr 1045
 
2448 mario79 1046
; check for hardware cursor
1047
        cmp     [_display.select_cursor], select_cursor
1048
        jne     @f
2436 mario79 1049
; check mouse area for putpixel
1050
        test    eax, 0x04000000
1051
        jnz     @f
5154 hidnplayr 1052
 
2436 mario79 1053
; check for Y
1054
        cmp     cx, [Y_UNDER_sub_CUR_hot_y_add_curh]
1055
        jae     @f
2575 mario79 1056
        sub     cx, [Y_UNDER_subtraction_CUR_hot_y]
1057
        jb      @f
5154 hidnplayr 1058
        rol     ecx, 16
2575 mario79 1059
 
2436 mario79 1060
; check for X
1061
        cmp     cx, [X_UNDER_sub_CUR_hot_x_add_curh]
1062
        jae     @f
2575 mario79 1063
        sub     cx, [X_UNDER_subtraction_CUR_hot_x]
1064
        jb      @f
1065
        ror     ecx, 16
1066
 
2436 mario79 1067
        call    check_mouse_area_for_putpixel_new.1
5154 hidnplayr 1068
  @@:
1069
; store to LFB
2436 mario79 1070
        mov     [LFB_BASE+ebx+edi], ax
1071
        shr     eax, 16
1072
        mov     [LFB_BASE+ebx+edi+2], al
2288 clevermous 1073
        ret
5154 hidnplayr 1074
 
2430 mario79 1075
;-----------------------------------------------------------------------------
5154 hidnplayr 1076
; eax = x
1077
; ebx = y
1078
 
2288 clevermous 1079
align 4
1080
Vesa20_putpixel32:
5154 hidnplayr 1081
 
2430 mario79 1082
        mov     ecx, eax
1083
        shl     ecx, 16
1084
        mov     cx, bx
1085
 
2446 mario79 1086
;        imul    ebx, [BytesPerScanLine]  ; ebx = y * y multiplier
2480 mario79 1087
        mov     ebx, [BPSLine_calc_area+ebx*4]
5154 hidnplayr 1088
        lea     edi, [ebx+eax*4]        ; edi = x*4+(y*y multiplier)
1089
        mov     eax, [esp+32-8+4]       ; eax = color
1090
 
2448 mario79 1091
; check for hardware cursor
1092
        cmp     [_display.select_cursor], 0
1093
        jne     @f
2430 mario79 1094
; check mouse area for putpixel
1095
        test    eax, 0x04000000
1096
        jnz     @f
2436 mario79 1097
        call    check_mouse_area_for_putpixel
5154 hidnplayr 1098
  @@:
2430 mario79 1099
        and     eax, 0xffffff
5154 hidnplayr 1100
; store to LFB
2288 clevermous 1101
        mov     [LFB_BASE+edi], eax
2436 mario79 1102
        ret
5154 hidnplayr 1103
 
2436 mario79 1104
;-----------------------------------------------------------------------------
5154 hidnplayr 1105
; eax = x
1106
; ebx = y
1107
 
2436 mario79 1108
align 4
1109
Vesa20_putpixel32_new:
5154 hidnplayr 1110
 
2436 mario79 1111
        mov     ecx, eax
1112
        shl     ecx, 16
1113
        mov     cx, bx
1114
 
2446 mario79 1115
;        imul    ebx, [BytesPerScanLine]  ; ebx = y * y multiplier
2480 mario79 1116
        mov     ebx, [BPSLine_calc_area+ebx*4]
5154 hidnplayr 1117
        lea     edi, [ebx+eax*4]        ; edi = x*4+(y*y multiplier)
1118
        mov     eax, [esp+32-8+4]       ; eax = color
1119
 
2448 mario79 1120
; check for hardware cursor
1121
        cmp     [_display.select_cursor], select_cursor
1122
        jne     @f
2436 mario79 1123
; check mouse area for putpixel
1124
        test    eax, 0x04000000
1125
        jnz     @f
5154 hidnplayr 1126
 
2436 mario79 1127
; check for Y
1128
        cmp     cx, [Y_UNDER_sub_CUR_hot_y_add_curh]
1129
        jae     @f
2575 mario79 1130
        sub     cx, [Y_UNDER_subtraction_CUR_hot_y]
1131
        jb      @f
5154 hidnplayr 1132
        rol     ecx, 16
2575 mario79 1133
 
2436 mario79 1134
; check for X
1135
        cmp     cx, [X_UNDER_sub_CUR_hot_x_add_curh]
1136
        jae     @f
2575 mario79 1137
        sub     cx, [X_UNDER_subtraction_CUR_hot_x]
1138
        jb      @f
1139
        ror     ecx, 16
1140
 
2436 mario79 1141
        call    check_mouse_area_for_putpixel_new.1
5154 hidnplayr 1142
  @@:
1143
        and     eax, 0x00ffffff
1144
; store to LFB
2436 mario79 1145
        mov     [LFB_BASE+edi], eax
2288 clevermous 1146
        ret
5154 hidnplayr 1147
 
2430 mario79 1148
;-----------------------------------------------------------------------------
5154 hidnplayr 1149
 
2430 mario79 1150
align 4
2288 clevermous 1151
calculate_edi:
2446 mario79 1152
;        mov     edi, ebx
1153
;        imul    edi, [Screen_Max_X]
1154
;        add     edi, ebx
1155
        mov     edi, [d_width_calc_area + ebx*4]
2288 clevermous 1156
        add     edi, eax
1157
        ret
5154 hidnplayr 1158
 
1159
 
2430 mario79 1160
;-----------------------------------------------------------------------------
2288 clevermous 1161
; DRAWLINE
2430 mario79 1162
;-----------------------------------------------------------------------------
5154 hidnplayr 1163
; eax = x1 shl 16 + x2
1164
; ebx = y1 shl 16 + y2
2288 clevermous 1165
; ecx = color
1166
; edi = force ?
1167
 
5154 hidnplayr 1168
align 4
1169
__sys_draw_line:
1170
 
2288 clevermous 1171
dl_x1 equ esp+20
1172
dl_y1 equ esp+16
1173
dl_x2 equ esp+12
1174
dl_y2 equ esp+8
1175
dl_dx equ esp+4
1176
dl_dy equ esp+0
1177
 
5154 hidnplayr 1178
        pusha
1179
 
1180
        xor     edx, edx        ; clear edx
1181
        xor     esi, esi        ; unpack arguments
2288 clevermous 1182
        xor     ebp, ebp
5154 hidnplayr 1183
        mov     si, ax          ; esi = x2
1184
        mov     bp, bx          ; ebp = y2
1185
        shr     eax, 16         ; eax = x1
1186
        shr     ebx, 16         ; ebx = y1
1187
        push    eax             ; save x1
1188
        push    ebx             ; save y1
1189
        push    esi             ; save x2
1190
        push    ebp             ; save y2
2288 clevermous 1191
; checking x-axis...
5154 hidnplayr 1192
        sub     esi, eax        ; esi = x2-x1
1193
        push    esi             ; save y2-y1
1194
        jl      .x2lx1          ; is x2 less than x1 ?
1195
        jg      .no_vline       ; x1 > x2 ?
1196
        mov     edx, ebp        ; else (if x1=x2)
2288 clevermous 1197
        call    vline
5154 hidnplayr 1198
        push    edx             ; necessary to rightly restore stack frame at .exit
2288 clevermous 1199
        jmp     .exit
5154 hidnplayr 1200
 
1201
  .x2lx1:
1202
        neg     esi             ; get esi absolute value
1203
 
1204
  .no_vline:
2288 clevermous 1205
; checking y-axis...
5154 hidnplayr 1206
        sub     ebp, ebx        ; ebp = y2-y1
1207
        push    ebp             ; save y2-y1
1208
        jl      .y2ly1          ; is y2 less than y1 ?
1209
        jg      .no_hline       ; y1 > y2 ?
1210
        mov     edx, [dl_x2]    ; else (if y1=y2)
2288 clevermous 1211
        call    hline
1212
        jmp     .exit
5154 hidnplayr 1213
 
1214
  .y2ly1:
1215
        neg     ebp             ; get ebp absolute value
1216
 
1217
  .no_hline:
2288 clevermous 1218
        cmp     ebp, esi
5154 hidnplayr 1219
        jle     .x_rules        ; |y2-y1| < |x2-x1|  ?
1220
        cmp     [dl_y2], ebx    ; make sure y1 is at the begining
2288 clevermous 1221
        jge     .no_reverse1
1222
        neg     dword [dl_dx]
1223
        mov     edx, [dl_x2]
1224
        mov     [dl_x2], eax
1225
        mov     [dl_x1], edx
1226
        mov     edx, [dl_y2]
1227
        mov     [dl_y2], ebx
1228
        mov     [dl_y1], edx
5154 hidnplayr 1229
 
1230
  .no_reverse1:
2288 clevermous 1231
        mov     eax, [dl_dx]
5154 hidnplayr 1232
        cdq                     ; extend eax sing to edx
1233
        shl     eax, 16         ; using 16bit fix-point maths
1234
        idiv    ebp             ; eax = ((x2-x1)*65536)/(y2-y1)
1235
 
2353 mario79 1236
; correction for the remainder of the division
1237
        shl     edx, 1
1238
        cmp     ebp, edx
1239
        jb      @f
1240
        inc     eax
5154 hidnplayr 1241
  @@:
1242
        mov     edx, ebp        ; edx = counter (number of pixels to draw)
1243
        mov     ebp, 1 shl 16   ; ebp = dy = 1.0
1244
        mov     esi, eax        ; esi = dx
2288 clevermous 1245
        jmp     .y_rules
5154 hidnplayr 1246
  .x_rules:
1247
        cmp     [dl_x2], eax    ; make sure x1 is at the begining
2288 clevermous 1248
        jge     .no_reverse2
1249
        neg     dword [dl_dy]
1250
        mov     edx, [dl_x2]
1251
        mov     [dl_x2], eax
1252
        mov     [dl_x1], edx
1253
        mov     edx, [dl_y2]
1254
        mov     [dl_y2], ebx
1255
        mov     [dl_y1], edx
5154 hidnplayr 1256
  .no_reverse2:
2288 clevermous 1257
        xor     edx, edx
1258
        mov     eax, [dl_dy]
5154 hidnplayr 1259
        cdq                     ; extend eax sing to edx
1260
        shl     eax, 16         ; using 16bit fix-point maths
1261
        idiv    esi             ; eax = ((y2-y1)*65536)/(x2-x1)
2353 mario79 1262
; correction for the remainder of the division
1263
        shl     edx, 1
1264
        cmp     esi, edx
1265
        jb      @f
1266
        inc     eax
5154 hidnplayr 1267
  @@:
1268
        mov     edx, esi        ; edx = counter (number of pixels to draw)
1269
        mov     esi, 1 shl 16   ; esi = dx = 1.0
1270
        mov     ebp, eax        ; ebp = dy
1271
 
1272
  .y_rules:
2288 clevermous 1273
        mov     eax, [dl_x1]
1274
        mov     ebx, [dl_y1]
1275
        shl     eax, 16
1276
        shl     ebx, 16
2455 mario79 1277
 
5154 hidnplayr 1278
        and     ecx, 0xFBFFFFFF ; negate 0x04000000 save to mouseunder area
1279
  .draw:
2288 clevermous 1280
        push    eax ebx
5154 hidnplayr 1281
 
2353 mario79 1282
; correction for the remainder of the division
1283
        test    ah, 0x80
1284
        jz      @f
1285
        add     eax, 1 shl 16
5154 hidnplayr 1286
  @@:
2288 clevermous 1287
        shr     eax, 16
2353 mario79 1288
; correction for the remainder of the division
1289
        test    bh, 0x80
1290
        jz      @f
1291
        add     ebx, 1 shl 16
5154 hidnplayr 1292
  @@:
2288 clevermous 1293
        shr     ebx, 16
5154 hidnplayr 1294
;        and     ecx, 0xFBFFFFFF  ; negate 0x04000000 save to mouseunder area
2453 mario79 1295
;        call    [putpixel]
1296
        call    __sys_putpixel
2288 clevermous 1297
        pop     ebx eax
1298
        add     ebx, ebp     ; y = y+dy
1299
        add     eax, esi     ; x = x+dx
1300
        dec     edx
1301
        jnz     .draw
1302
; force last drawn pixel to be at (x2,y2)
1303
        mov     eax, [dl_x2]
1304
        mov     ebx, [dl_y2]
5154 hidnplayr 1305
;        and     ecx, 0xFBFFFFFF ;n egate 0x04000000 save to mouseunder area
2453 mario79 1306
;        call    [putpixel]
1307
        call    __sys_putpixel
5154 hidnplayr 1308
 
1309
  .exit:
2288 clevermous 1310
        add     esp, 6*4
1311
        popa
2430 mario79 1312
;        call    [draw_pointer]
2288 clevermous 1313
        ret
5154 hidnplayr 1314
 
2430 mario79 1315
;------------------------------------------------------------------------------
2288 clevermous 1316
; draw an horizontal line
1317
; eax = x1
1318
; edx = x2
1319
; ebx = y
1320
; ecx = color
1321
; edi = force ?
5154 hidnplayr 1322
 
1323
align 4
1324
hline:
1325
 
2288 clevermous 1326
        push    eax edx
1327
        cmp     edx, eax   ; make sure x2 is above x1
1328
        jge     @f
1329
        xchg    eax, edx
5154 hidnplayr 1330
  @@:
2430 mario79 1331
        and     ecx, 0xFBFFFFFF  ;negate 0x04000000 save to mouseunder area
5154 hidnplayr 1332
  @@:
2453 mario79 1333
;        call    [putpixel]
1334
        call    __sys_putpixel
2288 clevermous 1335
        inc     eax
1336
        cmp     eax, edx
1337
        jle     @b
1338
        pop     edx eax
1339
        ret
5154 hidnplayr 1340
 
2430 mario79 1341
;------------------------------------------------------------------------------
2288 clevermous 1342
; draw a vertical line
1343
; eax = x
1344
; ebx = y1
1345
; edx = y2
1346
; ecx = color
1347
; edi = force ?
5154 hidnplayr 1348
 
1349
align 4
1350
vline:
1351
 
2288 clevermous 1352
        push    ebx edx
1353
        cmp     edx, ebx   ; make sure y2 is above y1
1354
        jge     @f
1355
        xchg    ebx, edx
5154 hidnplayr 1356
  @@:
2430 mario79 1357
        and     ecx, 0xFBFFFFFF ;negate 0x04000000 save to mouseunder area
5154 hidnplayr 1358
  @@:
2453 mario79 1359
;        call    [putpixel]
1360
        call    __sys_putpixel
2288 clevermous 1361
        inc     ebx
1362
        cmp     ebx, edx
1363
        jle     @b
1364
        pop     edx ebx
1365
        ret
5154 hidnplayr 1366
 
2430 mario79 1367
;------------------------------------------------------------------------------
5154 hidnplayr 1368
; eax   cx
1369
; ebx   cy
1370
; ecx   xe
1371
; edx   ye
1372
; edi   color
1373
 
2430 mario79 1374
align 4
5154 hidnplayr 1375
vesa20_drawbar:
1376
 
2288 clevermous 1377
virtual at esp
1378
drbar:
1379
     .bar_sx       dd ?
1380
     .bar_sy       dd ?
1381
     .bar_cx       dd ?
1382
     .bar_cy       dd ?
1383
     .abs_cx       dd ?
1384
     .abs_cy       dd ?
1385
     .real_sx      dd ?
1386
     .real_sy      dd ?
1387
     .color        dd ?
1388
     .line_inc_scr dd ?
1389
     .line_inc_map dd ?
2430 mario79 1390
     .real_sx_and_abs_cx dd ?
1391
     .real_sy_and_abs_cy dd ?
1392
     .stack_data = 4*13
2288 clevermous 1393
end virtual
5154 hidnplayr 1394
 
2288 clevermous 1395
        pushad
1396
        sub     esp, drbar.stack_data
1397
        mov     [drbar.color], edi
1398
        sub     edx, ebx
5154 hidnplayr 1399
        jle     .exit
2288 clevermous 1400
        sub     ecx, eax
5154 hidnplayr 1401
        jle     .exit
2288 clevermous 1402
        mov     [drbar.bar_sy], edx
1403
        mov     [drbar.bar_sx], ecx
1404
        mov     [drbar.bar_cx], eax
1405
        mov     [drbar.bar_cy], ebx
9679 Doczom 1406
        ;mov     edi, [TASK_BASE]
1407
        mov     edi, [current_slot_idx]
1408
        shl     edi, 5 ; sizeof.WDATA
1409
        add     eax, [edi + window_data + WDATA.box.left]        ; win_cx
1410
        add     ebx, [edi + window_data + WDATA.box.top]         ; win_cy
2288 clevermous 1411
        mov     [drbar.abs_cx], eax
1412
        mov     [drbar.abs_cy], ebx
1413
; real_sx = MIN(wnd_sx-bar_cx, bar_sx);
9679 Doczom 1414
        mov     ebx, [edi + window_data + WDATA.box.width]       ; ebx = wnd_sx
5154 hidnplayr 1415
        inc     ebx                                     ; WDATA.box.width is one pixel less than real window x-size
2288 clevermous 1416
        sub     ebx, [drbar.bar_cx]
1417
        ja      @f
5154 hidnplayr 1418
  .exit:
2288 clevermous 1419
        add     esp, drbar.stack_data
1420
        popad
1421
        xor     eax, eax
1422
        inc     eax
1423
        ret
5154 hidnplayr 1424
  @@:
2288 clevermous 1425
        cmp     ebx, [drbar.bar_sx]
1426
        jbe     .end_x
1427
        mov     ebx, [drbar.bar_sx]
5154 hidnplayr 1428
  .end_x:
2288 clevermous 1429
        mov     [drbar.real_sx], ebx
1430
; real_sy = MIN(wnd_sy-bar_cy, bar_sy);
9679 Doczom 1431
        mov     ebx, [edi + window_data + WDATA.box.height]      ; ebx = wnd_sy
2288 clevermous 1432
        inc     ebx
1433
        sub     ebx, [drbar.bar_cy]
1434
        ja      @f
1435
        add     esp, drbar.stack_data
1436
        popad
1437
        xor     eax, eax
1438
        inc     eax
1439
        ret
5154 hidnplayr 1440
  @@:
2288 clevermous 1441
        cmp     ebx, [drbar.bar_sy]
1442
        jbe     .end_y
1443
        mov     ebx, [drbar.bar_sy]
5154 hidnplayr 1444
  .end_y:
2288 clevermous 1445
        mov     [drbar.real_sy], ebx
1446
; line_inc_map
5350 serge 1447
        mov     eax, [_display.width]
2288 clevermous 1448
        sub     eax, [drbar.real_sx]
1449
        mov     [drbar.line_inc_map], eax
1450
; line_inc_scr
1451
        mov     eax, [drbar.real_sx]
5154 hidnplayr 1452
        mov     ebx, [_display.bytes_per_pixel]
2288 clevermous 1453
        imul    eax, ebx
1454
        neg     eax
5351 serge 1455
        add     eax, [_display.lfb_pitch]
2288 clevermous 1456
        mov     [drbar.line_inc_scr], eax
1457
; pointer to screen
1458
        mov     edx, [drbar.abs_cy]
2446 mario79 1459
;        imul    edx, [BytesPerScanLine]
2480 mario79 1460
        mov     edx, [BPSLine_calc_area+edx*4]
2288 clevermous 1461
        mov     eax, [drbar.abs_cx]
1462
        imul    eax, ebx
1463
        add     edx, eax
1464
; pointer to pixel map
1465
        mov     eax, [drbar.abs_cy]
2446 mario79 1466
;        imul    eax, [Screen_Max_X]
1467
;        add     eax, [drbar.abs_cy]
1468
        mov     eax, [d_width_calc_area + eax*4]
1469
 
2288 clevermous 1470
        add     eax, [drbar.abs_cx]
5351 serge 1471
        add     eax, [_display.win_map]
2288 clevermous 1472
        xchg    eax, ebp
5154 hidnplayr 1473
 
2430 mario79 1474
        mov     ebx, [drbar.real_sx]
1475
        add     ebx, [drbar.abs_cx]
1476
        mov     [drbar.real_sx_and_abs_cx], ebx
1477
        mov     ebx, [drbar.real_sy]
1478
        add     ebx, [drbar.abs_cy]
1479
        mov     [drbar.real_sy_and_abs_cy], ebx
1480
 
1481
        add     edx, LFB_BASE
5154 hidnplayr 1482
 
2288 clevermous 1483
; get process number
8869 rgimad 1484
        mov     ebx, [current_slot_idx]  ; bl - process num
2446 mario79 1485
        mov     esi, [drbar.real_sy]
1486
        mov     eax, [drbar.color] ; BBGGRR00
1487
        rol     eax, 8
1488
        mov     bh, al  ; 0x80 drawing gradient bars
1489
        ror     eax, 8
5154 hidnplayr 1490
 
1491
        cmp     byte [_display.bits_per_pixel], 16
1492
        je      draw_bar_end_16
1493
        cmp     byte [_display.bits_per_pixel], 24
1494
        je      draw_bar_end_24
1495
        cmp     byte [_display.bits_per_pixel], 32
1496
        je      draw_bar_end_32
1497
 
2430 mario79 1498
;--------------------------------------
2446 mario79 1499
; eax - color high   RRGGBB
2288 clevermous 1500
; bl - process num
1501
; ecx - temp
1502
; edx - pointer to screen
1503
; esi - counter
1504
; edi - counter
5154 hidnplayr 1505
 
1506
align 4
1507
draw_bar_end_24:
1508
 
2453 mario79 1509
; check for hardware cursor
2455 mario79 1510
        mov     ecx, [_display.select_cursor]
1511
        cmp     ecx, select_cursor
1512
        je      draw_bar_end_24_new
1513
        cmp     ecx, 0
2453 mario79 1514
        je      draw_bar_end_24_old
5154 hidnplayr 1515
  .new_y:
2288 clevermous 1516
        mov     edi, [drbar.real_sx]
5154 hidnplayr 1517
  .new_x:
2288 clevermous 1518
        cmp     byte [ebp], bl
1519
        jne     .skip
5154 hidnplayr 1520
 
1521
; store to LFB
2453 mario79 1522
        mov     [edx], ax
1523
        shr     eax, 16
1524
        mov     [edx + 2], al
5154 hidnplayr 1525
  .skip:
2453 mario79 1526
; add pixel
1527
        add     edx, 3
1528
        inc     ebp
1529
        dec     edi
1530
        jnz     .new_x
1531
; add line
1532
        add     edx, [drbar.line_inc_scr]
1533
        add     ebp, [drbar.line_inc_map]
1534
; drawing gradient bars
1535
        test    bh, 0x80
1536
        jz      @f
1537
        test    al, al
1538
        jz      @f
1539
        dec     al
5154 hidnplayr 1540
  @@:
2453 mario79 1541
        dec     esi
1542
        jnz     .new_y
5154 hidnplayr 1543
  .end:
2453 mario79 1544
        add     esp, drbar.stack_data
1545
        popad
1546
        xor     eax, eax
1547
        ret
5154 hidnplayr 1548
 
2453 mario79 1549
;------------------------------------------------------------------------------
5154 hidnplayr 1550
 
2453 mario79 1551
align 4
1552
draw_bar_end_24_old:
5154 hidnplayr 1553
 
1554
  .new_y:
2453 mario79 1555
        mov     edi, [drbar.real_sx]
5154 hidnplayr 1556
  .new_x:
2453 mario79 1557
        cmp     byte [ebp], bl
1558
        jne     .skip
5154 hidnplayr 1559
 
2446 mario79 1560
        mov     ecx, [drbar.real_sx_and_abs_cx]
2430 mario79 1561
        sub     ecx, edi
1562
        shl     ecx, 16
2446 mario79 1563
        add     ecx, [drbar.real_sy_and_abs_cy]
2430 mario79 1564
        sub     ecx, esi
1565
; check mouse area for putpixel
1566
        call    check_mouse_area_for_putpixel
5154 hidnplayr 1567
; store to LFB
2430 mario79 1568
        mov     [edx], ax
1569
        shr     eax, 16
1570
        mov     [edx + 2], al
2446 mario79 1571
        mov     eax, [drbar.color]
5154 hidnplayr 1572
  .skip:
2288 clevermous 1573
; add pixel
1574
        add     edx, 3
1575
        inc     ebp
1576
        dec     edi
1577
        jnz     .new_x
1578
; add line
1579
        add     edx, [drbar.line_inc_scr]
1580
        add     ebp, [drbar.line_inc_map]
2446 mario79 1581
; drawing gradient bars
1582
        test    bh, 0x80
2288 clevermous 1583
        jz      @f
2446 mario79 1584
        test    al, al
2288 clevermous 1585
        jz      @f
2446 mario79 1586
        dec     al
5154 hidnplayr 1587
  @@:
2288 clevermous 1588
        dec     esi
1589
        jnz     .new_y
2453 mario79 1590
        jmp     draw_bar_end_24.end
5154 hidnplayr 1591
 
2453 mario79 1592
;------------------------------------------------------------------------------
5154 hidnplayr 1593
 
2430 mario79 1594
align 4
1595
draw_bar_end_24_new:
5154 hidnplayr 1596
 
1597
  .new_y:
2430 mario79 1598
        mov     edi, [drbar.real_sx]
5154 hidnplayr 1599
  .new_x:
2430 mario79 1600
        cmp     byte [ebp], bl
1601
        jne     .skip
5154 hidnplayr 1602
 
2430 mario79 1603
        mov     ecx, [drbar.real_sy_and_abs_cy]
1604
        sub     ecx, esi
5154 hidnplayr 1605
 
2430 mario79 1606
; check for Y
1607
        cmp     cx, [Y_UNDER_sub_CUR_hot_y_add_curh]
1608
        jae     .no_mouse_area
2575 mario79 1609
        sub     cx, [Y_UNDER_subtraction_CUR_hot_y]
1610
        jb      .no_mouse_area
2430 mario79 1611
        rol     ecx, 16
1612
        add     ecx, [drbar.real_sx_and_abs_cx]
1613
        sub     ecx, edi
5154 hidnplayr 1614
 
2430 mario79 1615
; check for X
2575 mario79 1616
        cmp     cx, [X_UNDER_sub_CUR_hot_x_add_curh]
1617
        jae     .no_mouse_area
1618
        sub     cx, [X_UNDER_subtraction_CUR_hot_x]
2430 mario79 1619
        jb      .no_mouse_area
5154 hidnplayr 1620
        ror     ecx, 16
2430 mario79 1621
 
1622
; check mouse area for putpixel
2477 mario79 1623
        push    eax
2430 mario79 1624
        call    check_mouse_area_for_putpixel_new.1
1625
        mov     [edx], ax
1626
        shr     eax, 16
1627
        mov     [edx + 2], al
2477 mario79 1628
        pop     eax
2430 mario79 1629
        jmp     .skip
5154 hidnplayr 1630
 
1631
  .no_mouse_area:
1632
; store to LFB
2446 mario79 1633
        mov     [edx], ax
1634
        ror     eax, 16
1635
        mov     [edx + 2], al
1636
        rol     eax, 16
5154 hidnplayr 1637
  .skip:
1638
 
2430 mario79 1639
; add pixel
1640
        add     edx, 3
1641
        inc     ebp
1642
        dec     edi
1643
        jnz     .new_x
5154 hidnplayr 1644
 
2430 mario79 1645
; add line
1646
        add     edx, [drbar.line_inc_scr]
1647
        add     ebp, [drbar.line_inc_map]
5154 hidnplayr 1648
 
2446 mario79 1649
; drawing gradient bars
1650
        test    bh, 0x80
2430 mario79 1651
        jz      @f
2446 mario79 1652
        test    al, al
2430 mario79 1653
        jz      @f
2446 mario79 1654
        dec     al
5154 hidnplayr 1655
  @@:
2430 mario79 1656
        dec     esi
1657
        jnz     .new_y
1658
        jmp     draw_bar_end_24.end
5154 hidnplayr 1659
 
2453 mario79 1660
;------------------------------------------------------------------------------
2446 mario79 1661
; eax - color high   RRGGBB
1662
; bl - process num
1663
; ecx - temp
1664
; edx - pointer to screen
1665
; esi - counter
1666
; edi - counter
5154 hidnplayr 1667
 
1668
draw_bar_end_32:
1669
 
2453 mario79 1670
; check for hardware cursor
2455 mario79 1671
        mov     ecx, [_display.select_cursor]
1672
        cmp     ecx, select_cursor
1673
        je      draw_bar_end_32_new
1674
        cmp     ecx, 0
2453 mario79 1675
        je      draw_bar_end_32_old
5154 hidnplayr 1676
 
1677
  .new_y:
2288 clevermous 1678
        mov     edi, [drbar.real_sx]
5154 hidnplayr 1679
  .new_x:
2288 clevermous 1680
        cmp     byte [ebp], bl
1681
        jne     .skip
5154 hidnplayr 1682
 
1683
; store to LFB
2430 mario79 1684
        mov     [edx], eax
2446 mario79 1685
        mov     eax, [drbar.color]
5154 hidnplayr 1686
  .skip:
1687
 
2288 clevermous 1688
; add pixel
1689
        add     edx, 4
1690
        inc     ebp
1691
        dec     edi
1692
        jnz     .new_x
5154 hidnplayr 1693
 
2288 clevermous 1694
; add line
1695
        add     edx, [drbar.line_inc_scr]
1696
        add     ebp, [drbar.line_inc_map]
5154 hidnplayr 1697
 
2446 mario79 1698
; drawing gradient bars
1699
        test    bh, 0x80
2288 clevermous 1700
        jz      @f
1701
        test    al, al
1702
        jz      @f
1703
        dec     al
5154 hidnplayr 1704
  @@:
2288 clevermous 1705
        dec     esi
1706
        jnz     .new_y
5154 hidnplayr 1707
  .end:
2288 clevermous 1708
        add     esp, drbar.stack_data
1709
        popad
3606 Serge 1710
        cmp     [SCR_MODE], 0x12
2436 mario79 1711
        jne     @f
2288 clevermous 1712
        call    VGA_draw_bar
5154 hidnplayr 1713
  @@:
2288 clevermous 1714
        xor     eax, eax
1715
        mov     [EGA_counter], 1
1716
        ret
5154 hidnplayr 1717
 
2453 mario79 1718
draw_bar_end_32_old:
5154 hidnplayr 1719
 
1720
  .new_y:
2453 mario79 1721
        mov     edi, [drbar.real_sx]
5154 hidnplayr 1722
  .new_x:
2453 mario79 1723
        cmp     byte [ebp], bl
1724
        jne     .skip
5154 hidnplayr 1725
 
2453 mario79 1726
        mov     ecx, [drbar.real_sx_and_abs_cx]
1727
        sub     ecx, edi
1728
        shl     ecx, 16
1729
        add     ecx, [drbar.real_sy_and_abs_cy]
1730
        sub     ecx, esi
1731
 
1732
; check mouse area for putpixel
1733
        call    check_mouse_area_for_putpixel
5154 hidnplayr 1734
; store to LFB
2453 mario79 1735
        mov     [edx], eax
1736
        mov     eax, [drbar.color]
5154 hidnplayr 1737
  .skip:
2453 mario79 1738
; add pixel
1739
        add     edx, 4
1740
        inc     ebp
1741
        dec     edi
1742
        jnz     .new_x
1743
; add line
1744
        add     edx, [drbar.line_inc_scr]
1745
        add     ebp, [drbar.line_inc_map]
1746
; drawing gradient bars
1747
        test    bh, 0x80
1748
        jz      @f
1749
        test    al, al
1750
        jz      @f
1751
        dec     al
5154 hidnplayr 1752
  @@:
2453 mario79 1753
        dec     esi
1754
        jnz     .new_y
1755
        jmp     draw_bar_end_32.end
5154 hidnplayr 1756
 
2453 mario79 1757
;------------------------------------------------------------------------------
5154 hidnplayr 1758
 
2453 mario79 1759
align 4
2430 mario79 1760
draw_bar_end_32_new:
5154 hidnplayr 1761
 
1762
  .new_y:
2430 mario79 1763
        mov     edi, [drbar.real_sx]
5154 hidnplayr 1764
  .new_x:
2430 mario79 1765
        cmp     byte [ebp], bl
1766
        jne     .skip
5154 hidnplayr 1767
 
2430 mario79 1768
        mov     ecx, [drbar.real_sy_and_abs_cy]
1769
        sub     ecx, esi
5154 hidnplayr 1770
 
2430 mario79 1771
; check for Y
1772
        cmp     cx, [Y_UNDER_sub_CUR_hot_y_add_curh]
1773
        jae     .no_mouse_area
2575 mario79 1774
        sub     cx, [Y_UNDER_subtraction_CUR_hot_y]
1775
        jb      .no_mouse_area
2430 mario79 1776
        rol     ecx, 16
1777
        add     ecx, [drbar.real_sx_and_abs_cx]
1778
        sub     ecx, edi
5154 hidnplayr 1779
 
2430 mario79 1780
; check for X
2575 mario79 1781
        cmp     cx, [X_UNDER_sub_CUR_hot_x_add_curh]
1782
        jae     .no_mouse_area
1783
        sub     cx, [X_UNDER_subtraction_CUR_hot_x]
2430 mario79 1784
        jb      .no_mouse_area
5154 hidnplayr 1785
        ror     ecx, 16
2430 mario79 1786
 
1787
; check mouse area for putpixel
2477 mario79 1788
        push    eax
2430 mario79 1789
        call    check_mouse_area_for_putpixel_new.1
1790
        mov     [edx], eax
2477 mario79 1791
        pop     eax
2430 mario79 1792
        jmp     .skip
5154 hidnplayr 1793
  .no_mouse_area:
1794
 
1795
; store to LFB
2430 mario79 1796
        mov     [edx], eax
5154 hidnplayr 1797
  .skip:
1798
 
1799
; add pixel
1800
        add     edx, 4
1801
        inc     ebp
1802
        dec     edi
1803
        jnz     .new_x
1804
 
1805
; add line
1806
        add     edx, [drbar.line_inc_scr]
1807
        add     ebp, [drbar.line_inc_map]
1808
 
1809
; drawing gradient bars
1810
        test    bh, 0x80
1811
        jz      @f
1812
        test    al, al
1813
        jz      @f
1814
        dec     al
1815
  @@:
1816
        dec     esi
1817
        jnz     .new_y
1818
        jmp     draw_bar_end_32.end
1819
 
1820
;------------------------------------------------------------------------------
1821
; eax - color high   RRGGBB
1822
; bl - process num
1823
; ecx - temp
1824
; edx - pointer to screen
1825
; esi - counter
1826
; edi - counter
1827
 
2430 mario79 1828
align 4
5154 hidnplayr 1829
draw_bar_end_16:
1830
 
1831
; check for hardware cursor
1832
        mov     ecx, [_display.select_cursor]
1833
        cmp     ecx, select_cursor
1834
        je      draw_bar_end_16_new
1835
        cmp     ecx, 0
1836
        je      draw_bar_end_16_old
1837
  .new_y:
1838
        mov     edi, [drbar.real_sx]
1839
  .new_x:
1840
        cmp     byte [ebp], bl
1841
        jne     .skip
1842
; convert to 16 bpp and store to LFB
1843
        and     eax, 00000000111110001111110011111000b
1844
        shr     ah, 2
1845
        shr     ax, 3
1846
        ror     eax, 8
1847
        add     al, ah
1848
        rol     eax, 8
1849
        mov     [edx], ax
1850
        mov     eax, [drbar.color]
1851
  .skip:
1852
 
1853
; add pixel
1854
        add     edx, 2
1855
        inc     ebp
1856
        dec     edi
1857
        jnz     .new_x
1858
; add line
1859
        add     edx, [drbar.line_inc_scr]
1860
        add     ebp, [drbar.line_inc_map]
1861
; drawing gradient bars
1862
        test    bh, 0x80
1863
        jz      @f
1864
        test    al, al
1865
        jz      @f
1866
        dec     al
1867
  @@:
1868
        dec     esi
1869
        jnz     .new_y
1870
  .end:
1871
        add     esp, drbar.stack_data
1872
        popad
1873
        cmp     [SCR_MODE], 0x12
1874
        jne     @f
1875
        call    VGA_draw_bar
1876
  @@:
1877
        xor     eax, eax
1878
        mov     [EGA_counter], 1
1879
        ret
1880
 
1881
;------------------------------------------------------------------------------
1882
 
1883
align 4
1884
draw_bar_end_16_old:
1885
 
1886
  .new_y:
1887
        mov     edi, [drbar.real_sx]
1888
  .new_x:
1889
        cmp     byte [ebp], bl
1890
        jne     .skip
1891
 
1892
        mov     ecx, [drbar.real_sx_and_abs_cx]
1893
        sub     ecx, edi
1894
        shl     ecx, 16
1895
        add     ecx, [drbar.real_sy_and_abs_cy]
1896
        sub     ecx, esi
1897
 
1898
; check mouse area for putpixel
1899
        call    check_mouse_area_for_putpixel
1900
; convert to 16 bpp and store to LFB
1901
        and     eax, 00000000111110001111110011111000b
1902
        shr     ah, 2
1903
        shr     ax, 3
1904
        ror     eax, 8
1905
        add     al, ah
1906
        rol     eax, 8
1907
        mov     [edx], ax
1908
        mov     eax, [drbar.color]
2430 mario79 1909
.skip:
5154 hidnplayr 1910
 
2430 mario79 1911
; add pixel
5154 hidnplayr 1912
        add     edx, 2
2430 mario79 1913
        inc     ebp
1914
        dec     edi
1915
        jnz     .new_x
5154 hidnplayr 1916
 
2430 mario79 1917
; add line
1918
        add     edx, [drbar.line_inc_scr]
1919
        add     ebp, [drbar.line_inc_map]
5154 hidnplayr 1920
 
2446 mario79 1921
; drawing gradient bars
1922
        test    bh, 0x80
2430 mario79 1923
        jz      @f
1924
        test    al, al
1925
        jz      @f
1926
        dec     al
5154 hidnplayr 1927
  @@:
1928
        dec     esi
1929
        jnz     .new_y
1930
        jmp     draw_bar_end_16.end
1931
 
1932
;------------------------------------------------------------------------------
1933
 
2430 mario79 1934
align 4
5154 hidnplayr 1935
draw_bar_end_16_new:
1936
 
1937
  .new_y:
1938
        mov     edi, [drbar.real_sx]
1939
  .new_x:
1940
        cmp     byte [ebp], bl
1941
        jne     .skip
1942
 
1943
        mov     ecx, [drbar.real_sy_and_abs_cy]
1944
        sub     ecx, esi
1945
 
1946
; check for Y
1947
        cmp     cx, [Y_UNDER_sub_CUR_hot_y_add_curh]
1948
        jae     .no_mouse_area
1949
        sub     cx, [Y_UNDER_subtraction_CUR_hot_y]
1950
        jb      .no_mouse_area
1951
        rol     ecx, 16
1952
        add     ecx, [drbar.real_sx_and_abs_cx]
1953
        sub     ecx, edi
1954
 
1955
; check for X
1956
        cmp     cx, [X_UNDER_sub_CUR_hot_x_add_curh]
1957
        jae     .no_mouse_area
1958
        sub     cx, [X_UNDER_subtraction_CUR_hot_x]
1959
        jb      .no_mouse_area
1960
        ror     ecx, 16
1961
 
1962
; check mouse area for putpixel
1963
        push    eax
1964
        call    check_mouse_area_for_putpixel_new.1
1965
        push    eax
1966
        and     eax, 00000000111110001111110011111000b
1967
        shr     ah, 2
1968
        shr     ax, 3
1969
        ror     eax, 8
1970
        add     al, ah
1971
        rol     eax, 8
1972
        mov     [edx], ax
1973
        pop     eax
1974
        pop     eax
1975
        jmp     .skip
1976
 
1977
  .no_mouse_area:
1978
; convert to 16 bpp and store to LFB
1979
        push    eax
1980
        and     eax, 00000000111110001111110011111000b
1981
        shr     ah, 2
1982
        shr     ax, 3
1983
        ror     eax, 8
1984
        add     al, ah
1985
        rol     eax, 8
1986
        mov     [edx], ax
1987
        pop     eax
1988
  .skip:
1989
 
1990
; add pixel
1991
        add     edx, 2
1992
        inc     ebp
1993
        dec     edi
1994
        jnz     .new_x
1995
 
1996
; add line
1997
        add     edx, [drbar.line_inc_scr]
1998
        add     ebp, [drbar.line_inc_map]
1999
 
2000
; drawing gradient bars
2001
        test    bh, 0x80
2002
        jz      @f
2003
        test    al, al
2004
        jz      @f
2005
        dec     al
2006
  @@:
2430 mario79 2007
        dec     esi
2008
        jnz     .new_y
5154 hidnplayr 2009
        jmp     draw_bar_end_16.end
2010
 
2430 mario79 2011
;------------------------------------------------------------------------------
5154 hidnplayr 2012
 
2430 mario79 2013
align 4
2288 clevermous 2014
vesa20_drawbackground_tiled:
5154 hidnplayr 2015
 
2288 clevermous 2016
        pushad
2017
; External loop for all y from start to end
2018
        mov     ebx, [draw_data+32+RECT.top]    ; y start
5154 hidnplayr 2019
  dp2:
2288 clevermous 2020
        mov     ebp, [draw_data+32+RECT.left]   ; x start
2021
; 1) Calculate pointers in WinMapAddress (does pixel belong to OS thread?) [ebp]
5154 hidnplayr 2022
;    and LFB data (output for our function) [edi]
2446 mario79 2023
;        mov     eax, [BytesPerScanLine]
2024
;        mul     ebx
2480 mario79 2025
        mov     eax, [BPSLine_calc_area+ebx*4]
2288 clevermous 2026
        xchg    ebp, eax
2027
        add     ebp, eax
2028
        add     ebp, eax
5154 hidnplayr 2029
        cmp     byte [_display.bytes_per_pixel], 2
2030
        je      @f
2288 clevermous 2031
        add     ebp, eax
5154 hidnplayr 2032
        cmp     byte [_display.bytes_per_pixel], 3
2033
        je      @f
2288 clevermous 2034
        add     ebp, eax
5154 hidnplayr 2035
 
2036
  @@:
2288 clevermous 2037
        add     ebp, LFB_BASE
2038
; ebp:=Y*BytesPerScanLine+X*BytesPerPixel+AddrLFB
2039
        call    calculate_edi
2040
        xchg    edi, ebp
5351 serge 2041
        add     ebp, [_display.win_map]
2288 clevermous 2042
; Now eax=x, ebx=y, edi->output, ebp=offset in WinMapAddress
2043
; 2) Calculate offset in background memory block
2044
        push    eax
2045
        xor     edx, edx
2046
        mov     eax, ebx
2047
        div     dword [BgrDataHeight]   ; edx := y mod BgrDataHeight
2048
        pop     eax
2049
        push    eax
2050
        mov     ecx, [BgrDataWidth]
2051
        mov     esi, edx
2052
        imul    esi, ecx                ; esi := (y mod BgrDataHeight) * BgrDataWidth
2053
        xor     edx, edx
2054
        div     ecx             ; edx := x mod BgrDataWidth
2055
        sub     ecx, edx
2056
        add     esi, edx        ; esi := (y mod BgrDataHeight)*BgrDataWidth + (x mod BgrDataWidth)
2057
        pop     eax
2058
        lea     esi, [esi*3]
2059
        add     esi, [img_background]
2060
        xor     edx, edx
2061
        inc     edx
2062
; 3) Loop through redraw rectangle and copy background data
2063
; Registers meaning:
2064
; eax = x, ebx = y (screen coordinates)
2065
; ecx = deltax - number of pixels left in current tile block
2066
; edx = 1
2067
; esi -> bgr memory, edi -> output
2068
; ebp = offset in WinMapAddress
5154 hidnplayr 2069
  dp3:
2288 clevermous 2070
        cmp     [ebp], dl
5154 hidnplayr 2071
        jnz     .next_pix
2072
 
2430 mario79 2073
        push    eax ecx
2074
        mov     ecx, eax
2075
        shl     ecx, 16
2076
        add     ecx, ebx
2077
 
2078
        mov     eax, [esi]
2448 mario79 2079
 
2080
; check for hardware cursor
2451 mario79 2081
        cmp     [_display.select_cursor], select_cursor
2082
        je      @f
2448 mario79 2083
        cmp     [_display.select_cursor], 0
2084
        jne     .no_mouseunder
5154 hidnplayr 2085
  @@:
2430 mario79 2086
        and     eax, 0xffffff
2087
; check mouse area for putpixel
2088
        call    [_display.check_mouse]
5154 hidnplayr 2089
  .no_mouseunder:
2090
 
2091
        cmp     byte [_display.bits_per_pixel], 16
2092
        je      .16bpp
2093
; store to LFB
2430 mario79 2094
        mov     [edi], ax
2095
        shr     eax, 16
2096
        mov     [edi+2], al
5154 hidnplayr 2097
        pop     ecx eax
2098
        jmp     .next_pix
2430 mario79 2099
 
5154 hidnplayr 2100
  .16bpp:
2101
; convert to 16 bpp and store to LFB
2102
        and     eax, 00000000111110001111110011111000b
2103
        shr     ah, 2
2104
        shr     ax, 3
2105
        ror     eax, 8
2106
        add     al, ah
2107
        rol     eax, 8
2108
        mov     [edi], ax
2430 mario79 2109
        pop     ecx eax
5154 hidnplayr 2110
 
2111
; Advance to next pixel
2112
  .next_pix:
2288 clevermous 2113
        add     esi, 3
5154 hidnplayr 2114
        add     edi, [_display.bytes_per_pixel]
2115
 
2288 clevermous 2116
        add     ebp, edx
2117
        add     eax, edx
2118
        cmp     eax, [draw_data+32+RECT.right]
2119
        ja      dp4
2120
        sub     ecx, edx
2121
        jnz     dp3
5154 hidnplayr 2122
 
2288 clevermous 2123
; next tile block on x-axis
2124
        mov     ecx, [BgrDataWidth]
2125
        sub     esi, ecx
2126
        sub     esi, ecx
2127
        sub     esi, ecx
2128
        jmp     dp3
5154 hidnplayr 2129
 
2130
  dp4:
2288 clevermous 2131
; next scan line
2132
        inc     ebx
2133
        cmp     ebx, [draw_data+32+RECT.bottom]
2134
        jbe     dp2
2135
        popad
2136
        mov     [EGA_counter], 1
3606 Serge 2137
        cmp     [SCR_MODE], 0x12
2436 mario79 2138
        jne     @f
2288 clevermous 2139
        call    VGA_drawbackground
5154 hidnplayr 2140
  @@:
2288 clevermous 2141
        ret
5154 hidnplayr 2142
 
2430 mario79 2143
;------------------------------------------------------------------------------
5154 hidnplayr 2144
 
2430 mario79 2145
align 4
2288 clevermous 2146
vesa20_drawbackground_stretch:
5154 hidnplayr 2147
 
2288 clevermous 2148
        pushad
2149
; Helper variables
2150
; calculate 2^32*(BgrDataWidth-1) mod (ScreenWidth-1)
2151
        mov     eax, [BgrDataWidth]
2152
        dec     eax
2153
        xor     edx, edx
6593 serge 2154
        div     dword [_display.width]
2288 clevermous 2155
        push    eax     ; high
2156
        xor     eax, eax
6593 serge 2157
        div     dword [_display.width]
2288 clevermous 2158
        push    eax     ; low
5154 hidnplayr 2159
 
2288 clevermous 2160
; the same for height
2161
        mov     eax, [BgrDataHeight]
2162
        dec     eax
2163
        xor     edx, edx
6593 serge 2164
        div     dword [_display.height]
2288 clevermous 2165
        push    eax     ; high
2166
        xor     eax, eax
6593 serge 2167
        div     dword [_display.height]
2288 clevermous 2168
        push    eax     ; low
5154 hidnplayr 2169
 
2288 clevermous 2170
; External loop for all y from start to end
2171
        mov     ebx, [draw_data+32+RECT.top]    ; y start
2172
        mov     ebp, [draw_data+32+RECT.left]   ; x start
2173
; 1) Calculate pointers in WinMapAddress (does pixel belong to OS thread?) [ebp]
2174
;                       and LFB data (output for our function) [edi]
2446 mario79 2175
;        mov     eax, [BytesPerScanLine]
2176
;        mul     ebx
2480 mario79 2177
        mov     eax, [BPSLine_calc_area+ebx*4]
2288 clevermous 2178
        xchg    ebp, eax
2179
        add     ebp, eax
2180
        add     ebp, eax
5154 hidnplayr 2181
        cmp     byte [_display.bytes_per_pixel], 2
2182
        jz      @f
2288 clevermous 2183
        add     ebp, eax
5154 hidnplayr 2184
        cmp     byte [_display.bytes_per_pixel], 3
2288 clevermous 2185
        jz      @f
2186
        add     ebp, eax
5154 hidnplayr 2187
  @@:
2188
 
2288 clevermous 2189
; ebp:=Y*BytesPerScanLine+X*BytesPerPixel+AddrLFB
2190
        call    calculate_edi
2191
        xchg    edi, ebp
5154 hidnplayr 2192
 
2288 clevermous 2193
; Now eax=x, ebx=y, edi->output, ebp=offset in WinMapAddress
2194
        push    ebx
2195
        push    eax
2196
; 2) Calculate offset in background memory block
2197
        mov     eax, ebx
2198
        imul    ebx, dword [esp+12]
2199
        mul     dword [esp+8]
2200
        add     edx, ebx        ; edx:eax = y * 2^32*(BgrDataHeight-1)/(ScreenHeight-1)
2201
        mov     esi, edx
2202
        imul    esi, [BgrDataWidth]
2203
        push    edx
2204
        push    eax
2205
        mov     eax, [esp+8]
2206
        mul     dword [esp+28]
2207
        push    eax
2208
        mov     eax, [esp+12]
2209
        mul     dword [esp+28]
2210
        add     [esp], edx
2211
        pop     edx             ; edx:eax = x * 2^32*(BgrDataWidth-1)/(ScreenWidth-1)
2212
        add     esi, edx
2213
        lea     esi, [esi*3]
2214
        add     esi, [img_background]
2215
        push    eax
2216
        push    edx
2217
        push    esi
5154 hidnplayr 2218
 
2288 clevermous 2219
; 3) Smooth horizontal
5154 hidnplayr 2220
  bgr_resmooth0:
2288 clevermous 2221
        mov     ecx, [esp+8]
2222
        mov     edx, [esp+4]
2223
        mov     esi, [esp]
2224
        push    edi
2225
        mov     edi, bgr_cur_line
2226
        call    smooth_line
5154 hidnplayr 2227
 
2228
  bgr_resmooth1:
2288 clevermous 2229
        mov     eax, [esp+16+4]
2230
        inc     eax
2231
        cmp     eax, [BgrDataHeight]
2232
        jae     bgr.no2nd
2233
        mov     ecx, [esp+8+4]
2234
        mov     edx, [esp+4+4]
2235
        mov     esi, [esp+4]
2236
        add     esi, [BgrDataWidth]
2237
        add     esi, [BgrDataWidth]
2238
        add     esi, [BgrDataWidth]
2239
        mov     edi, bgr_next_line
2240
        call    smooth_line
5154 hidnplayr 2241
 
2242
  bgr.no2nd:
2288 clevermous 2243
        pop     edi
5154 hidnplayr 2244
 
2245
  sdp3:
2288 clevermous 2246
        xor     esi, esi
2247
        mov     ecx, [esp+12]
5154 hidnplayr 2248
 
2288 clevermous 2249
; 4) Loop through redraw rectangle and copy background data
2250
; Registers meaning:
2251
; esi = offset in current line, edi -> output
2252
; ebp = offset in WinMapAddress
2253
; dword [esp] = offset in bgr data
2254
; qword [esp+4] = x * 2^32 * (BgrDataWidth-1) / (ScreenWidth-1)
2255
; qword [esp+12] = y * 2^32 * (BgrDataHeight-1) / (ScreenHeight-1)
2256
; dword [esp+20] = x
2257
; dword [esp+24] = y
2258
; precalculated constants:
2259
; qword [esp+28] = 2^32*(BgrDataHeight-1)/(ScreenHeight-1)
2260
; qword [esp+36] = 2^32*(BgrDataWidth-1)/(ScreenWidth-1)
5154 hidnplayr 2261
 
2262
  sdp3a:
5351 serge 2263
        mov     eax, [_display.win_map]
2288 clevermous 2264
        cmp     [ebp+eax], byte 1
2265
        jnz     snbgp
2266
        mov     eax, [bgr_cur_line+esi]
2267
        test    ecx, ecx
2268
        jz      .novert
2269
        mov     ebx, [bgr_next_line+esi]
2270
        call    [overlapping_of_points_ptr]
5154 hidnplayr 2271
 
2272
  .novert:
2430 mario79 2273
        push    ecx
2448 mario79 2274
; check for hardware cursor
2451 mario79 2275
        cmp     [_display.select_cursor], select_cursor
2459 mario79 2276
        je      @f
2448 mario79 2277
        cmp     [_display.select_cursor], 0
2278
        jne     .no_mouseunder
5154 hidnplayr 2279
  @@:
2430 mario79 2280
        mov     ecx, [esp+20+4]        ;x
2281
        shl     ecx, 16
2282
        add     ecx, [esp+24+4]        ;y
2283
; check mouse area for putpixel
2284
        call    [_display.check_mouse]
5154 hidnplayr 2285
  .no_mouseunder:
2286
 
2287
        cmp     [_display.bits_per_pixel], 16
2288
        jne     .not_16bpp
2289
; convert to 16 bpp and store to LFB
2290
        and     eax, 00000000111110001111110011111000b
2291
        shr     ah, 2
2292
        shr     ax, 3
2293
        ror     eax, 8
2294
        add     al, ah
2295
        rol     eax, 8
2288 clevermous 2296
        mov     [LFB_BASE+edi], ax
5154 hidnplayr 2297
        pop     ecx
2298
        jmp     snbgp
2299
  .not_16bpp:
2300
 
2301
; store to LFB
2302
        mov     [LFB_BASE+edi], ax
2288 clevermous 2303
        shr     eax, 16
2304
        mov     [LFB_BASE+edi+2], al
2430 mario79 2305
        pop     ecx
5154 hidnplayr 2306
 
2307
  snbgp:
2308
        add     edi, [_display.bytes_per_pixel]
2288 clevermous 2309
        add     ebp, 1
2310
        mov     eax, [esp+20]
2311
        add     eax, 1
2312
        mov     [esp+20], eax
2313
        add     esi, 4
2314
        cmp     eax, [draw_data+32+RECT.right]
2315
        jbe     sdp3a
5154 hidnplayr 2316
 
2317
  sdp4:
2288 clevermous 2318
; next y
2319
        mov     ebx, [esp+24]
2320
        add     ebx, 1
2321
        mov     [esp+24], ebx
2322
        cmp     ebx, [draw_data+32+RECT.bottom]
2323
        ja      sdpdone
5154 hidnplayr 2324
 
2288 clevermous 2325
; advance edi, ebp to next scan line
2326
        sub     eax, [draw_data+32+RECT.left]
2327
        sub     ebp, eax
5350 serge 2328
        add     ebp, [_display.width]
2288 clevermous 2329
        sub     edi, eax
2330
        sub     edi, eax
5154 hidnplayr 2331
        cmp     byte [_display.bytes_per_pixel], 2
2332
        jz      @f
2288 clevermous 2333
        sub     edi, eax
5154 hidnplayr 2334
        cmp     byte [_display.bytes_per_pixel], 3
2288 clevermous 2335
        jz      @f
2336
        sub     edi, eax
5154 hidnplayr 2337
 
2338
  @@:
5351 serge 2339
        add     edi, [_display.lfb_pitch]
2288 clevermous 2340
; restore ecx,edx; advance esi to next background line
2341
        mov     eax, [esp+28]
2342
        mov     ebx, [esp+32]
2343
        add     [esp+12], eax
2344
        mov     eax, [esp+16]
2345
        adc     [esp+16], ebx
2346
        sub     eax, [esp+16]
2347
        mov     ebx, eax
2348
        lea     eax, [eax*3]
2349
        imul    eax, [BgrDataWidth]
2350
        sub     [esp], eax
2351
        mov     eax, [draw_data+32+RECT.left]
2352
        mov     [esp+20], eax
2353
        test    ebx, ebx
2354
        jz      sdp3
2355
        cmp     ebx, -1
2356
        jnz     bgr_resmooth0
2357
        push    edi
2358
        mov     esi, bgr_next_line
2359
        mov     edi, bgr_cur_line
5350 serge 2360
        mov     ecx, [_display.width]
2288 clevermous 2361
        rep movsd
2362
        jmp     bgr_resmooth1
5154 hidnplayr 2363
 
2364
  sdpdone:
2288 clevermous 2365
        add     esp, 44
2366
        popad
2367
        mov     [EGA_counter], 1
3606 Serge 2368
        cmp     [SCR_MODE], 0x12
2436 mario79 2369
        jne     @f
2288 clevermous 2370
        call    VGA_drawbackground
5154 hidnplayr 2371
  @@:
2288 clevermous 2372
        ret
2373
 
2430 mario79 2374
;--------------------------------------
5154 hidnplayr 2375
 
2288 clevermous 2376
align 4
2377
smooth_line:
2378
        mov     al, [esi+2]
2379
        shl     eax, 16
2380
        mov     ax, [esi]
2381
        test    ecx, ecx
2382
        jz      @f
2383
        mov     ebx, [esi+2]
2384
        shr     ebx, 8
2385
        call    [overlapping_of_points_ptr]
5154 hidnplayr 2386
  @@:
2288 clevermous 2387
        stosd
2388
        mov     eax, [esp+20+8]
2389
        add     eax, 1
2390
        mov     [esp+20+8], eax
2391
        cmp     eax, [draw_data+32+RECT.right]
2392
        ja      @f
2393
        add     ecx, [esp+36+8]
2394
        mov     eax, edx
2395
        adc     edx, [esp+40+8]
2396
        sub     eax, edx
2397
        lea     eax, [eax*3]
2398
        sub     esi, eax
2399
        jmp     smooth_line
5154 hidnplayr 2400
  @@:
2288 clevermous 2401
        mov     eax, [draw_data+32+RECT.left]
2402
        mov     [esp+20+8], eax
2403
        ret
5154 hidnplayr 2404
 
2430 mario79 2405
;------------------------------------------------------------------------------
5154 hidnplayr 2406
 
2288 clevermous 2407
align 16
2408
overlapping_of_points:
2409
if 0
2410
; this version of procedure works, but is slower than next version
2411
        push    ecx edx
2412
        mov     edx, eax
2413
        push    esi
2414
        shr     ecx, 24
2415
        mov     esi, ecx
2416
        mov     ecx, ebx
2417
        movzx   ebx, dl
2418
        movzx   eax, cl
2419
        sub     eax, ebx
2420
        movzx   ebx, dh
2421
        imul    eax, esi
2422
        add     dl, ah
2423
        movzx   eax, ch
2424
        sub     eax, ebx
2425
        imul    eax, esi
2426
        add     dh, ah
2427
        ror     ecx, 16
2428
        ror     edx, 16
2429
        movzx   eax, cl
2430
        movzx   ebx, dl
2431
        sub     eax, ebx
2432
        imul    eax, esi
2433
        pop     esi
2434
        add     dl, ah
2435
        mov     eax, edx
2436
        pop     edx
2437
        ror     eax, 16
2438
        pop     ecx
2439
        ret
2440
else
2441
        push    ecx edx
2442
        mov     edx, eax
2443
        push    esi
2444
        shr     ecx, 26
2445
        mov     esi, ecx
2446
        mov     ecx, ebx
2447
        shl     esi, 9
2448
        movzx   ebx, dl
2449
        movzx   eax, cl
2450
        sub     eax, ebx
2451
        movzx   ebx, dh
2452
        add     dl, [BgrAuxTable+(eax+0x100)+esi]
2453
        movzx   eax, ch
2454
        sub     eax, ebx
2455
        add     dh, [BgrAuxTable+(eax+0x100)+esi]
2456
        ror     ecx, 16
2457
        ror     edx, 16
2458
        movzx   eax, cl
2459
        movzx   ebx, dl
2460
        sub     eax, ebx
2461
        add     dl, [BgrAuxTable+(eax+0x100)+esi]
2462
        pop     esi
2463
        mov     eax, edx
2464
        pop     edx
2465
        ror     eax, 16
2466
        pop     ecx
2467
        ret
2468
end if
2469
 
5154 hidnplayr 2470
 
2430 mario79 2471
;------------------------------------------------------------------------------
5154 hidnplayr 2472
 
2430 mario79 2473
align 4
2288 clevermous 2474
init_background:
5154 hidnplayr 2475
 
2288 clevermous 2476
        mov     edi, BgrAuxTable
2477
        xor     edx, edx
5154 hidnplayr 2478
 
2479
  .loop2:
2288 clevermous 2480
        mov     eax, edx
2481
        shl     eax, 8
2482
        neg     eax
2483
        mov     ecx, 0x200
5154 hidnplayr 2484
 
2485
  .loop1:
2288 clevermous 2486
        mov     byte [edi], ah
2487
        inc     edi
2488
        add     eax, edx
2489
        loop    .loop1
2490
        add     dl, 4
2491
        jnz     .loop2
2492
        test    byte [cpu_caps+(CAPS_MMX/8)], 1 shl (CAPS_MMX mod 8)
2493
        jz      @f
2494
        mov     [overlapping_of_points_ptr], overlapping_of_points_mmx
5154 hidnplayr 2495
  @@:
2288 clevermous 2496
        ret
5154 hidnplayr 2497
 
2430 mario79 2498
;------------------------------------------------------------------------------
5154 hidnplayr 2499
 
2288 clevermous 2500
align 16
2501
overlapping_of_points_mmx:
5154 hidnplayr 2502
 
2288 clevermous 2503
        movd    mm0, eax
2504
        movd    mm4, eax
2505
        movd    mm1, ebx
2506
        pxor    mm2, mm2
2507
        punpcklbw mm0, mm2
2508
        punpcklbw mm1, mm2
2509
        psubw   mm1, mm0
2510
        movd    mm3, ecx
2511
        psrld   mm3, 24
2512
        packuswb mm3, mm3
2513
        packuswb mm3, mm3
2514
        pmullw  mm1, mm3
2515
        psrlw   mm1, 8
2516
        packuswb mm1, mm2
2517
        paddb   mm4, mm1
2518
        movd    eax, mm4
5154 hidnplayr 2519
 
2288 clevermous 2520
        ret
5154 hidnplayr 2521
 
2430 mario79 2522
;------------------------------------------------------------------------------