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
This commit is contained in:
arcum42 2009-05-01 01:13:37 +00:00
parent 1a1d51308c
commit 5edb195282
5 changed files with 341 additions and 274 deletions

View File

@ -79,6 +79,23 @@ enum cdvdActions
, cdvdAction_Read // note: not used yet. , 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 // 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 btoi(b) ((b)/16*10 + (b)%16) /* BCD to u_char */
#define itob(i) ((i)/10*16 + (i)%10) /* u_char to BCD */ #define itob(i) ((i)/10*16 + (i)%10) /* u_char to BCD */
#define SetResultSize(size) \ __forceinline void SetResultSize(u8 size)
cdvd.ResultC = size; cdvd.ResultP = 0; \ {
cdvd.ResultC = size;
cdvd.ResultP = 0;
cdvd.sDataIn&=~0x40; 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) static void CDVD_INT(int eCycle)
{ {
if( eCycle == 0 ) if( eCycle == 0 )
@ -226,10 +250,14 @@ static void cdvdSetIrq( uint id = (1<<Irq_CommandComplete) )
psxSetNextBranchDelta( 20 ); psxSetNextBranchDelta( 20 );
} }
static int mg_BIToffset(u8 *buffer){ static int mg_BIToffset(u8 *buffer)
int i, ofs = 0x20; for (i=0; i<*(u16*)&buffer[0x1A]; i++)ofs+=0x10; {
if (*(u16*)&buffer[0x18] & 1)ofs+=buffer[ofs]; int i, ofs = 0x20;
if ((*(u16*)&buffer[0x18] & 0xF000)==0)ofs+=8; for (i=0; i<*(u16*)&buffer[0x1A]; i++)
ofs+=0x10;
if (*(u16*)&buffer[0x18] & 1) ofs += buffer[ofs];
if ((*(u16*)&buffer[0x18] & 0xF000) == 0) ofs += 8;
return ofs + 0x20; return ofs + 0x20;
} }
@ -331,8 +359,10 @@ s32 cdvdWriteNVM(const u8 *src, int offset, int bytes) {
return 0; return 0;
} }
#define GET_NVM_DATA(buff, offset, size, fmtOffset) getNvmData(buff, offset, size, BiosVersion, offsetof(NVMLayout, fmtOffset)) #define GET_NVM_DATA(buff, offset, size, fmtOffset) \
#define SET_NVM_DATA(buff, offset, size, fmtOffset) setNvmData(buff, offset, size, BiosVersion, offsetof(NVMLayout, 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) s32 getNvmData(u8* buffer, s32 offset, s32 size, u32 biosVersion, s32 fmtOffset)
{ {
@ -437,12 +467,17 @@ s32 cdvdReadConfig(u8* config)
} }
// get config data // get config data
if(cdvd.COffset == 0) switch (cdvd.COffset)
return GET_NVM_DATA(config, (cdvd.CBlockIndex++)*16, 16, config0); else {
if(cdvd.COffset == 2) case 0:
return GET_NVM_DATA(config, (cdvd.CBlockIndex++)*16, 16, config2); return GET_NVM_DATA(config, (cdvd.CBlockIndex++)*16, 16, config0);
else break;
return GET_NVM_DATA(config, (cdvd.CBlockIndex++)*16, 16, config1); case 2:
return GET_NVM_DATA(config, (cdvd.CBlockIndex++)*16, 16, config2);
break;
default:
return GET_NVM_DATA(config, (cdvd.CBlockIndex++)*16, 16, config1);
}
} }
s32 cdvdWriteConfig(const u8* config) s32 cdvdWriteConfig(const u8* config)
{ {
@ -460,12 +495,17 @@ s32 cdvdWriteConfig(const u8* config)
return 0; return 0;
// get config data // get config data
if(cdvd.COffset == 0) switch (cdvd.COffset)
return SET_NVM_DATA(config, (cdvd.CBlockIndex++)*16, 16, config0); else {
if(cdvd.COffset == 2) case 0:
return SET_NVM_DATA(config, (cdvd.CBlockIndex++)*16, 16, config2); return SET_NVM_DATA(config, (cdvd.CBlockIndex++)*16, 16, config0);
else break;
return SET_NVM_DATA(config, (cdvd.CBlockIndex++)*16, 16, config1); case 2:
return SET_NVM_DATA(config, (cdvd.CBlockIndex++)*16, 16, config2);
break;
default:
return SET_NVM_DATA(config, (cdvd.CBlockIndex++)*16, 16, config1);
}
} }
@ -554,90 +594,6 @@ s32 cdvdGetToc(void* toc)
s32 ret = CDVDgetTOC(toc); s32 ret = CDVDgetTOC(toc);
if(ret == -1) ret = 0x80; if(ret == -1) ret = 0x80;
return ret; return ret;
/*
cdvdTN diskInfo;
cdvdTD trackInfo;
u8 _time[3];
u32 type;
int i, err;
//Param[0] is 0 for CdGetToc and any value for cdvdman_call19
//the code below handles only CdGetToc!
//if(cdvd.Param[0]==0x01)
//{
Console::WriteLn("CDGetToc Param[0]=%d, Param[1]=%d", params cdvd.Param[0],cdvd.Param[1]);
//}
type = CDVDgetDiskType();
if (CDVDgetTN(&diskInfo) == -1) { diskInfo.etrack = 0;diskInfo.strack = 1; }
if (CDVDgetTD(0, &trackInfo) == -1) trackInfo.lsn = 0;
if (type == CDVD_TYPE_CDDA) {
PSXMu8(HW_DMA3_MADR+ 0) = 0x01;
} else
if (type == CDVD_TYPE_PS2DVD) {
if (trackInfo.lsn >= (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) s32 cdvdReadSubQ(s32 lsn, cdvdSubQ* subq)
@ -666,10 +622,8 @@ s32 cdvdCtrlTrayClose()
s32 cdvdGetTrayStatus() s32 cdvdGetTrayStatus()
{ {
s32 ret = CDVDgetTrayStatus(); s32 ret = CDVDgetTrayStatus();
// get current tray state // get current tray state - never true
if (cdCaseopen) return(CDVD_TRAY_OPEN); if (cdCaseopen) return(CDVD_TRAY_OPEN);
if (ret == -1) return(CDVD_TRAY_CLOSE); if (ret == -1) return(CDVD_TRAY_CLOSE);
return(ret); return(ret);
} }
@ -691,16 +645,18 @@ __forceinline void cdvdGetDiskType()
} }
cdvd.Type = CDVDgetDiskType(); cdvd.Type = CDVDgetDiskType();
// Is the type listed as a PS2 CD?
if (cdvd.Type == CDVD_TYPE_PS2CD) // && needReset == 1) if (cdvd.Type == CDVD_TYPE_PS2CD) // && needReset == 1)
{ {
char str[g_MaxPath]; char str[g_MaxPath];
if (GetPS2ElfName(str) == 1) if (GetPS2ElfName(str) == 1)
{ {
// Does the SYSTEM.CNF file only say "BOOT="? PS1 CD then.
cdvd.Type = CDVD_TYPE_PSCD; 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 // check whether disc is single or dual layer
// if its dual layer, check what the disctype is and what sector number // if its dual layer, check what the disctype is and what sector number
@ -862,12 +818,14 @@ int cdvdReadSector() {
// dual layer ptp disc // dual layer ptp disc
layerNum = 1; layerNum = 1;
lsn = lsn-layer1Start + 0x30000; lsn = lsn-layer1Start + 0x30000;
} else if((dualType == 2) && (lsn >= layer1Start)) }
else if((dualType == 2) && (lsn >= layer1Start))
{ {
// dual layer otp disc // dual layer otp disc
layerNum = 1; layerNum = 1;
lsn = ~(layer1Start+0x30000 - 1); lsn = ~(layer1Start+0x30000 - 1);
} else }
else
{ {
// single layer disc // single layer disc
// or on first layer of dual layer disc // or on first layer of dual layer disc
@ -986,14 +944,20 @@ __forceinline void cdvdReadInterrupt()
return; return;
} }
if (cdvd.Reading == 1) { if (cdvd.Reading == 1)
if (cdvd.RErr == 0) { {
if (cdvd.RErr == 0)
cdr.pTransfer = CDVDgetBuffer(); cdr.pTransfer = CDVDgetBuffer();
} else cdr.pTransfer = NULL; else
if (cdr.pTransfer == NULL) { cdr.pTransfer = NULL;
if (cdr.pTransfer == NULL)
{
cdvd.RetryCntP++; cdvd.RetryCntP++;
Console::Error("CDVD READ ERROR, sector=%d", params cdvd.Sector); 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); cdvd.RErr = CDVDreadTrack(cdvd.Sector, cdvd.ReadMode);
CDVDREAD_INT(cdvd.ReadTime); CDVDREAD_INT(cdvd.ReadTime);
return; return;
@ -1002,8 +966,9 @@ __forceinline void cdvdReadInterrupt()
cdvd.Reading = 0; cdvd.Reading = 0;
} }
if (cdvdReadSector() == -1) { if (cdvdReadSector() == -1)
assert( (int)cdvd.ReadTime > 0 ); {
assert((int)cdvd.ReadTime > 0 );
CDVDREAD_INT(cdvd.ReadTime); CDVDREAD_INT(cdvd.ReadTime);
return; return;
} }
@ -1018,7 +983,7 @@ __forceinline void cdvdReadInterrupt()
HW_DMA3_CHCR &= ~0x01000000; HW_DMA3_CHCR &= ~0x01000000;
psxDmaInterrupt(3); psxDmaInterrupt(3);
cdvd.Ready = 0x4e; cdvd.Ready = 0x4e;
// All done! :D // All done! :D
@ -1159,7 +1124,7 @@ u8 cdvdRead17(void) { // SREADY
} }
u8 cdvdRead18(void) { // SDATAOUT u8 cdvdRead18(void) { // SDATAOUT
u8 ret=0; u8 ret = 0;
if ((cdvd.sDataIn & 0x40) == 0) { if ((cdvd.sDataIn & 0x40) == 0) {
if (cdvd.ResultP < cdvd.ResultC) { if (cdvd.ResultP < cdvd.ResultC) {
@ -1348,12 +1313,12 @@ void cdvdWrite04(u8 rt) { // NCOMMAND
cdvd.PwOff = Irq_None; // good or bad? cdvd.PwOff = Irq_None; // good or bad?
switch (rt) { switch (rt) {
case 0x00: // CdSync case N_CD_SYNC: // CdSync
case 0x01: // CdNop_ case N_CD_NOP: // CdNop_
cdvdSetIrq(); cdvdSetIrq();
break; break;
case 0x02: // CdStandby case N_CD_STANDBY: // CdStandby
// Seek to sector zero. The cdvdStartSeek function will simulate // Seek to sector zero. The cdvdStartSeek function will simulate
// spinup times if needed. // spinup times if needed.
@ -1364,24 +1329,24 @@ void cdvdWrite04(u8 rt) { // NCOMMAND
CDVD_INT( cdvdStartSeek( 0, MODE_DVDROM ) ); CDVD_INT( cdvdStartSeek( 0, MODE_DVDROM ) );
break; break;
case 0x03: // CdStop case N_CD_STOP: // CdStop
DevCon::Notice( "CdStop : %d", params rt ); DevCon::Notice( "CdStop : %d", params rt );
cdvd.Action = cdvdAction_Stop; cdvd.Action = cdvdAction_Stop;
CDVD_INT( PSXCLK / 6 ); // 166ms delay? CDVD_INT( PSXCLK / 6 ); // 166ms delay?
break; break;
// from an emulation point of view there is not much need to do anything for this one // 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(); cdvdSetIrq();
break; break;
case 0x05: // CdSeek case N_CD_SEEK: // CdSeek
cdvd.Action = cdvdAction_Seek; cdvd.Action = cdvdAction_Seek;
cdvd.ReadTime = cdvdBlockReadTime( MODE_DVDROM ); cdvd.ReadTime = cdvdBlockReadTime( MODE_DVDROM );
CDVD_INT( cdvdStartSeek( *(uint*)(cdvd.Param+0), MODE_DVDROM ) ); CDVD_INT( cdvdStartSeek( *(uint*)(cdvd.Param+0), MODE_DVDROM ) );
break; break;
case 0x06: // CdRead case N_CD_READ: // CdRead
cdvd.SeekToSector = *(uint*)(cdvd.Param+0); cdvd.SeekToSector = *(uint*)(cdvd.Param+0);
cdvd.nSectors = *(int*)(cdvd.Param+4); cdvd.nSectors = *(int*)(cdvd.Param+4);
cdvd.RetryCnt = (cdvd.Param[8] == 0) ? 0x100 : cdvd.Param[8]; cdvd.RetryCnt = (cdvd.Param[8] == 0) ? 0x100 : cdvd.Param[8];
@ -1414,8 +1379,8 @@ void cdvdWrite04(u8 rt) { // NCOMMAND
cdvd.Reading = 1; cdvd.Reading = 1;
break; break;
case 0x07: // CdReadCDDA case N_CD_READ_CDDA: // CdReadCDDA
case 0x0E: // CdReadXCDDA case N_CD_READ_XCDDA: // CdReadXCDDA
cdvd.SeekToSector = *(int*)(cdvd.Param+0); cdvd.SeekToSector = *(int*)(cdvd.Param+0);
cdvd.nSectors = *(int*)(cdvd.Param+4); cdvd.nSectors = *(int*)(cdvd.Param+4);
if (cdvd.Param[8] == 0) cdvd.RetryCnt = 0x100; if (cdvd.Param[8] == 0) cdvd.RetryCnt = 0x100;
@ -1455,7 +1420,7 @@ void cdvdWrite04(u8 rt) { // NCOMMAND
cdvd.Reading = 1; cdvd.Reading = 1;
break; break;
case 0x08: // DvdRead case N_DVD_READ: // DvdRead
cdvd.SeekToSector = *(int*)(cdvd.Param+0); cdvd.SeekToSector = *(int*)(cdvd.Param+0);
cdvd.nSectors = *(int*)(cdvd.Param+4); cdvd.nSectors = *(int*)(cdvd.Param+4);
if (cdvd.Param[8] == 0) cdvd.RetryCnt = 0x100; if (cdvd.Param[8] == 0) cdvd.RetryCnt = 0x100;
@ -1486,7 +1451,7 @@ void cdvdWrite04(u8 rt) { // NCOMMAND
cdvd.Reading = 1; cdvd.Reading = 1;
break; 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 //Param[0] is 0 for CdGetToc and any value for cdvdman_call19
//the code below handles only CdGetToc! //the code below handles only CdGetToc!
//if(cdvd.Param[0]==0x01) //if(cdvd.Param[0]==0x01)
@ -1499,7 +1464,7 @@ void cdvdWrite04(u8 rt) { // NCOMMAND
psxDmaInterrupt(3); psxDmaInterrupt(3);
break; break;
case 0x0C: // CdReadKey case N_CD_READ_KEY: // CdReadKey
{ {
u8 arg0 = cdvd.Param[0]; u8 arg0 = cdvd.Param[0];
u16 arg1 = cdvd.Param[1] | (cdvd.Param[2]<<8); u16 arg1 = cdvd.Param[1] | (cdvd.Param[2]<<8);
@ -1511,7 +1476,7 @@ void cdvdWrite04(u8 rt) { // NCOMMAND
} }
break; break;
case 0x0F: // CdChgSpdlCtrl case N_CD_CHG_SPDL_CTRL: // CdChgSpdlCtrl
Console::Notice("sceCdChgSpdlCtrl(%d)", params cdvd.Param[0]); Console::Notice("sceCdChgSpdlCtrl(%d)", params cdvd.Param[0]);
cdvdSetIrq(); cdvdSetIrq();
break; break;
@ -1544,8 +1509,7 @@ void cdvdWrite07(u8 rt) // BREAK
CDR_LOG("cdvdWrite07(Break) %x", rt); CDR_LOG("cdvdWrite07(Break) %x", rt);
// If we're already in a Ready state or already Breaking, then do nothing: // If we're already in a Ready state or already Breaking, then do nothing:
if( cdvd.Ready != 0 || cdvd.Action == cdvdAction_Break ) if ((cdvd.Ready != 0) || (cdvd.Action == cdvdAction_Break)) return;
return;
DbgCon::Notice("*PCSX2*: CDVD BREAK %x", params rt); DbgCon::Notice("*PCSX2*: CDVD BREAK %x", params rt);
@ -1614,34 +1578,38 @@ void cdvdWrite16(u8 rt) // SCOMMAND
break; break;
case 0x03: // Mecacon-command case 0x03: // Mecacon-command
if(cdvd.Param[0]==0x00) { switch (cdvd.Param[0])
// get mecha version (1:4) {
SetResultSize(4); case 0x00: // get mecha version (1:4)
cdvdGetMechaVer(&cdvd.Result[0]); SetResultSize(4);
} cdvdGetMechaVer(&cdvd.Result[0]);
else if(cdvd.Param[0]==0x44) { break;
// write console ID (9:1)
SetResultSize(1); case 0x44: // write console ID (9:1)
cdvd.Result[0] = cdvdWriteConsoleID(&cdvd.Param[1]); SetResultSize(1);
} cdvd.Result[0] = cdvdWriteConsoleID(&cdvd.Param[1]);
else if(cdvd.Param[0]==0x45) { break;
// read console ID (1:9)
SetResultSize(9); case 0x45: // read console ID (1:9)
cdvd.Result[0] = cdvdReadConsoleID(&cdvd.Result[1]); SetResultSize(9);
} cdvd.Result[0] = cdvdReadConsoleID(&cdvd.Result[1]);
else if(cdvd.Param[0]==0xFD) { break;
// _sceCdReadRenewalDate (1:6) BCD
SetResultSize(6); case 0xFD: // _sceCdReadRenewalDate (1:6) BCD
cdvd.Result[0] = 0; SetResultSize(6);
cdvd.Result[1] = 0x04;//year cdvd.Result[0] = 0;
cdvd.Result[2] = 0x12;//month cdvd.Result[1] = 0x04;//year
cdvd.Result[3] = 0x10;//day cdvd.Result[2] = 0x12;//month
cdvd.Result[4] = 0x01;//hour cdvd.Result[3] = 0x10;//day
cdvd.Result[5] = 0x30;//min cdvd.Result[4] = 0x01;//hour
} else { cdvd.Result[5] = 0x30;//min
SetResultSize(1); break;
cdvd.Result[0] = 0x80;
Console::WriteLn("*Unknown Mecacon Command param[0]=%02X", params cdvd.Param[0]); default:
SetResultSize(1);
cdvd.Result[0] = 0x80;
Console::WriteLn("*Unknown Mecacon Command param[0]=%02X", params cdvd.Param[0]);
break;
} }
break; break;
@ -1674,7 +1642,6 @@ void cdvdWrite16(u8 rt) // SCOMMAND
cdvd.Result[3], cdvd.Result[5], cdvd.Result[6], cdvd.Result[7]); 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, 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);*/ cdvd.RTC.hour, cdvd.RTC.day, cdvd.RTC.month, cdvd.RTC.year);*/
break; break;
case 0x09: // sceCdWriteRTC (7:1) case 0x09: // sceCdWriteRTC (7:1)
@ -1699,14 +1666,17 @@ void cdvdWrite16(u8 rt) // SCOMMAND
case 0x0A: // sceCdReadNVM (2:3) case 0x0A: // sceCdReadNVM (2:3)
address = (cdvd.Param[0]<<8) | cdvd.Param[1]; address = (cdvd.Param[0]<<8) | cdvd.Param[1];
if (address < 512) { if (address < 512)
{
SetResultSize(3); SetResultSize(3);
cdvd.Result[0] = cdvdReadNVM(&cdvd.Result[1], address*2, 2); cdvd.Result[0] = cdvdReadNVM(&cdvd.Result[1], address*2, 2);
// swap bytes around // swap bytes around
tmp = cdvd.Result[1]; tmp = cdvd.Result[1];
cdvd.Result[1] = cdvd.Result[2]; cdvd.Result[1] = cdvd.Result[2];
cdvd.Result[2] = tmp; cdvd.Result[2] = tmp;
} else { }
else
{
SetResultSize(1); SetResultSize(1);
cdvd.Result[0] = 0xff; cdvd.Result[0] = 0xff;
} }
@ -1715,13 +1685,16 @@ void cdvdWrite16(u8 rt) // SCOMMAND
case 0x0B: // sceCdWriteNVM (4:1) case 0x0B: // sceCdWriteNVM (4:1)
address = (cdvd.Param[0]<<8) | cdvd.Param[1]; address = (cdvd.Param[0]<<8) | cdvd.Param[1];
SetResultSize(1); SetResultSize(1);
if (address < 512) { if (address < 512)
{
// swap bytes around // swap bytes around
tmp = cdvd.Param[2]; tmp = cdvd.Param[2];
cdvd.Param[2] = cdvd.Param[3]; cdvd.Param[2] = cdvd.Param[3];
cdvd.Param[3] = tmp; cdvd.Param[3] = tmp;
cdvd.Result[0] = cdvdWriteNVM(&cdvd.Param[2], address*2, 2); cdvd.Result[0] = cdvdWriteNVM(&cdvd.Param[2], address*2, 2);
} else { }
else
{
cdvd.Result[0] = 0xff; cdvd.Result[0] = 0xff;
} }
break; break;
@ -2020,8 +1993,11 @@ void cdvdWrite16(u8 rt) // SCOMMAND
case 0x8D: // sceMgWriteData case 0x8D: // sceMgWriteData
SetResultSize(1);//in:length<=16 SetResultSize(1);//in:length<=16
if (cdvd.mg_size + cdvd.ParamC > cdvd.mg_maxsize) if (cdvd.mg_size + cdvd.ParamC > cdvd.mg_maxsize)
{
cdvd.Result[0] = 0x80; cdvd.Result[0] = 0x80;
else{ }
else
{
memcpy_fast(cdvd.mg_buffer + cdvd.mg_size, cdvd.Param, cdvd.ParamC); memcpy_fast(cdvd.mg_buffer + cdvd.mg_size, cdvd.Param, cdvd.ParamC);
cdvd.mg_size += cdvd.ParamC; cdvd.mg_size += cdvd.ParamC;
cdvd.Result[0] = 0; // 0 complete ; 1 busy ; 0x80 error 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 0x88: // secrman: __mechacon_auth_0x88 //for now it is the same; so, fall;)
case 0x8F: // secrman: __mechacon_auth_0x8F case 0x8F: // secrman: __mechacon_auth_0x8F
// fixme: Needs a rewrite that doesn't involve gotos.
SetResultSize(1);//in:0 SetResultSize(1);//in:0
if (cdvd.mg_datatype == 1){// header data if (cdvd.mg_datatype == 1) // header data
u64* psrc, *pdst; {
u64* psrc, *pdst;
int bit_ofs, i; int bit_ofs, i;
if (cdvd.mg_maxsize != cdvd.mg_size) 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 < 0x20) goto fail_pol_cal;
if (cdvd.mg_size != *(u16*)&cdvd.mg_buffer[0x14]) 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=", 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], *(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]); *(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("%s ", mg_zones[i]);
SysPrintf("\n"); SysPrintf("\n");
bit_ofs = mg_BIToffset(cdvd.mg_buffer); bit_ofs = mg_BIToffset(cdvd.mg_buffer);
psrc = (u64*)&cdvd.mg_buffer[bit_ofs-0x20];
pdst = (u64*)cdvd.mg_kbit; psrc = (u64*)&cdvd.mg_buffer[bit_ofs-0x20];
pdst[0] = psrc[0]; pdst[1] = psrc[1];//memcpy(cdvd.mg_kbit, &cdvd.mg_buffer[bit_ofs-0x20], 0x10); pdst = (u64*)cdvd.mg_kbit;
pdst = (u64*)cdvd.mg_kcon;
pdst[0] = psrc[2]; pdst[1] = psrc[3];//memcpy(cdvd.mg_kcon, &cdvd.mg_buffer[bit_ofs-0x10], 0x10); 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]){ if (cdvd.mg_buffer[bit_ofs+4] * 16 + bit_ofs + 8 + 16 != *(u16*)&cdvd.mg_buffer[0x14]){
fail_pol_cal: fail_pol_cal:
Console::Error("[MG] ERROR - Make sure the file is already decrypted!!!"); Console::Error("[MG] ERROR - Make sure the file is already decrypted!!!");
@ -2080,11 +2066,12 @@ fail_pol_cal:
break; break;
case 0x91: // sceMgReadBITLength case 0x91: // sceMgReadBITLength
{
SetResultSize(3);//in:0 SetResultSize(3);//in:0
{
int bit_ofs = mg_BIToffset(cdvd.mg_buffer); 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]); 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_maxsize = 0; // don't allow any write
cdvd.mg_size = 8+16*cdvd.mg_buffer[4];//new offset, i just moved the data 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]); 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[1] = (cdvd.mg_size >> 0) & 0xFF;
cdvd.Result[2] = (cdvd.mg_size >> 8) & 0xFF; cdvd.Result[2] = (cdvd.mg_size >> 8) & 0xFF;
break; break;
}
case 0x92: // sceMgWriteDatainLength case 0x92: // sceMgWriteDatainLength
cdvd.mg_size = 0; cdvd.mg_size = 0;
cdvd.mg_datatype = 0;//data (encrypted) cdvd.mg_datatype = 0;//data (encrypted)
@ -2104,40 +2091,48 @@ fail_pol_cal:
case 0x93: // sceMgWriteDataoutLength case 0x93: // sceMgWriteDataoutLength
SetResultSize(1);//in:2 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.mg_maxsize = 0; // don't allow any write
cdvd.Result[0] = 0; // 0 complete ; 1 busy ; 0x80 error cdvd.Result[0] = 0; // 0 complete ; 1 busy ; 0x80 error
}else }
else
{
cdvd.Result[0] = 0x80; cdvd.Result[0] = 0x80;
}
break; break;
case 0x94: // sceMgReadKbit - read first half of BIT key case 0x94: // sceMgReadKbit - read first half of BIT key
SetResultSize(1+8);//in:0 SetResultSize(1+8);//in:0
cdvd.Result[0] = 0; cdvd.Result[0] = 0;
((int*)(cdvd.Result+1))[0] = ((int*)cdvd.mg_kbit)[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); ((int*)(cdvd.Result+1))[1] = ((int*)cdvd.mg_kbit)[1];
break; //memcpy(cdvd.Result+1, cdvd.mg_kbit, 8);
break;
case 0x95: // sceMgReadKbit2 - read second half of BIT key case 0x95: // sceMgReadKbit2 - read second half of BIT key
SetResultSize(1+8);//in:0 SetResultSize(1+8);//in:0
cdvd.Result[0] = 0; cdvd.Result[0] = 0;
((int*)(cdvd.Result+1))[0] = ((int*)(cdvd.mg_kbit+8))[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))[1] = ((int*)(cdvd.mg_kbit+8))[1];
//memcpy(cdvd.Result+1, cdvd.mg_kbit+8, 8);
break; break;
case 0x96: // sceMgReadKcon - read first half of content key case 0x96: // sceMgReadKcon - read first half of content key
SetResultSize(1+8);//in:0 SetResultSize(1+8);//in:0
cdvd.Result[0] = 0; cdvd.Result[0] = 0;
((int*)(cdvd.Result+1))[0] = ((int*)cdvd.mg_kcon)[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))[1] = ((int*)cdvd.mg_kcon)[1];
//memcpy(cdvd.Result+1, cdvd.mg_kcon, 8);
break; break;
case 0x97: // sceMgReadKcon2 - read second half of content key case 0x97: // sceMgReadKcon2 - read second half of content key
SetResultSize(1+8);//in:0 SetResultSize(1+8);//in:0
cdvd.Result[0] = 0; cdvd.Result[0] = 0;
((int*)(cdvd.Result+1))[0] = ((int*)(cdvd.mg_kcon+8))[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))[1] = ((int*)(cdvd.mg_kcon+8))[1];
//memcpy(cdvd.Result+1, cdvd.mg_kcon+8, 8);
break; break;
default: default:
@ -2146,9 +2141,10 @@ fail_pol_cal:
SetResultSize(1); //in:0 SetResultSize(1); //in:0
cdvd.Result[0] = 0; // 0 complete ; 1 busy ; 0x80 error cdvd.Result[0] = 0; // 0 complete ; 1 busy ; 0x80 error
break; break;
} } // end switch
//SysPrintf("SCMD - %x\n", rt);
cdvd.ParamP = 0; cdvd.ParamC = 0; //SysPrintf("SCMD - %x\n", rt);
cdvd.ParamP = 0; cdvd.ParamC = 0;
} }
void cdvdWrite17(u8 rt) { // SDATAIN void cdvdWrite17(u8 rt) { // SDATAIN

View File

@ -133,7 +133,9 @@ namespace OpcodeImpl {
* Jump to target * * Jump to target *
* Format: OP 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() void J()
{ {
doBranch(_JumpTarget_); doBranch(_JumpTarget_);
@ -215,7 +217,7 @@ void BLTZ() // Branch if Rs < 0
void BLTZAL() // Branch if Rs < 0 and link void BLTZAL() // Branch if Rs < 0 and link
{ {
_SetLink(31); \ _SetLink(31);
if (cpuRegs.GPR.r[_Rs_].SD[0] < 0) if (cpuRegs.GPR.r[_Rs_].SD[0] < 0)
{ {
doBranch(_BranchTarget_); doBranch(_BranchTarget_);

View File

@ -171,29 +171,33 @@ const char *biosC0n[256] = {
#define Rv0 (iopVirtMemR<char>(v0)) #define Rv0 (iopVirtMemR<char>(v0))
#define Rsp (iopVirtMemR<char>(sp)) #define Rsp (iopVirtMemR<char>(sp))
void bios_write() { // 0x35/0x03 void bios_write() // 0x35/0x03
{
if (a0 == 1) // stdout
if (a0 == 1) { // stdout {
const char *ptr = Ra1; const char *ptr = Ra1;
while (a2 > 0) { while (a2 > 0)
SysPrintf("%c", *ptr++); a2--; {
Console::Write("%c", params *ptr++);
a2--;
} }
pc0 = ra; return; }
} else
PSXBIOS_LOG("bios_%s: %x,%x,%x", biosB0n[0x35], a0, a1, a2); {
PSXBIOS_LOG("bios_%s: %x,%x,%x", biosB0n[0x35], a0, a1, a2);
v0 = -1; v0 = -1;
}
pc0 = ra; pc0 = ra;
} }
void bios_printf() { // 3f void bios_printf() // 3f
char tmp[1024]; {
char tmp2[1024]; char tmp[1024], tmp2[1024];
unsigned long save[4]; u32 save[4];
char *ptmp = tmp; char *ptmp = tmp;
int n=1, i=0, j; int n=1, i=0, j = 0;
memcpy(save, iopVirtMemR<void>(sp), 4*4); memcpy(save, iopVirtMemR<void>(sp), 4*4);
@ -201,58 +205,86 @@ void bios_printf() { // 3f
iopMemWrite32(sp + 4, a1); iopMemWrite32(sp + 4, a1);
iopMemWrite32(sp + 8, a2); iopMemWrite32(sp + 8, a2);
iopMemWrite32(sp + 12, a3); iopMemWrite32(sp + 12, a3);
// old code used phys... is tlb more correct? // old code used phys... is tlb more correct?
//psxMu32(sp) = a0; //psxMu32(sp) = a0;
//psxMu32(sp + 4) = a1; //psxMu32(sp + 4) = a1;
//psxMu32(sp + 8) = a2; //psxMu32(sp + 8) = a2;
//psxMu32(sp + 12) = a3; //psxMu32(sp + 12) = a3;+
while (Ra0[i]) { while (Ra0[i])
switch (Ra0[i]) { {
switch (Ra0[i])
{
case '%': case '%':
j = 0; j = 0;
tmp2[j++] = '%'; tmp2[j++] = '%';
_start: _start:
switch (Ra0[++i]) { switch (Ra0[++i])
{
case '.': case '.':
case 'l': case 'l':
tmp2[j++] = Ra0[i]; goto _start; tmp2[j++] = Ra0[i];
goto _start;
default: default:
if (Ra0[i] >= '0' && Ra0[i] <= '9') { if (Ra0[i] >= '0' && Ra0[i] <= '9')
{
tmp2[j++] = Ra0[i]; tmp2[j++] = Ra0[i];
goto _start; goto _start;
} }
break; break;
} }
tmp2[j++] = Ra0[i]; tmp2[j++] = Ra0[i];
tmp2[j] = 0; tmp2[j] = 0;
switch (Ra0[i]) { switch (Ra0[i])
{
case 'f': case 'F': 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 'a': case 'A':
case 'e': case 'E': case 'e': case 'E':
case 'g': case 'G': 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 'p':
case 'i': case 'i':
case 'd': case 'D': case 'd': case 'D':
case 'o': case 'O': case 'o': case 'O':
case 'x': case 'X': 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': 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': case 's':
ptmp+= sprintf(ptmp, tmp2, iopVirtMemR<char>(iopMemRead32(sp + n * 4))); n++; break; ptmp+= sprintf(ptmp, tmp2, iopVirtMemR<char>(iopMemRead32(sp + n * 4)));
n++;
break;
case '%': case '%':
*ptmp++ = Ra0[i]; break; *ptmp++ = Ra0[i];
break;
default:
break;
} }
i++; i++;
break; break;
default: default:
*ptmp++ = Ra0[i++]; *ptmp++ = Ra0[i++];
break;
} }
} }
*ptmp = 0; *ptmp = 0;
@ -260,18 +292,18 @@ _start:
// Note: Use Read to obtain a write pointer here, since we're just writing back the // Note: Use Read to obtain a write pointer here, since we're just writing back the
// temp buffer we saved earlier. // temp buffer we saved earlier.
memcpy( (void*)iopVirtMemR<void>(sp), save, 4*4); memcpy( (void*)iopVirtMemR<void>(sp), save, 4*4);
Console::Write( Color_Cyan, "%s", params tmp); Console::Write( Color_Cyan, "%s", params tmp);
pc0 = ra; pc0 = ra;
} }
void bios_putchar () { // 3d void bios_putchar () // 3d
{
Console::Write( Color_Cyan, "%c", params a0 ); Console::Write( Color_Cyan, "%c", params a0 );
pc0 = ra; pc0 = ra;
} }
void bios_puts () { // 3e/3f void bios_puts () // 3e/3f
{
Console::Write( Color_Cyan, Ra0 ); Console::Write( Color_Cyan, Ra0 );
pc0 = ra; pc0 = ra;
} }
@ -280,10 +312,12 @@ void (*biosA0[256])();
void (*biosB0[256])(); void (*biosB0[256])();
void (*biosC0[256])(); void (*biosC0[256])();
void psxBiosInit() { void psxBiosInit()
{
int i; int i;
for(i = 0; i < 256; i++) { for(i = 0; i < 256; i++)
{
biosA0[i] = NULL; biosA0[i] = NULL;
biosB0[i] = NULL; biosB0[i] = NULL;
biosC0[i] = NULL; biosC0[i] = NULL;
@ -296,7 +330,8 @@ void psxBiosInit() {
} }
void psxBiosShutdown() { void psxBiosShutdown()
{
} }
} // end namespace R3000A } // end namespace R3000A

View File

@ -335,43 +335,96 @@ void spyFunctions(){
} }
} }
*/ */
/********************************************************* /*********************************************************
* Register branch logic * * Register branch logic *
* Format: OP rs, offset * * 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 psxBGEZ() // Branch if Rs >= 0
void psxBGEZAL() { RepZBranchLinki32(>=) } // Branch if Rs >= 0 and link {
void psxBGTZ() { RepZBranchi32(>) } // Branch if Rs > 0 if (_i32(_rRs_) >= 0) doBranch(_BranchTarget_);
void psxBLEZ() { RepZBranchi32(<=) } // Branch if Rs <= 0 }
void psxBLTZ() { RepZBranchi32(<) } // Branch if Rs < 0
void psxBLTZAL() { RepZBranchLinki32(<) } // Branch if Rs < 0 and link 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 * * Register branch logic *
* Format: OP rs, rt, offset * * Format: OP rs, rt, offset *
*********************************************************/ *********************************************************/
#define RepBranchi32(op) if(_i32(_rRs_) op _i32(_rRt_)) doBranch(_BranchTarget_);
void psxBEQ() { RepBranchi32(==) } // Branch if Rs == Rt void psxBEQ() // Branch if Rs == Rt
void psxBNE() { RepBranchi32(!=) } // 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 * * Jump to target *
* Format: OP target * * Format: OP target *
*********************************************************/ *********************************************************/
void psxJ() { doBranch(_JumpTarget_); } void psxJ()
void psxJAL() { _SetLink(31); doBranch(_JumpTarget_); /*spyFunctions();*/ } {
doBranch(_JumpTarget_);
}
void psxJAL()
{
_SetLink(31);
doBranch(_JumpTarget_);
/*spyFunctions();*/
}
/********************************************************* /*********************************************************
* Register jump * * Register jump *
* Format: OP rs, rd * * Format: OP rs, rd *
*********************************************************/ *********************************************************/
void psxJR() { doBranch(_u32(_rRs_)); } void psxJR()
void psxJALR() { if (_Rd_) { _SetLink(_Rd_); } doBranch(_u32(_rRs_)); } {
doBranch(_u32(_rRs_));
}
void psxJALR()
{
if (_Rd_)
{
_SetLink(_Rd_);
}
doBranch(_u32(_rRs_));
}
/////////////////////////////////////////// ///////////////////////////////////////////
// These macros are used to assemble the repassembler functions // These macros are used to assemble the repassembler functions

View File

@ -93,24 +93,6 @@ then
fi fi
AC_MSG_RESULT($devbuild) 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 dnl gtk
AC_MSG_CHECKING(gtk+) AC_MSG_CHECKING(gtk+)
AC_CHECK_PROG(GTK_CONFIG, pkg-config, pkg-config) AC_CHECK_PROG(GTK_CONFIG, pkg-config, pkg-config)
@ -153,7 +135,6 @@ echo "Configuration:"
echo " Target system type: $target" echo " Target system type: $target"
echo " Debug build? $debug" echo " Debug build? $debug"
echo " Dev build? $devbuild" echo " Dev build? $devbuild"
echo " Force sse3? $sse3"
echo " nls support? $nls" echo " nls support? $nls"
echo " local plugin inis? $localinis" echo " local plugin inis? $localinis"
echo " custom cflags? $customcflags" echo " custom cflags? $customcflags"