… | |
… | |
99 | |
99 | |
100 | #define KMOD_LRAM 0x10000 // our extension |
100 | #define KMOD_LRAM 0x10000 // our extension |
101 | |
101 | |
102 | #define TEXID_SPEECH 1 |
102 | #define TEXID_SPEECH 1 |
103 | #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 | } |
104 | |
123 | |
105 | static AV *texture_av; |
124 | static AV *texture_av; |
106 | |
125 | |
107 | static struct |
126 | static struct |
108 | { |
127 | { |
… | |
… | |
463 | |
482 | |
464 | SDL_PushEvent ((SDL_Event *)&ev); |
483 | SDL_PushEvent ((SDL_Event *)&ev); |
465 | } |
484 | } |
466 | |
485 | |
467 | 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 |
468 | minpot (unsigned int n) |
493 | minpot (unsigned int n) |
469 | { |
494 | { |
470 | if (!n) |
495 | if (!n) |
471 | return 0; |
496 | return 0; |
472 | |
497 | |
… | |
… | |
552 | |
577 | |
553 | return mod; |
578 | return mod; |
554 | } |
579 | } |
555 | |
580 | |
556 | static void |
581 | static void |
557 | deliantra_main () |
582 | deliantra_main (SV *real_main) |
558 | { |
583 | { |
559 | char *argv[] = { 0 }; |
584 | dSP; |
560 | call_argv ("::main", G_DISCARD | G_VOID, argv); |
585 | |
|
|
586 | PUSHMARK (SP); |
|
|
587 | call_sv (real_main, G_DISCARD | G_VOID); |
561 | } |
588 | } |
562 | |
589 | |
563 | #ifdef __MACOSX__ |
590 | #ifdef __MACOSX__ |
|
|
591 | static SV *real_main; |
|
|
592 | |
564 | /* to due surprising braindamage on the side of SDL design, we |
593 | /* to due surprising braindamage on the side of SDL design, we |
565 | * do some mind-boggling hack here: SDL requires a custom main() |
594 | * do some mind-boggling hack here: SDL requires a custom main() |
566 | * 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, |
567 | * 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, |
568 | * and which calls our main (== SDL_main) back. |
597 | * and which calls our main (== SDL_main) back. |
569 | */ |
598 | */ |
570 | extern C_LINKAGE int |
599 | extern C_LINKAGE int |
571 | main (int argc, char *argv[]) |
600 | main (int argc, char *argv[]) |
572 | { |
601 | { |
573 | deliantra_main (); |
602 | deliantra_main (real_main); |
574 | } |
603 | } |
575 | |
604 | |
576 | #undef main |
605 | #undef main |
577 | |
606 | |
578 | extern C_LINKAGE int main (int argc, char *argv[]); |
607 | extern C_LINKAGE int main (int argc, char *argv[]); |
579 | |
608 | |
580 | static void |
609 | static void |
581 | SDL_braino (void) |
610 | SDL_main_hack (SV *real_main_) |
582 | { |
611 | { |
|
|
612 | real_main = real_main_; |
|
|
613 | |
583 | char *argv[] = { "deliantra client", 0 }; |
614 | char *argv[] = { "deliantra client", 0 }; |
584 | (main) (1, argv); |
615 | (main) (1, argv); |
585 | } |
616 | } |
586 | #else |
617 | #else |
587 | static void |
618 | static void |
588 | SDL_braino (void) |
619 | SDL_main_hack (SV *real_main) |
589 | { |
620 | { |
590 | deliantra_main (); |
621 | deliantra_main (real_main); |
591 | } |
622 | } |
592 | #endif |
623 | #endif |
593 | |
624 | |
594 | MODULE = Deliantra::Client PACKAGE = DC |
625 | MODULE = Deliantra::Client PACKAGE = DC |
595 | |
626 | |
… | |
… | |
796 | |
827 | |
797 | const_iv (FOW_DARKNESS) |
828 | const_iv (FOW_DARKNESS) |
798 | # undef const_iv |
829 | # undef const_iv |
799 | }; |
830 | }; |
800 | |
831 | |
801 | 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--) |
802 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
833 | newCONSTSUB (stash, (char *)civ[-1].name, newSViv (civ[-1].iv)); |
803 | |
834 | |
804 | assert (SDLK_MODIFIER_MIN == SDLK_NUMLOCK); |
835 | assert (SDLK_MODIFIER_MIN == SDLK_NUMLOCK); |
805 | assert (SDLK_MODIFIER_MAX == SDLK_COMPOSE); |
836 | assert (SDLK_MODIFIER_MAX == SDLK_COMPOSE); |
806 | } |
837 | } |
807 | |
838 | |
… | |
… | |
846 | #endif |
877 | #endif |
847 | } |
878 | } |
848 | |
879 | |
849 | char *SDL_GetError () |
880 | char *SDL_GetError () |
850 | |
881 | |
851 | void SDL_braino () |
882 | void SDL_main_hack (SV *real_main) |
|
|
883 | PROTOTYPE: & |
852 | |
884 | |
853 | int SDL_Init (U32 flags) |
885 | int SDL_Init (U32 flags) |
854 | |
886 | |
855 | int SDL_InitSubSystem (U32 flags) |
887 | int SDL_InitSubSystem (U32 flags) |
856 | |
888 | |
… | |
… | |
925 | ); |
957 | ); |
926 | |
958 | |
927 | if (RETVAL) |
959 | if (RETVAL) |
928 | { |
960 | { |
929 | av_clear (texture_av); |
961 | av_clear (texture_av); |
930 | |
|
|
931 | SDL_WM_SetCaption ("Deliantra MORPG Client " VERSION, "Deliantra"); |
|
|
932 | #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); |
933 | #include "glfunc.h" |
963 | #include "glfunc.h" |
934 | #undef GL_FUNC |
964 | #undef GL_FUNC |
935 | |
|
|
936 | if (!gl.ActiveTexture ) gl.ActiveTexture = gl.ActiveTextureARB; |
965 | if (!gl.ActiveTexture ) gl.ActiveTexture = gl.ActiveTextureARB; |
937 | if (!gl.MultiTexCoord2f) gl.MultiTexCoord2f = gl.MultiTexCoord2fARB; |
966 | if (!gl.MultiTexCoord2f) gl.MultiTexCoord2f = gl.MultiTexCoord2fARB; |
938 | } |
967 | } |
939 | } |
968 | } |
940 | OUTPUT: |
969 | OUTPUT: |
941 | RETVAL |
970 | RETVAL |
942 | |
971 | |
943 | void |
972 | void |
|
|
973 | SDL_WM_SetCaption (const char *title, const char *icon) |
|
|
974 | |
|
|
975 | void |
944 | SDL_GL_SwapBuffers () |
976 | SDL_GL_SwapBuffers () |
945 | |
977 | |
946 | char * |
978 | char * |
947 | SDL_GetKeyName (int sym) |
979 | SDL_GetKeyName (int sym) |
948 | |
980 | |
… | |
… | |
950 | SDL_GetAppState () |
982 | SDL_GetAppState () |
951 | |
983 | |
952 | int |
984 | int |
953 | SDL_GetModState () |
985 | SDL_GetModState () |
954 | |
986 | |
|
|
987 | int |
|
|
988 | SDL_WaitEvent () |
|
|
989 | C_ARGS: 0 |
|
|
990 | |
955 | void |
991 | void |
|
|
992 | SDL_PumpEvents () |
|
|
993 | |
|
|
994 | void |
956 | poll_events () |
995 | peep_events () |
957 | PPCODE: |
996 | PPCODE: |
958 | { |
997 | { |
959 | SDL_Event ev; |
998 | SDL_Event ev; |
960 | |
999 | |
961 | SDL_PumpEvents (); |
1000 | SDL_PumpEvents (); |
… | |
… | |
1027 | |
1066 | |
1028 | 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)))); |
1029 | } |
1068 | } |
1030 | } |
1069 | } |
1031 | |
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 | |
1032 | int |
1084 | int |
1033 | 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) |
1034 | POSTCALL: |
1086 | POSTCALL: |
1035 | Mix_HookMusicFinished (music_finished); |
1087 | Mix_HookMusicFinished (music_finished); |
1036 | Mix_ChannelFinished (channel_finished); |
1088 | Mix_ChannelFinished (channel_finished); |
… | |
… | |
1098 | add_font (char *file) |
1150 | add_font (char *file) |
1099 | CODE: |
1151 | CODE: |
1100 | RETVAL = FcConfigAppFontAddFile (0, (const FcChar8 *)file); |
1152 | RETVAL = FcConfigAppFontAddFile (0, (const FcChar8 *)file); |
1101 | OUTPUT: |
1153 | OUTPUT: |
1102 | 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) |
1103 | |
1162 | |
1104 | void |
1163 | void |
1105 | load_image_inline (SV *image_) |
1164 | load_image_inline (SV *image_) |
1106 | ALIAS: |
1165 | ALIAS: |
1107 | load_image_file = 1 |
1166 | load_image_file = 1 |
… | |
… | |
1973 | self->y += MAP_EXTEND_Y; |
2032 | self->y += MAP_EXTEND_Y; |
1974 | } |
2033 | } |
1975 | } |
2034 | } |
1976 | |
2035 | |
1977 | SV * |
2036 | SV * |
1978 | map1a_update (DC::Map self, SV *data_, int extmap) |
2037 | map1a_update (DC::Map self, SV *data_) |
1979 | CODE: |
2038 | CODE: |
1980 | { |
2039 | { |
1981 | uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_); |
2040 | uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_); |
1982 | uint8_t *data_end = (uint8_t *)SvEND (data_); |
2041 | uint8_t *data_end = (uint8_t *)SvEND (data_); |
1983 | mapcell *cell; |
2042 | mapcell *cell; |
… | |
… | |
2004 | |
2063 | |
2005 | //TODO: don't trust server data to be in-range(!) |
2064 | //TODO: don't trust server data to be in-range(!) |
2006 | |
2065 | |
2007 | if (flags & 8) |
2066 | if (flags & 8) |
2008 | { |
2067 | { |
|
|
2068 | uint8_t ext, cmd; |
|
|
2069 | |
2009 | if (extmap) |
2070 | do |
2010 | { |
2071 | { |
2011 | uint8_t ext, cmd; |
2072 | ext = *data++; |
|
|
2073 | cmd = ext & 0x7f; |
2012 | |
2074 | |
2013 | do |
2075 | if (cmd < 4) |
|
|
2076 | cell->darkness = 255 - ext * 64 + 1; /* make sure this doesn't collide with FOW_DARKNESS */ |
|
|
2077 | else if (cmd == 5) // health |
2014 | { |
2078 | { |
2015 | ext = *data++; |
|
|
2016 | cmd = ext & 0x7f; |
|
|
2017 | |
|
|
2018 | if (cmd < 4) |
|
|
2019 | cell->darkness = 255 - ext * 64 + 1; /* make sure this doesn't collide with FOW_DARKNESS */ |
|
|
2020 | else if (cmd == 5) // health |
|
|
2021 | { |
|
|
2022 | cell->stat_width = 1; |
2079 | cell->stat_width = 1; |
2023 | cell->stat_hp = *data++; |
2080 | cell->stat_hp = *data++; |
2024 | } |
|
|
2025 | else if (cmd == 6) // monster width |
|
|
2026 | cell->stat_width = *data++ + 1; |
|
|
2027 | else if (cmd == 0x47) |
|
|
2028 | { |
|
|
2029 | if (*data == 1) cell->player = data [1]; |
|
|
2030 | else if (*data == 2) cell->player = data [2] + (data [1] << 8); |
|
|
2031 | else if (*data == 3) cell->player = data [3] + (data [2] << 8) + (data [1] << 16); |
|
|
2032 | else if (*data == 4) cell->player = data [4] + (data [3] << 8) + (data [2] << 16) + (data [1] << 24); |
|
|
2033 | |
|
|
2034 | data += *data + 1; |
|
|
2035 | } |
|
|
2036 | else if (cmd == 8) // cell flags |
|
|
2037 | cell->flags = *data++; |
|
|
2038 | else if (ext & 0x40) // unknown, multibyte => skip |
|
|
2039 | data += *data + 1; |
|
|
2040 | else |
|
|
2041 | data++; |
|
|
2042 | } |
2081 | } |
2043 | while (ext & 0x80); |
2082 | else if (cmd == 6) // monster width |
|
|
2083 | cell->stat_width = *data++ + 1; |
|
|
2084 | else if (cmd == 0x47) |
|
|
2085 | { |
|
|
2086 | if (*data == 1) cell->player = data [1]; |
|
|
2087 | else if (*data == 2) cell->player = data [2] + (data [1] << 8); |
|
|
2088 | else if (*data == 3) cell->player = data [3] + (data [2] << 8) + (data [1] << 16); |
|
|
2089 | else if (*data == 4) cell->player = data [4] + (data [3] << 8) + (data [2] << 16) + (data [1] << 24); |
|
|
2090 | |
|
|
2091 | data += *data + 1; |
|
|
2092 | } |
|
|
2093 | else if (cmd == 8) // cell flags |
|
|
2094 | cell->flags = *data++; |
|
|
2095 | else if (ext & 0x40) // unknown, multibyte => skip |
|
|
2096 | data += *data + 1; |
|
|
2097 | else |
|
|
2098 | data++; |
2044 | } |
2099 | } |
2045 | else |
2100 | while (ext & 0x80); |
2046 | cell->darkness = *data++ + 1; |
|
|
2047 | } |
2101 | } |
2048 | |
2102 | |
2049 | for (z = 0; z <= 2; ++z) |
2103 | for (z = 0; z <= 2; ++z) |
2050 | if (flags & (4 >> z)) |
2104 | if (flags & (4 >> z)) |
2051 | { |
2105 | { |
… | |
… | |
2099 | ? self->row + y |
2153 | ? self->row + y |
2100 | : 0; |
2154 | : 0; |
2101 | |
2155 | |
2102 | for (x = x0; x < x1; x++) |
2156 | for (x = x0; x < x1; x++) |
2103 | { |
2157 | { |
2104 | int r = 32, g = 32, b = 32, a = 192; |
2158 | unsigned int r = 32, g = 32, b = 32, a = 192; |
2105 | |
2159 | |
2106 | if (row && row->c0 <= x && x < row->c1) |
2160 | if (row && row->c0 <= x && x < row->c1) |
2107 | { |
2161 | { |
2108 | mapcell *cell = row->col + (x - row->c0); |
2162 | mapcell *cell = row->col + (x - row->c0); |
2109 | |
2163 | |
… | |
… | |
2111 | { |
2165 | { |
2112 | maptex tex = self->tex [cell->tile [z]]; |
2166 | maptex tex = self->tex [cell->tile [z]]; |
2113 | int a0 = 255 - tex.a; |
2167 | int a0 = 255 - tex.a; |
2114 | int a1 = tex.a; |
2168 | int a1 = tex.a; |
2115 | |
2169 | |
2116 | r = (r * a0 + tex.r * a1) / 255; |
2170 | r = div255 (r * a0 + tex.r * a1); |
2117 | g = (g * a0 + tex.g * a1) / 255; |
2171 | g = div255 (g * a0 + tex.g * a1); |
2118 | b = (b * a0 + tex.b * a1) / 255; |
2172 | b = div255 (b * a0 + tex.b * a1); |
2119 | a = (a * a0 + tex.a * a1) / 255; |
2173 | a = div255 (a * a0 + tex.a * a1); |
2120 | } |
2174 | } |
2121 | } |
2175 | } |
2122 | |
2176 | |
2123 | *map++ = (r ) |
2177 | *map++ = (r ) |
2124 | | (g << 8) |
2178 | | (g << 8) |
… | |
… | |
2131 | } |
2185 | } |
2132 | OUTPUT: |
2186 | OUTPUT: |
2133 | RETVAL |
2187 | RETVAL |
2134 | |
2188 | |
2135 | void |
2189 | void |
2136 | draw (DC::Map self, int mx, int my, int sw, int sh, int T, U32 player = 0xffffffff, int sdx = 0, int sdy = 0) |
2190 | 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) |
2137 | CODE: |
2191 | CODE: |
2138 | { |
2192 | { |
2139 | int x, y, z; |
2193 | int x, y, z; |
2140 | |
2194 | |
2141 | HV *smooth = (HV *)sv_2mortal ((SV *)newHV ()); |
2195 | HV *smooth = (HV *)sv_2mortal ((SV *)newHV ()); |
… | |
… | |
2225 | |
2279 | |
2226 | key.texname = tex.name; |
2280 | key.texname = tex.name; |
2227 | arr = rc_array (rc, &key); |
2281 | arr = rc_array (rc, &key); |
2228 | } |
2282 | } |
2229 | |
2283 | |
2230 | px = (x + 1) * T - tex.w; |
2284 | px = (x + 1) * Th - tex.w; |
2231 | py = (y + 1) * T - tex.h; |
2285 | py = (y + 1) * Tw - tex.h; |
2232 | |
2286 | |
2233 | if (expect_false (cell->player == player) && expect_false (z == 2)) |
2287 | if (expect_false (cell->player == player) && expect_false (z == 2)) |
2234 | { |
2288 | { |
2235 | pl_x = px; |
2289 | pl_x = px; |
2236 | pl_y = py; |
2290 | pl_y = py; |
… | |
… | |
2289 | if (cell->flags & 1) |
2343 | if (cell->flags & 1) |
2290 | { |
2344 | { |
2291 | rc_key_t key_ov = key; |
2345 | rc_key_t key_ov = key; |
2292 | maptex tex = self->tex [TEXID_SPEECH]; |
2346 | maptex tex = self->tex [TEXID_SPEECH]; |
2293 | rc_array_t *arr; |
2347 | rc_array_t *arr; |
2294 | int px = x * T + T * 2 / 32; |
2348 | int px = x * Tw + Tw * 2 / 32; |
2295 | int py = y * T - T * 6 / 32; |
2349 | int py = y * Th - Th * 6 / 32; |
2296 | |
2350 | |
2297 | key_ov.texname = tex.name; |
2351 | key_ov.texname = tex.name; |
2298 | arr = rc_array (rc_ov, &key_ov); |
2352 | arr = rc_array (rc_ov, &key_ov); |
2299 | |
2353 | |
2300 | rc_t2f_v3f (arr, 0 , 0 , px , py , 0); |
2354 | rc_t2f_v3f (arr, 0 , 0 , px , py , 0); |
2301 | rc_t2f_v3f (arr, 0 , tex.t, px , py + T, 0); |
2355 | rc_t2f_v3f (arr, 0 , tex.t, px , py + Th, 0); |
2302 | rc_t2f_v3f (arr, tex.s, tex.t, px + T, py + T, 0); |
2356 | rc_t2f_v3f (arr, tex.s, tex.t, px + Tw, py + Th, 0); |
2303 | rc_t2f_v3f (arr, tex.s, 0 , px + T, py , 0); |
2357 | rc_t2f_v3f (arr, tex.s, 0 , px + Tw, py , 0); |
2304 | } |
2358 | } |
2305 | } |
2359 | } |
2306 | } |
2360 | } |
2307 | } |
2361 | } |
2308 | |
2362 | |
… | |
… | |
2335 | if (!(bits & 0x1000) |
2389 | if (!(bits & 0x1000) |
2336 | && skey->level == level |
2390 | && skey->level == level |
2337 | && level > smooth_max [skey->x][skey->y]) |
2391 | && level > smooth_max [skey->x][skey->y]) |
2338 | { |
2392 | { |
2339 | maptex tex = self->tex [skey->tile]; |
2393 | maptex tex = self->tex [skey->tile]; |
2340 | int px = (((int)skey->x) - 1) * T; |
2394 | int px = (((int)skey->x) - 1) * Tw; |
2341 | int py = (((int)skey->y) - 1) * T; |
2395 | int py = (((int)skey->y) - 1) * Th; |
2342 | int border = bits & 15; |
2396 | int border = bits & 15; |
2343 | int corner = (bits >> 8) & ~(bits >> 4) & 15; |
2397 | int corner = (bits >> 8) & ~(bits >> 4) & 15; |
2344 | float dx = tex.s * .0625f; // 16 images/row |
2398 | float dx = tex.s * .0625f; // 16 images/row |
2345 | float dy = tex.t * .5f ; // 2 images/column |
2399 | float dy = tex.t * .5f ; // 2 images/column |
2346 | |
2400 | |
… | |
… | |
2359 | |
2413 | |
2360 | if (border) |
2414 | if (border) |
2361 | { |
2415 | { |
2362 | float ox = border * dx; |
2416 | float ox = border * dx; |
2363 | |
2417 | |
2364 | glTexCoord2f (ox , 0.f ); glVertex2i (px , py ); |
2418 | glTexCoord2f (ox , 0.f ); glVertex2i (px , py ); |
2365 | glTexCoord2f (ox , dy ); glVertex2i (px , py + T); |
2419 | glTexCoord2f (ox , dy ); glVertex2i (px , py + Th); |
2366 | glTexCoord2f (ox + dx, dy ); glVertex2i (px + T, py + T); |
2420 | glTexCoord2f (ox + dx, dy ); glVertex2i (px + Tw, py + Th); |
2367 | glTexCoord2f (ox + dx, 0.f ); glVertex2i (px + T, py ); |
2421 | glTexCoord2f (ox + dx, 0.f ); glVertex2i (px + Tw, py ); |
2368 | } |
2422 | } |
2369 | |
2423 | |
2370 | if (corner) |
2424 | if (corner) |
2371 | { |
2425 | { |
2372 | float ox = corner * dx; |
2426 | float ox = corner * dx; |
2373 | |
2427 | |
2374 | glTexCoord2f (ox , dy ); glVertex2i (px , py ); |
2428 | glTexCoord2f (ox , dy ); glVertex2i (px , py ); |
2375 | glTexCoord2f (ox , dy * 2.f); glVertex2i (px , py + T); |
2429 | glTexCoord2f (ox , dy * 2.f); glVertex2i (px , py + Th); |
2376 | glTexCoord2f (ox + dx, dy * 2.f); glVertex2i (px + T, py + T); |
2430 | glTexCoord2f (ox + dx, dy * 2.f); glVertex2i (px + Tw, py + Th); |
2377 | glTexCoord2f (ox + dx, dy ); glVertex2i (px + T, py ); |
2431 | glTexCoord2f (ox + dx, dy ); glVertex2i (px + Tw, py ); |
2378 | } |
2432 | } |
2379 | } |
2433 | } |
2380 | } |
2434 | } |
2381 | } |
2435 | } |
2382 | } |
2436 | } |
… | |
… | |
2423 | for (x = 0; x < sw; x++) |
2477 | for (x = 0; x < sw; x++) |
2424 | if (row->c0 <= x + mx && x + mx < row->c1) |
2478 | if (row->c0 <= x + mx && x + mx < row->c1) |
2425 | { |
2479 | { |
2426 | mapcell *cell = row->col + (x + mx - row->c0); |
2480 | mapcell *cell = row->col + (x + mx - row->c0); |
2427 | |
2481 | |
2428 | int px = x * T; |
2482 | int px = x * Tw; |
2429 | int py = y * T; |
2483 | int py = y * Th; |
2430 | |
2484 | |
2431 | if (expect_false (cell->player == player)) |
2485 | if (expect_false (cell->player == player)) |
2432 | { |
2486 | { |
2433 | px += sdx; |
2487 | px += sdx; |
2434 | py += sdy; |
2488 | py += sdy; |
2435 | } |
2489 | } |
2436 | |
2490 | |
2437 | if (cell->stat_hp) |
2491 | if (cell->stat_hp) |
2438 | { |
2492 | { |
2439 | int width = cell->stat_width * T; |
2493 | int width = cell->stat_width * Tw; |
2440 | int thick = (sh * T / 32 + 27) / 28 + 1 + cell->stat_width; |
2494 | int thick = (sh * Th / 32 + 27) / 28 + 1 + cell->stat_width; |
2441 | |
2495 | |
2442 | glColor3ub (0, 0, 0); |
2496 | glColor3ub (0, 0, 0); |
2443 | glRectf (px + 1, py - thick - 2, |
2497 | glRectf (px + 1, py - thick - 2, |
2444 | px + width - 1, py); |
2498 | px + width - 1, py); |
2445 | |
2499 | |
… | |
… | |
2525 | int x, y; |
2579 | int x, y; |
2526 | int sw1 = sw + 2; |
2580 | int sw1 = sw + 2; |
2527 | int sh1 = sh + 2; |
2581 | int sh1 = sh + 2; |
2528 | int sh3 = sh * 3; |
2582 | int sh3 = sh * 3; |
2529 | int sw3 = sw * 3; |
2583 | int sw3 = sw * 3; |
2530 | uint8_t *darkness1 = (uint8_t *)malloc (sw1 * sh1); |
|
|
2531 | SV *darkness3_sv = sv_2mortal (newSV (sw3 * sh3)); |
2584 | SV *darkness3_sv = sv_2mortal (newSV (sw3 * sh3)); |
2532 | uint8_t *darkness3 = (uint8_t *)SvPVX (darkness3_sv); |
2585 | uint8_t *darkness3 = (uint8_t *)SvPVX (darkness3_sv); |
|
|
2586 | uint8_t *darkness1 = (uint8_t *)malloc (sw1 * sh1); |
|
|
2587 | memset (darkness1, 0, sw1*sh1); |
2533 | |
2588 | |
2534 | SvPOK_only (darkness3_sv); |
2589 | SvPOK_only (darkness3_sv); |
2535 | SvCUR_set (darkness3_sv, sw3 * sh3); |
2590 | SvCUR_set (darkness3_sv, sw3 * sh3); |
2536 | |
2591 | |
2537 | mx += self->x - 1; |
2592 | mx += self->x - 1; |
… | |
… | |
2798 | if (RETVAL < 0) |
2853 | if (RETVAL < 0) |
2799 | { |
2854 | { |
2800 | RETVAL = Mix_GroupOldest (-1); |
2855 | RETVAL = Mix_GroupOldest (-1); |
2801 | |
2856 | |
2802 | if (RETVAL < 0) |
2857 | if (RETVAL < 0) |
|
|
2858 | { |
|
|
2859 | // happens sometimes, maybe it just stopped playing(?) |
|
|
2860 | RETVAL = Mix_GroupAvailable (-1); |
|
|
2861 | |
|
|
2862 | if (RETVAL < 0) |
2803 | XSRETURN_UNDEF; |
2863 | XSRETURN_UNDEF; |
2804 | |
2864 | } |
|
|
2865 | else |
2805 | Mix_HaltChannel (RETVAL); |
2866 | Mix_HaltChannel (RETVAL); |
2806 | } |
2867 | } |
2807 | |
2868 | |
2808 | Mix_UnregisterAllEffects (RETVAL); |
2869 | Mix_UnregisterAllEffects (RETVAL); |
2809 | Mix_Volume (RETVAL, 128); |
2870 | Mix_Volume (RETVAL, 128); |
2810 | } |
2871 | } |
… | |
… | |
2869 | Mix_SetReverseStereo (self, flip); |
2930 | Mix_SetReverseStereo (self, flip); |
2870 | |
2931 | |
2871 | MODULE = Deliantra::Client PACKAGE = DC::MixChunk |
2932 | MODULE = Deliantra::Client PACKAGE = DC::MixChunk |
2872 | |
2933 | |
2873 | PROTOTYPES: DISABLE |
2934 | PROTOTYPES: DISABLE |
|
|
2935 | |
|
|
2936 | void |
|
|
2937 | decoders () |
|
|
2938 | PPCODE: |
|
|
2939 | #if SDL_MIXER_MAJOR_VERSION > 1 || SDL_MIXER_MINOR_VERSION > 2 || SDL_MIXER_PATCHLEVEL >= 10 |
|
|
2940 | int i, num = Mix_GetNumChunkDecoders (); |
|
|
2941 | EXTEND (SP, num); |
|
|
2942 | for (i = 0; i < num; ++i) |
|
|
2943 | PUSHs (sv_2mortal (newSVpv (Mix_GetChunkDecoder (i), 0))); |
|
|
2944 | #else |
|
|
2945 | XPUSHs (sv_2mortal (newSVpv ("(sdl mixer too old)", 0))); |
|
|
2946 | #endif |
2874 | |
2947 | |
2875 | DC::MixChunk |
2948 | DC::MixChunk |
2876 | new (SV *class, DC::RW rwops) |
2949 | new (SV *class, DC::RW rwops) |
2877 | CODE: |
2950 | CODE: |
2878 | RETVAL = Mix_LoadWAV_RW (rwops, 1); |
2951 | RETVAL = Mix_LoadWAV_RW (rwops, 1); |
… | |
… | |
2911 | OUTPUT: |
2984 | OUTPUT: |
2912 | RETVAL |
2985 | RETVAL |
2913 | |
2986 | |
2914 | MODULE = Deliantra::Client PACKAGE = DC::MixMusic |
2987 | MODULE = Deliantra::Client PACKAGE = DC::MixMusic |
2915 | |
2988 | |
|
|
2989 | void |
|
|
2990 | decoders () |
|
|
2991 | PPCODE: |
|
|
2992 | #if SDL_MIXER_MAJOR_VERSION > 1 || SDL_MIXER_MINOR_VERSION > 2 || SDL_MIXER_PATCHLEVEL >= 10 |
|
|
2993 | int i, num = Mix_GetNumMusicDecoders (); |
|
|
2994 | EXTEND (SP, num); |
|
|
2995 | for (i = 0; i < num; ++i) |
|
|
2996 | PUSHs (sv_2mortal (newSVpv (Mix_GetMusicDecoder (i), 0))); |
|
|
2997 | #else |
|
|
2998 | XPUSHs (sv_2mortal (newSVpv ("(sdl mixer too old)", 0))); |
|
|
2999 | #endif |
|
|
3000 | |
2916 | int |
3001 | int |
2917 | volume (int volume = -1) |
3002 | volume (int volume = -1) |
2918 | PROTOTYPE: ;$ |
3003 | PROTOTYPE: ;$ |
2919 | CODE: |
3004 | CODE: |
2920 | if (items > 0) |
3005 | if (items > 0) |
… | |
… | |
2930 | |
3015 | |
2931 | void |
3016 | void |
2932 | halt () |
3017 | halt () |
2933 | CODE: |
3018 | CODE: |
2934 | Mix_HaltMusic (); |
3019 | Mix_HaltMusic (); |
|
|
3020 | |
|
|
3021 | int |
|
|
3022 | playing () |
|
|
3023 | CODE: |
|
|
3024 | RETVAL = Mix_PlayingMusic (); |
|
|
3025 | OUTPUT: |
|
|
3026 | RETVAL |
2935 | |
3027 | |
2936 | DC::MixMusic |
3028 | DC::MixMusic |
2937 | new (SV *class, DC::RW rwops) |
3029 | new (SV *class, DC::RW rwops) |
2938 | CODE: |
3030 | CODE: |
2939 | RETVAL = Mix_LoadMUS_RW (rwops); |
3031 | RETVAL = Mix_LoadMUS_RW (rwops); |
… | |
… | |
3079 | const_iv (GL_FUNC_SUBTRACT), |
3171 | const_iv (GL_FUNC_SUBTRACT), |
3080 | const_iv (GL_FUNC_REVERSE_SUBTRACT), |
3172 | const_iv (GL_FUNC_REVERSE_SUBTRACT), |
3081 | # undef const_iv |
3173 | # undef const_iv |
3082 | }; |
3174 | }; |
3083 | |
3175 | |
3084 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
3176 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ > const_iv; civ--) |
3085 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
3177 | newCONSTSUB (stash, (char *)civ[-1].name, newSViv (civ[-1].iv)); |
3086 | |
3178 | |
3087 | texture_av = newAV (); |
3179 | texture_av = newAV (); |
3088 | AvREAL_off (texture_av); |
3180 | AvREAL_off (texture_av); |
3089 | } |
3181 | } |
3090 | |
3182 | |
… | |
… | |
3133 | RETVAL |
3225 | RETVAL |
3134 | |
3226 | |
3135 | int glGetError () |
3227 | int glGetError () |
3136 | |
3228 | |
3137 | void glFinish () |
3229 | void glFinish () |
|
|
3230 | |
|
|
3231 | void glFlush () |
3138 | |
3232 | |
3139 | void glClear (int mask) |
3233 | void glClear (int mask) |
3140 | |
3234 | |
3141 | void glClearColor (float r, float g, float b, float a = 1.0) |
3235 | void glClearColor (float r, float g, float b, float a = 1.0) |
3142 | PROTOTYPE: @ |
3236 | PROTOTYPE: @ |