diff options
-rw-r--r-- | FAQ-cd.txt | 18 | ||||
-rwxr-xr-x | Makefile | 7 | ||||
-rw-r--r-- | generic.h | 11 | ||||
-rw-r--r-- | lzss.cpp | 2 | ||||
-rw-r--r-- | str-util.cpp | 72 |
5 files changed, 100 insertions, 10 deletions
@@ -194,12 +194,18 @@ int is_valid_BCD(uchar x) {return (((x & 15) < 10) && ((x >> 4) < 10));} 5: Form 2 6: Real Time (RT) 7: End of File (EOF) - - Very last things to know: of course, the PSX has the CDs in MODE 2... So the - common files are stored in MODE 2 FORM 1, the STR/XA files are stored in - "MODE 2" but actually they are in MODE 2 FORM 2. The MOVCONV tool will - in fact produce files that does contain the subheaders. And those subheaders - seems to contain a CN equals to 1, and the flags RT and Data are activated. + but it seems it's not very accurate, as you will se below. + + Of course, the PSX has the CDs in MODE 2... So the common files are + stored in MODE 2 FORM 1, the STR/XA files are stored in "MODE 2" but + actually they are in MODE 2 FORM 1/2. The MOVCONV tool will in fact produce + files that does contain the subheaders. And those subheaders seems to + contain a CN equals to 1, and the flags RT and Data are activated for the + video frames, and FN, CN, and CI equal to 1, and the flags are placed + as it: RT, Form 2, Audio for Audio streams. So the Video frames are in + plain Form 1, and the Audio frames are in plain Form 2. But it _seems_ the + Video frames are not checked against ECC/EDC, but filled with zeros + instead. The last but not the least: the MODE 2 FORM 1 and MODE 2 FORM 2 are also called XA-Mode1 and XA-Mode2 or simplier: XA-1 and XA-2. @@ -1,9 +1,9 @@ #!/usr/bin/make -f -CPPFLAGS=-Wall -g -I. -O3 -mcpu=i686 -pedantic -pedantic-errors -Werror +CPPFLAGS=-Wall -g -O3 -mcpu=i686 -pedantic -pedantic-errors -Werror CXX=g++ -TARGET = lzss dlzss yazedc cd-tool dte-tool +TARGET = lzss dlzss yazedc cd-tool dte-tool str-tool all: ${TARGET} @@ -25,5 +25,8 @@ dte-tool-asm: dteutils.cpp generic.h generic.cpp fileutils.cpp fileutils.h dte-a dte-tool: dteutils.cpp generic.h generic.cpp fileutils.cpp fileutils.h ${CXX} ${CPPFLAGS} ${LDFLAGS} dteutils.cpp generic.cpp fileutils.cpp -o dte-tool -DDTEMAIN +str-tool: str-util.cpp generic.h generic.cpp fileutils.cpp fileutils.h + ${CXX} ${CPPFLAGS} ${LDFLAGS} str-util.cpp generic.cpp fileutils.cpp -o str-tool -DSTR_MAIN + clean: rm -f *.o ${TARGET} compil.c @@ -33,6 +33,17 @@ #define MIN(a,b) ((a)<(b)?(a):(b)) #define MAX(a,b) ((a)<(b)?(b):(a) +typedef unsigned long int Uint32; +typedef signed long int int32; +typedef unsigned short int Uint16; +typedef signed short int int16; +typedef unsigned char Uint8; +typedef signed char int8; + +typedef Uint8 Byte; +typedef Uint16 Word; +typedef Uint32 DWord; + extern char verbosity; void printm(int level, char * fmt, ...); char ** split(char * s, char t); @@ -21,7 +21,7 @@ #include <stdlib.h> #include <string.h> #include <getopt.h> -#include <iostream.h> +#include <iostream> #include "fileutils.h" #include "generic.h" #include "lzss.h" diff --git a/str-util.cpp b/str-util.cpp index b93e2a6..f0dd3f7 100644 --- a/str-util.cpp +++ b/str-util.cpp @@ -3,10 +3,80 @@ #include "generic.h" #include "yazedc.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; +} __attribute__((packed)); + +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_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) { + printm(M_BARE, "Video sector\n"); + } else if (sector[2] == 0x64) { + printm(M_BARE, "Audio sector\n"); + } else { + printm(M_BARE, "Unknow 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); + printm(M_BARE, "---------------------------------\n\n"); +} + +#ifdef STR_MAIN -#ifdef __STR_MAIN__ int main(void) { + while (!feof(stdin)) { + process_one_sector(stdin); + } } + #endif |