… | |
… | |
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 |
|
|
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 | } |
102 | |
123 | |
103 | static AV *texture_av; |
124 | static AV *texture_av; |
104 | |
125 | |
105 | static struct |
126 | static struct |
106 | { |
127 | { |
… | |
… | |
461 | |
482 | |
462 | SDL_PushEvent ((SDL_Event *)&ev); |
483 | SDL_PushEvent ((SDL_Event *)&ev); |
463 | } |
484 | } |
464 | |
485 | |
465 | 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 |
466 | minpot (unsigned int n) |
493 | minpot (unsigned int n) |
467 | { |
494 | { |
468 | if (!n) |
495 | if (!n) |
469 | return 0; |
496 | return 0; |
470 | |
497 | |
… | |
… | |
550 | |
577 | |
551 | return mod; |
578 | return mod; |
552 | } |
579 | } |
553 | |
580 | |
554 | static void |
581 | static void |
555 | deliantra_main () |
582 | deliantra_main (SV *real_main) |
556 | { |
583 | { |
557 | char *argv[] = { 0 }; |
584 | dSP; |
558 | call_argv ("::main", G_DISCARD | G_VOID, argv); |
585 | |
|
|
586 | PUSHMARK (SP); |
|
|
587 | call_sv (real_main, G_DISCARD | G_VOID); |
559 | } |
588 | } |
560 | |
589 | |
561 | #ifdef __MACOSX__ |
590 | #ifdef __MACOSX__ |
|
|
591 | static SV *real_main; |
|
|
592 | |
562 | /* to due surprising braindamage on the side of SDL design, we |
593 | /* to due surprising braindamage on the side of SDL design, we |
563 | * do some mind-boggling hack here: SDL requires a custom main() |
594 | * do some mind-boggling hack here: SDL requires a custom main() |
564 | * on OS X, so... we provide one and call the original main(), which, |
595 | * on OS X, so... we provide one and call the original main(), which, |
565 | * due to share dlibrary magic, calls -lSDLmain's main, not perl's main, |
596 | * due to shared library magic, calls -lSDLmain's main, not perl's main, |
566 | * and which calls our main (== SDL_main) back. |
597 | * and which calls our main (== SDL_main) back. |
567 | */ |
598 | */ |
568 | extern C_LINKAGE int |
599 | extern C_LINKAGE int |
569 | main (int argc, char *argv[]) |
600 | main (int argc, char *argv[]) |
570 | { |
601 | { |
571 | deliantra_main (); |
602 | deliantra_main (real_main); |
572 | } |
603 | } |
573 | |
604 | |
574 | #undef main |
605 | #undef main |
575 | |
606 | |
576 | extern C_LINKAGE int main (int argc, char *argv[]); |
607 | extern C_LINKAGE int main (int argc, char *argv[]); |
577 | |
608 | |
578 | static void |
609 | static void |
579 | SDL_braino (void) |
610 | SDL_main_hack (SV *real_main_) |
580 | { |
611 | { |
|
|
612 | real_main = real_main_; |
|
|
613 | |
581 | char *argv[] = { "deliantra client", 0 }; |
614 | char *argv[] = { "deliantra client", 0 }; |
582 | (main) (1, argv); |
615 | (main) (1, argv); |
583 | } |
616 | } |
584 | #else |
617 | #else |
585 | static void |
618 | static void |
586 | SDL_braino (void) |
619 | SDL_main_hack (SV *real_main) |
587 | { |
620 | { |
588 | deliantra_main (); |
621 | deliantra_main (real_main); |
589 | } |
622 | } |
590 | #endif |
623 | #endif |
591 | |
624 | |
592 | MODULE = Deliantra::Client PACKAGE = DC |
625 | MODULE = Deliantra::Client PACKAGE = DC |
593 | |
626 | |
… | |
… | |
794 | |
827 | |
795 | const_iv (FOW_DARKNESS) |
828 | const_iv (FOW_DARKNESS) |
796 | # undef const_iv |
829 | # undef const_iv |
797 | }; |
830 | }; |
798 | |
831 | |
799 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
832 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ > const_iv; civ--) |
800 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
833 | newCONSTSUB (stash, (char *)civ[-1].name, newSViv (civ[-1].iv)); |
801 | |
834 | |
802 | assert (SDLK_MODIFIER_MIN == SDLK_NUMLOCK); |
835 | assert (SDLK_MODIFIER_MIN == SDLK_NUMLOCK); |
803 | assert (SDLK_MODIFIER_MAX == SDLK_COMPOSE); |
836 | assert (SDLK_MODIFIER_MAX == SDLK_COMPOSE); |
804 | } |
837 | } |
805 | |
838 | |
… | |
… | |
844 | #endif |
877 | #endif |
845 | } |
878 | } |
846 | |
879 | |
847 | char *SDL_GetError () |
880 | char *SDL_GetError () |
848 | |
881 | |
849 | void SDL_braino () |
882 | void SDL_main_hack (SV *real_main) |
|
|
883 | PROTOTYPE: & |
850 | |
884 | |
851 | int SDL_Init (U32 flags) |
885 | int SDL_Init (U32 flags) |
852 | |
886 | |
853 | int SDL_InitSubSystem (U32 flags) |
887 | int SDL_InitSubSystem (U32 flags) |
854 | |
888 | |
… | |
… | |
923 | ); |
957 | ); |
924 | |
958 | |
925 | if (RETVAL) |
959 | if (RETVAL) |
926 | { |
960 | { |
927 | av_clear (texture_av); |
961 | av_clear (texture_av); |
928 | |
|
|
929 | SDL_WM_SetCaption ("Deliantra MORPG Client " VERSION, "Deliantra"); |
|
|
930 | #define GL_FUNC(ptr,name) gl.name = (ptr)SDL_GL_GetProcAddress ("gl" # name); |
962 | #define GL_FUNC(ptr,name) gl.name = (ptr)SDL_GL_GetProcAddress ("gl" # name); |
931 | #include "glfunc.h" |
963 | #include "glfunc.h" |
932 | #undef GL_FUNC |
964 | #undef GL_FUNC |
|
|
965 | if (!gl.ActiveTexture ) gl.ActiveTexture = gl.ActiveTextureARB; |
|
|
966 | if (!gl.MultiTexCoord2f) gl.MultiTexCoord2f = gl.MultiTexCoord2fARB; |
933 | } |
967 | } |
934 | } |
968 | } |
935 | OUTPUT: |
969 | OUTPUT: |
936 | RETVAL |
970 | RETVAL |
937 | |
971 | |
938 | void |
972 | void |
|
|
973 | SDL_WM_SetCaption (const char *title, const char *icon) |
|
|
974 | |
|
|
975 | void |
939 | SDL_GL_SwapBuffers () |
976 | SDL_GL_SwapBuffers () |
940 | |
977 | |
941 | char * |
978 | char * |
942 | SDL_GetKeyName (int sym) |
979 | SDL_GetKeyName (int sym) |
943 | |
980 | |
… | |
… | |
945 | SDL_GetAppState () |
982 | SDL_GetAppState () |
946 | |
983 | |
947 | int |
984 | int |
948 | SDL_GetModState () |
985 | SDL_GetModState () |
949 | |
986 | |
|
|
987 | int |
|
|
988 | SDL_WaitEvent () |
|
|
989 | C_ARGS: 0 |
|
|
990 | |
950 | void |
991 | void |
|
|
992 | SDL_PumpEvents () |
|
|
993 | |
|
|
994 | void |
951 | poll_events () |
995 | peep_events () |
952 | PPCODE: |
996 | PPCODE: |
953 | { |
997 | { |
954 | SDL_Event ev; |
998 | SDL_Event ev; |
955 | |
999 | |
956 | SDL_PumpEvents (); |
1000 | SDL_PumpEvents (); |
… | |
… | |
1022 | |
1066 | |
1023 | XPUSHs (sv_2mortal (sv_bless (newRV_noinc ((SV *)hv), gv_stashpv ("DC::UI::Event", 1)))); |
1067 | XPUSHs (sv_2mortal (sv_bless (newRV_noinc ((SV *)hv), gv_stashpv ("DC::UI::Event", 1)))); |
1024 | } |
1068 | } |
1025 | } |
1069 | } |
1026 | |
1070 | |
|
|
1071 | char * |
|
|
1072 | SDL_AudioDriverName () |
|
|
1073 | CODE: |
|
|
1074 | { |
|
|
1075 | char buf [256]; |
|
|
1076 | if (!SDL_AudioDriverName (buf, sizeof (buf))) |
|
|
1077 | XSRETURN_UNDEF; |
|
|
1078 | |
|
|
1079 | RETVAL = buf; |
|
|
1080 | } |
|
|
1081 | OUTPUT: |
|
|
1082 | RETVAL |
|
|
1083 | |
1027 | int |
1084 | int |
1028 | Mix_OpenAudio (int frequency = 44100, int format = MIX_DEFAULT_FORMAT, int channels = 2, int chunksize = 4096) |
1085 | Mix_OpenAudio (int frequency = 44100, int format = MIX_DEFAULT_FORMAT, int channels = 2, int chunksize = 4096) |
1029 | POSTCALL: |
1086 | POSTCALL: |
1030 | Mix_HookMusicFinished (music_finished); |
1087 | Mix_HookMusicFinished (music_finished); |
1031 | Mix_ChannelFinished (channel_finished); |
1088 | Mix_ChannelFinished (channel_finished); |
… | |
… | |
1093 | add_font (char *file) |
1150 | add_font (char *file) |
1094 | CODE: |
1151 | CODE: |
1095 | RETVAL = FcConfigAppFontAddFile (0, (const FcChar8 *)file); |
1152 | RETVAL = FcConfigAppFontAddFile (0, (const FcChar8 *)file); |
1096 | OUTPUT: |
1153 | OUTPUT: |
1097 | RETVAL |
1154 | RETVAL |
|
|
1155 | |
|
|
1156 | void |
|
|
1157 | IMG_Init (int flags = IMG_INIT_JPG | IMG_INIT_PNG) |
|
|
1158 | |
|
|
1159 | # MIX_INIT_MP3 gives smpeg + libstdc++ + libgcc_s |
|
|
1160 | void |
|
|
1161 | Mix_Init (int flags = MIX_INIT_MOD | MIX_INIT_OGG) |
1098 | |
1162 | |
1099 | void |
1163 | void |
1100 | load_image_inline (SV *image_) |
1164 | load_image_inline (SV *image_) |
1101 | ALIAS: |
1165 | ALIAS: |
1102 | load_image_file = 1 |
1166 | load_image_file = 1 |
… | |
… | |
1670 | void |
1734 | void |
1671 | 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) |
1735 | 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) |
1672 | PROTOTYPE: @ |
1736 | PROTOTYPE: @ |
1673 | CODE: |
1737 | CODE: |
1674 | { |
1738 | { |
|
|
1739 | glEnable (GL_BLEND); |
|
|
1740 | glBlendFunc (intensity ? GL_SRC_ALPHA : GL_ONE, GL_ONE_MINUS_SRC_ALPHA); |
1675 | glEnable (GL_TEXTURE_2D); |
1741 | glEnable (GL_TEXTURE_2D); |
1676 | glEnable (GL_BLEND); |
|
|
1677 | glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA); |
|
|
1678 | glBindTexture (GL_TEXTURE_2D, name1); |
1742 | glBindTexture (GL_TEXTURE_2D, name1); |
1679 | |
1743 | |
1680 | glColor3f (intensity, intensity, intensity); |
1744 | glColor3f (intensity, intensity, intensity); |
1681 | glPushMatrix (); |
1745 | glPushMatrix (); |
1682 | glScalef (1./3, 1./3, 1.); |
1746 | glScalef (1./3, 1./3, 1.); |
… | |
… | |
1697 | glBindTexture (GL_TEXTURE_2D, name2); |
1761 | glBindTexture (GL_TEXTURE_2D, name2); |
1698 | glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE); |
1762 | glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE); |
1699 | |
1763 | |
1700 | /* rgb == rgb(glcolor) */ |
1764 | /* rgb == rgb(glcolor) */ |
1701 | glTexEnvi (GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_REPLACE); |
1765 | glTexEnvi (GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_REPLACE); |
1702 | glTexEnvi (GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_CONSTANT); |
1766 | glTexEnvi (GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_PRIMARY_COLOR); |
1703 | glTexEnvi (GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR); |
1767 | glTexEnvi (GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR); |
1704 | |
1768 | |
1705 | /* alpha = interpolate t0, t1 by env_alpha */ |
1769 | /* alpha = interpolate t0, t1 by env_alpha */ |
1706 | glTexEnvfv (GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, env_color); |
1770 | glTexEnvfv (GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, env_color); |
1707 | |
1771 | |
… | |
… | |
2094 | ? self->row + y |
2158 | ? self->row + y |
2095 | : 0; |
2159 | : 0; |
2096 | |
2160 | |
2097 | for (x = x0; x < x1; x++) |
2161 | for (x = x0; x < x1; x++) |
2098 | { |
2162 | { |
2099 | int r = 32, g = 32, b = 32, a = 192; |
2163 | unsigned int r = 32, g = 32, b = 32, a = 192; |
2100 | |
2164 | |
2101 | if (row && row->c0 <= x && x < row->c1) |
2165 | if (row && row->c0 <= x && x < row->c1) |
2102 | { |
2166 | { |
2103 | mapcell *cell = row->col + (x - row->c0); |
2167 | mapcell *cell = row->col + (x - row->c0); |
2104 | |
2168 | |
… | |
… | |
2106 | { |
2170 | { |
2107 | maptex tex = self->tex [cell->tile [z]]; |
2171 | maptex tex = self->tex [cell->tile [z]]; |
2108 | int a0 = 255 - tex.a; |
2172 | int a0 = 255 - tex.a; |
2109 | int a1 = tex.a; |
2173 | int a1 = tex.a; |
2110 | |
2174 | |
2111 | r = (r * a0 + tex.r * a1) / 255; |
2175 | r = div255 (r * a0 + tex.r * a1); |
2112 | g = (g * a0 + tex.g * a1) / 255; |
2176 | g = div255 (g * a0 + tex.g * a1); |
2113 | b = (b * a0 + tex.b * a1) / 255; |
2177 | b = div255 (b * a0 + tex.b * a1); |
2114 | a = (a * a0 + tex.a * a1) / 255; |
2178 | a = div255 (a * a0 + tex.a * a1); |
2115 | } |
2179 | } |
2116 | } |
2180 | } |
2117 | |
2181 | |
2118 | *map++ = (r ) |
2182 | *map++ = (r ) |
2119 | | (g << 8) |
2183 | | (g << 8) |
… | |
… | |
2126 | } |
2190 | } |
2127 | OUTPUT: |
2191 | OUTPUT: |
2128 | RETVAL |
2192 | RETVAL |
2129 | |
2193 | |
2130 | void |
2194 | void |
2131 | draw (DC::Map self, int mx, int my, int sw, int sh, int T, U32 player = 0xffffffff, int sdx = 0, int sdy = 0) |
2195 | 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) |
2132 | CODE: |
2196 | CODE: |
2133 | { |
2197 | { |
2134 | int x, y, z; |
2198 | int x, y, z; |
2135 | |
2199 | |
2136 | HV *smooth = (HV *)sv_2mortal ((SV *)newHV ()); |
2200 | HV *smooth = (HV *)sv_2mortal ((SV *)newHV ()); |
… | |
… | |
2220 | |
2284 | |
2221 | key.texname = tex.name; |
2285 | key.texname = tex.name; |
2222 | arr = rc_array (rc, &key); |
2286 | arr = rc_array (rc, &key); |
2223 | } |
2287 | } |
2224 | |
2288 | |
2225 | px = (x + 1) * T - tex.w; |
2289 | px = (x + 1) * Th - tex.w; |
2226 | py = (y + 1) * T - tex.h; |
2290 | py = (y + 1) * Tw - tex.h; |
2227 | |
2291 | |
2228 | if (expect_false (cell->player == player) && expect_false (z == 2)) |
2292 | if (expect_false (cell->player == player) && expect_false (z == 2)) |
2229 | { |
2293 | { |
2230 | pl_x = px; |
2294 | pl_x = px; |
2231 | pl_y = py; |
2295 | pl_y = py; |
… | |
… | |
2284 | if (cell->flags & 1) |
2348 | if (cell->flags & 1) |
2285 | { |
2349 | { |
2286 | rc_key_t key_ov = key; |
2350 | rc_key_t key_ov = key; |
2287 | maptex tex = self->tex [TEXID_SPEECH]; |
2351 | maptex tex = self->tex [TEXID_SPEECH]; |
2288 | rc_array_t *arr; |
2352 | rc_array_t *arr; |
2289 | int px = x * T + T * 2 / 32; |
2353 | int px = x * Tw + Tw * 2 / 32; |
2290 | int py = y * T - T * 6 / 32; |
2354 | int py = y * Th - Th * 6 / 32; |
2291 | |
2355 | |
2292 | key_ov.texname = tex.name; |
2356 | key_ov.texname = tex.name; |
2293 | arr = rc_array (rc_ov, &key_ov); |
2357 | arr = rc_array (rc_ov, &key_ov); |
2294 | |
2358 | |
2295 | rc_t2f_v3f (arr, 0 , 0 , px , py , 0); |
2359 | rc_t2f_v3f (arr, 0 , 0 , px , py , 0); |
2296 | rc_t2f_v3f (arr, 0 , tex.t, px , py + T, 0); |
2360 | rc_t2f_v3f (arr, 0 , tex.t, px , py + Th, 0); |
2297 | rc_t2f_v3f (arr, tex.s, tex.t, px + T, py + T, 0); |
2361 | rc_t2f_v3f (arr, tex.s, tex.t, px + Tw, py + Th, 0); |
2298 | rc_t2f_v3f (arr, tex.s, 0 , px + T, py , 0); |
2362 | rc_t2f_v3f (arr, tex.s, 0 , px + Tw, py , 0); |
2299 | } |
2363 | } |
2300 | } |
2364 | } |
2301 | } |
2365 | } |
2302 | } |
2366 | } |
2303 | |
2367 | |
… | |
… | |
2330 | if (!(bits & 0x1000) |
2394 | if (!(bits & 0x1000) |
2331 | && skey->level == level |
2395 | && skey->level == level |
2332 | && level > smooth_max [skey->x][skey->y]) |
2396 | && level > smooth_max [skey->x][skey->y]) |
2333 | { |
2397 | { |
2334 | maptex tex = self->tex [skey->tile]; |
2398 | maptex tex = self->tex [skey->tile]; |
2335 | int px = (((int)skey->x) - 1) * T; |
2399 | int px = (((int)skey->x) - 1) * Tw; |
2336 | int py = (((int)skey->y) - 1) * T; |
2400 | int py = (((int)skey->y) - 1) * Th; |
2337 | int border = bits & 15; |
2401 | int border = bits & 15; |
2338 | int corner = (bits >> 8) & ~(bits >> 4) & 15; |
2402 | int corner = (bits >> 8) & ~(bits >> 4) & 15; |
2339 | float dx = tex.s * .0625f; // 16 images/row |
2403 | float dx = tex.s * .0625f; // 16 images/row |
2340 | float dy = tex.t * .5f ; // 2 images/column |
2404 | float dy = tex.t * .5f ; // 2 images/column |
2341 | |
2405 | |
… | |
… | |
2354 | |
2418 | |
2355 | if (border) |
2419 | if (border) |
2356 | { |
2420 | { |
2357 | float ox = border * dx; |
2421 | float ox = border * dx; |
2358 | |
2422 | |
2359 | glTexCoord2f (ox , 0.f ); glVertex2i (px , py ); |
2423 | glTexCoord2f (ox , 0.f ); glVertex2i (px , py ); |
2360 | glTexCoord2f (ox , dy ); glVertex2i (px , py + T); |
2424 | glTexCoord2f (ox , dy ); glVertex2i (px , py + Th); |
2361 | glTexCoord2f (ox + dx, dy ); glVertex2i (px + T, py + T); |
2425 | glTexCoord2f (ox + dx, dy ); glVertex2i (px + Tw, py + Th); |
2362 | glTexCoord2f (ox + dx, 0.f ); glVertex2i (px + T, py ); |
2426 | glTexCoord2f (ox + dx, 0.f ); glVertex2i (px + Tw, py ); |
2363 | } |
2427 | } |
2364 | |
2428 | |
2365 | if (corner) |
2429 | if (corner) |
2366 | { |
2430 | { |
2367 | float ox = corner * dx; |
2431 | float ox = corner * dx; |
2368 | |
2432 | |
2369 | glTexCoord2f (ox , dy ); glVertex2i (px , py ); |
2433 | glTexCoord2f (ox , dy ); glVertex2i (px , py ); |
2370 | glTexCoord2f (ox , dy * 2.f); glVertex2i (px , py + T); |
2434 | glTexCoord2f (ox , dy * 2.f); glVertex2i (px , py + Th); |
2371 | glTexCoord2f (ox + dx, dy * 2.f); glVertex2i (px + T, py + T); |
2435 | glTexCoord2f (ox + dx, dy * 2.f); glVertex2i (px + Tw, py + Th); |
2372 | glTexCoord2f (ox + dx, dy ); glVertex2i (px + T, py ); |
2436 | glTexCoord2f (ox + dx, dy ); glVertex2i (px + Tw, py ); |
2373 | } |
2437 | } |
2374 | } |
2438 | } |
2375 | } |
2439 | } |
2376 | } |
2440 | } |
2377 | } |
2441 | } |
… | |
… | |
2418 | for (x = 0; x < sw; x++) |
2482 | for (x = 0; x < sw; x++) |
2419 | if (row->c0 <= x + mx && x + mx < row->c1) |
2483 | if (row->c0 <= x + mx && x + mx < row->c1) |
2420 | { |
2484 | { |
2421 | mapcell *cell = row->col + (x + mx - row->c0); |
2485 | mapcell *cell = row->col + (x + mx - row->c0); |
2422 | |
2486 | |
2423 | int px = x * T; |
2487 | int px = x * Tw; |
2424 | int py = y * T; |
2488 | int py = y * Th; |
2425 | |
2489 | |
2426 | if (expect_false (cell->player == player)) |
2490 | if (expect_false (cell->player == player)) |
2427 | { |
2491 | { |
2428 | px += sdx; |
2492 | px += sdx; |
2429 | py += sdy; |
2493 | py += sdy; |
2430 | } |
2494 | } |
2431 | |
2495 | |
2432 | if (cell->stat_hp) |
2496 | if (cell->stat_hp) |
2433 | { |
2497 | { |
2434 | int width = cell->stat_width * T; |
2498 | int width = cell->stat_width * Tw; |
2435 | int thick = (sh * T / 32 + 27) / 28 + 1 + cell->stat_width; |
2499 | int thick = (sh * Th / 32 + 27) / 28 + 1 + cell->stat_width; |
2436 | |
2500 | |
2437 | glColor3ub (0, 0, 0); |
2501 | glColor3ub (0, 0, 0); |
2438 | glRectf (px + 1, py - thick - 2, |
2502 | glRectf (px + 1, py - thick - 2, |
2439 | px + width - 1, py); |
2503 | px + width - 1, py); |
2440 | |
2504 | |
… | |
… | |
2520 | int x, y; |
2584 | int x, y; |
2521 | int sw1 = sw + 2; |
2585 | int sw1 = sw + 2; |
2522 | int sh1 = sh + 2; |
2586 | int sh1 = sh + 2; |
2523 | int sh3 = sh * 3; |
2587 | int sh3 = sh * 3; |
2524 | int sw3 = sw * 3; |
2588 | int sw3 = sw * 3; |
2525 | uint8_t *darkness1 = (uint8_t *)malloc (sw1 * sh1); |
|
|
2526 | SV *darkness3_sv = sv_2mortal (newSV (sw3 * sh3)); |
2589 | SV *darkness3_sv = sv_2mortal (newSV (sw3 * sh3)); |
2527 | uint8_t *darkness3 = (uint8_t *)SvPVX (darkness3_sv); |
2590 | uint8_t *darkness3 = (uint8_t *)SvPVX (darkness3_sv); |
|
|
2591 | uint8_t *darkness1 = (uint8_t *)malloc (sw1 * sh1); |
|
|
2592 | memset (darkness1, 0, sw1*sh1); |
2528 | |
2593 | |
2529 | SvPOK_only (darkness3_sv); |
2594 | SvPOK_only (darkness3_sv); |
2530 | SvCUR_set (darkness3_sv, sw3 * sh3); |
2595 | SvCUR_set (darkness3_sv, sw3 * sh3); |
2531 | |
2596 | |
2532 | mx += self->x - 1; |
2597 | mx += self->x - 1; |
… | |
… | |
2793 | if (RETVAL < 0) |
2858 | if (RETVAL < 0) |
2794 | { |
2859 | { |
2795 | RETVAL = Mix_GroupOldest (-1); |
2860 | RETVAL = Mix_GroupOldest (-1); |
2796 | |
2861 | |
2797 | if (RETVAL < 0) |
2862 | if (RETVAL < 0) |
|
|
2863 | { |
|
|
2864 | // happens sometimes, maybe it just stopped playing(?) |
|
|
2865 | RETVAL = Mix_GroupAvailable (-1); |
|
|
2866 | |
|
|
2867 | if (RETVAL < 0) |
2798 | XSRETURN_UNDEF; |
2868 | XSRETURN_UNDEF; |
2799 | |
2869 | } |
|
|
2870 | else |
2800 | Mix_HaltChannel (RETVAL); |
2871 | Mix_HaltChannel (RETVAL); |
2801 | } |
2872 | } |
2802 | |
2873 | |
2803 | Mix_UnregisterAllEffects (RETVAL); |
2874 | Mix_UnregisterAllEffects (RETVAL); |
2804 | Mix_Volume (RETVAL, 128); |
2875 | Mix_Volume (RETVAL, 128); |
2805 | } |
2876 | } |
… | |
… | |
2864 | Mix_SetReverseStereo (self, flip); |
2935 | Mix_SetReverseStereo (self, flip); |
2865 | |
2936 | |
2866 | MODULE = Deliantra::Client PACKAGE = DC::MixChunk |
2937 | MODULE = Deliantra::Client PACKAGE = DC::MixChunk |
2867 | |
2938 | |
2868 | PROTOTYPES: DISABLE |
2939 | PROTOTYPES: DISABLE |
|
|
2940 | |
|
|
2941 | void |
|
|
2942 | decoders () |
|
|
2943 | PPCODE: |
|
|
2944 | #if SDL_MIXER_MAJOR_VERSION > 1 || SDL_MIXER_MINOR_VERSION > 2 || SDL_MIXER_PATCHLEVEL >= 10 |
|
|
2945 | int i, num = Mix_GetNumChunkDecoders (); |
|
|
2946 | EXTEND (SP, num); |
|
|
2947 | for (i = 0; i < num; ++i) |
|
|
2948 | PUSHs (sv_2mortal (newSVpv (Mix_GetChunkDecoder (i), 0))); |
|
|
2949 | #else |
|
|
2950 | XPUSHs (sv_2mortal (newSVpv ("(sdl mixer too old)", 0))); |
|
|
2951 | #endif |
2869 | |
2952 | |
2870 | DC::MixChunk |
2953 | DC::MixChunk |
2871 | new (SV *class, DC::RW rwops) |
2954 | new (SV *class, DC::RW rwops) |
2872 | CODE: |
2955 | CODE: |
2873 | RETVAL = Mix_LoadWAV_RW (rwops, 1); |
2956 | RETVAL = Mix_LoadWAV_RW (rwops, 1); |
… | |
… | |
2906 | OUTPUT: |
2989 | OUTPUT: |
2907 | RETVAL |
2990 | RETVAL |
2908 | |
2991 | |
2909 | MODULE = Deliantra::Client PACKAGE = DC::MixMusic |
2992 | MODULE = Deliantra::Client PACKAGE = DC::MixMusic |
2910 | |
2993 | |
|
|
2994 | void |
|
|
2995 | decoders () |
|
|
2996 | PPCODE: |
|
|
2997 | #if SDL_MIXER_MAJOR_VERSION > 1 || SDL_MIXER_MINOR_VERSION > 2 || SDL_MIXER_PATCHLEVEL >= 10 |
|
|
2998 | int i, num = Mix_GetNumMusicDecoders (); |
|
|
2999 | EXTEND (SP, num); |
|
|
3000 | for (i = 0; i < num; ++i) |
|
|
3001 | PUSHs (sv_2mortal (newSVpv (Mix_GetMusicDecoder (i), 0))); |
|
|
3002 | #else |
|
|
3003 | XPUSHs (sv_2mortal (newSVpv ("(sdl mixer too old)", 0))); |
|
|
3004 | #endif |
|
|
3005 | |
2911 | int |
3006 | int |
2912 | volume (int volume = -1) |
3007 | volume (int volume = -1) |
2913 | PROTOTYPE: ;$ |
3008 | PROTOTYPE: ;$ |
2914 | CODE: |
3009 | CODE: |
2915 | if (items > 0) |
3010 | if (items > 0) |
… | |
… | |
2925 | |
3020 | |
2926 | void |
3021 | void |
2927 | halt () |
3022 | halt () |
2928 | CODE: |
3023 | CODE: |
2929 | Mix_HaltMusic (); |
3024 | Mix_HaltMusic (); |
|
|
3025 | |
|
|
3026 | int |
|
|
3027 | playing () |
|
|
3028 | CODE: |
|
|
3029 | RETVAL = Mix_PlayingMusic (); |
|
|
3030 | OUTPUT: |
|
|
3031 | RETVAL |
2930 | |
3032 | |
2931 | DC::MixMusic |
3033 | DC::MixMusic |
2932 | new (SV *class, DC::RW rwops) |
3034 | new (SV *class, DC::RW rwops) |
2933 | CODE: |
3035 | CODE: |
2934 | RETVAL = Mix_LoadMUS_RW (rwops); |
3036 | RETVAL = Mix_LoadMUS_RW (rwops); |
… | |
… | |
3074 | const_iv (GL_FUNC_SUBTRACT), |
3176 | const_iv (GL_FUNC_SUBTRACT), |
3075 | const_iv (GL_FUNC_REVERSE_SUBTRACT), |
3177 | const_iv (GL_FUNC_REVERSE_SUBTRACT), |
3076 | # undef const_iv |
3178 | # undef const_iv |
3077 | }; |
3179 | }; |
3078 | |
3180 | |
3079 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
3181 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ > const_iv; civ--) |
3080 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
3182 | newCONSTSUB (stash, (char *)civ[-1].name, newSViv (civ[-1].iv)); |
3081 | |
3183 | |
3082 | texture_av = newAV (); |
3184 | texture_av = newAV (); |
3083 | AvREAL_off (texture_av); |
3185 | AvREAL_off (texture_av); |
3084 | } |
3186 | } |
3085 | |
3187 | |
… | |
… | |
3128 | RETVAL |
3230 | RETVAL |
3129 | |
3231 | |
3130 | int glGetError () |
3232 | int glGetError () |
3131 | |
3233 | |
3132 | void glFinish () |
3234 | void glFinish () |
|
|
3235 | |
|
|
3236 | void glFlush () |
3133 | |
3237 | |
3134 | void glClear (int mask) |
3238 | void glClear (int mask) |
3135 | |
3239 | |
3136 | void glClearColor (float r, float g, float b, float a = 1.0) |
3240 | void glClearColor (float r, float g, float b, float a = 1.0) |
3137 | PROTOTYPE: @ |
3241 | PROTOTYPE: @ |