blob: 445e8906f6c5557837d884579a75a82793f4af9a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
#include <stdint.h>
#define VESA_FRAMEBUFFER 0xfa000000
#define VESA_PITCH 2560
#define VESA_BPP 4
//https://forum.osdev.org/viewtopic.php?t=10018&p=64358
// TODO: what will happen in 24bit mode?
/*
volatile int c;
int delay()
{
c++;
}
*/
void put_rect(int x,int y, int w, int h,uint32_t col)
{
// start
uint8_t *p=VESA_FRAMEBUFFER+y*VESA_PITCH+x*VESA_BPP;
uint32_t *pix=p;
for(int yy=y; yy<y+h; yy++) // iter over lines
{
for(int xx=x; xx<x+w; xx++) // single line
{
*pix=col;
pix++;
}
pix+=640-w;
}
}
void put_pixel(int x,int y, uint32_t color)
{
uint8_t *p=VESA_FRAMEBUFFER+y*VESA_PITCH+x*VESA_BPP;
uint32_t *pix=p;
*pix=color;
}
void put_pixel_old(int x,int y, int color)
{
//do not write memory outside the screen buffer, check parameters against the VBE mode info
// if (x<0 || x>vesaXres|| y<0 || y>vesaYres) return;
if (x) x = (x*VESA_BPP); // get bytes (divide by 8)
if (y) y = (y*VESA_PITCH);
//uint8_t *cTemp=VbeModeInfoBlock->physbase;
uint8_t *cTemp=VESA_FRAMEBUFFER;
cTemp[x+y] = (uint8_t)(color & 0xff);
cTemp[x+y+1] = (uint8_t)((color>>8) & 0xff);
cTemp[x+y+2] = (uint8_t)((color>>16) & 0xff);
}
|