summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPixel <Pixel>2002-07-19 12:52:47 +0000
committerPixel <Pixel>2002-07-19 12:52:47 +0000
commit492ca575941d0e30b3725bf7a9966cab8df7e238 (patch)
tree5cd34563c530988291691bd0a2a671e1a416b0e2
parent2d5f7c1052fb4206cc46fffe236ebfcac4ee316f (diff)
Moved everything in the right place. Cleaner now.
-rwxr-xr-xMakefile35
-rwxr-xr-xMegamanX5/Makefile6
-rwxr-xr-xVP/Makefile18
-rwxr-xr-xXenogears/Makefile22
-rw-r--r--dtemain.cpp1
-rwxr-xr-xlib/Makefile11
-rw-r--r--lib/cdutils.cpp (renamed from cdutils.cpp)0
-rw-r--r--lib/crctable.out (renamed from crctable.out)0
-rw-r--r--lib/crctables (renamed from crctables)0
-rw-r--r--lib/dteutils.cpp (renamed from dteutils.cpp)0
-rw-r--r--lib/fileutils.cpp (renamed from fileutils.cpp)0
-rw-r--r--lib/generic.cpp (renamed from generic.cpp)0
-rw-r--r--lib/lzss.cpp (renamed from lzss.cpp)0
-rw-r--r--lib/yazedc.cpp (renamed from yazedc.cpp)0
-rw-r--r--psxdev/Makefile2
-rw-r--r--str-player.cpp215
16 files changed, 269 insertions, 41 deletions
diff --git a/Makefile b/Makefile
index f8e9ad3..1d95ce6 100755
--- a/Makefile
+++ b/Makefile
@@ -1,39 +1,40 @@
#!/usr/bin/make -f
-CPPFLAGS=-Wall -g -O3 -mcpu=i686 -pedantic -pedantic-errors -Werror
+CPPFLAGS=-Wall -g -O3 -mcpu=i686 -pedantic -pedantic-errors -Werror -Iincludes `sdl-config --cflags`
+LDFLAGS=`sdl-config --libs`
CXX=g++
-SUBDIRS = psxdev Xenogears VP MegamanX5
-TARGET = lzss dlzss cd-tool str-tool crypto-search bgrep
+SUBDIRS = psxdev lib Xenogears VP MegamanX5
+TARGET = lzss dlzss cd-tool str-player crypto-search bgrep dte-tool
all: subdirs ${TARGET}
subdirs:
for d in ${SUBDIRS} ; do make -C $$d || exit -1 ; done
-lzss: lzss.o lzss.h generic.o generic.h fileutils.h fileutils.o lzss-main.o Makefile
- ${CXX} ${LDFLAGS} -DLZSS_MAIN lzss.o generic.o fileutils.o lzss-main.o -o lzss
+lzss: lib/lzss.o includes/lzss.h lib/generic.o includes/generic.h includes/fileutils.h lib/fileutils.o lzss-main.o Makefile
+ ${CXX} ${LDFLAGS} -DLZSS_MAIN lib/lzss.o lib/generic.o lib/fileutils.o lzss-main.o -o lzss
dlzss: lzss Makefile
ln -fs lzss dlzss
-yazedc: yazedc.o crctables crctable.out yazedc-main.o Makefile
- ${CXX} ${LDFLAGS} yazedc.o yazedc-main.o -DMAIN -o yazedc
+yazedc: lib/yazedc.o lib/crctables lib/crctable.out yazedc-main.o Makefile
+ ${CXX} ${LDFLAGS} lib/yazedc.o yazedc-main.o -DMAIN -o yazedc
-cd-tool: cd-tool.o cdutils.o cdutils.h fileutils.o fileutils.h generic.o generic.h yazedc.o yazedc.h Makefile
- ${CXX} ${LDFLAGAS} cd-tool.o cdutils.o fileutils.o yazedc.o generic.o -o cd-tool
+cd-tool: cd-tool.o lib/cdutils.o includes/cdutils.h lib/fileutils.o includes/fileutils.h lib/generic.o includes/generic.h lib/yazedc.o includes/yazedc.h Makefile
+ ${CXX} ${LDFLAGAS} cd-tool.o lib/cdutils.o lib/fileutils.o lib/yazedc.o lib/generic.o -o cd-tool
-dte-tool: dteutils.o generic.h generic.o fileutils.o fileutils.h dtemain.o Makefile
- ${CXX} ${LDFLAGS} dteutils.o generic.o fileutils.o dtemain.o -o dte-tool
+dte-tool: lib/dteutils.o includes/generic.h lib/generic.o lib/fileutils.o includes/fileutils.h includes/dte.h dtemain.o Makefile
+ ${CXX} ${LDFLAGS} lib/dteutils.o lib/generic.o lib/fileutils.o dtemain.o -o dte-tool
-str-tool: str-util.o generic.h generic.o fileutils.o fileutils.h cdutils.o cdutils.h yazedc.o yazedc.h Makefile
- ${CXX} ${LDFLAGS} str-util.o generic.o fileutils.o cdutils.o yazedc.o psxdev/bs.o psxdev/idctfst.o psxdev/jfdctint.o psxdev/vlc.o psxdev/xadecode.o -o str-tool -lSDL
+str-player: str-player.o includes/generic.h lib/generic.o lib/fileutils.o includes/fileutils.h lib/cdutils.o includes/cdutils.h lib/yazedc.o includes/yazedc.h Makefile
+ ${CXX} ${LDFLAGS} str-player.o lib/generic.o lib/fileutils.o lib/cdutils.o lib/yazedc.o psxdev/bs.o psxdev/idctfst.o psxdev/jfdctint.o psxdev/vlc.o psxdev/xadecode.o -o str-player
-crypto-search: crypto-search.o generic.h generic.o fileutils.o fileutils.h Makefile
- ${CXX} ${LDFLAGS} crypto-search.o generic.o fileutils.o -o crypto-search
+crypto-search: crypto-search.o includes/generic.h lib/generic.o lib/fileutils.o includes/fileutils.h Makefile
+ ${CXX} ${LDFLAGS} crypto-search.o lib/generic.o lib/fileutils.o -o crypto-search
-bgrep: bgrep.o generic.h generic.o fileutils.h fileutils.o Makefile
- ${CXX} ${LDFLAGS} bgrep.o generic.o fileutils.o -o bgrep
+bgrep: bgrep.o includes/generic.h lib/generic.o includes/fileutils.h lib/fileutils.o Makefile
+ ${CXX} ${LDFLAGS} bgrep.o lib/generic.o lib/fileutils.o -o bgrep
clean:
for d in ${SUBDIRS} ; do make -C $$d clean || exit -1 ; done
diff --git a/MegamanX5/Makefile b/MegamanX5/Makefile
index 80db8f8..c655df9 100755
--- a/MegamanX5/Makefile
+++ b/MegamanX5/Makefile
@@ -1,14 +1,14 @@
#!/usr/bin/make -f
-CPPFLAGS=-Wall -g -O3 -mcpu=i686 -pedantic -pedantic-errors -Werror -I..
+CPPFLAGS=-Wall -g -O3 -mcpu=i686 -pedantic -pedantic-errors -Werror -I../includes
CXX=g++
TARGET = unarc
all: ${TARGET}
-unarc: unarc.o ../fileutils.h ../fileutils.cpp ../generic.h ../generic.cpp Makefile
- ${CXX} ${LDFLAGS} unarc.o ../fileutils.o ../generic.o -o unarc
+unarc: unarc.o ../includes/fileutils.h ../lib/fileutils.cpp ../includes/generic.h ../lib/generic.cpp Makefile
+ ${CXX} ${LDFLAGS} unarc.o ../lib/fileutils.o ../lib/generic.o -o unarc
clean:
rm -f *.o ${TARGET} compil.c
diff --git a/VP/Makefile b/VP/Makefile
index 13a540e..9cc267d 100755
--- a/VP/Makefile
+++ b/VP/Makefile
@@ -1,23 +1,23 @@
#!/usr/bin/make -f
-CPPFLAGS=-Wall -g -O3 -mcpu=i686 -pedantic -pedantic-errors -Werror -I..
+CPPFLAGS=-Wall -g -O3 -mcpu=i686 -pedantic -pedantic-errors -Werror -I../includes
CXX=g++
TARGET = main_dump VP-CD1.sqr decomp-slz unarc search-script
all: ${TARGET}
-main_dump: main_dump.o ../fileutils.o ../fileutils.h ../cdutils.o ../cdutils.h ../generic.o ../generic.h Makefile
- ${CXX} ${LDFLAGS} main_dump.o ../yazedc.o ../fileutils.o ../cdutils.o ../generic.o -o main_dump
+main_dump: main_dump.o ../lib/fileutils.o ../includes/fileutils.h ../lib/cdutils.o ../includes/cdutils.h ../lib/generic.o ../includes/generic.h Makefile
+ ${CXX} ${LDFLAGS} main_dump.o ../lib/yazedc.o ../lib/fileutils.o ../lib/cdutils.o ../lib/generic.o -o main_dump
-decomp-slz: decomp-slz.o ../fileutils.o ../fileutils.h ../generic.o ../generic.h ../lzss.o ../lzss.h Makefile
- ${CXX} ${LDFLAGS} decomp-slz.o ../fileutils.o ../generic.o ../lzss.o -o decomp-slz
+decomp-slz: decomp-slz.o ../lib/fileutils.o ../includes/fileutils.h ../lib/generic.o ../includes/generic.h ../lib/lzss.o ../includes/lzss.h Makefile
+ ${CXX} ${LDFLAGS} decomp-slz.o ../lib/fileutils.o ../lib/generic.o ../lib/lzss.o -o decomp-slz
-unarc: unarc.o ../fileutils.o ../fileutils.h ../generic.o ../generic.h Makefile
- ${CXX} ${LDFLAGS} unarc.o ../fileutils.o ../generic.o -o unarc
+unarc: unarc.o ../lib/fileutils.o ../includes/fileutils.h ../lib/generic.o ../includes/generic.h Makefile
+ ${CXX} ${LDFLAGS} unarc.o ../lib/fileutils.o ../lib/generic.o -o unarc
-search-script: search-script.o ../fileutils.o ../fileutils.h ../generic.o ../generic.h Makefile
- ${CXX} ${LDFLAGS} search-script.o ../fileutils.o ../generic.o -o search-script
+search-script: search-script.o ../lib/fileutils.o ../includes/fileutils.h ../lib/generic.o ../includes/generic.h Makefile
+ ${CXX} ${LDFLAGS} search-script.o ../lib/fileutils.o ../lib/generic.o -o search-script
clean:
rm -f *.o ${TARGET}
diff --git a/Xenogears/Makefile b/Xenogears/Makefile
index e5b3945..339b9a2 100755
--- a/Xenogears/Makefile
+++ b/Xenogears/Makefile
@@ -1,26 +1,26 @@
#!/usr/bin/make -f
-CPPFLAGS=-Wall -g -O3 -mcpu=i686 -pedantic -pedantic-errors -I..
+CPPFLAGS=-Wall -g -O3 -mcpu=i686 -pedantic -pedantic-errors -I../includes
CXX=g++
TARGET = reinsert main_dump Decrypt script-comp script-dec XenoCD1.sqr XenoCD2.sqr
all: ${TARGET}
-main_dump: main_dump.o ../cdutils.o ../cdutils.h ../fileutils.o ../fileutils.h ../generic.o ../generic.h ../yazedc.o ../yazedc.h Makefile
- ${CXX} ${LDFLAGS} main_dump.o ../cdutils.o ../fileutils.o ../yazedc.o ../generic.o -o main_dump
+main_dump: main_dump.o ../lib/cdutils.o ../includes/cdutils.h ../lib/fileutils.o ../includes/fileutils.h ../lib/generic.o ../includes/generic.h ../lib/yazedc.o ../includes/yazedc.h Makefile
+ ${CXX} ${LDFLAGS} main_dump.o ../lib/cdutils.o ../lib/fileutils.o ../lib/yazedc.o ../lib/generic.o -o main_dump
-reinsert: reinsert.o ../cdutils.o ../cdutils.h ../fileutils.o ../fileutils.h ../generic.o ../generic.h ../yazedc.o ../yazedc.h Makefile
- ${CXX} ${LDFLAGS} reinsert.o ../cdutils.o ../fileutils.o ../yazedc.o ../generic.o -o reinsert
+reinsert: reinsert.o ../lib/cdutils.o ../includes/cdutils.h ../lib/fileutils.o ../includes/fileutils.h ../lib/generic.o ../includes/generic.h ../lib/yazedc.o ../includes/yazedc.h Makefile
+ ${CXX} ${LDFLAGS} reinsert.o ../lib/cdutils.o ../lib/fileutils.o ../lib/yazedc.o ../lib/generic.o -o reinsert
-Decrypt: Decrypt.o ../fileutils.o ../fileutils.h ../generic.o ../generic.h Makefile
- ${CXX} ${LDFLAGS} Decrypt.o ../fileutils.o ../generic.o -o Decrypt
+Decrypt: Decrypt.o ../lib/fileutils.o ../includes/fileutils.h ../lib/generic.o ../includes/generic.h Makefile
+ ${CXX} ${LDFLAGS} Decrypt.o ../lib/fileutils.o ../lib/generic.o -o Decrypt
-script-comp: script-comp.o ../fileutils.o ../fileutils.h ../generic.o ../generic.h ../lzss.o ../lzss.h Makefile
- ${CXX} ${LDFLAGS} script-comp.o ../fileutils.o ../generic.o ../lzss.o -o script-comp
+script-comp: script-comp.o ../lib/fileutils.o ../includes/fileutils.h ../lib/generic.o ../includes/generic.h ../lib/lzss.o ../includes/lzss.h Makefile
+ ${CXX} ${LDFLAGS} script-comp.o ../lib/fileutils.o ../lib/generic.o ../lib/lzss.o -o script-comp
-script-dec: script-dec.o ../fileutils.o ../fileutils.h ../generic.o ../generic.h ../lzss.o ../lzss.h Makefile
- ${CXX} ${LDFLAGS} script-dec.o ../fileutils.o ../generic.o ../lzss.o -o script-dec
+script-dec: script-dec.o ../lib/fileutils.o ../includes/fileutils.h ../lib/generic.o ../includes/generic.h ../lib/lzss.o ../includes/lzss.h Makefile
+ ${CXX} ${LDFLAGS} script-dec.o ../lib/fileutils.o ../lib/generic.o ../lib/lzss.o -o script-dec
clean:
rm -f *.o ${TARGET} compil.c
diff --git a/dtemain.cpp b/dtemain.cpp
index 404f52f..c044c79 100644
--- a/dtemain.cpp
+++ b/dtemain.cpp
@@ -23,6 +23,7 @@
#include <string.h>
#include "fileutils.h"
#include "generic.h"
+#include "dte.h"
int main(int argc, char ** argv) {
FILE * f, * t;
diff --git a/lib/Makefile b/lib/Makefile
new file mode 100755
index 0000000..5503701
--- /dev/null
+++ b/lib/Makefile
@@ -0,0 +1,11 @@
+#!/usr/bin/make -f
+
+CPPFLAGS=-Wall -g -O3 -mcpu=i686 -pedantic -pedantic-errors -Werror -I../includes
+CXX=g++
+
+TARGET = cdutils.o dteutils.o fileutils.o generic.o lzss.o yazedc.o
+
+all: ${TARGET}
+
+clean:
+ rm -f *.o ${TARGET} compil.c
diff --git a/cdutils.cpp b/lib/cdutils.cpp
index 0dd0e8a..0dd0e8a 100644
--- a/cdutils.cpp
+++ b/lib/cdutils.cpp
diff --git a/crctable.out b/lib/crctable.out
index 47842cd..47842cd 100644
--- a/crctable.out
+++ b/lib/crctable.out
diff --git a/crctables b/lib/crctables
index 3dd89c1..3dd89c1 100644
--- a/crctables
+++ b/lib/crctables
diff --git a/dteutils.cpp b/lib/dteutils.cpp
index 4ae8668..4ae8668 100644
--- a/dteutils.cpp
+++ b/lib/dteutils.cpp
diff --git a/fileutils.cpp b/lib/fileutils.cpp
index b04a414..b04a414 100644
--- a/fileutils.cpp
+++ b/lib/fileutils.cpp
diff --git a/generic.cpp b/lib/generic.cpp
index d165d27..d165d27 100644
--- a/generic.cpp
+++ b/lib/generic.cpp
diff --git a/lzss.cpp b/lib/lzss.cpp
index 4f9e424..4f9e424 100644
--- a/lzss.cpp
+++ b/lib/lzss.cpp
diff --git a/yazedc.cpp b/lib/yazedc.cpp
index f4bced0..f4bced0 100644
--- a/yazedc.cpp
+++ b/lib/yazedc.cpp
diff --git a/psxdev/Makefile b/psxdev/Makefile
index fb1cc78..0ddfc4f 100644
--- a/psxdev/Makefile
+++ b/psxdev/Makefile
@@ -3,7 +3,7 @@
TARGETS=xadecode.o bs.o idctfst.o jfdctint.o vlc.o
CC=gcc
-CPPFLAGS=-Wall -g -O3 -mcpu=i686 -pedantic -I..
+CPPFLAGS=-Wall -g -O3 -mcpu=i686 -pedantic -I../includes
# -Werror
# -pedantic-errors
diff --git a/str-player.cpp b/str-player.cpp
new file mode 100644
index 0000000..223270c
--- /dev/null
+++ b/str-player.cpp
@@ -0,0 +1,215 @@
+#include <stdlib.h>
+#include <string.h>
+#include <SDL/SDL.h>
+#include <SDL/SDL_audio.h>
+#include "psxdev/bs.h"
+#include "fileutils.h"
+#include "generic.h"
+#include "cdutils.h"
+#include "psxdev/xadecode.h"
+
+/*
+
+ From the SONY documentation:
+
+ 32 bytes header:
+
+StSTATUS : 2 bytes 0
+StTYPE : 2 bytes 2
+StSECTOR_OFFSET: 2 bytes 4
+StSECTOR_SIZE : 2 bytes 6
+StFRAME_NO : 4 bytes 10
+StFRAME_SIZE : 4 bytes 14
+StMOVIE_WIDTH : 2 bytes 16
+StMOVIE_HEIGHT : 2 bytes 18
+StMOVIE_HEADM : 4 bytes 22
+StMOVIE_HEADV : 4 bytes 26
+Channels : 2 bytes 30
+
+ */
+
+struct STR_Header {
+ Uint16 StSTATUS;
+ Uint16 StTYPE;
+ Uint16 StSECTOR_OFFSET;
+ Uint16 StSECTOR_SIZE;
+ Uint32 StFRAME_NO;
+ Uint32 StFRAME_SIZE;
+ Uint16 StMOVIE_WIDTH;
+ Uint16 StMOVIE_HEIGHT;
+ Uint32 StMOVIE_HEADM;
+ Uint32 StMOVIE_HEADV;
+ Uint16 Channels;
+} PACKED;
+
+Byte * video = 0, * audio = 0, * audio2 = 0;
+
+int width, height;
+
+SDL_Surface * screen = 0;
+Uint8 bpp;
+
+int32 audio_len = 0, audio_len2 = 0;
+Uint8 *audio_pos;
+
+void mixaudio(void *unused, Uint8 *stream, int len) {
+ /* Only play if we have data left */
+ if ( audio_len == 0 )
+ return;
+
+ /* Mix as much data as possible */
+ len = ( len > audio_len ? audio_len : len );
+ SDL_MixAudio(stream, audio_pos, len, SDL_MIX_MAXVOLUME);
+ audio_pos += len;
+ audio_len -= len;
+}
+
+void process_one_sector(FILE * f) {
+ Byte sector[2336];
+ STR_Header * h;
+
+ fread(sector, 2336, 1, f);
+ h = (STR_Header *) ((Byte *) sector + 8);
+// printm(M_INFO, "SubHeader: FN = %x, CN = %x, SM = %x, CI = %x: ", sector[0], sector[1], sector[2], sector[3]);
+/*
+ printm(M_BARE, "SubHeader FN : %x\n", sector[0]);
+ printm(M_BARE, "SubHeader CN : %x\n", sector[1]);
+ printm(M_BARE, "SubHeader SM : %x\n", sector[2]);
+ printm(M_BARE, "SubHeader CI : %x\n", sector[3]);
+*/
+ if ((sector[2] == 0x48) || (sector[2] == 0x42)) {
+// printm(M_BARE, "Video sector\n");
+/* printm(M_BARE, "Status : %04x\n", h->StSTATUS);
+ printm(M_BARE, "Type : %04x\n", h->StTYPE);
+ printm(M_BARE, "Sector Offset: %i\n", h->StSECTOR_OFFSET);
+ printm(M_BARE, "Sector Size : %i\n", h->StSECTOR_SIZE);
+ printm(M_BARE, "Frame Number : %i\n", h->StFRAME_NO);
+ printm(M_BARE, "Frame Size : %i\n", h->StFRAME_SIZE);
+ printm(M_BARE, "Movie Width : %i\n", h->StMOVIE_WIDTH);
+ printm(M_BARE, "Movie Height : %i\n", h->StMOVIE_HEIGHT);
+ printm(M_BARE, "Movie HeadM : %08x\n", h->StMOVIE_HEADM);
+ printm(M_BARE, "Movie HeadV : %08x\n", h->StMOVIE_HEADV);
+ printm(M_BARE, "Channels : %04x\n", h->Channels); */
+ if (h->StSECTOR_OFFSET == 0) {
+ video = (Byte *) malloc(h->StSECTOR_SIZE * 2016);
+ if (!screen) {
+ bs_init();
+ width = h->StMOVIE_WIDTH;
+ height = h->StMOVIE_HEIGHT;
+ screen = SDL_SetVideoMode(width, height, 24, SDL_HWSURFACE | SDL_DOUBLEBUF);
+ if (!screen) {
+ printm(M_ERROR, "Couldn't get framebuffer\n");
+ exit(-1);
+ }
+ bpp = screen->format->BytesPerPixel;
+ }
+ }
+
+ memcpy(video + h->StSECTOR_OFFSET * 2016, sector + 40, 2016);
+
+ if (h->StSECTOR_SIZE == (h->StSECTOR_OFFSET + 1)) {
+ // Frame finished.
+// printm(M_BARE, "End of Frame.\n");
+
+ Uint8 * buffer = ((Uint8 *) screen->pixels);
+
+ if (SDL_MUSTLOCK(screen))
+ if (SDL_LockSurface(screen) < 0)
+ exit(1);
+// printm(M_BARE, "Width: %i, Height: %i - bpp: %i\n", width, height, bpp);
+ bs_decode_rgb24(buffer, (bs_header_t *) video, width, height, 0);
+
+// fwrite(screen->pixels, 3, width * height, stdout);
+
+ if (SDL_MUSTLOCK(screen))
+ SDL_UnlockSurface(screen);
+ SDL_Flip(screen);
+
+ free(video);
+ }
+ } else if (sector[2] == 0x64) {
+ int locked = 0;
+
+ SoundSector * buffer = (SoundSector *) sector;
+// printm(M_BARE, "Audio sector\n");
+/* printm(M_BARE, "Frequency: %i\n", xahalfhz(buffer) ? 18900 : 37800);
+ printm(M_BARE, "Channels : %s\n", xastereo(buffer) ? "stereo" : "mono"); */
+// fwrite(sector + 8, 1, 2324, stdout);
+
+ while (audio_len > 0) {
+ SDL_Delay(1);
+ }
+
+ if (!audio2) {
+ SDL_AudioSpec fmt;
+
+ /* Un son sereo de 16 bits à 44kHz */
+ fmt.freq = xahalfhz(buffer) ? 18900 : 37800;
+ fmt.format = AUDIO_S16;
+ fmt.channels = xastereo(buffer) ? 2 : 1;
+ fmt.samples = 128; /*Une bonne valeur pour les jeux */
+ fmt.callback = mixaudio;
+ fmt.userdata = NULL;
+
+ /* Ouvre le contexte audio et joue le son */
+ if (SDL_OpenAudio(&fmt, NULL) < 0) {
+ fprintf(stderr, "Impossible d'accéder à l'audio: %s\n", SDL_GetError());
+ exit(1);
+ }
+
+ initXaDecode();
+ } else {
+ if (audio) {
+ SDL_LockAudio();
+ free(audio);
+ locked = 1;
+ }
+ audio_pos = audio = audio2;
+ audio_len = audio_len2;
+ }
+
+ audio2 = (Byte *) malloc(8192);
+ switchXaDecode(xachannel(buffer));
+ audio_len2 = convXaToWave((char *) buffer, (char *) audio2, xachannel(buffer), 0, 255);
+ if (locked)
+ SDL_UnlockAudio();
+ else if (audio)
+ SDL_PauseAudio(0);
+ saveXaDecode(xachannel(buffer));
+
+ } else {
+// printm(M_BARE, "Unknow sector\n");
+ }
+// printm(M_BARE, "---------------------------------\n\n");
+}
+
+int main(int argc, char ** argv) {
+ if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER) < 0) {
+ printm(M_ERROR, "Couldn't initialise SDL: %s\n", SDL_GetError());
+ exit(-1);
+ }
+ atexit(SDL_Quit);
+ SDL_ShowCursor(SDL_DISABLE);
+
+
+ switch (argc) {
+ case 1:
+ break;
+ case 2:
+ fclose(stdin);
+ stdin = fopen(argv[1], "r");
+ break;
+ default:
+ printm(M_ERROR, "Too much arguments.\n");
+ exit(-1);
+ }
+
+ while (!feof(stdin)) {
+ process_one_sector(stdin);
+ }
+
+ if (!audio)
+ SDL_CloseAudio();
+
+ SDL_Quit();
+}