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