void ParticleData::kill(int id) {
		if (countAlive > 0) {
			alive[id] = false;
			swapData(id, countAlive - 1);
			countAlive--;
		}
	}
示例#2
0
int DCIFile::readData() {
	file_t f;
	uint8 *raw;
	vmu_dir_t header;
	DreamcastFile *df;
	
	df=getDCFile();
	if(df == NULL) {
		df=new DreamcastFile();
		setDCFile(df);
	}
	if (!(f=fs_open(getFileName(), O_RDONLY))) {
		printf("ERROR: Can't open %s!\n", getFileName());
		return(-1);
	}
	fs_read(f, &header, 0x20);
	df->loadHeader(&header);
//	raw=(uint8*)malloc(df->getSize());
	raw=new uint8[df->getSize()];
	fs_read(f, raw, df->getSize());
	df->setData(swapData(raw));
//	free(raw);
	fs_close(f);
	return(0);
}
	void ParticleData::wake(int id) {
		if (countAlive < count) {
			alive[id] = true;
			swapData(id, countAlive);
			countAlive++;
		}
	}
示例#4
0
void TransformSystem::sortByParentChild()
{
    short* indirection = (short*) alloca(sizeof(short) * _index._size);
    short* relocations = (short*) alloca(sizeof(short) * _index._size);
    short* array = (short*) alloca(sizeof(short) * _index._size);
    
    for (int i = 0; i < _index._size; i++)
    {
        indirection[i] = i;
        relocations[i] = i;
        array[i] = i;
    }
    
    std::sort(indirection, indirection + _index._size, DataComp<int>(_heights));
    
    /*for (int j = 0; j < _index._size; j++)
     {
     printf("%i ", indirection[j]);
     }
     printf("\n");*/
    
    for (int i = 0; i < _index._size - 1; i++)
    {
        const int currentIndex = i;
        //i = 0, proper = 1, properLocation = 1, toReloc = 0 = i relocTarget=properLocation=1
        const int proper = indirection[i];
        const int properLocation = relocations[proper];
        const int toReloc = array[properLocation];
        const int relocTarget = array[currentIndex];
        const int a = currentIndex;
        const int b = properLocation;
        
        //printf("swap(%i, %i) proper=%i properLocation=%i toReloc=%i relocTarget=%i\n", a, b, proper, properLocation, toReloc, relocTarget);
        if (a == b)
        {
            relocations[proper] = -1;
            /*for (int j = 0; j < _index._size; j++)
             {
             printf("%i ", relocations[j]);
             }
             printf("\n");*/
            continue;
        }
        
        
        relocations[relocTarget] = toReloc;
        relocations[currentIndex] = proper;
        relocations[proper] = -1;
        /*for (int j = 0; j < _index._size; j++)
         {
         printf("%i ", relocations[j]);
         }
         printf("\n");*/
        
        swapData(a, b);
        swap(array[a], array[b]);
    }
    
    _dirty = false;
}
示例#5
0
int DCIFile::writeData() {
	file_t f;
	vmu_dir_t header;
	DreamcastFile *df;

	df=getDCFile();
	if (!(f=fs_open(getFileName(), "wb"))) {
		printf("ERROR: Can't open %s!\n", getFileName());
		return(-1);
	}
	df->buildHeader(&header);
	fs_write(f, &header, 0x20);
	fs_write(f, swapData(df->getData()), df->getSize());
	fs_close(f);
	swapData(df->getData());
	return(0);
}
void ParticleData::wake(size_t id)
{
	if(_aliveParticleCount < _particleCount)
	{
		_particleAliveFlags[id]=true;
		swapData(id,_aliveParticleCount);
		_aliveParticleCount++;
	}
}
void ParticleData::kill(size_t id)
{
	if(_aliveParticleCount>0)
	{
		_particleAliveFlags[id]=false;
		swapData(id,_aliveParticleCount-1);
		_aliveParticleCount--;
	}
}
示例#8
0
void _DMAengine_xmit_buf(struct zsTxDmaQueue *q, VBUF *buf)
{
    VDESC *currVdesc;
    struct zsDmaDesc* usbDesc;
    struct zsDmaDesc* prevUsbDesc = NULL;
    struct zsDmaDesc* headUsbDesc;   
        
    /* Re-link the VDESC of buf into USB descriptor list & queue the descriptors 
       into upQ
     */
    currVdesc = (VDESC *)buf->desc_list;
    while(currVdesc != NULL) {
        
        usbDesc = (struct zsDmaDesc *)currVdesc->hw_desc_buf;
                
        init_usb_desc(usbDesc);
        usbDesc->dataSize = currVdesc->data_size;
        usbDesc->dataAddr = (volatile u32_t)(currVdesc->buf_addr + currVdesc->data_offset);
        usbDesc->ctrl = 0;
        usbDesc->status = 0;

#if ENABLE_SW_SWAP_DATA_MODE && ENABLE_SWAP_DATA_MODE == 0
        swapData(usbDesc);
#endif

        if ( prevUsbDesc == NULL ) {
            headUsbDesc = usbDesc;
            
            usbDesc->ctrl |= ZM_FS_BIT;
            
            // how to get the total len???
            usbDesc->totalLen = buf->buf_length;
            prevUsbDesc = usbDesc;
        }
        else {
            prevUsbDesc->nextAddr = usbDesc;
            prevUsbDesc = usbDesc;
        }
             
        currVdesc = currVdesc->next_desc;
    }

    usbDesc->ctrl |= ZM_LS_BIT;
    headUsbDesc->lastAddr = usbDesc;

    if ( q->xmited_buf_head == NULL && q->xmited_buf_tail == NULL ) {
        q->xmited_buf_head = buf;
        q->xmited_buf_tail = buf;
        q->xmited_buf_head->next_buf = q->xmited_buf_tail;
    }
    else {
        q->xmited_buf_tail->next_buf = buf;
        q->xmited_buf_tail = buf;
    }

    DMA_Engine_put_packet((struct zsDmaQueue *)q, headUsbDesc); 
}
示例#9
0
void VectorMem::swap(int index1, int index2)
{
    // Swap Particles:
    // Uh, Yeah, so we don't really need to swap anything...
    //Particle temp = mem[index1];
    mem[index1] = mem[index2];
    //mem[index2] = temp;

    swapData(index1, index2);
}
示例#10
0
void ICACHE_FLASH_ATTR sortData(void) {
	int outerIdx, innerIdx, swapped = true;
	for (outerIdx = 0; (outerIdx < MAX_ENTRY) && swapped; outerIdx++) {
		swapped = false;
		for (innerIdx = MAX_ENTRY - 1; innerIdx > outerIdx + 1; innerIdx--) {
			if (compareData(innerIdx, innerIdx - 1) > 0) {
				swapData(innerIdx, innerIdx - 1);
				// os_printf("%d<->%d\n", innerIdx, innerIdx - 1);
				swapped = true;
			}
		}
	}
}
示例#11
0
static bstnode * _delete(bstnode * root, bstnode * n) {
    bstnode * c = NULL;

    if(n->left == NULL && n->right == NULL) {
        if (n == root)
            root = NULL;
        bst_dispose(n);
    } else if (n->left != NULL && n->right != NULL) {
        c = bst_minimum(n->right);
        swapData(n, c);
        _delete(root, c);
    } else {
        c = n->left == NULL? n->right : n->left;
        if (root == n)
            root = c;
        c->parent = n->parent;
        bst_dispose(n);
    }
    return root;
}
示例#12
0
VBUF* _DMAengine_reap_recv_buf(struct zsDmaQueue *q)
{
    struct zsDmaDesc* desc;
    VBUF *buf;
    //int i;
    //u8_t *tbuf = (u8_t *)desc->dataAddr;
            
    desc = DMA_Engine_get_packet(q);            
    
    if(!desc)
       return NULL;

#if ENABLE_SW_SWAP_DATA_MODE && ENABLE_SWAP_DATA_MODE == 0
    swapData(desc);
#endif
    
    buf = VBUF_alloc_vbuf();
    adf_os_assert(buf != NULL);
    
    relinkUSBDescToVdesc(buf, desc);
    return buf;
}
示例#13
0
	bool doRedo()
	{
		return swapData();
	}
示例#14
0
	bool doUndo()
	{
		return swapData();
	}
示例#15
0
 void ParticleData::kill(unsigned int id) {
     
     mAlive[id] = false;
     swapData(id, (mCountAlive - 1));
     --mCountAlive;
 }
示例#16
0
	bool doRedo() override { return swapData(); }