| 1870 | } |
| 1871 | |
| 1872 | staticfn void |
| 1873 | mk_bubble(coordxy x, coordxy y, int n) |
| 1874 | { |
| 1875 | /* |
| 1876 | * These bit masks make visually pleasing bubbles on a normal aspect |
| 1877 | * 25x80 terminal, which naturally results in them being mathematically |
| 1878 | * anything but symmetric. For this reason they cannot be computed |
| 1879 | * in situ, either. The first two elements tell the dimensions of |
| 1880 | * the bubble's bounding box. |
| 1881 | */ |
| 1882 | static const uchar |
| 1883 | bm2[] = { 2, 1, 0x3 }, |
| 1884 | bm3[] = { 3, 2, 0x7, 0x7 }, |
| 1885 | bm4[] = { 4, 3, 0x6, 0xf, 0x6 }, |
| 1886 | bm5[] = { 5, 3, 0xe, 0x1f, 0xe }, |
| 1887 | bm6[] = { 6, 4, 0x1e, 0x3f, 0x3f, 0x1e }, |
| 1888 | bm7[] = { 7, 4, 0x3e, 0x7f, 0x7f, 0x3e }, |
| 1889 | bm8[] = { 8, 4, 0x7e, 0xff, 0xff, 0x7e }, |
| 1890 | *const bmask[] = { bm2, bm3, bm4, bm5, bm6, bm7, bm8 }; |
| 1891 | struct bubble *b; |
| 1892 | |
| 1893 | if (x >= gbxmax || y >= gbymax) |
| 1894 | return; |
| 1895 | if (n >= SIZE(bmask)) { |
| 1896 | impossible("n too large (mk_bubble)"); |
| 1897 | n = SIZE(bmask) - 1; |
| 1898 | } |
| 1899 | if (bmask[n][1] > MAX_BMASK) { |
| 1900 | panic("bmask size is larger than MAX_BMASK"); |
| 1901 | } |
| 1902 | b = (struct bubble *) alloc(sizeof *b); |
| 1903 | if ((x + (int) bmask[n][0] - 1) > gbxmax) |
| 1904 | x = gbxmax - bmask[n][0] + 1; |
| 1905 | if ((y + (int) bmask[n][1] - 1) > gbymax) |
| 1906 | y = gbymax - bmask[n][1] + 1; |
| 1907 | b->x = x; |
| 1908 | b->y = y; |
| 1909 | b->dx = 1 - rn2(3); |
| 1910 | b->dy = 1 - rn2(3); |
| 1911 | /* y dimension is the length of bitmap data - see bmask above */ |
| 1912 | (void) memcpy((genericptr_t) b->bm, (genericptr_t) bmask[n], |
| 1913 | (bmask[n][1] + 2) * sizeof (b->bm[0])); |
| 1914 | b->cons = 0; |
| 1915 | if (!svb.bbubbles) |
| 1916 | svb.bbubbles = b; |
| 1917 | if (ge.ebubbles) { |
| 1918 | ge.ebubbles->next = b; |
| 1919 | b->prev = ge.ebubbles; |
| 1920 | } else |
| 1921 | b->prev = (struct bubble *) 0; |
| 1922 | b->next = (struct bubble *) 0; |
| 1923 | ge.ebubbles = b; |
| 1924 | mv_bubble(b, 0, 0, TRUE); |
| 1925 | } |
| 1926 | |
| 1927 | /* maybe change the movement direction of the bubble hero is in */ |
| 1928 | void |
no test coverage detected