2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
7 * This animation code draws a picture centered on the screen
8 * and flashes a specified region once per second.
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"
28 static const UBYTE
*unpack_byterun1(const UBYTE
*source
, UBYTE
*dest
, LONG unpackedsize
)
35 c
= (BYTE
)(*source
++);
41 if (--unpackedsize
<= 0) return source
;
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
;
71 ad
->picture
= AllocVec(size
, MEMF_ANY
);
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
);
92 DOSBootBase
->animData
= ad
;
93 DOSBootBase
->delayTicks
= 25; /* We run at 2 frames per second */
96 FreeMem(ad
, sizeof(struct AnimData
));
102 void anim_Animate(struct Screen
*scr
, struct DOSBootBase
*DOSBootBase
)
104 struct AnimData
*ad
= DOSBootBase
->animData
;
106 ad
->frame
= !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);
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
;
124 FreeVec(ad
->picture
);
125 FreeMem(ad
, sizeof(struct AnimData
));
127 DOSBootBase
->animData
= NULL
;