(GX) Move defines to defines/gx_defines.h

This commit is contained in:
twinaphex 2015-11-18 12:55:28 +01:00
parent 3b7e53bf58
commit 9d98bfbe6b
8 changed files with 140 additions and 151 deletions

View File

@ -1,8 +1,96 @@
#ifndef _GX_DEFINES_H
#define _GX_DEFINES_H
#define _SHIFTL(v, s, w) ((uint32_t) (((uint32_t)(v) & ((0x01 << (w)) - 1)) << (s)))
#define _SHIFTR(v, s, w) ((uint32_t)(((uint32_t)(v) >> (s)) & ((0x01 << (w)) - 1)))
#ifndef __lhbrx
#define __lhbrx(base,index) \
({ register u16 res; \
__asm__ volatile ("lhbrx %0,%1,%2" : "=r"(res) : "b%"(index), "r"(base) : "memory"); \
res; })
#endif
#ifndef __sthbrx
#define __sthbrx(base,index,value) \
__asm__ volatile ("sthbrx %0,%1,%2" : : "r"(value), "b%"(index), "r"(base) : "memory")
#endif
#ifndef __stwbrx
#define __stwbrx(base,index,value) \
__asm__ volatile ("stwbrx %0,%1,%2" : : "r"(value), "b%"(index), "r"(base) : "memory")
#endif
#ifndef _sync
#define _sync() asm volatile("sync")
#endif
#ifndef _nop
#define _nop() asm volatile("nop")
#endif
#ifndef ppcsync
#define ppcsync() asm volatile("sc")
#endif
#ifndef ppchalt
#define ppchalt() ({ \
_sync(); \
while(1) { \
_nop(); \
asm volatile("li 3,0"); \
_nop(); \
} \
})
#endif
#ifndef _CPU_ISR_Enable
#define _CPU_ISR_Enable() \
{ register u32 _val = 0; \
__asm__ __volatile__ ( \
"mfmsr %0\n" \
"ori %0,%0,0x8000\n" \
"mtmsr %0" \
: "=&r" ((_val)) : "0" ((_val)) \
); \
}
#endif
#ifndef _CPU_ISR_Disable
#define _CPU_ISR_Disable( _isr_cookie ) \
{ register u32 _disable_mask = 0; \
_isr_cookie = 0; \
__asm__ __volatile__ ( \
"mfmsr %0\n" \
"rlwinm %1,%0,0,17,15\n" \
"mtmsr %1\n" \
"extrwi %0,%0,1,16" \
: "=&r" ((_isr_cookie)), "=&r" ((_disable_mask)) \
: "0" ((_isr_cookie)), "1" ((_disable_mask)) \
); \
}
#endif
#ifndef _CPU_ISR_Restore
#define _CPU_ISR_Restore( _isr_cookie ) \
{ register u32 _enable_mask = 0; \
__asm__ __volatile__ ( \
" cmpwi %0,0\n" \
" beq 1f\n" \
" mfmsr %1\n" \
" ori %1,%1,0x8000\n" \
" mtmsr %1\n" \
"1:" \
: "=r"((_isr_cookie)),"=&r" ((_enable_mask)) \
: "0"((_isr_cookie)),"1" ((_enable_mask)) \
); \
}
#endif
#ifdef GEKKO
extern void __lwp_thread_stopmultitasking(void (*exitfunc)());
#define OSThread lwp_t
#define OSCond lwpq_t
#define OSThreadQueue lwpq_t

View File

@ -30,7 +30,7 @@
#include <file/file_path.h>
#include <retro_miscellaneous.h>
#include "../../gfx/drivers/ppc_asm.h"
#include "../../defines/gx_defines.h"
#define EXECUTE_ADDR ((uint8_t *) 0x91800000)
#define BOOTER_ADDR ((uint8_t *) 0x93000000)

View File

@ -35,9 +35,7 @@
#include "../../memory/wii/mem2_manager.h"
#endif
#include "ppc_asm.h"
#include "gx_gfx_inl.h"
#include "../../defines/gx_defines.h"
struct gx_overlay_data
{

View File

@ -1,5 +1,7 @@
#include <retro_inline.h>
#include "../../defines/gx_defines.h"
#define STRUCT_REGDEF_SIZE 1440
#define WGPIPE (0xCC008000)
@ -31,9 +33,6 @@
FIFO_PUTU8(0x10); \
FIFO_PUTU32((((((n) & 0xffff)-1)<<16)|((x) & 0xffff)))
#define _SHIFTL(v, s, w) ((u32) (((u32)(v) & ((0x01 << (w)) - 1)) << (s)))
#define _SHIFTR(v, s, w) ((u32)(((u32)(v) >> (s)) & ((0x01 << (w)) - 1)))
extern u8 __gxregs[];
struct __gx_regdef
@ -361,11 +360,10 @@ static void __SETVCDATTR(struct __gx_regdef *__gx, u8 attr,u8 type)
#ifdef HW_DOL
static INLINE void __GX_UpdateBPMask(struct __gx_regdef *__gx)
{
u32 i, nbmp, nres;
u32 i;
u8 ntexmap;
nbmp = _SHIFTR(__gx->genMode,16,3);
nres = 0;
u32 nbmp = _SHIFTR(__gx->genMode,16,3);
u32 nres = 0;
for(i = 0; i < nbmp; i++)
{
@ -426,11 +424,13 @@ static INLINE void __GX_SetTexCoordGen(struct __gx_regdef *__gx)
GX_LOAD_XF_REG(0x103f,(__gx->genMode&0xf));
}
i = 0;
i = 0;
texcoord = 0x1040;
mask = _SHIFTR(__gx->dirtyState,16,8);
while(mask) {
if(mask&0x0001) {
mask = _SHIFTR(__gx->dirtyState,16,8);
while(mask)
{
if(mask&0x0001)
{
GX_LOAD_XF_REG(texcoord,__gx->texCoordGen[i]);
GX_LOAD_XF_REG((texcoord+0x10),__gx->texCoordGen2[i]);
}
@ -442,16 +442,12 @@ static INLINE void __GX_SetTexCoordGen(struct __gx_regdef *__gx)
static void __SetSURegs(struct __gx_regdef *__gx, u8 texmap,u8 texcoord)
{
u32 reg;
u16 wd, ht;
u8 wrap_s,wrap_t;
u16 wd = __gx->texMapSize[texmap] & 0x3ff;
u16 ht = _SHIFTR(__gx->texMapSize[texmap],10,10);
u8 wrap_s = __gx->texMapWrap[texmap] & 3;
u8 wrap_t = _SHIFTR(__gx->texMapWrap[texmap],2,2);
u32 reg = (texcoord & 0x7);
wd = __gx->texMapSize[texmap] & 0x3ff;
ht = _SHIFTR(__gx->texMapSize[texmap],10,10);
wrap_s = __gx->texMapWrap[texmap] & 3;
wrap_t = _SHIFTR(__gx->texMapWrap[texmap],2,2);
reg = (texcoord & 0x7);
__gx->suSsize[reg] = (__gx->suSsize[reg] & ~0x0000ffff)|wd;
__gx->suTsize[reg] = (__gx->suTsize[reg]&~0x0000ffff)|ht;
__gx->suSsize[reg] = (__gx->suSsize[reg]&~0x00010000)|(_SHIFTL(wrap_s,16,1));
@ -463,14 +459,13 @@ static void __SetSURegs(struct __gx_regdef *__gx, u8 texmap,u8 texcoord)
static INLINE void __GX_SetSUTexRegs(struct __gx_regdef *__gx)
{
u32 i, indtev, dirtev, tevreg, tevm, texcm;
u32 i, texcm;
u8 texcoord, texmap;
u32 dirtev = (_SHIFTR(__gx->genMode,10,4))+1;
u32 indtev = _SHIFTR(__gx->genMode,16,3);
dirtev = (_SHIFTR(__gx->genMode,10,4))+1;
indtev = _SHIFTR(__gx->genMode,16,3);
//indirect texture order
for(i = 0;i < indtev; i++)
/* Indirect texture order */
for(i = 0; i < indtev; i++)
{
switch(i)
{
@ -502,10 +497,11 @@ static INLINE void __GX_SetSUTexRegs(struct __gx_regdef *__gx)
__SetSURegs(__gx, texmap,texcoord);
}
//direct texture order
/* Direct texture order */
for(i = 0; i < dirtev; i++)
{
tevreg = 3+(_SHIFTR(i,1,3));
u32 tevm;
u32 tevreg = 3+(_SHIFTR(i,1,3));
texmap = (__gx->tevTexMap[i] & 0xff);
if(i & 1)
@ -515,7 +511,7 @@ static INLINE void __GX_SetSUTexRegs(struct __gx_regdef *__gx)
tevm = _SHIFTL(1,i,1);
texcm = _SHIFTL(1,texcoord,1);
if(texmap!=0xff && (__gx->tevTexCoordEnable&tevm) && !(__gx->texCoordManually & texcm))
if(texmap!=0xff && (__gx->tevTexCoordEnable & tevm) && !(__gx->texCoordManually & texcm))
{
__SetSURegs(__gx, texmap,texcoord);
}
@ -576,9 +572,8 @@ static void __GX_SetDirtyState(struct __gx_regdef *__gx)
static void __GX_SendFlushPrim(struct __gx_regdef *__gx)
{
u32 tmp,tmp2,cnt;
tmp = (__gx->xfFlush*__gx->xfFlushExp);
u32 tmp2,cnt;
u32 tmp = (__gx->xfFlush*__gx->xfFlushExp);
FIFO_PUTU8(0x98);
FIFO_PUTU16(__gx->xfFlush);
@ -755,14 +750,16 @@ static INLINE void __GX_SetViewportJitter(f32 xOrig,f32 yOrig,f32 wd,f32 ht,f32
static f32 Xfactor = 0.5;
static f32 Yfactor = 342.0;
static f32 Zfactor = 16777215.0;
if(!field) yOrig -= Xfactor;
if(!field)
yOrig -= Xfactor;
x0 = wd*Xfactor;
y0 = (-ht)*Xfactor;
x1 = (xOrig+(wd*Xfactor))+Yfactor;
y1 = (yOrig+(ht*Xfactor))+Yfactor;
n = Zfactor*nearZ;
f = Zfactor*farZ;
z = f-n;
n = Zfactor*nearZ;
f = Zfactor*farZ;
z = f-n;
GX_LOAD_XF_REGS(0x101a,6);
FIFO_PUTF32(x0);
FIFO_PUTF32(y0);

View File

@ -44,19 +44,9 @@
#include <retro_miscellaneous.h>
#include "../../gfx/drivers/ppc_asm.h"
#include "../../defines/gx_defines.h"
/****************************************************************************
* I2C driver by Hector Martin (marcan)
*
****************************************************************************/
#define _SHIFTL(v, s, w) \
((u32) (((u32)(v) & ((0x01 << (w)) - 1)) << (s)))
#define _SHIFTR(v, s, w) \
((u32)(((u32)(v) >> (s)) & ((0x01 << (w)) - 1)))
extern void udelay(int us);
void udelay(int us);
static u32 i2cIdentFirst = 0;
static u32 i2cIdentFlag = 1;
@ -111,7 +101,7 @@ static u32 __sendSlaveAddress(u8 addr)
__viSetSCL(1);
udelay(2);
if(i2cIdentFlag==1 && __viGetSDA()!=0)
if ((i2cIdentFlag == 1) && __viGetSDA()!=0)
return 0;
__viSetSDA(i2cIdentFlag^1);
@ -134,12 +124,12 @@ void VIDEO_SetTrapFilter(bool enable)
u8 addr = 0xe0;
u32 len = 2;
buf[0] = reg;
buf[1] = data;
buf[0] = reg;
buf[1] = data;
val = buf;
val = buf;
if(i2cIdentFirst==0)
if(i2cIdentFirst == 0)
{
__viOpenI2C(0);
udelay(4);
@ -160,7 +150,9 @@ void VIDEO_SetTrapFilter(bool enable)
udelay(4);
ret = __sendSlaveAddress(addr);
if(ret==0) {
if(ret == 0)
{
_CPU_ISR_Restore(level);
goto end;
}
@ -172,7 +164,7 @@ void VIDEO_SetTrapFilter(bool enable)
for(j=0;j<8;j++)
{
u32 chan = i2cIdentFlag;
if(c&0x80) {}
if(c & 0x80) {}
else
chan ^= 1;
@ -190,7 +182,7 @@ void VIDEO_SetTrapFilter(bool enable)
__viSetSCL(1);
udelay(2);
if(i2cIdentFlag==1 && __viGetSDA()!=0)
if((i2cIdentFlag == 1) && __viGetSDA()!=0)
{
_CPU_ISR_Restore(level);
goto end;

View File

@ -1,89 +0,0 @@
#ifndef __PPC_ASM_H
#define __PPC_ASM_H
#ifndef __lhbrx
#define __lhbrx(base,index) \
({ register u16 res; \
__asm__ volatile ("lhbrx %0,%1,%2" : "=r"(res) : "b%"(index), "r"(base) : "memory"); \
res; })
#endif
#ifndef __sthbrx
#define __sthbrx(base,index,value) \
__asm__ volatile ("sthbrx %0,%1,%2" : : "r"(value), "b%"(index), "r"(base) : "memory")
#endif
#ifndef __stwbrx
#define __stwbrx(base,index,value) \
__asm__ volatile ("stwbrx %0,%1,%2" : : "r"(value), "b%"(index), "r"(base) : "memory")
#endif
#ifndef _sync
#define _sync() asm volatile("sync")
#endif
#ifndef _nop
#define _nop() asm volatile("nop")
#endif
#ifndef ppcsync
#define ppcsync() asm volatile("sc")
#endif
#ifndef ppchalt
#define ppchalt() ({ \
_sync(); \
while(1) { \
_nop(); \
asm volatile("li 3,0"); \
_nop(); \
} \
})
#endif
#ifndef _CPU_ISR_Enable
#define _CPU_ISR_Enable() \
{ register u32 _val = 0; \
__asm__ __volatile__ ( \
"mfmsr %0\n" \
"ori %0,%0,0x8000\n" \
"mtmsr %0" \
: "=&r" ((_val)) : "0" ((_val)) \
); \
}
#endif
#ifndef _CPU_ISR_Disable
#define _CPU_ISR_Disable( _isr_cookie ) \
{ register u32 _disable_mask = 0; \
_isr_cookie = 0; \
__asm__ __volatile__ ( \
"mfmsr %0\n" \
"rlwinm %1,%0,0,17,15\n" \
"mtmsr %1\n" \
"extrwi %0,%0,1,16" \
: "=&r" ((_isr_cookie)), "=&r" ((_disable_mask)) \
: "0" ((_isr_cookie)), "1" ((_disable_mask)) \
); \
}
#endif
#ifndef _CPU_ISR_Restore
#define _CPU_ISR_Restore( _isr_cookie ) \
{ register u32 _enable_mask = 0; \
__asm__ __volatile__ ( \
" cmpwi %0,0\n" \
" beq 1f\n" \
" mfmsr %1\n" \
" ori %1,%1,0x8000\n" \
" mtmsr %1\n" \
"1:" \
: "=r"((_isr_cookie)),"=&r" ((_enable_mask)) \
: "0"((_isr_cookie)),"1" ((_enable_mask)) \
); \
}
#endif
extern void __lwp_thread_stopmultitasking(void (*exitfunc)());
#endif

View File

@ -15,13 +15,16 @@
*/
#include <math.h>
#include <VG/openvg.h>
#include <VG/vgext.h>
#include <EGL/egl.h>
#include <EGL/eglext.h>
#include "../video_context_driver.h"
#include <gfx/math/matrix_3x3.h>
#include <retro_inline.h>
#include <gfx/math/matrix_3x3.h>
#include "../video_context_driver.h"
#include "../../libretro.h"
#include "../../general.h"
#include "../../retroarch.h"

View File

@ -9,7 +9,7 @@
#include <retro_inline.h>
#include "mem2_manager.h"
#include "../../gfx/drivers/ppc_asm.h"
#include "../../defines/gx_defines.h"
/* Forbid the use of MEM2 through malloc */
uint32_t MALLOC_MEM2 = 0;