-
Notifications
You must be signed in to change notification settings - Fork 6
/
rotozoom.c
88 lines (78 loc) · 2.16 KB
/
rotozoom.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/*
* Displaying a rotating RISCV logo
* Bruno Levy, 2020
*/
#include "GL_tty.h"
/* The RISCV logo, with a tiny resolution
* (remember, I only got 4Kb of RAM
* on the IceStick !)
*/
unsigned char logo[16][16] = {
{7,7,7,7,7,7,5,3,3,3,3,3,3,3,3,7},
{7,7,7,7,7,7,7,5,3,3,3,3,3,3,3,7},
{1,1,1,1,2,7,7,7,3,3,3,3,3,3,3,7},
{0,0,0,0,0,1,7,7,5,3,3,3,3,3,3,7},
{0,0,0,0,0,0,7,7,6,3,3,3,3,3,6,7},
{0,0,0,0,0,0,7,7,5,3,3,3,3,4,7,7},
{0,0,0,0,0,2,7,7,4,3,3,3,3,7,7,7},
{0,2,2,2,7,7,7,6,3,3,3,3,6,7,7,7},
{0,7,7,7,7,7,6,3,3,3,3,5,7,7,2,7},
{0,1,7,7,7,4,3,3,3,3,3,7,7,7,0,7},
{0,0,2,7,7,6,3,3,3,3,6,7,7,1,0,7},
{0,0,0,2,7,7,5,3,3,5,7,7,2,0,0,7},
{0,0,0,0,7,7,7,5,4,7,7,2,0,0,0,7},
{0,0,0,0,0,7,7,7,7,7,7,0,0,0,0,7},
{0,0,0,0,0,1,7,7,7,7,1,0,0,0,0,7},
{7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7}
};
/*
* The colormap.
*/
const char* cmap[8] = {
GL_RGB(040,051,116),
GL_RGB(123,128,155),
GL_RGB(170,172,188),
GL_RGB(249,177,021),
GL_RGB(249,190,101),
GL_RGB(249,199,130),
GL_RGB(252,216,176),
GL_RGB(250,251,248)
};
/*
* Generated by make_sintab.c 64 256
*/
int sintab[64] = {
0,25,49,74,97,120,142,162,181,197,212,225,236,244,251,254,
256,254,251,244,236,225,212,197,181,162,142,120,97,74,49,25,
0,-25,-49,-74,-97,-120,-142,-162,-181,-197,-212,-225,-236,-244,
-251,-254,-256,-254,-251,-244,-236,-225,-212,-197,-181,-162,
-142,-120,-97,-74,-49,-25
};
void main() {
int frame = 0;
for(;;) {
GL_home();
int scaling = (sintab[frame&63]+300)*3;
int Ux = scaling*sintab[frame & 63];
int Uy = scaling*sintab[(frame + 16) & 63];
int Vx = -Uy;
int Vy = Ux;
int X0 = -(GL_width/2)*(Ux+Vx);
int Y0 = -(GL_height/2)*(Uy+Vy);
for(int y=0; y<GL_height; ++y) {
int X = X0;
int Y = Y0;
for(int x=0; x<GL_width; ++x) {
unsigned char col = logo[(Y >> 18)&15][(X >> 18)&15];
GL_setpixelIhere(cmap, col);
X += Ux;
Y += Uy;
}
GL_newline();
X0 += Vx;
Y0 += Vy;
}
++frame;
GL_swapbuffers();
}
}