… | |
… | |
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 |
… | |
… | |
184 | { |
184 | { |
185 | GSList *attrs = run->item->analysis.extra_attrs; |
185 | GSList *attrs = run->item->analysis.extra_attrs; |
186 | |
186 | |
187 | while (attrs) |
187 | while (attrs) |
188 | { |
188 | { |
189 | PangoAttribute *attr = attrs->data; |
189 | PangoAttribute *attr = (PangoAttribute *)attrs->data; |
190 | |
190 | |
191 | if (attr->klass->type == PANGO_ATTR_SHAPE) |
191 | if (attr->klass->type == PANGO_ATTR_SHAPE) |
192 | return 1; |
192 | return 1; |
193 | |
193 | |
194 | attrs = attrs->next; |
194 | attrs = attrs->next; |
… | |
… | |
212 | static void |
212 | static void |
213 | substitute_func (FcPattern *pattern, gpointer data) |
213 | substitute_func (FcPattern *pattern, gpointer data) |
214 | { |
214 | { |
215 | FcPatternAddBool (pattern, FC_HINTING, 1); |
215 | FcPatternAddBool (pattern, FC_HINTING, 1); |
216 | #ifdef FC_HINT_STYLE |
216 | #ifdef FC_HINT_STYLE |
217 | FcPatternAddBool (pattern, FC_HINT_STYLE, FC_HINT_FULL); |
217 | FcPatternAddInteger (pattern, FC_HINT_STYLE, FC_HINT_FULL); |
218 | #endif |
218 | #endif |
219 | FcPatternAddBool (pattern, FC_AUTOHINT, 0); |
219 | FcPatternAddBool (pattern, FC_AUTOHINT, 0); |
220 | } |
220 | } |
221 | |
221 | |
222 | static void |
222 | static void |
… | |
… | |
481 | ev.data2 = 0; |
481 | ev.data2 = 0; |
482 | |
482 | |
483 | SDL_PushEvent ((SDL_Event *)&ev); |
483 | SDL_PushEvent ((SDL_Event *)&ev); |
484 | } |
484 | } |
485 | |
485 | |
|
|
486 | // approximately divide by 255 |
486 | static unsigned int |
487 | static unsigned int |
487 | div255 (unsigned int n) |
488 | div255 (unsigned int n) |
488 | { |
489 | { |
489 | return (n + (n >> 8)) >> 8; |
490 | return (n + (n >> 8)) >> 8; |
490 | } |
491 | } |
… | |
… | |
577 | |
578 | |
578 | return mod; |
579 | return mod; |
579 | } |
580 | } |
580 | |
581 | |
581 | static void |
582 | static void |
582 | deliantra_main () |
583 | deliantra_main (SV *real_main) |
583 | { |
584 | { |
584 | char *argv[] = { 0 }; |
585 | dSP; |
585 | call_argv ("::main", G_DISCARD | G_VOID, argv); |
586 | |
|
|
587 | PUSHMARK (SP); |
|
|
588 | call_sv (real_main, G_DISCARD | G_VOID); |
586 | } |
589 | } |
587 | |
590 | |
588 | #ifdef __MACOSX__ |
591 | #ifdef __MACOSX__ |
|
|
592 | static SV *real_main; |
|
|
593 | |
589 | /* to due surprising braindamage on the side of SDL design, we |
594 | /* to due surprising braindamage on the side of SDL design, we |
590 | * do some mind-boggling hack here: SDL requires a custom main() |
595 | * do some mind-boggling hack here: SDL requires a custom main() |
591 | * on OS X, so... we provide one and call the original main(), which, |
596 | * on OS X, so... we provide one and call the original main(), which, |
592 | * due to share dlibrary magic, calls -lSDLmain's main, not perl's main, |
597 | * due to shared library magic, calls -lSDLmain's main, not perl's main, |
593 | * and which calls our main (== SDL_main) back. |
598 | * and which calls our main (== SDL_main) back. |
594 | */ |
599 | */ |
595 | extern C_LINKAGE int |
600 | extern C_LINKAGE int |
596 | main (int argc, char *argv[]) |
601 | main (int argc, char *argv[]) |
597 | { |
602 | { |
598 | deliantra_main (); |
603 | deliantra_main (real_main); |
599 | } |
604 | } |
600 | |
605 | |
601 | #undef main |
606 | #undef main |
602 | |
607 | |
603 | extern C_LINKAGE int main (int argc, char *argv[]); |
608 | extern C_LINKAGE int main (int argc, char *argv[]); |
604 | |
609 | |
605 | static void |
610 | static void |
606 | SDL_braino (void) |
611 | SDL_main_hack (SV *real_main_) |
607 | { |
612 | { |
|
|
613 | real_main = real_main_; |
|
|
614 | |
608 | char *argv[] = { "deliantra client", 0 }; |
615 | char *argv[] = { "deliantra client", 0 }; |
609 | (main) (1, argv); |
616 | (main) (1, argv); |
610 | } |
617 | } |
611 | #else |
618 | #else |
612 | static void |
619 | static void |
613 | SDL_braino (void) |
620 | SDL_main_hack (SV *real_main) |
614 | { |
621 | { |
615 | deliantra_main (); |
622 | deliantra_main (real_main); |
616 | } |
623 | } |
617 | #endif |
624 | #endif |
618 | |
625 | |
619 | MODULE = Deliantra::Client PACKAGE = DC |
626 | MODULE = Deliantra::Client PACKAGE = DC |
620 | |
627 | |
… | |
… | |
821 | |
828 | |
822 | const_iv (FOW_DARKNESS) |
829 | const_iv (FOW_DARKNESS) |
823 | # undef const_iv |
830 | # undef const_iv |
824 | }; |
831 | }; |
825 | |
832 | |
826 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
833 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ > const_iv; civ--) |
827 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
834 | newCONSTSUB (stash, (char *)civ[-1].name, newSViv (civ[-1].iv)); |
828 | |
835 | |
829 | assert (SDLK_MODIFIER_MIN == SDLK_NUMLOCK); |
836 | assert (SDLK_MODIFIER_MIN == SDLK_NUMLOCK); |
830 | assert (SDLK_MODIFIER_MAX == SDLK_COMPOSE); |
837 | assert (SDLK_MODIFIER_MAX == SDLK_COMPOSE); |
831 | } |
838 | } |
832 | |
839 | |
… | |
… | |
871 | #endif |
878 | #endif |
872 | } |
879 | } |
873 | |
880 | |
874 | char *SDL_GetError () |
881 | char *SDL_GetError () |
875 | |
882 | |
876 | void SDL_braino () |
883 | void SDL_main_hack (SV *real_main) |
|
|
884 | PROTOTYPE: & |
877 | |
885 | |
878 | int SDL_Init (U32 flags) |
886 | int SDL_Init (U32 flags) |
879 | |
887 | |
880 | int SDL_InitSubSystem (U32 flags) |
888 | int SDL_InitSubSystem (U32 flags) |
881 | |
889 | |
882 | void SDL_QuitSubSystem (U32 flags) |
890 | void SDL_QuitSubSystem (U32 flags) |
883 | |
891 | |
884 | void SDL_Quit () |
892 | void SDL_Quit () |
885 | |
893 | |
886 | int SDL_GL_SetAttribute (int attr, int value) |
894 | int SDL_GL_SetAttribute (int attr, int value) |
|
|
895 | C_ARGS: (SDL_GLattr)attr, value |
887 | |
896 | |
888 | int SDL_GL_GetAttribute (int attr) |
897 | int SDL_GL_GetAttribute (int attr) |
889 | CODE: |
898 | CODE: |
890 | if (SDL_GL_GetAttribute (attr, &RETVAL)) |
899 | if (SDL_GL_GetAttribute ((SDL_GLattr)attr, &RETVAL)) |
891 | XSRETURN_UNDEF; |
900 | XSRETURN_UNDEF; |
892 | OUTPUT: |
901 | OUTPUT: |
893 | RETVAL |
902 | RETVAL |
894 | |
903 | |
895 | void |
904 | void |
… | |
… | |
950 | ); |
959 | ); |
951 | |
960 | |
952 | if (RETVAL) |
961 | if (RETVAL) |
953 | { |
962 | { |
954 | av_clear (texture_av); |
963 | av_clear (texture_av); |
955 | |
|
|
956 | SDL_WM_SetCaption ("Deliantra MORPG Client " VERSION, "Deliantra"); |
|
|
957 | #define GL_FUNC(ptr,name) gl.name = (ptr)SDL_GL_GetProcAddress ("gl" # name); |
964 | #define GL_FUNC(ptr,name) gl.name = (ptr)SDL_GL_GetProcAddress ("gl" # name); |
958 | #include "glfunc.h" |
965 | #include "glfunc.h" |
959 | #undef GL_FUNC |
966 | #undef GL_FUNC |
960 | |
|
|
961 | if (!gl.ActiveTexture ) gl.ActiveTexture = gl.ActiveTextureARB; |
967 | if (!gl.ActiveTexture ) gl.ActiveTexture = gl.ActiveTextureARB; |
962 | if (!gl.MultiTexCoord2f) gl.MultiTexCoord2f = gl.MultiTexCoord2fARB; |
968 | if (!gl.MultiTexCoord2f) gl.MultiTexCoord2f = gl.MultiTexCoord2fARB; |
963 | } |
969 | } |
964 | } |
970 | } |
965 | OUTPUT: |
971 | OUTPUT: |
966 | RETVAL |
972 | RETVAL |
967 | |
973 | |
968 | void |
974 | void |
|
|
975 | SDL_WM_SetCaption (const char *title, const char *icon) |
|
|
976 | |
|
|
977 | void |
969 | SDL_GL_SwapBuffers () |
978 | SDL_GL_SwapBuffers () |
970 | |
979 | |
971 | char * |
980 | char * |
972 | SDL_GetKeyName (int sym) |
981 | SDL_GetKeyName (int sym) |
|
|
982 | C_ARGS: (SDLKey)sym |
973 | |
983 | |
974 | int |
984 | int |
975 | SDL_GetAppState () |
985 | SDL_GetAppState () |
976 | |
986 | |
977 | int |
987 | int |
978 | SDL_GetModState () |
988 | SDL_GetModState () |
979 | |
989 | |
|
|
990 | int |
|
|
991 | SDL_WaitEvent () |
|
|
992 | C_ARGS: 0 |
|
|
993 | |
980 | void |
994 | void |
|
|
995 | SDL_PumpEvents () |
|
|
996 | |
|
|
997 | void |
981 | poll_events () |
998 | peep_events () |
982 | PPCODE: |
999 | PPCODE: |
983 | { |
1000 | { |
984 | SDL_Event ev; |
1001 | SDL_Event ev; |
985 | |
1002 | |
986 | SDL_PumpEvents (); |
1003 | SDL_PumpEvents (); |
… | |
… | |
1067 | OUTPUT: |
1084 | OUTPUT: |
1068 | RETVAL |
1085 | RETVAL |
1069 | |
1086 | |
1070 | int |
1087 | int |
1071 | Mix_OpenAudio (int frequency = 44100, int format = MIX_DEFAULT_FORMAT, int channels = 2, int chunksize = 4096) |
1088 | Mix_OpenAudio (int frequency = 44100, int format = MIX_DEFAULT_FORMAT, int channels = 2, int chunksize = 4096) |
1072 | POSTCALL: |
1089 | POSTCALL: |
1073 | Mix_HookMusicFinished (music_finished); |
1090 | Mix_HookMusicFinished (music_finished); |
1074 | Mix_ChannelFinished (channel_finished); |
1091 | Mix_ChannelFinished (channel_finished); |
1075 | |
1092 | |
1076 | void |
1093 | void |
1077 | Mix_QuerySpec () |
1094 | Mix_QuerySpec () |
… | |
… | |
1139 | OUTPUT: |
1156 | OUTPUT: |
1140 | RETVAL |
1157 | RETVAL |
1141 | |
1158 | |
1142 | void |
1159 | void |
1143 | IMG_Init (int flags = IMG_INIT_JPG | IMG_INIT_PNG) |
1160 | IMG_Init (int flags = IMG_INIT_JPG | IMG_INIT_PNG) |
|
|
1161 | |
|
|
1162 | # MIX_INIT_MP3 gives smpeg + libstdc++ + libgcc_s |
|
|
1163 | void |
|
|
1164 | Mix_Init (int flags = MIX_INIT_MOD | MIX_INIT_OGG) |
1144 | |
1165 | |
1145 | void |
1166 | void |
1146 | load_image_inline (SV *image_) |
1167 | load_image_inline (SV *image_) |
1147 | ALIAS: |
1168 | ALIAS: |
1148 | load_image_file = 1 |
1169 | load_image_file = 1 |
… | |
… | |
1194 | |
1215 | |
1195 | SDL_LockSurface (surface2); |
1216 | SDL_LockSurface (surface2); |
1196 | EXTEND (SP, 6); |
1217 | EXTEND (SP, 6); |
1197 | PUSHs (sv_2mortal (newSViv (surface2->w))); |
1218 | PUSHs (sv_2mortal (newSViv (surface2->w))); |
1198 | PUSHs (sv_2mortal (newSViv (surface2->h))); |
1219 | PUSHs (sv_2mortal (newSViv (surface2->h))); |
1199 | PUSHs (sv_2mortal (newSVpvn (surface2->pixels, surface2->h * surface2->pitch))); |
1220 | PUSHs (sv_2mortal (newSVpvn ((const char *)surface2->pixels, surface2->h * surface2->pitch))); |
1200 | PUSHs (sv_2mortal (newSViv (surface->flags & (SDL_SRCCOLORKEY | SDL_SRCALPHA) ? GL_RGBA : GL_RGB))); |
1221 | PUSHs (sv_2mortal (newSViv (surface->flags & (SDL_SRCCOLORKEY | SDL_SRCALPHA) ? GL_RGBA : GL_RGB))); |
1201 | PUSHs (sv_2mortal (newSViv (GL_RGBA))); |
1222 | PUSHs (sv_2mortal (newSViv (GL_RGBA))); |
1202 | PUSHs (sv_2mortal (newSViv (GL_UNSIGNED_BYTE))); |
1223 | PUSHs (sv_2mortal (newSViv (GL_UNSIGNED_BYTE))); |
1203 | SDL_UnlockSurface (surface2); |
1224 | SDL_UnlockSurface (surface2); |
1204 | |
1225 | |
… | |
… | |
1276 | MODULE = Deliantra::Client PACKAGE = DC::Font |
1297 | MODULE = Deliantra::Client PACKAGE = DC::Font |
1277 | |
1298 | |
1278 | PROTOTYPES: DISABLE |
1299 | PROTOTYPES: DISABLE |
1279 | |
1300 | |
1280 | DC::Font |
1301 | DC::Font |
1281 | new_from_file (SV *class, char *path, int id = 0) |
1302 | new_from_file (SV *klass, char *path, int id = 0) |
1282 | CODE: |
1303 | CODE: |
1283 | { |
1304 | { |
1284 | int count; |
1305 | int count; |
1285 | FcPattern *pattern = FcFreeTypeQuery ((const FcChar8 *)path, id, 0, &count); |
1306 | FcPattern *pattern = FcFreeTypeQuery ((const FcChar8 *)path, id, 0, &count); |
1286 | RETVAL = pango_fc_font_description_from_pattern (pattern, 0); |
1307 | RETVAL = pango_fc_font_description_from_pattern (pattern, 0); |
… | |
… | |
1315 | PROTOTYPE: |
1336 | PROTOTYPE: |
1316 | CODE: |
1337 | CODE: |
1317 | tc_restore (); |
1338 | tc_restore (); |
1318 | |
1339 | |
1319 | DC::Layout |
1340 | DC::Layout |
1320 | new (SV *class) |
1341 | new (SV *klass) |
1321 | CODE: |
1342 | CODE: |
1322 | New (0, RETVAL, 1, struct cf_layout); |
1343 | New (0, RETVAL, 1, struct cf_layout); |
1323 | |
1344 | |
1324 | RETVAL->pl = pango_layout_new (opengl_context); |
1345 | RETVAL->pl = pango_layout_new (opengl_context); |
1325 | RETVAL->r = 1.; |
1346 | RETVAL->r = 1.; |
… | |
… | |
1474 | |
1495 | |
1475 | void |
1496 | void |
1476 | set_height (DC::Layout self, int base_height) |
1497 | set_height (DC::Layout self, int base_height) |
1477 | CODE: |
1498 | CODE: |
1478 | if (self->base_height != base_height) |
1499 | if (self->base_height != base_height) |
1479 | { |
1500 | { |
1480 | self->base_height = base_height; |
1501 | self->base_height = base_height; |
1481 | layout_update_font (self); |
1502 | layout_update_font (self); |
1482 | } |
1503 | } |
1483 | |
1504 | |
1484 | void |
1505 | void |
… | |
… | |
1848 | MODULE = Deliantra::Client PACKAGE = DC::Map |
1869 | MODULE = Deliantra::Client PACKAGE = DC::Map |
1849 | |
1870 | |
1850 | PROTOTYPES: DISABLE |
1871 | PROTOTYPES: DISABLE |
1851 | |
1872 | |
1852 | DC::Map |
1873 | DC::Map |
1853 | new (SV *class) |
1874 | new (SV *klass) |
1854 | CODE: |
1875 | CODE: |
1855 | New (0, RETVAL, 1, struct map); |
1876 | New (0, RETVAL, 1, struct map); |
1856 | RETVAL->x = 0; |
1877 | RETVAL->x = 0; |
1857 | RETVAL->y = 0; |
1878 | RETVAL->y = 0; |
1858 | RETVAL->w = 0; |
1879 | RETVAL->w = 0; |
… | |
… | |
1897 | |
1918 | |
1898 | void |
1919 | void |
1899 | set_smooth (DC::Map self, int face, int smooth, int level) |
1920 | set_smooth (DC::Map self, int face, int smooth, int level) |
1900 | CODE: |
1921 | CODE: |
1901 | { |
1922 | { |
1902 | tileid texid; |
1923 | tileid texid; |
1903 | maptex *tex; |
1924 | maptex *tex; |
1904 | |
1925 | |
1905 | if (face < 0 || face >= self->faces) |
1926 | if (face < 0 || face >= self->faces) |
1906 | return; |
1927 | return; |
1907 | |
1928 | |
1908 | if (smooth < 0 || smooth >= self->faces) |
1929 | if (smooth < 0 || smooth >= self->faces) |
1909 | return; |
1930 | return; |
1910 | |
1931 | |
1911 | texid = self->face2tile [face]; |
1932 | texid = self->face2tile [face]; |
1912 | |
1933 | |
1913 | if (!texid) |
1934 | if (!texid) |
1914 | return; |
1935 | return; |
1915 | |
1936 | |
1916 | tex = self->tex + texid; |
1937 | tex = self->tex + texid; |
… | |
… | |
1949 | } |
1970 | } |
1950 | |
1971 | |
1951 | void |
1972 | void |
1952 | expire_textures (DC::Map self, int texid, int count) |
1973 | expire_textures (DC::Map self, int texid, int count) |
1953 | PPCODE: |
1974 | PPCODE: |
1954 | for (; texid < self->texs && count; ++texid, --count) |
1975 | for (; texid < self->texs && count; ++texid, --count) |
1955 | { |
1976 | { |
1956 | maptex *tex = self->tex + texid; |
1977 | maptex *tex = self->tex + texid; |
1957 | |
1978 | |
1958 | if (tex->name) |
1979 | if (tex->name) |
1959 | { |
1980 | { |
… | |
… | |
2014 | self->y += MAP_EXTEND_Y; |
2035 | self->y += MAP_EXTEND_Y; |
2015 | } |
2036 | } |
2016 | } |
2037 | } |
2017 | |
2038 | |
2018 | SV * |
2039 | SV * |
2019 | map1a_update (DC::Map self, SV *data_, int extmap) |
2040 | map1a_update (DC::Map self, SV *data_) |
2020 | CODE: |
2041 | CODE: |
2021 | { |
2042 | { |
2022 | uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_); |
2043 | uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_); |
2023 | uint8_t *data_end = (uint8_t *)SvEND (data_); |
2044 | uint8_t *data_end = (uint8_t *)SvEND (data_); |
2024 | mapcell *cell; |
2045 | mapcell *cell; |
… | |
… | |
2045 | |
2066 | |
2046 | //TODO: don't trust server data to be in-range(!) |
2067 | //TODO: don't trust server data to be in-range(!) |
2047 | |
2068 | |
2048 | if (flags & 8) |
2069 | if (flags & 8) |
2049 | { |
2070 | { |
|
|
2071 | uint8_t ext, cmd; |
|
|
2072 | |
2050 | if (extmap) |
2073 | do |
2051 | { |
2074 | { |
2052 | uint8_t ext, cmd; |
2075 | ext = *data++; |
|
|
2076 | cmd = ext & 0x7f; |
2053 | |
2077 | |
2054 | do |
2078 | if (cmd < 4) |
|
|
2079 | cell->darkness = 255 - ext * 64 + 1; /* make sure this doesn't collide with FOW_DARKNESS */ |
|
|
2080 | else if (cmd == 5) // health |
2055 | { |
2081 | { |
2056 | ext = *data++; |
|
|
2057 | cmd = ext & 0x7f; |
|
|
2058 | |
|
|
2059 | if (cmd < 4) |
|
|
2060 | cell->darkness = 255 - ext * 64 + 1; /* make sure this doesn't collide with FOW_DARKNESS */ |
|
|
2061 | else if (cmd == 5) // health |
|
|
2062 | { |
|
|
2063 | cell->stat_width = 1; |
2082 | cell->stat_width = 1; |
2064 | cell->stat_hp = *data++; |
2083 | cell->stat_hp = *data++; |
2065 | } |
|
|
2066 | else if (cmd == 6) // monster width |
|
|
2067 | cell->stat_width = *data++ + 1; |
|
|
2068 | else if (cmd == 0x47) |
|
|
2069 | { |
|
|
2070 | if (*data == 1) cell->player = data [1]; |
|
|
2071 | else if (*data == 2) cell->player = data [2] + (data [1] << 8); |
|
|
2072 | else if (*data == 3) cell->player = data [3] + (data [2] << 8) + (data [1] << 16); |
|
|
2073 | else if (*data == 4) cell->player = data [4] + (data [3] << 8) + (data [2] << 16) + (data [1] << 24); |
|
|
2074 | |
|
|
2075 | data += *data + 1; |
|
|
2076 | } |
|
|
2077 | else if (cmd == 8) // cell flags |
|
|
2078 | cell->flags = *data++; |
|
|
2079 | else if (ext & 0x40) // unknown, multibyte => skip |
|
|
2080 | data += *data + 1; |
|
|
2081 | else |
|
|
2082 | data++; |
|
|
2083 | } |
2084 | } |
2084 | while (ext & 0x80); |
2085 | else if (cmd == 6) // monster width |
|
|
2086 | cell->stat_width = *data++ + 1; |
|
|
2087 | else if (cmd == 0x47) |
|
|
2088 | { |
|
|
2089 | if (*data == 1) cell->player = data [1]; |
|
|
2090 | else if (*data == 2) cell->player = data [2] + (data [1] << 8); |
|
|
2091 | else if (*data == 3) cell->player = data [3] + (data [2] << 8) + (data [1] << 16); |
|
|
2092 | else if (*data == 4) cell->player = data [4] + (data [3] << 8) + (data [2] << 16) + (data [1] << 24); |
|
|
2093 | |
|
|
2094 | data += *data + 1; |
|
|
2095 | } |
|
|
2096 | else if (cmd == 8) // cell flags |
|
|
2097 | cell->flags = *data++; |
|
|
2098 | else if (ext & 0x40) // unknown, multibyte => skip |
|
|
2099 | data += *data + 1; |
|
|
2100 | else |
|
|
2101 | data++; |
2085 | } |
2102 | } |
2086 | else |
2103 | while (ext & 0x80); |
2087 | cell->darkness = *data++ + 1; |
|
|
2088 | } |
2104 | } |
2089 | |
2105 | |
2090 | for (z = 0; z <= 2; ++z) |
2106 | for (z = 0; z <= 2; ++z) |
2091 | if (flags & (4 >> z)) |
2107 | if (flags & (4 >> z)) |
2092 | { |
2108 | { |
… | |
… | |
2166 | | (b << 16) |
2182 | | (b << 16) |
2167 | | (a << 24); |
2183 | | (a << 24); |
2168 | } |
2184 | } |
2169 | } |
2185 | } |
2170 | |
2186 | |
2171 | RETVAL = map_sv; |
2187 | RETVAL = map_sv; |
2172 | } |
2188 | } |
2173 | OUTPUT: |
2189 | OUTPUT: |
2174 | RETVAL |
2190 | RETVAL |
2175 | |
2191 | |
2176 | void |
2192 | void |
2177 | 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) |
2193 | 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) |
2178 | CODE: |
2194 | CODE: |
2179 | { |
2195 | { |
2180 | int x, y, z; |
2196 | int x, y, z; |
2181 | |
2197 | |
2182 | HV *smooth = (HV *)sv_2mortal ((SV *)newHV ()); |
2198 | HV *smooth = (HV *)sv_2mortal ((SV *)newHV ()); |
2183 | uint32_t smooth_level[256 / 32]; // one bit for every possible smooth level |
2199 | uint32_t smooth_level[256 / 32]; // one bit for every possible smooth level |
2184 | static uint8_t smooth_max[256][256]; // egad, fast and wasteful on memory (64k) |
2200 | static uint8_t smooth_max[256][256]; // egad, fast and wasteful on memory (64k) |
2185 | smooth_key skey; |
2201 | smooth_key skey; |
2186 | int pl_x, pl_y; |
2202 | int pl_x, pl_y; |
2187 | maptex pl_tex; |
2203 | maptex pl_tex; |
… | |
… | |
2566 | int x, y; |
2582 | int x, y; |
2567 | int sw1 = sw + 2; |
2583 | int sw1 = sw + 2; |
2568 | int sh1 = sh + 2; |
2584 | int sh1 = sh + 2; |
2569 | int sh3 = sh * 3; |
2585 | int sh3 = sh * 3; |
2570 | int sw3 = sw * 3; |
2586 | int sw3 = sw * 3; |
2571 | uint8_t *darkness1 = (uint8_t *)malloc (sw1 * sh1); |
|
|
2572 | SV *darkness3_sv = sv_2mortal (newSV (sw3 * sh3)); |
2587 | SV *darkness3_sv = sv_2mortal (newSV (sw3 * sh3)); |
2573 | uint8_t *darkness3 = (uint8_t *)SvPVX (darkness3_sv); |
2588 | uint8_t *darkness3 = (uint8_t *)SvPVX (darkness3_sv); |
|
|
2589 | uint8_t *darkness1 = (uint8_t *)malloc (sw1 * sh1); |
|
|
2590 | memset (darkness1, 0, sw1*sh1); |
2574 | |
2591 | |
2575 | SvPOK_only (darkness3_sv); |
2592 | SvPOK_only (darkness3_sv); |
2576 | SvCUR_set (darkness3_sv, sw3 * sh3); |
2593 | SvCUR_set (darkness3_sv, sw3 * sh3); |
2577 | |
2594 | |
2578 | mx += self->x - 1; |
2595 | mx += self->x - 1; |
… | |
… | |
2704 | else |
2721 | else |
2705 | *data++ = 0; |
2722 | *data++ = 0; |
2706 | } |
2723 | } |
2707 | } |
2724 | } |
2708 | |
2725 | |
2709 | /* if size is w*h + 5 then no data has been found */ |
2726 | /* if size is w*h + 5 then no data has been found */ |
2710 | if (data - (uint8_t *)SvPVX (data_sv) != w * h + 5) |
2727 | if (data - (uint8_t *)SvPVX (data_sv) != w * h + 5) |
2711 | { |
2728 | { |
2712 | SvPOK_only (data_sv); |
2729 | SvPOK_only (data_sv); |
2713 | SvCUR_set (data_sv, data - (uint8_t *)SvPVX (data_sv)); |
2730 | SvCUR_set (data_sv, data - (uint8_t *)SvPVX (data_sv)); |
2714 | } |
2731 | } |
2715 | |
2732 | |
2716 | RETVAL = data_sv; |
2733 | RETVAL = data_sv; |
2717 | } |
2734 | } |
2718 | OUTPUT: |
2735 | OUTPUT: |
2719 | RETVAL |
2736 | RETVAL |
2720 | |
2737 | |
2721 | void |
2738 | void |
… | |
… | |
2728 | STRLEN len; |
2745 | STRLEN len; |
2729 | uint8_t *data, *end; |
2746 | uint8_t *data, *end; |
2730 | |
2747 | |
2731 | len = SvLEN (data_sv); |
2748 | len = SvLEN (data_sv); |
2732 | SvGROW (data_sv, len + 8); // reserve at least 7+ bytes more |
2749 | SvGROW (data_sv, len + 8); // reserve at least 7+ bytes more |
2733 | data = SvPVbyte_nolen (data_sv); |
2750 | data = (uint8_t *)SvPVbyte_nolen (data_sv); |
2734 | end = data + len + 8; |
2751 | end = data + len + 8; |
2735 | |
2752 | |
2736 | if (len < 5) |
2753 | if (len < 5) |
2737 | XSRETURN_EMPTY; |
2754 | XSRETURN_EMPTY; |
2738 | |
2755 | |
… | |
… | |
2799 | } |
2816 | } |
2800 | |
2817 | |
2801 | MODULE = Deliantra::Client PACKAGE = DC::RW |
2818 | MODULE = Deliantra::Client PACKAGE = DC::RW |
2802 | |
2819 | |
2803 | DC::RW |
2820 | DC::RW |
2804 | new (SV *class, SV *data_sv) |
2821 | new (SV *klass, SV *data_sv) |
2805 | CODE: |
2822 | CODE: |
2806 | { |
2823 | { |
2807 | STRLEN datalen; |
2824 | STRLEN datalen; |
2808 | char *data = SvPVbyte (data_sv, datalen); |
2825 | char *data = SvPVbyte (data_sv, datalen); |
2809 | |
2826 | |
… | |
… | |
2811 | } |
2828 | } |
2812 | OUTPUT: |
2829 | OUTPUT: |
2813 | RETVAL |
2830 | RETVAL |
2814 | |
2831 | |
2815 | DC::RW |
2832 | DC::RW |
2816 | new_from_file (SV *class, const char *path, const char *mode = "rb") |
2833 | new_from_file (SV *klass, const char *path, const char *mode = "rb") |
2817 | CODE: |
2834 | CODE: |
2818 | RETVAL = SDL_RWFromFile (path, mode); |
2835 | RETVAL = SDL_RWFromFile (path, mode); |
2819 | OUTPUT: |
2836 | OUTPUT: |
2820 | RETVAL |
2837 | RETVAL |
2821 | |
2838 | |
… | |
… | |
2930 | #else |
2947 | #else |
2931 | XPUSHs (sv_2mortal (newSVpv ("(sdl mixer too old)", 0))); |
2948 | XPUSHs (sv_2mortal (newSVpv ("(sdl mixer too old)", 0))); |
2932 | #endif |
2949 | #endif |
2933 | |
2950 | |
2934 | DC::MixChunk |
2951 | DC::MixChunk |
2935 | new (SV *class, DC::RW rwops) |
2952 | new (SV *klass, DC::RW rwops) |
2936 | CODE: |
2953 | CODE: |
2937 | RETVAL = Mix_LoadWAV_RW (rwops, 1); |
2954 | RETVAL = Mix_LoadWAV_RW (rwops, 1); |
2938 | OUTPUT: |
2955 | OUTPUT: |
2939 | RETVAL |
2956 | RETVAL |
2940 | |
2957 | |
… | |
… | |
3010 | RETVAL = Mix_PlayingMusic (); |
3027 | RETVAL = Mix_PlayingMusic (); |
3011 | OUTPUT: |
3028 | OUTPUT: |
3012 | RETVAL |
3029 | RETVAL |
3013 | |
3030 | |
3014 | DC::MixMusic |
3031 | DC::MixMusic |
3015 | new (SV *class, DC::RW rwops) |
3032 | new (SV *klass, DC::RW rwops) |
3016 | CODE: |
3033 | CODE: |
3017 | RETVAL = Mix_LoadMUS_RW (rwops); |
3034 | RETVAL = Mix_LoadMUS_RW (rwops); |
3018 | OUTPUT: |
3035 | OUTPUT: |
3019 | RETVAL |
3036 | RETVAL |
3020 | |
3037 | |
… | |
… | |
3157 | const_iv (GL_FUNC_SUBTRACT), |
3174 | const_iv (GL_FUNC_SUBTRACT), |
3158 | const_iv (GL_FUNC_REVERSE_SUBTRACT), |
3175 | const_iv (GL_FUNC_REVERSE_SUBTRACT), |
3159 | # undef const_iv |
3176 | # undef const_iv |
3160 | }; |
3177 | }; |
3161 | |
3178 | |
3162 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
3179 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ > const_iv; civ--) |
3163 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
3180 | newCONSTSUB (stash, (char *)civ[-1].name, newSViv (civ[-1].iv)); |
3164 | |
3181 | |
3165 | texture_av = newAV (); |
3182 | texture_av = newAV (); |
3166 | AvREAL_off (texture_av); |
3183 | AvREAL_off (texture_av); |
3167 | } |
3184 | } |
3168 | |
3185 | |
… | |
… | |
3173 | gl.BlendFuncSeparateEXT = 0; |
3190 | gl.BlendFuncSeparateEXT = 0; |
3174 | |
3191 | |
3175 | void |
3192 | void |
3176 | apple_nvidia_bug (int enable) |
3193 | apple_nvidia_bug (int enable) |
3177 | |
3194 | |
3178 | char * |
3195 | const char * |
3179 | gl_vendor () |
3196 | gl_vendor () |
3180 | CODE: |
3197 | CODE: |
3181 | RETVAL = (char *)glGetString (GL_VENDOR); |
3198 | RETVAL = (const char *)glGetString (GL_VENDOR); |
3182 | OUTPUT: |
3199 | OUTPUT: |
3183 | RETVAL |
3200 | RETVAL |
3184 | |
3201 | |
3185 | char * |
3202 | const char * |
3186 | gl_version () |
3203 | gl_version () |
3187 | CODE: |
3204 | CODE: |
3188 | RETVAL = (char *)glGetString (GL_VERSION); |
3205 | RETVAL = (const char *)glGetString (GL_VERSION); |
3189 | OUTPUT: |
3206 | OUTPUT: |
3190 | RETVAL |
3207 | RETVAL |
3191 | |
3208 | |
3192 | char * |
3209 | const char * |
3193 | gl_extensions () |
3210 | gl_extensions () |
3194 | CODE: |
3211 | CODE: |
3195 | RETVAL = (char *)glGetString (GL_EXTENSIONS); |
3212 | RETVAL = (const char *)glGetString (GL_EXTENSIONS); |
3196 | OUTPUT: |
3213 | OUTPUT: |
3197 | RETVAL |
3214 | RETVAL |
3198 | |
3215 | |
3199 | const char *glGetString (GLenum pname) |
3216 | const char *glGetString (GLenum pname) |
|
|
3217 | CODE: |
|
|
3218 | RETVAL = (const char *)glGetString (pname); |
|
|
3219 | OUTPUT: |
|
|
3220 | RETVAL |
3200 | |
3221 | |
3201 | GLint glGetInteger (GLenum pname) |
3222 | GLint glGetInteger (GLenum pname) |
3202 | CODE: |
3223 | CODE: |
3203 | glGetIntegerv (pname, &RETVAL); |
3224 | glGetIntegerv (pname, &RETVAL); |
3204 | OUTPUT: |
3225 | OUTPUT: |
… | |
… | |
3407 | |
3428 | |
3408 | void |
3429 | void |
3409 | find_widget (SV *self, NV x, NV y) |
3430 | find_widget (SV *self, NV x, NV y) |
3410 | PPCODE: |
3431 | PPCODE: |
3411 | { |
3432 | { |
3412 | if (within_widget (self, x, y)) |
3433 | if (within_widget (self, x, y)) |
3413 | XPUSHs (self); |
3434 | XPUSHs (self); |
3414 | } |
3435 | } |
3415 | |
3436 | |
3416 | BOOT: |
3437 | BOOT: |
3417 | { |
3438 | { |
… | |
… | |
3425 | |
3446 | |
3426 | void |
3447 | void |
3427 | draw (SV *self) |
3448 | draw (SV *self) |
3428 | CODE: |
3449 | CODE: |
3429 | { |
3450 | { |
3430 | HV *hv; |
3451 | HV *hv; |
3431 | SV **svp; |
3452 | SV **svp; |
3432 | NV x, y, w, h; |
3453 | NV x, y, w, h; |
3433 | SV *draw_x_sv = GvSV (draw_x_gv); |
3454 | SV *draw_x_sv = GvSV (draw_x_gv); |
3434 | SV *draw_y_sv = GvSV (draw_y_gv); |
3455 | SV *draw_y_sv = GvSV (draw_y_gv); |
3435 | SV *draw_w_sv = GvSV (draw_w_gv); |
3456 | SV *draw_w_sv = GvSV (draw_w_gv); |
3436 | SV *draw_h_sv = GvSV (draw_h_gv); |
3457 | SV *draw_h_sv = GvSV (draw_h_gv); |