1 | #ifdef _WIN32 |
1 | #ifdef _WIN32 |
|
|
2 | # define WIN32_LEAN_AND_MEAN |
2 | # define _WIN32_WINNT 0x0500 // needed to get win2000 api calls |
3 | # define _WIN32_WINNT 0x0500 // needed to get win2000 api calls |
3 | # include <malloc.h> |
4 | # include <malloc.h> |
4 | # include <windows.h> |
5 | # include <windows.h> |
5 | # pragma warning(disable:4244) |
6 | # pragma warning(disable:4244) |
6 | #endif |
7 | #endif |
7 | |
8 | |
8 | #include "EXTERN.h" |
9 | #include "EXTERN.h" |
9 | #include "perl.h" |
10 | #include "perl.h" |
10 | #include "XSUB.h" |
11 | #include "XSUB.h" |
|
|
12 | |
|
|
13 | #ifdef _WIN32 |
|
|
14 | # undef pipe |
|
|
15 | #endif |
11 | |
16 | |
12 | #include <math.h> |
17 | #include <math.h> |
13 | #include <string.h> |
18 | #include <string.h> |
14 | #include <stdio.h> |
19 | #include <stdio.h> |
15 | #include <stdlib.h> |
20 | #include <stdlib.h> |
… | |
… | |
40 | typedef signed char int8_t; |
45 | typedef signed char int8_t; |
41 | typedef signed short int16_t; |
46 | typedef signed short int16_t; |
42 | typedef signed int int32_t; |
47 | typedef signed int int32_t; |
43 | #endif |
48 | #endif |
44 | |
49 | |
45 | #include "glext.h" |
|
|
46 | |
|
|
47 | #define OBJ_STR "\xef\xbf\xbc" /* U+FFFC, objetc replacement character */ |
50 | #define OBJ_STR "\xef\xbf\xbc" /* U+FFFC, objetc replacement character */ |
48 | |
51 | |
49 | #define FOW_DARKNESS 32 |
52 | #define FOW_DARKNESS 32 |
50 | |
53 | |
51 | #define MAP_EXTEND_X 32 |
54 | #define MAP_EXTEND_X 32 |
52 | #define MAP_EXTEND_Y 512 |
55 | #define MAP_EXTEND_Y 512 |
53 | |
56 | |
54 | #define MIN_FONT_HEIGHT 10 |
57 | #define MIN_FONT_HEIGHT 10 |
55 | |
58 | |
56 | #if 1 |
59 | #if 0 |
57 | # define PARACHUTE SDL_INIT_NOPARACHUTE |
60 | # define PARACHUTE SDL_INIT_NOPARACHUTE |
58 | #else |
61 | #else |
59 | # define PARACHUTE 0 |
62 | # define PARACHUTE 0 |
60 | #endif |
63 | #endif |
61 | |
64 | |
… | |
… | |
80 | |
83 | |
81 | #include "pango-font.c" |
84 | #include "pango-font.c" |
82 | #include "pango-fontmap.c" |
85 | #include "pango-fontmap.c" |
83 | #include "pango-render.c" |
86 | #include "pango-render.c" |
84 | |
87 | |
85 | typedef Mix_Chunk *CFClient__MixChunk; |
88 | typedef Mix_Chunk *CFPlus__MixChunk; |
86 | typedef Mix_Music *CFClient__MixMusic; |
89 | typedef Mix_Music *CFPlus__MixMusic; |
87 | |
90 | |
88 | typedef PangoFontDescription *CFClient__Font; |
91 | typedef PangoFontDescription *CFPlus__Font; |
89 | |
92 | |
90 | static int |
93 | static int |
91 | shape_attr_p (PangoLayoutRun *run) |
94 | shape_attr_p (PangoLayoutRun *run) |
92 | { |
95 | { |
93 | GSList *attrs = run->item->analysis.extra_attrs; |
96 | GSList *attrs = run->item->analysis.extra_attrs; |
… | |
… | |
107 | |
110 | |
108 | typedef struct cf_layout { |
111 | typedef struct cf_layout { |
109 | PangoLayout *pl; |
112 | PangoLayout *pl; |
110 | float r, g, b, a; // default color for rgba mode |
113 | float r, g, b, a; // default color for rgba mode |
111 | int base_height; |
114 | int base_height; |
112 | CFClient__Font font; |
115 | CFPlus__Font font; |
113 | } *CFClient__Layout; |
116 | } *CFPlus__Layout; |
114 | |
117 | |
115 | static CFClient__Font default_font; |
118 | static CFPlus__Font default_font; |
116 | static PangoContext *opengl_context; |
119 | static PangoContext *opengl_context; |
117 | static PangoFontMap *opengl_fontmap; |
120 | static PangoFontMap *opengl_fontmap; |
118 | |
121 | |
119 | static void |
122 | static void |
120 | substitute_func (FcPattern *pattern, gpointer data) |
123 | substitute_func (FcPattern *pattern, gpointer data) |
121 | { |
124 | { |
122 | FcPatternAddBool (pattern, FC_HINTING, 1); |
125 | FcPatternAddBool (pattern, FC_HINTING, 1); |
123 | #ifdef FC_HINT_STYLE |
126 | #ifdef FC_HINT_STYLE |
124 | FcPatternAddBool (pattern, FC_HINT_STYLE, FC_HINT_FULL); |
127 | FcPatternAddBool (pattern, FC_HINT_STYLE, FC_HINT_FULL); |
125 | #endif |
128 | #endif |
126 | #ifdef _WIN32 |
|
|
127 | FcPatternAddBool (pattern, FC_AUTOHINT, 1); |
|
|
128 | #else |
|
|
129 | FcPatternAddBool (pattern, FC_AUTOHINT, 0); |
129 | FcPatternAddBool (pattern, FC_AUTOHINT, 0); |
130 | #endif |
|
|
131 | } |
130 | } |
132 | |
131 | |
133 | static void |
132 | static void |
134 | layout_update_font (CFClient__Layout self) |
133 | layout_update_font (CFPlus__Layout self) |
135 | { |
134 | { |
136 | /* use a random scale factor to account for unknown descenders, 0.8 works |
135 | /* use a random scale factor to account for unknown descenders, 0.8 works |
137 | * reasonably well with bitstream vera |
136 | * reasonably well with bitstream vera |
138 | */ |
137 | */ |
139 | PangoFontDescription *font = self->font ? self->font : default_font; |
138 | PangoFontDescription *font = self->font ? self->font : default_font; |
… | |
… | |
143 | |
142 | |
144 | pango_layout_set_font_description (self->pl, font); |
143 | pango_layout_set_font_description (self->pl, font); |
145 | } |
144 | } |
146 | |
145 | |
147 | static void |
146 | static void |
148 | layout_get_pixel_size (CFClient__Layout self, int *w, int *h) |
147 | layout_get_pixel_size (CFPlus__Layout self, int *w, int *h) |
149 | { |
148 | { |
|
|
149 | PangoRectangle rect; |
|
|
150 | |
|
|
151 | // get_pixel_* wrongly rounds down |
150 | pango_layout_get_pixel_size (self->pl, w, h); |
152 | pango_layout_get_extents (self->pl, 0, &rect); |
151 | |
153 | |
152 | if (!*w) *w = 1; |
154 | rect.width = (rect.width + PANGO_SCALE - 1) / PANGO_SCALE; |
153 | if (!*h) *h = 1; |
155 | rect.height = (rect.height + PANGO_SCALE - 1) / PANGO_SCALE; |
154 | |
156 | |
155 | *w = (*w + 3) & ~3; |
157 | if (!rect.width) rect.width = 1; |
|
|
158 | if (!rect.height) rect.height = 1; |
|
|
159 | |
|
|
160 | *w = rect.width; |
|
|
161 | *h = rect.height; |
156 | } |
162 | } |
157 | |
163 | |
158 | typedef uint16_t mapface; |
164 | typedef uint16_t mapface; |
159 | |
165 | |
160 | typedef struct { |
166 | typedef struct { |
… | |
… | |
163 | float s, t; |
169 | float s, t; |
164 | uint8_t r, g, b, a; |
170 | uint8_t r, g, b, a; |
165 | } maptex; |
171 | } maptex; |
166 | |
172 | |
167 | typedef struct { |
173 | typedef struct { |
168 | int16_t darkness; |
174 | uint16_t darkness; |
169 | mapface face[3]; |
175 | mapface face[3]; |
|
|
176 | uint8_t stat_hp; |
170 | } mapcell; |
177 | } mapcell; |
171 | |
178 | |
172 | typedef struct { |
179 | typedef struct { |
173 | int32_t c0, c1; |
180 | int32_t c0, c1; |
174 | mapcell *col; |
181 | mapcell *col; |
… | |
… | |
183 | int texs; |
190 | int texs; |
184 | maptex *tex; |
191 | maptex *tex; |
185 | |
192 | |
186 | int32_t rows; |
193 | int32_t rows; |
187 | maprow *row; |
194 | maprow *row; |
188 | } *CFClient__Map; |
195 | } *CFPlus__Map; |
189 | |
196 | |
190 | static char * |
197 | static char * |
191 | prepend (char *ptr, int sze, int inc) |
198 | prepend (char *ptr, int sze, int inc) |
192 | { |
199 | { |
193 | char *p; |
200 | char *p; |
… | |
… | |
211 | |
218 | |
212 | #define Append(type,ptr,sze,inc) (ptr) = (type *)append ((char *)ptr, (sze) * sizeof (type), (inc) * sizeof (type)) |
219 | #define Append(type,ptr,sze,inc) (ptr) = (type *)append ((char *)ptr, (sze) * sizeof (type), (inc) * sizeof (type)) |
213 | #define Prepend(type,ptr,sze,inc) (ptr) = (type *)prepend ((char *)ptr, (sze) * sizeof (type), (inc) * sizeof (type)) |
220 | #define Prepend(type,ptr,sze,inc) (ptr) = (type *)prepend ((char *)ptr, (sze) * sizeof (type), (inc) * sizeof (type)) |
214 | |
221 | |
215 | static maprow * |
222 | static maprow * |
216 | map_get_row (CFClient__Map self, int y) |
223 | map_get_row (CFPlus__Map self, int y) |
217 | { |
224 | { |
218 | if (0 > y) |
225 | if (0 > y) |
219 | { |
226 | { |
220 | int extend = - y + MAP_EXTEND_Y; |
227 | int extend = - y + MAP_EXTEND_Y; |
221 | Prepend (maprow, self->row, self->rows, extend); |
228 | Prepend (maprow, self->row, self->rows, extend); |
… | |
… | |
259 | |
266 | |
260 | return row->col + (x - row->c0); |
267 | return row->col + (x - row->c0); |
261 | } |
268 | } |
262 | |
269 | |
263 | static mapcell * |
270 | static mapcell * |
264 | map_get_cell (CFClient__Map self, int x, int y) |
271 | map_get_cell (CFPlus__Map self, int x, int y) |
265 | { |
272 | { |
266 | return row_get_cell (map_get_row (self, y), x); |
273 | return row_get_cell (map_get_row (self, y), x); |
267 | } |
274 | } |
268 | |
275 | |
269 | static void |
276 | static void |
270 | map_clear (CFClient__Map self) |
277 | map_clear (CFPlus__Map self) |
271 | { |
278 | { |
272 | int r; |
279 | int r; |
273 | |
280 | |
274 | for (r = 0; r < self->rows; r++) |
281 | for (r = 0; r < self->rows; r++) |
275 | Safefree (self->row[r].col); |
282 | Safefree (self->row[r].col); |
… | |
… | |
283 | self->row = 0; |
290 | self->row = 0; |
284 | self->rows = 0; |
291 | self->rows = 0; |
285 | } |
292 | } |
286 | |
293 | |
287 | static void |
294 | static void |
288 | map_blank (CFClient__Map self, int x0, int y0, int w, int h) |
295 | map_blank (CFPlus__Map self, int x0, int y0, int w, int h) |
289 | { |
296 | { |
290 | int x, y; |
297 | int x, y; |
291 | maprow *row; |
298 | maprow *row; |
292 | |
299 | |
293 | for (y = y0; y < y0 + h; y++) |
300 | for (y = y0; y < y0 + h; y++) |
… | |
… | |
302 | if (x >= row->c0) |
309 | if (x >= row->c0) |
303 | { |
310 | { |
304 | if (x >= row->c1) |
311 | if (x >= row->c1) |
305 | break; |
312 | break; |
306 | |
313 | |
307 | row->col[x - row->c0].darkness = -1; |
314 | row->col[x - row->c0].darkness = 0; |
308 | } |
315 | } |
309 | } |
316 | } |
310 | } |
317 | } |
311 | |
318 | |
312 | static void |
319 | static void |
… | |
… | |
350 | n |= n >> 16; |
357 | n |= n >> 16; |
351 | |
358 | |
352 | return n + 1; |
359 | return n + 1; |
353 | } |
360 | } |
354 | |
361 | |
355 | MODULE = CFClient PACKAGE = CFClient |
362 | MODULE = CFPlus PACKAGE = CFPlus |
356 | |
363 | |
357 | PROTOTYPES: ENABLE |
364 | PROTOTYPES: ENABLE |
358 | |
365 | |
359 | BOOT: |
366 | BOOT: |
360 | { |
367 | { |
361 | HV *stash = gv_stashpv ("CFClient", 1); |
368 | HV *stash = gv_stashpv ("CFPlus", 1); |
362 | static const struct { |
369 | static const struct { |
363 | const char *name; |
370 | const char *name; |
364 | IV iv; |
371 | IV iv; |
365 | } *civ, const_iv[] = { |
372 | } *civ, const_iv[] = { |
366 | # define const_iv(name) { # name, (IV)name } |
373 | # define const_iv(name) { # name, (IV)name } |
… | |
… | |
467 | |
474 | |
468 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
475 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
469 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
476 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
470 | } |
477 | } |
471 | |
478 | |
|
|
479 | int |
|
|
480 | in_destruct () |
|
|
481 | CODE: |
|
|
482 | RETVAL = PL_main_cv == Nullcv; |
|
|
483 | OUTPUT: |
|
|
484 | RETVAL |
|
|
485 | |
472 | NV floor (NV x) |
486 | NV floor (NV x) |
473 | |
487 | |
474 | NV ceil (NV x) |
488 | NV ceil (NV x) |
475 | |
489 | |
476 | void |
490 | void |
… | |
… | |
506 | SDL_GL_SetAttribute (SDL_GL_ACCUM_GREEN_SIZE, 0); |
520 | SDL_GL_SetAttribute (SDL_GL_ACCUM_GREEN_SIZE, 0); |
507 | SDL_GL_SetAttribute (SDL_GL_ACCUM_BLUE_SIZE, 0); |
521 | SDL_GL_SetAttribute (SDL_GL_ACCUM_BLUE_SIZE, 0); |
508 | SDL_GL_SetAttribute (SDL_GL_ACCUM_ALPHA_SIZE, 0); |
522 | SDL_GL_SetAttribute (SDL_GL_ACCUM_ALPHA_SIZE, 0); |
509 | |
523 | |
510 | SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1); |
524 | SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1); |
|
|
525 | #if SDL_VERSION_ATLEAST(1,2,10) |
|
|
526 | SDL_GL_SetAttribute (SDL_GL_ACCELERATED_VISUAL, 1); |
|
|
527 | SDL_GL_SetAttribute (SDL_GL_SWAP_CONTROL, 1); |
|
|
528 | #endif |
511 | |
529 | |
512 | SDL_EnableUNICODE (1); |
530 | SDL_EnableUNICODE (1); |
513 | SDL_EnableKeyRepeat (SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); |
531 | SDL_EnableKeyRepeat (SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); |
514 | |
532 | |
515 | m = SDL_ListModes (0, SDL_FULLSCREEN | SDL_OPENGL); |
533 | m = SDL_ListModes (0, SDL_FULLSCREEN | SDL_OPENGL); |
… | |
… | |
602 | hv_store (hv, "data1", 5, newSViv ((IV)ev.user.data1), 0); |
620 | hv_store (hv, "data1", 5, newSViv ((IV)ev.user.data1), 0); |
603 | hv_store (hv, "data2", 5, newSViv ((IV)ev.user.data2), 0); |
621 | hv_store (hv, "data2", 5, newSViv ((IV)ev.user.data2), 0); |
604 | break; |
622 | break; |
605 | } |
623 | } |
606 | |
624 | |
607 | XPUSHs (sv_2mortal (newRV_noinc ((SV *)hv))); |
625 | XPUSHs (sv_2mortal (sv_bless (newRV_noinc ((SV *)hv), gv_stashpv ("CFPlus::UI::Event", 1)))); |
608 | } |
626 | } |
609 | } |
627 | } |
610 | |
628 | |
611 | int |
629 | int |
612 | Mix_OpenAudio (int frequency = 48000, int format = MIX_DEFAULT_FORMAT, int channels = 1, int chunksize = 2048) |
630 | Mix_OpenAudio (int frequency = 48000, int format = MIX_DEFAULT_FORMAT, int channels = 1, int chunksize = 2048) |
… | |
… | |
628 | #endif |
646 | #endif |
629 | |
647 | |
630 | void |
648 | void |
631 | add_font (char *file) |
649 | add_font (char *file) |
632 | CODE: |
650 | CODE: |
633 | FcConfigAppFontAddFile (0, (const FcChar8 *)file); /* no idea wether this is required */ |
651 | FcConfigAppFontAddFile (0, (const FcChar8 *)file); |
634 | |
652 | |
635 | void |
653 | void |
636 | load_image_inline (SV *image_) |
654 | load_image_inline (SV *image_) |
637 | ALIAS: |
655 | ALIAS: |
638 | load_image_file = 1 |
656 | load_image_file = 1 |
… | |
… | |
680 | |
698 | |
681 | surface2 = SDL_ConvertSurface (surface, &fmt, SDL_SWSURFACE); |
699 | surface2 = SDL_ConvertSurface (surface, &fmt, SDL_SWSURFACE); |
682 | |
700 | |
683 | assert (surface2->pitch == surface2->w * 4); |
701 | assert (surface2->pitch == surface2->w * 4); |
684 | |
702 | |
|
|
703 | SDL_LockSurface (surface2); |
685 | EXTEND (SP, 5); |
704 | EXTEND (SP, 6); |
686 | PUSHs (sv_2mortal (newSViv (surface2->w))); |
705 | PUSHs (sv_2mortal (newSViv (surface2->w))); |
687 | PUSHs (sv_2mortal (newSViv (surface2->h))); |
706 | PUSHs (sv_2mortal (newSViv (surface2->h))); |
688 | SDL_LockSurface (surface2); |
|
|
689 | PUSHs (sv_2mortal (newSVpvn (surface2->pixels, surface2->h * surface2->pitch))); |
707 | PUSHs (sv_2mortal (newSVpvn (surface2->pixels, surface2->h * surface2->pitch))); |
690 | SDL_UnlockSurface (surface2); |
|
|
691 | PUSHs (sv_2mortal (newSViv (surface->flags & (SDL_SRCCOLORKEY | SDL_SRCALPHA) ? GL_RGBA : GL_RGB))); |
708 | PUSHs (sv_2mortal (newSViv (surface->flags & (SDL_SRCCOLORKEY | SDL_SRCALPHA) ? GL_RGBA : GL_RGB))); |
692 | PUSHs (sv_2mortal (newSViv (GL_RGBA))); |
709 | PUSHs (sv_2mortal (newSViv (GL_RGBA))); |
693 | PUSHs (sv_2mortal (newSViv (GL_UNSIGNED_BYTE))); |
710 | PUSHs (sv_2mortal (newSViv (GL_UNSIGNED_BYTE))); |
|
|
711 | SDL_UnlockSurface (surface2); |
694 | |
712 | |
695 | SDL_FreeSurface (surface); |
713 | SDL_FreeSurface (surface); |
696 | SDL_FreeSurface (surface2); |
714 | SDL_FreeSurface (surface2); |
697 | } |
715 | } |
698 | |
716 | |
… | |
… | |
741 | void |
759 | void |
742 | _exit (int retval) |
760 | _exit (int retval) |
743 | CODE: |
761 | CODE: |
744 | _exit (retval); |
762 | _exit (retval); |
745 | |
763 | |
746 | MODULE = CFClient PACKAGE = CFClient::Font |
764 | MODULE = CFPlus PACKAGE = CFPlus::Font |
747 | |
765 | |
748 | CFClient::Font |
766 | CFPlus::Font |
749 | new_from_file (SV *class, char *path, int id = 0) |
767 | new_from_file (SV *class, char *path, int id = 0) |
750 | CODE: |
768 | CODE: |
751 | { |
769 | { |
752 | int count; |
770 | int count; |
753 | FcPattern *pattern = FcFreeTypeQuery ((const FcChar8 *)path, id, 0, &count); |
771 | FcPattern *pattern = FcFreeTypeQuery ((const FcChar8 *)path, id, 0, &count); |
… | |
… | |
756 | } |
774 | } |
757 | OUTPUT: |
775 | OUTPUT: |
758 | RETVAL |
776 | RETVAL |
759 | |
777 | |
760 | void |
778 | void |
761 | DESTROY (CFClient::Font self) |
779 | DESTROY (CFPlus::Font self) |
762 | CODE: |
780 | CODE: |
763 | pango_font_description_free (self); |
781 | pango_font_description_free (self); |
764 | |
782 | |
765 | void |
783 | void |
766 | make_default (CFClient::Font self) |
784 | make_default (CFPlus::Font self) |
767 | CODE: |
785 | CODE: |
768 | default_font = self; |
786 | default_font = self; |
769 | |
787 | |
770 | MODULE = CFClient PACKAGE = CFClient::Layout |
788 | MODULE = CFPlus PACKAGE = CFPlus::Layout |
771 | |
789 | |
772 | void |
790 | void |
773 | clear_font_cache () |
791 | reset_glyph_cache () |
774 | CODE: |
792 | CODE: |
775 | pango_fc_font_map_cache_clear ((PangoFcFontMap *)opengl_fontmap); |
|
|
776 | tc_clear (); |
793 | tc_clear (); |
777 | |
794 | |
778 | CFClient::Layout |
795 | CFPlus::Layout |
779 | new (SV *class, int type = 0) |
796 | new (SV *class) |
780 | CODE: |
797 | CODE: |
781 | New (0, RETVAL, 1, struct cf_layout); |
798 | New (0, RETVAL, 1, struct cf_layout); |
782 | |
799 | |
783 | RETVAL->pl = pango_layout_new (opengl_context); |
800 | RETVAL->pl = pango_layout_new (opengl_context); |
784 | RETVAL->r = 1.; |
801 | RETVAL->r = 1.; |
… | |
… | |
792 | layout_update_font (RETVAL); |
809 | layout_update_font (RETVAL); |
793 | OUTPUT: |
810 | OUTPUT: |
794 | RETVAL |
811 | RETVAL |
795 | |
812 | |
796 | void |
813 | void |
797 | DESTROY (CFClient::Layout self) |
814 | DESTROY (CFPlus::Layout self) |
798 | CODE: |
815 | CODE: |
799 | g_object_unref (self->pl); |
816 | g_object_unref (self->pl); |
800 | Safefree (self); |
817 | Safefree (self); |
801 | |
818 | |
802 | void |
819 | void |
803 | set_text (CFClient::Layout self, SV *text_) |
820 | set_text (CFPlus::Layout self, SV *text_) |
804 | CODE: |
821 | CODE: |
805 | { |
822 | { |
806 | STRLEN textlen; |
823 | STRLEN textlen; |
807 | char *text = SvPVutf8 (text_, textlen); |
824 | char *text = SvPVutf8 (text_, textlen); |
808 | |
825 | |
809 | pango_layout_set_text (self->pl, text, textlen); |
826 | pango_layout_set_text (self->pl, text, textlen); |
810 | } |
827 | } |
811 | |
828 | |
812 | void |
829 | void |
813 | set_markup (CFClient::Layout self, SV *text_) |
830 | set_markup (CFPlus::Layout self, SV *text_) |
814 | CODE: |
831 | CODE: |
815 | { |
832 | { |
816 | STRLEN textlen; |
833 | STRLEN textlen; |
817 | char *text = SvPVutf8 (text_, textlen); |
834 | char *text = SvPVutf8 (text_, textlen); |
818 | |
835 | |
819 | pango_layout_set_markup (self->pl, text, textlen); |
836 | pango_layout_set_markup (self->pl, text, textlen); |
820 | } |
837 | } |
821 | |
838 | |
822 | void |
839 | void |
823 | set_shapes (CFClient::Layout self, ...) |
840 | set_shapes (CFPlus::Layout self, ...) |
824 | CODE: |
841 | CODE: |
825 | { |
842 | { |
826 | PangoAttrList *attrs = 0; |
843 | PangoAttrList *attrs = 0; |
827 | const char *text = pango_layout_get_text (self->pl); |
844 | const char *text = pango_layout_get_text (self->pl); |
828 | const char *pos = text; |
845 | const char *pos = text; |
… | |
… | |
863 | if (attrs) |
880 | if (attrs) |
864 | pango_layout_set_attributes (self->pl, attrs); |
881 | pango_layout_set_attributes (self->pl, attrs); |
865 | } |
882 | } |
866 | |
883 | |
867 | void |
884 | void |
868 | get_shapes (CFClient::Layout self) |
885 | get_shapes (CFPlus::Layout self) |
869 | PPCODE: |
886 | PPCODE: |
870 | { |
887 | { |
871 | PangoLayoutIter *iter = pango_layout_get_iter (self->pl); |
888 | PangoLayoutIter *iter = pango_layout_get_iter (self->pl); |
872 | |
889 | |
873 | do |
890 | do |
… | |
… | |
877 | if (run && shape_attr_p (run)) |
894 | if (run && shape_attr_p (run)) |
878 | { |
895 | { |
879 | PangoRectangle extents; |
896 | PangoRectangle extents; |
880 | pango_layout_iter_get_run_extents (iter, 0, &extents); |
897 | pango_layout_iter_get_run_extents (iter, 0, &extents); |
881 | |
898 | |
|
|
899 | EXTEND (SP, 2); |
882 | PUSHs (sv_2mortal (newSViv (PANGO_PIXELS (extents.x)))); |
900 | PUSHs (sv_2mortal (newSViv (PANGO_PIXELS (extents.x)))); |
883 | PUSHs (sv_2mortal (newSViv (PANGO_PIXELS (extents.y)))); |
901 | PUSHs (sv_2mortal (newSViv (PANGO_PIXELS (extents.y)))); |
884 | } |
902 | } |
885 | } |
903 | } |
886 | while (pango_layout_iter_next_run (iter)); |
904 | while (pango_layout_iter_next_run (iter)); |
887 | |
905 | |
888 | pango_layout_iter_free (iter); |
906 | pango_layout_iter_free (iter); |
889 | } |
907 | } |
890 | |
908 | |
891 | int |
909 | int |
892 | has_wrapped (CFClient::Layout self) |
910 | has_wrapped (CFPlus::Layout self) |
893 | CODE: |
911 | CODE: |
894 | { |
912 | { |
895 | int lines = 1; |
913 | int lines = 1; |
896 | const char *text = pango_layout_get_text (self->pl); |
914 | const char *text = pango_layout_get_text (self->pl); |
897 | |
915 | |
… | |
… | |
902 | } |
920 | } |
903 | OUTPUT: |
921 | OUTPUT: |
904 | RETVAL |
922 | RETVAL |
905 | |
923 | |
906 | SV * |
924 | SV * |
907 | get_text (CFClient::Layout self) |
925 | get_text (CFPlus::Layout self) |
908 | CODE: |
926 | CODE: |
909 | RETVAL = newSVpv (pango_layout_get_text (self->pl), 0); |
927 | RETVAL = newSVpv (pango_layout_get_text (self->pl), 0); |
910 | sv_utf8_decode (RETVAL); |
928 | sv_utf8_decode (RETVAL); |
911 | OUTPUT: |
929 | OUTPUT: |
912 | RETVAL |
930 | RETVAL |
913 | |
931 | |
914 | void |
932 | void |
915 | set_foreground (CFClient::Layout self, float r, float g, float b, float a = 1.) |
933 | set_foreground (CFPlus::Layout self, float r, float g, float b, float a = 1.) |
916 | CODE: |
934 | CODE: |
917 | self->r = r; |
935 | self->r = r; |
918 | self->g = g; |
936 | self->g = g; |
919 | self->b = b; |
937 | self->b = b; |
920 | self->a = a; |
938 | self->a = a; |
921 | |
939 | |
922 | void |
940 | void |
923 | set_font (CFClient::Layout self, CFClient::Font font = 0) |
941 | set_font (CFPlus::Layout self, CFPlus::Font font = 0) |
924 | CODE: |
942 | CODE: |
925 | if (self->font != font) |
943 | if (self->font != font) |
926 | { |
944 | { |
927 | self->font = font; |
945 | self->font = font; |
928 | layout_update_font (self); |
946 | layout_update_font (self); |
929 | } |
947 | } |
930 | |
948 | |
931 | void |
949 | void |
932 | set_height (CFClient::Layout self, int base_height) |
950 | set_height (CFPlus::Layout self, int base_height) |
933 | CODE: |
951 | CODE: |
934 | if (self->base_height != base_height) |
952 | if (self->base_height != base_height) |
935 | { |
953 | { |
936 | self->base_height = base_height; |
954 | self->base_height = base_height; |
937 | layout_update_font (self); |
955 | layout_update_font (self); |
938 | } |
956 | } |
939 | |
957 | |
940 | void |
958 | void |
941 | set_width (CFClient::Layout self, int max_width = -1) |
959 | set_width (CFPlus::Layout self, int max_width = -1) |
942 | CODE: |
960 | CODE: |
943 | pango_layout_set_width (self->pl, max_width < 0 ? max_width : max_width * PANGO_SCALE); |
961 | pango_layout_set_width (self->pl, max_width < 0 ? max_width : max_width * PANGO_SCALE); |
944 | |
962 | |
945 | void |
963 | void |
946 | set_indent (CFClient::Layout self, int indent) |
964 | set_indent (CFPlus::Layout self, int indent) |
947 | CODE: |
965 | CODE: |
948 | pango_layout_set_indent (self->pl, indent * PANGO_SCALE); |
966 | pango_layout_set_indent (self->pl, indent * PANGO_SCALE); |
949 | |
967 | |
950 | void |
968 | void |
951 | set_spacing (CFClient::Layout self, int spacing) |
969 | set_spacing (CFPlus::Layout self, int spacing) |
952 | CODE: |
970 | CODE: |
953 | pango_layout_set_spacing (self->pl, spacing * PANGO_SCALE); |
971 | pango_layout_set_spacing (self->pl, spacing * PANGO_SCALE); |
954 | |
972 | |
955 | void |
973 | void |
956 | set_ellipsise (CFClient::Layout self, int ellipsise) |
974 | set_ellipsise (CFPlus::Layout self, int ellipsise) |
957 | CODE: |
975 | CODE: |
958 | pango_layout_set_ellipsize (self->pl, |
976 | pango_layout_set_ellipsize (self->pl, |
959 | ellipsise == 1 ? PANGO_ELLIPSIZE_START |
977 | ellipsise == 1 ? PANGO_ELLIPSIZE_START |
960 | : ellipsise == 2 ? PANGO_ELLIPSIZE_MIDDLE |
978 | : ellipsise == 2 ? PANGO_ELLIPSIZE_MIDDLE |
961 | : ellipsise == 3 ? PANGO_ELLIPSIZE_END |
979 | : ellipsise == 3 ? PANGO_ELLIPSIZE_END |
962 | : PANGO_ELLIPSIZE_NONE |
980 | : PANGO_ELLIPSIZE_NONE |
963 | ); |
981 | ); |
964 | |
982 | |
965 | void |
983 | void |
966 | set_single_paragraph_mode (CFClient::Layout self, int spm) |
984 | set_single_paragraph_mode (CFPlus::Layout self, int spm) |
967 | CODE: |
985 | CODE: |
968 | pango_layout_set_single_paragraph_mode (self->pl, !!spm); |
986 | pango_layout_set_single_paragraph_mode (self->pl, !!spm); |
969 | |
987 | |
970 | void |
988 | void |
971 | size (CFClient::Layout self) |
989 | size (CFPlus::Layout self) |
972 | PPCODE: |
990 | PPCODE: |
973 | { |
991 | { |
974 | int w, h; |
992 | int w, h; |
975 | |
993 | |
976 | layout_get_pixel_size (self, &w, &h); |
994 | layout_get_pixel_size (self, &w, &h); |
… | |
… | |
979 | PUSHs (sv_2mortal (newSViv (w))); |
997 | PUSHs (sv_2mortal (newSViv (w))); |
980 | PUSHs (sv_2mortal (newSViv (h))); |
998 | PUSHs (sv_2mortal (newSViv (h))); |
981 | } |
999 | } |
982 | |
1000 | |
983 | int |
1001 | int |
984 | descent (CFClient::Layout self) |
1002 | descent (CFPlus::Layout self) |
985 | CODE: |
1003 | CODE: |
986 | { |
1004 | { |
987 | PangoRectangle rect; |
1005 | PangoRectangle rect; |
988 | PangoLayoutLine *line = pango_layout_get_line (self->pl, 0); |
1006 | PangoLayoutLine *line = pango_layout_get_line (self->pl, 0); |
989 | pango_layout_line_get_pixel_extents (line, 0, &rect); |
1007 | pango_layout_line_get_pixel_extents (line, 0, &rect); |
… | |
… | |
991 | } |
1009 | } |
992 | OUTPUT: |
1010 | OUTPUT: |
993 | RETVAL |
1011 | RETVAL |
994 | |
1012 | |
995 | int |
1013 | int |
996 | xy_to_index (CFClient::Layout self, int x, int y) |
1014 | xy_to_index (CFPlus::Layout self, int x, int y) |
997 | CODE: |
1015 | CODE: |
998 | { |
1016 | { |
999 | int index, trailing; |
1017 | int index, trailing; |
1000 | pango_layout_xy_to_index (self->pl, x * PANGO_SCALE, y * PANGO_SCALE, &index, &trailing); |
1018 | pango_layout_xy_to_index (self->pl, x * PANGO_SCALE, y * PANGO_SCALE, &index, &trailing); |
1001 | RETVAL = index; |
1019 | RETVAL = index; |
1002 | } |
1020 | } |
1003 | OUTPUT: |
1021 | OUTPUT: |
1004 | RETVAL |
1022 | RETVAL |
1005 | |
1023 | |
1006 | void |
1024 | void |
1007 | cursor_pos (CFClient::Layout self, int index) |
1025 | cursor_pos (CFPlus::Layout self, int index) |
1008 | PPCODE: |
1026 | PPCODE: |
1009 | { |
1027 | { |
1010 | PangoRectangle strong_pos; |
1028 | PangoRectangle strong_pos; |
1011 | pango_layout_get_cursor_pos (self->pl, index, &strong_pos, 0); |
1029 | pango_layout_get_cursor_pos (self->pl, index, &strong_pos, 0); |
1012 | |
1030 | |
… | |
… | |
1015 | PUSHs (sv_2mortal (newSViv (strong_pos.y / PANGO_SCALE))); |
1033 | PUSHs (sv_2mortal (newSViv (strong_pos.y / PANGO_SCALE))); |
1016 | PUSHs (sv_2mortal (newSViv (strong_pos.height / PANGO_SCALE))); |
1034 | PUSHs (sv_2mortal (newSViv (strong_pos.height / PANGO_SCALE))); |
1017 | } |
1035 | } |
1018 | |
1036 | |
1019 | void |
1037 | void |
1020 | render (CFClient::Layout self, float x, float y) |
1038 | render (CFPlus::Layout self, float x, float y, int flags = 0) |
1021 | PPCODE: |
1039 | PPCODE: |
1022 | pango_opengl_render_layout_subpixel ( |
1040 | pango_opengl_render_layout_subpixel ( |
1023 | self->pl, |
1041 | self->pl, |
1024 | x * PANGO_SCALE, y * PANGO_SCALE, |
1042 | x * PANGO_SCALE, y * PANGO_SCALE, |
1025 | self->r, self->g, self->b, self->a |
1043 | self->r, self->g, self->b, self->a, |
|
|
1044 | flags |
1026 | ); |
1045 | ); |
1027 | |
1046 | |
1028 | MODULE = CFClient PACKAGE = CFClient::Texture |
1047 | MODULE = CFPlus PACKAGE = CFPlus::Texture |
1029 | |
1048 | |
1030 | void |
1049 | void |
1031 | pad2pot (SV *data_, SV *w_, SV *h_) |
1050 | pad2pot (SV *data_, SV *w_, SV *h_) |
1032 | CODE: |
1051 | CODE: |
1033 | { |
1052 | { |
… | |
… | |
1111 | glDisable (GL_ALPHA_TEST); |
1130 | glDisable (GL_ALPHA_TEST); |
1112 | glDisable (GL_BLEND); |
1131 | glDisable (GL_BLEND); |
1113 | } |
1132 | } |
1114 | } |
1133 | } |
1115 | |
1134 | |
1116 | MODULE = CFClient PACKAGE = CFClient::Map |
1135 | MODULE = CFPlus PACKAGE = CFPlus::Map |
1117 | |
1136 | |
1118 | CFClient::Map |
1137 | CFPlus::Map |
1119 | new (SV *class, int map_width, int map_height) |
1138 | new (SV *class, int map_width, int map_height) |
1120 | CODE: |
1139 | CODE: |
1121 | New (0, RETVAL, 1, struct map); |
1140 | New (0, RETVAL, 1, struct map); |
1122 | RETVAL->x = 0; |
1141 | RETVAL->x = 0; |
1123 | RETVAL->y = 0; |
1142 | RETVAL->y = 0; |
… | |
… | |
1133 | RETVAL->row = 0; |
1152 | RETVAL->row = 0; |
1134 | OUTPUT: |
1153 | OUTPUT: |
1135 | RETVAL |
1154 | RETVAL |
1136 | |
1155 | |
1137 | void |
1156 | void |
1138 | DESTROY (CFClient::Map self) |
1157 | DESTROY (CFPlus::Map self) |
1139 | CODE: |
1158 | CODE: |
1140 | { |
1159 | { |
1141 | map_clear (self); |
1160 | map_clear (self); |
1142 | Safefree (self->face); |
1161 | Safefree (self->face); |
1143 | Safefree (self->tex); |
1162 | Safefree (self->tex); |
1144 | Safefree (self); |
1163 | Safefree (self); |
1145 | } |
1164 | } |
1146 | |
1165 | |
1147 | void |
1166 | void |
1148 | clear (CFClient::Map self) |
1167 | clear (CFPlus::Map self) |
1149 | CODE: |
1168 | CODE: |
1150 | map_clear (self); |
1169 | map_clear (self); |
1151 | |
1170 | |
1152 | void |
1171 | void |
1153 | set_face (CFClient::Map self, int face, int texid) |
1172 | set_face (CFPlus::Map self, int face, int texid) |
1154 | CODE: |
1173 | CODE: |
1155 | { |
1174 | { |
1156 | while (self->faces <= face) |
1175 | while (self->faces <= face) |
1157 | { |
1176 | { |
1158 | Append (mapface, self->face, self->faces, self->faces); |
1177 | Append (mapface, self->face, self->faces, self->faces); |
… | |
… | |
1161 | |
1180 | |
1162 | self->face [face] = texid; |
1181 | self->face [face] = texid; |
1163 | } |
1182 | } |
1164 | |
1183 | |
1165 | void |
1184 | void |
1166 | set_texture (CFClient::Map self, int texid, int name, int w, int h, float s, float t, int r, int g, int b, int a) |
1185 | set_texture (CFPlus::Map self, int texid, int name, int w, int h, float s, float t, int r, int g, int b, int a) |
1167 | CODE: |
1186 | CODE: |
1168 | { |
1187 | { |
1169 | while (self->texs <= texid) |
1188 | while (self->texs <= texid) |
1170 | { |
1189 | { |
1171 | Append (maptex, self->tex, self->texs, self->texs); |
1190 | Append (maptex, self->tex, self->texs, self->texs); |
… | |
… | |
1195 | // from transparent color bleeding and ugly wrapping effects. |
1214 | // from transparent color bleeding and ugly wrapping effects. |
1196 | glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
1215 | glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
1197 | } |
1216 | } |
1198 | |
1217 | |
1199 | int |
1218 | int |
1200 | ox (CFClient::Map self) |
1219 | ox (CFPlus::Map self) |
1201 | ALIAS: |
1220 | ALIAS: |
1202 | oy = 1 |
1221 | oy = 1 |
1203 | x = 2 |
1222 | x = 2 |
1204 | y = 3 |
1223 | y = 3 |
1205 | w = 4 |
1224 | w = 4 |
… | |
… | |
1216 | } |
1235 | } |
1217 | OUTPUT: |
1236 | OUTPUT: |
1218 | RETVAL |
1237 | RETVAL |
1219 | |
1238 | |
1220 | void |
1239 | void |
1221 | scroll (CFClient::Map self, int dx, int dy) |
1240 | scroll (CFPlus::Map self, int dx, int dy) |
1222 | CODE: |
1241 | CODE: |
1223 | { |
1242 | { |
1224 | if (dx > 0) |
1243 | if (dx > 0) |
1225 | map_blank (self, self->x, self->y, dx - 1, self->h); |
1244 | map_blank (self, self->x, self->y, dx - 1, self->h); |
1226 | else if (dx < 0) |
1245 | else if (dx < 0) |
… | |
… | |
1242 | self->y += MAP_EXTEND_Y; |
1261 | self->y += MAP_EXTEND_Y; |
1243 | } |
1262 | } |
1244 | } |
1263 | } |
1245 | |
1264 | |
1246 | void |
1265 | void |
1247 | map1a_update (CFClient::Map self, SV *data_) |
1266 | map1a_update (CFPlus::Map self, SV *data_, int extmap) |
1248 | CODE: |
1267 | CODE: |
1249 | { |
1268 | { |
1250 | uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_); |
1269 | uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_); |
1251 | uint8_t *data_end = (uint8_t *)SvEND (data_); |
1270 | uint8_t *data_end = (uint8_t *)SvEND (data_); |
1252 | mapcell *cell; |
1271 | mapcell *cell; |
… | |
… | |
1261 | |
1280 | |
1262 | cell = map_get_cell (self, x, y); |
1281 | cell = map_get_cell (self, x, y); |
1263 | |
1282 | |
1264 | if (flags & 15) |
1283 | if (flags & 15) |
1265 | { |
1284 | { |
1266 | if (cell->darkness < 0) |
1285 | if (!cell->darkness) |
1267 | { |
1286 | { |
1268 | cell->darkness = 0; |
1287 | cell->darkness = 256; |
1269 | cell->face [0] = 0; |
1288 | cell->face [0] = 0; |
1270 | cell->face [1] = 0; |
1289 | cell->face [1] = 0; |
1271 | cell->face [2] = 0; |
1290 | cell->face [2] = 0; |
1272 | } |
1291 | } |
1273 | |
1292 | |
1274 | cell->darkness = flags & 8 ? *data++ : 255; |
|
|
1275 | |
|
|
1276 | //TODO: don't trust server data to be in-range(!) |
1293 | //TODO: don't trust server data to be in-range(!) |
|
|
1294 | |
|
|
1295 | if (flags & 8) |
|
|
1296 | { |
|
|
1297 | if (extmap) |
|
|
1298 | { |
|
|
1299 | uint8_t ext, cmd; |
|
|
1300 | |
|
|
1301 | do |
|
|
1302 | { |
|
|
1303 | ext = *data++; |
|
|
1304 | cmd = ext & 0x7f; |
|
|
1305 | |
|
|
1306 | if (ext < 4) |
|
|
1307 | cell->darkness = 255 - ext * 64 + 1; |
|
|
1308 | else if (ext == 5) // health |
|
|
1309 | cell->stat_hp = *data++; |
|
|
1310 | } |
|
|
1311 | while (cmd & 0x80); |
|
|
1312 | } |
|
|
1313 | else |
|
|
1314 | cell->darkness = *data++ + 1; |
|
|
1315 | } |
1277 | |
1316 | |
1278 | if (flags & 4) |
1317 | if (flags & 4) |
1279 | { |
1318 | { |
1280 | cell->face [0] = self->face [(data [0] << 8) + data [1]]; data += 2; |
1319 | cell->face [0] = self->face [(data [0] << 8) + data [1]]; data += 2; |
1281 | } |
1320 | } |
… | |
… | |
1289 | { |
1328 | { |
1290 | cell->face [2] = self->face [(data [0] << 8) + data [1]]; data += 2; |
1329 | cell->face [2] = self->face [(data [0] << 8) + data [1]]; data += 2; |
1291 | } |
1330 | } |
1292 | } |
1331 | } |
1293 | else |
1332 | else |
1294 | cell->darkness = -1; |
1333 | cell->darkness = 0; |
1295 | } |
1334 | } |
1296 | } |
1335 | } |
1297 | |
1336 | |
1298 | SV * |
1337 | SV * |
1299 | mapmap (CFClient::Map self, int x0, int y0, int w, int h) |
1338 | mapmap (CFPlus::Map self, int x0, int y0, int w, int h) |
1300 | CODE: |
1339 | CODE: |
1301 | { |
1340 | { |
1302 | int x1, x; |
1341 | int x1, x; |
1303 | int y1, y; |
1342 | int y1, y; |
1304 | int z; |
1343 | int z; |
… | |
… | |
1354 | } |
1393 | } |
1355 | OUTPUT: |
1394 | OUTPUT: |
1356 | RETVAL |
1395 | RETVAL |
1357 | |
1396 | |
1358 | void |
1397 | void |
1359 | draw (CFClient::Map self, int shift_x, int shift_y, int x0, int y0, int sw, int sh) |
1398 | draw (CFPlus::Map self, int shift_x, int shift_y, int x0, int y0, int sw, int sh) |
1360 | CODE: |
1399 | CODE: |
1361 | { |
1400 | { |
1362 | int vx, vy; |
1401 | int vx, vy; |
1363 | int x, y, z; |
1402 | int x, y, z; |
1364 | int last_name; |
1403 | int last_name; |
… | |
… | |
1429 | glDisable (GL_TEXTURE_2D); |
1468 | glDisable (GL_TEXTURE_2D); |
1430 | glDisable (GL_BLEND); |
1469 | glDisable (GL_BLEND); |
1431 | } |
1470 | } |
1432 | |
1471 | |
1433 | void |
1472 | void |
1434 | draw_magicmap (CFClient::Map self, int dx, int dy, int w, int h, unsigned char *data) |
1473 | draw_magicmap (CFPlus::Map self, int dx, int dy, int w, int h, unsigned char *data) |
1435 | CODE: |
1474 | CODE: |
1436 | { |
1475 | { |
1437 | static float color[16][3] = { |
1476 | static float color[16][3] = { |
1438 | { 0.00F, 0.00F, 0.00F }, |
1477 | { 0.00F, 0.00F, 0.00F }, |
1439 | { 1.00F, 1.00F, 1.00F }, |
1478 | { 1.00F, 1.00F, 1.00F }, |
… | |
… | |
1489 | glDisable (GL_BLEND); |
1528 | glDisable (GL_BLEND); |
1490 | glDisable (GL_TEXTURE_2D); |
1529 | glDisable (GL_TEXTURE_2D); |
1491 | } |
1530 | } |
1492 | |
1531 | |
1493 | void |
1532 | void |
1494 | fow_texture (CFClient::Map self, int shift_x, int shift_y, int x0, int y0, int sw, int sh) |
1533 | fow_texture (CFPlus::Map self, int shift_x, int shift_y, int x0, int y0, int sw, int sh) |
1495 | PPCODE: |
1534 | PPCODE: |
1496 | { |
1535 | { |
1497 | int vx, vy; |
1536 | int vx, vy; |
1498 | int x, y; |
1537 | int x, y; |
1499 | int sw4 = (sw + 3) & ~3; |
1538 | int sw4 = (sw + 3) & ~3; |
… | |
… | |
1515 | for (x = 0; x < sw; x++) |
1554 | for (x = 0; x < sw; x++) |
1516 | if (row->c0 <= x + vx && x + vx < row->c1) |
1555 | if (row->c0 <= x + vx && x + vx < row->c1) |
1517 | { |
1556 | { |
1518 | mapcell *cell = row->col + (x + vx - row->c0); |
1557 | mapcell *cell = row->col + (x + vx - row->c0); |
1519 | |
1558 | |
1520 | darkness[y * sw4 + x] = cell->darkness < 0 |
1559 | darkness[y * sw4 + x] = cell->darkness |
|
|
1560 | ? 255 - cell->darkness + 1 |
1521 | ? 255 - FOW_DARKNESS |
1561 | : 255 - FOW_DARKNESS; |
1522 | : 255 - cell->darkness; |
|
|
1523 | } |
1562 | } |
1524 | } |
1563 | } |
1525 | |
1564 | |
1526 | EXTEND (SP, 3); |
1565 | EXTEND (SP, 3); |
1527 | PUSHs (sv_2mortal (newSViv (sw4))); |
1566 | PUSHs (sv_2mortal (newSViv (sw4))); |
1528 | PUSHs (sv_2mortal (newSViv (sh))); |
1567 | PUSHs (sv_2mortal (newSViv (sh))); |
1529 | PUSHs (darkness_sv); |
1568 | PUSHs (darkness_sv); |
1530 | } |
1569 | } |
1531 | |
1570 | |
1532 | SV * |
1571 | SV * |
1533 | get_rect (CFClient::Map self, int x0, int y0, int w, int h) |
1572 | get_rect (CFPlus::Map self, int x0, int y0, int w, int h) |
1534 | CODE: |
1573 | CODE: |
1535 | { |
1574 | { |
1536 | int x, y, x1, y1; |
1575 | int x, y, x1, y1; |
1537 | SV *data_sv = newSV (w * h * 7 + 5); |
1576 | SV *data_sv = newSV (w * h * 7 + 5); |
1538 | uint8_t *data = (uint8_t *)SvPVX (data_sv); |
1577 | uint8_t *data = (uint8_t *)SvPVX (data_sv); |
… | |
… | |
1600 | } |
1639 | } |
1601 | OUTPUT: |
1640 | OUTPUT: |
1602 | RETVAL |
1641 | RETVAL |
1603 | |
1642 | |
1604 | void |
1643 | void |
1605 | set_rect (CFClient::Map self, int x0, int y0, uint8_t *data) |
1644 | set_rect (CFPlus::Map self, int x0, int y0, uint8_t *data) |
1606 | PPCODE: |
1645 | PPCODE: |
1607 | { |
1646 | { |
1608 | int x, y, z; |
1647 | int x, y, z; |
1609 | int w, h; |
1648 | int w, h; |
1610 | int x1, y1; |
1649 | int x1, y1; |
… | |
… | |
1642 | |
1681 | |
1643 | if (flags & 1) { face[0] = *data++ << 8; face[0] |= *data++; } |
1682 | if (flags & 1) { face[0] = *data++ << 8; face[0] |= *data++; } |
1644 | if (flags & 2) { face[1] = *data++ << 8; face[1] |= *data++; } |
1683 | if (flags & 2) { face[1] = *data++ << 8; face[1] |= *data++; } |
1645 | if (flags & 4) { face[2] = *data++ << 8; face[2] |= *data++; } |
1684 | if (flags & 4) { face[2] = *data++ << 8; face[2] |= *data++; } |
1646 | |
1685 | |
1647 | if (cell->darkness <= 0) |
1686 | if (cell->darkness <= 1) |
1648 | { |
1687 | { |
1649 | cell->darkness = -1; |
1688 | cell->darkness = 0; |
1650 | |
1689 | |
1651 | for (z = 0; z <= 2; z++) |
1690 | for (z = 0; z <= 2; z++) |
1652 | { |
1691 | { |
1653 | cell->face[z] = face[z]; |
1692 | cell->face[z] = face[z]; |
1654 | |
1693 | |
… | |
… | |
1659 | } |
1698 | } |
1660 | } |
1699 | } |
1661 | } |
1700 | } |
1662 | } |
1701 | } |
1663 | |
1702 | |
1664 | MODULE = CFClient PACKAGE = CFClient::MixChunk |
1703 | MODULE = CFPlus PACKAGE = CFPlus::MixChunk |
1665 | |
1704 | |
1666 | CFClient::MixChunk |
1705 | CFPlus::MixChunk |
1667 | new_from_file (SV *class, char *path) |
1706 | new_from_file (SV *class, char *path) |
1668 | CODE: |
1707 | CODE: |
1669 | RETVAL = Mix_LoadWAV (path); |
1708 | RETVAL = Mix_LoadWAV (path); |
1670 | OUTPUT: |
1709 | OUTPUT: |
1671 | RETVAL |
1710 | RETVAL |
1672 | |
1711 | |
1673 | void |
1712 | void |
1674 | DESTROY (CFClient::MixChunk self) |
1713 | DESTROY (CFPlus::MixChunk self) |
1675 | CODE: |
1714 | CODE: |
1676 | Mix_FreeChunk (self); |
1715 | Mix_FreeChunk (self); |
1677 | |
1716 | |
1678 | int |
1717 | int |
1679 | volume (CFClient::MixChunk self, int volume = -1) |
1718 | volume (CFPlus::MixChunk self, int volume = -1) |
1680 | CODE: |
1719 | CODE: |
1681 | RETVAL = Mix_VolumeChunk (self, volume); |
1720 | RETVAL = Mix_VolumeChunk (self, volume); |
1682 | OUTPUT: |
1721 | OUTPUT: |
1683 | RETVAL |
1722 | RETVAL |
1684 | |
1723 | |
1685 | int |
1724 | int |
1686 | play (CFClient::MixChunk self, int channel = -1, int loops = 0, int ticks = -1) |
1725 | play (CFPlus::MixChunk self, int channel = -1, int loops = 0, int ticks = -1) |
1687 | CODE: |
1726 | CODE: |
1688 | RETVAL = Mix_PlayChannelTimed (channel, self, loops, ticks); |
1727 | RETVAL = Mix_PlayChannelTimed (channel, self, loops, ticks); |
1689 | OUTPUT: |
1728 | OUTPUT: |
1690 | RETVAL |
1729 | RETVAL |
1691 | |
1730 | |
1692 | MODULE = CFClient PACKAGE = CFClient::MixMusic |
1731 | MODULE = CFPlus PACKAGE = CFPlus::MixMusic |
1693 | |
1732 | |
1694 | int |
1733 | int |
1695 | volume (int volume = -1) |
1734 | volume (int volume = -1) |
1696 | CODE: |
1735 | CODE: |
1697 | RETVAL = Mix_VolumeMusic (volume); |
1736 | RETVAL = Mix_VolumeMusic (volume); |
1698 | OUTPUT: |
1737 | OUTPUT: |
1699 | RETVAL |
1738 | RETVAL |
1700 | |
1739 | |
1701 | CFClient::MixMusic |
1740 | CFPlus::MixMusic |
1702 | new_from_file (SV *class, char *path) |
1741 | new_from_file (SV *class, char *path) |
1703 | CODE: |
1742 | CODE: |
1704 | RETVAL = Mix_LoadMUS (path); |
1743 | RETVAL = Mix_LoadMUS (path); |
1705 | OUTPUT: |
1744 | OUTPUT: |
1706 | RETVAL |
1745 | RETVAL |
1707 | |
1746 | |
1708 | void |
1747 | void |
1709 | DESTROY (CFClient::MixMusic self) |
1748 | DESTROY (CFPlus::MixMusic self) |
1710 | CODE: |
1749 | CODE: |
1711 | Mix_FreeMusic (self); |
1750 | Mix_FreeMusic (self); |
1712 | |
1751 | |
1713 | int |
1752 | int |
1714 | play (CFClient::MixMusic self, int loops = -1) |
1753 | play (CFPlus::MixMusic self, int loops = -1) |
1715 | CODE: |
1754 | CODE: |
1716 | RETVAL = Mix_PlayMusic (self, loops); |
1755 | RETVAL = Mix_PlayMusic (self, loops); |
1717 | OUTPUT: |
1756 | OUTPUT: |
1718 | RETVAL |
1757 | RETVAL |
1719 | |
1758 | |
1720 | MODULE = CFClient PACKAGE = CFClient::OpenGL |
1759 | MODULE = CFPlus PACKAGE = CFPlus::OpenGL |
1721 | |
1760 | |
1722 | BOOT: |
1761 | BOOT: |
1723 | { |
1762 | { |
1724 | HV *stash = gv_stashpv ("CFClient::OpenGL", 1); |
1763 | HV *stash = gv_stashpv ("CFPlus::OpenGL", 1); |
1725 | static const struct { |
1764 | static const struct { |
1726 | const char *name; |
1765 | const char *name; |
1727 | IV iv; |
1766 | IV iv; |
1728 | } *civ, const_iv[] = { |
1767 | } *civ, const_iv[] = { |
1729 | # define const_iv(name) { # name, (IV)name } |
1768 | # define const_iv(name) { # name, (IV)name } |
… | |
… | |
1792 | const_iv (GL_SEPARABLE_2D), |
1831 | const_iv (GL_SEPARABLE_2D), |
1793 | const_iv (GL_CONVOLUTION_2D), |
1832 | const_iv (GL_CONVOLUTION_2D), |
1794 | const_iv (GL_CONVOLUTION_BORDER_MODE), |
1833 | const_iv (GL_CONVOLUTION_BORDER_MODE), |
1795 | const_iv (GL_CONSTANT_BORDER), |
1834 | const_iv (GL_CONSTANT_BORDER), |
1796 | const_iv (GL_LINES), |
1835 | const_iv (GL_LINES), |
|
|
1836 | const_iv (GL_LINE_STRIP), |
1797 | const_iv (GL_LINE_LOOP), |
1837 | const_iv (GL_LINE_LOOP), |
1798 | const_iv (GL_QUADS), |
1838 | const_iv (GL_QUADS), |
1799 | const_iv (GL_QUAD_STRIP), |
1839 | const_iv (GL_QUAD_STRIP), |
1800 | const_iv (GL_TRIANGLES), |
1840 | const_iv (GL_TRIANGLES), |
1801 | const_iv (GL_TRIANGLE_STRIP), |
1841 | const_iv (GL_TRIANGLE_STRIP), |
… | |
… | |
1911 | r *= a; |
1951 | r *= a; |
1912 | g *= a; |
1952 | g *= a; |
1913 | b *= a; |
1953 | b *= a; |
1914 | } |
1954 | } |
1915 | // microsoft visual "c" rounds instead of truncating... |
1955 | // microsoft visual "c" rounds instead of truncating... |
1916 | glColor4ub (MIN ((int)(r * 256.f), 255), |
1956 | glColor4f (r, g, b, a); |
1917 | MIN ((int)(g * 256.f), 255), |
|
|
1918 | MIN ((int)(b * 256.f), 255), |
|
|
1919 | MIN ((int)(a * 256.f), 255)); |
|
|
1920 | |
1957 | |
1921 | void glInterleavedArrays (int format, int stride, char *data) |
1958 | void glInterleavedArrays (int format, int stride, char *data) |
1922 | |
1959 | |
1923 | void glDrawElements (int mode, int count, int type, char *indices) |
1960 | void glDrawElements (int mode, int count, int type, char *indices) |
1924 | |
1961 | |
… | |
… | |
2001 | |
2038 | |
2002 | void glEndList () |
2039 | void glEndList () |
2003 | |
2040 | |
2004 | void glCallList (int list) |
2041 | void glCallList (int list) |
2005 | |
2042 | |
2006 | |
|
|