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.318 by root, Wed Dec 24 06:12:21 2014 UTC vs.
Revision 1.331 by root, Mon Nov 19 00:10:34 2018 UTC

15 15
16#include "EXTERN.h" 16#include "EXTERN.h"
17#include "perl.h" 17#include "perl.h"
18#include "XSUB.h" 18#include "XSUB.h"
19 19
20#include "flat_hash_map.hpp"
21
20#ifdef _WIN32 22#ifdef _WIN32
21# undef pipe 23# undef pipe
22// microsoft vs. C 24// microsoft vs. C
23# define sqrtf(x) sqrt(x) 25# define sqrtf(x) sqrt(x)
24# define atan2f(x,y) atan2(x,y) 26# define atan2f(x,y) atan2(x,y)
25# define M_PI 3.14159265f 27# define M_PI 3.14159265f
26#endif 28#endif
27 29
28#include <assert.h> 30#include <cassert>
29#include <math.h> 31#include <cmath>
30#include <string.h> 32#include <cstring>
31#include <stdio.h> 33#include <cstdio>
32#include <stdlib.h> 34#include <cstdlib>
35
36#include <utility>
37#include <bitset>
33 38
34#define USE_RWOPS 1 // for SDL_mixer:LoadMUS_RW 39#define USE_RWOPS 1 // for SDL_mixer:LoadMUS_RW
35 40
36#include <SDL.h> 41#include <SDL.h>
37#include <SDL_thread.h> 42#include <SDL_thread.h>
71# include <netinet/in.h> 76# include <netinet/in.h>
72# include <netinet/tcp.h> 77# include <netinet/tcp.h>
73# include <inttypes.h> 78# include <inttypes.h>
74#endif 79#endif
75 80
76#if __GNUC__ >= 4 81#include "ecb.h"
77# define expect(expr,value) __builtin_expect ((expr),(value))
78#else
79# define expect(expr,value) (expr)
80#endif
81
82#define expect_false(expr) expect ((expr) != 0, 0)
83#define expect_true(expr) expect ((expr) != 0, 1)
84 82
85#define OBJ_STR "\xef\xbf\xbc" /* U+FFFC, object replacement character */ 83#define OBJ_STR "\xef\xbf\xbc" /* U+FFFC, object replacement character */
86 84
87/* this is used as fow flag as well, so has to have a different value */ 85/* this is used as fow flag as well, so has to have a different value */
88/* then anything that is computed by incoming darkness */ 86/* then anything that is computed by incoming darkness */
106fast_sv_grow (SV *sv, STRLEN need) 104fast_sv_grow (SV *sv, STRLEN need)
107{ 105{
108 STRLEN len = SvLEN (sv); 106 STRLEN len = SvLEN (sv);
109 STRLEN want = SvCUR (sv) + need; 107 STRLEN want = SvCUR (sv) + need;
110 108
111 if (expect_false (len < want)) 109 if (ecb_expect_false (len < want))
112 { 110 {
113 do 111 do
114 len *= 2; 112 len *= 2;
115 while (len < want); 113 while (len < want);
116 114
184{ 182{
185 GSList *attrs = run->item->analysis.extra_attrs; 183 GSList *attrs = run->item->analysis.extra_attrs;
186 184
187 while (attrs) 185 while (attrs)
188 { 186 {
189 PangoAttribute *attr = attrs->data; 187 PangoAttribute *attr = (PangoAttribute *)attrs->data;
190 188
191 if (attr->klass->type == PANGO_ATTR_SHAPE) 189 if (attr->klass->type == PANGO_ATTR_SHAPE)
192 return 1; 190 return 1;
193 191
194 attrs = attrs->next; 192 attrs = attrs->next;
195 } 193 }
196 194
197 return 0; 195 return 0;
198} 196}
199 197
200typedef struct cf_layout { 198struct cf_layout {
201 PangoLayout *pl; 199 PangoLayout *pl;
202 float r, g, b, a; // default color for rgba mode 200 float r, g, b, a; // default color for rgba mode
203 int base_height; 201 int base_height;
204 DC__Font font; 202 DC__Font font;
205 rc_t *rc; 203 rc_t rc;
206} *DC__Layout; 204};
205
206typedef cf_layout *DC__Layout;
207 207
208static DC__Font default_font; 208static DC__Font default_font;
209static PangoContext *opengl_context; 209static PangoContext *opengl_context;
210static PangoFontMap *opengl_fontmap; 210static PangoFontMap *opengl_fontmap;
211 211
212static void 212static void
213substitute_func (FcPattern *pattern, gpointer data) 213substitute_func (FcPattern *pattern, gpointer data)
214{ 214{
215 FcPatternAddBool (pattern, FC_HINTING, 1); 215 FcPatternAddBool (pattern, FC_HINTING, 1);
216#ifdef FC_HINT_STYLE 216#ifdef FC_HINT_STYLE
217 FcPatternAddBool (pattern, FC_HINT_STYLE, FC_HINT_FULL); 217 FcPatternAddInteger (pattern, FC_HINT_STYLE, FC_HINT_FULL);
218#endif 218#endif
219 FcPatternAddBool (pattern, FC_AUTOHINT, 0); 219 FcPatternAddBool (pattern, FC_AUTOHINT, 0);
220} 220}
221 221
222static void 222static void
249 249
250 *w = rect.width; 250 *w = rect.width;
251 *h = rect.height; 251 *h = rect.height;
252} 252}
253 253
254/////////////////////////////////////////////////////////////////////////////
255
254typedef uint16_t tileid; 256typedef uint16_t tileid;
255typedef uint16_t faceid; 257typedef uint16_t faceid;
256 258
257typedef struct { 259struct maptex
260{
258 GLuint name; 261 GLuint name;
259 int w, h; 262 int w, h;
260 float s, t; 263 float s, t;
261 uint8_t r, g, b, a; 264 uint8_t r, g, b, a;
262 tileid smoothtile; 265 tileid smoothtile;
263 uint8_t smoothlevel; 266 uint8_t smoothlevel;
264 uint8_t unused; /* set to zero on use */ 267 uint8_t unused; /* set to zero on use */
265} maptex; 268};
266 269
267typedef struct { 270struct mapcell
271{
268 uint32_t player; 272 uint32_t player;
269 tileid tile[3]; 273 tileid tile[3];
270 uint16_t darkness; 274 uint16_t darkness;
271 uint8_t stat_width, stat_hp, flags, smoothmax; 275 uint8_t stat_width, stat_hp, flags, smoothmax;
272} mapcell; 276};
273 277
274typedef struct { 278struct maprow
279{
275 int32_t c0, c1; 280 int32_t c0, c1;
276 mapcell *col; 281 mapcell *col;
277} maprow; 282};
278 283
279typedef struct map { 284struct mapgrid {
280 int x, y, w, h; 285 int x, y, w, h;
281 int ox, oy; /* offset to virtual global coordinate system */ 286 int ox, oy; /* offset to virtual global coordinate system */
282 int faces; tileid *face2tile; // [faceid] 287 int faces; tileid *face2tile; // [faceid]
283 int texs; maptex *tex; // [tileid] 288 int texs; maptex *tex; // [tileid]
284 289
285 int32_t rows; 290 int32_t rows;
286 maprow *row; 291 maprow *row;
287} *DC__Map; 292};
288 293
289static char * 294typedef mapgrid *DC__Map;
295
296template<typename T>
297static void
290prepend (char *ptr, int sze, int inc) 298prepend (T *&ptr, int sze, int inc)
291{ 299{
292 char *p; 300 T *p;
293 301
294 New (0, p, sze + inc, char); 302 Newx (p, inc + sze, T);
295 Zero (p, inc, char); 303 Zero (p, inc, T);
296 Move (ptr, p + inc, sze, char); 304 Move (ptr, p + inc, sze, T);
297 Safefree (ptr); 305 Safefree (ptr);
298 306
299 return p; 307 ptr = p;
300} 308}
301 309
302static char * 310template<typename T>
303append (char *ptr, int sze, int inc)
304{
305 Renew (ptr, sze + inc, char);
306 Zero (ptr + sze, inc, char);
307
308 return ptr;
309}
310
311#define Append(type,ptr,sze,inc) (ptr) = (type *)append ((char *)ptr, (sze) * sizeof (type), (inc) * sizeof (type))
312#define Prepend(type,ptr,sze,inc) (ptr) = (type *)prepend ((char *)ptr, (sze) * sizeof (type), (inc) * sizeof (type))
313
314static void 311static void
312append (T *&ptr, int sze, int inc)
313{
314 Renew (ptr, sze + inc, T);
315 Zero (ptr + sze, inc, T);
316}
317
318static void
315need_facenum (struct map *self, faceid face) 319need_facenum (struct mapgrid *self, faceid face)
316{ 320{
317 while (self->faces <= face) 321 while (self->faces <= face)
318 { 322 {
319 Append (tileid, self->face2tile, self->faces, self->faces); 323 append (self->face2tile, self->faces, self->faces);
320 self->faces *= 2; 324 self->faces *= 2;
321 } 325 }
322} 326}
323 327
324static void 328static void
325need_texid (struct map *self, int texid) 329need_texid (struct mapgrid *self, int texid)
326{ 330{
327 while (self->texs <= texid) 331 while (self->texs <= texid)
328 { 332 {
329 Append (maptex, self->tex, self->texs, self->texs); 333 append (self->tex, self->texs, self->texs);
330 self->texs *= 2; 334 self->texs *= 2;
331 } 335 }
332} 336}
333 337
334static maprow * 338static maprow *
335map_get_row (DC__Map self, int y) 339map_get_row (mapgrid *self, int y)
336{ 340{
337 if (0 > y) 341 if (0 > y)
338 { 342 {
339 int extend = - y + MAP_EXTEND_Y; 343 int extend = - y + MAP_EXTEND_Y;
340 Prepend (maprow, self->row, self->rows, extend); 344 prepend (self->row, self->rows, extend);
341 345
342 self->rows += extend; 346 self->rows += extend;
343 self->y += extend; 347 self->y += extend;
344 y += extend; 348 y += extend;
345 } 349 }
346 else if (y >= self->rows) 350 else if (y >= self->rows)
347 { 351 {
348 int extend = y - self->rows + MAP_EXTEND_Y; 352 int extend = y - self->rows + MAP_EXTEND_Y;
349 Append (maprow, self->row, self->rows, extend); 353 append (self->row, self->rows, extend);
350 self->rows += extend; 354 self->rows += extend;
351 } 355 }
352 356
353 return self->row + y; 357 return self->row + y;
354} 358}
364 } 368 }
365 369
366 if (row->c0 > x) 370 if (row->c0 > x)
367 { 371 {
368 int extend = row->c0 - x + MAP_EXTEND_X; 372 int extend = row->c0 - x + MAP_EXTEND_X;
369 Prepend (mapcell, row->col, row->c1 - row->c0, extend); 373 prepend (row->col, row->c1 - row->c0, extend);
370 row->c0 -= extend; 374 row->c0 -= extend;
371 } 375 }
372 else if (x >= row->c1) 376 else if (x >= row->c1)
373 { 377 {
374 int extend = x - row->c1 + MAP_EXTEND_X; 378 int extend = x - row->c1 + MAP_EXTEND_X;
375 Append (mapcell, row->col, row->c1 - row->c0, extend); 379 append (row->col, row->c1 - row->c0, extend);
376 row->c1 += extend; 380 row->c1 += extend;
377 } 381 }
378 382
379 return row->col + (x - row->c0); 383 return row->col + (x - row->c0);
380} 384}
381 385
382static mapcell * 386static mapcell *
383map_get_cell (DC__Map self, int x, int y) 387map_get_cell (mapgrid *self, int x, int y)
384{ 388{
385 return row_get_cell (map_get_row (self, y), x); 389 return row_get_cell (map_get_row (self, y), x);
386} 390}
387 391
388static void 392static void
389map_clear (DC__Map self) 393map_clear (mapgrid *self)
390{ 394{
391 int r; 395 int r;
392 396
393 for (r = 0; r < self->rows; r++) 397 for (r = 0; r < self->rows; r++)
394 Safefree (self->row[r].col); 398 Safefree (self->row[r].col);
412 (cell)->flags = 0; \ 416 (cell)->flags = 0; \
413 (cell)->player = 0; \ 417 (cell)->player = 0; \
414 } while (0) 418 } while (0)
415 419
416static void 420static void
417map_blank (DC__Map self, int x0, int y0, int w, int h) 421map_blank (mapgrid *self, int x0, int y0, int w, int h)
418{ 422{
419 int x, y; 423 int x, y;
420 maprow *row; 424 maprow *row;
421 mapcell *cell; 425 mapcell *cell;
422 426
439 CELL_CLEAR (cell); 443 CELL_CLEAR (cell);
440 } 444 }
441 } 445 }
442} 446}
443 447
444typedef struct { 448struct smooth_key
449{
445 tileid tile; 450 tileid tile;
446 uint8_t x, y, level; 451 uint8_t x, y, level;
447} smooth_key; 452
453 bool operator == (const smooth_key &o) const
454 {
455 return tile == o.tile && x == o.x && y == o.y && level == o.level;
456 }
457};
458
459typedef ska::flat_hash_map<smooth_key, IV> smooth_hash;
460
461namespace std {
462 template <>
463 struct hash<smooth_key>
464 {
465 size_t operator () (const smooth_key &v) const
466 {
467 return v.tile + (v.x << 8) + (v.y << 16) + (v.level << 24);
468 }
469 };
470}
448 471
449static void 472static void
450smooth_or_bits (HV *hv, smooth_key *key, IV bits) 473smooth_or_bits (smooth_hash &h, smooth_key &key, IV bits)
451{ 474{
452 SV **sv = hv_fetch (hv, (char *)key, sizeof (*key), 1); 475 auto &&it = h.find (key);
453 476
454 if (SvIOK (*sv)) 477 if (it == h.end ())
455 SvIV_set (*sv, SvIVX (*sv) | bits); 478 h.insert (std::make_pair (key, bits));
456 else 479 else
457 sv_setiv (*sv, bits); 480 it->second |= bits;
458} 481}
459 482
460static void 483static void
461music_finished (void) 484music_finished (void)
462{ 485{
481 ev.data2 = 0; 504 ev.data2 = 0;
482 505
483 SDL_PushEvent ((SDL_Event *)&ev); 506 SDL_PushEvent ((SDL_Event *)&ev);
484} 507}
485 508
509// approximately divide by 255
486static unsigned int 510static unsigned int
487div255 (unsigned int n) 511div255 (unsigned int n)
488{ 512{
489 return (n + (n >> 8)) >> 8; 513 return (n + (n >> 8)) >> 8;
490} 514}
502 n |= n >> 4; 526 n |= n >> 4;
503 n |= n >> 8; 527 n |= n >> 8;
504 n |= n >> 16; 528 n |= n >> 16;
505 529
506 return n + 1; 530 return n + 1;
507}
508
509static unsigned int
510popcount (unsigned int n)
511{
512 n -= (n >> 1) & 0x55555555U;
513 n = ((n >> 2) & 0x33333333U) + (n & 0x33333333U);
514 n = ((n >> 4) + n) & 0x0f0f0f0fU;
515 n *= 0x01010101U;
516
517 return n >> 24;
518} 531}
519 532
520/* SDL should provide this, really. */ 533/* SDL should provide this, really. */
521#define SDLK_MODIFIER_MIN 300 534#define SDLK_MODIFIER_MIN 300
522#define SDLK_MODIFIER_MAX 314 535#define SDLK_MODIFIER_MAX 314
854NV ceil (NV x) 867NV ceil (NV x)
855 868
856IV minpot (UV n) 869IV minpot (UV n)
857 870
858IV popcount (UV n) 871IV popcount (UV n)
872 CODE:
873 RETVAL = ecb_popcount32 (n);
874 OUTPUT:
875 RETVAL
859 876
860NV distance (NV dx, NV dy) 877NV distance (NV dx, NV dy)
861 CODE: 878 CODE:
862 RETVAL = pow (dx * dx + dy * dy, 0.5); 879 RETVAL = pow (dx * dx + dy * dy, 0.5);
863 OUTPUT: 880 OUTPUT:
889void SDL_QuitSubSystem (U32 flags) 906void SDL_QuitSubSystem (U32 flags)
890 907
891void SDL_Quit () 908void SDL_Quit ()
892 909
893int SDL_GL_SetAttribute (int attr, int value) 910int SDL_GL_SetAttribute (int attr, int value)
911 C_ARGS: (SDL_GLattr)attr, value
894 912
895int SDL_GL_GetAttribute (int attr) 913int SDL_GL_GetAttribute (int attr)
896 CODE: 914 CODE:
897 if (SDL_GL_GetAttribute (attr, &RETVAL)) 915 if (SDL_GL_GetAttribute ((SDL_GLattr)attr, &RETVAL))
898 XSRETURN_UNDEF; 916 XSRETURN_UNDEF;
899 OUTPUT: 917 OUTPUT:
900 RETVAL 918 RETVAL
901 919
902void 920void
975void 993void
976SDL_GL_SwapBuffers () 994SDL_GL_SwapBuffers ()
977 995
978char * 996char *
979SDL_GetKeyName (int sym) 997SDL_GetKeyName (int sym)
998 C_ARGS: (SDLKey)sym
980 999
981int 1000int
982SDL_GetAppState () 1001SDL_GetAppState ()
983 1002
984int 1003int
1081 OUTPUT: 1100 OUTPUT:
1082 RETVAL 1101 RETVAL
1083 1102
1084int 1103int
1085Mix_OpenAudio (int frequency = 44100, int format = MIX_DEFAULT_FORMAT, int channels = 2, int chunksize = 4096) 1104Mix_OpenAudio (int frequency = 44100, int format = MIX_DEFAULT_FORMAT, int channels = 2, int chunksize = 4096)
1086 POSTCALL: 1105 POSTCALL:
1087 Mix_HookMusicFinished (music_finished); 1106 Mix_HookMusicFinished (music_finished);
1088 Mix_ChannelFinished (channel_finished); 1107 Mix_ChannelFinished (channel_finished);
1089 1108
1090void 1109void
1091Mix_QuerySpec () 1110Mix_QuerySpec ()
1212 1231
1213 SDL_LockSurface (surface2); 1232 SDL_LockSurface (surface2);
1214 EXTEND (SP, 6); 1233 EXTEND (SP, 6);
1215 PUSHs (sv_2mortal (newSViv (surface2->w))); 1234 PUSHs (sv_2mortal (newSViv (surface2->w)));
1216 PUSHs (sv_2mortal (newSViv (surface2->h))); 1235 PUSHs (sv_2mortal (newSViv (surface2->h)));
1217 PUSHs (sv_2mortal (newSVpvn (surface2->pixels, surface2->h * surface2->pitch))); 1236 PUSHs (sv_2mortal (newSVpvn ((const char *)surface2->pixels, surface2->h * surface2->pitch)));
1218 PUSHs (sv_2mortal (newSViv (surface->flags & (SDL_SRCCOLORKEY | SDL_SRCALPHA) ? GL_RGBA : GL_RGB))); 1237 PUSHs (sv_2mortal (newSViv (surface->flags & (SDL_SRCCOLORKEY | SDL_SRCALPHA) ? GL_RGBA : GL_RGB)));
1219 PUSHs (sv_2mortal (newSViv (GL_RGBA))); 1238 PUSHs (sv_2mortal (newSViv (GL_RGBA)));
1220 PUSHs (sv_2mortal (newSViv (GL_UNSIGNED_BYTE))); 1239 PUSHs (sv_2mortal (newSViv (GL_UNSIGNED_BYTE)));
1221 SDL_UnlockSurface (surface2); 1240 SDL_UnlockSurface (surface2);
1222 1241
1294MODULE = Deliantra::Client PACKAGE = DC::Font 1313MODULE = Deliantra::Client PACKAGE = DC::Font
1295 1314
1296PROTOTYPES: DISABLE 1315PROTOTYPES: DISABLE
1297 1316
1298DC::Font 1317DC::Font
1299new_from_file (SV *class, char *path, int id = 0) 1318new_from_file (SV *klass, char *path, int id = 0)
1300 CODE: 1319 CODE:
1301{ 1320{
1302 int count; 1321 int count;
1303 FcPattern *pattern = FcFreeTypeQuery ((const FcChar8 *)path, id, 0, &count); 1322 FcPattern *pattern = FcFreeTypeQuery ((const FcChar8 *)path, id, 0, &count);
1304 RETVAL = pango_fc_font_description_from_pattern (pattern, 0); 1323 RETVAL = pango_fc_font_description_from_pattern (pattern, 0);
1333 PROTOTYPE: 1352 PROTOTYPE:
1334 CODE: 1353 CODE:
1335 tc_restore (); 1354 tc_restore ();
1336 1355
1337DC::Layout 1356DC::Layout
1338new (SV *class) 1357new (SV *klass)
1339 CODE: 1358 CODE:
1340 New (0, RETVAL, 1, struct cf_layout); 1359 RETVAL = new cf_layout;
1341 1360
1342 RETVAL->pl = pango_layout_new (opengl_context); 1361 RETVAL->pl = pango_layout_new (opengl_context);
1343 RETVAL->r = 1.; 1362 RETVAL->r = 1.;
1344 RETVAL->g = 1.; 1363 RETVAL->g = 1.;
1345 RETVAL->b = 1.; 1364 RETVAL->b = 1.;
1346 RETVAL->a = 1.; 1365 RETVAL->a = 1.;
1347 RETVAL->base_height = MIN_FONT_HEIGHT; 1366 RETVAL->base_height = MIN_FONT_HEIGHT;
1348 RETVAL->font = 0; 1367 RETVAL->font = 0;
1349 RETVAL->rc = rc_alloc ();
1350 1368
1351 pango_layout_set_wrap (RETVAL->pl, PANGO_WRAP_WORD_CHAR); 1369 pango_layout_set_wrap (RETVAL->pl, PANGO_WRAP_WORD_CHAR);
1352 layout_update_font (RETVAL); 1370 layout_update_font (RETVAL);
1353 OUTPUT: 1371 OUTPUT:
1354 RETVAL 1372 RETVAL
1355 1373
1356void 1374void
1357DESTROY (DC::Layout self) 1375DESTROY (DC::Layout self)
1358 CODE: 1376 CODE:
1359 g_object_unref (self->pl); 1377 g_object_unref (self->pl);
1360 rc_free (self->rc);
1361 Safefree (self); 1378 delete self;
1362 1379
1363void 1380void
1364set_text (DC::Layout self, SV *text_) 1381set_text (DC::Layout self, SV *text_)
1365 CODE: 1382 CODE:
1366{ 1383{
1620} 1637}
1621 1638
1622void 1639void
1623render (DC::Layout self, float x, float y, int flags = 0) 1640render (DC::Layout self, float x, float y, int flags = 0)
1624 CODE: 1641 CODE:
1625 rc_clear (self->rc); 1642 self->rc.clear ();
1626 pango_opengl_render_layout_subpixel ( 1643 pango_opengl_render_layout_subpixel (
1627 self->pl, 1644 self->pl,
1628 self->rc, 1645 &self->rc,
1629 x * PANGO_SCALE, y * PANGO_SCALE, 1646 x * PANGO_SCALE, y * PANGO_SCALE,
1630 self->r, self->g, self->b, self->a, 1647 self->r, self->g, self->b, self->a,
1631 flags 1648 flags
1632 ); 1649 );
1633 // we assume that context_change actually clears/frees stuff 1650 // we assume that context_change actually clears/frees stuff
1644 gl_BlendFuncSeparate (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, 1661 gl_BlendFuncSeparate (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA,
1645 GL_ONE , GL_ONE_MINUS_SRC_ALPHA); 1662 GL_ONE , GL_ONE_MINUS_SRC_ALPHA);
1646 glEnable (GL_ALPHA_TEST); 1663 glEnable (GL_ALPHA_TEST);
1647 glAlphaFunc (GL_GREATER, 7.f / 255.f); 1664 glAlphaFunc (GL_GREATER, 7.f / 255.f);
1648 1665
1649 rc_draw (self->rc); 1666 self->rc.draw ();
1650 1667
1651 glDisable (GL_ALPHA_TEST); 1668 glDisable (GL_ALPHA_TEST);
1652 glDisable (GL_BLEND); 1669 glDisable (GL_BLEND);
1653 glDisable (GL_TEXTURE_2D); 1670 glDisable (GL_TEXTURE_2D);
1654} 1671}
1866MODULE = Deliantra::Client PACKAGE = DC::Map 1883MODULE = Deliantra::Client PACKAGE = DC::Map
1867 1884
1868PROTOTYPES: DISABLE 1885PROTOTYPES: DISABLE
1869 1886
1870DC::Map 1887DC::Map
1871new (SV *class) 1888new (SV *klass)
1872 CODE: 1889 CODE:
1873 New (0, RETVAL, 1, struct map); 1890 New (0, RETVAL, 1, mapgrid);
1874 RETVAL->x = 0; 1891 RETVAL->x = 0;
1875 RETVAL->y = 0; 1892 RETVAL->y = 0;
1876 RETVAL->w = 0; 1893 RETVAL->w = 0;
1877 RETVAL->h = 0; 1894 RETVAL->h = 0;
1878 RETVAL->ox = 0; 1895 RETVAL->ox = 0;
1915 1932
1916void 1933void
1917set_smooth (DC::Map self, int face, int smooth, int level) 1934set_smooth (DC::Map self, int face, int smooth, int level)
1918 CODE: 1935 CODE:
1919{ 1936{
1920 tileid texid; 1937 tileid texid;
1921 maptex *tex; 1938 maptex *tex;
1922 1939
1923 if (face < 0 || face >= self->faces) 1940 if (face < 0 || face >= self->faces)
1924 return; 1941 return;
1925 1942
1926 if (smooth < 0 || smooth >= self->faces) 1943 if (smooth < 0 || smooth >= self->faces)
1927 return; 1944 return;
1928 1945
1929 texid = self->face2tile [face]; 1946 texid = self->face2tile [face];
1930 1947
1931 if (!texid) 1948 if (!texid)
1932 return; 1949 return;
1933 1950
1934 tex = self->tex + texid; 1951 tex = self->tex + texid;
1967} 1984}
1968 1985
1969void 1986void
1970expire_textures (DC::Map self, int texid, int count) 1987expire_textures (DC::Map self, int texid, int count)
1971 PPCODE: 1988 PPCODE:
1972 for (; texid < self->texs && count; ++texid, --count) 1989 for (; texid < self->texs && count; ++texid, --count)
1973 { 1990 {
1974 maptex *tex = self->tex + texid; 1991 maptex *tex = self->tex + texid;
1975 1992
1976 if (tex->name) 1993 if (tex->name)
1977 { 1994 {
2024 self->ox += dx; self->x += dx; 2041 self->ox += dx; self->x += dx;
2025 self->oy += dy; self->y += dy; 2042 self->oy += dy; self->y += dy;
2026 2043
2027 while (self->y < 0) 2044 while (self->y < 0)
2028 { 2045 {
2029 Prepend (maprow, self->row, self->rows, MAP_EXTEND_Y); 2046 prepend (self->row, self->rows, MAP_EXTEND_Y);
2030 2047
2031 self->rows += MAP_EXTEND_Y; 2048 self->rows += MAP_EXTEND_Y;
2032 self->y += MAP_EXTEND_Y; 2049 self->y += MAP_EXTEND_Y;
2033 } 2050 }
2034} 2051}
2179 | (b << 16) 2196 | (b << 16)
2180 | (a << 24); 2197 | (a << 24);
2181 } 2198 }
2182 } 2199 }
2183 2200
2184 RETVAL = map_sv; 2201 RETVAL = map_sv;
2185} 2202}
2186 OUTPUT: 2203 OUTPUT:
2187 RETVAL 2204 RETVAL
2188 2205
2189void 2206void
2190draw (DC::Map self, int mx, int my, int sw, int sh, int Tw, int Th, U32 player = 0xffffffff, int sdx = 0, int sdy = 0) 2207draw (DC::Map self, int mx, int my, int sw, int sh, int Tw, int Th, U32 player = 0xffffffff, int sdx = 0, int sdy = 0)
2191 CODE: 2208 CODE:
2192{ 2209{
2193 int x, y, z; 2210 int x, y, z;
2194 2211
2195 HV *smooth = (HV *)sv_2mortal ((SV *)newHV ());
2196 uint32_t smooth_level[256 / 32]; // one bit for every possible smooth level
2197 static uint8_t smooth_max[256][256]; // egad, fast and wasteful on memory (64k) 2212 static uint8_t smooth_max[256][256]; // egad, fast and wasteful on memory (64k), also, static!
2198 smooth_key skey;
2199 int pl_x, pl_y; 2213 int pl_x, pl_y;
2200 maptex pl_tex; 2214 maptex pl_tex;
2201 rc_t *rc = rc_alloc (); 2215 rc_t rc;
2202 rc_t *rc_ov = rc_alloc (); 2216 rc_t rc_ov;
2203 rc_key_t key; 2217 rc_key_t key;
2204 rc_array_t *arr; 2218 rc_t::array_t *arr;
2205 2219
2206 pl_tex.name = 0; 2220 pl_tex.name = 0;
2207 2221
2208 // that's current max. sorry. 2222 // that's current max. sorry.
2209 if (sw > 255) sw = 255; 2223 if (sw > 255) sw = 255;
2210 if (sh > 255) sh = 255; 2224 if (sh > 255) sh = 255;
2211
2212 // clear key, in case of extra padding
2213 memset (&skey, 0, sizeof (skey));
2214 2225
2215 memset (&key, 0, sizeof (key)); 2226 memset (&key, 0, sizeof (key));
2216 key.r = 255; 2227 key.r = 255;
2217 key.g = 255; 2228 key.g = 255;
2218 key.b = 255; 2229 key.b = 255;
2224 my += self->y; 2235 my += self->y;
2225 2236
2226 // first pass: determine smooth_max 2237 // first pass: determine smooth_max
2227 // rather ugly, if you ask me 2238 // rather ugly, if you ask me
2228 // could also be stored inside mapcell and updated on change 2239 // could also be stored inside mapcell and updated on change
2229 memset (smooth_max, 0, sizeof (smooth_max)); 2240 memset (smooth_max, 0, sizeof (smooth_max[0]) * (sh + 1));
2230 2241
2231 for (y = 0; y < sh; y++) 2242 for (y = 0; y < sh; y++)
2232 if (0 <= y + my && y + my < self->rows) 2243 if (0 <= y + my && y + my < self->rows)
2233 { 2244 {
2234 maprow *row = self->row + (y + my); 2245 maprow *row = self->row + (y + my);
2249 glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 2260 glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
2250 glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); 2261 glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
2251 2262
2252 for (z = 0; z <= 2; z++) 2263 for (z = 0; z <= 2; z++)
2253 { 2264 {
2254 memset (smooth_level, 0, sizeof (smooth_level)); 2265 std::bitset<256> smooth_level; // one bit for every possible smooth level
2266 smooth_key skey;
2267 smooth_hash smooth;
2255 key.texname = -1; 2268 key.texname = -1;
2256 2269
2257 for (y = 0; y < sh; y++) 2270 for (y = 0; y < sh; y++)
2258 if (0 <= y + my && y + my < self->rows) 2271 if (0 <= y + my && y + my < self->rows)
2259 { 2272 {
2276 2289
2277 if (!tex.name) 2290 if (!tex.name)
2278 tex = self->tex [TEXID_NOFACE]; /* missing, replace by noface */ 2291 tex = self->tex [TEXID_NOFACE]; /* missing, replace by noface */
2279 2292
2280 key.texname = tex.name; 2293 key.texname = tex.name;
2281 arr = rc_array (rc, &key); 2294 arr = &rc.array (key);
2282 } 2295 }
2283 2296
2284 px = (x + 1) * Th - tex.w; 2297 px = (x + 1) * Th - tex.w;
2285 py = (y + 1) * Tw - tex.h; 2298 py = (y + 1) * Tw - tex.h;
2286 2299
2287 if (expect_false (cell->player == player) && expect_false (z == 2)) 2300 if (ecb_expect_false (cell->player == player) && ecb_expect_false (z == 2))
2288 { 2301 {
2289 pl_x = px; 2302 pl_x = px;
2290 pl_y = py; 2303 pl_y = py;
2291 pl_tex = tex; 2304 pl_tex = tex;
2292 continue; 2305 continue;
2293 } 2306 }
2294 2307
2295 rc_t2f_v3f (arr, 0 , 0 , px , py , 0); 2308 arr->t2f_v3f (0 , 0 , px , py , 0);
2296 rc_t2f_v3f (arr, 0 , tex.t, px , py + tex.h, 0); 2309 arr->t2f_v3f (0 , tex.t, px , py + tex.h, 0);
2297 rc_t2f_v3f (arr, tex.s, tex.t, px + tex.w, py + tex.h, 0); 2310 arr->t2f_v3f (tex.s, tex.t, px + tex.w, py + tex.h, 0);
2298 rc_t2f_v3f (arr, tex.s, 0 , px + tex.w, py , 0); 2311 arr->t2f_v3f (tex.s, 0 , px + tex.w, py , 0);
2299 2312
2300 // update smooth hash 2313 // update smooth hash
2301 if (tex.smoothtile) 2314 if (tex.smoothtile)
2302 { 2315 {
2303 skey.tile = tex.smoothtile; 2316 skey.tile = tex.smoothtile;
2304 skey.level = tex.smoothlevel; 2317 skey.level = tex.smoothlevel;
2305 2318
2306 smooth_level [tex.smoothlevel >> 5] |= ((uint32_t)1) << (tex.smoothlevel & 31); 2319 smooth_level[tex.smoothlevel] = 1;
2307 2320
2308 // add bits to current tile and all neighbours. skey.x|y is 2321 // add bits to current tile and all neighbours. skey.x|y is
2309 // shifted +1|+1 so we always stay positive. 2322 // shifted +1|+1 so we always stay positive.
2310 2323
2311 // bits is ___n cccc CCCC bbbb 2324 // bits is ___n cccc CCCC bbbb
2319 2332
2320 // corners: 1 ┛· 2 ·┗ 4 ·· 8 ·· 2333 // corners: 1 ┛· 2 ·┗ 4 ·· 8 ··
2321 // ·· ·· ·┏ ┓· 2334 // ·· ·· ·┏ ┓·
2322 2335
2323 // full tile 2336 // full tile
2324 skey.x = x + 1; skey.y = y + 1; smooth_or_bits (smooth, &skey, 0x1000); 2337 skey.x = x + 1; skey.y = y + 1; smooth_or_bits (smooth, skey, 0x1000);
2325 2338
2326 // borders 2339 // borders
2327 skey.x = x + 2; skey.y = y + 1; smooth_or_bits (smooth, &skey, 0x0091); 2340 skey.x = x + 2; skey.y = y + 1; smooth_or_bits (smooth, skey, 0x0091);
2328 skey.x = x + 1; skey.y = y + 2; smooth_or_bits (smooth, &skey, 0x0032); 2341 skey.x = x + 1; skey.y = y + 2; smooth_or_bits (smooth, skey, 0x0032);
2329 skey.x = x ; skey.y = y + 1; smooth_or_bits (smooth, &skey, 0x0064); 2342 skey.x = x ; skey.y = y + 1; smooth_or_bits (smooth, skey, 0x0064);
2330 skey.x = x + 1; skey.y = y ; smooth_or_bits (smooth, &skey, 0x00c8); 2343 skey.x = x + 1; skey.y = y ; smooth_or_bits (smooth, skey, 0x00c8);
2331 2344
2332 // corners 2345 // corners
2333 skey.x = x + 2; skey.y = y + 2; smooth_or_bits (smooth, &skey, 0x0100); 2346 skey.x = x + 2; skey.y = y + 2; smooth_or_bits (smooth, skey, 0x0100);
2334 skey.x = x ; skey.y = y + 2; smooth_or_bits (smooth, &skey, 0x0200); 2347 skey.x = x ; skey.y = y + 2; smooth_or_bits (smooth, skey, 0x0200);
2335 skey.x = x ; skey.y = y ; smooth_or_bits (smooth, &skey, 0x0400); 2348 skey.x = x ; skey.y = y ; smooth_or_bits (smooth, skey, 0x0400);
2336 skey.x = x + 2; skey.y = y ; smooth_or_bits (smooth, &skey, 0x0800); 2349 skey.x = x + 2; skey.y = y ; smooth_or_bits (smooth, skey, 0x0800);
2337 } 2350 }
2338 } 2351 }
2339 2352
2340 if (expect_false (z == 2) && expect_false (cell->flags)) 2353 if (ecb_expect_false (z == 2) && ecb_expect_false (cell->flags))
2341 { 2354 {
2342 // overlays such as the speech bubble, probably more to come 2355 // overlays such as the speech bubble, probably more to come
2343 if (cell->flags & 1) 2356 if (cell->flags & 1)
2344 { 2357 {
2345 rc_key_t key_ov = key; 2358 rc_key_t key_ov = key;
2346 maptex tex = self->tex [TEXID_SPEECH]; 2359 maptex tex = self->tex[TEXID_SPEECH];
2347 rc_array_t *arr;
2348 int px = x * Tw + Tw * 2 / 32; 2360 int px = x * Tw + Tw * 2 / 32;
2349 int py = y * Th - Th * 6 / 32; 2361 int py = y * Th - Th * 6 / 32;
2350 2362
2351 key_ov.texname = tex.name; 2363 key_ov.texname = tex.name;
2352 arr = rc_array (rc_ov, &key_ov); 2364 rc_t::array_t &arr = rc_ov.array (key_ov);
2353 2365
2354 rc_t2f_v3f (arr, 0 , 0 , px , py , 0); 2366 arr.t2f_v3f (0 , 0 , px , py , 0);
2355 rc_t2f_v3f (arr, 0 , tex.t, px , py + Th, 0); 2367 arr.t2f_v3f (0 , tex.t, px , py + Th, 0);
2356 rc_t2f_v3f (arr, tex.s, tex.t, px + Tw, py + Th, 0); 2368 arr.t2f_v3f (tex.s, tex.t, px + Tw, py + Th, 0);
2357 rc_t2f_v3f (arr, tex.s, 0 , px + Tw, py , 0); 2369 arr.t2f_v3f (tex.s, 0 , px + Tw, py , 0);
2358 } 2370 }
2359 } 2371 }
2360 } 2372 }
2361 } 2373 }
2362 2374
2363 rc_draw (rc); 2375 rc.draw ();
2364 rc_clear (rc); 2376 rc.clear ();
2365 2377
2366 // go through all smoothlevels, lowest to highest, then draw. 2378 // go through all smoothlevels, lowest to highest, then draw.
2367 // this is basically counting sort 2379 // this is basically counting sort
2368 { 2380 {
2369 int w, b; 2381 int w, b;
2370 2382
2371 glEnable (GL_TEXTURE_2D); 2383 glEnable (GL_TEXTURE_2D);
2372 glBegin (GL_QUADS); 2384 glBegin (GL_QUADS);
2373 for (w = 0; w < 256 / 32; ++w) 2385 for (int level = 0; level < smooth_level.size (); ++level)
2386 if (smooth_level[level])
2387 for (auto &&it = smooth.begin (); it != smooth.end (); ++it)
2374 { 2388 {
2375 uint32_t smask = smooth_level [w]; 2389 smooth_key &skey = it->first;
2376 if (smask) 2390 IV bits = it->second;
2377 for (b = 0; b < 32; ++b) 2391
2378 if (smask & (((uint32_t)1) << b)) 2392 if (!(bits & 0x1000)
2393 && skey.level == level
2394 && level > smooth_max [skey.x][skey.y])
2379 { 2395 {
2380 int level = (w << 5) | b; 2396 maptex tex = self->tex [skey.tile];
2397 int px = (((int)skey.x) - 1) * Tw;
2398 int py = (((int)skey.y) - 1) * Th;
2399 int border = bits & 15;
2400 int corner = (bits >> 8) & ~(bits >> 4) & 15;
2401 float dx = tex.s * .0625f; // 16 images/row
2402 float dy = tex.t * .5f ; // 2 images/column
2403
2381 HE *he; 2404 if (tex.name)
2382
2383 hv_iterinit (smooth);
2384 while ((he = hv_iternext (smooth)))
2385 { 2405 {
2386 smooth_key *skey = (smooth_key *)HeKEY (he); 2406 // this time avoiding texture state changes
2387 IV bits = SvIVX (HeVAL (he)); 2407 // save gobs of state changes.
2388 2408 if (key.texname != tex.name)
2389 if (!(bits & 0x1000)
2390 && skey->level == level
2391 && level > smooth_max [skey->x][skey->y])
2392 { 2409 {
2393 maptex tex = self->tex [skey->tile];
2394 int px = (((int)skey->x) - 1) * Tw;
2395 int py = (((int)skey->y) - 1) * Th;
2396 int border = bits & 15;
2397 int corner = (bits >> 8) & ~(bits >> 4) & 15;
2398 float dx = tex.s * .0625f; // 16 images/row
2399 float dy = tex.t * .5f ; // 2 images/column
2400
2401 if (tex.name)
2402 {
2403 // this time avoiding texture state changes
2404 // save gobs of state changes.
2405 if (key.texname != tex.name)
2406 {
2407 self->tex [skey->tile].unused = 0; 2410 self->tex [skey.tile].unused = 0;
2408 2411
2409 glEnd (); 2412 glEnd ();
2410 glBindTexture (GL_TEXTURE_2D, key.texname = tex.name); 2413 glBindTexture (GL_TEXTURE_2D, key.texname = tex.name);
2411 glBegin (GL_QUADS); 2414 glBegin (GL_QUADS);
2412 } 2415 }
2413 2416
2414 if (border) 2417 if (border)
2415 { 2418 {
2416 float ox = border * dx; 2419 float ox = border * dx;
2417 2420
2418 glTexCoord2f (ox , 0.f ); glVertex2i (px , py ); 2421 glTexCoord2f (ox , 0.f ); glVertex2i (px , py );
2419 glTexCoord2f (ox , dy ); glVertex2i (px , py + Th); 2422 glTexCoord2f (ox , dy ); glVertex2i (px , py + Th);
2420 glTexCoord2f (ox + dx, dy ); glVertex2i (px + Tw, py + Th); 2423 glTexCoord2f (ox + dx, dy ); glVertex2i (px + Tw, py + Th);
2421 glTexCoord2f (ox + dx, 0.f ); glVertex2i (px + Tw, py ); 2424 glTexCoord2f (ox + dx, 0.f ); glVertex2i (px + Tw, py );
2422 } 2425 }
2423 2426
2424 if (corner) 2427 if (corner)
2425 { 2428 {
2426 float ox = corner * dx; 2429 float ox = corner * dx;
2427 2430
2428 glTexCoord2f (ox , dy ); glVertex2i (px , py ); 2431 glTexCoord2f (ox , dy ); glVertex2i (px , py );
2429 glTexCoord2f (ox , dy * 2.f); glVertex2i (px , py + Th); 2432 glTexCoord2f (ox , dy * 2.f); glVertex2i (px , py + Th);
2430 glTexCoord2f (ox + dx, dy * 2.f); glVertex2i (px + Tw, py + Th); 2433 glTexCoord2f (ox + dx, dy * 2.f); glVertex2i (px + Tw, py + Th);
2431 glTexCoord2f (ox + dx, dy ); glVertex2i (px + Tw, py ); 2434 glTexCoord2f (ox + dx, dy ); glVertex2i (px + Tw, py );
2432 }
2433 }
2434 } 2435 }
2435 } 2436 }
2436 } 2437 }
2437 } 2438 }
2438 2439
2439 glEnd (); 2440 glEnd ();
2440 glDisable (GL_TEXTURE_2D); 2441 glDisable (GL_TEXTURE_2D);
2441 key.texname = -1; 2442 key.texname = -1;
2442 } 2443 }
2443
2444 hv_clear (smooth);
2445 } 2444 }
2446 2445
2447 if (pl_tex.name) 2446 if (pl_tex.name)
2448 { 2447 {
2449 maptex tex = pl_tex; 2448 maptex tex = pl_tex;
2450 int px = pl_x + sdx; 2449 int px = pl_x + sdx;
2451 int py = pl_y + sdy; 2450 int py = pl_y + sdy;
2452 2451
2453 key.texname = tex.name; 2452 key.texname = tex.name;
2454 arr = rc_array (rc, &key); 2453 rc_t::array_t &arr = rc.array (key);
2455 2454
2456 rc_t2f_v3f (arr, 0 , 0 , px , py , 0); 2455 arr.t2f_v3f (0 , 0 , px , py , 0);
2457 rc_t2f_v3f (arr, 0 , tex.t, px , py + tex.h, 0); 2456 arr.t2f_v3f (0 , tex.t, px , py + tex.h, 0);
2458 rc_t2f_v3f (arr, tex.s, tex.t, px + tex.w, py + tex.h, 0); 2457 arr.t2f_v3f (tex.s, tex.t, px + tex.w, py + tex.h, 0);
2459 rc_t2f_v3f (arr, tex.s, 0 , px + tex.w, py , 0); 2458 arr.t2f_v3f (tex.s, 0 , px + tex.w, py , 0);
2460 2459
2461 rc_draw (rc); 2460 rc.draw ();
2462 } 2461 }
2463 2462
2464 rc_draw (rc_ov); 2463 rc_ov.draw ();
2465 rc_clear (rc_ov); 2464 rc_ov.clear ();
2466 2465
2467 glDisable (GL_BLEND); 2466 glDisable (GL_BLEND);
2468 rc_free (rc);
2469 rc_free (rc_ov);
2470 2467
2471 // top layer: overlays such as the health bar 2468 // top layer: overlays such as the health bar
2472 for (y = 0; y < sh; y++) 2469 for (y = 0; y < sh; y++)
2473 if (0 <= y + my && y + my < self->rows) 2470 if (0 <= y + my && y + my < self->rows)
2474 { 2471 {
2480 mapcell *cell = row->col + (x + mx - row->c0); 2477 mapcell *cell = row->col + (x + mx - row->c0);
2481 2478
2482 int px = x * Tw; 2479 int px = x * Tw;
2483 int py = y * Th; 2480 int py = y * Th;
2484 2481
2485 if (expect_false (cell->player == player)) 2482 if (ecb_expect_false (cell->player == player))
2486 { 2483 {
2487 px += sdx; 2484 px += sdx;
2488 py += sdy; 2485 py += sdy;
2489 } 2486 }
2490 2487
2718 else 2715 else
2719 *data++ = 0; 2716 *data++ = 0;
2720 } 2717 }
2721 } 2718 }
2722 2719
2723 /* if size is w*h + 5 then no data has been found */ 2720 /* if size is w*h + 5 then no data has been found */
2724 if (data - (uint8_t *)SvPVX (data_sv) != w * h + 5) 2721 if (data - (uint8_t *)SvPVX (data_sv) != w * h + 5)
2725 { 2722 {
2726 SvPOK_only (data_sv); 2723 SvPOK_only (data_sv);
2727 SvCUR_set (data_sv, data - (uint8_t *)SvPVX (data_sv)); 2724 SvCUR_set (data_sv, data - (uint8_t *)SvPVX (data_sv));
2728 } 2725 }
2729 2726
2730 RETVAL = data_sv; 2727 RETVAL = data_sv;
2731} 2728}
2732 OUTPUT: 2729 OUTPUT:
2733 RETVAL 2730 RETVAL
2734 2731
2735void 2732void
2742 STRLEN len; 2739 STRLEN len;
2743 uint8_t *data, *end; 2740 uint8_t *data, *end;
2744 2741
2745 len = SvLEN (data_sv); 2742 len = SvLEN (data_sv);
2746 SvGROW (data_sv, len + 8); // reserve at least 7+ bytes more 2743 SvGROW (data_sv, len + 8); // reserve at least 7+ bytes more
2747 data = SvPVbyte_nolen (data_sv); 2744 data = (uint8_t *)SvPVbyte_nolen (data_sv);
2748 end = data + len + 8; 2745 end = data + len + 8;
2749 2746
2750 if (len < 5) 2747 if (len < 5)
2751 XSRETURN_EMPTY; 2748 XSRETURN_EMPTY;
2752 2749
2813} 2810}
2814 2811
2815MODULE = Deliantra::Client PACKAGE = DC::RW 2812MODULE = Deliantra::Client PACKAGE = DC::RW
2816 2813
2817DC::RW 2814DC::RW
2818new (SV *class, SV *data_sv) 2815new (SV *klass, SV *data_sv)
2819 CODE: 2816 CODE:
2820{ 2817{
2821 STRLEN datalen; 2818 STRLEN datalen;
2822 char *data = SvPVbyte (data_sv, datalen); 2819 char *data = SvPVbyte (data_sv, datalen);
2823 2820
2825} 2822}
2826 OUTPUT: 2823 OUTPUT:
2827 RETVAL 2824 RETVAL
2828 2825
2829DC::RW 2826DC::RW
2830new_from_file (SV *class, const char *path, const char *mode = "rb") 2827new_from_file (SV *klass, const char *path, const char *mode = "rb")
2831 CODE: 2828 CODE:
2832 RETVAL = SDL_RWFromFile (path, mode); 2829 RETVAL = SDL_RWFromFile (path, mode);
2833 OUTPUT: 2830 OUTPUT:
2834 RETVAL 2831 RETVAL
2835 2832
2944#else 2941#else
2945 XPUSHs (sv_2mortal (newSVpv ("(sdl mixer too old)", 0))); 2942 XPUSHs (sv_2mortal (newSVpv ("(sdl mixer too old)", 0)));
2946#endif 2943#endif
2947 2944
2948DC::MixChunk 2945DC::MixChunk
2949new (SV *class, DC::RW rwops) 2946new (SV *klass, DC::RW rwops)
2950 CODE: 2947 CODE:
2951 RETVAL = Mix_LoadWAV_RW (rwops, 1); 2948 RETVAL = Mix_LoadWAV_RW (rwops, 1);
2952 OUTPUT: 2949 OUTPUT:
2953 RETVAL 2950 RETVAL
2954 2951
3024 RETVAL = Mix_PlayingMusic (); 3021 RETVAL = Mix_PlayingMusic ();
3025 OUTPUT: 3022 OUTPUT:
3026 RETVAL 3023 RETVAL
3027 3024
3028DC::MixMusic 3025DC::MixMusic
3029new (SV *class, DC::RW rwops) 3026new (SV *klass, DC::RW rwops)
3030 CODE: 3027 CODE:
3031 RETVAL = Mix_LoadMUS_RW (rwops); 3028 RETVAL = Mix_LoadMUS_RW (rwops);
3032 OUTPUT: 3029 OUTPUT:
3033 RETVAL 3030 RETVAL
3034 3031
3187 gl.BlendFuncSeparateEXT = 0; 3184 gl.BlendFuncSeparateEXT = 0;
3188 3185
3189void 3186void
3190apple_nvidia_bug (int enable) 3187apple_nvidia_bug (int enable)
3191 3188
3192char * 3189const char *
3193gl_vendor () 3190gl_vendor ()
3194 CODE: 3191 CODE:
3195 RETVAL = (char *)glGetString (GL_VENDOR); 3192 RETVAL = (const char *)glGetString (GL_VENDOR);
3196 OUTPUT: 3193 OUTPUT:
3197 RETVAL 3194 RETVAL
3198 3195
3199char * 3196const char *
3200gl_version () 3197gl_version ()
3201 CODE: 3198 CODE:
3202 RETVAL = (char *)glGetString (GL_VERSION); 3199 RETVAL = (const char *)glGetString (GL_VERSION);
3203 OUTPUT: 3200 OUTPUT:
3204 RETVAL 3201 RETVAL
3205 3202
3206char * 3203const char *
3207gl_extensions () 3204gl_extensions ()
3208 CODE: 3205 CODE:
3209 RETVAL = (char *)glGetString (GL_EXTENSIONS); 3206 RETVAL = (const char *)glGetString (GL_EXTENSIONS);
3210 OUTPUT: 3207 OUTPUT:
3211 RETVAL 3208 RETVAL
3212 3209
3213const char *glGetString (GLenum pname) 3210const char *glGetString (GLenum pname)
3211 CODE:
3212 RETVAL = (const char *)glGetString (pname);
3213 OUTPUT:
3214 RETVAL
3214 3215
3215GLint glGetInteger (GLenum pname) 3216GLint glGetInteger (GLenum pname)
3216 CODE: 3217 CODE:
3217 glGetIntegerv (pname, &RETVAL); 3218 glGetIntegerv (pname, &RETVAL);
3218 OUTPUT: 3219 OUTPUT:
3421 3422
3422void 3423void
3423find_widget (SV *self, NV x, NV y) 3424find_widget (SV *self, NV x, NV y)
3424 PPCODE: 3425 PPCODE:
3425{ 3426{
3426 if (within_widget (self, x, y)) 3427 if (within_widget (self, x, y))
3427 XPUSHs (self); 3428 XPUSHs (self);
3428} 3429}
3429 3430
3430BOOT: 3431BOOT:
3431{ 3432{
3439 3440
3440void 3441void
3441draw (SV *self) 3442draw (SV *self)
3442 CODE: 3443 CODE:
3443{ 3444{
3444 HV *hv; 3445 HV *hv;
3445 SV **svp; 3446 SV **svp;
3446 NV x, y, w, h; 3447 NV x, y, w, h;
3447 SV *draw_x_sv = GvSV (draw_x_gv); 3448 SV *draw_x_sv = GvSV (draw_x_gv);
3448 SV *draw_y_sv = GvSV (draw_y_gv); 3449 SV *draw_y_sv = GvSV (draw_y_gv);
3449 SV *draw_w_sv = GvSV (draw_w_gv); 3450 SV *draw_w_sv = GvSV (draw_w_gv);
3450 SV *draw_h_sv = GvSV (draw_h_gv); 3451 SV *draw_h_sv = GvSV (draw_h_gv);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines