diff options
Diffstat (limited to 'str-player.cpp')
-rw-r--r-- | str-player.cpp | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/str-player.cpp b/str-player.cpp index 223270c..7d9f47b 100644 --- a/str-player.cpp +++ b/str-player.cpp @@ -2,8 +2,8 @@ #include <string.h> #include <SDL/SDL.h> #include <SDL/SDL_audio.h> +#include "Input.h" #include "psxdev/bs.h" -#include "fileutils.h" #include "generic.h" #include "cdutils.h" #include "psxdev/xadecode.h" @@ -64,11 +64,11 @@ void mixaudio(void *unused, Uint8 *stream, int len) { audio_len -= len; } -void process_one_sector(FILE * f) { +void process_one_sector(Handle * f) { Byte sector[2336]; STR_Header * h; - fread(sector, 2336, 1, f); + f->read(sector, 2336); 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]); /* @@ -184,6 +184,8 @@ void process_one_sector(FILE * f) { } int main(int argc, char ** argv) { + Handle * file = 0; + 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); @@ -194,18 +196,18 @@ int main(int argc, char ** argv) { switch (argc) { case 1: + file = &Stdin; break; case 2: - fclose(stdin); - stdin = fopen(argv[1], "r"); + file = new Input(argv[1]); break; default: printm(M_ERROR, "Too much arguments.\n"); exit(-1); } - while (!feof(stdin)) { - process_one_sector(stdin); + while (1) { + process_one_sector(file); } if (!audio) |