荔园在线

荔园之美,在春之萌芽,在夏之绽放,在秋之收获,在冬之沉淀

[回到开始] [上一篇][下一篇]


发信人: zzt (好好学习,天天向上), 信区: Program
标  题: 闹钟程序
发信站: BBS 荔园晨风站 (Wed Jan 26 10:40:22 2000), 转信

程序(一)
发信人: shield.bbs@bbs.sjtu.edu.cn (宝宝), 信区: C
标  题: 程序(一)
发信站: 饮水思源站 (Sat Mar 29 16:01:20 1997)
转信站: DUT!sjtunews!sjtubbs
出  处: bbs.sjtu.edu.cn

#include <io.h>

#include <fcntl.h>

#include <stdio.h>

#include <dos.h>

#include <conio.h>

#include <math.h>

#include <stdlib.h>

/*

Map file:

 Start  Stop   Length Name               Class



 00000H 0193DH 0193EH _TEXT              CODE

 01940H 02063H 00724H _DATA              DATA

 02064H 02067H 00004H _EMUSEG            DATA

 02068H 02069H 00002H _CRTSEG            DATA

 0206AH 0206BH 00002H _CVTSEG            DATA

 0206CH 02071H 00006H _SCNSEG            DATA

 02072H 0210DH 0009CH _BSS               BSS

 0210EH 0210EH 00000H _BSSEND            STACK

 02110H 0218FH 00080H _STACK             STACK

*/

#define sizeprogram 0x239 /* 0x239 = (0x2190 + 0x100 + 0x80 * 2) / 16      */

                          /*            |        |      |     |     |      */

                          /*            |        |      |     |for 0x31    */

                          /*            |        |      |     |DOS service */

                          /*            |        |      |     |            */

                          /*            |        |      | for makeing a    */

                          /*            |        |      | more safty stack */

                          /*            |        |      |                  */

                          /*            |        | _STACK LENGTH.          */

                          /*            |        |                         */

                          /*            |     PSP size.                    */

                          /*            |                                  */

                          /*   program size in memory.                     */

#define stackptr 0x100 /* 0x100 = 0x80(_STACK LENGTH) * 2 */



void interrupt (*oldtimer)();

void interrupt newtimer(void);

extern void _restorezero(void);



unsigned intsp,intss,myss;

static union REGS rg;

struct date dat;

struct time tim;

unsigned vseg,voffset,color;

int running = 0;

char bf[22];

unsigned v;

char tmsk[] = "%02d-%02d-%02d %02d:%02d:%02d";

int ticker = 0;

static struct SREGS seg;

struct text_info ti;



int main(int argc,char **argv)

{

  if(argc < 5)

    {

    printf("Usage: clock td_row td_column td_tcolor td_bcolor\n");

    printf("\ttd_row:    time displaying row.\n");

    printf("\ttd_column: time displaying column.\n");

    printf("\ttd_tcolor: time displaying text color.\n");

    printf("\ttd_bcolor: time displaying background color.\n");

    printf("Note:\n");

    printf("\t 0-BLACK         1-BLUE\n");

    printf("\t 2-GREEN         3-CYAN\n");

    printf("\t 4-RED           5-MAGENT\n");

    printf("\t 6-BROWN         7-LIGHTGRAY\n");

    printf("\t 8-DARKGRAY      9-LIGHTBLUE\n");

    printf("\t10-LIGHTGREEN   11-LIGHTCYAN\n");

    printf("\t12-LIGHTRED     13-LIGHTMAGENTA\n");

    printf("\t14-YELLOW       15-WHITE\n");

    return 1;

    }

  color = (abs(atoi(argv[4])) * 0x10 + abs(atoi(argv[3]))) * 0x100;

  segread(&seg);

  myss = _SS;

  oldtimer = getvect(0x1c);

  gettextinfo(&ti);

  voffset = (abs(atoi(argv[1])) * ti.screenwidth + abs(atoi(argv[2]))) * 2;

  if(ti.currmode == MONO)

    vseg = 0xb000;

    else

    vseg = 0xb800;

  gettime(&tim);

  getdate(&dat);

  _restorezero();

  rg.x.ax = 0x3100;

  rg.x.dx = sizeprogram;

  setvect(0x1c,newtimer);

  intdos(&rg,&rg);

  return 0;

}



void interrupt newtimer(void)

{

  (*oldtimer)();

  if(running == 0)

    {

    running = 1;

    disable();

    intsp = _SP;

    intss = _SS;

    _SP = stackptr;

    _SS = myss;

    enable();

    if(ticker == 0)

      {

      ticker = (((tim.ti_sec % 5) == 0)? 19: 18);

      tim.ti_sec++;

      if(tim.ti_sec == 60)

        {

        tim.ti_sec = 0;

        tim.ti_min++;

        if(tim.ti_min == 60)

          {

          tim.ti_min = 0;

          tim.ti_hour++;

          if(tim.ti_hour == 24)

            tim.ti_hour = 0;

          }

        }

      sprintf(bf,tmsk,dat.da_day,dat.da_mon,dat.da_year%100,\

             tim.ti_hour,tim.ti_min,tim.ti_sec);

      }

    --ticker;

    for(v = 0; v < 17;v++)

      poke(vseg,voffset + v * 2,color + bf[v]);

    disable();

    _SP = intsp;

    _SS = intss;

    enable();

    running = 0;

    }

}


--
m;31m※ 来源:·饮水思源站 bbs.sjtu.edu.cn·[FROM: ms.fudan.edu.cn]m
--
m;32m※ 转寄:.碧海青天 bbs.dlut.edu.cn.[FROM: 210.39.3.50]m

--



日出东方,唯我不败;
    天上地下,唯我独尊。

※ 来源:·BBS 荔园晨风站 bbs.szu.edu.cn·[FROM: 192.168.1.11]


[回到开始] [上一篇][下一篇]

荔园在线首页 友情链接:深圳大学 深大招生 荔园晨风BBS S-Term软件 网络书店