/* ybspr.c (c)1988 Ali T. Ozer ** Sprite stuff for YaBoing II ** Freely distributable. */ #include "yb2.h" #define IMAGEHEIGHT 20 unsigned short sprimages[OPVALUE+OPVALUES][IMAGEHEIGHT] = { {0x00e0,0x071c,0x0e0e,0x0e0e,0x1e0f,0x1e0f,0x1e0f,0x1e0f,0x1e0f,0x1e0f, 0x1e0f,0x1e0f,0x1e0f,0x1e0f,0x1e0f,0x1e0f,0x0e0e,0x0e0e,0x071c,0x00e0}, {0x0020,0x00e0,0x0fe0,0x0ce0,0x00e0,0x00e0,0x00e0,0x00e0,0x00e0,0x00e0, 0x00e0,0x00e0,0x00e0,0x00e0,0x00e0,0x00e0,0x00e0,0x00e0,0x0ffe,0x0ffe}, {0x01e0,0x07fc,0x1c1e,0x1c1f,0x1e0f,0x1e0f,0x0c0f,0x000f,0x001e,0x001e, 0x003c,0x0070,0x00e0,0x01c1,0x0181,0x0203,0x07ff,0x0fff,0x1ffe,0x1ffe}, {0x01e0,0x07fc,0x0e1e,0x0e1e,0x0e1e,0x0e1e,0x001e,0x003c,0x0078,0x01f8, 0x001e,0x001f,0x000f,0x000f,0x1c0f,0x1e0f,0x1e1f,0x1c1e,0x0ffc,0x01e0}, {0x0018,0x0038,0x0078,0x0078,0x00b8,0x01b8,0x0338,0x0638,0x0438,0x0838, 0x1838,0x3038,0x6038,0x7fff,0x0078,0x0078,0x0078,0x0078,0x03ff,0x03ff}, {0x0402,0x07fc,0x07fc,0x07f0,0x07c0,0x0400,0x0400,0x0400,0x07f8,0x041e, 0x000e,0x000f,0x000f,0x1c0f,0x1c0f,0x1c0f,0x180f,0x0c1e,0x07fc,0x01e0}, {0x0078,0x01fe,0x038e,0x070e,0x0e0e,0x1e00,0x1e00,0x1e00,0x1ef8,0x1f0e, 0x1e0f,0x1e0f,0x1e0f,0x1e0f,0x1e0f,0x1e0f,0x0e0f,0x070e,0x03fc,0x00f0}, {0x1fff,0x1fff,0x1ffe,0x1ffe,0x100c,0x3018,0x3030,0x0060,0x0060,0x00c0, 0x00c0,0x01c0,0x01c0,0x01c0,0x01c0,0x03c0,0x03c0,0x03c0,0x03c0,0x0180}, {0x00f0,0x03fc,0x060e,0x0c06,0x0c06,0x0e06,0x0f8e,0x0fdc,0x07f0,0x03fc, 0x07fe,0x0e3f,0x1c1f,0x1807,0x1803,0x1803,0x1c07,0x0e06,0x07fc,0x01f0}, {0x01e0,0x07f8,0x0f1c,0x1e0e,0x1e0f,0x1e0f,0x1e0f,0x1e0f,0x1e0f,0x1e0f, 0x0e1f,0x03ef,0x000f,0x000f,0x000f,0x0e0e,0x0e1e,0x0e3c,0x07f0,0x03e0}, /*** ADD ***/ {0x0000,0x0000,0x0000,0x0000,0x00e0,0x00e0,0x00e0,0x00e0,0x0ffe,0x0ffe, 0x0ffe,0x00e0,0x00e0,0x00e0,0x00e0,0x0000,0x0000,0x0000,0x0000,0x0000}, /*** POP ***/ {0x0000,0x7e00,0x3300,0x3300,0x3300,0x3e00,0x31c0,0x3360,0x3630,0x7e30, 0x0630,0x067e,0x0633,0x0373,0x01f3,0x003e,0x0030,0x0030,0x0030,0x0078}, /*** MUL ***/ {0x0000,0x0000,0x0000,0x0000,0x0000,0x030c,0x079e,0x03fc,0x01f8,0x00f0, 0x01f8,0x03fc,0x079e,0x030c,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000}, /*** DIV ***/ {0x0000,0x0000,0x0000,0x00e0,0x00e0,0x00e0,0x0000,0x0000,0x0ffe,0x0ffe, 0x0ffe,0x0000,0x0000,0x00e0,0x00e0,0x00e0,0x0000,0x0000,0x0000,0x0000}, /*** SWP ***/ {0x3800,0x6def,0x60c6,0x3cc6,0x06c6,0x06d6,0x66d6,0x66d6,0x3c7c,0x006c, 0x0c00,0x1e7e,0x3333,0x3333,0x3333,0x3f3e,0x3330,0x3330,0x7eb0,0x0078}, /*** SUB ***/ {0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0ffe,0x0ffe, 0x0ffe,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000}, /*** Question Mark ***/ {0x00e0,0x03f8,0x061c,0x0f1e,0x0f1e,0x0f1e,0x001e,0x003c,0x0070,0x0060, 0x00c0,0x00c0,0x00c0,0x00c0,0x0000,0x00c0,0x01e0,0x01e0,0x01e0,0x00c0} }; /* Assuming we have enough bytes in the sprite area... ** Loads specified image into the memory area provided. */ void LoadSpriteImage (sprmem, image) unsigned short *sprmem; int image; { register int cnt; unsigned short *imem = sprimages[image]; sprmem += 2; for (cnt = 0; cnt < IMAGEHEIGHT; cnt++) { *sprmem++ = *imem << 1; *sprmem++ = *imem++; } *sprmem++ = 0; *sprmem++ = 0; } /* Applies the given mask to the image. */ void DissolveSprite (sprmem, dissolvemask) unsigned short *sprmem, dissolvemask; { register int cnt; sprmem += 2; for (cnt = 0; cnt < IMAGEHEIGHT+IMAGEHEIGHT; cnt++) *sprmem++ &= dissolvemask; } /* Obtains and initializes the specified sprite. */ int InitSprite (spr, sprnum) struct sprrec *spr; int sprnum; { if ((GetSprite (&(spr->actualsprite), (long)sprnum) != -1) && ((spr->sprmem = AllocMem ((long)((IMAGEHEIGHT*2+4)*2), MEMF_CHIP | MEMF_CLEAR)) != NULL)) return (1); else return (0); } /* Gives the sprite back to the system. */ void ReleaseSprite (spr) struct sprrec *spr; { if (spr->actualsprite.num != -1) FreeSprite ((long)(spr->actualsprite.num)); if (spr->sprmem != NULL) FreeMem (spr->sprmem, (long)((IMAGEHEIGHT*2+4)*2)); } /* Makes the sprite visible/invisible... */ void ShowSprite (spr, show) struct sprrec *spr; int show; { spr->actualsprite.height = (show ? IMAGEHEIGHT : 0); ChangeSprite (NULL, &(spr->actualsprite), spr->sprmem); } /* The following SHOULD go into CHIP RAM, so link with "+cd" */ unsigned short timepointer[] = { 0x0000,0x0000, 0x0000,0xffff,0x4800,0xffff,0x634c,0xffff,0x4aae, 0xffff,0x4aa8,0xffff,0x2a26,0xffff,0x0000,0xffff, 0x0000,0x0000 }; /* Changes the mouse pointer into the "time" pointer */ void SetWarnPointer (win, show) struct Window *win; int show; { if (show) SetPointer (win, &timepointer[0], 7L, 16L, -7L, -3L); else ClearPointer (win); }