summaryrefslogtreecommitdiff
path: root/str-player.cpp
diff options
context:
space:
mode:
authorpixel <pixel>2004-02-27 04:12:32 +0000
committerpixel <pixel>2004-02-27 04:12:32 +0000
commitab3512285bb0ecf721cfd9a015f0e32dbf2751a6 (patch)
tree56de0be6d033297e664d3a1dd8c38ca935941dbb /str-player.cpp
parentdd1a70b70cc5a4ab3a7dbeef2862d4a817fd91a7 (diff)
Fixing str-player
Diffstat (limited to 'str-player.cpp')
-rw-r--r--str-player.cpp34
1 files changed, 25 insertions, 9 deletions
diff --git a/str-player.cpp b/str-player.cpp
index d13b706..fa5f17a 100644
--- a/str-player.cpp
+++ b/str-player.cpp
@@ -4,6 +4,7 @@
#include <SDL/SDL_audio.h>
#include <getopt.h>
#include "Input.h"
+#include "Output.h"
#include "psxdev/bs.h"
#include "generic.h"
#include "cdutils.h"
@@ -44,7 +45,7 @@ struct STR_Header {
Uint16 Channels;
} PACKED;
-Byte * video = 0, * audio = 0, * audio2 = 0;
+Byte * video = 0, * audio = 0, * audio2 = 0, * tbuffer = 0;
int channel = -1;
@@ -69,24 +70,28 @@ void mixaudio(void *unused, Uint8 *stream, int len) {
}
CODE_BEGINS
-void process_one_sector(Handle * f) {
+int process_one_sector(Handle * f) {
Byte sector[2336];
STR_Header * h;
- f->read(sector, 2336);
+ if (!f->read(sector, 2336))
+ return 0;
h = (STR_Header *) ((Byte *) sector + 8);
+#ifdef CHATTING
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]);
+#endif
if ((channel != -1) && (channel != sector[1]))
- return;
+ return -1;
- if ((sector[2] == 0x48) || (sector[2] == 0x42)) {
+ if ((sector[2] == 0x48) || (sector[2] == 0x42) || ((sector[2] == 8) && (sector[14] == 8))) {
+#ifdef CHATTING
printm(M_BARE, "Video sector\n");
printm(M_BARE, "Status : %04x\n", h->StSTATUS);
printm(M_BARE, "Type : %04x\n", h->StTYPE);
@@ -99,10 +104,11 @@ void process_one_sector(Handle * f) {
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);
+#endif
if (h->StSECTOR_OFFSET == 0) {
+ bs_init();
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);
@@ -118,14 +124,19 @@ void process_one_sector(Handle * f) {
if (h->StSECTOR_SIZE == (h->StSECTOR_OFFSET + 1)) {
// Frame finished.
+#ifdef CHATTING
printm(M_BARE, "End of Frame.\n");
+#endif
Uint8 * buffer = ((Uint8 *) screen->pixels);
if (SDL_MUSTLOCK(screen))
if (SDL_LockSurface(screen) < 0)
exit(1);
+#ifdef CHATTING
printm(M_BARE, "Width: %i, Height: %i - bpp: %i\n", width, height, bpp);
+#endif
+ memset(video + h->StFRAME_SIZE, 0, h->StSECTOR_SIZE * 2016 - h->StFRAME_SIZE);
bs_decode_rgb24(buffer, (bs_header_t *) video, width, height, 0);
// fwrite(screen->pixels, 3, width * height, stdout);
@@ -140,9 +151,11 @@ void process_one_sector(Handle * f) {
int locked = 0;
SoundSector * buffer = (SoundSector *) sector;
+#ifdef CHATTING
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");
+#endif
// fwrite(sector + 8, 1, 2324, stdout);
while (audio_len > 0) {
@@ -187,9 +200,14 @@ void process_one_sector(Handle * f) {
saveXaDecode(xachannel(buffer));
} else {
+#ifdef CHATTING
printm(M_BARE, "Unknow sector\n");
+#endif
}
+#ifdef CHATTING
printm(M_BARE, "---------------------------------\n\n");
+#endif
+ return 1;
}
virtual int startup() throw (GeneralException) {
@@ -226,9 +244,7 @@ virtual int startup() throw (GeneralException) {
exit(-1);
}
- while (1) {
- process_one_sector(file);
- }
+ while (process_one_sector(file));
if (!audio)
SDL_CloseAudio();