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 |
… | |
… | |
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) |
… | |
… | |
125 | #endif |
128 | #endif |
126 | FcPatternAddBool (pattern, FC_AUTOHINT, 0); |
129 | FcPatternAddBool (pattern, FC_AUTOHINT, 0); |
127 | } |
130 | } |
128 | |
131 | |
129 | static void |
132 | static void |
130 | layout_update_font (CFClient__Layout self) |
133 | layout_update_font (CFPlus__Layout self) |
131 | { |
134 | { |
132 | /* 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 |
133 | * reasonably well with bitstream vera |
136 | * reasonably well with bitstream vera |
134 | */ |
137 | */ |
135 | PangoFontDescription *font = self->font ? self->font : default_font; |
138 | PangoFontDescription *font = self->font ? self->font : default_font; |
… | |
… | |
139 | |
142 | |
140 | pango_layout_set_font_description (self->pl, font); |
143 | pango_layout_set_font_description (self->pl, font); |
141 | } |
144 | } |
142 | |
145 | |
143 | static void |
146 | static void |
144 | layout_get_pixel_size (CFClient__Layout self, int *w, int *h) |
147 | layout_get_pixel_size (CFPlus__Layout self, int *w, int *h) |
145 | { |
148 | { |
|
|
149 | PangoRectangle rect; |
|
|
150 | |
|
|
151 | // get_pixel_* wrongly rounds down |
146 | pango_layout_get_pixel_size (self->pl, w, h); |
152 | pango_layout_get_extents (self->pl, 0, &rect); |
147 | |
153 | |
148 | if (!*w) *w = 1; |
154 | rect.width = (rect.width + PANGO_SCALE - 1) / PANGO_SCALE; |
149 | if (!*h) *h = 1; |
155 | rect.height = (rect.height + PANGO_SCALE - 1) / PANGO_SCALE; |
150 | |
156 | |
151 | *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; |
152 | } |
162 | } |
153 | |
163 | |
154 | typedef uint16_t mapface; |
164 | typedef uint16_t mapface; |
155 | |
165 | |
156 | typedef struct { |
166 | typedef struct { |
… | |
… | |
159 | float s, t; |
169 | float s, t; |
160 | uint8_t r, g, b, a; |
170 | uint8_t r, g, b, a; |
161 | } maptex; |
171 | } maptex; |
162 | |
172 | |
163 | typedef struct { |
173 | typedef struct { |
164 | int16_t darkness; |
174 | uint32_t player; |
165 | mapface face[3]; |
175 | mapface face[3]; |
|
|
176 | uint16_t darkness; |
|
|
177 | uint8_t stat_width, stat_hp, flags; |
166 | } mapcell; |
178 | } mapcell; |
167 | |
179 | |
168 | typedef struct { |
180 | typedef struct { |
169 | int32_t c0, c1; |
181 | int32_t c0, c1; |
170 | mapcell *col; |
182 | mapcell *col; |
… | |
… | |
179 | int texs; |
191 | int texs; |
180 | maptex *tex; |
192 | maptex *tex; |
181 | |
193 | |
182 | int32_t rows; |
194 | int32_t rows; |
183 | maprow *row; |
195 | maprow *row; |
184 | } *CFClient__Map; |
196 | } *CFPlus__Map; |
185 | |
197 | |
186 | static char * |
198 | static char * |
187 | prepend (char *ptr, int sze, int inc) |
199 | prepend (char *ptr, int sze, int inc) |
188 | { |
200 | { |
189 | char *p; |
201 | char *p; |
… | |
… | |
207 | |
219 | |
208 | #define Append(type,ptr,sze,inc) (ptr) = (type *)append ((char *)ptr, (sze) * sizeof (type), (inc) * sizeof (type)) |
220 | #define Append(type,ptr,sze,inc) (ptr) = (type *)append ((char *)ptr, (sze) * sizeof (type), (inc) * sizeof (type)) |
209 | #define Prepend(type,ptr,sze,inc) (ptr) = (type *)prepend ((char *)ptr, (sze) * sizeof (type), (inc) * sizeof (type)) |
221 | #define Prepend(type,ptr,sze,inc) (ptr) = (type *)prepend ((char *)ptr, (sze) * sizeof (type), (inc) * sizeof (type)) |
210 | |
222 | |
211 | static maprow * |
223 | static maprow * |
212 | map_get_row (CFClient__Map self, int y) |
224 | map_get_row (CFPlus__Map self, int y) |
213 | { |
225 | { |
214 | if (0 > y) |
226 | if (0 > y) |
215 | { |
227 | { |
216 | int extend = - y + MAP_EXTEND_Y; |
228 | int extend = - y + MAP_EXTEND_Y; |
217 | Prepend (maprow, self->row, self->rows, extend); |
229 | Prepend (maprow, self->row, self->rows, extend); |
… | |
… | |
255 | |
267 | |
256 | return row->col + (x - row->c0); |
268 | return row->col + (x - row->c0); |
257 | } |
269 | } |
258 | |
270 | |
259 | static mapcell * |
271 | static mapcell * |
260 | map_get_cell (CFClient__Map self, int x, int y) |
272 | map_get_cell (CFPlus__Map self, int x, int y) |
261 | { |
273 | { |
262 | return row_get_cell (map_get_row (self, y), x); |
274 | return row_get_cell (map_get_row (self, y), x); |
263 | } |
275 | } |
264 | |
276 | |
265 | static void |
277 | static void |
266 | map_clear (CFClient__Map self) |
278 | map_clear (CFPlus__Map self) |
267 | { |
279 | { |
268 | int r; |
280 | int r; |
269 | |
281 | |
270 | for (r = 0; r < self->rows; r++) |
282 | for (r = 0; r < self->rows; r++) |
271 | Safefree (self->row[r].col); |
283 | Safefree (self->row[r].col); |
… | |
… | |
279 | self->row = 0; |
291 | self->row = 0; |
280 | self->rows = 0; |
292 | self->rows = 0; |
281 | } |
293 | } |
282 | |
294 | |
283 | static void |
295 | static void |
284 | map_blank (CFClient__Map self, int x0, int y0, int w, int h) |
296 | map_blank (CFPlus__Map self, int x0, int y0, int w, int h) |
285 | { |
297 | { |
286 | int x, y; |
298 | int x, y; |
287 | maprow *row; |
299 | maprow *row; |
|
|
300 | mapcell *cell; |
288 | |
301 | |
289 | for (y = y0; y < y0 + h; y++) |
302 | for (y = y0; y < y0 + h; y++) |
290 | if (y >= 0) |
303 | if (y >= 0) |
291 | { |
304 | { |
292 | if (y >= self->rows) |
305 | if (y >= self->rows) |
… | |
… | |
298 | if (x >= row->c0) |
311 | if (x >= row->c0) |
299 | { |
312 | { |
300 | if (x >= row->c1) |
313 | if (x >= row->c1) |
301 | break; |
314 | break; |
302 | |
315 | |
303 | row->col[x - row->c0].darkness = -1; |
316 | cell = row->col + x - row->c0; |
|
|
317 | |
|
|
318 | cell->darkness = 0; |
|
|
319 | cell->stat_hp = 0; |
|
|
320 | cell->flags = 0; |
|
|
321 | cell->player = 0; |
304 | } |
322 | } |
305 | } |
323 | } |
306 | } |
324 | } |
307 | |
325 | |
308 | static void |
326 | static void |
… | |
… | |
346 | n |= n >> 16; |
364 | n |= n >> 16; |
347 | |
365 | |
348 | return n + 1; |
366 | return n + 1; |
349 | } |
367 | } |
350 | |
368 | |
351 | MODULE = CFClient PACKAGE = CFClient |
369 | MODULE = CFPlus PACKAGE = CFPlus |
352 | |
370 | |
353 | PROTOTYPES: ENABLE |
371 | PROTOTYPES: ENABLE |
354 | |
372 | |
355 | BOOT: |
373 | BOOT: |
356 | { |
374 | { |
357 | HV *stash = gv_stashpv ("CFClient", 1); |
375 | HV *stash = gv_stashpv ("CFPlus", 1); |
358 | static const struct { |
376 | static const struct { |
359 | const char *name; |
377 | const char *name; |
360 | IV iv; |
378 | IV iv; |
361 | } *civ, const_iv[] = { |
379 | } *civ, const_iv[] = { |
362 | # define const_iv(name) { # name, (IV)name } |
380 | # define const_iv(name) { # name, (IV)name } |
… | |
… | |
509 | SDL_GL_SetAttribute (SDL_GL_ACCUM_GREEN_SIZE, 0); |
527 | SDL_GL_SetAttribute (SDL_GL_ACCUM_GREEN_SIZE, 0); |
510 | SDL_GL_SetAttribute (SDL_GL_ACCUM_BLUE_SIZE, 0); |
528 | SDL_GL_SetAttribute (SDL_GL_ACCUM_BLUE_SIZE, 0); |
511 | SDL_GL_SetAttribute (SDL_GL_ACCUM_ALPHA_SIZE, 0); |
529 | SDL_GL_SetAttribute (SDL_GL_ACCUM_ALPHA_SIZE, 0); |
512 | |
530 | |
513 | SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1); |
531 | SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1); |
|
|
532 | #if SDL_VERSION_ATLEAST(1,2,10) |
|
|
533 | SDL_GL_SetAttribute (SDL_GL_ACCELERATED_VISUAL, 1); |
|
|
534 | SDL_GL_SetAttribute (SDL_GL_SWAP_CONTROL, 1); |
|
|
535 | #endif |
514 | |
536 | |
515 | SDL_EnableUNICODE (1); |
537 | SDL_EnableUNICODE (1); |
516 | SDL_EnableKeyRepeat (SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); |
538 | SDL_EnableKeyRepeat (SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); |
517 | |
539 | |
518 | m = SDL_ListModes (0, SDL_FULLSCREEN | SDL_OPENGL); |
540 | m = SDL_ListModes (0, SDL_FULLSCREEN | SDL_OPENGL); |
… | |
… | |
605 | hv_store (hv, "data1", 5, newSViv ((IV)ev.user.data1), 0); |
627 | hv_store (hv, "data1", 5, newSViv ((IV)ev.user.data1), 0); |
606 | hv_store (hv, "data2", 5, newSViv ((IV)ev.user.data2), 0); |
628 | hv_store (hv, "data2", 5, newSViv ((IV)ev.user.data2), 0); |
607 | break; |
629 | break; |
608 | } |
630 | } |
609 | |
631 | |
610 | XPUSHs (sv_2mortal (newRV_noinc ((SV *)hv))); |
632 | XPUSHs (sv_2mortal (sv_bless (newRV_noinc ((SV *)hv), gv_stashpv ("CFPlus::UI::Event", 1)))); |
611 | } |
633 | } |
612 | } |
634 | } |
613 | |
635 | |
614 | int |
636 | int |
615 | Mix_OpenAudio (int frequency = 48000, int format = MIX_DEFAULT_FORMAT, int channels = 1, int chunksize = 2048) |
637 | Mix_OpenAudio (int frequency = 48000, int format = MIX_DEFAULT_FORMAT, int channels = 1, int chunksize = 2048) |
… | |
… | |
744 | void |
766 | void |
745 | _exit (int retval) |
767 | _exit (int retval) |
746 | CODE: |
768 | CODE: |
747 | _exit (retval); |
769 | _exit (retval); |
748 | |
770 | |
749 | MODULE = CFClient PACKAGE = CFClient::Font |
771 | MODULE = CFPlus PACKAGE = CFPlus::Font |
750 | |
772 | |
751 | CFClient::Font |
773 | CFPlus::Font |
752 | new_from_file (SV *class, char *path, int id = 0) |
774 | new_from_file (SV *class, char *path, int id = 0) |
753 | CODE: |
775 | CODE: |
754 | { |
776 | { |
755 | int count; |
777 | int count; |
756 | FcPattern *pattern = FcFreeTypeQuery ((const FcChar8 *)path, id, 0, &count); |
778 | FcPattern *pattern = FcFreeTypeQuery ((const FcChar8 *)path, id, 0, &count); |
… | |
… | |
759 | } |
781 | } |
760 | OUTPUT: |
782 | OUTPUT: |
761 | RETVAL |
783 | RETVAL |
762 | |
784 | |
763 | void |
785 | void |
764 | DESTROY (CFClient::Font self) |
786 | DESTROY (CFPlus::Font self) |
765 | CODE: |
787 | CODE: |
766 | pango_font_description_free (self); |
788 | pango_font_description_free (self); |
767 | |
789 | |
768 | void |
790 | void |
769 | make_default (CFClient::Font self) |
791 | make_default (CFPlus::Font self) |
770 | CODE: |
792 | CODE: |
771 | default_font = self; |
793 | default_font = self; |
772 | |
794 | |
773 | MODULE = CFClient PACKAGE = CFClient::Layout |
795 | MODULE = CFPlus PACKAGE = CFPlus::Layout |
774 | |
796 | |
775 | void |
797 | void |
776 | reset_glyph_cache () |
798 | reset_glyph_cache () |
777 | CODE: |
799 | CODE: |
778 | tc_clear (); |
800 | tc_clear (); |
779 | |
801 | |
780 | CFClient::Layout |
802 | CFPlus::Layout |
781 | new (SV *class) |
803 | new (SV *class) |
782 | CODE: |
804 | CODE: |
783 | New (0, RETVAL, 1, struct cf_layout); |
805 | New (0, RETVAL, 1, struct cf_layout); |
784 | |
806 | |
785 | RETVAL->pl = pango_layout_new (opengl_context); |
807 | RETVAL->pl = pango_layout_new (opengl_context); |
… | |
… | |
794 | layout_update_font (RETVAL); |
816 | layout_update_font (RETVAL); |
795 | OUTPUT: |
817 | OUTPUT: |
796 | RETVAL |
818 | RETVAL |
797 | |
819 | |
798 | void |
820 | void |
799 | DESTROY (CFClient::Layout self) |
821 | DESTROY (CFPlus::Layout self) |
800 | CODE: |
822 | CODE: |
801 | g_object_unref (self->pl); |
823 | g_object_unref (self->pl); |
802 | Safefree (self); |
824 | Safefree (self); |
803 | |
825 | |
804 | void |
826 | void |
805 | set_text (CFClient::Layout self, SV *text_) |
827 | set_text (CFPlus::Layout self, SV *text_) |
806 | CODE: |
828 | CODE: |
807 | { |
829 | { |
808 | STRLEN textlen; |
830 | STRLEN textlen; |
809 | char *text = SvPVutf8 (text_, textlen); |
831 | char *text = SvPVutf8 (text_, textlen); |
810 | |
832 | |
811 | pango_layout_set_text (self->pl, text, textlen); |
833 | pango_layout_set_text (self->pl, text, textlen); |
812 | } |
834 | } |
813 | |
835 | |
814 | void |
836 | void |
815 | set_markup (CFClient::Layout self, SV *text_) |
837 | set_markup (CFPlus::Layout self, SV *text_) |
816 | CODE: |
838 | CODE: |
817 | { |
839 | { |
818 | STRLEN textlen; |
840 | STRLEN textlen; |
819 | char *text = SvPVutf8 (text_, textlen); |
841 | char *text = SvPVutf8 (text_, textlen); |
820 | |
842 | |
821 | pango_layout_set_markup (self->pl, text, textlen); |
843 | pango_layout_set_markup (self->pl, text, textlen); |
822 | } |
844 | } |
823 | |
845 | |
824 | void |
846 | void |
825 | set_shapes (CFClient::Layout self, ...) |
847 | set_shapes (CFPlus::Layout self, ...) |
826 | CODE: |
848 | CODE: |
827 | { |
849 | { |
828 | PangoAttrList *attrs = 0; |
850 | PangoAttrList *attrs = 0; |
829 | const char *text = pango_layout_get_text (self->pl); |
851 | const char *text = pango_layout_get_text (self->pl); |
830 | const char *pos = text; |
852 | const char *pos = text; |
… | |
… | |
865 | if (attrs) |
887 | if (attrs) |
866 | pango_layout_set_attributes (self->pl, attrs); |
888 | pango_layout_set_attributes (self->pl, attrs); |
867 | } |
889 | } |
868 | |
890 | |
869 | void |
891 | void |
870 | get_shapes (CFClient::Layout self) |
892 | get_shapes (CFPlus::Layout self) |
871 | PPCODE: |
893 | PPCODE: |
872 | { |
894 | { |
873 | PangoLayoutIter *iter = pango_layout_get_iter (self->pl); |
895 | PangoLayoutIter *iter = pango_layout_get_iter (self->pl); |
874 | |
896 | |
875 | do |
897 | do |
… | |
… | |
890 | |
912 | |
891 | pango_layout_iter_free (iter); |
913 | pango_layout_iter_free (iter); |
892 | } |
914 | } |
893 | |
915 | |
894 | int |
916 | int |
895 | has_wrapped (CFClient::Layout self) |
917 | has_wrapped (CFPlus::Layout self) |
896 | CODE: |
918 | CODE: |
897 | { |
919 | { |
898 | int lines = 1; |
920 | int lines = 1; |
899 | const char *text = pango_layout_get_text (self->pl); |
921 | const char *text = pango_layout_get_text (self->pl); |
900 | |
922 | |
… | |
… | |
905 | } |
927 | } |
906 | OUTPUT: |
928 | OUTPUT: |
907 | RETVAL |
929 | RETVAL |
908 | |
930 | |
909 | SV * |
931 | SV * |
910 | get_text (CFClient::Layout self) |
932 | get_text (CFPlus::Layout self) |
911 | CODE: |
933 | CODE: |
912 | RETVAL = newSVpv (pango_layout_get_text (self->pl), 0); |
934 | RETVAL = newSVpv (pango_layout_get_text (self->pl), 0); |
913 | sv_utf8_decode (RETVAL); |
935 | sv_utf8_decode (RETVAL); |
914 | OUTPUT: |
936 | OUTPUT: |
915 | RETVAL |
937 | RETVAL |
916 | |
938 | |
917 | void |
939 | void |
918 | set_foreground (CFClient::Layout self, float r, float g, float b, float a = 1.) |
940 | set_foreground (CFPlus::Layout self, float r, float g, float b, float a = 1.) |
919 | CODE: |
941 | CODE: |
920 | self->r = r; |
942 | self->r = r; |
921 | self->g = g; |
943 | self->g = g; |
922 | self->b = b; |
944 | self->b = b; |
923 | self->a = a; |
945 | self->a = a; |
924 | |
946 | |
925 | void |
947 | void |
926 | set_font (CFClient::Layout self, CFClient::Font font = 0) |
948 | set_font (CFPlus::Layout self, CFPlus::Font font = 0) |
927 | CODE: |
949 | CODE: |
928 | if (self->font != font) |
950 | if (self->font != font) |
929 | { |
951 | { |
930 | self->font = font; |
952 | self->font = font; |
931 | layout_update_font (self); |
953 | layout_update_font (self); |
932 | } |
954 | } |
933 | |
955 | |
934 | void |
956 | void |
935 | set_height (CFClient::Layout self, int base_height) |
957 | set_height (CFPlus::Layout self, int base_height) |
936 | CODE: |
958 | CODE: |
937 | if (self->base_height != base_height) |
959 | if (self->base_height != base_height) |
938 | { |
960 | { |
939 | self->base_height = base_height; |
961 | self->base_height = base_height; |
940 | layout_update_font (self); |
962 | layout_update_font (self); |
941 | } |
963 | } |
942 | |
964 | |
943 | void |
965 | void |
944 | set_width (CFClient::Layout self, int max_width = -1) |
966 | set_width (CFPlus::Layout self, int max_width = -1) |
945 | CODE: |
967 | CODE: |
946 | pango_layout_set_width (self->pl, max_width < 0 ? max_width : max_width * PANGO_SCALE); |
968 | pango_layout_set_width (self->pl, max_width < 0 ? max_width : max_width * PANGO_SCALE); |
947 | |
969 | |
948 | void |
970 | void |
949 | set_indent (CFClient::Layout self, int indent) |
971 | set_indent (CFPlus::Layout self, int indent) |
950 | CODE: |
972 | CODE: |
951 | pango_layout_set_indent (self->pl, indent * PANGO_SCALE); |
973 | pango_layout_set_indent (self->pl, indent * PANGO_SCALE); |
952 | |
974 | |
953 | void |
975 | void |
954 | set_spacing (CFClient::Layout self, int spacing) |
976 | set_spacing (CFPlus::Layout self, int spacing) |
955 | CODE: |
977 | CODE: |
956 | pango_layout_set_spacing (self->pl, spacing * PANGO_SCALE); |
978 | pango_layout_set_spacing (self->pl, spacing * PANGO_SCALE); |
957 | |
979 | |
958 | void |
980 | void |
959 | set_ellipsise (CFClient::Layout self, int ellipsise) |
981 | set_ellipsise (CFPlus::Layout self, int ellipsise) |
960 | CODE: |
982 | CODE: |
961 | pango_layout_set_ellipsize (self->pl, |
983 | pango_layout_set_ellipsize (self->pl, |
962 | ellipsise == 1 ? PANGO_ELLIPSIZE_START |
984 | ellipsise == 1 ? PANGO_ELLIPSIZE_START |
963 | : ellipsise == 2 ? PANGO_ELLIPSIZE_MIDDLE |
985 | : ellipsise == 2 ? PANGO_ELLIPSIZE_MIDDLE |
964 | : ellipsise == 3 ? PANGO_ELLIPSIZE_END |
986 | : ellipsise == 3 ? PANGO_ELLIPSIZE_END |
965 | : PANGO_ELLIPSIZE_NONE |
987 | : PANGO_ELLIPSIZE_NONE |
966 | ); |
988 | ); |
967 | |
989 | |
968 | void |
990 | void |
969 | set_single_paragraph_mode (CFClient::Layout self, int spm) |
991 | set_single_paragraph_mode (CFPlus::Layout self, int spm) |
970 | CODE: |
992 | CODE: |
971 | pango_layout_set_single_paragraph_mode (self->pl, !!spm); |
993 | pango_layout_set_single_paragraph_mode (self->pl, !!spm); |
972 | |
994 | |
973 | void |
995 | void |
974 | size (CFClient::Layout self) |
996 | size (CFPlus::Layout self) |
975 | PPCODE: |
997 | PPCODE: |
976 | { |
998 | { |
977 | int w, h; |
999 | int w, h; |
978 | |
1000 | |
979 | layout_get_pixel_size (self, &w, &h); |
1001 | layout_get_pixel_size (self, &w, &h); |
… | |
… | |
982 | PUSHs (sv_2mortal (newSViv (w))); |
1004 | PUSHs (sv_2mortal (newSViv (w))); |
983 | PUSHs (sv_2mortal (newSViv (h))); |
1005 | PUSHs (sv_2mortal (newSViv (h))); |
984 | } |
1006 | } |
985 | |
1007 | |
986 | int |
1008 | int |
987 | descent (CFClient::Layout self) |
1009 | descent (CFPlus::Layout self) |
988 | CODE: |
1010 | CODE: |
989 | { |
1011 | { |
990 | PangoRectangle rect; |
1012 | PangoRectangle rect; |
991 | PangoLayoutLine *line = pango_layout_get_line (self->pl, 0); |
1013 | PangoLayoutLine *line = pango_layout_get_line (self->pl, 0); |
992 | pango_layout_line_get_pixel_extents (line, 0, &rect); |
1014 | pango_layout_line_get_pixel_extents (line, 0, &rect); |
… | |
… | |
994 | } |
1016 | } |
995 | OUTPUT: |
1017 | OUTPUT: |
996 | RETVAL |
1018 | RETVAL |
997 | |
1019 | |
998 | int |
1020 | int |
999 | xy_to_index (CFClient::Layout self, int x, int y) |
1021 | xy_to_index (CFPlus::Layout self, int x, int y) |
1000 | CODE: |
1022 | CODE: |
1001 | { |
1023 | { |
1002 | int index, trailing; |
1024 | int index, trailing; |
1003 | pango_layout_xy_to_index (self->pl, x * PANGO_SCALE, y * PANGO_SCALE, &index, &trailing); |
1025 | pango_layout_xy_to_index (self->pl, x * PANGO_SCALE, y * PANGO_SCALE, &index, &trailing); |
1004 | RETVAL = index; |
1026 | RETVAL = index; |
1005 | } |
1027 | } |
1006 | OUTPUT: |
1028 | OUTPUT: |
1007 | RETVAL |
1029 | RETVAL |
1008 | |
1030 | |
1009 | void |
1031 | void |
1010 | cursor_pos (CFClient::Layout self, int index) |
1032 | cursor_pos (CFPlus::Layout self, int index) |
1011 | PPCODE: |
1033 | PPCODE: |
1012 | { |
1034 | { |
1013 | PangoRectangle strong_pos; |
1035 | PangoRectangle strong_pos; |
1014 | pango_layout_get_cursor_pos (self->pl, index, &strong_pos, 0); |
1036 | pango_layout_get_cursor_pos (self->pl, index, &strong_pos, 0); |
1015 | |
1037 | |
… | |
… | |
1018 | PUSHs (sv_2mortal (newSViv (strong_pos.y / PANGO_SCALE))); |
1040 | PUSHs (sv_2mortal (newSViv (strong_pos.y / PANGO_SCALE))); |
1019 | PUSHs (sv_2mortal (newSViv (strong_pos.height / PANGO_SCALE))); |
1041 | PUSHs (sv_2mortal (newSViv (strong_pos.height / PANGO_SCALE))); |
1020 | } |
1042 | } |
1021 | |
1043 | |
1022 | void |
1044 | void |
1023 | render (CFClient::Layout self, float x, float y) |
1045 | render (CFPlus::Layout self, float x, float y, int flags = 0) |
1024 | PPCODE: |
1046 | PPCODE: |
1025 | pango_opengl_render_layout_subpixel ( |
1047 | pango_opengl_render_layout_subpixel ( |
1026 | self->pl, |
1048 | self->pl, |
1027 | x * PANGO_SCALE, y * PANGO_SCALE, |
1049 | x * PANGO_SCALE, y * PANGO_SCALE, |
1028 | self->r, self->g, self->b, self->a |
1050 | self->r, self->g, self->b, self->a, |
|
|
1051 | flags |
1029 | ); |
1052 | ); |
1030 | |
1053 | |
1031 | MODULE = CFClient PACKAGE = CFClient::Texture |
1054 | MODULE = CFPlus PACKAGE = CFPlus::Texture |
1032 | |
1055 | |
1033 | void |
1056 | void |
1034 | pad2pot (SV *data_, SV *w_, SV *h_) |
1057 | pad2pot (SV *data_, SV *w_, SV *h_) |
1035 | CODE: |
1058 | CODE: |
1036 | { |
1059 | { |
… | |
… | |
1114 | glDisable (GL_ALPHA_TEST); |
1137 | glDisable (GL_ALPHA_TEST); |
1115 | glDisable (GL_BLEND); |
1138 | glDisable (GL_BLEND); |
1116 | } |
1139 | } |
1117 | } |
1140 | } |
1118 | |
1141 | |
1119 | MODULE = CFClient PACKAGE = CFClient::Map |
1142 | MODULE = CFPlus PACKAGE = CFPlus::Map |
1120 | |
1143 | |
1121 | CFClient::Map |
1144 | CFPlus::Map |
1122 | new (SV *class, int map_width, int map_height) |
1145 | new (SV *class, int map_width, int map_height) |
1123 | CODE: |
1146 | CODE: |
1124 | New (0, RETVAL, 1, struct map); |
1147 | New (0, RETVAL, 1, struct map); |
1125 | RETVAL->x = 0; |
1148 | RETVAL->x = 0; |
1126 | RETVAL->y = 0; |
1149 | RETVAL->y = 0; |
… | |
… | |
1136 | RETVAL->row = 0; |
1159 | RETVAL->row = 0; |
1137 | OUTPUT: |
1160 | OUTPUT: |
1138 | RETVAL |
1161 | RETVAL |
1139 | |
1162 | |
1140 | void |
1163 | void |
1141 | DESTROY (CFClient::Map self) |
1164 | DESTROY (CFPlus::Map self) |
1142 | CODE: |
1165 | CODE: |
1143 | { |
1166 | { |
1144 | map_clear (self); |
1167 | map_clear (self); |
1145 | Safefree (self->face); |
1168 | Safefree (self->face); |
1146 | Safefree (self->tex); |
1169 | Safefree (self->tex); |
1147 | Safefree (self); |
1170 | Safefree (self); |
1148 | } |
1171 | } |
1149 | |
1172 | |
1150 | void |
1173 | void |
1151 | clear (CFClient::Map self) |
1174 | clear (CFPlus::Map self) |
1152 | CODE: |
1175 | CODE: |
1153 | map_clear (self); |
1176 | map_clear (self); |
1154 | |
1177 | |
1155 | void |
1178 | void |
1156 | set_face (CFClient::Map self, int face, int texid) |
1179 | set_face (CFPlus::Map self, int face, int texid) |
1157 | CODE: |
1180 | CODE: |
1158 | { |
1181 | { |
1159 | while (self->faces <= face) |
1182 | while (self->faces <= face) |
1160 | { |
1183 | { |
1161 | Append (mapface, self->face, self->faces, self->faces); |
1184 | Append (mapface, self->face, self->faces, self->faces); |
… | |
… | |
1164 | |
1187 | |
1165 | self->face [face] = texid; |
1188 | self->face [face] = texid; |
1166 | } |
1189 | } |
1167 | |
1190 | |
1168 | void |
1191 | void |
1169 | 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) |
1192 | 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) |
1170 | CODE: |
1193 | CODE: |
1171 | { |
1194 | { |
1172 | while (self->texs <= texid) |
1195 | while (self->texs <= texid) |
1173 | { |
1196 | { |
1174 | Append (maptex, self->tex, self->texs, self->texs); |
1197 | Append (maptex, self->tex, self->texs, self->texs); |
… | |
… | |
1198 | // from transparent color bleeding and ugly wrapping effects. |
1221 | // from transparent color bleeding and ugly wrapping effects. |
1199 | glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
1222 | glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
1200 | } |
1223 | } |
1201 | |
1224 | |
1202 | int |
1225 | int |
1203 | ox (CFClient::Map self) |
1226 | ox (CFPlus::Map self) |
1204 | ALIAS: |
1227 | ALIAS: |
1205 | oy = 1 |
1228 | oy = 1 |
1206 | x = 2 |
1229 | x = 2 |
1207 | y = 3 |
1230 | y = 3 |
1208 | w = 4 |
1231 | w = 4 |
… | |
… | |
1219 | } |
1242 | } |
1220 | OUTPUT: |
1243 | OUTPUT: |
1221 | RETVAL |
1244 | RETVAL |
1222 | |
1245 | |
1223 | void |
1246 | void |
1224 | scroll (CFClient::Map self, int dx, int dy) |
1247 | scroll (CFPlus::Map self, int dx, int dy) |
1225 | CODE: |
1248 | CODE: |
1226 | { |
1249 | { |
1227 | if (dx > 0) |
1250 | if (dx > 0) |
1228 | map_blank (self, self->x, self->y, dx - 1, self->h); |
1251 | map_blank (self, self->x, self->y, dx, self->h); |
1229 | else if (dx < 0) |
1252 | else if (dx < 0) |
1230 | map_blank (self, self->x + self->w + dx + 1, self->y, 1 - dx, self->h); |
1253 | map_blank (self, self->x + self->w + dx + 1, self->y, -dx, self->h); |
1231 | |
1254 | |
1232 | if (dy > 0) |
1255 | if (dy > 0) |
1233 | map_blank (self, self->x, self->y, self->w, dy - 1); |
1256 | map_blank (self, self->x, self->y, self->w, dy); |
1234 | else if (dy < 0) |
1257 | else if (dy < 0) |
1235 | map_blank (self, self->x, self->y + self->h + dy + 1, self->w, 1 - dy); |
1258 | map_blank (self, self->x, self->y + self->h + dy + 1, self->w, -dy); |
1236 | |
1259 | |
1237 | self->ox += dx; self->x += dx; |
1260 | self->ox += dx; self->x += dx; |
1238 | self->oy += dy; self->y += dy; |
1261 | self->oy += dy; self->y += dy; |
1239 | |
1262 | |
1240 | while (self->y < 0) |
1263 | while (self->y < 0) |
… | |
… | |
1245 | self->y += MAP_EXTEND_Y; |
1268 | self->y += MAP_EXTEND_Y; |
1246 | } |
1269 | } |
1247 | } |
1270 | } |
1248 | |
1271 | |
1249 | void |
1272 | void |
1250 | map1a_update (CFClient::Map self, SV *data_) |
1273 | map1a_update (CFPlus::Map self, SV *data_, int extmap) |
1251 | CODE: |
1274 | CODE: |
1252 | { |
1275 | { |
1253 | uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_); |
1276 | uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_); |
1254 | uint8_t *data_end = (uint8_t *)SvEND (data_); |
1277 | uint8_t *data_end = (uint8_t *)SvEND (data_); |
1255 | mapcell *cell; |
1278 | mapcell *cell; |
1256 | int x, y, flags; |
1279 | int x, y, flags; |
1257 | |
1280 | |
1258 | while (data < data_end) |
1281 | while (data < data_end - 1) |
1259 | { |
1282 | { |
1260 | flags = (data [0] << 8) + data [1]; data += 2; |
1283 | flags = (data [0] << 8) + data [1]; data += 2; |
1261 | |
1284 | |
1262 | x = self->x + ((flags >> 10) & 63); |
1285 | x = self->x + ((flags >> 10) & 63); |
1263 | y = self->y + ((flags >> 4) & 63); |
1286 | y = self->y + ((flags >> 4) & 63); |
1264 | |
1287 | |
1265 | cell = map_get_cell (self, x, y); |
1288 | cell = map_get_cell (self, x, y); |
1266 | |
1289 | |
1267 | if (flags & 15) |
1290 | if (flags & 15) |
1268 | { |
1291 | { |
1269 | if (cell->darkness < 0) |
1292 | if (!cell->darkness) |
1270 | { |
1293 | { |
|
|
1294 | memset (cell, 0, sizeof (*cell)); |
1271 | cell->darkness = 0; |
1295 | cell->darkness = 256; |
1272 | cell->face [0] = 0; |
|
|
1273 | cell->face [1] = 0; |
|
|
1274 | cell->face [2] = 0; |
|
|
1275 | } |
1296 | } |
1276 | |
1297 | |
1277 | cell->darkness = flags & 8 ? *data++ : 255; |
|
|
1278 | |
|
|
1279 | //TODO: don't trust server data to be in-range(!) |
1298 | //TODO: don't trust server data to be in-range(!) |
|
|
1299 | |
|
|
1300 | if (flags & 8) |
|
|
1301 | { |
|
|
1302 | if (extmap) |
|
|
1303 | { |
|
|
1304 | uint8_t ext, cmd; |
|
|
1305 | |
|
|
1306 | do |
|
|
1307 | { |
|
|
1308 | ext = *data++; |
|
|
1309 | cmd = ext & 0x3f; |
|
|
1310 | |
|
|
1311 | if (cmd < 4) |
|
|
1312 | cell->darkness = 255 - ext * 64 + 1; |
|
|
1313 | else if (cmd == 5) // health |
|
|
1314 | { |
|
|
1315 | cell->stat_width = 1; |
|
|
1316 | cell->stat_hp = *data++; |
|
|
1317 | } |
|
|
1318 | else if (cmd == 6) // monster width |
|
|
1319 | cell->stat_width = *data++ + 1; |
|
|
1320 | else if (cmd == 0x47) // monster width |
|
|
1321 | { |
|
|
1322 | if (*data == 4) |
|
|
1323 | ; // decode player tag |
|
|
1324 | |
|
|
1325 | data += *data + 1; |
|
|
1326 | } |
|
|
1327 | else if (cmd == 8) // cell flags |
|
|
1328 | cell->flags = *data++; |
|
|
1329 | else if (ext & 0x40) // unknown, multibyte => skip |
|
|
1330 | data += *data + 1; |
|
|
1331 | else |
|
|
1332 | data++; |
|
|
1333 | } |
|
|
1334 | while (ext & 0x80); |
|
|
1335 | } |
|
|
1336 | else |
|
|
1337 | cell->darkness = *data++ + 1; |
|
|
1338 | |
|
|
1339 | } |
1280 | |
1340 | |
1281 | if (flags & 4) |
1341 | if (flags & 4) |
1282 | { |
1342 | { |
1283 | cell->face [0] = self->face [(data [0] << 8) + data [1]]; data += 2; |
1343 | cell->face [0] = self->face [(data [0] << 8) + data [1]]; data += 2; |
1284 | } |
1344 | } |
… | |
… | |
1292 | { |
1352 | { |
1293 | cell->face [2] = self->face [(data [0] << 8) + data [1]]; data += 2; |
1353 | cell->face [2] = self->face [(data [0] << 8) + data [1]]; data += 2; |
1294 | } |
1354 | } |
1295 | } |
1355 | } |
1296 | else |
1356 | else |
|
|
1357 | { |
1297 | cell->darkness = -1; |
1358 | cell->darkness = 0; |
|
|
1359 | cell->stat_hp = 0; |
|
|
1360 | cell->flags = 0; |
|
|
1361 | cell->player = 0; |
|
|
1362 | } |
1298 | } |
1363 | } |
1299 | } |
1364 | } |
1300 | |
1365 | |
1301 | SV * |
1366 | SV * |
1302 | mapmap (CFClient::Map self, int x0, int y0, int w, int h) |
1367 | mapmap (CFPlus::Map self, int x0, int y0, int w, int h) |
1303 | CODE: |
1368 | CODE: |
1304 | { |
1369 | { |
1305 | int x1, x; |
1370 | int x1, x; |
1306 | int y1, y; |
1371 | int y1, y; |
1307 | int z; |
1372 | int z; |
… | |
… | |
1357 | } |
1422 | } |
1358 | OUTPUT: |
1423 | OUTPUT: |
1359 | RETVAL |
1424 | RETVAL |
1360 | |
1425 | |
1361 | void |
1426 | void |
1362 | draw (CFClient::Map self, int shift_x, int shift_y, int x0, int y0, int sw, int sh) |
1427 | draw (CFPlus::Map self, int shift_x, int shift_y, int x0, int y0, int sw, int sh) |
1363 | CODE: |
1428 | CODE: |
1364 | { |
1429 | { |
1365 | int vx, vy; |
1430 | int vx, vy; |
1366 | int x, y, z; |
1431 | int x, y, z; |
1367 | int last_name; |
1432 | int last_name; |
… | |
… | |
1402 | { |
1467 | { |
1403 | mapcell *cell = row->col + (x + vx - row->c0); |
1468 | mapcell *cell = row->col + (x + vx - row->c0); |
1404 | |
1469 | |
1405 | face = cell->face [z]; |
1470 | face = cell->face [z]; |
1406 | |
1471 | |
1407 | if (face) |
1472 | if (face && face < self->texs) |
1408 | { |
1473 | { |
1409 | maptex tex = self->tex [face]; |
1474 | maptex tex = self->tex [face]; |
1410 | |
|
|
1411 | int px = (x + 1) * 32 - tex.w; |
1475 | int px = (x + 1) * 32 - tex.w; |
1412 | int py = (y + 1) * 32 - tex.h; |
1476 | int py = (y + 1) * 32 - tex.h; |
1413 | |
1477 | |
1414 | if (last_name != tex.name) |
1478 | if (last_name != tex.name) |
1415 | { |
1479 | { |
1416 | glEnd (); |
1480 | glEnd (); |
1417 | last_name = tex.name; |
|
|
1418 | glBindTexture (GL_TEXTURE_2D, last_name); |
1481 | glBindTexture (GL_TEXTURE_2D, last_name = tex.name); |
1419 | glBegin (GL_QUADS); |
1482 | glBegin (GL_QUADS); |
1420 | } |
1483 | } |
1421 | |
1484 | |
1422 | glTexCoord2f (0 , 0 ); glVertex2f (px , py ); |
1485 | glTexCoord2f (0 , 0 ); glVertex2f (px , py ); |
1423 | glTexCoord2f (0 , tex.t); glVertex2f (px , py + tex.h); |
1486 | glTexCoord2f (0 , tex.t); glVertex2f (px , py + tex.h); |
1424 | glTexCoord2f (tex.s, tex.t); glVertex2f (px + tex.w, py + tex.h); |
1487 | glTexCoord2f (tex.s, tex.t); glVertex2f (px + tex.w, py + tex.h); |
1425 | glTexCoord2f (tex.s, 0 ); glVertex2f (px + tex.w, py ); |
1488 | glTexCoord2f (tex.s, 0 ); glVertex2f (px + tex.w, py ); |
1426 | } |
1489 | } |
|
|
1490 | |
|
|
1491 | if (cell->flags && z == 2) |
|
|
1492 | { |
|
|
1493 | if (cell->flags & 1) |
|
|
1494 | { |
|
|
1495 | maptex tex = self->tex [1]; |
|
|
1496 | int px = (x + 1) * 32 - tex.w + 2; |
|
|
1497 | int py = (y + 1) * 32 - tex.h - 6; |
|
|
1498 | |
|
|
1499 | glEnd (); |
|
|
1500 | glBindTexture (GL_TEXTURE_2D, last_name = tex.name); |
|
|
1501 | glBegin (GL_QUADS); |
|
|
1502 | |
|
|
1503 | glTexCoord2f (0 , 0 ); glVertex2f (px , py ); |
|
|
1504 | glTexCoord2f (0 , tex.t); glVertex2f (px , py + tex.h); |
|
|
1505 | glTexCoord2f (tex.s, tex.t); glVertex2f (px + tex.w, py + tex.h); |
|
|
1506 | glTexCoord2f (tex.s, 0 ); glVertex2f (px + tex.w, py ); |
|
|
1507 | } |
|
|
1508 | } |
1427 | } |
1509 | } |
1428 | } |
1510 | } |
1429 | |
1511 | |
1430 | glEnd (); |
1512 | glEnd (); |
1431 | |
1513 | |
1432 | glDisable (GL_TEXTURE_2D); |
1514 | glDisable (GL_TEXTURE_2D); |
1433 | glDisable (GL_BLEND); |
1515 | glDisable (GL_BLEND); |
1434 | } |
|
|
1435 | |
1516 | |
|
|
1517 | // top layer: overlays such as the health bar |
|
|
1518 | for (y = 0; y < sh; y++) |
|
|
1519 | if (0 <= y + vy && y + vy < self->rows) |
|
|
1520 | { |
|
|
1521 | maprow *row = self->row + (y + vy); |
|
|
1522 | |
|
|
1523 | for (x = 0; x < sw; x++) |
|
|
1524 | if (row->c0 <= x + vx && x + vx < row->c1) |
|
|
1525 | { |
|
|
1526 | mapcell *cell = row->col + (x + vx - row->c0); |
|
|
1527 | |
|
|
1528 | int px = x * 32; |
|
|
1529 | int py = y * 32; |
|
|
1530 | |
|
|
1531 | if (cell->stat_hp) |
|
|
1532 | { |
|
|
1533 | int width = cell->stat_width * 32; |
|
|
1534 | int thick = sh / 28 + 1 + cell->stat_width; |
|
|
1535 | |
|
|
1536 | glColor3ub (0, 0, 0); |
|
|
1537 | glRectf (px + 1, py - thick - 2, |
|
|
1538 | px + width - 1, py); |
|
|
1539 | |
|
|
1540 | glColor3ub (cell->stat_hp, 255 - cell->stat_hp, 0); |
|
|
1541 | glRectf (px + 2, |
|
|
1542 | py - thick - 1, |
|
|
1543 | px + width - 2 - cell->stat_hp * (width - 4) / 255, py - 1); |
|
|
1544 | } |
|
|
1545 | } |
|
|
1546 | } |
|
|
1547 | } |
|
|
1548 | |
1436 | void |
1549 | void |
1437 | draw_magicmap (CFClient::Map self, int dx, int dy, int w, int h, unsigned char *data) |
1550 | draw_magicmap (CFPlus::Map self, int dx, int dy, int w, int h, unsigned char *data) |
1438 | CODE: |
1551 | CODE: |
1439 | { |
1552 | { |
1440 | static float color[16][3] = { |
1553 | static float color[16][3] = { |
1441 | { 0.00F, 0.00F, 0.00F }, |
1554 | { 0.00F, 0.00F, 0.00F }, |
1442 | { 1.00F, 1.00F, 1.00F }, |
1555 | { 1.00F, 1.00F, 1.00F }, |
… | |
… | |
1492 | glDisable (GL_BLEND); |
1605 | glDisable (GL_BLEND); |
1493 | glDisable (GL_TEXTURE_2D); |
1606 | glDisable (GL_TEXTURE_2D); |
1494 | } |
1607 | } |
1495 | |
1608 | |
1496 | void |
1609 | void |
1497 | fow_texture (CFClient::Map self, int shift_x, int shift_y, int x0, int y0, int sw, int sh) |
1610 | fow_texture (CFPlus::Map self, int shift_x, int shift_y, int x0, int y0, int sw, int sh) |
1498 | PPCODE: |
1611 | PPCODE: |
1499 | { |
1612 | { |
1500 | int vx, vy; |
1613 | int vx, vy; |
1501 | int x, y; |
1614 | int x, y; |
1502 | int sw4 = (sw + 3) & ~3; |
1615 | int sw4 = (sw + 3) & ~3; |
… | |
… | |
1518 | for (x = 0; x < sw; x++) |
1631 | for (x = 0; x < sw; x++) |
1519 | if (row->c0 <= x + vx && x + vx < row->c1) |
1632 | if (row->c0 <= x + vx && x + vx < row->c1) |
1520 | { |
1633 | { |
1521 | mapcell *cell = row->col + (x + vx - row->c0); |
1634 | mapcell *cell = row->col + (x + vx - row->c0); |
1522 | |
1635 | |
1523 | darkness[y * sw4 + x] = cell->darkness < 0 |
1636 | darkness[y * sw4 + x] = cell->darkness |
|
|
1637 | ? 255 - (cell->darkness - 1) |
1524 | ? 255 - FOW_DARKNESS |
1638 | : 255 - FOW_DARKNESS; |
1525 | : 255 - cell->darkness; |
|
|
1526 | } |
1639 | } |
1527 | } |
1640 | } |
1528 | |
1641 | |
1529 | EXTEND (SP, 3); |
1642 | EXTEND (SP, 3); |
1530 | PUSHs (sv_2mortal (newSViv (sw4))); |
1643 | PUSHs (sv_2mortal (newSViv (sw4))); |
1531 | PUSHs (sv_2mortal (newSViv (sh))); |
1644 | PUSHs (sv_2mortal (newSViv (sh))); |
1532 | PUSHs (darkness_sv); |
1645 | PUSHs (darkness_sv); |
1533 | } |
1646 | } |
1534 | |
1647 | |
1535 | SV * |
1648 | SV * |
1536 | get_rect (CFClient::Map self, int x0, int y0, int w, int h) |
1649 | get_rect (CFPlus::Map self, int x0, int y0, int w, int h) |
1537 | CODE: |
1650 | CODE: |
1538 | { |
1651 | { |
1539 | int x, y, x1, y1; |
1652 | int x, y, x1, y1; |
1540 | SV *data_sv = newSV (w * h * 7 + 5); |
1653 | SV *data_sv = newSV (w * h * 7 + 5); |
1541 | uint8_t *data = (uint8_t *)SvPVX (data_sv); |
1654 | uint8_t *data = (uint8_t *)SvPVX (data_sv); |
… | |
… | |
1603 | } |
1716 | } |
1604 | OUTPUT: |
1717 | OUTPUT: |
1605 | RETVAL |
1718 | RETVAL |
1606 | |
1719 | |
1607 | void |
1720 | void |
1608 | set_rect (CFClient::Map self, int x0, int y0, uint8_t *data) |
1721 | set_rect (CFPlus::Map self, int x0, int y0, uint8_t *data) |
1609 | PPCODE: |
1722 | PPCODE: |
1610 | { |
1723 | { |
1611 | int x, y, z; |
1724 | int x, y, z; |
1612 | int w, h; |
1725 | int w, h; |
1613 | int x1, y1; |
1726 | int x1, y1; |
… | |
… | |
1645 | |
1758 | |
1646 | if (flags & 1) { face[0] = *data++ << 8; face[0] |= *data++; } |
1759 | if (flags & 1) { face[0] = *data++ << 8; face[0] |= *data++; } |
1647 | if (flags & 2) { face[1] = *data++ << 8; face[1] |= *data++; } |
1760 | if (flags & 2) { face[1] = *data++ << 8; face[1] |= *data++; } |
1648 | if (flags & 4) { face[2] = *data++ << 8; face[2] |= *data++; } |
1761 | if (flags & 4) { face[2] = *data++ << 8; face[2] |= *data++; } |
1649 | |
1762 | |
1650 | if (cell->darkness <= 0) |
1763 | if (cell->darkness == 0) |
1651 | { |
1764 | { |
1652 | cell->darkness = -1; |
1765 | cell->darkness = 0; |
1653 | |
1766 | |
1654 | for (z = 0; z <= 2; z++) |
1767 | for (z = 0; z <= 2; z++) |
1655 | { |
1768 | { |
1656 | cell->face[z] = face[z]; |
1769 | cell->face[z] = face[z]; |
1657 | |
1770 | |
… | |
… | |
1662 | } |
1775 | } |
1663 | } |
1776 | } |
1664 | } |
1777 | } |
1665 | } |
1778 | } |
1666 | |
1779 | |
1667 | MODULE = CFClient PACKAGE = CFClient::MixChunk |
1780 | MODULE = CFPlus PACKAGE = CFPlus::MixChunk |
1668 | |
1781 | |
1669 | CFClient::MixChunk |
1782 | CFPlus::MixChunk |
1670 | new_from_file (SV *class, char *path) |
1783 | new_from_file (SV *class, char *path) |
1671 | CODE: |
1784 | CODE: |
1672 | RETVAL = Mix_LoadWAV (path); |
1785 | RETVAL = Mix_LoadWAV (path); |
1673 | OUTPUT: |
1786 | OUTPUT: |
1674 | RETVAL |
1787 | RETVAL |
1675 | |
1788 | |
1676 | void |
1789 | void |
1677 | DESTROY (CFClient::MixChunk self) |
1790 | DESTROY (CFPlus::MixChunk self) |
1678 | CODE: |
1791 | CODE: |
1679 | Mix_FreeChunk (self); |
1792 | Mix_FreeChunk (self); |
1680 | |
1793 | |
1681 | int |
1794 | int |
1682 | volume (CFClient::MixChunk self, int volume = -1) |
1795 | volume (CFPlus::MixChunk self, int volume = -1) |
1683 | CODE: |
1796 | CODE: |
1684 | RETVAL = Mix_VolumeChunk (self, volume); |
1797 | RETVAL = Mix_VolumeChunk (self, volume); |
1685 | OUTPUT: |
1798 | OUTPUT: |
1686 | RETVAL |
1799 | RETVAL |
1687 | |
1800 | |
1688 | int |
1801 | int |
1689 | play (CFClient::MixChunk self, int channel = -1, int loops = 0, int ticks = -1) |
1802 | play (CFPlus::MixChunk self, int channel = -1, int loops = 0, int ticks = -1) |
1690 | CODE: |
1803 | CODE: |
1691 | RETVAL = Mix_PlayChannelTimed (channel, self, loops, ticks); |
1804 | RETVAL = Mix_PlayChannelTimed (channel, self, loops, ticks); |
1692 | OUTPUT: |
1805 | OUTPUT: |
1693 | RETVAL |
1806 | RETVAL |
1694 | |
1807 | |
1695 | MODULE = CFClient PACKAGE = CFClient::MixMusic |
1808 | MODULE = CFPlus PACKAGE = CFPlus::MixMusic |
1696 | |
1809 | |
1697 | int |
1810 | int |
1698 | volume (int volume = -1) |
1811 | volume (int volume = -1) |
1699 | CODE: |
1812 | CODE: |
1700 | RETVAL = Mix_VolumeMusic (volume); |
1813 | RETVAL = Mix_VolumeMusic (volume); |
1701 | OUTPUT: |
1814 | OUTPUT: |
1702 | RETVAL |
1815 | RETVAL |
1703 | |
1816 | |
1704 | CFClient::MixMusic |
1817 | CFPlus::MixMusic |
1705 | new_from_file (SV *class, char *path) |
1818 | new_from_file (SV *class, char *path) |
1706 | CODE: |
1819 | CODE: |
1707 | RETVAL = Mix_LoadMUS (path); |
1820 | RETVAL = Mix_LoadMUS (path); |
1708 | OUTPUT: |
1821 | OUTPUT: |
1709 | RETVAL |
1822 | RETVAL |
1710 | |
1823 | |
1711 | void |
1824 | void |
1712 | DESTROY (CFClient::MixMusic self) |
1825 | DESTROY (CFPlus::MixMusic self) |
1713 | CODE: |
1826 | CODE: |
1714 | Mix_FreeMusic (self); |
1827 | Mix_FreeMusic (self); |
1715 | |
1828 | |
1716 | int |
1829 | int |
1717 | play (CFClient::MixMusic self, int loops = -1) |
1830 | play (CFPlus::MixMusic self, int loops = -1) |
1718 | CODE: |
1831 | CODE: |
1719 | RETVAL = Mix_PlayMusic (self, loops); |
1832 | RETVAL = Mix_PlayMusic (self, loops); |
1720 | OUTPUT: |
1833 | OUTPUT: |
1721 | RETVAL |
1834 | RETVAL |
1722 | |
1835 | |
1723 | MODULE = CFClient PACKAGE = CFClient::OpenGL |
1836 | MODULE = CFPlus PACKAGE = CFPlus::OpenGL |
1724 | |
1837 | |
1725 | BOOT: |
1838 | BOOT: |
1726 | { |
1839 | { |
1727 | HV *stash = gv_stashpv ("CFClient::OpenGL", 1); |
1840 | HV *stash = gv_stashpv ("CFPlus::OpenGL", 1); |
1728 | static const struct { |
1841 | static const struct { |
1729 | const char *name; |
1842 | const char *name; |
1730 | IV iv; |
1843 | IV iv; |
1731 | } *civ, const_iv[] = { |
1844 | } *civ, const_iv[] = { |
1732 | # define const_iv(name) { # name, (IV)name } |
1845 | # define const_iv(name) { # name, (IV)name } |
… | |
… | |
1795 | const_iv (GL_SEPARABLE_2D), |
1908 | const_iv (GL_SEPARABLE_2D), |
1796 | const_iv (GL_CONVOLUTION_2D), |
1909 | const_iv (GL_CONVOLUTION_2D), |
1797 | const_iv (GL_CONVOLUTION_BORDER_MODE), |
1910 | const_iv (GL_CONVOLUTION_BORDER_MODE), |
1798 | const_iv (GL_CONSTANT_BORDER), |
1911 | const_iv (GL_CONSTANT_BORDER), |
1799 | const_iv (GL_LINES), |
1912 | const_iv (GL_LINES), |
|
|
1913 | const_iv (GL_LINE_STRIP), |
1800 | const_iv (GL_LINE_LOOP), |
1914 | const_iv (GL_LINE_LOOP), |
1801 | const_iv (GL_QUADS), |
1915 | const_iv (GL_QUADS), |
1802 | const_iv (GL_QUAD_STRIP), |
1916 | const_iv (GL_QUAD_STRIP), |
1803 | const_iv (GL_TRIANGLES), |
1917 | const_iv (GL_TRIANGLES), |
1804 | const_iv (GL_TRIANGLE_STRIP), |
1918 | const_iv (GL_TRIANGLE_STRIP), |
… | |
… | |
2001 | |
2115 | |
2002 | void glEndList () |
2116 | void glEndList () |
2003 | |
2117 | |
2004 | void glCallList (int list) |
2118 | void glCallList (int list) |
2005 | |
2119 | |
2006 | |
|
|