Esempio n. 1
0
int		aff_pixel(int color, t_rtv1 *rt, int x, int y)
{
  t_obj		*tmp;
  int		i;

  tmp = rt->start;
  i = 0;
  while (i < rt->lenght)
    {
      if (i == color)
	{

	  put_pixel_to_img(rt->img->data, get_dot(x, y), get_color(tmp->color->r, tmp->color->v, tmp->color->b), rt->sbe->sizeline);
	  return (0);
	}
      tmp = tmp->next;
      i++;
    }
  put_pixel_to_img(rt->img->data, get_dot(x, y), get_color(40, 40, 40), 
		   rt->sbe->sizeline);
  return (0);
}
Esempio n. 2
0
void heal_t::assess_damage( dmg_e heal_type,
                            action_state_t* s )
{
  s -> target -> assess_heal( get_school() , heal_type, s );

  if ( heal_type == HEAL_DIRECT )
  {
    if ( sim -> log )
    {
      sim -> out_log.printf( "%s %s heals %s for %.0f (%.0f) (%s)",
                     player -> name(), name(),
                     s -> target -> name(), s -> result_total, s -> result_amount,
                     util::result_type_string( s -> result ) );
    }
  }
  else // HEAL_OVER_TIME
  {
    if ( sim -> log )
    {
      dot_t* dot = get_dot( s -> target );
      sim -> out_log.printf( "%s %s ticks (%d of %d) %s for %.0f (%.0f) heal (%s)",
                     player -> name(), name(),
                     dot -> current_tick, dot -> num_ticks,
                     s -> target -> name(), s -> result_total, s -> result_amount,
                     util::result_type_string( s -> result ) );
    }
  }

  // New callback system; proc spells on impact. 
  // Note: direct_tick_callbacks should not be used with the new system, 
  // override action_t::proc_type() instead
  if ( callbacks )
  {
    proc_types pt = s -> proc_type();
    proc_types2 pt2 = s -> impact_proc_type2();
    if ( pt != PROC1_INVALID && pt2 != PROC2_INVALID )
      action_callback_t::trigger( player -> callbacks.procs[ pt ][ pt2 ], this, s );
  }

  if ( player -> record_healing() )
  {
    stats -> add_result( s -> result_amount, s -> result_total, ( direct_tick ? HEAL_OVER_TIME : heal_type ), s -> result, s -> block_result, s -> target );

    // Record external healing too
    if ( player != s -> target )
      s -> target -> gains.health -> add( RESOURCE_HEALTH, s -> result_amount, s -> result_total - s -> result_amount );
    else
      heal_gain -> add( RESOURCE_HEALTH, s -> result_amount, s -> result_total - s -> result_amount );
  }
}
Esempio n. 3
0
static void print_common_debug_info(cpu_registers* registers) {
    uint16_t scanline = get_scanline();
    fprintf(cpu_logfile, "A:%02X ", registers->A);
    fprintf(cpu_logfile, "X:%02X ", registers->X);
    fprintf(cpu_logfile, "Y:%02X ", registers->Y);
    fprintf(cpu_logfile, "P:%02X ", registers->flags);
    fprintf(cpu_logfile, "SP:%02X ", registers->S);
    fprintf(cpu_logfile, "CYC:%3d ", get_dot());
    if(scanline == 261)
        fprintf(cpu_logfile, "SL:%d", -1);
    else
        fprintf(cpu_logfile, "SL:%d", scanline);
    fprintf(cpu_logfile, "\n");
}
      virtual Eigen::Matrix<double,6,6> get_xyz_vel()
      {
	Eigen::Matrix3d mat = get();
	Eigen::Matrix3d mat_dot = get_dot();
	Eigen::Matrix<double,6,6> retval;
	
	for (register int i = 0; i < 3; ++i) {
	  for (register int j = 0; j < 3; ++j) {
	    retval(i,j) = mat(i,j);
	    retval(i,j+3) = 0;
	    retval(i+3,j) = mat_dot(i,j);
	    retval(i+3,j+3) = mat(i,j);
	  }
	}
	return retval;
      }
Esempio n. 5
0
/**
	@brief Initialises dialog state variables
	@param char control_mask - The controls to enable on the dialog
	@return void
*/
void io_dialog_init(char control_mask) {
	char last_dot = get_dot();
	
	for (int i = 0; i < 6; i++) {
		if ((control_mask & (1 << i)) != 0) {
			io_dialog_dots_enabled[i] = true;
		}
	}
	if ((control_mask & LEFT_RIGHT) == LEFT_RIGHT) {
		io_dialog_left_right_enabled = true;
	}
	if ((control_mask & ENTER_CANCEL) == ENTER_CANCEL) {
		io_dialog_enter_cancel_enabled = true;
	}
	if (last_dot == LEFT || last_dot == RIGHT) {
		io_dialog_incorrect_tries = 0;
	}
	io_dialog_initialised = true;
}
Esempio n. 6
0
char *parse_note_string(char *ptr, struct defaults *def, struct note *note){
  char len_string[3];
  char pitch_string[3];
  char octave_string[2];
  char dot[2];

  // eat whitespace / commas and advance the pointer
  char* dummy = malloc(strlen(ptr)+1);
  if (dummy == NULL){ error("malloc failed");}
  dummy[0] = '\0';
  sscanf(ptr,"%[ ,]",dummy);
  ptr += strlen(dummy);
  free(dummy);

  DEBUG&&printf("Begin Parsing Note String...\n");
  ptr = get_len(ptr, len_string, def->len);
  DEBUG&&printf("get_len Successful...\n");
  ptr = get_pitch(ptr, pitch_string);
  DEBUG&&printf("get_pitch Successful...\n");
  ptr = get_octave(ptr, octave_string, def->oct);
  DEBUG&&printf("get_octave Successful...\n");
  ptr = get_dot(ptr, dot);
  DEBUG&&printf("get_dot Successful...\n");

  strcpy(note->pitch, pitch_string);
  sscanf(len_string, "%d", &(note->length));
  sscanf(octave_string, "%d", &(note->octave));

  note->divisor = calc_divisor(pitch_string, octave_string);
  DEBUG&&printf("divisor successful\n");

  note->cycles = calc_cycles(def, len_string, dot);
  DEBUG&&printf("cycles successful\n");

  return ptr;
}
Esempio n. 7
0
void wuline(SDL_Surface *surface,int x1,int y1,int x2,int y2, Uint32 pixel)
{
    double dx,dy,xend,yend,xgap,ygap,xpxl1,ypxl1,xpxl2,ypxl2,intery,interx,gradient, f;
    Uint8 alph;
    dx = x2-x1;
    dy = y2-y1;
    int ax,ay,a,b;
    Uint32 pixnoalph=(pixel&0x00FFFFFF);
    if(abs(dx) > abs(dy))
    {
        if(x2<x1)
        {
            ax=x1;
            x1= x2;
            x2 = ax;
            ay = y1;
            y1 = y2;
            y2 = ay;
        }
        gradient=dy/dx;
        xend=ceil(x1);
        yend=y1+gradient*(xend-x1);
        xgap = 1.0-fract(x1 + 0.5);
        xpxl1 = xend;
        ypxl1 = floor(yend);
        f=1.0-fract(yend)*xgap;
        alph=lerp(rgba(get_dot(surface,xpxl1,ypxl1)),rgba(pixel),f);
        dot(surface,xpxl1,ypxl1,pixnoalph|(alph<<24));
        f = fract(yend)*xgap;
        alph=lerp(rgba(get_dot(surface,xpxl1,ypxl1+1)),rgba(pixel),f);
        dot(surface,xpxl1,ypxl1+1,pixnoalph|(alph<<24));
        intery = yend + gradient;
        xend = ceil(x2);
        yend = y2 + gradient * (xend-x2);
        xgap = 1.0 - fract(x2 + 0.5);
        xpxl2 = xend;
        ypxl2 = (int)(yend);
        f = 1.0-fract(yend)*xgap;
        alph=lerp(rgba(get_dot(surface,xpxl2,ypxl2)),rgba(pixel),f);
        dot(surface,xpxl2,ypxl2,pixnoalph|(alph<<24));
        f = fract(yend)*xgap;
        alph=lerp(rgba(get_dot(surface,xpxl2,ypxl2+1)),rgba(pixel),f);
        dot(surface,xpxl2,ypxl2+1,pixnoalph|(alph<<24));


        a = xpxl1+1;
        b = xpxl2-1;
        for(int x=a;x<=b;x++)
        {

            f = 1.0-fract(intery);
            alph=lerp(rgba(get_dot(surface,x,intery)),rgba(pixel),f);
            dot(surface,x,intery,pixnoalph|(alph<<24));


            f = fract(intery);
            alph=lerp(rgba(get_dot(surface,x,intery+1)),rgba(pixel),f);
            dot(surface,x,intery+1,pixnoalph|(alph<<24));

            intery = intery + gradient;

        }

    }else{
        if(y2 < y1)
        {

            ax = x1;
            x1 = x2;
            x2 = ax;
            ay = y1;
            y1 = y2;
            y2 = ay;
        }

        gradient = dx / dy;

        yend = ceil(y1);
        xend = x1 + gradient * (yend-y1);
        ygap = 1.0 - fract(y1 + 0.5);
        xpxl1 = (int)(xend);
        ypxl1 = yend;
        f = 1.0-fract(xend)*ygap;
        alph=lerp(rgba(get_dot(surface,xpxl1, ypxl1)),rgba(pixel),f);
        dot(surface,xpxl1, ypxl1,pixnoalph|(alph<<24));

        f = fract(xend)*ygap;
        alph=lerp(rgba(get_dot(surface,xpxl1, ypxl1+1)),rgba(pixel),f);
        dot(surface,xpxl1, ypxl1+1,pixnoalph|(alph<<24));

        interx = xend + gradient;

        yend = ceil(y2);
        xend = x2 + gradient * (yend-y2);
        ygap = fract(y2 + 0.5);
        xpxl2 = (int)(xend);
        ypxl2 = yend;
        f = 1.0-fract(xend)*ygap;
        alph=lerp(rgba(get_dot(surface,xpxl2, ypxl2)),rgba(pixel),f);
        dot(surface,xpxl2, ypxl2,pixnoalph|(alph<<24));

        f = fract(xend)*ygap;
        alph=lerp(rgba(get_dot(surface,xpxl2, ypxl2+1)),rgba(pixel),f);
        dot(surface,xpxl2, ypxl2+1,pixnoalph|(alph<<24));


        a = ypxl1+1;
        b = ypxl2-1;
        for(int y=a;y<=b;y++)
        {

            f = 1.0-fract(interx);
            alph=lerp(rgba(get_dot(surface,interx,y)),rgba(pixel),f);
            dot(surface,interx,y,pixnoalph|(alph<<24));

            f = fract(interx);
            alph=lerp(rgba(get_dot(surface,interx+1,y)),rgba(pixel),f);
            dot(surface,interx+1,y,pixnoalph|(alph<<24));
            interx = interx + gradient;
        }
    }
}
Esempio n. 8
0
/**
* @brief Creates a dialog with prompt and specified allowed user inputs
* @param char* prompt - Pointer to filename for prompt to play - prefixed with
* mode fileset
* @param char control_mask - Controls to allow on dialog re: io.h for masks
* @return char - Button corresponding to user input
*/
char create_dialog(char* prompt, char control_mask) {

	// Gets initialised on first call after a successful return or first run
	if (io_dialog_initialised == false) {
		log_msg("[IO] Creating dialog: %s\n\r", prompt);
		
		io_dialog_init(control_mask);
	}

	char last_dot = get_dot();
	switch (last_dot) {

		// Returns NO_DOTS but also plays prompt when fresh call or after a certain
		// number of incorrect tries
		case NO_DOTS:
			if (io_dialog_incorrect_tries == -1) {
				play_mp3(mode_fileset, prompt);
				io_dialog_incorrect_tries++;
			}
			return NO_DOTS;
			break;

		// Returns dot if enabled, o/w registers error
		case '1': case '2': case '3': case '4': case '5': case '6':
			if (io_dialog_dots_enabled[CHARTOINT(last_dot) - 1] == true) {
				log_msg("[IO] Returning dot %c\n\r", last_dot);
				
				io_dialog_reset();
				return last_dot;
			} else {
				io_dialog_error();
				return NO_DOTS;
			}
			break;

		// Returns control button if enabled, o/w registers error
		case ENTER: case CANCEL:
			if (io_dialog_enter_cancel_enabled == true) {
				io_dialog_reset();
				return last_dot;
			} else {
				io_dialog_error();
				return NO_DOTS;
			}
			break;

		// Returns control button if enabled, o/w registers error
		case LEFT: case RIGHT:
			if (io_dialog_left_right_enabled == true) {
				io_dot = last_dot;
				io_dialog_reset();
				return last_dot;
			} else {
				io_dialog_error();
				return NO_DOTS;
			}
			break;

		// Should not get here
		default:
			log_msg("[IO] Invalid dot: %x\n\r", last_dot);
			
			quit_mode();
			return NO_DOTS;
			break;
	}
}
Esempio n. 9
0
/**
*	@brief Gets current cell
* @param void
* @return char - Cell pattern with 2 MSB as controls for ENTER, LEFT, RIGHT
* terminated cell entry, WITH_CANCEL for CANCEL and NO_DOTS when nothing to
* return (wait)
*/
char get_cell(void) {
	char last_dot = get_dot();
	char ret_val = NO_DOTS;

	switch(last_dot) {

		case NO_DOTS:
			return NO_DOTS;
			break;
		
		// If one of the dots, then add to cell state
		case '1': case '2': case '3': case '4':	case '5': case '6':
			io_cell_state = add_dot(io_cell_state, last_dot);
			return NO_DOTS;
			break;

		// If a control is pressed, return cell state with control preserved in
		// 2 MSB of char
		case ENTER: case LEFT: case RIGHT: case CANCEL:
			ret_val = io_cell_state;
			io_cell_state = NO_DOTS;
			switch (last_dot) {
				case ENTER:
					io_user_cancel = false;
					io_user_abort = false;
					log_msg("[IO] Cell pattern: %x\n\r",
						ret_val | WITH_ENTER);
					
					return ret_val | WITH_ENTER;
					break;
				case LEFT:
					io_user_cancel = false;
					io_user_abort = false;
					return ret_val | WITH_LEFT;
					break;
				case RIGHT:
					io_user_cancel = false;
					io_user_abort = false;
					return ret_val | WITH_RIGHT;
					break;
				case CANCEL:
					if (ret_val == 0x00) {
						if (io_user_cancel == true) {
							io_user_abort = true;
							io_user_cancel = false;
						} else {
							io_user_cancel = true;
							io_user_abort = false;
						}
					}
					return ret_val | WITH_CANCEL;
					break;
				// Should not execute this code
				default:
					log_msg("[IO] Invalid dot: %x\n\r", last_dot);
					
					quit_mode();
					return NO_DOTS;
					break;
			}
			break;

		// Should not execute this code
		default:
			log_msg("[IO] Invalid dot: %x\n\r", last_dot);
			
			quit_mode();
			return NO_DOTS;
			break;
	}
}