zzogl: Get a start on abstracting the memory code a bit.

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@3657 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
arcum42 2010-08-18 08:54:16 +00:00
parent fcba95f4d4
commit 9a5e9e24e1
5 changed files with 90 additions and 31 deletions

View File

@ -72,6 +72,29 @@ class GLWindow
extern GLWindow GLWin;
extern u8* g_pbyGSMemory;
class GSMemory
{
public:
void init();
void destroy();
u8* get();
u8* get(u32 addr);
u8* get_raw(u32 addr);
};
extern u8* g_pbyGSClut; // the temporary clut buffer
class GSClut
{
public:
void init();
void destroy();
u8* get();
u8* get(u32 addr);
u8* get_raw(u32 addr);
};
struct Vector_16F
{
u16 x, y, z, w;
@ -316,6 +339,12 @@ inline int PSMT_BITMODE(int psm) {return (psm & 0x7);}
inline int PSMT_BITS_NUM(int psm)
{
// Treat these as 32 bit.
if ((psm == PSMT8H) || (psm == PSMT4HL) || (psm == PSMT4HH))
{
return 4;
}
switch (PSMT_BITMODE(psm))
{
case 4:
@ -657,6 +686,9 @@ typedef struct
pathInfo path[4];
GIFRegDIMX dimx;
GSMemory mem;
GSClut clut_buffer;
void setRGBA(u32 r, u32 g, u32 b, u32 a)
{
rgba = (r & 0xff) |

View File

@ -27,7 +27,49 @@
#include "zerogs.h"
#include "targets.h"
extern _getPixelAddress getPixelFun[64];
u8* g_pbyGSMemory = NULL; // 4Mb GS system mem
void GSMemory::init()
{
const u32 mem_size = MEMORY_END + 0x10000; // leave some room for out of range accesses (saves on the checks)
// clear
g_pbyGSMemory = (u8*)_aligned_malloc(mem_size, 1024);
memset(g_pbyGSMemory, 0, mem_size);
}
void GSMemory::destroy()
{
_aligned_free(g_pbyGSMemory);
g_pbyGSMemory = NULL;
}
u8* GSMemory::get() { return g_pbyGSMemory; }
u8* GSMemory::get(u32 addr) { return &g_pbyGSMemory[addr*8]; }
u8* GSMemory::get_raw(u32 addr) { return &g_pbyGSMemory[addr]; }
u8* g_pbyGSClut = NULL; // ZZ
void GSClut::init()
{
g_pbyGSClut = (u8*)_aligned_malloc(256 * 8, 1024); // need 512 alignment!
memset(g_pbyGSClut, 0, 256*8);
}
void GSClut::destroy()
{
_aligned_free(g_pbyGSClut);
g_pbyGSClut = NULL;
}
u8* GSClut::get() { return g_pbyGSClut; }
u8* GSClut::get(u32 addr) { return &g_pbyGSClut[addr*8]; }
u8* GSClut::get_raw(u32 addr) { return &g_pbyGSClut[addr]; }
extern _getPixelAddress getPixelFun[64];
namespace ZeroGS
{
@ -63,16 +105,7 @@ extern _getPixelAddress getPixelFun[64];
return;
}
// For some reason, we have to treat these as 32 bit.
if ((psm == PSMT8H) || (psm == PSMT4HL) || (psm == PSMT4HH))
{
bits = 4;
}
else
{
bits = PSMT_BITS_NUM(psm);
}
bits = PSMT_BITS_NUM(psm);
start = getPixelFun[psm](x, y, bp, bw);
end = getPixelFun[psm](x + w - 1, y + h - 1, bp, bw) + 1;
@ -473,7 +506,7 @@ __forceinline void _TransferLocalLocal_4()
{
_TransferLocalLocal_4();
}
g_MemTargs.ClearRange(dststart, dstend);
#ifdef ZEROGS_DEVBUILD

View File

@ -302,18 +302,6 @@ _getPixelAddress_0 getPixelFun_0[64] =
NULL, NULL, getPixelAddress16SZ_0, NULL, NULL, NULL, NULL, NULL
};
_getPixelAddress getPixelFun[64] =
{
getPixelAddress32, getPixelAddress24, getPixelAddress16, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, getPixelAddress16S, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, getPixelAddress8, getPixelAddress4, NULL, NULL, NULL,
NULL, NULL, NULL, getPixelAddress8H, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, getPixelAddress4HL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, getPixelAddress4HH, NULL, NULL, NULL,
getPixelAddress32Z, getPixelAddress24Z, getPixelAddress16Z, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, getPixelAddress16SZ, NULL, NULL, NULL, NULL, NULL
};
_writePixel_0 writePixelFun_0[64] =
{
writePixel32_0, writePixel24_0, writePixel16_0, NULL, NULL, NULL, NULL, NULL,
@ -338,6 +326,18 @@ _readPixel_0 readPixelFun_0[64] =
NULL, NULL, readPixel16SZ_0, NULL, NULL, NULL, NULL, NULL
};
_getPixelAddress getPixelFun[64] =
{
getPixelAddress32, getPixelAddress24, getPixelAddress16, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, getPixelAddress16S, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, getPixelAddress8, getPixelAddress4, NULL, NULL, NULL,
NULL, NULL, NULL, getPixelAddress8H, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, getPixelAddress4HL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, getPixelAddress4HH, NULL, NULL, NULL,
getPixelAddress32Z, getPixelAddress24Z, getPixelAddress16Z, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, getPixelAddress16SZ, NULL, NULL, NULL, NULL, NULL
};
_writePixel writePixelFun[64] =
{
writePixel32, writePixel24, writePixel16, NULL, NULL, NULL, NULL, NULL,

View File

@ -92,10 +92,7 @@ int s_nResolveCounts[30] = {0}; // resolve counts for last 30 frames
////////////////////
// State parameters
int nBackbufferWidth, nBackbufferHeight;
u8* g_pbyGSMemory = NULL; // 4Mb GS system mem
u8* g_pbyGSClut = NULL; // ZZ
int nBackbufferWidth, nBackbufferHeight; // ZZ
namespace ZeroGS
{

View File

@ -112,9 +112,6 @@ extern u32 ptexLogo;
extern int nLogoWidth, nLogoHeight;
extern int nBackbufferWidth, nBackbufferHeight;
extern u8* g_pbyGSMemory;
extern u8* g_pbyGSClut; // the temporary clut buffer
namespace ZeroGS
{