Subversion Repositories Kolibri OS

Rev

Rev 425 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

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