… | |
… | |
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> |
|
|
37 | #include <bitset> |
33 | |
38 | |
34 | #define USE_RWOPS 1 // for SDL_mixer:LoadMUS_RW |
39 | #define USE_RWOPS 1 // for SDL_mixer:LoadMUS_RW |
35 | |
40 | |
36 | #include <SDL.h> |
41 | #include <SDL.h> |
37 | #include <SDL_thread.h> |
42 | #include <SDL_thread.h> |
… | |
… | |
48 | #endif |
53 | #endif |
49 | |
54 | |
50 | #define PANGO_ENABLE_BACKEND |
55 | #define PANGO_ENABLE_BACKEND |
51 | #define G_DISABLE_CAST_CHECKS |
56 | #define G_DISABLE_CAST_CHECKS |
52 | |
57 | |
53 | #include <glib/gmacros.h> |
58 | #include <glib.h> |
54 | |
59 | |
55 | #include <pango/pango.h> |
60 | #include <pango/pango.h> |
56 | |
61 | |
57 | #ifndef PANGO_VERSION_CHECK |
62 | #ifndef PANGO_VERSION_CHECK |
58 | # define PANGO_VERSION_CHECK(a,b,c) 0 |
63 | # define PANGO_VERSION_CHECK(a,b,c) 0 |
… | |
… | |
100 | #define KMOD_LRAM 0x10000 // our extension |
105 | #define KMOD_LRAM 0x10000 // our extension |
101 | |
106 | |
102 | #define TEXID_SPEECH 1 |
107 | #define TEXID_SPEECH 1 |
103 | #define TEXID_NOFACE 2 |
108 | #define TEXID_NOFACE 2 |
104 | |
109 | |
|
|
110 | static char * |
|
|
111 | fast_sv_grow (SV *sv, STRLEN need) |
|
|
112 | { |
|
|
113 | STRLEN len = SvLEN (sv); |
|
|
114 | STRLEN want = SvCUR (sv) + need; |
|
|
115 | |
|
|
116 | if (expect_false (len < want)) |
|
|
117 | { |
|
|
118 | do |
|
|
119 | len *= 2; |
|
|
120 | while (len < want); |
|
|
121 | |
|
|
122 | sv_grow (sv, len); |
|
|
123 | } |
|
|
124 | |
|
|
125 | SvCUR_set (sv, want); |
|
|
126 | return SvEND (sv) - need; |
|
|
127 | } |
|
|
128 | |
105 | static AV *texture_av; |
129 | static AV *texture_av; |
106 | |
130 | |
107 | static struct |
131 | static struct |
108 | { |
132 | { |
109 | #define GL_FUNC(ptr,name) ptr name; |
133 | #define GL_FUNC(ptr,name) ptr name; |
… | |
… | |
165 | { |
189 | { |
166 | GSList *attrs = run->item->analysis.extra_attrs; |
190 | GSList *attrs = run->item->analysis.extra_attrs; |
167 | |
191 | |
168 | while (attrs) |
192 | while (attrs) |
169 | { |
193 | { |
170 | PangoAttribute *attr = attrs->data; |
194 | PangoAttribute *attr = (PangoAttribute *)attrs->data; |
171 | |
195 | |
172 | if (attr->klass->type == PANGO_ATTR_SHAPE) |
196 | if (attr->klass->type == PANGO_ATTR_SHAPE) |
173 | return 1; |
197 | return 1; |
174 | |
198 | |
175 | attrs = attrs->next; |
199 | attrs = attrs->next; |
176 | } |
200 | } |
177 | |
201 | |
178 | return 0; |
202 | return 0; |
179 | } |
203 | } |
180 | |
204 | |
181 | typedef struct cf_layout { |
205 | struct cf_layout { |
182 | PangoLayout *pl; |
206 | PangoLayout *pl; |
183 | float r, g, b, a; // default color for rgba mode |
207 | float r, g, b, a; // default color for rgba mode |
184 | int base_height; |
208 | int base_height; |
185 | DC__Font font; |
209 | DC__Font font; |
186 | rc_t *rc; |
210 | rc_t *rc; |
187 | } *DC__Layout; |
211 | }; |
|
|
212 | |
|
|
213 | typedef cf_layout *DC__Layout; |
188 | |
214 | |
189 | static DC__Font default_font; |
215 | static DC__Font default_font; |
190 | static PangoContext *opengl_context; |
216 | static PangoContext *opengl_context; |
191 | static PangoFontMap *opengl_fontmap; |
217 | static PangoFontMap *opengl_fontmap; |
192 | |
218 | |
193 | static void |
219 | static void |
194 | substitute_func (FcPattern *pattern, gpointer data) |
220 | substitute_func (FcPattern *pattern, gpointer data) |
195 | { |
221 | { |
196 | FcPatternAddBool (pattern, FC_HINTING, 1); |
222 | FcPatternAddBool (pattern, FC_HINTING, 1); |
197 | #ifdef FC_HINT_STYLE |
223 | #ifdef FC_HINT_STYLE |
198 | FcPatternAddBool (pattern, FC_HINT_STYLE, FC_HINT_FULL); |
224 | FcPatternAddInteger (pattern, FC_HINT_STYLE, FC_HINT_FULL); |
199 | #endif |
225 | #endif |
200 | FcPatternAddBool (pattern, FC_AUTOHINT, 0); |
226 | FcPatternAddBool (pattern, FC_AUTOHINT, 0); |
201 | } |
227 | } |
202 | |
228 | |
203 | static void |
229 | static void |
… | |
… | |
233 | } |
259 | } |
234 | |
260 | |
235 | typedef uint16_t tileid; |
261 | typedef uint16_t tileid; |
236 | typedef uint16_t faceid; |
262 | typedef uint16_t faceid; |
237 | |
263 | |
238 | typedef struct { |
264 | struct maptex |
|
|
265 | { |
239 | GLuint name; |
266 | GLuint name; |
240 | int w, h; |
267 | int w, h; |
241 | float s, t; |
268 | float s, t; |
242 | uint8_t r, g, b, a; |
269 | uint8_t r, g, b, a; |
243 | tileid smoothtile; |
270 | tileid smoothtile; |
244 | uint8_t smoothlevel; |
271 | uint8_t smoothlevel; |
245 | uint8_t unused; /* set to zero on use */ |
272 | uint8_t unused; /* set to zero on use */ |
246 | } maptex; |
273 | }; |
247 | |
274 | |
248 | typedef struct { |
275 | struct mapcell |
|
|
276 | { |
249 | uint32_t player; |
277 | uint32_t player; |
250 | tileid tile[3]; |
278 | tileid tile[3]; |
251 | uint16_t darkness; |
279 | uint16_t darkness; |
252 | uint8_t stat_width, stat_hp, flags, smoothmax; |
280 | uint8_t stat_width, stat_hp, flags, smoothmax; |
253 | } mapcell; |
281 | }; |
254 | |
282 | |
255 | typedef struct { |
283 | struct maprow |
|
|
284 | { |
256 | int32_t c0, c1; |
285 | int32_t c0, c1; |
257 | mapcell *col; |
286 | mapcell *col; |
258 | } maprow; |
287 | }; |
259 | |
288 | |
260 | typedef struct map { |
289 | struct mapgrid { |
261 | int x, y, w, h; |
290 | int x, y, w, h; |
262 | int ox, oy; /* offset to virtual global coordinate system */ |
291 | int ox, oy; /* offset to virtual global coordinate system */ |
263 | int faces; tileid *face2tile; // [faceid] |
292 | int faces; tileid *face2tile; // [faceid] |
264 | int texs; maptex *tex; // [tileid] |
293 | int texs; maptex *tex; // [tileid] |
265 | |
294 | |
266 | int32_t rows; |
295 | int32_t rows; |
267 | maprow *row; |
296 | maprow *row; |
268 | } *DC__Map; |
297 | }; |
|
|
298 | |
|
|
299 | typedef mapgrid *DC__Map; |
269 | |
300 | |
270 | static char * |
301 | static char * |
271 | prepend (char *ptr, int sze, int inc) |
302 | prepend (char *ptr, int sze, int inc) |
272 | { |
303 | { |
273 | char *p; |
304 | char *p; |
… | |
… | |
291 | |
322 | |
292 | #define Append(type,ptr,sze,inc) (ptr) = (type *)append ((char *)ptr, (sze) * sizeof (type), (inc) * sizeof (type)) |
323 | #define Append(type,ptr,sze,inc) (ptr) = (type *)append ((char *)ptr, (sze) * sizeof (type), (inc) * sizeof (type)) |
293 | #define Prepend(type,ptr,sze,inc) (ptr) = (type *)prepend ((char *)ptr, (sze) * sizeof (type), (inc) * sizeof (type)) |
324 | #define Prepend(type,ptr,sze,inc) (ptr) = (type *)prepend ((char *)ptr, (sze) * sizeof (type), (inc) * sizeof (type)) |
294 | |
325 | |
295 | static void |
326 | static void |
296 | need_facenum (struct map *self, faceid face) |
327 | need_facenum (struct mapgrid *self, faceid face) |
297 | { |
328 | { |
298 | while (self->faces <= face) |
329 | while (self->faces <= face) |
299 | { |
330 | { |
300 | Append (tileid, self->face2tile, self->faces, self->faces); |
331 | Append (tileid, self->face2tile, self->faces, self->faces); |
301 | self->faces *= 2; |
332 | self->faces *= 2; |
302 | } |
333 | } |
303 | } |
334 | } |
304 | |
335 | |
305 | static void |
336 | static void |
306 | need_texid (struct map *self, int texid) |
337 | need_texid (struct mapgrid *self, int texid) |
307 | { |
338 | { |
308 | while (self->texs <= texid) |
339 | while (self->texs <= texid) |
309 | { |
340 | { |
310 | Append (maptex, self->tex, self->texs, self->texs); |
341 | Append (maptex, self->tex, self->texs, self->texs); |
311 | self->texs *= 2; |
342 | self->texs *= 2; |
312 | } |
343 | } |
313 | } |
344 | } |
314 | |
345 | |
315 | static maprow * |
346 | static maprow * |
316 | map_get_row (DC__Map self, int y) |
347 | map_get_row (mapgrid *self, int y) |
317 | { |
348 | { |
318 | if (0 > y) |
349 | if (0 > y) |
319 | { |
350 | { |
320 | int extend = - y + MAP_EXTEND_Y; |
351 | int extend = - y + MAP_EXTEND_Y; |
321 | Prepend (maprow, self->row, self->rows, extend); |
352 | Prepend (maprow, self->row, self->rows, extend); |
… | |
… | |
359 | |
390 | |
360 | return row->col + (x - row->c0); |
391 | return row->col + (x - row->c0); |
361 | } |
392 | } |
362 | |
393 | |
363 | static mapcell * |
394 | static mapcell * |
364 | map_get_cell (DC__Map self, int x, int y) |
395 | map_get_cell (mapgrid *self, int x, int y) |
365 | { |
396 | { |
366 | return row_get_cell (map_get_row (self, y), x); |
397 | return row_get_cell (map_get_row (self, y), x); |
367 | } |
398 | } |
368 | |
399 | |
369 | static void |
400 | static void |
370 | map_clear (DC__Map self) |
401 | map_clear (mapgrid *self) |
371 | { |
402 | { |
372 | int r; |
403 | int r; |
373 | |
404 | |
374 | for (r = 0; r < self->rows; r++) |
405 | for (r = 0; r < self->rows; r++) |
375 | Safefree (self->row[r].col); |
406 | Safefree (self->row[r].col); |
… | |
… | |
393 | (cell)->flags = 0; \ |
424 | (cell)->flags = 0; \ |
394 | (cell)->player = 0; \ |
425 | (cell)->player = 0; \ |
395 | } while (0) |
426 | } while (0) |
396 | |
427 | |
397 | static void |
428 | static void |
398 | map_blank (DC__Map self, int x0, int y0, int w, int h) |
429 | map_blank (mapgrid *self, int x0, int y0, int w, int h) |
399 | { |
430 | { |
400 | int x, y; |
431 | int x, y; |
401 | maprow *row; |
432 | maprow *row; |
402 | mapcell *cell; |
433 | mapcell *cell; |
403 | |
434 | |
… | |
… | |
420 | CELL_CLEAR (cell); |
451 | CELL_CLEAR (cell); |
421 | } |
452 | } |
422 | } |
453 | } |
423 | } |
454 | } |
424 | |
455 | |
425 | typedef struct { |
456 | struct smooth_key |
|
|
457 | { |
426 | tileid tile; |
458 | tileid tile; |
427 | uint8_t x, y, level; |
459 | uint8_t x, y, level; |
428 | } smooth_key; |
460 | |
|
|
461 | bool operator == (const smooth_key &o) const |
|
|
462 | { |
|
|
463 | return tile == o.tile && x == o.x && y == o.y && level == o.level; |
|
|
464 | } |
|
|
465 | }; |
|
|
466 | |
|
|
467 | typedef ska::flat_hash_map<smooth_key, IV> smooth_hash; |
|
|
468 | |
|
|
469 | namespace std { |
|
|
470 | template <> |
|
|
471 | struct hash<smooth_key> |
|
|
472 | { |
|
|
473 | size_t operator () (const smooth_key &v) const |
|
|
474 | { |
|
|
475 | return v.tile + (v.x << 8) + (v.y << 16) + (v.level << 24); |
|
|
476 | } |
|
|
477 | }; |
|
|
478 | } |
429 | |
479 | |
430 | static void |
480 | static void |
431 | smooth_or_bits (HV *hv, smooth_key *key, IV bits) |
481 | smooth_or_bits (smooth_hash &h, smooth_key &key, IV bits) |
432 | { |
482 | { |
433 | SV **sv = hv_fetch (hv, (char *)key, sizeof (*key), 1); |
483 | auto &&it = h.find (key); |
434 | |
484 | |
435 | if (SvIOK (*sv)) |
485 | if (it == h.end ()) |
436 | SvIV_set (*sv, SvIVX (*sv) | bits); |
486 | h.insert (std::make_pair (key, bits)); |
437 | else |
487 | else |
438 | sv_setiv (*sv, bits); |
488 | it->second |= bits; |
439 | } |
489 | } |
440 | |
490 | |
441 | static void |
491 | static void |
442 | music_finished (void) |
492 | music_finished (void) |
443 | { |
493 | { |
… | |
… | |
460 | ev.code = 1; |
510 | ev.code = 1; |
461 | ev.data1 = (void *)(long)channel; |
511 | ev.data1 = (void *)(long)channel; |
462 | ev.data2 = 0; |
512 | ev.data2 = 0; |
463 | |
513 | |
464 | SDL_PushEvent ((SDL_Event *)&ev); |
514 | SDL_PushEvent ((SDL_Event *)&ev); |
|
|
515 | } |
|
|
516 | |
|
|
517 | // approximately divide by 255 |
|
|
518 | static unsigned int |
|
|
519 | div255 (unsigned int n) |
|
|
520 | { |
|
|
521 | return (n + (n >> 8)) >> 8; |
465 | } |
522 | } |
466 | |
523 | |
467 | static unsigned int |
524 | static unsigned int |
468 | minpot (unsigned int n) |
525 | minpot (unsigned int n) |
469 | { |
526 | { |
… | |
… | |
552 | |
609 | |
553 | return mod; |
610 | return mod; |
554 | } |
611 | } |
555 | |
612 | |
556 | static void |
613 | static void |
557 | deliantra_main () |
614 | deliantra_main (SV *real_main) |
558 | { |
615 | { |
559 | char *argv[] = { 0 }; |
616 | dSP; |
560 | call_argv ("::main", G_DISCARD | G_VOID, argv); |
617 | |
|
|
618 | PUSHMARK (SP); |
|
|
619 | call_sv (real_main, G_DISCARD | G_VOID); |
561 | } |
620 | } |
562 | |
621 | |
563 | #ifdef __MACOSX__ |
622 | #ifdef __MACOSX__ |
|
|
623 | static SV *real_main; |
|
|
624 | |
564 | /* to due surprising braindamage on the side of SDL design, we |
625 | /* to due surprising braindamage on the side of SDL design, we |
565 | * do some mind-boggling hack here: SDL requires a custom main() |
626 | * 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, |
627 | * 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, |
628 | * due to shared library magic, calls -lSDLmain's main, not perl's main, |
568 | * and which calls our main (== SDL_main) back. |
629 | * and which calls our main (== SDL_main) back. |
569 | */ |
630 | */ |
570 | extern C_LINKAGE int |
631 | extern C_LINKAGE int |
571 | main (int argc, char *argv[]) |
632 | main (int argc, char *argv[]) |
572 | { |
633 | { |
573 | deliantra_main (); |
634 | deliantra_main (real_main); |
574 | } |
635 | } |
575 | |
636 | |
576 | #undef main |
637 | #undef main |
577 | |
638 | |
578 | extern C_LINKAGE int main (int argc, char *argv[]); |
639 | extern C_LINKAGE int main (int argc, char *argv[]); |
579 | |
640 | |
580 | static void |
641 | static void |
581 | SDL_braino (void) |
642 | SDL_main_hack (SV *real_main_) |
582 | { |
643 | { |
|
|
644 | real_main = real_main_; |
|
|
645 | |
583 | char *argv[] = { "deliantra client", 0 }; |
646 | char *argv[] = { "deliantra client", 0 }; |
584 | (main) (1, argv); |
647 | (main) (1, argv); |
585 | } |
648 | } |
586 | #else |
649 | #else |
587 | static void |
650 | static void |
588 | SDL_braino (void) |
651 | SDL_main_hack (SV *real_main) |
589 | { |
652 | { |
590 | deliantra_main (); |
653 | deliantra_main (real_main); |
591 | } |
654 | } |
592 | #endif |
655 | #endif |
593 | |
656 | |
594 | MODULE = Deliantra::Client PACKAGE = DC |
657 | MODULE = Deliantra::Client PACKAGE = DC |
595 | |
658 | |
… | |
… | |
796 | |
859 | |
797 | const_iv (FOW_DARKNESS) |
860 | const_iv (FOW_DARKNESS) |
798 | # undef const_iv |
861 | # undef const_iv |
799 | }; |
862 | }; |
800 | |
863 | |
801 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
864 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ > const_iv; civ--) |
802 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
865 | newCONSTSUB (stash, (char *)civ[-1].name, newSViv (civ[-1].iv)); |
803 | |
866 | |
804 | assert (SDLK_MODIFIER_MIN == SDLK_NUMLOCK); |
867 | assert (SDLK_MODIFIER_MIN == SDLK_NUMLOCK); |
805 | assert (SDLK_MODIFIER_MAX == SDLK_COMPOSE); |
868 | assert (SDLK_MODIFIER_MAX == SDLK_COMPOSE); |
806 | } |
869 | } |
807 | |
870 | |
… | |
… | |
846 | #endif |
909 | #endif |
847 | } |
910 | } |
848 | |
911 | |
849 | char *SDL_GetError () |
912 | char *SDL_GetError () |
850 | |
913 | |
851 | void SDL_braino () |
914 | void SDL_main_hack (SV *real_main) |
|
|
915 | PROTOTYPE: & |
852 | |
916 | |
853 | int SDL_Init (U32 flags) |
917 | int SDL_Init (U32 flags) |
854 | |
918 | |
855 | int SDL_InitSubSystem (U32 flags) |
919 | int SDL_InitSubSystem (U32 flags) |
856 | |
920 | |
857 | void SDL_QuitSubSystem (U32 flags) |
921 | void SDL_QuitSubSystem (U32 flags) |
858 | |
922 | |
859 | void SDL_Quit () |
923 | void SDL_Quit () |
860 | |
924 | |
861 | int SDL_GL_SetAttribute (int attr, int value) |
925 | int SDL_GL_SetAttribute (int attr, int value) |
|
|
926 | C_ARGS: (SDL_GLattr)attr, value |
862 | |
927 | |
863 | int SDL_GL_GetAttribute (int attr) |
928 | int SDL_GL_GetAttribute (int attr) |
864 | CODE: |
929 | CODE: |
865 | if (SDL_GL_GetAttribute (attr, &RETVAL)) |
930 | if (SDL_GL_GetAttribute ((SDL_GLattr)attr, &RETVAL)) |
866 | XSRETURN_UNDEF; |
931 | XSRETURN_UNDEF; |
867 | OUTPUT: |
932 | OUTPUT: |
868 | RETVAL |
933 | RETVAL |
869 | |
934 | |
870 | void |
935 | void |
… | |
… | |
925 | ); |
990 | ); |
926 | |
991 | |
927 | if (RETVAL) |
992 | if (RETVAL) |
928 | { |
993 | { |
929 | av_clear (texture_av); |
994 | 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); |
995 | #define GL_FUNC(ptr,name) gl.name = (ptr)SDL_GL_GetProcAddress ("gl" # name); |
933 | #include "glfunc.h" |
996 | #include "glfunc.h" |
934 | #undef GL_FUNC |
997 | #undef GL_FUNC |
|
|
998 | if (!gl.ActiveTexture ) gl.ActiveTexture = gl.ActiveTextureARB; |
|
|
999 | if (!gl.MultiTexCoord2f) gl.MultiTexCoord2f = gl.MultiTexCoord2fARB; |
935 | } |
1000 | } |
936 | } |
1001 | } |
937 | OUTPUT: |
1002 | OUTPUT: |
938 | RETVAL |
1003 | RETVAL |
|
|
1004 | |
|
|
1005 | void |
|
|
1006 | SDL_WM_SetCaption (const char *title, const char *icon) |
939 | |
1007 | |
940 | void |
1008 | void |
941 | SDL_GL_SwapBuffers () |
1009 | SDL_GL_SwapBuffers () |
942 | |
1010 | |
943 | char * |
1011 | char * |
944 | SDL_GetKeyName (int sym) |
1012 | SDL_GetKeyName (int sym) |
|
|
1013 | C_ARGS: (SDLKey)sym |
945 | |
1014 | |
946 | int |
1015 | int |
947 | SDL_GetAppState () |
1016 | SDL_GetAppState () |
948 | |
1017 | |
949 | int |
1018 | int |
950 | SDL_GetModState () |
1019 | SDL_GetModState () |
951 | |
1020 | |
|
|
1021 | int |
|
|
1022 | SDL_WaitEvent () |
|
|
1023 | C_ARGS: 0 |
|
|
1024 | |
952 | void |
1025 | void |
|
|
1026 | SDL_PumpEvents () |
|
|
1027 | |
|
|
1028 | void |
953 | poll_events () |
1029 | peep_events () |
954 | PPCODE: |
1030 | PPCODE: |
955 | { |
1031 | { |
956 | SDL_Event ev; |
1032 | SDL_Event ev; |
957 | |
1033 | |
958 | SDL_PumpEvents (); |
1034 | SDL_PumpEvents (); |
… | |
… | |
1024 | |
1100 | |
1025 | XPUSHs (sv_2mortal (sv_bless (newRV_noinc ((SV *)hv), gv_stashpv ("DC::UI::Event", 1)))); |
1101 | XPUSHs (sv_2mortal (sv_bless (newRV_noinc ((SV *)hv), gv_stashpv ("DC::UI::Event", 1)))); |
1026 | } |
1102 | } |
1027 | } |
1103 | } |
1028 | |
1104 | |
|
|
1105 | char * |
|
|
1106 | SDL_AudioDriverName () |
|
|
1107 | CODE: |
|
|
1108 | { |
|
|
1109 | char buf [256]; |
|
|
1110 | if (!SDL_AudioDriverName (buf, sizeof (buf))) |
|
|
1111 | XSRETURN_UNDEF; |
|
|
1112 | |
|
|
1113 | RETVAL = buf; |
|
|
1114 | } |
|
|
1115 | OUTPUT: |
|
|
1116 | RETVAL |
|
|
1117 | |
1029 | int |
1118 | int |
1030 | Mix_OpenAudio (int frequency = 44100, int format = MIX_DEFAULT_FORMAT, int channels = 2, int chunksize = 4096) |
1119 | Mix_OpenAudio (int frequency = 44100, int format = MIX_DEFAULT_FORMAT, int channels = 2, int chunksize = 4096) |
1031 | POSTCALL: |
1120 | POSTCALL: |
1032 | Mix_HookMusicFinished (music_finished); |
1121 | Mix_HookMusicFinished (music_finished); |
1033 | Mix_ChannelFinished (channel_finished); |
1122 | Mix_ChannelFinished (channel_finished); |
1034 | |
1123 | |
1035 | void |
1124 | void |
1036 | Mix_QuerySpec () |
1125 | Mix_QuerySpec () |
… | |
… | |
1095 | add_font (char *file) |
1184 | add_font (char *file) |
1096 | CODE: |
1185 | CODE: |
1097 | RETVAL = FcConfigAppFontAddFile (0, (const FcChar8 *)file); |
1186 | RETVAL = FcConfigAppFontAddFile (0, (const FcChar8 *)file); |
1098 | OUTPUT: |
1187 | OUTPUT: |
1099 | RETVAL |
1188 | RETVAL |
|
|
1189 | |
|
|
1190 | void |
|
|
1191 | IMG_Init (int flags = IMG_INIT_JPG | IMG_INIT_PNG) |
|
|
1192 | |
|
|
1193 | # MIX_INIT_MP3 gives smpeg + libstdc++ + libgcc_s |
|
|
1194 | void |
|
|
1195 | Mix_Init (int flags = MIX_INIT_MOD | MIX_INIT_OGG) |
1100 | |
1196 | |
1101 | void |
1197 | void |
1102 | load_image_inline (SV *image_) |
1198 | load_image_inline (SV *image_) |
1103 | ALIAS: |
1199 | ALIAS: |
1104 | load_image_file = 1 |
1200 | load_image_file = 1 |
… | |
… | |
1150 | |
1246 | |
1151 | SDL_LockSurface (surface2); |
1247 | SDL_LockSurface (surface2); |
1152 | EXTEND (SP, 6); |
1248 | EXTEND (SP, 6); |
1153 | PUSHs (sv_2mortal (newSViv (surface2->w))); |
1249 | PUSHs (sv_2mortal (newSViv (surface2->w))); |
1154 | PUSHs (sv_2mortal (newSViv (surface2->h))); |
1250 | PUSHs (sv_2mortal (newSViv (surface2->h))); |
1155 | PUSHs (sv_2mortal (newSVpvn (surface2->pixels, surface2->h * surface2->pitch))); |
1251 | PUSHs (sv_2mortal (newSVpvn ((const char *)surface2->pixels, surface2->h * surface2->pitch))); |
1156 | PUSHs (sv_2mortal (newSViv (surface->flags & (SDL_SRCCOLORKEY | SDL_SRCALPHA) ? GL_RGBA : GL_RGB))); |
1252 | PUSHs (sv_2mortal (newSViv (surface->flags & (SDL_SRCCOLORKEY | SDL_SRCALPHA) ? GL_RGBA : GL_RGB))); |
1157 | PUSHs (sv_2mortal (newSViv (GL_RGBA))); |
1253 | PUSHs (sv_2mortal (newSViv (GL_RGBA))); |
1158 | PUSHs (sv_2mortal (newSViv (GL_UNSIGNED_BYTE))); |
1254 | PUSHs (sv_2mortal (newSViv (GL_UNSIGNED_BYTE))); |
1159 | SDL_UnlockSurface (surface2); |
1255 | SDL_UnlockSurface (surface2); |
1160 | |
1256 | |
… | |
… | |
1232 | MODULE = Deliantra::Client PACKAGE = DC::Font |
1328 | MODULE = Deliantra::Client PACKAGE = DC::Font |
1233 | |
1329 | |
1234 | PROTOTYPES: DISABLE |
1330 | PROTOTYPES: DISABLE |
1235 | |
1331 | |
1236 | DC::Font |
1332 | DC::Font |
1237 | new_from_file (SV *class, char *path, int id = 0) |
1333 | new_from_file (SV *klass, char *path, int id = 0) |
1238 | CODE: |
1334 | CODE: |
1239 | { |
1335 | { |
1240 | int count; |
1336 | int count; |
1241 | FcPattern *pattern = FcFreeTypeQuery ((const FcChar8 *)path, id, 0, &count); |
1337 | FcPattern *pattern = FcFreeTypeQuery ((const FcChar8 *)path, id, 0, &count); |
1242 | RETVAL = pango_fc_font_description_from_pattern (pattern, 0); |
1338 | RETVAL = pango_fc_font_description_from_pattern (pattern, 0); |
… | |
… | |
1271 | PROTOTYPE: |
1367 | PROTOTYPE: |
1272 | CODE: |
1368 | CODE: |
1273 | tc_restore (); |
1369 | tc_restore (); |
1274 | |
1370 | |
1275 | DC::Layout |
1371 | DC::Layout |
1276 | new (SV *class) |
1372 | new (SV *klass) |
1277 | CODE: |
1373 | CODE: |
1278 | New (0, RETVAL, 1, struct cf_layout); |
1374 | New (0, RETVAL, 1, struct cf_layout); |
1279 | |
1375 | |
1280 | RETVAL->pl = pango_layout_new (opengl_context); |
1376 | RETVAL->pl = pango_layout_new (opengl_context); |
1281 | RETVAL->r = 1.; |
1377 | RETVAL->r = 1.; |
… | |
… | |
1430 | |
1526 | |
1431 | void |
1527 | void |
1432 | set_height (DC::Layout self, int base_height) |
1528 | set_height (DC::Layout self, int base_height) |
1433 | CODE: |
1529 | CODE: |
1434 | if (self->base_height != base_height) |
1530 | if (self->base_height != base_height) |
1435 | { |
1531 | { |
1436 | self->base_height = base_height; |
1532 | self->base_height = base_height; |
1437 | layout_update_font (self); |
1533 | layout_update_font (self); |
1438 | } |
1534 | } |
1439 | |
1535 | |
1440 | void |
1536 | void |
… | |
… | |
1672 | void |
1768 | void |
1673 | draw_fow_texture (float intensity, int hidden_tex, int name1, uint8_t *data1, float s, float t, int w, int h, float blend = 0.f, int dx = 0, int dy = 0, int name2 = 0, uint8_t *data2 = data1) |
1769 | draw_fow_texture (float intensity, int hidden_tex, int name1, uint8_t *data1, float s, float t, int w, int h, float blend = 0.f, int dx = 0, int dy = 0, int name2 = 0, uint8_t *data2 = data1) |
1674 | PROTOTYPE: @ |
1770 | PROTOTYPE: @ |
1675 | CODE: |
1771 | CODE: |
1676 | { |
1772 | { |
|
|
1773 | glEnable (GL_BLEND); |
|
|
1774 | glBlendFunc (intensity ? GL_SRC_ALPHA : GL_ONE, GL_ONE_MINUS_SRC_ALPHA); |
1677 | glEnable (GL_TEXTURE_2D); |
1775 | glEnable (GL_TEXTURE_2D); |
1678 | glEnable (GL_BLEND); |
|
|
1679 | glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA); |
|
|
1680 | glBindTexture (GL_TEXTURE_2D, name1); |
1776 | glBindTexture (GL_TEXTURE_2D, name1); |
1681 | |
1777 | |
1682 | glColor3f (intensity, intensity, intensity); |
1778 | glColor3f (intensity, intensity, intensity); |
1683 | glPushMatrix (); |
1779 | glPushMatrix (); |
1684 | glScalef (1./3, 1./3, 1.); |
1780 | glScalef (1./3, 1./3, 1.); |
… | |
… | |
1699 | glBindTexture (GL_TEXTURE_2D, name2); |
1795 | glBindTexture (GL_TEXTURE_2D, name2); |
1700 | glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE); |
1796 | glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE); |
1701 | |
1797 | |
1702 | /* rgb == rgb(glcolor) */ |
1798 | /* rgb == rgb(glcolor) */ |
1703 | glTexEnvi (GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_REPLACE); |
1799 | glTexEnvi (GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_REPLACE); |
1704 | glTexEnvi (GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_CONSTANT); |
1800 | glTexEnvi (GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_PRIMARY_COLOR); |
1705 | glTexEnvi (GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR); |
1801 | glTexEnvi (GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR); |
1706 | |
1802 | |
1707 | /* alpha = interpolate t0, t1 by env_alpha */ |
1803 | /* alpha = interpolate t0, t1 by env_alpha */ |
1708 | glTexEnvfv (GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, env_color); |
1804 | glTexEnvfv (GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, env_color); |
1709 | |
1805 | |
… | |
… | |
1804 | MODULE = Deliantra::Client PACKAGE = DC::Map |
1900 | MODULE = Deliantra::Client PACKAGE = DC::Map |
1805 | |
1901 | |
1806 | PROTOTYPES: DISABLE |
1902 | PROTOTYPES: DISABLE |
1807 | |
1903 | |
1808 | DC::Map |
1904 | DC::Map |
1809 | new (SV *class) |
1905 | new (SV *klass) |
1810 | CODE: |
1906 | CODE: |
1811 | New (0, RETVAL, 1, struct map); |
1907 | New (0, RETVAL, 1, mapgrid); |
1812 | RETVAL->x = 0; |
1908 | RETVAL->x = 0; |
1813 | RETVAL->y = 0; |
1909 | RETVAL->y = 0; |
1814 | RETVAL->w = 0; |
1910 | RETVAL->w = 0; |
1815 | RETVAL->h = 0; |
1911 | RETVAL->h = 0; |
1816 | RETVAL->ox = 0; |
1912 | RETVAL->ox = 0; |
… | |
… | |
1853 | |
1949 | |
1854 | void |
1950 | void |
1855 | set_smooth (DC::Map self, int face, int smooth, int level) |
1951 | set_smooth (DC::Map self, int face, int smooth, int level) |
1856 | CODE: |
1952 | CODE: |
1857 | { |
1953 | { |
1858 | tileid texid; |
1954 | tileid texid; |
1859 | maptex *tex; |
1955 | maptex *tex; |
1860 | |
1956 | |
1861 | if (face < 0 || face >= self->faces) |
1957 | if (face < 0 || face >= self->faces) |
1862 | return; |
1958 | return; |
1863 | |
1959 | |
1864 | if (smooth < 0 || smooth >= self->faces) |
1960 | if (smooth < 0 || smooth >= self->faces) |
1865 | return; |
1961 | return; |
1866 | |
1962 | |
1867 | texid = self->face2tile [face]; |
1963 | texid = self->face2tile [face]; |
1868 | |
1964 | |
1869 | if (!texid) |
1965 | if (!texid) |
1870 | return; |
1966 | return; |
1871 | |
1967 | |
1872 | tex = self->tex + texid; |
1968 | tex = self->tex + texid; |
… | |
… | |
1905 | } |
2001 | } |
1906 | |
2002 | |
1907 | void |
2003 | void |
1908 | expire_textures (DC::Map self, int texid, int count) |
2004 | expire_textures (DC::Map self, int texid, int count) |
1909 | PPCODE: |
2005 | PPCODE: |
1910 | for (; texid < self->texs && count; ++texid, --count) |
2006 | for (; texid < self->texs && count; ++texid, --count) |
1911 | { |
2007 | { |
1912 | maptex *tex = self->tex + texid; |
2008 | maptex *tex = self->tex + texid; |
1913 | |
2009 | |
1914 | if (tex->name) |
2010 | if (tex->name) |
1915 | { |
2011 | { |
… | |
… | |
1970 | self->y += MAP_EXTEND_Y; |
2066 | self->y += MAP_EXTEND_Y; |
1971 | } |
2067 | } |
1972 | } |
2068 | } |
1973 | |
2069 | |
1974 | SV * |
2070 | SV * |
1975 | map1a_update (DC::Map self, SV *data_, int extmap) |
2071 | map1a_update (DC::Map self, SV *data_) |
1976 | CODE: |
2072 | CODE: |
1977 | { |
2073 | { |
1978 | uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_); |
2074 | uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_); |
1979 | uint8_t *data_end = (uint8_t *)SvEND (data_); |
2075 | uint8_t *data_end = (uint8_t *)SvEND (data_); |
1980 | mapcell *cell; |
2076 | mapcell *cell; |
… | |
… | |
2001 | |
2097 | |
2002 | //TODO: don't trust server data to be in-range(!) |
2098 | //TODO: don't trust server data to be in-range(!) |
2003 | |
2099 | |
2004 | if (flags & 8) |
2100 | if (flags & 8) |
2005 | { |
2101 | { |
|
|
2102 | uint8_t ext, cmd; |
|
|
2103 | |
2006 | if (extmap) |
2104 | do |
2007 | { |
2105 | { |
2008 | uint8_t ext, cmd; |
2106 | ext = *data++; |
|
|
2107 | cmd = ext & 0x7f; |
2009 | |
2108 | |
2010 | do |
2109 | if (cmd < 4) |
|
|
2110 | cell->darkness = 255 - ext * 64 + 1; /* make sure this doesn't collide with FOW_DARKNESS */ |
|
|
2111 | else if (cmd == 5) // health |
2011 | { |
2112 | { |
2012 | ext = *data++; |
|
|
2013 | cmd = ext & 0x7f; |
|
|
2014 | |
|
|
2015 | if (cmd < 4) |
|
|
2016 | cell->darkness = 255 - ext * 64 + 1; /* make sure this doesn't collide with FOW_DARKNESS */ |
|
|
2017 | else if (cmd == 5) // health |
|
|
2018 | { |
|
|
2019 | cell->stat_width = 1; |
2113 | cell->stat_width = 1; |
2020 | cell->stat_hp = *data++; |
2114 | cell->stat_hp = *data++; |
2021 | } |
|
|
2022 | else if (cmd == 6) // monster width |
|
|
2023 | cell->stat_width = *data++ + 1; |
|
|
2024 | else if (cmd == 0x47) |
|
|
2025 | { |
|
|
2026 | if (*data == 1) cell->player = data [1]; |
|
|
2027 | else if (*data == 2) cell->player = data [2] + (data [1] << 8); |
|
|
2028 | else if (*data == 3) cell->player = data [3] + (data [2] << 8) + (data [1] << 16); |
|
|
2029 | else if (*data == 4) cell->player = data [4] + (data [3] << 8) + (data [2] << 16) + (data [1] << 24); |
|
|
2030 | |
|
|
2031 | data += *data + 1; |
|
|
2032 | } |
|
|
2033 | else if (cmd == 8) // cell flags |
|
|
2034 | cell->flags = *data++; |
|
|
2035 | else if (ext & 0x40) // unknown, multibyte => skip |
|
|
2036 | data += *data + 1; |
|
|
2037 | else |
|
|
2038 | data++; |
|
|
2039 | } |
2115 | } |
2040 | while (ext & 0x80); |
2116 | else if (cmd == 6) // monster width |
|
|
2117 | cell->stat_width = *data++ + 1; |
|
|
2118 | else if (cmd == 0x47) |
|
|
2119 | { |
|
|
2120 | if (*data == 1) cell->player = data [1]; |
|
|
2121 | else if (*data == 2) cell->player = data [2] + (data [1] << 8); |
|
|
2122 | else if (*data == 3) cell->player = data [3] + (data [2] << 8) + (data [1] << 16); |
|
|
2123 | else if (*data == 4) cell->player = data [4] + (data [3] << 8) + (data [2] << 16) + (data [1] << 24); |
|
|
2124 | |
|
|
2125 | data += *data + 1; |
|
|
2126 | } |
|
|
2127 | else if (cmd == 8) // cell flags |
|
|
2128 | cell->flags = *data++; |
|
|
2129 | else if (ext & 0x40) // unknown, multibyte => skip |
|
|
2130 | data += *data + 1; |
|
|
2131 | else |
|
|
2132 | data++; |
2041 | } |
2133 | } |
2042 | else |
2134 | while (ext & 0x80); |
2043 | cell->darkness = *data++ + 1; |
|
|
2044 | } |
2135 | } |
2045 | |
2136 | |
2046 | for (z = 0; z <= 2; ++z) |
2137 | for (z = 0; z <= 2; ++z) |
2047 | if (flags & (4 >> z)) |
2138 | if (flags & (4 >> z)) |
2048 | { |
2139 | { |
… | |
… | |
2096 | ? self->row + y |
2187 | ? self->row + y |
2097 | : 0; |
2188 | : 0; |
2098 | |
2189 | |
2099 | for (x = x0; x < x1; x++) |
2190 | for (x = x0; x < x1; x++) |
2100 | { |
2191 | { |
2101 | int r = 32, g = 32, b = 32, a = 192; |
2192 | unsigned int r = 32, g = 32, b = 32, a = 192; |
2102 | |
2193 | |
2103 | if (row && row->c0 <= x && x < row->c1) |
2194 | if (row && row->c0 <= x && x < row->c1) |
2104 | { |
2195 | { |
2105 | mapcell *cell = row->col + (x - row->c0); |
2196 | mapcell *cell = row->col + (x - row->c0); |
2106 | |
2197 | |
… | |
… | |
2108 | { |
2199 | { |
2109 | maptex tex = self->tex [cell->tile [z]]; |
2200 | maptex tex = self->tex [cell->tile [z]]; |
2110 | int a0 = 255 - tex.a; |
2201 | int a0 = 255 - tex.a; |
2111 | int a1 = tex.a; |
2202 | int a1 = tex.a; |
2112 | |
2203 | |
2113 | r = (r * a0 + tex.r * a1) / 255; |
2204 | r = div255 (r * a0 + tex.r * a1); |
2114 | g = (g * a0 + tex.g * a1) / 255; |
2205 | g = div255 (g * a0 + tex.g * a1); |
2115 | b = (b * a0 + tex.b * a1) / 255; |
2206 | b = div255 (b * a0 + tex.b * a1); |
2116 | a = (a * a0 + tex.a * a1) / 255; |
2207 | a = div255 (a * a0 + tex.a * a1); |
2117 | } |
2208 | } |
2118 | } |
2209 | } |
2119 | |
2210 | |
2120 | *map++ = (r ) |
2211 | *map++ = (r ) |
2121 | | (g << 8) |
2212 | | (g << 8) |
2122 | | (b << 16) |
2213 | | (b << 16) |
2123 | | (a << 24); |
2214 | | (a << 24); |
2124 | } |
2215 | } |
2125 | } |
2216 | } |
2126 | |
2217 | |
2127 | RETVAL = map_sv; |
2218 | RETVAL = map_sv; |
2128 | } |
2219 | } |
2129 | OUTPUT: |
2220 | OUTPUT: |
2130 | RETVAL |
2221 | RETVAL |
2131 | |
2222 | |
2132 | void |
2223 | void |
2133 | draw (DC::Map self, int mx, int my, int sw, int sh, int T, U32 player = 0xffffffff, int sdx = 0, int sdy = 0) |
2224 | 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) |
2134 | CODE: |
2225 | CODE: |
2135 | { |
2226 | { |
2136 | int x, y, z; |
2227 | int x, y, z; |
2137 | |
2228 | |
2138 | HV *smooth = (HV *)sv_2mortal ((SV *)newHV ()); |
|
|
2139 | uint32_t smooth_level[256 / 32]; // one bit for every possible smooth level |
|
|
2140 | static uint8_t smooth_max[256][256]; // egad, fast and wasteful on memory (64k) |
2229 | static uint8_t smooth_max[256][256]; // egad, fast and wasteful on memory (64k), also, static! |
2141 | smooth_key skey; |
|
|
2142 | int pl_x, pl_y; |
2230 | int pl_x, pl_y; |
2143 | maptex pl_tex; |
2231 | maptex pl_tex; |
2144 | rc_t *rc = rc_alloc (); |
2232 | rc_t *rc = rc_alloc (); |
2145 | rc_t *rc_ov = rc_alloc (); |
2233 | rc_t *rc_ov = rc_alloc (); |
2146 | rc_key_t key; |
2234 | rc_key_t key; |
… | |
… | |
2149 | pl_tex.name = 0; |
2237 | pl_tex.name = 0; |
2150 | |
2238 | |
2151 | // that's current max. sorry. |
2239 | // that's current max. sorry. |
2152 | if (sw > 255) sw = 255; |
2240 | if (sw > 255) sw = 255; |
2153 | if (sh > 255) sh = 255; |
2241 | if (sh > 255) sh = 255; |
2154 | |
|
|
2155 | // clear key, in case of extra padding |
|
|
2156 | memset (&skey, 0, sizeof (skey)); |
|
|
2157 | |
2242 | |
2158 | memset (&key, 0, sizeof (key)); |
2243 | memset (&key, 0, sizeof (key)); |
2159 | key.r = 255; |
2244 | key.r = 255; |
2160 | key.g = 255; |
2245 | key.g = 255; |
2161 | key.b = 255; |
2246 | key.b = 255; |
… | |
… | |
2167 | my += self->y; |
2252 | my += self->y; |
2168 | |
2253 | |
2169 | // first pass: determine smooth_max |
2254 | // first pass: determine smooth_max |
2170 | // rather ugly, if you ask me |
2255 | // rather ugly, if you ask me |
2171 | // could also be stored inside mapcell and updated on change |
2256 | // could also be stored inside mapcell and updated on change |
2172 | memset (smooth_max, 0, sizeof (smooth_max)); |
2257 | memset (smooth_max, 0, sizeof (smooth_max[0]) * (sh + 1)); |
2173 | |
2258 | |
2174 | for (y = 0; y < sh; y++) |
2259 | for (y = 0; y < sh; y++) |
2175 | if (0 <= y + my && y + my < self->rows) |
2260 | if (0 <= y + my && y + my < self->rows) |
2176 | { |
2261 | { |
2177 | maprow *row = self->row + (y + my); |
2262 | maprow *row = self->row + (y + my); |
… | |
… | |
2192 | glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
2277 | glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
2193 | glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); |
2278 | glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); |
2194 | |
2279 | |
2195 | for (z = 0; z <= 2; z++) |
2280 | for (z = 0; z <= 2; z++) |
2196 | { |
2281 | { |
2197 | memset (smooth_level, 0, sizeof (smooth_level)); |
2282 | std::bitset<256> smooth_level; // one bit for every possible smooth level |
|
|
2283 | smooth_key skey; |
|
|
2284 | smooth_hash smooth; |
2198 | key.texname = -1; |
2285 | key.texname = -1; |
2199 | |
2286 | |
2200 | for (y = 0; y < sh; y++) |
2287 | for (y = 0; y < sh; y++) |
2201 | if (0 <= y + my && y + my < self->rows) |
2288 | if (0 <= y + my && y + my < self->rows) |
2202 | { |
2289 | { |
… | |
… | |
2222 | |
2309 | |
2223 | key.texname = tex.name; |
2310 | key.texname = tex.name; |
2224 | arr = rc_array (rc, &key); |
2311 | arr = rc_array (rc, &key); |
2225 | } |
2312 | } |
2226 | |
2313 | |
2227 | px = (x + 1) * T - tex.w; |
2314 | px = (x + 1) * Th - tex.w; |
2228 | py = (y + 1) * T - tex.h; |
2315 | py = (y + 1) * Tw - tex.h; |
2229 | |
2316 | |
2230 | if (expect_false (cell->player == player) && expect_false (z == 2)) |
2317 | if (expect_false (cell->player == player) && expect_false (z == 2)) |
2231 | { |
2318 | { |
2232 | pl_x = px; |
2319 | pl_x = px; |
2233 | pl_y = py; |
2320 | pl_y = py; |
… | |
… | |
2244 | if (tex.smoothtile) |
2331 | if (tex.smoothtile) |
2245 | { |
2332 | { |
2246 | skey.tile = tex.smoothtile; |
2333 | skey.tile = tex.smoothtile; |
2247 | skey.level = tex.smoothlevel; |
2334 | skey.level = tex.smoothlevel; |
2248 | |
2335 | |
2249 | smooth_level [tex.smoothlevel >> 5] |= ((uint32_t)1) << (tex.smoothlevel & 31); |
2336 | smooth_level[tex.smoothlevel] = 1; |
2250 | |
2337 | |
2251 | // add bits to current tile and all neighbours. skey.x|y is |
2338 | // add bits to current tile and all neighbours. skey.x|y is |
2252 | // shifted +1|+1 so we always stay positive. |
2339 | // shifted +1|+1 so we always stay positive. |
2253 | |
2340 | |
2254 | // bits is ___n cccc CCCC bbbb |
2341 | // bits is ___n cccc CCCC bbbb |
… | |
… | |
2262 | |
2349 | |
2263 | // corners: 1 ┛· 2 ·┗ 4 ·· 8 ·· |
2350 | // corners: 1 ┛· 2 ·┗ 4 ·· 8 ·· |
2264 | // ·· ·· ·┏ ┓· |
2351 | // ·· ·· ·┏ ┓· |
2265 | |
2352 | |
2266 | // full tile |
2353 | // full tile |
2267 | skey.x = x + 1; skey.y = y + 1; smooth_or_bits (smooth, &skey, 0x1000); |
2354 | skey.x = x + 1; skey.y = y + 1; smooth_or_bits (smooth, skey, 0x1000); |
2268 | |
2355 | |
2269 | // borders |
2356 | // borders |
2270 | skey.x = x + 2; skey.y = y + 1; smooth_or_bits (smooth, &skey, 0x0091); |
2357 | skey.x = x + 2; skey.y = y + 1; smooth_or_bits (smooth, skey, 0x0091); |
2271 | skey.x = x + 1; skey.y = y + 2; smooth_or_bits (smooth, &skey, 0x0032); |
2358 | skey.x = x + 1; skey.y = y + 2; smooth_or_bits (smooth, skey, 0x0032); |
2272 | skey.x = x ; skey.y = y + 1; smooth_or_bits (smooth, &skey, 0x0064); |
2359 | skey.x = x ; skey.y = y + 1; smooth_or_bits (smooth, skey, 0x0064); |
2273 | skey.x = x + 1; skey.y = y ; smooth_or_bits (smooth, &skey, 0x00c8); |
2360 | skey.x = x + 1; skey.y = y ; smooth_or_bits (smooth, skey, 0x00c8); |
2274 | |
2361 | |
2275 | // corners |
2362 | // corners |
2276 | skey.x = x + 2; skey.y = y + 2; smooth_or_bits (smooth, &skey, 0x0100); |
2363 | skey.x = x + 2; skey.y = y + 2; smooth_or_bits (smooth, skey, 0x0100); |
2277 | skey.x = x ; skey.y = y + 2; smooth_or_bits (smooth, &skey, 0x0200); |
2364 | skey.x = x ; skey.y = y + 2; smooth_or_bits (smooth, skey, 0x0200); |
2278 | skey.x = x ; skey.y = y ; smooth_or_bits (smooth, &skey, 0x0400); |
2365 | skey.x = x ; skey.y = y ; smooth_or_bits (smooth, skey, 0x0400); |
2279 | skey.x = x + 2; skey.y = y ; smooth_or_bits (smooth, &skey, 0x0800); |
2366 | skey.x = x + 2; skey.y = y ; smooth_or_bits (smooth, skey, 0x0800); |
2280 | } |
2367 | } |
2281 | } |
2368 | } |
2282 | |
2369 | |
2283 | if (expect_false (z == 2) && expect_false (cell->flags)) |
2370 | if (expect_false (z == 2) && expect_false (cell->flags)) |
2284 | { |
2371 | { |
… | |
… | |
2286 | if (cell->flags & 1) |
2373 | if (cell->flags & 1) |
2287 | { |
2374 | { |
2288 | rc_key_t key_ov = key; |
2375 | rc_key_t key_ov = key; |
2289 | maptex tex = self->tex [TEXID_SPEECH]; |
2376 | maptex tex = self->tex [TEXID_SPEECH]; |
2290 | rc_array_t *arr; |
2377 | rc_array_t *arr; |
2291 | int px = x * T + T * 2 / 32; |
2378 | int px = x * Tw + Tw * 2 / 32; |
2292 | int py = y * T - T * 6 / 32; |
2379 | int py = y * Th - Th * 6 / 32; |
2293 | |
2380 | |
2294 | key_ov.texname = tex.name; |
2381 | key_ov.texname = tex.name; |
2295 | arr = rc_array (rc_ov, &key_ov); |
2382 | arr = rc_array (rc_ov, &key_ov); |
2296 | |
2383 | |
2297 | rc_t2f_v3f (arr, 0 , 0 , px , py , 0); |
2384 | rc_t2f_v3f (arr, 0 , 0 , px , py , 0); |
2298 | rc_t2f_v3f (arr, 0 , tex.t, px , py + T, 0); |
2385 | rc_t2f_v3f (arr, 0 , tex.t, px , py + Th, 0); |
2299 | rc_t2f_v3f (arr, tex.s, tex.t, px + T, py + T, 0); |
2386 | rc_t2f_v3f (arr, tex.s, tex.t, px + Tw, py + Th, 0); |
2300 | rc_t2f_v3f (arr, tex.s, 0 , px + T, py , 0); |
2387 | rc_t2f_v3f (arr, tex.s, 0 , px + Tw, py , 0); |
2301 | } |
2388 | } |
2302 | } |
2389 | } |
2303 | } |
2390 | } |
2304 | } |
2391 | } |
2305 | |
2392 | |
… | |
… | |
2311 | { |
2398 | { |
2312 | int w, b; |
2399 | int w, b; |
2313 | |
2400 | |
2314 | glEnable (GL_TEXTURE_2D); |
2401 | glEnable (GL_TEXTURE_2D); |
2315 | glBegin (GL_QUADS); |
2402 | glBegin (GL_QUADS); |
2316 | for (w = 0; w < 256 / 32; ++w) |
2403 | for (int level = 0; level < smooth_level.size (); ++level) |
|
|
2404 | if (smooth_level[level]) |
|
|
2405 | for (auto &&it = smooth.begin (); it != smooth.end (); ++it) |
2317 | { |
2406 | { |
2318 | uint32_t smask = smooth_level [w]; |
2407 | smooth_key &skey = it->first; |
2319 | if (smask) |
2408 | IV bits = it->second; |
2320 | for (b = 0; b < 32; ++b) |
2409 | |
2321 | if (smask & (((uint32_t)1) << b)) |
2410 | if (!(bits & 0x1000) |
|
|
2411 | && skey.level == level |
|
|
2412 | && level > smooth_max [skey.x][skey.y]) |
2322 | { |
2413 | { |
2323 | int level = (w << 5) | b; |
2414 | maptex tex = self->tex [skey.tile]; |
|
|
2415 | int px = (((int)skey.x) - 1) * Tw; |
|
|
2416 | int py = (((int)skey.y) - 1) * Th; |
|
|
2417 | int border = bits & 15; |
|
|
2418 | int corner = (bits >> 8) & ~(bits >> 4) & 15; |
|
|
2419 | float dx = tex.s * .0625f; // 16 images/row |
|
|
2420 | float dy = tex.t * .5f ; // 2 images/column |
|
|
2421 | |
2324 | HE *he; |
2422 | if (tex.name) |
2325 | |
|
|
2326 | hv_iterinit (smooth); |
|
|
2327 | while ((he = hv_iternext (smooth))) |
|
|
2328 | { |
2423 | { |
2329 | smooth_key *skey = (smooth_key *)HeKEY (he); |
2424 | // this time avoiding texture state changes |
2330 | IV bits = SvIVX (HeVAL (he)); |
2425 | // save gobs of state changes. |
2331 | |
2426 | if (key.texname != tex.name) |
2332 | if (!(bits & 0x1000) |
|
|
2333 | && skey->level == level |
|
|
2334 | && level > smooth_max [skey->x][skey->y]) |
|
|
2335 | { |
2427 | { |
2336 | maptex tex = self->tex [skey->tile]; |
|
|
2337 | int px = (((int)skey->x) - 1) * T; |
|
|
2338 | int py = (((int)skey->y) - 1) * T; |
|
|
2339 | int border = bits & 15; |
|
|
2340 | int corner = (bits >> 8) & ~(bits >> 4) & 15; |
|
|
2341 | float dx = tex.s * .0625f; // 16 images/row |
|
|
2342 | float dy = tex.t * .5f ; // 2 images/column |
|
|
2343 | |
|
|
2344 | if (tex.name) |
|
|
2345 | { |
|
|
2346 | // this time avoiding texture state changes |
|
|
2347 | // save gobs of state changes. |
|
|
2348 | if (key.texname != tex.name) |
|
|
2349 | { |
|
|
2350 | self->tex [skey->tile].unused = 0; |
2428 | self->tex [skey.tile].unused = 0; |
2351 | |
2429 | |
2352 | glEnd (); |
2430 | glEnd (); |
2353 | glBindTexture (GL_TEXTURE_2D, key.texname = tex.name); |
2431 | glBindTexture (GL_TEXTURE_2D, key.texname = tex.name); |
2354 | glBegin (GL_QUADS); |
2432 | glBegin (GL_QUADS); |
2355 | } |
2433 | } |
2356 | |
2434 | |
2357 | if (border) |
2435 | if (border) |
2358 | { |
2436 | { |
2359 | float ox = border * dx; |
2437 | float ox = border * dx; |
2360 | |
2438 | |
2361 | glTexCoord2f (ox , 0.f ); glVertex2i (px , py ); |
2439 | glTexCoord2f (ox , 0.f ); glVertex2i (px , py ); |
2362 | glTexCoord2f (ox , dy ); glVertex2i (px , py + T); |
2440 | glTexCoord2f (ox , dy ); glVertex2i (px , py + Th); |
2363 | glTexCoord2f (ox + dx, dy ); glVertex2i (px + T, py + T); |
2441 | glTexCoord2f (ox + dx, dy ); glVertex2i (px + Tw, py + Th); |
2364 | glTexCoord2f (ox + dx, 0.f ); glVertex2i (px + T, py ); |
2442 | glTexCoord2f (ox + dx, 0.f ); glVertex2i (px + Tw, py ); |
2365 | } |
2443 | } |
2366 | |
2444 | |
2367 | if (corner) |
2445 | if (corner) |
2368 | { |
2446 | { |
2369 | float ox = corner * dx; |
2447 | float ox = corner * dx; |
2370 | |
2448 | |
2371 | glTexCoord2f (ox , dy ); glVertex2i (px , py ); |
2449 | glTexCoord2f (ox , dy ); glVertex2i (px , py ); |
2372 | glTexCoord2f (ox , dy * 2.f); glVertex2i (px , py + T); |
2450 | glTexCoord2f (ox , dy * 2.f); glVertex2i (px , py + Th); |
2373 | glTexCoord2f (ox + dx, dy * 2.f); glVertex2i (px + T, py + T); |
2451 | glTexCoord2f (ox + dx, dy * 2.f); glVertex2i (px + Tw, py + Th); |
2374 | glTexCoord2f (ox + dx, dy ); glVertex2i (px + T, py ); |
2452 | glTexCoord2f (ox + dx, dy ); glVertex2i (px + Tw, py ); |
2375 | } |
|
|
2376 | } |
|
|
2377 | } |
2453 | } |
2378 | } |
2454 | } |
2379 | } |
2455 | } |
2380 | } |
2456 | } |
2381 | |
2457 | |
2382 | glEnd (); |
2458 | glEnd (); |
2383 | glDisable (GL_TEXTURE_2D); |
2459 | glDisable (GL_TEXTURE_2D); |
2384 | key.texname = -1; |
2460 | key.texname = -1; |
2385 | } |
2461 | } |
2386 | |
|
|
2387 | hv_clear (smooth); |
|
|
2388 | } |
2462 | } |
2389 | |
2463 | |
2390 | if (pl_tex.name) |
2464 | if (pl_tex.name) |
2391 | { |
2465 | { |
2392 | maptex tex = pl_tex; |
2466 | maptex tex = pl_tex; |
… | |
… | |
2420 | for (x = 0; x < sw; x++) |
2494 | for (x = 0; x < sw; x++) |
2421 | if (row->c0 <= x + mx && x + mx < row->c1) |
2495 | if (row->c0 <= x + mx && x + mx < row->c1) |
2422 | { |
2496 | { |
2423 | mapcell *cell = row->col + (x + mx - row->c0); |
2497 | mapcell *cell = row->col + (x + mx - row->c0); |
2424 | |
2498 | |
2425 | int px = x * T; |
2499 | int px = x * Tw; |
2426 | int py = y * T; |
2500 | int py = y * Th; |
2427 | |
2501 | |
2428 | if (expect_false (cell->player == player)) |
2502 | if (expect_false (cell->player == player)) |
2429 | { |
2503 | { |
2430 | px += sdx; |
2504 | px += sdx; |
2431 | py += sdy; |
2505 | py += sdy; |
2432 | } |
2506 | } |
2433 | |
2507 | |
2434 | if (cell->stat_hp) |
2508 | if (cell->stat_hp) |
2435 | { |
2509 | { |
2436 | int width = cell->stat_width * T; |
2510 | int width = cell->stat_width * Tw; |
2437 | int thick = (sh * T / 32 + 27) / 28 + 1 + cell->stat_width; |
2511 | int thick = (sh * Th / 32 + 27) / 28 + 1 + cell->stat_width; |
2438 | |
2512 | |
2439 | glColor3ub (0, 0, 0); |
2513 | glColor3ub (0, 0, 0); |
2440 | glRectf (px + 1, py - thick - 2, |
2514 | glRectf (px + 1, py - thick - 2, |
2441 | px + width - 1, py); |
2515 | px + width - 1, py); |
2442 | |
2516 | |
… | |
… | |
2522 | int x, y; |
2596 | int x, y; |
2523 | int sw1 = sw + 2; |
2597 | int sw1 = sw + 2; |
2524 | int sh1 = sh + 2; |
2598 | int sh1 = sh + 2; |
2525 | int sh3 = sh * 3; |
2599 | int sh3 = sh * 3; |
2526 | int sw3 = sw * 3; |
2600 | int sw3 = sw * 3; |
2527 | uint8_t *darkness1 = (uint8_t *)malloc (sw1 * sh1); |
|
|
2528 | SV *darkness3_sv = sv_2mortal (newSV (sw3 * sh3)); |
2601 | SV *darkness3_sv = sv_2mortal (newSV (sw3 * sh3)); |
2529 | uint8_t *darkness3 = (uint8_t *)SvPVX (darkness3_sv); |
2602 | uint8_t *darkness3 = (uint8_t *)SvPVX (darkness3_sv); |
|
|
2603 | uint8_t *darkness1 = (uint8_t *)malloc (sw1 * sh1); |
|
|
2604 | memset (darkness1, 0, sw1*sh1); |
2530 | |
2605 | |
2531 | SvPOK_only (darkness3_sv); |
2606 | SvPOK_only (darkness3_sv); |
2532 | SvCUR_set (darkness3_sv, sw3 * sh3); |
2607 | SvCUR_set (darkness3_sv, sw3 * sh3); |
2533 | |
2608 | |
2534 | mx += self->x - 1; |
2609 | mx += self->x - 1; |
… | |
… | |
2660 | else |
2735 | else |
2661 | *data++ = 0; |
2736 | *data++ = 0; |
2662 | } |
2737 | } |
2663 | } |
2738 | } |
2664 | |
2739 | |
2665 | /* if size is w*h + 5 then no data has been found */ |
2740 | /* if size is w*h + 5 then no data has been found */ |
2666 | if (data - (uint8_t *)SvPVX (data_sv) != w * h + 5) |
2741 | if (data - (uint8_t *)SvPVX (data_sv) != w * h + 5) |
2667 | { |
2742 | { |
2668 | SvPOK_only (data_sv); |
2743 | SvPOK_only (data_sv); |
2669 | SvCUR_set (data_sv, data - (uint8_t *)SvPVX (data_sv)); |
2744 | SvCUR_set (data_sv, data - (uint8_t *)SvPVX (data_sv)); |
2670 | } |
2745 | } |
2671 | |
2746 | |
2672 | RETVAL = data_sv; |
2747 | RETVAL = data_sv; |
2673 | } |
2748 | } |
2674 | OUTPUT: |
2749 | OUTPUT: |
2675 | RETVAL |
2750 | RETVAL |
2676 | |
2751 | |
2677 | void |
2752 | void |
… | |
… | |
2684 | STRLEN len; |
2759 | STRLEN len; |
2685 | uint8_t *data, *end; |
2760 | uint8_t *data, *end; |
2686 | |
2761 | |
2687 | len = SvLEN (data_sv); |
2762 | len = SvLEN (data_sv); |
2688 | SvGROW (data_sv, len + 8); // reserve at least 7+ bytes more |
2763 | SvGROW (data_sv, len + 8); // reserve at least 7+ bytes more |
2689 | data = SvPVbyte_nolen (data_sv); |
2764 | data = (uint8_t *)SvPVbyte_nolen (data_sv); |
2690 | end = data + len + 8; |
2765 | end = data + len + 8; |
2691 | |
2766 | |
2692 | if (len < 5) |
2767 | if (len < 5) |
2693 | XSRETURN_EMPTY; |
2768 | XSRETURN_EMPTY; |
2694 | |
2769 | |
… | |
… | |
2755 | } |
2830 | } |
2756 | |
2831 | |
2757 | MODULE = Deliantra::Client PACKAGE = DC::RW |
2832 | MODULE = Deliantra::Client PACKAGE = DC::RW |
2758 | |
2833 | |
2759 | DC::RW |
2834 | DC::RW |
2760 | new (SV *class, SV *data_sv) |
2835 | new (SV *klass, SV *data_sv) |
2761 | CODE: |
2836 | CODE: |
2762 | { |
2837 | { |
2763 | STRLEN datalen; |
2838 | STRLEN datalen; |
2764 | char *data = SvPVbyte (data_sv, datalen); |
2839 | char *data = SvPVbyte (data_sv, datalen); |
2765 | |
2840 | |
… | |
… | |
2767 | } |
2842 | } |
2768 | OUTPUT: |
2843 | OUTPUT: |
2769 | RETVAL |
2844 | RETVAL |
2770 | |
2845 | |
2771 | DC::RW |
2846 | DC::RW |
2772 | new_from_file (SV *class, const char *path, const char *mode = "rb") |
2847 | new_from_file (SV *klass, const char *path, const char *mode = "rb") |
2773 | CODE: |
2848 | CODE: |
2774 | RETVAL = SDL_RWFromFile (path, mode); |
2849 | RETVAL = SDL_RWFromFile (path, mode); |
2775 | OUTPUT: |
2850 | OUTPUT: |
2776 | RETVAL |
2851 | RETVAL |
2777 | |
2852 | |
… | |
… | |
2795 | if (RETVAL < 0) |
2870 | if (RETVAL < 0) |
2796 | { |
2871 | { |
2797 | RETVAL = Mix_GroupOldest (-1); |
2872 | RETVAL = Mix_GroupOldest (-1); |
2798 | |
2873 | |
2799 | if (RETVAL < 0) |
2874 | if (RETVAL < 0) |
|
|
2875 | { |
|
|
2876 | // happens sometimes, maybe it just stopped playing(?) |
|
|
2877 | RETVAL = Mix_GroupAvailable (-1); |
|
|
2878 | |
|
|
2879 | if (RETVAL < 0) |
2800 | XSRETURN_UNDEF; |
2880 | XSRETURN_UNDEF; |
2801 | |
2881 | } |
|
|
2882 | else |
2802 | Mix_HaltChannel (RETVAL); |
2883 | Mix_HaltChannel (RETVAL); |
2803 | } |
2884 | } |
2804 | |
2885 | |
2805 | Mix_UnregisterAllEffects (RETVAL); |
2886 | Mix_UnregisterAllEffects (RETVAL); |
2806 | Mix_Volume (RETVAL, 128); |
2887 | Mix_Volume (RETVAL, 128); |
2807 | } |
2888 | } |
… | |
… | |
2867 | |
2948 | |
2868 | MODULE = Deliantra::Client PACKAGE = DC::MixChunk |
2949 | MODULE = Deliantra::Client PACKAGE = DC::MixChunk |
2869 | |
2950 | |
2870 | PROTOTYPES: DISABLE |
2951 | PROTOTYPES: DISABLE |
2871 | |
2952 | |
|
|
2953 | void |
|
|
2954 | decoders () |
|
|
2955 | PPCODE: |
|
|
2956 | #if SDL_MIXER_MAJOR_VERSION > 1 || SDL_MIXER_MINOR_VERSION > 2 || SDL_MIXER_PATCHLEVEL >= 10 |
|
|
2957 | int i, num = Mix_GetNumChunkDecoders (); |
|
|
2958 | EXTEND (SP, num); |
|
|
2959 | for (i = 0; i < num; ++i) |
|
|
2960 | PUSHs (sv_2mortal (newSVpv (Mix_GetChunkDecoder (i), 0))); |
|
|
2961 | #else |
|
|
2962 | XPUSHs (sv_2mortal (newSVpv ("(sdl mixer too old)", 0))); |
|
|
2963 | #endif |
|
|
2964 | |
2872 | DC::MixChunk |
2965 | DC::MixChunk |
2873 | new (SV *class, DC::RW rwops) |
2966 | new (SV *klass, DC::RW rwops) |
2874 | CODE: |
2967 | CODE: |
2875 | RETVAL = Mix_LoadWAV_RW (rwops, 1); |
2968 | RETVAL = Mix_LoadWAV_RW (rwops, 1); |
2876 | OUTPUT: |
2969 | OUTPUT: |
2877 | RETVAL |
2970 | RETVAL |
2878 | |
2971 | |
… | |
… | |
2908 | OUTPUT: |
3001 | OUTPUT: |
2909 | RETVAL |
3002 | RETVAL |
2910 | |
3003 | |
2911 | MODULE = Deliantra::Client PACKAGE = DC::MixMusic |
3004 | MODULE = Deliantra::Client PACKAGE = DC::MixMusic |
2912 | |
3005 | |
|
|
3006 | void |
|
|
3007 | decoders () |
|
|
3008 | PPCODE: |
|
|
3009 | #if SDL_MIXER_MAJOR_VERSION > 1 || SDL_MIXER_MINOR_VERSION > 2 || SDL_MIXER_PATCHLEVEL >= 10 |
|
|
3010 | int i, num = Mix_GetNumMusicDecoders (); |
|
|
3011 | EXTEND (SP, num); |
|
|
3012 | for (i = 0; i < num; ++i) |
|
|
3013 | PUSHs (sv_2mortal (newSVpv (Mix_GetMusicDecoder (i), 0))); |
|
|
3014 | #else |
|
|
3015 | XPUSHs (sv_2mortal (newSVpv ("(sdl mixer too old)", 0))); |
|
|
3016 | #endif |
|
|
3017 | |
2913 | int |
3018 | int |
2914 | volume (int volume = -1) |
3019 | volume (int volume = -1) |
2915 | PROTOTYPE: ;$ |
3020 | PROTOTYPE: ;$ |
2916 | CODE: |
3021 | CODE: |
2917 | if (items > 0) |
3022 | if (items > 0) |
… | |
… | |
2928 | void |
3033 | void |
2929 | halt () |
3034 | halt () |
2930 | CODE: |
3035 | CODE: |
2931 | Mix_HaltMusic (); |
3036 | Mix_HaltMusic (); |
2932 | |
3037 | |
|
|
3038 | int |
|
|
3039 | playing () |
|
|
3040 | CODE: |
|
|
3041 | RETVAL = Mix_PlayingMusic (); |
|
|
3042 | OUTPUT: |
|
|
3043 | RETVAL |
|
|
3044 | |
2933 | DC::MixMusic |
3045 | DC::MixMusic |
2934 | new (SV *class, DC::RW rwops) |
3046 | new (SV *klass, DC::RW rwops) |
2935 | CODE: |
3047 | CODE: |
2936 | RETVAL = Mix_LoadMUS_RW (rwops); |
3048 | RETVAL = Mix_LoadMUS_RW (rwops); |
2937 | OUTPUT: |
3049 | OUTPUT: |
2938 | RETVAL |
3050 | RETVAL |
2939 | |
3051 | |
… | |
… | |
3076 | const_iv (GL_FUNC_SUBTRACT), |
3188 | const_iv (GL_FUNC_SUBTRACT), |
3077 | const_iv (GL_FUNC_REVERSE_SUBTRACT), |
3189 | const_iv (GL_FUNC_REVERSE_SUBTRACT), |
3078 | # undef const_iv |
3190 | # undef const_iv |
3079 | }; |
3191 | }; |
3080 | |
3192 | |
3081 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
3193 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ > const_iv; civ--) |
3082 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
3194 | newCONSTSUB (stash, (char *)civ[-1].name, newSViv (civ[-1].iv)); |
3083 | |
3195 | |
3084 | texture_av = newAV (); |
3196 | texture_av = newAV (); |
3085 | AvREAL_off (texture_av); |
3197 | AvREAL_off (texture_av); |
3086 | } |
3198 | } |
3087 | |
3199 | |
… | |
… | |
3092 | gl.BlendFuncSeparateEXT = 0; |
3204 | gl.BlendFuncSeparateEXT = 0; |
3093 | |
3205 | |
3094 | void |
3206 | void |
3095 | apple_nvidia_bug (int enable) |
3207 | apple_nvidia_bug (int enable) |
3096 | |
3208 | |
3097 | char * |
3209 | const char * |
3098 | gl_vendor () |
3210 | gl_vendor () |
3099 | CODE: |
3211 | CODE: |
3100 | RETVAL = (char *)glGetString (GL_VENDOR); |
3212 | RETVAL = (const char *)glGetString (GL_VENDOR); |
3101 | OUTPUT: |
3213 | OUTPUT: |
3102 | RETVAL |
3214 | RETVAL |
3103 | |
3215 | |
3104 | char * |
3216 | const char * |
3105 | gl_version () |
3217 | gl_version () |
3106 | CODE: |
3218 | CODE: |
3107 | RETVAL = (char *)glGetString (GL_VERSION); |
3219 | RETVAL = (const char *)glGetString (GL_VERSION); |
3108 | OUTPUT: |
3220 | OUTPUT: |
3109 | RETVAL |
3221 | RETVAL |
3110 | |
3222 | |
3111 | char * |
3223 | const char * |
3112 | gl_extensions () |
3224 | gl_extensions () |
3113 | CODE: |
3225 | CODE: |
3114 | RETVAL = (char *)glGetString (GL_EXTENSIONS); |
3226 | RETVAL = (const char *)glGetString (GL_EXTENSIONS); |
3115 | OUTPUT: |
3227 | OUTPUT: |
3116 | RETVAL |
3228 | RETVAL |
3117 | |
3229 | |
3118 | const char *glGetString (GLenum pname) |
3230 | const char *glGetString (GLenum pname) |
|
|
3231 | CODE: |
|
|
3232 | RETVAL = (const char *)glGetString (pname); |
|
|
3233 | OUTPUT: |
|
|
3234 | RETVAL |
3119 | |
3235 | |
3120 | GLint glGetInteger (GLenum pname) |
3236 | GLint glGetInteger (GLenum pname) |
3121 | CODE: |
3237 | CODE: |
3122 | glGetIntegerv (pname, &RETVAL); |
3238 | glGetIntegerv (pname, &RETVAL); |
3123 | OUTPUT: |
3239 | OUTPUT: |
… | |
… | |
3130 | RETVAL |
3246 | RETVAL |
3131 | |
3247 | |
3132 | int glGetError () |
3248 | int glGetError () |
3133 | |
3249 | |
3134 | void glFinish () |
3250 | void glFinish () |
|
|
3251 | |
|
|
3252 | void glFlush () |
3135 | |
3253 | |
3136 | void glClear (int mask) |
3254 | void glClear (int mask) |
3137 | |
3255 | |
3138 | void glClearColor (float r, float g, float b, float a = 1.0) |
3256 | void glClearColor (float r, float g, float b, float a = 1.0) |
3139 | PROTOTYPE: @ |
3257 | PROTOTYPE: @ |
… | |
… | |
3324 | |
3442 | |
3325 | void |
3443 | void |
3326 | find_widget (SV *self, NV x, NV y) |
3444 | find_widget (SV *self, NV x, NV y) |
3327 | PPCODE: |
3445 | PPCODE: |
3328 | { |
3446 | { |
3329 | if (within_widget (self, x, y)) |
3447 | if (within_widget (self, x, y)) |
3330 | XPUSHs (self); |
3448 | XPUSHs (self); |
3331 | } |
3449 | } |
3332 | |
3450 | |
3333 | BOOT: |
3451 | BOOT: |
3334 | { |
3452 | { |
… | |
… | |
3342 | |
3460 | |
3343 | void |
3461 | void |
3344 | draw (SV *self) |
3462 | draw (SV *self) |
3345 | CODE: |
3463 | CODE: |
3346 | { |
3464 | { |
3347 | HV *hv; |
3465 | HV *hv; |
3348 | SV **svp; |
3466 | SV **svp; |
3349 | NV x, y, w, h; |
3467 | NV x, y, w, h; |
3350 | SV *draw_x_sv = GvSV (draw_x_gv); |
3468 | SV *draw_x_sv = GvSV (draw_x_gv); |
3351 | SV *draw_y_sv = GvSV (draw_y_gv); |
3469 | SV *draw_y_sv = GvSV (draw_y_gv); |
3352 | SV *draw_w_sv = GvSV (draw_w_gv); |
3470 | SV *draw_w_sv = GvSV (draw_w_gv); |
3353 | SV *draw_h_sv = GvSV (draw_h_gv); |
3471 | SV *draw_h_sv = GvSV (draw_h_gv); |