Category : Recently Uploaded Files
Archive   : DOSUIT07.ZIP
Filename : HARDWARE.HPP

 
Output of file : HARDWARE.HPP contained in archive : DOSUIT07.ZIP

// Hardware specific stuff
#ifndef HARDWARE_HPP
#define HARDWARE_HPP
// Turn off DEBUG if INSPECT off
#ifdef NINSPECT
#ifndef NDEBUG
#define NDEBUG
#endif
#endif

#ifdef NDEBUG
#define ASSERT(ignore) ((void) 0)
#else
#define ASSERT(e) ((void)((e) || (crash(#e,__FILE__,__LINE__),1)))
extern void crash(const char *err, const char *filename, unsigned lineno);
// Crash with debugging dump.
#endif

typedef int coord; // x,y coordinate system.
typedef unsigned char color; // Color/highlight values.

const coord maxcoord = 127; // Maximum possible coordinate.

// The colours available for printing on the screen.
// Obviously, some hardware may not support all of these.
enum Colors {
Black, Blue, Green, Cyan, Red, Magenta, Brown, White,
Gray, LightBlue, LightGreen, LightCyan, LightRed, LightMagenta, Yellow,
BrightWhite,
Blinking = 0x80 // May be ORed with any of the others
};

// Return a single color value for the specified foreground and
// background.
inline color Color(Colors foreground, Colors background = Black,
int blinking = 0)
{
return color ((foreground & 0x0f)
| ((background & 0x07) << 4)
| ((blinking) ? Blinking : 0));
}

// Represents the possible keyboard shift states.
enum ShiftState {
SHnone = 0,
SHright = 1,
SHleft = 2,
SHshift = (SHright|SHleft),
SHctrl = 4,
SHalt = 8,
SHscroll = 16,
SHnum = 32,
SHcaps = 64
};

// Represents all the "special" keys on the keyboard.
// The control+letter keys are represented using the "ctrl(letter)" macro.
enum Keys {
Kauto = -1,
Knone = 0,
KBksp = 8,
KTab = 9,
Klf = 10,
Kcr = 13,
Kesc = 27,
KBackTab = 0x0f00,

Kup = 0x4800,
Kdown = 0x5000,
Kleft = 0x4B00,
Kright = 0x4D00,
Kpgup = 0x4900,
Kpgdn = 0x5100,
Khome = 0x4700,
Kend = 0x4F00,
Kinsert = 0x5200,
Kdel = 0x5300,
Kctrlleft = 0x7300,
Kctrlright = 0x7400,
Kctrlpgup = 0x8400,
Kctrlpgdn = 0x9300,
Kctrlhome = 0x7700,
Kctrlend = 0x7500,

KF1 = 0x3B00,
KF2 = 0x3C00,
KF3 = 0x3D00,
KF4 = 0x3E00,
KF5 = 0x3F00,
KF6 = 0x4000,
KF7 = 0x4100,
KF8 = 0x4200,
KF9 = 0x4300,
KF10 = 0x4400,

KShiftF1 = 0x5400,
KShiftF2 = 0x5500,
KShiftF3 = 0x5600,
KShiftF4 = 0x5700,
KShiftF5 = 0x5800,
KShiftF6 = 0x5900,
KShiftF7 = 0x5A00,
KShiftF8 = 0x5B00,
KShiftF9 = 0x5C00,
KShiftF10 = 0x5D00,

KCtrlF1 = 0x5E00,
KCtrlF2 = 0x5F00,
KCtrlF3 = 0x6000,
KCtrlF4 = 0x6100,
KCtrlF5 = 0x6200,
KCtrlF6 = 0x6300,
KCtrlF7 = 0x6400,
KCtrlF8 = 0x6500,
KCtrlF9 = 0x6600,
KCtrlF10 = 0x6700,

KAltF1 = 0x6800,
KAltF2 = 0x6900,
KAltF3 = 0x6A00,
KAltF4 = 0x6B00,
KAltF5 = 0x6C00,
KAltF6 = 0x6D00,
KAltF7 = 0x6E00,
KAltF8 = 0x6F00,
KAltF9 = 0x7000,
KAltF10 = 0x7100,

KAlt0 = 0x8100,
KAlt1 = 0x7800,
KAlt2 = 0x7900,
KAlt3 = 0x7a00,
KAlt4 = 0x7b00,
KAlt5 = 0x7c00,
KAlt6 = 0x7d00,
KAlt7 = 0x7e00,
KAlt8 = 0x7f00,
KAlt9 = 0x8000,

KAltA = 0x1E00,
KAltB = 0x3000,
KAltC = 0x2E00,
KAltD = 0x2000,
KAltE = 0x1200,
KAltF = 0x2100,
KAltG = 0x2200,
KAltH = 0x2300,
KAltI = 0x1700,
KAltJ = 0x2400,
KAltK = 0x2500,
KAltL = 0x2600,
KAltM = 0x3200,
KAltN = 0x3100,
KAltO = 0x1800,
KAltP = 0x1900,
KAltQ = 0x1000,
KAltR = 0x1300,
KAltS = 0x1F00,
KAltT = 0x1400,
KAltU = 0x1600,
KAltV = 0x2F00,
KAltW = 0x1100,
KAltX = 0x2D00,
KAltY = 0x1500,
KAltZ = 0x2C00
};

#define ctrl(key) Keys((key)-'@')
extern Keys alt(int key);
// Return the Keys value of Alt+the specified key (if possible).

const int maxKeynameLength = 7; // The length of a key name.

extern const char *keyname(unsigned keyvalue);
// Return the name of the specified key value.
extern Keys namekey(const char *keyname);
// Return the key value whose name is given.

// The different types of Box or Line which can be drawn.
enum BoxType { BTnone, BTsingle, BTdouble, BTbold, nBoxType /*!*/};

//!
// Character constants for printing symbols on the screen.
extern const char RightArrow[], LeftArrow[], DownArrow[], UpArrow[];
extern const char RadioOn[], RadioOff[], CheckOn[], CheckOff[];
extern const char Tick[];

enum BoxChars {
Btopleft, Btop, Btopright,
Bleft, Bright,
Bbotleft, Bbot, Bbotright,
nBoxChars };

extern const char boxChars[nBoxType][nBoxChars];
#endif