diff options
Diffstat (limited to 'includes')
-rw-r--r-- | includes/cdutils.h | 103 | ||||
-rw-r--r-- | includes/fileutils.h | 42 | ||||
-rw-r--r-- | includes/generic.h | 80 | ||||
-rw-r--r-- | includes/lzss.h | 63 | ||||
-rw-r--r-- | includes/yazedc.h | 142 |
5 files changed, 430 insertions, 0 deletions
diff --git a/includes/cdutils.h b/includes/cdutils.h new file mode 100644 index 0000000..3dcf7ac --- /dev/null +++ b/includes/cdutils.h @@ -0,0 +1,103 @@ +/* + * PSX-Tools Bundle Pack + * Copyright (C) 2002 Nicolas "Pixel" Noble + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef __CDUTILS_H__ +#define __CDUTILS_H__ + +#include "yazedc.h" +#include "generic.h" + +#define GUESS 5 + +struct DirEntry { + unsigned char R; + unsigned char NExt; + unsigned long Sector; + unsigned long BESector; + unsigned long Size; + unsigned long BESize; + unsigned char Year; + unsigned char Month; + unsigned char Day; + unsigned char Hour; + unsigned char Minute; + unsigned char Second; + unsigned char Offset; + unsigned char Flags; + unsigned char FileUnit; + unsigned char FileGap; + unsigned short VolSeq; + unsigned short BEVolSeq; + unsigned char N; + char id; +} PACKED; + +extern struct DirEntry rootDir; + +extern long sec_sizes[]; +extern long sec_offsts[]; +extern char * sec_modes[]; + +FILE * open_ppf(char * ppf, FILE * iso, char * comment); +FILE * open_ppf(char * ppf, int iso, char * comment); +unsigned short int swap_word(unsigned short int i); +unsigned long int swap_dword(unsigned long int i); +int guess_type(FILE * f_iso, int number); +int guess_type(int f_iso, int number); +void sector_seek(FILE * f_iso, long sector); +void sector_seek(int f_iso, long sector); +long read_sector(FILE * f_iso, unsigned char * buffer, char type, int number = -1); +long read_sector(int f_iso, unsigned char * buffer, char type, int number = -1); +void read_datas(FILE * f_iso, unsigned char * buffer, int type, int number, long size); +void read_datas(int f_iso, unsigned char * buffer, int type, int number, long size); +void read_file(FILE * f_iso, FILE * file, char type, int number, long size); +void read_file(int f_iso, int file, char type, int number, long size); +void write_sector(FILE * f_iso_r, FILE * f_iso_w, unsigned char * buffer, char type, int number = -1); +void write_sector(int f_iso_r, int f_iso_w, unsigned char * buffer, char type, int number = -1); +void write_datas(FILE * f_iso_r, FILE * f_iso_w, unsigned char * buffer, char type, int number, long size); +void write_datas(int f_iso_r, int f_iso_w, unsigned char * buffer, char type, int number, long size); +void write_file(FILE * f_iso_r, FILE * f_iso_w, FILE * file, char type, int number = -1); +void write_file(int f_iso_r, int f_iso_w, int file, char type, int number = -1); +int get_iso_infos(FILE * h); +int get_iso_infos(int h); +int show_iso_infos(FILE * h); +int show_iso_infos(int h); +int get_pt_infos(FILE * h); +int get_pt_infos(int h); +int show_pt_infos(FILE * h); +int show_pt_infos(int h); +struct DirEntry find_path(FILE * h, char * path); +struct DirEntry find_path(int h, char * path); +struct DirEntry find_parent(FILE * h, char * path); +struct DirEntry find_parent(int h, char * path); +void show_head_entry(void); +int show_entry(struct DirEntry * dir); +int show_dir(FILE * h, struct DirEntry * dir); +int show_dir(int h, struct DirEntry * dir); +struct DirEntry find_dir_entry(FILE * h, struct DirEntry * dir, char * name); +struct DirEntry find_dir_entry(int h, struct DirEntry * dir, char * name); +struct DirEntry * find_dir_entry(FILE * h, unsigned char ** buffer, struct DirEntry * dir, char * name); +struct DirEntry * find_dir_entry(int h, unsigned char ** buffer, struct DirEntry * dir, char * name); +unsigned char from_BCD(unsigned char x); +unsigned char to_BCD(unsigned char x); +int is_valid_BCD(unsigned char x); +unsigned long from_MSF(unsigned long msf, unsigned long start = 150); +unsigned long from_MSF(unsigned char m, unsigned char s, unsigned char f, unsigned long start = 150); + +#endif diff --git a/includes/fileutils.h b/includes/fileutils.h new file mode 100644 index 0000000..a552477 --- /dev/null +++ b/includes/fileutils.h @@ -0,0 +1,42 @@ +/* + * PSX-Tools Bundle Pack + * Copyright (C) 2002 Nicolas "Pixel" Noble + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef __FILEUTILS_H__ +#define __FILEUTILS_H__ + +#include <stdio.h> +#include <sys/stat.h> +#include <sys/types.h> +#include <fcntl.h> + +unsigned long filesize(int f_iso); +void copy(int s, int d, long size = -1); + +unsigned long filesize(FILE * f_iso); +void copy(FILE * s, FILE * d, long size = -1); + +#if defined __linux__ || defined __CYGWIN32__ +#define MKDIR(name) mkdir(name, 0777) +#elif defined __MINGW32_VERSION +#define MKDIR mkdir +#else +#error Unknow compiler/platform +#endif + +#endif diff --git a/includes/generic.h b/includes/generic.h new file mode 100644 index 0000000..04c91fa --- /dev/null +++ b/includes/generic.h @@ -0,0 +1,80 @@ +/* + * PSX-Tools Bundle Pack + * Copyright (C) 2002 Nicolas "Pixel" Noble + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef __GENERIC_H__ +#define __GENERIC_H__ + +#define M_BARE -1 +#define M_ERROR 0 +#define M_STATUS 1 +#define M_WARNING 2 +#define M_INFO 3 + +#ifndef bcopy +#define bcopy(x,y,z) memcpy((y),(x),(z)) +#endif + +#define MIN(a,b) ((a)<(b)?(a):(b)) +#define MAX(a,b) ((a)<(b)?(b):(a) + +#ifndef SDL_VERSIONNUM +typedef unsigned long int Uint32; +#endif + +#ifndef int32 +typedef signed long int int32; +#endif + +#ifndef Uint16 +typedef unsigned short int Uint16; +#endif + +#ifndef int16 +typedef signed short int int16; +#endif + +#ifndef Uint8 +typedef unsigned char Uint8; +#endif + +#ifndef int8 +typedef signed char int8; +#endif + +#ifndef Byte +typedef Uint8 Byte; +#endif + +#ifndef Word +typedef Uint16 Word; +#endif + +#ifndef DWord +typedef Uint32 DWord; +#endif + +#if defined __linux__ || defined __CYGWIN32__ +#define PACKED __attribute__((packed)) +#endif + +extern char verbosity; +void printm(int level, char * fmt, ...); +char ** split(char * s, char t); + +#endif diff --git a/includes/lzss.h b/includes/lzss.h new file mode 100644 index 0000000..127a494 --- /dev/null +++ b/includes/lzss.h @@ -0,0 +1,63 @@ +/* + * PSX-Tools Bundle Pack + * Copyright (C) 2002 Nicolas "Pixel" Noble + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef __LZSS_H__ +#define __LZSS_H__ + +#include <stdio.h> +#include "generic.h" + +#define LZSS_VERSION "3.0.0-pre1" +#define LZSS_NAME "lzss" + +typedef struct { + char * name; + int one_is_compressed, bitmap_inversed, one_jump, overlap_trick, negative_trick, sixteen_bits, ptrb, filling; + int window_start; + int l_mask_1, l_shft_1, l_mask_2, l_shft_2; + int j_mask_1, j_shft_1, j_mask_2, j_shft_2; + int f_mask_1, f_shft_1, f_mask_2, f_shft_2; + int v_mask_1, v_shft_1, v_mask_2, v_shft_2; +} scheme_t; + +enum { + XENO = 0, + DBZ, + FF7, + LM, + MM, + OB, + LODOSS, + FF6, + VP_1, + VP_2, + END +}; + +extern scheme_t scheme, schemes[]; + +extern int tolerate, blockb; +extern long blk, bitmap_count; + +unsigned long lzss_decomp(FILE * f_source, FILE * f_cible, long true_length = -1); +void lzss_comp(FILE * f_source, FILE * f_cible, long * delta = NULL); + +char swap_bits(char); + +#endif diff --git a/includes/yazedc.h b/includes/yazedc.h new file mode 100644 index 0000000..b990d3e --- /dev/null +++ b/includes/yazedc.h @@ -0,0 +1,142 @@ +/* + * PSX-Tools Bundle Pack + * Copyright (C) 1998 Heiko Eissfeldt + * portions used& Chris Smith + * First modified by Yazoo, then by + * Nicolas "Pixel" Noble + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef __YAZEDC_H__ + +#define RS_L12_BITS 8 + +/* audio sector definitions for CIRC */ +#define FRAMES_PER_SECTOR 98 +/* user data bytes per frame */ +#define L1_RAW 24 +/* parity bytes with 8 bit */ +#define L1_Q 4 +#define L1_P 4 + +/* audio sector Cross Interleaved Reed-Solomon Code (CIRC) encoder (layer 1) */ +/* adds P- and Q- parity information to audio (f2) frames. Also + optionally handles the various delays and permutations. The output with all + stages enabled can be fed into the Eight-Fourteen-Modulator. + On input: 2352 bytes of audio data is given. + On output: 3136 bytes of CIRC enriched audio data are returned. + */ +int do_encode_L1(unsigned char in[L1_RAW*FRAMES_PER_SECTOR], + unsigned char out[(L1_RAW+L1_Q+L1_P)*FRAMES_PER_SECTOR], + int delay1, int delay2, int delay3, int scramble); + +/* data sector definitions for RSPC */ +/* user data bytes per frame */ +#define L2_RAW (1024*2) +/* parity bytes for 16 bit units */ +#define L2_Q (26*2*2) +#define L2_P (43*2*2) + +/* known sector types */ +#define MODE_0 0 +#define MODE_1 1 +#define MODE_2 2 +#define MODE_2_FORM_1 3 +#define MODE_2_FORM_2 4 + +#ifdef __cplusplus +extern "C" { +#endif + +/* set one of the MODE_* constants for subsequent data sector formatting */ +int set_sector_type(int st); +/* get the current sector type setting for data sector formatting */ +int get_sector_type(void); + +/* data sector layer 2 Reed-Solomon Product Code encoder */ +/* encode the given data portion depending on sector type (see + get/set_sector_type() functions). Use the given address for the header. + The returned data is __unscrambled__ and not in F2-frame format (for that + see function scramble_L2()). + Supported sector types: + MODE_0: a 12-byte sync field, a header and 2336 zeros are returned. + MODE_1: the user data portion (2048 bytes) has to be given + at offset 16 in the inout array. + Sync-, header-, edc-, spare-, p- and q- fields will be added. + MODE_2: the user data portion (2336 bytes) has to be given + at offset 16 in the inout array. + Sync- and header- fields will be added. + MODE_2_FORM_1: the user data portion (8 bytes subheader followed + by 2048 bytes data) has to be given at offset 16 + in the inout array. + Sync-, header-, edc-, p- and q- fields will be added. + MODE_2_FORM_2: the user data portion (8 bytes subheader followed + by 2324 bytes data) has to be given at offset 16 + in the inout array. + Sync-, header- and edc- fields will be added. +*/ +int do_encode_L2(unsigned char *inout, int sectortype, unsigned address); +int decode_L2_Q(unsigned char inout[4 + L2_RAW + 12 + L2_Q]); +int decode_L2_P(unsigned char inout[4 + L2_RAW + 12 + L2_Q + L2_P]); +unsigned long int build_edc(unsigned char inout[], int from, int upto); + +/* generates f2 frames from otherwise fully formatted sectors (generated by + do_encode_L2()). */ +int scramble_L2(unsigned char *inout); + +#ifdef __cplusplus +} +#endif + +/* r-w sub channel definitions */ +#define RS_SUB_RW_BITS 6 + +#define PACKETS_PER_SUBCHANNELFRAME 4 +#define LSUB_RAW 18 +#define LSUB_QRAW 2 +/* 6 bit */ +#define LSUB_Q 2 +#define LSUB_P 4 + +#ifdef __cplusplus +extern "C" { +#endif + +/* R-W subchannel encoder */ +/* On input: 72 bytes packed user data, four frames with each 18 bytes. + On output: per frame: 2 bytes user data, 2 bytes Q parity, + 16 bytes user data, 4 bytes P parity. + Options: + delay1: use low level delay line + scramble: perform low level permutations + */ +int do_encode_sub(unsigned char in[LSUB_RAW*PACKETS_PER_SUBCHANNELFRAME], + unsigned char out[(LSUB_RAW+LSUB_Q+LSUB_P)*PACKETS_PER_SUBCHANNELFRAME], + int delay1, int scramble); +int do_decode_sub(unsigned char in[(LSUB_RAW+LSUB_Q+LSUB_P)*PACKETS_PER_SUBCHANNELFRAME], + unsigned char out[LSUB_RAW*PACKETS_PER_SUBCHANNELFRAME], + int delay1, int scramble); + +int decode_LSUB_Q(unsigned char inout[LSUB_QRAW + LSUB_Q]); +int decode_LSUB_P(unsigned char inout[LSUB_RAW + LSUB_Q + LSUB_P]); + +#ifdef __cplusplus +} +#endif + +extern unsigned char minute, second, frame; + +#endif |