… | |
… | |
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 | { |
… | |
… | |
373 | self->oy = 0; |
367 | self->oy = 0; |
374 | self->row = 0; |
368 | self->row = 0; |
375 | self->rows = 0; |
369 | self->rows = 0; |
376 | } |
370 | } |
377 | |
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 | |
378 | static void |
382 | static void |
379 | 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) |
380 | { |
384 | { |
381 | int x, y; |
385 | int x, y; |
382 | maprow *row; |
386 | maprow *row; |
… | |
… | |
396 | if (x >= row->c1) |
400 | if (x >= row->c1) |
397 | break; |
401 | break; |
398 | |
402 | |
399 | cell = row->col + x - row->c0; |
403 | cell = row->col + x - row->c0; |
400 | |
404 | |
401 | cell->darkness = 0; |
405 | CELL_CLEAR (cell); |
402 | cell->stat_hp = 0; |
|
|
403 | cell->flags = 0; |
|
|
404 | cell->player = 0; |
|
|
405 | } |
406 | } |
406 | } |
407 | } |
407 | } |
408 | } |
408 | |
409 | |
409 | typedef struct { |
410 | typedef struct { |
… | |
… | |
644 | const_iv (KMOD_NUM), |
645 | const_iv (KMOD_NUM), |
645 | const_iv (KMOD_CAPS), |
646 | const_iv (KMOD_CAPS), |
646 | const_iv (KMOD_MODE), |
647 | const_iv (KMOD_MODE), |
647 | |
648 | |
648 | const_iv (MIX_DEFAULT_FORMAT), |
649 | const_iv (MIX_DEFAULT_FORMAT), |
|
|
650 | |
|
|
651 | const_iv (SDL_INIT_TIMER), |
|
|
652 | const_iv (SDL_INIT_AUDIO), |
|
|
653 | const_iv (SDL_INIT_VIDEO), |
|
|
654 | const_iv (SDL_INIT_CDROM), |
|
|
655 | const_iv (SDL_INIT_JOYSTICK), |
|
|
656 | const_iv (SDL_INIT_EVERYTHING), |
|
|
657 | const_iv (SDL_INIT_NOPARACHUTE), |
|
|
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) |
649 | # undef const_iv |
677 | # undef const_iv |
650 | }; |
678 | }; |
651 | |
679 | |
652 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
680 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
653 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
681 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
… | |
… | |
689 | pango_context_set_language (opengl_context, pango_language_from_string ("en")); |
717 | pango_context_set_language (opengl_context, pango_language_from_string ("en")); |
690 | /*pango_context_set_base_dir (opengl_context, PANGO_DIRECTION_WEAK_LTR);*/ |
718 | /*pango_context_set_base_dir (opengl_context, PANGO_DIRECTION_WEAK_LTR);*/ |
691 | #endif |
719 | #endif |
692 | } |
720 | } |
693 | |
721 | |
694 | char * |
|
|
695 | SDL_GetError () |
722 | char *SDL_GetError () |
696 | |
723 | |
697 | int |
724 | int SDL_Init (U32 flags) |
698 | SDL_Init (U32 flags = SDL_INIT_VIDEO | SDL_INIT_AUDIO | PARACHUTE) |
|
|
699 | |
725 | |
700 | void |
726 | int SDL_InitSubSystem (U32 flags) |
|
|
727 | |
|
|
728 | void SDL_QuitSubSystem (U32 flags) |
|
|
729 | |
701 | SDL_Quit () |
730 | void SDL_Quit () |
|
|
731 | |
|
|
732 | int SDL_GL_SetAttribute (int attr, int value) |
|
|
733 | |
|
|
734 | int SDL_GL_GetAttribute (int attr) |
|
|
735 | CODE: |
|
|
736 | if (SDL_GL_GetAttribute (attr, &RETVAL)) |
|
|
737 | XSRETURN_UNDEF; |
|
|
738 | OUTPUT: |
|
|
739 | RETVAL |
702 | |
740 | |
703 | void |
741 | void |
704 | SDL_ListModes (int rgb, int alpha) |
742 | SDL_ListModes (int rgb, int alpha) |
705 | PPCODE: |
743 | PPCODE: |
706 | { |
744 | { |
… | |
… | |
718 | SDL_GL_SetAttribute (SDL_GL_ACCUM_GREEN_SIZE, 0); |
756 | SDL_GL_SetAttribute (SDL_GL_ACCUM_GREEN_SIZE, 0); |
719 | SDL_GL_SetAttribute (SDL_GL_ACCUM_BLUE_SIZE , 0); |
757 | SDL_GL_SetAttribute (SDL_GL_ACCUM_BLUE_SIZE , 0); |
720 | SDL_GL_SetAttribute (SDL_GL_ACCUM_ALPHA_SIZE, 0); |
758 | SDL_GL_SetAttribute (SDL_GL_ACCUM_ALPHA_SIZE, 0); |
721 | |
759 | |
722 | SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1); |
760 | 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); |
761 | SDL_GL_SetAttribute (SDL_GL_SWAP_CONTROL, 1); |
726 | #endif |
|
|
727 | |
762 | |
728 | m = SDL_ListModes (0, SDL_FULLSCREEN | SDL_OPENGL); |
763 | m = SDL_ListModes (0, SDL_FULLSCREEN | SDL_OPENGL); |
729 | |
764 | |
730 | if (m && m != (SDL_Rect **)-1) |
765 | if (m && m != (SDL_Rect **)-1) |
731 | while (*m) |
766 | while (*m) |
732 | { |
767 | { |
733 | if ((*m)->w >= 800 && (*m)->h >= 480) |
768 | if ((*m)->w >= 400 && (*m)->h >= 300) |
734 | { |
769 | { |
735 | AV *av = newAV (); |
770 | AV *av = newAV (); |
736 | av_push (av, newSViv ((*m)->w)); |
771 | av_push (av, newSViv ((*m)->w)); |
737 | av_push (av, newSViv ((*m)->h)); |
772 | av_push (av, newSViv ((*m)->h)); |
738 | av_push (av, newSViv (rgb)); |
773 | av_push (av, newSViv (rgb)); |
… | |
… | |
1752 | } |
1787 | } |
1753 | } |
1788 | } |
1754 | } |
1789 | } |
1755 | } |
1790 | } |
1756 | else |
1791 | else |
1757 | cell->darkness = 0; |
1792 | CELL_CLEAR (cell); |
1758 | } |
1793 | } |
1759 | } |
1794 | } |
1760 | OUTPUT: |
1795 | OUTPUT: |
1761 | RETVAL |
1796 | RETVAL |
1762 | |
1797 | |
… | |
… | |
1814 | } |
1849 | } |
1815 | OUTPUT: |
1850 | OUTPUT: |
1816 | RETVAL |
1851 | RETVAL |
1817 | |
1852 | |
1818 | void |
1853 | 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) |
1854 | 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: |
1855 | CODE: |
1821 | { |
1856 | { |
1822 | int x, y, z; |
1857 | int x, y, z; |
1823 | |
1858 | |
1824 | HV *smooth = (HV *)sv_2mortal ((SV *)newHV ()); |
1859 | HV *smooth = (HV *)sv_2mortal ((SV *)newHV ()); |
1825 | uint32_t smooth_level[256 / 32]; // one bit for every possible smooth level |
1860 | 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) |
1861 | static uint8_t smooth_max[256][256]; // egad, fast and wasteful on memory (64k) |
1827 | smooth_key skey; |
1862 | smooth_key skey; |
1828 | int pl_x, pl_y; |
1863 | int pl_x, pl_y; |
1829 | maptex pl_tex; |
1864 | maptex pl_tex; |
1830 | |
|
|
1831 | pl_tex.name = 0; |
|
|
1832 | |
|
|
1833 | rc_t *rc = rc_alloc (); |
1865 | rc_t *rc = rc_alloc (); |
1834 | rc_key_t key; |
1866 | rc_key_t key; |
1835 | rc_array_t *arr; |
1867 | rc_array_t *arr; |
|
|
1868 | |
|
|
1869 | pl_tex.name = 0; |
1836 | |
1870 | |
1837 | // thats current max. sorry. |
1871 | // thats current max. sorry. |
1838 | if (sw > 255) sw = 255; |
1872 | if (sw > 255) sw = 255; |
1839 | if (sh > 255) sh = 255; |
1873 | if (sh > 255) sh = 255; |
1840 | |
1874 | |
… | |
… | |
2072 | } |
2106 | } |
2073 | |
2107 | |
2074 | if (pl_tex.name) |
2108 | if (pl_tex.name) |
2075 | { |
2109 | { |
2076 | maptex tex = pl_tex; |
2110 | maptex tex = pl_tex; |
2077 | int px = pl_x + pdx; |
2111 | int px = pl_x + sdx; |
2078 | int py = pl_y + pdy; |
2112 | int py = pl_y + sdy; |
2079 | |
2113 | |
2080 | key.texname = tex.name; |
2114 | key.texname = tex.name; |
2081 | arr = rc_array (rc, &key); |
2115 | arr = rc_array (rc, &key); |
2082 | |
2116 | |
2083 | rc_t2f_v3f (arr, 0 , 0 , px , py , 0); |
2117 | rc_t2f_v3f (arr, 0 , 0 , px , py , 0); |