27 lines
723 B
C
27 lines
723 B
C
#include <stdint.h>
|
|
|
|
#define CEILDIV(x, y) (((x)+((y)-1))/(y))
|
|
|
|
#if FB_DEPTH==1
|
|
|
|
#define FB_WIDTH_BYTES CEILDIV(FB_WIDTH, 8)
|
|
#define FRAMEBUFFER uint8_t framebuffer[FB_HEIGHT][FB_WIDTH_BYTES];
|
|
#define FB_SET(w,h,c) if (c) { \
|
|
framebuffer[h][w>>3] |= (1 << (w & 7)); \
|
|
} else { \
|
|
framebuffer[h][w>>3] &= ~(1 << (w & 7)); \
|
|
}
|
|
#define FB_CLEAR() memset(framebuffer, 0, sizeof(framebuffer[0][0]) * FB_HEIGHT * FB_WIDTH_BYTES);
|
|
|
|
#elif FB_DEPTH==8
|
|
|
|
#define FRAMEBUFFER uint8_t framebuffer][FB_HEIGHT][FB_WIDTH];
|
|
#define FB_SET(w,h,c) framebuffer[h][w] = c
|
|
#define FB_CLEAR() memset(framebuffer, 0, sizeof(framebuffer[0][0]) * FB_HEIGHT * FB_WIDTH);
|
|
|
|
#endif
|
|
|
|
#ifndef DONT_DECLARE_FRAMEBUFFER
|
|
extern FRAMEBUFFER
|
|
#endif
|