summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPixel <Pixel>2002-06-23 17:13:59 +0000
committerPixel <Pixel>2002-06-23 17:13:59 +0000
commitd0f485b19a53ce3c7032066096305dbecba536fe (patch)
tree3a54b4c9bca34535e7bf42adcbef483619b37fc2
parentab0afb77b2a0bb9d5dd3eb27ea98c6f9f4e938c2 (diff)
Tralala
-rw-r--r--FAQ-psx.txt3
-rwxr-xr-xMakefile2
-rwxr-xr-xXenogears/Makefile2
-rw-r--r--psxdev/vlc.c2
-rw-r--r--psxdev/xadecode.h8
-rw-r--r--str-util.cpp79
6 files changed, 71 insertions, 25 deletions
diff --git a/FAQ-psx.txt b/FAQ-psx.txt
index 6bb7fe8..6ec6061 100644
--- a/FAQ-psx.txt
+++ b/FAQ-psx.txt
@@ -1,3 +1,6 @@
+
+
+
Q: What is the asm used in the PSX?
A: The PSX is equipped with a MIPS r3000. This processor is little endian, so
don't you worry if you know SNES or PC hacking.
diff --git a/Makefile b/Makefile
index 19ce4e8..c330d89 100755
--- a/Makefile
+++ b/Makefile
@@ -27,7 +27,7 @@ dte-tool: dteutils.o generic.h generic.o fileutils.o fileutils.h dtemain.o Makef
${CXX} ${LDFLAGS} dteutils.o generic.o 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 -o str-tool -lSDL
+ ${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
clean:
for d in ${SUBDIRS} ; do make -C $$d clean || exit -1 ; done
diff --git a/Xenogears/Makefile b/Xenogears/Makefile
index 9b8d9db..e5b3945 100755
--- a/Xenogears/Makefile
+++ b/Xenogears/Makefile
@@ -1,6 +1,6 @@
#!/usr/bin/make -f
-CPPFLAGS=-Wall -g -O3 -mcpu=i686 -pedantic -pedantic-errors -Werror -I..
+CPPFLAGS=-Wall -g -O3 -mcpu=i686 -pedantic -pedantic-errors -I..
CXX=g++
TARGET = reinsert main_dump Decrypt script-comp script-dec XenoCD1.sqr XenoCD2.sqr
diff --git a/psxdev/vlc.c b/psxdev/vlc.c
index 196fa96..4ff3d06 100644
--- a/psxdev/vlc.c
+++ b/psxdev/vlc.c
@@ -428,7 +428,7 @@ static void yuv2rgb15(BLOCK *blk,Uint16 *image)
}
}
-enum {B,G,R};
+enum {R, G, B};
static void yuv2rgb24(BLOCK *blk,Uint8 image[][3])
{
diff --git a/psxdev/xadecode.h b/psxdev/xadecode.h
index 025d36a..b886285 100644
--- a/psxdev/xadecode.h
+++ b/psxdev/xadecode.h
@@ -61,6 +61,10 @@ typedef unsigned short WORD;
typedef long FXD;
#endif
+#ifdef __cplusplus
+extern "C" {
+#endif
+
long decodeSoundSect(SoundSector *ssct, char *wav);
long decodeSoundSect1(SoundSector *ssct, char *wav);
long convXaToWave(char *adp, char *wav, int cn, int fn_s, int fn_e);
@@ -81,4 +85,8 @@ char xahalfhz(SoundSector *ss);
FXD FXD_FixMul(FXD a, FXD b);
#endif
+#ifdef __cplusplus
+}
+#endif
+
#endif
diff --git a/str-util.cpp b/str-util.cpp
index 7c76917..b1a2f2d 100644
--- a/str-util.cpp
+++ b/str-util.cpp
@@ -42,14 +42,27 @@ struct STR_Header {
Uint16 Channels;
} PACKED;
-Byte * video = 0, * audio = 0;
+Byte * video = 0, * audio = 0, * audio2 = 0;
int width, height;
SDL_Surface * screen = 0;
Uint8 bpp;
-extern void mixaudio(void *unused, Uint8 *stream, int len);
+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];
@@ -57,14 +70,14 @@ void process_one_sector(FILE * f) {
fread(sector, 2336, 1, f);
h = (STR_Header *) ((Byte *) sector + 8);
-
+/*
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, "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);
@@ -75,7 +88,7 @@ void process_one_sector(FILE * f) {
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);
+ printm(M_BARE, "Channels : %04x\n", h->Channels); */
if (h->StSECTOR_OFFSET == 0) {
video = (Byte *) malloc(h->StSECTOR_SIZE * 2016);
if (!screen) {
@@ -95,14 +108,14 @@ void process_one_sector(FILE * f) {
if (h->StSECTOR_SIZE == (h->StSECTOR_OFFSET + 1)) {
// Frame finished.
- printm(M_BARE, "End of Frame.\n");
+// 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);
+// 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);
@@ -114,37 +127,59 @@ void process_one_sector(FILE * f) {
free(video);
}
} else if (sector[2] == 0x64) {
- SoundSector * buffer = (SoundSector *) sector);
- printm(M_BARE, "Audio sector\n");
+ 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");
+ printm(M_BARE, "Channels : %s\n", xastereo(buffer) ? "stereo" : "mono"); */
// fwrite(sector + 8, 1, 2324, stdout);
- if (!audio) {
+
+ 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.freq = xahalfhz(buffer) ? 18900 : 37800;
fmt.format = AUDIO_S16;
- fmt.channels = 2;
- fmt.samples = 512; /*Une bonne valeur pour les jeux */
+ 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'acce'der a` l'audio: %s\n", SDL_GetError());
+ if (SDL_OpenAudio(&fmt, NULL) < 0) {
+ fprintf(stderr, "Impossible d'accéder à l'audio: %s\n", SDL_GetError());
exit(1);
}
- SDL_PauseAudio(0);
+ initXaDecode();
} else {
- free(audio);
+ if (audio) {
+ SDL_LockAudio();
+ free(audio);
+ locked = 1;
+ }
+ audio_pos = audio = audio2;
+ audio_len = audio_len2;
}
- audio = (Byte *) malloc(2336);
+
+ 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, "Unknow sector\n");
}
- printm(M_BARE, "---------------------------------\n\n");
+// printm(M_BARE, "---------------------------------\n\n");
}
int main(int argc, char ** argv) {