Chinaunix首页 | 论坛 | 博客
  • 博客访问: 735442
  • 博文数量: 769
  • 博客积分: 6000
  • 博客等级: 准将
  • 技术积分: 4985
  • 用 户 组: 普通用户
  • 注册时间: 2008-10-15 16:37
文章分类

全部博文(769)

文章存档

2011年(1)

2008年(768)

我的朋友

分类:

2008-10-15 16:40:52

    TC本身提供中断程序的接口,函数名记不清了,大概的过程是定义一个函数作为中断的处理程序,然后调用TC自己的函数(可以在DOS.H或BIOS.H中找到,名称与Interrupt有关)

 

    /keys.cpp
    // 按键表索引发:
    // 首先建立key_table[]作为按键表,然后根据按键扫描码改变key_table[]中的状态,
    // 这样key_table[]中所有对应的索引按键即为需要的组合键。
    // 以下程序仅对上、下、左、右四个光标键做了组合按键的处理。
    // 本程序在Borland 3.1 中调试通过。
    #include
    #include
    #include

    #define ESC 1
    #define UP 72
    #define _UP 200
    #define DOWN 80
    #define _DOWN 208
    #define LEFT 75
    #define _LEFT 203
    #define RIGHT 77
    #define _RIGHT 205

    #define NUM_KEYS 4

    #define INDEX_UP 0
    #define INDEX_DOWN 1
    #define INDEX_LEFT 2
    #define INDEX_RIGHT 3
    #ifdef __cplusplus
    #define __CPPARGS...
    #else
    #define __CPPARGS
    #endif

    char * key_table_name[NUM_KEYS]
    = {"UP","DOWN","LEFT","RIGHT" };
    int key_scan_code; // 键盘扫描码
    int key_table[NUM_KEYS]; // 按键表

    class INTERRUPT
    {// 定义中断类
    int INT;
    void far interrupt ( *Old_Int)(__CPPARGS);
    public:
    void BEGIN_INT(int Int,void far interrupt(*New_Int)(__CPPARGS));
    void END_INT(void);
    };

    void INTERRUPT::BEGIN_INT(int Int,void far interrupt(*New_Int)(__CPPARGS))
    {// 开始自定义中断处理
    INT = Int;
    Old_Int = getvect(INT);
    setvect(INT,New_Int);
    }

    void INTERRUPT::END_INT(void)
    {// 结束自定义中断处理
    setvect(INT,Old_Int);
    }

    void far interrupt special_key(__CPPARGS)

[1]  

【责编:landy】

--------------------next---------------------

阅读(427) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~