mirror of https://github.com/PCSX2/pcsx2.git
Remove some commented out code and inline a few defines.
git-svn-id: http://pcsx2-playground.googlecode.com/svn/trunk@311 a6443dda-0b58-4228-96e9-037be469359c
This commit is contained in:
parent
fe1c4a0aef
commit
44699ebf68
787
pcsx2/CdRom.c
787
pcsx2/CdRom.c
File diff suppressed because it is too large
Load Diff
|
@ -75,6 +75,7 @@ cdrStruct cdr;
|
|||
|
||||
s32 MSFtoLSN(u8 *Time);
|
||||
void LSNtoMSF(u8 *Time, s32 lsn);
|
||||
void AddIrqQueue(u8 irq, unsigned long ecycle);
|
||||
|
||||
void cdrReset();
|
||||
void cdrInterrupt();
|
||||
|
|
|
@ -417,8 +417,6 @@ int SysInit() {
|
|||
|
||||
if(cpuInit() == -1 )
|
||||
return -1;
|
||||
|
||||
applychanges = FALSE; // Just in case
|
||||
|
||||
while (LoadPlugins() == -1) {
|
||||
if (Pcsx2Configure() == FALSE)
|
||||
|
|
183
pcsx2/Misc.c
183
pcsx2/Misc.c
|
@ -125,7 +125,8 @@ static struct {
|
|||
};
|
||||
|
||||
void GetRPCVersion(char *ioprp, char *rpcver){
|
||||
char *p=ioprp; int i;
|
||||
char *p=ioprp;
|
||||
int i;
|
||||
struct TocEntry te;
|
||||
|
||||
if (p && (CDVD_findfile(p+strlen("cdromN:"), &te) != -1)){
|
||||
|
@ -135,6 +136,7 @@ void GetRPCVersion(char *ioprp, char *rpcver){
|
|||
if (ioprps[i].size>0)
|
||||
p=ioprps[i].name;
|
||||
}
|
||||
// fixme - Is p really supposed to be set in the middle of an if statement?
|
||||
if (p && (p=strstr(p, "IOPRP")+strlen("IOPRP"))){
|
||||
for (i=0;(i<4) && p && (*p>='0') && (*p<='9');i++, p++) rpcver[i]=*p;
|
||||
for ( ; i<4 ;i++ ) rpcver[i]='0';
|
||||
|
@ -260,26 +262,24 @@ int IsBIOS(char *filename, char *description){
|
|||
|
||||
// LOAD STUFF
|
||||
|
||||
// fixme - Is there any reason why we shouldn't delete this define, and replace the array lengths
|
||||
// with the actual numbers?
|
||||
#define ISODCL(from, to) (to - from + 1)
|
||||
|
||||
struct iso_directory_record {
|
||||
char length [ISODCL (1, 1)]; /* 711 */
|
||||
char ext_attr_length [ISODCL (2, 2)]; /* 711 */
|
||||
char extent [ISODCL (3, 10)]; /* 733 */
|
||||
char size [ISODCL (11, 18)]; /* 733 */
|
||||
char date [ISODCL (19, 25)]; /* 7 by 711 */
|
||||
char flags [ISODCL (26, 26)];
|
||||
char file_unit_size [ISODCL (27, 27)]; /* 711 */
|
||||
char interleave [ISODCL (28, 28)]; /* 711 */
|
||||
char volume_sequence_number [ISODCL (29, 32)]; /* 723 */
|
||||
unsigned char name_len [ISODCL (33, 33)]; /* 711 */
|
||||
char length [ISODCL (1, 1)]; /* length[1]; 711 */
|
||||
char ext_attr_length [ISODCL (2, 2)]; /* ext_attr_length[1]; 711 */
|
||||
char extent [ISODCL (3, 10)]; /* extent[8]; 733 */
|
||||
char size [ISODCL (11, 18)]; /* size[8]; 733 */
|
||||
char date [ISODCL (19, 25)]; /* date[7]; 7 by 711 */
|
||||
char flags [ISODCL (26, 26)]; /* flags[1]; */
|
||||
char file_unit_size [ISODCL (27, 27)]; /* file_unit_size[1]; 711 */
|
||||
char interleave [ISODCL (28, 28)]; /* interleave[1]; 711 */
|
||||
char volume_sequence_number [ISODCL (29, 32)]; /* volume_sequence_number[3]; 723 */
|
||||
unsigned char name_len [ISODCL (33, 33)]; /* name_len[1]; 711 */
|
||||
char name [1];
|
||||
};
|
||||
|
||||
#define READTRACK(lsn) \
|
||||
if (CDVDreadTrack(lsn, CDVD_MODE_2352) == -1) return -1; \
|
||||
buf = CDVDgetBuffer(); if (buf == NULL) return -1;
|
||||
|
||||
int LoadCdrom() {
|
||||
return 0;
|
||||
}
|
||||
|
@ -287,7 +287,12 @@ int LoadCdrom() {
|
|||
int CheckCdrom() {
|
||||
u8 *buf;
|
||||
|
||||
READTRACK(16);
|
||||
if (CDVDreadTrack(16, CDVD_MODE_2352) == -1)
|
||||
return -1;
|
||||
buf = CDVDgetBuffer();
|
||||
if (buf == NULL)
|
||||
return -1;
|
||||
|
||||
strncpy(CdromId, (char*)buf+52, 10);
|
||||
|
||||
return 0;
|
||||
|
@ -314,11 +319,11 @@ int GetPS2ElfName(char *name){
|
|||
CDVDFS_close(f);
|
||||
|
||||
buffer[tocEntry.fileSize]='\0';
|
||||
|
||||
// SysPrintf(
|
||||
// "---------------------SYSTEM.CNF---------------------\n"
|
||||
// "%s"
|
||||
// "----------------------------------------------------\n", buffer);
|
||||
// SysPrintf(
|
||||
// "---------------------SYSTEM.CNF---------------------\n"
|
||||
// "%s"
|
||||
// "----------------------------------------------------\n", buffer);
|
||||
|
||||
pos=strstr(buffer, "BOOT2");
|
||||
if (pos==NULL){
|
||||
pos=strstr(buffer, "BOOT");
|
||||
|
@ -336,14 +341,12 @@ int GetPS2ElfName(char *name){
|
|||
return 0;
|
||||
|
||||
sscanf(pos, "%s", name);
|
||||
//SysPrintf("ELF name: '%s'\n", name);
|
||||
|
||||
if (strncmp("cdrom0:\\", name, 8) == 0) {
|
||||
strncpy(CdromId, name+8, 11); CdromId[11] = 0;
|
||||
}
|
||||
|
||||
// inifile_read(CdromId);
|
||||
|
||||
|
||||
// inifile_read(CdromId);
|
||||
fp = fopen("System.map", "r");
|
||||
if (fp) {
|
||||
u32 addr;
|
||||
|
@ -370,73 +373,6 @@ int GetPS2ElfName(char *name){
|
|||
return 2;
|
||||
}
|
||||
|
||||
/*#define PSX_EXE 1
|
||||
#define CPE_EXE 2
|
||||
#define COFF_EXE 3
|
||||
#define INVALID_EXE 4
|
||||
|
||||
static int PSXGetFileType(FILE *f) {
|
||||
unsigned long current;
|
||||
unsigned long mybuf[2048];
|
||||
EXE_HEADER *exe_hdr;
|
||||
FILHDR *coff_hdr;
|
||||
|
||||
current = ftell(f);
|
||||
fseek(f,0L,SEEK_SET);
|
||||
fread(mybuf,2048,1,f);
|
||||
fseek(f,current,SEEK_SET);
|
||||
|
||||
exe_hdr = (EXE_HEADER *)mybuf;
|
||||
if (memcmp(exe_hdr->id,"PS-X EXE",8)==0)
|
||||
return PSX_EXE;
|
||||
|
||||
if (mybuf[0]=='C' && mybuf[1]=='P' && mybuf[2]=='E')
|
||||
return CPE_EXE;
|
||||
|
||||
coff_hdr = (FILHDR *)mybuf;
|
||||
if (coff_hdr->f_magic == 0x0162)
|
||||
return COFF_EXE;
|
||||
|
||||
return INVALID_EXE;
|
||||
}
|
||||
|
||||
int Load(char *ExePath) {
|
||||
FILE *tmpFile;
|
||||
EXE_HEADER tmpHead;
|
||||
int type;
|
||||
|
||||
strcpy(CdromId, "SLUS_999.99");
|
||||
|
||||
tmpFile = fopen(ExePath,"rb");
|
||||
if (tmpFile == NULL) { SysMessage("Error opening file: %s", ExePath); return 0; }
|
||||
|
||||
type = PSXGetFileType(tmpFile);
|
||||
switch (type) {
|
||||
case PSX_EXE:
|
||||
fread(&tmpHead,sizeof(EXE_HEADER),1,tmpFile);
|
||||
fseek(tmpFile, 0x800, SEEK_SET);
|
||||
fread((void *)PSXM(tmpHead.t_addr), tmpHead.t_size,1,tmpFile);
|
||||
fclose(tmpFile);
|
||||
psxRegs.pc = tmpHead.pc0;
|
||||
psxRegs.GPR.n.gp = tmpHead.gp0;
|
||||
psxRegs.GPR.n.sp = tmpHead.s_addr;
|
||||
if (psxRegs.GPR.n.sp == 0) psxRegs.GPR.n.sp = 0x801fff00;
|
||||
break;
|
||||
case CPE_EXE:
|
||||
SysMessage("Pcsx found that you wanna use a CPE file. CPE files not support yet");
|
||||
break;
|
||||
case COFF_EXE:
|
||||
SysMessage("Pcsx found that you wanna use a COFF file.COFF files not support yet");
|
||||
break;
|
||||
case INVALID_EXE:
|
||||
SysMessage("This file is not a psx file");
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
FILE *emuLog;
|
||||
|
||||
#ifdef PCSX2_DEVBUILD
|
||||
|
@ -617,7 +553,6 @@ int LoadState(const char *file) {
|
|||
|
||||
#ifdef _DEBUG
|
||||
s_vucount = 0;
|
||||
//dumplog |= 2;
|
||||
#endif
|
||||
|
||||
SysPrintf("LoadState: %s\n", file);
|
||||
|
@ -1083,6 +1018,7 @@ void injectIRX(char *filename){
|
|||
rd[iBLANK].fileSize-=DIRENTRY_SIZE+DIRENTRY_SIZE;
|
||||
p=(char*)PS2MEM_ROM;for (i=0; i<iBLANK; i++)p+=(rd[i].fileSize+0xF)&(~0xF);p+=DIRENTRY_SIZE;
|
||||
|
||||
// fixme - brevity, yes, but at the expense of readability?
|
||||
q=(char*)PS2MEM_ROM;for (i=0; i<=iIOPBTCONF; i++) q+=(rd[i].fileSize+0xF)&(~0xF);
|
||||
while (p-16>q){*((u64*)p)=*((u64*)p-4);*((u64*)p+1)=*((u64*)p-3);p-=DIRENTRY_SIZE;}
|
||||
*((u64*)p)=*((u64*)p+1)=0;p-=DIRENTRY_SIZE;rd[iIOPBTCONF].fileSize+=DIRENTRY_SIZE;
|
||||
|
@ -1121,64 +1057,3 @@ void injectIRX(char *filename){
|
|||
rd[i].extInfoSize=0;
|
||||
}
|
||||
|
||||
// failed inline calls, this is because of inline hell and gcc syntax
|
||||
#ifndef _WIN32
|
||||
|
||||
/*void InterlockedExchangePointer(PVOID volatile* Target, void* Value)
|
||||
{
|
||||
#ifdef __x86_64__
|
||||
__asm__ __volatile__(".intel_syntax\n"
|
||||
"lock xchg [%0], %%rax\n"
|
||||
".att_syntax\n" : : "r"(Target), "a"(Value) : "memory" );
|
||||
#else
|
||||
__asm__ __volatile__(".intel_syntax\n"
|
||||
"lock xchg [%0], %%eax\n"
|
||||
".att_syntax\n" : : "r"(Target), "a"(Value) : "memory" );
|
||||
#endif
|
||||
}
|
||||
|
||||
long InterlockedExchange(long volatile* Target, long Value)
|
||||
{
|
||||
__asm__ __volatile__(".intel_syntax\n"
|
||||
"lock xchg [%0], %%eax\n"
|
||||
".att_syntax\n" : : "r"(Target), "a"(Value) : "memory" );
|
||||
// fixme - This is supposed to return a long
|
||||
}
|
||||
|
||||
long InterlockedExchangeAdd(long volatile* Addend, long Value)
|
||||
{
|
||||
__asm__ __volatile__(".intel_syntax\n"
|
||||
"lock xadd [%0], %%eax\n"
|
||||
".att_syntax\n" : : "r"(Addend), "a"(Value) : "memory" );
|
||||
// fixme - This is supposed to return a long
|
||||
}*/
|
||||
|
||||
/*u32 timeGetTime()
|
||||
{
|
||||
struct timeb t;
|
||||
ftime(&t);
|
||||
return (u32)(t.time*1000+t.millitm);
|
||||
}
|
||||
|
||||
void* pcsx2_aligned_malloc(size_t size, size_t align)
|
||||
{
|
||||
assert( align < 0x10000 );
|
||||
char* p = (char*)malloc(size+align);
|
||||
int off = 2+align - ((int)(uptr)(p+2) % align);
|
||||
|
||||
p += off;
|
||||
*(u16*)(p-2) = off;
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
void pcsx2_aligned_free(void* pmem)
|
||||
{
|
||||
if( pmem != NULL ) {
|
||||
char* p = (char*)pmem;
|
||||
free(p - (int)*(u16*)(p-2));
|
||||
}
|
||||
}*/
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -24,24 +24,22 @@
|
|||
// Dma3 in CdRom.c
|
||||
// Dma8 in PsxSpd.c
|
||||
// Dma11/12 in PsxSio2.c
|
||||
//static int spudmaenable[2];
|
||||
|
||||
int iopsifbusy[2] = { 0, 0 };
|
||||
void psxDma4(u32 madr, u32 bcr, u32 chcr) { // SPU
|
||||
int size;
|
||||
|
||||
/*if(chcr & 0x400) SysPrintf("SPU 2 DMA 4 linked list chain mode! chcr = %x madr = %x bcr = %x\n", chcr, madr, bcr);
|
||||
if(chcr & 0x40000000) SysPrintf("SPU 2 DMA 4 Unusual bit set on 'to' direction chcr = %x madr = %x bcr = %x\n", chcr, madr, bcr);
|
||||
if((chcr & 0x1) == 0) SysPrintf("SPU 2 DMA 4 loading from spu2 memory chcr = %x madr = %x bcr = %x\n", chcr, madr, bcr);
|
||||
*/
|
||||
/*if (chcr & 0x400) SysPrintf("SPU 2 DMA 4 linked list chain mode! chcr = %x madr = %x bcr = %x\n", chcr, madr, bcr);
|
||||
if (chcr & 0x40000000) SysPrintf("SPU 2 DMA 4 Unusual bit set on 'to' direction chcr = %x madr = %x bcr = %x\n", chcr, madr, bcr);
|
||||
if ((chcr & 0x1) == 0) SysPrintf("SPU 2 DMA 4 loading from spu2 memory chcr = %x madr = %x bcr = %x\n", chcr, madr, bcr);*/
|
||||
|
||||
if(SPU2async)
|
||||
{
|
||||
//if((psxRegs.cycle - psxCounters[6].sCycleT) >= psxCounters[6].CycleT){
|
||||
SPU2async(psxRegs.cycle - psxCounters[6].sCycleT);
|
||||
SPU2async(psxRegs.cycle - psxCounters[6].sCycleT);
|
||||
|
||||
//SysPrintf("cycles sent to SPU2 %x\n", psxRegs.cycle - psxCounters[6].sCycleT);
|
||||
psxCounters[6].sCycleT = psxRegs.cycle;
|
||||
psxCounters[6].CycleT = ((bcr >> 16) * (bcr & 0xFFFF)) * 3;
|
||||
//}
|
||||
|
||||
psxNextCounter -= (psxRegs.cycle-psxNextsCounter);
|
||||
psxNextsCounter = psxRegs.cycle;
|
||||
if(psxCounters[6].CycleT < psxNextCounter) psxNextCounter = psxCounters[6].CycleT;
|
||||
|
@ -50,18 +48,16 @@ void psxDma4(u32 madr, u32 bcr, u32 chcr) { // SPU
|
|||
|
||||
switch (chcr) {
|
||||
case 0x01000201: //cpu to spu transfer
|
||||
#ifdef PSXDMA_LOG
|
||||
PSXDMA_LOG("*** DMA 4 - SPU mem2spu *** %lx addr = %lx size = %lx\n", chcr, madr, bcr);
|
||||
#endif
|
||||
//SysPrintf("DMA4 write blocks %x, size per block %x\n", (bcr >> 16), (bcr & 0xFFFF));
|
||||
|
||||
size = (bcr >> 16) * (bcr & 0xFFFF); // Number of blocks to transfer
|
||||
SPU2writeDMA4Mem((u16 *)PSXM(madr), size*2);
|
||||
break;
|
||||
case 0x01000200: //spu to cpu transfer
|
||||
#ifdef PSXDMA_LOG
|
||||
PSXDMA_LOG("*** DMA 4 - SPU spu2mem *** %lx addr = %lx size = %lx\n", chcr, madr, bcr);
|
||||
#endif
|
||||
//SysPrintf("DMA4 read blocks %x, size per block %x\n", (bcr >> 16), (bcr & 0xFFFF));
|
||||
|
||||
size = (bcr >> 16) * (bcr & 0xFFFF); // Number of blocks to transfer
|
||||
SPU2readDMA4Mem((u16 *)PSXM(madr), size*2);
|
||||
psxCpu->Clear(HW_DMA4_MADR, size);
|
||||
|
@ -71,8 +67,6 @@ void psxDma4(u32 madr, u32 bcr, u32 chcr) { // SPU
|
|||
SysPrintf("*** DMA 4 - SPU unknown *** %lx addr = %lx size = %lx\n", chcr, madr, bcr);
|
||||
break;
|
||||
}
|
||||
|
||||
//spudmaenable[0] = size;
|
||||
}
|
||||
|
||||
int psxDma4Interrupt() {
|
||||
|
@ -90,9 +84,7 @@ void psxDma2(u32 madr, u32 bcr, u32 chcr) { // GPU
|
|||
void psxDma6(u32 madr, u32 bcr, u32 chcr) {
|
||||
u32 *mem = (u32 *)PSXM(madr);
|
||||
|
||||
#ifdef PSXDMA_LOG
|
||||
PSXDMA_LOG("*** DMA 6 - OT *** %lx addr = %lx size = %lx\n", chcr, madr, bcr);
|
||||
#endif
|
||||
|
||||
if (chcr == 0x11000002) {
|
||||
while (bcr--) {
|
||||
|
@ -102,9 +94,7 @@ void psxDma6(u32 madr, u32 bcr, u32 chcr) {
|
|||
mem++; *mem = 0xffffff;
|
||||
} else {
|
||||
// Unknown option
|
||||
#ifdef PSXDMA_LOG
|
||||
PSXDMA_LOG("*** DMA 6 - OT unknown *** %lx addr = %lx size = %lx\n", chcr, madr, bcr);
|
||||
#endif
|
||||
}
|
||||
HW_DMA6_CHCR &= ~0x01000000;
|
||||
psxDmaInterrupt(6);
|
||||
|
@ -115,36 +105,31 @@ void psxDma7(u32 madr, u32 bcr, u32 chcr) {
|
|||
|
||||
if(SPU2async)
|
||||
{
|
||||
//if((psxRegs.cycle - psxCounters[6].sCycleT) >= psxCounters[6].CycleT){
|
||||
SPU2async(psxRegs.cycle - psxCounters[6].sCycleT);
|
||||
//SysPrintf("cycles sent to SPU2 %x\n", psxRegs.cycle - psxCounters[6].sCycleT);
|
||||
|
||||
psxCounters[6].sCycleT = psxRegs.cycle;
|
||||
psxCounters[6].CycleT = ((bcr >> 16) * (bcr & 0xFFFF)) * 3;
|
||||
//}
|
||||
|
||||
psxNextCounter -= (psxRegs.cycle-psxNextsCounter);
|
||||
psxNextsCounter = psxRegs.cycle;
|
||||
if(psxCounters[6].CycleT < psxNextCounter) psxNextCounter = psxCounters[6].CycleT;
|
||||
|
||||
}
|
||||
|
||||
|
||||
switch (chcr) {
|
||||
case 0x01000201: //cpu to spu2 transfer
|
||||
#ifdef PSXDMA_LOG
|
||||
PSXDMA_LOG("*** DMA 7 - SPU2 mem2spu *** %lx addr = %lx size = %lx\n", chcr, madr, bcr);
|
||||
#endif
|
||||
//SysPrintf("DMA7 write blocks %x, size per block %x\n", (bcr >> 16), (bcr & 0xFFFF));
|
||||
|
||||
size = (bcr >> 16) * (bcr & 0xFFFF); // Number of blocks to transfer
|
||||
|
||||
SPU2writeDMA7Mem((u16 *)PSXM(madr), size*2);
|
||||
break;
|
||||
case 0x01000200: //spu2 to cpu transfer
|
||||
#ifdef PSXDMA_LOG
|
||||
PSXDMA_LOG("*** DMA 7 - SPU2 spu2mem *** %lx addr = %lx size = %lx\n", chcr, madr, bcr);
|
||||
#endif
|
||||
//SysPrintf("DMA4 read blocks %x, size per block %x\n", (bcr >> 16), (bcr & 0xFFFF));
|
||||
//SysPrintf("DMA7 read blocks %x, size per block %x\n", (bcr >> 16), (bcr & 0xFFFF));
|
||||
|
||||
size = (bcr >> 16) * (bcr & 0xFFFF); // Number of blocks to transfer
|
||||
|
||||
SPU2readDMA7Mem((u16 *)PSXM(madr), size*2);
|
||||
psxCpu->Clear(HW_DMA7_MADR, size);
|
||||
break;
|
||||
|
@ -152,11 +137,9 @@ void psxDma7(u32 madr, u32 bcr, u32 chcr) {
|
|||
SysPrintf("*** DMA 7 - SPU unknown *** %lx addr = %lx size = %lx\n", chcr, madr, bcr);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int psxDma7Interrupt() {
|
||||
|
||||
HW_DMA7_CHCR &= ~0x01000000;
|
||||
psxDmaInterrupt2(0);
|
||||
return 1;
|
||||
|
@ -164,15 +147,11 @@ int psxDma7Interrupt() {
|
|||
}
|
||||
extern int eesifbusy[2];
|
||||
void psxDma9(u32 madr, u32 bcr, u32 chcr) {
|
||||
|
||||
//DMACh *dma = (DMACh*)&PS2MEM_HW[0xc000]; //Not used
|
||||
|
||||
#ifdef SIF_LOG
|
||||
SIF_LOG("IOP: dmaSIF0 chcr = %lx, madr = %lx, bcr = %lx, tadr = %lx\n", chcr, madr, bcr, HW_DMA9_TADR);
|
||||
#endif
|
||||
|
||||
iopsifbusy[0] = 1;
|
||||
psHu32(0x1000F240) |= 0x2000;
|
||||
|
||||
if (eesifbusy[0] == 1 && iopsifbusy[0] == 1) {
|
||||
SIF0Dma();
|
||||
psHu32(0x1000F240) &= ~0x20;
|
||||
|
@ -181,14 +160,11 @@ void psxDma9(u32 madr, u32 bcr, u32 chcr) {
|
|||
}
|
||||
|
||||
void psxDma10(u32 madr, u32 bcr, u32 chcr) {
|
||||
//DMACh *dma = (DMACh*)&PS2MEM_HW[0xc400]; //Not used
|
||||
|
||||
#ifdef SIF_LOG
|
||||
SIF_LOG("IOP: dmaSIF1 chcr = %lx, madr = %lx, bcr = %lx\n", chcr, madr, bcr);
|
||||
#endif
|
||||
|
||||
iopsifbusy[1] = 1;
|
||||
psHu32(0x1000F240) |= 0x4000;
|
||||
|
||||
if (eesifbusy[1] == 1 && iopsifbusy[1] == 1) {
|
||||
FreezeXMMRegs(1);
|
||||
SIF1Dma();
|
||||
|
@ -204,26 +180,21 @@ void psxDma8(u32 madr, u32 bcr, u32 chcr) {
|
|||
|
||||
switch (chcr & 0x01000201) {
|
||||
case 0x01000201: //cpu to dev9 transfer
|
||||
#ifdef PSXDMA_LOG
|
||||
PSXDMA_LOG("*** DMA 8 - DEV9 mem2dev9 *** %lx addr = %lx size = %lx\n", chcr, madr, bcr);
|
||||
#endif
|
||||
size = (bcr >> 16) * (bcr & 0xFFFF); // Number of blocks to transfer
|
||||
|
||||
size = (bcr >> 16) * (bcr & 0xFFFF); // Number of blocks to transfer
|
||||
DEV9writeDMA8Mem((u32*)PSXM(madr), size*8);
|
||||
break;
|
||||
case 0x01000200: //dev9 to cpu transfer
|
||||
#ifdef PSXDMA_LOG
|
||||
PSXDMA_LOG("*** DMA 8 - DEV9 dev9mem *** %lx addr = %lx size = %lx\n", chcr, madr, bcr);
|
||||
#endif
|
||||
|
||||
size = (bcr >> 16) * (bcr & 0xFFFF); // Number of blocks to transfer
|
||||
|
||||
DEV9readDMA8Mem((u32*)PSXM(madr), size*8);
|
||||
break;
|
||||
#ifdef PSXDMA_LOG
|
||||
default:
|
||||
PSXDMA_LOG("*** DMA 8 - DEV9 unknown *** %lx addr = %lx size = %lx\n", chcr, madr, bcr);
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
HW_DMA8_CHCR &= ~0x01000000;
|
||||
psxDmaInterrupt2(1);
|
||||
|
@ -231,11 +202,13 @@ void psxDma8(u32 madr, u32 bcr, u32 chcr) {
|
|||
|
||||
void dev9Interrupt() {
|
||||
if (dev9Handler == NULL) goto irq;
|
||||
|
||||
if (dev9Handler() != 1) {
|
||||
psxRegs.interrupt&= ~(1 << 20);
|
||||
return;
|
||||
}
|
||||
irq:
|
||||
|
||||
irq:
|
||||
psxHu32(0x1070)|= 1<<13;
|
||||
//SBUS
|
||||
hwIntcIrq(INTC_SBUS);
|
||||
|
@ -248,11 +221,13 @@ void dev9Irq(int cycles) {
|
|||
|
||||
void usbInterrupt() {
|
||||
if (usbHandler == NULL) goto irq;
|
||||
|
||||
if (usbHandler() != 1) {
|
||||
psxRegs.interrupt&= ~(1 << 21);
|
||||
return;
|
||||
}
|
||||
irq:
|
||||
|
||||
irq:
|
||||
psxHu32(0x1070)|= 1<<22;
|
||||
//SBUS
|
||||
hwIntcIrq(INTC_SBUS);
|
||||
|
|
72
pcsx2/Sif.c
72
pcsx2/Sif.c
|
@ -30,8 +30,6 @@
|
|||
#define FIFO_SIF0_W 128
|
||||
#define FIFO_SIF1_W 128
|
||||
|
||||
int eesifbusy[2] = { 0, 0 };
|
||||
extern int iopsifbusy[2];
|
||||
typedef struct {
|
||||
u32 fifoData[FIFO_SIF0_W];
|
||||
int fifoReadPos;
|
||||
|
@ -58,14 +56,14 @@ typedef struct {
|
|||
_sif0 sif0;
|
||||
_sif1 sif1;
|
||||
|
||||
int sifInit() {
|
||||
int wP0, wP1;
|
||||
int eesifbusy[2] = { 0, 0 };
|
||||
extern int iopsifbusy[2];
|
||||
|
||||
void sifInit() {
|
||||
memset(&sif0, 0, sizeof(sif0));
|
||||
memset(&sif1, 0, sizeof(sif1));
|
||||
|
||||
return 0;
|
||||
}
|
||||
int wP0;
|
||||
int wP1;
|
||||
_inline void SIF0write(u32 *from, int words)
|
||||
{
|
||||
/*if(FIFO_SIF0_W < (words+sif0.fifoWritePos)) {*/
|
||||
|
@ -84,15 +82,7 @@ _inline void SIF0write(u32 *from, int words)
|
|||
}*/
|
||||
|
||||
sif0.fifoSize += words;
|
||||
#ifdef SIF_LOG
|
||||
SIF_LOG(" SIF0 + %d = %d (pos=%d)\n", words, sif0.fifoSize, sif0.fifoWritePos);
|
||||
// {
|
||||
// int i;
|
||||
// for(i = 0; i < words; i += 4) {
|
||||
// SIF_LOG(" EE SIF write data: %x %x %x %x\n", from[i], from[i+1], from[i+2], from[i+3]);
|
||||
// }
|
||||
// }
|
||||
#endif
|
||||
|
||||
/* if (sif0.fifoSize == FIFO_SIF0_W) {
|
||||
Cpu->ExecuteBlock();
|
||||
|
@ -118,9 +108,7 @@ _inline void SIF0read(u32 *to, int words)
|
|||
}*/
|
||||
|
||||
sif0.fifoSize -= words;
|
||||
#ifdef SIF_LOG
|
||||
SIF_LOG(" SIF0 - %d = %d (pos=%d)\n", words, sif0.fifoSize, sif0.fifoReadPos);
|
||||
#endif
|
||||
}
|
||||
|
||||
_inline void SIF1write(u32 *from, int words)
|
||||
|
@ -142,9 +130,7 @@ _inline void SIF1write(u32 *from, int words)
|
|||
}*/
|
||||
|
||||
sif1.fifoSize += words;
|
||||
#ifdef SIF_LOG
|
||||
SIF_LOG(" SIF1 + %d = %d (pos=%d)\n", words, sif1.fifoSize, sif1.fifoWritePos);
|
||||
#endif
|
||||
|
||||
/* if (sif1.fifoSize == FIFO_SIF1_W) {
|
||||
psxCpu->ExecuteBlock();
|
||||
|
@ -170,21 +156,17 @@ _inline void SIF1read(u32 *to, int words)
|
|||
}*/
|
||||
|
||||
sif1.fifoSize -= words;
|
||||
#ifdef SIF_LOG
|
||||
SIF_LOG(" SIF1 - %d = %d (pos=%d)\n", words, sif1.fifoSize, sif1.fifoReadPos);
|
||||
#endif
|
||||
}
|
||||
|
||||
_inline void SIF0Dma()
|
||||
{
|
||||
u32 *ptag;
|
||||
int notDone;
|
||||
int notDone = 1;
|
||||
int cycles = 0, psxCycles = 0;
|
||||
|
||||
#ifdef SIF_LOG
|
||||
SIF_LOG("SIF0 DMA start...\n");
|
||||
#endif
|
||||
notDone = 1;
|
||||
|
||||
do
|
||||
{
|
||||
|
||||
|
@ -200,9 +182,7 @@ notDone = 1;
|
|||
// Note.. add normal mode here
|
||||
if (sif0.sifData.data & 0xC0000000) // If NORMAL mode or end of CHAIN, or interrupt then stop DMA
|
||||
{
|
||||
#ifdef SIF_LOG
|
||||
SIF_LOG(" IOP SIF Stopped\n");
|
||||
#endif
|
||||
|
||||
// Stop & signal interrupts on IOP
|
||||
//HW_DMA9_CHCR &= ~0x01000000; //reset TR flag
|
||||
|
@ -230,31 +210,18 @@ notDone = 1;
|
|||
sif0.counter = sif0.sifData.words & 0xFFFFFF;
|
||||
notDone = 1;
|
||||
|
||||
#ifdef SIF_LOG
|
||||
SIF_LOG(" SIF0 Tag: madr=%lx, tadr=%lx, counter=%lx (%08X_%08X)\n", HW_DMA9_MADR, HW_DMA9_TADR, sif0.counter, sif0.sifData.words, sif0.sifData.data);
|
||||
#endif
|
||||
if(sif0.sifData.data & 0x40000000)
|
||||
{
|
||||
#ifdef SIF_LOG
|
||||
SIF_LOG(" END\n");
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef SIF_LOG
|
||||
SIF_LOG(" CNT %08X, %08X\n", sif0.sifData.data, sif0.sifData.words);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
else // There's some data ready to transfer into the fifo..
|
||||
{
|
||||
int wTransfer = min(sif0.counter, FIFO_SIF0_W-sif0.fifoSize); // HW_DMA9_BCR >> 16;
|
||||
|
||||
|
||||
#ifdef SIF_LOG
|
||||
SIF_LOG("+++++++++++ %lX of %lX\n", wTransfer, sif0.counter /*(HW_DMA9_BCR >> 16)*/ );
|
||||
#endif
|
||||
|
||||
SIF0write((u32*)PSXM(HW_DMA9_MADR), wTransfer);
|
||||
HW_DMA9_MADR += wTransfer << 2;
|
||||
|
@ -279,9 +246,7 @@ notDone = 1;
|
|||
int readSize = min(size, (sif0.fifoSize>>2));
|
||||
|
||||
//SIF_LOG(" EE SIF doing transfer %04Xqw to %08X\n", readSize, sif0dma->madr);
|
||||
#ifdef SIF_LOG
|
||||
SIF_LOG("----------- %lX of %lX\n", readSize << 2, size << 2 );
|
||||
#endif
|
||||
|
||||
_dmaGetAddr(sif0dma, ptag, sif0dma->madr, 5);
|
||||
|
||||
|
@ -308,9 +273,8 @@ notDone = 1;
|
|||
if((sif0dma->chcr & 0x80000080) == 0x80000080) // Stop on tag IRQ
|
||||
{
|
||||
// Tag interrupt
|
||||
#ifdef SIF_LOG
|
||||
SIF_LOG(" EE SIF interrupt\n");
|
||||
#endif
|
||||
|
||||
//sif0dma->chcr &= ~0x100;
|
||||
eesifbusy[0] = 0;
|
||||
INT(5, cycles*BIAS);
|
||||
|
@ -320,9 +284,8 @@ notDone = 1;
|
|||
else if(sif0.end) // Stop on tag END
|
||||
{
|
||||
// End tag.
|
||||
#ifdef SIF_LOG
|
||||
SIF_LOG(" EE SIF end\n");
|
||||
#endif
|
||||
|
||||
//sif0dma->chcr &= ~0x100;
|
||||
//hwDmacIrq(5);
|
||||
eesifbusy[0] = 0;
|
||||
|
@ -333,9 +296,8 @@ notDone = 1;
|
|||
{
|
||||
static PCSX2_ALIGNED16(u32 tag[4]);
|
||||
SIF0read((u32*)&tag[0], 4); // Tag
|
||||
#ifdef SIF_LOG
|
||||
SIF_LOG(" EE SIF read tag: %x %x %x %x\n", tag[0], tag[1], tag[2], tag[3]);
|
||||
#endif
|
||||
SIF_LOG(" EE SIF read tag: %x %x %x %x\n", tag[0], tag[1], tag[2], tag[3]);
|
||||
|
||||
sif0dma->qwc = (u16)tag[0];
|
||||
sif0dma->madr = tag[1];
|
||||
sif0dma->chcr = (sif0dma->chcr & 0xffff) | (tag[0] & 0xffff0000);
|
||||
|
@ -343,9 +305,8 @@ notDone = 1;
|
|||
/*if ((sif0dma->chcr & 0x80) && (tag[0] >> 31)) {
|
||||
SysPrintf("SIF0 TIE\n");
|
||||
}*/
|
||||
#ifdef SIF_LOG
|
||||
SIF_LOG(" EE SIF dest chain tag madr:%08X qwc:%04X id:%X irq:%d(%08X_%08X)\n", sif0dma->madr, sif0dma->qwc, (tag[0]>>28)&3, (tag[0]>>31)&1, tag[1], tag[0]);
|
||||
#endif
|
||||
|
||||
if ((psHu32(DMAC_CTRL) & 0x30) != 0 && ((tag[0]>>28)&3) == 0)
|
||||
psHu32(DMAC_STADR) = sif0dma->madr + (sif0dma->qwc * 16);
|
||||
notDone = 1;
|
||||
|
@ -581,11 +542,8 @@ _inline void EEsif1Interrupt() {
|
|||
}
|
||||
|
||||
_inline void dmaSIF0() {
|
||||
|
||||
#ifdef SIF_LOG
|
||||
SIF_LOG("EE: dmaSIF0 chcr = %lx, madr = %lx, qwc = %lx, tadr = %lx\n",
|
||||
sif0dma->chcr, sif0dma->madr, sif0dma->qwc, sif0dma->tadr);
|
||||
#endif
|
||||
|
||||
if (sif0.fifoReadPos != sif0.fifoWritePos) {
|
||||
SysPrintf("warning, sif0.fifoReadPos != sif0.fifoWritePos\n");
|
||||
|
@ -608,11 +566,8 @@ _inline void dmaSIF0() {
|
|||
}
|
||||
|
||||
_inline void dmaSIF1() {
|
||||
|
||||
#ifdef SIF_LOG
|
||||
SIF_LOG("EE: dmaSIF1 chcr = %lx, madr = %lx, qwc = %lx, tadr = %lx\n",
|
||||
sif1dma->chcr, sif1dma->madr, sif1dma->qwc, sif1dma->tadr);
|
||||
#endif
|
||||
|
||||
if (sif1.fifoReadPos != sif1.fifoWritePos) {
|
||||
SysPrintf("warning, sif1.fifoReadPos != sif1.fifoWritePos\n");
|
||||
|
@ -637,11 +592,8 @@ _inline void dmaSIF1() {
|
|||
}
|
||||
|
||||
_inline void dmaSIF2() {
|
||||
|
||||
#ifdef SIF_LOG
|
||||
SIF_LOG("dmaSIF2 chcr = %lx, madr = %lx, qwc = %lx\n",
|
||||
sif2dma->chcr, sif2dma->madr, sif2dma->qwc);
|
||||
#endif
|
||||
|
||||
sif2dma->chcr&= ~0x100;
|
||||
hwDmacIrq(7);
|
||||
|
|
|
@ -34,7 +34,7 @@ DMACh *sif0ch;
|
|||
DMACh *sif1ch;
|
||||
DMACh *sif2ch;
|
||||
|
||||
extern int sifInit();
|
||||
extern void sifInit();
|
||||
extern void SIF0Dma();
|
||||
extern void SIF1Dma();
|
||||
extern void dmaSIF0();
|
||||
|
|
Loading…
Reference in New Issue