X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Fscr%2Fbump.c;h=2761c7d5e9390f39ef6ec24ae0aebb0491560129;hb=42675cece161caf9c65b1c944df2df4b1aacec81;hp=b82594ba536a0e46b6a20395b2b7662bd182c0d4;hpb=ba648ddfc62fc6d3f47294aa8bfc10ea6ca3f479;p=dosdemo diff --git a/src/scr/bump.c b/src/scr/bump.c index b82594b..2761c7d 100644 --- a/src/scr/bump.c +++ b/src/scr/bump.c @@ -1,4 +1,4 @@ -// Bump effect (not moving yet of course, I have many ideas on this to commit before it's ready) +/* Bump effect (not moving yet of course, I have many ideas on this to commit before it's ready) */ #include #include @@ -62,10 +62,11 @@ static int init(void) const int bigLightSize = BIG_LIGHT_WIDTH * BIG_LIGHT_HEIGHT; const int particleLightSize = PARTICLE_LIGHT_WIDTH * PARTICLE_LIGHT_HEIGHT; - const int fb_size = fb_width * fb_height; + const int fb_size = FB_WIDTH * FB_HEIGHT; - // Just some parameters to temporary test the colors of 3 lights - // if every light uses it's own channel bits, it's better + /* Just some parameters to temporary test the colors of 3 lights + * if every light uses it's own channel bits, it's better + */ const float rgbMul[9] = { 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f}; @@ -83,40 +84,40 @@ static int init(void) memset(bumpOffset, 0, sizeof(*bumpOffset) * fb_size); memset(particlePoint, 0, sizeof(*particlePoint) * NUM_PARTICLES); - // Create random junk + /* Create random junk */ for (i = 0; i < fb_size; i++) heightmap[i] = rand() & 255; - // Blur to smooth + /* Blur to smooth */ for (j = 0; j < numBlurs; j++) for (i = 0; i < fb_size; i++) - heightmap[i] = (heightmap[abs((i - 1) % fb_size)] + heightmap[abs((i + 1) % fb_size)] + heightmap[abs((i - fb_width) % fb_size)] + heightmap[abs((i + fb_width) % fb_size)]) >> 2; + heightmap[i] = (heightmap[abs((i - 1) % fb_size)] + heightmap[abs((i + 1) % fb_size)] + heightmap[abs((i - FB_WIDTH) % fb_size)] + heightmap[abs((i + FB_WIDTH) % fb_size)]) >> 2; - // Inclination precalculation + /* Inclination precalculation */ i = 0; - for (y = 0; y < fb_height; y++) + for (y = 0; y < FB_HEIGHT; y++) { - for (x = 0; x < fb_width; x++) + for (x = 0; x < FB_WIDTH; x++) { const float offsetPower = 0.75f; int dx, dy, xp, yp; dx = i < fb_size - 1 ? (int)((heightmap[i] - heightmap[i + 1]) * offsetPower) : 0; - dy = i < fb_size - fb_width ? (int)((heightmap[i] - heightmap[i + fb_width]) * offsetPower) : 0; + dy = i < fb_size - FB_WIDTH ? (int)((heightmap[i] - heightmap[i + FB_WIDTH]) * offsetPower) : 0; xp = x + dx; if (xp < 0) xp = 0; - if (xp > fb_width - 1) xp = fb_width - 1; + if (xp > FB_WIDTH - 1) xp = FB_WIDTH - 1; yp = y + dy; if (yp < 0) yp = 0; - if (yp > fb_height - 1) yp = fb_height - 1; + if (yp > FB_HEIGHT - 1) yp = FB_HEIGHT - 1; - bumpOffset[i++] = yp * fb_width + xp; + bumpOffset[i++] = yp * FB_WIDTH + xp; } } - // Generate three lights + /* Generate three lights */ i = 0; for (y = 0; y < BIG_LIGHT_HEIGHT; y++) { @@ -181,12 +182,12 @@ static void eraseArea(struct point *p, int width, int height) if (x0 < 0) x0 = 0; if (y0 < 0) y0 = 0; - if (x1 > fb_width) x1 = fb_width; - if (y1 > fb_height) y1 = fb_height; + if (x1 > FB_WIDTH) x1 = FB_WIDTH; + if (y1 > FB_HEIGHT) y1 = FB_HEIGHT; dx = x1 - x0; - dst = lightmap + y0 * fb_width + x0; + dst = lightmap + y0 * FB_WIDTH + x0; for (y = y0; y < y1; y++) { @@ -194,7 +195,7 @@ static void eraseArea(struct point *p, int width, int height) { *dst++ = 0; } - dst += fb_width - dx; + dst += FB_WIDTH - dx; } } @@ -224,12 +225,12 @@ static void renderLight(struct point *p, int width, int height, unsigned short * y0 = 0; } - if (x1 > fb_width) x1 = fb_width; - if (y1 > fb_height) y1 = fb_height; + if (x1 > FB_WIDTH) x1 = FB_WIDTH; + if (y1 > FB_HEIGHT) y1 = FB_HEIGHT; dx = x1 - x0; - dst = lightmap + y0 * fb_width + x0; + dst = lightmap + y0 * FB_WIDTH + x0; src = light + yl * width + xl; for (y = y0; y < y1; y++) @@ -238,7 +239,7 @@ static void renderLight(struct point *p, int width, int height, unsigned short * { *dst++ |= *src++; } - dst += fb_width - dx; + dst += FB_WIDTH - dx; src += width - dx; } } @@ -271,8 +272,8 @@ static void animateLights() float tt = 1.0f - sin(dt); float disperse = tt * 64.0f; - center.x = (fb_width >> 1) - (BIG_LIGHT_WIDTH / 2); - center.y = (fb_height >> 1) - (BIG_LIGHT_HEIGHT / 2); + center.x = (FB_WIDTH >> 1) - (BIG_LIGHT_WIDTH / 2); + center.y = (FB_HEIGHT >> 1) - (BIG_LIGHT_HEIGHT / 2); bigLightPoint[0].x = center.x + sin(1.2f * dt) * (144.0f + disperse); bigLightPoint[0].y = center.y + sin(0.8f * dt) * (148.0f + disperse); @@ -287,7 +288,7 @@ static void animateLights() static void renderBump(unsigned short *vram) { int i; - for (i = 0; i < fb_width * fb_height; i++) + for (i = 0; i < FB_WIDTH * FB_HEIGHT; i++) { unsigned short c = lightmap[bumpOffset[i]]; *vram++ = c; @@ -301,8 +302,8 @@ static void animateParticles() float dt = (float)(time_msec - startingTime) / 2000.0f; float tt = sin(dt); - center.x = (fb_width >> 1) - (PARTICLE_LIGHT_WIDTH / 2); - center.y = (fb_height >> 1) - (PARTICLE_LIGHT_HEIGHT / 2); + center.x = (FB_WIDTH >> 1) - (PARTICLE_LIGHT_WIDTH / 2); + center.y = (FB_HEIGHT >> 1) - (PARTICLE_LIGHT_HEIGHT / 2); for (i = 0; i < NUM_PARTICLES; i++) { @@ -313,9 +314,9 @@ static void animateParticles() static void draw(void) { - memset(lightmap, 0, fb_width * fb_height * sizeof(*lightmap)); + memset(lightmap, 0, FB_WIDTH * FB_HEIGHT * sizeof(*lightmap)); - //eraseLights(); + /*eraseLights();*/ animateLights(); renderLights();