Added a test for MUIA_Listview_SelectChange.
[AROS.git] / rom / dosboot / bootanim.c
blob79b6a3bf9e49167c8372252b8804000474c00b54
1 /*
2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 /*
7 * This animation code draws a picture centered on the screen
8 * and flashes a specified region once per second.
9 */
11 #include <aros/debug.h>
12 #include <intuition/screens.h>
13 #include <proto/exec.h>
14 #include <proto/graphics.h>
16 #include "dosboot_intern.h"
17 #include "nomedia_image.h"
18 #include "nomedia_anim.h"
20 struct AnimData
22 UBYTE *picture;
23 UBYTE frame;
24 UWORD x;
25 UWORD y;
28 static const UBYTE *unpack_byterun1(const UBYTE *source, UBYTE *dest, LONG unpackedsize)
30 UBYTE r;
31 BYTE c;
33 for(;;)
35 c = (BYTE)(*source++);
36 if (c >= 0)
38 while(c-- >= 0)
40 *dest++ = *source++;
41 if (--unpackedsize <= 0) return source;
44 else if (c != -128)
46 c = -c;
47 r = *source++;
49 while(c-- >= 0)
51 *dest++ = r;
52 if (--unpackedsize <= 0) return source;
58 APTR anim_Init(struct Screen *scr, struct DOSBootBase *DOSBootBase)
60 D(bug("Screen: %dx%dx%d\nImage: %dx%dx%d\n",
61 scr->Width, scr->Height, scr->RastPort.BitMap->Depth,
62 NOMEDIA_WIDTH, NOMEDIA_HEIGHT, NOMEDIA_PLANES));
63 if ((scr->Width >= NOMEDIA_WIDTH) && (scr->Height >= NOMEDIA_HEIGHT) &&
64 (scr->RastPort.BitMap->Depth >= NOMEDIA_PLANES))
66 struct AnimData *ad = AllocMem(sizeof(struct AnimData), MEMF_ANY);
67 ULONG size = NOMEDIA_WIDTH * NOMEDIA_HEIGHT;
69 if (ad)
71 ad->picture = AllocVec(size, MEMF_ANY);
73 if (ad->picture)
75 ULONG i;
77 unpack_byterun1(nomedia_data, ad->picture, size);
79 for (i = 0; i < NOMEDIA_COLORS; i++)
80 SetRGB32(&scr->ViewPort, i, (nomedia_pal[i] << 8) & 0xFF000000,
81 (nomedia_pal[i] << 16) & 0xFF000000, (nomedia_pal[i] << 24) & 0xFF000000);
83 SetAPen(&scr->RastPort, 0);
84 RectFill(&scr->RastPort, 0, 0, scr->Width, scr->Height);
86 ad->x = (scr->Width - NOMEDIA_WIDTH ) >> 1;
87 ad->y = (scr->Height - NOMEDIA_HEIGHT) >> 1;
88 WriteChunkyPixels(&scr->RastPort, ad->x, ad->y, ad->x + NOMEDIA_WIDTH - 1, ad->y + NOMEDIA_HEIGHT - 1,
89 ad->picture, NOMEDIA_WIDTH);
91 ad->frame = 0;
92 DOSBootBase->animData = ad;
93 DOSBootBase->delayTicks = 25; /* We run at 2 frames per second */
94 return ad;
96 FreeMem(ad, sizeof(struct AnimData));
99 return NULL;
102 void anim_Animate(struct Screen *scr, struct DOSBootBase *DOSBootBase)
104 struct AnimData *ad = DOSBootBase->animData;
106 ad->frame = !ad->frame;
107 if (ad->frame)
108 RectFill(&scr->RastPort, ad->x + FLASH_X, ad->y + FLASH_Y,
109 ad->x + FLASH_X + FLASH_WIDTH - 1, ad->y + FLASH_Y + FLASH_HEIGHT - 1);
110 else
112 WriteChunkyPixels(&scr->RastPort, ad->x + FLASH_X, ad->y + FLASH_Y,
113 ad->x + FLASH_X + FLASH_WIDTH - 1, ad->y + FLASH_Y + FLASH_HEIGHT - 1,
114 ad->picture + FLASH_X, NOMEDIA_WIDTH);
118 void anim_Stop(struct DOSBootBase *DOSBootBase)
120 struct AnimData *ad = DOSBootBase->animData;
122 if (ad)
124 FreeVec(ad->picture);
125 FreeMem(ad, sizeof(struct AnimData));
127 DOSBootBase->animData = NULL;