… | |
… | |
32 | #include <cstring> |
32 | #include <cstring> |
33 | #include <cstdio> |
33 | #include <cstdio> |
34 | #include <cstdlib> |
34 | #include <cstdlib> |
35 | |
35 | |
36 | #include <utility> |
36 | #include <utility> |
|
|
37 | #include <bitset> |
37 | |
38 | |
38 | #define USE_RWOPS 1 // for SDL_mixer:LoadMUS_RW |
39 | #define USE_RWOPS 1 // for SDL_mixer:LoadMUS_RW |
39 | |
40 | |
40 | #include <SDL.h> |
41 | #include <SDL.h> |
41 | #include <SDL_thread.h> |
42 | #include <SDL_thread.h> |
… | |
… | |
2223 | draw (DC::Map self, int mx, int my, int sw, int sh, int Tw, int Th, U32 player = 0xffffffff, int sdx = 0, int sdy = 0) |
2224 | draw (DC::Map self, int mx, int my, int sw, int sh, int Tw, int Th, U32 player = 0xffffffff, int sdx = 0, int sdy = 0) |
2224 | CODE: |
2225 | CODE: |
2225 | { |
2226 | { |
2226 | int x, y, z; |
2227 | int x, y, z; |
2227 | |
2228 | |
2228 | uint32_t smooth_level[256 / 32]; // one bit for every possible smooth level |
|
|
2229 | static uint8_t smooth_max[256][256]; // egad, fast and wasteful on memory (64k) |
2229 | static uint8_t smooth_max[256][256]; // egad, fast and wasteful on memory (64k), also, static! |
2230 | smooth_key skey; |
|
|
2231 | int pl_x, pl_y; |
2230 | int pl_x, pl_y; |
2232 | maptex pl_tex; |
2231 | maptex pl_tex; |
2233 | rc_t *rc = rc_alloc (); |
2232 | rc_t *rc = rc_alloc (); |
2234 | rc_t *rc_ov = rc_alloc (); |
2233 | rc_t *rc_ov = rc_alloc (); |
2235 | rc_key_t key; |
2234 | rc_key_t key; |
… | |
… | |
2238 | pl_tex.name = 0; |
2237 | pl_tex.name = 0; |
2239 | |
2238 | |
2240 | // that's current max. sorry. |
2239 | // that's current max. sorry. |
2241 | if (sw > 255) sw = 255; |
2240 | if (sw > 255) sw = 255; |
2242 | if (sh > 255) sh = 255; |
2241 | if (sh > 255) sh = 255; |
2243 | |
|
|
2244 | // clear key, in case of extra padding |
|
|
2245 | memset (&skey, 0, sizeof (skey)); |
|
|
2246 | |
2242 | |
2247 | memset (&key, 0, sizeof (key)); |
2243 | memset (&key, 0, sizeof (key)); |
2248 | key.r = 255; |
2244 | key.r = 255; |
2249 | key.g = 255; |
2245 | key.g = 255; |
2250 | key.b = 255; |
2246 | key.b = 255; |
… | |
… | |
2256 | my += self->y; |
2252 | my += self->y; |
2257 | |
2253 | |
2258 | // first pass: determine smooth_max |
2254 | // first pass: determine smooth_max |
2259 | // rather ugly, if you ask me |
2255 | // rather ugly, if you ask me |
2260 | // could also be stored inside mapcell and updated on change |
2256 | // could also be stored inside mapcell and updated on change |
2261 | memset (smooth_max, 0, sizeof (smooth_max)); |
2257 | memset (smooth_max, 0, sizeof (smooth_max[0]) * (sh + 1)); |
2262 | |
2258 | |
2263 | for (y = 0; y < sh; y++) |
2259 | for (y = 0; y < sh; y++) |
2264 | if (0 <= y + my && y + my < self->rows) |
2260 | if (0 <= y + my && y + my < self->rows) |
2265 | { |
2261 | { |
2266 | maprow *row = self->row + (y + my); |
2262 | maprow *row = self->row + (y + my); |
… | |
… | |
2281 | glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
2277 | glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
2282 | glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); |
2278 | glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); |
2283 | |
2279 | |
2284 | for (z = 0; z <= 2; z++) |
2280 | for (z = 0; z <= 2; z++) |
2285 | { |
2281 | { |
|
|
2282 | uint32_t smooth_level[256 / 32]; // one bit for every possible smooth level |
|
|
2283 | smooth_key skey; |
2286 | smooth_hash smooth; |
2284 | smooth_hash smooth; |
2287 | memset (smooth_level, 0, sizeof (smooth_level)); |
2285 | memset (smooth_level, 0, sizeof (smooth_level)); |
2288 | key.texname = -1; |
2286 | key.texname = -1; |
2289 | |
2287 | |
2290 | for (y = 0; y < sh; y++) |
2288 | for (y = 0; y < sh; y++) |