… | |
… | |
804 | XPUSHs (sv_2mortal (sv_bless (newRV_noinc ((SV *)hv), gv_stashpv ("CFPlus::UI::Event", 1)))); |
804 | XPUSHs (sv_2mortal (sv_bless (newRV_noinc ((SV *)hv), gv_stashpv ("CFPlus::UI::Event", 1)))); |
805 | } |
805 | } |
806 | } |
806 | } |
807 | |
807 | |
808 | int |
808 | int |
809 | Mix_OpenAudio (int frequency = 44100, int format = MIX_DEFAULT_FORMAT, int channels = 2, int chunksize = 4096) |
809 | Mix_OpenAudio (int frequency = 44100, int format = MIX_DEFAULT_FORMAT, int channels = 2, int chunksize = 1024) |
810 | POSTCALL: |
810 | POSTCALL: |
811 | Mix_HookMusicFinished (music_finished); |
811 | Mix_HookMusicFinished (music_finished); |
812 | Mix_ChannelFinished (channel_finished); |
812 | Mix_ChannelFinished (channel_finished); |
813 | |
813 | |
814 | void |
814 | void |
… | |
… | |
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 | } |
… | |
… | |
1696 | RETVAL = map_sv; |
1699 | RETVAL = map_sv; |
1697 | } |
1700 | } |
1698 | OUTPUT: |
1701 | OUTPUT: |
1699 | RETVAL |
1702 | RETVAL |
1700 | |
1703 | |
1701 | void |
1704 | SV * |
1702 | draw (CFPlus::Map self, int mx, int my, int sw, int sh, int T) |
1705 | draw (CFPlus::Map self, int mx, int my, int sw, int sh, int T) |
1703 | CODE: |
1706 | CODE: |
1704 | { |
1707 | { |
1705 | HV *smooth = (HV *)sv_2mortal ((SV *)newHV ()); |
1708 | HV *smooth = (HV *)sv_2mortal ((SV *)newHV ()); |
1706 | uint32_t smooth_level[256 / 32]; // one bit for every possible smooth level |
1709 | uint32_t smooth_level[256 / 32]; // one bit for every possible smooth level |
1707 | static uint8_t smooth_max[256][256]; // egad, fats and wasteful on memory (64k) |
1710 | static uint8_t smooth_max[256][256]; // egad, fats and wasteful on memory (64k) |
1708 | smooth_key skey; |
1711 | smooth_key skey; |
1709 | int x, y, z; |
1712 | int x, y, z; |
1710 | int last_name; |
1713 | int last_name; |
|
|
1714 | AV *missing = newAV (); |
|
|
1715 | RETVAL = newRV_noinc ((SV *)missing); |
1711 | |
1716 | |
1712 | // thats current max. sorry. |
1717 | // thats current max. sorry. |
1713 | if (sw > 255) sw = 255; |
1718 | if (sw > 255) sw = 255; |
1714 | if (sh > 255) sh = 255; |
1719 | if (sh > 255) sh = 255; |
1715 | |
1720 | |
… | |
… | |
1723 | glEnable (GL_TEXTURE_2D); |
1728 | glEnable (GL_TEXTURE_2D); |
1724 | glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); |
1729 | glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); |
1725 | |
1730 | |
1726 | glBegin (GL_QUADS); |
1731 | glBegin (GL_QUADS); |
1727 | |
1732 | |
1728 | last_name = 0; |
1733 | last_name = -1; |
1729 | |
1734 | |
1730 | mx += self->x; |
1735 | mx += self->x; |
1731 | my += self->y; |
1736 | my += self->y; |
1732 | |
1737 | |
1733 | // first pass: determine smooth_max |
1738 | // first pass: determine smooth_max |
… | |
… | |
1768 | tileid tile = cell->tile [z]; |
1773 | tileid tile = cell->tile [z]; |
1769 | |
1774 | |
1770 | if (tile) |
1775 | if (tile) |
1771 | { |
1776 | { |
1772 | maptex tex = self->tex [tile]; |
1777 | maptex tex = self->tex [tile]; |
1773 | int px = (x + 1) * T - tex.w; |
1778 | int px, py; |
1774 | int py = (y + 1) * T - tex.h; |
|
|
1775 | |
1779 | |
1776 | // suppressing texture state switches here |
1780 | // suppressing texture state switches here |
1777 | // is only moderately effective, but worth the extra effort |
1781 | // is only moderately effective, but worth the extra effort |
1778 | if (last_name != tex.name) |
1782 | if (last_name != tex.name) |
1779 | { |
1783 | { |
1780 | if (!tex.name) |
1784 | if (!tex.name) |
|
|
1785 | { |
|
|
1786 | av_push (missing, newSViv (tile)); |
1781 | tex = self->tex [2]; /* missing, replace by noface */ |
1787 | tex = self->tex [2]; /* missing, replace by noface */ |
|
|
1788 | } |
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 ); |
… | |
… | |
1887 | // this time naively avoiding texture state changes |
1897 | // this time naively avoiding texture state changes |
1888 | // save gobs of state changes. |
1898 | // save gobs of state changes. |
1889 | if (last_name != tex.name) |
1899 | if (last_name != tex.name) |
1890 | { |
1900 | { |
1891 | if (!tex.name) |
1901 | if (!tex.name) |
|
|
1902 | { |
|
|
1903 | av_push (missing, newSViv (skey->tile)); |
1892 | continue; // smoothing not yet available |
1904 | continue; // smoothing not yet available |
|
|
1905 | } |
1893 | |
1906 | |
1894 | glEnd (); |
1907 | glEnd (); |
1895 | glBindTexture (GL_TEXTURE_2D, last_name = tex.name); |
1908 | glBindTexture (GL_TEXTURE_2D, last_name = tex.name); |
1896 | glBegin (GL_QUADS); |
1909 | glBegin (GL_QUADS); |
1897 | } |
1910 | } |
… | |
… | |
1958 | px + width - 2 - cell->stat_hp * (width - 4) / 255, py - 1); |
1971 | px + width - 2 - cell->stat_hp * (width - 4) / 255, py - 1); |
1959 | } |
1972 | } |
1960 | } |
1973 | } |
1961 | } |
1974 | } |
1962 | } |
1975 | } |
|
|
1976 | OUTPUT: |
|
|
1977 | RETVAL |
1963 | |
1978 | |
1964 | void |
1979 | void |
1965 | draw_magicmap (CFPlus::Map self, int dx, int dy, int w, int h, unsigned char *data) |
1980 | draw_magicmap (CFPlus::Map self, int dx, int dy, int w, int h, unsigned char *data) |
1966 | CODE: |
1981 | CODE: |
1967 | { |
1982 | { |
… | |
… | |
2260 | CODE: |
2275 | CODE: |
2261 | RETVAL = SDL_RWFromFile (path, mode); |
2276 | RETVAL = SDL_RWFromFile (path, mode); |
2262 | OUTPUT: |
2277 | OUTPUT: |
2263 | RETVAL |
2278 | RETVAL |
2264 | |
2279 | |
|
|
2280 | # fails on win32: |
|
|
2281 | # CFPlus.xs(2268) : error C2059: syntax error : '(' |
2265 | void |
2282 | #void |
2266 | close (CFPlus::RW self) |
2283 | #close (CFPlus::RW self) |
2267 | CODE: |
2284 | # CODE: |
2268 | SDL_RWclose (self); |
2285 | # (self->(close)) (self); |
2269 | |
2286 | |
2270 | MODULE = CFPlus PACKAGE = CFPlus::Channel |
2287 | MODULE = CFPlus PACKAGE = CFPlus::Channel |
2271 | |
2288 | |
2272 | PROTOTYPES: DISABLE |
2289 | PROTOTYPES: DISABLE |
2273 | |
2290 | |
… | |
… | |
2309 | Mix_FadeOutChannel (self, ticks); |
2326 | Mix_FadeOutChannel (self, ticks); |
2310 | |
2327 | |
2311 | int |
2328 | int |
2312 | volume (CFPlus::Channel self, int volume) |
2329 | volume (CFPlus::Channel self, int volume) |
2313 | CODE: |
2330 | CODE: |
2314 | RETVAL = Mix_Volume (self, volume); |
2331 | RETVAL = Mix_Volume (self, CLAMP (volume, 0, 128)); |
2315 | OUTPUT: |
2332 | OUTPUT: |
2316 | RETVAL |
2333 | RETVAL |
2317 | |
2334 | |
2318 | void |
2335 | void |
2319 | unregister_all_effects (CFPlus::Channel self) |
2336 | unregister_all_effects (CFPlus::Channel self) |
… | |
… | |
2321 | Mix_UnregisterAllEffects (self); |
2338 | Mix_UnregisterAllEffects (self); |
2322 | |
2339 | |
2323 | void |
2340 | void |
2324 | set_panning (CFPlus::Channel self, int left, int right) |
2341 | set_panning (CFPlus::Channel self, int left, int right) |
2325 | CODE: |
2342 | CODE: |
|
|
2343 | left = CLAMP (left , 0, 255); |
|
|
2344 | right = CLAMP (right, 0, 255); |
2326 | Mix_SetPanning (self, left, right); |
2345 | Mix_SetPanning (self, left, right); |
2327 | |
2346 | |
2328 | void |
2347 | void |
2329 | set_distance (CFPlus::Channel self, int distance) |
2348 | set_distance (CFPlus::Channel self, int distance) |
2330 | CODE: |
2349 | CODE: |
2331 | Mix_SetDistance (self, distance); |
2350 | Mix_SetDistance (self, CLAMP (distance, 0, 255)); |
2332 | |
2351 | |
2333 | void |
2352 | void |
2334 | set_position (CFPlus::Channel self, int angle, int distance) |
2353 | set_position (CFPlus::Channel self, int angle, int distance) |
2335 | CODE: |
2354 | CODE: |
2336 | Mix_SetPosition (self, angle, distance); |
2355 | Mix_SetPosition (self, angle, CLAMP (distance, 0, 255)); |
2337 | |
2356 | |
2338 | void |
2357 | void |
2339 | set_reverse_stereo (CFPlus::Channel self, int flip) |
2358 | set_reverse_stereo (CFPlus::Channel self, int flip) |
2340 | CODE: |
2359 | CODE: |
2341 | Mix_SetReverseStereo (self, flip); |
2360 | Mix_SetReverseStereo (self, flip); |
… | |
… | |
2357 | Mix_FreeChunk (self); |
2376 | Mix_FreeChunk (self); |
2358 | |
2377 | |
2359 | int |
2378 | int |
2360 | volume (CFPlus::MixChunk self, int volume = -1) |
2379 | volume (CFPlus::MixChunk self, int volume = -1) |
2361 | CODE: |
2380 | CODE: |
|
|
2381 | if (items > 1) |
|
|
2382 | volume = CLAMP (volume, 0, 128); |
2362 | RETVAL = Mix_VolumeChunk (self, volume); |
2383 | RETVAL = Mix_VolumeChunk (self, volume); |
2363 | OUTPUT: |
2384 | OUTPUT: |
2364 | RETVAL |
2385 | RETVAL |
2365 | |
2386 | |
2366 | CFPlus::Channel |
2387 | CFPlus::Channel |
… | |
… | |
2385 | |
2406 | |
2386 | int |
2407 | int |
2387 | volume (int volume = -1) |
2408 | volume (int volume = -1) |
2388 | PROTOTYPE: ;$ |
2409 | PROTOTYPE: ;$ |
2389 | CODE: |
2410 | CODE: |
|
|
2411 | if (items > 0) |
|
|
2412 | volume = CLAMP (volume, 0, 128); |
2390 | RETVAL = Mix_VolumeMusic (volume); |
2413 | RETVAL = Mix_VolumeMusic (volume); |
2391 | OUTPUT: |
2414 | OUTPUT: |
2392 | RETVAL |
2415 | RETVAL |
2393 | |
2416 | |
2394 | void |
2417 | void |