… | |
… | |
85 | |
85 | |
86 | #define MIN_FONT_HEIGHT 10 |
86 | #define MIN_FONT_HEIGHT 10 |
87 | |
87 | |
88 | /* mask out modifiers we are not interested in */ |
88 | /* mask out modifiers we are not interested in */ |
89 | #define MOD_MASK (KMOD_CTRL | KMOD_SHIFT | KMOD_ALT | KMOD_META) |
89 | #define MOD_MASK (KMOD_CTRL | KMOD_SHIFT | KMOD_ALT | KMOD_META) |
90 | |
|
|
91 | #if 1 |
|
|
92 | # define PARACHUTE SDL_INIT_NOPARACHUTE |
|
|
93 | #else |
|
|
94 | # define PARACHUTE 0 |
|
|
95 | #endif |
|
|
96 | |
90 | |
97 | static AV *texture_av; |
91 | static AV *texture_av; |
98 | |
92 | |
99 | static struct |
93 | static struct |
100 | { |
94 | { |
… | |
… | |
644 | const_iv (KMOD_NUM), |
638 | const_iv (KMOD_NUM), |
645 | const_iv (KMOD_CAPS), |
639 | const_iv (KMOD_CAPS), |
646 | const_iv (KMOD_MODE), |
640 | const_iv (KMOD_MODE), |
647 | |
641 | |
648 | const_iv (MIX_DEFAULT_FORMAT), |
642 | const_iv (MIX_DEFAULT_FORMAT), |
|
|
643 | |
|
|
644 | const_iv (SDL_INIT_TIMER), |
|
|
645 | const_iv (SDL_INIT_AUDIO), |
|
|
646 | const_iv (SDL_INIT_VIDEO), |
|
|
647 | const_iv (SDL_INIT_CDROM), |
|
|
648 | const_iv (SDL_INIT_JOYSTICK), |
|
|
649 | const_iv (SDL_INIT_EVERYTHING), |
|
|
650 | const_iv (SDL_INIT_NOPARACHUTE), |
|
|
651 | const_iv (SDL_INIT_EVENTTHREAD), |
|
|
652 | |
|
|
653 | const_iv (SDL_GL_RED_SIZE), |
|
|
654 | const_iv (SDL_GL_GREEN_SIZE), |
|
|
655 | const_iv (SDL_GL_BLUE_SIZE), |
|
|
656 | const_iv (SDL_GL_ALPHA_SIZE), |
|
|
657 | const_iv (SDL_GL_DOUBLEBUFFER), |
|
|
658 | const_iv (SDL_GL_BUFFER_SIZE), |
|
|
659 | const_iv (SDL_GL_DEPTH_SIZE), |
|
|
660 | const_iv (SDL_GL_STENCIL_SIZE), |
|
|
661 | const_iv (SDL_GL_ACCUM_RED_SIZE), |
|
|
662 | const_iv (SDL_GL_ACCUM_GREEN_SIZE), |
|
|
663 | const_iv (SDL_GL_ACCUM_BLUE_SIZE), |
|
|
664 | const_iv (SDL_GL_ACCUM_ALPHA_SIZE), |
|
|
665 | const_iv (SDL_GL_STEREO), |
|
|
666 | const_iv (SDL_GL_MULTISAMPLEBUFFERS), |
|
|
667 | const_iv (SDL_GL_MULTISAMPLESAMPLES), |
|
|
668 | const_iv (SDL_GL_ACCELERATED_VISUAL), |
|
|
669 | const_iv (SDL_GL_SWAP_CONTROL) |
649 | # undef const_iv |
670 | # undef const_iv |
650 | }; |
671 | }; |
651 | |
672 | |
652 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
673 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
653 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
674 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
… | |
… | |
689 | pango_context_set_language (opengl_context, pango_language_from_string ("en")); |
710 | pango_context_set_language (opengl_context, pango_language_from_string ("en")); |
690 | /*pango_context_set_base_dir (opengl_context, PANGO_DIRECTION_WEAK_LTR);*/ |
711 | /*pango_context_set_base_dir (opengl_context, PANGO_DIRECTION_WEAK_LTR);*/ |
691 | #endif |
712 | #endif |
692 | } |
713 | } |
693 | |
714 | |
694 | char * |
|
|
695 | SDL_GetError () |
715 | char *SDL_GetError () |
696 | |
716 | |
697 | int |
717 | int SDL_Init (U32 flags) |
698 | SDL_Init (U32 flags = SDL_INIT_VIDEO | SDL_INIT_AUDIO | PARACHUTE) |
|
|
699 | |
718 | |
700 | void |
719 | int SDL_InitSubSystem (U32 flags) |
|
|
720 | |
|
|
721 | void SDL_QuitSubSystem (U32 flags) |
|
|
722 | |
701 | SDL_Quit () |
723 | void SDL_Quit () |
|
|
724 | |
|
|
725 | int SDL_GL_SetAttribute (int attr, int value) |
|
|
726 | |
|
|
727 | int SDL_GL_GetAttribute (int attr) |
|
|
728 | CODE: |
|
|
729 | if (SDL_GL_GetAttribute (attr, &RETVAL)) |
|
|
730 | XSRETURN_UNDEF; |
|
|
731 | OUTPUT: |
|
|
732 | RETVAL |
702 | |
733 | |
703 | void |
734 | void |
704 | SDL_ListModes (int rgb, int alpha) |
735 | SDL_ListModes (int rgb, int alpha) |
705 | PPCODE: |
736 | PPCODE: |
706 | { |
737 | { |
… | |
… | |
718 | SDL_GL_SetAttribute (SDL_GL_ACCUM_GREEN_SIZE, 0); |
749 | SDL_GL_SetAttribute (SDL_GL_ACCUM_GREEN_SIZE, 0); |
719 | SDL_GL_SetAttribute (SDL_GL_ACCUM_BLUE_SIZE , 0); |
750 | SDL_GL_SetAttribute (SDL_GL_ACCUM_BLUE_SIZE , 0); |
720 | SDL_GL_SetAttribute (SDL_GL_ACCUM_ALPHA_SIZE, 0); |
751 | SDL_GL_SetAttribute (SDL_GL_ACCUM_ALPHA_SIZE, 0); |
721 | |
752 | |
722 | SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1); |
753 | SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1); |
723 | #if SDL_VERSION_ATLEAST(1,2,10) |
|
|
724 | SDL_GL_SetAttribute (SDL_GL_ACCELERATED_VISUAL, 1); |
|
|
725 | SDL_GL_SetAttribute (SDL_GL_SWAP_CONTROL, 1); |
754 | SDL_GL_SetAttribute (SDL_GL_SWAP_CONTROL, 1); |
726 | #endif |
|
|
727 | |
755 | |
728 | m = SDL_ListModes (0, SDL_FULLSCREEN | SDL_OPENGL); |
756 | m = SDL_ListModes (0, SDL_FULLSCREEN | SDL_OPENGL); |
729 | |
757 | |
730 | if (m && m != (SDL_Rect **)-1) |
758 | if (m && m != (SDL_Rect **)-1) |
731 | while (*m) |
759 | while (*m) |
732 | { |
760 | { |
733 | if ((*m)->w >= 800 && (*m)->h >= 480) |
761 | if ((*m)->w >= 400 && (*m)->h >= 300) |
734 | { |
762 | { |
735 | AV *av = newAV (); |
763 | AV *av = newAV (); |
736 | av_push (av, newSViv ((*m)->w)); |
764 | av_push (av, newSViv ((*m)->w)); |
737 | av_push (av, newSViv ((*m)->h)); |
765 | av_push (av, newSViv ((*m)->h)); |
738 | av_push (av, newSViv (rgb)); |
766 | av_push (av, newSViv (rgb)); |
… | |
… | |
1752 | } |
1780 | } |
1753 | } |
1781 | } |
1754 | } |
1782 | } |
1755 | } |
1783 | } |
1756 | else |
1784 | else |
|
|
1785 | { |
1757 | cell->darkness = 0; |
1786 | cell->darkness = 0; |
|
|
1787 | cell->stat_hp = 0; |
|
|
1788 | cell->flags = 0; |
|
|
1789 | cell->player = 0; |
|
|
1790 | } |
1758 | } |
1791 | } |
1759 | } |
1792 | } |
1760 | OUTPUT: |
1793 | OUTPUT: |
1761 | RETVAL |
1794 | RETVAL |
1762 | |
1795 | |
… | |
… | |
1814 | } |
1847 | } |
1815 | OUTPUT: |
1848 | OUTPUT: |
1816 | RETVAL |
1849 | RETVAL |
1817 | |
1850 | |
1818 | void |
1851 | void |
1819 | draw (DC::Map self, int mx, int my, int sw, int sh, int T, U32 player = 0xffffffff, int pdx = 0, int pdy = 0) |
1852 | draw (DC::Map self, int mx, int my, int sw, int sh, int T, U32 player = 0xffffffff, int sdx = 0, int sdy = 0) |
1820 | CODE: |
1853 | CODE: |
1821 | { |
1854 | { |
1822 | int x, y, z; |
1855 | int x, y, z; |
1823 | |
1856 | |
1824 | HV *smooth = (HV *)sv_2mortal ((SV *)newHV ()); |
1857 | HV *smooth = (HV *)sv_2mortal ((SV *)newHV ()); |
1825 | uint32_t smooth_level[256 / 32]; // one bit for every possible smooth level |
1858 | uint32_t smooth_level[256 / 32]; // one bit for every possible smooth level |
1826 | static uint8_t smooth_max[256][256]; // egad, fast and wasteful on memory (64k) |
1859 | static uint8_t smooth_max[256][256]; // egad, fast and wasteful on memory (64k) |
1827 | smooth_key skey; |
1860 | smooth_key skey; |
1828 | int pl_x, pl_y; |
1861 | int pl_x, pl_y; |
1829 | maptex pl_tex; |
1862 | maptex pl_tex; |
1830 | |
|
|
1831 | pl_tex.name = 0; |
|
|
1832 | |
|
|
1833 | rc_t *rc = rc_alloc (); |
1863 | rc_t *rc = rc_alloc (); |
1834 | rc_key_t key; |
1864 | rc_key_t key; |
1835 | rc_array_t *arr; |
1865 | rc_array_t *arr; |
|
|
1866 | |
|
|
1867 | pl_tex.name = 0; |
1836 | |
1868 | |
1837 | // thats current max. sorry. |
1869 | // thats current max. sorry. |
1838 | if (sw > 255) sw = 255; |
1870 | if (sw > 255) sw = 255; |
1839 | if (sh > 255) sh = 255; |
1871 | if (sh > 255) sh = 255; |
1840 | |
1872 | |
… | |
… | |
2072 | } |
2104 | } |
2073 | |
2105 | |
2074 | if (pl_tex.name) |
2106 | if (pl_tex.name) |
2075 | { |
2107 | { |
2076 | maptex tex = pl_tex; |
2108 | maptex tex = pl_tex; |
2077 | int px = pl_x + pdx; |
2109 | int px = pl_x + sdx; |
2078 | int py = pl_y + pdy; |
2110 | int py = pl_y + sdy; |
2079 | |
2111 | |
2080 | key.texname = tex.name; |
2112 | key.texname = tex.name; |
2081 | arr = rc_array (rc, &key); |
2113 | arr = rc_array (rc, &key); |
2082 | |
2114 | |
2083 | rc_t2f_v3f (arr, 0 , 0 , px , py , 0); |
2115 | rc_t2f_v3f (arr, 0 , 0 , px , py , 0); |