… | |
… | |
15 | |
15 | |
16 | #include "EXTERN.h" |
16 | #include "EXTERN.h" |
17 | #include "perl.h" |
17 | #include "perl.h" |
18 | #include "XSUB.h" |
18 | #include "XSUB.h" |
19 | |
19 | |
|
|
20 | #include "flat_hash_map.hpp" |
|
|
21 | |
20 | #ifdef _WIN32 |
22 | #ifdef _WIN32 |
21 | # undef pipe |
23 | # undef pipe |
22 | // microsoft vs. C |
24 | // microsoft vs. C |
23 | # define sqrtf(x) sqrt(x) |
25 | # define sqrtf(x) sqrt(x) |
24 | # define atan2f(x,y) atan2(x,y) |
26 | # define atan2f(x,y) atan2(x,y) |
25 | # define M_PI 3.14159265f |
27 | # define M_PI 3.14159265f |
26 | #endif |
28 | #endif |
27 | |
29 | |
28 | #include <assert.h> |
30 | #include <cassert> |
29 | #include <math.h> |
31 | #include <cmath> |
30 | #include <string.h> |
32 | #include <cstring> |
31 | #include <stdio.h> |
33 | #include <cstdio> |
32 | #include <stdlib.h> |
34 | #include <cstdlib> |
|
|
35 | |
|
|
36 | #include <utility> |
33 | |
37 | |
34 | #define USE_RWOPS 1 // for SDL_mixer:LoadMUS_RW |
38 | #define USE_RWOPS 1 // for SDL_mixer:LoadMUS_RW |
35 | |
39 | |
36 | #include <SDL.h> |
40 | #include <SDL.h> |
37 | #include <SDL_thread.h> |
41 | #include <SDL_thread.h> |
… | |
… | |
48 | #endif |
52 | #endif |
49 | |
53 | |
50 | #define PANGO_ENABLE_BACKEND |
54 | #define PANGO_ENABLE_BACKEND |
51 | #define G_DISABLE_CAST_CHECKS |
55 | #define G_DISABLE_CAST_CHECKS |
52 | |
56 | |
53 | #include <glib/gmacros.h> |
57 | #include <glib.h> |
54 | |
58 | |
55 | #include <pango/pango.h> |
59 | #include <pango/pango.h> |
56 | |
60 | |
57 | #ifndef PANGO_VERSION_CHECK |
61 | #ifndef PANGO_VERSION_CHECK |
58 | # define PANGO_VERSION_CHECK(a,b,c) 0 |
62 | # define PANGO_VERSION_CHECK(a,b,c) 0 |
… | |
… | |
100 | #define KMOD_LRAM 0x10000 // our extension |
104 | #define KMOD_LRAM 0x10000 // our extension |
101 | |
105 | |
102 | #define TEXID_SPEECH 1 |
106 | #define TEXID_SPEECH 1 |
103 | #define TEXID_NOFACE 2 |
107 | #define TEXID_NOFACE 2 |
104 | |
108 | |
|
|
109 | static char * |
|
|
110 | fast_sv_grow (SV *sv, STRLEN need) |
|
|
111 | { |
|
|
112 | STRLEN len = SvLEN (sv); |
|
|
113 | STRLEN want = SvCUR (sv) + need; |
|
|
114 | |
|
|
115 | if (expect_false (len < want)) |
|
|
116 | { |
|
|
117 | do |
|
|
118 | len *= 2; |
|
|
119 | while (len < want); |
|
|
120 | |
|
|
121 | sv_grow (sv, len); |
|
|
122 | } |
|
|
123 | |
|
|
124 | SvCUR_set (sv, want); |
|
|
125 | return SvEND (sv) - need; |
|
|
126 | } |
|
|
127 | |
105 | static AV *texture_av; |
128 | static AV *texture_av; |
106 | |
129 | |
107 | static struct |
130 | static struct |
108 | { |
131 | { |
109 | #define GL_FUNC(ptr,name) ptr name; |
132 | #define GL_FUNC(ptr,name) ptr name; |
… | |
… | |
165 | { |
188 | { |
166 | GSList *attrs = run->item->analysis.extra_attrs; |
189 | GSList *attrs = run->item->analysis.extra_attrs; |
167 | |
190 | |
168 | while (attrs) |
191 | while (attrs) |
169 | { |
192 | { |
170 | PangoAttribute *attr = attrs->data; |
193 | PangoAttribute *attr = (PangoAttribute *)attrs->data; |
171 | |
194 | |
172 | if (attr->klass->type == PANGO_ATTR_SHAPE) |
195 | if (attr->klass->type == PANGO_ATTR_SHAPE) |
173 | return 1; |
196 | return 1; |
174 | |
197 | |
175 | attrs = attrs->next; |
198 | attrs = attrs->next; |
… | |
… | |
193 | static void |
216 | static void |
194 | substitute_func (FcPattern *pattern, gpointer data) |
217 | substitute_func (FcPattern *pattern, gpointer data) |
195 | { |
218 | { |
196 | FcPatternAddBool (pattern, FC_HINTING, 1); |
219 | FcPatternAddBool (pattern, FC_HINTING, 1); |
197 | #ifdef FC_HINT_STYLE |
220 | #ifdef FC_HINT_STYLE |
198 | FcPatternAddBool (pattern, FC_HINT_STYLE, FC_HINT_FULL); |
221 | FcPatternAddInteger (pattern, FC_HINT_STYLE, FC_HINT_FULL); |
199 | #endif |
222 | #endif |
200 | FcPatternAddBool (pattern, FC_AUTOHINT, 0); |
223 | FcPatternAddBool (pattern, FC_AUTOHINT, 0); |
201 | } |
224 | } |
202 | |
225 | |
203 | static void |
226 | static void |
… | |
… | |
420 | CELL_CLEAR (cell); |
443 | CELL_CLEAR (cell); |
421 | } |
444 | } |
422 | } |
445 | } |
423 | } |
446 | } |
424 | |
447 | |
425 | typedef struct { |
448 | struct smooth_key |
|
|
449 | { |
426 | tileid tile; |
450 | tileid tile; |
427 | uint8_t x, y, level; |
451 | uint8_t x, y, level; |
428 | } smooth_key; |
452 | |
|
|
453 | bool operator == (const smooth_key &o) const |
|
|
454 | { |
|
|
455 | return tile == o.tile && x == o.x && y == o.y && level == o.level; |
|
|
456 | } |
|
|
457 | }; |
|
|
458 | |
|
|
459 | typedef ska::flat_hash_map<smooth_key, IV> smooth_hash; |
|
|
460 | |
|
|
461 | namespace std { |
|
|
462 | template <> |
|
|
463 | struct hash<smooth_key> |
|
|
464 | { |
|
|
465 | size_t operator () (const smooth_key &v) const |
|
|
466 | { |
|
|
467 | return v.tile + (v.x << 8) + (v.y << 16) + (v.level << 24); |
|
|
468 | } |
|
|
469 | }; |
|
|
470 | } |
429 | |
471 | |
430 | static void |
472 | static void |
431 | smooth_or_bits (HV *hv, smooth_key *key, IV bits) |
473 | smooth_or_bits (smooth_hash &h, smooth_key &key, IV bits) |
432 | { |
474 | { |
433 | SV **sv = hv_fetch (hv, (char *)key, sizeof (*key), 1); |
475 | auto &&it = h.find (key); |
434 | |
476 | |
435 | if (SvIOK (*sv)) |
477 | if (it == h.end ()) |
436 | SvIV_set (*sv, SvIVX (*sv) | bits); |
478 | h.insert (std::make_pair (key, bits)); |
437 | else |
479 | else |
438 | sv_setiv (*sv, bits); |
480 | it->second |= bits; |
439 | } |
481 | } |
440 | |
482 | |
441 | static void |
483 | static void |
442 | music_finished (void) |
484 | music_finished (void) |
443 | { |
485 | { |
… | |
… | |
460 | ev.code = 1; |
502 | ev.code = 1; |
461 | ev.data1 = (void *)(long)channel; |
503 | ev.data1 = (void *)(long)channel; |
462 | ev.data2 = 0; |
504 | ev.data2 = 0; |
463 | |
505 | |
464 | SDL_PushEvent ((SDL_Event *)&ev); |
506 | SDL_PushEvent ((SDL_Event *)&ev); |
|
|
507 | } |
|
|
508 | |
|
|
509 | // approximately divide by 255 |
|
|
510 | static unsigned int |
|
|
511 | div255 (unsigned int n) |
|
|
512 | { |
|
|
513 | return (n + (n >> 8)) >> 8; |
465 | } |
514 | } |
466 | |
515 | |
467 | static unsigned int |
516 | static unsigned int |
468 | minpot (unsigned int n) |
517 | minpot (unsigned int n) |
469 | { |
518 | { |
… | |
… | |
552 | |
601 | |
553 | return mod; |
602 | return mod; |
554 | } |
603 | } |
555 | |
604 | |
556 | static void |
605 | static void |
557 | deliantra_main () |
606 | deliantra_main (SV *real_main) |
558 | { |
607 | { |
559 | char *argv[] = { 0 }; |
608 | dSP; |
560 | call_argv ("::main", G_DISCARD | G_VOID, argv); |
609 | |
|
|
610 | PUSHMARK (SP); |
|
|
611 | call_sv (real_main, G_DISCARD | G_VOID); |
561 | } |
612 | } |
562 | |
613 | |
563 | #ifdef __MACOSX__ |
614 | #ifdef __MACOSX__ |
|
|
615 | static SV *real_main; |
|
|
616 | |
564 | /* to due surprising braindamage on the side of SDL design, we |
617 | /* to due surprising braindamage on the side of SDL design, we |
565 | * do some mind-boggling hack here: SDL requires a custom main() |
618 | * 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, |
619 | * 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, |
620 | * due to shared library magic, calls -lSDLmain's main, not perl's main, |
568 | * and which calls our main (== SDL_main) back. |
621 | * and which calls our main (== SDL_main) back. |
569 | */ |
622 | */ |
570 | extern C_LINKAGE int |
623 | extern C_LINKAGE int |
571 | main (int argc, char *argv[]) |
624 | main (int argc, char *argv[]) |
572 | { |
625 | { |
573 | deliantra_main (); |
626 | deliantra_main (real_main); |
574 | } |
627 | } |
575 | |
628 | |
576 | #undef main |
629 | #undef main |
577 | |
630 | |
578 | extern C_LINKAGE int main (int argc, char *argv[]); |
631 | extern C_LINKAGE int main (int argc, char *argv[]); |
579 | |
632 | |
580 | static void |
633 | static void |
581 | SDL_braino (void) |
634 | SDL_main_hack (SV *real_main_) |
582 | { |
635 | { |
|
|
636 | real_main = real_main_; |
|
|
637 | |
583 | char *argv[] = { "deliantra client", 0 }; |
638 | char *argv[] = { "deliantra client", 0 }; |
584 | (main) (1, argv); |
639 | (main) (1, argv); |
585 | } |
640 | } |
586 | #else |
641 | #else |
587 | static void |
642 | static void |
588 | SDL_braino (void) |
643 | SDL_main_hack (SV *real_main) |
589 | { |
644 | { |
590 | deliantra_main (); |
645 | deliantra_main (real_main); |
591 | } |
646 | } |
592 | #endif |
647 | #endif |
593 | |
648 | |
594 | MODULE = Deliantra::Client PACKAGE = DC |
649 | MODULE = Deliantra::Client PACKAGE = DC |
595 | |
650 | |
… | |
… | |
796 | |
851 | |
797 | const_iv (FOW_DARKNESS) |
852 | const_iv (FOW_DARKNESS) |
798 | # undef const_iv |
853 | # undef const_iv |
799 | }; |
854 | }; |
800 | |
855 | |
801 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
856 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ > const_iv; civ--) |
802 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
857 | newCONSTSUB (stash, (char *)civ[-1].name, newSViv (civ[-1].iv)); |
803 | |
858 | |
804 | assert (SDLK_MODIFIER_MIN == SDLK_NUMLOCK); |
859 | assert (SDLK_MODIFIER_MIN == SDLK_NUMLOCK); |
805 | assert (SDLK_MODIFIER_MAX == SDLK_COMPOSE); |
860 | assert (SDLK_MODIFIER_MAX == SDLK_COMPOSE); |
806 | } |
861 | } |
807 | |
862 | |
… | |
… | |
846 | #endif |
901 | #endif |
847 | } |
902 | } |
848 | |
903 | |
849 | char *SDL_GetError () |
904 | char *SDL_GetError () |
850 | |
905 | |
851 | void SDL_braino () |
906 | void SDL_main_hack (SV *real_main) |
|
|
907 | PROTOTYPE: & |
852 | |
908 | |
853 | int SDL_Init (U32 flags) |
909 | int SDL_Init (U32 flags) |
854 | |
910 | |
855 | int SDL_InitSubSystem (U32 flags) |
911 | int SDL_InitSubSystem (U32 flags) |
856 | |
912 | |
857 | void SDL_QuitSubSystem (U32 flags) |
913 | void SDL_QuitSubSystem (U32 flags) |
858 | |
914 | |
859 | void SDL_Quit () |
915 | void SDL_Quit () |
860 | |
916 | |
861 | int SDL_GL_SetAttribute (int attr, int value) |
917 | int SDL_GL_SetAttribute (int attr, int value) |
|
|
918 | C_ARGS: (SDL_GLattr)attr, value |
862 | |
919 | |
863 | int SDL_GL_GetAttribute (int attr) |
920 | int SDL_GL_GetAttribute (int attr) |
864 | CODE: |
921 | CODE: |
865 | if (SDL_GL_GetAttribute (attr, &RETVAL)) |
922 | if (SDL_GL_GetAttribute ((SDL_GLattr)attr, &RETVAL)) |
866 | XSRETURN_UNDEF; |
923 | XSRETURN_UNDEF; |
867 | OUTPUT: |
924 | OUTPUT: |
868 | RETVAL |
925 | RETVAL |
869 | |
926 | |
870 | void |
927 | void |
… | |
… | |
925 | ); |
982 | ); |
926 | |
983 | |
927 | if (RETVAL) |
984 | if (RETVAL) |
928 | { |
985 | { |
929 | av_clear (texture_av); |
986 | 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); |
987 | #define GL_FUNC(ptr,name) gl.name = (ptr)SDL_GL_GetProcAddress ("gl" # name); |
933 | #include "glfunc.h" |
988 | #include "glfunc.h" |
934 | #undef GL_FUNC |
989 | #undef GL_FUNC |
935 | |
|
|
936 | if (!gl.ActiveTexture ) gl.ActiveTexture = gl.ActiveTextureARB; |
990 | if (!gl.ActiveTexture ) gl.ActiveTexture = gl.ActiveTextureARB; |
937 | if (!gl.MultiTexCoord2f) gl.MultiTexCoord2f = gl.MultiTexCoord2fARB; |
991 | if (!gl.MultiTexCoord2f) gl.MultiTexCoord2f = gl.MultiTexCoord2fARB; |
938 | } |
992 | } |
939 | } |
993 | } |
940 | OUTPUT: |
994 | OUTPUT: |
941 | RETVAL |
995 | RETVAL |
942 | |
996 | |
943 | void |
997 | void |
|
|
998 | SDL_WM_SetCaption (const char *title, const char *icon) |
|
|
999 | |
|
|
1000 | void |
944 | SDL_GL_SwapBuffers () |
1001 | SDL_GL_SwapBuffers () |
945 | |
1002 | |
946 | char * |
1003 | char * |
947 | SDL_GetKeyName (int sym) |
1004 | SDL_GetKeyName (int sym) |
|
|
1005 | C_ARGS: (SDLKey)sym |
948 | |
1006 | |
949 | int |
1007 | int |
950 | SDL_GetAppState () |
1008 | SDL_GetAppState () |
951 | |
1009 | |
952 | int |
1010 | int |
953 | SDL_GetModState () |
1011 | SDL_GetModState () |
954 | |
1012 | |
|
|
1013 | int |
|
|
1014 | SDL_WaitEvent () |
|
|
1015 | C_ARGS: 0 |
|
|
1016 | |
955 | void |
1017 | void |
|
|
1018 | SDL_PumpEvents () |
|
|
1019 | |
|
|
1020 | void |
956 | poll_events () |
1021 | peep_events () |
957 | PPCODE: |
1022 | PPCODE: |
958 | { |
1023 | { |
959 | SDL_Event ev; |
1024 | SDL_Event ev; |
960 | |
1025 | |
961 | SDL_PumpEvents (); |
1026 | SDL_PumpEvents (); |
… | |
… | |
1042 | OUTPUT: |
1107 | OUTPUT: |
1043 | RETVAL |
1108 | RETVAL |
1044 | |
1109 | |
1045 | int |
1110 | int |
1046 | Mix_OpenAudio (int frequency = 44100, int format = MIX_DEFAULT_FORMAT, int channels = 2, int chunksize = 4096) |
1111 | Mix_OpenAudio (int frequency = 44100, int format = MIX_DEFAULT_FORMAT, int channels = 2, int chunksize = 4096) |
1047 | POSTCALL: |
1112 | POSTCALL: |
1048 | Mix_HookMusicFinished (music_finished); |
1113 | Mix_HookMusicFinished (music_finished); |
1049 | Mix_ChannelFinished (channel_finished); |
1114 | Mix_ChannelFinished (channel_finished); |
1050 | |
1115 | |
1051 | void |
1116 | void |
1052 | Mix_QuerySpec () |
1117 | Mix_QuerySpec () |
… | |
… | |
1114 | OUTPUT: |
1179 | OUTPUT: |
1115 | RETVAL |
1180 | RETVAL |
1116 | |
1181 | |
1117 | void |
1182 | void |
1118 | IMG_Init (int flags = IMG_INIT_JPG | IMG_INIT_PNG) |
1183 | IMG_Init (int flags = IMG_INIT_JPG | IMG_INIT_PNG) |
|
|
1184 | |
|
|
1185 | # MIX_INIT_MP3 gives smpeg + libstdc++ + libgcc_s |
|
|
1186 | void |
|
|
1187 | Mix_Init (int flags = MIX_INIT_MOD | MIX_INIT_OGG) |
1119 | |
1188 | |
1120 | void |
1189 | void |
1121 | load_image_inline (SV *image_) |
1190 | load_image_inline (SV *image_) |
1122 | ALIAS: |
1191 | ALIAS: |
1123 | load_image_file = 1 |
1192 | load_image_file = 1 |
… | |
… | |
1169 | |
1238 | |
1170 | SDL_LockSurface (surface2); |
1239 | SDL_LockSurface (surface2); |
1171 | EXTEND (SP, 6); |
1240 | EXTEND (SP, 6); |
1172 | PUSHs (sv_2mortal (newSViv (surface2->w))); |
1241 | PUSHs (sv_2mortal (newSViv (surface2->w))); |
1173 | PUSHs (sv_2mortal (newSViv (surface2->h))); |
1242 | PUSHs (sv_2mortal (newSViv (surface2->h))); |
1174 | PUSHs (sv_2mortal (newSVpvn (surface2->pixels, surface2->h * surface2->pitch))); |
1243 | PUSHs (sv_2mortal (newSVpvn ((const char *)surface2->pixels, surface2->h * surface2->pitch))); |
1175 | PUSHs (sv_2mortal (newSViv (surface->flags & (SDL_SRCCOLORKEY | SDL_SRCALPHA) ? GL_RGBA : GL_RGB))); |
1244 | PUSHs (sv_2mortal (newSViv (surface->flags & (SDL_SRCCOLORKEY | SDL_SRCALPHA) ? GL_RGBA : GL_RGB))); |
1176 | PUSHs (sv_2mortal (newSViv (GL_RGBA))); |
1245 | PUSHs (sv_2mortal (newSViv (GL_RGBA))); |
1177 | PUSHs (sv_2mortal (newSViv (GL_UNSIGNED_BYTE))); |
1246 | PUSHs (sv_2mortal (newSViv (GL_UNSIGNED_BYTE))); |
1178 | SDL_UnlockSurface (surface2); |
1247 | SDL_UnlockSurface (surface2); |
1179 | |
1248 | |
… | |
… | |
1251 | MODULE = Deliantra::Client PACKAGE = DC::Font |
1320 | MODULE = Deliantra::Client PACKAGE = DC::Font |
1252 | |
1321 | |
1253 | PROTOTYPES: DISABLE |
1322 | PROTOTYPES: DISABLE |
1254 | |
1323 | |
1255 | DC::Font |
1324 | DC::Font |
1256 | new_from_file (SV *class, char *path, int id = 0) |
1325 | new_from_file (SV *klass, char *path, int id = 0) |
1257 | CODE: |
1326 | CODE: |
1258 | { |
1327 | { |
1259 | int count; |
1328 | int count; |
1260 | FcPattern *pattern = FcFreeTypeQuery ((const FcChar8 *)path, id, 0, &count); |
1329 | FcPattern *pattern = FcFreeTypeQuery ((const FcChar8 *)path, id, 0, &count); |
1261 | RETVAL = pango_fc_font_description_from_pattern (pattern, 0); |
1330 | RETVAL = pango_fc_font_description_from_pattern (pattern, 0); |
… | |
… | |
1290 | PROTOTYPE: |
1359 | PROTOTYPE: |
1291 | CODE: |
1360 | CODE: |
1292 | tc_restore (); |
1361 | tc_restore (); |
1293 | |
1362 | |
1294 | DC::Layout |
1363 | DC::Layout |
1295 | new (SV *class) |
1364 | new (SV *klass) |
1296 | CODE: |
1365 | CODE: |
1297 | New (0, RETVAL, 1, struct cf_layout); |
1366 | New (0, RETVAL, 1, struct cf_layout); |
1298 | |
1367 | |
1299 | RETVAL->pl = pango_layout_new (opengl_context); |
1368 | RETVAL->pl = pango_layout_new (opengl_context); |
1300 | RETVAL->r = 1.; |
1369 | RETVAL->r = 1.; |
… | |
… | |
1449 | |
1518 | |
1450 | void |
1519 | void |
1451 | set_height (DC::Layout self, int base_height) |
1520 | set_height (DC::Layout self, int base_height) |
1452 | CODE: |
1521 | CODE: |
1453 | if (self->base_height != base_height) |
1522 | if (self->base_height != base_height) |
1454 | { |
1523 | { |
1455 | self->base_height = base_height; |
1524 | self->base_height = base_height; |
1456 | layout_update_font (self); |
1525 | layout_update_font (self); |
1457 | } |
1526 | } |
1458 | |
1527 | |
1459 | void |
1528 | void |
… | |
… | |
1823 | MODULE = Deliantra::Client PACKAGE = DC::Map |
1892 | MODULE = Deliantra::Client PACKAGE = DC::Map |
1824 | |
1893 | |
1825 | PROTOTYPES: DISABLE |
1894 | PROTOTYPES: DISABLE |
1826 | |
1895 | |
1827 | DC::Map |
1896 | DC::Map |
1828 | new (SV *class) |
1897 | new (SV *klass) |
1829 | CODE: |
1898 | CODE: |
1830 | New (0, RETVAL, 1, struct map); |
1899 | New (0, RETVAL, 1, struct map); |
1831 | RETVAL->x = 0; |
1900 | RETVAL->x = 0; |
1832 | RETVAL->y = 0; |
1901 | RETVAL->y = 0; |
1833 | RETVAL->w = 0; |
1902 | RETVAL->w = 0; |
… | |
… | |
1872 | |
1941 | |
1873 | void |
1942 | void |
1874 | set_smooth (DC::Map self, int face, int smooth, int level) |
1943 | set_smooth (DC::Map self, int face, int smooth, int level) |
1875 | CODE: |
1944 | CODE: |
1876 | { |
1945 | { |
1877 | tileid texid; |
1946 | tileid texid; |
1878 | maptex *tex; |
1947 | maptex *tex; |
1879 | |
1948 | |
1880 | if (face < 0 || face >= self->faces) |
1949 | if (face < 0 || face >= self->faces) |
1881 | return; |
1950 | return; |
1882 | |
1951 | |
1883 | if (smooth < 0 || smooth >= self->faces) |
1952 | if (smooth < 0 || smooth >= self->faces) |
1884 | return; |
1953 | return; |
1885 | |
1954 | |
1886 | texid = self->face2tile [face]; |
1955 | texid = self->face2tile [face]; |
1887 | |
1956 | |
1888 | if (!texid) |
1957 | if (!texid) |
1889 | return; |
1958 | return; |
1890 | |
1959 | |
1891 | tex = self->tex + texid; |
1960 | tex = self->tex + texid; |
… | |
… | |
1924 | } |
1993 | } |
1925 | |
1994 | |
1926 | void |
1995 | void |
1927 | expire_textures (DC::Map self, int texid, int count) |
1996 | expire_textures (DC::Map self, int texid, int count) |
1928 | PPCODE: |
1997 | PPCODE: |
1929 | for (; texid < self->texs && count; ++texid, --count) |
1998 | for (; texid < self->texs && count; ++texid, --count) |
1930 | { |
1999 | { |
1931 | maptex *tex = self->tex + texid; |
2000 | maptex *tex = self->tex + texid; |
1932 | |
2001 | |
1933 | if (tex->name) |
2002 | if (tex->name) |
1934 | { |
2003 | { |
… | |
… | |
1989 | self->y += MAP_EXTEND_Y; |
2058 | self->y += MAP_EXTEND_Y; |
1990 | } |
2059 | } |
1991 | } |
2060 | } |
1992 | |
2061 | |
1993 | SV * |
2062 | SV * |
1994 | map1a_update (DC::Map self, SV *data_, int extmap) |
2063 | map1a_update (DC::Map self, SV *data_) |
1995 | CODE: |
2064 | CODE: |
1996 | { |
2065 | { |
1997 | uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_); |
2066 | uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_); |
1998 | uint8_t *data_end = (uint8_t *)SvEND (data_); |
2067 | uint8_t *data_end = (uint8_t *)SvEND (data_); |
1999 | mapcell *cell; |
2068 | mapcell *cell; |
… | |
… | |
2020 | |
2089 | |
2021 | //TODO: don't trust server data to be in-range(!) |
2090 | //TODO: don't trust server data to be in-range(!) |
2022 | |
2091 | |
2023 | if (flags & 8) |
2092 | if (flags & 8) |
2024 | { |
2093 | { |
|
|
2094 | uint8_t ext, cmd; |
|
|
2095 | |
2025 | if (extmap) |
2096 | do |
2026 | { |
2097 | { |
2027 | uint8_t ext, cmd; |
2098 | ext = *data++; |
|
|
2099 | cmd = ext & 0x7f; |
2028 | |
2100 | |
2029 | do |
2101 | if (cmd < 4) |
|
|
2102 | cell->darkness = 255 - ext * 64 + 1; /* make sure this doesn't collide with FOW_DARKNESS */ |
|
|
2103 | else if (cmd == 5) // health |
2030 | { |
2104 | { |
2031 | ext = *data++; |
|
|
2032 | cmd = ext & 0x7f; |
|
|
2033 | |
|
|
2034 | if (cmd < 4) |
|
|
2035 | cell->darkness = 255 - ext * 64 + 1; /* make sure this doesn't collide with FOW_DARKNESS */ |
|
|
2036 | else if (cmd == 5) // health |
|
|
2037 | { |
|
|
2038 | cell->stat_width = 1; |
2105 | cell->stat_width = 1; |
2039 | cell->stat_hp = *data++; |
2106 | cell->stat_hp = *data++; |
2040 | } |
|
|
2041 | else if (cmd == 6) // monster width |
|
|
2042 | cell->stat_width = *data++ + 1; |
|
|
2043 | else if (cmd == 0x47) |
|
|
2044 | { |
|
|
2045 | if (*data == 1) cell->player = data [1]; |
|
|
2046 | else if (*data == 2) cell->player = data [2] + (data [1] << 8); |
|
|
2047 | else if (*data == 3) cell->player = data [3] + (data [2] << 8) + (data [1] << 16); |
|
|
2048 | else if (*data == 4) cell->player = data [4] + (data [3] << 8) + (data [2] << 16) + (data [1] << 24); |
|
|
2049 | |
|
|
2050 | data += *data + 1; |
|
|
2051 | } |
|
|
2052 | else if (cmd == 8) // cell flags |
|
|
2053 | cell->flags = *data++; |
|
|
2054 | else if (ext & 0x40) // unknown, multibyte => skip |
|
|
2055 | data += *data + 1; |
|
|
2056 | else |
|
|
2057 | data++; |
|
|
2058 | } |
2107 | } |
2059 | while (ext & 0x80); |
2108 | else if (cmd == 6) // monster width |
|
|
2109 | cell->stat_width = *data++ + 1; |
|
|
2110 | else if (cmd == 0x47) |
|
|
2111 | { |
|
|
2112 | if (*data == 1) cell->player = data [1]; |
|
|
2113 | else if (*data == 2) cell->player = data [2] + (data [1] << 8); |
|
|
2114 | else if (*data == 3) cell->player = data [3] + (data [2] << 8) + (data [1] << 16); |
|
|
2115 | else if (*data == 4) cell->player = data [4] + (data [3] << 8) + (data [2] << 16) + (data [1] << 24); |
|
|
2116 | |
|
|
2117 | data += *data + 1; |
|
|
2118 | } |
|
|
2119 | else if (cmd == 8) // cell flags |
|
|
2120 | cell->flags = *data++; |
|
|
2121 | else if (ext & 0x40) // unknown, multibyte => skip |
|
|
2122 | data += *data + 1; |
|
|
2123 | else |
|
|
2124 | data++; |
2060 | } |
2125 | } |
2061 | else |
2126 | while (ext & 0x80); |
2062 | cell->darkness = *data++ + 1; |
|
|
2063 | } |
2127 | } |
2064 | |
2128 | |
2065 | for (z = 0; z <= 2; ++z) |
2129 | for (z = 0; z <= 2; ++z) |
2066 | if (flags & (4 >> z)) |
2130 | if (flags & (4 >> z)) |
2067 | { |
2131 | { |
… | |
… | |
2115 | ? self->row + y |
2179 | ? self->row + y |
2116 | : 0; |
2180 | : 0; |
2117 | |
2181 | |
2118 | for (x = x0; x < x1; x++) |
2182 | for (x = x0; x < x1; x++) |
2119 | { |
2183 | { |
2120 | int r = 32, g = 32, b = 32, a = 192; |
2184 | unsigned int r = 32, g = 32, b = 32, a = 192; |
2121 | |
2185 | |
2122 | if (row && row->c0 <= x && x < row->c1) |
2186 | if (row && row->c0 <= x && x < row->c1) |
2123 | { |
2187 | { |
2124 | mapcell *cell = row->col + (x - row->c0); |
2188 | mapcell *cell = row->col + (x - row->c0); |
2125 | |
2189 | |
… | |
… | |
2127 | { |
2191 | { |
2128 | maptex tex = self->tex [cell->tile [z]]; |
2192 | maptex tex = self->tex [cell->tile [z]]; |
2129 | int a0 = 255 - tex.a; |
2193 | int a0 = 255 - tex.a; |
2130 | int a1 = tex.a; |
2194 | int a1 = tex.a; |
2131 | |
2195 | |
2132 | r = (r * a0 + tex.r * a1) / 255; |
2196 | r = div255 (r * a0 + tex.r * a1); |
2133 | g = (g * a0 + tex.g * a1) / 255; |
2197 | g = div255 (g * a0 + tex.g * a1); |
2134 | b = (b * a0 + tex.b * a1) / 255; |
2198 | b = div255 (b * a0 + tex.b * a1); |
2135 | a = (a * a0 + tex.a * a1) / 255; |
2199 | a = div255 (a * a0 + tex.a * a1); |
2136 | } |
2200 | } |
2137 | } |
2201 | } |
2138 | |
2202 | |
2139 | *map++ = (r ) |
2203 | *map++ = (r ) |
2140 | | (g << 8) |
2204 | | (g << 8) |
2141 | | (b << 16) |
2205 | | (b << 16) |
2142 | | (a << 24); |
2206 | | (a << 24); |
2143 | } |
2207 | } |
2144 | } |
2208 | } |
2145 | |
2209 | |
2146 | RETVAL = map_sv; |
2210 | RETVAL = map_sv; |
2147 | } |
2211 | } |
2148 | OUTPUT: |
2212 | OUTPUT: |
2149 | RETVAL |
2213 | RETVAL |
2150 | |
2214 | |
2151 | void |
2215 | void |
2152 | draw (DC::Map self, int mx, int my, int sw, int sh, int T, U32 player = 0xffffffff, int sdx = 0, int sdy = 0) |
2216 | 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) |
2153 | CODE: |
2217 | CODE: |
2154 | { |
2218 | { |
2155 | int x, y, z; |
2219 | int x, y, z; |
2156 | |
2220 | |
2157 | HV *smooth = (HV *)sv_2mortal ((SV *)newHV ()); |
|
|
2158 | uint32_t smooth_level[256 / 32]; // one bit for every possible smooth level |
2221 | uint32_t smooth_level[256 / 32]; // one bit for every possible smooth level |
2159 | static uint8_t smooth_max[256][256]; // egad, fast and wasteful on memory (64k) |
2222 | static uint8_t smooth_max[256][256]; // egad, fast and wasteful on memory (64k) |
2160 | smooth_key skey; |
2223 | smooth_key skey; |
2161 | int pl_x, pl_y; |
2224 | int pl_x, pl_y; |
2162 | maptex pl_tex; |
2225 | maptex pl_tex; |
… | |
… | |
2211 | glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
2274 | glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
2212 | glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); |
2275 | glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); |
2213 | |
2276 | |
2214 | for (z = 0; z <= 2; z++) |
2277 | for (z = 0; z <= 2; z++) |
2215 | { |
2278 | { |
|
|
2279 | smooth_hash smooth; |
2216 | memset (smooth_level, 0, sizeof (smooth_level)); |
2280 | memset (smooth_level, 0, sizeof (smooth_level)); |
2217 | key.texname = -1; |
2281 | key.texname = -1; |
2218 | |
2282 | |
2219 | for (y = 0; y < sh; y++) |
2283 | for (y = 0; y < sh; y++) |
2220 | if (0 <= y + my && y + my < self->rows) |
2284 | if (0 <= y + my && y + my < self->rows) |
… | |
… | |
2241 | |
2305 | |
2242 | key.texname = tex.name; |
2306 | key.texname = tex.name; |
2243 | arr = rc_array (rc, &key); |
2307 | arr = rc_array (rc, &key); |
2244 | } |
2308 | } |
2245 | |
2309 | |
2246 | px = (x + 1) * T - tex.w; |
2310 | px = (x + 1) * Th - tex.w; |
2247 | py = (y + 1) * T - tex.h; |
2311 | py = (y + 1) * Tw - tex.h; |
2248 | |
2312 | |
2249 | if (expect_false (cell->player == player) && expect_false (z == 2)) |
2313 | if (expect_false (cell->player == player) && expect_false (z == 2)) |
2250 | { |
2314 | { |
2251 | pl_x = px; |
2315 | pl_x = px; |
2252 | pl_y = py; |
2316 | pl_y = py; |
… | |
… | |
2281 | |
2345 | |
2282 | // corners: 1 ┛· 2 ·┗ 4 ·· 8 ·· |
2346 | // corners: 1 ┛· 2 ·┗ 4 ·· 8 ·· |
2283 | // ·· ·· ·┏ ┓· |
2347 | // ·· ·· ·┏ ┓· |
2284 | |
2348 | |
2285 | // full tile |
2349 | // full tile |
2286 | skey.x = x + 1; skey.y = y + 1; smooth_or_bits (smooth, &skey, 0x1000); |
2350 | skey.x = x + 1; skey.y = y + 1; smooth_or_bits (smooth, skey, 0x1000); |
2287 | |
2351 | |
2288 | // borders |
2352 | // borders |
2289 | skey.x = x + 2; skey.y = y + 1; smooth_or_bits (smooth, &skey, 0x0091); |
2353 | skey.x = x + 2; skey.y = y + 1; smooth_or_bits (smooth, skey, 0x0091); |
2290 | skey.x = x + 1; skey.y = y + 2; smooth_or_bits (smooth, &skey, 0x0032); |
2354 | skey.x = x + 1; skey.y = y + 2; smooth_or_bits (smooth, skey, 0x0032); |
2291 | skey.x = x ; skey.y = y + 1; smooth_or_bits (smooth, &skey, 0x0064); |
2355 | skey.x = x ; skey.y = y + 1; smooth_or_bits (smooth, skey, 0x0064); |
2292 | skey.x = x + 1; skey.y = y ; smooth_or_bits (smooth, &skey, 0x00c8); |
2356 | skey.x = x + 1; skey.y = y ; smooth_or_bits (smooth, skey, 0x00c8); |
2293 | |
2357 | |
2294 | // corners |
2358 | // corners |
2295 | skey.x = x + 2; skey.y = y + 2; smooth_or_bits (smooth, &skey, 0x0100); |
2359 | skey.x = x + 2; skey.y = y + 2; smooth_or_bits (smooth, skey, 0x0100); |
2296 | skey.x = x ; skey.y = y + 2; smooth_or_bits (smooth, &skey, 0x0200); |
2360 | skey.x = x ; skey.y = y + 2; smooth_or_bits (smooth, skey, 0x0200); |
2297 | skey.x = x ; skey.y = y ; smooth_or_bits (smooth, &skey, 0x0400); |
2361 | skey.x = x ; skey.y = y ; smooth_or_bits (smooth, skey, 0x0400); |
2298 | skey.x = x + 2; skey.y = y ; smooth_or_bits (smooth, &skey, 0x0800); |
2362 | skey.x = x + 2; skey.y = y ; smooth_or_bits (smooth, skey, 0x0800); |
2299 | } |
2363 | } |
2300 | } |
2364 | } |
2301 | |
2365 | |
2302 | if (expect_false (z == 2) && expect_false (cell->flags)) |
2366 | if (expect_false (z == 2) && expect_false (cell->flags)) |
2303 | { |
2367 | { |
… | |
… | |
2305 | if (cell->flags & 1) |
2369 | if (cell->flags & 1) |
2306 | { |
2370 | { |
2307 | rc_key_t key_ov = key; |
2371 | rc_key_t key_ov = key; |
2308 | maptex tex = self->tex [TEXID_SPEECH]; |
2372 | maptex tex = self->tex [TEXID_SPEECH]; |
2309 | rc_array_t *arr; |
2373 | rc_array_t *arr; |
2310 | int px = x * T + T * 2 / 32; |
2374 | int px = x * Tw + Tw * 2 / 32; |
2311 | int py = y * T - T * 6 / 32; |
2375 | int py = y * Th - Th * 6 / 32; |
2312 | |
2376 | |
2313 | key_ov.texname = tex.name; |
2377 | key_ov.texname = tex.name; |
2314 | arr = rc_array (rc_ov, &key_ov); |
2378 | arr = rc_array (rc_ov, &key_ov); |
2315 | |
2379 | |
2316 | rc_t2f_v3f (arr, 0 , 0 , px , py , 0); |
2380 | rc_t2f_v3f (arr, 0 , 0 , px , py , 0); |
2317 | rc_t2f_v3f (arr, 0 , tex.t, px , py + T, 0); |
2381 | rc_t2f_v3f (arr, 0 , tex.t, px , py + Th, 0); |
2318 | rc_t2f_v3f (arr, tex.s, tex.t, px + T, py + T, 0); |
2382 | rc_t2f_v3f (arr, tex.s, tex.t, px + Tw, py + Th, 0); |
2319 | rc_t2f_v3f (arr, tex.s, 0 , px + T, py , 0); |
2383 | rc_t2f_v3f (arr, tex.s, 0 , px + Tw, py , 0); |
2320 | } |
2384 | } |
2321 | } |
2385 | } |
2322 | } |
2386 | } |
2323 | } |
2387 | } |
2324 | |
2388 | |
… | |
… | |
2340 | if (smask & (((uint32_t)1) << b)) |
2404 | if (smask & (((uint32_t)1) << b)) |
2341 | { |
2405 | { |
2342 | int level = (w << 5) | b; |
2406 | int level = (w << 5) | b; |
2343 | HE *he; |
2407 | HE *he; |
2344 | |
2408 | |
2345 | hv_iterinit (smooth); |
2409 | for (auto &&it = smooth.begin (); it != smooth.end (); ++it) |
2346 | while ((he = hv_iternext (smooth))) |
|
|
2347 | { |
2410 | { |
2348 | smooth_key *skey = (smooth_key *)HeKEY (he); |
2411 | smooth_key &skey = it->first; |
2349 | IV bits = SvIVX (HeVAL (he)); |
2412 | IV bits = it->second; |
2350 | |
2413 | |
2351 | if (!(bits & 0x1000) |
2414 | if (!(bits & 0x1000) |
2352 | && skey->level == level |
2415 | && skey.level == level |
2353 | && level > smooth_max [skey->x][skey->y]) |
2416 | && level > smooth_max [skey.x][skey.y]) |
2354 | { |
2417 | { |
2355 | maptex tex = self->tex [skey->tile]; |
2418 | maptex tex = self->tex [skey.tile]; |
2356 | int px = (((int)skey->x) - 1) * T; |
2419 | int px = (((int)skey.x) - 1) * Tw; |
2357 | int py = (((int)skey->y) - 1) * T; |
2420 | int py = (((int)skey.y) - 1) * Th; |
2358 | int border = bits & 15; |
2421 | int border = bits & 15; |
2359 | int corner = (bits >> 8) & ~(bits >> 4) & 15; |
2422 | int corner = (bits >> 8) & ~(bits >> 4) & 15; |
2360 | float dx = tex.s * .0625f; // 16 images/row |
2423 | float dx = tex.s * .0625f; // 16 images/row |
2361 | float dy = tex.t * .5f ; // 2 images/column |
2424 | float dy = tex.t * .5f ; // 2 images/column |
2362 | |
2425 | |
… | |
… | |
2364 | { |
2427 | { |
2365 | // this time avoiding texture state changes |
2428 | // this time avoiding texture state changes |
2366 | // save gobs of state changes. |
2429 | // save gobs of state changes. |
2367 | if (key.texname != tex.name) |
2430 | if (key.texname != tex.name) |
2368 | { |
2431 | { |
2369 | self->tex [skey->tile].unused = 0; |
2432 | self->tex [skey.tile].unused = 0; |
2370 | |
2433 | |
2371 | glEnd (); |
2434 | glEnd (); |
2372 | glBindTexture (GL_TEXTURE_2D, key.texname = tex.name); |
2435 | glBindTexture (GL_TEXTURE_2D, key.texname = tex.name); |
2373 | glBegin (GL_QUADS); |
2436 | glBegin (GL_QUADS); |
2374 | } |
2437 | } |
2375 | |
2438 | |
2376 | if (border) |
2439 | if (border) |
2377 | { |
2440 | { |
2378 | float ox = border * dx; |
2441 | float ox = border * dx; |
2379 | |
2442 | |
2380 | glTexCoord2f (ox , 0.f ); glVertex2i (px , py ); |
2443 | glTexCoord2f (ox , 0.f ); glVertex2i (px , py ); |
2381 | glTexCoord2f (ox , dy ); glVertex2i (px , py + T); |
2444 | glTexCoord2f (ox , dy ); glVertex2i (px , py + Th); |
2382 | glTexCoord2f (ox + dx, dy ); glVertex2i (px + T, py + T); |
2445 | glTexCoord2f (ox + dx, dy ); glVertex2i (px + Tw, py + Th); |
2383 | glTexCoord2f (ox + dx, 0.f ); glVertex2i (px + T, py ); |
2446 | glTexCoord2f (ox + dx, 0.f ); glVertex2i (px + Tw, py ); |
2384 | } |
2447 | } |
2385 | |
2448 | |
2386 | if (corner) |
2449 | if (corner) |
2387 | { |
2450 | { |
2388 | float ox = corner * dx; |
2451 | float ox = corner * dx; |
2389 | |
2452 | |
2390 | glTexCoord2f (ox , dy ); glVertex2i (px , py ); |
2453 | glTexCoord2f (ox , dy ); glVertex2i (px , py ); |
2391 | glTexCoord2f (ox , dy * 2.f); glVertex2i (px , py + T); |
2454 | glTexCoord2f (ox , dy * 2.f); glVertex2i (px , py + Th); |
2392 | glTexCoord2f (ox + dx, dy * 2.f); glVertex2i (px + T, py + T); |
2455 | glTexCoord2f (ox + dx, dy * 2.f); glVertex2i (px + Tw, py + Th); |
2393 | glTexCoord2f (ox + dx, dy ); glVertex2i (px + T, py ); |
2456 | glTexCoord2f (ox + dx, dy ); glVertex2i (px + Tw, py ); |
2394 | } |
2457 | } |
2395 | } |
2458 | } |
2396 | } |
2459 | } |
2397 | } |
2460 | } |
2398 | } |
2461 | } |
… | |
… | |
2400 | |
2463 | |
2401 | glEnd (); |
2464 | glEnd (); |
2402 | glDisable (GL_TEXTURE_2D); |
2465 | glDisable (GL_TEXTURE_2D); |
2403 | key.texname = -1; |
2466 | key.texname = -1; |
2404 | } |
2467 | } |
2405 | |
|
|
2406 | hv_clear (smooth); |
|
|
2407 | } |
2468 | } |
2408 | |
2469 | |
2409 | if (pl_tex.name) |
2470 | if (pl_tex.name) |
2410 | { |
2471 | { |
2411 | maptex tex = pl_tex; |
2472 | maptex tex = pl_tex; |
… | |
… | |
2439 | for (x = 0; x < sw; x++) |
2500 | for (x = 0; x < sw; x++) |
2440 | if (row->c0 <= x + mx && x + mx < row->c1) |
2501 | if (row->c0 <= x + mx && x + mx < row->c1) |
2441 | { |
2502 | { |
2442 | mapcell *cell = row->col + (x + mx - row->c0); |
2503 | mapcell *cell = row->col + (x + mx - row->c0); |
2443 | |
2504 | |
2444 | int px = x * T; |
2505 | int px = x * Tw; |
2445 | int py = y * T; |
2506 | int py = y * Th; |
2446 | |
2507 | |
2447 | if (expect_false (cell->player == player)) |
2508 | if (expect_false (cell->player == player)) |
2448 | { |
2509 | { |
2449 | px += sdx; |
2510 | px += sdx; |
2450 | py += sdy; |
2511 | py += sdy; |
2451 | } |
2512 | } |
2452 | |
2513 | |
2453 | if (cell->stat_hp) |
2514 | if (cell->stat_hp) |
2454 | { |
2515 | { |
2455 | int width = cell->stat_width * T; |
2516 | int width = cell->stat_width * Tw; |
2456 | int thick = (sh * T / 32 + 27) / 28 + 1 + cell->stat_width; |
2517 | int thick = (sh * Th / 32 + 27) / 28 + 1 + cell->stat_width; |
2457 | |
2518 | |
2458 | glColor3ub (0, 0, 0); |
2519 | glColor3ub (0, 0, 0); |
2459 | glRectf (px + 1, py - thick - 2, |
2520 | glRectf (px + 1, py - thick - 2, |
2460 | px + width - 1, py); |
2521 | px + width - 1, py); |
2461 | |
2522 | |
… | |
… | |
2541 | int x, y; |
2602 | int x, y; |
2542 | int sw1 = sw + 2; |
2603 | int sw1 = sw + 2; |
2543 | int sh1 = sh + 2; |
2604 | int sh1 = sh + 2; |
2544 | int sh3 = sh * 3; |
2605 | int sh3 = sh * 3; |
2545 | int sw3 = sw * 3; |
2606 | int sw3 = sw * 3; |
2546 | uint8_t *darkness1 = (uint8_t *)malloc (sw1 * sh1); |
|
|
2547 | SV *darkness3_sv = sv_2mortal (newSV (sw3 * sh3)); |
2607 | SV *darkness3_sv = sv_2mortal (newSV (sw3 * sh3)); |
2548 | uint8_t *darkness3 = (uint8_t *)SvPVX (darkness3_sv); |
2608 | uint8_t *darkness3 = (uint8_t *)SvPVX (darkness3_sv); |
|
|
2609 | uint8_t *darkness1 = (uint8_t *)malloc (sw1 * sh1); |
|
|
2610 | memset (darkness1, 0, sw1*sh1); |
2549 | |
2611 | |
2550 | SvPOK_only (darkness3_sv); |
2612 | SvPOK_only (darkness3_sv); |
2551 | SvCUR_set (darkness3_sv, sw3 * sh3); |
2613 | SvCUR_set (darkness3_sv, sw3 * sh3); |
2552 | |
2614 | |
2553 | mx += self->x - 1; |
2615 | mx += self->x - 1; |
… | |
… | |
2679 | else |
2741 | else |
2680 | *data++ = 0; |
2742 | *data++ = 0; |
2681 | } |
2743 | } |
2682 | } |
2744 | } |
2683 | |
2745 | |
2684 | /* if size is w*h + 5 then no data has been found */ |
2746 | /* if size is w*h + 5 then no data has been found */ |
2685 | if (data - (uint8_t *)SvPVX (data_sv) != w * h + 5) |
2747 | if (data - (uint8_t *)SvPVX (data_sv) != w * h + 5) |
2686 | { |
2748 | { |
2687 | SvPOK_only (data_sv); |
2749 | SvPOK_only (data_sv); |
2688 | SvCUR_set (data_sv, data - (uint8_t *)SvPVX (data_sv)); |
2750 | SvCUR_set (data_sv, data - (uint8_t *)SvPVX (data_sv)); |
2689 | } |
2751 | } |
2690 | |
2752 | |
2691 | RETVAL = data_sv; |
2753 | RETVAL = data_sv; |
2692 | } |
2754 | } |
2693 | OUTPUT: |
2755 | OUTPUT: |
2694 | RETVAL |
2756 | RETVAL |
2695 | |
2757 | |
2696 | void |
2758 | void |
… | |
… | |
2703 | STRLEN len; |
2765 | STRLEN len; |
2704 | uint8_t *data, *end; |
2766 | uint8_t *data, *end; |
2705 | |
2767 | |
2706 | len = SvLEN (data_sv); |
2768 | len = SvLEN (data_sv); |
2707 | SvGROW (data_sv, len + 8); // reserve at least 7+ bytes more |
2769 | SvGROW (data_sv, len + 8); // reserve at least 7+ bytes more |
2708 | data = SvPVbyte_nolen (data_sv); |
2770 | data = (uint8_t *)SvPVbyte_nolen (data_sv); |
2709 | end = data + len + 8; |
2771 | end = data + len + 8; |
2710 | |
2772 | |
2711 | if (len < 5) |
2773 | if (len < 5) |
2712 | XSRETURN_EMPTY; |
2774 | XSRETURN_EMPTY; |
2713 | |
2775 | |
… | |
… | |
2774 | } |
2836 | } |
2775 | |
2837 | |
2776 | MODULE = Deliantra::Client PACKAGE = DC::RW |
2838 | MODULE = Deliantra::Client PACKAGE = DC::RW |
2777 | |
2839 | |
2778 | DC::RW |
2840 | DC::RW |
2779 | new (SV *class, SV *data_sv) |
2841 | new (SV *klass, SV *data_sv) |
2780 | CODE: |
2842 | CODE: |
2781 | { |
2843 | { |
2782 | STRLEN datalen; |
2844 | STRLEN datalen; |
2783 | char *data = SvPVbyte (data_sv, datalen); |
2845 | char *data = SvPVbyte (data_sv, datalen); |
2784 | |
2846 | |
… | |
… | |
2786 | } |
2848 | } |
2787 | OUTPUT: |
2849 | OUTPUT: |
2788 | RETVAL |
2850 | RETVAL |
2789 | |
2851 | |
2790 | DC::RW |
2852 | DC::RW |
2791 | new_from_file (SV *class, const char *path, const char *mode = "rb") |
2853 | new_from_file (SV *klass, const char *path, const char *mode = "rb") |
2792 | CODE: |
2854 | CODE: |
2793 | RETVAL = SDL_RWFromFile (path, mode); |
2855 | RETVAL = SDL_RWFromFile (path, mode); |
2794 | OUTPUT: |
2856 | OUTPUT: |
2795 | RETVAL |
2857 | RETVAL |
2796 | |
2858 | |
… | |
… | |
2905 | #else |
2967 | #else |
2906 | XPUSHs (sv_2mortal (newSVpv ("(sdl mixer too old)", 0))); |
2968 | XPUSHs (sv_2mortal (newSVpv ("(sdl mixer too old)", 0))); |
2907 | #endif |
2969 | #endif |
2908 | |
2970 | |
2909 | DC::MixChunk |
2971 | DC::MixChunk |
2910 | new (SV *class, DC::RW rwops) |
2972 | new (SV *klass, DC::RW rwops) |
2911 | CODE: |
2973 | CODE: |
2912 | RETVAL = Mix_LoadWAV_RW (rwops, 1); |
2974 | RETVAL = Mix_LoadWAV_RW (rwops, 1); |
2913 | OUTPUT: |
2975 | OUTPUT: |
2914 | RETVAL |
2976 | RETVAL |
2915 | |
2977 | |
… | |
… | |
2985 | RETVAL = Mix_PlayingMusic (); |
3047 | RETVAL = Mix_PlayingMusic (); |
2986 | OUTPUT: |
3048 | OUTPUT: |
2987 | RETVAL |
3049 | RETVAL |
2988 | |
3050 | |
2989 | DC::MixMusic |
3051 | DC::MixMusic |
2990 | new (SV *class, DC::RW rwops) |
3052 | new (SV *klass, DC::RW rwops) |
2991 | CODE: |
3053 | CODE: |
2992 | RETVAL = Mix_LoadMUS_RW (rwops); |
3054 | RETVAL = Mix_LoadMUS_RW (rwops); |
2993 | OUTPUT: |
3055 | OUTPUT: |
2994 | RETVAL |
3056 | RETVAL |
2995 | |
3057 | |
… | |
… | |
3132 | const_iv (GL_FUNC_SUBTRACT), |
3194 | const_iv (GL_FUNC_SUBTRACT), |
3133 | const_iv (GL_FUNC_REVERSE_SUBTRACT), |
3195 | const_iv (GL_FUNC_REVERSE_SUBTRACT), |
3134 | # undef const_iv |
3196 | # undef const_iv |
3135 | }; |
3197 | }; |
3136 | |
3198 | |
3137 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
3199 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ > const_iv; civ--) |
3138 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
3200 | newCONSTSUB (stash, (char *)civ[-1].name, newSViv (civ[-1].iv)); |
3139 | |
3201 | |
3140 | texture_av = newAV (); |
3202 | texture_av = newAV (); |
3141 | AvREAL_off (texture_av); |
3203 | AvREAL_off (texture_av); |
3142 | } |
3204 | } |
3143 | |
3205 | |
… | |
… | |
3148 | gl.BlendFuncSeparateEXT = 0; |
3210 | gl.BlendFuncSeparateEXT = 0; |
3149 | |
3211 | |
3150 | void |
3212 | void |
3151 | apple_nvidia_bug (int enable) |
3213 | apple_nvidia_bug (int enable) |
3152 | |
3214 | |
3153 | char * |
3215 | const char * |
3154 | gl_vendor () |
3216 | gl_vendor () |
3155 | CODE: |
3217 | CODE: |
3156 | RETVAL = (char *)glGetString (GL_VENDOR); |
3218 | RETVAL = (const char *)glGetString (GL_VENDOR); |
3157 | OUTPUT: |
3219 | OUTPUT: |
3158 | RETVAL |
3220 | RETVAL |
3159 | |
3221 | |
3160 | char * |
3222 | const char * |
3161 | gl_version () |
3223 | gl_version () |
3162 | CODE: |
3224 | CODE: |
3163 | RETVAL = (char *)glGetString (GL_VERSION); |
3225 | RETVAL = (const char *)glGetString (GL_VERSION); |
3164 | OUTPUT: |
3226 | OUTPUT: |
3165 | RETVAL |
3227 | RETVAL |
3166 | |
3228 | |
3167 | char * |
3229 | const char * |
3168 | gl_extensions () |
3230 | gl_extensions () |
3169 | CODE: |
3231 | CODE: |
3170 | RETVAL = (char *)glGetString (GL_EXTENSIONS); |
3232 | RETVAL = (const char *)glGetString (GL_EXTENSIONS); |
3171 | OUTPUT: |
3233 | OUTPUT: |
3172 | RETVAL |
3234 | RETVAL |
3173 | |
3235 | |
3174 | const char *glGetString (GLenum pname) |
3236 | const char *glGetString (GLenum pname) |
|
|
3237 | CODE: |
|
|
3238 | RETVAL = (const char *)glGetString (pname); |
|
|
3239 | OUTPUT: |
|
|
3240 | RETVAL |
3175 | |
3241 | |
3176 | GLint glGetInteger (GLenum pname) |
3242 | GLint glGetInteger (GLenum pname) |
3177 | CODE: |
3243 | CODE: |
3178 | glGetIntegerv (pname, &RETVAL); |
3244 | glGetIntegerv (pname, &RETVAL); |
3179 | OUTPUT: |
3245 | OUTPUT: |
… | |
… | |
3382 | |
3448 | |
3383 | void |
3449 | void |
3384 | find_widget (SV *self, NV x, NV y) |
3450 | find_widget (SV *self, NV x, NV y) |
3385 | PPCODE: |
3451 | PPCODE: |
3386 | { |
3452 | { |
3387 | if (within_widget (self, x, y)) |
3453 | if (within_widget (self, x, y)) |
3388 | XPUSHs (self); |
3454 | XPUSHs (self); |
3389 | } |
3455 | } |
3390 | |
3456 | |
3391 | BOOT: |
3457 | BOOT: |
3392 | { |
3458 | { |
… | |
… | |
3400 | |
3466 | |
3401 | void |
3467 | void |
3402 | draw (SV *self) |
3468 | draw (SV *self) |
3403 | CODE: |
3469 | CODE: |
3404 | { |
3470 | { |
3405 | HV *hv; |
3471 | HV *hv; |
3406 | SV **svp; |
3472 | SV **svp; |
3407 | NV x, y, w, h; |
3473 | NV x, y, w, h; |
3408 | SV *draw_x_sv = GvSV (draw_x_gv); |
3474 | SV *draw_x_sv = GvSV (draw_x_gv); |
3409 | SV *draw_y_sv = GvSV (draw_y_gv); |
3475 | SV *draw_y_sv = GvSV (draw_y_gv); |
3410 | SV *draw_w_sv = GvSV (draw_w_gv); |
3476 | SV *draw_w_sv = GvSV (draw_w_gv); |
3411 | SV *draw_h_sv = GvSV (draw_h_gv); |
3477 | SV *draw_h_sv = GvSV (draw_h_gv); |