⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 initclk.c

📁 开源DOS的C代码源程序
💻 C
字号:
/****************************************************************/
/*                                                              */
/*                           initclk.c                           */
/*                                                              */
/*                     System Clock Driver - initialization     */
/*                                                              */
/*                      Copyright (c) 1995                      */
/*                      Pasquale J. Villani                     */
/*                      All Rights Reserved                     */
/*                                                              */
/* This file is part of DOS-C.                                  */
/*                                                              */
/* DOS-C is free software; you can redistribute it and/or       */
/* modify it under the terms of the GNU General Public License  */
/* as published by the Free Software Foundation; either version */
/* 2, or (at your option) any later version.                    */
/*                                                              */
/* DOS-C is distributed in the hope that it will be useful, but */
/* WITHOUT ANY WARRANTY; without even the implied warranty of   */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See    */
/* the GNU General Public License for more details.             */
/*                                                              */
/* You should have received a copy of the GNU General Public    */
/* License along with DOS-C; see the file COPYING.  If not,     */
/* write to the Free Software Foundation, 675 Mass Ave,         */
/* Cambridge, MA 02139, USA.                                    */
/****************************************************************/

#include "portab.h"
#include "init-mod.h"

#ifdef VERSION_STRINGS
static char *RcsId =
    "$Id: initclk.c,v 1.4 2003/09/09 17:33:23 bartoldeman Exp $";
#endif

/*                                                                      */
/* WARNING - THIS DRIVER IS NON-PORTABLE!!!!                            */
/*                                                                      */

STATIC int InitBcdToByte(int x)
{
  return ((x >> 4) & 0xf) * 10 + (x & 0xf);
}

void Init_clk_driver(void)
{
  static iregs regsT = {0x200}; /* ah=0x02 */
  static iregs regsD = {0x400, 0, 0x1400, 0x101};
                      /* ah=4, ch=20^ ^cl=0, ^dh=dl=1 (2000/1/1)
                       * (above date will be set on error) */
  iregs dosregs;

  init_call_intr(0x1a, &regsT); /* get BIOS time */
  init_call_intr(0x1a, &regsD); /* get BIOS date */

  /* DosSetDate */
  dosregs.a.b.h = 0x2b;
  dosregs.c.x = 100 * InitBcdToByte(regsD.c.b.h) /* century */
                    + InitBcdToByte(regsD.c.b.l);/* year */
  dosregs.d.b.h = InitBcdToByte(regsD.d.b.h);   /* month */
  dosregs.d.b.l = InitBcdToByte(regsD.d.b.l);   /* day   */
  init_call_intr(0x21, &dosregs);

  /* DosSetTime */
  dosregs.a.b.h = 0x2d;
  dosregs.c.b.l = InitBcdToByte(regsT.c.b.l);   /* minutes */
  dosregs.c.b.h = InitBcdToByte(regsT.c.b.h);   /* hours   */
  dosregs.d.b.h = InitBcdToByte(regsT.d.b.h);   /*seconds */
  dosregs.d.b.l = 0;
  init_call_intr(0x21, &dosregs);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -