From c399184e6ad9b02041f6d74235fb7812ef68808d Mon Sep 17 00:00:00 2001 From: gabest Date: Thu, 4 Sep 2008 22:09:02 +0000 Subject: [PATCH] --- cdvd/SettingsDlg.cpp | 194 +++++++++++++++++++++++ cdvd/SettingsDlg.h | 36 +++++ cdvd/cdvd.cpp | 334 +++++++++++++++++++++------------------- cdvd/cdvd.h | 30 ++++ cdvd/cdvd.rc | 54 +++++-- cdvd/cdvd_vs2008.vcproj | 8 + cdvd/resource.h | 10 +- gsdx/GSCrc.cpp | 3 +- gsdx/GSRasterizer.cpp | 77 +++------ gsdx/GSRasterizer.h | 2 +- 10 files changed, 515 insertions(+), 233 deletions(-) create mode 100644 cdvd/SettingsDlg.cpp create mode 100644 cdvd/SettingsDlg.h diff --git a/cdvd/SettingsDlg.cpp b/cdvd/SettingsDlg.cpp new file mode 100644 index 0000000..3b41539 --- /dev/null +++ b/cdvd/SettingsDlg.cpp @@ -0,0 +1,194 @@ +// SettingsDlg.cpp : implementation file +// + +#include "stdafx.h" +#include "cdvd.h" +#include "SettingsDlg.h" +#include +#include + +// CSettingsDlg dialog + +IMPLEMENT_DYNAMIC(CSettingsDlg, CDialog) + +CSettingsDlg::CSettingsDlg(CWnd* pParent /*=NULL*/) + : CDialog(CSettingsDlg::IDD, pParent) + , m_iso(_T("")) +{ + +} + +CSettingsDlg::~CSettingsDlg() +{ +} + +BOOL CSettingsDlg::OnInitDialog() +{ + __super::OnInitDialog(); + + InitDrive(); + InitISO(); + + UpdateData(FALSE); + + return TRUE; // return TRUE unless you set the focus to a control + // EXCEPTION: OCX Property Pages should return FALSE +} + +void CSettingsDlg::InitDrive() +{ + int drive = AfxGetApp()->GetProfileInt(_T("Settings"), _T("drive"), -1); + + int sel = m_drive.GetCurSel(); + + if(sel >= 0) + { + drive = m_drive.GetItemData(sel); + } + + while(m_drive.GetCount() > 0) + { + m_drive.DeleteString(0); + } + + for(int i = 'A'; i <= 'Z'; i++) + { + CString path; + + path.Format(_T("%c:"), i); + + if(GetDriveType(path) == DRIVE_CDROM) + { + CString label = path; + + path.Format(_T("\\\\.\\%c:"), i); + + CDVD cdvd; + + if(cdvd.Open(path)) + { + CString str = cdvd.GetLabel(); + + if(str.IsEmpty()) + { + str = _T("(no label)"); + } + + label.Format(_T("[%s] %s"), CString(label), str); + } + else + { + label.Format(_T("[%s] (not detected)"), CString(label)); + } + + m_drive.SetItemData(m_drive.AddString(label), (DWORD_PTR)i); + } + } + + m_drive.SetItemData(m_drive.AddString(_T("Other...")), (DWORD_PTR)-1); + + for(int i = 0, j = m_drive.GetCount(); i < j; i++) + { + if((int)m_drive.GetItemData(i) == drive) + { + m_drive.SetCurSel(i); + + return; + } + } + + m_drive.SetCurSel(-1); +} + +void CSettingsDlg::InitISO() +{ + m_iso = AfxGetApp()->GetProfileString(_T("Settings"), _T("iso"), _T("")); +} + +void CSettingsDlg::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + DDX_Control(pDX, IDC_COMBO1, m_drive); + DDX_Text(pDX, IDC_EDIT1, m_iso); +} + +BEGIN_MESSAGE_MAP(CSettingsDlg, CDialog) + ON_BN_CLICKED(IDC_BUTTON1, &CSettingsDlg::OnBrowse) + ON_BN_CLICKED(IDOK, &CSettingsDlg::OnBnClickedOk) +END_MESSAGE_MAP() + +// CSettingsDlg message handlers + +LRESULT CSettingsDlg::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) +{ + if(message == WM_DEVICECHANGE) + { + if(wParam == DBT_DEVICEARRIVAL || wParam == DBT_DEVICEREMOVECOMPLETE) + { + InitDrive(); + + DEV_BROADCAST_HDR* p = (DEV_BROADCAST_HDR*)lParam; + + if(p->dbch_devicetype == DBT_DEVTYP_VOLUME) + { + DEV_BROADCAST_VOLUME* v = (DEV_BROADCAST_VOLUME*)p; + + for(int i = 0; i < 32; i++) + { + if(v->dbcv_unitmask & (1 << i)) + { + TRACE(_T("%c:\n"), 'A' + i); + + // TODO + } + } + } + } + } + + return __super::WindowProc(message, wParam, lParam); +} + +void CSettingsDlg::OnBrowse() +{ + UpdateData(); + + CFileDialog fd(TRUE, NULL, m_iso, + OFN_EXPLORER | OFN_ENABLESIZING | OFN_HIDEREADONLY, + _T("ISO file|*.iso|All files|*.*|"), this); + + if(fd.DoModal() == IDOK) + { + m_iso = fd.GetPathName(); + + UpdateData(FALSE); + + for(int i = 0, j = m_drive.GetCount(); i < j; i++) + { + if((int)m_drive.GetItemData(i) < 0) + { + m_drive.SetCurSel(i); + + break; + } + } + } +} + +void CSettingsDlg::OnBnClickedOk() +{ + UpdateData(); + + int i = m_drive.GetCurSel(); + + if(i >= 0) + { + i = (int)m_drive.GetItemData(i); + } + + AfxGetApp()->WriteProfileInt(_T("Settings"), _T("drive"), i); + + AfxGetApp()->WriteProfileString(_T("Settings"), _T("iso"), m_iso); + + OnOK(); +} diff --git a/cdvd/SettingsDlg.h b/cdvd/SettingsDlg.h new file mode 100644 index 0000000..2ff9c87 --- /dev/null +++ b/cdvd/SettingsDlg.h @@ -0,0 +1,36 @@ +#pragma once +#include "afxwin.h" +#include "resource.h" + +// CSettingsDlg dialog + +class CSettingsDlg : public CDialog +{ + DECLARE_DYNAMIC(CSettingsDlg) + +protected: + void InitDrive(); + void InitISO(); + +public: + CSettingsDlg(CWnd* pParent = NULL); // standard constructor + virtual ~CSettingsDlg(); + + virtual BOOL OnInitDialog(); + + enum { IDD = IDD_CONFIG }; + + CComboBox m_drive; + CString m_iso; + +protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + + DECLARE_MESSAGE_MAP() + + LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam); + + afx_msg void OnBrowse(); +public: + afx_msg void OnBnClickedOk(); +}; diff --git a/cdvd/cdvd.cpp b/cdvd/cdvd.cpp index b229c05..0dce970 100644 --- a/cdvd/cdvd.cpp +++ b/cdvd/cdvd.cpp @@ -21,6 +21,7 @@ #include "stdafx.h" #include "cdvd.h" +#include "SettingsDlg.h" #include #ifdef _DEBUG @@ -98,190 +99,189 @@ EXPORT_C_(UINT32) PS2EgetLibVersion2(UINT32 type) // -#define CACHE_BLOCK_COUNT 16 - -static class CDVD +CDVD::CDVD() + : m_hFile(INVALID_HANDLE_VALUE) { - HANDLE m_hFile; - OVERLAPPED m_overlapped; - struct {int count, size, offset;} m_block; - struct {BYTE buff[2048 * CACHE_BLOCK_COUNT]; bool pending; int start, count;} m_cache; - BYTE m_buff[2352]; + memset(&m_overlapped, 0, sizeof(m_overlapped)); + m_overlapped.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL); + m_cache.pending = false; + m_cache.count = 0; +} - LARGE_INTEGER MakeOffset(int lsn) +CDVD::~CDVD() +{ + CloseHandle(m_overlapped.hEvent); +} + +LARGE_INTEGER CDVD::MakeOffset(int lsn) +{ + LARGE_INTEGER offset; + offset.QuadPart = (LONGLONG)lsn * m_block.size + m_block.offset; + return offset; +} + +bool CDVD::SyncRead(int lsn) +{ + return Read(lsn) && GetBuffer(); +} + +bool CDVD::Open(CString path) +{ + m_label.Empty(); + + DWORD share = FILE_SHARE_READ; + DWORD flags = FILE_ATTRIBUTE_READONLY | FILE_FLAG_SEQUENTIAL_SCAN | FILE_FLAG_OVERLAPPED; + + m_hFile = CreateFile(path, GENERIC_READ, share, NULL, OPEN_EXISTING, flags, (HANDLE)NULL); + + if(m_hFile == INVALID_HANDLE_VALUE) { - LARGE_INTEGER offset; - offset.QuadPart = (LONGLONG)lsn * m_block.size + m_block.offset; - return offset; + return false; } - bool SyncRead(int lsn) + m_block.count = 0; + m_block.size = 2048; + m_block.offset = 0; + + GET_LENGTH_INFORMATION info; + DWORD ret = 0; + + if(GetFileSizeEx(m_hFile, &info.Length) || DeviceIoControl(m_hFile, IOCTL_DISK_GET_LENGTH_INFO, NULL, 0, &info, sizeof(info), &ret, NULL)) { - return Read(lsn) && GetBuffer(); + m_block.count = (int)(info.Length.QuadPart / m_block.size); + } + else + { + Close(); + + return false; } -public: - CDVD() - : m_hFile(INVALID_HANDLE_VALUE) + if(!SyncRead(16) || memcmp(&m_buff[24 + 1], "CD001", 5) != 0) { - memset(&m_overlapped, 0, sizeof(m_overlapped)); - m_overlapped.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL); + Close(); + + return false; + } + + m_label = CString(CStringA((char*)&m_buff[24 + 40], 32)); + m_label.Trim(); + + // m_block.count = *(DWORD*)&m_buff[24 + 80]; + + return true; +} + +void CDVD::Close() +{ + if(m_hFile != INVALID_HANDLE_VALUE) + { + CancelIo(m_hFile); + CloseHandle(m_hFile); + m_hFile = INVALID_HANDLE_VALUE; + } + + m_cache.pending = false; + m_cache.count = 0; + + m_label.Empty(); +} + +CString CDVD::GetLabel() +{ + return m_label; +} + +bool CDVD::Read(int lsn, int mode) +{ + if(mode != CDVD_MODE_2048) return false; + + if(lsn < 0) lsn += m_block.count; + + if(lsn < 0 || lsn >= m_block.count) return false; + + if(m_cache.pending) + { + CancelIo(m_hFile); + ResetEvent(m_overlapped.hEvent); m_cache.pending = false; - m_cache.count = 0; } - virtual ~CDVD() + if(lsn >= m_cache.start && lsn < m_cache.start + m_cache.count) { - CloseHandle(m_overlapped.hEvent); - } - - bool Open() - { - CString path = _T("\\\\.\\H:"); // TODO: config dialog - - DWORD share = FILE_SHARE_READ; - DWORD flags = FILE_ATTRIBUTE_READONLY | FILE_FLAG_SEQUENTIAL_SCAN | FILE_FLAG_OVERLAPPED; - - m_hFile = CreateFile(path, GENERIC_READ, share, NULL, OPEN_EXISTING, flags, (HANDLE)NULL); - - if(m_hFile == INVALID_HANDLE_VALUE) - { - return false; - } - - m_block.count = 0; - m_block.size = 2048; - m_block.offset = 0; - - GET_LENGTH_INFORMATION info; - DWORD ret = 0; - - if(GetFileSizeEx(m_hFile, &info.Length) || DeviceIoControl(m_hFile, IOCTL_DISK_GET_LENGTH_INFO, NULL, 0, &info, sizeof(info), &ret, NULL)) - { - m_block.count = (int)(info.Length.QuadPart / m_block.size); - } - else - { - Close(); - - return false; - } - - if(!SyncRead(16) || memcmp(&m_buff[24 + 1], "CD001", 5) != 0) - { - Close(); - - return false; - } - - // m_block.count = *(DWORD*)&m_buff[24 + 80]; + memcpy(&m_buff[24], &m_cache.buff[(lsn - m_cache.start) * 2048], 2048); return true; } - void Close() - { - if(m_hFile != INVALID_HANDLE_VALUE) - { - CancelIo(m_hFile); - CloseHandle(m_hFile); - m_hFile = INVALID_HANDLE_VALUE; - } + m_cache.pending = true; + m_cache.start = lsn; + m_cache.count = min(CACHE_BLOCK_COUNT, m_block.count - m_cache.start); - m_cache.pending = false; - m_cache.count = 0; + LARGE_INTEGER offset = MakeOffset(lsn); + + m_overlapped.Offset = offset.LowPart; + m_overlapped.OffsetHigh = offset.HighPart; + + if(!ReadFile(m_hFile, m_cache.buff, m_cache.count * 2048, NULL, &m_overlapped)) + { + switch(GetLastError()) + { + case ERROR_IO_PENDING: + break; + case ERROR_HANDLE_EOF: + return false; + } } - bool Read(int lsn, int mode = CDVD_MODE_2048) + return true; +} + +BYTE* CDVD::GetBuffer() +{ + DWORD size = 0; + + if(m_cache.pending) { - if(mode != CDVD_MODE_2048) return false; - - if(lsn < 0) lsn += m_block.count; - - if(lsn < 0 || lsn >= m_block.count) return false; - - if(m_cache.pending) + if(GetOverlappedResult(m_hFile, &m_overlapped, &size, TRUE)) { - CancelIo(m_hFile); - ResetEvent(m_overlapped.hEvent); + memcpy(&m_buff[24], m_cache.buff, 2048); + m_cache.pending = false; } - - if(lsn >= m_cache.start && lsn < m_cache.start + m_cache.count) - { - memcpy(&m_buff[24], &m_cache.buff[(lsn - m_cache.start) * 2048], 2048); - - return true; - } - - m_cache.pending = true; - m_cache.start = lsn; - m_cache.count = min(CACHE_BLOCK_COUNT, m_block.count - m_cache.start); - - LARGE_INTEGER offset = MakeOffset(lsn); - - m_overlapped.Offset = offset.LowPart; - m_overlapped.OffsetHigh = offset.HighPart; - - if(!ReadFile(m_hFile, m_cache.buff, m_cache.count * 2048, NULL, &m_overlapped)) - { - switch(GetLastError()) - { - case ERROR_IO_PENDING: - break; - case ERROR_HANDLE_EOF: - return false; - } - } - - return true; - } - - BYTE* GetBuffer() - { - DWORD size = 0; - - if(m_cache.pending) - { - if(GetOverlappedResult(m_hFile, &m_overlapped, &size, TRUE)) - { - memcpy(&m_buff[24], m_cache.buff, 2048); - - m_cache.pending = false; - } - else - { - return NULL; - } - } - - return &m_buff[24]; - } - - UINT32 GetTN(cdvdTN* buff) - { - buff->strack = 1; - buff->etrack = 1; - - return 0; - } - - UINT32 GetTD(BYTE track, cdvdTD* buff) - { - if(track == 0) - { - buff->lsn = m_block.count; - } else { - buff->type = CDVD_MODE1_TRACK; - buff->lsn = 0; + return NULL; } - - return 0; } -} s_cdvd; + return &m_buff[24]; +} + +UINT32 CDVD::GetTN(cdvdTN* buff) +{ + buff->strack = 1; + buff->etrack = 1; + + return 0; +} + +UINT32 CDVD::GetTD(BYTE track, cdvdTD* buff) +{ + if(track == 0) + { + buff->lsn = m_block.count; + } + else + { + buff->type = CDVD_MODE1_TRACK; + buff->lsn = 0; + } + + return 0; +} + +static CDVD s_cdvd; // @@ -296,7 +296,20 @@ EXPORT_C CDVDshutdown() EXPORT_C_(UINT32) CDVDopen(const char* title) { - return s_cdvd.Open() ? 0 : -1; + CString path; + + int i = AfxGetApp()->GetProfileInt(_T("Settings"), _T("drive"), -1); + + if(i >= 'A' && i <= 'Z') + { + path.Format(_T("\\\\.\\%c:"), i); + } + else + { + path = AfxGetApp()->GetProfileString(_T("Settings"), _T("iso"), _T("")); + } + + return s_cdvd.Open(path) ? 0 : -1; } EXPORT_C CDVDclose() @@ -356,6 +369,15 @@ EXPORT_C_(UINT32) CDVDctrlTrayClose() EXPORT_C CDVDconfigure() { + AFX_MANAGE_STATE(AfxGetStaticModuleState()); + + CSettingsDlg dlg; + + if(IDOK == dlg.DoModal()) + { + CDVDshutdown(); + CDVDinit(); + } } EXPORT_C CDVDabout() diff --git a/cdvd/cdvd.h b/cdvd/cdvd.h index 15798b9..1d9a8a5 100644 --- a/cdvd/cdvd.h +++ b/cdvd/cdvd.h @@ -104,3 +104,33 @@ struct cdvdTN #define CDVD_AUDIO_MASK 0x00 #define CDVD_DATA_MASK 0x40 // CDROM_DATA_TRACK 0x04 // do not enable this! (from linux kernel) + +// + +#define CACHE_BLOCK_COUNT 16 + +class CDVD +{ + HANDLE m_hFile; + CString m_label; + OVERLAPPED m_overlapped; + struct {int count, size, offset;} m_block; + struct {BYTE buff[2048 * CACHE_BLOCK_COUNT]; bool pending; int start, count;} m_cache; + BYTE m_buff[2352]; + + LARGE_INTEGER MakeOffset(int lsn); + bool SyncRead(int lsn); + +public: + CDVD(); + virtual ~CDVD(); + + bool Open(CString path); + void Close(); + CString GetLabel(); + bool Read(int lsn, int mode = CDVD_MODE_2048); + BYTE* GetBuffer(); + UINT32 GetTN(cdvdTN* buff); + UINT32 GetTD(BYTE track, cdvdTD* buff); +}; + diff --git a/cdvd/cdvd.rc b/cdvd/cdvd.rc index 50b2df4..9df8f32 100644 --- a/cdvd/cdvd.rc +++ b/cdvd/cdvd.rc @@ -69,21 +69,6 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US #pragma code_page(1252) #endif //_WIN32 -///////////////////////////////////////////////////////////////////////////// -// -// Bitmap -// - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog -// - -///////////////////////////////////////////////////////////////////////////// -// -// DESIGNINFO -// - ///////////////////////////////////////////////////////////////////////////// // // Version @@ -123,6 +108,45 @@ BEGIN END END + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +IDD_CONFIG DIALOGEX 0, 0, 211, 71 +STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Settings..." +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + COMBOBOX IDC_COMBO1,7,7,197,85,CBS_DROPDOWNLIST | WS_VSCROLL | WS_GROUP | WS_TABSTOP + EDITTEXT IDC_EDIT1,7,24,143,14,ES_AUTOHSCROLL | ES_READONLY + PUSHBUTTON "Browse...",IDC_BUTTON1,154,24,50,14 + DEFPUSHBUTTON "OK",IDOK,53,50,50,14 + PUSHBUTTON "Cancel",IDCANCEL,107,50,50,14 +END + + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO +BEGIN + IDD_CONFIG, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 204 + TOPMARGIN, 7 + BOTTOMMARGIN, 64 + HORZGUIDE, 13 + HORZGUIDE, 31 + END +END +#endif // APSTUDIO_INVOKED + #endif // English (U.S.) resources ///////////////////////////////////////////////////////////////////////////// diff --git a/cdvd/cdvd_vs2008.vcproj b/cdvd/cdvd_vs2008.vcproj index 2e20f8f..2d49dbc 100644 --- a/cdvd/cdvd_vs2008.vcproj +++ b/cdvd/cdvd_vs2008.vcproj @@ -1060,6 +1060,10 @@ RelativePath=".\cdvd.def" > + + @@ -1202,6 +1206,10 @@ RelativePath=".\cdvd.h" > + + diff --git a/cdvd/resource.h b/cdvd/resource.h index cb3e074..1aef423 100644 --- a/cdvd/resource.h +++ b/cdvd/resource.h @@ -2,15 +2,19 @@ // Microsoft Visual C++ generated include file. // Used by cdvd.rc // - +#define IDC_COMBO1 2000 +#define IDC_RADIO1 2001 +#define IDC_EDIT1 2003 +#define IDC_BUTTON1 2004 +#define IDD_CONFIG 10000 // Next default values for new objects // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 10000 +#define _APS_NEXT_RESOURCE_VALUE 10001 #define _APS_NEXT_COMMAND_VALUE 32768 -#define _APS_NEXT_CONTROL_VALUE 2000 +#define _APS_NEXT_CONTROL_VALUE 2005 #define _APS_NEXT_SYMED_VALUE 5000 #endif #endif diff --git a/gsdx/GSCrc.cpp b/gsdx/GSCrc.cpp index c584bfd..5bbd881 100644 --- a/gsdx/GSCrc.cpp +++ b/gsdx/GSCrc.cpp @@ -63,7 +63,8 @@ CRC::Game CRC::m_games[] = {0x98D4BC93, MetalGearSolid3, EU, false}, {0x278722BF, DBZBT2, US, false}, {0xFE961D28, DBZBT2, US, false}, - {0X0393B6BE, DBZBT2, EU, false}, + {0x0393B6BE, DBZBT2, EU, false}, + {0xE2F289ED, DBZBT2, JP, false}, // Sparking Neo! {0x428113C2, DBZBT3, US, false}, {0xA422BB13, DBZBT3, EU, false}, {0x983c53d2, DBZBT3, Unknown, false}, diff --git a/gsdx/GSRasterizer.cpp b/gsdx/GSRasterizer.cpp index 428b00e..c7d7930 100644 --- a/gsdx/GSRasterizer.cpp +++ b/gsdx/GSRasterizer.cpp @@ -138,13 +138,17 @@ int GSRasterizer::Draw(Vertex* vertices, int count, const GSTextureCacheSW::GSTe for(int i = 0; i < count; i += 2) { - vertices[i + 0].t /= vertices[i + 1].t.zzzz(); - vertices[i + 1].t /= vertices[i + 1].t.zzzz(); + GSVector4 q = vertices[i + 1].t.zzzz(); + + vertices[i + 0].t /= q; + vertices[i + 1].t /= q; } } if(m_sel.fst && m_sel.ltf) { + // if q is constant we can do the half pel shift for bilinear sampling on the vertices + GSVector4 half(0.5f, 0.5f, 0.0f, 0.0f); for(int i = 0; i < count; i++) @@ -216,7 +220,8 @@ int GSRasterizer::Draw(Vertex* vertices, int count, const GSTextureCacheSW::GSTe // m_slenv - SetupColumnOffset(); + SetupColumnOffset(m_fbco, context->FRAME.Block(), context->FRAME.FBW, context->FRAME.PSM); + SetupColumnOffset(m_zbco, context->ZBUF.Block(), context->FRAME.FBW, context->ZBUF.PSM); m_slenv.steps = 0; m_slenv.vm = m_state->m_mem.m_vm32; @@ -817,85 +822,43 @@ void GSRasterizer::DrawSolidRect(const GSVector4i& r, const Vertex& v) // m_slenv.steps += r.Width() * r.Height(); } -void GSRasterizer::SetupColumnOffset() +void GSRasterizer::SetupColumnOffset(ColumnOffset*& co, DWORD bp, DWORD bw, DWORD psm) { - GSDrawingContext* context = m_state->m_context; + if(bw == 0) {ASSERT(0); return;} - if(context->FRAME.FBW == 0) return; + DWORD hash = bp | (bw << 14) | (psm << 20); - // fb - - DWORD hash = context->FRAME.FBP | (context->FRAME.FBW << 9) | (context->FRAME.PSM << 15); - - if(!m_fbco || m_fbco->hash != hash) + if(!co || co->hash != hash) { CRBMap::CPair* pair = m_comap.Lookup(hash); if(pair) { - m_fbco = pair->m_value; + co = pair->m_value; } else { - m_fbco = (ColumnOffset*)_aligned_malloc(sizeof(ColumnOffset), 16); + co = (ColumnOffset*)_aligned_malloc(sizeof(ColumnOffset), 16); - m_fbco->hash = hash; + co->hash = hash; - GSLocalMemory::pixelAddress pa = GSLocalMemory::m_psm[context->FRAME.PSM].pa; + GSLocalMemory::pixelAddress pa = GSLocalMemory::m_psm[psm].pa; for(int i = 0, j = 1024; i < j; i++) { - m_fbco->row[i] = GSVector4i((int)pa(0, i, context->FRAME.Block(), context->FRAME.FBW)); + co->row[i] = GSVector4i((int)pa(0, i, bp, bw)); } int* p = (int*)_aligned_malloc(sizeof(int) * (2048 + 3) * 4, 16); for(int i = 0; i < 4; i++) { - m_fbco->col[i] = &p[2048 * i + ((4 - (i & 3)) & 3)]; + co->col[i] = &p[2048 * i + ((4 - (i & 3)) & 3)]; - memcpy(m_fbco->col[i], GSLocalMemory::m_psm[context->FRAME.PSM].rowOffset[0], sizeof(int) * 2048); + memcpy(co->col[i], GSLocalMemory::m_psm[psm].rowOffset[0], sizeof(int) * 2048); } - m_comap.SetAt(hash, m_fbco); - } - } - - // zb - - hash = context->ZBUF.ZBP | (context->FRAME.FBW << 9) | (context->ZBUF.PSM << 15); - - if(!m_zbco || m_zbco->hash != hash) - { - CRBMap::CPair* pair = m_comap.Lookup(hash); - - if(pair) - { - m_zbco = pair->m_value; - } - else - { - m_zbco = (ColumnOffset*)_aligned_malloc(sizeof(ColumnOffset), 16); - - m_zbco->hash = hash; - - GSLocalMemory::pixelAddress pa = GSLocalMemory::m_psm[context->ZBUF.PSM].pa; - - for(int i = 0, j = 1024; i < j; i++) - { - m_zbco->row[i] = GSVector4i((int)pa(0, i, context->ZBUF.Block(), context->FRAME.FBW)); - } - - int* p = (int*)_aligned_malloc(sizeof(int) * (2048 + 3) * 4, 16); - - for(int i = 0; i < 4; i++) - { - m_zbco->col[i] = &p[2048 * i + ((4 - (i & 3)) & 3)]; - - memcpy(m_zbco->col[i], GSLocalMemory::m_psm[context->ZBUF.PSM].rowOffset[0], sizeof(int) * 2048); - } - - m_comap.SetAt(hash, m_zbco); + m_comap.SetAt(hash, co); } } } diff --git a/gsdx/GSRasterizer.h b/gsdx/GSRasterizer.h index 0cd12b2..d8d4aa2 100644 --- a/gsdx/GSRasterizer.h +++ b/gsdx/GSRasterizer.h @@ -119,7 +119,7 @@ private: ScanlineEnvironment m_slenv; bool m_solidrect; - void SetupColumnOffset(); + void SetupColumnOffset(ColumnOffset*& co, DWORD bp, DWORD bw, DWORD psm); template __forceinline void SetupScanline(const Vertex& dv);