… | |
… | |
1350 | HV *hv = (HV *)SvRV (self); |
1350 | HV *hv = (HV *)SvRV (self); |
1351 | float s = SvNV (*hv_fetch (hv, "s", 1, 1)); |
1351 | float s = SvNV (*hv_fetch (hv, "s", 1, 1)); |
1352 | float t = SvNV (*hv_fetch (hv, "t", 1, 1)); |
1352 | float t = SvNV (*hv_fetch (hv, "t", 1, 1)); |
1353 | int name = SvIV (*hv_fetch (hv, "name", 4, 1)); |
1353 | int name = SvIV (*hv_fetch (hv, "name", 4, 1)); |
1354 | |
1354 | |
|
|
1355 | if (name <= 0) |
|
|
1356 | XSRETURN_EMPTY; |
|
|
1357 | |
1355 | if (items < 5) |
1358 | if (items < 5) |
1356 | { |
1359 | { |
1357 | w = SvNV (*hv_fetch (hv, "w", 1, 1)); |
1360 | w = SvNV (*hv_fetch (hv, "w", 1, 1)); |
1358 | h = SvNV (*hv_fetch (hv, "h", 1, 1)); |
1361 | h = SvNV (*hv_fetch (hv, "h", 1, 1)); |
1359 | } |
1362 | } |
… | |
… | |
1547 | self->rows += MAP_EXTEND_Y; |
1550 | self->rows += MAP_EXTEND_Y; |
1548 | self->y += MAP_EXTEND_Y; |
1551 | self->y += MAP_EXTEND_Y; |
1549 | } |
1552 | } |
1550 | } |
1553 | } |
1551 | |
1554 | |
1552 | void |
1555 | SV * |
1553 | map1a_update (CFPlus::Map self, SV *data_, int extmap) |
1556 | map1a_update (CFPlus::Map self, SV *data_, int extmap) |
1554 | CODE: |
1557 | CODE: |
1555 | { |
1558 | { |
1556 | uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_); |
1559 | uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_); |
1557 | uint8_t *data_end = (uint8_t *)SvEND (data_); |
1560 | uint8_t *data_end = (uint8_t *)SvEND (data_); |
1558 | mapcell *cell; |
1561 | mapcell *cell; |
1559 | int x, y, flags; |
1562 | int x, y, z, flags; |
|
|
1563 | AV *missing = newAV (); |
|
|
1564 | RETVAL = newRV_noinc ((SV *)missing); |
1560 | |
1565 | |
1561 | while (data < data_end - 1) |
1566 | while (data < data_end - 1) |
1562 | { |
1567 | { |
1563 | flags = (data [0] << 8) + data [1]; data += 2; |
1568 | flags = (data [0] << 8) + data [1]; data += 2; |
1564 | |
1569 | |
… | |
… | |
1615 | } |
1620 | } |
1616 | else |
1621 | else |
1617 | cell->darkness = *data++ + 1; |
1622 | cell->darkness = *data++ + 1; |
1618 | } |
1623 | } |
1619 | |
1624 | |
|
|
1625 | for (z = 0; z <= 2; ++z) |
1620 | if (flags & 4) |
1626 | if (flags & (4 >> z)) |
1621 | { |
1627 | { |
1622 | faceid face = (data [0] << 8) + data [1]; data += 2; |
1628 | faceid face = (data [0] << 8) + data [1]; data += 2; |
1623 | need_facenum (self, face); |
1629 | need_facenum (self, face); |
1624 | cell->tile [0] = self->face2tile [face]; |
1630 | cell->tile [z] = self->face2tile [face]; |
|
|
1631 | |
|
|
1632 | if (cell->tile [z]) |
|
|
1633 | { |
|
|
1634 | maptex *tex = self->tex + cell->tile [z]; |
|
|
1635 | if (!tex->name) |
|
|
1636 | av_push (missing, newSViv (cell->tile [z])); |
|
|
1637 | |
|
|
1638 | if (tex->smoothtile) |
|
|
1639 | { |
|
|
1640 | maptex *smooth = self->tex + tex->smoothtile; |
|
|
1641 | if (!smooth->name) |
|
|
1642 | av_push (missing, newSViv (tex->smoothtile)); |
|
|
1643 | } |
|
|
1644 | } |
1625 | } |
1645 | } |
1626 | |
|
|
1627 | if (flags & 2) |
|
|
1628 | { |
|
|
1629 | faceid face = (data [0] << 8) + data [1]; data += 2; |
|
|
1630 | need_facenum (self, face); |
|
|
1631 | cell->tile [1] = self->face2tile [face]; |
|
|
1632 | } |
|
|
1633 | |
|
|
1634 | if (flags & 1) |
|
|
1635 | { |
|
|
1636 | faceid face = (data [0] << 8) + data [1]; data += 2; |
|
|
1637 | need_facenum (self, face); |
|
|
1638 | cell->tile [2] = self->face2tile [face]; |
|
|
1639 | } |
|
|
1640 | } |
1646 | } |
1641 | else |
1647 | else |
1642 | cell->darkness = 0; |
1648 | cell->darkness = 0; |
1643 | } |
1649 | } |
1644 | } |
1650 | } |
|
|
1651 | OUTPUT: |
|
|
1652 | RETVAL |
1645 | |
1653 | |
1646 | SV * |
1654 | SV * |
1647 | mapmap (CFPlus::Map self, int x0, int y0, int w, int h) |
1655 | mapmap (CFPlus::Map self, int x0, int y0, int w, int h) |
1648 | CODE: |
1656 | CODE: |
1649 | { |
1657 | { |
… | |
… | |
1723 | glEnable (GL_TEXTURE_2D); |
1731 | glEnable (GL_TEXTURE_2D); |
1724 | glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); |
1732 | glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); |
1725 | |
1733 | |
1726 | glBegin (GL_QUADS); |
1734 | glBegin (GL_QUADS); |
1727 | |
1735 | |
1728 | last_name = 0; |
1736 | last_name = -1; |
1729 | |
1737 | |
1730 | mx += self->x; |
1738 | mx += self->x; |
1731 | my += self->y; |
1739 | my += self->y; |
1732 | |
1740 | |
1733 | // first pass: determine smooth_max |
1741 | // first pass: determine smooth_max |
… | |
… | |
1768 | tileid tile = cell->tile [z]; |
1776 | tileid tile = cell->tile [z]; |
1769 | |
1777 | |
1770 | if (tile) |
1778 | if (tile) |
1771 | { |
1779 | { |
1772 | maptex tex = self->tex [tile]; |
1780 | maptex tex = self->tex [tile]; |
1773 | int px = (x + 1) * T - tex.w; |
1781 | int px, py; |
1774 | int py = (y + 1) * T - tex.h; |
|
|
1775 | |
1782 | |
1776 | // suppressing texture state switches here |
1783 | // suppressing texture state switches here |
1777 | // is only moderately effective, but worth the extra effort |
1784 | // is only moderately effective, but worth the extra effort |
1778 | if (last_name != tex.name) |
1785 | if (last_name != tex.name) |
1779 | { |
1786 | { |
… | |
… | |
1782 | |
1789 | |
1783 | glEnd (); |
1790 | glEnd (); |
1784 | glBindTexture (GL_TEXTURE_2D, last_name = tex.name); |
1791 | glBindTexture (GL_TEXTURE_2D, last_name = tex.name); |
1785 | glBegin (GL_QUADS); |
1792 | glBegin (GL_QUADS); |
1786 | } |
1793 | } |
|
|
1794 | |
|
|
1795 | px = (x + 1) * T - tex.w; |
|
|
1796 | py = (y + 1) * T - tex.h; |
1787 | |
1797 | |
1788 | glTexCoord2f (0 , 0 ); glVertex2f (px , py ); |
1798 | glTexCoord2f (0 , 0 ); glVertex2f (px , py ); |
1789 | glTexCoord2f (0 , tex.t); glVertex2f (px , py + tex.h); |
1799 | glTexCoord2f (0 , tex.t); glVertex2f (px , py + tex.h); |
1790 | glTexCoord2f (tex.s, tex.t); glVertex2f (px + tex.w, py + tex.h); |
1800 | glTexCoord2f (tex.s, tex.t); glVertex2f (px + tex.w, py + tex.h); |
1791 | glTexCoord2f (tex.s, 0 ); glVertex2f (px + tex.w, py ); |
1801 | glTexCoord2f (tex.s, 0 ); glVertex2f (px + tex.w, py ); |
… | |
… | |
2260 | CODE: |
2270 | CODE: |
2261 | RETVAL = SDL_RWFromFile (path, mode); |
2271 | RETVAL = SDL_RWFromFile (path, mode); |
2262 | OUTPUT: |
2272 | OUTPUT: |
2263 | RETVAL |
2273 | RETVAL |
2264 | |
2274 | |
|
|
2275 | # fails on win32: |
|
|
2276 | # CFPlus.xs(2268) : error C2059: syntax error : '(' |
2265 | void |
2277 | #void |
2266 | close (CFPlus::RW self) |
2278 | #close (CFPlus::RW self) |
2267 | CODE: |
2279 | # CODE: |
2268 | SDL_RWclose (self); |
2280 | # (self->(close)) (self); |
2269 | |
2281 | |
2270 | MODULE = CFPlus PACKAGE = CFPlus::Channel |
2282 | MODULE = CFPlus PACKAGE = CFPlus::Channel |
2271 | |
2283 | |
2272 | PROTOTYPES: DISABLE |
2284 | PROTOTYPES: DISABLE |
2273 | |
2285 | |
… | |
… | |
2333 | Mix_SetDistance (self, CLAMP (distance, 0, 255)); |
2345 | Mix_SetDistance (self, CLAMP (distance, 0, 255)); |
2334 | |
2346 | |
2335 | void |
2347 | void |
2336 | set_position (CFPlus::Channel self, int angle, int distance) |
2348 | set_position (CFPlus::Channel self, int angle, int distance) |
2337 | CODE: |
2349 | CODE: |
|
|
2350 | |
|
|
2351 | void |
|
|
2352 | set_position_r (CFPlus::Channel self, int dx, int dy, int maxdistance) |
|
|
2353 | CODE: |
|
|
2354 | { |
|
|
2355 | int distance = sqrtf (dx * dx + dy * dy) * (255.f / sqrtf (maxdistance * maxdistance)); |
|
|
2356 | int angle = 360 + (int)roundf (atan2f (dx, -dy) * 180.f / (float)M_PI); |
2338 | Mix_SetPosition (self, angle, CLAMP (distance, 0, 255)); |
2357 | Mix_SetPosition (self, angle, CLAMP (distance, 0, 255)); |
|
|
2358 | } |
2339 | |
2359 | |
2340 | void |
2360 | void |
2341 | set_reverse_stereo (CFPlus::Channel self, int flip) |
2361 | set_reverse_stereo (CFPlus::Channel self, int flip) |
2342 | CODE: |
2362 | CODE: |
2343 | Mix_SetReverseStereo (self, flip); |
2363 | Mix_SetReverseStereo (self, flip); |