Пример #1
0
void Control::calculate()
{
    STACKTRACE;

    if (!exists())
        return;

    target_stuff();

    if (ship) {
        if (!ship->exists() || (ship->death_counter != -1)) {
            //message.print(5000, 12, "Ship died in frame %d", game->frame_number);
            select_ship( NULL, NULL);
        }
        else keys = think();
    }

    if (!ship) {
        keys = 0;
        if (temporary)
            state = 0;
    }

    if (channel != Game::channel_none) {
        //prediction stuff
        _prediction_keys[_prediction_keys_index] = keys;
        _prediction_keys_index = (_prediction_keys_index + 1) & (_prediction_keys_size-1);

        //network prep for dieing (set state to unbuffering)
        if (!ship && temporary && (already > 0)) already = -already;

        //network traffic
        int lf = game->lag_frames;
        if (0) ;
        else if (already < 0) {
            //unbuffering
            game->log->unbuffer(channel + Game::_channel_buffered, &keys, sizeof(KeyCode));
            keys = intel_ordering_short(keys);
            already += 1;
        }
        else if (already < lf) {
            //buffering
            keys = intel_ordering_short(keys);
            game->log->buffer(channel + Game::_channel_buffered, &keys, sizeof(KeyCode));
            keys = intel_ordering_short(keys);
            already += 1;
        }
        else if (already > lf) {
            //stupid error check
            tw_error("Control::calculate() - inconcievable!");
        }						 //stable, perform no action
        else {
            game->log_short(channel + Game::_channel_buffered, keys);
        }
    }

    return;
}
Пример #2
0
void nand_reset(void)
{
    /* 选中 */
    select_ship();
    
    /* 清除RnB */
    clean_RnB();
    
    /* 发出复位信号 */
    nand_cmd(0xff);
    
    /* 等待就绪 */
    wait_RnB();
    
    /* 取消选中 */
    delselect_ship();
}
Пример #3
0
void NF_PageRead(unsigned long addr,unsigned char* buff)
{
    int i;
    
    
    /* 选中芯片 */
    select_ship();
    
    /* 清除RnB */
    clean_RnB();
    
    /* 发出命令0x00 */
     nand_cmd(0x00);
        
     /* 发出列地址 */
    nand_addr(0x00);
    nand_addr(0x00);

    /* 发出行地址 */
    nand_addr(addr&0xff);
    nand_addr((addr >>8 ) & (0xff));
    nand_addr((addr >>16 ) & (0xff));
        
    /* 发出命令0x30 */
     nand_cmd(0x30);
        
    /* 等待就绪 */
     wait_RnB();
        
    /* 读数据 */
     for(i = 0; i<1024*2; i++)
    {
    	*buff++ = NFDATA;
    }
        
      
     /* 取消片选 */
     
     delselect_ship();
     
}