Exemplo n.º 1
0
int get_mod_info (char *filename, JGMOD_INFO *ji)
{
    int temp;

    if (ji == null)
        return -1;

    
    if (detect_jgm (filename) == 1)
        {
        JGMOD_FILE *f;

        f = jgmod_fopen (filename, "rb");
        if (f != null)
            {
            temp = get_jgm_info(f, ji);
            jgmod_fclose (f);
            return temp;
            }
        }

    if (detect_it (filename) == 1)
        return get_it_info (filename, 0, ji);

    if (detect_xm (filename) == 1)
        return get_xm_info (filename, 0, ji);

    if (detect_s3m (filename) == 1)
        return get_s3m_info (filename, 0, ji);

    if (detect_m31 (filename) == 1)
        return get_m_info (filename, 31, ji);

    temp = detect_unreal_it (filename);
    if (temp > 0)
        return get_it_info (filename, temp, ji);

    temp = detect_unreal_xm (filename);
    if (temp > 0)
        return get_xm_info (filename, temp, ji);

    temp = detect_unreal_s3m (filename);
    if (temp > 0)
        return get_s3m_info (filename, temp, ji);

    if (enable_m15 == TRUE)            //detect this last
        {
        if (detect_m15 (filename) == 1)        
            return get_m_info (filename, 15, ji);
        }


    sprintf (jgmod_error, "Unsupported MOD type or unable to open file");
    return -1;
}
Exemplo n.º 2
0
int mouse_moving(void)
{
    m_event mevent;

    if(get_m_info(fd, &mevent) > 0)
    {
        restore_shape(mx, my);
        mx += mevent.dx;
        my += mevent.dy;

        mx = ((mx >= 0) ? mx : 0);
        my = ((my >= 0) ? my : 0);
        if(mx >= (fb_v.w-C_WIDTH))
        {
            mx = (fb_v.w-C_WIDTH);
        }
        if(my >= (fb_v.h-C_HEIGHT))
        {
            my = (fb_v.h-C_HEIGHT);
        }

        mouse_cursor(mx, my);
    }
    return 0;
}
Exemplo n.º 3
0
int mouse_doing(void)
{
    int fd;
    int press_flag = 0;
    int end_flag = 0;
    mouse_event m_event;
    fd = open("/dev/input/mice", O_RDWR|O_NONBLOCK); //?
    if (fd == -1) 
    {
        perror("mice");
        exit(0);
    }

    mx = fb_v.w / 2;    //initial the coordinates.
    my = fb_v.h / 2;

    draw_cursor(mx, my);

    while (1) 
    {
        if (get_m_info(fd, &m_event) > 0) 
        {
            restore(mx, my);
            mx += m_event.dx;
            my += m_event.dy;
            mx = (mx < 0) ? 0 : mx;
            my = (my < 0) ? 0 : my;

            if (mx > (fb_v.w - C_W)) 
            {
                mx = fb_v.w - C_W;
            }
            if (my > (fb_v.h - C_H)) 
            {
                my = fb_v.h - C_H;
            }

            switch (m_event.button)
            {
                case 0: 
                    if (press_flag == 1) 
                    {
                        press_flag = 0;
                        if (end_flag == 0) 
                        {
                            end_flag = chess_do();
                        }
                        else 
                        {
                            print_board(GRAY, YELLOW);
                            end_flag = 0;
                        }
                    }
                    else if (press_flag == 2) 
                    {
                        press_flag = 0;
                        chess_do();
                    }
                    break;
                case 1: press_flag = 1; break;
                case 2: press_flag = 2; break;
                case 3:  break;
                case 4:  break;
                default: break;
            }

            draw_cursor(mx, my);
        }
        usleep(1000);
    }
    
    return 0;
}
Exemplo n.º 4
0
int  mouse_doing(void)
{
    int fd;
    mouse_event m_event;

    fd = open ("/dev/input/mice", O_RDWR|O_NONBLOCK);
    if (-1 == fd) 
    {
        perror ("mice");
        exit(0);
    }

    mx = fb_v.w/2;
    my = fb_v.h/2;

    int press_flag = 0;
    int end_flag = 0;

    draw_curser(mx ,my);
    while(1)
    {
        if (get_m_info(fd, &m_event)>0) 
        {
            restore(mx, my);
            mx += m_event.dx;
            my += m_event.dy;

            mx = ((mx<0) ? 0 : mx);
            my = ((my<0) ? 0 : my);
    
            if (mx > (fb_v.w-C_W)) 
            {
                mx = fb_v.w-C_W;
            }
            if (my >(fb_v.h-C_H)) 
            {
                my = fb_v.h-C_H;
            }
            switch(m_event.button)
            {
                case 0:
                    if (1 == press_flag) 
                    {

                        press_flag = 0;
                        if (0 == end_flag) 
                        {
                           end_flag =  chess_do();
                        }
                        else 
                        {
                           print_board(); 
                           end_flag = 0;
                        }
                    }
                    break;
                case 1: 
                    press_flag = 1; 
                    break;
                case 2: 
                    break;
                case 4: 
                break;
                default:
                break;
            }
            
            draw_curser(mx, my);    
        }

        usleep(100);
    }

    return 0;
}
Exemplo n.º 5
0
int mouse_doing(void)
{
    m_event mevent;
    fd_set input_fd;
    int fd;
    char c,victory = -1;
    int w=0;
    int who,n,flag1 = 1;;
    u32_t color = 0x00ffffff;
    int mx = 521;
    int my = 384;
    bzero(&board,sizeof(board));
    fd = open("/dev/input/mice",O_RDWR|O_NONBLOCK);
    if(fd < 0)
    {
        perror("open");
        exit(1);
    }
    draw_cursor(mx ,my);
    while(1)
    {
        FD_ZERO(&input_fd);
        FD_SET(client_sock,&input_fd);
        FD_SET(fd,&input_fd);
        if((select(fd+1,&input_fd,NULL,NULL,NULL)) < 0)
        {
            perror("select error");
            continue;
        }
        if((FD_ISSET(fd,&input_fd))&&(get_m_info(fd,&mevent)>0))
        {
            restore_shape(mx,my);
            mx += mevent.dx;
            my += mevent.dy;

            mx = ((mx >= 0)? mx:0);
            my = ((my >= 0)? my:0);
            if(mx >= (fb_v.w-C_WIDTH))
                mx = (fb_v.w-C_WIDTH);
            if(my >= (fb_v.h-C_HEIGHT))
                my = (fb_v.h-C_HEIGHT);

            switch(mevent.button)
            {
                case 1: 
                       if(flag1 == 1)
                       {
                            if((mx > 335)&&(mx < 1235)&&(my >55)&&(my < 775))
                            {
                                if( !check(mx,my) )
                                {
                                    color = ~color;
                                    who = create_spot(mx,my,color,w);
                                    save_shape(mx,my);
                                    chess_count(mx,my,who);
                                    victory = check_all();
                                    server_len = sizeof(server);
                                    n = sendto(client_sock, buffer, 12, 0, (struct sockaddr *)&server, server_len);
                                    flag1 = 0;
                                    w++;
                                }
                            }
                        }
                        break;
                case 2: break;
                case 4: break;
                default :break;
            }
            draw_cursor(mx,my);
        }
        usleep(1000);
        if(FD_ISSET(client_sock,&input_fd))
        {
            restore_shape(mx,my);
            server_len = sizeof(server);
            n = recvfrom(client_sock, buffer, BUFFER_SIZE, 0, (struct sockaddr *)&server, &server_len);
            mx = (p->x)*30 + 350;
            my = (p->y)*30 +70;
            if( !check(mx,my) )
            {
                color = ~color;
                who = create_spot(mx,my,color,w);
                save_shape(mx,my);
                chess_count(mx,my,who);
                victory = check_all();
                w++;
            }
            flag1 = 1;
            draw_cursor(mx,my);
        }
        if( victory == 1)
        {
            printf("play%d won!\n",who);
            printf("continue ? y/n\n");
            scanf("%c",&c);
            getchar();
            if( c=='n')
                break;
           else
            {
                create_scr_fb();
                print_board(350,70,0x008b6914);
                victory = -1;
                w=0;
                color = 0x00ffffff;
                mx = 521;
                my = 384;
                flag1 = 1;
                bzero(&board,sizeof(board)); 
                draw_cursor(mx,my);
            }
        }
     }
     close(fd); 
     return 0;
}
Exemplo n.º 6
0
int mouse_doing1(void)//(int x,int y)             //wang luo  hua qi zi  (zuo wei fu wu qi)
{
    m_event mevent;
	int len;
    int x,y;
    int kkk;
    int a;
    int p = 0;
    int fd;
    int k1,k2;
    int mx = 512;
    int my = 384;
    int aaaa;
    fd_set input_fd;
    fd = open("/dev/input/mice",O_RDWR);
    if(fd < 0)
    {
        perror("open");
        exit(1);
    }
    draw_cursor(mx, my);
    aaaa = fd > server_sock ? fd : server_sock;
    while(1)
    {
        FD_ZERO(&input_fd);
        FD_SET(fd,&input_fd);
        FD_SET(server_sock,&input_fd);
        if((select(aaaa+1,&input_fd,NULL,NULL,NULL)) < 0)
        {
            perror("select");
            continue;
        }
        if(FD_ISSET(fd,&input_fd))
        {
        if(get_m_info(fd, &mevent) > 0)
        {
            restore_shape(mx ,my);

            mx += mevent.dx;
            my += mevent.dy;

            mx = ((mx >= 0) ? mx : 0);
            my = ((my >= 0) ? my : 0);
            if(mx >= (fb_v.w-C_WIDTH))
            {
                mx = (fb_v.w-C_WIDTH);
            
            }
            if(my>= (fb_v.h-C_HEIGHT))
            {
                my = (fb_v.h-C_HEIGHT);
            
            }
            if(p%2 == 1)
            {
                switch(mevent.button)
                {
                    case 1 :

                             w= print_one_chess(mx,my,p);
                             save_shape(mx ,my);
                             chess_count(mx,my,w);
                             a = check_all();
                             p++;
	                  	     sendto(server_sock, buffer, BUFFER_SIZE, 0, (struct sockaddr *)&client, client_len);
                             break;
                    case 2 : break;
                    case 4 : break;
                    default: break;
            
                }
            }
//            if(a != 1)
            draw_cursor(mx ,my);
            if(a == 1)
            {
                bzero(&board,sizeof(board));
                printf("go: 0   exit: 1\n");
                scanf("%d",&kkk);
                break;
            }
        }
        usleep(1000);
        if(kkk == 1) close(fd);  
    }
    if(FD_ISSET(server_sock,&input_fd))
    {
    
        printf("dsads\n");
        restore_shape(mx,my);
		client_len = sizeof(client);
        printf("sdfsdf\n");
		len = recvfrom(server_sock, buffer, BUFFER_SIZE, 0, (struct sockaddr *)&client, &client_len);
        printf("%d\n",len);
		if (len < 0)
		{
			close(server_sock);
			fprintf(stderr, "%s\n", strerror(errno));
			exit(EXIT_FAILURE);
		}
		else
		{
			printf("recvfrom client ok!\n");
			in.s_addr = client.sin_addr.s_addr;
			printf("client ip  : %s\n", inet_ntoa(in));
			printf("client port: %d\n", ntohs(client.sin_port));
			printf("\n");
            x= pp->x ;
            y= pp->y ;
            printf("%d\n",pp->x);
            printf("%d\n",y);
            k1=x*30+100;
            k2=y*30+40;
            w= print_one1_chess(k1,k2);
            p++;
            chess_count(k1,k2,w);
            a = check_all();
		}
    }
    }
    return 0;
}
Exemplo n.º 7
0
int mouse_doing(void)                // zheng chang hua qi zi (dan  ji)
{
    m_event mevent;
    int kkk,a;
    int p = 0;
    int fd;
    int mx = 512;
    int my = 384;
    fd = open("/dev/input/mice",O_RDWR|O_NONBLOCK);
    if(fd < 0)
    {
        perror("open");
        exit(1);
    }
    draw_cursor(mx, my);
    while(1)
    {
        if(get_m_info(fd, &mevent) > 0)
        {
            restore_shape(mx ,my);

            mx += mevent.dx;
            my += mevent.dy;

            mx = ((mx >= 0) ? mx : 0);
            my = ((my >= 0) ? my : 0);
            if(mx >= (fb_v.w-C_WIDTH))
            {
                mx = (fb_v.w-C_WIDTH);
            
            }
            if(my >= (fb_v.h-C_HEIGHT))
            {
                my = (fb_v.h-C_HEIGHT);
            
            }
            switch(mevent.button)
            {
                case 1 :
                         w= print_one_chess(mx, my,p) ;
                         save_shape(mx ,my);
                         chess_count(mx,my,w);
                         a = check_all();
                         if(a == 1)
                         break;
                         p++;
                         break;
                case 2 : break;
                case 4 : break;
                default: break;
            
            }
            if(a != 1)
            draw_cursor(mx ,my);
          if(a == 1)
            {
                bzero(&board,sizeof(board));
                printf("go: 0   exit: 1\n");
                scanf("%d",&kkk);
                break;
            }
        }
        usleep(1000);
    }
    if(kkk == 1) close(fd);  
    return kkk;
}
Exemplo n.º 8
0
int mouse_doing(void)
{
    m_event mevent;
    //int fd;
    //int mx = 512;
    //int my = 384;
    char victory = -1;

    //fd = open("/dev/input/mice", O_RDWR|O_NONBLOCK);
    //if(fd < 0)
    //{
    //perror("open");
    //exit(1);
    //}

    //print_color();
    //mouse_cursor(mx, my);
    //while(1)
    //{
    if(get_m_info(fd, &mevent) > 0)
    {
        restore_shape(mx, my);
        mx += mevent.dx;
        my += mevent.dy;

        mx = ((mx >= 0) ? mx : 0);
        my = ((my >= 0) ? my : 0);
        if(mx >= (fb_v.w-C_WIDTH))
        {
            mx = (fb_v.w-C_WIDTH);
        }
        if(my >= (fb_v.h-C_HEIGHT))
        {
            my = (fb_v.h-C_HEIGHT);
        }

        mouse_cursor(mx, my);
        switch(mevent.mode)
        {
        case 1:
            restore_shape(mx, my);
            if (scan_point(mx, my) == 0)
            {
                //if(global_color == 0x00ffffff)
                //{
                //global_color = 0x00000000;
                //who = 1;
                //}
                //else
                //{
                //global_color = 0x00ffffff;
                //who = 2;
                //}
                flag = 1;
                chess_count(mx, my);
                //global_x = mx - STARTX;
                //global_y = my - STARTY;
                //global_x = mx;
                //global_y = my;
                victory = check_all();
            }
            mouse_cursor(mx, my);
            break;
        case 2:
            break;
        case 4:
            break;
        default:
            break;
        }
#if 0
        if(victory == 1)
        {
            printf("play%d won!\n", who);
            printf("contniue ? y/n\n");
            if(getchar() == 'n')
                return 0;
            else
            {
                memset((u8_t *)fb_v.fb_men, 0, fb_v.h * fb_v.w *fb_v.bpp/8);
                memset(board, 0, H_NUM * V_NUM);
                fb_backgound(0, 0, fb_v.w - 1, fb_v.h - 1, 0x00996600);
                fb_backgound(STARTX, STARTY, STARTX + (V_NUM - 1) * SPACE, STARTY + (H_NUM - 1) * SPACE, 0x00ffcc33);
                fb_board(0x000000ff);
                print_color();
                mouse_cursor(512, 384);
                global_color = 0xffffffff;
                who = 1;
                victory = -1;
                mx = 512;
                my = 384;
                mouse_cursor(mx, my);
            }
            getchar();
        }
#endif
    }
    usleep(1000);
    //}
    return 0;
}