/***************************************************************************** * Function Name: InitializeSystem() ****************************************************************************** * Summary: * Initialize everything here. * * Parameters: * None. * * Return: * None. * * Note: * *****************************************************************************/ void InitializeSystem(void) { // Enable global interrupts. CyGlobalIntEnable; // Initialize the table used for CRC calcultation. crc_Init(); //Initalize the vectors used for data storage. Vector_Init(); //Initialize the LED module. _LED_Init(); // Initialize the CapSense module. _CapSense_Init(); // Initialize the BLE module. _BLE_Init(); // Initialize the watchdog. _Watchdog_Init(); #if LOWPOWERMODE_ENABLED // Initialize the Low Power module. LowPowerMode_Init(); #else // Initialize the Timer and related Interrupt components. _Timer_Init(); #endif // Initialize status flags Status_Ready = TRUE; Status_Acquiring = FALSE; Status_NoMoreSpace = FALSE; Status_DataAcquired = FALSE; Status_Sending = FALSE; Status_NoMoreData = FALSE; // Initialize counters numConnInterval = 0u; }
//************************************************************************************* //************************************************************************************* void ARX_FOGS_RenderAll(LPDIRECT3DDEVICE7 m_pd3dDevice) { EERIE_3D angle; Vector_Init(&angle); SETALPHABLEND(m_pd3dDevice, FALSE); for (long i = 0; i < MAX_FOG; i++) { if (fogs[i].exist) { if (fogobj) DrawEERIEInter(m_pd3dDevice, fogobj, &angle, &fogs[i].pos, NULL); Vector_Copy(&fogs[i].bboxmin, &BBOXMIN); Vector_Copy(&fogs[i].bboxmax, &BBOXMAX); if (fogs[i].special & FOG_DIRECTIONAL) { EERIE_3D orgn, dest; orgn.x = fogs[i].pos.x; orgn.y = fogs[i].pos.y; orgn.z = fogs[i].pos.z; dest.x = orgn.x + fogs[i].move.x * 50.f; dest.y = orgn.y + fogs[i].move.y * 50.f; dest.z = orgn.z + fogs[i].move.z * 50.f; EERIEDraw3DLine(m_pd3dDevice, &orgn, &dest, EERIECOLOR_WHITE); } if (fogs[i].selected) { EERIEDraw2DLine(m_pd3dDevice, fogs[i].bboxmin.x, fogs[i].bboxmin.y, fogs[i].bboxmax.x, fogs[i].bboxmin.y, 0.01f, EERIECOLOR_YELLOW); EERIEDraw2DLine(m_pd3dDevice, fogs[i].bboxmax.x, fogs[i].bboxmin.y, fogs[i].bboxmax.x, fogs[i].bboxmax.y, 0.01f, EERIECOLOR_YELLOW); EERIEDraw2DLine(m_pd3dDevice, fogs[i].bboxmax.x, fogs[i].bboxmax.y, fogs[i].bboxmin.x, fogs[i].bboxmax.y, 0.01f, EERIECOLOR_YELLOW); EERIEDraw2DLine(m_pd3dDevice, fogs[i].bboxmin.x, fogs[i].bboxmax.y, fogs[i].bboxmin.x, fogs[i].bboxmin.y, 0.01f, EERIECOLOR_YELLOW); } } } }
//----------------------------------------------------------------------------- float CMagicMissile::Render(LPDIRECT3DDEVICE7 m_pd3dDevice) { int i = 0; EERIE_3D lastpos, newpos; EERIE_3D v; EERIE_3D stiteangle; EERIE_3D stitepos; EERIE_3D stitescale; EERIE_RGB stitecolor; EERIE_3D av; if (ulCurrentTime >= ulDuration) { return 0.f; } // Set Appropriate Renderstates ------------------------------------------- SETCULL(m_pd3dDevice, D3DCULL_NONE); SETZWRITE(m_pd3dDevice, FALSE); m_pd3dDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE); m_pd3dDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE); SETALPHABLEND(m_pd3dDevice, TRUE); // Set Texture ------------------------------------------------------------ if (tex_mm && tex_mm->m_pddsSurface) { if ((spells[spellinstance].caster == 0) && (cur_mr == 3)) SETTC(m_pd3dDevice, NULL); else SETTC(m_pd3dDevice, tex_mm); } // ------------------------------------------------------------------------ if (bMove) { fTrail = (ulCurrentTime * fOneOnDuration) * (iBezierPrecision + 2) * 5; } lastpos.x = pathways[0].sx; lastpos.y = pathways[0].sy; lastpos.z = pathways[0].sz; Vector_Copy(&newpos, &lastpos); for (i = 0; i < 5; i++) { int kp = i; int kpprec = (i > 0) ? kp - 1 : kp ; int kpsuiv = kp + 1 ; int kpsuivsuiv = (i < (5 - 2)) ? kpsuiv + 1 : kpsuiv; for (int toto = 1; toto < iBezierPrecision; toto++) { if (fTrail < i * iBezierPrecision + toto) break; float t = toto * fOneOnBezierPrecision; float t1 = t; float t2 = t1 * t1 ; float t3 = t2 * t1 ; float f0 = 2.f * t3 - 3.f * t2 + 1.f ; float f1 = -2.f * t3 + 3.f * t2 ; float f2 = t3 - 2.f * t2 + t1 ; float f3 = t3 - t2 ; float val = pathways[kpsuiv].sx; float p0 = 0.5f * (val - pathways[kpprec].sx) ; float p1 = 0.5f * (pathways[kpsuivsuiv].sx - pathways[kp].sx) ; v.x = f0 * pathways[kp].sx + f1 * val + f2 * p0 + f3 * p1 ; val = pathways[kpsuiv].sy ; p0 = 0.5f * (val - pathways[kpprec].sy) ; p1 = 0.5f * (pathways[kpsuivsuiv].sy - pathways[kp].sy) ; v.y = f0 * pathways[kp].sy + f1 * val + f2 * p0 + f3 * p1 ; val = pathways[kpsuiv].sz ; p0 = 0.5f * (val - pathways[kpprec].sz) ; p1 = 0.5f * (pathways[kpsuivsuiv].sz - pathways[kp].sz) ; v.z = f0 * pathways[kp].sz + f1 * val + f2 * p0 + f3 * p1 ; Vector_Copy(&newpos, &v); if (!((fTrail - (i * iBezierPrecision + toto)) > iLength)) { float c; if (fTrail < iLength) { c = 1.0f - ((fTrail - (i * iBezierPrecision + toto)) / fTrail); } else { c = 1.0f - ((fTrail - (i * iBezierPrecision + toto)) / (float)iLength); } float fsize = c; float alpha = c - 0.2f; if (alpha < 0.2f) alpha = 0.2f; c += frand2() * 0.1f; if (c < 0) c = 0; else if (c > 1) c = 1; int color = D3DRGB(c * fColor[0] * alpha, c * fColor[1] * alpha, c * fColor[2] * alpha); if (fsize < 0.5f) fsize = fsize * 2 * 3; else fsize = (1.0f - fsize + 0.5f) * 2 * (3 * 0.5f); float fs = fsize * 6 + rnd() * 0.3f; float fe = fsize * 6 + rnd() * 0.3f; Draw3DLineTex(m_pd3dDevice, lastpos, newpos, color, fs, fe); } EERIE_3D temp_vector; Vector_Copy(&temp_vector, &lastpos); Vector_Copy(&lastpos, &newpos); Vector_Copy(&newpos, &temp_vector); } } av.x = newpos.x - lastpos.x; av.y = newpos.y - lastpos.y; av.z = newpos.z - lastpos.z; float bubu = GetAngle(av.x, av.z, 0, 0); float bubu1 = GetAngle(av.x, av.y, 0, 0); Vector_Copy(&stitepos, &lastpos); stiteangle.b = -RAD2DEG(bubu); stiteangle.a = 0; stiteangle.g = -(RAD2DEG(bubu1)); if (av.x < 0) stiteangle.g -= 90; if (av.x > 0) stiteangle.g += 90; if (stiteangle.g < 0) stiteangle.g += 360.0f; if ((spells[spellinstance].caster == 0) && (cur_mr == 3)) { stitecolor.r = 1.f; stitecolor.g = 0.f; stitecolor.b = 0.2f; } else { stitecolor.r = 0.3f; stitecolor.g = 0.3f; stitecolor.b = 0.5f; } Vector_Init(&stitescale, 1, 1, 1); { if ((smissile)) DrawEERIEObjEx(m_pd3dDevice, smissile, &stiteangle, &stitepos, &stitescale, &stitecolor); } Vector_Copy(&eCurPos, &lastpos); return 1 - 0.5f * rnd(); }