Graphics progress
This commit is contained in:
parent
8e0625a750
commit
66076a7076
1 changed files with 35 additions and 4 deletions
|
@ -998,11 +998,41 @@ typedef struct cpu_data {
|
||||||
|
|
||||||
static void draw_callback(GtkWidget *widget, cairo_t *cr, gpointer user_data) {
|
static void draw_callback(GtkWidget *widget, cairo_t *cr, gpointer user_data) {
|
||||||
int x, y;
|
int x, y;
|
||||||
int upscaleFactor = 4;
|
int upscaleFactor = 3;
|
||||||
|
uint8_t *video = malloc(sizeof(uint8_t) * 224 * 256 * 4);
|
||||||
|
|
||||||
|
//ROTATION ALGORITHM
|
||||||
|
for (int i=0; i< 224; i++)
|
||||||
|
{
|
||||||
|
for (int j = 0; j < 256; j+= 8)
|
||||||
|
{
|
||||||
|
int p;
|
||||||
|
//Read the first 1-bit pixel
|
||||||
|
// divide by 8 because there are 8 pixels
|
||||||
|
// in a byte
|
||||||
|
unsigned char pix = bitmap[(i*(256/8)) + j/8];
|
||||||
|
|
||||||
|
//That makes 8 output vertical pixels
|
||||||
|
// we need to do a vertical flip
|
||||||
|
// so j needs to start at the last line
|
||||||
|
// and advance backward through the buffer
|
||||||
|
int offset = (255-j)*(224*4) + (i*4);
|
||||||
|
unsigned int *p1 = (unsigned int*)(&video[offset]);
|
||||||
|
for (p=0; p<8; p++)
|
||||||
|
{
|
||||||
|
if ( 0!= (pix & (1<<p)))
|
||||||
|
*p1 = 1;
|
||||||
|
else
|
||||||
|
*p1 = 0;
|
||||||
|
p1-=224; //next line
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// RENDERING GRAPHICS
|
||||||
|
|
||||||
for (x = 0; x < WIDTH; x++) {
|
for (x = 0; x < 224; x++) {
|
||||||
for (y = 0; y < HEIGHT; y++) {
|
for (y = 0; y < 256; y++) {
|
||||||
if (bitmap[y * WIDTH + x]) {
|
if (video[y * 224 + x]) {
|
||||||
cairo_set_source_rgb(cr, 1.0, 1.0, 1.0); // Set color to white
|
cairo_set_source_rgb(cr, 1.0, 1.0, 1.0); // Set color to white
|
||||||
} else {
|
} else {
|
||||||
cairo_set_source_rgb(cr, 0.0, 0.0, 0.0); // Set color to black
|
cairo_set_source_rgb(cr, 0.0, 0.0, 0.0); // Set color to black
|
||||||
|
@ -1012,6 +1042,7 @@ static void draw_callback(GtkWidget *widget, cairo_t *cr, gpointer user_data) {
|
||||||
cairo_fill(cr);
|
cairo_fill(cr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
free(video);
|
||||||
}
|
}
|
||||||
|
|
||||||
void *cpu(void* arg) {
|
void *cpu(void* arg) {
|
||||||
|
|
Loading…
Reference in a new issue