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.314 by root, Wed Jan 18 15:31:51 2012 UTC vs.
Revision 1.326 by root, Sun Nov 18 03:06:13 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>
48#endif 53#endif
49 54
50#define PANGO_ENABLE_BACKEND 55#define PANGO_ENABLE_BACKEND
51#define G_DISABLE_CAST_CHECKS 56#define G_DISABLE_CAST_CHECKS
52 57
53#include <glib/gmacros.h> 58#include <glib.h>
54 59
55#include <pango/pango.h> 60#include <pango/pango.h>
56 61
57#ifndef PANGO_VERSION_CHECK 62#ifndef PANGO_VERSION_CHECK
58# define PANGO_VERSION_CHECK(a,b,c) 0 63# define PANGO_VERSION_CHECK(a,b,c) 0
184{ 189{
185 GSList *attrs = run->item->analysis.extra_attrs; 190 GSList *attrs = run->item->analysis.extra_attrs;
186 191
187 while (attrs) 192 while (attrs)
188 { 193 {
189 PangoAttribute *attr = attrs->data; 194 PangoAttribute *attr = (PangoAttribute *)attrs->data;
190 195
191 if (attr->klass->type == PANGO_ATTR_SHAPE) 196 if (attr->klass->type == PANGO_ATTR_SHAPE)
192 return 1; 197 return 1;
193 198
194 attrs = attrs->next; 199 attrs = attrs->next;
195 } 200 }
196 201
197 return 0; 202 return 0;
198} 203}
199 204
200typedef struct cf_layout { 205struct cf_layout {
201 PangoLayout *pl; 206 PangoLayout *pl;
202 float r, g, b, a; // default color for rgba mode 207 float r, g, b, a; // default color for rgba mode
203 int base_height; 208 int base_height;
204 DC__Font font; 209 DC__Font font;
205 rc_t *rc; 210 rc_t rc;
206} *DC__Layout; 211};
212
213typedef cf_layout *DC__Layout;
207 214
208static DC__Font default_font; 215static DC__Font default_font;
209static PangoContext *opengl_context; 216static PangoContext *opengl_context;
210static PangoFontMap *opengl_fontmap; 217static PangoFontMap *opengl_fontmap;
211 218
212static void 219static void
213substitute_func (FcPattern *pattern, gpointer data) 220substitute_func (FcPattern *pattern, gpointer data)
214{ 221{
215 FcPatternAddBool (pattern, FC_HINTING, 1); 222 FcPatternAddBool (pattern, FC_HINTING, 1);
216#ifdef FC_HINT_STYLE 223#ifdef FC_HINT_STYLE
217 FcPatternAddBool (pattern, FC_HINT_STYLE, FC_HINT_FULL); 224 FcPatternAddInteger (pattern, FC_HINT_STYLE, FC_HINT_FULL);
218#endif 225#endif
219 FcPatternAddBool (pattern, FC_AUTOHINT, 0); 226 FcPatternAddBool (pattern, FC_AUTOHINT, 0);
220} 227}
221 228
222static void 229static void
252} 259}
253 260
254typedef uint16_t tileid; 261typedef uint16_t tileid;
255typedef uint16_t faceid; 262typedef uint16_t faceid;
256 263
257typedef struct { 264struct maptex
265{
258 GLuint name; 266 GLuint name;
259 int w, h; 267 int w, h;
260 float s, t; 268 float s, t;
261 uint8_t r, g, b, a; 269 uint8_t r, g, b, a;
262 tileid smoothtile; 270 tileid smoothtile;
263 uint8_t smoothlevel; 271 uint8_t smoothlevel;
264 uint8_t unused; /* set to zero on use */ 272 uint8_t unused; /* set to zero on use */
265} maptex; 273};
266 274
267typedef struct { 275struct mapcell
276{
268 uint32_t player; 277 uint32_t player;
269 tileid tile[3]; 278 tileid tile[3];
270 uint16_t darkness; 279 uint16_t darkness;
271 uint8_t stat_width, stat_hp, flags, smoothmax; 280 uint8_t stat_width, stat_hp, flags, smoothmax;
272} mapcell; 281};
273 282
274typedef struct { 283struct maprow
284{
275 int32_t c0, c1; 285 int32_t c0, c1;
276 mapcell *col; 286 mapcell *col;
277} maprow; 287};
278 288
279typedef struct map { 289struct mapgrid {
280 int x, y, w, h; 290 int x, y, w, h;
281 int ox, oy; /* offset to virtual global coordinate system */ 291 int ox, oy; /* offset to virtual global coordinate system */
282 int faces; tileid *face2tile; // [faceid] 292 int faces; tileid *face2tile; // [faceid]
283 int texs; maptex *tex; // [tileid] 293 int texs; maptex *tex; // [tileid]
284 294
285 int32_t rows; 295 int32_t rows;
286 maprow *row; 296 maprow *row;
287} *DC__Map; 297};
298
299typedef mapgrid *DC__Map;
288 300
289static char * 301static char *
290prepend (char *ptr, int sze, int inc) 302prepend (char *ptr, int sze, int inc)
291{ 303{
292 char *p; 304 char *p;
310 322
311#define Append(type,ptr,sze,inc) (ptr) = (type *)append ((char *)ptr, (sze) * sizeof (type), (inc) * sizeof (type)) 323#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)) 324#define Prepend(type,ptr,sze,inc) (ptr) = (type *)prepend ((char *)ptr, (sze) * sizeof (type), (inc) * sizeof (type))
313 325
314static void 326static void
315need_facenum (struct map *self, faceid face) 327need_facenum (struct mapgrid *self, faceid face)
316{ 328{
317 while (self->faces <= face) 329 while (self->faces <= face)
318 { 330 {
319 Append (tileid, self->face2tile, self->faces, self->faces); 331 Append (tileid, self->face2tile, self->faces, self->faces);
320 self->faces *= 2; 332 self->faces *= 2;
321 } 333 }
322} 334}
323 335
324static void 336static void
325need_texid (struct map *self, int texid) 337need_texid (struct mapgrid *self, int texid)
326{ 338{
327 while (self->texs <= texid) 339 while (self->texs <= texid)
328 { 340 {
329 Append (maptex, self->tex, self->texs, self->texs); 341 Append (maptex, self->tex, self->texs, self->texs);
330 self->texs *= 2; 342 self->texs *= 2;
331 } 343 }
332} 344}
333 345
334static maprow * 346static maprow *
335map_get_row (DC__Map self, int y) 347map_get_row (mapgrid *self, int y)
336{ 348{
337 if (0 > y) 349 if (0 > y)
338 { 350 {
339 int extend = - y + MAP_EXTEND_Y; 351 int extend = - y + MAP_EXTEND_Y;
340 Prepend (maprow, self->row, self->rows, extend); 352 Prepend (maprow, self->row, self->rows, extend);
378 390
379 return row->col + (x - row->c0); 391 return row->col + (x - row->c0);
380} 392}
381 393
382static mapcell * 394static mapcell *
383map_get_cell (DC__Map self, int x, int y) 395map_get_cell (mapgrid *self, int x, int y)
384{ 396{
385 return row_get_cell (map_get_row (self, y), x); 397 return row_get_cell (map_get_row (self, y), x);
386} 398}
387 399
388static void 400static void
389map_clear (DC__Map self) 401map_clear (mapgrid *self)
390{ 402{
391 int r; 403 int r;
392 404
393 for (r = 0; r < self->rows; r++) 405 for (r = 0; r < self->rows; r++)
394 Safefree (self->row[r].col); 406 Safefree (self->row[r].col);
412 (cell)->flags = 0; \ 424 (cell)->flags = 0; \
413 (cell)->player = 0; \ 425 (cell)->player = 0; \
414 } while (0) 426 } while (0)
415 427
416static void 428static void
417map_blank (DC__Map self, int x0, int y0, int w, int h) 429map_blank (mapgrid *self, int x0, int y0, int w, int h)
418{ 430{
419 int x, y; 431 int x, y;
420 maprow *row; 432 maprow *row;
421 mapcell *cell; 433 mapcell *cell;
422 434
439 CELL_CLEAR (cell); 451 CELL_CLEAR (cell);
440 } 452 }
441 } 453 }
442} 454}
443 455
444typedef struct { 456struct smooth_key
457{
445 tileid tile; 458 tileid tile;
446 uint8_t x, y, level; 459 uint8_t x, y, level;
447} smooth_key; 460
461 bool operator == (const smooth_key &o) const
462 {
463 return tile == o.tile && x == o.x && y == o.y && level == o.level;
464 }
465};
466
467typedef ska::flat_hash_map<smooth_key, IV> smooth_hash;
468
469namespace std {
470 template <>
471 struct hash<smooth_key>
472 {
473 size_t operator () (const smooth_key &v) const
474 {
475 return v.tile + (v.x << 8) + (v.y << 16) + (v.level << 24);
476 }
477 };
478}
448 479
449static void 480static void
450smooth_or_bits (HV *hv, smooth_key *key, IV bits) 481smooth_or_bits (smooth_hash &h, smooth_key &key, IV bits)
451{ 482{
452 SV **sv = hv_fetch (hv, (char *)key, sizeof (*key), 1); 483 auto &&it = h.find (key);
453 484
454 if (SvIOK (*sv)) 485 if (it == h.end ())
455 SvIV_set (*sv, SvIVX (*sv) | bits); 486 h.insert (std::make_pair (key, bits));
456 else 487 else
457 sv_setiv (*sv, bits); 488 it->second |= bits;
458} 489}
459 490
460static void 491static void
461music_finished (void) 492music_finished (void)
462{ 493{
481 ev.data2 = 0; 512 ev.data2 = 0;
482 513
483 SDL_PushEvent ((SDL_Event *)&ev); 514 SDL_PushEvent ((SDL_Event *)&ev);
484} 515}
485 516
517// approximately divide by 255
486static unsigned int 518static unsigned int
487div255 (unsigned int n) 519div255 (unsigned int n)
488{ 520{
489 return (n + (n >> 8)) >> 8; 521 return (n + (n >> 8)) >> 8;
490} 522}
607 extern C_LINKAGE int main (int argc, char *argv[]); 639 extern C_LINKAGE int main (int argc, char *argv[]);
608 640
609 static void 641 static void
610 SDL_main_hack (SV *real_main_) 642 SDL_main_hack (SV *real_main_)
611 { 643 {
612 real_main = real_main; 644 real_main = real_main_;
613 645
614 char *argv[] = { "deliantra client", 0 }; 646 char *argv[] = { "deliantra client", 0 };
615 (main) (1, argv); 647 (main) (1, argv);
616 } 648 }
617#else 649#else
889void SDL_QuitSubSystem (U32 flags) 921void SDL_QuitSubSystem (U32 flags)
890 922
891void SDL_Quit () 923void SDL_Quit ()
892 924
893int SDL_GL_SetAttribute (int attr, int value) 925int SDL_GL_SetAttribute (int attr, int value)
926 C_ARGS: (SDL_GLattr)attr, value
894 927
895int SDL_GL_GetAttribute (int attr) 928int SDL_GL_GetAttribute (int attr)
896 CODE: 929 CODE:
897 if (SDL_GL_GetAttribute (attr, &RETVAL)) 930 if (SDL_GL_GetAttribute ((SDL_GLattr)attr, &RETVAL))
898 XSRETURN_UNDEF; 931 XSRETURN_UNDEF;
899 OUTPUT: 932 OUTPUT:
900 RETVAL 933 RETVAL
901 934
902void 935void
975void 1008void
976SDL_GL_SwapBuffers () 1009SDL_GL_SwapBuffers ()
977 1010
978char * 1011char *
979SDL_GetKeyName (int sym) 1012SDL_GetKeyName (int sym)
1013 C_ARGS: (SDLKey)sym
980 1014
981int 1015int
982SDL_GetAppState () 1016SDL_GetAppState ()
983 1017
984int 1018int
1081 OUTPUT: 1115 OUTPUT:
1082 RETVAL 1116 RETVAL
1083 1117
1084int 1118int
1085Mix_OpenAudio (int frequency = 44100, int format = MIX_DEFAULT_FORMAT, int channels = 2, int chunksize = 4096) 1119Mix_OpenAudio (int frequency = 44100, int format = MIX_DEFAULT_FORMAT, int channels = 2, int chunksize = 4096)
1086 POSTCALL: 1120 POSTCALL:
1087 Mix_HookMusicFinished (music_finished); 1121 Mix_HookMusicFinished (music_finished);
1088 Mix_ChannelFinished (channel_finished); 1122 Mix_ChannelFinished (channel_finished);
1089 1123
1090void 1124void
1091Mix_QuerySpec () 1125Mix_QuerySpec ()
1212 1246
1213 SDL_LockSurface (surface2); 1247 SDL_LockSurface (surface2);
1214 EXTEND (SP, 6); 1248 EXTEND (SP, 6);
1215 PUSHs (sv_2mortal (newSViv (surface2->w))); 1249 PUSHs (sv_2mortal (newSViv (surface2->w)));
1216 PUSHs (sv_2mortal (newSViv (surface2->h))); 1250 PUSHs (sv_2mortal (newSViv (surface2->h)));
1217 PUSHs (sv_2mortal (newSVpvn (surface2->pixels, surface2->h * surface2->pitch))); 1251 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))); 1252 PUSHs (sv_2mortal (newSViv (surface->flags & (SDL_SRCCOLORKEY | SDL_SRCALPHA) ? GL_RGBA : GL_RGB)));
1219 PUSHs (sv_2mortal (newSViv (GL_RGBA))); 1253 PUSHs (sv_2mortal (newSViv (GL_RGBA)));
1220 PUSHs (sv_2mortal (newSViv (GL_UNSIGNED_BYTE))); 1254 PUSHs (sv_2mortal (newSViv (GL_UNSIGNED_BYTE)));
1221 SDL_UnlockSurface (surface2); 1255 SDL_UnlockSurface (surface2);
1222 1256
1294MODULE = Deliantra::Client PACKAGE = DC::Font 1328MODULE = Deliantra::Client PACKAGE = DC::Font
1295 1329
1296PROTOTYPES: DISABLE 1330PROTOTYPES: DISABLE
1297 1331
1298DC::Font 1332DC::Font
1299new_from_file (SV *class, char *path, int id = 0) 1333new_from_file (SV *klass, char *path, int id = 0)
1300 CODE: 1334 CODE:
1301{ 1335{
1302 int count; 1336 int count;
1303 FcPattern *pattern = FcFreeTypeQuery ((const FcChar8 *)path, id, 0, &count); 1337 FcPattern *pattern = FcFreeTypeQuery ((const FcChar8 *)path, id, 0, &count);
1304 RETVAL = pango_fc_font_description_from_pattern (pattern, 0); 1338 RETVAL = pango_fc_font_description_from_pattern (pattern, 0);
1333 PROTOTYPE: 1367 PROTOTYPE:
1334 CODE: 1368 CODE:
1335 tc_restore (); 1369 tc_restore ();
1336 1370
1337DC::Layout 1371DC::Layout
1338new (SV *class) 1372new (SV *klass)
1339 CODE: 1373 CODE:
1340 New (0, RETVAL, 1, struct cf_layout); 1374 RETVAL = new cf_layout;
1341 1375
1342 RETVAL->pl = pango_layout_new (opengl_context); 1376 RETVAL->pl = pango_layout_new (opengl_context);
1343 RETVAL->r = 1.; 1377 RETVAL->r = 1.;
1344 RETVAL->g = 1.; 1378 RETVAL->g = 1.;
1345 RETVAL->b = 1.; 1379 RETVAL->b = 1.;
1346 RETVAL->a = 1.; 1380 RETVAL->a = 1.;
1347 RETVAL->base_height = MIN_FONT_HEIGHT; 1381 RETVAL->base_height = MIN_FONT_HEIGHT;
1348 RETVAL->font = 0; 1382 RETVAL->font = 0;
1349 RETVAL->rc = rc_alloc ();
1350 1383
1351 pango_layout_set_wrap (RETVAL->pl, PANGO_WRAP_WORD_CHAR); 1384 pango_layout_set_wrap (RETVAL->pl, PANGO_WRAP_WORD_CHAR);
1352 layout_update_font (RETVAL); 1385 layout_update_font (RETVAL);
1353 OUTPUT: 1386 OUTPUT:
1354 RETVAL 1387 RETVAL
1355 1388
1356void 1389void
1357DESTROY (DC::Layout self) 1390DESTROY (DC::Layout self)
1358 CODE: 1391 CODE:
1359 g_object_unref (self->pl); 1392 g_object_unref (self->pl);
1360 rc_free (self->rc);
1361 Safefree (self); 1393 delete self;
1362 1394
1363void 1395void
1364set_text (DC::Layout self, SV *text_) 1396set_text (DC::Layout self, SV *text_)
1365 CODE: 1397 CODE:
1366{ 1398{
1492 1524
1493void 1525void
1494set_height (DC::Layout self, int base_height) 1526set_height (DC::Layout self, int base_height)
1495 CODE: 1527 CODE:
1496 if (self->base_height != base_height) 1528 if (self->base_height != base_height)
1497 { 1529 {
1498 self->base_height = base_height; 1530 self->base_height = base_height;
1499 layout_update_font (self); 1531 layout_update_font (self);
1500 } 1532 }
1501 1533
1502void 1534void
1620} 1652}
1621 1653
1622void 1654void
1623render (DC::Layout self, float x, float y, int flags = 0) 1655render (DC::Layout self, float x, float y, int flags = 0)
1624 CODE: 1656 CODE:
1625 rc_clear (self->rc); 1657 self->rc.clear ();
1626 pango_opengl_render_layout_subpixel ( 1658 pango_opengl_render_layout_subpixel (
1627 self->pl, 1659 self->pl,
1628 self->rc, 1660 &self->rc,
1629 x * PANGO_SCALE, y * PANGO_SCALE, 1661 x * PANGO_SCALE, y * PANGO_SCALE,
1630 self->r, self->g, self->b, self->a, 1662 self->r, self->g, self->b, self->a,
1631 flags 1663 flags
1632 ); 1664 );
1633 // we assume that context_change actually clears/frees stuff 1665 // we assume that context_change actually clears/frees stuff
1644 gl_BlendFuncSeparate (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, 1676 gl_BlendFuncSeparate (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA,
1645 GL_ONE , GL_ONE_MINUS_SRC_ALPHA); 1677 GL_ONE , GL_ONE_MINUS_SRC_ALPHA);
1646 glEnable (GL_ALPHA_TEST); 1678 glEnable (GL_ALPHA_TEST);
1647 glAlphaFunc (GL_GREATER, 7.f / 255.f); 1679 glAlphaFunc (GL_GREATER, 7.f / 255.f);
1648 1680
1649 rc_draw (self->rc); 1681 self->rc.draw ();
1650 1682
1651 glDisable (GL_ALPHA_TEST); 1683 glDisable (GL_ALPHA_TEST);
1652 glDisable (GL_BLEND); 1684 glDisable (GL_BLEND);
1653 glDisable (GL_TEXTURE_2D); 1685 glDisable (GL_TEXTURE_2D);
1654} 1686}
1866MODULE = Deliantra::Client PACKAGE = DC::Map 1898MODULE = Deliantra::Client PACKAGE = DC::Map
1867 1899
1868PROTOTYPES: DISABLE 1900PROTOTYPES: DISABLE
1869 1901
1870DC::Map 1902DC::Map
1871new (SV *class) 1903new (SV *klass)
1872 CODE: 1904 CODE:
1873 New (0, RETVAL, 1, struct map); 1905 New (0, RETVAL, 1, mapgrid);
1874 RETVAL->x = 0; 1906 RETVAL->x = 0;
1875 RETVAL->y = 0; 1907 RETVAL->y = 0;
1876 RETVAL->w = 0; 1908 RETVAL->w = 0;
1877 RETVAL->h = 0; 1909 RETVAL->h = 0;
1878 RETVAL->ox = 0; 1910 RETVAL->ox = 0;
1915 1947
1916void 1948void
1917set_smooth (DC::Map self, int face, int smooth, int level) 1949set_smooth (DC::Map self, int face, int smooth, int level)
1918 CODE: 1950 CODE:
1919{ 1951{
1920 tileid texid; 1952 tileid texid;
1921 maptex *tex; 1953 maptex *tex;
1922 1954
1923 if (face < 0 || face >= self->faces) 1955 if (face < 0 || face >= self->faces)
1924 return; 1956 return;
1925 1957
1926 if (smooth < 0 || smooth >= self->faces) 1958 if (smooth < 0 || smooth >= self->faces)
1927 return; 1959 return;
1928 1960
1929 texid = self->face2tile [face]; 1961 texid = self->face2tile [face];
1930 1962
1931 if (!texid) 1963 if (!texid)
1932 return; 1964 return;
1933 1965
1934 tex = self->tex + texid; 1966 tex = self->tex + texid;
1967} 1999}
1968 2000
1969void 2001void
1970expire_textures (DC::Map self, int texid, int count) 2002expire_textures (DC::Map self, int texid, int count)
1971 PPCODE: 2003 PPCODE:
1972 for (; texid < self->texs && count; ++texid, --count) 2004 for (; texid < self->texs && count; ++texid, --count)
1973 { 2005 {
1974 maptex *tex = self->tex + texid; 2006 maptex *tex = self->tex + texid;
1975 2007
1976 if (tex->name) 2008 if (tex->name)
1977 { 2009 {
2032 self->y += MAP_EXTEND_Y; 2064 self->y += MAP_EXTEND_Y;
2033 } 2065 }
2034} 2066}
2035 2067
2036SV * 2068SV *
2037map1a_update (DC::Map self, SV *data_, int extmap) 2069map1a_update (DC::Map self, SV *data_)
2038 CODE: 2070 CODE:
2039{ 2071{
2040 uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_); 2072 uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_);
2041 uint8_t *data_end = (uint8_t *)SvEND (data_); 2073 uint8_t *data_end = (uint8_t *)SvEND (data_);
2042 mapcell *cell; 2074 mapcell *cell;
2063 2095
2064 //TODO: don't trust server data to be in-range(!) 2096 //TODO: don't trust server data to be in-range(!)
2065 2097
2066 if (flags & 8) 2098 if (flags & 8)
2067 { 2099 {
2100 uint8_t ext, cmd;
2101
2068 if (extmap) 2102 do
2069 { 2103 {
2070 uint8_t ext, cmd; 2104 ext = *data++;
2105 cmd = ext & 0x7f;
2071 2106
2072 do 2107 if (cmd < 4)
2108 cell->darkness = 255 - ext * 64 + 1; /* make sure this doesn't collide with FOW_DARKNESS */
2109 else if (cmd == 5) // health
2073 { 2110 {
2074 ext = *data++;
2075 cmd = ext & 0x7f;
2076
2077 if (cmd < 4)
2078 cell->darkness = 255 - ext * 64 + 1; /* make sure this doesn't collide with FOW_DARKNESS */
2079 else if (cmd == 5) // health
2080 {
2081 cell->stat_width = 1; 2111 cell->stat_width = 1;
2082 cell->stat_hp = *data++; 2112 cell->stat_hp = *data++;
2083 }
2084 else if (cmd == 6) // monster width
2085 cell->stat_width = *data++ + 1;
2086 else if (cmd == 0x47)
2087 {
2088 if (*data == 1) cell->player = data [1];
2089 else if (*data == 2) cell->player = data [2] + (data [1] << 8);
2090 else if (*data == 3) cell->player = data [3] + (data [2] << 8) + (data [1] << 16);
2091 else if (*data == 4) cell->player = data [4] + (data [3] << 8) + (data [2] << 16) + (data [1] << 24);
2092
2093 data += *data + 1;
2094 }
2095 else if (cmd == 8) // cell flags
2096 cell->flags = *data++;
2097 else if (ext & 0x40) // unknown, multibyte => skip
2098 data += *data + 1;
2099 else
2100 data++;
2101 } 2113 }
2102 while (ext & 0x80); 2114 else if (cmd == 6) // monster width
2115 cell->stat_width = *data++ + 1;
2116 else if (cmd == 0x47)
2117 {
2118 if (*data == 1) cell->player = data [1];
2119 else if (*data == 2) cell->player = data [2] + (data [1] << 8);
2120 else if (*data == 3) cell->player = data [3] + (data [2] << 8) + (data [1] << 16);
2121 else if (*data == 4) cell->player = data [4] + (data [3] << 8) + (data [2] << 16) + (data [1] << 24);
2122
2123 data += *data + 1;
2124 }
2125 else if (cmd == 8) // cell flags
2126 cell->flags = *data++;
2127 else if (ext & 0x40) // unknown, multibyte => skip
2128 data += *data + 1;
2129 else
2130 data++;
2103 } 2131 }
2104 else 2132 while (ext & 0x80);
2105 cell->darkness = *data++ + 1;
2106 } 2133 }
2107 2134
2108 for (z = 0; z <= 2; ++z) 2135 for (z = 0; z <= 2; ++z)
2109 if (flags & (4 >> z)) 2136 if (flags & (4 >> z))
2110 { 2137 {
2184 | (b << 16) 2211 | (b << 16)
2185 | (a << 24); 2212 | (a << 24);
2186 } 2213 }
2187 } 2214 }
2188 2215
2189 RETVAL = map_sv; 2216 RETVAL = map_sv;
2190} 2217}
2191 OUTPUT: 2218 OUTPUT:
2192 RETVAL 2219 RETVAL
2193 2220
2194void 2221void
2195draw (DC::Map self, int mx, int my, int sw, int sh, int Tw, int Th, U32 player = 0xffffffff, int sdx = 0, int sdy = 0) 2222draw (DC::Map self, int mx, int my, int sw, int sh, int Tw, int Th, U32 player = 0xffffffff, int sdx = 0, int sdy = 0)
2196 CODE: 2223 CODE:
2197{ 2224{
2198 int x, y, z; 2225 int x, y, z;
2199 2226
2200 HV *smooth = (HV *)sv_2mortal ((SV *)newHV ());
2201 uint32_t smooth_level[256 / 32]; // one bit for every possible smooth level
2202 static uint8_t smooth_max[256][256]; // egad, fast and wasteful on memory (64k) 2227 static uint8_t smooth_max[256][256]; // egad, fast and wasteful on memory (64k), also, static!
2203 smooth_key skey;
2204 int pl_x, pl_y; 2228 int pl_x, pl_y;
2205 maptex pl_tex; 2229 maptex pl_tex;
2206 rc_t *rc = rc_alloc (); 2230 rc_t rc;
2207 rc_t *rc_ov = rc_alloc (); 2231 rc_t rc_ov;
2208 rc_key_t key; 2232 rc_key_t key;
2209 rc_array_t *arr; 2233 rc_t::array_t *arr;
2210 2234
2211 pl_tex.name = 0; 2235 pl_tex.name = 0;
2212 2236
2213 // that's current max. sorry. 2237 // that's current max. sorry.
2214 if (sw > 255) sw = 255; 2238 if (sw > 255) sw = 255;
2215 if (sh > 255) sh = 255; 2239 if (sh > 255) sh = 255;
2216
2217 // clear key, in case of extra padding
2218 memset (&skey, 0, sizeof (skey));
2219 2240
2220 memset (&key, 0, sizeof (key)); 2241 memset (&key, 0, sizeof (key));
2221 key.r = 255; 2242 key.r = 255;
2222 key.g = 255; 2243 key.g = 255;
2223 key.b = 255; 2244 key.b = 255;
2229 my += self->y; 2250 my += self->y;
2230 2251
2231 // first pass: determine smooth_max 2252 // first pass: determine smooth_max
2232 // rather ugly, if you ask me 2253 // rather ugly, if you ask me
2233 // could also be stored inside mapcell and updated on change 2254 // could also be stored inside mapcell and updated on change
2234 memset (smooth_max, 0, sizeof (smooth_max)); 2255 memset (smooth_max, 0, sizeof (smooth_max[0]) * (sh + 1));
2235 2256
2236 for (y = 0; y < sh; y++) 2257 for (y = 0; y < sh; y++)
2237 if (0 <= y + my && y + my < self->rows) 2258 if (0 <= y + my && y + my < self->rows)
2238 { 2259 {
2239 maprow *row = self->row + (y + my); 2260 maprow *row = self->row + (y + my);
2254 glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 2275 glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
2255 glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); 2276 glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
2256 2277
2257 for (z = 0; z <= 2; z++) 2278 for (z = 0; z <= 2; z++)
2258 { 2279 {
2259 memset (smooth_level, 0, sizeof (smooth_level)); 2280 std::bitset<256> smooth_level; // one bit for every possible smooth level
2281 smooth_key skey;
2282 smooth_hash smooth;
2260 key.texname = -1; 2283 key.texname = -1;
2261 2284
2262 for (y = 0; y < sh; y++) 2285 for (y = 0; y < sh; y++)
2263 if (0 <= y + my && y + my < self->rows) 2286 if (0 <= y + my && y + my < self->rows)
2264 { 2287 {
2281 2304
2282 if (!tex.name) 2305 if (!tex.name)
2283 tex = self->tex [TEXID_NOFACE]; /* missing, replace by noface */ 2306 tex = self->tex [TEXID_NOFACE]; /* missing, replace by noface */
2284 2307
2285 key.texname = tex.name; 2308 key.texname = tex.name;
2286 arr = rc_array (rc, &key); 2309 arr = &rc.array (key);
2287 } 2310 }
2288 2311
2289 px = (x + 1) * Th - tex.w; 2312 px = (x + 1) * Th - tex.w;
2290 py = (y + 1) * Tw - tex.h; 2313 py = (y + 1) * Tw - tex.h;
2291 2314
2295 pl_y = py; 2318 pl_y = py;
2296 pl_tex = tex; 2319 pl_tex = tex;
2297 continue; 2320 continue;
2298 } 2321 }
2299 2322
2300 rc_t2f_v3f (arr, 0 , 0 , px , py , 0); 2323 arr->t2f_v3f (0 , 0 , px , py , 0);
2301 rc_t2f_v3f (arr, 0 , tex.t, px , py + tex.h, 0); 2324 arr->t2f_v3f (0 , tex.t, px , py + tex.h, 0);
2302 rc_t2f_v3f (arr, tex.s, tex.t, px + tex.w, py + tex.h, 0); 2325 arr->t2f_v3f (tex.s, tex.t, px + tex.w, py + tex.h, 0);
2303 rc_t2f_v3f (arr, tex.s, 0 , px + tex.w, py , 0); 2326 arr->t2f_v3f (tex.s, 0 , px + tex.w, py , 0);
2304 2327
2305 // update smooth hash 2328 // update smooth hash
2306 if (tex.smoothtile) 2329 if (tex.smoothtile)
2307 { 2330 {
2308 skey.tile = tex.smoothtile; 2331 skey.tile = tex.smoothtile;
2309 skey.level = tex.smoothlevel; 2332 skey.level = tex.smoothlevel;
2310 2333
2311 smooth_level [tex.smoothlevel >> 5] |= ((uint32_t)1) << (tex.smoothlevel & 31); 2334 smooth_level[tex.smoothlevel] = 1;
2312 2335
2313 // add bits to current tile and all neighbours. skey.x|y is 2336 // add bits to current tile and all neighbours. skey.x|y is
2314 // shifted +1|+1 so we always stay positive. 2337 // shifted +1|+1 so we always stay positive.
2315 2338
2316 // bits is ___n cccc CCCC bbbb 2339 // bits is ___n cccc CCCC bbbb
2324 2347
2325 // corners: 1 ┛· 2 ·┗ 4 ·· 8 ·· 2348 // corners: 1 ┛· 2 ·┗ 4 ·· 8 ··
2326 // ·· ·· ·┏ ┓· 2349 // ·· ·· ·┏ ┓·
2327 2350
2328 // full tile 2351 // full tile
2329 skey.x = x + 1; skey.y = y + 1; smooth_or_bits (smooth, &skey, 0x1000); 2352 skey.x = x + 1; skey.y = y + 1; smooth_or_bits (smooth, skey, 0x1000);
2330 2353
2331 // borders 2354 // borders
2332 skey.x = x + 2; skey.y = y + 1; smooth_or_bits (smooth, &skey, 0x0091); 2355 skey.x = x + 2; skey.y = y + 1; smooth_or_bits (smooth, skey, 0x0091);
2333 skey.x = x + 1; skey.y = y + 2; smooth_or_bits (smooth, &skey, 0x0032); 2356 skey.x = x + 1; skey.y = y + 2; smooth_or_bits (smooth, skey, 0x0032);
2334 skey.x = x ; skey.y = y + 1; smooth_or_bits (smooth, &skey, 0x0064); 2357 skey.x = x ; skey.y = y + 1; smooth_or_bits (smooth, skey, 0x0064);
2335 skey.x = x + 1; skey.y = y ; smooth_or_bits (smooth, &skey, 0x00c8); 2358 skey.x = x + 1; skey.y = y ; smooth_or_bits (smooth, skey, 0x00c8);
2336 2359
2337 // corners 2360 // corners
2338 skey.x = x + 2; skey.y = y + 2; smooth_or_bits (smooth, &skey, 0x0100); 2361 skey.x = x + 2; skey.y = y + 2; smooth_or_bits (smooth, skey, 0x0100);
2339 skey.x = x ; skey.y = y + 2; smooth_or_bits (smooth, &skey, 0x0200); 2362 skey.x = x ; skey.y = y + 2; smooth_or_bits (smooth, skey, 0x0200);
2340 skey.x = x ; skey.y = y ; smooth_or_bits (smooth, &skey, 0x0400); 2363 skey.x = x ; skey.y = y ; smooth_or_bits (smooth, skey, 0x0400);
2341 skey.x = x + 2; skey.y = y ; smooth_or_bits (smooth, &skey, 0x0800); 2364 skey.x = x + 2; skey.y = y ; smooth_or_bits (smooth, skey, 0x0800);
2342 } 2365 }
2343 } 2366 }
2344 2367
2345 if (expect_false (z == 2) && expect_false (cell->flags)) 2368 if (expect_false (z == 2) && expect_false (cell->flags))
2346 { 2369 {
2347 // overlays such as the speech bubble, probably more to come 2370 // overlays such as the speech bubble, probably more to come
2348 if (cell->flags & 1) 2371 if (cell->flags & 1)
2349 { 2372 {
2350 rc_key_t key_ov = key; 2373 rc_key_t key_ov = key;
2351 maptex tex = self->tex [TEXID_SPEECH]; 2374 maptex tex = self->tex[TEXID_SPEECH];
2352 rc_array_t *arr;
2353 int px = x * Tw + Tw * 2 / 32; 2375 int px = x * Tw + Tw * 2 / 32;
2354 int py = y * Th - Th * 6 / 32; 2376 int py = y * Th - Th * 6 / 32;
2355 2377
2356 key_ov.texname = tex.name; 2378 key_ov.texname = tex.name;
2357 arr = rc_array (rc_ov, &key_ov); 2379 rc_t::array_t &arr = rc_ov.array (key_ov);
2358 2380
2359 rc_t2f_v3f (arr, 0 , 0 , px , py , 0); 2381 arr.t2f_v3f (0 , 0 , px , py , 0);
2360 rc_t2f_v3f (arr, 0 , tex.t, px , py + Th, 0); 2382 arr.t2f_v3f (0 , tex.t, px , py + Th, 0);
2361 rc_t2f_v3f (arr, tex.s, tex.t, px + Tw, py + Th, 0); 2383 arr.t2f_v3f (tex.s, tex.t, px + Tw, py + Th, 0);
2362 rc_t2f_v3f (arr, tex.s, 0 , px + Tw, py , 0); 2384 arr.t2f_v3f (tex.s, 0 , px + Tw, py , 0);
2363 } 2385 }
2364 } 2386 }
2365 } 2387 }
2366 } 2388 }
2367 2389
2368 rc_draw (rc); 2390 rc.draw ();
2369 rc_clear (rc); 2391 rc.clear ();
2370 2392
2371 // go through all smoothlevels, lowest to highest, then draw. 2393 // go through all smoothlevels, lowest to highest, then draw.
2372 // this is basically counting sort 2394 // this is basically counting sort
2373 { 2395 {
2374 int w, b; 2396 int w, b;
2375 2397
2376 glEnable (GL_TEXTURE_2D); 2398 glEnable (GL_TEXTURE_2D);
2377 glBegin (GL_QUADS); 2399 glBegin (GL_QUADS);
2378 for (w = 0; w < 256 / 32; ++w) 2400 for (int level = 0; level < smooth_level.size (); ++level)
2401 if (smooth_level[level])
2402 for (auto &&it = smooth.begin (); it != smooth.end (); ++it)
2379 { 2403 {
2380 uint32_t smask = smooth_level [w]; 2404 smooth_key &skey = it->first;
2381 if (smask) 2405 IV bits = it->second;
2382 for (b = 0; b < 32; ++b) 2406
2383 if (smask & (((uint32_t)1) << b)) 2407 if (!(bits & 0x1000)
2408 && skey.level == level
2409 && level > smooth_max [skey.x][skey.y])
2384 { 2410 {
2385 int level = (w << 5) | b; 2411 maptex tex = self->tex [skey.tile];
2412 int px = (((int)skey.x) - 1) * Tw;
2413 int py = (((int)skey.y) - 1) * Th;
2414 int border = bits & 15;
2415 int corner = (bits >> 8) & ~(bits >> 4) & 15;
2416 float dx = tex.s * .0625f; // 16 images/row
2417 float dy = tex.t * .5f ; // 2 images/column
2418
2386 HE *he; 2419 if (tex.name)
2387
2388 hv_iterinit (smooth);
2389 while ((he = hv_iternext (smooth)))
2390 { 2420 {
2391 smooth_key *skey = (smooth_key *)HeKEY (he); 2421 // this time avoiding texture state changes
2392 IV bits = SvIVX (HeVAL (he)); 2422 // save gobs of state changes.
2393 2423 if (key.texname != tex.name)
2394 if (!(bits & 0x1000)
2395 && skey->level == level
2396 && level > smooth_max [skey->x][skey->y])
2397 { 2424 {
2398 maptex tex = self->tex [skey->tile];
2399 int px = (((int)skey->x) - 1) * Tw;
2400 int py = (((int)skey->y) - 1) * Th;
2401 int border = bits & 15;
2402 int corner = (bits >> 8) & ~(bits >> 4) & 15;
2403 float dx = tex.s * .0625f; // 16 images/row
2404 float dy = tex.t * .5f ; // 2 images/column
2405
2406 if (tex.name)
2407 {
2408 // this time avoiding texture state changes
2409 // save gobs of state changes.
2410 if (key.texname != tex.name)
2411 {
2412 self->tex [skey->tile].unused = 0; 2425 self->tex [skey.tile].unused = 0;
2413 2426
2414 glEnd (); 2427 glEnd ();
2415 glBindTexture (GL_TEXTURE_2D, key.texname = tex.name); 2428 glBindTexture (GL_TEXTURE_2D, key.texname = tex.name);
2416 glBegin (GL_QUADS); 2429 glBegin (GL_QUADS);
2417 } 2430 }
2418 2431
2419 if (border) 2432 if (border)
2420 { 2433 {
2421 float ox = border * dx; 2434 float ox = border * dx;
2422 2435
2423 glTexCoord2f (ox , 0.f ); glVertex2i (px , py ); 2436 glTexCoord2f (ox , 0.f ); glVertex2i (px , py );
2424 glTexCoord2f (ox , dy ); glVertex2i (px , py + Th); 2437 glTexCoord2f (ox , dy ); glVertex2i (px , py + Th);
2425 glTexCoord2f (ox + dx, dy ); glVertex2i (px + Tw, py + Th); 2438 glTexCoord2f (ox + dx, dy ); glVertex2i (px + Tw, py + Th);
2426 glTexCoord2f (ox + dx, 0.f ); glVertex2i (px + Tw, py ); 2439 glTexCoord2f (ox + dx, 0.f ); glVertex2i (px + Tw, py );
2427 } 2440 }
2428 2441
2429 if (corner) 2442 if (corner)
2430 { 2443 {
2431 float ox = corner * dx; 2444 float ox = corner * dx;
2432 2445
2433 glTexCoord2f (ox , dy ); glVertex2i (px , py ); 2446 glTexCoord2f (ox , dy ); glVertex2i (px , py );
2434 glTexCoord2f (ox , dy * 2.f); glVertex2i (px , py + Th); 2447 glTexCoord2f (ox , dy * 2.f); glVertex2i (px , py + Th);
2435 glTexCoord2f (ox + dx, dy * 2.f); glVertex2i (px + Tw, py + Th); 2448 glTexCoord2f (ox + dx, dy * 2.f); glVertex2i (px + Tw, py + Th);
2436 glTexCoord2f (ox + dx, dy ); glVertex2i (px + Tw, py ); 2449 glTexCoord2f (ox + dx, dy ); glVertex2i (px + Tw, py );
2437 }
2438 }
2439 } 2450 }
2440 } 2451 }
2441 } 2452 }
2442 } 2453 }
2443 2454
2444 glEnd (); 2455 glEnd ();
2445 glDisable (GL_TEXTURE_2D); 2456 glDisable (GL_TEXTURE_2D);
2446 key.texname = -1; 2457 key.texname = -1;
2447 } 2458 }
2448
2449 hv_clear (smooth);
2450 } 2459 }
2451 2460
2452 if (pl_tex.name) 2461 if (pl_tex.name)
2453 { 2462 {
2454 maptex tex = pl_tex; 2463 maptex tex = pl_tex;
2455 int px = pl_x + sdx; 2464 int px = pl_x + sdx;
2456 int py = pl_y + sdy; 2465 int py = pl_y + sdy;
2457 2466
2458 key.texname = tex.name; 2467 key.texname = tex.name;
2459 arr = rc_array (rc, &key); 2468 rc_t::array_t &arr = rc.array (key);
2460 2469
2461 rc_t2f_v3f (arr, 0 , 0 , px , py , 0); 2470 arr.t2f_v3f (0 , 0 , px , py , 0);
2462 rc_t2f_v3f (arr, 0 , tex.t, px , py + tex.h, 0); 2471 arr.t2f_v3f (0 , tex.t, px , py + tex.h, 0);
2463 rc_t2f_v3f (arr, tex.s, tex.t, px + tex.w, py + tex.h, 0); 2472 arr.t2f_v3f (tex.s, tex.t, px + tex.w, py + tex.h, 0);
2464 rc_t2f_v3f (arr, tex.s, 0 , px + tex.w, py , 0); 2473 arr.t2f_v3f (tex.s, 0 , px + tex.w, py , 0);
2465 2474
2466 rc_draw (rc); 2475 rc.draw ();
2467 } 2476 }
2468 2477
2469 rc_draw (rc_ov); 2478 rc_ov.draw ();
2470 rc_clear (rc_ov); 2479 rc_ov.clear ();
2471 2480
2472 glDisable (GL_BLEND); 2481 glDisable (GL_BLEND);
2473 rc_free (rc);
2474 rc_free (rc_ov);
2475 2482
2476 // top layer: overlays such as the health bar 2483 // top layer: overlays such as the health bar
2477 for (y = 0; y < sh; y++) 2484 for (y = 0; y < sh; y++)
2478 if (0 <= y + my && y + my < self->rows) 2485 if (0 <= y + my && y + my < self->rows)
2479 { 2486 {
2723 else 2730 else
2724 *data++ = 0; 2731 *data++ = 0;
2725 } 2732 }
2726 } 2733 }
2727 2734
2728 /* if size is w*h + 5 then no data has been found */ 2735 /* if size is w*h + 5 then no data has been found */
2729 if (data - (uint8_t *)SvPVX (data_sv) != w * h + 5) 2736 if (data - (uint8_t *)SvPVX (data_sv) != w * h + 5)
2730 { 2737 {
2731 SvPOK_only (data_sv); 2738 SvPOK_only (data_sv);
2732 SvCUR_set (data_sv, data - (uint8_t *)SvPVX (data_sv)); 2739 SvCUR_set (data_sv, data - (uint8_t *)SvPVX (data_sv));
2733 } 2740 }
2734 2741
2735 RETVAL = data_sv; 2742 RETVAL = data_sv;
2736} 2743}
2737 OUTPUT: 2744 OUTPUT:
2738 RETVAL 2745 RETVAL
2739 2746
2740void 2747void
2747 STRLEN len; 2754 STRLEN len;
2748 uint8_t *data, *end; 2755 uint8_t *data, *end;
2749 2756
2750 len = SvLEN (data_sv); 2757 len = SvLEN (data_sv);
2751 SvGROW (data_sv, len + 8); // reserve at least 7+ bytes more 2758 SvGROW (data_sv, len + 8); // reserve at least 7+ bytes more
2752 data = SvPVbyte_nolen (data_sv); 2759 data = (uint8_t *)SvPVbyte_nolen (data_sv);
2753 end = data + len + 8; 2760 end = data + len + 8;
2754 2761
2755 if (len < 5) 2762 if (len < 5)
2756 XSRETURN_EMPTY; 2763 XSRETURN_EMPTY;
2757 2764
2818} 2825}
2819 2826
2820MODULE = Deliantra::Client PACKAGE = DC::RW 2827MODULE = Deliantra::Client PACKAGE = DC::RW
2821 2828
2822DC::RW 2829DC::RW
2823new (SV *class, SV *data_sv) 2830new (SV *klass, SV *data_sv)
2824 CODE: 2831 CODE:
2825{ 2832{
2826 STRLEN datalen; 2833 STRLEN datalen;
2827 char *data = SvPVbyte (data_sv, datalen); 2834 char *data = SvPVbyte (data_sv, datalen);
2828 2835
2830} 2837}
2831 OUTPUT: 2838 OUTPUT:
2832 RETVAL 2839 RETVAL
2833 2840
2834DC::RW 2841DC::RW
2835new_from_file (SV *class, const char *path, const char *mode = "rb") 2842new_from_file (SV *klass, const char *path, const char *mode = "rb")
2836 CODE: 2843 CODE:
2837 RETVAL = SDL_RWFromFile (path, mode); 2844 RETVAL = SDL_RWFromFile (path, mode);
2838 OUTPUT: 2845 OUTPUT:
2839 RETVAL 2846 RETVAL
2840 2847
2949#else 2956#else
2950 XPUSHs (sv_2mortal (newSVpv ("(sdl mixer too old)", 0))); 2957 XPUSHs (sv_2mortal (newSVpv ("(sdl mixer too old)", 0)));
2951#endif 2958#endif
2952 2959
2953DC::MixChunk 2960DC::MixChunk
2954new (SV *class, DC::RW rwops) 2961new (SV *klass, DC::RW rwops)
2955 CODE: 2962 CODE:
2956 RETVAL = Mix_LoadWAV_RW (rwops, 1); 2963 RETVAL = Mix_LoadWAV_RW (rwops, 1);
2957 OUTPUT: 2964 OUTPUT:
2958 RETVAL 2965 RETVAL
2959 2966
3029 RETVAL = Mix_PlayingMusic (); 3036 RETVAL = Mix_PlayingMusic ();
3030 OUTPUT: 3037 OUTPUT:
3031 RETVAL 3038 RETVAL
3032 3039
3033DC::MixMusic 3040DC::MixMusic
3034new (SV *class, DC::RW rwops) 3041new (SV *klass, DC::RW rwops)
3035 CODE: 3042 CODE:
3036 RETVAL = Mix_LoadMUS_RW (rwops); 3043 RETVAL = Mix_LoadMUS_RW (rwops);
3037 OUTPUT: 3044 OUTPUT:
3038 RETVAL 3045 RETVAL
3039 3046
3192 gl.BlendFuncSeparateEXT = 0; 3199 gl.BlendFuncSeparateEXT = 0;
3193 3200
3194void 3201void
3195apple_nvidia_bug (int enable) 3202apple_nvidia_bug (int enable)
3196 3203
3197char * 3204const char *
3198gl_vendor () 3205gl_vendor ()
3199 CODE: 3206 CODE:
3200 RETVAL = (char *)glGetString (GL_VENDOR); 3207 RETVAL = (const char *)glGetString (GL_VENDOR);
3201 OUTPUT: 3208 OUTPUT:
3202 RETVAL 3209 RETVAL
3203 3210
3204char * 3211const char *
3205gl_version () 3212gl_version ()
3206 CODE: 3213 CODE:
3207 RETVAL = (char *)glGetString (GL_VERSION); 3214 RETVAL = (const char *)glGetString (GL_VERSION);
3208 OUTPUT: 3215 OUTPUT:
3209 RETVAL 3216 RETVAL
3210 3217
3211char * 3218const char *
3212gl_extensions () 3219gl_extensions ()
3213 CODE: 3220 CODE:
3214 RETVAL = (char *)glGetString (GL_EXTENSIONS); 3221 RETVAL = (const char *)glGetString (GL_EXTENSIONS);
3215 OUTPUT: 3222 OUTPUT:
3216 RETVAL 3223 RETVAL
3217 3224
3218const char *glGetString (GLenum pname) 3225const char *glGetString (GLenum pname)
3226 CODE:
3227 RETVAL = (const char *)glGetString (pname);
3228 OUTPUT:
3229 RETVAL
3219 3230
3220GLint glGetInteger (GLenum pname) 3231GLint glGetInteger (GLenum pname)
3221 CODE: 3232 CODE:
3222 glGetIntegerv (pname, &RETVAL); 3233 glGetIntegerv (pname, &RETVAL);
3223 OUTPUT: 3234 OUTPUT:
3426 3437
3427void 3438void
3428find_widget (SV *self, NV x, NV y) 3439find_widget (SV *self, NV x, NV y)
3429 PPCODE: 3440 PPCODE:
3430{ 3441{
3431 if (within_widget (self, x, y)) 3442 if (within_widget (self, x, y))
3432 XPUSHs (self); 3443 XPUSHs (self);
3433} 3444}
3434 3445
3435BOOT: 3446BOOT:
3436{ 3447{
3444 3455
3445void 3456void
3446draw (SV *self) 3457draw (SV *self)
3447 CODE: 3458 CODE:
3448{ 3459{
3449 HV *hv; 3460 HV *hv;
3450 SV **svp; 3461 SV **svp;
3451 NV x, y, w, h; 3462 NV x, y, w, h;
3452 SV *draw_x_sv = GvSV (draw_x_gv); 3463 SV *draw_x_sv = GvSV (draw_x_gv);
3453 SV *draw_y_sv = GvSV (draw_y_gv); 3464 SV *draw_y_sv = GvSV (draw_y_gv);
3454 SV *draw_w_sv = GvSV (draw_w_gv); 3465 SV *draw_w_sv = GvSV (draw_w_gv);
3455 SV *draw_h_sv = GvSV (draw_h_gv); 3466 SV *draw_h_sv = GvSV (draw_h_gv);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines