Apply the new ground_level method.
[crawl.git] / crawl-ref / source / libdos.cc
blobdb2eae669dc7945dd7c1fbd76a4ef5b04fc8d4c8
1 /*
2 * File: libdos.cc
3 * Summary: Functions for DOS support.
4 * Needed by makefile.dos.
5 * Written by: Darshan Shaligram
7 * Added for Crawl Reference by dshaligram on Wed Nov 22 08:41:20 2006 UTC
8 */
10 // Every .cc must include AppHdr or bad things happen.
11 #include "AppHdr.h"
13 #include "cio.h"
14 #include <termios.h>
15 #include <conio.h>
16 #include "options.h"
17 #include "viewgeom.h"
19 #if defined(TARGET_OS_DOS)
21 static bool cursor_is_enabled = true;
23 void init_libdos()
25 struct termios charmode;
27 tcgetattr (0, &charmode);
28 // Ignore Ctrl-C
29 charmode.c_lflag &= ~ISIG;
30 tcsetattr (0, TCSANOW, &charmode);
32 // Turn off blink.
33 intensevideo();
36 void set_cursor_enabled(bool enabled)
38 cursor_is_enabled = enabled;
39 _setcursortype(enabled? _NORMALCURSOR : _NOCURSOR);
42 bool is_cursor_enabled()
44 return (cursor_is_enabled);
47 // This will force the cursor down to the next line.
48 void clear_to_end_of_line()
50 clreol();
53 int get_number_of_lines()
55 return (25);
58 int get_number_of_cols()
60 return (80);
63 int getch_ck()
65 int c = getch();
66 if (!c)
68 switch (c = getch())
70 case 'O': return CK_END;
71 case 'P': return CK_DOWN;
72 case 'I': return CK_PGUP;
73 case 'H': return CK_UP;
74 case 'G': return CK_HOME;
75 case 'K': return CK_LEFT;
76 case 'Q': return CK_PGDN;
77 case 'M': return CK_RIGHT;
78 case 119: return CK_CTRL_HOME;
79 case 141: return CK_CTRL_UP;
80 case 132: return CK_CTRL_PGUP;
81 case 116: return CK_CTRL_RIGHT;
82 case 118: return CK_CTRL_PGDN;
83 case 145: return CK_CTRL_DOWN;
84 case 117: return CK_CTRL_END;
85 case 115: return CK_CTRL_LEFT;
86 case 'S': return CK_DELETE;
89 return c;
92 int m_getch()
94 return getch();
97 void putwch(unsigned c)
99 putch(static_cast<char>(c));
102 #endif /* #if defined(TARGET_OS_DOS) */