?? timerint.c
字號:
/************************************************************************
*
* Module name : TIMERINT.C
*
* Module description :
* Timer interrupt handler.
*
* Project : RTMK
*
* Target platform : DOS
*
* Compiler & Library : BC++ 3.1
*
* Author : Richard Shen
*
* Creation date : 30 August, 1995
*
************************************************************************/
#ifdef __DOS__
#include <dos.h>
#include <types.h>
#include <timerint.h>
#include "rtmkloc.h"
/************************************************************************
* F U N T I O N P R O T O T Y P E S *
************************************************************************/
static void interrupt TimerIntHandler(__CPPARGS);
/************************************************************************
* S T A T I C V A R I A B L E S *
************************************************************************/
static void interrupt (*OriginalInt1C)(__CPPARGS) = NULL;
static void (*ApplTimerFunc)(void) = NULL;
/************************************************************************
* Function name : SetTimerInt
* Description : Install timer interrupt handler (int 1cH)
* :
* Parameters : -
* Returns : -
* Author : Richard Shen
* -----------------------------------------------------------------------
* Date By Description
* -----------------------------------------------------------------------
* 30Aug95 RCS Created.
************************************************************************/
void SetTimerInt(void)
{
disable();
OriginalInt1C = getvect(0x1c);
ApplTimerFunc = NULL;
setvect(0x1c, TimerIntHandler);
enable();
} /* SetTimerInt() */
/************************************************************************
* Function name : RestoreTimerInt
* Description : Restore timer interrupt handler (int 1cH)
* :
* Parameters : -
* Returns : -
* Author : Richard Shen
* -----------------------------------------------------------------------
* Date By Description
* -----------------------------------------------------------------------
* 30Aug95 RCS Created.
************************************************************************/
void RestoreTimerInt(void)
{
disable();
if (OriginalInt1C)
{
setvect(0x1c, OriginalInt1C);
ApplTimerFunc = NULL;
} /* end of if */
enable();
} /* RestoreTimerInt() */
/************************************************************************
* Function name : TimerIntHandler
* Description : Timer interrupt handler
* :
* Parameters : -
* Returns : -
* Author : Richard Shen
* -----------------------------------------------------------------------
* Date By Description
* -----------------------------------------------------------------------
* 30Aug95 RCS Created.
************************************************************************/
static void interrupt TimerIntHandler(__CPPARGS)
{
disable();
servingInt++;
if (ApplTimerFunc != NULL)
ApplTimerFunc();
servingInt--;
outport(0x20, 0x20); /* Inform PIC end of interrupt */
enable();
} /* TimerIntHandler() */
/************************************************************************
* Function name : SetApplTimerHandler
* Description : Set up application timer service routine
* :
* Parameters : applHandler - Application service routine
* Returns : -
* Author : Richard Shen
* -----------------------------------------------------------------------
* Date By Description
* -----------------------------------------------------------------------
* 30Aug95 RCS Created.
************************************************************************/
void SetApplTimerHandler(void (*applHandler)(void))
{
disable();
ApplTimerFunc = applHandler;
enable();
} /* SetApplTimerHandler() */
#endif /* __DOS__ */
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -