Debian Codegraph @

src/gui/tutorial.cpp

raw
1 /**
2 * Furnace Tracker - multi-system chiptune tracker
3 * Copyright (C) 2021-2025 tildearrow and contributors
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
20 #include "gui.h"
21 #include "../ta-log.h"
22 #include "IconsFontAwesome4.h"
23 #include "imgui_internal.h"
24
25 #include "gif_load.h"
26
27 #ifdef _WIN32
28 #include <windows.h>
29 #include "../utfutils.h"
30 #else
31 #include <dirent.h>
32 #endif
33
34 #ifndef IS_MOBILE
35 #define CLICK_TO_OPEN(t) ImGui::TextColored(uiColors[GUI_COLOR_ACCENT_PRIMARY],t); \
36 if (ImGui::IsItemHovered()) { \
37 ImGui::SetTooltip("click to open"); \
38 ImGui::SetMouseCursor(ImGuiMouseCursor_Hand); \
39 if (ImGui::IsMouseReleased(ImGuiMouseButton_Left)) { \
40 SDL_OpenURL(t); \
41 } \
42 } \
43 ImGui::SameLine(); \
44 ImGui::Text(ICON_FA_CLIPBOARD); \
45 if (ImGui::IsItemHovered(ImGuiHoveredFlags_DelayShort)) ImGui::SetTooltip("click to copy"); \
46 if (ImGui::IsItemClicked()) { \
47 ImGui::SetClipboardText(t); \
48 tutorial.popupTimer=0; \
49 }
50 #else
51 #define CLICK_TO_OPEN(t) ImGui::TextColored(uiColors[GUI_COLOR_ACCENT_PRIMARY],t); if (ImGui::IsItemClicked()) SDL_OpenURL(t);
52 #endif
53
54 enum FurnaceCVObjectTypes {
55 CV_NULL=0,
56 CV_PLAYER,
57 CV_BULLET,
58 CV_ENEMY_BULLET,
59 CV_BOMB,
60 CV_ENEMY_BOMB,
61 CV_EXPLOSION,
62 CV_ENEMY,
63 CV_PLANE,
64 CV_FURBALL,
65 CV_MINE,
66 CV_POWERUP_P,
67 CV_POWERUP_S,
68 CV_SPECIAL,
69 CV_MOD_I,
70 CV_MOD_S,
71 CV_EXTRA_LIFE
72 };
73
74 struct FurnaceCVObject {
75 FurnaceCV* cv;
76 unsigned short type;
77 unsigned short spriteDef[512];
78 unsigned char spriteWidth, spriteHeight;
79 bool dead;
80 short x, y;
81 unsigned char z, prio;
82 short collX0, collX1, collY0, collY1;
83 short frozen;
84
85 virtual void collision(FurnaceCVObject* other);
86 virtual void tick();
87 FurnaceCVObject(FurnaceCV* p):
88 cv(p),
89 type(0),
90 spriteWidth(2),
91 spriteHeight(2),
92 dead(false),
93 x(0),
94 y(0),
95 z(0),
96 prio(1),
97 collX0(0),
98 collX1(15),
99 collY0(0),
100 collY1(15),
101 frozen(0) {
102 memset(spriteDef,0,512*sizeof(unsigned short));
103 spriteDef[0]=4;
104 spriteDef[1]=5;
105 spriteDef[2]=36;
106 spriteDef[3]=37;
107 }
108 virtual ~FurnaceCVObject() {
109 }
110 };
111
112 void FurnaceCVObject::collision(FurnaceCVObject* other) {
113 }
114
115 void FurnaceCVObject::tick() {
116 }
117
118 // special types:
119 // - 0: nothing
120 // - 1: "?" one of the following:
121 // - 10/30: spawn more enemies
122 // - 4/30: downgrades enemies
123 // - 3/30: teleports you
124 // - 3/30: stops all enemies (momentarily)
125 // - 3/30: grants speed and invincible status
126 // - 2/30: spawn purple tanks
127 // - 2/30: spawn vortices
128 // - 1/30: skip to next level
129 // - 1/30: 5-up
130 // - 1/30: call planes
131 // - 2: "T" teleports you
132 // - 3: "X" ripple shot
133 // - 4: "W" bidirectional shots (until next round)
134 // - 5: "S" stops all enemies for 10 seconds
135
136 struct FurnaceCV {
137 SDL_Surface* surface;
138 unsigned char* prioBuf;
139 DivEngine* e;
140 unsigned char* tileData;
141 unsigned int tick;
142
143 // state
144 unsigned short* curStage;
145 int stageWidth, stageHeight;
146 int stageWidthPx, stageHeightPx;
147
148 const char* typeAddr;
149 unsigned char typeDelay;
150 int typeX, typeY;
151 int typeXStart, typeYStart;
152 int typeXEnd, typeYEnd;
153
154 int textWait, curText, transWait;
155 int ticksToInit;
156
157 bool inGame, inTransition, newHiScore, playSongs, pleaseInitSongs, gameOver;
158 unsigned char lives, respawnTime, stage, shotType, lifeBank, specialType;
159 int score;
160 int hiScore;
161 short lastPlayerX, lastPlayerY;
162 short fxChanBase, fxInsBase;
163 short speedTicks;
164 short planeTime;
165 float origSongRate;
166
167 FixedQueue<unsigned char,16> weaponStack;
168
169 // graphics
170 unsigned short tile0[56][80];
171 unsigned short tile1[56][80];
172 unsigned short scrollX[2];
173 unsigned short scrollY[2];
174 unsigned char bgColor;
175 std::vector<FurnaceCVObject*> sprite;
176 // this offset is applied to sprites.
177 int viewX, viewY;
178
179 // input
180 unsigned char joyInputPrev;
181 unsigned char joyPressed;
182 unsigned char joyReleased;
183 unsigned char joyInput;
184
185 template<typename T> T* createObject(short x=0, short y=0);
186 template<typename T> T* createObjectNoPos();
187 void buildStage(int which);
188
189 void putText(int fontBase, bool fontHeight, String text, int x, int y);
190
191 void startTyping(const char* text, int x, int y);
192
193 void soundEffect(int ins, int chan, int note);
194 void stopSoundEffect(int ins, int chan, int note);
195
196 void addScore(int amount);
197
198 void typeTick();
199
200 void rasterH(int scanline);
201 void render(unsigned char joyIn);
202 void tileDataRead(struct GIF_WHDR* data);
203 void loadInstruments();
204 bool init(DivEngine* eng);
205 void unload();
206
207 FurnaceCV():
208 surface(NULL),
209 e(NULL),
210 tileData(NULL),
211 tick(0),
212 curStage(NULL),
213 stageWidth(40),
214 stageHeight(28),
215 stageWidthPx(320),
216 stageHeightPx(224),
217 typeAddr(NULL),
218 typeDelay(0),
219 typeX(0),
220 typeY(0),
221 typeXStart(0),
222 typeYStart(0),
223 typeXEnd(39),
224 typeYEnd(27),
225 textWait(60),
226 curText(0),
227 transWait(0),
228 ticksToInit(2),
229 inGame(false),
230 inTransition(false),
231 newHiScore(false),
232 playSongs(true),
233 pleaseInitSongs(false),
234 gameOver(false),
235 lives(5),
236 respawnTime(0),
237 stage(0),
238 shotType(0),
239 lifeBank(0),
240 specialType(0),
241 score(0),
242 hiScore(25000),
243 lastPlayerX(0),
244 lastPlayerY(0),
245 fxChanBase(-1),
246 fxInsBase(-1),
247 speedTicks(0),
248 planeTime(0),
249 origSongRate(60.0f),
250 bgColor(0),
251 viewX(0),
252 viewY(0),
253 joyInputPrev(0),
254 joyPressed(0),
255 joyReleased(0),
256 joyInput(0) {
257 memset(tile0,0,80*56*sizeof(short));
258 memset(tile1,0,80*56*sizeof(short));
259
260 scrollX[0]=0;
261 scrollX[1]=0;
262 scrollY[0]=0;
263 scrollY[1]=0;
264 }
265 };
266
267 struct FurnaceCVPlayer: FurnaceCVObject {
268 short subX, subY;
269 short speedX, speedY;
270 unsigned char shootDir;
271 unsigned char animFrame;
272 short invincible;
273 unsigned char shotTimer;
274 bool doubleShot;
275
276 void collision(FurnaceCVObject* other);
277 void tick();
278 FurnaceCVPlayer(FurnaceCV* p):
279 FurnaceCVObject(p),
280 subX(0),
281 subY(0),
282 speedX(0),
283 speedY(0),
284 shootDir(2),
285 animFrame(0),
286 invincible(120),
287 shotTimer(4),
288 doubleShot(false) {
289 type=CV_PLAYER;
290 spriteWidth=3;
291 spriteHeight=3;
292 spriteDef[0]=0x10;
293 spriteDef[1]=0x11;
294 spriteDef[2]=0x12;
295 spriteDef[3]=0x30;
296 spriteDef[4]=0x31;
297 spriteDef[5]=0x32;
298 spriteDef[6]=0x50;
299 spriteDef[7]=0x51;
300 spriteDef[8]=0x52;
301 collX0=0;
302 collX1=23;
303 collY0=0;
304 collY1=23;
305 }
306 };
307
308 struct FurnaceCVBullet: FurnaceCVObject {
309 short subX, subY;
310 short speedX, speedY;
311 unsigned char bulletType, orient, life;
312
313 void killBullet();
314 void setType(unsigned char t);
315 void collision(FurnaceCVObject* other);
316 void tick();
317 FurnaceCVBullet(FurnaceCV* p):
318 FurnaceCVObject(p),
319 subX(0),
320 subY(0),
321 speedX(0),
322 speedY(0),
323 bulletType(0),
324 orient(0),
325 life(0) {
326 type=CV_BULLET;
327 spriteWidth=1;
328 spriteHeight=1;
329 spriteDef[0]=6;
330 collX0=2;
331 collX1=5;
332 collY0=2;
333 collY1=5;
334 }
335 };
336
337 struct FurnaceCVEnemyBullet: FurnaceCVObject {
338 short subX, subY;
339 short speedX, speedY;
340 unsigned char animFrame, bulletType;
341
342 void setType(unsigned char type);
343 void tick();
344 FurnaceCVEnemyBullet(FurnaceCV* p):
345 FurnaceCVObject(p),
346 subX(0),
347 subY(0),
348 speedX(0),
349 speedY(0),
350 animFrame(rand()&0xff),
351 bulletType(0) {
352 type=CV_ENEMY_BULLET;
353 spriteWidth=1;
354 spriteHeight=1;
355 spriteDef[0]=6;
356 collX0=2;
357 collX1=5;
358 collY0=2;
359 collY1=5;
360 }
361 };
362
363 struct FurnaceCVEnemy: FurnaceCVObject {
364 unsigned char enemyType;
365 unsigned char health;
366 unsigned char stopped;
367
368 void setType(unsigned char type);
369 FurnaceCVEnemy(FurnaceCV* p):
370 FurnaceCVObject(p),
371 enemyType(0),
372 health(1),
373 stopped(0) {
374 type=CV_ENEMY;
375 }
376 };
377
378 struct FurnaceCVEnemy1: FurnaceCVEnemy {
379 unsigned char orient;
380 unsigned char animFrame;
381 short nextTime, shootTime;
382 unsigned char shootCooldown;
383 short orientCount;
384
385 void collision(FurnaceCVObject* other);
386
387 void tick();
388 FurnaceCVEnemy1(FurnaceCV* p):
389 FurnaceCVEnemy(p),
390 orient(rand()&3),
391 animFrame(0),
392 nextTime(64+(rand()%600)),
393 shootTime(8),
394 shootCooldown(0),
395 orientCount(0) {
396 type=CV_ENEMY;
397 spriteDef[0]=0x200;
398 spriteDef[1]=0x201;
399 spriteDef[2]=0x220;
400 spriteDef[3]=0x221;
401 }
402 };
403
404 struct FurnaceCVEnemyVortex: FurnaceCVEnemy {
405 unsigned char animFrame;
406 short nextTime, shootTime, speedX, speedY;
407
408 void collision(FurnaceCVObject* other);
409
410 void tick();
411 FurnaceCVEnemyVortex(FurnaceCV* p):
412 FurnaceCVEnemy(p),
413 animFrame(0),
414 nextTime(4+(rand()%140)),
415 shootTime(360),
416 speedX((rand()%5)-2),
417 speedY((rand()%5)-2) {
418 type=CV_ENEMY;
419 prio=2;
420 spriteDef[0]=0x480;
421 spriteDef[1]=0x481;
422 spriteDef[2]=0x4a0;
423 spriteDef[3]=0x4a1;
424 }
425 };
426
427 struct FurnaceCVEnemyPlane: FurnaceCVObject {
428 unsigned char orient;
429 short shootTime, speed;
430 bool notifyPlayer;
431
432 void collision(FurnaceCVObject* other);
433
434 void tick();
435 FurnaceCVEnemyPlane(FurnaceCV* p):
436 FurnaceCVObject(p),
437 orient(rand()&3),
438 shootTime(40),
439 speed(3),
440 notifyPlayer(true) {
441 type=CV_PLANE;
442 speed=2+(p->stage>>2)+(rand()%3);
443 prio=3;
444 if (speed>8) speed=8;
445 switch (orient) {
446 case 0: case 2:
447 spriteWidth=8;
448 spriteHeight=5;
449 break;
450 case 1: case 3:
451 spriteWidth=5;
452 spriteHeight=8;
453 break;
454 }
455
456 switch (orient) {
457 case 0:
458 for (int i=0; i<40; i++) {
459 spriteDef[i]=0x4c0+(i&7)+((i>>3)<<5);
460 }
461 x=-80;
462 y=rand()%(p->stageHeightPx-80);
463 break;
464 case 1:
465 for (int i=0; i<40; i++) {
466 spriteDef[i]=0x4d7+(i%5)+((i/5)<<5);
467 }
468 x=rand()%(p->stageWidthPx-80);
469 y=p->stageHeightPx+16;
470 break;
471 case 2:
472 for (int i=0; i<40; i++) {
473 spriteDef[i]=0x4c9+(i&7)+((i>>3)<<5);
474 }
475 x=p->stageWidthPx+16;
476 y=rand()%(p->stageHeightPx-80);
477 break;
478 case 3:
479 for (int i=0; i<40; i++) {
480 spriteDef[i]=0x4d2+(i%5)+((i/5)<<5);
481 }
482 x=rand()%(p->stageWidthPx-80);
483 y=-80;
484 break;
485 }
486 }
487 };
488
489 struct FurnaceCVExplTiny: FurnaceCVObject {
490 unsigned char animFrame;
491
492 void tick();
493 FurnaceCVExplTiny(FurnaceCV* p):
494 FurnaceCVObject(p),
495 animFrame(0) {
496 type=CV_EXPLOSION;
497 spriteWidth=1;
498 spriteHeight=1;
499 spriteDef[0]=8;
500 }
501 };
502
503 struct FurnaceCVExplMedium: FurnaceCVObject {
504 unsigned char animFrame;
505
506 void tick();
507 FurnaceCVExplMedium(FurnaceCV* p):
508 FurnaceCVObject(p),
509 animFrame(0) {
510 type=CV_EXPLOSION;
511 spriteWidth=3;
512 spriteHeight=3;
513 spriteDef[0]=0x210;
514 spriteDef[1]=0x211;
515 spriteDef[2]=0x212;
516 spriteDef[3]=0x230;
517 spriteDef[4]=0x231;
518 spriteDef[5]=0x232;
519 spriteDef[6]=0x250;
520 spriteDef[7]=0x251;
521 spriteDef[8]=0x252;
522 }
523 };
524
525 struct FurnaceCVFurBallMedium: FurnaceCVObject {
526 unsigned char animFrame;
527
528 void tick();
529 FurnaceCVFurBallMedium(FurnaceCV* p):
530 FurnaceCVObject(p),
531 animFrame(0) {
532 type=CV_FURBALL;
533 spriteWidth=3;
534 spriteHeight=3;
535 spriteDef[0]=0x410;
536 spriteDef[1]=0x411;
537 spriteDef[2]=0x412;
538 spriteDef[3]=0x430;
539 spriteDef[4]=0x431;
540 spriteDef[5]=0x432;
541 spriteDef[6]=0x450;
542 spriteDef[7]=0x451;
543 spriteDef[8]=0x452;
544 }
545 };
546
547 struct FurnaceCVFurBallLarge: FurnaceCVObject {
548 unsigned char animFrame;
549
550 void tick();
551 FurnaceCVFurBallLarge(FurnaceCV* p):
552 FurnaceCVObject(p),
553 animFrame(0) {
554 type=CV_FURBALL;
555 spriteWidth=4;
556 spriteHeight=4;
557 spriteDef[0]=0x390;
558 spriteDef[1]=0x391;
559 spriteDef[2]=0x392;
560 spriteDef[3]=0x393;
561 spriteDef[4]=0x3b0;
562 spriteDef[5]=0x3b1;
563 spriteDef[6]=0x3b2;
564 spriteDef[7]=0x3b3;
565 spriteDef[8]=0x3d0;
566 spriteDef[9]=0x3d1;
567 spriteDef[10]=0x3d2;
568 spriteDef[11]=0x3d3;
569 spriteDef[12]=0x3f0;
570 spriteDef[13]=0x3f1;
571 spriteDef[14]=0x3f2;
572 spriteDef[15]=0x3f3;
573 }
574 };
575
576 struct FurnaceCVMine: FurnaceCVObject {
577 void collision(FurnaceCVObject* other);
578 FurnaceCVMine(FurnaceCV* p):
579 FurnaceCVObject(p) {
580 type=CV_MINE;
581 }
582 };
583
584 struct FurnaceCVPowerupP: FurnaceCVObject {
585 unsigned char life;
586 void collision(FurnaceCVObject* other);
587 void tick();
588 FurnaceCVPowerupP(FurnaceCV* p):
589 FurnaceCVObject(p),
590 life(255) {
591 type=CV_POWERUP_P;
592 }
593 };
594
595 struct FurnaceCVPowerupS: FurnaceCVObject {
596 unsigned char life;
597 void collision(FurnaceCVObject* other);
598 void tick();
599 FurnaceCVPowerupS(FurnaceCV* p):
600 FurnaceCVObject(p),
601 life(255) {
602 type=CV_POWERUP_S;
603 }
604 };
605
606 struct FurnaceCVSpecial: FurnaceCVObject {
607 unsigned char life;
608 unsigned char specialType;
609 void collision(FurnaceCVObject* other);
610 void tick();
611 FurnaceCVSpecial(FurnaceCV* p):
612 FurnaceCVObject(p),
613 life(255) {
614 type=CV_SPECIAL;
615 specialType=1+(rand()%5);
616 }
617 };
618
619 struct FurnaceCVModI: FurnaceCVObject {
620 unsigned char life;
621 void collision(FurnaceCVObject* other);
622 void tick();
623 FurnaceCVModI(FurnaceCV* p):
624 FurnaceCVObject(p),
625 life(255) {
626 type=CV_MOD_I;
627 }
628 };
629
630 struct FurnaceCVModS: FurnaceCVObject {
631 unsigned char life;
632 void collision(FurnaceCVObject* other);
633 void tick();
634 FurnaceCVModS(FurnaceCV* p):
635 FurnaceCVObject(p),
636 life(255) {
637 type=CV_MOD_S;
638 }
639 };
640
641 struct FurnaceCVExtraLife: FurnaceCVObject {
642 unsigned char life;
643 void collision(FurnaceCVObject* other);
644 void tick();
645 FurnaceCVExtraLife(FurnaceCV* p):
646 FurnaceCVObject(p),
647 life(255) {
648 type=CV_EXTRA_LIFE;
649 }
650 };
651
652 static const char* cvText[]={
653 // intro
654 _N("Play demo songs?\n"
655 "- Down: Play current song\n"
656 "- Up: Play demo songs"),
657
658 _N("Welcome to Combat Vehicle!\n\n"
659 "Controls:\n"
660 "X - Shoot Arrow Key - Move\n"
661 "Z - Special Esc - Quit"),
662
663 _N("GAME OVER"),
664
665 _N("High Score!"),
666
667 _N("Welcome to Combat Vehicle!\n\n"
668 "Controls:\n"
669 "B - Shoot D-Pad - Move\n"
670 "A - Special"),
671 };
672
673 void FurnaceGUI::syncTutorial() {
674 #ifdef SUPPORT_XP
675 tutorial.introPlayed=e->getConfBool("tutIntroPlayed",true);
676 #else
677 tutorial.introPlayed=e->getConfBool("tutIntroPlayed",false);
678 #endif
679 tutorial.protoWelcome=e->getConfBool("tutProtoWelcome2",false);
680 tutorial.importedMOD=e->getConfBool("tutImportedMOD",false);
681 tutorial.importedS3M=e->getConfBool("tutImportedS3M",false);
682 tutorial.importedXM=e->getConfBool("tutImportedXM",false);
683 tutorial.importedIT=e->getConfBool("tutImportedIT",false);
684 }
685
686 void FurnaceGUI::commitTutorial() {
687 e->setConf("tutIntroPlayed",tutorial.introPlayed);
688 e->setConf("tutProtoWelcome2",tutorial.protoWelcome);
689 e->setConf("tutImportedMOD",tutorial.importedMOD);
690 e->setConf("tutImportedS3M",tutorial.importedS3M);
691 e->setConf("tutImportedXM",tutorial.importedXM);
692 e->setConf("tutImportedIT",tutorial.importedIT);
693 }
694
695 void FurnaceGUI::initRandomDemoSong() {
696 std::vector<String> subDirs;
697 #if !defined(IS_MOBILE) && defined(FURNACE_DATADIR) && defined(SHOW_OPEN_ASSETS_MENU_ENTRY)
698 String demoPath=FURNACE_DATADIR;
699 demoPath+=DIR_SEPARATOR_STR;
700 demoPath+="demos";
701 #else
702 #ifdef IS_MOBILE
703 String demoPath="/storage/emulated/0/demos";
704 #else
705 String demoPath="demos";
706 #endif
707 #endif
708
709 logW("searching for demos in %s...",demoPath);
710
711 #ifdef _WIN32
712 WIN32_FIND_DATAW de;
713 String realDemoPath=demoPath;
714 realDemoPath+=DIR_SEPARATOR_STR;
715 realDemoPath+="*";
716 HANDLE d=FindFirstFileW(utf8To16(realDemoPath.c_str()).c_str(),&de);
717 if (d==INVALID_HANDLE_VALUE) {
718 realDemoPath="..";
719 realDemoPath+=DIR_SEPARATOR_STR;
720 realDemoPath+="demos";
721 realDemoPath+=DIR_SEPARATOR_STR;
722 realDemoPath+="*";
723 logW("OH NO");
724 HANDLE d=FindFirstFileW(utf8To16(realDemoPath.c_str()).c_str(),&de);
725 if (d==INVALID_HANDLE_VALUE) {
726 logW("dang it");
727 return;
728 }
729 }
730 do {
731 String u8Name=utf16To8(de.cFileName);
732 if (u8Name==".") continue;
733 if (u8Name=="..") continue;
734 if (de.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY) {
735 String newPath=demoPath;
736 newPath+=DIR_SEPARATOR_STR;
737 newPath+=u8Name;
738 logW("adding subdir %s",newPath);
739 subDirs.push_back(newPath);
740 } else if (strstr(u8Name.c_str(),".fur")!=NULL) {
741 String newPath=demoPath;
742 newPath+=DIR_SEPARATOR_STR;
743 newPath+=u8Name;
744 randomDemoSong.push_back(newPath);
745 }
746 } while (FindNextFileW(d,&de)!=0);
747 FindClose(d);
748 #else
749 DIR* d=opendir(demoPath.c_str());
750 if (d==NULL) {
751 demoPath="..";
752 demoPath+=DIR_SEPARATOR_STR;
753 demoPath+="demos";
754 logW("OH NO");
755 d=opendir(demoPath.c_str());
756 if (d==NULL) {
757 logW("dang it");
758 return;
759 }
760 }
761
762 struct dirent* de=NULL;
763 while (true) {
764 de=readdir(d);
765 if (de==NULL) break;
766 if (strcmp(de->d_name,".")==0) continue;
767 if (strcmp(de->d_name,"..")==0) continue;
768 if (de->d_type==DT_DIR) {
769 String newPath=demoPath;
770 newPath+=DIR_SEPARATOR_STR;
771 newPath+=de->d_name;
772 logW("adding subdir %s",newPath);
773 subDirs.push_back(newPath);
774 } else if (de->d_type==DT_REG && strstr(de->d_name,".fur")!=NULL) {
775 String newPath=demoPath;
776 newPath+=DIR_SEPARATOR_STR;
777 newPath+=de->d_name;
778 randomDemoSong.push_back(newPath);
779 }
780 }
781 closedir(d);
782 #endif
783
784 for (String& i: subDirs) {
785 #ifdef _WIN32
786 WIN32_FIND_DATAW de1;
787 String realI=i;
788 realI+=DIR_SEPARATOR_STR;
789 realI+="*.fur";
790 HANDLE d1=FindFirstFileW(utf8To16(realI.c_str()).c_str(),&de1);
791 if (d1==INVALID_HANDLE_VALUE) continue;
792 do {
793 String u8Name=utf16To8(de1.cFileName);
794 String newPath=i;
795 newPath+=DIR_SEPARATOR_STR;
796 newPath+=u8Name;
797 randomDemoSong.push_back(newPath);
798 } while (FindNextFileW(d1,&de1)!=0);
799 FindClose(d1);
800 #else
801 DIR* d1=opendir(i.c_str());
802 if (d1==NULL) continue;
803
804 struct dirent* de1=NULL;
805 while (true) {
806 de1=readdir(d1);
807 if (de1==NULL) break;
808 if (strcmp(de1->d_name,".")==0) continue;
809 if (strcmp(de1->d_name,"..")==0) continue;
810 if (de1->d_type==DT_REG && strstr(de1->d_name,".fur")!=NULL) {
811 String newPath=i;
812 newPath+=DIR_SEPARATOR_STR;
813 newPath+=de1->d_name;
814 randomDemoSong.push_back(newPath);
815 }
816 }
817 closedir(d1);
818 #endif
819 }
820 }
821
822 bool FurnaceGUI::loadRandomDemoSong() {
823 if (randomDemoSong.empty()) return false;
824 String which=randomDemoSong[rand()%randomDemoSong.size()];
825 logW("RDS LOAD... %s",which);
826 load(which);
827 return true;
828 }
829
830 void FurnaceGUI::drawTutorial() {
831 // welcome
832 if (!tutorial.protoWelcome) {
833 ImGui::OpenPopup("Welcome");
834 }
835 if (ImGui::BeginPopupModal("Welcome",NULL,ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoMove|ImGuiWindowFlags_NoTitleBar)) {
836 ImGui::PushFont(bigFont);
837 ImGui::SetCursorPosX((ImGui::GetContentRegionAvail().x-ImGui::CalcTextSize("Welcome!").x)*0.5);
838 ImGui::Text(_("Welcome!"));
839 ImGui::PopFont();
840
841 ImGui::Text(_("welcome to Furnace, the biggest open-source chiptune tracker!"));
842
843 ImGui::Separator();
844
845 ImGui::TextWrapped(_("here are some tips to get you started:"));
846
847 ImGui::TextWrapped(_(
848 "- add an instrument by clicking on + in Instruments\n"
849 "- click on the pattern view to focus it\n"
850 "- channel columns have the following, in this order: note, instrument, volume and effects\n"
851 "- hit space bar while on the pattern to toggle Edit Mode\n"
852 "- click on the pattern or use arrow keys to move the cursor\n"
853 "- values (instrument, volume, effects and effect values) are in hexadecimal\n"
854 "- hit enter to play/stop the song\n"
855 "- extend the song by adding more orders in the Orders window\n"
856 "- click on the Orders matrix to change the patterns of a channel (left click increases; right click decreases)"
857 ));
858
859 ImGui::Separator();
860
861 ImGui::TextWrapped(_(
862 "if you are new to trackers, you may check the quick start guide:"
863 ));
864 CLICK_TO_OPEN("https://github.com/tildearrow/furnace/blob/master/doc/1-intro/quickstart.md")
865 ImGui::TextWrapped(_(
866 "if you need help, you may:\n"
867 "- read the manual (a file called manual.pdf)\n"
868 "- ask for help in Discussions"
869 ));
870 CLICK_TO_OPEN("https://github.com/tildearrow/furnace/discussions")
871
872 ImGui::Separator();
873
874 ImGui::TextWrapped(_("if you find any issues, be sure to report them! the issue tracker is here:"));
875 CLICK_TO_OPEN("https://github.com/tildearrow/furnace/issues")
876
877 if (ImGui::Button(_("OK"))) {
878 tutorial.protoWelcome=true;
879 commitTutorial();
880 ImGui::CloseCurrentPopup();
881 }
882
883 ImGui::SetWindowPos(ImVec2(
884 (canvasW-ImGui::GetWindowSize().x)*0.5,
885 (canvasH-ImGui::GetWindowSize().y)*0.5
886 ));
887
888 if (tutorial.popupTimer<2.0f) {
889 ImDrawList* dl=ImGui::GetForegroundDrawList();
890 const ImVec2 winPos=ImGui::GetWindowPos();
891 const ImVec2 txtSize=ImGui::CalcTextSize("copied!");
892 const ImVec2 winSize=ImGui::GetWindowSize();
893 dl->AddText(ImVec2(
894 winPos.x+(winSize.x-txtSize.x)/2,
895 winPos.y+(winSize.y-txtSize.y*2)
896 ),ImGui::ColorConvertFloat4ToU32(uiColors[GUI_COLOR_TOGGLE_ON]),"copied!");
897 tutorial.popupTimer+=ImGui::GetIO().DeltaTime;
898 }
899 ImGui::EndPopup();
900 }
901
902 if (cvOpen) {
903 ImGui::SetNextWindowPos(ImVec2(0,0));
904 ImGui::SetNextWindowSize(ImVec2(canvasW,canvasH));
905 if (ImGui::Begin("Combat Vehicle",&cvOpen,ImGuiWindowFlags_NoDocking|ImGuiWindowFlags_NoMove|ImGuiWindowFlags_NoResize|ImGuiWindowFlags_Modal|ImGuiWindowFlags_NoTitleBar)) {
906 ImVec2 dpadLoc=ImVec2(canvasW*0.22,canvasH*0.85);
907 ImVec2 buttonLoc=ImVec2(canvasW*0.78,canvasH*0.85);
908 ImVec2 quitLoc=ImVec2(canvasW*0.5,canvasH*0.6);
909 float oneUnit=MIN(canvasW,canvasH)*0.12;
910
911 ImVec2 dpadUpStart=ImVec2(
912 dpadLoc.x-oneUnit*1.75,
913 dpadLoc.y-oneUnit*1.75
914 );
915 ImVec2 dpadUpEnd=ImVec2(
916 dpadLoc.x+oneUnit*1.75,
917 dpadLoc.y-oneUnit*0.5
918 );
919 ImVec2 dpadLeftEnd=ImVec2(
920 dpadLoc.x-oneUnit*0.5,
921 dpadLoc.y+oneUnit*1.75
922 );
923 ImVec2 dpadDownStart=ImVec2(
924 dpadLoc.x-oneUnit*1.75,
925 dpadLoc.y+oneUnit*0.5
926 );
927 ImVec2 dpadDownEnd=ImVec2(
928 dpadLoc.x+oneUnit*1.75,
929 dpadLoc.y+oneUnit*1.75
930 );
931 ImVec2 dpadRightStart=ImVec2(
932 dpadLoc.x+oneUnit*0.5,
933 dpadLoc.y-oneUnit*1.75
934 );
935
936 ImVec2 buttonBStart=ImVec2(
937 buttonLoc.x-oneUnit*1.25,
938 buttonLoc.y-oneUnit*0.5
939 );
940 ImVec2 buttonBEnd=ImVec2(
941 buttonLoc.x-oneUnit*0.25,
942 buttonLoc.y+oneUnit*0.5
943 );
944 ImVec2 buttonAStart=ImVec2(
945 buttonLoc.x+oneUnit*0.25,
946 buttonLoc.y-oneUnit*0.5
947 );
948 ImVec2 buttonAEnd=ImVec2(
949 buttonLoc.x+oneUnit*1.25,
950 buttonLoc.y+oneUnit*0.5
951 );
952 ImVec2 buttonQuitStart=ImVec2(
953 quitLoc.x-oneUnit*0.5,
954 quitLoc.y-oneUnit*0.25
955 );
956 ImVec2 buttonQuitEnd=ImVec2(
957 quitLoc.x+oneUnit*0.5,
958 quitLoc.y+oneUnit*0.25
959 );
960
961 unsigned char touchControls=0;
962
963 if (mobileUI) {
964 for (TouchPoint& i: activePoints) {
965 // B
966 if (i.x>=buttonBStart.x && i.y>=buttonBStart.y &&
967 i.x<=buttonBEnd.x && i.y<=buttonBEnd.y) {
968 touchControls|=1;
969 }
970 // A
971 if (i.x>=buttonAStart.x && i.y>=buttonAStart.y &&
972 i.x<=buttonAEnd.x && i.y<=buttonAEnd.y) {
973 touchControls|=2;
974 }
975 // up
976 if (i.x>=dpadUpStart.x && i.y>=dpadUpStart.y &&
977 i.x<=dpadUpEnd.x && i.y<=dpadUpEnd.y) {
978 touchControls|=16;
979 }
980 // down
981 if (i.x>=dpadDownStart.x && i.y>=dpadDownStart.y &&
982 i.x<=dpadDownEnd.x && i.y<=dpadDownEnd.y) {
983 touchControls|=32;
984 }
985 // left
986 if (i.x>=dpadUpStart.x && i.y>=dpadUpStart.y &&
987 i.x<=dpadLeftEnd.x && i.y<=dpadLeftEnd.y) {
988 touchControls|=64;
989 }
990 // right
991 if (i.x>=dpadRightStart.x && i.y>=dpadRightStart.y &&
992 i.x<=dpadDownEnd.x && i.y<=dpadDownEnd.y) {
993 touchControls|=128;
994 }
995 // quit
996 if (cv!=NULL) {
997 if (i.x>=buttonQuitStart.x && i.y>=buttonQuitStart.y &&
998 i.x<=buttonQuitEnd.x && i.y<=buttonQuitEnd.y) {
999 cv->unload();
1000 delete cv;
1001 cv=NULL;
1002 cvOpen=false;
1003 return;
1004 }
1005 }
1006 }
1007 }
1008
1009 if (cv==NULL) {
1010 initRandomDemoSong();
1011 cv=new FurnaceCV;
1012 cv->init(e);
1013 cv->hiScore=cvHiScore;
1014 lastCVFrame=SDL_GetPerformanceCounter();
1015 cvFrameTime=100000;
1016 cvFrameHold=0;
1017 }
1018 if (cvTex==NULL) {
1019 cvTex=rend->createTexture(true,320,224,false,bestTexFormat);
1020 } else if (!rend->isTextureValid(cvTex)) {
1021 rend->destroyTexture(cvTex);
1022 cvTex=rend->createTexture(true,320,224,false,bestTexFormat);
1023 }
1024
1025 if (cv->pleaseInitSongs) {
1026 cv->pleaseInitSongs=false;
1027 if (cv->playSongs) {
1028 if (loadRandomDemoSong()) {
1029 cv->loadInstruments();
1030 }
1031 }
1032 cv->origSongRate=e->getHz();
1033 }
1034
1035 WAKE_UP;
1036
1037 if (cv->inTransition && cv->transWait==1) {
1038 // load random demo song
1039 int avgSpeed=0;
1040 for (int i=0; i<e->curSubSong->speeds.len; i++) {
1041 avgSpeed+=e->curSubSong->speeds.val[i];
1042 }
1043 int oneQuarter=(e->curSubSong->ordersLen*e->curSubSong->patLen*avgSpeed);
1044 if (e->curSubSong->speeds.len) oneQuarter/=e->curSubSong->speeds.len;
1045 oneQuarter=(oneQuarter*e->curSubSong->virtualTempoN)/e->curSubSong->virtualTempoD;
1046 oneQuarter/=e->curSubSong->hz;
1047 oneQuarter/=4;
1048 if (cv->playSongs && e->getTotalSeconds()>=oneQuarter) {
1049 if (loadRandomDemoSong()) {
1050 cv->loadInstruments();
1051 e->changeSongP(0);
1052 e->setOrder(0);
1053 e->play();
1054 cv->origSongRate=e->getHz();
1055 }
1056 }
1057 }
1058
1059 if (cv->speedTicks>0) {
1060 cv->e->setSongRate(cv->origSongRate*1.5);
1061 }
1062
1063 uint64_t nextFrame=SDL_GetPerformanceCounter();
1064 unsigned int mDivider=SDL_GetPerformanceFrequency()/1000000;
1065 int delta=(nextFrame-lastCVFrame)/mDivider;
1066 cvFrameTime=(cvFrameTime*15+delta)/16;
1067 cvFrameHold+=delta;
1068 if (cvFrameHold>=16667 || cvFrameTime>15000) {
1069 cv->render(touchControls);
1070 cvFrameHold%=16667;
1071 }
1072 lastCVFrame=nextFrame;
1073
1074 if (cv->hiScore>cvHiScore) {
1075 cvHiScore=cv->hiScore;
1076 }
1077
1078 if (cvTex!=NULL) {
1079 SDL_LockSurface(cv->surface);
1080 rend->updateTexture(cvTex,cv->surface->pixels,320*4);
1081 SDL_UnlockSurface(cv->surface);
1082
1083 ImDrawList* dl=ImGui::GetForegroundDrawList();
1084
1085 ImVec2 p0, p1;
1086
1087 if (((double)canvasH/(double)canvasW)>0.7) {
1088 if (mobileUI) {
1089 p0=ImVec2(0.0,canvasH*0.05);
1090 p1=ImVec2(canvasW,(canvasH*0.05)+(canvasW*0.7));
1091 } else {
1092 p0=ImVec2(0.0,(canvasH-(canvasW*0.7))*0.5);
1093 p1=ImVec2(canvasW,canvasW*0.7+(canvasH-(canvasW*0.7))*0.5);
1094 }
1095 } else {
1096 p0=ImVec2((canvasW-(canvasH/0.7))*0.5,0.0);
1097 p1=ImVec2((canvasH/0.7)+(canvasW-(canvasH/0.7))*0.5,canvasH);
1098 }
1099
1100 dl->AddRectFilled(ImVec2(0,0),ImVec2(canvasW,canvasH),0xff000000);
1101
1102 dl->AddImage(rend->getTextureID(cvTex),p0,p1,ImVec2(0,0),ImVec2(rend->getTextureU(cvTex),rend->getTextureV(cvTex)));
1103
1104 if (mobileUI) {
1105 ImVec2 chevron[3];
1106
1107 // up
1108 chevron[0]=ImLerp(dpadUpStart,dpadUpEnd,ImVec2(0.4,0.65));
1109 chevron[1]=ImLerp(dpadUpStart,dpadUpEnd,ImVec2(0.5,0.35));
1110 chevron[2]=ImLerp(dpadUpStart,dpadUpEnd,ImVec2(0.6,0.65));
1111 dl->AddPolyline(chevron,3,0xffffffff,0,4.0f*dpiScale);
1112
1113 // left
1114 chevron[0]=ImLerp(dpadUpStart,dpadLeftEnd,ImVec2(0.65,0.4));
1115 chevron[1]=ImLerp(dpadUpStart,dpadLeftEnd,ImVec2(0.35,0.5));
1116 chevron[2]=ImLerp(dpadUpStart,dpadLeftEnd,ImVec2(0.65,0.6));
1117 dl->AddPolyline(chevron,3,0xffffffff,0,4.0f*dpiScale);
1118
1119 // down
1120 chevron[0]=ImLerp(dpadDownStart,dpadDownEnd,ImVec2(0.4,0.35));
1121 chevron[1]=ImLerp(dpadDownStart,dpadDownEnd,ImVec2(0.5,0.65));
1122 chevron[2]=ImLerp(dpadDownStart,dpadDownEnd,ImVec2(0.6,0.35));
1123 dl->AddPolyline(chevron,3,0xffffffff,0,4.0f*dpiScale);
1124
1125 // right
1126 chevron[0]=ImLerp(dpadRightStart,dpadDownEnd,ImVec2(0.35,0.4));
1127 chevron[1]=ImLerp(dpadRightStart,dpadDownEnd,ImVec2(0.65,0.5));
1128 chevron[2]=ImLerp(dpadRightStart,dpadDownEnd,ImVec2(0.35,0.6));
1129 dl->AddPolyline(chevron,3,0xffffffff,0,4.0f*dpiScale);
1130
1131 // A/B
1132 dl->AddRectFilled(buttonBStart,buttonBEnd,(touchControls&1)?0x4040ffff:0x2040ffff,0,0);
1133 dl->AddRectFilled(buttonAStart,buttonAEnd,(touchControls&2)?0x4040ffff:0x2040ffff,0,0);
1134 dl->AddRect(buttonBStart,buttonBEnd,0xff00ffff,0,0,dpiScale);
1135 dl->AddRect(buttonAStart,buttonAEnd,0xff00ffff,0,0,dpiScale);
1136 dl->AddText(headFont,settings.headFontSize*dpiScale,ImLerp(buttonBStart,buttonBEnd,ImVec2(0.5,0.5))-(headFont->CalcTextSizeA(settings.headFontSize*dpiScale,FLT_MAX,0,"B")*0.5f),0xff00ffff,"B");
1137 dl->AddText(headFont,settings.headFontSize*dpiScale,ImLerp(buttonAStart,buttonAEnd,ImVec2(0.5,0.5))-(headFont->CalcTextSizeA(settings.headFontSize*dpiScale,FLT_MAX,0,"A")*0.5f),0xff00ffff,"A");
1138
1139 // quit
1140 dl->AddRect(buttonQuitStart,buttonQuitEnd,0xffffffff,0,0,dpiScale);
1141 }
1142 }
1143 }
1144 ImGui::End();
1145
1146 if (ImGui::IsKeyPressed(ImGuiKey_Escape)) {
1147 if (cv!=NULL) {
1148 cv->unload();
1149 delete cv;
1150 cv=NULL;
1151 }
1152 cvOpen=false;
1153 }
1154 }
1155 }
1156
1157 // CV
1158 // 320x224
1159
1160 // renderer details:
1161 // two 80x56 tile planes (40x28 is visible)
1162 // 256 colors
1163 // 4096 tiles (image is 256-color, 256x1024)
1164 // each tile is 8x8
1165
1166 static const unsigned char cvPalette[1024]={
1167 0x00, 0x00, 0x00, 0xff, 0xb3, 0x00, 0x00, 0xff, 0x00, 0xa7, 0x00, 0xff,
1168 0xe5, 0x93, 0x00, 0xff, 0x00, 0x00, 0xa6, 0xff, 0x77, 0x00, 0x97, 0xff,
1169 0x12, 0x81, 0xb1, 0xff, 0xbe, 0xbe, 0xbe, 0xff, 0x51, 0x51, 0x51, 0xff,
1170 0xfc, 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0xff, 0xff, 0x1d, 0xff,
1171 0x00, 0x00, 0xfa, 0xff, 0xff, 0x00, 0xff, 0xff, 0x1f, 0xfa, 0xff, 0xff,
1172 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x01, 0x67, 0xff,
1173 0x04, 0x00, 0x89, 0xff, 0x00, 0x03, 0xab, 0xff, 0x00, 0x00, 0xdc, 0xff,
1174 0x04, 0x00, 0xfe, 0xff, 0x00, 0x63, 0x00, 0xff, 0x00, 0x5f, 0x5f, 0xff,
1175 0x01, 0x62, 0x85, 0xff, 0x05, 0x5d, 0xb6, 0xff, 0x00, 0x61, 0xd9, 0xff,
1176 0x02, 0x5f, 0xfb, 0xff, 0x00, 0x8a, 0x06, 0xff, 0x00, 0x8a, 0x59, 0xff,
1177 0x00, 0x85, 0x8a, 0xff, 0x06, 0x87, 0xb1, 0xff, 0x00, 0x8b, 0xd3, 0xff,
1178 0x02, 0x87, 0xff, 0xff, 0x00, 0xb0, 0x00, 0xff, 0x00, 0xb1, 0x62, 0xff,
1179 0x00, 0xaf, 0x84, 0xff, 0x02, 0xad, 0xa7, 0xff, 0x00, 0xaf, 0xd8, 0xff,
1180 0x02, 0xb1, 0xfe, 0xff, 0x00, 0xd8, 0x05, 0xff, 0x00, 0xdb, 0x5c, 0xff,
1181 0x00, 0xd7, 0x8e, 0xff, 0x03, 0xd5, 0xb0, 0xff, 0x00, 0xd9, 0xd2, 0xff,
1182 0x00, 0xd4, 0xff, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x66, 0xff,
1183 0x00, 0xff, 0x88, 0xff, 0x03, 0xff, 0xaa, 0xff, 0x00, 0xff, 0xdb, 0xff,
1184 0x00, 0xff, 0xfd, 0xff, 0x64, 0x00, 0x00, 0xff, 0x64, 0x00, 0x65, 0xff,
1185 0x5c, 0x03, 0x87, 0xff, 0x60, 0x01, 0xa9, 0xff, 0x64, 0x00, 0xda, 0xff,
1186 0x5c, 0x00, 0xfc, 0xff, 0x61, 0x60, 0x00, 0xff, 0x5d, 0x5d, 0x5d, 0xff,
1187 0x65, 0x5f, 0x83, 0xff, 0x5d, 0x61, 0xb5, 0xff, 0x61, 0x5f, 0xd7, 0xff,
1188 0x59, 0x63, 0xf9, 0xff, 0x61, 0x88, 0x04, 0xff, 0x5e, 0x87, 0x57, 0xff,
1189 0x62, 0x83, 0x88, 0xff, 0x5e, 0x8b, 0xaf, 0xff, 0x62, 0x86, 0xe0, 0xff,
1190 0x5a, 0x8a, 0xff, 0xff, 0x5e, 0xae, 0x00, 0xff, 0x5e, 0xaf, 0x60, 0xff,
1191 0x62, 0xad, 0x83, 0xff, 0x5a, 0xae, 0xb4, 0xff, 0x5e, 0xac, 0xd6, 0xff,
1192 0x5a, 0xb5, 0xfc, 0xff, 0x5e, 0xd5, 0x03, 0xff, 0x5e, 0xd9, 0x5b, 0xff,
1193 0x62, 0xd4, 0x8c, 0xff, 0x5b, 0xd9, 0xae, 0xff, 0x5f, 0xd7, 0xd0, 0xff,
1194 0x63, 0xd2, 0xff, 0xff, 0x5f, 0xff, 0x00, 0xff, 0x5f, 0xff, 0x64, 0xff,
1195 0x63, 0xff, 0x86, 0xff, 0x5b, 0xff, 0xa8, 0xff, 0x5f, 0xfe, 0xd9, 0xff,
1196 0x63, 0xfc, 0xfc, 0xff, 0x88, 0x01, 0x00, 0xff, 0x88, 0x01, 0x62, 0xff,
1197 0x8c, 0x00, 0x84, 0xff, 0x84, 0x01, 0xb5, 0xff, 0x88, 0x00, 0xd7, 0xff,
1198 0x8c, 0x00, 0xfa, 0xff, 0x85, 0x60, 0x07, 0xff, 0x81, 0x60, 0x5a, 0xff,
1199 0x89, 0x5f, 0x8f, 0xff, 0x8d, 0x5e, 0xb2, 0xff, 0x85, 0x62, 0xd4, 0xff,
1200 0x89, 0x5d, 0xff, 0xff, 0x85, 0x8b, 0x01, 0xff, 0x82, 0x87, 0x63, 0xff,
1201 0x86, 0x86, 0x86, 0xff, 0x8a, 0x84, 0xa8, 0xff, 0x86, 0x89, 0xdd, 0xff,
1202 0x8a, 0x87, 0xff, 0xff, 0x82, 0xb1, 0x00, 0xff, 0x82, 0xb2, 0x5e, 0xff,
1203 0x86, 0xb0, 0x80, 0xff, 0x8a, 0xab, 0xb1, 0xff, 0x82, 0xaf, 0xd3, 0xff,
1204 0x8a, 0xaf, 0xff, 0xff, 0x82, 0xd8, 0x00, 0xff, 0x82, 0xdc, 0x58, 0xff,
1205 0x86, 0xd7, 0x89, 0xff, 0x8b, 0xd5, 0xab, 0xff, 0x83, 0xd7, 0xdc, 0xff,
1206 0x87, 0xd5, 0xff, 0xff, 0x83, 0xff, 0x00, 0xff, 0x83, 0xff, 0x61, 0xff,
1207 0x87, 0xff, 0x83, 0xff, 0x8b, 0xfd, 0xb4, 0xff, 0x83, 0xff, 0xd7, 0xff,
1208 0x87, 0xff, 0xf9, 0xff, 0xac, 0x01, 0x07, 0xff, 0xac, 0x04, 0x5f, 0xff,
1209 0xb0, 0x02, 0x81, 0xff, 0xb4, 0x00, 0xb2, 0xff, 0xac, 0x02, 0xd4, 0xff,
1210 0xb0, 0x00, 0xff, 0xff, 0xb5, 0x5d, 0x04, 0xff, 0xb1, 0x5d, 0x57, 0xff,
1211 0xad, 0x62, 0x8d, 0xff, 0xb1, 0x60, 0xaf, 0xff, 0xb5, 0x5c, 0xe0, 0xff,
1212 0xad, 0x60, 0xff, 0xff, 0xb5, 0x88, 0x00, 0xff, 0xb1, 0x84, 0x60, 0xff,
1213 0xaa, 0x88, 0x83, 0xff, 0xae, 0x84, 0xb4, 0xff, 0xb6, 0x86, 0xda, 0xff,
1214 0xae, 0x8a, 0xfc, 0xff, 0xb2, 0xab, 0x03, 0xff, 0xb2, 0xaf, 0x5b, 0xff,
1215 0xaa, 0xb0, 0x8c, 0xff, 0xae, 0xae, 0xae, 0xff, 0xb2, 0xac, 0xd0, 0xff,
1216 0xaa, 0xae, 0xff, 0xff, 0xb2, 0xd5, 0x00, 0xff, 0xb2, 0xd6, 0x64, 0xff,
1217 0xaa, 0xda, 0x86, 0xff, 0xae, 0xd8, 0xa8, 0xff, 0xb3, 0xd4, 0xd9, 0xff,
1218 0xab, 0xd8, 0xfc, 0xff, 0xb3, 0xff, 0x00, 0xff, 0xb3, 0xff, 0x5e, 0xff,
1219 0xab, 0xff, 0x80, 0xff, 0xaf, 0xff, 0xb1, 0xff, 0xb3, 0xfe, 0xd4, 0xff,
1220 0xab, 0xff, 0xff, 0xff, 0xdc, 0x00, 0x05, 0xff, 0xdc, 0x01, 0x5c, 0xff,
1221 0xd4, 0x02, 0x8d, 0xff, 0xd8, 0x01, 0xaf, 0xff, 0xdc, 0x00, 0xd2, 0xff,
1222 0xd4, 0x00, 0xff, 0xff, 0xd9, 0x60, 0x01, 0xff, 0xd5, 0x5d, 0x63, 0xff,
1223 0xd9, 0x5b, 0x86, 0xff, 0xd5, 0x63, 0xac, 0xff, 0xd9, 0x5f, 0xdd, 0xff,
1224 0xdd, 0x5d, 0xff, 0xff, 0xd5, 0x86, 0x00, 0xff, 0xd5, 0x87, 0x5e, 0xff,
1225 0xd9, 0x85, 0x80, 0xff, 0xd2, 0x87, 0xb1, 0xff, 0xda, 0x89, 0xd7, 0xff,
1226 0xde, 0x84, 0xff, 0xff, 0xd6, 0xae, 0x00, 0xff, 0xd6, 0xb1, 0x58, 0xff,
1227 0xda, 0xad, 0x89, 0xff, 0xd2, 0xb1, 0xab, 0xff, 0xd6, 0xac, 0xdc, 0xff,
1228 0xda, 0xaa, 0xff, 0xff, 0xd6, 0xd8, 0x00, 0xff, 0xd6, 0xd9, 0x61, 0xff,
1229 0xda, 0xd7, 0x83, 0xff, 0xd2, 0xd8, 0xb4, 0xff, 0xd7, 0xd7, 0xd7, 0xff,
1230 0xdb, 0xd5, 0xf9, 0xff, 0xd7, 0xff, 0x04, 0xff, 0xd7, 0xff, 0x5b, 0xff,
1231 0xdb, 0xfe, 0x8c, 0xff, 0xd3, 0xff, 0xaf, 0xff, 0xd7, 0xff, 0xd1, 0xff,
1232 0xdb, 0xfc, 0xff, 0xff, 0xff, 0x00, 0x02, 0xff, 0xff, 0x01, 0x68, 0xff,
1233 0xff, 0x00, 0x8a, 0xff, 0xfc, 0x04, 0xac, 0xff, 0xff, 0x00, 0xde, 0xff,
1234 0xff, 0x00, 0xff, 0xff, 0xfd, 0x63, 0x00, 0xff, 0xf9, 0x60, 0x60, 0xff,
1235 0xfd, 0x5e, 0x83, 0xff, 0xff, 0x5d, 0xb8, 0xff, 0xfd, 0x62, 0xda, 0xff,
1236 0xff, 0x60, 0xfc, 0xff, 0xf9, 0x86, 0x03, 0xff, 0xf9, 0x8a, 0x5b, 0xff,
1237 0xfd, 0x85, 0x8c, 0xff, 0xff, 0x84, 0xae, 0xff, 0xfa, 0x88, 0xd0, 0xff,
1238 0xff, 0x87, 0xff, 0xff, 0xfa, 0xb1, 0x00, 0xff, 0xff, 0xab, 0x64, 0xff,
1239 0xfe, 0xb0, 0x86, 0xff, 0xff, 0xae, 0xa8, 0xff, 0xfa, 0xaf, 0xd9, 0xff,
1240 0xfe, 0xad, 0xfc, 0xff, 0xfa, 0xdb, 0x00, 0xff, 0xff, 0xd6, 0x5e, 0xff,
1241 0xfe, 0xda, 0x80, 0xff, 0xff, 0xd5, 0xb1, 0xff, 0xfb, 0xd9, 0xd4, 0xff,
1242 0xff, 0xd5, 0xff, 0xff, 0xfb, 0xff, 0x01, 0xff, 0xff, 0xf9, 0x63, 0xff,
1243 0xff, 0xff, 0x89, 0xff, 0xff, 0xff, 0xac, 0xff, 0xfb, 0xff, 0xdd, 0xff,
1244 0xff, 0xff, 0xff, 0xff, 0x04, 0x04, 0x04, 0xff, 0x0c, 0x0c, 0x0c, 0xff,
1245 0x18, 0x18, 0x18, 0xff, 0x20, 0x20, 0x20, 0xff, 0x2d, 0x2d, 0x2d, 0xff,
1246 0x35, 0x35, 0x35, 0xff, 0x41, 0x41, 0x41, 0xff, 0x49, 0x49, 0x49, 0xff,
1247 0x55, 0x55, 0x55, 0xff, 0x61, 0x61, 0x61, 0xff, 0x69, 0x69, 0x69, 0xff,
1248 0x71, 0x71, 0x71, 0xff, 0x7d, 0x7d, 0x7d, 0xff, 0x8a, 0x8a, 0x8a, 0xff,
1249 0x92, 0x92, 0x92, 0xff, 0x9a, 0x9a, 0x9a, 0xff, 0xa6, 0xa6, 0xa6, 0xff,
1250 0xb2, 0xb2, 0xb2, 0xff, 0xba, 0xba, 0xba, 0xff, 0xc2, 0xc2, 0xc2, 0xff,
1251 0xce, 0xce, 0xce, 0xff, 0xdb, 0xdb, 0xdb, 0xff, 0xe3, 0xe3, 0xe3, 0xff,
1252 0xeb, 0xeb, 0xeb, 0xff
1253 };
1254
1255 #include "tileData.h"
1256
1257 #define SE_SHOT1 0, 0, 48
1258 #define SE_EXPL1 1, 1, 67
1259 #define SE_PICKUP1 2, 2, 67
1260 #define SE_PICKUP2 3, 2, 69
1261 #define SE_DEATH_C1 4, 0, 48
1262 #define SE_DEATH_C2 5, 1, 48
1263 #define SE_SHOT2 6, 0, 48
1264 #define SE_TYPEWRITER 7, 0, 48
1265 #define SE_TRANSITION1 8, 2, 43
1266 #define SE_TRANSITION2 9, 2, 48
1267 #define SE_INIT 10, 2, 48
1268 #define SE_RESPAWN 11, 2, 48
1269 #define SE_TANKMOVE 12, 3, 48
1270 #define SE_VORTEXMOVE 13, 3, 55
1271 #define SE_VORTEXSHOOT 14, 3, 48
1272 #define SE_RESIST 15, 1, 48
1273 #define SE_PLANE1 16, 1, 47
1274 #define SE_PLANE2 17, 2, 47
1275 #define SE_EXPL2 18, 1, 60
1276 #define SE_PICKUP3 19, 3, 67
1277 #define SE_TIMEUP 20, 2, 81
1278
1279 template<typename T> T* FurnaceCV::createObject(short x, short y) {
1280 T* ret=new T(this);
1281 ret->x=x;
1282 ret->y=y;
1283 sprite.push_back(ret);
1284 return ret;
1285 }
1286
1287 template<typename T> T* FurnaceCV::createObjectNoPos() {
1288 T* ret=new T(this);
1289 sprite.push_back(ret);
1290 return ret;
1291 }
1292
1293 void FurnaceCV::soundEffect(int ins, int chan, int note) {
1294 e->noteOn(chan+fxChanBase,ins+fxInsBase,note);
1295 /*
1296 e->dispatchCmd(DivCommand(DIV_CMD_INSTRUMENT,chan,ins,1));
1297 e->dispatchCmd(DivCommand(DIV_CMD_NOTE_ON,chan,note));
1298 */
1299 }
1300
1301 void FurnaceCV::stopSoundEffect(int ins, int chan, int note) {
1302 e->noteOff(chan+fxChanBase);
1303 //e->dispatchCmd(DivCommand(DIV_CMD_NOTE_OFF,chan));
1304 }
1305
1306 static const int floorBases[4]={
1307 0x40, 0x48, 0x60, 0x68
1308 };
1309
1310 void FurnaceCV::buildStage(int which) {
1311 if (curStage!=NULL) {
1312 delete[] curStage;
1313 curStage=NULL;
1314 }
1315
1316 if (which>18 || which==4 || which==7 || which==9 || which==11 || which==13 || which==16 || which==17) {
1317 stageWidth=80;
1318 stageHeight=56;
1319 } else {
1320 stageWidth=40;
1321 stageHeight=28;
1322 }
1323
1324 stageWidthPx=stageWidth<<3;
1325 stageHeightPx=stageHeight<<3;
1326
1327 curStage=new unsigned short[stageWidth*stageHeight];
1328
1329 int floorBase=floorBases[rand()&3];
1330
1331 for (int i=0; i<stageHeight; i++) {
1332 for (int j=0; j<stageWidth; j++) {
1333 curStage[i*stageWidth+j]=floorBase+(rand()&7);
1334 }
1335 }
1336
1337 // render
1338 for (int i=0; i<stageHeight; i++) {
1339 for (int j=0; j<stageWidth; j++) {
1340 tile0[i][j]=curStage[i*stageWidth+j];
1341 }
1342 }
1343
1344 // prepare enemies
1345 bool busy[28][40];
1346 memset(busy,0,28*40*sizeof(bool));
1347
1348 // special stages
1349 if ((which%20)==19) {
1350 for (int i=0; i<20+(which>>2); i++) {
1351 int tries=0;
1352 while (tries<20) {
1353 int x=(rand()%(stageWidth>>1))&(~1);
1354 int y=(rand()%(stageHeight>>1))&(~1);
1355 int finalX=x<<4;
1356 int finalY=y<<4;
1357 if (busy[y][x]) {
1358 tries++;
1359 continue;
1360 }
1361 FurnaceCVEnemy1* enemy=createObject<FurnaceCVEnemy1>(finalX,finalY);
1362 createObject<FurnaceCVFurBallLarge>(finalX-4,finalY-4);
1363 enemy->setType(3);
1364 busy[y][x]=true;
1365 busy[y][x+1]=true;
1366 busy[y+1][x]=true;
1367 busy[y+1][x+1]=true;
1368 break;
1369 }
1370 }
1371 } else if ((which%10)==9) {
1372 // vortex
1373 for (int i=0; i<20+(which>>2); i++) {
1374 int tries=0;
1375 while (tries<20) {
1376 int x=rand()%(stageWidth>>1);
1377 int y=rand()%(stageHeight>>1);
1378 int finalX=x<<4;
1379 int finalY=y<<4;
1380 if (busy[y][x]) {
1381 tries++;
1382 continue;
1383 }
1384 createObject<FurnaceCVEnemyVortex>(finalX,finalY);
1385 createObject<FurnaceCVFurBallMedium>(finalX-4,finalY-4);
1386 busy[y][x]=true;
1387 break;
1388 }
1389 }
1390 } else {
1391 // large
1392 if (which>=2) for (int i=0; i<(rand()%3)+which-2; i++) {
1393 int tries=0;
1394 while (tries<20) {
1395 int x=(rand()%(stageWidth>>1))&(~1);
1396 int y=(rand()%(stageHeight>>1))&(~1);
1397 int finalX=x<<4;
1398 int finalY=y<<4;
1399 if (busy[y][x]) {
1400 tries++;
1401 continue;
1402 }
1403 FurnaceCVEnemy1* enemy=createObject<FurnaceCVEnemy1>(finalX,finalY);
1404 createObject<FurnaceCVFurBallLarge>(finalX-4,finalY-4);
1405 enemy->setType(2);
1406 if (which>7) {
1407 enemy->setType((rand()%MAX(3,17-which))==0?3:2);
1408 }
1409 busy[y][x]=true;
1410 busy[y][x+1]=true;
1411 busy[y+1][x]=true;
1412 busy[y+1][x+1]=true;
1413 break;
1414 }
1415 }
1416
1417 // vortex
1418 if (which>=4) for (int i=0; i<(rand()%(1+which))+(which>>1); i++) {
1419 int tries=0;
1420 while (tries<20) {
1421 int x=rand()%(stageWidth>>1);
1422 int y=rand()%(stageHeight>>1);
1423 int finalX=x<<4;
1424 int finalY=y<<4;
1425 if (busy[y][x]) {
1426 tries++;
1427 continue;
1428 }
1429 createObject<FurnaceCVEnemyVortex>(finalX,finalY);
1430 createObject<FurnaceCVFurBallMedium>(finalX-4,finalY-4);
1431 busy[y][x]=true;
1432 break;
1433 }
1434 }
1435
1436 // small
1437 for (int i=0; i<7+(rand()%4)+((which&3)<<2)+(which>>1); i++) {
1438 int tries=0;
1439 while (tries<20) {
1440 int x=rand()%(stageWidth>>1);
1441 int y=rand()%(stageHeight>>1);
1442 int finalX=x<<4;
1443 int finalY=y<<4;
1444 if (busy[y][x]) {
1445 tries++;
1446 continue;
1447 }
1448 FurnaceCVEnemy1* enemy=createObject<FurnaceCVEnemy1>(finalX,finalY);
1449 createObject<FurnaceCVFurBallMedium>(finalX-4,finalY-4);
1450 if (which>0) {
1451 if (which>=20) {
1452 enemy->setType(1);
1453 } else {
1454 enemy->setType((rand()%MAX(2,8-which))==0?1:0);
1455 }
1456 }
1457 busy[y][x]=true;
1458 break;
1459 }
1460 }
1461
1462 // mines
1463 for (int i=0; i<7+(rand()%18); i++) {
1464 int tries=0;
1465 while (tries<20) {
1466 int x=rand()%(stageWidth>>1);
1467 int y=rand()%(stageHeight>>1);
1468 int finalX=x<<4;
1469 int finalY=y<<4;
1470 if (busy[y][x]) {
1471 tries++;
1472 continue;
1473 }
1474 createObject<FurnaceCVMine>(finalX,finalY);
1475 busy[y][x]=true;
1476 break;
1477 }
1478 }
1479 }
1480
1481 // setup stuff
1482 planeTime=180+(rand()%400);
1483 }
1484
1485 #define CV_FONTBASE_8x8 0x250
1486 #define CV_FONTBASE_8x8_RED 0x2d0
1487 #define CV_FONTBASE_8x16 0x0
1488
1489 void FurnaceCV::putText(int fontBase, bool fontHeight, String text, int x, int y) {
1490 int initX=x;
1491 for (const char* i=text.c_str(); *i; i++) {
1492 if (*i=='\n') {
1493 x=initX;
1494 y+=fontHeight?2:1;
1495 continue;
1496 }
1497 if (y>=28) break;
1498 tile1[y][x]=fontBase+((*i)&15)+(((*i)&(~15))<<(fontHeight?2:1));
1499 if (fontHeight) {
1500 tile1[y+1][x]=fontBase+((*i)&15)+32+(((*i)&(~15))<<(fontHeight?2:1));
1501 }
1502 x++;
1503 if (x>=40) {
1504 x=initX;
1505 y+=fontHeight?2:1;
1506 }
1507 }
1508 }
1509
1510 void FurnaceCV::startTyping(const char* text, int x, int y) {
1511 typeAddr=text;
1512 typeX=x;
1513 typeY=y;
1514 typeXStart=x;
1515 typeYStart=y;
1516 typeDelay=1;
1517 soundEffect(SE_TYPEWRITER);
1518 }
1519
1520 void FurnaceCV::typeTick() {
1521 if (typeAddr==NULL) return;
1522
1523 unsigned char typeChar=(unsigned char)(*typeAddr);
1524
1525 if (typeChar<0x20 || typeChar>=0x80) {
1526 switch (typeChar) {
1527 case '\n':
1528 typeX=typeXStart;
1529 typeY+=2;
1530 if (typeY>=typeYEnd) typeY=typeYEnd;
1531 break;
1532 }
1533 } else {
1534 tile1[typeY][typeX]=(typeChar&15)|((typeChar&(~15))<<2);
1535 tile1[typeY+1][typeX]=32|((typeChar&15)|((typeChar&(~15))<<2));
1536
1537 if (++typeX>typeXEnd) {
1538 typeX=typeXStart;
1539 typeY+=2;
1540
1541 if (typeY>=typeYEnd) typeY=typeYEnd;
1542 }
1543 }
1544
1545 if (*(++typeAddr)==0) {
1546 typeAddr=NULL;
1547 stopSoundEffect(SE_TYPEWRITER);
1548 }
1549 }
1550
1551 void FurnaceCV::rasterH(int scanline) {
1552
1553 }
1554
1555 void FurnaceCV::render(unsigned char joyIn) {
1556 // input
1557 joyInputPrev=joyInput;
1558 joyInput=joyIn;
1559 joyInput|=(
1560 (ImGui::IsKeyDown(ImGuiKey_X)?1:0)|
1561 (ImGui::IsKeyDown(ImGuiKey_Z)?2:0)|
1562 (ImGui::IsKeyDown(ImGuiKey_RightShift)?4:0)|
1563 (ImGui::IsKeyDown(ImGuiKey_Enter)?8:0)|
1564 (ImGui::IsKeyDown(ImGuiKey_UpArrow)?16:0)|
1565 (ImGui::IsKeyDown(ImGuiKey_DownArrow)?32:0)|
1566 (ImGui::IsKeyDown(ImGuiKey_LeftArrow)?64:0)|
1567 (ImGui::IsKeyDown(ImGuiKey_RightArrow)?128:0)
1568 );
1569 joyPressed=(joyInputPrev^0xff)&joyInput;
1570 joyReleased=(joyInput^0xff)&joyInputPrev;
1571
1572 // logic
1573 typeTick();
1574
1575 int enemyCount=0;
1576
1577 for (size_t i=0; i<sprite.size(); i++) {
1578 for (size_t j=i+1; j<sprite.size(); j++) {
1579 const short s_x0=sprite[i]->x+sprite[i]->collX0;
1580 const short s_x1=sprite[i]->x+sprite[i]->collX1;
1581 const short s_y0=sprite[i]->y+sprite[i]->collY0;
1582 const short s_y1=sprite[i]->y+sprite[i]->collY1;
1583 const short d_x0=sprite[j]->x+sprite[j]->collX0;
1584 const short d_x1=sprite[j]->x+sprite[j]->collX1;
1585 const short d_y0=sprite[j]->y+sprite[j]->collY0;
1586 const short d_y1=sprite[j]->y+sprite[j]->collY1;
1587 if (d_y0<s_y1 && d_y1>s_y0 && d_x0<s_x1 && d_x1>s_x0) {
1588 sprite[i]->collision(sprite[j]);
1589 sprite[j]->collision(sprite[i]);
1590 }
1591 }
1592 sprite[i]->tick();
1593 if (sprite[i]->dead) {
1594 delete sprite[i];
1595 sprite.erase(sprite.begin()+i);
1596 i--;
1597 }
1598 }
1599
1600 if (inGame) {
1601 // planes
1602 if (--planeTime<=0) {
1603 planeTime=MAX(10,60-(stage*2))+(rand()%MAX(50,320-stage*4));
1604 if (stage>=5 && stage!=9 && (stage&1 || stage>=10)) {
1605 createObjectNoPos<FurnaceCVEnemyPlane>();
1606 }
1607 }
1608
1609 // initialization
1610 if (ticksToInit>0) {
1611 if (--ticksToInit<1) {
1612 e->changeSongP(0);
1613 e->setOrder(0);
1614 e->play();
1615 buildStage(stage);
1616 createObject<FurnaceCVPlayer>(160,112);
1617 createObject<FurnaceCVFurBallLarge>(160-4,112-4);
1618 soundEffect(SE_INIT);
1619 }
1620 } else {
1621 bool hasEnemy=false;
1622 for (FurnaceCVObject* i: sprite) {
1623 if (i->type==CV_ENEMY) {
1624 hasEnemy=true;
1625 enemyCount++;
1626 }
1627 }
1628 if (!hasEnemy) {
1629 inTransition=true;
1630 inGame=false;
1631 transWait=100;
1632 soundEffect(SE_TRANSITION1);
1633 stopSoundEffect(0,0,0);
1634 stopSoundEffect(0,3,0);
1635 respawnTime=0;
1636 for (FurnaceCVObject* i: sprite) {
1637 if (i->type==CV_EXTRA_LIFE) lifeBank++;
1638 i->dead=true;
1639 }
1640 memset(tile0,0,80*56*sizeof(short));
1641 memset(tile1,0,80*56*sizeof(short));
1642 }
1643 }
1644
1645 if (respawnTime>0) {
1646 if (--respawnTime<1) {
1647 if (lives>0) {
1648 createObject<FurnaceCVPlayer>(lastPlayerX,lastPlayerY);
1649 createObject<FurnaceCVFurBallLarge>(lastPlayerX-4,lastPlayerY-4);
1650 soundEffect(SE_RESPAWN);
1651 lives--;
1652 } else {
1653 if (newHiScore) {
1654 inGame=false;
1655 inTransition=false;
1656 for (FurnaceCVObject* i: sprite) {
1657 i->dead=true;
1658 }
1659 memset(tile0,0,80*56*sizeof(short));
1660 memset(tile1,0,80*56*sizeof(short));
1661 startTyping(_(cvText[3]),2,3);
1662 e->setConf("cvHiScore",hiScore);
1663 e->saveConf();
1664 curText=4;
1665 textWait=90;
1666 } else {
1667 startTyping(_(cvText[2]),15,13);
1668 }
1669 gameOver=true;
1670 }
1671 }
1672 }
1673
1674 if (gameOver && lifeBank>0 && joyInput==3) {
1675 lives+=lifeBank;
1676 respawnTime=1;
1677 lifeBank=0;
1678 score=0;
1679 gameOver=false;
1680 }
1681
1682 // draw score
1683 putText(CV_FONTBASE_8x8_RED,false,"1UP",0,0);
1684 putText(CV_FONTBASE_8x8,false,fmt::sprintf("%8d",score),3,0);
1685
1686 putText(CV_FONTBASE_8x8_RED,false,"HI",15,0);
1687 putText(CV_FONTBASE_8x8,false,fmt::sprintf("%8d",hiScore),17,0);
1688 tile1[0][31]=0x27e;
1689 putText(CV_FONTBASE_8x8,false,fmt::sprintf("*%2d",enemyCount),32,0);
1690 tile1[0][36]=0x27f;
1691 putText(CV_FONTBASE_8x8,false,fmt::sprintf("*%2d",lives),37,0);
1692
1693 // arrow overlay
1694 bool arrowLeft=false;
1695 bool arrowRight=false;
1696 bool arrowUp=false;
1697 bool arrowDown=false;
1698 if (stageWidthPx>320 || stageHeightPx>224) {
1699 for (FurnaceCVObject* i: sprite) {
1700 if (i->type!=CV_ENEMY) continue;
1701 if ((i->x-viewX+(i->spriteWidth<<3))<0) {
1702 arrowLeft=true;
1703 }
1704 if ((i->x-viewX)>=320) {
1705 arrowRight=true;
1706 }
1707 if ((i->y-viewY+(i->spriteHeight<<3))<0) {
1708 arrowUp=true;
1709 }
1710 if ((i->y-viewY)>=224) {
1711 arrowDown=true;
1712 }
1713 }
1714 }
1715 if (arrowLeft && !(tick&8)) {
1716 tile1[13][1]=0x580;
1717 tile1[13][2]=0x581;
1718 tile1[14][1]=0x5a0;
1719 tile1[14][2]=0x5a1;
1720 } else {
1721 tile1[13][1]=0;
1722 tile1[13][2]=0;
1723 tile1[14][1]=0;
1724 tile1[14][2]=0;
1725 }
1726 if (arrowRight && !(tick&8)) {
1727 tile1[13][37]=0x584;
1728 tile1[13][38]=0x585;
1729 tile1[14][37]=0x5a4;
1730 tile1[14][38]=0x5a5;
1731 } else {
1732 tile1[13][37]=0;
1733 tile1[13][38]=0;
1734 tile1[14][37]=0;
1735 tile1[14][38]=0;
1736 }
1737 if (arrowUp && !(tick&8)) {
1738 tile1[1][19]=0x582;
1739 tile1[1][20]=0x583;
1740 tile1[2][19]=0x5a2;
1741 tile1[2][20]=0x5a3;
1742 } else {
1743 tile1[1][19]=0;
1744 tile1[1][20]=0;
1745 tile1[2][19]=0;
1746 tile1[2][20]=0;
1747 }
1748 if (arrowDown && !(tick&8)) {
1749 tile1[25][19]=0x586;
1750 tile1[25][20]=0x587;
1751 tile1[26][19]=0x5a6;
1752 tile1[26][20]=0x5a7;
1753 } else {
1754 tile1[25][19]=0;
1755 tile1[25][20]=0;
1756 tile1[26][19]=0;
1757 tile1[26][20]=0;
1758 }
1759
1760 // special stat
1761 if (specialType>0 && (tick&16)) {
1762 tile1[24][2]=0x4dc+(((specialType-1)&1)<<1)+(((specialType-1)>>1)<<6);
1763 tile1[24][3]=0x4dd+(((specialType-1)&1)<<1)+(((specialType-1)>>1)<<6);
1764 tile1[25][2]=0x4fc+(((specialType-1)&1)<<1)+(((specialType-1)>>1)<<6);
1765 tile1[25][3]=0x4fd+(((specialType-1)&1)<<1)+(((specialType-1)>>1)<<6);
1766 } else {
1767 tile1[24][2]=0;
1768 tile1[24][3]=0;
1769 tile1[25][2]=0;
1770 tile1[25][3]=0;
1771 }
1772
1773 // S mod stat
1774 if (speedTicks>0) {
1775 speedTicks--;
1776 if (speedTicks==120) soundEffect(SE_TIMEUP);
1777 if ((speedTicks<120 && speedTicks&2) || (speedTicks>=120 && speedTicks&16)) {
1778 tile1[24][36]=0x41e;
1779 tile1[24][37]=0x41f;
1780 tile1[25][36]=0x43e;
1781 tile1[25][37]=0x43f;
1782 } else {
1783 tile1[24][36]=0;
1784 tile1[24][37]=0;
1785 tile1[25][36]=0;
1786 tile1[25][37]=0;
1787 }
1788 if (speedTicks==0) {
1789 e->setSongRate(origSongRate);
1790 }
1791 } else {
1792 tile1[24][36]=0;
1793 tile1[24][37]=0;
1794 tile1[25][36]=0;
1795 tile1[25][37]=0;
1796 }
1797 } else {
1798 if (inTransition) {
1799 if (--transWait<0) {
1800 stage++;
1801 logV("stage %d",stage+1);
1802 soundEffect(SE_TRANSITION2);
1803 buildStage(stage);
1804 createObject<FurnaceCVPlayer>(lastPlayerX,lastPlayerY);
1805 createObject<FurnaceCVFurBallLarge>(lastPlayerX-4,lastPlayerY-4);
1806 inGame=true;
1807 }
1808 if (transWait==40) {
1809 putText(CV_FONTBASE_8x16,true,fmt::sprintf(_("STAGE %d"),stage+2),16,13);
1810 } else if (transWait>40) {
1811 for (int i=1; i<28; i++) {
1812 for (int j=0; j<40; j++) {
1813 int result=0x270+(j>>3)+(i>>3)+(transWait>>1)-32;
1814 tile1[i][j]=(result>=0x270 && result<=0x27b)?result:0;
1815 }
1816 }
1817 } else if (transWait==1) {
1818 memset(tile1,0,80*56*sizeof(short));
1819 }
1820 } else {
1821 if (curText==1) {
1822 if (typeAddr==NULL) {
1823 textWait=1;
1824 if (joyPressed&32) {
1825 playSongs=false;
1826 }
1827 if (joyPressed) {
1828 pleaseInitSongs=true;
1829 textWait=0;
1830 }
1831 }
1832 } else if (joyPressed&15 && curText<3) {
1833 textWait=1;
1834 typeAddr=NULL;
1835 }
1836 if (typeAddr==NULL) {
1837 if (--textWait<0) {
1838 if (curText==4) {
1839 textWait=90;
1840 } else if (curText==2) {
1841 memset(tile1,0,80*56*sizeof(short));
1842 inGame=true;
1843 } else {
1844 memset(tile1,0,80*56*sizeof(short));
1845 startTyping(_(cvText[curText]),2,3);
1846 curText++;
1847 textWait=90;
1848 }
1849 }
1850 }
1851 }
1852 }
1853
1854 tick++;
1855
1856 // render
1857 if (surface==NULL) return;
1858
1859 SDL_LockSurface(surface);
1860
1861 // render here
1862 unsigned int* p=(unsigned int*)surface->pixels;
1863 unsigned int* pCopy=p;
1864 unsigned int* paletteInt=(unsigned int*)cvPalette;
1865 unsigned char* pb=prioBuf;
1866 unsigned short y0=scrollY[0];
1867 unsigned short y1=scrollY[1];
1868 for (int i=0; i<224; i++) {
1869 rasterH(i);
1870
1871 unsigned short x0=scrollX[0]%stageWidthPx;
1872 unsigned short x1=scrollX[1]%stageWidthPx;
1873
1874 y0%=stageHeightPx;
1875 y1%=stageHeightPx;
1876
1877 for (int j=0; j<320; j++) {
1878 unsigned short t0=tile0[y0>>3][x0>>3]&0xfff;
1879 unsigned short t1=tile1[y1>>3][x1>>3]&0xfff;
1880
1881 unsigned char td0=tileData[((t0&31)<<3)|(x0&7)|((t0&(~31))<<6)|((y0&7)<<8)];
1882 unsigned char td1=tileData[((t1&31)<<3)|(x1&7)|((t1&(~31))<<6)|((y1&7)<<8)];
1883
1884 if (td1) {
1885 *p++=paletteInt[td1];
1886 *pb++=2;
1887 } else if (td0) {
1888 *p++=paletteInt[td0];
1889 *pb++=1;
1890 } else {
1891 *p++=paletteInt[bgColor];
1892 *pb++=0;
1893 }
1894
1895 if (++x0>=stageWidthPx) x0=0;
1896 if (++x1>=stageWidthPx) x1=0;
1897 }
1898
1899 y0++;
1900 y1++;
1901 }
1902
1903 // draw sprites
1904 p=pCopy;
1905 for (FurnaceCVObject* i: sprite) {
1906 int jk=0;
1907 for (int j=0; j<i->spriteHeight; j++) {
1908 for (int k=0; k<i->spriteWidth; k++) {
1909 int dx=i->x-viewX+(k<<3);
1910 int dy=i->y-viewY+(j<<3);
1911 int ptr=dx+dy*320;
1912 int ptrC=ptr;
1913 unsigned short spriteTile=i->spriteDef[jk];
1914 for (int l=0; l<8; l++) {
1915 dx=i->x-viewX+(k<<3);
1916 if (dy>=0 && dy<224) for (int m=0; m<8; m++) {
1917 if (dx>=0 && dx<320) {
1918 unsigned char data=tileData[((spriteTile&31)<<3)|m|((spriteTile&(~31))<<6)|(l<<8)];
1919 if (data) {
1920 if (i->prio>=prioBuf[ptr]) {
1921 p[ptr]=paletteInt[data];
1922 }
1923 }
1924 }
1925 dx++;
1926 ptr++;
1927 }
1928 dy++;
1929 ptrC+=320;
1930 ptr=ptrC;
1931 }
1932 jk++;
1933 }
1934 }
1935 }
1936
1937 SDL_UnlockSurface(surface);
1938 }
1939
1940 void FurnaceCV::addScore(int amount) {
1941 score+=amount;
1942 if (score>=99999999) score=99999999;
1943 if (score>hiScore) {
1944 hiScore=score;
1945 newHiScore=true;
1946 }
1947 }
1948
1949 void _tileDataRead(void* user, struct GIF_WHDR* data) {
1950 ((FurnaceCV*)user)->tileDataRead(data);
1951 }
1952
1953 void FurnaceCV::tileDataRead(struct GIF_WHDR* data) {
1954 logV("got tile: %d %d",data->xdim,data->ydim);
1955 logV("frd: %d %d fro: %d %d",data->frxd,data->fryd,data->frxo,data->fryo);
1956 memcpy(tileData,data->bptr,data->xdim*data->ydim);
1957 }
1958
1959
1960 bool FurnaceCV::init(DivEngine* eng) {
1961 e=eng;
1962
1963 tileData=new unsigned char[8*8*4096];
1964 memset(tileData,0,8*8*4096);
1965 GIF_Load((void*)tileDataC,tileDataC_len,_tileDataRead,NULL,this,0);
1966
1967 surface=SDL_CreateRGBSurfaceWithFormat(0,320,224,32,SDL_PIXELFORMAT_ARGB8888);
1968 if (surface==NULL) {
1969 logE("FurnaceCV: couldn't create surface!");
1970 return false;
1971 }
1972
1973 prioBuf=new unsigned char[320*224];
1974 memset(prioBuf,0,320*224);
1975
1976 loadInstruments();
1977
1978 return true;
1979 }
1980
1981 void FurnaceCV::unload() {
1982 SDL_FreeSurface(surface);
1983 delete[] tileData;
1984 delete[] prioBuf;
1985
1986 if (fxInsBase>=0) {
1987 for (int i=e->song.insLen-1; i>=fxInsBase; i--) {
1988 e->delInstrument(i);
1989 }
1990 }
1991 if (fxChanBase>=0) {
1992 e->removeSystem(e->song.systemLen-1);
1993 }
1994 e->setSongRate(origSongRate);
1995
1996 if (curStage!=NULL) {
1997 delete[] curStage;
1998 curStage=NULL;
1999 }
2000 }
2001
2002 #define IS_VISIBLE ((x-cv->viewX+(spriteWidth<<3))>=0 && (x-cv->viewX)<320 && (y-cv->viewY+(spriteHeight<<3))>=0 && (y-cv->viewY)<224)
2003 #define IS_IN_AREA ((x+(spriteWidth<<3))>=0 && (x)<cv->stageWidthPx && (y+(spriteHeight<<3))>=0 && (y)<cv->stageHeightPx)
2004 #define HITS_BORDER (x<0 || y<0 || (x+(spriteWidth<<3))>=cv->stageWidthPx || (y+(spriteHeight<<3))>=cv->stageHeightPx)
2005 #define CONFINE_TO_BORDER \
2006 if (x<0) x=0; \
2007 if (y<0) y=0; \
2008 if ((x+(spriteWidth<<3))>=cv->stageWidthPx) x=(cv->stageWidthPx-1)-(spriteWidth<<3); \
2009 if ((y+(spriteHeight<<3))>=cv->stageHeightPx) y=(cv->stageHeightPx-1)-(spriteHeight<<3);
2010
2011 // FurnaceCVPlayer IMPLEMENTATION
2012
2013 void FurnaceCVPlayer::collision(FurnaceCVObject* other) {
2014 if (other->type==CV_ENEMY_BULLET ||
2015 other->type==CV_MINE ||
2016 other->type==CV_ENEMY) {
2017 bool mustDie=!invincible;
2018
2019 if (other->type==CV_ENEMY_BULLET) {
2020 const int diffX=abs((other->x+4)-(x+12));
2021 const int diffY=abs((other->y+4)-(y+12));
2022 if (diffX>4 || diffY>4) mustDie=false;
2023 }
2024
2025 if (mustDie) {
2026 dead=true;
2027 cv->speedTicks=0;
2028 cv->e->setSongRate(cv->origSongRate);
2029 cv->respawnTime=48;
2030 cv->specialType=0;
2031 if (cv->weaponStack.empty()) {
2032 cv->shotType=0;
2033 } else {
2034 cv->shotType=cv->weaponStack.front();
2035 cv->weaponStack.pop_front();
2036 }
2037 cv->soundEffect(SE_DEATH_C1);
2038 cv->soundEffect(SE_DEATH_C2);
2039 cv->createObject<FurnaceCVExplMedium>(x-8,y);
2040 cv->createObject<FurnaceCVExplMedium>(x+8,y);
2041 cv->createObject<FurnaceCVExplMedium>(x,y-8);
2042 cv->createObject<FurnaceCVExplMedium>(x,y+8);
2043 cv->createObject<FurnaceCVExplMedium>(x,y);
2044 } else if (other->type==CV_ENEMY || other->type==CV_MINE) {
2045 cv->soundEffect(SE_EXPL1);
2046 }
2047 }
2048 }
2049
2050 static const int shootDirOffsX[8]={
2051 16, 16, 8, 0, 0, 0, 8, 16
2052 };
2053
2054 static const int shootDirOffsY[8]={
2055 8, 0, 0, 0, 8, 16, 16, 16
2056 };
2057
2058 static const int shootDirOrient[8]={
2059 0x80, 0, 0, 0, 0x180, 0x100, 0x100, 0x100
2060 };
2061
2062 void FurnaceCVPlayer::tick() {
2063 signed char sdX=0;
2064 signed char sdY=0;
2065
2066 int maxSpeed=(cv->speedTicks>0)?128:64;
2067 int maxSpeedDiagonal=(cv->speedTicks>0)?90:45;
2068
2069 if (cv->joyInput&16) {
2070 speedY-=12;
2071 sdY=-1;
2072 if (speedY<-maxSpeed) speedY=-maxSpeed;
2073 } else if (cv->joyInput&32) {
2074 speedY+=12;
2075 sdY=1;
2076 if (speedY>maxSpeed) speedY=maxSpeed;
2077 } else {
2078 if (speedY>0) {
2079 speedY-=12;
2080 if (speedY<0) speedY=0;
2081 } else if (speedY<0) {
2082 speedY+=12;
2083 if (speedY>0) speedY=0;
2084 }
2085 }
2086 if (cv->joyInput&64) {
2087 speedX-=12;
2088 sdX=-1;
2089 if (speedX<-maxSpeed) speedX=-maxSpeed;
2090 } else if (cv->joyInput&128) {
2091 speedX+=12;
2092 sdX=1;
2093 if (speedX>maxSpeed) speedX=maxSpeed;
2094 } else {
2095 if (speedX>0) {
2096 speedX-=12;
2097 if (speedX<0) speedX=0;
2098 } else if (speedX<0) {
2099 speedX+=12;
2100 if (speedX>0) speedX=0;
2101 }
2102 }
2103
2104 // sqrt(2)
2105 if (speedX && speedY) {
2106 if (speedX>maxSpeedDiagonal) speedX=maxSpeedDiagonal;
2107 if (speedX<-maxSpeedDiagonal) speedX=-maxSpeedDiagonal;
2108 if (speedY>maxSpeedDiagonal) speedY=maxSpeedDiagonal;
2109 if (speedY<-maxSpeedDiagonal) speedY=-maxSpeedDiagonal;
2110 }
2111
2112 subX+=speedX;
2113 while (subX>=32) {
2114 x++;
2115 subX-=32;
2116 }
2117 while (subX<0) {
2118 x--;
2119 subX+=32;
2120 }
2121
2122 subY+=speedY;
2123 while (subY>=32) {
2124 y++;
2125 subY-=32;
2126 }
2127 while (subY<0) {
2128 y--;
2129 subY+=32;
2130 }
2131
2132 if (HITS_BORDER) {
2133 CONFINE_TO_BORDER;
2134 }
2135
2136 cv->lastPlayerX=x;
2137 cv->lastPlayerY=y;
2138
2139 if (sdX>0 && sdY>0) shootDir=7;
2140 if (sdX>0 && sdY<0) shootDir=1;
2141 if (sdX<0 && sdY>0) shootDir=5;
2142 if (sdX<0 && sdY<0) shootDir=3;
2143 if (sdX<0 && sdY==0) shootDir=4;
2144 if (sdX>0 && sdY==0) shootDir=0;
2145 if (sdX==0 && sdY<0) shootDir=2;
2146 if (sdX==0 && sdY>0) shootDir=6;
2147
2148 if (cv->joyPressed&1) {
2149 shotTimer=(cv->shotType==2)?5:9;
2150 if (cv->speedTicks>0) {
2151 shotTimer=(cv->shotType==2)?2:4;
2152 }
2153 if (cv->shotType==1) {
2154 cv->soundEffect(SE_SHOT2);
2155 } else {
2156 cv->soundEffect(SE_SHOT1);
2157 }
2158 FurnaceCVBullet* b;
2159
2160 b=cv->createObject<FurnaceCVBullet>(x+shootDirOffsX[shootDir],y+shootDirOffsY[shootDir]);
2161 b->orient=shootDir;
2162 b->setType((cv->shotType==1)?1:0);
2163 switch (shootDir) {
2164 case 0:
2165 case 1:
2166 case 7:
2167 b->speedX=160;
2168 break;
2169 case 3:
2170 case 4:
2171 case 5:
2172 b->speedX=-160;
2173 break;
2174 default:
2175 b->speedX=0;
2176 break;
2177 }
2178 switch (shootDir) {
2179 case 1:
2180 case 2:
2181 case 3:
2182 b->speedY=-160;
2183 break;
2184 case 5:
2185 case 6:
2186 case 7:
2187 b->speedY=160;
2188 break;
2189 default:
2190 b->speedY=0;
2191 break;
2192 }
2193
2194 if (doubleShot) {
2195 b=cv->createObject<FurnaceCVBullet>(x+shootDirOffsX[((shootDir+4)&7)],y+shootDirOffsY[((shootDir+4)&7)]);
2196 b->orient=((shootDir+4)&7);
2197 b->setType((cv->shotType==1)?1:0);
2198 switch (((shootDir+4)&7)) {
2199 case 0:
2200 case 1:
2201 case 7:
2202 b->speedX=160;
2203 break;
2204 case 3:
2205 case 4:
2206 case 5:
2207 b->speedX=-160;
2208 break;
2209 default:
2210 b->speedX=0;
2211 break;
2212 }
2213 switch (((shootDir+4)&7)) {
2214 case 1:
2215 case 2:
2216 case 3:
2217 b->speedY=-160;
2218 break;
2219 case 5:
2220 case 6:
2221 case 7:
2222 b->speedY=160;
2223 break;
2224 default:
2225 b->speedY=0;
2226 break;
2227 }
2228 }
2229 }
2230
2231 if (cv->joyInput&1) {
2232 if (--shotTimer<1) {
2233 shotTimer=(cv->shotType==2)?4:8;
2234 if (cv->speedTicks>0) {
2235 shotTimer=(cv->shotType==2)?1:3;
2236 }
2237 if (cv->shotType==1) {
2238 cv->soundEffect(SE_SHOT2);
2239 } else {
2240 cv->soundEffect(SE_SHOT1);
2241 }
2242
2243 FurnaceCVBullet* b;
2244
2245 b=cv->createObject<FurnaceCVBullet>(x+shootDirOffsX[shootDir],y+shootDirOffsY[shootDir]);
2246 b->orient=shootDir;
2247 b->setType((cv->shotType==1)?1:0);
2248 switch (shootDir) {
2249 case 0:
2250 case 1:
2251 case 7:
2252 b->speedX=160;
2253 break;
2254 case 3:
2255 case 4:
2256 case 5:
2257 b->speedX=-160;
2258 break;
2259 default:
2260 b->speedX=0;
2261 break;
2262 }
2263 switch (shootDir) {
2264 case 1:
2265 case 2:
2266 case 3:
2267 b->speedY=-160;
2268 break;
2269 case 5:
2270 case 6:
2271 case 7:
2272 b->speedY=160;
2273 break;
2274 default:
2275 b->speedY=0;
2276 break;
2277 }
2278
2279 if (cv->shotType==2) {
2280 b->speedX+=(rand()%64)-32;
2281 b->speedY+=(rand()%64)-32;
2282 }
2283
2284 if (doubleShot) {
2285 b=cv->createObject<FurnaceCVBullet>(x+shootDirOffsX[((shootDir+4)&7)],y+shootDirOffsY[((shootDir+4)&7)]);
2286 b->orient=((shootDir+4)&7);
2287 b->setType((cv->shotType==1)?1:0);
2288 switch (((shootDir+4)&7)) {
2289 case 0:
2290 case 1:
2291 case 7:
2292 b->speedX=160;
2293 break;
2294 case 3:
2295 case 4:
2296 case 5:
2297 b->speedX=-160;
2298 break;
2299 default:
2300 b->speedX=0;
2301 break;
2302 }
2303 switch (((shootDir+4)&7)) {
2304 case 1:
2305 case 2:
2306 case 3:
2307 b->speedY=-160;
2308 break;
2309 case 5:
2310 case 6:
2311 case 7:
2312 b->speedY=160;
2313 break;
2314 default:
2315 b->speedY=0;
2316 break;
2317 }
2318
2319 if (cv->shotType==2) {
2320 b->speedX+=(rand()%64)-32;
2321 b->speedY+=(rand()%64)-32;
2322 }
2323 }
2324 }
2325 }
2326
2327 if (cv->joyPressed&2) {
2328 if (cv->specialType>0) {
2329 switch (cv->specialType) {
2330 case 1: // ?
2331 switch (rand()%30) {
2332 case 0: case 1: case 2: case 3: case 4:
2333 case 5: case 6: case 7: case 8: case 9: // spawn enemies
2334 for (int i=0; i<10; i++) {
2335 FurnaceCVEnemy1* obj=cv->createObject<FurnaceCVEnemy1>((rand()%(cv->stageWidth-4))<<3,(rand()%(cv->stageHeight-4))<<3);
2336 obj->setType(rand()%2);
2337 }
2338 invincible+=60;
2339 cv->soundEffect(SE_DEATH_C1);
2340 break;
2341 case 10: case 11: case 12: case 13: // downgrade enemies
2342 for (FurnaceCVObject* i: cv->sprite) {
2343 if (i->type==CV_ENEMY) {
2344 if (((FurnaceCVEnemy*)i)->enemyType>0) {
2345 if (((FurnaceCVEnemy*)i)->enemyType>1) {
2346 cv->createObject<FurnaceCVFurBallLarge>(i->x-4,i->y-4);
2347 } else {
2348 cv->createObject<FurnaceCVFurBallMedium>(i->x-4,i->y-4);
2349 }
2350 if (((FurnaceCVEnemy*)i)->enemyType==2) {
2351 i->x+=8;
2352 i->y+=8;
2353 }
2354 ((FurnaceCVEnemy*)i)->setType(((FurnaceCVEnemy*)i)->enemyType-1);
2355 }
2356 }
2357 }
2358 cv->soundEffect(SE_EXPL2);
2359 break;
2360 case 14: case 15: case 16: // teleport
2361 cv->createObject<FurnaceCVFurBallLarge>(x-4,y-4);
2362 invincible=120;
2363 x=(rand()%(cv->stageWidth-2))<<3;
2364 y=(rand()%(cv->stageHeight-2))<<3;
2365 cv->createObject<FurnaceCVFurBallLarge>(x-4,y-4);
2366 cv->soundEffect(SE_INIT);
2367 for (FurnaceCVObject* i: cv->sprite) {
2368 if (i->type==CV_ENEMY_BULLET) {
2369 i->dead=true;
2370 }
2371 }
2372 break;
2373 case 17: case 18: case 19: // stop enemies
2374 for (FurnaceCVObject* i: cv->sprite) {
2375 if (i->type==CV_ENEMY) {
2376 ((FurnaceCVEnemy*)i)->stopped=true;
2377 }
2378 }
2379 cv->soundEffect(SE_TIMEUP);
2380 break;
2381 case 20: case 21: case 22: // speed + invincible
2382 invincible=600;
2383 cv->speedTicks=900;
2384 cv->soundEffect(SE_PICKUP3);
2385 break;
2386 case 23: case 24: // purple tank
2387 for (int i=0; i<6; i++) {
2388 FurnaceCVEnemy1* obj=cv->createObject<FurnaceCVEnemy1>((rand()%(cv->stageWidth-3))<<3,(rand()%(cv->stageHeight-3))<<3);
2389 obj->setType(3);
2390 }
2391 invincible+=60;
2392 cv->soundEffect(SE_DEATH_C1);
2393 break;
2394 case 25: case 26: // vortex
2395 for (int i=0; i<12; i++) {
2396 cv->createObject<FurnaceCVEnemyVortex>((rand()%(cv->stageWidth-2))<<3,(rand()%(cv->stageHeight-2))<<3);
2397 }
2398 invincible+=60;
2399 cv->soundEffect(SE_DEATH_C1);
2400 break;
2401 case 27: // next level
2402 for (FurnaceCVObject* i: cv->sprite) {
2403 if (i->type==CV_ENEMY) {
2404 i->dead=true;
2405 }
2406 }
2407 break;
2408 case 28: // 5-up
2409 cv->soundEffect(SE_PICKUP1);
2410 cv->lives+=5;
2411 break;
2412 case 29: // plane
2413 for (int i=0; i<6; i++) {
2414 cv->createObjectNoPos<FurnaceCVEnemyPlane>();
2415 }
2416 cv->soundEffect(SE_TIMEUP);
2417 break;
2418 }
2419 break;
2420 case 2: // T
2421 cv->createObject<FurnaceCVFurBallLarge>(x-4,y-4);
2422 invincible=120;
2423 x=(rand()%(cv->stageWidth-2))<<3;
2424 y=(rand()%(cv->stageHeight-2))<<3;
2425 cv->createObject<FurnaceCVFurBallLarge>(x-4,y-4);
2426 cv->soundEffect(SE_INIT);
2427 for (FurnaceCVObject* i: cv->sprite) {
2428 if (i->type==CV_ENEMY_BULLET) {
2429 i->dead=true;
2430 }
2431 }
2432 break;
2433 case 3: { // X
2434 for (int i=0; i<64; i++) {
2435 FurnaceCVBullet* b=cv->createObject<FurnaceCVBullet>(x+4,y+4);
2436 b->orient=(-i>>3)&7;
2437 b->setType(1);
2438 b->speedX=120*cos(M_PI*((float)i/32.0));
2439 b->speedY=120*sin(M_PI*((float)i/32.0));
2440 }
2441 cv->soundEffect(SE_SHOT2);
2442 break;
2443 }
2444 case 4: // W
2445 doubleShot=true;
2446 cv->soundEffect(SE_PICKUP3);
2447 break;
2448 case 5: // S
2449 for (FurnaceCVObject* i: cv->sprite) {
2450 if (i->type==CV_ENEMY) {
2451 i->frozen=600;
2452 }
2453 }
2454 cv->soundEffect(SE_TIMEUP);
2455 break;
2456 }
2457 cv->specialType=0;
2458 }
2459 }
2460
2461 if (invincible>0) {
2462 invincible--;
2463 }
2464
2465 if (invincible&1) {
2466 memset(spriteDef,0,9*sizeof(unsigned short));
2467 } else {
2468 spriteDef[0]=0x10+((animFrame>>6)<<2)+shootDirOrient[shootDir];
2469 spriteDef[1]=0x11+((animFrame>>6)<<2)+shootDirOrient[shootDir];
2470 spriteDef[2]=0x12+((animFrame>>6)<<2)+shootDirOrient[shootDir];
2471 spriteDef[3]=0x30+((animFrame>>6)<<2)+shootDirOrient[shootDir];
2472 spriteDef[4]=0x31+((animFrame>>6)<<2)+shootDirOrient[shootDir];
2473 spriteDef[5]=0x32+((animFrame>>6)<<2)+shootDirOrient[shootDir];
2474 spriteDef[6]=0x50+((animFrame>>6)<<2)+shootDirOrient[shootDir];
2475 spriteDef[7]=0x51+((animFrame>>6)<<2)+shootDirOrient[shootDir];
2476 spriteDef[8]=0x52+((animFrame>>6)<<2)+shootDirOrient[shootDir];
2477 }
2478
2479 animFrame+=MAX(fabs(speedX),fabs(speedY));
2480
2481 // camera
2482 cv->viewX=x-160+12;
2483 cv->viewY=y-112+12;
2484 if (cv->viewX<0) cv->viewX=0;
2485 if (cv->viewX>cv->stageWidthPx-320) cv->viewX=cv->stageWidthPx-320;
2486 if (cv->viewY<0) cv->viewY=0;
2487 if (cv->viewY>cv->stageHeightPx-224) cv->viewY=cv->stageHeightPx-224;
2488 cv->scrollX[0]=cv->viewX;
2489 cv->scrollY[0]=cv->viewY;
2490 }
2491
2492 // FurnaceCVBullet IMPLEMENTATION
2493
2494 void FurnaceCVBullet::setType(unsigned char t) {
2495 bulletType=t;
2496
2497 if (bulletType==1) {
2498 spriteWidth=2;
2499 spriteHeight=2;
2500
2501 switch (orient) {
2502 case 0:
2503 spriteDef[0]=0x496;
2504 spriteDef[1]=0x497;
2505 spriteDef[2]=0x4b6;
2506 spriteDef[3]=0x4b7;
2507 break;
2508 case 1:
2509 spriteDef[0]=0x49c;
2510 spriteDef[1]=0x49d;
2511 spriteDef[2]=0x4bc;
2512 spriteDef[3]=0x4bd;
2513 break;
2514 case 2:
2515 spriteDef[0]=0x494;
2516 spriteDef[1]=0x495;
2517 spriteDef[2]=0x4b4;
2518 spriteDef[3]=0x4b5;
2519 break;
2520 case 3:
2521 spriteDef[0]=0x45e;
2522 spriteDef[1]=0x45f;
2523 spriteDef[2]=0x47e;
2524 spriteDef[3]=0x47f;
2525 break;
2526 case 4:
2527 spriteDef[0]=0x49a;
2528 spriteDef[1]=0x49b;
2529 spriteDef[2]=0x4ba;
2530 spriteDef[3]=0x4bb;
2531 break;
2532 case 5:
2533 spriteDef[0]=0x45c;
2534 spriteDef[1]=0x45d;
2535 spriteDef[2]=0x47c;
2536 spriteDef[3]=0x47d;
2537 break;
2538 case 6:
2539 spriteDef[0]=0x498;
2540 spriteDef[1]=0x499;
2541 spriteDef[2]=0x4b8;
2542 spriteDef[3]=0x4b9;
2543 break;
2544 case 7:
2545 spriteDef[0]=0x49e;
2546 spriteDef[1]=0x49f;
2547 spriteDef[2]=0x4be;
2548 spriteDef[3]=0x4bf;
2549 break;
2550 }
2551
2552 collX0=0;
2553 collX1=15;
2554 collY0=0;
2555 collY1=15;
2556
2557 life=11;
2558 }
2559 }
2560
2561 void FurnaceCVBullet::killBullet() {
2562 if (bulletType==1) {
2563 cv->soundEffect(SE_EXPL1);
2564 FurnaceCVBullet* b1=cv->createObject<FurnaceCVBullet>(x+4,y+4);
2565 FurnaceCVBullet* b2=cv->createObject<FurnaceCVBullet>(x+4,y+4);
2566 FurnaceCVBullet* b3=cv->createObject<FurnaceCVBullet>(x+4,y+4);
2567 switch (orient) {
2568 case 0:
2569 b1->speedX=240;
2570 b1->speedY=-100;
2571 b2->speedX=240;
2572 b2->speedY=0;
2573 b3->speedX=240;
2574 b3->speedY=100;
2575 break;
2576 case 1:
2577 b1->speedX=130;
2578 b1->speedY=-170;
2579 b2->speedX=170;
2580 b2->speedY=-170;
2581 b3->speedX=170;
2582 b3->speedY=-130;
2583 break;
2584 case 2:
2585 b1->speedX=-100;
2586 b1->speedY=-240;
2587 b2->speedX=0;
2588 b2->speedY=-240;
2589 b3->speedX=100;
2590 b3->speedY=-240;
2591 break;
2592 case 3:
2593 b1->speedX=-130;
2594 b1->speedY=-170;
2595 b2->speedX=-170;
2596 b2->speedY=-170;
2597 b3->speedX=-170;
2598 b3->speedY=-130;
2599 break;
2600 case 4:
2601 b1->speedX=-240;
2602 b1->speedY=-100;
2603 b2->speedX=-240;
2604 b2->speedY=0;
2605 b3->speedX=-240;
2606 b3->speedY=100;
2607 break;
2608 case 5:
2609 b1->speedX=-130;
2610 b1->speedY=170;
2611 b2->speedX=-170;
2612 b2->speedY=170;
2613 b3->speedX=-170;
2614 b3->speedY=130;
2615 break;
2616 case 6:
2617 b1->speedX=-100;
2618 b1->speedY=240;
2619 b2->speedX=0;
2620 b2->speedY=240;
2621 b3->speedX=100;
2622 b3->speedY=240;
2623 break;
2624 case 7:
2625 b1->speedX=130;
2626 b1->speedY=170;
2627 b2->speedX=170;
2628 b2->speedY=170;
2629 b3->speedX=170;
2630 b3->speedY=130;
2631 break;
2632 }
2633 b1->orient=orient;
2634 b2->orient=orient;
2635 b3->orient=orient;
2636 cv->createObject<FurnaceCVExplMedium>(x-8,y-8);
2637 } else {
2638 cv->createObject<FurnaceCVExplTiny>(x,y);
2639 }
2640 }
2641
2642 void FurnaceCVBullet::collision(FurnaceCVObject* other) {
2643 if (other->type==CV_ENEMY || other->type==CV_MINE) {
2644 dead=true;
2645 killBullet();
2646 }
2647 }
2648
2649 void FurnaceCVBullet::tick() {
2650 subX+=speedX;
2651 while (subX>=32) {
2652 x++;
2653 subX-=32;
2654 }
2655 while (subX<0) {
2656 x--;
2657 subX+=32;
2658 }
2659
2660 subY+=speedY;
2661 while (subY>=32) {
2662 y++;
2663 subY-=32;
2664 }
2665 while (subY<0) {
2666 y--;
2667 subY+=32;
2668 }
2669
2670 if (life>0) {
2671 if (--life<=0) {
2672 dead=true;
2673 killBullet();
2674 }
2675 }
2676
2677 if (!IS_IN_AREA) {
2678 dead=true;
2679 }
2680 }
2681
2682 // FurnaceCVEnemyBullet IMPLEMENTATION
2683
2684 void FurnaceCVEnemyBullet::setType(unsigned char type) {
2685 bulletType=type;
2686 }
2687
2688 void FurnaceCVEnemyBullet::tick() {
2689 subX+=speedX;
2690 while (subX>=32) {
2691 x++;
2692 subX-=32;
2693 }
2694 while (subX<0) {
2695 x--;
2696 subX+=32;
2697 }
2698
2699 subY+=speedY;
2700 while (subY>=32) {
2701 y++;
2702 subY-=32;
2703 }
2704 while (subY<0) {
2705 y--;
2706 subY+=32;
2707 }
2708
2709 if (bulletType==1) {
2710 animFrame+=10+(rand()%12);
2711 spriteDef[0]=0x28+(animFrame>>6);
2712 }
2713
2714 if (!IS_IN_AREA) {
2715 dead=true;
2716 }
2717 }
2718
2719 // FurnaceCVEnemy1 IMPLEMENTATION
2720
2721 void FurnaceCVEnemy1::collision(FurnaceCVObject* other) {
2722 if (other->type==CV_BULLET || other->type==CV_PLAYER) {
2723 if (--health<=0) {
2724 dead=true;
2725 if ((rand()%7)==0 || (enemyType>1 && (rand()%3)==2)) {
2726 switch (rand()%14) {
2727 case 0: // extra life
2728 cv->createObject<FurnaceCVExtraLife>(x+(enemyType>=2?8:0),y+(enemyType>=2?8:0));
2729 break;
2730 case 1: case 2: case 3: case 4: // powerup
2731 cv->createObject<FurnaceCVPowerupP>(x+(enemyType>=2?8:0),y+(enemyType>=2?8:0));
2732 break;
2733 case 5: case 6: case 7: case 8: case 9: // powerup
2734 cv->createObject<FurnaceCVPowerupS>(x+(enemyType>=2?8:0),y+(enemyType>=2?8:0));
2735 break;
2736 case 10: case 11: // special
2737 cv->createObject<FurnaceCVSpecial>(x+(enemyType>=2?8:0),y+(enemyType>=2?8:0));
2738 break;
2739 case 12: // mod
2740 cv->createObject<FurnaceCVModS>(x+(enemyType>=2?8:0),y+(enemyType>=2?8:0));
2741 break;
2742 case 13: // mod
2743 cv->createObject<FurnaceCVModI>(x+(enemyType>=2?8:0),y+(enemyType>=2?8:0));
2744 break;
2745 }
2746 }
2747 cv->soundEffect(SE_EXPL1);
2748 switch (enemyType) {
2749 case 0:
2750 cv->createObject<FurnaceCVExplMedium>(x-4,y-4);
2751 cv->addScore(100);
2752 break;
2753 case 1:
2754 cv->createObject<FurnaceCVExplMedium>(x-4,y-4);
2755 cv->addScore(200);
2756 break;
2757 case 2:
2758 cv->createObject<FurnaceCVExplMedium>(x-8,y);
2759 cv->createObject<FurnaceCVExplMedium>(x+8,y);
2760 cv->createObject<FurnaceCVExplMedium>(x,y-8);
2761 cv->createObject<FurnaceCVExplMedium>(x,y+8);
2762 cv->createObject<FurnaceCVExplMedium>(x,y);
2763 cv->addScore(400);
2764 break;
2765 case 3:
2766 cv->createObject<FurnaceCVExplMedium>(x-8,y);
2767 cv->createObject<FurnaceCVExplMedium>(x+8,y);
2768 cv->createObject<FurnaceCVExplMedium>(x,y-8);
2769 cv->createObject<FurnaceCVExplMedium>(x,y+8);
2770 cv->createObject<FurnaceCVExplMedium>(x,y);
2771 cv->addScore(800);
2772 break;
2773 }
2774 } else {
2775 cv->soundEffect(SE_RESIST);
2776 }
2777 } else if (other->type==CV_ENEMY || other->type==CV_MINE) {
2778 // reorient
2779 orientCount+=2;
2780 if (orientCount>6) {
2781 // stuck...
2782 stopped=true;
2783 cv->stopSoundEffect(SE_TANKMOVE);
2784 } else {
2785 orient=(orient+2)&3;
2786 }
2787 }
2788 }
2789
2790 void FurnaceCVEnemy1::tick() {
2791 if (frozen>0) {
2792 if (--frozen>0) return;
2793 }
2794
2795 if (!stopped) {
2796 switch (orient) {
2797 case 0:
2798 x+=MAX(1,enemyType);
2799 break;
2800 case 1:
2801 y-=MAX(1,enemyType);
2802 break;
2803 case 2:
2804 x-=MAX(1,enemyType);
2805 break;
2806 case 3:
2807 y+=MAX(1,enemyType);
2808 break;
2809 }
2810 animFrame+=0x15;
2811 }
2812
2813 if (--orientCount<=0) orientCount=0;
2814
2815 if (--nextTime==0) {
2816 nextTime=64+(rand()%600);
2817
2818 stopped=((rand()%10)==0);
2819 if (stopped) {
2820 nextTime>>=2;
2821 cv->stopSoundEffect(SE_TANKMOVE);
2822 } else {
2823 unsigned char oldOrient=orient;
2824 orient=rand()&3;
2825 if (orient==oldOrient) orient=(orient+1)&3;
2826 cv->soundEffect(SE_TANKMOVE);
2827 }
2828 }
2829
2830 if (shootCooldown>64) {
2831 shootCooldown+=16*(enemyType+1);
2832 } else if (--shootTime==0) {
2833 shootTime=(enemyType>=2)?4:8;
2834 for (FurnaceCVObject* i: cv->sprite) {
2835 if (i->type==CV_PLAYER) {
2836 float dist=sqrt(pow((y+8)-(i->y+12),2.0)+pow((i->x+12)-(x+8),2.0));
2837 float angle=atan2((y+8)-(i->y+12),(i->x+12)-(x+8))/(M_PI*0.5);
2838 if (angle<0.0) angle+=4.0;
2839 float angleDelta=angle-(float)orient;
2840 if (angleDelta>=2.0) angleDelta-=4.0;
2841 if (angleDelta<-2.0) angleDelta+=4.0;
2842 if (fabs(angleDelta)<0.3 && dist<256.0 && IS_VISIBLE) {
2843 cv->soundEffect(SE_SHOT1);
2844 shootCooldown+=16-enemyType*2;
2845 FurnaceCVEnemyBullet* b=cv->createObject<FurnaceCVEnemyBullet>(x+(enemyType>=2?8:4),y+(enemyType>=2?8:4));
2846 switch (orient) {
2847 case 0:
2848 b->speedX=160;
2849 break;
2850 case 1:
2851 b->speedY=-160;
2852 break;
2853 case 2:
2854 b->speedX=-160;
2855 break;
2856 case 3:
2857 b->speedY=160;
2858 break;
2859 }
2860
2861 if (enemyType>0) {
2862 b->speedX+=(rand()%64)-32;
2863 b->speedY+=(rand()%64)-32;
2864 }
2865 }
2866 break;
2867 }
2868 }
2869 }
2870
2871 if (HITS_BORDER) {
2872 orient=(orient+2)&3;
2873
2874 CONFINE_TO_BORDER;
2875 }
2876
2877 if (enemyType>=2) {
2878 spriteWidth=3;
2879 spriteHeight=3;
2880 collX1=23;
2881 collY1=23;
2882 switch (orient) {
2883 case 0:
2884 spriteDef[0]=0x300+((animFrame>>7)<<2)+(enemyType==3?8:0);
2885 spriteDef[1]=0x301+((animFrame>>7)<<2)+(enemyType==3?8:0);
2886 spriteDef[2]=0x302+((animFrame>>7)<<2)+(enemyType==3?8:0);
2887 spriteDef[3]=0x320+((animFrame>>7)<<2)+(enemyType==3?8:0);
2888 spriteDef[4]=0x321+((animFrame>>7)<<2)+(enemyType==3?8:0);
2889 spriteDef[5]=0x322+((animFrame>>7)<<2)+(enemyType==3?8:0);
2890 spriteDef[6]=0x340+((animFrame>>7)<<2)+(enemyType==3?8:0);
2891 spriteDef[7]=0x341+((animFrame>>7)<<2)+(enemyType==3?8:0);
2892 spriteDef[8]=0x342+((animFrame>>7)<<2)+(enemyType==3?8:0);
2893 break;
2894 case 1:
2895 spriteDef[0]=0x280+((animFrame>>7)<<2)+(enemyType==3?8:0);
2896 spriteDef[1]=0x281+((animFrame>>7)<<2)+(enemyType==3?8:0);
2897 spriteDef[2]=0x282+((animFrame>>7)<<2)+(enemyType==3?8:0);
2898 spriteDef[3]=0x2a0+((animFrame>>7)<<2)+(enemyType==3?8:0);
2899 spriteDef[4]=0x2a1+((animFrame>>7)<<2)+(enemyType==3?8:0);
2900 spriteDef[5]=0x2a2+((animFrame>>7)<<2)+(enemyType==3?8:0);
2901 spriteDef[6]=0x2c0+((animFrame>>7)<<2)+(enemyType==3?8:0);
2902 spriteDef[7]=0x2c1+((animFrame>>7)<<2)+(enemyType==3?8:0);
2903 spriteDef[8]=0x2c2+((animFrame>>7)<<2)+(enemyType==3?8:0);
2904 break;
2905 case 2:
2906 spriteDef[0]=0x400+((animFrame>>7)<<2)+(enemyType==3?8:0);
2907 spriteDef[1]=0x401+((animFrame>>7)<<2)+(enemyType==3?8:0);
2908 spriteDef[2]=0x402+((animFrame>>7)<<2)+(enemyType==3?8:0);
2909 spriteDef[3]=0x420+((animFrame>>7)<<2)+(enemyType==3?8:0);
2910 spriteDef[4]=0x421+((animFrame>>7)<<2)+(enemyType==3?8:0);
2911 spriteDef[5]=0x422+((animFrame>>7)<<2)+(enemyType==3?8:0);
2912 spriteDef[6]=0x440+((animFrame>>7)<<2)+(enemyType==3?8:0);
2913 spriteDef[7]=0x441+((animFrame>>7)<<2)+(enemyType==3?8:0);
2914 spriteDef[8]=0x442+((animFrame>>7)<<2)+(enemyType==3?8:0);
2915 break;
2916 case 3:
2917 spriteDef[0]=0x380+((animFrame>>7)<<2)+(enemyType==3?8:0);
2918 spriteDef[1]=0x381+((animFrame>>7)<<2)+(enemyType==3?8:0);
2919 spriteDef[2]=0x382+((animFrame>>7)<<2)+(enemyType==3?8:0);
2920 spriteDef[3]=0x3a0+((animFrame>>7)<<2)+(enemyType==3?8:0);
2921 spriteDef[4]=0x3a1+((animFrame>>7)<<2)+(enemyType==3?8:0);
2922 spriteDef[5]=0x3a2+((animFrame>>7)<<2)+(enemyType==3?8:0);
2923 spriteDef[6]=0x3c0+((animFrame>>7)<<2)+(enemyType==3?8:0);
2924 spriteDef[7]=0x3c1+((animFrame>>7)<<2)+(enemyType==3?8:0);
2925 spriteDef[8]=0x3c2+((animFrame>>7)<<2)+(enemyType==3?8:0);
2926 break;
2927 }
2928 } else {
2929 spriteWidth=2;
2930 spriteHeight=2;
2931 collX1=15;
2932 collY1=15;
2933 switch (orient) {
2934 case 0:
2935 spriteDef[0]=0x204+((animFrame>>7)<<1)+(enemyType==1?0x40:0);
2936 spriteDef[1]=0x205+((animFrame>>7)<<1)+(enemyType==1?0x40:0);
2937 spriteDef[2]=0x224+((animFrame>>7)<<1)+(enemyType==1?0x40:0);
2938 spriteDef[3]=0x225+((animFrame>>7)<<1)+(enemyType==1?0x40:0);
2939 break;
2940 case 1:
2941 spriteDef[0]=0x200+((animFrame>>7)<<1)+(enemyType==1?0x40:0);
2942 spriteDef[1]=0x201+((animFrame>>7)<<1)+(enemyType==1?0x40:0);
2943 spriteDef[2]=0x220+((animFrame>>7)<<1)+(enemyType==1?0x40:0);
2944 spriteDef[3]=0x221+((animFrame>>7)<<1)+(enemyType==1?0x40:0);
2945 break;
2946 case 2:
2947 spriteDef[0]=0x20c+((animFrame>>7)<<1)+(enemyType==1?0x40:0);
2948 spriteDef[1]=0x20d+((animFrame>>7)<<1)+(enemyType==1?0x40:0);
2949 spriteDef[2]=0x22c+((animFrame>>7)<<1)+(enemyType==1?0x40:0);
2950 spriteDef[3]=0x22d+((animFrame>>7)<<1)+(enemyType==1?0x40:0);
2951 break;
2952 case 3:
2953 spriteDef[0]=0x208+((animFrame>>7)<<1)+(enemyType==1?0x40:0);
2954 spriteDef[1]=0x209+((animFrame>>7)<<1)+(enemyType==1?0x40:0);
2955 spriteDef[2]=0x228+((animFrame>>7)<<1)+(enemyType==1?0x40:0);
2956 spriteDef[3]=0x229+((animFrame>>7)<<1)+(enemyType==1?0x40:0);
2957 break;
2958 }
2959 }
2960 }
2961
2962 void FurnaceCVEnemy::setType(unsigned char t) {
2963 enemyType=t;
2964 switch (enemyType) {
2965 case 0:
2966 health=1;
2967 break;
2968 case 1:
2969 health=2;
2970 break;
2971 case 2:
2972 health=8;
2973 break;
2974 case 3:
2975 health=14;
2976 break;
2977 }
2978 }
2979
2980 // FurnaceCVExplTiny IMPLEMENTATION
2981
2982 void FurnaceCVExplTiny::tick() {
2983 spriteDef[0]=8+(animFrame>>1);
2984
2985 if (animFrame>=4) {
2986 spriteDef[0]=0;
2987 dead=true;
2988 }
2989
2990 animFrame++;
2991 }
2992
2993 // FurnaceCVExplMedium IMPLEMENTATION
2994
2995 void FurnaceCVExplMedium::tick() {
2996 if ((animFrame/3)>=5) {
2997 memset(spriteDef,0,9*sizeof(unsigned short));
2998 dead=true;
2999 } else {
3000 spriteDef[0]=0x210+(animFrame/3)*3;
3001 spriteDef[1]=0x211+(animFrame/3)*3;
3002 spriteDef[2]=0x212+(animFrame/3)*3;
3003 spriteDef[3]=0x230+(animFrame/3)*3;
3004 spriteDef[4]=0x231+(animFrame/3)*3;
3005 spriteDef[5]=0x232+(animFrame/3)*3;
3006 spriteDef[6]=0x250+(animFrame/3)*3;
3007 spriteDef[7]=0x251+(animFrame/3)*3;
3008 spriteDef[8]=0x252+(animFrame/3)*3;
3009 }
3010
3011 animFrame++;
3012 }
3013
3014 // FurnaceCVFurBallMedium IMPLEMENTATION
3015
3016 void FurnaceCVFurBallMedium::tick() {
3017 if ((animFrame/3)>=4) {
3018 memset(spriteDef,0,9*sizeof(unsigned short));
3019 dead=true;
3020 } else {
3021 spriteDef[0]=0x410+(animFrame/3)*3;
3022 spriteDef[1]=0x411+(animFrame/3)*3;
3023 spriteDef[2]=0x412+(animFrame/3)*3;
3024 spriteDef[3]=0x430+(animFrame/3)*3;
3025 spriteDef[4]=0x431+(animFrame/3)*3;
3026 spriteDef[5]=0x432+(animFrame/3)*3;
3027 spriteDef[6]=0x450+(animFrame/3)*3;
3028 spriteDef[7]=0x451+(animFrame/3)*3;
3029 spriteDef[8]=0x452+(animFrame/3)*3;
3030 }
3031
3032 animFrame++;
3033 }
3034
3035 // FurnaceCVFurBallLarge IMPLEMENTATION
3036
3037 void FurnaceCVFurBallLarge::tick() {
3038 if ((animFrame/3)>=4) {
3039 memset(spriteDef,0,16*sizeof(unsigned short));
3040 dead=true;
3041 } else {
3042 for (int i=0; i<4; i++) {
3043 spriteDef[i<<2]=(i<<5)+0x390+((animFrame/3)<<2);
3044 spriteDef[1+(i<<2)]=(i<<5)+0x391+((animFrame/3)<<2);
3045 spriteDef[2+(i<<2)]=(i<<5)+0x392+((animFrame/3)<<2);
3046 spriteDef[3+(i<<2)]=(i<<5)+0x393+((animFrame/3)<<2);
3047 }
3048 }
3049
3050 animFrame++;
3051 }
3052
3053 // INSTRUMENTS
3054
3055 static const unsigned char __00_fui[] = {
3056 0x46, 0x49, 0x4e, 0x53, 0xc4, 0x00, 0x38, 0x00, 0x4e, 0x41, 0x06, 0x00,
3057 0x73, 0x68, 0x6f, 0x74, 0x31, 0x00, 0x4d, 0x41, 0x8c, 0x00, 0x08, 0x00,
3058 0x00, 0x0b, 0xff, 0xff, 0x00, 0x01, 0x00, 0x01, 0x0f, 0x0b, 0x09, 0x07,
3059 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, 0x01, 0x10, 0xff, 0xff, 0x00,
3060 0xc1, 0x00, 0x01, 0x42, 0x00, 0x00, 0x40, 0x48, 0x00, 0x00, 0x40, 0x3c,
3061 0x00, 0x00, 0x40, 0x36, 0x00, 0x00, 0x40, 0x32, 0x00, 0x00, 0x40, 0x2f,
3062 0x00, 0x00, 0x40, 0x28, 0x00, 0x00, 0x40, 0x24, 0x00, 0x00, 0x40, 0x21,
3063 0x00, 0x00, 0x40, 0x1f, 0x00, 0x00, 0x40, 0x1f, 0x00, 0x00, 0x40, 0x24,
3064 0x00, 0x00, 0x40, 0x24, 0x00, 0x00, 0x40, 0x24, 0x00, 0x00, 0x40, 0x24,
3065 0x00, 0x00, 0x40, 0x21, 0x00, 0x00, 0x40, 0x05, 0x01, 0xff, 0xff, 0x00,
3066 0x01, 0x00, 0x01, 0x01, 0x0e, 0x01, 0xff, 0xff, 0x00, 0x01, 0x00, 0x01,
3067 0x00, 0x0f, 0x01, 0xff, 0xff, 0x00, 0x01, 0x00, 0x01, 0x0d, 0x10, 0x01,
3068 0xff, 0xff, 0x00, 0x01, 0x00, 0x01, 0x0e, 0x13, 0x01, 0xff, 0xff, 0x00,
3069 0x81, 0x00, 0x01, 0xd8, 0x75, 0xff, 0x50, 0x4e, 0x01, 0x00, 0x03
3070 };
3071 static const unsigned int __00_fui_len = 167;
3072 static const unsigned char __01_fui[] = {
3073 0x46, 0x49, 0x4e, 0x53, 0xc4, 0x00, 0x38, 0x00, 0x4e, 0x41, 0x0c, 0x00,
3074 0x65, 0x78, 0x70, 0x6c, 0x31, 0x20, 0x28, 0x47, 0x2d, 0x35, 0x29, 0x00,
3075 0x4d, 0x41, 0xc5, 0x00, 0x08, 0x00, 0x00, 0x3a, 0xff, 0xff, 0x00, 0x01,
3076 0x00, 0x01, 0x0a, 0x0e, 0x0e, 0x0d, 0x0d, 0x0c, 0x0e, 0x0f, 0x09, 0x0e,
3077 0x0d, 0x0e, 0x0d, 0x0c, 0x0c, 0x0c, 0x0b, 0x0b, 0x0b, 0x0a, 0x0a, 0x0a,
3078 0x0a, 0x09, 0x09, 0x09, 0x08, 0x08, 0x08, 0x08, 0x08, 0x07, 0x07, 0x07,
3079 0x06, 0x06, 0x06, 0x06, 0x06, 0x05, 0x05, 0x05, 0x05, 0x04, 0x04, 0x04,
3080 0x03, 0x03, 0x03, 0x03, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00,
3081 0x01, 0x25, 0x06, 0xff, 0x00, 0x41, 0x00, 0x01, 0xf5, 0xe9, 0xe7, 0xe5,
3082 0xe4, 0x04, 0x03, 0xf9, 0xf4, 0x01, 0xfa, 0x03, 0xf3, 0xf2, 0x00, 0xf4,
3083 0x04, 0x05, 0xf8, 0x00, 0xf9, 0x01, 0xf9, 0xfc, 0xfc, 0xf7, 0x02, 0xff,
3084 0xf8, 0x04, 0x00, 0xf7, 0xf7, 0xff, 0xfa, 0x00, 0xfb, 0x05, 0x06, 0xff,
3085 0xff, 0x00, 0x01, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x0e,
3086 0x01, 0xff, 0xff, 0x00, 0x01, 0x00, 0x01, 0x01, 0x0f, 0x06, 0xff, 0xff,
3087 0x00, 0x01, 0x00, 0x01, 0x0a, 0x01, 0x01, 0x01, 0x01, 0x06, 0x10, 0x06,
3088 0xff, 0xff, 0x00, 0x01, 0x00, 0x01, 0x05, 0x04, 0x04, 0x04, 0x04, 0x0c,
3089 0x13, 0x06, 0xff, 0xff, 0x00, 0xc1, 0x00, 0x01, 0xad, 0x3a, 0x00, 0x00,
3090 0xaa, 0xaa, 0x00, 0x00, 0xaa, 0xaa, 0x00, 0x00, 0xaa, 0xaa, 0x00, 0x00,
3091 0xaa, 0xaa, 0x00, 0x00, 0x20, 0x21, 0x00, 0x00, 0xff, 0x50, 0x4e, 0x01,
3092 0x00, 0x00
3093 };
3094 static const unsigned int __01_fui_len = 230;
3095 static const unsigned char __02_fui[] = {
3096 0x46, 0x49, 0x4e, 0x53, 0xc4, 0x00, 0x38, 0x00, 0x4e, 0x41, 0x0e, 0x00,
3097 0x70, 0x69, 0x63, 0x6b, 0x75, 0x70, 0x31, 0x20, 0x28, 0x47, 0x2d, 0x35,
3098 0x29, 0x00, 0x4d, 0x41, 0x5d, 0x00, 0x08, 0x00, 0x00, 0x21, 0xff, 0xff,
3099 0x00, 0x01, 0x00, 0x01, 0x0f, 0x0f, 0x04, 0x04, 0x0c, 0x0c, 0x03, 0x03,
3100 0x0a, 0x0a, 0x02, 0x02, 0x08, 0x08, 0x01, 0x01, 0x06, 0x06, 0x06, 0x06,
3101 0x04, 0x04, 0x04, 0x04, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01,
3102 0x00, 0x01, 0x04, 0x00, 0xff, 0x00, 0x01, 0x00, 0x04, 0x00, 0x04, 0x07,
3103 0x0c, 0x05, 0x01, 0xff, 0xff, 0x00, 0x01, 0x00, 0x01, 0x00, 0x0e, 0x01,
3104 0xff, 0xff, 0x00, 0x01, 0x00, 0x01, 0x01, 0x0f, 0x01, 0xff, 0xff, 0x00,
3105 0x01, 0x00, 0x01, 0x01, 0x13, 0x01, 0xff, 0xff, 0x00, 0x81, 0x00, 0x01,
3106 0x55, 0x55, 0xff, 0x50, 0x4e, 0x01, 0x00, 0x00
3107 };
3108 static const unsigned int __02_fui_len = 128;
3109 static const unsigned char __03_fui[] = {
3110 0x46, 0x49, 0x4e, 0x53, 0xc4, 0x00, 0x38, 0x00, 0x4e, 0x41, 0x0e, 0x00,
3111 0x70, 0x69, 0x63, 0x6b, 0x75, 0x70, 0x32, 0x20, 0x28, 0x41, 0x2d, 0x35,
3112 0x29, 0x00, 0x4d, 0x41, 0x44, 0x00, 0x08, 0x00, 0x00, 0x0a, 0xff, 0xff,
3113 0x00, 0x01, 0x00, 0x01, 0x0f, 0x0e, 0x04, 0x0d, 0x0c, 0x03, 0x02, 0x02,
3114 0x01, 0x00, 0x01, 0x02, 0x00, 0xff, 0x00, 0x01, 0x00, 0x03, 0x00, 0x07,
3115 0x05, 0x01, 0xff, 0xff, 0x00, 0x01, 0x00, 0x01, 0x00, 0x0e, 0x01, 0xff,
3116 0xff, 0x00, 0x01, 0x00, 0x01, 0x01, 0x0f, 0x01, 0xff, 0xff, 0x00, 0x01,
3117 0x00, 0x01, 0x01, 0x13, 0x01, 0xff, 0xff, 0x00, 0x81, 0x00, 0x01, 0x55,
3118 0x55, 0xff, 0x50, 0x4e, 0x01, 0x00, 0x00
3119 };
3120 static const unsigned int __03_fui_len = 103;
3121 static const unsigned char __04_fui[] = {
3122 0x46, 0x49, 0x4e, 0x53, 0xc4, 0x00, 0x38, 0x00, 0x4e, 0x41, 0x0f, 0x00,
3123 0x64, 0x65, 0x61, 0x74, 0x68, 0x20, 0x63, 0x31, 0x20, 0x28, 0x43, 0x2d,
3124 0x34, 0x29, 0x00, 0x4d, 0x41, 0xbf, 0x00, 0x08, 0x00, 0x00, 0x50, 0xff,
3125 0xff, 0x00, 0x01, 0x00, 0x01, 0x0f, 0x0e, 0x0b, 0x09, 0x0f, 0x0f, 0x0f,
3126 0x0e, 0x0e, 0x0d, 0x0d, 0x0c, 0x0c, 0x0c, 0x0b, 0x0b, 0x0c, 0x0b, 0x09,
3127 0x08, 0x0d, 0x0d, 0x0c, 0x0c, 0x0b, 0x0b, 0x0b, 0x0a, 0x0a, 0x0a, 0x0a,
3128 0x09, 0x09, 0x09, 0x08, 0x08, 0x09, 0x09, 0x08, 0x08, 0x07, 0x07, 0x06,
3129 0x06, 0x06, 0x06, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05,
3130 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x03, 0x03, 0x03, 0x02, 0x02, 0x01,
3131 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
3132 0x00, 0x01, 0x10, 0x00, 0xff, 0x00, 0x41, 0x00, 0x01, 0xff, 0xf7, 0xf0,
3133 0xef, 0x06, 0x02, 0xfd, 0xfb, 0xf7, 0xf5, 0xf3, 0xf1, 0xf0, 0xee, 0xec,
3134 0xec, 0x04, 0x01, 0x00, 0xff, 0x01, 0x41, 0x00, 0x01, 0xf6, 0x05, 0x01,
3135 0xff, 0xff, 0x00, 0x01, 0x00, 0x01, 0x00, 0x0e, 0x10, 0x00, 0xff, 0x00,
3136 0x01, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3137 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x10, 0x00, 0xff, 0x00,
3138 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x05, 0x05, 0x05, 0x05, 0x05,
3139 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x13, 0x01, 0xff, 0xff, 0x00,
3140 0x81, 0x00, 0x01, 0x55, 0x55, 0xff, 0x50, 0x4e, 0x01, 0x00, 0x00
3141 };
3142 static const unsigned int __04_fui_len = 227;
3143 static const unsigned char __05_fui[] = {
3144 0x46, 0x49, 0x4e, 0x53, 0xc4, 0x00, 0x38, 0x00, 0x4e, 0x41, 0x0f, 0x00,
3145 0x64, 0x65, 0x61, 0x74, 0x68, 0x20, 0x63, 0x32, 0x20, 0x28, 0x43, 0x2d,
3146 0x34, 0x29, 0x00, 0x4d, 0x41, 0xd8, 0x00, 0x08, 0x00, 0x00, 0x51, 0xff,
3147 0xff, 0x00, 0x01, 0x00, 0x01, 0x08, 0x0b, 0x0b, 0x0c, 0x0f, 0x0f, 0x0f,
3148 0x0e, 0x0e, 0x0d, 0x0d, 0x0c, 0x0c, 0x0c, 0x0b, 0x0b, 0x05, 0x07, 0x07,
3149 0x07, 0x09, 0x09, 0x09, 0x08, 0x08, 0x08, 0x08, 0x07, 0x07, 0x07, 0x07,
3150 0x07, 0x03, 0x04, 0x04, 0x04, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05,
3151 0x04, 0x04, 0x04, 0x04, 0x04, 0x02, 0x02, 0x02, 0x02, 0x03, 0x03, 0x03,
3152 0x03, 0x03, 0x03, 0x03, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01,
3153 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01,
3154 0x01, 0x00, 0x01, 0x10, 0x00, 0xff, 0x00, 0x01, 0x00, 0x01, 0x36, 0x15,
3155 0x0f, 0x0b, 0x39, 0x37, 0x35, 0x34, 0x33, 0x32, 0x31, 0x31, 0x30, 0x2f,
3156 0x2f, 0x2e, 0x04, 0x01, 0x00, 0xff, 0x01, 0x41, 0x00, 0x01, 0xf6, 0x05,
3157 0x01, 0xff, 0xff, 0x00, 0x01, 0x00, 0x01, 0x01, 0x0e, 0x10, 0x00, 0xff,
3158 0x00, 0x01, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3159 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x10, 0x00, 0xff,
3160 0x00, 0x01, 0x00, 0x01, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d,
3161 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x10, 0x10, 0x00, 0xff,
3162 0x00, 0x01, 0x00, 0x01, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
3163 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x13, 0x01, 0xff, 0xff,
3164 0x00, 0x81, 0x00, 0x01, 0xf5, 0x75, 0xff, 0x50, 0x4e, 0x01, 0x00, 0x00
3165 };
3166 static const unsigned int __05_fui_len = 252;
3167 static const unsigned char __07_fui[] = {
3168 0x46, 0x49, 0x4e, 0x53, 0xc4, 0x00, 0x38, 0x00, 0x4e, 0x41, 0x0b, 0x00,
3169 0x74, 0x79, 0x70, 0x65, 0x77, 0x72, 0x69, 0x74, 0x65, 0x72, 0x00, 0x4d,
3170 0x41, 0x4c, 0x00, 0x08, 0x00, 0x00, 0x04, 0x00, 0xff, 0x00, 0x01, 0x00,
3171 0x01, 0x06, 0x05, 0x04, 0x00, 0x01, 0x01, 0x00, 0xff, 0x00, 0xc1, 0x00,
3172 0x01, 0x3e, 0x00, 0x00, 0x40, 0x05, 0x01, 0xff, 0xff, 0x00, 0x01, 0x00,
3173 0x01, 0x00, 0x0e, 0x04, 0x00, 0xff, 0x00, 0x01, 0x00, 0x01, 0x01, 0x00,
3174 0x00, 0x00, 0x0f, 0x01, 0xff, 0xff, 0x00, 0x01, 0x00, 0x01, 0x0e, 0x10,
3175 0x01, 0xff, 0xff, 0x00, 0x01, 0x00, 0x01, 0x07, 0x13, 0x01, 0xff, 0xff,
3176 0x00, 0x81, 0x00, 0x01, 0xc5, 0x55, 0xff, 0x50, 0x4e, 0x01, 0x00, 0x03
3177 };
3178 static const unsigned int __07_fui_len = 108;
3179 static const unsigned char __08_fui[] = {
3180 0x46, 0x49, 0x4e, 0x53, 0xc4, 0x00, 0x38, 0x00, 0x4e, 0x41, 0x12, 0x00,
3181 0x74, 0x72, 0x61, 0x6e, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x31, 0x20,
3182 0x28, 0x47, 0x2d, 0x33, 0x29, 0x00, 0x4d, 0x41, 0xdf, 0x00, 0x08, 0x00,
3183 0x00, 0x5e, 0xff, 0xff, 0x00, 0x01, 0x00, 0x01, 0x0c, 0x0b, 0x0b, 0x0a,
3184 0x09, 0x08, 0x08, 0x08, 0x0f, 0x0d, 0x0d, 0x0c, 0x0b, 0x0b, 0x0a, 0x0a,
3185 0x0e, 0x0e, 0x0d, 0x0d, 0x0c, 0x0c, 0x0c, 0x0c, 0x0b, 0x0c, 0x0c, 0x0c,
3186 0x0d, 0x0d, 0x0e, 0x0e, 0x0e, 0x0d, 0x0e, 0x0e, 0x0e, 0x0e, 0x0e, 0x0e,
3187 0x0e, 0x0e, 0x0e, 0x0e, 0x0e, 0x0e, 0x0e, 0x0e, 0x0d, 0x0d, 0x0c, 0x0c,
3188 0x0c, 0x0b, 0x0b, 0x0b, 0x0b, 0x0a, 0x0a, 0x09, 0x08, 0x08, 0x08, 0x07,
3189 0x07, 0x07, 0x07, 0x06, 0x06, 0x06, 0x05, 0x05, 0x04, 0x04, 0x04, 0x04,
3190 0x04, 0x03, 0x03, 0x03, 0x03, 0x03, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
3191 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x1b, 0x17, 0xff, 0x00, 0x01,
3192 0x00, 0x02, 0x00, 0x04, 0x07, 0x04, 0x07, 0x0c, 0x07, 0x0c, 0x10, 0x0c,
3193 0x10, 0x13, 0x10, 0x13, 0x18, 0x13, 0x18, 0x1c, 0x18, 0x1c, 0x1f, 0x1c,
3194 0x1f, 0x24, 0x1f, 0x1c, 0x1f, 0x04, 0x26, 0x25, 0xff, 0x01, 0x01, 0x00,
3195 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3196 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3197 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3198 0x00, 0x00, 0x0e, 0x05, 0x01, 0xff, 0xff, 0x00, 0x01, 0x00, 0x01, 0x00,
3199 0x0e, 0x01, 0xff, 0xff, 0x00, 0x01, 0x00, 0x01, 0x01, 0x0f, 0x01, 0xff,
3200 0xff, 0x00, 0x01, 0x00, 0x01, 0x01, 0x13, 0x01, 0xff, 0xff, 0x00, 0x81,
3201 0x00, 0x01, 0x55, 0x55, 0xff, 0x50, 0x4e, 0x01, 0x00, 0x00
3202 };
3203 static const unsigned int __08_fui_len = 262;
3204 static const unsigned char __09_fui[] = {
3205 0x46, 0x49, 0x4e, 0x53, 0xc4, 0x00, 0x38, 0x00, 0x4e, 0x41, 0x12, 0x00,
3206 0x74, 0x72, 0x61, 0x6e, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x32, 0x20,
3207 0x28, 0x43, 0x2d, 0x34, 0x29, 0x00, 0x4d, 0x41, 0x77, 0x00, 0x08, 0x00,
3208 0x00, 0x3b, 0xff, 0xff, 0x00, 0x01, 0x00, 0x01, 0x0f, 0x0e, 0x0c, 0x0b,
3209 0x0a, 0x09, 0x08, 0x07, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x02, 0x02,
3210 0x0b, 0x0a, 0x09, 0x08, 0x07, 0x06, 0x06, 0x05, 0x05, 0x04, 0x03, 0x03,
3211 0x02, 0x02, 0x01, 0x01, 0x07, 0x06, 0x06, 0x05, 0x05, 0x04, 0x04, 0x03,
3212 0x02, 0x02, 0x02, 0x01, 0x01, 0x00, 0x00, 0x00, 0x04, 0x03, 0x03, 0x02,
3213 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x04, 0x00, 0xff, 0x00,
3214 0x01, 0x00, 0x01, 0x04, 0x07, 0x0e, 0x12, 0x05, 0x01, 0xff, 0xff, 0x00,
3215 0x01, 0x00, 0x01, 0x00, 0x0e, 0x01, 0xff, 0xff, 0x00, 0x01, 0x00, 0x01,
3216 0x01, 0x0f, 0x01, 0xff, 0xff, 0x00, 0x01, 0x00, 0x01, 0x01, 0x13, 0x01,
3217 0xff, 0xff, 0x00, 0x81, 0x00, 0x01, 0x55, 0x55, 0xff, 0x50, 0x4e, 0x01,
3218 0x00, 0x00
3219 };
3220 static const unsigned int __09_fui_len = 158;
3221 static const unsigned char __0a_fui[] = {
3222 0x46, 0x49, 0x4e, 0x53, 0xc4, 0x00, 0x38, 0x00, 0x4e, 0x41, 0x0b, 0x00,
3223 0x69, 0x6e, 0x69, 0x74, 0x20, 0x28, 0x43, 0x2d, 0x34, 0x29, 0x00, 0x4d,
3224 0x41, 0x6a, 0x00, 0x08, 0x00, 0x00, 0x29, 0xff, 0xff, 0x00, 0x01, 0x00,
3225 0x01, 0x0f, 0x0e, 0x0e, 0x0d, 0x0c, 0x0c, 0x0c, 0x0b, 0x0b, 0x0b, 0x0a,
3226 0x0a, 0x0a, 0x09, 0x09, 0x09, 0x08, 0x08, 0x08, 0x08, 0x07, 0x07, 0x07,
3227 0x07, 0x06, 0x06, 0x06, 0x06, 0x06, 0x05, 0x05, 0x05, 0x05, 0x04, 0x04,
3228 0x04, 0x04, 0x03, 0x02, 0x01, 0x00, 0x01, 0x09, 0x03, 0xff, 0x00, 0x01,
3229 0x00, 0x01, 0x07, 0x13, 0x07, 0x0b, 0x07, 0x04, 0x08, 0x0e, 0x04, 0x05,
3230 0x01, 0xff, 0xff, 0x00, 0x01, 0x00, 0x01, 0x00, 0x0e, 0x01, 0xff, 0xff,
3231 0x00, 0x01, 0x00, 0x01, 0x01, 0x0f, 0x01, 0xff, 0xff, 0x00, 0x01, 0x00,
3232 0x01, 0x01, 0x13, 0x01, 0xff, 0xff, 0x00, 0x81, 0x00, 0x01, 0x55, 0x55,
3233 0xff, 0x50, 0x4e, 0x01, 0x00, 0x00
3234 };
3235 static const unsigned int __0a_fui_len = 138;
3236 static const unsigned char __0b_fui[] = {
3237 0x46, 0x49, 0x4e, 0x53, 0xc4, 0x00, 0x38, 0x00, 0x4e, 0x41, 0x0e, 0x00,
3238 0x72, 0x65, 0x73, 0x70, 0x61, 0x77, 0x6e, 0x20, 0x28, 0x43, 0x2d, 0x34,
3239 0x29, 0x00, 0x4d, 0x41, 0x69, 0x00, 0x08, 0x00, 0x00, 0x29, 0xff, 0xff,
3240 0x00, 0x01, 0x00, 0x01, 0x0f, 0x0c, 0x0b, 0x0a, 0x05, 0x0f, 0x0c, 0x0b,
3241 0x0a, 0x05, 0x0f, 0x0c, 0x0b, 0x0a, 0x05, 0x0f, 0x0c, 0x0b, 0x0a, 0x05,
3242 0x0f, 0x0c, 0x0b, 0x0a, 0x05, 0x0f, 0x0c, 0x0b, 0x0a, 0x05, 0x0f, 0x0c,
3243 0x0b, 0x08, 0x05, 0x0f, 0x0d, 0x0b, 0x09, 0x05, 0x00, 0x01, 0x08, 0x08,
3244 0xff, 0x00, 0x01, 0x00, 0x05, 0x10, 0x0f, 0x0d, 0x15, 0x14, 0x0d, 0x0f,
3245 0x10, 0x05, 0x01, 0xff, 0xff, 0x00, 0x01, 0x00, 0x01, 0x00, 0x0e, 0x01,
3246 0xff, 0xff, 0x00, 0x01, 0x00, 0x01, 0x01, 0x0f, 0x01, 0xff, 0xff, 0x00,
3247 0x01, 0x00, 0x01, 0x01, 0x13, 0x01, 0xff, 0xff, 0x00, 0x81, 0x00, 0x01,
3248 0x55, 0x55, 0xff, 0x50, 0x4e, 0x01, 0x00, 0x00
3249 };
3250 static const unsigned int __0b_fui_len = 140;
3251 static const unsigned char __0c_fui[] = {
3252 0x46, 0x49, 0x4e, 0x53, 0xc4, 0x00, 0x39, 0x00, 0x4e, 0x41, 0x09, 0x00,
3253 0x74, 0x61, 0x6e, 0x6b, 0x6d, 0x6f, 0x76, 0x65, 0x00, 0x4d, 0x41, 0x92,
3254 0x01, 0x08, 0x00, 0x00, 0xff, 0x0b, 0xff, 0x00, 0x01, 0x00, 0x01, 0x04,
3255 0x05, 0x07, 0x07, 0x07, 0x06, 0x06, 0x06, 0x05, 0x05, 0x05, 0x04, 0x04,
3256 0x04, 0x04, 0x04, 0x05, 0x04, 0x05, 0x05, 0x05, 0x04, 0x05, 0x05, 0x04,
3257 0x04, 0x04, 0x05, 0x04, 0x04, 0x05, 0x04, 0x05, 0x05, 0x04, 0x05, 0x04,
3258 0x05, 0x05, 0x05, 0x04, 0x05, 0x05, 0x04, 0x05, 0x05, 0x04, 0x04, 0x05,
3259 0x05, 0x05, 0x04, 0x04, 0x05, 0x05, 0x04, 0x05, 0x05, 0x05, 0x04, 0x05,
3260 0x05, 0x04, 0x05, 0x04, 0x04, 0x04, 0x04, 0x05, 0x04, 0x05, 0x05, 0x05,
3261 0x04, 0x05, 0x04, 0x05, 0x04, 0x05, 0x05, 0x05, 0x04, 0x05, 0x05, 0x05,
3262 0x05, 0x05, 0x05, 0x04, 0x05, 0x05, 0x04, 0x04, 0x05, 0x05, 0x04, 0x05,
3263 0x05, 0x04, 0x05, 0x05, 0x04, 0x04, 0x04, 0x04, 0x04, 0x05, 0x04, 0x04,
3264 0x04, 0x05, 0x05, 0x04, 0x04, 0x05, 0x04, 0x05, 0x04, 0x05, 0x04, 0x05,
3265 0x04, 0x04, 0x05, 0x05, 0x05, 0x05, 0x04, 0x04, 0x04, 0x05, 0x04, 0x04,
3266 0x04, 0x04, 0x04, 0x04, 0x05, 0x04, 0x04, 0x05, 0x05, 0x05, 0x04, 0x04,
3267 0x04, 0x04, 0x05, 0x05, 0x05, 0x05, 0x04, 0x05, 0x05, 0x04, 0x04, 0x04,
3268 0x05, 0x04, 0x05, 0x05, 0x04, 0x05, 0x05, 0x04, 0x05, 0x04, 0x04, 0x05,
3269 0x04, 0x04, 0x04, 0x04, 0x05, 0x04, 0x04, 0x04, 0x04, 0x05, 0x05, 0x05,
3270 0x05, 0x05, 0x04, 0x04, 0x05, 0x04, 0x05, 0x05, 0x05, 0x04, 0x04, 0x05,
3271 0x05, 0x04, 0x05, 0x04, 0x04, 0x05, 0x05, 0x04, 0x05, 0x04, 0x04, 0x04,
3272 0x04, 0x04, 0x04, 0x05, 0x04, 0x05, 0x04, 0x05, 0x05, 0x05, 0x05, 0x04,
3273 0x05, 0x04, 0x05, 0x04, 0x04, 0x04, 0x05, 0x05, 0x04, 0x04, 0x04, 0x04,
3274 0x05, 0x05, 0x04, 0x04, 0x05, 0x05, 0x05, 0x04, 0x05, 0x05, 0x05, 0x05,
3275 0x05, 0x05, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x05,
3276 0x04, 0x04, 0x01, 0x02, 0x00, 0xff, 0x00, 0x41, 0x00, 0x01, 0xf4, 0xce,
3277 0x04, 0x10, 0xff, 0xff, 0x00, 0x81, 0x00, 0x01, 0xb8, 0x00, 0xd9, 0x00,
3278 0x02, 0x01, 0x18, 0x01, 0xd7, 0x00, 0xa3, 0x00, 0x79, 0x00, 0x59, 0x00,
3279 0x3e, 0x00, 0x2b, 0x00, 0x1b, 0x00, 0x0f, 0x00, 0x05, 0x00, 0xfe, 0xff,
3280 0xfe, 0xff, 0xf5, 0xff, 0x05, 0x01, 0xff, 0xff, 0x00, 0x01, 0x00, 0x01,
3281 0x00, 0x06, 0x02, 0x00, 0xff, 0x00, 0x01, 0x00, 0x01, 0x52, 0x00, 0x07,
3282 0x02, 0x00, 0xff, 0x00, 0x01, 0x00, 0x01, 0x15, 0x00, 0x0e, 0x01, 0xff,
3283 0xff, 0x00, 0x01, 0x00, 0x01, 0x01, 0x0f, 0x02, 0x00, 0xff, 0x00, 0x01,
3284 0x00, 0x01, 0x02, 0x0d, 0x10, 0x02, 0x00, 0xff, 0x00, 0x01, 0x00, 0x01,
3285 0x0c, 0x0a, 0x11, 0x01, 0xff, 0xff, 0x00, 0x01, 0x00, 0x01, 0x01, 0x12,
3286 0x01, 0xff, 0xff, 0x00, 0x01, 0x00, 0x01, 0x0b, 0x13, 0x01, 0x00, 0xff,
3287 0x00, 0x81, 0x00, 0x01, 0xaa, 0x5a, 0xff, 0x50, 0x4e, 0x01, 0x00, 0x00
3288 };
3289 static const unsigned int __0c_fui_len = 432;
3290 static const unsigned char __0d_fui[] = {
3291 0x46, 0x49, 0x4e, 0x53, 0xc4, 0x00, 0x39, 0x00, 0x4e, 0x41, 0x0b, 0x00,
3292 0x76, 0x6f, 0x72, 0x74, 0x65, 0x78, 0x6d, 0x6f, 0x76, 0x65, 0x00, 0x4d,
3293 0x41, 0x68, 0x00, 0x08, 0x00, 0x00, 0x10, 0xff, 0xff, 0x00, 0x01, 0x00,
3294 0x01, 0x0a, 0x0a, 0x09, 0x08, 0x07, 0x07, 0x06, 0x06, 0x07, 0x08, 0x09,
3295 0x0b, 0x0b, 0x0c, 0x0c, 0x00, 0x01, 0x0f, 0xff, 0xff, 0x00, 0x01, 0x00,
3296 0x01, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a,
3297 0x0b, 0x0c, 0x0d, 0x0e, 0x05, 0x01, 0xff, 0xff, 0x00, 0x01, 0x00, 0x01,
3298 0x00, 0x06, 0x01, 0xff, 0xff, 0x00, 0x01, 0x00, 0x01, 0x3a, 0x07, 0x01,
3299 0xff, 0xff, 0x00, 0x01, 0x00, 0x01, 0x00, 0x0e, 0x01, 0xff, 0xff, 0x00,
3300 0x01, 0x00, 0x01, 0x01, 0x11, 0x01, 0xff, 0xff, 0x00, 0x01, 0x00, 0x01,
3301 0x01, 0x12, 0x01, 0xff, 0xff, 0x00, 0x01, 0x00, 0x01, 0x00, 0xff, 0x50,
3302 0x4e, 0x01, 0x00, 0x00
3303 };
3304 static const unsigned int __0d_fui_len = 136;
3305 static const unsigned char __0e_fui[] = {
3306 0x46, 0x49, 0x4e, 0x53, 0xc4, 0x00, 0x39, 0x00, 0x4e, 0x41, 0x0c, 0x00,
3307 0x76, 0x6f, 0x72, 0x74, 0x65, 0x78, 0x73, 0x68, 0x6f, 0x6f, 0x74, 0x00,
3308 0x4d, 0x41, 0xc1, 0x00, 0x08, 0x00, 0x00, 0x3c, 0xff, 0xff, 0x00, 0x01,
3309 0x00, 0x01, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f,
3310 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f,
3311 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0e, 0x0e, 0x0d, 0x0d, 0x0c,
3312 0x0c, 0x0b, 0x0b, 0x0b, 0x0a, 0x0a, 0x09, 0x09, 0x08, 0x08, 0x07, 0x07,
3313 0x06, 0x06, 0x05, 0x05, 0x05, 0x04, 0x04, 0x03, 0x03, 0x03, 0x02, 0x02,
3314 0x01, 0x00, 0x01, 0x3c, 0xff, 0xff, 0x00, 0x41, 0x00, 0x01, 0x0b, 0x09,
3315 0x0b, 0x07, 0x0b, 0x05, 0x0b, 0x03, 0x0b, 0x01, 0x0b, 0xfe, 0x0b, 0xfc,
3316 0x0b, 0xfa, 0x0b, 0x05, 0x0b, 0x04, 0x0b, 0x03, 0x0b, 0x02, 0x0b, 0x01,
3317 0x0b, 0x00, 0x0b, 0xff, 0x0b, 0xfe, 0x0b, 0xfd, 0x0b, 0xfc, 0x0b, 0xfb,
3318 0x0b, 0xfa, 0x0b, 0xf9, 0x0b, 0xf7, 0x0b, 0xf6, 0x0b, 0xf5, 0x0b, 0xf4,
3319 0x0b, 0xf3, 0x0b, 0xf2, 0x0b, 0xf1, 0x0b, 0xef, 0x0b, 0xee, 0x05, 0x01,
3320 0x00, 0xff, 0x00, 0x01, 0x00, 0x01, 0x0c, 0x06, 0x01, 0xff, 0xff, 0x00,
3321 0x01, 0x00, 0x01, 0xff, 0x07, 0x01, 0xff, 0xff, 0x00, 0x01, 0x00, 0x01,
3322 0x04, 0x0e, 0x01, 0x00, 0xff, 0x00, 0x01, 0x00, 0x01, 0x01, 0x11, 0x01,
3323 0xff, 0xff, 0x00, 0x01, 0x00, 0x01, 0x01, 0x12, 0x01, 0xff, 0xff, 0x00,
3324 0x01, 0x00, 0x01, 0x00, 0xff, 0x50, 0x4e, 0x01, 0x00, 0x00
3325 };
3326 static const unsigned int __0e_fui_len = 226;
3327 static const unsigned char __06_fui[] = {
3328 0x46, 0x49, 0x4e, 0x53, 0xc4, 0x00, 0x38, 0x00, 0x4d, 0x41, 0xbf, 0x00,
3329 0x08, 0x00, 0x00, 0x1c, 0xff, 0xff, 0x00, 0x01, 0x00, 0x01, 0x0f, 0x0e,
3330 0x0c, 0x0c, 0x0c, 0x0b, 0x0b, 0x0a, 0x0a, 0x0a, 0x09, 0x09, 0x08, 0x08,
3331 0x08, 0x08, 0x07, 0x07, 0x07, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01,
3332 0x01, 0x00, 0x01, 0x15, 0xff, 0xff, 0x00, 0xc1, 0x00, 0x01, 0x5d, 0x00,
3333 0x00, 0x40, 0x63, 0x00, 0x00, 0x40, 0x35, 0x00, 0x00, 0x40, 0x35, 0x00,
3334 0x00, 0x40, 0x31, 0x00, 0x00, 0x40, 0x2e, 0x00, 0x00, 0x40, 0x2b, 0x00,
3335 0x00, 0x40, 0x29, 0x00, 0x00, 0x40, 0x27, 0x00, 0x00, 0x40, 0x26, 0x00,
3336 0x00, 0x40, 0x24, 0x00, 0x00, 0x40, 0x23, 0x00, 0x00, 0x40, 0x22, 0x00,
3337 0x00, 0x40, 0x1e, 0x00, 0x00, 0x40, 0x1d, 0x00, 0x00, 0x40, 0x1c, 0x00,
3338 0x00, 0x40, 0x1b, 0x00, 0x00, 0x40, 0x1a, 0x00, 0x00, 0x40, 0x1a, 0x00,
3339 0x00, 0x40, 0x19, 0x00, 0x00, 0x40, 0x18, 0x00, 0x00, 0x40, 0x05, 0x03,
3340 0x04, 0x04, 0x00, 0x01, 0x00, 0x01, 0x01, 0x01, 0x00, 0x0e, 0x01, 0x01,
3341 0x04, 0x00, 0x01, 0x00, 0x01, 0x01, 0x0f, 0x03, 0x04, 0x04, 0x00, 0x01,
3342 0x00, 0x01, 0x0d, 0x0d, 0x01, 0x10, 0x01, 0xff, 0xff, 0x00, 0x01, 0x00,
3343 0x01, 0x0e, 0x13, 0x03, 0x05, 0x04, 0x00, 0xc1, 0x00, 0x01, 0xd8, 0x75,
3344 0x00, 0x00, 0xaa, 0xea, 0x00, 0x00, 0xaa, 0xaa, 0x00, 0x00, 0xff, 0x50,
3345 0x4e, 0x01, 0x00, 0x00
3346 };
3347 static const unsigned int __06_fui_len = 208;
3348 static const unsigned char __0f_fui[] = {
3349 0x46, 0x49, 0x4e, 0x53, 0xc4, 0x00, 0x38, 0x00, 0x4d, 0x41, 0x54, 0x00,
3350 0x08, 0x00, 0x00, 0x0b, 0xff, 0xff, 0x00, 0x01, 0x00, 0x01, 0x0f, 0x09,
3351 0x06, 0x04, 0x04, 0x03, 0x03, 0x02, 0x01, 0x01, 0x00, 0x01, 0x02, 0x00,
3352 0xff, 0x00, 0xc1, 0x00, 0x02, 0x3e, 0x00, 0x00, 0x40, 0x4e, 0x00, 0x00,
3353 0x40, 0x05, 0x01, 0xff, 0xff, 0x00, 0x01, 0x00, 0x01, 0x00, 0x0e, 0x01,
3354 0x06, 0xff, 0x00, 0x01, 0x00, 0x01, 0x01, 0x0f, 0x01, 0xff, 0xff, 0x00,
3355 0x01, 0x00, 0x01, 0x04, 0x10, 0x01, 0xff, 0xff, 0x00, 0x01, 0x00, 0x01,
3356 0x09, 0x13, 0x01, 0xff, 0xff, 0x00, 0x81, 0x00, 0x01, 0xc5, 0x55, 0xff,
3357 0x50, 0x4e, 0x01, 0x00, 0x03
3358 };
3359 static const unsigned int __0f_fui_len = 101;
3360 static const unsigned char __10_fui[] = {
3361 0x46, 0x49, 0x4e, 0x53, 0xe2, 0x00, 0x38, 0x00, 0x4d, 0x41, 0x94, 0x00,
3362 0x08, 0x00, 0x00, 0x10, 0xff, 0xff, 0x00, 0x03, 0x00, 0x01, 0x00, 0x0f,
3363 0x06, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3364 0x00, 0x00, 0x04, 0x4c, 0x48, 0xff, 0x01, 0x41, 0x00, 0x01, 0xfd, 0xfc,
3365 0xfb, 0xfb, 0xfb, 0xfa, 0xfa, 0xfa, 0xfa, 0xf8, 0xf7, 0xf6, 0xf6, 0xf5,
3366 0xf5, 0xf4, 0xf3, 0xf3, 0xf2, 0xf2, 0xf3, 0xf2, 0xf1, 0xf1, 0xf0, 0xf0,
3367 0xef, 0xef, 0xee, 0xee, 0xee, 0xed, 0xed, 0xed, 0xec, 0xec, 0xec, 0xeb,
3368 0xeb, 0xeb, 0xeb, 0xeb, 0xeb, 0xea, 0xea, 0xea, 0xea, 0xea, 0xea, 0xea,
3369 0xeb, 0xeb, 0xeb, 0xeb, 0xeb, 0xec, 0xec, 0xec, 0xed, 0xed, 0xed, 0xed,
3370 0xee, 0xee, 0xef, 0xef, 0xf0, 0xf0, 0xf1, 0xf1, 0xf2, 0xf2, 0xf2, 0xf3,
3371 0xf3, 0xf3, 0x05, 0x01, 0xff, 0xff, 0x00, 0x01, 0x00, 0x01, 0x00, 0x0e,
3372 0x01, 0xff, 0xff, 0x00, 0x01, 0x00, 0x01, 0x01, 0x0f, 0x01, 0xff, 0xff,
3373 0x00, 0x01, 0x00, 0x01, 0x01, 0x13, 0x01, 0xff, 0xff, 0x00, 0x81, 0x00,
3374 0x01, 0x55, 0x55, 0xff, 0x50, 0x4e, 0x01, 0x00, 0x00
3375 };
3376 static const unsigned int __10_fui_len = 165;
3377 static const unsigned char __11_fui[] = {
3378 0x46, 0x49, 0x4e, 0x53, 0xe2, 0x00, 0x38, 0x00, 0x4d, 0x41, 0x94, 0x00,
3379 0x08, 0x00, 0x00, 0x10, 0xff, 0xff, 0x00, 0x03, 0x00, 0x01, 0x00, 0x0f,
3380 0x06, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3381 0x00, 0x00, 0x04, 0x4c, 0x48, 0xff, 0x01, 0x41, 0x00, 0x01, 0xd7, 0xfd,
3382 0xfb, 0xfb, 0xfb, 0xfa, 0xfa, 0xfa, 0xfa, 0xf8, 0xf7, 0xf6, 0xf6, 0xf5,
3383 0xf5, 0xf4, 0xf3, 0xf3, 0xf2, 0xf2, 0xf3, 0xf2, 0xf1, 0xf1, 0xf0, 0xf0,
3384 0xef, 0xef, 0xee, 0xee, 0xee, 0xed, 0xed, 0xed, 0xec, 0xec, 0xec, 0xeb,
3385 0xeb, 0xeb, 0xeb, 0xeb, 0xeb, 0xea, 0xea, 0xea, 0xea, 0xea, 0xea, 0xea,
3386 0xeb, 0xeb, 0xeb, 0xeb, 0xeb, 0xec, 0xec, 0xec, 0xed, 0xed, 0xed, 0xed,
3387 0xee, 0xee, 0xef, 0xef, 0xf0, 0xf0, 0xf1, 0xf1, 0xf2, 0xf2, 0xf2, 0xf3,
3388 0xf3, 0xf3, 0x05, 0x01, 0xff, 0xff, 0x00, 0x01, 0x00, 0x01, 0x00, 0x0e,
3389 0x01, 0xff, 0xff, 0x00, 0x01, 0x00, 0x01, 0x01, 0x0f, 0x01, 0xff, 0xff,
3390 0x00, 0x01, 0x00, 0x01, 0x01, 0x13, 0x01, 0xff, 0xff, 0x00, 0x81, 0x00,
3391 0x01, 0x55, 0x55, 0xff, 0x50, 0x4e, 0x01, 0x00, 0x00
3392 };
3393 static const unsigned int __11_fui_len = 165;
3394 static const unsigned char __12_fui[] = {
3395 0x46, 0x49, 0x4e, 0x53, 0xe2, 0x00, 0x38, 0x00, 0x4d, 0x41, 0xd0, 0x00,
3396 0x08, 0x00, 0x00, 0x40, 0xff, 0xff, 0x00, 0x01, 0x00, 0x01, 0x0f, 0x0f,
3397 0x0e, 0x0e, 0x0e, 0x0e, 0x0e, 0x0e, 0x0e, 0x0d, 0x0d, 0x0e, 0x0d, 0x0d,
3398 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0b, 0x0b, 0x0b, 0x0b, 0x09, 0x09, 0x07,
3399 0x07, 0x07, 0x06, 0x06, 0x05, 0x05, 0x05, 0x04, 0x04, 0x04, 0x04, 0x04,
3400 0x04, 0x04, 0x04, 0x04, 0x03, 0x03, 0x03, 0x03, 0x03, 0x02, 0x02, 0x02,
3401 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00,
3402 0x00, 0x00, 0x01, 0x3c, 0x06, 0xff, 0x00, 0x41, 0x00, 0x01, 0x28, 0xfe,
3403 0xe8, 0xf6, 0x2c, 0x21, 0x1d, 0x05, 0x27, 0x04, 0x0b, 0x0b, 0x27, 0x28,
3404 0x02, 0x0d, 0x0a, 0x04, 0x03, 0x2c, 0x2c, 0x0c, 0xfc, 0x06, 0x1e, 0x2c,
3405 0xfe, 0xfe, 0x2c, 0x23, 0x2c, 0x24, 0x08, 0x0b, 0x2b, 0x1e, 0x2b, 0xfe,
3406 0x01, 0x07, 0x07, 0x0a, 0x2b, 0xff, 0x1c, 0x2a, 0x21, 0x16, 0x20, 0x16,
3407 0x16, 0x1d, 0x1d, 0x1c, 0x09, 0x02, 0x05, 0xfd, 0x09, 0x29, 0x05, 0x06,
3408 0xff, 0xff, 0x00, 0x01, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01,
3409 0x0e, 0x01, 0xff, 0xff, 0x00, 0x01, 0x00, 0x01, 0x01, 0x0f, 0x03, 0xff,
3410 0xff, 0x00, 0x01, 0x00, 0x01, 0x0a, 0x01, 0x06, 0x10, 0x03, 0xff, 0xff,
3411 0x00, 0x01, 0x00, 0x01, 0x05, 0x04, 0x0c, 0x13, 0x03, 0xff, 0xff, 0x00,
3412 0xc1, 0x00, 0x01, 0xad, 0x3a, 0x00, 0x00, 0xaa, 0xaa, 0x00, 0x00, 0x20,
3413 0x21, 0x00, 0x00, 0xff, 0x50, 0x4e, 0x01, 0x00, 0x00
3414 };
3415 static const unsigned int __12_fui_len = 225;
3416 static const unsigned char __13_fui[] = {
3417 0x46, 0x49, 0x4e, 0x53, 0xe2, 0x00, 0x39, 0x00, 0x4d, 0x41, 0x95, 0x00,
3418 0x08, 0x00, 0x00, 0x52, 0xff, 0xff, 0x00, 0x01, 0x00, 0x01, 0x0f, 0x0e,
3419 0x0d, 0x0c, 0x0b, 0x0a, 0x09, 0x08, 0x00, 0x0f, 0x0e, 0x0d, 0x0c, 0x0b,
3420 0x0a, 0x09, 0x08, 0x00, 0x0f, 0x0e, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d,
3421 0x0d, 0x0d, 0x0c, 0x0c, 0x0c, 0x0c, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0a,
3422 0x0a, 0x0a, 0x0a, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x08, 0x08, 0x08, 0x08,
3423 0x07, 0x07, 0x07, 0x07, 0x07, 0x06, 0x06, 0x06, 0x06, 0x06, 0x05, 0x05,
3424 0x05, 0x05, 0x05, 0x04, 0x04, 0x04, 0x04, 0x04, 0x03, 0x03, 0x02, 0x02,
3425 0x02, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x0b, 0x06, 0xff,
3426 0x00, 0x01, 0x00, 0x03, 0x00, 0x04, 0x07, 0x02, 0x06, 0x09, 0x04, 0x08,
3427 0x0b, 0x10, 0x0b, 0x05, 0x01, 0xff, 0xff, 0x00, 0x01, 0x00, 0x01, 0x00,
3428 0x0e, 0x01, 0xff, 0xff, 0x00, 0x01, 0x00, 0x01, 0x01, 0x0f, 0x01, 0xff,
3429 0xff, 0x00, 0x01, 0x00, 0x01, 0x01, 0x13, 0x01, 0xff, 0xff, 0x00, 0x81,
3430 0x00, 0x01, 0x55, 0x55, 0xff, 0x50, 0x4e, 0x01, 0x00, 0x00
3431 };
3432 static const unsigned int __13_fui_len = 166;
3433 static const unsigned char __14_fui[] = {
3434 0x46, 0x49, 0x4e, 0x53, 0xe2, 0x00, 0x38, 0x00, 0x4d, 0x41, 0x4f, 0x00,
3435 0x08, 0x00, 0x00, 0x1f, 0xff, 0xff, 0x00, 0x01, 0x00, 0x02, 0x0f, 0x0f,
3436 0x00, 0x00, 0x0f, 0x0f, 0x00, 0x00, 0x0f, 0x0f, 0x00, 0x00, 0x0f, 0x0f,
3437 0x00, 0x00, 0x0f, 0x0f, 0x00, 0x00, 0x0f, 0x0f, 0x00, 0x00, 0x0f, 0x0f,
3438 0x00, 0x00, 0x0f, 0x0f, 0x00, 0x05, 0x01, 0xff, 0xff, 0x00, 0x01, 0x00,
3439 0x01, 0x00, 0x0e, 0x01, 0xff, 0xff, 0x00, 0x01, 0x00, 0x01, 0x01, 0x0f,
3440 0x01, 0xff, 0xff, 0x00, 0x01, 0x00, 0x01, 0x01, 0x13, 0x01, 0xff, 0xff,
3441 0x00, 0x81, 0x00, 0x01, 0x55, 0x55, 0xff, 0x50, 0x4e, 0x01, 0x00, 0x00
3442 };
3443 static const unsigned int __14_fui_len = 96;
3444
3445 #define LOAD_INS(x,y) { \
3446 DivInstrument* newIns=new DivInstrument; \
3447 SafeReader reader(x,y); \
3448 newIns->readInsData(reader,DIV_ENGINE_VERSION,&e->song); \
3449 newIns->std.volMacro.speed*=macroMul; \
3450 newIns->std.arpMacro.speed*=macroMul; \
3451 newIns->std.dutyMacro.speed*=macroMul; \
3452 newIns->std.waveMacro.speed*=macroMul; \
3453 newIns->std.pitchMacro.speed*=macroMul; \
3454 newIns->std.phaseResetMacro.speed*=macroMul; \
3455 newIns->std.ex1Macro.speed*=macroMul; \
3456 newIns->std.ex2Macro.speed*=macroMul; \
3457 newIns->std.ex3Macro.speed*=macroMul; \
3458 newIns->std.ex4Macro.speed*=macroMul; \
3459 newIns->std.ex5Macro.speed*=macroMul; \
3460 newIns->std.ex6Macro.speed*=macroMul; \
3461 newIns->std.ex7Macro.speed*=macroMul; \
3462 newIns->std.ex8Macro.speed*=macroMul; \
3463 e->addInstrumentPtr(newIns); \
3464 }
3465
3466 void FurnaceCV::loadInstruments() {
3467 logV("loadInstruments");
3468 fxInsBase=e->song.ins.size();
3469 fxChanBase=e->getTotalChannelCount();
3470
3471 int macroMul=(int)((e->curSubSong->hz+20.0)/60.0);
3472
3473 int sys=e->song.systemLen;
3474 if (e->addSystem(DIV_SYSTEM_POWERNOISE)) {
3475 if (e->song.masterVol<0.1) {
3476 e->song.systemVol[sys]=12.0;
3477 } else {
3478 e->song.systemVol[sys]=1.2/e->song.masterVol;
3479 }
3480 }
3481
3482
3483 LOAD_INS(__00_fui,__00_fui_len);
3484 LOAD_INS(__01_fui,__01_fui_len);
3485 LOAD_INS(__02_fui,__02_fui_len);
3486 LOAD_INS(__03_fui,__03_fui_len);
3487 LOAD_INS(__04_fui,__04_fui_len);
3488 LOAD_INS(__05_fui,__05_fui_len);
3489 LOAD_INS(__06_fui,__06_fui_len);
3490 LOAD_INS(__07_fui,__07_fui_len);
3491 LOAD_INS(__08_fui,__08_fui_len);
3492 LOAD_INS(__09_fui,__09_fui_len);
3493 LOAD_INS(__0a_fui,__0a_fui_len);
3494 LOAD_INS(__0b_fui,__0b_fui_len);
3495 LOAD_INS(__0c_fui,__0c_fui_len);
3496 LOAD_INS(__0d_fui,__0d_fui_len);
3497 LOAD_INS(__0e_fui,__0e_fui_len);
3498 LOAD_INS(__0f_fui,__0f_fui_len);
3499 LOAD_INS(__10_fui,__10_fui_len);
3500 LOAD_INS(__11_fui,__11_fui_len);
3501 LOAD_INS(__12_fui,__12_fui_len);
3502 LOAD_INS(__13_fui,__13_fui_len);
3503 LOAD_INS(__14_fui,__14_fui_len);
3504 }
3505
3506 // FurnaceCVMine IMPLEMENTATION
3507
3508 void FurnaceCVMine::collision(FurnaceCVObject* other) {
3509 if (other->type==CV_BULLET || other->type==CV_PLAYER) {
3510 dead=true;
3511 cv->createObject<FurnaceCVExplMedium>(x-4,y-4);
3512 cv->soundEffect(SE_EXPL1);
3513 cv->addScore(rand()%50);
3514 }
3515 }
3516
3517 // FurnaceCVPowerupP IMPLEMENTATION
3518
3519 void FurnaceCVPowerupP::collision(FurnaceCVObject* other) {
3520 if (other->type==CV_PLAYER) {
3521 dead=true;
3522 if (cv->shotType) {
3523 cv->weaponStack.push_front(cv->shotType);
3524 }
3525 cv->shotType=1;
3526 cv->soundEffect(SE_PICKUP2);
3527 cv->addScore(200);
3528 }
3529 }
3530
3531 void FurnaceCVPowerupP::tick() {
3532 if (--life==0) dead=true;
3533
3534 if (life>64 || (life&1)) {
3535 spriteDef[0]=0x490;
3536 spriteDef[1]=0x491;
3537 spriteDef[2]=0x4b0;
3538 spriteDef[3]=0x4b1;
3539 } else {
3540 spriteDef[0]=0;
3541 spriteDef[1]=0;
3542 spriteDef[2]=0;
3543 spriteDef[3]=0;
3544 }
3545 }
3546
3547 // FurnaceCVPowerupS IMPLEMENTATION
3548
3549 void FurnaceCVPowerupS::collision(FurnaceCVObject* other) {
3550 if (other->type==CV_PLAYER) {
3551 dead=true;
3552 if (cv->shotType) {
3553 cv->weaponStack.push_front(cv->shotType);
3554 }
3555 cv->shotType=2;
3556 cv->soundEffect(SE_PICKUP2);
3557 cv->addScore(200);
3558 }
3559 }
3560
3561 void FurnaceCVPowerupS::tick() {
3562 if (--life==0) dead=true;
3563
3564 if (life>64 || (life&1)) {
3565 spriteDef[0]=0x492;
3566 spriteDef[1]=0x493;
3567 spriteDef[2]=0x4b2;
3568 spriteDef[3]=0x4b3;
3569 } else {
3570 spriteDef[0]=0;
3571 spriteDef[1]=0;
3572 spriteDef[2]=0;
3573 spriteDef[3]=0;
3574 }
3575 }
3576
3577 // FurnaceCVExtraLife IMPLEMENTATION
3578
3579 void FurnaceCVExtraLife::collision(FurnaceCVObject* other) {
3580 if (other->type==CV_PLAYER) {
3581 dead=true;
3582 cv->soundEffect(SE_PICKUP1);
3583 cv->lives++;
3584 }
3585 }
3586
3587 void FurnaceCVExtraLife::tick() {
3588 if (--life==0) {
3589 dead=true;
3590 cv->lifeBank++;
3591 }
3592
3593 if (life>64 || (life&1)) {
3594 spriteDef[0]=0x0c;
3595 spriteDef[1]=0x0d;
3596 spriteDef[2]=0x2c;
3597 spriteDef[3]=0x2d;
3598 } else {
3599 spriteDef[0]=0;
3600 spriteDef[1]=0;
3601 spriteDef[2]=0;
3602 spriteDef[3]=0;
3603 }
3604 }
3605
3606 // FurnaceCVSpecial IMPLEMENTATION
3607
3608 void FurnaceCVSpecial::collision(FurnaceCVObject* other) {
3609 if (other->type==CV_PLAYER) {
3610 dead=true;
3611 cv->soundEffect(SE_PICKUP2);
3612 cv->specialType=specialType;
3613 }
3614 }
3615
3616 void FurnaceCVSpecial::tick() {
3617 if (--life==0) dead=true;
3618
3619 if (life>64 || (life&1)) {
3620 spriteDef[0]=0x4dc+(((specialType-1)&1)<<1)+(((specialType-1)>>1)<<6);
3621 spriteDef[1]=0x4dd+(((specialType-1)&1)<<1)+(((specialType-1)>>1)<<6);
3622 spriteDef[2]=0x4fc+(((specialType-1)&1)<<1)+(((specialType-1)>>1)<<6);
3623 spriteDef[3]=0x4fd+(((specialType-1)&1)<<1)+(((specialType-1)>>1)<<6);
3624 } else {
3625 spriteDef[0]=0;
3626 spriteDef[1]=0;
3627 spriteDef[2]=0;
3628 spriteDef[3]=0;
3629 }
3630 }
3631
3632
3633 // FurnaceCVModI IMPLEMENTATION
3634
3635 void FurnaceCVModI::collision(FurnaceCVObject* other) {
3636 if (other->type==CV_PLAYER) {
3637 dead=true;
3638 cv->soundEffect(SE_PICKUP1);
3639 cv->addScore(200);
3640 ((FurnaceCVPlayer*)other)->invincible=600;
3641 }
3642 }
3643
3644 void FurnaceCVModI::tick() {
3645 if (--life==0) dead=true;
3646
3647 if (life>64 || (life&1)) {
3648 spriteDef[0]=0x41c;
3649 spriteDef[1]=0x41d;
3650 spriteDef[2]=0x43c;
3651 spriteDef[3]=0x43d;
3652 } else {
3653 spriteDef[0]=0;
3654 spriteDef[1]=0;
3655 spriteDef[2]=0;
3656 spriteDef[3]=0;
3657 }
3658 }
3659
3660 // FurnaceCVModS IMPLEMENTATION
3661
3662 void FurnaceCVModS::collision(FurnaceCVObject* other) {
3663 if (other->type==CV_PLAYER) {
3664 dead=true;
3665 cv->soundEffect(SE_PICKUP3);
3666 cv->addScore(200);
3667 cv->speedTicks=900;
3668 cv->e->setSongRate(cv->origSongRate*1.5);
3669 }
3670 }
3671
3672 void FurnaceCVModS::tick() {
3673 if (--life==0) dead=true;
3674
3675 if (life>64 || (life&1)) {
3676 spriteDef[0]=0x41e;
3677 spriteDef[1]=0x41f;
3678 spriteDef[2]=0x43e;
3679 spriteDef[3]=0x43f;
3680 } else {
3681 spriteDef[0]=0;
3682 spriteDef[1]=0;
3683 spriteDef[2]=0;
3684 spriteDef[3]=0;
3685 }
3686 }
3687
3688 // FurnaceCVEnemyVortex IMPLEMENTATION
3689
3690 void FurnaceCVEnemyVortex::collision(FurnaceCVObject* other) {
3691 if (other->type==CV_BULLET || other->type==CV_PLAYER) {
3692 dead=true;
3693 if ((rand()%2)==0) {
3694 switch (rand()%14) {
3695 case 0: // extra life
3696 cv->createObject<FurnaceCVExtraLife>(x,y);
3697 break;
3698 case 1: case 2: case 3: case 4: // powerup
3699 cv->createObject<FurnaceCVPowerupP>(x,y);
3700 break;
3701 case 5: case 6: case 7: case 8: case 9: // powerup
3702 cv->createObject<FurnaceCVPowerupS>(x,y);
3703 break;
3704 case 10: case 11: // special
3705 cv->createObject<FurnaceCVSpecial>(x,y);
3706 break;
3707 case 12: // mod
3708 cv->createObject<FurnaceCVModS>(x,y);
3709 break;
3710 case 13: // mod
3711 cv->createObject<FurnaceCVModI>(x,y);
3712 break;
3713 }
3714 }
3715 cv->soundEffect(SE_EXPL1);
3716 cv->createObject<FurnaceCVFurBallMedium>(x-4,y-4);
3717 cv->addScore(1000);
3718 }
3719 }
3720
3721 void FurnaceCVEnemyVortex::tick() {
3722 if (frozen>0) {
3723 if (--frozen>0) return;
3724 }
3725
3726 x+=speedX;
3727 y+=speedY;
3728 animFrame+=0x08;
3729
3730 if (--nextTime==0) {
3731 nextTime=10+(rand()%160);
3732 speedX=(rand()%5)-2;
3733 speedY=(rand()%5)-2;
3734 cv->soundEffect(SE_VORTEXMOVE);
3735 }
3736
3737 if (--shootTime==0) {
3738 shootTime=6+(rand()%100);
3739 cv->soundEffect(SE_VORTEXSHOOT);
3740 for (int i=0; i<6+cv->stage; i++) {
3741 float fraction=(float)i/(float)(5+cv->stage);
3742 float xs=cos(fraction*M_PI*2.0)*28;
3743 float ys=sin(fraction*M_PI*2.0)*28;
3744 FurnaceCVEnemyBullet* b=cv->createObject<FurnaceCVEnemyBullet>(x+4,y+4);
3745 b->setType(1);
3746 b->speedX=xs;
3747 b->speedY=ys;
3748 }
3749 }
3750
3751 if (HITS_BORDER) {
3752 CONFINE_TO_BORDER;
3753 }
3754
3755 spriteDef[0]=0x480+((animFrame>>5)<<1);
3756 spriteDef[1]=0x481+((animFrame>>5)<<1);
3757 spriteDef[2]=0x4a0+((animFrame>>5)<<1);
3758 spriteDef[3]=0x4a1+((animFrame>>5)<<1);
3759 }
3760
3761 // FurnaceCVEnemyPlane IMPLEMENTATION
3762
3763 void FurnaceCVEnemyPlane::collision(FurnaceCVObject* other) {
3764 // ignore completely
3765 }
3766
3767 void FurnaceCVEnemyPlane::tick() {
3768 switch (orient) {
3769 case 0:
3770 x+=speed;
3771 if (x>cv->stageWidthPx+32) dead=true;
3772 break;
3773 case 1:
3774 y-=speed;
3775 if (y<-160) dead=true;
3776 break;
3777 case 2:
3778 x-=speed;
3779 if (x<-160) dead=true;
3780 break;
3781 case 3:
3782 y+=speed;
3783 if (y>cv->stageHeightPx+32) dead=true;
3784 break;
3785 default:
3786 dead=true;
3787 logE("plane with invalid orientation %d",orient);
3788 break;
3789 }
3790
3791 if (notifyPlayer) {
3792 for (FurnaceCVObject* i: cv->sprite) {
3793 if (i->type==CV_PLAYER) {
3794 if (abs((x+(spriteWidth<<2))-(i->x+(i->spriteWidth<<2)))<((orient&1)?80:180)) {
3795 if (abs((y+(spriteHeight<<2))-(i->y+(i->spriteHeight<<2)))<((orient&1)?180:80)) {
3796 cv->soundEffect(SE_PLANE1);
3797 cv->soundEffect(SE_PLANE2);
3798 shootTime=(50-speed*4)+(rand()%20);
3799 notifyPlayer=false;
3800 }
3801 }
3802 break;
3803 }
3804 }
3805 } else {
3806 if (--shootTime<=0) {
3807 shootTime=28-(speed*2);
3808 cv->soundEffect(SE_EXPL2);
3809 cv->createObject<FurnaceCVFurBallLarge>(x+(spriteWidth<<2)-16,y+(spriteHeight<<2)-16);
3810 for (int i=0; i<14; i++) {
3811 float fraction=(float)i/13.0f;
3812 float xs=cos(fraction*M_PI*2.0)*28;
3813 float ys=sin(fraction*M_PI*2.0)*28;
3814 FurnaceCVEnemyBullet* b=cv->createObject<FurnaceCVEnemyBullet>(x+(spriteWidth<<2)-4,y+(spriteHeight<<2)-4);
3815 b->speedX=xs;
3816 b->speedY=ys;
3817 }
3818 }
3819 }
3820 }