Subversion Repositories Kolibri OS

Rev

Rev 9948 | Details | Compare with Previous | Last modification | View Log | RSS feed

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