kernel/src/framebuffer.c

25 lines
818 B
C

#include "framebuffer.h"
static unsigned long fb_address;
static unsigned long fb_pitch;
static unsigned short fb_width, fb_height;
static unsigned char fb_bpp, fb_bytespp;
static unsigned char fb_rpos, fb_bpos, fb_gpos;
void initfb(unsigned long addr, unsigned short w, unsigned short h, unsigned char bpp, unsigned long pitch, unsigned char rpos, unsigned char gpos, unsigned char bpos) {
fb_address = addr;
fb_pitch = pitch;
fb_width = w;
fb_height = h;
fb_bpp = bpp;
fb_bytespp = bpp/8;
fb_rpos = rpos;
fb_gpos = gpos;
fb_bpos = bpos;
}
void putpixel(unsigned short x, unsigned short y, unsigned char r, unsigned char g, unsigned char b, unsigned char a) {
if (x>fb_width || y> fb_height) return;
*((unsigned long *)(fb_address + y*fb_pitch + x*fb_bytespp)) = r<<fb_rpos | g<<fb_gpos | b<<fb_bpos;
}