… | |
… | |
41 | #include <SDL_opengl.h> |
41 | #include <SDL_opengl.h> |
42 | |
42 | |
43 | /* work around os x broken headers */ |
43 | /* work around os x broken headers */ |
44 | #ifdef __MACOSX__ |
44 | #ifdef __MACOSX__ |
45 | typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); |
45 | typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); |
|
|
46 | typedef void (APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture); |
|
|
47 | typedef void (APIENTRYP PFNGLMULTITEXCOORD2FPROC) (GLenum target, GLfloat s, GLfloat t); |
46 | #endif |
48 | #endif |
47 | |
49 | |
48 | #define PANGO_ENABLE_BACKEND |
50 | #define PANGO_ENABLE_BACKEND |
49 | #define G_DISABLE_CAST_CHECKS |
51 | #define G_DISABLE_CAST_CHECKS |
50 | |
52 | |
… | |
… | |
97 | |
99 | |
98 | #define KMOD_LRAM 0x10000 // our extension |
100 | #define KMOD_LRAM 0x10000 // our extension |
99 | |
101 | |
100 | #define TEXID_SPEECH 1 |
102 | #define TEXID_SPEECH 1 |
101 | #define TEXID_NOFACE 2 |
103 | #define TEXID_NOFACE 2 |
102 | #define TEXID_HIDDEN 3 |
104 | |
|
|
105 | static char * |
|
|
106 | fast_sv_grow (SV *sv, STRLEN need) |
|
|
107 | { |
|
|
108 | STRLEN len = SvLEN (sv); |
|
|
109 | STRLEN want = SvCUR (sv) + need; |
|
|
110 | |
|
|
111 | if (expect_false (len < want)) |
|
|
112 | { |
|
|
113 | do |
|
|
114 | len *= 2; |
|
|
115 | while (len < want); |
|
|
116 | |
|
|
117 | sv_grow (sv, len); |
|
|
118 | } |
|
|
119 | |
|
|
120 | SvCUR_set (sv, want); |
|
|
121 | return SvEND (sv) - need; |
|
|
122 | } |
103 | |
123 | |
104 | static AV *texture_av; |
124 | static AV *texture_av; |
105 | |
125 | |
106 | static struct |
126 | static struct |
107 | { |
127 | { |
… | |
… | |
462 | |
482 | |
463 | SDL_PushEvent ((SDL_Event *)&ev); |
483 | SDL_PushEvent ((SDL_Event *)&ev); |
464 | } |
484 | } |
465 | |
485 | |
466 | static unsigned int |
486 | static unsigned int |
|
|
487 | div255 (unsigned int n) |
|
|
488 | { |
|
|
489 | return (n + (n >> 8)) >> 8; |
|
|
490 | } |
|
|
491 | |
|
|
492 | static unsigned int |
467 | minpot (unsigned int n) |
493 | minpot (unsigned int n) |
468 | { |
494 | { |
469 | if (!n) |
495 | if (!n) |
470 | return 0; |
496 | return 0; |
471 | |
497 | |
… | |
… | |
554 | |
580 | |
555 | static void |
581 | static void |
556 | deliantra_main () |
582 | deliantra_main () |
557 | { |
583 | { |
558 | char *argv[] = { 0 }; |
584 | char *argv[] = { 0 }; |
559 | call_argv ("::main", G_DISCARD | G_VOID, argv); |
585 | call_argv ("DC::Main::main", G_DISCARD | G_VOID, argv); |
560 | } |
586 | } |
561 | |
587 | |
562 | #ifdef __MACOSX__ |
588 | #ifdef __MACOSX__ |
563 | /* to due surprising braindamage on the side of SDL design, we |
589 | /* to due surprising braindamage on the side of SDL design, we |
564 | * do some mind-boggling hack here: SDL requires a custom main() |
590 | * do some mind-boggling hack here: SDL requires a custom main() |
565 | * on OS X, so... we provide one and call the original main(), which, |
591 | * on OS X, so... we provide one and call the original main(), which, |
566 | * due to share dlibrary magic, calls -lSDLmain's main, not perl's main, |
592 | * due to shared library magic, calls -lSDLmain's main, not perl's main, |
567 | * and which calls our main (== SDL_main) back. |
593 | * and which calls our main (== SDL_main) back. |
568 | */ |
594 | */ |
569 | extern C_LINKAGE int |
595 | extern C_LINKAGE int |
570 | main (int argc, char *argv[]) |
596 | main (int argc, char *argv[]) |
571 | { |
597 | { |
… | |
… | |
795 | |
821 | |
796 | const_iv (FOW_DARKNESS) |
822 | const_iv (FOW_DARKNESS) |
797 | # undef const_iv |
823 | # undef const_iv |
798 | }; |
824 | }; |
799 | |
825 | |
800 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
826 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ > const_iv; civ--) |
801 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
827 | newCONSTSUB (stash, (char *)civ[-1].name, newSViv (civ[-1].iv)); |
802 | |
828 | |
803 | assert (SDLK_MODIFIER_MIN == SDLK_NUMLOCK); |
829 | assert (SDLK_MODIFIER_MIN == SDLK_NUMLOCK); |
804 | assert (SDLK_MODIFIER_MAX == SDLK_COMPOSE); |
830 | assert (SDLK_MODIFIER_MAX == SDLK_COMPOSE); |
805 | } |
831 | } |
806 | |
832 | |
… | |
… | |
924 | ); |
950 | ); |
925 | |
951 | |
926 | if (RETVAL) |
952 | if (RETVAL) |
927 | { |
953 | { |
928 | av_clear (texture_av); |
954 | av_clear (texture_av); |
929 | |
|
|
930 | SDL_WM_SetCaption ("Deliantra MORPG Client " VERSION, "Deliantra"); |
|
|
931 | #define GL_FUNC(ptr,name) gl.name = (ptr)SDL_GL_GetProcAddress ("gl" # name); |
955 | #define GL_FUNC(ptr,name) gl.name = (ptr)SDL_GL_GetProcAddress ("gl" # name); |
932 | #include "glfunc.h" |
956 | #include "glfunc.h" |
933 | #undef GL_FUNC |
957 | #undef GL_FUNC |
|
|
958 | if (!gl.ActiveTexture ) gl.ActiveTexture = gl.ActiveTextureARB; |
|
|
959 | if (!gl.MultiTexCoord2f) gl.MultiTexCoord2f = gl.MultiTexCoord2fARB; |
934 | } |
960 | } |
935 | } |
961 | } |
936 | OUTPUT: |
962 | OUTPUT: |
937 | RETVAL |
963 | RETVAL |
938 | |
964 | |
939 | void |
965 | void |
|
|
966 | SDL_WM_SetCaption (const char *title, const char *icon) |
|
|
967 | |
|
|
968 | void |
940 | SDL_GL_SwapBuffers () |
969 | SDL_GL_SwapBuffers () |
941 | |
970 | |
942 | char * |
971 | char * |
943 | SDL_GetKeyName (int sym) |
972 | SDL_GetKeyName (int sym) |
944 | |
973 | |
… | |
… | |
946 | SDL_GetAppState () |
975 | SDL_GetAppState () |
947 | |
976 | |
948 | int |
977 | int |
949 | SDL_GetModState () |
978 | SDL_GetModState () |
950 | |
979 | |
|
|
980 | int |
|
|
981 | SDL_WaitEvent () |
|
|
982 | C_ARGS: 0 |
|
|
983 | |
951 | void |
984 | void |
|
|
985 | SDL_PumpEvents () |
|
|
986 | |
|
|
987 | void |
952 | poll_events () |
988 | peep_events () |
953 | PPCODE: |
989 | PPCODE: |
954 | { |
990 | { |
955 | SDL_Event ev; |
991 | SDL_Event ev; |
956 | |
992 | |
957 | SDL_PumpEvents (); |
993 | SDL_PumpEvents (); |
… | |
… | |
1023 | |
1059 | |
1024 | XPUSHs (sv_2mortal (sv_bless (newRV_noinc ((SV *)hv), gv_stashpv ("DC::UI::Event", 1)))); |
1060 | XPUSHs (sv_2mortal (sv_bless (newRV_noinc ((SV *)hv), gv_stashpv ("DC::UI::Event", 1)))); |
1025 | } |
1061 | } |
1026 | } |
1062 | } |
1027 | |
1063 | |
|
|
1064 | char * |
|
|
1065 | SDL_AudioDriverName () |
|
|
1066 | CODE: |
|
|
1067 | { |
|
|
1068 | char buf [256]; |
|
|
1069 | if (!SDL_AudioDriverName (buf, sizeof (buf))) |
|
|
1070 | XSRETURN_UNDEF; |
|
|
1071 | |
|
|
1072 | RETVAL = buf; |
|
|
1073 | } |
|
|
1074 | OUTPUT: |
|
|
1075 | RETVAL |
|
|
1076 | |
1028 | int |
1077 | int |
1029 | Mix_OpenAudio (int frequency = 44100, int format = MIX_DEFAULT_FORMAT, int channels = 2, int chunksize = 4096) |
1078 | Mix_OpenAudio (int frequency = 44100, int format = MIX_DEFAULT_FORMAT, int channels = 2, int chunksize = 4096) |
1030 | POSTCALL: |
1079 | POSTCALL: |
1031 | Mix_HookMusicFinished (music_finished); |
1080 | Mix_HookMusicFinished (music_finished); |
1032 | Mix_ChannelFinished (channel_finished); |
1081 | Mix_ChannelFinished (channel_finished); |
… | |
… | |
1094 | add_font (char *file) |
1143 | add_font (char *file) |
1095 | CODE: |
1144 | CODE: |
1096 | RETVAL = FcConfigAppFontAddFile (0, (const FcChar8 *)file); |
1145 | RETVAL = FcConfigAppFontAddFile (0, (const FcChar8 *)file); |
1097 | OUTPUT: |
1146 | OUTPUT: |
1098 | RETVAL |
1147 | RETVAL |
|
|
1148 | |
|
|
1149 | void |
|
|
1150 | IMG_Init (int flags = IMG_INIT_JPG | IMG_INIT_PNG) |
|
|
1151 | |
|
|
1152 | # MIX_INIT_MP3 gives smpeg + libstdc++ + libgcc_s |
|
|
1153 | void |
|
|
1154 | Mix_Init (int flags = MIX_INIT_MOD | MIX_INIT_OGG) |
1099 | |
1155 | |
1100 | void |
1156 | void |
1101 | load_image_inline (SV *image_) |
1157 | load_image_inline (SV *image_) |
1102 | ALIAS: |
1158 | ALIAS: |
1103 | load_image_file = 1 |
1159 | load_image_file = 1 |
… | |
… | |
1671 | void |
1727 | void |
1672 | draw_fow_texture (float intensity, int hidden_tex, int name1, uint8_t *data1, float s, float t, int w, int h, float blend = 0.f, int dx = 0, int dy = 0, int name2 = 0, uint8_t *data2 = data1) |
1728 | draw_fow_texture (float intensity, int hidden_tex, int name1, uint8_t *data1, float s, float t, int w, int h, float blend = 0.f, int dx = 0, int dy = 0, int name2 = 0, uint8_t *data2 = data1) |
1673 | PROTOTYPE: @ |
1729 | PROTOTYPE: @ |
1674 | CODE: |
1730 | CODE: |
1675 | { |
1731 | { |
|
|
1732 | glEnable (GL_BLEND); |
|
|
1733 | glBlendFunc (intensity ? GL_SRC_ALPHA : GL_ONE, GL_ONE_MINUS_SRC_ALPHA); |
1676 | glEnable (GL_TEXTURE_2D); |
1734 | glEnable (GL_TEXTURE_2D); |
1677 | glEnable (GL_BLEND); |
|
|
1678 | glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA); |
|
|
1679 | glBindTexture (GL_TEXTURE_2D, name1); |
1735 | glBindTexture (GL_TEXTURE_2D, name1); |
1680 | |
1736 | |
1681 | glColor3f (intensity, intensity, intensity); |
1737 | glColor3f (intensity, intensity, intensity); |
1682 | glPushMatrix (); |
1738 | glPushMatrix (); |
1683 | glScalef (1./3, 1./3, 1.); |
1739 | glScalef (1./3, 1./3, 1.); |
… | |
… | |
1698 | glBindTexture (GL_TEXTURE_2D, name2); |
1754 | glBindTexture (GL_TEXTURE_2D, name2); |
1699 | glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE); |
1755 | glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE); |
1700 | |
1756 | |
1701 | /* rgb == rgb(glcolor) */ |
1757 | /* rgb == rgb(glcolor) */ |
1702 | glTexEnvi (GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_REPLACE); |
1758 | glTexEnvi (GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_REPLACE); |
1703 | glTexEnvi (GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_CONSTANT); |
1759 | glTexEnvi (GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_PRIMARY_COLOR); |
1704 | glTexEnvi (GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR); |
1760 | glTexEnvi (GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR); |
1705 | |
1761 | |
1706 | /* alpha = interpolate t0, t1 by env_alpha */ |
1762 | /* alpha = interpolate t0, t1 by env_alpha */ |
1707 | glTexEnvfv (GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, env_color); |
1763 | glTexEnvfv (GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, env_color); |
1708 | |
1764 | |
… | |
… | |
2095 | ? self->row + y |
2151 | ? self->row + y |
2096 | : 0; |
2152 | : 0; |
2097 | |
2153 | |
2098 | for (x = x0; x < x1; x++) |
2154 | for (x = x0; x < x1; x++) |
2099 | { |
2155 | { |
2100 | int r = 32, g = 32, b = 32, a = 192; |
2156 | unsigned int r = 32, g = 32, b = 32, a = 192; |
2101 | |
2157 | |
2102 | if (row && row->c0 <= x && x < row->c1) |
2158 | if (row && row->c0 <= x && x < row->c1) |
2103 | { |
2159 | { |
2104 | mapcell *cell = row->col + (x - row->c0); |
2160 | mapcell *cell = row->col + (x - row->c0); |
2105 | |
2161 | |
… | |
… | |
2107 | { |
2163 | { |
2108 | maptex tex = self->tex [cell->tile [z]]; |
2164 | maptex tex = self->tex [cell->tile [z]]; |
2109 | int a0 = 255 - tex.a; |
2165 | int a0 = 255 - tex.a; |
2110 | int a1 = tex.a; |
2166 | int a1 = tex.a; |
2111 | |
2167 | |
2112 | r = (r * a0 + tex.r * a1) / 255; |
2168 | r = div255 (r * a0 + tex.r * a1); |
2113 | g = (g * a0 + tex.g * a1) / 255; |
2169 | g = div255 (g * a0 + tex.g * a1); |
2114 | b = (b * a0 + tex.b * a1) / 255; |
2170 | b = div255 (b * a0 + tex.b * a1); |
2115 | a = (a * a0 + tex.a * a1) / 255; |
2171 | a = div255 (a * a0 + tex.a * a1); |
2116 | } |
2172 | } |
2117 | } |
2173 | } |
2118 | |
2174 | |
2119 | *map++ = (r ) |
2175 | *map++ = (r ) |
2120 | | (g << 8) |
2176 | | (g << 8) |
… | |
… | |
2127 | } |
2183 | } |
2128 | OUTPUT: |
2184 | OUTPUT: |
2129 | RETVAL |
2185 | RETVAL |
2130 | |
2186 | |
2131 | void |
2187 | void |
2132 | draw (DC::Map self, int mx, int my, int sw, int sh, int T, U32 player = 0xffffffff, int sdx = 0, int sdy = 0) |
2188 | 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) |
2133 | CODE: |
2189 | CODE: |
2134 | { |
2190 | { |
2135 | int x, y, z; |
2191 | int x, y, z; |
2136 | |
2192 | |
2137 | HV *smooth = (HV *)sv_2mortal ((SV *)newHV ()); |
2193 | HV *smooth = (HV *)sv_2mortal ((SV *)newHV ()); |
… | |
… | |
2141 | int pl_x, pl_y; |
2197 | int pl_x, pl_y; |
2142 | maptex pl_tex; |
2198 | maptex pl_tex; |
2143 | rc_t *rc = rc_alloc (); |
2199 | rc_t *rc = rc_alloc (); |
2144 | rc_t *rc_ov = rc_alloc (); |
2200 | rc_t *rc_ov = rc_alloc (); |
2145 | rc_key_t key; |
2201 | rc_key_t key; |
2146 | rc_array_t *arr, *arr_hidden; |
2202 | rc_array_t *arr; |
2147 | |
2203 | |
2148 | pl_tex.name = 0; |
2204 | pl_tex.name = 0; |
2149 | |
2205 | |
2150 | // that's current max. sorry. |
2206 | // that's current max. sorry. |
2151 | if (sw > 255) sw = 255; |
2207 | if (sw > 255) sw = 255; |
… | |
… | |
2188 | } |
2244 | } |
2189 | |
2245 | |
2190 | glEnable (GL_BLEND); |
2246 | glEnable (GL_BLEND); |
2191 | glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
2247 | glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
2192 | glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); |
2248 | glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); |
2193 | |
|
|
2194 | key.texname = self->tex [TEXID_HIDDEN].name; |
|
|
2195 | arr_hidden = rc_array (rc_ov, &key); |
|
|
2196 | |
2249 | |
2197 | for (z = 0; z <= 2; z++) |
2250 | for (z = 0; z <= 2; z++) |
2198 | { |
2251 | { |
2199 | memset (smooth_level, 0, sizeof (smooth_level)); |
2252 | memset (smooth_level, 0, sizeof (smooth_level)); |
2200 | key.texname = -1; |
2253 | key.texname = -1; |
… | |
… | |
2224 | |
2277 | |
2225 | key.texname = tex.name; |
2278 | key.texname = tex.name; |
2226 | arr = rc_array (rc, &key); |
2279 | arr = rc_array (rc, &key); |
2227 | } |
2280 | } |
2228 | |
2281 | |
2229 | px = (x + 1) * T - tex.w; |
2282 | px = (x + 1) * Th - tex.w; |
2230 | py = (y + 1) * T - tex.h; |
2283 | py = (y + 1) * Tw - tex.h; |
2231 | |
2284 | |
2232 | if (expect_false (cell->player == player) && expect_false (z == 2)) |
2285 | if (expect_false (cell->player == player) && expect_false (z == 2)) |
2233 | { |
2286 | { |
2234 | pl_x = px; |
2287 | pl_x = px; |
2235 | pl_y = py; |
2288 | pl_y = py; |
… | |
… | |
2288 | if (cell->flags & 1) |
2341 | if (cell->flags & 1) |
2289 | { |
2342 | { |
2290 | rc_key_t key_ov = key; |
2343 | rc_key_t key_ov = key; |
2291 | maptex tex = self->tex [TEXID_SPEECH]; |
2344 | maptex tex = self->tex [TEXID_SPEECH]; |
2292 | rc_array_t *arr; |
2345 | rc_array_t *arr; |
2293 | int px = x * T + T * 2 / 32; |
2346 | int px = x * Tw + Tw * 2 / 32; |
2294 | int py = y * T - T * 6 / 32; |
2347 | int py = y * Th - Th * 6 / 32; |
2295 | |
2348 | |
2296 | key_ov.texname = tex.name; |
2349 | key_ov.texname = tex.name; |
2297 | arr = rc_array (rc_ov, &key_ov); |
2350 | arr = rc_array (rc_ov, &key_ov); |
2298 | |
2351 | |
2299 | rc_t2f_v3f (arr, 0 , 0 , px , py , 0); |
2352 | rc_t2f_v3f (arr, 0 , 0 , px , py , 0); |
2300 | rc_t2f_v3f (arr, 0 , tex.t, px , py + T, 0); |
2353 | rc_t2f_v3f (arr, 0 , tex.t, px , py + Th, 0); |
2301 | rc_t2f_v3f (arr, tex.s, tex.t, px + T, py + T, 0); |
2354 | rc_t2f_v3f (arr, tex.s, tex.t, px + Tw, py + Th, 0); |
2302 | rc_t2f_v3f (arr, tex.s, 0 , px + T, py , 0); |
2355 | rc_t2f_v3f (arr, tex.s, 0 , px + Tw, py , 0); |
2303 | } |
2356 | } |
2304 | } |
2357 | } |
2305 | } |
2358 | } |
2306 | } |
2359 | } |
2307 | |
2360 | |
… | |
… | |
2334 | if (!(bits & 0x1000) |
2387 | if (!(bits & 0x1000) |
2335 | && skey->level == level |
2388 | && skey->level == level |
2336 | && level > smooth_max [skey->x][skey->y]) |
2389 | && level > smooth_max [skey->x][skey->y]) |
2337 | { |
2390 | { |
2338 | maptex tex = self->tex [skey->tile]; |
2391 | maptex tex = self->tex [skey->tile]; |
2339 | int px = (((int)skey->x) - 1) * T; |
2392 | int px = (((int)skey->x) - 1) * Tw; |
2340 | int py = (((int)skey->y) - 1) * T; |
2393 | int py = (((int)skey->y) - 1) * Th; |
2341 | int border = bits & 15; |
2394 | int border = bits & 15; |
2342 | int corner = (bits >> 8) & ~(bits >> 4) & 15; |
2395 | int corner = (bits >> 8) & ~(bits >> 4) & 15; |
2343 | float dx = tex.s * .0625f; // 16 images/row |
2396 | float dx = tex.s * .0625f; // 16 images/row |
2344 | float dy = tex.t * .5f ; // 2 images/column |
2397 | float dy = tex.t * .5f ; // 2 images/column |
2345 | |
2398 | |
… | |
… | |
2358 | |
2411 | |
2359 | if (border) |
2412 | if (border) |
2360 | { |
2413 | { |
2361 | float ox = border * dx; |
2414 | float ox = border * dx; |
2362 | |
2415 | |
2363 | glTexCoord2f (ox , 0.f ); glVertex2i (px , py ); |
2416 | glTexCoord2f (ox , 0.f ); glVertex2i (px , py ); |
2364 | glTexCoord2f (ox , dy ); glVertex2i (px , py + T); |
2417 | glTexCoord2f (ox , dy ); glVertex2i (px , py + Th); |
2365 | glTexCoord2f (ox + dx, dy ); glVertex2i (px + T, py + T); |
2418 | glTexCoord2f (ox + dx, dy ); glVertex2i (px + Tw, py + Th); |
2366 | glTexCoord2f (ox + dx, 0.f ); glVertex2i (px + T, py ); |
2419 | glTexCoord2f (ox + dx, 0.f ); glVertex2i (px + Tw, py ); |
2367 | } |
2420 | } |
2368 | |
2421 | |
2369 | if (corner) |
2422 | if (corner) |
2370 | { |
2423 | { |
2371 | float ox = corner * dx; |
2424 | float ox = corner * dx; |
2372 | |
2425 | |
2373 | glTexCoord2f (ox , dy ); glVertex2i (px , py ); |
2426 | glTexCoord2f (ox , dy ); glVertex2i (px , py ); |
2374 | glTexCoord2f (ox , dy * 2.f); glVertex2i (px , py + T); |
2427 | glTexCoord2f (ox , dy * 2.f); glVertex2i (px , py + Th); |
2375 | glTexCoord2f (ox + dx, dy * 2.f); glVertex2i (px + T, py + T); |
2428 | glTexCoord2f (ox + dx, dy * 2.f); glVertex2i (px + Tw, py + Th); |
2376 | glTexCoord2f (ox + dx, dy ); glVertex2i (px + T, py ); |
2429 | glTexCoord2f (ox + dx, dy ); glVertex2i (px + Tw, py ); |
2377 | } |
2430 | } |
2378 | } |
2431 | } |
2379 | } |
2432 | } |
2380 | } |
2433 | } |
2381 | } |
2434 | } |
… | |
… | |
2422 | for (x = 0; x < sw; x++) |
2475 | for (x = 0; x < sw; x++) |
2423 | if (row->c0 <= x + mx && x + mx < row->c1) |
2476 | if (row->c0 <= x + mx && x + mx < row->c1) |
2424 | { |
2477 | { |
2425 | mapcell *cell = row->col + (x + mx - row->c0); |
2478 | mapcell *cell = row->col + (x + mx - row->c0); |
2426 | |
2479 | |
2427 | int px = x * T; |
2480 | int px = x * Tw; |
2428 | int py = y * T; |
2481 | int py = y * Th; |
2429 | |
2482 | |
2430 | if (expect_false (cell->player == player)) |
2483 | if (expect_false (cell->player == player)) |
2431 | { |
2484 | { |
2432 | px += sdx; |
2485 | px += sdx; |
2433 | py += sdy; |
2486 | py += sdy; |
2434 | } |
2487 | } |
2435 | |
2488 | |
2436 | if (cell->stat_hp) |
2489 | if (cell->stat_hp) |
2437 | { |
2490 | { |
2438 | int width = cell->stat_width * T; |
2491 | int width = cell->stat_width * Tw; |
2439 | int thick = (sh * T / 32 + 27) / 28 + 1 + cell->stat_width; |
2492 | int thick = (sh * Th / 32 + 27) / 28 + 1 + cell->stat_width; |
2440 | |
2493 | |
2441 | glColor3ub (0, 0, 0); |
2494 | glColor3ub (0, 0, 0); |
2442 | glRectf (px + 1, py - thick - 2, |
2495 | glRectf (px + 1, py - thick - 2, |
2443 | px + width - 1, py); |
2496 | px + width - 1, py); |
2444 | |
2497 | |
… | |
… | |
2524 | int x, y; |
2577 | int x, y; |
2525 | int sw1 = sw + 2; |
2578 | int sw1 = sw + 2; |
2526 | int sh1 = sh + 2; |
2579 | int sh1 = sh + 2; |
2527 | int sh3 = sh * 3; |
2580 | int sh3 = sh * 3; |
2528 | int sw3 = sw * 3; |
2581 | int sw3 = sw * 3; |
2529 | uint8_t *darkness1 = (uint8_t *)malloc (sw1 * sh1); |
|
|
2530 | SV *darkness3_sv = sv_2mortal (newSV (sw3 * sh3)); |
2582 | SV *darkness3_sv = sv_2mortal (newSV (sw3 * sh3)); |
2531 | uint8_t *darkness3 = (uint8_t *)SvPVX (darkness3_sv); |
2583 | uint8_t *darkness3 = (uint8_t *)SvPVX (darkness3_sv); |
|
|
2584 | uint8_t *darkness1 = (uint8_t *)malloc (sw1 * sh1); |
|
|
2585 | memset (darkness1, 0, sw1*sh1); |
2532 | |
2586 | |
2533 | SvPOK_only (darkness3_sv); |
2587 | SvPOK_only (darkness3_sv); |
2534 | SvCUR_set (darkness3_sv, sw3 * sh3); |
2588 | SvCUR_set (darkness3_sv, sw3 * sh3); |
2535 | |
2589 | |
2536 | mx += self->x - 1; |
2590 | mx += self->x - 1; |
… | |
… | |
2797 | if (RETVAL < 0) |
2851 | if (RETVAL < 0) |
2798 | { |
2852 | { |
2799 | RETVAL = Mix_GroupOldest (-1); |
2853 | RETVAL = Mix_GroupOldest (-1); |
2800 | |
2854 | |
2801 | if (RETVAL < 0) |
2855 | if (RETVAL < 0) |
|
|
2856 | { |
|
|
2857 | // happens sometimes, maybe it just stopped playing(?) |
|
|
2858 | RETVAL = Mix_GroupAvailable (-1); |
|
|
2859 | |
|
|
2860 | if (RETVAL < 0) |
2802 | XSRETURN_UNDEF; |
2861 | XSRETURN_UNDEF; |
2803 | |
2862 | } |
|
|
2863 | else |
2804 | Mix_HaltChannel (RETVAL); |
2864 | Mix_HaltChannel (RETVAL); |
2805 | } |
2865 | } |
2806 | |
2866 | |
2807 | Mix_UnregisterAllEffects (RETVAL); |
2867 | Mix_UnregisterAllEffects (RETVAL); |
2808 | Mix_Volume (RETVAL, 128); |
2868 | Mix_Volume (RETVAL, 128); |
2809 | } |
2869 | } |
… | |
… | |
2868 | Mix_SetReverseStereo (self, flip); |
2928 | Mix_SetReverseStereo (self, flip); |
2869 | |
2929 | |
2870 | MODULE = Deliantra::Client PACKAGE = DC::MixChunk |
2930 | MODULE = Deliantra::Client PACKAGE = DC::MixChunk |
2871 | |
2931 | |
2872 | PROTOTYPES: DISABLE |
2932 | PROTOTYPES: DISABLE |
|
|
2933 | |
|
|
2934 | void |
|
|
2935 | decoders () |
|
|
2936 | PPCODE: |
|
|
2937 | #if SDL_MIXER_MAJOR_VERSION > 1 || SDL_MIXER_MINOR_VERSION > 2 || SDL_MIXER_PATCHLEVEL >= 10 |
|
|
2938 | int i, num = Mix_GetNumChunkDecoders (); |
|
|
2939 | EXTEND (SP, num); |
|
|
2940 | for (i = 0; i < num; ++i) |
|
|
2941 | PUSHs (sv_2mortal (newSVpv (Mix_GetChunkDecoder (i), 0))); |
|
|
2942 | #else |
|
|
2943 | XPUSHs (sv_2mortal (newSVpv ("(sdl mixer too old)", 0))); |
|
|
2944 | #endif |
2873 | |
2945 | |
2874 | DC::MixChunk |
2946 | DC::MixChunk |
2875 | new (SV *class, DC::RW rwops) |
2947 | new (SV *class, DC::RW rwops) |
2876 | CODE: |
2948 | CODE: |
2877 | RETVAL = Mix_LoadWAV_RW (rwops, 1); |
2949 | RETVAL = Mix_LoadWAV_RW (rwops, 1); |
… | |
… | |
2910 | OUTPUT: |
2982 | OUTPUT: |
2911 | RETVAL |
2983 | RETVAL |
2912 | |
2984 | |
2913 | MODULE = Deliantra::Client PACKAGE = DC::MixMusic |
2985 | MODULE = Deliantra::Client PACKAGE = DC::MixMusic |
2914 | |
2986 | |
|
|
2987 | void |
|
|
2988 | decoders () |
|
|
2989 | PPCODE: |
|
|
2990 | #if SDL_MIXER_MAJOR_VERSION > 1 || SDL_MIXER_MINOR_VERSION > 2 || SDL_MIXER_PATCHLEVEL >= 10 |
|
|
2991 | int i, num = Mix_GetNumMusicDecoders (); |
|
|
2992 | EXTEND (SP, num); |
|
|
2993 | for (i = 0; i < num; ++i) |
|
|
2994 | PUSHs (sv_2mortal (newSVpv (Mix_GetMusicDecoder (i), 0))); |
|
|
2995 | #else |
|
|
2996 | XPUSHs (sv_2mortal (newSVpv ("(sdl mixer too old)", 0))); |
|
|
2997 | #endif |
|
|
2998 | |
2915 | int |
2999 | int |
2916 | volume (int volume = -1) |
3000 | volume (int volume = -1) |
2917 | PROTOTYPE: ;$ |
3001 | PROTOTYPE: ;$ |
2918 | CODE: |
3002 | CODE: |
2919 | if (items > 0) |
3003 | if (items > 0) |
… | |
… | |
2929 | |
3013 | |
2930 | void |
3014 | void |
2931 | halt () |
3015 | halt () |
2932 | CODE: |
3016 | CODE: |
2933 | Mix_HaltMusic (); |
3017 | Mix_HaltMusic (); |
|
|
3018 | |
|
|
3019 | int |
|
|
3020 | playing () |
|
|
3021 | CODE: |
|
|
3022 | RETVAL = Mix_PlayingMusic (); |
|
|
3023 | OUTPUT: |
|
|
3024 | RETVAL |
2934 | |
3025 | |
2935 | DC::MixMusic |
3026 | DC::MixMusic |
2936 | new (SV *class, DC::RW rwops) |
3027 | new (SV *class, DC::RW rwops) |
2937 | CODE: |
3028 | CODE: |
2938 | RETVAL = Mix_LoadMUS_RW (rwops); |
3029 | RETVAL = Mix_LoadMUS_RW (rwops); |
… | |
… | |
3078 | const_iv (GL_FUNC_SUBTRACT), |
3169 | const_iv (GL_FUNC_SUBTRACT), |
3079 | const_iv (GL_FUNC_REVERSE_SUBTRACT), |
3170 | const_iv (GL_FUNC_REVERSE_SUBTRACT), |
3080 | # undef const_iv |
3171 | # undef const_iv |
3081 | }; |
3172 | }; |
3082 | |
3173 | |
3083 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
3174 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ > const_iv; civ--) |
3084 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
3175 | newCONSTSUB (stash, (char *)civ[-1].name, newSViv (civ[-1].iv)); |
3085 | |
3176 | |
3086 | texture_av = newAV (); |
3177 | texture_av = newAV (); |
3087 | AvREAL_off (texture_av); |
3178 | AvREAL_off (texture_av); |
3088 | } |
3179 | } |
3089 | |
3180 | |
… | |
… | |
3132 | RETVAL |
3223 | RETVAL |
3133 | |
3224 | |
3134 | int glGetError () |
3225 | int glGetError () |
3135 | |
3226 | |
3136 | void glFinish () |
3227 | void glFinish () |
|
|
3228 | |
|
|
3229 | void glFlush () |
3137 | |
3230 | |
3138 | void glClear (int mask) |
3231 | void glClear (int mask) |
3139 | |
3232 | |
3140 | void glClearColor (float r, float g, float b, float a = 1.0) |
3233 | void glClearColor (float r, float g, float b, float a = 1.0) |
3141 | PROTOTYPE: @ |
3234 | PROTOTYPE: @ |