Пример #1
0
static void b_basic_teste(int argc, char **argv) {
    (void) argc;
    (void) argv;

    if (argc != 1) {
        msg_erro_nos_argumentos();
        return;
    }

    usb_print(NOVA_LINHA);

    ubasic_init(prog_test_basic);
    do {
        ubasic_run();
    } while (!ubasic_finished());
}
Пример #2
0
int main (int argc, char *argv[])
{
	int inc=0;
	
	start_time = time(NULL);
	
	GetArguments(argc, argv); /* Get the script filename */
	PrintVersion();  /* Print info */
	InitGFX();       /* Setup SDL  */	
	DisplayTitle();  /* Show the irixbasic titles */
	DisplayReady();  /* Display the ready text */
	
	LoadScript(); 
	
	SDL_Flip(screen);
	ubasic_init(program); /* Setup uBasic  */	
	
	
	/* Start the program when the user is ready */
	PrintTextLine("Click to Run.");
	SDL_Delay(200);
	do
	{
		GetInput();   /* Read the inputs */
	}while (!GetMouseButton());
	
	
	do
	{
		GetInput();   /* Read the inputs */
		ubasic_run(); /* Process a line of code*/
	}while (!ubasic_finished() && !done);
	
	PrintTextLine("");
	PrintTextLine("Click or Press ESC to quit.");
	SDL_Flip(screen);
	
	while(!done && !GetMouseButton()){
		GetInput();
	}
	
	TTF_CloseFont( fntc64 );
	
	return 0;
}
Пример #3
0
/**
 * uBasic als ct-Bot Verhalten
 * \param *data Zeiger auf den Datensatz des Verhaltens
 */
void bot_ubasic_behaviour(Behaviour_t * data) {
	/* keine neue Zeile ausfuehren, falls nach letztem WAIT noch gewartet werden soll */
	if (wait_until <= TIMER_GET_TICKCOUNT_32) {
		LOG_DEBUG("neue Zeile von uBasic verarbeiten");
		ubasic_run();
		if (ubasic_finished()) {
			LOG_DEBUG("->-> Endeanforderung <-<-");
			return_from_behaviour(data);
			return;
		}
	} else {
		LOG_DEBUG("WAITing");
	}

	/* Speedvariable setzen */
	speedWishLeft = speedWishLeftBas;
	speedWishRight = speedWishRightBas;
}
Пример #4
0
/*---------------------------------------------------------------------------*/
void run(const char program[]) {
  static int test_num = 0;
  clock_t start_t, end_t;
  double delta_t;

  start_t = clock();

  test_num++;
  printf("Running test #%u... ", test_num);
  fflush(stdout);


  ubasic_init_peek_poke(program, &peek, &poke);

  do {
    ubasic_run();
  } while(!ubasic_finished());

  end_t = clock();
  delta_t = (double)(end_t - start_t) / CLOCKS_PER_SEC;

  printf("done. Run time: %.3f s\n", delta_t);
}
Пример #5
0
void process_script()
{
    long t;
    int Lres;

    // process stack operations
    if (kbd_int_stack_ptr){
	switch (KBD_STACK_PREV(1)){

	case SCRIPT_MOTION_DETECTOR:
			if(md_detect_motion()==0){
				kbd_int_stack_ptr-=1;
 				if (L)
 				{
 					  // We need to recover the motion detector's
 					  // result from ubasic variable 0 and push
 					  // it onto the thread's stack. -- AUJ
 					  lua_pushnumber( Lt, ubasic_get_variable(0) );
 				}
			}
			return;

	case SCRIPT_PRESS:
	    kbd_key_press(KBD_STACK_PREV(2));
	    kbd_int_stack_ptr-=2; // pop op.
	    return;
	case SCRIPT_RELEASE:
	    kbd_key_release(KBD_STACK_PREV(2));
	    kbd_int_stack_ptr-=2; // pop op.
	    return;
	case SCRIPT_SLEEP:
	    t = get_tick_count();
	    // FIXME take care if overflow occurs
	    if (delay_target_ticks == 0){
		/* setup timer */
		delay_target_ticks = t+KBD_STACK_PREV(2);
	    } else {
		if (delay_target_ticks <= t){
		    delay_target_ticks = 0;
		    kbd_int_stack_ptr-=2; // pop sleep op.
		}
	    }
	    return;
	case SCRIPT_PR_WAIT_SAVE:
	    state_shooting_progress = SHOOTING_PROGRESS_NONE;
	    state_expos_recalculated = 0;
	    histogram_stop();

	    kbd_int_stack_ptr-=1; // pop op.
	    return;
	case SCRIPT_WAIT_SAVE:{
	    if (state_shooting_progress == SHOOTING_PROGRESS_DONE)
		kbd_int_stack_ptr-=1; // pop op.
	    return;
	}
	case SCRIPT_WAIT_FLASH:{
	    if (shooting_is_flash_ready())
		kbd_int_stack_ptr-=1; // pop op.
	    return;
	}
	case SCRIPT_WAIT_EXPHIST:{
	    if (state_expos_recalculated) {
		kbd_int_stack_ptr-=1; // pop op.
		state_expos_under = under_exposed;
		state_expos_over = over_exposed;
	    }
	    return;
	}
	case SCRIPT_PR_WAIT_EXPHIST: {
	    if (shooting_in_progress() || mvideo) {
		state_expos_recalculated = 0;
		histogram_restart();
		kbd_int_stack_ptr-=1; // pop op.
	    }
	    return;
	}
        case SCRIPT_WAIT_CLICK: {
            t = get_tick_count();
	    if (delay_target_ticks == 0){
		/* setup timer */
		delay_target_ticks = t+((KBD_STACK_PREV(2))?KBD_STACK_PREV(2):86400000);
	    } else {
                kbd_last_clicked = kbd_get_clicked_key();
                if (kbd_last_clicked || delay_target_ticks <= t) {
                    if (!kbd_last_clicked) 
                        kbd_last_clicked=0xFFFF;
        	    delay_target_ticks = 0;
                    kbd_int_stack_ptr-=2; // pop op.
                }
	    }
	    return;
	}
	default:
	    /*finished();*/
	    script_end();
	}
    }

 	if (state_kbd_script_run != 3)
 	{
 		if( L ) {
 			int top;
 			if (state_lua_kbd_first_call_to_resume)
 			{
 				state_lua_kbd_first_call_to_resume = 0;
 				top = 0;
 			}
 			else
 			{
 				top = lua_gettop(Lt);
 			}
 		   Lres = lua_resume( Lt, top );
 
 		  if (Lres != LUA_YIELD && Lres != 0) {
 		script_console_add_line( lua_tostring( Lt, -1 ) );
 		wait_and_end();
 		return;
 		  }
 
 		  if (Lres != LUA_YIELD) {
 			script_console_add_line(lang_str(LANG_CONSOLE_TEXT_FINISHED));
 		script_end();
 		  }    
 		} 
 		else {
 		  ubasic_run();
 		  if (ubasic_finished()) {
 		script_console_add_line(lang_str(LANG_CONSOLE_TEXT_FINISHED));
 		script_end();
 		  }    
 	}
    }
}