void LLDBConnector::Detach() { if(IsCanInteract()) { CL_DEBUG("Sending 'Detach' command"); LLDBCommand command; command.SetCommandType(kCommandDetach); SendCommand(command); } else { Interrupt(kInterruptReasonDetaching); } }
void BehaviorSet::ClearState(NPC *npc) { // Ensure any existing script is ended correctly. Interrupt(npc); for (size_t i = 0; i<behaviors.GetSize(); i++) { behaviors[i]->ResetNeed(); behaviors[i]->SetIsActive(false); behaviors[i]->ClearInterrupted(); } active = NULL; }
void ActionInfo::Reset(UnitStateMgr* mgr) { if (!HasFlag(ACTION_STATE_INITIALIZED)) return; if (!HasFlag(ACTION_STATE_INTERRUPTED) && HasFlag(ACTION_STATE_ACTIVE)) Interrupt(mgr); RemoveFlag(ACTION_STATE_INITIALIZED); DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "ActionInfo: %s reset action %s", mgr->GetOwnerStr().c_str(), TypeName()); }
void CBSPLightingThread::StartLighting( char const *pVMFFileWithEntities ) { // First, kill any lighting going on. Interrupt(); // Store the VMF file data for the thread. int len = strlen( pVMFFileWithEntities ) + 1; m_VMFFileWithEntities.CopyArray( pVMFFileWithEntities, len ); // Tell the thread to start lighting. SetThreadState( STATE_LIGHTING ); SetThreadCmd( THREADCMD_LIGHT ); }
bool Connection::Open(const char *filename, int open_flags) { Interrupt(); Close(); if (nullptr == filename) { return false; } int rc = sqlite3_open_v2(filename, &db_, open_flags, nullptr); if (SQLITE_OK != rc) { Close(); } return SQLITE_OK == rc; }
// Primary entrypoint from the set of "debugger hooks", which the VM calls in // response to various events. While this function is quite general wrt. the // type of interrupt, practically the type will be one of the following: // - ExceptionThrown // - ExceptionHandler // - BreakPointReached // - HardBreakPoint // // Note: it is indeed a bit odd that interrupts due to single stepping come in // as "BreakPointReached". Currently this results in spurious work in the // debugger. void Debugger::InterruptVMHook(int type /* = BreakPointReached */, CVarRef e /* = null_variant */) { TRACE(2, "Debugger::InterruptVMHook\n"); // Computing the interrupt site here pulls in more data from the Unit to // describe the current execution point. InterruptSite site(type == HardBreakPoint, e); if (!site.valid()) { // An invalid site is missing something like an ActRec, a func, or a // Unit. Currently the debugger has no action to take at such sites. return; } Interrupt(type, nullptr, &site); }
bool RandomCircleMovementGenerator<Creature>::Update(Creature &creature, const uint32 &diff) { if (creature.hasUnitState(UNIT_STAT_NOT_MOVE | UNIT_STAT_ON_VEHICLE)) { i_nextMoveTime.Update(i_nextMoveTime.GetExpiry()); // Expire the timer creature.clearUnitState(UNIT_STAT_ROAMING_MOVE); return true; } i_nextMoveTime.Update(diff); if (!creature.IsStopped() && !creature.canFly()) creature.clearUnitState(UNIT_STAT_ROAMING_MOVE); if (creature.IsStopped()) creature.addUnitState(UNIT_STAT_ROAMING_MOVE); if (!IsActive(creature)) // force stop processing (movement can move out active zone with cleanup movegens list) { Interrupt(creature); return true; } if (m_splineMap.empty()) { Reset(creature); return true; } if (i_nextMoveTime.Passed()) { if (m_splineMap.find(i_wpId) == m_splineMap.end()) { Reset(creature); return true; } SplineWayPointMap::iterator wp = m_splineMap.find(i_wpId); //rellocate but not send creature.Relocate(wp->second->x, wp->second->y, wp->second->z, wp->second->o); if (i_wpId == 29) // not last wp { Initialize(creature); return true; } i_wpId++; i_nextMoveTime.Reset(500); } return true; }
void WaitForShutdown(boost::thread_group* threadGroup) { bool fShutdown = ShutdownRequested(); // Tell the main threads to shutdown. while (!fShutdown) { MilliSleep(200); fShutdown = ShutdownRequested(); } if (threadGroup) { Interrupt(*threadGroup); threadGroup->join_all(); } }
void ProcessInterruptTerminateHandler::InterruptProcess(PROCESS_INFORMATION& info) { //block from second call if (IsInterrupted()) return; LOG.LogInfo(L"Service process will be killed, exit code would be 42"); //TODO:implement kill process if (0 == TerminateProcess(info.hProcess, 42)) { LOG.LogWarnFormat(L"Failed to terminate service process. %s", LOG.GetLastError()); return; } //mark interrupt to the process was sent Interrupt(); }
// Try to take the latched interrupt static inline void TryInt() { int nDid; if (Doze.nInterruptLatch & DOZE_IRQSTATUS_NONE) { return; } nDid = Interrupt(Doze.nInterruptLatch & 0xFF); // Success! we did some cycles, and took the interrupt if (nDid > 0 && (Doze.nInterruptLatch & DOZE_IRQSTATUS_AUTO)) { Doze.nInterruptLatch = DOZE_IRQSTATUS_NONE; } Doze.nCyclesLeft -= nDid; }
void LLDBConnector::DeleteBreakpoints() { if ( IsCanInteract() ) { CL_DEBUGS(wxString () << "codelite: deleting breakpoints (total of " << m_pendingDeletionBreakpoints.size() << " breakpoints)"); LLDBCommand command; command.SetCommandType( kCommandDeleteBreakpoint ); command.SetBreakpoints( m_pendingDeletionBreakpoints ); SendCommand( command ); CL_DEBUGS(wxString () << "codelite: DeleteBreakpoints celar pending deletionbreakpoints queue"); m_pendingDeletionBreakpoints.clear(); } else { CL_DEBUG("codelite: interrupting codelite-lldb for kInterruptReasonDeleteBreakpoint"); Interrupt( kInterruptReasonDeleteBreakpoint ); } }
void ChaseMovementGenerator<T>::Finalize(T &owner) { Interrupt(owner); if (Creature* creature = owner.ToCreature()) { if (creature->IsAIEnabled) creature->AI()->MovementInform(CHASE_MOTION_TYPE, 0); if (creature->isPet()) return; if (!creature->isInCombat()) creature->GetMotionMaster()->MoveTargetedHome(); } }
void LLDBConnector::ApplyBreakpoints() { if(!m_breakpoints.empty()) { if(IsCanInteract()) { LLDBCommand command; command.SetCommandType(kCommandApplyBreakpoints); command.SetBreakpoints(GetUnappliedBreakpoints()); SendCommand(command); m_breakpoints.clear(); } else { Interrupt(kInterruptReasonApplyBreakpoints); } } }
void DataContainerImpl::getRecycleAccess(Recycler*const recycler) { if(! recycler) throw WrongArgument(); unique_lock_t lock(m_mutex); try { while(m_recycleAccess) m_cond.wait(lock); } catch(boost::thread_interrupted&) { throw Interrupt(); } m_recycleAccess = recycler; }
CBSPLightingThread::~CBSPLightingThread() { if( m_hThread ) { // Stop the current lighting process if one is going on. Interrupt(); // Tell the thread to exit. SetThreadCmd( THREADCMD_EXIT ); DWORD dwCode; while( 1 ) { if( GetExitCodeThread( m_hThread, &dwCode ) && dwCode == 0 ) break; Sleep( 10 ); } CloseHandle( m_hThread ); } DeleteCriticalSection( &m_CS ); }
void Debugger::InterruptSessionEnded(const char *file) { TRACE(2, "Debugger::InterruptSessionEnded\n"); Interrupt(SessionEnded, file); }
void Debugger::InterruptSessionStarted(const char *file, const char *error /* = NULL */) { TRACE(2, "Debugger::InterruptSessionStarted\n"); ThreadInfo::s_threadInfo->m_reqInjectionData.setDebugger(true); Interrupt(SessionStarted, file, nullptr, error); }
void FollowMovementGenerator<T>::Finalize(T &owner) { Interrupt(owner); }
/* 主要变例完全搜索例程,和零窗口完全搜索的区别有以下几点: * * 1. 启用内部迭代加深启发; * 2. 不使用有负面影响的裁剪; * 3. Alpha-Beta边界判定复杂; * 4. PV结点要获取主要变例; * 5. 考虑PV结点处理最佳着法的情况。 */ static int SearchPV(int vlAlpha, int vlBeta, int nDepth, uint16_t *lpwmvPvLine) { int nNewDepth, nHashFlag, vlBest, vl; int mvBest, mvHash, mv, mvEvade; MoveSortStruct MoveSort; uint16_t wmvPvLine[LIMIT_DEPTH]; // 完全搜索例程包括以下几个步骤: // 1. 在叶子结点处调用静态搜索; *lpwmvPvLine = 0; if (nDepth <= 0) { __ASSERT(nDepth >= -NULL_DEPTH); return SearchQuiesc(Search.pos, vlAlpha, vlBeta); } Search2.nAllNodes ++; // 2. 无害裁剪; vl = HarmlessPruning(Search.pos, vlBeta); if (vl > -MATE_VALUE) { return vl; } // 3. 置换裁剪; vl = ProbeHash(Search.pos, vlAlpha, vlBeta, nDepth, NO_NULL, mvHash); if (Search.bUseHash && vl > -MATE_VALUE) { // 由于PV结点不适用置换裁剪,所以不会发生PV路线中断的情况 return vl; } // 4. 达到极限深度,直接返回评价值; __ASSERT(Search.pos.nDistance > 0); if (Search.pos.nDistance == LIMIT_DEPTH) { return Evaluate(Search.pos, vlAlpha, vlBeta); } __ASSERT(Search.pos.nDistance < LIMIT_DEPTH); // 5. 中断调用; Search2.nMainNodes ++; vlBest = -MATE_VALUE; if ((Search2.nMainNodes & Search.nCountMask) == 0 && Interrupt()) { return vlBest; } // 6. 内部迭代加深启发; if (nDepth > IID_DEPTH && mvHash == 0) { __ASSERT(nDepth / 2 <= nDepth - IID_DEPTH); vl = SearchPV(vlAlpha, vlBeta, nDepth / 2, wmvPvLine); if (vl <= vlAlpha) { vl = SearchPV(-MATE_VALUE, vlBeta, nDepth / 2, wmvPvLine); } if (Search2.bStop) { return vlBest; } mvHash = wmvPvLine[0]; } // 7. 初始化; mvBest = 0; nHashFlag = HASH_ALPHA; if (Search.pos.LastMove().ChkChs > 0) { // 如果是将军局面,那么生成所有应将着法; mvEvade = MoveSort.InitEvade(Search.pos, mvHash, Search2.wmvKiller[Search.pos.nDistance]); } else { // 如果不是将军局面,那么使用正常的着法列表。 MoveSort.InitFull(Search.pos, mvHash, Search2.wmvKiller[Search.pos.nDistance]); mvEvade = 0; } // 8. 按照"MoveSortStruct::NextFull()"例程的着法顺序逐一搜索; while ((mv = MoveSort.NextFull(Search.pos)) != 0) { if (Search.pos.MakeMove(mv)) { // 9. 尝试选择性延伸; nNewDepth = (Search.pos.LastMove().ChkChs > 0 || mvEvade != 0 ? nDepth : nDepth - 1); // 10. 主要变例搜索; if (vlBest == -MATE_VALUE) { vl = -SearchPV(-vlBeta, -vlAlpha, nNewDepth, wmvPvLine); } else { vl = -SearchCut(-vlAlpha, nNewDepth); if (vl > vlAlpha && vl < vlBeta) { vl = -SearchPV(-vlBeta, -vlAlpha, nNewDepth, wmvPvLine); } } Search.pos.UndoMakeMove(); if (Search2.bStop) { return vlBest; } // 11. Alpha-Beta边界判定; if (vl > vlBest) { vlBest = vl; if (vl >= vlBeta) { mvBest = mv; nHashFlag = HASH_BETA; break; } if (vl > vlAlpha) { vlAlpha = vl; mvBest = mv; nHashFlag = HASH_PV; AppendPvLine(lpwmvPvLine, mv, wmvPvLine); } } } } // 12. 更新置换表、历史表和杀手着法表。 if (vlBest == -MATE_VALUE) { __ASSERT(Search.pos.IsMate()); return Search.pos.nDistance - MATE_VALUE; } else { RecordHash(Search.pos, nHashFlag, vlBest, nDepth, mvEvade == 0 ? mvBest : mvEvade); if (mvBest != 0 && !MoveSort.GoodCap(Search.pos, mvBest)) { SetBestMove(mvBest, nDepth, Search2.wmvKiller[Search.pos.nDistance]); } return vlBest; } }
// 零窗口完全搜索例程 static int SearchCut(int vlBeta, int nDepth, bool bNoNull = false) { int nNewDepth, vlBest, vl; int mvHash, mv, mvEvade; MoveSortStruct MoveSort; // 完全搜索例程包括以下几个步骤: // 1. 在叶子结点处调用静态搜索; if (nDepth <= 0) { __ASSERT(nDepth >= -NULL_DEPTH); return SearchQuiesc(Search.pos, vlBeta - 1, vlBeta); } Search2.nAllNodes ++; // 2. 无害裁剪; vl = HarmlessPruning(Search.pos, vlBeta); if (vl > -MATE_VALUE) { return vl; } // 3. 置换裁剪; vl = ProbeHash(Search.pos, vlBeta - 1, vlBeta, nDepth, bNoNull, mvHash); if (Search.bUseHash && vl > -MATE_VALUE) { return vl; } // 4. 达到极限深度,直接返回评价值; if (Search.pos.nDistance == LIMIT_DEPTH) { return Evaluate(Search.pos, vlBeta - 1, vlBeta); } __ASSERT(Search.pos.nDistance < LIMIT_DEPTH); // 5. 中断调用; Search2.nMainNodes ++; vlBest = -MATE_VALUE; if ((Search2.nMainNodes & Search.nCountMask) == 0 && Interrupt()) { return vlBest; } // 6. 尝试空着裁剪; if (Search.bNullMove && !bNoNull && Search.pos.LastMove().ChkChs <= 0 && Search.pos.NullOkay()) { Search.pos.NullMove(); vl = -SearchCut(1 - vlBeta, nDepth - NULL_DEPTH - 1, NO_NULL); Search.pos.UndoNullMove(); if (Search2.bStop) { return vlBest; } if (vl >= vlBeta) { if (Search.pos.NullSafe()) { // a. 如果空着裁剪不带检验,那么记录深度至少为(NULL_DEPTH + 1); RecordHash(Search.pos, HASH_BETA, vl, MAX(nDepth, NULL_DEPTH + 1), 0); return vl; } else if (SearchCut(vlBeta, nDepth - NULL_DEPTH, NO_NULL) >= vlBeta) { // b. 如果空着裁剪带检验,那么记录深度至少为(NULL_DEPTH); RecordHash(Search.pos, HASH_BETA, vl, MAX(nDepth, NULL_DEPTH), 0); return vl; } } } // 7. 初始化; if (Search.pos.LastMove().ChkChs > 0) { // 如果是将军局面,那么生成所有应将着法; mvEvade = MoveSort.InitEvade(Search.pos, mvHash, Search2.wmvKiller[Search.pos.nDistance]); } else { // 如果不是将军局面,那么使用正常的着法列表。 MoveSort.InitFull(Search.pos, mvHash, Search2.wmvKiller[Search.pos.nDistance]); mvEvade = 0; } // 8. 按照"MoveSortStruct::NextFull()"例程的着法顺序逐一搜索; while ((mv = MoveSort.NextFull(Search.pos)) != 0) { if (Search.pos.MakeMove(mv)) { // 9. 尝试选择性延伸; nNewDepth = (Search.pos.LastMove().ChkChs > 0 || mvEvade != 0 ? nDepth : nDepth - 1); // 10. 零窗口搜索; vl = -SearchCut(1 - vlBeta, nNewDepth); Search.pos.UndoMakeMove(); if (Search2.bStop) { return vlBest; } // 11. 截断判定; if (vl > vlBest) { vlBest = vl; if (vl >= vlBeta) { RecordHash(Search.pos, HASH_BETA, vlBest, nDepth, mv); if (!MoveSort.GoodCap(Search.pos, mv)) { SetBestMove(mv, nDepth, Search2.wmvKiller[Search.pos.nDistance]); } return vlBest; } } } } // 12. 不截断措施。 if (vlBest == -MATE_VALUE) { __ASSERT(Search.pos.IsMate()); return Search.pos.nDistance - MATE_VALUE; } else { RecordHash(Search.pos, HASH_ALPHA, vlBest, nDepth, mvEvade); return vlBest; } }
void Debugger::InterruptSessionStarted(const char *file, const char *error /* = NULL */) { TRACE(2, "Debugger::InterruptSessionStarted\n"); get().registerThread(); // Register this thread as being debugged Interrupt(SessionStarted, file, nullptr, error); }
/* Generate interrupts */ static void Interrupt(void) { /* the 6805 latches interrupt requests internally, so we don't clear */ /* pending_interrupts until the interrupt is taken, no matter what the */ /* external IRQ pin does. */ #if (1) //HAS_HD63705) if( (m6805.pending_interrupts & (1<<HD63705_INT_NMI)) != 0) { PUSHWORD(m6805.pc); PUSHBYTE(m6805.x); PUSHBYTE(m6805.a); PUSHBYTE(m6805.cc); SEI; /* no vectors supported, just do the callback to clear irq_state if needed */ if (m6805.irq_callback) (*m6805.irq_callback)(0); RM16( 0x1ffc, &pPC); change_pc(PC); m6805.pending_interrupts &= ~(1<<HD63705_INT_NMI); m6805_ICount -= 11; } else if( (m6805.pending_interrupts & ((1<<M6805_IRQ_LINE)|HD63705_INT_MASK)) != 0 ) { if ( (CC & IFLAG) == 0 ) { #else if( (m6805.pending_interrupts & (1<<M6805_IRQ_LINE)) != 0 ) { if ( (CC & IFLAG) == 0 ) { #endif { /* standard IRQ */ //#if (HAS_HD63705) // if(SUBTYPE!=SUBTYPE_HD63705) //#endif // PC |= ~AMASK; PUSHWORD(m6805.pc); PUSHBYTE(m6805.x); PUSHBYTE(m6805.a); PUSHBYTE(m6805.cc); SEI; /* no vectors supported, just do the callback to clear irq_state if needed */ if (m6805.irq_callback) (*m6805.irq_callback)(0); //#if (HAS_HD63705) if(SUBTYPE==SUBTYPE_HD63705) { /* Need to add emulation of other interrupt sources here KW-2/4/99 */ /* This is just a quick patch for Namco System 2 operation */ if((m6805.pending_interrupts&(1<<HD63705_INT_IRQ1))!=0) { m6805.pending_interrupts &= ~(1<<HD63705_INT_IRQ1); RM16( 0x1ff8, &pPC); change_pc(PC); } else if((m6805.pending_interrupts&(1<<HD63705_INT_IRQ2))!=0) { m6805.pending_interrupts &= ~(1<<HD63705_INT_IRQ2); RM16( 0x1fec, &pPC); change_pc(PC); } else if((m6805.pending_interrupts&(1<<HD63705_INT_ADCONV))!=0) { m6805.pending_interrupts &= ~(1<<HD63705_INT_ADCONV); RM16( 0x1fea, &pPC); change_pc(PC); } else if((m6805.pending_interrupts&(1<<HD63705_INT_TIMER1))!=0) { m6805.pending_interrupts &= ~(1<<HD63705_INT_TIMER1); RM16( 0x1ff6, &pPC); change_pc(PC); } else if((m6805.pending_interrupts&(1<<HD63705_INT_TIMER2))!=0) { m6805.pending_interrupts &= ~(1<<HD63705_INT_TIMER2); RM16( 0x1ff4, &pPC); change_pc(PC); } else if((m6805.pending_interrupts&(1<<HD63705_INT_TIMER3))!=0) { m6805.pending_interrupts &= ~(1<<HD63705_INT_TIMER3); RM16( 0x1ff2, &pPC); change_pc(PC); } else if((m6805.pending_interrupts&(1<<HD63705_INT_PCI))!=0) { m6805.pending_interrupts &= ~(1<<HD63705_INT_PCI); RM16( 0x1ff0, &pPC); change_pc(PC); } else if((m6805.pending_interrupts&(1<<HD63705_INT_SCI))!=0) { m6805.pending_interrupts &= ~(1<<HD63705_INT_SCI); RM16( 0x1fee, &pPC); change_pc(PC); } } else //#endif { RM16( 0xffff - 5, &pPC ); change_pc(PC); } } // CC & IFLAG m6805.pending_interrupts &= ~(1<<M6805_IRQ_LINE); } m6805_ICount -= 11; } } static void m6805_reset() { int (*save_irqcallback)(int) = m6805.irq_callback; memset(&m6805, 0, sizeof(m6805)); m6805.irq_callback = save_irqcallback; /* Force CPU sub-type and relevant masks */ m6805.subtype = SUBTYPE_M6805; SP_MASK = 0x07f; SP_LOW = 0x060; /* Initial stack pointer */ S = SP_MASK; /* IRQ disabled */ SEI; RM16( 0xfffe , &pPC ); change_pc(PC); } void m6805Reset() { m6805_reset(); } //static void m6805_init(int ) //int (*irqcallback)(int)) //{ // m6805.irq_callback = irqcallback; //} //static void m6805_exit(void) //{ // /* nothing to do */ //} void m6805SetIrqLine(int , int state) { /* Basic 6805 only has one IRQ line */ /* See HD63705 specific version */ if (m6805.irq_state[0] == state) return; m6805.irq_state[0] = state; if (state != CLEAR_LINE) m6805.pending_interrupts |= 1<<M6805_IRQ_LINE; } #include "6805ops.c" /* execute instructions on this CPU until icount expires */ int m6805Run(int cycles) { UINT8 ireg; m6805_ICount = cycles; do { if (m6805.pending_interrupts != 0) { if (SUBTYPE==SUBTYPE_M68705) { m68705_Interrupt(); } else { Interrupt(); } } ireg=M_RDOP(PC++); switch( ireg ) { case 0x00: brset(0x01); break; case 0x01: brclr(0x01); break; case 0x02: brset(0x02); break; case 0x03: brclr(0x02); break; case 0x04: brset(0x04); break; case 0x05: brclr(0x04); break; case 0x06: brset(0x08); break; case 0x07: brclr(0x08); break; case 0x08: brset(0x10); break; case 0x09: brclr(0x10); break; case 0x0A: brset(0x20); break; case 0x0B: brclr(0x20); break; case 0x0C: brset(0x40); break; case 0x0D: brclr(0x40); break; case 0x0E: brset(0x80); break; case 0x0F: brclr(0x80); break; case 0x10: bset(0x01); break; case 0x11: bclr(0x01); break; case 0x12: bset(0x02); break; case 0x13: bclr(0x02); break; case 0x14: bset(0x04); break; case 0x15: bclr(0x04); break; case 0x16: bset(0x08); break; case 0x17: bclr(0x08); break; case 0x18: bset(0x10); break; case 0x19: bclr(0x10); break; case 0x1a: bset(0x20); break; case 0x1b: bclr(0x20); break; case 0x1c: bset(0x40); break; case 0x1d: bclr(0x40); break; case 0x1e: bset(0x80); break; case 0x1f: bclr(0x80); break; case 0x20: bra(); break; case 0x21: brn(); break; case 0x22: bhi(); break; case 0x23: bls(); break; case 0x24: bcc(); break; case 0x25: bcs(); break; case 0x26: bne(); break; case 0x27: beq(); break; case 0x28: bhcc(); break; case 0x29: bhcs(); break; case 0x2a: bpl(); break; case 0x2b: bmi(); break; case 0x2c: bmc(); break; case 0x2d: bms(); break; case 0x2e: bil(); break; case 0x2f: bih(); break; case 0x30: neg_di(); break; case 0x31: illegal(); break; case 0x32: illegal(); break; case 0x33: com_di(); break; case 0x34: lsr_di(); break; case 0x35: illegal(); break; case 0x36: ror_di(); break; case 0x37: asr_di(); break; case 0x38: lsl_di(); break; case 0x39: rol_di(); break; case 0x3a: dec_di(); break; case 0x3b: illegal(); break; case 0x3c: inc_di(); break; case 0x3d: tst_di(); break; case 0x3e: illegal(); break; case 0x3f: clr_di(); break; case 0x40: nega(); break; case 0x41: illegal(); break; case 0x42: illegal(); break; case 0x43: coma(); break; case 0x44: lsra(); break; case 0x45: illegal(); break; case 0x46: rora(); break; case 0x47: asra(); break; case 0x48: lsla(); break; case 0x49: rola(); break; case 0x4a: deca(); break; case 0x4b: illegal(); break; case 0x4c: inca(); break; case 0x4d: tsta(); break; case 0x4e: illegal(); break; case 0x4f: clra(); break; case 0x50: negx(); break; case 0x51: illegal(); break; case 0x52: illegal(); break; case 0x53: comx(); break; case 0x54: lsrx(); break; case 0x55: illegal(); break; case 0x56: rorx(); break; case 0x57: asrx(); break; case 0x58: aslx(); break; case 0x59: rolx(); break; case 0x5a: decx(); break; case 0x5b: illegal(); break; case 0x5c: incx(); break; case 0x5d: tstx(); break; case 0x5e: illegal(); break; case 0x5f: clrx(); break; case 0x60: neg_ix1(); break; case 0x61: illegal(); break; case 0x62: illegal(); break; case 0x63: com_ix1(); break; case 0x64: lsr_ix1(); break; case 0x65: illegal(); break; case 0x66: ror_ix1(); break; case 0x67: asr_ix1(); break; case 0x68: lsl_ix1(); break; case 0x69: rol_ix1(); break; case 0x6a: dec_ix1(); break; case 0x6b: illegal(); break; case 0x6c: inc_ix1(); break; case 0x6d: tst_ix1(); break; case 0x6e: illegal(); break; case 0x6f: clr_ix1(); break; case 0x70: neg_ix(); break; case 0x71: illegal(); break; case 0x72: illegal(); break; case 0x73: com_ix(); break; case 0x74: lsr_ix(); break; case 0x75: illegal(); break; case 0x76: ror_ix(); break; case 0x77: asr_ix(); break; case 0x78: lsl_ix(); break; case 0x79: rol_ix(); break; case 0x7a: dec_ix(); break; case 0x7b: illegal(); break; case 0x7c: inc_ix(); break; case 0x7d: tst_ix(); break; case 0x7e: illegal(); break; case 0x7f: clr_ix(); break; case 0x80: rti(); break; case 0x81: rts(); break; case 0x82: illegal(); break; case 0x83: swi(); break; case 0x84: illegal(); break; case 0x85: illegal(); break; case 0x86: illegal(); break; case 0x87: illegal(); break; case 0x88: illegal(); break; case 0x89: illegal(); break; case 0x8a: illegal(); break; case 0x8b: illegal(); break; case 0x8c: illegal(); break; case 0x8d: illegal(); break; case 0x8e: illegal(); break; case 0x8f: illegal(); break; case 0x90: illegal(); break; case 0x91: illegal(); break; case 0x92: illegal(); break; case 0x93: illegal(); break; case 0x94: illegal(); break; case 0x95: illegal(); break; case 0x96: illegal(); break; case 0x97: tax(); break; case 0x98: CLC; break; case 0x99: SEC; break; #if IRQ_LEVEL_DETECT case 0x9a: CLI; if (m6805.irq_state != CLEAR_LINE) m6805.pending_interrupts |= 1<<M6805_IRQ_LINE; break; #else case 0x9a: CLI; break; #endif case 0x9b: SEI; break; case 0x9c: rsp(); break; case 0x9d: nop(); break; case 0x9e: illegal(); break; case 0x9f: txa(); break; case 0xa0: suba_im(); break; case 0xa1: cmpa_im(); break; case 0xa2: sbca_im(); break; case 0xa3: cpx_im(); break; case 0xa4: anda_im(); break; case 0xa5: bita_im(); break; case 0xa6: lda_im(); break; case 0xa7: illegal(); break; case 0xa8: eora_im(); break; case 0xa9: adca_im(); break; case 0xaa: ora_im(); break; case 0xab: adda_im(); break; case 0xac: illegal(); break; case 0xad: bsr(); break; case 0xae: ldx_im(); break; case 0xaf: illegal(); break; case 0xb0: suba_di(); break; case 0xb1: cmpa_di(); break; case 0xb2: sbca_di(); break; case 0xb3: cpx_di(); break; case 0xb4: anda_di(); break; case 0xb5: bita_di(); break; case 0xb6: lda_di(); break; case 0xb7: sta_di(); break; case 0xb8: eora_di(); break; case 0xb9: adca_di(); break; case 0xba: ora_di(); break; case 0xbb: adda_di(); break; case 0xbc: jmp_di(); break; case 0xbd: jsr_di(); break; case 0xbe: ldx_di(); break; case 0xbf: stx_di(); break; case 0xc0: suba_ex(); break; case 0xc1: cmpa_ex(); break; case 0xc2: sbca_ex(); break; case 0xc3: cpx_ex(); break; case 0xc4: anda_ex(); break; case 0xc5: bita_ex(); break; case 0xc6: lda_ex(); break; case 0xc7: sta_ex(); break; case 0xc8: eora_ex(); break; case 0xc9: adca_ex(); break; case 0xca: ora_ex(); break; case 0xcb: adda_ex(); break; case 0xcc: jmp_ex(); break; case 0xcd: jsr_ex(); break; case 0xce: ldx_ex(); break; case 0xcf: stx_ex(); break; case 0xd0: suba_ix2(); break; case 0xd1: cmpa_ix2(); break; case 0xd2: sbca_ix2(); break; case 0xd3: cpx_ix2(); break; case 0xd4: anda_ix2(); break; case 0xd5: bita_ix2(); break; case 0xd6: lda_ix2(); break; case 0xd7: sta_ix2(); break; case 0xd8: eora_ix2(); break; case 0xd9: adca_ix2(); break; case 0xda: ora_ix2(); break; case 0xdb: adda_ix2(); break; case 0xdc: jmp_ix2(); break; case 0xdd: jsr_ix2(); break; case 0xde: ldx_ix2(); break; case 0xdf: stx_ix2(); break; case 0xe0: suba_ix1(); break; case 0xe1: cmpa_ix1(); break; case 0xe2: sbca_ix1(); break; case 0xe3: cpx_ix1(); break; case 0xe4: anda_ix1(); break; case 0xe5: bita_ix1(); break; case 0xe6: lda_ix1(); break; case 0xe7: sta_ix1(); break; case 0xe8: eora_ix1(); break; case 0xe9: adca_ix1(); break; case 0xea: ora_ix1(); break; case 0xeb: adda_ix1(); break; case 0xec: jmp_ix1(); break; case 0xed: jsr_ix1(); break; case 0xee: ldx_ix1(); break; case 0xef: stx_ix1(); break; case 0xf0: suba_ix(); break; case 0xf1: cmpa_ix(); break; case 0xf2: sbca_ix(); break; case 0xf3: cpx_ix(); break; case 0xf4: anda_ix(); break; case 0xf5: bita_ix(); break; case 0xf6: lda_ix(); break; case 0xf7: sta_ix(); break; case 0xf8: eora_ix(); break; case 0xf9: adca_ix(); break; case 0xfa: ora_ix(); break; case 0xfb: adda_ix(); break; case 0xfc: jmp_ix(); break; case 0xfd: jsr_ix(); break; case 0xfe: ldx_ix(); break; case 0xff: stx_ix(); break; } m6805_ICount -= cycles1[ireg]; m6805.nTotalCycles += cycles1[ireg]; } while( m6805_ICount > 0 ); return cycles - m6805_ICount; }
void Keyboard::install() { IDT::interrupt(0x21) = Interrupt(Keyboard::dispatchIRQ); }
////////////////////////////////////////////////////////////////////////////// // // Start // static bool AppInit(int argc, char* argv[]) { bool fRet = false; // // Parameters // // If Qt is used, parameters/digibyte.conf are parsed in qt/digibyte.cpp's main() SetupServerArgs(); std::string error; if (!gArgs.ParseParameters(argc, argv, error)) { fprintf(stderr, "Error parsing command line arguments: %s\n", error.c_str()); return false; } // Process help and version before taking care about datadir if (HelpRequested(gArgs) || gArgs.IsArgSet("-version")) { std::string strUsage = strprintf("%s Daemon", PACKAGE_NAME) + " version " + FormatFullVersion() + "\n"; if (gArgs.IsArgSet("-version")) { strUsage += FormatParagraph(LicenseInfo()); } else { strUsage += "\nUsage:\n" " digibyted [options] " + strprintf("Start %s Daemon", PACKAGE_NAME) + "\n"; strUsage += "\n" + gArgs.GetHelpMessage(); } fprintf(stdout, "%s", strUsage.c_str()); return true; } try { if (!fs::is_directory(GetDataDir(false))) { fprintf(stderr, "Error: Specified data directory \"%s\" does not exist.\n", gArgs.GetArg("-datadir", "").c_str()); return false; } if (!gArgs.ReadConfigFiles(error, true)) { fprintf(stderr, "Error reading configuration file: %s\n", error.c_str()); return false; } // Check for -testnet or -regtest parameter (Params() calls are only valid after this clause) try { SelectParams(gArgs.GetChainName()); } catch (const std::exception& e) { fprintf(stderr, "Error: %s\n", e.what()); return false; } // Error out when loose non-argument tokens are encountered on command line for (int i = 1; i < argc; i++) { if (!IsSwitchChar(argv[i][0])) { fprintf(stderr, "Error: Command line contains unexpected token '%s', see digibyted -h for a list of options.\n", argv[i]); return false; } } // -server defaults to true for digibyted but not for the GUI so do this here gArgs.SoftSetBoolArg("-server", true); // Set this early so that parameter interactions go to console InitLogging(); InitParameterInteraction(); if (!AppInitBasicSetup()) { // InitError will have been called with detailed error, which ends up on console return false; } if (!AppInitParameterInteraction()) { // InitError will have been called with detailed error, which ends up on console return false; } if (!AppInitSanityChecks()) { // InitError will have been called with detailed error, which ends up on console return false; } if (gArgs.GetBoolArg("-daemon", false)) { #if HAVE_DECL_DAEMON #if defined(MAC_OSX) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wdeprecated-declarations" #endif fprintf(stdout, "DigiByte server starting\n"); // Daemonize if (daemon(1, 0)) { // don't chdir (1), do close FDs (0) fprintf(stderr, "Error: daemon() failed: %s\n", strerror(errno)); return false; } #if defined(MAC_OSX) #pragma GCC diagnostic pop #endif #else fprintf(stderr, "Error: -daemon is not supported on this operating system\n"); return false; #endif // HAVE_DECL_DAEMON } // Lock data directory after daemonization if (!AppInitLockDataDirectory()) { // If locking the data directory failed, exit immediately return false; } fRet = AppInitMain(); } catch (const std::exception& e) { PrintExceptionContinue(&e, "AppInit()"); } catch (...) { PrintExceptionContinue(nullptr, "AppInit()"); } if (!fRet) { Interrupt(); } else { WaitForShutdown(); } Shutdown(); return fRet; }
void TIM::begin(void) { TIMxBaseInit(_period,_prescaler); Interrupt(DISABLE); stop(); }
int main (int argc,char **argv ) { #ifdef _DEBUG printf("SIZE OF CELL: %d\n",sizeof(Cell)); printf("SIZE OF EdiTCOmmitData: %d\n",sizeof(EditCommitAuxData)); printf("SIZE OF RenderAuxData: %d\n",sizeof(RenderAuxData)); printf("SIZE OF FBOOL: %d\n",sizeof(FBool)); printf("SIZE OF BoolVector: %d\n",sizeof(BoolVector)); printf("SIZE OF Chain<GIndex>: %d\n",sizeof(Chain<GIndex>)); printf("SIZE OF std::map<unsigned int,unsigned int>: %d\n",sizeof(std::map<unsigned int,unsigned int>)); printf("waste: %d\n",sizeof(FBool)*5+sizeof(BoolVector)*3+sizeof(Chain<GIndex>)+sizeof(std::map<unsigned int,unsigned int>)); printf("SIZE OF Chain<GIndex>: %d\n",sizeof(Chain<GIndex>)); printf("SIZE OF Chain<OFace>: %d\n",sizeof(Chain<OFace>)); printf("SIZE OF Chain<OVertex>: %d\n",sizeof(Chain<OVertex>)); printf("SIZE OF Chain<OVertex>::Chunk: %d\n",sizeof(Chain<OVertex>::Chunk)); printf("SIZE OF CachePolicy: %d\n",sizeof(CachePolicy)); printf("SIZE OF std::string: %d\n",sizeof(std::string)); printf("SIZE OF vcgMesh: %d\n",sizeof(vcgMesh)); printf("SIZE OF Impostor: %d\n",sizeof(Impostor)); #endif std::vector<std::wstring> refvecFiles; std::wstring refcstrRootDirectory(L"."); std::wstring refcstrExtension(L"ply"); bool bSearchSubdirectories = true; // _CrtSetBreakAlloc(1281429); std::vector<std::string> files_to_load; struct stat buf; { int c; int digit_optind = 0; unsigned int meshadded = 0, max_meshes = 1000 /*std::numeric_limits<unsigned int>::max()*/, min_meshes = 0, min_meshes_aln = 0, max_meshes_aln= 1000 /*std::numeric_limits<unsigned int>::max()*/, cache_memory_limit = 200, berkeley_page_size = 1024, side_factor = 50; std::string ocmename,tra_ma_file; bool logging = false; bool save_impostors = false; bool overwrite_database = false; bool transform = false; bool verify = false; bool only_vertices = false; bool compute_normals = false; bool all_plys = false; bool compute_stats = false; bool recompute_impostors = false; vcg::Matrix44f tra_ma;tra_ma.SetIdentity(); #ifdef _DEBUG printf("ocme builder DEBUG MODE\n"); #endif std::string stat_file = std::string(""); if(argc==1) UsageExit(); while (1) { int this_option_optind = optind ? optind : 1; c = getopt (argc, argv, "IVFsqciosnvp:t:m:l:f:L:a:A:k:S:"); if (c == EOF) break; switch (c) { case 'q': verify = true; break; case 'i': save_impostors = true; break; case 'I': recompute_impostors = true; break; case 'n': compute_normals = true; break; case 's': only_vertices = true; break; case 'V': compute_stats = true; break; #ifdef _WIN32 case 'F': all_plys = true; SearchDirectory(refvecFiles,refcstrRootDirectory,refcstrExtension,false); break; #endif case 't': transform = true; printf("filename %s\n",optarg );tra_ma_file = std::string(optarg); LoadTraMa(tra_ma_file.c_str(),tra_ma); break; case 'S': printf("filename %s\n",optarg );stat_file = std::string(optarg); break; case 'o': overwrite_database = true; break; case 'f': printf("filename %s\n",optarg );ocmename = std::string(optarg); break; case 'a': min_meshes_aln = atoi(optarg); break; case 'k': side_factor = atoi(optarg); break; case 'A': max_meshes_aln = atoi(optarg); break; case 'l': min_meshes = atoi(optarg); break; case 'L': max_meshes = atoi(optarg); break; case 'm': cache_memory_limit = atoi(optarg); break; case 'p': berkeley_page_size = atoi(optarg); break; case 'v': logging = true; break; default: printf("unknown parameter 0%o ??\n", c); UsageExit(); } } /* .................................. */ Impostor::Gridsize()= 8; if(stat_file.empty()) stat_file = ocmename + std::string("_log.txt"); lgn = new Logging(stat_file.c_str()); lgn->Append("starting"); lgn->Push(); TIM::Begin(1); STAT::Begin(N_STAT); meshona = new OCME(); meshona->params.side_factor = side_factor; meshona->oce.cache_policy->memory_limit = cache_memory_limit * (1<<20); lgn->off = !logging; if(!verify && !compute_stats && !recompute_impostors){ meshona->streaming_mode = true; int start = clock(); int totalstart = start; #ifdef SIMPLE_DB if(overwrite_database) meshona->Create((std::string(ocmename)).c_str(),berkeley_page_size); else meshona->Open((std::string(ocmename)+std::string(".socm")).c_str()); #else if(overwrite_database) meshona->Create((std::string(ocmename) +std::string(".kch") ).c_str(),berkeley_page_size); else meshona->Open((std::string(ocmename)+std::string(".kch")).c_str()); #endif if(all_plys) for(int i = 0 ; i < refvecFiles.size() ;++i) files_to_load.push_back( std::string( refvecFiles[i].begin(),refvecFiles[i].end())); else for(int i = optind ; (i < argc) ;++i) files_to_load.push_back(argv[i]); for(int i = min_meshes; (i < files_to_load.size())&& (i<max_meshes)&& !Interrupt();++i){ unsigned int wh = std::string(files_to_load[i]).find(std::string(".aln")); if(wh == std::string(files_to_load[i]).length()-4) // it is an aln file { std::vector<std::pair<std::string,vcg::Matrix44f> > aln; LoadAln(files_to_load[i].c_str(),aln); printf("aln.size() = %d\n",aln.size()); for(unsigned int idm = min_meshes_aln; (idm< std::min(max_meshes_aln,aln.size())) && !Interrupt();++idm){ STAT::Reset(); start = clock(); vcgMesh m; stat(aln[idm].first.c_str(),&buf); ++meshona->stat.n_files; meshona->stat.input_file_size+=buf.st_size; TIM::Begin(0); vcg::tri::io::ImporterPLY<vcgMesh>::Open(m,aln[idm].first.c_str()); TIM::End(0); meshona->stat.n_triangles += m.fn; meshona->stat.n_vertices += m.fn; printf("%d of %d in %f sec\n",idm,aln.size(),(clock()-start)/float(CLOCKS_PER_SEC)); vcg::tri::UpdatePosition<vcgMesh>::Matrix(m,aln[idm].second); unsigned int newstart = clock(); if(!m.face.empty()){ if(only_vertices){ if(compute_normals) vcg::tri::UpdateNormals<vcgMesh>::PerVertexPerFace(m); m.fn = 0; } if(transform){ sprintf(lgn->Buf(),"Apply transform" ); lgn->Push(); vcg::tri::UpdatePosition<vcgMesh>::Matrix(m,tra_ma); } meshona->AddMesh(m); ++meshadded; } printf("Sizeof meshona->oce %d\n", meshona->oce.SizeOfMem()); samples.push_back(Sample( m.fn,(clock()-newstart)/float(CLOCKS_PER_SEC),meshona->cells.size(), STAT::V(0),STAT::V(1),STAT::V(6),STAT::V(3),STAT::V(5))); PrintFacesSec(); } } else // It is a ply file { STAT::Reset(); start = clock(); vcgMesh m; unsigned long n_faces =0; sprintf(lgn->Buf(),"Adding mesh %s (%d of %d)..Loading",files_to_load[i].c_str(),i, files_to_load.size()); lgn->Push(); stat(files_to_load[i].c_str(),&buf); meshona->stat.input_file_size+=buf.st_size; if(buf.st_size < 100 * (1<<20)) // if(false) {// if the file is less that 50MB load the mesh in memory and then add it int mask = 0; TIM::Begin(0); AttributeMapper am; vcg::tri::io::ImporterPLY<vcgMesh>::LoadMask(files_to_load[i].c_str(),mask); if(mask & vcg::tri::io::Mask::IOM_VERTCOLOR){ m.vert.EnableColor(); am.vert_attrs.push_back("Color4b"); } vcg::tri::io::ImporterPLY<vcgMesh>::Open(m,files_to_load[i].c_str(),cb); meshona->stat.n_triangles += m.fn; meshona->stat.n_vertices += m.vn; if(transform){ sprintf(lgn->Buf(),"Apply transform" ); lgn->Push(); vcg::tri::UpdatePosition<vcgMesh>::Matrix(m,tra_ma); // vcg::tri::io::ExporterPLY<vcgMesh>::Save(m,std::string(argv[i]).append("T.ply").c_str()); } TIM::End(0); n_faces = m.fn; sprintf(lgn->Buf(),"loaded in %f seconds\n",(clock()-start)/float(CLOCKS_PER_SEC)); lgn->Push(); assert( MemDbg::CheckHeap(0)); ++meshona->stat.n_files; if(only_vertices){ if(compute_normals) { vcg::tri::UpdateNormals<vcgMesh>::PerVertexPerFace(m); am.vert_attrs.push_back("Normal3f"); } m.fn = 0; } meshona->AddMesh(m,am); ++meshadded; sprintf(lgn->Buf(),"#cells: %d \n", meshona->cells.size()); lgn->Push(); } else { TIM::Begin(2); // if the file is more that 50 MB build directly from file n_faces = vcg::tri::io::ImporterOCMPLY<vcgMesh>::Open(m,meshona,files_to_load[i].c_str(),tra_ma,true,cb); TIM::End(2); } sprintf(lgn->Buf(),"added in %f seconds\n",(clock()-start)/float(CLOCKS_PER_SEC)); lgn->Push(); samples.push_back(Sample( n_faces,(clock()-start)/float(CLOCKS_PER_SEC),meshona->cells.size(), STAT::V(0),STAT::V(1),STAT::V(6),STAT::V(3),STAT::V(5))); PrintFacesSec(); printf("accesses % d \n",STAT::V(N_ACCESSES)); } } meshona->RemoveEmptyCells(); start = clock(); printf("number of cells: %d \n number of chains %d\n", meshona->cells.size(), meshona->oce.chains.size()); if(save_impostors){ vcgMesh impostorMesh; vcg::tri::io::PlyInfo pi; pi.mask |= vcg::tri::io::Mask::IOM_VERTCOLOR | vcg::tri::io::Mask::IOM_VERTNORMAL; impostorMesh.vert.EnableColor(); meshona->ImpostorsToMesh(impostorMesh); vcg::tri::io::ExporterPLY<vcgMesh>::Save(impostorMesh,(std::string(ocmename)+std::string("_imp.ply")).c_str(),pi.mask); } meshona->Close(true); TIM::End(1); PrintFacesSec(); printf("closed %ld seconds\n",(clock()-start)/CLOCKS_PER_SEC); printf("total %ld seconds\n",(clock()-totalstart)/CLOCKS_PER_SEC); // PrintStats(); } else { #ifdef SIMPLE_DB meshona->Open(( ocmename+std::string(".socm")).c_str()); #else meshona->Open(( ocmename+std::string(".kch")).c_str()); #endif if(verify) meshona->Verify(); if(compute_stats){ meshona->ComputeStatistics(); printf("tri: %d, ver %d]\n",meshona->stat.n_triangles,meshona->stat.n_vertices); } if(recompute_impostors) meshona->ComputeImpostors(); meshona->Close(false); } delete meshona; } samples.clear(); MemDbg::End(); MemDbg::DumpMemoryLeaks(); }
/* ******************************************************************************** * * * Search() is the recursive routine used to implement the alpha/beta * * negamax search (similar to minimax but simpler to code.) Search() is * * called whenever there is "depth" remaining so that all moves are subject * * to searching, or when the side to move is in check, to make sure that this * * side isn't mated. Search() recursively calls itself until depth is ex- * * hausted, at which time it calls Quiesce() instead. * * * ******************************************************************************** */ int Search(int alpha, int beta, int wtm, int depth, int ply, int do_null) { register int first_move=1; register BITBOARD save_hash_key; register int initial_alpha, value; register int extensions; /* ---------------------------------------------------------- | | | check to see if we have searched enough nodes that it | | is time to peek at how much time has been used, or if | | is time to check for operator keyboard input. this is | | usually enough nodes to force a time/input check about | | once per second, except when the target time per move | | is very small, in which case we try to check the time | | at least 10 times during the search. | | | ---------------------------------------------------------- */ if (ply >= MAXPLY-2) return(beta); nodes_searched++; if (--next_time_check <= 0) { next_time_check=nodes_between_time_checks; if (CheckInput()) Interrupt(ply); time_abort+=TimeCheck(0); if (time_abort) { abort_search=1; return(0); } } /* ---------------------------------------------------------- | | | check for draw by repetition. | | | ---------------------------------------------------------- */ if (RepetitionCheck(ply,wtm)) { value=(wtm==root_wtm) ? DrawScore() : -DrawScore(); if (value < beta) SavePV(ply,value,0); #if !defined(FAST) if(ply <= trace_level) printf("draw by repetition detected, ply=%d.\n",ply); #endif return(value); } /* ---------------------------------------------------------- | | | now call LookUp() to see if this position has been | | searched before. if so, we may get a real score, | | produce a cutoff, or get nothing more than a good move | | to try first. there are four cases to handle: | | | | 1. LookUp() returned "EXACT_SCORE" if this score is | | greater than beta, return beta. otherwise, return the | | score. In either case, no further searching is needed | | from this position. note that lookup verified that | | the table position has sufficient "draft" to meet the | | requirements of the current search depth remaining. | | | | 2. LookUp() returned "LOWER_BOUND" which means that | | when this position was searched previously, every move | | was "refuted" by one of its descendents. as a result, | | when the search was completed, we returned alpha at | | that point. we simply return alpha here as well. | | | | 3. LookUp() returned "UPPER_BOUND" which means that | | when we encountered this position before, we searched | | one branch (probably) which promptly refuted the move | | at the previous ply. | | | | 4. LookUp() returned "AVOID_NULL_MOVE" which means | | the hashed score/bound was no good, but it indicated | | that trying a null-move in this position will be a | | waste of time. | | | ---------------------------------------------------------- */ switch (LookUp(ply,depth,wtm,&alpha,beta)) { case EXACT_SCORE: if(alpha >= beta) return(beta); else { SavePV(ply,alpha,1); return(alpha); } case LOWER_BOUND: return(alpha); case UPPER_BOUND: return(beta); case AVOID_NULL_MOVE: do_null=0; } /* ---------------------------------------------------------- | | | now it's time to try a probe into the endgame table- | | base files. this is done if (a) the previous move was | | a capture or promotion, unless we are at very shallow | | plies (<4) in the search; (b) there are less than 5 | | pieces left (currently all interesting 4 piece endings | | are available.) | | | ---------------------------------------------------------- */ #if defined(TABLEBASES) if (TotalPieces < 5) do { register int wpawn, bpawn; int tb_value; if (TotalWhitePawns && TotalBlackPawns) { wpawn=FirstOne(WhitePawns); bpawn=FirstOne(BlackPawns); if (FileDistance(wpawn,bpawn) == 1) { if(((Rank(wpawn)==1) && (Rank(bpawn)>2)) || ((Rank(bpawn)==6) && (Rank(wpawn)<5)) || EnPassant(ply)) break; } } tb_probes++; if (EGTBScore(ply, wtm, &tb_value)) { tb_probes_successful++; alpha=tb_value; if (abs(alpha) > MATE-100) alpha+=(alpha > 0) ? -(ply-1) : +(ply-1); else if (alpha == 0) alpha=(wtm==root_wtm) ? DrawScore() : -DrawScore(); if(alpha >= beta) return(beta); else { SavePV(ply,alpha,2); return(alpha); } } } while(0); # endif /* ---------------------------------------------------------- | | | initialize. | | | ---------------------------------------------------------- */ in_check[ply+1]=0; extended_reason[ply+1]=no_extension; initial_alpha=alpha; last[ply]=last[ply-1]; killer_count1[ply+1]=0; killer_count2[ply+1]=0; /* ---------------------------------------------------------- | | | first, we try a null move to see if we can get a quick | | cutoff with only a little work. this operates as | | follows. instead of making a legal move, the side on | | move 'passes' and does nothing. the resulting position | | is searched to a shallower depth than normal (usually | | one ply less but settable by the operator) this should | | result in a cutoff or at least should set the lower | | bound better since anything should be better than not | | doing anything. | | | | this is skipped for any of the following reasons: | | | | 1. the side on move is in check. the null move | | results in an illegal position. | | 2. no more than one null move can appear in succession | | or else the search will degenerate into nothing. | | 3. the side on move has little material left making | | zugzwang positions more likely. | | | ---------------------------------------------------------- */ # if defined(NULL_MOVE_DEPTH) if (do_null && !in_check[ply] && ((wtm) ? TotalWhitePieces : TotalBlackPieces)>2) { current_move[ply]=0; current_phase[ply]=NULL_MOVE; #if !defined(FAST) if (ply <= trace_level) SearchTrace(ply,depth,wtm,alpha,beta,"Search",0); #endif position[ply+1]=position[ply]; Rule50Moves(ply+1)++; save_hash_key=HashKey; if (EnPassant(ply)) { HashEP(EnPassant(ply+1),HashKey); EnPassant(ply+1)=0; } if ((depth-NULL_MOVE_DEPTH-INCREMENT_PLY) >= INCREMENT_PLY) value=-Search(-beta,-alpha,ChangeSide(wtm),depth-NULL_MOVE_DEPTH-INCREMENT_PLY,ply+1,NO_NULL); else value=-Quiesce(-beta,-alpha,ChangeSide(wtm),ply+1); HashKey=save_hash_key; if (abort_search) return(0); if (value >= beta) { StoreRefutation(ply,depth,wtm,beta); return(beta); } } # endif /* ---------------------------------------------------------- | | | if there is no best move from the hash table, and this | | is a PV node, then we need a good move to search | | first. while killers and history moves are good, they | | are not "good enough". the simplest action is to try | | a shallow search (depth-2) to get a move. note that | | when we call Search() with depth-2, it, too, will | | not have a hash move, and will therefore recursively | | continue this process, hence the name "internal | | iterative deepening." | | | ---------------------------------------------------------- */ next_status[ply].phase=FIRST_PHASE; if (hash_move[ply]==0 && (depth > 2*INCREMENT_PLY) && (((ply & 1) && alpha == root_alpha && beta == root_beta) || (!(ply & 1) && alpha == -root_beta && beta == -root_alpha))) { current_move[ply]=0; value=Search(alpha,beta,wtm,depth-2*INCREMENT_PLY,ply,DO_NULL); if (abort_search) return(0); if (value <= alpha) { value=Search(-MATE,beta,wtm,depth-2*INCREMENT_PLY,ply,DO_NULL); if (abort_search) return(0); } else if (value < beta) { if ((int) pv[ply-1].path_length >= ply) hash_move[ply]=pv[ply-1].path[ply]; } else hash_move[ply]=current_move[ply]; last[ply]=last[ply-1]; next_status[ply].phase=FIRST_PHASE; } /* ---------------------------------------------------------- | | | now iterate through the move list and search the | | resulting positions. note that Search() culls any | | move that is not legal by using Check(). the special | | case is that we must find one legal move to search to | | confirm that it's not a mate or draw. | | | ---------------------------------------------------------- */ while ((current_phase[ply]=(in_check[ply]) ? NextEvasion(ply,wtm) : NextMove(depth,ply,wtm))) { extended_reason[ply]&=check_extension; #if !defined(FAST) if (ply <= trace_level) SearchTrace(ply,depth,wtm,alpha,beta,"Search",current_phase[ply]); #endif /* ---------------------------------------------------------- | | | if two successive moves are capture / re-capture so | | that the material score is restored, extend the search | | by one ply on the re-capture since it is pretty much | | forced and easy to analyze. | | | ---------------------------------------------------------- */ extensions=-INCREMENT_PLY; if (Captured(current_move[ply]) && Captured(current_move[ply-1]) && To(current_move[ply-1]) == To(current_move[ply]) && (p_values[Captured(current_move[ply-1])+7] == p_values[Captured(current_move[ply])+7] || Promote(current_move[ply-1])) && !(extended_reason[ply-1]&recapture_extension)) { extended_reason[ply]|=recapture_extension; recapture_extensions_done++; extensions+=RECAPTURE; } /* ---------------------------------------------------------- | | | if we push a passed pawn, we need to look deeper to | | see if it is a legitimate threat. | | | ---------------------------------------------------------- */ if (Piece(current_move[ply])==pawn && !FutileAhead(wtm) && ((wtm && To(current_move[ply])>H5 && TotalBlackPieces<16 && !And(mask_pawn_passed_w[To(current_move[ply])],BlackPawns)) || (!wtm && To(current_move[ply])<A4 && TotalWhitePieces<16 && !And(mask_pawn_passed_b[To(current_move[ply])],WhitePawns)) || push_extensions[To(current_move[ply])]) && Swap(From(current_move[ply]),To(current_move[ply]),wtm) >= 0) { extended_reason[ply]|=passed_pawn_extension; passed_pawn_extensions_done++; extensions+=PASSED_PAWN_PUSH; } /* ---------------------------------------------------------- | | | now make the move and search the resulting position. | | if we are in check, the current move must be legal | | since NextEvasion ensures this, otherwise we have to | | make sure the side-on-move is not in check after the | | move to weed out illegal moves and save time. | | | ---------------------------------------------------------- */ MakeMove(ply,current_move[ply],wtm); if (in_check[ply] || !Check(wtm)) { /* ---------------------------------------------------------- | | | if the move to be made checks the opponent, then we | | need to remember that he's in check and also extend | | the depth by one ply for him to get out. | | | ---------------------------------------------------------- */ if (Check(ChangeSide(wtm))) { in_check[ply+1]=1; extended_reason[ply+1]=check_extension; check_extensions_done++; extensions+=IN_CHECK; } else { in_check[ply+1]=0; extended_reason[ply+1]=no_extension; } /* ---------------------------------------------------------- | | | now we toss in the "razoring" trick, which simply says | | if we are doing fairly badly, we can reduce the depth | | an additional ply, if there was nothing at the current | | ply that caused an extension. | | | ---------------------------------------------------------- */ if (depth < 3*INCREMENT_PLY && !in_check[ply] && extensions == -INCREMENT_PLY) { register int val=(wtm) ? Material : -Material; if (val+1500 < alpha) extensions-=INCREMENT_PLY; } /* ---------------------------------------------------------- | | | if there's only one legal move, extend the search one | | additional ply since this node is very easy to search. | | | ---------------------------------------------------------- */ if (first_move) { if (last[ply]-last[ply-1] == 1) { extended_reason[ply]|=one_reply_extension; one_reply_extensions_done++; extensions+=ONE_REPLY_TO_CHECK; } if (depth+MaxExtensions(extensions) >= INCREMENT_PLY) value=-Search(-beta,-alpha,ChangeSide(wtm),depth+MaxExtensions(extensions),ply+1,DO_NULL); else { value=-Quiesce(-beta,-alpha,ChangeSide(wtm),ply+1); } if (abort_search) { UnMakeMove(ply,current_move[ply],wtm); return(0); } first_move=0; } else { if (depth+MaxExtensions(extensions) >= INCREMENT_PLY) value=-Search(-alpha-1,-alpha,ChangeSide(wtm),depth+MaxExtensions(extensions),ply+1,DO_NULL); else { value=-Quiesce(-alpha-1,-alpha,ChangeSide(wtm),ply+1); } if (abort_search) { UnMakeMove(ply,current_move[ply],wtm); return(0); } if (value>alpha && value<beta) { if (depth+MaxExtensions(extensions) >= INCREMENT_PLY) value=-Search(-beta,-alpha,ChangeSide(wtm),depth+MaxExtensions(extensions),ply+1,DO_NULL); else value=-Quiesce(-beta,-alpha,ChangeSide(wtm),ply+1); if (abort_search) { UnMakeMove(ply,current_move[ply],wtm); return(0); } } } if (value > alpha) { if(value >= beta) { HistoryRefutation(ply,depth,wtm); UnMakeMove(ply,current_move[ply],wtm); StoreRefutation(ply,depth,wtm,beta); return(beta); } alpha=value; } } UnMakeMove(ply,current_move[ply],wtm); } /* ---------------------------------------------------------- | | | all moves have been searched. if none were legal, | | return either MATE or DRAW depending on whether the | | side to move is in check or not. | | | ---------------------------------------------------------- */ if (first_move == 1) { value=(Check(wtm)) ? -(MATE-ply) : ((wtm==root_wtm) ? DrawScore() : -DrawScore()); if(value > beta) value=beta; else if (value < alpha) value=alpha; if (value >=alpha && value <beta) { SavePV(ply,value,0); #if !defined(FAST) if (ply <= trace_level) printf("Search() no moves! ply=%d\n",ply); #endif } return(value); } else { if (alpha != initial_alpha) { memcpy(&pv[ply-1].path[ply],&pv[ply].path[ply],(pv[ply].path_length-ply+1)*4); memcpy(&pv[ply-1].path_hashed,&pv[ply].path_hashed,3); pv[ply-1].path[ply-1]=current_move[ply-1]; HistoryBest(ply,depth,wtm); } StoreBest(ply,depth,wtm,alpha,initial_alpha); /* ---------------------------------------------------------- | | | if the 50-move rule is drawing close, then adjust the | | score to reflect the impending draw. | | | ---------------------------------------------------------- */ if (Rule50Moves(ply) > 99) { value=(wtm==root_wtm) ? DrawScore() : -DrawScore(); if (value < beta) SavePV(ply,value,0); #if !defined(FAST) if(ply <= trace_level) printf("draw by 50-move rule detected, ply=%d.\n",ply); #endif return(value); } return(alpha); } }
////////////////////////////////////////////////////////////////////////////// // // Start // bool AppInit(int argc, char* argv[]) { boost::thread_group threadGroup; CScheduler scheduler; bool fRet = false; // // Parameters // // If Qt is used, parameters/bitcoin.conf are parsed in qt/bitcoin.cpp's main() ParseParameters(argc, argv); // Process help and version before taking care about datadir if (mapArgs.count("-?") || mapArgs.count("-h") || mapArgs.count("-help") || mapArgs.count("-version")) { std::string strUsage = strprintf(_("%s Daemon"), _(PACKAGE_NAME)) + " " + _("version") + " " + FormatFullVersion() + "\n"; if (mapArgs.count("-version")) { strUsage += FormatParagraph(LicenseInfo()); } else { strUsage += "\n" + _("Usage:") + "\n" + " bitcoind [options] " + strprintf(_("Start %s Daemon"), _(PACKAGE_NAME)) + "\n"; strUsage += "\n" + HelpMessage(HMM_BITCOIND); } fprintf(stdout, "%s", strUsage.c_str()); return false; } try { if (!boost::filesystem::is_directory(GetDataDir(false))) { fprintf(stderr, "Error: Specified data directory \"%s\" does not exist.\n", mapArgs["-datadir"].c_str()); return false; } try { ReadConfigFile(mapArgs, mapMultiArgs); } catch (const std::exception& e) { fprintf(stderr,"Error reading configuration file: %s\n", e.what()); return false; } // Check for -testnet or -regtest parameter (Params() calls are only valid after this clause) try { SelectParams(ChainNameFromCommandLine()); } catch (const std::exception& e) { fprintf(stderr, "Error: %s\n", e.what()); return false; } // Command-line RPC bool fCommandLine = false; for (int i = 1; i < argc; i++) if (!IsSwitchChar(argv[i][0]) && !boost::algorithm::istarts_with(argv[i], "bitcoin:")) fCommandLine = true; if (fCommandLine) { fprintf(stderr, "Error: There is no RPC client functionality in bitcoind anymore. Use the bitcoin-cli utility instead.\n"); exit(1); } #ifndef WIN32 fDaemon = GetBoolArg("-daemon", false); if (fDaemon) { fprintf(stdout, "Bitcoin server starting\n"); // Daemonize pid_t pid = fork(); if (pid < 0) { fprintf(stderr, "Error: fork() returned %d errno %d\n", pid, errno); return false; } if (pid > 0) // Parent process, pid is child process id { return true; } // Child process falls through to rest of initialization pid_t sid = setsid(); if (sid < 0) fprintf(stderr, "Error: setsid() returned %d errno %d\n", sid, errno); } #endif SoftSetBoolArg("-server", true); // Set this early so that parameter interactions go to console InitLogging(); InitParameterInteraction(); fRet = AppInit2(threadGroup, scheduler); } catch (const std::exception& e) { PrintExceptionContinue(&e, "AppInit()"); } catch (...) { PrintExceptionContinue(NULL, "AppInit()"); } if (!fRet) { Interrupt(threadGroup); // threadGroup.join_all(); was left out intentionally here, because we didn't re-test all of // the startup-failure cases to make sure they don't result in a hang due to some // thread-blocking-waiting-for-another-thread-during-startup case } else { WaitForShutdown(&threadGroup); } Shutdown(); return fRet; }
////////////////////////////////////////////////////////////////////////////// // // Start // bool AppInit(int argc, char* argv[]) { boost::thread_group threadGroup; CScheduler scheduler; bool fRet = false; // // Parameters // // If Qt is used, parameters/bitcoin.conf are parsed in qt/bitcoin.cpp's main() ParseParameters(argc, argv); // Process help and version before taking care about datadir if (IsArgSet("-?") || IsArgSet("-h") || IsArgSet("-help") || IsArgSet("-version")) { std::string strUsage = strprintf(_("%s Daemon"), _(PACKAGE_NAME)) + " " + _("version") + " " + FormatFullVersion() + "\n"; if (IsArgSet("-version")) { strUsage += FormatParagraph(LicenseInfo()); } else { strUsage += "\n" + _("Usage:") + "\n" + " bitcoind [options] " + strprintf(_("Start %s Daemon"), _(PACKAGE_NAME)) + "\n"; strUsage += "\n" + HelpMessage(HMM_BITCOIND); } fprintf(stdout, "%s", strUsage.c_str()); return true; } try { if (!fs::is_directory(GetDataDir(false))) { fprintf(stderr, "Error: Specified data directory \"%s\" does not exist.\n", GetArg("-datadir", "").c_str()); return false; } try { ReadConfigFile(GetArg("-conf", BITCOIN_CONF_FILENAME)); } catch (const std::exception& e) { fprintf(stderr,"Error reading configuration file: %s\n", e.what()); return false; } // Check for -testnet or -regtest parameter (Params() calls are only valid after this clause) try { SelectParams(ChainNameFromCommandLine()); } catch (const std::exception& e) { fprintf(stderr, "Error: %s\n", e.what()); return false; } // Command-line RPC bool fCommandLine = false; for (int i = 1; i < argc; i++) if (!IsSwitchChar(argv[i][0]) && !boost::algorithm::istarts_with(argv[i], "bitcoin:")) fCommandLine = true; if (fCommandLine) { fprintf(stderr, "Error: There is no RPC client functionality in bitcoind anymore. Use the bitcoin-cli utility instead.\n"); exit(EXIT_FAILURE); } // -server defaults to true for bitcoind but not for the GUI so do this here SoftSetBoolArg("-server", true); // Set this early so that parameter interactions go to console InitLogging(); InitParameterInteraction(); if (!AppInitBasicSetup()) { // InitError will have been called with detailed error, which ends up on console exit(EXIT_FAILURE); } if (!AppInitParameterInteraction()) { // InitError will have been called with detailed error, which ends up on console exit(EXIT_FAILURE); } if (!AppInitSanityChecks()) { // InitError will have been called with detailed error, which ends up on console exit(EXIT_FAILURE); } if (GetBoolArg("-daemon", false)) { #if HAVE_DECL_DAEMON fprintf(stdout, "Bitcoin server starting\n"); // Daemonize if (daemon(1, 0)) { // don't chdir (1), do close FDs (0) fprintf(stderr, "Error: daemon() failed: %s\n", strerror(errno)); return false; } #else fprintf(stderr, "Error: -daemon is not supported on this operating system\n"); return false; #endif // HAVE_DECL_DAEMON } fRet = AppInitMain(threadGroup, scheduler); } catch (const std::exception& e) { PrintExceptionContinue(&e, "AppInit()"); } catch (...) { PrintExceptionContinue(NULL, "AppInit()"); } if (!fRet) { Interrupt(threadGroup); // threadGroup.join_all(); was left out intentionally here, because we didn't re-test all of // the startup-failure cases to make sure they don't result in a hang due to some // thread-blocking-waiting-for-another-thread-during-startup case } else { WaitForShutdown(&threadGroup); } Shutdown(); return fRet; }
/* execute instructions on this CPU until icount expires */ static CPU_EXECUTE( m6805 ) { UINT8 ireg; m6805_Regs *cpustate = get_safe_token(device); S = SP_ADJUST( S ); /* Taken from CPU_SET_CONTEXT when pointer'afying */ do { if (cpustate->pending_interrupts != 0) { if (SUBTYPE==SUBTYPE_M68705) { m68705_Interrupt(cpustate); } else { Interrupt(cpustate); } } debugger_instruction_hook(device, PC); ireg=M_RDOP(PC++); switch( ireg ) { case 0x00: brset(cpustate, 0x01); break; case 0x01: brclr(cpustate, 0x01); break; case 0x02: brset(cpustate, 0x02); break; case 0x03: brclr(cpustate, 0x02); break; case 0x04: brset(cpustate, 0x04); break; case 0x05: brclr(cpustate, 0x04); break; case 0x06: brset(cpustate, 0x08); break; case 0x07: brclr(cpustate, 0x08); break; case 0x08: brset(cpustate, 0x10); break; case 0x09: brclr(cpustate, 0x10); break; case 0x0A: brset(cpustate, 0x20); break; case 0x0B: brclr(cpustate, 0x20); break; case 0x0C: brset(cpustate, 0x40); break; case 0x0D: brclr(cpustate, 0x40); break; case 0x0E: brset(cpustate, 0x80); break; case 0x0F: brclr(cpustate, 0x80); break; case 0x10: bset(cpustate, 0x01); break; case 0x11: bclr(cpustate, 0x01); break; case 0x12: bset(cpustate, 0x02); break; case 0x13: bclr(cpustate, 0x02); break; case 0x14: bset(cpustate, 0x04); break; case 0x15: bclr(cpustate, 0x04); break; case 0x16: bset(cpustate, 0x08); break; case 0x17: bclr(cpustate, 0x08); break; case 0x18: bset(cpustate, 0x10); break; case 0x19: bclr(cpustate, 0x10); break; case 0x1a: bset(cpustate, 0x20); break; case 0x1b: bclr(cpustate, 0x20); break; case 0x1c: bset(cpustate, 0x40); break; case 0x1d: bclr(cpustate, 0x40); break; case 0x1e: bset(cpustate, 0x80); break; case 0x1f: bclr(cpustate, 0x80); break; case 0x20: bra(cpustate); break; case 0x21: brn(cpustate); break; case 0x22: bhi(cpustate); break; case 0x23: bls(cpustate); break; case 0x24: bcc(cpustate); break; case 0x25: bcs(cpustate); break; case 0x26: bne(cpustate); break; case 0x27: beq(cpustate); break; case 0x28: bhcc(cpustate); break; case 0x29: bhcs(cpustate); break; case 0x2a: bpl(cpustate); break; case 0x2b: bmi(cpustate); break; case 0x2c: bmc(cpustate); break; case 0x2d: bms(cpustate); break; case 0x2e: bil(cpustate); break; case 0x2f: bih(cpustate); break; case 0x30: neg_di(cpustate); break; case 0x31: illegal(cpustate); break; case 0x32: illegal(cpustate); break; case 0x33: com_di(cpustate); break; case 0x34: lsr_di(cpustate); break; case 0x35: illegal(cpustate); break; case 0x36: ror_di(cpustate); break; case 0x37: asr_di(cpustate); break; case 0x38: lsl_di(cpustate); break; case 0x39: rol_di(cpustate); break; case 0x3a: dec_di(cpustate); break; case 0x3b: illegal(cpustate); break; case 0x3c: inc_di(cpustate); break; case 0x3d: tst_di(cpustate); break; case 0x3e: illegal(cpustate); break; case 0x3f: clr_di(cpustate); break; case 0x40: nega(cpustate); break; case 0x41: illegal(cpustate); break; case 0x42: illegal(cpustate); break; case 0x43: coma(cpustate); break; case 0x44: lsra(cpustate); break; case 0x45: illegal(cpustate); break; case 0x46: rora(cpustate); break; case 0x47: asra(cpustate); break; case 0x48: lsla(cpustate); break; case 0x49: rola(cpustate); break; case 0x4a: deca(cpustate); break; case 0x4b: illegal(cpustate); break; case 0x4c: inca(cpustate); break; case 0x4d: tsta(cpustate); break; case 0x4e: illegal(cpustate); break; case 0x4f: clra(cpustate); break; case 0x50: negx(cpustate); break; case 0x51: illegal(cpustate); break; case 0x52: illegal(cpustate); break; case 0x53: comx(cpustate); break; case 0x54: lsrx(cpustate); break; case 0x55: illegal(cpustate); break; case 0x56: rorx(cpustate); break; case 0x57: asrx(cpustate); break; case 0x58: aslx(cpustate); break; case 0x59: rolx(cpustate); break; case 0x5a: decx(cpustate); break; case 0x5b: illegal(cpustate); break; case 0x5c: incx(cpustate); break; case 0x5d: tstx(cpustate); break; case 0x5e: illegal(cpustate); break; case 0x5f: clrx(cpustate); break; case 0x60: neg_ix1(cpustate); break; case 0x61: illegal(cpustate); break; case 0x62: illegal(cpustate); break; case 0x63: com_ix1(cpustate); break; case 0x64: lsr_ix1(cpustate); break; case 0x65: illegal(cpustate); break; case 0x66: ror_ix1(cpustate); break; case 0x67: asr_ix1(cpustate); break; case 0x68: lsl_ix1(cpustate); break; case 0x69: rol_ix1(cpustate); break; case 0x6a: dec_ix1(cpustate); break; case 0x6b: illegal(cpustate); break; case 0x6c: inc_ix1(cpustate); break; case 0x6d: tst_ix1(cpustate); break; case 0x6e: illegal(cpustate); break; case 0x6f: clr_ix1(cpustate); break; case 0x70: neg_ix(cpustate); break; case 0x71: illegal(cpustate); break; case 0x72: illegal(cpustate); break; case 0x73: com_ix(cpustate); break; case 0x74: lsr_ix(cpustate); break; case 0x75: illegal(cpustate); break; case 0x76: ror_ix(cpustate); break; case 0x77: asr_ix(cpustate); break; case 0x78: lsl_ix(cpustate); break; case 0x79: rol_ix(cpustate); break; case 0x7a: dec_ix(cpustate); break; case 0x7b: illegal(cpustate); break; case 0x7c: inc_ix(cpustate); break; case 0x7d: tst_ix(cpustate); break; case 0x7e: illegal(cpustate); break; case 0x7f: clr_ix(cpustate); break; case 0x80: rti(cpustate); break; case 0x81: rts(cpustate); break; case 0x82: illegal(cpustate); break; case 0x83: swi(cpustate); break; case 0x84: illegal(cpustate); break; case 0x85: illegal(cpustate); break; case 0x86: illegal(cpustate); break; case 0x87: illegal(cpustate); break; case 0x88: illegal(cpustate); break; case 0x89: illegal(cpustate); break; case 0x8a: illegal(cpustate); break; case 0x8b: illegal(cpustate); break; case 0x8c: illegal(cpustate); break; case 0x8d: illegal(cpustate); break; case 0x8e: illegal(cpustate); break; case 0x8f: illegal(cpustate); break; case 0x90: illegal(cpustate); break; case 0x91: illegal(cpustate); break; case 0x92: illegal(cpustate); break; case 0x93: illegal(cpustate); break; case 0x94: illegal(cpustate); break; case 0x95: illegal(cpustate); break; case 0x96: illegal(cpustate); break; case 0x97: tax(cpustate); break; case 0x98: CLC; break; case 0x99: SEC; break; #if IRQ_LEVEL_DETECT case 0x9a: CLI; if (m6805.irq_state != CLEAR_LINE) m6805.pending_interrupts |= 1<<M6805_IRQ_LINE; break; #else case 0x9a: CLI; break; #endif case 0x9b: SEI; break; case 0x9c: rsp(cpustate); break; case 0x9d: nop(cpustate); break; case 0x9e: illegal(cpustate); break; case 0x9f: txa(cpustate); break; case 0xa0: suba_im(cpustate); break; case 0xa1: cmpa_im(cpustate); break; case 0xa2: sbca_im(cpustate); break; case 0xa3: cpx_im(cpustate); break; case 0xa4: anda_im(cpustate); break; case 0xa5: bita_im(cpustate); break; case 0xa6: lda_im(cpustate); break; case 0xa7: illegal(cpustate); break; case 0xa8: eora_im(cpustate); break; case 0xa9: adca_im(cpustate); break; case 0xaa: ora_im(cpustate); break; case 0xab: adda_im(cpustate); break; case 0xac: illegal(cpustate); break; case 0xad: bsr(cpustate); break; case 0xae: ldx_im(cpustate); break; case 0xaf: illegal(cpustate); break; case 0xb0: suba_di(cpustate); break; case 0xb1: cmpa_di(cpustate); break; case 0xb2: sbca_di(cpustate); break; case 0xb3: cpx_di(cpustate); break; case 0xb4: anda_di(cpustate); break; case 0xb5: bita_di(cpustate); break; case 0xb6: lda_di(cpustate); break; case 0xb7: sta_di(cpustate); break; case 0xb8: eora_di(cpustate); break; case 0xb9: adca_di(cpustate); break; case 0xba: ora_di(cpustate); break; case 0xbb: adda_di(cpustate); break; case 0xbc: jmp_di(cpustate); break; case 0xbd: jsr_di(cpustate); break; case 0xbe: ldx_di(cpustate); break; case 0xbf: stx_di(cpustate); break; case 0xc0: suba_ex(cpustate); break; case 0xc1: cmpa_ex(cpustate); break; case 0xc2: sbca_ex(cpustate); break; case 0xc3: cpx_ex(cpustate); break; case 0xc4: anda_ex(cpustate); break; case 0xc5: bita_ex(cpustate); break; case 0xc6: lda_ex(cpustate); break; case 0xc7: sta_ex(cpustate); break; case 0xc8: eora_ex(cpustate); break; case 0xc9: adca_ex(cpustate); break; case 0xca: ora_ex(cpustate); break; case 0xcb: adda_ex(cpustate); break; case 0xcc: jmp_ex(cpustate); break; case 0xcd: jsr_ex(cpustate); break; case 0xce: ldx_ex(cpustate); break; case 0xcf: stx_ex(cpustate); break; case 0xd0: suba_ix2(cpustate); break; case 0xd1: cmpa_ix2(cpustate); break; case 0xd2: sbca_ix2(cpustate); break; case 0xd3: cpx_ix2(cpustate); break; case 0xd4: anda_ix2(cpustate); break; case 0xd5: bita_ix2(cpustate); break; case 0xd6: lda_ix2(cpustate); break; case 0xd7: sta_ix2(cpustate); break; case 0xd8: eora_ix2(cpustate); break; case 0xd9: adca_ix2(cpustate); break; case 0xda: ora_ix2(cpustate); break; case 0xdb: adda_ix2(cpustate); break; case 0xdc: jmp_ix2(cpustate); break; case 0xdd: jsr_ix2(cpustate); break; case 0xde: ldx_ix2(cpustate); break; case 0xdf: stx_ix2(cpustate); break; case 0xe0: suba_ix1(cpustate); break; case 0xe1: cmpa_ix1(cpustate); break; case 0xe2: sbca_ix1(cpustate); break; case 0xe3: cpx_ix1(cpustate); break; case 0xe4: anda_ix1(cpustate); break; case 0xe5: bita_ix1(cpustate); break; case 0xe6: lda_ix1(cpustate); break; case 0xe7: sta_ix1(cpustate); break; case 0xe8: eora_ix1(cpustate); break; case 0xe9: adca_ix1(cpustate); break; case 0xea: ora_ix1(cpustate); break; case 0xeb: adda_ix1(cpustate); break; case 0xec: jmp_ix1(cpustate); break; case 0xed: jsr_ix1(cpustate); break; case 0xee: ldx_ix1(cpustate); break; case 0xef: stx_ix1(cpustate); break; case 0xf0: suba_ix(cpustate); break; case 0xf1: cmpa_ix(cpustate); break; case 0xf2: sbca_ix(cpustate); break; case 0xf3: cpx_ix(cpustate); break; case 0xf4: anda_ix(cpustate); break; case 0xf5: bita_ix(cpustate); break; case 0xf6: lda_ix(cpustate); break; case 0xf7: sta_ix(cpustate); break; case 0xf8: eora_ix(cpustate); break; case 0xf9: adca_ix(cpustate); break; case 0xfa: ora_ix(cpustate); break; case 0xfb: adda_ix(cpustate); break; case 0xfc: jmp_ix(cpustate); break; case 0xfd: jsr_ix(cpustate); break; case 0xfe: ldx_ix(cpustate); break; case 0xff: stx_ix(cpustate); break; } cpustate->iCount -= cycles1[ireg]; } while( cpustate->iCount > 0 ); }