Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
425 victor 1
$Revision: 431 $
431 serge 2
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3
;;                                                              ;;
4
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
5
;; Distributed under terms of the GNU General Public License    ;;
6
;;                                                              ;;
7
;;  VESA12.INC                                                  ;;
8
;;                                                              ;;
9
;;  Vesa 1.2 functions for MenuetOS                             ;;
10
;;                                                              ;;
11
;;  Copyright 2002 Ville Turjanmaa                              ;;
12
;;                                                              ;;
13
;;  quickcode@mail.ru - bankswitch for S3 cards                 ;;
14
;;                                                              ;;
15
;;  See file COPYING for details                                ;;
16
;;                                                              ;;
17
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1 ha 18
 
19
 
20
; A complete video driver should include the following types of function
21
;
22
; Putpixel
23
; Getpixel
24
;
25
; Drawimage
26
; Drawbar
27
;
28
; Drawbackground
29
;
30
;
31
; Modifying the set_bank -function is mostly enough
32
; for different Vesa 1.2 setups.
33
 
5 halyavin 34
;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
35
; set_bank for Trident videocards, work on Trident 9440
36
; modified by Mario79
37
;set_bank:
38
;cli
381 serge 39
;cmp al,[BANK_RW]
5 halyavin 40
;je retsb
381 serge 41
;mov [BANK_RW],al
5 halyavin 42
;push dx
43
;mov dx,3D8h
44
;out  dx,al
45
;pop dx
46
;retsb:
47
;sti
48
;ret
1 ha 49
 
5 halyavin 50
 
51
;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
52
; set_bank for S3 videocards, work on S3 ViRGE PCI (325)
379 serge 53
; modified by kmeaw
54
set_bank:
102 poddubny 55
pushfd
379 serge 56
cli
381 serge 57
cmp al,[BANK_RW]
379 serge 58
je retsb
381 serge 59
mov [BANK_RW],al
379 serge 60
push ax
61
push dx
62
push cx
63
mov cl, al
64
mov dx, 0x3D4
65
mov al, 0x38
1 ha 66
out dx, al     ;CR38 Register Lock 1 ;Note: Traditionally 48h is used to
67
               ;unlock and 00h to lock
379 serge 68
inc dx
69
mov al, 0x48
1 ha 70
out dx, al     ;3d5 -?
379 serge 71
dec dx
72
mov al, 0x31
1 ha 73
out dx, al     ;CR31 Memory Configuration Register
74
;0  Enable Base Address Offset (CPUA BASE). Enables bank operation if set, ;disables if clear.
75
;4-5  Bit 16-17 of the Display Start Address. For the 801/5,928 see index 51h,
76
;for the 864/964 see index 69h.
77
 
379 serge 78
inc dx
79
in al, dx
80
dec dx
81
mov ah, al
82
mov al, 0x31
83
out dx, ax
84
mov al, ah
85
or al, 9
86
inc dx
87
out dx, al
88
dec dx
89
mov al, 0x35
1 ha 90
out dx, al   ;CR35 CRT Register Lock
379 serge 91
inc dx
92
in al, dx
93
dec dx
94
and al, 0xF0
95
mov ch, cl
96
and ch, 0x0F
97
or ch, al
98
mov al, 0x35
99
out dx, al
100
inc dx
101
mov al, ch
102
out dx, ax
103
dec dx
1 ha 104
mov al, 0x51  ;Extended System Control 2 Register
379 serge 105
out dx, al
106
inc dx
107
in al, dx
108
dec dx
109
and al, 0xF3
110
shr cl, 2
111
and cl, 0x0C
112
or cl, al
113
mov al, 0x51
114
out dx, al
115
inc dx
116
mov al, cl
117
out dx, al
118
dec dx
119
mov al, 0x38
120
out dx, al
121
inc dx
122
xor al, al
123
out dx, al
124
dec dx
125
pop cx
126
pop dx
127
pop ax
128
retsb:
102 poddubny 129
popfd
1 ha 130
ret
131
 
132
;Set bank function for Intel 810/815 chipsets
133
; *****Modified by Protopopius, Russia.*****
134
; ********* http://menuetos.hut.ru **************
135
; ************************************************
136
;
137
;set_bank:
138
;cli
381 serge 139
;cmp al,[BANK_RW]
1 ha 140
;je retsb
381 serge 141
;mov [BANK_RW],al
1 ha 142
;push ax
143
;push dx
144
;mov dx,3CEh
145
;mov ah,al            ; Save value for later use
146
;mov al,10h           ; Index GR10 (Address Mapping)
147
;out dx,al            ; Select GR10
148
;inc dl
149
;mov al,3             ; Set bits 0 and 1 (Enable linear page mapping)
150
;out dx,al            ; Write value
151
;dec dl
152
;mov al,11h           ; Index GR11 (Page Selector)
153
;out dx,al            ; Select GR11
154
;inc dl
155
;mov al,ah            ; Write address
156
;out dx,al            ; Write the value
157
;pop dx
158
;pop ax
159
;retsb:
160
;sti
161
;ret
162
 
163
;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!}
164
 
165
;set_bank:
166
;   cli
381 serge 167
;   cmp al,[BANK_RW]
1 ha 168
;   je retsb
381 serge 169
;   mov [BANK_RW],al
1 ha 170
;   push ax
171
;   push dx
172
;   mov ah,al
173
;   mov dx,0x03D4
174
;   mov al,0x39
175
;   out dx,al
176
;   inc dl
177
;   mov al,0xA5
178
;   out dx,al
179
;   dec dl
180
;   mov al,6Ah
181
;   out dx,al
182
;   inc dl
183
;   mov al,ah
184
;   out dx,al
185
;   dec dl
186
;   mov al,0x39
187
;   out dx,al
188
;   inc dl
189
;   mov al,0x5A
190
;   out dx,al
191
;   dec dl
192
;   pop dx
193
;   pop ax
194
;
195
; retsb:
196
;   ret
197
 
198
 
199
vesa12_drawbackground:
200
 
201
        call  [disable_mouse]
202
 
203
        push  eax
204
        push  ebx
205
        push  ecx
206
        push  edx
207
 
208
        xor   edx,edx
209
        mov   eax,dword[WinMapAddress-8]
210
        mov   ebx,dword[WinMapAddress-4]
211
        mul   ebx
212
        mov   ebx,3
213
        mul   ebx
214
        mov   [imax],eax
115 poddubny 215
        mov   eax,[draw_data+32+RECT.left]
216
        mov   ebx,[draw_data+32+RECT.top]
1 ha 217
        mov   edi,0 ;no force
218
 
219
      v12dp3:
220
 
221
        push  eax
222
        push  ebx
381 serge 223
        mov   esi,IMG_BACKGROUND
1 ha 224
 
225
        cmp   [WinMapAddress-12],dword 1     ; tiled background
226
        jne   no_vesa12_tiled_bgr
227
 
228
        push  edx
229
 
230
        xor   edx,edx
231
        mov   ecx,[WinMapAddress-8]
232
        div   ecx
233
        mov   eax,edx
234
 
235
        push  eax
236
        mov   eax,ebx
237
        xor   edx,edx
238
        mov   ecx,[WinMapAddress-4]
239
        div   ecx
240
        mov   ebx,edx
241
        pop   eax
242
 
243
        pop   edx
244
 
245
      no_vesa12_tiled_bgr:
246
 
247
        cmp   [WinMapAddress-12],dword 2     ; stretched background
248
        jne   no_vesa12_stretched_bgr
249
 
250
        push  edx
251
 
252
        imul  eax,dword [WinMapAddress-8]
253
        xor   edx,edx
381 serge 254
        mov   ecx,[ScreenWidth]
1 ha 255
        inc   ecx
256
        div   ecx
257
 
258
        push  eax
259
        mov   eax,ebx
260
        imul  eax,dword [WinMapAddress-4]
261
        xor   edx,edx
381 serge 262
        mov   ecx,[ScreenHeight]
1 ha 263
        inc   ecx
264
        div   ecx
265
        mov   ebx,eax
266
        pop   eax
267
 
268
        pop   edx
269
 
270
      no_vesa12_stretched_bgr:
271
 
272
 
273
        push  eax
274
        mov   eax,ebx
275
        xor   edx,edx
276
        mov   ebx,[WinMapAddress-8]
277
        add   ebx,[WinMapAddress-8]
278
        add   ebx,[WinMapAddress-8]
279
        mul   ebx
280
        mov   esi,eax
281
        pop   eax
282
        add   esi,eax
283
        add   esi,eax
284
        add   esi,eax
381 serge 285
        add   esi,IMG_BACKGROUND
1 ha 286
        pop   ebx
287
        pop   eax
288
 
289
      v12di4:
290
 
291
        mov   ecx,[esi]
292
        pusha
293
        mov   esi,eax
294
        mov   edi,ebx
381 serge 295
        mov   eax,[ScreenWidth]
1 ha 296
        add   eax,1
297
        mul   ebx
298
        add   eax,esi
299
        add   eax,WinMapAddress
300
        cmp   [eax],byte 1
301
        jnz   v12nbgp
381 serge 302
        mov   eax,[BytesPerScanLine]
1 ha 303
        mov   ebx,edi
304
        mul   ebx
305
        add   eax,esi
306
        add   eax,esi
307
        add   eax,esi
381 serge 308
        cmp   [ScreenBPP],byte 24
1 ha 309
        jz    v12bgl3
310
        add   eax,esi
311
 
312
      v12bgl3:
313
 
314
        push ebx
315
        push eax
316
 
381 serge 317
        sub  eax,[LFBAddress]
1 ha 318
 
319
        shr  eax,16
320
        call set_bank
321
        pop  eax
322
        and  eax,65535
381 serge 323
        add  eax,VGABasePtr
1 ha 324
        pop  ebx
325
 
326
        mov   [eax],cx
327
        add   eax,2
328
        shr   ecx,16
329
        mov   [eax],cl
330
        sti
331
 
332
      v12nbgp:
333
 
334
        popa
335
        add   esi,3
336
        inc   eax
115 poddubny 337
        cmp   eax,[draw_data+32+RECT.right]
1 ha 338
        jg    v12nodp31
339
        jmp   v12dp3
340
 
341
      v12nodp31:
342
 
115 poddubny 343
        mov   eax,[draw_data+32+RECT.left]
1 ha 344
        inc   ebx
115 poddubny 345
        cmp   ebx,[draw_data+32+RECT.bottom]
1 ha 346
        jg    v12dp4
347
        jmp   v12dp3
348
 
349
      v12dp4:
350
 
351
        pop   edx
352
        pop   ecx
353
        pop   ebx
354
        pop   eax
355
        ret
356
 
357
 
358
vesa12_drawbar:
359
 
360
    call  [disable_mouse]
361
 
362
;;    mov  [novesachecksum],dword 0
363
    sub  edx,ebx
364
    sub  ecx,eax
365
    push esi
366
    push edi
367
    push eax
368
    push ebx
369
    push ecx
370
    push edx
379 serge 371
    mov  ecx,[TASK_BASE]
115 poddubny 372
    add  eax,[ecx-twdw+WDATA.box.left]
373
    add  ebx,[ecx-twdw+WDATA.box.top]
1 ha 374
    push eax
375
    mov  eax,ebx         ; y
381 serge 376
    mov  ebx,[BytesPerScanLine]
1 ha 377
    mul  ebx
378
    pop  ecx
379
    add  eax,ecx         ; x
380
    add  eax,ecx
381
    add  eax,ecx
381 serge 382
    cmp  [ScreenBPP],byte 24     ; 24 or 32 bpp ? - x start
1 ha 383
    jz   dbpi2412
384
    add  eax,ecx
385
 
386
  dbpi2412:
387
 
381 serge 388
    add  eax,[LFBAddress]
1 ha 389
    mov  edi,eax
390
 
391
    ; x size
392
 
393
    mov  eax,[esp+4] ; [esp+6]
394
    mov  ecx,eax
395
    add  ecx,eax
396
    add  ecx,eax
381 serge 397
    cmp  [ScreenBPP],byte 24     ; 24 or 32 bpp ? - x size
1 ha 398
    jz   dbpi24312
399
    add  ecx,eax
400
 
401
  dbpi24312:
402
 
403
    mov  ebx,[esp+0]
404
 
405
    ; check limits ?
406
 
407
    push eax
408
    push ecx
379 serge 409
    mov  eax,[TASK_BASE]
410
    mov  ecx,[eax+draw_data-CURRENT_TASK+RECT.left]
1 ha 411
    cmp  ecx,0
412
    jnz  dbcblimitlset12
379 serge 413
    mov  ecx,[eax+draw_data-CURRENT_TASK+RECT.top]
1 ha 414
    cmp  ecx,0
415
    jnz  dbcblimitlset12
379 serge 416
    mov  ecx,[eax+draw_data-CURRENT_TASK+RECT.right]
381 serge 417
    cmp  ecx,[ScreenWidth]
1 ha 418
    jnz  dbcblimitlset12
379 serge 419
    mov  ecx,[eax+draw_data-CURRENT_TASK+RECT.bottom]
381 serge 420
    cmp  ecx,[ScreenHeight]
1 ha 421
    jnz  dbcblimitlset12
422
    pop  ecx
423
    pop  eax
424
    push dword 0
425
    jmp  dbcblimitlno12
426
 
427
  dbcblimitlset12:
428
 
429
    pop  ecx
430
    pop  eax
431
    push dword 1
432
 
433
  dbcblimitlno12:
434
 
381 serge 435
    cmp  [ScreenBPP],byte 24     ; 24 or 32 bpp ?
1 ha 436
    jz   dbpi24bit12
437
    jmp  dbpi32bit12
438
 
439
 
440
; DRAWBAR 24 BBP
441
 
442
 
443
dbpi24bit12:
444
 
445
    push eax
446
    push ebx
447
    push edx
448
    mov  eax,ecx
449
    mov  ebx,3
450
    div  ebx
451
    mov  ecx,eax
452
    pop  edx
453
    pop  ebx
454
    pop  eax
455
    cld
456
 
457
  dbnewpi12:
458
 
459
    push ebx
460
    push edi
461
    push ecx
462
 
463
      xor  edx,edx
464
      mov  eax,edi
381 serge 465
      sub  eax,[LFBAddress]
1 ha 466
      mov  ebx,3
467
      div  ebx
468
      add  eax,WinMapAddress
379 serge 469
      mov   ebx,[CURRENT_TASK]
1 ha 470
      cld
471
 
472
      dbnp2412:
473
 
474
        mov  dl,[eax]
475
        push eax
476
        push ecx
477
        cmp  dl,bl
478
        jnz  dbimp24no12
479
        cmp  [esp+5*4],dword 0
480
        jz   dbimp24yes12
481
;        call dbcplimit
482
;        jnz  dbimp24no12
483
 
484
     dbimp24yes12:
485
 
486
        push edi
487
        mov  eax,edi
381 serge 488
        sub  eax,[LFBAddress]
1 ha 489
        shr  eax,16
490
        call set_bank
491
        and  edi,0xffff
381 serge 492
        add  edi,VGABasePtr
1 ha 493
        mov  eax,[esp+8+3*4+16+4+4]
494
        stosw
495
        shr  eax,16
496
        stosb
497
        sti
498
        pop  edi
499
        add  edi,3
500
        pop  ecx
501
        pop  eax
502
        inc  eax
503
        loop dbnp2412
504
        jmp  dbnp24d12
505
 
506
      dbimp24no12:
507
 
508
        pop  ecx
509
        pop  eax
510
        cld
511
        add  edi,3
512
        inc  eax
513
        loop dbnp2412
514
 
515
      dbnp24d12:
516
 
517
        mov  eax,[esp+3*4+16+4]
518
        test eax,0x80000000
519
        jz   nodbgl2412
520
        cmp  al,0
521
        jz   nodbgl2412
522
        dec  eax
523
        mov  [esp+3*4+16+4],eax
524
 
525
      nodbgl2412:
526
 
527
    pop  ecx
528
    pop  edi
529
    pop  ebx
381 serge 530
    add  edi,[BytesPerScanLine]
1 ha 531
    dec  ebx
532
    jz   dbnonewpi12
533
    jmp  dbnewpi12
534
 
535
  dbnonewpi12:
536
 
537
    add  esp,7*4
538
 
539
    ret
540
 
541
 
542
; DRAWBAR 32 BBP
543
 
544
 
545
  dbpi32bit12:
546
 
547
    cld
548
    shr  ecx,2
549
 
550
   dbnewpi3212:
551
 
552
    push ebx
553
    push edi
554
    push ecx
555
 
556
      mov  eax,edi
381 serge 557
      sub  eax,[LFBAddress]
1 ha 558
      shr  eax,2
559
      add  eax,WinMapAddress
379 serge 560
      mov   ebx,[CURRENT_TASK]
1 ha 561
      cld
562
 
563
      dbnp3212:
564
 
565
        mov  dl,[eax]
566
        push eax
567
        push ecx
568
        cmp  dl,bl
569
        jnz  dbimp32no12
570
        cmp  [esp+5*4],dword 0
571
        jz   dbimp32yes12
572
;        call dbcplimit
573
;        jnz  dbimp32no12
574
 
575
      dbimp32yes12:
576
 
577
        push edi
578
        mov  eax,edi
381 serge 579
        sub  eax,[LFBAddress]
1 ha 580
        shr  eax,16
581
        call set_bank
582
        and  edi,0xffff
381 serge 583
        add  edi,VGABasePtr
1 ha 584
        mov  eax,[esp+8+3*4+16+4+4]
585
        stosw
586
        shr  eax,16
587
        stosb
588
        sti
589
        pop  edi
590
        add  edi,4
591
        inc  ebp
592
        pop  ecx
593
        pop  eax
594
        inc  eax
595
        loop dbnp3212
596
        jmp  dbnp32d12
597
 
598
      dbimp32no12:
599
 
600
        pop  ecx
601
        pop  eax
602
        inc  eax
603
        add  edi,4
604
        inc  ebp
605
        loop dbnp3212
606
 
607
      dbnp32d12:
608
 
609
        mov  eax,[esp+12+16+4]
610
        test eax,0x80000000
611
        jz   nodbgl3212
612
        cmp  al,0
613
        jz   nodbgl3212
614
        dec  eax
615
        mov  [esp+12+16+4],eax
616
 
617
      nodbgl3212:
618
 
619
    pop  ecx
620
    pop  edi
621
    pop  ebx
381 serge 622
    add  edi,[BytesPerScanLine]
1 ha 623
    dec  ebx
624
    jz   nodbnewpi3212
625
    jmp  dbnewpi3212
626
 
627
  nodbnewpi3212:
628
 
629
    add  esp,7*4
630
    ret
631
 
632
 
633
Vesa12_putpixel24:
634
 
635
        mov  edi,eax ; x
636
        mov  eax,ebx ; y
637
        lea  edi,[edi+edi*2]
381 serge 638
        mov  ebx,[BytesPerScanLine]
1 ha 639
        mul  ebx
640
        add  edi,eax
641
        mov  eax,edi
642
        shr  eax,16
643
        call set_bank
644
        and  edi,65535
381 serge 645
        add  edi,VGABasePtr
1 ha 646
        mov  eax,[esp+28]
647
        stosw
648
        shr  eax,16
649
        mov  [edi],al
650
        sti
651
        ret
652
 
653
 
654
 
655
Vesa12_putpixel32:
656
 
657
        mov  edi,eax ; x
658
        mov  eax,ebx ; y
659
        shl  edi,2
381 serge 660
        mov  ebx,[BytesPerScanLine]
1 ha 661
        mul  ebx
662
        add  edi,eax
663
        mov  eax,edi
664
        shr  eax,16
665
        call set_bank
666
        and  edi,65535
381 serge 667
        add  edi,VGABasePtr
1 ha 668
        mov  ecx,[esp+28]
669
        mov  [edi],ecx
670
        sti
671
        ret
672
 
673
 
674
Vesa12_getpixel24:
675
 
676
        mov  edi,eax ; x
677
        mov  eax,ebx ; y
678
        lea  edi,[edi+edi*2]
381 serge 679
        mov  ebx,[BytesPerScanLine]
1 ha 680
        mul  ebx
681
        add  edi,eax
682
        mov  eax,edi
683
        shr  eax,16
684
        call set_bank
685
        and  edi,65535
381 serge 686
        add  edi,VGABasePtr
1 ha 687
        mov  ecx,[edi]
688
        and  ecx,255*256*256+255*256+255
689
        sti
690
        ret
691
 
692
 
693
Vesa12_getpixel32:
694
 
695
        mov  edi,eax ; x
696
        mov  eax,ebx ; y
697
        shl  edi,2
381 serge 698
        mov  ebx,[BytesPerScanLine]
1 ha 699
        xor  edx,edx
700
        mul  ebx
701
        add  edi,eax
702
        mov  eax,edi
703
        shr  eax,16
704
        call set_bank
705
        and  edi,65535
381 serge 706
        add  edi,VGABasePtr
1 ha 707
        mov  ecx,[edi]
708
        and  ecx,255*256*256+255*256+255
709
        sti
710
 
711
        ret
712
 
713
 
714
 
715
vesa12_putimage:
283 diamond 716
; ebx = pointer to image
717
; ecx = size [x|y]
718
; edx = coordinates [x|y]
719
; ebp = pointer to 'get' function
720
; esi = pointer to 'init' function
721
; edi = parameter for 'get' function
1 ha 722
 
723
;    mov  ebx,image
724
;    mov  ecx,320*65536+240
725
;    mov  edx,20*65536+20
726
 
727
    call  [disable_mouse]
728
 
729
    mov   [novesachecksum],dword 0
730
    push  esi
731
    push  edi
732
    push  eax
733
    push  ebx
734
    push  ecx
735
    push  edx
736
    movzx eax,word [esp+2]
737
    movzx ebx,word [esp+0]
379 serge 738
    mov   ecx,[TASK_BASE]
115 poddubny 739
    add   eax,[ecx-twdw+WDATA.box.left]
740
    add   ebx,[ecx-twdw+WDATA.box.top]
1 ha 741
    push  eax
742
    mov   eax,ebx         ; y
381 serge 743
    mul   dword [BytesPerScanLine]
1 ha 744
    pop   ecx
745
    add   eax,ecx         ; x
746
    add   eax,ecx
747
    add   eax,ecx
381 serge 748
    cmp  [ScreenBPP],byte 24     ; 24 or 32 bpp ? - x start
1 ha 749
    jz   pi2412
750
    add  eax,ecx
751
 
752
  pi2412:
753
 
381 serge 754
    add  eax,[LFBAddress]
1 ha 755
    mov  edi,eax
756
 
757
    ; x size
758
 
283 diamond 759
    movzx ecx,word [esp+6]
1 ha 760
 
761
    mov   esi,[esp+8]
762
    movzx ebx,word [esp+4]
763
 
764
    ; check limits while draw ?
765
 
766
    push  ecx
379 serge 767
    mov  eax,[TASK_BASE]
768
    cmp  dword [eax+draw_data-CURRENT_TASK+RECT.left], 0
1 ha 769
    jnz  dbcblimitlset212
379 serge 770
    cmp  dword [eax+draw_data-CURRENT_TASK+RECT.top], 0
1 ha 771
    jnz  dbcblimitlset212
379 serge 772
    mov  ecx,[eax+draw_data-CURRENT_TASK+RECT.right]
381 serge 773
    cmp  ecx,[ScreenWidth]
1 ha 774
    jnz  dbcblimitlset212
379 serge 775
    mov  ecx,[eax+draw_data-CURRENT_TASK+RECT.bottom]
381 serge 776
    cmp  ecx,[ScreenHeight]
1 ha 777
    jnz  dbcblimitlset212
778
    pop  ecx
283 diamond 779
    push 0
1 ha 780
    jmp  dbcblimitlno212
781
 
782
  dbcblimitlset212:
783
 
784
    pop  ecx
283 diamond 785
    push 1
1 ha 786
 
787
  dbcblimitlno212:
788
 
381 serge 789
    cmp  [ScreenBPP],byte 24     ; 24 or 32 bpp ?
283 diamond 790
    jnz  pi32bit12
1 ha 791
 
792
  pi24bit12:
793
 
794
  newpi12:
795
 
796
    push edi
797
    push ecx
798
    push ebx
799
 
283 diamond 800
      mov  edx,edi
381 serge 801
      sub  edx,[LFBAddress]
1 ha 802
      mov  ebx,3
803
      div  ebx
283 diamond 804
      add  edx,WinMapAddress
379 serge 805
      mov  ebx,[CURRENT_TASK]
283 diamond 806
      mov  bh,[esp+4*3]
1 ha 807
 
808
      np2412:
809
 
283 diamond 810
        cmp  bl,[edx]
1 ha 811
        jnz  imp24no12
283 diamond 812
;        mov  eax,[esi]
813
        push    dword [esp+4*3+20]
814
        call    ebp
815
;        cmp  bh,0
816
;        jz   imp24yes12
1 ha 817
;        call dbcplimit
818
;        jnz  imp24no12
819
 
820
     imp24yes12:
821
 
283 diamond 822
        push edi
1 ha 823
        push eax
824
        mov  eax,edi
381 serge 825
        sub  eax,[LFBAddress]
1 ha 826
        shr  eax,16
827
        call set_bank
283 diamond 828
        pop  eax
1 ha 829
        and  edi,0xffff
381 serge 830
        add  edi,VGABasePtr
283 diamond 831
        mov  [edi],ax
832
        shr  eax,16
833
        mov  [edi+2],al
1 ha 834
        pop  edi
835
 
836
     imp24no12:
837
 
283 diamond 838
        inc  edx
839
;        add  esi,3
1 ha 840
        add  edi,3
841
        dec  ecx
842
        jnz  np2412
843
 
844
      np24d12:
845
 
846
     pop  ebx
847
     pop  ecx
848
     pop  edi
849
 
381 serge 850
    add  edi,[BytesPerScanLine]
314 diamond 851
    add  esi,[esp+32]
1 ha 852
    dec  ebx
283 diamond 853
    jnz  newpi12
1 ha 854
 
855
  nonewpi12:
856
 
283 diamond 857
        pop     eax edx ecx ebx eax edi esi
858
        xor     eax, eax
859
        ret
1 ha 860
 
861
 
862
  pi32bit12:
863
 
864
   newpi3212:
865
 
866
    push edi
867
    push ecx
868
    push ebx
869
 
283 diamond 870
      mov  edx,edi
381 serge 871
      sub  edx,[LFBAddress]
283 diamond 872
      shr  edx,2
873
      add  edx,WinMapAddress
379 serge 874
      mov   ebx,[CURRENT_TASK]
283 diamond 875
      mov   bh,[esp+4*3]
1 ha 876
 
877
      np3212:
878
 
283 diamond 879
        cmp  bl,[edx]
1 ha 880
        jnz  imp32no12
283 diamond 881
;        mov  eax,[esi]
882
        push    dword [esp+4*3+20]
883
        call    ebp
884
;        cmp  bh,0
885
;        jz   imp32yes12
1 ha 886
;        call dbcplimit
887
;        jnz  imp32no12
888
 
889
      imp32yes12:
890
 
283 diamond 891
        push edi
1 ha 892
        push eax
893
        mov  eax,edi
381 serge 894
        sub  eax,[LFBAddress]
1 ha 895
        shr  eax,16
896
        call set_bank
283 diamond 897
        pop  eax
1 ha 898
        and  edi,0xffff
381 serge 899
        mov  [edi+VGABasePtr],eax
1 ha 900
        pop  edi
901
 
902
      imp32no12:
903
 
283 diamond 904
        inc  edx
905
;        add  esi,3
1 ha 906
        add  edi,4
907
        dec  ecx
908
        jnz  np3212
909
 
910
      np32d12:
911
 
912
     pop  ebx
913
     pop  ecx
914
     pop  edi
915
 
381 serge 916
    add   edi,[BytesPerScanLine]
1 ha 917
    dec   ebx
283 diamond 918
    jnz   newpi3212
1 ha 919
 
920
  nonewpi3212:
921
 
283 diamond 922
        pop     eax edx ecx ebx eax edi esi
923
        xor     eax, eax
924
        ret
1 ha 925
 
926
 
927
vesa12_read_screen_pixel:
928
 
929
     and   eax,0x3FFFFF
381 serge 930
     cmp   [ScreenBPP],byte 24      ; 24 or 32 bpp ?
1 ha 931
     jz    v12rsp24
932
     mov   edi,eax
933
     shl   edi,2
934
     mov   eax,edi
935
     shr   eax,16
936
     call  set_bank
937
     and   edi,65535
381 serge 938
     add   edi,VGABasePtr
1 ha 939
     mov   eax,[edi]
940
     and   eax,0x00ffffff
941
     ret
942
  v12rsp24:
943
 
944
     imul  eax,3
945
     mov   edi,eax
946
     shr   eax,16
947
     call  set_bank
948
     and   edi,65535
381 serge 949
     add   edi,VGABasePtr
1 ha 950
     mov   eax,[edi]
951
     and   eax,0x00ffffff
952
     ret
953