summaryrefslogtreecommitdiffstats
path: root/src/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c70
1 files changed, 41 insertions, 29 deletions
diff --git a/src/main.c b/src/main.c
index 842a20c..8caab89 100644
--- a/src/main.c
+++ b/src/main.c
@@ -24,10 +24,8 @@ main(void)
struct map *map;
struct area *a;
SDL_Color colors[256];
- struct map_exit *e;
int i;
- Uint32 start, end;
- int x, y;
+ struct map_exit *e;
init();
vp = init_viewport(240, 160, 8);
@@ -61,29 +59,38 @@ main(void)
render_area_to_viewport(a, vp);
{
- float step;
+ Uint32 t;
+ double x;
int y_start, y_end;
- for (step = 0.0; step < 12.57; step += 0.006136) {
+
+ for (t = 0; t <= 2880; t += 5) {
for (i = 0; i < 256; ++i) {
/*
+ * t => [0 .. INF]
+ * t[0 .. 1440] => x[0, 3.14159]
+ * x = (t % 1440) * 3.14159 / 720
+ * y => [y_start, y_end]
* ((cos(x) + 1) / 2) => [0,1]
* y = ((cos(x) + 1) / 2) *
* (y_end - y_start) + y_start
*/
+ x = t % 1440;
+ x = x * 3.14159 / 720;
+
y_start = (i % 8) * 36;
- y_end = y_start / 4;
- colors[i].r = ((cos(step) + 1) / 2) *
+ y_end = y_start * 0.25;
+ colors[i].r = ((cos(x) + 1) / 2) *
(y_end - y_start) + y_start;
y_start = (i % 64 / 8) * 36;
- y_end = y_start / 4;
- colors[i].g = ((cos(step) + 1) / 2) *
+ y_end = y_start * 0.25;
+ colors[i].g = ((cos(x) + 1) / 2) *
(y_end - y_start) + y_start;
y_start = (i / 64) * 85;
- y_end = y_start / 4;
- colors[i].b = ((cos(step) + 1) / 2) *
+ y_end = y_start * 0.375;
+ colors[i].b = ((cos(x) + 1) / 2) *
(y_end - y_start) + y_start;
}
if (!SDL_SetPalette(vp->screen, SDL_LOGPAL, colors, 0, 256)) {
@@ -93,7 +100,6 @@ main(void)
SDL_Delay(10);
}
}
- SDL_Delay(1000);
/* Demo */
for (i = 0; i < 256; ++i) {
@@ -104,23 +110,29 @@ main(void)
if (!SDL_SetPalette(vp->screen, SDL_LOGPAL, colors, 0, 256)) {
warn("Failed to set palette");
}
- i = 0;
- start = SDL_GetTicks();
- x = 19 * map->tilewidth ;
- y = 38 * map->tileheight;
- for (; y > 34 * map->tileheight; y -= 2) DEMO(); /* Up */
- for (; x < 23 * map->tilewidth ; x += 2) DEMO(); /* Right */
- for (; y > 16 * map->tileheight; y -= 2) DEMO(); /* Up */
- for (; x > 15 * map->tilewidth ; x -= 2) DEMO(); /* Left */
- for (; y < 25 * map->tileheight; y += 2) DEMO(); /* Down */
- for (; x > 4 * map->tilewidth ; x -= 2) DEMO(); /* Left */
- for (; y > 18 * map->tileheight; y -= 2) DEMO(); /* Up */
- for (; x < 9 * map->tilewidth ; x += 2) DEMO(); /* Right */
- for (; y > 5 * map->tileheight; y -= 2) DEMO(); /* Up */
- for (; x < 15 * map->tilewidth ; x += 2) DEMO(); /* Right */
- for (; y > 1 * map->tileheight; y -= 2) DEMO(); /* Up */
- end = SDL_GetTicks();
- debug("Rendered %d frames in %d milliseconds", i, end - start);
+
+ {
+ Uint32 start, end;
+ int x, y;
+
+ i = 0;
+ start = SDL_GetTicks();
+ x = 19 * map->tilewidth ;
+ y = 38 * map->tileheight;
+ for (; y > 34 * map->tileheight; y -= 2) DEMO(); /* Up */
+ for (; x < 23 * map->tilewidth ; x += 2) DEMO(); /* Right */
+ for (; y > 16 * map->tileheight; y -= 2) DEMO(); /* Up */
+ for (; x > 15 * map->tilewidth ; x -= 2) DEMO(); /* Left */
+ for (; y < 25 * map->tileheight; y += 2) DEMO(); /* Down */
+ for (; x > 4 * map->tilewidth ; x -= 2) DEMO(); /* Left */
+ for (; y > 18 * map->tileheight; y -= 2) DEMO(); /* Up */
+ for (; x < 9 * map->tilewidth ; x += 2) DEMO(); /* Right */
+ for (; y > 5 * map->tileheight; y -= 2) DEMO(); /* Up */
+ for (; x < 15 * map->tilewidth ; x += 2) DEMO(); /* Right */
+ for (; y > 1 * map->tileheight; y -= 2) DEMO(); /* Up */
+ end = SDL_GetTicks();
+ debug("Rendered %d frames in %d milliseconds", i, end - start);
+ }
quit(0);