Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
431 serge 1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                              ;;
3
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
4
;; Distributed under terms of the GNU General Public License    ;;
5
;;                                                              ;;
6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
214 serge 7
 
8
format MS COFF
9
 
10
include 'proc32.inc'
281 serge 11
include 'imports.inc'
214 serge 12
 
227 serge 13
DEBUG     equ 1
214 serge 14
 
15
VID_ATI     equ 0x1002
16
 
227 serge 17
LOAD_FROM_FILE  equ 0
18
LOAD_FROM_MEM   equ 1
19
LOAD_INDIRECT   equ 2
20
LOAD_SYSTEM     equ 3
21
 
233 serge 22
VIDEO_FREE      equ 2
23
 
227 serge 24
struc BITMAPINFOHEADER {
25
  .biSize          dd ? ; DWORD
26
  .biWidth         dd ? ; LONG
27
  .biHeight        dd ? ; LONG
28
  .biPlanes        dw ? ; WORD
29
  .biBitCount      dw ? ; WORD
30
  .biCompression   dd ? ; DWORD
31
  .biSizeImage     dd ? ; DWORD
32
  .biXPelsPerMeter dd ? ; LONG
33
  .biYPelsPerMeter dd ? ; LONG
34
  .biClrUsed       dd ? ; DWORD
35
  .biClrImportant  dd ? ; DWORD
36
}
37
 
38
virtual at 0
39
  BI BITMAPINFOHEADER
40
end virtual
41
 
42
struc CURSOR
281 serge 43
{;common object header
44
   .magic       dd ?   ;'CURS'
45
   .destroy     dd ?   ;internal destructor
46
   .fd          dd ?   ;next object in list
47
   .bk          dd ?   ;prev object in list
48
   .pid         dd ?   ;owner id
49
 
50
 ;cursor data
51
   .base        dd ?   ;allocated memory
52
   .hot_x       dd ?   ;hotspot coords
227 serge 53
   .hot_y       dd ?
54
}
55
virtual at 0
56
  CURSOR CURSOR
57
end virtual
58
 
281 serge 59
CURSOR_SIZE     equ 32
227 serge 60
 
214 serge 61
R8500       equ 0x514C  ;R200
62
R9000       equ 0x4966  ;RV250
63
R9200       equ 0x5961  ;RV280
64
R9500       equ 0x4144  ;R300
65
R9500P      equ 0x4E45  ;R300
66
R9550       equ 0x4153  ;RV350
67
R9600       equ 0x4150  ;RV350
68
R9600XT     equ 0x4152  ;RV360
69
R9700P      equ 0x4E44  ;R300
70
R9800       equ 0x4E49  ;R350
71
R9800P      equ 0x4E48  ;R350
72
R9800XT     equ 0x4E4A  ;R360
73
 
378 serge 74
OS_BASE         equ 0
75
new_app_base    equ 0x80000000
380 serge 76
SLOT_BASE       equ 0x0080000
214 serge 77
 
78
PG_SW        equ 0x003
79
PG_NOCACHE   equ 0x018
80
 
81
struc IOCTL
82
{  .handle           dd ?
83
   .io_code          dd ?
84
   .input            dd ?
85
   .inp_size         dd ?
86
   .output           dd ?
87
   .out_size         dd ?
88
}
89
 
90
virtual at 0
91
  IOCTL IOCTL
92
end virtual
93
 
378 serge 94
;MMIO                   equ 0F9000000h
95
RD_RB3D_CNTL            equ 1c3ch
214 serge 96
 
97
RD_MEM_CNTL                equ 0140h
98
RD_CRTC_GEN_CNTL           equ 0050h
99
RD_CRTC_CUR_EN             equ 10000h
100
RD_DISPLAY_BASE_ADDR       equ 023ch
101
RD_DEFAULT_OFFSET          equ 16e0h
102
CUR_HORZ_VERT_OFF          equ 0268h
103
CUR_HORZ_VERT_POSN         equ 0264h
104
CUR_OFFSET                 equ 0260h
105
RD_RB3D_CNTL               equ 1c3ch
106
RD_RBBM_STATUS             equ 0e40h
107
RD_RBBM_FIFOCNT_MASK       equ 007fh
108
RD_RBBM_ACTIVE             equ 80000000h
109
RD_TIMEOUT                 equ 2000000
110
 
111
RD_DP_GUI_MASTER_CNTL      equ 0146ch
112
RD_DP_BRUSH_BKGD_CLR       equ 01478h
113
RD_DP_BRUSH_FRGD_CLR       equ 0147ch
114
RD_DP_SRC_BKGD_CLR         equ 015dch
115
RD_DP_SRC_FRGD_CLR         equ 015d8h
116
RD_DP_CNTL                 equ 016c0h
117
RD_DP_DATATYPE             equ 016c4h
118
RD_DP_WRITE_MASK           equ 016cch
119
RD_DP_SRC_SOURCE_MEMORY    equ (2 shl 24)
120
RD_DP_SRC_SOURCE_HOST_DATA equ (3 shl 24)
121
RD_DEFAULT_SC_BOTTOM_RIGHT equ 16e8h
122
RD_GMC_BRUSH_SOLID_COLOR   equ (13 shl 4)
123
RD_DEFAULT_SC_RIGHT_MAX    equ 1fffh
124
RD_DEFAULT_SC_BOTTOM_MAX   equ 1fff0000h
125
RD_GMC_DST_DATATYPE_SHIFT  equ 8
126
 
127
RD_ROP3_S                  equ 00cc0000h
128
RD_ROP3_P                  equ 00f00000h
129
 
130
RD_RB2D_DSTCACHE_MODE      equ 03428h
131
RD_RB2D_DSTCACHE_CTLSTAT   equ 0342ch
132
RD_RB2D_DC_FLUSH_ALL       equ 000fh
133
RD_RB2D_DC_BUSY            equ 80000000h
134
 
135
RD_GMC_BRUSH_SOLID_COLOR   equ 000000D0h
136
RD_GMC_SRC_DATATYPE_COLOR  equ (3 shl 12)
137
RD_GMC_CLR_CMP_CNTL_DIS    equ (1 shl 28)
138
RD_GMC_WR_MSK_DIS          equ (1 shl 30)
139
 
140
cmdSolidFill               equ 73f036d0h
141
 
142
RD_DST_PITCH_OFFSET        equ 142ch
143
RD_SRC_PITCH_OFFSET        equ 1428h
144
 
145
RD_DST_X_LEFT_TO_RIGHT     equ 1
146
RD_DST_Y_TOP_TO_BOTTOM     equ 2
147
RD_DST_Y_X                 equ 1438h
148
RD_DST_WIDTH_HEIGHT        equ 1598h
149
RD_DST_LINE_START          equ 1600h
150
RD_DST_LINE_END            equ 1604h
151
R300_MEM_NUM_CHANNELS_MASK equ 0003h
152
 
153
macro rdr op1, op2
154
{
155
     mov edi, [ati_io]
156
     mov op1, [edi+op2]
157
}
158
 
159
macro wrr dest, src
160
{
161
     mov edi, [ati_io]
162
     mov dword [edi+dest], src
163
}
164
 
165
 
166
public START
167
public service_proc
227 serge 168
public version
214 serge 169
 
170
CURSOR_IMAGE_OFFSET  equ 0x00500000
171
 
172
DRV_ENTRY equ 1
173
DRV_EXIT  equ -1
174
 
175
section '.flat' code readable align 16
176
 
177
proc START stdcall, state:dword
178
 
227 serge 179
           cmp [state], 1
180
           jne .exit
181
 
214 serge 182
     if DEBUG
183
           mov esi, msgInit
184
           call SysMsgBoardStr
185
     end if
186
 
187
           call detect_ati
227 serge 188
           test eax, eax
214 serge 189
           jz .fail
190
 
191
           call init_ati
192
           test eax, eax
193
           jz .fail
194
 
281 serge 195
           or eax, -1
227 serge 196
           mov [cursor_map], eax
197
           mov [cursor_map+4], eax
198
           mov edx, cursor_map
199
           mov [cursor_start], edx
281 serge 200
           add edx, 8
227 serge 201
           mov [cursor_end], edx
202
 
214 serge 203
           stdcall RegService, sz_ati_srv, service_proc
204
           test eax, eax
205
           jz .fail
227 serge 206
           mov dword [SetHwCursor], drvCursorPos ;enable hardware cursor
207
           mov dword [HwCursorRestore], drv_restore
208
           mov dword [HwCursorCreate], ati_cursor
209
           ret
214 serge 210
.fail:
211
     if DEBUG
227 serge 212
           mov esi, msgFail
214 serge 213
           call SysMsgBoardStr
214
     end if
215
 
216
.exit:
217
           xor eax, eax
227 serge 218
;           mov ebx, SetHwCursor
219
;           mov dword [ebx], eax    ;force disable hardware cursor
214 serge 220
           ret
221
endp
222
 
223
handle     equ  IOCTL.handle
224
io_code    equ  IOCTL.io_code
225
input      equ  IOCTL.input
226
inp_size   equ  IOCTL.inp_size
227
output     equ  IOCTL.output
228
out_size   equ  IOCTL.out_size
229
 
230
align 4
231
proc service_proc stdcall, ioctl:dword
232
 
233 serge 233
           mov edi, [ioctl]
234
           mov ebx, [edi+io_code]
235
           cmp ebx, VIDEO_FREE
236
           jne .fail
214 serge 237
 
233 serge 238
           mov eax, [edi+input]
239
           call video_free
240
.fail:
378 serge 241
           or eax, -1
233 serge 242
           ret
214 serge 243
endp
244
 
245
restore   handle
246
restore   io_code
247
restore   input
248
restore   inp_size
249
restore   output
250
restore   out_size
251
 
252
align 4
253
proc detect_ati
227 serge 254
           locals
255
             last_bus dd ?
256
           endl
214 serge 257
 
227 serge 258
           xor eax, eax
259
           mov [bus], eax
260
           inc eax
214 serge 261
           call PciApi
227 serge 262
           cmp eax, -1
214 serge 263
           je .err
264
 
227 serge 265
           mov [last_bus], eax
214 serge 266
 
267
.next_bus:
227 serge 268
           and [devfn], 0
214 serge 269
.next_dev:
270
           stdcall PciRead32, [bus], [devfn], dword 0
227 serge 271
           test eax, eax
272
           jz .next
273
           cmp eax, -1
274
           je .next
214 serge 275
 
227 serge 276
           mov edi, devices
214 serge 277
@@:
227 serge 278
           mov ebx, [edi]
279
           test ebx, ebx
280
           jz .next
214 serge 281
 
227 serge 282
           cmp eax, ebx
283
           je .found
214 serge 284
           add edi, 4
227 serge 285
           jmp @B
214 serge 286
 
227 serge 287
.next:
288
           inc [devfn]
289
           cmp [devfn], 256
290
           jb  .next_dev
291
           mov eax, [bus]
292
           inc eax
293
           mov [bus], eax
294
           cmp eax, [last_bus]
295
           jna .next_bus
296
           xor eax, eax
297
           ret
214 serge 298
.found:
227 serge 299
           xor eax, eax
214 serge 300
           inc eax
227 serge 301
           ret
214 serge 302
.err:
303
           xor eax, eax
304
           ret
305
endp
306
 
307
align 4
308
proc init_ati
309
 
310
           stdcall AllocKernelSpace, dword 0x10000
311
           test eax, eax
312
           jz .fail
313
 
314
           mov [ati_io], eax
315
 
316
           stdcall PciRead32, [bus], [devfn], dword 0x18
317
           and eax, 0xFFFF0000
318
           mov esi, eax
319
 
320
           mov edi, [ati_io]
321
           mov edx, 16
322
@@:
323
           stdcall MapPage,edi,esi,PG_SW+PG_NOCACHE
227 serge 324
           add edi, 0x1000
214 serge 325
           add esi, 0x1000
326
           dec edx
327
           jnz @B
328
 
329
           mov edi, [ati_io]
330
           mov dword [edi+RD_RB3D_CNTL], 0
331
           call engRestore
332
 
333
           mov edi, [ati_io]
334
           mov eax, [edi+0x50]
335
           mov ebx,3
336
           shl ebx,20
337
           not ebx
338
           and eax,ebx
339
           mov ebx, 2
340
           shl ebx,20
341
           or eax, ebx
342
           mov [edi+0x50], eax
343
 
344
           call drvShowCursor
345
           xor eax, eax
346
           inc eax
347
.fail:
348
           ret
349
endp
350
 
351
align 4
227 serge 352
drv_restore:
353
           ret 8
354
 
355
align 4
214 serge 356
drvShowCursor:
357
           mov edi, [ati_io]
358
 
359
           mov eax, [edi+RD_CRTC_GEN_CNTL]
360
           bts eax,16
361
           mov [edi+RD_CRTC_GEN_CNTL], eax
362
           ret
363
 
364
align 4
227 serge 365
proc drvCursorPos stdcall, hcursor:dword, x:dword, y:dword
233 serge 366
           pushfd
367
           cli
227 serge 368
 
233 serge 369
           xor eax, eax
370
           xor edx, edx
371
           mov esi, [hcursor]
372
           mov ebx, [x]
373
           mov ecx, [y]
214 serge 374
 
233 serge 375
           sub ebx, [esi+CURSOR.hot_x]
376
           jnc @F
377
           neg ebx
378
           mov eax, ebx
214 serge 379
           shl eax, 16
233 serge 380
           xor ebx, ebx
381
@@:
382
           sub ecx, [esi+CURSOR.hot_y]
383
           jnc @F
384
           neg ecx
385
           mov ax, cx
386
           mov edx, ecx
387
           xor ecx, ecx
388
@@:
389
           or eax, 0x80000000
390
           wrr CUR_HORZ_VERT_OFF, eax
214 serge 391
 
233 serge 392
           shl ebx, 16
393
           mov bx, cx
394
           or ebx, 0x80000000
395
           wrr CUR_HORZ_VERT_POSN, ebx
396
 
397
           shl edx, 8
398
           add edx, [esi+CURSOR.base]
399
           sub edx, LFBAddress
400
           wrr CUR_OFFSET, edx
401
           popfd
227 serge 402
           ret
403
endp
214 serge 404
 
405
align 4
227 serge 406
proc video_alloc
407
 
408
           pushfd
409
           cli
410
           mov ebx, [cursor_start]
411
           mov ecx, [cursor_end]
412
.l1:
413
           bsf eax,[ebx];
414
           jnz .found
415
           add ebx,4
416
           cmp ebx, ecx
417
           jb .l1
418
           popfd
419
           xor eax,eax
420
           ret
421
.found:
422
           btr [ebx], eax
423
           popfd
424
 
425
           mov [cursor_start],ebx
426
           sub ebx, cursor_map
254 serge 427
           lea eax,[eax+ebx*8]
227 serge 428
 
429
           shl eax,14
430
           add eax, LFBAddress+CURSOR_IMAGE_OFFSET
431
           ret
432
endp
433
 
434
align 4
233 serge 435
video_free:
436
           pushfd
437
           cli
438
           sub eax, LFBAddress+CURSOR_IMAGE_OFFSET
439
           shr eax, 14
440
           mov ebx, cursor_map
441
           bts [ebx], eax
442
           shr eax, 3
443
           and eax, not 3
444
           add eax, ebx
445
           cmp [cursor_start], eax
446
           ja @f
447
           popfd
448
           ret
449
@@:
450
           mov [cursor_start], eax
451
           popfd
452
           ret
453
 
281 serge 454
; param
455
;  eax= pid
456
;  ebx= src
457
;  ecx= flags
458
 
233 serge 459
align 4
281 serge 460
ati_cursor:
461
.src     equ esp
462
.flags   equ esp+4
463
.hcursor equ esp+8
227 serge 464
 
281 serge 465
           sub esp, 4          ;space for .hcursor
466
           push ecx
467
           push ebx
227 serge 468
 
281 serge 469
           mov ebx, eax
470
           mov eax, CURSOR_SIZE
471
           call CreateObject
472
           test eax, eax
473
           jz .fail
474
 
475
           mov [.hcursor],eax
476
 
477
           xor ebx, ebx
478
           mov [eax+CURSOR.magic], 'CURS'
479
           mov [eax+CURSOR.destroy], destroy_cursor
480
           mov [eax+CURSOR.hot_x], ebx
481
           mov [eax+CURSOR.hot_y], ebx
482
 
483
           call video_alloc
484
           mov edi, [.hcursor]
227 serge 485
           mov [edi+CURSOR.base], eax
486
 
281 serge 487
           mov esi, [.src]
488
           mov ebx, [.flags]
227 serge 489
           cmp bx, LOAD_INDIRECT
490
           je .indirect
491
 
492
           movzx ecx, word [esi+10]
493
           movzx edx, word [esi+12]
494
           mov [edi+CURSOR.hot_x], ecx
495
           mov [edi+CURSOR.hot_y], edx
496
 
497
           stdcall ati_init_cursor, eax, esi
281 serge 498
           mov eax, [.hcursor]
227 serge 499
.fail:
281 serge 500
           add esp, 12
227 serge 501
           ret
502
.indirect:
503
           shr ebx, 16
504
           movzx ecx, bh
505
           movzx edx, bl
233 serge 506
           mov [edi+CURSOR.hot_x], ecx
507
           mov [edi+CURSOR.hot_y], edx
227 serge 508
 
281 serge 509
           mov edi, eax
510
           mov ebx, eax
227 serge 511
           mov ecx, 64*64
512
           xor eax,eax
281 serge 513
           cld
227 serge 514
           rep stosd
281 serge 515
           mov edi, ebx
227 serge 516
 
281 serge 517
           mov esi, [.src]
227 serge 518
           mov ebx, 32
519
           cld
520
@@:
521
           mov ecx, 32
522
           rep movsd
523
           add edi, 128
524
           dec ebx
525
           jnz @B
281 serge 526
           mov eax, [.hcursor]
527
           add esp, 12
227 serge 528
           ret
529
 
530
align 4
281 serge 531
destroy_cursor:
532
 
533
           push eax
534
           mov eax, [eax+CURSOR.base]
535
           call video_free
536
           pop eax
537
 
538
           call DestroyObject
539
           ret
540
 
541
align 4
227 serge 542
proc ati_init_cursor stdcall, dst:dword, src:dword
214 serge 543
           locals
544
             rBase    dd ?
545
             pQuad    dd ?
546
             pBits    dd ?
547
             pAnd     dd ?
548
             width    dd ?
549
             height   dd ?
550
             counter  dd ?
551
           endl
552
 
227 serge 553
           mov esi, [src]
554
           add esi,[esi+18]
555
           mov eax,esi
214 serge 556
 
227 serge 557
           cmp [esi+BI.biBitCount], 24
558
           je .img_24
233 serge 559
           cmp [esi+BI.biBitCount], 8
560
           je .img_8
561
           cmp [esi+BI.biBitCount], 4
562
           je .img_4
563
 
564
.img_2:
565
           add eax, [esi]
566
           mov [pQuad],eax
567
           add eax,8
568
           mov [pBits],eax
569
           add eax, 128
570
           mov [pAnd],eax
571
           mov eax,[esi+4]
572
           mov [width],eax
573
           mov ebx,[esi+8]
574
           shr ebx,1
575
           mov [height],ebx
576
 
577
           mov edi, pCursor
578
           add edi, 32*31*4
579
           mov [rBase],edi
580
 
581
           mov esi,[pQuad]
582
.l21:
583
           mov ebx, [pBits]
584
           mov ebx, [ebx]
585
           bswap ebx
586
           mov eax, [pAnd]
587
           mov eax, [eax]
588
           bswap eax
589
           mov [counter], 32
590
@@:
591
           xor edx, edx
592
           shl eax,1
593
           setc dl
594
           dec edx
595
 
596
           xor ecx, ecx
597
           shl ebx,1
598
           setc cl
599
           mov ecx, [esi+ecx*4]
600
           and ecx, edx
601
           and edx, 0xFF000000
602
           or edx, ecx
603
           mov [edi], edx
604
 
605
           add edi, 4
606
           dec [counter]
607
           jnz @B
608
 
609
           add [pBits], 4
610
           add [pAnd], 4
611
           mov edi,[rBase]
612
           sub edi,128
613
           mov [rBase],edi
614
           sub [height],1
615
           jnz .l21
616
           jmp .copy
227 serge 617
.img_4:
214 serge 618
           add eax, [esi]
619
           mov [pQuad],eax
620
           add eax,64
621
           mov [pBits],eax
622
           add eax, 0x200
623
           mov [pAnd],eax
624
           mov eax,[esi+4]
625
           mov [width],eax
626
           mov ebx,[esi+8]
627
           shr ebx,1
628
           mov [height],ebx
629
 
630
           mov edi, pCursor
631
           add edi, 32*31*4
632
           mov [rBase],edi
633
 
233 serge 634
           mov esi,[pQuad]
214 serge 635
           mov ebx, [pBits]
233 serge 636
.l4:
637
           mov eax, [pAnd]
638
           mov eax, [eax]
214 serge 639
           bswap eax
640
           mov [counter], 16
641
@@:
642
           xor edx, edx
643
           shl eax,1
644
           setc dl
645
           dec edx
646
 
233 serge 647
           movzx ecx, byte [ebx]
648
           and cl, 0xF0
214 serge 649
           shr ecx, 2
233 serge 650
           mov ecx, [esi+ecx]
214 serge 651
           and ecx, edx
652
           and edx, 0xFF000000
653
           or edx, ecx
654
           mov [edi], edx
655
 
656
           xor edx, edx
657
           shl eax,1
658
           setc dl
659
           dec edx
660
 
233 serge 661
           movzx ecx, byte [ebx]
662
           and cl, 0x0F
663
           mov ecx, [esi+ecx*4]
214 serge 664
           and ecx, edx
665
           and edx, 0xFF000000
666
           or edx, ecx
667
           mov [edi+4], edx
668
 
669
           inc ebx
670
           add edi, 8
671
           dec [counter]
672
           jnz @B
673
 
233 serge 674
           add [pAnd], 4
214 serge 675
           mov edi,[rBase]
676
           sub edi,128
677
           mov [rBase],edi
678
           sub [height],1
233 serge 679
           jnz .l4
227 serge 680
           jmp .copy
233 serge 681
.img_8:
682
           add eax, [esi]
683
           mov [pQuad],eax
684
           add eax,1024
685
           mov [pBits],eax
686
           add eax, 1024
687
           mov [pAnd],eax
688
           mov eax,[esi+4]
689
           mov [width],eax
690
           mov ebx,[esi+8]
691
           shr ebx,1
692
           mov [height],ebx
214 serge 693
 
233 serge 694
           mov edi, pCursor
695
           add edi, 32*31*4
696
           mov [rBase],edi
697
 
698
           mov esi,[pQuad]
699
           mov ebx, [pBits]
700
.l81:
701
           mov eax, [pAnd]
702
           mov eax, [eax]
703
           bswap eax
704
           mov [counter], 32
705
@@:
706
           xor edx, edx
707
           shl eax,1
708
           setc dl
709
           dec edx
710
 
711
           movzx ecx,  byte [ebx]
712
           mov ecx, [esi+ecx*4]
713
           and ecx, edx
714
           and edx, 0xFF000000
715
           or edx, ecx
716
           mov [edi], edx
717
 
718
           inc ebx
719
           add edi, 4
720
           dec [counter]
721
           jnz @B
722
 
723
           add [pAnd], 4
724
           mov edi,[rBase]
725
           sub edi,128
726
           mov [rBase],edi
727
           sub [height],1
728
           jnz .l81
729
           jmp .copy
227 serge 730
.img_24:
731
           add eax, [esi]
732
           mov [pQuad],eax
733
           add eax, 0xC00
734
           mov [pAnd],eax
735
           mov eax,[esi+BI.biWidth]
736
           mov [width],eax
737
           mov ebx,[esi+BI.biHeight]
738
           shr ebx,1
739
           mov [height],ebx
740
 
741
           mov edi, pCursor
742
           add edi, 32*31*4
743
           mov [rBase],edi
744
 
745
           mov esi,[pAnd]
746
           mov ebx, [pQuad]
747
.row_24:
748
           mov eax, [esi]
749
           bswap eax
750
           mov [counter], 32
751
@@:
752
           xor edx, edx
753
           shl eax,1
754
           setc dl
755
           dec edx
756
 
757
           mov ecx, [ebx]
758
           and ecx, 0x00FFFFFF
759
           and ecx, edx
760
           and edx, 0xFF000000
761
           or edx, ecx
762
           mov [edi], edx
763
           add ebx, 3
764
           add edi, 4
765
           dec [counter]
766
           jnz @B
767
 
768
           add esi, 4
769
           mov edi,[rBase]
770
           sub edi,128
771
           mov [rBase],edi
772
           sub [height],1
773
           jnz .row_24
774
.copy:
775
           mov edi, [dst]
214 serge 776
           mov ecx, 64*64
777
           xor eax,eax
778
           rep stosd
779
 
780
           mov esi, pCursor
227 serge 781
           mov edi, [dst]
214 serge 782
           mov ebx, 32
227 serge 783
           cld
784
@@:
214 serge 785
           mov ecx, 32
227 serge 786
           rep movsd
214 serge 787
           add edi, 128
227 serge 788
           dec ebx
789
           jnz @B
214 serge 790
           ret
791
endp
792
 
793
align 4
794
proc engFlush
795
 
796
           mov edi, [ati_io]
797
 
798
           mov eax, [edi+RD_RB2D_DSTCACHE_CTLSTAT]
799
           or eax,RD_RB2D_DC_FLUSH_ALL
800
           mov [edi+RD_RB2D_DSTCACHE_CTLSTAT],eax
801
 
802
           mov ecx, RD_TIMEOUT
803
@@:
804
           mov eax,[edi+RD_RB2D_DSTCACHE_CTLSTAT]
805
           and eax, RD_RB2D_DC_BUSY
806
           jz .exit
807
 
808
           sub ecx,1
809
           jnz @B
810
.exit:
811
           ret
812
endp
813
 
814
align 4
815
engWaitForFifo:
816
cnt equ bp+8
817
           push ebp
818
           mov ebp, esp
819
 
820
           mov edi, [ati_io]
821
 
822
           mov ecx, RD_TIMEOUT
823
@@:
824
           mov eax, [edi+RD_RBBM_STATUS]
825
           and eax, RD_RBBM_FIFOCNT_MASK
826
           cmp eax, [ebp+8]
827
           jae .exit
828
 
829
           sub ecx,1
830
           jmp @B
831
 
832
.exit:
833
           leave
834
           ret 4
835
 
836
align 4
837
proc engWaitForIdle
838
 
227 serge 839
           push dword 64
840
           call engWaitForFifo
214 serge 841
 
227 serge 842
           mov edi, [ati_io]
843
           mov ecx ,RD_TIMEOUT
214 serge 844
@@:
227 serge 845
           mov eax, [edi+RD_RBBM_STATUS]
846
           and eax,RD_RBBM_ACTIVE
847
           jz .exit
214 serge 848
 
227 serge 849
           sub ecx,1
850
           jnz @B
214 serge 851
.exit:
227 serge 852
           call engFlush
853
           ret
214 serge 854
endp
855
 
856
align 4
857
proc engRestore
858
 
859
;             push dword 1
860
;             call engWaitForFifo
861
 
862
;             mov dword  [MMIO+RD_RB2D_DSTCACHE_MODE], 0
863
 
227 serge 864
           push dword 3
865
           call engWaitForFifo
214 serge 866
 
867
           mov edi, [ati_io]
868
 
869
           mov eax, [edi+RD_DISPLAY_BASE_ADDR]
870
           shr eax, 10d
871
           or eax,(64d shl 22d)
872
           mov [edi+RD_DEFAULT_OFFSET],eax
873
           mov [edi+RD_SRC_PITCH_OFFSET],eax
874
           mov [edi+RD_DST_PITCH_OFFSET],eax
875
 
876
           push dword 1
877
           call engWaitForFifo
878
 
879
           mov edi, [ati_io]
880
           mov eax, [edi+RD_DP_DATATYPE]
881
           btr eax, 29d
882
           mov [edi+RD_DP_DATATYPE],eax
883
 
884
           push dword 1
885
           call engWaitForFifo
886
 
887
           mov edi, [ati_io]
888
           mov dword [edi+RD_DEFAULT_SC_BOTTOM_RIGHT],\
889
                     (RD_DEFAULT_SC_RIGHT_MAX or RD_DEFAULT_SC_BOTTOM_MAX)
890
 
891
           push dword 1
892
           call engWaitForFifo
893
 
894
           mov edi, [ati_io]
895
           mov dword [edi+RD_DP_GUI_MASTER_CNTL],\
896
                     (RD_GMC_BRUSH_SOLID_COLOR or \
897
                      RD_GMC_SRC_DATATYPE_COLOR or \
898
                     (6 shl RD_GMC_DST_DATATYPE_SHIFT) or \
899
                      RD_GMC_CLR_CMP_CNTL_DIS or \
900
                      RD_ROP3_P or \
901
                      RD_GMC_WR_MSK_DIS)
902
 
903
 
904
           push dword 7
905
           call engWaitForFifo
906
 
907
           mov edi, [ati_io]
908
 
909
           mov dword [edi+RD_DST_LINE_START],0
910
           mov dword [edi+RD_DST_LINE_END], 0
911
           mov dword [edi+RD_DP_BRUSH_FRGD_CLR], 808000ffh
912
           mov dword [edi+RD_DP_BRUSH_BKGD_CLR], 002020ffh
913
           mov dword [edi+RD_DP_SRC_FRGD_CLR],   808000ffh
914
           mov dword [edi+RD_DP_SRC_BKGD_CLR],   004000ffh
915
           mov dword [edi+RD_DP_WRITE_MASK],0ffffffffh
916
 
917
           call engWaitForIdle
918
 
919
           ret
920
endp
921
 
922
align 4
923
engSetupSolidFill:
924
           push ebp
925
           mov ebp, esp
926
 
927
           push dword 3
928
           call engWaitForFifo
929
 
930
           wrr RD_DP_GUI_MASTER_CNTL, cmdSolidFill
931
 
932
           mov eax, [ebp+8]
933
           wrr RD_DP_BRUSH_FRGD_CLR,eax
934
 
935
           mov edi, [ati_io]
936
           mov dword [edi+RD_DP_CNTL],(RD_DST_X_LEFT_TO_RIGHT or RD_DST_Y_TOP_TO_BOTTOM)
937
           leave
938
           ret 4
939
 
940
 
941
align 4
942
drvSolidFill:
943
;x:word,y:word,w:word,h:word,color:dword
944
            push ebp
945
            mov ebp, esp
946
x equ ebp+8
947
y equ ebp+12
948
w equ ebp+16
949
h equ ebp+20
950
color equ ebp+24
951
 
227 serge 952
           push dword [ebp+24]
953
           call engSetupSolidFill
214 serge 954
 
227 serge 955
           push dword 2
956
           call engWaitForFifo
214 serge 957
 
227 serge 958
           mov edi, [ati_io]
214 serge 959
 
227 serge 960
           mov eax, [y]
961
           mov ebx, [x]
962
           shl eax,16
963
           or eax, ebx
214 serge 964
 
227 serge 965
           mov ecx,  [w]
966
           mov edx,  [h]
967
           shl ecx,16
968
           or ecx, edx
969
           mov [edi+RD_DST_Y_X], eax
970
           mov [edi+RD_DST_WIDTH_HEIGHT], ecx
971
           call engFlush
972
           leave
973
           ret 20
214 serge 974
 
975
align 4
976
devices dd (R8500   shl 16)+VID_ATI
977
        dd (R9000   shl 16)+VID_ATI
978
        dd (R9200   shl 16)+VID_ATI
979
        dd (R9500   shl 16)+VID_ATI
980
        dd (R9500P  shl 16)+VID_ATI
981
        dd (R9550   shl 16)+VID_ATI
982
        dd (R9600   shl 16)+VID_ATI
983
        dd (R9600XT shl 16)+VID_ATI
984
        dd (R9700P  shl 16)+VID_ATI
985
        dd (R9800   shl 16)+VID_ATI
986
        dd (R9800P  shl 16)+VID_ATI
987
        dd (R9800XT shl 16)+VID_ATI
988
        dd 0    ;terminator
989
 
378 serge 990
version dd 0x00040004
214 serge 991
 
227 serge 992
sz_ati_srv   db 'HWCURSOR',0
214 serge 993
 
994
msgInit      db 'detect hardware...',13,10,0
995
msgPCI       db 'PCI accsess not supported',13,10,0
996
msgFail      db 'device not found',13,10,0
233 serge 997
msg_neg      db 'neg ecx',13,10,0
998
buff         db 8 dup(0)
999
             db 13,10, 0
214 serge 1000
 
1001
section '.data' data readable writable align 16
1002
 
1003
pCursor  db 4096 dup(?)
1004
 
227 serge 1005
cursor_map     rd 2
1006
cursor_start   rd 1
1007
cursor_end     rd 1
214 serge 1008
 
227 serge 1009
bus            dd ?
1010
devfn          dd ?
1011
ati_io         dd ?
214 serge 1012