示例#1
0
文件: coff.c 项目: giggi/12step
block_list coff_make(section_list seclist)
{
  block_list blklist;
  block blk_coff_header;
  block blk_optional_header;
  block blk_section_header;
  block blk_sections;
  section text_sec, data_sec, bss_sec;
  int section_header_number;

  blklist = block_list_create();

  blk_coff_header     = block_create("COFF header");
  blk_optional_header = block_create("optional header");
  blk_section_header  = block_create("section header");
  blk_sections        = block_create("sections");

  block_list_insert(blklist, NULL, blk_coff_header);
  block_list_insert(blklist, NULL, blk_optional_header);
  block_list_insert(blklist, NULL, blk_section_header);
  block_list_insert(blklist, NULL, blk_sections);

  section_list_align(seclist, sizeof(long));

  text_sec = section_list_search(seclist, ".text");
  data_sec = section_list_search(seclist, ".data");
  bss_sec  = section_list_search(seclist, ".bss");

  /* 不要なセクション情報を削除 */
  coff_delete_waste_section(seclist);
  section_header_number = section_list_get_length(seclist);

  /* COFFヘッダを作成 */
  coff_make_coff_header(blk_coff_header, section_list_get_length(seclist));

  /* オプションヘッダを作成 */
  coff_make_optional_header(blk_optional_header,
			    section_get_memory_size(text_sec),
			    section_get_memory_size(data_sec),
			    section_get_memory_size(bss_sec),
			    section_list_get_entry_point(seclist),
			    section_get_virtual_addr(text_sec),
			    section_get_virtual_addr(data_sec));

  /* セクションヘッダを作成 */
  coff_make_section_header(blk_section_header, seclist,
			   sizeof(struct coff_header) + sizeof(struct coff_optional_header) + sizeof(struct coff_section_header) * section_header_number);

  /* セクションの本体を作成 */
  coff_make_sections(blk_sections, seclist);

  block_list_align(blklist, sizeof(long));

  return blklist;
}
示例#2
0
文件: arena.c 项目: UweKopf/server
void create_arena(void)
{
  int x;
  arena_id = hashstring("arena");
  arena = getplanebyid(arena_id);
  if (arena != NULL)
    return;
  score();                      /* ist wichtig, damit alle Parteien einen score haben, wenn sie durchs Tor wollen. */
  guardian_faction(arena, 999);
  if (arena)
    arena_center = findregion(plane_center_x(arena), plane_center_y(arena));
  if (!arena_center) {
    newarena = 1;
    arena =
      create_new_plane(arena_id, "Arena", -10000, -10000, 0, BLOCKSIZE - 1,
      PFL_LOWSTEALING | PFL_NORECRUITS | PFL_NOALLIANCES);
    block_create(arena->minx, arena->miny, T_OCEAN);
    arena_center = findregion(plane_center_x(arena), plane_center_y(arena));
    for (x = 0; x != BLOCKSIZE; ++x) {
      int y;
      for (y = 0; y != BLOCKSIZE; ++y) {
        region *r = findregion(arena->minx + x, arena->miny + y);
        freset(r, RF_ENCOUNTER);
        r->planep = arena;
        switch (distance(r, arena_center)) {
          case 4:
            terraform(r, T_FIREWALL);
            break;
          case 0:
            terraform(r, T_GLACIER);
            break;
          case 1:
            terraform(r, T_SWAMP);
            break;
          case 2:
            terraform(r, T_MOUNTAIN);
            break;
        }
      }
    }
  }
  make_temple(arena_center);
#ifdef CENTRAL_VOLCANO
  init_volcano();
#else
  if (arena_center->terrain != T_DESERT)
    terraform(arena_center, T_DESERT);
#endif
  rsetmoney(arena_center, 0);
  rsetpeasants(arena_center, 0);
  tower_init();
}
示例#3
0
/*
 * Stores held ztr huffman_codes as ZTR chunks.
 * Returns 0 for success
 *        -1 for failure
 */
int ztr_store_hcodes(ztr_t *ztr) {
    int i;
    ztr_chunk_t *chunks;
    int nchunks;

    if (ztr->nhcodes == 0)
	return 0;

    /* Extend chunks array */
    nchunks = ztr->nchunks + ztr->nhcodes;
    chunks = (ztr_chunk_t *)realloc(ztr->chunk, nchunks * sizeof(*chunks));
    if (!chunks)
	return -1;
    ztr->chunk = chunks;

    /* Encode */
    for (i = 0; i < ztr->nhcodes; i++) {
	block_t *blk = block_create(NULL, 2);
	int j = ztr->nchunks;
	unsigned char bytes[2];

	ztr->chunk[j].type = ZTR_TYPE_HUFF;
	ztr->chunk[j].mdata = 0;
	ztr->chunk[j].mdlength = 0;
	ztr->chunk[j].ztr_owns = 1;
	bytes[0] = 0;
	bytes[1] = ztr->hcodes[i].codes->code_set;
	store_bytes(blk, bytes, 2);
	/* FIXME: Now already cached in ztr_hcode_t */
	if (0 == store_codes(blk, ztr->hcodes[i].codes, 1)) {
	    /* Last byte is always merged with first of stream */
	    if (blk->bit == 0) {
		unsigned char zero = 0;
		store_bytes(blk, &zero, 1);
	    }

	    ztr->chunk[j].data = (char *)blk->data;
	    ztr->chunk[j].dlength = blk->byte + (blk->bit != 0);
	    block_destroy(blk, 1);
	    ztr->nchunks++;
	}
    }

    return ztr->nchunks == nchunks ? 0 : -1;
}
示例#4
0
文件: parser.c 项目: stonegao/mirb
struct node *alloc_scope(struct compiler *compiler, struct block **block_var, enum block_type type)
{
    struct block *block = block_create(compiler, type);

    struct node *result = compiler_alloc(compiler, sizeof(struct node));

    block->parent = compiler->current_block;
    block->owner = compiler->current_block ? compiler->current_block->owner : 0;

    result->left = (void *)block;
    result->type = N_SCOPE;

    compiler->current_block = block;

    *block_var = block;

    return result;
}
示例#5
0
文件: map.c 项目: odrevet/GE
int map_block_add(map* p_map, float fill_percent, float dispertion_average)
{
  int i,j;
  int block_nb=0;

  if(fill_percent <= 0) return 0;              //Reduce algo complexity
  else if (fill_percent >1)fill_percent=1;     //roof


  //Count the actual number of blocks to put (equal at the fill percent of empty and unprotected tiles)
  //Get all possibly blocks
  for (i=0;i<p_map->height;i++)
    {
      for (j=0;j<p_map->width[i];j++)
        {
	  if ((p_map->pp_tile[i][j].type == EMPTY) && (!p_map->pp_tile[i][j].is_protected))
            {
	      block_nb++;
            }
        }
    }

  //Apply percentage
  block_nb =  block_nb * fill_percent;
  int initial_block_nb = block_nb;

  //Randomly put blocks on the map
  while(block_nb > 0)
    {
      i = rand() % (p_map->height);
      j = rand() % (p_map->width[i]);
      if ((p_map->pp_tile[i][j].type == EMPTY) && (!p_map->pp_tile[i][j].is_protected))
        {
	  p_map->pp_tile[i][j].type = BLOCK;
	  p_map->pp_tile[i][j].p_block = block_create();
	  p_map->pp_tile[i][j].p_block->x = j * TILE_SIZE;
	  p_map->pp_tile[i][j].p_block->y = i * TILE_SIZE;
	  p_map->pp_tile[i][j].is_walkable= false;
	  block_nb--;
        }
    }

  return initial_block_nb;
}
示例#6
0
文件: state.c 项目: Aleyr/nesemu2
int state_save(memfile_t *file)
{
	stateheader_t header;
	block_t *block;
	int i;

	//clear the state info
	memset(&header,0,sizeof(stateheader_t));

	//set the ident/version of the state header
	header.ident = ident;
	header.version = version;

	//calculate total data size
	for(i=0;blockinfo[i].type;i++) {
		blockinfo[i].size = 0;
		blockinfo[i].func(STATE_SIZE,(u8*)&blockinfo[i].size);
		if(blockinfo[i].size) {
			header.usize += blockinfo[i].size + 8;
		}
	}

	//write the state header
	writevar(header.ident,4);
	writevar(header.version,2);
	writevar(header.flags,2);
	writevar(header.usize,4);
	writevar(header.csize,4);
	writevar(header.crc32,4);

	//write each block
	for(i=0;blockinfo[i].type;i++) {
		if(blockinfo[i].size == 0)
			continue;
		printf("saving block '%4s' (%d bytes)\n",&blockinfo[i].type,blockinfo[i].size);
		block = block_create(blockinfo[i].type,blockinfo[i].size);
		blockinfo[i].func(STATE_SAVE,block->data);
		block_save(file,block);
		block_destroy(block);
	}

	return(0);
}
示例#7
0
Access *access_avi_create(char *access_path)
{
	return_val_if_fail(access_path, NULL);
		
	int fd = -1;
	char file_path[64] = {0};

	if(avi_parse_path(access_path, file_path, 64) != 0)
	{
		msg_dbg("Fun(%s) error parse the access_path(%s) failed!\n", __func__, access_path);
		return NULL;
	}

	Access *thiz = (Access *)FTK_ZALLOC(sizeof(Access) + sizeof(PrivInfo));
	return_val_if_fail(thiz != NULL, NULL);

	/*open the file */
	fd = open(file_path, O_RDONLY);
	if(fd <= 0)
	{
		msg_dbg("error:open the file failed! file path(%s)\n", file_path);
		return NULL;
	}

	thiz->seek = NULL;
	thiz->read = NULL;
	thiz->block = access_avi_block;
	thiz->control = NULL;
	thiz->destroy = access_avi_destroy;

	DECL_PRIV(thiz, priv);

	priv->file_path = FTK_STRDUP(file_path);
	priv->block = block_create(MAX_H264_PACKET_LEN);
	
	access_init_ffmpeg(thiz, file_path);
	
	return thiz;
}
示例#8
0
// Create a heapAllocator of *size* bytes
// Initialised with one block pointing to the whole memory
heapAllocator* heap_create( int heap_size ) {
	// We add space for the first block header, so we do get the correct total size
	// ie. this means that heap_create (size), followed by heap_Allocate( size ) should work
	void* data = malloc( sizeof( heapAllocator ) + sizeof( block ) + heap_size );
	memset( data, 0, sizeof( heapAllocator ) + sizeof( block ) + heap_size );

	heapAllocator* allocator = (heapAllocator*)data;
	data = (uint8_t*)data + sizeof( heapAllocator );
	allocator->total_size = heap_size;
	allocator->total_free = heap_size;
	allocator->total_allocated = 0;
	allocator->bitpool_count = 0;
	
	// Should not be possible to fail creating the first block header
	allocator->free = NULL;
	allocator->first = block_create( allocator, data, heap_size );
	vAssert( allocator->first ); 
	vAssert( allocator->free == allocator->first ); 
	vAssert( allocator->free == allocator->first ); 
	vAssert( nextFree( allocator->free ) == NULL ); 

	return allocator;
}
示例#9
0
文件: blocks.c 项目: daktyl/Arkanoid
void blocks_initialize(ALLEGRO_DISPLAY* display) {
    unsigned short blocks_in_row = 0;
    unsigned short row = 1;
    unsigned short count = 1;
    while (row <= BLOCKS_ROWS) {
        block_create((blocks_in_row * BLOCK_W), (unsigned short) ((SCREEN_H/2) - (row * BLOCK_H)));
        ++blocks_in_row;
        ++count;
        if (blocks_in_row * BLOCK_W > SCREEN_W) {
            ++row;
            blocks_in_row = 0;
        }
    }
    struct listNode* current = first;
    while (current != NULL) {
        current->bitmap = al_create_bitmap(BLOCK_W, BLOCK_H);
        al_set_target_bitmap(current->bitmap);
        al_clear_to_color(al_map_rgb(234,225,100));
        current = current->next;
    }
    al_set_target_bitmap(al_get_backbuffer(display));   /* Change drawing target to screen buffer */
    al_flip_display();                                  /* Print buffer to screen */
}
示例#10
0
/*
 * Searches through the cached huffman_codeset_t tables looking for a stored
 * huffman code of type 'code_set'.
 * NB: only code_sets >= CODE_USER will be stored here.
 *
 * Returns codes on success,
 *         NULL on failure
 */
ztr_hcode_t *ztr_find_hcode(ztr_t *ztr, int code_set) {
    int i;

    if (code_set < CODE_USER)
	return NULL; /* computed on-the-fly or use a hard-coded set */

    /* Check through chunks for undecoded HUFF chunks */
    if (!ztr->hcodes_checked) {
	for (i = 0; i < ztr->nchunks; i++) {
	    if (ztr->chunk[i].type == ZTR_TYPE_HUFF) {
		block_t *blk;
		huffman_codeset_t *cs;
		uncompress_chunk(ztr, &ztr->chunk[i]);
		blk = block_create((unsigned char *)(ztr->chunk[i].data+2),
				   ztr->chunk[i].dlength-2);
		cs = restore_codes(blk, NULL);
		if (!cs) {
		    block_destroy(blk, 1);
		    return NULL;
		}
		cs->code_set = (unsigned char)(ztr->chunk[i].data[1]);
		ztr_add_hcode(ztr, cs, 1);
		block_destroy(blk, 1);
	    }
	}
	ztr->hcodes_checked = 1;
    }

    /* Check cached copies */
    for (i = 0; i < ztr->nhcodes; i++) {
	if (ztr->hcodes[i].codes->code_set == code_set)
	    return &ztr->hcodes[i];
    }

    return NULL;
}
示例#11
0
void pge_init() {
  // Allocate
  for(int z = 0; z < GRID_DEPTH; z++) {
    for(int y = 0; y < GRID_HEIGHT; y++) {
      for(int x = 0; x < GRID_WIDTH; x++) {
        s_block_array[vec2i(Vec3(x, y, z))] = block_create(Vec3(x * BLOCK_SIZE, y * BLOCK_SIZE, z * BLOCK_SIZE), GSize(BLOCK_SIZE, BLOCK_SIZE), COLOR_INVISIBLE);
      }
    }
  }
  for(int i = 0; i < MAX_CLOUDS; i++) {
    s_cloud_array[i] = cloud_create(Vec3(0, 0, SKY_HEIGHT), GSize(BLOCK_SIZE, BLOCK_SIZE), Vec3(GRID_WIDTH * BLOCK_SIZE, GRID_HEIGHT * BLOCK_SIZE, SKY_HEIGHT));
  }

  // Set up world
  generate_world();

  // Set up engine
  pge_isometric_set_projection_offset(PBL_IF_ROUND_ELSE(GPoint(90, 110), GPoint(72, 80)));
  pge_isometric_set_enabled(true);
  pge_set_framerate(FRAME_RATE_IDLE);
  pge_begin(GColorBlack, logic, render, click);
  s_main_window = pge_get_window();

  s_status_layer = text_layer_create(grect_inset(
    layer_get_bounds((window_get_root_layer(s_main_window))),
    PBL_IF_ROUND_ELSE(GEdgeInsets(30, 0, 130, 0), GEdgeInsets(0, 0, 150, 0))));
  text_layer_set_background_color(s_status_layer, GColorBlack);
  text_layer_set_text_color(s_status_layer, GColorWhite);
  text_layer_set_text_alignment(s_status_layer, PBL_IF_ROUND_ELSE(GTextAlignmentCenter, GTextAlignmentLeft));
  layer_add_child(window_get_root_layer(s_main_window), text_layer_get_layer(s_status_layer));
  update_status_text();

#ifdef BENCHMARK
  APP_LOG(APP_LOG_LEVEL_INFO, "Heap free: %dB after creating %d blocks (Size: %dB)", (int)heap_bytes_free(), (GRID_WIDTH * GRID_HEIGHT * GRID_DEPTH), get_world_size());
#endif
}
示例#12
0
// Allocates *size* bytes from the given heapAllocator *heap*
// Will crash if out of memory
// NEEDS TO BE THREADSAFE
void* heap_allocate_aligned( heapAllocator* heap, size_t toAllocate, size_t alignment, const char* source ) {
	(void)source;
	vmutex_lock( &allocator_mutex );
#ifdef MEM_DEBUG_VERBOSE
	printf( "HeapAllocator request for " dPTRf " bytes, " dPTRf " byte aligned.\n", toAllocate, alignment );
#endif
	bitpool* bit_pool = heap_findBitpool( heap, toAllocate );
	if ( bit_pool ) {
		void* data = bitpool_allocate( bit_pool, toAllocate );
		if ( data ) {
			vmutex_unlock( &allocator_mutex );
			return data;
		}
	}

	size_t size_original = toAllocate;
	toAllocate += alignment;	// Make sure we have enough space to align
	block* b = heap_findEmptyBlock( heap, toAllocate );

	if ( !b ) {
		heap_dumpBlocks( heap );
		printError( "HeapAllocator out of memory on request for " dPTRf " bytes. Total size: " dPTRf " bytes, Used size: " dPTRf " bytes\n", toAllocate, heap->total_size, heap->total_allocated );
		vAssert( 0 );
	}

	vAssert( b->free );
	assertBlockInvariants( b );

	removeFromFreeList( heap, b );
	b->free = false;

	assertBlockInvariants( b );

	if ( b->size > ( toAllocate + sizeof( block ) + sizeof( block* ) * 2) ) {
		void* new_ptr = ((uint8_t*)b->data) + toAllocate;
		block* remaining = block_create( heap, new_ptr, b->size - toAllocate );
		block_insertAfter( b, remaining );
		b->size = toAllocate;
		heap->total_allocated += sizeof( block );
		heap->total_free -= sizeof( block );
		validateBlockNext(b);
		validateBlockNext(remaining);
	}

	assertBlockInvariants( b );

	// Move the data pointer on enough to force alignment
	uintptr_t offset = alignment - (((uintptr_t)b->data - 1) % alignment + 1);
	b->data = ((uint8_t*)b->data) + offset;
	b->size -= offset;
	// Now move the block on and copy the header, so that it's contiguous with the block
	block* new_block_position = (block*)(((uint8_t*)b) + offset);
	// Force alignment for this so we can memcpy (on Android, even memcpy requires alignments when dealing with structs)
	block block_temp;
	memcpy( &block_temp, b, sizeof( block ));
	//////////////////////////////////////////////////////
	vAssert( b->prevFree == NULL );
	vAssert( b->nextFree == NULL );
	b = new_block_position;
	memcpy( b, &block_temp, sizeof( block ));
	// Fix up pointers to this block, for the new location
	if ( b->prev ) {
		b->prev->next = b;
		b->prev->size += offset; // Increment previous block size by what we've moved the block
	}
	else
		heap->first = b;
	if ( b->next )
		b->next->prev = b;

	assertBlockInvariants( b );
	//////////////////////////////////////////////////////
	validateBlockNext(b);

	heap->total_allocated += toAllocate;
	heap->total_free -= toAllocate;
	++heap->allocations;

	// Ensure we have met our requirements
	uintptr_t align_offset = ((uintptr_t)b->data) % alignment;
	vAssert( align_offset == 0 );	// Correctly Aligned
	vAssert( b->size >= size_original );	// Large enough

#ifdef MEM_DEBUG_VERBOSE
	printf("Allocator returned address: " xPTRf ".\n", (uintptr_t)b->data );
#endif

#ifdef MEM_STACK_TRACE
	block_recordAlloc( b, mem_stack_string );
#endif // MEM_STACK_TRACE

	assertBlockInvariants( b );

#ifdef TRACK_ALLOCATIONS
	if (source)
		strncpy( b->source, source, MemSourceLength);
	else
		b->source[0] = '\0';
#endif
	//validateFreeList( heap );
	vmutex_unlock( &allocator_mutex );

	return b->data;
}
示例#13
0
文件: main.c 项目: nowl/open-dm
int main(int argc, char *argv[])
{
    lapis_init();

    engine_t *engine = lapis_get_engine();
    set_ticks_per_second(30);

    game_state_t *state = game_state_create(0);
    state->num_render_levels = RL_NUM;

    engine_switch_state(engine, state);

    /* initialize video */

    lsdl_set_video_mode(engine->sdl_driver,
                        WIDTH, HEIGHT, 0, 1);

    SDL_EnableKeyRepeat(500, 50);
    SDL_WM_SetCaption( "Open DM v. 0.1", NULL );

    glMatrixMode( GL_PROJECTION );
    glLoadIdentity( );
    gluPerspective(FIELD_OF_VISION, 1, 0.1, 100);

//    glEnable(GL_TEXTURE_2D);

    glClearColor( 0.0f, 0.0f, 0.0f, 0.0f );
    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    glEnable(GL_DEPTH_TEST);
//    glDisable(GL_LIGHTING);
//    glEnable(GL_LIGHTING);

    glViewport(0, 0, WIDTH, HEIGHT);

    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    gluLookAt(0,0,0, 0, 0, -10, 0, 1.0, 0);

    /* test */
    /* load graphics */
//    lapis_lua_t *lua = lua_scripting_init();
//    if( lua_scripting_run_file(lua, "main.lua") != 0 )
//        return 0;
    /* end test */

    /* create objects */

    game_object_t * global_object = game_object_create("global", NULL);
    game_state_append_object(state, global_object);
    game_object_set_recv_callback_c_func(global_object, global_message_handler);
    game_state_append_bcast_recvr(state,
                                  global_object,
                                  "sdl-event");

    block_t *block = block_create(1, 1);
    game_state_append_object(state, block->go);

    camera_t *camera = camera_create(0, 0, 0);
    game_state_append_object(state, camera->go);

    lapis_mainloop();

    /* this will be cleaned up by the OS */
    //game_state_destroy(state);
    //lapis_deinit();

    return 0;
}
示例#14
0
文件: block_test.c 项目: rebas/so
int main (int argc, char **argv)
{
	int result = handle_options(argc, argv);
	struct device *dev;
	int i;

	if (result != 0)
		exit(result);

	if (argc - optind != 1) {
		printf ("Necesita un argumento que es el nombre del"
			" sistema de ficheross\n\n");
		while (optind < argc)
			printf ("'%s' ", argv[optind++]);
		printf ("\n");
		usage(-2);
	}

	dev = block_create(argv[optind], num_blocks, block_size);

	if (dev == NULL) {
		printf("Error creando el sistema de ficheros %s (%s)\n",
		       argv[optind], strerror(errno));
		exit(-1);
	}

	if (block_close(dev) == -1) {
		printf("Error cerrando el sistema de ficheros %s 1\n",
		       argv[optind]);
		exit(-1);
	}

	dev = block_open(argv[optind]);
	if (dev == NULL) {
		printf("Error abriendo el sistema de ficheros %s 2\n",
		       argv[optind]);
		exit(-1);
	}

	for (i = 0; i < num_blocks; i++) {
		int buffer[block_size/4];
		int j;
		for (j = 0; j < block_size/4; j++)
			buffer[j] = i;
		result = block_write(dev, buffer, i);
		if (result == -1)
			printf("Error escribiendo bloque %d, (Error %s)\n",
			       i, strerror(errno));
	}

	if (block_close(dev) == -1) {
		printf("Error cerrando el sistema de ficheros %s 2\n",
		       argv[optind]);
		exit(-1);
	}

	dev = block_open(argv[optind]);
	if (dev == NULL) {
		printf("Error abriendo el sistema de ficheros %s 3\n",
		       argv[optind]);
		exit(-1);
	}

	for (i = 0; i < num_blocks; i++) {
		int buffer[block_size/4];
		int j;

		result = block_read(dev, buffer, i);		
		if (result == -1)
			printf("Error leyendo bloque %d, (Error %s)\n",
			       i, strerror(errno));

		for (j = 0; j < block_size/4; j++)
			if (buffer[j] !=  i) {
				printf("Contenido blque %d erroreo\n", i);
				break;
			}

	}

	if (block_close(dev) == -1) {
		printf("Error cerrando el sistema de ficheros %s 4\n",
		       argv[optind]);
		exit(-1);
	}

	exit (0);
}
示例#15
0
void g_updateGame()
{
	if (game.state == STATE_IDLE)
	{
		//do nothing
	}
	else if (game.state == STATE_MENU)
	{	
		//menuSound = m_move;
		
		switch ( m_move() )
		{
			case SND_MENUMOVE:
				s_playSound(menuMove);
				break;
			case SND_MENUSELECT:
				s_playSound(menuSelect);
				break;
			case SND_NONE:
			default:
				break;
		}
		/*
		if ( !m_move() )
		{
			//too much output
			//printf("[g_updateGame]: m_move returned false!\n");
		}
		*/
	}
	else if (game.state == STATE_PLAYING)
	{	
		//game.currentTime = SDL_GetTicks();
		
		//take note of the frame here, see if it is time to move the current tetro
		//1 notch down
		if ( dropFrameInterval >= dropIntervalPerRow[game.level] && !game.isSoftDropping ) //time to drop down 1, only if down arrow not already held down
		{
			dropFrameInterval = 0;

			if ( !tetro_move(game.current, DIR_SOUTH) ) //the periodic drop down was blocked
			{
				//printf("[g_updateGame]: periodic drop down blocked!\n");
				g_onDownBlocked();
			}
			//game.lastDropTime = game.currentTime;
		}
		
		
			
		//rotate has priority
		if ( game.current->tryRotate )
		{
			debug_msg("[g_updateGame]: trying rotate...\n");
			if ( tetro_rotate(game.current) )
			{
				debug_msg("[g_updateGame]: rotate success!\n");
				s_playSound(rotate);
			}
			else
				debug_msg("[g_updateGame]: rotate failed!\n");
		}
		
		//for delayed auto shifting
		if ( game.dasDir != DIR_NONE )
		{
			game.current->nextMoveY = DIR_NONE;
			if ( game.dasDelaying )
			{
				if ( game.dasFrame >= DAS_DELAY )
				{
					game.dasDelaying = false;
					game.current->nextMoveX = game.dasDir;
					game.dasFrame = 0;
				}
			}
			else
			{
				if ( game.dasFrame >= DAS_PERIOD )
				{
					game.current->nextMoveX = game.dasDir;
					game.dasFrame = 0;
				}
			}
			game.dasFrame++;
		}
		//printf("game.dasFrame = %d\n", game.dasFrame);
		
		if ( game.isSoftDropping )
		{
			if ( game.softDropFrame >= SOFT_DROP_FRAMES ) //time to move down a notch
			{
				game.softDropFrame = 0;
				if ( !tetro_move(game.current, DIR_SOUTH) )
				{
					//printf("[g_updateGame]: periodic drop down blocked!\n");
					g_onDownBlocked();
					game.softDropFrame = SOFT_DROP_FRAMES; //next block insta drop down
					game.score += game.softDropDistanceCount;
					game.softDropDistanceCount = 0;
				}
				else
					game.softDropDistanceCount++;
			}
			game.softDropFrame++;
		}
		else
		{
			//create resultant move direction
			if ( game.current->nextMoveX == DIR_NONE )
				game.current->nextMoveDir = game.current->nextMoveY;
			else if ( game.current->nextMoveY == DIR_NONE )
				game.current->nextMoveDir = game.current->nextMoveX;
			else if ( game.current->nextMoveY == DIR_NORTH )
			{
				if ( game.current->nextMoveX == DIR_WEST )
					game.current->nextMoveDir = DIR_NORTHWEST;
				else
					game.current->nextMoveDir = DIR_NORTHEAST;
			}
			else //nextMoveY == south
			{
				if ( game.current->nextMoveX == DIR_WEST )
					game.current->nextMoveDir = DIR_SOUTHWEST;
				else
					game.current->nextMoveDir = DIR_SOUTHEAST;
			}
		
			//attempt to move tetro in this direction
			if ( !tetro_move(game.current, game.current->nextMoveDir) )
			{
				printf("move failed no sound\n");
				//printf("[g_updateGame]: tetro_move failed!\n");
				if ( game.current->nextMoveDir == DIR_SOUTH  || game.current->nextMoveDir == DIR_SOUTHWEST || game.current->nextMoveDir == DIR_SOUTHEAST )
				{
					g_onDownBlocked();
				}
			}
			else if ( game.current->nextMoveDir == DIR_WEST || game.current->nextMoveDir == DIR_EAST ) //successful move, check to see if i should play a sound
			{
				printf("play move because move succeeded west or east\n");
				//if ( game.dasFrame == 0 && game.dasDelaying == true )
					s_playSound(moveSideways);
			}
		}
		
		game.current->nextMoveX = DIR_NONE;
		game.current->nextMoveY = DIR_NONE;
		game.current->nextMoveDir = DIR_NONE;
		game.current->tryRotate = false;

		dropFrameInterval++;
	}
	else if (game.state == STATE_LOSS)
	{
		//the idea: every frame fill up one of the spaces with a "dead" block. so in 180 frames the whole screen will be filled
		short i;
		block * b;
		
		if (game.lossFrame == -1)
		{
			//do nothing
		}
		else
		{
			if (game.lossCurrentRow >= SIZE_Y)
			{
				g_clear(REASON_LOSS);
			}
			else
			{
				if (game.lossFrame == 0)
					SDL_Delay(LOSS_PAUSE);
				
				if (game.lossFrame % 3 == 0)
				{
					for ( i = 0; i < SIZE_X; i++ )
					{
						b = g_getBlockAtPos(i, game.lossCurrentRow);
						if (b != NULL)
							g_removeBlockFromPos(b);
						b = NULL;
					
						b = block_create(TETRO_DEAD, NULL);
						if ( !block_teleport(b, i, game.lossCurrentRow) )
							debug_msg("[g_updateGame]: STATE_LOSS- error teleporting dead block into position!\n");
						b = NULL;
					}
					game.lossCurrentRow++;
				}
			}
		}
		
		game.lossFrame++;
	}		
	else
		debug_msg("[g_updateGame]: unknown game.state!\n");
	
	menu.nextMoveDir = DIR_NONE;
}