-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtitlescreen.h
234 lines (169 loc) · 7.25 KB
/
titlescreen.h
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
void renderTitleScreen(){
if(mustDrawTitleScreen==true) {
mustDrawTitleScreen = false;
startSong("/joe2/flute.pcm");
Pokitto::Display::setTASRowMask(0b0000'00000000'00000000);
File tsFile;
// titlescreen.bmp MUST be 8bit and upside down. Ther is no error checking!
if(tsFile.openRO("/joe2/titlescreen.bmp")){
tsFile.seek(54); // skip all data checking, if the bmp is wrong, we get a garbled mess
uint8_t RGBA[256*4];
tsFile.read(RGBA, 256*4);
for(int t=0; t<256; t++){
// convert 888 to 565 for reloading
uint8_t R5 = (( (int)RGBA[2+(t*4)] * 249 + 1014 ) >> 11)&31;
uint8_t G6 = (( (int)RGBA[1+(t*4)] * 253 + 505 ) >> 10)&63;
uint8_t B5 = (( (int)RGBA[0+(t*4)] * 249 + 1014 ) >> 11)&31;
gamePalette.rgb[t] = (R5<<11)|(G6<<5)|B5;
}
Pokitto::Display::load565Palette(gamePalette.rgb);
uint8_t buff[220];
Pokitto::lcdPrepareRefresh();
for(int y=0; y<176; y++){
tsFile.read(buff, 220);
flushLine(Pokitto::Display::palette, buff);
}
tsFile.close();
Pokitto::Display::update(); // needed?
}
}
}
void titleScreen(){
renderTitleScreen();
if(_A_But[NEW]){
reSaturate(0,0,0);
gameMode=1;
playingMusic1 = false;
loadLevel(1);
//if(++levelNumber==3)levelNumber=1;
playingMusic1 = true;
Pokitto::Display::lineFillers[0] = myBGFiller; // map layer
Pokitto::Display::lineFillers[1] = myBGFiller2; // background map layer
Pokitto::Display::lineFillers[2] = spriteFill; // sprite layer
Pokitto::Display::setTASRowMask(0b1111'11111111'11111111);
// a little 'wide-screening' to remove some lines for higher frame rate
bg.screenTop = 20;
bg.screenBottom = 176-bg.screenTop;
bg.screenHeight = bg.screenBottom-bg.screenTop;
mustDrawTitleScreen=true;
titleTimer=0;
startSong("/joe2/C_6000.pcm");
player.numLives = maxLives;
playerDying = 0;
}
}
void gameOverScreen(){
if(mustDrawTitleScreen==true) {
mustDrawTitleScreen = false;
Pokitto::Display::setTASRowMask(0b0000'00000000'00000000);
File tsFile;
// titlescreen.bmp MUST be 8bit and upside down. Ther is no error checking!
if(tsFile.openRO("/joe2/gameoverscreen.bmp")){
tsFile.seek(54); // skip all data checking, if the bmp is wrong, we get a garbled mess
uint8_t RGBA[256*4];
tsFile.read(RGBA, 256*4);
for(int t=0; t<256; t++){
// convert 888 to 565 for reloading
uint8_t R5 = (( (int)RGBA[2+(t*4)] * 249 + 1014 ) >> 11)&31;
uint8_t G6 = (( (int)RGBA[1+(t*4)] * 253 + 505 ) >> 10)&63;
uint8_t B5 = (( (int)RGBA[0+(t*4)] * 249 + 1014 ) >> 11)&31;
gamePalette.rgb[t] = (R5<<11)|(G6<<5)|B5;
}
Pokitto::Display::load565Palette(gamePalette.rgb);
uint8_t buff[220];
Pokitto::lcdPrepareRefresh();
for(int y=0; y<176; y++){
tsFile.read(buff, 220);
flushLine(Pokitto::Display::palette, buff);
}
tsFile.close();
Pokitto::Display::update(); // needed?
}
}
if(_A_But[NEW]){
mustDrawTitleScreen = true;
gameMode=0;
}
}
/*
void titleScreenOld(){
if(Pokitto::Core::getTime() > titleTimer+6000){
//titleTimer = Pokitto::Core::getTime();
if(titleScratch==0){
titleScratch=1;
// startSong("/joe2/scratch.pcm");
}
}
if(Pokitto::Core::getTime() > titleTimer+8000 && mustDrawTitleScreen==true){
// startSong("/joe2/C_6000.pcm");
//titleTimer = Pokitto::Core::getTime();
// if(mustDrawTitleScreen==true) {
mustDrawTitleScreen = false;
Pokitto::Display::setTASRowMask(0b0000'00000000'00000000);
File tsFile;
// titlescreen.bmp MUST be 8bit and upside down. Ther is no error checking!
if(tsFile.openRO("/joe2/titlescreen.bmp")){
tsFile.seek(54); // skip all data checking, if the bmp is wrong, we get a garbled mess
uint8_t RGBA[256*4];
tsFile.read(RGBA, 256*4);
for(int t=0; t<256; t++){
// convert 888 to 565 for reloading
uint8_t R5 = (( (int)RGBA[2+(t*4)] * 249 + 1014 ) >> 11)&31;
uint8_t G6 = (( (int)RGBA[1+(t*4)] * 253 + 505 ) >> 10)&63;
uint8_t B5 = (( (int)RGBA[0+(t*4)] * 249 + 1014 ) >> 11)&31;
gamePalette.rgb[t] = (R5<<11)|(G6<<5)|B5;
}
Pokitto::Display::load565Palette(gamePalette.rgb);
uint8_t buff[220];
Pokitto::lcdPrepareRefresh();
int mainData = 1024+54; // main bitmap data in file
int rollSize = sizeof(titleRoll);
for(int y=0; y<176; y++){
titleLine[y] = y;
}
int tempTime=Pokitto::Core::getTime();
for(int top=176+rollSize; top>=-(rollSize+3); top-=1){
for(int t=top; t<top+rollSize-1; t++){
int p = t+titleRoll[t-top];
if(p>=176) p-=176;
int s = top-(t-top);
if(s >0 && s <176)
titleLine[s] = p;
}
for(int y=top-rollSize+2; y<top; y++){
Pokitto::setDRAMpoint(0, y); SET_MASK_P2;
if(y>=0 && y<176){
tsFile.seek(mainData+(220*titleLine[y]));
tsFile.read(buff, 220);
flushLine(Pokitto::Display::palette, buff);
}
}
Pokitto::Display::update(); // needed?
// updateStream(); // keep the sound going
}
}
}
if(_A_But[NEW]){
reSaturate(0,0,0);
gameMode=1;
// playingMusic1 = false;
loadLevel(1);
// playingMusic1 = true;
Pokitto::Display::lineFillers[0] = myBGFiller; // map layer
Pokitto::Display::lineFillers[1] = myBGFiller2; // background map layer
Pokitto::Display::lineFillers[2] = spriteFill; // sprite layer
// clear screen to black
//for(int y=0; y<176; y++){
// flushLine(emptyPalette, blankLine);
//}
Pokitto::Display::setTASRowMask(0b1111'11111111'11111111);
// a little 'wide-screening' to remove some lines for higher frame rate
bg.screenTop=20;
bg.screenBottom=176-20;
bg.screenHeight = bg.screenBottom-bg.screenTop;
mustDrawTitleScreen=true;
titleTimer=0;
// startSong("/joe2/C_6000.pcm");
}
}
*/