亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? timer.c

?? 計算時間間隔的程序
?? C
?? 第 1 頁 / 共 3 頁
字號:
/***************************************************************************\
**  TIMING CODE MODULE (80x86 specific code!)                              **
**=========================================================================**
**  Written by Ethan Rohrer, (c) Nuthing Software, December 4, 1994        **
**                                                                         **
**  Revision History                                                       **
**  ----------------                                                       **
**  Date        Description                                                **
**  ---------   ---------------------------------------------------------  **
**  13 May 94   Initial Release                                            **
**  04 Dec 94   Updated code to conform to current coding standards/style  **
**              Allowed appl. to specify # of timers as param. to TM_Init  **
**              Standardized error handling with function _TM_Error        **
**=========================================================================**
**  This file contains code which makes use of system timer 0.  This timer **
**  normally operates at a frequency of 1.1932MHz, regardless of the speed **
**  of the CPU.  Normally, this timer is operating in mode 3 (square wave  **
**  mode), and it completes a "cycle" in 0.054926 seconds (~1/18.207       **
**  seconds).  The reason I say "normally" is because it is possible to    **
**  change the length of the cycle, which changes the timer's frequency.   **
**  This is NOT what the following code does.                              **
**                                                                         **
**  System timer 0 has its own 16 bit counter.  Here is some simplified    **
**  pseudo-code of what system timer 0 does with its counter when it is    **
**  operating in mode 3, and its frequency has not been tampered with:     **
**                                                                         **
**      counter = 65536                                                    **
**      while (counter != 0)                                               **
**          counter -= 2;                                                  **
**      counter = 65536                                                    **
**      while (counter != 0)                                               **
**          counter -= 2;                                                  **
**                                                                         **
**  You read that right.  The counter is decremented from 65536 to 0       **
**  TWICE.  This is somewhat unfortunate, because we want to read that     **
**  counter to use for our timing operations because it is very accurate.  **
**  The counter is decremented 65536 times in one timer cycle (32768       **
**  times in each while loop above).  So, the time between decrements is:  **
**                                                                         **
**      (0.054926 seconds/cycle) / (65536 decrements/cycle) =              **
**                      0.000000838 seconds/decrement = 838ns/decrement    **
**                                                                         **
**  Since the counter is decremented to 0 twice in each timer cycle, we    **
**  would only be able to time events that take no longer than 0.027463    **
**  seconds (one half of the timer cycle, the duration of one of the       **
**  while loops above).                                                    **
**                                                                         **
**  The solution used by the code in this file is to change the timer's    **
**  operation mode to mode 2.  Here is some simplified pseudo-code of what **
**  system timer 0 does with its counter when it is operating in mode 2,   **
**  and its frequency has not been tampered with:                          **
**                                                                         **
**      counter = 65536                                                    **
**      while (counter != 0)                                               **
**          counter -= 1;                                                  **
**                                                                         **
**  This solves any problems concerning the ambiguity of determining       **
**  which while loop is executing when we read the counter from the timer. **
**  But now, we have a 16 bit value which can only be used to time events  **
**  which take no longer than 0.054926 seconds (duration of one cycle).    **
**                                                                         **
**  The solution used by this code is to make use of another timer:        **
**  the "large timer", which is a 32-bit value at memory location          **
**  0x40:0x6C.  Conveniently, this "large timer" is incremented each time  **
**  system timer 0 completes a cycle (once each 0.054926 seconds).         **
**  The code in this file generates 32-bit values to represent the         **
**  time.  Obviously, we can't pack in the 16 bit counter and the 32 bit   **
**  large timer into the 32 bit time type, so we cut off the high order    **
**  16 bits of the large timer.  The following picture describes how the   **
**  time value is generated using the timers:                              **
**                                                                         **
**    31                                        0 15                   0   **
**    ------------------------------------------- ----------------------   **
**    |         L a r g e   T i m e r           | |  65535 - Counter   |   **
**    ------------------------------------------- ----------------------   **
**                         |                     |                     |   **
**                        \|/                   \|/                   \|/  **
**                         V                     V                     V   **
**                         31                  16 15                   0   **
**                         ---------------------- ----------------------   **
**                         |                 t T I M E                 |   **
**                         ---------------------- ----------------------   **
**                                                                         **
**  (Note that we have to use (65535-Counter) because Counter is being     **
**  decremented by the timer, but time is increasing)                      **
**                                                                         **
**=========================================================================**
**  USING THIS MODULE                                                      **
**      Before calling any other timing routine, you must call TM_Init(n), **
**      where  n  specifies the number of timers your application needs.   **
**      It may be a good idea to call TM_Init() in the initialization      **
**      portion of your application.                                       **
**                                                                         **
**      To begin timing an event, make a call to TM_StartTimer(tid),       **
**      where tid is an integer in the range [0..(n-1)] which specifies    **
**      which of the n timers you are starting.                            **
**                                                                         **
**      To compute the duration of the event, just call                    **
**      TM_ElapsedTime(tid), where tid is the same integer used in the     **
**      call to TM_StartTimer().                                           **
**                                                                         **
**      When you are finished with the timing routines, call TM_Close().   **
**      This should fit in nicely with the cleanup section of your         **
**      application.                                                       **
**                                                                         **
**      If your application NEEDS to handle the time computations itself,  **
**      the function TM_ReadTimer(tid) is also available.  This function   **
**      will return the current time (MOD 1 hour, approximately).  I       **
**      discourage use of this function, but discovered that I need it     **
**      for another module/library...                                      **
**                                                                         **
**      EXAMPLES                                                           **
**          A simple delaying routine:                                     **
**              void delay( tTIME duration )                               **
**              {                                                          **
**                  TM_StartTimer(0);                                      **
**                  while (TM_ElapsedTime(0) < duration)                   **
**                      ;                                                  **
**              }                                                          **
**                                                                         **
**          A fixed frame-rate game:                                       **
**              TM_Init(1);                                                **
**              while (player_not_dead)                                    **
**              {                                                          **
**                  TM_StartTimer(0);                                      **
**                  MoveMonsters();                                        **
**                  MovePlayers();                                         **
**                  UpdateDisplay();                                       **
**                  while (TM_ElapsedTime(0) < frame_duration)             **
**                      ;                                                  **
**              }                                                          **
**              TM_Close();                                                **
\***************************************************************************/

#include <dos.h>
#include <stdio.h>
#include <stdlib.h>
#include "timer.h"

/*-------------------------------- MACROS ---------------------------------*/

/* macro to return the current value of the large timer */

#define  TM_LARGE_TIMER   (*((unsigned long far *)MK_FP(0x40, 0x6C)))

/*--------------------------- GLOBAL VARIABLES ----------------------------*/

/* starting times for all of the timers this code will support */

tTIME  *gpTM_start_time = NULL;

unsigned int gTM_max_timers = 0;

/* flag to let us know if it is ok to run the timing routines */
/*     (1 = NOT safe, 0 = safe)                               */

unsigned char  gTM_module_not_initialized = 1;

/*------------------------- Error Message Strings -------------------------*/

#define TM_ERR_STR_GENERAL                                                 \
	"General (unspecified) error."
#define TM_ERR_STR_UNINITIALIZED                                           \
	"Timing routines not yet initialized.\n"                           \
	"(TM_Init() has not been called)"
#define TM_ERR_STR_BAD_TIMER_ID                                            \
	"Application specified an invalid timer ID."
#define TM_ERR_STR_ALLOC                                                   \
	"Unable to allocate dynamic memory."
#define TM_ERR_STR_ZERO_TIMERS                                             \
	"Application requested 0 timers.\n"                                \
	"(must request 1 or more timers to use this module)"

/*------------------------- Error Message Indices -------------------------*/
/* (Make sure these indices are accurate according to gpTM_error_text[]     */
/* declared below !!)                                                      */

#define TM_ERR_GENERAL           0
#define TM_ERR_UNINITIALIZED     1
#define TM_ERR_BAD_TIMER_ID      2
#define TM_ERR_ALLOC             3
#define TM_ERR_ZERO_TIMERS       4

/*------------------------- Error Message Strings -------------------------*/
/* (Make sure the positions of the error messages in this array are        */
/* accurately represented by the error messages indices listed above !!)   */

char *gpTM_error_text[] =
{
    TM_ERR_STR_GENERAL,
    TM_ERR_STR_UNINITIALIZED,
    TM_ERR_STR_BAD_TIMER_ID,
    TM_ERR_STR_ALLOC,
    TM_ERR_STR_ZERO_TIMERS
};

/***************************************************************************\
**  void _TM_Error( )                                                      **
*****************************************************************************
**  ARGUMENTS                                                              **
**      const char *pCalling_function_name                                 **
**          (I) name of the calling function                               **
**      int error_number                                                   **
**          (I) integer identifier of the error that occurred              **
**      const char *pCustom_message                                        **
**          (I) additional message text to be displayed                    **
**-------------------------------------------------------------------------**
**  RETURNS                                                                **
**      void                                                               **
**-------------------------------------------------------------------------**
**  EXAMPLE USAGE (NOT INTENDED FOR EXTERNAL USE)                          **
**      if ( gTM_module_not_initialized )                                  **
**      {                                                                  **
**          _TM_Error ( pFunction_name, TM_ERR_UNINITIALIZED, NULL ); <-<< **
**          return;                                                        **
**      }                                                                  **
**-------------------------------------------------------------------------**
**  DETECTABLE ERROR CONDITIONS                                            **
**      None                                                               **
**-------------------------------------------------------------------------**
**  DESCRIPTION                                                            **
**      This function will generate a message which will be sent to stderr **
**      to inform the user of an error.  This message will include the     **
**      name of the function the error occurred in (if supplied), a canned **
**      error string for the error indicated, and a custom string (if      **
**      supplied) which may provide more details about th error.           **
**-------------------------------------------------------------------------**
**  LIMITATIONS                                                            **
**      The message text must not exceed 1024 bytes in size, which can     **
**      store over 12 80-character lines of text.                          **
\***************************************************************************/

void _TM_Error ( pCalling_function_name, error_number, pCustom_message )
    const char  *pCalling_function_name;
    int          error_number;
    const char  *pCustom_message;
{
    char error_message[1024];          /* buffer for message text */

    /*---------------------------------------------------------------------*\
    **  Insert the "ERROR IN MODULE "TIMER"" header string into our        **
    **  message.                                                           **
    \*---------------------------------------------------------------------*/

    sprintf ( error_message, 
	      "\n******** ERROR IN MODULE \"TIMER\" *********\n" );

    /*---------------------------------------------------------------------*\

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日本精品一级二级| 视频在线观看一区| 国产精品欧美久久久久无广告 | 国产亚洲一区字幕| 国产精品入口麻豆原神| 欧美一级爆毛片| 欧美一区二区三区免费大片| 777午夜精品视频在线播放| 91久久精品日日躁夜夜躁欧美| 国产·精品毛片| 国产福利不卡视频| 成人免费高清在线| 在线观看精品一区| 欧美理论在线播放| 91精品国产综合久久小美女| 精品国产免费人成电影在线观看四季 | 成人a区在线观看| 色一情一伦一子一伦一区| 欧美亚洲精品一区| 精品久久一区二区| 国产精品国产三级国产aⅴ无密码 国产精品国产三级国产aⅴ原创 | 欧美色综合影院| 久久久www免费人成精品| 亚洲一区二区三区四区在线免费观看| 亚洲精品国产无天堂网2021| 另类小说欧美激情| 91一区二区三区在线观看| 欧美一区二区三区色| 国产欧美精品国产国产专区| **性色生活片久久毛片| 成人美女视频在线观看18| 制服丝袜成人动漫| 中文字幕视频一区| 国产精品资源在线看| 欧美日韩日日夜夜| 亚洲综合色丁香婷婷六月图片| 久久国产精品第一页| 欧美性猛交一区二区三区精品| 久久精品亚洲麻豆av一区二区 | 亚洲一区二区视频| 欧美一卡二卡三卡四卡| 午夜精品久久久久久不卡8050 | 午夜精品久久久久久久99樱桃| 91免费观看在线| 亚洲精品国产一区二区三区四区在线 | 日韩免费福利电影在线观看| 蜜臀91精品一区二区三区| 宅男噜噜噜66一区二区66| 五月婷婷激情综合| 国产日韩欧美综合一区| 成人午夜电影小说| 亚洲综合免费观看高清完整版| 91在线云播放| 婷婷成人激情在线网| 日韩欧美www| 91麻豆文化传媒在线观看| 中文字幕在线一区免费| 欧美精品v日韩精品v韩国精品v| 久久99精品久久久久久国产越南| 日韩欧美一级精品久久| 成人午夜视频免费看| 亚洲精品久久久蜜桃| 精品少妇一区二区三区| 91久久久免费一区二区| 精品亚洲成a人| 性做久久久久久免费观看| 久久久高清一区二区三区| 欧美色成人综合| 色婷婷av一区二区三区gif| 男女性色大片免费观看一区二区 | 99精品视频免费在线观看| 日本在线不卡一区| 亚洲国产成人va在线观看天堂| 久久天天做天天爱综合色| 777亚洲妇女| 欧美不卡在线视频| 欧美日韩精品欧美日韩精品| 91在线精品一区二区三区| 国产成人亚洲综合a∨婷婷图片| 亚洲一区欧美一区| 亚洲一区二区三区三| 亚洲视频香蕉人妖| 日韩av中文在线观看| 欧美色视频在线观看| 99久久精品情趣| 9l国产精品久久久久麻豆| av福利精品导航| 欧美午夜视频网站| 欧美日韩久久一区| 久久午夜电影网| 中文字幕亚洲区| 免费在线观看精品| 97国产一区二区| 在线电影一区二区三区| 日韩一二三区视频| 亚洲制服丝袜av| 国产91露脸合集magnet | 亚洲精选一二三| 激情深爱一区二区| 6080国产精品一区二区| 色综合天天狠狠| 欧美色综合影院| 国产亚洲欧美色| 久久国产三级精品| 91高清视频免费看| 精品久久久久久久久久久久包黑料 | 精品美女一区二区| 性做久久久久久久免费看| 不卡一区二区中文字幕| 精品成人一区二区三区| 激情成人午夜视频| 欧美日韩国产高清一区二区三区| 久久久午夜电影| 久久福利资源站| 日韩一级大片在线| 国产福利一区二区三区视频| 国产女主播在线一区二区| 国产不卡在线播放| 国产欧美一区二区三区鸳鸯浴 | 中文字幕av不卡| 高清成人免费视频| 国产精品高清亚洲| 99久久er热在这里只有精品15| 欧洲一区在线电影| 亚洲日本丝袜连裤袜办公室| 国产酒店精品激情| 国产精品丝袜一区| 欧美日韩午夜在线| 日韩精品一二三| 欧美α欧美αv大片| 丁香婷婷综合色啪| 亚洲欧美日韩中文字幕一区二区三区| 99在线热播精品免费| 视频一区二区中文字幕| 国产欧美一区视频| 欧美一级一区二区| 欧美制服丝袜第一页| 蜜臀av在线播放一区二区三区 | 国产麻豆午夜三级精品| 亚洲一区二区精品久久av| 国产日产欧美一区| 欧美军同video69gay| 91蝌蚪porny九色| 国产精品18久久久久久久网站| 日本中文在线一区| 水野朝阳av一区二区三区| 国产精品区一区二区三区| 日韩无一区二区| 7777女厕盗摄久久久| 欧美日韩国产经典色站一区二区三区 | 91黄视频在线| 在线视频国内自拍亚洲视频| av一区二区不卡| 99re这里都是精品| 欧美精品高清视频| 欧美电影免费观看高清完整版 | av在线播放一区二区三区| 在线观看日韩高清av| 欧美电影影音先锋| 欧美成人官网二区| 中文字幕 久热精品 视频在线| 国产精品传媒在线| 午夜久久久影院| 不卡欧美aaaaa| 欧美怡红院视频| 欧美一级黄色录像| 亚洲一级二级三级在线免费观看| 亚洲超丰满肉感bbw| 国产精品一级黄| 色婷婷av一区| 久久久久97国产精华液好用吗| 一区在线中文字幕| 国产一区二区久久| 99精品欧美一区二区三区小说| 欧美丰满一区二区免费视频| 亚洲欧洲色图综合| 国产乱码一区二区三区| 欧美又粗又大又爽| 国产精品成人免费精品自在线观看| 亚洲成av人片一区二区梦乃| 国产在线一区观看| 91精品国产91久久久久久一区二区| 26uuu国产电影一区二区| 日韩不卡一区二区三区| 欧美精选一区二区| 日韩精品91亚洲二区在线观看| 色婷婷精品久久二区二区蜜臂av | 午夜电影一区二区三区| 国产福利精品一区二区| 中文字幕不卡三区| 紧缚奴在线一区二区三区| 在线欧美日韩精品| 亚洲人成网站色在线观看| 91视视频在线观看入口直接观看www | 成人一区二区三区在线观看| 久久久99精品免费观看| 懂色av中文字幕一区二区三区| 国产精品乱人伦一区二区| 国产精品亚洲专一区二区三区| 日韩一级片在线观看|