-
Notifications
You must be signed in to change notification settings - Fork 1
/
matrixscroller.cpp
119 lines (100 loc) · 3.95 KB
/
matrixscroller.cpp
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#include "matrixscroller.hpp"
struct Matrix
{
char *scrollerText = (char*)"Send codes over serial port to unlock features";
bool firstRun = true;
bool decode = false;
int linesY[60];
uint8_t lineSpeed[60];
uint8_t lineColour[60];
bool linesEnabled[60];
double jitter = 0.01f;
double maxjitter = 0.02f;
double minjitter = 0.00f;
double zoom = 0.9f;
double maxzoom = 1.0f;
double minzoom = 0.8f;
uint8_t frameCounter = 0;
int startName = -360;
int endName = 360;
int nameX = startName;
} matrixData;
bool matrixLoop(GameBuff *gameBuff)
{
if (matrixData.frameCounter==255) {
matrixData.frameCounter=0;
} else {
matrixData.frameCounter++;
}
// Initial Setup
if (matrixData.firstRun)
{
for (int i = 0; i < 60; i++)
{
matrixData.linesEnabled[i] = false;
matrixData.linesY[i] = -29 * 8;
matrixData.lineSpeed[i] = rand() % 4;
matrixData.firstRun = false;
}
}
// Input
if (gameBuff->playerKeys.debouncedInput && gameBuff->playerKeys.a && gameBuff->playerKeys.down && gameBuff->playerKeys.start)
matrixData.decode = !matrixData.decode;
if (gameBuff->playerKeys.debouncedInput && gameBuff->playerKeys.a && gameBuff->playerKeys.b)
return true;
if (gameBuff->playerKeys.debouncedInput && gameBuff->playerKeys.start && gameBuff->playerKeys.select)
return true;
// Display
displayClear(gameBuff, 0x00);
++matrixData.nameX;
if (matrixData.nameX == matrixData.endName) matrixData.nameX = matrixData.startName;
drawString2x(gameBuff,gameBuff->badgeState->name,matrixData.nameX,gameBuff->HEIGHT/16,0x6E,0);
drawScreenDouble(gameBuff);
drawScreenDouble(gameBuff);
for (int i = 0; i < 60; i++)
{
if (matrixData.linesEnabled[i])
{
char *LastChar = &matrixData.scrollerText[28];
if (matrixData.decode) {
drawString(gameBuff, matrixData.scrollerText, matrixData.linesY[i] * 8, (i % 30) * 8, matrixData.lineColour[i], 0x00);
drawString(gameBuff, LastChar, matrixData.linesY[i] * 8 + 28 * 8, (i % 30) * 8, 0xFF, 0x00);
} else {
drawPigString(gameBuff, matrixData.scrollerText, matrixData.linesY[i] * 8, (i % 30) * 8, matrixData.lineColour[i], 0x00);
drawPigString(gameBuff, LastChar, matrixData.linesY[i] * 8 + 28 * 8, (i % 30) * 8, 0xFF, 0x00);
}
// if (frameCounter % matrixData.lineSpeed[i])
matrixData.linesY[i] += matrixData.lineSpeed[i];
}
if (matrixData.linesY[i] > gameBuff->WIDTH)
{
matrixData.linesEnabled[i] = false;
}
}
// Seed Data
int random = rand() % 120;
if (random < 60)
{
if (!matrixData.linesEnabled[random])
{
matrixData.linesEnabled[random] = true;
matrixData.linesY[random] = -46 * 8;
matrixData.lineSpeed[random] = rand() % 4;
matrixData.lineColour[random] = rand() % 256;
}
}
// Mess with screen code... didn't really pan out so cool.
// Dimensions imageDim;
// imageDim.width = 240;
// imageDim.height = 240;
// imageDim.y = 0;
// imageDim.x = 0;
// matrixData.jitter += (rand()%100-50)/1000.0f;
// if (matrixData.jitter < matrixData.minjitter) matrixData.jitter = matrixData.minjitter;
// if (matrixData.jitter > matrixData.maxjitter) matrixData.jitter = matrixData.maxjitter;
// matrixData.zoom += (rand()%100-50)/1000.0f;
// if (matrixData.zoom < matrixData.minzoom) matrixData.zoom = matrixData.minzoom;
// if (matrixData.zoom > matrixData.maxzoom) matrixData.zoom = matrixData.maxzoom;
// rotateObject(gameBuff, imageDim, matrixData.jitter, matrixData.zoom, gameBuff->consoleBuffer, 0x00);
return false;
}