-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.c
181 lines (143 loc) · 5 KB
/
Main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
#include "System.h"
#include "LED.h"
#include "Button.h"
#include "VGA.h"
#include "RCC.h"
#include "Audio.h"
#include "Random.h"
#include "Utils.h"
#include "BitBin.h"
#include "Global.h"
#include "Fields.h"
#include "LogoShow.h"
#include "Mystery.h"
#include "PixelParticles.h"
#include "Pukezoomer.h"
#include "Rasterize.h"
#include "Starfield.h"
#include "TorusTunnel.h"
#include "Voxelscape.h"
#include "Credits.h"
#include "Environment.h"
#include <string.h>
#define ATTRACT_MODE 0
#define LOOP_MODE 0
static void AudioCallback(void *context,int buffer);
int16_t *buffers[2]={ (int16_t *)0x2001fa00,(int16_t *)0x2001fc00 };
extern BitBinNote *channels[8];
BitBinSong* songp;
union GlobalData data;
int main()
{
InitializeLEDs();
InitializeSystem();
SysTick_Config(HCLKFrequency()/100);
InitializeLEDs();
InitializeUserButton();
BitBinSong song;
// InitializeBitBinSong(&song,BitBin22kTable,8,1952,channels);
// SetBitBinSongLoops(&song,true);
songp = &song;
// InitializeAudio(Audio22050HzSettings);
// SetAudioVolume(0xAA);
// InitializeAudio(Audio44100HzSettings);
//PlayAudioWithCallback(AudioCallback,&song);
InitializeVGA();
// Part Length Effect Next Row total
// --------------------------------------------------------------------------------------------------
// INTRO
// 256 Metablobs() -> STARFIELD 256
// 128 Pukezoomer(), Fadeout 384
// 128 LogoShow() Titlecard 512
// 160 Reflector() -> add sync!! 672
// Ticking
// 128 TorusTunnel() 800
// Happy
// 128 Voxelscape() -> OVERLAY 928
// 128 Rasterize() -> OVERLAY 1056
// 128 Fields() -> OVERLAY 1184
// Bubbly
// 128 PixelParticles() -> add sync? 1312
// Mystery
// 256 Starfield(); 1568
// 128 Credits(); 1696
// 256 IDontEvenKnow(); 1940
if(ATTRACT_MODE) {
while(1) {
Metablobs(1);
int32_t darkFrame = VGAFrame;
uint8_t *framebuffer1=(uint8_t *)0x20000000;
uint8_t *framebuffer2=(uint8_t *)0x20010000;
memset(framebuffer1,0,320*200);
memset(framebuffer2,0,320*200);
SetVGAScreenMode320x200_60Hz(framebuffer1);
int frame = 0;
while(!UserButtonState()) {
if(frame&1) { SetFrameBuffer(framebuffer1); }
else { SetFrameBuffer(framebuffer2); }
WaitVBL();
frame++;
}
while(UserButtonState());
if(frame < 50) {
break;
}
}
}
for(;;)
{
uint8_t *framebuffer1=(uint8_t *)0x20000000;
uint8_t *framebuffer2=(uint8_t *)0x20010000;
memset(framebuffer1,0,320*200);
memset(framebuffer2,0,320*200);
SetVGAScreenMode320x200_60Hz(framebuffer1);
for(int i = 0; i < 200; i++) {
if(i&1) { SetFrameBuffer(framebuffer1); }
else { SetFrameBuffer(framebuffer2); }
WaitVBL();
}
InitializeBitBinSong(&song,BitBin22kTable,8,1920,channels);
InitializeAudio(Audio22050HzSettings);
SetAudioVolume(0xCC);
PlayAudioWithCallback(AudioCallback,&song);
Metablobs(0);
Pukezoomer();
LogoShow();
Environment();
TorusTunnel();
Voxelscape();
RasterizeInit();
Rasterize();
Fields();
PixelParticles();
Starfield();
Credits();
IDontEvenKnow();
if(!LOOP_MODE) {
while(1) {
}
}
}
}
static void AudioCallback(void *context,int buffer)
{
BitBinSong *song=context;
int16_t *samples=buffers[buffer];
RenderBitBinSamples(song,128,samples);
for(int i=128;i>=0;i--)
{
samples[2*i+0]=samples[i];
samples[2*i+1]=samples[i];
}
ProvideAudioBuffer(samples,256);
}
volatile uint32_t SysTickCounter=0;
void Delay(uint32_t time)
{
uint32_t end=SysTickCounter+time;
while(SysTickCounter!=end);
}
void SysTick_Handler()
{
SysTickCounter++;
}