Subversion Repositories Kolibri OS

Rev

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

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