2 Haiku S3 Trio64 driver adapted from the X.org S3 driver.
4 Copyright 2001 Ani Joshi <ajoshi@unixbox.com>
6 Copyright 2008 Haiku, Inc. All rights reserved.
7 Distributed under the terms of the MIT license.
20 Trio64_FillRectangle(engine_token
* et
, uint32 color
, fill_rect_params
* pList
,
23 (void)et
; // avoid compiler warning for unused arg
26 WriteReg16(MULTIFUNC_CNTL
, 0xa000);
27 WriteReg32(FRGD_COLOR
, color
);
28 WriteReg16(FRGD_MIX
, FSS_FRGDCOL
| 0x07); // 7 = GXcopy rop
33 int w
= pList
->right
- x
;
34 int h
= pList
->bottom
- y
;
39 WriteReg16(CUR_WIDTH
, w
);
40 WriteReg16(MULTIFUNC_CNTL
, h
);
41 WriteReg16(CMD
, CMD_RECT
| DRAW
| INC_X
| INC_Y
| WRTDATA
);
49 Trio64_FillSpan(engine_token
* et
, uint32 color
, uint16
* pList
, uint32 count
)
51 (void)et
; // avoid compiler warning for unused arg
54 WriteReg16(MULTIFUNC_CNTL
, 0xa000);
55 WriteReg32(FRGD_COLOR
, color
);
56 WriteReg16(FRGD_MIX
, FSS_FRGDCOL
| 0x07); // 7 = GXcopy rop
63 // Some S3 chips display a line completely across the screen when a
64 // span has zero width; thus, the following if statement discards any
65 // span with zero or negative width.
70 // Draw the span as a rectangle with a height of 1 to avoid the
71 // extra complexity of drawing a line.
76 WriteReg16(CUR_WIDTH
, w
);
77 WriteReg16(MULTIFUNC_CNTL
, 0); // height is 1; but as computed it is 0
78 WriteReg16(CMD
, CMD_RECT
| DRAW
| INC_X
| INC_Y
| WRTDATA
);
84 Trio64_InvertRectangle(engine_token
* et
, fill_rect_params
* pList
, uint32 count
)
86 (void)et
; // avoid compiler warning for unused arg
89 WriteReg16(MULTIFUNC_CNTL
, 0xa000);
90 WriteReg16(FRGD_MIX
, FSS_FRGDCOL
| 0x00); // 0 = GXinvert rop
95 int w
= pList
->right
- x
;
96 int h
= pList
->bottom
- y
;
100 WriteReg16(CUR_Y
, y
);
101 WriteReg16(CUR_WIDTH
, w
);
102 WriteReg16(MULTIFUNC_CNTL
, h
);
103 WriteReg16(CMD
, CMD_RECT
| DRAW
| INC_X
| INC_Y
| WRTDATA
);
111 Trio64_ScreenToScreenBlit(engine_token
* et
, blit_params
* pList
, uint32 count
)
113 (void)et
; // avoid compiler warning for unused arg
116 WriteReg16(MULTIFUNC_CNTL
, 0xa000);
117 WriteReg16(FRGD_MIX
, FSS_BITBLT
| 0x07); // 7 = GXcopy rop
120 int src_x
= pList
->src_left
;
121 int src_y
= pList
->src_top
;
122 int dest_x
= pList
->dest_left
;
123 int dest_y
= pList
->dest_top
;
124 int width
= pList
->width
;
125 int height
= pList
->height
;
127 if (src_x
== dest_x
&& src_y
== dest_y
)
130 int cmd
= CMD_BITBLT
| DRAW
| INC_X
| INC_Y
| WRTDATA
;
132 if (src_x
< dest_x
) {
138 if (src_y
< dest_y
) {
145 WriteReg16(CUR_X
, src_x
);
146 WriteReg16(CUR_Y
, src_y
);
147 WriteReg16(DESTX_DIASTP
, dest_x
);
148 WriteReg16(DESTY_AXSTP
, dest_y
);
149 WriteReg16(CUR_WIDTH
, width
);
150 WriteReg16(MULTIFUNC_CNTL
, height
);
151 WriteReg16(CMD
, cmd
);