-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmylib.c
More file actions
100 lines (90 loc) · 2.24 KB
/
Copy pathmylib.c
File metadata and controls
100 lines (90 loc) · 2.24 KB
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#include "mylib.h"
void setPixel(int row, int col, u16 color)
{
videoBuffer[OFFSET(row, col, 240)] = color;
}
void drawRectangle(int x, int y, int width, int height, u16 color) {
for (int i = y; i < height + y; i++) {
for (int j = x; j < width + x; j++) {
videoBuffer[i * 240 + j] = color;
}
}
}
void drawHollowRect(int x, int y, int width, int height, u16 color) {
for (int i = y; i < height + y; i++) {
videoBuffer[i * 240 + x] = color;
videoBuffer[i * 240 + (x + width)] = color;
}
for (int j = x; j < width + x; j++) {
videoBuffer[y * 240 + j] = color;
videoBuffer[(y + height) * 240 + j] = color;
}
}
void drawImage3(int x, int y, int width, int height, const u16* picture) {
int counter = 0;
for (int i = y; i < height + y; i++) {
for (int j = x; j < width + x; j++) {
setPixel(i, j, picture[counter]);
counter++;
}
}
}
void drawBlue(int x, int y, int width, int height) {
int counter = 0;
for (int i = y; i < height + y; i++) {
for (int j = x; j < width + x; j++) {
videoBuffer[i * 240 + j] = BLUE;
counter++;
}
}
}
void drawNoWhite(int x, int y, int width, int height, const u16* picture) {
int counter = 0;
for (int i = y; i < height + y; i++) {
for (int j = x; j < width + x; j++) {
u16 color = picture[counter];
if (color != WHITE) {
videoBuffer[i * 240 + j] = picture[counter];
} else {
videoBuffer[i * 240 + j] = BLUE;
}
counter++;
}
}
}
void drawNoWhiteNoWrap(int x, int y, int width, int height, const u16* picture) {
int counter = 0;
for (int i = y; i < height + y; i++) {
for (int j = x; j < width + x; j++) {
if(i >= 0 && j >=0 && i < 160 && j < 240) {
u16 color = picture[counter];
if (color != WHITE) {
videoBuffer[i * 240 + j] = picture[counter];
} else {
videoBuffer[i * 240 + j] = BLUE;
}
}
counter++;
}
}
}
void drawChar(int row, int col, char ch, u16 color){
int r,c;
for(r=0; r<8; r++){
for(c=0; c<6; c++){
if(fontdata_6x8[OFFSET(r,c,6) + 48*ch]){
setPixel(r + row, c + col, color);
}
}
}
}
void drawString(int row, int col, char *str, u16 color){
int chars_drawn = 0;
while(*str){
drawChar(row, col + 6*chars_drawn++, *str++, color);
}
}
void waitforVBlank() {
while(SCANLINECOUNTER > 1);
while(SCANLINECOUNTER < 1);
}