int8_t testADCHelper(CPU *c, int8_t accumByte, int8_t operand){ OP_CODE_INFO *o = getOP_CODE_INFO(operand,0,modeImmediate); setRegByte(c,ACCUM,accumByte); adc(c,o); freeOP_CODE_INFO(o); return getRegByte(c,ACCUM); }
void CompilerFactory::LoadSettings() { bool needAutoDetection = false; for (size_t i = 0; i < Compilers.GetCount(); ++i) { wxString baseKey = Compilers[i]->GetParentID().IsEmpty() ? _T("/sets") : _T("/user_sets"); Compilers[i]->LoadSettings(baseKey); CodeBlocksEvent event(cbEVT_COMPILER_SETTINGS_CHANGED); event.SetString(Compilers[i]->GetID()); event.SetInt(static_cast<int>(i)); event.SetClientData(static_cast<void*>(Compilers[i])); Manager::Get()->ProcessEvent(event); if (Compilers[i]->GetMasterPath().IsEmpty()) { Manager::Get()->GetLogManager()->DebugLog(F(_T("Master path of compiler ID \"%s\" is empty -> triggers auto-detection."), Compilers[i]->GetID().wx_str())); needAutoDetection = true; } } // auto-detect missing compilers if (needAutoDetection) { AutoDetectCompilers adc(Manager::Get()->GetAppWindow()); PlaceWindow(&adc); adc.ShowModal(); adc.Raise(); } }
Code() { Xbyak::Label label; cmpss(xmm0, ptr[rip + label], 0); test(dword[rip + label], 33); bt(dword[rip + label ], 3); vblendpd(xmm0, dword[rip + label], 3); vpalignr(xmm0, qword[rip + label], 4); vextractf128(dword[rip + label], ymm3, 12); vperm2i128(ymm0, ymm1, qword[rip + label], 13); vcvtps2ph(ptr[rip + label], xmm2, 44); mov(dword[rip + label], 0x1234); shl(dword[rip + label], 3); shr(dword[rip + label], 1); shld(qword[rip + label], rax, 3); imul(rax, qword[rip + label], 21); rorx(rax, qword[rip + label], 21); test(dword[rip + label], 5); pextrq(ptr[rip + label], xmm0, 3); pinsrq(xmm2, ptr[rip + label], 5); pextrw(ptr[rip + label], xmm1, 4); adc(dword[rip + label], 0x12345); bt(byte[rip + label], 0x34); btc(word[rip + label], 0x34); btr(dword[rip + label], 0x34); rcl(dword[rip + label], 4); shld(qword[rip + label], rax, 4); palignr(mm0, ptr[rip + label], 4); aeskeygenassist(xmm3, ptr[rip + label], 4); vpcmpestrm(xmm2, ptr[rip + label], 7); ret(); L(label); dq(0x123456789abcdef0ull); };
void vTaskAdc( void * args ) { static portTickType prevTime; static portTickType pointTime; static TData * st; int32_t i; st = data(); filterInit(); prevTime = xTaskGetTickCount(); pointTime = 0; for ( ;; ) { // Get ADC data. i = adc(); // Filter ADC data. i = filter( i ); // Put ADC data. adcSetData( i ); vTaskDelayUntil( &prevTime, ADC_INTERVAL ); pointTime += ADC_INTERVAL; if ( pointTime >= PLOT_TIME_PER_PT ) { pointTime = 0; plotPlaceCurrentData(); } } }
void newbrain_eim_device::device_add_mconfig(machine_config &config) { // devices Z80CTC(config, m_ctc, XTAL(16'000'000)/8); m_ctc->zc_callback<0>().set(m_acia, FUNC(acia6850_device::write_rxc)); m_ctc->zc_callback<1>().set(m_acia, FUNC(acia6850_device::write_txc)); m_ctc->zc_callback<2>().set(FUNC(newbrain_eim_device::ctc_z2_w)); TIMER(config, "z80ctc_c2").configure_periodic(FUNC(newbrain_eim_device::ctc_c2_tick), attotime::from_hz(XTAL(16'000'000)/4/13)); adc0809_device &adc(ADC0809(config, ADC0809_TAG, 500000)); adc.eoc_callback().set(FUNC(newbrain_eim_device::adc_eoc_w)); adc.in_callback<0>().set_constant(0); adc.in_callback<1>().set_constant(0); adc.in_callback<2>().set_constant(0); adc.in_callback<3>().set_constant(0); adc.in_callback<4>().set_constant(0); adc.in_callback<5>().set_constant(0); adc.in_callback<6>().set_constant(0); adc.in_callback<7>().set_constant(0); ACIA6850(config, m_acia, 0); m_acia->irq_handler().set(FUNC(newbrain_eim_device::acia_interrupt)); RS232_PORT(config, RS232_TAG, default_rs232_devices, nullptr); NEWBRAIN_EXPANSION_SLOT(config, m_exp, XTAL(16'000'000)/8, newbrain_expansion_cards, "fdc"); // internal ram RAM(config, RAM_TAG).set_default_size("96K"); }
void model1io_device::device_add_mconfig(machine_config &config) { z80_device &iocpu(Z80(config, "iocpu", 32_MHz_XTAL/8)); iocpu.set_addrmap(AS_PROGRAM, &model1io_device::mem_map); EEPROM_93C46_16BIT(config, m_eeprom); // 93C45 sega_315_5338a_device &io(SEGA_315_5338A(config, "io", 32_MHz_XTAL)); io.read_callback().set(FUNC(model1io_device::io_r)); io.write_callback().set(FUNC(model1io_device::io_w)); io.out_pa_callback().set(FUNC(model1io_device::io_pa_w)); io.in_pb_callback().set(FUNC(model1io_device::io_pb_r)); io.in_pc_callback().set(FUNC(model1io_device::io_pc_r)); io.in_pd_callback().set(FUNC(model1io_device::io_pd_r)); io.in_pe_callback().set(FUNC(model1io_device::io_pe_r)); io.out_pe_callback().set(FUNC(model1io_device::io_pe_w)); io.out_pf_callback().set(FUNC(model1io_device::io_pf_w)); io.in_pg_callback().set(FUNC(model1io_device::io_pg_r)); msm6253_device &adc(MSM6253(config, "adc", 0)); adc.set_input_cb<0>(FUNC(model1io_device::analog0_r)); adc.set_input_cb<1>(FUNC(model1io_device::analog1_r)); adc.set_input_cb<2>(FUNC(model1io_device::analog2_r)); adc.set_input_cb<3>(FUNC(model1io_device::analog3_r)); }
//main****************************************************************** int main(void) { DDRB =0xFF; DIDR0=1<<ADC1D; ADMUX=0b00000001; ADCSRA=0b10000100; PORTB=1<<PB2; while(8){ int k=0; for(k=0;k<200;k++) { //led(k); led(adc()); } } }
int HcalDigi::adcTotal() { int retval = 0.; for (int i = 0; i < size(); ++i) { retval += adc(i); } return retval; }
void main() { lcd_ini(); lcd_dataa("%Rel.Humidity:"); while(1) { adc(); } }
inline static void atualizar_sensor(sensor s,uint16_t *valor_l,uint8_t *bit) { uint16_t valor = adc(s.canal_adc); /* O conversor A/D fornece valores com uma pequena taxa de variação. Por exemplo: 780 781 779 Caso o sensor de linha seja posicionado em uma área onde a intensidade luminosa seja perto do valor de linha e do valor de fundo,essa variação pode ser o suficiente deixar em dúvida se o sensor está realmente sobre a linha ou sobre o fundo. Ex: valor de linha 200 e de fundo 300, sendo que ele considera como linha valores menores que 250. O sensor chega perto da linha,em um ponto que o ele lê o valor 250.Agora imagina o que acontece se esse valor variar. 251 -> fundo 249 -> linha 250 -> fundo Caso essa situação aconteça, o robo ira ficar parado,pois esses valores variam em um período muito menor do que o necessário para os motores se moverem ou para moverem o robo a alguma distancia significativa. EX: Deu 251, o robo liga os motores para ir para frente.Mas antes que os motores comecem a girar,o sensor retorna 249,fazendo que o robo inverta a rotação de uns dos motores para ele girar em torno do próprio eixo.Mas de novo o valor do sensor muda e o robo tenta mudar de direção.E fica em um loop infinito. Por tanto,o que fazemos é comparar o novo resultado com o antigo,e caso a variação for muito pequena nós simplesmente não fazemos nada. */ if (VARIACAO_EM_MODULO(valor,*valor_l) > FAIXA_DE_VARIACAO) { /* Quando calibramos o sensor, nós medimos a linha com ele completamente em cima dela.Mas devido a maneira que o feixe de luz da led se propaga(em forma de cone), quando o sensor estiver bem próximo da linha(de forma que as bordas da linha sejam atingidas pela luz da led), o valor lido pelo sensor irá cair para um valor acima do medido na calibragem da linha e abaixo do valor medido na calibragem do fundo.Por tanto, já consideramos como linha qualquer valor abaixo da média entre o valor do fundo e o valor da linha. */ *bit = (valor < s.media); *valor_l = valor; } }
void interrupt isr(void) { uint8_t i; if (PIR1bits.RCIF == 1) { PIR1bits.RCIF = 0; } if (PIR1bits.TXIF & PIE1bits.TXIE) { if (ringbuf_num(&tx_buf)) { TXREG = ringbuf_pop(&tx_buf); } else { PIE1bits.TXIE = 0; } } if (PIR1bits.TMR1IF == 1) { PIR1bits.TMR1IF = 0; button_timer_interrupt(&sh_0, !SH0); button_timer_interrupt(&sh_1, !SH1); button_timer_interrupt(&sh_2, !SH2); button_timer_interrupt(&sw_0, !SW0); button_timer_interrupt(&sw_1, !SW1); for (i = 0; i < 3; i++) { if (auto_cut_ON[i]) { v[i] = 2 * adc(i)*4 / 5; // *3/4 tyousetsu if (v[i] < CUT_current) { //もし一定電流を下回ったらカウントアップスタート cut[i]++; if (cut[i] >= 30 * CUT_time) { //一定時間たったら、出力シャットアウト cut_flag[i] = 1; } } else { //経過時間カウントリセット cut[i] = 0; } } } } if (INTCONbits.TMR0IF == 1) { INTCONbits.TMR0IF = 0; cnt0++; if (cnt0 == 400) { cnt0 = 0; lchika(); display(print_port, print_content); } cnt1s++; if (cnt1s == 1953) { cnt1s = 0; for (i = 0; i < 3; i++) { ss[i] += v[i]; s[i] = ss[i] / 3600; if (s[i] != sp[i]) { change_flag[i] = 1; sp[i] = s[i]; } } } } }
unsigned char ReadTouchSensor(unsigned char chip,unsigned char channel) { unsigned char value; chipsel(chip); value = adc(channel); // get one channel of analog input chipunsel(); return value; }
static void hposn(void) { unsigned char msktbl[]={0x81,0x82,0x84,0x88,0x90,0xA0,0xC0}; // F411 ram[HGR_Y]=a; ram[HGR_X]=x; ram[HGR_X+1]=y; pha(); a=a&0xC0; ram[GBASL]=a; lsr(); lsr(); a=a|ram[GBASL]; ram[GBASL]=a; pla(); // F423 ram[GBASH]=a; asl(); asl(); asl(); rol_mem(GBASH); asl(); rol_mem(GBASH); asl(); ror_mem(GBASL); lda(GBASH); a=a&0x1f; a=a|ram[HGR_PAGE]; ram[GBASH]=a; // F438 a=x; cpy(0); if (z==1) goto hposn_2; y=35; adc(4); hposn_1: iny(); // f442 hposn_2: sbc(7); if (c==1) goto hposn_1; ram[HGR_HORIZ]=y; x=a; a=msktbl[(x-0x100)+7]; // LDA MSKTBL-$100+7,X BIT MASK // MSKTBL=F5B8 ram[HMASK]=a; a=y; lsr(); a=ram[HGR_COLOR]; ram[HGR_BITS]=a; if (c) color_shift(); }
int main() { init(); printf("Hello\r\n"); PORTD |= (1 << PD3); DDRD |= (1 << PD3); DDRB |= (1 << PB1); PORTB &= ~(1 << PB1); _delay_ms(100); lcd.init(); lcd.clear(); lcd.go(10, 10); fprintf(&lcd.lcdf, "lala"); lcd.sync(); for (;;) { uint8_t ambient; uint16_t tip; readTemperature(&ambient, &tip); uint16_t setTemp = (((float) adc()) / 0xffff) * 210 + 190; regulator.setWanted(setTemp); lcd.clear(); lcd.go(10, 2); fprintf(&lcd.lcdf, "Ext %3d C", ambient); lcd.go(10, 12); fprintf(&lcd.lcdf, "Tip %3d C", tip); lcd.go(10, 22); regulator.processInput(tip); if (setTemp >= 200) { pwm1::setDuty(regulator.getOutput()); fprintf(&lcd.lcdf, "Set %3d C", setTemp); lcd.go(10, 32); fprintf(&lcd.lcdf, "%3d%% %3d%%", (int16_t) (regulator.getP() * 100), (int16_t) (regulator.getI() * 100)); } else { pwm1::setDuty(0); fprintf(&lcd.lcdf, "OFF"); } lcd.sync(); _delay_ms(50); } }
LRESULT CMainDlg::OnPaint(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { //CWindowDC adc(m_hWnd); RECT rectWindow={0}; GetWindowRect(&rectWindow); WTL::CMemoryDC adc(GetWindowDC(), rectWindow); RECT rect ={0,0, 100, 100}; adc.DrawText(L"abc", 4, &rect, 0); bHandled = FALSE; return 0; }
int main() { ADS1115 adc(ADS1115_DEFAULT_ADDRESS); adc.setMultiplexer(ADS1115_MUX_P1_NG); adc.setMode(ADS1115_MODE_CONTINUOUS); while (true) { float mV = adc.getMilliVolts(); printf("mV: %f\n", mV ); } return 0; }
int main(void) { halInit(); chSysInit(); chThdSleepMilliseconds(200); // input capture & high-res timer const ICUConfig icuConfig = { ICU_INPUT_ACTIVE_HIGH, 1000000, nullptr, nullptr, nullptr, nullptr, nullptr }; icuStart(&TIMING_ICU, &icuConfig); icuEnable(&TIMING_ICU); // serial setup const SerialConfig btSerialConfig = { 921600, 0, USART_CR2_STOP1_BITS, USART_CR3_CTSE | USART_CR3_RTSE }; sdStart(&BT_SERIAL, &btSerialConfig); // PWM setup const PWMConfig mPWMConfig = { STM32_TIMCLK1, PWM_PERIOD, nullptr, { { PWM_OUTPUT_DISABLED, nullptr }, { PWM_OUTPUT_DISABLED, nullptr }, { PWM_OUTPUT_ACTIVE_HIGH, nullptr }, { PWM_OUTPUT_ACTIVE_HIGH, nullptr } }, 0, }; pwmStart(&M1_PWM, &mPWMConfig); // SPI setup // speed = pclk/8 = 5.25MHz const SPIConfig m1SPIConfig = { NULL, GPIOC, GPIOC_M1_NSS, SPI_CR1_DFF | SPI_CR1_BR_1 }; const SPIConfig m2SPIConfig = { NULL, GPIOD, GPIOD_M2_NSS, SPI_CR1_DFF | SPI_CR1_BR_1 }; const SPIConfig adcSPIConfig = { NULL, GPIOA, GPIOA_ADC_NSS, SPI_CR1_BR_2 | SPI_CR1_CPHA }; spiStart(&M1_SPI, &m1SPIConfig); spiStart(&M2_SPI, &m2SPIConfig); spiStart(&ADC_SPI, &adcSPIConfig); // motor setup A4960 m1(&M1_SPI, &M1_PWM, M1_PWM_CHAN); A4960 m2(&M2_SPI, &M2_PWM, M2_PWM_CHAN); // ADC setup ADS1259 adc(&ADC_SPI); // initialize control structure Tortilla tortilla(m1, m2, adc, &TIMING_ICU, &BT_SERIAL); // start slave threads // chThdCreateStatic(waHeartbeat, sizeof(waHeartbeat), IDLEPRIO, tfunc_t(threadHeartbeat), nullptr); chThdCreateStatic(waIO, sizeof(waIO), LOWPRIO, tfunc_t(threadIO), &tortilla); // done with setup palClearPad(GPIOC, GPIOC_LEDB); palClearPad(GPIOB, GPIOB_LED2); tortilla.fastLoop(); }
void interrupt isr(void) { if (PIR1bits.TMR1IF == 1) { PIR1bits.TMR1IF = 0; cnt1++; if (cnt1 == 15) { cnt1 = 0; for (i = 0; i < 4; i++) { temp[i] = adc(i); v[i] = temp[i] * 2; } } } if (INTCONbits.TMR0IF == 1) { INTCONbits.TMR0IF = 0; cnt0++; if (cnt0 == 400) { cnt0 = 0; for (k = 0; k < 4; k++) { if (cutf[k])cut[k]++; } cnt++; if (cnt == 40) { cnt = 0; } for (j = 0; j < 4; j++) { d[j] = v[j] / 100; } if ((cnt % 2) == 1) { if (((cnt + 1) / 2) <= d[0]) { PORTBbits.RB4 = 1; } if (((cnt + 1) / 2) <= d[1]) { PORTBbits.RB5 = 1; } if (((cnt + 1) / 2) <= d[2]) { PORTBbits.RB6 = 1; } if (((cnt + 1) / 2) <= d[3]) { PORTBbits.RB7 = 1; } } else { PORTB = PORTB & 0b00001111; } } } }
int NXLFSFolder::buildc() { if(!m_collections) return 0; //NXMutexLocker ml(m_mutex, "buildc", "n/a"); C* c = NULL; auto_deletev<C> adc(&c); NXLFSFileRAR::Fni fni; for(NXLFSFile* ff = m_files; ff; ff = ff->next()) { if(NXLFSFileRAR::analyze(fni, ff->name()) < 0) continue; C* cc; for(cc = c; cc; cc = cc->n) { if(cc->l == fni.bnl && wcsncmp(cc->i, ff->name(), fni.bnl) == 0) { break; } } if(!cc) c = cc = new C(ff->name(), fni.bnl, c); if(cc->f[fni.part]) return R(-1, "naming conflict"); // could have test.rar and test.part01.rar in same dir cc->f[fni.part] = ff; cc->k |= fni.kaputt; } for(C* cc = c; cc; cc = cc->n) { bool ok = !cc->k; for(int i = 0; ok && i < NXRARP-1; i++) { if(cc->f[i] == NULL && cc->f[i+1]) { ok = false; } } if(ok) { releasefiles(cc->f); m_folders = new NXLFSFolderRAR(cc->f[0], cc->i, cc->f[0]->time(), m_folders); } } return 0; }
void sniper() { init_all(); // set voltage reference to 5V clear(ADMUX, REFS1); set(ADMUX, REFS0); m_disableJTAG();//allowing gpio of F pins //setting ADC prescaler set(ADCSRA,ADPS2); set(ADCSRA,ADPS1); set(ADCSRA,ADPS0); //setting pins to turn off digital circuitry set(DIDR0,ADC1D);//setting F1 set(DIDR0,ADC4D);//setting F4 set(DIDR0,ADC5D);//setting F5 set(DIDR0,ADC6D);//setting F6 set(DIDR0,ADC7D);//setting F7 set(ADCSRA, ADEN); play_state = 1; set_position(1024/2, 768/2); first = true; //state_before_game(); //state_play(); m_usb_init(); /* while(!m_usb_isconnected()); m_green(ON); */ set_left(30); set_right(100); while(1) { adc(); // m_usb_tx_string("left: "); //m_usb_tx_int(a_left); wait(1); } }
void SkBaseDevice::drawTextRSXform(const void* text, size_t len, const SkRSXform xform[], const SkPaint& paint) { CountTextProc proc = nullptr; switch (paint.getTextEncoding()) { case SkPaint::kUTF8_TextEncoding: proc = SkUTF8_CountUTF8Bytes; break; case SkPaint::kUTF16_TextEncoding: proc = count_utf16; break; case SkPaint::kUTF32_TextEncoding: proc = return_4; break; case SkPaint::kGlyphID_TextEncoding: proc = return_2; break; } SkPaint localPaint(paint); SkShader* shader = paint.getShader(); SkMatrix localM, currM; const void* stopText = (const char*)text + len; while ((const char*)text < (const char*)stopText) { localM.setRSXform(*xform++); currM.setConcat(this->ctm(), localM); SkAutoDeviceCTMRestore adc(this, currM); // We want to rotate each glyph by the rsxform, but we don't want to rotate "space" // (i.e. the shader that cares about the ctm) so we have to undo our little ctm trick // with a localmatrixshader so that the shader draws as if there was no change to the ctm. if (shader) { SkMatrix inverse; if (localM.invert(&inverse)) { localPaint.setShader(shader->makeWithLocalMatrix(inverse)); } else { localPaint.setShader(nullptr); // can't handle this xform } } int subLen = proc((const char*)text); this->drawText(text, subLen, 0, 0, localPaint); text = (const char*)text + subLen; } }
void main(void){ unsigned char adc_value; OSCCON = 0b00111000; //500KHz clock speed TRISC = 0; //all LED pins are outputs //setup ADC TRISAbits.TRISA4 = 1; //Potentiamtor is connected to RA4...set as input ANSELAbits.ANSA4 = 1; //analog ADCON0 = 0b00001101; //select RA4 as source of ADC and enable the module (AN3) ADCON1 = 0b00010000; //left justified - FOSC/8 speed - Vref is Vdd while(1){ adc_value = adc(); //get the ADC value from the POT adc_value >>= 4; //save only the top 4 MSbs LATC = gray_code[adc_value]; //convert to Grey Code and display on the LEDs } }
inline static void calibrar_fundo(sensor * s) { uint16_t f; f = adc(s->canal_adc); /* Ao contrário do feito acima, nós guardamos o menor valor. Caso pegaçemos qualquer valor,a variação de luminosidade e outros fatores externos poderiam provocar uma leitura abaixo da calibrada,fazendo com que o robo não reconhecesse a superfície como sendo o fundo da pista.Mas não há poblema se o valor medido for acima,pois o robo continuara renconhedendo a superfície como o fundo. */ if (f < s->valor.fundo || s->valor.fundo == 0) s->valor.fundo = f; }
void CompilerFactory::LoadSettings() { bool needAutoDetection = false; for (size_t i = 0; i < Compilers.GetCount(); ++i) { wxString baseKey = Compilers[i]->GetParentID().IsEmpty() ? _T("/sets") : _T("/user_sets"); Compilers[i]->LoadSettings(baseKey); if (Compilers[i]->GetMasterPath(false).IsEmpty()) needAutoDetection = true; } // auto-detect missing compilers if (needAutoDetection) { AutoDetectCompilers adc(Manager::Get()->GetAppWindow()); PlaceWindow(&adc); adc.ShowModal(); } }
void akkuSpannungPruefen(int schwellwert) { // Prüfe die AkkuSpannung nur, wenn Schalter 4 an ist und nur nach einem Reset!! // alle LEDs blinken, wenn Akku-Spannung < Schwellwert !! analogwertAkku=adc(7); if (analogwertAkku < schwellwert) { ledPB1(1); ledPB2(1); ledPC2(1); ledPC3(1); warte_ms(blinkT/2); ledPB1(0); ledPB2(0); ledPC2(0); ledPC3(0); warte_ms(blinkT/2); } }
inline static void calibrar_linha(sensor * s) { uint16_t l; l = adc(s->canal_adc); /* Nós pegamos o maior valor lido !!! A linha branca é reconhecida quando o valor do sensor é menor que o valor medido na linha + a metadade da diferença entre o valor de fundo e o valor de linha. Então para que não corra o risco de o robo não reconhecer a linha mesmo o sensor estando nela,nós guardamos como o valor da linha o valor mais alto medido. */ if (l > s->valor.linha) s->valor.linha = l; }
void add_test() { printf("def atest(x,y,ci,z,co)\n zz=x+y+ci;\n msg=\"x=#{x} y=#{y} ci=#{ci} z=#{z} co=#{co} zz=#{zz}\"\n puts(msg+\" zz\") if (zz&0xffffffffffffffff != z);\n puts(msg+ \" co\") if (zz>>64 != co)\nend\n\n"); for (uint64 xh = 1; xh > 0; xh <<= 1) { //printf("xh=%llu\n", xh); for (uint64 yh = 1; yh > 0; yh <<= 1) { //printf("yh=%llu\n", yh); for (uint64 xl = 0; xl <= 5; xl++) { uint64 x = xh + xl - 1; // printf("puts('xh=%llu xl=%llu x=%llu')\n", xh, xl, x); for (uint64 yl = 0; yl <= 5; yl++) { uint64 y = yh + yl - 1; //printf("yh=%llu yl=%llu y=%llu\n", yh, yl, y); for (uint8 carry = 0; carry <= 1; carry++) { unsigned_result_with_carry z = adc(x, y, carry); printf("x=%llu; y=%llu; ci=%d; z=%llu; co=%d;\natest(x,y,ci,z,co);\n", x, y, (int) carry, z.value, (int) z.carry); } } } } } }
int main(int argc, char** argv) { OSCCON = 0x70; TRISA = 0x01; TRISB = 0x00; ANSELA = 0x00; ANSELB = 0x01; CCPTMRS = 0x00; CCP3CON = 0x0A; CCP4CON = 0x0A; T2CON = 0x06; PR2 = 0xFF; ADCON1 = 0b10000000; while (1) { CCP3CON = 0b00001100; temp = adc(); PORTB = temp >> 2; CCPR3L = temp >> 2; } return 0; }
void othunder_state::othunder(machine_config &config) { /* basic machine hardware */ M68000(config, m_maincpu, 24_MHz_XTAL/2); m_maincpu->set_addrmap(AS_PROGRAM, &othunder_state::othunder_map); Z80(config, m_audiocpu, 16_MHz_XTAL/2/2); m_audiocpu->set_addrmap(AS_PROGRAM, &othunder_state::z80_sound_map); EEPROM_93C46_16BIT(config, m_eeprom); adc0808_device &adc(ADC0808(config, "adc", 16_MHz_XTAL/2/2/8)); adc.eoc_callback().set(FUNC(othunder_state::adc_eoc_w)); adc.in_callback<0>().set_ioport("P1X"); adc.in_callback<1>().set_ioport("P1Y"); adc.in_callback<2>().set_ioport("P2X"); adc.in_callback<3>().set_ioport("P2Y"); TC0220IOC(config, m_tc0220ioc, 0); m_tc0220ioc->read_0_callback().set_ioport("DSWA"); m_tc0220ioc->read_1_callback().set_ioport("DSWB"); m_tc0220ioc->read_2_callback().set_ioport("IN0"); m_tc0220ioc->read_3_callback().set(m_eeprom, FUNC(eeprom_serial_93cxx_device::do_read)).lshift(7); m_tc0220ioc->write_3_callback().set(FUNC(othunder_state::eeprom_w)); m_tc0220ioc->write_4_callback().set(FUNC(othunder_state::coins_w)); m_tc0220ioc->read_7_callback().set_ioport("IN2"); /* video hardware */ screen_device &screen(SCREEN(config, "screen", SCREEN_TYPE_RASTER)); screen.set_refresh_hz(60); screen.set_vblank_time(ATTOSECONDS_IN_USEC(0)); screen.set_size(40*8, 32*8); screen.set_visarea(0*8, 40*8-1, 2*8, 32*8-1); screen.set_screen_update(FUNC(othunder_state::screen_update)); screen.set_palette(m_palette); screen.screen_vblank().set(FUNC(othunder_state::vblank_w)); GFXDECODE(config, m_gfxdecode, m_palette, gfx_othunder); PALETTE(config, m_palette).set_entries(4096); TC0100SCN(config, m_tc0100scn, 0); m_tc0100scn->set_gfx_region(1); m_tc0100scn->set_tx_region(2); m_tc0100scn->set_offsets(4, 0); m_tc0100scn->set_gfxdecode_tag(m_gfxdecode); m_tc0100scn->set_palette_tag(m_palette); TC0110PCR(config, m_tc0110pcr, 0, m_palette); /* sound hardware */ SPEAKER(config, "speaker").front_center(); ym2610_device &ymsnd(YM2610(config, "ymsnd", 16000000/2)); ymsnd.irq_handler().set_inputline(m_audiocpu, 0); ymsnd.add_route(0, "2610.0l", 0.25); ymsnd.add_route(0, "2610.0r", 0.25); ymsnd.add_route(1, "2610.1l", 1.0); ymsnd.add_route(1, "2610.1r", 1.0); ymsnd.add_route(2, "2610.2l", 1.0); ymsnd.add_route(2, "2610.2r", 1.0); FILTER_VOLUME(config, "2610.0l").add_route(ALL_OUTPUTS, "speaker", 1.0); FILTER_VOLUME(config, "2610.0r").add_route(ALL_OUTPUTS, "speaker", 1.0); FILTER_VOLUME(config, "2610.1l").add_route(ALL_OUTPUTS, "speaker", 1.0); FILTER_VOLUME(config, "2610.1r").add_route(ALL_OUTPUTS, "speaker", 1.0); FILTER_VOLUME(config, "2610.2l").add_route(ALL_OUTPUTS, "speaker", 1.0); FILTER_VOLUME(config, "2610.2r").add_route(ALL_OUTPUTS, "speaker", 1.0); TC0140SYT(config, m_tc0140syt, 0); m_tc0140syt->set_master_tag(m_maincpu); m_tc0140syt->set_slave_tag(m_audiocpu); }
static void hglin(void) { // F53A pha(); c=1; sbc(ram[HGR_X]); pha(); a=x; sbc(ram[HGR_X+1]); ram[HGR_QUADRANT]=a; // F544 if (c==1) goto hglin_1; pla(); a=a^0xff; adc(1); pha(); lda_const(0); sbc(ram[HGR_QUADRANT]); // F550 hglin_1: ram[HGR_DX+1]=a; ram[HGR_E+1]=a; pla(); ram[HGR_DX]=a; ram[HGR_E]=a; pla(); ram[HGR_X]=a; ram[HGR_X+1]=x; a=y; c=0; sbc(ram[HGR_Y]); if (c==0) goto hglin_2; a=a^0xff; adc(0xfe); hglin_2: // F568 ram[HGR_DY]=a; ram[HGR_Y]=y; ror_mem(HGR_QUADRANT); c=1; sbc(ram[HGR_DX]); x=a; lda_const(0xff); sbc(ram[HGR_DX+1]); ram[HGR_COUNT]=a; ldy(HGR_HORIZ); goto movex2; // always? // f57c movex: asl(); move_left_or_right(); c=1; // f581 movex2: lda(HGR_E); adc(ram[HGR_DY]); ram[HGR_E]=a; lda(HGR_E+1); sbc(0); movex2_1: ram[HGR_E+1]=a; lda(y_indirect(GBASL,y)); a=a^ram[HGR_BITS]; a=a&ram[HMASK]; a=a^ram[y_indirect(GBASL,y)]; ram[y_indirect(GBASL,y)]=a; inx(); if (z!=1) goto movex2_2; ram[HGR_COUNT]++; if (ram[HGR_COUNT]==0) return; // F59e movex2_2: lda(HGR_QUADRANT); if (c==1) goto movex; move_up_or_down(); c=0; lda(HGR_E); adc(ram[HGR_DX]); ram[HGR_E]=a; lda(HGR_E+1); adc(ram[HGR_DX+1]); goto movex2_1; }