mirror of https://github.com/PCSX2/pcsx2.git
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
This commit is contained in:
parent
b6ba2f050f
commit
bc9e0b08ad
|
@ -58,8 +58,6 @@
|
|||
// disable the default case in a switch
|
||||
#define jNO_DEFAULT \
|
||||
{ \
|
||||
break; \
|
||||
\
|
||||
default: \
|
||||
jASSUME(0); \
|
||||
break; \
|
||||
|
|
1007
pcsx2/CDVD.cpp
1007
pcsx2/CDVD.cpp
File diff suppressed because it is too large
Load Diff
256
pcsx2/CDVD.h
256
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__ */
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue