mirror of https://github.com/PCSX2/pcsx2.git
CDVD fix: "CDVD Ready" and "Seek Complete" flags are managed correctly now, and Cdvd timing accuracy is more precise.
Disabled PS2 BIOS console logging in non-dev Release builds. Win32: Profiler no longer freezes the emulator for 1-3 seconds during startup. (and yes I'll make it an option soon!) Win32: Updated build names in project and workspace files Code cleanups: * Heavy modifications to how Pcsx2 devbuild logging works. Devbuilds should be a bit more efficient now. * Removed all color tags from SysPrintf's. The colors didn't work on Win32 builds (may have worked on linux) and were needlessly complex. Will replace them with a (working!) console colorizer that works on a per log-type basis soon. * Added a new Console namespace with various replacements for SysPrintf. API is loosely modeled after C#'s Console class. git-svn-id: http://pcsx2-playground.googlecode.com/svn/trunk@476 a6443dda-0b58-4228-96e9-037be469359c
This commit is contained in:
parent
8650ba5817
commit
8654341dec
292
pcsx2/CDVD.c
292
pcsx2/CDVD.c
|
@ -35,6 +35,31 @@
|
|||
static cdvdStruct cdvd;
|
||||
static int cdCaseopen;
|
||||
|
||||
// -- Cdvd Block Read Cycle Timings --
|
||||
// These timings are based on a median average block read speed. In theory the read
|
||||
// speeds differ based on the location of the sector being read (outer rings have
|
||||
// a different read speed from inner rings). But for our purposes an average is good
|
||||
// enough, since all of Pcsx2's instruction cycle counting is hardly accurate anyway.
|
||||
|
||||
// Morale of the story: don't get too caught up micro-managing your cycle timings. :)
|
||||
|
||||
// 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.
|
||||
|
||||
static const uint PSX_CD_READSPEED = 153600; // 1 Byte Time @ x1 (150KB = cd x 1)
|
||||
static const uint PSX_DVD_READSPEED = 1382400 + 100000; // normal is 1 Byte Time @ x1 (1350KB = dvd x 1).
|
||||
|
||||
enum CDVD_MODE_TYPE
|
||||
{
|
||||
MODE_DVDROM,
|
||||
MODE_CDROM
|
||||
};
|
||||
|
||||
// if a seek is within this many blocks, read instead of seek.
|
||||
// I picked 6 as an arbitrary value. Not sure what the real PS2 uses.
|
||||
static const int Cdvd_Contigious_Seek = 6;
|
||||
static const uint Cdvd_Avg_SeekCycles = (PSXCLK*110) / 1000; // average number of cycles per seek (110ms)
|
||||
|
||||
|
||||
const char *mg_zones[8] = {"Japan", "USA", "Europe", "Oceania", "Asia", "Russia", "China", "Mexico"};
|
||||
|
||||
|
@ -559,6 +584,7 @@ s32 cdvdGetTrayStatus()
|
|||
// Note: Is tray status being kept as a var here somewhere?
|
||||
// cdvdNewDiskCB() can update it's status as well...
|
||||
extern int needReset;
|
||||
|
||||
// Modified by (efp) - 16/01/2006
|
||||
s32 cdvdGetDiskType() {
|
||||
// defs 0.9.0
|
||||
|
@ -625,24 +651,22 @@ s32 cdvdReadDvdDualInfo(s32* dualType, u32* layer1Start)
|
|||
|
||||
#include <time.h>
|
||||
|
||||
#define PSX_CD_READSPEED (PSXCLK / 153600) // 1 Byte Time @ x1 (150KB = cd x 1)
|
||||
#define PSX_DVD_READSPEED (PSXCLK / 1382400) // normal is 1 Byte Time @ x1 (1350KB = dvd x 1)
|
||||
|
||||
enum CDVD_MODE_TYPE
|
||||
static uint cdvdBlockReadTime( CDVD_MODE_TYPE mode )
|
||||
{
|
||||
MODE_DVDROM,
|
||||
MODE_CDROM
|
||||
};
|
||||
return (PSXCLK * cdvd.BlockSize) / (((mode==MODE_CDROM) ? PSX_CD_READSPEED : PSX_DVD_READSPEED) * cdvd.Speed);
|
||||
}
|
||||
|
||||
static void cdvdReadTimeRcnt(CDVD_MODE_TYPE mode) // Mode 0 is DVD, Mode 1 is CD
|
||||
/*static void cdvdReadTimeRcnt(CDVD_MODE_TYPE mode) // Mode 0 is DVD, Mode 1 is CD
|
||||
{
|
||||
if (cdvd.Sector == 16) //DVD TOC
|
||||
cdvdReadTime = 30000; //simulates spin-up time, fixes hdloader
|
||||
cdvdReadTime = 30000; //simulates spin-up time, fixes hdloader // wtf? just how old is this hack? goodbye, I say! (air)
|
||||
else
|
||||
cdvdReadTime = ( ((mode==MODE_CDROM) ? PSX_CD_READSPEED : PSX_DVD_READSPEED) * cdvd.BlockSize ) / cdvd.Speed;
|
||||
}*/
|
||||
|
||||
//SysPrintf("cdvdReadTime = %d \n", cdvdReadTime);
|
||||
}
|
||||
// Incurs an extra delay for the first read operation of the Cdvd drive.
|
||||
// fixme: this should be part of the cdvd struct and saved as part of the savestate.
|
||||
static bool cdvdSpinUp = false;
|
||||
|
||||
void cdvdReset()
|
||||
{
|
||||
|
@ -657,13 +681,15 @@ void cdvdReset()
|
|||
ptlocal = localtime(&traw);
|
||||
#endif
|
||||
|
||||
cdvdSpinUp = false;
|
||||
|
||||
memset(&cdvd, 0, sizeof(cdvd));
|
||||
cdvd.sDataIn = 0x40;
|
||||
cdvd.Ready = 0x4e;
|
||||
cdCaseopen = 0;
|
||||
cdvd.Speed = 4;
|
||||
cdvd.BlockSize = 2064;
|
||||
cdvdReadTimeRcnt(MODE_DVDROM);
|
||||
cdvdReadTime = cdvdBlockReadTime( MODE_DVDROM );
|
||||
|
||||
// any random valid date will do
|
||||
cdvd.RTC.hour = 1;
|
||||
|
@ -691,85 +717,8 @@ void cdvdReset()
|
|||
|
||||
}
|
||||
|
||||
//void cdvdReadTimeRcnt(int mode){ // Mode 0 is DVD, Mode 1 is CD
|
||||
//
|
||||
// /* rant by giga:
|
||||
//
|
||||
// 4x reading speed = ~5.40mb/s
|
||||
// 4x reading time = ~0,185 seconds/mb
|
||||
// = ~0.00036169e-4 seconds/sector
|
||||
// = ~0.36169 ms/sector
|
||||
//
|
||||
// psx clock = 48000 * 768 = 36864000 Hz
|
||||
//
|
||||
// 4x reading time = 13333 cycles/sector
|
||||
//
|
||||
// so:
|
||||
// 1x reading time = 53333 cycles/sector
|
||||
//
|
||||
// now:
|
||||
// ps2's drive is CAV, so at the end of the disc it gets faster.
|
||||
// The inner edge is roughly 2cm radius, while the outer edge is 6cm
|
||||
//
|
||||
// so at the outer edge, the speed is roughly 3x the speed at the inner edge.
|
||||
//
|
||||
// question: the 1x speed refers to the inner or the outer edge? I assume inner.
|
||||
//
|
||||
// (cottonvibes: i think this assumption is wrong, a cd's 1x speed is their theoretical fastest read-speed
|
||||
// so you should assume the fastest value as the base speed. therfore you should start
|
||||
// with the outer-edge, and base your calculations on that.)
|
||||
//
|
||||
// then:
|
||||
// if the inner timing is 53333cycles/sector
|
||||
// then the outer timing woudl be 1/3 of that
|
||||
//
|
||||
// so:
|
||||
// 1x outer reading time = 17777 cycles/sector
|
||||
//
|
||||
// 1x reading time would follow a function similar to:
|
||||
//
|
||||
// f(start_sector->cycle_delay) = 53333 - (start_sector) * (53333-17777) / cdvd_layer_size
|
||||
//
|
||||
// assuming cdvd_layer_size is 2300000 (it's slightly smaller)
|
||||
// we can say:
|
||||
//
|
||||
// f(start_sector->cycle_delay) = 53333 - (start_sector) * (53333-17777) / 2300000
|
||||
//
|
||||
// because those numbers are too ugly, I will simplify everything and round it up
|
||||
//
|
||||
// f(start_sector->cycle_delay) = 54000 - (start_sector) * (54-18) / 2300
|
||||
// f(start_sector->cycle_delay) = 54000 - (start_sector) * 36 / 2300
|
||||
// f(start_sector->cycle_delay) = 54000 - (start_sector) / 64
|
||||
// f(start_sector->cycle_delay) = 54000 - (start_sector >> 6)
|
||||
//
|
||||
// */
|
||||
//
|
||||
// static int last_sector = 0;
|
||||
//
|
||||
// int start_sector = cdvd.Sector;
|
||||
//
|
||||
// int amount = (cdvd.BlockSize+2047)/2048; // in Sectors
|
||||
//
|
||||
// int sector_difference = abs(start_sector - last_sector);
|
||||
//
|
||||
// if(mode==0)
|
||||
// {
|
||||
// cdvdReadTime = (54000 - (start_sector >> 6)) * amount / cdvd.Speed;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// // 1 sector = 1/75 of a second
|
||||
// cdvdReadTime = (PSXCLK * amount / 75) / cdvd.Speed; //150KB = cd x 1
|
||||
// }
|
||||
//
|
||||
// //calculate seek delay
|
||||
// cdvdReadTime += sector_difference / 14;
|
||||
//
|
||||
// SysPrintf("CDVD Cnt Time = %d Sector difference: %d \n", cdvdReadTime, sector_difference);
|
||||
// last_sector = start_sector;
|
||||
//}
|
||||
|
||||
int cdvdFreeze(gzFile f, int Mode) {
|
||||
int cdvdFreeze(gzFile f, int Mode)
|
||||
{
|
||||
gzfreeze(&cdvd, sizeof(cdvd));
|
||||
if (Mode == FREEZE_LOAD) {
|
||||
if (cdvd.Reading) {
|
||||
|
@ -785,7 +734,8 @@ int cdvdInterrupt() {
|
|||
}
|
||||
|
||||
// Modified by (efp) - 16/01/2006
|
||||
void cdvdNewDiskCB() {
|
||||
void cdvdNewDiskCB()
|
||||
{
|
||||
cdvd.Type = CDVDgetDiskType();
|
||||
if(cdvd.Type == CDVD_TYPE_PS2CD) {
|
||||
char str[g_MaxPath];
|
||||
|
@ -817,14 +767,16 @@ int cdvdReadSector() {
|
|||
|
||||
bcr = (HW_DMA3_BCR_H16 * HW_DMA3_BCR_L16) *4;
|
||||
if (bcr < cdvd.BlockSize) {
|
||||
//SysPrintf("*PCSX2*: cdvdReadSector: bcr < cdvd.BlockSize; %x < %x\n", bcr, cdvd.BlockSize);
|
||||
CDR_LOG( "READBLOCK: bcr < cdvd.BlockSize; %x < %x\n", bcr, cdvd.BlockSize );
|
||||
if (HW_DMA3_CHCR & 0x01000000) {
|
||||
HW_DMA3_CHCR &= ~0x01000000;
|
||||
psxDmaInterrupt(3);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
FreezeMMXRegs(1);
|
||||
|
||||
// if raw dvd sector 'fill in the blanks'
|
||||
if (cdvd.BlockSize == 2064) {
|
||||
// get info on dvd type and layer1 start
|
||||
|
@ -832,6 +784,7 @@ int cdvdReadSector() {
|
|||
s32 dualType;
|
||||
s32 layerNum;
|
||||
u32 lsn = cdvd.Sector;
|
||||
|
||||
cdvdReadDvdDualInfo(&dualType, &layer1Start);
|
||||
|
||||
if((dualType == 1) && (lsn >= layer1Start)) {
|
||||
|
@ -898,13 +851,22 @@ __forceinline void cdvdReadInterrupt() {
|
|||
psxRegs.interrupt &= ~(1<<19);
|
||||
|
||||
cdvd.Ready = 0x00;
|
||||
if (cdvd.Readed == 0) {
|
||||
if (cdvd.Readed == 0)
|
||||
{
|
||||
// Seeking finished. Process the track we requested before, and
|
||||
// then schedule another CDVD read int for when the block read finishes.
|
||||
|
||||
// NOTE: The first CD track was read when the seek was initiated, so no need
|
||||
// to call CDVDReadTrack here.
|
||||
|
||||
cdvd.RetryCntP = 0;
|
||||
cdvd.Reading = 1;
|
||||
cdvd.RErr = CDVDreadTrack(cdvd.Sector, cdvd.ReadMode);
|
||||
cdvd.Readed = 1;
|
||||
cdvd.Status = CDVD_STATUS_SEEK_COMPLETE;
|
||||
CDVDREAD_INT(cdvdReadTime*24);
|
||||
|
||||
CDR_LOG( "Cdvd Seek Complete > Scheduling block read interrupt at iopcycle=%8.8x.\n", psxRegs.cycle + cdvdReadTime );
|
||||
|
||||
CDVDREAD_INT(cdvdReadTime);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -914,7 +876,7 @@ __forceinline void cdvdReadInterrupt() {
|
|||
} else cdr.pTransfer = NULL;
|
||||
if (cdr.pTransfer == NULL) {
|
||||
cdvd.RetryCntP++;
|
||||
SysPrintf("READ ERROR %d\n", cdvd.Sector);
|
||||
SysPrintf("CDVD READ ERROR, sector=%d\n", cdvd.Sector);
|
||||
if (cdvd.RetryCntP <= cdvd.RetryCnt) {
|
||||
cdvd.RErr = CDVDreadTrack(cdvd.Sector, cdvd.ReadMode);
|
||||
CDVDREAD_INT(cdvdReadTime);
|
||||
|
@ -923,6 +885,7 @@ __forceinline void cdvdReadInterrupt() {
|
|||
}
|
||||
cdvd.Reading = 0;
|
||||
}
|
||||
|
||||
if (cdvdReadSector() == -1) {
|
||||
assert( (int)cdvdReadTime > 0 );
|
||||
CDVDREAD_INT(cdvdReadTime);
|
||||
|
@ -1196,6 +1159,41 @@ u8 cdvdRead3A(void) { // DEC_SET
|
|||
}
|
||||
|
||||
|
||||
// Initiates a Cdvd seek from the current sector to the assigned SeekSector.
|
||||
// Fixme: Should the seek set the cdvd.Sector immediately, or only when the
|
||||
// seek has finished? Current implementation is immediate. (the sector is readable
|
||||
// by HW registers so it could be important!)
|
||||
static void cdvdStartSeek( uint oldsector )
|
||||
{
|
||||
uint delta = abs(cdvd.Sector - oldsector);
|
||||
uint seektime;
|
||||
|
||||
if( !cdvdSpinUp )
|
||||
{
|
||||
cdvdSpinUp = true;
|
||||
CDR_LOG( "CdSpinUp > Simulating CdRom Spinup Time...\n", cdvd.Sector, oldsector, delta );
|
||||
seektime = PSXCLK / 3; // 333ms delay
|
||||
}
|
||||
else if( (Cdvd_Contigious_Seek >= 0) && (delta >= Cdvd_Contigious_Seek) )
|
||||
{
|
||||
CDR_LOG( "CdSeek Begin > to sector %d, from %d - delta=%d\n", cdvd.Sector, oldsector, delta );
|
||||
seektime = Cdvd_Avg_SeekCycles;
|
||||
}
|
||||
else
|
||||
{
|
||||
CDR_LOG( "CdSeek Begin > Contigious block without seek - delta=%d sectors\n", delta );
|
||||
|
||||
// seektime is the time it takes to read to the destination block:
|
||||
seektime = delta * cdvdBlockReadTime( MODE_CDROM );
|
||||
}
|
||||
|
||||
cdvd.Ready = 0;
|
||||
cdvd.Reading = 0;
|
||||
cdvd.Readed = 0;
|
||||
cdvd.PwOff = 2;//cmdcmplt
|
||||
|
||||
CDVDREAD_INT(seektime);
|
||||
}
|
||||
|
||||
void cdvdWrite04(u8 rt) { // NCOMMAND
|
||||
CDR_LOG("cdvdWrite04: NCMD %s (%x) (ParamP = %x)\n", nCmdName[rt], rt, cdvd.ParamP);
|
||||
|
@ -1218,19 +1216,32 @@ void cdvdWrite04(u8 rt) { // NCOMMAND
|
|||
//SBUS
|
||||
hwIntcIrq(INTC_SBUS);
|
||||
break;
|
||||
|
||||
// should we change the sector location here?
|
||||
case 0x05: // CdSeek
|
||||
cdvd.Sector = *(int*)(cdvd.Param+0);
|
||||
{
|
||||
int newsector = *(int*)(cdvd.Param+0);
|
||||
uint delta = abs(newsector - cdvd.Sector);
|
||||
|
||||
CDR_LOG( "Cdrom Seek Immed > Sectors: from %d, to %d, delta=%d\n", cdvd.Sector, newsector, delta );
|
||||
cdvd.Sector = newsector;
|
||||
|
||||
// Should the IntcIrq be thrown now? Or should it be scheduled
|
||||
// for the future when the seek has actually completed?
|
||||
|
||||
psxHu32(0x1070)|= 0x4;
|
||||
//SBUS
|
||||
hwIntcIrq(INTC_SBUS);
|
||||
break;
|
||||
}
|
||||
|
||||
case 0x06: // CdRead
|
||||
cdvd.Sector = *(int*)(cdvd.Param+0);
|
||||
{
|
||||
int oldSector = cdvd.Sector;
|
||||
|
||||
cdvd.Sector = *(int*)(cdvd.Param+0);
|
||||
cdvd.nSectors = *(int*)(cdvd.Param+4);
|
||||
if (cdvd.Param[8] == 0) cdvd.RetryCnt = 0x100;
|
||||
else cdvd.RetryCnt = cdvd.Param[8];
|
||||
cdvd.RetryCnt = (cdvd.Param[8] == 0) ? 0x100 : cdvd.Param[8];
|
||||
cdvd.SpindlCtrl = cdvd.Param[9];
|
||||
cdvd.Speed = 24;
|
||||
switch (cdvd.Param[10]) {
|
||||
|
@ -1239,19 +1250,25 @@ void cdvdWrite04(u8 rt) { // NCOMMAND
|
|||
case 0: default: cdvd.ReadMode = CDVD_MODE_2048; cdvd.BlockSize = 2048; break;
|
||||
}
|
||||
|
||||
cdvdReadTimeRcnt(MODE_CDROM);
|
||||
CDR_LOG( "CdRead > startSector=%d, nSectors=%d, RetryCnt=%x, Speed=%x(%x), ReadMode=%x(%x) (1074=%x)\n",
|
||||
cdvd.Sector, cdvd.nSectors, cdvd.RetryCnt, cdvd.Speed, cdvd.Param[9], cdvd.ReadMode, cdvd.Param[10], psxHu32(0x1074));
|
||||
|
||||
CDR_LOG( "CdRead: %d, nSectors=%d, RetryCnt=%x, Speed=%x(%x), ReadMode=%x(%x) (1074=%x)\n", cdvd.Sector, cdvd.nSectors, cdvd.RetryCnt, cdvd.Speed, cdvd.Param[9], cdvd.ReadMode, cdvd.Param[10], psxHu32(0x1074));
|
||||
//SysPrintf("CdRead: Reading Sector %d(%d Blocks of Size %d) at Speed=%dx\n", cdvd.Sector, cdvd.nSectors,cdvd.BlockSize,cdvd.Speed);
|
||||
// Read-ahead by telling the plugin about the track now.
|
||||
// This helps improve performance on actual from-cd emulation
|
||||
// (ie, not using the hard drive)
|
||||
|
||||
cdvd.Readed = 0;
|
||||
cdvd.PwOff = 2;//cmdcmplt
|
||||
CDVDREAD_INT(1);
|
||||
cdvd.RErr = CDVDreadTrack( cdvd.Sector, cdvd.ReadMode );
|
||||
cdvdReadTime = cdvdBlockReadTime( MODE_CDROM );
|
||||
cdvdStartSeek( oldSector );
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case 0x07: // CdReadCDDA
|
||||
case 0x0E: // CdReadXCDDA
|
||||
{
|
||||
int oldSector = cdvd.Sector;
|
||||
|
||||
cdvd.Sector = *(int*)(cdvd.Param+0);
|
||||
cdvd.nSectors = *(int*)(cdvd.Param+4);
|
||||
if (cdvd.Param[8] == 0) cdvd.RetryCnt = 0x100;
|
||||
|
@ -1269,15 +1286,27 @@ void cdvdWrite04(u8 rt) { // NCOMMAND
|
|||
case 2:
|
||||
case 0: cdvd.ReadMode = CDVD_MODE_2352; cdvd.BlockSize = 2352; break;
|
||||
}
|
||||
cdvdReadTimeRcnt(MODE_CDROM);
|
||||
//SysPrintf("CdAudioRead: Reading Sector %d(%d Blocks of Size %d) at Speed=%dx\n", cdvd.Sector, cdvd.nSectors,cdvd.BlockSize,cdvd.Speed);
|
||||
|
||||
cdvd.Readed = 0;
|
||||
cdvd.PwOff = 2;//cmdcmplt
|
||||
CDVDREAD_INT(1);
|
||||
|
||||
CDR_LOG( "CdReadCDDA > startSector=%d, nSectors=%d, RetryCnt=%x, Speed=%xx(%x), ReadMode=%x(%x) (1074=%x)\n",
|
||||
cdvd.Sector, cdvd.nSectors, cdvd.RetryCnt, cdvd.Speed, cdvd.Param[9], cdvd.ReadMode, cdvd.Param[10], psxHu32(0x1074));
|
||||
|
||||
// Read-ahead by telling the plugin about the track now.
|
||||
// This helps improve performance on actual from-cd emulation
|
||||
// (ie, not using the hard drive)
|
||||
|
||||
cdvd.RErr = CDVDreadTrack( cdvd.Sector, cdvd.ReadMode );
|
||||
cdvdReadTime = cdvdBlockReadTime( MODE_CDROM );
|
||||
cdvdStartSeek( oldSector );
|
||||
break;
|
||||
}
|
||||
|
||||
case 0x08: // DvdRead
|
||||
{
|
||||
int oldSector = cdvd.Sector;
|
||||
|
||||
cdvd.Sector = *(int*)(cdvd.Param+0);
|
||||
cdvd.nSectors = *(int*)(cdvd.Param+4);
|
||||
if (cdvd.Param[8] == 0) cdvd.RetryCnt = 0x100;
|
||||
|
@ -1286,15 +1315,20 @@ void cdvdWrite04(u8 rt) { // NCOMMAND
|
|||
cdvd.Speed = 4;
|
||||
cdvd.ReadMode = CDVD_MODE_2048;
|
||||
cdvd.BlockSize = 2064; // Why oh why was it 2064
|
||||
cdvdReadTimeRcnt(MODE_DVDROM);
|
||||
|
||||
CDR_LOG( "DvdRead: %d, nSectors=%d, RetryCnt=%x, Speed=%x(%x), ReadMode=%x(%x) (1074=%x)\n", cdvd.Sector, cdvd.nSectors, cdvd.RetryCnt, cdvd.Speed, cdvd.Param[9], cdvd.ReadMode, cdvd.Param[10], psxHu32(0x1074));
|
||||
CDR_LOG( "DvdRead > startSector=%d, nSectors=%d, RetryCnt=%x, Speed=%x(%x), ReadMode=%x(%x) (1074=%x)\n",
|
||||
cdvd.Sector, cdvd.nSectors, cdvd.RetryCnt, cdvd.Speed, cdvd.Param[9], cdvd.ReadMode, cdvd.Param[10], psxHu32(0x1074));
|
||||
|
||||
// Read-ahead by telling the plugin about the track now.
|
||||
// This helps improve performance on actual from-cd emulation
|
||||
// (ie, not using the hard drive)
|
||||
|
||||
cdvd.RErr = CDVDreadTrack( cdvd.Sector, cdvd.ReadMode );
|
||||
cdvdReadTime = cdvdBlockReadTime( MODE_DVDROM );
|
||||
cdvdStartSeek( oldSector );
|
||||
|
||||
//SysPrintf("DvdRead: Reading Sector %d(%d Blocks of Size %d) at Speed=%dx\n", cdvd.Sector, cdvd.nSectors,cdvd.BlockSize,cdvd.Speed);
|
||||
cdvd.Readed = 0;
|
||||
cdvd.PwOff = 2;//cmdcmplt
|
||||
CDVDREAD_INT(1);
|
||||
break;
|
||||
}
|
||||
|
||||
case 0x09: // CdGetToc & cdvdman_call19
|
||||
//Param[0] is 0 for CdGetToc and any value for cdvdman_call19
|
||||
|
@ -1312,31 +1346,28 @@ void cdvdWrite04(u8 rt) { // NCOMMAND
|
|||
break;
|
||||
|
||||
case 0x0C: // CdReadKey
|
||||
{
|
||||
unsigned char arg0 = cdvd.Param[0];
|
||||
unsigned short arg1 = cdvd.Param[1] | (cdvd.Param[2]<<8);
|
||||
unsigned int arg2 = cdvd.Param[3] | (cdvd.Param[4]<<8) | (cdvd.Param[5]<<16) | (cdvd.Param[6]<<24);
|
||||
{
|
||||
u8 arg0 = cdvd.Param[0];
|
||||
u16 arg1 = cdvd.Param[1] | (cdvd.Param[2]<<8);
|
||||
u32 arg2 = cdvd.Param[3] | (cdvd.Param[4]<<8) | (cdvd.Param[5]<<16) | (cdvd.Param[6]<<24);
|
||||
SysPrintf("cdvdReadKey(%d, %d, %d)\n", arg0, arg1, arg2);
|
||||
cdvdReadKey(arg0, arg1, arg2, cdvd.Key);
|
||||
cdvd.KeyXor = 0x00;
|
||||
psxHu32(0x1070)|= 0x4;
|
||||
//SBUS
|
||||
hwIntcIrq(INTC_SBUS);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
case 0x0F: // CdChgSpdlCtrl
|
||||
SysPrintf("sceCdChgSpdlCtrl(%d)\n", cdvd.Param[0]);
|
||||
cdvd.PwOff = 2;//cmdcmplt
|
||||
psxHu32(0x1070)|= 0x4;
|
||||
//SBUS
|
||||
hwIntcIrq(INTC_SBUS);
|
||||
break;
|
||||
|
||||
default:
|
||||
SysPrintf("NCMD Unknown %x\n", rt);
|
||||
psxHu32(0x1070)|= 0x4;
|
||||
//SBUS
|
||||
hwIntcIrq(INTC_SBUS);
|
||||
break;
|
||||
}
|
||||
|
@ -1359,7 +1390,16 @@ void cdvdWrite06(u8 rt) { // HOWTO
|
|||
|
||||
void cdvdWrite07(u8 rt) { // BREAK
|
||||
CDR_LOG("cdvdWrite07(Break) %x\n", rt);
|
||||
SysPrintf("*PCSX2*: CDVD BREAK %x\n" , rt);
|
||||
|
||||
// fixme: Should the CDVD do anything here? Actual meaning of Break command in
|
||||
// general CDVD terms is to cancel the current program command queue. This is
|
||||
// mostly to do with running dvd menus and stuff, and I don't think it's relevant
|
||||
// to PS2 emulation.
|
||||
|
||||
// Some games use it: DigitalDevilSaga during startup and some FMVs. Not sure
|
||||
// what the purpose is supposed to be.
|
||||
|
||||
//SysPrintf("*PCSX2*: CDVD BREAK %x\n" , rt);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1375,9 +1415,7 @@ Interrupts
|
|||
*/
|
||||
|
||||
void cdvdWrite08(u8 rt) { // INTR_STAT
|
||||
#ifdef CDR_LOG
|
||||
CDR_LOG("cdvdWrite08(IntrReason) = ACK(%x)\n", rt);
|
||||
#endif
|
||||
cdvd.PwOff &= ~rt;
|
||||
}
|
||||
|
||||
|
|
|
@ -291,9 +291,7 @@ int CDVD_findfile(const char* fname, struct TocEntry* tocEntry){
|
|||
|
||||
struct dirTocEntry* tocEntryPointer;
|
||||
|
||||
#ifdef DEBUG
|
||||
SysPrintf("CDVD_findfile called\n");
|
||||
#endif
|
||||
DbgCon::WriteLn("CDVD_findfile called");
|
||||
|
||||
//make sure we have good cdReadMode
|
||||
cdReadMode.trycount = 0;
|
||||
|
|
14
pcsx2/COP0.c
14
pcsx2/COP0.c
|
@ -22,7 +22,6 @@
|
|||
#include "R5900.h"
|
||||
#include "InterTables.h"
|
||||
|
||||
//extern BOOL bExecBIOS;
|
||||
|
||||
void COP0_BC0() {
|
||||
COP0_LOG("%s\n", disR5900Current.getString());
|
||||
|
@ -172,9 +171,6 @@ void TLBR() {
|
|||
|
||||
int i = cpuRegs.CP0.n.Index&0x1f;
|
||||
|
||||
// if( !bExecBIOS )
|
||||
// __Log("TLBR %d\n", cpuRegs.CP0.n.Index&0x1f);
|
||||
|
||||
COP0_LOG("COP0 > TLBR\n");
|
||||
cpuRegs.CP0.n.PageMask = tlb[i].PageMask;
|
||||
cpuRegs.CP0.n.EntryHi = tlb[i].EntryHi&~(tlb[i].PageMask|0x1f00);
|
||||
|
@ -230,7 +226,9 @@ void MapTLB(int i)
|
|||
u32 saddr, eaddr;
|
||||
|
||||
#ifndef PCSX2_VIRTUAL_MEM
|
||||
SysPrintf("MAP TLB %d: %08x-> [%08x %08x] S=%d G=%d ASID=%d Mask= %03X\n",i,tlb[i].VPN2,tlb[i].PFN0,tlb[i].PFN1,tlb[i].S,tlb[i].G,tlb[i].ASID,tlb[i].Mask);
|
||||
DevCon::FormatLn("MAP TLB %d: %08x-> [%08x %08x] S=%d G=%d ASID=%d Mask= %03X",
|
||||
i,tlb[i].VPN2,tlb[i].PFN0,tlb[i].PFN1,tlb[i].S,tlb[i].G,tlb[i].ASID,tlb[i].Mask);
|
||||
|
||||
if (tlb[i].S)
|
||||
{
|
||||
SysPrintf("OMG SPRAM MAPPING %08X %08X\n",tlb[i].VPN2,tlb[i].Mask);
|
||||
|
@ -294,9 +292,6 @@ void TLBWI() {
|
|||
cpuRegs.CP0.n.Index, cpuRegs.CP0.n.PageMask, cpuRegs.CP0.n.EntryHi,
|
||||
cpuRegs.CP0.n.EntryLo0, cpuRegs.CP0.n.EntryLo1);*/
|
||||
|
||||
// if( !bExecBIOS )
|
||||
// __Log("TLBWI %d\n", j);
|
||||
|
||||
UnmapTLB(j);
|
||||
WriteTLB(j);
|
||||
}
|
||||
|
@ -331,9 +326,6 @@ void TLBP() {
|
|||
u32 u;
|
||||
} EntryHi32;
|
||||
|
||||
// if( !bExecBIOS )
|
||||
// __Log("TLBP %x\n", cpuRegs.CP0.n.EntryHi);
|
||||
|
||||
EntryHi32.u=cpuRegs.CP0.n.EntryHi;
|
||||
|
||||
cpuRegs.CP0.n.Index=0xFFFFFFFF;
|
||||
|
|
|
@ -167,6 +167,8 @@ void cdrInterrupt() {
|
|||
int i;
|
||||
u8 Irq = cdr.Irq;
|
||||
|
||||
psxRegs.interrupt&= ~(1 << 17);
|
||||
|
||||
if (cdr.Stat) {
|
||||
CDR_INT(0x800);
|
||||
return;
|
||||
|
@ -457,10 +459,8 @@ void cdrInterrupt() {
|
|||
break;
|
||||
|
||||
case READ_ACK:
|
||||
if (!cdr.Reading) {
|
||||
psxRegs.interrupt&= ~(1 << 17);
|
||||
if (!cdr.Reading)
|
||||
return;
|
||||
}
|
||||
|
||||
SetResultSize(1);
|
||||
cdr.StatP|= 0x2;
|
||||
|
@ -485,7 +485,6 @@ void cdrInterrupt() {
|
|||
break;
|
||||
|
||||
case 0xff:
|
||||
psxRegs.interrupt&= ~(1 << 17);
|
||||
return;
|
||||
|
||||
default:
|
||||
|
@ -496,16 +495,15 @@ void cdrInterrupt() {
|
|||
if (cdr.Stat != NoIntr && cdr.Reg2 != 0x18) psxHu32(0x1070)|=0x4;
|
||||
|
||||
CDR_LOG("Cdr Interrupt %x\n", Irq);
|
||||
psxRegs.interrupt&= ~(1 << 17);
|
||||
}
|
||||
|
||||
void cdrReadInterrupt() {
|
||||
u8 *buf;
|
||||
|
||||
if (!cdr.Reading) {
|
||||
psxRegs.interrupt&= ~(1 << 18);
|
||||
psxRegs.interrupt&= ~(1 << 18);
|
||||
|
||||
if (!cdr.Reading)
|
||||
return;
|
||||
}
|
||||
|
||||
if (cdr.Stat) {
|
||||
CDREAD_INT(0x800);
|
||||
|
@ -868,11 +866,13 @@ void cdrWrite2(u8 rt) {
|
|||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!(cdr.Ctrl & 0x1) && cdr.ParamP < 8) {
|
||||
cdr.Param[cdr.ParamP++] = rt;
|
||||
cdr.ParamC++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
u8 cdrRead3(void) {
|
||||
if (cdr.Stat) {
|
||||
|
@ -949,17 +949,6 @@ void cdrReset() {
|
|||
cdr.CurTrack=1;
|
||||
cdr.File=1; cdr.Channel=1;
|
||||
cdReadTime = (PSXCLK / 1757) * BIAS;
|
||||
//DVD is 4x (PSXCLK / 75) CD is 24x on the PS2, so that would mean CD = (PSXCLK / 450)
|
||||
// 75/4 = 18.75 x 24 = 450 remember its faster than the PS1 ;) Refraction
|
||||
|
||||
// with the timing set to 60 Gran Turismo works
|
||||
// anybody knows why it doesn't with 75?
|
||||
// 75 is the correct cdrom timing
|
||||
// if (Config.CdTiming)
|
||||
// cdReadTime = (PSXCLK / 60) / BIAS;
|
||||
// this seems to be the most compatible
|
||||
// let's leave like this until we know why
|
||||
// 75 is buggy with some games
|
||||
}
|
||||
|
||||
int cdrFreeze(gzFile f, int Mode) {
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#include <zlib.h> // fixme: is zlib.h stuff used by that many modules that it should be here in common?
|
||||
#include <zlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "PS2Etypes.h"
|
||||
|
@ -80,30 +80,6 @@
|
|||
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_NLS
|
||||
|
||||
#ifdef __MSCW32__
|
||||
#include "libintlmsc.h"
|
||||
#else
|
||||
#include <locale.h>
|
||||
#include <libintl.h>
|
||||
#endif
|
||||
|
||||
#undef _
|
||||
#define _(String) dgettext (PACKAGE, String)
|
||||
#ifdef gettext_noop
|
||||
# define N_(String) gettext_noop (String)
|
||||
#else
|
||||
# define N_(String) (String)
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
#define _(msgid) msgid
|
||||
#define N_(msgid) msgid
|
||||
|
||||
#endif
|
||||
|
||||
struct TESTRUNARGS
|
||||
{
|
||||
u8 enabled;
|
||||
|
@ -145,18 +121,9 @@ extern TESTRUNARGS g_TestRun;
|
|||
#define PSXPIXEL ((int)(PSXCLK / 13500000))
|
||||
#define PSXSOUNDCLK ((int)(48000))
|
||||
|
||||
#define COLOR_BLACK "\033[30m"
|
||||
#define COLOR_RED "\033[31m"
|
||||
#define COLOR_GREEN "\033[32m"
|
||||
#define COLOR_YELLOW "\033[33m"
|
||||
#define COLOR_BLUE "\033[34m"
|
||||
#define COLOR_MAGENTA "\033[35m"
|
||||
#define COLOR_CYAN "\033[36m"
|
||||
#define COLOR_WHITE "\033[37m"
|
||||
#define COLOR_RESET "\033[0m"
|
||||
|
||||
#include <pthread.h> // sync functions
|
||||
|
||||
#include "Misc.h"
|
||||
#include "Plugins.h"
|
||||
#include "DebugTools/Debug.h"
|
||||
#include "R5900.h"
|
||||
|
@ -167,7 +134,6 @@ extern TESTRUNARGS g_TestRun;
|
|||
#include "Vif.h"
|
||||
#include "SPR.h"
|
||||
#include "Sif.h"
|
||||
#include "Misc.h"
|
||||
#include "Counters.h"
|
||||
#include "IPU/IPU.h"
|
||||
#include "Patch.h"
|
||||
|
@ -177,9 +143,6 @@ extern TESTRUNARGS g_TestRun;
|
|||
#include "x86/ix86/ix86.h"
|
||||
#endif
|
||||
|
||||
extern void __Log(const char *fmt, ...);
|
||||
extern u16 logProtocol;
|
||||
extern u8 logSource;
|
||||
#define PCSX2_VERSION "Playground (beta)"
|
||||
|
||||
#ifdef __LINUX__
|
||||
|
|
|
@ -69,58 +69,80 @@ extern DisR5900CurrentState disR5900Current;
|
|||
|
||||
extern int Log;
|
||||
extern u32 varLog;
|
||||
extern u16 logProtocol;
|
||||
extern u8 logSource;
|
||||
|
||||
void __Log(const char *fmt, ...);
|
||||
void SourceLog( u16 protocol, u8 source, u32 cpuPc, u32 cpuCycle, const char *fmt, ...);
|
||||
void __Log( const char* fmt, ... );
|
||||
|
||||
//memcars has the same number as PAD_LOG
|
||||
#define MEMCARDS_LOG if (varLog & 0x02000000) {logProtocol=7; logSource='I';} if (varLog & 0x02000000) __Log
|
||||
extern void SrcLog_CPU( const char* fmt, ... );
|
||||
extern void SrcLog_COP0( const char* fmt, ... );
|
||||
extern void SrcLog_FPU( const char* fmt, ... );
|
||||
extern void SrcLog_MMI( const char* fmt, ... );
|
||||
|
||||
#define CPU_LOG if (varLog & 0x00000001) {logProtocol=1; logSource='E';} if (varLog & 0x00000001) __Log
|
||||
#define MEM_LOG if (varLog & 0x00000002) {logProtocol=6; logSource='E';} if (varLog & 0x00000002) __Log("%8.8lx: ", cpuRegs.pc); if (varLog & 0x00000002) __Log
|
||||
#define HW_LOG if (varLog & 0x00000004) {logProtocol=6; logSource='E';} if (varLog & 0x00000004) __Log("%8.8lx: ", cpuRegs.pc); if (varLog & 0x00000004) __Log
|
||||
#define DMA_LOG if (varLog & 0x00000008) {logProtocol=5; logSource='E';} if (varLog & 0x00000008) __Log
|
||||
#define BIOS_LOG if (varLog & 0x00000010) {logProtocol=0; logSource='E';} if (varLog & 0x00000010) __Log("%8.8lx: ", cpuRegs.pc); if (varLog & 0x00000010) __Log
|
||||
#define ELF_LOG if (varLog & 0x00000020) {logProtocol=7; logSource='E';} if (varLog & 0x00000020) __Log
|
||||
#define FPU_LOG if (varLog & 0x00000040) {logProtocol=1; logSource='E';} if (varLog & 0x00000040) __Log
|
||||
#define MMI_LOG if (varLog & 0x00000080) {logProtocol=1; logSource='E';} if (varLog & 0x00000080) __Log
|
||||
#define VU0_LOG if (varLog & 0x00000100) {logProtocol=2; logSource='E';} if (varLog & 0x00000100) __Log
|
||||
#define COP0_LOG if (varLog & 0x00000200) {logProtocol=1; logSource='E';} if (varLog & 0x00000200) __Log
|
||||
#define VIF_LOG if (varLog & 0x00000400) {logProtocol=3; logSource='E';} if (varLog & 0x00000400) __Log
|
||||
#define SPR_LOG if (varLog & 0x00000800) {logProtocol=7; logSource='E';} if (varLog & 0x00000800) __Log
|
||||
#define GIF_LOG if (varLog & 0x00001000) {logProtocol=4; logSource='E';} if (varLog & 0x00001000) __Log
|
||||
#define SIF_LOG if (varLog & 0x00002000) {logProtocol=9; logSource='E';} if (varLog & 0x00002000) __Log
|
||||
#define IPU_LOG if (varLog & 0x00004000) {logProtocol=8; logSource='E';} if (varLog & 0x00004000) __Log
|
||||
#define VUM_LOG if (varLog & 0x00008000) {logProtocol=2; logSource='E';} if (varLog & 0x00008000) __Log
|
||||
#define RPC_LOG if (varLog & 0x00010000) {logProtocol=9; logSource='E';} if (varLog & 0x00010000) __Log
|
||||
extern void SrcLog_MEM( const char* fmt, ... );
|
||||
extern void SrcLog_HW( const char* fmt, ... );
|
||||
extern void SrcLog_DMA( const char* fmt, ... );
|
||||
extern void SrcLog_BIOS( const char* fmt, ... );
|
||||
extern void SrcLog_ELF( const char* fmt, ... );
|
||||
extern void SrcLog_VU0( const char* fmt, ... );
|
||||
|
||||
#define PSXCPU_LOG if (varLog & 0x00100000) {logProtocol=1; logSource='I';} if (varLog & 0x00100000) __Log
|
||||
#define PSXMEM_LOG if (varLog & 0x00200000) {logProtocol=6; logSource='I';} if (varLog & 0x00200000) __Log("%8.8lx : ", psxRegs.pc); if (varLog & 0x00200000) __Log
|
||||
#define PSXHW_LOG if (varLog & 0x00400000) {logProtocol=2; logSource='I';} if (varLog & 0x00400000) __Log("%8.8lx : ", psxRegs.pc); if (varLog & 0x00400000) __Log
|
||||
#define PSXBIOS_LOG if (varLog & 0x00800000) {logProtocol=0; logSource='I';} if (varLog & 0x00800000) __Log("%8.8lx : ", psxRegs.pc); if (varLog & 0x00800000) __Log
|
||||
#define PSXDMA_LOG if (varLog & 0x01000000) {logProtocol=5; logSource='I';} if (varLog & 0x01000000) __Log
|
||||
extern void SrcLog_VIF( const char* fmt, ... );
|
||||
extern void SrcLog_SPR( const char* fmt, ... );
|
||||
extern void SrcLog_GIF( const char* fmt, ... );
|
||||
extern void SrcLog_SIF( const char* fmt, ... );
|
||||
extern void SrcLog_IPU( const char* fmt, ... );
|
||||
extern void SrcLog_VUM( const char* fmt, ... );
|
||||
extern void SrcLog_RPC( const char* fmt, ... );
|
||||
extern void SrcLog_EECNT( const char* fmt, ... );
|
||||
|
||||
#define PAD_LOG if (varLog & 0x02000000) {logProtocol=7; logSource='I';} if (varLog & 0x02000000) __Log
|
||||
#define GTE_LOG if (varLog & 0x04000000) {logProtocol=3; logSource='I';} if (varLog & 0x04000000) __Log
|
||||
#define CDR_LOG if (varLog & 0x08000000) {logProtocol=8; logSource='I';} if (varLog & 0x08000000) __Log("%8.8lx %8.8lx: ", psxRegs.pc, psxRegs.cycle); if (varLog & 0x08000000) __Log
|
||||
#define GPU_LOG if (varLog & 0x10000000) {logProtocol=4; logSource='I';} if (varLog & 0x10000000) __Log
|
||||
#define PSXCNT_LOG if (varLog & 0x20000000) {logProtocol=0; logSource='I';} if (varLog & 0x20000000) __Log("%8.8lx %8.8lx: ", psxRegs.pc, psxRegs.cycle); if (varLog & 0x20000000) __Log
|
||||
#define EECNT_LOG if (varLog & 0x40000000) {logProtocol=0; logSource='I';} if (varLog & 0x40000000) __Log("%8.8lx %8.8lx: ", cpuRegs.pc, cpuRegs.cycle); if (varLog & 0x40000000) __Log
|
||||
extern void SrcLog_PSXCPU( const char* fmt, ... );
|
||||
extern void SrcLog_PSXMEM( const char* fmt, ... );
|
||||
extern void SrcLog_PSXHW( const char* fmt, ... );
|
||||
extern void SrcLog_PSXBIOS( const char* fmt, ... );
|
||||
extern void SrcLog_PSXDMA( const char* fmt, ... );
|
||||
extern void SrcLog_PSXCNT( const char* fmt, ... );
|
||||
|
||||
extern void SrcLog_MEMCARDS( const char* fmt, ... );
|
||||
extern void SrcLog_PAD( const char* fmt, ... );
|
||||
extern void SrcLog_GTE( const char* fmt, ... );
|
||||
extern void SrcLog_CDR( const char* fmt, ... );
|
||||
extern void SrcLog_GPU( const char* fmt, ... );
|
||||
|
||||
#define CPU_LOG if (varLog & 0x00000001) SrcLog_CPU
|
||||
#define MEM_LOG if (varLog & 0x00000002) SrcLog_MEM
|
||||
#define HW_LOG if (varLog & 0x00000004) SrcLog_HW
|
||||
#define DMA_LOG if (varLog & 0x00000008) SrcLog_DMA
|
||||
#define BIOS_LOG if (varLog & 0x00000010) SrcLog_BIOS
|
||||
#define ELF_LOG if (varLog & 0x00000020) SrcLog_ELF
|
||||
#define FPU_LOG if (varLog & 0x00000040) SrcLog_FPU
|
||||
#define MMI_LOG if (varLog & 0x00000080) SrcLog_MMI
|
||||
#define VU0_LOG if (varLog & 0x00000100) SrcLog_VU0
|
||||
#define COP0_LOG if (varLog & 0x00000200) SrcLog_COP0
|
||||
#define VIF_LOG if (varLog & 0x00000400) SrcLog_VIF
|
||||
#define SPR_LOG if (varLog & 0x00000800) SrcLog_SPR
|
||||
#define GIF_LOG if (varLog & 0x00001000) SrcLog_GIF
|
||||
#define SIF_LOG if (varLog & 0x00002000) SrcLog_SIF
|
||||
#define IPU_LOG if (varLog & 0x00004000) SrcLog_IPU
|
||||
#define VUM_LOG if (varLog & 0x00008000) SrcLog_VUM
|
||||
#define RPC_LOG if (varLog & 0x00010000) SrcLog_RPC
|
||||
#define EECNT_LOG if (varLog & 0x40000000) SrcLog_EECNT
|
||||
|
||||
#define PSXCPU_LOG if (varLog & 0x00100000) SrcLog_PSXCPU
|
||||
#define PSXMEM_LOG if (varLog & 0x00200000) SrcLog_PSXMEM
|
||||
#define PSXHW_LOG if (varLog & 0x00400000) SrcLog_PSXHW
|
||||
#define PSXBIOS_LOG if (varLog & 0x00800000) SrcLog_PSXBIOS
|
||||
#define PSXDMA_LOG if (varLog & 0x01000000) SrcLog_PSXDMA
|
||||
#define PSXCNT_LOG if (varLog & 0x20000000) SrcLog_PSXCNT
|
||||
|
||||
//memcard has the same number as PAD_LOG for now
|
||||
#define MEMCARDS_LOG if (varLog & 0x02000000) SrcLog_MEMCARDS
|
||||
#define PAD_LOG if (varLog & 0x02000000) SrcLog_PAD
|
||||
#define GTE_LOG if (varLog & 0x04000000) SrcLog_GTE
|
||||
#define CDR_LOG if (varLog & 0x08000000) SrcLog_CDR
|
||||
#define GPU_LOG if (varLog & 0x10000000) SrcLog_GPU
|
||||
|
||||
// fixme - currently we don't log cache
|
||||
#define CACHE_LOG 0&&
|
||||
|
||||
#if defined (CPU_LOG) || defined(MEM_LOG) || defined(HW_LOG) || defined(DMA_LOG) || \
|
||||
defined(BIOS_LOG) || defined(ELF_LOG) || defined(FPU_LOG) || defined(MMI_LOG) || \
|
||||
defined(VU0_LOG) || defined(COP0_LOG) || defined(VIF_LOG) || defined(SPR_LOG) || \
|
||||
defined(GIF_LOG) || defined(SIF_LOG) || defined(IPU_LOG) || defined(VUM_log) || \
|
||||
defined(PSXCPU_LOG) || defined(PSXMEM_LOG)|| defined(IOPBIOS_LOG)|| defined(IOPHW_LOG)|| \
|
||||
defined(PAD_LOG) || defined(GTE_LOG) || defined(CDR_LOG) || defined(GPU_LOG) || \
|
||||
defined(MEMCARDS_LOG)|| defined(PSXCNT_LOG) || defined(EECNT_LOG)
|
||||
#define EMU_LOG __Log
|
||||
#endif
|
||||
|
||||
#else // PCSX2_DEVBUILD
|
||||
|
||||
#define varLog 0
|
||||
|
|
|
@ -30,7 +30,6 @@
|
|||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
AppData gApp;
|
||||
#endif
|
||||
|
||||
u32 ElfCRC;
|
||||
|
@ -562,10 +561,10 @@ int loadElfFile(char *filename) {
|
|||
// Applying patches
|
||||
if (Config.Patch) {
|
||||
sprintf(str, "%8.8x", crc);
|
||||
#ifdef _WIN32
|
||||
|
||||
sprintf(str2,"No patch found.Game will run normally. [CRC=%8.8x]",crc);//if patches found it will overwritten :p
|
||||
if (gApp.hConsole) SetConsoleTitle(str2);
|
||||
#endif
|
||||
Console::SetTitle( str2 );
|
||||
|
||||
if(LoadPatch(str)!=0)
|
||||
{
|
||||
SysPrintf("XML Loader returned an error. Trying to load a pnach...\n");
|
||||
|
|
|
@ -2314,10 +2314,8 @@ int gsFreeze(gzFile f, int Mode)
|
|||
|
||||
// Earlier versions had an extra u32 in the tag struct:
|
||||
|
||||
//if( Mode == 0 && g_SaveVersion <= 0x7a300010 )
|
||||
{
|
||||
u32 dummy=g_path[i].nreg; gzfreeze( &dummy, sizeof( dummy ) );
|
||||
}
|
||||
u32 dummy=g_path[i].nreg;
|
||||
gzfreeze( &dummy, sizeof( dummy ) );
|
||||
}
|
||||
|
||||
for(int i=0; i<3; i++ )
|
||||
|
|
|
@ -413,7 +413,7 @@ void hwWrite8(u32 mem, u8 value) {
|
|||
case 0x1000f180:
|
||||
if (value == '\n') {
|
||||
sio_buffer[sio_count] = 0;
|
||||
SysPrintf(COLOR_GREEN "%s\n" COLOR_RESET, sio_buffer);
|
||||
SysPrintf("%s\n", sio_buffer);
|
||||
sio_count = 0;
|
||||
} else {
|
||||
if (sio_count < 1023) {
|
||||
|
|
|
@ -0,0 +1,102 @@
|
|||
/* Pcsx2 - Pc Ps2 Emulator
|
||||
* Copyright (C) 2002-2008 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 "Misc.h"
|
||||
#include "Debug.h"
|
||||
#include "System.h"
|
||||
|
||||
// Linux Note : The Linux Console is pretty simple. It just dumps to the stdio!
|
||||
// (no console open/clode/title stuff tho, so those functions are dummies)
|
||||
namespace Console
|
||||
{
|
||||
void SetTitle( const char* title )
|
||||
{
|
||||
}
|
||||
|
||||
void Open()
|
||||
{
|
||||
}
|
||||
|
||||
void Close()
|
||||
{
|
||||
}
|
||||
|
||||
__forceinline bool __fastcall WriteLn()
|
||||
{
|
||||
if (Config.PsxOut != 0)
|
||||
puts( "\n" );
|
||||
|
||||
if (emuLog != NULL)
|
||||
{
|
||||
fputs("\n", emuLog);
|
||||
fflush( emuLog );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
__forceinline bool __fastcall Write( const char* fmt )
|
||||
{
|
||||
if (Config.PsxOut != 0)
|
||||
puts( fmt );
|
||||
|
||||
// No flushing here -- only flush after newlines.
|
||||
if (emuLog != NULL)
|
||||
fputs(fmt, emuLog);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
__forceinline bool __fastcall WriteLn( const char* fmt )
|
||||
{
|
||||
Write( fmt );
|
||||
WriteLn();
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Format( const char* fmt, ... )
|
||||
{
|
||||
va_list list;
|
||||
char msg[2048];
|
||||
|
||||
va_start(list,fmt);
|
||||
vsprintf(msg,2047,fmt,list);
|
||||
msg[2047] = '\0';
|
||||
va_end(list);
|
||||
|
||||
Write( msg );
|
||||
return false;
|
||||
}
|
||||
|
||||
bool FormatLn( const char* fmt, ... )
|
||||
{
|
||||
va_list list;
|
||||
char msg[2048];
|
||||
|
||||
va_start(list,fmt);
|
||||
_vsnprintf(msg,2046,fmt,list); // 2046 to leave room for the newline
|
||||
va_end(list);
|
||||
|
||||
strcat( msg, "\n" ); // yeah, that newline!
|
||||
Write( msg );
|
||||
if( emuLog != NULL )
|
||||
fflush( emuLog ); // manual flush to accomany manual newline
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -441,49 +441,15 @@ void SysClose() {
|
|||
void SysPrintf(const char *fmt, ...) {
|
||||
va_list list;
|
||||
char msg[512];
|
||||
char* ptr;
|
||||
int len, i, j, s;
|
||||
|
||||
va_start(list, fmt);
|
||||
vsprintf(msg, fmt, list);
|
||||
va_start(list,fmt);
|
||||
_vsnprintf(msg,511,fmt,list);
|
||||
msg[511] = '\0';
|
||||
va_end(list);
|
||||
|
||||
if (Config.PsxOut == 0) {
|
||||
#ifdef EMU_LOG
|
||||
#ifndef LOG_STDOUT
|
||||
if (emuLog != NULL && !(varLog & 0x80000000)) {
|
||||
fprintf(emuLog, "%s", msg);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
printf("%s", msg);
|
||||
|
||||
#ifdef EMU_LOG
|
||||
#ifndef LOG_STDOUT
|
||||
if (emuLog != NULL && !(varLog & 0x80000000)) {
|
||||
ptr = msg; len = strlen(msg);
|
||||
for (i=0, j=0; i<len; i++, j++) {
|
||||
if (ptr[j] == '\033') {
|
||||
ptr[j] = 0;
|
||||
fprintf(emuLog, "%s", ptr);
|
||||
if (ptr[j+2] == '0') {
|
||||
s = 4;
|
||||
} else {
|
||||
s = 5;
|
||||
}
|
||||
ptr+= j+s;
|
||||
j = 0;
|
||||
}
|
||||
}
|
||||
|
||||
fprintf(emuLog, "%s", ptr);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
Console::Write( msg );
|
||||
}
|
||||
|
||||
void *SysLoadLibrary(const char *lib) {
|
||||
return dlopen(lib, RTLD_NOW);
|
||||
}
|
||||
|
|
75
pcsx2/Misc.c
75
pcsx2/Misc.c
|
@ -16,10 +16,17 @@
|
|||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#include "RDebug/deci2.h"
|
||||
#else
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cstdarg>
|
||||
#include <cstring>
|
||||
#include <sys/stat.h>
|
||||
#include <ctype.h>
|
||||
|
||||
|
@ -27,12 +34,6 @@
|
|||
#include "PsxCommon.h"
|
||||
#include "CDVDisodrv.h"
|
||||
#include "VUmicro.h"
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#include "RDebug/deci2.h"
|
||||
#else
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
|
||||
#include "VU.h"
|
||||
#include "iCore.h"
|
||||
|
@ -380,49 +381,6 @@ int GetPS2ElfName(char *name){
|
|||
return 2;
|
||||
}
|
||||
|
||||
FILE *emuLog;
|
||||
|
||||
#ifdef PCSX2_DEVBUILD
|
||||
int Log;
|
||||
u32 varLog;
|
||||
#endif
|
||||
|
||||
u16 logProtocol;
|
||||
u8 logSource;
|
||||
int connected=0;
|
||||
|
||||
#define SYNC_LOGGING
|
||||
|
||||
void __Log(const char *fmt, ...) {
|
||||
#ifdef EMU_LOG
|
||||
va_list list;
|
||||
char tmp[2024]; //hm, should be enough
|
||||
|
||||
va_start(list, fmt);
|
||||
#ifdef _WIN32
|
||||
if (connected && logProtocol>=0 && logProtocol<0x10){
|
||||
vsprintf(tmp, fmt, list);
|
||||
sendTTYP(logProtocol, logSource, tmp);
|
||||
}//else //!!!!! is disabled, so the text goes to ttyp AND log
|
||||
#endif
|
||||
{
|
||||
#ifndef LOG_STDOUT
|
||||
if (varLog & 0x80000000) {
|
||||
vsprintf(tmp, fmt, list);
|
||||
SysPrintf(tmp);
|
||||
} else if( emuLog != NULL ) {
|
||||
vfprintf(emuLog, fmt, list);
|
||||
fflush( emuLog );
|
||||
}
|
||||
#else //i assume that this will not be used (Florin)
|
||||
vsprintf(tmp, fmt, list);
|
||||
SysPrintf(tmp);
|
||||
#endif
|
||||
}
|
||||
va_end(list);
|
||||
#endif
|
||||
}
|
||||
|
||||
// STATES
|
||||
|
||||
#define STATE_VERSION "STv6"
|
||||
|
@ -1023,7 +981,7 @@ void ProcessFKeys(int fkey, int shift)
|
|||
}
|
||||
}
|
||||
|
||||
void injectIRX(char *filename){
|
||||
void injectIRX(const char *filename){
|
||||
struct stat buf;
|
||||
char path[260], name[260], *p, *q;
|
||||
struct romdir *rd;
|
||||
|
@ -1123,12 +1081,3 @@ u64 GetCPUTicks()
|
|||
return ((u64)t.tv_sec*GetTickFrequency())+t.tv_usec;
|
||||
#endif
|
||||
}
|
||||
|
||||
__forceinline void _TIMESLICE()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
Sleep(0);
|
||||
#else
|
||||
usleep(500);
|
||||
#endif
|
||||
}
|
||||
|
|
196
pcsx2/Misc.h
196
pcsx2/Misc.h
|
@ -46,6 +46,35 @@
|
|||
#define __unused
|
||||
#endif
|
||||
|
||||
// --->> GNU GetText / NLS
|
||||
|
||||
#ifdef ENABLE_NLS
|
||||
|
||||
#ifdef __MSCW32__
|
||||
#include "libintlmsc.h"
|
||||
#else
|
||||
#include <locale.h>
|
||||
#include <libintl.h>
|
||||
#endif
|
||||
|
||||
#undef _
|
||||
#define _(String) dgettext (PACKAGE, String)
|
||||
#ifdef gettext_noop
|
||||
# define N_(String) gettext_noop (String)
|
||||
#else
|
||||
# define N_(String) (String)
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
#define _(msgid) msgid
|
||||
#define N_(msgid) msgid
|
||||
|
||||
#endif
|
||||
|
||||
// <<--- End GNU GetText / NLS
|
||||
|
||||
|
||||
// --->> Path Utilities [PathUtil.c]
|
||||
|
||||
#define g_MaxPath 255 // 255 is safer with antiquitated Win32 ASCII APIs.
|
||||
|
@ -288,12 +317,10 @@ void memxor_mmx(void* dst, const void* src1, int cmpsize);
|
|||
#pragma pack()
|
||||
#endif
|
||||
|
||||
void __Log(const char *fmt, ...);
|
||||
void injectIRX(char *filename);
|
||||
void injectIRX(const char *filename);
|
||||
|
||||
// aligned_malloc: Implement/declare linux equivalents here!
|
||||
#if !defined(_MSC_VER) && !defined(HAVE_ALIGNED_MALLOC)
|
||||
|
||||
// declare linux equivalents
|
||||
static __forceinline void* pcsx2_aligned_malloc(size_t size, size_t align)
|
||||
{
|
||||
assert( align < 0x10000 );
|
||||
|
@ -319,159 +346,38 @@ static __forceinline void pcsx2_aligned_free(void* pmem)
|
|||
|
||||
#endif
|
||||
|
||||
// cross-platform atomic operations
|
||||
// InterlockedExchange: Declare linux/GCC equivalents here
|
||||
// (implementations are in ThreadTools.cpp)
|
||||
#ifndef _WIN32
|
||||
typedef void* PVOID;
|
||||
|
||||
/*inline unsigned long _Atomic_swap(unsigned long * __p, unsigned long __q) {
|
||||
# if __mips < 3 || !(defined (_ABIN32) || defined(_ABI64))
|
||||
return test_and_set(__p, __q);
|
||||
# else
|
||||
return __test_and_set(__p, (unsigned long)__q);
|
||||
# endif
|
||||
}*/
|
||||
static __forceinline 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
|
||||
}
|
||||
|
||||
static __forceinline 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" );
|
||||
return 0; // The only function that even looks at this is a debugging function
|
||||
}
|
||||
|
||||
static __forceinline 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" );
|
||||
return 0; // The return value is never looked at.
|
||||
}
|
||||
|
||||
static __forceinline long InterlockedIncrement( volatile long* Addend )
|
||||
{
|
||||
return InterlockedExchangeAdd( Addend, 1 );
|
||||
}
|
||||
|
||||
static __forceinline long InterlockedDecrement( volatile long* Addend )
|
||||
{
|
||||
return InterlockedExchangeAdd( Addend, -1 );
|
||||
}
|
||||
|
||||
static __forceinline long InterlockedCompareExchange(volatile long *dest, long exch, long comp)
|
||||
{
|
||||
long old;
|
||||
|
||||
#ifdef __x86_64__
|
||||
__asm__ __volatile__
|
||||
(
|
||||
"lock; cmpxchgq %q2, %1"
|
||||
: "=a" (old), "=m" (*dest)
|
||||
: "r" (exch), "m" (*dest), "0" (comp));
|
||||
#else
|
||||
__asm__ __volatile__
|
||||
(
|
||||
"lock; cmpxchgl %2, %0"
|
||||
: "=m" (*dest), "=a" (old)
|
||||
: "r" (exch), "m" (*dest), "a" (comp)
|
||||
);
|
||||
#endif
|
||||
|
||||
return(old);
|
||||
}
|
||||
|
||||
static __forceinline long InterlockedCompareExchangePointer(PVOID volatile *dest, PVOID exch, long comp)
|
||||
{
|
||||
long old;
|
||||
|
||||
// Note: This *should* be 32/64 compatibles since the assembler should pick the opcode
|
||||
// that matches the size of the pointer type, so no need to ifdef it like the std non-compare
|
||||
// exchange.
|
||||
|
||||
#ifdef __x86_64__
|
||||
__asm__ __volatile__
|
||||
(
|
||||
"lock; cmpxchgq %q2, %1"
|
||||
: "=a" (old), "=m" (*dest)
|
||||
: "r" (exch), "m" (*dest), "0" (comp)
|
||||
);
|
||||
#else
|
||||
__asm__ __volatile__
|
||||
(
|
||||
"lock; cmpxchgl %2, %0"
|
||||
: "=m" (*dest), "=a" (old)
|
||||
: "r" (exch), "m" (*dest), "a" (comp)
|
||||
);
|
||||
#endif
|
||||
return(old);
|
||||
}
|
||||
extern void InterlockedExchangePointer(PVOID volatile* Target, void* Value);
|
||||
extern long InterlockedExchange(long volatile* Target, long Value);
|
||||
extern long InterlockedExchangeAdd(long volatile* Addend, long Value);
|
||||
extern long InterlockedIncrement( volatile long* Addend );
|
||||
extern long InterlockedDecrement( volatile long* Addend );
|
||||
extern long InterlockedCompareExchange(volatile long *dest, long exch, long comp);
|
||||
extern long InterlockedCompareExchangePointer(PVOID volatile *dest, PVOID exch, long comp);
|
||||
#endif
|
||||
|
||||
// define some overloads for InterlockedExchanges, for commonly used types.
|
||||
|
||||
// Note: _unused is there simply to get rid of a few Linux compiler warnings while
|
||||
// debugging, as any compiler warnings in Misc.h get repeated x100 or so.
|
||||
__unused static void AtomicExchange( u32& Target, u32 value )
|
||||
{
|
||||
InterlockedExchange( (volatile LONG*)&Target, value );
|
||||
}
|
||||
|
||||
__unused static void AtomicExchangeAdd( u32& Target, u32 value )
|
||||
{
|
||||
InterlockedExchangeAdd( (volatile LONG*)&Target, value );
|
||||
}
|
||||
|
||||
__unused static void AtomicIncrement( u32& Target )
|
||||
{
|
||||
InterlockedIncrement( (volatile LONG*)&Target );
|
||||
}
|
||||
|
||||
__unused static void AtomicDecrement( u32& Target )
|
||||
{
|
||||
InterlockedDecrement( (volatile LONG*)&Target );
|
||||
}
|
||||
|
||||
__unused static void AtomicExchange( s32& Target, s32 value )
|
||||
{
|
||||
InterlockedExchange( (volatile LONG*)&Target, value );
|
||||
}
|
||||
|
||||
__unused static void AtomicExchangeAdd( s32& Target, u32 value )
|
||||
{
|
||||
InterlockedExchangeAdd( (volatile LONG*)&Target, value );
|
||||
}
|
||||
|
||||
__unused static void AtomicIncrement( s32& Target )
|
||||
{
|
||||
InterlockedIncrement( (volatile LONG*)&Target );
|
||||
}
|
||||
|
||||
__unused static void AtomicDecrement( s32& Target )
|
||||
{
|
||||
InterlockedDecrement( (volatile LONG*)&Target );
|
||||
}
|
||||
extern void AtomicExchange( u32& Target, u32 value );
|
||||
extern void AtomicExchangeAdd( u32& Target, u32 value );
|
||||
extern void AtomicIncrement( u32& Target );
|
||||
extern void AtomicDecrement( u32& Target );
|
||||
extern void AtomicExchange( s32& Target, s32 value );
|
||||
extern void AtomicExchangeAdd( s32& Target, u32 value );
|
||||
extern void AtomicIncrement( s32& Target );
|
||||
extern void AtomicDecrement( s32& Target );
|
||||
|
||||
// No fancy templating or overloading can save us from having to use C-style dereferences here.
|
||||
#define AtomicExchangePointer( target, value ) \
|
||||
InterlockedExchangePointer( reinterpret_cast<PVOID volatile*>(&target), reinterpret_cast<uptr>(value) )
|
||||
|
||||
// Timeslice releaser for those many idle loop spots through out PCSX2.
|
||||
extern void _TIMESLICE();
|
||||
|
||||
extern void InitCPUTicks();
|
||||
extern u64 GetTickFrequency();
|
||||
extern u64 GetCPUTicks();
|
||||
|
||||
// Timeslice releaser for those many idle loop spots through out PCSX2.
|
||||
extern void _TIMESLICE();
|
||||
|
||||
#endif /* __MISC_H__ */
|
||||
|
||||
|
|
|
@ -368,7 +368,7 @@ void patchFunc_gametitle( char * text1, char * text2 )
|
|||
SysPrintf( "gametitle: %s \n", text2 );
|
||||
#ifdef _WIN32
|
||||
sprintf(strgametitle,"%s",text2);
|
||||
if (gApp.hConsole) SetConsoleTitle(strgametitle);
|
||||
Console::SetTitle(strgametitle);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -79,18 +79,6 @@ struct IniPatch
|
|||
u64 data;
|
||||
};
|
||||
|
||||
#ifdef _WINDOWS_
|
||||
struct AppData
|
||||
{
|
||||
HWND hWnd; // Main window handle
|
||||
HINSTANCE hInstance; // Application instance
|
||||
HMENU hMenu; // Main window menu
|
||||
HANDLE hConsole;
|
||||
};
|
||||
|
||||
extern AppData gApp;
|
||||
#endif
|
||||
|
||||
//
|
||||
// Function prototypes
|
||||
//
|
||||
|
|
|
@ -223,7 +223,7 @@ USBhandler usbHandler;
|
|||
#define MapSymbolVarType(var,type,name) var = (type)SysLoadSym(drv,Strfy(name))
|
||||
#define MapSymbolVar(var,name) MapSymbolVarType(var,_##name,name)
|
||||
#define MapSymbolVar_Fallback(var,name,fallback) if((MapSymbolVar(var,name))==NULL) var = fallback
|
||||
#define MapSymbolVar_Error(var,name) if((MapSymbolVar(var,name))==NULL) { char* errString = SysLibError(); SysMessage (_("%s: Error loading %s: %s"), filename, __FUNCTION__, errString); return -1; }
|
||||
#define MapSymbolVar_Error(var,name) if((MapSymbolVar(var,name))==NULL) { const char* errString = SysLibError(); SysMessage (_("%s: Error loading %s: %s"), filename, __FUNCTION__, errString); return -1; }
|
||||
|
||||
#define MapSymbol(name) MapSymbolVar(name,name)
|
||||
#define MapSymbol_Fallback(name,fallback) MapSymbolVar_Fallback(name,name,fallback)
|
||||
|
@ -236,7 +236,7 @@ USBhandler usbHandler;
|
|||
|
||||
#define TestPS2Esyms(type) if(_TestPS2Esyms(drv,PS2E_LT_##type,PS2E_##type##_VERSION,filename) < 0) return -1;
|
||||
|
||||
int _TestPS2Esyms(void* drv, int type, int expected_version, char* filename)
|
||||
int _TestPS2Esyms(void* drv, int type, int expected_version, const char* filename)
|
||||
{
|
||||
_PS2EgetLibType PS2EgetLibType;
|
||||
_PS2EgetLibVersion2 PS2EgetLibVersion2;
|
||||
|
@ -256,7 +256,7 @@ int _TestPS2Esyms(void* drv, int type, int expected_version, char* filename)
|
|||
return 0;
|
||||
}
|
||||
|
||||
//static char *err;
|
||||
//static const char *err;
|
||||
//static int errval;
|
||||
|
||||
void *GSplugin;
|
||||
|
|
|
@ -179,7 +179,7 @@ void bios_write() { // 0x35/0x03
|
|||
char *ptr = Ra1;
|
||||
|
||||
while (a2 > 0) {
|
||||
SysPrintf(COLOR_RED "%c" COLOR_RESET, *ptr++); a2--;
|
||||
SysPrintf("%c", *ptr++); a2--;
|
||||
}
|
||||
pc0 = ra; return;
|
||||
}
|
||||
|
@ -252,7 +252,7 @@ _start:
|
|||
|
||||
memcpy((char*)PSXM(sp), save, 4*4);
|
||||
|
||||
SysPrintf(COLOR_RED "%s" COLOR_RESET, tmp);
|
||||
SysPrintf( "%s", tmp);
|
||||
|
||||
pc0 = ra;
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
extern long LoadCdBios;
|
||||
extern int cdOpenCase;
|
||||
|
||||
#define PSXCLK 36864000 /* 36.864 Mhz */
|
||||
#define PSXCLK (36864000ULL) /* 36.864 Mhz */
|
||||
|
||||
#include "Plugins.h"
|
||||
#include "R3000A.h"
|
||||
|
|
|
@ -207,7 +207,9 @@ const char* intrname[]={
|
|||
"INT_MAX" //40
|
||||
};
|
||||
|
||||
void zeroEx() {
|
||||
void zeroEx()
|
||||
{
|
||||
#ifdef PCSX2_DEVBUILD
|
||||
u32 pc;
|
||||
u32 code;
|
||||
char *lib;
|
||||
|
@ -236,14 +238,12 @@ void zeroEx() {
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef PCSX2_DEVBUILD
|
||||
{char libz[9]; memcpy(libz, lib, 8); libz[8]=0;
|
||||
PSXBIOS_LOG("%s: %s (%x)"
|
||||
" (%x, %x, %x, %x)" //comment this line to disable param showing
|
||||
, libz, fname == NULL ? "unknown" : fname, code,
|
||||
psxRegs.GPR.n.a0, psxRegs.GPR.n.a1, psxRegs.GPR.n.a2, psxRegs.GPR.n.a3);
|
||||
}
|
||||
#endif
|
||||
|
||||
// Log=0;
|
||||
// if (!strcmp(lib, "intrman") && code == 0x11) Log=1;
|
||||
|
@ -271,40 +271,38 @@ void zeroEx() {
|
|||
}
|
||||
|
||||
if (!strncmp(lib, "loadcore", 8) && code == 6) {
|
||||
SysPrintf("loadcore RegisterLibraryEntries (%x): %8.8s\n", psxRegs.pc, PSXM(psxRegs.GPR.n.a0+12));
|
||||
DevCon::FormatLn("loadcore RegisterLibraryEntries (%x): %8.8s", psxRegs.pc, PSXM(psxRegs.GPR.n.a0+12));
|
||||
}
|
||||
|
||||
if (!strncmp(lib, "intrman", 7) && code == 4) {
|
||||
SysPrintf("intrman RegisterIntrHandler (%x): intr %s, handler %x\n", psxRegs.pc, intrname[psxRegs.GPR.n.a0], psxRegs.GPR.n.a2);
|
||||
DevCon::FormatLn("intrman RegisterIntrHandler (%x): intr %s, handler %x", psxRegs.pc, intrname[psxRegs.GPR.n.a0], psxRegs.GPR.n.a2);
|
||||
}
|
||||
|
||||
if (!strncmp(lib, "sifcmd", 6) && code == 17) {
|
||||
SysPrintf("sifcmd sceSifRegisterRpc (%x): rpc_id %x\n", psxRegs.pc, psxRegs.GPR.n.a1);
|
||||
DevCon::FormatLn("sifcmd sceSifRegisterRpc (%x): rpc_id %x", psxRegs.pc, psxRegs.GPR.n.a1);
|
||||
}
|
||||
|
||||
#ifdef PCSX2_DEVBUILD
|
||||
if (!strncmp(lib, "sysclib", 8)) {
|
||||
switch (code) {
|
||||
if (!strncmp(lib, "sysclib", 8))
|
||||
{
|
||||
switch (code)
|
||||
{
|
||||
case 0x16: // strcmp
|
||||
if (varLog & 0x00800000) EMU_LOG(" \"%s\": \"%s\"", Ra0, Ra1);
|
||||
PSXBIOS_LOG(" \"%s\": \"%s\"", Ra0, Ra1);
|
||||
break;
|
||||
|
||||
case 0x1e: // strncpy
|
||||
if (varLog & 0x00800000) EMU_LOG(" \"%s\"", Ra1);
|
||||
PSXBIOS_LOG(" \"%s\"", Ra1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PCSX2_DEVBUILD
|
||||
if (varLog & 0x00800000) EMU_LOG("\n");
|
||||
#endif
|
||||
|
||||
/* psxRegs.pc = branchPC;
|
||||
pc = psxRegs.GPR.n.ra;
|
||||
while (psxRegs.pc != pc) psxCpu->ExecuteBlock();
|
||||
|
||||
PSXBIOS_LOG("%s: %s (%x) END\n", lib, fname == NULL ? "unknown" : fname, code);*/
|
||||
#endif
|
||||
|
||||
}
|
||||
/*/==========================================CALL LOG
|
||||
char* getName(char *file, u32 addr){
|
||||
|
|
|
@ -361,6 +361,9 @@ int psxMemInit()
|
|||
memset(psxMemRLUT, 0, 0x10000 * sizeof(uptr));
|
||||
memset(psxMemWLUT, 0, 0x10000 * sizeof(uptr));
|
||||
|
||||
// fixme: WHY are we allocating VM blocks in TLB builds for
|
||||
// non-executable data blocks!?
|
||||
|
||||
psxM = (s8*)SysMmap(PS2MEM_PSX_, 0x00200000);
|
||||
psxP = (s8*)SysMmap(PS2MEM_BASE_+0x1f000000, 0x00010000);
|
||||
psxH = (s8*)SysMmap(PS2MEM_BASE_+0x1f800000, 0x00010000);
|
||||
|
|
|
@ -0,0 +1,157 @@
|
|||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#include "RDebug/deci2.h"
|
||||
#else
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cstdarg>
|
||||
#include <cstring>
|
||||
#include <sys/stat.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "Common.h"
|
||||
#include "PsxCommon.h"
|
||||
|
||||
FILE *emuLog;
|
||||
|
||||
#ifdef PCSX2_DEVBUILD
|
||||
int Log;
|
||||
u32 varLog;
|
||||
|
||||
// these used by the depreciated _old_Log only
|
||||
u16 logProtocol;
|
||||
u8 logSource;
|
||||
#endif
|
||||
|
||||
int connected=0;
|
||||
|
||||
#define SYNC_LOGGING
|
||||
|
||||
// writes text directly to the logfile, no newlines appended.
|
||||
void __Log( const char* fmt, ... )
|
||||
{
|
||||
char tmp[2024];
|
||||
|
||||
va_list list;
|
||||
va_start(list, fmt);
|
||||
|
||||
// concatenate the log message after the prefix:
|
||||
int length = vsprintf(tmp, fmt, list);
|
||||
va_end( list );
|
||||
|
||||
assert( length <= 2020 );
|
||||
if( length > 2020 )
|
||||
{
|
||||
SysMessage( "Source Log Stack Corruption Detected. Program execution may become unstable." );
|
||||
// fixme: should throw an exception here once we have proper exception handling implemented.
|
||||
}
|
||||
|
||||
if (varLog & 0x80000000) // log to console enabled?
|
||||
{
|
||||
Console::Write(tmp);
|
||||
|
||||
} else if( emuLog != NULL ) // manually write to the logfile.
|
||||
{
|
||||
fputs( tmp, emuLog );
|
||||
//fputs( "\r\n", emuLog );
|
||||
fflush( emuLog );
|
||||
}
|
||||
}
|
||||
|
||||
static __forceinline void _vSourceLog( u16 protocol, u8 source, u32 cpuPc, u32 cpuCycle, const char *fmt, va_list list )
|
||||
{
|
||||
char tmp[2024];
|
||||
|
||||
int prelength = sprintf( tmp, "%c/%8.8lx %8.8lx: ", source, cpuPc, cpuCycle );
|
||||
|
||||
// concatenate the log message after the prefix:
|
||||
int length = vsprintf(&tmp[prelength], fmt, list);
|
||||
assert( length <= 2020 );
|
||||
if( length > 2020 )
|
||||
{
|
||||
SysMessage( "Source Log Stack Corruption Detected. Program execution may become unstable." );
|
||||
// fixme: should throw an exception here once we have proper exception handling implemented.
|
||||
}
|
||||
|
||||
#ifdef PCSX2_DEVBUILD
|
||||
#ifdef _WIN32
|
||||
// Send log data to the (remote?) debugger.
|
||||
if (connected && logProtocol>=0 && logProtocol<0x10)
|
||||
{
|
||||
sendTTYP(logProtocol, logSource, tmp);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if (varLog & 0x80000000) // log to console enabled?
|
||||
{
|
||||
Console::WriteLn(tmp);
|
||||
|
||||
} else if( emuLog != NULL ) // manually write to the logfile.
|
||||
{
|
||||
fputs( tmp, emuLog );
|
||||
//fputs( "\r\n", emuLog );
|
||||
fflush( emuLog );
|
||||
}
|
||||
}
|
||||
|
||||
// Note: This function automatically appends a newline character always!
|
||||
// (actually it doesn't yet because too much legacy code, will fix soon!)
|
||||
void SourceLog( u16 protocol, u8 source, u32 cpuPc, u32 cpuCycle, const char *fmt, ...)
|
||||
{
|
||||
va_list list;
|
||||
va_start(list, fmt);
|
||||
_vSourceLog( protocol, source, cpuPc, cpuCycle, fmt, list );
|
||||
va_end(list);
|
||||
}
|
||||
|
||||
#define IMPLEMENT_SOURCE_LOG( unit, source, protocol ) \
|
||||
__forceinline void SrcLog_##unit##( const char* fmt, ... ) \
|
||||
{ \
|
||||
va_list list; \
|
||||
va_start( list, fmt ); \
|
||||
_vSourceLog( protocol, source, \
|
||||
(source == 'E') ? cpuRegs.pc : psxRegs.pc, \
|
||||
(source == 'E') ? cpuRegs.cycle : psxRegs.cycle, fmt, list ); \
|
||||
va_end( list ); \
|
||||
} \
|
||||
|
||||
IMPLEMENT_SOURCE_LOG( EECNT, 'E', 0 )
|
||||
IMPLEMENT_SOURCE_LOG( BIOS, 'E', 0 )
|
||||
|
||||
IMPLEMENT_SOURCE_LOG( CPU, 'E', 1 )
|
||||
IMPLEMENT_SOURCE_LOG( FPU, 'E', 1 )
|
||||
IMPLEMENT_SOURCE_LOG( MMI, 'E', 1 )
|
||||
IMPLEMENT_SOURCE_LOG( COP0, 'E', 1 )
|
||||
|
||||
IMPLEMENT_SOURCE_LOG( MEM, 'E', 6 )
|
||||
IMPLEMENT_SOURCE_LOG( HW, 'E', 6 )
|
||||
IMPLEMENT_SOURCE_LOG( DMA, 'E', 5 )
|
||||
IMPLEMENT_SOURCE_LOG( ELF, 'E', 7 )
|
||||
IMPLEMENT_SOURCE_LOG( VU0, 'E', 2 )
|
||||
IMPLEMENT_SOURCE_LOG( VIF, 'E', 3 )
|
||||
IMPLEMENT_SOURCE_LOG( SPR, 'E', 7 )
|
||||
IMPLEMENT_SOURCE_LOG( GIF, 'E', 4 )
|
||||
IMPLEMENT_SOURCE_LOG( SIF, 'E', 9 )
|
||||
IMPLEMENT_SOURCE_LOG( IPU, 'E', 8 )
|
||||
IMPLEMENT_SOURCE_LOG( VUM, 'E', 2 )
|
||||
IMPLEMENT_SOURCE_LOG( RPC, 'E', 9 )
|
||||
|
||||
IMPLEMENT_SOURCE_LOG( PSXCPU, 'I', 1 )
|
||||
IMPLEMENT_SOURCE_LOG( PSXMEM, 'I', 6 )
|
||||
IMPLEMENT_SOURCE_LOG( PSXHW, 'I', 2 )
|
||||
IMPLEMENT_SOURCE_LOG( PSXBIOS, 'I', 0 )
|
||||
IMPLEMENT_SOURCE_LOG( PSXDMA, 'I', 5 )
|
||||
IMPLEMENT_SOURCE_LOG( PSXCNT, 'I', 4 )
|
||||
|
||||
IMPLEMENT_SOURCE_LOG( MEMCARDS, 'I', 7 )
|
||||
IMPLEMENT_SOURCE_LOG( PAD, 'I', 7 )
|
||||
IMPLEMENT_SOURCE_LOG( GTE, 'I', 3 )
|
||||
IMPLEMENT_SOURCE_LOG( CDR, 'I', 8 )
|
||||
|
||||
|
||||
|
||||
|
|
@ -21,18 +21,85 @@
|
|||
|
||||
int SysInit(); // Init mem and plugins
|
||||
int SysReset(); // Resets mem
|
||||
void SysPrintf(const char *fmt, ...); // Printf used by bios syscalls
|
||||
void SysMessage(const char *fmt, ...); // Message used to print msg to users
|
||||
void SysUpdate(); // Called on VBlank (to update i.e. pads)
|
||||
void SysRunGui(); // Returns to the Gui
|
||||
void SysClose(); // Close mem and plugins
|
||||
void *SysLoadLibrary(const char *lib); // Loads Library
|
||||
void *SysLoadLibrary(const char *lib); // Loads Library
|
||||
void *SysLoadSym(void *lib, const char *sym); // Loads Symbol from Library
|
||||
char *SysLibError(); // Gets previous error loading sysbols
|
||||
const char *SysLibError(); // Gets previous error loading sysbols
|
||||
void SysCloseLibrary(void *lib); // Closes Library
|
||||
|
||||
// Causes a pop-up to appear with the specified message. Use this to issue
|
||||
// critical or fatal messages to the user.
|
||||
void SysMessage(const char *fmt, ...);
|
||||
|
||||
// Maps a block of memory for use as a recompiled code buffer.
|
||||
// The allocated block has code execution privliges.
|
||||
// Returns NULL on allocation failure.
|
||||
void *SysMmap(uptr base, u32 size);
|
||||
|
||||
// Unamps a block allocated by SysMmap
|
||||
void SysMunmap(uptr base, u32 size);
|
||||
|
||||
// Writes text to the console.
|
||||
// *DEPRECIATED* Use Console namespace methods instead.
|
||||
void SysPrintf(const char *fmt, ...); // *DEPRECIATED*
|
||||
|
||||
|
||||
// Console Namespace -- Replacements for SysPrintf.
|
||||
// SysPrintf is depreciated -- We should phase these in over time.
|
||||
namespace Console
|
||||
{
|
||||
extern void Open();
|
||||
extern void Close();
|
||||
extern void SetTitle( const char* title );
|
||||
|
||||
// The following Write functions return bool so that we can use macros to exclude
|
||||
// them from different buildypes. The return values are always zero.
|
||||
|
||||
extern bool __fastcall WriteLn();
|
||||
extern bool __fastcall Write( const char* fmt );
|
||||
extern bool __fastcall WriteLn( const char* fmt );
|
||||
extern bool Format( const char* fmt, ... );
|
||||
extern bool FormatLn( const char* fmt, ... );
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
// Macros for ifdef'ing out specific lines of code.
|
||||
|
||||
#ifdef PCSX2_DEVBUILD
|
||||
|
||||
# define DEVCODE(x) (x)
|
||||
# define DevCon Console
|
||||
# define PUBCODE 0&&
|
||||
|
||||
static const bool IsDevBuild = true;
|
||||
|
||||
#else
|
||||
|
||||
# define DEVCODE(x) 0&&(x)
|
||||
# define DevCon 0&&Console
|
||||
# define PUBCODE(x) (x)
|
||||
|
||||
static const bool IsDevBuild = false;
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef _DEBUG
|
||||
|
||||
static const bool IsDebugBuild = true;
|
||||
|
||||
# define DBGCODE(x) (x)
|
||||
# define DbgCon 0&&Console
|
||||
|
||||
#else
|
||||
|
||||
# define DBGCODE(x) 0&&
|
||||
# define DbgCon 0&&Console
|
||||
|
||||
static const bool IsDebugBuild = false;
|
||||
#endif
|
||||
|
||||
#ifdef PCSX2_VIRTUAL_MEM
|
||||
|
||||
struct PSMEMORYBLOCK
|
||||
|
|
|
@ -0,0 +1,170 @@
|
|||
/* Pcsx2 - Pc Ps2 Emulator
|
||||
* Copyright (C) 2002-2008 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 "misc.h"
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// Cross-platform atomic operations for GCC
|
||||
#ifndef _WIN32
|
||||
|
||||
typedef void* PVOID;
|
||||
|
||||
/*inline unsigned long _Atomic_swap(unsigned long * __p, unsigned long __q) {
|
||||
# if __mips < 3 || !(defined (_ABIN32) || defined(_ABI64))
|
||||
return test_and_set(__p, __q);
|
||||
# else
|
||||
return __test_and_set(__p, (unsigned long)__q);
|
||||
# endif
|
||||
}*/
|
||||
__forceinline 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
|
||||
}
|
||||
|
||||
__forceinline 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" );
|
||||
return 0; // The only function that even looks at this is a debugging function
|
||||
}
|
||||
|
||||
__forceinline 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" );
|
||||
return 0; // The return value is never looked at.
|
||||
}
|
||||
|
||||
__forceinline long InterlockedIncrement( volatile long* Addend )
|
||||
{
|
||||
return InterlockedExchangeAdd( Addend, 1 );
|
||||
}
|
||||
|
||||
__forceinline long InterlockedDecrement( volatile long* Addend )
|
||||
{
|
||||
return InterlockedExchangeAdd( Addend, -1 );
|
||||
}
|
||||
|
||||
__forceinline long InterlockedCompareExchange(volatile long *dest, long exch, long comp)
|
||||
{
|
||||
long old;
|
||||
|
||||
#ifdef __x86_64__
|
||||
__asm__ __volatile__
|
||||
(
|
||||
"lock; cmpxchgq %q2, %1"
|
||||
: "=a" (old), "=m" (*dest)
|
||||
: "r" (exch), "m" (*dest), "0" (comp));
|
||||
#else
|
||||
__asm__ __volatile__
|
||||
(
|
||||
"lock; cmpxchgl %2, %0"
|
||||
: "=m" (*dest), "=a" (old)
|
||||
: "r" (exch), "m" (*dest), "a" (comp)
|
||||
);
|
||||
#endif
|
||||
|
||||
return(old);
|
||||
}
|
||||
|
||||
__forceinline long InterlockedCompareExchangePointer(PVOID volatile *dest, PVOID exch, long comp)
|
||||
{
|
||||
long old;
|
||||
|
||||
#ifdef __x86_64__
|
||||
__asm__ __volatile__
|
||||
(
|
||||
"lock; cmpxchgq %q2, %1"
|
||||
: "=a" (old), "=m" (*dest)
|
||||
: "r" (exch), "m" (*dest), "0" (comp)
|
||||
);
|
||||
#else
|
||||
__asm__ __volatile__
|
||||
(
|
||||
"lock; cmpxchgl %2, %0"
|
||||
: "=m" (*dest), "=a" (old)
|
||||
: "r" (exch), "m" (*dest), "a" (comp)
|
||||
);
|
||||
#endif
|
||||
return(old);
|
||||
}
|
||||
#endif
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
// define some overloads for InterlockedExchanges
|
||||
// for commonly used types, like u32 and s32.
|
||||
|
||||
__forceinline void AtomicExchange( u32& Target, u32 value )
|
||||
{
|
||||
InterlockedExchange( (volatile LONG*)&Target, value );
|
||||
}
|
||||
|
||||
__forceinline void AtomicExchangeAdd( u32& Target, u32 value )
|
||||
{
|
||||
InterlockedExchangeAdd( (volatile LONG*)&Target, value );
|
||||
}
|
||||
|
||||
__forceinline void AtomicIncrement( u32& Target )
|
||||
{
|
||||
InterlockedIncrement( (volatile LONG*)&Target );
|
||||
}
|
||||
|
||||
__forceinline void AtomicDecrement( u32& Target )
|
||||
{
|
||||
InterlockedDecrement( (volatile LONG*)&Target );
|
||||
}
|
||||
|
||||
__forceinline void AtomicExchange( s32& Target, s32 value )
|
||||
{
|
||||
InterlockedExchange( (volatile LONG*)&Target, value );
|
||||
}
|
||||
|
||||
__forceinline void AtomicExchangeAdd( s32& Target, u32 value )
|
||||
{
|
||||
InterlockedExchangeAdd( (volatile LONG*)&Target, value );
|
||||
}
|
||||
|
||||
__forceinline void AtomicIncrement( s32& Target )
|
||||
{
|
||||
InterlockedIncrement( (volatile LONG*)&Target );
|
||||
}
|
||||
|
||||
__forceinline void AtomicDecrement( s32& Target )
|
||||
{
|
||||
InterlockedDecrement( (volatile LONG*)&Target );
|
||||
}
|
||||
|
||||
|
||||
__forceinline void _TIMESLICE()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
Sleep(0);
|
||||
#else
|
||||
usleep(500);
|
||||
#endif
|
||||
}
|
|
@ -0,0 +1,132 @@
|
|||
/* Pcsx2 - Pc Ps2 Emulator
|
||||
* Copyright (C) 2002-2008 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 <windows.h>
|
||||
|
||||
#include "Misc.h"
|
||||
#include "Debug.h"
|
||||
#include "System.h"
|
||||
|
||||
namespace Console
|
||||
{
|
||||
static HANDLE hConsole = NULL;
|
||||
|
||||
void SetTitle( const char* title )
|
||||
{
|
||||
if( !hConsole || title==NULL ) return;
|
||||
SetConsoleTitle( title );
|
||||
}
|
||||
|
||||
void Open()
|
||||
{
|
||||
COORD csize;
|
||||
CONSOLE_SCREEN_BUFFER_INFO csbiInfo;
|
||||
SMALL_RECT srect;
|
||||
|
||||
if( hConsole ) return;
|
||||
AllocConsole();
|
||||
SetConsoleTitle(_("Ps2 Output"));
|
||||
|
||||
csize.X = 100;
|
||||
csize.Y = 2048;
|
||||
SetConsoleScreenBufferSize(GetStdHandle(STD_OUTPUT_HANDLE), csize);
|
||||
GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbiInfo);
|
||||
|
||||
srect = csbiInfo.srWindow;
|
||||
srect.Right = srect.Left + 99;
|
||||
srect.Bottom = srect.Top + 64;
|
||||
SetConsoleWindowInfo(GetStdHandle(STD_OUTPUT_HANDLE), TRUE, &srect);
|
||||
hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
}
|
||||
|
||||
void Close()
|
||||
{
|
||||
if( hConsole == NULL ) return;
|
||||
FreeConsole();
|
||||
hConsole = NULL;
|
||||
}
|
||||
|
||||
__forceinline bool __fastcall WriteLn()
|
||||
{
|
||||
if (Config.PsxOut != 0)
|
||||
{
|
||||
DWORD tmp;
|
||||
WriteConsole(hConsole, "\r\n", 2, &tmp, 0);
|
||||
}
|
||||
|
||||
if (emuLog != NULL)
|
||||
{
|
||||
fputs("\r\n", emuLog);
|
||||
fflush( emuLog );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
__forceinline bool __fastcall Write( const char* fmt )
|
||||
{
|
||||
if (Config.PsxOut != 0)
|
||||
{
|
||||
DWORD tmp;
|
||||
WriteConsole(hConsole, fmt, (DWORD)strlen(fmt), &tmp, 0);
|
||||
}
|
||||
|
||||
// No flushing here -- only flush after newlines.
|
||||
if (emuLog != NULL)
|
||||
fputs(fmt, emuLog);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
__forceinline bool __fastcall WriteLn( const char* fmt )
|
||||
{
|
||||
Write( fmt );
|
||||
WriteLn();
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Format( const char* fmt, ... )
|
||||
{
|
||||
va_list list;
|
||||
char msg[2048];
|
||||
|
||||
va_start(list,fmt);
|
||||
_vsnprintf(msg,2047,fmt,list);
|
||||
msg[2047] = '\0';
|
||||
va_end(list);
|
||||
|
||||
Write( msg );
|
||||
return false;
|
||||
}
|
||||
|
||||
bool FormatLn( const char* fmt, ... )
|
||||
{
|
||||
va_list list;
|
||||
char msg[2048];
|
||||
|
||||
va_start(list,fmt);
|
||||
_vsnprintf(msg,2045,fmt,list);
|
||||
va_end(list);
|
||||
|
||||
strcat( msg, "\r\n" );
|
||||
Write( msg );
|
||||
if( emuLog != NULL )
|
||||
fflush( emuLog ); // manual flush to accomany manual newline
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -16,7 +16,7 @@
|
|||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
|
||||
#include "Win32.h"
|
||||
#include "Common.h"
|
||||
#include "resource.h"
|
||||
|
||||
|
|
|
@ -559,11 +559,11 @@ BOOL APIENTRY DebuggerProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
#ifdef PCSX2_DEVBUILD
|
||||
case IDC_DEBUG_LOG:
|
||||
#ifdef PCSX2_DEVBUILD
|
||||
Log = 1 - Log;
|
||||
#endif
|
||||
return TRUE;
|
||||
#endif
|
||||
|
||||
case IDC_DEBUG_RESETTOPC:
|
||||
DebuggerPC = 0;
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
|
||||
#ifndef _DEBUG
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#include "SamplProf.h"
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
@ -102,29 +104,33 @@ struct Module
|
|||
}
|
||||
};
|
||||
|
||||
vector<Module> ProfModules;
|
||||
typedef map<string,Module> MapType;
|
||||
|
||||
MapType ProfUnknownHash;
|
||||
static vector<Module> ProfModules;
|
||||
static MapType ProfUnknownHash;
|
||||
|
||||
HANDLE hEmuThread;
|
||||
HANDLE hProfThread;
|
||||
static HANDLE hEmuThread;
|
||||
static HANDLE hProfThread;
|
||||
|
||||
static CRITICAL_SECTION ProfModulesLock;
|
||||
|
||||
static volatile bool ProfRunning=false;
|
||||
|
||||
void ProfilerRegisterSource(const char* Name,void* buff,u32 sz)
|
||||
{
|
||||
ProfilerTerm();
|
||||
EnterCriticalSection( &ProfModulesLock );
|
||||
Module tmp(Name,buff,sz);
|
||||
ProfModules.push_back(tmp);
|
||||
ProfilerInit();
|
||||
LeaveCriticalSection( &ProfModulesLock );
|
||||
}
|
||||
|
||||
void ProfilerRegisterSource(const char* Name,void* function)
|
||||
{
|
||||
ProfilerTerm();
|
||||
EnterCriticalSection( &ProfModulesLock );
|
||||
Module tmp(Name,function);
|
||||
ProfModules.push_back(tmp);
|
||||
ProfilerInit();
|
||||
LeaveCriticalSection( &ProfModulesLock );
|
||||
}
|
||||
volatile bool ProfRunning=false;
|
||||
|
||||
int __stdcall ProfilerThread(void* nada)
|
||||
{
|
||||
|
@ -134,9 +140,9 @@ int __stdcall ProfilerThread(void* nada)
|
|||
while(ProfRunning)
|
||||
{
|
||||
_loopstart:
|
||||
Sleep(10);
|
||||
Sleep(7);
|
||||
|
||||
if (tick_count>300)
|
||||
if (tick_count>400)
|
||||
{
|
||||
string rv="|";
|
||||
u32 subtotal=0;
|
||||
|
@ -172,15 +178,19 @@ _loopstart:
|
|||
CONTEXT ctx;
|
||||
ctx.ContextFlags= CONTEXT_FULL;
|
||||
GetThreadContext(hEmuThread,&ctx);
|
||||
for (size_t i=0;i<ProfModules.size();i++)
|
||||
|
||||
EnterCriticalSection( &ProfModulesLock );
|
||||
size_t i;
|
||||
for(i=0;i<ProfModules.size();i++)
|
||||
if (ProfModules[i].Inside(ctx.Eip)) break;
|
||||
|
||||
if( i < ProfModules.size() )
|
||||
{
|
||||
|
||||
if (ProfModules[i].Inside(ctx.Eip))
|
||||
{
|
||||
ProfModules[i].ticks++;
|
||||
goto _loopstart; //and thats why structured programming sucks
|
||||
}
|
||||
ProfModules[i].ticks++;
|
||||
LeaveCriticalSection( &ProfModulesLock );
|
||||
continue;
|
||||
}
|
||||
LeaveCriticalSection( &ProfModulesLock );
|
||||
|
||||
char modulename[512];
|
||||
|
||||
|
@ -201,9 +211,7 @@ _loopstart:
|
|||
Module tmp(sz==0?modulenam.c_str():0,(void*)ctx.Eip);
|
||||
tmp.ticks++;
|
||||
|
||||
|
||||
ProfUnknownHash.insert(MapType::value_type(modulenam, tmp));
|
||||
|
||||
}
|
||||
|
||||
return -1;
|
||||
|
@ -213,6 +221,8 @@ void ProfilerInit()
|
|||
{
|
||||
if (ProfRunning)
|
||||
return;
|
||||
|
||||
//Console::Write( "Profiler Thread Initializing..." );
|
||||
ProfRunning=true;
|
||||
DuplicateHandle(GetCurrentProcess(),
|
||||
GetCurrentThread(),
|
||||
|
@ -221,11 +231,17 @@ void ProfilerInit()
|
|||
0,
|
||||
FALSE,
|
||||
DUPLICATE_SAME_ACCESS);
|
||||
|
||||
InitializeCriticalSection( &ProfModulesLock );
|
||||
|
||||
hProfThread=CreateThread(0,0,(LPTHREAD_START_ROUTINE)ProfilerThread,0,0,0);
|
||||
SetThreadPriority(hProfThread,THREAD_PRIORITY_HIGHEST);
|
||||
//Console::WriteLn( " Done!" );
|
||||
}
|
||||
|
||||
void ProfilerTerm()
|
||||
{
|
||||
//Console::Write( "Profiler Terminating..." );
|
||||
if (!ProfRunning)
|
||||
return;
|
||||
ProfRunning=false;
|
||||
|
@ -233,6 +249,8 @@ void ProfilerTerm()
|
|||
WaitForSingleObject(hProfThread,INFINITE);
|
||||
CloseHandle(hProfThread);
|
||||
CloseHandle(hEmuThread);
|
||||
DeleteCriticalSection( &ProfModulesLock );
|
||||
//Console::WriteLn( " Done!" );
|
||||
}
|
||||
|
||||
void ProfilerSetEnabled(bool Enabled)
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Release VM|Win32"
|
||||
Name="Release vm (dev)|Win32"
|
||||
ConfigurationType="1"
|
||||
InheritedPropertySheets=".\vsprops\common.vsprops;.\vsprops\release.vsprops;.\vsprops\virtualmem.vsprops;.\vsprops\devbuild.vsprops"
|
||||
UseOfMFC="0"
|
||||
|
@ -235,7 +235,7 @@
|
|||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release vtlb|Win32"
|
||||
Name="Release vtlb (dev)|Win32"
|
||||
ConfigurationType="1"
|
||||
InheritedPropertySheets=".\vsprops\common.vsprops;.\vsprops\release.vsprops;.\vsprops\devbuild.vsprops"
|
||||
UseOfMFC="0"
|
||||
|
@ -328,7 +328,7 @@
|
|||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release VM (to Public)|Win32"
|
||||
Name="Release vm (nondev)|Win32"
|
||||
ConfigurationType="1"
|
||||
InheritedPropertySheets=".\vsprops\common.vsprops;.\vsprops\release.vsprops;.\vsprops\virtualmem.vsprops"
|
||||
UseOfMFC="0"
|
||||
|
@ -404,7 +404,7 @@
|
|||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release vtlb (to Public)|Win32"
|
||||
Name="Release vtlb (nondev)|Win32"
|
||||
OutputDirectory="$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="1"
|
||||
|
@ -504,6 +504,10 @@
|
|||
RelativePath="..\ConfigDlg.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\Console.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\CpuDlg.c"
|
||||
>
|
||||
|
@ -636,10 +640,18 @@
|
|||
RelativePath="..\..\SamplProf.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\SourceLog.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\System.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\ThreadTools.cpp"
|
||||
>
|
||||
</File>
|
||||
<Filter
|
||||
Name="TinyXML"
|
||||
>
|
||||
|
@ -768,7 +780,7 @@
|
|||
RelativePath="..\..\zlib\adler32.c"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Release VM|Win32"
|
||||
Name="Release vm (dev)|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
|
@ -792,7 +804,7 @@
|
|||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release vtlb|Win32"
|
||||
Name="Release vtlb (dev)|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
|
@ -800,7 +812,7 @@
|
|||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release VM (to Public)|Win32"
|
||||
Name="Release vm (nondev)|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
|
@ -808,7 +820,7 @@
|
|||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release vtlb (to Public)|Win32"
|
||||
Name="Release vtlb (nondev)|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
|
@ -820,7 +832,7 @@
|
|||
RelativePath="..\..\zlib\compress.c"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Release VM|Win32"
|
||||
Name="Release vm (dev)|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
|
@ -844,7 +856,7 @@
|
|||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release vtlb|Win32"
|
||||
Name="Release vtlb (dev)|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
|
@ -852,7 +864,7 @@
|
|||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release VM (to Public)|Win32"
|
||||
Name="Release vm (nondev)|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
|
@ -860,7 +872,7 @@
|
|||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release vtlb (to Public)|Win32"
|
||||
Name="Release vtlb (nondev)|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
|
@ -872,7 +884,7 @@
|
|||
RelativePath="..\..\zlib\crc32.c"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Release VM|Win32"
|
||||
Name="Release vm (dev)|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
|
@ -896,7 +908,7 @@
|
|||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release vtlb|Win32"
|
||||
Name="Release vtlb (dev)|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
|
@ -904,7 +916,7 @@
|
|||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release VM (to Public)|Win32"
|
||||
Name="Release vm (nondev)|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
|
@ -912,7 +924,7 @@
|
|||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release vtlb (to Public)|Win32"
|
||||
Name="Release vtlb (nondev)|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
|
@ -928,7 +940,7 @@
|
|||
RelativePath="..\..\zlib\deflate.c"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Release VM|Win32"
|
||||
Name="Release vm (dev)|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
|
@ -952,7 +964,7 @@
|
|||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release vtlb|Win32"
|
||||
Name="Release vtlb (dev)|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
|
@ -960,7 +972,7 @@
|
|||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release VM (to Public)|Win32"
|
||||
Name="Release vm (nondev)|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
|
@ -968,7 +980,7 @@
|
|||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release vtlb (to Public)|Win32"
|
||||
Name="Release vtlb (nondev)|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
|
@ -984,7 +996,7 @@
|
|||
RelativePath="..\..\zlib\gzio.c"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Release VM|Win32"
|
||||
Name="Release vm (dev)|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
|
@ -1008,7 +1020,7 @@
|
|||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release vtlb|Win32"
|
||||
Name="Release vtlb (dev)|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
|
@ -1016,7 +1028,7 @@
|
|||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release VM (to Public)|Win32"
|
||||
Name="Release vm (nondev)|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
|
@ -1024,7 +1036,7 @@
|
|||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release vtlb (to Public)|Win32"
|
||||
Name="Release vtlb (nondev)|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
|
@ -1036,7 +1048,7 @@
|
|||
RelativePath="..\..\zlib\infback.c"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Release VM|Win32"
|
||||
Name="Release vm (dev)|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
|
@ -1060,7 +1072,7 @@
|
|||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release vtlb|Win32"
|
||||
Name="Release vtlb (dev)|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
|
@ -1068,7 +1080,7 @@
|
|||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release VM (to Public)|Win32"
|
||||
Name="Release vm (nondev)|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
|
@ -1076,7 +1088,7 @@
|
|||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release vtlb (to Public)|Win32"
|
||||
Name="Release vtlb (nondev)|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
|
@ -1088,7 +1100,7 @@
|
|||
RelativePath="..\..\zlib\inffast.c"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Release VM|Win32"
|
||||
Name="Release vm (dev)|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
|
@ -1112,7 +1124,7 @@
|
|||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release vtlb|Win32"
|
||||
Name="Release vtlb (dev)|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
|
@ -1120,7 +1132,7 @@
|
|||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release VM (to Public)|Win32"
|
||||
Name="Release vm (nondev)|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
|
@ -1128,7 +1140,7 @@
|
|||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release vtlb (to Public)|Win32"
|
||||
Name="Release vtlb (nondev)|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
|
@ -1148,7 +1160,7 @@
|
|||
RelativePath="..\..\zlib\inflate.c"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Release VM|Win32"
|
||||
Name="Release vm (dev)|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
|
@ -1172,7 +1184,7 @@
|
|||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release vtlb|Win32"
|
||||
Name="Release vtlb (dev)|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
|
@ -1180,7 +1192,7 @@
|
|||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release VM (to Public)|Win32"
|
||||
Name="Release vm (nondev)|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
|
@ -1188,7 +1200,7 @@
|
|||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release vtlb (to Public)|Win32"
|
||||
Name="Release vtlb (nondev)|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
|
@ -1204,7 +1216,7 @@
|
|||
RelativePath="..\..\zlib\inftrees.c"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Release VM|Win32"
|
||||
Name="Release vm (dev)|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
|
@ -1228,7 +1240,7 @@
|
|||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release vtlb|Win32"
|
||||
Name="Release vtlb (dev)|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
|
@ -1236,7 +1248,7 @@
|
|||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release VM (to Public)|Win32"
|
||||
Name="Release vm (nondev)|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
|
@ -1244,7 +1256,7 @@
|
|||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release vtlb (to Public)|Win32"
|
||||
Name="Release vtlb (nondev)|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
|
@ -1260,7 +1272,7 @@
|
|||
RelativePath="..\..\zlib\trees.c"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Release VM|Win32"
|
||||
Name="Release vm (dev)|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
|
@ -1284,7 +1296,7 @@
|
|||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release vtlb|Win32"
|
||||
Name="Release vtlb (dev)|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
|
@ -1292,7 +1304,7 @@
|
|||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release VM (to Public)|Win32"
|
||||
Name="Release vm (nondev)|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
|
@ -1300,7 +1312,7 @@
|
|||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release vtlb (to Public)|Win32"
|
||||
Name="Release vtlb (nondev)|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
|
@ -1316,7 +1328,7 @@
|
|||
RelativePath="..\..\zlib\uncompr.c"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Release VM|Win32"
|
||||
Name="Release vm (dev)|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
|
@ -1340,7 +1352,7 @@
|
|||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release vtlb|Win32"
|
||||
Name="Release vtlb (dev)|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
|
@ -1348,7 +1360,7 @@
|
|||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release VM (to Public)|Win32"
|
||||
Name="Release vm (nondev)|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
|
@ -1356,7 +1368,7 @@
|
|||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release vtlb (to Public)|Win32"
|
||||
Name="Release vtlb (nondev)|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
|
@ -1376,7 +1388,7 @@
|
|||
RelativePath="..\..\zlib\zutil.c"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Release VM|Win32"
|
||||
Name="Release vm (dev)|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
|
@ -1400,7 +1412,7 @@
|
|||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release vtlb|Win32"
|
||||
Name="Release vtlb (dev)|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
|
@ -1408,7 +1420,7 @@
|
|||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release VM (to Public)|Win32"
|
||||
Name="Release vm (nondev)|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
|
@ -1416,7 +1428,7 @@
|
|||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release vtlb (to Public)|Win32"
|
||||
Name="Release vtlb (nondev)|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
|
@ -1459,7 +1471,7 @@
|
|||
RelativePath="..\..\Counters.c"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Release VM|Win32"
|
||||
Name="Release vm (dev)|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
|
@ -1467,7 +1479,7 @@
|
|||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release VM (to Public)|Win32"
|
||||
Name="Release vm (nondev)|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
|
@ -1476,7 +1488,7 @@
|
|||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release vtlb (to Public)|Win32"
|
||||
Name="Release vtlb (nondev)|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
|
@ -1568,7 +1580,7 @@
|
|||
RelativePath="..\..\x86\iFPU.c"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Release VM|Win32"
|
||||
Name="Release vm (dev)|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
|
@ -1592,7 +1604,7 @@
|
|||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release vtlb|Win32"
|
||||
Name="Release vtlb (dev)|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
|
@ -1600,7 +1612,7 @@
|
|||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release VM (to Public)|Win32"
|
||||
Name="Release vm (nondev)|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
|
@ -1608,7 +1620,7 @@
|
|||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release vtlb (to Public)|Win32"
|
||||
Name="Release vtlb (nondev)|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
|
@ -1668,7 +1680,7 @@
|
|||
RelativePath="..\..\x86\ir5900tables.c"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Release VM (to Public)|Win32"
|
||||
Name="Release vm (nondev)|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
|
@ -1676,7 +1688,7 @@
|
|||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release vtlb (to Public)|Win32"
|
||||
Name="Release vtlb (nondev)|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#define __WIN32_H__
|
||||
|
||||
#include <tchar.h>
|
||||
#include "Misc.h"
|
||||
|
||||
// --->> Ini Configuration [ini.c]
|
||||
|
||||
|
@ -31,6 +32,14 @@ void SaveConfig();
|
|||
|
||||
// <<--- END Ini Configuration [ini.c]
|
||||
|
||||
struct AppData
|
||||
{
|
||||
HWND hWnd; // Main window handle
|
||||
HINSTANCE hInstance; // Application instance
|
||||
HMENU hMenu; // Main window menu
|
||||
};
|
||||
|
||||
extern AppData gApp;
|
||||
|
||||
extern int needReset;
|
||||
|
||||
|
@ -49,8 +58,6 @@ void InitLanguages();
|
|||
char *GetLanguageNext();
|
||||
void CloseLanguages();
|
||||
void ChangeLanguage(char *lang);
|
||||
void OpenConsole();
|
||||
void CloseConsole();
|
||||
#define StatusSet(text) SendMessage(hStatusWnd, SB_SETTEXT, 0, (LPARAM)text);
|
||||
|
||||
//patch browser window
|
||||
|
|
|
@ -67,6 +67,7 @@ static unsigned int langsMax;
|
|||
PcsxConfig winConfig; // local storage of the configuration options.
|
||||
|
||||
HWND hStatusWnd;
|
||||
AppData gApp;
|
||||
|
||||
extern int g_SaveGSStream;
|
||||
|
||||
|
@ -82,30 +83,6 @@ _langs *langs = NULL;
|
|||
static int UseGui = 1;
|
||||
static int nDisableSC = 0; // screensaver
|
||||
|
||||
void OpenConsole() {
|
||||
COORD csize;
|
||||
CONSOLE_SCREEN_BUFFER_INFO csbiInfo;
|
||||
SMALL_RECT srect;
|
||||
|
||||
if (gApp.hConsole) return;
|
||||
AllocConsole();
|
||||
SetConsoleTitle(_("Ps2 Output"));
|
||||
csize.X = 100;
|
||||
csize.Y = 2048;
|
||||
SetConsoleScreenBufferSize(GetStdHandle(STD_OUTPUT_HANDLE), csize);
|
||||
|
||||
GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbiInfo);
|
||||
srect = csbiInfo.srWindow;
|
||||
srect.Right = srect.Left + 99;
|
||||
srect.Bottom = srect.Top + 64;
|
||||
SetConsoleWindowInfo(GetStdHandle(STD_OUTPUT_HANDLE), TRUE, &srect);
|
||||
gApp.hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
}
|
||||
|
||||
void CloseConsole() {
|
||||
if (gApp.hConsole == NULL) return;
|
||||
FreeConsole(); gApp.hConsole = NULL;
|
||||
}
|
||||
void strcatz(char *dst, char *src) {
|
||||
int len = strlen(dst) + 1;
|
||||
strcpy(dst + len, src);
|
||||
|
@ -456,9 +433,9 @@ static int ParseCommandLine( int tokenCount, TCHAR *const *const tokens )
|
|||
UseGui = 0;
|
||||
}
|
||||
#ifdef PCSX2_DEVBUILD
|
||||
else if( CmdSwitchIs( "jpg" ) ) {
|
||||
g_TestRun.jpgcapture = 1;
|
||||
}
|
||||
else if( CmdSwitchIs( "jpg" ) ) {
|
||||
g_TestRun.jpgcapture = 1;
|
||||
}
|
||||
#endif
|
||||
else
|
||||
{
|
||||
|
@ -551,7 +528,6 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
|
|||
gApp.hInstance = hInstance;
|
||||
gApp.hMenu = NULL;
|
||||
gApp.hWnd = NULL;
|
||||
gApp.hConsole = NULL;
|
||||
|
||||
#ifdef ENABLE_NLS
|
||||
bindtextdomain(PACKAGE, "Langs\\");
|
||||
|
@ -625,10 +601,10 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
|
|||
|
||||
if( winConfig.PsxOut )
|
||||
{
|
||||
OpenConsole();
|
||||
Console::Open();
|
||||
|
||||
if( lpCmdLine == NULL || *lpCmdLine == 0 )
|
||||
SysPrintf("-help to see arguments\n");
|
||||
Console::WriteLn("-help to see arguments");
|
||||
}
|
||||
|
||||
// Load the command line overrides for plugins:
|
||||
|
@ -638,26 +614,25 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
|
|||
if( g_TestRun.pgsdll )
|
||||
{
|
||||
_tcscpy_s( Config.GS, g_MaxPath, g_TestRun.pgsdll );
|
||||
SysPrintf( "* GS plugin override: \n\t%s\n\n", Config.GS );
|
||||
Console::FormatLn( "* GS plugin override: \n\t%s\n", Config.GS );
|
||||
}
|
||||
if( g_TestRun.pcdvddll )
|
||||
{
|
||||
_tcscpy_s( Config.CDVD, g_MaxPath, g_TestRun.pcdvddll );
|
||||
SysPrintf( "* CDVD plugin override: \n\t%s\n\n", Config.CDVD );
|
||||
Console::FormatLn( "* CDVD plugin override: \n\t%s\n", Config.CDVD );
|
||||
}
|
||||
if( g_TestRun.pspudll )
|
||||
{
|
||||
_tcscpy_s( Config.SPU2, g_MaxPath, g_TestRun.pspudll );
|
||||
SysPrintf( "* SPU2 plugin override: \n\t%s\n\n", Config.SPU2 );
|
||||
Console::FormatLn( "* SPU2 plugin override: \n\t%s\n", Config.SPU2 );
|
||||
}
|
||||
|
||||
// [TODO] : Add the other plugin overrides here...
|
||||
|
||||
ProfilerInit();
|
||||
InitCPUTicks();
|
||||
if (SysInit() == -1) return 1;
|
||||
|
||||
ProfilerInit();
|
||||
|
||||
#ifdef PCSX2_DEVBUILD
|
||||
if( g_TestRun.enabled || g_TestRun.ptitle != NULL ) {
|
||||
// run without ui
|
||||
|
@ -682,15 +657,13 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
|
|||
if( Config.PsxOut )
|
||||
{
|
||||
// output the help commands
|
||||
SysPrintf("\tF1 - save state\n");
|
||||
SysPrintf("\t(Shift +) F2 - cycle states\n");
|
||||
SysPrintf("\tF3 - load state\n");
|
||||
Console::WriteLn("\tF1 - save state");
|
||||
Console::WriteLn("\t(Shift +) F2 - cycle states");
|
||||
Console::WriteLn("\tF3 - load state");
|
||||
|
||||
#ifdef PCSX2_DEVBUILD
|
||||
SysPrintf("\tF10 - dump performance counters\n");
|
||||
SysPrintf("\tF11 - save GS state\n");
|
||||
SysPrintf("\tF12 - dump hardware registers\n");
|
||||
#endif
|
||||
DevCon::WriteLn("\tF10 - dump performance counters");
|
||||
DevCon::WriteLn("\tF11 - save GS state");
|
||||
DevCon::WriteLn("\tF12 - dump hardware registers");
|
||||
}
|
||||
|
||||
LoadPatch("default");
|
||||
|
@ -1331,14 +1304,14 @@ LRESULT WINAPI MainWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) {
|
|||
if(Config.PsxOut)
|
||||
{
|
||||
CheckMenuItem(gApp.hMenu,ID_CONSOLE,MF_UNCHECKED);
|
||||
CloseConsole();
|
||||
Console::Close();
|
||||
Config.PsxOut=0;
|
||||
SaveConfig();
|
||||
}
|
||||
else
|
||||
{
|
||||
CheckMenuItem(gApp.hMenu,ID_CONSOLE,MF_CHECKED);
|
||||
OpenConsole();
|
||||
Console::Open();
|
||||
Config.PsxOut=1;
|
||||
SaveConfig();
|
||||
}
|
||||
|
@ -1385,7 +1358,7 @@ LRESULT WINAPI MainWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) {
|
|||
break;
|
||||
|
||||
case WM_QUIT:
|
||||
if (Config.PsxOut) CloseConsole();
|
||||
if (Config.PsxOut) Console::Close();
|
||||
exit(0);
|
||||
break;
|
||||
|
||||
|
@ -1475,9 +1448,6 @@ void CreateMainMenu() {
|
|||
ADDMENUITEM(0,_("E&xecute"), ID_RUN_EXECUTE);
|
||||
|
||||
ADDSUBMENU(0,_("&Config"));
|
||||
//#ifdef PCSX2_DEVBUILD
|
||||
// ADDMENUITEM(0,_("&Advanced"), ID_CONFIG_ADVANCED);
|
||||
//#endif
|
||||
ADDMENUITEM(0,_("Advanced"), ID_ADVANCED_OPTIONS);
|
||||
ADDMENUITEM(0,_("Speed &Hacks"), ID_HACKS);
|
||||
ADDMENUITEM(0,_("Gamefixes"), ID_GAMEFIXES);
|
||||
|
@ -1525,9 +1495,8 @@ void CreateMainMenu() {
|
|||
ADDMENUITEM(0,_("&Compatibility List..."), ID_HELP_HELP);
|
||||
ADDMENUITEM(0,_("&About..."), ID_HELP_ABOUT);
|
||||
|
||||
#ifndef PCSX2_DEVBUILD
|
||||
EnableMenuItem(GetSubMenu(gApp.hMenu, 4), ID_DEBUG_LOGGING, MF_GRAYED);
|
||||
#endif
|
||||
if( !IsDevBuild )
|
||||
EnableMenuItem(GetSubMenu(gApp.hMenu, 4), ID_DEBUG_LOGGING, MF_GRAYED);
|
||||
}
|
||||
|
||||
void CreateMainWindow(int nCmdShow) {
|
||||
|
@ -1730,17 +1699,15 @@ static int sinit=0;
|
|||
int SysInit() {
|
||||
CreateDirectory(MEMCARDS_DIR, NULL);
|
||||
CreateDirectory(SSTATES_DIR, NULL);
|
||||
#ifdef EMU_LOG
|
||||
|
||||
CreateDirectory(LOGS_DIR, NULL);
|
||||
|
||||
#ifdef PCSX2_DEVBUILD
|
||||
if( g_TestRun.plogname != NULL )
|
||||
|
||||
if( IsDevBuild && g_TestRun.plogname != NULL )
|
||||
emuLog = fopen(g_TestRun.plogname, "w");
|
||||
#endif
|
||||
|
||||
if( emuLog == NULL )
|
||||
emuLog = fopen(LOGS_DIR "\\emuLog.txt","w");
|
||||
#endif
|
||||
|
||||
if (cpuInit() == -1) return -1;
|
||||
|
||||
|
@ -1786,53 +1753,13 @@ void SysPrintf(const char *fmt, ...)
|
|||
{
|
||||
va_list list;
|
||||
char msg[512];
|
||||
char *ptr;
|
||||
DWORD tmp;
|
||||
int len, s;
|
||||
int i, j;
|
||||
|
||||
va_start(list,fmt);
|
||||
_vsnprintf(msg,511,fmt,list);
|
||||
vsnprintf(msg,511,fmt,list);
|
||||
msg[511] = '\0';
|
||||
va_end(list);
|
||||
|
||||
if (Config.PsxOut == 0) {
|
||||
#ifndef LOG_STDOUT
|
||||
if (emuLog != NULL && !(varLog & 0x80000000)) {
|
||||
fprintf(emuLog, "%s", msg);
|
||||
}
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
ptr = msg; len = strlen(msg);
|
||||
for (i=0, j=0; i<len; i++, j++) {
|
||||
if (ptr[j] == '\033') {
|
||||
ptr[j] = 0;
|
||||
WriteConsole(gApp.hConsole, ptr, (DWORD)strlen(ptr), &tmp, 0);
|
||||
#ifndef LOG_STDOUT
|
||||
if (emuLog != NULL && !(varLog & 0x80000000)) {
|
||||
fprintf(emuLog, "%s", ptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (ptr[j+2] == '0') {
|
||||
SetConsoleTextAttribute(gApp.hConsole, 7);
|
||||
s = 4;
|
||||
} else {
|
||||
SetConsoleTextAttribute(gApp.hConsole, 7);
|
||||
s = 5;
|
||||
}
|
||||
ptr+= j+s;
|
||||
j = 0;
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef LOG_STDOUT
|
||||
if (emuLog != NULL && !(varLog & 0x80000000))
|
||||
fprintf(emuLog, "%s", ptr);
|
||||
#endif
|
||||
WriteConsole(gApp.hConsole, ptr, (DWORD)strlen(ptr), &tmp, 0);
|
||||
Console::Write( msg );
|
||||
}
|
||||
|
||||
void SysMessage(const char *fmt, ...)
|
||||
|
@ -1857,7 +1784,7 @@ void SysRunGui() {
|
|||
RunGui();
|
||||
}
|
||||
|
||||
static char *err = N_("Error Loading Symbol");
|
||||
static const char *err = N_("Error Loading Symbol");
|
||||
static int errval;
|
||||
|
||||
void *SysLoadLibrary(const char *lib) {
|
||||
|
@ -1871,7 +1798,7 @@ void *SysLoadSym(void *lib, const char *sym) {
|
|||
return tmp;
|
||||
}
|
||||
|
||||
char *SysLibError() {
|
||||
const char *SysLibError() {
|
||||
if (GetLastError())
|
||||
{
|
||||
static char perr[4096];
|
||||
|
@ -2120,8 +2047,8 @@ BOOL SysLoggedSetLockPagesPrivilege ( HANDLE hProcess, BOOL bEnable)
|
|||
& Token);
|
||||
|
||||
if( Result != TRUE ) {
|
||||
SysPrintf( "Cannot open process token.\n" );
|
||||
return FALSE;
|
||||
Console::WriteLn( "VirtualMemory Error > Cannot open process token." );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// Enable or disable?
|
||||
|
@ -2129,11 +2056,11 @@ BOOL SysLoggedSetLockPagesPrivilege ( HANDLE hProcess, BOOL bEnable)
|
|||
Info.Count = 1;
|
||||
if( bEnable )
|
||||
{
|
||||
Info.Privilege[0].Attributes = SE_PRIVILEGE_ENABLED;
|
||||
Info.Privilege[0].Attributes = SE_PRIVILEGE_ENABLED;
|
||||
}
|
||||
else
|
||||
{
|
||||
Info.Privilege[0].Attributes = SE_PRIVILEGE_REMOVED;
|
||||
Info.Privilege[0].Attributes = SE_PRIVILEGE_REMOVED;
|
||||
}
|
||||
|
||||
// Get the LUID.
|
||||
|
@ -2143,8 +2070,8 @@ BOOL SysLoggedSetLockPagesPrivilege ( HANDLE hProcess, BOOL bEnable)
|
|||
|
||||
if( Result != TRUE )
|
||||
{
|
||||
SysPrintf( "Cannot get privilege value for %s.\n", SE_LOCK_MEMORY_NAME );
|
||||
return FALSE;
|
||||
Console::FormatLn( "VirtualMemory Error > Cannot get privilege value for %s.", SE_LOCK_MEMORY_NAME );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// Adjust the privilege.
|
||||
|
@ -2156,7 +2083,7 @@ BOOL SysLoggedSetLockPagesPrivilege ( HANDLE hProcess, BOOL bEnable)
|
|||
// Check the result.
|
||||
if( Result != TRUE )
|
||||
{
|
||||
SysPrintf ("Cannot adjust token privileges, error %u.\n", GetLastError() );
|
||||
Console::FormatLn( "VirtualMemory Error > Cannot adjust token privileges, error %u.", GetLastError() );
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
|
@ -2298,7 +2225,7 @@ int SysVirtualPhyAlloc(void* base, u32 size, PSMEMORYBLOCK* pblock)
|
|||
LPVOID lpMemReserved = VirtualAlloc( base, size, MEM_RESERVE | MEM_PHYSICAL, PAGE_READWRITE );
|
||||
if( lpMemReserved == NULL || base != lpMemReserved )
|
||||
{
|
||||
SysPrintf("Cannot reserve memory at 0x%8.8x(%x), error: %d.\n", base, lpMemReserved, GetLastError());
|
||||
Console::FormatLn("VirtualMemory Error %d > Cannot reserve memory at 0x%8.8x(%x).", base, lpMemReserved, GetLastError());
|
||||
goto eCleanupAndExit;
|
||||
}
|
||||
|
||||
|
@ -2310,7 +2237,7 @@ int SysVirtualPhyAlloc(void* base, u32 size, PSMEMORYBLOCK* pblock)
|
|||
|
||||
if( bResult != TRUE )
|
||||
{
|
||||
SysPrintf("MapUserPhysicalPages failed to map, error %u.\n", GetLastError() );
|
||||
Console::FormatLn("VirtualMemory Error %u > MapUserPhysicalPages failed to map.", GetLastError() );
|
||||
goto eCleanupAndExit;
|
||||
}
|
||||
|
||||
|
@ -2326,7 +2253,7 @@ void SysVirtualFree(void* lpMemReserved, u32 size)
|
|||
// unmap
|
||||
if( MapUserPhysicalPages( lpMemReserved, (size+s_dwPageSize-1)/s_dwPageSize, NULL ) != TRUE )
|
||||
{
|
||||
SysPrintf("MapUserPhysicalPages failed to unmap, error %u.\n", GetLastError() );
|
||||
Console::FormatLn("MapUserPhysicalPages failed to unmap, error %u.", GetLastError() );
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -496,7 +496,7 @@ static void PrintDebug(u8 value)
|
|||
{
|
||||
if (value == '\n') {
|
||||
sio_buffer[sio_count] = 0;
|
||||
SysPrintf(COLOR_GREEN "%s\n" COLOR_RESET, sio_buffer);
|
||||
SysPrintf("%s\n", sio_buffer);
|
||||
sio_count = 0;
|
||||
} else {
|
||||
if (sio_count < 1023) {
|
||||
|
|
|
@ -541,12 +541,13 @@ static int recInit() {
|
|||
}
|
||||
else break;
|
||||
}
|
||||
ProfilerRegisterSource("IOPRec",recMem, RECMEM_SIZE);
|
||||
if( recMem == NULL ) {
|
||||
SysPrintf("R3000A bad rec memory allocation\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
ProfilerRegisterSource("IOPRec",recMem, RECMEM_SIZE);
|
||||
|
||||
psxRecLUT = (uptr*) malloc(0x010000 * sizeof(uptr));
|
||||
memset(psxRecLUT, 0, 0x010000 * sizeof(uptr));
|
||||
|
||||
|
@ -1199,13 +1200,16 @@ static void recExecuteBlock()
|
|||
|
||||
void iDumpPsxRegisters(u32 startpc, u32 temp)
|
||||
{
|
||||
// [TODO] fixme : thie code is broken and has no labels. Needs a rewrite to be useful.
|
||||
|
||||
#if 0
|
||||
int i;
|
||||
const char* pstr = temp ? "t" : "";
|
||||
|
||||
__Log("%spsxreg: %x %x ra:%x k0: %x %x\n", pstr, startpc, psxRegs.cycle, psxRegs.GPR.n.ra, psxRegs.GPR.n.k0, *(int*)PSXM(0x13c128));
|
||||
for(i = 0; i < 34; i+=2) __Log("%spsx%s: %x %x\n", pstr, disRNameGPR[i], psxRegs.GPR.r[i], psxRegs.GPR.r[i+1]);
|
||||
__Log("%scycle: %x %x %x; counters %x %x\n", pstr, psxRegs.cycle, g_psxNextBranchCycle, EEsCycle,
|
||||
(uptr)psxNextsCounter, (uptr)psxNextCounter);
|
||||
psxNextsCounter, psxNextCounter);
|
||||
|
||||
__Log("psxdma%d c%x b%x m%x t%x\n", 2, HW_DMA2_CHCR, HW_DMA2_BCR, HW_DMA2_MADR, HW_DMA2_TADR);
|
||||
__Log("psxdma%d c%x b%x m%x\n", 3, HW_DMA3_CHCR, HW_DMA3_BCR, HW_DMA3_MADR);
|
||||
|
@ -1217,10 +1221,9 @@ void iDumpPsxRegisters(u32 startpc, u32 temp)
|
|||
__Log("psxdma%d c%x b%x m%x\n", 10, HW_DMA10_CHCR, HW_DMA10_BCR, HW_DMA10_MADR);
|
||||
__Log("psxdma%d c%x b%x m%x\n", 11, HW_DMA11_CHCR, HW_DMA11_BCR, HW_DMA11_MADR);
|
||||
__Log("psxdma%d c%x b%x m%x\n", 12, HW_DMA12_CHCR, HW_DMA12_BCR, HW_DMA12_MADR);
|
||||
for(i = 0; i < 7; ++i) __Log("%scounter%d: mode %x count %I64x rate %x scycle %x target %I64x\n", pstr, i, psxCounters[i].mode, psxCounters[i].count, psxCounters[i].rate, psxCounters[i].sCycleT, psxCounters[i].target);
|
||||
// for(i = 0; i < 32; ++i) {
|
||||
// __Log("int%d: %x %x\n", i, psxRegs.sCycle[i], psxRegs.eCycle[i]);
|
||||
// }
|
||||
for(i = 0; i < 7; ++i)
|
||||
__Log("%scounter%d: mode %x count %I64x rate %x scycle %x target %I64x\n", pstr, i, psxCounters[i].mode, psxCounters[i].count, psxCounters[i].rate, psxCounters[i].sCycleT, psxCounters[i].target);
|
||||
#endif
|
||||
}
|
||||
|
||||
void iDumpPsxRegisters(u32 startpc);
|
||||
|
|
|
@ -2650,7 +2650,7 @@ void svudispfntemp()
|
|||
{
|
||||
//static int curesp;
|
||||
//__asm mov curesp, esp
|
||||
__Log("tVU: %x %x %x\n", s_svulast, s_vucount, s_vufnheader);
|
||||
Console::FormatLn("tVU: %x %x %x", s_svulast, s_vucount, s_vufnheader);
|
||||
if( g_curdebugvu ) iDumpVU1Registers();
|
||||
else iDumpVU0Registers();
|
||||
s_vucount++;
|
||||
|
@ -4052,25 +4052,6 @@ void vu1xgkick(u32* pMem, u32 addr)
|
|||
StopSVUCounter();
|
||||
#endif
|
||||
|
||||
#ifdef _DEBUG
|
||||
static int scount = 0;
|
||||
//static int curesp;
|
||||
//__asm mov curesp, esp;
|
||||
scount++;
|
||||
|
||||
// if( scount > 1500 ) {
|
||||
// __Log("xgkick 0x%x (%d)\n", addr, scount);
|
||||
// iDumpVU1Registers();
|
||||
// for(int i = 0; i < 0x400; ++i) {
|
||||
// __Log("%x: %x %x %x %x\n", i, *(int*)(VU1.Mem+16*i), *(int*)(VU1.Mem+16*i+4), *(int*)(VU1.Mem+16*i+8), *(int*)(VU1.Mem+16*i+12));
|
||||
// }
|
||||
// }
|
||||
|
||||
if( vudump & 8 ) {
|
||||
__Log("xgkick 0x%x (%d)\n", addr, scount);
|
||||
}
|
||||
#endif
|
||||
|
||||
GSGIFTRANSFER1(pMem, addr);
|
||||
|
||||
#ifdef SUPERVU_COUNT
|
||||
|
|
|
@ -2728,6 +2728,10 @@ extern int rdram_sdevid;
|
|||
|
||||
void iDumpRegisters(u32 startpc, u32 temp)
|
||||
{
|
||||
// [TODO] fixme : thie code is broken and has no labels. Needs a rewrite to be useful.
|
||||
|
||||
#if 0
|
||||
|
||||
int i;
|
||||
const char* pstr;// = temp ? "t" : "";
|
||||
const u32 dmacs[] = {0x8000, 0x9000, 0xa000, 0xb000, 0xb400, 0xc000, 0xc400, 0xc800, 0xd000, 0xd400 };
|
||||
|
@ -2776,6 +2780,7 @@ void iDumpRegisters(u32 startpc, u32 temp)
|
|||
__Log("dmac %x %x %x %x\n", psHu32(DMAC_CTRL), psHu32(DMAC_STAT), psHu32(DMAC_RBSR), psHu32(DMAC_RBOR));
|
||||
__Log("intc %x %x\n", psHu32(INTC_STAT), psHu32(INTC_MASK));
|
||||
__Log("sif: %x %x %x %x %x\n", psHu32(0xf200), psHu32(0xf220), psHu32(0xf230), psHu32(0xf240), psHu32(0xf260));
|
||||
#endif
|
||||
}
|
||||
|
||||
extern u32 psxdump;
|
||||
|
@ -3279,13 +3284,14 @@ StartRecomp:
|
|||
while(stg>0)
|
||||
{
|
||||
CMP32ItoM((uptr)PSM(lpc),*(u32*)PSM(lpc));
|
||||
// fixme: was dyna_block_discard_recmem .. but umm.. why?
|
||||
JNE32(((u32)&dyna_block_discard)- ( (u32)x86Ptr + 6 ));
|
||||
//JMP32( (uptr)&dyna_block_discard - ( (u32)x86Ptr + 5 ));
|
||||
|
||||
stg-=4;
|
||||
lpc+=4;
|
||||
}
|
||||
SysPrintf("Manual block @ %08X : %08X %d %d %d %d\n",startpc,inpage_ptr,pgsz,0x1000-inpage_offs,inpage_sz,sz*4);
|
||||
DbgCon::FormatLn("Manual block @ %08X : %08X %d %d %d %d",
|
||||
startpc,inpage_ptr,pgsz,0x1000-inpage_offs,inpage_sz,sz*4);
|
||||
}
|
||||
}
|
||||
inpage_ptr+=pgsz;
|
||||
|
|
|
@ -25,6 +25,7 @@ using namespace std;
|
|||
#include "tinyxml/tinyxml.h"
|
||||
|
||||
#include "Patch.h"
|
||||
#include "System.h"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(disable:4996) //ignore the stricmp deprecated warning
|
||||
|
@ -113,16 +114,8 @@ int LoadPatch(char *crc)
|
|||
return result;
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
if (gApp.hConsole)
|
||||
{
|
||||
if(title)
|
||||
SetConsoleTitle(title);
|
||||
else
|
||||
SetConsoleTitle("<No Title>");
|
||||
}
|
||||
|
||||
#endif
|
||||
Console::SetTitle(
|
||||
((title==NULL) || (strlen(title)==0)) ? "<No Title>" : title );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -130,7 +123,6 @@ int LoadPatch(char *crc)
|
|||
|
||||
int LoadGroup(TiXmlNode *group,int gParent)
|
||||
{
|
||||
|
||||
TiXmlElement *groupelement = group->ToElement();
|
||||
|
||||
const char *gtitle=groupelement->Attribute("title");
|
||||
|
|
|
@ -7,24 +7,24 @@ Global
|
|||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug vm|Win32 = Debug vm|Win32
|
||||
Debug vtlb|Win32 = Debug vtlb|Win32
|
||||
Release vm (to Public)|Win32 = Release vm (to Public)|Win32
|
||||
Release vm|Win32 = Release vm|Win32
|
||||
Release vtlb (to Public)|Win32 = Release vtlb (to Public)|Win32
|
||||
Release vtlb|Win32 = Release vtlb|Win32
|
||||
Release vm (dev)|Win32 = Release vm (dev)|Win32
|
||||
Release vm (nondev) [public]|Win32 = Release vm (nondev) [public]|Win32
|
||||
Release vtlb (dev)|Win32 = Release vtlb (dev)|Win32
|
||||
Release vtlb (nondev) [public]|Win32 = Release vtlb (nondev) [public]|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{1CEFD830-2B76-4596-A4EE-BCD7280A60BD}.Debug vm|Win32.ActiveCfg = Debug vm|Win32
|
||||
{1CEFD830-2B76-4596-A4EE-BCD7280A60BD}.Debug vm|Win32.Build.0 = Debug vm|Win32
|
||||
{1CEFD830-2B76-4596-A4EE-BCD7280A60BD}.Debug vtlb|Win32.ActiveCfg = Debug vtlb|Win32
|
||||
{1CEFD830-2B76-4596-A4EE-BCD7280A60BD}.Debug vtlb|Win32.Build.0 = Debug vtlb|Win32
|
||||
{1CEFD830-2B76-4596-A4EE-BCD7280A60BD}.Release vm (to Public)|Win32.ActiveCfg = Release VM (to Public)|Win32
|
||||
{1CEFD830-2B76-4596-A4EE-BCD7280A60BD}.Release vm (to Public)|Win32.Build.0 = Release VM (to Public)|Win32
|
||||
{1CEFD830-2B76-4596-A4EE-BCD7280A60BD}.Release vm|Win32.ActiveCfg = Release VM|Win32
|
||||
{1CEFD830-2B76-4596-A4EE-BCD7280A60BD}.Release vm|Win32.Build.0 = Release VM|Win32
|
||||
{1CEFD830-2B76-4596-A4EE-BCD7280A60BD}.Release vtlb (to Public)|Win32.ActiveCfg = Release vtlb (to Public)|Win32
|
||||
{1CEFD830-2B76-4596-A4EE-BCD7280A60BD}.Release vtlb (to Public)|Win32.Build.0 = Release vtlb (to Public)|Win32
|
||||
{1CEFD830-2B76-4596-A4EE-BCD7280A60BD}.Release vtlb|Win32.ActiveCfg = Release vtlb|Win32
|
||||
{1CEFD830-2B76-4596-A4EE-BCD7280A60BD}.Release vtlb|Win32.Build.0 = Release vtlb|Win32
|
||||
{1CEFD830-2B76-4596-A4EE-BCD7280A60BD}.Release vm (dev)|Win32.ActiveCfg = Release vm (dev)|Win32
|
||||
{1CEFD830-2B76-4596-A4EE-BCD7280A60BD}.Release vm (dev)|Win32.Build.0 = Release vm (dev)|Win32
|
||||
{1CEFD830-2B76-4596-A4EE-BCD7280A60BD}.Release vm (nondev) [public]|Win32.ActiveCfg = Release vm (nondev)|Win32
|
||||
{1CEFD830-2B76-4596-A4EE-BCD7280A60BD}.Release vm (nondev) [public]|Win32.Build.0 = Release vm (nondev)|Win32
|
||||
{1CEFD830-2B76-4596-A4EE-BCD7280A60BD}.Release vtlb (dev)|Win32.ActiveCfg = Release vtlb (dev)|Win32
|
||||
{1CEFD830-2B76-4596-A4EE-BCD7280A60BD}.Release vtlb (dev)|Win32.Build.0 = Release vtlb (dev)|Win32
|
||||
{1CEFD830-2B76-4596-A4EE-BCD7280A60BD}.Release vtlb (nondev) [public]|Win32.ActiveCfg = Release vtlb (nondev)|Win32
|
||||
{1CEFD830-2B76-4596-A4EE-BCD7280A60BD}.Release vtlb (nondev) [public]|Win32.Build.0 = Release vtlb (nondev)|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
|
Loading…
Reference in New Issue