… | |
… | |
367 | self->oy = 0; |
367 | self->oy = 0; |
368 | self->row = 0; |
368 | self->row = 0; |
369 | self->rows = 0; |
369 | self->rows = 0; |
370 | } |
370 | } |
371 | |
371 | |
|
|
372 | #define CELL_CLEAR(cell) \ |
|
|
373 | do { \ |
|
|
374 | if ((cell)->player) \ |
|
|
375 | (cell)->tile [2] = 0; \ |
|
|
376 | (cell)->darkness = 0; \ |
|
|
377 | (cell)->stat_hp = 0; \ |
|
|
378 | (cell)->flags = 0; \ |
|
|
379 | (cell)->player = 0; \ |
|
|
380 | } while (0) |
|
|
381 | |
372 | static void |
382 | static void |
373 | map_blank (DC__Map self, int x0, int y0, int w, int h) |
383 | map_blank (DC__Map self, int x0, int y0, int w, int h) |
374 | { |
384 | { |
375 | int x, y; |
385 | int x, y; |
376 | maprow *row; |
386 | maprow *row; |
… | |
… | |
390 | if (x >= row->c1) |
400 | if (x >= row->c1) |
391 | break; |
401 | break; |
392 | |
402 | |
393 | cell = row->col + x - row->c0; |
403 | cell = row->col + x - row->c0; |
394 | |
404 | |
395 | cell->darkness = 0; |
405 | CELL_CLEAR (cell); |
396 | cell->stat_hp = 0; |
|
|
397 | cell->flags = 0; |
|
|
398 | cell->player = 0; |
|
|
399 | } |
406 | } |
400 | } |
407 | } |
401 | } |
408 | } |
402 | |
409 | |
403 | typedef struct { |
410 | typedef struct { |
… | |
… | |
647 | const_iv (SDL_INIT_CDROM), |
654 | const_iv (SDL_INIT_CDROM), |
648 | const_iv (SDL_INIT_JOYSTICK), |
655 | const_iv (SDL_INIT_JOYSTICK), |
649 | const_iv (SDL_INIT_EVERYTHING), |
656 | const_iv (SDL_INIT_EVERYTHING), |
650 | const_iv (SDL_INIT_NOPARACHUTE), |
657 | const_iv (SDL_INIT_NOPARACHUTE), |
651 | const_iv (SDL_INIT_EVENTTHREAD), |
658 | const_iv (SDL_INIT_EVENTTHREAD), |
|
|
659 | |
|
|
660 | const_iv (SDL_GL_RED_SIZE), |
|
|
661 | const_iv (SDL_GL_GREEN_SIZE), |
|
|
662 | const_iv (SDL_GL_BLUE_SIZE), |
|
|
663 | const_iv (SDL_GL_ALPHA_SIZE), |
|
|
664 | const_iv (SDL_GL_DOUBLEBUFFER), |
|
|
665 | const_iv (SDL_GL_BUFFER_SIZE), |
|
|
666 | const_iv (SDL_GL_DEPTH_SIZE), |
|
|
667 | const_iv (SDL_GL_STENCIL_SIZE), |
|
|
668 | const_iv (SDL_GL_ACCUM_RED_SIZE), |
|
|
669 | const_iv (SDL_GL_ACCUM_GREEN_SIZE), |
|
|
670 | const_iv (SDL_GL_ACCUM_BLUE_SIZE), |
|
|
671 | const_iv (SDL_GL_ACCUM_ALPHA_SIZE), |
|
|
672 | const_iv (SDL_GL_STEREO), |
|
|
673 | const_iv (SDL_GL_MULTISAMPLEBUFFERS), |
|
|
674 | const_iv (SDL_GL_MULTISAMPLESAMPLES), |
|
|
675 | const_iv (SDL_GL_ACCELERATED_VISUAL), |
|
|
676 | const_iv (SDL_GL_SWAP_CONTROL), |
|
|
677 | |
|
|
678 | const_iv (FOW_DARKNESS) |
652 | # undef const_iv |
679 | # undef const_iv |
653 | }; |
680 | }; |
654 | |
681 | |
655 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
682 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
656 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
683 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
… | |
… | |
673 | RETVAL |
700 | RETVAL |
674 | |
701 | |
675 | NV floor (NV x) |
702 | NV floor (NV x) |
676 | |
703 | |
677 | NV ceil (NV x) |
704 | NV ceil (NV x) |
|
|
705 | |
|
|
706 | NV ceilabs (NV x) |
|
|
707 | CODE: |
|
|
708 | RETVAL = x < 0. ? - ceil (-x) : ceil (x); |
|
|
709 | OUTPUT: |
|
|
710 | RETVAL |
678 | |
711 | |
679 | IV minpot (UV n) |
712 | IV minpot (UV n) |
680 | |
713 | |
681 | IV popcount (UV n) |
714 | IV popcount (UV n) |
682 | |
715 | |
… | |
… | |
702 | |
735 | |
703 | void SDL_QuitSubSystem (U32 flags) |
736 | void SDL_QuitSubSystem (U32 flags) |
704 | |
737 | |
705 | void SDL_Quit () |
738 | void SDL_Quit () |
706 | |
739 | |
|
|
740 | int SDL_GL_SetAttribute (int attr, int value) |
|
|
741 | |
|
|
742 | int SDL_GL_GetAttribute (int attr) |
|
|
743 | CODE: |
|
|
744 | if (SDL_GL_GetAttribute (attr, &RETVAL)) |
|
|
745 | XSRETURN_UNDEF; |
|
|
746 | OUTPUT: |
|
|
747 | RETVAL |
|
|
748 | |
707 | void |
749 | void |
708 | SDL_ListModes (int rgb, int alpha) |
750 | SDL_ListModes (int rgb, int alpha) |
709 | PPCODE: |
751 | PPCODE: |
710 | { |
752 | { |
711 | SDL_Rect **m; |
753 | SDL_Rect **m; |
… | |
… | |
722 | SDL_GL_SetAttribute (SDL_GL_ACCUM_GREEN_SIZE, 0); |
764 | SDL_GL_SetAttribute (SDL_GL_ACCUM_GREEN_SIZE, 0); |
723 | SDL_GL_SetAttribute (SDL_GL_ACCUM_BLUE_SIZE , 0); |
765 | SDL_GL_SetAttribute (SDL_GL_ACCUM_BLUE_SIZE , 0); |
724 | SDL_GL_SetAttribute (SDL_GL_ACCUM_ALPHA_SIZE, 0); |
766 | SDL_GL_SetAttribute (SDL_GL_ACCUM_ALPHA_SIZE, 0); |
725 | |
767 | |
726 | SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1); |
768 | SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1); |
727 | #if SDL_VERSION_ATLEAST(1,2,10) |
|
|
728 | SDL_GL_SetAttribute (SDL_GL_ACCELERATED_VISUAL, 1); |
|
|
729 | SDL_GL_SetAttribute (SDL_GL_SWAP_CONTROL, 1); |
769 | SDL_GL_SetAttribute (SDL_GL_SWAP_CONTROL, 1); |
730 | #endif |
|
|
731 | |
770 | |
732 | m = SDL_ListModes (0, SDL_FULLSCREEN | SDL_OPENGL); |
771 | m = SDL_ListModes (0, SDL_FULLSCREEN | SDL_OPENGL); |
733 | |
772 | |
734 | if (m && m != (SDL_Rect **)-1) |
773 | if (m && m != (SDL_Rect **)-1) |
735 | while (*m) |
774 | while (*m) |
736 | { |
775 | { |
|
|
776 | if ((*m)->w >= 400 && (*m)->h >= 300) |
|
|
777 | { |
737 | AV *av = newAV (); |
778 | AV *av = newAV (); |
738 | av_push (av, newSViv ((*m)->w)); |
779 | av_push (av, newSViv ((*m)->w)); |
739 | av_push (av, newSViv ((*m)->h)); |
780 | av_push (av, newSViv ((*m)->h)); |
740 | av_push (av, newSViv (rgb)); |
781 | av_push (av, newSViv (rgb)); |
741 | av_push (av, newSViv (alpha)); |
782 | av_push (av, newSViv (alpha)); |
742 | XPUSHs (sv_2mortal (newRV_noinc ((SV *)av))); |
783 | XPUSHs (sv_2mortal (newRV_noinc ((SV *)av))); |
|
|
784 | } |
743 | |
785 | |
744 | ++m; |
786 | ++m; |
745 | } |
787 | } |
746 | } |
788 | } |
747 | |
789 | |
… | |
… | |
1753 | } |
1795 | } |
1754 | } |
1796 | } |
1755 | } |
1797 | } |
1756 | } |
1798 | } |
1757 | else |
1799 | else |
1758 | cell->darkness = 0; |
1800 | CELL_CLEAR (cell); |
1759 | } |
1801 | } |
1760 | } |
1802 | } |
1761 | OUTPUT: |
1803 | OUTPUT: |
1762 | RETVAL |
1804 | RETVAL |
1763 | |
1805 | |
… | |
… | |
1815 | } |
1857 | } |
1816 | OUTPUT: |
1858 | OUTPUT: |
1817 | RETVAL |
1859 | RETVAL |
1818 | |
1860 | |
1819 | void |
1861 | void |
1820 | draw (DC::Map self, int mx, int my, int sw, int sh, int T, U32 player = 0xffffffff, int pdx = 0, int pdy = 0) |
1862 | draw (DC::Map self, int mx, int my, int sw, int sh, int T, U32 player = 0xffffffff, int sdx = 0, int sdy = 0) |
1821 | CODE: |
1863 | CODE: |
1822 | { |
1864 | { |
1823 | int x, y, z; |
1865 | int x, y, z; |
1824 | |
1866 | |
1825 | HV *smooth = (HV *)sv_2mortal ((SV *)newHV ()); |
1867 | HV *smooth = (HV *)sv_2mortal ((SV *)newHV ()); |
… | |
… | |
2072 | } |
2114 | } |
2073 | |
2115 | |
2074 | if (pl_tex.name) |
2116 | if (pl_tex.name) |
2075 | { |
2117 | { |
2076 | maptex tex = pl_tex; |
2118 | maptex tex = pl_tex; |
2077 | int px = pl_x + pdx; |
2119 | int px = pl_x + sdx; |
2078 | int py = pl_y + pdy; |
2120 | int py = pl_y + sdy; |
2079 | |
2121 | |
2080 | key.texname = tex.name; |
2122 | key.texname = tex.name; |
2081 | arr = rc_array (rc, &key); |
2123 | arr = rc_array (rc, &key); |
2082 | |
2124 | |
2083 | rc_t2f_v3f (arr, 0 , 0 , px , py , 0); |
2125 | rc_t2f_v3f (arr, 0 , 0 , px , py , 0); |
… | |
… | |
2200 | SvCUR_set (darkness3_sv, sw34 * sh3); |
2242 | SvCUR_set (darkness3_sv, sw34 * sh3); |
2201 | |
2243 | |
2202 | mx += self->x - 1; |
2244 | mx += self->x - 1; |
2203 | my += self->y - 1; |
2245 | my += self->y - 1; |
2204 | |
2246 | |
2205 | memset (darkness1, 255, sw1 * sh1); |
2247 | memset (darkness1, 255 - FOW_DARKNESS, sw1 * sh1); |
2206 | |
2248 | |
2207 | for (y = 0; y < sh1; y++) |
2249 | for (y = 0; y < sh1; y++) |
2208 | if (0 <= y + my && y + my < self->rows) |
2250 | if (0 <= y + my && y + my < self->rows) |
2209 | { |
2251 | { |
2210 | maprow *row = self->row + (y + my); |
2252 | maprow *row = self->row + (y + my); |