Esempio n. 1
0
static int playback_frame( void )
{
  int error, finished;
  libspectrum_snap *snap;

  error = libspectrum_rzx_playback_frame( rzx, &finished, &snap );
  if( error ) return rzx_stop_playback( 0 );

  if( finished ) {
    ui_error( UI_ERROR_INFO, "Finished RZX playback" );
    return rzx_stop_playback( 0 );
  }

  /* Move the RZX sentinel back out to 79000 tstates; the addition of
     the frame length is because everything is reduced by that in
     event_frame() */
  event_remove_type( sentinel_event );
  event_add( RZX_SENTINEL_TIME + tstates, sentinel_event );

  if( snap ) {
    error = snapshot_copy_from( snap );
    if( error ) return rzx_stop_playback( 0 );
  }

  /* If we've got another frame to do, fetch the new instruction count and
     continue */
  rzx_instruction_count = libspectrum_rzx_instructions( rzx );
  counter_reset();

  return 0;
}
Esempio n. 2
0
static void
start_recording( libspectrum_rzx *rzx, int competition_mode )
{
  libspectrum_rzx_start_input( rzx, tstates );

  counter_reset();
  rzx_in_count = 0;
  autosave_frame_count = 0;

  rzx_recording = 1;

  ui_menu_activate( UI_MENU_ITEM_RECORDING, 1 );

  if( competition_mode ) {

    if( !libspectrum_gcrypt_version() )
      ui_error( UI_ERROR_WARNING,
                "gcrypt not available: recording will NOT be signed" );

    settings_current.emulation_speed = 100;
    rzx_competition_mode = 1;

  } else {

    ui_menu_activate( UI_MENU_ITEM_RECORDING_ROLLBACK, 1 );
    rzx_competition_mode = 0;

  }
}
Esempio n. 3
0
static int recording_frame( void )
{
  libspectrum_error error;

  error = libspectrum_rzx_store_frame( rzx, R + rzx_instructions_offset,
				       rzx_in_count, rzx_in_bytes );
  if( error ) {
    rzx_stop_recording();
    return error;
  }

  /* Reset the instruction counter */
  rzx_in_count = 0; counter_reset();

  /* If we're in competition mode, check we're running at close to 100%
     speed */
  if( rzx_competition_mode && 
      fabs( current_speed - 100.0 ) > SPEED_TOLERANCE ) {

    rzx_stop_recording();

    ui_error(
      UI_ERROR_INFO,
      "emulator speed is %d%%: stopping competition mode RZX recording",
      (int)( current_speed )
    );

  }

  if( !rzx_competition_mode && settings_current.rzx_autosaves )
    autosave_frame();

  return 0;
}
void counter_reset_all ( void )
{
    int32 i;
    
    for (i = 0; i < n_ctr; i++)
	counter_reset (i);
}
Esempio n. 5
0
static int
start_playback( libspectrum_rzx *rzx )
{
  int error;
  libspectrum_snap *snap;

  error = libspectrum_rzx_start_playback( rzx, 0, &snap );
  if( error ) return error;

  if( snap ) {
    error = snapshot_copy_from( snap );
    if( error ) return error;
  }

  /* End of frame will now be generated by the RZX code */
  event_remove_type( spectrum_frame_event );

  /* Add a sentinel event to prevent tstates overrun (bug #1057471) */
  event_add( RZX_SENTINEL_TIME, sentinel_event );

  tstates = libspectrum_rzx_tstates( rzx );
  rzx_instruction_count = libspectrum_rzx_instructions( rzx );
  rzx_playback = 1;
  counter_reset();

  ui_menu_activate( UI_MENU_ITEM_RECORDING, 1 );
  ui_menu_activate( UI_MENU_ITEM_RECORDING_ROLLBACK, 0 );

  return 0;
}
Esempio n. 6
0
static int cnt_reset_f(struct sip_msg* msg, char* handle, char* bar)
{
	counter_handle_t h;
	
	h.id = (long)(void*)handle;
	counter_reset(h);
	return 1;
}
Esempio n. 7
0
static int ki_cnt_reset(sip_msg_t* msg, str *sname)
{
	char* name;
	char* grp;
	char* p;
	counter_handle_t h;

	cnt_op_handle_get();

	counter_reset(h);
	return 1;
}
Esempio n. 8
0
int uac_reg_reset_ht_gc(void)
{
	int i;
	reg_item_t *it = NULL;
	reg_item_t *it0 = NULL;

	if(_reg_htable_gc==NULL)
	{
		LM_DBG("no hash table\n");
		return -1;
	}
	for(i=0; i<_reg_htable_gc->htsize; i++)
	{
		/* free entries */
		it = _reg_htable_gc->entries[i].byuuid;
		while(it)
		{
			it0 = it;
			it = it->next;
			shm_free(it0);
		}
		_reg_htable_gc->entries[i].byuuid = NULL;
		_reg_htable_gc->entries[i].isize=0;
		it = _reg_htable_gc->entries[i].byuser;
		while(it)
		{
			it0 = it;
			it = it->next;
			shm_free(it0->r);
			shm_free(it0);
		}
		_reg_htable_gc->entries[i].byuser = NULL;
		_reg_htable_gc->entries[i].usize = 0;
	}
	/* Reset all counters */
	counter_reset(regtotal);
	counter_reset(regactive);
	counter_reset(regdisabled);
	return 0;
}
Esempio n. 9
0
static void cnt_reset_rpc(rpc_t* rpc, void* c)
{
	char* group;
	char* name;
	counter_handle_t h;
	
	if (rpc->scan(c, "ss", &group, &name) < 2) {
		/* rpc->fault(c, 400, "group and counter name required"); */
		return;
	}
	if (counter_lookup(&h, group, name) < 0) {
		rpc->fault(c, 400, "non-existent counter %s.%s\n", group, name);
		return;
	}
	counter_reset(h);
	return;
}
Esempio n. 10
0
static int
start_after_rollback( libspectrum_snap *snap )
{
  int error;

  error = snapshot_copy_from( snap );
  if( error ) return error;

  libspectrum_rzx_start_input( rzx, tstates );

  error = counter_reset();
  if( error ) return error;

  if( settings_current.rzx_autosaves )
    autosave_reset();

  return 0;
}
Esempio n. 11
0
/* callback for counter_iterate_grp_vars to reset counters */
static void mi_add_grp_vars_cbk2(void* r, str* g, str* n, counter_handle_t h)
{
	struct mi_node *rpl;
	counter_val_t old_val, new_val;

	rpl = r;
	old_val = counter_get_val(h);
	counter_reset(h);
	new_val = counter_get_val(h);

	if (old_val==new_val)
	{
		addf_mi_node_child(rpl, 0, 0, 0, "%.*s:%.*s = %lu",
					g->len, g->s, n->len, n->s, new_val);
	} else {
		addf_mi_node_child(rpl, 0, 0, 0, "%.*s:%.*s = %lu (%lu)",
					g->len, g->s, n->len, n->s, new_val, old_val);
	}
}
Esempio n. 12
0
/**********************************************************************
 * Plugin starts here
 **********************************************************************/
enum plugin_status plugin_start(const void* parameter){
    int button;
    int last_second = -1;
    bool redraw=true;
    struct time time;
    struct counter counter;
    bool exit_clock = false;
    (void)parameter;
    atexit(cleanup);

#if LCD_DEPTH > 1
    rb->lcd_set_backdrop(NULL);
#endif

    load_settings();

    /* init xlcd functions */
    counter_init(&counter);
    clock_draw_set_colors();

    while(!exit_clock){
        clock_update_time(&time);

        if(!clock_settings.general.idle_poweroff)
            rb->reset_poweroff_timer();

        /*************************
         * Scan for button presses
         ************************/
        button =  pluginlib_getaction(HZ/10, plugin_contexts, PLA_ARRAY_COUNT);
        redraw=true;/* we'll set it to false afterwards if there was no action */
        switch (button){
            case ACTION_COUNTER_TOGGLE: /* start/stop counter */
                if(clock_settings.general.show_counter)
                    counter_toggle(&counter);
                break;

            case ACTION_COUNTER_RESET: /* reset counter */
                if(clock_settings.general.show_counter)
                    counter_reset(&counter);
                break;

            case ACTION_MODE_NEXT_REPEAT:
            case ACTION_MODE_NEXT:
                clock_settings.mode++;
                if(clock_settings.mode >= NB_CLOCK_MODES)
                    clock_settings.mode = 0;
                break;

            case ACTION_MODE_PREV_REPEAT:
            case ACTION_MODE_PREV:
                clock_settings.mode--;
                if(clock_settings.mode < 0)
                    clock_settings.mode = NB_CLOCK_MODES-1;
                break;
            case ACTION_SKIN_PREV_REPEAT:
            case ACTION_SKIN_PREV:
                clock_settings_skin_next(&clock_settings);
                break;
            case ACTION_SKIN_NEXT_REPEAT:
            case ACTION_SKIN_NEXT:
                clock_settings_skin_previous(&clock_settings);
                break;
            case ACTION_MENU:
                clock_draw_restore_colors();
                exit_clock=main_menu();
                break;
            default:
                exit_on_usb(button);
                if(time.second != last_second){
                    last_second=time.second;
                    redraw=true;
                }else
                    redraw=false;
                break;
        }

        if(redraw){
            clock_draw_set_colors();
            FOR_NB_SCREENS(i)
                clock_draw(rb->screens[i], &time, &counter);
            redraw=false;
        }
    }

    return PLUGIN_OK;
}