2 Register.hpp version 1.0
\r
3 by Robert Schmidt of Ztiff Zox Softwear 1993
\r
5 Declares the Register class, members defined in Register.cpp.
\r
8 #ifndef _Register_HPP
\r
9 #define _Register_HPP
\r
11 #include <iostream.h>
\r
14 xxxxADDR defines the base port number used to access VGA component xxxx,
\r
15 and is defined for xxxx =
\r
16 ATTRCON - Attribute Controller
\r
17 MISC - Miscellaneous Register
\r
18 VGAENABLE - VGA Enable Register
\r
20 GRACON - Graphics Controller
\r
21 CRTC - Cathode Ray Tube Controller
\r
22 STATUS - Status Register
\r
25 #define ATTRCON_ADDR 0x3c0
\r
26 #define MISC_ADDR 0x3c2
\r
27 #define VGAENABLE_ADDR 0x3c3
\r
28 #define SEQ_ADDR 0x3c4
\r
29 #define GRACON_ADDR 0x3ce
\r
30 #define CRTC_ADDR 0x3d4
\r
31 #define STATUS_ADDR 0x3da
\r
33 // SVGA specific registers here:
\r
35 #define CHIPSTECH 0x3d6
\r
41 unsigned char index;
\r
42 unsigned char value;
\r
44 Register(unsigned p=0, unsigned char i=0, unsigned char v=0)
\r
46 unsigned char init(unsigned p, unsigned char i, unsigned char v)
\r
47 { port = p; index = i; return value = v; }
\r
48 unsigned char init(Register& r)
\r
49 { port = r.port; index = r.index; return value = r.value; }
\r
50 void setPort(unsigned p) { port = p; }
\r
51 void setIndex(unsigned char i) { index = i; }
\r
52 void setValue(unsigned char v) { value = v; }
\r
53 unsigned getPort(void) const { return port; }
\r
54 unsigned char getIndex(void) const { return index; }
\r
55 unsigned char getValue(void) const { return value; }
\r
56 unsigned char operator++(void) { return value++; }
\r
57 unsigned char operator--(void) { return value--; }
\r
58 unsigned char operator++(int) { return ++value; }
\r
59 unsigned char operator--(int) { return --value; }
\r
60 unsigned char &operator *() { return value; }
\r
61 unsigned char operator=(Register &r)
\r
63 unsigned operator() (int rbit, int len)
\r
64 { return (value >> rbit) & (1 << len)-1; }
\r
69 friend istream& operator>> (istream&, Register&);
\r
70 friend ostream& operator<< (ostream&, Register&);
\r
74 class NamedRegister : public Register
\r
79 NamedRegister() { doEnable(); }
\r
80 ~NamedRegister() { delete name; }
\r
81 void doEnable() { enableFlag = 1; }
\r
82 void doDisable() { enableFlag = 0; }
\r
83 void toggleEnable() { enableFlag = !enableFlag; }
\r
84 char isEnabled() { return enableFlag; }
\r
85 char *getName() { return name; }
\r
88 friend istream& operator>> (istream&, NamedRegister&);
\r