1 /** 2 * @namespace biewlib 3 * @file biewlib/sysdep/ia16/dos/timer.c 4 * @brief This file contains implementation of timer depended part for DOS. 5 * @version - 6 * @remark this source file is part of Binary vIEW project (BIEW). 7 * The Binary vIEW (BIEW) is copyright (C) 1995 Nickols_K. 8 * All rights reserved. This software is redistributable under the 9 * licence given in the file "Licence.en" ("Licence.ru" in russian 10 * translation) distributed in the BIEW archive. 11 * @note Requires POSIX compatible development system 12 * 13 * @author Nickols_K 14 * @since 1995 15 * @note Development, fixes and improvements 16 **/ 17 #include <dos.h> 18 #include <stddef.h> 19 20 #include "biewlib/biewlib.h" 21 22 static void * original_timer = NULL; 23 static timer_callback *user_callback = NULL; 24 lib_callback(void)25static void interrupt lib_callback( void ) 26 { 27 if(user_callback) (*user_callback)(); 28 } 29 __OsSetTimerCallBack(unsigned ms,timer_callback func)30unsigned __FASTCALL__ __OsSetTimerCallBack(unsigned ms,timer_callback func) 31 { 32 if(!original_timer) 33 original_timer = (void *)getvect(0x1C); 34 user_callback = func; 35 setvect(0x1C,lib_callback); 36 return ms = 54; 37 } 38 /* Restore time callback function to original 39 state */ __OsRestoreTimer(void)40void __FASTCALL__ __OsRestoreTimer(void) 41 { 42 if(original_timer) setvect(0x1C,(void (interrupt *)())original_timer); 43 } 44