Exemplo n.º 1
0
void LuaContext::update()
{
	update_drawables();
	update_menus();
	update_timers();

	//main_on_update();
}
Exemplo n.º 2
0
static void update_timers_all_cpus(void)
{
	int cpu;

	get_online_cpus();
	for_each_online_cpu(cpu)
		update_timers(cpu);
	put_online_cpus();
}
Exemplo n.º 3
0
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);


}
Exemplo n.º 4
0
/*!
    \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 //
Exemplo n.º 5
0
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();
}
Exemplo n.º 6
0
/*!
    \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 //
Exemplo n.º 7
0
/*!
    \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 //
Exemplo n.º 8
0
/*!
    \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 //
Exemplo n.º 9
0
void unpause_timer(UInt8 TIMER)
{
    update_timers();
    timer[TIMER].active = TRUE;
}
Exemplo n.º 10
0
void pause_timer(UInt8 TIMER)
{
    update_timers();
    timer[TIMER].active = FALSE;
}
Exemplo n.º 11
0
// 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();
    }
}