-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLogoShow.c
103 lines (86 loc) · 2.69 KB
/
LogoShow.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/**
* Show a bitmap from flash.
*/
#include "Global.h"
#include "VGA.h"
#include "LED.h"
#include "Utils.h"
#include "Button.h"
#include "Random.h"
#include "Graphics/Bitmap.h"
#include "Graphics/Drawing.h"
#include <string.h>
#include "FullscreenBitmaps.h"
void DiagonalFadeIn(uint8_t* pixels, int t, int speedmul, int speeddiv) {
for(int32_t y = 0; y < 200; y++ ) {
for(int32_t x = 0; x < 320; x++) {
int32_t shval = -((((y<<1)-x)>>2)+((t*speedmul)/speeddiv)-((32*speedmul)/speeddiv))>>4;
shval = shval < 0 ? 0 : shval;
shval = shval > 7 ? 7 : shval;
int32_t pos = x+y*320;
pixels[pos] = data.logoshow.colourLut[pixels[pos]+shval*256];
}
}
}
void DiagonalFadeOut(uint8_t* pixels, int t, int speedmul, int speeddiv) {
for(int32_t y = 0; y < 200; y++ ) {
for(int32_t x = 0; x < 320; x++) {
int32_t shval = ((((y<<1)-x)>>2)+((t*speedmul)/speeddiv)-((32*speedmul)/speeddiv))>>4;
shval = shval < 0 ? 0 : shval;
shval = shval > 7 ? 7 : shval;
int32_t pos = x+y*320;
pixels[pos] = data.logoshow.colourLut[pixels[pos]+shval*256];
}
}
}
void LogoShow() {
uint8_t *framebuffer1=(uint8_t *)0x20000000;
uint8_t *framebuffer2=(uint8_t *)0x20010000;
Bitmap frame1,frame2;
InitializeBitmap(&frame1,320,200,320,framebuffer1);
InitializeBitmap(&frame2,320,200,320,framebuffer2);
ClearBitmap(&frame1);
ClearBitmap(&frame2);
SetVGAScreenMode320x200_60Hz(framebuffer1);
int t=0;
for(int32_t c = 0; c < 256; c++) {
for(int32_t shval = 0; shval < 8; shval++) {
data.logoshow.colourLut[c+shval*256] =
((((c & 0xE0) >> 5) - shval) < 0 ? 0 : ((((c & 0xE0) >> 5) - shval) << 5)) |
((((c & 0x1C) >> 2) - shval) < 0 ? 0 : ((((c & 0x1C) >> 2) - shval) << 2)) |
((((c & 0x03)) - (shval >> 1)) < 0 ? 0 : ((((c & 0x03)) - (shval >> 1)) ));
}
}
int32_t drawc = 0;
while(CurrentBitBinRow(songp) < 512)
{
WaitVBL();
Bitmap *currframe;
if(t&1)
{
SetFrameBuffer(framebuffer1);
currframe=&frame2;
}
else
{
SetFrameBuffer(framebuffer2);
currframe=&frame1;
drawc++;
}
DrawRLEBitmap(currframe, &Jupiter1, 0, 0);
uint8_t* pixels = currframe->pixels;
// if(t < 2000) {
if(t<190) {
DiagonalFadeIn(currframe->pixels, t-50, 2, 1);
}
else {
DiagonalFadeOut(currframe->pixels, t-355, 2, 1);
}
// }
// else {
// DiagonalFadeOut(currframe->pixels, t-500, 2, 1);
// }
t++;
}
while(UserButtonState());
}