some gambatte trunk stuff
This commit is contained in:
parent
17ce177e5f
commit
1f0c994b46
|
@ -460,12 +460,13 @@ void CPU::loadState(const SaveState &state) {
|
||||||
PC_MOD((PC + jr_disp_var_tmp) & 0xFFFF); \
|
PC_MOD((PC + jr_disp_var_tmp) & 0xFFFF); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
//CALLS, RESTARTS AND RETURNS:
|
// CALLS, RESTARTS AND RETURNS:
|
||||||
//call nn (24 cycles):
|
// call nn (24 cycles):
|
||||||
//Push address of next instruction onto stack and then jump to address stored in next two bytes in memory:
|
// Jump to 16-bit immediate operand and push return address onto stack:
|
||||||
#define call_nn() do { \
|
#define call_nn() do { \
|
||||||
PUSH(((PC + 2) >> 8) & 0xFF, (PC + 2) & 0xFF); \
|
unsigned const npc = (PC + 2) & 0xFFFF; \
|
||||||
jp_nn(); \
|
jp_nn(); \
|
||||||
|
PUSH(npc >> 8, npc & 0xFF); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
//rst n (16 Cycles):
|
//rst n (16 Cycles):
|
||||||
|
@ -487,7 +488,8 @@ void CPU::loadState(const SaveState &state) {
|
||||||
|
|
||||||
void CPU::process(const unsigned long cycles) {
|
void CPU::process(const unsigned long cycles) {
|
||||||
memory.setEndtime(cycleCounter_, cycles);
|
memory.setEndtime(cycleCounter_, cycles);
|
||||||
|
memory.updateInput();
|
||||||
|
|
||||||
//unsigned char A = A_;
|
//unsigned char A = A_;
|
||||||
unsigned long cycleCounter = cycleCounter_;
|
unsigned long cycleCounter = cycleCounter_;
|
||||||
|
|
||||||
|
|
|
@ -291,7 +291,7 @@ unsigned long Memory::stop(unsigned long cycleCounter) {
|
||||||
sound.generate_samples(cycleCounter, isDoubleSpeed());
|
sound.generate_samples(cycleCounter, isDoubleSpeed());
|
||||||
|
|
||||||
display.speedChange(cycleCounter);
|
display.speedChange(cycleCounter);
|
||||||
ioamhram[0x14D] = ~ioamhram[0x14D] & 0x80;
|
ioamhram[0x14D] ^= 0x81;
|
||||||
|
|
||||||
intreq.setEventTime<BLIT>((ioamhram[0x140] & 0x80) ? display.nextMode1IrqTime() : cycleCounter + (70224 << isDoubleSpeed()));
|
intreq.setEventTime<BLIT>((ioamhram[0x140] & 0x80) ? display.nextMode1IrqTime() : cycleCounter + (70224 << isDoubleSpeed()));
|
||||||
|
|
||||||
|
@ -355,22 +355,22 @@ unsigned long Memory::resetCounters(unsigned long cycleCounter) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Memory::updateInput() {
|
void Memory::updateInput() {
|
||||||
unsigned button = 0xFF;
|
unsigned state = 0xF;
|
||||||
unsigned dpad = 0xFF;
|
|
||||||
|
if ((ioamhram[0x100] & 0x30) != 0x30 && getInput) {
|
||||||
if (getInput) {
|
unsigned input = (*getInput)();
|
||||||
const unsigned is = (*getInput)();
|
unsigned dpad_state = ~input >> 4;
|
||||||
button ^= is & 0x0F;
|
unsigned button_state = ~input;
|
||||||
dpad ^= is >> 4 & 0x0F;
|
if (!(ioamhram[0x100] & 0x10))
|
||||||
}
|
state &= dpad_state;
|
||||||
|
if (!(ioamhram[0x100] & 0x20))
|
||||||
ioamhram[0x100] |= 0xF;
|
state &= button_state;
|
||||||
|
}
|
||||||
if (!(ioamhram[0x100] & 0x10))
|
|
||||||
ioamhram[0x100] &= dpad;
|
if (state != 0xF && (ioamhram[0x100] & 0xF) == 0xF)
|
||||||
|
intreq.flagIrq(0x10);
|
||||||
if (!(ioamhram[0x100] & 0x20))
|
|
||||||
ioamhram[0x100] &= button;
|
ioamhram[0x100] = (ioamhram[0x100] & -0x10u) | state;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Memory::updateOamDma(const unsigned long cycleCounter) {
|
void Memory::updateOamDma(const unsigned long cycleCounter) {
|
||||||
|
@ -594,9 +594,12 @@ void Memory::nontrivial_ff_write(const unsigned P, unsigned data, const unsigned
|
||||||
updateOamDma(cycleCounter);
|
updateOamDma(cycleCounter);
|
||||||
|
|
||||||
switch (P & 0xFF) {
|
switch (P & 0xFF) {
|
||||||
case 0x00:
|
case 0x00:
|
||||||
data = (ioamhram[0x100] & 0xCF) | (data & 0xF0);
|
if ((data ^ ioamhram[0x100]) & 0x30) {
|
||||||
break;
|
ioamhram[0x100] = (ioamhram[0x100] & ~0x30u) | (data & 0x30);
|
||||||
|
updateInput();
|
||||||
|
}
|
||||||
|
return;
|
||||||
case 0x01:
|
case 0x01:
|
||||||
updateSerial(cycleCounter);
|
updateSerial(cycleCounter);
|
||||||
break;
|
break;
|
||||||
|
@ -856,8 +859,8 @@ void Memory::nontrivial_ff_write(const unsigned P, unsigned data, const unsigned
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x4D:
|
case 0x4D:
|
||||||
ioamhram[0x14D] |= data & 0x01;
|
if (isCgb())
|
||||||
return;
|
ioamhram[0x14D] = (ioamhram[0x14D] & ~1u) | (data & 1); return;
|
||||||
case 0x4F:
|
case 0x4F:
|
||||||
if (isCgb()) {
|
if (isCgb()) {
|
||||||
cart.setVrambank(data & 1);
|
cart.setVrambank(data & 1);
|
||||||
|
|
|
@ -57,7 +57,6 @@ class Memory {
|
||||||
bool LINKCABLE;
|
bool LINKCABLE;
|
||||||
bool linkClockTrigger;
|
bool linkClockTrigger;
|
||||||
|
|
||||||
void updateInput();
|
|
||||||
void decEventCycles(MemEventId eventId, unsigned long dec);
|
void decEventCycles(MemEventId eventId, unsigned long dec);
|
||||||
|
|
||||||
void oamDmaInitSetup();
|
void oamDmaInitSetup();
|
||||||
|
@ -91,7 +90,8 @@ public:
|
||||||
void loadSavedata(const char *data) { cart.loadSavedata(data); }
|
void loadSavedata(const char *data) { cart.loadSavedata(data); }
|
||||||
int saveSavedataLength() {return cart.saveSavedataLength(); }
|
int saveSavedataLength() {return cart.saveSavedataLength(); }
|
||||||
void saveSavedata(char *dest) { cart.saveSavedata(dest); }
|
void saveSavedata(char *dest) { cart.saveSavedata(dest); }
|
||||||
|
void updateInput();
|
||||||
|
|
||||||
bool getMemoryArea(int which, unsigned char **data, int *length); // { return cart.getMemoryArea(which, data, length); }
|
bool getMemoryArea(int which, unsigned char **data, int *length); // { return cart.getMemoryArea(which, data, length); }
|
||||||
|
|
||||||
unsigned long stop(unsigned long cycleCounter);
|
unsigned long stop(unsigned long cycleCounter);
|
||||||
|
|
Binary file not shown.
Loading…
Reference in New Issue