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

📄 netback.c

📁 开放源码的编译器open watcom 1.6.0版的源代码
💻 C
字号:
#include <stdio.h>
#include <stdlib.h>
#include <dos.h>

#include "wattcp.h"
#include "language.h"
#include "strings.h"
#include "pctcp.h"
#include "wdpmi.h"

#define TIMER_INTR 8
#define STK_SIZE   1024


#if (DOSX)
  void backgroundon (void)
  {
    outsnl (_LANG("Use wintr_init() / wintr_enable() instead"));
    exit (3);
  }

#elif !defined(NO_INLINE_ASM)  /* MSC <=6 unsupported */

  static void (*userRoutine)(void) = NULL;
  static int inside = 0;

  #ifdef __TURBOC__
    static void interrupt (*oldinterrupt)(void);
  #else
    static void (interrupt *oldinterrupt)();
  #endif

  static void interrupt newinterrupt(void)
  {
    (*oldinterrupt)();
    DISABLE();
    if (inside)
    {
      static UINT tempstack [STK_SIZE];
  #ifdef __WATCOMC__
      stackset (&tempstack[STK_SIZE-1]);
  #else
        static UINT old_SP;
        static WORD old_SS;
        asm  mov ax,ss
        asm  mov old_SS,ax
        asm  mov ax,sp
        asm  mov old_SP,ax
        asm  mov ax,ds
        asm  mov ss,ax
        asm  lea sp,tempstack[STK_SIZE-1]

  #endif
      ENABLE();

      if (userRoutine)
        (*userRoutine)();
      tcp_tick (NULL);

      DISABLE();

  #ifdef __WATCOMC__
      stackrestore();
  #else
      asm  mov ax,old_SS
      asm  mov ss,ax
      asm  mov ax,old_SP
      asm  mov sp,ax

  #endif
      inside = 0;
    }
    ENABLE();
  }

  void backgroundon (void)
  {
    oldinterrupt = getvect (TIMER_INTR);
    setvect (TIMER_INTR, newinterrupt);
  }

  void backgroundoff (void)
  {
    setvect (TIMER_INTR, oldinterrupt);
  }

  void backgroundfn (void (*fn)())
  {
    userRoutine = fn;
  }
#endif  /* DOSX */

⌨️ 快捷键说明

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