void DrawChar(uint8_t c, uint16_t x, uint16_t y, uint32_t Colour) { if(!Console::IsInitialised()) return; if(!c) return; if(c == ' ') { for(uint64_t i = y; i < y + CharHeight; i++) { Memory::Set32((void*)(Kernel::GetFramebufferAddress() + (i * GetResX() + x) * 4), BackColour, 4); } } uint32_t* rowAddress; uint32_t* columnAddress; rowAddress = (uint32_t *) Kernel::GetFramebufferAddress() + y * GetResX() + x; for(int row = 0; row < CharHeight; row++) { uint8_t data = CurrentFont[c][row]; columnAddress = rowAddress; for(data = CurrentFont[c][row]; data != 0; data <<= 1) { if((data & 0x80) != 0) { *columnAddress = Colour; } columnAddress++; } rowAddress += GetResX(); } }
void ClearScreen() { Memory::Set((uint64_t*) Kernel::GetFramebufferAddress(), 0x00, GetResX() * GetResY() * 4); Memory::Set((uint64_t*) Kernel::GetTrueLFBAddress(), 0x00, GetResX() * GetResY() * 4); VT_CursorX = 0; VT_CursorY = 0; }
void PutPixel(uint16_t x, uint16_t y, uint32_t Colour) { if(x < GetResX() && y < GetResY()) { // Index = (x * width) + y uint32_t pos = y * GetResX() + x; pos *= 4; // 4 bytes per pixel PutPixelAtAddr(pos, Colour); } }
void Initialise() { CharsPerLine = (GetResX() - OffsetLeft) / CharWidth - 1; CharsPerPage = CharsPerLine * (GetResY() / 16) - 1; CharsPerColumn = CharsPerPage / CharsPerLine; VT_DidInit = true; }
// returns the boundaries of the currently visible 16x16 pixel blocks SDL_Rect *Engine::GetVisibleBlockRect(void) { uint32 posx = GetCamera().x < 0 ? 0 : GetCamera().x; uint32 posy = GetCamera().y < 0 ? 0 : GetCamera().y; _visibleBlockRect.x = posx / 16; _visibleBlockRect.y = posy / 16; _visibleBlockRect.w = ((GetResX() + posx) / 16) + 1; _visibleBlockRect.h = ((GetResY() + posy) / 16) + 1; return &_visibleBlockRect; }
void Engine::InitScreen(uint32 sizex, uint32 sizey, uint8 bpp /* = 0 */, uint32 extraflags /* = 0 */) { if(sizex == GetResX() && sizey == GetResY() && (!bpp || bpp == GetBPP()) && ((_screen->flags | extraflags) == _screen->flags)) return; // no change, nothing to do if(_screen) SDL_FreeSurface(_screen); _screenFlags = SDL_HWSURFACE | SDL_DOUBLEBUF | SDL_ANYFORMAT | SDL_HWACCEL | extraflags; _screen = SDL_SetVideoMode(sizex, sizey, bpp, _screenFlags); _screenFlags &= ~SDL_FULLSCREEN; // this depends on current setting and should not be stored _gcnGfx->setTarget(GetSurface()); }
void Scroll() { // asm volatile("cli"); uint64_t x = GetResX(), y = GetResY(); // copy up. Memory::Copy((void*) Kernel::GetFramebufferAddress(), (void*)(Kernel::GetFramebufferAddress() + (x * CharHeight * (BitsPerPixel / 8))), (x * y * (BitsPerPixel / 8)) - (x * CharHeight * (BitsPerPixel / 8))); // delete the last line. Memory::Set((void*)(Kernel::GetFramebufferAddress() + ((x * y * (BitsPerPixel / 8)) - (x * CharHeight * (BitsPerPixel / 8)))), 0x00, x * CharHeight * (BitsPerPixel / 8)); // asm volatile("sti"); }
void Engine::SetResizable(bool b) { if(b == IsResizable()) return; // no change required uint32 flags = _screen->flags | _screenFlags; // toggle between fullscreen, preserving other flags if(b) flags |= SDL_RESIZABLE; // add resizable flag else flags &= ~SDL_RESIZABLE; // remove resizable flag InitScreen(GetResX(), GetResY(), GetBPP(), flags); }
void Engine::SetFullscreen(bool b) { if(b == IsFullscreen()) return; // no change required uint32 flags = _screen->flags | _screenFlags; // toggle between fullscreen, preserving other flags if(b) flags |= SDL_FULLSCREEN; // add fullscreen flag else flags &= ~SDL_FULLSCREEN; // remove fullscreen flag InitScreen(GetResX(), GetResY(), GetBPP(), flags); }
void PrintChar(uint8_t c) { if(c == 0) return; if(SERIALMIRROR){ HardwareAbstraction::Devices::SerialPort::WriteChar(c); } if(!IsInitialised()) { Kernel::HardwareAbstraction::VideoOutput::Console80x25::PrintChar(c); return; } AutoMutex lk = AutoMutex(Mutexes::ConsoleOutput); if(c == '\r') { VT_CursorX = 0; return; } if(c == '\b') { if(VT_CursorX > 0) { VT_CursorX--; DrawChar(' ', (VT_CursorX * CharWidth) + OffsetLeft, (VT_CursorY * 16), VT_Colour); } else if(VT_CursorY > 0) { VT_CursorX = CharsPerLine - 1; VT_CursorY--; DrawChar(' ', (VT_CursorX * CharWidth) + OffsetLeft, (VT_CursorY * 16), VT_Colour); } return; } if(VT_CursorY == CharsPerColumn && VT_CursorX == CharsPerLine) { // Reached end of line and no more space below VT_CursorX = 0; ScrollDown(1); if(c == '\n' || c == '\t') { ScrollDown(1); VT_CursorX = 0; return; } DrawChar(c, (VT_CursorX * CharWidth) + OffsetLeft, (VT_CursorY * 16), VT_Colour); VT_CursorX++; } else if((VT_CursorX * 8) >= ((GetResX()) - 10)) { // Reached end of line VT_CursorX = 0; VT_CursorY++; DrawChar(c, (VT_CursorX * CharWidth) + OffsetLeft, (VT_CursorY * 16), VT_Colour); VT_CursorX = 1; } else { if(c == '\n') { if(VT_CursorY < CharsPerColumn) { VT_CursorX = 0; VT_CursorY++; } else { VT_CursorX = 0; ScrollDown(1); } return; } else if(c == '\t') { if(((VT_CursorX + 4) & ~(4 - 1)) < CharsPerLine) { VT_CursorX = (VT_CursorX + 4) & ~(4 - 1); } else { VT_CursorX = 0; if(VT_CursorY < CharsPerColumn) VT_CursorY++; else ScrollDown(1); } return; } // Normal printing DrawChar(c, (VT_CursorX * CharWidth) + OffsetLeft, (VT_CursorY * 16), VT_Colour); VT_CursorX++; } return; }