ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/Client.xs
(Generate patch)

Comparing deliantra/Deliantra-Client/Client.xs (file contents):
Revision 1.129 by root, Wed Jul 12 17:20:04 2006 UTC vs.
Revision 1.138 by root, Mon Aug 14 01:21:01 2006 UTC

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
85typedef Mix_Chunk *CFClient__MixChunk; 88typedef Mix_Chunk *CFPlus__MixChunk;
86typedef Mix_Music *CFClient__MixMusic; 89typedef Mix_Music *CFPlus__MixMusic;
87 90
88typedef PangoFontDescription *CFClient__Font; 91typedef PangoFontDescription *CFPlus__Font;
89 92
90static int 93static int
91shape_attr_p (PangoLayoutRun *run) 94shape_attr_p (PangoLayoutRun *run)
92{ 95{
93 GSList *attrs = run->item->analysis.extra_attrs; 96 GSList *attrs = run->item->analysis.extra_attrs;
107 110
108typedef struct cf_layout { 111typedef 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
115static CFClient__Font default_font; 118static CFPlus__Font default_font;
116static PangoContext *opengl_context; 119static PangoContext *opengl_context;
117static PangoFontMap *opengl_fontmap; 120static PangoFontMap *opengl_fontmap;
118 121
119static void 122static void
120substitute_func (FcPattern *pattern, gpointer data) 123substitute_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
129static void 132static void
130layout_update_font (CFClient__Layout self) 133layout_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
143static void 146static void
144layout_get_pixel_size (CFClient__Layout self, int *w, int *h) 147layout_get_pixel_size (CFPlus__Layout self, int *w, int *h)
145{ 148{
146 pango_layout_get_pixel_size (self->pl, w, h); 149 pango_layout_get_pixel_size (self->pl, w, h);
147 150
148 if (!*w) *w = 1; 151 if (!*w) *w = 1;
149 if (!*h) *h = 1; 152 if (!*h) *h = 1;
179 int texs; 182 int texs;
180 maptex *tex; 183 maptex *tex;
181 184
182 int32_t rows; 185 int32_t rows;
183 maprow *row; 186 maprow *row;
184} *CFClient__Map; 187} *CFPlus__Map;
185 188
186static char * 189static char *
187prepend (char *ptr, int sze, int inc) 190prepend (char *ptr, int sze, int inc)
188{ 191{
189 char *p; 192 char *p;
207 210
208#define Append(type,ptr,sze,inc) (ptr) = (type *)append ((char *)ptr, (sze) * sizeof (type), (inc) * sizeof (type)) 211#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)) 212#define Prepend(type,ptr,sze,inc) (ptr) = (type *)prepend ((char *)ptr, (sze) * sizeof (type), (inc) * sizeof (type))
210 213
211static maprow * 214static maprow *
212map_get_row (CFClient__Map self, int y) 215map_get_row (CFPlus__Map self, int y)
213{ 216{
214 if (0 > y) 217 if (0 > y)
215 { 218 {
216 int extend = - y + MAP_EXTEND_Y; 219 int extend = - y + MAP_EXTEND_Y;
217 Prepend (maprow, self->row, self->rows, extend); 220 Prepend (maprow, self->row, self->rows, extend);
255 258
256 return row->col + (x - row->c0); 259 return row->col + (x - row->c0);
257} 260}
258 261
259static mapcell * 262static mapcell *
260map_get_cell (CFClient__Map self, int x, int y) 263map_get_cell (CFPlus__Map self, int x, int y)
261{ 264{
262 return row_get_cell (map_get_row (self, y), x); 265 return row_get_cell (map_get_row (self, y), x);
263} 266}
264 267
265static void 268static void
266map_clear (CFClient__Map self) 269map_clear (CFPlus__Map self)
267{ 270{
268 int r; 271 int r;
269 272
270 for (r = 0; r < self->rows; r++) 273 for (r = 0; r < self->rows; r++)
271 Safefree (self->row[r].col); 274 Safefree (self->row[r].col);
279 self->row = 0; 282 self->row = 0;
280 self->rows = 0; 283 self->rows = 0;
281} 284}
282 285
283static void 286static void
284map_blank (CFClient__Map self, int x0, int y0, int w, int h) 287map_blank (CFPlus__Map self, int x0, int y0, int w, int h)
285{ 288{
286 int x, y; 289 int x, y;
287 maprow *row; 290 maprow *row;
288 291
289 for (y = y0; y < y0 + h; y++) 292 for (y = y0; y < y0 + h; y++)
346 n |= n >> 16; 349 n |= n >> 16;
347 350
348 return n + 1; 351 return n + 1;
349} 352}
350 353
351MODULE = CFClient PACKAGE = CFClient 354MODULE = CFPlus PACKAGE = CFPlus
352 355
353PROTOTYPES: ENABLE 356PROTOTYPES: ENABLE
354 357
355BOOT: 358BOOT:
356{ 359{
357 HV *stash = gv_stashpv ("CFClient", 1); 360 HV *stash = gv_stashpv ("CFPlus", 1);
358 static const struct { 361 static const struct {
359 const char *name; 362 const char *name;
360 IV iv; 363 IV iv;
361 } *civ, const_iv[] = { 364 } *civ, const_iv[] = {
362# define const_iv(name) { # name, (IV)name } 365# define const_iv(name) { # name, (IV)name }
509 SDL_GL_SetAttribute (SDL_GL_ACCUM_GREEN_SIZE, 0); 512 SDL_GL_SetAttribute (SDL_GL_ACCUM_GREEN_SIZE, 0);
510 SDL_GL_SetAttribute (SDL_GL_ACCUM_BLUE_SIZE, 0); 513 SDL_GL_SetAttribute (SDL_GL_ACCUM_BLUE_SIZE, 0);
511 SDL_GL_SetAttribute (SDL_GL_ACCUM_ALPHA_SIZE, 0); 514 SDL_GL_SetAttribute (SDL_GL_ACCUM_ALPHA_SIZE, 0);
512 515
513 SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1); 516 SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1);
517#if SDL_VERSION_ATLEAST(1,2,10)
518 SDL_GL_SetAttribute (SDL_GL_ACCELERATED_VISUAL, 1);
519 SDL_GL_SetAttribute (SDL_GL_SWAP_CONTROL, 1);
520#endif
514 521
515 SDL_EnableUNICODE (1); 522 SDL_EnableUNICODE (1);
516 SDL_EnableKeyRepeat (SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); 523 SDL_EnableKeyRepeat (SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
517 524
518 m = SDL_ListModes (0, SDL_FULLSCREEN | SDL_OPENGL); 525 m = SDL_ListModes (0, SDL_FULLSCREEN | SDL_OPENGL);
605 hv_store (hv, "data1", 5, newSViv ((IV)ev.user.data1), 0); 612 hv_store (hv, "data1", 5, newSViv ((IV)ev.user.data1), 0);
606 hv_store (hv, "data2", 5, newSViv ((IV)ev.user.data2), 0); 613 hv_store (hv, "data2", 5, newSViv ((IV)ev.user.data2), 0);
607 break; 614 break;
608 } 615 }
609 616
610 XPUSHs (sv_2mortal (newRV_noinc ((SV *)hv))); 617 XPUSHs (sv_2mortal (sv_bless (newRV_noinc ((SV *)hv), gv_stashpv ("CFPlus::UI::Event", 1))));
611 } 618 }
612} 619}
613 620
614int 621int
615Mix_OpenAudio (int frequency = 48000, int format = MIX_DEFAULT_FORMAT, int channels = 1, int chunksize = 2048) 622Mix_OpenAudio (int frequency = 48000, int format = MIX_DEFAULT_FORMAT, int channels = 1, int chunksize = 2048)
744void 751void
745_exit (int retval) 752_exit (int retval)
746 CODE: 753 CODE:
747 _exit (retval); 754 _exit (retval);
748 755
749MODULE = CFClient PACKAGE = CFClient::Font 756MODULE = CFPlus PACKAGE = CFPlus::Font
750 757
751CFClient::Font 758CFPlus::Font
752new_from_file (SV *class, char *path, int id = 0) 759new_from_file (SV *class, char *path, int id = 0)
753 CODE: 760 CODE:
754{ 761{
755 int count; 762 int count;
756 FcPattern *pattern = FcFreeTypeQuery ((const FcChar8 *)path, id, 0, &count); 763 FcPattern *pattern = FcFreeTypeQuery ((const FcChar8 *)path, id, 0, &count);
759} 766}
760 OUTPUT: 767 OUTPUT:
761 RETVAL 768 RETVAL
762 769
763void 770void
764DESTROY (CFClient::Font self) 771DESTROY (CFPlus::Font self)
765 CODE: 772 CODE:
766 pango_font_description_free (self); 773 pango_font_description_free (self);
767 774
768void 775void
769make_default (CFClient::Font self) 776make_default (CFPlus::Font self)
770 CODE: 777 CODE:
771 default_font = self; 778 default_font = self;
772 779
773MODULE = CFClient PACKAGE = CFClient::Layout 780MODULE = CFPlus PACKAGE = CFPlus::Layout
774 781
775void 782void
776reset_glyph_cache () 783reset_glyph_cache ()
777 CODE: 784 CODE:
778 tc_clear (); 785 tc_clear ();
779 786
780CFClient::Layout 787CFPlus::Layout
781new (SV *class) 788new (SV *class)
782 CODE: 789 CODE:
783 New (0, RETVAL, 1, struct cf_layout); 790 New (0, RETVAL, 1, struct cf_layout);
784 791
785 RETVAL->pl = pango_layout_new (opengl_context); 792 RETVAL->pl = pango_layout_new (opengl_context);
794 layout_update_font (RETVAL); 801 layout_update_font (RETVAL);
795 OUTPUT: 802 OUTPUT:
796 RETVAL 803 RETVAL
797 804
798void 805void
799DESTROY (CFClient::Layout self) 806DESTROY (CFPlus::Layout self)
800 CODE: 807 CODE:
801 g_object_unref (self->pl); 808 g_object_unref (self->pl);
802 Safefree (self); 809 Safefree (self);
803 810
804void 811void
805set_text (CFClient::Layout self, SV *text_) 812set_text (CFPlus::Layout self, SV *text_)
806 CODE: 813 CODE:
807{ 814{
808 STRLEN textlen; 815 STRLEN textlen;
809 char *text = SvPVutf8 (text_, textlen); 816 char *text = SvPVutf8 (text_, textlen);
810 817
811 pango_layout_set_text (self->pl, text, textlen); 818 pango_layout_set_text (self->pl, text, textlen);
812} 819}
813 820
814void 821void
815set_markup (CFClient::Layout self, SV *text_) 822set_markup (CFPlus::Layout self, SV *text_)
816 CODE: 823 CODE:
817{ 824{
818 STRLEN textlen; 825 STRLEN textlen;
819 char *text = SvPVutf8 (text_, textlen); 826 char *text = SvPVutf8 (text_, textlen);
820 827
821 pango_layout_set_markup (self->pl, text, textlen); 828 pango_layout_set_markup (self->pl, text, textlen);
822} 829}
823 830
824void 831void
825set_shapes (CFClient::Layout self, ...) 832set_shapes (CFPlus::Layout self, ...)
826 CODE: 833 CODE:
827{ 834{
828 PangoAttrList *attrs = 0; 835 PangoAttrList *attrs = 0;
829 const char *text = pango_layout_get_text (self->pl); 836 const char *text = pango_layout_get_text (self->pl);
830 const char *pos = text; 837 const char *pos = text;
865 if (attrs) 872 if (attrs)
866 pango_layout_set_attributes (self->pl, attrs); 873 pango_layout_set_attributes (self->pl, attrs);
867} 874}
868 875
869void 876void
870get_shapes (CFClient::Layout self) 877get_shapes (CFPlus::Layout self)
871 PPCODE: 878 PPCODE:
872{ 879{
873 PangoLayoutIter *iter = pango_layout_get_iter (self->pl); 880 PangoLayoutIter *iter = pango_layout_get_iter (self->pl);
874 881
875 do 882 do
890 897
891 pango_layout_iter_free (iter); 898 pango_layout_iter_free (iter);
892} 899}
893 900
894int 901int
895has_wrapped (CFClient::Layout self) 902has_wrapped (CFPlus::Layout self)
896 CODE: 903 CODE:
897{ 904{
898 int lines = 1; 905 int lines = 1;
899 const char *text = pango_layout_get_text (self->pl); 906 const char *text = pango_layout_get_text (self->pl);
900 907
905} 912}
906 OUTPUT: 913 OUTPUT:
907 RETVAL 914 RETVAL
908 915
909SV * 916SV *
910get_text (CFClient::Layout self) 917get_text (CFPlus::Layout self)
911 CODE: 918 CODE:
912 RETVAL = newSVpv (pango_layout_get_text (self->pl), 0); 919 RETVAL = newSVpv (pango_layout_get_text (self->pl), 0);
913 sv_utf8_decode (RETVAL); 920 sv_utf8_decode (RETVAL);
914 OUTPUT: 921 OUTPUT:
915 RETVAL 922 RETVAL
916 923
917void 924void
918set_foreground (CFClient::Layout self, float r, float g, float b, float a = 1.) 925set_foreground (CFPlus::Layout self, float r, float g, float b, float a = 1.)
919 CODE: 926 CODE:
920 self->r = r; 927 self->r = r;
921 self->g = g; 928 self->g = g;
922 self->b = b; 929 self->b = b;
923 self->a = a; 930 self->a = a;
924 931
925void 932void
926set_font (CFClient::Layout self, CFClient::Font font = 0) 933set_font (CFPlus::Layout self, CFPlus::Font font = 0)
927 CODE: 934 CODE:
928 if (self->font != font) 935 if (self->font != font)
929 { 936 {
930 self->font = font; 937 self->font = font;
931 layout_update_font (self); 938 layout_update_font (self);
932 } 939 }
933 940
934void 941void
935set_height (CFClient::Layout self, int base_height) 942set_height (CFPlus::Layout self, int base_height)
936 CODE: 943 CODE:
937 if (self->base_height != base_height) 944 if (self->base_height != base_height)
938 { 945 {
939 self->base_height = base_height; 946 self->base_height = base_height;
940 layout_update_font (self); 947 layout_update_font (self);
941 } 948 }
942 949
943void 950void
944set_width (CFClient::Layout self, int max_width = -1) 951set_width (CFPlus::Layout self, int max_width = -1)
945 CODE: 952 CODE:
946 pango_layout_set_width (self->pl, max_width < 0 ? max_width : max_width * PANGO_SCALE); 953 pango_layout_set_width (self->pl, max_width < 0 ? max_width : max_width * PANGO_SCALE);
947 954
948void 955void
949set_indent (CFClient::Layout self, int indent) 956set_indent (CFPlus::Layout self, int indent)
950 CODE: 957 CODE:
951 pango_layout_set_indent (self->pl, indent * PANGO_SCALE); 958 pango_layout_set_indent (self->pl, indent * PANGO_SCALE);
952 959
953void 960void
954set_spacing (CFClient::Layout self, int spacing) 961set_spacing (CFPlus::Layout self, int spacing)
955 CODE: 962 CODE:
956 pango_layout_set_spacing (self->pl, spacing * PANGO_SCALE); 963 pango_layout_set_spacing (self->pl, spacing * PANGO_SCALE);
957 964
958void 965void
959set_ellipsise (CFClient::Layout self, int ellipsise) 966set_ellipsise (CFPlus::Layout self, int ellipsise)
960 CODE: 967 CODE:
961 pango_layout_set_ellipsize (self->pl, 968 pango_layout_set_ellipsize (self->pl,
962 ellipsise == 1 ? PANGO_ELLIPSIZE_START 969 ellipsise == 1 ? PANGO_ELLIPSIZE_START
963 : ellipsise == 2 ? PANGO_ELLIPSIZE_MIDDLE 970 : ellipsise == 2 ? PANGO_ELLIPSIZE_MIDDLE
964 : ellipsise == 3 ? PANGO_ELLIPSIZE_END 971 : ellipsise == 3 ? PANGO_ELLIPSIZE_END
965 : PANGO_ELLIPSIZE_NONE 972 : PANGO_ELLIPSIZE_NONE
966 ); 973 );
967 974
968void 975void
969set_single_paragraph_mode (CFClient::Layout self, int spm) 976set_single_paragraph_mode (CFPlus::Layout self, int spm)
970 CODE: 977 CODE:
971 pango_layout_set_single_paragraph_mode (self->pl, !!spm); 978 pango_layout_set_single_paragraph_mode (self->pl, !!spm);
972 979
973void 980void
974size (CFClient::Layout self) 981size (CFPlus::Layout self)
975 PPCODE: 982 PPCODE:
976{ 983{
977 int w, h; 984 int w, h;
978 985
979 layout_get_pixel_size (self, &w, &h); 986 layout_get_pixel_size (self, &w, &h);
982 PUSHs (sv_2mortal (newSViv (w))); 989 PUSHs (sv_2mortal (newSViv (w)));
983 PUSHs (sv_2mortal (newSViv (h))); 990 PUSHs (sv_2mortal (newSViv (h)));
984} 991}
985 992
986int 993int
987descent (CFClient::Layout self) 994descent (CFPlus::Layout self)
988 CODE: 995 CODE:
989{ 996{
990 PangoRectangle rect; 997 PangoRectangle rect;
991 PangoLayoutLine *line = pango_layout_get_line (self->pl, 0); 998 PangoLayoutLine *line = pango_layout_get_line (self->pl, 0);
992 pango_layout_line_get_pixel_extents (line, 0, &rect); 999 pango_layout_line_get_pixel_extents (line, 0, &rect);
994} 1001}
995 OUTPUT: 1002 OUTPUT:
996 RETVAL 1003 RETVAL
997 1004
998int 1005int
999xy_to_index (CFClient::Layout self, int x, int y) 1006xy_to_index (CFPlus::Layout self, int x, int y)
1000 CODE: 1007 CODE:
1001{ 1008{
1002 int index, trailing; 1009 int index, trailing;
1003 pango_layout_xy_to_index (self->pl, x * PANGO_SCALE, y * PANGO_SCALE, &index, &trailing); 1010 pango_layout_xy_to_index (self->pl, x * PANGO_SCALE, y * PANGO_SCALE, &index, &trailing);
1004 RETVAL = index; 1011 RETVAL = index;
1005} 1012}
1006 OUTPUT: 1013 OUTPUT:
1007 RETVAL 1014 RETVAL
1008 1015
1009void 1016void
1010cursor_pos (CFClient::Layout self, int index) 1017cursor_pos (CFPlus::Layout self, int index)
1011 PPCODE: 1018 PPCODE:
1012{ 1019{
1013 PangoRectangle strong_pos; 1020 PangoRectangle strong_pos;
1014 pango_layout_get_cursor_pos (self->pl, index, &strong_pos, 0); 1021 pango_layout_get_cursor_pos (self->pl, index, &strong_pos, 0);
1015 1022
1018 PUSHs (sv_2mortal (newSViv (strong_pos.y / PANGO_SCALE))); 1025 PUSHs (sv_2mortal (newSViv (strong_pos.y / PANGO_SCALE)));
1019 PUSHs (sv_2mortal (newSViv (strong_pos.height / PANGO_SCALE))); 1026 PUSHs (sv_2mortal (newSViv (strong_pos.height / PANGO_SCALE)));
1020} 1027}
1021 1028
1022void 1029void
1023render (CFClient::Layout self, float x, float y) 1030render (CFPlus::Layout self, float x, float y, int flags = 0)
1024 PPCODE: 1031 PPCODE:
1025 pango_opengl_render_layout_subpixel ( 1032 pango_opengl_render_layout_subpixel (
1026 self->pl, 1033 self->pl,
1027 x * PANGO_SCALE, y * PANGO_SCALE, 1034 x * PANGO_SCALE, y * PANGO_SCALE,
1028 self->r, self->g, self->b, self->a 1035 self->r, self->g, self->b, self->a,
1036 flags
1029 ); 1037 );
1030 1038
1031MODULE = CFClient PACKAGE = CFClient::Texture 1039MODULE = CFPlus PACKAGE = CFPlus::Texture
1032 1040
1033void 1041void
1034pad2pot (SV *data_, SV *w_, SV *h_) 1042pad2pot (SV *data_, SV *w_, SV *h_)
1035 CODE: 1043 CODE:
1036{ 1044{
1114 glDisable (GL_ALPHA_TEST); 1122 glDisable (GL_ALPHA_TEST);
1115 glDisable (GL_BLEND); 1123 glDisable (GL_BLEND);
1116 } 1124 }
1117} 1125}
1118 1126
1119MODULE = CFClient PACKAGE = CFClient::Map 1127MODULE = CFPlus PACKAGE = CFPlus::Map
1120 1128
1121CFClient::Map 1129CFPlus::Map
1122new (SV *class, int map_width, int map_height) 1130new (SV *class, int map_width, int map_height)
1123 CODE: 1131 CODE:
1124 New (0, RETVAL, 1, struct map); 1132 New (0, RETVAL, 1, struct map);
1125 RETVAL->x = 0; 1133 RETVAL->x = 0;
1126 RETVAL->y = 0; 1134 RETVAL->y = 0;
1136 RETVAL->row = 0; 1144 RETVAL->row = 0;
1137 OUTPUT: 1145 OUTPUT:
1138 RETVAL 1146 RETVAL
1139 1147
1140void 1148void
1141DESTROY (CFClient::Map self) 1149DESTROY (CFPlus::Map self)
1142 CODE: 1150 CODE:
1143{ 1151{
1144 map_clear (self); 1152 map_clear (self);
1145 Safefree (self->face); 1153 Safefree (self->face);
1146 Safefree (self->tex); 1154 Safefree (self->tex);
1147 Safefree (self); 1155 Safefree (self);
1148} 1156}
1149 1157
1150void 1158void
1151clear (CFClient::Map self) 1159clear (CFPlus::Map self)
1152 CODE: 1160 CODE:
1153 map_clear (self); 1161 map_clear (self);
1154 1162
1155void 1163void
1156set_face (CFClient::Map self, int face, int texid) 1164set_face (CFPlus::Map self, int face, int texid)
1157 CODE: 1165 CODE:
1158{ 1166{
1159 while (self->faces <= face) 1167 while (self->faces <= face)
1160 { 1168 {
1161 Append (mapface, self->face, self->faces, self->faces); 1169 Append (mapface, self->face, self->faces, self->faces);
1164 1172
1165 self->face [face] = texid; 1173 self->face [face] = texid;
1166} 1174}
1167 1175
1168void 1176void
1169set_texture (CFClient::Map self, int texid, int name, int w, int h, float s, float t, int r, int g, int b, int a) 1177set_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: 1178 CODE:
1171{ 1179{
1172 while (self->texs <= texid) 1180 while (self->texs <= texid)
1173 { 1181 {
1174 Append (maptex, self->tex, self->texs, self->texs); 1182 Append (maptex, self->tex, self->texs, self->texs);
1198 // from transparent color bleeding and ugly wrapping effects. 1206 // from transparent color bleeding and ugly wrapping effects.
1199 glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 1207 glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1200} 1208}
1201 1209
1202int 1210int
1203ox (CFClient::Map self) 1211ox (CFPlus::Map self)
1204 ALIAS: 1212 ALIAS:
1205 oy = 1 1213 oy = 1
1206 x = 2 1214 x = 2
1207 y = 3 1215 y = 3
1208 w = 4 1216 w = 4
1219 } 1227 }
1220 OUTPUT: 1228 OUTPUT:
1221 RETVAL 1229 RETVAL
1222 1230
1223void 1231void
1224scroll (CFClient::Map self, int dx, int dy) 1232scroll (CFPlus::Map self, int dx, int dy)
1225 CODE: 1233 CODE:
1226{ 1234{
1227 if (dx > 0) 1235 if (dx > 0)
1228 map_blank (self, self->x, self->y, dx - 1, self->h); 1236 map_blank (self, self->x, self->y, dx - 1, self->h);
1229 else if (dx < 0) 1237 else if (dx < 0)
1245 self->y += MAP_EXTEND_Y; 1253 self->y += MAP_EXTEND_Y;
1246 } 1254 }
1247} 1255}
1248 1256
1249void 1257void
1250map1a_update (CFClient::Map self, SV *data_) 1258map1a_update (CFPlus::Map self, SV *data_)
1251 CODE: 1259 CODE:
1252{ 1260{
1253 uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_); 1261 uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_);
1254 uint8_t *data_end = (uint8_t *)SvEND (data_); 1262 uint8_t *data_end = (uint8_t *)SvEND (data_);
1255 mapcell *cell; 1263 mapcell *cell;
1297 cell->darkness = -1; 1305 cell->darkness = -1;
1298 } 1306 }
1299} 1307}
1300 1308
1301SV * 1309SV *
1302mapmap (CFClient::Map self, int x0, int y0, int w, int h) 1310mapmap (CFPlus::Map self, int x0, int y0, int w, int h)
1303 CODE: 1311 CODE:
1304{ 1312{
1305 int x1, x; 1313 int x1, x;
1306 int y1, y; 1314 int y1, y;
1307 int z; 1315 int z;
1357} 1365}
1358 OUTPUT: 1366 OUTPUT:
1359 RETVAL 1367 RETVAL
1360 1368
1361void 1369void
1362draw (CFClient::Map self, int shift_x, int shift_y, int x0, int y0, int sw, int sh) 1370draw (CFPlus::Map self, int shift_x, int shift_y, int x0, int y0, int sw, int sh)
1363 CODE: 1371 CODE:
1364{ 1372{
1365 int vx, vy; 1373 int vx, vy;
1366 int x, y, z; 1374 int x, y, z;
1367 int last_name; 1375 int last_name;
1432 glDisable (GL_TEXTURE_2D); 1440 glDisable (GL_TEXTURE_2D);
1433 glDisable (GL_BLEND); 1441 glDisable (GL_BLEND);
1434} 1442}
1435 1443
1436void 1444void
1437draw_magicmap (CFClient::Map self, int dx, int dy, int w, int h, unsigned char *data) 1445draw_magicmap (CFPlus::Map self, int dx, int dy, int w, int h, unsigned char *data)
1438 CODE: 1446 CODE:
1439{ 1447{
1440 static float color[16][3] = { 1448 static float color[16][3] = {
1441 { 0.00F, 0.00F, 0.00F }, 1449 { 0.00F, 0.00F, 0.00F },
1442 { 1.00F, 1.00F, 1.00F }, 1450 { 1.00F, 1.00F, 1.00F },
1492 glDisable (GL_BLEND); 1500 glDisable (GL_BLEND);
1493 glDisable (GL_TEXTURE_2D); 1501 glDisable (GL_TEXTURE_2D);
1494} 1502}
1495 1503
1496void 1504void
1497fow_texture (CFClient::Map self, int shift_x, int shift_y, int x0, int y0, int sw, int sh) 1505fow_texture (CFPlus::Map self, int shift_x, int shift_y, int x0, int y0, int sw, int sh)
1498 PPCODE: 1506 PPCODE:
1499{ 1507{
1500 int vx, vy; 1508 int vx, vy;
1501 int x, y; 1509 int x, y;
1502 int sw4 = (sw + 3) & ~3; 1510 int sw4 = (sw + 3) & ~3;
1531 PUSHs (sv_2mortal (newSViv (sh))); 1539 PUSHs (sv_2mortal (newSViv (sh)));
1532 PUSHs (darkness_sv); 1540 PUSHs (darkness_sv);
1533} 1541}
1534 1542
1535SV * 1543SV *
1536get_rect (CFClient::Map self, int x0, int y0, int w, int h) 1544get_rect (CFPlus::Map self, int x0, int y0, int w, int h)
1537 CODE: 1545 CODE:
1538{ 1546{
1539 int x, y, x1, y1; 1547 int x, y, x1, y1;
1540 SV *data_sv = newSV (w * h * 7 + 5); 1548 SV *data_sv = newSV (w * h * 7 + 5);
1541 uint8_t *data = (uint8_t *)SvPVX (data_sv); 1549 uint8_t *data = (uint8_t *)SvPVX (data_sv);
1603} 1611}
1604 OUTPUT: 1612 OUTPUT:
1605 RETVAL 1613 RETVAL
1606 1614
1607void 1615void
1608set_rect (CFClient::Map self, int x0, int y0, uint8_t *data) 1616set_rect (CFPlus::Map self, int x0, int y0, uint8_t *data)
1609 PPCODE: 1617 PPCODE:
1610{ 1618{
1611 int x, y, z; 1619 int x, y, z;
1612 int w, h; 1620 int w, h;
1613 int x1, y1; 1621 int x1, y1;
1662 } 1670 }
1663 } 1671 }
1664 } 1672 }
1665} 1673}
1666 1674
1667MODULE = CFClient PACKAGE = CFClient::MixChunk 1675MODULE = CFPlus PACKAGE = CFPlus::MixChunk
1668 1676
1669CFClient::MixChunk 1677CFPlus::MixChunk
1670new_from_file (SV *class, char *path) 1678new_from_file (SV *class, char *path)
1671 CODE: 1679 CODE:
1672 RETVAL = Mix_LoadWAV (path); 1680 RETVAL = Mix_LoadWAV (path);
1673 OUTPUT: 1681 OUTPUT:
1674 RETVAL 1682 RETVAL
1675 1683
1676void 1684void
1677DESTROY (CFClient::MixChunk self) 1685DESTROY (CFPlus::MixChunk self)
1678 CODE: 1686 CODE:
1679 Mix_FreeChunk (self); 1687 Mix_FreeChunk (self);
1680 1688
1681int 1689int
1682volume (CFClient::MixChunk self, int volume = -1) 1690volume (CFPlus::MixChunk self, int volume = -1)
1683 CODE: 1691 CODE:
1684 RETVAL = Mix_VolumeChunk (self, volume); 1692 RETVAL = Mix_VolumeChunk (self, volume);
1685 OUTPUT: 1693 OUTPUT:
1686 RETVAL 1694 RETVAL
1687 1695
1688int 1696int
1689play (CFClient::MixChunk self, int channel = -1, int loops = 0, int ticks = -1) 1697play (CFPlus::MixChunk self, int channel = -1, int loops = 0, int ticks = -1)
1690 CODE: 1698 CODE:
1691 RETVAL = Mix_PlayChannelTimed (channel, self, loops, ticks); 1699 RETVAL = Mix_PlayChannelTimed (channel, self, loops, ticks);
1692 OUTPUT: 1700 OUTPUT:
1693 RETVAL 1701 RETVAL
1694 1702
1695MODULE = CFClient PACKAGE = CFClient::MixMusic 1703MODULE = CFPlus PACKAGE = CFPlus::MixMusic
1696 1704
1697int 1705int
1698volume (int volume = -1) 1706volume (int volume = -1)
1699 CODE: 1707 CODE:
1700 RETVAL = Mix_VolumeMusic (volume); 1708 RETVAL = Mix_VolumeMusic (volume);
1701 OUTPUT: 1709 OUTPUT:
1702 RETVAL 1710 RETVAL
1703 1711
1704CFClient::MixMusic 1712CFPlus::MixMusic
1705new_from_file (SV *class, char *path) 1713new_from_file (SV *class, char *path)
1706 CODE: 1714 CODE:
1707 RETVAL = Mix_LoadMUS (path); 1715 RETVAL = Mix_LoadMUS (path);
1708 OUTPUT: 1716 OUTPUT:
1709 RETVAL 1717 RETVAL
1710 1718
1711void 1719void
1712DESTROY (CFClient::MixMusic self) 1720DESTROY (CFPlus::MixMusic self)
1713 CODE: 1721 CODE:
1714 Mix_FreeMusic (self); 1722 Mix_FreeMusic (self);
1715 1723
1716int 1724int
1717play (CFClient::MixMusic self, int loops = -1) 1725play (CFPlus::MixMusic self, int loops = -1)
1718 CODE: 1726 CODE:
1719 RETVAL = Mix_PlayMusic (self, loops); 1727 RETVAL = Mix_PlayMusic (self, loops);
1720 OUTPUT: 1728 OUTPUT:
1721 RETVAL 1729 RETVAL
1722 1730
1723MODULE = CFClient PACKAGE = CFClient::OpenGL 1731MODULE = CFPlus PACKAGE = CFPlus::OpenGL
1724 1732
1725BOOT: 1733BOOT:
1726{ 1734{
1727 HV *stash = gv_stashpv ("CFClient::OpenGL", 1); 1735 HV *stash = gv_stashpv ("CFPlus::OpenGL", 1);
1728 static const struct { 1736 static const struct {
1729 const char *name; 1737 const char *name;
1730 IV iv; 1738 IV iv;
1731 } *civ, const_iv[] = { 1739 } *civ, const_iv[] = {
1732# define const_iv(name) { # name, (IV)name } 1740# define const_iv(name) { # name, (IV)name }
1795 const_iv (GL_SEPARABLE_2D), 1803 const_iv (GL_SEPARABLE_2D),
1796 const_iv (GL_CONVOLUTION_2D), 1804 const_iv (GL_CONVOLUTION_2D),
1797 const_iv (GL_CONVOLUTION_BORDER_MODE), 1805 const_iv (GL_CONVOLUTION_BORDER_MODE),
1798 const_iv (GL_CONSTANT_BORDER), 1806 const_iv (GL_CONSTANT_BORDER),
1799 const_iv (GL_LINES), 1807 const_iv (GL_LINES),
1808 const_iv (GL_LINE_STRIP),
1800 const_iv (GL_LINE_LOOP), 1809 const_iv (GL_LINE_LOOP),
1801 const_iv (GL_QUADS), 1810 const_iv (GL_QUADS),
1802 const_iv (GL_QUAD_STRIP), 1811 const_iv (GL_QUAD_STRIP),
1803 const_iv (GL_TRIANGLES), 1812 const_iv (GL_TRIANGLES),
1804 const_iv (GL_TRIANGLE_STRIP), 1813 const_iv (GL_TRIANGLE_STRIP),
1914 r *= a; 1923 r *= a;
1915 g *= a; 1924 g *= a;
1916 b *= a; 1925 b *= a;
1917 } 1926 }
1918 // microsoft visual "c" rounds instead of truncating... 1927 // microsoft visual "c" rounds instead of truncating...
1919 glColor4ub (MIN ((int)(r * 256.f), 255), 1928 glColor4f (r, g, b, a);
1920 MIN ((int)(g * 256.f), 255),
1921 MIN ((int)(b * 256.f), 255),
1922 MIN ((int)(a * 256.f), 255));
1923 1929
1924void glInterleavedArrays (int format, int stride, char *data) 1930void glInterleavedArrays (int format, int stride, char *data)
1925 1931
1926void glDrawElements (int mode, int count, int type, char *indices) 1932void glDrawElements (int mode, int count, int type, char *indices)
1927 1933
2004 2010
2005void glEndList () 2011void glEndList ()
2006 2012
2007void glCallList (int list) 2013void glCallList (int list)
2008 2014
2009

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines