21 #include "pedigree/kernel/core/BootIO.h" 25 HostedVga::HostedVga()
26 : m_nWidth(80), m_nHeight(25), m_CursorX(0), m_CursorY(0), m_ModeStack(0),
27 m_nMode(3), m_nControls(0), m_pBackbuffer(0)
31 HostedVga::~HostedVga()
33 delete[] m_pBackbuffer;
38 m_nControls |= 1 <<
static_cast<uint8_t
>(which);
43 m_nControls &= ~(1 <<
static_cast<uint8_t
>(which));
84 size_t thisLen = (m_nWidth * m_nWidth * 2);
85 if (nBufLen > thisLen)
88 MemoryCopy(m_pBackbuffer, pBuffer, nBufLen);
90 size_t savedCursorX = m_CursorX;
91 size_t savedCursorY = m_CursorY;
94 for (
size_t y = 0; y < m_nHeight; ++y)
96 for (
size_t x = 0; x < m_nWidth; ++x)
98 size_t offset = (y * m_nWidth) + x;
99 char c =
static_cast<char>(m_pBackbuffer[offset] & 0xFF);
100 uint8_t attr = (m_pBackbuffer[offset] >> 8) & 0xFF;
116 size_t thisLen = (m_nWidth * m_nWidth * 2);
117 if (nBufLen > thisLen)
119 MemoryCopy(pBuffer, m_pBackbuffer, nBufLen);
129 printf(
"\033[%zu;%zuH", nY, nX);
132 bool HostedVga::initialise()
140 m_pBackbuffer =
new uint16_t[m_nHeight * m_nWidth];
151 case BootIO::DarkGrey:
154 case BootIO::LightBlue:
157 case BootIO::LightGreen:
160 case BootIO::LightCyan:
163 case BootIO::LightRed:
165 case BootIO::Magenta:
166 case BootIO::LightMagenta:
171 case BootIO::LightGrey:
182 uint8_t fore = ansiColourFixup(attr & 0xF);
183 uint8_t back = ansiColourFixup((attr >> 4) & 0xF);
185 uint32_t fore_param = fore > 7 ? 90 + fore : 30 + fore;
186 uint32_t back_param = back > 7 ? 100 + back : 40 + back;
187 printf(
"\033[%d;%dm", fore_param, back_param);
virtual void setControl(VgaControl which)
virtual void clearControl(VgaControl which)
void moveCursor(size_t nX, size_t nY)
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 bool isLargestTextMode()
virtual void restoreMode()
static void printAttrAsAnsi(uint8_t attr)