auto R65816::op_jsr_addr() { aa.l = readPC(); aa.h = readPC(); idle(); r.pc.w--; writeSP(r.pc.h); L writeSP(r.pc.l); r.pc.w = aa.w; }
int runCPUCycle(){ //Both used in DAA char correction; char beforeA; unsigned short beforeHL; char temp; opcodeInstruction instruction; unsigned char currentInterrupts; if(delayCyclesLeft!=0){ delayCyclesLeft--; return 0; } //Check for Interrupts if(IME == 1){ currentInterrupts = (*interruptFlags)&interruptER; if(currentInterrupts&INT_VBLANK){ writeSP(getSP()-2); writeShortToMem(getSP(),getPC()); writePC(0x40); IME = 0; *interruptFlags = (*interruptFlags)& ~(INT_VBLANK); } else if(currentInterrupts&INT_LCD){ writeSP(getSP()-2); writeShortToMem(getSP(),getPC()); writePC(0x48); IME = 0; *interruptFlags = (*interruptFlags)& ~(INT_LCD); } else if(currentInterrupts&INT_TIMER){ writeSP(getSP()-2); writeShortToMem(getSP(),getPC()); writePC(0x50); IME = 0; *interruptFlags = (*interruptFlags)& ~(INT_TIMER); } else if(currentInterrupts&INT_SERIAL){ writeSP(getSP()-2); writeShortToMem(getSP(),getPC()); writePC(0x58); IME = 0; *interruptFlags = (*interruptFlags)& ~(INT_SERIAL); } else if(currentInterrupts&INT_JOYPAD){ writeSP(getSP()-2); writeShortToMem(getSP(),getPC()); writePC(0x60); IME = 0; *interruptFlags = (*interruptFlags)& ~(INT_JOYPAD); } } delayCyclesLeft = instructionClockCycles[readCharFromMem(getPC())]; //Will be overwritten is instruction is CB if(delayCyclesLeft == -1){ delayCyclesLeft = 20; //My not need any actual implementation } //Add the instruction to the list of called instructions PCRecallAdd(PCRecallHead,getPC()); //Get the instruction from the jump table if((readCharFromMem(getPC())&0xFF)==0xCB){ instruction = opcodes[readCharFromMem(getPC()+1)+0x100]; writePC(getPC()+1); incrementInstructionCount(readCharFromMem(getPC())+0x100); delayCyclesLeft = CBInstructionClockCycles[readCharFromMem(getPC())]; //printf("Using CB instruction at PC: %hX\n",getPC()); } else { if((readCharFromMem(getPC())&0xFF)==0x10){ return 0x10; } //printf("Instruction Index: %hhX PC: %hX\n",readCharFromMem(getPC()),getPC()); incrementInstructionCount(readCharFromMem(getPC())); instruction = opcodes[readCharFromMem(getPC())]; } //Call the instruction if(instruction!=0){ instruction(); } else { printf("Unknown Instruction: %hhX at PC: %hhX\n",readCharFromMem(getPC()),getPC()); return 0x10; //Stop writePC(getPC()+1); } return 0; }
auto R65816::op_sta_sr_w() { sp = readPC(); idle(); writeSP(sp + 0, r.a.l); L writeSP(sp + 1, r.a.h); }
uint32_t DebugProtocolWriter::writeBinary( const std::unique_ptr<folly::IOBuf>& str) { writeSP(folly::StringPiece(str->clone()->coalesce())); return 0; }
auto R65816::op_sta_sr_b() { sp = readPC(); idle(); L writeSP(sp, r.a.l); }