87 /* This part of the screen is now dirty. */ |
87 /* This part of the screen is now dirty. */ |
88 _video_driver->MakeDirty(left, top, width, height); |
88 _video_driver->MakeDirty(left, top, width, height); |
89 } |
89 } |
90 |
90 |
91 |
91 |
92 void GfxFillRect(int left, int top, int right, int bottom, int color) |
92 /** |
|
93 * Applies a certain FillRectMode-operation to a rectangle [left, right] x [top, bottom] on the screen. |
|
94 * |
|
95 * @pre dpi->zoom == ZOOM_LVL_NORMAL, right >= left, bottom >= top |
|
96 * @param left Minimum X (inclusive) |
|
97 * @param top Minimum Y (inclusive) |
|
98 * @param right Maximum X (inclusive) |
|
99 * @param bottom Maximum Y (inclusive) |
|
100 * @param color A 8 bit palette index (FILLRECT_OPAQUE and FILLRECT_CHECKER) or a recolor spritenumber (FILLRECT_RECOLOR) |
|
101 * @param mode |
|
102 * FILLRECT_OPAQUE: Fill the rectangle with the specified color |
|
103 * FILLRECT_CHECKER: Like FILLRECT_OPAQUE, but only draw every second pixel (used to grey out things) |
|
104 * FILLRECT_RECOLOR: Apply a recolor sprite to every pixel in the rectangle currently on screen |
|
105 */ |
|
106 void GfxFillRect(int left, int top, int right, int bottom, int color, FillRectMode mode) |
93 { |
107 { |
94 Blitter *blitter = BlitterFactoryBase::GetCurrentBlitter(); |
108 Blitter *blitter = BlitterFactoryBase::GetCurrentBlitter(); |
95 const DrawPixelInfo *dpi = _cur_dpi; |
109 const DrawPixelInfo *dpi = _cur_dpi; |
96 void *dst; |
110 void *dst; |
97 const int otop = top; |
111 const int otop = top; |
114 bottom -= top; |
128 bottom -= top; |
115 assert(bottom > 0); |
129 assert(bottom > 0); |
116 |
130 |
117 dst = blitter->MoveTo(dpi->dst_ptr, left, top); |
131 dst = blitter->MoveTo(dpi->dst_ptr, left, top); |
118 |
132 |
119 if (!HasBit(color, PALETTE_MODIFIER_GREYOUT)) { |
133 switch (mode) { |
120 if (!HasBit(color, USE_COLORTABLE)) { |
134 default: // FILLRECT_OPAQUE |
121 blitter->DrawRect(dst, right, bottom, (uint8)color); |
135 blitter->DrawRect(dst, right, bottom, (uint8)color); |
122 } else { |
136 break; |
|
137 |
|
138 case FILLRECT_RECOLOR: |
123 blitter->DrawColorMappingRect(dst, right, bottom, GB(color, 0, PALETTE_WIDTH)); |
139 blitter->DrawColorMappingRect(dst, right, bottom, GB(color, 0, PALETTE_WIDTH)); |
124 } |
140 break; |
125 } else { |
141 |
126 byte bo = (oleft - left + dpi->left + otop - top + dpi->top) & 1; |
142 case FILLRECT_CHECKER: { |
127 do { |
143 byte bo = (oleft - left + dpi->left + otop - top + dpi->top) & 1; |
128 for (int i = (bo ^= 1); i < right; i += 2) blitter->SetPixel(dst, i, 0, (uint8)color); |
144 do { |
129 dst = blitter->MoveTo(dst, 0, 1); |
145 for (int i = (bo ^= 1); i < right; i += 2) blitter->SetPixel(dst, i, 0, (uint8)color); |
130 } while (--bottom > 0); |
146 dst = blitter->MoveTo(dst, 0, 1); |
|
147 } while (--bottom > 0); |
|
148 break; |
|
149 } |
131 } |
150 } |
132 } |
151 } |
133 |
152 |
134 void GfxDrawLine(int x, int y, int x2, int y2, int color) |
153 void GfxDrawLine(int x, int y, int x2, int y2, int color) |
135 { |
154 { |