forked from flyinghead/flycast
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request flyinghead#1523 from reicast/fh/master-merge
Tons of fixes, much improved naomi support, atomiswave support, imgui UI, arm64 dynarec, improved x64 dynarec, dsp interpreter + arm64 + x64, others
- Loading branch information
Showing
510 changed files
with
323,688 additions
and
18,798 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
/* | ||
Created on: Nov 22, 2018 | ||
Copyright 2018 flyinghead | ||
This file is part of reicast. | ||
reicast is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 2 of the License, or | ||
(at your option) any later version. | ||
reicast is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with reicast. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
#include "7zArchive.h" | ||
#include "deps/lzma/7z.h" | ||
#include "deps/lzma/7zCrc.h" | ||
#include "deps/lzma/Alloc.h" | ||
|
||
#define kInputBufSize ((size_t)1 << 18) | ||
|
||
static bool crc_tables_generated; | ||
|
||
bool SzArchive::Open(const char* path) | ||
{ | ||
SzArEx_Init(&szarchive); | ||
|
||
if (InFile_Open(&archiveStream.file, path)) | ||
return false; | ||
FileInStream_CreateVTable(&archiveStream); | ||
LookToRead2_CreateVTable(&lookStream, false); | ||
lookStream.buf = (Byte *)ISzAlloc_Alloc(&g_Alloc, kInputBufSize); | ||
if (lookStream.buf == NULL) | ||
return false; | ||
lookStream.bufSize = kInputBufSize; | ||
lookStream.realStream = &archiveStream.vt; | ||
LookToRead2_Init(&lookStream); | ||
|
||
if (!crc_tables_generated) | ||
{ | ||
CrcGenerateTable(); | ||
crc_tables_generated = true; | ||
} | ||
SRes res = SzArEx_Open(&szarchive, &lookStream.vt, &g_Alloc, &g_Alloc); | ||
|
||
return (res == SZ_OK); | ||
} | ||
|
||
ArchiveFile* SzArchive::OpenFile(const char* name) | ||
{ | ||
u16 fname[512]; | ||
for (int i = 0; i < szarchive.NumFiles; i++) | ||
{ | ||
unsigned isDir = SzArEx_IsDir(&szarchive, i); | ||
if (isDir) | ||
continue; | ||
|
||
int len = SzArEx_GetFileNameUtf16(&szarchive, i, fname); | ||
char szname[512]; | ||
int j = 0; | ||
for (; j < len && j < sizeof(szname) - 1; j++) | ||
szname[j] = fname[j]; | ||
szname[j] = 0; | ||
if (strcmp(name, szname)) | ||
continue; | ||
|
||
size_t offset = 0; | ||
size_t out_size_processed = 0; | ||
SRes res = SzArEx_Extract(&szarchive, &lookStream.vt, i, &block_idx, &out_buffer, &out_buffer_size, &offset, &out_size_processed, &g_Alloc, &g_Alloc); | ||
if (res != SZ_OK) | ||
return NULL; | ||
|
||
return new SzArchiveFile(out_buffer, offset, (u32)out_size_processed); | ||
} | ||
return NULL; | ||
} | ||
|
||
SzArchive::~SzArchive() | ||
{ | ||
if (lookStream.buf != NULL) | ||
{ | ||
File_Close(&archiveStream.file); | ||
ISzAlloc_Free(&g_Alloc, lookStream.buf); | ||
if (out_buffer != NULL) | ||
ISzAlloc_Free(&g_Alloc, out_buffer); | ||
SzArEx_Free(&szarchive, &g_Alloc); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
Created on: Nov 23, 2018 | ||
Copyright 2018 flyinghead | ||
This file is part of reicast. | ||
reicast is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 2 of the License, or | ||
(at your option) any later version. | ||
reicast is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with reicast. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#ifndef CORE_ARCHIVE_7ZARCHIVE_H_ | ||
#define CORE_ARCHIVE_7ZARCHIVE_H_ | ||
|
||
#include "archive.h" | ||
#include "deps/lzma/7z.h" | ||
#include "deps/lzma/7zFile.h" | ||
|
||
class SzArchive : public Archive | ||
{ | ||
public: | ||
SzArchive() : out_buffer(NULL) { | ||
memset(&archiveStream, 0, sizeof(archiveStream)); | ||
memset(&lookStream, 0, sizeof(lookStream)); | ||
} | ||
virtual ~SzArchive(); | ||
|
||
virtual ArchiveFile* OpenFile(const char* name) override; | ||
|
||
private: | ||
virtual bool Open(const char* path) override; | ||
|
||
CSzArEx szarchive; | ||
UInt32 block_idx; /* it can have any value before first call (if outBuffer = 0) */ | ||
Byte *out_buffer; /* it must be 0 before first call for each new archive. */ | ||
size_t out_buffer_size; /* it can have any value before first call (if outBuffer = 0) */ | ||
CFileInStream archiveStream; | ||
CLookToRead2 lookStream; | ||
|
||
}; | ||
|
||
class SzArchiveFile : public ArchiveFile | ||
{ | ||
public: | ||
SzArchiveFile(u8 *data, u32 offset, u32 length) : data(data), offset(offset), length(length) {} | ||
virtual u32 Read(void *buffer, u32 length) override | ||
{ | ||
length = min(length, this->length); | ||
memcpy(buffer, data + offset, length); | ||
return length; | ||
} | ||
|
||
private: | ||
u8 *data; | ||
u32 offset; | ||
u32 length; | ||
}; | ||
|
||
#endif /* CORE_ARCHIVE_7ZARCHIVE_H_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
Created on: Nov 23, 2018 | ||
Copyright 2018 flyinghead | ||
This file is part of reicast. | ||
reicast is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 2 of the License, or | ||
(at your option) any later version. | ||
reicast is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with reicast. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
#include "ZipArchive.h" | ||
|
||
ZipArchive::~ZipArchive() | ||
{ | ||
zip_close(zip); | ||
} | ||
|
||
bool ZipArchive::Open(const char* path) | ||
{ | ||
zip = zip_open(path, 0, NULL); | ||
return (zip != NULL); | ||
} | ||
|
||
ArchiveFile* ZipArchive::OpenFile(const char* name) | ||
{ | ||
zip_file *zip_file = zip_fopen(zip, name, 0); | ||
if (zip_file == NULL) | ||
return NULL; | ||
|
||
return new ZipArchiveFile(zip_file); | ||
} | ||
|
||
u32 ZipArchiveFile::Read(void* buffer, u32 length) | ||
{ | ||
return zip_fread(zip_file, buffer, length); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
Created on: Nov 23, 2018 | ||
Copyright 2018 flyinghead | ||
This file is part of reicast. | ||
reicast is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 2 of the License, or | ||
(at your option) any later version. | ||
reicast is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with reicast. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#ifndef CORE_ARCHIVE_ZIPARCHIVE_H_ | ||
#define CORE_ARCHIVE_ZIPARCHIVE_H_ | ||
#include "archive.h" | ||
#include "deps/libzip/zip.h" | ||
|
||
class ZipArchive : public Archive | ||
{ | ||
public: | ||
ZipArchive() : zip(NULL) {} | ||
virtual ~ZipArchive(); | ||
|
||
virtual ArchiveFile* OpenFile(const char* name) override; | ||
|
||
private: | ||
virtual bool Open(const char* path) override; | ||
|
||
struct zip *zip; | ||
}; | ||
|
||
class ZipArchiveFile : public ArchiveFile | ||
{ | ||
public: | ||
ZipArchiveFile(struct zip_file *zip_file) : zip_file(zip_file) {} | ||
virtual ~ZipArchiveFile() { zip_fclose(zip_file); } | ||
virtual u32 Read(void* buffer, u32 length) override; | ||
|
||
private: | ||
struct zip_file *zip_file; | ||
}; | ||
|
||
#endif /* CORE_ARCHIVE_ZIPARCHIVE_H_ */ |
Oops, something went wrong.