libgambatte: shave off an instruction or two on ff loads/stores
gcc arm/x86.
This commit is contained in:
parent
869d8fa3bf
commit
f79044ee79
@ -995,8 +995,8 @@ void CPU::process(unsigned long const cycles) {
|
|||||||
// halt (4 cycles):
|
// halt (4 cycles):
|
||||||
case 0x76:
|
case 0x76:
|
||||||
if (!mem_.ime()
|
if (!mem_.ime()
|
||||||
&& ( mem_.ff_read(0xFF0F, cycleCounter)
|
&& ( mem_.ff_read(0x0F, cycleCounter)
|
||||||
& mem_.ff_read(0xFFFF, cycleCounter) & 0x1F)) {
|
& mem_.ff_read(0xFF, cycleCounter) & 0x1F)) {
|
||||||
if (mem_.isCgb())
|
if (mem_.isCgb())
|
||||||
cycleCounter += 4;
|
cycleCounter += 4;
|
||||||
else
|
else
|
||||||
@ -1779,7 +1779,7 @@ void CPU::process(unsigned long const cycles) {
|
|||||||
{
|
{
|
||||||
unsigned imm;
|
unsigned imm;
|
||||||
PC_READ(imm);
|
PC_READ(imm);
|
||||||
FF_WRITE(0xFF00 | imm, a);
|
FF_WRITE(imm, a);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -1791,7 +1791,7 @@ void CPU::process(unsigned long const cycles) {
|
|||||||
// ld ($FF00+C),a (8 ycles):
|
// ld ($FF00+C),a (8 ycles):
|
||||||
// Put A into address (0xFF00 + register C):
|
// Put A into address (0xFF00 + register C):
|
||||||
case 0xE2:
|
case 0xE2:
|
||||||
FF_WRITE(0xFF00 | c, a);
|
FF_WRITE(c, a);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0xE3: // not specified. should freeze.
|
case 0xE3: // not specified. should freeze.
|
||||||
@ -1868,7 +1868,7 @@ void CPU::process(unsigned long const cycles) {
|
|||||||
{
|
{
|
||||||
unsigned imm;
|
unsigned imm;
|
||||||
PC_READ(imm);
|
PC_READ(imm);
|
||||||
FF_READ(a, 0xFF00 | imm);
|
FF_READ(a, imm);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -1887,7 +1887,7 @@ void CPU::process(unsigned long const cycles) {
|
|||||||
// ld a,($FF00+C) (8 cycles):
|
// ld a,($FF00+C) (8 cycles):
|
||||||
// Put value at address (0xFF00 + register C) into A:
|
// Put value at address (0xFF00 + register C) into A:
|
||||||
case 0xF2:
|
case 0xF2:
|
||||||
FF_READ(a, 0xFF00 | c);
|
FF_READ(a, c);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// di (4 cycles):
|
// di (4 cycles):
|
||||||
|
@ -51,9 +51,9 @@ void Memory::setStatePtrs(SaveState &state) {
|
|||||||
|
|
||||||
unsigned long Memory::saveState(SaveState &state, unsigned long cc) {
|
unsigned long Memory::saveState(SaveState &state, unsigned long cc) {
|
||||||
cc = resetCounters(cc);
|
cc = resetCounters(cc);
|
||||||
nontrivial_ff_read(0xFF05, cc);
|
nontrivial_ff_read(0x05, cc);
|
||||||
nontrivial_ff_read(0xFF0F, cc);
|
nontrivial_ff_read(0x0F, cc);
|
||||||
nontrivial_ff_read(0xFF26, cc);
|
nontrivial_ff_read(0x26, cc);
|
||||||
|
|
||||||
state.mem.divLastUpdate = divLastUpdate_;
|
state.mem.divLastUpdate = divLastUpdate_;
|
||||||
state.mem.nextSerialtime = intreq_.eventTime(intevent_serial);
|
state.mem.nextSerialtime = intreq_.eventTime(intevent_serial);
|
||||||
@ -455,7 +455,7 @@ unsigned Memory::nontrivial_ff_read(unsigned const p, unsigned long const cc) {
|
|||||||
if (lastOamDmaUpdate_ != disabled_time)
|
if (lastOamDmaUpdate_ != disabled_time)
|
||||||
updateOamDma(cc);
|
updateOamDma(cc);
|
||||||
|
|
||||||
switch (p & 0x7F) {
|
switch (p) {
|
||||||
case 0x00:
|
case 0x00:
|
||||||
updateInput();
|
updateInput();
|
||||||
break;
|
break;
|
||||||
@ -516,7 +516,7 @@ unsigned Memory::nontrivial_ff_read(unsigned const p, unsigned long const cc) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ioamhram_[p - 0xFE00];
|
return ioamhram_[p + 0x100];
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool isInOamDmaConflictArea(OamDmaSrc const oamDmaSrc, unsigned const p, bool const cgb) {
|
static bool isInOamDmaConflictArea(OamDmaSrc const oamDmaSrc, unsigned const p, bool const cgb) {
|
||||||
@ -574,8 +574,9 @@ unsigned Memory::nontrivial_read(unsigned const p, unsigned long const cc) {
|
|||||||
if (p < 0xFE00)
|
if (p < 0xFE00)
|
||||||
return cart_.wramdata(p >> 12 & 1)[p & 0xFFF];
|
return cart_.wramdata(p >> 12 & 1)[p & 0xFFF];
|
||||||
|
|
||||||
if (p >= 0xFF00)
|
long const ffp = long(p) - 0xFF00;
|
||||||
return nontrivial_ff_read(p, cc);
|
if (ffp >= 0)
|
||||||
|
return nontrivial_ff_read(ffp, cc);
|
||||||
|
|
||||||
if (!lcd_.oamReadable(cc) || oamDmaPos_ < 0xA0)
|
if (!lcd_.oamReadable(cc) || oamDmaPos_ < 0xA0)
|
||||||
return 0xFF;
|
return 0xFF;
|
||||||
@ -788,7 +789,7 @@ void Memory::nontrivial_ff_write(unsigned const p, unsigned data, unsigned long
|
|||||||
psg_.generateSamples(cc, isDoubleSpeed());
|
psg_.generateSamples(cc, isDoubleSpeed());
|
||||||
|
|
||||||
if (!(data & 0x80)) {
|
if (!(data & 0x80)) {
|
||||||
for (unsigned i = 0xFF10; i < 0xFF26; ++i)
|
for (unsigned i = 0x10; i < 0x26; ++i)
|
||||||
ff_write(i, 0, cc);
|
ff_write(i, 0, cc);
|
||||||
|
|
||||||
psg_.setEnabled(false);
|
psg_.setEnabled(false);
|
||||||
@ -1001,7 +1002,7 @@ void Memory::nontrivial_ff_write(unsigned const p, unsigned data, unsigned long
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ioamhram_[p - 0xFE00] = data;
|
ioamhram_[p + 0x100] = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Memory::nontrivial_write(unsigned const p, unsigned const data, unsigned long const cc) {
|
void Memory::nontrivial_write(unsigned const p, unsigned const data, unsigned long const cc) {
|
||||||
@ -1030,13 +1031,14 @@ void Memory::nontrivial_write(unsigned const p, unsigned const data, unsigned lo
|
|||||||
} else
|
} else
|
||||||
cart_.wramdata(p >> 12 & 1)[p & 0xFFF] = data;
|
cart_.wramdata(p >> 12 & 1)[p & 0xFFF] = data;
|
||||||
} else if (p - 0xFF80u >= 0x7Fu) {
|
} else if (p - 0xFF80u >= 0x7Fu) {
|
||||||
if (p < 0xFF00) {
|
long const ffp = long(p) - 0xFF00;
|
||||||
|
if (ffp < 0) {
|
||||||
if (lcd_.oamWritable(cc) && oamDmaPos_ >= 0xA0 && (p < 0xFEA0 || isCgb())) {
|
if (lcd_.oamWritable(cc) && oamDmaPos_ >= 0xA0 && (p < 0xFEA0 || isCgb())) {
|
||||||
lcd_.oamChange(cc);
|
lcd_.oamChange(cc);
|
||||||
ioamhram_[p - 0xFE00] = data;
|
ioamhram_[p - 0xFE00] = data;
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
nontrivial_ff_write(p, data, cc);
|
nontrivial_ff_write(ffp, data, cc);
|
||||||
} else
|
} else
|
||||||
ioamhram_[p - 0xFE00] = data;
|
ioamhram_[p - 0xFE00] = data;
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,7 @@ public:
|
|||||||
void di() { intreq_.di(); }
|
void di() { intreq_.di(); }
|
||||||
|
|
||||||
unsigned ff_read(unsigned p, unsigned long cc) {
|
unsigned ff_read(unsigned p, unsigned long cc) {
|
||||||
return p < 0xFF80 ? nontrivial_ff_read(p, cc) : ioamhram_[p - 0xFE00];
|
return p < 0x80 ? nontrivial_ff_read(p, cc) : ioamhram_[p + 0x100];
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned read(unsigned p, unsigned long cc) {
|
unsigned read(unsigned p, unsigned long cc) {
|
||||||
@ -82,8 +82,8 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ff_write(unsigned p, unsigned data, unsigned long cc) {
|
void ff_write(unsigned p, unsigned data, unsigned long cc) {
|
||||||
if (p - 0xFF80u < 0x7Fu) {
|
if (p - 0x80u < 0x7Fu) {
|
||||||
ioamhram_[p - 0xFE00] = data;
|
ioamhram_[p + 0x100] = data;
|
||||||
} else
|
} else
|
||||||
nontrivial_ff_write(p, data, cc);
|
nontrivial_ff_write(p, data, cc);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user