MCPcopy Create free account
hub / github.com/NetHack/NetHack / map_update

Function map_update

win/X11/winmap.c:1367–1521  ·  view source on GitHub ↗

* Do the actual work of the putting characters onto our X window. This * is called from the expose event routine, the display window (flush) * routine, and the display cursor routine. The last involves inverting * the foreground and background colors, which are also inverted when the * position's color is above CLR_MAX. * * This works for rectangular regions (this includes one line rectang

Source from the content-addressed store, hash-verified

1365 * The start and stop columns are *inclusive*.
1366 */
1367static void
1368map_update(struct xwindow *wp, int start_row, int stop_row, int start_col, int stop_col, boolean inverted)
1369{
1370 struct map_info_t *map_info = wp->map_information;
1371 int row;
1372 int count;
1373
1374 if (start_row < 0 || stop_row >= ROWNO) {
1375 impossible("map_update: bad row range %d-%d\n", start_row, stop_row);
1376 return;
1377 }
1378 if (start_col < 0 || stop_col >= COLNO) {
1379 impossible("map_update: bad col range %d-%d\n", start_col, stop_col);
1380 return;
1381 }
1382
1383#ifdef VERBOSE_UPDATE
1384 printf("update: [0x%x] %d %d %d %d\n",
1385 (int) wp->w, start_row, stop_row, start_col, stop_col);
1386#endif
1387
1388 if (map_info->is_tile) {
1389 struct tile_map_info_t *tile_map = &map_info->tile_map;
1390 int cur_col;
1391 Display *dpy = XtDisplay(wp->w);
1392 Screen *screen = DefaultScreenOfDisplay(dpy);
1393
1394 for (row = start_row; row <= stop_row; row++) {
1395 for (cur_col = start_col; cur_col <= stop_col; cur_col++) {
1396#if 0
1397 int glyph = tile_map->glyphs[row][cur_col].glyph;
1398 int tile = glyph2tile[glyph];
1399#else
1400 int tile = tile_map->glyphs[row][cur_col].tileidx;
1401#endif
1402 int src_x, src_y;
1403 int dest_x = (cur_col - COL0_OFFSET) * tile_map->square_width;
1404 int dest_y = row * tile_map->square_height;
1405 unsigned gflags = tile_map->glyphs[row][cur_col].glyphflags;
1406
1407#if 0
1408 /* not required with the new glyph representations */
1409 if ((gflags & MG_FEMALE) != 0)
1410 tile++; /* advance to the female tile variation */
1411#endif
1412 src_x = (tile % TILES_PER_ROW) * tile_width;
1413 src_y = (tile / TILES_PER_ROW) * tile_height;
1414 XCopyArea(dpy, tile_pixmap, XtWindow(wp->w),
1415 tile_map->black_gc, /* no grapics_expose */
1416 src_x, src_y, tile_width, tile_height,
1417 dest_x, dest_y);
1418
1419 if ((gflags & MG_PET) != 0 && iflags.hilite_pet) {
1420 /* draw pet annotation (a heart) */
1421 XSetForeground(dpy, tile_map->black_gc,
1422 pet_annotation.foreground);
1423 XSetClipOrigin(dpy, tile_map->black_gc, dest_x, dest_y);
1424 XSetClipMask(dpy, tile_map->black_gc,

Callers 3

display_cursorFunction · 0.85
display_map_windowFunction · 0.85
map_exposedFunction · 0.85

Calls 5

printfFunction · 0.85
X11_make_gcFunction · 0.85
X11_draw_image_stringFunction · 0.85
X11_free_gcFunction · 0.85
impossibleFunction · 0.50

Tested by

no test coverage detected