The Pedigree Project  0.1
kernel/machine/hosted/Vga.h
1 /*
2  * Copyright (c) 2008-2014, Pedigree Developers
3  *
4  * Please see the CONTRIB file in the root of the source tree for a full
5  * list of contributors.
6  *
7  * Permission to use, copy, modify, and distribute this software for any
8  * purpose with or without fee is hereby granted, provided that the above
9  * copyright notice and this permission notice appear in all copies.
10  *
11  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18  */
19 
20 #ifndef MACHINE_HOSTED_VGA_H
21 #define MACHINE_HOSTED_VGA_H
22 
23 #include "pedigree/kernel/machine/Vga.h"
24 
28 class HostedVga : public Vga
29 {
30  public:
31  HostedVga();
32  virtual ~HostedVga();
33 
37  virtual void setControl(VgaControl which);
38 
42  virtual void clearControl(VgaControl which);
43 
44  virtual bool setMode(int mode);
45 
50  virtual bool setLargestTextMode();
51 
56  virtual bool
57  isMode(size_t nCols, size_t nRows, bool bIsText, size_t nBpp = 0);
58 
63  virtual bool isLargestTextMode();
64 
68  virtual size_t getNumCols()
69  {
70  return m_nWidth;
71  }
72 
76  virtual size_t getNumRows()
77  {
78  return m_nHeight;
79  }
80 
84  virtual void rememberMode();
85 
89  virtual void restoreMode();
90 
101  virtual void pokeBuffer(uint8_t *pBuffer, size_t nBufLen);
102 
112  virtual void peekBuffer(uint8_t *pBuffer, size_t nBufLen);
113 
119  virtual void moveCursor(size_t nX, size_t nY);
120 
121  bool initialise();
122 
123  operator uint16_t *() const
124  {
125  return m_pBackbuffer;
126  }
127 
128  private:
129  HostedVga(const HostedVga &);
130  HostedVga &operator=(const HostedVga &);
131 
135  static void printAttrAsAnsi(uint8_t attr);
136 
140  static uint8_t ansiColourFixup(uint8_t colour);
141 
145  size_t m_nWidth;
146 
150  size_t m_nHeight;
151 
155  size_t m_CursorX;
156 
160  size_t m_CursorY;
161 
169 
173  int m_nMode;
174 
178  uint8_t m_nControls;
179 
183  uint16_t *m_pBackbuffer;
184 };
185 
186 #endif
virtual void setControl(VgaControl which)
virtual void clearControl(VgaControl which)
virtual size_t getNumCols()
virtual bool isMode(size_t nCols, size_t nRows, bool bIsText, size_t nBpp=0)
virtual void peekBuffer(uint8_t *pBuffer, size_t nBufLen)
virtual void rememberMode()
static uint8_t ansiColourFixup(uint8_t colour)
virtual void moveCursor(size_t nX, size_t nY)
virtual void pokeBuffer(uint8_t *pBuffer, size_t nBufLen)
virtual bool setMode(int mode)
virtual bool setLargestTextMode()
virtual size_t getNumRows()
virtual bool isLargestTextMode()
virtual void restoreMode()
static void printAttrAsAnsi(uint8_t attr)