refactored the interrupt scheduling code a bit to make it a little more readable than using those "magic" numbers.
git-svn-id: https://pcsxr.svn.codeplex.com/svn/pcsxr@55866 e17a0e51-4ae3-4d35-97c3-1a29b211df97
This commit is contained in:
parent
3c9ffdf13c
commit
511edc3388
14
ChangeLog
14
ChangeLog
|
@ -1,3 +1,17 @@
|
|||
August 7, 2010 Wei Mingzhi <whistler_wmz@users.sf.net>
|
||||
|
||||
* libpcsxcore/r3000a.h: Refactored the interrupt scheduling code to make it a
|
||||
little more readable than using the "magic" numbers.
|
||||
* libpcsxcore/r3000a.c: Likewise.
|
||||
* libpcsxcore/cdrom.c: Likewise.
|
||||
* libpcsxcore/mdec.c: Likewise.
|
||||
* libpcsxcore/sio.c: Likewise.
|
||||
* libpcsxcore/psxdma.h: Likewise.
|
||||
* libpcsxcore/misc.c: Bumped savestate version.
|
||||
* debian/changelog: Updated version.
|
||||
* macosx/Info.plist: Likewise.
|
||||
* po/zh_TW.po: Corrected a minor translation error.
|
||||
|
||||
August 2, 2010 Wei Mingzhi <whistler_wmz@users.sf.net>
|
||||
|
||||
* macosx/Pcsx.xcodeproj/project.pbxproj: Added some more optimizations
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
pcsxr (2:1.9.91-1) unstable; urgency=low
|
||||
pcsxr (2:1.9.92-1) unstable; urgency=low
|
||||
|
||||
* Initial Release.
|
||||
|
||||
|
|
|
@ -92,14 +92,16 @@ static struct CdrStat stat;
|
|||
static struct SubQ *subq;
|
||||
|
||||
#define CDR_INT(eCycle) { \
|
||||
psxRegs.interrupt |= 0x4; \
|
||||
psxRegs.intCycle[2 + 1] = eCycle; \
|
||||
psxRegs.intCycle[2] = psxRegs.cycle; }
|
||||
psxRegs.interrupt |= (1 << PSXINT_CDR); \
|
||||
psxRegs.intCycle[PSXINT_CDR].cycle = eCycle; \
|
||||
psxRegs.intCycle[PSXINT_CDR].sCycle = psxRegs.cycle; \
|
||||
}
|
||||
|
||||
#define CDREAD_INT(eCycle) { \
|
||||
psxRegs.interrupt |= 0x40000; \
|
||||
psxRegs.intCycle[2 + 16 + 1] = eCycle; \
|
||||
psxRegs.intCycle[2 + 16] = psxRegs.cycle; }
|
||||
psxRegs.interrupt |= (1 << PSXINT_CDREAD); \
|
||||
psxRegs.intCycle[PSXINT_CDREAD].cycle = eCycle; \
|
||||
psxRegs.intCycle[PSXINT_CDREAD].sCycle = psxRegs.cycle; \
|
||||
}
|
||||
|
||||
#define StartReading(type, eCycle) { \
|
||||
cdr.Reading = type; \
|
||||
|
@ -111,7 +113,7 @@ static struct SubQ *subq;
|
|||
#define StopReading() { \
|
||||
if (cdr.Reading) { \
|
||||
cdr.Reading = 0; \
|
||||
psxRegs.interrupt &= ~0x40000; \
|
||||
psxRegs.interrupt &= ~(1 << PSXINT_CDREAD); \
|
||||
} \
|
||||
cdr.StatP &= ~0x20;\
|
||||
}
|
||||
|
|
|
@ -543,12 +543,11 @@ void mdec1Interrupt() {
|
|||
if (HW_DMA1_CHCR & SWAP32(0x01000000)) {
|
||||
// Set a fixed value totaly arbitrarie another sound value is
|
||||
// PSXCLK / 60 or PSXCLK / 50 since the bug happened at end of frame.
|
||||
// PSXCLK / 1000 seems good for FF9. (for FF9 need < ~28000)
|
||||
// PSXCLK / 500 seems good for FF9.
|
||||
// CAUTION: commented interrupt-handling may lead to problems, keep an eye ;-)
|
||||
MDECOUTDMA_INT(PSXCLK / 1000 * BIAS);
|
||||
// psxRegs.interrupt |= 0x02000000;
|
||||
// psxRegs.intCycle[5 + 24 + 1] *= 8;
|
||||
// psxRegs.intCycle[5 + 24] = psxRegs.cycle;
|
||||
MDECOUTDMA_INT(PSXCLK / 500);
|
||||
// MDECOUTDMA_INT(psxRegs.intCycle[PSXINT_MDECOUTDMA].cycle * 8);
|
||||
|
||||
HW_DMA1_CHCR &= SWAP32(~0x01000000);
|
||||
DMA_INTERRUPT(1);
|
||||
} else {
|
||||
|
|
|
@ -456,7 +456,7 @@ static const char PcsxHeader[32] = "STv4 PCSX v" PACKAGE_VERSION;
|
|||
|
||||
// Savestate Versioning!
|
||||
// If you make changes to the savestate version, please increment the value below.
|
||||
static const u32 SaveVersion = 0x8b410004;
|
||||
static const u32 SaveVersion = 0x8b410005;
|
||||
|
||||
int SaveState(const char *file) {
|
||||
gzFile f;
|
||||
|
|
|
@ -30,21 +30,21 @@ extern "C" {
|
|||
#include "psxmem.h"
|
||||
|
||||
#define GPUDMA_INT(eCycle) { \
|
||||
psxRegs.interrupt |= 0x01000000; \
|
||||
psxRegs.intCycle[3 + 24 + 1] = eCycle; \
|
||||
psxRegs.intCycle[3 + 24] = psxRegs.cycle; \
|
||||
psxRegs.interrupt |= (1 << PSXINT_GPUDMA); \
|
||||
psxRegs.intCycle[PSXINT_GPUDMA].cycle = eCycle; \
|
||||
psxRegs.intCycle[PSXINT_GPUDMA].sCycle = psxRegs.cycle; \
|
||||
}
|
||||
|
||||
#define SPUDMA_INT(eCycle) { \
|
||||
psxRegs.interrupt |= 0x04000000; \
|
||||
psxRegs.intCycle[1 + 24 + 1] = eCycle; \
|
||||
psxRegs.intCycle[1 + 24] = psxRegs.cycle; \
|
||||
psxRegs.interrupt |= (1 << PSXINT_SPUDMA); \
|
||||
psxRegs.intCycle[PSXINT_SPUDMA].cycle = eCycle; \
|
||||
psxRegs.intCycle[PSXINT_SPUDMA].sCycle = psxRegs.cycle; \
|
||||
}
|
||||
|
||||
#define MDECOUTDMA_INT(eCycle) { \
|
||||
psxRegs.interrupt |= 0x02000000; \
|
||||
psxRegs.intCycle[5 + 24 + 1] = eCycle; \
|
||||
psxRegs.intCycle[5 + 24] = psxRegs.cycle; \
|
||||
psxRegs.interrupt |= (1 << PSXINT_MDECOUTDMA); \
|
||||
psxRegs.intCycle[PSXINT_MDECOUTDMA].cycle = eCycle; \
|
||||
psxRegs.intCycle[PSXINT_MDECOUTDMA].sCycle = psxRegs.cycle; \
|
||||
}
|
||||
|
||||
void psxDma2(u32 madr, u32 bcr, u32 chcr);
|
||||
|
|
|
@ -115,39 +115,39 @@ void psxBranchTest() {
|
|||
psxRcntUpdate();
|
||||
|
||||
if (psxRegs.interrupt) {
|
||||
if ((psxRegs.interrupt & 0x80) && !Config.Sio) { // sio
|
||||
if ((psxRegs.cycle - psxRegs.intCycle[7]) >= psxRegs.intCycle[7 + 1]) {
|
||||
psxRegs.interrupt &= ~0x80;
|
||||
if ((psxRegs.interrupt & (1 << PSXINT_SIO)) && !Config.Sio) { // sio
|
||||
if ((psxRegs.cycle - psxRegs.intCycle[PSXINT_SIO].sCycle) >= psxRegs.intCycle[PSXINT_SIO].cycle) {
|
||||
psxRegs.interrupt &= ~(1 << PSXINT_SIO);
|
||||
sioInterrupt();
|
||||
}
|
||||
}
|
||||
if (psxRegs.interrupt & 0x04) { // cdr
|
||||
if ((psxRegs.cycle - psxRegs.intCycle[2]) >= psxRegs.intCycle[2 + 1]) {
|
||||
psxRegs.interrupt &= ~0x04;
|
||||
if (psxRegs.interrupt & (1 << PSXINT_CDR)) { // cdr
|
||||
if ((psxRegs.cycle - psxRegs.intCycle[PSXINT_CDR].sCycle) >= psxRegs.intCycle[PSXINT_CDR].cycle) {
|
||||
psxRegs.interrupt &= ~(1 << PSXINT_CDR);
|
||||
cdrInterrupt();
|
||||
}
|
||||
}
|
||||
if (psxRegs.interrupt & 0x040000) { // cdr read
|
||||
if ((psxRegs.cycle - psxRegs.intCycle[2 + 16]) >= psxRegs.intCycle[2 + 16 + 1]) {
|
||||
psxRegs.interrupt &= ~0x040000;
|
||||
if (psxRegs.interrupt & (1 << PSXINT_CDREAD)) { // cdr read
|
||||
if ((psxRegs.cycle - psxRegs.intCycle[PSXINT_CDREAD].sCycle) >= psxRegs.intCycle[PSXINT_CDREAD].cycle) {
|
||||
psxRegs.interrupt &= ~(1 << PSXINT_CDREAD);
|
||||
cdrReadInterrupt();
|
||||
}
|
||||
}
|
||||
if (psxRegs.interrupt & 0x01000000) { // gpu dma
|
||||
if ((psxRegs.cycle - psxRegs.intCycle[3 + 24]) >= psxRegs.intCycle[3 + 24 + 1]) {
|
||||
psxRegs.interrupt &= ~0x01000000;
|
||||
if (psxRegs.interrupt & (1 << PSXINT_GPUDMA)) { // gpu dma
|
||||
if ((psxRegs.cycle - psxRegs.intCycle[PSXINT_GPUDMA].sCycle) >= psxRegs.intCycle[PSXINT_GPUDMA].cycle) {
|
||||
psxRegs.interrupt &= ~(1 << PSXINT_GPUDMA);
|
||||
gpuInterrupt();
|
||||
}
|
||||
}
|
||||
if (psxRegs.interrupt & 0x02000000) { // mdec out dma
|
||||
if ((psxRegs.cycle - psxRegs.intCycle[5 + 24]) >= psxRegs.intCycle[5 + 24 + 1]) {
|
||||
psxRegs.interrupt &= ~0x02000000;
|
||||
if (psxRegs.interrupt & (1 << PSXINT_MDECOUTDMA)) { // mdec out dma
|
||||
if ((psxRegs.cycle - psxRegs.intCycle[PSXINT_MDECOUTDMA].sCycle) >= psxRegs.intCycle[PSXINT_MDECOUTDMA].cycle) {
|
||||
psxRegs.interrupt &= ~(1 << PSXINT_MDECOUTDMA);
|
||||
mdec1Interrupt();
|
||||
}
|
||||
}
|
||||
if (psxRegs.interrupt & 0x04000000) { // spu dma
|
||||
if ((psxRegs.cycle - psxRegs.intCycle[1 + 24]) >= psxRegs.intCycle[1 + 24 + 1]) {
|
||||
psxRegs.interrupt &= ~0x04000000;
|
||||
if (psxRegs.interrupt & (1 << PSXINT_SPUDMA)) { // spu dma
|
||||
if ((psxRegs.cycle - psxRegs.intCycle[PSXINT_SPUDMA].sCycle) >= psxRegs.intCycle[PSXINT_SPUDMA].cycle) {
|
||||
psxRegs.interrupt &= ~(1 << PSXINT_SPUDMA);
|
||||
spuInterrupt();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -145,6 +145,15 @@ typedef union {
|
|||
PAIR p[32];
|
||||
} psxCP2Ctrl;
|
||||
|
||||
enum {
|
||||
PSXINT_SIO = 0,
|
||||
PSXINT_CDR,
|
||||
PSXINT_CDREAD,
|
||||
PSXINT_GPUDMA,
|
||||
PSXINT_MDECOUTDMA,
|
||||
PSXINT_SPUDMA
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
psxGPRRegs GPR; /* General Purpose Registers */
|
||||
psxCP0Regs CP0; /* Coprocessor0 Registers */
|
||||
|
@ -154,7 +163,7 @@ typedef struct {
|
|||
u32 code; /* The instruction */
|
||||
u32 cycle;
|
||||
u32 interrupt;
|
||||
u32 intCycle[32];
|
||||
struct { u32 sCycle, cycle; } intCycle[32];
|
||||
} psxRegisters;
|
||||
|
||||
extern psxRegisters psxRegs;
|
||||
|
|
|
@ -65,23 +65,25 @@ static unsigned int padst;
|
|||
|
||||
char Mcd1Data[MCD_SIZE], Mcd2Data[MCD_SIZE];
|
||||
|
||||
#define SIO_INT(eCycle) { \
|
||||
if (!Config.Sio) { \
|
||||
psxRegs.interrupt |= (1 << PSXINT_SIO); \
|
||||
psxRegs.intCycle[PSXINT_SIO].cycle = eCycle; \
|
||||
psxRegs.intCycle[PSXINT_SIO].sCycle = psxRegs.cycle; \
|
||||
} \
|
||||
}
|
||||
|
||||
// clk cycle byte
|
||||
// 4us * 8bits = (PSXCLK / 1000000) * 32; (linuzappz)
|
||||
// TODO: add SioModePrescaler and BaudReg
|
||||
static inline void SIO_INT() {
|
||||
if (!Config.Sio) {
|
||||
psxRegs.interrupt |= 0x80;
|
||||
psxRegs.intCycle[7 + 1] = 400;
|
||||
psxRegs.intCycle[7] = psxRegs.cycle;
|
||||
}
|
||||
}
|
||||
#define SIO_CYCLES 535
|
||||
|
||||
void sioWrite8(unsigned char value) {
|
||||
#ifdef PAD_LOG
|
||||
PAD_LOG("sio write8 %x\n", value);
|
||||
#endif
|
||||
switch (padst) {
|
||||
case 1: SIO_INT();
|
||||
case 1: SIO_INT(SIO_CYCLES);
|
||||
if ((value & 0x40) == 0x40) {
|
||||
padst = 2; parp = 1;
|
||||
if (!Config.UseNet) {
|
||||
|
@ -119,7 +121,7 @@ void sioWrite8(unsigned char value) {
|
|||
parp++;
|
||||
/* if (buf[1] == 0x45) {
|
||||
buf[parp] = 0;
|
||||
SIO_INT();
|
||||
SIO_INT(SIO_CYCLES);
|
||||
return;
|
||||
}*/
|
||||
if (!Config.UseNet) {
|
||||
|
@ -130,13 +132,13 @@ void sioWrite8(unsigned char value) {
|
|||
}
|
||||
|
||||
if (parp == bufcount) { padst = 0; return; }
|
||||
SIO_INT();
|
||||
SIO_INT(SIO_CYCLES);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (mcdst) {
|
||||
case 1:
|
||||
SIO_INT();
|
||||
SIO_INT(SIO_CYCLES);
|
||||
if (rdwr) { parp++; return; }
|
||||
parp = 1;
|
||||
switch (value) {
|
||||
|
@ -146,7 +148,7 @@ void sioWrite8(unsigned char value) {
|
|||
}
|
||||
return;
|
||||
case 2: // address H
|
||||
SIO_INT();
|
||||
SIO_INT(SIO_CYCLES);
|
||||
adrH = value;
|
||||
*buf = 0;
|
||||
parp = 0;
|
||||
|
@ -154,7 +156,7 @@ void sioWrite8(unsigned char value) {
|
|||
mcdst = 3;
|
||||
return;
|
||||
case 3: // address L
|
||||
SIO_INT();
|
||||
SIO_INT(SIO_CYCLES);
|
||||
adrL = value;
|
||||
*buf = adrH;
|
||||
parp = 0;
|
||||
|
@ -162,7 +164,7 @@ void sioWrite8(unsigned char value) {
|
|||
mcdst = 4;
|
||||
return;
|
||||
case 4:
|
||||
SIO_INT();
|
||||
SIO_INT(SIO_CYCLES);
|
||||
parp = 0;
|
||||
switch (rdwr) {
|
||||
case 1: // read
|
||||
|
@ -204,7 +206,7 @@ void sioWrite8(unsigned char value) {
|
|||
if (rdwr == 2) {
|
||||
if (parp < 128) buf[parp + 1] = value;
|
||||
}
|
||||
SIO_INT();
|
||||
SIO_INT(SIO_CYCLES);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -252,7 +254,7 @@ void sioWrite8(unsigned char value) {
|
|||
bufcount = 2;
|
||||
parp = 0;
|
||||
padst = 1;
|
||||
SIO_INT();
|
||||
SIO_INT(SIO_CYCLES);
|
||||
return;
|
||||
case 0x81: // start memcard
|
||||
StatReg |= RX_RDY;
|
||||
|
@ -261,7 +263,7 @@ void sioWrite8(unsigned char value) {
|
|||
bufcount = 3;
|
||||
mcdst = 1;
|
||||
rdwr = 0;
|
||||
SIO_INT();
|
||||
SIO_INT(SIO_CYCLES);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -279,7 +281,7 @@ void sioWriteCtrl16(unsigned short value) {
|
|||
if ((CtrlReg & SIO_RESET) || (!CtrlReg)) {
|
||||
padst = 0; mcdst = 0; parp = 0;
|
||||
StatReg = TX_RDY | TX_EMPTY;
|
||||
psxRegs.interrupt &= ~0x80;
|
||||
psxRegs.interrupt &= ~(1 << PSXINT_SIO);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -94,11 +94,11 @@
|
|||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>PCSX-Reloaded 1.9.91</string>
|
||||
<string>PCSX-Reloaded SVN</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>Pcsx</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1.9.91</string>
|
||||
<string>SVN</string>
|
||||
<key>NSMainNibFile</key>
|
||||
<string>PCSX.nib</string>
|
||||
<key>NSPrincipalClass</key>
|
||||
|
|
|
@ -8,7 +8,7 @@ msgstr ""
|
|||
"Project-Id-Version: pcsxr 1.0\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2010-07-10 14:04+0800\n"
|
||||
"PO-Revision-Date: 2010-07-10 14:06+0700\n"
|
||||
"PO-Revision-Date: 2010-08-07 22:16+0700\n"
|
||||
"Last-Translator: Wei Mingzhi <whistler@openoffice.org>\n"
|
||||
"Language-Team: Traditional Chinese <whistler@openoffice.org>\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
|
@ -3087,8 +3087,8 @@ msgid ""
|
|||
"Digital Pad\n"
|
||||
"Analog Pad"
|
||||
msgstr ""
|
||||
"數字手把\n"
|
||||
"模擬手把"
|
||||
"普通手把\n"
|
||||
"類比手把"
|
||||
|
||||
#: ../plugins/dfinput/dfinput.glade2:149
|
||||
#: ../plugins/dfinput/dfinput.glade2:346
|
||||
|
@ -3187,3 +3187,4 @@ msgstr "離線遊戲"
|
|||
#: ../plugins/bladesio1/sio1.c:29
|
||||
msgid "Sio1 Driver"
|
||||
msgstr "Sio1 驅動程式"
|
||||
|
||||
|
|
Loading…
Reference in New Issue