From 04ef4ac34d7bbc5358a3adbf542071599e71c515 Mon Sep 17 00:00:00 2001 From: dshaligram Date: Sun, 11 Mar 2007 15:31:45 +0000 Subject: [1657502] Added use_fake_cursor option to make Crawl draw a cursor for Unix terminals that cannot draw cursors on black spaces or darkgrey areas. May need some work, since the fake cursor tends to leave artifacts on the scrolling edge. Removed the +1 X offset to the viewport. Fixed crash when monster wielding a weapon of orc slaying hits player (Erik). git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1016 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/libunix.cc | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'crawl-ref/source/libunix.cc') diff --git a/crawl-ref/source/libunix.cc b/crawl-ref/source/libunix.cc index 3eb398237b..1ef0d2ea45 100644 --- a/crawl-ref/source/libunix.cc +++ b/crawl-ref/source/libunix.cc @@ -640,6 +640,44 @@ int gotoxy(int x, int y) return (move(y - 1, x - 1)); } +static unsigned oldch, oldmangledch; +static int faked_x = -1, faked_y; + +void fakecursorxy(int x, int y) +{ + if (oldch && faked_x != -1 + && mvinch(faked_y, faked_x) == oldmangledch) + { + if (faked_x != x - 1 || faked_y != y - 1) + mvaddch(faked_y, faked_x, oldch); + else + return; + } + + const unsigned c = mvinch(y - 1, x - 1); + const int ch = c & A_CHARTEXT; + const unsigned colour = c & A_COLOR; + const int pair = PAIR_NUMBER(colour); + + faked_x = x - 1; + faked_y = y - 1; + oldch = c; + + int fg = pair & 7; + int bg = (pair >> 3) & 7; + + if (pair == 63) + { + fg = COLOR_WHITE; + bg = COLOR_BLACK; + } + + const int newpair = (fg * 8 + bg); + + mvaddch( y - 1, x - 1, oldmangledch = ((ch & 127) | COLOR_PAIR(newpair)) ); + + move(y - 1, x - 1); +} int wherex() { -- cgit v1.2.3-54-g00ecf