Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program KP;
- uses dos,crt;
- const
- ncnt:integer = 222;
- notes: array[0..221] of integer =(659, 0,659, 0,659, 0,523, 0,659, 0,784, 0,392, 0,523, 0,392, 0,330, 0,440, 0,494, 0,
- 466, 0,440, 0,392, 0,659, 0,784, 0,880, 0,698, 0,784, 0,659, 0,523, 0,587, 0,494, 0,523, 0,392, 0,330, 0,440, 0,494,
- 0,466, 0,440, 0,392, 0,659, 0,784, 0,880, 0,698, 0,784, 0,659, 0,523, 0,587, 0,494, 0,
- 0,784, 0,740, 0,698, 0,622, 0,659, 0,415, 0,440, 0,523, 0,440, 0,523, 0,587, 0,
- 0,784, 0,740, 0,698, 0,622, 0,659, 0,1046, 0,1046, 0,1046, 0,
- 0,784, 0,740, 0,698, 0,622, 0,659, 0,415, 0,440, 0,523, 0,440, 0,523, 0,587, 0,
- 0,622, 0,587, 0,523, 0,
- 0,784, 0,740, 0,698, 0,622, 0,659, 0,415, 0,440, 0,523, 0,440, 0,523, 0,587, 0,
- 0,784, 0,740, 0,698, 0,622, 0,659, 0,1046, 0,1046, 0,1046, 0,
- 0,784, 0,740, 0,698, 0,622, 0,659, 0,415, 0,440, 0,523, 0,440, 0,523, 0,587, 0,
- 0,622, 0,587, 0,523, 0);
- pause: array[0..221] of integer =(180,20,180,200,360,20,180,20,180,200,360,380,360,380,360,200,180,380,180,380,180,200,180,200,
- 180,20,180,200,180,20,180,20,180,20,180,200,180,20,360,20,180,200,180,20,180,20,180,380,360,200,180,380,180,380,180,200,180,
- 200,180,20,180,200,180,20,180,20,180,20,180,200,180,20,360,20,180,200,180,20,180,20,180,380,
- 360,180,10,180,10,180,10,180,200,180,200,180,20,180,20,180,200,180,20,180,20,180,20,
- 360,180,10,180,10,180,10,180,200,180,200, 180,200, 180,20, 180,560,
- 360,180,10,180,10,180,10,180,200,180,200,180,20,180,20,180,200,180,20,180,20,180,20,
- 360,180,380,180,380,180,1000,
- 360,180,10,180,10,180,10,180,200,180,200,180,20,180,20,180,200,180,20,180,20,180,20,
- 360,180,10,180,10,180,10,180,200,180,200, 180,200, 180,20, 180,560,
- 360,180,10,180,10,180,10,180,200,180,200,180,20,180,20,180,200,180,20,180,20,180,20,
- 360,180,380,180,380,180,1000);
- var
- i:integer;
- curnote:integer;
- play:boolean;
- len:integer;
- PreTime:Longint;
- Tick:integer;
- C:char;
- MAINLOOP:boolean;
- function GetMSecs:LongInt;
- var
- H,M,S,SS:word;
- begin
- gettime(h,m,s,ss);
- GetMSecs:=ss + 100*s + 100*60*m;
- end;
- function GetTicks:LongInt;
- var
- now:Longint;
- begin
- now:=GetMsecs;
- GetTicks:=abs(now - PreTime);
- PreTime:=now;
- end;
- procedure UpdateMusic;
- begin
- if (play) then
- begin
- len:=len-(GetTicks*18);
- if(len <= 0) then
- begin
- curnote:=curnote+1;
- if (curnote >= ncnt) then
- curnote:=0;
- len:=pause[curnote];
- if (notes[curnote] = 0) then
- nosound
- else
- sound (notes[curnote]);
- end;
- end;
- end;
- procedure PausePlay;
- begin
- play:= not play;
- if (play) then
- begin
- if (notes[curnote] = 0) then
- nosound
- else
- sound(notes[curnote]);
- end
- else
- nosound;
- end;
- begin
- PreTime:=GetMSecs;
- curnote:=ncnt;
- len:=0;
- play:=true;
- MAINLOOP:=true;
- while( MAINLOOP ) do
- begin
- UpdateMusic;
- if (KeyPressed) then
- begin
- C:=ReadKey;
- if (C = #0) then C:=ReadKey;
- writeln(ord(C));
- if (C = #$20) then PausePlay;
- if (C = #$1B) then MAINLOOP:=false;
- end;
- Delay(10);
- end;
- nosound;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement