diff --git a/src/driver.h b/src/driver.h index 440201da..a88cdd5d 100644 --- a/src/driver.h +++ b/src/driver.h @@ -89,9 +89,13 @@ void FCEUI_DisableSpriteLimitation(int a); void FCEUI_SetRenderPlanes(bool sprites, bool bg); void FCEUI_GetRenderPlanes(bool& sprites, bool& bg); -//name=path and file to load. returns 0 on failure, 1 on success +//name=path and file to load. returns null if it failed FCEUGI *FCEUI_LoadGame(const char *name, int OverwriteVidMode); +//same as FCEUI_LoadGame, except that it can load from a tempfile. +//name is the actual path to open; logicalname is what the emulator should think it is +FCEUGI *FCEUI_LoadGameVirtual(const char *name, const char *logicalname, int OverwriteVidMode); + //general purpose emulator initialization. returns true if successful bool FCEUI_Initialize(); diff --git a/src/drivers/win/7zip.cpp b/src/drivers/win/7zip.cpp new file mode 100644 index 00000000..e9f6c504 --- /dev/null +++ b/src/drivers/win/7zip.cpp @@ -0,0 +1,416 @@ +#include +#include +#include +#include + +#include +#include +#include + +#include "7zip/IArchive.h" + +#include "driver.h" +#include "main.h" + +DEFINE_GUID(CLSID_CFormat7z,0x23170F69,0x40C1,0x278A,0x10,0x00,0x00,0x01,0x10,0x07,0x00,0x00); + +class OutStream : public IArchiveExtractCallback +{ + class SeqStream : public ISequentialOutStream + { + uint8* const output; + uint32 pos; + const uint32 size; + ULONG refCount; + + HRESULT STDMETHODCALLTYPE QueryInterface(REFGUID,void**) + { + return E_NOINTERFACE; + } + + HRESULT STDMETHODCALLTYPE Write(const void* data,UInt32 length,UInt32* save) + { + if (data != NULL || size == 0) + { + //NST_VERIFY( length <= size - pos ); + + if (length > size - pos) + length = size - pos; + + std::memcpy( output + pos, data, length ); + pos += length; + + if (save) + *save = length; + + return S_OK; + } + else + { + return E_INVALIDARG; + } + } + + ULONG STDMETHODCALLTYPE AddRef() + { + return ++refCount; + } + + ULONG STDMETHODCALLTYPE Release() + { + return --refCount; + } + + public: + + SeqStream(void* d,uint32 s) + : output(static_cast(d)), pos(0), size(s), refCount(0) {} + + uint32 Size() const + { + return pos; + } + }; + + SeqStream seqStream; + const uint32 index; + ULONG refCount; + + HRESULT STDMETHODCALLTYPE QueryInterface(REFGUID,void**) + { + return E_NOINTERFACE; + } + + HRESULT STDMETHODCALLTYPE PrepareOperation(Int32) + { + return S_OK; + } + + HRESULT STDMETHODCALLTYPE SetTotal(UInt64) + { + return S_OK; + } + + HRESULT STDMETHODCALLTYPE SetCompleted(const UInt64*) + { + return S_OK; + } + + HRESULT STDMETHODCALLTYPE SetOperationResult(Int32) + { + return S_OK; + } + + HRESULT STDMETHODCALLTYPE GetStream(UInt32 id,ISequentialOutStream** ptr,Int32 mode) + { + switch (mode) + { + case NArchive::NExtract::NAskMode::kExtract: + case NArchive::NExtract::NAskMode::kTest: + + if (id != index || ptr == NULL) + return S_FALSE; + else + *ptr = &seqStream; + + case NArchive::NExtract::NAskMode::kSkip: + return S_OK; + + default: + return E_INVALIDARG; + } + } + + ULONG STDMETHODCALLTYPE AddRef() + { + return ++refCount; + } + + ULONG STDMETHODCALLTYPE Release() + { + return --refCount; + } + +public: + + OutStream(uint32 index,void* data,uint32 size) + : seqStream(data,size), index(index), refCount(0) {} + + uint32 Size() const + { + return seqStream.Size(); + } +}; + +class InStream : public IInStream, private IStreamGetSize +{ + ULONG refCount; + + HRESULT STDMETHODCALLTYPE QueryInterface(REFGUID,void**) + { + return E_NOINTERFACE; + } + + HRESULT STDMETHODCALLTYPE GetSize(UInt64* save) + { + if (save) + { + *save = size; + return S_OK; + } + else + { + return E_INVALIDARG; + } + } + + ULONG STDMETHODCALLTYPE AddRef() + { + return ++refCount; + } + + ULONG STDMETHODCALLTYPE Release() + { + return --refCount; + } + +protected: + + uint32 size; + +public: + + explicit InStream() + : refCount(0) + {} +}; + + +class InFileStream : public InStream +{ +public: + + ~InFileStream() + { + if(inf) delete inf; + } + + std::fstream* inf; + + InFileStream(std::string fname) + : inf(0) + { + inf = FCEUD_UTF8_fstream(fname,"rb"); + if(inf) + { + inf->seekg(0,std::ios::end); + size = inf->tellg(); + inf->seekg(0,std::ios::beg); + } + } + + HRESULT STDMETHODCALLTYPE Read(void* data,UInt32 length,UInt32* save) + { + if(!inf) return E_FAIL; + + if (data != NULL || length == 0) + { + inf->read((char*)data,length); + length = inf->gcount(); + + //do we need to do + //return E_FAIL; + + if (save) + *save = length; + + return S_OK; + } + else + { + return E_INVALIDARG; + } + } + + HRESULT STDMETHODCALLTYPE Seek(Int64 offset,UInt32 origin,UInt64* pos) + { + if(!inf) return E_FAIL; + + if (origin < 3) + { + std::ios::off_type offtype; + switch(origin) + { + case 0: offtype = std::ios::beg; break; + case 1: offtype = std::ios::cur; break; + case 2: offtype = std::ios::end; break; + default: + return E_INVALIDARG; + } + inf->seekg(offset,offtype); + origin = inf->tellg(); + + if (pos) + *pos = origin; + + return S_OK; + } + else + { + return E_INVALIDARG; + } + + } +}; + + +class LibRef +{ +public: + HMODULE hmod; + LibRef(const char* fname) { + hmod = LoadLibrary("7zxa.dll"); + } + ~LibRef() { + if(hmod) + FreeLibrary(hmod); + } +}; + +struct FileSelectorContext +{ + struct Item + { + std::string name; + uint32 size, index; + }; + std::vector items; +} *currFileSelectorContext; + + + +static BOOL CALLBACK ArchiveFileSelectorCallback(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + switch(uMsg) + { + case WM_INITDIALOG: + { + HWND hwndListbox = GetDlgItem(hwndDlg,IDC_LIST1); + for(uint32 i=0;iitems.size();i++) + { + std::string& name = currFileSelectorContext->items[i].name; + SendMessage(hwndListbox,LB_ADDSTRING,0,(LPARAM)name.c_str()); + } + } + break; + + case WM_COMMAND: + switch(LOWORD(wParam)) + { + case IDC_LIST1: + if(HIWORD(wParam) == LBN_DBLCLK) + { + EndDialog(hwndDlg,SendMessage((HWND)lParam,LB_GETCURSEL,0,0)); + } + return TRUE; + + case IDOK: + EndDialog(hwndDlg,SendMessage((HWND)lParam,LB_GETCURSEL,0,0)); + return TRUE; + + case IDCANCEL: + EndDialog(hwndDlg, LB_ERR); + return TRUE; + } + break; + } + return FALSE; +} + +void do7zip(HWND hParent, std::string fname) +{ + LibRef libref("7zxa.dll"); + if(!libref.hmod) { + MessageBox(hParent,"Could not locate 7zxa.dll","Failure launching 7z archive browser",0); + return; + } + + typedef UINT32 (WINAPI *CreateObjectFunc)(const GUID*,const GUID*,void**); + CreateObjectFunc CreateObject = (CreateObjectFunc)GetProcAddress(libref.hmod,"CreateObject"); + if(!CreateObject) + { + MessageBox(hParent,"7zxa.dll was invalid","Failure launching 7z archive browser",0); + return; + } + + IInArchive* object; + if (!FAILED(CreateObject( &CLSID_CFormat7z, &IID_IInArchive, (void**)&object ))) + { + InFileStream ifs(fname); + if (SUCCEEDED(object->Open(&ifs,0,0))) + { + uint32 numFiles; + if (SUCCEEDED(object->GetNumberOfItems(&numFiles))) + { + FileSelectorContext fileSelectorContext; + currFileSelectorContext = &fileSelectorContext; + + for(uint32 i=0;iGetProperty( i, kpidSize, &prop )) || prop.vt != VT_UI8 || !prop.uhVal.LowPart || prop.uhVal.HighPart) + continue; + + item.size = prop.uhVal.LowPart; + + if (FAILED(object->GetProperty( i, kpidPath, &prop )) || prop.vt != VT_BSTR || prop.bstrVal == NULL) + continue; + + + std::wstring tempfname = prop.bstrVal; + int buflen = tempfname.size()*2; + char* buf = new char[buflen]; + int ret = WideCharToMultiByte(CP_ACP,0,tempfname.c_str(),tempfname.size(),buf,buflen,0,0); + if(ret == 0) { + delete[] buf; + continue; + } + buf[ret] = 0; + item.name = buf; + delete[] buf; + + ::VariantClear( reinterpret_cast(&prop) ); + + fileSelectorContext.items.push_back(item); + } + + int ret = DialogBoxParam(fceu_hInstance, "7ZIPARCHIVEDIALOG", hParent, ArchiveFileSelectorCallback, (LPARAM)0); + if(ret != LB_ERR) + { + FileSelectorContext::Item& item = fileSelectorContext.items[ret]; + std::vector data(item.size); + OutStream outStream( item.index, &data[0], item.size); + const uint32 indices[1] = {item.index}; + if (SUCCEEDED(object->Extract(indices,1,0,&outStream))) + { + char* tempname = tmpnam(0); + FILE* outf = fopen(tempname,"wb"); + fwrite(&data[0],1,item.size,outf); + fclose(outf); + void ALoad(char *nameo,char* actualfile); + ALoad((char*)item.name.c_str(),tempname); + + } //if we extracted the file correctly + + } //if returned a file from the fileselector + + } //if we scanned the 7z correctly + } //if we opened the 7z correctly + object->Release(); + } +} \ No newline at end of file diff --git a/src/drivers/win/7zip/IArchive.h b/src/drivers/win/7zip/IArchive.h new file mode 100644 index 00000000..2cfdfc2d --- /dev/null +++ b/src/drivers/win/7zip/IArchive.h @@ -0,0 +1,173 @@ +// IArchive.h + +#ifndef __IARCHIVE_H +#define __IARCHIVE_H + +#include "IStream.h" +#include "IProgress.h" +#include "PropID.h" + +// MIDL_INTERFACE("23170F69-40C1-278A-0000-000600xx0000") +#define ARCHIVE_INTERFACE_SUB(i, base, x) \ +DEFINE_GUID(IID_ ## i, \ +0x23170F69, 0x40C1, 0x278A, 0x00, 0x00, 0x00, 0x06, 0x00, x, 0x00, 0x00); \ +struct i: public base + +#define ARCHIVE_INTERFACE(i, x) ARCHIVE_INTERFACE_SUB(i, IUnknown, x) + +namespace NFileTimeType +{ + enum EEnum + { + kWindows, + kUnix, + kDOS + }; +} + +namespace NArchive +{ + enum + { + kName = 0, + kClassID, + kExtension, + kAddExtension, + kUpdate, + kKeepName, + kStartSignature, + kFinishSignature, + kAssociate + }; + + namespace NExtract + { + namespace NAskMode + { + enum + { + kExtract = 0, + kTest, + kSkip + }; + } + namespace NOperationResult + { + enum + { + kOK = 0, + kUnSupportedMethod, + kDataError, + kCRCError + }; + } + } + namespace NUpdate + { + namespace NOperationResult + { + enum + { + kOK = 0, + kError + }; + } + } +} + +ARCHIVE_INTERFACE(IArchiveOpenCallback, 0x10) +{ + STDMETHOD(SetTotal)(const UInt64 *files, const UInt64 *bytes) PURE; + STDMETHOD(SetCompleted)(const UInt64 *files, const UInt64 *bytes) PURE; +}; + + +ARCHIVE_INTERFACE_SUB(IArchiveExtractCallback, IProgress, 0x20) +{ + STDMETHOD(GetStream)(UInt32 index, ISequentialOutStream **outStream, + Int32 askExtractMode) PURE; + // GetStream OUT: S_OK - OK, S_FALSE - skeep this file + STDMETHOD(PrepareOperation)(Int32 askExtractMode) PURE; + STDMETHOD(SetOperationResult)(Int32 resultEOperationResult) PURE; +}; + + +ARCHIVE_INTERFACE(IArchiveOpenVolumeCallback, 0x30) +{ + STDMETHOD(GetProperty)(PROPID propID, PROPVARIANT *value) PURE; + STDMETHOD(GetStream)(const wchar_t *name, IInStream **inStream) PURE; +}; + + +ARCHIVE_INTERFACE(IInArchiveGetStream, 0x40) +{ + STDMETHOD(GetStream)(UInt32 index, ISequentialInStream **stream) PURE; +}; + + +ARCHIVE_INTERFACE(IArchiveOpenSetSubArchiveName, 0x50) +{ + STDMETHOD(SetSubArchiveName)(const wchar_t *name) PURE; +}; + + +ARCHIVE_INTERFACE(IInArchive, 0x60) +{ + STDMETHOD(Open)(IInStream *stream, const UInt64 *maxCheckStartPosition, + IArchiveOpenCallback *openArchiveCallback) PURE; + STDMETHOD(Close)() PURE; + STDMETHOD(GetNumberOfItems)(UInt32 *numItems) PURE; + STDMETHOD(GetProperty)(UInt32 index, PROPID propID, PROPVARIANT *value) PURE; + STDMETHOD(Extract)(const UInt32* indices, UInt32 numItems, + Int32 testMode, IArchiveExtractCallback *extractCallback) PURE; + // indices must be sorted + // numItems = 0xFFFFFFFF means all files + // testMode != 0 means "test files operation" + + STDMETHOD(GetArchiveProperty)(PROPID propID, PROPVARIANT *value) PURE; + + STDMETHOD(GetNumberOfProperties)(UInt32 *numProperties) PURE; + STDMETHOD(GetPropertyInfo)(UInt32 index, + BSTR *name, PROPID *propID, VARTYPE *varType) PURE; + + STDMETHOD(GetNumberOfArchiveProperties)(UInt32 *numProperties) PURE; + STDMETHOD(GetArchivePropertyInfo)(UInt32 index, + BSTR *name, PROPID *propID, VARTYPE *varType) PURE; +}; + + +ARCHIVE_INTERFACE_SUB(IArchiveUpdateCallback, IProgress, 0x80) +{ + STDMETHOD(GetUpdateItemInfo)(UInt32 index, + Int32 *newData, // 1 - new data, 0 - old data + Int32 *newProperties, // 1 - new properties, 0 - old properties + UInt32 *indexInArchive // -1 if there is no in archive, or if doesn't matter + ) PURE; + STDMETHOD(GetProperty)(UInt32 index, PROPID propID, PROPVARIANT *value) PURE; + STDMETHOD(GetStream)(UInt32 index, ISequentialInStream **inStream) PURE; + STDMETHOD(SetOperationResult)(Int32 operationResult) PURE; +}; + + +ARCHIVE_INTERFACE_SUB(IArchiveUpdateCallback2, IArchiveUpdateCallback, 0x82) +{ + STDMETHOD(GetVolumeSize)(UInt32 index, UInt64 *size) PURE; + STDMETHOD(GetVolumeStream)(UInt32 index, ISequentialOutStream **volumeStream) PURE; +}; + + +ARCHIVE_INTERFACE(IOutArchive, 0xA0) +{ + STDMETHOD(UpdateItems)(ISequentialOutStream *outStream, UInt32 numItems, + IArchiveUpdateCallback *updateCallback) PURE; + STDMETHOD(GetFileTimeType)(UInt32 *type) PURE; +}; + + +ARCHIVE_INTERFACE(ISetProperties, 0x03) +{ + STDMETHOD(SetProperties)(const wchar_t **names, const PROPVARIANT *values, Int32 numProperties) PURE; +}; + + +#endif diff --git a/src/drivers/win/7zip/IProgress.h b/src/drivers/win/7zip/IProgress.h new file mode 100644 index 00000000..c94b7f4c --- /dev/null +++ b/src/drivers/win/7zip/IProgress.h @@ -0,0 +1,32 @@ +// Interface/IProgress.h + +#ifndef __IPROGRESS_H +#define __IPROGRESS_H + +#include "MyUnknown.h" +#include "Types.h" + +// {23170F69-40C1-278A-0000-000000050000} +DEFINE_GUID(IID_IProgress, +0x23170F69, 0x40C1, 0x278A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00); +MIDL_INTERFACE("23170F69-40C1-278A-0000-000000050000") +IProgress: public IUnknown +{ + STDMETHOD(SetTotal)(UInt64 total) PURE; + STDMETHOD(SetCompleted)(const UInt64 *completeValue) PURE; +}; + +/* +// {23170F69-40C1-278A-0000-000000050002} +DEFINE_GUID(IID_IProgress2, +0x23170F69, 0x40C1, 0x278A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x02); +MIDL_INTERFACE("23170F69-40C1-278A-0000-000000050002") +IProgress2: public IUnknown +{ +public: + STDMETHOD(SetTotal)(const UInt64 *total) PURE; + STDMETHOD(SetCompleted)(const UInt64 *completeValue) PURE; +}; +*/ + +#endif diff --git a/src/drivers/win/7zip/IStream.h b/src/drivers/win/7zip/IStream.h new file mode 100644 index 00000000..1a50af69 --- /dev/null +++ b/src/drivers/win/7zip/IStream.h @@ -0,0 +1,62 @@ +// IStream.h + +#ifndef __ISTREAM_H +#define __ISTREAM_H + +#include "MyUnknown.h" +#include "Types.h" + +// "23170F69-40C1-278A-0000-000300xx0000" + +#define STREAM_INTERFACE_SUB(i, b, x) \ +DEFINE_GUID(IID_ ## i, \ +0x23170F69, 0x40C1, 0x278A, 0x00, 0x00, 0x00, 0x03, 0x00, x, 0x00, 0x00); \ +struct i: public b + +#define STREAM_INTERFACE(i, x) STREAM_INTERFACE_SUB(i, IUnknown, x) + +STREAM_INTERFACE(ISequentialInStream, 0x01) +{ + STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize) PURE; + /* + Out: if size != 0, return_value = S_OK and (*processedSize == 0), + then there are no more bytes in stream. + if (size > 0) && there are bytes in stream, + this function must read at least 1 byte. + This function is allowed to read less than number of remaining bytes in stream. + You must call Read function in loop, if you need exact amount of data + */ +}; + +STREAM_INTERFACE(ISequentialOutStream, 0x02) +{ + STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize) PURE; + /* + if (size > 0) this function must write at least 1 byte. + This function is allowed to write less than "size". + You must call Write function in loop, if you need to write exact amount of data + */ +}; + +STREAM_INTERFACE_SUB(IInStream, ISequentialInStream, 0x03) +{ + STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition) PURE; +}; + +STREAM_INTERFACE_SUB(IOutStream, ISequentialOutStream, 0x04) +{ + STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition) PURE; + STDMETHOD(SetSize)(Int64 newSize) PURE; +}; + +STREAM_INTERFACE(IStreamGetSize, 0x06) +{ + STDMETHOD(GetSize)(UInt64 *size) PURE; +}; + +STREAM_INTERFACE(IOutStreamFlush, 0x07) +{ + STDMETHOD(Flush)() PURE; +}; + +#endif diff --git a/src/drivers/win/7zip/MyUnknown.h b/src/drivers/win/7zip/MyUnknown.h new file mode 100644 index 00000000..6cd32cad --- /dev/null +++ b/src/drivers/win/7zip/MyUnknown.h @@ -0,0 +1,24 @@ +// MyUnknown.h + +#ifndef __MYUNKNOWN_H +#define __MYUNKNOWN_H + +#ifdef _WIN32 + +#ifdef _WIN32_WCE +#if (_WIN32_WCE > 300) +#include +#else +#define MIDL_INTERFACE(x) struct +#endif +#else +#include +#endif + +#include + +#else +#include "MyWindows.h" +#endif + +#endif diff --git a/src/drivers/win/7zip/PropID.h b/src/drivers/win/7zip/PropID.h new file mode 100644 index 00000000..c42b990a --- /dev/null +++ b/src/drivers/win/7zip/PropID.h @@ -0,0 +1,50 @@ +// Interface/PropID.h + +#ifndef __INTERFACE_PROPID_H +#define __INTERFACE_PROPID_H + +enum +{ + kpidNoProperty = 0, + + kpidHandlerItemIndex = 2, + kpidPath, + kpidName, + kpidExtension, + kpidIsFolder, + kpidSize, + kpidPackedSize, + kpidAttributes, + kpidCreationTime, + kpidLastAccessTime, + kpidLastWriteTime, + kpidSolid, + kpidCommented, + kpidEncrypted, + kpidSplitBefore, + kpidSplitAfter, + kpidDictionarySize, + kpidCRC, + kpidType, + kpidIsAnti, + kpidMethod, + kpidHostOS, + kpidFileSystem, + kpidUser, + kpidGroup, + kpidBlock, + kpidComment, + kpidPosition, + + kpidTotalSize = 0x1100, + kpidFreeSpace, + kpidClusterSize, + kpidVolumeName, + + kpidLocalName = 0x1200, + kpidProvider, + + kpidUserDefined = 0x10000 +}; + +#endif diff --git a/src/drivers/win/7zip/Types.h b/src/drivers/win/7zip/Types.h new file mode 100644 index 00000000..52d07081 --- /dev/null +++ b/src/drivers/win/7zip/Types.h @@ -0,0 +1,19 @@ +// Common/Types.h + +#ifndef __COMMON_TYPES_H +#define __COMMON_TYPES_H + +typedef unsigned char Byte; +typedef short Int16; +typedef unsigned short UInt16; +typedef int Int32; +typedef unsigned int UInt32; +#ifdef _MSC_VER +typedef __int64 Int64; +typedef unsigned __int64 UInt64; +#else +typedef long long int Int64; +typedef unsigned long long int UInt64; +#endif + +#endif diff --git a/src/drivers/win/7zip/readme.txt b/src/drivers/win/7zip/readme.txt new file mode 100644 index 00000000..33fb406d --- /dev/null +++ b/src/drivers/win/7zip/readme.txt @@ -0,0 +1,225 @@ +7-Zip 4.27 Sources +------------------ + +7-Zip is a file archiver for Windows 95/98/ME/NT/2000/2003/XP. + +7-Zip Copyright (C) 1999-2005 Igor Pavlov. + + +License Info +------------ + +Most of 7-Zip source code is under GNU LGPL. + +Files in folders + 7zip/Compress/Rar20 + 7zip/Compress/Rar29 + 7zip/Compress/Rar29/Original +are licensed under "unRAR license + GNU LGPL" license. +Source code files in all other folders of this package are under GNU LGPL. + +"unRAR license + GNU LGPL" means that you must follow +GNU LGPL in all aspects while it is in agreement +with unRAR license. But you can not break unRAR license rules. +It means that unRAR license is main license in that pair. + +You can find unRAR license in file unrarLicense.txt +You can find GNU LGPL license in file copying.txt + + +GNU LGPL information: +--------------------- + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library 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 +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + +unRAR license + GNU LGPL Notes +------------------------------ + +Please check main restriction from unRar license: + + 2. The unRAR sources may be used in any software to handle RAR + archives without limitations free of charge, but cannot be used + to re-create the RAR compression algorithm, which is proprietary. + Distribution of modified unRAR sources in separate form or as a + part of other software is permitted, provided that it is clearly + stated in the documentation and source comments that the code may + not be used to develop a RAR (WinRAR) compatible archiver. + +In brief it means: +1) You can compile and use compiled files under GNU LGPL rules, since + unRAR license almost has no restrictions for compiled files. + You can link these compiled files to LGPL programs. +2) You can fix bugs in source code and use compiled fixed version. +3) You can not use unRAR sources to re-create the RAR compression algorithm. + + +7zip\Compress\Rar29\Original folder contains files that are modified +versions of original unRAR source code files. + + +License notes +------------- + +You can support development of 7-Zip by registering. + +7-Zip is free software distributed under the GNU LGPL. +If you need license with other conditions, write to +http://www.7-zip.org/support.html + +--- +Also this package contains files from LZMA SDK +you can download LZMA SDK from this page: +http://www.7-zip.org/sdk.html +read about addtional licenses for LZMA SDK in file +DOC/lzma.txt + + +How to compile +-------------- +To compile sources you need Visual C++ 6.0. +For compiling some files you also need +new Platform SDK from Microsoft' Site: +http://www.microsoft.com/msdownload/platformsdk/sdkupdate/psdk-full.htm +or +http://www.microsoft.com/msdownload/platformsdk/sdkupdate/XPSP2FULLInstall.htm +or +http://www.microsoft.com/msdownload/platformsdk/sdkupdate/ + +If you use MSVC6, specify SDK directories at top of directories lists: +Tools / Options / Directories + - Include files + - Library files + + +To compile 7-Zip for AMD64 and IA64 you need: + Windows Server 2003 SP1 Platform SDK from microsoft.com + + + +Compiling under Unix/Linux +-------------------------- +Check this site for Posix/Linux version: +http://sourceforge.net/projects/p7zip/ + + +Notes: +------ +7-Zip consists of COM modules (DLL files). +But 7-Zip doesn't use standard COM interfaces for creating objects. +Look at +7zip\UI\Client7z folder for example of using DLL files of 7-Zip. +Some DLL files can use other DLL files from 7-Zip. +If you don't like it, you must use standalone version of DLL. +To compile standalone version of DLL you must include all used parts +to project and define some defs. +For example, 7zip\Bundles\Format7z is a standalone version of 7z.dll +that works with 7z format. So you can use such DLL in your project +without additional DLL files. + + +Description of 7-Zip sources package +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +DOC Documentation +--- + 7zFormat.txt - 7z format description + copying.txt - GNU LGPL license + unRarLicense.txt - License for unRAR part of source code + history.txt - Sources history + Methods.txt - Compression method IDs + readme.txt - Readme file + lzma.txt - LZMA SDK description + 7zip.nsi - installer script for NSIS + + +Common Common modules +Windows Win32 wrappers + +7zip +------- + Common Common modules for 7-zip + + Archive 7-Zip Archive Format Plugins + -------- + Common + 7z + Arj + BZip2 + Cab + Cpio + GZip + Rar + Rpm + Split + Tar + Zip + + Bundle Modules that are bundles of other modules + ------ + Alone 7za.exe: Standalone version of 7z + SFXCon 7zCon.sfx: Console 7z SFX module + SFXWin 7z.sfx: Windows 7z SFX module + SFXSetup 7zS.sfx: Windows 7z SFX module for Installers + Format7z 7za.dll: Standalone version of 7z.dll + + UI + -- + Agent Intermediary modules for FAR plugin and Explorer plugin + Console 7z.exe Console version + Explorer Explorer plugin + Resource Resources + Far FAR plugin + Client7z Test application for 7za.dll + + Compress + -------- + BZip2 BZip2 compressor + Original Download BZip2 compression sources from + http://sources.redhat.com/bzip2/index.html + to that folder. + Branch Branch converter + ByteSwap Byte Swap converter + Copy Copy coder + Deflate + Implode + Arj + LZMA + PPMd Dmitry Shkarin's PPMdH with small changes. + LZ Lempel - Ziv + MT Multi Thread Match finder + BinTree Match Finder based on Binary Tree + Patricia Match Finder based on Patricia algoritm + HashChain Match Finder based on Hash Chains + + Crypto Crypto modules + ------ + 7zAES Cipher for 7z + AES AES Cipher + Rar20 Cipher for Rar 2.0 + RarAES Cipher for Rar 3.0 + Zip Cipher for Zip + + FileManager File Manager + + +--- +Igor Pavlov +http://www.7-zip.org + + +--- +End of document + diff --git a/src/drivers/win/7zxa.dll b/src/drivers/win/7zxa.dll new file mode 100644 index 00000000..1ae72528 Binary files /dev/null and b/src/drivers/win/7zxa.dll differ diff --git a/src/drivers/win/config.cpp b/src/drivers/win/config.cpp index 3832aaf4..e7f5d0f7 100644 --- a/src/drivers/win/config.cpp +++ b/src/drivers/win/config.cpp @@ -39,6 +39,8 @@ extern CFGSTRUCT HotkeyConfig[]; extern char *BasicBotDir; extern int autoHoldKey, autoHoldClearKey; +extern uint8 gNoBGFillColor; + //window positions: extern int ChtPosX,ChtPosY; extern int DbgPosX,DbgPosY; @@ -75,7 +77,7 @@ static CFGSTRUCT fceuconfig[] = { ACS(memw_recent_files[3]), ACS(memw_recent_files[4]), - + AC(gNoBGFillColor), AC(ntsccol),AC(ntsctint),AC(ntschue), NAC("palyo",pal_emulation), @@ -85,8 +87,6 @@ static CFGSTRUCT fceuconfig[] = { NAC("sound",soundo), NAC("sicon",status_icon), - ACS(gfsdir), - NACS("odroms",directory_names[0]), NACS("odnonvol",directory_names[1]), NACS("odstates",directory_names[2]), diff --git a/src/drivers/win/main.h b/src/drivers/win/main.h index 47035c40..9bcd14bb 100644 --- a/src/drivers/win/main.h +++ b/src/drivers/win/main.h @@ -41,7 +41,6 @@ extern int pauseAfterPlayback; extern int EnableBackgroundInput; extern int vmod; -static char *gfsdir=0; extern char* directory_names[13]; diff --git a/src/drivers/win/res.rc b/src/drivers/win/res.rc index e4fefda0..1433ba23 100644 --- a/src/drivers/win/res.rc +++ b/src/drivers/win/res.rc @@ -1244,6 +1244,57 @@ BEGIN DEFPUSHBUTTON "&OK",IDOK,67,52,50,14 END +CDLOGGER DIALOGEX 0, 0, 322, 213 +STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +CAPTION "Code Data Logger" +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + DEFPUSHBUTTON "Load...",BTN_CDLOGGER_LOAD,7,81,50,14 + PUSHBUTTON "Save",BTN_CDLOGGER_SAVE,257,81,50,14 + GROUPBOX "Code Data Log Status",-1,2,4,316,119,BS_CENTER + PUSHBUTTON "Start",BTN_CDLOGGER_START_PAUSE,129,81,50,14 + GROUPBOX "Address Label Logger",65534,3,128,315,79,BS_CENTER + PUSHBUTTON "Load...",111,7,182,50,14,WS_DISABLED + PUSHBUTTON "Start",112,127,181,50,14,WS_DISABLED + PUSHBUTTON "Save...",113,259,181,50,14,WS_DISABLED + LTEXT "4067 - 29.5%",LBL_CDLOGGER_CODECOUNT,38,31,68,11 + GROUPBOX "Bytes Logged As Code",65533,29,20,84,27 + GROUPBOX "Bytes Logged as data",65532,117,20,84,27 + LTEXT "7092 - 37.2%",LBL_CDLOGGER_DATACOUNT,128,31,65,9 + GROUPBOX "Bytes Not Logged",65531,205,20,79,27 + LTEXT "6072 - 32.7%",LBL_CDLOGGER_UNDEFCOUNT,210,31,60,8 + LTEXT "Itsa me the Code Data Logger! Press Start to play!",65530,69,56,172,12 + PUSHBUTTON "Reset Log",BTN_CDLOGGER_RESET,7,66,50,14 + PUSHBUTTON "Save as...",BTN_CDLOGGER_SAVE_AS,257,66,50,14 + PUSHBUTTON "Save Stripped iNes Rom...",BTN_CDLOGGER_SAVE_STRIPPED,213,102,99,14 +END + +PPUVIEW DIALOG 44, 38, 355, 246 +STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +CAPTION "PPU Viewer" +FONT 8, "MS Sans Serif" +BEGIN + GROUPBOX "Pattern Tables",GRP_PPUVIEW_TABLES,2,-1,351,192,WS_TABSTOP + LTEXT "Tile:",LBL_PPUVIEW_TILE1,6,168,50,10 + LTEXT "Tile:",LBL_PPUVIEW_TILE2,177,168,50,10 + CONTROL "",CTL_PPUVIEW_TRACKBAR,"msctls_trackbar32",WS_TABSTOP,227,178,106,11 + LTEXT "Refresh: More",-1,177,178,50,10 + LTEXT "Less",-1,334,178,18,10 + GROUPBOX "Palettes",LBL_PPUVIEW_PALETTES,2,192,351,53,WS_TABSTOP + LTEXT "Display on scanline:",-1,6,178,65,10 + EDITTEXT IDC_PPUVIEW_SCANLINE,72,176,27,12 +END + +7ZIPARCHIVEDIALOG DIALOGEX 0, 0, 265, 159 +STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Choose File From Archive" +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + DEFPUSHBUTTON "OK",IDOK,146,138,50,14 + PUSHBUTTON "Cancel",IDCANCEL,208,138,50,14 + LISTBOX IDC_LIST1,7,7,251,120,LBS_SORT | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_HSCROLL | WS_TABSTOP +END + ///////////////////////////////////////////////////////////////////////////// // @@ -1361,6 +1412,14 @@ BEGIN TOPMARGIN, 7 BOTTOMMARGIN, 66 END + + "7ZIPARCHIVEDIALOG", DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 258 + TOPMARGIN, 7 + BOTTOMMARGIN, 152 + END END #endif // APSTUDIO_INVOKED @@ -1522,47 +1581,6 @@ END // Dialog // -CDLOGGER DIALOGEX 0, 0, 322, 213 -STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU -CAPTION "Code Data Logger" -FONT 8, "MS Shell Dlg", 400, 0, 0x1 -BEGIN - DEFPUSHBUTTON "Load...",BTN_CDLOGGER_LOAD,7,81,50,14 - PUSHBUTTON "Save",BTN_CDLOGGER_SAVE,257,81,50,14 - GROUPBOX "Code Data Log Status",-1,2,4,316,119,BS_CENTER - PUSHBUTTON "Start",BTN_CDLOGGER_START_PAUSE,129,81,50,14 - GROUPBOX "Address Label Logger",65534,3,128,315,79,BS_CENTER - PUSHBUTTON "Load...",111,7,182,50,14,WS_DISABLED - PUSHBUTTON "Start",112,127,181,50,14,WS_DISABLED - PUSHBUTTON "Save...",113,259,181,50,14,WS_DISABLED - LTEXT "4067 - 29.5%",LBL_CDLOGGER_CODECOUNT,38,31,68,11 - GROUPBOX "Bytes Logged As Code",65533,29,20,84,27 - GROUPBOX "Bytes Logged as data",65532,117,20,84,27 - LTEXT "7092 - 37.2%",LBL_CDLOGGER_DATACOUNT,128,31,65,9 - GROUPBOX "Bytes Not Logged",65531,205,20,79,27 - LTEXT "6072 - 32.7%",LBL_CDLOGGER_UNDEFCOUNT,210,31,60,8 - LTEXT "Itsa me the Code Data Logger! Press Start to play!",65530,69,56,172,12 - PUSHBUTTON "Reset Log",BTN_CDLOGGER_RESET,7,66,50,14 - PUSHBUTTON "Save as...",BTN_CDLOGGER_SAVE_AS,257,66,50,14 - PUSHBUTTON "Save Stripped iNes Rom...",BTN_CDLOGGER_SAVE_STRIPPED,213,102,99,14 -END - -PPUVIEW DIALOG 44, 38, 355, 246 -STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU -CAPTION "PPU Viewer" -FONT 8, "MS Sans Serif" -BEGIN - GROUPBOX "Pattern Tables",GRP_PPUVIEW_TABLES,2,-1,351,192,WS_TABSTOP - LTEXT "Tile:",LBL_PPUVIEW_TILE1,6,168,50,10 - LTEXT "Tile:",LBL_PPUVIEW_TILE2,177,168,50,10 - CONTROL "",CTL_PPUVIEW_TRACKBAR,"msctls_trackbar32",WS_TABSTOP,227,178,106,11 - LTEXT "Refresh: More",-1,177,178,50,10 - LTEXT "Less",-1,334,178,18,10 - GROUPBOX "Palettes",LBL_PPUVIEW_PALETTES,2,192,351,53,WS_TABSTOP - LTEXT "Display on scanline:",-1,6,178,65,10 - EDITTEXT IDC_PPUVIEW_SCANLINE,72,176,27,12 -END - IDD_REPLAY_METADATA DIALOGEX 0, 0, 325, 250 STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "Movie Metadata" diff --git a/src/drivers/win/resource.h b/src/drivers/win/resource.h index fc4a37ff..5b782e94 100644 --- a/src/drivers/win/resource.h +++ b/src/drivers/win/resource.h @@ -127,6 +127,7 @@ #define IDD_DIALOG1 114 #define LBL_AUTO_HOLD 115 #define IDC_CHECK_LOG_NEW_DATA 115 +#define IDD_DIALOG2 115 #define LBL_CLEAR_AH 116 #define IDC_CHECK_LOG_UPDATE_WINDOW 116 #define CHECK_SOUND_8BIT 122 @@ -536,7 +537,7 @@ // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 115 +#define _APS_NEXT_RESOURCE_VALUE 116 #define _APS_NEXT_COMMAND_VALUE 40151 #define _APS_NEXT_CONTROL_VALUE 1133 #define _APS_NEXT_SYMED_VALUE 101 diff --git a/src/drivers/win/window.cpp b/src/drivers/win/window.cpp index 5b74db52..fc170556 100644 --- a/src/drivers/win/window.cpp +++ b/src/drivers/win/window.cpp @@ -512,9 +512,11 @@ void FCEUD_HideMenuToggle(void) ToggleHideMenu(); } -void ALoad(char *nameo) +void ALoad(char *nameo,char* actualfile) { - if(FCEUI_LoadGame(nameo, 1)) + bool isvirtual = (actualfile==0); + if(isvirtual) actualfile = nameo; + if(FCEUI_LoadGameVirtual(actualfile, nameo, 1)) { pal_emulation = FCEUI_GetCurrentVidSystem(0, 0); @@ -522,7 +524,9 @@ void ALoad(char *nameo) SetMainWindowStuff(); - AddRecentFile(nameo); + //todo-add recent files from archives somehow + if(!isvirtual) + AddRecentFile(nameo); RefreshThrottleFPS(); @@ -569,32 +573,18 @@ void LoadNewGamey(HWND hParent, const char *initialdir) // Show the Open File dialog if(GetOpenFileName(&ofn)) { - char *tmpdir = (char *)malloc( ofn.nFileOffset + 1 ); //mbg merge 7/17/06 added cast - - if(tmpdir) + //if the user selected a 7zip file, then we have some work to do.. + //todo - scan file instead of checking extension + std::string fname = nameo; + extern void do7zip(HWND hwnd, std::string fname); + if(fname.substr(fname.size()-3,3) == ".7z") { - // Get the directory from the filename - strncpy(tmpdir, ofn.lpstrFile, ofn.nFileOffset); - tmpdir[ofn.nFileOffset]=0; - - // Prevent setting the File->Open default - // directory when a "Recent Directory" is selected. - if(!initialdir) - { - if(gfsdir) - { - free(gfsdir); - } - - gfsdir = tmpdir; - } - else - { - free(tmpdir); - } + do7zip(hParent, fname); + } + else + { + ALoad(nameo,0); } - - ALoad(nameo); } } @@ -726,7 +716,7 @@ LRESULT FAR PASCAL AppWndProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam) if((ftmp=(char*)malloc(len))) //mbg merge 7/17/06 added cast { DragQueryFile((HDROP)wParam,0,ftmp,len); //mbg merge 7/17/06 changed (HANDLE) to (HDROP) - ALoad(ftmp); + ALoad(ftmp,0); free(ftmp); } } @@ -742,7 +732,7 @@ LRESULT FAR PASCAL AppWndProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam) if(wParam >= MENU_FIRST_RECENT_FILE && wParam <= MENU_FIRST_RECENT_FILE + MAX_NUMBER_OF_RECENT_FILES - 1) { if(recent_files[wParam - MENU_FIRST_RECENT_FILE]) - ALoad(recent_files[wParam - MENU_FIRST_RECENT_FILE]); + ALoad(recent_files[wParam - MENU_FIRST_RECENT_FILE],0); } switch(LOWORD(wParam)) { diff --git a/src/drivers/win/window.h b/src/drivers/win/window.h index 492107e8..94ff1507 100644 --- a/src/drivers/win/window.h +++ b/src/drivers/win/window.h @@ -23,7 +23,7 @@ void ByebyeWindow(); void DoTimingConfigFix(); int CreateMainWindow(); void UpdateCheckedMenuItems(); -void ALoad(char *nameo); +void ALoad(char *nameo,char* actualfile=0); void LoadNewGamey(HWND hParent, const char *initialdir); int BrowseForFolder(HWND hParent, const char *htext, char *buf); void UpdateCheckedMenuItems(); diff --git a/src/fceu.cpp b/src/fceu.cpp index 5cfd7b2b..054ceacd 100644 --- a/src/fceu.cpp +++ b/src/fceu.cpp @@ -283,17 +283,17 @@ static DECLFR(ARAMH) void ResetGameLoaded(void) { - if(GameInfo) CloseGame(); - EmulationPaused = 0; //mbg 5/8/08 - loading games while paused was bad news. maybe this fixes it - GameStateRestore=0; - PPU_hook=0; - GameHBIRQHook=0; - if(GameExpSound.Kill) - GameExpSound.Kill(); - memset(&GameExpSound,0,sizeof(GameExpSound)); - MapIRQHook=0; - MMC5Hack=0; - PAL&=1; + if(GameInfo) CloseGame(); + EmulationPaused = 0; //mbg 5/8/08 - loading games while paused was bad news. maybe this fixes it + GameStateRestore=0; + PPU_hook=0; + GameHBIRQHook=0; + if(GameExpSound.Kill) + GameExpSound.Kill(); + memset(&GameExpSound,0,sizeof(GameExpSound)); + MapIRQHook=0; + MMC5Hack=0; + PAL&=1; pale=0; } @@ -302,14 +302,16 @@ int iNESLoad(const char *name, FCEUFILE *fp, int OverwriteVidMode); int FDSLoad(const char *name, FCEUFILE *fp); int NSFLoad(FCEUFILE *fp); -char lastLoadedGameName [2048] = {0,}; // hack for movie WRAM clearing on record from poweron +//mbg 6/25/08 - remove this one day +//char lastLoadedGameName [2048] = {0,}; // hack for movie WRAM clearing on record from poweron -FCEUGI *FCEUI_LoadGame(const char *name, int OverwriteVidMode) + +FCEUGI *FCEUI_LoadGameVirtual(const char *name, const char *logicalname, int OverwriteVidMode) { //mbg merge 7/17/07 - why is this here -//#ifdef WIN32 -// StopSound(); -//#endif + //#ifdef WIN32 + // StopSound(); + //#endif //---------- //attempt to open the files @@ -317,14 +319,14 @@ FCEUGI *FCEUI_LoadGame(const char *name, int OverwriteVidMode) char *ipsfn; FCEU_printf("Loading %s...\n\n",name); - GetFileBase(name); + GetFileBase(logicalname); ipsfn=strdup(FCEU_MakeFName(FCEUMKF_IPS,0,0).c_str()); fp=FCEU_fopen(name,ipsfn,"rb",0); free(ipsfn); if(!fp) { - FCEU_PrintError("Error opening \"%s\"!",name); + FCEU_PrintError("Error opening \"%s\"!",name); return 0; } //--------- @@ -332,66 +334,69 @@ FCEUGI *FCEUI_LoadGame(const char *name, int OverwriteVidMode) //file opened ok. start loading. ResetGameLoaded(); - + AutosaveStatus[0] = AutosaveStatus[1] = 0; AutosaveStatus[2] = AutosaveStatus[3] = 0; CloseGame(); GameInfo = new FCEUGI; memset(GameInfo, 0, sizeof(FCEUGI)); - + GameInfo->soundchan = 0; GameInfo->soundrate = 0; - GameInfo->name=0; - GameInfo->type=GIT_CART; - GameInfo->vidsys=GIV_USER; - GameInfo->input[0]=GameInfo->input[1]=SI_UNSET; - GameInfo->inputfc=SIFC_UNSET; - GameInfo->cspecial=SIS_NONE; + GameInfo->name=0; + GameInfo->type=GIT_CART; + GameInfo->vidsys=GIV_USER; + GameInfo->input[0]=GameInfo->input[1]=SI_UNSET; + GameInfo->inputfc=SIFC_UNSET; + GameInfo->cspecial=SIS_NONE; - //try to load each different format - if(iNESLoad(name,fp,OverwriteVidMode)) - goto endlseq; - if(NSFLoad(fp)) - goto endlseq; - if(UNIFLoad(name,fp)) - goto endlseq; - if(FDSLoad(name,fp)) - goto endlseq; + //try to load each different format + if(iNESLoad(name,fp,OverwriteVidMode)) + goto endlseq; + if(NSFLoad(fp)) + goto endlseq; + if(UNIFLoad(name,fp)) + goto endlseq; + if(FDSLoad(name,fp)) + goto endlseq; - FCEU_PrintError("An error occurred while loading the file."); - FCEU_fclose(fp); + FCEU_PrintError("An error occurred while loading the file."); + FCEU_fclose(fp); - delete GameInfo; - GameInfo = 0; + delete GameInfo; + GameInfo = 0; - return 0; + return 0; - endlseq: - - FCEU_fclose(fp); +endlseq: + + FCEU_fclose(fp); + + FCEU_ResetVidSys(); + + if(GameInfo->type!=GIT_NSF) + if(FSettings.GameGenie) + OpenGenie(); + PowerNES(); - FCEU_ResetVidSys(); - - if(GameInfo->type!=GIT_NSF) - if(FSettings.GameGenie) - OpenGenie(); - PowerNES(); - FCEUSS_CheckStates(); - if(GameInfo->type!=GIT_NSF) - { - FCEU_LoadGamePalette(); - FCEU_LoadGameCheats(0); - } - + if(GameInfo->type!=GIT_NSF) + { + FCEU_LoadGamePalette(); + FCEU_LoadGameCheats(0); + } + FCEU_ResetPalette(); FCEU_ResetMessages(); // Save state, status messages, etc. - strcpy(lastLoadedGameName, name); + return GameInfo; +} - return GameInfo; +FCEUGI *FCEUI_LoadGame(const char *name, int OverwriteVidMode) +{ + return FCEUI_LoadGameVirtual(name,name,OverwriteVidMode); } @@ -605,36 +610,34 @@ int suppressAddPowerCommand=0; // hack... yeah, I know... void PowerNES(void) { if(!suppressAddPowerCommand) - FCEUMOV_AddCommand(FCEUNPCMD_POWER); - if(!GameInfo) return; + FCEUMOV_AddCommand(FCEUNPCMD_POWER); + if(!GameInfo) return; FCEU_CheatResetRAM(); FCEU_CheatAddRAM(2,0,RAM); - GeniePower(); + GeniePower(); FCEU_MemoryRand(RAM,0x800); //memset(RAM,0xFF,0x800); - - SetReadHandler(0x0000,0xFFFF,ANull); - SetWriteHandler(0x0000,0xFFFF,BNull); - - SetReadHandler(0,0x7FF,ARAML); - SetWriteHandler(0,0x7FF,BRAML); - - SetReadHandler(0x800,0x1FFF,ARAMH); /* Part of a little */ - SetWriteHandler(0x800,0x1FFF,BRAMH); /* hack for a small speed boost. */ - - InitializeInput(); - FCEUSND_Power(); - FCEUPPU_Power(); - /* Have the external game hardware "powered" after the internal NES stuff. - Needed for the NSF code and VS System code. - */ + SetReadHandler(0x0000,0xFFFF,ANull); + SetWriteHandler(0x0000,0xFFFF,BNull); + + SetReadHandler(0,0x7FF,ARAML); + SetWriteHandler(0,0x7FF,BRAML); + + SetReadHandler(0x800,0x1FFF,ARAMH); // Part of a little + SetWriteHandler(0x800,0x1FFF,BRAMH); //hack for a small speed boost. + + InitializeInput(); + FCEUSND_Power(); + FCEUPPU_Power(); + + //Have the external game hardware "powered" after the internal NES stuff. Needed for the NSF code and VS System code. GameInterface(GI_POWER); if(GameInfo->type==GIT_VSUNI) - FCEU_VSUniPower(); + FCEU_VSUniPower(); timestampbase=0; X6502_Power(); diff --git a/src/movie.cpp b/src/movie.cpp index 5db6eb7e..01f03e2e 100644 --- a/src/movie.cpp +++ b/src/movie.cpp @@ -559,27 +559,35 @@ void FCEUI_StopMovie() static void poweron(bool shouldDisableBatteryLoading) { - // make a for-movie-recording power-on clear the game's save data, too - extern char lastLoadedGameName [2048]; - extern int disableBatteryLoading, suppressAddPowerCommand; - suppressAddPowerCommand=1; - if(shouldDisableBatteryLoading) disableBatteryLoading=1; - suppressMovieStop=true; - { - //we need to save the pause state through this process - int oldPaused = EmulationPaused; + //// make a for-movie-recording power-on clear the game's save data, too + // extern char lastLoadedGameName [2048]; + // extern int disableBatteryLoading, suppressAddPowerCommand; + // suppressAddPowerCommand=1; + // if(shouldDisableBatteryLoading) disableBatteryLoading=1; + // suppressMovieStop=true; + // { + // //we need to save the pause state through this process + // int oldPaused = EmulationPaused; - // NOTE: this will NOT write an FCEUNPCMD_POWER into the movie file - FCEUGI* gi = FCEUI_LoadGame(lastLoadedGameName, 0); - //mbg 5/23/08 - wtf? why would this return null? - //if(!gi) PowerNES(); - assert(gi); + // // NOTE: this will NOT write an FCEUNPCMD_POWER into the movie file + // FCEUGI* gi = FCEUI_LoadGame(lastLoadedGameName, 0); + // //mbg 5/23/08 - wtf? why would this return null? + // //if(!gi) PowerNES(); + // assert(gi); - EmulationPaused = oldPaused; - } - suppressMovieStop=false; - if(shouldDisableBatteryLoading) disableBatteryLoading=0; - suppressAddPowerCommand=0; + // EmulationPaused = oldPaused; + // } + // suppressMovieStop=false; + // if(shouldDisableBatteryLoading) disableBatteryLoading=0; + // suppressAddPowerCommand=0; + + //mbg 6/25/08 + //ok this pissed me off + //the only reason for lastLoadedGameName and all these hacks was for this fix: + //"hack for movie WRAM clearing on record from poweron" + //but W-T-F. are you telling me that there is some problem with the poweron sequence? + //screw that. we're using the main poweron sequence, even if that breaks old movie compatibility (unlikely) + PowerNES(); } diff --git a/src/ppu.cpp b/src/ppu.cpp index 36892565..baac11af 100644 --- a/src/ppu.cpp +++ b/src/ppu.cpp @@ -104,6 +104,11 @@ static int ppudead=1; static int kook=0; int fceuindbg=0; +//mbg 6/23/08 +//make the no-bg fill color configurable +//0xFF shall indicate to use palette[0] +uint8 gNoBGFillColor = 0xFF; + int MMC5Hack=0; uint32 MMC5HackVROMMask=0; uint8 *MMC5HackExNTARAMPtr=0; @@ -755,7 +760,11 @@ static void DoLine(void) if(!renderbg) // User asked to not display background data. { uint32 tem; - tem=Pal[0]|(Pal[0]<<8)|(Pal[0]<<16)|(Pal[0]<<24); + uint8 col; + if(gNoBGFillColor == 0xFF) + col = Pal[0]; + else col = gNoBGFillColor; + tem=col|(col<<8)|(col<<16)|(col<<24); tem|=0x40404040; FCEU_dwmemset(target,tem,256); } diff --git a/vc8/fceux.vcproj b/vc8/fceux.vcproj index c921b2aa..e2df3bdb 100644 --- a/vc8/fceux.vcproj +++ b/vc8/fceux.vcproj @@ -97,6 +97,7 @@ /> + +