initial commit
took me a day to make the base... ...and ~12 hours to write a reader that reads 100% of all demo songs in 1.0
This commit is contained in:
commit
783d56c72a
26 changed files with 1660 additions and 0 deletions
65
src/main.cpp
Normal file
65
src/main.cpp
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
#include <stdio.h>
|
||||
#include <mutex>
|
||||
#include "ta-log.h"
|
||||
#include "engine/engine.h"
|
||||
|
||||
DivEngine e;
|
||||
|
||||
std::mutex m;
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
if (argc<2) {
|
||||
logI("usage: %s file\n",argv[0]);
|
||||
return 1;
|
||||
}
|
||||
logI("divorce dev0\n");
|
||||
logI("loading module...\n");
|
||||
FILE* f=fopen(argv[1],"rb");
|
||||
if (f==NULL) {
|
||||
perror("error");
|
||||
return 1;
|
||||
}
|
||||
if (fseek(f,0,SEEK_END)<0) {
|
||||
perror("size error");
|
||||
fclose(f);
|
||||
return 1;
|
||||
}
|
||||
ssize_t len=ftell(f);
|
||||
if (len<1) {
|
||||
if (len==0) {
|
||||
printf("that file is empty!\n");
|
||||
} else {
|
||||
perror("tell error");
|
||||
}
|
||||
fclose(f);
|
||||
return 1;
|
||||
}
|
||||
unsigned char* file=new unsigned char[len];
|
||||
if (fseek(f,0,SEEK_SET)<0) {
|
||||
perror("size error");
|
||||
fclose(f);
|
||||
return 1;
|
||||
}
|
||||
if (fread(file,1,(size_t)len,f)!=(size_t)len) {
|
||||
perror("read error");
|
||||
fclose(f);
|
||||
return 1;
|
||||
}
|
||||
fclose(f);
|
||||
if (!e.load((void*)file,(size_t)len)) {
|
||||
logE("could not open file!\n");
|
||||
return 1;
|
||||
}
|
||||
if (!e.init()) {
|
||||
logE("could not initialize engine!\n");
|
||||
return 1;
|
||||
}
|
||||
logI("loaded! :o\n");
|
||||
while (true) {
|
||||
logI("locking...\n");
|
||||
e.play();
|
||||
m.lock();
|
||||
m.lock();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue