summaryrefslogtreecommitdiff
path: root/userspace/put_pixel.h
blob: f4b93327f3aca62d7002cb05e006cdb2e8438745 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <stdint.h>

#define VESA_FRAMEBUFFER 0xf6000000
#define VESA_PITCH 2560
#define VESA_BPP 32

// TODO: what will happen in 24bit mode?
static void put_pixel(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>>3)); // 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);
}