-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathframebuffer.c
69 lines (61 loc) · 1.21 KB
/
framebuffer.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#include <stdio.h>
#include <stdlib.h>
#include "agra.h"
#define FrameWidth 40
#define FrameHeight 20
pixcolor_t * buffer = 0x00000000;
int FrameBufferGetWidth()
{
return FrameWidth;
}
int FrameBufferGetHeight()
{
return FrameHeight;
}
pixcolor_t * FrameBufferGetAddress()
{
if(buffer != 0x00000000) return buffer;
else
{
buffer = (pixcolor_t*) malloc( FrameHeight * FrameWidth * sizeof(pixcolor_t));
return buffer;
};
}
int FrameShow()
{
for(int i = 0; i < FrameHeight; i++)
{
for(int j = 0; j < FrameWidth; j++)
{
int r = buffer[i*FrameWidth+j].r;
int g = buffer[i*FrameWidth+j].g;
int b = buffer[i*FrameWidth+j].b;
if(r > g)
{
if(r > b) printf("R");
else printf("M");
}
else if(b > g)
{
if(b > r) printf("B");
}
else if(r == g && g == b)
{
if(r == 0x0000) printf(" ");
else printf("*");
}
else
{
if(g > b && r > b) printf("Y");
else if( b > r) printf("C");
else printf("G");
};
}
printf("\n");
}
//printf("%d\n", buffer[2*40+25].r);
//printf("%d\n", buffer[2*40+25].g);
//printf("%d\n", buffer[2*40+25].b);
//printf("%d\n", buffer[2*40+25].op);
return 0;
}