void LuaContext::update() { update_drawables(); update_menus(); update_timers(); //main_on_update(); }
static void update_timers_all_cpus(void) { int cpu; get_online_cpus(); for_each_online_cpu(cpu) update_timers(cpu); put_online_cpus(); }
void emulate_cycle(chip8 * cpu) { update_timers(cpu); //fetch opcode cpu->opcode = cpu->memory[cpu->pc] << 8 | cpu->memory[cpu->pc + 1]; decode_opcode(cpu); }
/*! \brief Returns the timer remaining before the timer expires. \param[in] TIMER The timer to get the time remaining for. \return The time remaining. 0 willl be returned if it is not a valid timer or the timer is inactive. */ tick_t ont_get_timer(const UInt8 TIMER) { if(TIMER >= ONT_NUM_TIMERS || !timer[TIMER].active) { return 0; } // if the timer is invalid // update_timers(); return timer[TIMER].tick; } // ont_get_timer //
static void update_timers_all_cpus(void) { int cpu; get_online_cpus(); preempt_disable(); for_each_online_cpu(cpu) update_timers(cpu); preempt_enable(); put_online_cpus(); }
/*! \brief Sets the timer to start counting. \param[in] TIMER The timer to set \param[in] DURATION The number of ticks to set the timer for. \return TRUE if the timer was set. FALSE if the timer was not set (ie doesn't exist) */ BOOL ont_set_timer(const UInt8 TIMER, const tick_t DURATION) { if(TIMER >= ONT_NUM_TIMERS) { return FALSE; } // if the timer is invalid // update_timers(); timer[TIMER].active = TRUE; timer[TIMER].tick = DURATION; return TRUE; } // ont_set_timer //
/*! \brief Returns whether or not the timer has expired. The timer is deactivated by this function if the timer has expired and TRUE is returned. \param[in] TIMER The timer who is being checked. \return TRUE if the timer has expired FALSE if the timer is not valid, is not active, or has not expired. */ BOOL ont_expired(const UInt8 TIMER) { if(TIMER >= ONT_NUM_TIMERS || !timer[TIMER].active) { return FALSE; } // if the timer is invalid // update_timers(); if(timer[TIMER].tick == 0) { timer[TIMER].active = FALSE; } // if the timer has expired // return timer[TIMER].tick == 0; } // ont_expired //
/*! \brief Returns TRUE if the timer is inactive or has expired. \param[in] TIMER The timer who is being checked. \return TRUE if the timer is inactive or has expired FALSE if the timer is not valid, or is not active and has not expired. */ BOOL ont_inactive_or_expired(const UInt8 TIMER) { if(TIMER >= ONT_NUM_TIMERS) { return FALSE; } // if the timer is invalid // update_timers(); if(timer[TIMER].tick == 0) { timer[TIMER].active = FALSE; } // if the timer has expired // // If the timer expired, it was deactivated so the timer's active flag // will be FALSE if it was inactive or the timer expired return !timer[TIMER].active; } // ont_inactive_or_expired //
void unpause_timer(UInt8 TIMER) { update_timers(); timer[TIMER].active = TRUE; }
void pause_timer(UInt8 TIMER) { update_timers(); timer[TIMER].active = FALSE; }
// Draws one frame then returns void run_one_frame() { frame_drawn = 0; while (!frame_drawn) { if (halted || stopped) { long current_cycles = cgb_speed ? 2 : 4; update_timers(current_cycles); sound_add_cycles(current_cycles); inc_serial_cycles(current_cycles); // If Key pressed in "stop" mode, then gameboy is "unstopped" if (stopped) { if(key_pressed()) { stopped = 0; } } if (halted) { update_graphics(current_cycles); } } else if (!(halted || stopped)) { current_cycles = 0; current_cycles += exec_opcode(skip_bug); } cycles += current_cycles; #ifdef EFIAPI if (cycles > 3000) { #else if (cycles > 15000) { #endif quit |= update_keys(); cycles = 0; } skip_bug = handle_interrupts(); if (debug && step_count > 0 && --step_count == 0) { int flags = get_command(); step_count = (flags & STEPS_SET) ? get_steps() : STEPS_OFF; } } } void setup_debug() { if (debug) { int flags = get_command(); step_count = (flags & STEPS_SET) ? get_steps() : STEPS_OFF; breakpoint = (flags & BREAKPOINT_SET) ? get_breakpoint() : BREAKPOINT_OFF; } } void run() { log_message(LOG_INFO, "About to setup debug\n"); setup_debug(); log_message(LOG_INFO, "About to run\n"); while(!quit) { run_one_frame(); } }