reformat CDVDiso

This commit is contained in:
Clang Format 2016-09-04 14:19:01 +02:00 committed by Gregory Hainaut
parent d6ae5bfafa
commit e503534ff4
14 changed files with 2142 additions and 2171 deletions

View File

@ -20,7 +20,7 @@
#define __CDVDISO_H__
#ifdef _MSC_VER
#pragma warning(disable:4018)
#pragma warning(disable : 4018)
#endif
#include "PS2Edefs.h"
@ -31,7 +31,7 @@
#ifdef _MSC_VER
#define EXPORT_C_(type) extern "C" __declspec(dllexport) type CALLBACK
#else
#define EXPORT_C_(type) extern "C" __attribute__((stdcall,externally_visible,visibility("default"))) type
#define EXPORT_C_(type) extern "C" __attribute__((stdcall, externally_visible, visibility("default"))) type
#endif
#else
@ -39,40 +39,61 @@
#ifdef _MSC_VER
#define EXPORT_C_(type) __declspec(dllexport) type __stdcall
#else
#define EXPORT_C_(type) __attribute__((stdcall,externally_visible,visibility("default"))) type
#define EXPORT_C_(type) __attribute__((stdcall, externally_visible, visibility("default"))) type
#endif
#endif
EXPORT_C_(u32) PS2EgetLibType();
EXPORT_C_(u32) PS2EgetLibVersion2(u32 type);
EXPORT_C_(char*) PS2EgetLibName();
EXPORT_C_(u32)
PS2EgetLibType();
EXPORT_C_(u32)
PS2EgetLibVersion2(u32 type);
EXPORT_C_(char *)
PS2EgetLibName();
EXPORT_C_(s32) CDVDinit();
EXPORT_C_(s32) CDVDopen(const char* pTitleFilename);
EXPORT_C_(void) CDVDclose();
EXPORT_C_(void) CDVDshutdown();
EXPORT_C_(s32) CDVDreadTrack(u32 lsn, int mode);
EXPORT_C_(s32)
CDVDinit();
EXPORT_C_(s32)
CDVDopen(const char *pTitleFilename);
EXPORT_C_(void)
CDVDclose();
EXPORT_C_(void)
CDVDshutdown();
EXPORT_C_(s32)
CDVDreadTrack(u32 lsn, int mode);
// return can be NULL (for async modes)
EXPORT_C_(u8*) CDVDgetBuffer();
EXPORT_C_(u8 *)
CDVDgetBuffer();
EXPORT_C_(s32) CDVDreadSubQ(u32 lsn, cdvdSubQ* subq);//read subq from disc (only cds have subq data)
EXPORT_C_(s32) CDVDgetTN(cdvdTN *Buffer); //disk information
EXPORT_C_(s32) CDVDgetTD(u8 Track, cdvdTD *Buffer); //track info: min,sec,frame,type
EXPORT_C_(s32) CDVDgetTOC(void* toc); //gets ps2 style toc from disc
EXPORT_C_(s32) CDVDgetDiskType(); //CDVD_TYPE_xxxx
EXPORT_C_(s32) CDVDgetTrayStatus(); //CDVD_TRAY_xxxx
EXPORT_C_(s32) CDVDctrlTrayOpen(); //open disc tray
EXPORT_C_(s32) CDVDctrlTrayClose(); //close disc tray
EXPORT_C_(s32)
CDVDreadSubQ(u32 lsn, cdvdSubQ *subq); //read subq from disc (only cds have subq data)
EXPORT_C_(s32)
CDVDgetTN(cdvdTN *Buffer); //disk information
EXPORT_C_(s32)
CDVDgetTD(u8 Track, cdvdTD *Buffer); //track info: min,sec,frame,type
EXPORT_C_(s32)
CDVDgetTOC(void *toc); //gets ps2 style toc from disc
EXPORT_C_(s32)
CDVDgetDiskType(); //CDVD_TYPE_xxxx
EXPORT_C_(s32)
CDVDgetTrayStatus(); //CDVD_TRAY_xxxx
EXPORT_C_(s32)
CDVDctrlTrayOpen(); //open disc tray
EXPORT_C_(s32)
CDVDctrlTrayClose(); //close disc tray
// extended funcs
EXPORT_C_(void) CDVDconfigure();
EXPORT_C_(void) CDVDabout();
EXPORT_C_(s32) CDVDtest();
EXPORT_C_(void) CDVDnewDiskCB(void (*callback)());
EXPORT_C_(void)
CDVDconfigure();
EXPORT_C_(void)
CDVDabout();
EXPORT_C_(s32)
CDVDtest();
EXPORT_C_(void)
CDVDnewDiskCB(void (*callback)());
#define CDVD_LOG __Log
extern FILE *cdvdLog;
@ -81,29 +102,29 @@ void __Log(char *fmt, ...);
#define VERBOSE 1
#define DEV_DEF ""
#define CDDEV_DEF "/dev/cdrom"
#define DEV_DEF ""
#define CDDEV_DEF "/dev/cdrom"
typedef struct
{
int slsn;
int elsn;
int slsn;
int elsn;
#ifdef _WINDOWS_
HANDLE handle;
HANDLE handle;
#else
FILE *handle;
FILE *handle;
#endif
} _cdIso;
extern _cdIso cdIso[8];
#define CD_FRAMESIZE_RAW 2352
#define DATA_SIZE (CD_FRAMESIZE_RAW-12)
#define CD_FRAMESIZE_RAW 2352
#define DATA_SIZE (CD_FRAMESIZE_RAW - 12)
#define itob(i) ((i)/10*16 + (i)%10) /* u_char to BCD */
#define btoi(b) ((b)/16*10 + (b)%16) /* BCD to u_char */
#define itob(i) ((i) / 10 * 16 + (i) % 10) /* u_char to BCD */
#define btoi(b) ((b) / 16 * 10 + (b) % 16) /* BCD to u_char */
#define MSF2SECT(m,s,f) (((m)*60+(s)-2)*75+(f))
#define MSF2SECT(m, s, f) (((m)*60 + (s)-2) * 75 + (f))
extern const u8 version;
extern const u8 revision;
@ -125,8 +146,8 @@ extern int cdoffset;
extern int cdtype;
extern int cdblocks;
extern int Zmode; // 1 Z - 2 bz2
extern int fmode; // 0 - file / 1 - Zfile
extern int Zmode; // 1 Z - 2 bz2
extern int fmode; // 0 - file / 1 - Zfile
extern char *Ztable;
extern char *methods[];

View File

@ -26,8 +26,8 @@ int cdoffset;
int cdtype;
int cdblocks;
int Zmode; // 1 Z - 2 bz2
int fmode; // 0 - file / 1 - Zfile
int Zmode; // 1 Z - 2 bz2
int fmode; // 0 - file / 1 - Zfile
char *Ztable;
int BlockDump;
@ -41,11 +41,10 @@ FILE *cdvdLog = NULL;
static char cdvdCurrentIso[MAX_PATH];
char *methods[] =
{
".Z - compress faster",
".BZ - compress better",
NULL
};
{
".Z - compress faster",
".BZ - compress better",
NULL};
#ifdef PCSX2_DEBUG
char *LibName = "Linuz Iso CDVD (Debug) ";
@ -61,290 +60,295 @@ u8 cdbuffer[CD_FRAMESIZE_RAW * 10] = {0};
s32 msf_to_lba(u8 m, u8 s, u8 f)
{
u32 lsn;
lsn = f;
lsn += (s - 2) * 75;
lsn += m * 75 * 60;
return lsn;
u32 lsn;
lsn = f;
lsn += (s - 2) * 75;
lsn += m * 75 * 60;
return lsn;
}
void lba_to_msf(s32 lba, u8* m, u8* s, u8* f)
void lba_to_msf(s32 lba, u8 *m, u8 *s, u8 *f)
{
lba += 150;
*m = lba / (60 * 75);
*s = (lba / 75) % 60;
*f = lba % 75;
lba += 150;
*m = lba / (60 * 75);
*s = (lba / 75) % 60;
*f = lba % 75;
}
#define btoi(b) ((b)/16*10 + (b)%16) /* BCD to u_char */
#define itob(i) ((i)/10*16 + (i)%10) /* u_char to BCD */
#define btoi(b) ((b) / 16 * 10 + (b) % 16) /* BCD to u_char */
#define itob(i) ((i) / 10 * 16 + (i) % 10) /* u_char to BCD */
EXPORT_C_(char*) PS2EgetLibName()
EXPORT_C_(char *)
PS2EgetLibName()
{
return LibName;
return LibName;
}
EXPORT_C_(u32) PS2EgetLibType()
EXPORT_C_(u32)
PS2EgetLibType()
{
return PS2E_LT_CDVD;
return PS2E_LT_CDVD;
}
EXPORT_C_(u32) PS2EgetLibVersion2(u32 type)
EXPORT_C_(u32)
PS2EgetLibVersion2(u32 type)
{
return (version << 16) | (revision << 8) | build;
return (version << 16) | (revision << 8) | build;
}
#ifdef PCSX2_DEBUG
void __Log(char *fmt, ...)
{
va_list list;
va_list list;
if (cdvdLog == NULL) return;
if (cdvdLog == NULL)
return;
va_start(list, fmt);
vfprintf(cdvdLog, fmt, list);
va_end(list);
va_start(list, fmt);
vfprintf(cdvdLog, fmt, list);
va_end(list);
}
#else
#define __Log 0&&
#define __Log 0 &&
#endif
EXPORT_C_(s32) CDVDinit()
EXPORT_C_(s32)
CDVDinit()
{
#ifdef PCSX2_DEBUG
cdvdLog = fopen("logs/cdvdLog.txt", "w");
if (cdvdLog == NULL)
{
cdvdLog = fopen("cdvdLog.txt", "w");
if (cdvdLog == NULL)
{
SysMessage("Can't create cdvdLog.txt");
return -1;
}
}
setvbuf(cdvdLog, NULL, _IONBF, 0);
CDVD_LOG("CDVDinit\n");
cdvdLog = fopen("logs/cdvdLog.txt", "w");
if (cdvdLog == NULL) {
cdvdLog = fopen("cdvdLog.txt", "w");
if (cdvdLog == NULL) {
SysMessage("Can't create cdvdLog.txt");
return -1;
}
}
setvbuf(cdvdLog, NULL, _IONBF, 0);
CDVD_LOG("CDVDinit\n");
#endif
cdvdCurrentIso[0] = 0;
memset(cdIso, 0, sizeof(cdIso));
return 0;
cdvdCurrentIso[0] = 0;
memset(cdIso, 0, sizeof(cdIso));
return 0;
}
EXPORT_C_(void) CDVDshutdown()
EXPORT_C_(void)
CDVDshutdown()
{
cdvdCurrentIso[0] = 0;
cdvdCurrentIso[0] = 0;
#ifdef CDVD_LOG
if (cdvdLog != NULL) fclose(cdvdLog);
if (cdvdLog != NULL)
fclose(cdvdLog);
#endif
}
EXPORT_C_(s32) CDVDopen(const char* pTitle)
EXPORT_C_(s32)
CDVDopen(const char *pTitle)
{
LoadConf();
LoadConf();
if (pTitle != NULL) strcpy(IsoFile, pTitle);
if (pTitle != NULL)
strcpy(IsoFile, pTitle);
if (*IsoFile == 0) strcpy(IsoFile, cdvdCurrentIso);
if (*IsoFile == 0)
strcpy(IsoFile, cdvdCurrentIso);
if (*IsoFile == 0)
{
char temp[256];
if (*IsoFile == 0) {
char temp[256];
CfgOpenFile();
CfgOpenFile();
if (IsoFile[0] == 0)
{
// user pressed CANCEL
return 1;
}
if (IsoFile[0] == 0) {
// user pressed CANCEL
return 1;
}
strcpy(temp, IsoFile);
*IsoFile = 0;
SaveConf();
strcpy(IsoFile, temp);
}
strcpy(temp, IsoFile);
*IsoFile = 0;
SaveConf();
strcpy(IsoFile, temp);
}
iso = isoOpen(IsoFile);
if (iso == NULL)
{
SysMessage("Error loading %s\nMake sure the iso file is not mounted in any disk emulation software!", IsoFile);
return -1;
}
iso = isoOpen(IsoFile);
if (iso == NULL) {
SysMessage("Error loading %s\nMake sure the iso file is not mounted in any disk emulation software!", IsoFile);
return -1;
}
if (iso->type == ISOTYPE_DVD)
cdtype = CDVD_TYPE_PS2DVD;
else if (iso->type == ISOTYPE_AUDIO)
cdtype = CDVD_TYPE_CDDA;
else
cdtype = CDVD_TYPE_PS2CD;
if (iso->type == ISOTYPE_DVD)
cdtype = CDVD_TYPE_PS2DVD;
else if (iso->type == ISOTYPE_AUDIO)
cdtype = CDVD_TYPE_CDDA;
else
cdtype = CDVD_TYPE_PS2CD;
if (BlockDump)
{
char fname_only[MAX_PATH];
if (BlockDump) {
char fname_only[MAX_PATH];
#ifdef _WIN32
char fname[MAX_PATH], ext[MAX_PATH];
_splitpath(IsoFile, NULL, NULL, fname, ext);
_makepath(fname_only, NULL, NULL, fname, NULL);
char fname[MAX_PATH], ext[MAX_PATH];
_splitpath(IsoFile, NULL, NULL, fname, ext);
_makepath(fname_only, NULL, NULL, fname, NULL);
#else
char* p, *plast;
char *p, *plast;
plast = p = strchr(IsoFile, '/');
while (p != NULL)
{
plast = p;
p = strchr(p + 1, '/');
}
plast = p = strchr(IsoFile, '/');
while (p != NULL) {
plast = p;
p = strchr(p + 1, '/');
}
// Lets not create dumps in the plugin directory.
strcpy(fname_only, "../");
if (plast != NULL)
strcat(fname_only, plast + 1);
else
strcat(fname_only, IsoFile);
// Lets not create dumps in the plugin directory.
strcpy(fname_only, "../");
if (plast != NULL)
strcat(fname_only, plast + 1);
else
strcat(fname_only, IsoFile);
plast = p = strchr(fname_only, '.');
plast = p = strchr(fname_only, '.');
while (p != NULL)
{
plast = p;
p = strchr(p + 1, '.');
}
while (p != NULL) {
plast = p;
p = strchr(p + 1, '.');
}
if (plast != NULL) *plast = 0;
if (plast != NULL)
*plast = 0;
#endif
strcat(fname_only, ".dump");
fdump = isoCreate(fname_only, ISOFLAGS_BLOCKDUMP);
if (fdump) isoSetFormat(fdump, iso->blockofs, iso->blocksize, iso->blocks);
}
else
{
fdump = NULL;
}
strcat(fname_only, ".dump");
fdump = isoCreate(fname_only, ISOFLAGS_BLOCKDUMP);
if (fdump)
isoSetFormat(fdump, iso->blockofs, iso->blocksize, iso->blocks);
} else {
fdump = NULL;
}
return 0;
return 0;
}
EXPORT_C_(void) CDVDclose()
EXPORT_C_(void)
CDVDclose()
{
if (!iso) return;
if (!iso)
return;
strcpy(cdvdCurrentIso, IsoFile);
strcpy(cdvdCurrentIso, IsoFile);
isoClose(iso);
if (fdump != NULL) isoClose(fdump);
isoClose(iso);
if (fdump != NULL)
isoClose(fdump);
}
EXPORT_C_(s32) CDVDreadSubQ(u32 lsn, cdvdSubQ* subq)
EXPORT_C_(s32)
CDVDreadSubQ(u32 lsn, cdvdSubQ *subq)
{
if (!iso) return -1;
if (!iso)
return -1;
// fake it
u8 min, sec, frm;
subq->ctrl = 4;
subq->mode = 1;
subq->trackNum = itob(1);
subq->trackIndex = itob(1);
// fake it
u8 min, sec, frm;
subq->ctrl = 4;
subq->mode = 1;
subq->trackNum = itob(1);
subq->trackIndex = itob(1);
lba_to_msf(lsn, &min, &sec, &frm);
subq->trackM = itob(min);
subq->trackS = itob(sec);
subq->trackF = itob(frm);
lba_to_msf(lsn, &min, &sec, &frm);
subq->trackM = itob(min);
subq->trackS = itob(sec);
subq->trackF = itob(frm);
subq->pad = 0;
subq->pad = 0;
lba_to_msf(lsn + (2*75), &min, &sec, &frm);
subq->discM = itob(min);
subq->discS = itob(sec);
subq->discF = itob(frm);
return 0;
lba_to_msf(lsn + (2 * 75), &min, &sec, &frm);
subq->discM = itob(min);
subq->discS = itob(sec);
subq->discF = itob(frm);
return 0;
}
EXPORT_C_(s32) CDVDgetTN(cdvdTN *Buffer)
EXPORT_C_(s32)
CDVDgetTN(cdvdTN *Buffer)
{
Buffer->strack = 1;
Buffer->etrack = 1;
Buffer->strack = 1;
Buffer->etrack = 1;
return 0;
return 0;
}
EXPORT_C_(s32) CDVDgetTD(u8 Track, cdvdTD *Buffer)
EXPORT_C_(s32)
CDVDgetTD(u8 Track, cdvdTD *Buffer)
{
if (!iso) return -1;
if (!iso)
return -1;
if (Track == 0)
{
Buffer->lsn = iso->blocks;
}
else
{
Buffer->type = CDVD_MODE1_TRACK;
Buffer->lsn = 0;
}
if (Track == 0) {
Buffer->lsn = iso->blocks;
} else {
Buffer->type = CDVD_MODE1_TRACK;
Buffer->lsn = 0;
}
return 0;
return 0;
}
static s32 layer1start = -1;
static bool testForPartitionInfo( const u8 (&tempbuffer)[CD_FRAMESIZE_RAW] )
static bool testForPartitionInfo(const u8 (&tempbuffer)[CD_FRAMESIZE_RAW])
{
const int off = iso->blockofs;
const int off = iso->blockofs;
// test for: CD001
return (
(tempbuffer[off+1] == 0x43) &&
(tempbuffer[off+2] == 0x44) &&
(tempbuffer[off+3] == 0x30) &&
(tempbuffer[off+4] == 0x30) &&
(tempbuffer[off+5] == 0x31)
);
// test for: CD001
return (
(tempbuffer[off + 1] == 0x43) &&
(tempbuffer[off + 2] == 0x44) &&
(tempbuffer[off + 3] == 0x30) &&
(tempbuffer[off + 4] == 0x30) &&
(tempbuffer[off + 5] == 0x31));
}
EXPORT_C_(s32) CDVDgetTOC(void* toc)
EXPORT_C_(s32)
CDVDgetTOC(void *toc)
{
if (!iso) return -1;
if (!iso)
return -1;
u8 type = CDVDgetDiskType();
u8* tocBuff = (u8*)toc;
u8 type = CDVDgetDiskType();
u8 *tocBuff = (u8 *)toc;
//__Log("CDVDgetTOC\n");
//__Log("CDVDgetTOC\n");
if (type == CDVD_TYPE_DVDV || type == CDVD_TYPE_PS2DVD)
{
// get dvd structure format
// scsi command 0x43
memset(tocBuff, 0, 2048);
if (type == CDVD_TYPE_DVDV || type == CDVD_TYPE_PS2DVD) {
// get dvd structure format
// scsi command 0x43
memset(tocBuff, 0, 2048);
if (layer1start != -2 && iso->blocks >= 0x300000)
{
//int off = iso->blockofs;
if (layer1start != -2 && iso->blocks >= 0x300000) {
//int off = iso->blockofs;
// dual sided
tocBuff[ 0] = 0x24;
tocBuff[ 1] = 0x02;
tocBuff[ 2] = 0xF2;
tocBuff[ 3] = 0x00;
tocBuff[ 4] = 0x41;
tocBuff[ 5] = 0x95;
// dual sided
tocBuff[0] = 0x24;
tocBuff[1] = 0x02;
tocBuff[2] = 0xF2;
tocBuff[3] = 0x00;
tocBuff[4] = 0x41;
tocBuff[5] = 0x95;
tocBuff[14] = 0x60; // dual sided, ptp
tocBuff[14] = 0x60; // dual sided, ptp
tocBuff[16] = 0x00;
tocBuff[17] = 0x03;
tocBuff[18] = 0x00;
tocBuff[19] = 0x00;
tocBuff[16] = 0x00;
tocBuff[17] = 0x03;
tocBuff[18] = 0x00;
tocBuff[19] = 0x00;
// search for it
if (layer1start == -1)
{
printf("CDVD: searching for layer1...");
// search for it
if (layer1start == -1) {
printf("CDVD: searching for layer1...");
/*tempbuffer = (u8*)malloc(CD_FRAMESIZE_RAW * 10);
/*tempbuffer = (u8*)malloc(CD_FRAMESIZE_RAW * 10);
for (layer1start = (iso->blocks / 2 - 0x10) & ~0xf; layer1start < 0x200010; layer1start += 16)
{
isoReadBlock(iso, tempbuffer, layer1start);
@ -358,201 +362,196 @@ EXPORT_C_(s32) CDVDgetTOC(void* toc)
}
free(tempbuffer);*/
uint midsector = (iso->blocks / 2) & ~0xf;
uint deviation = 0;
uint midsector = (iso->blocks / 2) & ~0xf;
uint deviation = 0;
while( (layer1start == -1) && (deviation < midsector-16) )
{
u8 tempbuffer[CD_FRAMESIZE_RAW];
isoReadBlock(iso, tempbuffer, midsector-deviation);
while ((layer1start == -1) && (deviation < midsector - 16)) {
u8 tempbuffer[CD_FRAMESIZE_RAW];
isoReadBlock(iso, tempbuffer, midsector - deviation);
if(testForPartitionInfo( tempbuffer ))
layer1start = midsector-deviation;
else
{
isoReadBlock(iso, tempbuffer, midsector+deviation);
if( testForPartitionInfo( tempbuffer ) )
layer1start = midsector+deviation;
}
if (testForPartitionInfo(tempbuffer))
layer1start = midsector - deviation;
else {
isoReadBlock(iso, tempbuffer, midsector + deviation);
if (testForPartitionInfo(tempbuffer))
layer1start = midsector + deviation;
}
if( layer1start != -1 )
{
if( tempbuffer[iso->blockofs] != 0x01 )
{
fprintf( stderr, "(LinuzCDVDiso): Invalid partition type on layer 1!? (type=0x%x)", tempbuffer[iso->blockofs] );
}
}
deviation += 16;
}
if (layer1start != -1) {
if (tempbuffer[iso->blockofs] != 0x01) {
fprintf(stderr, "(LinuzCDVDiso): Invalid partition type on layer 1!? (type=0x%x)", tempbuffer[iso->blockofs]);
}
}
deviation += 16;
}
if (layer1start == -1)
{
printf("(LinuzCDVDiso): Couldn't find second layer on dual layer... ignoring\n");
// fake it
tocBuff[ 0] = 0x04;
tocBuff[ 1] = 0x02;
tocBuff[ 2] = 0xF2;
tocBuff[ 3] = 0x00;
tocBuff[ 4] = 0x86;
tocBuff[ 5] = 0x72;
if (layer1start == -1) {
printf("(LinuzCDVDiso): Couldn't find second layer on dual layer... ignoring\n");
// fake it
tocBuff[0] = 0x04;
tocBuff[1] = 0x02;
tocBuff[2] = 0xF2;
tocBuff[3] = 0x00;
tocBuff[4] = 0x86;
tocBuff[5] = 0x72;
tocBuff[16] = 0x00;
tocBuff[17] = 0x03;
tocBuff[18] = 0x00;
tocBuff[19] = 0x00;
layer1start = -2;
return 0;
}
tocBuff[16] = 0x00;
tocBuff[17] = 0x03;
tocBuff[18] = 0x00;
tocBuff[19] = 0x00;
layer1start = -2;
return 0;
}
printf("(LinuzCDVDiso): found at 0x%8.8x\n", layer1start);
layer1start = layer1start + 0x30000 - 1;
}
printf("(LinuzCDVDiso): found at 0x%8.8x\n", layer1start);
layer1start = layer1start + 0x30000 - 1;
}
tocBuff[20] = layer1start >> 24;
tocBuff[21] = (layer1start >> 16) & 0xff;
tocBuff[22] = (layer1start >> 8) & 0xff;
tocBuff[23] = (layer1start >> 0) & 0xff;
}
else
{
// fake it
tocBuff[ 0] = 0x04;
tocBuff[ 1] = 0x02;
tocBuff[ 2] = 0xF2;
tocBuff[ 3] = 0x00;
tocBuff[ 4] = 0x86;
tocBuff[ 5] = 0x72;
tocBuff[20] = layer1start >> 24;
tocBuff[21] = (layer1start >> 16) & 0xff;
tocBuff[22] = (layer1start >> 8) & 0xff;
tocBuff[23] = (layer1start >> 0) & 0xff;
} else {
// fake it
tocBuff[0] = 0x04;
tocBuff[1] = 0x02;
tocBuff[2] = 0xF2;
tocBuff[3] = 0x00;
tocBuff[4] = 0x86;
tocBuff[5] = 0x72;
tocBuff[16] = 0x00;
tocBuff[17] = 0x03;
tocBuff[18] = 0x00;
tocBuff[19] = 0x00;
}
}
else if ((type == CDVD_TYPE_CDDA) || (type == CDVD_TYPE_PS2CDDA) ||
(type == CDVD_TYPE_PS2CD) || (type == CDVD_TYPE_PSCDDA) || (type == CDVD_TYPE_PSCD))
{
// cd toc
// (could be replaced by 1 command that reads the full toc)
u8 min, sec, frm;
s32 i, err;
cdvdTN diskInfo;
cdvdTD trackInfo;
memset(tocBuff, 0, 1024);
if (CDVDgetTN(&diskInfo) == -1)
{
diskInfo.etrack = 0;
diskInfo.strack = 1;
}
if (CDVDgetTD(0, &trackInfo) == -1) trackInfo.lsn = 0;
tocBuff[16] = 0x00;
tocBuff[17] = 0x03;
tocBuff[18] = 0x00;
tocBuff[19] = 0x00;
}
} else if ((type == CDVD_TYPE_CDDA) || (type == CDVD_TYPE_PS2CDDA) ||
(type == CDVD_TYPE_PS2CD) || (type == CDVD_TYPE_PSCDDA) || (type == CDVD_TYPE_PSCD)) {
// cd toc
// (could be replaced by 1 command that reads the full toc)
u8 min, sec, frm;
s32 i, err;
cdvdTN diskInfo;
cdvdTD trackInfo;
memset(tocBuff, 0, 1024);
if (CDVDgetTN(&diskInfo) == -1) {
diskInfo.etrack = 0;
diskInfo.strack = 1;
}
if (CDVDgetTD(0, &trackInfo) == -1)
trackInfo.lsn = 0;
tocBuff[0] = 0x41;
tocBuff[1] = 0x00;
tocBuff[0] = 0x41;
tocBuff[1] = 0x00;
//Number of FirstTrack
tocBuff[2] = 0xA0;
tocBuff[7] = itob(diskInfo.strack);
//Number of FirstTrack
tocBuff[2] = 0xA0;
tocBuff[7] = itob(diskInfo.strack);
//Number of LastTrack
tocBuff[12] = 0xA1;
tocBuff[17] = itob(diskInfo.etrack);
//Number of LastTrack
tocBuff[12] = 0xA1;
tocBuff[17] = itob(diskInfo.etrack);
//DiskLength
lba_to_msf(trackInfo.lsn, &min, &sec, &frm);
tocBuff[22] = 0xA2;
tocBuff[27] = itob(min);
tocBuff[28] = itob(sec);
//DiskLength
lba_to_msf(trackInfo.lsn, &min, &sec, &frm);
tocBuff[22] = 0xA2;
tocBuff[27] = itob(min);
tocBuff[28] = itob(sec);
for (i = diskInfo.strack; i <= diskInfo.etrack; i++)
{
err = CDVDgetTD(i, &trackInfo);
lba_to_msf(trackInfo.lsn, &min, &sec, &frm);
tocBuff[i*10+30] = trackInfo.type;
tocBuff[i*10+32] = err == -1 ? 0 : itob(i); //number
tocBuff[i*10+37] = itob(min);
tocBuff[i*10+38] = itob(sec);
tocBuff[i*10+39] = itob(frm);
}
}
else
return -1;
for (i = diskInfo.strack; i <= diskInfo.etrack; i++) {
err = CDVDgetTD(i, &trackInfo);
lba_to_msf(trackInfo.lsn, &min, &sec, &frm);
tocBuff[i * 10 + 30] = trackInfo.type;
tocBuff[i * 10 + 32] = err == -1 ? 0 : itob(i); //number
tocBuff[i * 10 + 37] = itob(min);
tocBuff[i * 10 + 38] = itob(sec);
tocBuff[i * 10 + 39] = itob(frm);
}
} else
return -1;
return 0;
return 0;
}
EXPORT_C_(s32) CDVDreadTrack(u32 lsn, int mode)
EXPORT_C_(s32)
CDVDreadTrack(u32 lsn, int mode)
{
if (!iso) return -1;
if (!iso)
return -1;
int _lsn = lsn;
int _lsn = lsn;
//__Log("CDVDreadTrack: %x %x\n", lsn, mode);
if (_lsn < 0)
{
// lsn = 2097152 + (-_lsn);
lsn = iso->blocks - (-_lsn);
}
// printf ("CDRreadTrack %d\n", lsn);
//__Log("CDVDreadTrack: %x %x\n", lsn, mode);
if (_lsn < 0) {
// lsn = 2097152 + (-_lsn);
lsn = iso->blocks - (-_lsn);
}
// printf ("CDRreadTrack %d\n", lsn);
isoReadBlock(iso, cdbuffer, lsn);
if (fdump != NULL)
{
isoWriteBlock(fdump, cdbuffer, lsn);
}
isoReadBlock(iso, cdbuffer, lsn);
if (fdump != NULL) {
isoWriteBlock(fdump, cdbuffer, lsn);
}
pbuffer = cdbuffer;
switch (mode)
{
case CDVD_MODE_2352:
break;
case CDVD_MODE_2340:
pbuffer += 12;
break;
case CDVD_MODE_2328:
pbuffer += 24;
break;
case CDVD_MODE_2048:
pbuffer += 24;
break;
}
pbuffer = cdbuffer;
switch (mode) {
case CDVD_MODE_2352:
break;
case CDVD_MODE_2340:
pbuffer += 12;
break;
case CDVD_MODE_2328:
pbuffer += 24;
break;
case CDVD_MODE_2048:
pbuffer += 24;
break;
}
return 0;
return 0;
}
EXPORT_C_(u8*) CDVDgetBuffer()
EXPORT_C_(u8 *)
CDVDgetBuffer()
{
return pbuffer;
return pbuffer;
}
EXPORT_C_(s32) CDVDgetDiskType()
EXPORT_C_(s32)
CDVDgetDiskType()
{
return cdtype;
return cdtype;
}
EXPORT_C_(s32) CDVDgetTrayStatus()
EXPORT_C_(s32)
CDVDgetTrayStatus()
{
return CDVD_TRAY_CLOSE;
return CDVD_TRAY_CLOSE;
}
EXPORT_C_(s32) CDVDctrlTrayOpen()
EXPORT_C_(s32)
CDVDctrlTrayOpen()
{
return 0;
return 0;
}
EXPORT_C_(s32) CDVDctrlTrayClose()
EXPORT_C_(s32)
CDVDctrlTrayClose()
{
return 0;
return 0;
}
EXPORT_C_(s32) CDVDtest()
EXPORT_C_(s32)
CDVDtest()
{
if (*IsoFile == 0) return 0;
if (*IsoFile == 0)
return 0;
iso = isoOpen(IsoFile);
if (iso == NULL) return -1;
isoClose(iso);
iso = isoOpen(IsoFile);
if (iso == NULL)
return -1;
isoClose(iso);
return 0;
return 0;
}

View File

@ -18,308 +18,311 @@
#include "Config.h"
const char *s_strIniPath="./inis/CDVDiso.ini";
const char *s_strIniPath = "./inis/CDVDiso.ini";
GtkWidget *AboutDlg, *ConfDlg, *MsgDlg, *FileSel;
GtkWidget *Edit, *CdEdit;
void LoadConf()
{
FILE *f;
char cfg[256];
FILE *f;
char cfg[256];
//sprintf(cfg, "%s/.PS2E/CDVDiso.cfg", getenv("HOME"));
strcpy(cfg, s_strIniPath);
f = fopen(cfg, "r");
//sprintf(cfg, "%s/.PS2E/CDVDiso.cfg", getenv("HOME"));
strcpy(cfg, s_strIniPath);
f = fopen(cfg, "r");
if (f == NULL)
{
printf("Unable to load %s\n", cfg);
strcpy(IsoFile, DEV_DEF);
strcpy(CdDev, CDDEV_DEF);
BlockDump = 0;
SaveConf();
return;
}
if (f == NULL) {
printf("Unable to load %s\n", cfg);
strcpy(IsoFile, DEV_DEF);
strcpy(CdDev, CDDEV_DEF);
BlockDump = 0;
SaveConf();
return;
}
fscanf(f, "IsoFile = %[^\n]\n", IsoFile);
fscanf(f, "CdDev = %[^\n]\n", CdDev);
fscanf(f, "BlockDump = %d\n", &BlockDump);
fscanf(f, "IsoFile = %[^\n]\n", IsoFile);
fscanf(f, "CdDev = %[^\n]\n", CdDev);
fscanf(f, "BlockDump = %d\n", &BlockDump);
if (!strncmp(IsoFile, "CdDev =", 9)) *IsoFile = 0; // quick fix
if (*CdDev == 0) strcpy(CdDev, CDDEV_DEF);
if (!strncmp(IsoFile, "CdDev =", 9))
*IsoFile = 0; // quick fix
if (*CdDev == 0)
strcpy(CdDev, CDDEV_DEF);
fclose(f);
fclose(f);
}
void SaveConf()
{
FILE *f;
char cfg[256];
FILE *f;
char cfg[256];
//sprintf(cfg, "%s/.PS2E", getenv("HOME"));
//sprintf(cfg, "%s/.PS2E", getenv("HOME"));
//mkdir(cfg, 0755);
//sprintf(cfg, "%s/.PS2E/CDVDiso.cfg", getenv("HOME"));
strcpy(cfg, s_strIniPath);
//mkdir(cfg, 0755);
//sprintf(cfg, "%s/.PS2E/CDVDiso.cfg", getenv("HOME"));
strcpy(cfg, s_strIniPath);
f = fopen(cfg, "w");
if (f == NULL)
{
printf("Unable to save %s\n", cfg);
return;
}
f = fopen(cfg, "w");
if (f == NULL) {
printf("Unable to save %s\n", cfg);
return;
}
fprintf(f, "IsoFile = %s\n", IsoFile);
fprintf(f, "CdDev = %s\n", CdDev);
fprintf(f, "BlockDump = %d\n", BlockDump);
fclose(f);
fprintf(f, "IsoFile = %s\n", IsoFile);
fprintf(f, "CdDev = %s\n", CdDev);
fprintf(f, "BlockDump = %d\n", BlockDump);
fclose(f);
}
void SysMessage(char *fmt, ...)
{
va_list list;
char tmp[256];
char cmd[256];
va_list list;
char tmp[256];
char cmd[256];
va_start(list, fmt);
vsprintf(tmp, fmt, list);
va_end(list);
va_start(list, fmt);
vsprintf(tmp, fmt, list);
va_end(list);
sprintf(cmd, "message \"%s\"", tmp);
SysMessageLoc(tmp);
sprintf(cmd, "message \"%s\"", tmp);
SysMessageLoc(tmp);
}
void OnFile_Ok()
{
const gchar *File;
const gchar *File;
gtk_widget_hide(FileSel);
File = gtk_file_selection_get_filename(GTK_FILE_SELECTION(FileSel));
strcpy(IsoFile, File);
gtk_main_quit();
gtk_widget_hide(FileSel);
File = gtk_file_selection_get_filename(GTK_FILE_SELECTION(FileSel));
strcpy(IsoFile, File);
gtk_main_quit();
}
void OnFile_Cancel()
{
gtk_widget_hide(FileSel);
gtk_main_quit();
gtk_widget_hide(FileSel);
gtk_main_quit();
}
void CfgOpenFile()
{
GtkWidget *Ok, *Cancel;
GtkWidget *Ok, *Cancel;
FileSel = gtk_file_selection_new("Select Iso File");
FileSel = gtk_file_selection_new("Select Iso File");
Ok = GTK_FILE_SELECTION(FileSel)->ok_button;
gtk_signal_connect(GTK_OBJECT(Ok), "clicked",
GTK_SIGNAL_FUNC(OnFile_Ok), NULL);
gtk_widget_show(Ok);
Ok = GTK_FILE_SELECTION(FileSel)->ok_button;
gtk_signal_connect(GTK_OBJECT(Ok), "clicked",
GTK_SIGNAL_FUNC(OnFile_Ok), NULL);
gtk_widget_show(Ok);
Cancel = GTK_FILE_SELECTION(FileSel)->cancel_button;
gtk_signal_connect(GTK_OBJECT(Cancel), "clicked",
GTK_SIGNAL_FUNC(OnFile_Cancel), NULL);
gtk_widget_show(Cancel);
Cancel = GTK_FILE_SELECTION(FileSel)->cancel_button;
gtk_signal_connect(GTK_OBJECT(Cancel), "clicked",
GTK_SIGNAL_FUNC(OnFile_Cancel), NULL);
gtk_widget_show(Cancel);
gtk_widget_show(FileSel);
gdk_window_raise(FileSel->window);
gtk_widget_show(FileSel);
gdk_window_raise(FileSel->window);
gtk_main();
gtk_main();
SaveConf();
SaveConf();
}
void OnMsg_Ok()
{
gtk_widget_destroy(MsgDlg);
gtk_main_quit();
gtk_widget_destroy(MsgDlg);
gtk_main_quit();
}
void SysMessageLoc(char *fmt, ...)
{
GtkWidget *Ok, *Txt;
GtkWidget *Box, *Box1;
va_list list;
int w;
char msg[512];
GtkWidget *Ok, *Txt;
GtkWidget *Box, *Box1;
va_list list;
int w;
char msg[512];
va_start(list, fmt);
vsprintf(msg, fmt, list);
va_end(list);
va_start(list, fmt);
vsprintf(msg, fmt, list);
va_end(list);
if (msg[strlen(msg)-1] == '\n') msg[strlen(msg)-1] = 0;
if (msg[strlen(msg) - 1] == '\n')
msg[strlen(msg) - 1] = 0;
w = strlen(msg) * 6 + 20;
w = strlen(msg) * 6 + 20;
MsgDlg = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_widget_set_usize(MsgDlg, w, 70);
gtk_window_set_position(GTK_WINDOW(MsgDlg), GTK_WIN_POS_CENTER);
gtk_window_set_title(GTK_WINDOW(MsgDlg), "cdriso Msg");
gtk_container_set_border_width(GTK_CONTAINER(MsgDlg), 0);
MsgDlg = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_widget_set_usize(MsgDlg, w, 70);
gtk_window_set_position(GTK_WINDOW(MsgDlg), GTK_WIN_POS_CENTER);
gtk_window_set_title(GTK_WINDOW(MsgDlg), "cdriso Msg");
gtk_container_set_border_width(GTK_CONTAINER(MsgDlg), 0);
Box = gtk_vbox_new(0, 0);
gtk_container_add(GTK_CONTAINER(MsgDlg), Box);
gtk_widget_show(Box);
Box = gtk_vbox_new(0, 0);
gtk_container_add(GTK_CONTAINER(MsgDlg), Box);
gtk_widget_show(Box);
Txt = gtk_label_new(msg);
Txt = gtk_label_new(msg);
gtk_box_pack_start(GTK_BOX(Box), Txt, FALSE, FALSE, 5);
gtk_widget_show(Txt);
gtk_box_pack_start(GTK_BOX(Box), Txt, FALSE, FALSE, 5);
gtk_widget_show(Txt);
Box1 = gtk_hbutton_box_new();
gtk_box_pack_start(GTK_BOX(Box), Box1, FALSE, FALSE, 0);
gtk_widget_show(Box1);
Box1 = gtk_hbutton_box_new();
gtk_box_pack_start(GTK_BOX(Box), Box1, FALSE, FALSE, 0);
gtk_widget_show(Box1);
Ok = gtk_button_new_with_label("Ok");
gtk_signal_connect(GTK_OBJECT(Ok), "clicked", GTK_SIGNAL_FUNC(OnMsg_Ok), NULL);
gtk_container_add(GTK_CONTAINER(Box1), Ok);
GTK_WIDGET_SET_FLAGS(Ok, GTK_CAN_DEFAULT);
gtk_widget_show(Ok);
Ok = gtk_button_new_with_label("Ok");
gtk_signal_connect(GTK_OBJECT(Ok), "clicked", GTK_SIGNAL_FUNC(OnMsg_Ok), NULL);
gtk_container_add(GTK_CONTAINER(Box1), Ok);
GTK_WIDGET_SET_FLAGS(Ok, GTK_CAN_DEFAULT);
gtk_widget_show(Ok);
gtk_widget_show(MsgDlg);
gtk_widget_show(MsgDlg);
gtk_main();
gtk_main();
}
void OnOk (GtkButton *button, gpointer user_data)
void OnOk(GtkButton *button, gpointer user_data)
{
const char *tmp;
const char *tmp;
stop = true;
tmp = gtk_entry_get_text(GTK_ENTRY(Edit));
strcpy(IsoFile, tmp);
tmp = gtk_entry_get_text(GTK_ENTRY(CdEdit));
strcpy(CdDev, tmp);
stop = true;
tmp = gtk_entry_get_text(GTK_ENTRY(Edit));
strcpy(IsoFile, tmp);
tmp = gtk_entry_get_text(GTK_ENTRY(CdEdit));
strcpy(CdDev, tmp);
if is_checked(ConfDlg, "checkBlockDump")
BlockDump = 1;
else
BlockDump = 0;
if
is_checked(ConfDlg, "checkBlockDump")
BlockDump = 1;
else
BlockDump = 0;
SaveConf();
gtk_widget_destroy(ConfDlg);
gtk_main_quit();
SaveConf();
gtk_widget_destroy(ConfDlg);
gtk_main_quit();
}
void OnCancel(GtkButton *button, gpointer user_data)
void OnCancel(GtkButton *button, gpointer user_data)
{
stop = true;
gtk_widget_destroy(ConfDlg);
gtk_main_quit();
stop = true;
gtk_widget_destroy(ConfDlg);
gtk_main_quit();
}
void OnFileSel_Ok()
{
const gchar *File;
const gchar *File;
File = gtk_file_selection_get_filename(GTK_FILE_SELECTION(FileSel));
gtk_entry_set_text(GTK_ENTRY(Edit), File);
gtk_widget_destroy(FileSel);
File = gtk_file_selection_get_filename(GTK_FILE_SELECTION(FileSel));
gtk_entry_set_text(GTK_ENTRY(Edit), File);
gtk_widget_destroy(FileSel);
}
void OnFileSel_Cancel()
{
gtk_widget_destroy(FileSel);
gtk_widget_destroy(FileSel);
}
void OnFileSel(GtkButton *button, gpointer user_data)
void OnFileSel(GtkButton *button, gpointer user_data)
{
GtkWidget *Ok, *Cancel;
GtkWidget *Ok, *Cancel;
FileSel = gtk_file_selection_new("Select Psx Iso File");
gtk_file_selection_set_filename(GTK_FILE_SELECTION(FileSel), IsoFile);
FileSel = gtk_file_selection_new("Select Psx Iso File");
gtk_file_selection_set_filename(GTK_FILE_SELECTION(FileSel), IsoFile);
Ok = GTK_FILE_SELECTION(FileSel)->ok_button;
gtk_signal_connect(GTK_OBJECT(Ok), "clicked", GTK_SIGNAL_FUNC(OnFileSel_Ok), NULL);
gtk_widget_show(Ok);
Ok = GTK_FILE_SELECTION(FileSel)->ok_button;
gtk_signal_connect(GTK_OBJECT(Ok), "clicked", GTK_SIGNAL_FUNC(OnFileSel_Ok), NULL);
gtk_widget_show(Ok);
Cancel = GTK_FILE_SELECTION(FileSel)->cancel_button;
gtk_signal_connect(GTK_OBJECT(Cancel), "clicked", GTK_SIGNAL_FUNC(OnFileSel_Cancel), NULL);
gtk_widget_show(Cancel);
Cancel = GTK_FILE_SELECTION(FileSel)->cancel_button;
gtk_signal_connect(GTK_OBJECT(Cancel), "clicked", GTK_SIGNAL_FUNC(OnFileSel_Cancel), NULL);
gtk_widget_show(Cancel);
gtk_widget_show(FileSel);
gdk_window_raise(FileSel->window);
gtk_widget_show(FileSel);
gdk_window_raise(FileSel->window);
}
EXPORT_C_(void) CDVDconfigure()
EXPORT_C_(void)
CDVDconfigure()
{
int i;
int i;
LoadConf();
LoadConf();
ConfDlg = create_Config();
ConfDlg = create_Config();
Edit = lookup_widget(ConfDlg, "GtkEntry_Iso");
gtk_entry_set_text(GTK_ENTRY(Edit), IsoFile);
CdEdit = lookup_widget(ConfDlg, "GtkEntry_CdDev");
gtk_entry_set_text(GTK_ENTRY(CdEdit), CdDev);
Edit = lookup_widget(ConfDlg, "GtkEntry_Iso");
gtk_entry_set_text(GTK_ENTRY(Edit), IsoFile);
CdEdit = lookup_widget(ConfDlg, "GtkEntry_CdDev");
gtk_entry_set_text(GTK_ENTRY(CdEdit), CdDev);
Progress = lookup_widget(ConfDlg, "GtkProgressBar_Progress");
Progress = lookup_widget(ConfDlg, "GtkProgressBar_Progress");
BtnCompress = lookup_widget(ConfDlg, "GtkButton_Compress");
BtnDecompress = lookup_widget(ConfDlg, "GtkButton_Decompress");
BtnCreate = lookup_widget(ConfDlg, "GtkButton_Create");
BtnCreateZ = lookup_widget(ConfDlg, "GtkButton_CreateZ");
BtnCompress = lookup_widget(ConfDlg, "GtkButton_Compress");
BtnDecompress = lookup_widget(ConfDlg, "GtkButton_Decompress");
BtnCreate = lookup_widget(ConfDlg, "GtkButton_Create");
BtnCreateZ = lookup_widget(ConfDlg, "GtkButton_CreateZ");
methodlist = NULL;
for (i = 0; i < 2; i++)
methodlist = g_list_append(methodlist, methods[i]);
methodlist = NULL;
for (i = 0; i < 2; i++)
methodlist = g_list_append(methodlist, methods[i]);
Method = lookup_widget(ConfDlg, "GtkCombo_Method");
gtk_combo_set_popdown_strings(GTK_COMBO(Method), methodlist);
if (strstr(IsoFile, ".Z") != NULL)
gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(Method)->entry), methods[0]);
else
gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(Method)->entry), methods[1]);
Method = lookup_widget(ConfDlg, "GtkCombo_Method");
gtk_combo_set_popdown_strings(GTK_COMBO(Method), methodlist);
if (strstr(IsoFile, ".Z") != NULL)
gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(Method)->entry), methods[0]);
else
gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(Method)->entry), methods[1]);
set_checked(ConfDlg, "checkBlockDump", (BlockDump == 1));
gtk_widget_show_all(ConfDlg);
gtk_main();
set_checked(ConfDlg, "checkBlockDump", (BlockDump == 1));
gtk_widget_show_all(ConfDlg);
gtk_main();
}
void OnAboutOk(GtkMenuItem * menuitem, gpointer userdata)
void OnAboutOk(GtkMenuItem *menuitem, gpointer userdata)
{
gtk_widget_hide(AboutDlg);
gtk_main_quit();
gtk_widget_hide(AboutDlg);
gtk_main_quit();
}
EXPORT_C_(void) CDVDabout()
EXPORT_C_(void)
CDVDabout()
{
GtkWidget *Label;
GtkWidget *Ok;
GtkWidget *Box, *BBox;
char AboutText[255];
GtkWidget *Label;
GtkWidget *Ok;
GtkWidget *Box, *BBox;
char AboutText[255];
sprintf(AboutText, "%s %d.%d\n", LibName, revision, build);
sprintf(AboutText, "%s %d.%d\n", LibName, revision, build);
AboutDlg = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_widget_set_usize(AboutDlg, 260, 80);
gtk_window_set_title(GTK_WINDOW(AboutDlg), "CDVD About Dialog");
gtk_window_set_position(GTK_WINDOW(AboutDlg), GTK_WIN_POS_CENTER);
gtk_container_set_border_width(GTK_CONTAINER(AboutDlg), 10);
AboutDlg = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_widget_set_usize(AboutDlg, 260, 80);
gtk_window_set_title(GTK_WINDOW(AboutDlg), "CDVD About Dialog");
gtk_window_set_position(GTK_WINDOW(AboutDlg), GTK_WIN_POS_CENTER);
gtk_container_set_border_width(GTK_CONTAINER(AboutDlg), 10);
Box = gtk_vbox_new(0, 0);
gtk_container_add(GTK_CONTAINER(AboutDlg), Box);
gtk_widget_show(Box);
Box = gtk_vbox_new(0, 0);
gtk_container_add(GTK_CONTAINER(AboutDlg), Box);
gtk_widget_show(Box);
Label = gtk_label_new(AboutText);
gtk_box_pack_start(GTK_BOX(Box), Label, FALSE, FALSE, 0);
gtk_widget_show(Label);
Label = gtk_label_new(AboutText);
gtk_box_pack_start(GTK_BOX(Box), Label, FALSE, FALSE, 0);
gtk_widget_show(Label);
BBox = gtk_hbutton_box_new();
gtk_box_pack_start(GTK_BOX(Box), BBox, FALSE, FALSE, 0);
gtk_widget_show(BBox);
BBox = gtk_hbutton_box_new();
gtk_box_pack_start(GTK_BOX(Box), BBox, FALSE, FALSE, 0);
gtk_widget_show(BBox);
Ok = gtk_button_new_with_label("Ok");
gtk_signal_connect(GTK_OBJECT(Ok), "clicked",
GTK_SIGNAL_FUNC(OnAboutOk), NULL);
gtk_container_add(GTK_CONTAINER(BBox), Ok);
GTK_WIDGET_SET_FLAGS(Ok, GTK_CAN_DEFAULT);
gtk_widget_show(Ok);
Ok = gtk_button_new_with_label("Ok");
gtk_signal_connect(GTK_OBJECT(Ok), "clicked",
GTK_SIGNAL_FUNC(OnAboutOk), NULL);
gtk_container_add(GTK_CONTAINER(BBox), Ok);
GTK_WIDGET_SET_FLAGS(Ok, GTK_CAN_DEFAULT);
gtk_widget_show(Ok);
gtk_widget_show(AboutDlg);
gtk_main();
gtk_widget_show(AboutDlg);
gtk_main();
}

View File

@ -31,9 +31,8 @@
#include <bzlib.h>
#include <gtk/gtk.h>
#ifdef __cplusplus
extern "C"
{
#ifdef __cplusplus
extern "C" {
#endif
#include "support.h"
@ -59,7 +58,7 @@ extern GtkWidget *AboutDlg, *ConfDlg, *MsgDlg, *FileSel;
extern GtkWidget *Edit, *CdEdit;
extern bool stop;
extern GtkWidget *Method,*Progress;
extern GtkWidget *Method, *Progress;
extern GtkWidget *BtnCompress, *BtnDecompress;
extern GtkWidget *BtnCreate, *BtnCreateZ;
@ -67,7 +66,7 @@ extern GList *methodlist;
// Make it easier to check and set checkmarks in the gui
#define is_checked(main_widget, widget_name) (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lookup_widget(main_widget, widget_name))))
#define set_checked(main_widget,widget_name, state) gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(lookup_widget(main_widget, widget_name)), state)
#define set_checked(main_widget, widget_name, state) gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(lookup_widget(main_widget, widget_name)), state)
extern void OnFileSel(GtkButton *button, gpointer user_data);
@ -78,4 +77,3 @@ extern void OnCreate(GtkButton *button, gpointer user_data);
extern void OnCreateZ(GtkButton *button, gpointer user_data);
extern void OnOk(GtkButton *button, gpointer user_data);
extern void OnCancel(GtkButton *button, gpointer user_data);

View File

@ -20,7 +20,7 @@
unsigned char Zbuf[CD_FRAMESIZE_RAW * 10 * 2];
GtkWidget *Method,*Progress;
GtkWidget *Method, *Progress;
GtkWidget *BtnCompress, *BtnDecompress;
GtkWidget *BtnCreate, *BtnCreateZ;
@ -30,107 +30,112 @@ unsigned char param[4];
int cddev = -1;
bool stop;
#define CD_LEADOUT (0xaa)
#define CD_LEADOUT (0xaa)
union
{
struct cdrom_msf msf;
unsigned char buf[CD_FRAMESIZE_RAW];
struct cdrom_msf msf;
unsigned char buf[CD_FRAMESIZE_RAW];
} cr;
void OnStop(GtkButton *button, gpointer user_data)
void OnStop(GtkButton *button, gpointer user_data)
{
stop = true;
stop = true;
}
void UpdZmode()
{
const char *tmp;
const char *tmp;
tmp = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(Method)->entry));
if (!strcmp(tmp, methods[0])) Zmode = 1;
else Zmode = 2;
tmp = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(Method)->entry));
if (!strcmp(tmp, methods[0]))
Zmode = 1;
else
Zmode = 2;
}
char buffer[2352 * 10];
void OnCompress(GtkButton *button, gpointer user_data)
void OnCompress(GtkButton *button, gpointer user_data)
{
struct stat buf;
u32 lsn;
u8 cdbuff[10*2352];
char Zfile[256];
const char *tmp;
int ret = 0;
isoFile *src;
isoFile *dst;
struct stat buf;
u32 lsn;
u8 cdbuff[10 * 2352];
char Zfile[256];
const char *tmp;
int ret = 0;
isoFile *src;
isoFile *dst;
tmp = gtk_entry_get_text(GTK_ENTRY(Edit));
strcpy(IsoFile, tmp);
UpdZmode();
tmp = gtk_entry_get_text(GTK_ENTRY(Edit));
strcpy(IsoFile, tmp);
UpdZmode();
if (Zmode == 1) sprintf(Zfile, "%s.Z2", IsoFile);
if (Zmode == 2) sprintf(Zfile, "%s.BZ2", IsoFile);
if (Zmode == 1)
sprintf(Zfile, "%s.Z2", IsoFile);
if (Zmode == 2)
sprintf(Zfile, "%s.BZ2", IsoFile);
if (stat(Zfile, &buf) != -1)
{
/*char str[256];*/
return;
/* sprintf(str, "'%s' already exists, overwrite?", Zfile);
if (stat(Zfile, &buf) != -1) {
/*char str[256];*/
return;
/* sprintf(str, "'%s' already exists, overwrite?", Zfile);
if (MessageBox(hDlg, str, "Question", MB_YESNO) != IDYES) {
return;
}*/
}
}
src = isoOpen(IsoFile);
if (src == NULL) return;
dst = isoCreate(Zfile, Zmode == 1 ? ISOFLAGS_Z2 : ISOFLAGS_BZ2);
if (dst == NULL) return;
src = isoOpen(IsoFile);
if (src == NULL)
return;
dst = isoCreate(Zfile, Zmode == 1 ? ISOFLAGS_Z2 : ISOFLAGS_BZ2);
if (dst == NULL)
return;
gtk_widget_set_sensitive(BtnCompress, FALSE);
gtk_widget_set_sensitive(BtnDecompress, FALSE);
gtk_widget_set_sensitive(BtnCreate, FALSE);
gtk_widget_set_sensitive(BtnCreateZ, FALSE);
stop = false;
gtk_widget_set_sensitive(BtnCompress, FALSE);
gtk_widget_set_sensitive(BtnDecompress, FALSE);
gtk_widget_set_sensitive(BtnCreate, FALSE);
gtk_widget_set_sensitive(BtnCreateZ, FALSE);
stop = false;
for (lsn = 0; lsn < src->blocks; lsn++)
{
printf("block %d ", lsn);
putchar(13);
fflush(stdout);
ret = isoReadBlock(src, cdbuff, lsn);
if (ret == -1) break;
ret = isoWriteBlock(dst, cdbuff, lsn);
if (ret == -1) break;
for (lsn = 0; lsn < src->blocks; lsn++) {
printf("block %d ", lsn);
putchar(13);
fflush(stdout);
ret = isoReadBlock(src, cdbuff, lsn);
if (ret == -1)
break;
ret = isoWriteBlock(dst, cdbuff, lsn);
if (ret == -1)
break;
gtk_progress_bar_update(GTK_PROGRESS_BAR(Progress), (lsn * 100) / src->blocks);
while (gtk_events_pending()) gtk_main_iteration();
if (stop) break;
}
isoClose(src);
isoClose(dst);
gtk_progress_bar_update(GTK_PROGRESS_BAR(Progress), (lsn * 100) / src->blocks);
while (gtk_events_pending())
gtk_main_iteration();
if (stop)
break;
}
isoClose(src);
isoClose(dst);
if (!stop) gtk_entry_set_text(GTK_ENTRY(Edit), IsoFile);
if (!stop)
gtk_entry_set_text(GTK_ENTRY(Edit), IsoFile);
gtk_widget_set_sensitive(BtnCompress, TRUE);
gtk_widget_set_sensitive(BtnDecompress, TRUE);
gtk_widget_set_sensitive(BtnCreate, TRUE);
gtk_widget_set_sensitive(BtnCreateZ, TRUE);
gtk_widget_set_sensitive(BtnCompress, TRUE);
gtk_widget_set_sensitive(BtnDecompress, TRUE);
gtk_widget_set_sensitive(BtnCreate, TRUE);
gtk_widget_set_sensitive(BtnCreateZ, TRUE);
if (!stop)
{
if (ret == -1)
{
SysMessageLoc("Error compressing iso image");
}
else
{
SysMessageLoc("Iso image compressed OK");
}
}
if (!stop) {
if (ret == -1) {
SysMessageLoc("Error compressing iso image");
} else {
SysMessageLoc("Iso image compressed OK");
}
}
}
void OnDecompress(GtkButton *button, gpointer user_data)
void OnDecompress(GtkButton *button, gpointer user_data)
{
#if 0
struct stat buf;
@ -255,40 +260,38 @@ void OnDecompress(GtkButton *button, gpointer user_data)
void incSector()
{
param[2]++;
if (param[2] == 75)
{
param[2] = 0;
param[1]++;
}
if (param[1] == 60)
{
param[1] = 0;
param[0]++;
}
param[2]++;
if (param[2] == 75) {
param[2] = 0;
param[1]++;
}
if (param[1] == 60) {
param[1] = 0;
param[0]++;
}
}
long CDR_open(void)
{
if (cddev != -1)
return 0;
cddev = open(CdDev, O_RDONLY);
if (cddev == -1)
{
printf("CDR: Could not open %s\n", CdDev);
return -1;
}
if (cddev != -1)
return 0;
cddev = open(CdDev, O_RDONLY);
if (cddev == -1) {
printf("CDR: Could not open %s\n", CdDev);
return -1;
}
return 0;
return 0;
}
long CDR_close(void)
{
if (cddev == -1) return 0;
close(cddev);
cddev = -1;
if (cddev == -1)
return 0;
close(cddev);
cddev = -1;
return 0;
return 0;
}
// return Starting and Ending Track
@ -297,14 +300,15 @@ long CDR_close(void)
// byte 1 - end track
long CDR_getTN(unsigned char *buffer)
{
struct cdrom_tochdr toc;
struct cdrom_tochdr toc;
if (ioctl(cddev, CDROMREADTOCHDR, &toc) == -1) return -1;
if (ioctl(cddev, CDROMREADTOCHDR, &toc) == -1)
return -1;
buffer[0] = toc.cdth_trk0; // start track
buffer[1] = toc.cdth_trk1; // end track
buffer[0] = toc.cdth_trk0; // start track
buffer[1] = toc.cdth_trk1; // end track
return 0;
return 0;
}
// return Track Time
@ -314,19 +318,21 @@ long CDR_getTN(unsigned char *buffer)
// byte 2 - minute
long CDR_getTD(unsigned char track, unsigned char *buffer)
{
struct cdrom_tocentry entry;
struct cdrom_tocentry entry;
if (track == 0) track = 0xaa; // total time
entry.cdte_track = track;
entry.cdte_format = CDROM_MSF;
if (track == 0)
track = 0xaa; // total time
entry.cdte_track = track;
entry.cdte_format = CDROM_MSF;
if (ioctl(cddev, CDROMREADTOCENTRY, &entry) == -1) return -1;
if (ioctl(cddev, CDROMREADTOCENTRY, &entry) == -1)
return -1;
buffer[0] = entry.cdte_addr.msf.minute; /* minute */
buffer[1] = entry.cdte_addr.msf.second; /* second */
buffer[2] = entry.cdte_addr.msf.frame; /* frame */
buffer[0] = entry.cdte_addr.msf.minute; /* minute */
buffer[1] = entry.cdte_addr.msf.second; /* second */
buffer[2] = entry.cdte_addr.msf.frame; /* frame */
return 0;
return 0;
}
// read track
@ -336,340 +342,333 @@ long CDR_getTD(unsigned char track, unsigned char *buffer)
// byte 2 - frame
unsigned char *CDR_readTrack(unsigned char *time)
{
cr.msf.cdmsf_min0 = time[0];
cr.msf.cdmsf_sec0 = time[1];
cr.msf.cdmsf_frame0 = time[2];
cr.msf.cdmsf_min0 = time[0];
cr.msf.cdmsf_sec0 = time[1];
cr.msf.cdmsf_frame0 = time[2];
if (ioctl(cddev, CDROMREADRAW, &cr) == -1) return NULL;
return cr.buf;
if (ioctl(cddev, CDROMREADRAW, &cr) == -1)
return NULL;
return cr.buf;
}
void OnCreate(GtkButton *button, gpointer user_data)
void OnCreate(GtkButton *button, gpointer user_data)
{
FILE *f;
struct stat buf;
struct tm *Tm;
time_t Ttime;
unsigned long ftrack, ltrack;
unsigned long p = 0, s;
unsigned char *buffer;
unsigned char bufferz[2352];
unsigned char start[4], end[4];
const char *tmp;
FILE *f;
struct stat buf;
struct tm *Tm;
time_t Ttime;
unsigned long ftrack, ltrack;
unsigned long p = 0, s;
unsigned char *buffer;
unsigned char bufferz[2352];
unsigned char start[4], end[4];
const char *tmp;
#ifdef VERBOSE
unsigned long count = 0;
int i = 0;
unsigned long count = 0;
int i = 0;
#endif
memset(bufferz, 0, sizeof(bufferz));
ftrack = 1;
ltrack = CD_LEADOUT;
memset(bufferz, 0, sizeof(bufferz));
ftrack = 1;
ltrack = CD_LEADOUT;
tmp = gtk_entry_get_text(GTK_ENTRY(Edit));
strcpy(IsoFile, tmp);
tmp = gtk_entry_get_text(GTK_ENTRY(Edit));
strcpy(IsoFile, tmp);
if (stat(IsoFile, &buf) == 0)
{
printf("File %s Already exists\n", IsoFile);
return;
}
if (stat(IsoFile, &buf) == 0) {
printf("File %s Already exists\n", IsoFile);
return;
}
if (CDR_open() == -1)
{
return;
}
if (CDR_open() == -1) {
return;
}
if (CDR_getTD(ftrack, start) == -1)
{
printf("Error getting TD\n");
if (CDR_getTD(ftrack, start) == -1) {
printf("Error getting TD\n");
CDR_close();
return;
}
if (CDR_getTD(ltrack, end) == -1)
{
printf("Error getting TD\n");
CDR_close();
return;
}
if (CDR_getTD(ltrack, end) == -1) {
printf("Error getting TD\n");
CDR_close();
return;
}
CDR_close();
return;
}
f = fopen(IsoFile, "wb");
if (f == NULL)
{
CDR_close();
printf("Error opening %s", IsoFile);
return;
}
f = fopen(IsoFile, "wb");
if (f == NULL) {
CDR_close();
printf("Error opening %s", IsoFile);
return;
}
printf("Making Iso: from %2.2d:%2.2d:%2.2d to %2.2d:%2.2d:%2.2d\n",
start[0], start[1], start[2], end[0], end[1], end[2]);
printf("Making Iso: from %2.2d:%2.2d:%2.2d to %2.2d:%2.2d:%2.2d\n",
start[0], start[1], start[2], end[0], end[1], end[2]);
memcpy(param, start, 3);
memcpy(param, start, 3);
time(&Ttime);
time(&Ttime);
stop = false;
s = MSF2SECT(end[0], end[1], end[2]);
gtk_widget_set_sensitive(BtnCompress, FALSE);
gtk_widget_set_sensitive(BtnDecompress, FALSE);
gtk_widget_set_sensitive(BtnCreate, FALSE);
gtk_widget_set_sensitive(BtnCreateZ, FALSE);
stop = false;
s = MSF2SECT(end[0], end[1], end[2]);
gtk_widget_set_sensitive(BtnCompress, FALSE);
gtk_widget_set_sensitive(BtnDecompress, FALSE);
gtk_widget_set_sensitive(BtnCreate, FALSE);
gtk_widget_set_sensitive(BtnCreateZ, FALSE);
for (;;) /* loop until end */
{
float per;
for (;;) /* loop until end */
{
float per;
if ((param[0] == end[0]) & (param[1] == end[1]) & (param[2] == end[2]))
break;
buffer = CDR_readTrack(param);
if (buffer == NULL)
{
int i;
if ((param[0] == end[0]) & (param[1] == end[1]) & (param[2] == end[2]))
break;
buffer = CDR_readTrack(param);
if (buffer == NULL) {
int i;
for (i = 0; i < 10; i++)
{
buffer = CDR_readTrack(param);
if (buffer != NULL) break;
}
if (buffer == NULL)
{
printf("Error Reading %2d:%2d:%2d\n", param[0], param[1], param[2]);
buffer = bufferz;
buffer[12] = param[0];
buffer[13] = param[1];
buffer[14] = param[2];
buffer[15] = 0x2;
}
}
fwrite(buffer, 1, 2352, f);
for (i = 0; i < 10; i++) {
buffer = CDR_readTrack(param);
if (buffer != NULL)
break;
}
if (buffer == NULL) {
printf("Error Reading %2d:%2d:%2d\n", param[0], param[1], param[2]);
buffer = bufferz;
buffer[12] = param[0];
buffer[13] = param[1];
buffer[14] = param[2];
buffer[15] = 0x2;
}
}
fwrite(buffer, 1, 2352, f);
#ifdef VERBOSE
count += CD_FRAMESIZE_RAW;
count += CD_FRAMESIZE_RAW;
printf("reading %2d:%2d:%2d ", param[0], param[1], param[2]);
if ((time(NULL) - Ttime) != 0)
{
i = (count / 1024) / (time(NULL) - Ttime);
printf("( %5dKbytes/s, %dX)", i, i / 150);
}
putchar(13);
fflush(stdout);
printf("reading %2d:%2d:%2d ", param[0], param[1], param[2]);
if ((time(NULL) - Ttime) != 0) {
i = (count / 1024) / (time(NULL) - Ttime);
printf("( %5dKbytes/s, %dX)", i, i / 150);
}
putchar(13);
fflush(stdout);
#endif
incSector();
incSector();
p++;
per = ((float)p / s);
gtk_progress_bar_update(GTK_PROGRESS_BAR(Progress), per);
while (gtk_events_pending()) gtk_main_iteration();
if (stop) break;
}
p++;
per = ((float)p / s);
gtk_progress_bar_update(GTK_PROGRESS_BAR(Progress), per);
while (gtk_events_pending())
gtk_main_iteration();
if (stop)
break;
}
Ttime = time(NULL) - Ttime;
Tm = gmtime(&Ttime);
printf("\nTotal Time used: %d:%d:%d\n", Tm->tm_hour, Tm->tm_min,
Tm->tm_sec);
Ttime = time(NULL) - Ttime;
Tm = gmtime(&Ttime);
printf("\nTotal Time used: %d:%d:%d\n", Tm->tm_hour, Tm->tm_min,
Tm->tm_sec);
CDR_close();
fclose(f);
CDR_close();
fclose(f);
gtk_widget_set_sensitive(BtnCompress, TRUE);
gtk_widget_set_sensitive(BtnDecompress, TRUE);
gtk_widget_set_sensitive(BtnCreate, TRUE);
gtk_widget_set_sensitive(BtnCreateZ, TRUE);
gtk_widget_set_sensitive(BtnCompress, TRUE);
gtk_widget_set_sensitive(BtnDecompress, TRUE);
gtk_widget_set_sensitive(BtnCreate, TRUE);
gtk_widget_set_sensitive(BtnCreateZ, TRUE);
if (!stop) SysMessageLoc("Iso Image Created OK");
if (!stop)
SysMessageLoc("Iso Image Created OK");
}
void OnCreateZ(GtkButton *button, gpointer user_data)
void OnCreateZ(GtkButton *button, gpointer user_data)
{
FILE *f;
FILE *t;
struct stat buf;
struct tm *Tm;
time_t Ttime;
unsigned long ftrack, ltrack;
unsigned long p = 0, s, c = 0;
unsigned char *buffer;
unsigned char bufferz[2352];
unsigned char start[4], end[4];
char table[256];
const char *tmp;
int b, blocks;
FILE *f;
FILE *t;
struct stat buf;
struct tm *Tm;
time_t Ttime;
unsigned long ftrack, ltrack;
unsigned long p = 0, s, c = 0;
unsigned char *buffer;
unsigned char bufferz[2352];
unsigned char start[4], end[4];
char table[256];
const char *tmp;
int b, blocks;
#ifdef VERBOSE
unsigned long count = 0;
int i = 0;
unsigned long count = 0;
int i = 0;
#endif
memset(bufferz, 0, sizeof(bufferz));
ftrack = 1;
ltrack = CD_LEADOUT;
memset(bufferz, 0, sizeof(bufferz));
ftrack = 1;
ltrack = CD_LEADOUT;
tmp = gtk_entry_get_text(GTK_ENTRY(Edit));
strcpy(IsoFile, tmp);
tmp = gtk_entry_get_text(GTK_ENTRY(Edit));
strcpy(IsoFile, tmp);
UpdZmode();
UpdZmode();
if (Zmode == 1)
{
blocks = 1;
if (strstr(IsoFile, ".Z") == NULL) strcat(IsoFile, ".Z");
}
else
{
blocks = 10;
if (strstr(IsoFile, ".bz") == NULL) strcat(IsoFile, ".bz");
}
if (Zmode == 1) {
blocks = 1;
if (strstr(IsoFile, ".Z") == NULL)
strcat(IsoFile, ".Z");
} else {
blocks = 10;
if (strstr(IsoFile, ".bz") == NULL)
strcat(IsoFile, ".bz");
}
if (stat(IsoFile, &buf) == 0)
{
printf("File %s Already exists\n", IsoFile);
return;
}
if (stat(IsoFile, &buf) == 0) {
printf("File %s Already exists\n", IsoFile);
return;
}
strcpy(table, IsoFile);
if (Zmode == 1)
strcat(table, ".table");
else
strcat(table, ".index");
strcpy(table, IsoFile);
if (Zmode == 1)
strcat(table, ".table");
else
strcat(table, ".index");
t = fopen(table, "wb");
t = fopen(table, "wb");
if (t == NULL) return;
if (CDR_open() == -1)
{
fclose(t);
return;
}
if (CDR_getTD(ftrack, start) == -1)
{
printf("Error getting TD\n");
CDR_close();
fclose(t);
return;
}
if (t == NULL)
return;
if (CDR_open() == -1) {
fclose(t);
return;
}
if (CDR_getTD(ftrack, start) == -1) {
printf("Error getting TD\n");
CDR_close();
fclose(t);
return;
}
if (CDR_getTD(ltrack, end) == -1)
{
printf("Error getting TD\n");
CDR_close();
fclose(t);
return;
}
if (CDR_getTD(ltrack, end) == -1) {
printf("Error getting TD\n");
CDR_close();
fclose(t);
return;
}
f = fopen(IsoFile, "wb");
if (f == NULL)
{
CDR_close();
fclose(t);
printf("Error opening %s", IsoFile);
return;
}
f = fopen(IsoFile, "wb");
if (f == NULL) {
CDR_close();
fclose(t);
printf("Error opening %s", IsoFile);
return;
}
printf("Making Iso: from %2.2d:%2.2d:%2.2d to %2.2d:%2.2d:%2.2d\n",
start[0], start[1], start[2], end[0], end[1], end[2]);
printf("Making Iso: from %2.2d:%2.2d:%2.2d to %2.2d:%2.2d:%2.2d\n",
start[0], start[1], start[2], end[0], end[1], end[2]);
memcpy(param, start, 3);
memcpy(param, start, 3);
time(&Ttime);
time(&Ttime);
stop = false;
s = MSF2SECT(end[0], end[1], end[2]) / blocks;
gtk_widget_set_sensitive(BtnCompress, FALSE);
gtk_widget_set_sensitive(BtnDecompress, FALSE);
gtk_widget_set_sensitive(BtnCreate, FALSE);
gtk_widget_set_sensitive(BtnCreateZ, FALSE);
stop = false;
s = MSF2SECT(end[0], end[1], end[2]) / blocks;
gtk_widget_set_sensitive(BtnCompress, FALSE);
gtk_widget_set_sensitive(BtnDecompress, FALSE);
gtk_widget_set_sensitive(BtnCreate, FALSE);
gtk_widget_set_sensitive(BtnCreateZ, FALSE);
for (;;) /* loop until end */
{
unsigned long size;
unsigned char Zbuf[CD_FRAMESIZE_RAW * 10 * 2];
float per;
for (;;) /* loop until end */
{
unsigned long size;
unsigned char Zbuf[CD_FRAMESIZE_RAW * 10 * 2];
float per;
for (b = 0; b < blocks; b++)
{
if ((param[0] == end[0]) & (param[1] == end[1]) & (param[2] == end[2]))
break;
for (b = 0; b < blocks; b++) {
if ((param[0] == end[0]) & (param[1] == end[1]) & (param[2] == end[2]))
break;
buffer = CDR_readTrack(param);
if (buffer == NULL)
{
int i;
buffer = CDR_readTrack(param);
if (buffer == NULL) {
int i;
for (i = 0; i < 10; i++)
{
buffer = CDR_readTrack(param);
if (buffer != NULL) break;
}
for (i = 0; i < 10; i++) {
buffer = CDR_readTrack(param);
if (buffer != NULL)
break;
}
if (buffer == NULL)
{
printf("Error Reading %2d:%2d:%2d\n", param[0], param[1], param[2]);
buffer = bufferz;
buffer[12] = param[0];
buffer[13] = param[1];
buffer[14] = param[2];
buffer[15] = 0x2;
}
}
memcpy(cdbuffer + b * CD_FRAMESIZE_RAW, buffer, CD_FRAMESIZE_RAW);
if (buffer == NULL) {
printf("Error Reading %2d:%2d:%2d\n", param[0], param[1], param[2]);
buffer = bufferz;
buffer[12] = param[0];
buffer[13] = param[1];
buffer[14] = param[2];
buffer[15] = 0x2;
}
}
memcpy(cdbuffer + b * CD_FRAMESIZE_RAW, buffer, CD_FRAMESIZE_RAW);
incSector();
}
if ((param[0] == end[0]) & (param[1] == end[1]) & (param[2] == end[2]))
break;
incSector();
}
if ((param[0] == end[0]) & (param[1] == end[1]) & (param[2] == end[2]))
break;
size = CD_FRAMESIZE_RAW * blocks * 2;
if (Zmode == 1)
compress(Zbuf, &size, cdbuffer, CD_FRAMESIZE_RAW);
else
BZ2_bzBuffToBuffCompress((char*)Zbuf, (unsigned int*)&size, (char*)cdbuffer, CD_FRAMESIZE_RAW * 10, 1, 0, 30);
size = CD_FRAMESIZE_RAW * blocks * 2;
if (Zmode == 1)
compress(Zbuf, &size, cdbuffer, CD_FRAMESIZE_RAW);
else
BZ2_bzBuffToBuffCompress((char *)Zbuf, (unsigned int *)&size, (char *)cdbuffer, CD_FRAMESIZE_RAW * 10, 1, 0, 30);
fwrite(&c, 1, 4, t);
if (Zmode == 1) fwrite(&size, 1, 2, t);
fwrite(&c, 1, 4, t);
if (Zmode == 1)
fwrite(&size, 1, 2, t);
fwrite(Zbuf, 1, size, f);
fwrite(Zbuf, 1, size, f);
c += size;
c += size;
#ifdef VERBOSE
count += CD_FRAMESIZE_RAW * blocks;
count += CD_FRAMESIZE_RAW * blocks;
printf("reading %2d:%2d:%2d ", param[0], param[1], param[2]);
if ((time(NULL) - Ttime) != 0)
{
i = (count / 1024) / (time(NULL) - Ttime);
printf("( %5dKbytes/s, %dX)", i, i / 150);
}
putchar(13);
fflush(stdout);
printf("reading %2d:%2d:%2d ", param[0], param[1], param[2]);
if ((time(NULL) - Ttime) != 0) {
i = (count / 1024) / (time(NULL) - Ttime);
printf("( %5dKbytes/s, %dX)", i, i / 150);
}
putchar(13);
fflush(stdout);
#endif
p++;
per = ((float)p / s);
p++;
per = ((float)p / s);
gtk_progress_bar_update(GTK_PROGRESS_BAR(Progress), per);
while (gtk_events_pending()) gtk_main_iteration();
gtk_progress_bar_update(GTK_PROGRESS_BAR(Progress), per);
while (gtk_events_pending())
gtk_main_iteration();
if (stop) break;
}
if (Zmode == 2) fwrite(&c, 1, 4, f);
if (stop)
break;
}
if (Zmode == 2)
fwrite(&c, 1, 4, f);
if (!stop) gtk_entry_set_text(GTK_ENTRY(Edit), IsoFile);
if (!stop)
gtk_entry_set_text(GTK_ENTRY(Edit), IsoFile);
Ttime = time(NULL) - Ttime;
Tm = gmtime(&Ttime);
printf("\nTotal Time used: %d:%d:%d\n", Tm->tm_hour, Tm->tm_min,
Tm->tm_sec);
Ttime = time(NULL) - Ttime;
Tm = gmtime(&Ttime);
printf("\nTotal Time used: %d:%d:%d\n", Tm->tm_hour, Tm->tm_min,
Tm->tm_sec);
CDR_close();
fclose(f);
fclose(t);
CDR_close();
fclose(f);
fclose(t);
gtk_widget_set_sensitive(BtnCompress, TRUE);
gtk_widget_set_sensitive(BtnDecompress, TRUE);
gtk_widget_set_sensitive(BtnCreate, TRUE);
gtk_widget_set_sensitive(BtnCreateZ, TRUE);
gtk_widget_set_sensitive(BtnCompress, TRUE);
gtk_widget_set_sensitive(BtnDecompress, TRUE);
gtk_widget_set_sensitive(BtnCreate, TRUE);
gtk_widget_set_sensitive(BtnCreateZ, TRUE);
if (!stop) SysMessageLoc("Compressed Iso Image Created OK");
if (!stop)
SysMessageLoc("Compressed Iso Image Created OK");
}

View File

@ -1,34 +1,26 @@
#include <gtk/gtk.h>
void
OnFileSel (GtkButton *button,
gpointer user_data);
void OnFileSel(GtkButton *button,
gpointer user_data);
void
OnStop (GtkButton *button,
gpointer user_data);
void OnStop(GtkButton *button,
gpointer user_data);
void
OnCompress (GtkButton *button,
gpointer user_data);
void OnCompress(GtkButton *button,
gpointer user_data);
void
OnDecompress (GtkButton *button,
gpointer user_data);
void OnDecompress(GtkButton *button,
gpointer user_data);
void
OnCreate (GtkButton *button,
gpointer user_data);
void OnCreate(GtkButton *button,
gpointer user_data);
void
OnCreateZ (GtkButton *button,
gpointer user_data);
void OnCreateZ(GtkButton *button,
gpointer user_data);
void
OnOk (GtkButton *button,
gpointer user_data);
void OnOk(GtkButton *button,
gpointer user_data);
void
OnCancel (GtkButton *button,
gpointer user_data);
void OnCancel(GtkButton *button,
gpointer user_data);

View File

@ -2,4 +2,4 @@
* DO NOT EDIT THIS FILE - it is generated by Glade.
*/
GtkWidget* create_Config (void);
GtkWidget *create_Config(void);

View File

@ -3,7 +3,7 @@
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#include <config.h>
#endif
#include <gtk/gtk.h>
@ -12,24 +12,24 @@
* Standard gettext macros.
*/
#ifdef ENABLE_NLS
# include <libintl.h>
# undef _
# define _(String) dgettext (PACKAGE, String)
# define Q_(String) g_strip_context ((String), gettext (String))
# ifdef gettext_noop
# define N_(String) gettext_noop (String)
# else
# define N_(String) (String)
# endif
#include <libintl.h>
#undef _
#define _(String) dgettext(PACKAGE, String)
#define Q_(String) g_strip_context((String), gettext(String))
#ifdef gettext_noop
#define N_(String) gettext_noop(String)
#else
# define textdomain(String) (String)
# define gettext(String) (String)
# define dgettext(Domain,Message) (Message)
# define dcgettext(Domain,Message,Type) (Message)
# define bindtextdomain(Domain,Directory) (Domain)
# define _(String) (String)
# define Q_(String) g_strip_context ((String), (String))
# define N_(String) (String)
#define N_(String) (String)
#endif
#else
#define textdomain(String) (String)
#define gettext(String) (String)
#define dgettext(Domain, Message) (Message)
#define dcgettext(Domain, Message, Type) (Message)
#define bindtextdomain(Domain, Directory) (Domain)
#define _(String) (String)
#define Q_(String) g_strip_context((String), (String))
#define N_(String) (String)
#endif
@ -43,12 +43,12 @@
* or alternatively any widget in the component, and the name of the widget
* you want returned.
*/
GtkWidget* lookup_widget (GtkWidget *widget,
const gchar *widget_name);
GtkWidget *lookup_widget(GtkWidget *widget,
const gchar *widget_name);
/* Use this function to set the directory containing installed pixmaps. */
void add_pixmap_directory (const gchar *directory);
void add_pixmap_directory(const gchar *directory);
/*
@ -56,14 +56,13 @@ void add_pixmap_directory (const gchar *directory);
*/
/* This is used to create the pixmaps used in the interface. */
GtkWidget* create_pixmap (GtkWidget *widget,
const gchar *filename);
GtkWidget *create_pixmap(GtkWidget *widget,
const gchar *filename);
/* This is used to create the pixbufs used in the interface. */
GdkPixbuf* create_pixbuf (const gchar *filename);
GdkPixbuf *create_pixbuf(const gchar *filename);
/* This is used to set ATK action descriptions. */
void glade_set_atk_action_description (AtkAction *action,
const gchar *action_name,
const gchar *description);
void glade_set_atk_action_description(AtkAction *action,
const gchar *action_name,
const gchar *description);

View File

@ -4,48 +4,48 @@
#include "../CDVDiso.h"
#define GetKeyV(name, var, s, t) \
size = s; type = t; \
RegQueryValueEx(myKey, name, 0, &type, (LPBYTE) var, &size);
size = s; \
type = t; \
RegQueryValueEx(myKey, name, 0, &type, (LPBYTE)var, &size);
#define GetKeyVdw(name, var) \
GetKeyV(name, var, 4, REG_DWORD);
GetKeyV(name, var, 4, REG_DWORD);
#define SetKeyV(name, var, s, t) \
RegSetValueEx(myKey, name, 0, t, (LPBYTE) var, s);
RegSetValueEx(myKey, name, 0, t, (LPBYTE)var, s);
#define SetKeyVdw(name, var) \
SetKeyV(name, var, 4, REG_DWORD);
SetKeyV(name, var, 4, REG_DWORD);
void SaveConf()
{
HKEY myKey;
DWORD myDisp;
HKEY myKey;
DWORD myDisp;
RegCreateKeyEx(HKEY_CURRENT_USER, "Software\\PS2Eplugin\\CDVD\\CDVDiso", 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &myKey, &myDisp);
RegCreateKeyEx(HKEY_CURRENT_USER, "Software\\PS2Eplugin\\CDVD\\CDVDiso", 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &myKey, &myDisp);
SetKeyV("IsoFile", IsoFile, sizeof(IsoFile), REG_BINARY);
SetKeyV("CurrentWorkingFolder", IsoCWD, sizeof(IsoCWD), REG_BINARY);
SetKeyVdw("BlockDump", &BlockDump);
SetKeyV("IsoFile", IsoFile, sizeof(IsoFile), REG_BINARY);
SetKeyV("CurrentWorkingFolder", IsoCWD, sizeof(IsoCWD), REG_BINARY);
SetKeyVdw("BlockDump", &BlockDump);
RegCloseKey(myKey);
RegCloseKey(myKey);
}
void LoadConf()
{
HKEY myKey;
DWORD type, size;
HKEY myKey;
DWORD type, size;
memset(IsoFile, 0, sizeof(IsoFile));
memset(IsoFile, 0, sizeof(IsoFile));
if (RegOpenKeyEx(HKEY_CURRENT_USER, "Software\\PS2Eplugin\\CDVD\\CDVDiso", 0, KEY_ALL_ACCESS, &myKey) != ERROR_SUCCESS)
{
SaveConf();
return;
}
if (RegOpenKeyEx(HKEY_CURRENT_USER, "Software\\PS2Eplugin\\CDVD\\CDVDiso", 0, KEY_ALL_ACCESS, &myKey) != ERROR_SUCCESS) {
SaveConf();
return;
}
GetKeyV("IsoFile", IsoFile, sizeof(IsoFile), REG_BINARY);
GetKeyV("CurrentWorkingFolder", IsoCWD, sizeof(IsoCWD), REG_BINARY);
GetKeyVdw("BlockDump", &BlockDump);
GetKeyV("IsoFile", IsoFile, sizeof(IsoFile), REG_BINARY);
GetKeyV("CurrentWorkingFolder", IsoCWD, sizeof(IsoCWD), REG_BINARY);
GetKeyVdw("BlockDump", &BlockDump);
RegCloseKey(myKey);
RegCloseKey(myKey);
}

View File

@ -1,3 +1,2 @@
void SaveConf();
void LoadConf();

View File

@ -27,372 +27,348 @@ int stop;
void SysMessage(char *fmt, ...)
{
va_list list;
char tmp[512];
va_list list;
char tmp[512];
va_start(list, fmt);
vsprintf(tmp, fmt, list);
va_end(list);
MessageBox(GetActiveWindow(), tmp, "CDVDiso Msg", 0);
va_start(list, fmt);
vsprintf(tmp, fmt, list);
va_end(list);
MessageBox(GetActiveWindow(), tmp, "CDVDiso Msg", 0);
}
int _GetFile(char *out)
{
OPENFILENAME ofn;
char szFileName[MAXFILENAME];
char szFileTitle[MAXFILENAME];
OPENFILENAME ofn;
char szFileName[MAXFILENAME];
char szFileTitle[MAXFILENAME];
memset(&szFileName, 0, sizeof(szFileName));
memset(&szFileTitle, 0, sizeof(szFileTitle));
memset(&szFileName, 0, sizeof(szFileName));
memset(&szFileTitle, 0, sizeof(szFileTitle));
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = GetActiveWindow();
ofn.lpstrFilter =
"Supported Formats\0*.bin;*.iso;*.img;*.nrg;*.mdf;*.Z;*.Z2;*.BZ2;*.dump\0"
"Cd Iso Format (*.bin;*.iso;*.img;*.nrg;*.mdf)\0"
"*.bin;*.iso;*.img;*.nrg;*.mdf\0"
"Compressed Z Iso Format (*.Z;*.Z2)\0"
"*.Z;*.Z2\0Compressed BZ Iso Format (*.BZ2)\0"
"*.BZ2\0Block Dumps (*.dump)\0*.dump\0All Files\0*.*\0";
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = GetActiveWindow();
ofn.lpstrFilter =
"Supported Formats\0*.bin;*.iso;*.img;*.nrg;*.mdf;*.Z;*.Z2;*.BZ2;*.dump\0"
"Cd Iso Format (*.bin;*.iso;*.img;*.nrg;*.mdf)\0"
"*.bin;*.iso;*.img;*.nrg;*.mdf\0"
"Compressed Z Iso Format (*.Z;*.Z2)\0"
"*.Z;*.Z2\0Compressed BZ Iso Format (*.BZ2)\0"
"*.BZ2\0Block Dumps (*.dump)\0*.dump\0All Files\0*.*\0";
ofn.lpstrCustomFilter = NULL;
ofn.nMaxCustFilter = 0;
ofn.nFilterIndex = 1;
ofn.lpstrFile = szFileName;
ofn.nMaxFile = MAXFILENAME;
ofn.lpstrInitialDir = (IsoCWD[0] == 0) ? NULL : IsoCWD;
ofn.lpstrFileTitle = szFileTitle;
ofn.nMaxFileTitle = MAXFILENAME;
ofn.lpstrTitle = NULL;
ofn.lpstrDefExt = NULL;
ofn.Flags = OFN_HIDEREADONLY;
ofn.lpstrCustomFilter = NULL;
ofn.nMaxCustFilter = 0;
ofn.nFilterIndex = 1;
ofn.lpstrFile = szFileName;
ofn.nMaxFile = MAXFILENAME;
ofn.lpstrInitialDir = (IsoCWD[0] == 0) ? NULL : IsoCWD;
ofn.lpstrFileTitle = szFileTitle;
ofn.nMaxFileTitle = MAXFILENAME;
ofn.lpstrTitle = NULL;
ofn.lpstrDefExt = NULL;
ofn.Flags = OFN_HIDEREADONLY;
if (GetOpenFileName((LPOPENFILENAME)&ofn))
{
strcpy(out, szFileName);
return 1;
}
if (GetOpenFileName((LPOPENFILENAME)&ofn)) {
strcpy(out, szFileName);
return 1;
}
return 0;
return 0;
}
int _OpenFile(int saveConf)
{
int retval = 0;
int retval = 0;
// for saving the pcsx2 current working directory;
char* cwd_pcsx2 = _getcwd(NULL, MAXFILENAME);
// for saving the pcsx2 current working directory;
char *cwd_pcsx2 = _getcwd(NULL, MAXFILENAME);
if (IsoCWD[0] != 0)
_chdir(IsoCWD);
if (IsoCWD[0] != 0)
_chdir(IsoCWD);
if (_GetFile(IsoFile) == 1)
{
// Save the user's new cwd:
if (_getcwd(IsoCWD, MAXFILENAME) == NULL)
IsoCWD[0] = 0;
if (_GetFile(IsoFile) == 1) {
// Save the user's new cwd:
if (_getcwd(IsoCWD, MAXFILENAME) == NULL)
IsoCWD[0] = 0;
if (saveConf)
SaveConf();
if (saveConf)
SaveConf();
retval = 1;
}
retval = 1;
}
// Restore Pcsx2's path.
if (cwd_pcsx2 != NULL)
{
_chdir(cwd_pcsx2);
free(cwd_pcsx2);
cwd_pcsx2 = NULL;
}
return retval;
// Restore Pcsx2's path.
if (cwd_pcsx2 != NULL) {
_chdir(cwd_pcsx2);
free(cwd_pcsx2);
cwd_pcsx2 = NULL;
}
return retval;
}
void CfgOpenFile()
{
_OpenFile(TRUE);
_OpenFile(TRUE);
}
void UpdZmode()
{
if (ComboBox_GetCurSel(hMethod) == 0)
{
Zmode = 1;
}
else
{
Zmode = 2;
}
if (ComboBox_GetCurSel(hMethod) == 0) {
Zmode = 1;
} else {
Zmode = 2;
}
}
void SysUpdate()
{
MSG msg;
MSG msg;
while (PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
while (PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
void OnCompress()
{
u32 lsn;
u8 cdbuff[10*2352];
char Zfile[256];
int ret;
isoFile *src;
isoFile *dst;
u32 lsn;
u8 cdbuff[10 * 2352];
char Zfile[256];
int ret;
isoFile *src;
isoFile *dst;
Edit_GetText(hIsoFile, IsoFile, 256);
UpdZmode();
Edit_GetText(hIsoFile, IsoFile, 256);
UpdZmode();
if (Zmode == 1)
{
sprintf(Zfile, "%s.Z2", IsoFile);
}
else
{
sprintf(Zfile, "%s.BZ2", IsoFile);
}
if (Zmode == 1) {
sprintf(Zfile, "%s.Z2", IsoFile);
} else {
sprintf(Zfile, "%s.BZ2", IsoFile);
}
src = isoOpen(IsoFile);
if (src == NULL) return;
if (Zmode == 1)
{
dst = isoCreate(Zfile, ISOFLAGS_Z2);
}
else
{
dst = isoCreate(Zfile, ISOFLAGS_BZ2);
}
if (dst == NULL) return;
src = isoOpen(IsoFile);
if (src == NULL)
return;
if (Zmode == 1) {
dst = isoCreate(Zfile, ISOFLAGS_Z2);
} else {
dst = isoCreate(Zfile, ISOFLAGS_BZ2);
}
if (dst == NULL)
return;
isoSetFormat(dst, src->blockofs, src->blocksize, src->blocks);
Button_Enable(GetDlgItem(hDlg, IDC_COMPRESSISO), FALSE);
Button_Enable(GetDlgItem(hDlg, IDC_DECOMPRESSISO), FALSE);
stop = 0;
isoSetFormat(dst, src->blockofs, src->blocksize, src->blocks);
Button_Enable(GetDlgItem(hDlg, IDC_COMPRESSISO), FALSE);
Button_Enable(GetDlgItem(hDlg, IDC_DECOMPRESSISO), FALSE);
stop = 0;
for (lsn = 0; lsn < src->blocks; lsn++)
{
//printf("block %d ", lsn);
//putchar(13);
//fflush(stdout);
ret = isoReadBlock(src, cdbuff, lsn);
if (ret == -1) break;
ret = isoWriteBlock(dst, cdbuff, lsn);
if (ret == -1) break;
for (lsn = 0; lsn < src->blocks; lsn++) {
//printf("block %d ", lsn);
//putchar(13);
//fflush(stdout);
ret = isoReadBlock(src, cdbuff, lsn);
if (ret == -1)
break;
ret = isoWriteBlock(dst, cdbuff, lsn);
if (ret == -1)
break;
SendMessage(hProgress, PBM_SETPOS, (lsn * 100) / src->blocks, 0);
SysUpdate();
if (stop) break;
}
isoClose(src);
isoClose(dst);
SendMessage(hProgress, PBM_SETPOS, (lsn * 100) / src->blocks, 0);
SysUpdate();
if (stop)
break;
}
isoClose(src);
isoClose(dst);
if (!stop) Edit_SetText(hIsoFile, Zfile);
if (!stop)
Edit_SetText(hIsoFile, Zfile);
Button_Enable(GetDlgItem(hDlg, IDC_COMPRESSISO), TRUE);
Button_Enable(GetDlgItem(hDlg, IDC_DECOMPRESSISO), TRUE);
Button_Enable(GetDlgItem(hDlg, IDC_COMPRESSISO), TRUE);
Button_Enable(GetDlgItem(hDlg, IDC_DECOMPRESSISO), TRUE);
if (!stop)
{
if (ret == -1)
{
SysMessage("Error compressing iso image");
}
else
{
SysMessage("Iso image compressed OK");
}
}
if (!stop) {
if (ret == -1) {
SysMessage("Error compressing iso image");
} else {
SysMessage("Iso image compressed OK");
}
}
}
void OnDecompress()
{
char file[256];
u8 cdbuff[10*2352];
u32 lsn;
isoFile *src;
isoFile *dst;
int ret;
char file[256];
u8 cdbuff[10 * 2352];
u32 lsn;
isoFile *src;
isoFile *dst;
int ret;
Edit_GetText(hIsoFile, IsoFile, 256);
Edit_GetText(hIsoFile, IsoFile, 256);
src = isoOpen(IsoFile);
if (src == NULL) return;
src = isoOpen(IsoFile);
if (src == NULL)
return;
strcpy(file, IsoFile);
if (src->flags & ISOFLAGS_Z)
{
file[strlen(file) - 2] = 0;
}
else
if (src->flags & ISOFLAGS_Z2)
{
file[strlen(file) - 3] = 0;
}
else
if (src->flags & ISOFLAGS_BZ2)
{
file[strlen(file) - 3] = 0;
}
else
{
SysMessage("%s is not a compressed image", IsoFile);
return;
}
strcpy(file, IsoFile);
if (src->flags & ISOFLAGS_Z) {
file[strlen(file) - 2] = 0;
} else if (src->flags & ISOFLAGS_Z2) {
file[strlen(file) - 3] = 0;
} else if (src->flags & ISOFLAGS_BZ2) {
file[strlen(file) - 3] = 0;
} else {
SysMessage("%s is not a compressed image", IsoFile);
return;
}
dst = isoCreate(file, 0);
if (dst == NULL) return;
dst = isoCreate(file, 0);
if (dst == NULL)
return;
isoSetFormat(dst, src->blockofs, src->blocksize, src->blocks);
Button_Enable(GetDlgItem(hDlg, IDC_COMPRESSISO), FALSE);
Button_Enable(GetDlgItem(hDlg, IDC_DECOMPRESSISO), FALSE);
stop = 0;
isoSetFormat(dst, src->blockofs, src->blocksize, src->blocks);
Button_Enable(GetDlgItem(hDlg, IDC_COMPRESSISO), FALSE);
Button_Enable(GetDlgItem(hDlg, IDC_DECOMPRESSISO), FALSE);
stop = 0;
for (lsn = 0; lsn < src->blocks; lsn++)
{
printf("block %d ", lsn);
putchar(13);
fflush(stdout);
ret = isoReadBlock(src, cdbuff, lsn);
if (ret == -1) break;
ret = isoWriteBlock(dst, cdbuff, lsn);
if (ret == -1) break;
for (lsn = 0; lsn < src->blocks; lsn++) {
printf("block %d ", lsn);
putchar(13);
fflush(stdout);
ret = isoReadBlock(src, cdbuff, lsn);
if (ret == -1)
break;
ret = isoWriteBlock(dst, cdbuff, lsn);
if (ret == -1)
break;
SendMessage(hProgress, PBM_SETPOS, (lsn * 100) / src->blocks, 0);
SysUpdate();
if (stop) break;
}
if (!stop) Edit_SetText(hIsoFile, file);
SendMessage(hProgress, PBM_SETPOS, (lsn * 100) / src->blocks, 0);
SysUpdate();
if (stop)
break;
}
if (!stop)
Edit_SetText(hIsoFile, file);
isoClose(src);
isoClose(dst);
isoClose(src);
isoClose(dst);
Button_Enable(GetDlgItem(hDlg, IDC_COMPRESSISO), TRUE);
Button_Enable(GetDlgItem(hDlg, IDC_DECOMPRESSISO), TRUE);
Button_Enable(GetDlgItem(hDlg, IDC_COMPRESSISO), TRUE);
Button_Enable(GetDlgItem(hDlg, IDC_DECOMPRESSISO), TRUE);
if (!stop)
{
if (ret == -1)
{
SysMessage("Error decompressing iso image");
}
else
{
SysMessage("Iso image decompressed OK");
}
}
if (!stop) {
if (ret == -1) {
SysMessage("Error decompressing iso image");
} else {
SysMessage("Iso image decompressed OK");
}
}
}
BOOL CALLBACK ConfigureDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
int i;
int i;
switch (uMsg)
{
case WM_INITDIALOG:
hDlg = hW;
LoadConf();
switch (uMsg) {
case WM_INITDIALOG:
hDlg = hW;
LoadConf();
hProgress = GetDlgItem(hW, IDC_PROGRESS);
hIsoFile = GetDlgItem(hW, IDC_ISOFILE);
hMethod = GetDlgItem(hW, IDC_METHOD);
hBlockDump = GetDlgItem(hW, IDC_BLOCKDUMP);
hProgress = GetDlgItem(hW, IDC_PROGRESS);
hIsoFile = GetDlgItem(hW, IDC_ISOFILE);
hMethod = GetDlgItem(hW, IDC_METHOD);
hBlockDump = GetDlgItem(hW, IDC_BLOCKDUMP);
for (i = 0; methods[i] != NULL; i++)
{
ComboBox_AddString(hMethod, methods[i]);
}
for (i = 0; methods[i] != NULL; i++) {
ComboBox_AddString(hMethod, methods[i]);
}
Edit_SetText(hIsoFile, IsoFile);
ComboBox_SetCurSel(hMethod, 0);
/* if (strstr(IsoFile, ".Z") != NULL)
Edit_SetText(hIsoFile, IsoFile);
ComboBox_SetCurSel(hMethod, 0);
/* if (strstr(IsoFile, ".Z") != NULL)
ComboBox_SetCurSel(hMethod, 1);
else ComboBox_SetCurSel(hMethod, 0);*/
Button_SetCheck(hBlockDump, BlockDump);
Button_SetCheck(hBlockDump, BlockDump);
return TRUE;
return TRUE;
case WM_COMMAND:
switch (LOWORD(wParam))
{
case IDC_SELECTISO:
if (_OpenFile(FALSE) == 1)
Edit_SetText(hIsoFile, IsoFile);
return TRUE;
case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDC_SELECTISO:
if (_OpenFile(FALSE) == 1)
Edit_SetText(hIsoFile, IsoFile);
return TRUE;
case IDC_COMPRESSISO:
OnCompress();
return TRUE;
case IDC_COMPRESSISO:
OnCompress();
return TRUE;
case IDC_DECOMPRESSISO:
OnDecompress();
return TRUE;
case IDC_DECOMPRESSISO:
OnDecompress();
return TRUE;
case IDC_STOP:
stop = 1;
return TRUE;
case IDC_STOP:
stop = 1;
return TRUE;
case IDCANCEL:
EndDialog(hW, TRUE);
return TRUE;
case IDCANCEL:
EndDialog(hW, TRUE);
return TRUE;
case IDOK:
Edit_GetText(hIsoFile, IsoFile, 256);
BlockDump = Button_GetCheck(hBlockDump);
case IDOK:
Edit_GetText(hIsoFile, IsoFile, 256);
BlockDump = Button_GetCheck(hBlockDump);
SaveConf();
EndDialog(hW, FALSE);
return TRUE;
}
}
return FALSE;
SaveConf();
EndDialog(hW, FALSE);
return TRUE;
}
}
return FALSE;
}
EXPORT_C_(void) CDVDconfigure()
EXPORT_C_(void)
CDVDconfigure()
{
DialogBox(hInst,
MAKEINTRESOURCE(IDD_CONFIG),
GetActiveWindow(),
(DLGPROC)ConfigureDlgProc);
DialogBox(hInst,
MAKEINTRESOURCE(IDD_CONFIG),
GetActiveWindow(),
(DLGPROC)ConfigureDlgProc);
}
BOOL CALLBACK AboutDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg)
{
case WM_INITDIALOG:
return TRUE;
switch (uMsg) {
case WM_INITDIALOG:
return TRUE;
case WM_COMMAND:
switch (LOWORD(wParam))
{
case IDOK:
EndDialog(hW, TRUE);
return FALSE;
}
}
return FALSE;
case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDOK:
EndDialog(hW, TRUE);
return FALSE;
}
}
return FALSE;
}
EXPORT_C_(void) CDVDabout()
EXPORT_C_(void)
CDVDabout()
{
DialogBox(hInst,
MAKEINTRESOURCE(IDD_ABOUT),
GetActiveWindow(),
(DLGPROC)AboutDlgProc);
DialogBox(hInst,
MAKEINTRESOURCE(IDD_ABOUT),
GetActiveWindow(),
(DLGPROC)AboutDlgProc);
}
BOOL APIENTRY DllMain(HANDLE hModule, // DLL INIT
DWORD dwReason,
BOOL APIENTRY DllMain(HANDLE hModule, // DLL INIT
DWORD dwReason,
LPVOID lpReserved)
{
hInst = (HINSTANCE)hModule;
return TRUE; // very quick :)
hInst = (HINSTANCE)hModule;
return TRUE; // very quick :)
}

File diff suppressed because it is too large Load Diff

View File

@ -2,59 +2,59 @@
#define __LIBISO_H__
#ifdef _MSC_VER
#pragma warning(disable:4018)
#pragma warning(disable : 4018)
#endif
#define ISOTYPE_ILLEGAL 0
#define ISOTYPE_CD 1
#define ISOTYPE_DVD 2
#define ISOTYPE_AUDIO 3
#define ISOTYPE_ILLEGAL 0
#define ISOTYPE_CD 1
#define ISOTYPE_DVD 2
#define ISOTYPE_AUDIO 3
#define ISOFLAGS_Z 0x0001
#define ISOFLAGS_Z2 0x0002
#define ISOFLAGS_BLOCKDUMP 0x0004
#define ISOFLAGS_MULTI 0x0008
#define ISOFLAGS_BZ2 0x0010
#define ISOFLAGS_Z 0x0001
#define ISOFLAGS_Z2 0x0002
#define ISOFLAGS_BLOCKDUMP 0x0004
#define ISOFLAGS_MULTI 0x0008
#define ISOFLAGS_BZ2 0x0010
#define CD_FRAMESIZE_RAW 2352
#define DATA_SIZE (CD_FRAMESIZE_RAW-12)
#define CD_FRAMESIZE_RAW 2352
#define DATA_SIZE (CD_FRAMESIZE_RAW - 12)
#define itob(i) ((i)/10*16 + (i)%10) /* u_char to BCD */
#define btoi(b) ((b)/16*10 + (b)%16) /* BCD to u_char */
#define itob(i) ((i) / 10 * 16 + (i) % 10) /* u_char to BCD */
#define btoi(b) ((b) / 16 * 10 + (b) % 16) /* BCD to u_char */
typedef struct
{
u32 slsn;
u32 elsn;
void *handle;
u32 slsn;
u32 elsn;
void *handle;
} _multih;
typedef struct
{
char filename[256];
u32 type;
u32 flags;
u32 offset;
u32 blockofs;
u32 blocksize;
u32 blocks;
void *handle;
void *htable;
char *Ztable;
u32 *dtable;
int dtablesize;
_multih multih[8];
int buflsn;
u8 *buffer;
char filename[256];
u32 type;
u32 flags;
u32 offset;
u32 blockofs;
u32 blocksize;
u32 blocks;
void *handle;
void *htable;
char *Ztable;
u32 *dtable;
int dtablesize;
_multih multih[8];
int buflsn;
u8 *buffer;
} isoFile;
isoFile *isoOpen(const char *filename);
isoFile *isoCreate(const char *filename, int mode);
int isoSetFormat(isoFile *iso, int blockofs, int blocksize, int blocks);
int isoDetect(isoFile *iso);
int isoReadBlock(isoFile *iso, u8 *dst, int lsn);
int isoWriteBlock(isoFile *iso, u8 *src, int lsn);
int isoSetFormat(isoFile *iso, int blockofs, int blocksize, int blocks);
int isoDetect(isoFile *iso);
int isoReadBlock(isoFile *iso, u8 *dst, int lsn);
int isoWriteBlock(isoFile *iso, u8 *src, int lsn);
void isoClose(isoFile *iso);
void *_openfile(const char *filename, int flags);

View File

@ -27,127 +27,121 @@
void Compress(char *filename, int mode)
{
struct stat buf;
u32 lsn;
u8 cdbuff[1024*16];
char Zfile[256];
int ret = 0;
isoFile *src;
isoFile *dst;
struct stat buf;
u32 lsn;
u8 cdbuff[1024 * 16];
char Zfile[256];
int ret = 0;
isoFile *src;
isoFile *dst;
if (mode == 1)
{
sprintf(Zfile, "%s.Z2", filename);
}
else
{
sprintf(Zfile, "%s.BZ2", filename);
}
if (mode == 1) {
sprintf(Zfile, "%s.Z2", filename);
} else {
sprintf(Zfile, "%s.BZ2", filename);
}
if (stat(Zfile, &buf) != -1)
{
printf("'%s' already exists\n", Zfile);
return;
/* sprintf(str, "'%s' already exists, overwrite?", Zfile);
if (stat(Zfile, &buf) != -1) {
printf("'%s' already exists\n", Zfile);
return;
/* sprintf(str, "'%s' already exists, overwrite?", Zfile);
if (MessageBox(hDlg, str, "Question", MB_YESNO) != IDYES) {
return;
}*/
}
}
printf("src %s; dst %s\n", filename, Zfile);
src = isoOpen(filename);
if (src == NULL) return;
printf("src %s; dst %s\n", filename, Zfile);
src = isoOpen(filename);
if (src == NULL)
return;
if (mode == 1)
{
dst = isoCreate(Zfile, ISOFLAGS_Z2);
}
else
{
dst = isoCreate(Zfile, ISOFLAGS_BZ2);
}
isoSetFormat(dst, src->blockofs, src->blocksize, src->blocks);
if (dst == NULL) return;
if (mode == 1) {
dst = isoCreate(Zfile, ISOFLAGS_Z2);
} else {
dst = isoCreate(Zfile, ISOFLAGS_BZ2);
}
isoSetFormat(dst, src->blockofs, src->blocksize, src->blocks);
if (dst == NULL)
return;
for (lsn = 0; lsn < src->blocks; lsn++)
{
printf("block %d ", lsn);
putchar(13);
fflush(stdout);
ret = isoReadBlock(src, cdbuff, lsn);
if (ret == -1) break;
ret = isoWriteBlock(dst, cdbuff, lsn);
if (ret == -1) break;
}
isoClose(src);
isoClose(dst);
for (lsn = 0; lsn < src->blocks; lsn++) {
printf("block %d ", lsn);
putchar(13);
fflush(stdout);
ret = isoReadBlock(src, cdbuff, lsn);
if (ret == -1)
break;
ret = isoWriteBlock(dst, cdbuff, lsn);
if (ret == -1)
break;
}
isoClose(src);
isoClose(dst);
if (ret == -1)
{
printf("Error compressing iso image\n");
}
else
{
printf("Iso image compressed OK\n");
}
if (ret == -1) {
printf("Error compressing iso image\n");
} else {
printf("Iso image compressed OK\n");
}
}
void Decompress(char *filename)
{
struct stat buf;
char file[256];
u8 cdbuff[10*2352];
u32 lsn;
isoFile *src;
isoFile *dst;
int ret = 0;
struct stat buf;
char file[256];
u8 cdbuff[10 * 2352];
u32 lsn;
isoFile *src;
isoFile *dst;
int ret = 0;
src = isoOpen(filename);
if (src == NULL) return;
src = isoOpen(filename);
if (src == NULL)
return;
strcpy(file, filename);
if (src->flags & ISOFLAGS_Z)
file[strlen(file) - 2] = 0;
else if (src->flags & ISOFLAGS_Z2)
file[strlen(file) - 3] = 0;
else if (src->flags & ISOFLAGS_BZ2)
file[strlen(file) - 3] = 0;
else
{
printf("%s is not a compressed image\n", filename);
return;
}
strcpy(file, filename);
if (src->flags & ISOFLAGS_Z)
file[strlen(file) - 2] = 0;
else if (src->flags & ISOFLAGS_Z2)
file[strlen(file) - 3] = 0;
else if (src->flags & ISOFLAGS_BZ2)
file[strlen(file) - 3] = 0;
else {
printf("%s is not a compressed image\n", filename);
return;
}
if (stat(file, &buf) != -1)
{
char str[256];
sprintf(str, "'%s' already exists", file);
isoClose(src);
return;
}
if (stat(file, &buf) != -1) {
char str[256];
sprintf(str, "'%s' already exists", file);
isoClose(src);
return;
}
dst = isoCreate(file, 0);
if (dst == NULL) return;
isoSetFormat(dst, src->blockofs, src->blocksize, src->blocks);
dst = isoCreate(file, 0);
if (dst == NULL)
return;
isoSetFormat(dst, src->blockofs, src->blocksize, src->blocks);
for (lsn = 0; lsn < src->blocks; lsn++)
{
printf("block %d ", lsn);
putchar(13);
fflush(stdout);
ret = isoReadBlock(src, cdbuff, lsn);
if (ret == -1) break;
ret = isoWriteBlock(dst, cdbuff, lsn);
if (ret == -1) break;
}
for (lsn = 0; lsn < src->blocks; lsn++) {
printf("block %d ", lsn);
putchar(13);
fflush(stdout);
ret = isoReadBlock(src, cdbuff, lsn);
if (ret == -1)
break;
ret = isoWriteBlock(dst, cdbuff, lsn);
if (ret == -1)
break;
}
isoClose(src);
isoClose(dst);
isoClose(src);
isoClose(dst);
if (ret == -1)
printf("Error decompressing iso image\n");
else
printf("Iso image decompressed OK\n");
if (ret == -1)
printf("Error decompressing iso image\n");
else
printf("Iso image decompressed OK\n");
}