41 lines
795 B
C
41 lines
795 B
C
#include "vhex/display.h"
|
|
#include "vhex/defs/types.h"
|
|
|
|
//TODO: dynamic
|
|
extern struct {
|
|
uint32_t width;
|
|
uint32_t height;
|
|
uint32_t pixel[];
|
|
} font8x9;
|
|
|
|
/* dascii() : display one char */
|
|
void dascii(int x, int y, int fg, int bg, int n)
|
|
{
|
|
uint32_t bit;
|
|
uint32_t idx;
|
|
uint32_t bitmap;
|
|
int shift;
|
|
|
|
if (n >= 0x80 || n <= 0x20)
|
|
return;
|
|
n -= 0x20;
|
|
bit = n * font8x9.height * font8x9.width;
|
|
idx = bit / 32;
|
|
shift = bit & 31;
|
|
bitmap = font8x9.pixel[idx];
|
|
for (unsigned int i = 0; i < font8x9.height ; ++i) {
|
|
for (unsigned int j = 0 ; j < font8x9.width ; j++) {
|
|
if ((bitmap & (0x80000000 >> shift)) != 0) {
|
|
dpixel(x + j, y + i, fg);
|
|
} else {
|
|
dpixel(x + j, y + i, bg);
|
|
}
|
|
shift += 1;
|
|
if (shift >= 32) {
|
|
bitmap = font8x9.pixel[++idx];
|
|
shift = 0;
|
|
}
|
|
}
|
|
}
|
|
}
|