bool can_be_mfc_app() { netnode importz("$ imports"); if (importz != BADNODE) for (ulong ndx = importz.sup1st(); ndx != BADNODE; ndx = importz.supnxt(ndx)) try { char impname[MAXSPECSIZE]; if (importz.supstr(ndx, CPY(impname)) > 0 && pcre_match("^mfc\\d{2,}", impname, PCRE_CASELESS)) return true; // assumed by imported rtl #ifdef _DEBUG } catch (const std::exception &e) { _RPT3(_CRT_ERROR, "%s(...): %s on iterating import node: index=0x%IX\n", __FUNCTION__, e.what(), ndx); #endif // _DEBUG } catch (...) { _RPT3(_CRT_ERROR, "%s(...): %s on iterating import node: index=0x%IX\n", __FUNCTION__, "unknown exception", ndx); } char buf[MAXSPECSIZE/*??*/]; ulong total(0); for (int counter = 0; counter < get_idasgn_qty(); ++counter) { const long applieds(get_idasgn_desc(counter, CPY(buf), NULL, 0)); if (applieds != -1 && pcre_match("^vc(?:32|64)mfc", buf, PCRE_CASELESS)) switch (calc_idasgn_state(counter)) { case IDASGN_APPLIED: total += applieds; break; case IDASGN_CURRENT: case IDASGN_PLANNED: return true; } } return total > 0; }
Attachable::Attachable(const char *filename) { d_filename = CPY(filename); char *lastslash; lastslash = strrchr(d_filename, '/'); if (!lastslash) { lastslash = d_filename; d_path = CPY("./"); } else { char ch = *lastslash; *lastslash = '\0'; // temporarily terminate at / and copy d_path = CPY(d_filename); *lastslash = ch; lastslash++; } // Choice label is everything after last '/' without ending d_choiceLabel = CPY(lastslash); char *ending = strstr(d_choiceLabel, ".obj"); if (!ending) ending = strstr(d_choiceLabel, ".OBJ"); if (!ending) ending = strstr(d_choiceLabel, ".Obj"); if (ending) *ending = '\0'; }
BitmapText &BitmapText::operator =( const BitmapText &cpy ) { #define CPY(a) a = cpy.a CPY( m_sText ); CPY( m_wTextLines ); CPY( m_iLineWidths ); CPY( m_iWrapWidthPixels ); CPY( m_fMaxWidth ); CPY( m_fMaxHeight ); CPY( m_bRainbow ); // CPY( m_bJitter ); // CPY( m_iVertSpacing ); CPY( m_aVertices ); CPY( m_pTextures ); // CPY( m_bHasGlowAttribute ); // CPY( m_mAttributes ); #undef CPY if( m_pFont ) FONT->UnloadFont( m_pFont ); if( cpy.m_pFont != NULL ) m_pFont = FONT->CopyFont( cpy.m_pFont ); else m_pFont = NULL; return *this; }
n4 sp_sc_ring_pop(vp ring_ptr, vp elem) { u4 ridx; u4 widx; ring_p ring; ring = ring_ptr; ridx = ring->read_pos; widx = ring->write_pos; // the ring is empty if (IS_EQ(ring_index(ridx, ring->unit_num), ring_index(widx, ring->unit_num))) { // RET_INT(-2, "push widx = %u, ridx = %u", widx, ridx); RET_INT(-2, nil_str); } CPY(elem, ring->data + ring_index(ridx, ring->unit_num) * ring->unit_size, ring->unit_size); // lisk_sync_add(ring->read_pos, 1); // lisk_sync_sub(ring->size, 1); ring->read_pos++; ring->size++; RET_INT(0, nil_str); }
n4 mp_ring_push(vp ring_ptr, vp elem) { u4 ridx; u4 widx; ring_p ring; ridx = 0; widx = 0; ring = ring_ptr; do { ridx = ring->read_pos; widx = ring->write_pos; //the ring is full if (IS_EQ(ring_index(widx + 1, ring->unit_num), ring_index(ridx, ring->unit_num))) { // RET_INT(-2, "push widx = %u, ridx = %u", widx, ridx); RET_INT(-2, nil_str); } } while(IS_NEQ(lisk_sync_cas(ring->write_pos, widx, widx + 1), widx)); CPY(ring->data + ring_index(widx, ring->unit_num) * ring->unit_size, elem, ring->unit_size); while (IS_NEQ(lisk_sync_cas(ring->max_read_idx, widx, widx + 1), widx)) { sched_yield(); } lisk_sync_add(ring->size, 1); RET_INT(0, nil_str); }
n4 sp_ring_push(vp ring_ptr, vp elem) { u4 ridx; u4 widx; ring_p ring; ring = ring_ptr; ridx = ring->read_pos; widx = ring->write_pos; //the ring is full if (IS_EQ(ring_index(widx + 1, ring->unit_num), ring_index(ridx, ring->unit_num))) { // RET_INT(-2, "push widx = %u, ridx = %u", widx, ridx); RET_INT(-2, nil_str); } CPY(ring->data + ring_index(widx, ring->unit_num) * ring->unit_size, elem, ring->unit_size); lisk_sync_add(ring->write_pos, 1); lisk_sync_add(ring->size, 1); RET_INT(0, nil_str); }
n4 sp_mc_ring_pop(vp ring_ptr, vp elem) { u4 ridx; u4 widx; ring_p ring; ridx = 0; widx = 0; ring = ring_ptr; do { ridx = ring->read_pos; widx = ring->write_pos; // the ring is empty if (IS_EQ(ring_index(ridx, ring->unit_num), ring_index(widx, ring->unit_num))) { // RET_INT(-2, "push widx = %u, ridx = %u", widx, ridx); RET_INT(-2, nil_str); } CPY(elem, ring->data + ring_index(ridx, ring->unit_num) * ring->unit_size, ring->unit_size); if (IS_EQ(lisk_sync_cas(ring->read_pos, ridx, ridx + 1), ridx)) { lisk_sync_sub(ring->size, 1); RET_INT(0, nil_str); } } while(1); RET_INT(-2, nil_str); }
n4 mp_mc_ring_pop(vp ring_ptr, vp elem) { u4 ridx; u4 max_ridx; ring_p ring; ridx = 0; max_ridx = 0; ring = ring_ptr; do { ridx = ring->read_pos; max_ridx = ring->max_read_idx; // the ring is empty or a procuder has got space // from the ring and dumping data into it now if (IS_EQ(ring_index(ridx, ring->unit_num), ring_index(max_ridx, ring->unit_num))) { // RET_INT(-2, "push ridx = %u, max_ridx = %u", ridx, max_ridx); RET_INT(-2, nil_str); } CPY(elem, ring->data + ring_index(ridx, ring->unit_num) * ring->unit_size, ring->unit_size); if (IS_EQ(lisk_sync_cas(ring->read_pos, ridx, ridx + 1), ridx)) { lisk_sync_sub(ring->size, 1); RET_INT(0, nil_str); } } while(1); RET_INT(-2, nil_str); }
n4 mp_sc_ring_pop(vp ring_ptr, vp elem) { u4 ridx; u4 max_ridx; ring_p ring; ring = ring_ptr; ridx = ring->read_pos; max_ridx = ring->max_read_idx; // the ring is empty if (IS_EQ(ring_index(ridx, ring->unit_num), ring_index(max_ridx, ring->unit_num))) { // RET_INT(-2, "push ridx = %u, max_ridx = %u", ridx, max_ridx); RET_INT(-2, nil_str); } CPY(elem, ring->data + ring_index(ridx, ring->unit_num) * ring->unit_size, ring->unit_size); lisk_sync_add(ring->read_pos, 1); lisk_sync_sub(ring->size, 1); RET_INT(0, nil_str); }
void multi(int x[MAX][MAX], int y[MAX][MAX], int n) { int r[MAX][MAX] = {0}, i, j, k; i64 temp; for(i = 1; i <= n; i++) { for(j = 1; j <= n; j++) { for(k = 1; k <= n; k++) { temp = x[i][k]; temp *= y[k][j]; temp += r[i][j]; temp %= MOD; r[i][j] = temp; } } } CPY(x, r); }
ulong get_signature_state(const char *signame) { _ASSERTE(signame != 0 && *signame != 0); if (signame != 0 && *signame != 0) { std::string pattern(signame); const int extpos(pcre_match("\\.sig$", pattern.c_str(), PCRE_CASELESS)); if (extpos >= 0) pattern.erase(extpos); const PCRE::regexp regex(pattern.insert(0, "^\\Q").append("\\E(?:\\.sig)?$"), PCRE_CASELESS/*, true*/); if (!regex) throw fmt_exception("failed to compile regexp for \"%s\"", signame); char buf[MAXSPECSIZE/*??*/]; for (int counter = 0; counter < get_idasgn_qty(); ++counter) { const long applieds(get_idasgn_desc(counter, CPY(buf), NULL, 0)); if (applieds >= 0 && regex.match(buf)) { const ulong state(static_cast<ulong>(calc_idasgn_state(counter))); _ASSERTE(state <= 7); if (state == IDASGN_APPLIED || state == IDASGN_CURRENT || state == IDASGN_PLANNED) return static_cast<ulong>(applieds) & SIG_COUNT | (state & 7) << 29; } } } return (IDASGN_BADARG & 7) << 29; // signature not in list }
BitmapText & BitmapText::operator=(const BitmapText &cpy) { Actor::operator=(cpy); #define CPY(a) a = cpy.a CPY( m_bUppercase ); CPY( m_sText ); CPY( m_wTextLines ); CPY( m_iLineWidths ); CPY( m_iWrapWidthPixels ); CPY( m_fMaxWidth ); CPY( m_fMaxHeight ); CPY( m_bRainbowScroll ); CPY( m_bJitter ); CPY( m_fDistortion ); CPY( m_bUsingDistortion ); CPY( m_iVertSpacing ); CPY( m_aVertices ); CPY( m_vpFontPageTextures ); CPY( m_mAttributes ); CPY( m_bHasGlowAttribute ); CPY( m_StrokeColor ); #undef CPY if( m_pFont ) FONT->UnloadFont( m_pFont ); if( cpy.m_pFont != NULL ) m_pFont = FONT->CopyFont( cpy.m_pFont ); else m_pFont = NULL; return *this; }
ActorFrame::ActorFrame( const ActorFrame &cpy ): Actor( cpy ) { #define CPY(x) this->x = cpy.x; CPY( m_bPropagateCommands ); CPY( m_bDeleteChildren ); CPY( m_bDrawByZPosition ); CPY( m_DrawFunction ); CPY( m_UpdateFunction ); CPY( m_fUpdateRate ); CPY( m_fFOV ); CPY( m_fVanishX ); CPY( m_fVanishY ); CPY( m_bOverrideLighting ); CPY( m_bLighting ); CPY( m_ambientColor ); CPY( m_diffuseColor ); CPY( m_specularColor ); CPY( m_lightDirection ); #undef CPY /* If m_bDeleteChildren, we own our children and it's up to us to copy * them. If not, the derived class owns the children. This must preserve * the current order of m_SubActors. */ if( m_bDeleteChildren ) { for( unsigned i = 0; i < cpy.m_SubActors.size(); ++i ) { Actor *pActor = cpy.m_SubActors[i]->Copy(); this->AddChild( pActor ); } } }
Sprite::Sprite( const Sprite &cpy ): Actor( cpy ) { #define CPY(a) a = cpy.a CPY( m_States ); CPY(m_animation_length_seconds); CPY( m_iCurState ); CPY( m_fSecsIntoState ); CPY( m_bUsingCustomTexCoords ); CPY( m_bUsingCustomPosCoords ); CPY( m_bSkipNextUpdate ); CPY( m_DecodeMovie ); CPY( m_EffectMode ); memcpy( m_CustomTexCoords, cpy.m_CustomTexCoords, sizeof(m_CustomTexCoords) ); memcpy( m_CustomPosCoords, cpy.m_CustomPosCoords, sizeof(m_CustomPosCoords) ); CPY( m_fRememberedClipWidth ); CPY( m_fRememberedClipHeight ); CPY( m_fTexCoordVelocityX ); CPY( m_fTexCoordVelocityY ); #undef CPY if( cpy.m_pTexture != NULL ) m_pTexture = TEXTUREMAN->CopyTexture( cpy.m_pTexture ); else m_pTexture = NULL; }
/// Copy-Constructor: copy everything Attachable::Attachable(const Attachable &old) { d_filename = CPY(old.d_filename); d_choiceLabel = CPY(old.d_choiceLabel); d_path = CPY(old.d_path); }
// // 柦椷幚峴 // INT CPU::EXEC( INT request_cycles ) { BYTE opcode; // 僆儁僐乕僪 INT OLD_cycles = TOTAL_cycles; INT exec_cycles; BYTE nmi_request, irq_request; BOOL bClockProcess = m_bClockProcess; // TEMP register WORD EA; register WORD ET; register WORD WT; register BYTE DT; while( request_cycles > 0 ) { exec_cycles = 0; if( DMA_cycles ) { if( request_cycles <= DMA_cycles ) { DMA_cycles -= request_cycles; TOTAL_cycles += request_cycles; // 僋儘僢僋摨婜張棟 mapper->Clock( request_cycles ); #if DPCM_SYNCCLOCK apu->SyncDPCM( request_cycles ); #endif if( bClockProcess ) { nes->Clock( request_cycles ); } // nes->Clock( request_cycles ); goto _execute_exit; } else { exec_cycles += DMA_cycles; // request_cycles -= DMA_cycles; DMA_cycles = 0; } } nmi_request = irq_request = 0; opcode = OP6502( R.PC++ ); if( R.INT_pending ) { if( R.INT_pending & NMI_FLAG ) { nmi_request = 0xFF; R.INT_pending &= ~NMI_FLAG; } else if( R.INT_pending & IRQ_MASK ) { R.INT_pending &= ~IRQ_TRIGGER2; if( !(R.P & I_FLAG) && opcode != 0x40 ) { irq_request = 0xFF; R.INT_pending &= ~IRQ_TRIGGER; } } } //增加指令预测忽略功能 //opcode BYTE iInstructionLen =1; switch (TraceAddrMode[opcode]) { case IND: case ADR: case ABS: case ABX: case ABY: iInstructionLen = 3; break; case IMM: case ZPG: case ZPX: case ZPY: case INX: case INY: iInstructionLen = 2; break; case IMP:case ACC:case ERR: break; case REL:iInstructionLen = 2;break; } if( ((TraceArr[opcode][0]=='*') || (TraceArr[opcode][1]=='?'))&& (!Config.emulator.bIllegalOp) ) { //这里可以优化输出信息 //char str[111]; //DecodeInstruction (R.PC-1, str); //DEBUGOUT( "Bad Instruction:%s\n",str); R.PC=(R.PC-1)+iInstructionLen; ADD_CYCLE(iInstructionLen*2); goto end_is; } // switch( opcode ) { case 0x69: // ADC #$?? MR_IM(); ADC(); ADD_CYCLE(2); break; case 0x65: // ADC $?? MR_ZP(); ADC(); ADD_CYCLE(3); break; case 0x75: // ADC $??,X MR_ZX(); ADC(); ADD_CYCLE(4); break; case 0x6D: // ADC $???? MR_AB(); ADC(); ADD_CYCLE(4); break; case 0x7D: // ADC $????,X MR_AX(); ADC(); CHECK_EA(); ADD_CYCLE(4); break; case 0x79: // ADC $????,Y MR_AY(); ADC(); CHECK_EA(); ADD_CYCLE(4); break; case 0x61: // ADC ($??,X) MR_IX(); ADC(); ADD_CYCLE(6); break; case 0x71: // ADC ($??),Y MR_IY(); ADC(); CHECK_EA(); ADD_CYCLE(4); break; case 0xE9: // SBC #$?? MR_IM(); SBC(); ADD_CYCLE(2); break; case 0xE5: // SBC $?? MR_ZP(); SBC(); ADD_CYCLE(3); break; case 0xF5: // SBC $??,X MR_ZX(); SBC(); ADD_CYCLE(4); break; case 0xED: // SBC $???? MR_AB(); SBC(); ADD_CYCLE(4); break; case 0xFD: // SBC $????,X MR_AX(); SBC(); CHECK_EA(); ADD_CYCLE(4); break; case 0xF9: // SBC $????,Y MR_AY(); SBC(); CHECK_EA(); ADD_CYCLE(4); break; case 0xE1: // SBC ($??,X) MR_IX(); SBC(); ADD_CYCLE(6); break; case 0xF1: // SBC ($??),Y MR_IY(); SBC(); CHECK_EA(); ADD_CYCLE(5); break; case 0xC6: // DEC $?? MR_ZP(); DEC(); MW_ZP(); ADD_CYCLE(5); break; case 0xD6: // DEC $??,X MR_ZX(); DEC(); MW_ZP(); ADD_CYCLE(6); break; case 0xCE: // DEC $???? MR_AB(); DEC(); MW_EA(); ADD_CYCLE(6); break; case 0xDE: // DEC $????,X MR_AX(); DEC(); MW_EA(); ADD_CYCLE(7); break; case 0xCA: // DEX DEX(); ADD_CYCLE(2); break; case 0x88: // DEY DEY(); ADD_CYCLE(2); break; case 0xE6: // INC $?? MR_ZP(); INC(); MW_ZP(); ADD_CYCLE(5); break; case 0xF6: // INC $??,X MR_ZX(); INC(); MW_ZP(); ADD_CYCLE(6); break; case 0xEE: // INC $???? MR_AB(); INC(); MW_EA(); ADD_CYCLE(6); break; case 0xFE: // INC $????,X MR_AX(); INC(); MW_EA(); ADD_CYCLE(7); break; case 0xE8: // INX INX(); ADD_CYCLE(2); break; case 0xC8: // INY INY(); ADD_CYCLE(2); break; case 0x29: // AND #$?? MR_IM(); AND(); ADD_CYCLE(2); break; case 0x25: // AND $?? MR_ZP(); AND(); ADD_CYCLE(3); break; case 0x35: // AND $??,X MR_ZX(); AND(); ADD_CYCLE(4); break; case 0x2D: // AND $???? MR_AB(); AND(); ADD_CYCLE(4); break; case 0x3D: // AND $????,X MR_AX(); AND(); CHECK_EA(); ADD_CYCLE(4); break; case 0x39: // AND $????,Y MR_AY(); AND(); CHECK_EA(); ADD_CYCLE(4); break; case 0x21: // AND ($??,X) MR_IX(); AND(); ADD_CYCLE(6); break; case 0x31: // AND ($??),Y MR_IY(); AND(); CHECK_EA(); ADD_CYCLE(5); break; case 0x0A: // ASL A ASL_A(); ADD_CYCLE(2); break; case 0x06: // ASL $?? MR_ZP(); ASL(); MW_ZP(); ADD_CYCLE(5); break; case 0x16: // ASL $??,X MR_ZX(); ASL(); MW_ZP(); ADD_CYCLE(6); break; case 0x0E: // ASL $???? MR_AB(); ASL(); MW_EA(); ADD_CYCLE(6); break; case 0x1E: // ASL $????,X MR_AX(); ASL(); MW_EA(); ADD_CYCLE(7); break; case 0x24: // BIT $?? MR_ZP(); BIT(); ADD_CYCLE(3); break; case 0x2C: // BIT $???? MR_AB(); BIT(); ADD_CYCLE(4); break; case 0x49: // EOR #$?? MR_IM(); EOR(); ADD_CYCLE(2); break; case 0x45: // EOR $?? MR_ZP(); EOR(); ADD_CYCLE(3); break; case 0x55: // EOR $??,X MR_ZX(); EOR(); ADD_CYCLE(4); break; case 0x4D: // EOR $???? MR_AB(); EOR(); ADD_CYCLE(4); break; case 0x5D: // EOR $????,X MR_AX(); EOR(); CHECK_EA(); ADD_CYCLE(4); break; case 0x59: // EOR $????,Y MR_AY(); EOR(); CHECK_EA(); ADD_CYCLE(4); break; case 0x41: // EOR ($??,X) MR_IX(); EOR(); ADD_CYCLE(6); break; case 0x51: // EOR ($??),Y MR_IY(); EOR(); CHECK_EA(); ADD_CYCLE(5); break; case 0x4A: // LSR A LSR_A(); ADD_CYCLE(2); break; case 0x46: // LSR $?? MR_ZP(); LSR(); MW_ZP(); ADD_CYCLE(5); break; case 0x56: // LSR $??,X MR_ZX(); LSR(); MW_ZP(); ADD_CYCLE(6); break; case 0x4E: // LSR $???? MR_AB(); LSR(); MW_EA(); ADD_CYCLE(6); break; case 0x5E: // LSR $????,X MR_AX(); LSR(); MW_EA(); ADD_CYCLE(7); break; case 0x09: // ORA #$?? MR_IM(); ORA(); ADD_CYCLE(2); break; case 0x05: // ORA $?? MR_ZP(); ORA(); ADD_CYCLE(3); break; case 0x15: // ORA $??,X MR_ZX(); ORA(); ADD_CYCLE(4); break; case 0x0D: // ORA $???? MR_AB(); ORA(); ADD_CYCLE(4); break; case 0x1D: // ORA $????,X MR_AX(); ORA(); CHECK_EA(); ADD_CYCLE(4); break; case 0x19: // ORA $????,Y MR_AY(); ORA(); CHECK_EA(); ADD_CYCLE(4); break; case 0x01: // ORA ($??,X) MR_IX(); ORA(); ADD_CYCLE(6); break; case 0x11: // ORA ($??),Y MR_IY(); ORA(); CHECK_EA(); ADD_CYCLE(5); break; case 0x2A: // ROL A ROL_A(); ADD_CYCLE(2); break; case 0x26: // ROL $?? MR_ZP(); ROL(); MW_ZP(); ADD_CYCLE(5); break; case 0x36: // ROL $??,X MR_ZX(); ROL(); MW_ZP(); ADD_CYCLE(6); break; case 0x2E: // ROL $???? MR_AB(); ROL(); MW_EA(); ADD_CYCLE(6); break; case 0x3E: // ROL $????,X MR_AX(); ROL(); MW_EA(); ADD_CYCLE(7); break; case 0x6A: // ROR A ROR_A(); ADD_CYCLE(2); break; case 0x66: // ROR $?? MR_ZP(); ROR(); MW_ZP(); ADD_CYCLE(5); break; case 0x76: // ROR $??,X MR_ZX(); ROR(); MW_ZP(); ADD_CYCLE(6); break; case 0x6E: // ROR $???? MR_AB(); ROR(); MW_EA(); ADD_CYCLE(6); break; case 0x7E: // ROR $????,X MR_AX(); ROR(); MW_EA(); ADD_CYCLE(7); break; case 0xA9: // LDA #$?? MR_IM(); LDA(); ADD_CYCLE(2); break; case 0xA5: // LDA $?? MR_ZP(); LDA(); ADD_CYCLE(3); break; case 0xB5: // LDA $??,X MR_ZX(); LDA(); ADD_CYCLE(4); break; case 0xAD: // LDA $???? MR_AB(); LDA(); ADD_CYCLE(4); break; case 0xBD: // LDA $????,X MR_AX(); LDA(); CHECK_EA(); ADD_CYCLE(4); break; case 0xB9: // LDA $????,Y MR_AY(); LDA(); CHECK_EA(); ADD_CYCLE(4); break; case 0xA1: // LDA ($??,X) MR_IX(); LDA(); ADD_CYCLE(6); break; case 0xB1: // LDA ($??),Y MR_IY(); LDA(); CHECK_EA(); ADD_CYCLE(5); break; case 0xA2: // LDX #$?? MR_IM(); LDX(); ADD_CYCLE(2); break; case 0xA6: // LDX $?? MR_ZP(); LDX(); ADD_CYCLE(3); break; case 0xB6: // LDX $??,Y MR_ZY(); LDX(); ADD_CYCLE(4); break; case 0xAE: // LDX $???? MR_AB(); LDX(); ADD_CYCLE(4); break; case 0xBE: // LDX $????,Y MR_AY(); LDX(); CHECK_EA(); ADD_CYCLE(4); break; case 0xA0: // LDY #$?? MR_IM(); LDY(); ADD_CYCLE(2); break; case 0xA4: // LDY $?? MR_ZP(); LDY(); ADD_CYCLE(3); break; case 0xB4: // LDY $??,X MR_ZX(); LDY(); ADD_CYCLE(4); break; case 0xAC: // LDY $???? MR_AB(); LDY(); ADD_CYCLE(4); break; case 0xBC: // LDY $????,X MR_AX(); LDY(); CHECK_EA(); ADD_CYCLE(4); break; case 0x85: // STA $?? EA_ZP(); STA(); MW_ZP(); ADD_CYCLE(3); break; case 0x95: // STA $??,X EA_ZX(); STA(); MW_ZP(); ADD_CYCLE(4); break; case 0x8D: // STA $???? EA_AB(); STA(); MW_EA(); ADD_CYCLE(4); break; case 0x9D: // STA $????,X EA_AX(); STA(); MW_EA(); ADD_CYCLE(5); break; case 0x99: // STA $????,Y EA_AY(); STA(); MW_EA(); ADD_CYCLE(5); break; case 0x81: // STA ($??,X) EA_IX(); STA(); MW_EA(); ADD_CYCLE(6); break; case 0x91: // STA ($??),Y EA_IY(); STA(); MW_EA(); ADD_CYCLE(6); break; case 0x86: // STX $?? EA_ZP(); STX(); MW_ZP(); ADD_CYCLE(3); break; case 0x96: // STX $??,Y EA_ZY(); STX(); MW_ZP(); ADD_CYCLE(4); break; case 0x8E: // STX $???? EA_AB(); STX(); MW_EA(); ADD_CYCLE(4); break; case 0x84: // STY $?? EA_ZP(); STY(); MW_ZP(); ADD_CYCLE(3); break; case 0x94: // STY $??,X EA_ZX(); STY(); MW_ZP(); ADD_CYCLE(4); break; case 0x8C: // STY $???? EA_AB(); STY(); MW_EA(); ADD_CYCLE(4); break; case 0xAA: // TAX TAX(); ADD_CYCLE(2); break; case 0x8A: // TXA TXA(); ADD_CYCLE(2); break; case 0xA8: // TAY TAY(); ADD_CYCLE(2); break; case 0x98: // TYA TYA(); ADD_CYCLE(2); break; case 0xBA: // TSX TSX(); ADD_CYCLE(2); break; case 0x9A: // TXS TXS(); ADD_CYCLE(2); break; case 0xC9: // CMP #$?? MR_IM(); CMP_(); ADD_CYCLE(2); break; case 0xC5: // CMP $?? MR_ZP(); CMP_(); ADD_CYCLE(3); break; case 0xD5: // CMP $??,X MR_ZX(); CMP_(); ADD_CYCLE(4); break; case 0xCD: // CMP $???? MR_AB(); CMP_(); ADD_CYCLE(4); break; case 0xDD: // CMP $????,X MR_AX(); CMP_(); CHECK_EA(); ADD_CYCLE(4); break; case 0xD9: // CMP $????,Y MR_AY(); CMP_(); CHECK_EA(); ADD_CYCLE(4); break; case 0xC1: // CMP ($??,X) MR_IX(); CMP_(); ADD_CYCLE(6); break; case 0xD1: // CMP ($??),Y MR_IY(); CMP_(); CHECK_EA(); ADD_CYCLE(5); break; case 0xE0: // CPX #$?? MR_IM(); CPX(); ADD_CYCLE(2); break; case 0xE4: // CPX $?? MR_ZP(); CPX(); ADD_CYCLE(3); break; case 0xEC: // CPX $???? MR_AB(); CPX(); ADD_CYCLE(4); break; case 0xC0: // CPY #$?? MR_IM(); CPY(); ADD_CYCLE(2); break; case 0xC4: // CPY $?? MR_ZP(); CPY(); ADD_CYCLE(3); break; case 0xCC: // CPY $???? MR_AB(); CPY(); ADD_CYCLE(4); break; case 0x90: // BCC MR_IM(); BCC(); ADD_CYCLE(2); break; case 0xB0: // BCS MR_IM(); BCS(); ADD_CYCLE(2); break; case 0xF0: // BEQ MR_IM(); BEQ(); ADD_CYCLE(2); break; case 0x30: // BMI MR_IM(); BMI(); ADD_CYCLE(2); break; case 0xD0: // BNE MR_IM(); BNE(); ADD_CYCLE(2); break; case 0x10: // BPL MR_IM(); BPL(); ADD_CYCLE(2); break; case 0x50: // BVC MR_IM(); BVC(); ADD_CYCLE(2); break; case 0x70: // BVS MR_IM(); BVS(); ADD_CYCLE(2); break; case 0x4C: // JMP $???? JMP(); ADD_CYCLE(3); break; case 0x6C: // JMP ($????) JMP_ID(); ADD_CYCLE(5); break; case 0x20: // JSR JSR(); ADD_CYCLE(6); break; case 0x40: // RTI RTI(); ADD_CYCLE(6); break; case 0x60: // RTS RTS(); ADD_CYCLE(6); break; // 僼儔僌惂屼宯 case 0x18: // CLC CLC(); ADD_CYCLE(2); break; case 0xD8: // CLD CLD(); ADD_CYCLE(2); break; case 0x58: // CLI CLI(); ADD_CYCLE(2); break; case 0xB8: // CLV CLV(); ADD_CYCLE(2); break; case 0x38: // SEC SEC(); ADD_CYCLE(2); break; case 0xF8: // SED SED(); ADD_CYCLE(2); break; case 0x78: // SEI SEI(); ADD_CYCLE(2); break; // 僗僞僢僋宯 case 0x48: // PHA PUSH( R.A ); ADD_CYCLE(3); break; case 0x08: // PHP PUSH( R.P | B_FLAG ); ADD_CYCLE(3); break; case 0x68: // PLA (N-----Z-) R.A = POP(); SET_ZN_FLAG(R.A); ADD_CYCLE(4); break; case 0x28: // PLP R.P = POP() | R_FLAG; ADD_CYCLE(4); break; // 偦偺懠 case 0x00: // BRK BRK(); ADD_CYCLE(7); break; case 0xEA: // NOP ADD_CYCLE(2); break; // 枹岞奐柦椷孮 case 0x0B: // ANC #$?? case 0x2B: // ANC #$?? MR_IM(); ANC(); ADD_CYCLE(2); break; case 0x8B: // ANE #$?? MR_IM(); ANE(); ADD_CYCLE(2); break; case 0x6B: // ARR #$?? MR_IM(); ARR(); ADD_CYCLE(2); break; case 0x4B: // ASR #$?? MR_IM(); ASR(); ADD_CYCLE(2); break; case 0xC7: // DCP $?? MR_ZP(); DCP(); MW_ZP(); ADD_CYCLE(5); break; case 0xD7: // DCP $??,X MR_ZX(); DCP(); MW_ZP(); ADD_CYCLE(6); break; case 0xCF: // DCP $???? MR_AB(); DCP(); MW_EA(); ADD_CYCLE(6); break; case 0xDF: // DCP $????,X MR_AX(); DCP(); MW_EA(); ADD_CYCLE(7); break; case 0xDB: // DCP $????,Y MR_AY(); DCP(); MW_EA(); ADD_CYCLE(7); break; case 0xC3: // DCP ($??,X) MR_IX(); DCP(); MW_EA(); ADD_CYCLE(8); break; case 0xD3: // DCP ($??),Y MR_IY(); DCP(); MW_EA(); ADD_CYCLE(8); break; case 0xE7: // ISB $?? MR_ZP(); ISB(); MW_ZP(); ADD_CYCLE(5); break; case 0xF7: // ISB $??,X MR_ZX(); ISB(); MW_ZP(); ADD_CYCLE(5); break; case 0xEF: // ISB $???? MR_AB(); ISB(); MW_EA(); ADD_CYCLE(5); break; case 0xFF: // ISB $????,X MR_AX(); ISB(); MW_EA(); ADD_CYCLE(5); break; case 0xFB: // ISB $????,Y MR_AY(); ISB(); MW_EA(); ADD_CYCLE(5); break; case 0xE3: // ISB ($??,X) MR_IX(); ISB(); MW_EA(); ADD_CYCLE(5); break; case 0xF3: // ISB ($??),Y MR_IY(); ISB(); MW_EA(); ADD_CYCLE(5); break; case 0xBB: // LAS $????,Y MR_AY(); LAS(); CHECK_EA(); ADD_CYCLE(4); break; case 0xA7: // LAX $?? MR_ZP(); LAX(); ADD_CYCLE(3); break; case 0xB7: // LAX $??,Y MR_ZY(); LAX(); ADD_CYCLE(4); break; case 0xAF: // LAX $???? MR_AB(); LAX(); ADD_CYCLE(4); break; case 0xBF: // LAX $????,Y MR_AY(); LAX(); CHECK_EA(); ADD_CYCLE(4); break; case 0xA3: // LAX ($??,X) MR_IX(); LAX(); ADD_CYCLE(6); break; case 0xB3: // LAX ($??),Y MR_IY(); LAX(); CHECK_EA(); ADD_CYCLE(5); break; case 0xAB: // LXA #$?? MR_IM(); LXA(); ADD_CYCLE(2); break; case 0x27: // RLA $?? MR_ZP(); RLA(); MW_ZP(); ADD_CYCLE(5); break; case 0x37: // RLA $??,X MR_ZX(); RLA(); MW_ZP(); ADD_CYCLE(6); break; case 0x2F: // RLA $???? MR_AB(); RLA(); MW_EA(); ADD_CYCLE(6); break; case 0x3F: // RLA $????,X MR_AX(); RLA(); MW_EA(); ADD_CYCLE(7); break; case 0x3B: // RLA $????,Y MR_AY(); RLA(); MW_EA(); ADD_CYCLE(7); break; case 0x23: // RLA ($??,X) MR_IX(); RLA(); MW_EA(); ADD_CYCLE(8); break; case 0x33: // RLA ($??),Y MR_IY(); RLA(); MW_EA(); ADD_CYCLE(8); break; case 0x67: // RRA $?? MR_ZP(); RRA(); MW_ZP(); ADD_CYCLE(5); break; case 0x77: // RRA $??,X MR_ZX(); RRA(); MW_ZP(); ADD_CYCLE(6); break; case 0x6F: // RRA $???? MR_AB(); RRA(); MW_EA(); ADD_CYCLE(6); break; case 0x7F: // RRA $????,X MR_AX(); RRA(); MW_EA(); ADD_CYCLE(7); break; case 0x7B: // RRA $????,Y MR_AY(); RRA(); MW_EA(); ADD_CYCLE(7); break; case 0x63: // RRA ($??,X) MR_IX(); RRA(); MW_EA(); ADD_CYCLE(8); break; case 0x73: // RRA ($??),Y MR_IY(); RRA(); MW_EA(); ADD_CYCLE(8); break; case 0x87: // SAX $?? MR_ZP(); SAX(); MW_ZP(); ADD_CYCLE(3); break; case 0x97: // SAX $??,Y MR_ZY(); SAX(); MW_ZP(); ADD_CYCLE(4); break; case 0x8F: // SAX $???? MR_AB(); SAX(); MW_EA(); ADD_CYCLE(4); break; case 0x83: // SAX ($??,X) MR_IX(); SAX(); MW_EA(); ADD_CYCLE(6); break; case 0xCB: // SBX #$?? MR_IM(); SBX(); ADD_CYCLE(2); break; case 0x9F: // SHA $????,Y MR_AY(); SHA(); MW_EA(); ADD_CYCLE(5); break; case 0x93: // SHA ($??),Y MR_IY(); SHA(); MW_EA(); ADD_CYCLE(6); break; case 0x9B: // SHS $????,Y MR_AY(); SHS(); MW_EA(); ADD_CYCLE(5); break; case 0x9E: // SHX $????,Y MR_AY(); SHX(); MW_EA(); ADD_CYCLE(5); break; case 0x9C: // SHY $????,X MR_AX(); SHY(); MW_EA(); ADD_CYCLE(5); break; case 0x07: // SLO $?? MR_ZP(); SLO(); MW_ZP(); ADD_CYCLE(5); break; case 0x17: // SLO $??,X MR_ZX(); SLO(); MW_ZP(); ADD_CYCLE(6); break; case 0x0F: // SLO $???? MR_AB(); SLO(); MW_EA(); ADD_CYCLE(6); break; case 0x1F: // SLO $????,X MR_AX(); SLO(); MW_EA(); ADD_CYCLE(7); break; case 0x1B: // SLO $????,Y MR_AY(); SLO(); MW_EA(); ADD_CYCLE(7); break; case 0x03: // SLO ($??,X) MR_IX(); SLO(); MW_EA(); ADD_CYCLE(8); break; case 0x13: // SLO ($??),Y MR_IY(); SLO(); MW_EA(); ADD_CYCLE(8); break; case 0x47: // SRE $?? MR_ZP(); SRE(); MW_ZP(); ADD_CYCLE(5); break; case 0x57: // SRE $??,X MR_ZX(); SRE(); MW_ZP(); ADD_CYCLE(6); break; case 0x4F: // SRE $???? MR_AB(); SRE(); MW_EA(); ADD_CYCLE(6); break; case 0x5F: // SRE $????,X MR_AX(); SRE(); MW_EA(); ADD_CYCLE(7); break; case 0x5B: // SRE $????,Y MR_AY(); SRE(); MW_EA(); ADD_CYCLE(7); break; case 0x43: // SRE ($??,X) MR_IX(); SRE(); MW_EA(); ADD_CYCLE(8); break; case 0x53: // SRE ($??),Y MR_IY(); SRE(); MW_EA(); ADD_CYCLE(8); break; case 0xEB: // SBC #$?? (Unofficial) MR_IM(); SBC(); ADD_CYCLE(2); break; case 0x1A: // NOP (Unofficial) case 0x3A: // NOP (Unofficial) case 0x5A: // NOP (Unofficial) case 0x7A: // NOP (Unofficial) case 0xDA: // NOP (Unofficial) case 0xFA: // NOP (Unofficial) ADD_CYCLE(2); break; case 0x80: // DOP (CYCLES 2) case 0x82: // DOP (CYCLES 2) case 0x89: // DOP (CYCLES 2) case 0xC2: // DOP (CYCLES 2) case 0xE2: // DOP (CYCLES 2) R.PC++; ADD_CYCLE(2); break; case 0x04: // DOP (CYCLES 3) case 0x44: // DOP (CYCLES 3) case 0x64: // DOP (CYCLES 3) R.PC++; ADD_CYCLE(3); break; case 0x14: // DOP (CYCLES 4) case 0x34: // DOP (CYCLES 4) case 0x54: // DOP (CYCLES 4) case 0x74: // DOP (CYCLES 4) case 0xD4: // DOP (CYCLES 4) case 0xF4: // DOP (CYCLES 4) R.PC++; ADD_CYCLE(4); break; case 0x0C: // TOP case 0x1C: // TOP case 0x3C: // TOP case 0x5C: // TOP case 0x7C: // TOP case 0xDC: // TOP case 0xFC: // TOP R.PC+=2; ADD_CYCLE(4); break; case 0x02: /* JAM */ case 0x12: /* JAM */ case 0x22: /* JAM */ case 0x32: /* JAM */ case 0x42: /* JAM */ case 0x52: /* JAM */ case 0x62: /* JAM */ case 0x72: /* JAM */ case 0x92: /* JAM */ case 0xB2: /* JAM */ case 0xD2: /* JAM */ case 0xF2: /* JAM */ default: if( !Config.emulator.bIllegalOp ) { throw CApp::GetErrorString( IDS_ERROR_ILLEGALOPCODE ); goto _execute_exit; } else { R.PC--; ADD_CYCLE(4); } break; // default: // __assume(0); } end_is: __asm nop; if( nmi_request ) { _NMI(); } else if( irq_request ) { _IRQ(); } request_cycles -= exec_cycles; TOTAL_cycles += exec_cycles; // 僋儘僢僋摨婜張棟 mapper->Clock( exec_cycles ); #if DPCM_SYNCCLOCK apu->SyncDPCM( exec_cycles ); #endif if( bClockProcess ) { nes->Clock( exec_cycles ); } // nes->Clock( exec_cycles ); } _execute_exit: #if !DPCM_SYNCCLOCK apu->SyncDPCM( TOTAL_cycles - OLD_cycles ); #endif return TOTAL_cycles - OLD_cycles; }
bool has_meaningful_name(ea_t ea) { _ASSERTE(isEnabled(ea)); char tmp[MAXNAMESIZE]; return has_name(get_flags_novalue(ea)) && get_true_name(BADADDR, ea, CPY(tmp)) != 0 && !pcre_match("^unknown_libname_\\d+$", tmp); }
INT_PTR CALLBACK CFileGroups::DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { // OutputDebugString("%s(%08X, %s, %08X, %08X)", __FUNCTION__, hwndDlg, // GetMessageName(uMsg), wParam, lParam); static filegroups_t *pfile_groups(0); static HWND hwndTVCtrl, hwndEditCtrl; OPENFILENAME ofn; TVINSERTSTRUCT tvis; TVITEMEX tvi; HTREEITEM hti, hParent, hGroup, hChild, hSel; char text[MAX_PATH], drive[_MAX_DRIVE], dir[_MAX_DIR], path[QMAXPATH], ext[_MAX_EXT]; BOOL hasSelection; switch (uMsg) { case WM_INITDIALOG: { _ASSERTE(lParam != 0); if (lParam == 0) { EndDialog(hwndDlg, IDCANCEL); return FALSE; } pfile_groups = reinterpret_cast<filegroups_t *>(lParam); hwndTVCtrl = GetDlgItem(hwndDlg, IDC_GROUPVWR); _ASSERTE(hwndTVCtrl != 0); if (hwndTVCtrl == NULL) { EndDialog(hwndDlg, IDCANCEL); return FALSE; } hwndEditCtrl = NULL; for (filegroups_t::const_iterator i = pfile_groups->begin(); i != pfile_groups->end(); ++i) { tvis.hParent = TVI_ROOT; tvis.hInsertAfter = TVI_SORT; tvis.itemex.mask = TVIF_STATE | TVIF_TEXT; tvis.itemex.state = 0; //TVIS_EXPANDED; tvis.itemex.stateMask = 0; tvis.itemex.pszText = const_cast<LPTSTR>(i->first.c_str()); hParent = TreeView_InsertItem(hwndTVCtrl, &tvis); _ASSERTE(hParent != NULL); if (hParent == NULL) continue; for (filegroups_t::mapped_type::const_iterator j = i->second.begin(); j != i->second.end(); ++j) { tvis.hParent = hParent; tvis.hInsertAfter = TVI_SORT; tvis.itemex.mask = TVIF_TEXT; tvis.itemex.pszText = const_cast<LPTSTR>(j->c_str()); hti = TreeView_InsertItem(hwndTVCtrl, &tvis); _ASSERTE(hti != NULL); } EnableDlgItem(hwndDlg, IDADD, TreeView_GetCount(hwndTVCtrl) > 0); EnableDlgItem(hwndDlg, IDREMOVE, TreeView_GetSelection(hwndTVCtrl) != 0); } static const tooltip_item_t tooltips[] = { IDC_GROUPVWR, "You can edit group names or filenames inplace by left clicking or pressing F2 on selected item", }; HWND hwndTT(CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, NULL, WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP | TTS_BALLOON, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, hwndDlg, NULL, hInstance, NULL)); SetWindowPos(hwndTT, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); SendMessage(hwndTT, TTM_SETMAXTIPWIDTH, 0, static_cast<LPARAM>(400)); SendMessage(hwndTT, TTM_SETDELAYTIME, static_cast<WPARAM>(TTDT_AUTOPOP), static_cast<LPARAM>(20000)); TOOLINFO tt; memset(&tt, 0, sizeof tt); tt.cbSize = sizeof tt; tt.uFlags = TTF_SUBCLASS | TTF_IDISHWND | TTF_TRANSPARENT; tt.hwnd = hwndDlg; tt.hinst = hInstance; for (UINT j = 0; j < qnumber(tooltips); ++j) { tt.uId = reinterpret_cast<UINT_PTR>(GetDlgItem(hwndDlg, tooltips[j].uID)); tt.lpszText = const_cast<LPTSTR>(tooltips[j].lpText); SendMessage(hwndTT, TTM_ADDTOOL, 0, reinterpret_cast<LPARAM>(&tt)); } return TRUE; } case WM_CLOSE: EndDialog(hwndDlg, LOWORD(wParam)); return TRUE; case WM_COMMAND: //if (hwndEditCtrl != NULL) return FALSE; switch (HIWORD(wParam)) { case BN_CLICKED: switch (LOWORD(wParam)) { case IDOK: if (hwndEditCtrl != NULL) { TreeView_EndEditLabelNow(hwndTVCtrl, FALSE); SetWindowLong(hwndDlg, DWL_MSGRESULT, TRUE); return TRUE; } _ASSERTE(pfile_groups != 0); pfile_groups->clear(); for (hGroup = TreeView_GetRoot(hwndTVCtrl); hGroup != NULL; hGroup = TreeView_GetNextSibling(hwndTVCtrl, hGroup)) { tvi.mask = TVIF_HANDLE | TVIF_TEXT; tvi.hItem = hGroup; tvi.pszText = text; tvi.cchTextMax = sizeof text; if (TreeView_GetItem(hwndTVCtrl, &tvi)) { filegroups_t::iterator i(pfile_groups->insert(pfile_groups->begin(), filegroups_t::value_type(text, filegroups_t::mapped_type()))); _ASSERTE(i != pfile_groups->end()); filegroups_t::mapped_type * pcurrentset(i != pfile_groups->end() ? &i->second : 0); if (pcurrentset != 0) for (hChild = TreeView_GetChild(hwndTVCtrl, hGroup); hChild != NULL; hChild = TreeView_GetNextSibling(hwndTVCtrl, hChild)) { tvi.mask = TVIF_HANDLE | TVIF_TEXT; tvi.hItem = hChild; tvi.pszText = text; tvi.cchTextMax = sizeof text; if (TreeView_GetItem(hwndTVCtrl, &tvi)) { /*if (qfileexist(text)) */pcurrentset->insert(text); } #ifdef _DEBUG else _RPTF3(_CRT_ERROR, "%s(%08X, WM_COMMAND, ...): TreeView_GetItem(%08X, ...) returned NULL\n", __FUNCTION__, hwndDlg, hwndTVCtrl); #endif // _DEBUG } } #ifdef _DEBUG else _RPTF3(_CRT_ERROR, "%s(%08X, WM_COMMAND, ...): TreeView_GetItem(%08X, ...) returned NULL\n", __FUNCTION__, hwndDlg, hwndTVCtrl); #endif // _DEBUG } case IDCANCEL: if (hwndEditCtrl != NULL) TreeView_EndEditLabelNow(hwndTVCtrl, TRUE); else EndDialog(hwndDlg, LOWORD(wParam)); SetWindowLong(hwndDlg, DWL_MSGRESULT, 0); return TRUE; case IDADD: { hSel = TreeView_GetSelection(hwndTVCtrl); if (hSel == NULL) hSel = TreeView_GetRoot(hwndTVCtrl); if (hSel != NULL) { hGroup = TreeView_GetParent(hwndTVCtrl, hSel); if (hGroup == NULL) hGroup = hSel; memset(&ofn, 0, sizeof ofn); ofn.lStructSize = sizeof ofn; ofn.hInstance = hInstance; ofn.hwndOwner = hwndDlg; ofn.lpstrTitle = CFileGroups::lpstrTitle; boost::scoped_array<char> FileName(new char[0x10000]); if (!FileName) { _RPTF2(_CRT_ERROR, "%s(...): failed to allocate new string of size 0x%X\n", __FUNCTION__, 0x10000); SetWindowLong(hwndDlg, DWL_MSGRESULT, 0); throw std::bad_alloc(); //break; } FileName[0] = 0; ofn.lpstrFile = FileName.get(); ofn.nMaxFile = 0x10000; ofn.Flags = OFN_ENABLESIZING | OFN_EXPLORER | OFN_FORCESHOWHIDDEN | OFN_LONGNAMES | OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_ALLOWMULTISELECT; ofn.lpstrFilter = CFileGroups::lpstrFilter; ofn.nFilterIndex = CFileGroups::nFilterIndex; ofn.lpstrDefExt = CFileGroups::lpstrDefExt; get_input_file_path(CPY(path)); _splitpath(path, drive, dir, 0, 0); _makepath(path, drive, dir, 0, 0); ofn.lpstrInitialDir = path; ofn.nMaxFile = 0x10000; if (GetOpenFileName(&ofn)) if (ofn.nFileOffset > strlen(ofn.lpstrFile)) while (*(ofn.lpstrFile + ofn.nFileOffset)) { AddFile(hwndTVCtrl, hGroup, _sprintf("%s\\%s", ofn.lpstrFile, ofn.lpstrFile + ofn.nFileOffset).c_str()); ofn.nFileOffset += strlen(ofn.lpstrFile + ofn.nFileOffset) + 1; } else AddFile(hwndTVCtrl, hGroup, ofn.lpstrFile); EnableDlgItem(hwndDlg, IDADD, TRUE); EnableDlgItem(hwndDlg, IDREMOVE, TreeView_GetSelection(hwndTVCtrl) != 0); } SetWindowLong(hwndDlg, DWL_MSGRESULT, 0); return TRUE; } case IDADDGROUP: { char *newgroup(askstr(HIST_IDENT, NULL, "New group name")); if (newgroup != 0 && strlen(newgroup) > 0) { if (strlen(newgroup) >= MAX_PATH) newgroup[MAX_PATH - 1] = 0; for (hGroup = TreeView_GetRoot(hwndTVCtrl); hGroup != NULL; hGroup = TreeView_GetNextSibling(hwndTVCtrl, hGroup)) { tvi.mask = TVIF_HANDLE | TVIF_TEXT; tvi.hItem = hGroup; tvi.pszText = text; tvi.cchTextMax = sizeof text; if (TreeView_GetItem(hwndTVCtrl, &tvi)) { if (strcmp(newgroup, text) == 0) { warning("Group with this name already exists"); SetWindowLong(hwndDlg, DWL_MSGRESULT, 0); return FALSE; } } #ifdef _DEBUG else _RPTF3(_CRT_ERROR, "%s(%08X, WM_COMMAND, ...): TreeView_GetItem(%08X, ...) returned NULL\n", __FUNCTION__, hwndDlg, hwndTVCtrl); #endif // _DEBUG } tvis.hParent = TVI_ROOT; tvis.hInsertAfter = TVI_SORT; tvis.itemex.mask = TVIF_STATE | TVIF_TEXT; tvis.itemex.state = TVIS_EXPANDED; tvis.itemex.stateMask = 0; tvis.itemex.pszText = newgroup; hti = TreeView_InsertItem(hwndTVCtrl, &tvis); _ASSERTE(hti != NULL); if (hti != NULL) { TreeView_SelectItem(hwndTVCtrl, hti); TreeView_Expand(hwndTVCtrl, hti, TVE_EXPAND); EnableDlgItem(hwndDlg, IDADD, TRUE); EnableDlgItem(hwndDlg, IDREMOVE, TRUE); } } SetWindowLong(hwndDlg, DWL_MSGRESULT, 0); return TRUE; } case IDREMOVE: if ((hSel = TreeView_GetSelection(hwndTVCtrl)) != NULL) { if ((hParent = TreeView_GetParent(hwndTVCtrl, hSel)) == NULL && TreeView_GetChild(hwndTVCtrl, hSel) != NULL) { // is group std::string msg("Are you sure to delete group '"); tvi.mask = TVIF_HANDLE | TVIF_TEXT; tvi.hItem = hSel; tvi.pszText = text; tvi.cchTextMax = sizeof text; if (TreeView_GetItem(hwndTVCtrl, &tvi)) msg.append(text); msg.append("' and all it's files?"); if (MessageBox(hwndDlg, msg.c_str(), "libnames matching", MB_ICONQUESTION | MB_YESNO | MB_DEFBUTTON1) == IDYES) TreeView_DeleteItem(hwndTVCtrl, hSel); } else // is file or group has no files - delete without confirmation TreeView_DeleteItem(hwndTVCtrl, hSel); if (TreeView_GetCount(hwndTVCtrl) <= 0) EnableDlgItem(hwndDlg, IDADD, FALSE); EnableDlgItem(hwndDlg, IDREMOVE, TreeView_GetSelection(hwndTVCtrl) != NULL); } SetWindowLong(hwndDlg, DWL_MSGRESULT, 0); return TRUE; } break; } break; case WM_NOTIFY: _ASSERTE(lParam != NULL); if (lParam != NULL) { // OutputDebugString("%s(%08X, WM_NOTIFY, ...): hwndFrom=%08X idFrom=%u code=0x%X", // __FUNCTION__, hwndDlg, reinterpret_cast<LPNMHDR>(lParam)->hwndFrom, reinterpret_cast<LPNMHDR>(lParam)->idFrom, // reinterpret_cast<LPNMHDR>(lParam)->code); switch (reinterpret_cast<LPNMHDR>(lParam)->idFrom) { case IDC_GROUPVWR: switch (reinterpret_cast<LPNMHDR>(lParam)->code) { case TVN_KEYDOWN: switch (reinterpret_cast<LPNMTVKEYDOWN>(lParam)->wVKey) { case VK_F2: if ((hSel = TreeView_GetSelection(hwndTVCtrl)) != NULL) TreeView_EditLabel(hwndTVCtrl, hSel); SetWindowLong(hwndDlg, DWL_MSGRESULT, TRUE); return TRUE; case VK_INSERT: SendMessage(hwndDlg, WM_COMMAND, (hSel = TreeView_GetSelection(hwndTVCtrl)) != NULL && TreeView_GetParent(hwndTVCtrl, hSel) != NULL ? MAKELONG(IDADD, BN_CLICKED) : MAKELONG(IDADDGROUP, BN_CLICKED), reinterpret_cast<LPARAM>(hwndTVCtrl)); SetWindowLong(hwndDlg, DWL_MSGRESULT, TRUE); return TRUE; case VK_DELETE: SendMessage(hwndDlg, WM_COMMAND, MAKELONG(IDREMOVE, BN_CLICKED), reinterpret_cast<LPARAM>(hwndTVCtrl)); SetWindowLong(hwndDlg, DWL_MSGRESULT, TRUE); return TRUE; } break; case TVN_BEGINLABELEDIT: { if ((hSel = TreeView_GetSelection(hwndTVCtrl)) != NULL && TreeView_GetParent(hwndTVCtrl, hSel) != NULL) { tvi.mask = TVIF_HANDLE | TVIF_TEXT; tvi.hItem = hSel; tvi.pszText = text; tvi.cchTextMax = sizeof text; if (TreeView_GetItem(hwndTVCtrl, &tvi)) { memset(&ofn, 0, sizeof ofn); ofn.lStructSize = sizeof ofn; ofn.lpstrFile = text; ofn.nMaxFile = sizeof text; _splitpath(text, drive, dir, 0, ext); _makepath(path, drive, dir, 0, 0); ofn.lpstrInitialDir = path; ofn.hwndOwner = hwndDlg; ofn.hInstance = hInstance; ofn.Flags = OFN_ENABLESIZING | OFN_EXPLORER | OFN_FORCESHOWHIDDEN | OFN_LONGNAMES | OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY; ofn.lpstrTitle = "Change file's location"; ofn.lpstrFilter = "all files\0*.*\0"; ofn.nFilterIndex = 1; ofn.lpstrDefExt = ext; if (GetOpenFileName(&ofn)) { tvi.mask = TVIF_HANDLE | TVIF_TEXT; TreeView_SetItem(hwndTVCtrl, &tvi); } SetWindowLong(hwndDlg, DWL_MSGRESULT, TRUE); return TRUE; } #ifdef _DEBUG else _RPTF2(_CRT_WARN, "%s(...): TreeView_GetItem(%08X, ...) returned NULL", __FUNCTION__, hwndTVCtrl); #endif // _DEBUG } hwndEditCtrl = TreeView_GetEditControl(hwndTVCtrl); _ASSERTE(hwndEditCtrl != NULL); SendMessage(hwndEditCtrl, EM_LIMITTEXT, MAX_PATH - 1, 0); SetWindowLong(hwndDlg, DWL_MSGRESULT, FALSE); return TRUE; } case TVN_ENDLABELEDIT: hwndEditCtrl = NULL; SetWindowLong(hwndDlg, DWL_MSGRESULT, reinterpret_cast<LPNMTVDISPINFO>(lParam)->item.pszText != NULL && strlen(reinterpret_cast<LPNMTVDISPINFO>(lParam)->item.pszText) > 0 && strlen(reinterpret_cast<LPNMTVDISPINFO>(lParam)->item.pszText) < MAX_PATH); return TRUE; case TVN_SELCHANGED: EnableDlgItem(hwndDlg, IDREMOVE, TreeView_GetSelection(hwndTVCtrl) != 0); return TRUE; //case WM_LBUTTONDBLCLCK: // break; } // switch code break; } // switch idFrom } // lParam != NULL break; } // main switch return 0; }
/*===================================================================*/ void K6502_Step( WORD wClocks ) { /* * Only the specified number of the clocks execute Op. * * Parameters * WORD wClocks (Read) * The number of the clocks */ BYTE byCode; WORD wA0; BYTE byD0; BYTE byD1; WORD wD0; // Dispose of it if there is an interrupt requirement if ( NMI_State != NMI_Wiring ) { // NMI Interrupt NMI_State = NMI_Wiring; CLK( 7 ); PUSHW( PC ); PUSH( F & ~FLAG_B ); RSTF( FLAG_D ); SETF( FLAG_I ); PC = K6502_ReadW( VECTOR_NMI ); } else if ( IRQ_State != IRQ_Wiring ) { // IRQ Interrupt // Execute IRQ if an I flag isn't being set if ( !( F & FLAG_I ) ) { IRQ_State = IRQ_Wiring; CLK( 7 ); PUSHW( PC ); PUSH( F & ~FLAG_B ); RSTF( FLAG_D ); SETF( FLAG_I ); PC = K6502_ReadW( VECTOR_IRQ ); } } // It has a loop until a constant clock passes while ( g_wPassedClocks < wClocks ) { // Read an instruction byCode = K6502_Read( PC++ ); // Execute an instruction. switch ( byCode ) { case 0x00: // BRK ++PC; PUSHW( PC ); SETF( FLAG_B ); PUSH( F ); SETF( FLAG_I ); RSTF( FLAG_D ); PC = K6502_ReadW( VECTOR_IRQ ); CLK( 7 ); break; case 0x01: // ORA (Zpg,X) ORA( A_IX ); CLK( 6 ); break; case 0x05: // ORA Zpg ORA( A_ZP ); CLK( 3 ); break; case 0x06: // ASL Zpg ASL( AA_ZP ); CLK( 5 ); break; case 0x08: // PHP SETF( FLAG_B ); PUSH( F ); CLK( 3 ); break; case 0x09: // ORA #Oper ORA( A_IMM ); CLK( 2 ); break; case 0x0A: // ASL A ASLA; CLK( 2 ); break; case 0x0D: // ORA Abs ORA( A_ABS ); CLK( 4 ); break; case 0x0e: // ASL Abs ASL( AA_ABS ); CLK( 6 ); break; case 0x10: // BPL Oper BRA( !( F & FLAG_N ) ); break; case 0x11: // ORA (Zpg),Y ORA( A_IY ); CLK( 5 ); break; case 0x15: // ORA Zpg,X ORA( A_ZPX ); CLK( 4 ); break; case 0x16: // ASL Zpg,X ASL( AA_ZPX ); CLK( 6 ); break; case 0x18: // CLC RSTF( FLAG_C ); CLK( 2 ); break; case 0x19: // ORA Abs,Y ORA( A_ABSY ); CLK( 4 ); break; case 0x1D: // ORA Abs,X ORA( A_ABSX ); CLK( 4 ); break; case 0x1E: // ASL Abs,X ASL( AA_ABSX ); CLK( 7 ); break; case 0x20: // JSR Abs JSR; CLK( 6 ); break; case 0x21: // AND (Zpg,X) AND( A_IX ); CLK( 6 ); break; case 0x24: // BIT Zpg BIT( A_ZP ); CLK( 3 ); break; case 0x25: // AND Zpg AND( A_ZP ); CLK( 3 ); break; case 0x26: // ROL Zpg ROL( AA_ZP ); CLK( 5 ); break; case 0x28: // PLP POP( F ); SETF( FLAG_R ); CLK( 4 ); break; case 0x29: // AND #Oper AND( A_IMM ); CLK( 2 ); break; case 0x2A: // ROL A ROLA; CLK( 2 ); break; case 0x2C: // BIT Abs BIT( A_ABS ); CLK( 4 ); break; case 0x2D: // AND Abs AND( A_ABS ); CLK( 4 ); break; case 0x2E: // ROL Abs ROL( AA_ABS ); CLK( 6 ); break; case 0x30: // BMI Oper BRA( F & FLAG_N ); break; case 0x31: // AND (Zpg),Y AND( A_IY ); CLK( 5 ); break; case 0x35: // AND Zpg,X AND( A_ZPX ); CLK( 4 ); break; case 0x36: // ROL Zpg,X ROL( AA_ZPX ); CLK( 6 ); break; case 0x38: // SEC SETF( FLAG_C ); CLK( 2 ); break; case 0x39: // AND Abs,Y AND( A_ABSY ); CLK( 4 ); break; case 0x3D: // AND Abs,X AND( A_ABSX ); CLK( 4 ); break; case 0x3E: // ROL Abs,X ROL( AA_ABSX ); CLK( 7 ); break; case 0x40: // RTI POP( F ); SETF( FLAG_R ); POPW( PC ); CLK( 6 ); break; case 0x41: // EOR (Zpg,X) EOR( A_IX ); CLK( 6 ); break; case 0x45: // EOR Zpg EOR( A_ZP ); CLK( 3 ); break; case 0x46: // LSR Zpg LSR( AA_ZP ); CLK( 5 ); break; case 0x48: // PHA PUSH( A ); CLK( 3 ); break; case 0x49: // EOR #Oper EOR( A_IMM ); CLK( 2 ); break; case 0x4A: // LSR A LSRA; CLK( 2 ); break; case 0x4C: // JMP Abs JMP( AA_ABS ); CLK( 3 ); break; case 0x4D: // EOR Abs EOR( A_ABS ); CLK( 4 ); break; case 0x4E: // LSR Abs LSR( AA_ABS ); CLK( 6 ); break; case 0x50: // BVC BRA( !( F & FLAG_V ) ); break; case 0x51: // EOR (Zpg),Y EOR( A_IY ); CLK( 5 ); break; case 0x55: // EOR Zpg,X EOR( A_ZPX ); CLK( 4 ); break; case 0x56: // LSR Zpg,X LSR( AA_ZPX ); CLK( 6 ); break; case 0x58: // CLI byD0 = F; RSTF( FLAG_I ); CLK( 2 ); if ( ( byD0 & FLAG_I ) && IRQ_State != IRQ_Wiring ) { IRQ_State = IRQ_Wiring; CLK( 7 ); PUSHW( PC ); PUSH( F & ~FLAG_B ); RSTF( FLAG_D ); SETF( FLAG_I ); PC = K6502_ReadW( VECTOR_IRQ ); } break; case 0x59: // EOR Abs,Y EOR( A_ABSY ); CLK( 4 ); break; case 0x5D: // EOR Abs,X EOR( A_ABSX ); CLK( 4 ); break; case 0x5E: // LSR Abs,X LSR( AA_ABSX ); CLK( 7 ); break; case 0x60: // RTS POPW( PC ); ++PC; CLK( 6 ); break; case 0x61: // ADC (Zpg,X) ADC( A_IX ); CLK( 6 ); break; case 0x65: // ADC Zpg ADC( A_ZP ); CLK( 3 ); break; case 0x66: // ROR Zpg ROR( AA_ZP ); CLK( 5 ); break; case 0x68: // PLA POP( A ); TEST( A ); CLK( 4 ); break; case 0x69: // ADC #Oper ADC( A_IMM ); CLK( 2 ); break; case 0x6A: // ROR A RORA; CLK( 2 ); break; case 0x6C: // JMP (Abs) JMP( K6502_ReadW2( AA_ABS ) ); CLK( 5 ); break; case 0x6D: // ADC Abs ADC( A_ABS ); CLK( 4 ); break; case 0x6E: // ROR Abs ROR( AA_ABS ); CLK( 6 ); break; case 0x70: // BVS BRA( F & FLAG_V ); break; case 0x71: // ADC (Zpg),Y ADC( A_IY ); CLK( 5 ); break; case 0x75: // ADC Zpg,X ADC( A_ZPX ); CLK( 4 ); break; case 0x76: // ROR Zpg,X ROR( AA_ZPX ); CLK( 6 ); break; case 0x78: // SEI SETF( FLAG_I ); CLK( 2 ); break; case 0x79: // ADC Abs,Y ADC( A_ABSY ); CLK( 4 ); break; case 0x7D: // ADC Abs,X ADC( A_ABSX ); CLK( 4 ); break; case 0x7E: // ROR Abs,X ROR( AA_ABSX ); CLK( 7 ); break; case 0x81: // STA (Zpg,X) STA( AA_IX ); CLK( 6 ); break; case 0x84: // STY Zpg STY( AA_ZP ); CLK( 3 ); break; case 0x85: // STA Zpg STA( AA_ZP ); CLK( 3 ); break; case 0x86: // STX Zpg STX( AA_ZP ); CLK( 3 ); break; case 0x88: // DEY --Y; TEST( Y ); CLK( 2 ); break; case 0x8A: // TXA A = X; TEST( A ); CLK( 2 ); break; case 0x8C: // STY Abs STY( AA_ABS ); CLK( 4 ); break; case 0x8D: // STA Abs STA( AA_ABS ); CLK( 4 ); break; case 0x8E: // STX Abs STX( AA_ABS ); CLK( 4 ); break; case 0x90: // BCC BRA( !( F & FLAG_C ) ); break; case 0x91: // STA (Zpg),Y STA( AA_IY ); CLK( 6 ); break; case 0x94: // STY Zpg,X STY( AA_ZPX ); CLK( 4 ); break; case 0x95: // STA Zpg,X STA( AA_ZPX ); CLK( 4 ); break; case 0x96: // STX Zpg,Y STX( AA_ZPY ); CLK( 4 ); break; case 0x98: // TYA A = Y; TEST( A ); CLK( 2 ); break; case 0x99: // STA Abs,Y STA( AA_ABSY ); CLK( 5 ); break; case 0x9A: // TXS SP = X; CLK( 2 ); break; case 0x9D: // STA Abs,X STA( AA_ABSX ); CLK( 5 ); break; case 0xA0: // LDY #Oper LDY( A_IMM ); CLK( 2 ); break; case 0xA1: // LDA (Zpg,X) LDA( A_IX ); CLK( 6 ); break; case 0xA2: // LDX #Oper LDX( A_IMM ); CLK( 2 ); break; case 0xA4: // LDY Zpg LDY( A_ZP ); CLK( 3 ); break; case 0xA5: // LDA Zpg LDA( A_ZP ); CLK( 3 ); break; case 0xA6: // LDX Zpg LDX( A_ZP ); CLK( 3 ); break; case 0xA8: // TAY Y = A; TEST( A ); CLK( 2 ); break; case 0xA9: // LDA #Oper LDA( A_IMM ); CLK( 2 ); break; case 0xAA: // TAX X = A; TEST( A ); CLK( 2 ); break; case 0xAC: // LDY Abs LDY( A_ABS ); CLK( 4 ); break; case 0xAD: // LDA Abs LDA( A_ABS ); CLK( 4 ); break; case 0xAE: // LDX Abs LDX( A_ABS ); CLK( 4 ); break; case 0xB0: // BCS BRA( F & FLAG_C ); break; case 0xB1: // LDA (Zpg),Y LDA( A_IY ); CLK( 5 ); break; case 0xB4: // LDY Zpg,X LDY( A_ZPX ); CLK( 4 ); break; case 0xB5: // LDA Zpg,X LDA( A_ZPX ); CLK( 4 ); break; case 0xB6: // LDX Zpg,Y LDX( A_ZPY ); CLK( 4 ); break; case 0xB8: // CLV RSTF( FLAG_V ); CLK( 2 ); break; case 0xB9: // LDA Abs,Y LDA( A_ABSY ); CLK( 4 ); break; case 0xBA: // TSX X = SP; TEST( X ); CLK( 2 ); break; case 0xBC: // LDY Abs,X LDY( A_ABSX ); CLK( 4 ); break; case 0xBD: // LDA Abs,X LDA( A_ABSX ); CLK( 4 ); break; case 0xBE: // LDX Abs,Y LDX( A_ABSY ); CLK( 4 ); break; case 0xC0: // CPY #Oper CPY( A_IMM ); CLK( 2 ); break; case 0xC1: // CMP (Zpg,X) CMP( A_IX ); CLK( 6 ); break; case 0xC4: // CPY Zpg CPY( A_ZP ); CLK( 3 ); break; case 0xC5: // CMP Zpg CMP( A_ZP ); CLK( 3 ); break; case 0xC6: // DEC Zpg DEC( AA_ZP ); CLK( 5 ); break; case 0xC8: // INY ++Y; TEST( Y ); CLK( 2 ); break; case 0xC9: // CMP #Oper CMP( A_IMM ); CLK( 2 ); break; case 0xCA: // DEX --X; TEST( X ); CLK( 2 ); break; case 0xCC: // CPY Abs CPY( A_ABS ); CLK( 4 ); break; case 0xCD: // CMP Abs CMP( A_ABS ); CLK( 4 ); break; case 0xCE: // DEC Abs DEC( AA_ABS ); CLK( 6 ); break; case 0xD0: // BNE BRA( !( F & FLAG_Z ) ); break; case 0xD1: // CMP (Zpg),Y CMP( A_IY ); CLK( 5 ); break; case 0xD5: // CMP Zpg,X CMP( A_ZPX ); CLK( 4 ); break; case 0xD6: // DEC Zpg,X DEC( AA_ZPX ); CLK( 6 ); break; case 0xD8: // CLD RSTF( FLAG_D ); CLK( 2 ); break; case 0xD9: // CMP Abs,Y CMP( A_ABSY ); CLK( 4 ); break; case 0xDD: // CMP Abs,X CMP( A_ABSX ); CLK( 4 ); break; case 0xDE: // DEC Abs,X DEC( AA_ABSX ); CLK( 7 ); break; case 0xE0: // CPX #Oper CPX( A_IMM ); CLK( 2 ); break; case 0xE1: // SBC (Zpg,X) SBC( A_IX ); CLK( 6 ); break; case 0xE4: // CPX Zpg CPX( A_ZP ); CLK( 3 ); break; case 0xE5: // SBC Zpg SBC( A_ZP ); CLK( 3 ); break; case 0xE6: // INC Zpg INC( AA_ZP ); CLK( 5 ); break; case 0xE8: // INX ++X; TEST( X ); CLK( 2 ); break; case 0xE9: // SBC #Oper SBC( A_IMM ); CLK( 2 ); break; case 0xEA: // NOP CLK( 2 ); break; case 0xEC: // CPX Abs CPX( A_ABS ); CLK( 4 ); break; case 0xED: // SBC Abs SBC( A_ABS ); CLK( 4 ); break; case 0xEE: // INC Abs INC( AA_ABS ); CLK( 6 ); break; case 0xF0: // BEQ BRA( F & FLAG_Z ); break; case 0xF1: // SBC (Zpg),Y SBC( A_IY ); CLK( 5 ); break; case 0xF5: // SBC Zpg,X SBC( A_ZPX ); CLK( 4 ); break; case 0xF6: // INC Zpg,X INC( AA_ZPX ); CLK( 6 ); break; case 0xF8: // SED SETF( FLAG_D ); CLK( 2 ); break; case 0xF9: // SBC Abs,Y SBC( A_ABSY ); CLK( 4 ); break; case 0xFD: // SBC Abs,X SBC( A_ABSX ); CLK( 4 ); break; case 0xFE: // INC Abs,X INC( AA_ABSX ); CLK( 7 ); break; /*-----------------------------------------------------------*/ /* Unlisted Instructions ( thanks to virtualnes ) */ /*-----------------------------------------------------------*/ case 0x1A: // NOP (Unofficial) case 0x3A: // NOP (Unofficial) case 0x5A: // NOP (Unofficial) case 0x7A: // NOP (Unofficial) case 0xDA: // NOP (Unofficial) case 0xFA: // NOP (Unofficial) CLK( 2 ); break; case 0x80: // DOP (CYCLES 2) case 0x82: // DOP (CYCLES 2) case 0x89: // DOP (CYCLES 2) case 0xC2: // DOP (CYCLES 2) case 0xE2: // DOP (CYCLES 2) PC++; CLK( 2 ); break; case 0x04: // DOP (CYCLES 3) case 0x44: // DOP (CYCLES 3) case 0x64: // DOP (CYCLES 3) PC++; CLK( 3 ); break; case 0x14: // DOP (CYCLES 4) case 0x34: // DOP (CYCLES 4) case 0x54: // DOP (CYCLES 4) case 0x74: // DOP (CYCLES 4) case 0xD4: // DOP (CYCLES 4) case 0xF4: // DOP (CYCLES 4) PC++; CLK( 4 ); break; case 0x0C: // TOP case 0x1C: // TOP case 0x3C: // TOP case 0x5C: // TOP case 0x7C: // TOP case 0xDC: // TOP case 0xFC: // TOP PC+=2; CLK( 4 ); break; default: // Unknown Instruction CLK( 2 ); #if 0 InfoNES_MessageBox( "0x%02x is unknown instruction.\n", byCode ) ; #endif break; } /* end of switch ( byCode ) */ } /* end of while ... */ // Correct the number of the clocks g_wPassedClocks -= wClocks; }
char * formataddr (char *orig, char *str) { register int len; register int isgroup; register char *dst; register char *cp; register char *sp; register struct mailname *mp = NULL; /* if we don't have a buffer yet, get one */ if (bufsiz == 0) { buf = mh_xmalloc (BUFINCR); last_dst = buf; /* XXX */ bufsiz = BUFINCR - 6; /* leave some slop */ bufend = buf + bufsiz; } /* * If "orig" points to our buffer we can just pick up where we * left off. Otherwise we have to copy orig into our buffer. */ if (orig == buf) dst = last_dst; else if (!orig || !*orig) { dst = buf; *dst = '\0'; } else { dst = last_dst; /* XXX */ CHECKMEM (orig); CPY (orig); } /* concatenate all the new addresses onto 'buf' */ for (isgroup = 0; (cp = getname (str)); ) { if ((mp = getm (cp, NULL, 0, fmt_norm, NULL)) == NULL) continue; if (isgroup && (mp->m_gname || !mp->m_ingrp)) { *dst++ = ';'; isgroup = 0; } /* if we get here we're going to add an address */ if (dst != buf) { *dst++ = ','; *dst++ = ' '; } if (mp->m_gname) { CHECKMEM (mp->m_gname); CPY (mp->m_gname); isgroup++; } sp = adrformat (mp); CHECKMEM (sp); CPY (sp); mnfree (mp); } if (isgroup) *dst++ = ';'; *dst = '\0'; last_dst = dst; return (buf); }
// does not check whether the element is already there static void tree23_insert (tree23_root_t *R, int x, int *Data) { tree23_t *st[40]; int x_Data[8]; tree23_t *cur, *s, *l; int sp, extra_words = R->extra_words; #define Extra_words extra_words #define x1_Data extra-Extra_words #define x2_Data extra-Extra_words*2 #define DATA(__x) (__x##_Data) #define CPY(__x,__y) {if(Extra_words>0) {memcpy(__x,__y,Extra_words*4);}} #define DCPY(__x,__y) CPY(DATA(__x),DATA(__y)) #define LET(__x,__y) {__x = __y; DCPY(__x,__y);} #define IS_2N(__t) ((__t)->x1 == (__t)->x2) #define IS_3N(__t) (!IS_2N(__t)) #define LEAF(__t) ((tree23_leaf_t *)(__t)) //empty tree case if (!R->root) { R->root = new_leaf (x, extra_words); CPY(DATA(R->root->x1), Data); R->depth = 0; return; } sp = 0; cur = R->root; while (sp < R->depth) { st[sp++] = cur; if (x < cur->x1) { cur = cur->left; } else if (x > cur->x2) { cur = cur->right; } else { cur = cur->middle; } } //leaf split if (IS_3N(cur)) { //case 1. two-element leaf: have cur:[ B D ] if (x < cur->x1) { // cur:[ B D ] + x:A --> [ A B D ] --> (new)s:[ A ] new_x:B (cur)l:[ D ] s = new_leaf (x, Extra_words); CPY (DATA(s->x1), Data) LET (x, cur->x1); LET (cur->x1, cur->x2); l = cur; } else if (x > cur->x2) { // cur:[ B D ] + x:E --> [ A D E ] --> (cur)s:[ B ] new_x:D (new)l:[ E ] l = new_leaf (x, Extra_words); CPY (DATA(l->x1), Data) LET (x, cur->x2) cur->x2 = cur->x1; s = cur; } else { // cur:[ B D ] + x:C --> [ A C E ] --> (cur)s:[ B ] new_x:C (new)l:[ D ] l = new_leaf (cur->x2, Extra_words); CPY (DATA(l->x1), DATA(cur->x2)) CPY (DATA(x), Data); cur->x2 = cur->x1; s = cur; } } else { //case 2. single-element leaf: have cur:[ B ] if (x < cur->x1) { // cur:[ B ] + x:A --> cur:[ A B ] LET (cur->x2, cur->x1); cur->x1 = x; CPY (DATA(cur->x1), Data); } else { // cur:[ B ] + x:C --> cur:[ B C ] cur->x2 = x; CPY (DATA(cur->x2), Data); } return; } while (sp) { cur = st[--sp]; // here cur is a parent node cur: [ ... old_cur:[.E.G.] ... ] // we are replacing its subtree [.E.G.] with two: s:[.E.] x:F l:[.G.] if (IS_3N(cur)) { //case 1. two-element internal node // cur: [ (left) x1 (middle) x2 (right) ] if (x < cur->x1) { // s l middle right // cur: [ old_cur:[.E.G.] x1:H [.I.] x2:J [.K.] ] // --> [ s:[.E.] x:F l:[.G.] x1:H [.I.] J [.K.] ] // --> (new)new_s:[ s:[.E.] x:F l:[.G.] ] new_x:H (cur)new_l:[ [.I.] J [.K.] ] s = new_node2 (x, s, l, Extra_words); DCPY(s->x1, x); LET (x, cur->x1); LET (cur->x1, cur->x2); cur->left = cur->middle; l = cur; } else if (x > cur->x2) { // left middle s l // cur: [ [.A.] B [.C.] D old_cur:[.E.G.] ] // --> [ [.A.] x1:B [.C.] x2:D s:[.E.] x:F l:[.G.] ] // --> (cur)new_s:[ [.A.] x1:B [.C.] ] new_x:D (new)new_l:[ s:[.E.] x:F l:[.G.] ] l = new_node2 (x, s, l, Extra_words); DCPY(l->x1, x); LET (x, cur->x2); cur->right = cur->middle; cur->x2 = cur->x1; s = cur; } else { //left s l right // cur: [ [.C.] x1:D old_cur:[.E.G.] x2:H [.I.] ] // --> [ [.C.] x1:D s:[.E.] x:F l:[.G.] x2:H [.I.] ] // --> (cur)new_s:[ [.C.] x1:D s:[.E.] ] new_x:F (new)new_l:[l:[.G.] x2:H [.I.] ] l = new_node2 (cur->x2, l, cur->right, Extra_words); DCPY(l->x1, cur->x2); cur->right = s; cur->x2 = cur->x1; s = cur; } } else { //case 2. single-element internal node // cur: [ (left) x1=x2 (right) ] if (x < cur->x1) { // s l right // cur: [ old_cur:[.E.G.] x1:H [.I.] ] // --> [ s:[.E.] x:F l:[.G.] x1:H [.I.] ] cur->left = s; cur->middle = l; cur->x1 = x; DCPY(cur->x2, cur->x1); DCPY(cur->x1, x); } else { //left s l // cur: [ [.C.] x1:D old_cur:[.E.G.] ] // --> [ [.C.] x1:D s:[.E.] x:F l:[.G.] ] cur->middle = s; cur->right = l; LET(cur->x2, x); } return; } } //root split // here s:[.E.] x:F l:[.G.] comes to the top // create new root [ [.E.] F [.G.] ] R->root = new_node2 (x, s, l, Extra_words); R->depth++; CPY (DATA(R->root->x1), Data); }
void shoes_place_decide(shoes_place *place, VALUE c, VALUE attr, int dw, int dh, unsigned char rel, int padded) { shoes_canvas *canvas = NULL; if (!NIL_P(c)) Data_Get_Struct(c, shoes_canvas, canvas); VALUE ck = rb_obj_class(c); VALUE stuck = ATTR(attr, attach); // for image : we want to scale the image, given only one attribute :width or :height // get dw and dh, set width or height if (REL_FLAGS(rel) & REL_SCALE) { // 8 VALUE rw = ATTR(attr, width), rh = ATTR(attr, height); if (NIL_P(rw) && !NIL_P(rh)) { // we have height // fetch height in pixels whatever the input (string, float, positive/negative int) int spx = shoes_px(rh, dh, CPH(canvas), 1); // compute width with image aspect ratio [(dh == dw) means a square ] dw = (dh == dw) ? spx : ROUND(((dh * 1.) / dw) * spx); dh = spx; // now re-init 'dh' for next calculations ATTRSET(attr, width, INT2NUM(dw)); // set calculated width } else if (NIL_P(rh) && !NIL_P(rw)) { int spx = shoes_px(rw, dw, CPW(canvas), 1); dh = (dh == dw) ? spx : ROUND(((dh * 1.) / dw) * spx); dw = spx; ATTRSET(attr, height, INT2NUM(dh)); } } ATTR_MARGINS(attr, 0, canvas); if (padded || dh == 0) dh += tmargin + bmargin; if (padded || dw == 0) dw += lmargin + rmargin; int testw = dw; if (testw == 0) testw = lmargin + 1 + rmargin; if (!NIL_P(stuck)) { if (stuck == cShoesWindow) rel = REL_FLAGS(rel) | REL_WINDOW; else if (stuck == cMouse) rel = REL_FLAGS(rel) | REL_CURSOR; else rel = REL_FLAGS(rel) | REL_STICKY; } place->flags = rel; place->dx = place->dy = 0; if (canvas == NULL) { place->ix = place->x = 0; place->iy = place->y = 0; place->iw = place->w = dw; place->ih = place->h = dh; } else { int cx, cy, ox, oy, tw = dw, th = dh; switch (REL_COORDS(rel)) { case REL_WINDOW: cx = 0; cy = 0; ox = 0; oy = canvas->slot->scrolly; break; case REL_CANVAS: cx = canvas->cx - CPX(canvas); cy = canvas->cy - CPY(canvas); ox = CPX(canvas); oy = CPY(canvas); break; case REL_CURSOR: cx = 0; cy = 0; ox = canvas->app->mousex; oy = canvas->app->mousey; break; case REL_TILE: cx = 0; cy = 0; ox = CPX(canvas); oy = CPY(canvas); testw = dw = CPW(canvas); dh = max(canvas->height, CPH(canvas)); // Fix #2 ? //dh = (max(canvas->height, canvas->fully - CPB(canvas)) - CPY(canvas)); break; default: cx = 0; cy = 0; ox = canvas->cx; oy = canvas->cy; if ((REL_COORDS(rel) & REL_STICKY) && shoes_is_element(stuck)) { shoes_element *element; Data_Get_Struct(stuck, shoes_element, element); ox = element->place.x; oy = element->place.y; } break; } place->w = PX(attr, width, testw, CPW(canvas)); if (dw == 0 && place->w + (int)canvas->cx > canvas->place.iw) { canvas->cx = canvas->endx = CPX(canvas); canvas->cy = canvas->endy; place->w = canvas->place.iw; } place->h = PX(attr, height, dh, CPH(canvas)); if (REL_COORDS(rel) != REL_TILE) { tw = place->w; th = place->h; } place->x = PX2(attr, left, right, cx, tw, canvas->place.iw) + ox; place->y = PX2(attr, top, bottom, cy, th, ORIGIN(canvas->place) ? canvas->height : canvas->fully) + oy; if (!ORIGIN(canvas->place)) { place->dx = canvas->place.dx; place->dy = canvas->place.dy; } place->dx += PXN(attr, displace_left, 0, CPW(canvas)); place->dy += PXN(attr, displace_top, 0, CPH(canvas)); place->flags |= NIL_P(ATTR(attr, left)) && NIL_P(ATTR(attr, right)) ? 0 : FLAG_ABSX; place->flags |= NIL_P(ATTR(attr, top)) && NIL_P(ATTR(attr, bottom)) ? 0 : FLAG_ABSY; if (REL_COORDS(rel) != REL_TILE && ABSY(*place) == 0 && (ck == cStack || place->x + place->w > CPX(canvas) + canvas->place.iw)) { canvas->cx = place->x = CPX(canvas); canvas->cy = place->y = canvas->endy; } } place->ix = place->x + lmargin; place->iy = place->y + tmargin; place->iw = place->w - (lmargin + rmargin); //place->iw = (RTEST(ATTR(attr, width))) ? place->w : place->w - (lmargin + rmargin); if (place->iw < 0) place->iw = 0; place->ih = place->h - (tmargin + bmargin); //place->ih = (RTEST(ATTR(attr, height))) ? place->h : place->h - (tmargin + bmargin); if (place->ih < 0) place->ih = 0; INFO("PLACE: (%d, %d), (%d: %d, %d: %d) [%d, %d] %x\n", place->x, place->y, place->w, place->iw, place->h, place->ih, ABSX(*place), ABSY(*place), place->flags); }
//////////////////////////////////////////////////// // Run! void Cpu::run(timestamp_t runto) { if(cpuJammed && (curCyc() < runto)) { setMainTimestamp(runto); } while( curCyc() < runto ) { ///////////////////////////////////// // Are we to take an interrupt if(wantInterrupt) { performInterrupt(false); continue; } if( *tracer ) tracer->traceCpuLine( cpu ); ///////////////////////////////////// // No interrupt, do an instruction u8 opcode = rd( cpu.PC++ ); switch(opcode) { /* Branches */ case 0x10: adBranch( !cpu.getN() ); break; /* BPL */ case 0x30: adBranch( cpu.getN() ); break; /* BMI */ case 0x50: adBranch( !cpu.getV() ); break; /* BVC */ case 0x70: adBranch( cpu.getV() ); break; /* BVS */ case 0x90: adBranch( !cpu.getC() ); break; /* BCC */ case 0xB0: adBranch( cpu.getC() ); break; /* BCS */ case 0xD0: adBranch( !cpu.getZ() ); break; /* BNE */ case 0xF0: adBranch( cpu.getZ() ); break; /* BEQ */ /* Flag flip-flop */ case 0x18: adImplied(); cpu.setC(0); break; /* CLC */ case 0x38: adImplied(); cpu.setC(1); break; /* SEC */ case 0x58: adImplied(); cpu.setI(0); break; /* CLI */ case 0x78: adImplied(); cpu.setI(1); break; /* SEI */ case 0xB8: adImplied(); cpu.setV(0); break; /* CLV */ case 0xD8: adImplied(); cpu.setD(0); break; /* CLD */ case 0xF8: adImplied(); cpu.setD(1); break; /* SED */ /* Stack push/pull */ case 0x08: adPush( cpu.getStatus(true) ); break; /* PHP */ case 0x28: cpu.setStatus( adPull() ); break; /* PLP */ case 0x48: adPush( cpu.A ); break; /* PHA */ case 0x68: cpu.NZ( cpu.A = adPull() ); break; /* PLA */ /* Reg Xfer */ case 0xAA: adImplied(); cpu.NZ( cpu.X = cpu.A ); break; /* TAX */ case 0xA8: adImplied(); cpu.NZ( cpu.Y = cpu.A ); break; /* TAY */ case 0xBA: adImplied(); cpu.NZ( cpu.X = cpu.SP ); break; /* TSX */ case 0x8A: adImplied(); cpu.NZ( cpu.A = cpu.X ); break; /* TXA */ case 0x9A: adImplied(); cpu.SP = cpu.X; break; /* TXS */ case 0x98: adImplied(); cpu.NZ( cpu.A = cpu.Y ); break; /* TYA */ /* Misc */ case 0x00: performInterrupt(true); break; /* BRK */ case 0x4C: full_JMP(); break; /* JMP $xxxx */ case 0x6C: full_JMP_Indirect(); break; /* JMP ($xxxx) */ case 0x20: full_JSR(); break; /* JSR $xxxx */ case 0xEA: adImplied(); break; /* NOP */ case 0x40: full_RTI(); break; /* RTI */ case 0x60: full_RTS(); break; /* RTS */ /* ADC */ case 0x69: ADC( adRdIm() ); break; case 0x65: ADC( adRdZp() ); break; case 0x75: ADC( adRdZx() ); break; case 0x6D: ADC( adRdAb() ); break; case 0x7D: ADC( adRdAx() ); break; case 0x79: ADC( adRdAy() ); break; case 0x61: ADC( adRdIx() ); break; case 0x71: ADC( adRdIy() ); break; /* AND */ case 0x29: AND( adRdIm() ); break; case 0x25: AND( adRdZp() ); break; case 0x35: AND( adRdZx() ); break; case 0x2D: AND( adRdAb() ); break; case 0x3D: AND( adRdAx() ); break; case 0x39: AND( adRdAy() ); break; case 0x21: AND( adRdIx() ); break; case 0x31: AND( adRdIy() ); break; /* ASL */ case 0x0A: adImplied(); ASL(cpu.A); break; case 0x06: adRWZp( &Cpu::ASL ); break; case 0x16: adRWZx( &Cpu::ASL ); break; case 0x0E: adRWAb( &Cpu::ASL ); break; case 0x1E: adRWAx( &Cpu::ASL ); break; /* BIT */ case 0x24: BIT( adRdZp() ); break; case 0x2C: BIT( adRdAb() ); break; /* CMP */ case 0xC9: CMP( adRdIm() ); break; case 0xC5: CMP( adRdZp() ); break; case 0xD5: CMP( adRdZx() ); break; case 0xCD: CMP( adRdAb() ); break; case 0xDD: CMP( adRdAx() ); break; case 0xD9: CMP( adRdAy() ); break; case 0xC1: CMP( adRdIx() ); break; case 0xD1: CMP( adRdIy() ); break; /* CPX */ case 0xE0: CPX( adRdIm() ); break; case 0xE4: CPX( adRdZp() ); break; case 0xEC: CPX( adRdAb() ); break; /* CPY */ case 0xC0: CPY( adRdIm() ); break; case 0xC4: CPY( adRdZp() ); break; case 0xCC: CPY( adRdAb() ); break; /* DEC */ case 0xCA: adImplied(); DEC(cpu.X); break; /* DEX */ case 0x88: adImplied(); DEC(cpu.Y); break; /* DEY */ case 0xC6: adRWZp( &Cpu::DEC ); break; case 0xD6: adRWZx( &Cpu::DEC ); break; case 0xCE: adRWAb( &Cpu::DEC ); break; case 0xDE: adRWAx( &Cpu::DEC ); break; /* EOR */ case 0x49: EOR( adRdIm() ); break; case 0x45: EOR( adRdZp() ); break; case 0x55: EOR( adRdZx() ); break; case 0x4D: EOR( adRdAb() ); break; case 0x5D: EOR( adRdAx() ); break; case 0x59: EOR( adRdAy() ); break; case 0x41: EOR( adRdIx() ); break; case 0x51: EOR( adRdIy() ); break; /* INC */ case 0xE8: adImplied(); INC(cpu.X); break; /* INX */ case 0xC8: adImplied(); INC(cpu.Y); break; /* INY */ case 0xE6: adRWZp( &Cpu::INC ); break; case 0xF6: adRWZx( &Cpu::INC ); break; case 0xEE: adRWAb( &Cpu::INC ); break; case 0xFE: adRWAx( &Cpu::INC ); break; /* LDA */ case 0xA9: cpu.NZ( cpu.A = adRdIm() ); break; case 0xA5: cpu.NZ( cpu.A = adRdZp() ); break; case 0xB5: cpu.NZ( cpu.A = adRdZx() ); break; case 0xAD: cpu.NZ( cpu.A = adRdAb() ); break; case 0xBD: cpu.NZ( cpu.A = adRdAx() ); break; case 0xB9: cpu.NZ( cpu.A = adRdAy() ); break; case 0xA1: cpu.NZ( cpu.A = adRdIx() ); break; case 0xB1: cpu.NZ( cpu.A = adRdIy() ); break; /* LDX */ case 0xA2: cpu.NZ( cpu.X = adRdIm() ); break; case 0xA6: cpu.NZ( cpu.X = adRdZp() ); break; case 0xB6: cpu.NZ( cpu.X = adRdZy() ); break; case 0xAE: cpu.NZ( cpu.X = adRdAb() ); break; case 0xBE: cpu.NZ( cpu.X = adRdAy() ); break; /* LDY */ case 0xA0: cpu.NZ( cpu.Y = adRdIm() ); break; case 0xA4: cpu.NZ( cpu.Y = adRdZp() ); break; case 0xB4: cpu.NZ( cpu.Y = adRdZx() ); break; case 0xAC: cpu.NZ( cpu.Y = adRdAb() ); break; case 0xBC: cpu.NZ( cpu.Y = adRdAx() ); break; /* LSR */ case 0x4A: adImplied(); LSR(cpu.A); break; case 0x46: adRWZp( &Cpu::LSR ); break; case 0x56: adRWZx( &Cpu::LSR ); break; case 0x4E: adRWAb( &Cpu::LSR ); break; case 0x5E: adRWAx( &Cpu::LSR ); break; /* ORA */ case 0x09: ORA( adRdIm() ); break; case 0x05: ORA( adRdZp() ); break; case 0x15: ORA( adRdZx() ); break; case 0x0D: ORA( adRdAb() ); break; case 0x1D: ORA( adRdAx() ); break; case 0x19: ORA( adRdAy() ); break; case 0x01: ORA( adRdIx() ); break; case 0x11: ORA( adRdIy() ); break; /* ROL */ case 0x2A: adImplied(); ROL(cpu.A); break; case 0x26: adRWZp( &Cpu::ROL ); break; case 0x36: adRWZx( &Cpu::ROL ); break; case 0x2E: adRWAb( &Cpu::ROL ); break; case 0x3E: adRWAx( &Cpu::ROL ); break; /* ROR */ case 0x6A: adImplied(); ROR(cpu.A); break; case 0x66: adRWZp( &Cpu::ROR ); break; case 0x76: adRWZx( &Cpu::ROR ); break; case 0x6E: adRWAb( &Cpu::ROR ); break; case 0x7E: adRWAx( &Cpu::ROR ); break; /* SBC */ case 0xE9: SBC( adRdIm() ); break; case 0xE5: SBC( adRdZp() ); break; case 0xF5: SBC( adRdZx() ); break; case 0xED: SBC( adRdAb() ); break; case 0xFD: SBC( adRdAx() ); break; case 0xF9: SBC( adRdAy() ); break; case 0xE1: SBC( adRdIx() ); break; case 0xF1: SBC( adRdIy() ); break; /* STA */ case 0x85: adWrZp( cpu.A ); break; case 0x95: adWrZx( cpu.A ); break; case 0x8D: adWrAb( cpu.A ); break; case 0x9D: adWrAx( cpu.A ); break; case 0x99: adWrAy( cpu.A ); break; case 0x81: adWrIx( cpu.A ); break; case 0x91: adWrIy( cpu.A ); break; /* STX */ case 0x86: adWrZp( cpu.X ); break; case 0x96: adWrZy( cpu.X ); break; case 0x8E: adWrAb( cpu.X ); break; /* STY */ case 0x84: adWrZp( cpu.Y ); break; case 0x94: adWrZx( cpu.Y ); break; case 0x8C: adWrAb( cpu.Y ); break; ///////////////////////////////////// // Unofficial ops /* One offs */ case 0x0B: case 0x2B: ANC( adRdIm() ); break; /* ANC */ case 0x4B: ALR( adRdIm() ); break; /* ALR */ case 0x6B: ARR( adRdIm() ); break; /* ARR */ case 0xCB: AXS( adRdIm() ); break; /* AXS */ case 0xBB: LAS( adRdAy() ); break; /* LAS */ case 0xEB: SBC( adRdIm() ); break; /* alternative SBC */ case 0x9E: adWrAy_xxx( cpu.X ); break; /* SHX */ case 0x9C: adWrAx_xxx( cpu.Y ); break; /* SHY */ case 0x8B: XAA( adRdIm() ); break; /* XAA */ case 0x9B: cpu.SP = cpu.A & cpu.X; adWrAy_xxx( cpu.SP ); break; /* TAS */ /* AHX */ case 0x9F: adWrAy_xxx( cpu.A & cpu.X ); break; case 0x93: adWrIy_xxx( cpu.A & cpu.X ); break; /* DCP */ case 0xC7: adRWZp( &Cpu::DCP ); break; case 0xD7: adRWZx( &Cpu::DCP ); break; case 0xCF: adRWAb( &Cpu::DCP ); break; case 0xDF: adRWAx( &Cpu::DCP ); break; case 0xDB: adRWAy( &Cpu::DCP ); break; case 0xC3: adRWIx( &Cpu::DCP ); break; case 0xD3: adRWIy( &Cpu::DCP ); break; /* ISC */ case 0xE7: adRWZp( &Cpu::ISC ); break; case 0xF7: adRWZx( &Cpu::ISC ); break; case 0xEF: adRWAb( &Cpu::ISC ); break; case 0xFF: adRWAx( &Cpu::ISC ); break; case 0xFB: adRWAy( &Cpu::ISC ); break; case 0xE3: adRWIx( &Cpu::ISC ); break; case 0xF3: adRWIy( &Cpu::ISC ); break; /* LAX */ case 0xAB: LAX( adRdIm() ); break; case 0xA7: LAX( adRdZp() ); break; case 0xB7: LAX( adRdZy() ); break; case 0xAF: LAX( adRdAb() ); break; case 0xBF: LAX( adRdAy() ); break; case 0xA3: LAX( adRdIx() ); break; case 0xB3: LAX( adRdIy() ); break; /* NOP */ case 0x1A: case 0x3A: case 0x5A: case 0x7A: case 0xDA: case 0xFA: adImplied();break; case 0x04: case 0x44: case 0x64: adRdZp(); break; case 0x14: case 0x34: case 0x54: case 0x74: case 0xD4: case 0xF4: adRdZx(); break; case 0x80: case 0x82: case 0x89: case 0xC2: case 0xE2: adRdIm(); break; case 0x0C: adRdAb(); break; case 0x1C: case 0x3C: case 0x5C: case 0x7C: case 0xDC: case 0xFC: adRdAx(); break; /* RLA */ case 0x27: adRWZp( &Cpu::RLA ); break; case 0x37: adRWZx( &Cpu::RLA ); break; case 0x2F: adRWAb( &Cpu::RLA ); break; case 0x3F: adRWAx( &Cpu::RLA ); break; case 0x3B: adRWAy( &Cpu::RLA ); break; case 0x23: adRWIx( &Cpu::RLA ); break; case 0x33: adRWIy( &Cpu::RLA ); break; /* RRA */ case 0x67: adRWZp( &Cpu::RRA ); break; case 0x77: adRWZx( &Cpu::RRA ); break; case 0x6F: adRWAb( &Cpu::RRA ); break; case 0x7F: adRWAx( &Cpu::RRA ); break; case 0x7B: adRWAy( &Cpu::RRA ); break; case 0x63: adRWIx( &Cpu::RRA ); break; case 0x73: adRWIy( &Cpu::RRA ); break; /* SAX */ case 0x87: adWrZp( cpu.A & cpu.X ); break; case 0x97: adWrZy( cpu.A & cpu.X ); break; case 0x8F: adWrAb( cpu.A & cpu.X ); break; case 0x83: adWrIx( cpu.A & cpu.X ); break; /* SLO */ case 0x07: adRWZp( &Cpu::SLO ); break; case 0x17: adRWZx( &Cpu::SLO ); break; case 0x0F: adRWAb( &Cpu::SLO ); break; case 0x1F: adRWAx( &Cpu::SLO ); break; case 0x1B: adRWAy( &Cpu::SLO ); break; case 0x03: adRWIx( &Cpu::SLO ); break; case 0x13: adRWIy( &Cpu::SLO ); break; /* SRE */ case 0x47: adRWZp( &Cpu::SRE ); break; case 0x57: adRWZx( &Cpu::SRE ); break; case 0x4F: adRWAb( &Cpu::SRE ); break; case 0x5F: adRWAx( &Cpu::SRE ); break; case 0x5B: adRWAy( &Cpu::SRE ); break; case 0x43: adRWIx( &Cpu::SRE ); break; case 0x53: adRWIy( &Cpu::SRE ); break; /* STP */ case 0x02: case 0x12: case 0x22: case 0x32: case 0x42: case 0x52: case 0x62: case 0x72: case 0x92: case 0xB2: case 0xD2: case 0xF2: cpuJammed = true; setMainTimestamp(runto); break; } } }
static inline void sha1_do_chunk(unsigned char W[], unsigned int h[]) { unsigned int a, b, c, d, e; unsigned int w[80]; #define CPY(i) w[i] = be32_to_cpu(((unsigned int *) W)[i]) CPY(0); CPY(1); CPY(2); CPY(3); CPY(4); CPY(5); CPY(6); CPY(7); CPY(8); CPY(9); CPY(10); CPY(11); CPY(12); CPY(13); CPY(14); CPY(15); #undef CPY a = h[0]; b = h[1]; c = h[2]; d = h[3]; e = h[4]; /* following unrolled from: * for (i = 0; i < 20; i++) { * t = f1(b, c, d) + K1 + rol32(a, 5) + e + M(i); * e = d; d = c; c = rol32(b, 30); b = a; a = t; * } */ R(a, b, c, d, e, f1, K1, w[0]); R(e, a, b, c, d, f1, K1, w[1]); R(d, e, a, b, c, f1, K1, w[2]); R(c, d, e, a, b, f1, K1, w[3]); R(b, c, d, e, a, f1, K1, w[4]); R(a, b, c, d, e, f1, K1, w[5]); R(e, a, b, c, d, f1, K1, w[6]); R(d, e, a, b, c, f1, K1, w[7]); R(c, d, e, a, b, f1, K1, w[8]); R(b, c, d, e, a, f1, K1, w[9]); R(a, b, c, d, e, f1, K1, w[10]); R(e, a, b, c, d, f1, K1, w[11]); R(d, e, a, b, c, f1, K1, w[12]); R(c, d, e, a, b, f1, K1, w[13]); R(b, c, d, e, a, f1, K1, w[14]); R(a, b, c, d, e, f1, K1, w[15]); R(e, a, b, c, d, f1, K1, M(16)); R(d, e, a, b, c, f1, K1, M(17)); R(c, d, e, a, b, f1, K1, M(18)); R(b, c, d, e, a, f1, K1, M(19)); /* following unrolled from: * for (i = 20; i < 40; i++) { * t = f2(b, c, d) + K2 + rol32(a, 5) + e + M(i); * e = d; d = c; c = rol32(b, 30); b = a; a = t; * } */ R(a, b, c, d, e, f2, K2, M(20)); R(e, a, b, c, d, f2, K2, M(21)); R(d, e, a, b, c, f2, K2, M(22)); R(c, d, e, a, b, f2, K2, M(23)); R(b, c, d, e, a, f2, K2, M(24)); R(a, b, c, d, e, f2, K2, M(25)); R(e, a, b, c, d, f2, K2, M(26)); R(d, e, a, b, c, f2, K2, M(27)); R(c, d, e, a, b, f2, K2, M(28)); R(b, c, d, e, a, f2, K2, M(29)); R(a, b, c, d, e, f2, K2, M(30)); R(e, a, b, c, d, f2, K2, M(31)); R(d, e, a, b, c, f2, K2, M(32)); R(c, d, e, a, b, f2, K2, M(33)); R(b, c, d, e, a, f2, K2, M(34)); R(a, b, c, d, e, f2, K2, M(35)); R(e, a, b, c, d, f2, K2, M(36)); R(d, e, a, b, c, f2, K2, M(37)); R(c, d, e, a, b, f2, K2, M(38)); R(b, c, d, e, a, f2, K2, M(39)); /* following unrolled from: * for (i = 40; i < 60; i++) { * t = f3(b, c, d) + K3 + rol32(a, 5) + e + M(i); * e = d; d = c; c = rol32(b, 30); b = a; a = t; * } */ R(a, b, c, d, e, f3, K3, M(40)); R(e, a, b, c, d, f3, K3, M(41)); R(d, e, a, b, c, f3, K3, M(42)); R(c, d, e, a, b, f3, K3, M(43)); R(b, c, d, e, a, f3, K3, M(44)); R(a, b, c, d, e, f3, K3, M(45)); R(e, a, b, c, d, f3, K3, M(46)); R(d, e, a, b, c, f3, K3, M(47)); R(c, d, e, a, b, f3, K3, M(48)); R(b, c, d, e, a, f3, K3, M(49)); R(a, b, c, d, e, f3, K3, M(50)); R(e, a, b, c, d, f3, K3, M(51)); R(d, e, a, b, c, f3, K3, M(52)); R(c, d, e, a, b, f3, K3, M(53)); R(b, c, d, e, a, f3, K3, M(54)); R(a, b, c, d, e, f3, K3, M(55)); R(e, a, b, c, d, f3, K3, M(56)); R(d, e, a, b, c, f3, K3, M(57)); R(c, d, e, a, b, f3, K3, M(58)); R(b, c, d, e, a, f3, K3, M(59)); /* following unrolled from: * for (i = 60; i < 80; i++) { * t = f2(b, c, d) + K4 + rol32(a, 5) + e + M(i); * e = d; d = c; c = rol32(b, 30); b = a; a = t; * } */ R(a, b, c, d, e, f4, K4, M(60)); R(e, a, b, c, d, f4, K4, M(61)); R(d, e, a, b, c, f4, K4, M(62)); R(c, d, e, a, b, f4, K4, M(63)); R(b, c, d, e, a, f4, K4, M(64)); R(a, b, c, d, e, f4, K4, M(65)); R(e, a, b, c, d, f4, K4, M(66)); R(d, e, a, b, c, f4, K4, M(67)); R(c, d, e, a, b, f4, K4, M(68)); R(b, c, d, e, a, f4, K4, M(69)); R(a, b, c, d, e, f4, K4, M(70)); R(e, a, b, c, d, f4, K4, M(71)); R(d, e, a, b, c, f4, K4, M(72)); R(c, d, e, a, b, f4, K4, M(73)); R(b, c, d, e, a, f4, K4, M(74)); R(a, b, c, d, e, f4, K4, M(75)); R(e, a, b, c, d, f4, K4, M(76)); R(d, e, a, b, c, f4, K4, M(77)); R(c, d, e, a, b, f4, K4, M(78)); R(b, c, d, e, a, f4, K4, M(79)); h[0] += a; h[1] += b; h[2] += c; h[3] += d; h[4] += e; }
void mad_cmat_copy(const cnum_t x[], cnum_t r[], ssz_t m, ssz_t n, ssz_t ldx, ssz_t ldr) { CHKXRX; CPY(); }
void mad_mat_copym(const num_t x[], cnum_t r[], ssz_t m, ssz_t n, ssz_t ldx, ssz_t ldr) { CHKXR; CPY(); }
// ************************************************* // ************************************************* // Pass2 // ************************************************* // ************************************************* uint8_t xvid4EncoderPass2::init (uint32_t br, uint32_t fps1000, xvid4EncParam * param) { int xerr; printf ("[xvid] Pass 2 of 2, average bitrate = %lu\n", br); _bitrate = br; _fps1000 = fps1000; memcpy (&_param, param, sizeof (_param)); dump (); // Here we go... MMSET (xvid_enc_create); MMSET (pass2); xvid_enc_create.version = XVID_VERSION; xvid_enc_create.width = _w; xvid_enc_create.height = _h; plugins[0].func = xvid_plugin_2pass2; plugins[0].param = &pass2; plugins[1].func = adm_hook; plugins[1].param = NULL; pass2.version = XVID_VERSION; pass2.filename = (char *) _param.logName; pass2.bitrate = br; // Average bitrate #define CPY(x) pass2.x=_param.x;printf("[xvid] "#x"=%d\n",pass2.x); CPY (keyframe_boost); CPY (curve_compression_high); CPY (curve_compression_low); CPY (overflow_control_strength); CPY (max_overflow_improvement); CPY (max_overflow_degradation); CPY (kfreduction); CPY (kfthreshold); CPY (container_frame_overhead); xvid_enc_create.plugins = plugins; xvid_enc_create.num_plugins = 2; //Framerate xvid_enc_create.fincr = 1000; xvid_enc_create.fbase = _fps1000; // createUpdate (); xerr = xvid_encore (NULL, XVID_ENC_CREATE, &xvid_enc_create, NULL); if (xerr < 0) { printf ("[xvid] Init error: %d\n", xerr); return 0; } _handle = xvid_enc_create.handle; printf ("[xvid] Init Ok\n"); return 1; }
Actor::Actor( const Actor &cpy ): IMessageSubscriber( cpy ) { /* Don't copy an Actor in the middle of rendering. */ ASSERT( cpy.m_pTempState == NULL ); m_pTempState = NULL; #define CPY(x) x = cpy.x CPY( m_sName ); //CPY( m_pParent ); //CPY( m_pLuaInstance ); CPY( m_baseRotation ); CPY( m_baseScale ); CPY( m_fBaseAlpha ); CPY( m_size ); CPY( m_current ); CPY( m_start ); //for( unsigned i = 0; i < cpy.m_Tweens.size(); ++i ) //m_Tweens.push_back( new TweenStateAndInfo((*cpy).m_Tweens[i]) ); m_Tweens = cpy.m_Tweens; CPY( m_bFirstUpdate ); CPY( m_HorizAlign ); CPY( m_VertAlign ); CPY( m_Effect ); CPY( m_fSecsIntoEffect ); CPY( m_fEffectDelta ); //CPY( m_fEffectRampUp ); //CPY( m_fEffectHoldAtHalf ); //CPY( m_fEffectRampDown ); //CPY( m_fEffectHoldAtZero ); CPY( m_fEffectOffset ); CPY( m_EffectClock ); CPY( m_effectColor1 ); CPY( m_effectColor2 ); CPY( m_vEffectMagnitude ); CPY( m_bVisible ); CPY( m_fHibernateSecondsLeft ); CPY( m_fShadowLength ); CPY( m_bIsAnimating ); CPY( m_iDrawOrder ); CPY( m_bTextureWrapping ); //CPY( m_bTextureFiltering ); CPY( m_BlendMode ); CPY( m_bClearZBuffer ); CPY( m_ZTestMode ); CPY( m_bZWrite ); CPY( m_fZBias ); CPY( m_CullMode ); CPY( m_mapNameToCommands ); #undef CPY }