void DelayMS(unsigned int milliseconds) { while (milliseconds >= 100) { _Delay(11700); milliseconds -= 100; } while (milliseconds != 0) { _Delay(117); milliseconds--; } }
/** * @brief Main program. * @param None * @retval None */ void main(void) { static u16 i=0; CLK_Config(); UART_Config(); TIM2_Config(); enableInterrupts(); printF("TIM2_Config finish !\n",FALSE,0); /* Infinite loop */ while (1) { _Delay(100); printF("LOG MSG (%4d) !\n",TRUE,i++); } }
/********************************************************************* * * _InitController * * Purpose: * Initializes the display controller */ static void _InitController(void) { #ifndef WIN32 #define BYTES_PER_LINE ((XSIZE_PHYS + 7) >> 2) LCD_X_Init(); _Write1(0x40); // SYSTEM SET: _Delay(255); // Wait a while _Write0((1 << 5) // P1: Screen Origin Compensation: not done. | (1 << 4) // Reserved | (0 << 3) // Panel Drive Select: single panel drive | (0 << 2) // Character Height: 8 pixels | (0 << 1) // Reserved | (0 << 0)); // Character Generator Select: CGROM _Write0((1 << 7) // P2: MOD: two-frame AC drive | (7 << 0)); // Horizontal Character Size: 8 _Write0((7 << 0)); // P3: Vertical Character Size: 8 _Write0(BYTES_PER_LINE - 1); // P4: Character Bytes Per Row _Write0(BYTES_PER_LINE + 2); // P5: Total Character Bytes Per Row _Write0(YSIZE_PHYS - 1); // P6: Frame Height _Write0(BYTES_PER_LINE); // P7: Horizontal Address Range Register 0 _Write0(0x00); // P8: Horizontal Address Range Register 1 _Write1(0x44); // SCROLL: _Write0((BYTES_PER_LINE * YSIZE_PHYS) & 0xff); // Screen Block 1 Start Address Register 0 (Text) _Write0((BYTES_PER_LINE * YSIZE_PHYS) >> 8); // Screen Block 1 Start Address Register 1 (Text) _Write0(YSIZE_PHYS); // Screen Block 1 Size Register _Write0(0); // Screen Block 2 Start Address Register 0 (Graphic) _Write0(0); // Screen Block 2 Start Address Register 0 (Graphic) _Write0(YSIZE_PHYS); // Screen Block 2 Size Register _Write1(0x4C); // CSR DIR: Set cursor shift direction to right _Write1(0x5A); // HDOT SCR: _Write0(0 << 0); // Horizontal Pixel Scroll bits: 0 _Write1(0x5B); // OVLAY: _Write0((0 << 4) // two layers are used | (0 << 3) // screen block 2 and 4 can display graphics | (0 << 2) // screen block 2 and 4 can display graphics | (1 << 0)); // Layer Composition Method: Exclusive-OR _Write1(0x60); // GRAYSCALE _Write0(0x01); // Bit-Per-Pixel Select bits #endif }
static F64 calculate_cpu_frequency(U32 measure_msecs) { if(measure_msecs == 0) { return 0; } // After that we declare some vars and check the frequency of the high // resolution timer for the measure process. // If there"s no high-res timer, we exit. unsigned __int64 starttime, endtime, timedif, freq, start, end, dif; if (!QueryPerformanceFrequency((LARGE_INTEGER *) &freq)) { return 0; } // Now we can init the measure process. We set the process and thread priority // to the highest available level (Realtime priority). Also we focus the // first processor in the multiprocessor system. HANDLE hProcess = GetCurrentProcess(); HANDLE hThread = GetCurrentThread(); unsigned long dwCurPriorityClass = GetPriorityClass(hProcess); int iCurThreadPriority = GetThreadPriority(hThread); unsigned long dwProcessMask, dwSystemMask, dwNewMask = 1; GetProcessAffinityMask(hProcess, &dwProcessMask, &dwSystemMask); SetPriorityClass(hProcess, REALTIME_PRIORITY_CLASS); SetThreadPriority(hThread, THREAD_PRIORITY_TIME_CRITICAL); SetProcessAffinityMask(hProcess, dwNewMask); //// Now we call a CPUID to ensure, that all other prior called functions are //// completed now (serialization) //__asm cpuid int cpu_info[4] = {-1}; __cpuid(cpu_info, 0); // We ask the high-res timer for the start time QueryPerformanceCounter((LARGE_INTEGER *) &starttime); // Then we get the current cpu clock and store it start = __rdtsc(); // Now we wart for some msecs _Delay(measure_msecs); // Sleep(uiMeasureMSecs); // We ask for the end time QueryPerformanceCounter((LARGE_INTEGER *) &endtime); // And also for the end cpu clock end = __rdtsc(); // Now we can restore the default process and thread priorities SetProcessAffinityMask(hProcess, dwProcessMask); SetThreadPriority(hThread, iCurThreadPriority); SetPriorityClass(hProcess, dwCurPriorityClass); // Then we calculate the time and clock differences dif = end - start; timedif = endtime - starttime; // And finally the frequency is the clock difference divided by the time // difference. F64 frequency = (F64)dif / (((F64)timedif) / freq); // At last we just return the frequency that is also stored in the call // member var uqwFrequency - converted to MHz return frequency / (F64)1000000; }
////로고만들기 int Mystart() { int i; int x,y; for(i=0; i<10; i++) { g_aH[i].x=6*i; //6칸씩 배열 g_aH[i].y=1; //첫번째 칸 그니까 맨 위에 적들 배열 sprintf(g_aH[i].msg,"♥"); //적의 모양 입력 } //gun 초기화 g_G.x=40; g_G.y=20; for(y=0; y<=24; y++) { for(x=0; x<1; x++) { _DrawTextColorOrg(0,0,"□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□",15); _Delay(50); } for(x=0; x<1; x++) { _DrawTextColorOrg(0,1,"□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□",15); _Delay(50); } for(x=0; x<1; x++) { _DrawTextColorOrg(0,2,"□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□",15); _Delay(50); } for(x=0; x<1; x++) { _DrawTextColorOrg(0,3,"□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□",15); _Delay(50); } for(x=0; x<1; x++) { _DrawTextColorOrg(0,4,"□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□",15); _Delay(50); } for(x=0; x<1; x++) { _DrawTextColorOrg(0,5,"□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□",15); _Delay(50); } for(x=0; x<1; x++) { _DrawTextColorOrg(0,6,"□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□",15); _Delay(50); } for(x=0; x<1; x++) { _DrawTextColorOrg(0,7,"□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□",15); _Delay(50); } for(x=0; x<1; x++) { _DrawTextColorOrg(0,8,"□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□",15); _Delay(50); } for(x=0; x<1; x++) { _DrawTextColorOrg(0,9,"□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□",15); _Delay(50); } for(x=0; x<1; x++) { _DrawTextColorOrg(0,10,"□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□",15); _Delay(50); } for(x=0; x<1; x++) { _DrawTextColorOrg(0,11,"□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□",15); _Delay(50); } for(x=0; x<1; x++) { _DrawTextColorOrg(0,12,"□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□",15); _Delay(50); } for(x=0; x<1; x++) { _DrawTextColorOrg(0,13,"□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□",15); _Delay(50); } for(x=0; x<1; x++) { _DrawTextColorOrg(0,14,"□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□",15); _Delay(50); } for(x=0; x<1; x++) { _DrawTextColorOrg(0,15,"□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□",15); _Delay(50); } for(x=0; x<1; x++) { _DrawTextColorOrg(0,16,"□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□",15); _Delay(50); } for(x=0; x<1; x++) { _DrawTextColorOrg(0,17,"□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□",15); _Delay(50); } for(x=0; x<1; x++) { _DrawTextColorOrg(0,18,"□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□",15); _Delay(50); } for(x=0; x<1; x++) { _DrawTextColorOrg(0,19,"□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□",15); _Delay(50); } for(x=0; x<1; x++) { _DrawTextColorOrg(0,20,"□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□",15); _Delay(50); } for(x=0; x<1; x++) { _DrawTextColorOrg(0,21,"□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□",15); _Delay(50); } for(x=0; x<1; x++) { _DrawTextColorOrg(0,22,"□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□",15); _Delay(50); } for(x=0; x<1; x++) { _DrawTextColorOrg(0,23,"□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□",15); _Delay(50); } for(x=0; x<1; x++) { _DrawTextColorOrg(0,24,"□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□",15); _Delay(50); } break; _Delay(50); } for(y=0; y<=12; y++) { for(x=0; x<79; x++) { _DrawTextOrg(x,12-y," "); _DrawTextOrg(x,12+y," "); } _Delay(50); } _Delay(50); /////////////////////////////// 졸라맨♡피하기 게임타이틀 찍기 for(y=0; y<=24; y++) { for(x=0; x<1; x++) { _DrawTextColorOrg(0,0," ■■■■■■ ",14); _Delay(100); } for(x=0; x<1; x++) { _DrawTextColorOrg(0,1," ■■ ■ ■ ■ ",14); _Delay(100); } for(x=0; x<1; x++) { _DrawTextColorOrg(0,2," ■ ■ ■■■■■■ ■ ■■■■■■ ■ ■ ",14); _Delay(100); } for(x=0; x<1; x++) { _DrawTextColorOrg(0,3," ■ ■■ ■ ■ ■ ■ ■ ■■■ ",14); _Delay(100); } for(x=0; x<1; x++) { _DrawTextColorOrg(0,4," ■■■■■■ ■■■■■■ ■■■ ■ ■ ■■■ ",14); _Delay(100); } for(x=0; x<1; x++) { _DrawTextColorOrg(0,5," ■■■■■■ ■ ■ ■■■■■■ ■ ■ ",14); _Delay(100); } for(x=0; x<1; x++) { _DrawTextColorOrg(0,6," ■ ■■■■■■ ■ ■ ■ ",14); _Delay(100); } for(x=0; x<1; x++) { _DrawTextColorOrg(0,7," ■■■■■■ ■ ■ ",14); _Delay(100); } for(x=0; x<1; x++) { _DrawTextColorOrg(0,8," ■ ■■■■■■■■ ",14); _Delay(100); } for(x=0; x<1; x++) { _DrawTextColorOrg(0,9," ■■■■■■ ",14); _Delay(100); } for(x=0; x<1; x++) { _DrawTextColorOrg(0,10," ■ ■ ",12); _Delay(100); } for(x=0; x<1; x++) { _DrawTextColorOrg(0,11," ■■■ ■■■ ",12); _Delay(100); } for(x=0; x<1; x++) { _DrawTextColorOrg(0,12," ■■■■■■■■■ ",12); _Delay(100); } for(x=0; x<1; x++) { _DrawTextColorOrg(0,13," ■■■■■■■ ",12); _Delay(100); } for(x=0; x<1; x++) { _DrawTextColorOrg(0,14," ■■■■■ ",12); _Delay(100); } for(x=0; x<1; x++) { _DrawTextColorOrg(0,15," ■■■ ",12); _Delay(100); } for(x=0; x<1; x++) { _DrawTextColorOrg(0,16," ■ ",12); _Delay(100); } for(x=0; x<1; x++) { _DrawTextColorOrg(0,17," ■ ■■■■ ■ ■ ",10); _Delay(100); } for(x=0; x<1; x++) { _DrawTextColorOrg(0,18," ■■■■■■ ■ ■■■■■■ ■ ■■■■■■ ■ ",10); _Delay(100); } for(x=0; x<1; x++) { _DrawTextColorOrg(0,19," ■ ■ ■ ■■ ■■■ ■ ■ ",10); _Delay(100); } for(x=0; x<1; x++) { _DrawTextColorOrg(0,20," ■ ■ ■ ■ ■ ■ ■ ■ ",10); _Delay(100); } { for(x=0; x<1; x++) { _DrawTextColorOrg(0,21," ■ ■ ■ ■ ■ ■ ■ ■ ",10); _Delay(100); } for(x=0; x<1; x++) { _DrawTextColorOrg(0,22," ■■■■■■ ■ ■ ■ ■ ■ ■ ",10); _Delay(100); } for(x=0; x<1; x++) { _DrawTextColorOrg(0,23," ■ ■■ ■ ■ ■ ",10); _Delay(100); } break; } _Delay(500); return 0; } }