From 6c88e99cf2476d6e248053c572f69fcb7903e1ce Mon Sep 17 00:00:00 2001 From: drkiiraziel Date: Thu, 9 Apr 2009 20:44:26 +0000 Subject: [PATCH 02/41] --This breaks linux. --Basic vtlb code rewrite for full mapping using exceptions --This is buggy & leaks ram for now git-svn-id: http://pcsx2.googlecode.com/svn/branches/vtlb-exp@934 96395faa-99c1-11dd-bbfe-3dabce05a288 --- pcsx2/IopCounters.cpp | 4 +- pcsx2/vtlb.cpp | 35 +++- pcsx2/windows/WinMain.cpp | 6 - pcsx2/windows/WinSysExec.cpp | 49 ++++- pcsx2/x86/ix86-32/recVTLB.cpp | 352 +++++++++++++++++++--------------- pcsx2/x86/ix86/ix86.h | 2 +- pcsx2/x86/ix86/ix86.inl | 7 +- 7 files changed, 289 insertions(+), 166 deletions(-) diff --git a/pcsx2/IopCounters.cpp b/pcsx2/IopCounters.cpp index 1152854a19..626f857503 100644 --- a/pcsx2/IopCounters.cpp +++ b/pcsx2/IopCounters.cpp @@ -357,13 +357,15 @@ static void psxCheckEndGate32(int i) _psxCheckEndGate( i ); } - +#include void psxVBlankStart() { cdvdVsync(); psxHu32(0x1070) |= 1; if(psxvblankgate & (1 << 1)) psxCheckStartGate16(1); if(psxvblankgate & (1 << 3)) psxCheckStartGate32(3); + if (GetAsyncKeyState('P')) + Cpu->Reset(); } void psxVBlankEnd() diff --git a/pcsx2/vtlb.cpp b/pcsx2/vtlb.cpp index f34df81bf4..810cbc5d41 100644 --- a/pcsx2/vtlb.cpp +++ b/pcsx2/vtlb.cpp @@ -61,6 +61,12 @@ vtlbHandler UnmappedVirtHandler1; vtlbHandler UnmappedPhyHandler0; vtlbHandler UnmappedPhyHandler1; +#define VTLB_ALLOC_SIZE (0x2900000) //this is a bit more than required + +u8* vtlb_alloc_base; //base of the memory array +u8* vtlb_alloc_current; //current base +u8 vtlb_alloc_bits[VTLB_ALLOC_SIZE/16/8]; //328 kb + /* __asm @@ -91,6 +97,13 @@ callfunction: // Interpreter Implementations of VTLB Memory Operations. // See recVTLB.cpp for the dynarec versions. +void memwritebits(u8* ptr) +{ + u32 offs=ptr-vtlb_alloc_base; + offs/=16; + vtlb_alloc_bits[offs/8]|=1<<(offs%8); +} + // Interpreted VTLB lookup for 8, 16, and 32 bit accesses template __forceinline DataType __fastcall MemOp_r0(u32 addr) @@ -116,7 +129,6 @@ __forceinline DataType __fastcall MemOp_r0(u32 addr) jNO_DEFAULT; } } - // Interpreterd VTLB lookup for 64 and 128 bit accesses. template __forceinline void __fastcall MemOp_r1(u32 addr, DataType* data) @@ -155,6 +167,7 @@ __forceinline void __fastcall MemOp_w0(u32 addr, DataType data) s32 ppf=addr+vmv; if (!(ppf<0)) { + //memwritebits((u8*)ppf); *reinterpret_cast(ppf)=data; } else @@ -182,6 +195,7 @@ __forceinline void __fastcall MemOp_w1(u32 addr,const DataType* data) s32 ppf=addr+vmv; if (!(ppf<0)) { + //memwritebits((u8*)ppf); *reinterpret_cast(ppf)=*data; if (DataSize==128) *reinterpret_cast(ppf+8)=data[1]; @@ -552,6 +566,13 @@ void vtlb_Term() //nothing to do for now } + +void vtlb_alloc_mem() +{ + u32 size=VTLB_ALLOC_SIZE; + vtlb_alloc_base=SysMmapEx( 0, size, 0x80000000, "Vtlb"); + vtlb_alloc_current=vtlb_alloc_base; +} // This function allocates memory block with are compatible with the Vtlb's requirements // for memory locations. The Vtlb requires the topmost bit (Sign bit) of the memory // pointer to be cleared. Some operating systems and/or implementations of malloc do that, @@ -559,6 +580,17 @@ void vtlb_Term() // platform. u8* vtlb_malloc( uint size, uint align, uptr tryBaseAddress ) { + if (!vtlb_alloc_base) + vtlb_alloc_mem(); + + u32 realign=((uptr)vtlb_alloc_current&(align-1)); + if (realign) + vtlb_alloc_current+=align-realign; + + u8* rv=vtlb_alloc_current; + vtlb_alloc_current+=size; + return rv; + #ifdef __LINUX__ return SysMmapEx( tryBaseAddress, size, 0x80000000, "Vtlb" ); #else @@ -569,6 +601,7 @@ u8* vtlb_malloc( uint size, uint align, uptr tryBaseAddress ) void vtlb_free( void* pmem, uint size ) { + return;//whatever if( pmem == NULL ) return; #ifdef __LINUX__ diff --git a/pcsx2/windows/WinMain.cpp b/pcsx2/windows/WinMain.cpp index de6b3a953b..c74e88157f 100644 --- a/pcsx2/windows/WinMain.cpp +++ b/pcsx2/windows/WinMain.cpp @@ -202,10 +202,8 @@ void WinRun() _doPluginOverride( "DEV9", g_Startup.dev9dll, Config.DEV9 ); -#ifndef _DEBUG if( Config.Profiler ) ProfilerInit(); -#endif InitCPUTicks(); @@ -800,7 +798,6 @@ LRESULT WINAPI MainWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) SaveConfig(); break; -#ifndef _DEBUG case ID_PROFILER: Config.Profiler = !Config.Profiler; if( Config.Profiler ) @@ -815,7 +812,6 @@ LRESULT WINAPI MainWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) } SaveConfig(); break; -#endif default: if (LOWORD(wParam) >= ID_LANGS && LOWORD(wParam) <= (ID_LANGS + langsMax)) @@ -989,9 +985,7 @@ void CreateMainMenu() { ADDMENUITEM(0,_("Print cdvd &Info"), ID_CDVDPRINT); ADDMENUITEM(0,_("Close GS Window on Esc"), ID_CLOSEGS); ADDSEPARATOR(0); -#ifndef _DEBUG ADDMENUITEM(0,_("Enable &Profiler"), ID_PROFILER); -#endif ADDMENUITEM(0,_("Enable &Patches"), ID_PATCHES); ADDMENUITEM(0,_("Enable &Console"), ID_CONSOLE); ADDSEPARATOR(0); diff --git a/pcsx2/windows/WinSysExec.cpp b/pcsx2/windows/WinSysExec.cpp index ec62fe33d0..3c7ce85aff 100644 --- a/pcsx2/windows/WinSysExec.cpp +++ b/pcsx2/windows/WinSysExec.cpp @@ -49,14 +49,53 @@ int SysPageFaultExceptionFilter( EXCEPTION_POINTERS* eps ) } // get bad virtual address - u32 offset = (u8*)ExceptionRecord.ExceptionInformation[1]-psM; + uptr addr=ExceptionRecord.ExceptionInformation[1]; - if (offset>=Ps2MemSize::Base) - return EXCEPTION_CONTINUE_SEARCH; + //this is a *hackfix* for a bug on x64 windows kernels.They do not give correct address + //if the error is a missaligned access (they return 0) + if (addr==0) + { + if (eps->ContextRecord->Ecx & 0x80000000) + addr=eps->ContextRecord->Ecx; + } + u32 offset = addr-(uptr)psM; + + if (addr&0x80000000) + { + uptr _vtlb_HandleRewrite(uptr code); + u8* pcode=(u8*)ExceptionRecord.ExceptionAddress; - mmap_ClearCpuBlock( offset ); + u32 patch_point=1; + //01 C1 + while(pcode[-patch_point]!=0x81 || pcode[-patch_point-1]!=0xC1 || pcode[-patch_point-2]!=0x01) + { + patch_point++; + } + assert(pcode[-patch_point]==0x81); + pcode[-patch_point]=0xF;//js32, 0x81 is add32 + pcode[-patch_point+1]=0x88; - return EXCEPTION_CONTINUE_EXECUTION; + //resume execution from correct point + + eps->ContextRecord->Eax-=*(u32*)&pcode[-patch_point+2]; + + uptr codeloc=_vtlb_HandleRewrite(*(u32*)&pcode[-patch_point+2]); + + eps->ContextRecord->Eip=codeloc; + *(u32*)&pcode[-patch_point+2]=codeloc-(u32)&pcode[-patch_point+6]; + + SysPrintf("memop patch for full mapping @ %08X : pp %d\n",pcode,patch_point); + return EXCEPTION_CONTINUE_EXECUTION; + } + else + { + if (offset>=Ps2MemSize::Base) + return EXCEPTION_CONTINUE_SEARCH; + + mmap_ClearCpuBlock( offset ); + + return EXCEPTION_CONTINUE_EXECUTION; + } } diff --git a/pcsx2/x86/ix86-32/recVTLB.cpp b/pcsx2/x86/ix86-32/recVTLB.cpp index cbc567c68d..2554ab041f 100644 --- a/pcsx2/x86/ix86-32/recVTLB.cpp +++ b/pcsx2/x86/ix86-32/recVTLB.cpp @@ -24,23 +24,178 @@ #include "iCore.h" #include "iR5900.h" -using namespace vtlb_private; +u8* execohax_pos=0; +u8* execohax_start=0; +u32 execohx_sz; -// NOTICE: This function *destroys* EAX!! -// Moves 128 bits of memory from the source register ptr to the dest register ptr. -// (used as an equivalent to movaps, when a free XMM register is unavailable for some reason) -void MOV128_MtoM( x86IntRegType destRm, x86IntRegType srcRm ) +u8* code_pos=0; +u8* code_start=0; +u32 code_sz; + +using namespace vtlb_private; +#include + +void execuCode(bool set) { - MOV32RmtoR(EAX,srcRm); - MOV32RtoRm(destRm,EAX); - MOV32RmtoROffset(EAX,srcRm,4); - MOV32RtoRmOffset(destRm,EAX,4); - MOV32RmtoROffset(EAX,srcRm,8); - MOV32RtoRmOffset(destRm,EAX,8); - MOV32RmtoROffset(EAX,srcRm,12); - MOV32RtoRmOffset(destRm,EAX,12); + u32 used=code_pos-code_start; + u32 free=2*1024*1024-used; + + if (code_pos == 0 || free<128) + { + SysPrintf("Leaking 2 megabytes of ram\n"); + code_start=code_pos=(u8*)VirtualAlloc(0,2*1024*1024,MEM_COMMIT,PAGE_EXECUTE_READWRITE); + code_sz+=2*1024*1024; + int i=0; + while(i( 0x81 ); + ModRM<_EmitterId_>( 3, 0, EAX ); + write32<_EmitterId_>( (uptr)execohax_pos ); + + saved=x86SetPtr(execohax_pos); + mod=execohax_pos; + write8<_EmitterId_>(0); //size, in bytes + write32<_EmitterId_>(0); //return address + } + else + { + //x86AlignExecutable(4); + //x86Align(64); + execohax_pos=x86SetPtr(mod); + write8<_EmitterId_>(execohax_pos-mod-5); + return (u32*)x86SetPtr(saved); + } + + return 0; +} + +uptr _vtlb_HandleRewrite(uptr block) +{ + u8 size=*(u8*)block; + u32 ra=*(u32*)(block+1); + u8* pcode=(u8*)(block+5); + execuCode(true); + uptr rv=(uptr)code_pos; + + while(size--) + { + write8<_EmitterId_>(*pcode++); + } + JMP32(ra-(uptr)x86Ptr[_EmitterId_]-5); + + execuCode(false); + //do magic + return rv; +} + +PCSX2_ALIGNED16( static u64 g_globalXMMData[2*XMMREGS] ); +void MOVx_SSE( x86IntRegType destRm, x86IntRegType srcRm,u32 srcAddr=0,u32 dstAddr=0,bool half=false ) +{ + int reg; + bool free_reg=false; + if( _hasFreeXMMreg() ) + { + free_reg=true; + reg=_allocTempXMMreg( XMMT_INT, -1 ); + } + else + { + SSE2_MOVDQA_XMM_to_M128((uptr)g_globalXMMData,XMM0); + reg=XMM0; + } + + if (half) + { + if (srcAddr) + SSE_MOVLPS_M64_to_XMM(reg,srcAddr); + else + SSE_MOVLPS_RmOffset_to_XMM(reg,srcRm,0); + + if (dstAddr) + SSE_MOVLPS_XMM_to_M64(dstAddr,reg); + else + SSE_MOVLPS_XMM_to_RmOffset(destRm,reg,0); + } + else + { + if (srcAddr) + SSE2_MOVDQA_M128_to_XMM(reg,srcAddr); + else + SSE2_MOVDQARmtoROffset(reg,srcRm,0); + + if (dstAddr) + SSE2_MOVDQA_XMM_to_M128(dstAddr,reg); + else + SSE2_MOVDQARtoRmOffset(destRm,reg,0); + } + + + if (free_reg) + _freeXMMreg(reg); + else + { + SSE2_MOVDQA_M128_to_XMM(XMM0,(uptr)g_globalXMMData); + } +} +void MOV64_MMX( x86IntRegType destRm, x86IntRegType srcRm,u32 srcAddr=0,u32 dstAddr=0) +{ + //if free xmm && fpu state then we use the SSE version. + if( !(_hasFreeXMMreg() && (x86FpuState == FPU_STATE)) && _hasFreeMMXreg() ) + { + const int freereg = _allocMMXreg(-1, MMX_TEMP, 0); + if (srcAddr) + MOVQMtoR(freereg,srcAddr); + else + MOVQRmtoROffset(freereg,srcRm,0); + + if (dstAddr) + MOVQRtoM(dstAddr,freereg); + else + MOVQRtoRmOffset(destRm,freereg,0); + + _freeMMXreg(freereg); + } + else + { + MOVx_SSE(destRm,srcRm,srcAddr,dstAddr,true); + } +} /* // Pseudo-Code For the following Dynarec Implementations --> @@ -118,38 +273,11 @@ static void _vtlb_DynGen_DirectRead( u32 bits, bool sign ) break; case 64: - if( _hasFreeMMXreg() ) - { - const int freereg = _allocMMXreg(-1, MMX_TEMP, 0); - MOVQRmtoROffset(freereg,ECX,0); - MOVQRtoRmOffset(EDX,freereg,0); - _freeMMXreg(freereg); - } - else - { - MOV32RmtoR(EAX,ECX); - MOV32RtoRm(EDX,EAX); - - MOV32RmtoROffset(EAX,ECX,4); - MOV32RtoRmOffset(EDX,EAX,4); - } + MOV64_MMX(EDX,ECX); break; case 128: - if( _hasFreeXMMreg() ) - { - const int freereg = _allocTempXMMreg( XMMT_INT, -1 ); - SSE2_MOVDQARmtoROffset(freereg,ECX,0); - SSE2_MOVDQARtoRmOffset(EDX,freereg,0); - _freeXMMreg(freereg); - } - else - { - // Could put in an MMX optimization here as well, but no point really. - // It's almost never used since there's almost always a free XMM reg. - - MOV128_MtoM( EDX, ECX ); // dest <- src! - } + MOVx_SSE(EDX,ECX); break; jNO_DEFAULT @@ -189,15 +317,16 @@ void vtlb_DynGenRead64(u32 bits) SHR32ItoR(EAX,VTLB_PAGE_BITS); MOV32RmSOffsettoR(EAX,EAX,(int)vtlbdata.vmap,2); ADD32RtoR(ECX,EAX); - u8* _fullread = JS8(0); + //u8* _direct = JMP8(0); + execohaxme(true); - _vtlb_DynGen_DirectRead( bits, false ); - u8* cont = JMP8(0); - - x86SetJ8(_fullread); _vtlb_DynGen_IndirectRead( bits ); - - x86SetJ8(cont); + + u32* patch=execohaxme(false); + + _vtlb_DynGen_DirectRead( bits, false ); + + *patch=(uptr)x86Ptr[_EmitterId_]; } // Recompiled input registers: @@ -211,12 +340,9 @@ void vtlb_DynGenRead32(u32 bits, bool sign) SHR32ItoR(EAX,VTLB_PAGE_BITS); MOV32RmSOffsettoR(EAX,EAX,(int)vtlbdata.vmap,2); ADD32RtoR(ECX,EAX); - u8* _fullread = JS8(0); + //u8* _direct = JMP8(0); + execohaxme(true); - _vtlb_DynGen_DirectRead( bits, sign ); - u8* cont = JMP8(0); - - x86SetJ8(_fullread); _vtlb_DynGen_IndirectRead( bits ); // perform sign extension on the result: @@ -236,7 +362,11 @@ void vtlb_DynGenRead32(u32 bits, bool sign) MOVZX32R16toR(EAX,EAX); } - x86SetJ8(cont); + u32* patch=execohaxme(false); + + _vtlb_DynGen_DirectRead( bits, sign ); + + *patch=(uptr)x86Ptr[_EmitterId_]; } // @@ -251,39 +381,11 @@ void vtlb_DynGenRead64_Const( u32 bits, u32 addr_const ) switch( bits ) { case 64: - if( _hasFreeMMXreg() ) - { - const int freereg = _allocMMXreg(-1, MMX_TEMP, 0); - MOVQMtoR(freereg,ppf); - MOVQRtoRmOffset(EDX,freereg,0); - _freeMMXreg(freereg); - } - else - { - MOV32MtoR(EAX,ppf); - MOV32RtoRm(EDX,EAX); - - MOV32MtoR(EAX,ppf+4); - MOV32RtoRmOffset(EDX,EAX,4); - } + MOV64_MMX( EDX, ECX,ppf ); // dest <- src! break; case 128: - if( _hasFreeXMMreg() ) - { - const int freereg = _allocTempXMMreg( XMMT_INT, -1 ); - SSE2_MOVDQA_M128_to_XMM( freereg, ppf ); - SSE2_MOVDQARtoRmOffset(EDX,freereg,0); - _freeXMMreg(freereg); - } - else - { - // Could put in an MMX optimization here as well, but no point really. - // It's almost never used since there's almost always a free XMM reg. - - MOV32ItoR( ECX, ppf ); - MOV128_MtoM( EDX, ECX ); // dest <- src! - } + MOVx_SSE( EDX, ECX,ppf ); // dest <- src! break; jNO_DEFAULT @@ -403,40 +505,16 @@ static void _vtlb_DynGen_DirectWrite( u32 bits ) break; case 64: - if( _hasFreeMMXreg() ) - { - const int freereg = _allocMMXreg(-1, MMX_TEMP, 0); - MOVQRmtoROffset(freereg,EDX,0); - MOVQRtoRmOffset(ECX,freereg,0); - _freeMMXreg( freereg ); - } - else - { - MOV32RmtoR(EAX,EDX); - MOV32RtoRm(ECX,EAX); - - MOV32RmtoROffset(EAX,EDX,4); - MOV32RtoRmOffset(ECX,EAX,4); - } + MOV64_MMX( ECX, EDX ); break; case 128: - if( _hasFreeXMMreg() ) - { - const int freereg = _allocTempXMMreg( XMMT_INT, -1 ); - SSE2_MOVDQARmtoROffset(freereg,EDX,0); - SSE2_MOVDQARtoRmOffset(ECX,freereg,0); - _freeXMMreg( freereg ); - } - else - { - // Could put in an MMX optimization here as well, but no point really. - // It's almost never used since there's almost always a free XMM reg. - - MOV128_MtoM( ECX, EDX ); // dest <- src! - } + MOVx_SSE( ECX, EDX ); break; } + +// SHR32ItoR(ECX,4);// do /16 +// BTS_wtf(asdasd,ECX); } static void _vtlb_DynGen_IndirectWrite( u32 bits ) @@ -464,15 +542,17 @@ void vtlb_DynGenWrite(u32 sz) SHR32ItoR(EAX,VTLB_PAGE_BITS); MOV32RmSOffsettoR(EAX,EAX,(int)vtlbdata.vmap,2); ADD32RtoR(ECX,EAX); - u8* _full=JS8(0); - _vtlb_DynGen_DirectWrite( sz ); - u8* cont = JMP8(0); + //u8* _direct=JMP8(0); - x86SetJ8(_full); + execohaxme(true); + _vtlb_DynGen_IndirectWrite( sz ); - - x86SetJ8(cont); + + u32* patch=execohaxme(false); + _vtlb_DynGen_DirectWrite( sz ); + + *patch=(uptr)x86Ptr[_EmitterId_]; } @@ -499,39 +579,11 @@ void vtlb_DynGenWrite_Const( u32 bits, u32 addr_const ) break; case 64: - if( _hasFreeMMXreg() ) - { - const int freereg = _allocMMXreg(-1, MMX_TEMP, 0); - MOVQRmtoROffset(freereg,EDX,0); - MOVQRtoM(ppf,freereg); - _freeMMXreg( freereg ); - } - else - { - MOV32RmtoR(EAX,EDX); - MOV32RtoM(ppf,EAX); - - MOV32RmtoROffset(EAX,EDX,4); - MOV32RtoM(ppf+4,EAX); - } + MOV64_MMX( ECX, EDX,0,ppf); // dest <- src! break; case 128: - if( _hasFreeXMMreg() ) - { - const int freereg = _allocTempXMMreg( XMMT_INT, -1 ); - SSE2_MOVDQARmtoROffset(freereg,EDX,0); - SSE2_MOVDQA_XMM_to_M128(ppf,freereg); - _freeXMMreg( freereg ); - } - else - { - // Could put in an MMX optimization here as well, but no point really. - // It's almost never used since there's almost always a free XMM reg. - - MOV32ItoR( ECX, ppf ); - MOV128_MtoM( ECX, EDX ); // dest <- src! - } + MOVx_SSE( ECX, EDX,0,ppf); // dest <- src! break; } diff --git a/pcsx2/x86/ix86/ix86.h b/pcsx2/x86/ix86/ix86.h index 797dc2eaf7..51a65d712a 100644 --- a/pcsx2/x86/ix86/ix86.h +++ b/pcsx2/x86/ix86/ix86.h @@ -79,7 +79,7 @@ emitterT void write64( u64 val ){ //------------------------------------------------------------------ // jump/align functions //------------------------------------------------------------------ -emitterT void ex86SetPtr( u8 *ptr ); +emitterT u8* ex86SetPtr( u8 *ptr ); emitterT void ex86SetJ8( u8 *j8 ); emitterT void ex86SetJ8A( u8 *j8 ); emitterT void ex86SetJ16( u16 *j16 ); diff --git a/pcsx2/x86/ix86/ix86.inl b/pcsx2/x86/ix86/ix86.inl index ae4f5829af..7394bd6a3a 100644 --- a/pcsx2/x86/ix86/ix86.inl +++ b/pcsx2/x86/ix86/ix86.inl @@ -159,9 +159,12 @@ emitterT void CMOV32MtoR( int cc, int to, uptr from ) } //////////////////////////////////////////////////// -emitterT void ex86SetPtr( u8* ptr ) +emitterT u8* ex86SetPtr( u8* ptr ) { - x86Ptr[I] = ptr; + u8* rv= x86Ptr[I]; + if (ptr!=0) + x86Ptr[I] = ptr; + return rv; } //////////////////////////////////////////////////// From f5e99af1ab4874dae6e89292ca9f7e34bac8ce24 Mon Sep 17 00:00:00 2001 From: drkiiraziel Date: Thu, 9 Apr 2009 23:01:56 +0000 Subject: [PATCH 03/41] --No longer uses 2 hacks/buffers, it just stores the info needed to generate the memops directly on the code git-svn-id: http://pcsx2.googlecode.com/svn/branches/vtlb-exp@936 96395faa-99c1-11dd-bbfe-3dabce05a288 --- pcsx2/windows/WinSysExec.cpp | 4 +- pcsx2/x86/ix86-32/recVTLB.cpp | 197 +++++++++++++++++----------------- 2 files changed, 101 insertions(+), 100 deletions(-) diff --git a/pcsx2/windows/WinSysExec.cpp b/pcsx2/windows/WinSysExec.cpp index 3c7ce85aff..39add1c5f2 100644 --- a/pcsx2/windows/WinSysExec.cpp +++ b/pcsx2/windows/WinSysExec.cpp @@ -62,7 +62,7 @@ int SysPageFaultExceptionFilter( EXCEPTION_POINTERS* eps ) if (addr&0x80000000) { - uptr _vtlb_HandleRewrite(uptr code); + uptr _vtlb_HandleRewrite(u32 info,u8* ra); u8* pcode=(u8*)ExceptionRecord.ExceptionAddress; u32 patch_point=1; @@ -79,7 +79,7 @@ int SysPageFaultExceptionFilter( EXCEPTION_POINTERS* eps ) eps->ContextRecord->Eax-=*(u32*)&pcode[-patch_point+2]; - uptr codeloc=_vtlb_HandleRewrite(*(u32*)&pcode[-patch_point+2]); + uptr codeloc=_vtlb_HandleRewrite(*(u32*)&pcode[-patch_point+2],&pcode[-patch_point+2+4]); eps->ContextRecord->Eip=codeloc; *(u32*)&pcode[-patch_point+2]=codeloc-(u32)&pcode[-patch_point+6]; diff --git a/pcsx2/x86/ix86-32/recVTLB.cpp b/pcsx2/x86/ix86-32/recVTLB.cpp index 2554ab041f..d830a26d9d 100644 --- a/pcsx2/x86/ix86-32/recVTLB.cpp +++ b/pcsx2/x86/ix86-32/recVTLB.cpp @@ -24,14 +24,28 @@ #include "iCore.h" #include "iR5900.h" -u8* execohax_pos=0; -u8* execohax_start=0; -u32 execohx_sz; - u8* code_pos=0; u8* code_start=0; u32 code_sz; +union _vtlb_MemOpInfo +{ + struct + { + u32 sz:8;//0 -> 8, 1 -> 16, 2 -> 32, 3 -> 64, 4 -> 128 + u32 skip:8;//bytes to skip + u32 sx:1; + u32 read:1; + }; + u32 full; + bool isRead() { return read; } + bool isWrite(){ return !isRead(); } + bool isSX() { return sx; } + u32 getSize() { return sz; } + u32 getSkip() { return skip; } +}; + + using namespace vtlb_private; #include @@ -49,8 +63,8 @@ void execuCode(bool set) while(i( 0x81 ); + ModRM<_EmitterId_>( 3, 0, EAX ); - if (execohax_pos == 0 || free<128) - { - SysPrintf("Leaking 2 megabytes of ram\n"); - execohax_start=execohax_pos=(u8*)VirtualAlloc(0,2*1024*1024,MEM_COMMIT,PAGE_EXECUTE_READWRITE); - execohx_sz+=2*1024*1024; - } - static u8* saved; - static u8* mod; - if (set) - { - write8<_EmitterId_>( 0x81 ); - ModRM<_EmitterId_>( 3, 0, EAX ); - write32<_EmitterId_>( (uptr)execohax_pos ); + u8* rv=x86SetPtr(0); + write32<_EmitterId_>(0); - saved=x86SetPtr(execohax_pos); - mod=execohax_pos; - write8<_EmitterId_>(0); //size, in bytes - write32<_EmitterId_>(0); //return address - } - else - { - //x86AlignExecutable(4); - //x86Align(64); - execohax_pos=x86SetPtr(mod); - write8<_EmitterId_>(execohax_pos-mod-5); - return (u32*)x86SetPtr(saved); - } - - return 0; -} - -uptr _vtlb_HandleRewrite(uptr block) -{ - u8 size=*(u8*)block; - u32 ra=*(u32*)(block+1); - u8* pcode=(u8*)(block+5); - execuCode(true); - uptr rv=(uptr)code_pos; - - while(size--) - { - write8<_EmitterId_>(*pcode++); - } - JMP32(ra-(uptr)x86Ptr[_EmitterId_]-5); - - execuCode(false); - //do magic return rv; } - +void IndirectPlaceholderB(u8* pl,bool read,u32 sz,bool sx) +{ + _vtlb_MemOpInfo inf; + inf.full=0; + inf.read=read; + inf.sz=sz; + inf.sx=sx; + + u8* old=x86SetPtr(pl); + inf.skip=old-pl-4; + //Add32 ,imm, 6 bytes form. + write32<_EmitterId_>( inf.full ); + x86SetPtr(old); +} PCSX2_ALIGNED16( static u64 g_globalXMMData[2*XMMREGS] ); void MOVx_SSE( x86IntRegType destRm, x86IntRegType srcRm,u32 srcAddr=0,u32 dstAddr=0,bool half=false ) { @@ -196,6 +176,8 @@ void MOV64_MMX( x86IntRegType destRm, x86IntRegType srcRm,u32 srcAddr=0,u32 dstA MOVx_SSE(destRm,srcRm,srcAddr,dstAddr,true); } } + + /* // Pseudo-Code For the following Dynarec Implementations --> @@ -317,16 +299,12 @@ void vtlb_DynGenRead64(u32 bits) SHR32ItoR(EAX,VTLB_PAGE_BITS); MOV32RmSOffsettoR(EAX,EAX,(int)vtlbdata.vmap,2); ADD32RtoR(ECX,EAX); - //u8* _direct = JMP8(0); - execohaxme(true); - _vtlb_DynGen_IndirectRead( bits ); - - u32* patch=execohaxme(false); + u8* patch=IndirectPlaceholderA(); _vtlb_DynGen_DirectRead( bits, false ); - - *patch=(uptr)x86Ptr[_EmitterId_]; + + IndirectPlaceholderB(patch,true,bits,false); } // Recompiled input registers: @@ -340,33 +318,12 @@ void vtlb_DynGenRead32(u32 bits, bool sign) SHR32ItoR(EAX,VTLB_PAGE_BITS); MOV32RmSOffsettoR(EAX,EAX,(int)vtlbdata.vmap,2); ADD32RtoR(ECX,EAX); - //u8* _direct = JMP8(0); - execohaxme(true); - - _vtlb_DynGen_IndirectRead( bits ); - - // perform sign extension on the result: - - if( bits==8 ) - { - if( sign ) - MOVSX32R8toR(EAX,EAX); - else - MOVZX32R8toR(EAX,EAX); - } - else if( bits==16 ) - { - if( sign ) - MOVSX32R16toR(EAX,EAX); - else - MOVZX32R16toR(EAX,EAX); - } - - u32* patch=execohaxme(false); + + u8* patch=IndirectPlaceholderA(); _vtlb_DynGen_DirectRead( bits, sign ); - - *patch=(uptr)x86Ptr[_EmitterId_]; + + IndirectPlaceholderB(patch,true,bits,sign); } // @@ -543,16 +500,11 @@ void vtlb_DynGenWrite(u32 sz) MOV32RmSOffsettoR(EAX,EAX,(int)vtlbdata.vmap,2); ADD32RtoR(ECX,EAX); - //u8* _direct=JMP8(0); + u8* patch=IndirectPlaceholderA(); - execohaxme(true); - - _vtlb_DynGen_IndirectWrite( sz ); - - u32* patch=execohaxme(false); _vtlb_DynGen_DirectWrite( sz ); - - *patch=(uptr)x86Ptr[_EmitterId_]; + + IndirectPlaceholderB(patch,false,sz,false); } @@ -608,3 +560,52 @@ void vtlb_DynGenWrite_Const( u32 bits, u32 addr_const ) CALLFunc( (int)vtlbdata.RWFT[szidx][1][handler] ); } } + + +u32 GenIndirectMemOp(u32 info) +{ + _vtlb_MemOpInfo inf; + inf.full=info; + + u32 bits=inf.getSize(); + bool sign=inf.isSX(); + + if (inf.isWrite()) + { + _vtlb_DynGen_IndirectWrite(bits); + } + else + { + _vtlb_DynGen_IndirectRead(bits); + + if( bits==8 ) + { + if( sign ) + MOVSX32R8toR(EAX,EAX); + else + MOVZX32R8toR(EAX,EAX); + } + else if( bits==16 ) + { + if( sign ) + MOVSX32R16toR(EAX,EAX); + else + MOVZX32R16toR(EAX,EAX); + } + } + + return inf.getSkip(); +} +uptr _vtlb_HandleRewrite(u32 info,u8* ra) +{ + execuCode(true); + uptr rv=(uptr)x86SetPtr(0); + + u32 skip=GenIndirectMemOp(info); + + JMP32(ra-x86Ptr[_EmitterId_]-5+skip); + + execuCode(false); + + return rv; +} \ No newline at end of file From 3fb09c219248e5d0977cf46a5af1d0fb7c317a07 Mon Sep 17 00:00:00 2001 From: drkiiraziel Date: Fri, 10 Apr 2009 20:26:43 +0000 Subject: [PATCH 04/41] --BTS r/m+r added for emitter --Uses BTS + bit arrays for manual block tracking, instead of full invalidation.It makes some games much much faster and doesn't seem to affect he rest (still, testing is needed).Okami that uses some sort of SMC works .. but i'm sure there are some bugs left in it git-svn-id: http://pcsx2.googlecode.com/svn/branches/vtlb-exp@951 96395faa-99c1-11dd-bbfe-3dabce05a288 --- pcsx2/x86/ix86-32/iR5900-32.cpp | 55 +++++++++++++++++++++++++++++++++ pcsx2/x86/ix86-32/recVTLB.cpp | 15 +++++++-- pcsx2/x86/ix86/ix86.inl | 9 ++++++ pcsx2/x86/ix86/ix86_macros.h | 1 + 4 files changed, 78 insertions(+), 2 deletions(-) diff --git a/pcsx2/x86/ix86-32/iR5900-32.cpp b/pcsx2/x86/ix86-32/iR5900-32.cpp index 6d568c95b8..9926bed745 100644 --- a/pcsx2/x86/ix86-32/iR5900-32.cpp +++ b/pcsx2/x86/ix86-32/iR5900-32.cpp @@ -1348,6 +1348,10 @@ void __fastcall dyna_block_discard(u32 start,u32 sz) Cpu->Clear(start,sz); } +#define VTLB_ALLOC_SIZE (0x2900000) //this is a bit more than required +extern u8* vtlb_alloc_base; //base of the memory array +extern u8 vtlb_alloc_bits[VTLB_ALLOC_SIZE/16/8]; //328 kb + void recRecompile( const u32 startpc ) { u32 i = 0; @@ -1707,7 +1711,57 @@ StartRecomp: { MOV32ItoR(ECX, startpc); MOV32ItoR(EDX, sz); + + u32 mask=0; + u32 writen=0; + u32 writen_start=0; + u32 lpc=inpage_ptr; + u32 stg=pgsz; + + while(stg>0) + { + u32 bit=(lpc>>4)&7; + if (mask==0) + { + //writen=bit; + writen_start=(((u8*)PSM(lpc)-vtlb_alloc_base)>>4)/8; + } + mask|=1<>4); + mask=0; + } + + //writen++; + + if (stg<=16) + { + lpc+=stg; + stg=0; + } + else + { + lpc+=16; + stg-=16; + } + } + + if (mask) + { + vtlb_alloc_bits[writen_start]&=~mask; + TEST32ItoM((uptr)&vtlb_alloc_bits[writen_start],mask); + JNZ32(((u32)&dyna_block_discard)- ( (u32)x86Ptr[0] + 6 )); + SysPrintf("%08X %d %d\n",mask,pgsz,pgsz>>4); + mask=0; + } + + /* u32 lpc=inpage_ptr; u32 stg=pgsz; while(stg>0) @@ -1719,6 +1773,7 @@ StartRecomp: stg-=4; lpc+=4; } + */ DbgCon::WriteLn("Manual block @ %08X : %08X %d %d %d %d", params startpc,inpage_ptr,pgsz,0x1000-inpage_offs,inpage_sz,sz*4); } diff --git a/pcsx2/x86/ix86-32/recVTLB.cpp b/pcsx2/x86/ix86-32/recVTLB.cpp index d830a26d9d..243acb01be 100644 --- a/pcsx2/x86/ix86-32/recVTLB.cpp +++ b/pcsx2/x86/ix86-32/recVTLB.cpp @@ -28,6 +28,10 @@ u8* code_pos=0; u8* code_start=0; u32 code_sz; +#define VTLB_ALLOC_SIZE (0x2900000) //this is a bit more than required +extern u8* vtlb_alloc_base; //base of the memory array +extern u8 vtlb_alloc_bits[VTLB_ALLOC_SIZE/16/8]; //328 kb + union _vtlb_MemOpInfo { struct @@ -82,6 +86,7 @@ void execuCode(bool set) u8* IndirectPlaceholderA() { + //Add32 ,imm, 6 bytes form. write8<_EmitterId_>( 0x81 ); ModRM<_EmitterId_>( 3, 0, EAX ); @@ -100,7 +105,7 @@ void IndirectPlaceholderB(u8* pl,bool read,u32 sz,bool sx) u8* old=x86SetPtr(pl); inf.skip=old-pl-4; - //Add32 ,imm, 6 bytes form. + //Add32 ,imm, 6 bytes form, patch the imm value write32<_EmitterId_>( inf.full ); x86SetPtr(old); } @@ -470,7 +475,13 @@ static void _vtlb_DynGen_DirectWrite( u32 bits ) break; } -// SHR32ItoR(ECX,4);// do /16 + SHR32ItoR(ECX,4);// do /16 + uptr alloc_base=(uptr)vtlb_alloc_base; + + uptr bits_base=(uptr)vtlb_alloc_bits; + bits_base-=(alloc_base>>4)/8;//in bytes + + BTS32MtoR(bits_base,ECX); // BTS_wtf(asdasd,ECX); } diff --git a/pcsx2/x86/ix86/ix86.inl b/pcsx2/x86/ix86/ix86.inl index 7394bd6a3a..24e197ffcf 100644 --- a/pcsx2/x86/ix86/ix86.inl +++ b/pcsx2/x86/ix86/ix86.inl @@ -2311,6 +2311,15 @@ emitterT void eAND32ItoM( uptr to, u32 from ) } } +/* bts imm32 to r32 */ +emitterT void eBTS32MtoR( uptr to, x86IntRegType from ) +{ + RexR(0,from); + write8( 0xf ); + write8( 0xab ); + ModRM( 0, from, DISP32 ); + write32( MEMADDR(to, 4) ); +} /* and sign ext imm8 to m32 */ emitterT void eAND32I8toM( uptr to, u8 from ) diff --git a/pcsx2/x86/ix86/ix86_macros.h b/pcsx2/x86/ix86/ix86_macros.h index 2ad9cdfe47..560b68e8aa 100644 --- a/pcsx2/x86/ix86/ix86_macros.h +++ b/pcsx2/x86/ix86/ix86_macros.h @@ -286,6 +286,7 @@ #define AND8RtoM eAND8RtoM<_EmitterId_> #define AND8MtoR eAND8MtoR<_EmitterId_> #define AND8RtoR eAND8RtoR<_EmitterId_> +#define BTS32MtoR eBTS32MtoR<_EmitterId_> #define NOT64R eNOT64R<_EmitterId_> #define NOT32R eNOT32R<_EmitterId_> #define NOT32M eNOT32M<_EmitterId_> From 13cda40ec83a4f91c4353bf3d043124056d23ae8 Mon Sep 17 00:00:00 2001 From: cottonvibes Date: Mon, 27 Apr 2009 02:20:09 +0000 Subject: [PATCH 05/41] microVU: -Finished operand logging, so microprogram logs are very detailed. -Apparently XGkick specifies the address divided by 16 (thats how zerorecs handles it), so now microVU does the same thing. -Zerorecs also saves '(PC+16)/8' instead of 'PC+16' in BAL/JALR instructions, so I did the same with microVU... git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1070 96395faa-99c1-11dd-bbfe-3dabce05a288 --- pcsx2/x86/microVU_Alloc.inl | 10 ++-- pcsx2/x86/microVU_Analyze.inl | 13 +---- pcsx2/x86/microVU_Compile.inl | 1 + pcsx2/x86/microVU_Execute.inl | 2 + pcsx2/x86/microVU_Log.inl | 2 +- pcsx2/x86/microVU_Lower.inl | 103 ++++++++++++++++++---------------- pcsx2/x86/microVU_Misc.h | 7 ++- pcsx2/x86/microVU_Misc.inl | 2 +- pcsx2/x86/microVU_Upper.inl | 77 ++++++++++++++----------- 9 files changed, 116 insertions(+), 101 deletions(-) diff --git a/pcsx2/x86/microVU_Alloc.inl b/pcsx2/x86/microVU_Alloc.inl index 72c4a56f24..d22af17fdd 100644 --- a/pcsx2/x86/microVU_Alloc.inl +++ b/pcsx2/x86/microVU_Alloc.inl @@ -72,7 +72,7 @@ microVUt(void) mVUallocFMAC2a(int& Fs, int& Ft) { microVUt(void) mVUallocFMAC2b(int& Ft) { microVU* mVU = mVUx; - if (!_Ft_) { SysPrintf("microVU: If a game does this, its retarded...\n"); return; } + if (!_Ft_) return; //if (CHECK_VU_OVERFLOW) mVUclamp1(Ft, xmmT1, _X_Y_Z_W); mVUsaveReg(Ft, (uptr)&mVU->regs->VF[_Ft_].UL[0], _X_Y_Z_W, 1); } @@ -533,7 +533,7 @@ microVUt(void) mVUallocFMAC18b(int& ACC, int& Fs) { } //------------------------------------------------------------------ -// FMAC19 - OPMULA FMAC Opcode +// FMAC19 - OPMSUB FMAC Opcode //------------------------------------------------------------------ microVUt(void) mVUallocFMAC19a(int& Fd, int& ACC, int& Fs, int& Ft) { @@ -727,9 +727,9 @@ microVUt(void) mVUallocVIb(int GPRreg, int _reg_) { MOV32RtoM((uptr)&mVU->VIbackup[0], GPRreg); MOV32MtoR(GPRreg, (uptr)&mVU->VIbackup[1]); } - if (_reg_ == 0) { return; } - else if (_reg_ < 9) { MOVD32RtoMMX(mmVI(_reg_), GPRreg); } - else { MOV16RtoM((uptr)&mVU->regs->VI[_reg_].UL, GPRreg); } + if (_reg_ == 0) { return; } + else if (_reg_ < 9) { MOVD32RtoMMX(mmVI(_reg_), GPRreg); } + else if (_reg_ < 16) { MOV16RtoM((uptr)&mVU->regs->VI[_reg_].UL, GPRreg); } } //------------------------------------------------------------------ diff --git a/pcsx2/x86/microVU_Analyze.inl b/pcsx2/x86/microVU_Analyze.inl index 7a1992570f..7a6dc106c7 100644 --- a/pcsx2/x86/microVU_Analyze.inl +++ b/pcsx2/x86/microVU_Analyze.inl @@ -146,7 +146,6 @@ microVUt(void) mVUanalyzeIALU2(int Is, int It) { microVUt(void) mVUanalyzeMR32(int Fs, int Ft) { microVU* mVU = mVUx; - mVUprint("microVU: MR32 Opcode"); if (!Ft) { mVUinfo |= _isNOP; } analyzeReg6(Fs); analyzeReg2(Ft); @@ -202,7 +201,6 @@ microVUt(void) mVUanalyzeEFU2(int Fs, u8 xCycles) { microVUt(void) mVUanalyzeMFP(int Ft) { microVU* mVU = mVUx; - mVUprint("microVU: MFP Opcode"); if (!Ft) { mVUinfo |= _isNOP; } analyzeReg2(Ft); } @@ -239,14 +237,12 @@ microVUt(void) mVUanalyzeSQ(int Fs, int It, bool writeIt) { microVUt(void) mVUanalyzeR1(int Fs, int Fsf) { microVU* mVU = mVUx; - mVUprint("microVU: R-reg Opcode"); analyzeReg5(Fs, Fsf); analyzeRreg(); } microVUt(void) mVUanalyzeR2(int Ft, bool canBeNOP) { microVU* mVU = mVUx; - mVUprint("microVU: R-reg Opcode"); if (!Ft) { mVUinfo |= ((canBeNOP) ? _isNOP : _noWriteVF); } analyzeReg2(Ft); analyzeRreg(); @@ -258,7 +254,6 @@ microVUt(void) mVUanalyzeR2(int Ft, bool canBeNOP) { microVUt(void) mVUanalyzeSflag(int It) { microVU* mVU = mVUx; - mVUprint("microVU: Sflag Opcode"); if (!It) { mVUinfo |= _isNOP; } else { // Sets _isSflag at instruction that FSxxx opcode reads it's status flag from mVUinfo |= _swapOps; @@ -274,7 +269,6 @@ microVUt(void) mVUanalyzeSflag(int It) { microVUt(void) mVUanalyzeFSSET() { microVU* mVU = mVUx; mVUinfo |= _isFSSET; - mVUprint("microVU: FSSET Opcode"); // mVUinfo &= ~_doStatus; // Note: I'm not entirely sure if the non-sticky flags // should be taken from the current upper instruction @@ -288,7 +282,6 @@ microVUt(void) mVUanalyzeFSSET() { microVUt(void) mVUanalyzeMflag(int Is, int It) { microVU* mVU = mVUx; - mVUprint("microVU: Mflag Opcode"); if (!It) { mVUinfo |= _isNOP; } else { // Need set _doMac for 4 previous Ops (need to do all 4 because stalls could change the result needed) mVUinfo |= _swapOps; @@ -324,13 +317,13 @@ microVUt(void) mVUanalyzeXGkick(int Fs, int xCycles) { #define analyzeBranchVI(reg, infoVal) { \ if (reg && (mVUcount > 0)) { /* Ensures branch is not first opcode in block */ \ - incPC(-2); \ + incPC2(-2); \ if (writesVI && (reg == mVU->VIbackup[0])) { /* If prev Op modified VI reg */ \ mVUinfo |= _backupVI; \ - incPC(2); \ + incPC2(2); \ mVUinfo |= infoVal; \ } \ - else { incPC(2); } \ + else { incPC2(2); } \ } \ } diff --git a/pcsx2/x86/microVU_Compile.inl b/pcsx2/x86/microVU_Compile.inl index aa60df2037..6b9f7a898d 100644 --- a/pcsx2/x86/microVU_Compile.inl +++ b/pcsx2/x86/microVU_Compile.inl @@ -34,6 +34,7 @@ else { ajmp = JMPcc((uptr)0); } \ break +// ToDo: Fix this properly. #define flagSetMacro(xFlag, pFlag, xF, yF, zF) { \ yF += (mVUstall > 3) ? 3 : mVUstall; \ if (yF > zF) { \ diff --git a/pcsx2/x86/microVU_Execute.inl b/pcsx2/x86/microVU_Execute.inl index ff892ab0ca..ad5b2dfc30 100644 --- a/pcsx2/x86/microVU_Execute.inl +++ b/pcsx2/x86/microVU_Execute.inl @@ -144,6 +144,8 @@ microVUt(void*) __fastcall mVUexecute(u32 startPC, u32 cycles) { microVUt(void) mVUcleanUp() { microVU* mVU = mVUx; //mVUprint("microVU: Program exited successfully!"); + //mVUprint("microVU: VF0 = {%x,%x,%x,%x}", params mVU->regs->VF[0].UL[0], mVU->regs->VF[0].UL[1], mVU->regs->VF[0].UL[2], mVU->regs->VF[0].UL[3]); + //mVUprint("microVU: VI0 = %x", params mVU->regs->VI[0].UL); mVUcurProg.x86ptr = x86Ptr; mVUcacheCheck(x86Ptr, mVUcurProg.x86start, (uptr)(mVUcurProg.x86end - mVUcurProg.x86start)); } diff --git a/pcsx2/x86/microVU_Log.inl b/pcsx2/x86/microVU_Log.inl index 4aaf139880..12a1b4c42e 100644 --- a/pcsx2/x86/microVU_Log.inl +++ b/pcsx2/x86/microVU_Log.inl @@ -47,7 +47,7 @@ microVUx(void) __mVULog(const char* fmt, ...) { microVUt(void) __mVUdumpProgram(int progIndex) { microVU* mVU = mVUx; bool bitX[7]; - //mVU->prog.cur = progIndex; // Needed in order to set iPC + mVUlog("*********************\n", progIndex); mVUlog("* Micro-Program #%02d *\n", progIndex); mVUlog("*********************\n\n", progIndex); diff --git a/pcsx2/x86/microVU_Lower.inl b/pcsx2/x86/microVU_Lower.inl index 2522ef83a0..ff562494c1 100644 --- a/pcsx2/x86/microVU_Lower.inl +++ b/pcsx2/x86/microVU_Lower.inl @@ -76,7 +76,7 @@ microVUf(void) mVU_DIV() { mVUunpack_xyzw(xmmFs, xmmFs, 0); mVUmergeRegs(xmmPQ, xmmFs, writeQ ? 4 : 8); } - pass3 { mVUlog("DIV"); } + pass3 { mVUlog("DIV Q, vf%02d%s, vf%02d%s", _Fs_, _Fsf_String, _Ft_, _Ftf_String); } } microVUf(void) mVU_SQRT() { @@ -94,7 +94,7 @@ microVUf(void) mVU_SQRT() { mVUunpack_xyzw(xmmFt, xmmFt, 0); mVUmergeRegs(xmmPQ, xmmFt, writeQ ? 4 : 8); } - pass3 { mVUlog("SQRT"); } + pass3 { mVUlog("SQRT Q, vf%02d%s", _Ft_, _Ftf_String); } } microVUf(void) mVU_RSQRT() { @@ -132,7 +132,7 @@ microVUf(void) mVU_RSQRT() { mVUunpack_xyzw(xmmFs, xmmFs, 0); mVUmergeRegs(xmmPQ, xmmFs, writeQ ? 4 : 8); } - pass3 { mVUlog("RSQRT"); } + pass3 { mVUlog("RSQRT Q, vf%02d%s, vf%02d%s", _Fs_, _Fsf_String, _Ft_, _Ftf_String); } } //------------------------------------------------------------------ @@ -181,7 +181,7 @@ microVUf(void) mVU_EATAN() { mVU_EATAN_(); } - pass3 { mVUlog("EATAN"); } + pass3 { mVUlog("EATAN P"); } } microVUf(void) mVU_EATANxy() { @@ -199,7 +199,7 @@ microVUf(void) mVU_EATANxy() { mVU_EATAN_(); } - pass3 { mVUlog("EATANxy"); } + pass3 { mVUlog("EATANxy P"); } } microVUf(void) mVU_EATANxz() { @@ -217,7 +217,7 @@ microVUf(void) mVU_EATANxz() { mVU_EATAN_(); } - pass3 { mVUlog("EATANxz"); } + pass3 { mVUlog("EATANxz P"); } } #define eexpHelper(addr) { \ @@ -257,7 +257,7 @@ microVUf(void) mVU_EEXP() { SSE_MOVSS_XMM_to_XMM(xmmPQ, xmmT1); SSE2_PSHUFD_XMM_to_XMM(xmmPQ, xmmPQ, writeP ? 0x27 : 0xC6); // Flip back } - pass3 { mVUlog("EEXP"); } + pass3 { mVUlog("EEXP P"); } } microVUt(void) mVU_sumXYZ() { @@ -286,7 +286,7 @@ microVUf(void) mVU_ELENG() { SSE_SQRTSS_XMM_to_XMM(xmmPQ, xmmPQ); SSE2_PSHUFD_XMM_to_XMM(xmmPQ, xmmPQ, writeP ? 0x27 : 0xC6); // Flip back } - pass3 { mVUlog("ELENG"); } + pass3 { mVUlog("ELENG P"); } } microVUf(void) mVU_ERCPR() { @@ -301,7 +301,7 @@ microVUf(void) mVU_ERCPR() { SSE_MOVSS_XMM_to_XMM(xmmPQ, xmmFs); SSE2_PSHUFD_XMM_to_XMM(xmmPQ, xmmPQ, writeP ? 0x27 : 0xC6); // Flip back } - pass3 { mVUlog("ERCPR"); } + pass3 { mVUlog("ERCPR P"); } } microVUf(void) mVU_ERLENG() { @@ -317,7 +317,7 @@ microVUf(void) mVU_ERLENG() { SSE_MOVSS_XMM_to_XMM(xmmPQ, xmmFs); SSE2_PSHUFD_XMM_to_XMM(xmmPQ, xmmPQ, writeP ? 0x27 : 0xC6); // Flip back } - pass3 { mVUlog("ERLENG"); } + pass3 { mVUlog("ERLENG P"); } } microVUf(void) mVU_ERSADD() { @@ -333,7 +333,7 @@ microVUf(void) mVU_ERSADD() { SSE_MOVSS_XMM_to_XMM(xmmPQ, xmmFs); SSE2_PSHUFD_XMM_to_XMM(xmmPQ, xmmPQ, writeP ? 0x27 : 0xC6); // Flip back } - pass3 { mVUlog("ERSADD"); } + pass3 { mVUlog("ERSADD P"); } } microVUf(void) mVU_ERSQRT() { @@ -348,7 +348,7 @@ microVUf(void) mVU_ERSQRT() { SSE_MOVSS_XMM_to_XMM(xmmPQ, xmmFs); SSE2_PSHUFD_XMM_to_XMM(xmmPQ, xmmPQ, writeP ? 0x27 : 0xC6); // Flip back } - pass3 { mVUlog("ERSQRT"); } + pass3 { mVUlog("ERSQRT P"); } } microVUf(void) mVU_ESADD() { @@ -360,7 +360,7 @@ microVUf(void) mVU_ESADD() { mVU_sumXYZ(); SSE2_PSHUFD_XMM_to_XMM(xmmPQ, xmmPQ, writeP ? 0x27 : 0xC6); // Flip back } - pass3 { mVUlog("ESADD"); } + pass3 { mVUlog("ESADD P"); } } #define esinHelper(addr) { \ @@ -394,7 +394,7 @@ microVUf(void) mVU_ESIN() { SSE_ADDSS_XMM_to_XMM(xmmPQ, xmmT1); SSE2_PSHUFD_XMM_to_XMM(xmmPQ, xmmPQ, writeP ? 0x27 : 0xC6); // Flip back } - pass3 { mVUlog("ESIN"); } + pass3 { mVUlog("ESIN P"); } } microVUf(void) mVU_ESQRT() { @@ -406,7 +406,7 @@ microVUf(void) mVU_ESQRT() { SSE_SQRTSS_XMM_to_XMM(xmmPQ, xmmFs); SSE2_PSHUFD_XMM_to_XMM(xmmPQ, xmmPQ, writeP ? 0x27 : 0xC6); // Flip back } - pass3 { mVUlog("ESQRT"); } + pass3 { mVUlog("ESQRT P"); } } microVUf(void) mVU_ESUM() { @@ -422,7 +422,7 @@ microVUf(void) mVU_ESUM() { SSE_MOVSS_XMM_to_XMM(xmmPQ, xmmFs); SSE2_PSHUFD_XMM_to_XMM(xmmPQ, xmmPQ, writeP ? 0x27 : 0xC6); // Flip back } - pass3 { mVUlog("ESUM"); } + pass3 { mVUlog("ESUM P"); } } //------------------------------------------------------------------ @@ -438,7 +438,7 @@ microVUf(void) mVU_FCAND() { SHR32ItoR(gprT1, 24); mVUallocVIb(gprT1, 1); } - pass3 { mVUlog("FCAND"); } + pass3 { mVUlog("FCAND vi01, $%x", _Imm24_); } } microVUf(void) mVU_FCEQ() { @@ -450,7 +450,7 @@ microVUf(void) mVU_FCEQ() { SHR32ItoR(gprT1, 31); mVUallocVIb(gprT1, 1); } - pass3 { mVUlog("FCEQ"); } + pass3 { mVUlog("FCEQ vi01, $%x", _Imm24_); } } microVUf(void) mVU_FCGET() { @@ -460,7 +460,7 @@ microVUf(void) mVU_FCGET() { AND32ItoR(gprT1, 0xfff); mVUallocVIb(gprT1, _Ft_); } - pass3 { mVUlog("FCGET"); } + pass3 { mVUlog("FCGET vi%02d", _Ft_); } } microVUf(void) mVU_FCOR() { @@ -472,7 +472,7 @@ microVUf(void) mVU_FCOR() { SHR32ItoR(gprT1, 24); // Get the 25th bit (also clears the rest of the garbage in the reg) mVUallocVIb(gprT1, 1); } - pass3 { mVUlog("FCOR"); } + pass3 { mVUlog("FCOR vi01, $%x", _Imm24_); } } microVUf(void) mVU_FCSET() { @@ -482,7 +482,7 @@ microVUf(void) mVU_FCSET() { MOV32ItoR(gprT1, _Imm24_); mVUallocCFLAGb(gprT1, fcInstance); } - pass3 { mVUlog("FCSET"); } + pass3 { mVUlog("FCSET $%x", _Imm24_); } } //------------------------------------------------------------------ @@ -498,7 +498,7 @@ microVUf(void) mVU_FMAND() { AND16RtoR(gprT1, gprT2); mVUallocVIb(gprT1, _Ft_); } - pass3 { mVUlog("FMAND"); } + pass3 { mVUlog("FMAND vi%02d, vi%02d", _Ft_, _Fs_); } } microVUf(void) mVU_FMEQ() { @@ -512,7 +512,7 @@ microVUf(void) mVU_FMEQ() { SHR32ItoR(gprT1, 31); mVUallocVIb(gprT1, _Ft_); } - pass3 { mVUlog("FMEQ"); } + pass3 { mVUlog("FMEQ vi%02d, vi%02d", _Ft_, _Fs_); } } microVUf(void) mVU_FMOR() { @@ -524,7 +524,7 @@ microVUf(void) mVU_FMOR() { OR16RtoR(gprT1, gprT2); mVUallocVIb(gprT1, _Ft_); } - pass3 { mVUlog("FMOR"); } + pass3 { mVUlog("FMOR vi%02d, vi%02d", _Ft_, _Fs_); } } //------------------------------------------------------------------ @@ -539,7 +539,7 @@ microVUf(void) mVU_FSAND() { AND16ItoR(gprT1, _Imm12_); mVUallocVIb(gprT1, _Ft_); } - pass3 { mVUlog("FSAND"); } + pass3 { mVUlog("FSAND vi%02d, $%x", _Ft_, _Imm12_); } } microVUf(void) mVU_FSEQ() { @@ -552,7 +552,7 @@ microVUf(void) mVU_FSEQ() { SHR16ItoR(gprT1, 15); mVUallocVIb(gprT1, _Ft_); } - pass3 { mVUlog("FSEQ"); } + pass3 { mVUlog("FSEQ vi%02d, $%x", _Ft_, _Imm12_); } } microVUf(void) mVU_FSOR() { @@ -563,7 +563,7 @@ microVUf(void) mVU_FSOR() { OR16ItoR(gprT1, _Imm12_); mVUallocVIb(gprT1, _Ft_); } - pass3 { mVUlog("FSOR"); } + pass3 { mVUlog("FSOR vi%02d, $%x", _Ft_, _Imm12_); } } microVUf(void) mVU_FSSET() { @@ -576,7 +576,7 @@ microVUf(void) mVU_FSSET() { AND16ItoR(flagReg1, 0x03f); // Remember not to modify upper 16 bits because of mac flag OR16ItoR (flagReg1, (_Imm12_ & 0xfc0)); } - pass3 { mVUlog("FSSET"); } + pass3 { mVUlog("FSSET $%x", _Imm12_); } } //------------------------------------------------------------------ @@ -595,7 +595,7 @@ microVUf(void) mVU_IADD() { else ADD16RtoR(gprT1, gprT1); mVUallocVIb(gprT1, _Fd_); } - pass3 { mVUlog("IADD"); } + pass3 { mVUlog("IADD vi%02d, vi%02d, vi%02d", _Fd_, _Fs_, _Ft_); } } microVUf(void) mVU_IADDI() { @@ -606,7 +606,7 @@ microVUf(void) mVU_IADDI() { ADD16ItoR(gprT1, _Imm5_); mVUallocVIb(gprT1, _Ft_); } - pass3 { mVUlog("IADDI"); } + pass3 { mVUlog("IADDI vi%02d, vi%02d, %d", _Ft_, _Fs_, _Imm5_); } } microVUf(void) mVU_IADDIU() { @@ -617,7 +617,7 @@ microVUf(void) mVU_IADDIU() { ADD16ItoR(gprT1, _Imm15_); mVUallocVIb(gprT1, _Ft_); } - pass3 { mVUlog("IADDIU"); } + pass3 { mVUlog("IADDIU vi%02d, vi%02d, %d", _Ft_, _Fs_, _Imm15_); } } microVUf(void) mVU_IAND() { @@ -631,7 +631,7 @@ microVUf(void) mVU_IAND() { } mVUallocVIb(gprT1, _Fd_); } - pass3 { mVUlog("IAND"); } + pass3 { mVUlog("IAND vi%02d, vi%02d, vi%02d", _Fd_, _Fs_, _Ft_); } } microVUf(void) mVU_IOR() { @@ -645,7 +645,7 @@ microVUf(void) mVU_IOR() { } mVUallocVIb(gprT1, _Fd_); } - pass3 { mVUlog("IOR"); } + pass3 { mVUlog("IOR vi%02d, vi%02d, vi%02d", _Fd_, _Fs_, _Ft_); } } microVUf(void) mVU_ISUB() { @@ -664,7 +664,7 @@ microVUf(void) mVU_ISUB() { } else { PXORRtoR(mmVI(_Fd_), mmVI(_Fd_)); } } - pass3 { mVUlog("ISUB"); } + pass3 { mVUlog("ISUB vi%02d, vi%02d, vi%02d", _Fd_, _Fs_, _Ft_); } } microVUf(void) mVU_ISUBIU() { @@ -675,7 +675,7 @@ microVUf(void) mVU_ISUBIU() { SUB16ItoR(gprT1, _Imm15_); mVUallocVIb(gprT1, _Ft_); } - pass3 { mVUlog("ISUBIU"); } + pass3 { mVUlog("ISUBIU vi%02d, vi%02d, %d", _Ft_, _Fs_, _Imm15_); } } //------------------------------------------------------------------ @@ -692,7 +692,7 @@ microVUf(void) mVU_MFIR() { if (!_XYZW_SS) { mVUunpack_xyzw(xmmT1, xmmT1, 0); } mVUsaveReg(xmmT1, (uptr)&mVU->regs->VF[_Ft_].UL[0], _X_Y_Z_W, 1); } - pass3 { mVUlog("MFIR"); } + pass3 { mVUlog("MFIR.%s vf%02d, vi%02d", _XYZW_String, _Ft_, _Fs_); } } microVUf(void) mVU_MFP() { @@ -702,7 +702,7 @@ microVUf(void) mVU_MFP() { getPreg(xmmFt); mVUsaveReg(xmmFt, (uptr)&mVU->regs->VF[_Ft_].UL[0], _X_Y_Z_W, 1); } - pass3 { mVUlog("MFP"); } + pass3 { mVUlog("MFP.%s vf%02d, P", _XYZW_String, _Ft_); } } microVUf(void) mVU_MOVE() { @@ -712,7 +712,7 @@ microVUf(void) mVU_MOVE() { mVUloadReg(xmmT1, (uptr)&mVU->regs->VF[_Fs_].UL[0], _X_Y_Z_W); mVUsaveReg(xmmT1, (uptr)&mVU->regs->VF[_Ft_].UL[0], _X_Y_Z_W, 1); } - pass3 { mVUlog("MOVE"); } + pass3 { mVUlog("MOVE.%s vf%02d, vf%02d", _XYZW_String, _Ft_, _Fs_); } } microVUf(void) mVU_MR32() { @@ -723,7 +723,7 @@ microVUf(void) mVU_MR32() { if (_X_Y_Z_W != 8) { SSE2_PSHUFD_XMM_to_XMM(xmmT1, xmmT1, 0x39); } mVUsaveReg(xmmT1, (uptr)&mVU->regs->VF[_Ft_].UL[0], _X_Y_Z_W, 0); } - pass3 { mVUlog("MR32"); } + pass3 { mVUlog("MR32.%s vf%02d, vf%02d", _XYZW_String, _Ft_, _Fs_); } } microVUf(void) mVU_MTIR() { @@ -733,7 +733,7 @@ microVUf(void) mVU_MTIR() { MOVZX32M16toR(gprT1, (uptr)&mVU->regs->VF[_Fs_].UL[_Fsf_]); mVUallocVIb(gprT1, _Ft_); } - pass3 { mVUlog("MTIR"); } + pass3 { mVUlog("MTIR vi%02d, vf%02d%s", _Ft_, _Fs_, _Fsf_String); } } //------------------------------------------------------------------ @@ -757,7 +757,7 @@ microVUf(void) mVU_ILW() { mVUallocVIb(gprT1, _Ft_); } } - pass3 { mVUlog("ILW"); } + pass3 { mVUlog("ILW.%s vi%02d, vi%02d + %d", _XYZW_String, _Ft_, _Fs_, _Imm11_); } } microVUf(void) mVU_ILWR() { @@ -771,12 +771,11 @@ microVUf(void) mVU_ILWR() { else { mVUallocVIa(gprT1, _Fs_); mVUaddrFix(gprT1); - MOV32RmtoR(gprT1, gprT1, (uptr)mVU->regs->Mem + offsetSS); - if (isMMX(_Ft_)) AND32ItoR(gprT1, 0xffff); + MOVZX32Rm16toR(gprT1, gprT1, (uptr)mVU->regs->Mem + offsetSS); mVUallocVIb(gprT1, _Ft_); } } - pass3 { mVUlog("ILWR"); } + pass3 { mVUlog("ILWR.%s vi%02d, vi%02d", _XYZW_String, _Ft_, _Fs_); } } //------------------------------------------------------------------ @@ -806,7 +805,7 @@ microVUf(void) mVU_ISW() { if (_W) MOV32RtoRm(gprT1, gprT2, (uptr)mVU->regs->Mem+12); } } - pass3 { mVUlog("ISW"); } + pass3 { mVUlog("ISW.%s vi%02d, vi%02d + %d", _XYZW_String, _Ft_, _Fs_, _Imm11_); } } microVUf(void) mVU_ISWR() { @@ -830,7 +829,7 @@ microVUf(void) mVU_ISWR() { if (_W) MOV32RtoRm(gprT1, gprT2, (uptr)mVU->regs->Mem+12); } } - pass3 { mVUlog("ISWR"); } + pass3 { mVUlog("ISWR.%s vi%02d, vi%02d", _XYZW_String, _Ft_, _Fs_); } } //------------------------------------------------------------------ @@ -1081,6 +1080,7 @@ microVUf(void) mVU_XITOP() { //------------------------------------------------------------------ void __fastcall mVU_XGKICK_(u32 addr) { + addr = (addr<<4) & 0x3fff; // Multiply addr by 16 to get real address u32 *data = (u32*)(microVU1.regs->Mem + (addr&0x3fff)); u32 size = mtgsThread->PrepDataPacket( GIF_PATH_1, data, (0x4000-(addr&0x3fff)) >> 4); u8 *pDest = mtgsThread->GetDataPacketPtr(); @@ -1088,6 +1088,10 @@ void __fastcall mVU_XGKICK_(u32 addr) { mtgsThread->SendDataPacket(); } +void __fastcall mVU_XGKICK__(u32 addr) { + GSGIFTRANSFER1((u32*)microVU1.regs->Mem, ((addr<<4)&0x3fff)); +} + microVUf(void) mVU_XGKICK() { microVU* mVU = mVUx; pass1 { mVUanalyzeXGkick(_Fs_, 4); } @@ -1095,7 +1099,8 @@ microVUf(void) mVU_XGKICK() { mVUprint("XGkick"); mVUallocVIa(gprT2, _Fs_); // gprT2 = ECX for __fastcall PUSH32R(gprR); // gprR = EDX is volatile so backup - CALLFunc((uptr)mVU_XGKICK_); + if (mtgsThread != NULL) CALLFunc((uptr)mVU_XGKICK_); + else CALLFunc((uptr)mVU_XGKICK__); POP32R(gprR); // Restore } pass3 { mVUlog("XGKICK vi%02d", _Fs_); } @@ -1197,6 +1202,8 @@ microVUf(void) mVU_JR() { pass2 { if (memReadIs) MOV32MtoR(gprT1, (uptr)&mVU->VIbackup[0]); else mVUallocVIa(gprT1, _Fs_); + SHL32ItoR(gprT1, 3); + AND32ItoR(gprT1, vuIndex ? 0x3ff8 : 0xff8); MOV32RtoM((uptr)&mVU->branch, gprT1); } pass3 { mVUlog("JR [vi%02d]", _Fs_); } @@ -1208,6 +1215,8 @@ microVUf(void) mVU_JALR() { pass2 { if (memReadIs) MOV32MtoR(gprT1, (uptr)&mVU->VIbackup[0]); else mVUallocVIa(gprT1, _Fs_); + SHL32ItoR(gprT1, 3); + AND32ItoR(gprT1, vuIndex ? 0x3ff8 : 0xff8); MOV32RtoM((uptr)&mVU->branch, gprT1); MOV32ItoR(gprT1, bSaveAddr); mVUallocVIb(gprT1, _Ft_); diff --git a/pcsx2/x86/microVU_Misc.h b/pcsx2/x86/microVU_Misc.h index fb2eb21fec..acd86c3a7d 100644 --- a/pcsx2/x86/microVU_Misc.h +++ b/pcsx2/x86/microVU_Misc.h @@ -88,7 +88,7 @@ declareAllVariables #define _Fsf_ ((mVU->code >> 21) & 0x03) #define _Ftf_ ((mVU->code >> 23) & 0x03) -#define _Imm5_ (((mVU->code & 0x400) ? 0xfff0 : 0) | ((mVU->code >> 6) & 0xf)) +#define _Imm5_ (s16)(((mVU->code & 0x400) ? 0xfff0 : 0) | ((mVU->code >> 6) & 0xf)) #define _Imm11_ (s32)((mVU->code & 0x400) ? (0xfffffc00 | (mVU->code & 0x3ff)) : mVU->code & 0x3ff) #define _Imm12_ (((mVU->code >> 21) & 0x1) << 11) | (mVU->code & 0x7ff) #define _Imm15_ (((mVU->code >> 10) & 0x7800) | (mVU->code & 0x7ff)) @@ -161,13 +161,14 @@ declareAllVariables #define incPC(x) { iPC = ((iPC + x) & (mVU->progSize-1)); setCode(); } #define incPC2(x) { iPC = ((iPC + x) & (mVU->progSize-1)); } #define incCycles(x) { mVUincCycles(x); } -#define bSaveAddr ((xPC + (2 * 8)) & ((vuIndex) ? 0x3ff8:0xff8)) +#define bSaveAddr (((xPC + (2 * 8)) & ((vuIndex) ? 0x3ff8:0xff8)) / 8) #define branchAddr ((xPC + 8 + (_Imm11_ * 8)) & ((vuIndex) ? 0x3ff8:0xff8)) -#define shufflePQ (((mVU->q) ? 0xb0 : 0xe0) | ((mVU->q) ? 0x01 : 0x04)) +#define shufflePQ (((mVU->p) ? 0xb0 : 0xe0) | ((mVU->q) ? 0x01 : 0x04)) #define _Fsf_String ((_Fsf_ == 3) ? "w" : ((_Fsf_ == 2) ? "z" : ((_Fsf_ == 1) ? "y" : "x"))) #define _Ftf_String ((_Ftf_ == 3) ? "w" : ((_Ftf_ == 2) ? "z" : ((_Ftf_ == 1) ? "y" : "x"))) #define xyzwStr(x,s) (_X_Y_Z_W == x) ? s : #define _XYZW_String (xyzwStr(1, "w") (xyzwStr(2, "z") (xyzwStr(3, "zw") (xyzwStr(4, "y") (xyzwStr(5, "yw") (xyzwStr(6, "yz") (xyzwStr(7, "yzw") (xyzwStr(8, "x") (xyzwStr(9, "xw") (xyzwStr(10, "xz") (xyzwStr(11, "xzw") (xyzwStr(12, "xy") (xyzwStr(13, "xyw") (xyzwStr(14, "xyz") "xyzw")))))))))))))) +#define _BC_String (_bc_x ? "x" : (_bc_y ? "y" : (_bc_z ? "z" : "w"))) #define _isNOP (1<<0) // Skip Lower Instruction diff --git a/pcsx2/x86/microVU_Misc.inl b/pcsx2/x86/microVU_Misc.inl index 895507cc4e..59ca4ee4f7 100644 --- a/pcsx2/x86/microVU_Misc.inl +++ b/pcsx2/x86/microVU_Misc.inl @@ -264,7 +264,7 @@ microVUx(void) mVUmergeRegs(int dest, int src, int xyzw) { // Transforms the Address in gprReg to valid VU0/VU1 Address microVUt(void) mVUaddrFix(int gprReg) { - if ( vuIndex == 1 ) { + if (vuIndex) { AND32ItoR(gprReg, 0x3ff); // wrap around SHL32ItoR(gprReg, 4); } diff --git a/pcsx2/x86/microVU_Upper.inl b/pcsx2/x86/microVU_Upper.inl index 2d45895a63..f265db53a9 100644 --- a/pcsx2/x86/microVU_Upper.inl +++ b/pcsx2/x86/microVU_Upper.inl @@ -78,6 +78,15 @@ microVUt(void) mVUupdateFlags(int reg, int regT1, int regT2, int xyzw, bool modX // Helper Macros //------------------------------------------------------------------ +#define mVUlogFtFs() { mVUlog(".%s vf%02d, vf%02d", _XYZW_String, _Ft_, _Fs_); } +#define mVUlogFd() { mVUlog(".%s vf%02d, vf%02d", _XYZW_String, _Fd_, _Fs_); } +#define mVUlogACC() { mVUlog(".%s ACC, vf%02d", _XYZW_String, _Fs_); } +#define mVUlogFt() { mVUlog(", vf%02d", _Ft_); } +#define mVUlogBC() { mVUlog(", vf%02d%s", _Ft_, _BC_String); } +#define mVUlogI() { mVUlog(", I"); } +#define mVUlogQ() { mVUlog(", Q"); } +#define mVUlogCLIP() { mVUlog("w.xyz vf%02d, vf%02dw", _Fs_, _Ft_); } + // FMAC1 - Normal FMAC Opcodes #define mVU_FMAC1(operation, OPname) { \ microVU* mVU = mVUx; \ @@ -90,7 +99,7 @@ microVUt(void) mVUupdateFlags(int reg, int regT1, int regT2, int xyzw, bool modX mVUupdateFlags(Fd, xmmT1, xmmT2, _X_Y_Z_W, 1); \ mVUallocFMAC1b(Fd); \ } \ - pass3 { mVUlog(OPname); } \ + pass3 { mVUlog(OPname); mVUlogFd(); mVUlogFt(); } \ } // FMAC3 - BC(xyzw) FMAC Opcodes #define mVU_FMAC3(operation, OPname) { \ @@ -104,7 +113,7 @@ microVUt(void) mVUupdateFlags(int reg, int regT1, int regT2, int xyzw, bool modX mVUupdateFlags(Fd, xmmT1, xmmT2, _X_Y_Z_W, 1); \ mVUallocFMAC3b(Fd); \ } \ - pass3 { mVUlog(OPname); } \ + pass3 { mVUlog(OPname); mVUlogFd(); mVUlogBC(); } \ } // FMAC4 - FMAC Opcodes Storing Result to ACC #define mVU_FMAC4(operation, OPname) { \ @@ -118,7 +127,7 @@ microVUt(void) mVUupdateFlags(int reg, int regT1, int regT2, int xyzw, bool modX mVUupdateFlags(Fs, xmmT1, xmmT2, _X_Y_Z_W, 0); \ mVUallocFMAC4b(ACC, Fs); \ } \ - pass3 { mVUlog(OPname); } \ + pass3 { mVUlog(OPname); mVUlogACC(); mVUlogFt(); } \ } // FMAC5 - FMAC BC(xyzw) Opcodes Storing Result to ACC #define mVU_FMAC5(operation, OPname) { \ @@ -132,7 +141,7 @@ microVUt(void) mVUupdateFlags(int reg, int regT1, int regT2, int xyzw, bool modX mVUupdateFlags(Fs, xmmT1, xmmT2, _X_Y_Z_W, 0); \ mVUallocFMAC5b(ACC, Fs); \ } \ - pass3 { mVUlog(OPname); } \ + pass3 { mVUlog(OPname); mVUlogACC(); mVUlogBC(); } \ } // FMAC6 - Normal FMAC Opcodes (I Reg) #define mVU_FMAC6(operation, OPname) { \ @@ -146,7 +155,7 @@ microVUt(void) mVUupdateFlags(int reg, int regT1, int regT2, int xyzw, bool modX mVUupdateFlags(Fd, xmmT1, xmmT2, _X_Y_Z_W, 1); \ mVUallocFMAC6b(Fd); \ } \ - pass3 { mVUlog(OPname); } \ + pass3 { mVUlog(OPname); mVUlogFd(); mVUlogI(); } \ } // FMAC7 - FMAC Opcodes Storing Result to ACC (I Reg) #define mVU_FMAC7(operation, OPname) { \ @@ -160,7 +169,7 @@ microVUt(void) mVUupdateFlags(int reg, int regT1, int regT2, int xyzw, bool modX mVUupdateFlags(Fs, xmmT1, xmmT2, _X_Y_Z_W, 0); \ mVUallocFMAC7b(ACC, Fs); \ } \ - pass3 { mVUlog(OPname); } \ + pass3 { mVUlog(OPname); mVUlogACC(); mVUlogI(); } \ } // FMAC8 - MADD FMAC Opcode Storing Result to Fd #define mVU_FMAC8(operation, OPname) { \ @@ -180,7 +189,7 @@ microVUt(void) mVUupdateFlags(int reg, int regT1, int regT2, int xyzw, bool modX mVUupdateFlags(Fd, xmmT1, xmmT2, _X_Y_Z_W, 0); \ mVUallocFMAC8b(Fd); \ } \ - pass3 { mVUlog(OPname); } \ + pass3 { mVUlog(OPname); mVUlogFd(); mVUlogFt(); } \ } // FMAC9 - MSUB FMAC Opcode Storing Result to Fd #define mVU_FMAC9(operation, OPname) { \ @@ -200,7 +209,7 @@ microVUt(void) mVUupdateFlags(int reg, int regT1, int regT2, int xyzw, bool modX mVUupdateFlags(Fd, Fs, xmmT2, _X_Y_Z_W, 0); \ mVUallocFMAC9b(Fd); \ } \ - pass3 { mVUlog(OPname); } \ + pass3 { mVUlog(OPname); mVUlogFd(); mVUlogFt(); } \ } // FMAC10 - MADD FMAC BC(xyzw) Opcode Storing Result to Fd #define mVU_FMAC10(operation, OPname) { \ @@ -220,7 +229,7 @@ microVUt(void) mVUupdateFlags(int reg, int regT1, int regT2, int xyzw, bool modX mVUupdateFlags(Fd, xmmT1, xmmT2, _X_Y_Z_W, 0); \ mVUallocFMAC10b(Fd); \ } \ - pass3 { mVUlog(OPname); } \ + pass3 { mVUlog(OPname); mVUlogFd(); mVUlogBC(); } \ } // FMAC11 - MSUB FMAC BC(xyzw) Opcode Storing Result to Fd #define mVU_FMAC11(operation, OPname) { \ @@ -240,7 +249,7 @@ microVUt(void) mVUupdateFlags(int reg, int regT1, int regT2, int xyzw, bool modX mVUupdateFlags(Fd, Fs, xmmT2, _X_Y_Z_W, 0); \ mVUallocFMAC11b(Fd); \ } \ - pass3 { mVUlog(OPname); } \ + pass3 { mVUlog(OPname); mVUlogFd(); mVUlogBC(); } \ } // FMAC12 - MADD FMAC Opcode Storing Result to Fd (I Reg) #define mVU_FMAC12(operation, OPname) { \ @@ -260,7 +269,7 @@ microVUt(void) mVUupdateFlags(int reg, int regT1, int regT2, int xyzw, bool modX mVUupdateFlags(Fd, xmmT1, xmmT2, _X_Y_Z_W, 0); \ mVUallocFMAC12b(Fd); \ } \ - pass3 { mVUlog(OPname); } \ + pass3 { mVUlog(OPname); mVUlogFd(); mVUlogI(); } \ } // FMAC13 - MSUB FMAC Opcode Storing Result to Fd (I Reg) #define mVU_FMAC13(operation, OPname) { \ @@ -280,7 +289,7 @@ microVUt(void) mVUupdateFlags(int reg, int regT1, int regT2, int xyzw, bool modX mVUupdateFlags(Fd, Fs, xmmT2, _X_Y_Z_W, 0); \ mVUallocFMAC13b(Fd); \ } \ - pass3 { mVUlog(OPname); } \ + pass3 { mVUlog(OPname); mVUlogFd(); mVUlogI(); } \ } // FMAC14 - MADDA/MSUBA FMAC Opcode #define mVU_FMAC14(operation, OPname) { \ @@ -300,7 +309,7 @@ microVUt(void) mVUupdateFlags(int reg, int regT1, int regT2, int xyzw, bool modX mVUupdateFlags(ACCr, Fs, xmmT2, _X_Y_Z_W, 0); \ mVUallocFMAC14b(ACCw, ACCr); \ } \ - pass3 { mVUlog(OPname); } \ + pass3 { mVUlog(OPname); mVUlogACC(); mVUlogFt(); } \ } // FMAC15 - MADDA/MSUBA BC(xyzw) FMAC Opcode #define mVU_FMAC15(operation, OPname) { \ @@ -320,7 +329,7 @@ microVUt(void) mVUupdateFlags(int reg, int regT1, int regT2, int xyzw, bool modX mVUupdateFlags(ACCr, Fs, xmmT2, _X_Y_Z_W, 0); \ mVUallocFMAC15b(ACCw, ACCr); \ } \ - pass3 { mVUlog(OPname); } \ + pass3 { mVUlog(OPname); mVUlogACC(); mVUlogBC(); } \ } // FMAC16 - MADDA/MSUBA FMAC Opcode (I Reg) #define mVU_FMAC16(operation, OPname) { \ @@ -340,7 +349,7 @@ microVUt(void) mVUupdateFlags(int reg, int regT1, int regT2, int xyzw, bool modX mVUupdateFlags(ACCr, Fs, xmmT2, _X_Y_Z_W, 0); \ mVUallocFMAC16b(ACCw, ACCr); \ } \ - pass3 { mVUlog(OPname); } \ + pass3 { mVUlog(OPname); mVUlogACC(); mVUlogI(); } \ } // FMAC18 - OPMULA FMAC Opcode #define mVU_FMAC18(operation, OPname) { \ @@ -353,9 +362,9 @@ microVUt(void) mVUupdateFlags(int reg, int regT1, int regT2, int xyzw, bool modX mVUupdateFlags(Fs, xmmT1, xmmT2, _X_Y_Z_W, 0); \ mVUallocFMAC18b(ACC, Fs); \ } \ - pass3 { mVUlog(OPname); } \ + pass3 { mVUlog(OPname); mVUlogACC(); mVUlogFt(); } \ } -// FMAC19 - OPMULA FMAC Opcode +// FMAC19 - OPMSUB FMAC Opcode #define mVU_FMAC19(operation, OPname) { \ microVU* mVU = mVUx; \ pass1 { mVUanalyzeFMAC1(_Fd_, _Fs_, _Ft_); } \ @@ -367,7 +376,7 @@ microVUt(void) mVUupdateFlags(int reg, int regT1, int regT2, int xyzw, bool modX mVUupdateFlags(Fd, Fs, xmmT2, _X_Y_Z_W, 0); \ mVUallocFMAC19b(Fd); \ } \ - pass3 { mVUlog(OPname); } \ + pass3 { mVUlog(OPname); mVUlogFd(); mVUlogFt(); } \ } // FMAC22 - Normal FMAC Opcodes (Q Reg) #define mVU_FMAC22(operation, OPname) { \ @@ -381,7 +390,7 @@ microVUt(void) mVUupdateFlags(int reg, int regT1, int regT2, int xyzw, bool modX mVUupdateFlags(Fd, xmmT1, xmmT2, _X_Y_Z_W, 1); \ mVUallocFMAC22b(Fd); \ } \ - pass3 { mVUlog(OPname); } \ + pass3 { mVUlog(OPname); mVUlogFd(); mVUlogQ(); } \ } // FMAC23 - FMAC Opcodes Storing Result to ACC (Q Reg) #define mVU_FMAC23(operation, OPname) { \ @@ -395,7 +404,7 @@ microVUt(void) mVUupdateFlags(int reg, int regT1, int regT2, int xyzw, bool modX mVUupdateFlags(Fs, xmmT1, xmmT2, _X_Y_Z_W, 0); \ mVUallocFMAC23b(ACC, Fs); \ } \ - pass3 { mVUlog(OPname); } \ + pass3 { mVUlog(OPname); mVUlogACC(); mVUlogQ();} \ } // FMAC24 - MADD FMAC Opcode Storing Result to Fd (Q Reg) #define mVU_FMAC24(operation, OPname) { \ @@ -415,7 +424,7 @@ microVUt(void) mVUupdateFlags(int reg, int regT1, int regT2, int xyzw, bool modX mVUupdateFlags(Fd, xmmT1, xmmT2, _X_Y_Z_W, 0); \ mVUallocFMAC24b(Fd); \ } \ - pass3 { mVUlog(OPname); } \ + pass3 { mVUlog(OPname); mVUlogFd(); mVUlogQ(); } \ } // FMAC25 - MSUB FMAC Opcode Storing Result to Fd (Q Reg) #define mVU_FMAC25(operation, OPname) { \ @@ -435,7 +444,7 @@ microVUt(void) mVUupdateFlags(int reg, int regT1, int regT2, int xyzw, bool modX mVUupdateFlags(Fd, Fs, xmmT2, _X_Y_Z_W, 0); \ mVUallocFMAC25b(Fd); \ } \ - pass3 { mVUlog(OPname); } \ + pass3 { mVUlog(OPname); mVUlogFd(); mVUlogQ(); } \ } // FMAC26 - MADDA/MSUBA FMAC Opcode (Q Reg) #define mVU_FMAC26(operation, OPname) { \ @@ -455,7 +464,7 @@ microVUt(void) mVUupdateFlags(int reg, int regT1, int regT2, int xyzw, bool modX mVUupdateFlags(ACCr, Fs, xmmT2, _X_Y_Z_W, 0); \ mVUallocFMAC26b(ACCw, ACCr); \ } \ - pass3 { mVUlog(OPname); } \ + pass3 { mVUlog(OPname); mVUlogACC(); mVUlogQ(); } \ } //------------------------------------------------------------------ @@ -471,7 +480,7 @@ microVUf(void) mVU_ABS() { SSE_ANDPS_M128_to_XMM(Fs, (uptr)mVU_absclip); mVUallocFMAC2b(Ft); } - pass3 { mVUlog("ABS"); } + pass3 { mVUlog("ABS"); mVUlogFtFs(); } } microVUf(void) mVU_ADD() { mVU_FMAC1 (ADD, "ADD"); } microVUf(void) mVU_ADDi() { mVU_FMAC6 (ADD, "ADDi"); } @@ -545,7 +554,7 @@ microVUf(void) mVU_MSUBAz() { mVU_FMAC15(SUB, "MSUBAz"); } microVUf(void) mVU_MSUBAw() { mVU_FMAC15(SUB, "MSUBAw"); } microVUf(void) mVU_MAX() { mVU_FMAC1 (MAX, "MAX"); } microVUf(void) mVU_MAXi() { mVU_FMAC6 (MAX, "MAXi"); } -microVUf(void) mVU_MAXx() { mVU_FMAC3 (MAX, "MAXq"); } +microVUf(void) mVU_MAXx() { mVU_FMAC3 (MAX, "MAXx"); } microVUf(void) mVU_MAXy() { mVU_FMAC3 (MAX, "MAXy"); } microVUf(void) mVU_MAXz() { mVU_FMAC3 (MAX, "MAXz"); } microVUf(void) mVU_MAXw() { mVU_FMAC3 (MAX, "MAXw"); } @@ -579,10 +588,10 @@ microVUq(void) mVU_FTOIx(uptr addr) { mVUallocFMAC2b(Ft); } } -microVUf(void) mVU_FTOI0() { mVU_FTOIx((uptr)0); pass3 { mVUlog("FTOI0"); } } -microVUf(void) mVU_FTOI4() { mVU_FTOIx((uptr)mVU_FTOI_4); pass3 { mVUlog("FTOI4"); } } -microVUf(void) mVU_FTOI12() { mVU_FTOIx((uptr)mVU_FTOI_12); pass3 { mVUlog("FTOI12"); } } -microVUf(void) mVU_FTOI15() { mVU_FTOIx((uptr)mVU_FTOI_15); pass3 { mVUlog("FTOI15"); } } +microVUf(void) mVU_FTOI0() { mVU_FTOIx((uptr)0); pass3 { microVU* mVU = mVUx; mVUlog("FTOI0"); mVUlogFtFs(); } } +microVUf(void) mVU_FTOI4() { mVU_FTOIx((uptr)mVU_FTOI_4); pass3 { microVU* mVU = mVUx; mVUlog("FTOI4"); mVUlogFtFs(); } } +microVUf(void) mVU_FTOI12() { mVU_FTOIx((uptr)mVU_FTOI_12); pass3 { microVU* mVU = mVUx; mVUlog("FTOI12"); mVUlogFtFs(); } } +microVUf(void) mVU_FTOI15() { mVU_FTOIx((uptr)mVU_FTOI_15); pass3 { microVU* mVU = mVUx; mVUlog("FTOI15"); mVUlogFtFs(); } } microVUq(void) mVU_ITOFx(uptr addr) { microVU* mVU = mVUx; pass1 { mVUanalyzeFMAC2(_Fs_, _Ft_); } @@ -597,10 +606,10 @@ microVUq(void) mVU_ITOFx(uptr addr) { mVUallocFMAC2b(Ft); } } -microVUf(void) mVU_ITOF0() { mVU_ITOFx((uptr)0); pass3 { mVUlog("ITOF0"); } } -microVUf(void) mVU_ITOF4() { mVU_ITOFx((uptr)mVU_ITOF_4); pass3 { mVUlog("ITOF4"); } } -microVUf(void) mVU_ITOF12() { mVU_ITOFx((uptr)mVU_ITOF_12); pass3 { mVUlog("ITOF12"); } } -microVUf(void) mVU_ITOF15() { mVU_ITOFx((uptr)mVU_ITOF_15); pass3 { mVUlog("ITOF15"); } } +microVUf(void) mVU_ITOF0() { mVU_ITOFx((uptr)0); pass3 { microVU* mVU = mVUx; mVUlog("ITOF0"); mVUlogFtFs(); } } +microVUf(void) mVU_ITOF4() { mVU_ITOFx((uptr)mVU_ITOF_4); pass3 { microVU* mVU = mVUx; mVUlog("ITOF4"); mVUlogFtFs(); } } +microVUf(void) mVU_ITOF12() { mVU_ITOFx((uptr)mVU_ITOF_12); pass3 { microVU* mVU = mVUx; mVUlog("ITOF12"); mVUlogFtFs(); } } +microVUf(void) mVU_ITOF15() { mVU_ITOFx((uptr)mVU_ITOF_15); pass3 { microVU* mVU = mVUx; mVUlog("ITOF15"); mVUlogFtFs(); } } microVUf(void) mVU_CLIP() { microVU* mVU = mVUx; pass1 { mVUanalyzeFMAC4(_Fs_, _Ft_); } @@ -633,6 +642,6 @@ microVUf(void) mVU_CLIP() { mVUallocCFLAGb(gprT1, fcInstance); } - pass3 { mVUlog("CLIP"); } + pass3 { mVUlog("CLIP"); mVUlogCLIP(); } } #endif //PCSX2_MICROVU From 5183f1eb631186a35f16967786a014289efa9920 Mon Sep 17 00:00:00 2001 From: cottonvibes Date: Mon, 27 Apr 2009 10:00:58 +0000 Subject: [PATCH 06/41] pcsx2: - fixed the 5 warnings in hacksDlg.cpp microVU: - major changes to microprogram logging. logs are now in html format with color-coding, hyperlinks to branch addresses, horizontal rules separating blocks, etc... - made mmx reg usage for VI regs toggable (off by default now) - minor changes git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1071 96395faa-99c1-11dd-bbfe-3dabce05a288 --- pcsx2/windows/HacksDlg.cpp | 10 +++--- pcsx2/x86/iVUzerorec.cpp | 2 +- pcsx2/x86/microVU.cpp | 8 ++--- pcsx2/x86/microVU.h | 8 ++--- pcsx2/x86/microVU_Alloc.inl | 12 +++---- pcsx2/x86/microVU_Compile.inl | 4 +-- pcsx2/x86/microVU_Execute.inl | 11 +++--- pcsx2/x86/microVU_Log.inl | 65 ++++++++++++++++++++++++----------- pcsx2/x86/microVU_Lower.inl | 23 ++++++------- pcsx2/x86/microVU_Misc.h | 4 +-- pcsx2/x86/microVU_Misc.inl | 18 ++++++++++ 11 files changed, 101 insertions(+), 64 deletions(-) diff --git a/pcsx2/windows/HacksDlg.cpp b/pcsx2/windows/HacksDlg.cpp index 5eb37a49c0..a7a1efb74b 100644 --- a/pcsx2/windows/HacksDlg.cpp +++ b/pcsx2/windows/HacksDlg.cpp @@ -86,11 +86,11 @@ BOOL APIENTRY HacksProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) } } - newhacks.IOPCycleDouble = IsDlgButtonChecked(hDlg, IDC_IOPSYNC); - newhacks.WaitCycleExt = IsDlgButtonChecked(hDlg, IDC_WAITCYCLES); - newhacks.INTCSTATSlow = IsDlgButtonChecked(hDlg, IDC_INTCSTATHACK); - newhacks.ESCExits = IsDlgButtonChecked(hDlg, IDC_ESCHACK); - newhacks.IdleLoopFF = IsDlgButtonChecked(hDlg, IDC_IDLELOOPFF); + newhacks.IOPCycleDouble = !!IsDlgButtonChecked(hDlg, IDC_IOPSYNC); + newhacks.WaitCycleExt = !!IsDlgButtonChecked(hDlg, IDC_WAITCYCLES); + newhacks.INTCSTATSlow = !!IsDlgButtonChecked(hDlg, IDC_INTCSTATHACK); + newhacks.ESCExits = !!IsDlgButtonChecked(hDlg, IDC_ESCHACK); + newhacks.IdleLoopFF = !!IsDlgButtonChecked(hDlg, IDC_IDLELOOPFF); newhacks.VUCycleSteal = SendDlgItemMessage(hDlg, IDC_VUCYCLE, TBM_GETPOS, 0, 0); CheckVUCycleHack(hDlg, newhacks.VUCycleSteal); diff --git a/pcsx2/x86/iVUzerorec.cpp b/pcsx2/x86/iVUzerorec.cpp index b5fdbc1c54..2c9797626a 100644 --- a/pcsx2/x86/iVUzerorec.cpp +++ b/pcsx2/x86/iVUzerorec.cpp @@ -118,7 +118,7 @@ union VURecRegs u32 id; }; -#define SUPERVU_XGKICKDELAY 1 // yes this is needed as default (wipeout) +#define SUPERVU_XGKICKDELAY 0 // yes this is needed as default (wipeout) class VuBaseBlock; diff --git a/pcsx2/x86/microVU.cpp b/pcsx2/x86/microVU.cpp index daa5f01ad3..7f508ebebd 100644 --- a/pcsx2/x86/microVU.cpp +++ b/pcsx2/x86/microVU.cpp @@ -28,7 +28,6 @@ PCSX2_ALIGNED16(microVU microVU0); PCSX2_ALIGNED16(microVU microVU1); -FILE *mVUlogFile[2] = {NULL, NULL}; declareAllVariables // Declares All Global Variables :D //------------------------------------------------------------------ @@ -46,7 +45,6 @@ microVUt(void) mVUinit(VURegs* vuRegsPtr) { mVU->cache = NULL; memset(&mVU->prog, 0, sizeof(mVU->prog)); mVUprint((vuIndex) ? "microVU1: init" : "microVU0: init"); - mVUsetupLog(); mVUreset(); } @@ -151,7 +149,7 @@ microVUt(int) mVUfindLeastUsedProg() { if (mVU->prog.total < mVU->prog.max) { mVU->prog.total++; mVUcacheProg(mVU->prog.total); // Cache Micro Program - Console::Notice("microVU: Program Total = %d", params mVU->prog.total); + Console::Notice("microVU%d: Cached MicroPrograms = %d", params vuIndex, mVU->prog.total+1); return mVU->prog.total; } else { @@ -165,7 +163,7 @@ microVUt(int) mVUfindLeastUsedProg() { } mVUclearProg(j); // Clear old data if overwriting old program mVUcacheProg(j); // Cache Micro Program - Console::Notice("microVU: Program Cache got Full!"); + Console::Notice("microVU%d: MicroProgram Cache Full!", params vuIndex); return j; } } @@ -175,9 +173,7 @@ microVUt(int) mVUsearchProg() { microVU* mVU = mVUx; if (mVU->prog.cleared) { // If cleared, we need to search for new program for (int i = 0; i <= mVU->prog.total; i++) { - //if (i == mVU->prog.cur) continue; // We can skip the current program. (ToDo: Verify that games don't clear, and send the same microprogram :/) if (!memcmp_mmx(mVU->prog.prog[i].data, mVU->regs->Micro, mVU->microSize)) { - //if (i == mVU->prog.cur) { mVUprint("microVU: Same micro program sent!"); } mVU->prog.cur = i; mVU->prog.cleared = 0; mVU->prog.prog[i].used++; diff --git a/pcsx2/x86/microVU.h b/pcsx2/x86/microVU.h index 78cd364220..e2152ed167 100644 --- a/pcsx2/x86/microVU.h +++ b/pcsx2/x86/microVU.h @@ -93,7 +93,8 @@ struct microVU { static const u32 cacheSize = 0x800000; // VU Cache Size microProgManager<0x4000> prog; // Micro Program Data - + + FILE* logFile; // Log File Pointer VURegs* regs; // VU Regs Struct u8* cache; // Dynarec Cache Start (where we will start writing the recompiled code to) u8* startFunct; // Ptr Function to the Start code for recompiled programs @@ -109,6 +110,8 @@ struct microVU { u32 espBackup; // Temp Backup for ESP u32 totalCycles; u32 cycles; + + PCSX2_ALIGNED16(u32 xmmPQb[4]); // Backup for xmmPQ }; // microVU rec structs @@ -119,9 +122,6 @@ extern PCSX2_ALIGNED16(microVU microVU1); extern void (*mVU_UPPER_OPCODE[64])( VURegs* VU, s32 info ); extern void (*mVU_LOWER_OPCODE[128])( VURegs* VU, s32 info ); -// Used for logging microPrograms -extern FILE *mVUlogFile[2]; - // Main Functions microVUt(void) mVUinit(VURegs*); microVUt(void) mVUreset(); diff --git a/pcsx2/x86/microVU_Alloc.inl b/pcsx2/x86/microVU_Alloc.inl index d22af17fdd..1d972814ee 100644 --- a/pcsx2/x86/microVU_Alloc.inl +++ b/pcsx2/x86/microVU_Alloc.inl @@ -714,9 +714,9 @@ microVUt(void) mVUallocCFLAGb(int reg, int fInstance) { microVUt(void) mVUallocVIa(int GPRreg, int _reg_) { microVU* mVU = mVUx; - if (_reg_ == 0) { XOR32RtoR(GPRreg, GPRreg); } - else if (_reg_ < 9) { MOVD32MMXtoR(GPRreg, mmVI(_reg_)); } - else { MOVZX32M16toR(GPRreg, (uptr)&mVU->regs->VI[_reg_].UL); } + if (!_reg_ || _reg_>15) { XOR32RtoR(GPRreg, GPRreg); } + else if (isMMX(_reg_)) { MOVD32MMXtoR(GPRreg, mmVI(_reg_)); } + else { MOVZX32M16toR(GPRreg, (uptr)&mVU->regs->VI[_reg_].UL); } } microVUt(void) mVUallocVIb(int GPRreg, int _reg_) { @@ -727,9 +727,9 @@ microVUt(void) mVUallocVIb(int GPRreg, int _reg_) { MOV32RtoM((uptr)&mVU->VIbackup[0], GPRreg); MOV32MtoR(GPRreg, (uptr)&mVU->VIbackup[1]); } - if (_reg_ == 0) { return; } - else if (_reg_ < 9) { MOVD32RtoMMX(mmVI(_reg_), GPRreg); } - else if (_reg_ < 16) { MOV16RtoM((uptr)&mVU->regs->VI[_reg_].UL, GPRreg); } + if (_reg_ == 0) { return; } + else if (isMMX(_reg_)) { MOVD32RtoMMX(mmVI(_reg_), GPRreg); } + else if (_reg_ < 16) { MOV16RtoM((uptr)&mVU->regs->VI[_reg_].UL, GPRreg); } } //------------------------------------------------------------------ diff --git a/pcsx2/x86/microVU_Compile.inl b/pcsx2/x86/microVU_Compile.inl index 6b9f7a898d..96187b529d 100644 --- a/pcsx2/x86/microVU_Compile.inl +++ b/pcsx2/x86/microVU_Compile.inl @@ -359,14 +359,14 @@ microVUt(void*) __fastcall mVUcompile(u32 startPC, uptr pState) { memcpy_fast(&pBlock->pStateEnd, &mVUregs, sizeof(microRegInfo)); mVUsetupBranch(bStatus, bMac); - PUSH32R(gprR); // Backup EDX + mVUbackupRegs(); MOV32MtoR(gprT2, (uptr)&mVU->branch); // Get startPC (ECX first argument for __fastcall) //AND32ItoR(gprT2, (vuIndex)?0x3ff8:0xff8); // Ensure valid jump address MOV32ItoR(gprR, (u32)&pBlock->pStateEnd); // Get pState (EDX second argument for __fastcall) if (!vuIndex) CALLFunc((uptr)mVUcompileVU0); //(u32 startPC, uptr pState) else CALLFunc((uptr)mVUcompileVU1); - POP32R(gprR); // Restore EDX + mVUrestoreRegs(); JMPR(gprT1); // Jump to rec-code address return thisPtr; } diff --git a/pcsx2/x86/microVU_Execute.inl b/pcsx2/x86/microVU_Execute.inl index ad5b2dfc30..a8765d4a8e 100644 --- a/pcsx2/x86/microVU_Execute.inl +++ b/pcsx2/x86/microVU_Execute.inl @@ -56,8 +56,8 @@ microVUt(void) mVUdispatcherA() { MOV32RtoR(gprF2, gprF0); MOV32RtoR(gprF3, gprF0); - for (int i = 0; i < 8; i++) { - MOVQMtoR(i, (uptr)&mVU->regs->VI[i+1].UL); + for (int i = 1; i < 16; i++) { + if (isMMX(i)) { MOVQMtoR(mmVI(i), (uptr)&mVU->regs->VI[i].UL); } } SSE_MOVAPS_M128_to_XMM(xmmACC, (uptr)&mVU->regs->ACC.UL[0]); @@ -99,7 +99,10 @@ microVUt(void) mVUdispatcherB() { MOV32RtoM((uptr)&mVU->regs->VI[REG_MAC_FLAG].UL, gprF0); for (int i = 0; i < 8; i++) { - MOVDMMXtoM((uptr)&mVU->regs->VI[i+1].UL, i); + + } + for (int i = 1; i < 16; i++) { + if (isMMX(i)) { MOVDMMXtoM((uptr)&mVU->regs->VI[i].UL, mmVI(i)); } } SSE_MOVAPS_XMM_to_M128((uptr)&mVU->regs->ACC.UL[0], xmmACC); @@ -112,7 +115,7 @@ microVUt(void) mVUdispatcherB() { //write8(0xcc); - EMMS(); + if (isMMX(1)) EMMS(); RET(); mVUcacheCheck(x86Ptr, mVU->cache, 512); diff --git a/pcsx2/x86/microVU_Log.inl b/pcsx2/x86/microVU_Log.inl index 12a1b4c42e..d83cbe4de8 100644 --- a/pcsx2/x86/microVU_Log.inl +++ b/pcsx2/x86/microVU_Log.inl @@ -19,13 +19,9 @@ #pragma once #ifdef PCSX2_MICROVU -microVUt(void) __mVUsetupLog() { - if (!vuIndex) { if (!mVUlogFile[0]) mVUlogFile[0] = fopen(LOGS_DIR "\\microVU0.txt", "w"); } - else { if (!mVUlogFile[1]) mVUlogFile[1] = fopen(LOGS_DIR "\\microVU1.txt", "w"); } -} - // writes text directly to the microVU.txt, no newlines appended. microVUx(void) __mVULog(const char* fmt, ...) { + microVU* mVU = mVUx; char tmp[2024]; va_list list; @@ -35,10 +31,9 @@ microVUx(void) __mVULog(const char* fmt, ...) { int length = vsprintf(tmp, fmt, list); va_end(list); - if (mVUlogFile[vuIndex]) { - fputs(tmp, mVUlogFile[vuIndex]); - //fputs("\n", mVUlogFile[vuIndex]); - fflush(mVUlogFile[vuIndex]); + if (mVU->logFile) { + fputs(tmp, mVU->logFile); + fflush(mVU->logFile); } } @@ -46,15 +41,30 @@ microVUx(void) __mVULog(const char* fmt, ...) { microVUt(void) __mVUdumpProgram(int progIndex) { microVU* mVU = mVUx; - bool bitX[7]; + bool bitX[9]; + char str[30]; + int delay = 0; + mVUbranch = 0; + + sprintf(str, "%s\\microVU%d prog - %02d.html", LOGS_DIR, vuIndex, progIndex); + mVU->logFile = fopen(str, "w"); + + mVUlog("\n"); + mVUlog("microVU%d MicroProgram Log\n", vuIndex); + mVUlog("\n"); + mVUlog("\n"); + + mVUlog(""); + mVUlog("*********************\n
", progIndex); + mVUlog("* Micro-Program #%02d *\n
", progIndex); + mVUlog("*********************\n\n

", progIndex); + mVUlog("
"); - mVUlog("*********************\n", progIndex); - mVUlog("* Micro-Program #%02d *\n", progIndex); - mVUlog("*********************\n\n", progIndex); for (u32 i = 0; i < mVU->progSize; i+=2) { + if (delay) { delay--; mVUlog("
"); if (!delay) mVUlog("
"); } + if (mVUbranch) { delay = 1; mVUbranch = 0; } mVU->code = mVU->prog.prog[progIndex].data[i+1]; - mVUlog("[%04x] (%08x) ", i*4, mVU->code); bitX[0] = 0; bitX[1] = 0; @@ -63,14 +73,21 @@ microVUt(void) __mVUdumpProgram(int progIndex) { bitX[4] = 0; bitX[5] = 0; bitX[6] = 0; + bitX[7] = 0; + bitX[8] = 0; - if (mVU->code & _Ibit_) {bitX[0] = 1; bitX[5] = 1;} - if (mVU->code & _Ebit_) {bitX[1] = 1; bitX[5] = 1;} - if (mVU->code & _Mbit_) {bitX[2] = 1; bitX[5] = 1;} - if (mVU->code & _Dbit_) {bitX[3] = 1; bitX[5] = 1;} - if (mVU->code & _Tbit_) {bitX[4] = 1; bitX[5] = 1;} + if (mVU->code & _Ibit_) { bitX[0] = 1; bitX[5] = 1; bitX[7] = 1; } + if (mVU->code & _Ebit_) { bitX[1] = 1; bitX[5] = 1; delay = 2; } + if (mVU->code & _Mbit_) { bitX[2] = 1; bitX[5] = 1; } + if (mVU->code & _Dbit_) { bitX[3] = 1; bitX[5] = 1; } + if (mVU->code & _Tbit_) { bitX[4] = 1; bitX[5] = 1; } + + if (delay == 2) { mVUlog(""); } + if (delay == 1) { mVUlog(""); } iPC = (i+1)/4; + mVUlog("", i*4); + mVUlog("[%04x] (%08x) ", i*4, mVU->code); mVUopU(); if (bitX[5]) { @@ -84,11 +101,17 @@ microVUt(void) __mVUdumpProgram(int progIndex) { } iPC = i/4; + if (bitX[7]) { mVUlog(""); } mVU->code = mVU->prog.prog[progIndex].data[i]; - mVUlog("\n[%04x] (%08x) ", i*4, mVU->code); + mVUlog("
\n[%04x] (%08x) ", i*4, mVU->code); mVUopL(); - mVUlog("\n\n"); + mVUlog("\n\n

"); + if (bitX[7]) { mVUlog("
"); } } + mVUlog("
\n"); + mVUlog("\n"); + mVUlog("\n"); + fclose(mVU->logFile); } #endif //PCSX2_MICROVU diff --git a/pcsx2/x86/microVU_Lower.inl b/pcsx2/x86/microVU_Lower.inl index ff562494c1..dfe5fefb96 100644 --- a/pcsx2/x86/microVU_Lower.inl +++ b/pcsx2/x86/microVU_Lower.inl @@ -752,8 +752,7 @@ microVUf(void) mVU_ILW() { mVUallocVIa(gprT1, _Fs_); ADD32ItoR(gprT1, _Imm11_); mVUaddrFix(gprT1); - MOV32RmtoR(gprT1, gprT1, (uptr)mVU->regs->Mem + offsetSS); - if (isMMX(_Ft_)) AND32ItoR(gprT1, 0xffff); + MOVZX32Rm16toR(gprT1, gprT1, (uptr)mVU->regs->Mem + offsetSS); mVUallocVIb(gprT1, _Ft_); } } @@ -1098,10 +1097,10 @@ microVUf(void) mVU_XGKICK() { pass2 { mVUprint("XGkick"); mVUallocVIa(gprT2, _Fs_); // gprT2 = ECX for __fastcall - PUSH32R(gprR); // gprR = EDX is volatile so backup + mVUbackupRegs(); if (mtgsThread != NULL) CALLFunc((uptr)mVU_XGKICK_); else CALLFunc((uptr)mVU_XGKICK__); - POP32R(gprR); // Restore + mVUrestoreRegs(); } pass3 { mVUlog("XGKICK vi%02d", _Fs_); } } @@ -1113,7 +1112,7 @@ microVUf(void) mVU_XGKICK() { microVUf(void) mVU_B() { microVU* mVU = mVUx; mVUbranch = 1; - pass3 { mVUlog("B [%04x]", branchAddr); } + pass3 { mVUlog("B [%04x]", branchAddr, branchAddr); } } microVUf(void) mVU_BAL() { microVU* mVU = mVUx; @@ -1123,7 +1122,7 @@ microVUf(void) mVU_BAL() { MOV32ItoR(gprT1, bSaveAddr); mVUallocVIb(gprT1, _Ft_); } - pass3 { mVUlog("BAL vi%02d [%04x]", _Ft_, branchAddr); } + pass3 { mVUlog("BAL vi%02d [%04x]", _Ft_, branchAddr, branchAddr); } } microVUf(void) mVU_IBEQ() { microVU* mVU = mVUx; @@ -1136,7 +1135,7 @@ microVUf(void) mVU_IBEQ() { else { mVUallocVIa(gprT2, _Ft_); XOR32RtoR(gprT1, gprT2); } MOV32RtoM((uptr)&mVU->branch, gprT1); } - pass3 { mVUlog("IBEQ vi%02d, vi%02d [%04x]", _Ft_, _Fs_, branchAddr); } + pass3 { mVUlog("IBEQ vi%02d, vi%02d [%04x]", _Ft_, _Fs_, branchAddr, branchAddr); } } microVUf(void) mVU_IBGEZ() { microVU* mVU = mVUx; @@ -1147,7 +1146,7 @@ microVUf(void) mVU_IBGEZ() { else mVUallocVIa(gprT1, _Fs_); MOV32RtoM((uptr)&mVU->branch, gprT1); } - pass3 { mVUlog("IBGEZ vi%02d [%04x]", _Fs_, branchAddr); } + pass3 { mVUlog("IBGEZ vi%02d [%04x]", _Fs_, branchAddr, branchAddr); } } microVUf(void) mVU_IBGTZ() { microVU* mVU = mVUx; @@ -1158,7 +1157,7 @@ microVUf(void) mVU_IBGTZ() { else mVUallocVIa(gprT1, _Fs_); MOV32RtoM((uptr)&mVU->branch, gprT1); } - pass3 { mVUlog("IBGTZ vi%02d [%04x]", _Fs_, branchAddr); } + pass3 { mVUlog("IBGTZ vi%02d [%04x]", _Fs_, branchAddr, branchAddr); } } microVUf(void) mVU_IBLEZ() { microVU* mVU = mVUx; @@ -1169,7 +1168,7 @@ microVUf(void) mVU_IBLEZ() { else mVUallocVIa(gprT1, _Fs_); MOV32RtoM((uptr)&mVU->branch, gprT1); } - pass3 { mVUlog("IBLEZ vi%02d [%04x]", _Fs_, branchAddr); } + pass3 { mVUlog("IBLEZ vi%02d [%04x]", _Fs_, branchAddr, branchAddr); } } microVUf(void) mVU_IBLTZ() { microVU* mVU = mVUx; @@ -1180,7 +1179,7 @@ microVUf(void) mVU_IBLTZ() { else mVUallocVIa(gprT1, _Fs_); MOV32RtoM((uptr)&mVU->branch, gprT1); } - pass3 { mVUlog("IBLTZ vi%02d [%04x]", _Fs_, branchAddr); } + pass3 { mVUlog("IBLTZ vi%02d [%04x]", _Fs_, branchAddr, branchAddr); } } microVUf(void) mVU_IBNE() { microVU* mVU = mVUx; @@ -1193,7 +1192,7 @@ microVUf(void) mVU_IBNE() { else { mVUallocVIa(gprT2, _Ft_); XOR32RtoR(gprT1, gprT2); } MOV32RtoM((uptr)&mVU->branch, gprT1); } - pass3 { mVUlog("IBNE vi%02d, vi%02d [%04x]", _Ft_, _Fs_, branchAddr); } + pass3 { mVUlog("IBNE vi%02d, vi%02d [%04x]", _Ft_, _Fs_, branchAddr, branchAddr); } } microVUf(void) mVU_JR() { microVU* mVU = mVUx; diff --git a/pcsx2/x86/microVU_Misc.h b/pcsx2/x86/microVU_Misc.h index acd86c3a7d..97980dc8a2 100644 --- a/pcsx2/x86/microVU_Misc.h +++ b/pcsx2/x86/microVU_Misc.h @@ -231,7 +231,7 @@ declareAllVariables #define doDivFlag (mVUinfo & (1<<28)) #define doClip (mVUinfo & (1<<29)) -#define isMMX(_VIreg_) (_VIreg_ >= 1 && _VIreg_ <=9) +#define isMMX(_VIreg_) 0//(_VIreg_ >= 1 && _VIreg_ <=8) #define mmVI(_VIreg_) (_VIreg_ - 1) #ifdef mVUdebug @@ -250,11 +250,9 @@ declareAllVariables #ifdef mVUlogProg #define mVUlog __mVULog -#define mVUsetupLog __mVUsetupLog #define mVUdumpProg __mVUdumpProgram #else #define mVUlog 0&& -#define mVUsetupLog() #define mVUdumpProg 0&& #endif diff --git a/pcsx2/x86/microVU_Misc.inl b/pcsx2/x86/microVU_Misc.inl index 59ca4ee4f7..48c91520e7 100644 --- a/pcsx2/x86/microVU_Misc.inl +++ b/pcsx2/x86/microVU_Misc.inl @@ -281,4 +281,22 @@ microVUt(void) mVUaddrFix(int gprReg) { } } +// Backup Volatile Regs (EAX, ECX, EDX, MM0~7, XMM0~7, are all volatile according to 32bit Win/Linux ABI) +microVUt(void) mVUbackupRegs() { + microVU* mVU = mVUx; + SSE_MOVAPS_XMM_to_M128((uptr)&mVU->regs->ACC.UL[0], xmmACC); + SSE_MOVAPS_XMM_to_M128((uptr)&mVU->xmmPQb[0], xmmPQ); + PUSH32R(gprR); // Backup EDX +} + +// Restore Volatile Regs +microVUt(void) mVUrestoreRegs() { + microVU* mVU = mVUx; + SSE_MOVAPS_M128_to_XMM(xmmACC, (uptr)&mVU->regs->ACC.UL[0]); + SSE_MOVAPS_M128_to_XMM(xmmPQ, (uptr)&mVU->xmmPQb[0]); + SSE_MOVAPS_M128_to_XMM(xmmMax, (uptr)mVU_maxvals); + SSE_MOVAPS_M128_to_XMM(xmmMin, (uptr)mVU_minvals); + POP32R(gprR); // Restore EDX +} + #endif //PCSX2_MICROVU From 7ecc0dd6a3a85e9b33692c8d9fa2319d5b54804f Mon Sep 17 00:00:00 2001 From: ramapcsx2 Date: Mon, 27 Apr 2009 19:40:07 +0000 Subject: [PATCH 07/41] Fix xgkick delay mistake git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1073 96395faa-99c1-11dd-bbfe-3dabce05a288 --- pcsx2/x86/iVUzerorec.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pcsx2/x86/iVUzerorec.cpp b/pcsx2/x86/iVUzerorec.cpp index 2c9797626a..b5fdbc1c54 100644 --- a/pcsx2/x86/iVUzerorec.cpp +++ b/pcsx2/x86/iVUzerorec.cpp @@ -118,7 +118,7 @@ union VURecRegs u32 id; }; -#define SUPERVU_XGKICKDELAY 0 // yes this is needed as default (wipeout) +#define SUPERVU_XGKICKDELAY 1 // yes this is needed as default (wipeout) class VuBaseBlock; From 1245659eeecfcca944468b401fc28d9504e19298 Mon Sep 17 00:00:00 2001 From: gabest11 Date: Mon, 27 Apr 2009 20:17:06 +0000 Subject: [PATCH 08/41] GSdx: fixed Issue 182 (narrowed the neq alpha test range to +/-0.4f/255, scream if something broke), and re-enabled something to make DATE faster (counting min/max of the vertices outperforms stencil buffer clearing when there are many small primitive batches). git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1074 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/GSdx/GSCrc.cpp | 4 +- plugins/GSdx/GSRendererHW.h | 2 - plugins/GSdx/GSRendererHW10.cpp | 50 +- plugins/GSdx/GSRendererHW9.cpp | 54 +- plugins/GSdx/GSdx_vs2008.vcproj | 3607 ++++++++++++++++--------------- plugins/GSdx/res/tfx10.fx | 4 +- plugins/GSdx/res/tfx9.fx | 4 +- 7 files changed, 1880 insertions(+), 1845 deletions(-) diff --git a/plugins/GSdx/GSCrc.cpp b/plugins/GSdx/GSCrc.cpp index 584c9c4404..34307df48b 100644 --- a/plugins/GSdx/GSCrc.cpp +++ b/plugins/GSdx/GSCrc.cpp @@ -85,6 +85,7 @@ CRC::Game CRC::m_games[] = {0x6F8545DB, ICO, US}, {0xB01A4C95, ICO, JP}, {0x5C991F4E, ICO, Unknown}, + {0x7ACF7E03, ICO, Unknown}, {0xAEAD1CA3, GT4, JP}, {0x44A61C8F, GT4, Unknown}, {0x0086E35B, GT4, Unknown}, @@ -112,10 +113,11 @@ CRC::Game CRC::m_games[] = {0xEB001875, GodOfWar, EU}, {0xA61A4C6D, GodOfWar, Unknown}, {0xE23D532B, GodOfWar, Unknown}, + {0xDF1AF973, GodOfWar, Unknown}, {0x2F123FD8, GodOfWar2, RU}, {0x2F123FD8, GodOfWar2, US}, {0x44A8A22A, GodOfWar2, EU}, - {0X4340C7C6, GodOfWar2, Unknown}, + {0x4340C7C6, GodOfWar2, Unknown}, {0x5D482F18, JackieChanAdv, Unknown}, {0xf0a6d880, HarvestMoon, US}, {0x75c01a04, NamcoXCapcom, US}, diff --git a/plugins/GSdx/GSRendererHW.h b/plugins/GSdx/GSRendererHW.h index 31c5673c9b..e0d1818d25 100644 --- a/plugins/GSdx/GSRendererHW.h +++ b/plugins/GSdx/GSRendererHW.h @@ -334,8 +334,6 @@ protected: if(s_save) rt->m_texture.Save(str); str.Format(_T("c:\\temp2\\_%05d_f%I64d_rz0_%05x_%d.bmp"), s_n-1, m_perfmon.GetFrame(), context->ZBUF.Block(), context->ZBUF.PSM); if(s_savez) ds->m_texture.Save(str); - // if(s_savez) m_dev.SaveToFileD32S8X24(ds->m_texture, str); // TODO - // if(s_savez) m_dev.SaveToFileD24S8(ds->m_texture, str); // TODO } int prim = PRIM->PRIM; diff --git a/plugins/GSdx/GSRendererHW10.cpp b/plugins/GSdx/GSRendererHW10.cpp index 3fd9ccb9d7..0265f582d8 100644 --- a/plugins/GSdx/GSRendererHW10.cpp +++ b/plugins/GSdx/GSRendererHW10.cpp @@ -493,34 +493,48 @@ void GSRendererHW10::SetupDATE(Texture& rt, Texture& ds) { if(!m_context->TEST.DATE) return; // || (::GetAsyncKeyState(VK_CONTROL) & 0x8000) - // sfex3 (after the capcom logo), vf4 (first menu fading in), ffxii shadows, rumble roses shadows + // sfex3 (after the capcom logo), vf4 (first menu fading in), ffxii shadows, rumble roses shadows, persona4 shadows GSVector4 mm; // TODO mm = GSVector4(-1, -1, 1, 1); -/* - MinMaxXY(mm); - int w = rt.GetWidth(); - int h = rt.GetHeight(); + // if(m_count < 100) + { + GSVector4 pmin(65535, 65535, 0, 0); + GSVector4 pmax = GSVector4::zero(); - float sx = 2.0f * rt.m_scale.x / (w * 16); - float sy = 2.0f * rt.m_scale.y / (h * 16); - float ox = (float)(int)m_context->XYOFFSET.OFX; - float oy = (float)(int)m_context->XYOFFSET.OFY; + for(int i = 0, j = m_count; i < j; i++) + { + GSVector4 p(GSVector4i(m_vertices[i].m128i[0]).uph16()); - mm.x = (mm.x - ox) * sx - 1; - mm.y = (mm.y - oy) * sy - 1; - mm.z = (mm.z - ox) * sx - 1; - mm.w = (mm.w - oy) * sy - 1; + pmin = p.minv(pmin); + pmax = p.maxv(pmax); + } + + mm += pmin.xyxy(pmax); + + int w = rt.GetWidth(); + int h = rt.GetHeight(); + + float sx = 2.0f * rt.m_scale.x / (w * 16); + float sy = 2.0f * rt.m_scale.y / (h * 16); + float ox = (float)(int)m_context->XYOFFSET.OFX; + float oy = (float)(int)m_context->XYOFFSET.OFY; + + mm.x = (mm.x - ox) * sx - 1; + mm.y = (mm.y - oy) * sy - 1; + mm.z = (mm.z - ox) * sx - 1; + mm.w = (mm.w - oy) * sy - 1; + + if(mm.x < -1) mm.x = -1; + if(mm.y < -1) mm.y = -1; + if(mm.z > +1) mm.z = +1; + if(mm.w > +1) mm.w = +1; + } - if(mm.x < -1) mm.x = -1; - if(mm.y < -1) mm.y = -1; - if(mm.z > +1) mm.z = +1; - if(mm.w > +1) mm.w = +1; -*/ GSVector4 uv = (mm + 1.0f) / 2.0f; // diff --git a/plugins/GSdx/GSRendererHW9.cpp b/plugins/GSdx/GSRendererHW9.cpp index 4459094f1d..47acb327a3 100644 --- a/plugins/GSdx/GSRendererHW9.cpp +++ b/plugins/GSdx/GSRendererHW9.cpp @@ -79,8 +79,8 @@ void GSRendererHW9::VertexKick(bool skip) { Vertex& dst = m_vl.AddTail(); - dst.p.x = (float)m_v.XYZ.X; - dst.p.y = (float)m_v.XYZ.Y; + dst.p.x = (float)(int)m_v.XYZ.X; + dst.p.y = (float)(int)m_v.XYZ.Y; dst.p.z = (float)m_v.XYZ.Z; dst.c0 = m_v.RGBAQ.ai32[0]; @@ -469,34 +469,48 @@ void GSRendererHW9::SetupDATE(Texture& rt, Texture& ds) { if(!m_context->TEST.DATE) return; // || (::GetAsyncKeyState(VK_CONTROL) & 0x8000) - // sfex3 (after the capcom logo), vf4 (first menu fading in), ffxii shadows, rumble roses shadows + // sfex3 (after the capcom logo), vf4 (first menu fading in), ffxii shadows, rumble roses shadows, persona4 shadows GSVector4 mm; // TODO mm = GSVector4(-1, -1, 1, 1); -/* - MinMaxXY(mm); - int w = rt.GetWidth(); - int h = rt.GetHeight(); + // if(m_count < 100) + { + GSVector4 pmin(65535, 65535, 0, 0); + GSVector4 pmax = GSVector4::zero(); - float sx = 2.0f * rt.m_scale.x / (w * 16); - float sy = 2.0f * rt.m_scale.y / (h * 16); - float ox = (float)(int)m_context->XYOFFSET.OFX; - float oy = (float)(int)m_context->XYOFFSET.OFY; + for(int i = 0, j = m_count; i < j; i++) + { + GSVector4 p(m_vertices[i].p); - mm.x = (mm.x - ox) * sx - 1; - mm.y = (mm.y - oy) * sy - 1; - mm.z = (mm.z - ox) * sx - 1; - mm.w = (mm.w - oy) * sy - 1; + pmin = p.minv(pmin); + pmax = p.maxv(pmax); + } + + mm += pmin.xyxy(pmax); + + int w = rt.GetWidth(); + int h = rt.GetHeight(); + + float sx = 2.0f * rt.m_scale.x / (w * 16); + float sy = 2.0f * rt.m_scale.y / (h * 16); + float ox = (float)(int)m_context->XYOFFSET.OFX; + float oy = (float)(int)m_context->XYOFFSET.OFY; + + mm.x = (mm.x - ox) * sx - 1; + mm.y = (mm.y - oy) * sy - 1; + mm.z = (mm.z - ox) * sx - 1; + mm.w = (mm.w - oy) * sy - 1; + + if(mm.x < -1) mm.x = -1; + if(mm.y < -1) mm.y = -1; + if(mm.z > +1) mm.z = +1; + if(mm.w > +1) mm.w = +1; + } - if(mm.x < -1) mm.x = -1; - if(mm.y < -1) mm.y = -1; - if(mm.z > +1) mm.z = +1; - if(mm.w > +1) mm.w = +1; -*/ GSVector4 uv = (mm + 1.0f) / 2.0f; // diff --git a/plugins/GSdx/GSdx_vs2008.vcproj b/plugins/GSdx/GSdx_vs2008.vcproj index 8fa577240e..2075063ef6 100644 --- a/plugins/GSdx/GSdx_vs2008.vcproj +++ b/plugins/GSdx/GSdx_vs2008.vcproj @@ -82,452 +82,6 @@ Name="VCPostBuildEventTool" /> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1191,14 +1198,6 @@ AssemblerOutput="4" /> - - - + + + @@ -1244,7 +1251,7 @@ RelativePath=".\GSRasterizer.cpp" > - - - - - - - - - - - - - - - - - - - - - @@ -1523,6 +1474,14 @@ UsePrecompiledHeader="1" /> + + + @@ -1531,6 +1490,14 @@ UsePrecompiledHeader="1" /> + + + @@ -1539,6 +1506,14 @@ UsePrecompiledHeader="1" /> + + + @@ -1547,6 +1522,14 @@ UsePrecompiledHeader="1" /> + + + @@ -1555,6 +1538,14 @@ UsePrecompiledHeader="1" /> + + + @@ -1563,6 +1554,14 @@ UsePrecompiledHeader="1" /> + + + @@ -1571,6 +1570,14 @@ UsePrecompiledHeader="1" /> + + + @@ -1947,62 +1954,6 @@ UsePrecompiledHeader="0" /> - - - - - - - - - - - - - - - - - - - - - @@ -2011,6 +1962,14 @@ UsePrecompiledHeader="0" /> + + + @@ -2019,6 +1978,14 @@ UsePrecompiledHeader="0" /> + + + @@ -2027,6 +1994,14 @@ UsePrecompiledHeader="0" /> + + + @@ -2035,6 +2010,14 @@ UsePrecompiledHeader="0" /> + + + @@ -2043,6 +2026,14 @@ UsePrecompiledHeader="0" /> + + + @@ -2051,6 +2042,14 @@ UsePrecompiledHeader="0" /> + + + @@ -2059,6 +2058,14 @@ UsePrecompiledHeader="0" /> + + + @@ -2083,62 +2090,6 @@ UsePrecompiledHeader="0" /> - - - - - - - - - - - - - - - - - - - - - @@ -2147,6 +2098,14 @@ UsePrecompiledHeader="0" /> + + + @@ -2155,6 +2114,14 @@ UsePrecompiledHeader="0" /> + + + @@ -2163,6 +2130,14 @@ UsePrecompiledHeader="0" /> + + + @@ -2171,6 +2146,14 @@ UsePrecompiledHeader="0" /> + + + @@ -2179,6 +2162,14 @@ UsePrecompiledHeader="0" /> + + + @@ -2187,6 +2178,14 @@ UsePrecompiledHeader="0" /> + + + @@ -2195,6 +2194,14 @@ UsePrecompiledHeader="0" /> + + + @@ -2219,62 +2226,6 @@ UsePrecompiledHeader="0" /> - - - - - - - - - - - - - - - - - - - - - @@ -2283,6 +2234,14 @@ UsePrecompiledHeader="0" /> + + + @@ -2291,6 +2250,14 @@ UsePrecompiledHeader="0" /> + + + @@ -2299,6 +2266,14 @@ UsePrecompiledHeader="0" /> + + + @@ -2307,6 +2282,14 @@ UsePrecompiledHeader="0" /> + + + @@ -2315,6 +2298,14 @@ UsePrecompiledHeader="0" /> + + + @@ -2323,6 +2314,14 @@ UsePrecompiledHeader="0" /> + + + @@ -2331,6 +2330,14 @@ UsePrecompiledHeader="0" /> + + + @@ -2355,62 +2362,6 @@ UsePrecompiledHeader="0" /> - - - - - - - - - - - - - - - - - - - - - @@ -2419,6 +2370,14 @@ UsePrecompiledHeader="0" /> + + + @@ -2427,6 +2386,14 @@ UsePrecompiledHeader="0" /> + + + @@ -2435,6 +2402,14 @@ UsePrecompiledHeader="0" /> + + + @@ -2443,6 +2418,14 @@ UsePrecompiledHeader="0" /> + + + @@ -2451,6 +2434,14 @@ UsePrecompiledHeader="0" /> + + + @@ -2459,6 +2450,14 @@ UsePrecompiledHeader="0" /> + + + @@ -2467,6 +2466,14 @@ UsePrecompiledHeader="0" /> + + + @@ -2491,62 +2498,6 @@ UsePrecompiledHeader="0" /> - - - - - - - - - - - - - - - - - - - - - @@ -2555,6 +2506,14 @@ UsePrecompiledHeader="0" /> + + + @@ -2563,6 +2522,14 @@ UsePrecompiledHeader="0" /> + + + @@ -2571,6 +2538,14 @@ UsePrecompiledHeader="0" /> + + + @@ -2579,6 +2554,14 @@ UsePrecompiledHeader="0" /> + + + @@ -2587,6 +2570,14 @@ UsePrecompiledHeader="0" /> + + + @@ -2595,6 +2586,14 @@ UsePrecompiledHeader="0" /> + + + @@ -2603,6 +2602,14 @@ UsePrecompiledHeader="0" /> + + + @@ -2627,62 +2634,6 @@ UsePrecompiledHeader="0" /> - - - - - - - - - - - - - - - - - - - - - @@ -2691,6 +2642,14 @@ UsePrecompiledHeader="0" /> + + + @@ -2699,6 +2658,14 @@ UsePrecompiledHeader="0" /> + + + @@ -2707,6 +2674,14 @@ UsePrecompiledHeader="0" /> + + + @@ -2715,6 +2690,14 @@ UsePrecompiledHeader="0" /> + + + @@ -2723,6 +2706,14 @@ UsePrecompiledHeader="0" /> + + + @@ -2731,6 +2722,14 @@ UsePrecompiledHeader="0" /> + + + @@ -2739,6 +2738,14 @@ UsePrecompiledHeader="0" /> + + + @@ -2779,62 +2786,6 @@ UsePrecompiledHeader="0" /> - - - - - - - - - - - - - - - - - - - - - @@ -2843,6 +2794,14 @@ UsePrecompiledHeader="0" /> + + + @@ -2851,6 +2810,14 @@ UsePrecompiledHeader="0" /> + + + @@ -2859,6 +2826,14 @@ UsePrecompiledHeader="0" /> + + + @@ -2867,6 +2842,14 @@ UsePrecompiledHeader="0" /> + + + @@ -2875,6 +2858,14 @@ UsePrecompiledHeader="0" /> + + + @@ -2883,6 +2874,14 @@ UsePrecompiledHeader="0" /> + + + @@ -2891,6 +2890,14 @@ UsePrecompiledHeader="0" /> + + + @@ -2915,62 +2922,6 @@ UsePrecompiledHeader="0" /> - - - - - - - - - - - - - - - - - - - - - @@ -2979,6 +2930,14 @@ UsePrecompiledHeader="0" /> + + + @@ -2987,6 +2946,14 @@ UsePrecompiledHeader="0" /> + + + @@ -2995,6 +2962,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3003,6 +2978,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3011,6 +2994,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3019,6 +3010,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3027,6 +3026,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3051,62 +3058,6 @@ UsePrecompiledHeader="0" /> - - - - - - - - - - - - - - - - - - - - - @@ -3115,6 +3066,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3123,6 +3082,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3131,6 +3098,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3139,6 +3114,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3147,6 +3130,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3155,6 +3146,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3163,6 +3162,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3187,62 +3194,6 @@ UsePrecompiledHeader="0" /> - - - - - - - - - - - - - - - - - - - - - @@ -3251,6 +3202,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3259,6 +3218,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3267,6 +3234,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3275,6 +3250,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3283,6 +3266,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3291,6 +3282,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3299,6 +3298,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3323,62 +3330,6 @@ UsePrecompiledHeader="0" /> - - - - - - - - - - - - - - - - - - - - - @@ -3387,6 +3338,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3395,6 +3354,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3403,6 +3370,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3411,6 +3386,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3419,6 +3402,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3427,6 +3418,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3435,6 +3434,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3463,62 +3470,6 @@ UsePrecompiledHeader="0" /> - - - - - - - - - - - - - - - - - - - - - @@ -3527,6 +3478,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3535,6 +3494,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3543,6 +3510,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3551,6 +3526,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3559,6 +3542,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3567,6 +3558,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3575,6 +3574,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3599,62 +3606,6 @@ UsePrecompiledHeader="0" /> - - - - - - - - - - - - - - - - - - - - - @@ -3663,6 +3614,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3671,6 +3630,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3679,6 +3646,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3687,6 +3662,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3695,6 +3678,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3703,6 +3694,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3711,6 +3710,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3735,62 +3742,6 @@ UsePrecompiledHeader="0" /> - - - - - - - - - - - - - - - - - - - - - @@ -3799,6 +3750,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3807,6 +3766,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3815,6 +3782,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3823,6 +3798,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3831,6 +3814,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3839,6 +3830,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3847,6 +3846,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3871,62 +3878,6 @@ UsePrecompiledHeader="0" /> - - - - - - - - - - - - - - - - - - - - - @@ -3935,6 +3886,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3943,6 +3902,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3951,6 +3918,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3959,6 +3934,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3967,6 +3950,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3975,6 +3966,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3983,6 +3982,14 @@ UsePrecompiledHeader="0" /> + + + @@ -4011,62 +4018,6 @@ UsePrecompiledHeader="0" /> - - - - - - - - - - - - - - - - - - - - - @@ -4075,6 +4026,14 @@ UsePrecompiledHeader="0" /> + + + @@ -4083,6 +4042,14 @@ UsePrecompiledHeader="0" /> + + + @@ -4091,6 +4058,14 @@ UsePrecompiledHeader="0" /> + + + @@ -4099,6 +4074,14 @@ UsePrecompiledHeader="0" /> + + + @@ -4107,6 +4090,14 @@ UsePrecompiledHeader="0" /> + + + @@ -4115,6 +4106,14 @@ UsePrecompiledHeader="0" /> + + + @@ -4123,6 +4122,14 @@ UsePrecompiledHeader="0" /> + + + @@ -4147,62 +4154,6 @@ UsePrecompiledHeader="0" /> - - - - - - - - - - - - - - - - - - - - - @@ -4211,6 +4162,14 @@ UsePrecompiledHeader="0" /> + + + @@ -4219,6 +4178,14 @@ UsePrecompiledHeader="0" /> + + + @@ -4227,6 +4194,14 @@ UsePrecompiledHeader="0" /> + + + @@ -4235,6 +4210,14 @@ UsePrecompiledHeader="0" /> + + + @@ -4243,6 +4226,14 @@ UsePrecompiledHeader="0" /> + + + @@ -4251,6 +4242,14 @@ UsePrecompiledHeader="0" /> + + + @@ -4259,6 +4258,14 @@ UsePrecompiledHeader="0" /> + + + @@ -4283,62 +4290,6 @@ UsePrecompiledHeader="0" /> - - - - - - - - - - - - - - - - - - - - - @@ -4347,6 +4298,14 @@ UsePrecompiledHeader="0" /> + + + @@ -4355,6 +4314,14 @@ UsePrecompiledHeader="0" /> + + + @@ -4363,6 +4330,14 @@ UsePrecompiledHeader="0" /> + + + @@ -4371,6 +4346,14 @@ UsePrecompiledHeader="0" /> + + + @@ -4379,6 +4362,14 @@ UsePrecompiledHeader="0" /> + + + @@ -4387,6 +4378,14 @@ UsePrecompiledHeader="0" /> + + + @@ -4395,6 +4394,14 @@ UsePrecompiledHeader="0" /> + + + @@ -4419,62 +4426,6 @@ UsePrecompiledHeader="0" /> - - - - - - - - - - - - - - - - - - - - - @@ -4483,6 +4434,14 @@ UsePrecompiledHeader="0" /> + + + @@ -4491,6 +4450,14 @@ UsePrecompiledHeader="0" /> + + + @@ -4499,6 +4466,14 @@ UsePrecompiledHeader="0" /> + + + @@ -4507,6 +4482,14 @@ UsePrecompiledHeader="0" /> + + + @@ -4515,6 +4498,14 @@ UsePrecompiledHeader="0" /> + + + @@ -4523,6 +4514,14 @@ UsePrecompiledHeader="0" /> + + + @@ -4531,6 +4530,14 @@ UsePrecompiledHeader="0" /> + + + @@ -4555,62 +4562,6 @@ UsePrecompiledHeader="0" /> - - - - - - - - - - - - - - - - - - - - - @@ -4619,6 +4570,14 @@ UsePrecompiledHeader="0" /> + + + @@ -4627,6 +4586,14 @@ UsePrecompiledHeader="0" /> + + + @@ -4635,6 +4602,14 @@ UsePrecompiledHeader="0" /> + + + @@ -4643,6 +4618,14 @@ UsePrecompiledHeader="0" /> + + + @@ -4651,6 +4634,14 @@ UsePrecompiledHeader="0" /> + + + @@ -4659,6 +4650,14 @@ UsePrecompiledHeader="0" /> + + + @@ -4667,6 +4666,14 @@ UsePrecompiledHeader="0" /> + + + @@ -4691,62 +4698,6 @@ UsePrecompiledHeader="0" /> - - - - - - - - - - - - - - - - - - - - - @@ -4755,6 +4706,14 @@ UsePrecompiledHeader="0" /> + + + @@ -4763,6 +4722,14 @@ UsePrecompiledHeader="0" /> + + + @@ -4771,6 +4738,14 @@ UsePrecompiledHeader="0" /> + + + @@ -4779,6 +4754,14 @@ UsePrecompiledHeader="0" /> + + + @@ -4787,6 +4770,14 @@ UsePrecompiledHeader="0" /> + + + @@ -4795,6 +4786,14 @@ UsePrecompiledHeader="0" /> + + + @@ -4803,6 +4802,14 @@ UsePrecompiledHeader="0" /> + + + @@ -4827,62 +4834,6 @@ UsePrecompiledHeader="0" /> - - - - - - - - - - - - - - - - - - - - - @@ -4891,6 +4842,14 @@ UsePrecompiledHeader="0" /> + + + @@ -4899,6 +4858,14 @@ UsePrecompiledHeader="0" /> + + + @@ -4907,6 +4874,14 @@ UsePrecompiledHeader="0" /> + + + @@ -4915,6 +4890,14 @@ UsePrecompiledHeader="0" /> + + + @@ -4923,6 +4906,14 @@ UsePrecompiledHeader="0" /> + + + @@ -4931,6 +4922,14 @@ UsePrecompiledHeader="0" /> + + + @@ -4939,6 +4938,14 @@ UsePrecompiledHeader="0" /> + + + @@ -4963,62 +4970,6 @@ UsePrecompiledHeader="0" /> - - - - - - - - - - - - - - - - - - - - - @@ -5027,6 +4978,14 @@ UsePrecompiledHeader="0" /> + + + @@ -5035,6 +4994,14 @@ UsePrecompiledHeader="0" /> + + + @@ -5043,6 +5010,14 @@ UsePrecompiledHeader="0" /> + + + @@ -5051,6 +5026,14 @@ UsePrecompiledHeader="0" /> + + + @@ -5059,6 +5042,14 @@ UsePrecompiledHeader="0" /> + + + @@ -5067,6 +5058,14 @@ UsePrecompiledHeader="0" /> + + + @@ -5075,6 +5074,14 @@ UsePrecompiledHeader="0" /> + + + diff --git a/plugins/GSdx/res/tfx10.fx b/plugins/GSdx/res/tfx10.fx index 7be092dfd7..0a20767d6b 100644 --- a/plugins/GSdx/res/tfx10.fx +++ b/plugins/GSdx/res/tfx10.fx @@ -458,7 +458,7 @@ PS_OUTPUT ps_main(PS_INPUT input) } else if(ATST == 4) // e { - clip(0.9f/256 - abs(c.a - AREF)); + clip(0.5f / 256 - abs(c.a - AREF)); } else if(ATST == 5 || ATST == 6) // ge, g { @@ -466,7 +466,7 @@ PS_OUTPUT ps_main(PS_INPUT input) } else if(ATST == 7) // ne { - clip(abs(c.a - AREF) - 0.9f/256); + clip(abs(c.a - AREF) - 0.4f / 255); // FIXME: 0.5f is too much } } diff --git a/plugins/GSdx/res/tfx9.fx b/plugins/GSdx/res/tfx9.fx index b7f6dba519..0dfc6f6a7c 100644 --- a/plugins/GSdx/res/tfx9.fx +++ b/plugins/GSdx/res/tfx9.fx @@ -285,7 +285,7 @@ float4 ps_main(PS_INPUT input) : COLOR } else if(ATST == 4) // e { - clip(0.9f/256 - abs(c.a - AREF)); + clip(0.5f / 256 - abs(c.a - AREF)); } else if(ATST == 5 || ATST == 6) // ge, g { @@ -293,7 +293,7 @@ float4 ps_main(PS_INPUT input) : COLOR } else if(ATST == 7) // ne { - clip(abs(c.a - AREF) - 0.9f/256); + clip(abs(c.a - AREF) - 0.4f / 255); // FIXME: 0.5f is too much } } From 752db6056fb721e3daa85ce9b7a05a8cb8eb0948 Mon Sep 17 00:00:00 2001 From: gabest11 Date: Mon, 27 Apr 2009 20:34:11 +0000 Subject: [PATCH 09/41] GSdx: just restoring the vcproj from two revisions ago... git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1075 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/GSdx/GSdx_vs2008.vcproj | 3319 +++++++++++++++---------------- 1 file changed, 1656 insertions(+), 1663 deletions(-) diff --git a/plugins/GSdx/GSdx_vs2008.vcproj b/plugins/GSdx/GSdx_vs2008.vcproj index 2075063ef6..8fa577240e 100644 --- a/plugins/GSdx/GSdx_vs2008.vcproj +++ b/plugins/GSdx/GSdx_vs2008.vcproj @@ -82,6 +82,452 @@ Name="VCPostBuildEventTool" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1198,6 +1191,14 @@ AssemblerOutput="4" /> + + + - - - @@ -1251,7 +1244,7 @@ RelativePath=".\GSRasterizer.cpp" > - - - @@ -1482,14 +1467,6 @@ UsePrecompiledHeader="1" /> - - - @@ -1498,14 +1475,6 @@ UsePrecompiledHeader="1" /> - - - @@ -1514,14 +1483,6 @@ UsePrecompiledHeader="1" /> - - - @@ -1530,14 +1491,6 @@ UsePrecompiledHeader="1" /> - - - @@ -1546,14 +1499,6 @@ UsePrecompiledHeader="1" /> - - - @@ -1563,7 +1508,7 @@ /> + + + + + + + + + + + + + + + + + + - - - @@ -1970,14 +1955,6 @@ UsePrecompiledHeader="0" /> - - - @@ -1986,14 +1963,6 @@ UsePrecompiledHeader="0" /> - - - @@ -2002,14 +1971,6 @@ UsePrecompiledHeader="0" /> - - - @@ -2018,14 +1979,6 @@ UsePrecompiledHeader="0" /> - - - @@ -2034,14 +1987,6 @@ UsePrecompiledHeader="0" /> - - - @@ -2051,7 +1996,7 @@ /> + + + + + + + + + + + + + + + + + + - - - @@ -2106,14 +2091,6 @@ UsePrecompiledHeader="0" /> - - - @@ -2122,14 +2099,6 @@ UsePrecompiledHeader="0" /> - - - @@ -2138,14 +2107,6 @@ UsePrecompiledHeader="0" /> - - - @@ -2154,14 +2115,6 @@ UsePrecompiledHeader="0" /> - - - @@ -2170,14 +2123,6 @@ UsePrecompiledHeader="0" /> - - - @@ -2187,7 +2132,7 @@ /> + + + + + + + + + + + + + + + + + + - - - @@ -2242,14 +2227,6 @@ UsePrecompiledHeader="0" /> - - - @@ -2258,14 +2235,6 @@ UsePrecompiledHeader="0" /> - - - @@ -2274,14 +2243,6 @@ UsePrecompiledHeader="0" /> - - - @@ -2290,14 +2251,6 @@ UsePrecompiledHeader="0" /> - - - @@ -2306,14 +2259,6 @@ UsePrecompiledHeader="0" /> - - - @@ -2323,7 +2268,7 @@ /> + + + + + + + + + + + + + + + + + + - - - @@ -2378,14 +2363,6 @@ UsePrecompiledHeader="0" /> - - - @@ -2394,14 +2371,6 @@ UsePrecompiledHeader="0" /> - - - @@ -2410,14 +2379,6 @@ UsePrecompiledHeader="0" /> - - - @@ -2426,14 +2387,6 @@ UsePrecompiledHeader="0" /> - - - @@ -2442,14 +2395,6 @@ UsePrecompiledHeader="0" /> - - - @@ -2459,7 +2404,7 @@ /> + + + + + + + + + + + + + + + + + + - - - @@ -2514,14 +2499,6 @@ UsePrecompiledHeader="0" /> - - - @@ -2530,14 +2507,6 @@ UsePrecompiledHeader="0" /> - - - @@ -2546,14 +2515,6 @@ UsePrecompiledHeader="0" /> - - - @@ -2562,14 +2523,6 @@ UsePrecompiledHeader="0" /> - - - @@ -2578,14 +2531,6 @@ UsePrecompiledHeader="0" /> - - - @@ -2595,7 +2540,7 @@ /> + + + + + + + + + + + + + + + + + + - - - @@ -2650,14 +2635,6 @@ UsePrecompiledHeader="0" /> - - - @@ -2666,14 +2643,6 @@ UsePrecompiledHeader="0" /> - - - @@ -2682,14 +2651,6 @@ UsePrecompiledHeader="0" /> - - - @@ -2698,14 +2659,6 @@ UsePrecompiledHeader="0" /> - - - @@ -2714,14 +2667,6 @@ UsePrecompiledHeader="0" /> - - - @@ -2731,7 +2676,7 @@ /> + + + + + + + + + + + + + + + + + + - - - @@ -2802,14 +2787,6 @@ UsePrecompiledHeader="0" /> - - - @@ -2818,14 +2795,6 @@ UsePrecompiledHeader="0" /> - - - @@ -2834,14 +2803,6 @@ UsePrecompiledHeader="0" /> - - - @@ -2850,14 +2811,6 @@ UsePrecompiledHeader="0" /> - - - @@ -2866,14 +2819,6 @@ UsePrecompiledHeader="0" /> - - - @@ -2883,7 +2828,7 @@ /> + + + + + + + + + + + + + + + + + + - - - @@ -2938,14 +2923,6 @@ UsePrecompiledHeader="0" /> - - - @@ -2954,14 +2931,6 @@ UsePrecompiledHeader="0" /> - - - @@ -2970,14 +2939,6 @@ UsePrecompiledHeader="0" /> - - - @@ -2986,14 +2947,6 @@ UsePrecompiledHeader="0" /> - - - @@ -3002,14 +2955,6 @@ UsePrecompiledHeader="0" /> - - - @@ -3019,7 +2964,7 @@ /> + + + + + + + + + + + + + + + + + + - - - @@ -3074,14 +3059,6 @@ UsePrecompiledHeader="0" /> - - - @@ -3090,14 +3067,6 @@ UsePrecompiledHeader="0" /> - - - @@ -3106,14 +3075,6 @@ UsePrecompiledHeader="0" /> - - - @@ -3122,14 +3083,6 @@ UsePrecompiledHeader="0" /> - - - @@ -3138,14 +3091,6 @@ UsePrecompiledHeader="0" /> - - - @@ -3155,7 +3100,7 @@ /> + + + + + + + + + + + + + + + + + + - - - @@ -3210,14 +3195,6 @@ UsePrecompiledHeader="0" /> - - - @@ -3226,14 +3203,6 @@ UsePrecompiledHeader="0" /> - - - @@ -3242,14 +3211,6 @@ UsePrecompiledHeader="0" /> - - - @@ -3258,14 +3219,6 @@ UsePrecompiledHeader="0" /> - - - @@ -3274,14 +3227,6 @@ UsePrecompiledHeader="0" /> - - - @@ -3291,7 +3236,7 @@ /> + + + + + + + + + + + + + + + + + + - - - @@ -3346,14 +3331,6 @@ UsePrecompiledHeader="0" /> - - - @@ -3362,14 +3339,6 @@ UsePrecompiledHeader="0" /> - - - @@ -3378,14 +3347,6 @@ UsePrecompiledHeader="0" /> - - - @@ -3394,14 +3355,6 @@ UsePrecompiledHeader="0" /> - - - @@ -3410,14 +3363,6 @@ UsePrecompiledHeader="0" /> - - - @@ -3427,7 +3372,7 @@ /> + + + + + + + + + + + + + + + + + + - - - @@ -3486,14 +3471,6 @@ UsePrecompiledHeader="0" /> - - - @@ -3502,14 +3479,6 @@ UsePrecompiledHeader="0" /> - - - @@ -3518,14 +3487,6 @@ UsePrecompiledHeader="0" /> - - - @@ -3534,14 +3495,6 @@ UsePrecompiledHeader="0" /> - - - @@ -3550,14 +3503,6 @@ UsePrecompiledHeader="0" /> - - - @@ -3567,7 +3512,7 @@ /> + + + + + + + + + + + + + + + + + + - - - @@ -3622,14 +3607,6 @@ UsePrecompiledHeader="0" /> - - - @@ -3638,14 +3615,6 @@ UsePrecompiledHeader="0" /> - - - @@ -3654,14 +3623,6 @@ UsePrecompiledHeader="0" /> - - - @@ -3670,14 +3631,6 @@ UsePrecompiledHeader="0" /> - - - @@ -3686,14 +3639,6 @@ UsePrecompiledHeader="0" /> - - - @@ -3703,7 +3648,7 @@ /> + + + + + + + + + + + + + + + + + + - - - @@ -3758,14 +3743,6 @@ UsePrecompiledHeader="0" /> - - - @@ -3774,14 +3751,6 @@ UsePrecompiledHeader="0" /> - - - @@ -3790,14 +3759,6 @@ UsePrecompiledHeader="0" /> - - - @@ -3806,14 +3767,6 @@ UsePrecompiledHeader="0" /> - - - @@ -3822,14 +3775,6 @@ UsePrecompiledHeader="0" /> - - - @@ -3839,7 +3784,7 @@ /> + + + + + + + + + + + + + + + + + + - - - @@ -3894,14 +3879,6 @@ UsePrecompiledHeader="0" /> - - - @@ -3910,14 +3887,6 @@ UsePrecompiledHeader="0" /> - - - @@ -3926,14 +3895,6 @@ UsePrecompiledHeader="0" /> - - - @@ -3942,14 +3903,6 @@ UsePrecompiledHeader="0" /> - - - @@ -3958,14 +3911,6 @@ UsePrecompiledHeader="0" /> - - - @@ -3975,7 +3920,7 @@ /> + + + + + + + + + + + + + + + + + + - - - @@ -4034,14 +4019,6 @@ UsePrecompiledHeader="0" /> - - - @@ -4050,14 +4027,6 @@ UsePrecompiledHeader="0" /> - - - @@ -4066,14 +4035,6 @@ UsePrecompiledHeader="0" /> - - - @@ -4082,14 +4043,6 @@ UsePrecompiledHeader="0" /> - - - @@ -4098,14 +4051,6 @@ UsePrecompiledHeader="0" /> - - - @@ -4115,7 +4060,7 @@ /> + + + + + + + + + + + + + + + + + + - - - @@ -4170,14 +4155,6 @@ UsePrecompiledHeader="0" /> - - - @@ -4186,14 +4163,6 @@ UsePrecompiledHeader="0" /> - - - @@ -4202,14 +4171,6 @@ UsePrecompiledHeader="0" /> - - - @@ -4218,14 +4179,6 @@ UsePrecompiledHeader="0" /> - - - @@ -4234,14 +4187,6 @@ UsePrecompiledHeader="0" /> - - - @@ -4251,7 +4196,7 @@ /> + + + + + + + + + + + + + + + + + + - - - @@ -4306,14 +4291,6 @@ UsePrecompiledHeader="0" /> - - - @@ -4322,14 +4299,6 @@ UsePrecompiledHeader="0" /> - - - @@ -4338,14 +4307,6 @@ UsePrecompiledHeader="0" /> - - - @@ -4354,14 +4315,6 @@ UsePrecompiledHeader="0" /> - - - @@ -4370,14 +4323,6 @@ UsePrecompiledHeader="0" /> - - - @@ -4387,7 +4332,7 @@ /> + + + + + + + + + + + + + + + + + + - - - @@ -4442,14 +4427,6 @@ UsePrecompiledHeader="0" /> - - - @@ -4458,14 +4435,6 @@ UsePrecompiledHeader="0" /> - - - @@ -4474,14 +4443,6 @@ UsePrecompiledHeader="0" /> - - - @@ -4490,14 +4451,6 @@ UsePrecompiledHeader="0" /> - - - @@ -4506,14 +4459,6 @@ UsePrecompiledHeader="0" /> - - - @@ -4523,7 +4468,7 @@ /> + + + + + + + + + + + + + + + + + + - - - @@ -4578,14 +4563,6 @@ UsePrecompiledHeader="0" /> - - - @@ -4594,14 +4571,6 @@ UsePrecompiledHeader="0" /> - - - @@ -4610,14 +4579,6 @@ UsePrecompiledHeader="0" /> - - - @@ -4626,14 +4587,6 @@ UsePrecompiledHeader="0" /> - - - @@ -4642,14 +4595,6 @@ UsePrecompiledHeader="0" /> - - - @@ -4659,7 +4604,7 @@ /> + + + + + + + + + + + + + + + + + + - - - @@ -4714,14 +4699,6 @@ UsePrecompiledHeader="0" /> - - - @@ -4730,14 +4707,6 @@ UsePrecompiledHeader="0" /> - - - @@ -4746,14 +4715,6 @@ UsePrecompiledHeader="0" /> - - - @@ -4762,14 +4723,6 @@ UsePrecompiledHeader="0" /> - - - @@ -4778,14 +4731,6 @@ UsePrecompiledHeader="0" /> - - - @@ -4795,7 +4740,7 @@ /> + + + + + + + + + + + + + + + + + + - - - @@ -4850,14 +4835,6 @@ UsePrecompiledHeader="0" /> - - - @@ -4866,14 +4843,6 @@ UsePrecompiledHeader="0" /> - - - @@ -4882,14 +4851,6 @@ UsePrecompiledHeader="0" /> - - - @@ -4898,14 +4859,6 @@ UsePrecompiledHeader="0" /> - - - @@ -4914,14 +4867,6 @@ UsePrecompiledHeader="0" /> - - - @@ -4931,7 +4876,7 @@ /> + + + + + + + + + + + + + + + + + + - - - @@ -4986,14 +4971,6 @@ UsePrecompiledHeader="0" /> - - - @@ -5002,14 +4979,6 @@ UsePrecompiledHeader="0" /> - - - @@ -5018,14 +4987,6 @@ UsePrecompiledHeader="0" /> - - - @@ -5034,14 +4995,6 @@ UsePrecompiledHeader="0" /> - - - @@ -5050,14 +5003,6 @@ UsePrecompiledHeader="0" /> - - - @@ -5067,7 +5012,7 @@ /> + + + + + + + + + + + + + + + + + + Date: Mon, 27 Apr 2009 21:19:50 +0000 Subject: [PATCH 10/41] GSdx: more alpha test magic git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1076 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/GSdx/res/tfx10.fx | 2 +- plugins/GSdx/res/tfx9.fx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/GSdx/res/tfx10.fx b/plugins/GSdx/res/tfx10.fx index 0a20767d6b..fe101d1674 100644 --- a/plugins/GSdx/res/tfx10.fx +++ b/plugins/GSdx/res/tfx10.fx @@ -458,7 +458,7 @@ PS_OUTPUT ps_main(PS_INPUT input) } else if(ATST == 4) // e { - clip(0.5f / 256 - abs(c.a - AREF)); + clip(0.6f / 255 - abs(c.a - AREF)); // FIXME: 0.5f is too small } else if(ATST == 5 || ATST == 6) // ge, g { diff --git a/plugins/GSdx/res/tfx9.fx b/plugins/GSdx/res/tfx9.fx index 0dfc6f6a7c..d3c9d05d85 100644 --- a/plugins/GSdx/res/tfx9.fx +++ b/plugins/GSdx/res/tfx9.fx @@ -285,7 +285,7 @@ float4 ps_main(PS_INPUT input) : COLOR } else if(ATST == 4) // e { - clip(0.5f / 256 - abs(c.a - AREF)); + clip(0.6f / 256 - abs(c.a - AREF)); // FIXME: 0.5f is too small } else if(ATST == 5 || ATST == 6) // ge, g { From 2a47e807c3a1083e77ca434d6ed786f5a300656d Mon Sep 17 00:00:00 2001 From: cottonvibes Date: Mon, 27 Apr 2009 21:58:20 +0000 Subject: [PATCH 11/41] microVU: - fixed a bug in the logging system causing incorrect branch-to addresses. git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1077 96395faa-99c1-11dd-bbfe-3dabce05a288 --- pcsx2/x86/microVU_Log.inl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pcsx2/x86/microVU_Log.inl b/pcsx2/x86/microVU_Log.inl index d83cbe4de8..9c05a82317 100644 --- a/pcsx2/x86/microVU_Log.inl +++ b/pcsx2/x86/microVU_Log.inl @@ -85,7 +85,7 @@ microVUt(void) __mVUdumpProgram(int progIndex) { if (delay == 2) { mVUlog(""); } if (delay == 1) { mVUlog(""); } - iPC = (i+1)/4; + iPC = (i+1); mVUlog("", i*4); mVUlog("[%04x] (%08x) ", i*4, mVU->code); mVUopU(); @@ -100,7 +100,7 @@ microVUt(void) __mVUdumpProgram(int progIndex) { mVUlog(")"); } - iPC = i/4; + iPC = i; if (bitX[7]) { mVUlog(""); } mVU->code = mVU->prog.prog[progIndex].data[i]; mVUlog("
\n[%04x] (%08x) ", i*4, mVU->code); From ad7aa893e97e8fd2c93dad9b954e63c38ebcb3a1 Mon Sep 17 00:00:00 2001 From: arcum42 Date: Wed, 29 Apr 2009 05:07:18 +0000 Subject: [PATCH 12/41] All right, now that's just silly... (Fix Linux compilation.) git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1084 96395faa-99c1-11dd-bbfe-3dabce05a288 --- pcsx2/x86/ix86-32/recVTLB.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/pcsx2/x86/ix86-32/recVTLB.cpp b/pcsx2/x86/ix86-32/recVTLB.cpp index 2f43fa3686..a7ef079687 100644 --- a/pcsx2/x86/ix86-32/recVTLB.cpp +++ b/pcsx2/x86/ix86-32/recVTLB.cpp @@ -23,7 +23,6 @@ #include "iCore.h" #include "iR5900.h" -#include "ix86\ix86_internal.h" using namespace vtlb_private; using namespace x86Emitter; From 6e82c77e92dc01a006a164d1370a7a60a114e634 Mon Sep 17 00:00:00 2001 From: "Jake.Stine" Date: Wed, 29 Apr 2009 08:30:33 +0000 Subject: [PATCH 13/41] Bugfix for r1083. [Don't ask me what I was thinking when I wrote >>10 instead of >>12] git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1085 96395faa-99c1-11dd-bbfe-3dabce05a288 --- pcsx2/x86/ix86-32/iR5900-32.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pcsx2/x86/ix86-32/iR5900-32.cpp b/pcsx2/x86/ix86-32/iR5900-32.cpp index 67c1b1e8ce..fc2c354932 100644 --- a/pcsx2/x86/ix86-32/iR5900-32.cpp +++ b/pcsx2/x86/ix86-32/iR5900-32.cpp @@ -1269,7 +1269,7 @@ void __fastcall dyna_page_reset(u32 start,u32 sz) { DevCon::WriteLn("dyna_page_reset .. start=%08X count=%d", params start,sz); Cpu->Clear(start & ~0xfffUL, 0x400); - manual_counter[start >> 10]++; + manual_counter[start >> 12]++; mmap_MarkCountedRamPage(PSM(start), start & ~0xfffUL); } From 41079415fa4d0d776b492979c8496111b544720a Mon Sep 17 00:00:00 2001 From: "Jake.Stine" Date: Wed, 29 Apr 2009 10:10:33 +0000 Subject: [PATCH 14/41] Improved SSE detection: * SSE3 detection via cpuid implemented. [fixes Linux -- the force_sse3 option should no longer be needed!] * Instruction tests are now done for SSE3, SSE4, and SSE4.1 to confirm cpuid results (I doubt this is necessary, but the old code did it for SSE3, so I figured I'd keep it and log results anytime an inconsistency is detected). * SSE4.2 and SSE4a detection added. git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1086 96395faa-99c1-11dd-bbfe-3dabce05a288 --- pcsx2/System.cpp | 12 ++- pcsx2/x86/ix86/ix86_cpudetect.cpp | 117 +++++++++++++++++++++--------- pcsx2/x86/ix86/ix86_types.h | 3 + 3 files changed, 94 insertions(+), 38 deletions(-) diff --git a/pcsx2/System.cpp b/pcsx2/System.cpp index 8197d76f20..97b2a3b64f 100644 --- a/pcsx2/System.cpp +++ b/pcsx2/System.cpp @@ -135,13 +135,15 @@ void SysDetect() "\t%sDetected SSE2\n" "\t%sDetected SSE3\n" "\t%sDetected SSSE3\n" - "\t%sDetected SSE4.1\n", params + "\t%sDetected SSE4.1\n" + "\t%sDetected SSE4.2\n", params cpucaps.hasMultimediaExtensions ? "" : "Not ", cpucaps.hasStreamingSIMDExtensions ? "" : "Not ", cpucaps.hasStreamingSIMD2Extensions ? "" : "Not ", cpucaps.hasStreamingSIMD3Extensions ? "" : "Not ", cpucaps.hasSupplementalStreamingSIMD3Extensions ? "" : "Not ", - cpucaps.hasStreamingSIMD4Extensions ? "" : "Not " + cpucaps.hasStreamingSIMD4Extensions ? "" : "Not ", + cpucaps.hasStreamingSIMD4Extensions2 ? "" : "Not " ); if ( cpuinfo.x86ID[0] == 'A' ) //AMD cpu @@ -150,10 +152,12 @@ void SysDetect() WriteLn( "\t%sDetected MMX2\n" "\t%sDetected 3DNOW\n" - "\t%sDetected 3DNOW2\n", params + "\t%sDetected 3DNOW2\n" + "\t%sDetected SSE4a\n", params cpucaps.hasMultimediaExtensionsExt ? "" : "Not ", cpucaps.has3DNOWInstructionExtensions ? "" : "Not ", - cpucaps.has3DNOWInstructionExtensionsExt ? "" : "Not " + cpucaps.has3DNOWInstructionExtensionsExt ? "" : "Not ", + cpucaps.hasStreamingSIMD4ExtensionsA ? "" : "Not " ); } diff --git a/pcsx2/x86/ix86/ix86_cpudetect.cpp b/pcsx2/x86/ix86/ix86_cpudetect.cpp index 083d72e1b2..d43ec437ef 100644 --- a/pcsx2/x86/ix86/ix86_cpudetect.cpp +++ b/pcsx2/x86/ix86/ix86_cpudetect.cpp @@ -23,6 +23,8 @@ #include "RedtapeWindows.h" +using namespace x86Emitter; + #if defined (_MSC_VER) && _MSC_VER >= 1400 extern "C" @@ -148,31 +150,29 @@ u64 GetCPUTick( void ) #endif } +////////////////////////////////////////////////////////////////////////////////////////// // Note: This function doesn't support GCC/Linux. Looking online it seems the only // way to simulate the Micrsoft SEH model is to use unix signals, and the 'sigaction' // function specifically. Maybe a project for a linux developer at a later date. :) -void cpudetectSSE3(void* pfnCallSSE3) -{ - cpucaps.hasStreamingSIMD3Extensions = 1; - #ifdef _MSC_VER +static bool _test_instruction( void* pfnCall ) +{ __try { - ((void (*)())pfnCallSSE3)(); + ((void (*)())pfnCall)(); } __except(EXCEPTION_EXECUTE_HANDLER) { - cpucaps.hasStreamingSIMD3Extensions = 0; + return false; } -#else // linux - -#ifdef PCSX2_FORCESSE3 - cpucaps.hasStreamingSIMD3Extensions = 1; -#else - // exception handling doesn't work, so disable for x86 builds of linux - cpucaps.hasStreamingSIMD3Extensions = 0; -#endif -#endif + return true; } +static char* bool_to_char( bool testcond ) +{ + return testcond ? "true" : "false"; +} + +#endif + #if defined __LINUX__ #include @@ -180,6 +180,8 @@ void cpudetectSSE3(void* pfnCallSSE3) #endif +////////////////////////////////////////////////////////////////////////////////////////// +// s64 CPUSpeedHz( unsigned int time ) { s64 timeStart, @@ -197,9 +199,10 @@ s64 CPUSpeedHz( unsigned int time ) timeStart = timeGetTime( ); while( timeGetTime( ) == timeStart ) - { - timeStart = timeGetTime( ); - } + { + timeStart = timeGetTime( ); + } + for(;;) { timeStop = timeGetTime( ); @@ -294,6 +297,7 @@ void cpudetectInit() if ( iCpuId( 0x80000001, regs ) != -1 ) { x86_64_12BITBRANDID = regs[1] & 0xfff; + cpuinfo.x86EFlags2 = regs[ 2 ]; cpuinfo.x86EFlags = regs[ 3 ]; } @@ -364,40 +368,85 @@ void cpudetectInit() cpucaps.hasMultiThreading = ( cpuinfo.x86Flags >> 28 ) & 1; cpucaps.hasThermalMonitor = ( cpuinfo.x86Flags >> 29 ) & 1; cpucaps.hasIntel64BitArchitecture = ( cpuinfo.x86Flags >> 30 ) & 1; + //that is only for AMDs cpucaps.hasMultimediaExtensionsExt = ( cpuinfo.x86EFlags >> 22 ) & 1; //mmx2 cpucaps.hasAMD64BitArchitecture = ( cpuinfo.x86EFlags >> 29 ) & 1; //64bit cpu cpucaps.has3DNOWInstructionExtensionsExt = ( cpuinfo.x86EFlags >> 30 ) & 1; //3dnow+ cpucaps.has3DNOWInstructionExtensions = ( cpuinfo.x86EFlags >> 31 ) & 1; //3dnow + cpucaps.hasStreamingSIMD4ExtensionsA = ( cpuinfo.x86EFlags2 >> 6 ) & 1; //INSERTQ / EXTRQ / MOVNT - cpuinfo.cpuspeed = (u32)(CPUSpeedHz( 1000 ) / 1000000); - // --> SSE 4.1 detection <-- - // We don't care about the small subset of CPUs using SSE4 (which is also hard to - // detect, in addition to being of limited use due to the abbreviated instruction set). - // So we'll just leave it at SSE 4.1. SSE4 cpu detection is ignored. + cpuinfo.cpuspeed = (u32)(CPUSpeedHz( 600 ) / 1000000); - cpucaps.hasStreamingSIMD4Extensions = ( cpuinfo.x86Flags2 >> 19 ) & 1; //sse4.1 - - // --> SSSE3 detection <-- + // --> SSE3 / SSSE3 / SSE4.1 / SSE 4.2 detection <-- + cpucaps.hasStreamingSIMD3Extensions = ( cpuinfo.x86Flags2 >> 0 ) & 1; //sse3 cpucaps.hasSupplementalStreamingSIMD3Extensions = ( cpuinfo.x86Flags2 >> 9 ) & 1; //ssse3 + cpucaps.hasStreamingSIMD4Extensions = ( cpuinfo.x86Flags2 >> 19 ) & 1; //sse4.1 + cpucaps.hasStreamingSIMD4Extensions2 = ( cpuinfo.x86Flags2 >> 20 ) & 1; //sse4.2 - // --> SSE3 detection <-- - // These instructions may not be recognized by some compilers, or may not have - // intrinsic equivalents available. So we use our own ix86 emitter to generate - // some code and run it that way. :) + // Can the SSE3 / SSE4.1 bits be trusted? Using an instruction test is a very "complete" + // approach to ensuring the bit is accurate, and at least one reported case of a Q9550 not + // having SSE 4.1 set but still supporting it properly is fixed by this --air + #ifdef _MSC_VER u8* recSSE = (u8*)HostSys::Mmap( NULL, 0x1000 ); if( recSSE != NULL ) { - x86SetPtr(recSSE); - SSE3_MOVSLDUP_XMM_to_XMM(XMM0, XMM0); + xSetPtr( recSSE ); + xMOVSLDUP( xmm1, xmm0 ); RET(); - cpudetectSSE3(recSSE); + + u8* funcSSSE3 = xGetPtr(); + xPABS.W( xmm0, xmm1 ); + RET(); + + u8* funcSSE41 = xGetPtr(); + xBLEND.VPD( xmm1, xmm0 ); + RET(); + + bool sse3_result = _test_instruction( recSSE ); // sse3 + bool ssse3_result = _test_instruction( funcSSSE3 ); + bool sse41_result = _test_instruction( funcSSE41 ); + HostSys::Munmap( recSSE, 0x1000 ); + + // Test for and log any irregularities here. + // We take the instruction test result over cpuid since (in theory) it should be a + // more reliable gauge of the cpu's actual ability. + + if( sse3_result != cpucaps.hasStreamingSIMD3Extensions ) + { + Console::Notice( "SSE3 Detection Inconsistency: cpuid=%s, test_result=%s", + params bool_to_char( cpucaps.hasStreamingSIMD3Extensions ), bool_to_char( sse3_result ) ); + + cpucaps.hasStreamingSIMD3Extensions = sse3_result; + } + + if( ssse3_result != cpucaps.hasSupplementalStreamingSIMD3Extensions ) + { + Console::Notice( "SSSE3 Detection Inconsistency: cpuid=%s, test_result=%s", + params bool_to_char( cpucaps.hasSupplementalStreamingSIMD3Extensions ), bool_to_char( ssse3_result ) ); + + cpucaps.hasSupplementalStreamingSIMD3Extensions = ssse3_result; + } + + if( sse41_result != cpucaps.hasStreamingSIMD4Extensions ) + { + Console::Notice( "SSE4 Detection Inconsistency: cpuid=%s, test_result=%s", + params bool_to_char( cpucaps.hasStreamingSIMD4Extensions ), bool_to_char( sse41_result ) ); + + cpucaps.hasStreamingSIMD4Extensions = sse41_result; + } + } - else { Console::Error("Error: Failed to allocate memory for SSE3 State detection."); } + else + Console::Notice( + "Notice: Could not allocate memory for SSE3/4 detection.\n" + "\tRelying on CPUID results. [this is not an error]" + ); + #endif ////////////////////////////////////// // Core Counting! diff --git a/pcsx2/x86/ix86/ix86_types.h b/pcsx2/x86/ix86/ix86_types.h index 78cd2538a5..95a6a3b3cd 100644 --- a/pcsx2/x86/ix86/ix86_types.h +++ b/pcsx2/x86/ix86/ix86_types.h @@ -54,12 +54,14 @@ struct CAPABILITIES u32 hasStreamingSIMD3Extensions; u32 hasSupplementalStreamingSIMD3Extensions; u32 hasStreamingSIMD4Extensions; + u32 hasStreamingSIMD4Extensions2; // AMD-specific CPU Features u32 hasMultimediaExtensionsExt; u32 hasAMD64BitArchitecture; u32 has3DNOWInstructionExtensionsExt; u32 has3DNOWInstructionExtensions; + u32 hasStreamingSIMD4ExtensionsA; }; extern CAPABILITIES cpucaps; @@ -73,6 +75,7 @@ struct CPUINFO u32 x86Flags; // Feature Flags u32 x86Flags2; // More Feature Flags u32 x86EFlags; // Extended Feature Flags + u32 x86EFlags2; // Extended Feature Flags pg2 u32 PhysicalCores; u32 LogicalCores; From e81fbc728de4f27512ea11c352fb6234fb02804c Mon Sep 17 00:00:00 2001 From: "Jake.Stine" Date: Wed, 29 Apr 2009 11:13:17 +0000 Subject: [PATCH 15/41] Fixed a bug in the cpu mhz detection introduced in the prev revision, and improved the algo to be much quicker and generally more accurate than before (and with luck AMDs will agree!) git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1087 96395faa-99c1-11dd-bbfe-3dabce05a288 --- pcsx2/x86/ix86/ix86_cpudetect.cpp | 54 +++++++++++++------------------ 1 file changed, 22 insertions(+), 32 deletions(-) diff --git a/pcsx2/x86/ix86/ix86_cpudetect.cpp b/pcsx2/x86/ix86/ix86_cpudetect.cpp index d43ec437ef..6e211619f3 100644 --- a/pcsx2/x86/ix86/ix86_cpudetect.cpp +++ b/pcsx2/x86/ix86/ix86_cpudetect.cpp @@ -182,49 +182,39 @@ static char* bool_to_char( bool testcond ) ////////////////////////////////////////////////////////////////////////////////////////// // -s64 CPUSpeedHz( unsigned int time ) +s64 CPUSpeedHz( int time ) { - s64 timeStart, + int timeStart, timeStop; s64 startTick, endTick; - s64 overhead; if( ! cpucaps.hasTimeStampCounter ) { return 0; //check if function is supported } - - overhead = GetCPUTick() - GetCPUTick(); - timeStart = timeGetTime( ); - while( timeGetTime( ) == timeStart ) - { - timeStart = timeGetTime( ); - } + // Align the cpu execution to a timeGetTime boundary. + // Without this the result could be skewed by up to several milliseconds. + + do { timeStart = timeGetTime( ); + } while( timeGetTime( ) == timeStart ); - for(;;) + do { timeStop = timeGetTime( ); - if ( ( timeStop - timeStart ) > 1 ) - { - startTick = GetCPUTick( ); - break; - } - } + startTick = GetCPUTick( ); + } while( ( timeStop - timeStart ) < 1 ); timeStart = timeStop; - for(;;) + do { - timeStop = timeGetTime( ); - if ( ( timeStop - timeStart ) > time ) - { - endTick = GetCPUTick( ); - break; - } + timeStop = timeGetTime(); + endTick = GetCPUTick(); } + while( ( timeStop - timeStart ) < time ); - return (s64)( ( endTick - startTick ) + ( overhead ) ); + return (s64)( endTick - startTick ); } //////////////////////////////////////////////////// @@ -377,7 +367,7 @@ void cpudetectInit() cpucaps.hasStreamingSIMD4ExtensionsA = ( cpuinfo.x86EFlags2 >> 6 ) & 1; //INSERTQ / EXTRQ / MOVNT - cpuinfo.cpuspeed = (u32)(CPUSpeedHz( 600 ) / 1000000); + cpuinfo.cpuspeed = (u32)(CPUSpeedHz( 400 ) / 400000 ); // --> SSE3 / SSSE3 / SSE4.1 / SSE 4.2 detection <-- @@ -416,26 +406,26 @@ void cpudetectInit() // We take the instruction test result over cpuid since (in theory) it should be a // more reliable gauge of the cpu's actual ability. - if( sse3_result != cpucaps.hasStreamingSIMD3Extensions ) + if( sse3_result != !!cpucaps.hasStreamingSIMD3Extensions ) { Console::Notice( "SSE3 Detection Inconsistency: cpuid=%s, test_result=%s", - params bool_to_char( cpucaps.hasStreamingSIMD3Extensions ), bool_to_char( sse3_result ) ); + params bool_to_char( !!cpucaps.hasStreamingSIMD3Extensions ), bool_to_char( sse3_result ) ); cpucaps.hasStreamingSIMD3Extensions = sse3_result; } - if( ssse3_result != cpucaps.hasSupplementalStreamingSIMD3Extensions ) + if( ssse3_result != !!cpucaps.hasSupplementalStreamingSIMD3Extensions ) { Console::Notice( "SSSE3 Detection Inconsistency: cpuid=%s, test_result=%s", - params bool_to_char( cpucaps.hasSupplementalStreamingSIMD3Extensions ), bool_to_char( ssse3_result ) ); + params bool_to_char( !!cpucaps.hasSupplementalStreamingSIMD3Extensions ), bool_to_char( ssse3_result ) ); cpucaps.hasSupplementalStreamingSIMD3Extensions = ssse3_result; } - if( sse41_result != cpucaps.hasStreamingSIMD4Extensions ) + if( sse41_result != !!cpucaps.hasStreamingSIMD4Extensions ) { Console::Notice( "SSE4 Detection Inconsistency: cpuid=%s, test_result=%s", - params bool_to_char( cpucaps.hasStreamingSIMD4Extensions ), bool_to_char( sse41_result ) ); + params bool_to_char( !!cpucaps.hasStreamingSIMD4Extensions ), bool_to_char( sse41_result ) ); cpucaps.hasStreamingSIMD4Extensions = sse41_result; } From d8617c1ee8220b073e437a3d0e5633e86dd74fd0 Mon Sep 17 00:00:00 2001 From: arcum42 Date: Wed, 29 Apr 2009 11:47:05 +0000 Subject: [PATCH 16/41] Get rid of duplicated code in PS2Etypes.h. :) git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1088 96395faa-99c1-11dd-bbfe-3dabce05a288 --- build.sh | 6 +- common/include/PS2Edefs.h | 8 +- common/include/PS2Etypes.h | 218 +----------------------------------- common/include/Pcsx2Defs.h | 5 + common/include/Pcsx2Types.h | 22 ++-- pcsx2/Common.h | 2 +- pcsx2/Patch.h | 2 +- pcsx2/PrecompiledHeader.h | 2 +- pcsx2/R5900OpcodeTables.h | 2 +- pcsx2/System.h | 2 +- pcsx2/Threading.h | 2 +- pcsx2/configure.ac | 2 +- 12 files changed, 33 insertions(+), 240 deletions(-) diff --git a/build.sh b/build.sh index e409a5c185..a6aaa8710d 100644 --- a/build.sh +++ b/build.sh @@ -6,13 +6,13 @@ # Uncomment if building by itself, rather then with all the plugins #Normal -#export PCSX2OPTIONS="--enable-sse3 --enable-sse4 --prefix `pwd`" +#export PCSX2OPTIONS="--prefix `pwd`" #Optimized, but a devbuild -export PCSX2OPTIONS="--enable-sse3 --enable-sse4 --enable-devbuild --prefix `pwd`" +export PCSX2OPTIONS="--enable-devbuild --prefix `pwd`" #Debug / Devbuild version -#export PCSX2OPTIONS="--enable-debug --enable-devbuild --enable-sse3 --prefix `pwd`" +#export PCSX2OPTIONS="--enable-debug --enable-devbuild --prefix `pwd`" #ZeroGS Normal mode export ZEROGSOPTIONS="--enable-sse2" diff --git a/common/include/PS2Edefs.h b/common/include/PS2Edefs.h index edee168d9e..eac022192b 100644 --- a/common/include/PS2Edefs.h +++ b/common/include/PS2Edefs.h @@ -48,13 +48,7 @@ */ -#include "PS2Etypes.h" - - -/* common defines */ -#ifndef C_ASSERT -#define C_ASSERT(e) typedef char __C_ASSERT__[(e)?1:-1] -#endif +#include "Pcsx2Defs.h" #if defined(GSdefs) || defined(PADdefs) || defined(SIOdefs) || \ defined(SPU2defs) || defined(CDVDdefs) || defined(DEV9defs) || \ diff --git a/common/include/PS2Etypes.h b/common/include/PS2Etypes.h index 474eb50eff..a2401d6041 100644 --- a/common/include/PS2Etypes.h +++ b/common/include/PS2Etypes.h @@ -15,221 +15,13 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ + + // This file is just for backwards compatability. #ifndef __PS2ETYPES_H__ #define __PS2ETYPES_H__ -#if defined (__linux__) && !defined(__LINUX__) // some distributions are lower case -#define __LINUX__ -#endif - -#ifdef __CYGWIN__ -#define __LINUX__ -#endif - -// Renamed ARRAYSIZE to ArraySize -- looks nice and gets rid of Windows.h conflicts (air) -#ifndef ArraySize -#define ArraySize(x) (sizeof(x)/sizeof((x)[0])) -#endif - -////////////////////////////////////////////////////////////////////////////////////////// -// jASSUME - give hints to the optimizer -// This is primarily useful for the default case switch optimizer, which enables VC to -// generate more compact switches. - -#ifdef NDEBUG -# define jBREAKPOINT() ((void) 0) -# ifdef _MSC_VER -# define jASSUME(exp) (__assume(exp)) -# else -# define jASSUME(exp) ((void) sizeof(exp)) -# endif -#else -# if defined(_MSC_VER) -# define jBREAKPOINT() do { __asm int 3 } while(0) -# else -# define jBREAKPOINT() ((void) *(volatile char *) 0) -# endif -# define jASSUME(exp) if(exp) ; else jBREAKPOINT() -#endif - -// disable the default case in a switch -#define jNO_DEFAULT \ -{ \ -default: \ - jASSUME(0); \ - break; \ -} - -////////////////////////////////////////////////////////////////////////////////////////// -// Basic Atomic Types - -#if defined(_MSC_VER) - -typedef __int8 s8; -typedef __int16 s16; -typedef __int32 s32; -typedef __int64 s64; - -typedef unsigned __int8 u8; -typedef unsigned __int16 u16; -typedef unsigned __int32 u32; -typedef unsigned __int64 u64; - -typedef unsigned int uint; - -// Note: building the 'extern' into PCSX2_ALIGNED16_DECL fixes Visual Assist X's intellisense. - -#define PCSX2_ALIGNED(alig,x) __declspec(align(alig)) x -#define PCSX2_ALIGNED_EXTERN(alig,x) extern __declspec(align(alig)) x -#define PCSX2_ALIGNED16(x) __declspec(align(16)) x -#define PCSX2_ALIGNED16_EXTERN(x) extern __declspec(align(16)) x - -#define __naked __declspec(naked) -#define __unused /*unused*/ -#define __noinline __declspec(noinline) -#define CALLBACK __stdcall - -#else // _MSC_VER - -#ifdef __LINUX__ - -#ifdef HAVE_STDINT_H -#include "stdint.h" - -typedef int8_t s8; -typedef int16_t s16; -typedef int32_t s32; -typedef int64_t s64; - -typedef uint8_t u8; -typedef uint16_t u16; -typedef uint32_t u32; -typedef uint64_t u64; - -typedef uintptr_t uptr; -typedef intptr_t sptr; - -#else // HAVE_STDINT_H - -typedef char s8; -typedef short s16; -typedef int s32; -typedef long long s64; - -typedef unsigned char u8; -typedef unsigned short u16; -typedef unsigned int u32; -typedef unsigned long long u64; - -#endif // HAVE_STDINT_H - -typedef unsigned int uint; - -#define LONG long -typedef union _LARGE_INTEGER -{ - long long QuadPart; -} LARGE_INTEGER; - -#define __fastcall __attribute__((fastcall)) -#define __unused __attribute__((unused)) -#define _inline __inline__ __attribute__((unused)) -#define __forceinline __attribute__((always_inline,unused)) -#define __noinline __attribute__((noinline)) -#define __naked // GCC lacks the naked specifier -#define CALLBACK // CALLBACK is win32-specific mess - -#endif // __LINUX__ - -#define PCSX2_ALIGNED(alig,x) x __attribute((aligned(alig))) -#define PCSX2_ALIGNED16(x) x __attribute((aligned(16))) - -// fixme - is this needed for recent versions of GCC? Or can we just use the macros -// above instead for both definitions (implementations) and declarations (includes)? -- air - -#define PCSX2_ALIGNED_EXTERN(alig,x) extern x __attribute((aligned(alig))) -#define PCSX2_ALIGNED16_EXTERN(x) extern x __attribute((aligned(16))) - -#endif // _MSC_VER - -#if !defined(__LINUX__) || !defined(HAVE_STDINT_H) -#if defined(__x86_64__) -typedef u64 uptr; -typedef s64 sptr; -#else -typedef u32 uptr; -typedef s32 sptr; -#endif -#endif - -////////////////////////////////////////////////////////////////////////////////////////// -// A rough-and-ready cross platform 128-bit datatype, Non-SSE style. -#ifdef __cplusplus -struct u128 -{ - u64 lo; - u64 hi; - - // Implicit conversion from u64 - u128( u64 src ) : - lo( src ) - , hi( 0 ) {} - - // Implicit conversion from u32 - u128( u32 src ) : - lo( src ) - , hi( 0 ) {} -}; - -struct s128 -{ - s64 lo; - s64 hi; - - // Implicit conversion from u64 - s128( s64 src ) : - lo( src ) - , hi( 0 ) {} - - // Implicit conversion from u32 - s128( s32 src ) : - lo( src ) - , hi( 0 ) {} -}; - -#else - -typedef union _u128_t -{ - u64 lo; - u64 hi; -} u128; - -typedef union _s128_t -{ - s64 lo; - s64 hi; -} s128; - -#endif - -typedef struct { - int size; - s8 *data; -} freezeData; - -// event values: -#define KEYPRESS 1 -#define KEYRELEASE 2 - -typedef struct _keyEvent { - u32 key; - u32 evt; -} keyEvent; - -/* common defines */ -#ifndef C_ASSERT -#define C_ASSERT(e) typedef char __C_ASSERT__[(e)?1:-1] -#endif +// This brings in both all the things that used to be in PS2types.h that weren't type related, +// and also brings Pcsx2Types in. +#include "Pcsx2Defs.h" #endif /* __PS2ETYPES_H__ */ diff --git a/common/include/Pcsx2Defs.h b/common/include/Pcsx2Defs.h index dbaf5ca315..20a5f8f1fa 100644 --- a/common/include/Pcsx2Defs.h +++ b/common/include/Pcsx2Defs.h @@ -27,6 +27,8 @@ #define __LINUX__ #endif +#include "Pcsx2Types.h" + // Renamed ARRAYSIZE to ArraySize -- looks nice and gets rid of Windows.h conflicts (air) #ifndef ArraySize #define ArraySize(x) (sizeof(x)/sizeof((x)[0])) @@ -77,6 +79,8 @@ default: \ #define PCSX2_ALIGNED16_EXTERN(x) extern __declspec(align(16)) x #define __naked __declspec(naked) +#define __unused /*unused*/ +#define __noinline __declspec(noinline) #define CALLBACK __stdcall #else @@ -96,6 +100,7 @@ default: \ #define __unused __attribute__((unused)) #define _inline __inline__ __attribute__((unused)) #define __forceinline __attribute__((always_inline,unused)) +#define __noinline __attribute__((noinline)) #endif typedef struct { diff --git a/common/include/Pcsx2Types.h b/common/include/Pcsx2Types.h index 942076e972..41e2d893a1 100644 --- a/common/include/Pcsx2Types.h +++ b/common/include/Pcsx2Types.h @@ -19,8 +19,6 @@ #ifndef __PCSX2TYPES_H__ #define __PCSX2TYPES_H__ -// Note; this header is experamental, and will be a shifting target. Only use this if you are willing to repeatedly fix breakage. - /* * Based on PS2E Definitions by linuzappz@hotmail.com, @@ -45,12 +43,10 @@ typedef unsigned __int32 u32; typedef unsigned __int64 u64; typedef unsigned int uint; -typedef u32 uptr; -typedef s32 sptr; -#else // _MSC_VER +#else // _MSC_VER*/ - #ifdef __LINUX__ +#ifdef __LINUX__ #ifdef HAVE_STDINT_H #include "stdint.h" @@ -80,9 +76,6 @@ typedef unsigned short u16; typedef unsigned int u32; typedef unsigned long long u64; -typedef u32 uptr; -typedef s32 sptr; - #endif // HAVE_STDINT_H typedef unsigned int uint; @@ -96,6 +89,15 @@ typedef union _LARGE_INTEGER #endif // __LINUX__ #endif //_MSC_VER +#if !defined(__LINUX__) || !defined(HAVE_STDINT_H) +#if defined(__x86_64__) +typedef u64 uptr; +typedef s64 sptr; +#else +typedef u32 uptr; +typedef s32 sptr; +#endif +#endif ////////////////////////////////////////////////////////////////////////////////////////// // A rough-and-ready cross platform 128-bit datatype, Non-SSE style. @@ -148,4 +150,4 @@ typedef union _s128_t #endif - #endif \ No newline at end of file +#endif \ No newline at end of file diff --git a/pcsx2/Common.h b/pcsx2/Common.h index 4daeee5663..1995b786c4 100644 --- a/pcsx2/Common.h +++ b/pcsx2/Common.h @@ -19,7 +19,7 @@ #ifndef __COMMON_H__ #define __COMMON_H__ -#include "PS2Etypes.h" +#include "Pcsx2Defs.h" #define BIAS 2 // Bus is half of the actual ps2 speed //#define PS2CLK 36864000 /* 294.912 mhz */ diff --git a/pcsx2/Patch.h b/pcsx2/Patch.h index e032614d51..b077ae67fd 100644 --- a/pcsx2/Patch.h +++ b/pcsx2/Patch.h @@ -18,7 +18,7 @@ #ifndef __PATCH_H__ #define __PATCH_H__ -#include "PS2Etypes.h" +#include "Pcsx2Defs.h" // // Defines diff --git a/pcsx2/PrecompiledHeader.h b/pcsx2/PrecompiledHeader.h index e2b24c72e3..b299dfb724 100644 --- a/pcsx2/PrecompiledHeader.h +++ b/pcsx2/PrecompiledHeader.h @@ -69,7 +69,7 @@ typedef int BOOL; // unchanged for long periods of time. #include "zlib/zlib.h" -#include "PS2Etypes.h" +#include "Pcsx2Defs.h" #include "MemcpyFast.h" #include "StringUtils.h" #include "Exceptions.h" diff --git a/pcsx2/R5900OpcodeTables.h b/pcsx2/R5900OpcodeTables.h index cd2a5e499c..a8d7346c59 100644 --- a/pcsx2/R5900OpcodeTables.h +++ b/pcsx2/R5900OpcodeTables.h @@ -18,7 +18,7 @@ #ifndef _R5900_OPCODETABLES_H #define _R5900_OPCODETABLES_H -#include "PS2Etypes.h" +#include "Pcsx2Defs.h" // TODO : Move these into the OpcodeTables namespace extern void (*Int_COP2PrintTable[32])(); diff --git a/pcsx2/System.h b/pcsx2/System.h index 09dff0196c..41208581f7 100644 --- a/pcsx2/System.h +++ b/pcsx2/System.h @@ -19,7 +19,7 @@ #ifndef __SYSTEM_H__ #define __SYSTEM_H__ -#include "PS2Etypes.h" +#include "Pcsx2Defs.h" #include "Paths.h" #include "Pcsx2Config.h" #include "Exceptions.h" diff --git a/pcsx2/Threading.h b/pcsx2/Threading.h index a448e9a943..f75d3e4262 100644 --- a/pcsx2/Threading.h +++ b/pcsx2/Threading.h @@ -22,7 +22,7 @@ #include // EBUSY #include -#include "PS2Etypes.h" +#include "Pcsx2Defs.h" #include "Exceptions.h" namespace Threading diff --git a/pcsx2/configure.ac b/pcsx2/configure.ac index d2d5ea39d6..e76f484618 100644 --- a/pcsx2/configure.ac +++ b/pcsx2/configure.ac @@ -38,7 +38,7 @@ fi WARNING_FLAGS="-Wno-format -Wno-unused-parameter -Wno-unused-value -Wunused-variable " EXTRA_WARNING_FLAGS="-Wall -Wextra" NORMAL_FLAGS=" -pipe -msse -msse2 -O2 ${WARNING_FLAGS}" -# These optimizations seem to cause issues with GCC 4.3.3, so we'll turn them off. +# These optimizations seem to cause issues with GCC 4.3.3, so we'll turn them off. Comment if not on 4.3+ NORMAL_FLAGS+=" -fno-guess-branch-probability -fno-dse -fno-tree-dse " DEBUG_FLAGS+=" -g -msse -msse2 ${EXTRA_WARNING_FLAGS} ${WARNING_FLAGS} " From a2fd88d952f22bcbc65171a8b97b0aaac932b3a0 Mon Sep 17 00:00:00 2001 From: "Jake.Stine" Date: Wed, 29 Apr 2009 20:55:13 +0000 Subject: [PATCH 17/41] Fixed bugs in BTS instruction emitters, and working on fixing bugs in BTS memory protection. git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1089 96395faa-99c1-11dd-bbfe-3dabce05a288 --- pcsx2/x86/ix86-32/iR5900-32.cpp | 73 +++++++++++---------------------- pcsx2/x86/ix86-32/recVTLB.cpp | 2 +- pcsx2/x86/ix86/implement/test.h | 20 ++++++--- pcsx2/x86/ix86/ix86_tools.cpp | 4 +- 4 files changed, 40 insertions(+), 59 deletions(-) diff --git a/pcsx2/x86/ix86-32/iR5900-32.cpp b/pcsx2/x86/ix86-32/iR5900-32.cpp index fc2c354932..ae3ce24403 100644 --- a/pcsx2/x86/ix86-32/iR5900-32.cpp +++ b/pcsx2/x86/ix86-32/iR5900-32.cpp @@ -751,6 +751,13 @@ void recClear(u32 addr, u32 size) return; addr = HWADDR(addr); + addr -= addr % 16; // round down. + size += 3; // round up! + size -= size % 4; + + for (u32 a = addr / 16; a < addr / 16 + size / 4; a++) + vtlb_private::vtlbdata.alloc_bits[a / 8] &= ~(1 << (a & 7)); + int blockidx = recBlocks.LastIndex(addr + size * 4 - 4); if (blockidx == -1) @@ -1544,66 +1551,32 @@ StartRecomp: } else { - // import the vtlbdata (alloc_bits and alloc_base and stuff): using namespace vtlb_private; - + MOV32ItoR(ECX, inpage_ptr); - MOV32ItoR(EDX, pgsz); - - u32 mask=0; - u32 writen=0; - u32 writen_start=0; + MOV32ItoR(EDX, pgsz / 4); - u32 lpc=inpage_ptr; - u32 stg=pgsz; + u32 index = (psM - vtlbdata.alloc_base + inpage_ptr) / 16 / 32; // 16 bytes per bit, 32 bits per dword. + u32 mask = 0; - while(stg>0) - { - u32 bit = (lpc>>4) & 7; - if (mask==0) + u32 start = inpage_ptr & ~15; + u32 end = inpage_ptr + pgsz; + for (u32 pos = start, bit = (start / 16) % 32; pos < end; pos += 16, bit++) { + if( bit == 32 ) { - //writen=bit; - writen_start=(((u8*)PSM(lpc)-vtlbdata.alloc_base)>>4)/8; + xTEST(ptr32[&vtlbdata.alloc_bits[index]], mask); + xJNZ(dyna_block_discard); + bit = 0; + mask = 0; + index++; } mask |= 1 << bit; - - if (bit==31) - { - vtlbdata.alloc_bits[writen_start]&=~mask; - xTEST( ptr32[&vtlbdata.alloc_bits[writen_start]], mask ); // auto-optimizes to imm8 when applicable. - xJNZ( dyna_block_discard ); - //SysPrintf("%08X %d %d\n",mask,pgsz,pgsz>>4); - mask = 0; - } - - //writen++; - - if (stg<=16) - { - lpc += stg; - stg = 0; - } - else - { - lpc += 16; - stg -= 16; - } } + xTEST(ptr32[&vtlbdata.alloc_bits[index]], mask); + xJNZ(dyna_block_discard); - if (mask) + if (manual_counter[inpage_ptr >> 12] <= 4) { - vtlbdata.alloc_bits[writen_start] &= ~mask; - xTEST( ptr32[&vtlbdata.alloc_bits[writen_start]], mask ); // auto-optimizes to imm8 when applicable. - xJNZ( dyna_block_discard ); - //SysPrintf("%08X %d %d\n",mask,pgsz,pgsz>>4); - mask = 0; - } - - if( startpc != 0x81fc0 && manual_counter[inpage_ptr >> 12] <= 4 ) - { - // Commented out until we replace it with a smarter algo that only - // recompiles blocks a limited number of times. - xADD(ptr16[&manual_page[inpage_ptr >> 12]], 1); xJC( dyna_page_reset ); } diff --git a/pcsx2/x86/ix86-32/recVTLB.cpp b/pcsx2/x86/ix86-32/recVTLB.cpp index a7ef079687..240ee78ab1 100644 --- a/pcsx2/x86/ix86-32/recVTLB.cpp +++ b/pcsx2/x86/ix86-32/recVTLB.cpp @@ -430,7 +430,7 @@ static void _vtlb_DynGen_DirectWrite( u32 bits ) u8* bits_base = vtlbdata.alloc_bits; bits_base -= (alloc_base>>4)/8; //in bytes - xBTS( ecx, bits_base ); + xBTS( ptr32[bits_base], ecx ); } // ------------------------------------------------------------------------ diff --git a/pcsx2/x86/ix86/implement/test.h b/pcsx2/x86/ix86/implement/test.h index 196c3cbba0..4771d6ecf5 100644 --- a/pcsx2/x86/ix86/implement/test.h +++ b/pcsx2/x86/ix86/implement/test.h @@ -96,15 +96,23 @@ public: // Bit Test Instructions - Valid on 16/32 bit instructions only. // template< G8Type InstType > -class xImpl_Group8 : public xImpl_BitScan<0xa3 | (InstType << 2)> +class xImpl_Group8 { + static const uint RegFormOp = 0xa3 | (InstType << 3); public: - using xImpl_BitScan<0xa3 | (InstType << 2)>::operator(); + __forceinline void operator()( const xRegister32& bitbase, const xRegister32& bitoffset ) const { xOpWrite0F( RegFormOp, bitbase, bitoffset ); } + __forceinline void operator()( const xRegister16& bitbase, const xRegister16& bitoffset ) const { xOpWrite0F( 0x66, RegFormOp, bitbase, bitoffset ); } + __forceinline void operator()( const ModSibBase& bitbase, const xRegister32& bitoffset ) const { xOpWrite0F( RegFormOp, bitoffset, bitbase ); } + __forceinline void operator()( const ModSibBase& bitbase, const xRegister16& bitoffset ) const { xOpWrite0F( 0x66, RegFormOp, bitoffset, bitbase ); } + __forceinline void operator()( const void* bitbase, const xRegister32& bitoffset ) const { xOpWrite0F( 0xab, bitoffset, bitbase ); } + __forceinline void operator()( const void* bitbase, const xRegister16& bitoffset ) const { xOpWrite0F( 0x66, RegFormOp, bitoffset, bitbase ); } - __forceinline void operator()( const ModSibStrict& bitbase, u8 bitoffset ) const { xOpWrite0F( 0xba, InstType, bitbase, bitoffset ); } - __forceinline void operator()( const ModSibStrict& bitbase, u8 bitoffset ) const { xOpWrite0F( 0x66, 0xba, InstType, bitbase, bitoffset ); } - void operator()( const xRegister& bitbase, u8 bitoffset ) const { xOpWrite0F( 0xba, InstType, bitbase, bitoffset ); } - void operator()( const xRegister& bitbase, u8 bitoffset ) const { xOpWrite0F( 0x66, 0xba, InstType, bitbase, bitoffset ); } + __forceinline void operator()( const ModSibStrict& bitbase, u8 bitoffset ) const { xOpWrite0F( 0xba, InstType, bitbase, bitoffset ); } + __forceinline void operator()( const ModSibStrict& bitbase, u8 bitoffset ) const { xOpWrite0F( 0x66, 0xba, InstType, bitbase, bitoffset ); } + __forceinline void operator()( const u32* bitbase, u8 bitoffset ) const { xOpWrite0F( 0xba, InstType, bitbase, bitoffset ); } + __forceinline void operator()( const u16* bitbase, u8 bitoffset ) const { xOpWrite0F( 0x66, 0xba, InstType, bitbase, bitoffset ); } + __forceinline void operator()( const xRegister& bitbase, u8 bitoffset ) const { xOpWrite0F( 0xba, InstType, bitbase, bitoffset ); } + __forceinline void operator()( const xRegister& bitbase, u8 bitoffset ) const { xOpWrite0F( 0x66, 0xba, InstType, bitbase, bitoffset ); } xImpl_Group8() {} }; diff --git a/pcsx2/x86/ix86/ix86_tools.cpp b/pcsx2/x86/ix86/ix86_tools.cpp index f4abbb3231..bdc4208ac9 100644 --- a/pcsx2/x86/ix86/ix86_tools.cpp +++ b/pcsx2/x86/ix86/ix86_tools.cpp @@ -34,12 +34,12 @@ namespace x86Emitter { void xStoreReg( const xRegisterSSE& src ) { - xMOVDQA( &g_globalXMMData[src.Id], src ); + xMOVDQA( &g_globalXMMData[src.Id*2], src ); } void xRestoreReg( const xRegisterSSE& dest ) { - xMOVDQA( dest, &g_globalXMMData[dest.Id] ); + xMOVDQA( dest, &g_globalXMMData[dest.Id*2] ); } } From 7dfc4c9ea2bfe40943b64c4d551964d3cf2b62c8 Mon Sep 17 00:00:00 2001 From: refraction Date: Wed, 29 Apr 2009 21:50:48 +0000 Subject: [PATCH 18/41] Some unpack fixes/changes git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1090 96395faa-99c1-11dd-bbfe-3dabce05a288 --- pcsx2/VifDma.cpp | 135 ++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 109 insertions(+), 26 deletions(-) diff --git a/pcsx2/VifDma.cpp b/pcsx2/VifDma.cpp index 7452378f4f..8ac5b9798a 100644 --- a/pcsx2/VifDma.cpp +++ b/pcsx2/VifDma.cpp @@ -295,7 +295,7 @@ static void ProcessMemSkip(int size, unsigned int unpackType, const unsigned int break; case 0xC: vif->tag.addr += size; - VIFUNPACK_LOG("Processing V4-32 skip, size = %d, CL = %d, WL = %d", size, vif1Regs->cycle.cl, vif1Regs->cycle.wl); + VIFUNPACK_LOG("Processing V4-32 skip, size = %d, CL = %d, WL = %d", size, vifRegs->cycle.cl, vifRegs->cycle.wl); break; case 0xD: vif->tag.addr += (size / unpack->gsize) * 16; @@ -350,12 +350,18 @@ static int VIFalign(u32 *data, vifCode *v, unsigned int size, const unsigned int { VU = &VU0; vifRegs = vif0Regs; + vifMaskRegs = g_vif0Masks; + vif = &vif0; + vifRow = g_vifRow0; assert(v->addr < memsize); } else { VU = &VU1; vifRegs = vif1Regs; + vifMaskRegs = g_vif1Masks; + vif = &vif1; + vifRow = g_vifRow1; assert(v->addr < memsize); } @@ -376,7 +382,7 @@ static int VIFalign(u32 *data, vifCode *v, unsigned int size, const unsigned int memsize = size; #endif - if(vif1Regs->offset != 0) + if(vifRegs->offset != 0) { int unpacksize; @@ -411,29 +417,46 @@ static int VIFalign(u32 *data, vifCode *v, unsigned int size, const unsigned int if (vifRegs->cycle.cl != vifRegs->cycle.wl) { vif->tag.addr += (((vifRegs->cycle.cl - vifRegs->cycle.wl) << 2) + ((4 - ft->qsize) + unpacksize)) * 4; - //dest += ((vifRegs->cycle.cl - vifRegs->cycle.wl) << 2) + destinc; + dest += ((vifRegs->cycle.cl - vifRegs->cycle.wl) << 2) + (4 - ft->qsize) + unpacksize; + if(vif->tag.addr >= (u32)(VIFdmanum ? 0x4000 : 0x1000)) + { + vif->tag.addr &= (u32)(VIFdmanum ? 0x3fff : 0xfff); + dest = (u32*)(VU->Mem + v->addr); + } } else { vif->tag.addr += ((4 - ft->qsize) + unpacksize) * 4; - //dest += destinc; + dest += (4 - ft->qsize) + unpacksize; + if(vif->tag.addr >= (u32)(VIFdmanum ? 0x4000 : 0x1000)) + { + vif->tag.addr &= (u32)(VIFdmanum ? 0x3fff : 0xfff); + dest = (u32*)(VU->Mem + v->addr); + } + } + cdata += unpacksize * ft->dsize; vif->cl = 0; VIFUNPACK_LOG("Aligning packet done size = %d offset %d addr %x", size, vifRegs->offset, vif->tag.addr); - return size >> 2; + if((size & 0xf) == 0)return size >> 2; } else { vif->tag.addr += ((4 - ft->qsize) + unpacksize) * 4; dest += (4 - ft->qsize) + unpacksize; + if(vif->tag.addr >= (u32)(VIFdmanum ? 0x4000 : 0x1000)) + { + vif->tag.addr &= (u32)(VIFdmanum ? 0x3fff : 0xfff); + dest = (u32*)(VU->Mem + v->addr); + } cdata += unpacksize * ft->dsize; VIFUNPACK_LOG("Aligning packet done size = %d offset %d addr %x", size, vifRegs->offset, vif->tag.addr); } } - if (vif->cl != 0) //Check alignment for SSE unpacks + if (vif->cl != 0 || (size & 0xf)) //Check alignment for SSE unpacks { #ifdef _DEBUG @@ -444,8 +467,13 @@ static int VIFalign(u32 *data, vifCode *v, unsigned int size, const unsigned int if (vifRegs->cycle.cl >= vifRegs->cycle.wl) // skipping write { + if(vif->tag.addr >= (u32)(VIFdmanum ? 0x4000 : 0x1000)) + { + vif->tag.addr &= (u32)(VIFdmanum ? 0x3fff : 0xfff); + dest = (u32*)(VU->Mem + v->addr); + } // continuation from last stream - + VIFUNPACK_LOG("Continuing last stream size = %d offset %d addr %x", size, vifRegs->offset, vif->tag.addr); incdest = ((vifRegs->cycle.cl - vifRegs->cycle.wl) << 2) + 4; while ((size >= ft->gsize) && (vifRegs->num > 0)) @@ -460,12 +488,20 @@ static int VIFalign(u32 *data, vifCode *v, unsigned int size, const unsigned int { dest += incdest; vif->tag.addr += incdest * 4; + vif->cl = 0; - break; + if((size & 0xf) == 0)break; + } + else + { + dest += 4; + vif->tag.addr += 16; + } + if(vif->tag.addr >= (u32)(VIFdmanum ? 0x4000 : 0x1000)) + { + vif->tag.addr &= (u32)(VIFdmanum ? 0x3fff : 0xfff); + dest = (u32*)(VU->Mem + v->addr); } - - dest += 4; - vif->tag.addr += 16; } if(vifRegs->mode == 2) @@ -479,6 +515,32 @@ static int VIFalign(u32 *data, vifCode *v, unsigned int size, const unsigned int } } + if (size >= ft->dsize && vifRegs->num > 0 && ((size & 0xf) != 0 || vif->cl != 0)) + { + //VIF_LOG("warning, end with size = %d", size); + /* unpack one qword */ + if(vif->tag.addr + ((size / ft->dsize) * 4) >= (u32)(VIFdmanum ? 0x4000 : 0x1000)) + { + //DevCon::Notice("Overflow"); + vif->tag.addr &= (u32)(VIFdmanum ? 0x3fff : 0xfff); + dest = (u32*)(VU->Mem + v->addr); + } + + vif->tag.addr += (size / ft->dsize) * 4; + + func(dest, (u32*)cdata, size / ft->dsize); + size = 0; + + if(vifRegs->mode == 2) + { + //Update the reg rows for SSE + vifRow[0] = vifRegs->r0; + vifRow[1] = vifRegs->r1; + vifRow[2] = vifRegs->r2; + vifRow[3] = vifRegs->r3; + } + VIFUNPACK_LOG("leftover done, size %d, vifnum %d, addr %x", size, vifRegs->num, vif->tag.addr); + } } return size>>2; } @@ -504,6 +566,9 @@ static void VIFunpack(u32 *data, vifCode *v, unsigned int size, const unsigned i { VU = &VU0; vifRegs = vif0Regs; + vifMaskRegs = g_vif0Masks; + vif = &vif0; + vifRow = g_vifRow0; assert(v->addr < memsize); } else @@ -511,6 +576,9 @@ static void VIFunpack(u32 *data, vifCode *v, unsigned int size, const unsigned i VU = &VU1; vifRegs = vif1Regs; + vifMaskRegs = g_vif1Masks; + vif = &vif1; + vifRow = g_vifRow1; assert(v->addr < memsize); if (vu1MicroIsSkipping()) @@ -548,9 +616,16 @@ static void VIFunpack(u32 *data, vifCode *v, unsigned int size, const unsigned i #ifdef _DEBUG static int s_count = 0; #endif + if(v->addr >= (u32)(VIFdmanum ? 0x4000 : 0x1000)) + { + //DevCon::Notice("Overflown at the start"); + v->addr &= (u32)(VIFdmanum ? 0x3fff : 0xfff); + dest = (u32*)(VU->Mem + v->addr); + } + tempsize = min(vifRegs->num, (size / ft->gsize)); tempsize = (vif->tag.addr + (size / (ft->gsize * vifRegs->cycle.wl)) * - ((vifRegs->cycle.cl - vifRegs->cycle.wl) * 16)) + ((size / ft->gsize) * 16); + ((vifRegs->cycle.cl - vifRegs->cycle.wl) * 16)) + (tempsize * 16); //Sanity Check (memory overflow) if(tempsize > (u32)(VIFdmanum ? 0x4000 : 0x1000)) @@ -671,11 +746,18 @@ static void VIFunpack(u32 *data, vifCode *v, unsigned int size, const unsigned i { int incdest = ((vifRegs->cycle.cl - vifRegs->cycle.wl) << 2) + 4; size = 0; + if((tempsize >> 2) != vif->tag.size) DevCon::Notice("split when size != tagsize"); - + VIFUNPACK_LOG("sorting tempsize :p, size %d, vifnum %d, addr %x", tempsize, vifRegs->num, vif->tag.addr); + while ((tempsize >= ft->gsize) && (vifRegs->num > 0)) { - //VIFUNPACK_LOG("sorting tempsize :p, size %d, vifnum %d, addr %x", tempsize, vifRegs->num, vif->tag.addr); + if(v->addr >= (u32)(VIFdmanum ? 0x4000 : 0x1000)) + { + v->addr &= (u32)(VIFdmanum ? 0x3fff : 0xfff); + dest = (u32*)(VU->Mem + v->addr); + } + func(dest, (u32*)cdata, ft->qsize); cdata += ft->gsize; tempsize -= ft->gsize; @@ -685,15 +767,13 @@ static void VIFunpack(u32 *data, vifCode *v, unsigned int size, const unsigned i if (vif->cl == vifRegs->cycle.wl) { dest += incdest; - v->addr = (v->addr + (incdest * 4)) & (VIFdmanum ? 0x3fff : 0xfff); - if(v->addr <= (u32)(VIFdmanum ? 0x3000 : 0x500)) dest = (u32*)(VU->Mem + v->addr); + v->addr += (incdest * 4); vif->cl = 0; } else { dest += 4; - v->addr = (v->addr + 16) & (VIFdmanum ? 0x3fff : 0xfff); - if(v->addr <= (u32)(VIFdmanum ? 0x3000 : 0x500)) dest = (u32*)(VU->Mem + v->addr); + v->addr += 16; } } @@ -705,6 +785,11 @@ static void VIFunpack(u32 *data, vifCode *v, unsigned int size, const unsigned i vifRow[2] = vifRegs->r2; vifRow[3] = vifRegs->r3; } + if(v->addr >= (u32)(VIFdmanum ? 0x4000 : 0x1000)) + { + v->addr &= (u32)(VIFdmanum ? 0x3fff : 0xfff); + dest = (u32*)(VU->Mem + v->addr); + } if(tempsize > 0) size = tempsize; } @@ -735,7 +820,7 @@ static void VIFunpack(u32 *data, vifCode *v, unsigned int size, const unsigned i if((u32)(((size / ft->gsize) / vifRegs->cycle.cl) * vifRegs->cycle.wl) < vifRegs->num) DevCon::Notice("Filling write warning! %x < %x and CL = %x WL = %x", params (size / ft->gsize), vifRegs->num, vifRegs->cycle.cl, vifRegs->cycle.wl); - VIFUNPACK_LOG("filling write %d cl %d, wl %d mask %x mode %x unpacktype %x", vifRegs->num, vifRegs->cycle.cl, vifRegs->cycle.wl, vifRegs->mask, vifRegs->mode, unpackType); + DevCon::Notice("filling write %d cl %d, wl %d mask %x mode %x unpacktype %x addr %x", params vifRegs->num, vifRegs->cycle.cl, vifRegs->cycle.wl, vifRegs->mask, vifRegs->mode, unpackType, vif->tag.addr); while (vifRegs->num > 0) { if (vif->cl == vifRegs->cycle.wl) @@ -872,9 +957,7 @@ static __forceinline void vif0UNPACK(u32 *data) vif0.tag.size = len; vif0Regs->offset = 0; - vifMaskRegs = g_vif0Masks; - vif = &vif0; - vifRow = g_vifRow0; + } static __forceinline void vif0mpgTransfer(u32 addr, u32 *data, int size) @@ -983,6 +1066,7 @@ static int __fastcall Vif0TransMPG(u32 *data) // MPG { if (vif0.vifpacketsize < vif0.tag.size) { + if((vif0.tag.addr + vif0.vifpacketsize) > 0x1000) DevCon::Notice("Vif0 MPG Split Overflow"); vif0mpgTransfer(vif0.tag.addr, data, vif0.vifpacketsize); vif0.tag.addr += vif0.vifpacketsize << 2; vif0.tag.size -= vif0.vifpacketsize; @@ -991,7 +1075,7 @@ static int __fastcall Vif0TransMPG(u32 *data) // MPG else { int ret; - + if((vif0.tag.addr + vif0.tag.size) > 0x1000) DevCon::Notice("Vif0 MPG Overflow"); vif0mpgTransfer(vif0.tag.addr, data, vif0.tag.size); ret = vif0.tag.size; vif0.tag.size = 0; @@ -1633,9 +1717,6 @@ static __forceinline void vif1UNPACK(u32 *data) vif1.tag.addr <<= 4; vif1.tag.cmd = vif1.cmd; - vifMaskRegs = g_vif1Masks; - vif = &vif1; - vifRow = g_vifRow1; } static __forceinline void vif1mpgTransfer(u32 addr, u32 *data, int size) @@ -1742,6 +1823,7 @@ static int __fastcall Vif1TransMPG(u32 *data) { if (vif1.vifpacketsize < vif1.tag.size) { + if((vif1.tag.addr + vif1.vifpacketsize) > 0x4000) DevCon::Notice("Vif1 MPG Split Overflow"); vif1mpgTransfer(vif1.tag.addr, data, vif1.vifpacketsize); vif1.tag.addr += vif1.vifpacketsize << 2; vif1.tag.size -= vif1.vifpacketsize; @@ -1750,6 +1832,7 @@ static int __fastcall Vif1TransMPG(u32 *data) else { int ret; + if((vif1.tag.addr + vif1.tag.size) > 0x4000) DevCon::Notice("Vif1 MPG Overflow"); vif1mpgTransfer(vif1.tag.addr, data, vif1.tag.size); ret = vif1.tag.size; vif1.tag.size = 0; From 9513be5476b49e403213e26b85a9e6217e9b9895 Mon Sep 17 00:00:00 2001 From: "Jake.Stine" Date: Thu, 30 Apr 2009 01:16:25 +0000 Subject: [PATCH 19/41] Reverted BTS due to unexpected complications, but retained a minor optimization we developed during the BTS experiment. :) git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1091 96395faa-99c1-11dd-bbfe-3dabce05a288 --- pcsx2/SPR.cpp | 4 -- pcsx2/vtlb.cpp | 14 ------- pcsx2/vtlb.h | 2 - pcsx2/x86/BaseblockEx.h | 22 +++++++--- pcsx2/x86/ix86-32/iR5900-32.cpp | 72 ++++++++++++++++----------------- pcsx2/x86/ix86-32/recVTLB.cpp | 8 ---- 6 files changed, 51 insertions(+), 71 deletions(-) diff --git a/pcsx2/SPR.cpp b/pcsx2/SPR.cpp index 8166ba3ba4..5c5291fad0 100644 --- a/pcsx2/SPR.cpp +++ b/pcsx2/SPR.cpp @@ -76,9 +76,6 @@ int _SPR0chain() { memcpy_fast((u8*)pMem, &PS2MEM_SCRATCH[spr0->sadr & 0x3fff], spr0->qwc << 4); - // Clear dependent EE recompiler blocks, if necessary [needed for BTS protection system] - Cpu->Clear( spr0->madr, spr0->qwc << 2 ); - // clear VU mem also! TestClearVUs(spr0->madr, spr0->qwc << 2); // Wtf is going on here? AFAIK, only VIF should affect VU micromem (cottonvibes) @@ -124,7 +121,6 @@ void _SPR0interleave() { // clear VU mem also! TestClearVUs(spr0->madr, spr0->qwc << 2); - Cpu->Clear( spr0->madr, spr0->qwc << 2 ); memcpy_fast((u8*)pMem, &PS2MEM_SCRATCH[spr0->sadr & 0x3fff], spr0->qwc << 4); } spr0->sadr += spr0->qwc * 16; diff --git a/pcsx2/vtlb.cpp b/pcsx2/vtlb.cpp index 058f1dcbed..2a016c61bf 100644 --- a/pcsx2/vtlb.cpp +++ b/pcsx2/vtlb.cpp @@ -90,18 +90,6 @@ callfunction: // Interpreter Implementations of VTLB Memory Operations. // See recVTLB.cpp for the dynarec versions. -// ------------------------------------------------------------------------ -// Helper for the BTS manual protection system. Sets a bit based on the given address, -// marking that piece of PS2 memory as 'dirty.' -// -static void memwritebits(u8* ptr) -{ - u32 offs=ptr-vtlbdata.alloc_base; - offs/=16; - vtlbdata.alloc_bits[offs/8] |= 1 << (offs%8); -} - -// ------------------------------------------------------------------------ // Interpreted VTLB lookup for 8, 16, and 32 bit accesses template __forceinline DataType __fastcall MemOp_r0(u32 addr) @@ -168,7 +156,6 @@ __forceinline void __fastcall MemOp_w0(u32 addr, DataType data) s32 ppf=addr+vmv; if (!(ppf<0)) { - memwritebits((u8*)ppf); *reinterpret_cast(ppf)=data; } else @@ -198,7 +185,6 @@ __forceinline void __fastcall MemOp_w1(u32 addr,const DataType* data) s32 ppf=addr+vmv; if (!(ppf<0)) { - memwritebits((u8*)ppf); *reinterpret_cast(ppf)=*data; if (DataSize==128) *reinterpret_cast(ppf+8)=data[1]; diff --git a/pcsx2/vtlb.h b/pcsx2/vtlb.h index 0eaaf5d90e..b1674fc79d 100644 --- a/pcsx2/vtlb.h +++ b/pcsx2/vtlb.h @@ -81,8 +81,6 @@ namespace vtlb_private struct MapData { - u8 alloc_bits[VTLB_ALLOC_SIZE/16/8]; - u8* alloc_base; //base of the memory array int alloc_current; //current base diff --git a/pcsx2/x86/BaseblockEx.h b/pcsx2/x86/BaseblockEx.h index 6ef0261451..fa38d61891 100644 --- a/pcsx2/x86/BaseblockEx.h +++ b/pcsx2/x86/BaseblockEx.h @@ -70,7 +70,7 @@ public: int LastIndex (u32 startpc) const; BASEBLOCKEX* GetByX86(uptr ip); - inline int Index (u32 startpc) const + __forceinline int Index (u32 startpc) const { int idx = LastIndex(startpc); // fixme: I changed the parenthesis to be unambiguous, but this needs to be checked to see if ((x or y or z) and w) @@ -83,31 +83,43 @@ public: return idx; } - inline BASEBLOCKEX* operator[](int idx) + __forceinline BASEBLOCKEX* operator[](int idx) { if (idx < 0 || idx >= (int)blocks.size()) return 0; return &blocks[idx]; } - inline BASEBLOCKEX* Get(u32 startpc) + __forceinline BASEBLOCKEX* Get(u32 startpc) { return (*this)[Index(startpc)]; } - inline void Remove(int idx) + __forceinline void Remove(int idx) { //u32 startpc = blocks[idx].startpc; std::pair range = links.equal_range(blocks[idx].startpc); for (linkiter_t i = range.first; i != range.second; ++i) *(u32*)i->second = recompiler - (i->second + 4); + + if( IsDevBuild ) + { + // Clear the first instruction to 0xcc (breakpoint), as a way to assert if some + // static jumps get left behind to this block. Note: Do not clear more than the + // first byte, since this code is called during exception handlers and event handlers + // both of which expect to be able to return to the recompiled code. + + BASEBLOCKEX effu( blocks[idx] ); + memset( (void*)effu.fnptr, 0xcc, 1 ); + } + // TODO: remove links from this block? blocks.erase(blocks.begin() + idx); } void Link(u32 pc, uptr jumpptr); - inline void Reset() + __forceinline void Reset() { blocks.clear(); links.clear(); diff --git a/pcsx2/x86/ix86-32/iR5900-32.cpp b/pcsx2/x86/ix86-32/iR5900-32.cpp index ae3ce24403..d6b67e39c0 100644 --- a/pcsx2/x86/ix86-32/iR5900-32.cpp +++ b/pcsx2/x86/ix86-32/iR5900-32.cpp @@ -751,13 +751,6 @@ void recClear(u32 addr, u32 size) return; addr = HWADDR(addr); - addr -= addr % 16; // round down. - size += 3; // round up! - size -= size % 4; - - for (u32 a = addr / 16; a < addr / 16 + size / 4; a++) - vtlb_private::vtlbdata.alloc_bits[a / 8] &= ~(1 << (a & 7)); - int blockidx = recBlocks.LastIndex(addr + size * 4 - 4); if (blockidx == -1) @@ -1274,7 +1267,7 @@ void __fastcall dyna_block_discard(u32 start,u32 sz) void __fastcall dyna_page_reset(u32 start,u32 sz) { - DevCon::WriteLn("dyna_page_reset .. start=%08X count=%d", params start,sz); + DevCon::WriteLn("dyna_page_reset .. start=%08X size=%d", params start,sz*4); Cpu->Clear(start & ~0xfffUL, 0x400); manual_counter[start >> 12]++; mmap_MarkCountedRamPage(PSM(start), start & ~0xfffUL); @@ -1532,10 +1525,10 @@ StartRecomp: iDumpBlock(startpc, recPtr); #endif - u32 sz=(s_nEndBlock-startpc)>>2; + u32 sz = (s_nEndBlock-startpc)>>2; - u32 inpage_ptr=HWADDR(startpc); - u32 inpage_sz=sz*4; + u32 inpage_ptr = HWADDR(startpc); + u32 inpage_sz = sz*4; while(inpage_sz) { @@ -1551,38 +1544,41 @@ StartRecomp: } else { - using namespace vtlb_private; - - MOV32ItoR(ECX, inpage_ptr); - MOV32ItoR(EDX, pgsz / 4); - - u32 index = (psM - vtlbdata.alloc_base + inpage_ptr) / 16 / 32; // 16 bytes per bit, 32 bits per dword. - u32 mask = 0; - - u32 start = inpage_ptr & ~15; - u32 end = inpage_ptr + pgsz; - for (u32 pos = start, bit = (start / 16) % 32; pos < end; pos += 16, bit++) { - if( bit == 32 ) - { - xTEST(ptr32[&vtlbdata.alloc_bits[index]], mask); - xJNZ(dyna_block_discard); - bit = 0; - mask = 0; - index++; - } - mask |= 1 << bit; - } - xTEST(ptr32[&vtlbdata.alloc_bits[index]], mask); - xJNZ(dyna_block_discard); - - if (manual_counter[inpage_ptr >> 12] <= 4) + xMOV( ecx, inpage_ptr ); + xMOV( edx, pgsz / 4 ); + //xMOV( eax, startpc ); // uncomment this to access startpc (as eax) in dyna_block_discard + + u32 lpc = inpage_ptr; + u32 stg = pgsz; + while(stg>0) { + xCMP( ptr32[PSM(lpc)], *(u32*)PSM(lpc) ); + xJNE( dyna_block_discard ); + + stg -= 4; + lpc += 4; + } + + if (startpc != 0x81fc0 && manual_counter[inpage_ptr >> 12] <= 4) { xADD(ptr16[&manual_page[inpage_ptr >> 12]], 1); xJC( dyna_page_reset ); + + // KH2 manual_counter failure -- during the intro vid a block which overlaps + // two pages causes constant recompilation. The block is very large and has two entry + // points, one around 0x01f1de1c and one around 0x01f1dfac (varies on locale). The + // former is the one that's not being cleared correctly [or at least behaves as though + // it's not being cleared correctly]. + + // note: clearcnt is measured per-page, not per-block! + DbgCon::WriteLn( "Manual block @ %08X : size=%3d page/offs=%05X/%03X inpgsz=%d clearcnt=%d", + params startpc, sz, inpage_ptr>>12, inpage_offs, inpage_sz, manual_counter[inpage_ptr >> 12] ); + } + else + { + DbgCon::WriteLn( "Uncounted Manual block @ %08X : size=%3d page/offs=%05X/%03X inpgsz=%d", + params startpc, sz, inpage_ptr>>12, inpage_offs, pgsz, inpage_sz ); } - DbgCon::WriteLn("Manual block @ %08X : %08X %d %d %d %d", params - startpc,inpage_ptr,pgsz,0x1000-inpage_offs,inpage_sz,sz*4); } } inpage_ptr += pgsz; diff --git a/pcsx2/x86/ix86-32/recVTLB.cpp b/pcsx2/x86/ix86-32/recVTLB.cpp index 240ee78ab1..b4ff537b44 100644 --- a/pcsx2/x86/ix86-32/recVTLB.cpp +++ b/pcsx2/x86/ix86-32/recVTLB.cpp @@ -423,14 +423,6 @@ static void _vtlb_DynGen_DirectWrite( u32 bits ) iMOV128_SSE(ptr[ecx],ptr[edx]); break; } - - xSHR( ecx, 4 ); - - uptr alloc_base = (uptr)vtlbdata.alloc_base; - u8* bits_base = vtlbdata.alloc_bits; - bits_base -= (alloc_base>>4)/8; //in bytes - - xBTS( ptr32[bits_base], ecx ); } // ------------------------------------------------------------------------ From 3af9acc01d1f4cf2f7dc8e462b30fdfb55baf059 Mon Sep 17 00:00:00 2001 From: "Jake.Stine" Date: Thu, 30 Apr 2009 01:32:39 +0000 Subject: [PATCH 20/41] Darned fungly header file dependencies, broke compilation in dev/release builds. >_< git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1092 96395faa-99c1-11dd-bbfe-3dabce05a288 --- pcsx2/PrecompiledHeader.h | 15 +++++++++++++++ pcsx2/System.h | 15 ++------------- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/pcsx2/PrecompiledHeader.h b/pcsx2/PrecompiledHeader.h index b299dfb724..3156cd4058 100644 --- a/pcsx2/PrecompiledHeader.h +++ b/pcsx2/PrecompiledHeader.h @@ -158,3 +158,18 @@ static __forceinline u32 timeGetTime() # define __releaseinline __forceinline #endif +////////////////////////////////////////////////////////////////////////////////////////// +// Dev / Debug conditionals -- +// Consts for using if() statements instead of uglier #ifdef macros. + +#ifdef PCSX2_DEVBUILD +static const bool IsDevBuild = true; +#else +static const bool IsDevBuild = false; +#endif + +#ifdef _DEBUG +static const bool IsDebugBuild = true; +#else +static const bool IsDebugBuild = false; +#endif diff --git a/pcsx2/System.h b/pcsx2/System.h index 41208581f7..8447b8499f 100644 --- a/pcsx2/System.h +++ b/pcsx2/System.h @@ -210,35 +210,24 @@ using Console::Color_Cyan; using Console::Color_Yellow; using Console::Color_White; -////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////////////////// // Dev / Debug conditionals -- // Consts for using if() statements instead of uglier #ifdef macros. // Abbreviated macros for dev/debug only consoles and msgboxes. #ifdef PCSX2_DEVBUILD - # define DevCon Console # define DevMsg MsgBox - static const bool IsDevBuild = true; - #else - # define DevCon 0&&Console # define DevMsg - static const bool IsDevBuild = false; - #endif #ifdef _DEBUG - # define DbgCon Console - static const bool IsDebugBuild = true; - #else - # define DbgCon 0&&Console - static const bool IsDebugBuild = false; - #endif #endif /* __SYSTEM_H__ */ From d14259b8b4282d366ff6080f84238f157e7c8aa5 Mon Sep 17 00:00:00 2001 From: "Jake.Stine" Date: Thu, 30 Apr 2009 08:33:51 +0000 Subject: [PATCH 21/41] *experimental* Added forced block splitting at 4k code boundaries in PS2 memory. This fixes issues with frequent recompilation of certain uncounted manual blocks, and also allows for us to greatly simplify the memory protection and recompiler block management code, but *may* have performance penalties under specific conditions. So I've added a verbose log message to Devel builds so that we can look for any problem games that might invoke more than their fair share of tiny block splits. git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1093 96395faa-99c1-11dd-bbfe-3dabce05a288 --- pcsx2/x86/ix86-32/iR5900-32.cpp | 175 ++++++++++++++++++-------------- 1 file changed, 96 insertions(+), 79 deletions(-) diff --git a/pcsx2/x86/ix86-32/iR5900-32.cpp b/pcsx2/x86/ix86-32/iR5900-32.cpp index d6b67e39c0..d93c425de6 100644 --- a/pcsx2/x86/ix86-32/iR5900-32.cpp +++ b/pcsx2/x86/ix86-32/iR5900-32.cpp @@ -1090,10 +1090,8 @@ void recompileNextInstruction(int delayslot) s_pCode = (int *)PSM( pc ); assert(s_pCode); - // why? -#ifdef _DEBUG - MOV32ItoR(EAX, pc); -#endif + if( IsDebugBuild ) + MOV32ItoR(EAX, pc); // acts as a tag for delimiting recompiled instructions when viewing x86 disasm. cpuRegs.code = *(int *)s_pCode; pc += 4; @@ -1142,63 +1140,33 @@ void recompileNextInstruction(int delayslot) const OPCODE& opcode = GetCurrentInstruction(); - // peephole optimizations -#ifdef PCSX2_VM_COISSUE - if( g_pCurInstInfo->info & EEINSTINFO_COREC ) { + //assert( !(g_pCurInstInfo->info & EEINSTINFO_NOREC) ); - if( g_pCurInstInfo->numpeeps > 1 ) { - switch(_Opcode_) { - case 30: recLQ_coX(g_pCurInstInfo->numpeeps); break; - case 31: recSQ_coX(g_pCurInstInfo->numpeeps); break; - case 49: recLWC1_coX(g_pCurInstInfo->numpeeps); break; - case 57: recSWC1_coX(g_pCurInstInfo->numpeeps); break; - case 55: recLD_coX(g_pCurInstInfo->numpeeps); break; - case 63: recSD_coX(g_pCurInstInfo->numpeeps, 1); break; //not sure if should be set to 1 or 0; looks like "1" handles alignment, so i'm going with that for now + // if this instruction is a jump or a branch, exit right away + if( delayslot ) { + switch(_Opcode_) { + case 1: + switch(_Rt_) { + case 0: case 1: case 2: case 3: case 0x10: case 0x11: case 0x12: case 0x13: + Console::Notice("branch %x in delay slot!", params cpuRegs.code); + _clearNeededX86regs(); + _clearNeededMMXregs(); + _clearNeededXMMregs(); + return; + } + break; - jNO_DEFAULT - } - pc += g_pCurInstInfo->numpeeps*4; - s_nBlockCycles += (g_pCurInstInfo->numpeeps+1) * opcode.cycles; - g_pCurInstInfo += g_pCurInstInfo->numpeeps; - } - else { - recBSC_co[_Opcode_](); - pc += 4; - g_pCurInstInfo++; - s_nBlockCycles += opcode.cycles*2; + case 2: case 3: case 4: case 5: case 6: case 7: case 0x14: case 0x15: case 0x16: case 0x17: + Console::Notice("branch %x in delay slot!", params cpuRegs.code); + _clearNeededX86regs(); + _clearNeededMMXregs(); + _clearNeededXMMregs(); + return; } } - else -#endif - { - //assert( !(g_pCurInstInfo->info & EEINSTINFO_NOREC) ); - - // if this instruction is a jump or a branch, exit right away - if( delayslot ) { - switch(_Opcode_) { - case 1: - switch(_Rt_) { - case 0: case 1: case 2: case 3: case 0x10: case 0x11: case 0x12: case 0x13: - Console::Notice("branch %x in delay slot!", params cpuRegs.code); - _clearNeededX86regs(); - _clearNeededMMXregs(); - _clearNeededXMMregs(); - return; - } - break; - - case 2: case 3: case 4: case 5: case 6: case 7: case 0x14: case 0x15: case 0x16: case 0x17: - Console::Notice("branch %x in delay slot!", params cpuRegs.code); - _clearNeededX86regs(); - _clearNeededMMXregs(); - _clearNeededXMMregs(); - return; - } - } - //If thh COP0 DIE bit is disabled, double the cycles. Happens rarely. - s_nBlockCycles += opcode.cycles * (2 - ((cpuRegs.CP0.n.Config >> 18) & 0x1)); - opcode.recompile(); - } + //If thh COP0 DIE bit is disabled, double the cycles. Happens rarely. + s_nBlockCycles += opcode.cycles * (2 - ((cpuRegs.CP0.n.Config >> 18) & 0x1)); + opcode.recompile(); if( !delayslot ) { if( s_bFlushReg ) { @@ -1358,25 +1326,41 @@ void recRecompile( const u32 startpc ) while(1) { BASEBLOCK* pblock = PC_GETBLOCK(i); - if (i != startpc && pblock->GetFnptr() != (uptr)JITCompile && pblock->GetFnptr() != (uptr)JITCompileInBlock) { - // branch = 3 - willbranch3 = 1; - s_nEndBlock = i; - break; + + if(i != startpc) // Block size truncation checks. + { + if( (i & 0xffc) == 0x0 ) // breaks blocks at 4k page boundaries + { + willbranch3 = 1; + s_nEndBlock = i; + + // Log the pagesplits verbosely for now, until we see if any games are affected + // adversely by excessive splits. + DevCon::Notice( "Pagesplit @ %08X : size=%d insts", params startpc, (i-startpc) / 4 ); + + break; + } + + if (pblock->GetFnptr() != (uptr)JITCompile && pblock->GetFnptr() != (uptr)JITCompileInBlock) + { + willbranch3 = 1; + s_nEndBlock = i; + break; + } } + //HUH ? PSM ? whut ? THIS IS VIRTUAL ACCESS GOD DAMMIT cpuRegs.code = *(int *)PSM(i); switch(cpuRegs.code >> 26) { case 0: // special - if( _Funct_ == 8 || _Funct_ == 9 ) { // JR, JALR s_nEndBlock = i + 8; s_nHasDelay = 1; goto StartRecomp; } - break; + case 1: // regimm if( _Rt_ < 4 || (_Rt_ >= 16 && _Rt_ < 20) ) { @@ -1390,7 +1374,6 @@ void recRecompile( const u32 startpc ) goto StartRecomp; } - break; case 2: // J @@ -1525,8 +1508,11 @@ StartRecomp: iDumpBlock(startpc, recPtr); #endif - u32 sz = (s_nEndBlock-startpc)>>2; + // fixme! The following manual/protected block code can be greatly simplified now. + // It originally had to account for cross-page blocks, but we have since guaranteed + // that no block will cross a page boundary. + u32 sz = (s_nEndBlock-startpc) >> 2; u32 inpage_ptr = HWADDR(startpc); u32 inpage_sz = sz*4; @@ -1559,15 +1545,34 @@ StartRecomp: lpc += 4; } - if (startpc != 0x81fc0 && manual_counter[inpage_ptr >> 12] <= 4) { - xADD(ptr16[&manual_page[inpage_ptr >> 12]], 1); - xJC( dyna_page_reset ); + // Tweakpoint! 3 is a 'magic' number representing the number of times a counted block + // is re-protected before the recompiler gives up and sets it up as an uncounted (permanent) + // manual block. 4 definitely seemed too high, but 2 might be better? Side effects of a + // lower threshold: over extended gameplay with several map changes, a game's overall + // performance could degrade. - // KH2 manual_counter failure -- during the intro vid a block which overlaps - // two pages causes constant recompilation. The block is very large and has two entry - // points, one around 0x01f1de1c and one around 0x01f1dfac (varies on locale). The - // former is the one that's not being cleared correctly [or at least behaves as though - // it's not being cleared correctly]. + // (ideally, perhaps, manual_counter should be reset to 0 every few minutes?) + + if (startpc != 0x81fc0 && manual_counter[inpage_ptr >> 12] <= 3) { + + // Counted blocks add a weighted (by block size) value into manual_page each time they're + // run. If the block gets run a lot, it resets and re-protects itself in the hope + // that whatever forced it to be manually-checked before was a 1-time deal. + + // Counted blocks have a secondary threshold check in manual_counter, which forces a block + // to 'uncounted' mode if it's recompiled several time. This protects against excessive + // recompilation of blocks that reside on the same codepage as data. + + // fixme? Currently this algo is kinda dumb and results in the forced recompilation of a + // lot of blocks before it decides to mark a 'busy' page as uncounted. There might be + // be a more clever approach that could streamline this process, by doing a first-pass + // test using the vtlb memory protection (without recompilation!) to reprotect a counted + // block. But unless a new also is relatively simple in implementation, it's probably + // not worth the effort (tests show that we have lots of recompiler memory to spare, and + // that the current amount of recompilation is fairly cheap). + + xADD(ptr16[&manual_page[inpage_ptr >> 12]], sz); + xJC( dyna_page_reset ); // note: clearcnt is measured per-page, not per-block! DbgCon::WriteLn( "Manual block @ %08X : size=%3d page/offs=%05X/%03X inpgsz=%d clearcnt=%d", @@ -1575,7 +1580,7 @@ StartRecomp: } else { - DbgCon::WriteLn( "Uncounted Manual block @ %08X : size=%3d page/offs=%05X/%03X inpgsz=%d", + DbgCon::Notice( "Uncounted Manual block @ %08X : size=%3d page/offs=%05X/%03X inpgsz=%d", params startpc, sz, inpage_ptr>>12, inpage_offs, pgsz, inpage_sz ); } @@ -1584,11 +1589,11 @@ StartRecomp: inpage_ptr += pgsz; inpage_sz -= pgsz; } - - // finally recompile // + + // Finally: Generate x86 recompiled code! g_pCurInstInfo = s_pInstCache; while (!branch && pc < s_nEndBlock) { - recompileNextInstruction(0); + recompileNextInstruction(0); // For the love of recursion, batman! } #ifdef _DEBUG @@ -1653,8 +1658,20 @@ StartRecomp: ADD32ItoM((int)&cpuRegs.cycle, eeScaleBlockCycles() ); if( willbranch3 || !branch) { + iFlushCall(FLUSH_EVERYTHING); - iBranchTest(pc); + + // Split Block concatenation mode. + // This code is run when blocks are split either to keep block sizes manageable + // or because we're crossing a 4k page protection boundary in ps2 mem. The latter + // case can result in very short blocks which should not issue branch tests for + // performance reasons. + + int numinsts = (pc - startpc) / 4; + if( numinsts > 12 ) + iBranchTest(pc); + else + iBranch(pc,0); // unconditional static link } } From 1a1d51308c90859e27c0571306e549d4856e2ee6 Mon Sep 17 00:00:00 2001 From: "Jake.Stine" Date: Thu, 30 Apr 2009 21:28:54 +0000 Subject: [PATCH 22/41] Fixed a typo in the SIO2 hardware read interface: SIO2_getSend1 and getSend2 had inverted switch cases (probably been there for years). git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1094 96395faa-99c1-11dd-bbfe-3dabce05a288 --- pcsx2/IopHw.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pcsx2/IopHw.cpp b/pcsx2/IopHw.cpp index b973f43ac0..e23294911c 100644 --- a/pcsx2/IopHw.cpp +++ b/pcsx2/IopHw.cpp @@ -560,7 +560,7 @@ u32 psxHwRead32(u32 add) { case 0x1F808240: case 0x1F808248: case 0x1F808250: - case 0x1F80825C: + case 0x1F808258: hard=sio2_getSend1((add-0x1F808240)/8); PSXHW_LOG("SIO2 read send1[%d] (%lx)", (add-0x1F808240)/8, hard); return hard; @@ -568,7 +568,7 @@ u32 psxHwRead32(u32 add) { case 0x1F808244: case 0x1F80824C: case 0x1F808254: - case 0x1F808258: + case 0x1F80825C: hard=sio2_getSend2((add-0x1F808244)/8); PSXHW_LOG("SIO2 read send2[%d] (%lx)", (add-0x1F808244)/8, hard); return hard; From 5edb195282ff9dbb8d313c0e17c289628dfb8511 Mon Sep 17 00:00:00 2001 From: arcum42 Date: Fri, 1 May 2009 01:13:37 +0000 Subject: [PATCH 23/41] Committing various cleanups I'd put aside at one point or another... git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1095 96395faa-99c1-11dd-bbfe-3dabce05a288 --- pcsx2/CDVD.cpp | 398 ++++++++++++++++++------------------ pcsx2/Interpreter.cpp | 6 +- pcsx2/IopBios.cpp | 107 ++++++---- pcsx2/R3000AInterpreter.cpp | 85 ++++++-- pcsx2/configure.ac | 19 -- 5 files changed, 341 insertions(+), 274 deletions(-) diff --git a/pcsx2/CDVD.cpp b/pcsx2/CDVD.cpp index 0418ad4eff..683a150a42 100644 --- a/pcsx2/CDVD.cpp +++ b/pcsx2/CDVD.cpp @@ -79,6 +79,23 @@ enum cdvdActions , cdvdAction_Read // note: not used yet. }; +enum ncommands +{ + N_CD_SYNC = 0x00, // CdSync + N_CD_NOP = 0x01, // CdNop + N_CD_STANDBY = 0x02, // CdStandby + N_CD_STOP = 0x03, // CdStop + N_CD_PAUSE = 0x04, // CdPause + N_CD_SEEK = 0x05, // CdSeek + N_CD_READ = 0x06, // CdRead + N_CD_READ_CDDA = 0x07, // CdReadCDDA + N_DVD_READ = 0x08, // DvdRead + N_CD_GET_TOC = 0x09, // CdGetToc & cdvdman_call19 + N_CD_READ_KEY = 0x0C, // CdReadKey + N_CD_READ_XCDDA = 0x0E, // CdReadXCDDA + N_CD_CHG_SPDL_CTRL = 0x0F, // CdChgSpdlCtrl +}; + ////////////////////////////////////////////////////////////////////////////////////////// // Cdvd Block Read Cycle Timings // @@ -203,11 +220,18 @@ NVMLayout nvmlayouts[NVM_FORMAT_MAX] = #define btoi(b) ((b)/16*10 + (b)%16) /* BCD to u_char */ #define itob(i) ((i)/10*16 + (i)%10) /* u_char to BCD */ -#define SetResultSize(size) \ - cdvd.ResultC = size; cdvd.ResultP = 0; \ +__forceinline void SetResultSize(u8 size) +{ + cdvd.ResultC = size; + cdvd.ResultP = 0; cdvd.sDataIn&=~0x40; +} + +static void CDVDREAD_INT(int eCycle) +{ + PSX_INT(IopEvt_CdvdRead, eCycle); +} -#define CDVDREAD_INT(eCycle) PSX_INT(IopEvt_CdvdRead, eCycle) static void CDVD_INT(int eCycle) { if( eCycle == 0 ) @@ -226,10 +250,14 @@ static void cdvdSetIrq( uint id = (1<= (2048*1024)) { // dual sided - PSXMu8(HW_DMA3_MADR+ 0) = 0x24; - } else { - PSXMu8(HW_DMA3_MADR+ 0) = 0x04; - } - } else - if (type == CDVD_TYPE_PS2CD) { - PSXMu8(HW_DMA3_MADR+ 0) = 0x41; - } - - if (PSXMu8(HW_DMA3_MADR+ 0) & 0x04) { - PSXMu8(HW_DMA3_MADR+ 1) = 0x02; - PSXMu8(HW_DMA3_MADR+ 2) = 0xF2; - PSXMu8(HW_DMA3_MADR+ 3) = 0x00; - - if (PSXMu8(HW_DMA3_MADR+ 0) & 0x20) { - PSXMu8(HW_DMA3_MADR+ 4) = 0x41; - PSXMu8(HW_DMA3_MADR+ 5) = 0x95; - } else { - PSXMu8(HW_DMA3_MADR+ 4) = 0x86; - PSXMu8(HW_DMA3_MADR+ 5) = 0x72; - } - PSXMu8(HW_DMA3_MADR+ 6) = 0x00; - PSXMu8(HW_DMA3_MADR+ 7) = 0x00; - PSXMu8(HW_DMA3_MADR+ 8) = 0x00; - PSXMu8(HW_DMA3_MADR+ 9) = 0x00; - PSXMu8(HW_DMA3_MADR+10) = 0x00; - PSXMu8(HW_DMA3_MADR+11) = 0x00; - - PSXMu8(HW_DMA3_MADR+12) = 0x00; - PSXMu8(HW_DMA3_MADR+13) = 0x00; - PSXMu8(HW_DMA3_MADR+14) = 0x00; - PSXMu8(HW_DMA3_MADR+15) = 0x00; - - PSXMu8(HW_DMA3_MADR+16) = 0x00; - PSXMu8(HW_DMA3_MADR+17) = 0x03; - PSXMu8(HW_DMA3_MADR+18) = 0x00; - PSXMu8(HW_DMA3_MADR+19) = 0x00; - - } else { - PSXMu8(HW_DMA3_MADR+ 1) = 0x00; - PSXMu8(HW_DMA3_MADR+ 2) = 0xA0; - PSXMu8(HW_DMA3_MADR+ 7) = itob(diskInfo.strack);//Number of FirstTrack - - PSXMu8(HW_DMA3_MADR+12) = 0xA1; - PSXMu8(HW_DMA3_MADR+17) = itob(diskInfo.etrack);//Number of LastTrack - - PSXMu8(HW_DMA3_MADR+22) = 0xA2;//DiskLength - LSNtoMSF(_time, trackInfo.lsn); - PSXMu8(HW_DMA3_MADR+27) = itob(_time[2]); - PSXMu8(HW_DMA3_MADR+28) = itob(_time[1]); - - for (i=diskInfo.strack; i<=diskInfo.etrack; i++) { - err=CDVDgetTD(i, &trackInfo); - LSNtoMSF(_time, trackInfo.lsn); - PSXMu8(HW_DMA3_MADR+i*10+30) = trackInfo.type; - PSXMu8(HW_DMA3_MADR+i*10+32) = err == -1 ? 0 : itob(i); //number - PSXMu8(HW_DMA3_MADR+i*10+37) = itob(_time[2]); - PSXMu8(HW_DMA3_MADR+i*10+38) = itob(_time[1]); - PSXMu8(HW_DMA3_MADR+i*10+39) = itob(_time[0]); - } - } -*/ } s32 cdvdReadSubQ(s32 lsn, cdvdSubQ* subq) @@ -666,10 +622,8 @@ s32 cdvdCtrlTrayClose() s32 cdvdGetTrayStatus() { s32 ret = CDVDgetTrayStatus(); - // get current tray state + // get current tray state - never true if (cdCaseopen) return(CDVD_TRAY_OPEN); - - if (ret == -1) return(CDVD_TRAY_CLOSE); return(ret); } @@ -691,16 +645,18 @@ __forceinline void cdvdGetDiskType() } cdvd.Type = CDVDgetDiskType(); + + // Is the type listed as a PS2 CD? if (cdvd.Type == CDVD_TYPE_PS2CD) // && needReset == 1) { char str[g_MaxPath]; if (GetPS2ElfName(str) == 1) { + // Does the SYSTEM.CNF file only say "BOOT="? PS1 CD then. cdvd.Type = CDVD_TYPE_PSCD; - } // ENDIF- Does the SYSTEM.CNF file only say "BOOT="? PS1 CD then. - } // ENDIF- Is the type listed as a PS2 CD? -} // END cdvdGetDiskType() - + } + } +} // check whether disc is single or dual layer // if its dual layer, check what the disctype is and what sector number @@ -862,12 +818,14 @@ int cdvdReadSector() { // dual layer ptp disc layerNum = 1; lsn = lsn-layer1Start + 0x30000; - } else if((dualType == 2) && (lsn >= layer1Start)) + } + else if((dualType == 2) && (lsn >= layer1Start)) { // dual layer otp disc layerNum = 1; lsn = ~(layer1Start+0x30000 - 1); - } else + } + else { // single layer disc // or on first layer of dual layer disc @@ -986,14 +944,20 @@ __forceinline void cdvdReadInterrupt() return; } - if (cdvd.Reading == 1) { - if (cdvd.RErr == 0) { + if (cdvd.Reading == 1) + { + if (cdvd.RErr == 0) cdr.pTransfer = CDVDgetBuffer(); - } else cdr.pTransfer = NULL; - if (cdr.pTransfer == NULL) { + else + cdr.pTransfer = NULL; + + if (cdr.pTransfer == NULL) + { cdvd.RetryCntP++; Console::Error("CDVD READ ERROR, sector=%d", params cdvd.Sector); - if (cdvd.RetryCntP <= cdvd.RetryCnt) { + + if (cdvd.RetryCntP <= cdvd.RetryCnt) + { cdvd.RErr = CDVDreadTrack(cdvd.Sector, cdvd.ReadMode); CDVDREAD_INT(cdvd.ReadTime); return; @@ -1002,8 +966,9 @@ __forceinline void cdvdReadInterrupt() cdvd.Reading = 0; } - if (cdvdReadSector() == -1) { - assert( (int)cdvd.ReadTime > 0 ); + if (cdvdReadSector() == -1) + { + assert((int)cdvd.ReadTime > 0 ); CDVDREAD_INT(cdvd.ReadTime); return; } @@ -1018,7 +983,7 @@ __forceinline void cdvdReadInterrupt() HW_DMA3_CHCR &= ~0x01000000; psxDmaInterrupt(3); - cdvd.Ready = 0x4e; + cdvd.Ready = 0x4e; // All done! :D @@ -1159,7 +1124,7 @@ u8 cdvdRead17(void) { // SREADY } u8 cdvdRead18(void) { // SDATAOUT - u8 ret=0; + u8 ret = 0; if ((cdvd.sDataIn & 0x40) == 0) { if (cdvd.ResultP < cdvd.ResultC) { @@ -1348,12 +1313,12 @@ void cdvdWrite04(u8 rt) { // NCOMMAND cdvd.PwOff = Irq_None; // good or bad? switch (rt) { - case 0x00: // CdSync - case 0x01: // CdNop_ + case N_CD_SYNC: // CdSync + case N_CD_NOP: // CdNop_ cdvdSetIrq(); break; - case 0x02: // CdStandby + case N_CD_STANDBY: // CdStandby // Seek to sector zero. The cdvdStartSeek function will simulate // spinup times if needed. @@ -1364,24 +1329,24 @@ void cdvdWrite04(u8 rt) { // NCOMMAND CDVD_INT( cdvdStartSeek( 0, MODE_DVDROM ) ); break; - case 0x03: // CdStop + case N_CD_STOP: // CdStop DevCon::Notice( "CdStop : %d", params rt ); cdvd.Action = cdvdAction_Stop; CDVD_INT( PSXCLK / 6 ); // 166ms delay? break; // from an emulation point of view there is not much need to do anything for this one - case 0x04: // CdPause + case N_CD_PAUSE: // CdPause cdvdSetIrq(); break; - case 0x05: // CdSeek + case N_CD_SEEK: // CdSeek cdvd.Action = cdvdAction_Seek; cdvd.ReadTime = cdvdBlockReadTime( MODE_DVDROM ); CDVD_INT( cdvdStartSeek( *(uint*)(cdvd.Param+0), MODE_DVDROM ) ); break; - case 0x06: // CdRead + case N_CD_READ: // CdRead cdvd.SeekToSector = *(uint*)(cdvd.Param+0); cdvd.nSectors = *(int*)(cdvd.Param+4); cdvd.RetryCnt = (cdvd.Param[8] == 0) ? 0x100 : cdvd.Param[8]; @@ -1414,8 +1379,8 @@ void cdvdWrite04(u8 rt) { // NCOMMAND cdvd.Reading = 1; break; - case 0x07: // CdReadCDDA - case 0x0E: // CdReadXCDDA + case N_CD_READ_CDDA: // CdReadCDDA + case N_CD_READ_XCDDA: // CdReadXCDDA cdvd.SeekToSector = *(int*)(cdvd.Param+0); cdvd.nSectors = *(int*)(cdvd.Param+4); if (cdvd.Param[8] == 0) cdvd.RetryCnt = 0x100; @@ -1455,7 +1420,7 @@ void cdvdWrite04(u8 rt) { // NCOMMAND cdvd.Reading = 1; break; - case 0x08: // DvdRead + case N_DVD_READ: // DvdRead cdvd.SeekToSector = *(int*)(cdvd.Param+0); cdvd.nSectors = *(int*)(cdvd.Param+4); if (cdvd.Param[8] == 0) cdvd.RetryCnt = 0x100; @@ -1486,7 +1451,7 @@ void cdvdWrite04(u8 rt) { // NCOMMAND cdvd.Reading = 1; break; - case 0x09: // CdGetToc & cdvdman_call19 + case N_CD_GET_TOC: // CdGetToc & cdvdman_call19 //Param[0] is 0 for CdGetToc and any value for cdvdman_call19 //the code below handles only CdGetToc! //if(cdvd.Param[0]==0x01) @@ -1499,7 +1464,7 @@ void cdvdWrite04(u8 rt) { // NCOMMAND psxDmaInterrupt(3); break; - case 0x0C: // CdReadKey + case N_CD_READ_KEY: // CdReadKey { u8 arg0 = cdvd.Param[0]; u16 arg1 = cdvd.Param[1] | (cdvd.Param[2]<<8); @@ -1511,7 +1476,7 @@ void cdvdWrite04(u8 rt) { // NCOMMAND } break; - case 0x0F: // CdChgSpdlCtrl + case N_CD_CHG_SPDL_CTRL: // CdChgSpdlCtrl Console::Notice("sceCdChgSpdlCtrl(%d)", params cdvd.Param[0]); cdvdSetIrq(); break; @@ -1544,8 +1509,7 @@ void cdvdWrite07(u8 rt) // BREAK CDR_LOG("cdvdWrite07(Break) %x", rt); // If we're already in a Ready state or already Breaking, then do nothing: - if( cdvd.Ready != 0 || cdvd.Action == cdvdAction_Break ) - return; + if ((cdvd.Ready != 0) || (cdvd.Action == cdvdAction_Break)) return; DbgCon::Notice("*PCSX2*: CDVD BREAK %x", params rt); @@ -1614,34 +1578,38 @@ void cdvdWrite16(u8 rt) // SCOMMAND break; case 0x03: // Mecacon-command - if(cdvd.Param[0]==0x00) { - // get mecha version (1:4) - SetResultSize(4); - cdvdGetMechaVer(&cdvd.Result[0]); - } - else if(cdvd.Param[0]==0x44) { - // write console ID (9:1) - SetResultSize(1); - cdvd.Result[0] = cdvdWriteConsoleID(&cdvd.Param[1]); - } - else if(cdvd.Param[0]==0x45) { - // read console ID (1:9) - SetResultSize(9); - cdvd.Result[0] = cdvdReadConsoleID(&cdvd.Result[1]); - } - else if(cdvd.Param[0]==0xFD) { - // _sceCdReadRenewalDate (1:6) BCD - SetResultSize(6); - cdvd.Result[0] = 0; - cdvd.Result[1] = 0x04;//year - cdvd.Result[2] = 0x12;//month - cdvd.Result[3] = 0x10;//day - cdvd.Result[4] = 0x01;//hour - cdvd.Result[5] = 0x30;//min - } else { - SetResultSize(1); - cdvd.Result[0] = 0x80; - Console::WriteLn("*Unknown Mecacon Command param[0]=%02X", params cdvd.Param[0]); + switch (cdvd.Param[0]) + { + case 0x00: // get mecha version (1:4) + SetResultSize(4); + cdvdGetMechaVer(&cdvd.Result[0]); + break; + + case 0x44: // write console ID (9:1) + SetResultSize(1); + cdvd.Result[0] = cdvdWriteConsoleID(&cdvd.Param[1]); + break; + + case 0x45: // read console ID (1:9) + SetResultSize(9); + cdvd.Result[0] = cdvdReadConsoleID(&cdvd.Result[1]); + break; + + case 0xFD: // _sceCdReadRenewalDate (1:6) BCD + SetResultSize(6); + cdvd.Result[0] = 0; + cdvd.Result[1] = 0x04;//year + cdvd.Result[2] = 0x12;//month + cdvd.Result[3] = 0x10;//day + cdvd.Result[4] = 0x01;//hour + cdvd.Result[5] = 0x30;//min + break; + + default: + SetResultSize(1); + cdvd.Result[0] = 0x80; + Console::WriteLn("*Unknown Mecacon Command param[0]=%02X", params cdvd.Param[0]); + break; } break; @@ -1674,7 +1642,6 @@ void cdvdWrite16(u8 rt) // SCOMMAND cdvd.Result[3], cdvd.Result[5], cdvd.Result[6], cdvd.Result[7]); Console::WriteLn("RTC Read Real Sec %d Min %d Hr %d Day %d Month %d Year %d", params cdvd.RTC.second, cdvd.RTC.minute, cdvd.RTC.hour, cdvd.RTC.day, cdvd.RTC.month, cdvd.RTC.year);*/ - break; case 0x09: // sceCdWriteRTC (7:1) @@ -1699,14 +1666,17 @@ void cdvdWrite16(u8 rt) // SCOMMAND case 0x0A: // sceCdReadNVM (2:3) address = (cdvd.Param[0]<<8) | cdvd.Param[1]; - if (address < 512) { + if (address < 512) + { SetResultSize(3); cdvd.Result[0] = cdvdReadNVM(&cdvd.Result[1], address*2, 2); // swap bytes around tmp = cdvd.Result[1]; cdvd.Result[1] = cdvd.Result[2]; cdvd.Result[2] = tmp; - } else { + } + else + { SetResultSize(1); cdvd.Result[0] = 0xff; } @@ -1715,13 +1685,16 @@ void cdvdWrite16(u8 rt) // SCOMMAND case 0x0B: // sceCdWriteNVM (4:1) address = (cdvd.Param[0]<<8) | cdvd.Param[1]; SetResultSize(1); - if (address < 512) { + if (address < 512) + { // swap bytes around tmp = cdvd.Param[2]; cdvd.Param[2] = cdvd.Param[3]; cdvd.Param[3] = tmp; cdvd.Result[0] = cdvdWriteNVM(&cdvd.Param[2], address*2, 2); - } else { + } + else + { cdvd.Result[0] = 0xff; } break; @@ -2020,8 +1993,11 @@ void cdvdWrite16(u8 rt) // SCOMMAND case 0x8D: // sceMgWriteData SetResultSize(1);//in:length<=16 if (cdvd.mg_size + cdvd.ParamC > cdvd.mg_maxsize) + { cdvd.Result[0] = 0x80; - else{ + } + else + { memcpy_fast(cdvd.mg_buffer + cdvd.mg_size, cdvd.Param, cdvd.ParamC); cdvd.mg_size += cdvd.ParamC; cdvd.Result[0] = 0; // 0 complete ; 1 busy ; 0x80 error @@ -2037,14 +2013,17 @@ void cdvdWrite16(u8 rt) // SCOMMAND case 0x88: // secrman: __mechacon_auth_0x88 //for now it is the same; so, fall;) case 0x8F: // secrman: __mechacon_auth_0x8F + // fixme: Needs a rewrite that doesn't involve gotos. SetResultSize(1);//in:0 - if (cdvd.mg_datatype == 1){// header data - u64* psrc, *pdst; + if (cdvd.mg_datatype == 1) // header data + { + u64* psrc, *pdst; int bit_ofs, i; - if (cdvd.mg_maxsize != cdvd.mg_size) goto fail_pol_cal; - if (cdvd.mg_size < 0x20) goto fail_pol_cal; + if (cdvd.mg_maxsize != cdvd.mg_size) goto fail_pol_cal; + if (cdvd.mg_size < 0x20) goto fail_pol_cal; if (cdvd.mg_size != *(u16*)&cdvd.mg_buffer[0x14]) goto fail_pol_cal; + SysPrintf("[MG] ELF_size=0x%X Hdr_size=0x%X unk=0x%X flags=0x%X count=%d zones=", *(u32*)&cdvd.mg_buffer[0x10], *(u16*)&cdvd.mg_buffer[0x14], *(u16*)&cdvd.mg_buffer[0x16], *(u16*)&cdvd.mg_buffer[0x18], *(u16*)&cdvd.mg_buffer[0x1A]); @@ -2053,13 +2032,20 @@ void cdvdWrite16(u8 rt) // SCOMMAND SysPrintf("%s ", mg_zones[i]); SysPrintf("\n"); bit_ofs = mg_BIToffset(cdvd.mg_buffer); - psrc = (u64*)&cdvd.mg_buffer[bit_ofs-0x20]; - pdst = (u64*)cdvd.mg_kbit; - pdst[0] = psrc[0]; pdst[1] = psrc[1];//memcpy(cdvd.mg_kbit, &cdvd.mg_buffer[bit_ofs-0x20], 0x10); - pdst = (u64*)cdvd.mg_kcon; - pdst[0] = psrc[2]; pdst[1] = psrc[3];//memcpy(cdvd.mg_kcon, &cdvd.mg_buffer[bit_ofs-0x10], 0x10); + + psrc = (u64*)&cdvd.mg_buffer[bit_ofs-0x20]; + pdst = (u64*)cdvd.mg_kbit; + + pdst[0] = psrc[0]; + pdst[1] = psrc[1]; + //memcpy(cdvd.mg_kbit, &cdvd.mg_buffer[bit_ofs-0x20], 0x10); + + pdst = (u64*)cdvd.mg_kcon; + pdst[0] = psrc[2]; + pdst[1] = psrc[3]; + //memcpy(cdvd.mg_kcon, &cdvd.mg_buffer[bit_ofs-0x10], 0x10); - if (cdvd.mg_buffer[bit_ofs+5] || cdvd.mg_buffer[bit_ofs+6] || cdvd.mg_buffer[bit_ofs+7])goto fail_pol_cal; + if (cdvd.mg_buffer[bit_ofs+5] || cdvd.mg_buffer[bit_ofs+6] || cdvd.mg_buffer[bit_ofs+7]) goto fail_pol_cal; if (cdvd.mg_buffer[bit_ofs+4] * 16 + bit_ofs + 8 + 16 != *(u16*)&cdvd.mg_buffer[0x14]){ fail_pol_cal: Console::Error("[MG] ERROR - Make sure the file is already decrypted!!!"); @@ -2080,11 +2066,12 @@ fail_pol_cal: break; case 0x91: // sceMgReadBITLength + { SetResultSize(3);//in:0 - { - int bit_ofs = mg_BIToffset(cdvd.mg_buffer); - memcpy_fast(cdvd.mg_buffer, &cdvd.mg_buffer[bit_ofs], 8+16*cdvd.mg_buffer[bit_ofs+4]); - } + + int bit_ofs = mg_BIToffset(cdvd.mg_buffer); + memcpy_fast(cdvd.mg_buffer, &cdvd.mg_buffer[bit_ofs], 8+16*cdvd.mg_buffer[bit_ofs+4]); + cdvd.mg_maxsize = 0; // don't allow any write cdvd.mg_size = 8+16*cdvd.mg_buffer[4];//new offset, i just moved the data Console::WriteLn("[MG] BIT count=%d", params cdvd.mg_buffer[4]); @@ -2093,7 +2080,7 @@ fail_pol_cal: cdvd.Result[1] = (cdvd.mg_size >> 0) & 0xFF; cdvd.Result[2] = (cdvd.mg_size >> 8) & 0xFF; break; - + } case 0x92: // sceMgWriteDatainLength cdvd.mg_size = 0; cdvd.mg_datatype = 0;//data (encrypted) @@ -2104,40 +2091,48 @@ fail_pol_cal: case 0x93: // sceMgWriteDataoutLength SetResultSize(1);//in:2 - if (((cdvd.Param[0] | (((int)cdvd.Param[1])<<8)) == cdvd.mg_size) && (cdvd.mg_datatype == 0)){ + if (((cdvd.Param[0] | (((int)cdvd.Param[1])<<8)) == cdvd.mg_size) && (cdvd.mg_datatype == 0)) + { cdvd.mg_maxsize = 0; // don't allow any write cdvd.Result[0] = 0; // 0 complete ; 1 busy ; 0x80 error - }else + } + else + { cdvd.Result[0] = 0x80; + } break; case 0x94: // sceMgReadKbit - read first half of BIT key SetResultSize(1+8);//in:0 cdvd.Result[0] = 0; - ((int*)(cdvd.Result+1))[0] = ((int*)cdvd.mg_kbit)[0]; - ((int*)(cdvd.Result+1))[1] = ((int*)cdvd.mg_kbit)[1];//memcpy(cdvd.Result+1, cdvd.mg_kbit, 8); - break; + ((int*)(cdvd.Result+1))[0] = ((int*)cdvd.mg_kbit)[0]; + ((int*)(cdvd.Result+1))[1] = ((int*)cdvd.mg_kbit)[1]; + //memcpy(cdvd.Result+1, cdvd.mg_kbit, 8); + break; case 0x95: // sceMgReadKbit2 - read second half of BIT key SetResultSize(1+8);//in:0 cdvd.Result[0] = 0; - ((int*)(cdvd.Result+1))[0] = ((int*)(cdvd.mg_kbit+8))[0]; - ((int*)(cdvd.Result+1))[1] = ((int*)(cdvd.mg_kbit+8))[1];//memcpy(cdvd.Result+1, cdvd.mg_kbit+8, 8); + ((int*)(cdvd.Result+1))[0] = ((int*)(cdvd.mg_kbit+8))[0]; + ((int*)(cdvd.Result+1))[1] = ((int*)(cdvd.mg_kbit+8))[1]; + //memcpy(cdvd.Result+1, cdvd.mg_kbit+8, 8); break; case 0x96: // sceMgReadKcon - read first half of content key SetResultSize(1+8);//in:0 cdvd.Result[0] = 0; - ((int*)(cdvd.Result+1))[0] = ((int*)cdvd.mg_kcon)[0]; - ((int*)(cdvd.Result+1))[1] = ((int*)cdvd.mg_kcon)[1];//memcpy(cdvd.Result+1, cdvd.mg_kcon, 8); + ((int*)(cdvd.Result+1))[0] = ((int*)cdvd.mg_kcon)[0]; + ((int*)(cdvd.Result+1))[1] = ((int*)cdvd.mg_kcon)[1]; + //memcpy(cdvd.Result+1, cdvd.mg_kcon, 8); break; case 0x97: // sceMgReadKcon2 - read second half of content key SetResultSize(1+8);//in:0 cdvd.Result[0] = 0; - ((int*)(cdvd.Result+1))[0] = ((int*)(cdvd.mg_kcon+8))[0]; - ((int*)(cdvd.Result+1))[1] = ((int*)(cdvd.mg_kcon+8))[1];//memcpy(cdvd.Result+1, cdvd.mg_kcon+8, 8); + ((int*)(cdvd.Result+1))[0] = ((int*)(cdvd.mg_kcon+8))[0]; + ((int*)(cdvd.Result+1))[1] = ((int*)(cdvd.mg_kcon+8))[1]; + //memcpy(cdvd.Result+1, cdvd.mg_kcon+8, 8); break; default: @@ -2146,9 +2141,10 @@ fail_pol_cal: SetResultSize(1); //in:0 cdvd.Result[0] = 0; // 0 complete ; 1 busy ; 0x80 error break; - } - //SysPrintf("SCMD - %x\n", rt); - cdvd.ParamP = 0; cdvd.ParamC = 0; + } // end switch + + //SysPrintf("SCMD - %x\n", rt); + cdvd.ParamP = 0; cdvd.ParamC = 0; } void cdvdWrite17(u8 rt) { // SDATAIN diff --git a/pcsx2/Interpreter.cpp b/pcsx2/Interpreter.cpp index 9e915c6de3..796f9e746a 100644 --- a/pcsx2/Interpreter.cpp +++ b/pcsx2/Interpreter.cpp @@ -133,7 +133,9 @@ namespace OpcodeImpl { * Jump to target * * Format: OP target * *********************************************************/ - +// fixme: looking at the other branching code, shouldn't those _SetLinks in BGEZAL and such only be set +// if the condition is true? --arcum42 + void J() { doBranch(_JumpTarget_); @@ -215,7 +217,7 @@ void BLTZ() // Branch if Rs < 0 void BLTZAL() // Branch if Rs < 0 and link { - _SetLink(31); \ + _SetLink(31); if (cpuRegs.GPR.r[_Rs_].SD[0] < 0) { doBranch(_BranchTarget_); diff --git a/pcsx2/IopBios.cpp b/pcsx2/IopBios.cpp index 697dac2510..7d4a2f1fb0 100644 --- a/pcsx2/IopBios.cpp +++ b/pcsx2/IopBios.cpp @@ -171,29 +171,33 @@ const char *biosC0n[256] = { #define Rv0 (iopVirtMemR(v0)) #define Rsp (iopVirtMemR(sp)) -void bios_write() { // 0x35/0x03 - - - if (a0 == 1) { // stdout +void bios_write() // 0x35/0x03 +{ + if (a0 == 1) // stdout + { const char *ptr = Ra1; - while (a2 > 0) { - SysPrintf("%c", *ptr++); a2--; + while (a2 > 0) + { + Console::Write("%c", params *ptr++); + a2--; } - pc0 = ra; return; - } - PSXBIOS_LOG("bios_%s: %x,%x,%x", biosB0n[0x35], a0, a1, a2); + } + else + { + PSXBIOS_LOG("bios_%s: %x,%x,%x", biosB0n[0x35], a0, a1, a2); - v0 = -1; + v0 = -1; + } pc0 = ra; } -void bios_printf() { // 3f - char tmp[1024]; - char tmp2[1024]; - unsigned long save[4]; +void bios_printf() // 3f +{ + char tmp[1024], tmp2[1024]; + u32 save[4]; char *ptmp = tmp; - int n=1, i=0, j; + int n=1, i=0, j = 0; memcpy(save, iopVirtMemR(sp), 4*4); @@ -201,58 +205,86 @@ void bios_printf() { // 3f iopMemWrite32(sp + 4, a1); iopMemWrite32(sp + 8, a2); iopMemWrite32(sp + 12, a3); - // old code used phys... is tlb more correct? //psxMu32(sp) = a0; //psxMu32(sp + 4) = a1; //psxMu32(sp + 8) = a2; - //psxMu32(sp + 12) = a3; + //psxMu32(sp + 12) = a3;+ - while (Ra0[i]) { - switch (Ra0[i]) { + while (Ra0[i]) + { + switch (Ra0[i]) + { case '%': j = 0; tmp2[j++] = '%'; + _start: - switch (Ra0[++i]) { + switch (Ra0[++i]) + { case '.': case 'l': - tmp2[j++] = Ra0[i]; goto _start; + tmp2[j++] = Ra0[i]; + goto _start; default: - if (Ra0[i] >= '0' && Ra0[i] <= '9') { + if (Ra0[i] >= '0' && Ra0[i] <= '9') + { tmp2[j++] = Ra0[i]; goto _start; } break; } + tmp2[j++] = Ra0[i]; tmp2[j] = 0; - switch (Ra0[i]) { + switch (Ra0[i]) + { case 'f': case 'F': - ptmp+= sprintf(ptmp, tmp2, (float)iopMemRead32(sp + n * 4)); n++; break; + ptmp+= sprintf(ptmp, tmp2, (float)iopMemRead32(sp + n * 4)); + n++; + break; + case 'a': case 'A': case 'e': case 'E': case 'g': case 'G': - ptmp+= sprintf(ptmp, tmp2, (double)iopMemRead32(sp + n * 4)); n++; break; + ptmp+= sprintf(ptmp, tmp2, (double)iopMemRead32(sp + n * 4)); + n++; + break; + case 'p': case 'i': case 'd': case 'D': case 'o': case 'O': case 'x': case 'X': - ptmp+= sprintf(ptmp, tmp2, (unsigned int)iopMemRead32(sp + n * 4)); n++; break; + ptmp+= sprintf(ptmp, tmp2, (u32)iopMemRead32(sp + n * 4)); + n++; + break; + case 'c': - ptmp+= sprintf(ptmp, tmp2, (unsigned char)iopMemRead32(sp + n * 4)); n++; break; + ptmp+= sprintf(ptmp, tmp2, (u8)iopMemRead32(sp + n * 4)); + n++; + break; + case 's': - ptmp+= sprintf(ptmp, tmp2, iopVirtMemR(iopMemRead32(sp + n * 4))); n++; break; + ptmp+= sprintf(ptmp, tmp2, iopVirtMemR(iopMemRead32(sp + n * 4))); + n++; + break; + case '%': - *ptmp++ = Ra0[i]; break; + *ptmp++ = Ra0[i]; + break; + + default: + break; } i++; break; + default: *ptmp++ = Ra0[i++]; + break; } } *ptmp = 0; @@ -260,18 +292,18 @@ _start: // Note: Use Read to obtain a write pointer here, since we're just writing back the // temp buffer we saved earlier. memcpy( (void*)iopVirtMemR(sp), save, 4*4); - Console::Write( Color_Cyan, "%s", params tmp); - pc0 = ra; } -void bios_putchar () { // 3d +void bios_putchar () // 3d +{ Console::Write( Color_Cyan, "%c", params a0 ); pc0 = ra; } -void bios_puts () { // 3e/3f +void bios_puts () // 3e/3f +{ Console::Write( Color_Cyan, Ra0 ); pc0 = ra; } @@ -280,10 +312,12 @@ void (*biosA0[256])(); void (*biosB0[256])(); void (*biosC0[256])(); -void psxBiosInit() { +void psxBiosInit() +{ int i; - for(i = 0; i < 256; i++) { + for(i = 0; i < 256; i++) + { biosA0[i] = NULL; biosB0[i] = NULL; biosC0[i] = NULL; @@ -296,7 +330,8 @@ void psxBiosInit() { } -void psxBiosShutdown() { +void psxBiosShutdown() +{ } } // end namespace R3000A \ No newline at end of file diff --git a/pcsx2/R3000AInterpreter.cpp b/pcsx2/R3000AInterpreter.cpp index 2612204644..ec321c609c 100644 --- a/pcsx2/R3000AInterpreter.cpp +++ b/pcsx2/R3000AInterpreter.cpp @@ -335,43 +335,96 @@ void spyFunctions(){ } } */ - /********************************************************* * Register branch logic * * Format: OP rs, offset * *********************************************************/ -#define RepZBranchi32(op) if(_i32(_rRs_) op 0) doBranch(_BranchTarget_); -#define RepZBranchLinki32(op) if(_i32(_rRs_) op 0) { _SetLink(31); doBranch(_BranchTarget_); } -void psxBGEZ() { RepZBranchi32(>=) } // Branch if Rs >= 0 -void psxBGEZAL() { RepZBranchLinki32(>=) } // Branch if Rs >= 0 and link -void psxBGTZ() { RepZBranchi32(>) } // Branch if Rs > 0 -void psxBLEZ() { RepZBranchi32(<=) } // Branch if Rs <= 0 -void psxBLTZ() { RepZBranchi32(<) } // Branch if Rs < 0 -void psxBLTZAL() { RepZBranchLinki32(<) } // Branch if Rs < 0 and link +void psxBGEZ() // Branch if Rs >= 0 +{ + if (_i32(_rRs_) >= 0) doBranch(_BranchTarget_); +} + +void psxBGEZAL() // Branch if Rs >= 0 and link +{ + if (_i32(_rRs_) >= 0) + { + _SetLink(31); + doBranch(_BranchTarget_); + } +} + +void psxBGTZ() // Branch if Rs > 0 +{ + if (_i32(_rRs_) > 0) doBranch(_BranchTarget_); +} + +void psxBLEZ() // Branch if Rs <= 0 +{ + if (_i32(_rRs_) <= 0) doBranch(_BranchTarget_); +} +void psxBLTZ() // Branch if Rs < 0 +{ + if (_i32(_rRs_) < 0) doBranch(_BranchTarget_); +} + +void psxBLTZAL() // Branch if Rs < 0 and link +{ + if (_i32(_rRs_) < 0) + { + _SetLink(31); + doBranch(_BranchTarget_); + } +} /********************************************************* * Register branch logic * * Format: OP rs, rt, offset * *********************************************************/ -#define RepBranchi32(op) if(_i32(_rRs_) op _i32(_rRt_)) doBranch(_BranchTarget_); -void psxBEQ() { RepBranchi32(==) } // Branch if Rs == Rt -void psxBNE() { RepBranchi32(!=) } // Branch if Rs != Rt +void psxBEQ() // Branch if Rs == Rt +{ + if (_i32(_rRs_) == _i32(_rRt_)) doBranch(_BranchTarget_); +} + +void psxBNE() // Branch if Rs != Rt +{ + if (_i32(_rRs_) != _i32(_rRt_)) doBranch(_BranchTarget_); +} /********************************************************* * Jump to target * * Format: OP target * *********************************************************/ -void psxJ() { doBranch(_JumpTarget_); } -void psxJAL() { _SetLink(31); doBranch(_JumpTarget_); /*spyFunctions();*/ } +void psxJ() +{ + doBranch(_JumpTarget_); +} + +void psxJAL() +{ + _SetLink(31); + doBranch(_JumpTarget_); + /*spyFunctions();*/ +} /********************************************************* * Register jump * * Format: OP rs, rd * *********************************************************/ -void psxJR() { doBranch(_u32(_rRs_)); } -void psxJALR() { if (_Rd_) { _SetLink(_Rd_); } doBranch(_u32(_rRs_)); } +void psxJR() +{ + doBranch(_u32(_rRs_)); +} + +void psxJALR() +{ + if (_Rd_) + { + _SetLink(_Rd_); + } + doBranch(_u32(_rRs_)); +} /////////////////////////////////////////// // These macros are used to assemble the repassembler functions diff --git a/pcsx2/configure.ac b/pcsx2/configure.ac index e76f484618..449e023f95 100644 --- a/pcsx2/configure.ac +++ b/pcsx2/configure.ac @@ -93,24 +93,6 @@ then fi AC_MSG_RESULT($devbuild) -AC_MSG_CHECKING(force sse3 instructions) -AC_ARG_ENABLE(sse3, AC_HELP_STRING([--enable-sse3], [Forces sse3 detection on CPUs]), - sse3=$enableval,sse3=no) -if test "x$sse3" == xyes -then - AC_DEFINE(PCSX2_FORCESSE3,1,[PCSX2_FORCESSE3]) -fi -AC_MSG_RESULT(sse3) - -AC_MSG_CHECKING(force sse4 instructions) -AC_ARG_ENABLE(sse4, AC_HELP_STRING([--enable-sse4], [Forces sse4 detection on CPUs]), - sse4=$enableval,sse4=no) -if test "x$sse4" == xyes -then - AC_DEFINE(PCSX2_FORCESSE4,1,[PCSX2_FORCESSE4]) -fi -AC_MSG_RESULT(sse4) - dnl gtk AC_MSG_CHECKING(gtk+) AC_CHECK_PROG(GTK_CONFIG, pkg-config, pkg-config) @@ -153,7 +135,6 @@ echo "Configuration:" echo " Target system type: $target" echo " Debug build? $debug" echo " Dev build? $devbuild" -echo " Force sse3? $sse3" echo " nls support? $nls" echo " local plugin inis? $localinis" echo " custom cflags? $customcflags" From e24851927a7cd066722e4734be80001e976be9d1 Mon Sep 17 00:00:00 2001 From: "Jake.Stine" Date: Fri, 1 May 2009 02:12:45 +0000 Subject: [PATCH 24/41] Fixed some 'too many newlines' bugs in the Console namespace. git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1096 96395faa-99c1-11dd-bbfe-3dabce05a288 --- pcsx2/Console.cpp | 2 +- pcsx2/windows/WinConsole.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pcsx2/Console.cpp b/pcsx2/Console.cpp index 05676cf478..abed30a619 100644 --- a/pcsx2/Console.cpp +++ b/pcsx2/Console.cpp @@ -43,7 +43,7 @@ namespace Console va_list list; va_start(list,dummy); - WriteLn( vfmt_string( fmt, list ).c_str() ); + Write( vfmt_string( fmt, list ).c_str() ); va_end(list); return false; diff --git a/pcsx2/windows/WinConsole.cpp b/pcsx2/windows/WinConsole.cpp index e09246a7fa..c587ff1a4c 100644 --- a/pcsx2/windows/WinConsole.cpp +++ b/pcsx2/windows/WinConsole.cpp @@ -95,7 +95,7 @@ namespace Console if (emuLog != NULL) { - fputs("\n", emuLog); + fputs("", emuLog); fflush( emuLog ); } @@ -114,7 +114,7 @@ namespace Console // No flushing here -- only flush after newlines. if (emuLog != NULL) - fputs(fmt, emuLog); + fprintf( emuLog, fmt ); return false; } From 17caa515acd0497d3d5920ed3183103359cebeed Mon Sep 17 00:00:00 2001 From: "Jake.Stine" Date: Fri, 1 May 2009 02:53:09 +0000 Subject: [PATCH 25/41] Rushed my prev commit. Here's some basic thing, only much less broken and crappy. (fixes double-spaced emuLog.txt file contents) git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1099 96395faa-99c1-11dd-bbfe-3dabce05a288 --- pcsx2/HwWrite.cpp | 20 ++++++++++++++------ pcsx2/IopHw.cpp | 20 +++++++++++++++----- pcsx2/windows/WinConsole.cpp | 4 ++-- 3 files changed, 31 insertions(+), 13 deletions(-) diff --git a/pcsx2/HwWrite.cpp b/pcsx2/HwWrite.cpp index fa5fbdd4ff..fc978a6f67 100644 --- a/pcsx2/HwWrite.cpp +++ b/pcsx2/HwWrite.cpp @@ -168,16 +168,24 @@ void hwWrite8(u32 mem, u8 value) { case RCNT3_TARGET: rcntWtarget(3, value); break; case 0x1000f180: - if (value == '\n') { + { + bool flush = false; + + // Terminate lines on CR or full buffers, and ignore \n's if the string contents + // are empty (otherwise terminate on \n too!) + if( ( value == '\r' ) || ( sio_count == 1023 ) || + ( value == '\n' && sio_count != 0 ) ) + { sio_buffer[sio_count] = 0; Console::WriteLn( Color_Cyan, sio_buffer ); sio_count = 0; - } else { - if (sio_count < 1023) { - sio_buffer[sio_count++] = value; - } } - break; + else if( value != '\n' ) + { + sio_buffer[sio_count++] = value; + } + } + break; //case 0x10003c02: //Tony Hawks Project 8 uses this // vif1Write32(mem & ~0x2, value << 16); diff --git a/pcsx2/IopHw.cpp b/pcsx2/IopHw.cpp index e23294911c..cf50b84ac1 100644 --- a/pcsx2/IopHw.cpp +++ b/pcsx2/IopHw.cpp @@ -666,14 +666,24 @@ void psxHwWrite8(u32 add, u8 value) { case 0x1f801803: cdrWrite3(value); break; case 0x1f80380c: - if (value == '\r') break; - if (value == '\n' || g_pbufi >= 1023) { // A line break, or the buffer is about to overflow. - g_pbuf[g_pbufi++] = 0; - g_pbufi = 0; + { + bool flush = false; + + // Terminate lines on CR or full buffers, and ignore \n's if the string contents + // are empty (otherwise terminate on \n too!) + if( ( value == '\r' ) || ( g_pbufi == 1023 ) || + ( value == '\n' && g_pbufi != 0 ) ) + { + g_pbuf[g_pbufi] = 0; DevCon::WriteLn( Color_Cyan, g_pbuf ); + g_pbufi = 0; + } + else if( value != '\n' ) + { + g_pbuf[g_pbufi++] = value; } - else g_pbuf[g_pbufi++] = value; psxHu8(add) = value; + } return; case 0x1F808260: diff --git a/pcsx2/windows/WinConsole.cpp b/pcsx2/windows/WinConsole.cpp index c587ff1a4c..8774737650 100644 --- a/pcsx2/windows/WinConsole.cpp +++ b/pcsx2/windows/WinConsole.cpp @@ -95,7 +95,7 @@ namespace Console if (emuLog != NULL) { - fputs("", emuLog); + fputs("\n", emuLog); fflush( emuLog ); } @@ -114,7 +114,7 @@ namespace Console // No flushing here -- only flush after newlines. if (emuLog != NULL) - fprintf( emuLog, fmt ); + fputs( fmt, emuLog ); return false; } From b6ba2f050f4d47cc8fdbd14c6807d719954d4949 Mon Sep 17 00:00:00 2001 From: cottonvibes Date: Fri, 1 May 2009 10:12:44 +0000 Subject: [PATCH 26/41] minor microVU changes git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1101 96395faa-99c1-11dd-bbfe-3dabce05a288 --- pcsx2/x86/microVU.cpp | 8 ++++---- pcsx2/x86/microVU_Analyze.inl | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/pcsx2/x86/microVU.cpp b/pcsx2/x86/microVU.cpp index 7f508ebebd..670767ee78 100644 --- a/pcsx2/x86/microVU.cpp +++ b/pcsx2/x86/microVU.cpp @@ -153,14 +153,14 @@ microVUt(int) mVUfindLeastUsedProg() { return mVU->prog.total; } else { - int j = 0; - u32 smallest = mVU->prog.prog[0].used; - for (int i = 1; i <= mVU->prog.total; i++) { + int j = (mVU->prog.cur + 1) & mVU->prog.max; + /*u32 smallest = mVU->prog.prog[j].used; + for (int i = ((j+1)&mVU->prog.max), z = 0; z < mVU->prog.max; i = (i+1)&mVU->prog.max, z++) { if (smallest > mVU->prog.prog[i].used) { smallest = mVU->prog.prog[i].used; j = i; } - } + }*/ mVUclearProg(j); // Clear old data if overwriting old program mVUcacheProg(j); // Cache Micro Program Console::Notice("microVU%d: MicroProgram Cache Full!", params vuIndex); diff --git a/pcsx2/x86/microVU_Analyze.inl b/pcsx2/x86/microVU_Analyze.inl index 7a6dc106c7..81512ba1f9 100644 --- a/pcsx2/x86/microVU_Analyze.inl +++ b/pcsx2/x86/microVU_Analyze.inl @@ -329,14 +329,14 @@ microVUt(void) mVUanalyzeXGkick(int Fs, int xCycles) { microVUt(void) mVUanalyzeBranch1(int Is) { microVU* mVU = mVUx; - if (mVUregs.VI[Is]) { analyzeVIreg1(Is); } - else { analyzeBranchVI(Is, _memReadIs); } + if (mVUregs.VI[Is] || mVUstall) { analyzeVIreg1(Is); } + else { analyzeBranchVI(Is, _memReadIs); } } microVUt(void) mVUanalyzeBranch2(int Is, int It) { microVU* mVU = mVUx; - if (mVUregs.VI[Is] || mVUregs.VI[It]) { analyzeVIreg1(Is); analyzeVIreg1(It); } - else { analyzeBranchVI(Is, _memReadIs); analyzeBranchVI(It, _memReadIt);} + if (mVUregs.VI[Is] || mVUregs.VI[It] || mVUstall) { analyzeVIreg1(Is); analyzeVIreg1(It); } + else { analyzeBranchVI(Is, _memReadIs); analyzeBranchVI(It, _memReadIt);} } #endif //PCSX2_MICROVU From bc9e0b08adbe4922433a980ee82166ef03d987c2 Mon Sep 17 00:00:00 2001 From: arcum42 Date: Fri, 1 May 2009 11:06:52 +0000 Subject: [PATCH 27/41] Some work on CDVD.cpp. Slight change to the branch statements in Interpreter.cpp. Restore a change to Pcsx2Defs.h that got reverted. git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1102 96395faa-99c1-11dd-bbfe-3dabce05a288 --- common/include/Pcsx2Defs.h | 2 - pcsx2/CDVD.cpp | 1007 +++++++++++++++--------------------- pcsx2/CDVD.h | 256 +++++++-- pcsx2/Interpreter.cpp | 8 +- pcsx2/IopHw.cpp | 79 +-- 5 files changed, 643 insertions(+), 709 deletions(-) diff --git a/common/include/Pcsx2Defs.h b/common/include/Pcsx2Defs.h index 20a5f8f1fa..b06ed47925 100644 --- a/common/include/Pcsx2Defs.h +++ b/common/include/Pcsx2Defs.h @@ -58,8 +58,6 @@ // disable the default case in a switch #define jNO_DEFAULT \ { \ - break; \ - \ default: \ jASSUME(0); \ break; \ diff --git a/pcsx2/CDVD.cpp b/pcsx2/CDVD.cpp index 683a150a42..1894559b09 100644 --- a/pcsx2/CDVD.cpp +++ b/pcsx2/CDVD.cpp @@ -19,206 +19,12 @@ #include "PrecompiledHeader.h" #include +#include #include "IopCommon.h" #include "CDVDiso.h" static cdvdStruct cdvd; -static int cdCaseopen; - -/* -Interrupts - values are flag bits. - -0x00 No interrupt -0x01 Data Ready -0x02 Command Complete -0x03 Acknowledge (reserved) -0x04 End of Data Detected -0x05 Error Detected -0x06 Drive Not Ready - -In limited experimentation I found that PS2 apps respond actively to use of the -'Data Ready' flag -- in that they'll almost immediately initiate a DMA transfer -after receiving an Irq with that as the cause. But the question is, of course, -*when* to use it. Adding it into some locations of CDVD reading only slowed -games down and broke things. - -Using Drive Not Ready also invokes basic error handling from the Iop Bios, but -without proper emulation of the cdvd status flag it also tends to break things. - -*/ - -enum CdvdIrqId -{ - Irq_None = 0 -, Irq_DataReady = 0 -, Irq_CommandComplete -, Irq_Acknowledge -, Irq_EndOfData -, Irq_Error -, Irq_NotReady - -}; - -/* is cdvd.Status only for NCMDS? (linuzappz) */ -enum cdvdStatus -{ - CDVD_STATUS_NONE = 0x00, // not sure ;) - CDVD_STATUS_SEEK_COMPLETE = 0x0A, -}; - -// Cdvd actions tell the emulator how and when to respond to certain requests. -// Actions are handled by the cdvdInterrupt() -enum cdvdActions -{ - cdvdAction_None = 0 -, cdvdAction_Seek -, cdvdAction_Standby -, cdvdAction_Stop -, cdvdAction_Break -, cdvdAction_Read // note: not used yet. -}; - -enum ncommands -{ - N_CD_SYNC = 0x00, // CdSync - N_CD_NOP = 0x01, // CdNop - N_CD_STANDBY = 0x02, // CdStandby - N_CD_STOP = 0x03, // CdStop - N_CD_PAUSE = 0x04, // CdPause - N_CD_SEEK = 0x05, // CdSeek - N_CD_READ = 0x06, // CdRead - N_CD_READ_CDDA = 0x07, // CdReadCDDA - N_DVD_READ = 0x08, // DvdRead - N_CD_GET_TOC = 0x09, // CdGetToc & cdvdman_call19 - N_CD_READ_KEY = 0x0C, // CdReadKey - N_CD_READ_XCDDA = 0x0E, // CdReadXCDDA - N_CD_CHG_SPDL_CTRL = 0x0F, // CdChgSpdlCtrl -}; - -////////////////////////////////////////////////////////////////////////////////////////// -// Cdvd Block Read Cycle Timings -// -// The PS2 CDVD effectively has two seek modes -- the normal/slow one (est. avg seeks being -// around 120-160ms), and a faster seek which has an estimated seek time of about 35-40ms. -// Fast seeks happen when the destination sector is within a certain range of the starting -// point, such that abs(start-dest) is less than the value in the tbl_FastSeekDelta. -// -// CDVDs also have a secondary seeking method used when the destination is close enough -// that a contiguous sector read can reach the sector faster than initiating a full seek. -// Typically this value is very low. - -enum CDVD_MODE_TYPE -{ - MODE_CDROM = 0, - MODE_DVDROM, -}; - -static const uint tbl_FastSeekDelta[3] = -{ - 4371, // CD-ROM - 14764, // Single-layer DVD-ROM - 13360 // dual-layer DVD-ROM [currently unused] -}; - -// if a seek is within this many blocks, read instead of seek. -// These values are arbitrary assumptions. Not sure what the real PS2 uses. -static const uint tbl_ContigiousSeekDelta[3] = -{ - 8, // CD-ROM - 16, // single-layer DVD-ROM - 16, // dual-layer DVD-ROM [currently unused] -}; - -// Note: DVD read times are modified to be faster, because games seem to be a lot more -// concerned with accurate(ish) seek delays and less concerned with actual block read speeds. -// Translation: it's a minor speedhack :D - -static const uint PSX_CD_READSPEED = 153600; // 1 Byte Time @ x1 (150KB = cd x 1) -static const uint PSX_DVD_READSPEED = 1382400 + 256000; // normal is 1 Byte Time @ x1 (1350KB = dvd x 1). - - -// Legacy Note: FullSeek timing causes many games to load very slow, but it likely not the real problem. -// Games breaking with it set to PSXCLK*40 : "wrath unleashed" and "Shijou Saikyou no Deshi Kenichi". - -static const uint Cdvd_FullSeek_Cycles = (PSXCLK*100) / 1000; // average number of cycles per fullseek (100ms) -static const uint Cdvd_FastSeek_Cycles = (PSXCLK*30) / 1000; // average number of cycles per fastseek (37ms) - -static const char *mg_zones[8] = {"Japan", "USA", "Europe", "Oceania", "Asia", "Russia", "China", "Mexico"}; - -static const char *nCmdName[0x100]= { - "CdSync", "CdNop", "CdStandby", "CdStop", - "CdPause", "CdSeek", "CdRead", "CdReadCDDA", - "CdReadDVDV", "CdGetToc", "", "NCMD_B", - "CdReadKey", "", "sceCdReadXCDDA", "sceCdChgSpdlCtrl", -}; - -static const char *sCmdName[0x100]= { - "", "sceCdGetDiscType", "sceCdReadSubQ", "subcommands",//sceCdGetMecaconVersion, read/write console id, read renewal date - "", "sceCdTrayState", "sceCdTrayCtrl", "", - "sceCdReadClock", "sceCdWriteClock", "sceCdReadNVM", "sceCdWriteNVM", - "sceCdSetHDMode", "", "", "sceCdPowerOff", - "", "", "sceCdReadILinkID", "sceCdWriteILinkID", /*10*/ - "sceAudioDigitalOut", "sceForbidDVDP", "sceAutoAdjustCtrl", "sceCdReadModelNumber", - "sceWriteModelNumber", "sceCdForbidCD", "sceCdBootCertify", "sceCdCancelPOffRdy", - "sceCdBlueLEDCtl", "", "sceRm2Read", "sceRemote2_7",//Rm2PortGetConnection? - "sceRemote2_6", "sceCdWriteWakeUpTime", "sceCdReadWakeUpTime", "", /*20*/ - "sceCdRcBypassCtl", "", "", "", - "", "sceCdNoticeGameStart", "", "", - "sceCdXBSPowerCtl", "sceCdXLEDCtl", "sceCdBuzzerCtl", "", - "", "sceCdSetMediumRemoval", "sceCdGetMediumRemoval", "sceCdXDVRPReset", /*30*/ - "", "", "__sceCdReadRegionParams", "__sceCdReadMAC", - "__sceCdWriteMAC", "", "", "", - "", "", "__sceCdWriteRegionParams", "", - "sceCdOpenConfig", "sceCdReadConfig", "sceCdWriteConfig", "sceCdCloseConfig", /*40*/ - "", "", "", "", - "", "", "", "", - "", "", "", "", - "", "", "", "", /*50*/ - "", "", "", "", - "", "", "", "", - "", "", "", "", - "", "", "", "", /*60*/ - "", "", "", "", - "", "", "", "", - "", "", "", "", - "", "", "", "", /*70*/ - "", "", "", "", - "", "", "", "", - "", "", "", "", - "mechacon_auth_0x80", "mechacon_auth_0x81", "mechacon_auth_0x82", "mechacon_auth_0x83", /*80*/ - "mechacon_auth_0x84", "mechacon_auth_0x85", "mechacon_auth_0x86", "mechacon_auth_0x87", - "mechacon_auth_0x88", "", "", "", - "", "sceMgWriteData", "sceMgReadData", "mechacon_auth_0x8F", - "sceMgWriteHeaderStart", "sceMgReadBITLength", "sceMgWriteDatainLength", "sceMgWriteDataoutLength", /*90*/ - "sceMgReadKbit", "sceMgReadKbit2", "sceMgReadKcon", "sceMgReadKcon2", - "sceMgReadIcvPs2", "", "", "", - "", "", "", "", - /*A0, no sCmds above?*/ -}; - -// NVM (eeprom) layout info -struct NVMLayout { - u32 biosVer; // bios version that this eeprom layout is for - s32 config0; // offset of 1st config block - s32 config1; // offset of 2nd config block - s32 config2; // offset of 3rd config block - s32 consoleId; // offset of console id (?) - s32 ilinkId; // offset of ilink id (ilink mac address) - s32 modelNum; // offset of ps2 model number (eg "SCPH-70002") - s32 regparams; // offset of RegionParams for PStwo - s32 mac; // offset of the value written to 0xFFFE0188 and 0xFFFE018C on PStwo -}; - -#define NVM_FORMAT_MAX 2 -NVMLayout nvmlayouts[NVM_FORMAT_MAX] = -{ - {0x000, 0x280, 0x300, 0x200, 0x1C8, 0x1C0, 0x1A0, 0x180, 0x198}, // eeproms from bios v0.00 and up - {0x146, 0x270, 0x2B0, 0x200, 0x1C8, 0x1E0, 0x1B0, 0x180, 0x198}, // eeproms from bios v1.70 and up -}; - -#define btoi(b) ((b)/16*10 + (b)%16) /* BCD to u_char */ -#define itob(i) ((i)/10*16 + (i)%10) /* u_char to BCD */ __forceinline void SetResultSize(u8 size) { @@ -258,6 +64,7 @@ static int mg_BIToffset(u8 *buffer) if (*(u16*)&buffer[0x18] & 1) ofs += buffer[ofs]; if ((*(u16*)&buffer[0x18] & 0xF000) == 0) ofs += 8; + return ofs + 0x20; } @@ -274,7 +81,9 @@ FILE *_cdvdOpenMechaVer() { // [TODO] : Upgrade this to use std::string! strcpy(file, Bios.c_str()); - ptr = file; i = (int)strlen(file); + ptr = file; + i = (int)strlen(file); + while (i > 0) { if (ptr[i] == '.') break; i--; } ptr[i+1] = '\0'; strcat(file, "MEC"); @@ -288,6 +97,7 @@ FILE *_cdvdOpenMechaVer() { Msgbox::Alert("_cdvdOpenMechaVer: Error creating %s", params file); exit(1); } + fputc(0x03, fd); fputc(0x06, fd); fputc(0x02, fd); @@ -319,9 +129,12 @@ FILE *_cdvdOpenNVM() { // [TODO] : Upgrade this to use std::string! strcpy( file, Bios.c_str() ); - ptr = file; i = (int)strlen(file); + ptr = file; + i = (int)strlen(file); + while (i > 0) { if (ptr[i] == '.') break; i--; } ptr[i+1] = '\0'; + strcat(file, "NVM"); // if file doesnt exist, create empty one @@ -345,53 +158,51 @@ FILE *_cdvdOpenNVM() { s32 cdvdReadNVM(u8 *dst, int offset, int bytes) { FILE* fd = _cdvdOpenNVM(); if (fd == NULL) return 1; + fseek(fd, offset, SEEK_SET); fread(dst, 1, bytes, fd); fclose(fd); + return 0; } s32 cdvdWriteNVM(const u8 *src, int offset, int bytes) { FILE* fd = _cdvdOpenNVM(); if (fd == NULL) return 1; + fseek(fd, offset, SEEK_SET); fwrite(src, 1, bytes, fd); fclose(fd); + return 0; } -#define GET_NVM_DATA(buff, offset, size, fmtOffset) \ -getNvmData(buff, offset, size, BiosVersion, offsetof(NVMLayout, fmtOffset)) -#define SET_NVM_DATA(buff, offset, size, fmtOffset) \ -setNvmData(buff, offset, size, BiosVersion, offsetof(NVMLayout, fmtOffset)) - -s32 getNvmData(u8* buffer, s32 offset, s32 size, u32 biosVersion, s32 fmtOffset) +NVMLayout* getNvmLayout(void) { - // find the correct bios version NVMLayout* nvmLayout = NULL; s32 nvmIdx; + for(nvmIdx=0; nvmIdx> 10) | ((0x01FFFFFF & letters) << 7); // numbers = 7F letters = FFFFFF80 @@ -592,28 +401,28 @@ void cdvdReadKey(u8 arg0, u16 arg1, u32 arg2, u8* key) { s32 cdvdGetToc(void* toc) { s32 ret = CDVDgetTOC(toc); - if(ret == -1) ret = 0x80; + if (ret == -1) ret = 0x80; return ret; } s32 cdvdReadSubQ(s32 lsn, cdvdSubQ* subq) { s32 ret = CDVDreadSubQ(lsn, subq); - if(ret == -1) ret = 0x80; + if (ret == -1) ret = 0x80; return ret; } s32 cdvdCtrlTrayOpen() { s32 ret = CDVDctrlTrayOpen(); - if(ret == -1) ret = 0x80; + if (ret == -1) ret = 0x80; return ret; } s32 cdvdCtrlTrayClose() { s32 ret = CDVDctrlTrayClose(); - if(ret == -1) ret = 0x80; + if (ret == -1) ret = 0x80; return ret; } @@ -622,10 +431,11 @@ s32 cdvdCtrlTrayClose() s32 cdvdGetTrayStatus() { s32 ret = CDVDgetTrayStatus(); - // get current tray state - never true - if (cdCaseopen) return(CDVD_TRAY_OPEN); - if (ret == -1) return(CDVD_TRAY_CLOSE); - return(ret); + + if (ret == -1) + return(CDVD_TRAY_CLOSE); + else + return(ret); } // Note: Is tray status being kept as a var here somewhere? @@ -635,10 +445,10 @@ s32 cdvdGetTrayStatus() __forceinline void cdvdGetDiskType() { // defs 0.9.0 - if(CDVDnewDiskCB || cdvd.Type != CDVD_TYPE_NODISC) return; + if (CDVDnewDiskCB || (cdvd.Type != CDVD_TYPE_NODISC)) return; // defs.0.8.1 - if(cdvdGetTrayStatus() == CDVD_TRAY_OPEN) + if (cdvdGetTrayStatus() == CDVD_TRAY_OPEN) { cdvd.Type = CDVD_TYPE_NODISC; return; @@ -650,6 +460,7 @@ __forceinline void cdvdGetDiskType() if (cdvd.Type == CDVD_TYPE_PS2CD) // && needReset == 1) { char str[g_MaxPath]; + if (GetPS2ElfName(str) == 1) { // Does the SYSTEM.CNF file only say "BOOT="? PS1 CD then. @@ -700,9 +511,6 @@ static s32 cdvdReadDvdDualInfo(s32* dualType, u32* layer1Start) return 1; } - -#include - static uint cdvdBlockReadTime( CDVD_MODE_TYPE mode ) { return (PSXCLK * cdvd.BlockSize) / (((mode==MODE_CDROM) ? PSX_CD_READSPEED : PSX_DVD_READSPEED) * cdvd.Speed); @@ -716,20 +524,19 @@ void cdvdReset() cdvd.Spinning = false; cdvd.sDataIn = 0x40; - cdvd.Ready = 0x4e; - cdCaseopen = 0; + cdvd.Ready = CDVD_READY2; cdvd.Speed = 4; cdvd.BlockSize = 2064; cdvd.Action = cdvdAction_None; cdvd.ReadTime = cdvdBlockReadTime( MODE_DVDROM ); - // any random valid date will do - cdvd.RTC.hour = 1; - cdvd.RTC.day = 25; - cdvd.RTC.month = 5; - cdvd.RTC.year = 7; //2007 + // any random valid date will do + cdvd.RTC.hour = 1; + cdvd.RTC.day = 25; + cdvd.RTC.month = 5; + cdvd.RTC.year = 7; //2007 - cdvdSetSystemTime( cdvd ); + cdvdSetSystemTime( cdvd ); } struct Freeze_v10Compat @@ -745,7 +552,7 @@ void SaveState::cdvdFreeze() FreezeTag( "cdvd" ); Freeze( cdvd ); - if( IsLoading() ) + if (IsLoading()) { // Make sure the Cdvd plugin has the expected track loaded into the buffer. // If cdvd.Readed is cleared it means we need to load the SeekToSector (ie, a @@ -760,11 +567,13 @@ void SaveState::cdvdFreeze() void cdvdNewDiskCB() { cdvd.Type = CDVDgetDiskType(); - if(cdvd.Type == CDVD_TYPE_PS2CD) { + + if (cdvd.Type == CDVD_TYPE_PS2CD) + { char str[g_MaxPath]; - if(GetPS2ElfName(str) == 1) { - cdvd.Type = CDVD_TYPE_PSCD; - } // ENDIF- Does the SYSTEM.CNF file only say "BOOT="? PS1 CD then. + + // Does the SYSTEM.CNF file only say "BOOT="? PS1 CD then. + if(GetPS2ElfName(str) == 1) cdvd.Type = CDVD_TYPE_PSCD; } } @@ -826,12 +635,12 @@ int cdvdReadSector() { lsn = ~(layer1Start+0x30000 - 1); } else - { + { // Assumed the other dualType is 0. // single layer disc // or on first layer of dual layer disc layerNum = 0; lsn += 0x30000; - } // ENDLONGIF- Assumed the other dualType is 0. + } mdest[0] = 0x20 | layerNum; mdest[1] = (u8)(lsn >> 16); @@ -873,8 +682,8 @@ int cdvdReadSector() { // Console::WriteLn("sector %x;%x;%x", params PSXMu8(madr+0), PSXMu8(madr+1), PSXMu8(madr+2)); - HW_DMA3_BCR_H16-= (cdvd.BlockSize / (HW_DMA3_BCR_L16*4)); - HW_DMA3_MADR+= cdvd.BlockSize; + HW_DMA3_BCR_H16 -= (cdvd.BlockSize / (HW_DMA3_BCR_L16*4)); + HW_DMA3_MADR += cdvd.BlockSize; return 0; } @@ -887,24 +696,24 @@ __forceinline void cdvdActionInterrupt() case cdvdAction_Seek: case cdvdAction_Standby: cdvd.Spinning = true; - cdvd.Ready = 0x40; + cdvd.Ready = CDVD_READY1; cdvd.Sector = cdvd.SeekToSector; cdvd.Status = CDVD_STATUS_SEEK_COMPLETE; break; case cdvdAction_Stop: cdvd.Spinning = false; - cdvd.Ready = 0x40; + cdvd.Ready = CDVD_READY1; cdvd.Sector = 0; - cdvd.Status = 0; + cdvd.Status = CDVD_STATUS_NONE; break; case cdvdAction_Break: // Make sure the cdvd action state is pretty well cleared: cdvd.Reading = 0; cdvd.Readed = 0; - cdvd.Ready = 0x4e; // should be 0x40 or something else? - cdvd.Status = 0; + cdvd.Ready = CDVD_READY2; // should be CDVD_READY1 or something else? + cdvd.Status = CDVD_STATUS_NONE; cdvd.RErr = 0; cdvd.nCommand = 0; break; @@ -921,8 +730,8 @@ __forceinline void cdvdReadInterrupt() { //Console::WriteLn("cdvdReadInterrupt %x %x %x %x %x", params cpuRegs.interrupt, cdvd.Readed, cdvd.Reading, cdvd.nSectors, (HW_DMA3_BCR_H16 * HW_DMA3_BCR_L16) *4); - cdvd.Ready = 0x00; - if (cdvd.Readed == 0) + cdvd.Ready = CDVD_NOTREADY; + if (!cdvd.Readed) { // Seeking finished. Process the track we requested before, and // then schedule another CDVD read int for when the block read finishes. @@ -943,8 +752,7 @@ __forceinline void cdvdReadInterrupt() CDVDREAD_INT(cdvd.ReadTime); return; } - - if (cdvd.Reading == 1) + else { if (cdvd.RErr == 0) cdr.pTransfer = CDVDgetBuffer(); @@ -963,7 +771,7 @@ __forceinline void cdvdReadInterrupt() return; } } - cdvd.Reading = 0; + cdvd.Reading = false; } if (cdvdReadSector() == -1) @@ -983,7 +791,7 @@ __forceinline void cdvdReadInterrupt() HW_DMA3_CHCR &= ~0x01000000; psxDmaInterrupt(3); - cdvd.Ready = 0x4e; + cdvd.Ready = CDVD_READY2; // All done! :D @@ -998,6 +806,65 @@ __forceinline void cdvdReadInterrupt() return; } +// Returns the number of IOP cycles until the event completes. +static uint cdvdStartSeek( uint newsector, CDVD_MODE_TYPE mode ) +{ + cdvd.SeekToSector = newsector; + + uint delta = abs(cdvd.SeekToSector - cdvd.Sector); + uint seektime; + + cdvd.Ready = CDVD_NOTREADY; + cdvd.Reading = 0; + cdvd.Readed = 0; + cdvd.Status = CDVD_STATUS_NONE; + + if( !cdvd.Spinning ) + { + CDR_LOG( "CdSpinUp > Simulating CdRom Spinup Time, and seek to sector %d", cdvd.SeekToSector ); + seektime = PSXCLK / 3; // 333ms delay + cdvd.Spinning = true; + } + else if( (tbl_ContigiousSeekDelta[mode] == 0) || (delta >= tbl_ContigiousSeekDelta[mode]) ) + { + // Select either Full or Fast seek depending on delta: + + if( delta >= tbl_FastSeekDelta[mode] ) + { + // Full Seek + CDR_LOG( "CdSeek Begin > to sector %d, from %d - delta=%d [FULL]", cdvd.SeekToSector, cdvd.Sector, delta ); + seektime = Cdvd_FullSeek_Cycles; + } + else + { + CDR_LOG( "CdSeek Begin > to sector %d, from %d - delta=%d [FAST]", cdvd.SeekToSector, cdvd.Sector, delta ); + seektime = Cdvd_FastSeek_Cycles; + } + } + else + { + CDR_LOG( "CdSeek Begin > Contiguous block without seek - delta=%d sectors", delta ); + + // seektime is the time it takes to read to the destination block: + seektime = delta * cdvd.ReadTime; + + if( delta == 0 ) + { + cdvd.Status = CDVD_STATUS_SEEK_COMPLETE; + cdvd.Readed = 1; // Note: 1, not 0, as implied by the next comment. Need to look into this. --arcum42 + cdvd.RetryCntP = 0; + + // setting Readed to 0 skips the seek logic, which means the next call to + // cdvdReadInterrupt will load a block. So make sure it's properly scheduled + // based on sector read speeds: + + seektime = cdvd.ReadTime; + } + } + + return seektime; +} + u8 monthmap[13] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; void cdvdVsync() { @@ -1030,282 +897,174 @@ void cdvdVsync() { cdvd.RTC.year = 0; } - -u8 cdvdRead04(void) { // NCOMMAND - CDR_LOG("cdvdRead04(NCMD) %x", cdvd.nCommand); - - return cdvd.nCommand; -} - -u8 cdvdRead05(void) { // N-READY - CDR_LOG("cdvdRead05(NReady) %x", cdvd.Ready); - - return cdvd.Ready; -} - -u8 cdvdRead06(void) { // ERROR - CDR_LOG("cdvdRead06(Error) %x", cdvd.Error); - - return cdvd.Error; -} - -u8 cdvdRead07(void) { // BREAK - CDR_LOG("cdvdRead07(Break) %x", 0); - - return 0; -} - -u8 cdvdRead08(void) { // INTR_STAT - CDR_LOG("cdvdRead08(IntrReason) %x", cdvd.PwOff); - - return cdvd.PwOff; -} - -u8 cdvdRead0A(void) { // STATUS - CDR_LOG("cdvdRead0A(Status) %x", cdvd.Status); - - return cdvd.Status; -} - -u8 cdvdRead0B(void) { // TRAY-STATE (if tray has been opened) - u8 tray = cdvdGetTrayStatus(); - CDR_LOG("cdvdRead0B(Tray) %x", tray); - - return tray; -} - -u8 cdvdRead0C(void) { // CRT MINUTE - CDR_LOG("cdvdRead0C(Min) %x", itob((u8)(cdvd.Sector/(60*75)))); - - return itob((u8)(cdvd.Sector/(60*75))); -} - -u8 cdvdRead0D(void) { // CRT SECOND - CDR_LOG("cdvdRead0D(Sec) %x", itob((u8)((cdvd.Sector/75)%60)+2)); - - return itob((u8)((cdvd.Sector/75)%60)+2); -} - -u8 cdvdRead0E(void) { // CRT FRAME - CDR_LOG("cdvdRead0E(Frame) %x", itob((u8)(cdvd.Sector%75))); - - return itob((u8)(cdvd.Sector%75)); -} - -u8 cdvdRead0F(void) // TYPE +static __forceinline u8 cdvdRead18(void) // SDATAOUT { - CDR_LOG("cdvdRead0F(Disc Type) %x", cdvd.Type); - cdvdGetDiskType(); - return cdvd.Type; -} - -u8 cdvdRead13(void) { // UNKNOWN - CDR_LOG("cdvdRead13(Unknown) %x", 4); - - return 4; -} - -u8 cdvdRead15(void) { // RSV - CDR_LOG("cdvdRead15(RSV)"); - - return 0x01; // | 0x80 for ATAPI mode -} - -u8 cdvdRead16(void) { // SCOMMAND - CDR_LOG("cdvdRead16(SCMD) %x", cdvd.sCommand); - - return cdvd.sCommand; -} - -u8 cdvdRead17(void) { // SREADY - CDR_LOG("cdvdRead17(SReady) %x", cdvd.sDataIn); - - return cdvd.sDataIn; -} - -u8 cdvdRead18(void) { // SDATAOUT u8 ret = 0; - if ((cdvd.sDataIn & 0x40) == 0) { - if (cdvd.ResultP < cdvd.ResultC) { - cdvd.ResultP++; - if (cdvd.ResultP >= cdvd.ResultC) cdvd.sDataIn|= 0x40; - ret = cdvd.Result[cdvd.ResultP-1]; - } + if (((cdvd.sDataIn & 0x40) == 0) && (cdvd.ResultP < cdvd.ResultC)) + { + cdvd.ResultP++; + if (cdvd.ResultP >= cdvd.ResultC) cdvd.sDataIn|= 0x40; + ret = cdvd.Result[cdvd.ResultP-1]; } CDR_LOG("cdvdRead18(SDataOut) %x (ResultC=%d, ResultP=%d)", ret, cdvd.ResultC, cdvd.ResultP); + return ret; } -u8 cdvdRead20(void) { - CDR_LOG("cdvdRead20(Key0) %x", cdvd.Key[0]); - - return cdvd.Key[0]; -} - -u8 cdvdRead21(void) { - CDR_LOG("cdvdRead21(Key1) %x", cdvd.Key[1]); - - return cdvd.Key[1]; -} - -u8 cdvdRead22(void) { - CDR_LOG("cdvdRead22(Key2) %x", cdvd.Key[2]); - - return cdvd.Key[2]; -} - -u8 cdvdRead23(void) { - CDR_LOG("cdvdRead23(Key3) %x", cdvd.Key[3]); - - return cdvd.Key[3]; -} - -u8 cdvdRead24(void) { - CDR_LOG("cdvdRead24(Key4) %x", cdvd.Key[4]); - - return cdvd.Key[4]; -} - -u8 cdvdRead28(void) { - CDR_LOG("cdvdRead28(Key5) %x", cdvd.Key[5]); - - return cdvd.Key[5]; -} - -u8 cdvdRead29(void) { - CDR_LOG("cdvdRead29(Key6) %x", cdvd.Key[6]); - - return cdvd.Key[6]; -} - -u8 cdvdRead2A(void) { - CDR_LOG("cdvdRead2A(Key7) %x", cdvd.Key[7]); - - return cdvd.Key[7]; -} - -u8 cdvdRead2B(void) { - CDR_LOG("cdvdRead2B(Key8) %x\n", cdvd.Key[8]); - - return cdvd.Key[8]; -} - -u8 cdvdRead2C(void) { - CDR_LOG("cdvdRead2C(Key9) %x", cdvd.Key[9]); - - return cdvd.Key[9]; -} - -u8 cdvdRead30(void) { - CDR_LOG("cdvdRead30(Key10) %x", cdvd.Key[10]); - - return cdvd.Key[10]; -} - -u8 cdvdRead31(void) { - CDR_LOG("cdvdRead31(Key11) %x", cdvd.Key[11]); - - return cdvd.Key[11]; -} - -u8 cdvdRead32(void) { - CDR_LOG("cdvdRead32(Key12) %x", cdvd.Key[12]); - - return cdvd.Key[12]; -} - -u8 cdvdRead33(void) { - CDR_LOG("cdvdRead33(Key13) %x", cdvd.Key[13]); - - return cdvd.Key[13]; -} - -u8 cdvdRead34(void) { - CDR_LOG("cdvdRead34(Key14) %x", cdvd.Key[14]); - - return cdvd.Key[14]; -} - -u8 cdvdRead38(void) { // valid parts of key data (first and last are valid) - CDR_LOG("cdvdRead38(KeysValid) %x", cdvd.Key[15]); - - return cdvd.Key[15]; -} - -u8 cdvdRead39(void) { // KEY-XOR - CDR_LOG("cdvdRead39(KeyXor) %x", cdvd.KeyXor); - - return cdvd.KeyXor; -} - -u8 cdvdRead3A(void) { // DEC_SET - CDR_LOG("cdvdRead3A(DecSet) %x", cdvd.decSet); - - Console::WriteLn("DecSet Read: %02X", params cdvd.decSet); - return cdvd.decSet; -} - - -// Returns the number of IOP cycles until the event completes. -static uint cdvdStartSeek( uint newsector, CDVD_MODE_TYPE mode ) +u8 cdvdRead(u8 key) { - cdvd.SeekToSector = newsector; - - uint delta = abs(cdvd.SeekToSector - cdvd.Sector); - uint seektime; - - cdvd.Ready = 0; - cdvd.Reading = 0; - cdvd.Readed = 0; - cdvd.Status = 0; - - if( !cdvd.Spinning ) + switch (key) { - CDR_LOG( "CdSpinUp > Simulating CdRom Spinup Time, and seek to sector %d", cdvd.SeekToSector ); - seektime = PSXCLK / 3; // 333ms delay - cdvd.Spinning = true; - } - else if( (tbl_ContigiousSeekDelta[mode] == 0) || (delta >= tbl_ContigiousSeekDelta[mode]) ) - { - // Select either Full or Fast seek depending on delta: + case 0x04: // NCOMMAND + CDR_LOG("cdvdRead04(NCMD) %x", cdvd.nCommand); + return cdvd.nCommand; + break; - if( delta >= tbl_FastSeekDelta[mode] ) - { - // Full Seek - CDR_LOG( "CdSeek Begin > to sector %d, from %d - delta=%d [FULL]", cdvd.SeekToSector, cdvd.Sector, delta ); - seektime = Cdvd_FullSeek_Cycles; - } - else - { - CDR_LOG( "CdSeek Begin > to sector %d, from %d - delta=%d [FAST]", cdvd.SeekToSector, cdvd.Sector, delta ); - seektime = Cdvd_FastSeek_Cycles; - } - } - else - { - CDR_LOG( "CdSeek Begin > Contiguous block without seek - delta=%d sectors", delta ); + case 0x05: // N-READY + CDR_LOG("cdvdRead05(NReady) %x", cdvd.Ready); + return cdvd.Ready; + break; - // seektime is the time it takes to read to the destination block: - seektime = delta * cdvd.ReadTime; - - if( delta == 0 ) + case 0x06: // ERROR + CDR_LOG("cdvdRead06(Error) %x", cdvd.Error); + return cdvd.Error; + break; + + case 0x07: // BREAK + CDR_LOG("cdvdRead07(Break) %x", 0); + return 0; + break; + + case 0x08: // STATUS + CDR_LOG("cdvdRead0A(Status) %x", cdvd.Status); + return cdvd.Status; + break; + + case 0x0A: // STATUS + CDR_LOG("cdvdRead0A(Status) %x", cdvd.Status); + return cdvd.Status; + break; + + case 0x0B: // TRAY-STATE (if tray has been opened) { - cdvd.Status = CDVD_STATUS_SEEK_COMPLETE; - cdvd.Readed = 1; - cdvd.RetryCntP = 0; - - // setting Readed to zero skips the seek logic, which means the next call to - // cdvdReadInterrupt will load a block. So make sure it's properly scheduled - // based on sector read speeds: - seektime = cdvd.ReadTime; + u8 tray = cdvdGetTrayStatus(); + CDR_LOG("cdvdRead0B(Tray) %x", tray); + return tray; + break; } + case 0x0C: // CRT MINUTE + CDR_LOG("cdvdRead0C(Min) %x", itob((u8)(cdvd.Sector/(60*75)))); + return itob((u8)(cdvd.Sector/(60*75))); + break; + + case 0x0D: // CRT SECOND + CDR_LOG("cdvdRead0D(Sec) %x", itob((u8)((cdvd.Sector/75)%60)+2)); + return itob((u8)((cdvd.Sector/75)%60)+2); + break; + + case 0x0E: // CRT FRAME + CDR_LOG("cdvdRead0E(Frame) %x", itob((u8)(cdvd.Sector%75))); + return itob((u8)(cdvd.Sector%75)); + break; + + case 0x0F: // TYPE + CDR_LOG("cdvdRead0F(Disc Type) %x", cdvd.Type); + cdvdGetDiskType(); + return cdvd.Type; + break; + + case 0x13: // UNKNOWN + CDR_LOG("cdvdRead13(Unknown) %x", 4); + return 4; + break; + + case 0x15: // RSV + CDR_LOG("cdvdRead15(RSV)"); + return 0x01; // | 0x80 for ATAPI mode + break; + + case 0x16: // SCOMMAND + CDR_LOG("cdvdRead16(SCMD) %x", cdvd.sCommand); + return cdvd.sCommand; + break; + + case 0x17: // SREADY + CDR_LOG("cdvdRead17(SReady) %x", cdvd.sDataIn); + return cdvd.sDataIn; + break; + + case 0x18: + return cdvdRead18(); + break; + + case 0x20: + case 0x21: + case 0x22: + case 0x23: + case 0x24: + { + int temp = key - 0x20; + + CDR_LOG("cdvdRead%d(Key%d) %x", key, temp, cdvd.Key[temp]); + return cdvd.Key[temp]; + break; + } + case 0x28: + case 0x29: + case 0x2A: + case 0x2B: + case 0x2C: + { + int temp = key - 0x23; + + CDR_LOG("cdvdRead%d(Key%d) %x", key, temp, cdvd.Key[temp]); + return cdvd.Key[temp]; + break; + } + + case 0x30: + case 0x31: + case 0x32: + case 0x33: + case 0x34: + { + int temp = key - 0x26; + + CDR_LOG("cdvdRead%d(Key%d) %x", key, temp, cdvd.Key[temp]); + return cdvd.Key[temp]; + break; + } + + case 0x38: // valid parts of key data (first and last are valid) + CDR_LOG("cdvdRead38(KeysValid) %x", cdvd.Key[15]); + + return cdvd.Key[15]; + break; + + case 0x39: // KEY-XOR + CDR_LOG("cdvdRead39(KeyXor) %x", cdvd.KeyXor); + + return cdvd.KeyXor; + break; + + case 0x3A: // DEC_SET + CDR_LOG("cdvdRead3A(DecSet) %x", cdvd.decSet); + + Console::WriteLn("DecSet Read: %02X", params cdvd.decSet); + return cdvd.decSet; + break; + + default: + // note: notify the console since this is a potentially serious emulation problem: + PSXHW_LOG("*Unknown 8bit read at address 0x1f4020%x", key); + Console::Error( "IOP Unknown 8bit read from addr 0x1f4020%x", params key ); + return 0; + break; } - - return seektime; } -void cdvdWrite04(u8 rt) { // NCOMMAND +static void cdvdWrite04(u8 rt) { // NCOMMAND CDR_LOG("cdvdWrite04: NCMD %s (%x) (ParamP = %x)", nCmdName[rt], rt, cdvd.ParamP); cdvd.nCommand = rt; @@ -1355,7 +1114,8 @@ void cdvdWrite04(u8 rt) { // NCOMMAND switch (cdvd.Param[10]) { case 2: cdvd.ReadMode = CDVD_MODE_2340; cdvd.BlockSize = 2340; break; case 1: cdvd.ReadMode = CDVD_MODE_2328; cdvd.BlockSize = 2328; break; - case 0: default: cdvd.ReadMode = CDVD_MODE_2048; cdvd.BlockSize = 2048; break; + case 0: + default: cdvd.ReadMode = CDVD_MODE_2048; cdvd.BlockSize = 2048; break; } CDR_LOG( "CdRead > startSector=%d, nSectors=%d, RetryCnt=%x, Speed=%x(%x), ReadMode=%x(%x) (1074=%x)", @@ -1377,15 +1137,20 @@ void cdvdWrite04(u8 rt) { // NCOMMAND // take priority in the handler anyway. If the read is contiguous then // this'll skip the seek delay. cdvd.Reading = 1; - break; + break; case N_CD_READ_CDDA: // CdReadCDDA case N_CD_READ_XCDDA: // CdReadXCDDA cdvd.SeekToSector = *(int*)(cdvd.Param+0); cdvd.nSectors = *(int*)(cdvd.Param+4); - if (cdvd.Param[8] == 0) cdvd.RetryCnt = 0x100; - else cdvd.RetryCnt = cdvd.Param[8]; + + if (cdvd.Param[8] == 0) + cdvd.RetryCnt = 0x100; + else + cdvd.RetryCnt = cdvd.Param[8]; + cdvd.SpindlCtrl = cdvd.Param[9]; + switch (cdvd.Param[9]) { case 0x01: cdvd.Speed = 1; break; case 0x02: cdvd.Speed = 2; break; @@ -1393,6 +1158,7 @@ void cdvdWrite04(u8 rt) { // NCOMMAND case 0x04: cdvd.Speed = 12; break; default: cdvd.Speed = 24; break; } + switch (cdvd.Param[10]) { case 1: cdvd.ReadMode = CDVD_MODE_2368; cdvd.BlockSize = 2368; break; case 2: @@ -1423,8 +1189,12 @@ void cdvdWrite04(u8 rt) { // NCOMMAND case N_DVD_READ: // DvdRead cdvd.SeekToSector = *(int*)(cdvd.Param+0); cdvd.nSectors = *(int*)(cdvd.Param+4); - if (cdvd.Param[8] == 0) cdvd.RetryCnt = 0x100; - else cdvd.RetryCnt = cdvd.Param[8]; + + if (cdvd.Param[8] == 0) + cdvd.RetryCnt = 0x100; + else + cdvd.RetryCnt = cdvd.Param[8]; + cdvd.SpindlCtrl = cdvd.Param[9]; cdvd.Speed = 4; cdvd.ReadMode = CDVD_MODE_2048; @@ -1490,7 +1260,7 @@ void cdvdWrite04(u8 rt) { // NCOMMAND cdvd.ParamC = 0; } -void cdvdWrite05(u8 rt) { // NDATAIN +static __forceinline void cdvdWrite05(u8 rt) { // NDATAIN CDR_LOG("cdvdWrite05(NDataIn) %x", rt); if (cdvd.ParamP < 32) { @@ -1499,17 +1269,17 @@ void cdvdWrite05(u8 rt) { // NDATAIN } } -void cdvdWrite06(u8 rt) { // HOWTO +static __forceinline void cdvdWrite06(u8 rt) { // HOWTO CDR_LOG("cdvdWrite06(HowTo) %x", rt); cdvd.HowTo = rt; } -void cdvdWrite07(u8 rt) // BREAK +static __forceinline void cdvdWrite07(u8 rt) // BREAK { CDR_LOG("cdvdWrite07(Break) %x", rt); // If we're already in a Ready state or already Breaking, then do nothing: - if ((cdvd.Ready != 0) || (cdvd.Action == cdvdAction_Break)) return; + if ((cdvd.Ready != CDVD_NOTREADY) || (cdvd.Action == cdvdAction_Break)) return; DbgCon::Notice("*PCSX2*: CDVD BREAK %x", params rt); @@ -1528,25 +1298,27 @@ void cdvdWrite07(u8 rt) // BREAK //cdvd.nCommand = 0; } -void cdvdWrite08(u8 rt) { // INTR_STAT +static __forceinline void cdvdWrite08(u8 rt) { // INTR_STAT CDR_LOG("cdvdWrite08(IntrReason) = ACK(%x)", rt); cdvd.PwOff &= ~rt; } -void cdvdWrite0A(u8 rt) { // STATUS +static __forceinline void cdvdWrite0A(u8 rt) { // STATUS CDR_LOG("cdvdWrite0A(Status) %x", rt); } -void cdvdWrite0F(u8 rt) { // TYPE +static __forceinline void cdvdWrite0F(u8 rt) { // TYPE CDR_LOG("cdvdWrite0F(Type) %x", rt); DevCon::WriteLn("*PCSX2*: CDVD TYPE %x", params rt); } -void cdvdWrite14(u8 rt) { // PS1 MODE?? +static __forceinline void cdvdWrite14(u8 rt) { // PS1 MODE?? u32 cycle = psxRegs.cycle; - if (rt == 0xFE) Console::Notice("*PCSX2*: go PS1 mode DISC SPEED = FAST"); - else Console::Notice("*PCSX2*: go PS1 mode DISC SPEED = %dX", params rt); + if (rt == 0xFE) + Console::Notice("*PCSX2*: go PS1 mode DISC SPEED = FAST"); + else + Console::Notice("*PCSX2*: go PS1 mode DISC SPEED = %dX", params rt); psxReset(); psxHu32(0x1f801450) = 0x8; @@ -1554,7 +1326,13 @@ void cdvdWrite14(u8 rt) { // PS1 MODE?? psxRegs.cycle = cycle; } -void cdvdWrite16(u8 rt) // SCOMMAND +static __forceinline void fail_pol_cal() +{ + Console::Error("[MG] ERROR - Make sure the file is already decrypted!!!"); + cdvd.Result[0] = 0x80; +} + +static void cdvdWrite16(u8 rt) // SCOMMAND { // cdvdTN diskInfo; // cdvdTD trackInfo; @@ -1566,7 +1344,6 @@ void cdvdWrite16(u8 rt) // SCOMMAND cdvd.sCommand = rt; switch (rt) { - // case 0x01: // GetDiscType - from cdvdman (0:1) // SetResultSize(1); // cdvd.Result[0] = 0; @@ -1632,7 +1409,6 @@ void cdvdWrite16(u8 rt) // SCOMMAND cdvd.Result[1] = itob(cdvd.RTC.second); //Seconds cdvd.Result[2] = itob(cdvd.RTC.minute); //Minutes cdvd.Result[3] = itob((cdvd.RTC.hour+8) %24); //Hours - cdvd.Result[4] = 0; //Nothing cdvd.Result[5] = itob(cdvd.RTC.day); //Day if(cdvd.Result[3] <= 7) cdvd.Result[5] += 1; @@ -1645,7 +1421,7 @@ void cdvdWrite16(u8 rt) // SCOMMAND break; case 0x09: // sceCdWriteRTC (7:1) - + SetResultSize(1); cdvd.Result[0] = 0; cdvd.RTC.pad = 0; @@ -1661,19 +1437,19 @@ void cdvdWrite16(u8 rt) // SCOMMAND Console::WriteLn("RTC Write Sec %d Min %d Hr %d Day %d Month %d Year %d", params cdvd.RTC.second, cdvd.RTC.minute, cdvd.RTC.hour, cdvd.RTC.day, cdvd.RTC.month, cdvd.RTC.year);*/ //memcpy_fast((u8*)&cdvd.RTC, cdvd.Param, 7); - SetResultSize(1); break; case 0x0A: // sceCdReadNVM (2:3) address = (cdvd.Param[0]<<8) | cdvd.Param[1]; + if (address < 512) { SetResultSize(3); cdvd.Result[0] = cdvdReadNVM(&cdvd.Result[1], address*2, 2); // swap bytes around - tmp = cdvd.Result[1]; - cdvd.Result[1] = cdvd.Result[2]; - cdvd.Result[2] = tmp; + tmp = cdvd.Result[1]; + cdvd.Result[1] = cdvd.Result[2]; + cdvd.Result[2] = tmp; } else { @@ -1683,14 +1459,15 @@ void cdvdWrite16(u8 rt) // SCOMMAND break; case 0x0B: // sceCdWriteNVM (4:1) - address = (cdvd.Param[0]<<8) | cdvd.Param[1]; SetResultSize(1); + address = (cdvd.Param[0]<<8) | cdvd.Param[1]; + if (address < 512) { // swap bytes around - tmp = cdvd.Param[2]; - cdvd.Param[2] = cdvd.Param[3]; - cdvd.Param[3] = tmp; + tmp = cdvd.Param[2]; + cdvd.Param[2] = cdvd.Param[3]; + cdvd.Param[3] = tmp; cdvd.Result[0] = cdvdWriteNVM(&cdvd.Param[2], address*2, 2); } else @@ -1848,7 +1625,7 @@ void cdvdWrite16(u8 rt) // SCOMMAND case 0x32: //sceCdGetMediumRemoval (0:2) SetResultSize(2); cdvd.Result[0] = 0; - cdvd.Result[0] = 0; + //cdvd.Result[0] = 0; // fixme: I'm pretty sure that the same variable shouldn't be set twice here. Perhaps cdvd.Result[1]? break; // case 0x33: //sceCdXDVRPReset (1:1) @@ -1856,6 +1633,7 @@ void cdvdWrite16(u8 rt) // SCOMMAND case 0x36: //cdvdman_call189 [__sceCdReadRegionParams - made up name] (0:15) i think it is 16, not 15 SetResultSize(15); + cdvdGetMechaVer(&cdvd.Result[1]); cdvd.Result[0] = cdvdReadRegionParams(&cdvd.Result[3]);//size==8 Console::WriteLn("REGION PARAMS = %s %s", params mg_zones[cdvd.Result[1]], &cdvd.Result[3]); @@ -1893,11 +1671,11 @@ void cdvdWrite16(u8 rt) // SCOMMAND break; case 0x40: // CdOpenConfig (3:1) + SetResultSize(1); cdvd.CReadWrite = cdvd.Param[0]; cdvd.COffset = cdvd.Param[1]; cdvd.CNumBlocks = cdvd.Param[2]; cdvd.CBlockIndex= 0; - SetResultSize(1); cdvd.Result[0] = 0; break; @@ -1912,23 +1690,23 @@ void cdvdWrite16(u8 rt) // SCOMMAND break; case 0x43: // CdCloseConfig (0:1) + SetResultSize(1); cdvd.CReadWrite = 0; - cdvd.COffset = 0; + cdvd.COffset = 0; cdvd.CNumBlocks = 0; cdvd.CBlockIndex= 0; - SetResultSize(1); cdvd.Result[0] = 0; break; case 0x80: // secrman: __mechacon_auth_0x80 - cdvd.mg_datatype = 0;//data SetResultSize(1);//in:1 + cdvd.mg_datatype = 0;//data cdvd.Result[0] = 0; break; case 0x81: // secrman: __mechacon_auth_0x81 - cdvd.mg_datatype = 0;//data SetResultSize(1);//in:1 + cdvd.mg_datatype = 0;//data cdvd.Result[0] = 0; break; @@ -2013,29 +1791,32 @@ void cdvdWrite16(u8 rt) // SCOMMAND case 0x88: // secrman: __mechacon_auth_0x88 //for now it is the same; so, fall;) case 0x8F: // secrman: __mechacon_auth_0x8F - // fixme: Needs a rewrite that doesn't involve gotos. SetResultSize(1);//in:0 if (cdvd.mg_datatype == 1) // header data { u64* psrc, *pdst; int bit_ofs, i; - if (cdvd.mg_maxsize != cdvd.mg_size) goto fail_pol_cal; - if (cdvd.mg_size < 0x20) goto fail_pol_cal; - if (cdvd.mg_size != *(u16*)&cdvd.mg_buffer[0x14]) goto fail_pol_cal; + if ((cdvd.mg_maxsize != cdvd.mg_size)||(cdvd.mg_size < 0x20) || (cdvd.mg_size != *(u16*)&cdvd.mg_buffer[0x14])) + { + fail_pol_cal(); + break; + } - SysPrintf("[MG] ELF_size=0x%X Hdr_size=0x%X unk=0x%X flags=0x%X count=%d zones=", - *(u32*)&cdvd.mg_buffer[0x10], *(u16*)&cdvd.mg_buffer[0x14], *(u16*)&cdvd.mg_buffer[0x16], + Console::Write("[MG] ELF_size=0x%X Hdr_size=0x%X unk=0x%X flags=0x%X count=%d zones=", + params *(u32*)&cdvd.mg_buffer[0x10], *(u16*)&cdvd.mg_buffer[0x14], *(u16*)&cdvd.mg_buffer[0x16], *(u16*)&cdvd.mg_buffer[0x18], *(u16*)&cdvd.mg_buffer[0x1A]); for (i=0; i<8; i++) - if (cdvd.mg_buffer[0x1C] & (1<> 0) & 0xFF; cdvd.Result[2] = (cdvd.mg_size >> 8) & 0xFF; break; } case 0x92: // sceMgWriteDatainLength + SetResultSize(1);//in:2 cdvd.mg_size = 0; cdvd.mg_datatype = 0;//data (encrypted) cdvd.mg_maxsize = cdvd.Param[0] | (((int)cdvd.Param[1])<<8); - SetResultSize(1);//in:2 cdvd.Result[0] = 0; // 0 complete ; 1 busy ; 0x80 error break; @@ -2137,17 +1917,18 @@ fail_pol_cal: default: // fake a 'correct' command - Console::WriteLn("SCMD Unknown %x", params rt); SetResultSize(1); //in:0 cdvd.Result[0] = 0; // 0 complete ; 1 busy ; 0x80 error + Console::WriteLn("SCMD Unknown %x", params rt); break; } // end switch - //SysPrintf("SCMD - %x\n", rt); - cdvd.ParamP = 0; cdvd.ParamC = 0; + //Console::WriteLn("SCMD - 0x%x\n", params rt); + cdvd.ParamP = 0; + cdvd.ParamC = 0; } -void cdvdWrite17(u8 rt) { // SDATAIN +static __forceinline void cdvdWrite17(u8 rt) { // SDATAIN CDR_LOG("cdvdWrite17(SDataIn) %x", rt); if (cdvd.ParamP < 32) { @@ -2156,13 +1937,35 @@ void cdvdWrite17(u8 rt) { // SDATAIN } } -void cdvdWrite18(u8 rt) { // SDATAOUT +static __forceinline void cdvdWrite18(u8 rt) { // SDATAOUT CDR_LOG("cdvdWrite18(SDataOut) %x", rt); Console::WriteLn("*PCSX2* SDATAOUT"); } -void cdvdWrite3A(u8 rt) { // DEC-SET +static __forceinline void cdvdWrite3A(u8 rt) { // DEC-SET CDR_LOG("cdvdWrite3A(DecSet) %x", rt); cdvd.decSet = rt; Console::WriteLn("DecSet Write: %02X", params cdvd.decSet); +} + +void cdvdWrite(u8 key, u8 rt) +{ + switch (key) + { + case 0x04: cdvdWrite04(rt); break; + case 0x05: cdvdWrite05(rt); break; + case 0x06: cdvdWrite06(rt); break; + case 0x07: cdvdWrite07(rt); break; + case 0x08: cdvdWrite08(rt); break; + case 0x0A: cdvdWrite0A(rt); break; + case 0x0F: cdvdWrite0F(rt); break; + case 0x14: cdvdWrite14(rt); break; + case 0x16: cdvdWrite16(rt); break; + case 0x17: cdvdWrite17(rt); break; + case 0x18: cdvdWrite18(rt); break; + case 0x3A: cdvdWrite3A(rt); break; + default: + Console::Notice("IOP Unknown 8bit write to addr 0x1f4020%x = 0x%x", params key, rt); + break; + } } \ No newline at end of file diff --git a/pcsx2/CDVD.h b/pcsx2/CDVD.h index 9eec464375..457e110926 100644 --- a/pcsx2/CDVD.h +++ b/pcsx2/CDVD.h @@ -62,8 +62,8 @@ struct cdvdStruct { u32 Sector; int nSectors; - int Readed; - int Reading; + int Readed; // change to bool. --arcum42 + int Reading; // same here. int ReadMode; int BlockSize; // Total bytes transfered at 1x speed int Speed; @@ -89,45 +89,229 @@ struct cdvdStruct { bool Spinning; // indicates if the Cdvd is spinning or needs a spinup delay }; +/* +Interrupts - values are flag bits. + +0x00 No interrupt +0x01 Data Ready +0x02 Command Complete +0x03 Acknowledge (reserved) +0x04 End of Data Detected +0x05 Error Detected +0x06 Drive Not Ready + +In limited experimentation I found that PS2 apps respond actively to use of the +'Data Ready' flag -- in that they'll almost immediately initiate a DMA transfer +after receiving an Irq with that as the cause. But the question is, of course, +*when* to use it. Adding it into some locations of CDVD reading only slowed +games down and broke things. + +Using Drive Not Ready also invokes basic error handling from the Iop Bios, but +without proper emulation of the cdvd status flag it also tends to break things. + +*/ + +enum CdvdIrqId +{ + Irq_None = 0 +, Irq_DataReady = 0 +, Irq_CommandComplete +, Irq_Acknowledge +, Irq_EndOfData +, Irq_Error +, Irq_NotReady + +}; + +/* is cdvd.Status only for NCMDS? (linuzappz) */ +enum cdvdStatus +{ + CDVD_STATUS_NONE = 0x00, // not sure ;) + CDVD_STATUS_SEEK_COMPLETE = 0x0A, +}; + +enum cdvdready +{ + CDVD_NOTREADY = 0x00, + CDVD_READY1 = 0x40, + CDVD_READY2 = 0x4e // This is used in a few places for some reason. + //It would be worth checking if this was just a typo made at some point. +}; + +// Cdvd actions tell the emulator how and when to respond to certain requests. +// Actions are handled by the cdvdInterrupt() +enum cdvdActions +{ + cdvdAction_None = 0 +, cdvdAction_Seek +, cdvdAction_Standby +, cdvdAction_Stop +, cdvdAction_Break +, cdvdAction_Read // note: not used yet. +}; + +////////////////////////////////////////////////////////////////////////////////////////// +// Cdvd Block Read Cycle Timings +// +// The PS2 CDVD effectively has two seek modes -- the normal/slow one (est. avg seeks being +// around 120-160ms), and a faster seek which has an estimated seek time of about 35-40ms. +// Fast seeks happen when the destination sector is within a certain range of the starting +// point, such that abs(start-dest) is less than the value in the tbl_FastSeekDelta. +// +// CDVDs also have a secondary seeking method used when the destination is close enough +// that a contiguous sector read can reach the sector faster than initiating a full seek. +// Typically this value is very low. + +enum CDVD_MODE_TYPE +{ + MODE_CDROM = 0, + MODE_DVDROM, +}; + +static const uint tbl_FastSeekDelta[3] = +{ + 4371, // CD-ROM + 14764, // Single-layer DVD-ROM + 13360 // dual-layer DVD-ROM [currently unused] +}; + +// if a seek is within this many blocks, read instead of seek. +// These values are arbitrary assumptions. Not sure what the real PS2 uses. +static const uint tbl_ContigiousSeekDelta[3] = +{ + 8, // CD-ROM + 16, // single-layer DVD-ROM + 16, // dual-layer DVD-ROM [currently unused] +}; + +// Note: DVD read times are modified to be faster, because games seem to be a lot more +// concerned with accurate(ish) seek delays and less concerned with actual block read speeds. +// Translation: it's a minor speedhack :D + +static const uint PSX_CD_READSPEED = 153600; // 1 Byte Time @ x1 (150KB = cd x 1) +static const uint PSX_DVD_READSPEED = 1382400 + 256000; // normal is 1 Byte Time @ x1 (1350KB = dvd x 1). + + +// Legacy Note: FullSeek timing causes many games to load very slow, but it likely not the real problem. +// Games breaking with it set to PSXCLK*40 : "wrath unleashed" and "Shijou Saikyou no Deshi Kenichi". + +static const uint Cdvd_FullSeek_Cycles = (PSXCLK*100) / 1000; // average number of cycles per fullseek (100ms) +static const uint Cdvd_FastSeek_Cycles = (PSXCLK*30) / 1000; // average number of cycles per fastseek (37ms) + +static const __unused char *mg_zones[8] = {"Japan", "USA", "Europe", "Oceania", "Asia", "Russia", "China", "Mexico"}; + +static const __unused char *nCmdName[0x100]= { + "CdSync", + "CdNop", + "CdStandby", + "CdStop", + "CdPause", + "CdSeek", + "CdRead", + "CdReadCDDA", + "CdReadDVDV", + "CdGetToc", + "", + "NCMD_B", + "CdReadKey", + "", + "sceCdReadXCDDA", + "sceCdChgSpdlCtrl", +}; + +enum nCmds +{ + N_CD_SYNC = 0x00, // CdSync + N_CD_NOP = 0x01, // CdNop + N_CD_STANDBY = 0x02, // CdStandby + N_CD_STOP = 0x03, // CdStop + N_CD_PAUSE = 0x04, // CdPause + N_CD_SEEK = 0x05, // CdSeek + N_CD_READ = 0x06, // CdRead + N_CD_READ_CDDA = 0x07, // CdReadCDDA + N_DVD_READ = 0x08, // DvdRead + N_CD_GET_TOC = 0x09, // CdGetToc & cdvdman_call19 + N_CMD_B = 0x0B, // CdReadKey + N_CD_READ_KEY = 0x0C, // CdReadKey + N_CD_READ_XCDDA = 0x0E, // CdReadXCDDA + N_CD_CHG_SPDL_CTRL = 0x0F, // CdChgSpdlCtrl +}; + +static const __unused char *sCmdName[0x100]= { + "", "sceCdGetDiscType", "sceCdReadSubQ", "subcommands",//sceCdGetMecaconVersion, read/write console id, read renewal date + "", "sceCdTrayState", "sceCdTrayCtrl", "", + "sceCdReadClock", "sceCdWriteClock", "sceCdReadNVM", "sceCdWriteNVM", + "sceCdSetHDMode", "", "", "sceCdPowerOff", + "", "", "sceCdReadILinkID", "sceCdWriteILinkID", /*10*/ + "sceAudioDigitalOut", "sceForbidDVDP", "sceAutoAdjustCtrl", "sceCdReadModelNumber", + "sceWriteModelNumber", "sceCdForbidCD", "sceCdBootCertify", "sceCdCancelPOffRdy", + "sceCdBlueLEDCtl", "", "sceRm2Read", "sceRemote2_7",//Rm2PortGetConnection? + "sceRemote2_6", "sceCdWriteWakeUpTime", "sceCdReadWakeUpTime", "", /*20*/ + "sceCdRcBypassCtl", "", "", "", + "", "sceCdNoticeGameStart", "", "", + "sceCdXBSPowerCtl", "sceCdXLEDCtl", "sceCdBuzzerCtl", "", + "", "sceCdSetMediumRemoval", "sceCdGetMediumRemoval", "sceCdXDVRPReset", /*30*/ + "", "", "__sceCdReadRegionParams", "__sceCdReadMAC", + "__sceCdWriteMAC", "", "", "", + "", "", "__sceCdWriteRegionParams", "", + "sceCdOpenConfig", "sceCdReadConfig", "sceCdWriteConfig", "sceCdCloseConfig", /*40*/ + "", "", "", "", + "", "", "", "", + "", "", "", "", + "", "", "", "", /*50*/ + "", "", "", "", + "", "", "", "", + "", "", "", "", + "", "", "", "", /*60*/ + "", "", "", "", + "", "", "", "", + "", "", "", "", + "", "", "", "", /*70*/ + "", "", "", "", + "", "", "", "", + "", "", "", "", + "mechacon_auth_0x80", "mechacon_auth_0x81", "mechacon_auth_0x82", "mechacon_auth_0x83", /*80*/ + "mechacon_auth_0x84", "mechacon_auth_0x85", "mechacon_auth_0x86", "mechacon_auth_0x87", + "mechacon_auth_0x88", "", "", "", + "", "sceMgWriteData", "sceMgReadData", "mechacon_auth_0x8F", + "sceMgWriteHeaderStart", "sceMgReadBITLength", "sceMgWriteDatainLength", "sceMgWriteDataoutLength", /*90*/ + "sceMgReadKbit", "sceMgReadKbit2", "sceMgReadKcon", "sceMgReadKcon2", + "sceMgReadIcvPs2", "", "", "", + "", "", "", "", + /*A0, no sCmds above?*/ +}; + +// NVM (eeprom) layout info +struct NVMLayout { + u32 biosVer; // bios version that this eeprom layout is for + s32 config0; // offset of 1st config block + s32 config1; // offset of 2nd config block + s32 config2; // offset of 3rd config block + s32 consoleId; // offset of console id (?) + s32 ilinkId; // offset of ilink id (ilink mac address) + s32 modelNum; // offset of ps2 model number (eg "SCPH-70002") + s32 regparams; // offset of RegionParams for PStwo + s32 mac; // offset of the value written to 0xFFFE0188 and 0xFFFE018C on PStwo +}; + +#define NVM_FORMAT_MAX 2 +static NVMLayout nvmlayouts[NVM_FORMAT_MAX] = +{ + {0x000, 0x280, 0x300, 0x200, 0x1C8, 0x1C0, 0x1A0, 0x180, 0x198}, // eeproms from bios v0.00 and up + {0x146, 0x270, 0x2B0, 0x200, 0x1C8, 0x1E0, 0x1B0, 0x180, 0x198}, // eeproms from bios v1.70 and up +}; + +#define btoi(b) ((b)/16*10 + (b)%16) /* BCD to u_char */ +#define itob(i) ((i)/10*16 + (i)%10) /* u_char to BCD */ + void cdvdReset(); void cdvdVsync(); extern void cdvdActionInterrupt(); extern void cdvdReadInterrupt(); void cdvdNewDiskCB(); -u8 cdvdRead04(void); -u8 cdvdRead05(void); -u8 cdvdRead06(void); -u8 cdvdRead07(void); -u8 cdvdRead08(void); -u8 cdvdRead0A(void); -u8 cdvdRead0B(void); -u8 cdvdRead0C(void); -u8 cdvdRead0D(void); -u8 cdvdRead0E(void); -u8 cdvdRead0F(void); -u8 cdvdRead13(void); -u8 cdvdRead15(void); -u8 cdvdRead16(void); -u8 cdvdRead17(void); +u8 cdvdRead(u8 key); u8 cdvdRead18(void); -u8 cdvdRead20(void); -u8 cdvdRead21(void); -u8 cdvdRead22(void); -u8 cdvdRead23(void); -u8 cdvdRead24(void); -u8 cdvdRead28(void); -u8 cdvdRead29(void); -u8 cdvdRead2A(void); -u8 cdvdRead2B(void); -u8 cdvdRead2C(void); -u8 cdvdRead30(void); -u8 cdvdRead31(void); -u8 cdvdRead32(void); -u8 cdvdRead33(void); -u8 cdvdRead34(void); -u8 cdvdRead38(void); -u8 cdvdRead39(void); -u8 cdvdRead3A(void); +void cdvdWrite(u8 key, u8 rt); void cdvdWrite04(u8 rt); void cdvdWrite05(u8 rt); void cdvdWrite06(u8 rt); @@ -143,5 +327,5 @@ void cdvdWrite3A(u8 rt); // Platform dependent system time assignment (see WinMisc / LnxMisc) extern void cdvdSetSystemTime( cdvdStruct& setme ); - + #endif /* __CDVD_H__ */ diff --git a/pcsx2/Interpreter.cpp b/pcsx2/Interpreter.cpp index 796f9e746a..8becc344ae 100644 --- a/pcsx2/Interpreter.cpp +++ b/pcsx2/Interpreter.cpp @@ -183,10 +183,10 @@ void BGEZ() // Branch if Rs >= 0 void BGEZAL() // Branch if Rs >= 0 and link { - _SetLink(31); if (cpuRegs.GPR.r[_Rs_].SD[0] >= 0) { + _SetLink(31); doBranch(_BranchTarget_); } } @@ -217,9 +217,9 @@ void BLTZ() // Branch if Rs < 0 void BLTZAL() // Branch if Rs < 0 and link { - _SetLink(31); if (cpuRegs.GPR.r[_Rs_].SD[0] < 0) { + _SetLink(31); doBranch(_BranchTarget_); } } @@ -310,10 +310,10 @@ void BGEZL() // Branch if Rs >= 0 void BLTZALL() // Branch if Rs < 0 and link { - _SetLink(31); if(cpuRegs.GPR.r[_Rs_].SD[0] < 0) { + _SetLink(31); doBranch(_BranchTarget_); } else @@ -325,10 +325,10 @@ void BLTZALL() // Branch if Rs < 0 and link void BGEZALL() // Branch if Rs >= 0 and link { - _SetLink(31); if(cpuRegs.GPR.r[_Rs_].SD[0] >= 0) { + _SetLink(31); doBranch(_BranchTarget_); } else diff --git a/pcsx2/IopHw.cpp b/pcsx2/IopHw.cpp index cf50b84ac1..de7eafadd6 100644 --- a/pcsx2/IopHw.cpp +++ b/pcsx2/IopHw.cpp @@ -1313,76 +1313,25 @@ void psxHwWrite32(u32 add, u32 value) { PSXHW_LOG("*Known 32bit write at address %lx value %lx", add, value); } -u8 psxHw4Read8(u32 add) { - u8 hard; - - switch (add) { - case 0x1f402004: return cdvdRead04(); - case 0x1f402005: return cdvdRead05(); - case 0x1f402006: return cdvdRead06(); - case 0x1f402007: return cdvdRead07(); - case 0x1f402008: return cdvdRead08(); - case 0x1f40200A: return cdvdRead0A(); - case 0x1f40200B: return cdvdRead0B(); - case 0x1f40200C: return cdvdRead0C(); - case 0x1f40200D: return cdvdRead0D(); - case 0x1f40200E: return cdvdRead0E(); - case 0x1f40200F: return cdvdRead0F(); - case 0x1f402013: return cdvdRead13(); - case 0x1f402015: return cdvdRead15(); - case 0x1f402016: return cdvdRead16(); - case 0x1f402017: return cdvdRead17(); - case 0x1f402018: return cdvdRead18(); - case 0x1f402020: return cdvdRead20(); - case 0x1f402021: return cdvdRead21(); - case 0x1f402022: return cdvdRead22(); - case 0x1f402023: return cdvdRead23(); - case 0x1f402024: return cdvdRead24(); - case 0x1f402028: return cdvdRead28(); - case 0x1f402029: return cdvdRead29(); - case 0x1f40202A: return cdvdRead2A(); - case 0x1f40202B: return cdvdRead2B(); - case 0x1f40202C: return cdvdRead2C(); - case 0x1f402030: return cdvdRead30(); - case 0x1f402031: return cdvdRead31(); - case 0x1f402032: return cdvdRead32(); - case 0x1f402033: return cdvdRead33(); - case 0x1f402034: return cdvdRead34(); - case 0x1f402038: return cdvdRead38(); - case 0x1f402039: return cdvdRead39(); - case 0x1f40203A: return cdvdRead3A(); - default: - // note: notify the console since this is a potentially serious emulation problem: - PSXHW_LOG("*Unknown 8bit read at address 0x%x", add); - Console::Error( "IOP Unknown 8bit read from addr 0x%x", params add ); - return 0; - } +u8 psxHw4Read8(u32 add) +{ + //u8 hard; + u16 mem = add & 0xFF; - PSXHW_LOG( "Known 8bit read from addr 0x%x = 0x%x", add, hard ); + //Console::WriteLn("psxHw4Read8 0x%x, %x", params add, mem); + return cdvdRead(mem); + + //PSXHW_LOG( "Known 8bit read from addr 0x%x = 0x%x", add, hard ); - return hard; + //return hard; } -void psxHw4Write8(u32 add, u8 value) { +void psxHw4Write8(u32 add, u8 value) +{ - switch (add) { - case 0x1f402004: cdvdWrite04(value); return; - case 0x1f402005: cdvdWrite05(value); return; - case 0x1f402006: cdvdWrite06(value); return; - case 0x1f402007: cdvdWrite07(value); return; - case 0x1f402008: cdvdWrite08(value); return; - case 0x1f40200A: cdvdWrite0A(value); return; - case 0x1f40200F: cdvdWrite0F(value); return; - case 0x1f402014: cdvdWrite14(value); return; - case 0x1f402016: cdvdWrite16(value); return; - case 0x1f402017: cdvdWrite17(value); return; - case 0x1f402018: cdvdWrite18(value); return; - case 0x1f40203A: cdvdWrite3A(value); return; - default: - //PSXHW_LOG("*Unknown 8bit write at address %lx value %x", add, value); - Console::Notice("IOP Unknown 8bit write to addr 0x%x = 0x%x", params add, value); - return; - } + u16 mem = add & 0xFF; + //Console::WriteLn("psxHw4Write8 0x%x, %x", params add, mem); + cdvdWrite(mem, value); PSXHW_LOG("Known 8bit write to addr 0x%x = 0x%x", add, value); } From 45bb6f3d2fc3ff009aa0c80483ae26c1977cd276 Mon Sep 17 00:00:00 2001 From: "Jake.Stine" Date: Fri, 1 May 2009 12:44:18 +0000 Subject: [PATCH 28/41] Bugfix for recent cleanups: SetResultSize was defined with different behaviors in two separate files, without being static. Depending on the whims of the wind, MSVC would sometimes pick the one from CDROM and link it into CDVD, overriding CDVD's version, and resulting in complete emulation failure. git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1103 96395faa-99c1-11dd-bbfe-3dabce05a288 --- pcsx2/CDVD.cpp | 4 ++-- pcsx2/CdRom.cpp | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/pcsx2/CDVD.cpp b/pcsx2/CDVD.cpp index 1894559b09..79e6a4b30f 100644 --- a/pcsx2/CDVD.cpp +++ b/pcsx2/CDVD.cpp @@ -26,7 +26,7 @@ static cdvdStruct cdvd; -__forceinline void SetResultSize(u8 size) +static __forceinline void SetResultSize(u8 size) { cdvd.ResultC = size; cdvd.ResultP = 0; @@ -442,7 +442,7 @@ s32 cdvdGetTrayStatus() // cdvdNewDiskCB() can update it's status as well... // Modified by (efp) - 16/01/2006 -__forceinline void cdvdGetDiskType() +static __forceinline void cdvdGetDiskType() { // defs 0.9.0 if (CDVDnewDiskCB || (cdvd.Type != CDVD_TYPE_NODISC)) return; diff --git a/pcsx2/CdRom.cpp b/pcsx2/CdRom.cpp index e9b4e6eb00..bb2f022b7a 100644 --- a/pcsx2/CdRom.cpp +++ b/pcsx2/CdRom.cpp @@ -112,13 +112,13 @@ static __forceinline void StopCdda() { } } -__forceinline void SetResultSize(u8 size) { +static __forceinline void SetResultSize(u8 size) { cdr.ResultP = 0; cdr.ResultC = size; cdr.ResultReady = 1; } -__forceinline s32 MSFtoLSN(u8 *Time) { +static __forceinline s32 MSFtoLSN(u8 *Time) { u32 lsn; lsn = Time[2]; @@ -127,7 +127,7 @@ __forceinline s32 MSFtoLSN(u8 *Time) { return lsn; } -void LSNtoMSF(u8 *Time, s32 lsn) { +static __forceinline void LSNtoMSF(u8 *Time, s32 lsn) { lsn += 150; Time[2] = lsn / 4500; // minuten lsn = lsn - Time[2] * 4500; // minuten rest @@ -135,7 +135,7 @@ void LSNtoMSF(u8 *Time, s32 lsn) { Time[0] = lsn - Time[1] * 75; // sekunden rest } -void ReadTrack() { +static void ReadTrack() { cdr.Prev[0] = itob(cdr.SetSector[0]); cdr.Prev[1] = itob(cdr.SetSector[1]); cdr.Prev[2] = itob(cdr.SetSector[2]); @@ -152,7 +152,7 @@ void ReadTrack() { #define DataEnd 4 #define DiskError 5 -void AddIrqQueue(u8 irq, unsigned long ecycle) { +static void AddIrqQueue(u8 irq, unsigned long ecycle) { cdr.Irq = irq; if (cdr.Stat) { cdr.eCycle = ecycle; From 74e0e786b773c63aa736f8d6d32efae4ca9dbc64 Mon Sep 17 00:00:00 2001 From: arcum42 Date: Sat, 2 May 2009 00:51:17 +0000 Subject: [PATCH 29/41] Begin work on renovating the Null plugins. (On the Linux side, anyways, though some of that will spill over to the Windows side.) Starting with FWnull. git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1105 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/FWnull/FW.c | 147 ---- plugins/FWnull/FW.h | 39 +- plugins/FWnull/Linux/{conf.c => Config.cpp} | 313 +++++---- plugins/FWnull/Linux/Config.h | 9 +- plugins/FWnull/Linux/{Linux.c => Linux.cpp} | 36 +- plugins/FWnull/Linux/{Config.c => Linux.h} | 40 +- plugins/FWnull/Linux/callbacks.c | 34 - plugins/FWnull/Linux/firewire.glade | 743 ++++++++++++-------- plugins/FWnull/Linux/interface.c | 219 ------ plugins/FWnull/Linux/support.c | 162 ----- plugins/FWnull/Linux/support.h | 37 +- plugins/FWnull/Makefile.am | 33 + plugins/FWnull/Windows/FWnull_vc2008.vcproj | 2 +- plugins/FWnull/Windows/Win32.c | 2 +- plugins/FWnull/build.sh | 23 +- plugins/FWnull/configure.ac | 80 +++ plugins/FWnull/install-sh | 1 + plugins/FWnull/missing | 1 + 18 files changed, 849 insertions(+), 1072 deletions(-) delete mode 100644 plugins/FWnull/FW.c rename plugins/FWnull/Linux/{conf.c => Config.cpp} (70%) rename plugins/FWnull/Linux/{Linux.c => Linux.cpp} (80%) rename plugins/FWnull/Linux/{Config.c => Linux.h} (55%) delete mode 100644 plugins/FWnull/Linux/callbacks.c delete mode 100644 plugins/FWnull/Linux/interface.c delete mode 100644 plugins/FWnull/Linux/support.c create mode 100644 plugins/FWnull/Makefile.am create mode 100644 plugins/FWnull/configure.ac create mode 120000 plugins/FWnull/install-sh create mode 120000 plugins/FWnull/missing diff --git a/plugins/FWnull/FW.c b/plugins/FWnull/FW.c deleted file mode 100644 index 5d94cae073..0000000000 --- a/plugins/FWnull/FW.c +++ /dev/null @@ -1,147 +0,0 @@ -/* FWnull - * Copyright (C) 2004-2005 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include -#include -#include - -#include "FW.h" - -const unsigned char version = PS2E_FW_VERSION; -const unsigned char revision = 0; -const unsigned char build = 4; // increase that with each version - -static char *libraryName = "FWnull Driver"; - -s8 *fwregs; - -#define fwRs32(mem) (*(s32*)&fwregs[(mem) & 0xffff]) -#define fwRu32(mem) (*(u32*)&fwregs[(mem) & 0xffff]) - - -u32 CALLBACK PS2EgetLibType() { - return PS2E_LT_FW; -} - -char* CALLBACK PS2EgetLibName() { - return libraryName; -} - -u32 CALLBACK PS2EgetLibVersion2(u32 type) { - return (version<<16) | (revision<<8) | build; -} - -void __Log(char *fmt, ...) { - va_list list; - - if (!conf.Log || fwLog == NULL) return; - - va_start(list, fmt); - vfprintf(fwLog, fmt, list); - va_end(list); -} - -s32 CALLBACK FWinit() { - LoadConfig(); -#ifdef FW_LOG - fwLog = fopen("logs/fwLog.txt", "w"); - if (fwLog) setvbuf(fwLog, NULL, _IONBF, 0); - FW_LOG("FWnull plugin version %d,%d\n",revision,build); - FW_LOG("FW init\n"); -#endif - - fwregs = (s8*)malloc(0x10000); - if (fwregs == NULL) { - SysMessage("Error allocating Memory\n"); return -1; - } - - return 0; -} - -void CALLBACK FWshutdown() { - free(fwregs); - -#ifdef FW_LOG - if (fwLog) fclose(fwLog); -#endif -} - -s32 CALLBACK FWopen(void *pDsp) { -#ifdef FW_LOG - FW_LOG("FW open\n"); -#endif - -#ifdef _WIN32 -#else - //Display* dsp = *(Display**)pDsp; -#endif - - return 0; -} - -void CALLBACK FWclose() { -} - - - - -u32 CALLBACK FWread32(u32 addr) { - u32 ret=0; - - switch (addr) { - case 0x1f808410: - ret = 0x8; - break; - - default: - ret = fwRu32(addr); - } -#ifdef FW_LOG - FW_LOG("FW read mem 0x%x: 0x%x\n", addr, ret); -#endif - - return ret; -} - - - -void CALLBACK FWwrite32(u32 addr, u32 value) { - switch (addr) { - default: - fwRu32(addr) = value; - break; - } -#ifdef FW_LOG - FW_LOG("FW write mem 0x%x: 0x%x\n", addr, value); -#endif -} - -void CALLBACK FWirqCallback(void (*callback)()) { - FWirq = callback; -} - - -s32 CALLBACK FWfreeze(int mode, freezeData *data) { - return 0; -} - - -s32 CALLBACK FWtest() { - return 0; -} - diff --git a/plugins/FWnull/FW.h b/plugins/FWnull/FW.h index 56d23fcd2d..d9008a3df7 100644 --- a/plugins/FWnull/FW.h +++ b/plugins/FWnull/FW.h @@ -1,5 +1,5 @@ -/* FWnull - * Copyright (C) 2004-2005 PCSX2 Team +/* FWnull + * Copyright (C) 2004-2009 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 @@ -15,15 +15,17 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - - + #ifndef __FW_H__ #define __FW_H__ #include +extern "C" +{ #define FWdefs #include "PS2Edefs.h" +} #ifdef _WIN32 @@ -35,25 +37,32 @@ #include #include -#define __inline inline +#endif +#ifdef _MSC_VER +#define EXPORT_C_(type) extern "C" __declspec(dllexport) type CALLBACK +#else +#define EXPORT_C_(type) extern "C" type #endif #define FW_LOG __Log -typedef struct { - int Log; +#define fwRs32(mem) (*(s32*)&fwregs[(mem) & 0xffff]) +#define fwRu32(mem) (*(u32*)&fwregs[(mem) & 0xffff]) + +typedef struct +{ + int Log; } Config; -Config conf; -void (*FWirq)(); +extern Config conf; +extern FILE *fwLog; -void SaveConfig(); -void LoadConfig(); +extern void (*FWirq)(); -FILE *fwLog; -void __Log(char *fmt, ...); - -void SysMessage(char *fmt, ...); +extern void __Log(char *fmt, ...); +extern void SysMessage(char *fmt, ...); +extern void SaveConfig(); +extern void LoadConfig(); #endif diff --git a/plugins/FWnull/Linux/conf.c b/plugins/FWnull/Linux/Config.cpp similarity index 70% rename from plugins/FWnull/Linux/conf.c rename to plugins/FWnull/Linux/Config.cpp index fe50bbd14a..515914ca1b 100644 --- a/plugins/FWnull/Linux/conf.c +++ b/plugins/FWnull/Linux/Config.cpp @@ -1,134 +1,179 @@ -/* FireWire - * Copyright (C) 2002-2004 FireWire 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include -#include -#include -#include -#include -#include - -#include "interface.h" -#include "support.h" -#include "callbacks.h" -#include "FW.h" -#include "Config.h" - -GtkWidget *MsgDlg; - -void OnMsg_Ok() { - gtk_widget_destroy(MsgDlg); - gtk_main_quit(); -} - -void cfgSysMessage(char *fmt, ...) { - GtkWidget *Ok,*Txt; - GtkWidget *Box,*Box1; - va_list list; - char msg[512]; - - va_start(list, fmt); - vsprintf(msg, fmt, list); - va_end(list); - - if (msg[strlen(msg)-1] == '\n') msg[strlen(msg)-1] = 0; - - MsgDlg = gtk_window_new (GTK_WINDOW_POPUP); - gtk_window_set_position(GTK_WINDOW(MsgDlg), GTK_WIN_POS_CENTER); - gtk_window_set_title(GTK_WINDOW(MsgDlg), "FireWire Msg"); - gtk_container_set_border_width(GTK_CONTAINER(MsgDlg), 5); - - Box = gtk_vbox_new(5, 0); - gtk_container_add(GTK_CONTAINER(MsgDlg), Box); - gtk_widget_show(Box); - - Txt = gtk_label_new(msg); - - gtk_box_pack_start(GTK_BOX(Box), Txt, FALSE, FALSE, 5); - gtk_widget_show(Txt); - - Box1 = gtk_hbutton_box_new(); - gtk_box_pack_start(GTK_BOX(Box), Box1, FALSE, FALSE, 0); - gtk_widget_show(Box1); - - Ok = gtk_button_new_with_label("Ok"); - gtk_signal_connect (GTK_OBJECT(Ok), "clicked", GTK_SIGNAL_FUNC(OnMsg_Ok), NULL); - gtk_container_add(GTK_CONTAINER(Box1), Ok); - GTK_WIDGET_SET_FLAGS(Ok, GTK_CAN_DEFAULT); - gtk_widget_show(Ok); - - gtk_widget_show(MsgDlg); - - gtk_main(); -} - -GtkWidget *About; - -void OnAbout_Ok(GtkButton *button, gpointer user_data) { - gtk_widget_destroy(About); - gtk_main_quit(); -} - -void CFGabout() { - About = create_About(); - gtk_widget_show_all(About); - gtk_main(); -} - -GtkWidget *Conf; - -void OnConf_Ok(GtkButton *button, gpointer user_data) { - SaveConfig(); - - gtk_widget_destroy(Conf); - gtk_main_quit(); -} - -void OnConf_Cancel(GtkButton *button, gpointer user_data) { - gtk_widget_destroy(Conf); - gtk_main_quit(); -} - -void CFGconfigure() { - Conf = create_Config(); - - LoadConfig(); - - gtk_widget_show_all(Conf); - gtk_main(); -} - -long CFGmessage(char *msg) { - cfgSysMessage(msg); - - return 0; -} - -int main(int argc, char *argv[]) { - gtk_init(NULL, NULL); - - if (!strcmp(argv[1], "configure")) { - CFGconfigure(); - } else if (!strcmp(argv[1], "about")) { - CFGabout(); - } else if (!strcmp(argv[1], "message")) { - CFGmessage(argv[2]); - } - - return 0; -} +/* FWnull + * Copyright (C) 2004-2009 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include +#include +#include +#include +#include +#include +#include +#include +using namespace std; + +#include "FW.h" +#include "Config.h" + +extern "C" +{ +#include "interface.h" +#include "support.h" +//#include "callbacks.h" +} + +GtkWidget *MsgDlg, *About, *Conf; +extern string s_strIniPath; + +void OnMsg_Ok() +{ + gtk_widget_destroy(MsgDlg); + gtk_main_quit(); +} + +void cfgSysMessage(char *fmt, ...) +{ + GtkWidget *Ok,*Txt; + GtkWidget *Box,*Box1; + va_list list; + char msg[512]; + + va_start(list, fmt); + vsprintf(msg, fmt, list); + va_end(list); + + if (msg[strlen(msg) - 1] == '\n') msg[strlen(msg)-1] = 0; + + MsgDlg = gtk_window_new (GTK_WINDOW_POPUP); + gtk_window_set_position(GTK_WINDOW(MsgDlg), GTK_WIN_POS_CENTER); + gtk_window_set_title(GTK_WINDOW(MsgDlg), "FireWire Msg"); + gtk_container_set_border_width(GTK_CONTAINER(MsgDlg), 5); + + Box = gtk_vbox_new(5, 0); + gtk_container_add(GTK_CONTAINER(MsgDlg), Box); + gtk_widget_show(Box); + + Txt = gtk_label_new(msg); + + gtk_box_pack_start(GTK_BOX(Box), Txt, FALSE, FALSE, 5); + gtk_widget_show(Txt); + + Box1 = gtk_hbutton_box_new(); + gtk_box_pack_start(GTK_BOX(Box), Box1, FALSE, FALSE, 0); + gtk_widget_show(Box1); + + Ok = gtk_button_new_with_label("Ok"); + gtk_signal_connect (GTK_OBJECT(Ok), "clicked", GTK_SIGNAL_FUNC(OnMsg_Ok), NULL); + gtk_container_add(GTK_CONTAINER(Box1), Ok); + GTK_WIDGET_SET_FLAGS(Ok, GTK_CAN_DEFAULT); + gtk_widget_show(Ok); + + gtk_widget_show(MsgDlg); + + gtk_main(); +} + +void OnAbout_Ok(GtkButton *button, gpointer user_data) +{ + gtk_widget_destroy(About); + gtk_main_quit(); +} + +void CFGabout() +{ + About = create_About(); + gtk_widget_show_all(About); + gtk_main(); +} + +void OnConf_Ok(GtkButton *button, gpointer user_data) { + SaveConfig(); + + gtk_widget_destroy(Conf); + gtk_main_quit(); +} + +void OnConf_Cancel(GtkButton *button, gpointer user_data) +{ + gtk_widget_destroy(Conf); + gtk_main_quit(); +} + +void CFGconfigure() +{ + Conf = create_Config(); + + LoadConfig(); + + gtk_widget_show_all(Conf); + gtk_main(); +} + +long CFGmessage(char *msg) { + cfgSysMessage(msg); + + return 0; +} + +/*int main(int argc, char *argv[]) { + gtk_init(NULL, NULL); + + if (!strcmp(argv[1], "configure")) { + CFGconfigure(); + } else if (!strcmp(argv[1], "about")) { + CFGabout(); + } else if (!strcmp(argv[1], "message")) { + CFGmessage(argv[2]); + } + + return 0; +}*/ + +void LoadConfig() +{ + FILE *f; + char cfg[255]; + + strcpy(cfg, s_strIniPath.c_str()); + f = fopen(cfg, "r"); + if (f == NULL) + { + printf("failed to open %s\n", s_strIniPath.c_str()); + SaveConfig();//save and return + return; + } + //fscanf(f, "options = %hhx\n", &confOptions); + fclose(f); +} + +void SaveConfig() +{ + FILE *f; + char cfg[255]; + + strcpy(cfg, s_strIniPath.c_str()); + f = fopen(cfg,"w"); + if (f == NULL) + { + printf("failed to open %s\n", s_strIniPath.c_str()); + return; + } + + //fprintf(f, "options = %hhx\n", confOptions); + fclose(f); +} + diff --git a/plugins/FWnull/Linux/Config.h b/plugins/FWnull/Linux/Config.h index 21577711de..824a7dafe7 100644 --- a/plugins/FWnull/Linux/Config.h +++ b/plugins/FWnull/Linux/Config.h @@ -1,5 +1,5 @@ -/* USBlinuz - * Copyright (C) 2002-2004 USBlinuz Team +/* FWnull + * Copyright (C) 2004-2009 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 @@ -18,3 +18,8 @@ void SaveConf(); void LoadConf(); + +extern long CFGmessage(char *msg); +extern void CFGconfigure(); +extern void cfgSysMessage(char *fmt, ...); +extern void CFGabout(); diff --git a/plugins/FWnull/Linux/Linux.c b/plugins/FWnull/Linux/Linux.cpp similarity index 80% rename from plugins/FWnull/Linux/Linux.c rename to plugins/FWnull/Linux/Linux.cpp index 90fa763510..38d86a5057 100644 --- a/plugins/FWnull/Linux/Linux.c +++ b/plugins/FWnull/Linux/Linux.cpp @@ -1,5 +1,5 @@ -/* FireWire - * Copyright (C) 2002-2004 FireWire Team +/* FWnull + * Copyright (C) 2004-2009 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 @@ -26,10 +26,11 @@ #include #include "FW.h" +#include "Config.h" int ExecCfg(char *arg) { - char cfg[256]; + /*char cfg[256]; struct stat buf; strcpy(cfg, "./cfgFWnull"); @@ -61,7 +62,7 @@ int ExecCfg(char *arg) } printf("cfgFWnull file not found!\n"); - return -1; + return -1;*/ } void SysMessage(char *fmt, ...) @@ -74,25 +75,28 @@ void SysMessage(char *fmt, ...) vsprintf(msg, fmt, list); va_end(list); - sprintf(cmd, "message \"%s\"", msg); - ExecCfg(cmd); + //sprintf(cmd, "message \"%s\"", msg); + cfgSysMessage(msg); + //ExecCfg(cmd); } void FWconfigure() { - char *file; - getcwd(file, ArraySize(file)); - chdir("plugins"); - ExecCfg("configure"); - chdir(file); + //char *file; + //getcwd(file, ArraySize(file)); + //chdir("plugins"); + //ExecCfg("configure"); + //chdir(file); + CFGconfigure(); } void FWabout() { - char *file; - getcwd(file, ArraySize(file)); - chdir("plugins"); - ExecCfg("about"); - chdir(file); + //char *file; + //getcwd(file, ArraySize(file)); + //chdir("plugins"); + //ExecCfg("about"); + //chdir(file); + CFGabout(); } diff --git a/plugins/FWnull/Linux/Config.c b/plugins/FWnull/Linux/Linux.h similarity index 55% rename from plugins/FWnull/Linux/Config.c rename to plugins/FWnull/Linux/Linux.h index 70fc156cd5..ed6cd2d1cb 100644 --- a/plugins/FWnull/Linux/Config.c +++ b/plugins/FWnull/Linux/Linux.h @@ -1,5 +1,5 @@ -/* FireWire - * Copyright (C) 2002-2004 USBlinuz Team +/* FWnull + * Copyright (C) 2004-2009 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 @@ -14,38 +14,4 @@ * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include -#include -#include -#include -#include - -#include "FW.h" - -void LoadConfig() { - FILE *f; - char cfg[256]; - - sprintf(cfg, "%s/.PS2E/FWnull.cfg", getenv("HOME")); - f = fopen(cfg, "r"); - if (f == NULL) { - return; - } - fclose(f); -} - -void SaveConfig() { - FILE *f; - char cfg[256]; - - sprintf(cfg, "%s/.PS2E", getenv("HOME")); - mkdir(cfg, 0755); - sprintf(cfg, "%s/.PS2E/FWnull.cfg", getenv("HOME")); - f = fopen(cfg, "w"); - if (f == NULL) - return; - fclose(f); -} - + */ \ No newline at end of file diff --git a/plugins/FWnull/Linux/callbacks.c b/plugins/FWnull/Linux/callbacks.c deleted file mode 100644 index fa070a7842..0000000000 --- a/plugins/FWnull/Linux/callbacks.c +++ /dev/null @@ -1,34 +0,0 @@ -#ifdef HAVE_CONFIG_H -# include -#endif - -#include - -#include "callbacks.h" -#include "interface.h" -#include "support.h" - - -void -OnConf_Ok (GtkButton *button, - gpointer user_data) -{ - -} - - -void -OnConf_Cancel (GtkButton *button, - gpointer user_data) -{ - -} - - -void -OnAbout_Ok (GtkButton *button, - gpointer user_data) -{ - -} - diff --git a/plugins/FWnull/Linux/firewire.glade b/plugins/FWnull/Linux/firewire.glade index 6644e52247..cef4eab65e 100644 --- a/plugins/FWnull/Linux/firewire.glade +++ b/plugins/FWnull/Linux/firewire.glade @@ -1,300 +1,443 @@ - - - - - FireWire - dev9linuz - - - pixmaps - C - False - False - False - False - False - - - - GtkWindow - Config - 5 - DEV9config - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_CENTER - False - False - True - False - - - GtkVBox - vbox1 - 5 - False - 5 - - - GtkFrame - frame2 - - 0 - GTK_SHADOW_ETCHED_IN - - 0 - True - True - - - - GtkHBox - hbox1 - 5 - True - 5 - - - GtkLabel - label4 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 0 - 0 - - 0 - False - False - - - - - GtkCombo - GtkCombo_Eth - 130 - False - True - False - True - False - - - 0 - False - False - - - - GtkEntry - GtkCombo:entry - combo-entry1 - True - True - True - 0 - - - - - - - - GtkFrame - frame3 - - 0 - GTK_SHADOW_ETCHED_IN - - 0 - True - True - - - - GtkHBox - hbox2 - 5 - True - 5 - - - GtkLabel - label5 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 0 - 0 - - 0 - False - False - - - - - GtkCombo - GtkCombo_Hdd - 130 - False - True - False - True - False - - - 0 - False - False - - - - GtkEntry - GtkCombo:entry - entry1 - True - True - True - 0 - - - - - - - - GtkHButtonBox - hbuttonbox1 - GTK_BUTTONBOX_DEFAULT_STYLE - 30 - 85 - 27 - 7 - 0 - - 0 - True - True - - - - GtkButton - button1 - True - True - - clicked - OnConf_Ok - Sat, 06 Apr 2002 17:07:56 GMT - - - GTK_RELIEF_NORMAL - - - - GtkButton - button2 - True - True - - clicked - OnConf_Cancel - Sat, 06 Apr 2002 17:08:08 GMT - - - GTK_RELIEF_NORMAL - - - - - - - GtkWindow - About - 5 - DEV9about - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_CENTER - False - False - True - False - - - GtkVBox - vbox2 - 5 - False - 5 - - - GtkLabel - label2 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 0 - 0 - - 0 - False - False - - - - - GtkLabel - label3 - - GTK_JUSTIFY_LEFT - False - 0.5 - 0.5 - 0 - 0 - - 0 - False - False - - - - - GtkHButtonBox - hbuttonbox2 - GTK_BUTTONBOX_DEFAULT_STYLE - 30 - 85 - 27 - 7 - 0 - - 0 - True - True - - - - GtkButton - button3 - True - True - - clicked - OnAbout_Ok - Sun, 07 Apr 2002 03:43:49 GMT - - - GTK_RELIEF_NORMAL - - - - - - + + + + + + + 5 + True + DEV9config + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + True + False + True + False + False + GDK_WINDOW_TYPE_HINT_NORMAL + GDK_GRAVITY_NORTH_WEST + True + False + + + + 5 + True + False + 5 + + + + True + 0 + 0.5 + GTK_SHADOW_ETCHED_IN + + + + 5 + True + True + 5 + + + + True + Device: + False + False + GTK_JUSTIFY_CENTER + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + False + False + + + + + + True + False + True + False + True + False + + + + True + True + True + True + 0 + + True + * + False + + + + + + True + GTK_SELECTION_BROWSE + + + + True + + + + True + + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + + + + + + + 0 + False + False + + + + + + + + True + Ethernet + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + label_item + + + + + 0 + True + True + + + + + + True + 0 + 0.5 + GTK_SHADOW_ETCHED_IN + + + + 5 + True + True + 5 + + + + True + Device: + False + False + GTK_JUSTIFY_CENTER + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + False + False + + + + + + True + False + True + False + True + False + + + + True + True + True + True + 0 + + True + * + False + + + + + + True + GTK_SELECTION_BROWSE + + + + True + + + + True + + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + + + + + + + 0 + False + False + + + + + + + + True + Hdd + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + label_item + + + + + 0 + True + True + + + + + + True + GTK_BUTTONBOX_DEFAULT_STYLE + 30 + + + + True + True + True + Ok + True + GTK_RELIEF_NORMAL + True + + + + + + + True + True + True + Cancel + True + GTK_RELIEF_NORMAL + True + + + + + + 0 + True + True + + + + + + + + 5 + True + DEV9about + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + True + False + True + False + False + GDK_WINDOW_TYPE_HINT_NORMAL + GDK_GRAVITY_NORTH_WEST + True + False + + + + 5 + True + False + 5 + + + + True + FireWire Driver + False + False + GTK_JUSTIFY_CENTER + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + False + False + + + + + + True + Author: linuzappz <linuzappz@hotmail.com> + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + False + False + + + + + + True + GTK_BUTTONBOX_DEFAULT_STYLE + 30 + + + + True + True + True + Ok + True + GTK_RELIEF_NORMAL + True + + + + + + 0 + True + True + + + + + + + diff --git a/plugins/FWnull/Linux/interface.c b/plugins/FWnull/Linux/interface.c deleted file mode 100644 index 10dcc15912..0000000000 --- a/plugins/FWnull/Linux/interface.c +++ /dev/null @@ -1,219 +0,0 @@ -/* - * DO NOT EDIT THIS FILE - it is generated by Glade. - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include -#include -#include -#include - -#include -#include - -#include "callbacks.h" -#include "interface.h" -#include "support.h" - -GtkWidget* -create_Config (void) -{ - GtkWidget *Config; - GtkWidget *vbox1; - GtkWidget *frame2; - GtkWidget *hbox1; - GtkWidget *label4; - GtkWidget *GtkCombo_Eth; - GtkWidget *combo_entry1; - GtkWidget *frame3; - GtkWidget *hbox2; - GtkWidget *label5; - GtkWidget *GtkCombo_Hdd; - GtkWidget *entry1; - GtkWidget *hbuttonbox1; - GtkWidget *button1; - GtkWidget *button2; - - Config = gtk_window_new (GTK_WINDOW_TOPLEVEL); - gtk_object_set_data (GTK_OBJECT (Config), "Config", Config); - gtk_container_set_border_width (GTK_CONTAINER (Config), 5); - gtk_window_set_title (GTK_WINDOW (Config), "DEV9config"); - gtk_window_set_position (GTK_WINDOW (Config), GTK_WIN_POS_CENTER); - - vbox1 = gtk_vbox_new (FALSE, 5); - gtk_widget_ref (vbox1); - gtk_object_set_data_full (GTK_OBJECT (Config), "vbox1", vbox1, - (GtkDestroyNotify) gtk_widget_unref); - gtk_widget_show (vbox1); - gtk_container_add (GTK_CONTAINER (Config), vbox1); - gtk_container_set_border_width (GTK_CONTAINER (vbox1), 5); - - frame2 = gtk_frame_new ("Ethernet"); - gtk_widget_ref (frame2); - gtk_object_set_data_full (GTK_OBJECT (Config), "frame2", frame2, - (GtkDestroyNotify) gtk_widget_unref); - gtk_widget_show (frame2); - gtk_box_pack_start (GTK_BOX (vbox1), frame2, TRUE, TRUE, 0); - - hbox1 = gtk_hbox_new (TRUE, 5); - gtk_widget_ref (hbox1); - gtk_object_set_data_full (GTK_OBJECT (Config), "hbox1", hbox1, - (GtkDestroyNotify) gtk_widget_unref); - gtk_widget_show (hbox1); - gtk_container_add (GTK_CONTAINER (frame2), hbox1); - gtk_container_set_border_width (GTK_CONTAINER (hbox1), 5); - - label4 = gtk_label_new ("Device:"); - gtk_widget_ref (label4); - gtk_object_set_data_full (GTK_OBJECT (Config), "label4", label4, - (GtkDestroyNotify) gtk_widget_unref); - gtk_widget_show (label4); - gtk_box_pack_start (GTK_BOX (hbox1), label4, FALSE, FALSE, 0); - - GtkCombo_Eth = gtk_combo_new (); - gtk_widget_ref (GtkCombo_Eth); - gtk_object_set_data_full (GTK_OBJECT (Config), "GtkCombo_Eth", GtkCombo_Eth, - (GtkDestroyNotify) gtk_widget_unref); - gtk_widget_show (GtkCombo_Eth); - gtk_box_pack_start (GTK_BOX (hbox1), GtkCombo_Eth, FALSE, FALSE, 0); - gtk_widget_set_usize (GtkCombo_Eth, 130, -2); - - combo_entry1 = GTK_COMBO (GtkCombo_Eth)->entry; - gtk_widget_ref (combo_entry1); - gtk_object_set_data_full (GTK_OBJECT (Config), "combo_entry1", combo_entry1, - (GtkDestroyNotify) gtk_widget_unref); - gtk_widget_show (combo_entry1); - - frame3 = gtk_frame_new ("Hdd"); - gtk_widget_ref (frame3); - gtk_object_set_data_full (GTK_OBJECT (Config), "frame3", frame3, - (GtkDestroyNotify) gtk_widget_unref); - gtk_widget_show (frame3); - gtk_box_pack_start (GTK_BOX (vbox1), frame3, TRUE, TRUE, 0); - - hbox2 = gtk_hbox_new (TRUE, 5); - gtk_widget_ref (hbox2); - gtk_object_set_data_full (GTK_OBJECT (Config), "hbox2", hbox2, - (GtkDestroyNotify) gtk_widget_unref); - gtk_widget_show (hbox2); - gtk_container_add (GTK_CONTAINER (frame3), hbox2); - gtk_container_set_border_width (GTK_CONTAINER (hbox2), 5); - - label5 = gtk_label_new ("Device:"); - gtk_widget_ref (label5); - gtk_object_set_data_full (GTK_OBJECT (Config), "label5", label5, - (GtkDestroyNotify) gtk_widget_unref); - gtk_widget_show (label5); - gtk_box_pack_start (GTK_BOX (hbox2), label5, FALSE, FALSE, 0); - - GtkCombo_Hdd = gtk_combo_new (); - gtk_widget_ref (GtkCombo_Hdd); - gtk_object_set_data_full (GTK_OBJECT (Config), "GtkCombo_Hdd", GtkCombo_Hdd, - (GtkDestroyNotify) gtk_widget_unref); - gtk_widget_show (GtkCombo_Hdd); - gtk_box_pack_start (GTK_BOX (hbox2), GtkCombo_Hdd, FALSE, FALSE, 0); - gtk_widget_set_usize (GtkCombo_Hdd, 130, -2); - - entry1 = GTK_COMBO (GtkCombo_Hdd)->entry; - gtk_widget_ref (entry1); - gtk_object_set_data_full (GTK_OBJECT (Config), "entry1", entry1, - (GtkDestroyNotify) gtk_widget_unref); - gtk_widget_show (entry1); - - hbuttonbox1 = gtk_hbutton_box_new (); - gtk_widget_ref (hbuttonbox1); - gtk_object_set_data_full (GTK_OBJECT (Config), "hbuttonbox1", hbuttonbox1, - (GtkDestroyNotify) gtk_widget_unref); - gtk_widget_show (hbuttonbox1); - gtk_box_pack_start (GTK_BOX (vbox1), hbuttonbox1, TRUE, TRUE, 0); - - button1 = gtk_button_new_with_label ("Ok"); - gtk_widget_ref (button1); - gtk_object_set_data_full (GTK_OBJECT (Config), "button1", button1, - (GtkDestroyNotify) gtk_widget_unref); - gtk_widget_show (button1); - gtk_container_add (GTK_CONTAINER (hbuttonbox1), button1); - GTK_WIDGET_SET_FLAGS (button1, GTK_CAN_DEFAULT); - - button2 = gtk_button_new_with_label ("Cancel"); - gtk_widget_ref (button2); - gtk_object_set_data_full (GTK_OBJECT (Config), "button2", button2, - (GtkDestroyNotify) gtk_widget_unref); - gtk_widget_show (button2); - gtk_container_add (GTK_CONTAINER (hbuttonbox1), button2); - GTK_WIDGET_SET_FLAGS (button2, GTK_CAN_DEFAULT); - - gtk_signal_connect (GTK_OBJECT (button1), "clicked", - GTK_SIGNAL_FUNC (OnConf_Ok), - NULL); - gtk_signal_connect (GTK_OBJECT (button2), "clicked", - GTK_SIGNAL_FUNC (OnConf_Cancel), - NULL); - - return Config; -} - -GtkWidget* -create_About (void) -{ - GtkWidget *About; - GtkWidget *vbox2; - GtkWidget *label2; - GtkWidget *label3; - GtkWidget *hbuttonbox2; - GtkWidget *button3; - - About = gtk_window_new (GTK_WINDOW_TOPLEVEL); - gtk_object_set_data (GTK_OBJECT (About), "About", About); - gtk_container_set_border_width (GTK_CONTAINER (About), 5); - gtk_window_set_title (GTK_WINDOW (About), "DEV9about"); - gtk_window_set_position (GTK_WINDOW (About), GTK_WIN_POS_CENTER); - - vbox2 = gtk_vbox_new (FALSE, 5); - gtk_widget_ref (vbox2); - gtk_object_set_data_full (GTK_OBJECT (About), "vbox2", vbox2, - (GtkDestroyNotify) gtk_widget_unref); - gtk_widget_show (vbox2); - gtk_container_add (GTK_CONTAINER (About), vbox2); - gtk_container_set_border_width (GTK_CONTAINER (vbox2), 5); - - label2 = gtk_label_new ("DEV9linuz Driver"); - gtk_widget_ref (label2); - gtk_object_set_data_full (GTK_OBJECT (About), "label2", label2, - (GtkDestroyNotify) gtk_widget_unref); - gtk_widget_show (label2); - gtk_box_pack_start (GTK_BOX (vbox2), label2, FALSE, FALSE, 0); - - label3 = gtk_label_new ("Author: linuzappz "); - gtk_widget_ref (label3); - gtk_object_set_data_full (GTK_OBJECT (About), "label3", label3, - (GtkDestroyNotify) gtk_widget_unref); - gtk_widget_show (label3); - gtk_box_pack_start (GTK_BOX (vbox2), label3, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label3), GTK_JUSTIFY_LEFT); - - hbuttonbox2 = gtk_hbutton_box_new (); - gtk_widget_ref (hbuttonbox2); - gtk_object_set_data_full (GTK_OBJECT (About), "hbuttonbox2", hbuttonbox2, - (GtkDestroyNotify) gtk_widget_unref); - gtk_widget_show (hbuttonbox2); - gtk_box_pack_start (GTK_BOX (vbox2), hbuttonbox2, TRUE, TRUE, 0); - - button3 = gtk_button_new_with_label ("Ok"); - gtk_widget_ref (button3); - gtk_object_set_data_full (GTK_OBJECT (About), "button3", button3, - (GtkDestroyNotify) gtk_widget_unref); - gtk_widget_show (button3); - gtk_container_add (GTK_CONTAINER (hbuttonbox2), button3); - GTK_WIDGET_SET_FLAGS (button3, GTK_CAN_DEFAULT); - - gtk_signal_connect (GTK_OBJECT (button3), "clicked", - GTK_SIGNAL_FUNC (OnAbout_Ok), - NULL); - - return About; -} - diff --git a/plugins/FWnull/Linux/support.c b/plugins/FWnull/Linux/support.c deleted file mode 100644 index 65007c9217..0000000000 --- a/plugins/FWnull/Linux/support.c +++ /dev/null @@ -1,162 +0,0 @@ -/* - * DO NOT EDIT THIS FILE - it is generated by Glade. - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include -#include -#include -#include - -#include - -#include "support.h" - -/* This is an internally used function to check if a pixmap file exists. */ -static gchar* check_file_exists (const gchar *directory, - const gchar *filename); - -/* This is an internally used function to create pixmaps. */ -static GtkWidget* create_dummy_pixmap (GtkWidget *widget); - -GtkWidget* -lookup_widget (GtkWidget *widget, - const gchar *widget_name) -{ - GtkWidget *parent, *found_widget; - - for (;;) - { - if (GTK_IS_MENU (widget)) - parent = gtk_menu_get_attach_widget (GTK_MENU (widget)); - else - parent = widget->parent; - if (parent == NULL) - break; - widget = parent; - } - - found_widget = (GtkWidget*) gtk_object_get_data (GTK_OBJECT (widget), - widget_name); - if (!found_widget) - g_warning ("Widget not found: %s", widget_name); - return found_widget; -} - -/* This is a dummy pixmap we use when a pixmap can't be found. */ -static char *dummy_pixmap_xpm[] = { -/* columns rows colors chars-per-pixel */ -"1 1 1 1", -" c None", -/* pixels */ -" " -}; - -/* This is an internally used function to create pixmaps. */ -static GtkWidget* -create_dummy_pixmap (GtkWidget *widget) -{ - GdkColormap *colormap; - GdkPixmap *gdkpixmap; - GdkBitmap *mask; - GtkWidget *pixmap; - - colormap = gtk_widget_get_colormap (widget); - gdkpixmap = gdk_pixmap_colormap_create_from_xpm_d (NULL, colormap, &mask, - NULL, dummy_pixmap_xpm); - if (gdkpixmap == NULL) - g_error ("Couldn't create replacement pixmap."); - pixmap = gtk_pixmap_new (gdkpixmap, mask); - gdk_pixmap_unref (gdkpixmap); - gdk_bitmap_unref (mask); - return pixmap; -} - -static GList *pixmaps_directories = NULL; - -/* Use this function to set the directory containing installed pixmaps. */ -void -add_pixmap_directory (const gchar *directory) -{ - pixmaps_directories = g_list_prepend (pixmaps_directories, - g_strdup (directory)); -} - -/* This is an internally used function to create pixmaps. */ -GtkWidget* -create_pixmap (GtkWidget *widget, - const gchar *filename) -{ - gchar *found_filename = NULL; - GdkColormap *colormap; - GdkPixmap *gdkpixmap; - GdkBitmap *mask; - GtkWidget *pixmap; - GList *elem; - - if (!filename || !filename[0]) - return create_dummy_pixmap (widget); - - /* We first try any pixmaps directories set by the application. */ - elem = pixmaps_directories; - while (elem) - { - found_filename = check_file_exists ((gchar*)elem->data, filename); - if (found_filename) - break; - elem = elem->next; - } - - /* If we haven't found the pixmap, try the source directory. */ - if (!found_filename) - { - found_filename = check_file_exists ("pixmaps", filename); - } - - if (!found_filename) - { - g_warning ("Couldn't find pixmap file: %s", filename); - return create_dummy_pixmap (widget); - } - - colormap = gtk_widget_get_colormap (widget); - gdkpixmap = gdk_pixmap_colormap_create_from_xpm (NULL, colormap, &mask, - NULL, found_filename); - if (gdkpixmap == NULL) - { - g_warning ("Error loading pixmap file: %s", found_filename); - g_free (found_filename); - return create_dummy_pixmap (widget); - } - g_free (found_filename); - pixmap = gtk_pixmap_new (gdkpixmap, mask); - gdk_pixmap_unref (gdkpixmap); - gdk_bitmap_unref (mask); - return pixmap; -} - -/* This is an internally used function to check if a pixmap file exists. */ -static gchar* -check_file_exists (const gchar *directory, - const gchar *filename) -{ - gchar *full_filename; - struct stat s; - gint status; - - full_filename = (gchar*) g_malloc (strlen (directory) + 1 - + strlen (filename) + 1); - strcpy (full_filename, directory); - strcat (full_filename, G_DIR_SEPARATOR_S); - strcat (full_filename, filename); - - status = stat (full_filename, &s); - if (status == 0 && S_ISREG (s.st_mode)) - return full_filename; - g_free (full_filename); - return NULL; -} - diff --git a/plugins/FWnull/Linux/support.h b/plugins/FWnull/Linux/support.h index aee31f935d..a32649e53c 100644 --- a/plugins/FWnull/Linux/support.h +++ b/plugins/FWnull/Linux/support.h @@ -8,6 +8,31 @@ #include +/* + * Standard gettext macros. + */ +#ifdef ENABLE_NLS +# include +# undef _ +# define _(String) dgettext (PACKAGE, String) +# define Q_(String) g_strip_context ((String), gettext (String)) +# ifdef gettext_noop +# define N_(String) gettext_noop (String) +# else +# define N_(String) (String) +# endif +#else +# define textdomain(String) (String) +# define gettext(String) (String) +# define dgettext(Domain,Message) (Message) +# define dcgettext(Domain,Message,Type) (Message) +# define bindtextdomain(Domain,Directory) (Domain) +# define _(String) (String) +# define Q_(String) g_strip_context ((String), (String)) +# define N_(String) (String) +#endif + + /* * Public Functions. */ @@ -21,8 +46,6 @@ GtkWidget* lookup_widget (GtkWidget *widget, const gchar *widget_name); -/* get_widget() is deprecated. Use lookup_widget instead. */ -#define get_widget lookup_widget /* Use this function to set the directory containing installed pixmaps. */ void add_pixmap_directory (const gchar *directory); @@ -32,7 +55,15 @@ void add_pixmap_directory (const gchar *directory); * Private Functions. */ -/* This is used to create the pixmaps in the interface. */ +/* This is used to create the pixmaps used in the interface. */ GtkWidget* create_pixmap (GtkWidget *widget, const gchar *filename); +/* This is used to create the pixbufs used in the interface. */ +GdkPixbuf* create_pixbuf (const gchar *filename); + +/* This is used to set ATK action descriptions. */ +void glade_set_atk_action_description (AtkAction *action, + const gchar *action_name, + const gchar *description); + diff --git a/plugins/FWnull/Makefile.am b/plugins/FWnull/Makefile.am new file mode 100644 index 0000000000..708c80c51b --- /dev/null +++ b/plugins/FWnull/Makefile.am @@ -0,0 +1,33 @@ +# Create a shared library libFWnull +AUTOMAKE_OPTIONS = foreign +noinst_LIBRARIES = libFWnull.a +INCLUDES = -I@srcdir@/../../common/include -I@srcdir@/../../3rdparty -I@srcdir@/Linux + +libFWnull_a_CXXFLAGS = $(shell pkg-config --cflags gtk+-2.0) +libFWnull_a_CFLAGS = $(shell pkg-config --cflags gtk+-2.0) + +# Create a shared object by faking an exe (thanks to ODE makefiles) +traplibdir=$(prefix) + +if DEBUGBUILD +preext=d +endif + +EXEEXT=$(preext)@so_ext@ + +traplib_PROGRAMS=libFWnull +libFWnull_SOURCES= +libFWnull_DEPENDENCIES = libFWnull.a +libFWnull_LDFLAGS= @SHARED_LDFLAGS@ +libFWnull_LDFLAGS+=-Wl,-soname,@libFWnull_SONAME@ +libFWnull_LDADD=$(libFWnull_a_OBJECTS) + +libFWnull_a_SOURCES = FW.cpp Linux/Config.cpp Linux/Linux.cpp \ +FW.h Linux/Config.h Linux/Linux.h + +libFWnull_a_SOURCES += \ +Linux/interface.h Linux/support.c \ +Linux/interface.c Linux/support.h \ +Linux/callbacks.c Linux/callbacks.h + +#SUBDIRS = Linux \ No newline at end of file diff --git a/plugins/FWnull/Windows/FWnull_vc2008.vcproj b/plugins/FWnull/Windows/FWnull_vc2008.vcproj index 9f1d86a290..d4d68494b8 100644 --- a/plugins/FWnull/Windows/FWnull_vc2008.vcproj +++ b/plugins/FWnull/Windows/FWnull_vc2008.vcproj @@ -161,7 +161,7 @@ >
Date: Sat, 2 May 2009 00:56:56 +0000 Subject: [PATCH 30/41] Helps if I have FW.cpp in there. :( git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1106 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/FWnull/FW.cpp | 151 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 151 insertions(+) create mode 100644 plugins/FWnull/FW.cpp diff --git a/plugins/FWnull/FW.cpp b/plugins/FWnull/FW.cpp new file mode 100644 index 0000000000..93a9a7a1d4 --- /dev/null +++ b/plugins/FWnull/FW.cpp @@ -0,0 +1,151 @@ +/* FWnull + * Copyright (C) 2004-2009 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include +#include +#include +#include +using namespace std; + +#include "FW.h" + +const unsigned char version = PS2E_FW_VERSION; +const unsigned char revision = 0; +const unsigned char build = 5; // increase that with each version + +static char *libraryName = "FWnull Driver"; +s8 *fwregs; +FILE *fwLog; +Config conf; +string s_strIniPath="inis/FWnull.ini"; +void (*FWirq)(); + +EXPORT_C_(u32) PS2EgetLibType() +{ + return PS2E_LT_FW; +} + +EXPORT_C_(char*) PS2EgetLibName() +{ + return libraryName; +} + +EXPORT_C_(u32) PS2EgetLibVersion2(u32 type) +{ + return (version<<16) | (revision<<8) | build; +} + +void __Log(char *fmt, ...) +{ + va_list list; + + if (!conf.Log || fwLog == NULL) return; + + va_start(list, fmt); + vfprintf(fwLog, fmt, list); + va_end(list); +} + +EXPORT_C_(s32) FWinit() +{ + LoadConfig(); + +#ifdef FW_LOG + fwLog = fopen("logs/fwLog.txt", "w"); + if (fwLog) setvbuf(fwLog, NULL, _IONBF, 0); + FW_LOG("FWnull plugin version %d,%d\n",revision,build); + FW_LOG("FW init\n"); +#endif + + fwregs = (s8*)malloc(0x10000); + if (fwregs == NULL) + { + SysMessage("Error allocating Memory\n"); + return -1; + } + + return 0; +} + +EXPORT_C_(void) FWshutdown() +{ + free(fwregs); + +#ifdef FW_LOG + if (fwLog) fclose(fwLog); +#endif +} + +EXPORT_C_(s32) FWopen(void *pDsp) +{ +#ifdef FW_LOG + FW_LOG("FW open\n"); +#endif + + return 0; +} + +EXPORT_C_(void) FWclose() +{ +} + +EXPORT_C_(u32) FWread32(u32 addr) +{ + u32 ret = 0; + + switch (addr) + { + case 0x1f808410: + ret = 0x8; + break; + + default: + ret = fwRu32(addr); + break; + } + + FW_LOG("FW read mem 0x%x: 0x%x\n", addr, ret); + + return ret; +} + +EXPORT_C_(void) FWwrite32(u32 addr, u32 value) +{ + switch (addr) + { + default: + fwRu32(addr) = value; + break; + } + FW_LOG("FW write mem 0x%x: 0x%x\n", addr, value); +} + +EXPORT_C_(void) FWirqCallback(void (*callback)()) +{ + FWirq = callback; +} + +EXPORT_C_(s32) FWfreeze(int mode, freezeData *data) +{ + return 0; +} + +EXPORT_C_(s32) FWtest() +{ + return 0; +} From 6fb0070c33af50c6047d5e1532e1543632340948 Mon Sep 17 00:00:00 2001 From: arcum42 Date: Sat, 2 May 2009 02:29:48 +0000 Subject: [PATCH 31/41] That's USBnull down. (And yes, I'm aware the dialog boxes for USBnull & FWnull are incorrect. For now, I just told it to use the incorrect one that was already in the plugin.) git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1107 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/FWnull/Linux/Linux.cpp | 49 -- plugins/FWnull/Linux/Makefile | 35 - plugins/USBnull/Linux/Config.c | 59 -- plugins/USBnull/Linux/{conf.c => Config.cpp} | 96 ++- plugins/USBnull/Linux/Config.h | 6 +- plugins/USBnull/Linux/{Linux.c => Linux.cpp} | 57 +- plugins/USBnull/Linux/Linux.h | 17 + plugins/USBnull/Linux/Makefile | 35 - plugins/USBnull/Linux/interface.c | 189 +++-- plugins/USBnull/Linux/support.c | 168 ++-- plugins/USBnull/Linux/support.h | 37 +- plugins/USBnull/Linux/usbnull.glade | 743 +++++++++++------- plugins/USBnull/Makefile.am | 33 + plugins/USBnull/{USB.c => USB.cpp} | 114 ++- plugins/USBnull/USB.h | 16 +- plugins/USBnull/Windows/USBnull_vc2008.vcproj | 2 +- plugins/USBnull/build.sh | 31 +- plugins/USBnull/configure.ac | 80 ++ plugins/USBnull/install-sh | 1 + plugins/USBnull/missing | 1 + 20 files changed, 954 insertions(+), 815 deletions(-) delete mode 100644 plugins/FWnull/Linux/Makefile delete mode 100644 plugins/USBnull/Linux/Config.c rename plugins/USBnull/Linux/{conf.c => Config.cpp} (62%) rename plugins/USBnull/Linux/{Linux.c => Linux.cpp} (54%) create mode 100644 plugins/USBnull/Linux/Linux.h delete mode 100644 plugins/USBnull/Linux/Makefile create mode 100644 plugins/USBnull/Makefile.am rename plugins/USBnull/{USB.c => USB.cpp} (62%) create mode 100644 plugins/USBnull/configure.ac create mode 120000 plugins/USBnull/install-sh create mode 120000 plugins/USBnull/missing diff --git a/plugins/FWnull/Linux/Linux.cpp b/plugins/FWnull/Linux/Linux.cpp index 38d86a5057..626584ce52 100644 --- a/plugins/FWnull/Linux/Linux.cpp +++ b/plugins/FWnull/Linux/Linux.cpp @@ -28,43 +28,6 @@ #include "FW.h" #include "Config.h" -int ExecCfg(char *arg) -{ - /*char cfg[256]; - struct stat buf; - - strcpy(cfg, "./cfgFWnull"); - if (stat(cfg, &buf) != -1) - { - sprintf(cfg, "%s %s", cfg, arg); - return system(cfg); - } - - strcpy(cfg, "./plugins/cfgFWnull"); - if (stat(cfg, &buf) != -1) - { - sprintf(cfg, "%s %s", cfg, arg); - return system(cfg); - } - - strcpy(cfg, "./cfg/cfgFWnull"); - if (stat(cfg, &buf) != -1) - { - sprintf(cfg, "%s %s", cfg, arg); - return system(cfg); - } - - sprintf(cfg, "%s/cfgFWnull", getenv("HOME")); - if (stat(cfg, &buf) != -1) - { - sprintf(cfg, "%s %s", cfg, arg); - return system(cfg); - } - - printf("cfgFWnull file not found!\n"); - return -1;*/ -} - void SysMessage(char *fmt, ...) { va_list list; @@ -75,28 +38,16 @@ void SysMessage(char *fmt, ...) vsprintf(msg, fmt, list); va_end(list); - //sprintf(cmd, "message \"%s\"", msg); cfgSysMessage(msg); - //ExecCfg(cmd); } void FWconfigure() { - //char *file; - //getcwd(file, ArraySize(file)); - //chdir("plugins"); - //ExecCfg("configure"); - //chdir(file); CFGconfigure(); } void FWabout() { - //char *file; - //getcwd(file, ArraySize(file)); - //chdir("plugins"); - //ExecCfg("about"); - //chdir(file); CFGabout(); } diff --git a/plugins/FWnull/Linux/Makefile b/plugins/FWnull/Linux/Makefile deleted file mode 100644 index a2f3f21617..0000000000 --- a/plugins/FWnull/Linux/Makefile +++ /dev/null @@ -1,35 +0,0 @@ - -PLUGIN = libFWnull.so -CFG = cfgFWnull -CFLAGS+= -fPIC -Wall -I. -I.. -I../../../common/include -O3 -fomit-frame-pointer -fno-strict-aliasing -OBJS = ../FW.o -OBJS+= Linux.o Config.o -CFGOBJS = conf.o interface.o support.o Config.o -DEPS:= $(OBJS:.o=.d) -CFGDEPS:= $(CFGOBJS:.o=.d) -LIBS = -lpthread -CFLAGS+= $(shell pkg-config --cflags gtk+-2.0) -D__LINUX__ -CFGLIBS = $(shell pkg-config --libs gtk+-2.0) - -CC = gcc - -all: plugin cfg -install: all - -plugin: ${OBJS} - rm -f ${PLUGIN} - ${CC} -shared -Wl,-soname,${PLUGIN} ${CFLAGS} ${OBJS} -o ${PLUGIN} ${LIBS} - strip --strip-unneeded --strip-debug ${PLUGIN} - -cfg: ${CFGOBJS} - rm -f ${CFG} - ${CC} ${CFLAGS} ${CFGOBJS} -o ${CFG} ${CFGLIBS} - strip ${CFG} - -clean: - rm -f ${OBJS} ${DEPS} ${CFGOBJS} ${CFGDEPS} ${PLUGIN} ${CFG} - -%.o: %.c - ${CC} ${CFLAGS} -c -o $@ $< -MD -MF $(patsubst %.o,%.d,$@) - --include ${DEPS} diff --git a/plugins/USBnull/Linux/Config.c b/plugins/USBnull/Linux/Config.c deleted file mode 100644 index 7c6833f54b..0000000000 --- a/plugins/USBnull/Linux/Config.c +++ /dev/null @@ -1,59 +0,0 @@ -/* USBnull - * Copyright (C) 2002-2004 USBnull 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include -#include -#include -#include -#include - -#include "USB.h" - -void LoadConfig() { -/* FILE *f; - char cfg[256]; - - sprintf(cfg, "%s/.PS2E/CDVDiso.cfg", getenv("HOME")); - f = fopen(cfg, "r"); - if (f == NULL) { - strcpy(IsoFile, DEV_DEF); - strcpy(CdDev, CDDEV_DEF); - return; - } - fscanf(f, "IsoFile = %[^\n]\n", IsoFile); - fscanf(f, "CdDev = %[^\n]\n", CdDev); - if (!strncmp(IsoFile, "CdDev =", 9)) *IsoFile = 0; // quick fix - if (*CdDev == 0) strcpy(CdDev, CDDEV_DEF); - fclose(f);*/ -} - -void SaveConfig() { -/* FILE *f; - char cfg[256]; - - sprintf(cfg, "%s/.PS2E", getenv("HOME")); - mkdir(cfg, 0755); - sprintf(cfg, "%s/.PS2E/CDVDiso.cfg", getenv("HOME")); - f = fopen(cfg, "w"); - if (f == NULL) - return; - fprintf(f, "IsoFile = %s\n", IsoFile); - fprintf(f, "CdDev = %s\n", CdDev); - fclose(f);*/ -} - diff --git a/plugins/USBnull/Linux/conf.c b/plugins/USBnull/Linux/Config.cpp similarity index 62% rename from plugins/USBnull/Linux/conf.c rename to plugins/USBnull/Linux/Config.cpp index e0018e9753..1456f2e2d6 100644 --- a/plugins/USBnull/Linux/conf.c +++ b/plugins/USBnull/Linux/Config.cpp @@ -1,5 +1,5 @@ /* USBnull - * Copyright (C) 2002-2004 USBnull Team + * Copyright (C) 2002-2009 USBnull 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 @@ -20,23 +20,34 @@ #include #include #include +#include #include #include +#include +using namespace std; +extern "C" +{ #include "interface.h" #include "support.h" -#include "callbacks.h" +//#include "callbacks.h" +} -GtkWidget *MsgDlg; +#include "USB.h" -void OnMsg_Ok() { +GtkWidget *MsgDlg, *About, *Conf; +extern string s_strIniPath; + +void OnMsg_Ok() +{ gtk_widget_destroy(MsgDlg); gtk_main_quit(); } -void cfgSysMessage(char *fmt, ...) { - GtkWidget *Ok,*Txt; - GtkWidget *Box,*Box1; +void cfgSysMessage(char *fmt, ...) +{ + GtkWidget *Ok, *Txt; + GtkWidget *Box, *Box1; va_list list; char msg[512]; @@ -46,7 +57,7 @@ void cfgSysMessage(char *fmt, ...) { if (msg[strlen(msg)-1] == '\n') msg[strlen(msg)-1] = 0; - MsgDlg = gtk_window_new (GTK_WINDOW_POPUP); + MsgDlg = gtk_window_new(GTK_WINDOW_POPUP); gtk_window_set_position(GTK_WINDOW(MsgDlg), GTK_WIN_POS_CENTER); gtk_window_set_title(GTK_WINDOW(MsgDlg), "USBnull Msg"); gtk_container_set_border_width(GTK_CONTAINER(MsgDlg), 5); @@ -56,7 +67,7 @@ void cfgSysMessage(char *fmt, ...) { gtk_widget_show(Box); Txt = gtk_label_new(msg); - + gtk_box_pack_start(GTK_BOX(Box), Txt, FALSE, FALSE, 5); gtk_widget_show(Txt); @@ -65,64 +76,87 @@ void cfgSysMessage(char *fmt, ...) { gtk_widget_show(Box1); Ok = gtk_button_new_with_label("Ok"); - gtk_signal_connect (GTK_OBJECT(Ok), "clicked", GTK_SIGNAL_FUNC(OnMsg_Ok), NULL); + gtk_signal_connect(GTK_OBJECT(Ok), "clicked", GTK_SIGNAL_FUNC(OnMsg_Ok), NULL); gtk_container_add(GTK_CONTAINER(Box1), Ok); GTK_WIDGET_SET_FLAGS(Ok, GTK_CAN_DEFAULT); gtk_widget_show(Ok); - gtk_widget_show(MsgDlg); + gtk_widget_show(MsgDlg); gtk_main(); } -GtkWidget *About; - -void OnAbout_Ok(GtkButton *button, gpointer user_data) { +void OnAbout_Ok(GtkButton *button, gpointer user_data) +{ gtk_widget_destroy(About); gtk_main_quit(); } -void CFGabout() { +void CFGabout() +{ About = create_About(); gtk_widget_show_all(About); gtk_main(); } -GtkWidget *Conf; - -void OnConf_Ok(GtkButton *button, gpointer user_data) { +void OnConf_Ok(GtkButton *button, gpointer user_data) +{ gtk_widget_destroy(Conf); gtk_main_quit(); } -void OnConf_Cancel(GtkButton *button, gpointer user_data) { +void OnConf_Cancel(GtkButton *button, gpointer user_data) +{ gtk_widget_destroy(Conf); gtk_main_quit(); } -void CFGconfigure() { +void CFGconfigure() +{ Conf = create_Config(); gtk_widget_show_all(Conf); gtk_main(); } -long CFGmessage(char *msg) { +long CFGmessage(char *msg) +{ cfgSysMessage(msg); return 0; } -int main(int argc, char *argv[]) { - gtk_init(NULL, NULL); +void LoadConfig() +{ + FILE *f; + char cfg[255]; - if (!strcmp(argv[1], "configure")) { - CFGconfigure(); - } else if (!strcmp(argv[1], "about")) { - CFGabout(); - } else if (!strcmp(argv[1], "message")) { - CFGmessage(argv[2]); + strcpy(cfg, s_strIniPath.c_str()); + f = fopen(cfg, "r"); + if (f == NULL) + { + printf("failed to open %s\n", s_strIniPath.c_str()); + SaveConfig();//save and return + return; } - - return 0; + //fscanf(f, "options = %hhx\n", &confOptions); + fclose(f); } + +void SaveConfig() +{ + FILE *f; + char cfg[255]; + + strcpy(cfg, s_strIniPath.c_str()); + f = fopen(cfg,"w"); + if (f == NULL) + { + printf("failed to open %s\n", s_strIniPath.c_str()); + return; + } + + //fprintf(f, "options = %hhx\n", confOptions); + fclose(f); +} + diff --git a/plugins/USBnull/Linux/Config.h b/plugins/USBnull/Linux/Config.h index 1dcda4ffc6..c4036d30ed 100644 --- a/plugins/USBnull/Linux/Config.h +++ b/plugins/USBnull/Linux/Config.h @@ -1,5 +1,5 @@ /* USBnull - * Copyright (C) 2002-2004 USBnull Team + * Copyright (C) 2002-2009 USBnull 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 @@ -18,3 +18,7 @@ void SaveConfig(); void LoadConfig(); +void cfgSysMessage(char *fmt, ...); +void CFGabout(); +void CFGconfigure(); +long CFGmessage(char *msg); diff --git a/plugins/USBnull/Linux/Linux.c b/plugins/USBnull/Linux/Linux.cpp similarity index 54% rename from plugins/USBnull/Linux/Linux.c rename to plugins/USBnull/Linux/Linux.cpp index b3cea92e61..739a7a8162 100644 --- a/plugins/USBnull/Linux/Linux.c +++ b/plugins/USBnull/Linux/Linux.cpp @@ -1,5 +1,5 @@ /* USBnull - * Copyright (C) 2002-2004 USBnull Team + * Copyright (C) 2002-2009 USBnull 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 @@ -15,7 +15,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - + #include #include #include @@ -26,43 +26,7 @@ #include #include "USB.h" - -int ExecCfg(char *arg) -{ - char cfg[256]; - struct stat buf; - - strcpy(cfg, "./cfgUSBnull"); - if (stat(cfg, &buf) != -1) - { - sprintf(cfg, "%s %s", cfg, arg); - return system(cfg); - } - - strcpy(cfg, "./plugins/cfgUSBnull"); - if (stat(cfg, &buf) != -1) - { - sprintf(cfg, "%s %s", cfg, arg); - return system(cfg); - } - - strcpy(cfg, "./cfg/cfgUSBnull"); - if (stat(cfg, &buf) != -1) - - { sprintf(cfg, "%s %s", cfg, arg); - return system(cfg); - } - - sprintf(cfg, "%s/cfgUSBnull", getenv("HOME")); - if (stat(cfg, &buf) != -1) - { - sprintf(cfg, "%s %s", cfg, arg); - return system(cfg); - } - - printf("cfgUSBnull file not found!\n"); - return -1; -} +#include "Config.h" void SysMessage(char *fmt, ...) { @@ -74,25 +38,16 @@ void SysMessage(char *fmt, ...) vsprintf(msg, fmt, list); va_end(list); - sprintf(cmd, "message \"%s\"", msg); - ExecCfg(cmd); + cfgSysMessage(msg); } void USBconfigure() { - char *file; - getcwd(file, ArraySize(file)); - chdir("plugins"); - ExecCfg("configure"); - chdir(file); + CFGconfigure(); } void USBabout() { - char *file; - getcwd(file, ArraySize(file)); - chdir("plugins"); - ExecCfg("about"); - chdir(file); + CFGabout(); } diff --git a/plugins/USBnull/Linux/Linux.h b/plugins/USBnull/Linux/Linux.h new file mode 100644 index 0000000000..daa92044d1 --- /dev/null +++ b/plugins/USBnull/Linux/Linux.h @@ -0,0 +1,17 @@ +/* USBnull + * Copyright (C) 2002-2009 USBnull 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ diff --git a/plugins/USBnull/Linux/Makefile b/plugins/USBnull/Linux/Makefile deleted file mode 100644 index 1a5798ffcd..0000000000 --- a/plugins/USBnull/Linux/Makefile +++ /dev/null @@ -1,35 +0,0 @@ - -PLUGIN = libUSBnull.so -CFG = cfgUSBnull -CFLAGS+= -fPIC -Wall -I. -I.. -I../../../common/include -O3 -fomit-frame-pointer -fno-strict-aliasing -OBJS = ../USB.o -OBJS+= Config.o Linux.o -CFGOBJS = conf.o interface.o support.o -DEPS:= $(OBJS:.o=.d) -CFGDEPS:= $(CFGOBJS:.o=.d) -LIBS = -lpthread -CFLAGS+= $(shell pkg-config --cflags gtk+-2.0) -D__LINUX__ -CFGLIBS = $(shell pkg-config --libs gtk+-2.0) - -CC = gcc - -all: plugin cfg -install: all - -plugin: ${OBJS} -# rm -f ${PLUGIN} - ${CC} -shared -Wl,-soname,${PLUGIN} ${CFLAGS} ${OBJS} -o ${PLUGIN} ${LIBS} - strip --strip-unneeded --strip-debug ${PLUGIN} - -cfg: ${CFGOBJS} -# rm -f ${CFG} - ${CC} ${CFLAGS} ${CFGOBJS} -o ${CFG} ${CFGLIBS} - strip ${CFG} - -clean: - rm -f ${OBJS} ${CFGOBJS} ${CFGDEPS} ${PLUGIN} ${CFG} - -%.o: %.c - ${CC} ${CFLAGS} -c -o $@ $< -MD -MF $(patsubst %.o,%.d,$@) - -#-include ${DEPS} diff --git a/plugins/USBnull/Linux/interface.c b/plugins/USBnull/Linux/interface.c index 10dcc15912..5c23358a21 100644 --- a/plugins/USBnull/Linux/interface.c +++ b/plugins/USBnull/Linux/interface.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include @@ -18,6 +19,13 @@ #include "interface.h" #include "support.h" +#define GLADE_HOOKUP_OBJECT(component,widget,name) \ + g_object_set_data_full (G_OBJECT (component), name, \ + gtk_widget_ref (widget), (GDestroyNotify) gtk_widget_unref) + +#define GLADE_HOOKUP_OBJECT_NO_REF(component,widget,name) \ + g_object_set_data (G_OBJECT (component), name, widget) + GtkWidget* create_Config (void) { @@ -27,131 +35,146 @@ create_Config (void) GtkWidget *hbox1; GtkWidget *label4; GtkWidget *GtkCombo_Eth; + GList *GtkCombo_Eth_items = NULL; GtkWidget *combo_entry1; + GtkWidget *label1; GtkWidget *frame3; GtkWidget *hbox2; GtkWidget *label5; GtkWidget *GtkCombo_Hdd; + GList *GtkCombo_Hdd_items = NULL; GtkWidget *entry1; + GtkWidget *label15; GtkWidget *hbuttonbox1; GtkWidget *button1; GtkWidget *button2; Config = gtk_window_new (GTK_WINDOW_TOPLEVEL); - gtk_object_set_data (GTK_OBJECT (Config), "Config", Config); + gtk_widget_set_name (Config, "Config"); gtk_container_set_border_width (GTK_CONTAINER (Config), 5); - gtk_window_set_title (GTK_WINDOW (Config), "DEV9config"); - gtk_window_set_position (GTK_WINDOW (Config), GTK_WIN_POS_CENTER); + gtk_window_set_title (GTK_WINDOW (Config), _("DEV9config")); vbox1 = gtk_vbox_new (FALSE, 5); - gtk_widget_ref (vbox1); - gtk_object_set_data_full (GTK_OBJECT (Config), "vbox1", vbox1, - (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_set_name (vbox1, "vbox1"); gtk_widget_show (vbox1); gtk_container_add (GTK_CONTAINER (Config), vbox1); gtk_container_set_border_width (GTK_CONTAINER (vbox1), 5); - frame2 = gtk_frame_new ("Ethernet"); - gtk_widget_ref (frame2); - gtk_object_set_data_full (GTK_OBJECT (Config), "frame2", frame2, - (GtkDestroyNotify) gtk_widget_unref); + frame2 = gtk_frame_new (NULL); + gtk_widget_set_name (frame2, "frame2"); gtk_widget_show (frame2); gtk_box_pack_start (GTK_BOX (vbox1), frame2, TRUE, TRUE, 0); hbox1 = gtk_hbox_new (TRUE, 5); - gtk_widget_ref (hbox1); - gtk_object_set_data_full (GTK_OBJECT (Config), "hbox1", hbox1, - (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_set_name (hbox1, "hbox1"); gtk_widget_show (hbox1); gtk_container_add (GTK_CONTAINER (frame2), hbox1); gtk_container_set_border_width (GTK_CONTAINER (hbox1), 5); - label4 = gtk_label_new ("Device:"); - gtk_widget_ref (label4); - gtk_object_set_data_full (GTK_OBJECT (Config), "label4", label4, - (GtkDestroyNotify) gtk_widget_unref); + label4 = gtk_label_new (_("Device:")); + gtk_widget_set_name (label4, "label4"); gtk_widget_show (label4); gtk_box_pack_start (GTK_BOX (hbox1), label4, FALSE, FALSE, 0); + gtk_label_set_justify (GTK_LABEL (label4), GTK_JUSTIFY_CENTER); GtkCombo_Eth = gtk_combo_new (); - gtk_widget_ref (GtkCombo_Eth); - gtk_object_set_data_full (GTK_OBJECT (Config), "GtkCombo_Eth", GtkCombo_Eth, - (GtkDestroyNotify) gtk_widget_unref); + g_object_set_data (G_OBJECT (GTK_COMBO (GtkCombo_Eth)->popwin), + "GladeParentKey", GtkCombo_Eth); + gtk_widget_set_name (GtkCombo_Eth, "GtkCombo_Eth"); gtk_widget_show (GtkCombo_Eth); gtk_box_pack_start (GTK_BOX (hbox1), GtkCombo_Eth, FALSE, FALSE, 0); - gtk_widget_set_usize (GtkCombo_Eth, 130, -2); + GtkCombo_Eth_items = g_list_append (GtkCombo_Eth_items, (gpointer) ""); + gtk_combo_set_popdown_strings (GTK_COMBO (GtkCombo_Eth), GtkCombo_Eth_items); + g_list_free (GtkCombo_Eth_items); combo_entry1 = GTK_COMBO (GtkCombo_Eth)->entry; - gtk_widget_ref (combo_entry1); - gtk_object_set_data_full (GTK_OBJECT (Config), "combo_entry1", combo_entry1, - (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_set_name (combo_entry1, "combo_entry1"); gtk_widget_show (combo_entry1); - frame3 = gtk_frame_new ("Hdd"); - gtk_widget_ref (frame3); - gtk_object_set_data_full (GTK_OBJECT (Config), "frame3", frame3, - (GtkDestroyNotify) gtk_widget_unref); + label1 = gtk_label_new (_("Ethernet")); + gtk_widget_set_name (label1, "label1"); + gtk_widget_show (label1); + gtk_frame_set_label_widget (GTK_FRAME (frame2), label1); + + frame3 = gtk_frame_new (NULL); + gtk_widget_set_name (frame3, "frame3"); gtk_widget_show (frame3); gtk_box_pack_start (GTK_BOX (vbox1), frame3, TRUE, TRUE, 0); hbox2 = gtk_hbox_new (TRUE, 5); - gtk_widget_ref (hbox2); - gtk_object_set_data_full (GTK_OBJECT (Config), "hbox2", hbox2, - (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_set_name (hbox2, "hbox2"); gtk_widget_show (hbox2); gtk_container_add (GTK_CONTAINER (frame3), hbox2); gtk_container_set_border_width (GTK_CONTAINER (hbox2), 5); - label5 = gtk_label_new ("Device:"); - gtk_widget_ref (label5); - gtk_object_set_data_full (GTK_OBJECT (Config), "label5", label5, - (GtkDestroyNotify) gtk_widget_unref); + label5 = gtk_label_new (_("Device:")); + gtk_widget_set_name (label5, "label5"); gtk_widget_show (label5); gtk_box_pack_start (GTK_BOX (hbox2), label5, FALSE, FALSE, 0); + gtk_label_set_justify (GTK_LABEL (label5), GTK_JUSTIFY_CENTER); GtkCombo_Hdd = gtk_combo_new (); - gtk_widget_ref (GtkCombo_Hdd); - gtk_object_set_data_full (GTK_OBJECT (Config), "GtkCombo_Hdd", GtkCombo_Hdd, - (GtkDestroyNotify) gtk_widget_unref); + g_object_set_data (G_OBJECT (GTK_COMBO (GtkCombo_Hdd)->popwin), + "GladeParentKey", GtkCombo_Hdd); + gtk_widget_set_name (GtkCombo_Hdd, "GtkCombo_Hdd"); gtk_widget_show (GtkCombo_Hdd); gtk_box_pack_start (GTK_BOX (hbox2), GtkCombo_Hdd, FALSE, FALSE, 0); - gtk_widget_set_usize (GtkCombo_Hdd, 130, -2); + GtkCombo_Hdd_items = g_list_append (GtkCombo_Hdd_items, (gpointer) ""); + gtk_combo_set_popdown_strings (GTK_COMBO (GtkCombo_Hdd), GtkCombo_Hdd_items); + g_list_free (GtkCombo_Hdd_items); entry1 = GTK_COMBO (GtkCombo_Hdd)->entry; - gtk_widget_ref (entry1); - gtk_object_set_data_full (GTK_OBJECT (Config), "entry1", entry1, - (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_set_name (entry1, "entry1"); gtk_widget_show (entry1); + label15 = gtk_label_new (_("Hdd")); + gtk_widget_set_name (label15, "label15"); + gtk_widget_show (label15); + gtk_frame_set_label_widget (GTK_FRAME (frame3), label15); + hbuttonbox1 = gtk_hbutton_box_new (); - gtk_widget_ref (hbuttonbox1); - gtk_object_set_data_full (GTK_OBJECT (Config), "hbuttonbox1", hbuttonbox1, - (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_set_name (hbuttonbox1, "hbuttonbox1"); gtk_widget_show (hbuttonbox1); gtk_box_pack_start (GTK_BOX (vbox1), hbuttonbox1, TRUE, TRUE, 0); + gtk_box_set_spacing (GTK_BOX (hbuttonbox1), 30); - button1 = gtk_button_new_with_label ("Ok"); - gtk_widget_ref (button1); - gtk_object_set_data_full (GTK_OBJECT (Config), "button1", button1, - (GtkDestroyNotify) gtk_widget_unref); + button1 = gtk_button_new_with_mnemonic (_("Ok")); + gtk_widget_set_name (button1, "button1"); gtk_widget_show (button1); gtk_container_add (GTK_CONTAINER (hbuttonbox1), button1); GTK_WIDGET_SET_FLAGS (button1, GTK_CAN_DEFAULT); - button2 = gtk_button_new_with_label ("Cancel"); - gtk_widget_ref (button2); - gtk_object_set_data_full (GTK_OBJECT (Config), "button2", button2, - (GtkDestroyNotify) gtk_widget_unref); + button2 = gtk_button_new_with_mnemonic (_("Cancel")); + gtk_widget_set_name (button2, "button2"); gtk_widget_show (button2); gtk_container_add (GTK_CONTAINER (hbuttonbox1), button2); GTK_WIDGET_SET_FLAGS (button2, GTK_CAN_DEFAULT); - gtk_signal_connect (GTK_OBJECT (button1), "clicked", - GTK_SIGNAL_FUNC (OnConf_Ok), - NULL); - gtk_signal_connect (GTK_OBJECT (button2), "clicked", - GTK_SIGNAL_FUNC (OnConf_Cancel), - NULL); + g_signal_connect ((gpointer) button1, "clicked", + G_CALLBACK (OnConf_Ok), + NULL); + g_signal_connect ((gpointer) button2, "clicked", + G_CALLBACK (OnConf_Cancel), + NULL); + + /* Store pointers to all widgets, for use by lookup_widget(). */ + GLADE_HOOKUP_OBJECT_NO_REF (Config, Config, "Config"); + GLADE_HOOKUP_OBJECT (Config, vbox1, "vbox1"); + GLADE_HOOKUP_OBJECT (Config, frame2, "frame2"); + GLADE_HOOKUP_OBJECT (Config, hbox1, "hbox1"); + GLADE_HOOKUP_OBJECT (Config, label4, "label4"); + GLADE_HOOKUP_OBJECT (Config, GtkCombo_Eth, "GtkCombo_Eth"); + GLADE_HOOKUP_OBJECT (Config, combo_entry1, "combo_entry1"); + GLADE_HOOKUP_OBJECT (Config, label1, "label1"); + GLADE_HOOKUP_OBJECT (Config, frame3, "frame3"); + GLADE_HOOKUP_OBJECT (Config, hbox2, "hbox2"); + GLADE_HOOKUP_OBJECT (Config, label5, "label5"); + GLADE_HOOKUP_OBJECT (Config, GtkCombo_Hdd, "GtkCombo_Hdd"); + GLADE_HOOKUP_OBJECT (Config, entry1, "entry1"); + GLADE_HOOKUP_OBJECT (Config, label15, "label15"); + GLADE_HOOKUP_OBJECT (Config, hbuttonbox1, "hbuttonbox1"); + GLADE_HOOKUP_OBJECT (Config, button1, "button1"); + GLADE_HOOKUP_OBJECT (Config, button2, "button2"); return Config; } @@ -167,52 +190,50 @@ create_About (void) GtkWidget *button3; About = gtk_window_new (GTK_WINDOW_TOPLEVEL); - gtk_object_set_data (GTK_OBJECT (About), "About", About); + gtk_widget_set_name (About, "About"); gtk_container_set_border_width (GTK_CONTAINER (About), 5); - gtk_window_set_title (GTK_WINDOW (About), "DEV9about"); - gtk_window_set_position (GTK_WINDOW (About), GTK_WIN_POS_CENTER); + gtk_window_set_title (GTK_WINDOW (About), _("DEV9about")); vbox2 = gtk_vbox_new (FALSE, 5); - gtk_widget_ref (vbox2); - gtk_object_set_data_full (GTK_OBJECT (About), "vbox2", vbox2, - (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_set_name (vbox2, "vbox2"); gtk_widget_show (vbox2); gtk_container_add (GTK_CONTAINER (About), vbox2); gtk_container_set_border_width (GTK_CONTAINER (vbox2), 5); - label2 = gtk_label_new ("DEV9linuz Driver"); - gtk_widget_ref (label2); - gtk_object_set_data_full (GTK_OBJECT (About), "label2", label2, - (GtkDestroyNotify) gtk_widget_unref); + label2 = gtk_label_new (_("FireWire Driver")); + gtk_widget_set_name (label2, "label2"); gtk_widget_show (label2); gtk_box_pack_start (GTK_BOX (vbox2), label2, FALSE, FALSE, 0); + gtk_label_set_justify (GTK_LABEL (label2), GTK_JUSTIFY_CENTER); - label3 = gtk_label_new ("Author: linuzappz "); - gtk_widget_ref (label3); - gtk_object_set_data_full (GTK_OBJECT (About), "label3", label3, - (GtkDestroyNotify) gtk_widget_unref); + label3 = gtk_label_new (_("Author: linuzappz ")); + gtk_widget_set_name (label3, "label3"); gtk_widget_show (label3); gtk_box_pack_start (GTK_BOX (vbox2), label3, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label3), GTK_JUSTIFY_LEFT); hbuttonbox2 = gtk_hbutton_box_new (); - gtk_widget_ref (hbuttonbox2); - gtk_object_set_data_full (GTK_OBJECT (About), "hbuttonbox2", hbuttonbox2, - (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_set_name (hbuttonbox2, "hbuttonbox2"); gtk_widget_show (hbuttonbox2); gtk_box_pack_start (GTK_BOX (vbox2), hbuttonbox2, TRUE, TRUE, 0); + gtk_box_set_spacing (GTK_BOX (hbuttonbox2), 30); - button3 = gtk_button_new_with_label ("Ok"); - gtk_widget_ref (button3); - gtk_object_set_data_full (GTK_OBJECT (About), "button3", button3, - (GtkDestroyNotify) gtk_widget_unref); + button3 = gtk_button_new_with_mnemonic (_("Ok")); + gtk_widget_set_name (button3, "button3"); gtk_widget_show (button3); gtk_container_add (GTK_CONTAINER (hbuttonbox2), button3); GTK_WIDGET_SET_FLAGS (button3, GTK_CAN_DEFAULT); - gtk_signal_connect (GTK_OBJECT (button3), "clicked", - GTK_SIGNAL_FUNC (OnAbout_Ok), - NULL); + g_signal_connect ((gpointer) button3, "clicked", + G_CALLBACK (OnAbout_Ok), + NULL); + + /* Store pointers to all widgets, for use by lookup_widget(). */ + GLADE_HOOKUP_OBJECT_NO_REF (About, About, "About"); + GLADE_HOOKUP_OBJECT (About, vbox2, "vbox2"); + GLADE_HOOKUP_OBJECT (About, label2, "label2"); + GLADE_HOOKUP_OBJECT (About, label3, "label3"); + GLADE_HOOKUP_OBJECT (About, hbuttonbox2, "hbuttonbox2"); + GLADE_HOOKUP_OBJECT (About, button3, "button3"); return About; } diff --git a/plugins/USBnull/Linux/support.c b/plugins/USBnull/Linux/support.c index 65007c9217..00aff29822 100644 --- a/plugins/USBnull/Linux/support.c +++ b/plugins/USBnull/Linux/support.c @@ -10,18 +10,12 @@ #include #include #include +#include #include #include "support.h" -/* This is an internally used function to check if a pixmap file exists. */ -static gchar* check_file_exists (const gchar *directory, - const gchar *filename); - -/* This is an internally used function to create pixmaps. */ -static GtkWidget* create_dummy_pixmap (GtkWidget *widget); - GtkWidget* lookup_widget (GtkWidget *widget, const gchar *widget_name) @@ -34,47 +28,20 @@ lookup_widget (GtkWidget *widget, parent = gtk_menu_get_attach_widget (GTK_MENU (widget)); else parent = widget->parent; + if (!parent) + parent = (GtkWidget*) g_object_get_data (G_OBJECT (widget), "GladeParentKey"); if (parent == NULL) break; widget = parent; } - found_widget = (GtkWidget*) gtk_object_get_data (GTK_OBJECT (widget), - widget_name); + found_widget = (GtkWidget*) g_object_get_data (G_OBJECT (widget), + widget_name); if (!found_widget) g_warning ("Widget not found: %s", widget_name); return found_widget; } -/* This is a dummy pixmap we use when a pixmap can't be found. */ -static char *dummy_pixmap_xpm[] = { -/* columns rows colors chars-per-pixel */ -"1 1 1 1", -" c None", -/* pixels */ -" " -}; - -/* This is an internally used function to create pixmaps. */ -static GtkWidget* -create_dummy_pixmap (GtkWidget *widget) -{ - GdkColormap *colormap; - GdkPixmap *gdkpixmap; - GdkBitmap *mask; - GtkWidget *pixmap; - - colormap = gtk_widget_get_colormap (widget); - gdkpixmap = gdk_pixmap_colormap_create_from_xpm_d (NULL, colormap, &mask, - NULL, dummy_pixmap_xpm); - if (gdkpixmap == NULL) - g_error ("Couldn't create replacement pixmap."); - pixmap = gtk_pixmap_new (gdkpixmap, mask); - gdk_pixmap_unref (gdkpixmap); - gdk_bitmap_unref (mask); - return pixmap; -} - static GList *pixmaps_directories = NULL; /* Use this function to set the directory containing installed pixmaps. */ @@ -85,78 +52,93 @@ add_pixmap_directory (const gchar *directory) g_strdup (directory)); } +/* This is an internally used function to find pixmap files. */ +static gchar* +find_pixmap_file (const gchar *filename) +{ + GList *elem; + + /* We step through each of the pixmaps directory to find it. */ + elem = pixmaps_directories; + while (elem) + { + gchar *pathname = g_strdup_printf ("%s%s%s", (gchar*)elem->data, + G_DIR_SEPARATOR_S, filename); + if (g_file_test (pathname, G_FILE_TEST_EXISTS)) + return pathname; + g_free (pathname); + elem = elem->next; + } + return NULL; +} + /* This is an internally used function to create pixmaps. */ GtkWidget* create_pixmap (GtkWidget *widget, const gchar *filename) { - gchar *found_filename = NULL; - GdkColormap *colormap; - GdkPixmap *gdkpixmap; - GdkBitmap *mask; + gchar *pathname = NULL; GtkWidget *pixmap; - GList *elem; if (!filename || !filename[0]) - return create_dummy_pixmap (widget); + return gtk_image_new (); - /* We first try any pixmaps directories set by the application. */ - elem = pixmaps_directories; - while (elem) + pathname = find_pixmap_file (filename); + + if (!pathname) { - found_filename = check_file_exists ((gchar*)elem->data, filename); - if (found_filename) - break; - elem = elem->next; + g_warning (_("Couldn't find pixmap file: %s"), filename); + return gtk_image_new (); } - /* If we haven't found the pixmap, try the source directory. */ - if (!found_filename) - { - found_filename = check_file_exists ("pixmaps", filename); - } - - if (!found_filename) - { - g_warning ("Couldn't find pixmap file: %s", filename); - return create_dummy_pixmap (widget); - } - - colormap = gtk_widget_get_colormap (widget); - gdkpixmap = gdk_pixmap_colormap_create_from_xpm (NULL, colormap, &mask, - NULL, found_filename); - if (gdkpixmap == NULL) - { - g_warning ("Error loading pixmap file: %s", found_filename); - g_free (found_filename); - return create_dummy_pixmap (widget); - } - g_free (found_filename); - pixmap = gtk_pixmap_new (gdkpixmap, mask); - gdk_pixmap_unref (gdkpixmap); - gdk_bitmap_unref (mask); + pixmap = gtk_image_new_from_file (pathname); + g_free (pathname); return pixmap; } -/* This is an internally used function to check if a pixmap file exists. */ -static gchar* -check_file_exists (const gchar *directory, - const gchar *filename) +/* This is an internally used function to create pixmaps. */ +GdkPixbuf* +create_pixbuf (const gchar *filename) { - gchar *full_filename; - struct stat s; - gint status; + gchar *pathname = NULL; + GdkPixbuf *pixbuf; + GError *error = NULL; - full_filename = (gchar*) g_malloc (strlen (directory) + 1 - + strlen (filename) + 1); - strcpy (full_filename, directory); - strcat (full_filename, G_DIR_SEPARATOR_S); - strcat (full_filename, filename); + if (!filename || !filename[0]) + return NULL; - status = stat (full_filename, &s); - if (status == 0 && S_ISREG (s.st_mode)) - return full_filename; - g_free (full_filename); - return NULL; + pathname = find_pixmap_file (filename); + + if (!pathname) + { + g_warning (_("Couldn't find pixmap file: %s"), filename); + return NULL; + } + + pixbuf = gdk_pixbuf_new_from_file (pathname, &error); + if (!pixbuf) + { + fprintf (stderr, "Failed to load pixbuf file: %s: %s\n", + pathname, error->message); + g_error_free (error); + } + g_free (pathname); + return pixbuf; +} + +/* This is used to set ATK action descriptions. */ +void +glade_set_atk_action_description (AtkAction *action, + const gchar *action_name, + const gchar *description) +{ + gint n_actions, i; + + n_actions = atk_action_get_n_actions (action); + for (i = 0; i < n_actions; i++) + { + if (!strcmp (atk_action_get_name (action, i), action_name)) + atk_action_set_description (action, i, description); + } } diff --git a/plugins/USBnull/Linux/support.h b/plugins/USBnull/Linux/support.h index aee31f935d..a32649e53c 100644 --- a/plugins/USBnull/Linux/support.h +++ b/plugins/USBnull/Linux/support.h @@ -8,6 +8,31 @@ #include +/* + * Standard gettext macros. + */ +#ifdef ENABLE_NLS +# include +# undef _ +# define _(String) dgettext (PACKAGE, String) +# define Q_(String) g_strip_context ((String), gettext (String)) +# ifdef gettext_noop +# define N_(String) gettext_noop (String) +# else +# define N_(String) (String) +# endif +#else +# define textdomain(String) (String) +# define gettext(String) (String) +# define dgettext(Domain,Message) (Message) +# define dcgettext(Domain,Message,Type) (Message) +# define bindtextdomain(Domain,Directory) (Domain) +# define _(String) (String) +# define Q_(String) g_strip_context ((String), (String)) +# define N_(String) (String) +#endif + + /* * Public Functions. */ @@ -21,8 +46,6 @@ GtkWidget* lookup_widget (GtkWidget *widget, const gchar *widget_name); -/* get_widget() is deprecated. Use lookup_widget instead. */ -#define get_widget lookup_widget /* Use this function to set the directory containing installed pixmaps. */ void add_pixmap_directory (const gchar *directory); @@ -32,7 +55,15 @@ void add_pixmap_directory (const gchar *directory); * Private Functions. */ -/* This is used to create the pixmaps in the interface. */ +/* This is used to create the pixmaps used in the interface. */ GtkWidget* create_pixmap (GtkWidget *widget, const gchar *filename); +/* This is used to create the pixbufs used in the interface. */ +GdkPixbuf* create_pixbuf (const gchar *filename); + +/* This is used to set ATK action descriptions. */ +void glade_set_atk_action_description (AtkAction *action, + const gchar *action_name, + const gchar *description); + diff --git a/plugins/USBnull/Linux/usbnull.glade b/plugins/USBnull/Linux/usbnull.glade index 6644e52247..cef4eab65e 100644 --- a/plugins/USBnull/Linux/usbnull.glade +++ b/plugins/USBnull/Linux/usbnull.glade @@ -1,300 +1,443 @@ - - - - - FireWire - dev9linuz - - - pixmaps - C - False - False - False - False - False - - - - GtkWindow - Config - 5 - DEV9config - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_CENTER - False - False - True - False - - - GtkVBox - vbox1 - 5 - False - 5 - - - GtkFrame - frame2 - - 0 - GTK_SHADOW_ETCHED_IN - - 0 - True - True - - - - GtkHBox - hbox1 - 5 - True - 5 - - - GtkLabel - label4 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 0 - 0 - - 0 - False - False - - - - - GtkCombo - GtkCombo_Eth - 130 - False - True - False - True - False - - - 0 - False - False - - - - GtkEntry - GtkCombo:entry - combo-entry1 - True - True - True - 0 - - - - - - - - GtkFrame - frame3 - - 0 - GTK_SHADOW_ETCHED_IN - - 0 - True - True - - - - GtkHBox - hbox2 - 5 - True - 5 - - - GtkLabel - label5 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 0 - 0 - - 0 - False - False - - - - - GtkCombo - GtkCombo_Hdd - 130 - False - True - False - True - False - - - 0 - False - False - - - - GtkEntry - GtkCombo:entry - entry1 - True - True - True - 0 - - - - - - - - GtkHButtonBox - hbuttonbox1 - GTK_BUTTONBOX_DEFAULT_STYLE - 30 - 85 - 27 - 7 - 0 - - 0 - True - True - - - - GtkButton - button1 - True - True - - clicked - OnConf_Ok - Sat, 06 Apr 2002 17:07:56 GMT - - - GTK_RELIEF_NORMAL - - - - GtkButton - button2 - True - True - - clicked - OnConf_Cancel - Sat, 06 Apr 2002 17:08:08 GMT - - - GTK_RELIEF_NORMAL - - - - - - - GtkWindow - About - 5 - DEV9about - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_CENTER - False - False - True - False - - - GtkVBox - vbox2 - 5 - False - 5 - - - GtkLabel - label2 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 0 - 0 - - 0 - False - False - - - - - GtkLabel - label3 - - GTK_JUSTIFY_LEFT - False - 0.5 - 0.5 - 0 - 0 - - 0 - False - False - - - - - GtkHButtonBox - hbuttonbox2 - GTK_BUTTONBOX_DEFAULT_STYLE - 30 - 85 - 27 - 7 - 0 - - 0 - True - True - - - - GtkButton - button3 - True - True - - clicked - OnAbout_Ok - Sun, 07 Apr 2002 03:43:49 GMT - - - GTK_RELIEF_NORMAL - - - - - - + + + + + + + 5 + True + DEV9config + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + True + False + True + False + False + GDK_WINDOW_TYPE_HINT_NORMAL + GDK_GRAVITY_NORTH_WEST + True + False + + + + 5 + True + False + 5 + + + + True + 0 + 0.5 + GTK_SHADOW_ETCHED_IN + + + + 5 + True + True + 5 + + + + True + Device: + False + False + GTK_JUSTIFY_CENTER + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + False + False + + + + + + True + False + True + False + True + False + + + + True + True + True + True + 0 + + True + * + False + + + + + + True + GTK_SELECTION_BROWSE + + + + True + + + + True + + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + + + + + + + 0 + False + False + + + + + + + + True + Ethernet + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + label_item + + + + + 0 + True + True + + + + + + True + 0 + 0.5 + GTK_SHADOW_ETCHED_IN + + + + 5 + True + True + 5 + + + + True + Device: + False + False + GTK_JUSTIFY_CENTER + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + False + False + + + + + + True + False + True + False + True + False + + + + True + True + True + True + 0 + + True + * + False + + + + + + True + GTK_SELECTION_BROWSE + + + + True + + + + True + + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + + + + + + + 0 + False + False + + + + + + + + True + Hdd + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + label_item + + + + + 0 + True + True + + + + + + True + GTK_BUTTONBOX_DEFAULT_STYLE + 30 + + + + True + True + True + Ok + True + GTK_RELIEF_NORMAL + True + + + + + + + True + True + True + Cancel + True + GTK_RELIEF_NORMAL + True + + + + + + 0 + True + True + + + + + + + + 5 + True + DEV9about + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + True + False + True + False + False + GDK_WINDOW_TYPE_HINT_NORMAL + GDK_GRAVITY_NORTH_WEST + True + False + + + + 5 + True + False + 5 + + + + True + FireWire Driver + False + False + GTK_JUSTIFY_CENTER + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + False + False + + + + + + True + Author: linuzappz <linuzappz@hotmail.com> + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + False + False + + + + + + True + GTK_BUTTONBOX_DEFAULT_STYLE + 30 + + + + True + True + True + Ok + True + GTK_RELIEF_NORMAL + True + + + + + + 0 + True + True + + + + + + + diff --git a/plugins/USBnull/Makefile.am b/plugins/USBnull/Makefile.am new file mode 100644 index 0000000000..d4241d3ad0 --- /dev/null +++ b/plugins/USBnull/Makefile.am @@ -0,0 +1,33 @@ +# Create a shared library libUSBnull +AUTOMAKE_OPTIONS = foreign +noinst_LIBRARIES = libUSBnull.a +INCLUDES = -I@srcdir@/../../common/include -I@srcdir@/../../3rdparty -I@srcdir@/Linux + +libUSBnull_a_CXXFLAGS = $(shell pkg-config --cflags gtk+-2.0) +libUSBnull_a_CFLAGS = $(shell pkg-config --cflags gtk+-2.0) + +# Create a shared object by faking an exe (thanks to ODE makefiles) +traplibdir=$(prefix) + +if DEBUGBUILD +preext=d +endif + +EXEEXT=$(preext)@so_ext@ + +traplib_PROGRAMS=libUSBnull +libUSBnull_SOURCES= +libUSBnull_DEPENDENCIES = libUSBnull.a +libUSBnull_LDFLAGS= @SHARED_LDFLAGS@ +libUSBnull_LDFLAGS+=-Wl,-soname,@libUSBnull_SONAME@ +libUSBnull_LDADD=$(libUSBnull_a_OBJECTS) + +libUSBnull_a_SOURCES = USB.cpp Linux/Config.cpp Linux/Linux.cpp \ +USB.h Linux/Config.h Linux/Linux.h + +libUSBnull_a_SOURCES += \ +Linux/interface.h Linux/support.c \ +Linux/interface.c Linux/support.h \ +Linux/callbacks.c Linux/callbacks.h + +#SUBDIRS = Linux \ No newline at end of file diff --git a/plugins/USBnull/USB.c b/plugins/USBnull/USB.cpp similarity index 62% rename from plugins/USBnull/USB.c rename to plugins/USBnull/USB.cpp index f8b9ac9952..6aa6bab4bc 100644 --- a/plugins/USBnull/USB.c +++ b/plugins/USBnull/USB.cpp @@ -19,30 +19,39 @@ #include #include #include +#include +using namespace std; #include "USB.h" - - +string s_strIniPath; const unsigned char version = PS2E_USB_VERSION; const unsigned char revision = 0; -const unsigned char build = 5; // increase that with each version +const unsigned char build = 6; // increase that with each version static char *libraryName = "USBnull Driver"; +//void (*USBirq)(); +USBcallback USBirq; +Config conf; +FILE *usbLog; -u32 CALLBACK PS2EgetLibType() { +EXPORT_C_(u32) PS2EgetLibType() +{ return PS2E_LT_USB; } -char* CALLBACK PS2EgetLibName() { +EXPORT_C_(char*) PS2EgetLibName() +{ return libraryName; } -u32 CALLBACK PS2EgetLibVersion2(u32 type) { - return (version<<16) | (revision<<8) | build; +EXPORT_C_(u32) PS2EgetLibVersion2(u32 type) +{ + return (version << 16) | (revision << 8) | build; } -void __Log(char *fmt, ...) { +void __Log(char *fmt, ...) +{ va_list list; if (!conf.Log || usbLog == NULL) return; @@ -52,119 +61,100 @@ void __Log(char *fmt, ...) { va_end(list); } -s32 CALLBACK USBinit() { - LoadConfig(); +EXPORT_C_(s32) USBinit() +{ + LoadConfig(); #ifdef USB_LOG usbLog = fopen("logs/usbLog.txt", "w"); if (usbLog) setvbuf(usbLog, NULL, _IONBF, 0); - USB_LOG("usbnull plugin version %d,%d\n",revision,build); + USB_LOG("usbnull plugin version %d,%d\n", revision, build); USB_LOG("USBinit\n"); #endif return 0; } -void CALLBACK USBshutdown() { +EXPORT_C_(void) USBshutdown() +{ #ifdef USB_LOG if (usbLog) fclose(usbLog); #endif } -s32 CALLBACK USBopen(void *pDsp) { -#ifdef USB_LOG +EXPORT_C_(s32) USBopen(void *pDsp) +{ USB_LOG("USBopen\n"); -#endif - -#ifdef _WIN32 -#else - Display* dsp = *(Display**)pDsp; -#endif return 0; } -void CALLBACK USBclose() { +EXPORT_C_(void) USBclose() +{ } -u8 CALLBACK USBread8(u32 addr) { - - - -#ifdef USB_LOG +EXPORT_C_(u8 ) USBread8(u32 addr) +{ USB_LOG("*UnKnown 8bit read at address %lx ", addr); -#endif return 0; } -u16 CALLBACK USBread16(u32 addr) { - - - -#ifdef USB_LOG +EXPORT_C_(u16) USBread16(u32 addr) +{ USB_LOG("*UnKnown 16bit read at address %lx", addr); -#endif return 0; } -u32 CALLBACK USBread32(u32 addr) { - -#ifdef USB_LOG +EXPORT_C_(u32) USBread32(u32 addr) +{ USB_LOG("*UnKnown 32bit read at address %lx", addr); -#endif return 0; } -void CALLBACK USBwrite8(u32 addr, u8 value) { - -#ifdef USB_LOG +EXPORT_C_(void) USBwrite8(u32 addr, u8 value) +{ USB_LOG("*UnKnown 8bit write at address %lx value %x\n", addr, value); -#endif } -void CALLBACK USBwrite16(u32 addr, u16 value) { - -#ifdef USB_LOG +EXPORT_C_(void) USBwrite16(u32 addr, u16 value) +{ USB_LOG("*UnKnown 16bit write at address %lx value %x\n", addr, value); -#endif } -void CALLBACK USBwrite32(u32 addr, u32 value) { - -#ifdef USB_LOG +EXPORT_C_(void) USBwrite32(u32 addr, u32 value) +{ USB_LOG("*UnKnown 32bit write at address %lx value %lx\n", addr, value); -#endif } -void CALLBACK USBirqCallback(USBcallback callback) { - USBirq = callback; +EXPORT_C_(void) USBirqCallback(USBcallback callback) +{ + USBirq = callback; } -int CALLBACK _USBirqHandler(void) { - +EXPORT_C_(int) _USBirqHandler(void) +{ return 0; } -USBhandler CALLBACK USBirqHandler(void) { +EXPORT_C_(USBhandler) USBirqHandler(void) +{ return (USBhandler)_USBirqHandler; } -void CALLBACK USBsetRAM(void *mem) { - +EXPORT_C_(void) USBsetRAM(void *mem) +{ } // extended funcs - - -s32 CALLBACK USBfreeze(int mode, freezeData *data) { - - +EXPORT_C_(s32) USBfreeze(int mode, freezeData *data) +{ return 0; } -s32 CALLBACK USBtest() { +EXPORT_C_(s32) USBtest() +{ return 0; } diff --git a/plugins/USBnull/USB.h b/plugins/USBnull/USB.h index bb2243c965..75c833e046 100644 --- a/plugins/USBnull/USB.h +++ b/plugins/USBnull/USB.h @@ -22,8 +22,11 @@ #include +extern "C" +{ #define USBdefs #include "PS2Edefs.h" +} #ifdef _WIN32 @@ -46,19 +49,24 @@ typedef struct { int Log; } Config; -Config conf; - +//extern void (*USBirq)(); +extern USBcallback USBirq; +extern Config conf; +extern FILE *usbLog; +#ifdef _MSC_VER +#define EXPORT_C_(type) extern "C" __declspec(dllexport) type CALLBACK +#else +#define EXPORT_C_(type) extern "C" type +#endif #define PSXCLK 36864000 /* 36.864 Mhz */ -USBcallback USBirq; void SaveConfig(); void LoadConfig(); -FILE *usbLog; void __Log(char *fmt, ...); void SysMessage(char *fmt, ...); diff --git a/plugins/USBnull/Windows/USBnull_vc2008.vcproj b/plugins/USBnull/Windows/USBnull_vc2008.vcproj index 87cafd596e..3092b94f31 100644 --- a/plugins/USBnull/Windows/USBnull_vc2008.vcproj +++ b/plugins/USBnull/Windows/USBnull_vc2008.vcproj @@ -161,7 +161,7 @@ > Date: Sat, 2 May 2009 02:45:13 +0000 Subject: [PATCH 32/41] I don't even wan to know how these got deleted during the commit... git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1108 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/FWnull/Linux/callbacks.c | 34 +++++ plugins/FWnull/Linux/interface.c | 240 +++++++++++++++++++++++++++++++ plugins/FWnull/Linux/support.c | 144 +++++++++++++++++++ 3 files changed, 418 insertions(+) create mode 100644 plugins/FWnull/Linux/callbacks.c create mode 100644 plugins/FWnull/Linux/interface.c create mode 100644 plugins/FWnull/Linux/support.c diff --git a/plugins/FWnull/Linux/callbacks.c b/plugins/FWnull/Linux/callbacks.c new file mode 100644 index 0000000000..e87ed8be2d --- /dev/null +++ b/plugins/FWnull/Linux/callbacks.c @@ -0,0 +1,34 @@ +#ifdef HAVE_CONFIG_H +# include +#endif + +#include + +#include "callbacks.h" +#include "interface.h" +#include "support.h" + + +void +OnConf_Ok (GtkButton *button, + gpointer user_data) +{ + +} + + +void +OnConf_Cancel (GtkButton *button, + gpointer user_data) +{ + +} + + +void +OnAbout_Ok (GtkButton *button, + gpointer user_data) +{ + +} + diff --git a/plugins/FWnull/Linux/interface.c b/plugins/FWnull/Linux/interface.c new file mode 100644 index 0000000000..5c23358a21 --- /dev/null +++ b/plugins/FWnull/Linux/interface.c @@ -0,0 +1,240 @@ +/* + * DO NOT EDIT THIS FILE - it is generated by Glade. + */ + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include +#include +#include +#include +#include + +#include +#include + +#include "callbacks.h" +#include "interface.h" +#include "support.h" + +#define GLADE_HOOKUP_OBJECT(component,widget,name) \ + g_object_set_data_full (G_OBJECT (component), name, \ + gtk_widget_ref (widget), (GDestroyNotify) gtk_widget_unref) + +#define GLADE_HOOKUP_OBJECT_NO_REF(component,widget,name) \ + g_object_set_data (G_OBJECT (component), name, widget) + +GtkWidget* +create_Config (void) +{ + GtkWidget *Config; + GtkWidget *vbox1; + GtkWidget *frame2; + GtkWidget *hbox1; + GtkWidget *label4; + GtkWidget *GtkCombo_Eth; + GList *GtkCombo_Eth_items = NULL; + GtkWidget *combo_entry1; + GtkWidget *label1; + GtkWidget *frame3; + GtkWidget *hbox2; + GtkWidget *label5; + GtkWidget *GtkCombo_Hdd; + GList *GtkCombo_Hdd_items = NULL; + GtkWidget *entry1; + GtkWidget *label15; + GtkWidget *hbuttonbox1; + GtkWidget *button1; + GtkWidget *button2; + + Config = gtk_window_new (GTK_WINDOW_TOPLEVEL); + gtk_widget_set_name (Config, "Config"); + gtk_container_set_border_width (GTK_CONTAINER (Config), 5); + gtk_window_set_title (GTK_WINDOW (Config), _("DEV9config")); + + vbox1 = gtk_vbox_new (FALSE, 5); + gtk_widget_set_name (vbox1, "vbox1"); + gtk_widget_show (vbox1); + gtk_container_add (GTK_CONTAINER (Config), vbox1); + gtk_container_set_border_width (GTK_CONTAINER (vbox1), 5); + + frame2 = gtk_frame_new (NULL); + gtk_widget_set_name (frame2, "frame2"); + gtk_widget_show (frame2); + gtk_box_pack_start (GTK_BOX (vbox1), frame2, TRUE, TRUE, 0); + + hbox1 = gtk_hbox_new (TRUE, 5); + gtk_widget_set_name (hbox1, "hbox1"); + gtk_widget_show (hbox1); + gtk_container_add (GTK_CONTAINER (frame2), hbox1); + gtk_container_set_border_width (GTK_CONTAINER (hbox1), 5); + + label4 = gtk_label_new (_("Device:")); + gtk_widget_set_name (label4, "label4"); + gtk_widget_show (label4); + gtk_box_pack_start (GTK_BOX (hbox1), label4, FALSE, FALSE, 0); + gtk_label_set_justify (GTK_LABEL (label4), GTK_JUSTIFY_CENTER); + + GtkCombo_Eth = gtk_combo_new (); + g_object_set_data (G_OBJECT (GTK_COMBO (GtkCombo_Eth)->popwin), + "GladeParentKey", GtkCombo_Eth); + gtk_widget_set_name (GtkCombo_Eth, "GtkCombo_Eth"); + gtk_widget_show (GtkCombo_Eth); + gtk_box_pack_start (GTK_BOX (hbox1), GtkCombo_Eth, FALSE, FALSE, 0); + GtkCombo_Eth_items = g_list_append (GtkCombo_Eth_items, (gpointer) ""); + gtk_combo_set_popdown_strings (GTK_COMBO (GtkCombo_Eth), GtkCombo_Eth_items); + g_list_free (GtkCombo_Eth_items); + + combo_entry1 = GTK_COMBO (GtkCombo_Eth)->entry; + gtk_widget_set_name (combo_entry1, "combo_entry1"); + gtk_widget_show (combo_entry1); + + label1 = gtk_label_new (_("Ethernet")); + gtk_widget_set_name (label1, "label1"); + gtk_widget_show (label1); + gtk_frame_set_label_widget (GTK_FRAME (frame2), label1); + + frame3 = gtk_frame_new (NULL); + gtk_widget_set_name (frame3, "frame3"); + gtk_widget_show (frame3); + gtk_box_pack_start (GTK_BOX (vbox1), frame3, TRUE, TRUE, 0); + + hbox2 = gtk_hbox_new (TRUE, 5); + gtk_widget_set_name (hbox2, "hbox2"); + gtk_widget_show (hbox2); + gtk_container_add (GTK_CONTAINER (frame3), hbox2); + gtk_container_set_border_width (GTK_CONTAINER (hbox2), 5); + + label5 = gtk_label_new (_("Device:")); + gtk_widget_set_name (label5, "label5"); + gtk_widget_show (label5); + gtk_box_pack_start (GTK_BOX (hbox2), label5, FALSE, FALSE, 0); + gtk_label_set_justify (GTK_LABEL (label5), GTK_JUSTIFY_CENTER); + + GtkCombo_Hdd = gtk_combo_new (); + g_object_set_data (G_OBJECT (GTK_COMBO (GtkCombo_Hdd)->popwin), + "GladeParentKey", GtkCombo_Hdd); + gtk_widget_set_name (GtkCombo_Hdd, "GtkCombo_Hdd"); + gtk_widget_show (GtkCombo_Hdd); + gtk_box_pack_start (GTK_BOX (hbox2), GtkCombo_Hdd, FALSE, FALSE, 0); + GtkCombo_Hdd_items = g_list_append (GtkCombo_Hdd_items, (gpointer) ""); + gtk_combo_set_popdown_strings (GTK_COMBO (GtkCombo_Hdd), GtkCombo_Hdd_items); + g_list_free (GtkCombo_Hdd_items); + + entry1 = GTK_COMBO (GtkCombo_Hdd)->entry; + gtk_widget_set_name (entry1, "entry1"); + gtk_widget_show (entry1); + + label15 = gtk_label_new (_("Hdd")); + gtk_widget_set_name (label15, "label15"); + gtk_widget_show (label15); + gtk_frame_set_label_widget (GTK_FRAME (frame3), label15); + + hbuttonbox1 = gtk_hbutton_box_new (); + gtk_widget_set_name (hbuttonbox1, "hbuttonbox1"); + gtk_widget_show (hbuttonbox1); + gtk_box_pack_start (GTK_BOX (vbox1), hbuttonbox1, TRUE, TRUE, 0); + gtk_box_set_spacing (GTK_BOX (hbuttonbox1), 30); + + button1 = gtk_button_new_with_mnemonic (_("Ok")); + gtk_widget_set_name (button1, "button1"); + gtk_widget_show (button1); + gtk_container_add (GTK_CONTAINER (hbuttonbox1), button1); + GTK_WIDGET_SET_FLAGS (button1, GTK_CAN_DEFAULT); + + button2 = gtk_button_new_with_mnemonic (_("Cancel")); + gtk_widget_set_name (button2, "button2"); + gtk_widget_show (button2); + gtk_container_add (GTK_CONTAINER (hbuttonbox1), button2); + GTK_WIDGET_SET_FLAGS (button2, GTK_CAN_DEFAULT); + + g_signal_connect ((gpointer) button1, "clicked", + G_CALLBACK (OnConf_Ok), + NULL); + g_signal_connect ((gpointer) button2, "clicked", + G_CALLBACK (OnConf_Cancel), + NULL); + + /* Store pointers to all widgets, for use by lookup_widget(). */ + GLADE_HOOKUP_OBJECT_NO_REF (Config, Config, "Config"); + GLADE_HOOKUP_OBJECT (Config, vbox1, "vbox1"); + GLADE_HOOKUP_OBJECT (Config, frame2, "frame2"); + GLADE_HOOKUP_OBJECT (Config, hbox1, "hbox1"); + GLADE_HOOKUP_OBJECT (Config, label4, "label4"); + GLADE_HOOKUP_OBJECT (Config, GtkCombo_Eth, "GtkCombo_Eth"); + GLADE_HOOKUP_OBJECT (Config, combo_entry1, "combo_entry1"); + GLADE_HOOKUP_OBJECT (Config, label1, "label1"); + GLADE_HOOKUP_OBJECT (Config, frame3, "frame3"); + GLADE_HOOKUP_OBJECT (Config, hbox2, "hbox2"); + GLADE_HOOKUP_OBJECT (Config, label5, "label5"); + GLADE_HOOKUP_OBJECT (Config, GtkCombo_Hdd, "GtkCombo_Hdd"); + GLADE_HOOKUP_OBJECT (Config, entry1, "entry1"); + GLADE_HOOKUP_OBJECT (Config, label15, "label15"); + GLADE_HOOKUP_OBJECT (Config, hbuttonbox1, "hbuttonbox1"); + GLADE_HOOKUP_OBJECT (Config, button1, "button1"); + GLADE_HOOKUP_OBJECT (Config, button2, "button2"); + + return Config; +} + +GtkWidget* +create_About (void) +{ + GtkWidget *About; + GtkWidget *vbox2; + GtkWidget *label2; + GtkWidget *label3; + GtkWidget *hbuttonbox2; + GtkWidget *button3; + + About = gtk_window_new (GTK_WINDOW_TOPLEVEL); + gtk_widget_set_name (About, "About"); + gtk_container_set_border_width (GTK_CONTAINER (About), 5); + gtk_window_set_title (GTK_WINDOW (About), _("DEV9about")); + + vbox2 = gtk_vbox_new (FALSE, 5); + gtk_widget_set_name (vbox2, "vbox2"); + gtk_widget_show (vbox2); + gtk_container_add (GTK_CONTAINER (About), vbox2); + gtk_container_set_border_width (GTK_CONTAINER (vbox2), 5); + + label2 = gtk_label_new (_("FireWire Driver")); + gtk_widget_set_name (label2, "label2"); + gtk_widget_show (label2); + gtk_box_pack_start (GTK_BOX (vbox2), label2, FALSE, FALSE, 0); + gtk_label_set_justify (GTK_LABEL (label2), GTK_JUSTIFY_CENTER); + + label3 = gtk_label_new (_("Author: linuzappz ")); + gtk_widget_set_name (label3, "label3"); + gtk_widget_show (label3); + gtk_box_pack_start (GTK_BOX (vbox2), label3, FALSE, FALSE, 0); + + hbuttonbox2 = gtk_hbutton_box_new (); + gtk_widget_set_name (hbuttonbox2, "hbuttonbox2"); + gtk_widget_show (hbuttonbox2); + gtk_box_pack_start (GTK_BOX (vbox2), hbuttonbox2, TRUE, TRUE, 0); + gtk_box_set_spacing (GTK_BOX (hbuttonbox2), 30); + + button3 = gtk_button_new_with_mnemonic (_("Ok")); + gtk_widget_set_name (button3, "button3"); + gtk_widget_show (button3); + gtk_container_add (GTK_CONTAINER (hbuttonbox2), button3); + GTK_WIDGET_SET_FLAGS (button3, GTK_CAN_DEFAULT); + + g_signal_connect ((gpointer) button3, "clicked", + G_CALLBACK (OnAbout_Ok), + NULL); + + /* Store pointers to all widgets, for use by lookup_widget(). */ + GLADE_HOOKUP_OBJECT_NO_REF (About, About, "About"); + GLADE_HOOKUP_OBJECT (About, vbox2, "vbox2"); + GLADE_HOOKUP_OBJECT (About, label2, "label2"); + GLADE_HOOKUP_OBJECT (About, label3, "label3"); + GLADE_HOOKUP_OBJECT (About, hbuttonbox2, "hbuttonbox2"); + GLADE_HOOKUP_OBJECT (About, button3, "button3"); + + return About; +} + diff --git a/plugins/FWnull/Linux/support.c b/plugins/FWnull/Linux/support.c new file mode 100644 index 0000000000..00aff29822 --- /dev/null +++ b/plugins/FWnull/Linux/support.c @@ -0,0 +1,144 @@ +/* + * DO NOT EDIT THIS FILE - it is generated by Glade. + */ + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include +#include +#include +#include +#include + +#include + +#include "support.h" + +GtkWidget* +lookup_widget (GtkWidget *widget, + const gchar *widget_name) +{ + GtkWidget *parent, *found_widget; + + for (;;) + { + if (GTK_IS_MENU (widget)) + parent = gtk_menu_get_attach_widget (GTK_MENU (widget)); + else + parent = widget->parent; + if (!parent) + parent = (GtkWidget*) g_object_get_data (G_OBJECT (widget), "GladeParentKey"); + if (parent == NULL) + break; + widget = parent; + } + + found_widget = (GtkWidget*) g_object_get_data (G_OBJECT (widget), + widget_name); + if (!found_widget) + g_warning ("Widget not found: %s", widget_name); + return found_widget; +} + +static GList *pixmaps_directories = NULL; + +/* Use this function to set the directory containing installed pixmaps. */ +void +add_pixmap_directory (const gchar *directory) +{ + pixmaps_directories = g_list_prepend (pixmaps_directories, + g_strdup (directory)); +} + +/* This is an internally used function to find pixmap files. */ +static gchar* +find_pixmap_file (const gchar *filename) +{ + GList *elem; + + /* We step through each of the pixmaps directory to find it. */ + elem = pixmaps_directories; + while (elem) + { + gchar *pathname = g_strdup_printf ("%s%s%s", (gchar*)elem->data, + G_DIR_SEPARATOR_S, filename); + if (g_file_test (pathname, G_FILE_TEST_EXISTS)) + return pathname; + g_free (pathname); + elem = elem->next; + } + return NULL; +} + +/* This is an internally used function to create pixmaps. */ +GtkWidget* +create_pixmap (GtkWidget *widget, + const gchar *filename) +{ + gchar *pathname = NULL; + GtkWidget *pixmap; + + if (!filename || !filename[0]) + return gtk_image_new (); + + pathname = find_pixmap_file (filename); + + if (!pathname) + { + g_warning (_("Couldn't find pixmap file: %s"), filename); + return gtk_image_new (); + } + + pixmap = gtk_image_new_from_file (pathname); + g_free (pathname); + return pixmap; +} + +/* This is an internally used function to create pixmaps. */ +GdkPixbuf* +create_pixbuf (const gchar *filename) +{ + gchar *pathname = NULL; + GdkPixbuf *pixbuf; + GError *error = NULL; + + if (!filename || !filename[0]) + return NULL; + + pathname = find_pixmap_file (filename); + + if (!pathname) + { + g_warning (_("Couldn't find pixmap file: %s"), filename); + return NULL; + } + + pixbuf = gdk_pixbuf_new_from_file (pathname, &error); + if (!pixbuf) + { + fprintf (stderr, "Failed to load pixbuf file: %s: %s\n", + pathname, error->message); + g_error_free (error); + } + g_free (pathname); + return pixbuf; +} + +/* This is used to set ATK action descriptions. */ +void +glade_set_atk_action_description (AtkAction *action, + const gchar *action_name, + const gchar *description) +{ + gint n_actions, i; + + n_actions = atk_action_get_n_actions (action); + for (i = 0; i < n_actions; i++) + { + if (!strcmp (atk_action_get_name (action, i), action_name)) + atk_action_set_description (action, i, description); + } +} + From 456672168ebb8d0d399af6889b5f1069d1e72ba0 Mon Sep 17 00:00:00 2001 From: arcum42 Date: Sat, 2 May 2009 03:41:03 +0000 Subject: [PATCH 33/41] And there goes SPU2null. This one deserves a lot more work, though. A real gui and backporting all the changes I made to ZeroSPU2, for starters. (And again, Windows may or may not compile for it. Looking at the Visual C++ file, I'm pretty sure it already wasn't compiling. git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1109 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/SPU2null/{Src => }/Changelog.txt | 0 plugins/SPU2null/Linux/Config.cpp | 86 ++ plugins/SPU2null/Makefile.am | 27 + plugins/SPU2null/SPU2.cpp | 1287 +++++++++++++++++ plugins/SPU2null/SPU2.h | 293 ++++ plugins/SPU2null/Src/Makefile | 25 - plugins/SPU2null/Src/SPU2.cpp | 1213 ---------------- plugins/SPU2null/Src/SPU2.h | 280 ---- plugins/SPU2null/{Src => Windows}/Config.cpp | 0 .../{Src => Windows}/ProjectRootDir.vsprops | 0 .../SPU2null/{Src => Windows}/SPU2null.def | 0 plugins/SPU2null/{Src => Windows}/SPU2null.rc | 0 .../{Src => Windows}/SPU2null_2008.vcproj | 12 +- plugins/SPU2null/{Src => Windows}/Win32.cpp | 0 plugins/SPU2null/{Src => Windows}/resource.h | 0 plugins/SPU2null/build.sh | 31 +- plugins/SPU2null/configure.ac | 80 + plugins/SPU2null/install-sh | 1 + plugins/SPU2null/missing | 1 + 19 files changed, 1806 insertions(+), 1530 deletions(-) rename plugins/SPU2null/{Src => }/Changelog.txt (100%) create mode 100644 plugins/SPU2null/Linux/Config.cpp create mode 100644 plugins/SPU2null/Makefile.am create mode 100644 plugins/SPU2null/SPU2.cpp create mode 100644 plugins/SPU2null/SPU2.h delete mode 100644 plugins/SPU2null/Src/Makefile delete mode 100644 plugins/SPU2null/Src/SPU2.cpp delete mode 100644 plugins/SPU2null/Src/SPU2.h rename plugins/SPU2null/{Src => Windows}/Config.cpp (100%) rename plugins/SPU2null/{Src => Windows}/ProjectRootDir.vsprops (100%) rename plugins/SPU2null/{Src => Windows}/SPU2null.def (100%) rename plugins/SPU2null/{Src => Windows}/SPU2null.rc (100%) rename plugins/SPU2null/{Src => Windows}/SPU2null_2008.vcproj (89%) rename plugins/SPU2null/{Src => Windows}/Win32.cpp (100%) rename plugins/SPU2null/{Src => Windows}/resource.h (100%) create mode 100644 plugins/SPU2null/configure.ac create mode 120000 plugins/SPU2null/install-sh create mode 120000 plugins/SPU2null/missing diff --git a/plugins/SPU2null/Src/Changelog.txt b/plugins/SPU2null/Changelog.txt similarity index 100% rename from plugins/SPU2null/Src/Changelog.txt rename to plugins/SPU2null/Changelog.txt diff --git a/plugins/SPU2null/Linux/Config.cpp b/plugins/SPU2null/Linux/Config.cpp new file mode 100644 index 0000000000..a42fc933a1 --- /dev/null +++ b/plugins/SPU2null/Linux/Config.cpp @@ -0,0 +1,86 @@ +/* SPU2null + * Copyright (C) 2002-2005 SPU2null 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "SPU2.h" + +#include +#include + +GtkWidget *MsgDlg; + +void OnMsg_Ok() +{ + gtk_widget_destroy(MsgDlg); + gtk_main_quit(); +} + +void SysMessage(char *fmt, ...) +{ + GtkWidget *Ok, *Txt; + GtkWidget *Box, *Box1; + va_list list; + char msg[512]; + + va_start(list, fmt); + vsprintf(msg, fmt, list); + va_end(list); + + if (msg[strlen(msg)-1] == '\n') msg[strlen(msg)-1] = 0; + + MsgDlg = gtk_window_new(GTK_WINDOW_POPUP); + gtk_window_set_position(GTK_WINDOW(MsgDlg), GTK_WIN_POS_CENTER); + gtk_window_set_title(GTK_WINDOW(MsgDlg), "SPU2null Msg"); + gtk_container_set_border_width(GTK_CONTAINER(MsgDlg), 5); + + Box = gtk_vbox_new(5, 0); + gtk_container_add(GTK_CONTAINER(MsgDlg), Box); + gtk_widget_show(Box); + + Txt = gtk_label_new(msg); + + gtk_box_pack_start(GTK_BOX(Box), Txt, FALSE, FALSE, 5); + gtk_widget_show(Txt); + + Box1 = gtk_hbutton_box_new(); + gtk_box_pack_start(GTK_BOX(Box), Box1, FALSE, FALSE, 0); + gtk_widget_show(Box1); + + Ok = gtk_button_new_with_label("Ok"); + gtk_signal_connect(GTK_OBJECT(Ok), "clicked", GTK_SIGNAL_FUNC(OnMsg_Ok), NULL); + gtk_container_add(GTK_CONTAINER(Box1), Ok); + GTK_WIDGET_SET_FLAGS(Ok, GTK_CAN_DEFAULT); + gtk_widget_show(Ok); + + gtk_widget_show(MsgDlg); + + gtk_main(); +} + +EXPORT_C_(void) SPU2configure() +{ + SysMessage("Nothing to Configure"); +} + +EXPORT_C_(void) SPU2about() +{ + SysMessage("%s %d.%d", libraryName, version, build); +} + +void LoadConfig() +{ +} diff --git a/plugins/SPU2null/Makefile.am b/plugins/SPU2null/Makefile.am new file mode 100644 index 0000000000..394dba22a3 --- /dev/null +++ b/plugins/SPU2null/Makefile.am @@ -0,0 +1,27 @@ +# Create a shared library libSPU2null +AUTOMAKE_OPTIONS = foreign +noinst_LIBRARIES = libSPU2null.a +INCLUDES = -I@srcdir@/../../common/include -I@srcdir@/../../3rdparty -I@srcdir@/Linux + +libSPU2null_a_CXXFLAGS = $(shell pkg-config --cflags gtk+-2.0) +libSPU2null_a_CFLAGS = $(shell pkg-config --cflags gtk+-2.0) + +# Create a shared object by faking an exe (thanks to ODE makefiles) +traplibdir=$(prefix) + +if DEBUGBUILD +preext=d +endif + +EXEEXT=$(preext)@so_ext@ + +traplib_PROGRAMS=libSPU2null +libSPU2null_SOURCES= +libSPU2null_DEPENDENCIES = libSPU2null.a +libSPU2null_LDFLAGS= @SHARED_LDFLAGS@ +libSPU2null_LDFLAGS+=-Wl,-soname,@libSPU2null_SONAME@ +libSPU2null_LDADD=$(libSPU2null_a_OBJECTS) + +libSPU2null_a_SOURCES = SPU2.cpp SPU2.h Linux/Config.cpp + +#SUBDIRS = Linux \ No newline at end of file diff --git a/plugins/SPU2null/SPU2.cpp b/plugins/SPU2null/SPU2.cpp new file mode 100644 index 0000000000..e8a8e23697 --- /dev/null +++ b/plugins/SPU2null/SPU2.cpp @@ -0,0 +1,1287 @@ +/* SPU2null + * Copyright (C) 2002-2005 SPU2null 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "SPU2.h" + +#include +#include + +const unsigned char version = PS2E_SPU2_VERSION; +const unsigned char revision = 0; +const unsigned char build = 7; // increase that with each version +const unsigned int minor = 1; // increase that with each version + +// ADSR constants +#define ATTACK_MS 494L +#define DECAYHALF_MS 286L +#define DECAY_MS 572L +#define SUSTAIN_MS 441L +#define RELEASE_MS 437L + +#ifdef _DEBUG +char *libraryName = "SPU2null (Debug)"; +#else +char *libraryName = "SPU2null "; +#endif + +FILE *spu2Log; +Config conf; + +ADMA Adma4; +ADMA Adma7; + +u32 MemAddr[2]; +u32 g_nSpuInit = 0; +unsigned short interrupt = 0; +s8 *spu2regs = NULL; +u16* spu2mem = NULL; +u16* pSpuIrq[2] = {NULL}; +u32 dwEndChannel2[2] = {0}; // keeps track of what channels have ended +unsigned long dwNoiseVal = 1; // global noise generator + +int SPUCycles = 0, SPUWorkerCycles = 0; +int SPUStartCycle[2]; +int SPUTargetCycle[2]; + +int ADMAS4Write(); +int ADMAS7Write(); + +void InitADSR(); + +void (*irqCallbackSPU2)(); // func of main emu, called on spu irq +void (*irqCallbackDMA4)() = 0; // func of main emu, called on spu irq +void (*irqCallbackDMA7)() = 0; // func of main emu, called on spu irq + +const int f[5][2] = { + { 0, 0 }, + { 60, 0 }, + { 115, -52 }, + { 98, -55 }, + { 122, -60 } +}; + +u32 RateTable[160]; + +// channels and voices +VOICE_PROCESSED voices[SPU_NUMBER_VOICES+1]; // +1 for modulation + +EXPORT_C_(u32) PS2EgetLibType() +{ + return PS2E_LT_SPU2; +} + +EXPORT_C_(char*) PS2EgetLibName() +{ + return libraryName; +} + +EXPORT_C_(u32) PS2EgetLibVersion2(u32 type) +{ + return (version << 16) | (revision << 8) | build | (minor << 24); +} + +void __Log(char *fmt, ...) +{ + va_list list; + + if (!conf.Log || spu2Log == NULL) return; + + va_start(list, fmt); + vfprintf(spu2Log, fmt, list); + va_end(list); +} + +EXPORT_C_(s32) SPU2init() +{ +#ifdef SPU2_LOG + spu2Log = fopen("logs/spu2.txt", "w"); + if (spu2Log) setvbuf(spu2Log, NULL, _IONBF, 0); + SPU2_LOG("Spu2 null version %d,%d\n", revision, build); + SPU2_LOG("SPU2init\n"); +#endif + spu2regs = (s8*)malloc(0x10000); + if (spu2regs == NULL) + { + SysMessage("Error allocating Memory\n"); + return -1; + } + memset(spu2regs, 0, 0x10000); + + spu2mem = (u16*)malloc(0x200000); // 2Mb + if (spu2mem == NULL) + { + SysMessage("Error allocating Memory\n"); + return -1; + } + memset(spu2mem, 0, 0x200000); + memset(dwEndChannel2, 0, sizeof(dwEndChannel2)); + + InitADSR(); + + memset(voices, 0, sizeof(voices)); + // last 24 channels have higher mem offset + for (int i = 0; i < 24; ++i) + voices[i+24].memoffset = 0x400; + + // init each channel + for (u32 i = 0; i < ArraySize(voices); ++i) + { + + voices[i].pLoop = voices[i].pStart = voices[i].pCurr = (u8*)spu2mem; + + voices[i].pvoice = (_SPU_VOICE*)((u8*)spu2regs + voices[i].memoffset) + (i % 24); + voices[i].ADSRX.SustainLevel = 1024; // -> init sustain + } + + return 0; +} + +EXPORT_C_(s32) SPU2open(void *pDsp) +{ + LoadConfig(); + SPUCycles = SPUWorkerCycles = 0; + interrupt = 0; + SPUStartCycle[0] = SPUStartCycle[1] = 0; + SPUTargetCycle[0] = SPUTargetCycle[1] = 0; + g_nSpuInit = 1; + return 0; +} + +EXPORT_C_(void) SPU2close() +{ + g_nSpuInit = 0; +} + +EXPORT_C_(void) SPU2shutdown() +{ + free(spu2regs); + spu2regs = NULL; + free(spu2mem); + spu2mem = NULL; +#ifdef SPU2_LOG + if (spu2Log) fclose(spu2Log); +#endif +} + +// simulate SPU2 for 1ms +void SPU2Worker(); + +#define CYCLES_PER_MS (36864000/1000) + +EXPORT_C_(void) SPU2async(u32 cycle) +{ + SPUCycles += cycle; + if (interrupt & (1 << 2)) + { + if (SPUCycles - SPUStartCycle[1] >= SPUTargetCycle[1]) + { + interrupt &= ~(1 << 2); + irqCallbackDMA7(); + } + + } + + if (interrupt & (1 << 1)) + { + if (SPUCycles - SPUStartCycle[0] >= SPUTargetCycle[0]) + { + interrupt &= ~(1 << 1); + irqCallbackDMA4(); + } + } + + if (g_nSpuInit) + { + + while (SPUCycles - SPUWorkerCycles > 0 && CYCLES_PER_MS < SPUCycles - SPUWorkerCycles) + { + SPU2Worker(); + SPUWorkerCycles += CYCLES_PER_MS; + } + } +} + +void InitADSR() // INIT ADSR +{ + unsigned long r, rs, rd; + int i; + memset(RateTable, 0, sizeof(unsigned long)*160); // build the rate table according to Neill's rules (see at bottom of file) + + r = 3; + rs = 1; + rd = 0; + + for (i = 32;i < 160;i++) // we start at pos 32 with the real values... everything before is 0 + { + if (r < 0x3FFFFFFF) + { + r += rs; + rd++; + if (rd == 5) + { + rd = 1; + rs *= 2; + } + } + if (r > 0x3FFFFFFF) r = 0x3FFFFFFF; + + RateTable[i] = r; + } +} + +int MixADSR(VOICE_PROCESSED* pvoice) // MIX ADSR +{ + if (pvoice->bStop) // should be stopped: + { + if (pvoice->bIgnoreLoop == 0) + { + pvoice->ADSRX.EnvelopeVol = 0; + pvoice->bOn = false; + pvoice->pStart = (u8*)(spu2mem + pvoice->iStartAddr); + pvoice->pLoop = (u8*)(spu2mem + pvoice->iStartAddr); + pvoice->pCurr = (u8*)(spu2mem + pvoice->iStartAddr); + pvoice->bStop = true; + pvoice->bIgnoreLoop = false; + return 0; + } + if (pvoice->ADSRX.ReleaseModeExp)// do release + { + switch ((pvoice->ADSRX.EnvelopeVol >> 28)&0x7) + { + case 0: + pvoice->ADSRX.EnvelopeVol -= RateTable[(4*(pvoice->ADSRX.ReleaseRate^0x1F))-0x18 +0 + 32]; + break; + case 1: + pvoice->ADSRX.EnvelopeVol -= RateTable[(4*(pvoice->ADSRX.ReleaseRate^0x1F))-0x18 +4 + 32]; + break; + case 2: + pvoice->ADSRX.EnvelopeVol -= RateTable[(4*(pvoice->ADSRX.ReleaseRate^0x1F))-0x18 +6 + 32]; + break; + case 3: + pvoice->ADSRX.EnvelopeVol -= RateTable[(4*(pvoice->ADSRX.ReleaseRate^0x1F))-0x18 +8 + 32]; + break; + case 4: + pvoice->ADSRX.EnvelopeVol -= RateTable[(4*(pvoice->ADSRX.ReleaseRate^0x1F))-0x18 +9 + 32]; + break; + case 5: + pvoice->ADSRX.EnvelopeVol -= RateTable[(4*(pvoice->ADSRX.ReleaseRate^0x1F))-0x18 +10+ 32]; + break; + case 6: + pvoice->ADSRX.EnvelopeVol -= RateTable[(4*(pvoice->ADSRX.ReleaseRate^0x1F))-0x18 +11+ 32]; + break; + case 7: + pvoice->ADSRX.EnvelopeVol -= RateTable[(4*(pvoice->ADSRX.ReleaseRate^0x1F))-0x18 +12+ 32]; + break; + } + } + else + { + pvoice->ADSRX.EnvelopeVol -= RateTable[(4*(pvoice->ADSRX.ReleaseRate^0x1F))-0x0C + 32]; + } + + if (pvoice->ADSRX.EnvelopeVol < 0) + { + pvoice->ADSRX.EnvelopeVol = 0; + pvoice->bOn = false; + pvoice->pStart = (u8*)(spu2mem + pvoice->iStartAddr); + pvoice->pLoop = (u8*)(spu2mem + pvoice->iStartAddr); + pvoice->pCurr = (u8*)(spu2mem + pvoice->iStartAddr); + pvoice->bStop = true; + pvoice->bIgnoreLoop = false; + //pvoice->bReverb=0; + //pvoice->bNoise=0; + } + + pvoice->ADSRX.lVolume = pvoice->ADSRX.EnvelopeVol >> 21; + pvoice->ADSRX.lVolume = pvoice->ADSRX.EnvelopeVol >> 21; + return pvoice->ADSRX.lVolume; + } + else // not stopped yet? + { + if (pvoice->ADSRX.State == 0) // -> attack + { + if (pvoice->ADSRX.AttackModeExp) + { + if (pvoice->ADSRX.EnvelopeVol < 0x60000000) + pvoice->ADSRX.EnvelopeVol += RateTable[(pvoice->ADSRX.AttackRate^0x7F)-0x10 + 32]; + else + pvoice->ADSRX.EnvelopeVol += RateTable[(pvoice->ADSRX.AttackRate^0x7F)-0x18 + 32]; + } + else + { + pvoice->ADSRX.EnvelopeVol += RateTable[(pvoice->ADSRX.AttackRate^0x7F)-0x10 + 32]; + } + + if (pvoice->ADSRX.EnvelopeVol < 0) + { + pvoice->ADSRX.EnvelopeVol = 0x7FFFFFFF; + pvoice->ADSRX.State = 1; + } + + pvoice->ADSRX.lVolume = pvoice->ADSRX.EnvelopeVol >> 21; + return pvoice->ADSRX.lVolume; + } + //--------------------------------------------------// + if (pvoice->ADSRX.State == 1) // -> decay + { + switch ((pvoice->ADSRX.EnvelopeVol >> 28)&0x7) + { + case 0: + pvoice->ADSRX.EnvelopeVol -= RateTable[(4*(pvoice->ADSRX.DecayRate^0x1F))-0x18+0 + 32]; + break; + case 1: + pvoice->ADSRX.EnvelopeVol -= RateTable[(4*(pvoice->ADSRX.DecayRate^0x1F))-0x18+4 + 32]; + break; + case 2: + pvoice->ADSRX.EnvelopeVol -= RateTable[(4*(pvoice->ADSRX.DecayRate^0x1F))-0x18+6 + 32]; + break; + case 3: + pvoice->ADSRX.EnvelopeVol -= RateTable[(4*(pvoice->ADSRX.DecayRate^0x1F))-0x18+8 + 32]; + break; + case 4: + pvoice->ADSRX.EnvelopeVol -= RateTable[(4*(pvoice->ADSRX.DecayRate^0x1F))-0x18+9 + 32]; + break; + case 5: + pvoice->ADSRX.EnvelopeVol -= RateTable[(4*(pvoice->ADSRX.DecayRate^0x1F))-0x18+10+ 32]; + break; + case 6: + pvoice->ADSRX.EnvelopeVol -= RateTable[(4*(pvoice->ADSRX.DecayRate^0x1F))-0x18+11+ 32]; + break; + case 7: + pvoice->ADSRX.EnvelopeVol -= RateTable[(4*(pvoice->ADSRX.DecayRate^0x1F))-0x18+12+ 32]; + break; + } + + if (pvoice->ADSRX.EnvelopeVol < 0) pvoice->ADSRX.EnvelopeVol = 0; + if (((pvoice->ADSRX.EnvelopeVol >> 27)&0xF) <= pvoice->ADSRX.SustainLevel) + { + pvoice->ADSRX.State = 2; + } + + pvoice->ADSRX.lVolume = pvoice->ADSRX.EnvelopeVol >> 21; + return pvoice->ADSRX.lVolume; + } + //--------------------------------------------------// + if (pvoice->ADSRX.State == 2) // -> sustain + { + if (pvoice->ADSRX.SustainIncrease) + { + if (pvoice->ADSRX.SustainModeExp) + { + if (pvoice->ADSRX.EnvelopeVol < 0x60000000) + pvoice->ADSRX.EnvelopeVol += RateTable[(pvoice->ADSRX.SustainRate^0x7F)-0x10 + 32]; + else + pvoice->ADSRX.EnvelopeVol += RateTable[(pvoice->ADSRX.SustainRate^0x7F)-0x18 + 32]; + } + else + { + pvoice->ADSRX.EnvelopeVol += RateTable[(pvoice->ADSRX.SustainRate^0x7F)-0x10 + 32]; + } + + if (pvoice->ADSRX.EnvelopeVol < 0) + { + pvoice->ADSRX.EnvelopeVol = 0x7FFFFFFF; + } + } + else + { + if (pvoice->ADSRX.SustainModeExp) + { + switch ((pvoice->ADSRX.EnvelopeVol >> 28)&0x7) + { + case 0: + pvoice->ADSRX.EnvelopeVol -= RateTable[((pvoice->ADSRX.SustainRate^0x7F))-0x1B +0 + 32]; + break; + case 1: + pvoice->ADSRX.EnvelopeVol -= RateTable[((pvoice->ADSRX.SustainRate^0x7F))-0x1B +4 + 32]; + break; + case 2: + pvoice->ADSRX.EnvelopeVol -= RateTable[((pvoice->ADSRX.SustainRate^0x7F))-0x1B +6 + 32]; + break; + case 3: + pvoice->ADSRX.EnvelopeVol -= RateTable[((pvoice->ADSRX.SustainRate^0x7F))-0x1B +8 + 32]; + break; + case 4: + pvoice->ADSRX.EnvelopeVol -= RateTable[((pvoice->ADSRX.SustainRate^0x7F))-0x1B +9 + 32]; + break; + case 5: + pvoice->ADSRX.EnvelopeVol -= RateTable[((pvoice->ADSRX.SustainRate^0x7F))-0x1B +10+ 32]; + break; + case 6: + pvoice->ADSRX.EnvelopeVol -= RateTable[((pvoice->ADSRX.SustainRate^0x7F))-0x1B +11+ 32]; + break; + case 7: + pvoice->ADSRX.EnvelopeVol -= RateTable[((pvoice->ADSRX.SustainRate^0x7F))-0x1B +12+ 32]; + break; + } + } + else + { + pvoice->ADSRX.EnvelopeVol -= RateTable[((pvoice->ADSRX.SustainRate^0x7F))-0x0F + 32]; + } + + if (pvoice->ADSRX.EnvelopeVol < 0) + { + pvoice->ADSRX.EnvelopeVol = 0; + } + } + pvoice->ADSRX.lVolume = pvoice->ADSRX.EnvelopeVol >> 21; + return pvoice->ADSRX.lVolume; + } + } + return 0; +} + +// simulate SPU2 for 1ms +void SPU2Worker() +{ + u8* start; + int ch, flags; + + VOICE_PROCESSED* pChannel = voices; + for (ch = 0;ch < SPU_NUMBER_VOICES;ch++, pChannel++) // loop em all... we will collect 1 ms of sound of each playing channel + { + if (pChannel->bNew) + { + pChannel->StartSound(); // start new sound + dwEndChannel2[ch/24] &= ~(1 << (ch % 24)); // clear end channel bit + } + + if (!pChannel->bOn) + { + // fill buffer with empty data + continue; + } + + if (pChannel->iActFreq != pChannel->iUsedFreq) // new psx frequency? + pChannel->VoiceChangeFrequency(); + + // loop until 1 ms of data is reached + int ns = 0; + while (ns < NSSIZE) + { + while (pChannel->spos >= 0x10000) + { + if (pChannel->iSBPos == 28) // 28 reached? + { + start = pChannel->pCurr; // set up the current pos + + // special "stop" sign + if (start == (u8*) - 1) //!pChannel->bOn + { + pChannel->bOn = false; // -> turn everything off + pChannel->ADSRX.lVolume = 0; + pChannel->ADSRX.EnvelopeVol = 0; + goto ENDX; // -> and done for this channel + } + + pChannel->iSBPos = 0; + + // decode the 16 byte packet + + flags = (int)start[1]; + start += 16; + + // some callback and irq active? + if (pChannel->GetCtrl()->irq) + { + // if irq address reached or irq on looping addr, when stop/loop flag is set + u8* pirq = (u8*)pSpuIrq[ch>=24]; + if ((pirq > start - 16 && pirq <= start) + || ((flags&1) && (pirq > pChannel->pLoop - 16 && pirq <= pChannel->pLoop))) + { + IRQINFO |= 4 << (int)(ch >= 24); + irqCallbackSPU2(); + } + } + + // flag handler + if ((flags&4) && (!pChannel->bIgnoreLoop)) + pChannel->pLoop = start - 16; // loop adress + + if (flags&1) // 1: stop/loop + { + // We play this block out first... + dwEndChannel2[ch/24] |= (1 << (ch % 24)); + //if(!(flags&2)) // 1+2: do loop... otherwise: stop + if (flags != 3 || pChannel->pLoop == NULL) // PETE: if we don't check exactly for 3, loop hang ups will happen (DQ4, for example) + { // and checking if pLoop is set avoids crashes, yeah + start = (u8*) - 1; + pChannel->bStop = true; + pChannel->bIgnoreLoop = false; + } + else + { + start = pChannel->pLoop; + } + } + + pChannel->pCurr = start; // store values for next cycle + } + + pChannel->iSBPos++; // get sample data + pChannel->spos -= 0x10000; + } + + MixADSR(pChannel); + + // go to the next packet + ns++; + pChannel->spos += pChannel->sinc; + } +ENDX: + ; + } + + // mix all channels + if ((spu2Ru16(REG_C0_MMIX) & 0xC0) && (spu2Ru16(REG_C0_ADMAS) & 0x1) && !(spu2Ru16(REG_C0_CTRL) & 0x30)) + { + for (int ns = 0;ns < NSSIZE;ns++) + { + Adma4.Index += 1; + + if (Adma4.Index == 128 || Adma4.Index == 384) + { + if (ADMAS4Write()) + { + spu2Ru16(REG_C0_SPUSTAT) &= ~0x80; + irqCallbackDMA4(); + } + else MemAddr[0] += 1024; + } + + if (Adma4.Index == 512) + { + Adma4.Index = 0; + } + } + } + + + if ((spu2Ru16(REG_C1_MMIX) & 0xC0) && (spu2Ru16(REG_C1_ADMAS) & 0x2) && !(spu2Ru16(REG_C1_CTRL) & 0x30)) + { + for (int ns = 0;ns < NSSIZE;ns++) + { + Adma7.Index += 1; + + if (Adma7.Index == 128 || Adma7.Index == 384) + { + if (ADMAS7Write()) + { + spu2Ru16(REG_C1_SPUSTAT) &= ~0x80; + irqCallbackDMA7(); + } + else MemAddr[1] += 1024; + } + + if (Adma7.Index == 512) Adma7.Index = 0; + } + } +} + +EXPORT_C_(void) SPU2readDMA4Mem(u16 *pMem, int size) +{ + u32 spuaddr = C0_SPUADDR; + int i; + + SPU2_LOG("SPU2 readDMA4Mem size %x, addr: %x\n", size, pMem); + + for (i = 0;i < size;i++) + { + *pMem++ = *(u16*)(spu2mem + spuaddr); + if ((spu2Rs16(REG_C0_CTRL)&0x40) && C0_IRQA == spuaddr) + { + spu2Ru16(SPDIF_OUT) |= 0x4; + C0_SPUADDR_SET(spuaddr); + IRQINFO |= 4; + irqCallbackSPU2(); + } + + spuaddr++; // inc spu addr + if (spuaddr > 0x0fffff) // wrap at 2Mb + spuaddr = 0; // wrap + } + + spuaddr += 19; //Transfer Local To Host TSAH/L + Data Size + 20 (already +1'd) + C0_SPUADDR_SET(spuaddr); + + // got from J.F. and Kanodin... is it needed? + spu2Ru16(REG_C0_SPUSTAT) &= ~0x80; // DMA complete + SPUStartCycle[0] = SPUCycles; + SPUTargetCycle[0] = size; + interrupt |= (1 << 1); +} + +EXPORT_C_(void) SPU2readDMA7Mem(u16* pMem, int size) +{ + u32 spuaddr = C1_SPUADDR; + int i; + + SPU2_LOG("SPU2 readDMA7Mem size %x, addr: %x\n", size, pMem); + + for (i = 0;i < size;i++) + { + *pMem++ = *(u16*)(spu2mem + spuaddr); + if ((spu2Rs16(REG_C1_CTRL)&0x40) && C1_IRQA == spuaddr) + { + spu2Ru16(SPDIF_OUT) |= 0x8; + C1_SPUADDR_SET(spuaddr); + IRQINFO |= 8; + irqCallbackSPU2(); + } + spuaddr++; // inc spu addr + if (spuaddr > 0x0fffff) // wrap at 2Mb + spuaddr = 0; // wrap + } + + spuaddr += 19; //Transfer Local To Host TSAH/L + Data Size + 20 (already +1'd) + C1_SPUADDR_SET(spuaddr); + + // got from J.F. and Kanodin... is it needed? + spu2Ru16(REG_C1_SPUSTAT) &= ~0x80; // DMA complete + SPUStartCycle[1] = SPUCycles; + SPUTargetCycle[1] = size; + interrupt |= (1 << 2); +} + +// WRITE + +// AutoDMA's are used to transfer to the DIRECT INPUT area of the spu2 memory +// Left and Right channels are always interleaved together in the transfer so +// the AutoDMA's deinterleaves them and transfers them. An interrupt is +// generated when half of the buffer (256 short-words for left and 256 +// short-words for right ) has been transferred. Another interrupt occurs at +// the end of the transfer. +int ADMAS4Write() +{ + u32 spuaddr; + if (interrupt & 0x2) return 0; + if (Adma4.AmountLeft <= 0) return 1; + + spuaddr = C0_SPUADDR; + // SPU2 Deinterleaves the Left and Right Channels + memcpy((short*)(spu2mem + spuaddr + 0x2000), (short*)Adma4.MemAddr, 512); + Adma4.MemAddr += 256; + memcpy((short*)(spu2mem + spuaddr + 0x2200), (short*)Adma4.MemAddr, 512); + Adma4.MemAddr += 256; + spuaddr = (spuaddr + 256) & 511; + C0_SPUADDR_SET(spuaddr); + + Adma4.AmountLeft -= 512; + if (Adma4.AmountLeft == 0) + { + SPUStartCycle[0] = SPUCycles; + SPUTargetCycle[0] = 1;//512*48000; + spu2Ru16(REG_C0_SPUSTAT) &= ~0x80; + interrupt |= (1 << 1); + } + return 0; +} + +int ADMAS7Write() +{ + u32 spuaddr; + if (interrupt & 0x4) return 0; + if (Adma7.AmountLeft <= 0) return 1; + + spuaddr = C1_SPUADDR; + // SPU2 Deinterleaves the Left and Right Channels + memcpy((short*)(spu2mem + spuaddr + 0x2400), (short*)Adma7.MemAddr, 512); + Adma7.MemAddr += 256; + memcpy((short*)(spu2mem + spuaddr + 0x2600), (short*)Adma7.MemAddr, 512); + Adma7.MemAddr += 256; + spuaddr = (spuaddr + 256) & 511; + C1_SPUADDR_SET(spuaddr); + + Adma7.AmountLeft -= 512; + if (Adma7.AmountLeft == 0) + { + SPUStartCycle[1] = SPUCycles; + SPUTargetCycle[1] = 1;//512*48000; + spu2Ru16(REG_C1_SPUSTAT) &= ~0x80; + interrupt |= (1 << 2); + } + return 0; +} + +EXPORT_C_(void) SPU2writeDMA4Mem(u16* pMem, int size) +{ + u32 spuaddr; + + SPU2_LOG("SPU2 writeDMA4Mem size %x, addr: %x\n", size, pMem); + + if ((spu2Ru16(REG_C0_ADMAS) & 0x1) && (spu2Ru16(REG_C0_CTRL) & 0x30) == 0 && size) + { + //fwrite(pMem,iSize<<1,1,LogFile); + memset(&Adma4, 0, sizeof(ADMA)); + C0_SPUADDR_SET(0); + Adma4.MemAddr = pMem; + Adma4.AmountLeft = size; + ADMAS4Write(); + return; + } + + spuaddr = C0_SPUADDR; + memcpy((unsigned char*)(spu2mem + spuaddr), (unsigned char*)pMem, size << 1); + spuaddr += size; + C0_SPUADDR_SET(spuaddr); + + if ((spu2Ru16(REG_C0_CTRL)&0x40) && C0_IRQA == spuaddr) + { + spu2Ru16(SPDIF_OUT) |= 0x4; + IRQINFO |= 4; + irqCallbackSPU2(); + } + if (spuaddr > 0xFFFFE) + spuaddr = 0x2800; + C0_SPUADDR_SET(spuaddr); + + MemAddr[0] += size << 1; + spu2Ru16(REG_C0_SPUSTAT) &= ~0x80; + SPUStartCycle[0] = SPUCycles; + SPUTargetCycle[0] = 1;//iSize; + interrupt |= (1 << 1); +} + +EXPORT_C_(void) SPU2writeDMA7Mem(u16* pMem, int size) +{ + u32 spuaddr; + + SPU2_LOG("SPU2 writeDMA7Mem size %x, addr: %x\n", size, pMem); + + if ((spu2Ru16(REG_C1_ADMAS) & 0x2) && (spu2Ru16(REG_C1_CTRL) & 0x30) == 0 && size) + { + //fwrite(pMem,iSize<<1,1,LogFile); + memset(&Adma7, 0, sizeof(ADMA)); + C1_SPUADDR_SET(0); + Adma7.MemAddr = pMem; + Adma7.AmountLeft = size; + ADMAS7Write(); + return; + } + + spuaddr = C1_SPUADDR; + memcpy((unsigned char*)(spu2mem + spuaddr), (unsigned char*)pMem, size << 1); + spuaddr += size; + C1_SPUADDR_SET(spuaddr); + + if ((spu2Ru16(REG_C1_CTRL)&0x40) && C1_IRQA == spuaddr) + { + spu2Ru16(SPDIF_OUT) |= 0x8; + IRQINFO |= 8; + irqCallbackSPU2(); + } + if (spuaddr > 0xFFFFE) + spuaddr = 0x2800; + C1_SPUADDR_SET(spuaddr); + + MemAddr[1] += size << 1; + spu2Ru16(REG_C1_SPUSTAT) &= ~0x80; + SPUStartCycle[1] = SPUCycles; + SPUTargetCycle[1] = 1;//iSize; + interrupt |= (1 << 2); +} + +EXPORT_C_(void) SPU2interruptDMA4() +{ + SPU2_LOG("SPU2 interruptDMA4\n"); + + spu2Rs16(REG_C0_CTRL) &= ~0x30; + spu2Ru16(REG_C0_SPUSTAT) |= 0x80; +} + +EXPORT_C_(void) SPU2interruptDMA7() +{ + SPU2_LOG("SPU2 interruptDMA7\n"); + +// spu2Rs16(REG_C1_CTRL)&= ~0x30; +// //spu2Rs16(REG__5B0) = 0; +// spu2Rs16(SPU2_STATX_DREQ)|= 0x80; + spu2Rs16(REG_C1_CTRL) &= ~0x30; + spu2Ru16(REG_C1_SPUSTAT) |= 0x80; +} + +// turn channels on +void SoundOn(int start, int end, unsigned short val) // SOUND ON PSX COMAND +{ + for (int ch = start;ch < end;ch++, val >>= 1) // loop channels + { + if ((val&1) && voices[ch].pStart) // mmm... start has to be set before key on !?! + { + voices[ch].bNew = true; + voices[ch].bIgnoreLoop = false; + } + } +} + +// turn channels off +void SoundOff(int start, int end, unsigned short val) // SOUND OFF PSX COMMAND +{ + for (int ch = start;ch < end;ch++, val >>= 1) // loop channels + { + if (val&1) // && s_chan[i].bOn) mmm... + voices[ch].bStop = true; + } +} + +void FModOn(int start, int end, unsigned short val) // FMOD ON PSX COMMAND +{ + int ch; + + for (ch = start;ch < end;ch++, val >>= 1) // loop channels + { + if (val&1) // -> fmod on/off + { + if (ch > 0) + { + } + } + else + { + // turn fmod off + } + } +} + +EXPORT_C_(void) SPU2write(u32 mem, u16 value) +{ + u32 spuaddr; + + SPU2_LOG("SPU2 write mem %x value %x\n", mem, value); + + assert(C0_SPUADDR < 0x100000); + assert(C1_SPUADDR < 0x100000); + + spu2Ru16(mem) = value; + u32 r = mem & 0xffff; + + // channel info + if ((r >= 0x0000 && r < 0x0180) || (r >= 0x0400 && r < 0x0580)) // some channel info? + { + int ch = 0; + if (r >= 0x400) ch = ((r - 0x400) >> 4) + 24; + else ch = (r >> 4); + + VOICE_PROCESSED* pvoice = &voices[ch]; + + switch (r&0x0f) + { + case 0: + case 2: + pvoice->SetVolume(mem&0x2); + break; + case 4: + { + int NP; + if (value > 0x3fff) NP = 0x3fff; // get pitch val + else NP = value; + + pvoice->pvoice->pitch = NP; + + NP = (44100L * NP) / 4096L; // calc frequency + if (NP < 1) NP = 1; // some security + pvoice->iActFreq = NP; // store frequency + break; + } + case 6: + { + pvoice->ADSRX.AttackModeExp = (value & 0x8000) ? 1 : 0; + pvoice->ADSRX.AttackRate = ((value >> 8) & 0x007f); + pvoice->ADSRX.DecayRate = (((value >> 4) & 0x000f)); + pvoice->ADSRX.SustainLevel = (value & 0x000f); + break; + } + case 8: + pvoice->ADSRX.SustainModeExp = (value & 0x8000) ? 1 : 0; + pvoice->ADSRX.SustainIncrease = (value & 0x4000) ? 0 : 1; + pvoice->ADSRX.SustainRate = ((value >> 6) & 0x007f); + pvoice->ADSRX.ReleaseModeExp = (value & 0x0020) ? 1 : 0; + pvoice->ADSRX.ReleaseRate = ((value & 0x001f)); + break; + } + + return; + } + + // more channel info + if ((r >= 0x01c0 && r <= 0x02E0) || (r >= 0x05c0 && r <= 0x06E0)) + { + int ch = 0; + unsigned long rx = r; + if (rx >= 0x400) + { + ch = 24; + rx -= 0x400; + } + + ch += ((rx - 0x1c0) / 12); + rx -= (ch % 24) * 12; + VOICE_PROCESSED* pvoice = &voices[ch]; + + switch (rx) + { + case 0x1C0: + pvoice->iStartAddr = (((unsigned long)value & 0x3f) << 16) | (pvoice->iStartAddr & 0xFFFF); + pvoice->pStart = (u8*)(spu2mem + pvoice->iStartAddr); + break; + case 0x1C2: + pvoice->iStartAddr = (pvoice->iStartAddr & 0x3f0000) | (value & 0xFFFF); + pvoice->pStart = (u8*)(spu2mem + pvoice->iStartAddr); + break; + case 0x1C4: + pvoice->iLoopAddr = (((unsigned long)value & 0x3f) << 16) | (pvoice->iLoopAddr & 0xFFFF); + pvoice->pLoop = (u8*)(spu2mem + pvoice->iLoopAddr); + pvoice->bIgnoreLoop = pvoice->iLoopAddr > 0; + break; + case 0x1C6: + pvoice->iLoopAddr = (pvoice->iLoopAddr & 0x3f0000) | (value & 0xFFFF); + pvoice->pLoop = (u8*)(spu2mem + pvoice->iLoopAddr); + pvoice->bIgnoreLoop = pvoice->iLoopAddr > 0; + break; + case 0x1C8: + // unused... check if it gets written as well + pvoice->iNextAddr = (((unsigned long)value & 0x3f) << 16) | (pvoice->iNextAddr & 0xFFFF); + break; + case 0x1CA: + // unused... check if it gets written as well + pvoice->iNextAddr = (pvoice->iNextAddr & 0x3f0000) | (value & 0xFFFF); + break; + } + + return; + } + + // process non-channel data + switch (mem&0xffff) + { + case REG_C0_SPUDATA: + spuaddr = C0_SPUADDR; + spu2mem[spuaddr] = value; + spuaddr++; + if ((spu2Ru16(REG_C0_CTRL)&0x40) && C0_IRQA == spuaddr) + { + spu2Ru16(SPDIF_OUT) |= 0x4; + IRQINFO |= 4; + irqCallbackSPU2(); + } + if (spuaddr > 0xFFFFE) + spuaddr = 0x2800; + C0_SPUADDR_SET(spuaddr); + spu2Ru16(REG_C0_SPUSTAT) &= ~0x80; + spu2Ru16(REG_C0_CTRL) &= ~0x30; + break; + case REG_C1_SPUDATA: + spuaddr = C1_SPUADDR; + spu2mem[spuaddr] = value; + spuaddr++; + if ((spu2Ru16(REG_C1_CTRL)&0x40) && C1_IRQA == spuaddr) + { + spu2Ru16(SPDIF_OUT) |= 0x8; + IRQINFO |= 8; + irqCallbackSPU2(); + } + if (spuaddr > 0xFFFFE) + spuaddr = 0x2800; + C1_SPUADDR_SET(spuaddr); + spu2Ru16(REG_C1_SPUSTAT) &= ~0x80; + spu2Ru16(REG_C1_CTRL) &= ~0x30; + break; + case REG_C0_IRQA_HI: + case REG_C0_IRQA_LO: + pSpuIrq[0] = spu2mem + (C0_IRQA << 1); + break; + case REG_C1_IRQA_HI: + case REG_C1_IRQA_LO: + pSpuIrq[1] = spu2mem + (C1_IRQA << 1); + break; + + case REG_C0_SPUADDR_HI: + case REG_C1_SPUADDR_HI: + spu2Ru16(mem) = value & 0xf; + break; + + case REG_C0_SPUON1: + SoundOn(0, 16, value); + break; + case REG_C0_SPUON2: + SoundOn(16, 24, value); + break; + case REG_C1_SPUON1: + SoundOn(24, 40, value); + break; + case REG_C1_SPUON2: + SoundOn(40, 48, value); + break; + case REG_C0_SPUOFF1: + SoundOff(0, 16, value); + break; + case REG_C0_SPUOFF2: + SoundOff(16, 24, value); + break; + case REG_C1_SPUOFF1: + SoundOff(24, 40, value); + break; + case REG_C1_SPUOFF2: + SoundOff(40, 48, value); + break; + + // According to manual all bits are cleared by writing an arbitary value + case REG_C0_END1: + dwEndChannel2[0] = 0; + break; + case REG_C0_END2: + dwEndChannel2[0] = 0; + break; + case REG_C1_END1: + dwEndChannel2[1] = 0; + break; + case REG_C1_END2: + dwEndChannel2[1] = 0; + break; + case REG_C0_FMOD1: + FModOn(0, 16, value); + break; + case REG_C0_FMOD2: + FModOn(16, 24, value); + break; + case REG_C1_FMOD1: + FModOn(24, 40, value); + break; + case REG_C1_FMOD2: + FModOn(40, 48, value); + break; + } + + assert(C0_SPUADDR < 0x100000); + assert(C1_SPUADDR < 0x100000); +} + +EXPORT_C_(u16) SPU2read(u32 mem) +{ + u32 spuaddr; + u16 ret; + u32 r = mem & 0xffff; + + if ((r >= 0x0000 && r <= 0x0180) || (r >= 0x0400 && r <= 0x0580)) // some channel info? + { + int ch = 0; + if (r >= 0x400) ch = ((r - 0x400) >> 4) + 24; + else ch = (r >> 4); + + VOICE_PROCESSED* pvoice = &voices[ch]; + + switch (r&0x0f) + { + case 10: + return (unsigned short)(pvoice->ADSRX.EnvelopeVol >> 16); + } + } + + if ((r > 0x01c0 && r <= 0x02E0) || (r > 0x05c0 && r <= 0x06E0)) // some channel info? + { + int ch = 0; + unsigned long rx = r; + if (rx >= 0x400) + { + ch = 24; + rx -= 0x400; + } + + ch += ((rx - 0x1c0) / 12); + rx -= (ch % 24) * 12; + VOICE_PROCESSED* pvoice = &voices[ch]; + + switch (rx) + { + case 0x1C0: + return (u16)(((pvoice->pStart - (u8*)spu2mem) >> 17)&0x3F); + case 0x1C2: + return (u16)(((pvoice->pStart - (u8*)spu2mem) >> 1)&0xFFFF); + case 0x1C4: + return (u16)(((pvoice->pLoop - (u8*)spu2mem) >> 17)&0x3F); + case 0x1C6: + return (u16)(((pvoice->pLoop - (u8*)spu2mem) >> 1)&0xFFFF); + case 0x1C8: + return (u16)(((pvoice->pCurr - (u8*)spu2mem) >> 17)&0x3F); + case 0x1CA: + return (u16)(((pvoice->pCurr - (u8*)spu2mem) >> 1)&0xFFFF); + } + } + + switch (mem&0xffff) + { + case REG_C0_SPUDATA: + spuaddr = C0_SPUADDR; + ret = spu2mem[spuaddr]; + spuaddr++; + if (spuaddr > 0xfffff) + spuaddr = 0; + C0_SPUADDR_SET(spuaddr); + break; + case REG_C1_SPUDATA: + spuaddr = C1_SPUADDR; + ret = spu2mem[spuaddr]; + spuaddr++; + if (spuaddr > 0xfffff) + spuaddr = 0; + C1_SPUADDR_SET(spuaddr); + break; + + case REG_C0_END1: + return (dwEndChannel2[0]&0xffff); + case REG_C0_END2: + return (dwEndChannel2[0] >> 16); + case REG_C1_END1: + return (dwEndChannel2[1]&0xffff); + case REG_C1_END2: + return (dwEndChannel2[1] >> 16); + + case REG_IRQINFO: + ret = IRQINFO; + IRQINFO = 0; + break; + default: + ret = spu2Ru16(mem); + } + + SPU2_LOG("SPU2 read mem %x: %x\n", mem, ret); + + return ret; +} + +EXPORT_C_(void) SPU2WriteMemAddr(int core, u32 value) +{ + MemAddr[core] = value; +} + +EXPORT_C_(u32) SPU2ReadMemAddr(int core) +{ + return MemAddr[core]; +} + +EXPORT_C_(void) SPU2irqCallback(void (*SPU2callback)(), void (*DMA4callback)(), void (*DMA7callback)()) +{ + irqCallbackSPU2 = SPU2callback; + irqCallbackDMA4 = DMA4callback; + irqCallbackDMA7 = DMA7callback; +} + +// VOICE_PROCESSED definitions +SPU_CONTROL_* VOICE_PROCESSED::GetCtrl() +{ + return ((SPU_CONTROL_*)(spu2regs + memoffset + REG_C0_CTRL)); +} + +void VOICE_PROCESSED::SetVolume(int iProcessRight) +{ + u16 vol = iProcessRight ? pvoice->right.word : pvoice->left.word; + + if (vol&0x8000) // sweep not working + { + short sInc = 1; // -> sweep up? + if (vol&0x2000) sInc = -1; // -> or down? + if (vol&0x1000) vol ^= 0xffff; // -> mmm... phase inverted? have to investigate this + vol = ((vol & 0x7f) + 1) / 2; // -> sweep: 0..127 -> 0..64 + vol += vol / (2 * sInc); // -> HACK: we don't sweep right now, so we just raise/lower the volume by the half! + vol *= 128; + } + else // no sweep: + { + if (vol&0x4000) // -> mmm... phase inverted? have to investigate this + vol = 0x3fff - (vol & 0x3fff); + } + + vol &= 0x3fff; + // set volume + //if( iProcessRight ) right = vol; + //else left = vol; +} + +void VOICE_PROCESSED::StartSound() +{ + ADSRX.lVolume = 1; // and init some adsr vars + ADSRX.State = 0; + ADSRX.EnvelopeVol = 0; + + if (bReverb && GetCtrl()->reverb) + { + // setup the reverb effects + } + + pCurr = pStart; // set sample start + iSBPos = 28; + + bNew = false; // init channel flags + bStop = false; + bOn = true; + spos = 0x10000L; +} + +void VOICE_PROCESSED::VoiceChangeFrequency() +{ + iUsedFreq = iActFreq; // -> take it and calc steps + sinc = (u32)pvoice->pitch << 4; + if (!sinc) + sinc = 1; +} + +void VOICE_PROCESSED::Stop() +{ +} + +// GUI Routines +EXPORT_C_(s32) SPU2test() +{ + return 0; +} + +typedef struct +{ + u32 version; + u8 spu2regs[0x10000]; +} SPU2freezeData; + +EXPORT_C_(s32) SPU2freeze(int mode, freezeData *data) +{ + SPU2freezeData *spud; + + if (mode == FREEZE_LOAD) + { + spud = (SPU2freezeData*)data->data; + if (spud->version == 0x11223344) + { + memcpy(spu2regs, spud->spu2regs, 0x10000); + } + else printf("SPU2null wrong format\n"); + } + else + if (mode == FREEZE_SAVE) + { + spud = (SPU2freezeData*)data->data; + spud->version = 0x11223344; + memcpy(spud->spu2regs, spu2regs, 0x10000); + } + else + if (mode == FREEZE_SIZE) + { + data->size = sizeof(SPU2freezeData); + } + + return 0; +} + diff --git a/plugins/SPU2null/SPU2.h b/plugins/SPU2null/SPU2.h new file mode 100644 index 0000000000..842ff27b85 --- /dev/null +++ b/plugins/SPU2null/SPU2.h @@ -0,0 +1,293 @@ +/* SPU2null + * Copyright (C) 2002-2005 SPU2null 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef __SPU2_H__ +#define __SPU2_H__ + +#define _CRT_SECURE_NO_DEPRECATE + +#include +#include + +extern "C" +{ +#define SPU2defs +#include "PS2Edefs.h" +} + +#ifdef __LINUX__ +#include +#else +#include +#include +#endif + +#ifdef _MSC_VER +#define EXPORT_C_(type) extern "C" __declspec(dllexport) type CALLBACK +#else +#define EXPORT_C_(type) extern "C" type +#endif + +extern FILE *spu2Log; +#define SPU2_LOG __Log //debug mode + +extern const unsigned char version; +extern const unsigned char revision; +extern const unsigned char build; +extern const unsigned int minor; +extern char *libraryName; + +typedef struct +{ + int Log; +} Config; + +extern Config conf; + +void __Log(char *fmt, ...); +void SaveConfig(); +void LoadConfig(); +void SysMessage(char *fmt, ...); + +//////////////////// +// SPU2 Registers // +//////////////////// +#define REG_VP_VOLL 0x0000 +#define REG_VP_VOLR 0x0002 +#define REG_VP_PITCH 0x0004 +#define REG_VP_ADSR1 0x0006 +#define REG_VP_ADSR2 0x0008 +#define REG_VP_ENVX 0x000A +#define REG_VP_VOLXL 0x000C +#define REG_VP_VOLXR 0x000E +#define REG_C0_FMOD1 0x0180 +#define REG_C0_FMOD2 0x0182 +#define REG_C1_FMOD1 0x0580 +#define REG_C1_FMOD2 0x0582 +#define REG_S_NON 0x0184 +#define REG_S_VMIXL 0x0188 +#define REG_S_VMIXEL 0x018C +#define REG_S_VMIXR 0x0190 +#define REG_S_VMIXER 0x0194 +#define REG_C0_MMIX 0x0198 +#define REG_C1_MMIX 0x0598 +#define REG_C0_CTRL 0x019A +#define REG_C0_IRQA_HI 0x019C +#define REG_C0_IRQA_LO 0x019D +#define REG_C1_IRQA_HI 0x059C +#define REG_C1_IRQA_LO 0x059D +#define REG_C0_SPUON1 0x1A0 +#define REG_C0_SPUON2 0x1A2 +#define REG_C1_SPUON1 0x5A0 +#define REG_C1_SPUON2 0x5A2 +#define REG_C0_SPUOFF1 0x1A4 +#define REG_C0_SPUOFF2 0x1A6 +#define REG_C1_SPUOFF1 0x5A4 +#define REG_C1_SPUOFF2 0x5A6 +#define REG_C0_SPUADDR_HI 0x01A8 +#define REG_C0_SPUADDR_LO 0x01AA +#define REG_C1_SPUADDR_HI 0x05A8 +#define REG_C1_SPUADDR_LO 0x05AA +#define REG_C0_SPUDATA 0x01AC +#define REG_C1_SPUDATA 0x05AC +#define REG_C0_DMACTRL 0x01AE +#define REG_C1_DMACTRL 0x05AE +#define REG_C0_ADMAS 0x01B0 +#define REG_VA_SSA 0x01C0 +#define REG_VA_LSAX 0x01C4 +#define REG_VA_NAX 0x01C8 +#define REG_A_ESA 0x02E0 +#define REG_A_EEA 0x033C +#define REG_C0_END1 0x0340 +#define REG_C0_END2 0x0342 +#define REG_C1_END1 0x0740 +#define REG_C1_END2 0x0742 +#define REG_C0_SPUSTAT 0x0344 //not sure! +#define REG_C1_CTRL 0x059A +#define REG_C1_ADMAS 0x05B0 +#define REG_C1_SPUSTAT 0x0744 //not sure! +#define REG_P_MVOLL 0x0760 +#define REG_P_MVOLR 0x0762 +#define REG_P_EVOLL 0x0764 +#define REG_P_EVOLR 0x0766 +#define REG_P_AVOLL 0x0768 +#define REG_P_AVOLR 0x076A +#define REG_P_BVOLL 0x076C +#define REG_P_BVOLR 0x076E +#define REG_P_MVOLXL 0x0770 +#define REG_P_MVOLXR 0x0772 +#define SPDIF_OUT 0x07C0 +#define REG_IRQINFO 0x07C2 +#define SPDIF_MODE 0x07C6 +#define SPDIF_MEDIA 0x07C8 + +#define spu2Rs16(mem) (*(s16*)&spu2regs[(mem) & 0xffff]) +#define spu2Ru16(mem) (*(u16*)&spu2regs[(mem) & 0xffff]) +//#define spu2Rs32(mem) (*(s32*)&spu2regs[(mem) & 0xffff]) +//#define spu2Ru32(mem) (*(u32*)&spu2regs[(mem) & 0xffff]) + +#define IRQINFO spu2Ru16(REG_IRQINFO) + +#define SPU2_GET32BIT(lo,hi) (((u32)(spu2Ru16(hi)&0x3f)<<16)|(u32)spu2Ru16(lo)) +#define SPU2_SET32BIT(value, lo, hi) { \ + spu2Ru16(hi) = ((value)>>16)&0x3f; \ + spu2Ru16(lo) = (value)&0xffff; \ + } \ + +#define C0_IRQA SPU2_GET32BIT(REG_C0_IRQA_LO, REG_C0_IRQA_HI) +#define C1_IRQA SPU2_GET32BIT(REG_C1_IRQA_LO, REG_C1_IRQA_HI) + +#define C0_SPUADDR SPU2_GET32BIT(REG_C0_SPUADDR_LO, REG_C0_SPUADDR_HI) +#define C1_SPUADDR SPU2_GET32BIT(REG_C1_SPUADDR_LO, REG_C1_SPUADDR_HI) + +#define C0_SPUADDR_SET(value) SPU2_SET32BIT(value, REG_C0_IRQA_LO, REG_C0_IRQA_HI) +#define C1_SPUADDR_SET(value) SPU2_SET32BIT(value, REG_C1_IRQA_LO, REG_C1_IRQA_HI) + +#define SPU_NUMBER_VOICES 48 + +struct SPU_CONTROL_ +{ + u16 spuon : 1; + u16 spuUnmute : 1; + u16 noiseFreq : 6; + u16 reverb : 1; + u16 irq : 1; + u16 dma : 2; // 1 - no dma, 2 - write, 3 - read + u16 extr : 1; // external reverb + u16 cdreverb : 1; + u16 extAudio : 1; + u16 extCd : 1; +}; + +// the layout of each voice in wSpuRegs +struct _SPU_VOICE +{ + union + { + struct { + u16 Vol : 14; + u16 Inverted : 1; + u16 Sweep0 : 1; + } vol; + struct { + u16 Vol : 7; + u16 res1 : 5; + u16 Inverted : 1; + u16 Decrease : 1; // if 0, increase + u16 ExpSlope : 1; // if 0, linear slope + u16 Sweep1 : 1; // always one + } sweep; + u16 word; +} left, right; + + u16 pitch : 14; // 1000 - no pitch, 2000 - pitch + 1, etc + u16 res0 : 2; + + u16 SustainLvl : 4; + u16 DecayRate : 4; + u16 AttackRate : 7; + u16 AttackExp : 1; // if 0, linear + + u16 ReleaseRate : 5; + u16 ReleaseExp : 1; // if 0, linear + u16 SustainRate : 7; + u16 res1 : 1; + u16 SustainDec : 1; // if 0, inc + u16 SustainExp : 1; // if 0, linear + + u16 AdsrVol; + u16 Address; // add / 8 + u16 RepeatAddr; // gets reset when sample starts +}; + +// ADSR INFOS PER CHANNEL +struct ADSRInfoEx +{ + int State; + int AttackModeExp; + int AttackRate; + int DecayRate; + int SustainLevel; + int SustainModeExp; + int SustainIncrease; + int SustainRate; + int ReleaseModeExp; + int ReleaseRate; + int EnvelopeVol; + long lVolume; +}; + +#define NSSIZE 48 // ~ 1 ms of data +#define NSFRAMES 16 // gather at least NSFRAMES of NSSIZE before submitting +#define NSPACKETS 4 +#define SPU_VOICE_STATE_SIZE (sizeof(VOICE_PROCESSED)-4*sizeof(void*)) + +struct VOICE_PROCESSED +{ + VOICE_PROCESSED() + { + memset(this, 0, sizeof(VOICE_PROCESSED)); + } + ~VOICE_PROCESSED() + { + } + + void SetVolume(int right); + void StartSound(); + void VoiceChangeFrequency(); + void FModChangeFrequency(int ns); + void Stop(); + + SPU_CONTROL_* GetCtrl(); + + // start save state + + int iSBPos; // mixing stuff + int spos; + int sinc; + + int iActFreq; // current psx pitch + int iUsedFreq; // current pc pitch + + int iStartAddr, iLoopAddr, iNextAddr; + + ADSRInfoEx ADSRX; // next ADSR settings (will be moved to active on sample start) + bool bIgnoreLoop, bNew, bNoise, bReverb, bOn, bStop, bVolChanged; + int memoffset; // if first core, 0, if second, 0x400 + + // end save state + + /////////////////// + // Sound Buffers // + /////////////////// + u8* pStart; // start and end addresses + u8* pLoop, *pCurr; + + _SPU_VOICE* pvoice; +}; + +struct ADMA +{ + unsigned short * MemAddr; + long IntPointer; + int Index; + int AmountLeft; + int Enabled; +}; + +#endif /* __SPU2_H__ */ diff --git a/plugins/SPU2null/Src/Makefile b/plugins/SPU2null/Src/Makefile deleted file mode 100644 index 89c2b357ae..0000000000 --- a/plugins/SPU2null/Src/Makefile +++ /dev/null @@ -1,25 +0,0 @@ - -CC = gcc - -PLUGIN = libSPU2null.so -CFLAGS+= -fPIC -Wall -O2 -fomit-frame-pointer -D__LINUX__ -I../../../common/include -OBJS = SPU2.o -DEPS:= $(OBJS:.o=.d) -LIBS = $(shell pkg-config --libs gtk+-2.0) -CFLAGS+= $(shell pkg-config --cflags gtk+-2.0) - -all: plugin -install: all - -plugin: ${OBJS} - rm -f ${PLUGIN} - gcc -shared -Wl,-soname,${PLUGIN} ${CFLAGS} ${OBJS} -o ${PLUGIN} ${LIBS} - strip --strip-unneeded --strip-debug ${PLUGIN} - -clean: - rm -f ${OBJS} ${DEPS} - -%.o: %.cpp - ${CC} ${CFLAGS} -c -o $@ $< -MD -MF $(patsubst %.o,%.d,$@) - -#-include ${DEPS} diff --git a/plugins/SPU2null/Src/SPU2.cpp b/plugins/SPU2null/Src/SPU2.cpp deleted file mode 100644 index da50e2bcce..0000000000 --- a/plugins/SPU2null/Src/SPU2.cpp +++ /dev/null @@ -1,1213 +0,0 @@ -/* SPU2null - * Copyright (C) 2002-2005 SPU2null 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "SPU2.h" - -#include -#include - -const unsigned char version = PS2E_SPU2_VERSION; -const unsigned char revision = 0; -const unsigned char build = 7; // increase that with each version -const unsigned int minor = 1; // increase that with each version - -// ADSR constants -#define ATTACK_MS 494L -#define DECAYHALF_MS 286L -#define DECAY_MS 572L -#define SUSTAIN_MS 441L -#define RELEASE_MS 437L - -#ifdef _DEBUG -static char *libraryName = "SPU2null (Debug)"; -#else -static char *libraryName = "SPU2null "; -#endif - -FILE *spu2Log; -Config conf; - -ADMA Adma4; -ADMA Adma7; - -u32 MemAddr[2]; -u32 g_nSpuInit = 0; -unsigned short interrupt = 0; -s8 *spu2regs = NULL; -u16* spu2mem = NULL; -u16* pSpuIrq[2] = {NULL}; -u32 dwEndChannel2[2] = {0}; // keeps track of what channels have ended -unsigned long dwNoiseVal=1; // global noise generator - -int SPUCycles = 0, SPUWorkerCycles = 0; -int SPUStartCycle[2]; -int SPUTargetCycle[2]; - -int ADMAS4Write(); -int ADMAS7Write(); - -void InitADSR(); - -void (*irqCallbackSPU2)(); // func of main emu, called on spu irq -void (*irqCallbackDMA4)()=0; // func of main emu, called on spu irq -void (*irqCallbackDMA7)()=0; // func of main emu, called on spu irq - -const int f[5][2] = { { 0, 0 }, - { 60, 0 }, - { 115, -52 }, - { 98, -55 }, - { 122, -60 } }; - -u32 RateTable[160]; - -// channels and voices -VOICE_PROCESSED voices[SPU_NUMBER_VOICES+1]; // +1 for modulation - -u32 CALLBACK PS2EgetLibType() { - return PS2E_LT_SPU2; -} - -char* CALLBACK PS2EgetLibName() { - return libraryName; -} - -u32 CALLBACK PS2EgetLibVersion2(u32 type) { - return (version<<16)|(revision<<8)|build|(minor<<24); -} - -void __Log(char *fmt, ...) { - va_list list; - - if (!conf.Log || spu2Log == NULL) return; - - va_start(list, fmt); - vfprintf(spu2Log, fmt, list); - va_end(list); -} - -s32 CALLBACK SPU2init() { -#ifdef SPU2_LOG - spu2Log = fopen("logs/spu2.txt", "w"); - if (spu2Log) setvbuf(spu2Log, NULL, _IONBF, 0); - SPU2_LOG("Spu2 null version %d,%d\n",revision,build); - SPU2_LOG("SPU2init\n"); -#endif - spu2regs = (s8*)malloc(0x10000); - if (spu2regs == NULL) { - SysMessage("Error allocating Memory\n"); return -1; - } - memset(spu2regs, 0, 0x10000); - - spu2mem = (u16*)malloc(0x200000); // 2Mb - if (spu2mem == NULL) { - SysMessage("Error allocating Memory\n"); return -1; - } - memset(spu2mem, 0, 0x200000); - memset(dwEndChannel2, 0, sizeof(dwEndChannel2)); - - InitADSR(); - - memset(voices, 0, sizeof(voices)); - // last 24 channels have higher mem offset - for(int i = 0; i < 24; ++i) - voices[i+24].memoffset = 0x400; - - // init each channel - for(u32 i = 0; i < ArraySize(voices); ++i) { - - voices[i].pLoop = voices[i].pStart = voices[i].pCurr = (u8*)spu2mem; - - voices[i].pvoice = (_SPU_VOICE*)((u8*)spu2regs+voices[i].memoffset)+(i%24); - voices[i].ADSRX.SustainLevel = 1024; // -> init sustain - } - - return 0; -} - -s32 CALLBACK SPU2open(void *pDsp) { - LoadConfig(); - SPUCycles = SPUWorkerCycles = 0; - interrupt = 0; - SPUStartCycle[0] = SPUStartCycle[1] = 0; - SPUTargetCycle[0] = SPUTargetCycle[1] = 0; - g_nSpuInit = 1; - return 0; -} - -void CALLBACK SPU2close() { - g_nSpuInit = 0; -} - -void CALLBACK SPU2shutdown() { - free(spu2regs); spu2regs = NULL; - free(spu2mem); spu2mem = NULL; -#ifdef SPU2_LOG - if (spu2Log) fclose(spu2Log); -#endif -} - -// simulate SPU2 for 1ms -void SPU2Worker(); - -#define CYCLES_PER_MS (36864000/1000) - -void CALLBACK SPU2async(u32 cycle) -{ - SPUCycles += cycle; - if(interrupt & (1<<2)){ - if(SPUCycles - SPUStartCycle[1] >= SPUTargetCycle[1]){ - interrupt &= ~(1<<2); - irqCallbackDMA7(); - } - - } - - if(interrupt & (1<<1)){ - if(SPUCycles - SPUStartCycle[0] >= SPUTargetCycle[0]){ - interrupt &= ~(1<<1); - irqCallbackDMA4(); - } - } - - if( g_nSpuInit ) { - - while( SPUCycles-SPUWorkerCycles > 0 && CYCLES_PER_MS < SPUCycles-SPUWorkerCycles ) { - SPU2Worker(); - SPUWorkerCycles += CYCLES_PER_MS; - } - } -} - -void InitADSR() // INIT ADSR -{ - unsigned long r,rs,rd; - int i; - memset(RateTable,0,sizeof(unsigned long)*160); // build the rate table according to Neill's rules (see at bottom of file) - - r=3;rs=1;rd=0; - - for(i=32;i<160;i++) // we start at pos 32 with the real values... everything before is 0 - { - if(r<0x3FFFFFFF) - { - r+=rs; - rd++;if(rd==5) {rd=1;rs*=2;} - } - if(r>0x3FFFFFFF) r=0x3FFFFFFF; - - RateTable[i]=r; - } -} - -int MixADSR(VOICE_PROCESSED* pvoice) // MIX ADSR -{ - if(pvoice->bStop) // should be stopped: - { - if(pvoice->bIgnoreLoop==0){ - pvoice->ADSRX.EnvelopeVol=0; - pvoice->bOn=false; - pvoice->pStart= (u8*)(spu2mem+pvoice->iStartAddr); - pvoice->pLoop= (u8*)(spu2mem+pvoice->iStartAddr); - pvoice->pCurr= (u8*)(spu2mem+pvoice->iStartAddr); - pvoice->bStop=true; - pvoice->bIgnoreLoop=false; - return 0; - } - if(pvoice->ADSRX.ReleaseModeExp)// do release - { - switch((pvoice->ADSRX.EnvelopeVol>>28)&0x7) - { - case 0: pvoice->ADSRX.EnvelopeVol-=RateTable[(4*(pvoice->ADSRX.ReleaseRate^0x1F))-0x18 +0 + 32]; break; - case 1: pvoice->ADSRX.EnvelopeVol-=RateTable[(4*(pvoice->ADSRX.ReleaseRate^0x1F))-0x18 +4 + 32]; break; - case 2: pvoice->ADSRX.EnvelopeVol-=RateTable[(4*(pvoice->ADSRX.ReleaseRate^0x1F))-0x18 +6 + 32]; break; - case 3: pvoice->ADSRX.EnvelopeVol-=RateTable[(4*(pvoice->ADSRX.ReleaseRate^0x1F))-0x18 +8 + 32]; break; - case 4: pvoice->ADSRX.EnvelopeVol-=RateTable[(4*(pvoice->ADSRX.ReleaseRate^0x1F))-0x18 +9 + 32]; break; - case 5: pvoice->ADSRX.EnvelopeVol-=RateTable[(4*(pvoice->ADSRX.ReleaseRate^0x1F))-0x18 +10+ 32]; break; - case 6: pvoice->ADSRX.EnvelopeVol-=RateTable[(4*(pvoice->ADSRX.ReleaseRate^0x1F))-0x18 +11+ 32]; break; - case 7: pvoice->ADSRX.EnvelopeVol-=RateTable[(4*(pvoice->ADSRX.ReleaseRate^0x1F))-0x18 +12+ 32]; break; - } - } - else - { - pvoice->ADSRX.EnvelopeVol-=RateTable[(4*(pvoice->ADSRX.ReleaseRate^0x1F))-0x0C + 32]; - } - - if(pvoice->ADSRX.EnvelopeVol<0) - { - pvoice->ADSRX.EnvelopeVol=0; - pvoice->bOn=false; - pvoice->pStart= (u8*)(spu2mem+pvoice->iStartAddr); - pvoice->pLoop= (u8*)(spu2mem+pvoice->iStartAddr); - pvoice->pCurr= (u8*)(spu2mem+pvoice->iStartAddr); - pvoice->bStop=true; - pvoice->bIgnoreLoop=false; - //pvoice->bReverb=0; - //pvoice->bNoise=0; - } - - pvoice->ADSRX.lVolume=pvoice->ADSRX.EnvelopeVol>>21; - pvoice->ADSRX.lVolume=pvoice->ADSRX.EnvelopeVol>>21; - return pvoice->ADSRX.lVolume; - } - else // not stopped yet? - { - if(pvoice->ADSRX.State==0) // -> attack - { - if(pvoice->ADSRX.AttackModeExp) - { - if(pvoice->ADSRX.EnvelopeVol<0x60000000) - pvoice->ADSRX.EnvelopeVol+=RateTable[(pvoice->ADSRX.AttackRate^0x7F)-0x10 + 32]; - else - pvoice->ADSRX.EnvelopeVol+=RateTable[(pvoice->ADSRX.AttackRate^0x7F)-0x18 + 32]; - } - else - { - pvoice->ADSRX.EnvelopeVol+=RateTable[(pvoice->ADSRX.AttackRate^0x7F)-0x10 + 32]; - } - - if(pvoice->ADSRX.EnvelopeVol<0) - { - pvoice->ADSRX.EnvelopeVol=0x7FFFFFFF; - pvoice->ADSRX.State=1; - } - - pvoice->ADSRX.lVolume=pvoice->ADSRX.EnvelopeVol>>21; - return pvoice->ADSRX.lVolume; - } - //--------------------------------------------------// - if(pvoice->ADSRX.State==1) // -> decay - { - switch((pvoice->ADSRX.EnvelopeVol>>28)&0x7) - { - case 0: pvoice->ADSRX.EnvelopeVol-=RateTable[(4*(pvoice->ADSRX.DecayRate^0x1F))-0x18+0 + 32]; break; - case 1: pvoice->ADSRX.EnvelopeVol-=RateTable[(4*(pvoice->ADSRX.DecayRate^0x1F))-0x18+4 + 32]; break; - case 2: pvoice->ADSRX.EnvelopeVol-=RateTable[(4*(pvoice->ADSRX.DecayRate^0x1F))-0x18+6 + 32]; break; - case 3: pvoice->ADSRX.EnvelopeVol-=RateTable[(4*(pvoice->ADSRX.DecayRate^0x1F))-0x18+8 + 32]; break; - case 4: pvoice->ADSRX.EnvelopeVol-=RateTable[(4*(pvoice->ADSRX.DecayRate^0x1F))-0x18+9 + 32]; break; - case 5: pvoice->ADSRX.EnvelopeVol-=RateTable[(4*(pvoice->ADSRX.DecayRate^0x1F))-0x18+10+ 32]; break; - case 6: pvoice->ADSRX.EnvelopeVol-=RateTable[(4*(pvoice->ADSRX.DecayRate^0x1F))-0x18+11+ 32]; break; - case 7: pvoice->ADSRX.EnvelopeVol-=RateTable[(4*(pvoice->ADSRX.DecayRate^0x1F))-0x18+12+ 32]; break; - } - - if(pvoice->ADSRX.EnvelopeVol<0) pvoice->ADSRX.EnvelopeVol=0; - if(((pvoice->ADSRX.EnvelopeVol>>27)&0xF) <= pvoice->ADSRX.SustainLevel) - { - pvoice->ADSRX.State=2; - } - - pvoice->ADSRX.lVolume=pvoice->ADSRX.EnvelopeVol>>21; - return pvoice->ADSRX.lVolume; - } - //--------------------------------------------------// - if(pvoice->ADSRX.State==2) // -> sustain - { - if(pvoice->ADSRX.SustainIncrease) - { - if(pvoice->ADSRX.SustainModeExp) - { - if(pvoice->ADSRX.EnvelopeVol<0x60000000) - pvoice->ADSRX.EnvelopeVol+=RateTable[(pvoice->ADSRX.SustainRate^0x7F)-0x10 + 32]; - else - pvoice->ADSRX.EnvelopeVol+=RateTable[(pvoice->ADSRX.SustainRate^0x7F)-0x18 + 32]; - } - else - { - pvoice->ADSRX.EnvelopeVol+=RateTable[(pvoice->ADSRX.SustainRate^0x7F)-0x10 + 32]; - } - - if(pvoice->ADSRX.EnvelopeVol<0) - { - pvoice->ADSRX.EnvelopeVol=0x7FFFFFFF; - } - } - else - { - if(pvoice->ADSRX.SustainModeExp) - { - switch((pvoice->ADSRX.EnvelopeVol>>28)&0x7) - { - case 0: pvoice->ADSRX.EnvelopeVol-=RateTable[((pvoice->ADSRX.SustainRate^0x7F))-0x1B +0 + 32];break; - case 1: pvoice->ADSRX.EnvelopeVol-=RateTable[((pvoice->ADSRX.SustainRate^0x7F))-0x1B +4 + 32];break; - case 2: pvoice->ADSRX.EnvelopeVol-=RateTable[((pvoice->ADSRX.SustainRate^0x7F))-0x1B +6 + 32];break; - case 3: pvoice->ADSRX.EnvelopeVol-=RateTable[((pvoice->ADSRX.SustainRate^0x7F))-0x1B +8 + 32];break; - case 4: pvoice->ADSRX.EnvelopeVol-=RateTable[((pvoice->ADSRX.SustainRate^0x7F))-0x1B +9 + 32];break; - case 5: pvoice->ADSRX.EnvelopeVol-=RateTable[((pvoice->ADSRX.SustainRate^0x7F))-0x1B +10+ 32];break; - case 6: pvoice->ADSRX.EnvelopeVol-=RateTable[((pvoice->ADSRX.SustainRate^0x7F))-0x1B +11+ 32];break; - case 7: pvoice->ADSRX.EnvelopeVol-=RateTable[((pvoice->ADSRX.SustainRate^0x7F))-0x1B +12+ 32];break; - } - } - else - { - pvoice->ADSRX.EnvelopeVol-=RateTable[((pvoice->ADSRX.SustainRate^0x7F))-0x0F + 32]; - } - - if(pvoice->ADSRX.EnvelopeVol<0) - { - pvoice->ADSRX.EnvelopeVol=0; - } - } - pvoice->ADSRX.lVolume=pvoice->ADSRX.EnvelopeVol>>21; - return pvoice->ADSRX.lVolume; - } - } - return 0; -} - -// simulate SPU2 for 1ms -void SPU2Worker() -{ - u8* start; - int ch,flags; - - VOICE_PROCESSED* pChannel=voices; - for(ch=0;chbNew) { - pChannel->StartSound(); // start new sound - dwEndChannel2[ch/24]&=~(1<<(ch%24)); // clear end channel bit - } - - if(!pChannel->bOn) - { - // fill buffer with empty data - continue; - } - - if(pChannel->iActFreq!=pChannel->iUsedFreq) // new psx frequency? - pChannel->VoiceChangeFrequency(); - - // loop until 1 ms of data is reached - int ns = 0; - while(nsspos >= 0x10000 ) - { - if(pChannel->iSBPos==28) // 28 reached? - { - start=pChannel->pCurr; // set up the current pos - - // special "stop" sign - if( start == (u8*)-1 ) //!pChannel->bOn - { - pChannel->bOn=false; // -> turn everything off - pChannel->ADSRX.lVolume=0; - pChannel->ADSRX.EnvelopeVol=0; - goto ENDX; // -> and done for this channel - } - - pChannel->iSBPos=0; - - // decode the 16 byte packet - - flags=(int)start[1]; - start += 16; - - // some callback and irq active? - if(pChannel->GetCtrl()->irq) { - // if irq address reached or irq on looping addr, when stop/loop flag is set - u8* pirq = (u8*)pSpuIrq[ch>=24]; - if( (pirq > start-16 && pirq <= start) - || ((flags&1) && (pirq > pChannel->pLoop-16 && pirq <= pChannel->pLoop))) - { - IRQINFO |= 4<<(int)(ch>=24); - irqCallbackSPU2(); - } - } - - // flag handler - if((flags&4) && (!pChannel->bIgnoreLoop)) - pChannel->pLoop=start-16; // loop adress - - if(flags&1) // 1: stop/loop - { - // We play this block out first... - dwEndChannel2[ch/24]|=(1<<(ch%24)); - //if(!(flags&2)) // 1+2: do loop... otherwise: stop - if(flags!=3 || pChannel->pLoop==NULL) // PETE: if we don't check exactly for 3, loop hang ups will happen (DQ4, for example) - { // and checking if pLoop is set avoids crashes, yeah - start = (u8*)-1; - pChannel->bStop = true; - pChannel->bIgnoreLoop = false; - } - else - { - start = pChannel->pLoop; - } - } - - pChannel->pCurr=start; // store values for next cycle - } - - pChannel->iSBPos++; // get sample data - pChannel->spos -= 0x10000; - } - - MixADSR(pChannel); - - // go to the next packet - ns++; - pChannel->spos += pChannel->sinc; - } -ENDX: - ; - } - - // mix all channels - if( (spu2Ru16(REG_C0_MMIX) & 0xC0) && (spu2Ru16(REG_C0_ADMAS) & 0x1) && !(spu2Ru16(REG_C0_CTRL) & 0x30)) { - for(int ns=0;ns0x0fffff) // wrap at 2Mb - spuaddr=0; // wrap - } - - spuaddr+=19; //Transfer Local To Host TSAH/L + Data Size + 20 (already +1'd) - C0_SPUADDR_SET(spuaddr); - - // got from J.F. and Kanodin... is it needed? - spu2Ru16(REG_C0_SPUSTAT) &=~0x80; // DMA complete - SPUStartCycle[0] = SPUCycles; - SPUTargetCycle[0] = size; - interrupt |= (1<<1); -} - -void CALLBACK SPU2readDMA7Mem(u16* pMem, int size) -{ - u32 spuaddr = C1_SPUADDR; - int i; - -#ifdef SPU2_LOG - SPU2_LOG("SPU2 readDMA7Mem size %x, addr: %x\n", size, pMem); -#endif - - for(i=0;i0x0fffff) // wrap at 2Mb - spuaddr=0; // wrap - } - - spuaddr+=19; //Transfer Local To Host TSAH/L + Data Size + 20 (already +1'd) - C1_SPUADDR_SET(spuaddr); - - // got from J.F. and Kanodin... is it needed? - spu2Ru16(REG_C1_SPUSTAT)&=~0x80; // DMA complete - SPUStartCycle[1] = SPUCycles; - SPUTargetCycle[1] = size; - interrupt |= (1<<2); -} - -// WRITE - -// AutoDMA's are used to transfer to the DIRECT INPUT area of the spu2 memory -// Left and Right channels are always interleaved together in the transfer so -// the AutoDMA's deinterleaves them and transfers them. An interrupt is -// generated when half of the buffer (256 short-words for left and 256 -// short-words for right ) has been transferred. Another interrupt occurs at -// the end of the transfer. -int ADMAS4Write() -{ - u32 spuaddr; - if(interrupt & 0x2) return 0; - if(Adma4.AmountLeft <= 0) return 1; - - spuaddr = C0_SPUADDR; - // SPU2 Deinterleaves the Left and Right Channels - memcpy((short*)(spu2mem + spuaddr + 0x2000),(short*)Adma4.MemAddr,512); - Adma4.MemAddr += 256; - memcpy((short*)(spu2mem + spuaddr + 0x2200),(short*)Adma4.MemAddr,512); - Adma4.MemAddr += 256; - spuaddr = (spuaddr + 256) & 511; - C0_SPUADDR_SET(spuaddr); - - Adma4.AmountLeft-=512; - if(Adma4.AmountLeft == 0) - { - SPUStartCycle[0] = SPUCycles; - SPUTargetCycle[0] = 1;//512*48000; - spu2Ru16(REG_C0_SPUSTAT)&=~0x80; - interrupt |= (1<<1); - } - return 0; -} - -int ADMAS7Write() -{ - u32 spuaddr; - if(interrupt & 0x4) return 0; - if(Adma7.AmountLeft <= 0) return 1; - - spuaddr = C1_SPUADDR; - // SPU2 Deinterleaves the Left and Right Channels - memcpy((short*)(spu2mem + spuaddr + 0x2400),(short*)Adma7.MemAddr,512); - Adma7.MemAddr += 256; - memcpy((short*)(spu2mem + spuaddr + 0x2600),(short*)Adma7.MemAddr,512); - Adma7.MemAddr += 256; - spuaddr = (spuaddr + 256) & 511; - C1_SPUADDR_SET(spuaddr); - - Adma7.AmountLeft-=512; - if(Adma7.AmountLeft == 0) - { - SPUStartCycle[1] = SPUCycles; - SPUTargetCycle[1] = 1;//512*48000; - spu2Ru16(REG_C1_SPUSTAT)&=~0x80; - interrupt |= (1<<2); - } - return 0; -} - -void CALLBACK SPU2writeDMA4Mem(u16* pMem, int size) -{ - u32 spuaddr; - -#ifdef SPU2_LOG - SPU2_LOG("SPU2 writeDMA4Mem size %x, addr: %x\n", size, pMem); -#endif - if((spu2Ru16(REG_C0_ADMAS) & 0x1) && (spu2Ru16(REG_C0_CTRL) & 0x30) == 0 && size) - { - //fwrite(pMem,iSize<<1,1,LogFile); - memset(&Adma4,0,sizeof(ADMA)); - C0_SPUADDR_SET(0); - Adma4.MemAddr = pMem; - Adma4.AmountLeft = size; - ADMAS4Write(); - return; - } - - spuaddr = C0_SPUADDR; - memcpy((unsigned char*)(spu2mem + spuaddr),(unsigned char*)pMem,size<<1); - spuaddr += size; - C0_SPUADDR_SET(spuaddr); - - if( (spu2Ru16(REG_C0_CTRL)&0x40) && C0_IRQA == spuaddr){ - spu2Ru16(SPDIF_OUT) |= 0x4; - IRQINFO |= 4; - irqCallbackSPU2(); - } - if(spuaddr>0xFFFFE) - spuaddr = 0x2800; - C0_SPUADDR_SET(spuaddr); - - MemAddr[0] += size<<1; - spu2Ru16(REG_C0_SPUSTAT)&=~0x80; - SPUStartCycle[0] = SPUCycles; - SPUTargetCycle[0] = 1;//iSize; - interrupt |= (1<<1); -} - -void CALLBACK SPU2writeDMA7Mem(u16* pMem, int size) -{ - u32 spuaddr; - -#ifdef SPU2_LOG - SPU2_LOG("SPU2 writeDMA7Mem size %x, addr: %x\n", size, pMem); -#endif - if((spu2Ru16(REG_C1_ADMAS) & 0x2) && (spu2Ru16(REG_C1_CTRL) & 0x30) == 0 && size) - { - //fwrite(pMem,iSize<<1,1,LogFile); - memset(&Adma7,0,sizeof(ADMA)); - C1_SPUADDR_SET(0); - Adma7.MemAddr = pMem; - Adma7.AmountLeft = size; - ADMAS7Write(); - return; - } - - spuaddr = C1_SPUADDR; - memcpy((unsigned char*)(spu2mem + spuaddr),(unsigned char*)pMem,size<<1); - spuaddr += size; - C1_SPUADDR_SET(spuaddr); - - if( (spu2Ru16(REG_C1_CTRL)&0x40) && C1_IRQA == spuaddr){ - spu2Ru16(SPDIF_OUT) |= 0x8; - IRQINFO |= 8; - irqCallbackSPU2(); - } - if(spuaddr>0xFFFFE) - spuaddr = 0x2800; - C1_SPUADDR_SET(spuaddr); - - MemAddr[1] += size<<1; - spu2Ru16(REG_C1_SPUSTAT)&=~0x80; - SPUStartCycle[1] = SPUCycles; - SPUTargetCycle[1] = 1;//iSize; - interrupt |= (1<<2); -} - -void CALLBACK SPU2interruptDMA4() -{ -#ifdef SPU2_LOG - SPU2_LOG("SPU2 interruptDMA4\n"); -#endif -// spu2Rs16(REG_C0_CTRL)&= ~0x30; -// spu2Rs16(REG__1B0) = 0; -// spu2Rs16(SPU2_STATX_WRDY_M)|= 0x80; - spu2Rs16(REG_C0_CTRL)&=~0x30; - spu2Ru16(REG_C0_SPUSTAT)|=0x80; -} - -void CALLBACK SPU2interruptDMA7() -{ -#ifdef SPU2_LOG - SPU2_LOG("SPU2 interruptDMA7\n"); -#endif -// spu2Rs16(REG_C1_CTRL)&= ~0x30; -// //spu2Rs16(REG__5B0) = 0; -// spu2Rs16(SPU2_STATX_DREQ)|= 0x80; - spu2Rs16(REG_C1_CTRL)&=~0x30; - spu2Ru16(REG_C1_SPUSTAT)|=0x80; -} - -// turn channels on -void SoundOn(int start,int end,unsigned short val) // SOUND ON PSX COMAND -{ - for(int ch=start;ch>=1) // loop channels - { - if((val&1) && voices[ch].pStart) // mmm... start has to be set before key on !?! - { - voices[ch].bNew=true; - voices[ch].bIgnoreLoop = false; - } - } -} - -// turn channels off -void SoundOff(int start,int end,unsigned short val) // SOUND OFF PSX COMMAND -{ - for(int ch=start;ch>=1) // loop channels - { - if(val&1) // && s_chan[i].bOn) mmm... - voices[ch].bStop=true; - } -} - -void FModOn(int start,int end,unsigned short val) // FMOD ON PSX COMMAND -{ - int ch; - - for(ch=start;ch>=1) // loop channels - { - if(val&1) // -> fmod on/off - { - if(ch>0) { - } - } - else { - // turn fmod off - } - } -} - -void CALLBACK SPU2write(u32 mem, u16 value) -{ - u32 spuaddr; -#ifdef SPU2_LOG - SPU2_LOG("SPU2 write mem %x value %x\n", mem, value); -#endif - - assert( C0_SPUADDR < 0x100000); - assert( C1_SPUADDR < 0x100000); - - spu2Ru16(mem) = value; - u32 r = mem&0xffff; - - // channel info - if((r>=0x0000 && r<0x0180)||(r>=0x0400 && r<0x0580)) // some channel info? - { - int ch=0; - if(r>=0x400) ch=((r-0x400)>>4)+24; - else ch=(r>>4); - - VOICE_PROCESSED* pvoice = &voices[ch]; - - switch(r&0x0f) - { - case 0: - case 2: - pvoice->SetVolume(mem&0x2); - break; - case 4: - { - int NP; - if(value>0x3fff) NP=0x3fff; // get pitch val - else NP=value; - - pvoice->pvoice->pitch = NP; - - NP=(44100L*NP)/4096L; // calc frequency - if(NP<1) NP=1; // some security - pvoice->iActFreq=NP; // store frequency - break; - } - case 6: - { - pvoice->ADSRX.AttackModeExp=(value&0x8000)?1:0; - pvoice->ADSRX.AttackRate = ((value>>8) & 0x007f); - pvoice->ADSRX.DecayRate = (((value>>4) & 0x000f)); - pvoice->ADSRX.SustainLevel = (value & 0x000f); - break; - } - case 8: - pvoice->ADSRX.SustainModeExp = (value&0x8000)?1:0; - pvoice->ADSRX.SustainIncrease= (value&0x4000)?0:1; - pvoice->ADSRX.SustainRate = ((value>>6) & 0x007f); - pvoice->ADSRX.ReleaseModeExp = (value&0x0020)?1:0; - pvoice->ADSRX.ReleaseRate = ((value & 0x001f)); - break; - } - - return; - } - - // more channel info - if((r>=0x01c0 && r<=0x02E0)||(r>=0x05c0 && r<=0x06E0)) - { - int ch=0; - unsigned long rx=r; - if(rx>=0x400) - { - ch=24; - rx-=0x400; - } - - ch+=((rx-0x1c0)/12); - rx-=(ch%24)*12; - VOICE_PROCESSED* pvoice = &voices[ch]; - - switch(rx) - { - case 0x1C0: - pvoice->iStartAddr=(((unsigned long)value&0x3f)<<16)|(pvoice->iStartAddr&0xFFFF); - pvoice->pStart=(u8*)(spu2mem+pvoice->iStartAddr); - break; - case 0x1C2: - pvoice->iStartAddr=(pvoice->iStartAddr & 0x3f0000) | (value & 0xFFFF); - pvoice->pStart=(u8*)(spu2mem+pvoice->iStartAddr); - break; - case 0x1C4: - pvoice->iLoopAddr =(((unsigned long)value&0x3f)<<16)|(pvoice->iLoopAddr&0xFFFF); - pvoice->pLoop=(u8*)(spu2mem+pvoice->iLoopAddr); - pvoice->bIgnoreLoop=pvoice->iLoopAddr>0; - break; - case 0x1C6: - pvoice->iLoopAddr=(pvoice->iLoopAddr& 0x3f0000) | (value & 0xFFFF); - pvoice->pLoop=(u8*)(spu2mem+pvoice->iLoopAddr); - pvoice->bIgnoreLoop=pvoice->iLoopAddr>0; - break; - case 0x1C8: - // unused... check if it gets written as well - pvoice->iNextAddr=(((unsigned long)value&0x3f)<<16)|(pvoice->iNextAddr&0xFFFF); - break; - case 0x1CA: - // unused... check if it gets written as well - pvoice->iNextAddr=(pvoice->iNextAddr & 0x3f0000) | (value & 0xFFFF); - break; - } - - return; - } - - // process non-channel data - switch(mem&0xffff) { - case REG_C0_SPUDATA: - spuaddr = C0_SPUADDR; - spu2mem[spuaddr] = value; - spuaddr++; - if( (spu2Ru16(REG_C0_CTRL)&0x40) && C0_IRQA == spuaddr){ - spu2Ru16(SPDIF_OUT) |= 0x4; - IRQINFO |= 4; - irqCallbackSPU2(); - } - if(spuaddr>0xFFFFE) - spuaddr = 0x2800; - C0_SPUADDR_SET(spuaddr); - spu2Ru16(REG_C0_SPUSTAT)&=~0x80; - spu2Ru16(REG_C0_CTRL)&=~0x30; - break; - case REG_C1_SPUDATA: - spuaddr = C1_SPUADDR; - spu2mem[spuaddr] = value; - spuaddr++; - if( (spu2Ru16(REG_C1_CTRL)&0x40) && C1_IRQA == spuaddr){ - spu2Ru16(SPDIF_OUT) |= 0x8; - IRQINFO |= 8; - irqCallbackSPU2(); - } - if(spuaddr>0xFFFFE) - spuaddr = 0x2800; - C1_SPUADDR_SET(spuaddr); - spu2Ru16(REG_C1_SPUSTAT)&=~0x80; - spu2Ru16(REG_C1_CTRL)&=~0x30; - break; - case REG_C0_IRQA_HI: - case REG_C0_IRQA_LO: - pSpuIrq[0]=spu2mem+(C0_IRQA<<1); - break; - case REG_C1_IRQA_HI: - case REG_C1_IRQA_LO: - pSpuIrq[1]=spu2mem+(C1_IRQA<<1); - break; - - case REG_C0_SPUADDR_HI: - case REG_C1_SPUADDR_HI: - spu2Ru16(mem) = value&0xf; - break; - - case REG_C0_SPUON1: SoundOn(0,16,value); break; - case REG_C0_SPUON2: SoundOn(16,24,value); break; - case REG_C1_SPUON1: SoundOn(24,40,value); break; - case REG_C1_SPUON2: SoundOn(40,48,value); break; - case REG_C0_SPUOFF1: SoundOff(0,16,value); break; - case REG_C0_SPUOFF2: SoundOff(16,24,value); break; - case REG_C1_SPUOFF1: SoundOff(24,40,value); break; - case REG_C1_SPUOFF2: SoundOff(40,48,value); break; - - // According to manual all bits are cleared by writing an arbitary value - case REG_C0_END1: dwEndChannel2[0] = 0; break; - case REG_C0_END2: dwEndChannel2[0] = 0; break; - case REG_C1_END1: dwEndChannel2[1] = 0; break; - case REG_C1_END2: dwEndChannel2[1] = 0; break; - case REG_C0_FMOD1: FModOn(0,16,value); break; - case REG_C0_FMOD2: FModOn(16,24,value); break; - case REG_C1_FMOD1: FModOn(24,40,value); break; - case REG_C1_FMOD2: FModOn(40,48,value); break; - } - - assert( C0_SPUADDR < 0x100000); - assert( C1_SPUADDR < 0x100000); -} - -u16 CALLBACK SPU2read(u32 mem) -{ - u32 spuaddr; - u16 ret; - u32 r = mem&0xffff; - - if((r>=0x0000 && r<=0x0180)||(r>=0x0400 && r<=0x0580)) // some channel info? - { - int ch=0; - if(r>=0x400) ch=((r-0x400)>>4)+24; - else ch=(r>>4); - - VOICE_PROCESSED* pvoice = &voices[ch]; - - switch(r&0x0f) { - case 10: return (unsigned short)(pvoice->ADSRX.EnvelopeVol>>16); - } - } - - if((r>0x01c0 && r<=0x02E0)||(r>0x05c0 && r<=0x06E0)) // some channel info? - { - int ch=0; - unsigned long rx=r; - if(rx>=0x400) - { - ch=24; - rx-=0x400; - } - - ch+=((rx-0x1c0)/12); - rx-=(ch%24)*12; - VOICE_PROCESSED* pvoice = &voices[ch]; - - switch(rx) { - case 0x1C0: return (u16)(((pvoice->pStart-(u8*)spu2mem)>>17)&0x3F); - case 0x1C2: return (u16)(((pvoice->pStart-(u8*)spu2mem)>>1)&0xFFFF); - case 0x1C4: return (u16)(((pvoice->pLoop-(u8*)spu2mem)>>17)&0x3F); - case 0x1C6: return (u16)(((pvoice->pLoop-(u8*)spu2mem)>>1)&0xFFFF); - case 0x1C8: return (u16)(((pvoice->pCurr-(u8*)spu2mem)>>17)&0x3F); - case 0x1CA: return (u16)(((pvoice->pCurr-(u8*)spu2mem)>>1)&0xFFFF); - } - } - - switch(mem&0xffff) { - case REG_C0_SPUDATA: - spuaddr = C0_SPUADDR; - ret =spu2mem[spuaddr]; - spuaddr++; - if(spuaddr>0xfffff) - spuaddr=0; - C0_SPUADDR_SET(spuaddr); - break; - case REG_C1_SPUDATA: - spuaddr = C1_SPUADDR; - ret = spu2mem[spuaddr]; - spuaddr++; - if(spuaddr>0xfffff) - spuaddr=0; - C1_SPUADDR_SET(spuaddr); - break; - - case REG_C0_END1: return (dwEndChannel2[0]&0xffff); - case REG_C0_END2: return (dwEndChannel2[0]>>16); - case REG_C1_END1: return (dwEndChannel2[1]&0xffff); - case REG_C1_END2: return (dwEndChannel2[1]>>16); - - case REG_IRQINFO: - ret = IRQINFO; - IRQINFO = 0; - break; - default: - ret = spu2Ru16(mem); - } -#ifdef SPU2_LOG - SPU2_LOG("SPU2 read mem %x: %x\n", mem, ret); -#endif - - return ret; -} - -void CALLBACK SPU2WriteMemAddr(int core, u32 value) -{ - MemAddr[core] = value; -} - -u32 CALLBACK SPU2ReadMemAddr(int core) -{ - return MemAddr[core]; -} - -void CALLBACK SPU2irqCallback(void (*SPU2callback)(),void (*DMA4callback)(),void (*DMA7callback)()) -{ - irqCallbackSPU2 = SPU2callback; - irqCallbackDMA4 = DMA4callback; - irqCallbackDMA7 = DMA7callback; -} - -// VOICE_PROCESSED definitions -SPU_CONTROL_* VOICE_PROCESSED::GetCtrl() -{ - return ((SPU_CONTROL_*)(spu2regs+memoffset+REG_C0_CTRL)); -} - -void VOICE_PROCESSED::SetVolume(int iProcessRight) -{ - u16 vol = iProcessRight ? pvoice->right.word : pvoice->left.word; - - if(vol&0x8000) // sweep not working - { - short sInc=1; // -> sweep up? - if(vol&0x2000) sInc=-1; // -> or down? - if(vol&0x1000) vol^=0xffff; // -> mmm... phase inverted? have to investigate this - vol=((vol&0x7f)+1)/2; // -> sweep: 0..127 -> 0..64 - vol+=vol/(2*sInc); // -> HACK: we don't sweep right now, so we just raise/lower the volume by the half! - vol*=128; - } - else // no sweep: - { - if(vol&0x4000) // -> mmm... phase inverted? have to investigate this - vol=0x3fff-(vol&0x3fff); - } - - vol&=0x3fff; - // set volume - //if( iProcessRight ) right = vol; - //else left = vol; -} - -void VOICE_PROCESSED::StartSound() -{ - ADSRX.lVolume=1; // and init some adsr vars - ADSRX.State=0; - ADSRX.EnvelopeVol=0; - - if(bReverb && GetCtrl()->reverb ) - { - // setup the reverb effects - } - - pCurr=pStart; // set sample start - iSBPos=28; - - bNew=false; // init channel flags - bStop=false; - bOn=true; - spos=0x10000L; -} - -void VOICE_PROCESSED::VoiceChangeFrequency() -{ - iUsedFreq=iActFreq; // -> take it and calc steps - sinc=(u32)pvoice->pitch<<4; - if(!sinc) - sinc=1; -} - -void VOICE_PROCESSED::Stop() -{ -} - -// GUI Routines -s32 CALLBACK SPU2test() { - return 0; -} - -typedef struct { - u32 version; - u8 spu2regs[0x10000]; -} SPU2freezeData; - -s32 CALLBACK SPU2freeze(int mode, freezeData *data){ - SPU2freezeData *spud; - - if (mode == FREEZE_LOAD) { - spud = (SPU2freezeData*)data->data; - if( spud->version == 0x11223344 ) { - memcpy(spu2regs, spud->spu2regs, 0x10000); - } - else printf("SPU2null wrong format\n"); - } else - if (mode == FREEZE_SAVE) { - spud = (SPU2freezeData*)data->data; - spud->version = 0x11223344; - memcpy(spud->spu2regs, spu2regs, 0x10000); - } else - if (mode == FREEZE_SIZE) { - data->size = sizeof(SPU2freezeData); - } - - return 0; -} - -#ifndef _WIN32 - -GtkWidget *MsgDlg; - -void OnMsg_Ok() { - gtk_widget_destroy(MsgDlg); - gtk_main_quit(); -} - -void SysMessage(char *fmt, ...) { - GtkWidget *Ok,*Txt; - GtkWidget *Box,*Box1; - va_list list; - char msg[512]; - - va_start(list, fmt); - vsprintf(msg, fmt, list); - va_end(list); - - if (msg[strlen(msg)-1] == '\n') msg[strlen(msg)-1] = 0; - - MsgDlg = gtk_window_new (GTK_WINDOW_POPUP); - gtk_window_set_position(GTK_WINDOW(MsgDlg), GTK_WIN_POS_CENTER); - gtk_window_set_title(GTK_WINDOW(MsgDlg), "SPU2null Msg"); - gtk_container_set_border_width(GTK_CONTAINER(MsgDlg), 5); - - Box = gtk_vbox_new(5, 0); - gtk_container_add(GTK_CONTAINER(MsgDlg), Box); - gtk_widget_show(Box); - - Txt = gtk_label_new(msg); - - gtk_box_pack_start(GTK_BOX(Box), Txt, FALSE, FALSE, 5); - gtk_widget_show(Txt); - - Box1 = gtk_hbutton_box_new(); - gtk_box_pack_start(GTK_BOX(Box), Box1, FALSE, FALSE, 0); - gtk_widget_show(Box1); - - Ok = gtk_button_new_with_label("Ok"); - gtk_signal_connect (GTK_OBJECT(Ok), "clicked", GTK_SIGNAL_FUNC(OnMsg_Ok), NULL); - gtk_container_add(GTK_CONTAINER(Box1), Ok); - GTK_WIDGET_SET_FLAGS(Ok, GTK_CAN_DEFAULT); - gtk_widget_show(Ok); - - gtk_widget_show(MsgDlg); - - gtk_main(); -} - -void CALLBACK SPU2configure() { - SysMessage("Nothing to Configure"); -} - -void CALLBACK SPU2about() { - SysMessage("%s %d.%d", libraryName, version, build); -} - -void LoadConfig() -{ -} - -#endif diff --git a/plugins/SPU2null/Src/SPU2.h b/plugins/SPU2null/Src/SPU2.h deleted file mode 100644 index 9ea1180a2e..0000000000 --- a/plugins/SPU2null/Src/SPU2.h +++ /dev/null @@ -1,280 +0,0 @@ -/* SPU2null - * Copyright (C) 2002-2005 SPU2null 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef __SPU2_H__ -#define __SPU2_H__ - -#define _CRT_SECURE_NO_DEPRECATE - -#include -#include - -extern "C" { -#define SPU2defs -#include "PS2Edefs.h" -} - -#ifdef __LINUX__ -#include -#else -#include -#include -#endif - -extern FILE *spu2Log; -#define SPU2_LOG __Log //debug mode - - -typedef struct { - int Log; -} Config; - -extern Config conf; - -void __Log(char *fmt, ...); -void SaveConfig(); -void LoadConfig(); -void SysMessage(char *fmt, ...); - -//////////////////// -// SPU2 Registers // -//////////////////// -#define REG_VP_VOLL 0x0000 -#define REG_VP_VOLR 0x0002 -#define REG_VP_PITCH 0x0004 -#define REG_VP_ADSR1 0x0006 -#define REG_VP_ADSR2 0x0008 -#define REG_VP_ENVX 0x000A -#define REG_VP_VOLXL 0x000C -#define REG_VP_VOLXR 0x000E -#define REG_C0_FMOD1 0x0180 -#define REG_C0_FMOD2 0x0182 -#define REG_C1_FMOD1 0x0580 -#define REG_C1_FMOD2 0x0582 -#define REG_S_NON 0x0184 -#define REG_S_VMIXL 0x0188 -#define REG_S_VMIXEL 0x018C -#define REG_S_VMIXR 0x0190 -#define REG_S_VMIXER 0x0194 -#define REG_C0_MMIX 0x0198 -#define REG_C1_MMIX 0x0598 -#define REG_C0_CTRL 0x019A -#define REG_C0_IRQA_HI 0x019C -#define REG_C0_IRQA_LO 0x019D -#define REG_C1_IRQA_HI 0x059C -#define REG_C1_IRQA_LO 0x059D -#define REG_C0_SPUON1 0x1A0 -#define REG_C0_SPUON2 0x1A2 -#define REG_C1_SPUON1 0x5A0 -#define REG_C1_SPUON2 0x5A2 -#define REG_C0_SPUOFF1 0x1A4 -#define REG_C0_SPUOFF2 0x1A6 -#define REG_C1_SPUOFF1 0x5A4 -#define REG_C1_SPUOFF2 0x5A6 -#define REG_C0_SPUADDR_HI 0x01A8 -#define REG_C0_SPUADDR_LO 0x01AA -#define REG_C1_SPUADDR_HI 0x05A8 -#define REG_C1_SPUADDR_LO 0x05AA -#define REG_C0_SPUDATA 0x01AC -#define REG_C1_SPUDATA 0x05AC -#define REG_C0_DMACTRL 0x01AE -#define REG_C1_DMACTRL 0x05AE -#define REG_C0_ADMAS 0x01B0 -#define REG_VA_SSA 0x01C0 -#define REG_VA_LSAX 0x01C4 -#define REG_VA_NAX 0x01C8 -#define REG_A_ESA 0x02E0 -#define REG_A_EEA 0x033C -#define REG_C0_END1 0x0340 -#define REG_C0_END2 0x0342 -#define REG_C1_END1 0x0740 -#define REG_C1_END2 0x0742 -#define REG_C0_SPUSTAT 0x0344 //not sure! -#define REG_C1_CTRL 0x059A -#define REG_C1_ADMAS 0x05B0 -#define REG_C1_SPUSTAT 0x0744 //not sure! -#define REG_P_MVOLL 0x0760 -#define REG_P_MVOLR 0x0762 -#define REG_P_EVOLL 0x0764 -#define REG_P_EVOLR 0x0766 -#define REG_P_AVOLL 0x0768 -#define REG_P_AVOLR 0x076A -#define REG_P_BVOLL 0x076C -#define REG_P_BVOLR 0x076E -#define REG_P_MVOLXL 0x0770 -#define REG_P_MVOLXR 0x0772 -#define SPDIF_OUT 0x07C0 -#define REG_IRQINFO 0x07C2 -#define SPDIF_MODE 0x07C6 -#define SPDIF_MEDIA 0x07C8 - -#define spu2Rs16(mem) (*(s16*)&spu2regs[(mem) & 0xffff]) -#define spu2Ru16(mem) (*(u16*)&spu2regs[(mem) & 0xffff]) -//#define spu2Rs32(mem) (*(s32*)&spu2regs[(mem) & 0xffff]) -//#define spu2Ru32(mem) (*(u32*)&spu2regs[(mem) & 0xffff]) - -#define IRQINFO spu2Ru16(REG_IRQINFO) - -#define SPU2_GET32BIT(lo,hi) (((u32)(spu2Ru16(hi)&0x3f)<<16)|(u32)spu2Ru16(lo)) -#define SPU2_SET32BIT(value, lo, hi) { \ - spu2Ru16(hi) = ((value)>>16)&0x3f; \ - spu2Ru16(lo) = (value)&0xffff; \ - } \ - -#define C0_IRQA SPU2_GET32BIT(REG_C0_IRQA_LO, REG_C0_IRQA_HI) -#define C1_IRQA SPU2_GET32BIT(REG_C1_IRQA_LO, REG_C1_IRQA_HI) - -#define C0_SPUADDR SPU2_GET32BIT(REG_C0_SPUADDR_LO, REG_C0_SPUADDR_HI) -#define C1_SPUADDR SPU2_GET32BIT(REG_C1_SPUADDR_LO, REG_C1_SPUADDR_HI) - -#define C0_SPUADDR_SET(value) SPU2_SET32BIT(value, REG_C0_IRQA_LO, REG_C0_IRQA_HI) -#define C1_SPUADDR_SET(value) SPU2_SET32BIT(value, REG_C1_IRQA_LO, REG_C1_IRQA_HI) - -#define SPU_NUMBER_VOICES 48 - -struct SPU_CONTROL_ -{ - u16 spuon : 1; - u16 spuUnmute : 1; - u16 noiseFreq : 6; - u16 reverb : 1; - u16 irq : 1; - u16 dma : 2; // 1 - no dma, 2 - write, 3 - read - u16 extr : 1; // external reverb - u16 cdreverb : 1; - u16 extAudio : 1; - u16 extCd : 1; -}; - -// the layout of each voice in wSpuRegs -struct _SPU_VOICE -{ - union - { - struct { - u16 Vol : 14; - u16 Inverted : 1; - u16 Sweep0 : 1; - } vol; - struct { - u16 Vol : 7; - u16 res1 : 5; - u16 Inverted : 1; - u16 Decrease : 1; // if 0, increase - u16 ExpSlope : 1; // if 0, linear slope - u16 Sweep1 : 1; // always one - } sweep; - u16 word; - } left, right; - - u16 pitch : 14; // 1000 - no pitch, 2000 - pitch + 1, etc - u16 res0 : 2; - - u16 SustainLvl : 4; - u16 DecayRate : 4; - u16 AttackRate : 7; - u16 AttackExp : 1; // if 0, linear - - u16 ReleaseRate : 5; - u16 ReleaseExp : 1; // if 0, linear - u16 SustainRate : 7; - u16 res1 : 1; - u16 SustainDec : 1; // if 0, inc - u16 SustainExp : 1; // if 0, linear - - u16 AdsrVol; - u16 Address; // add / 8 - u16 RepeatAddr; // gets reset when sample starts -}; - -// ADSR INFOS PER CHANNEL -struct ADSRInfoEx -{ - int State; - int AttackModeExp; - int AttackRate; - int DecayRate; - int SustainLevel; - int SustainModeExp; - int SustainIncrease; - int SustainRate; - int ReleaseModeExp; - int ReleaseRate; - int EnvelopeVol; - long lVolume; -}; - -#define NSSIZE 48 // ~ 1 ms of data -#define NSFRAMES 16 // gather at least NSFRAMES of NSSIZE before submitting -#define NSPACKETS 4 -#define SPU_VOICE_STATE_SIZE (sizeof(VOICE_PROCESSED)-4*sizeof(void*)) - -struct VOICE_PROCESSED -{ - VOICE_PROCESSED() - { - memset(this, 0, sizeof(VOICE_PROCESSED)); - } - ~VOICE_PROCESSED() - { - } - - void SetVolume(int right); - void StartSound(); - void VoiceChangeFrequency(); - void FModChangeFrequency(int ns); - void Stop(); - - SPU_CONTROL_* GetCtrl(); - - // start save state - - int iSBPos; // mixing stuff - int spos; - int sinc; - - int iActFreq; // current psx pitch - int iUsedFreq; // current pc pitch - - int iStartAddr, iLoopAddr, iNextAddr; - - ADSRInfoEx ADSRX; // next ADSR settings (will be moved to active on sample start) - bool bIgnoreLoop, bNew, bNoise, bReverb, bOn, bStop, bVolChanged; - int memoffset; // if first core, 0, if second, 0x400 - - // end save state - - /////////////////// - // Sound Buffers // - /////////////////// - u8* pStart; // start and end addresses - u8* pLoop, *pCurr; - - _SPU_VOICE* pvoice; -}; - -struct ADMA -{ - unsigned short * MemAddr; - long IntPointer; - int Index; - int AmountLeft; - int Enabled; -}; - -#endif /* __SPU2_H__ */ diff --git a/plugins/SPU2null/Src/Config.cpp b/plugins/SPU2null/Windows/Config.cpp similarity index 100% rename from plugins/SPU2null/Src/Config.cpp rename to plugins/SPU2null/Windows/Config.cpp diff --git a/plugins/SPU2null/Src/ProjectRootDir.vsprops b/plugins/SPU2null/Windows/ProjectRootDir.vsprops similarity index 100% rename from plugins/SPU2null/Src/ProjectRootDir.vsprops rename to plugins/SPU2null/Windows/ProjectRootDir.vsprops diff --git a/plugins/SPU2null/Src/SPU2null.def b/plugins/SPU2null/Windows/SPU2null.def similarity index 100% rename from plugins/SPU2null/Src/SPU2null.def rename to plugins/SPU2null/Windows/SPU2null.def diff --git a/plugins/SPU2null/Src/SPU2null.rc b/plugins/SPU2null/Windows/SPU2null.rc similarity index 100% rename from plugins/SPU2null/Src/SPU2null.rc rename to plugins/SPU2null/Windows/SPU2null.rc diff --git a/plugins/SPU2null/Src/SPU2null_2008.vcproj b/plugins/SPU2null/Windows/SPU2null_2008.vcproj similarity index 89% rename from plugins/SPU2null/Src/SPU2null_2008.vcproj rename to plugins/SPU2null/Windows/SPU2null_2008.vcproj index 1a8b6daea3..4df91f6d8e 100644 --- a/plugins/SPU2null/Src/SPU2null_2008.vcproj +++ b/plugins/SPU2null/Windows/SPU2null_2008.vcproj @@ -92,7 +92,7 @@ />
@@ -187,7 +187,7 @@ > diff --git a/plugins/SPU2null/Src/Win32.cpp b/plugins/SPU2null/Windows/Win32.cpp similarity index 100% rename from plugins/SPU2null/Src/Win32.cpp rename to plugins/SPU2null/Windows/Win32.cpp diff --git a/plugins/SPU2null/Src/resource.h b/plugins/SPU2null/Windows/resource.h similarity index 100% rename from plugins/SPU2null/Src/resource.h rename to plugins/SPU2null/Windows/resource.h diff --git a/plugins/SPU2null/build.sh b/plugins/SPU2null/build.sh index 5d04adfb50..da1381a4c4 100644 --- a/plugins/SPU2null/build.sh +++ b/plugins/SPU2null/build.sh @@ -1,13 +1,32 @@ #!/bin/sh +echo --------------- +echo Building SPU2null +echo --------------- + curdir=`pwd` -echo ----------------- -echo Building SPU2null -echo ----------------- -cd ${curdir}/Src +if test "${SPU2nullOPTIONS+set}" != set ; then +export SPU2nullOPTIONS="" +fi + +if [ $# -gt 0 ] && [ $1 = "all" ] +then + +aclocal +automake -a +autoconf + +./configure ${SPU2nullOPTIONS} --prefix=${PCSX2PLUGINS} make clean -make $@ +make install -cp libSPU2null.so ${PCSX2PLUGINS} +else +make $@ +fi + +if [ $? -ne 0 ] +then +exit 1 +fi diff --git a/plugins/SPU2null/configure.ac b/plugins/SPU2null/configure.ac new file mode 100644 index 0000000000..59ffe18988 --- /dev/null +++ b/plugins/SPU2null/configure.ac @@ -0,0 +1,80 @@ +AC_INIT(SPU2null, 0.5,arcum42@gmail.com) + +AM_INIT_AUTOMAKE(SPU2null,0.8) + +AC_PROG_CC([gcc g++ cl KCC CC cxx cc++ xlC aCC c++]) +AC_PROG_CXX([gcc g++ cl KCC CC cxx cc++ xlC aCC c++]) +AC_PROG_CPP([gcc g++ cl KCC CC cxx cc++ xlC aCC c++]) + +AC_PROG_INSTALL +AC_PROG_RANLIB + +dnl necessary for compiling assembly +AM_PROG_AS + +AC_SUBST(SPU2null_CURRENT, 0) +AC_SUBST(SPU2null_REVISION, 8) +AC_SUBST(SPU2null_AGE, 0) +AC_SUBST(SPU2null_RELEASE,[$SPU2null_CURRENT].[$SPU2null_REVISION].[$SPU2null_AGE]) +AC_SUBST(SPU2null_SONAME,libSPU2null.so.[$SPU2null_CURRENT].[$SPU2null_REVISION].[$SPU2null_AGE]) + +CFLAGS= +CPPFLAGS= +CXXFLAGS= + +dnl Check for debug build +AC_MSG_CHECKING(debug build) +AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug], [debug build]), +debug=$enableval,debug=no) +if test "x$debug" == xyes +then + AC_DEFINE(_DEBUG,1,[_DEBUG]) + CFLAGS+="-g -fPIC -Wall -Wno-unused-value " + CPPFLAGS+="-g -fPIC -Wall -Wno-unused-value " + CXXFLAGS+="-g -fPIC -Wall -Wno-unused-value " +else + AC_DEFINE(NDEBUG,1,[NDEBUG]) + CFLAGS+="-O3 -fomit-frame-pointer -fPIC -Wall -Wno-unused-value " + CPPFLAGS+="-O3 -fomit-frame-pointer -fPIC -Wall -Wno-unused-value " + CXXFLAGS+="-O3 -fomit-frame-pointer -fPIC -Wall -Wno-unused-value " +fi +AM_CONDITIONAL(DEBUGBUILD, test x$debug = xyes) +AC_MSG_RESULT($debug) + +AC_DEFINE(__LINUX__,1,[__LINUX__]) + +dnl Check for dev build +AC_MSG_CHECKING(for development build...) +AC_ARG_ENABLE(devbuild, AC_HELP_STRING([--enable-devbuild], [Special Build for developers that simplifies testing and adds extra checks]), + devbuild=$enableval,devbuild=no) +if test "x$devbuild" == xyes +then + AC_DEFINE(SPU2null_DEVBUILD,1,[SPU2null_DEVBUILD]) +fi +AC_MSG_RESULT($devbuild) +AM_CONDITIONAL(RELEASE_TO_PUBLIC, test x$devbuild = xno) + +AC_CHECK_FUNCS([ _aligned_malloc _aligned_free ], AC_DEFINE(HAVE_ALIGNED_MALLOC)) + +dnl gtk +AC_MSG_CHECKING(gtk2+) +AC_CHECK_PROG(GTK_CONFIG, pkg-config, pkg-config) +LIBS+=$(pkg-config --libs gtk+-2.0) + +dnl bindir = pcsx2exe + +dnl assuming linux environment +so_ext=".so.$SPU2null_RELEASE" +SHARED_LDFLAGS="-shared" +AC_SUBST(so_ext) +AC_SUBST(SHARED_LDFLAGS) + +AC_CHECK_LIB(stdc++,main,[LIBS="$LIBS -lstdc++"]) + +AC_OUTPUT([ + Makefile + ]) + +echo "Configuration:" +echo " Debug build? $debug" +echo " Dev build? $devbuild" \ No newline at end of file diff --git a/plugins/SPU2null/install-sh b/plugins/SPU2null/install-sh new file mode 120000 index 0000000000..8272958b56 --- /dev/null +++ b/plugins/SPU2null/install-sh @@ -0,0 +1 @@ +/usr/share/automake-1.10/install-sh \ No newline at end of file diff --git a/plugins/SPU2null/missing b/plugins/SPU2null/missing new file mode 120000 index 0000000000..1f0fe88e65 --- /dev/null +++ b/plugins/SPU2null/missing @@ -0,0 +1 @@ +/usr/share/automake-1.10/missing \ No newline at end of file From 6cc85d6050568f29e6a7c83a730caf85b9841fc7 Mon Sep 17 00:00:00 2001 From: arcum42 Date: Sat, 2 May 2009 04:12:29 +0000 Subject: [PATCH 34/41] And that's CDVDnull. Given how barebones this plugin is, it's closer to making a null plugin then cleaning it up... git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1110 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/CDVDnull/CDVD.cpp | 140 +++++++++++++++++ plugins/CDVDnull/CDVD.h | 52 +++++++ plugins/CDVDnull/Linux/Config.cpp | 78 ++++++++++ plugins/CDVDnull/Makefile.am | 27 ++++ plugins/CDVDnull/Src/CDVD.c | 145 ------------------ plugins/CDVDnull/Src/CDVD.h | 11 -- plugins/CDVDnull/Src/Makefile | 48 ------ .../CDVDnull/{Src => Windows}/CDVDnull.def | 0 .../{Src => Windows}/CDVDnull_vs2008.vcproj | 4 +- .../{Src => Windows}/ProjectRootDir.vsprops | 0 plugins/CDVDnull/{Src => Windows}/plugin.def | 0 plugins/CDVDnull/build.sh | 35 ++++- plugins/CDVDnull/configure.ac | 80 ++++++++++ plugins/CDVDnull/install-sh | 1 + plugins/CDVDnull/missing | 1 + 15 files changed, 408 insertions(+), 214 deletions(-) create mode 100644 plugins/CDVDnull/CDVD.cpp create mode 100644 plugins/CDVDnull/CDVD.h create mode 100644 plugins/CDVDnull/Linux/Config.cpp create mode 100644 plugins/CDVDnull/Makefile.am delete mode 100644 plugins/CDVDnull/Src/CDVD.c delete mode 100644 plugins/CDVDnull/Src/CDVD.h delete mode 100644 plugins/CDVDnull/Src/Makefile rename plugins/CDVDnull/{Src => Windows}/CDVDnull.def (100%) rename plugins/CDVDnull/{Src => Windows}/CDVDnull_vs2008.vcproj (92%) rename plugins/CDVDnull/{Src => Windows}/ProjectRootDir.vsprops (100%) rename plugins/CDVDnull/{Src => Windows}/plugin.def (100%) create mode 100644 plugins/CDVDnull/configure.ac create mode 120000 plugins/CDVDnull/install-sh create mode 120000 plugins/CDVDnull/missing diff --git a/plugins/CDVDnull/CDVD.cpp b/plugins/CDVDnull/CDVD.cpp new file mode 100644 index 0000000000..7d922872a7 --- /dev/null +++ b/plugins/CDVDnull/CDVD.cpp @@ -0,0 +1,140 @@ +/* CDVDnull + * Copyright (C) 2002-2009 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include + +#include "CDVD.h" + +const char *LibName = "CDVDnull Driver"; + +const unsigned char version = PS2E_CDVD_VERSION; +const unsigned char revision = 0; +const unsigned char build = 6; + +EXPORT_C_(char*) PS2EgetLibName() +{ + return (char *)LibName; +} + +EXPORT_C_(u32) PS2EgetLibType() +{ + return PS2E_LT_CDVD; +} + +EXPORT_C_(u32) CALLBACK PS2EgetLibVersion2(u32 type) +{ + return (version << 16) | (revision << 8) | build; +} + +#ifdef _WIN32 +void SysMessage(const char *fmt, ...) +{ + va_list list; + char tmp[512]; + + va_start(list, fmt); + vsprintf(tmp, fmt, list); + va_end(list); + + MessageBox(0, tmp, "CDVDnull Msg", 0); +} +#endif + +EXPORT_C_(s32) CDVDinit() +{ + return 0; +} + +EXPORT_C_(s32) CDVDopen(const char* pTitle) +{ + return 0; +} + +EXPORT_C_(void) CDVDclose() +{ +} + +EXPORT_C_(void) CDVDshutdown() +{ +} + +EXPORT_C_(s32) CDVDreadTrack(u32 lsn, int mode) +{ + return -1; +} + +// return can be NULL (for async modes) +EXPORT_C_(u8*) CDVDgetBuffer() +{ + return NULL; +} + +EXPORT_C_(s32) CDVDreadSubQ(u32 lsn, cdvdSubQ* subq) +{ + return -1; +} + +EXPORT_C_(s32) CDVDgetTN(cdvdTN *Buffer) +{ + return -1; +} + +EXPORT_C_(s32) CDVDgetTD(u8 Track, cdvdTD *Buffer) +{ + return -1; +} + +EXPORT_C_(s32) CDVDgetTOC(void* toc) +{ + return -1; +} + +EXPORT_C_(s32) CDVDgetDiskType() +{ + return CDVD_TYPE_NODISC; +} + +EXPORT_C_(s32) CDVDgetTrayStatus() +{ + return CDVD_TRAY_CLOSE; +} + +EXPORT_C_(s32) CDVDctrlTrayOpen() +{ + return 0; +} + +EXPORT_C_(s32) CDVDctrlTrayClose() +{ + return 0; +} + +EXPORT_C_(void) CDVDconfigure() +{ + SysMessage("Nothing to Configure"); +} + +EXPORT_C_(void) CDVDabout() +{ + SysMessage("%s %d.%d", LibName, revision, build); +} + +EXPORT_C_(s32) CDVDtest() +{ + return 0; +} diff --git a/plugins/CDVDnull/CDVD.h b/plugins/CDVDnull/CDVD.h new file mode 100644 index 0000000000..370e09bf26 --- /dev/null +++ b/plugins/CDVDnull/CDVD.h @@ -0,0 +1,52 @@ +/* CDVDnull + * Copyright (C) 2002-2009 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + + #ifndef __CDVD_H__ +#define __CDVD_H__ + +#ifdef _WIN32 +#include +#endif + +extern "C" +{ +#define CDVDdefs +#include "PS2Edefs.h" +} + +#ifdef __LINUX__ +#include +#else +#include +#include +#endif + +#ifdef _MSC_VER +#define EXPORT_C_(type) extern "C" __declspec(dllexport) type CALLBACK +#else +#define EXPORT_C_(type) extern "C" type +#endif + +extern const unsigned char version; +extern const unsigned char revision; +extern const unsigned char build; +extern const unsigned int minor; +extern const char *LibName; + +extern void SysMessage(const char *fmt, ...); +#endif /* __CDVD_H__ */ diff --git a/plugins/CDVDnull/Linux/Config.cpp b/plugins/CDVDnull/Linux/Config.cpp new file mode 100644 index 0000000000..fead9422be --- /dev/null +++ b/plugins/CDVDnull/Linux/Config.cpp @@ -0,0 +1,78 @@ +/* CDVDnull + * Copyright (C) 2002-2009 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "CDVD.h" + +#include +#include +#include +#include + +GtkWidget *MsgDlg; + +void OnMsg_Ok() +{ + gtk_widget_destroy(MsgDlg); + gtk_main_quit(); +} + +void SysMessage(const char *fmt, ...) +{ + GtkWidget *Ok, *Txt; + GtkWidget *Box, *Box1; + va_list list; + char msg[512]; + + va_start(list, fmt); + vsprintf(msg, fmt, list); + va_end(list); + + if (msg[strlen(msg)-1] == '\n') msg[strlen(msg)-1] = 0; + + MsgDlg = gtk_window_new(GTK_WINDOW_POPUP); + gtk_window_set_position(GTK_WINDOW(MsgDlg), GTK_WIN_POS_CENTER); + gtk_window_set_title(GTK_WINDOW(MsgDlg), "SPU2null Msg"); + gtk_container_set_border_width(GTK_CONTAINER(MsgDlg), 5); + + Box = gtk_vbox_new(5, 0); + gtk_container_add(GTK_CONTAINER(MsgDlg), Box); + gtk_widget_show(Box); + + Txt = gtk_label_new(msg); + + gtk_box_pack_start(GTK_BOX(Box), Txt, FALSE, FALSE, 5); + gtk_widget_show(Txt); + + Box1 = gtk_hbutton_box_new(); + gtk_box_pack_start(GTK_BOX(Box), Box1, FALSE, FALSE, 0); + gtk_widget_show(Box1); + + Ok = gtk_button_new_with_label("Ok"); + gtk_signal_connect(GTK_OBJECT(Ok), "clicked", GTK_SIGNAL_FUNC(OnMsg_Ok), NULL); + gtk_container_add(GTK_CONTAINER(Box1), Ok); + GTK_WIDGET_SET_FLAGS(Ok, GTK_CAN_DEFAULT); + gtk_widget_show(Ok); + + gtk_widget_show(MsgDlg); + + gtk_main(); +} + +void LoadConfig() +{ +} diff --git a/plugins/CDVDnull/Makefile.am b/plugins/CDVDnull/Makefile.am new file mode 100644 index 0000000000..4ec1b0e135 --- /dev/null +++ b/plugins/CDVDnull/Makefile.am @@ -0,0 +1,27 @@ +# Create a shared library libCDVDnull +AUTOMAKE_OPTIONS = foreign +noinst_LIBRARIES = libCDVDnull.a +INCLUDES = -I@srcdir@/../../common/include -I@srcdir@/../../3rdparty -I@srcdir@/Linux + +libCDVDnull_a_CXXFLAGS = $(shell pkg-config --cflags gtk+-2.0) +libCDVDnull_a_CFLAGS = $(shell pkg-config --cflags gtk+-2.0) + +# Create a shared object by faking an exe (thanks to ODE makefiles) +traplibdir=$(prefix) + +if DEBUGBUILD +preext=d +endif + +EXEEXT=$(preext)@so_ext@ + +traplib_PROGRAMS=libCDVDnull +libCDVDnull_SOURCES= +libCDVDnull_DEPENDENCIES = libCDVDnull.a +libCDVDnull_LDFLAGS= @SHARED_LDFLAGS@ +libCDVDnull_LDFLAGS+=-Wl,-soname,@libCDVDnull_SONAME@ +libCDVDnull_LDADD=$(libCDVDnull_a_OBJECTS) + +libCDVDnull_a_SOURCES = CDVD.cpp CDVD.h Linux/Config.cpp + +#SUBDIRS = Linux \ No newline at end of file diff --git a/plugins/CDVDnull/Src/CDVD.c b/plugins/CDVDnull/Src/CDVD.c deleted file mode 100644 index c4b3cfa04f..0000000000 --- a/plugins/CDVDnull/Src/CDVD.c +++ /dev/null @@ -1,145 +0,0 @@ -#include - -#include "CDVD.h" - -char *LibName = "CDVDnull Driver"; - -const unsigned char version = PS2E_CDVD_VERSION; -const unsigned char revision = 0; -const unsigned char build = 6; - - -char* CALLBACK PS2EgetLibName() { - return LibName; -} - -u32 CALLBACK PS2EgetLibType() { - return PS2E_LT_CDVD; -} - -u32 CALLBACK PS2EgetLibVersion2(u32 type) { - return (version << 16) | (revision << 8) | build; -} - -#ifdef _WIN32 -void SysMessage(char *fmt, ...) { - va_list list; - char tmp[512]; - - va_start(list,fmt); - vsprintf(tmp,fmt,list); - va_end(list); - - MessageBox(0, tmp, "CDVDnull Msg", 0); -} -#else - -void SysMessage(char *fmt, ...) { - /*GtkWidget *Ok,*Txt; - GtkWidget *Box,*Box1; - va_list list; - char msg[512]; - - va_start(list, fmt); - vsprintf(msg, fmt, list); - va_end(list); - - if (msg[strlen(msg)-1] == '\n') msg[strlen(msg)-1] = 0; - - MsgDlg = gtk_window_new (GTK_WINDOW_POPUP); - gtk_window_set_position(GTK_WINDOW(MsgDlg), GTK_WIN_POS_CENTER); - gtk_window_set_title(GTK_WINDOW(MsgDlg), "GSsoft Msg"); - gtk_container_set_border_width(GTK_CONTAINER(MsgDlg), 5); - - Box = gtk_vbox_new(5, 0); - gtk_container_add(GTK_CONTAINER(MsgDlg), Box); - gtk_widget_show(Box); - - Txt = gtk_label_new(msg); - - gtk_box_pack_start(GTK_BOX(Box), Txt, FALSE, FALSE, 5); - gtk_widget_show(Txt); - - Box1 = gtk_hbutton_box_new(); - gtk_box_pack_start(GTK_BOX(Box), Box1, FALSE, FALSE, 0); - gtk_widget_show(Box1); - - Ok = gtk_button_new_with_label("Ok"); - gtk_signal_connect (GTK_OBJECT(Ok), "clicked", GTK_SIGNAL_FUNC(OnMsg_Ok), NULL); - gtk_container_add(GTK_CONTAINER(Box1), Ok); - GTK_WIDGET_SET_FLAGS(Ok, GTK_CAN_DEFAULT); - gtk_widget_show(Ok); - - gtk_widget_show(MsgDlg); - - gtk_main();*/ -} - -#endif - -s32 CALLBACK CDVDinit() { - return 0; -} - -s32 CALLBACK CDVDopen(const char* pTitle) { - return 0; -} - -void CALLBACK CDVDclose() { -} - -void CALLBACK CDVDshutdown() { -} - -s32 CALLBACK CDVDreadTrack(u32 lsn, int mode) { - return -1; -} - -// return can be NULL (for async modes) -u8* CALLBACK CDVDgetBuffer() { - return NULL; -} - -s32 CALLBACK CDVDreadSubQ(u32 lsn, cdvdSubQ* subq) { - return -1; -} - -s32 CALLBACK CDVDgetTN(cdvdTN *Buffer) { - return -1; -} - -s32 CALLBACK CDVDgetTD(u8 Track, cdvdTD *Buffer) { - return -1; -} - -s32 CALLBACK CDVDgetTOC(void* toc) { - return -1; -} - -s32 CALLBACK CDVDgetDiskType() { - return CDVD_TYPE_NODISC; -} - -s32 CALLBACK CDVDgetTrayStatus() { - return CDVD_TRAY_CLOSE; -} - -s32 CALLBACK CDVDctrlTrayOpen() { - return 0; -} - -s32 CALLBACK CDVDctrlTrayClose() { - return 0; -} - -void CALLBACK CDVDconfigure() { - SysMessage("Nothing to Configure"); -} - -void CALLBACK CDVDabout() { - SysMessage("%s %d.%d", LibName, revision, build); -} - -s32 CALLBACK CDVDtest() { - return 0; -} diff --git a/plugins/CDVDnull/Src/CDVD.h b/plugins/CDVDnull/Src/CDVD.h deleted file mode 100644 index e8c983e700..0000000000 --- a/plugins/CDVDnull/Src/CDVD.h +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef __CDVD_H__ -#define __CDVD_H__ - -#ifdef _WIN32 -#include -#endif - -#define CDVDdefs -#include "PS2Edefs.h" - -#endif /* __CDVD_H__ */ diff --git a/plugins/CDVDnull/Src/Makefile b/plugins/CDVDnull/Src/Makefile deleted file mode 100644 index d9b83b8a82..0000000000 --- a/plugins/CDVDnull/Src/Makefile +++ /dev/null @@ -1,48 +0,0 @@ -# -# Makefile for MINGW32 -# - -all: cdvdnull -install: all - -PLUGIN = libCDVDnull.so - -CC = gcc -NASM = nasmw -RM = rm -f -AR = ar -STRIP = strip -RC = windres - -OPTIMIZE = -O2 -fomit-frame-pointer -finline-functions -ffast-math -fno-strict-aliasing -FLAGS = -DENABLE_NLS -DPACKAGE=\"pcsx2\" -RC1FLAGS = -LIBS = -RESOBJ = cdvdnull.o - -OBJS = CDVD.o - -DEPS:= $(OBJS:.o=.d) - -CFLAGS = -Wall ${OPTIMIZE} -I../../../common/include -I. -I/usr/local/include ${FLAGS} -fPIC - -cdvdnull: ${OBJS} -# dllwrap --def plugin.def -o ${PLUGIN} ${OBJS} ${LIBS} - ${CC} -shared -Wl,-soname,${PLUGIN} ${CFLAGS} ${OBJS} -o ${PLUGIN} ${LIBS} - ${STRIP} ${PLUGIN} - -.PHONY: clean cdvdnull - -clean: - ${RM} ${OBJS} ${DEPS} ${PCSX2} - -%.o: %.asm - ${NASM} ${ASMFLAGS} -o $@ $< - -%.o: %.c - ${CC} ${CFLAGS} -c -o $@ $< -MD -MF $(patsubst %.o,%.d,$@) - -${RESOBJ}: CDVDnull.rc - ${RC} -D__MINGW32__ -I rc -O coff -o $@ -i $< - --include ${DEPS} diff --git a/plugins/CDVDnull/Src/CDVDnull.def b/plugins/CDVDnull/Windows/CDVDnull.def similarity index 100% rename from plugins/CDVDnull/Src/CDVDnull.def rename to plugins/CDVDnull/Windows/CDVDnull.def diff --git a/plugins/CDVDnull/Src/CDVDnull_vs2008.vcproj b/plugins/CDVDnull/Windows/CDVDnull_vs2008.vcproj similarity index 92% rename from plugins/CDVDnull/Src/CDVDnull_vs2008.vcproj rename to plugins/CDVDnull/Windows/CDVDnull_vs2008.vcproj index 3e7a210ec4..26d4c17132 100644 --- a/plugins/CDVDnull/Src/CDVDnull_vs2008.vcproj +++ b/plugins/CDVDnull/Windows/CDVDnull_vs2008.vcproj @@ -102,11 +102,11 @@ Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" > Date: Sat, 2 May 2009 04:39:05 +0000 Subject: [PATCH 35/41] And that's dev9, which was about as barebones as CDVDnull. git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1111 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/CDVDnull/configure.ac | 4 +- plugins/dev9null/DEV9.cpp | 160 ++++++++++++++++++ plugins/dev9null/DEV9.h | 39 +++++ plugins/dev9null/Linux/Config.cpp | 79 +++++++++ plugins/dev9null/Makefile.am | 27 +++ .../{src => Windows}/DEV9null_vc2008.vcproj | 0 .../{src => Windows}/ProjectRootDir.vsprops | 0 .../dev9null/{src => Windows}/dev9null.def | 0 plugins/dev9null/build.sh | 33 +++- plugins/dev9null/configure.ac | 80 +++++++++ plugins/dev9null/install-sh | 1 + plugins/dev9null/missing | 1 + plugins/dev9null/src/DEV9.h | 17 -- plugins/dev9null/src/Makefile | 23 --- plugins/dev9null/src/dev9null.c | 152 ----------------- 15 files changed, 415 insertions(+), 201 deletions(-) create mode 100644 plugins/dev9null/DEV9.cpp create mode 100644 plugins/dev9null/DEV9.h create mode 100644 plugins/dev9null/Linux/Config.cpp create mode 100644 plugins/dev9null/Makefile.am rename plugins/dev9null/{src => Windows}/DEV9null_vc2008.vcproj (100%) rename plugins/dev9null/{src => Windows}/ProjectRootDir.vsprops (100%) rename plugins/dev9null/{src => Windows}/dev9null.def (100%) create mode 100644 plugins/dev9null/configure.ac create mode 120000 plugins/dev9null/install-sh create mode 120000 plugins/dev9null/missing delete mode 100644 plugins/dev9null/src/DEV9.h delete mode 100644 plugins/dev9null/src/Makefile delete mode 100644 plugins/dev9null/src/dev9null.c diff --git a/plugins/CDVDnull/configure.ac b/plugins/CDVDnull/configure.ac index 3953dd00f6..0ef1c2ae4c 100644 --- a/plugins/CDVDnull/configure.ac +++ b/plugins/CDVDnull/configure.ac @@ -1,6 +1,6 @@ -AC_INIT(CDVDnull, 0.5,arcum42@gmail.com) +AC_INIT(CDVDnull, 0.6,arcum42@gmail.com) -AM_INIT_AUTOMAKE(CDVDnull,0.7) +AM_INIT_AUTOMAKE(CDVDnull,0.6) AC_PROG_CC([gcc g++ cl KCC CC cxx cc++ xlC aCC c++]) AC_PROG_CXX([gcc g++ cl KCC CC cxx cc++ xlC aCC c++]) diff --git a/plugins/dev9null/DEV9.cpp b/plugins/dev9null/DEV9.cpp new file mode 100644 index 0000000000..0120d77f9d --- /dev/null +++ b/plugins/dev9null/DEV9.cpp @@ -0,0 +1,160 @@ +/* DEV9null + * Copyright (C) 2002-2009 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include +#include +#include +#include +#include "PS2Etypes.h" +#include "DEV9.h" + +const unsigned char version = PS2E_DEV9_VERSION; +const unsigned char revision = 0; +const unsigned char build = 4; // increase that with each version + +const char *libraryName = "DEV9null Driver"; + +void (*DEV9irq)(); +FILE *dev9Log; + +EXPORT_C_(u32) PS2EgetLibType() +{ + return PS2E_LT_DEV9; +} + +EXPORT_C_(char*) PS2EgetLibName() +{ + return (char *)libraryName; +} + +EXPORT_C_(u32) PS2EgetLibVersion2(u32 type) +{ + return (version<<16) | (revision<<8) | build; +} + +void __Log(char *fmt, ...) +{ + va_list list; + + va_start(list, fmt); + vfprintf(dev9Log, fmt, list); + va_end(list); +} + +EXPORT_C_(s32) DEV9init() +{ + return 0; +} + +EXPORT_C_(void) DEV9shutdown() +{ +} + +EXPORT_C_(s32) DEV9open(void *pDsp) +{ + return 0; +} + +EXPORT_C_(void) DEV9close() +{ + +} + +EXPORT_C_(u8) DEV9read8(u32 addr) +{ + return 0; +} + +EXPORT_C_(u16 ) DEV9read16(u32 addr) +{ + return 0; +} + +EXPORT_C_(u32 ) DEV9read32(u32 addr) +{ + return 0; +} + +EXPORT_C_(void) DEV9write8(u32 addr, u8 value) +{ +} + +EXPORT_C_(void) DEV9write16(u32 addr, u16 value) +{ +} + +EXPORT_C_(void) DEV9write32(u32 addr, u32 value) +{ +} + +EXPORT_C_(void) DEV9readDMA8Mem(u32 *pMem, int size) +{ +} + +EXPORT_C_(void) DEV9writeDMA8Mem(u32* pMem, int size) +{ +} + +EXPORT_C_(void) DEV9irqCallback(DEV9callback callback) +{ + +} + +EXPORT_C_(DEV9handler) DEV9irqHandler(void) +{ + return NULL; +} + +// extended funcs + +EXPORT_C_(s32) DEV9test() +{ + return 0; +} + +EXPORT_C_(void) DEV9configure() +{ + SysMessage("Nothing to Configure"); +} + +EXPORT_C_(void) DEV9about() +{ +} + +#ifdef _WIN32 + +HINSTANCE hInst; + +void SysMessage(char *fmt, ...) +{ + va_list list; + char tmp[512]; + va_start(list,fmt); + vsprintf(tmp,fmt,list); + va_end(list); + MessageBox(0, tmp, "DEV9null Msg", 0); +} + +BOOL APIENTRY DllMain(HANDLE hModule, // DLL INIT + DWORD dwReason, + LPVOID lpReserved) { + hInst = (HINSTANCE)hModule; + return TRUE; // very quick :) +} + +#endif diff --git a/plugins/dev9null/DEV9.h b/plugins/dev9null/DEV9.h new file mode 100644 index 0000000000..a46501a56e --- /dev/null +++ b/plugins/dev9null/DEV9.h @@ -0,0 +1,39 @@ +#ifndef __DEV9_H__ +#define __DEV9_H__ + +#include + +#ifdef __LINUX__ +#include +#else +#include +#include +#include +#endif + +extern "C" +{ +#define DEV9defs +#include "PS2Edefs.h" +} + +#ifdef _MSC_VER +#define EXPORT_C_(type) extern "C" __declspec(dllexport) type CALLBACK +#else +#define EXPORT_C_(type) extern "C" type +#endif + +extern const unsigned char version; +extern const unsigned char revision; +extern const unsigned char build; +extern const unsigned int minor; +extern const char *libraryName; + +extern void (*DEV9irq)(); +extern void SysMessage(const char *fmt, ...); + +extern FILE *dev9Log; +void __Log(char *fmt, ...); + + +#endif diff --git a/plugins/dev9null/Linux/Config.cpp b/plugins/dev9null/Linux/Config.cpp new file mode 100644 index 0000000000..89b686d779 --- /dev/null +++ b/plugins/dev9null/Linux/Config.cpp @@ -0,0 +1,79 @@ +/* DEV9null + * Copyright (C) 2002-2009 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "DEV9.h" + + +#include +#include +#include +#include + +GtkWidget *MsgDlg; + +void OnMsg_Ok() +{ + gtk_widget_destroy(MsgDlg); + gtk_main_quit(); +} + +void SysMessage(const char *fmt, ...) +{ + GtkWidget *Ok, *Txt; + GtkWidget *Box, *Box1; + va_list list; + char msg[512]; + + va_start(list, fmt); + vsprintf(msg, fmt, list); + va_end(list); + + if (msg[strlen(msg)-1] == '\n') msg[strlen(msg)-1] = 0; + + MsgDlg = gtk_window_new(GTK_WINDOW_POPUP); + gtk_window_set_position(GTK_WINDOW(MsgDlg), GTK_WIN_POS_CENTER); + gtk_window_set_title(GTK_WINDOW(MsgDlg), "SPU2null Msg"); + gtk_container_set_border_width(GTK_CONTAINER(MsgDlg), 5); + + Box = gtk_vbox_new(5, 0); + gtk_container_add(GTK_CONTAINER(MsgDlg), Box); + gtk_widget_show(Box); + + Txt = gtk_label_new(msg); + + gtk_box_pack_start(GTK_BOX(Box), Txt, FALSE, FALSE, 5); + gtk_widget_show(Txt); + + Box1 = gtk_hbutton_box_new(); + gtk_box_pack_start(GTK_BOX(Box), Box1, FALSE, FALSE, 0); + gtk_widget_show(Box1); + + Ok = gtk_button_new_with_label("Ok"); + gtk_signal_connect(GTK_OBJECT(Ok), "clicked", GTK_SIGNAL_FUNC(OnMsg_Ok), NULL); + gtk_container_add(GTK_CONTAINER(Box1), Ok); + GTK_WIDGET_SET_FLAGS(Ok, GTK_CAN_DEFAULT); + gtk_widget_show(Ok); + + gtk_widget_show(MsgDlg); + + gtk_main(); +} + +void LoadConfig() +{ +} diff --git a/plugins/dev9null/Makefile.am b/plugins/dev9null/Makefile.am new file mode 100644 index 0000000000..708b882df6 --- /dev/null +++ b/plugins/dev9null/Makefile.am @@ -0,0 +1,27 @@ +# Create a shared library libDEV9null +AUTOMAKE_OPTIONS = foreign +noinst_LIBRARIES = libDEV9null.a +INCLUDES = -I@srcdir@/../../common/include -I@srcdir@/../../3rdparty -I@srcdir@/Linux + +libDEV9null_a_CXXFLAGS = $(shell pkg-config --cflags gtk+-2.0) +libDEV9null_a_CFLAGS = $(shell pkg-config --cflags gtk+-2.0) + +# Create a shared object by faking an exe (thanks to ODE makefiles) +traplibdir=$(prefix) + +if DEBUGBUILD +preext=d +endif + +EXEEXT=$(preext)@so_ext@ + +traplib_PROGRAMS=libDEV9null +libDEV9null_SOURCES= +libDEV9null_DEPENDENCIES = libDEV9null.a +libDEV9null_LDFLAGS= @SHARED_LDFLAGS@ +libDEV9null_LDFLAGS+=-Wl,-soname,@libDEV9null_SONAME@ +libDEV9null_LDADD=$(libDEV9null_a_OBJECTS) + +libDEV9null_a_SOURCES = DEV9.cpp DEV9.h Linux/Config.cpp + +#SUBDIRS = Linux \ No newline at end of file diff --git a/plugins/dev9null/src/DEV9null_vc2008.vcproj b/plugins/dev9null/Windows/DEV9null_vc2008.vcproj similarity index 100% rename from plugins/dev9null/src/DEV9null_vc2008.vcproj rename to plugins/dev9null/Windows/DEV9null_vc2008.vcproj diff --git a/plugins/dev9null/src/ProjectRootDir.vsprops b/plugins/dev9null/Windows/ProjectRootDir.vsprops similarity index 100% rename from plugins/dev9null/src/ProjectRootDir.vsprops rename to plugins/dev9null/Windows/ProjectRootDir.vsprops diff --git a/plugins/dev9null/src/dev9null.def b/plugins/dev9null/Windows/dev9null.def similarity index 100% rename from plugins/dev9null/src/dev9null.def rename to plugins/dev9null/Windows/dev9null.def diff --git a/plugins/dev9null/build.sh b/plugins/dev9null/build.sh index 321284aa69..231a06d3c9 100644 --- a/plugins/dev9null/build.sh +++ b/plugins/dev9null/build.sh @@ -1,13 +1,32 @@ #!/bin/sh -echo ----------------- -echo Building dev9null -echo ----------------- +echo --------------- +echo Building DEV9null +echo --------------- curdir=`pwd` -cd ${curdir}/src -make clean -make $@ -cp libDEV9null.so ${PCSX2PLUGINS} +if test "${DEV9nullOPTIONS+set}" != set ; then +export DEV9nullOPTIONS="" +fi + +if [ $# -gt 0 ] && [ $1 = "all" ] +then + +aclocal +automake -a +autoconf + +./configure ${DEV9nullOPTIONS} --prefix=${PCSX2PLUGINS} +make clean +make install + +else +make $@ +fi + +if [ $? -ne 0 ] +then +exit 1 +fi diff --git a/plugins/dev9null/configure.ac b/plugins/dev9null/configure.ac new file mode 100644 index 0000000000..f2573aa6d2 --- /dev/null +++ b/plugins/dev9null/configure.ac @@ -0,0 +1,80 @@ +AC_INIT(DEV9null, 0.4,arcum42@gmail.com) + +AM_INIT_AUTOMAKE(DEV9null,0.4) + +AC_PROG_CC([gcc g++ cl KCC CC cxx cc++ xlC aCC c++]) +AC_PROG_CXX([gcc g++ cl KCC CC cxx cc++ xlC aCC c++]) +AC_PROG_CPP([gcc g++ cl KCC CC cxx cc++ xlC aCC c++]) + +AC_PROG_INSTALL +AC_PROG_RANLIB + +dnl necessary for compiling assembly +AM_PROG_AS + +AC_SUBST(DEV9null_CURRENT, 0) +AC_SUBST(DEV9null_REVISION, 8) +AC_SUBST(DEV9null_AGE, 0) +AC_SUBST(DEV9null_RELEASE,[$DEV9null_CURRENT].[$DEV9null_REVISION].[$DEV9null_AGE]) +AC_SUBST(DEV9null_SONAME,libDEV9null.so.[$DEV9null_CURRENT].[$DEV9null_REVISION].[$DEV9null_AGE]) + +CFLAGS= +CPPFLAGS= +CXXFLAGS= + +dnl Check for debug build +AC_MSG_CHECKING(debug build) +AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug], [debug build]), +debug=$enableval,debug=no) +if test "x$debug" == xyes +then + AC_DEFINE(_DEBUG,1,[_DEBUG]) + CFLAGS+="-g -fPIC -Wall -Wno-unused-value " + CPPFLAGS+="-g -fPIC -Wall -Wno-unused-value " + CXXFLAGS+="-g -fPIC -Wall -Wno-unused-value " +else + AC_DEFINE(NDEBUG,1,[NDEBUG]) + CFLAGS+="-O3 -fomit-frame-pointer -fPIC -Wall -Wno-unused-value " + CPPFLAGS+="-O3 -fomit-frame-pointer -fPIC -Wall -Wno-unused-value " + CXXFLAGS+="-O3 -fomit-frame-pointer -fPIC -Wall -Wno-unused-value " +fi +AM_CONDITIONAL(DEBUGBUILD, test x$debug = xyes) +AC_MSG_RESULT($debug) + +AC_DEFINE(__LINUX__,1,[__LINUX__]) + +dnl Check for dev build +AC_MSG_CHECKING(for development build...) +AC_ARG_ENABLE(devbuild, AC_HELP_STRING([--enable-devbuild], [Special Build for developers that simplifies testing and adds extra checks]), + devbuild=$enableval,devbuild=no) +if test "x$devbuild" == xyes +then + AC_DEFINE(DEV9null_DEVBUILD,1,[DEV9null_DEVBUILD]) +fi +AC_MSG_RESULT($devbuild) +AM_CONDITIONAL(RELEASE_TO_PUBLIC, test x$devbuild = xno) + +AC_CHECK_FUNCS([ _aligned_malloc _aligned_free ], AC_DEFINE(HAVE_ALIGNED_MALLOC)) + +dnl gtk +AC_MSG_CHECKING(gtk2+) +AC_CHECK_PROG(GTK_CONFIG, pkg-config, pkg-config) +LIBS+=$(pkg-config --libs gtk+-2.0) + +dnl bindir = pcsx2exe + +dnl assuming linux environment +so_ext=".so.$DEV9null_RELEASE" +SHARED_LDFLAGS="-shared" +AC_SUBST(so_ext) +AC_SUBST(SHARED_LDFLAGS) + +AC_CHECK_LIB(stdc++,main,[LIBS="$LIBS -lstdc++"]) + +AC_OUTPUT([ + Makefile + ]) + +echo "Configuration:" +echo " Debug build? $debug" +echo " Dev build? $devbuild" \ No newline at end of file diff --git a/plugins/dev9null/install-sh b/plugins/dev9null/install-sh new file mode 120000 index 0000000000..8272958b56 --- /dev/null +++ b/plugins/dev9null/install-sh @@ -0,0 +1 @@ +/usr/share/automake-1.10/install-sh \ No newline at end of file diff --git a/plugins/dev9null/missing b/plugins/dev9null/missing new file mode 120000 index 0000000000..1f0fe88e65 --- /dev/null +++ b/plugins/dev9null/missing @@ -0,0 +1 @@ +/usr/share/automake-1.10/missing \ No newline at end of file diff --git a/plugins/dev9null/src/DEV9.h b/plugins/dev9null/src/DEV9.h deleted file mode 100644 index a3b475d6c6..0000000000 --- a/plugins/dev9null/src/DEV9.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef __DEV9_H__ -#define __DEV9_H__ - -#include - -#define DEV9defs - -#include "PS2Edefs.h" - - -FILE *dev9Log; -void __Log(char *fmt, ...); -void (*DEV9irq)(); -void SysMessage(char *fmt, ...); - - -#endif diff --git a/plugins/dev9null/src/Makefile b/plugins/dev9null/src/Makefile deleted file mode 100644 index d0fa8ea301..0000000000 --- a/plugins/dev9null/src/Makefile +++ /dev/null @@ -1,23 +0,0 @@ - -CC = gcc - -PLUGIN = libDEV9null.so -CFLAGS+= -fPIC -Wall -O2 -fomit-frame-pointer -D__LINUX__ -I../../../common/include -OBJS = dev9null.o -DEPS:= $(OBJS:.o=.d) - -all: plugin -install: all - -plugin: ${OBJS} - rm -f ${PLUGIN} - gcc -shared -Wl,-soname,${PLUGIN} ${CFLAGS} ${OBJS} -o ${PLUGIN} ${LIBS} - strip --strip-unneeded --strip-debug ${PLUGIN} - -clean: - rm -f ${OBJS} ${DEPS} - -%.o: %.c - ${CC} ${CFLAGS} -c -o $@ $< -MD -MF $(patsubst %.o,%.d,$@) - --include ${DEPS} diff --git a/plugins/dev9null/src/dev9null.c b/plugins/dev9null/src/dev9null.c deleted file mode 100644 index 85b1d998be..0000000000 --- a/plugins/dev9null/src/dev9null.c +++ /dev/null @@ -1,152 +0,0 @@ - - -#ifdef _WIN32 - -#include -#include -#include - -#endif - -#include -#include -#include -#include -#include "PS2Etypes.h" -#include "DEV9.h" - -#ifdef _WIN32 - -HINSTANCE hInst; - -void SysMessage(char *fmt, ...) { - va_list list; - char tmp[512]; - va_start(list,fmt); - vsprintf(tmp,fmt,list); - va_end(list); - MessageBox(0, tmp, "DEV9null Msg", 0); -} - -#else - -#include - -void SysMessage(char *fmt, ...) { -} - -#endif - -const unsigned char version = PS2E_DEV9_VERSION; -const unsigned char revision = 0; -const unsigned char build = 3; // increase that with each version - -static char *libraryName = "DEV9null Driver"; - -u32 CALLBACK PS2EgetLibType() { - return PS2E_LT_DEV9; -} - -char* CALLBACK PS2EgetLibName() { - return libraryName; -} - -u32 CALLBACK PS2EgetLibVersion2(u32 type) { - return (version<<16) | (revision<<8) | build; -} - -void __Log(char *fmt, ...) { - va_list list; - -// if (!Log) return; - - va_start(list, fmt); - vfprintf(dev9Log, fmt, list); - va_end(list); -} - -s32 CALLBACK DEV9init() { - - return 0; -} - -void CALLBACK DEV9shutdown() { -} - -s32 CALLBACK DEV9open(void *pDsp) { - -#ifdef _WIN32 -#else - Display* dsp = *(Display**)pDsp; -#endif - return 0; -} - -void CALLBACK DEV9close() { - -} - - -u8 CALLBACK DEV9read8(u32 addr) { - return 0; -} - -u16 CALLBACK DEV9read16(u32 addr) { - return 0; -} - -u32 CALLBACK DEV9read32(u32 addr) { - return 0; -} - -void CALLBACK DEV9write8(u32 addr, u8 value) { -} - -void CALLBACK DEV9write16(u32 addr, u16 value) { - -} - -void CALLBACK DEV9write32(u32 addr, u32 value) { - -} - -void CALLBACK DEV9readDMA8Mem(u32 *pMem, int size) { - -} - -void CALLBACK DEV9writeDMA8Mem(u32* pMem, int size) { - -} - - -void CALLBACK DEV9irqCallback(DEV9callback callback) { - -} - -DEV9handler CALLBACK DEV9irqHandler(void) { - return NULL; -} - - -// extended funcs - -s32 CALLBACK DEV9test() { - return 0; -} - -void CALLBACK DEV9configure() -{ - SysMessage("Nothing to Configure"); -} -void CALLBACK DEV9about(){} - -#ifdef _WIN32 - -BOOL APIENTRY DllMain(HANDLE hModule, // DLL INIT - DWORD dwReason, - LPVOID lpReserved) { - hInst = (HINSTANCE)hModule; - return TRUE; // very quick :) -} - -#endif From df31bfc51a492e263f4e2aec18e1fa0f4ba1ef85 Mon Sep 17 00:00:00 2001 From: arcum42 Date: Sat, 2 May 2009 05:27:35 +0000 Subject: [PATCH 36/41] Lets get the null plugins working in Windows again... git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1112 96395faa-99c1-11dd-bbfe-3dabce05a288 --- pcsx2_suite_2008.sln | 4 +- plugins/CDVDnull/CDVD.h | 8 +- plugins/FWnull/FW.h | 12 +- .../FWnull/Windows/{Config.c => Config.cpp} | 102 +++++------ plugins/FWnull/Windows/FWnull_vc2008.vcproj | 4 +- plugins/FWnull/Windows/{Win32.c => Win32.cpp} | 162 +++++++++--------- plugins/USBnull/USB.h | 7 +- .../USBnull/Windows/{Config.c => Config.cpp} | 102 +++++------ plugins/USBnull/Windows/USBnull_vc2008.vcproj | 4 +- .../USBnull/Windows/{Win32.c => Win32.cpp} | 162 +++++++++--------- plugins/dev9null/DEV9.cpp | 2 +- plugins/dev9null/DEV9.h | 8 +- .../dev9null/Windows/DEV9null_vc2008.vcproj | 10 +- 13 files changed, 307 insertions(+), 280 deletions(-) rename plugins/FWnull/Windows/{Config.c => Config.cpp} (95%) rename plugins/FWnull/Windows/{Win32.c => Win32.cpp} (95%) rename plugins/USBnull/Windows/{Config.c => Config.cpp} (95%) rename plugins/USBnull/Windows/{Win32.c => Win32.cpp} (95%) diff --git a/pcsx2_suite_2008.sln b/pcsx2_suite_2008.sln index 53e8e2c588..fbaf270f39 100644 --- a/pcsx2_suite_2008.sln +++ b/pcsx2_suite_2008.sln @@ -45,13 +45,13 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "xpad", "plugins\xpad\xpad_v EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CDVDolio", "plugins\CDVDolio\cdvd_vs2008.vcproj", "{FCDF5AE2-EA47-4CC6-9F20-23A0517FEBCB}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CDVDnull", "plugins\CDVDnull\Src\CDVDnull_vs2008.vcproj", "{F38D9DF0-F68D-49D9-B3A0-932E74FB74A0}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CDVDnull", "plugins\CDVDnull\Windows\CDVDnull_vs2008.vcproj", "{F38D9DF0-F68D-49D9-B3A0-932E74FB74A0}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "USBnull", "plugins\USBnull\Windows\USBnull_vc2008.vcproj", "{BF7B81A5-E348-4F7C-A69F-F74C8EEEAD70}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FWnull", "plugins\FWnull\Windows\FWnull_vc2008.vcproj", "{3D0EB14D-32F3-4D82-9C6D-B806ADBB859C}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DEV9null", "plugins\dev9null\src\DEV9null_vc2008.vcproj", "{04439C5F-05FB-4A9C-AAD1-5388C25377DB}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DEV9null", "plugins\dev9null\Windows\DEV9null_vc2008.vcproj", "{04439C5F-05FB-4A9C-AAD1-5388C25377DB}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Nulls", "Nulls", "{E1828E40-2FBB-48FE-AE7F-5587755DCE0E}" EndProject diff --git a/plugins/CDVDnull/CDVD.h b/plugins/CDVDnull/CDVD.h index 370e09bf26..05858f3c41 100644 --- a/plugins/CDVDnull/CDVD.h +++ b/plugins/CDVDnull/CDVD.h @@ -36,10 +36,16 @@ extern "C" #include #endif -#ifdef _MSC_VER +/*#ifdef _MSC_VER #define EXPORT_C_(type) extern "C" __declspec(dllexport) type CALLBACK #else #define EXPORT_C_(type) extern "C" type +#endif*/ + +#ifdef _MSC_VER +#define EXPORT_C_(type) extern "C" type CALLBACK +#else +#define EXPORT_C_(type) extern "C" type #endif extern const unsigned char version; diff --git a/plugins/FWnull/FW.h b/plugins/FWnull/FW.h index d9008a3df7..da97459e62 100644 --- a/plugins/FWnull/FW.h +++ b/plugins/FWnull/FW.h @@ -21,11 +21,15 @@ #include +#ifdef __cplusplus extern "C" { +#endif #define FWdefs #include "PS2Edefs.h" +#ifdef __cplusplus } +#endif #ifdef _WIN32 @@ -39,10 +43,16 @@ extern "C" #endif -#ifdef _MSC_VER +/*#ifdef _MSC_VER #define EXPORT_C_(type) extern "C" __declspec(dllexport) type CALLBACK #else #define EXPORT_C_(type) extern "C" type +#endif*/ + +#ifdef _MSC_VER +#define EXPORT_C_(type) extern "C" type CALLBACK +#else +#define EXPORT_C_(type) extern "C" type #endif #define FW_LOG __Log diff --git a/plugins/FWnull/Windows/Config.c b/plugins/FWnull/Windows/Config.cpp similarity index 95% rename from plugins/FWnull/Windows/Config.c rename to plugins/FWnull/Windows/Config.cpp index aee13009b9..62db91dd61 100644 --- a/plugins/FWnull/Windows/Config.c +++ b/plugins/FWnull/Windows/Config.cpp @@ -1,51 +1,51 @@ -#include - -#include "../FW.h" - -extern HINSTANCE hInst; -void SaveConfig() -{ - - Config *Conf1 = &conf; - char *szTemp; - char szIniFile[256], szValue[256]; - - GetModuleFileName(GetModuleHandle((LPCSTR)hInst), szIniFile, 256); - szTemp = strrchr(szIniFile, '\\'); - - if(!szTemp) return; - strcpy(szTemp, "\\inis\\fwnull.ini"); - sprintf(szValue,"%u",Conf1->Log); - WritePrivateProfileString("Interface", "Logging",szValue,szIniFile); - -} - -void LoadConfig() { - FILE *fp; - - - Config *Conf1 = &conf; - char *szTemp; - char szIniFile[256], szValue[256]; - - GetModuleFileName(GetModuleHandle((LPCSTR)hInst), szIniFile, 256); - szTemp = strrchr(szIniFile, '\\'); - - if(!szTemp) return ; - strcpy(szTemp, "\\inis\\fwnull.ini"); - fp=fopen("inis\\fwnull.ini","rt");//check if firewirenull.ini really exists - if (!fp) - { - CreateDirectory("inis",NULL); - memset(&conf, 0, sizeof(conf)); - conf.Log = 0;//default value - SaveConfig();//save and return - return ; - } - fclose(fp); - GetPrivateProfileString("Interface", "Logging", NULL, szValue, 20, szIniFile); - Conf1->Log = strtoul(szValue, NULL, 10); - return ; - -} - +#include + +#include "../FW.h" + +extern HINSTANCE hInst; +void SaveConfig() +{ + + Config *Conf1 = &conf; + char *szTemp; + char szIniFile[256], szValue[256]; + + GetModuleFileName(GetModuleHandle((LPCSTR)hInst), szIniFile, 256); + szTemp = strrchr(szIniFile, '\\'); + + if(!szTemp) return; + strcpy(szTemp, "\\inis\\fwnull.ini"); + sprintf(szValue,"%u",Conf1->Log); + WritePrivateProfileString("Interface", "Logging",szValue,szIniFile); + +} + +void LoadConfig() { + FILE *fp; + + + Config *Conf1 = &conf; + char *szTemp; + char szIniFile[256], szValue[256]; + + GetModuleFileName(GetModuleHandle((LPCSTR)hInst), szIniFile, 256); + szTemp = strrchr(szIniFile, '\\'); + + if(!szTemp) return ; + strcpy(szTemp, "\\inis\\fwnull.ini"); + fp=fopen("inis\\fwnull.ini","rt");//check if firewirenull.ini really exists + if (!fp) + { + CreateDirectory("inis",NULL); + memset(&conf, 0, sizeof(conf)); + conf.Log = 0;//default value + SaveConfig();//save and return + return ; + } + fclose(fp); + GetPrivateProfileString("Interface", "Logging", NULL, szValue, 20, szIniFile); + Conf1->Log = strtoul(szValue, NULL, 10); + return ; + +} + diff --git a/plugins/FWnull/Windows/FWnull_vc2008.vcproj b/plugins/FWnull/Windows/FWnull_vc2008.vcproj index d4d68494b8..7ca94e36c7 100644 --- a/plugins/FWnull/Windows/FWnull_vc2008.vcproj +++ b/plugins/FWnull/Windows/FWnull_vc2008.vcproj @@ -157,7 +157,7 @@ Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm" > diff --git a/plugins/FWnull/Windows/Win32.c b/plugins/FWnull/Windows/Win32.cpp similarity index 95% rename from plugins/FWnull/Windows/Win32.c rename to plugins/FWnull/Windows/Win32.cpp index a4ba6cb54b..c09edf89f0 100644 --- a/plugins/FWnull/Windows/Win32.c +++ b/plugins/FWnull/Windows/Win32.cpp @@ -1,81 +1,81 @@ -#include -#include -#include - - -#include "resource.h" -#include "../FW.h" - -HINSTANCE hInst; - -void SysMessage(char *fmt, ...) { - va_list list; - char tmp[512]; - - va_start(list,fmt); - vsprintf(tmp,fmt,list); - va_end(list); - MessageBox(0, tmp, "FW Plugin Msg", 0); -} - -BOOL CALLBACK ConfigureDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam) { - - switch(uMsg) { - case WM_INITDIALOG: - LoadConfig(); - if (conf.Log) CheckDlgButton(hW, IDC_LOGGING, TRUE); - return TRUE; - - case WM_COMMAND: - switch(LOWORD(wParam)) { - case IDCANCEL: - EndDialog(hW, TRUE); - return TRUE; - case IDOK: - if (IsDlgButtonChecked(hW, IDC_LOGGING)) - conf.Log = 1; - else conf.Log = 0; - SaveConfig(); - EndDialog(hW, FALSE); - return TRUE; - } - } - return FALSE; -} - -BOOL CALLBACK AboutDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam) { - switch(uMsg) { - case WM_INITDIALOG: - return TRUE; - - case WM_COMMAND: - switch(LOWORD(wParam)) { - case IDOK: - EndDialog(hW, FALSE); - return TRUE; - } - } - return FALSE; -} - -void CALLBACK FWconfigure() { - DialogBox(hInst, - MAKEINTRESOURCE(IDD_CONFIG), - GetActiveWindow(), - (DLGPROC)ConfigureDlgProc); -} - -void CALLBACK FWabout() { - DialogBox(hInst, - MAKEINTRESOURCE(IDD_ABOUT), - GetActiveWindow(), - (DLGPROC)AboutDlgProc); -} - -BOOL APIENTRY DllMain(HANDLE hModule, // DLL INIT - DWORD dwReason, - LPVOID lpReserved) { - hInst = (HINSTANCE)hModule; - return TRUE; // very quick :) -} - +#include +#include +#include + + +#include "resource.h" +#include "../FW.h" + +HINSTANCE hInst; + +void SysMessage(char *fmt, ...) { + va_list list; + char tmp[512]; + + va_start(list,fmt); + vsprintf(tmp,fmt,list); + va_end(list); + MessageBox(0, tmp, "FW Plugin Msg", 0); +} + +BOOL CALLBACK ConfigureDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam) { + + switch(uMsg) { + case WM_INITDIALOG: + LoadConfig(); + if (conf.Log) CheckDlgButton(hW, IDC_LOGGING, TRUE); + return TRUE; + + case WM_COMMAND: + switch(LOWORD(wParam)) { + case IDCANCEL: + EndDialog(hW, TRUE); + return TRUE; + case IDOK: + if (IsDlgButtonChecked(hW, IDC_LOGGING)) + conf.Log = 1; + else conf.Log = 0; + SaveConfig(); + EndDialog(hW, FALSE); + return TRUE; + } + } + return FALSE; +} + +BOOL CALLBACK AboutDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam) { + switch(uMsg) { + case WM_INITDIALOG: + return TRUE; + + case WM_COMMAND: + switch(LOWORD(wParam)) { + case IDOK: + EndDialog(hW, FALSE); + return TRUE; + } + } + return FALSE; +} + +void CALLBACK FWconfigure() { + DialogBox(hInst, + MAKEINTRESOURCE(IDD_CONFIG), + GetActiveWindow(), + (DLGPROC)ConfigureDlgProc); +} + +void CALLBACK FWabout() { + DialogBox(hInst, + MAKEINTRESOURCE(IDD_ABOUT), + GetActiveWindow(), + (DLGPROC)AboutDlgProc); +} + +BOOL APIENTRY DllMain(HANDLE hModule, // DLL INIT + DWORD dwReason, + LPVOID lpReserved) { + hInst = (HINSTANCE)hModule; + return TRUE; // very quick :) +} + diff --git a/plugins/USBnull/USB.h b/plugins/USBnull/USB.h index 75c833e046..b10424e5d1 100644 --- a/plugins/USBnull/USB.h +++ b/plugins/USBnull/USB.h @@ -54,9 +54,14 @@ extern USBcallback USBirq; extern Config conf; extern FILE *usbLog; +/*#ifdef _MSC_VER +#define EXPORT_C_(type) extern "C" __declspec(dllexport) type CALLBACK +#else +#define EXPORT_C_(type) extern "C" type +#endif*/ #ifdef _MSC_VER -#define EXPORT_C_(type) extern "C" __declspec(dllexport) type CALLBACK +#define EXPORT_C_(type) extern "C" type CALLBACK #else #define EXPORT_C_(type) extern "C" type #endif diff --git a/plugins/USBnull/Windows/Config.c b/plugins/USBnull/Windows/Config.cpp similarity index 95% rename from plugins/USBnull/Windows/Config.c rename to plugins/USBnull/Windows/Config.cpp index 5e31d6dcb5..aff2667582 100644 --- a/plugins/USBnull/Windows/Config.c +++ b/plugins/USBnull/Windows/Config.cpp @@ -1,51 +1,51 @@ -#include - -#include "../USB.h" - -extern HINSTANCE hInst; -void SaveConfig() -{ - - Config *Conf1 = &conf; - char *szTemp; - char szIniFile[256], szValue[256]; - - GetModuleFileName(GetModuleHandle((LPCSTR)hInst), szIniFile, 256); - szTemp = strrchr(szIniFile, '\\'); - - if(!szTemp) return; - strcpy(szTemp, "\\inis\\usbnull.ini"); - sprintf(szValue,"%u",Conf1->Log); - WritePrivateProfileString("Interface", "Logging",szValue,szIniFile); - -} - -void LoadConfig() { - FILE *fp; - - - Config *Conf1 = &conf; - char *szTemp; - char szIniFile[256], szValue[256]; - - GetModuleFileName(GetModuleHandle((LPCSTR)hInst), szIniFile, 256); - szTemp = strrchr(szIniFile, '\\'); - - if(!szTemp) return ; - strcpy(szTemp, "\\inis\\usbnull.ini"); - fp=fopen("inis\\usbnull.ini","rt");//check if usbnull.ini really exists - if (!fp) - { - CreateDirectory("inis",NULL); - memset(&conf, 0, sizeof(conf)); - conf.Log = 0;//default value - SaveConfig();//save and return - return ; - } - fclose(fp); - GetPrivateProfileString("Interface", "Logging", NULL, szValue, 20, szIniFile); - Conf1->Log = strtoul(szValue, NULL, 10); - return ; - -} - +#include + +#include "../USB.h" + +extern HINSTANCE hInst; +void SaveConfig() +{ + + Config *Conf1 = &conf; + char *szTemp; + char szIniFile[256], szValue[256]; + + GetModuleFileName(GetModuleHandle((LPCSTR)hInst), szIniFile, 256); + szTemp = strrchr(szIniFile, '\\'); + + if(!szTemp) return; + strcpy(szTemp, "\\inis\\usbnull.ini"); + sprintf(szValue,"%u",Conf1->Log); + WritePrivateProfileString("Interface", "Logging",szValue,szIniFile); + +} + +void LoadConfig() { + FILE *fp; + + + Config *Conf1 = &conf; + char *szTemp; + char szIniFile[256], szValue[256]; + + GetModuleFileName(GetModuleHandle((LPCSTR)hInst), szIniFile, 256); + szTemp = strrchr(szIniFile, '\\'); + + if(!szTemp) return ; + strcpy(szTemp, "\\inis\\usbnull.ini"); + fp=fopen("inis\\usbnull.ini","rt");//check if usbnull.ini really exists + if (!fp) + { + CreateDirectory("inis",NULL); + memset(&conf, 0, sizeof(conf)); + conf.Log = 0;//default value + SaveConfig();//save and return + return ; + } + fclose(fp); + GetPrivateProfileString("Interface", "Logging", NULL, szValue, 20, szIniFile); + Conf1->Log = strtoul(szValue, NULL, 10); + return ; + +} + diff --git a/plugins/USBnull/Windows/USBnull_vc2008.vcproj b/plugins/USBnull/Windows/USBnull_vc2008.vcproj index 3092b94f31..6aa6dc011d 100644 --- a/plugins/USBnull/Windows/USBnull_vc2008.vcproj +++ b/plugins/USBnull/Windows/USBnull_vc2008.vcproj @@ -157,7 +157,7 @@ Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm" > diff --git a/plugins/USBnull/Windows/Win32.c b/plugins/USBnull/Windows/Win32.cpp similarity index 95% rename from plugins/USBnull/Windows/Win32.c rename to plugins/USBnull/Windows/Win32.cpp index b2cd1fac99..412b836d5b 100644 --- a/plugins/USBnull/Windows/Win32.c +++ b/plugins/USBnull/Windows/Win32.cpp @@ -1,81 +1,81 @@ -#include -#include -#include - -#include "../USB.h" -#include "resource.h" - -HINSTANCE hInst; - -void SysMessage(char *fmt, ...) { - va_list list; - char tmp[512]; - - va_start(list,fmt); - vsprintf(tmp,fmt,list); - va_end(list); - MessageBox(0, tmp, "USBnull Msg", 0); -} - -BOOL CALLBACK ConfigureDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam) { - - switch(uMsg) { - case WM_INITDIALOG: - LoadConfig(); - if (conf.Log) CheckDlgButton(hW, IDC_LOGGING, TRUE); - return TRUE; - - case WM_COMMAND: - switch(LOWORD(wParam)) { - case IDCANCEL: - EndDialog(hW, TRUE); - return TRUE; - case IDOK: - if (IsDlgButtonChecked(hW, IDC_LOGGING)) - conf.Log = 1; - else conf.Log = 0; - SaveConfig(); - EndDialog(hW, FALSE); - return TRUE; - } - } - return FALSE; -} - -BOOL CALLBACK AboutDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam) { - switch(uMsg) { - case WM_INITDIALOG: - return TRUE; - - case WM_COMMAND: - switch(LOWORD(wParam)) { - case IDOK: - EndDialog(hW, FALSE); - return TRUE; - } - } - return FALSE; -} - -void CALLBACK USBconfigure() { - DialogBox(hInst, - MAKEINTRESOURCE(IDD_CONFIG), - GetActiveWindow(), - (DLGPROC)ConfigureDlgProc); - -} - -void CALLBACK USBabout() { - DialogBox(hInst, - MAKEINTRESOURCE(IDD_ABOUT), - GetActiveWindow(), - (DLGPROC)AboutDlgProc); -} - -BOOL APIENTRY DllMain(HANDLE hModule, // DLL INIT - DWORD dwReason, - LPVOID lpReserved) { - hInst = (HINSTANCE)hModule; - return TRUE; // very quick :) -} - +#include +#include +#include + +#include "../USB.h" +#include "resource.h" + +HINSTANCE hInst; + +void SysMessage(char *fmt, ...) { + va_list list; + char tmp[512]; + + va_start(list,fmt); + vsprintf(tmp,fmt,list); + va_end(list); + MessageBox(0, tmp, "USBnull Msg", 0); +} + +BOOL CALLBACK ConfigureDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam) { + + switch(uMsg) { + case WM_INITDIALOG: + LoadConfig(); + if (conf.Log) CheckDlgButton(hW, IDC_LOGGING, TRUE); + return TRUE; + + case WM_COMMAND: + switch(LOWORD(wParam)) { + case IDCANCEL: + EndDialog(hW, TRUE); + return TRUE; + case IDOK: + if (IsDlgButtonChecked(hW, IDC_LOGGING)) + conf.Log = 1; + else conf.Log = 0; + SaveConfig(); + EndDialog(hW, FALSE); + return TRUE; + } + } + return FALSE; +} + +BOOL CALLBACK AboutDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam) { + switch(uMsg) { + case WM_INITDIALOG: + return TRUE; + + case WM_COMMAND: + switch(LOWORD(wParam)) { + case IDOK: + EndDialog(hW, FALSE); + return TRUE; + } + } + return FALSE; +} + +void CALLBACK USBconfigure() { + DialogBox(hInst, + MAKEINTRESOURCE(IDD_CONFIG), + GetActiveWindow(), + (DLGPROC)ConfigureDlgProc); + +} + +void CALLBACK USBabout() { + DialogBox(hInst, + MAKEINTRESOURCE(IDD_ABOUT), + GetActiveWindow(), + (DLGPROC)AboutDlgProc); +} + +BOOL APIENTRY DllMain(HANDLE hModule, // DLL INIT + DWORD dwReason, + LPVOID lpReserved) { + hInst = (HINSTANCE)hModule; + return TRUE; // very quick :) +} + diff --git a/plugins/dev9null/DEV9.cpp b/plugins/dev9null/DEV9.cpp index 0120d77f9d..7f050a4723 100644 --- a/plugins/dev9null/DEV9.cpp +++ b/plugins/dev9null/DEV9.cpp @@ -140,7 +140,7 @@ EXPORT_C_(void) DEV9about() HINSTANCE hInst; -void SysMessage(char *fmt, ...) +void SysMessage(const char *fmt, ...) { va_list list; char tmp[512]; diff --git a/plugins/dev9null/DEV9.h b/plugins/dev9null/DEV9.h index a46501a56e..a827a0e019 100644 --- a/plugins/dev9null/DEV9.h +++ b/plugins/dev9null/DEV9.h @@ -17,10 +17,16 @@ extern "C" #include "PS2Edefs.h" } -#ifdef _MSC_VER +/*#ifdef _MSC_VER #define EXPORT_C_(type) extern "C" __declspec(dllexport) type CALLBACK #else #define EXPORT_C_(type) extern "C" type +#endif*/ + +#ifdef _MSC_VER +#define EXPORT_C_(type) extern "C" type CALLBACK +#else +#define EXPORT_C_(type) extern "C" type #endif extern const unsigned char version; diff --git a/plugins/dev9null/Windows/DEV9null_vc2008.vcproj b/plugins/dev9null/Windows/DEV9null_vc2008.vcproj index 273188a5c2..84c15bd706 100644 --- a/plugins/dev9null/Windows/DEV9null_vc2008.vcproj +++ b/plugins/dev9null/Windows/DEV9null_vc2008.vcproj @@ -160,11 +160,7 @@ Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm" > - - + + From f8f4c7f136ccf26db87f4d89172faa29cb33d5f4 Mon Sep 17 00:00:00 2001 From: cottonvibes Date: Sat, 2 May 2009 06:13:43 +0000 Subject: [PATCH 37/41] microVU: fixed some bugs in stall calculations. git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1113 96395faa-99c1-11dd-bbfe-3dabce05a288 --- pcsx2/x86/microVU.cpp | 1 + pcsx2/x86/microVU.h | 2 +- pcsx2/x86/microVU_Compile.inl | 31 ++++++++++++++++++++----------- 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/pcsx2/x86/microVU.cpp b/pcsx2/x86/microVU.cpp index 670767ee78..72e8aa9cf1 100644 --- a/pcsx2/x86/microVU.cpp +++ b/pcsx2/x86/microVU.cpp @@ -82,6 +82,7 @@ microVUt(void) mVUreset() { mVU->prog.cleared = 1; mVU->prog.cur = -1; mVU->prog.total = -1; + memset(&mVU->prog.lpState, 0, sizeof(mVU->prog.lpState)); //mVU->prog.lpState = &mVU->prog.prog[15].allocInfo.block.pState; // Blank Pipeline State (ToDo: finish implementation) // Setup Dynarec Cache Limits for Each Program diff --git a/pcsx2/x86/microVU.h b/pcsx2/x86/microVU.h index e2152ed167..9dcbc0d1f5 100644 --- a/pcsx2/x86/microVU.h +++ b/pcsx2/x86/microVU.h @@ -41,7 +41,7 @@ public: microBlock* thisBlock = search(&pBlock->pState); if (!thisBlock) { listSize++; - listSize &= MaxBlocks; + if (listSize > MaxBlocks) { Console::Error("microVU Warning: Block List Overflow"); listSize &= MaxBlocks; } memcpy_fast(&blockList[listSize], pBlock, sizeof(microBlock)); thisBlock = &blockList[listSize]; } diff --git a/pcsx2/x86/microVU_Compile.inl b/pcsx2/x86/microVU_Compile.inl index 96187b529d..b0cddab4ca 100644 --- a/pcsx2/x86/microVU_Compile.inl +++ b/pcsx2/x86/microVU_Compile.inl @@ -50,6 +50,7 @@ #define startLoop() { mVUdebug1(); mVUstall = 0; memset(&mVUregsTemp, 0, sizeof(mVUregsTemp)); } #define calcCycles(reg, x) { reg = ((reg > x) ? (reg - x) : 0); } +#define tCycles(dest, src) { dest = aMax(dest, src); } #define incP() { mVU->p = (mVU->p+1) & 1; } #define incQ() { mVU->q = (mVU->q+1) & 1; } #define doUpperOp() { mVUopU(); mVUdivSet(); } @@ -212,18 +213,26 @@ microVUt(void) mVUsetCycles() { incCycles(mVUstall); if (mVUregsTemp.VFreg[0] == mVUregsTemp.VFreg[1] && mVUregsTemp.VFreg[0]) { // If upper Op && lower Op write to same VF reg mVUinfo |= (mVUregsTemp.r || mVUregsTemp.VI) ? _noWriteVF : _isNOP; // If lower Op doesn't modify anything else, then make it a NOP - mVUregsTemp.VF[1].x = aMax(mVUregsTemp.VF[0].x, mVUregsTemp.VF[1].x); // Use max cycles from each vector - mVUregsTemp.VF[1].y = aMax(mVUregsTemp.VF[0].y, mVUregsTemp.VF[1].y); - mVUregsTemp.VF[1].z = aMax(mVUregsTemp.VF[0].z, mVUregsTemp.VF[1].z); - mVUregsTemp.VF[1].w = aMax(mVUregsTemp.VF[0].w, mVUregsTemp.VF[1].w); + tCycles(mVUregsTemp.VF[1].x, mVUregsTemp.VF[0].x) // Use max cycles from each vector + tCycles(mVUregsTemp.VF[1].y, mVUregsTemp.VF[0].y) + tCycles(mVUregsTemp.VF[1].z, mVUregsTemp.VF[0].z) + tCycles(mVUregsTemp.VF[1].w, mVUregsTemp.VF[0].w) } - mVUregs.VF[mVUregsTemp.VFreg[0]].reg = mVUregsTemp.VF[0].reg; - mVUregs.VF[mVUregsTemp.VFreg[1]].reg = mVUregsTemp.VF[1].reg; - mVUregs.VI[mVUregsTemp.VIreg] = mVUregsTemp.VI; - mVUregs.q = mVUregsTemp.q; - mVUregs.p = mVUregsTemp.p; - mVUregs.r = mVUregsTemp.r; - mVUregs.xgkick = mVUregsTemp.xgkick; + tCycles(mVUregs.VF[mVUregsTemp.VFreg[0]].x, mVUregsTemp.VF[0].x); + tCycles(mVUregs.VF[mVUregsTemp.VFreg[0]].y, mVUregsTemp.VF[0].y); + tCycles(mVUregs.VF[mVUregsTemp.VFreg[0]].z, mVUregsTemp.VF[0].z); + tCycles(mVUregs.VF[mVUregsTemp.VFreg[0]].w, mVUregsTemp.VF[0].w); + + tCycles(mVUregs.VF[mVUregsTemp.VFreg[1]].x, mVUregsTemp.VF[1].x); + tCycles(mVUregs.VF[mVUregsTemp.VFreg[1]].y, mVUregsTemp.VF[1].y); + tCycles(mVUregs.VF[mVUregsTemp.VFreg[1]].z, mVUregsTemp.VF[1].z); + tCycles(mVUregs.VF[mVUregsTemp.VFreg[1]].w, mVUregsTemp.VF[1].w); + + tCycles(mVUregs.VI[mVUregsTemp.VIreg], mVUregsTemp.VI); + tCycles(mVUregs.q, mVUregsTemp.q); + tCycles(mVUregs.p, mVUregsTemp.p); + tCycles(mVUregs.r, mVUregsTemp.r); + tCycles(mVUregs.xgkick, mVUregsTemp.xgkick); } microVUt(void) mVUdivSet() { From a69cfcc464a8dc8e58fcd2cea163f3626bdbeefb Mon Sep 17 00:00:00 2001 From: "Jake.Stine" Date: Sat, 2 May 2009 09:04:47 +0000 Subject: [PATCH 38/41] Removed VU-Skip [helps simplify the frameskipper logic] -- Use the VU Cycle Stealer hack instead for better, faster, more stable speedups of the VU1 unit. git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1114 96395faa-99c1-11dd-bbfe-3dabce05a288 --- common/include/Pcsx2Config.h | 1 - pcsx2/Counters.cpp | 18 +--- pcsx2/GS.cpp | 41 ++-------- pcsx2/GS.h | 1 - pcsx2/Linux/CpuDlg.cpp | 3 - pcsx2/Misc.cpp | 22 +++-- pcsx2/System.cpp | 3 - pcsx2/VUmicro.h | 4 - pcsx2/VUmicroMem.cpp | 15 ---- pcsx2/VifDma.cpp | 7 -- pcsx2/windows/CpuDlg.cpp | 1 - pcsx2/windows/pcsx2.rc | 38 ++++----- pcsx2/x86/ix86-32/iR5900-32.cpp | 140 +++++++++++++++----------------- 13 files changed, 105 insertions(+), 189 deletions(-) diff --git a/common/include/Pcsx2Config.h b/common/include/Pcsx2Config.h index 8c248bd521..d26587a84b 100644 --- a/common/include/Pcsx2Config.h +++ b/common/include/Pcsx2Config.h @@ -54,7 +54,6 @@ extern SessionOverrideFlags g_Session; #define PCSX2_FRAMELIMIT_NORMAL 0x000 #define PCSX2_FRAMELIMIT_LIMIT 0x400 #define PCSX2_FRAMELIMIT_SKIP 0x800 -#define PCSX2_FRAMELIMIT_VUSKIP 0xc00 #define CHECK_FRAMELIMIT (Config.Options&PCSX2_FRAMELIMIT_MASK) diff --git a/pcsx2/Counters.cpp b/pcsx2/Counters.cpp index b9b9a7c9ed..89a5cf8bd6 100644 --- a/pcsx2/Counters.cpp +++ b/pcsx2/Counters.cpp @@ -32,7 +32,6 @@ using namespace Threading; extern u8 psxhblankgate; -u32 g_vu1SkipCount; // number of frames to disable/skip VU1 static const uint EECNT_FUTURE_TARGET = 0x10000000; @@ -50,8 +49,6 @@ SyncCounter vsyncCounter; u32 nextsCounter; // records the cpuRegs.cycle value of the last call to rcntUpdate() s32 nextCounter; // delta from nextsCounter, in cycles, until the next rcntUpdate() -// VUSkip Locals and Globals - void rcntReset(int index) { counters[index].count = 0; counters[index].sCycleT = cpuRegs.cycle; @@ -264,9 +261,6 @@ u32 UpdateVSyncRate() m_iStart = GetCPUTicks(); cpuRcntSet(); - // Initialize VU Skip Stuff... - g_vu1SkipCount = 0; - return (u32)m_iTicks; } @@ -363,17 +357,7 @@ static __forceinline void VSyncEnd(u32 sCycle) iFrame++; - if( g_vu1SkipCount > 0 ) - { - gsPostVsyncEnd( false ); - AtomicDecrement( g_vu1SkipCount ); - vu1MicroEnableSkip(); - } - else - { - gsPostVsyncEnd( true ); - vu1MicroDisableSkip(); - } + gsPostVsyncEnd( true ); hwIntcIrq(INTC_VBLANK_E); // HW Irq psxVBlankEnd(); // psxCounters vBlank End diff --git a/pcsx2/GS.cpp b/pcsx2/GS.cpp index 4ff204c57d..24b440538e 100644 --- a/pcsx2/GS.cpp +++ b/pcsx2/GS.cpp @@ -165,16 +165,10 @@ void gsSetVideoRegionType( u32 isPal ) // Make sure framelimiter options are in sync with the plugin's capabilities. void gsInit() { - switch(CHECK_FRAMELIMIT) + if( (CHECK_FRAMELIMIT == PCSX2_FRAMELIMIT_SKIP) && (GSsetFrameSkip == NULL) ) { - case PCSX2_FRAMELIMIT_SKIP: - case PCSX2_FRAMELIMIT_VUSKIP: - if( GSsetFrameSkip == NULL ) - { - Config.Options &= ~PCSX2_FRAMELIMIT_MASK; - Console::WriteLn("Notice: Disabling frameskip -- GS plugin does not support it."); - } - break; + Config.Options &= ~PCSX2_FRAMELIMIT_MASK; + Console::WriteLn("Notice: Disabling frameskip -- GS plugin does not support it."); } } @@ -619,8 +613,7 @@ __forceinline void gsFrameSkip( bool forceskip ) static u8 FramesToRender = 0; static u8 FramesToSkip = 0; - if( CHECK_FRAMELIMIT != PCSX2_FRAMELIMIT_SKIP && - CHECK_FRAMELIMIT != PCSX2_FRAMELIMIT_VUSKIP ) return; + if( CHECK_FRAMELIMIT != PCSX2_FRAMELIMIT_SKIP ) return; // FrameSkip and VU-Skip Magic! // Skips a sequence of consecutive frames after a sequence of rendered frames @@ -652,14 +645,6 @@ __forceinline void gsFrameSkip( bool forceskip ) return; } - // if we've already given the EE a skipcount assignment then don't do anything more. - // Otherwise we could start compounding the issue and skips would be too long. - if( g_vu1SkipCount > 0 ) - { - //Console::Status("- Already Assigned a Skipcount.. %d", params g_vu1SkipCount ); - return; - } - if( FramesToRender == 0 ) { // -- Standard operation section -- @@ -680,20 +665,9 @@ __forceinline void gsFrameSkip( bool forceskip ) if( (m_justSkipped && (sSlowDeltaTime > m_iSlowTicks)) || (sSlowDeltaTime > m_iSlowTicks*2) ) { - //Console::Status( "Frameskip Initiated! Lateness: %d", params (int)( (sSlowDeltaTime*100) / m_iSlowTicks ) ); - - if( CHECK_FRAMELIMIT == PCSX2_FRAMELIMIT_VUSKIP ) - { - // For best results we have to wait for the EE to - // tell us when to skip, so that VU skips are synched with GS skips. - AtomicExchangeAdd( g_vu1SkipCount, yesSkipFrames+1 ); - } - else - { - GSsetFrameSkip(1); - FramesToRender = noSkipFrames+1; - FramesToSkip = yesSkipFrames; - } + GSsetFrameSkip(1); + FramesToRender = noSkipFrames+1; + FramesToSkip = yesSkipFrames; } } else @@ -771,7 +745,6 @@ void gsPostVsyncEnd( bool updategs ) void _gs_ResetFrameskip() { - g_vu1SkipCount = 0; // set to 0 so that EE will re-enable the VU at the next vblank. GSsetFrameSkip( 0 ); } diff --git a/pcsx2/GS.h b/pcsx2/GS.h index bdb84fd19a..983d13a9b1 100644 --- a/pcsx2/GS.h +++ b/pcsx2/GS.h @@ -331,7 +331,6 @@ void mfifoGIFtransfer(int qwc); int _GIFchain(); void gifMFIFOInterrupt(); -extern u32 g_vu1SkipCount; extern u32 CSRw; extern u64 m_iSlowStart; diff --git a/pcsx2/Linux/CpuDlg.cpp b/pcsx2/Linux/CpuDlg.cpp index 0fd1e7b07b..4baca1577e 100644 --- a/pcsx2/Linux/CpuDlg.cpp +++ b/pcsx2/Linux/CpuDlg.cpp @@ -39,8 +39,6 @@ void OnCpu_Ok(GtkButton *button, gpointer user_data) newopts |= PCSX2_FRAMELIMIT_LIMIT; else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lookup_widget(CpuDlg, "GtkRadioButton_LimitFS")))) newopts |= PCSX2_FRAMELIMIT_SKIP; - else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lookup_widget(CpuDlg, "GtkRadioButton_VUSkip")))) - newopts |= PCSX2_FRAMELIMIT_VUSKIP; Config.CustomFps = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(lookup_widget(CpuDlg, "CustomFPSLimit"))); Config.CustomFrameSkip = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(lookup_widget(CpuDlg, "FrameThreshold"))); @@ -88,7 +86,6 @@ void OnConf_Cpu(GtkMenuItem *menuitem, gpointer user_data) gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(lookup_widget(CpuDlg, "GtkRadioButton_LimitNormal")), CHECK_FRAMELIMIT == PCSX2_FRAMELIMIT_NORMAL); gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(lookup_widget(CpuDlg, "GtkRadioButton_LimitLimit")), CHECK_FRAMELIMIT == PCSX2_FRAMELIMIT_LIMIT); gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(lookup_widget(CpuDlg, "GtkRadioButton_LimitFS")), CHECK_FRAMELIMIT == PCSX2_FRAMELIMIT_SKIP); - gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(lookup_widget(CpuDlg, "GtkRadioButton_VUSkip")), CHECK_FRAMELIMIT == PCSX2_FRAMELIMIT_VUSKIP); sprintf(str, "Cpu Vendor: %s", cpuinfo.x86ID); gtk_label_set_text(GTK_LABEL(lookup_widget(CpuDlg, "GtkLabel_CpuVendor")), str); diff --git a/pcsx2/Misc.cpp b/pcsx2/Misc.cpp index f6a67fe6f7..d129f4ed9a 100644 --- a/pcsx2/Misc.cpp +++ b/pcsx2/Misc.cpp @@ -447,12 +447,19 @@ void CycleFrameLimit(int dir) newFrameLimit = 0; } else newFrameLimit = oldFrameLimit; - } else if (dir > 0) { - // next - newFrameLimit = (curFrameLimit + PCSX2_FRAMELIMIT_LIMIT) & PCSX2_FRAMELIMIT_MASK; - } else { - // previous - newFrameLimit = (curFrameLimit + PCSX2_FRAMELIMIT_VUSKIP) & PCSX2_FRAMELIMIT_MASK; + } + else if (dir > 0) // next + { + newFrameLimit = curFrameLimit + PCSX2_FRAMELIMIT_LIMIT; + if( newFrameLimit > PCSX2_FRAMELIMIT_SKIP ) + newFrameLimit = 0; + } + else // previous + { + if( newFrameLimit == 0 ) + newFrameLimit = PCSX2_FRAMELIMIT_SKIP; + else + newFrameLimit = curFrameLimit - PCSX2_FRAMELIMIT_LIMIT; } newOptions = (Config.Options & ~PCSX2_FRAMELIMIT_MASK) | newFrameLimit; @@ -467,7 +474,6 @@ void CycleFrameLimit(int dir) limitMsg = "Limit"; break; case PCSX2_FRAMELIMIT_SKIP: - case PCSX2_FRAMELIMIT_VUSKIP: if( GSsetFrameSkip == NULL ) { newOptions &= ~PCSX2_FRAMELIMIT_MASK; @@ -479,7 +485,7 @@ void CycleFrameLimit(int dir) // When enabling Skipping we have to make sure Skipper (GS) and Limiter (EE) // are properly synchronized. gsDynamicSkipEnable(); - limitMsg = ((newOptions & PCSX2_FRAMELIMIT_MASK) == PCSX2_FRAMELIMIT_SKIP) ? "Skip" : "VUSkip"; + limitMsg = "Skip"; } break; diff --git a/pcsx2/System.cpp b/pcsx2/System.cpp index 97b2a3b64f..3ed6d4a102 100644 --- a/pcsx2/System.cpp +++ b/pcsx2/System.cpp @@ -319,9 +319,6 @@ void SysClearExecutionCache() psxCpu->Reset(); vuMicroCpuReset(); - - // make sure the VU1 doesn't have lingering "skip" enabled. - vu1MicroDisableSkip(); } __forceinline void SysUpdate() diff --git a/pcsx2/VUmicro.h b/pcsx2/VUmicro.h index 5933338447..18bb18a384 100644 --- a/pcsx2/VUmicro.h +++ b/pcsx2/VUmicro.h @@ -123,10 +123,6 @@ extern void vu1ResetRegs(); extern void vu1ExecMicro(u32 addr); extern void vu1Exec(VURegs* VU); -extern void vu1MicroEnableSkip(); -extern void vu1MicroDisableSkip(); -extern bool vu1MicroIsSkipping(); - void VU0_UPPER_FD_00(); void VU0_UPPER_FD_01(); void VU0_UPPER_FD_10(); diff --git a/pcsx2/VUmicroMem.cpp b/pcsx2/VUmicroMem.cpp index ce2e32add1..59ed7cd653 100644 --- a/pcsx2/VUmicroMem.cpp +++ b/pcsx2/VUmicroMem.cpp @@ -38,21 +38,6 @@ static void DummyExecuteVU1Block(void) VU1.vifRegs->stat &= ~4; // also reset the bit (grandia 3 works) } -void vu1MicroEnableSkip() -{ - CpuVU1.ExecuteBlock = DummyExecuteVU1Block; -} - -void vu1MicroDisableSkip() -{ - CpuVU1.ExecuteBlock = CHECK_VU1REC ? recVU1.ExecuteBlock : intVU1.ExecuteBlock; -} - -bool vu1MicroIsSkipping() -{ - return CpuVU1.ExecuteBlock == DummyExecuteVU1Block; -} - void vuMicroCpuReset() { CpuVU0 = CHECK_VU0REC ? recVU0 : intVU0; diff --git a/pcsx2/VifDma.cpp b/pcsx2/VifDma.cpp index 8ac5b9798a..37c25ed4e3 100644 --- a/pcsx2/VifDma.cpp +++ b/pcsx2/VifDma.cpp @@ -580,13 +580,6 @@ static void VIFunpack(u32 *data, vifCode *v, unsigned int size, const unsigned i vif = &vif1; vifRow = g_vifRow1; assert(v->addr < memsize); - - if (vu1MicroIsSkipping()) - { - // don't process since the frame is dummy - vif->tag.addr += (size / (VIFfuncTable[ vif->cmd & 0xf ].gsize * vifRegs->cycle.wl)) * ((vifRegs->cycle.cl - vifRegs->cycle.wl) * 16); - return; - } } dest = (u32*)(VU->Mem + v->addr); diff --git a/pcsx2/windows/CpuDlg.cpp b/pcsx2/windows/CpuDlg.cpp index dc4c97beff..d7a334385e 100644 --- a/pcsx2/windows/CpuDlg.cpp +++ b/pcsx2/windows/CpuDlg.cpp @@ -134,7 +134,6 @@ BOOL CALLBACK CpuDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam) if( SendDlgItemMessage(hW,IDC_CPU_FL_NORMAL,BM_GETCHECK,0,0) ) newopts |= PCSX2_FRAMELIMIT_NORMAL; else if( SendDlgItemMessage(hW,IDC_CPU_FL_LIMIT,BM_GETCHECK,0,0) ) newopts |= PCSX2_FRAMELIMIT_LIMIT; else if( SendDlgItemMessage(hW,IDC_CPU_FL_SKIP,BM_GETCHECK,0,0) ) newopts |= PCSX2_FRAMELIMIT_SKIP; - else if( SendDlgItemMessage(hW,IDC_CPU_FL_SKIPVU,BM_GETCHECK,0,0) ) newopts |= PCSX2_FRAMELIMIT_VUSKIP; GetDlgItemText(hW, IDC_CUSTOMFPS, cfps, 20); Config.CustomFps = atoi(cfps); diff --git a/pcsx2/windows/pcsx2.rc b/pcsx2/windows/pcsx2.rc index e5934d0551..e1013f35db 100644 --- a/pcsx2/windows/pcsx2.rc +++ b/pcsx2/windows/pcsx2.rc @@ -828,7 +828,7 @@ BEGIN CONTROL "EE Counters log",IDC_EECNTLOG,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,5,140,64,11 END -IDD_CPUDLG DIALOGEX 0, 0, 563, 321 +IDD_CPUDLG DIALOGEX 0, 0, 563, 305 STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN @@ -843,13 +843,11 @@ BEGIN CONTROL "Normal - All frames are rendered as fast as possible.",IDC_CPU_FL_NORMAL, "Button",BS_AUTORADIOBUTTON | BS_MULTILINE | WS_GROUP,309,17,221,17 CONTROL "Limit - Force frames to normal speeds if too fast.\n (You can set a custom FPS limit below.)",IDC_CPU_FL_LIMIT, - "Button",BS_AUTORADIOBUTTON | BS_MULTILINE,309,33,222,15 + "Button",BS_AUTORADIOBUTTON | BS_MULTILINE,309,37,222,15 CONTROL "Frame Skip - In order to achieve normal speeds,\n some frames are skipped (fast).\n Fps displayed counts skipped frames too.",IDC_CPU_FL_SKIP, - "Button",BS_AUTORADIOBUTTON | BS_MULTILINE,309,48,221,28 - CONTROL "VU Skip - Same as 'Frame Skip', but tries to skip more.\n Artifacts might be present, but will be faster.",IDC_CPU_FL_SKIPVU, - "Button",BS_AUTORADIOBUTTON | BS_MULTILINE,309,75,220,25 - DEFPUSHBUTTON "OK",IDOK,210,298,61,14 - PUSHBUTTON "Cancel",IDCANCEL,282,298,61,14,NOT WS_TABSTOP + "Button",BS_AUTORADIOBUTTON | BS_MULTILINE,309,56,221,28 + DEFPUSHBUTTON "OK",IDOK,210,287,61,14 + PUSHBUTTON "Cancel",IDCANCEL,282,287,61,14,NOT WS_TABSTOP LTEXT "CPU Vendor",IDC_VENDORNAME,12,23,88,8 LTEXT "Family",IDC_FAMILYNAME,12,41,88,8 LTEXT "Cpu Speed",IDC_CPUSPEEDNAME,12,60,88,8 @@ -860,19 +858,19 @@ BEGIN GROUPBOX "VU Recompilers - All options are set by default",IDC_CPU_VUGROUP,7,119,265,46 LTEXT "Features",IDC_FEATURESNAME,12,78,88,8 GROUPBOX "",IDC_STATIC,7,7,265,90 - LTEXT "Custom FPS Limit (0=auto):",IDC_CUSTOM_FPS,327,113,124,12 - EDITTEXT IDC_CUSTOMFPS,456,113,53,13,ES_AUTOHSCROLL | ES_NUMBER - EDITTEXT IDC_CUSTOM_FRAMESKIP,456,130,53,13,ES_AUTOHSCROLL | ES_NUMBER - EDITTEXT IDC_CUSTOM_CONSECUTIVE_FRAMES,456,148,53,13,ES_AUTOHSCROLL | ES_NUMBER - LTEXT "Skip Frames when slower than:\n(See Note 1)",IDC_FRAMESKIP_LABEL1,327,129,106,20 - LTEXT "Consecutive Frames before skipping:\n(See Note 2)",IDC_FRAMESKIP_LABEL2,327,149,121,17 - GROUPBOX "Frame Limiting (F4 key switches the mode in-game!)",IDC_FRAMELIMIT,301,7,250,280 - GROUPBOX "Detailed Settings",IDC_FRAMELIMIT_OPTIONS,310,99,234,185 - LTEXT "*Note 1: Will only skip when slower than this fps number.\n (0 = Auto) ; (9999 = Forced-Frameskip regardless of speed.)\n (e.g. If set to 45, will only skip when slower than 45fps.)",IDC_FRAMESKIP_LABEL3,318,189,217,26 - LTEXT "*Note 2: Will render this number of consecutive frames before\n skipping the next frame. (0=default)\n (e.g. If set to 2, will render 2 frames before skipping 1.)",IDC_FRAMESKIP_LABEL4,318,216,217,25 - EDITTEXT IDC_CUSTOM_CONSECUTIVE_SKIP,456,166,53,13,ES_AUTOHSCROLL | ES_NUMBER - LTEXT "Consecutive Frames to skip:\n(See Note 3)",IDC_FRAMESKIP_LABEL5,327,167,121,17 - LTEXT "*Note 3: Will skip this number of frames before\n rendering the next sequence of frames. (0=default)\n (e.g. If set to 2, will skip 2 consecutive frames whenever its time\n to skip.)",IDC_FRAMESKIP_LABEL6,318,244,217,32 + LTEXT "Custom FPS Limit (0=auto):",IDC_CUSTOM_FPS,327,103,124,12 + EDITTEXT IDC_CUSTOMFPS,456,103,53,13,ES_AUTOHSCROLL | ES_NUMBER + EDITTEXT IDC_CUSTOM_FRAMESKIP,456,121,53,13,ES_AUTOHSCROLL | ES_NUMBER + EDITTEXT IDC_CUSTOM_CONSECUTIVE_FRAMES,456,139,53,13,ES_AUTOHSCROLL | ES_NUMBER + LTEXT "Skip Frames when slower than:\n(See Note 1)",IDC_FRAMESKIP_LABEL1,327,119,106,20 + LTEXT "Consecutive Frames before skipping:\n(See Note 2)",IDC_FRAMESKIP_LABEL2,327,139,121,17 + GROUPBOX "Frame Limiting (F4 key switches the mode in-game!)",IDC_FRAMELIMIT,301,7,250,274 + GROUPBOX "Detailed Settings",IDC_FRAMELIMIT_OPTIONS,310,89,234,185 + LTEXT "*Note 1: Will only skip when slower than this fps number.\n (0 = Auto) ; (9999 = Forced-Frameskip regardless of speed.)\n (e.g. If set to 45, will only skip when slower than 45fps.)",IDC_FRAMESKIP_LABEL3,318,179,217,26 + LTEXT "*Note 2: Will render this number of consecutive frames before\n skipping the next frame. (0=default)\n (e.g. If set to 2, will render 2 frames before skipping 1.)",IDC_FRAMESKIP_LABEL4,318,206,217,25 + EDITTEXT IDC_CUSTOM_CONSECUTIVE_SKIP,456,157,53,13,ES_AUTOHSCROLL | ES_NUMBER + LTEXT "Consecutive Frames to skip:\n(See Note 3)",IDC_FRAMESKIP_LABEL5,327,157,121,17 + LTEXT "*Note 3: Will skip this number of frames before\n rendering the next sequence of frames. (0=default)\n (e.g. If set to 2, will skip 2 consecutive frames whenever its time\n to skip.)",IDC_FRAMESKIP_LABEL6,318,234,217,32 END diff --git a/pcsx2/x86/ix86-32/iR5900-32.cpp b/pcsx2/x86/ix86-32/iR5900-32.cpp index d93c425de6..f3768ab66e 100644 --- a/pcsx2/x86/ix86-32/iR5900-32.cpp +++ b/pcsx2/x86/ix86-32/iR5900-32.cpp @@ -424,7 +424,7 @@ PCSX2_ALIGNED16( static u8 manual_counter[Ps2MemSize::Base >> 12] ); //////////////////////////////////////////////////// void recResetEE( void ) { - DbgCon::Status( "iR5900-32 > Resetting recompiler memory and structures." ); + Console::Status( "Issuing EE/iR5900-32 Recompiler Reset [mem/structure cleanup]" ); maxrecmem = 0; @@ -1258,7 +1258,6 @@ void recRecompile( const u32 startpc ) // if recPtr reached the mem limit reset whole mem if ( ( (uptr)recPtr - (uptr)recMem ) >= REC_CACHEMEM-0x40000 || dumplog == 0xffffffff) { - DevCon::WriteLn( "EE Recompiler data reset" ); recResetEE(); } if ( ( (uptr)recStackPtr - (uptr)recStack ) >= RECSTACK_SIZE-0x100 ) { @@ -1334,10 +1333,7 @@ void recRecompile( const u32 startpc ) willbranch3 = 1; s_nEndBlock = i; - // Log the pagesplits verbosely for now, until we see if any games are affected - // adversely by excessive splits. - DevCon::Notice( "Pagesplit @ %08X : size=%d insts", params startpc, (i-startpc) / 4 ); - + //DevCon::Notice( "Pagesplit @ %08X : size=%d insts", params startpc, (i-startpc) / 4 ); break; } @@ -1508,86 +1504,80 @@ StartRecomp: iDumpBlock(startpc, recPtr); #endif - // fixme! The following manual/protected block code can be greatly simplified now. - // It originally had to account for cross-page blocks, but we have since guaranteed - // that no block will cross a page boundary. - u32 sz = (s_nEndBlock-startpc) >> 2; u32 inpage_ptr = HWADDR(startpc); u32 inpage_sz = sz*4; - while(inpage_sz) - { - int PageType = mmap_GetRamPageInfo((u32*)PSM(inpage_ptr)); - u32 inpage_offs = inpage_ptr & 0xFFF; - u32 pgsz = std::min(0x1000 - inpage_offs, inpage_sz); + // note: blocks are guaranteed to reside within the confines of a single page. - if(PageType!=-1) + const int PageType = mmap_GetRamPageInfo((u32*)PSM(inpage_ptr)); + const u32 inpage_offs = inpage_ptr & 0xFFF; + //const u32 pgsz = std::min(0x1000 - inpage_offs, inpage_sz); + const u32 pgsz = inpage_sz; + + if(PageType!=-1) + { + if (PageType==0) { + mmap_MarkCountedRamPage(PSM(inpage_ptr),inpage_ptr&~0xFFF); + manual_page[inpage_ptr >> 12] = 0; + } + else { - if (PageType==0) { - mmap_MarkCountedRamPage(PSM(inpage_ptr),inpage_ptr&~0xFFF); - manual_page[inpage_ptr >> 12] = 0; + xMOV( ecx, inpage_ptr ); + xMOV( edx, pgsz / 4 ); + //xMOV( eax, startpc ); // uncomment this to access startpc (as eax) in dyna_block_discard + + u32 lpc = inpage_ptr; + u32 stg = pgsz; + while(stg>0) + { + xCMP( ptr32[PSM(lpc)], *(u32*)PSM(lpc) ); + xJNE( dyna_block_discard ); + + stg -= 4; + lpc += 4; + } + + // Tweakpoint! 3 is a 'magic' number representing the number of times a counted block + // is re-protected before the recompiler gives up and sets it up as an uncounted (permanent) + // manual block. Higher thresholds result in more recompilations for blocks that share code + // and data on the same page. Side effects of a lower threshold: over extended gameplay + // with several map changes, a game's overall performance could degrade. + + // (ideally, perhaps, manual_counter should be reset to 0 every few minutes?) + + if (startpc != 0x81fc0 && manual_counter[inpage_ptr >> 12] <= 3) { + + // Counted blocks add a weighted (by block size) value into manual_page each time they're + // run. If the block gets run a lot, it resets and re-protects itself in the hope + // that whatever forced it to be manually-checked before was a 1-time deal. + + // Counted blocks have a secondary threshold check in manual_counter, which forces a block + // to 'uncounted' mode if it's recompiled several time. This protects against excessive + // recompilation of blocks that reside on the same codepage as data. + + // fixme? Currently this algo is kinda dumb and results in the forced recompilation of a + // lot of blocks before it decides to mark a 'busy' page as uncounted. There might be + // be a more clever approach that could streamline this process, by doing a first-pass + // test using the vtlb memory protection (without recompilation!) to reprotect a counted + // block. But unless a new also is relatively simple in implementation, it's probably + // not worth the effort (tests show that we have lots of recompiler memory to spare, and + // that the current amount of recompilation is fairly cheap). + + xADD(ptr16[&manual_page[inpage_ptr >> 12]], sz); + xJC( dyna_page_reset ); + + // note: clearcnt is measured per-page, not per-block! + DbgCon::WriteLn( "Manual block @ %08X : size=%3d page/offs=%05X/%03X inpgsz=%d clearcnt=%d", + params startpc, sz, inpage_ptr>>12, inpage_offs, inpage_sz, manual_counter[inpage_ptr >> 12] ); } else { - xMOV( ecx, inpage_ptr ); - xMOV( edx, pgsz / 4 ); - //xMOV( eax, startpc ); // uncomment this to access startpc (as eax) in dyna_block_discard - - u32 lpc = inpage_ptr; - u32 stg = pgsz; - while(stg>0) - { - xCMP( ptr32[PSM(lpc)], *(u32*)PSM(lpc) ); - xJNE( dyna_block_discard ); - - stg -= 4; - lpc += 4; - } - - // Tweakpoint! 3 is a 'magic' number representing the number of times a counted block - // is re-protected before the recompiler gives up and sets it up as an uncounted (permanent) - // manual block. 4 definitely seemed too high, but 2 might be better? Side effects of a - // lower threshold: over extended gameplay with several map changes, a game's overall - // performance could degrade. - - // (ideally, perhaps, manual_counter should be reset to 0 every few minutes?) - - if (startpc != 0x81fc0 && manual_counter[inpage_ptr >> 12] <= 3) { - - // Counted blocks add a weighted (by block size) value into manual_page each time they're - // run. If the block gets run a lot, it resets and re-protects itself in the hope - // that whatever forced it to be manually-checked before was a 1-time deal. - - // Counted blocks have a secondary threshold check in manual_counter, which forces a block - // to 'uncounted' mode if it's recompiled several time. This protects against excessive - // recompilation of blocks that reside on the same codepage as data. - - // fixme? Currently this algo is kinda dumb and results in the forced recompilation of a - // lot of blocks before it decides to mark a 'busy' page as uncounted. There might be - // be a more clever approach that could streamline this process, by doing a first-pass - // test using the vtlb memory protection (without recompilation!) to reprotect a counted - // block. But unless a new also is relatively simple in implementation, it's probably - // not worth the effort (tests show that we have lots of recompiler memory to spare, and - // that the current amount of recompilation is fairly cheap). - - xADD(ptr16[&manual_page[inpage_ptr >> 12]], sz); - xJC( dyna_page_reset ); - - // note: clearcnt is measured per-page, not per-block! - DbgCon::WriteLn( "Manual block @ %08X : size=%3d page/offs=%05X/%03X inpgsz=%d clearcnt=%d", - params startpc, sz, inpage_ptr>>12, inpage_offs, inpage_sz, manual_counter[inpage_ptr >> 12] ); - } - else - { - DbgCon::Notice( "Uncounted Manual block @ %08X : size=%3d page/offs=%05X/%03X inpgsz=%d", - params startpc, sz, inpage_ptr>>12, inpage_offs, pgsz, inpage_sz ); - } - + DbgCon::Notice( "Uncounted Manual block @ %08X : size=%3d page/offs=%05X/%03X inpgsz=%d", + params startpc, sz, inpage_ptr>>12, inpage_offs, pgsz, inpage_sz ); } + } - inpage_ptr += pgsz; - inpage_sz -= pgsz; } // Finally: Generate x86 recompiled code! From b560f325ae21591ae116115f6aaf4540cdf73812 Mon Sep 17 00:00:00 2001 From: arcum42 Date: Sat, 2 May 2009 09:31:14 +0000 Subject: [PATCH 39/41] Finish removing VU Skip from Linux, and fix a few compiler warnings left over from the work on CDVD.cpp. git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1115 96395faa-99c1-11dd-bbfe-3dabce05a288 --- pcsx2/CDVD.h | 13 ------------- pcsx2/CdRom.cpp | 3 --- pcsx2/CdRom.h | 6 ++---- pcsx2/Linux/interface.c | 9 --------- pcsx2/Linux/pcsx2.glade | 21 --------------------- 5 files changed, 2 insertions(+), 50 deletions(-) diff --git a/pcsx2/CDVD.h b/pcsx2/CDVD.h index 457e110926..3aaa5647a1 100644 --- a/pcsx2/CDVD.h +++ b/pcsx2/CDVD.h @@ -310,20 +310,7 @@ extern void cdvdActionInterrupt(); extern void cdvdReadInterrupt(); void cdvdNewDiskCB(); u8 cdvdRead(u8 key); -u8 cdvdRead18(void); void cdvdWrite(u8 key, u8 rt); -void cdvdWrite04(u8 rt); -void cdvdWrite05(u8 rt); -void cdvdWrite06(u8 rt); -void cdvdWrite07(u8 rt); -void cdvdWrite08(u8 rt); -void cdvdWrite0A(u8 rt); -void cdvdWrite0F(u8 rt); -void cdvdWrite14(u8 rt); -void cdvdWrite16(u8 rt); -void cdvdWrite17(u8 rt); -void cdvdWrite18(u8 rt); -void cdvdWrite3A(u8 rt); // Platform dependent system time assignment (see WinMisc / LnxMisc) extern void cdvdSetSystemTime( cdvdStruct& setme ); diff --git a/pcsx2/CdRom.cpp b/pcsx2/CdRom.cpp index bb2f022b7a..07bcf3a6ac 100644 --- a/pcsx2/CdRom.cpp +++ b/pcsx2/CdRom.cpp @@ -85,9 +85,6 @@ u8 Test23[] = { 0x43, 0x58, 0x44, 0x32, 0x39 ,0x34, 0x30, 0x51 }; //#define cdReadTime ((PSXCLK / 75) / BIAS) unsigned long cdReadTime;// = ((PSXCLK / 75) / BIAS); -#define btoi(b) ((b)/16*10 + (b)%16) /* BCD to u_char */ -#define itob(i) ((i)/10*16 + (i)%10) /* u_char to BCD */ - #define CDR_INT(eCycle) PSX_INT(IopEvt_Cdrom, eCycle) #define CDREAD_INT(eCycle) PSX_INT(IopEvt_CdromRead, eCycle) diff --git a/pcsx2/CdRom.h b/pcsx2/CdRom.h index 10757dff7e..36ceba98a2 100644 --- a/pcsx2/CdRom.h +++ b/pcsx2/CdRom.h @@ -72,12 +72,10 @@ struct cdrStruct char Unused[4087]; }; -extern cdrStruct cdr; - -s32 MSFtoLSN(u8 *Time); -void LSNtoMSF(u8 *Time, s32 lsn); void AddIrqQueue(u8 irq, unsigned long ecycle); +extern cdrStruct cdr; + void cdrReset(); void cdrInterrupt(); void cdrReadInterrupt(); diff --git a/pcsx2/Linux/interface.c b/pcsx2/Linux/interface.c index 035bc3fe03..87e6a49abf 100644 --- a/pcsx2/Linux/interface.c +++ b/pcsx2/Linux/interface.c @@ -3859,7 +3859,6 @@ create_CpuDlg (void) GSList *GtkRadioButton_LimitNormal_group = NULL; GtkWidget *GtkRadioButton_LimitLimit; GtkWidget *GtkRadioButton_LimitFS; - GtkWidget *GtkRadioButton_VUSkip; GtkWidget *label41; GtkWidget *frame23; GtkWidget *alignment18; @@ -4028,13 +4027,6 @@ create_CpuDlg (void) gtk_radio_button_set_group (GTK_RADIO_BUTTON (GtkRadioButton_LimitFS), GtkRadioButton_LimitNormal_group); GtkRadioButton_LimitNormal_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (GtkRadioButton_LimitFS)); - GtkRadioButton_VUSkip = gtk_radio_button_new_with_mnemonic (NULL, _("VU Skip - Same as Frame Skip, but tried to skip more. \n Artifacts might be present, but will be faster")); - gtk_widget_set_name (GtkRadioButton_VUSkip, "GtkRadioButton_VUSkip"); - gtk_widget_show (GtkRadioButton_VUSkip); - gtk_box_pack_start (GTK_BOX (vbox29), GtkRadioButton_VUSkip, FALSE, FALSE, 0); - gtk_radio_button_set_group (GTK_RADIO_BUTTON (GtkRadioButton_VUSkip), GtkRadioButton_LimitNormal_group); - GtkRadioButton_LimitNormal_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (GtkRadioButton_VUSkip)); - label41 = gtk_label_new (_("Frame Limiting (F4 switches in-game)")); gtk_widget_set_name (label41, "label41"); gtk_widget_show (label41); @@ -4198,7 +4190,6 @@ create_CpuDlg (void) GLADE_HOOKUP_OBJECT (CpuDlg, GtkRadioButton_LimitNormal, "GtkRadioButton_LimitNormal"); GLADE_HOOKUP_OBJECT (CpuDlg, GtkRadioButton_LimitLimit, "GtkRadioButton_LimitLimit"); GLADE_HOOKUP_OBJECT (CpuDlg, GtkRadioButton_LimitFS, "GtkRadioButton_LimitFS"); - GLADE_HOOKUP_OBJECT (CpuDlg, GtkRadioButton_VUSkip, "GtkRadioButton_VUSkip"); GLADE_HOOKUP_OBJECT (CpuDlg, label41, "label41"); GLADE_HOOKUP_OBJECT (CpuDlg, frame23, "frame23"); GLADE_HOOKUP_OBJECT (CpuDlg, alignment18, "alignment18"); diff --git a/pcsx2/Linux/pcsx2.glade b/pcsx2/Linux/pcsx2.glade index ae3a436467..bb90d59e3d 100644 --- a/pcsx2/Linux/pcsx2.glade +++ b/pcsx2/Linux/pcsx2.glade @@ -6859,27 +6859,6 @@ Version x.x False - - - - True - True - VU Skip - Same as Frame Skip, but tried to skip more. - Artifacts might be present, but will be faster - True - GTK_RELIEF_NORMAL - True - False - False - True - GtkRadioButton_LimitNormal - - - 0 - False - False - - From 56545f0b7db9cee0aed2de6f0543c58fdded9326 Mon Sep 17 00:00:00 2001 From: "Jake.Stine" Date: Sat, 2 May 2009 10:48:41 +0000 Subject: [PATCH 40/41] *Experimental* Made new IopHwRead and IopHwWrite from scratch, in pre-preparation for a new lookup-based IOP memory manager. Could be some lingering bugs or typos. :/ Win32/vcproj: Re-structured the folder layout of the project. git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1116 96395faa-99c1-11dd-bbfe-3dabce05a288 --- pcsx2/EEregs.h | 40 - pcsx2/IopCounters.cpp | 240 +- pcsx2/IopCounters.h | 38 +- pcsx2/IopHw.cpp | 40 +- pcsx2/IopHw.h | 77 +- pcsx2/IopMem.cpp | 152 +- pcsx2/IopMem.h | 46 +- pcsx2/ps2/Iop/IopHwRead.cpp | 445 ++++ pcsx2/ps2/Iop/IopHwWrite.cpp | 529 ++++ pcsx2/ps2/Iop/IopHw_Internal.h | 204 ++ pcsx2/windows/VCprojects/pcsx2_2008.vcproj | 2524 ++++++++++---------- 11 files changed, 2808 insertions(+), 1527 deletions(-) delete mode 100644 pcsx2/EEregs.h create mode 100644 pcsx2/ps2/Iop/IopHwRead.cpp create mode 100644 pcsx2/ps2/Iop/IopHwWrite.cpp create mode 100644 pcsx2/ps2/Iop/IopHw_Internal.h diff --git a/pcsx2/EEregs.h b/pcsx2/EEregs.h deleted file mode 100644 index 1445350185..0000000000 --- a/pcsx2/EEregs.h +++ /dev/null @@ -1,40 +0,0 @@ -/* Pcsx2 - Pc Ps2 Emulator - * Copyright (C) 2002-2009 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 __EEREGS_H__ -#define __EEREGS_H__ - -#define at cpuRegs.GPR.n.at -#define k0 cpuRegs.GPR.n.k0 -#define k1 cpuRegs.GPR.n.k1 -#define v0 cpuRegs.GPR.n.v0 -#define v1 cpuRegs.GPR.n.v1 -#define a0 cpuRegs.GPR.n.a0 -#define a1 cpuRegs.GPR.n.a1 -#define a2 cpuRegs.GPR.n.a2 -#define a3 cpuRegs.GPR.n.a3 -#define t0 cpuRegs.GPR.n.t0 -#define s0 cpuRegs.GPR.n.s0 -#define gp cpuRegs.GPR.n.gp -#define fp cpuRegs.GPR.n.s8 -#define sp cpuRegs.GPR.n.sp -#define ra cpuRegs.GPR.n.ra - -#define pc0 cpuRegs.pc - -#endif /* __EEREGS_H__ */ diff --git a/pcsx2/IopCounters.cpp b/pcsx2/IopCounters.cpp index 664dceb228..9e169100f7 100644 --- a/pcsx2/IopCounters.cpp +++ b/pcsx2/IopCounters.cpp @@ -479,7 +479,9 @@ void psxRcntUpdate() for (i=0; i<6; i++) _rcntSet( i ); } -void psxRcntWcount16(int index, u32 value) +////////////////////////////////////////////////////////////////////////////////////////// +// +void psxRcntWcount16(int index, u16 value) { u32 change; @@ -500,6 +502,8 @@ void psxRcntWcount16(int index, u32 value) _rcntSet( index ); } +////////////////////////////////////////////////////////////////////////////////////////// +// void psxRcntWcount32(int index, u32 value) { u32 change; @@ -521,159 +525,119 @@ void psxRcntWcount32(int index, u32 value) _rcntSet( index ); } -void psxRcnt0Wmode(u32 value) +////////////////////////////////////////////////////////////////////////////////////////// +// +__forceinline void psxRcntWmode16( int index, u32 value ) { - PSXCNT_LOG("IOP Counter[0] writeMode = %lx", value); + PSXCNT_LOG( "IOP Counter[%d] writeMode = 0x%04X", index, value ); - psxCounters[0].mode = value; - psxCounters[0].mode|= 0x0400; - psxCounters[0].rate = 1; + jASSUME( index >= 0 && index < 3 ); + psxCounter& counter = psxCounters[index]; - if(value & IOPCNT_ALT_SOURCE) - psxCounters[0].rate = PSXPIXEL; - - if(psxCounters[0].mode & IOPCNT_ENABLE_GATE) + counter.mode = value; + counter.mode |= 0x0400; + + if( index == 2 ) { - // gated counters are added up as per the h/vblank timers. - PSXCNT_LOG("IOP Counter[0] Gate Check set, value = %x", value); - psxhblankgate |= 1; - } - else psxhblankgate &= ~1; - - psxCounters[0].count = 0; - psxCounters[0].sCycleT = psxRegs.cycle; - psxCounters[0].target &= 0xffff; - - _rcntSet( 0 ); -} - -void psxRcnt1Wmode(u32 value) -{ - PSXCNT_LOG("IOP Counter[0] writeMode = %lx", value); - - psxCounters[1].mode = value; - psxCounters[1].mode|= 0x0400; - psxCounters[1].rate = 1; - - if(value & IOPCNT_ALT_SOURCE) - psxCounters[1].rate = PSXHBLANK; - - if(psxCounters[1].mode & IOPCNT_ENABLE_GATE) - { - PSXCNT_LOG("IOP Counter[1] Gate Check set, value = %x", value); - psxvblankgate |= 1<<1; - } - else psxvblankgate &= ~(1<<1); - - psxCounters[1].count = 0; - psxCounters[1].sCycleT = psxRegs.cycle; - psxCounters[1].target &= 0xffff; - _rcntSet( 1 ); -} - -void psxRcnt2Wmode(u32 value) -{ - PSXCNT_LOG("IOP Counter[0] writeMode = %lx", value); - - psxCounters[2].mode = value; - psxCounters[2].mode|= 0x0400; - - switch(value & 0x200) - { - case 0x200: psxCounters[2].rate = 8; break; + switch(value & 0x200) + { case 0x000: psxCounters[2].rate = 1; break; + case 0x200: psxCounters[2].rate = 8; break; + jNO_DEFAULT; + } + + if((counter.mode & 0x7) == 0x7 || (counter.mode & 0x7) == 0x1) + { + counter.mode |= IOPCNT_STOPPED; + } + } + else + { + // Counters 0 and 1 can select PIXEL or HSYNC as an alternate source: + counter.rate = 1; + + if(value & IOPCNT_ALT_SOURCE) + counter.rate = (index==0) ? PSXPIXEL : PSXHBLANK; + + if(counter.mode & IOPCNT_ENABLE_GATE) + { + // gated counters are added up as per the h/vblank timers. + // (the PIXEL alt source becomes a vsync gate) + + PSXCNT_LOG( "IOP Counter[%d] Gate Check set, value = 0x%04X", index, value ); + if( index == 0 ) + psxhblankgate |= 1; // fixme: these gate flags should be one var >_< + else + psxvblankgate |= 1<<1; + } + else + { + if( index == 0 ) + psxhblankgate &= ~1; + else + psxvblankgate &= ~(1<<1); + } } - if((psxCounters[2].mode & 0x7) == 0x7 || (psxCounters[2].mode & 0x7) == 0x1) - { - //Console::WriteLn("Gate set on IOP C2, disabling"); - psxCounters[2].mode |= IOPCNT_STOPPED; - } - - psxCounters[2].count = 0; - psxCounters[2].sCycleT = psxRegs.cycle; - psxCounters[2].target &= 0xffff; - _rcntSet( 2 ); + counter.count = 0; + counter.sCycleT = psxRegs.cycle; + counter.target &= 0xffff; + + _rcntSet( index ); } -void psxRcnt3Wmode(u32 value) +////////////////////////////////////////////////////////////////////////////////////////// +// +__forceinline void psxRcntWmode32( int index, u32 value ) { - PSXCNT_LOG("IOP Counter[3] writeMode = %lx", value); + PSXCNT_LOG( "IOP Counter[%d] writeMode = 0x%04x", index, value ); - psxCounters[3].mode = value; - psxCounters[3].rate = 1; - psxCounters[3].mode|= 0x0400; + jASSUME( index >= 3 && index < 6 ); + psxCounter& counter = psxCounters[index]; - if(value & IOPCNT_ALT_SOURCE) - psxCounters[3].rate = PSXHBLANK; - - if(psxCounters[3].mode & IOPCNT_ENABLE_GATE) + counter.mode = value; + counter.mode |= 0x0400; + + if( index == 3 ) { - PSXCNT_LOG("IOP Counter[3] Gate Check set, value = %x", value); - psxvblankgate |= 1<<3; - } - else psxvblankgate &= ~(1<<3); + // Counter 3 has the HBlank as an alternate source. + counter.rate = 1; + if(value & IOPCNT_ALT_SOURCE) + counter.rate = PSXHBLANK; - psxCounters[3].count = 0; - psxCounters[3].sCycleT = psxRegs.cycle; - psxCounters[3].target &= 0xffffffff; - _rcntSet( 3 ); -} - -void psxRcnt4Wmode(u32 value) -{ - PSXCNT_LOG("IOP Counter[4] writeMode = %lx", value); - - psxCounters[4].mode = value; - psxCounters[4].mode|= 0x0400; - - switch(value & 0x6000) - { - case 0x0000: psxCounters[4].rate = 1; break; - case 0x2000: psxCounters[4].rate = 8; break; - case 0x4000: psxCounters[4].rate = 16; break; - case 0x6000: psxCounters[4].rate = 256; break; - } - // Need to set a rate and target - if((psxCounters[4].mode & 0x7) == 0x7 || (psxCounters[4].mode & 0x7) == 0x1) - { - Console::WriteLn("Gate set on IOP C4, disabling"); - psxCounters[4].mode |= IOPCNT_STOPPED; - } - - psxCounters[4].count = 0; - psxCounters[4].sCycleT = psxRegs.cycle; - psxCounters[4].target &= 0xffffffff; - _rcntSet( 4 ); -} - -void psxRcnt5Wmode(u32 value) -{ - PSXCNT_LOG("IOP Counter[5] writeMode = %lx", value); - - psxCounters[5].mode = value; - psxCounters[5].mode|= 0x0400; - - switch(value & 0x6000) - { - case 0x0000: psxCounters[5].rate = 1; break; - case 0x2000: psxCounters[5].rate = 8; break; - case 0x4000: psxCounters[5].rate = 16; break; - case 0x6000: psxCounters[5].rate = 256; break; - } - // Need to set a rate and target - if((psxCounters[5].mode & 0x7) == 0x7 || (psxCounters[5].mode & 0x7) == 0x1) - { - Console::WriteLn("Gate set on IOP C5, disabling"); - psxCounters[5].mode |= IOPCNT_STOPPED; - } - - psxCounters[5].count = 0; - psxCounters[5].sCycleT = psxRegs.cycle; - psxCounters[5].target &= 0xffffffff; - _rcntSet( 5 ); + if(counter.mode & IOPCNT_ENABLE_GATE) + { + PSXCNT_LOG("IOP Counter[3] Gate Check set, value = %x", value); + psxvblankgate |= 1<<3; + } + else psxvblankgate &= ~(1<<3); + } + else + { + switch(value & 0x6000) + { + case 0x0000: counter.rate = 1; break; + case 0x2000: counter.rate = 8; break; + case 0x4000: counter.rate = 16; break; + case 0x6000: counter.rate = 256; break; + } + + // Need to set a rate and target + if((counter.mode & 0x7) == 0x7 || (counter.mode & 0x7) == 0x1) + { + Console::WriteLn( "Gate set on IOP Counter %d, disabling", params index ); + counter.mode |= IOPCNT_STOPPED; + } + } + + counter.count = 0; + counter.sCycleT = psxRegs.cycle; + counter.target &= 0xffffffff; + _rcntSet( index ); } +////////////////////////////////////////////////////////////////////////////////////////// +// void psxRcntWtarget16(int index, u32 value) { assert( index < 3 ); diff --git a/pcsx2/IopCounters.h b/pcsx2/IopCounters.h index 8a743408f0..c31fbe36fd 100644 --- a/pcsx2/IopCounters.h +++ b/pcsx2/IopCounters.h @@ -34,30 +34,24 @@ struct psxCounter { #endif extern psxCounter psxCounters[NUM_COUNTERS]; -extern s32 psxNextCounter; -extern u32 psxNextsCounter; -void psxRcntInit(); -void psxRcntUpdate(); -void cntspu2async(); -void psxRcntWcount16(int index, u32 value); -void psxRcntWcount32(int index, u32 value); -void psxRcnt0Wmode(u32 value); -void psxRcnt1Wmode(u32 value); -void psxRcnt2Wmode(u32 value); -void psxRcnt3Wmode(u32 value); -void psxRcnt4Wmode(u32 value); -void psxRcnt5Wmode(u32 value); -void psxRcntWtarget16(int index, u32 value); -void psxRcntWtarget32(int index, u32 value); -u16 psxRcntRcount16(int index); -u32 psxRcntRcount32(int index); -u64 psxRcntCycles(int index); +extern void psxRcntInit(); +extern void psxRcntUpdate(); +extern void cntspu2async(); +extern void psxRcntWcount16(int index, u16 value); +extern void psxRcntWcount32(int index, u32 value); +extern void psxRcntWmode16(int index, u32 value); +extern void psxRcntWmode32(int index, u32 value); +extern void psxRcntWtarget16(int index, u32 value); +extern void psxRcntWtarget32(int index, u32 value); +extern u16 psxRcntRcount16(int index); +extern u32 psxRcntRcount32(int index); +extern u64 psxRcntCycles(int index); -void psxVBlankStart(); -void psxVBlankEnd(); -void psxCheckStartGate16(int i); -void psxCheckEndGate16(int i); +extern void psxVBlankStart(); +extern void psxVBlankEnd(); +extern void psxCheckStartGate16(int i); +extern void psxCheckEndGate16(int i); //static void psxCheckStartGate32(int i); //static void psxCheckEndGate32(int i); diff --git a/pcsx2/IopHw.cpp b/pcsx2/IopHw.cpp index de7eafadd6..80c5108f9e 100644 --- a/pcsx2/IopHw.cpp +++ b/pcsx2/IopHw.cpp @@ -618,8 +618,8 @@ u32 psxHwRead32(u32 add) { } // A buffer that stores messages until it gets a /n or the number of chars (g_pbufi) is more then 1023. -s8 g_pbuf[1024]; -int g_pbufi; +static s8 g_pbuf[1024]; +static int g_pbufi; void psxHwWrite8(u32 add, u8 value) { if (add >= HW_USB_START && add < HW_USB_END) { USBwrite8(add, value); return; @@ -768,7 +768,7 @@ void psxHwWrite16(u32 add, u16 value) { psxRcntWcount16(0, value); return; case IOP_T0_MODE: PSXCNT_LOG("COUNTER 0 MODE 16bit write %x", value); - psxRcnt0Wmode(value); return; + psxRcntWmode16(0, value); return; case IOP_T0_TARGET: PSXCNT_LOG("COUNTER 0 TARGET 16bit write %x", value); psxRcntWtarget16(0, value); return; @@ -778,7 +778,7 @@ void psxHwWrite16(u32 add, u16 value) { psxRcntWcount16(1, value); return; case IOP_T1_MODE: PSXCNT_LOG("COUNTER 1 MODE 16bit write %x", value); - psxRcnt1Wmode(value); return; + psxRcntWmode16(1, value); return; case IOP_T1_TARGET: PSXCNT_LOG("COUNTER 1 TARGET 16bit write %x", value); psxRcntWtarget16(1, value); return; @@ -788,7 +788,7 @@ void psxHwWrite16(u32 add, u16 value) { psxRcntWcount16(2, value); return; case IOP_T2_MODE: PSXCNT_LOG("COUNTER 2 MODE 16bit write %x", value); - psxRcnt2Wmode(value); return; + psxRcntWmode16(2, value); return; case IOP_T2_TARGET: PSXCNT_LOG("COUNTER 2 TARGET 16bit write %x", value); psxRcntWtarget16(2, value); return; @@ -803,7 +803,7 @@ void psxHwWrite16(u32 add, u16 value) { psxRcntWcount32(3, value); return; case IOP_T3_MODE: PSXCNT_LOG("COUNTER 3 MODE 16bit write %lx", value); - psxRcnt3Wmode(value); return; + psxRcntWmode32(3, value); return; case IOP_T3_TARGET: PSXCNT_LOG("COUNTER 3 TARGET 16bit write %lx", value); psxRcntWtarget32(3, value); return; @@ -813,7 +813,7 @@ void psxHwWrite16(u32 add, u16 value) { psxRcntWcount32(4, value); return; case IOP_T4_MODE: PSXCNT_LOG("COUNTER 4 MODE 16bit write %lx", value); - psxRcnt4Wmode(value); return; + psxRcntWmode32(4, value); return; case IOP_T4_TARGET: PSXCNT_LOG("COUNTER 4 TARGET 16bit write %lx", value); psxRcntWtarget32(4, value); return; @@ -823,7 +823,7 @@ void psxHwWrite16(u32 add, u16 value) { psxRcntWcount32(5, value); return; case IOP_T5_MODE: PSXCNT_LOG("COUNTER 5 MODE 16bit write %lx", value); - psxRcnt5Wmode(value); return; + psxRcntWmode32(5, value); return; case IOP_T5_TARGET: PSXCNT_LOG("COUNTER 5 TARGET 16bit write %lx", value); psxRcntWtarget32(5, value); return; @@ -1180,7 +1180,7 @@ void psxHwWrite32(u32 add, u32 value) { psxRcntWcount16(0, value ); return; case IOP_T0_MODE: PSXCNT_LOG("COUNTER 0 MODE 32bit write %lx", value); - psxRcnt0Wmode(value); return; + psxRcntWmode16(0, value); return; case IOP_T0_TARGET: PSXCNT_LOG("COUNTER 0 TARGET 32bit write %lx", value); psxRcntWtarget16(0, value ); return; @@ -1190,7 +1190,7 @@ void psxHwWrite32(u32 add, u32 value) { psxRcntWcount16(1, value ); return; case IOP_T1_MODE: PSXCNT_LOG("COUNTER 1 MODE 32bit write %lx", value); - psxRcnt1Wmode(value); return; + psxRcntWmode16(1, value); return; case IOP_T1_TARGET: PSXCNT_LOG("COUNTER 1 TARGET 32bit write %lx", value); psxRcntWtarget16(1, value ); return; @@ -1200,7 +1200,7 @@ void psxHwWrite32(u32 add, u32 value) { psxRcntWcount16(2, value ); return; case IOP_T2_MODE: PSXCNT_LOG("COUNTER 2 MODE 32bit write %lx", value); - psxRcnt2Wmode(value); return; + psxRcntWmode16(0, value); return; case IOP_T2_TARGET: PSXCNT_LOG("COUNTER 2 TARGET 32bit write %lx", value); psxRcntWtarget16(2, value); return; @@ -1210,7 +1210,7 @@ void psxHwWrite32(u32 add, u32 value) { psxRcntWcount32(3, value); return; case IOP_T3_MODE: PSXCNT_LOG("COUNTER 3 MODE 32bit write %lx", value); - psxRcnt3Wmode(value); return; + psxRcntWmode32(3, value); return; case IOP_T3_TARGET: PSXCNT_LOG("COUNTER 3 TARGET 32bit write %lx", value); psxRcntWtarget32(3, value); return; @@ -1220,7 +1220,7 @@ void psxHwWrite32(u32 add, u32 value) { psxRcntWcount32(4, value); return; case IOP_T4_MODE: PSXCNT_LOG("COUNTER 4 MODE 32bit write %lx", value); - psxRcnt4Wmode(value); return; + psxRcntWmode32(4, value); return; case IOP_T4_TARGET: PSXCNT_LOG("COUNTER 4 TARGET 32bit write %lx", value); psxRcntWtarget32(4, value); return; @@ -1230,7 +1230,7 @@ void psxHwWrite32(u32 add, u32 value) { psxRcntWcount32(5, value); return; case IOP_T5_MODE: PSXCNT_LOG("COUNTER 5 MODE 32bit write %lx", value); - psxRcnt5Wmode(value); return; + psxRcntWmode32(5, value); return; case IOP_T5_TARGET: PSXCNT_LOG("COUNTER 5 TARGET 32bit write %lx", value); psxRcntWtarget32(5, value); return; @@ -1335,16 +1335,20 @@ void psxHw4Write8(u32 add, u8 value) PSXHW_LOG("Known 8bit write to addr 0x%x = 0x%x", add, value); } -void psxDmaInterrupt(int n) { - if (HW_DMA_ICR & (1 << (16 + n))) { +void psxDmaInterrupt(int n) +{ + if (HW_DMA_ICR & (1 << (16 + n))) + { HW_DMA_ICR|= (1 << (24 + n)); psxRegs.CP0.n.Cause |= 1 << (9 + n); iopIntcIrq( 3 ); } } -void psxDmaInterrupt2(int n) { - if (HW_DMA_ICR2 & (1 << (16 + n))) { +void psxDmaInterrupt2(int n) +{ + if (HW_DMA_ICR2 & (1 << (16 + n))) + { /* if (HW_DMA_ICR2 & (1 << (24 + n))) { Console::WriteLn("*PCSX2*: HW_DMA_ICR2 n=%d already set", params n); } diff --git a/pcsx2/IopHw.h b/pcsx2/IopHw.h index 5579161b9c..4b31f5f2c0 100644 --- a/pcsx2/IopHw.h +++ b/pcsx2/IopHw.h @@ -16,18 +16,69 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -#ifndef __PSXHW_H__ -#define __PSXHW_H__ +#pragma once -#include "R3000A.h" #include "IopMem.h" -#define HW_USB_START 0x1f801600 -#define HW_USB_END 0x1f801700 -#define HW_FW_START 0x1f808400 -#define HW_FW_END 0x1f808550 -#define HW_SPU2_START 0x1f801c00 -#define HW_SPU2_END 0x1f801e00 +static const u32 + HW_USB_START = 0x1f801600, + HW_USB_END = 0x1f801700, + HW_FW_START = 0x1f808400, + HW_FW_END = 0x1f808550, // end addr for FW is a guess... + HW_SPU2_START = 0x1f801c00, + HW_SPU2_END = 0x1f801e00; + +static const u32 + HW_SSBUS_SPD_ADDR = 0x1f801000, + HW_SSBUS_PIO_ADDR = 0x1f801004, + HW_SSBUS_SPD_DELAY = 0x1f801008, + HW_SSBUS_DEV1_DELAY = 0x1f80100C, + HW_SSBUS_ROM_DELAY = 0x1f801010, + HW_SSBUS_SPU_DELAY = 0x1f801014, + HW_SSBUS_DEV5_DELAY = 0x1f801018, + HW_SSBUS_PIO_DELAY = 0x1f80101c, + HW_SSBUS_COM_DELAY = 0x1f801020, + + HW_SIO_DATA = 0x1f801040, // SIO read/write register + HW_SIO_STAT = 0x1f801044, + HW_SIO_MODE = 0x1f801048, + HW_SIO_CTRL = 0x1f80104a, + HW_SIO_BAUD = 0x1f80104e, + + HW_IREG = 0x1f801070, + HW_IMASK = 0x1f801074, + HW_ICTRL = 0x1f801078, + + HW_SSBUS_DEV1_ADDR = 0x1f801400, + HW_SSBUS_SPU_ADDR = 0x1f801404, + HW_SSBUS_DEV5_ADDR = 0x1f801408, + HW_SSBUS_SPU1_ADDR = 0x1f80140c, + HW_SSBUS_DEV9_ADDR3 = 0x1f801410, + HW_SSBUS_SPU1_DELAY = 0x1f801414, + HW_SSBUS_DEV9_DELAY2= 0x1f801418, + HW_SSBUS_DEV9_DELAY3= 0x1f80141c, + HW_SSBUS_DEV9_DELAY1= 0x1f801420, + + HW_ICFG = 0x1f801450, + HW_DEV9_DATA = 0x1f80146e, // DEV9 read/write register + + // CDRom registers are used for various command, status, and data stuff. + + HW_CDR_DATA0 = 0x1f801800, // CDROM multipurpose data register 1 + HW_CDR_DATA1 = 0x1f801801, // CDROM multipurpose data register 2 + HW_CDR_DATA2 = 0x1f801802, // CDROM multipurpose data register 3 + HW_CDR_DATA3 = 0x1f801803, // CDROM multipurpose data register 4 + + // SIO2 is a DMA interface for the SIO. + + HW_SIO2_DATAIN = 0x1F808260, + HW_SIO2_FIFO = 0x1f808264, + HW_SIO2_CTRL = 0x1f808268, + HW_SIO2_RECV1 = 0x1f80826c, + HW_SIO2_RECV2 = 0x1f808270, + HW_SIO2_RECV3 = 0x1f808274, + HW_SIO2_INTR = 0x1f808280; + /* Registers for the IOP Counters */ enum IOPCountRegs @@ -37,7 +88,7 @@ enum IOPCountRegs IOP_T2_COUNT = 0x1f801120, IOP_T3_COUNT = 0x1f801480, IOP_T4_COUNT = 0x1f801490, - IOP_T5_COUNT = 0x1f8014a0, + IOP_T5_COUNT = 0x1f8014a0, IOP_T0_MODE = 0x1f801104, IOP_T1_MODE = 0x1f801114, @@ -46,7 +97,7 @@ enum IOPCountRegs IOP_T4_MODE = 0x1f801494, IOP_T5_MODE = 0x1f8014a4, - IOP_T0_TARGET= 0x1f801108, + IOP_T0_TARGET = 0x1f801108, IOP_T1_TARGET = 0x1f801118, IOP_T2_TARGET = 0x1f801128, IOP_T3_TARGET = 0x1f801488, @@ -166,6 +217,8 @@ extern void PSX_INT( IopEventId n, s32 ecycle); extern void psxSetNextBranch( u32 startCycle, s32 delta ); extern void psxSetNextBranchDelta( s32 delta ); +extern int iopTestCycle( u32 startCycle, s32 delta ); +extern void _iopTestInterrupts(); void psxHwReset(); u8 psxHwRead8 (u32 add); @@ -192,5 +245,3 @@ void psxHwConstWrite16(u32 add, int mmreg); void psxHwConstWrite32(u32 add, int mmreg); int psxHw4ConstRead8 (u32 x86reg, u32 add, u32 sign); void psxHw4ConstWrite8(u32 add, int mmreg); - -#endif /* __PSXHW_H__ */ diff --git a/pcsx2/IopMem.cpp b/pcsx2/IopMem.cpp index f44df6ac9f..a9580a1cdb 100644 --- a/pcsx2/IopMem.cpp +++ b/pcsx2/IopMem.cpp @@ -72,13 +72,9 @@ void psxMemReset() for (int i=0; i<0x0080; i++) { psxMemWLUT[i + 0x0000] = (uptr)&psxM[(i & 0x1f) << 16]; - //psxMemWLUT[i + 0x8000] = (uptr)&psxM[(i & 0x1f) << 16]; - //psxMemWLUT[i + 0xa000] = (uptr)&psxM[(i & 0x1f) << 16]; // RLUTs, accessed through WLUT. psxMemWLUT[i + 0x2000] = (uptr)&psxM[(i & 0x1f) << 16]; - //psxMemWLUT[i + 0x18000] = (uptr)&psxM[(i & 0x1f) << 16]; - //psxMemWLUT[i + 0x1a000] = (uptr)&psxM[(i & 0x1f) << 16]; } // A few single-page allocations for things we store in special locations. @@ -94,25 +90,17 @@ void psxMemReset() for (int i=0; i<0x0040; i++) { psxMemWLUT[i + 0x2000 + 0x1fc0] = (uptr)&PS2MEM_ROM[i << 16]; - //psxMemWLUT[i + 0x19fc0] = (uptr)&PS2MEM_ROM[i << 16]; - //psxMemWLUT[i + 0x1bfc0] = (uptr)&PS2MEM_ROM[i << 16]; } for (int i=0; i<0x0004; i++) { psxMemWLUT[i + 0x2000 + 0x1e00] = (uptr)&PS2MEM_ROM1[i << 16]; - //psxMemWLUT[i + 0x19e00] = (uptr)&PS2MEM_ROM1[i << 16]; - //psxMemWLUT[i + 0x1be00] = (uptr)&PS2MEM_ROM1[i << 16]; } // sif!! (which is read only? (air)) psxMemWLUT[0x2000 + 0x1d00] = (uptr)psxS; //psxMemWLUT[0x1bd00] = (uptr)psxS; - // why isn't scratchpad read/write? (air) - //for (i=0; i<0x0001; i++) psxMemWLUT[i + 0x1d00] = (uptr)&psxS[i << 16]; - //for (i=0; i<0x0001; i++) psxMemWLUT[i + 0xbd00] = (uptr)&psxS[i << 16]; - // this one looks like an old hack for some special write-only memory area, // but leaving it in for reference (air) //for (i=0; i<0x0008; i++) psxMemWLUT[i + 0xbfc0] = (uptr)&psR[i << 16]; @@ -136,10 +124,21 @@ u8 iopMemRead8(u32 mem) if (t == 0x1f80) { - if (mem < 0x1f801000) - return psxHu8(mem); - else - return psxHwRead8(mem); + switch( mem & 0xf000 ) + { + case 0x1000: return IopMemory::iopHwRead8_Page1(mem); + case 0x3000: return IopMemory::iopHwRead8_Page3(mem); + case 0x8000: return IopMemory::iopHwRead8_Page8(mem); + + // code for regression testing -- selectively enable these to help narrow out + // which register became buggy with the new Hw handlers. + //case 0x1000: return psxHwRead8(mem); + //case 0x3000: return psxHwRead8(mem); + //case 0x8000: return psxHwRead8(mem); + + default: + return psxHu8(mem); + } } else if (t == 0x1f40) { @@ -169,10 +168,21 @@ u16 iopMemRead16(u32 mem) if (t == 0x1f80) { - if (mem < 0x1f801000) - return psxHu16(mem); - else - return psxHwRead16(mem); + switch( mem & 0xf000 ) + { + case 0x1000: return IopMemory::iopHwRead16_Page1(mem); + case 0x3000: return IopMemory::iopHwRead16_Page3(mem); + case 0x8000: return IopMemory::iopHwRead16_Page8(mem); + + // code for regression testing -- selectively enable these to help narrow out + // which register became buggy with the new Hw handlers. + //case 0x1000: return psxHwRead16(mem); + //case 0x3000: return psxHwRead16(mem); + //case 0x8000: return psxHwRead16(mem); + + default: + return psxHu16(mem); + } } else { @@ -224,10 +234,21 @@ u32 iopMemRead32(u32 mem) if (t == 0x1f80) { - if (mem < 0x1f801000) - return psxHu32(mem); - else - return psxHwRead32(mem); + switch( mem & 0xf000 ) + { + case 0x1000: return IopMemory::iopHwRead32_Page1(mem); + case 0x3000: return IopMemory::iopHwRead32_Page3(mem); + case 0x8000: return IopMemory::iopHwRead32_Page8(mem); + + // code for regression testing -- selectively enable these to help narrow out + // which register became buggy with the new Hw handlers. + //case 0x1000: return psxHwRead32(mem); + //case 0x3000: return psxHwRead32(mem); + //case 0x8000: return psxHwRead32(mem); + + default: + return psxHu32(mem); + } } else { //see also Hw.c @@ -282,10 +303,31 @@ void iopMemWrite8(u32 mem, u8 value) if (t == 0x1f80) { - if (mem < 0x1f801000) - psxHu8(mem) = value; - else - psxHwWrite8(mem, value); + switch( mem & 0xf000 ) + { + // Regression testing: selectively pass ranges of registers to new or old + // handlers. Helps narrow out which area of registers is erroring out. + /*case 0x1000: + if( mem >= 0x1f801000 ) + psxHwWrite8( mem, value ); + else + IopMemory::iopHwWrite8_Page1(mem,value); + break;*/ + + case 0x1000: IopMemory::iopHwWrite8_Page1(mem,value); break; + case 0x3000: IopMemory::iopHwWrite8_Page3(mem,value); break; + case 0x8000: IopMemory::iopHwWrite8_Page8(mem,value); break; + + // code for regression testing -- selectively enable these to help narrow out + // which register became buggy with the new Hw handlers. + //case 0x1000: psxHwWrite8(mem,value); break; + //case 0x3000: psxHwWrite8(mem,value); break; + //case 0x8000: psxHwWrite8(mem,value); break; + + default: + psxHu8(mem) = value; + break; + } } else if (t == 0x1f40) { @@ -323,10 +365,29 @@ void iopMemWrite16(u32 mem, u16 value) if (t == 0x1f80) { - if (mem < 0x1f801000) - psxHu16(mem) = value; - else - psxHwWrite16(mem, value); + switch( mem & 0xf000 ) + { + // Regression testing: selectively pass ranges of registers to new or old + // handlers. Helps narrow out which area of registers is erroring out. + /*case 0x1000: + if( mem >= 0x1f801000 ) + psxHwWrite16( mem, value ); + else + IopMemory::iopHwWrite16_Page1(mem,value); + break;*/ + + case 0x1000: IopMemory::iopHwWrite16_Page1(mem,value); break; + case 0x3000: IopMemory::iopHwWrite16_Page3(mem,value); break; + case 0x8000: IopMemory::iopHwWrite16_Page8(mem,value); break; + + //case 0x1000: psxHwWrite16(mem,value); break; + //case 0x3000: psxHwWrite16(mem,value); break; + //case 0x8000: psxHwWrite16(mem,value); break; + + default: + psxHu16(mem) = value; + break; + } } else { u8* p = (u8 *)(psxMemWLUT[mem >> 16]); @@ -386,10 +447,29 @@ void iopMemWrite32(u32 mem, u32 value) if (t == 0x1f80) { - if (mem < 0x1f801000) - psxHu32(mem) = value; - else - psxHwWrite32(mem, value); + switch( mem & 0xf000 ) + { + // Regression testing: selectively pass ranges of registers to new or old + // handlers. Helps narrow out which area of registers is erroring out. + /*case 0x1000: + if( mem >= 0x1f801528 ) + psxHwWrite32( mem, value ); + else + IopMemory::iopHwWrite32_Page1(mem,value); + break;*/ + + case 0x1000: IopMemory::iopHwWrite32_Page1(mem,value); break; + case 0x3000: IopMemory::iopHwWrite32_Page3(mem,value); break; + case 0x8000: IopMemory::iopHwWrite32_Page8(mem,value); break; + + //case 0x1000: psxHwWrite32(mem,value); break; + //case 0x3000: psxHwWrite32(mem,value); break; + //case 0x8000: psxHwWrite32(mem,value); break; + + default: + psxHu32(mem) = value; + break; + } } else { //see also Hw.c diff --git a/pcsx2/IopMem.h b/pcsx2/IopMem.h index 21581df609..dc62657c45 100644 --- a/pcsx2/IopMem.h +++ b/pcsx2/IopMem.h @@ -16,8 +16,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -#ifndef __PSXMEMORY_H__ -#define __PSXMEMORY_H__ +#pragma once extern u8 *psxM; extern u8 *psxP; @@ -90,21 +89,40 @@ void iopMemWrite32(u32 mem, u32 value); // x86reg and mmreg are always x86 regs void psxRecMemRead8(); -int psxRecMemConstRead8(u32 x86reg, u32 mem, u32 sign); - void psxRecMemRead16(); -int psxRecMemConstRead16(u32 x86reg, u32 mem, u32 sign); - void psxRecMemRead32(); -int psxRecMemConstRead32(u32 x86reg, u32 mem); - void psxRecMemWrite8(); -int psxRecMemConstWrite8(u32 mem, int mmreg); - void psxRecMemWrite16(); -int psxRecMemConstWrite16(u32 mem, int mmreg); - void psxRecMemWrite32(); -int psxRecMemConstWrite32(u32 mem, int mmreg); -#endif /* __PSXMEMORY_H__ */ +namespace IopMemory +{ + // Sif functions not made yet (will for future Iop improvements): + extern u8 __fastcall SifRead8( u32 iopaddr ); + extern u16 __fastcall SifRead16( u32 iopaddr ); + extern u32 __fastcall SifRead32( u32 iopaddr ); + + extern void __fastcall SifWrite8( u32 iopaddr, u8 data ); + extern void __fastcall SifWrite16( u32 iopaddr, u16 data ); + extern void __fastcall SifWrite32( u32 iopaddr, u32 data ); + + extern u8 __fastcall iopHwRead8_Page1( u32 iopaddr ); + extern u8 __fastcall iopHwRead8_Page3( u32 iopaddr ); + extern u8 __fastcall iopHwRead8_Page8( u32 iopaddr ); + extern u16 __fastcall iopHwRead16_Page1( u32 iopaddr ); + extern u16 __fastcall iopHwRead16_Page3( u32 iopaddr ); + extern u16 __fastcall iopHwRead16_Page8( u32 iopaddr ); + extern u32 __fastcall iopHwRead32_Page1( u32 iopaddr ); + extern u32 __fastcall iopHwRead32_Page3( u32 iopaddr ); + extern u32 __fastcall iopHwRead32_Page8( u32 iopaddr ); + + extern void __fastcall iopHwWrite8_Page1( u32 iopaddr, u8 data ); + extern void __fastcall iopHwWrite8_Page3( u32 iopaddr, u8 data ); + extern void __fastcall iopHwWrite8_Page8( u32 iopaddr, u8 data ); + extern void __fastcall iopHwWrite16_Page1( u32 iopaddr, u16 data ); + extern void __fastcall iopHwWrite16_Page3( u32 iopaddr, u16 data ); + extern void __fastcall iopHwWrite16_Page8( u32 iopaddr, u16 data ); + extern void __fastcall iopHwWrite32_Page1( u32 iopaddr, u32 data ); + extern void __fastcall iopHwWrite32_Page3( u32 iopaddr, u32 data ); + extern void __fastcall iopHwWrite32_Page8( u32 iopaddr, u32 data ); +} \ No newline at end of file diff --git a/pcsx2/ps2/Iop/IopHwRead.cpp b/pcsx2/ps2/Iop/IopHwRead.cpp new file mode 100644 index 0000000000..85202e74c3 --- /dev/null +++ b/pcsx2/ps2/Iop/IopHwRead.cpp @@ -0,0 +1,445 @@ +/* Pcsx2 - Pc Ps2 Emulator + * Copyright (C) 2002-2009 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 "IopHw_Internal.h" + +namespace IopMemory +{ +using namespace Internal; + +////////////////////////////////////////////////////////////////////////////////////////// +// +u8 __fastcall iopHwRead8_Page1( u32 addr ) +{ + // all addresses are assumed to be prefixed with 0x1f801xxx: + jASSUME( (addr >> 12) == 0x1f801 ); + + u32 masked_addr = addr & 0x0fff; + + u8 ret; // using a return var can be helpful in debugging. + switch( masked_addr ) + { + mcase(HW_SIO_DATA): ret = sioRead8(); break; + + // for use of serial port ignore for now + //case 0x50: ret = serial_read8(); break; + + mcase(HW_DEV9_DATA): ret = DEV9read8( addr ); break; + + mcase(HW_CDR_DATA0): ret = cdrRead0(); break; + mcase(HW_CDR_DATA1): ret = cdrRead1(); break; + mcase(HW_CDR_DATA2): ret = cdrRead2(); break; + mcase(HW_CDR_DATA3): ret = cdrRead3(); break; + + default: + if( masked_addr >= 0x100 && masked_addr < 0x130 ) + { + DevCon::Notice( "*Hardware Read8 from Counter16 [ignored] [addr=0x%02x]", params addr, psxHu8(addr) ); + ret = psxHu8( addr ); + } + else if( masked_addr >= 0x480 && masked_addr < 0x4a0 ) + { + DevCon::Notice( "*Hardware Read8 from Counter32 [ignored] [addr=0x%02x]", params addr, psxHu8(addr) ); + ret = psxHu8( addr ); + } + else if( (masked_addr >= pgmsk(HW_USB_START)) && (masked_addr < pgmsk(HW_USB_END)) ) + { + ret = USBread8( addr ); + PSXHW_LOG( "Hardware Read8 from USB: addr 0x%08x = 0x%02x", addr, ret ); + } + else + { + ret = psxHu8(addr); + PSXHW_LOG( "*Unknown Hardware Read8 from addr 0x%08x = 0x%02x", addr, ret ); + } + return ret; + } + + PSXHW_LOG( "*Hardware Read8 from %s, addr 0x%08x = 0x%02x", _log_GetIopHwName( addr ), addr, ret ); + return ret; +} + +////////////////////////////////////////////////////////////////////////////////////////// +// +u8 __fastcall iopHwRead8_Page3( u32 addr ) +{ + // all addresses are assumed to be prefixed with 0x1f803xxx: + jASSUME( (addr >> 12) == 0x1f803 ); + + u8 ret; + if( addr == 0x1f803100 ) // PS/EE/IOP conf related + ret = 0x10; // Dram 2M + else + ret = psxHu8( addr ); + + PSXHW_LOG( "Hardware Read8 from %s, addr 0x%08x = 0x%02x", _log_GetIopHwName( addr ), addr, psxHu8(addr) ); + return ret; +} + +////////////////////////////////////////////////////////////////////////////////////////// +// +u8 __fastcall iopHwRead8_Page8( u32 addr ) +{ + // all addresses are assumed to be prefixed with 0x1f808xxx: + jASSUME( (addr >> 12) == 0x1f808 ); + + u8 ret; + + if( addr == HW_SIO2_FIFO ) + ret = sio2_fifoOut();//sio2 serial data feed/fifo_out + else + ret = psxHu8( addr ); + + PSXHW_LOG( "Hardware Read8 from %s, addr 0x%08x = 0x%02x", _log_GetIopHwName( addr ), addr, psxHu8(addr) ); + return ret; +} + +////////////////////////////////////////////////////////////////////////////////////////// +// +template< typename T > +static __forceinline T _HwRead_16or32_Page1( u32 addr ) +{ + // all addresses are assumed to be prefixed with 0x1f801xxx: + jASSUME( (addr >> 12) == 0x1f801 ); + + // all addresses should be aligned to the data operand size: + jASSUME( + ( sizeof(T) == 2 && (addr & 1) == 0 ) || + ( sizeof(T) == 4 && (addr & 3) == 0 ) + ); + + u32 masked_addr = pgmsk( addr ); + T ret; + + // ------------------------------------------------------------------------ + // Counters, 16-bit varieties! + // + if( masked_addr >= 0x100 && masked_addr < 0x130 ) + { + int cntidx = ( masked_addr >> 4 ) & 0xf; + switch( masked_addr & 0xf ) + { + case 0x0: + ret = (T)psxRcntRcount16( cntidx ); + break; + + case 0x4: + ret = psxCounters[cntidx].mode; + + // hmm! The old code only did this bitwise math for 16 bit reads. + // Logic indicates it should do the math consistently. Question is, + // should it do the logic for both 16 and 32, or not do logic at all? + + psxCounters[cntidx].mode &= ~0x1800; + psxCounters[cntidx].mode |= 0x400; + break; + + case 0x8: + ret = psxCounters[cntidx].target; + break; + + default: + ret = psxHu32(addr); + break; + } + } + // ------------------------------------------------------------------------ + // Counters, 32-bit varieties! + // + else if( masked_addr >= 0x480 && masked_addr < 0x4b0 ) + { + int cntidx = (( masked_addr >> 4 ) & 0xf) - 5; + switch( masked_addr & 0xf ) + { + case 0x0: + ret = (T)psxRcntRcount32( cntidx ); + break; + + case 0x2: + ret = (T)(psxRcntRcount32( cntidx ) >> 16); + break; + + case 0x4: + ret = psxCounters[cntidx].mode; + + // hmm! The old code only did the following bitwise math for 16 bit reads. + // Logic indicates it should do the math consistently. Question is, + // should it do the logic for both 16 and 32, or not do logic at all? + + psxCounters[cntidx].mode &= ~0x1800; + psxCounters[cntidx].mode |= 0x400; + break; + + case 0x8: + ret = psxCounters[cntidx].target; + break; + + case 0xa: + ret = psxCounters[cntidx].target >> 16; + break; + + default: + ret = psxHu32(addr); + break; + } + } + // ------------------------------------------------------------------------ + // USB, with both 16 and 32 bit interfaces + // + else if( masked_addr >= pgmsk(HW_USB_START) && masked_addr < pgmsk(HW_USB_END) ) + { + ret = (sizeof(T) == 2) ? USBread16( addr ) : USBread32( addr ); + } + // ------------------------------------------------------------------------ + // SPU2, accessible in 16 bit mode only! + // + else if( masked_addr >= pgmsk(HW_SPU2_START) && masked_addr < pgmsk(HW_SPU2_END) ) + { + if( sizeof(T) == 2 ) + ret = SPU2read( addr ); + else + { + DevCon::Notice( "*PCSX2* SPU2 Hardware Read32 (addr=0x%08X)? What manner of trickery is this?!", params addr ); + ret = psxHu32(addr); + } + } + else + { + switch( masked_addr ) + { + // ------------------------------------------------------------------------ + mcase(HW_SIO_DATA): + ret = sioRead8(); + ret |= sioRead8() << 8; + if( sizeof(T) == 4 ) + { + ret |= sioRead8() << 16; + ret |= sioRead8() << 24; + } + break; + + mcase(HW_SIO_STAT): + ret = sio.StatReg; + break; + + mcase(HW_SIO_MODE): + ret = sio.ModeReg; + if( sizeof(T) == 4 ) + { + // My guess on 32-bit accesses. Dunno yet what the real hardware does. --air + ret |= sio.CtrlReg << 16; + } + break; + + mcase(HW_SIO_CTRL): + ret = sio.CtrlReg; + break; + + mcase(HW_SIO_BAUD): + ret = sio.BaudReg; + break; + + // ------------------------------------------------------------------------ + //Serial port stuff not support now ;P + // case 0x050: hard = serial_read32(); break; + // case 0x054: hard = serial_status_read(); break; + // case 0x05a: hard = serial_control_read(); break; + // case 0x05e: hard = serial_baud_read(); break; + + mcase(HW_ICTRL): + ret = psxHu32(0x1078); + psxHu32(0x1078) = 0; + break; + + mcase(HW_ICTRL+2): + ret = psxHu16(0x107a); + psxHu32(0x1078) = 0; // most likely should clear all 32 bits here. + break; + + // ------------------------------------------------------------------------ + // Soon-to-be outdated SPU2 DMA hack (spu2 manages its own DMA MADR). + // + mcase(0x1f8010C0): + ret = SPU2ReadMemAddr(0); + break; + + mcase(0x1f801500): + ret = SPU2ReadMemAddr(1); + break; + + // ------------------------------------------------------------------------ + // Legacy GPU emulation (not needed). + // The IOP emulates the GPU itself through the EE's hardware. + + /*case 0x810: + PSXHW_LOG("GPU DATA 32bit write %lx", value); + GPU_writeData(value); return; + case 0x814: + PSXHW_LOG("GPU STATUS 32bit write %lx", value); + GPU_writeStatus(value); return; + + case 0x820: + mdecWrite0(value); break; + case 0x824: + mdecWrite1(value); break;*/ + + // ------------------------------------------------------------------------ + + mcase(0x1f80146e): + ret = DEV9read16( addr ); + break; + + default: + ret = psxHu32(addr); + break; + } + } + + PSXHW_LOG( "Hardware Read%s from %s, addr 0x%08x = 0x%04x", + (sizeof(T) == 2) ? "16" : "32", _log_GetIopHwName( addr ), addr, ret + ); + return ret; +} + +// Some Page 2 mess? I love random question marks for comments! +//case 0x1f802030: hard = //int_2000???? +//case 0x1f802040: hard =//dip switches...?? + +////////////////////////////////////////////////////////////////////////////////////////// +// +u16 __fastcall iopHwRead16_Page1( u32 addr ) +{ + return _HwRead_16or32_Page1( addr ); +} + +////////////////////////////////////////////////////////////////////////////////////////// +// +u16 __fastcall iopHwRead16_Page3( u32 addr ) +{ + // all addresses are assumed to be prefixed with 0x1f803xxx: + jASSUME( (addr >> 12) == 0x1f803 ); + + u16 ret = psxHu16(addr); + PSXHW_LOG( "Hardware Read16 from %s, addr 0x%08x = 0x%04x", _log_GetIopHwName( addr ), addr, ret ); + return ret; +} + +////////////////////////////////////////////////////////////////////////////////////////// +// +u16 __fastcall iopHwRead16_Page8( u32 addr ) +{ + // all addresses are assumed to be prefixed with 0x1f808xxx: + jASSUME( (addr >> 12) == 0x1f808 ); + + u16 ret = psxHu16(addr); + PSXHW_LOG( "Hardware Read16 from %s, addr 0x%08x = 0x%04x", _log_GetIopHwName( addr ), addr, ret ); + return ret; +} + +////////////////////////////////////////////////////////////////////////////////////////// +// +u32 __fastcall iopHwRead32_Page1( u32 addr ) +{ + return _HwRead_16or32_Page1( addr ); +} + +////////////////////////////////////////////////////////////////////////////////////////// +// +u32 __fastcall iopHwRead32_Page3( u32 addr ) +{ + // all addresses are assumed to be prefixed with 0x1f803xxx: + jASSUME( (addr >> 12) == 0x1f803 ); + const u32 ret = psxHu32(addr); + PSXHW_LOG( "Hardware Read32 from %s, addr 0x%08x = 0x%08x", _log_GetIopHwName( addr ), addr, ret ); + return ret; +} + +////////////////////////////////////////////////////////////////////////////////////////// +// +u32 __fastcall iopHwRead32_Page8( u32 addr ) +{ + // all addresses are assumed to be prefixed with 0x1f808xxx: + jASSUME( (addr >> 12) == 0x1f808 ); + + u32 masked_addr = addr & 0x0fff; + u32 ret; + + if( masked_addr >= 0x200 ) + { + if( masked_addr < 0x240 ) + { + const int parm = (masked_addr-0x200) / 4; + ret = sio2_getSend3( parm ); + } + else if( masked_addr < 0x260 ) + { + // SIO2 Send commands alternate registers. First reg maps to Send1, second + // to Send2, third to Send1, etc. And the following clever code does this: + + const int parm = (masked_addr-0x240) / 8; + ret = (masked_addr & 4) ? sio2_getSend2( parm ) : sio2_getSend1( parm ); + } + else + { + switch( masked_addr ) + { + mcase(0x1f801264): // unknown / reserved. + ret = psxHu32(addr); + break; + + mcase(HW_SIO2_CTRL): + ret = sio2_getCtrl(); + break; + + mcase(HW_SIO2_RECV1): + ret = sio2_getRecv1(); + break; + + mcase(HW_SIO2_RECV2): + ret = sio2_getRecv2(); + break; + + mcase(HW_SIO2_RECV3): + ret = sio2_getRecv3(); + break; + + mcase(0x1f808278): + ret = sio2_get8278(); + break; + + mcase(0x1f80827C): + ret = sio2_get827C(); + break; + + mcase(HW_SIO2_INTR): + ret = sio2_getIntr(); + break; + + jNO_DEFAULT; + } + } + } + else ret = psxHu32(addr); + + PSXHW_LOG( "Hardware Read32 from %s, addr 0x%08x = 0x%02x", _log_GetIopHwName( addr ), addr, ret ); + return ret; +} + +} + diff --git a/pcsx2/ps2/Iop/IopHwWrite.cpp b/pcsx2/ps2/Iop/IopHwWrite.cpp new file mode 100644 index 0000000000..04c5e61ce0 --- /dev/null +++ b/pcsx2/ps2/Iop/IopHwWrite.cpp @@ -0,0 +1,529 @@ +/* Pcsx2 - Pc Ps2 Emulator + * Copyright (C) 2002-2009 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 "IopHw_Internal.h" + +namespace IopMemory { + +using namespace Internal; + +////////////////////////////////////////////////////////////////////////////////////////// +// +void __fastcall iopHwWrite8_Page1( u32 addr, u8 val ) +{ + // all addresses are assumed to be prefixed with 0x1f801xxx: + jASSUME( (addr >> 12) == 0x1f801 ); + + u32 masked_addr = pgmsk( addr ); + + switch( masked_addr ) + { + mcase(HW_SIO_DATA): sioWrite8( val ); break; + + // for use of serial port ignore for now + //case 0x50: serial_write8( val ); break; + + mcase(HW_DEV9_DATA): DEV9write8( addr, val ); break; + + mcase(HW_CDR_DATA0): cdrWrite0( val ); break; + mcase(HW_CDR_DATA1): cdrWrite1( val ); break; + mcase(HW_CDR_DATA2): cdrWrite2( val ); break; + mcase(HW_CDR_DATA3): cdrWrite3( val ); break; + + default: + if( masked_addr >= 0x100 && masked_addr < 0x130 ) + { + DevCon::Notice( "*Hardware Write8 to Counter16 [ignored] [addr=0x%02x]", params addr, psxHu8(addr) ); + psxHu8( addr ) = val; + } + else if( masked_addr >= 0x480 && masked_addr < 0x4a0 ) + { + DevCon::Notice( "*Hardware Write8 to Counter32 [ignored] [addr=0x%02x]", params addr, psxHu8(addr) ); + psxHu8( addr ) = val; + } + else if( masked_addr >= pgmsk(HW_USB_START) && masked_addr < pgmsk(HW_USB_END) ) + { + USBwrite8( addr, val ); + } + else + { + psxHu8(addr) = val; + } + break; + } + + PSXHW_LOG( "*Hardware Write8 to %s, addr 0x%08x = 0x%02x\n", _log_GetIopHwName(addr), addr, val ); +} + +static char g_pbuf[1024]; +static int g_pbufi; + +void __fastcall iopHwWrite8_Page3( u32 addr, u8 val ) +{ + // all addresses are assumed to be prefixed with 0x1f803xxx: + jASSUME( (addr >> 12) == 0x1f803 ); + + if( addr == 0x1f80380c ) // STDOUT + { + bool flush = false; + + // Terminate lines on CR or full buffers, and ignore \n's if the string contents + // are empty (otherwise terminate on \n too!) + if( ( val == '\r' ) || ( g_pbufi == 1023 ) || + ( val == '\n' && g_pbufi != 0 ) ) + { + g_pbuf[g_pbufi] = 0; + DevCon::WriteLn( Color_Cyan, g_pbuf ); + g_pbufi = 0; + } + else if( val != '\n' ) + { + g_pbuf[g_pbufi++] = val; + } + } + + PSXHW_LOG( "Hardware Write8 to %s, addr 0x%08x = 0x%02x", _log_GetIopHwName(addr), addr, psxHu8(addr) ); + psxHu8( addr ) = val; +} + +void __fastcall iopHwWrite8_Page8( u32 addr, u8 val ) +{ + // all addresses are assumed to be prefixed with 0x1f808xxx: + jASSUME( (addr >> 12) == 0x1f808 ); + + if( addr == HW_SIO2_DATAIN ) // sio2 serial data feed input + sio2_serialIn( val ); + else + psxHu8( addr ) = val; + + PSXHW_LOG( "Hardware Write8 to %s, addr 0x%08x = 0x%02x", _log_GetIopHwName(addr), addr, psxHu8(addr) ); + +} + +// Template-compatible version of the psxHu macro. Used for writing. +#define psxHu(mem) (*(u32*)&psxH[(mem) & 0xffff]) + +////////////////////////////////////////////////////////////////////////////////////////// +// Templated handler for both 32 and 16 bit write operations, to Page 1 registers. +// +template< typename T > +static __forceinline void _HwWrite_16or32_Page1( u32 addr, T val ) +{ + // all addresses are assumed to be prefixed with 0x1f801xxx: + jASSUME( (addr >> 12) == 0x1f801 ); + + // all addresses should be aligned to the data operand size: + jASSUME( + ( sizeof(T) == 2 && (addr & 1) == 0 ) || + ( sizeof(T) == 4 && (addr & 3) == 0 ) + ); + + u32 masked_addr = addr & 0x0fff; + + // ------------------------------------------------------------------------ + // Counters, 16-bit varieties! + // + if( masked_addr >= 0x100 && masked_addr < 0x130 ) + { + int cntidx = ( masked_addr >> 4 ) & 0xf; + switch( masked_addr & 0xf ) + { + case 0x0: + psxRcntWcount16( cntidx, val ); + break; + + case 0x4: + psxRcntWmode16( cntidx, val ); + break; + + case 0x8: + psxRcntWtarget16( cntidx, val ); + break; + + default: + psxHu(addr) = val; + break; + } + } + // ------------------------------------------------------------------------ + // Counters, 32-bit varieties! + // + else if( masked_addr >= 0x480 && masked_addr < 0x4b0 ) + { + int cntidx = (( masked_addr >> 4 ) & 0xf) - 5; + switch( masked_addr & 0xf ) + { + case 0x0: + psxRcntWcount32( cntidx, val ); + break; + + case 0x2: // Count HiWord + psxRcntWcount32( cntidx, (u32)val << 16 ); + break; + + case 0x4: + psxRcntWmode32( cntidx, val ); + break; + + case 0x8: + psxRcntWtarget32( cntidx, val ); + break; + + case 0xa: // Target HiWord + psxRcntWtarget32( cntidx, (u32)val << 16); + break; + + default: + psxHu(addr) = val; + break; + } + } + // ------------------------------------------------------------------------ + // USB, with both 16 and 32 bit interfaces + // + else if( (masked_addr >= pgmsk(HW_USB_START)) && (masked_addr < pgmsk(HW_USB_END)) ) + { + if( sizeof(T) == 2 ) USBwrite16( addr, val ); else USBwrite32( addr, val ); + } + // ------------------------------------------------------------------------ + // SPU2, accessible in 16 bit mode only! + // + else if( (masked_addr >= pgmsk(HW_SPU2_START)) && (masked_addr < pgmsk(HW_SPU2_END)) ) + { + if( sizeof(T) == 2 ) + SPU2write( addr, val ); + else + { + DevCon::Notice( "*PCSX2* SPU2 Hardware Write32 (addr=0x%08X)? What manner of trickery is this?!", params addr ); + //psxHu(addr) = val; + } + } + else + { + switch( masked_addr ) + { + // ------------------------------------------------------------------------ + mcase(HW_SIO_DATA): + sioWrite8( (u8)val ); + sioWrite8( (u8)(val >> 8) ); + if( sizeof(T) == 4 ) + { + // u32 gets rid of compiler warnings when using the u16 version of this template + sioWrite8( (u8)((u32)val >> 16) ); + sioWrite8( (u8)((u32)val >> 24) ); + } + break; + + mcase(HW_SIO_STAT): // read-only? + //regname = "SIO_STAT (read-only?)"; + //sio.StatReg; + break; + + mcase(HW_SIO_MODE): + sio.ModeReg = (u16)val; + if( sizeof(T) == 4 ) + { + // My guess on 32-bit accesses. Dunno yet what the real hardware does. --air + sio.CtrlReg = (u16)((u32)val >> 16); + } + break; + + mcase(HW_SIO_CTRL): + sio.CtrlReg = (u16)val; + break; + + mcase(HW_SIO_BAUD): + sio.BaudReg = (u16)val; + break; + + // ------------------------------------------------------------------------ + //Serial port stuff not support now ;P + // case 0x050: serial_write16( val ); break; + // case 0x054: serial_status_write( val ); break; + // case 0x05a: serial_control_write( val ); break; + // case 0x05e: serial_baud_write( val ); break; + + mcase(HW_IREG): + psxHu(addr) &= val; + break; + + mcase(HW_IREG+2): + psxHu(addr) &= val; + break; + + mcase(HW_IMASK): + psxHu(addr) = val; + iopTestIntc(); + break; + + mcase(HW_IMASK+2): + psxHu(addr) = val; + iopTestIntc(); + break; + + mcase(HW_ICTRL): + psxHu(addr) = val; + iopTestIntc(); + break; + + mcase(HW_ICTRL+2): + psxHu(addr) = val; + iopTestIntc(); + break; + + // ------------------------------------------------------------------------ + // Soon-to-be outdated SPU2 DMA hack (spu2 manages its own DMA MADR currently, + // as asinine as that may seem). + // + mcase(0x1f8010C0): + SPU2WriteMemAddr( 0, val ); + HW_DMA4_MADR = val; + break; + + mcase(0x1f801500): + SPU2WriteMemAddr( 1, val ); + HW_DMA7_MADR = val; + break; + + // ------------------------------------------------------------------------ + // + /* + mcase(0x1f801088): // DMA0 CHCR -- MDEC IN [ignored] + DmaExec(0); + break; + + mcase(0x1f801098): // DMA1 CHCR -- MDEC OUT [ignored] + DmaExec(1); + break; + + mcase(0x1f8010a8): // DMA2 CHCR -- GPU [ignored] + DmaExec(2); + break;*/ + + mcase(0x1f8010b8): // DMA3 CHCR -- CDROM + psxHu(addr) = val; + DmaExec(3); + break; + + mcase(0x1f8010c8): // DMA4 CHCR -- SPU2 Core 1 + psxHu(addr) = val; + DmaExecNew(4); + break; + + mcase(0x1f8010e8): // DMA6 CHCR -- OT clear + psxHu(addr) = val; + DmaExec(6); + break; + + mcase(0x1f801508): // DMA7 CHCR -- SPU2 core 2 + psxHu(addr) = val; + DmaExecNew2(7); + break; + + mcase(0x1f801518): // DMA8 CHCR -- DEV9 + psxHu(addr) = val; + DmaExec2(8); + break; + + mcase(0x1f801528): // DMA9 CHCR -- SIF0 + psxHu(addr) = val; + DmaExec2(9); + break; + + mcase(0x1f801538): // DMA10 CHCR -- SIF1 + psxHu(addr) = val; + DmaExec2(10); + break; + + mcase(0x1f801548): // DMA11 CHCR -- SIO2 IN + psxHu(addr) = val; + DmaExec2(11); + break; + + mcase(0x1f801558): // DMA12 CHCR -- SIO2 OUT + psxHu(addr) = val; + DmaExec2(12); + break; + + // ------------------------------------------------------------------------ + // DMA ICR handlers -- General XOR behavior! + + mcase(0x1f8010f4): + { + u32 tmp = (~val) & HW_DMA_ICR; + psxHu(addr) = ((tmp ^ val) & 0xffffff) ^ tmp; + } + break; + + mcase(0x1f8010f6): // ICR_hi (16 bit?) [dunno if it ever happens] + { + const u32 val2 = (u32)val << 16; + const u32 tmp = (~val2) & HW_DMA_ICR; + psxHu(addr) = (((tmp ^ val2) & 0xffffff) ^ tmp) >> 16; + } + break; + + mcase(0x1f801574): + { + u32 tmp = (~val) & HW_DMA_ICR2; + psxHu(addr) = ((tmp ^ val) & 0xffffff) ^ tmp; + } + break; + + mcase(0x1f801576): // ICR2_hi (16 bit?) [dunno if it ever happens] + { + const u32 val2 = (u32)val << 16; + const u32 tmp = (~val2) & HW_DMA_ICR2; + psxHu(addr) = (((tmp ^ val2) & 0xffffff) ^ tmp) >> 16; + } + break; + + // ------------------------------------------------------------------------ + // Legacy GPU emulation (not needed). + // The IOP emulates the GPU itself through the EE's hardware. + + /*case 0x810: + PSXHW_LOG("GPU DATA 32bit write %lx", value); + GPU_writeData(value); return; + case 0x814: + PSXHW_LOG("GPU STATUS 32bit write %lx", value); + GPU_writeStatus(value); return; + + case 0x820: + mdecWrite0(value); break; + case 0x824: + mdecWrite1(value); break;*/ + + // ------------------------------------------------------------------------ + + mcase(HW_DEV9_DATA): + DEV9write16( addr, val ); + psxHu(addr) = val; + break; + + default: + psxHu(addr) = val; + break; + } + } + + PSXHW_LOG( "Hardware Write%s to %s, addr 0x%08x = 0x%04x", + sizeof(T) == 2 ? "16" : "32", _log_GetIopHwName( addr ), addr, val + ); +} + + +////////////////////////////////////////////////////////////////////////////////////////// +// +void __fastcall iopHwWrite16_Page1( u32 addr, u16 val ) +{ + _HwWrite_16or32_Page1( addr, val ); +} + +void __fastcall iopHwWrite16_Page3( u32 addr, u16 val ) +{ + // all addresses are assumed to be prefixed with 0x1f803xxx: + jASSUME( (addr >> 12) == 0x1f803 ); + psxHu16(addr) = val; + PSXHW_LOG( "Hardware Write16 to %s, addr 0x%08x = 0x%04x", _log_GetIopHwName( addr ), addr, val ); +} + +void __fastcall iopHwWrite16_Page8( u32 addr, u16 val ) +{ + // all addresses are assumed to be prefixed with 0x1f808xxx: + jASSUME( (addr >> 12) == 0x1f808 ); + psxHu16(addr) = val; + PSXHW_LOG( "Hardware Write16 to %s, addr 0x%08x = 0x%04x", _log_GetIopHwName( addr ), addr, val ); +} + +////////////////////////////////////////////////////////////////////////////////////////// +// +void __fastcall iopHwWrite32_Page1( u32 addr, u32 val ) +{ + _HwWrite_16or32_Page1( addr, val ); +} + +void __fastcall iopHwWrite32_Page3( u32 addr, u32 val ) +{ + // all addresses are assumed to be prefixed with 0x1f803xxx: + jASSUME( (addr >> 12) == 0x1f803 ); + psxHu16(addr) = val; + PSXHW_LOG( "Hardware Write32 to %s, addr 0x%08x = 0x%04x", _log_GetIopHwName( addr ), addr, val ); +} + +void __fastcall iopHwWrite32_Page8( u32 addr, u32 val ) +{ + // all addresses are assumed to be prefixed with 0x1f808xxx: + jASSUME( (addr >> 12) == 0x1f808 ); + + u32 masked_addr = addr & 0x0fff; + + if( masked_addr >= 0x200 ) + { + if( masked_addr < 0x240 ) + { + const int parm = (masked_addr-0x200) / 4; + sio2_setSend3( parm, val ); + } + else if( masked_addr < 0x260 ) + { + // SIO2 Send commands alternate registers. First reg maps to Send1, second + // to Send2, third to Send1, etc. And the following clever code does this: + + const int parm = (masked_addr-0x240) / 8; + if(masked_addr & 4) sio2_setSend2( parm, val ); else sio2_setSend1( parm, val ); + } + else + { + switch( masked_addr ) + { + case 0x264: // unknown / reserved. + case 0x26C: // recv1 [read-only] + case 0x270: // recv2 [read-only] + case 0x274: // recv3 [read-only] + psxHu32(addr) = val; + break; + + case 0x268: + sio2_setCtrl( val ); + break; + + case 0x278: + sio2_set8278( val ); + break; + + case 0x27C: + sio2_set827C( val ); + break; + + case 0x280: + sio2_setIntr( val ); + break; + + jNO_DEFAULT; + } + } + } + else psxHu32(addr) = val; + + PSXHW_LOG( "Hardware Write32 to %s, addr 0x%08x = 0x%02x", _log_GetIopHwName( addr ), addr, val ); + +} + +} diff --git a/pcsx2/ps2/Iop/IopHw_Internal.h b/pcsx2/ps2/Iop/IopHw_Internal.h new file mode 100644 index 0000000000..1a78d64bec --- /dev/null +++ b/pcsx2/ps2/Iop/IopHw_Internal.h @@ -0,0 +1,204 @@ +/* Pcsx2 - Pc Ps2 Emulator + * Copyright (C) 2002-2009 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 + */ + +#pragma once + +#include "IopCommon.h" + +namespace IopMemory { +namespace Internal { + +////////////////////////////////////////////////////////////////////////////////////////// +// Masking helper so that I can use the fully qualified address for case statements. +// Switches are based on the bottom 12 bits only, since MSVC tends to optimize switches +// better when it has a limited width operand to work with. :) +// +#define pgmsk( src ) ( (src) & 0x0fff ) +#define mcase( src ) case pgmsk(src) + + +////////////////////////////////////////////////////////////////////////////////////////// +// Helper for debug logging of IOP Registers. Takes an input address and retuns a +// register name. +// +// This list is not yet exhaustive. If you spot something that's missing, feel free to +// fill it in any time. :) +// +template< typename T> +static __forceinline const char* _log_GetIopHwName( u32 addr ) +{ + switch( addr ) + { + // ------------------------------------------------------------------------ + // SSBUS -- Two Ess'es? + + case HW_SSBUS_SPD_ADDR: return "SSBUS spd_addr"; + case HW_SSBUS_PIO_ADDR: return "SSBUS pio_addr"; + case HW_SSBUS_SPD_DELAY: return "SSBUS spd_delay"; + case HW_SSBUS_DEV1_DELAY: return "SSBUS dev1_delay"; + case HW_SSBUS_ROM_DELAY: return "SSBUS rom_delay"; + case HW_SSBUS_SPU_DELAY: return "SSBUS spu_delay"; + case HW_SSBUS_DEV5_DELAY: return "SSBUS dev5_delay"; + case HW_SSBUS_PIO_DELAY: return "SSBUS pio_delay"; + case HW_SSBUS_COM_DELAY: return "SSBUS com_delay"; + case HW_SSBUS_DEV1_ADDR: return "SSBUS dev1_addr"; + case HW_SSBUS_SPU_ADDR: return "SSBUS spu_addr"; + case HW_SSBUS_DEV5_ADDR: return "SSBUS dev5_addr"; + case HW_SSBUS_SPU1_ADDR: return "SSBUS spu1_addr"; + case HW_SSBUS_DEV9_ADDR3: return "SSBUS dev9_addr3"; + case HW_SSBUS_SPU1_DELAY: return "SSBUS spu1_delay"; + case HW_SSBUS_DEV9_DELAY2: return "SSBUS dev9_delay2"; + case HW_SSBUS_DEV9_DELAY3: return "SSBUS dev9_delay3"; + case HW_SSBUS_DEV9_DELAY1: return "SSBUS dev9_delay1"; + + // ------------------------------------------------------------------------ + case 0x1f801060:return "RAM_SIZE"; + + case HW_IREG: return "IREG"; + case HW_IREG+2: return "IREG_hi"; + case HW_IMASK: return "IMASK"; + case HW_IMASK+2:return "IMASK_hi"; + case HW_ICTRL: return "ICTRL"; + case HW_ICTRL+2:return "ICTRL_hi"; + case HW_ICFG: return "ICFG"; + + case HW_SIO_DATA: return "SIO"; + case HW_SIO_STAT: return "SIO STAT"; + case HW_SIO_MODE: return ( sizeof(T) == 4 ) ? "SIO_MODE+CTRL" : "SIO MODE"; + case HW_SIO_CTRL: return "SIO CTRL"; + case HW_SIO_BAUD: return "SIO BAUD"; + + case 0x1f8014c0: return "RTC_HOLDMODE"; + case HW_DEV9_DATA: return "DEV9_R_REV/DATA"; + + // ------------------------------------------------------------------------ + // BCR_LABEL -- Selects label for BCR depending on operand size (BCR has hi + // and low values of count and size, respectively) + #define BCR_LABEL( dma ) (sizeof(T)==4) ? dma" BCR" : dma" BCR_size"; + + case 0x1f8010a0: return "DMA2 MADR"; + case 0x1f8010a4: return BCR_LABEL( "DMA2" ); + case 0x1f8010a6: return "DMA2 BCR_count"; + case 0x1f8010a8: return "DMA2 CHCR"; + case 0x1f8010ac: return "DMA2 TADR"; + + case 0x1f8010b0: return "DMA3 MADR"; + case 0x1f8010b4: return BCR_LABEL( "DMA3" ); + case 0x1f8010b6: return "DMA3 BCR_count"; + case 0x1f8010b8: return "DMA3 CHCR"; + case 0x1f8010bc: return "DMA3 TADR"; + + case 0x1f8010c0: return "[SPU]DMA4 MADR"; + case 0x1f8010c4: return BCR_LABEL( "DMA4" ); + case 0x1f8010c6: return "[SPU]DMA4 BCR_count"; + case 0x1f8010c8: return "[SPU]DMA4 CHCR"; + case 0x1f8010cc: return "[SPU]DMA4 TADR"; + + case 0x1f8010f0: return "DMA PCR"; + case 0x1f8010f4: return "DMA ICR"; + case 0x1f8010f6: return "DMA ICR_hi"; + + case 0x1f801500: return "[SPU2]DMA7 MADR"; + case 0x1f801504: return BCR_LABEL( "DMA7" ); + case 0x1f801506: return "[SPU2]DMA7 BCR_count"; + case 0x1f801508: return "[SPU2]DMA7 CHCR"; + case 0x1f80150C: return "[SPU2]DMA7 TADR"; + + case 0x1f801520: return "DMA9 MADR"; + case 0x1f801524: return BCR_LABEL( "DMA9" ); + case 0x1f801526: return "DMA9 BCR_count"; + case 0x1f801528: return "DMA9 CHCR"; + case 0x1f80152C: return "DMA9 TADR"; + + case 0x1f801530: return "DMA10 MADR"; + case 0x1f801534: return BCR_LABEL( "DMA10" ); + case 0x1f801536: return "DMA10 BCR_count"; + case 0x1f801538: return "DMA10 CHCR"; + case 0x1f80153c: return "DMA10 TADR"; + + case 0x1f801570: return "DMA PCR2"; + case 0x1f801574: return "DMA ICR2"; + case 0x1f801576: return "DMA ICR2_hi"; + + case HW_CDR_DATA0: return "CDROM DATA0"; + case HW_CDR_DATA1: return "CDROM DATA1"; + case HW_CDR_DATA2: return "CDROM DATA2"; + case HW_CDR_DATA3: return "CDROM DATA3"; + + case 0x1f80380c: return "STDOUT"; + + // ------------------------------------------------------------------------ + + case HW_SIO2_FIFO: return "SIO2 FIFO"; + case HW_SIO2_CTRL: return "SIO2 CTRL"; + case HW_SIO2_RECV1: return "SIO2 RECV1"; + case HW_SIO2_RECV2: return "SIO2 RECV2"; + case HW_SIO2_RECV3: return "SIO2 RECV3"; + case HW_SIO2_INTR: return "SIO2 INTR"; + case 0x1f808278: return "SIO2 8278"; + case 0x1f80827C: return "SIO2 827C"; + + // ------------------------------------------------------------------------ + // Check for "zoned" registers in the default case. + // And if all that fails, return "unknown"! :) + + default: + if( addr >= 0x1f801100 && addr < 0x1f801130 ) + { + switch( addr & 0xf ) + { + case 0x0: return "CNT16_COUNT"; + case 0x4: return "CNT16_MODE"; + case 0x8: return "CNT16_TARGET"; + + default: return "Invalid Counter"; + } + } + else if( addr >= 0x1f801480 && addr < 0x1f8014b0 ) + { + switch( addr & 0xf ) + { + case 0x0: return "CNT32_COUNT"; + case 0x2: return "CNT32_COUNT_hi"; + case 0x4: return "CNT32_MODE"; + case 0x8: return "CNT32_TARGET"; + case 0xa: return "CNT32_TARGET_hi"; + + default: return "Invalid Counter"; + } + } + else if( (addr >= HW_USB_START) && (addr < HW_USB_END) ) + { + return "USB"; + } + else if( (addr >= HW_SPU2_START) && (addr < HW_SPU2_END) ) + { + return "SPU2"; + } + else if( addr >= 0x1f808200 ) + { + if( addr < 0x1f808240 ) + return "SIO2 param"; + else if( addr < 0x260 ) + return "SIO2 send"; + } + return "Unknown"; + } +} + +} }; \ No newline at end of file diff --git a/pcsx2/windows/VCprojects/pcsx2_2008.vcproj b/pcsx2/windows/VCprojects/pcsx2_2008.vcproj index f11c2294aa..16743d3655 100644 --- a/pcsx2/windows/VCprojects/pcsx2_2008.vcproj +++ b/pcsx2/windows/VCprojects/pcsx2_2008.vcproj @@ -270,7 +270,7 @@ - - - - - - @@ -1017,28 +1005,6 @@ RelativePath="..\..\vssprintf.cpp" > - - - - - - - - @@ -1363,6 +1329,1075 @@ > + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1755,529 +2790,12 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -2286,12 +2804,135 @@ UsePrecompiledHeader="0" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - From 025060532930ccf4860f25e6070867708e204d7c Mon Sep 17 00:00:00 2001 From: arcum42 Date: Sat, 2 May 2009 11:03:32 +0000 Subject: [PATCH 41/41] Linux: Quickly hack the new files into the main makefile. git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1117 96395faa-99c1-11dd-bbfe-3dabce05a288 --- pcsx2/Makefile.am | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pcsx2/Makefile.am b/pcsx2/Makefile.am index 16d61d4714..f62070e274 100644 --- a/pcsx2/Makefile.am +++ b/pcsx2/Makefile.am @@ -13,10 +13,11 @@ VU0.cpp VU0micro.cpp VU0microInterp.cpp VU1micro.cpp VU1microInterp.cpp VUflags. Vif.cpp VifDma.cpp vssprintf.cpp vtlb.cpp xmlpatchloader.cpp AlignedMalloc.cpp \ RecoverySystem.cpp Saveslots.cpp Dump.cpp - +libpcsx2_a_SOURCES += \ +ps2/Iop/IopHwRead.cpp ps2/Iop/IopHwWrite.cpp ps2/Iop/IopHw_Internal.h libpcsx2_a_SOURCES += \ -CDVD.h CDVDiso.h CDVDisodrv.h CDVDlib.h COP0.h Cache.h CdRom.h Common.h Counters.h Decode_XA.h EEregs.h \ +CDVD.h CDVDiso.h CDVDisodrv.h CDVDlib.h COP0.h Cache.h CdRom.h Common.h Counters.h Decode_XA.h \ Elfheader.h Exceptions.h GS.h Hw.h IopBios.h IopBios2.h IopCounters.h IopDma.h IopHw.h IopMem.h IopSio2.h Memcpyfast.h \ Memory.h MemoryCard.h Misc.h Patch.h Paths.h Plugins.h PrecompiledHeader.h IopCommon.h R3000A.h R5900.h R5900OpcodeTables.h \ SPR.h SamplProf.h SaveState.h Sif.h Sifcmd.h Sio.h SafeArray.h Stats.h StringUtils.h System.h Threading.h \