#include <stdlib.h>
#include <math.h>
#include <assert.h>
-/*#include <imago2.h>*/
+#include "imago2.h"
#include "demo.h"
#include "screen.h"
unsigned char *fog;
float aspect = (float)fb_width / (float)fb_height;
- xsz = fb_width / 2;
+ xsz = fb_width;
ysz = fb_height;
vxsz = xsz * VSCALE;
vysz = ysz * VSCALE;
}
}
- /*if(!(tex_pixels = img_load_pixels(TEX_FNAME, &tex_xsz, &tex_ysz, IMG_FMT_RGBA32))) {
+ if(!(tex_pixels = img_load_pixels(TEX_FNAME, &tex_xsz, &tex_ysz, IMG_FMT_RGBA32))) {
fprintf(stderr, "failed to load image " TEX_FNAME "\n");
return -1;
}
if((count_bits(tex_xsz) | count_bits(tex_ysz)) != 1) {
fprintf(stderr, "non-pow2 image (%dx%d)\n", tex_xsz, tex_ysz);
return -1;
- }*/
+ }
- tex_pixels = gen_test_image(&tex_xsz, &tex_ysz);
+ /*tex_pixels = gen_test_image(&tex_xsz, &tex_ysz);*/
n = count_zeros(tex_xsz);
for(i=0; i<n; i++) {
{
free(tunnel_map);
free(tunnel_fog);
- free(tex_pixels);
+ img_free_pixels(tex_pixels);
}
static void start(long trans_time)
for(i=0; i<NUM_WORK_ITEMS; i++) {
int starty = i * num_lines;
+ int resty = starty + draw_lines;
+ int rest_lines = num_lines - draw_lines;
draw_tunnel_range((unsigned short*)fb_pixels, xoffs, yoffs, starty, draw_lines, time_msec);
+ if(rest_lines) {
+ memset((unsigned short*)fb_pixels + resty * fb_width, 0, rest_lines * fb_width * 2);
+ }
}
}
unsigned int *pixels = (unsigned int*)pix + starty * (fb_width >> 1);
for(i=0; i<num_lines; i++) {
- for(j=0; j<xsz; j++) {
+ for(j=0; j<(xsz>>1); j++) {
unsigned int col;
- int r, g, b;
+ int r, g, b, idx = j << 1;
- tunnel_color(&r, &g, &b, toffs, tmap[j], fog[j]);
+ tunnel_color(&r, &g, &b, toffs, tmap[idx], fog[idx]);
col = PACK_RGB16(r, g, b);
- *pixels++ = (col << 16) | col;
+ tunnel_color(&r, &g, &b, toffs, tmap[idx + 1], fog[idx + 1]);
+ col |= PACK_RGB16(r, g, b) << 16;
+ *pixels++ = col;
}
tmap += vxsz;
fog += vxsz;