| 2153 | #ifdef SIMULATE_CURSOR |
| 2154 | |
| 2155 | void |
| 2156 | vesa_DrawCursor(void) |
| 2157 | { |
| 2158 | static boolean last_inmap = FALSE; |
| 2159 | unsigned x, y, left, top, right, bottom, width, height; |
| 2160 | boolean isrogue = Is_rogue_level(&u.uz); |
| 2161 | boolean halfwidth = |
| 2162 | (isrogue || iflags.over_view || iflags.traditional_view || !inmap); |
| 2163 | int curtyp; |
| 2164 | |
| 2165 | if (inmap && !last_inmap) { |
| 2166 | vesa_redrawmap(); |
| 2167 | } |
| 2168 | last_inmap = inmap; |
| 2169 | |
| 2170 | if (!cursor_type && inmap) |
| 2171 | return; /* CURSOR_INVIS - nothing to do */ |
| 2172 | if (undercursor == NULL) { |
| 2173 | /* size for the greater of one tile or one character */ |
| 2174 | unsigned size1 = vesa_char_width * vesa_char_height; |
| 2175 | unsigned size2 = iflags.wc_tile_width * iflags.wc_tile_height; |
| 2176 | undercursor = (unsigned long *) alloc( |
| 2177 | sizeof(undercursor[0]) * max(size1, size2)); |
| 2178 | } |
| 2179 | |
| 2180 | x = min(curcol, (CO - 1)); /* protection from callers */ |
| 2181 | y = min(currow, (LI - 1)); /* protection from callers */ |
| 2182 | if (!halfwidth |
| 2183 | && ((x < (unsigned) clipx) || (x > (unsigned) clipxmax) |
| 2184 | || (y < (unsigned) clipy) || (y > (unsigned) clipymax))) |
| 2185 | return; |
| 2186 | if (inmap) { |
| 2187 | x -= clipx; |
| 2188 | y -= clipy; |
| 2189 | } |
| 2190 | /* convert to pixels */ |
| 2191 | if (!inmap || iflags.traditional_view) { |
| 2192 | width = vesa_char_width; |
| 2193 | height = vesa_char_height; |
| 2194 | } else if (iflags.over_view) { |
| 2195 | width = vesa_oview_width; |
| 2196 | height = vesa_oview_height; |
| 2197 | } else { |
| 2198 | width = iflags.wc_tile_width; |
| 2199 | height = iflags.wc_tile_height; |
| 2200 | } |
| 2201 | left = x * width + vesa_x_center; |
| 2202 | top = y * height + vesa_y_center; |
| 2203 | if (y >= TOP_MAP_ROW) { |
| 2204 | top -= (height - vesa_char_height) * TOP_MAP_ROW; |
| 2205 | } |
| 2206 | right = left + width - 1; |
| 2207 | bottom = top + height - 1; |
| 2208 | |
| 2209 | for (y = 0; y < height; ++y) { |
| 2210 | for (x = 0; x < width; ++x) { |
| 2211 | undercursor[y * width + x] = vesa_ReadPixel32(left + x, top + y); |
| 2212 | } |
no test coverage detected