void SRS_Source_Out::Process(void* pSamples, int sampleBytes, int sampleRate, int countChans){ // Will NOT touch Audio in these cases... if (sampleRate < 0) return; if (countChans != 2) return; if (DidAPIInit == false) APIInit(sampleRate, countChans); if (DidAPIInit == false) return; // Still not ready? int tFrames = sampleBytes/(sizeof(int16_t)*countChans); if (Framesize != tFrames){ Framesize = tFrames; if ((Framesize%256 != 0) && (UseCache == false)){ SRS_LOG("Framesize of %d forcing Cache!!", Framesize); InitCaching(); } } int16_t FadeHold[512]; // 256*stereo bool tWantProcess = WillProcess(); if (tWantProcess == false){ // Turning off... if (ProcState == PROCST_OFF) return; // Already off... else if (ProcState == PROCST_IN){ // Was fading in, fade out... ProcState = PROCST_OUT; ProcTrack = PROC_FADELEN-ProcTrack; } else if (ProcState == PROCST_ON){ // start fade out.. ProcState = PROCST_OUT; ProcTrack = 0; } // else already fading out - keep going... } else { if (ProcState == PROCST_OFF){ ProcState = PROCST_IN; ProcTrack = 0; if (UseCache == true) InitCaching(); // Caching? Reset... } else if (ProcState == PROCST_OUT){ ProcState = PROCST_IN; ProcTrack = PROC_FADELEN-ProcTrack; } } int16_t* pSampsIn = (int16_t*)pSamples; // Fade In/Out... may return early... while ((ProcState == PROCST_OUT) || (ProcState == PROCST_IN)){ SRS_LOG("Fading %d - %d", ProcState, ProcTrack); int tProcLen = (tFrames<256)?tFrames:256; // How many samples to process? tFrames -= tProcLen; // Pull that many off... int16_t* pSampsOrig = FadeHold; memcpy(FadeHold, pSampsIn, tProcLen*sizeof(int16_t)*countChans); // Back up data for fade... CoreProcess(pSampsIn, tProcLen); // Process... int tProcRemain = PROC_FADELEN-ProcTrack; // How much can we process? int tDoProc = (tProcRemain<tProcLen)?tProcRemain:tProcLen; // How many will we process? int tDoPass = (tProcLen>tDoProc)?(tProcLen-tDoProc):0; // How many will we fill from history/processed? int32_t tTween = ProcTrack*gProcStep; // Where we are in the fade... ProcTrack += tDoProc; if (ProcState == PROCST_OUT){ // Fading out... FadeLoop_2Chan(pSampsIn, pSampsOrig, pSampsIn, tTween, gProcStep, tDoProc); pSampsIn += 2*tDoProc; pSampsOrig += 2*tDoProc; if (tDoPass > 0){ // We over processed - so restore from the originals we saved... memcpy(pSampsIn, pSampsOrig, tDoPass*sizeof(int16_t)*countChans); pSampsIn += 2*tDoPass; } if (ProcTrack >= PROC_FADELEN){ ProcState = PROCST_OFF; // Done!!! return; } } else { // Fading in... tTween -= PROC_DELAYIN*gProcStep; // Adjust for the fade-in delay... FadeLoop_2Chan(pSampsIn, pSampsIn, pSampsOrig, tTween, gProcStep, tDoProc); pSampsIn += 2*tProcLen; // Anything past tDoProc until tProcLen will be what we processed... no 'pass' phase... if (ProcTrack >= PROC_FADELEN){ ProcState = PROCST_ON; // Done!!! } } if (tFrames <= 0) break; } if (tFrames > 0) CoreProcess(pSampsIn, tFrames); }
/*!*************************************************************************** @Function SetTextures @Input pContext Context @Input dwScreenX Screen resolution along X @Input dwScreenY Screen resolution along Y @Input bRotate Rotate print3D by 90 degrees @Return PVR_SUCCESS or PVR_FAIL @Description Initialization and texture upload. Should be called only once for a given context. *****************************************************************************/ EPVRTError CPVRTPrint3D::SetTextures( const SPVRTContext * const pContext, const unsigned int dwScreenX, const unsigned int dwScreenY, const bool bRotate) { #if !defined (DISABLE_PRINT3D) unsigned short i; bool bStatus; // Set the aspect ratio, so we can chage it without updating textures or anything else float fX, fY; m_bRotate = bRotate; m_ui32ScreenDim[0] = bRotate ? dwScreenY : dwScreenX; m_ui32ScreenDim[1] = bRotate ? dwScreenX : dwScreenY; // Alter the X, Y resolutions if the screen isn't portrait. if(dwScreenX > dwScreenY) { fX = (float) dwScreenX; fY = (float) dwScreenY; } else { fX = (float) dwScreenY; fY = (float) dwScreenX; } m_fScreenScale[0] = (bRotate ? fY : fX) /640.0f; m_fScreenScale[1] = (bRotate ? fX : fY) /480.0f; // Check whether textures are already set up just in case if (m_bTexturesSet) return PVR_SUCCESS; if(!APIInit(pContext)) return PVR_FAIL; /* This is the window background texture Type 0 because the data comes in TexTool rectangular format. */ bStatus = APIUpLoad4444(1, (unsigned char *)WindowBackground, 16, 0); if (!bStatus) return PVR_FAIL; bStatus = APIUpLoad4444(2, (unsigned char *)WindowPlainBackground, 16, 0); if (!bStatus) return PVR_FAIL; bStatus = APIUpLoad4444(3, (unsigned char *)WindowBackgroundOp, 16, 0); if (!bStatus) return PVR_FAIL; bStatus = APIUpLoad4444(4, (unsigned char *)WindowPlainBackgroundOp, 16, 0); if (!bStatus) return PVR_FAIL; /* This is the texture with the fonts. Type 1 because there is only alpha component (RGB are white). */ bStatus = APIUpLoad4444(0, (unsigned char *)PVRTPrint3DABC_Pixels, 256, 1); if (!bStatus) return PVR_FAIL; // INDEX BUFFERS m_pwFacesFont = (unsigned short*)malloc(PVRTPRINT3D_MAX_RENDERABLE_LETTERS*2*3*sizeof(unsigned short)); if(!m_pwFacesFont) return PVR_FAIL; bStatus = APIUpLoadIcons((const PVRTuint32 *)PVRTPrint3DPVRLogo, (const PVRTuint32 *)PVRTPrint3DIMGLogo); if (!bStatus) return PVR_FAIL; // Vertex indices for letters for (i=0; i < PVRTPRINT3D_MAX_RENDERABLE_LETTERS; i++) { m_pwFacesFont[i*6+0] = 0+i*4; m_pwFacesFont[i*6+1] = 3+i*4; m_pwFacesFont[i*6+2] = 1+i*4; m_pwFacesFont[i*6+3] = 3+i*4; m_pwFacesFont[i*6+4] = 0+i*4; m_pwFacesFont[i*6+5] = 2+i*4; } m_nVtxCacheMax = MIN_CACHED_VTX; m_pVtxCache = (SPVRTPrint3DAPIVertex*)malloc(m_nVtxCacheMax * sizeof(*m_pVtxCache)); m_nVtxCache = 0; if(!m_pVtxCache) { return PVR_FAIL; } // Everything is OK m_bTexturesSet = true; // set all windows for an update for (i=0; i<PVRTPRINT3D_MAX_WINDOWS; i++) m_pWin[i].bNeedUpdated = true; // Return Success return PVR_SUCCESS; #else return PVR_SUCCESS; #endif }
/*!*************************************************************************** @Function SetTextures @Input pContext Context @Input pTexData User-provided font texture @Input uiDataSize Size of the data provided @Input dwScreenX Screen resolution along X @Input dwScreenY Screen resolution along Y @Input bRotate Rotate print3D by 90 degrees @Input bMakeCopy This instance of Print3D creates a copy of it's data instead of sharing with previous contexts. Set this parameter if you require thread safety. @Return PVR_SUCCESS or PVR_FAIL @Description Initialization and texture upload of user-provided font data. Should be called only once for a Print3D object. *****************************************************************************/ EPVRTError CPVRTPrint3D::SetTextures( const SPVRTContext * const pContext, const void * const pTexData, const unsigned int dwScreenX, const unsigned int dwScreenY, const bool bRotate, const bool bMakeCopy) { #if !defined (DISABLE_PRINT3D) unsigned short i; bool bStatus; // Set the aspect ratio, so we can change it without updating textures or anything else float fX, fY; m_bRotate = bRotate; m_ui32ScreenDim[0] = bRotate ? dwScreenY : dwScreenX; m_ui32ScreenDim[1] = bRotate ? dwScreenX : dwScreenY; // Alter the X, Y resolutions if the screen isn't portrait. if(dwScreenX > dwScreenY) { fX = (float) dwScreenX; fY = (float) dwScreenY; } else { fX = (float) dwScreenY; fY = (float) dwScreenX; } m_fScreenScale[0] = (bRotate ? fY : fX) /640.0f; m_fScreenScale[1] = (bRotate ? fX : fY) /480.0f; // Check whether textures are already set up just in case if (m_bTexturesSet) return PVR_SUCCESS; if(!APIInit(pContext, bMakeCopy)) return PVR_FAIL; /* This is the texture with the fonts. */ PVRTextureHeaderV3 header; CPVRTMap<PVRTuint32, CPVRTMap<PVRTuint32, MetaDataBlock> > MetaDataMap; bStatus = APIUpLoadTexture((unsigned char *)pTexData, &header, MetaDataMap); if (!bStatus) return PVR_FAIL; /* This is the associated font data with the default font */ bStatus = LoadFontData(&header, MetaDataMap); if (!bStatus) return PVR_FAIL; // INDEX BUFFERS m_pwFacesFont = (unsigned short*)malloc(PVRTPRINT3D_MAX_RENDERABLE_LETTERS*2*3*sizeof(unsigned short)); if(!m_pwFacesFont) return PVR_FAIL; bStatus = APIUpLoadIcons(PVRTPrint3DIMGLogo); if (!bStatus) return PVR_FAIL; // Vertex indices for letters for (i=0; i < PVRTPRINT3D_MAX_RENDERABLE_LETTERS; i++) { m_pwFacesFont[i*6+0] = 0+i*4; m_pwFacesFont[i*6+1] = 3+i*4; m_pwFacesFont[i*6+2] = 1+i*4; m_pwFacesFont[i*6+3] = 3+i*4; m_pwFacesFont[i*6+4] = 0+i*4; m_pwFacesFont[i*6+5] = 2+i*4; } m_nVtxCacheMax = MIN_CACHED_VTX; m_pVtxCache = (SPVRTPrint3DAPIVertex*)malloc(m_nVtxCacheMax * sizeof(*m_pVtxCache)); m_nVtxCache = 0; if(!m_pVtxCache) { return PVR_FAIL; } // Everything is OK m_bTexturesSet = true; // Return Success return PVR_SUCCESS; #else return PVR_SUCCESS; #endif }
/* * The Main function for the KL sub-module. * uint32_t *BITPointer -> the pointer to the BIT. */ void Main(BIT_t *BITPointer) { // Save BITPointer into a global variable. BIT = BITPointer; FileAPIFunc = (FileAPIFunc_t)BIT->FileAPI; VideoAPIFunc = (VideoAPIFunc_t)BIT->Video.VideoAPI; AllocFrameFunc = (AllocFrameFunc_t)BIT->DBALPMM.AllocFrame; FreeFrameFunc = (FreeFrameFunc_t)BIT->DBALPMM.FreeFrame; AllocContigFramesFunc = (AllocContigFramesFunc_t)BIT->DBALPMM.AllocContigFrames; FreeContigFramesFunc = (FreeContigFramesFunc_t)BIT->DBALPMM.FreeContigFrames; AbortBootFunc = (AbortBootFunc_t)BIT->Video.AbortBoot; uint32_t FeatureFlags = CPUFeatureFlags(); FILE_t Kernel, KernelMPMM, KernelMVMM; // Long mode is present - load the related files. if(FeatureFlags & LONG_MODE_PRESENT) { // Load the AMD64 kernel. FileAPIFunc(FILE_KERNEL, ARCH_AMD64, &Kernel); // Load the PMM and VMM AMD64 kernel module. FileAPIFunc(FILE_KERNEL_M, PMMAMD64, &KernelMPMM); FileAPIFunc(FILE_KERNEL_M, VMMAMD64, &KernelMVMM); AMD64PagingInit(); // Point the paging map function to AMD64 one. GenericPagingMap = &AMD64PagingMap; // Set the architecture. BIT->Arch = ARCH_AMD64; } // Else, load the x86 files. else { // Load the x86 kernel. FileAPIFunc(FILE_KERNEL, ARCH_X86, &Kernel); // If PAE is present, then load those modules. // ALSO, NOTE: Memory *should* be present over 4GiB to take advantage of PAE, so we // ensure there is. Else, we use x86. if((FeatureFlags & PAE_PRESENT) && (BIT->HighestAddress > 0xFFFFFFFFLLU)) { FileAPIFunc(FILE_KERNEL_M, PMMX86PAE, &KernelMPMM); FileAPIFunc(FILE_KERNEL_M, VMMX86PAE, &KernelMVMM); PAEPagingInit(); // Point the paging map function to PAE one. GenericPagingMap = &PAEPagingMap; // Set the architecture. BIT->Arch = ARCH_PAE; } // Else, load the x86 modules. else { FileAPIFunc(FILE_KERNEL_M, PMMX86, &KernelMPMM); FileAPIFunc(FILE_KERNEL_M, VMMX86, &KernelMVMM); x86PagingInit(); // Point the paging map function to x86 one. GenericPagingMap = &x86PagingMap; // Set the architecture. BIT->Arch = ARCH_X86; } } // Initialize the API. APIInit(); // Map the kernel (& modules). ModuleMap(Kernel); ModuleMap(KernelMPMM); ModuleMap(KernelMVMM); uint32_t BITFrame = AllocFrameFunc(POOL_BITMAP); if(!BITFrame) { // Switch to text mode. VideoAPIFunc(VIDEO_VGA_SWITCH_MODE, MODE_80_25_TEXT); AbortBootFunc("ERROR: Unable to allocate pages for the BIT."); } // Copy the BIT to the frame. memcpy((void*)BITFrame, BIT, sizeof(BIT_t)); switch(BIT->Arch) { case ARCH_X86: // Map the BIT frame. GenericPagingMap(X86_BIT, BITFrame); // Map the stack for x86. RegionMap(X86_STACK - STACK_SIZE, X86_STACK); // Enable paging completely. x86PagingEnable(); break; case ARCH_PAE: // Map the BIT frame. GenericPagingMap(PAE_BIT, BITFrame); // Map the stack for PAE. RegionMap(PAE_STACK - STACK_SIZE, PAE_STACK); // Enable paging completely. PAEPagingEnable(); break; case ARCH_AMD64: // Map the BIT frame. GenericPagingMap(AMD64_BIT, BITFrame); // Map the stack for AMD64. RegionMap(AMD64_STACK - STACK_SIZE, AMD64_STACK); // Enable paging completely. AMD64PagingEnable(); break; } // We shouldn't reach here. for(;;) { __asm__ __volatile__("hlt"); } }