bool TiEmuDCOP::turn_calc_on() { if (img_loaded && !engine_is_stopped()) { engine_stop(); hw_m68k_irq(6); while (ti68k_debug_is_supervisor()) hw_m68k_run(1,0); engine_start(); return true; } else return false; }
static int ilp_get(uint8_t *data) { tiTIME clk; toSTART(clk); while(!t2f_flag/* && !iu.cancel*/) { hw_m68k_run(1, 0); if(toELAPSED(clk, params.timeout)) return ERR_WRITE_TIMEOUT; }; *data = t2f_data; t2f_flag = 0; io_bit_set(0x0d,6); // STX=1 (tx reg is empty) hw_m68k_irq(4); // this turbo-boost transfer ! tdr->count++; return 0; }
static int ilp_put(uint8_t data) { tiTIME clk; tdr->count++; f2t_data = data; f2t_flag = 1; io_bit_set(0x0d,5); // SRX=1 (rx reg is full) io_bit_set(0x0d,2); // link activity hw_m68k_irq(4); // this turbo-boost transfer ! toSTART(clk); while(f2t_flag/* && !iu.cancel*/) { hw_m68k_run(1, 0); if(toELAPSED(clk, params.timeout)) return ERR_WRITE_TIMEOUT; }; return 0; }
/* This function is called by do_cycles to regularly updates the hardware. Rate is the same as the timer tick rate. */ void hw_update(void) { static unsigned int timer; //time_t curr_clock; // OSC2 enable (bit clear means oscillator stopped!) int osc2_enabled = io_bit_tst(0x15,1); timer++; if (osc2_enabled) { // Increment timer if(!(timer & timer_mask) && io_bit_tst(0x15,3)) { if (tihw.timer_value == 0x00) tihw.timer_value = tihw.io[0x17]; else tihw.timer_value++; } } // Increment HW2 RTC timer every 8192 seconds if ((tihw.hw_type >= HW2) && io2_bit_tst(0x1f, 2) && io2_bit_tst(0x1f, 1)) { static struct timeval ref = {0, 0}; struct timeval tmp = {0, 0}; gettimeofday(&tmp, NULL); // Check if 8192 seconds elapsed, avoiding 32-bit overflow if((unsigned)(tmp.tv_sec-ref.tv_sec)*500000u + ((unsigned)(tmp.tv_usec-ref.tv_usec)>>1u) >= 4096000000u) { gettimeofday(&ref, NULL); tihw.rtc_value++; } } // Toggles every FS (every time the LCD restarts at line 0) -> 90 Hz ~ timer/192 // Don't use the actual LCD count (and use 192 rather than 182) to keep exposure // times consistent if(!(timer % 192) && tihw.hw_type >= HW2) tihw.io2[0x1d] ^= 0x80; /* Auto-int management */ if (osc2_enabled) { // Auto-int 1: 1/2^6 of timer rate // Triggered at a fixed rate: OSC2/2^11 = (OSC2/2^5)/2^6 if(!(timer & 63)) { if(!io_bit_tst(0x15,7)) if((tihw.hw_type == HW1) || !(io2_bit_tst(0x1f, 2) && !io2_bit_tst(0x1f, 1))) hw_m68k_irq(1); } // Auto-int 2: keyboard scan // see keyboard.c } if(osc2_enabled || tihw.hw_type == HW2) { // Auto-int 3: disabled by default by AMS // When enabled, it is triggered at a fixed rate: OSC2/2^19 = 1/16384 of timer rate = 1Hz if(!(timer & 16383)) { if(!io_bit_tst(0x15,7) && io_bit_tst(0x15,2)) if((tihw.hw_type == HW1) || !(io2_bit_tst(0x1f, 2) && !io2_bit_tst(0x1f, 1))) hw_m68k_irq(3); } } // DBus: External link activity ? /* if(!ticables_cable_get_d0(cable_handle) || !ticables_cable_get_d1(cable_handle)) { io_bit_set(0x0d,3); //SA io_bit_set(0x0d,2); //EA } */ // DBUS enabled ? if(!io_bit_tst(0x0c,6)) { // Check for data arrival (link cable) hw_dbus_checkread(); // Auto-int 4: triggered by linkport (error, link act, txbuf empty or rxbuf full) if((io_bit_tst(0x0c,3) && io_bit_tst(0x0d,7)) || (io_bit_tst(0x0c,2) && io_bit_tst(0x0d,3)) || (io_bit_tst(0x0c,1) && io_bit_tst(0x0d,6)) || (io_bit_tst(0x0c,0) && io_bit_tst(0x0d,5))) { hw_m68k_irq(4); } } if (osc2_enabled) { // Auto-int 5: triggered by the programmable timer. // The default rate is OSC2/(K*2^9), where K=79 for HW1 and K=53 for HW2 // Make sure AI5 is triggered only if the timer was actually incremented. if(!(timer & timer_mask) && io_bit_tst(0x15,3) && tihw.timer_value == 0) { if(!io_bit_tst(0x15,7)) if((tihw.hw_type == HW1) || !(io2_bit_tst(0x1f, 2) && !io2_bit_tst(0x1f, 1))) hw_m68k_irq(5); } } // Auto-int 6: triggered when [ON] is pressed. // see keyboard.c // Auto-int 7: "vector table write protection" & "stack overflow" // see memory.c /* Hardware refresh */ // Update keyboard (~600Hz). Not related to timer but as a convenience if(!(timer & 127)) // 31 and 63 don't work, 127 and 255 are ok hw_kbd_update(); // Update LCD (HW1: every 256th timer tick, HW2: unrelated) if((tihw.hw_type == HW1) && !(timer & 255)) { G_LOCK(lcd_flag); lcd_flag = !0; G_UNLOCK(lcd_flag); lcd_hook_hw1(); } }