Exemplo n.º 1
0
void draw_user_velocities(Frame *vx_frame, Frame *vy_frame, Velocity *velocity)
{
  fill_frame(vx_frame, BLACK);
  fill_frame(vy_frame, BLACK);

  vx_frame->width = MAX(velocity->vx, 2);
  vy_frame->top = 75 + (velocity->vy < 0 ? 0 : -velocity->vy);
  vy_frame->height = ABS(velocity->vy);

  fill_frame(vx_frame, WHITE);
  fill_frame(vy_frame, WHITE);
}
Exemplo n.º 2
0
extern void 
fill_stack(debug_context_t *context, const rb_debug_inspector_t *inspector) {
  debug_frame_t *frame;
  VALUE locations;
  VALUE location;
  VALUE path;
  VALUE lineno;
  const char *file;
  int line;
  int stack_size;
  int i;

  locations = rb_debug_inspector_backtrace_locations(inspector);
  stack_size = locations == Qnil ? 0 : RARRAY_LENINT(locations);
  context->stack_size = stack_size;

  for (i = 0; i < stack_size; i++) {
    frame = ALLOC(debug_frame_t);
    location = rb_ary_entry(locations, i);
    path = rb_funcall(location, rb_intern("path"), 0);
    lineno = rb_funcall(location, rb_intern("lineno"), 0);
    file = path != Qnil ? RSTRING_PTR(path) : "";
    line = FIX2INT(lineno);
    fill_frame(frame, file, line, rb_debug_inspector_frame_binding_get(inspector, i), rb_debug_inspector_frame_self_get(inspector, i));
    frame->prev = context->stack;
    context->stack = frame;
  }
}
Exemplo n.º 3
0
int run_game(GameData *data)
{
  int cur_shot = 0;
  while(cur_shot < data->num_shots)
  {
    Pacman *cur_pac_shot = (data->shots + cur_shot);
    draw_pacman(cur_pac_shot);
    draw_pebbles(data->pebbles, data->num_pebbles);
    *cur_pac_shot->velocity = *(data->old_velocity);
    Velocity *velocity = cur_pac_shot->velocity;
    while(!KEY_PRESSED(START))
    {
      update_velocities(velocity);
      wait_for_vblank();
      draw_user_velocities(data->velocity_frame_x, data->velocity_frame_y, velocity);
      draw_pacman(cur_pac_shot);
    }
    *(data->old_velocity ) = *cur_pac_shot->velocity;//MUST save old shot

    erase_frame(data->velocity_frame_x, data->bg_color);
    erase_frame(data->velocity_frame_y, data->bg_color);

    //now we run simulation
    fill_frame(data->indicator, GREEN);
    int i = 0;
    while(!off_screen(cur_pac_shot->frame))
    {
      for (i = 0; i < data->num_pebbles; i++) {
        PacmanPebble *cur_pebble = (data->pebbles + i);
        check_collision(cur_pac_shot, cur_pebble);
      }
      wait_for_vblank();
      erase_frame(cur_pac_shot->frame, data->bg_color);
      move_shot(cur_pac_shot);
      draw_pebbles(data->pebbles, data->num_pebbles);
      draw_pacman(cur_pac_shot);
   }

    erase_frame(cur_pac_shot->frame, data->bg_color);
    cur_shot++;
  }
  fill_frame(data->indicator, RED);
  return 0;
}
Exemplo n.º 4
0
Arquivo: video.c Projeto: scs/u-boot
static void video_init(char *NTSCFrame)
{
	NTSCFrame = (char *)NTSC_FRAME_ADDR;
	NTSC_framebuffer_init(NTSCFrame);
	fill_frame(NTSCFrame, BLUE);

	bfin_write_PPI_CONTROL(0x0082);
	bfin_write_PPI_FRAME(0x020D);

	bfin_write_DMA0_START_ADDR(NTSCFrame);
	bfin_write_DMA0_X_COUNT(0x035A);
	bfin_write_DMA0_X_MODIFY(0x0002);
	bfin_write_DMA0_Y_COUNT(0x020D);
	bfin_write_DMA0_Y_MODIFY(0x0002);
	bfin_write_DMA0_CONFIG(0x1015);
	bfin_write_PPI_CONTROL(0x0083);
}
Exemplo n.º 5
0
void draw_pacman(Pacman *pacman)
{
  fill_frame(pacman->frame, YELLOW);
}
Exemplo n.º 6
0
static bool process_packet(tc_user_t *u, unsigned char *frame) 
{
    bool                    result;
    uint16_t                size_ip, size_tcp, tot_len, cont_len;
    uint32_t                h_ack, h_last_ack;
    tc_ip_header_t         *ip_header;
    tc_tcp_header_t        *tcp_header;
    ip_port_pair_mapping_t *test;

    ip_header  = (tc_ip_header_t *) (frame + ETHERNET_HDR_LEN);
    size_ip    = ip_header->ihl << 2;
    tcp_header = (tc_tcp_header_t *) ((char *) ip_header + size_ip);
    size_tcp = tcp_header->doff << 2;
    tot_len  = ntohs(ip_header->tot_len);
    cont_len = tot_len - size_tcp - size_ip;

    if (u->dst_port == 0) {
        test = get_test_pair(&(clt_settings.transfer), 
                ip_header->daddr, tcp_header->dest);
        if (test == NULL) {
            tc_log_info(LOG_NOTICE, 0, " test null:%u", 
                    ntohs(tcp_header->dest));
            tc_log_trace(LOG_WARN, 0, TO_BAKEND_FLAG, ip_header, tcp_header);
            return false;
        }
        u->dst_addr = test->target_ip;
        u->dst_port = test->target_port;
#if (GRYPHON_PCAP_SEND)
        u->src_mac       = test->src_mac;
        u->dst_mac       = test->dst_mac;
#endif
    }

    if (u->state.last_ack_recorded) {
        if (u->state.status < SEND_REQ && (u->state.status & SYN_CONFIRM)) {
            h_ack = ntohl(tcp_header->ack_seq);
            h_last_ack = ntohl(u->history_last_ack_seq);
            if (after(h_ack, h_last_ack)) {
                tc_log_debug1(LOG_DEBUG, 0, "server resp first, wait, p:%u", 
                        ntohs(u->src_port));
                u->state.resp_waiting = 1;
                return false;
            }
        }

    }

    ip_header->saddr = u->src_addr;
    tcp_header->source = u->src_port;
    u->history_last_ack_seq = tcp_header->ack_seq;
    u->state.last_ack_recorded = 1;
    tcp_header->ack_seq = u->exp_ack_seq;
    ip_header->daddr = u->dst_addr;
    tcp_header->dest = u->dst_port;

    tc_log_debug2(LOG_DEBUG, 0, "set ack seq:%u, p:%u",
            ntohl(u->exp_ack_seq), ntohs(u->src_port));

    packs_sent_cnt++;
    if (tcp_header->syn) {
        syn_sent_cnt++;
#if (!GRYPHON_SINGLE)
        if (!send_router_info(u, CLIENT_ADD)) {
            return false;
        }
#endif
        u->state.last_ack_recorded = 0;
        u->state.status  |= SYN_SENT;
    } else if (tcp_header->fin) {
        fin_sent_cnt++;
        u->state.status  |= CLIENT_FIN;
    } else if (tcp_header->rst) {
        rst_sent_cnt++;
        u->state.status  |= CLIENT_FIN;
        tc_log_debug1(LOG_DEBUG, 0, "a reset packet to back:%u",
                ntohs(u->src_port));
    }

    if (cont_len > 0) {
        cont_sent_cnt++;
        u->state.status |= SEND_REQ;
    }
    if (u->state.timestamped) {
        update_timestamp(u, tcp_header);
    }

    tcp_header->check = 0;
    tcp_header->check = tcpcsum((unsigned char *) ip_header,
            (unsigned short *) tcp_header, (int) (tot_len - size_ip));
#if (GRYPHON_PCAP_SEND)
    ip_header->check = 0;
    ip_header->check = csum((unsigned short *) ip_header,size_ip);
#endif
    tc_log_debug_trace(LOG_DEBUG, 0, TO_BAKEND_FLAG, ip_header, tcp_header);

#if (!GRYPHON_PCAP_SEND)
    result = tc_raw_socket_send(tc_raw_socket_out, ip_header, tot_len,
            ip_header->daddr);
#else
    fill_frame((struct ethernet_hdr *) frame, u->src_mac, u->dst_mac);
    result = tc_pcap_send(frame, tot_len + ETHERNET_HDR_LEN);
#endif

    if (result == TC_OK) {
        u->last_sent_time = tc_time();
        return true;
    } else {
        tc_log_info(LOG_ERR, 0, "send to back error,tot_len is:%d,cont_len:%d",
                tot_len,cont_len);
#if (!TCPCOPY_PCAP_SEND)
        tc_raw_socket_out = TC_INVALID_SOCKET;
#endif
        tc_over = SIGRTMAX;
        return false;
    }
}