mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 06:09:50 -06:00
add *.user, Win32, and x64 build dir to ignore list for DebuggerUICommon and Unit Tests
add *.aps to ignore list for DolphinWX dir add eol-style native to 120 or so files git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3689 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
@ -1,179 +1,179 @@
|
||||
// Copyright (C) 2003-2009 Dolphin Project.
|
||||
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, version 2.0.
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License 2.0 for more details.
|
||||
|
||||
// A copy of the GPL 2.0 should have been included with the program.
|
||||
// If not, see http://www.gnu.org/licenses/
|
||||
|
||||
// Official SVN repository and contact information can be found at
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
#include "AVIDump.h"
|
||||
#include "tchar.h"
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <vfw.h>
|
||||
#include <winerror.h>
|
||||
|
||||
#include "FileUtil.h"
|
||||
#include "CommonPaths.h"
|
||||
#include "Log.h"
|
||||
|
||||
static HWND m_emuWnd;
|
||||
static int m_width;
|
||||
static int m_height;
|
||||
static LONG m_byteBuffer;
|
||||
static LONG m_frameCount;
|
||||
static LONG m_totalBytes;
|
||||
static PAVIFILE m_file;
|
||||
static int m_fileCount;
|
||||
static PAVISTREAM m_stream;
|
||||
static PAVISTREAM m_streamCompressed;
|
||||
static AVISTREAMINFO m_header;
|
||||
static AVICOMPRESSOPTIONS m_options;
|
||||
static AVICOMPRESSOPTIONS *m_arrayOptions[1];
|
||||
static BITMAPINFOHEADER m_bitmap;
|
||||
|
||||
bool AVIDump::Start(HWND hWnd, int w, int h)
|
||||
{
|
||||
m_emuWnd = hWnd;
|
||||
m_fileCount = 0;
|
||||
|
||||
m_width = w;
|
||||
m_height = h;
|
||||
|
||||
return CreateFile();
|
||||
}
|
||||
|
||||
bool AVIDump::CreateFile()
|
||||
{
|
||||
m_totalBytes = 0;
|
||||
m_frameCount = 0;
|
||||
char movie_file_name[255];
|
||||
sprintf(movie_file_name, "%s/framedump%d.avi", FULL_FRAMES_DIR, m_fileCount);
|
||||
// Create path
|
||||
File::CreateFullPath(movie_file_name);
|
||||
|
||||
// Ask to delete file
|
||||
if (File::Exists(movie_file_name))
|
||||
{
|
||||
if (AskYesNo("Delete the existing file '%s'?", movie_file_name))
|
||||
File::Delete(movie_file_name);
|
||||
}
|
||||
|
||||
AVIFileInit();
|
||||
NOTICE_LOG(VIDEO, "Opening AVI file (%s) for dumping", movie_file_name);
|
||||
// TODO: Make this work with AVIFileOpenW without it throwing REGDB_E_CLASSNOTREG
|
||||
HRESULT hr = AVIFileOpenA(&m_file, movie_file_name, OF_WRITE | OF_CREATE, NULL);
|
||||
if (FAILED(hr)) {
|
||||
if (hr == AVIERR_BADFORMAT) NOTICE_LOG(VIDEO, "The file couldn't be read, indicating a corrupt file or an unrecognized format.");
|
||||
if (hr == AVIERR_MEMORY) NOTICE_LOG(VIDEO, "The file could not be opened because of insufficient memory.");
|
||||
if (hr == AVIERR_FILEREAD) NOTICE_LOG(VIDEO, "A disk error occurred while reading the file.");
|
||||
if (hr == AVIERR_FILEOPEN) NOTICE_LOG(VIDEO, "A disk error occurred while opening the file.");
|
||||
if (hr == REGDB_E_CLASSNOTREG) NOTICE_LOG(VIDEO, "AVI class not registered");
|
||||
Stop();
|
||||
return false;
|
||||
}
|
||||
SetBitmapFormat();
|
||||
NOTICE_LOG(VIDEO, "Setting video format...");
|
||||
if (!SetVideoFormat()) {
|
||||
NOTICE_LOG(VIDEO, "Setting video format failed");
|
||||
Stop();
|
||||
return false;
|
||||
}
|
||||
if (!m_fileCount) {
|
||||
if (!SetCompressionOptions()) {
|
||||
NOTICE_LOG(VIDEO, "SetCompressionOptions failed");
|
||||
Stop();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (FAILED(AVIMakeCompressedStream(&m_streamCompressed, m_stream, &m_options, NULL))) {
|
||||
NOTICE_LOG(VIDEO, "AVIMakeCompressedStream failed");
|
||||
Stop();
|
||||
return false;
|
||||
}
|
||||
if (FAILED(AVIStreamSetFormat(m_streamCompressed, 0, &m_bitmap, m_bitmap.biSize))) {
|
||||
NOTICE_LOG(VIDEO, "AVIStreamSetFormat failed");
|
||||
Stop();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void AVIDump::CloseFile()
|
||||
{
|
||||
if (m_streamCompressed) {
|
||||
AVIStreamClose(m_streamCompressed);
|
||||
m_streamCompressed = NULL;
|
||||
}
|
||||
if (m_stream) {
|
||||
AVIStreamClose(m_stream);
|
||||
m_stream = NULL;
|
||||
}
|
||||
if (m_file) {
|
||||
AVIFileRelease(m_file);
|
||||
m_file = NULL;
|
||||
}
|
||||
AVIFileExit();
|
||||
}
|
||||
|
||||
void AVIDump::Stop()
|
||||
{
|
||||
CloseFile();
|
||||
m_fileCount = 0;
|
||||
NOTICE_LOG(VIDEO, "Stop");
|
||||
}
|
||||
|
||||
void AVIDump::AddFrame(char *data)
|
||||
{
|
||||
AVIStreamWrite(m_streamCompressed, ++m_frameCount, 1, (LPVOID) data, m_bitmap.biSizeImage, AVIIF_KEYFRAME, NULL, &m_byteBuffer);
|
||||
m_totalBytes += m_byteBuffer;
|
||||
// Close the recording if the file is more than 2gb
|
||||
// VfW can't properly save files over 2gb in size, but can keep writing to them up to 4gb.
|
||||
if (m_totalBytes >= 2000000000) {
|
||||
CloseFile();
|
||||
m_fileCount++;
|
||||
CreateFile();
|
||||
}
|
||||
}
|
||||
|
||||
void AVIDump::SetBitmapFormat()
|
||||
{
|
||||
memset(&m_bitmap, 0, sizeof(m_bitmap));
|
||||
m_bitmap.biSize = 0x28;
|
||||
m_bitmap.biPlanes = 1;
|
||||
m_bitmap.biBitCount = 24;
|
||||
m_bitmap.biWidth = m_width;
|
||||
m_bitmap.biHeight = m_height;
|
||||
m_bitmap.biSizeImage = 3 * m_width * m_height;
|
||||
}
|
||||
|
||||
bool AVIDump::SetCompressionOptions()
|
||||
{
|
||||
memset(&m_options, 0, sizeof(m_options));
|
||||
m_arrayOptions[0] = &m_options;
|
||||
|
||||
return (AVISaveOptions(m_emuWnd, 0, 1, &m_stream, m_arrayOptions) != 0);
|
||||
}
|
||||
|
||||
bool AVIDump::SetVideoFormat()
|
||||
{
|
||||
memset(&m_header, 0, sizeof(m_header));
|
||||
m_header.fccType = streamtypeVIDEO;
|
||||
m_header.dwScale = 1;
|
||||
// TODO: Decect FPS using NTSC/PAL
|
||||
m_header.dwRate = 60;
|
||||
m_header.dwSuggestedBufferSize = m_bitmap.biSizeImage;
|
||||
|
||||
return SUCCEEDED(AVIFileCreateStream(m_file, &m_stream, &m_header));
|
||||
}
|
||||
// Copyright (C) 2003-2009 Dolphin Project.
|
||||
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, version 2.0.
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License 2.0 for more details.
|
||||
|
||||
// A copy of the GPL 2.0 should have been included with the program.
|
||||
// If not, see http://www.gnu.org/licenses/
|
||||
|
||||
// Official SVN repository and contact information can be found at
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
#include "AVIDump.h"
|
||||
#include "tchar.h"
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <vfw.h>
|
||||
#include <winerror.h>
|
||||
|
||||
#include "FileUtil.h"
|
||||
#include "CommonPaths.h"
|
||||
#include "Log.h"
|
||||
|
||||
static HWND m_emuWnd;
|
||||
static int m_width;
|
||||
static int m_height;
|
||||
static LONG m_byteBuffer;
|
||||
static LONG m_frameCount;
|
||||
static LONG m_totalBytes;
|
||||
static PAVIFILE m_file;
|
||||
static int m_fileCount;
|
||||
static PAVISTREAM m_stream;
|
||||
static PAVISTREAM m_streamCompressed;
|
||||
static AVISTREAMINFO m_header;
|
||||
static AVICOMPRESSOPTIONS m_options;
|
||||
static AVICOMPRESSOPTIONS *m_arrayOptions[1];
|
||||
static BITMAPINFOHEADER m_bitmap;
|
||||
|
||||
bool AVIDump::Start(HWND hWnd, int w, int h)
|
||||
{
|
||||
m_emuWnd = hWnd;
|
||||
m_fileCount = 0;
|
||||
|
||||
m_width = w;
|
||||
m_height = h;
|
||||
|
||||
return CreateFile();
|
||||
}
|
||||
|
||||
bool AVIDump::CreateFile()
|
||||
{
|
||||
m_totalBytes = 0;
|
||||
m_frameCount = 0;
|
||||
char movie_file_name[255];
|
||||
sprintf(movie_file_name, "%s/framedump%d.avi", FULL_FRAMES_DIR, m_fileCount);
|
||||
// Create path
|
||||
File::CreateFullPath(movie_file_name);
|
||||
|
||||
// Ask to delete file
|
||||
if (File::Exists(movie_file_name))
|
||||
{
|
||||
if (AskYesNo("Delete the existing file '%s'?", movie_file_name))
|
||||
File::Delete(movie_file_name);
|
||||
}
|
||||
|
||||
AVIFileInit();
|
||||
NOTICE_LOG(VIDEO, "Opening AVI file (%s) for dumping", movie_file_name);
|
||||
// TODO: Make this work with AVIFileOpenW without it throwing REGDB_E_CLASSNOTREG
|
||||
HRESULT hr = AVIFileOpenA(&m_file, movie_file_name, OF_WRITE | OF_CREATE, NULL);
|
||||
if (FAILED(hr)) {
|
||||
if (hr == AVIERR_BADFORMAT) NOTICE_LOG(VIDEO, "The file couldn't be read, indicating a corrupt file or an unrecognized format.");
|
||||
if (hr == AVIERR_MEMORY) NOTICE_LOG(VIDEO, "The file could not be opened because of insufficient memory.");
|
||||
if (hr == AVIERR_FILEREAD) NOTICE_LOG(VIDEO, "A disk error occurred while reading the file.");
|
||||
if (hr == AVIERR_FILEOPEN) NOTICE_LOG(VIDEO, "A disk error occurred while opening the file.");
|
||||
if (hr == REGDB_E_CLASSNOTREG) NOTICE_LOG(VIDEO, "AVI class not registered");
|
||||
Stop();
|
||||
return false;
|
||||
}
|
||||
SetBitmapFormat();
|
||||
NOTICE_LOG(VIDEO, "Setting video format...");
|
||||
if (!SetVideoFormat()) {
|
||||
NOTICE_LOG(VIDEO, "Setting video format failed");
|
||||
Stop();
|
||||
return false;
|
||||
}
|
||||
if (!m_fileCount) {
|
||||
if (!SetCompressionOptions()) {
|
||||
NOTICE_LOG(VIDEO, "SetCompressionOptions failed");
|
||||
Stop();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (FAILED(AVIMakeCompressedStream(&m_streamCompressed, m_stream, &m_options, NULL))) {
|
||||
NOTICE_LOG(VIDEO, "AVIMakeCompressedStream failed");
|
||||
Stop();
|
||||
return false;
|
||||
}
|
||||
if (FAILED(AVIStreamSetFormat(m_streamCompressed, 0, &m_bitmap, m_bitmap.biSize))) {
|
||||
NOTICE_LOG(VIDEO, "AVIStreamSetFormat failed");
|
||||
Stop();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void AVIDump::CloseFile()
|
||||
{
|
||||
if (m_streamCompressed) {
|
||||
AVIStreamClose(m_streamCompressed);
|
||||
m_streamCompressed = NULL;
|
||||
}
|
||||
if (m_stream) {
|
||||
AVIStreamClose(m_stream);
|
||||
m_stream = NULL;
|
||||
}
|
||||
if (m_file) {
|
||||
AVIFileRelease(m_file);
|
||||
m_file = NULL;
|
||||
}
|
||||
AVIFileExit();
|
||||
}
|
||||
|
||||
void AVIDump::Stop()
|
||||
{
|
||||
CloseFile();
|
||||
m_fileCount = 0;
|
||||
NOTICE_LOG(VIDEO, "Stop");
|
||||
}
|
||||
|
||||
void AVIDump::AddFrame(char *data)
|
||||
{
|
||||
AVIStreamWrite(m_streamCompressed, ++m_frameCount, 1, (LPVOID) data, m_bitmap.biSizeImage, AVIIF_KEYFRAME, NULL, &m_byteBuffer);
|
||||
m_totalBytes += m_byteBuffer;
|
||||
// Close the recording if the file is more than 2gb
|
||||
// VfW can't properly save files over 2gb in size, but can keep writing to them up to 4gb.
|
||||
if (m_totalBytes >= 2000000000) {
|
||||
CloseFile();
|
||||
m_fileCount++;
|
||||
CreateFile();
|
||||
}
|
||||
}
|
||||
|
||||
void AVIDump::SetBitmapFormat()
|
||||
{
|
||||
memset(&m_bitmap, 0, sizeof(m_bitmap));
|
||||
m_bitmap.biSize = 0x28;
|
||||
m_bitmap.biPlanes = 1;
|
||||
m_bitmap.biBitCount = 24;
|
||||
m_bitmap.biWidth = m_width;
|
||||
m_bitmap.biHeight = m_height;
|
||||
m_bitmap.biSizeImage = 3 * m_width * m_height;
|
||||
}
|
||||
|
||||
bool AVIDump::SetCompressionOptions()
|
||||
{
|
||||
memset(&m_options, 0, sizeof(m_options));
|
||||
m_arrayOptions[0] = &m_options;
|
||||
|
||||
return (AVISaveOptions(m_emuWnd, 0, 1, &m_stream, m_arrayOptions) != 0);
|
||||
}
|
||||
|
||||
bool AVIDump::SetVideoFormat()
|
||||
{
|
||||
memset(&m_header, 0, sizeof(m_header));
|
||||
m_header.fccType = streamtypeVIDEO;
|
||||
m_header.dwScale = 1;
|
||||
// TODO: Decect FPS using NTSC/PAL
|
||||
m_header.dwRate = 60;
|
||||
m_header.dwSuggestedBufferSize = m_bitmap.biSizeImage;
|
||||
|
||||
return SUCCEEDED(AVIFileCreateStream(m_file, &m_stream, &m_header));
|
||||
}
|
||||
|
@ -1,60 +1,60 @@
|
||||
// Copyright (C) 2003-2009 Dolphin Project.
|
||||
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, version 2.0.
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License 2.0 for more details.
|
||||
|
||||
// A copy of the GPL 2.0 should have been included with the program.
|
||||
// If not, see http://www.gnu.org/licenses/
|
||||
|
||||
// Official SVN repository and contact information can be found at
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
|
||||
// ------------------------------------------
|
||||
// The plugins has to define these functions
|
||||
// ------------------------------------------
|
||||
|
||||
#ifndef _BPFUNCTIONS_H_
|
||||
#define _BPFUNCTIONS_H_
|
||||
|
||||
#include "BPMemory.h"
|
||||
#include "VideoCommon.h"
|
||||
|
||||
namespace BPFunctions
|
||||
{
|
||||
|
||||
enum
|
||||
{
|
||||
CONFIG_ISWII = 0,
|
||||
CONFIG_DISABLEFOG,
|
||||
CONFIG_SHOWEFBREGIONS
|
||||
};
|
||||
|
||||
void FlushPipeline();
|
||||
void SetGenerationMode(const Bypass &bp);
|
||||
void SetScissor(const Bypass &bp);
|
||||
void SetLineWidth(const Bypass &bp);
|
||||
void SetDepthMode(const Bypass &bp);
|
||||
void SetBlendMode(const Bypass &bp);
|
||||
void SetDitherMode(const Bypass &bp);
|
||||
void SetLogicOpMode(const Bypass &bp);
|
||||
void SetColorMask(const Bypass &bp);
|
||||
float GetRendererTargetScaleX();
|
||||
float GetRendererTargetScaleY();
|
||||
void CopyEFB(const Bypass &bp, const TRectangle &rc, const u32 &address, const bool &fromZBuffer, const bool &isIntensityFmt, const u32 ©fmt, const bool &scaleByHalf);
|
||||
void RenderToXFB(const Bypass &bp, const TRectangle &multirc, const float &yScale, const float &xfbLines, u32 xfbAddr, const u32 &dstWidth, const u32 &dstHeight);
|
||||
void ClearScreen(const Bypass &bp, const TRectangle &multirc);
|
||||
void RestoreRenderState(const Bypass &bp);
|
||||
u8 *GetPointer(const u32 &address);
|
||||
bool GetConfig(const int &type);
|
||||
void SetSamplerState(const Bypass &bp);
|
||||
void SetInterlacingMode(const Bypass &bp);
|
||||
};
|
||||
|
||||
// Copyright (C) 2003-2009 Dolphin Project.
|
||||
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, version 2.0.
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License 2.0 for more details.
|
||||
|
||||
// A copy of the GPL 2.0 should have been included with the program.
|
||||
// If not, see http://www.gnu.org/licenses/
|
||||
|
||||
// Official SVN repository and contact information can be found at
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
|
||||
// ------------------------------------------
|
||||
// The plugins has to define these functions
|
||||
// ------------------------------------------
|
||||
|
||||
#ifndef _BPFUNCTIONS_H_
|
||||
#define _BPFUNCTIONS_H_
|
||||
|
||||
#include "BPMemory.h"
|
||||
#include "VideoCommon.h"
|
||||
|
||||
namespace BPFunctions
|
||||
{
|
||||
|
||||
enum
|
||||
{
|
||||
CONFIG_ISWII = 0,
|
||||
CONFIG_DISABLEFOG,
|
||||
CONFIG_SHOWEFBREGIONS
|
||||
};
|
||||
|
||||
void FlushPipeline();
|
||||
void SetGenerationMode(const Bypass &bp);
|
||||
void SetScissor(const Bypass &bp);
|
||||
void SetLineWidth(const Bypass &bp);
|
||||
void SetDepthMode(const Bypass &bp);
|
||||
void SetBlendMode(const Bypass &bp);
|
||||
void SetDitherMode(const Bypass &bp);
|
||||
void SetLogicOpMode(const Bypass &bp);
|
||||
void SetColorMask(const Bypass &bp);
|
||||
float GetRendererTargetScaleX();
|
||||
float GetRendererTargetScaleY();
|
||||
void CopyEFB(const Bypass &bp, const TRectangle &rc, const u32 &address, const bool &fromZBuffer, const bool &isIntensityFmt, const u32 ©fmt, const bool &scaleByHalf);
|
||||
void RenderToXFB(const Bypass &bp, const TRectangle &multirc, const float &yScale, const float &xfbLines, u32 xfbAddr, const u32 &dstWidth, const u32 &dstHeight);
|
||||
void ClearScreen(const Bypass &bp, const TRectangle &multirc);
|
||||
void RestoreRenderState(const Bypass &bp);
|
||||
u8 *GetPointer(const u32 &address);
|
||||
bool GetConfig(const int &type);
|
||||
void SetSamplerState(const Bypass &bp);
|
||||
void SetInterlacingMode(const Bypass &bp);
|
||||
};
|
||||
|
||||
#endif // _BPFUNCTIONS_H_
|
File diff suppressed because it is too large
Load Diff
@ -1,27 +1,27 @@
|
||||
// Copyright (C) 2003-2009 Dolphin Project.
|
||||
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, version 2.0.
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License 2.0 for more details.
|
||||
|
||||
// A copy of the GPL 2.0 should have been included with the program.
|
||||
// If not, see http://www.gnu.org/licenses/
|
||||
|
||||
// Official SVN repository and contact information can be found at
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
#ifndef _BPSTRUCTS_H_
|
||||
#define _BPSTRUCTS_H_
|
||||
|
||||
#include "BPMemory.h"
|
||||
|
||||
void BPInit();
|
||||
void LoadBPReg(u32 value0);
|
||||
void BPReload();
|
||||
|
||||
#endif // _BPSTRUCTS_H_
|
||||
// Copyright (C) 2003-2009 Dolphin Project.
|
||||
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, version 2.0.
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License 2.0 for more details.
|
||||
|
||||
// A copy of the GPL 2.0 should have been included with the program.
|
||||
// If not, see http://www.gnu.org/licenses/
|
||||
|
||||
// Official SVN repository and contact information can be found at
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
#ifndef _BPSTRUCTS_H_
|
||||
#define _BPSTRUCTS_H_
|
||||
|
||||
#include "BPMemory.h"
|
||||
|
||||
void BPInit();
|
||||
void LoadBPReg(u32 value0);
|
||||
void BPReload();
|
||||
|
||||
#endif // _BPSTRUCTS_H_
|
||||
|
@ -1,154 +1,154 @@
|
||||
// Copyright (C) 2003-2009 Dolphin Project.
|
||||
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, version 2.0.
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License 2.0 for more details.
|
||||
|
||||
// A copy of the GPL 2.0 should have been included with the program.
|
||||
// If not, see http://www.gnu.org/licenses/
|
||||
|
||||
// Official SVN repository and contact information can be found at
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
#include "HiresTextures.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <utility>
|
||||
#include <algorithm>
|
||||
#include "SOIL.h"
|
||||
#include "CommonPaths.h"
|
||||
#include "FileUtil.h"
|
||||
#include "FileSearch.h"
|
||||
|
||||
namespace HiresTextures
|
||||
{
|
||||
|
||||
std::map<std::string, std::string> textureMap;
|
||||
|
||||
void Init(const char *gameCode)
|
||||
{
|
||||
static bool bCheckedDir;
|
||||
|
||||
CFileSearch::XStringVector Directories;
|
||||
//Directories.push_back(std::string(FULL_HIRES_TEXTURES_DIR));
|
||||
char szDir[MAX_PATH];
|
||||
sprintf(szDir,"%s/%s",FULL_HIRES_TEXTURES_DIR,gameCode);
|
||||
Directories.push_back(std::string(szDir));
|
||||
|
||||
|
||||
for (u32 i = 0; i < Directories.size(); i++)
|
||||
{
|
||||
File::FSTEntry FST_Temp;
|
||||
File::ScanDirectoryTree(Directories.at(i).c_str(), FST_Temp);
|
||||
for (u32 j = 0; j < FST_Temp.children.size(); j++)
|
||||
{
|
||||
if (FST_Temp.children.at(j).isDirectory)
|
||||
{
|
||||
bool duplicate = false;
|
||||
NormalizeDirSep(&(FST_Temp.children.at(j).physicalName));
|
||||
for (u32 k = 0; k < Directories.size(); k++)
|
||||
{
|
||||
NormalizeDirSep(&Directories.at(k));
|
||||
if (strcmp(Directories.at(k).c_str(), FST_Temp.children.at(j).physicalName.c_str()) == 0)
|
||||
{
|
||||
duplicate = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!duplicate)
|
||||
Directories.push_back(FST_Temp.children.at(j).physicalName.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CFileSearch::XStringVector Extensions;
|
||||
Extensions.push_back("*.png");
|
||||
Extensions.push_back("*.bmp");
|
||||
Extensions.push_back("*.tga");
|
||||
Extensions.push_back("*.dds");
|
||||
Extensions.push_back("*.jpg"); // Why not? Could be useful for large photo-like textures
|
||||
|
||||
CFileSearch FileSearch(Extensions, Directories);
|
||||
const CFileSearch::XStringVector& rFilenames = FileSearch.GetFileNames();
|
||||
char code[MAX_PATH];
|
||||
sprintf(code, "%s_", gameCode);
|
||||
|
||||
if (rFilenames.size() > 0)
|
||||
{
|
||||
for (u32 i = 0; i < rFilenames.size(); i++)
|
||||
{
|
||||
std::string FileName;
|
||||
SplitPath(rFilenames[i], NULL, &FileName, NULL);
|
||||
|
||||
if (FileName.substr(0, strlen(code)).compare(code) == 0 && textureMap.find(FileName) == textureMap.end())
|
||||
textureMap.insert(std::map<std::string, std::string>::value_type(FileName, rFilenames[i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Shutdown()
|
||||
{
|
||||
textureMap.clear();
|
||||
}
|
||||
|
||||
PC_TexFormat GetHiresTex(const char *fileName, int *pWidth, int *pHeight, int texformat, u8 *data)
|
||||
{
|
||||
std::string key(fileName);
|
||||
|
||||
if(textureMap.find(key) == textureMap.end())
|
||||
return PC_TEX_FMT_NONE;
|
||||
|
||||
int width;
|
||||
int height;
|
||||
int channels;
|
||||
|
||||
u8 *temp = SOIL_load_image(textureMap[key].c_str(), &width, &height, &channels, SOIL_LOAD_RGBA);
|
||||
|
||||
if (temp == NULL) {
|
||||
ERROR_LOG(VIDEO, "Custom texture %s failed to load", textureMap[key].c_str(), width, height);
|
||||
SOIL_free_image_data(temp);
|
||||
return PC_TEX_FMT_NONE;
|
||||
}
|
||||
|
||||
if (width > 1024 || height > 1024) {
|
||||
ERROR_LOG(VIDEO, "Custom texture %s is too large (%ix%i); textures can only be 1024 pixels tall and wide", textureMap[key].c_str(), width, height);
|
||||
SOIL_free_image_data(temp);
|
||||
return PC_TEX_FMT_NONE;
|
||||
}
|
||||
|
||||
int offset = 0;
|
||||
PC_TexFormat returnTex;
|
||||
|
||||
switch (texformat)
|
||||
{
|
||||
case GX_TF_I4:
|
||||
case GX_TF_I8:
|
||||
case GX_TF_IA4:
|
||||
case GX_TF_IA8:
|
||||
for (int i = 0; i < width * height * 4; i += 4)
|
||||
{
|
||||
// Rather than use a luminosity function, just use the most intense color for luminance
|
||||
data[offset++] = *std::max_element(temp+i, temp+i+3);
|
||||
data[offset++] = temp[i+3];
|
||||
}
|
||||
returnTex = PC_TEX_FMT_IA8;
|
||||
break;
|
||||
default:
|
||||
memcpy(data, temp, width*height*4);
|
||||
returnTex = PC_TEX_FMT_RGBA32;
|
||||
break;
|
||||
}
|
||||
|
||||
*pWidth = width;
|
||||
*pHeight = height;
|
||||
SOIL_free_image_data(temp);
|
||||
INFO_LOG(VIDEO, "loading custom texture from %s", textureMap[key].c_str());
|
||||
return returnTex;
|
||||
}
|
||||
|
||||
}
|
||||
// Copyright (C) 2003-2009 Dolphin Project.
|
||||
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, version 2.0.
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License 2.0 for more details.
|
||||
|
||||
// A copy of the GPL 2.0 should have been included with the program.
|
||||
// If not, see http://www.gnu.org/licenses/
|
||||
|
||||
// Official SVN repository and contact information can be found at
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
#include "HiresTextures.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <utility>
|
||||
#include <algorithm>
|
||||
#include "SOIL.h"
|
||||
#include "CommonPaths.h"
|
||||
#include "FileUtil.h"
|
||||
#include "FileSearch.h"
|
||||
|
||||
namespace HiresTextures
|
||||
{
|
||||
|
||||
std::map<std::string, std::string> textureMap;
|
||||
|
||||
void Init(const char *gameCode)
|
||||
{
|
||||
static bool bCheckedDir;
|
||||
|
||||
CFileSearch::XStringVector Directories;
|
||||
//Directories.push_back(std::string(FULL_HIRES_TEXTURES_DIR));
|
||||
char szDir[MAX_PATH];
|
||||
sprintf(szDir,"%s/%s",FULL_HIRES_TEXTURES_DIR,gameCode);
|
||||
Directories.push_back(std::string(szDir));
|
||||
|
||||
|
||||
for (u32 i = 0; i < Directories.size(); i++)
|
||||
{
|
||||
File::FSTEntry FST_Temp;
|
||||
File::ScanDirectoryTree(Directories.at(i).c_str(), FST_Temp);
|
||||
for (u32 j = 0; j < FST_Temp.children.size(); j++)
|
||||
{
|
||||
if (FST_Temp.children.at(j).isDirectory)
|
||||
{
|
||||
bool duplicate = false;
|
||||
NormalizeDirSep(&(FST_Temp.children.at(j).physicalName));
|
||||
for (u32 k = 0; k < Directories.size(); k++)
|
||||
{
|
||||
NormalizeDirSep(&Directories.at(k));
|
||||
if (strcmp(Directories.at(k).c_str(), FST_Temp.children.at(j).physicalName.c_str()) == 0)
|
||||
{
|
||||
duplicate = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!duplicate)
|
||||
Directories.push_back(FST_Temp.children.at(j).physicalName.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CFileSearch::XStringVector Extensions;
|
||||
Extensions.push_back("*.png");
|
||||
Extensions.push_back("*.bmp");
|
||||
Extensions.push_back("*.tga");
|
||||
Extensions.push_back("*.dds");
|
||||
Extensions.push_back("*.jpg"); // Why not? Could be useful for large photo-like textures
|
||||
|
||||
CFileSearch FileSearch(Extensions, Directories);
|
||||
const CFileSearch::XStringVector& rFilenames = FileSearch.GetFileNames();
|
||||
char code[MAX_PATH];
|
||||
sprintf(code, "%s_", gameCode);
|
||||
|
||||
if (rFilenames.size() > 0)
|
||||
{
|
||||
for (u32 i = 0; i < rFilenames.size(); i++)
|
||||
{
|
||||
std::string FileName;
|
||||
SplitPath(rFilenames[i], NULL, &FileName, NULL);
|
||||
|
||||
if (FileName.substr(0, strlen(code)).compare(code) == 0 && textureMap.find(FileName) == textureMap.end())
|
||||
textureMap.insert(std::map<std::string, std::string>::value_type(FileName, rFilenames[i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Shutdown()
|
||||
{
|
||||
textureMap.clear();
|
||||
}
|
||||
|
||||
PC_TexFormat GetHiresTex(const char *fileName, int *pWidth, int *pHeight, int texformat, u8 *data)
|
||||
{
|
||||
std::string key(fileName);
|
||||
|
||||
if(textureMap.find(key) == textureMap.end())
|
||||
return PC_TEX_FMT_NONE;
|
||||
|
||||
int width;
|
||||
int height;
|
||||
int channels;
|
||||
|
||||
u8 *temp = SOIL_load_image(textureMap[key].c_str(), &width, &height, &channels, SOIL_LOAD_RGBA);
|
||||
|
||||
if (temp == NULL) {
|
||||
ERROR_LOG(VIDEO, "Custom texture %s failed to load", textureMap[key].c_str(), width, height);
|
||||
SOIL_free_image_data(temp);
|
||||
return PC_TEX_FMT_NONE;
|
||||
}
|
||||
|
||||
if (width > 1024 || height > 1024) {
|
||||
ERROR_LOG(VIDEO, "Custom texture %s is too large (%ix%i); textures can only be 1024 pixels tall and wide", textureMap[key].c_str(), width, height);
|
||||
SOIL_free_image_data(temp);
|
||||
return PC_TEX_FMT_NONE;
|
||||
}
|
||||
|
||||
int offset = 0;
|
||||
PC_TexFormat returnTex;
|
||||
|
||||
switch (texformat)
|
||||
{
|
||||
case GX_TF_I4:
|
||||
case GX_TF_I8:
|
||||
case GX_TF_IA4:
|
||||
case GX_TF_IA8:
|
||||
for (int i = 0; i < width * height * 4; i += 4)
|
||||
{
|
||||
// Rather than use a luminosity function, just use the most intense color for luminance
|
||||
data[offset++] = *std::max_element(temp+i, temp+i+3);
|
||||
data[offset++] = temp[i+3];
|
||||
}
|
||||
returnTex = PC_TEX_FMT_IA8;
|
||||
break;
|
||||
default:
|
||||
memcpy(data, temp, width*height*4);
|
||||
returnTex = PC_TEX_FMT_RGBA32;
|
||||
break;
|
||||
}
|
||||
|
||||
*pWidth = width;
|
||||
*pHeight = height;
|
||||
SOIL_free_image_data(temp);
|
||||
INFO_LOG(VIDEO, "loading custom texture from %s", textureMap[key].c_str());
|
||||
return returnTex;
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user