| 287 | } |
| 288 | |
| 289 | static Pen doGetTile_default(int x, int y, bool map, int32_t * df::graphic_viewportst::*texpos_field = NULL) { |
| 290 | bool use_graphics = Screen::inGraphicsMode(); |
| 291 | |
| 292 | if (map && use_graphics) |
| 293 | return doGetTile_map(x, y, texpos_field); |
| 294 | |
| 295 | if (x < 0 || x >= gps->dimx || y < 0 || y >= gps->dimy) |
| 296 | return Pen(0, 0, 0, -1); |
| 297 | |
| 298 | size_t index = (x * gps->dimy) + y; |
| 299 | uint8_t *screen = &gps->screen[index * 8]; |
| 300 | |
| 301 | if (screen > gps->screen_limit) |
| 302 | return Pen(0, 0, 0, -1); |
| 303 | |
| 304 | long *texpos = &gps->screentexpos[index]; |
| 305 | long *texpos_lower = &gps->screentexpos_lower[index]; |
| 306 | uint32_t *flag = &gps->screentexpos_flag[index]; |
| 307 | |
| 308 | if (gps->top_in_use && |
| 309 | (gps->screen_top[index * 8] || |
| 310 | (use_graphics && gps->screentexpos_top[index]))) { |
| 311 | screen = &gps->screen_top[index * 8]; |
| 312 | texpos = &gps->screentexpos_top[index]; |
| 313 | texpos_lower = &gps->screentexpos_top_lower[index]; |
| 314 | flag = &gps->screentexpos_top_flag[index]; |
| 315 | } |
| 316 | |
| 317 | char ch = *screen; |
| 318 | uint8_t fg = to_16_bit_color(&screen[1]); |
| 319 | uint8_t bg = to_16_bit_color(&screen[4]); |
| 320 | int tile = 0; |
| 321 | bool write_to_lower = false; |
| 322 | bool top_of_text = false; |
| 323 | bool bottom_of_text = false; |
| 324 | if (use_graphics) { |
| 325 | tile = *texpos; |
| 326 | if (!tile && *texpos_lower) { |
| 327 | tile = *texpos_lower; |
| 328 | write_to_lower = true; |
| 329 | } |
| 330 | if (*flag & 0x8) |
| 331 | top_of_text = true; |
| 332 | else if (*flag &0x10) |
| 333 | bottom_of_text = true; |
| 334 | } |
| 335 | |
| 336 | Pen ret; |
| 337 | if (*flag & 1) { |
| 338 | // TileColor |
| 339 | ret = Pen(ch, fg&7, bg, !!(fg&8), tile, fg, bg); |
| 340 | } else if (*flag & 2) { |
| 341 | // CharColor |
| 342 | ret = Pen(ch, fg, bg, tile, true); |
| 343 | } else { |
| 344 | // AsIs |
| 345 | ret = Pen(ch, fg, bg, tile, false); |
| 346 | } |
nothing calls this directly
no test coverage detected