--- /dev/null
+#define FONT_WIDTH 8
+#define FONT_HEIGHT 16
+extern uint8_t Font[];
+
+struct Video {
+ uint32_t* buffer;
+ uint32_t stride;
+};
+
+extern struct Video Video;
+
+void Video_Init(void);
+void Video_PutGlyph(int x, int y, char c);
+
+static inline void Video_PutPixel(int x, int y, uint32_t pixel)
+{
+ Video.buffer[Video.stride * y + x] = pixel;
+}
+
+void Term_Clear(void);
+void Term_PutChar(int c);
+void Term_PutString(char* s);
+void Term_PutInt(int64_t val);
+void Term_PutHex(uint64_t val);
+void Term_PutHex8(uint8_t val);
+void Term_PutHex16(uint16_t val);
+void Term_PutHex32(uint32_t val);
+void Term_PutHex64(uint64_t val);
+void Term_PutNewline(void);
#include <uefi.h>
-
-static void PutIntField(char* label, int val)
-{
- Term_PutString(label);
- Term_PutInt(val);
- Term_PutNewline();
-}
+#include <kernel.h>
int main (int argc, char** argv)
{
Video_Init();
-//
-// char glyph = 0;
-// for (int y = 0; y < 16; y++)
-// {
-// for (int x = 0; x < 16; x++)
-// {
-// Video_PutGlyph(
-// x,
-// y,
-// glyph++
-// );
-// }
-// }
+
+ char glyph = 0;
+ for (int y = 0; y < 16; y++)
+ {
+ for (int x = 0; x < 16; x++)
+ {
+ Video_PutGlyph(
+ x,
+ y,
+ glyph++
+ );
+ }
+ }
/* loop forever */
for (;;)
{
+ Term_PutString(".");
BS->Stall(1000000);
}
#define min(x,y) ((x)<(y)?(x):(y))
#define max(x,y) ((x)>(y)?(x):(y))
-#define FONT_WIDTH 8
-#define FONT_HEIGHT 16
-extern uint8_t Font[];
-
-extern uint32_t* VideoMem;
-extern uint32_t VideoStride;
-
-void Video_Init(void);
-void Video_PutGlyph(int x, int y, char c);
-
-static inline void Video_PutPixel(int x, int y, uint32_t pixel)
-{
- int offset = (sizeof(pixel) * VideoStride * y) + (sizeof(pixel) * x);
- *(VideoMem + offset) = pixel;
-}
-
-void Term_Clear(void);
-void Term_PutChar(int c);
-void Term_PutString(char* s);
-void Term_PutInt(int64_t val);
-void Term_PutHex(uint64_t val);
-void Term_PutHex8(uint8_t val);
-void Term_PutHex16(uint16_t val);
-void Term_PutHex32(uint32_t val);
-void Term_PutHex64(uint64_t val);
-void Term_PutNewline(void);
-
#ifdef __cplusplus
}
#endif
#include <uefi.h>
+#include <kernel.h>
-uint32_t* VideoMem = NULL;
-uint32_t VideoStride = 0;
+struct Video Video;
void Video_Init(void)
{
if (status == EFI_SUCCESS)
{
status = gop->SetMode(gop, 17); /* pick a smaller resolution for QEMU */
-// status = gop->SetMode(gop, gop->Mode->MaxMode-1);
+// status = gop->SetMode(gop, gop->Mode->MaxMode - 1);
}
/*
Now let's save off the info we need to draw pixels and glyphs.
The code in this file assumes 32 bits per pixel.
*/
- VideoMem = (uint32_t*)(gop->Mode->FrameBufferBase);
- VideoStride = gop->Mode->Information->PixelsPerScanLine;
+ Video.buffer = (uint32_t*)(gop->Mode->FrameBufferBase);
+ Video.stride = gop->Mode->Information->PixelsPerScanLine;
}
void Video_PutGlyph(int x, int y, char c)