/* ** === WtClk.C -- Clock module for WT */ #include #include #include #include #include "wt.h" #include "wtscn.h" #include "wtsta.h" #include "wtwin.h" /*=====================*/ /*===== Constants =====*/ /*=====================*/ #define CLK_REALHDR 55 #define CLK_REALPOS 60 #define CLK_BLHDR 69 #define CLK_BLPOS 74 /*=====================*/ /*===== Variables =====*/ /*=====================*/ static byte far *tic_ptr = (byte far *) MK_FP(0x40,0x6c); static time_t timer; static struct tm *lt; static byte last_tic = 0; static int last_sec = 0; static long bl_secs = 0L; static long bl_tics = 0L; static int clk_running = 0; /*=====================*/ /*===== Functions =====*/ /*=====================*/ /*****************************************/ /* */ /* clk_init(): Set up the clock display. */ /* */ /*****************************************/ void clk_init(void) { clk_running = 0; bl_secs = 0L; bl_tics = 0L; } /* End clk_init() */ /****************************************/ /* */ /* clk_start(): Start BL clock ticking. */ /* */ /****************************************/ void clk_start() { char time_str[90]; clk_running = 1; bl_secs = 0L; bl_tics = 0L; sprintf(time_str, "%4ld.%1ld", bl_tics/10L, bl_tics%10L); win_select(WIN_STAT); win_x(CLK_BLPOS); win_puts(time_str); } /* end clk_start() */ /**************************************/ /* */ /* clk_stop(): Stop BL clock ticking. */ /* */ /**************************************/ void clk_stop() { char time_str[90]; sprintf(time_str, "%4ld.%1ld", bl_tics/10L, bl_tics%10L); win_select(WIN_STAT); win_fg(BLACK); win_x(CLK_BLPOS); win_puts(time_str); clk_running = 0; } /* end clk_start() */ /*****************************************************/ /* */ /* clk_update(): display new time(s) if appropriate. */ /* */ /*****************************************************/ int clk_update() { char time_str[90]; if (*tic_ptr == last_tic) return 0; last_tic = *tic_ptr; sta_tick(); time(&timer); lt = localtime(&timer); if (lt->tm_sec == last_sec) return 1; last_sec = lt->tm_sec; sprintf(time_str, "%02d:%02d:%02d", lt->tm_hour, lt->tm_min, lt->tm_sec); sta_rwc(time_str); return 1; } /* end clk_update() */