2 * This animation code draws a picture centered on the screen
3 * and flashes a specified region once per second.
6 #include <aros/debug.h>
7 #include <intuition/screens.h>
8 #include <proto/exec.h>
9 #include <proto/graphics.h>
11 #include "dosboot_intern.h"
12 #include "nomedia_image.h"
13 #include "nomedia_anim.h"
23 static const UBYTE
*unpack_byterun1(const UBYTE
*source
, UBYTE
*dest
, LONG unpackedsize
)
30 c
= (BYTE
)(*source
++);
36 if (--unpackedsize
<= 0) return source
;
47 if (--unpackedsize
<= 0) return source
;
53 APTR
anim_Init(struct Screen
*scr
, struct DOSBootBase
*DOSBootBase
)
55 D(bug("Screen: %dx%dx%d\nImage: %dx%dx%d\n",
56 scr
->Width
, scr
->Height
, scr
->RastPort
.BitMap
->Depth
,
57 NOMEDIA_WIDTH
, NOMEDIA_HEIGHT
, NOMEDIA_PLANES
));
58 if ((scr
->Width
>= NOMEDIA_WIDTH
) && (scr
->Height
>= NOMEDIA_HEIGHT
) &&
59 (scr
->RastPort
.BitMap
->Depth
>= NOMEDIA_PLANES
))
61 struct AnimData
*ad
= AllocMem(sizeof(struct AnimData
), MEMF_ANY
);
62 ULONG size
= NOMEDIA_WIDTH
* NOMEDIA_HEIGHT
;
66 ad
->picture
= AllocVec(size
, MEMF_ANY
);
72 unpack_byterun1(nomedia_data
, ad
->picture
, size
);
74 for (i
= 0; i
< NOMEDIA_COLORS
; i
++)
75 SetRGB32(&scr
->ViewPort
, i
, (nomedia_pal
[i
] << 8) & 0xFF000000,
76 (nomedia_pal
[i
] << 16) & 0xFF000000, (nomedia_pal
[i
] << 24) & 0xFF000000);
78 SetAPen(&scr
->RastPort
, 0);
79 RectFill(&scr
->RastPort
, 0, 0, scr
->Width
, scr
->Height
);
81 ad
->x
= (scr
->Width
- NOMEDIA_WIDTH
) >> 1;
82 ad
->y
= (scr
->Height
- NOMEDIA_HEIGHT
) >> 1;
83 WriteChunkyPixels(&scr
->RastPort
, ad
->x
, ad
->y
, ad
->x
+ NOMEDIA_WIDTH
- 1, ad
->y
+ NOMEDIA_HEIGHT
- 1,
84 ad
->picture
, NOMEDIA_WIDTH
);
87 DOSBootBase
->animData
= ad
;
88 DOSBootBase
->delayTicks
= 25; /* We run at 2 frames per second */
91 FreeMem(ad
, sizeof(struct AnimData
));
97 void anim_Animate(struct Screen
*scr
, struct DOSBootBase
*DOSBootBase
)
99 struct AnimData
*ad
= DOSBootBase
->animData
;
101 ad
->frame
= !ad
->frame
;
103 RectFill(&scr
->RastPort
, ad
->x
+ FLASH_X
, ad
->y
+ FLASH_Y
,
104 ad
->x
+ FLASH_X
+ FLASH_WIDTH
- 1, ad
->y
+ FLASH_Y
+ FLASH_HEIGHT
- 1);
107 WriteChunkyPixels(&scr
->RastPort
, ad
->x
+ FLASH_X
, ad
->y
+ FLASH_Y
,
108 ad
->x
+ FLASH_X
+ FLASH_WIDTH
- 1, ad
->y
+ FLASH_Y
+ FLASH_HEIGHT
- 1,
109 ad
->picture
+ FLASH_X
, NOMEDIA_WIDTH
);
113 void anim_Stop(struct DOSBootBase
*DOSBootBase
)
115 struct AnimData
*ad
= DOSBootBase
->animData
;
119 FreeVec(ad
->picture
);
120 FreeMem(ad
, sizeof(struct AnimData
));
122 DOSBootBase
->animData
= NULL
;