home *** CD-ROM | disk | FTP | other *** search
- /*
- * saverPC.c: hterm CRT saver for IBM-PC
- *
- * Author: HIRANO Satoshi
- * (C) 1989 Halca Computer Science Laboratory TM
- * University of Tokyo
- *
- * 1.1 89/06/20 Halca.Hirano creation; null functions
- * 1.2 89/07/20 Halca.Hirano add kermit timer
- * ----- V2.3.-1 distributin ----
- * 1.3 89/09/17 Halca.Hirano add special saver attachment mechanism
- * ---- V2.4.0 distribution ----
- * 1.4 89/12/03 Halca.Hirano
- * add BS key watcher timer
- *
- * $Header: saverpc.cv 1.9 90/07/03 22:59:24 hirano Exp $
- */
-
-
- #include "option.h"
- #include <stdio.h>
- #include "config.h"
- #include "hterm.h"
- #include "default.h"
- #include "global.h"
-
- /*
- * saver type description
- *
- * TO ADD YOUR SAVER:
- * 0) make source.c
- * 1) add extern void FAR newSaver() to next line
- * 2) add saverInfo in savers[]
- * 3) add source.c in makefile
- */
- static void FAR blankSaver();
-
- struct saverInfo {
- char *name;
- void (FAR *saverFunc)();
- };
-
- struct saverInfo savers[] = {
- {" Blank Saver ", blankSaver},
- /* Insert your saver here. */
- };
-
- void (interrupt FAR *oldVect)();
-
- static void FAR INTERRUPT timerHandler(void );
- static void timerInit(void );
-
-
- void saverInit()
- {
- saver = DEFAULT_CRT_SAVER;
- maxSaverType = sizeof(savers)/sizeof(savers[0]) - 1;
- saverType = DEFAULT_SAVER_TYPE; /* maybe blank saver */
- oldVect = 0;
- saverReInit();
- }
-
- void saverReInit()
- {
- setTimerValue(); /* set timerLoadValue non zero */
- timerInit(); /* iniz timer interrupt */
- }
-
- static void interrupt FAR timerHandler()
- {
- /*
- * 54.95 msec timer (18.2 ticks/sec)
- */
- --timerValue;
- --kermitTimer;
- --portTimer;
- --bsKeyWatcherTimer;
- --blinkTimer;
- }
-
- static void timerInit()
- {
- oldVect = GET_DOSVECT(TIMER_VECT);
- SET_DOSVECT(TIMER_VECT, timerHandler);
- }
-
- void saverSetup()
- {
- setTimerValue();
- if (saverType > maxSaverType)
- saverType = 0;
- }
-
- void saverEnd()
- {
- timerLoadValue = 0;
- if (oldVect)
- SET_DOSVECT(TIMER_VECT, oldVect);
- oldVect = 0;
- }
-
- char *saverName(n)
- int n;
- {
- return(savers[n].name);
- }
-
- void setTimerValue()
- {
- switch (saver) {
- case CRT_SAVER_3:
- timerLoadValue = 3 * 60 * 18; /* 3 min */
- break;
- case CRT_SAVER_OFF:
- case CRT_SAVER_10:
- default:
- timerLoadValue = 10 * 60 * 18; /* 10 min */
- break;
- }
- bsKeyWatcherTimer = BS_WATCHER_SAMPLING_TIME*TICK_SEC;
- }
-
- void CRTSaver()
- {
- if (saverType > maxSaverType)
- saverType = 0;
- savePage(page0Save);
- textCRTOnOff(NO); /* erase text CRT */
- cursorOnOff(NO);
- /*
- * call saver
- */
- (*savers[saverType].saverFunc)();
- restorePage(page0Save);
- timerValue = timerLoadValue;
- textCRTOnOff(YES);
- cursorOnOff(cursor);
- }
-
- static void FAR blankSaver()
- /*
- * keep screen blank
- */
- {
- while (checkEvent() == 0) {
- ;
- }
- }
-