-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
81 lines (67 loc) · 1.98 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#include <stdio.h>
#include "sdl-audio.h"
#include "resid.h"
#include "resid-dmpplayer.h"
#include "resid-visualizer.h"
#include "sidekick-logo.h"
#include "music-turrican.h"
#include "music-cybernoidII.h"
SDL_AudioDeviceID SDL_Audio_DevID;
SDL_AudioSpec SDL_Audio_Spec;
ReSID R;
ReSIDPbData D;
ReSIDDmpPlayer DP(&R, &D);
ReSIDVisualizer RV(&R, &D);
void init()
{
sdl_audio_init(&SDL_Audio_DevID, &SDL_Audio_Spec, &D);
}
int main(int argc, char **argv)
{
SDL_Event event;
printf("[MAIN ] sidekick!\n");
init();
// -- load sid dmp
DP.setDmp(Cybernoid_II_dmp, Cybernoid_II_dmp_len);
// DP.setDmp(turrican_dmp, turrican_dmp_len);
// print logo
printf("%s", sidekick_unicode);
printf("\x1b[2A"); // 2 lines up
printf("\x1b[?25l"); // cursor off
printf("\x1b[38;5;60m"); // color
printf(
" "
" ");
printf("2023, M64\r");
printf("\x1b[0m"); // reset all attributes
// -- play sid dmp
DP.play();
int i = 0;
printf("\x1b[1A"); // 1 lines up
while(!DP.update()) {
SDL_Delay(5); // time to do stuff
// -- do visual stuff
if(!(i++%4)) {
RV.visualize();
}
// -- ctrl-c handler
if(SDL_PollEvent(&event)) {
switch(event.type) {
case SDL_QUIT:
printf("\x1b[8B"); // 8 lines down
printf("\x1b[?25h"); // cursor on
printf("\x1b[0m"); // reset all attributes
printf("\n[MAIN ] ctrl-c hit, exitting ...\n");
exit(1);
break;
default:
break;
}
}
}
printf("\x1b[8B"); // 8 lines down
printf("\x1b[?25h"); // cursor on
printf("\x1b[0m"); // reset all attributes (cursor color)
printf("\n[MAIN ] sidekick end.\n");
return 0;
}