X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=bootcensus;a=blobdiff_plain;f=src%2Fcensus%2Fcensus.c;h=724ab2a94f265ec589216eda872c524b6e9416f0;hp=1755133cbf657da5618f00cfa34aa79640ef2ad0;hb=22dd4db1a4ff756f76bdd87062c2252fe3091228;hpb=10843571c724084c68d33d0438167d400cc8de2e diff --git a/src/census/census.c b/src/census/census.c index 1755133..724ab2a 100644 --- a/src/census/census.c +++ b/src/census/census.c @@ -1,11 +1,26 @@ #include #include +#include #include "census.h" +#include "logo.h" +#include "timer.h" #include "3dgfx.h" #include "panic.h" +static void draw_disc(float x, float y, float rad, int sub); +static void draw_line(float x0, float y0, float x1, float y1, float rad); + +static int nverts = 256; +static long start_time; + +#define LOOPTIME 1.45f + void init_census(void *pixels, int xsz, int ysz) { + float aspect = (float)xsz / (float)ysz; + + init_logo(0); + fb_pixels = pixels; fb_width = xsz; fb_height = ysz; @@ -13,31 +28,95 @@ void init_census(void *pixels, int xsz, int ysz) g3d_init(); g3d_framebuffer(xsz, ysz, fb_pixels); g3d_polygon_mode(G3D_FLAT); + g3d_viewport(0, 0, xsz, ysz); + g3d_matrix_mode(G3D_PROJECTION); + g3d_load_identity(); + g3d_scale(1.0f / aspect , 1.0f, 1.0f); + + start_time = TICKS_TO_MSEC(nticks); } void draw_census(void) { int i; + long msec = TICKS_TO_MSEC(nticks); + float t = (float)msec / 1000.0f; + float a[2], b[2], dt; + float anim, alpha, center_alpha; + memset(fb_pixels, 0, fb_width * fb_height * 4); - g3d_matrix_mode(G3D_MODELVIEW); - g3d_load_identity(); + anim = fmod(t / 6.0f, LOOPTIME); + alpha = 1.0f - ((anim - (LOOPTIME - 0.075)) / 0.06f); + if(alpha < 0.0f) alpha = 0.0f; + if(alpha > 1.0f) alpha = 1.0f; + + dt = (anim > 1.0f ? 1.0f : anim) / (float)(nverts - 1); + + g3d_color4f(1, 1, 1, alpha); + for(i=0; i 0.0f) { + eval_logo(a, 0); + draw_disc(a[0], a[1], 0.05, 22); + } + if(anim >= 1.0f) { + eval_logo(b, 1); + draw_disc(b[0], b[1], 0.05, 22); + } + + + center_alpha = 2.0 * (anim - 1.0f) / (LOOPTIME - 1.0f); + if(center_alpha > 0.4) { + g3d_color4f(0.8, 0, 0, center_alpha); + draw_disc(0, 0, 0.14, 30); + } - g3d_enable(G3D_BLEND); +} + +static void draw_disc(float x, float y, float rad, int sub) +{ + int i; + float dt = 1.0f / (float)(sub - 1); + float da = dt * M_PI * 2.0; - g3d_color4b(64, 128, 255, 255); - for(i=0; i<2; i++) { - g3d_begin(G3D_QUADS); - g3d_vertex(-0.4, -0.5, 0); - g3d_vertex(0.6, -0.2, 0); - g3d_vertex(0, 0.8, 0); - g3d_vertex(-0.5, 0.6, 0); - g3d_end(); + g3d_begin(G3D_TRIANGLES); + for(i=0; i