… | |
… | |
92 | |
92 | |
93 | /* mask out modifiers we are not interested in */ |
93 | /* mask out modifiers we are not interested in */ |
94 | #define MOD_MASK (KMOD_CTRL | KMOD_SHIFT | KMOD_ALT | KMOD_META) |
94 | #define MOD_MASK (KMOD_CTRL | KMOD_SHIFT | KMOD_ALT | KMOD_META) |
95 | |
95 | |
96 | #define KMOD_LRAM 0x10000 // our extension |
96 | #define KMOD_LRAM 0x10000 // our extension |
|
|
97 | |
|
|
98 | #define TEXID_SPEECH 1 |
|
|
99 | #define TEXID_NOFACE 2 |
|
|
100 | #define TEXID_HIDDEN 3 |
97 | |
101 | |
98 | static AV *texture_av; |
102 | static AV *texture_av; |
99 | |
103 | |
100 | static struct |
104 | static struct |
101 | { |
105 | { |
… | |
… | |
2005 | uint32_t smooth_level[256 / 32]; // one bit for every possible smooth level |
2009 | uint32_t smooth_level[256 / 32]; // one bit for every possible smooth level |
2006 | static uint8_t smooth_max[256][256]; // egad, fast and wasteful on memory (64k) |
2010 | static uint8_t smooth_max[256][256]; // egad, fast and wasteful on memory (64k) |
2007 | smooth_key skey; |
2011 | smooth_key skey; |
2008 | int pl_x, pl_y; |
2012 | int pl_x, pl_y; |
2009 | maptex pl_tex; |
2013 | maptex pl_tex; |
2010 | rc_t *rc = rc_alloc (); |
2014 | rc_t *rc = rc_alloc (); |
|
|
2015 | rc_t *rc_ov = rc_alloc (); |
2011 | rc_key_t key; |
2016 | rc_key_t key; |
2012 | rc_array_t *arr; |
2017 | rc_array_t *arr, *arr_hidden; |
2013 | |
2018 | |
2014 | pl_tex.name = 0; |
2019 | pl_tex.name = 0; |
2015 | |
2020 | |
2016 | // thats current max. sorry. |
2021 | // thats current max. sorry. |
2017 | if (sw > 255) sw = 255; |
2022 | if (sw > 255) sw = 255; |
… | |
… | |
2054 | } |
2059 | } |
2055 | |
2060 | |
2056 | glEnable (GL_BLEND); |
2061 | glEnable (GL_BLEND); |
2057 | glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
2062 | glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
2058 | glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); |
2063 | glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); |
|
|
2064 | |
|
|
2065 | key.texname = self->tex [TEXID_HIDDEN].name; |
|
|
2066 | arr_hidden = rc_array (rc_ov, &key); |
2059 | |
2067 | |
2060 | for (z = 0; z <= 2; z++) |
2068 | for (z = 0; z <= 2; z++) |
2061 | { |
2069 | { |
2062 | memset (smooth_level, 0, sizeof (smooth_level)); |
2070 | memset (smooth_level, 0, sizeof (smooth_level)); |
2063 | key.texname = -1; |
2071 | key.texname = -1; |
… | |
… | |
2074 | tileid tile = cell->tile [z]; |
2082 | tileid tile = cell->tile [z]; |
2075 | |
2083 | |
2076 | if (tile) |
2084 | if (tile) |
2077 | { |
2085 | { |
2078 | maptex tex = self->tex [tile]; |
2086 | maptex tex = self->tex [tile]; |
2079 | int px = (x + 1) * T - tex.w; |
2087 | int px, py; |
2080 | int py = (y + 1) * T - tex.h; |
|
|
2081 | |
2088 | |
2082 | if (key.texname != tex.name) |
2089 | if (key.texname != tex.name) |
2083 | { |
2090 | { |
2084 | self->tex [tile].unused = 0; |
2091 | self->tex [tile].unused = 0; |
2085 | |
2092 | |
2086 | if (!tex.name) |
2093 | if (!tex.name) |
2087 | tex = self->tex [2]; /* missing, replace by noface */ |
2094 | tex = self->tex [TEXID_NOFACE]; /* missing, replace by noface */ |
2088 | |
2095 | |
2089 | key.texname = tex.name; |
2096 | key.texname = tex.name; |
2090 | arr = rc_array (rc, &key); |
2097 | arr = rc_array (rc, &key); |
2091 | } |
2098 | } |
|
|
2099 | |
|
|
2100 | px = (x + 1) * T - tex.w; |
|
|
2101 | py = (y + 1) * T - tex.h; |
2092 | |
2102 | |
2093 | if (expect_false (cell->player == player) && expect_false (z == 2)) |
2103 | if (expect_false (cell->player == player) && expect_false (z == 2)) |
2094 | { |
2104 | { |
2095 | pl_x = px; |
2105 | pl_x = px; |
2096 | pl_y = py; |
2106 | pl_y = py; |
… | |
… | |
2101 | rc_t2f_v3f (arr, 0 , 0 , px , py , 0); |
2111 | rc_t2f_v3f (arr, 0 , 0 , px , py , 0); |
2102 | rc_t2f_v3f (arr, 0 , tex.t, px , py + tex.h, 0); |
2112 | rc_t2f_v3f (arr, 0 , tex.t, px , py + tex.h, 0); |
2103 | rc_t2f_v3f (arr, tex.s, tex.t, px + tex.w, py + tex.h, 0); |
2113 | rc_t2f_v3f (arr, tex.s, tex.t, px + tex.w, py + tex.h, 0); |
2104 | rc_t2f_v3f (arr, tex.s, 0 , px + tex.w, py , 0); |
2114 | rc_t2f_v3f (arr, tex.s, 0 , px + tex.w, py , 0); |
2105 | |
2115 | |
2106 | if (expect_false (cell->flags) && expect_false (z == 2)) |
|
|
2107 | { |
|
|
2108 | /* this is a workaround to make speech bubbles drawn |
|
|
2109 | * for example above walls, work. */ |
|
|
2110 | rc_draw (rc); |
|
|
2111 | rc_clear (rc); |
|
|
2112 | key.texname = -1; |
|
|
2113 | |
|
|
2114 | // overlays such as the speech bubble, probably more to come |
|
|
2115 | if (cell->flags & 1) |
|
|
2116 | { |
|
|
2117 | maptex tex = self->tex [1]; |
|
|
2118 | int px = x * T + T * 2 / 32; |
|
|
2119 | int py = y * T - T * 6 / 32; |
|
|
2120 | |
|
|
2121 | if (tex.name) |
|
|
2122 | { |
|
|
2123 | if (key.texname != tex.name) |
|
|
2124 | { |
|
|
2125 | key.texname = tex.name; |
|
|
2126 | arr = rc_array (rc, &key); |
|
|
2127 | } |
|
|
2128 | |
|
|
2129 | rc_t2f_v3f (arr, 0 , 0 , px , py , 0); |
|
|
2130 | rc_t2f_v3f (arr, 0 , tex.t, px , py + T, 0); |
|
|
2131 | rc_t2f_v3f (arr, tex.s, tex.t, px + T, py + T, 0); |
|
|
2132 | rc_t2f_v3f (arr, tex.s, 0 , px + T, py , 0); |
|
|
2133 | } |
|
|
2134 | } |
|
|
2135 | } |
|
|
2136 | |
|
|
2137 | // update smooth hash |
2116 | // update smooth hash |
2138 | if (tex.smoothtile) |
2117 | if (tex.smoothtile) |
2139 | { |
2118 | { |
2140 | skey.tile = tex.smoothtile; |
2119 | skey.tile = tex.smoothtile; |
2141 | skey.level = tex.smoothlevel; |
2120 | skey.level = tex.smoothlevel; |
… | |
… | |
2169 | // corners |
2148 | // corners |
2170 | skey.x = x + 2; skey.y = y + 2; smooth_or_bits (smooth, &skey, 0x0100); |
2149 | skey.x = x + 2; skey.y = y + 2; smooth_or_bits (smooth, &skey, 0x0100); |
2171 | skey.x = x ; skey.y = y + 2; smooth_or_bits (smooth, &skey, 0x0200); |
2150 | skey.x = x ; skey.y = y + 2; smooth_or_bits (smooth, &skey, 0x0200); |
2172 | skey.x = x ; skey.y = y ; smooth_or_bits (smooth, &skey, 0x0400); |
2151 | skey.x = x ; skey.y = y ; smooth_or_bits (smooth, &skey, 0x0400); |
2173 | skey.x = x + 2; skey.y = y ; smooth_or_bits (smooth, &skey, 0x0800); |
2152 | skey.x = x + 2; skey.y = y ; smooth_or_bits (smooth, &skey, 0x0800); |
|
|
2153 | } |
|
|
2154 | } |
|
|
2155 | |
|
|
2156 | if (expect_false (z == 2)) |
|
|
2157 | { |
|
|
2158 | /* draw question marks on top of hidden spaces */ |
|
|
2159 | if (!cell->darkness) |
|
|
2160 | { |
|
|
2161 | maptex tex = self->tex [TEXID_HIDDEN]; |
|
|
2162 | int px = (x + 1) * T - tex.w; |
|
|
2163 | int py = (y + 1) * T - tex.h; |
|
|
2164 | |
|
|
2165 | rc_t2f_v3f (arr_hidden, 0 , 0 , px , py , 0); |
|
|
2166 | rc_t2f_v3f (arr_hidden, 0 , tex.t, px , py + tex.h, 0); |
|
|
2167 | rc_t2f_v3f (arr_hidden, tex.s, tex.t, px + tex.w, py + tex.h, 0); |
|
|
2168 | rc_t2f_v3f (arr_hidden, tex.s, 0 , px + tex.w, py , 0); |
|
|
2169 | } |
|
|
2170 | |
|
|
2171 | if (expect_false (cell->flags)) |
|
|
2172 | { |
|
|
2173 | // overlays such as the speech bubble, probably more to come |
|
|
2174 | if (cell->flags & 1) |
|
|
2175 | { |
|
|
2176 | rc_key_t key_ov = key; |
|
|
2177 | maptex tex = self->tex [TEXID_SPEECH]; |
|
|
2178 | rc_array_t *arr; |
|
|
2179 | |
|
|
2180 | key_ov.texname = tex.name; |
|
|
2181 | arr = rc_array (rc_ov, &key_ov); |
|
|
2182 | |
|
|
2183 | int px = x * T + T * 2 / 32; |
|
|
2184 | int py = y * T - T * 6 / 32; |
|
|
2185 | |
|
|
2186 | rc_t2f_v3f (arr, 0 , 0 , px , py , 0); |
|
|
2187 | rc_t2f_v3f (arr, 0 , tex.t, px , py + T, 0); |
|
|
2188 | rc_t2f_v3f (arr, tex.s, tex.t, px + T, py + T, 0); |
|
|
2189 | rc_t2f_v3f (arr, tex.s, 0 , px + T, py , 0); |
|
|
2190 | } |
2174 | } |
2191 | } |
2175 | } |
2192 | } |
2176 | } |
2193 | } |
2177 | } |
2194 | } |
2178 | |
2195 | |
… | |
… | |
2275 | rc_t2f_v3f (arr, tex.s, 0 , px + tex.w, py , 0); |
2292 | rc_t2f_v3f (arr, tex.s, 0 , px + tex.w, py , 0); |
2276 | |
2293 | |
2277 | rc_draw (rc); |
2294 | rc_draw (rc); |
2278 | } |
2295 | } |
2279 | |
2296 | |
|
|
2297 | rc_draw (rc_ov); |
|
|
2298 | rc_clear (rc_ov); |
|
|
2299 | |
2280 | glDisable (GL_BLEND); |
2300 | glDisable (GL_BLEND); |
2281 | rc_free (rc); |
2301 | rc_free (rc); |
|
|
2302 | rc_free (rc_ov); |
2282 | |
2303 | |
2283 | // top layer: overlays such as the health bar |
2304 | // top layer: overlays such as the health bar |
2284 | for (y = 0; y < sh; y++) |
2305 | for (y = 0; y < sh; y++) |
2285 | if (0 <= y + my && y + my < self->rows) |
2306 | if (0 <= y + my && y + my < self->rows) |
2286 | { |
2307 | { |