… | |
… | |
48 | #endif |
48 | #endif |
49 | |
49 | |
50 | #define PANGO_ENABLE_BACKEND |
50 | #define PANGO_ENABLE_BACKEND |
51 | #define G_DISABLE_CAST_CHECKS |
51 | #define G_DISABLE_CAST_CHECKS |
52 | |
52 | |
53 | #include <glib/gmacros.h> |
53 | #include <glib.h> |
54 | |
54 | |
55 | #include <pango/pango.h> |
55 | #include <pango/pango.h> |
56 | |
56 | |
57 | #ifndef PANGO_VERSION_CHECK |
57 | #ifndef PANGO_VERSION_CHECK |
58 | # define PANGO_VERSION_CHECK(a,b,c) 0 |
58 | # define PANGO_VERSION_CHECK(a,b,c) 0 |
… | |
… | |
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 | |
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 | } |
|
|
123 | |
105 | static AV *texture_av; |
124 | static AV *texture_av; |
106 | |
125 | |
107 | static struct |
126 | static struct |
108 | { |
127 | { |
109 | #define GL_FUNC(ptr,name) ptr name; |
128 | #define GL_FUNC(ptr,name) ptr name; |
… | |
… | |
165 | { |
184 | { |
166 | GSList *attrs = run->item->analysis.extra_attrs; |
185 | GSList *attrs = run->item->analysis.extra_attrs; |
167 | |
186 | |
168 | while (attrs) |
187 | while (attrs) |
169 | { |
188 | { |
170 | PangoAttribute *attr = attrs->data; |
189 | PangoAttribute *attr = (PangoAttribute *)attrs->data; |
171 | |
190 | |
172 | if (attr->klass->type == PANGO_ATTR_SHAPE) |
191 | if (attr->klass->type == PANGO_ATTR_SHAPE) |
173 | return 1; |
192 | return 1; |
174 | |
193 | |
175 | attrs = attrs->next; |
194 | attrs = attrs->next; |
… | |
… | |
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 | |
857 | void SDL_QuitSubSystem (U32 flags) |
889 | void SDL_QuitSubSystem (U32 flags) |
858 | |
890 | |
859 | void SDL_Quit () |
891 | void SDL_Quit () |
860 | |
892 | |
861 | int SDL_GL_SetAttribute (int attr, int value) |
893 | int SDL_GL_SetAttribute (int attr, int value) |
|
|
894 | C_ARGS: (SDL_GLattr)attr, value |
862 | |
895 | |
863 | int SDL_GL_GetAttribute (int attr) |
896 | int SDL_GL_GetAttribute (int attr) |
864 | CODE: |
897 | CODE: |
865 | if (SDL_GL_GetAttribute (attr, &RETVAL)) |
898 | if (SDL_GL_GetAttribute ((SDL_GLattr)attr, &RETVAL)) |
866 | XSRETURN_UNDEF; |
899 | XSRETURN_UNDEF; |
867 | OUTPUT: |
900 | OUTPUT: |
868 | RETVAL |
901 | RETVAL |
869 | |
902 | |
870 | void |
903 | void |
… | |
… | |
925 | ); |
958 | ); |
926 | |
959 | |
927 | if (RETVAL) |
960 | if (RETVAL) |
928 | { |
961 | { |
929 | av_clear (texture_av); |
962 | 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); |
963 | #define GL_FUNC(ptr,name) gl.name = (ptr)SDL_GL_GetProcAddress ("gl" # name); |
933 | #include "glfunc.h" |
964 | #include "glfunc.h" |
934 | #undef GL_FUNC |
965 | #undef GL_FUNC |
935 | |
|
|
936 | if (!gl.ActiveTexture ) gl.ActiveTexture = gl.ActiveTextureARB; |
966 | if (!gl.ActiveTexture ) gl.ActiveTexture = gl.ActiveTextureARB; |
937 | if (!gl.MultiTexCoord2f) gl.MultiTexCoord2f = gl.MultiTexCoord2fARB; |
967 | if (!gl.MultiTexCoord2f) gl.MultiTexCoord2f = gl.MultiTexCoord2fARB; |
938 | } |
968 | } |
939 | } |
969 | } |
940 | OUTPUT: |
970 | OUTPUT: |
941 | RETVAL |
971 | RETVAL |
942 | |
972 | |
943 | void |
973 | void |
|
|
974 | SDL_WM_SetCaption (const char *title, const char *icon) |
|
|
975 | |
|
|
976 | void |
944 | SDL_GL_SwapBuffers () |
977 | SDL_GL_SwapBuffers () |
945 | |
978 | |
946 | char * |
979 | char * |
947 | SDL_GetKeyName (int sym) |
980 | SDL_GetKeyName (int sym) |
|
|
981 | C_ARGS: (SDLKey)sym |
948 | |
982 | |
949 | int |
983 | int |
950 | SDL_GetAppState () |
984 | SDL_GetAppState () |
951 | |
985 | |
952 | int |
986 | int |
953 | SDL_GetModState () |
987 | SDL_GetModState () |
954 | |
988 | |
|
|
989 | int |
|
|
990 | SDL_WaitEvent () |
|
|
991 | C_ARGS: 0 |
|
|
992 | |
955 | void |
993 | void |
|
|
994 | SDL_PumpEvents () |
|
|
995 | |
|
|
996 | void |
956 | poll_events () |
997 | peep_events () |
957 | PPCODE: |
998 | PPCODE: |
958 | { |
999 | { |
959 | SDL_Event ev; |
1000 | SDL_Event ev; |
960 | |
1001 | |
961 | SDL_PumpEvents (); |
1002 | SDL_PumpEvents (); |
… | |
… | |
1111 | add_font (char *file) |
1152 | add_font (char *file) |
1112 | CODE: |
1153 | CODE: |
1113 | RETVAL = FcConfigAppFontAddFile (0, (const FcChar8 *)file); |
1154 | RETVAL = FcConfigAppFontAddFile (0, (const FcChar8 *)file); |
1114 | OUTPUT: |
1155 | OUTPUT: |
1115 | RETVAL |
1156 | RETVAL |
|
|
1157 | |
|
|
1158 | void |
|
|
1159 | IMG_Init (int flags = IMG_INIT_JPG | IMG_INIT_PNG) |
|
|
1160 | |
|
|
1161 | # MIX_INIT_MP3 gives smpeg + libstdc++ + libgcc_s |
|
|
1162 | void |
|
|
1163 | Mix_Init (int flags = MIX_INIT_MOD | MIX_INIT_OGG) |
1116 | |
1164 | |
1117 | void |
1165 | void |
1118 | load_image_inline (SV *image_) |
1166 | load_image_inline (SV *image_) |
1119 | ALIAS: |
1167 | ALIAS: |
1120 | load_image_file = 1 |
1168 | load_image_file = 1 |
… | |
… | |
1166 | |
1214 | |
1167 | SDL_LockSurface (surface2); |
1215 | SDL_LockSurface (surface2); |
1168 | EXTEND (SP, 6); |
1216 | EXTEND (SP, 6); |
1169 | PUSHs (sv_2mortal (newSViv (surface2->w))); |
1217 | PUSHs (sv_2mortal (newSViv (surface2->w))); |
1170 | PUSHs (sv_2mortal (newSViv (surface2->h))); |
1218 | PUSHs (sv_2mortal (newSViv (surface2->h))); |
1171 | PUSHs (sv_2mortal (newSVpvn (surface2->pixels, surface2->h * surface2->pitch))); |
1219 | PUSHs (sv_2mortal (newSVpvn ((const char *)surface2->pixels, surface2->h * surface2->pitch))); |
1172 | PUSHs (sv_2mortal (newSViv (surface->flags & (SDL_SRCCOLORKEY | SDL_SRCALPHA) ? GL_RGBA : GL_RGB))); |
1220 | PUSHs (sv_2mortal (newSViv (surface->flags & (SDL_SRCCOLORKEY | SDL_SRCALPHA) ? GL_RGBA : GL_RGB))); |
1173 | PUSHs (sv_2mortal (newSViv (GL_RGBA))); |
1221 | PUSHs (sv_2mortal (newSViv (GL_RGBA))); |
1174 | PUSHs (sv_2mortal (newSViv (GL_UNSIGNED_BYTE))); |
1222 | PUSHs (sv_2mortal (newSViv (GL_UNSIGNED_BYTE))); |
1175 | SDL_UnlockSurface (surface2); |
1223 | SDL_UnlockSurface (surface2); |
1176 | |
1224 | |
… | |
… | |
1248 | MODULE = Deliantra::Client PACKAGE = DC::Font |
1296 | MODULE = Deliantra::Client PACKAGE = DC::Font |
1249 | |
1297 | |
1250 | PROTOTYPES: DISABLE |
1298 | PROTOTYPES: DISABLE |
1251 | |
1299 | |
1252 | DC::Font |
1300 | DC::Font |
1253 | new_from_file (SV *class, char *path, int id = 0) |
1301 | new_from_file (SV *klass, char *path, int id = 0) |
1254 | CODE: |
1302 | CODE: |
1255 | { |
1303 | { |
1256 | int count; |
1304 | int count; |
1257 | FcPattern *pattern = FcFreeTypeQuery ((const FcChar8 *)path, id, 0, &count); |
1305 | FcPattern *pattern = FcFreeTypeQuery ((const FcChar8 *)path, id, 0, &count); |
1258 | RETVAL = pango_fc_font_description_from_pattern (pattern, 0); |
1306 | RETVAL = pango_fc_font_description_from_pattern (pattern, 0); |
… | |
… | |
1287 | PROTOTYPE: |
1335 | PROTOTYPE: |
1288 | CODE: |
1336 | CODE: |
1289 | tc_restore (); |
1337 | tc_restore (); |
1290 | |
1338 | |
1291 | DC::Layout |
1339 | DC::Layout |
1292 | new (SV *class) |
1340 | new (SV *klass) |
1293 | CODE: |
1341 | CODE: |
1294 | New (0, RETVAL, 1, struct cf_layout); |
1342 | New (0, RETVAL, 1, struct cf_layout); |
1295 | |
1343 | |
1296 | RETVAL->pl = pango_layout_new (opengl_context); |
1344 | RETVAL->pl = pango_layout_new (opengl_context); |
1297 | RETVAL->r = 1.; |
1345 | RETVAL->r = 1.; |
… | |
… | |
1446 | |
1494 | |
1447 | void |
1495 | void |
1448 | set_height (DC::Layout self, int base_height) |
1496 | set_height (DC::Layout self, int base_height) |
1449 | CODE: |
1497 | CODE: |
1450 | if (self->base_height != base_height) |
1498 | if (self->base_height != base_height) |
1451 | { |
1499 | { |
1452 | self->base_height = base_height; |
1500 | self->base_height = base_height; |
1453 | layout_update_font (self); |
1501 | layout_update_font (self); |
1454 | } |
1502 | } |
1455 | |
1503 | |
1456 | void |
1504 | void |
… | |
… | |
1820 | MODULE = Deliantra::Client PACKAGE = DC::Map |
1868 | MODULE = Deliantra::Client PACKAGE = DC::Map |
1821 | |
1869 | |
1822 | PROTOTYPES: DISABLE |
1870 | PROTOTYPES: DISABLE |
1823 | |
1871 | |
1824 | DC::Map |
1872 | DC::Map |
1825 | new (SV *class) |
1873 | new (SV *klass) |
1826 | CODE: |
1874 | CODE: |
1827 | New (0, RETVAL, 1, struct map); |
1875 | New (0, RETVAL, 1, struct map); |
1828 | RETVAL->x = 0; |
1876 | RETVAL->x = 0; |
1829 | RETVAL->y = 0; |
1877 | RETVAL->y = 0; |
1830 | RETVAL->w = 0; |
1878 | RETVAL->w = 0; |
… | |
… | |
1986 | self->y += MAP_EXTEND_Y; |
2034 | self->y += MAP_EXTEND_Y; |
1987 | } |
2035 | } |
1988 | } |
2036 | } |
1989 | |
2037 | |
1990 | SV * |
2038 | SV * |
1991 | map1a_update (DC::Map self, SV *data_, int extmap) |
2039 | map1a_update (DC::Map self, SV *data_) |
1992 | CODE: |
2040 | CODE: |
1993 | { |
2041 | { |
1994 | uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_); |
2042 | uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_); |
1995 | uint8_t *data_end = (uint8_t *)SvEND (data_); |
2043 | uint8_t *data_end = (uint8_t *)SvEND (data_); |
1996 | mapcell *cell; |
2044 | mapcell *cell; |
… | |
… | |
2017 | |
2065 | |
2018 | //TODO: don't trust server data to be in-range(!) |
2066 | //TODO: don't trust server data to be in-range(!) |
2019 | |
2067 | |
2020 | if (flags & 8) |
2068 | if (flags & 8) |
2021 | { |
2069 | { |
|
|
2070 | uint8_t ext, cmd; |
|
|
2071 | |
2022 | if (extmap) |
2072 | do |
2023 | { |
2073 | { |
2024 | uint8_t ext, cmd; |
2074 | ext = *data++; |
|
|
2075 | cmd = ext & 0x7f; |
2025 | |
2076 | |
2026 | do |
2077 | if (cmd < 4) |
|
|
2078 | cell->darkness = 255 - ext * 64 + 1; /* make sure this doesn't collide with FOW_DARKNESS */ |
|
|
2079 | else if (cmd == 5) // health |
2027 | { |
2080 | { |
2028 | ext = *data++; |
|
|
2029 | cmd = ext & 0x7f; |
|
|
2030 | |
|
|
2031 | if (cmd < 4) |
|
|
2032 | cell->darkness = 255 - ext * 64 + 1; /* make sure this doesn't collide with FOW_DARKNESS */ |
|
|
2033 | else if (cmd == 5) // health |
|
|
2034 | { |
|
|
2035 | cell->stat_width = 1; |
2081 | cell->stat_width = 1; |
2036 | cell->stat_hp = *data++; |
2082 | cell->stat_hp = *data++; |
2037 | } |
|
|
2038 | else if (cmd == 6) // monster width |
|
|
2039 | cell->stat_width = *data++ + 1; |
|
|
2040 | else if (cmd == 0x47) |
|
|
2041 | { |
|
|
2042 | if (*data == 1) cell->player = data [1]; |
|
|
2043 | else if (*data == 2) cell->player = data [2] + (data [1] << 8); |
|
|
2044 | else if (*data == 3) cell->player = data [3] + (data [2] << 8) + (data [1] << 16); |
|
|
2045 | else if (*data == 4) cell->player = data [4] + (data [3] << 8) + (data [2] << 16) + (data [1] << 24); |
|
|
2046 | |
|
|
2047 | data += *data + 1; |
|
|
2048 | } |
|
|
2049 | else if (cmd == 8) // cell flags |
|
|
2050 | cell->flags = *data++; |
|
|
2051 | else if (ext & 0x40) // unknown, multibyte => skip |
|
|
2052 | data += *data + 1; |
|
|
2053 | else |
|
|
2054 | data++; |
|
|
2055 | } |
2083 | } |
2056 | while (ext & 0x80); |
2084 | else if (cmd == 6) // monster width |
|
|
2085 | cell->stat_width = *data++ + 1; |
|
|
2086 | else if (cmd == 0x47) |
|
|
2087 | { |
|
|
2088 | if (*data == 1) cell->player = data [1]; |
|
|
2089 | else if (*data == 2) cell->player = data [2] + (data [1] << 8); |
|
|
2090 | else if (*data == 3) cell->player = data [3] + (data [2] << 8) + (data [1] << 16); |
|
|
2091 | else if (*data == 4) cell->player = data [4] + (data [3] << 8) + (data [2] << 16) + (data [1] << 24); |
|
|
2092 | |
|
|
2093 | data += *data + 1; |
|
|
2094 | } |
|
|
2095 | else if (cmd == 8) // cell flags |
|
|
2096 | cell->flags = *data++; |
|
|
2097 | else if (ext & 0x40) // unknown, multibyte => skip |
|
|
2098 | data += *data + 1; |
|
|
2099 | else |
|
|
2100 | data++; |
2057 | } |
2101 | } |
2058 | else |
2102 | while (ext & 0x80); |
2059 | cell->darkness = *data++ + 1; |
|
|
2060 | } |
2103 | } |
2061 | |
2104 | |
2062 | for (z = 0; z <= 2; ++z) |
2105 | for (z = 0; z <= 2; ++z) |
2063 | if (flags & (4 >> z)) |
2106 | if (flags & (4 >> z)) |
2064 | { |
2107 | { |
… | |
… | |
2112 | ? self->row + y |
2155 | ? self->row + y |
2113 | : 0; |
2156 | : 0; |
2114 | |
2157 | |
2115 | for (x = x0; x < x1; x++) |
2158 | for (x = x0; x < x1; x++) |
2116 | { |
2159 | { |
2117 | int r = 32, g = 32, b = 32, a = 192; |
2160 | unsigned int r = 32, g = 32, b = 32, a = 192; |
2118 | |
2161 | |
2119 | if (row && row->c0 <= x && x < row->c1) |
2162 | if (row && row->c0 <= x && x < row->c1) |
2120 | { |
2163 | { |
2121 | mapcell *cell = row->col + (x - row->c0); |
2164 | mapcell *cell = row->col + (x - row->c0); |
2122 | |
2165 | |
… | |
… | |
2124 | { |
2167 | { |
2125 | maptex tex = self->tex [cell->tile [z]]; |
2168 | maptex tex = self->tex [cell->tile [z]]; |
2126 | int a0 = 255 - tex.a; |
2169 | int a0 = 255 - tex.a; |
2127 | int a1 = tex.a; |
2170 | int a1 = tex.a; |
2128 | |
2171 | |
2129 | r = (r * a0 + tex.r * a1) / 255; |
2172 | r = div255 (r * a0 + tex.r * a1); |
2130 | g = (g * a0 + tex.g * a1) / 255; |
2173 | g = div255 (g * a0 + tex.g * a1); |
2131 | b = (b * a0 + tex.b * a1) / 255; |
2174 | b = div255 (b * a0 + tex.b * a1); |
2132 | a = (a * a0 + tex.a * a1) / 255; |
2175 | a = div255 (a * a0 + tex.a * a1); |
2133 | } |
2176 | } |
2134 | } |
2177 | } |
2135 | |
2178 | |
2136 | *map++ = (r ) |
2179 | *map++ = (r ) |
2137 | | (g << 8) |
2180 | | (g << 8) |
… | |
… | |
2144 | } |
2187 | } |
2145 | OUTPUT: |
2188 | OUTPUT: |
2146 | RETVAL |
2189 | RETVAL |
2147 | |
2190 | |
2148 | void |
2191 | void |
2149 | draw (DC::Map self, int mx, int my, int sw, int sh, int T, U32 player = 0xffffffff, int sdx = 0, int sdy = 0) |
2192 | 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) |
2150 | CODE: |
2193 | CODE: |
2151 | { |
2194 | { |
2152 | int x, y, z; |
2195 | int x, y, z; |
2153 | |
2196 | |
2154 | HV *smooth = (HV *)sv_2mortal ((SV *)newHV ()); |
2197 | HV *smooth = (HV *)sv_2mortal ((SV *)newHV ()); |
… | |
… | |
2238 | |
2281 | |
2239 | key.texname = tex.name; |
2282 | key.texname = tex.name; |
2240 | arr = rc_array (rc, &key); |
2283 | arr = rc_array (rc, &key); |
2241 | } |
2284 | } |
2242 | |
2285 | |
2243 | px = (x + 1) * T - tex.w; |
2286 | px = (x + 1) * Th - tex.w; |
2244 | py = (y + 1) * T - tex.h; |
2287 | py = (y + 1) * Tw - tex.h; |
2245 | |
2288 | |
2246 | if (expect_false (cell->player == player) && expect_false (z == 2)) |
2289 | if (expect_false (cell->player == player) && expect_false (z == 2)) |
2247 | { |
2290 | { |
2248 | pl_x = px; |
2291 | pl_x = px; |
2249 | pl_y = py; |
2292 | pl_y = py; |
… | |
… | |
2302 | if (cell->flags & 1) |
2345 | if (cell->flags & 1) |
2303 | { |
2346 | { |
2304 | rc_key_t key_ov = key; |
2347 | rc_key_t key_ov = key; |
2305 | maptex tex = self->tex [TEXID_SPEECH]; |
2348 | maptex tex = self->tex [TEXID_SPEECH]; |
2306 | rc_array_t *arr; |
2349 | rc_array_t *arr; |
2307 | int px = x * T + T * 2 / 32; |
2350 | int px = x * Tw + Tw * 2 / 32; |
2308 | int py = y * T - T * 6 / 32; |
2351 | int py = y * Th - Th * 6 / 32; |
2309 | |
2352 | |
2310 | key_ov.texname = tex.name; |
2353 | key_ov.texname = tex.name; |
2311 | arr = rc_array (rc_ov, &key_ov); |
2354 | arr = rc_array (rc_ov, &key_ov); |
2312 | |
2355 | |
2313 | rc_t2f_v3f (arr, 0 , 0 , px , py , 0); |
2356 | rc_t2f_v3f (arr, 0 , 0 , px , py , 0); |
2314 | rc_t2f_v3f (arr, 0 , tex.t, px , py + T, 0); |
2357 | rc_t2f_v3f (arr, 0 , tex.t, px , py + Th, 0); |
2315 | rc_t2f_v3f (arr, tex.s, tex.t, px + T, py + T, 0); |
2358 | rc_t2f_v3f (arr, tex.s, tex.t, px + Tw, py + Th, 0); |
2316 | rc_t2f_v3f (arr, tex.s, 0 , px + T, py , 0); |
2359 | rc_t2f_v3f (arr, tex.s, 0 , px + Tw, py , 0); |
2317 | } |
2360 | } |
2318 | } |
2361 | } |
2319 | } |
2362 | } |
2320 | } |
2363 | } |
2321 | |
2364 | |
… | |
… | |
2348 | if (!(bits & 0x1000) |
2391 | if (!(bits & 0x1000) |
2349 | && skey->level == level |
2392 | && skey->level == level |
2350 | && level > smooth_max [skey->x][skey->y]) |
2393 | && level > smooth_max [skey->x][skey->y]) |
2351 | { |
2394 | { |
2352 | maptex tex = self->tex [skey->tile]; |
2395 | maptex tex = self->tex [skey->tile]; |
2353 | int px = (((int)skey->x) - 1) * T; |
2396 | int px = (((int)skey->x) - 1) * Tw; |
2354 | int py = (((int)skey->y) - 1) * T; |
2397 | int py = (((int)skey->y) - 1) * Th; |
2355 | int border = bits & 15; |
2398 | int border = bits & 15; |
2356 | int corner = (bits >> 8) & ~(bits >> 4) & 15; |
2399 | int corner = (bits >> 8) & ~(bits >> 4) & 15; |
2357 | float dx = tex.s * .0625f; // 16 images/row |
2400 | float dx = tex.s * .0625f; // 16 images/row |
2358 | float dy = tex.t * .5f ; // 2 images/column |
2401 | float dy = tex.t * .5f ; // 2 images/column |
2359 | |
2402 | |
… | |
… | |
2372 | |
2415 | |
2373 | if (border) |
2416 | if (border) |
2374 | { |
2417 | { |
2375 | float ox = border * dx; |
2418 | float ox = border * dx; |
2376 | |
2419 | |
2377 | glTexCoord2f (ox , 0.f ); glVertex2i (px , py ); |
2420 | glTexCoord2f (ox , 0.f ); glVertex2i (px , py ); |
2378 | glTexCoord2f (ox , dy ); glVertex2i (px , py + T); |
2421 | glTexCoord2f (ox , dy ); glVertex2i (px , py + Th); |
2379 | glTexCoord2f (ox + dx, dy ); glVertex2i (px + T, py + T); |
2422 | glTexCoord2f (ox + dx, dy ); glVertex2i (px + Tw, py + Th); |
2380 | glTexCoord2f (ox + dx, 0.f ); glVertex2i (px + T, py ); |
2423 | glTexCoord2f (ox + dx, 0.f ); glVertex2i (px + Tw, py ); |
2381 | } |
2424 | } |
2382 | |
2425 | |
2383 | if (corner) |
2426 | if (corner) |
2384 | { |
2427 | { |
2385 | float ox = corner * dx; |
2428 | float ox = corner * dx; |
2386 | |
2429 | |
2387 | glTexCoord2f (ox , dy ); glVertex2i (px , py ); |
2430 | glTexCoord2f (ox , dy ); glVertex2i (px , py ); |
2388 | glTexCoord2f (ox , dy * 2.f); glVertex2i (px , py + T); |
2431 | glTexCoord2f (ox , dy * 2.f); glVertex2i (px , py + Th); |
2389 | glTexCoord2f (ox + dx, dy * 2.f); glVertex2i (px + T, py + T); |
2432 | glTexCoord2f (ox + dx, dy * 2.f); glVertex2i (px + Tw, py + Th); |
2390 | glTexCoord2f (ox + dx, dy ); glVertex2i (px + T, py ); |
2433 | glTexCoord2f (ox + dx, dy ); glVertex2i (px + Tw, py ); |
2391 | } |
2434 | } |
2392 | } |
2435 | } |
2393 | } |
2436 | } |
2394 | } |
2437 | } |
2395 | } |
2438 | } |
… | |
… | |
2436 | for (x = 0; x < sw; x++) |
2479 | for (x = 0; x < sw; x++) |
2437 | if (row->c0 <= x + mx && x + mx < row->c1) |
2480 | if (row->c0 <= x + mx && x + mx < row->c1) |
2438 | { |
2481 | { |
2439 | mapcell *cell = row->col + (x + mx - row->c0); |
2482 | mapcell *cell = row->col + (x + mx - row->c0); |
2440 | |
2483 | |
2441 | int px = x * T; |
2484 | int px = x * Tw; |
2442 | int py = y * T; |
2485 | int py = y * Th; |
2443 | |
2486 | |
2444 | if (expect_false (cell->player == player)) |
2487 | if (expect_false (cell->player == player)) |
2445 | { |
2488 | { |
2446 | px += sdx; |
2489 | px += sdx; |
2447 | py += sdy; |
2490 | py += sdy; |
2448 | } |
2491 | } |
2449 | |
2492 | |
2450 | if (cell->stat_hp) |
2493 | if (cell->stat_hp) |
2451 | { |
2494 | { |
2452 | int width = cell->stat_width * T; |
2495 | int width = cell->stat_width * Tw; |
2453 | int thick = (sh * T / 32 + 27) / 28 + 1 + cell->stat_width; |
2496 | int thick = (sh * Th / 32 + 27) / 28 + 1 + cell->stat_width; |
2454 | |
2497 | |
2455 | glColor3ub (0, 0, 0); |
2498 | glColor3ub (0, 0, 0); |
2456 | glRectf (px + 1, py - thick - 2, |
2499 | glRectf (px + 1, py - thick - 2, |
2457 | px + width - 1, py); |
2500 | px + width - 1, py); |
2458 | |
2501 | |
… | |
… | |
2538 | int x, y; |
2581 | int x, y; |
2539 | int sw1 = sw + 2; |
2582 | int sw1 = sw + 2; |
2540 | int sh1 = sh + 2; |
2583 | int sh1 = sh + 2; |
2541 | int sh3 = sh * 3; |
2584 | int sh3 = sh * 3; |
2542 | int sw3 = sw * 3; |
2585 | int sw3 = sw * 3; |
2543 | uint8_t *darkness1 = (uint8_t *)malloc (sw1 * sh1); |
|
|
2544 | SV *darkness3_sv = sv_2mortal (newSV (sw3 * sh3)); |
2586 | SV *darkness3_sv = sv_2mortal (newSV (sw3 * sh3)); |
2545 | uint8_t *darkness3 = (uint8_t *)SvPVX (darkness3_sv); |
2587 | uint8_t *darkness3 = (uint8_t *)SvPVX (darkness3_sv); |
|
|
2588 | uint8_t *darkness1 = (uint8_t *)malloc (sw1 * sh1); |
|
|
2589 | memset (darkness1, 0, sw1*sh1); |
2546 | |
2590 | |
2547 | SvPOK_only (darkness3_sv); |
2591 | SvPOK_only (darkness3_sv); |
2548 | SvCUR_set (darkness3_sv, sw3 * sh3); |
2592 | SvCUR_set (darkness3_sv, sw3 * sh3); |
2549 | |
2593 | |
2550 | mx += self->x - 1; |
2594 | mx += self->x - 1; |
… | |
… | |
2700 | STRLEN len; |
2744 | STRLEN len; |
2701 | uint8_t *data, *end; |
2745 | uint8_t *data, *end; |
2702 | |
2746 | |
2703 | len = SvLEN (data_sv); |
2747 | len = SvLEN (data_sv); |
2704 | SvGROW (data_sv, len + 8); // reserve at least 7+ bytes more |
2748 | SvGROW (data_sv, len + 8); // reserve at least 7+ bytes more |
2705 | data = SvPVbyte_nolen (data_sv); |
2749 | data = (uint8_t *)SvPVbyte_nolen (data_sv); |
2706 | end = data + len + 8; |
2750 | end = data + len + 8; |
2707 | |
2751 | |
2708 | if (len < 5) |
2752 | if (len < 5) |
2709 | XSRETURN_EMPTY; |
2753 | XSRETURN_EMPTY; |
2710 | |
2754 | |
… | |
… | |
2771 | } |
2815 | } |
2772 | |
2816 | |
2773 | MODULE = Deliantra::Client PACKAGE = DC::RW |
2817 | MODULE = Deliantra::Client PACKAGE = DC::RW |
2774 | |
2818 | |
2775 | DC::RW |
2819 | DC::RW |
2776 | new (SV *class, SV *data_sv) |
2820 | new (SV *klass, SV *data_sv) |
2777 | CODE: |
2821 | CODE: |
2778 | { |
2822 | { |
2779 | STRLEN datalen; |
2823 | STRLEN datalen; |
2780 | char *data = SvPVbyte (data_sv, datalen); |
2824 | char *data = SvPVbyte (data_sv, datalen); |
2781 | |
2825 | |
… | |
… | |
2783 | } |
2827 | } |
2784 | OUTPUT: |
2828 | OUTPUT: |
2785 | RETVAL |
2829 | RETVAL |
2786 | |
2830 | |
2787 | DC::RW |
2831 | DC::RW |
2788 | new_from_file (SV *class, const char *path, const char *mode = "rb") |
2832 | new_from_file (SV *klass, const char *path, const char *mode = "rb") |
2789 | CODE: |
2833 | CODE: |
2790 | RETVAL = SDL_RWFromFile (path, mode); |
2834 | RETVAL = SDL_RWFromFile (path, mode); |
2791 | OUTPUT: |
2835 | OUTPUT: |
2792 | RETVAL |
2836 | RETVAL |
2793 | |
2837 | |
… | |
… | |
2902 | #else |
2946 | #else |
2903 | XPUSHs (sv_2mortal (newSVpv ("(sdl mixer too old)", 0))); |
2947 | XPUSHs (sv_2mortal (newSVpv ("(sdl mixer too old)", 0))); |
2904 | #endif |
2948 | #endif |
2905 | |
2949 | |
2906 | DC::MixChunk |
2950 | DC::MixChunk |
2907 | new (SV *class, DC::RW rwops) |
2951 | new (SV *klass, DC::RW rwops) |
2908 | CODE: |
2952 | CODE: |
2909 | RETVAL = Mix_LoadWAV_RW (rwops, 1); |
2953 | RETVAL = Mix_LoadWAV_RW (rwops, 1); |
2910 | OUTPUT: |
2954 | OUTPUT: |
2911 | RETVAL |
2955 | RETVAL |
2912 | |
2956 | |
… | |
… | |
2982 | RETVAL = Mix_PlayingMusic (); |
3026 | RETVAL = Mix_PlayingMusic (); |
2983 | OUTPUT: |
3027 | OUTPUT: |
2984 | RETVAL |
3028 | RETVAL |
2985 | |
3029 | |
2986 | DC::MixMusic |
3030 | DC::MixMusic |
2987 | new (SV *class, DC::RW rwops) |
3031 | new (SV *klass, DC::RW rwops) |
2988 | CODE: |
3032 | CODE: |
2989 | RETVAL = Mix_LoadMUS_RW (rwops); |
3033 | RETVAL = Mix_LoadMUS_RW (rwops); |
2990 | OUTPUT: |
3034 | OUTPUT: |
2991 | RETVAL |
3035 | RETVAL |
2992 | |
3036 | |
… | |
… | |
3129 | const_iv (GL_FUNC_SUBTRACT), |
3173 | const_iv (GL_FUNC_SUBTRACT), |
3130 | const_iv (GL_FUNC_REVERSE_SUBTRACT), |
3174 | const_iv (GL_FUNC_REVERSE_SUBTRACT), |
3131 | # undef const_iv |
3175 | # undef const_iv |
3132 | }; |
3176 | }; |
3133 | |
3177 | |
3134 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
3178 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ > const_iv; civ--) |
3135 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
3179 | newCONSTSUB (stash, (char *)civ[-1].name, newSViv (civ[-1].iv)); |
3136 | |
3180 | |
3137 | texture_av = newAV (); |
3181 | texture_av = newAV (); |
3138 | AvREAL_off (texture_av); |
3182 | AvREAL_off (texture_av); |
3139 | } |
3183 | } |
3140 | |
3184 | |
… | |
… | |
3145 | gl.BlendFuncSeparateEXT = 0; |
3189 | gl.BlendFuncSeparateEXT = 0; |
3146 | |
3190 | |
3147 | void |
3191 | void |
3148 | apple_nvidia_bug (int enable) |
3192 | apple_nvidia_bug (int enable) |
3149 | |
3193 | |
3150 | char * |
3194 | const char * |
3151 | gl_vendor () |
3195 | gl_vendor () |
3152 | CODE: |
3196 | CODE: |
3153 | RETVAL = (char *)glGetString (GL_VENDOR); |
3197 | RETVAL = (const char *)glGetString (GL_VENDOR); |
3154 | OUTPUT: |
3198 | OUTPUT: |
3155 | RETVAL |
3199 | RETVAL |
3156 | |
3200 | |
3157 | char * |
3201 | const char * |
3158 | gl_version () |
3202 | gl_version () |
3159 | CODE: |
3203 | CODE: |
3160 | RETVAL = (char *)glGetString (GL_VERSION); |
3204 | RETVAL = (const char *)glGetString (GL_VERSION); |
3161 | OUTPUT: |
3205 | OUTPUT: |
3162 | RETVAL |
3206 | RETVAL |
3163 | |
3207 | |
3164 | char * |
3208 | const char * |
3165 | gl_extensions () |
3209 | gl_extensions () |
3166 | CODE: |
3210 | CODE: |
3167 | RETVAL = (char *)glGetString (GL_EXTENSIONS); |
3211 | RETVAL = (const char *)glGetString (GL_EXTENSIONS); |
3168 | OUTPUT: |
3212 | OUTPUT: |
3169 | RETVAL |
3213 | RETVAL |
3170 | |
3214 | |
3171 | const char *glGetString (GLenum pname) |
3215 | const char *glGetString (GLenum pname) |
|
|
3216 | CODE: |
|
|
3217 | RETVAL = (const char *)glGetString (pname); |
|
|
3218 | OUTPUT: |
|
|
3219 | RETVAL |
3172 | |
3220 | |
3173 | GLint glGetInteger (GLenum pname) |
3221 | GLint glGetInteger (GLenum pname) |
3174 | CODE: |
3222 | CODE: |
3175 | glGetIntegerv (pname, &RETVAL); |
3223 | glGetIntegerv (pname, &RETVAL); |
3176 | OUTPUT: |
3224 | OUTPUT: |
… | |
… | |
3183 | RETVAL |
3231 | RETVAL |
3184 | |
3232 | |
3185 | int glGetError () |
3233 | int glGetError () |
3186 | |
3234 | |
3187 | void glFinish () |
3235 | void glFinish () |
|
|
3236 | |
|
|
3237 | void glFlush () |
3188 | |
3238 | |
3189 | void glClear (int mask) |
3239 | void glClear (int mask) |
3190 | |
3240 | |
3191 | void glClearColor (float r, float g, float b, float a = 1.0) |
3241 | void glClearColor (float r, float g, float b, float a = 1.0) |
3192 | PROTOTYPE: @ |
3242 | PROTOTYPE: @ |