mirror of https://github.com/PCSX2/pcsx2.git
Fixed the crashing with blockdumps. It was the "iso file format" lib I took from cdvdiso.
So I axed the compressed iso (Z/BZ2) format reading, as part of fixing it. Anyone needing it can still use CDVDiso. git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1501 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
parent
6924e9cc44
commit
792b1031e6
|
@ -34,7 +34,7 @@ static int diskTypeCached=-1;
|
|||
static int psize;
|
||||
static int plsn=0;
|
||||
|
||||
static isoFile *blockDumpFile;
|
||||
static isoFile *blockDumpFile;
|
||||
|
||||
/////////////////////////////////////////////////
|
||||
//
|
||||
|
@ -170,11 +170,11 @@ int FindDiskType(int mType)
|
|||
|
||||
void DetectDiskType()
|
||||
{
|
||||
if (DoCDVDgetTrayStatus() == CDVD_TRAY_OPEN)
|
||||
{
|
||||
diskTypeCached = CDVD_TYPE_NODISC;
|
||||
return;
|
||||
}
|
||||
if (DoCDVDgetTrayStatus() == CDVD_TRAY_OPEN)
|
||||
{
|
||||
diskTypeCached = CDVD_TYPE_NODISC;
|
||||
return;
|
||||
}
|
||||
|
||||
int baseMediaType = DoCDVDgetDiskType();
|
||||
int mType = -1;
|
||||
|
@ -234,50 +234,52 @@ s32 DoCDVDopen(const char* pTitleFilename)
|
|||
else
|
||||
ret = CDVDopen(pTitleFilename);
|
||||
|
||||
if (Config.Blockdump)
|
||||
{
|
||||
char fname_only[MAX_PATH];
|
||||
|
||||
if(loadFromISO)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
char fname[MAX_PATH], ext[MAX_PATH];
|
||||
_splitpath(isoFileName, NULL, NULL, fname, ext);
|
||||
_makepath(fname_only, NULL, NULL, fname, NULL);
|
||||
#else
|
||||
char* p, *plast;
|
||||
|
||||
plast = p = strchr(isoFileName, '/');
|
||||
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, isoFileName);
|
||||
|
||||
plast = p = strchr(fname_only, '.');
|
||||
|
||||
while (p != NULL)
|
||||
{
|
||||
plast = p;
|
||||
p = strchr(p + 1, '.');
|
||||
}
|
||||
|
||||
if (plast != NULL) *plast = 0;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
strcpy(fname_only, "Untitled");
|
||||
}
|
||||
|
||||
#if defined(_WIN32) && defined(ENABLE_TIMESTAMPS)
|
||||
int cdtype = DoCDVDdetectDiskType();
|
||||
|
||||
if((Config.Blockdump)&&(cdtype != CDVD_TYPE_NODISC))
|
||||
{
|
||||
char fname_only[MAX_PATH];
|
||||
|
||||
if(loadFromISO)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
char fname[MAX_PATH], ext[MAX_PATH];
|
||||
_splitpath(isoFileName, NULL, NULL, fname, ext);
|
||||
_makepath(fname_only, NULL, NULL, fname, NULL);
|
||||
#else
|
||||
char* p, *plast;
|
||||
|
||||
plast = p = strchr(isoFileName, '/');
|
||||
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, isoFileName);
|
||||
|
||||
plast = p = strchr(fname_only, '.');
|
||||
|
||||
while (p != NULL)
|
||||
{
|
||||
plast = p;
|
||||
p = strchr(p + 1, '.');
|
||||
}
|
||||
|
||||
if (plast != NULL) *plast = 0;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
strcpy(fname_only, "Untitled");
|
||||
}
|
||||
|
||||
#if defined(_WIN32) && defined(ENABLE_TIMESTAMPS)
|
||||
SYSTEMTIME time;
|
||||
GetLocalTime(&time);
|
||||
|
||||
|
@ -286,17 +288,39 @@ s32 DoCDVDopen(const char* pTitleFilename)
|
|||
" (%04d-%02d-%02d %02d-%02d-%02d).dump",
|
||||
time.wYear, time.wMonth, time.wDay,
|
||||
time.wHour, time.wMinute, time.wSecond);
|
||||
#else
|
||||
// TODO: implement this
|
||||
strcat(fname_only, ".dump");
|
||||
#endif
|
||||
|
||||
blockDumpFile = isoCreate(fname_only, ISOFLAGS_BLOCKDUMP);
|
||||
if (blockDumpFile) isoSetFormat(blockDumpFile, iso->blockofs, iso->blocksize, iso->blocks);
|
||||
}
|
||||
else
|
||||
{
|
||||
blockDumpFile = NULL;
|
||||
|
||||
// TODO: implement this for linux
|
||||
#else
|
||||
strcat(fname_only, ".dump");
|
||||
#endif
|
||||
cdvdTD td;
|
||||
DoCDVDgetTD(0, &td);
|
||||
|
||||
int blockofs=0;
|
||||
int blocksize=0;
|
||||
int blocks = td.lsn;
|
||||
|
||||
switch(cdtype)
|
||||
{
|
||||
case CDVD_TYPE_PS2DVD:
|
||||
case CDVD_TYPE_DVDV:
|
||||
case CDVD_TYPE_DETCTDVDS:
|
||||
case CDVD_TYPE_DETCTDVDD:
|
||||
blockofs = 24;
|
||||
blocksize = 2048;
|
||||
break;
|
||||
default:
|
||||
blockofs = 0;
|
||||
blocksize= 2352;
|
||||
break;
|
||||
}
|
||||
|
||||
blockDumpFile = isoCreate(fname_only, ISOFLAGS_BLOCKDUMP);
|
||||
if (blockDumpFile) isoSetFormat(blockDumpFile, blockofs, blocksize, blocks);
|
||||
}
|
||||
else
|
||||
{
|
||||
blockDumpFile = NULL;
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
@ -308,8 +332,8 @@ void DoCDVDclose()
|
|||
ISOclose();
|
||||
else
|
||||
CDVDclose();
|
||||
|
||||
if (blockDumpFile != NULL) isoClose(blockDumpFile);
|
||||
|
||||
if (blockDumpFile != NULL) isoClose(blockDumpFile);
|
||||
}
|
||||
|
||||
void DoCDVDshutdown()
|
||||
|
@ -357,10 +381,10 @@ s32 DoCDVDreadSector(u8* buffer, u32 lsn, int mode)
|
|||
|
||||
if(ret==0)
|
||||
{
|
||||
if (blockDumpFile != NULL)
|
||||
{
|
||||
isoWriteBlock(blockDumpFile, buffer, plsn);
|
||||
}
|
||||
if (blockDumpFile != NULL)
|
||||
{
|
||||
isoWriteBlock(blockDumpFile, buffer, plsn);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
@ -412,10 +436,10 @@ s32 DoCDVDgetBuffer(u8* buffer)
|
|||
|
||||
if(ret==0)
|
||||
{
|
||||
if (blockDumpFile != NULL)
|
||||
{
|
||||
isoWriteBlock(blockDumpFile, buffer, plsn);
|
||||
}
|
||||
if (blockDumpFile != NULL)
|
||||
{
|
||||
isoWriteBlock(blockDumpFile, buffer, plsn);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -220,7 +220,7 @@ s32 ISOgetTOC(void* toc)
|
|||
if (layer1start == -1)
|
||||
{
|
||||
printf("CDVD: searching for layer1...");
|
||||
tempbuffer = (u8*)malloc(CD_FRAMESIZE_RAW * 10);
|
||||
tempbuffer = (u8*)malloc(CD_FRAMESIZE_RAW);
|
||||
for (layer1start = (iso->blocks / 2 - 0x10) & ~0xf; layer1start < 0x200010; layer1start += 16)
|
||||
{
|
||||
isoReadBlock(iso, tempbuffer, layer1start);
|
||||
|
@ -341,7 +341,7 @@ s32 ISOreadSector(u8* tempbuffer, u32 lsn, int mode)
|
|||
return 0;
|
||||
}
|
||||
|
||||
isoReadBlock(iso, cdbuffer, lsn);
|
||||
isoReadBlock(iso, cdbuffer + iso->blockofs, lsn);
|
||||
|
||||
pbuffer = cdbuffer;
|
||||
switch (mode)
|
||||
|
@ -378,7 +378,7 @@ s32 ISOreadTrack(u32 lsn, int mode)
|
|||
if(lsn > iso->blocks)
|
||||
return -1;
|
||||
|
||||
isoReadBlock(iso, cdbuffer, lsn);
|
||||
isoReadBlock(iso, cdbuffer + iso->blockofs, lsn);
|
||||
|
||||
pbuffer = cdbuffer;
|
||||
switch (mode)
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include "bzip2\bzlib.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
|
@ -148,7 +147,7 @@ int detect(isoFile *iso)
|
|||
u8 buf[2448];
|
||||
struct cdVolDesc *volDesc;
|
||||
|
||||
if (isoReadBlock(iso, buf, 16) == -1) return -1;
|
||||
if (isoReadBlock(iso, buf + iso->blockofs, 16) == -1) return -1;
|
||||
|
||||
volDesc = (struct cdVolDesc *)(buf + 24);
|
||||
|
||||
|
@ -162,138 +161,6 @@ int detect(isoFile *iso)
|
|||
return 1;
|
||||
}
|
||||
|
||||
int _isoReadZtable(isoFile *iso)
|
||||
{
|
||||
void *handle;
|
||||
char table[256];
|
||||
int size;
|
||||
|
||||
sprintf(table, "%s.table", iso->filename);
|
||||
handle = _openfile(table, O_RDONLY);
|
||||
if (handle == NULL)
|
||||
{
|
||||
printf("Error loading %s\n", table);
|
||||
return -1;
|
||||
}
|
||||
|
||||
_seekfile(handle, 0, SEEK_END);
|
||||
size = _tellfile(handle);
|
||||
iso->Ztable = (char*)malloc(size);
|
||||
|
||||
if (iso->Ztable == NULL)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
_seekfile(handle, 0, SEEK_SET);
|
||||
_readfile(handle, iso->Ztable, size);
|
||||
_closefile(handle);
|
||||
|
||||
iso->blocks = size / 6;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _isoReadZ2table(isoFile *iso)
|
||||
{
|
||||
void *handle;
|
||||
char table[256];
|
||||
u32 *Ztable;
|
||||
int ofs, size, i;
|
||||
|
||||
sprintf(table, "%s.table", iso->filename);
|
||||
handle = _openfile(table, O_RDONLY);
|
||||
|
||||
if (handle == NULL)
|
||||
{
|
||||
printf("Error loading %s\n", table);
|
||||
return -1;
|
||||
}
|
||||
|
||||
_seekfile(handle, 0, SEEK_END);
|
||||
size = _tellfile(handle);
|
||||
Ztable = (u32*)malloc(size);
|
||||
|
||||
if (Ztable == NULL)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
_seekfile(handle, 0, SEEK_SET);
|
||||
_readfile(handle, Ztable, size);
|
||||
_closefile(handle);
|
||||
|
||||
iso->Ztable = (char*)malloc(iso->blocks * 8);
|
||||
|
||||
if (iso->Ztable == NULL)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
ofs = 16;
|
||||
|
||||
for (i = 0; i < iso->blocks; i++)
|
||||
{
|
||||
*(u32*)&iso->Ztable[i*8+0] = ofs;
|
||||
*(u32*)&iso->Ztable[i*8+4] = Ztable[i];
|
||||
ofs += Ztable[i];
|
||||
}
|
||||
|
||||
free(Ztable);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _isoReadBZ2table(isoFile *iso)
|
||||
{
|
||||
void *handle;
|
||||
char table[256];
|
||||
u32 *Ztable;
|
||||
int ofs;
|
||||
int size;
|
||||
int i;
|
||||
|
||||
sprintf(table, "%s.table", iso->filename);
|
||||
handle = _openfile(table, O_RDONLY);
|
||||
if (handle == NULL)
|
||||
{
|
||||
printf("Error loading %s\n", table);
|
||||
return -1;
|
||||
}
|
||||
|
||||
_seekfile(handle, 0, SEEK_END);
|
||||
size = _tellfile(handle);
|
||||
Ztable = (u32*)malloc(size);
|
||||
if (Ztable == NULL) return -1;
|
||||
|
||||
_seekfile(handle, 0, SEEK_SET);
|
||||
_readfile(handle, Ztable, size);
|
||||
_closefile(handle);
|
||||
|
||||
iso->Ztable = (char*)malloc(iso->blocks * 8);
|
||||
if (iso->Ztable == NULL) return -1;
|
||||
|
||||
ofs = 16;
|
||||
|
||||
for (i = 0; i < iso->blocks / 16; i++)
|
||||
{
|
||||
*(u32*)&iso->Ztable[i*8+0] = ofs;
|
||||
*(u32*)&iso->Ztable[i*8+4] = Ztable[i];
|
||||
ofs += Ztable[i];
|
||||
}
|
||||
|
||||
if (iso->blocks & 0xf)
|
||||
{
|
||||
*(u32*)&iso->Ztable[i*8+0] = ofs;
|
||||
*(u32*)&iso->Ztable[i*8+4] = Ztable[i];
|
||||
ofs += Ztable[i];
|
||||
}
|
||||
|
||||
free(Ztable);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _isoReadDtable(isoFile *iso)
|
||||
{
|
||||
int ret;
|
||||
|
@ -321,16 +188,6 @@ int isoDetect(isoFile *iso) // based on florin's CDVDbin detection code :)
|
|||
iso->type = ISOTYPE_ILLEGAL;
|
||||
|
||||
len = strlen(iso->filename);
|
||||
if (len >= 2)
|
||||
{
|
||||
if (!strncmp(iso->filename + (len - 2), ".Z", 2))
|
||||
{
|
||||
iso->flags = ISOFLAGS_Z;
|
||||
iso->blocksize = 2352;
|
||||
_isoReadZtable(iso);
|
||||
return detect(iso) == 1 ? 0 : -1;
|
||||
}
|
||||
}
|
||||
|
||||
_seekfile(iso->handle, 0, SEEK_SET);
|
||||
_readfile(iso->handle, buf, 4);
|
||||
|
@ -344,27 +201,6 @@ int isoDetect(isoFile *iso) // based on florin's CDVDbin detection code :)
|
|||
_isoReadDtable(iso);
|
||||
return detect(iso) == 1 ? 0 : -1;
|
||||
}
|
||||
else if (strncmp(buf, "Z V2", 4) == 0)
|
||||
{
|
||||
iso->flags = ISOFLAGS_Z2;
|
||||
_readfile(iso->handle, &iso->blocksize, 4);
|
||||
_readfile(iso->handle, &iso->blocks, 4);
|
||||
_readfile(iso->handle, &iso->blockofs, 4);
|
||||
_isoReadZ2table(iso);
|
||||
return detect(iso) == 1 ? 0 : -1;
|
||||
}
|
||||
else if (strncmp(buf, "BZV2", 4) == 0)
|
||||
{
|
||||
iso->flags = ISOFLAGS_BZ2;
|
||||
_readfile(iso->handle, &iso->blocksize, 4);
|
||||
_readfile(iso->handle, &iso->blocks, 4);
|
||||
_readfile(iso->handle, &iso->blockofs, 4);
|
||||
iso->buflsn = -1;
|
||||
iso->buffer = (u8*)malloc(iso->blocksize * 16);
|
||||
if (iso->buffer == NULL) return -1;
|
||||
_isoReadBZ2table(iso);
|
||||
return detect(iso) == 1 ? 0 : -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
iso->blocks = 16;
|
||||
|
@ -550,23 +386,6 @@ int isoSetFormat(isoFile *iso, int blockofs, int blocksize, int blocks)
|
|||
printf("blockofs = %d\n", iso->blockofs);
|
||||
printf("blocksize = %d\n", iso->blocksize);
|
||||
printf("blocks = %d\n", iso->blocks);
|
||||
if (iso->flags & ISOFLAGS_Z2)
|
||||
{
|
||||
if (_writefile(iso->handle, "Z V2", 4) < 4) return -1;
|
||||
if (_writefile(iso->handle, &blocksize, 4) < 4) return -1;
|
||||
if (_writefile(iso->handle, &blocks, 4) < 4) return -1;
|
||||
if (_writefile(iso->handle, &blockofs, 4) < 4) return -1;
|
||||
}
|
||||
if (iso->flags & ISOFLAGS_BZ2)
|
||||
{
|
||||
if (_writefile(iso->handle, "BZV2", 4) < 4) return -1;
|
||||
if (_writefile(iso->handle, &blocksize, 4) < 4) return -1;
|
||||
if (_writefile(iso->handle, &blocks, 4) < 4) return -1;
|
||||
if (_writefile(iso->handle, &blockofs, 4) < 4) return -1;
|
||||
iso->buflsn = -1;
|
||||
iso->buffer = (u8*)malloc(iso->blocksize * 16);
|
||||
if (iso->buffer == NULL) return -1;
|
||||
}
|
||||
if (iso->flags & ISOFLAGS_BLOCKDUMP)
|
||||
{
|
||||
if (_writefile(iso->handle, "BDV2", 4) < 4) return -1;
|
||||
|
@ -607,10 +426,9 @@ int _isoReadBlock(isoFile *iso, u8 *dst, int lsn)
|
|||
u64 ofs = (u64)lsn * iso->blocksize + iso->offset;
|
||||
int ret;
|
||||
|
||||
// printf("_isoReadBlock %d, blocksize=%d, blockofs=%d\n", lsn, iso->blocksize, iso->blockofs);
|
||||
memset(dst, 0, iso->blockofs);
|
||||
_seekfile(iso->handle, ofs, SEEK_SET);
|
||||
ret = _readfile(iso->handle, dst + iso->blockofs, iso->blocksize);
|
||||
ret = _readfile(iso->handle, dst, iso->blocksize);
|
||||
if (ret < iso->blocksize)
|
||||
{
|
||||
printf("read error %d\n", ret);
|
||||
|
@ -620,100 +438,6 @@ int _isoReadBlock(isoFile *iso, u8 *dst, int lsn)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int _isoReadBlockZ(isoFile *iso, u8 *dst, int lsn)
|
||||
{
|
||||
u32 pos, p;
|
||||
uLongf size;
|
||||
u8 Zbuf[CD_FRAMESIZE_RAW*2];
|
||||
int ret;
|
||||
|
||||
// printf("_isoReadBlockZ %d, %d\n", lsn, iso->blocksize);
|
||||
pos = *(unsigned long*) & iso->Ztable[lsn * 6];
|
||||
p = *(unsigned short*) & iso->Ztable[lsn * 6 + 4];
|
||||
// printf("%d, %d\n", pos, p);
|
||||
_seekfile(iso->handle, pos, SEEK_SET);
|
||||
ret = _readfile(iso->handle, Zbuf, p);
|
||||
if (ret < p)
|
||||
{
|
||||
printf("error reading block!!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
size = CD_FRAMESIZE_RAW;
|
||||
uncompress(dst, &size, Zbuf, p);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _isoReadBlockZ2(isoFile *iso, u8 *dst, int lsn)
|
||||
{
|
||||
u32 pos, p;
|
||||
uLongf size;
|
||||
u8 Zbuf[16*1024];
|
||||
int ret;
|
||||
|
||||
// printf("_isoReadBlockZ2 %d, %d\n", lsn, iso->blocksize);
|
||||
pos = *(u32*) & iso->Ztable[lsn*8];
|
||||
p = *(u32*) & iso->Ztable[lsn*8+4];
|
||||
// printf("%d, %d\n", pos, p);
|
||||
_seekfile(iso->handle, pos, SEEK_SET);
|
||||
ret = _readfile(iso->handle, Zbuf, p);
|
||||
if (ret < p)
|
||||
{
|
||||
printf("error reading block!!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
size = iso->blocksize;
|
||||
uncompress(dst + iso->blockofs, &size, Zbuf, p);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _isoReadBlockBZ2(isoFile *iso, u8 *dst, int lsn)
|
||||
{
|
||||
u32 pos, p;
|
||||
u32 size;
|
||||
u8 Zbuf[64*1024];
|
||||
int ret;
|
||||
|
||||
if ((lsn / 16) == iso->buflsn)
|
||||
{
|
||||
memset(dst, 0, iso->blockofs);
|
||||
memcpy(dst + iso->blockofs, iso->buffer + (iso->blocksize*(lsn&0xf)), iso->blocksize);
|
||||
return 0;
|
||||
}
|
||||
|
||||
iso->buflsn = lsn / 16;
|
||||
// printf("_isoReadBlockBZ2 %d, %d\n", lsn, iso->blocksize);
|
||||
pos = *(u32*) & iso->Ztable[(lsn/16)*8];
|
||||
p = *(u32*) & iso->Ztable[(lsn/16)*8+4];
|
||||
// printf("%d, %d\n", pos, p);
|
||||
_seekfile(iso->handle, pos, SEEK_SET);
|
||||
ret = _readfile(iso->handle, Zbuf, p);
|
||||
|
||||
if (ret < p)
|
||||
{
|
||||
printf("error reading block!!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
size = iso->blocksize * 64;
|
||||
ret = BZ2_bzBuffToBuffDecompress((s8*)iso->buffer, &size, (s8*)Zbuf, p, 0, 0);
|
||||
|
||||
if (ret != BZ_OK)
|
||||
{
|
||||
printf("_isoReadBlockBZ2 %d, %d\n", lsn, iso->blocksize);
|
||||
printf("%d, %d\n", pos, p);
|
||||
printf("error on BZ2: %d\n", ret);
|
||||
}
|
||||
|
||||
memset(dst, 0, iso->blockofs);
|
||||
memcpy(dst + iso->blockofs, iso->buffer + (iso->blocksize*(lsn&0xf)), iso->blocksize);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _isoReadBlockD(isoFile *iso, u8 *dst, int lsn)
|
||||
{
|
||||
int ret;
|
||||
|
@ -726,7 +450,7 @@ int _isoReadBlockD(isoFile *iso, u8 *dst, int lsn)
|
|||
if (iso->dtable[i] != lsn) continue;
|
||||
|
||||
_seekfile(iso->handle, 16 + i*(iso->blocksize + 4) + 4, SEEK_SET);
|
||||
ret = _readfile(iso->handle, dst + iso->blockofs, iso->blocksize);
|
||||
ret = _readfile(iso->handle, dst, iso->blocksize);
|
||||
if (ret < iso->blocksize) return -1;
|
||||
|
||||
return 0;
|
||||
|
@ -756,7 +480,7 @@ int _isoReadBlockM(isoFile *iso, u8 *dst, int lsn)
|
|||
// printf("_isoReadBlock %d, blocksize=%d, blockofs=%d\n", lsn, iso->blocksize, iso->blockofs);
|
||||
memset(dst, 0, iso->blockofs);
|
||||
_seekfile(iso->multih[i].handle, ofs, SEEK_SET);
|
||||
ret = _readfile(iso->multih[i].handle, dst + iso->blockofs, iso->blocksize);
|
||||
ret = _readfile(iso->multih[i].handle, dst, iso->blocksize);
|
||||
|
||||
if (ret < iso->blocksize)
|
||||
{
|
||||
|
@ -777,16 +501,10 @@ int isoReadBlock(isoFile *iso, u8 *dst, int lsn)
|
|||
return -1;
|
||||
}
|
||||
|
||||
if (iso->flags & ISOFLAGS_Z)
|
||||
ret = _isoReadBlockZ(iso, dst, lsn);
|
||||
else if (iso->flags & ISOFLAGS_Z2)
|
||||
ret = _isoReadBlockZ2(iso, dst, lsn);
|
||||
else if (iso->flags & ISOFLAGS_BLOCKDUMP)
|
||||
if (iso->flags & ISOFLAGS_BLOCKDUMP)
|
||||
ret = _isoReadBlockD(iso, dst, lsn);
|
||||
else if (iso->flags & ISOFLAGS_MULTI)
|
||||
ret = _isoReadBlockM(iso, dst, lsn);
|
||||
else if (iso->flags & ISOFLAGS_BZ2)
|
||||
ret = _isoReadBlockBZ2(iso, dst, lsn);
|
||||
else
|
||||
ret = _isoReadBlock(iso, dst, lsn);
|
||||
|
||||
|
@ -807,68 +525,13 @@ int _isoWriteBlock(isoFile *iso, u8 *src, int lsn)
|
|||
u64 ofs = (u64)lsn * iso->blocksize + iso->offset;
|
||||
int ret;
|
||||
|
||||
// printf("_isoWriteBlock %d (ofs=%d)\n", iso->blocksize, ofs);
|
||||
_seekfile(iso->handle, ofs, SEEK_SET);
|
||||
ret = _writefile(iso->handle, src + iso->blockofs, iso->blocksize);
|
||||
// printf("_isoWriteBlock %d\n", ret);
|
||||
ret = _writefile(iso->handle, src, iso->blocksize);
|
||||
if (ret < iso->blocksize) return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _isoWriteBlockZ(isoFile *iso, u8 *src, int lsn)
|
||||
{
|
||||
u32 pos;
|
||||
uLongf size;
|
||||
u8 Zbuf[CD_FRAMESIZE_RAW];
|
||||
int ret;
|
||||
|
||||
// printf("_isoWriteBlockZ %d\n", iso->blocksize);
|
||||
size = 2352;
|
||||
compress(Zbuf, &size, src, 2352);
|
||||
// printf("_isoWriteBlockZ %d\n", size);
|
||||
|
||||
pos = (u32)_tellfile(iso->handle);
|
||||
ret = _writefile(iso->htable, &pos, 4);
|
||||
if (ret < 4) return -1;
|
||||
ret = _writefile(iso->htable, &size, 2);
|
||||
if (ret < 2) return -1;
|
||||
|
||||
ret = _writefile(iso->handle, Zbuf, size);
|
||||
// printf("_isoWriteBlockZ %d\n", ret);
|
||||
if (ret < size)
|
||||
{
|
||||
printf("error writing block!!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _isoWriteBlockZ2(isoFile *iso, u8 *src, int lsn)
|
||||
{
|
||||
uLongf size;
|
||||
u8 Zbuf[1024*16];
|
||||
int ret;
|
||||
|
||||
// printf("_isoWriteBlockZ %d\n", iso->blocksize);
|
||||
size = 1024 * 16;
|
||||
compress(Zbuf, &size, src + iso->blockofs, iso->blocksize);
|
||||
// printf("_isoWriteBlockZ %d\n", size);
|
||||
|
||||
ret = _writefile(iso->htable, (u8*) & size, 4);
|
||||
if (ret < 4) return -1;
|
||||
ret = _writefile(iso->handle, Zbuf, size);
|
||||
// printf("_isoWriteBlockZ %d\n", ret);
|
||||
if (ret < size)
|
||||
{
|
||||
printf("error writing block!!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _isoWriteBlockD(isoFile *iso, u8 *src, int lsn)
|
||||
{
|
||||
int ret;
|
||||
|
@ -876,69 +539,19 @@ int _isoWriteBlockD(isoFile *iso, u8 *src, int lsn)
|
|||
// printf("_isoWriteBlock %d (ofs=%d)\n", iso->blocksize, ofs);
|
||||
ret = _writefile(iso->handle, &lsn, 4);
|
||||
if (ret < 4) return -1;
|
||||
ret = _writefile(iso->handle, src + iso->blockofs, iso->blocksize);
|
||||
ret = _writefile(iso->handle, src, iso->blocksize);
|
||||
// printf("_isoWriteBlock %d\n", ret);
|
||||
if (ret < iso->blocksize) return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _isoWriteBlockBZ2(isoFile *iso, u8 *src, int lsn)
|
||||
{
|
||||
u32 size;
|
||||
u8 Zbuf[64*1024];
|
||||
int blocks;
|
||||
int ret;
|
||||
|
||||
memcpy(iso->buffer + (iso->blocksize*(lsn&0xf)), src + iso->blockofs, iso->blocksize);
|
||||
|
||||
if (lsn == (iso->blocks - 1))
|
||||
{
|
||||
blocks = (lsn & 0xf) + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
blocks = 16;
|
||||
if ((lsn & 0xf) != 0xf) return 0;
|
||||
}
|
||||
|
||||
// printf("_isoWriteBlockBZ2 %d\n", iso->blocksize);
|
||||
size = 64 * 1024;
|
||||
ret = BZ2_bzBuffToBuffCompress((s8*)Zbuf, (u32*) & size, (s8*)iso->buffer, iso->blocksize * blocks, 9, 0, 30);
|
||||
|
||||
if (ret != BZ_OK)
|
||||
{
|
||||
printf("error on BZ2: %d\n", ret);
|
||||
}
|
||||
|
||||
// printf("_isoWriteBlockBZ2 %d\n", size);
|
||||
|
||||
ret = _writefile(iso->htable, (u8*) & size, 4);
|
||||
if (ret < 4) return -1;
|
||||
ret = _writefile(iso->handle, Zbuf, size);
|
||||
// printf("_isoWriteBlockZ %d\n", ret);
|
||||
|
||||
if (ret < size)
|
||||
{
|
||||
printf("error writing block!!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int isoWriteBlock(isoFile *iso, u8 *src, int lsn)
|
||||
{
|
||||
int ret;
|
||||
|
||||
if (iso->flags & ISOFLAGS_Z)
|
||||
ret = _isoWriteBlockZ(iso, src, lsn);
|
||||
else if (iso->flags & ISOFLAGS_Z2)
|
||||
ret = _isoWriteBlockZ2(iso, src, lsn);
|
||||
else if (iso->flags & ISOFLAGS_BLOCKDUMP)
|
||||
if (iso->flags & ISOFLAGS_BLOCKDUMP)
|
||||
ret = _isoWriteBlockD(iso, src, lsn);
|
||||
else if (iso->flags & ISOFLAGS_BZ2)
|
||||
ret = _isoWriteBlockBZ2(iso, src, lsn);
|
||||
else
|
||||
ret = _isoWriteBlock(iso, src, lsn);
|
||||
|
||||
|
|
|
@ -71,7 +71,7 @@
|
|||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalOptions="/MACHINE:I386"
|
||||
AdditionalDependencies="zlib.lib bzip2.lib"
|
||||
AdditionalDependencies="zlib.lib"
|
||||
OutputFile="$(OutDir)\$(ProjectName)-dbg.exe"
|
||||
/>
|
||||
<Tool
|
||||
|
@ -151,7 +151,7 @@
|
|||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="zlib.lib bzip2.lib"
|
||||
AdditionalDependencies="zlib.lib"
|
||||
OutputFile="$(OutDir)\$(ProjectName)-dev.exe"
|
||||
LinkIncremental="2"
|
||||
/>
|
||||
|
@ -232,7 +232,7 @@
|
|||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="zlib.lib bzip2.lib"
|
||||
AdditionalDependencies="zlib.lib"
|
||||
ProgramDatabaseFile=""$(TargetDir)$(TargetName).pdb""
|
||||
/>
|
||||
<Tool
|
||||
|
|
|
@ -1130,6 +1130,7 @@ void CreateMainWindow()
|
|||
if(Config.Profiler) CheckMenuItem(gApp.hMenu,ID_PROFILER,MF_CHECKED);
|
||||
if(Config.cdvdPrint) CheckMenuItem(gApp.hMenu,ID_CDVDPRINT,MF_CHECKED);
|
||||
if(Config.closeGSonEsc)CheckMenuItem(gApp.hMenu,ID_CLOSEGS,MF_CHECKED);
|
||||
if(Config.Blockdump) CheckMenuItem(gApp.hMenu,ID_BLOCKDUMP,MF_CHECKED);
|
||||
|
||||
hStatusWnd = CreateStatusWindow(WS_CHILD | WS_VISIBLE, "", hWnd, 100);
|
||||
|
||||
|
|
Loading…
Reference in New Issue