Esempio n. 1
0
int cellAdecGetPcmItem(u32 handle, mem32_t pcmItem_ptr)
{
	cellAdec.Log("cellAdecGetPcmItem(handle=%d, pcmItem_ptr_addr=0x%x)", handle, pcmItem_ptr.GetAddr());

	AudioDecoder* adec;
	if (!Emu.GetIdManager().GetIDData(handle, adec))
	{
		return CELL_ADEC_ERROR_ARG;
	}

	if (!pcmItem_ptr.IsGood())
	{
		return CELL_ADEC_ERROR_FATAL;
	}

	AdecFrame& af = adec->frames.Peek();

	if (adec->frames.IsEmpty())
	{
		return CELL_ADEC_ERROR_EMPTY;
	}

	AVFrame* frame = af.data;

	mem_ptr_t<CellAdecPcmItem> pcm(adec->memAddr + adec->memBias);

	adec->memBias += 512;
	if (adec->memBias + 512 > adec->memSize)
	{
		adec->memBias = 0;
	}

	pcm->pcmHandle = 0; // ???
	pcm->pcmAttr.bsiInfo_addr = pcm.GetAddr() + sizeof(CellAdecPcmItem);
	pcm->startAddr = 0x00000312; // invalid address (no output)
	pcm->size = af.size;
	pcm->status = CELL_OK;
	pcm->auInfo.pts.lower = af.pts;
	pcm->auInfo.pts.upper = af.pts >> 32;
	pcm->auInfo.size = af.auSize;
	pcm->auInfo.startAddr = af.auAddr;
	pcm->auInfo.userData = af.userdata;

	mem_ptr_t<CellAdecAtracXInfo> atx(pcm.GetAddr() + sizeof(CellAdecPcmItem));
	atx->samplingFreq = frame->sample_rate; // ???
	atx->nbytes = frame->nb_samples * frame->channels * sizeof(float); // ???
	atx->channelConfigIndex = CELL_ADEC_CH_STEREO; // ???

	pcmItem_ptr = pcm.GetAddr();

	return CELL_OK;
}
Esempio n. 2
0
void CGPEngineView::OnDraw(CDC* pDC)
{
	CGPEngineDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	if (!pDoc)
		return;

	if(!init)
		return;

	// Render LOOP
	BOOL seguir = TRUE;
	float time = 0;
	LARGE_INTEGER F, T0, T1;   // address of current frequency
	QueryPerformanceFrequency(&F);
	QueryPerformanceCounter(&T0);

	// Back buffering
	CRect rc;
	GetClientRect(&rc);
	int width = rc.Width();
	int height = rc.Height();
	HBITMAP hbm = CreateCompatibleBitmap(pDC->m_hDC, width,height);   
	HDC hTmpDC = CreateCompatibleDC(pDC->m_hDC);       
	HBITMAP hOldBm = (HBITMAP)SelectObject(hTmpDC, hbm);
	HBRUSH hbr = CreateSolidBrush(RGB(255,255,255));
	double elapsed_time = 0;

	while (seguir)
	{

		QueryPerformanceCounter(&T1);
		elapsed_time += (double)(T1.QuadPart - T0.QuadPart) / (double)F.QuadPart;
		time += (float)elapsed_time;
		T0 = T1;


		if(!step_by_step)
		{
			if(elapsed_time>=fixed_dt)
			{
				_world.Update(fixed_dt);
				elapsed_time -= fixed_dt;
			}
		}

		FillRect(hTmpDC,&rc,hbr);
		_world.Render(hTmpDC,ox,oy,ex,ey);

		if(cant_pt!=0)
		{
			// Esta dibujando un poligono
			CDC *ptmpDC = CDC::FromHandle(hTmpDC);
			CPen pen,*penOld;
			float dE = 10 / ex;		// 10 pixeles
			// verifico si esta cerrado, es decir si el punto del mouse esta cerca del primero, si hace click, ya puede
			// cerrar el poligono
			Vector2 Q = Vector2((mouse_x-ox)/ex, (mouse_y-oy)/oy);
			bool cerrado = cant_pt >=3 && (pt[0]-Q).Length()<dE ? true : false;

			pen.CreatePen(PS_SOLID,cerrado ? 3 : 1,RGB(128,0,0));
			penOld = ptmpDC->SelectObject(&pen);

			ptmpDC->MoveTo(atx(pt[0].x) , aty(pt[0].y));
			for(int i=1;i<cant_pt;++i)
			{
				ptmpDC->LineTo(atx(pt[i].x) , aty(pt[i].y));
			}
			ptmpDC->LineTo(mouse_x, mouse_y);
			ptmpDC->SelectObject(penOld);
		}

		BitBlt (pDC->m_hDC, 0, 0, width,height, hTmpDC, 0,0, SRCCOPY);	

		MSG Msg;
		ZeroMemory(&Msg, sizeof(Msg));
		if (PeekMessage(&Msg, NULL, 0U, 0U, PM_REMOVE))
		{

			if (Msg.message == WM_QUIT || Msg.message == WM_CLOSE)
			{
				seguir = FALSE;
				exit(0);
			}

			// dejo que windows procese el mensaje
			TranslateMessage(&Msg);
			DispatchMessage(&Msg);
		}
	}

	DeleteObject(hbr);
	SelectObject(hTmpDC, hOldBm);   
	DeleteObject(hbm);
	DeleteDC(hTmpDC);

}