noname.c

来自「c编写的程序」· C语言 代码 · 共 83 行

C
83
字号
#include "conio.h"
#include "dos.h"
#define SPEED 15
/*获得准确的当前时间的函数*/
void get_time(int time)
{
    int t1,t2;
    union REGS in,out;
    in.h.ah=0x2c;
    int86(0x21,&in,&out);
    t1=t2=100*out.h.dh+out.h.dl;
    while(t2-t1<time)
    {
        int86(0x21,&in,&out);
        t2=100*out.h.dh+out.h.dl;
        if(t2<t1)  t2=t2+6000;
     }
}
/*发生函数*/
void sound2(int freq,int time)
{
    union
       {  long fenping;
          unsigned char c[2];
        }count;
        unsigned char ch;
        count.fenping=1193280/freq;
        outp(67,182);
        outp(66,count.c[0]);
        outp(66,count.c[1]);
        ch=inp(97);
        outp(97,ch|3);
        get_time(time);
        outp(97,ch);
}
main()
{
    int i,freq;
    int time=4*SPEED;
    char *qw="1pbnasdhdiglhg2gihljh2h4gihkhghqhgopodlhgodippoglsdonoplblblnoaldoslg2dlhohlpdhg3glpa2slpnsd4diplanaidls4siplgdgijlh4hkbnbnasasbnbnasasiglhogighljohihoglhgidls3slpdosldonlh3glas4diglhg2gihljh2hoglhgidls3slpdoslh3hlhj4h3hlpkasoalnonksd2slasid3nlgh2hlgksdis4a4a9";
    while(*qw++!='\0')
    {  i=1;
       switch(*qw)
            {
                 case 'k':  time=1*SPEED;i=0;break;
                 case '4':  time=16*SPEED;i=0;break;
                 case 'l':  time=2*SPEED;i=0;break;
                 case '1':  time=3*SPEED;i=0;break;
                 case '2':  time=8*SPEED;i=0;break;
                 case '3':  time=12*SPEED;i=0;break;
                 case 'i':  time=4*SPEED;i=0;break;
                 case 'o':  time=6*SPEED;i=0;break;
                 case 'p':  get_time(time-39);i=0;break;
                 case 'a':  freq=532;break;
                 case 's':  freq=587;break;
                 case 'd':  freq=659;break;
                 case 'f':  freq=698;break;
                 case 'g':  freq=784;break;
                 case 'h':  freq=880;break;
                 case 'j':  freq=988;break;
                 case 'z':  freq=262;break;
                 case 'x':  freq=294;break;
                 case 'c':  freq=330;break;
                 case 'v':  freq=349;break;
                 case 'b':  freq=392;break;
                 case 'n':  freq=440;break;
                 case 'm':  freq=494;break;
                 case 'q':  freq=1047;break;
                 case 'w':  freq=1175;break;
                 case 'e':  freq=1319;break;
                 case 'r':  freq=1397;break;
                 case 't':  freq=2568;break;
                 case 'y':  freq=1760;break;
                 case 'u':  freq=1976;break;
                 case '9':  return;
                 default:i=0;break;
             }
             if(i)
             sound2(freq,time);
     }
     getch();
}

⌨️ 快捷键说明

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