mirror of
https://github.com/Tom-on64/kern.git
synced 2026-11-03 18:22:22 +00:00
Made screen.h use correct resolution instead of assuming
This commit is contained in:
+4
-4
@@ -18,9 +18,9 @@
|
||||
#define rgb(r,g,b) ( ((r) << 16 | (g) << 8 | (b)) & 0x00ffffff )
|
||||
|
||||
void drawPixel(int32_t x, int32_t y, uint32_t color) {
|
||||
uint32_t* vidmem = *(uint32_t**)(MODE_INFO_BLOCK + 40);
|
||||
uint32_t* vidmem = (uint32_t*)gfxMode->physicalBasePtr;
|
||||
|
||||
uint32_t offset = (y * WIDTH) + x;
|
||||
uint32_t offset = (y * gfxMode->xRes) + x;
|
||||
vidmem[offset] = color;
|
||||
}
|
||||
|
||||
@@ -96,9 +96,9 @@ void drawCircle(int32_t x, int32_t y, uint16_t radius, uint32_t color) {
|
||||
|
||||
// Recursive (may need large stack)
|
||||
void boundaryFill(int32_t x, int32_t y, uint32_t fillColor, uint32_t boundaryColor) {
|
||||
uint32_t* vidmem = *(uint32_t**)(MODE_INFO_BLOCK + 40);
|
||||
uint32_t* vidmem = (uint32_t*)gfxMode->physicalBasePtr;
|
||||
|
||||
uint32_t offset = y * WIDTH + x;
|
||||
uint32_t offset = y * gfxMode->xRes + x;
|
||||
|
||||
if (vidmem[offset] != fillColor && vidmem[offset] != boundaryColor) {
|
||||
vidmem[offset] = fillColor;
|
||||
|
||||
+64
-8
@@ -4,24 +4,80 @@
|
||||
#include "stdint.h"
|
||||
|
||||
#define MODE_INFO_BLOCK 0x5000
|
||||
#define WIDTH 1920
|
||||
#define HEIGHT 1080
|
||||
#define BG_COLOR 0xff010b17
|
||||
#define FG_COLOR 0xffebddf4
|
||||
|
||||
typedef struct modeInfoBlock_s {
|
||||
// Required by all VBE revisions
|
||||
uint16_t modeAttr;
|
||||
uint8_t windowAAtrr;
|
||||
uint8_t windowBAttr;
|
||||
uint16_t windowGranularity;
|
||||
uint16_t windowSize;
|
||||
uint16_t windowASegment;
|
||||
uint16_t windowBSegment;
|
||||
uint32_t windowFunctionPtr;
|
||||
uint16_t bytesPerScanline;
|
||||
|
||||
// Required by VBE 1.2+
|
||||
uint16_t xRes;
|
||||
uint16_t yRes;
|
||||
uint8_t xCharSize;
|
||||
uint8_t yCharSize;
|
||||
uint8_t planeCount;
|
||||
uint8_t bpp;
|
||||
uint8_t bankCount;
|
||||
uint8_t memoryModel;
|
||||
uint8_t bankSize;
|
||||
uint8_t imagePageCount;
|
||||
uint8_t reserved1;
|
||||
|
||||
// Direct color fields
|
||||
uint8_t redMaskSize;
|
||||
uint8_t redFieldPos;
|
||||
uint8_t greenMaskSize;
|
||||
uint8_t greenFieldPos;
|
||||
uint8_t blueMaskSize;
|
||||
uint8_t blueFieldPos;
|
||||
uint8_t reservedMaskSize;
|
||||
uint8_t reservedFieldPos;
|
||||
uint8_t directColorModeInfo;
|
||||
|
||||
// Required by VBE 2.0+
|
||||
uint32_t physicalBasePtr;
|
||||
uint32_t reserved2;
|
||||
uint16_t reserved3;
|
||||
|
||||
// Required by VBE 3.0+
|
||||
uint16_t linearBytesPerScanline;
|
||||
uint8_t bankImagePageCount;
|
||||
uint8_t linearImagePageCount;
|
||||
uint8_t linearRedMaskSize;
|
||||
uint8_t linearRedFieldPos;
|
||||
uint8_t linearGreenMaskSize;
|
||||
uint8_t linearGreenFieldPos;
|
||||
uint8_t linearBlueMaskSize;
|
||||
uint8_t linearBlueFieldPos;
|
||||
uint8_t linearReservedMaskSize;
|
||||
uint8_t linearReservedFieldPos;
|
||||
uint32_t maxPixelClock;
|
||||
|
||||
uint8_t reserved4[190];
|
||||
} __attribute__ ((packed)) modeInfoBlock_t;
|
||||
|
||||
struct cursor_s {
|
||||
uint32_t x;
|
||||
uint32_t y;
|
||||
};
|
||||
|
||||
static char* font = (char*)0x6000;
|
||||
|
||||
static struct cursor_s cursor = { 0, 0 };
|
||||
static modeInfoBlock_t* gfxMode = (modeInfoBlock_t*)MODE_INFO_BLOCK;
|
||||
|
||||
// TODO: Probably make the font bigger in a better way, but this works for now
|
||||
void putcAt(unsigned char c, uint32_t x, uint32_t y) {
|
||||
uint32_t* vidmem = *(uint32_t**)(MODE_INFO_BLOCK + 40);
|
||||
uint32_t offset = (WIDTH * y * 16 + x * 8) * 2;
|
||||
uint32_t* vidmem = (uint32_t*)gfxMode->physicalBasePtr;
|
||||
uint32_t offset = (gfxMode->xRes * y * 16 + x * 8) * 2;
|
||||
|
||||
char* bitmap = &font[((c % 128) - 1) * 16];
|
||||
for (uint8_t i = 0; i < 32; i++) { // Rows (16*2 since we draw font 2x larger)
|
||||
@@ -34,7 +90,7 @@ void putcAt(unsigned char c, uint32_t x, uint32_t y) {
|
||||
}
|
||||
}
|
||||
|
||||
offset += WIDTH;
|
||||
offset += gfxMode->xRes;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,10 +123,10 @@ void print(const char* str) {
|
||||
}
|
||||
|
||||
void clear() {
|
||||
uint32_t* vidmem = *(uint32_t**)(MODE_INFO_BLOCK + 40);
|
||||
uint32_t* vidmem = (uint32_t*)gfxMode->physicalBasePtr;
|
||||
|
||||
size_t i = 0;
|
||||
while (i < WIDTH*HEIGHT) {
|
||||
while (i < gfxMode->xRes * gfxMode->yRes) {
|
||||
vidmem[i] = BG_COLOR; // #1f2937
|
||||
i++;
|
||||
}
|
||||
|
||||
+3
-4
@@ -252,7 +252,6 @@ protected_start:
|
||||
mov esi, modeInfoBlock
|
||||
mov edi, 0x5000 ; Destination
|
||||
mov ecx, 64 ; 64 * 4 = 256B (size of modeInfoBlock)
|
||||
|
||||
rep movsd
|
||||
|
||||
; Perform The far jump
|
||||
@@ -360,9 +359,9 @@ modeInfoBlock:
|
||||
.directColorModeInfo: db 0
|
||||
|
||||
;; Required by VBE 2.0+
|
||||
.physicalAddressPtr: dd 0
|
||||
.reserved2: db 0
|
||||
.reserved3: db 0
|
||||
.physicalBasePtr: dd 0
|
||||
.reserved2: dd 0
|
||||
.reserved3: dw 0
|
||||
|
||||
;; Required by VBE 3.0+
|
||||
.linearBytesPerScanline: dw 0
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
- [x] Multistage Bootloader
|
||||
- [ ] Bootloader reads filetable to find files
|
||||
- [ ] Makefile refactorin'
|
||||
- [x] Write down where stuff is in memory
|
||||
- [x] Write down where stuff is in memory (in notes.txt)
|
||||
- [ ] "Text" mode (not actually)
|
||||
- [ ] Scrolling
|
||||
- [ ] Scroll-back
|
||||
@@ -15,6 +15,7 @@
|
||||
- [x] Larger text size
|
||||
- [ ] Variable text size :)
|
||||
- [ ] Make output overflow go to next line
|
||||
- [ ] More fonts
|
||||
- [x] Graphics
|
||||
- [?] Enter/exit a "graphics" mode (idk if we need this)
|
||||
- [x] Pixel drawing
|
||||
|
||||
Reference in New Issue
Block a user