mirror of https://github.com/PCSX2/pcsx2.git
Forgot to add the new BaseblockEx files from the prev commit. -_-
git-svn-id: http://pcsx2-playground.googlecode.com/svn/trunk@618 a6443dda-0b58-4228-96e9-037be469359c
This commit is contained in:
parent
cb70542e4c
commit
8d09b80fb9
|
@ -0,0 +1,149 @@
|
|||
/* Pcsx2 - Pc Ps2 Emulator
|
||||
* Copyright (C) 2002-2008 Pcsx2 Team
|
||||
*
|
||||
* 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; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* 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 for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include "PrecompiledHeader.h"
|
||||
#include "BaseblockEx.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
using namespace std;
|
||||
|
||||
struct BASEBLOCKS
|
||||
{
|
||||
// 0 - ee, 1 - iop
|
||||
void Add(BASEBLOCKEX*);
|
||||
void Remove(BASEBLOCKEX*);
|
||||
int Get(u32 startpc);
|
||||
void Reset();
|
||||
|
||||
BASEBLOCKEX** GetAll(int* pnum);
|
||||
|
||||
vector<BASEBLOCKEX*> blocks;
|
||||
};
|
||||
|
||||
void BASEBLOCKS::Add(BASEBLOCKEX* pex)
|
||||
{
|
||||
assert( pex != NULL );
|
||||
|
||||
switch(blocks.size()) {
|
||||
case 0:
|
||||
blocks.push_back(pex);
|
||||
return;
|
||||
case 1:
|
||||
assert( blocks.front()->startpc != pex->startpc );
|
||||
|
||||
if( blocks.front()->startpc < pex->startpc ) {
|
||||
blocks.push_back(pex);
|
||||
}
|
||||
else blocks.insert(blocks.begin(), pex);
|
||||
|
||||
return;
|
||||
|
||||
default:
|
||||
{
|
||||
int imin = 0, imax = blocks.size(), imid;
|
||||
|
||||
while(imin < imax) {
|
||||
imid = (imin+imax)>>1;
|
||||
|
||||
if( blocks[imid]->startpc > pex->startpc ) imax = imid;
|
||||
else imin = imid+1;
|
||||
}
|
||||
|
||||
assert( imin == blocks.size() || blocks[imin]->startpc > pex->startpc );
|
||||
if( imin > 0 ) assert( blocks[imin-1]->startpc < pex->startpc );
|
||||
blocks.insert(blocks.begin()+imin, pex);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int BASEBLOCKS::Get(u32 startpc)
|
||||
{
|
||||
switch(blocks.size()) {
|
||||
case 1:
|
||||
return 0;
|
||||
case 2:
|
||||
return blocks.front()->startpc < startpc;
|
||||
|
||||
default:
|
||||
{
|
||||
int imin = 0, imax = blocks.size()-1, imid;
|
||||
|
||||
while(imin < imax) {
|
||||
imid = (imin+imax)>>1;
|
||||
|
||||
if( blocks[imid]->startpc > startpc ) imax = imid;
|
||||
else if( blocks[imid]->startpc == startpc ) return imid;
|
||||
else imin = imid+1;
|
||||
}
|
||||
|
||||
assert( blocks[imin]->startpc == startpc );
|
||||
return imin;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void BASEBLOCKS::Remove(BASEBLOCKEX* pex)
|
||||
{
|
||||
assert( pex != NULL );
|
||||
int i = Get(pex->startpc);
|
||||
assert( blocks[i] == pex );
|
||||
blocks.erase(blocks.begin()+i);
|
||||
}
|
||||
|
||||
void BASEBLOCKS::Reset()
|
||||
{
|
||||
blocks.resize(0);
|
||||
blocks.reserve(512);
|
||||
}
|
||||
|
||||
BASEBLOCKEX** BASEBLOCKS::GetAll(int* pnum)
|
||||
{
|
||||
assert( pnum != NULL );
|
||||
*pnum = blocks.size();
|
||||
return &blocks[0];
|
||||
}
|
||||
|
||||
static BASEBLOCKS s_vecBaseBlocksEx[2];
|
||||
|
||||
void AddBaseBlockEx(BASEBLOCKEX* pex, int cpu)
|
||||
{
|
||||
s_vecBaseBlocksEx[cpu].Add(pex);
|
||||
}
|
||||
|
||||
BASEBLOCKEX* GetBaseBlockEx(u32 startpc, int cpu)
|
||||
{
|
||||
return s_vecBaseBlocksEx[cpu].blocks[s_vecBaseBlocksEx[cpu].Get(startpc)];
|
||||
}
|
||||
|
||||
void RemoveBaseBlockEx(BASEBLOCKEX* pex, int cpu)
|
||||
{
|
||||
s_vecBaseBlocksEx[cpu].Remove(pex);
|
||||
}
|
||||
|
||||
void ResetBaseBlockEx(int cpu)
|
||||
{
|
||||
s_vecBaseBlocksEx[cpu].Reset();
|
||||
}
|
||||
|
||||
BASEBLOCKEX** GetAllBaseBlocks(int* pnum, int cpu)
|
||||
{
|
||||
return s_vecBaseBlocksEx[cpu].GetAll(pnum);
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
/* Pcsx2 - Pc Ps2 Emulator
|
||||
* Copyright (C) 2002-2008 Pcsx2 Team
|
||||
*
|
||||
* 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; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* 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 for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#ifndef _BASEBLOCKEX_H_
|
||||
#define _BASEBLOCKEX_H_
|
||||
|
||||
// used to keep block information
|
||||
#define BLOCKTYPE_STARTPC 4 // startpc offset
|
||||
#define BLOCKTYPE_DELAYSLOT 1 // if bit set, delay slot
|
||||
|
||||
// Every potential jump point in the PS2's addressable memory has a BASEBLOCK
|
||||
// associated with it. So that means a BASEBLOCK for every 4 bytes of PS2
|
||||
// addressable memory. Yay!
|
||||
struct BASEBLOCK
|
||||
{
|
||||
u32 pFnptr : 28;
|
||||
u32 uType : 4;
|
||||
u32 startpc;
|
||||
};
|
||||
|
||||
// extra block info (only valid for start of fn)
|
||||
// The only "important" piece of information is size. Startpc is used as a debug/check
|
||||
// var to make sure the baseblock is sane. (and it's used for some FFX hack involving
|
||||
// a big snake in a sewer, but no one knows if the hack is relevant anymore).
|
||||
struct BASEBLOCKEX
|
||||
{
|
||||
u16 size; // size in dwords
|
||||
u16 dummy;
|
||||
u32 startpc; // for debugging?
|
||||
|
||||
#ifdef PCSX2_DEVBUILD
|
||||
u32 visited; // number of times called
|
||||
LARGE_INTEGER ltime; // regs it assumes to have set already
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
// This is an asinine macro that bases indexing on sizeof(BASEBLOCK) for no reason. (air)
|
||||
#define GET_BLOCKTYPE(b) ((b)->Type)
|
||||
#define PC_GETBLOCK_(x, reclut) ((BASEBLOCK*)(reclut[((u32)(x)) >> 16] + (sizeof(BASEBLOCK)/4)*((x) & 0xffff)))
|
||||
|
||||
// This is needed because of the retarded GETBLOCK macro above.
|
||||
C_ASSERT( sizeof(BASEBLOCK) == 8 );
|
||||
|
||||
// 0 - ee, 1 - iop
|
||||
extern void AddBaseBlockEx(BASEBLOCKEX*, int cpu);
|
||||
extern void RemoveBaseBlockEx(BASEBLOCKEX*, int cpu);
|
||||
extern BASEBLOCKEX* GetBaseBlockEx(u32 startpc, int cpu);
|
||||
extern void ResetBaseBlockEx(int cpu);
|
||||
|
||||
extern BASEBLOCKEX** GetAllBaseBlocks(int* pnum, int cpu);
|
||||
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue