projects
/
dosdemo
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fixed mklibs.bat unix line endings, and added pull.bat
[dosdemo]
/
src
/
tunnel.c
diff --git
a/src/tunnel.c
b/src/tunnel.c
index
4662420
..
13eea70
100644
(file)
--- a/
src/tunnel.c
+++ b/
src/tunnel.c
@@
-1,8
+1,9
@@
#include <stdio.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include <math.h>
#include <assert.h>
#include <math.h>
#include <assert.h>
-/*#include <imago2.h>*/
+#include "imago2.h"
#include "demo.h"
#include "screen.h"
#include "demo.h"
#include "screen.h"
@@
-64,7
+65,7
@@
static int init(void)
unsigned char *fog;
float aspect = (float)fb_width / (float)fb_height;
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;
ysz = fb_height;
vxsz = xsz * VSCALE;
vysz = ysz * VSCALE;
@@
-102,16
+103,16
@@
static int init(void)
}
}
}
}
- /*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;
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++) {
n = count_zeros(tex_xsz);
for(i=0; i<n; i++) {
@@
-132,7
+133,7
@@
static void destroy(void)
{
free(tunnel_map);
free(tunnel_fog);
{
free(tunnel_map);
free(tunnel_fog);
- free(tex_pixels);
+ img_free_pixels(tex_pixels);
}
static void start(long trans_time)
}
static void start(long trans_time)
@@
-181,7
+182,12
@@
static void draw(void)
for(i=0; i<NUM_WORK_ITEMS; i++) {
int starty = i * num_lines;
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);
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);
+ }
}
}
}
}
@@
-222,13
+228,15
@@
static void draw_tunnel_range(unsigned short *pix, int xoffs, int yoffs, int sta
unsigned int *pixels = (unsigned int*)pix + starty * (fb_width >> 1);
for(i=0; i<num_lines; i++) {
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;
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);
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;
}
tmap += vxsz;
fog += vxsz;